Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Write debugCallbackFatal in terms of debugCallback | #include <stdio.h>
#include <stdlib.h>
#include <vulkan/vulkan.h>
VKAPI_ATTR VkBool32 VKAPI_CALL
debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) {
fprintf(stderr, "Validation: %s\n", pCallbackData->pMessage);
return VK_FALSE;
}
VKAPI_ATTR VkBool32 VKAPI_CALL
debugCallbackFatal(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) {
int errorBitSet = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT & messageSeverity;
int isError = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT == errorBitSet;
fprintf(stderr, "Validation: %s\n", pCallbackData->pMessage);
if (isError) {
fprintf(stderr, "Aborting on validation error.\n");
abort();
}
return VK_FALSE;
}
| #include <stdio.h>
#include <stdlib.h>
#include <vulkan/vulkan.h>
VKAPI_ATTR VkBool32 VKAPI_CALL
debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) {
fprintf(stderr, "Validation: %s\n", pCallbackData->pMessage);
return VK_FALSE;
}
VKAPI_ATTR VkBool32 VKAPI_CALL
debugCallbackFatal(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) {
debugCallback(messageSeverity, messageType, pCallbackData, pUserData);
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
fprintf(stderr, "Aborting on validation error.\n");
abort();
}
return VK_FALSE;
}
|
Fix compile warning on Windows: C4273: 'threadingzeug::parallel_for' : inconsistent dll linkage | #pragma once
#include <functional>
#include <vector>
#include <threadingzeug/threadingzeug.h>
namespace threadingzeug
{
template<typename T>
THREADINGZEUG_API void parallel_for(const std::vector<T>& elements, std::function<void(const T& element)> callback);
template<typename T>
THREADINGZEUG_API void parallel_for(std::vector<T>& elements, std::function<void(T& element)> callback);
THREADINGZEUG_API void parallel_for(int start, int end, std::function<void(int i)> callback);
template<typename T>
THREADINGZEUG_API void sequential_for(const std::vector<T>& elements, std::function<void(const T& element)> callback);
template<typename T>
THREADINGZEUG_API void sequential_for(std::vector<T>& elements, std::function<void(T& element)> callback);
THREADINGZEUG_API void sequential_for(int start, int end, std::function<void(int i)> callback);
} // namespace threadingzeug
#include <threadingzeug/parallelfor.hpp>
| #pragma once
#include <functional>
#include <vector>
#include <threadingzeug/threadingzeug.h>
namespace threadingzeug
{
template<typename T>
void parallel_for(const std::vector<T>& elements, std::function<void(const T& element)> callback);
template<typename T>
void parallel_for(std::vector<T>& elements, std::function<void(T& element)> callback);
THREADINGZEUG_API void parallel_for(int start, int end, std::function<void(int i)> callback);
template<typename T>
void sequential_for(const std::vector<T>& elements, std::function<void(const T& element)> callback);
template<typename T>
void sequential_for(std::vector<T>& elements, std::function<void(T& element)> callback);
THREADINGZEUG_API void sequential_for(int start, int end, std::function<void(int i)> callback);
} // namespace threadingzeug
#include <threadingzeug/parallelfor.hpp>
|
Update for sqmodule API change. | #define MODULE sample
#include <sqmodule.h>
#include <stdio.h>
DECLARE_SQAPI
static SQInteger func(HSQUIRRELVM v)
{
static char s[] = "Hello, modules!";
SQAPI(pushstring)(v, s, sizeof(s) - 1);
return 1;
}
// Module init function
SQRESULT MODULE_INIT(HSQUIRRELVM v, HSQAPI api)
{
printf("in sqmodule_load\n");
INIT_SQAPI(api);
SQAPI(pushstring)(v, _SC("func"), -1);
SQAPI(newclosure)(v, func, 0);
SQAPI(newslot)(v, -3, SQFalse);
printf("out sqmodule_load\n");
return SQ_OK;
}
| #define MODULE sample
#include <sqmodule.h>
#include <stdio.h>
DECLARE_SQAPI
static SQInteger func(HSQUIRRELVM v)
{
static char s[] = "Hello, modules!";
SQAPI(pushstring)(v, s, sizeof(s) - 1);
return 1;
}
// Module init function
SQRESULT MODULE_INIT(HSQUIRRELVM v, HSQAPI api)
{
printf("in sqmodule_load\n");
INIT_SQAPI(v, api);
SQAPI(pushstring)(v, _SC("func"), -1);
SQAPI(newclosure)(v, func, 0);
SQAPI(newslot)(v, -3, SQFalse);
printf("out sqmodule_load\n");
return SQ_OK;
}
|
Fix indentation and update comment. | // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
# pragma once
#include <vespa/vespalib/datastore/entryref.h>
namespace search::memoryindex {
/**
* Entry per document in memory index posting list.
*/
class PostingListEntry {
mutable datastore::EntryRef _features; // reference to compressed features
public:
PostingListEntry(datastore::EntryRef features)
: _features(features)
{
}
PostingListEntry()
: _features()
{
}
datastore::EntryRef get_features() const { return _features; }
// Reference moved data (used when compacting FeatureStore)
void update_features(datastore::EntryRef features) const { _features = features; }
};
}
| // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
# pragma once
#include <vespa/vespalib/datastore/entryref.h>
namespace search::memoryindex {
/**
* Entry per document in memory index posting list.
*/
class PostingListEntry {
mutable datastore::EntryRef _features; // reference to compressed features
public:
PostingListEntry(datastore::EntryRef features)
: _features(features)
{
}
PostingListEntry()
: _features()
{
}
datastore::EntryRef get_features() const { return _features; }
/*
* Reference moved features (used when compacting FeatureStore).
* The moved features must have the same content as the original
* features.
*/
void update_features(datastore::EntryRef features) const { _features = features; }
};
}
|
Allow the trace output by mbed error to be conditional of NDEBUG. | /* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include <stdarg.h>
#include "device.h"
#include "toolchain.h"
#include "mbed_error.h"
#include "mbed_interface.h"
#if DEVICE_STDIO_MESSAGES
#include <stdio.h>
#endif
WEAK void error(const char* format, ...) {
va_list arg;
va_start(arg, format);
mbed_error_vfprintf(format, arg);
va_end(arg);
exit(1);
}
| /* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include <stdarg.h>
#include "device.h"
#include "toolchain.h"
#include "mbed_error.h"
#include "mbed_interface.h"
#if DEVICE_STDIO_MESSAGES
#include <stdio.h>
#endif
WEAK void error(const char* format, ...) {
#ifndef NDEBUG
va_list arg;
va_start(arg, format);
mbed_error_vfprintf(format, arg);
va_end(arg);
#endif
exit(1);
}
|
Add global foundation import to umbrella header | //
// ResponseDetective.h
//
// Copyright (c) 2016 Netguru Sp. z o.o. All rights reserved.
// Licensed under the MIT License.
//
/// Project version number for ResponseDetective.
extern double ResponseDetectiveVersionNumber;
/// Project version string for ResponseDetective.
extern const unsigned char ResponseDetectiveVersionString[];
#import <ResponseDetective/RDTBodyDeserializer.h>
#import <ResponseDetective/RDTXMLBodyDeserializer.h>
#import <ResponseDetective/RDTHTMLBodyDeserializer.h>
| //
// ResponseDetective.h
//
// Copyright (c) 2016 Netguru Sp. z o.o. All rights reserved.
// Licensed under the MIT License.
//
/// Project version number for ResponseDetective.
extern double ResponseDetectiveVersionNumber;
/// Project version string for ResponseDetective.
extern const unsigned char ResponseDetectiveVersionString[];
@import Foundation;
#import <ResponseDetective/RDTBodyDeserializer.h>
#import <ResponseDetective/RDTXMLBodyDeserializer.h>
#import <ResponseDetective/RDTHTMLBodyDeserializer.h>
|
Add Address, Port and IoService classes in namespace socket, and complete classes' declaration. | #ifndef _SOCKET_H_
#define _SOCKET_H_
namespace bittorrent
{
namespace socket
{
struct Buffer
{
Buffer(char *b, std::size_t bl)
: buf(b), buflen(bl), used(0) { }
char *buf;
std::size_t buflen;
std::size_t used;
};
class BufferAllocator
{
public:
static Buffer AllocBuf(std::size_t size);
static void DeallocBuf(Buffer& buf);
};
class Socket
{
public:
Socket();
void Send(Buffer& buf);
void Recv(Buffer& buf);
};
class Acceptor
{
public:
Acceptor();
};
} // namespace socket
} // namespace bittorrent
#endif // _SOCKET_H_ | #ifndef _SOCKET_H_
#define _SOCKET_H_
#include <WinSock2.h>
#include <cstddef>
namespace bittorrent
{
namespace socket
{
struct Buffer
{
Buffer(char *b, std::size_t bl)
: buf(b), buflen(bl), used(0) { }
char *buf;
std::size_t buflen;
std::size_t used;
};
class BufferAllocator
{
public:
static Buffer AllocBuf(std::size_t size);
static void DeallocBuf(Buffer& buf);
};
class Address
{
public:
static const long any = INADDR_ANY;
Address();
Address(long hladdress);
Address(const char *address);
operator long () const { return address_; }
private:
long address_;
};
class Port
{
public:
Port(short hsport);
operator short () const { return port_; }
private:
short port_;
};
class IoService;
class Socket
{
public:
Socket();
void Connect(const Address& address, const Port& port);
void Send(Buffer& buf);
void Recv(Buffer& buf);
void Close();
SOCKET GetRawSock() const;
private:
SOCKET sock_;
IoService *service_;
};
class Acceptor
{
public:
Acceptor(const Address& address, const Port& port);
void Accept(Socket& sock);
void Close();
SOCKET GetRawSock() const;
private:
SOCKET sock_;
IoService *service_;
};
class IoService
{
public:
typedef HANDLE ServiceHandle;
IoService();
void Send(Socket *socket, Buffer& buf);
void Recv(Socket *socket, Buffer& buf);
void Connect(Socket *socket, const sockaddr *name);
void Accept(Acceptor *acceptor, Socket& socket);
private:
ServiceHandle handle_;
};
} // namespace socket
} // namespace bittorrent
#endif // _SOCKET_H_ |
Update driver version to 5.03.00-k5 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k4"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k5"
|
Update driver version to 5.03.00-k4 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k3"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k4"
|
Update driver version to 5.03.00-k9 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k8"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k9"
|
Add descriptions of the CC's | /*
* registers.h
*/
#ifndef REGISTERS_H
#define REGISTERS_H
#define REGSIZE 8 /* number of registers */
/* Program Registers */
#define EAX 0x0
#define ECX 0x1
#define EDX 0x2
#define EBX 0x3
#define ESP 0x4
#define EBP 0x5
#define ESI 0x6
#define EDI 0x7
#define RNONE 0xf /* i.e. - no register needed */
/* Condition Codes (CC) */
#define ZF 0x2 /* zero flag - bit 2 of the CC */
#define SF 0x1 /* sign flag - bit 1 of the CC */
#define OF 0x0 /* overflow flag - bit 0 of the CC */
void clearCC(void);
void clearRegisters(void);
unsigned int getCC(unsigned int bitNumber);
unsigned int getRegister(int regNum);
void setCC(unsigned int bitNumber, unsigned int value);
void setRegister(int regNum, unsigned int regValue);
#endif /* REGISTERS_H */
| /*
* registers.h
*/
#ifndef REGISTERS_H
#define REGISTERS_H
#define REGSIZE 8 /* number of registers */
/* Program Registers */
#define EAX 0x0
#define ECX 0x1
#define EDX 0x2
#define EBX 0x3
#define ESP 0x4
#define EBP 0x5
#define ESI 0x6
#define EDI 0x7
#define RNONE 0xf /* i.e. - no register needed */
/* Condition Codes (CC) */
/*
* Set with each arithmetic/logical operation (OPL).
* ZF: was the result 0?
* SF: was the result < 0?
* OF: did the result overflow? (2's complement)
*/
#define ZF 0x2 /* zero flag - bit 2 of the CC */
#define SF 0x1 /* sign flag - bit 1 of the CC */
#define OF 0x0 /* overflow flag - bit 0 of the CC */
void clearCC(void);
void clearRegisters(void);
unsigned int getCC(unsigned int bitNumber);
unsigned int getRegister(int regNum);
void setCC(unsigned int bitNumber, unsigned int value);
void setRegister(int regNum, unsigned int regValue);
#endif /* REGISTERS_H */
|
Add documentation in doxygen style (use JAVA_BRIEF) | /****************************************************************************/
/* This file is part of the Simbatch project */
/* written by Jean-Sebastien Gay, ENS Lyon */
/* */
/* Copyright (c) 2007 Jean-Sebastien Gay. All rights reserved. */
/* */
/* This program is free software; you can redistribute it and/or modify it */
/* under the terms of the license (GNU LGPL) which comes with this package. */
/****************************************************************************/
#ifndef _BATCH_H_
#define _BATCH_H_
/*
* Simulates the behavior of a Batch system
* MSG_tasks to use when calling the function:
* SB_TASK
* SB_RES to make reservations
* SB_ACK when a task has been done
* SB_DIET when working with DIET
* SED_PRED to perform a prediction of when the task will
* be able to execute
* SED_HPF
* PF_INIT to initialize the batch
*/
int SB_batch(int argc, char ** argv);
#endif
| /****************************************************************************/
/* This file is part of the Simbatch project. */
/* written by Jean-Sebastien Gay and Ghislain Charrier, ENS Lyon. */
/* */
/* Copyright (c) 2007, Simbatch Team. All rights reserved. */
/* */
/* This program is free software; you can redistribute it and/or modify it */
/* under the terms of the license (GNU LGPL) which comes with this package. */
/****************************************************************************/
#ifndef _BATCH_H_
#define _BATCH_H_
/**
* \file batch.h
* Define the batch process.
*/
/**
* Simulates the behavior of a Batch system.
*
* The behaviour of the batch process consists in responding to incoming
* messages and to schedule jobs sent by clients. Messages are MSG_task
* datatype provided by the simgrid library.
*
* Here is a short description of the different tasks received:
* SB_TASK conatins the job to schedule.
* SB_RES to make reservations.
* SB_ACK when a task has been done on a cpu. 5 cpus for a task => 5 SB_ACK.
* SB_DIET to allow Diet for using Simbatch.
* SED_PRED to perform a prediction of when the task will be able to execute.
* SED_HPF (work in progess)
* PF_INIT to initialize the batch
*
* \param argc number of parameters transmitted to the SB_batch process.
* \param **argv array containing the parameters. argc and argc are
* automacilly filled by simgrid when parsing the deployment.xml file.
* \return an error code.
*/
int
SB_batch(int argc, char **argv);
#endif
|
Fix forward lval struct declaration | #ifndef __VALUES_H__
# define __VALUES_H__
#include "mpc.h"
typedef struct {
int type;
long num;
/* Error and Symbol types have some string data */
char* err;
char* sym;
/* Count and Pointer to a list of "lval*" */
int count;
struct lval** cell;
} lval;
/* Create Enumeration of Possible lval Types */
enum {
LVAL_ERR,
LVAL_NUM,
LVAL_SYM,
LVAL_SEXPR
};
/* Create Enumeration of Possible Error Types */
enum {
LERR_DIV_ZERO,
LERR_BAD_OP,
LERR_BAD_NUM
};
lval* lval_num(long);
lval* lval_err(char*);
lval* lval_sym(char*);
lval* lval_sexpr(void);
lval* lval_add(lval*, struct lval*);
void lval_del(lval*);
lval* lval_read_num(mpc_ast_t*);
lval* lval_read(mpc_ast_t*);
void lval_expr_print(lval*, char, char);
void lval_print(lval*);
void lval_println(lval*);
#endif
| #ifndef __VALUES_H__
# define __VALUES_H__
#include "mpc.h"
typedef struct s_lval {
int type;
long num;
/* Error and Symbol types have some string data */
char* err;
char* sym;
/* Count and Pointer to a list of "lval*" */
int count;
struct s_lval** cell;
} lval;
/* Create Enumeration of Possible lval Types */
enum {
LVAL_ERR,
LVAL_NUM,
LVAL_SYM,
LVAL_SEXPR
};
/* Create Enumeration of Possible Error Types */
enum {
LERR_DIV_ZERO,
LERR_BAD_OP,
LERR_BAD_NUM
};
lval* lval_num(long);
lval* lval_err(char*);
lval* lval_sym(char*);
lval* lval_sexpr(void);
lval* lval_add(lval*, struct lval*);
void lval_del(lval*);
lval* lval_read_num(mpc_ast_t*);
lval* lval_read(mpc_ast_t*);
void lval_expr_print(lval*, char, char);
void lval_print(lval*);
void lval_println(lval*);
#endif
|
Use run time parameters to control LE features | /*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTA_DISABLE_DELAY 100 /* in milliseconds */
#define BTM_WBS_INCLUDED TRUE
#define BTIF_HF_WBS_PREFERRED TRUE
#endif
| /*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTA_DISABLE_DELAY 100 /* in milliseconds */
#define BTM_WBS_INCLUDED TRUE
#define BTIF_HF_WBS_PREFERRED TRUE
#define BLE_VND_INCLUDED TRUE
#endif
|
Edit comments so they align with our C-- spec | extern void print_int(int x);
extern void print_string(char c[]);
int x;
char c;
void main(void){
// check signed-ness of char -> int conversion
x = -1;
c = x;
print_string("should get -1\ngot: ");
print_int(c);
print_string("\n\n");
x = -2147483647;
print_string("should get -2147483647\ngot: ");
print_int(x);
print_string("\n\n");
// check signed-ness of char -> int conversion
x = -2147483648;
print_string("should get -2147483648\ngot: ");
print_int(x);
print_string("\n\n");
}
| extern void print_int(int x);
extern void print_string(char c[]);
int x;
char c;
void main(void){
/* check signed-ness of char -> int conversion */
x = -1;
c = x;
print_string("should get -1\ngot: ");
print_int(c);
print_string("\n\n");
x = -2147483647;
print_string("should get -2147483647\ngot: ");
print_int(x);
print_string("\n\n");
/* check signed-ness of char -> int conversion */
x = -2147483648;
print_string("should get -2147483648\ngot: ");
print_int(x);
print_string("\n\n");
}
|
Fix typo in Monotonic Counter GUID macro name | /** @file
Monotonic Counter Architectural Protocol as defined in PI SPEC VOLUME 2 DXE
This code provides the services required to access the systems monotonic counter
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __ARCH_PROTOCOL_MONTONIC_COUNTER_H__
#define __ARCH_PROTOCOL_MONTONIC_COUNTER_H__
///
/// Global ID for the Monotonic Counter Architectural Protocol
///
#define EFI_MONTONIC_COUNTER_ARCH_PROTOCOL_GUID \
{0x1da97072, 0xbddc, 0x4b30, {0x99, 0xf1, 0x72, 0xa0, 0xb5, 0x6f, 0xff, 0x2a} }
extern EFI_GUID gEfiMonotonicCounterArchProtocolGuid;
#endif
| /** @file
Monotonic Counter Architectural Protocol as defined in PI SPEC VOLUME 2 DXE
This code provides the services required to access the systems monotonic counter
Copyright (c) 2006 - 2010, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __ARCH_PROTOCOL_MONTONIC_COUNTER_H__
#define __ARCH_PROTOCOL_MONTONIC_COUNTER_H__
///
/// Global ID for the Monotonic Counter Architectural Protocol
///
#define EFI_MONOTONIC_COUNTER_ARCH_PROTOCOL_GUID \
{0x1da97072, 0xbddc, 0x4b30, {0x99, 0xf1, 0x72, 0xa0, 0xb5, 0x6f, 0xff, 0x2a} }
extern EFI_GUID gEfiMonotonicCounterArchProtocolGuid;
#endif
|
Fix build on FreeBSD, which has no alloca.h | /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#define HAVE_ALLOCA_H 1
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#define HAVE_FSEEKO 1
/* Define to 1 if you have the `pthread' library (-lpthread). */
#define HAVE_LIBPTHREAD 1
/* Define to 1 if you have the `realpath' function. */
#define HAVE_REALPATH 1
#if defined(__MINGW32__)
#undef HAVE_ALLOCA_H
#undef HAVE_REALPATH
#endif
#if defined(_MSC_VER)
#undef HAVE_ALLOCA_H
#undef HAVE_REALPATH
#undef HAVE_LIBPTHREAD
#undef HAVE_FSEEKO
#endif
# ifndef __STDC_FORMAT_MACROS
# define __STDC_FORMAT_MACROS 1
# endif
| /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#define HAVE_ALLOCA_H 1
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#define HAVE_FSEEKO 1
/* Define to 1 if you have the `pthread' library (-lpthread). */
#define HAVE_LIBPTHREAD 1
/* Define to 1 if you have the `realpath' function. */
#define HAVE_REALPATH 1
#if defined(__MINGW32__)
#undef HAVE_ALLOCA_H
#undef HAVE_REALPATH
#endif
#if defined(_MSC_VER)
#undef HAVE_ALLOCA_H
#undef HAVE_REALPATH
#undef HAVE_LIBPTHREAD
#undef HAVE_FSEEKO
#endif
#ifdef __FreeBSD__
#undef HAVE_ALLOCA_H
#endif
# ifndef __STDC_FORMAT_MACROS
# define __STDC_FORMAT_MACROS 1
# endif
|
Fix Krazy warnings: explicit - KreBorder | /***************************************************************************
* Copyright © 2004 Jason Kivlighn <jkivlighn@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef KREBORDER_H
#define KREBORDER_H
#include <QColor>
#include <QString>
//typedef enum KreBorderStyle { None = 0, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset, Outset };
class KreBorder
{
public:
KreBorder( int w = 1, const QString & s = "none", const QColor &c = Qt::black );
int width;
QString style;
QColor color;
};
#endif //KREBORDER_H
| /***************************************************************************
* Copyright © 2004 Jason Kivlighn <jkivlighn@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef KREBORDER_H
#define KREBORDER_H
#include <QColor>
#include <QString>
//typedef enum KreBorderStyle { None = 0, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset, Outset };
class KreBorder
{
public:
explicit KreBorder( int w = 1, const QString & s = "none", const QColor &c = Qt::black );
int width;
QString style;
QColor color;
};
#endif //KREBORDER_H
|
Add var_eq unsound unknown function invalidate test | // PARAM: --set ana.activated[+] var_eq
// ldv-benchmarks: u__linux-concurrency_safety__drivers---net---ethernet---ethoc.ko.cil.c
#include <assert.h>
struct resource {
char const *name ;
unsigned long flags ;
struct resource *parent ;
struct resource *sibling ;
struct resource *child ;
};
struct resource *magic();
int main() {
struct resource *res = (struct resource *)0;
res = magic();
if (res == (struct resource *)0)
assert(1); // reachable
else
assert(1); // TODO reachable
return 0;
} | |
Fix data type for syscall return value to be native word size (ADDRINT rather than INT32) so negative system call return values are passed back correctly | #ifndef __THREAD_INFO_H
#define __THREAD_INFO_H
#include "globals.h"
#include "sift_writer.h"
#include "bbv_count.h"
#include "pin.H"
#include <deque>
typedef struct {
Sift::Writer *output;
std::deque<ADDRINT> *dyn_address_queue;
Bbv *bbv;
UINT64 thread_num;
ADDRINT bbv_base;
UINT64 bbv_count;
ADDRINT bbv_last;
BOOL bbv_end;
UINT64 blocknum;
UINT64 icount;
UINT64 icount_detailed;
UINT32 last_syscall_number;
UINT32 last_syscall_returnval;
UINT64 flowcontrol_target;
ADDRINT tid_ptr;
ADDRINT last_routine;
BOOL last_syscall_emulated;
BOOL running;
#if defined(TARGET_IA32)
uint8_t __pad[41];
#elif defined(TARGET_INTEL64)
uint8_t __pad[13];
#endif
} __attribute__((packed)) thread_data_t;
extern thread_data_t *thread_data;
void initThreads();
#endif // __THREAD_INFO_H
| #ifndef __THREAD_INFO_H
#define __THREAD_INFO_H
#include "globals.h"
#include "sift_writer.h"
#include "bbv_count.h"
#include "pin.H"
#include <deque>
typedef struct {
Sift::Writer *output;
std::deque<ADDRINT> *dyn_address_queue;
Bbv *bbv;
UINT64 thread_num;
ADDRINT bbv_base;
UINT64 bbv_count;
ADDRINT bbv_last;
BOOL bbv_end;
UINT64 blocknum;
UINT64 icount;
UINT64 icount_detailed;
ADDRINT last_syscall_number;
ADDRINT last_syscall_returnval;
UINT64 flowcontrol_target;
ADDRINT tid_ptr;
ADDRINT last_routine;
BOOL last_syscall_emulated;
BOOL running;
#if defined(TARGET_IA32)
uint8_t __pad[41];
#elif defined(TARGET_INTEL64)
uint8_t __pad[5];
#endif
} __attribute__((packed)) thread_data_t;
extern thread_data_t *thread_data;
void initThreads();
#endif // __THREAD_INFO_H
|
Add note on OAEP version implemented | /*
* OAEP
* (C) 1999-2007 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_OAEP_H_
#define BOTAN_OAEP_H_
#include <botan/eme.h>
#include <botan/hash.h>
namespace Botan {
/**
* OAEP (called EME1 in IEEE 1363 and in earlier versions of the library)
*/
class BOTAN_PUBLIC_API(2,0) OAEP final : public EME
{
public:
size_t maximum_input_size(size_t) const override;
/**
* @param hash function to use for hashing (takes ownership)
* @param P an optional label. Normally empty.
*/
OAEP(HashFunction* hash, const std::string& P = "");
private:
secure_vector<uint8_t> pad(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const override;
secure_vector<uint8_t> unpad(uint8_t& valid_mask,
const uint8_t in[],
size_t in_len) const override;
secure_vector<uint8_t> m_Phash;
std::unique_ptr<HashFunction> m_hash;
};
}
#endif
| /*
* OAEP
* (C) 1999-2007 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_OAEP_H_
#define BOTAN_OAEP_H_
#include <botan/eme.h>
#include <botan/hash.h>
namespace Botan {
/**
* OAEP (called EME1 in IEEE 1363 and in earlier versions of the library)
* as specified in PKCS#1 v2.0 (RFC 2437)
*/
class BOTAN_PUBLIC_API(2,0) OAEP final : public EME
{
public:
size_t maximum_input_size(size_t) const override;
/**
* @param hash function to use for hashing (takes ownership)
* @param P an optional label. Normally empty.
*/
OAEP(HashFunction* hash, const std::string& P = "");
private:
secure_vector<uint8_t> pad(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const override;
secure_vector<uint8_t> unpad(uint8_t& valid_mask,
const uint8_t in[],
size_t in_len) const override;
secure_vector<uint8_t> m_Phash;
std::unique_ptr<HashFunction> m_hash;
};
}
#endif
|
Add component category for banners | #import <Foundation/Foundation.h>
/**
* Type for objects that describe a component category to use for fallbacks using `HUBComponentFallbackHandler`
*
* An application using the Hub Framework can declare any number of categories to use when performing fallback logic
* for components, in case an unknown component namespace/name combo was encountered.
*
* Ideally, a component category should be generic enough to apply to a range of components with similar visuals and
* behavior, but still contain enough information for a `HUBComponentFallbackHandler` to create appropriate fallback
* components based on them.
*/
typedef NSObject<NSCopying, NSCoding> HUBComponentCategory;
/// Category for components that have a row-like appearance, with a full screen width and a compact height
static HUBComponentCategory * const HUBComponentCategoryRow = @"row";
/// Category for components that have a card-like appearance, that are placable in a grid with compact width & height
static HUBComponentCategory * const HUBComponentCategoryCard = @"card";
/// Category for components that have a carousel-like apperance, with a swipeable horizontal set of child components
static HUBComponentCategory * const HUBComponentCategoryCarousel = @"carousel";
| #import <Foundation/Foundation.h>
/**
* Type for objects that describe a component category to use for fallbacks using `HUBComponentFallbackHandler`
*
* An application using the Hub Framework can declare any number of categories to use when performing fallback logic
* for components, in case an unknown component namespace/name combo was encountered.
*
* Ideally, a component category should be generic enough to apply to a range of components with similar visuals and
* behavior, but still contain enough information for a `HUBComponentFallbackHandler` to create appropriate fallback
* components based on them.
*/
typedef NSObject<NSCopying, NSCoding> HUBComponentCategory;
/// Category for components that have a row-like appearance, with a full screen width and a compact height
static HUBComponentCategory * const HUBComponentCategoryRow = @"row";
/// Category for components that have a card-like appearance, that are placable in a grid with compact width & height
static HUBComponentCategory * const HUBComponentCategoryCard = @"card";
/// Category for components that have a carousel-like apperance, with a swipeable horizontal set of child components
static HUBComponentCategory * const HUBComponentCategoryCarousel = @"carousel";
/// Category for components that have a banner-like appearance, imagery-heavy with a full screen width and compact height
static HUBComponentCategory * const HUBComponentCategoryBanner = @"banner"; |
Add some more tests for mixing methods and properties. | __attribute__((objc_root_class))
@interface ImplicitProperties
- (id)implicitProperty;
- (void)setImplicitProperty:(id)implicitProperty;
- (void)setAnotherImplicitProperty:(int)implicitProperty;
- (int)anotherImplicitProperty;
@end
__attribute__((objc_root_class))
@interface BadImplicitProperties
- (int)nonVoidReturn;
- (int)setNonVoidReturn:(int)val;
- (void)setNonMatchingType:(id)val;
- (int)nonMatchingType;
- (int)wrongGetterArgs:(int)val;
- (void)setWrongGetterArgs:(int)val;
- (void)setWrongSetterArgs:(int)val extra:(int)another;
- (int)wrongSetterArgs;
- (int)wrongSetterArgs2;
- (void)setWrongSetterArgs2;
- (int)getterOnly;
- (void)setSetterOnly:(int)val;
@end
| __attribute__((objc_root_class))
@interface ImplicitProperties
- (id)implicitProperty;
- (void)setImplicitProperty:(id)implicitProperty;
- (void)setAnotherImplicitProperty:(int)implicitProperty;
- (int)anotherImplicitProperty;
@end
__attribute__((objc_root_class))
@interface BadImplicitProperties
- (int)nonVoidReturn;
- (int)setNonVoidReturn:(int)val;
- (void)setNonMatchingType:(id)val;
- (int)nonMatchingType;
- (int)wrongGetterArgs:(int)val;
- (void)setWrongGetterArgs:(int)val;
- (void)setWrongSetterArgs:(int)val extra:(int)another;
- (int)wrongSetterArgs;
- (int)wrongSetterArgs2;
- (void)setWrongSetterArgs2;
- (int)getterOnly;
- (void)setSetterOnly:(int)val;
@end
@protocol PropertiesProto
- (id)methodInProto;
@property id propertyInProto;
@end
__attribute__((objc_root_class))
@interface Base <PropertiesProto>
- (id)methodInBase;
@property(readonly) id propertyInBase;
- (id)methodPairInBase;
- (void)setMethodPairInBase:(id)value;
- (id)getterOnlyInBase;
- (void)setSetterOnlyInBase:(id)value;
@property id methodInProto;
- (id)propertyInProto;
- (id)methodInBaseButPropertyInProto;
@property id propertyInBaseButMethodInProto;
@end
@protocol SubProto
- (id)propertyInBaseButMethodInProto;
@property id methodInBaseButPropertyInProto;
@end
@interface Sub : Base <SubProto>
@property id methodInBase;
- (id)propertyInBase;
- (void)setMethodPairInBase:(id)value;
- (id)getterOnlyInBase;
- (void)setGetterOnlyInBase:(id)value;
- (id)setterOnlyInBase;
@end
|
Update Skia milestone to 108 | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 107
#endif
| /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 108
#endif
|
Add project website to startup message | #include <truth/cpu.h>
#include <truth/types.h>
#include <truth/log.h>
#include <truth/physical_allocator.h>
void kernel_main(void *multiboot_tables) {
init_interrupts();
enum status unused(status) = init_log("log");
init_physical_allocator(multiboot_tables);
logf("The Kernel of Truth\n\tVersion %d.%d.%d\n\tCommit %s\n", kernel_major, kernel_minor, kernel_patch, vcs_version);
halt();
}
| #include <truth/cpu.h>
#include <truth/types.h>
#include <truth/log.h>
#include <truth/physical_allocator.h>
void kernel_main(void *multiboot_tables) {
init_interrupts();
enum status unused(status) = init_log("log");
init_physical_allocator(multiboot_tables);
logf("The Kernel of Truth\n\tVersion %d.%d.%d\n\tCommit %s\n\t%s\n",
kernel_major, kernel_minor, kernel_patch, vcs_version,
project_website);
halt();
}
|
Remove unused instance variable 'workerPool_' | //
// TKDOMProxyMaker.h
// TumblKitNG
//
// Created by uasi on 09/10/31.
// Copyright 2009 99cm.org. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#import <ActorKit/ActorKit.h>
// TKDOMMaker
//
// Make a DOMDocument from given URL synchronously
//
@interface TKDOMMaker : NSObject {
NSMutableSet *workerPool_;
}
+ (id)DOMMaker;
// NOTE:
// - Do NOT perform newDOMDocumentWithURLString on the main thread
// - Returned DOMDocument MUST be released with releaseDOM:
//
- (DOMDocument *)newDOMDocumentWithURLString:(NSString *)URLString;
- (void)releaseDOM:(id)object;
@end
| //
// TKDOMProxyMaker.h
// TumblKitNG
//
// Created by uasi on 09/10/31.
// Copyright 2009 99cm.org. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#import <ActorKit/ActorKit.h>
// TKDOMMaker
//
// Make a DOMDocument from given URL synchronously
//
@interface TKDOMMaker : NSObject {
}
+ (id)DOMMaker;
// NOTE:
// - Do NOT perform newDOMDocumentWithURLString on the main thread
// - Returned DOMDocument MUST be released with releaseDOM:
//
- (DOMDocument *)newDOMDocumentWithURLString:(NSString *)URLString;
- (void)releaseDOM:(id)object;
@end
|
Add support for edge routing to ports on the periphery of nodes, and splines for multiedges. | /* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifndef MULTISPLINE_H
#define MULTISPLINE_H
#include <render.h>
#include <pathutil.h>
typedef struct router_s router_t;
extern void freeRouter (router_t* rtr);
extern router_t* mkRouter (Ppoly_t** obs, int npoly);
extern int makeMultiSpline(edge_t* e, router_t * rtr, int);
#endif
| |
Add "extern C" stuff for clean compile of tests. | #ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H
#ifdef TESTING
#define READ \
fake_read
#else
#define READ \
read
#endif
#endif
| #ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H
#ifdef TESTING
#ifdef __cplusplus
extern "C" {
#endif
ssize_t fake_read(int fd, void *buf, size_t count);
#ifdef __cplusplus
}
#endif
#define READ \
fake_read
#else
#define READ \
read
#endif
#endif
|
Add Intel Firmware Version Info (FVI) definitions | /** @file
Intel Firmware Version Info (FVI) related definitions.
@todo: update document/spec reference
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Specification Reference:
System Management BIOS (SMBIOS) Reference Specification v3.0.0 dated 2015-Feb-12
http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
**/
#ifndef __FIRMWARE_VERSION_INFO_H__
#define __FIRMWARE_VERSION_INFO_H__
#include <IndustryStandard/SmBios.h>
#define INTEL_FIRMWARE_VERSION_INFO_GROUP_NAME "Firmware Version Info"
#pragma pack(1)
///
/// Firmware Version Structure
///
typedef struct {
UINT8 MajorVersion;
UINT8 MinorVersion;
UINT8 Revision;
UINT16 BuildNumber;
} INTEL_FIRMWARE_VERSION;
///
/// Firmware Version Info (FVI) Structure
///
typedef struct {
SMBIOS_TABLE_STRING ComponentName; ///< String Index of Component Name
SMBIOS_TABLE_STRING VersionString; ///< String Index of Version String
INTEL_FIRMWARE_VERSION Version; ///< Firmware version
} INTEL_FIRMWARE_VERSION_INFO;
///
/// SMBIOS OEM Type Intel Firmware Version Info (FVI) Structure
///
typedef struct {
SMBIOS_STRUCTURE Header; ///< SMBIOS structure header
UINT8 Count; ///< Number of FVI entries in this structure
INTEL_FIRMWARE_VERSION_INFO Fvi[1]; ///< FVI structure(s)
} SMBIOS_TABLE_TYPE_OEM_INTEL_FVI;
#pragma pack()
#endif
| |
Add an example of C string hex escape quirks | /*
* Hex escapes in C code can be confusing; this is non-portable:
*
* const char *str = "\xffab";
*
* GCC will warn:
*
* warning: hex escape sequence out of range [enabled by default]
*
* To avoid this, you can e.g. use the following form:
*
* const char *str = "\xff" "ab";
*
* If the C hex escape is terminated by a character that cannot be a
* valid hex digit, there is no need for this (but breaking up the
* string is still good practice), e.g.:
*
* const char *str = "\xffquux";
*
* Another hex escape always terminates a previous hex escape. For
* instance, to write a user internal property constant with two
* leading 0xFF bytes:
*
* const char *str = "\xff\xff" "quux";
*/
#include <stdio.h>
int main(int argc, char *argv[]) {
const char *str = "\xffabcdef"; /* Generates a warning on GCC */
printf("%s\n", str);
return 0;
}
| |
Add defines header to toolkit header | //
// Toolkit header to include the main headers of the 'AFToolkit' library.
//
#pragma mark - Common Import
#import "AFLogHelper.h"
#import "AFFileHelper.h"
#import "AFPlatformHelper.h"
#import "AFKVO.h"
#import "AFArray.h"
#import "AFMutableArray.h"
#import "UITableViewCell+Universal.h"
#import "AFDBClient.h"
#import "AFView.h"
#import "AFViewController.h" | //
// Toolkit header to include the main headers of the 'AFToolkit' library.
//
#import "AFDefines.h"
#import "AFLogHelper.h"
#import "AFFileHelper.h"
#import "AFPlatformHelper.h"
#import "AFKVO.h"
#import "AFArray.h"
#import "AFMutableArray.h"
#import "UITableViewCell+Universal.h"
#import "AFDBClient.h"
#import "AFView.h"
#import "AFViewController.h" |
Add call_touch to game test | #include <kotaka/paths.h>
#include <kotaka/log.h>
#include "~/test.h"
#include <status.h>
static void create()
{
}
void ignite(int count)
{
call_out("bomb", 0, count);
}
static void bomb(int quota)
{
int max;
max = (int)sqrt((float)quota);
if (quota % max != 0) {
max = quota % max;
}
if (max > quota) {
max = quota;
}
for (; quota > 0 && max > 0; quota--, max--) {
clone_object("~/obj/bomb");
}
LOGD->post_message("test", LOG_INFO, quota + " bombs left to clone.");
if (quota > 0) {
call_out("bomb", 0, quota);
}
}
| #include <kotaka/paths.h>
#include <kotaka/log.h>
#include "~/test.h"
#include <status.h>
static void create()
{
}
void ignite(int count)
{
call_out("bomb", 0, count);
}
void touchall()
{
int i;
LOGD->post_message("test", LOG_INFO, "Beginning touch");
call_out("do_touch", 0, status(ST_OTABSIZE) - 1);
}
static void do_touch(int quota)
{
int limit;
limit = 1024;
if (quota % limit != 0) {
limit = quota % limit;
}
for (; quota >= 0 && limit > 0; quota--, limit--) {
object bomb;
if (bomb = find_object("~/obj/bomb" + quota)) {
call_touch(bomb);
}
}
LOGD->post_message("test", LOG_INFO, quota + " objects left to check for touches.");
if (quota > 0) {
call_out("do_touch", 0, quota);
}
}
static void bomb(int quota)
{
int limit;
limit = 200;
for (; quota > 0 && limit > 0; quota--, limit--) {
clone_object("~/obj/bomb");
}
LOGD->post_message("test", LOG_INFO, quota + " bombs left to clone.");
if (quota > 0) {
call_out("bomb", 0, quota);
}
}
|
UPDATE changes made to names of variables in the AIComopnent | #ifndef AIDLL_AI_AICOMPONENT_H
#define AIDLL_AI_AICOMPONENT_H
#include <DirectXMath.h>
struct AIComponent
{
int active = 0;
int entityID = -1;
int direction;
int currentPos;
int nextPos;
DirectX::XMVECTOR waypoints[8];
};
#endif | #ifndef AIDLL_AI_AICOMPONENT_H
#define AIDLL_AI_AICOMPONENT_H
#include <DirectXMath.h>
struct AIComponent
{
int active = 0;
int entityID = -1;
int direction;
int currentWaypoint;
int nextWaypoint;
DirectX::XMVECTOR waypoints[8];
};
#endif |
Make sure the sploit points to the correct target | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "shellcode.h"
#define TARGET "/tmp/target2"
int main(void)
{
char *args[3];
char *env[1];
char buf[248];
memset(buf, 0x90, 248);
strncpy(buf+195, shellcode, 45);
strncpy(buf+244, "\x08\xfd\xff\xbf", 4);
//strncpy(buf+244, "\x12\x34\x56\x78", 4);
args[0] = TARGET;
args[1] = buf;
args[2] = NULL;
env[0] = NULL;
if (0 > execve(TARGET, args, env))
fprintf(stderr, "execve failed.\n");
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "shellcode.h"
#define TARGET "/tmp/target1"
int main(void)
{
char *args[3];
char *env[1];
char buf[248];
memset(buf, 0x90, 248);
strncpy(buf+195, shellcode, 45);
strncpy(buf+244, "\x08\xfd\xff\xbf", 4);
//strncpy(buf+244, "\x12\x34\x56\x78", 4);
args[0] = TARGET;
args[1] = buf;
args[2] = NULL;
env[0] = NULL;
if (0 > execve(TARGET, args, env))
fprintf(stderr, "execve failed.\n");
return 0;
}
|
Use a copy property semantics instead of strong. | #import <KPToolbox/KPViewController.h>
@class KPNavigationController;
@interface KPNavViewController : KPViewController
@property(readwrite, weak) KPNavigationController* navigationController;
@property(readwrite, strong) NSString* navigationTitle;
@property(readwrite, strong) NSButton* backButton;
@property(readwrite, strong) IBOutlet NSView* leftNavigationBarView;
@property(readwrite, strong) IBOutlet NSView* centerNavigationBarView;
@property(readwrite, strong) IBOutlet NSView* rightNavigationBarView;
@property(readwrite, strong) IBOutlet NSView* navigationToolbar;
- (void) viewWillAppear: (BOOL) animated;
- (void) viewDidAppear: (BOOL) animated;
- (void) viewWillDisappear: (BOOL) animated;
- (void) viewDidDisappear: (BOOL) animated;
@end
| #import <KPToolbox/KPViewController.h>
@class KPNavigationController;
@interface KPNavViewController : KPViewController
@property(readwrite, weak) KPNavigationController* navigationController;
@property(readwrite, copy) NSString* navigationTitle;
@property(readwrite, strong) NSButton* backButton;
@property(readwrite, strong) IBOutlet NSView* leftNavigationBarView;
@property(readwrite, strong) IBOutlet NSView* centerNavigationBarView;
@property(readwrite, strong) IBOutlet NSView* rightNavigationBarView;
@property(readwrite, strong) IBOutlet NSView* navigationToolbar;
- (void) viewWillAppear: (BOOL) animated;
- (void) viewDidAppear: (BOOL) animated;
- (void) viewWillDisappear: (BOOL) animated;
- (void) viewDidDisappear: (BOOL) animated;
@end
|
Make adjacent difference getter consistent with other providers | #ifndef ADJACENT_DIFFERENCE_STREAM_PROVIDER_H
#define ADJACENT_DIFFERENCE_STREAM_PROVIDER_H
#include "StreamProvider.h"
#include "Utility.h"
template<typename T, typename Subtractor>
class AdjacentDifferenceStreamProvider
: public StreamProvider<ReturnType<Subtractor, T&, T&>> {
public:
using DiffType = ReturnType<Subtractor, T&, T&>;
AdjacentDifferenceStreamProvider(StreamProviderPtr<T> source,
Subtractor&& subtract)
: source_(std::move(source)), subtract_(subtract) {}
std::shared_ptr<DiffType> get() override {
return std::make_shared<DiffType>(subtract_(*second_, *first_));
}
bool advance() override {
if(first_advance_) {
first_advance_ = false;
if(source_->advance()) {
first_ = source_->get();
} else {
return false;
}
if(source_->advance()) {
second_ = source_->get();
} else {
first_.reset();
return false;
}
return true;
}
first_ = std::move(second_);
if(source_->advance()) {
second_ = source_->get();
return true;
}
first_.reset();
return false;
}
private:
StreamProviderPtr<T> source_;
Subtractor subtract_;
std::shared_ptr<T> first_;
std::shared_ptr<T> second_;
bool first_advance_ = true;
};
#endif
| #ifndef ADJACENT_DIFFERENCE_STREAM_PROVIDER_H
#define ADJACENT_DIFFERENCE_STREAM_PROVIDER_H
#include "StreamProvider.h"
#include "Utility.h"
template<typename T, typename Subtractor>
class AdjacentDifferenceStreamProvider
: public StreamProvider<ReturnType<Subtractor, T&, T&>> {
public:
using DiffType = ReturnType<Subtractor, T&, T&>;
AdjacentDifferenceStreamProvider(StreamProviderPtr<T> source,
Subtractor&& subtract)
: source_(std::move(source)), subtract_(subtract) {}
std::shared_ptr<DiffType> get() override {
return result_;
}
bool advance() override {
if(first_advance_) {
first_advance_ = false;
if(source_->advance()) {
first_ = source_->get();
} else {
return false;
}
if(source_->advance()) {
second_ = source_->get();
} else {
first_.reset();
return false;
}
result_ = std::make_shared<DiffType>(subtract_(*second_, *first_));
return true;
}
first_ = std::move(second_);
if(source_->advance()) {
second_ = source_->get();
result_ = std::make_shared<DiffType>(subtract_(*second_, *first_));
return true;
}
first_.reset();
result_.reset();
return false;
}
private:
StreamProviderPtr<T> source_;
Subtractor subtract_;
std::shared_ptr<T> first_;
std::shared_ptr<T> second_;
std::shared_ptr<DiffType> result_;
bool first_advance_ = true;
};
#endif
|
Add documentation for the laco_dispatch function | #ifndef LACO_COMMANDS_H
#define LACO_COMMANDS_H
struct LacoState;
typedef void (*LacoHandler)(struct LacoState* laco, const char** arguments);
struct LacoCommand {
const char** matches;
LacoHandler handler;
};
void laco_dispatch(const struct LacoCommand* commands,
struct LacoState* laco, const char* command_keyword,
const char** arguments);
/**
* Gets passed ever line to see if it matches one of the REPL command. If it
* does, that command will be executed.
*/
void laco_handle_command(struct LacoState* laco, char* line);
#endif /* LACO_COMMANDS_H */
| #ifndef LACO_COMMANDS_H
#define LACO_COMMANDS_H
struct LacoState;
typedef void (*LacoHandler)(struct LacoState* laco, const char** arguments);
struct LacoCommand {
const char** matches;
LacoHandler handler;
};
/**
* Goes through each instance from the list of commands and see if there is
* a match with for command_keyword. When there is a match, the defined
* handler inside the LacoCommand gets called -- passing in LacoState and
* the arguments. The list of commands expects the last entry of the array
* to be `{ NULL, NULL }` for ease of iteration.
*/
void laco_dispatch(const struct LacoCommand* commands,
struct LacoState* laco, const char* command_keyword,
const char** arguments);
/**
* Gets passed ever line to see if it matches one of the REPL command. If it
* does, that command will be executed.
*/
void laco_handle_command(struct LacoState* laco, char* line);
#endif /* LACO_COMMANDS_H */
|
Append the test runs with '&&'. | // RUN: clang -checker-simple -verify %s
// RUN: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
int data_array[10];
};
typedef struct {
int data;
} STYPE;
void g1(struct s* p);
void f(void) {
int a[10];
int (*p)[10];
p = &a;
(*p)[3] = 1;
struct s d;
struct s *q;
q = &d;
q->data = 3;
d.data_array[9] = 17;
}
void f2() {
char *p = "/usr/local";
char (*q)[4];
q = &"abc";
}
void f3() {
STYPE s;
}
void f4() {
int a[] = { 1, 2, 3};
int b[3] = { 1, 2 };
}
void f5() {
struct s data;
g1(&data);
}
| // RUN: clang -checker-simple -verify %s &&
// RUN: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
int data_array[10];
};
typedef struct {
int data;
} STYPE;
void g1(struct s* p);
void f(void) {
int a[10];
int (*p)[10];
p = &a;
(*p)[3] = 1;
struct s d;
struct s *q;
q = &d;
q->data = 3;
d.data_array[9] = 17;
}
void f2() {
char *p = "/usr/local";
char (*q)[4];
q = &"abc";
}
void f3() {
STYPE s;
}
void f4() {
int a[] = { 1, 2, 3};
int b[3] = { 1, 2 };
}
void f5() {
struct s data;
g1(&data);
}
|
Reduce ticks to 250 to use 8bit diff | #include <stdint.h>
#include "stm8s208s.h"
void main(void)
{
MEMLOC(CLK_CKDIVR) = 0x00; // Set the frequency to 16 MHz
BITSET(CLK_PCKENR1, 7);
// Configure timer
// 1000 ticks per second
MEMLOC(TIM1_PSCRH) = (16000>>8);
MEMLOC(TIM1_PSCRL) = (uint8_t)(16000 & 0xff);
// Enable timer
MEMLOC(TIM1_CR1) = 0x01;
/* Set PB0 as output */
BITSET(PB_DDR, 0);
/* Set low speed mode */
BITRST(PB_CR2, 0);
/* Set Push/Pull mode */
BITSET(PB_CR1, 0);
for(;;)
{
if ((MEMLOC(TIM1_CNTRL)) % 1000 <= 500) {
BITTOG(PB_ODR, 0);
}
}
}
| #include <stdint.h>
#include "stm8s208s.h"
void main(void)
{
MEMLOC(CLK_CKDIVR) = 0x00; /* Set the frequency to 16 MHz */
BITSET(CLK_PCKENR1, 7); /* Enable clk to TIM1 */
// Configure timer
// 250 ticks per second
MEMLOC(TIM1_PSCRH) = (64000>>8);
MEMLOC(TIM1_PSCRL) = (uint8_t)(64000 & 0xff);
MEMLOC(TIM1_CR1) = 0x01; /* Enable timer */
BITSET(PB_DDR, 0); /* Set PB0 as output */
BITRST(PB_CR2, 0); /* Set low speed mode */
BITSET(PB_CR1, 0); /* Set Push/Pull mode */
for(;;) {
if ((MEMLOC(TIM1_CNTRL)) % 250 <= 125) {
BITTOG(PB_ODR, 0);
}
}
}
|
Fix typo in test description | #include "maxminddb_test_helper.h"
void run_tests(int mode, const char *mode_desc)
{
const char *filename = "MaxMind-DB-test-decoder.mmdb";
const char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path);
const char *ip = "1.1.1.1";
MMDB_lookup_result_s result =
lookup_string_ok(mmdb, ip, filename, mode_desc);
MMDB_entry_data_s entry_data;
char *lookup_path[] = { "array", "0", NULL };
int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
cmp_ok(status, "==", MMDB_SUCCESS,
"status for MMDB_get_value() is MMDB_SUCCESS");
ok(entry_data.has_data, "found a value with MMDB_aget_value");
cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
"returned entry type is uint32");
cmp_ok(entry_data.uint32, "==", 1, "entry value is 1");
MMDB_close(mmdb);
free(mmdb);
}
int main(void)
{
plan(NO_PLAN);
for_all_modes(&run_tests);
done_testing();
}
| #include "maxminddb_test_helper.h"
void run_tests(int mode, const char *mode_desc)
{
const char *filename = "MaxMind-DB-test-decoder.mmdb";
const char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path);
const char *ip = "1.1.1.1";
MMDB_lookup_result_s result =
lookup_string_ok(mmdb, ip, filename, mode_desc);
MMDB_entry_data_s entry_data;
char *lookup_path[] = { "array", "0", NULL };
int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
cmp_ok(status, "==", MMDB_SUCCESS,
"status for MMDB_aget_value() is MMDB_SUCCESS");
ok(entry_data.has_data, "found a value with MMDB_aget_value");
cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
"returned entry type is uint32");
cmp_ok(entry_data.uint32, "==", 1, "entry value is 1");
MMDB_close(mmdb);
free(mmdb);
}
int main(void)
{
plan(NO_PLAN);
for_all_modes(&run_tests);
done_testing();
}
|
Split APPLE operating system to IOS and MAC | //
// Created by dar on 1/29/16.
//
#ifndef C003_OS_H
#define C003_OS_H
enum class OS {
WIN32 = 0,
UNIX,
ANDROID,
APPLE
};
constexpr const OS OPERATING_SYTEM =
#ifdef _WIN32
OS::WIN32
#elif __APPLE__
OS::APPLE
#elif __ANDROID__
OS::ANDROID
#elif __unix__
OS::UNIX
#endif
;
constexpr const bool IS_MOBILE = OPERATING_SYTEM == OS::ANDROID || OPERATING_SYTEM == OS::APPLE;
#endif //C003_OS_H
| //
// Created by dar on 1/29/16.
//
#ifndef C003_OS_H
#define C003_OS_H
enum class OS {
WIN32 = 0,
UNIX,
ANDROID,
IOS,
MAC
};
#ifdef __APPLE__
#include "TargetConditionals.h"
#endif
constexpr const OS OPERATING_SYTEM =
#ifdef _WIN32
OS::WIN32
#elif __APPLE__
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
OS::IOS
#elif TARGET_OS_MAC
OS::MAC
#else
#error "Unknown Apple platform"
#endif
#elif __ANDROID__
OS::ANDROID
#elif __unix__
OS::UNIX
#else
#error "Unknown platform"
#endif
;
constexpr const bool IS_MOBILE = OPERATING_SYTEM == OS::ANDROID || OPERATING_SYTEM == OS::IOS;
#endif //C003_OS_H
|
Use value from CODATA 2010. | #ifndef LIBEFP_PHYS_CONST_H
#define LIBEFP_PHYS_CONST_H
/* Bohr radius in angstroms */
#define BOHR_RADIUS 0.52917724924
#endif /* LIBEFP_PHYS_CONST_H */
| #ifndef LIBEFP_PHYS_CONST_H
#define LIBEFP_PHYS_CONST_H
/* Bohr radius in angstroms */
#define BOHR_RADIUS 0.52917721092
#endif /* LIBEFP_PHYS_CONST_H */
|
Add power down mode for idle circle | /**
* @file
* @brief Implements ARCH interface for sparc processors
*
* @date 14.02.10
* @author Eldar Abusalimov
*/
#include <hal/arch.h>
#include <asm/cache.h>
#include <hal/ipl.h>
void arch_init(void) {
cache_enable();
}
void arch_idle(void) {
}
unsigned int arch_excep_disable(void) {
unsigned int ret;
unsigned int tmp;
__asm__ __volatile__ (
"rd %%psr, %0\n\t"
"andn %0, %2, %1\n\t"
"wr %1, 0, %%psr\n\t"
" nop; nop; nop\n"
: "=&r" (ret), "=r" (tmp)
: "i" (PSR_ET)
: "memory"
);
return ret;
}
void __attribute__ ((noreturn)) arch_shutdown(arch_shutdown_mode_t mode) {
ipl_disable();
arch_excep_disable();
asm ("ta 0");
while (1) {}
}
| /**
* @file
* @brief Implements ARCH interface for sparc processors
*
* @date 14.02.10
* @author Eldar Abusalimov
*/
#include <hal/arch.h>
#include <asm/cache.h>
#include <hal/ipl.h>
void arch_init(void) {
cache_enable();
}
void arch_idle(void) {
__asm__ __volatile__ ("wr %g0, %asr19");
}
unsigned int arch_excep_disable(void) {
unsigned int ret;
unsigned int tmp;
__asm__ __volatile__ (
"rd %%psr, %0\n\t"
"andn %0, %2, %1\n\t"
"wr %1, 0, %%psr\n\t"
" nop; nop; nop\n"
: "=&r" (ret), "=r" (tmp)
: "i" (PSR_ET)
: "memory"
);
return ret;
}
void __attribute__ ((noreturn)) arch_shutdown(arch_shutdown_mode_t mode) {
ipl_disable();
arch_excep_disable();
asm ("ta 0");
while (1) {}
}
|
Fix function names in Random comment | #ifndef __MINTPACK_RANDOM_H__
#define __MINTPACK_RANDOM_H__
#include <mintomic/mintomic.h>
//-------------------------------------
// PRNG that seeds itself using various information from the environment.
// generate() is uniformly distributed across all 32-bit integer values.
// generateUnique() returns unique integers 2^32 times in a row, then repeats the sequence.
//-------------------------------------
class Random
{
private:
static const int kNumOffsets = 8;
static mint_atomic32_t m_sharedCounter;
uint32_t m_value;
uint32_t m_offsets[kNumOffsets];
public:
Random();
uint32_t generate32();
uint32_t generateUnique32();
uint64_t generate64()
{
return (((uint64_t) generate32()) << 32) | generate32();
}
};
#endif // __MINTPACK_RANDOM_H__
| #ifndef __MINTPACK_RANDOM_H__
#define __MINTPACK_RANDOM_H__
#include <mintomic/mintomic.h>
//-------------------------------------
// PRNG that seeds itself using various information from the environment.
// generate32() is uniformly distributed across all 32-bit integer values.
// generateUnique32() returns unique integers 2^32 times in a row, then repeats the sequence.
//-------------------------------------
class Random
{
private:
static const int kNumOffsets = 8;
static mint_atomic32_t m_sharedCounter;
uint32_t m_value;
uint32_t m_offsets[kNumOffsets];
public:
Random();
uint32_t generate32();
uint32_t generateUnique32();
uint64_t generate64()
{
return (((uint64_t) generate32()) << 32) | generate32();
}
};
#endif // __MINTPACK_RANDOM_H__
|
Update driver version to 5.04.00-k0 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2013 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k11"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2013 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.04.00-k0"
|
Tweak to allow building on metro. | #ifdef _WIN32
#include <time.h>
#include <winsock2.h>
#include <windows.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timeval;
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
if (tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
tmpres /= 10; /*convert into microseconds*/
/*converting file time to unix epoch*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
return 0;
}
#else
void fz_gettimeofday_dummy() { }
#endif
| #ifdef _WIN32
#include <time.h>
#ifndef METRO
#include <winsock2.h>
#endif
#include <windows.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timeval;
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
if (tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
tmpres /= 10; /*convert into microseconds*/
/*converting file time to unix epoch*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
return 0;
}
#else
void fz_gettimeofday_dummy() { }
#endif
|
Include config.h, patch by Ralf Wildenhues. | #ifndef CRITMEM_H
#define CRITMEM_H
#include <sys/types.h>
/*@only@*//*@out@*//*@notnull@*/ void *mycritmalloc(const char *f, long, size_t size,
const char *message);
/*@only@*//*@notnull@*/ void *mycritcalloc(const char *f, long, size_t size,
const char *message);
/*@only@*//*@out@*//*@notnull@*/ void *mycritrealloc(const char *f, long,
/*@null@*//*@only@*//*@out@*//*@returned@*/
void *a, size_t size,
const char *message);
/*@only@*/ char *mycritstrdup(const char *f, long, const char *,
const char *message);
#define critmalloc(a,b) mycritmalloc(__FILE__,(long)__LINE__,a,b)
#define critcalloc(a,b) mycritcalloc(__FILE__,(long)__LINE__,a,b)
#define critrealloc(a,b,c) mycritrealloc(__FILE__,(long)__LINE__,a,b,c)
#define critstrdup(a,b) mycritstrdup(__FILE__,(long)__LINE__,a,b)
#endif
| #ifndef CRITMEM_H
#define CRITMEM_H
#include "config.h"
#include <sys/types.h>
/*@only@*//*@out@*//*@notnull@*/ void *mycritmalloc(const char *f, long, size_t size,
const char *message);
/*@only@*//*@notnull@*/ void *mycritcalloc(const char *f, long, size_t size,
const char *message);
/*@only@*//*@out@*//*@notnull@*/ void *mycritrealloc(const char *f, long,
/*@null@*//*@only@*//*@out@*//*@returned@*/
void *a, size_t size,
const char *message);
/*@only@*/ char *mycritstrdup(const char *f, long, const char *,
const char *message);
#define critmalloc(a,b) mycritmalloc(__FILE__,(long)__LINE__,a,b)
#define critcalloc(a,b) mycritcalloc(__FILE__,(long)__LINE__,a,b)
#define critrealloc(a,b,c) mycritrealloc(__FILE__,(long)__LINE__,a,b,c)
#define critstrdup(a,b) mycritstrdup(__FILE__,(long)__LINE__,a,b)
#endif
|
Add test case for r194593 | // RUN: %clang -target arm-none-gnueabi -mrestrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
// RUN: %clang -target armv8a-none-gnueabi -mrestrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
// CHECK-RESTRICTED: "-backend-option" "-arm-restrict-it"
// RUN: %clang -target arm-none-gnueabi -mno-restrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-RESTRICTED < %t %s
// RUN: %clang -target armv8a-none-gnueabi -mno-restrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-RESTRICTED < %t %s
// CHECK-NO-RESTRICTED: "-backend-option" "-arm-no-restrict-it"
| |
Add 'runnable' callback to ExecutionObserver | /*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <folly/experimental/fibers/ExecutionObserver.h>
#include "mcrouter/lib/cycles/Cycles.h"
namespace facebook { namespace memcache { namespace mcrouter {
class CyclesObserver : public folly::fibers::ExecutionObserver {
public:
void starting() noexcept override {
if (!cycles::start()) {
// Should never happen
DCHECK(false) << "There is already one cycles interval "
"active in this thread";
}
}
void stopped() noexcept override {
cycles::finish();
}
};
}}} // facebook::memcache::mcrouter
| /*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <folly/experimental/fibers/ExecutionObserver.h>
#include "mcrouter/lib/cycles/Cycles.h"
namespace facebook { namespace memcache { namespace mcrouter {
class CyclesObserver : public folly::fibers::ExecutionObserver {
public:
void starting(uintptr_t id) noexcept override {
if (!cycles::start()) {
// Should never happen
DCHECK(false) << "There is already one cycles interval "
"active in this thread";
}
}
void runnable(uintptr_t id) noexcept override {}
void stopped(uintptr_t id) noexcept override {
cycles::finish();
}
};
}}} // facebook::memcache::mcrouter
|
Make syscalls from C/inline assembler | // gcc -mpreferred-stack-boundary=2 -ggdb syscall_inline.c -o syscall_inline
// syscall.s in inline asm: print to stdout and exit from inline assembler
#include <stdio.h>
void f() {
char* str = "hi\n";
__asm__(
// write str (first local variable, at %ebp-4)
"movl $4, %eax \n\t"
"movl $1, %ebx \n\t"
"movl -4(%ebp), %ecx \n\t"
"movl $3, %edx \n\t"
"int $0x80 \n\t"
// exit 0
"movl $1, %eax; \n\t"
"movl $0, %ebx; \n\t"
"int $0x80; \n\t"
);
}
int main(void) {
f();
// never called because exit
printf("skipped\n");
return 0;
}
| |
Add a macro to determine whether a GET command | /* USB commands use the first byte as the 'type' variable.
* Subsequent bytes are generally the 'arguments'.
* So host->device usb packets usually look like:
* [command, arg1, arg2, 0, 0, ... , 0, 0]
* to which the device will respond with
* [CMD_ACK, command, 0, 0, 0 ..., 0, 0]
*
* The exception to this, are the commands which 'GET'
* For them host->device generally looks like:
* [command, 0, ..., 0, 0]
* to which the device responds
* [CMD_RESP, command, arg1, arg2, 0, ..., 0, 0]
* */
#ifndef USB_COMMANDS_H
#define USB_COMMANDS_H
#define CMD_ACK 0xAF
#define CMD_RESP 0xBF
#define CMD_BL_ON 0x10
#define CMD_BL_OFF 0x11
#define CMD_BL_LEVEL 0x12
#define CMD_BL_UP 0x13
#define CMD_BL_DOWN 0x14
#define CMD_BL_GET_STATE 0x1F
#define CMD_RGB_SET 0x20
#define CMD_RGB_GET 0x2F
#endif
| /* USB commands use the first byte as the 'type' variable.
* Subsequent bytes are generally the 'arguments'.
* So host->device usb packets usually look like:
* [command, arg1, arg2, 0, 0, ... , 0, 0]
* to which the device will respond with
* [CMD_ACK, command, 0, 0, 0 ..., 0, 0]
*
* The exception to this, are the commands which 'GET'
* For them host->device generally looks like:
* [command, 0, ..., 0, 0]
* to which the device responds
* [CMD_RESP, command, arg1, arg2, 0, ..., 0, 0]
* */
#ifndef USB_COMMANDS_H
#define USB_COMMANDS_H
#define CMD_ACK 0xAF
#define CMD_RESP 0xBF
#define CMD_BL_ON 0x10
#define CMD_BL_OFF 0x11
#define CMD_BL_LEVEL 0x12
#define CMD_BL_UP 0x13
#define CMD_BL_DOWN 0x14
#define CMD_BL_GET_STATE 0x1F
#define CMD_RGB_SET 0x20
#define CMD_RGB_GET 0x2F
#define IS_GET(x) (x == CMD_RGB_GET || x == CMD_BL_GET_STATE)
#endif
|
Add a third slash for Xcode | //
// NSUserDefaults+RACSupport.h
// ReactiveCocoa
//
// Created by Matt Diephouse on 12/19/13.
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class RACChannelTerminal;
@interface NSUserDefaults (RACSupport)
// Creates and returns a terminal for binding the user defaults key.
//
// key - The user defaults key to create the channel terminal for.
//
// This makes it easy to bind a property to a default by assigning to
// `RACChannelTo`.
//
// The terminal will send the value of the user defaults key upon subscription.
//
// Returns a channel terminal.
- (RACChannelTerminal *)rac_channelTerminalForKey:(NSString *)key;
@end
| //
// NSUserDefaults+RACSupport.h
// ReactiveCocoa
//
// Created by Matt Diephouse on 12/19/13.
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class RACChannelTerminal;
@interface NSUserDefaults (RACSupport)
/// Creates and returns a terminal for binding the user defaults key.
///
/// key - The user defaults key to create the channel terminal for.
///
/// This makes it easy to bind a property to a default by assigning to
/// `RACChannelTo`.
///
/// The terminal will send the value of the user defaults key upon subscription.
///
/// Returns a channel terminal.
- (RACChannelTerminal *)rac_channelTerminalForKey:(NSString *)key;
@end
|
Change framework app name, comopany, version, and window debug | #include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#define MY_UUID { 0xE3, 0x7B, 0xFC, 0xE9, 0x30, 0xD7, 0x4B, 0xC3, 0x96, 0x93, 0x15, 0x0C, 0x35, 0xDC, 0xB8, 0x58 }
PBL_APP_INFO(MY_UUID,
"Template App", "Your Company",
1, 0, /* App version */
DEFAULT_MENU_ICON,
APP_INFO_STANDARD_APP);
Window window;
void handle_init(AppContextRef ctx) {
window_init(&window, "Window Name");
window_stack_push(&window, true /* Animated */);
}
void pbl_main(void *params) {
PebbleAppHandlers handlers = {
.init_handler = &handle_init
};
app_event_loop(params, &handlers);
}
| #include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#define MY_UUID { 0xE3, 0x7B, 0xFC, 0xE9, 0x30, 0xD7, 0x4B, 0xC3, 0x96, 0x93, 0x15, 0x0C, 0x35, 0xDC, 0xB8, 0x58 }
PBL_APP_INFO(MY_UUID,
"Puddle", "Jon Speicher",
0, 1, /* App version */
DEFAULT_MENU_ICON,
APP_INFO_STANDARD_APP);
Window window;
void handle_init(AppContextRef ctx) {
window_init(&window, "Puddle Main");
window_stack_push(&window, true /* Animated */);
}
void pbl_main(void *params) {
PebbleAppHandlers handlers = {
.init_handler = &handle_init
};
app_event_loop(params, &handlers);
}
|
Add system page size constant. | // Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved.
// Please see the AUTHORS file for details. Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.
#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_
#define UNLIKELY(x) __builtin_expect((x), 0)
#define LIKELY(x) __builtin_expect((x), 1)
#define cache_aligned __attribute__((aligned(64)))
#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))
always_inline size_t PadSize(size_t size, size_t multiple) {
return (size + multiple - 1) / multiple * multiple;
}
#endif // SCALLOC_COMMON_H_
| // Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved.
// Please see the AUTHORS file for details. Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.
#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_
#define UNLIKELY(x) __builtin_expect((x), 0)
#define LIKELY(x) __builtin_expect((x), 1)
#define cache_aligned __attribute__((aligned(64)))
#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))
const size_t kSystemPageSize = 4096;
always_inline size_t PadSize(size_t size, size_t multiple) {
return (size + multiple - 1) / multiple * multiple;
}
#endif // SCALLOC_COMMON_H_
|
Add flag to stage API change | /*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
#define GR_TEST_UTILS 1
#define SK_BUILD_FOR_ANDROID_FRAMEWORK
#define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024)
#define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
#define SK_USE_FREETYPE_EMBOLDEN
// Disable these Ganesh features
#define SK_DISABLE_REDUCE_OPLIST_SPLITTING
// Check error is expensive. HWUI historically also doesn't check its allocations
#define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0
// Legacy flags
#define SK_SUPPORT_DEPRECATED_CLIPOPS
// Staging flags
#define SK_LEGACY_PATH_ARCTO_ENDPOINT
// Needed until we fix https://bug.skia.org/2440
#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
#define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
#define SK_SUPPORT_LEGACY_AA_CHOICE
#define SK_SUPPORT_LEGACY_AAA_CHOICE
#define SK_DISABLE_DAA // skbug.com/6886
#endif // SkUserConfigManual_DEFINED
| /*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
#define GR_TEST_UTILS 1
#define SK_BUILD_FOR_ANDROID_FRAMEWORK
#define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024)
#define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
#define SK_USE_FREETYPE_EMBOLDEN
// Disable these Ganesh features
#define SK_DISABLE_REDUCE_OPLIST_SPLITTING
// Check error is expensive. HWUI historically also doesn't check its allocations
#define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0
// Legacy flags
#define SK_SUPPORT_DEPRECATED_CLIPOPS
// Staging flags
#define SK_LEGACY_PATH_ARCTO_ENDPOINT
#define SK_SUPPORT_STROKEANDFILL
// Needed until we fix https://bug.skia.org/2440
#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
#define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
#define SK_SUPPORT_LEGACY_AA_CHOICE
#define SK_SUPPORT_LEGACY_AAA_CHOICE
#define SK_DISABLE_DAA // skbug.com/6886
#endif // SkUserConfigManual_DEFINED
|
Add BSD 3-clause open source header | /* dsemem.h
*
* routines for managing a free list of DataStackEntry structs
*
*/
#ifndef _DSEMEM_H_
#define _DSEMEM_H_
#include "dataStackEntry.h"
DataStackEntry *dse_alloc(void);
void dse_free(DataStackEntry *dse);
#endif /* _DSEMEM_H_ */
| /*
* Copyright (c) 2013, Court of the University of Glasgow
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the University of Glasgow nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* dsemem.h
*
* routines for managing a free list of DataStackEntry structs
*
*/
#ifndef _DSEMEM_H_
#define _DSEMEM_H_
#include "dataStackEntry.h"
DataStackEntry *dse_alloc(void);
void dse_free(DataStackEntry *dse);
#endif /* _DSEMEM_H_ */
|
Allow to define custom program name. | #include <primitives/sw/settings_program_name.h>
#if defined(SW_EXECUTABLE)
EXPORT_FROM_EXECUTABLE
std::string getProgramName()
{
// this will trigger build error if executable forget to set
// PackageDefinitions = true;
#ifndef PACKAGE_NAME_CLEAN
#error "Set '.PackageDefinitions = true;' on your target."
#endif
return PACKAGE_NAME_CLEAN;
}
// use gitrev instead?
EXPORT_FROM_EXECUTABLE
std::string getVersionString()
{
std::string s;
s += ::sw::getProgramName();
s += " version ";
s += PACKAGE_VERSION;
s += "\n";
s += "assembled " __DATE__ " " __TIME__;
return s;
}
#endif
| #include <primitives/sw/settings_program_name.h>
#if defined(SW_EXECUTABLE) && !defined(SW_CUSTOM_PROGRAM_NAME)
EXPORT_FROM_EXECUTABLE
std::string getProgramName()
{
// this will trigger build error if executable forget to set
// PackageDefinitions = true;
#ifndef PACKAGE_NAME_CLEAN
#error "Set '.PackageDefinitions = true;' on your target."
#endif
return PACKAGE_NAME_CLEAN;
}
// use gitrev instead?
EXPORT_FROM_EXECUTABLE
std::string getVersionString()
{
std::string s;
s += ::sw::getProgramName();
s += " version ";
s += PACKAGE_VERSION;
s += "\n";
s += "assembled " __DATE__ " " __TIME__;
return s;
}
#endif
|
Add assertion util to handle OCStackResult code with exception | //******************************************************************
//
// Copyright 2015 Samsung Electronics All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#ifndef __PRIMITIVERESOURCE_ASSERTUTILS_H
#define __PRIMITIVERESOURCE_ASSERTUTILS_H
#include <cstdint>
#include <octypes.h>
#include <PrimitiveException.h>
namespace OIC
{
namespace Service
{
inline void expectOCStackResult(OCStackResult actual, OCStackResult expected)
{
if (actual != expected)
{
throw PlatformException(actual);
}
}
inline void expectOCStackResultOK(OCStackResult actual)
{
expectOCStackResult(actual, OC_STACK_OK);
}
}
}
#endif // __PRIMITIVERESOURCE_ASSERTUTILS_H
| |
Include dependencies, remove excess debugging. | //
// mysociety_config.cpp:
// Read the terrible mySociety PHP format config files, as similar code for
// other languages.
//
// Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
// Email: francis@mysociety.org; WWW: http://www.mysociety.org/
//
// $Id: mysociety_error.h,v 1.4 2009-09-24 22:00:29 francis Exp $
//
#include "error.h"
#include <iostream>
#include <fstream>
void mysociety_read_conf(const std::string& mysociety_conf_file) {
setenv("MYSOCIETY_CONFIG_FILE_PATH", mysociety_conf_file.c_str(), 1);
std::string tmp_php_script = (boost::format("/tmp/c-php-mysociety-conf-%d") % getpid()).str();
{
std::ofstream out(tmp_php_script.c_str(), std::ios::out);
out <<
"#!/usr/bin/php\n"
"<?php\n"
"$b = get_defined_constants();\n"
"require(getenv(\"MYSOCIETY_CONFIG_FILE_PATH\"));\n"
"$a = array_diff_assoc(get_defined_constants(), $b);\n"
"foreach ($a as $k => $v) {\n"
" print \"$k=$v\\n\";\n"
"}\n"
"?>\n";
}
chmod(tmp_php_script.c_str(), 0555);
FILE * f = popen(tmp_php_script.c_str(), "r");
if (f == 0) {
throw Exception("Couldn't open temporary mySociety conf PHP script");
}
const int BUFSIZE = 2048;
char buf[BUFSIZE];
while(fgets(buf, BUFSIZE, f)) {
std::string line = std::string(buf);
std::string::size_type found = line.find_first_of("=");
if (found == std::string::npos) {
throw Exception("config output had line without = in it");
}
std::string key = line.substr(0, found);
std::string value = line.substr(found + 1, line.size() - found - 2);
debug_log(boost::format("mySociety config loaded: %s %s") % key % value);
setenv(key.c_str(), value.c_str(), 1);
}
pclose(f);
}
| |
Add timer with external clock count | /*
* main.c
*
* Created on: 2 Nov 2016
* Author: rafpe
*/
#include "stm32f4xx.h"
#include "stm32f407xx.h"
int main(void)
{
volatile uint32_t delay;
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIOEEN | RCC_AHB1ENR_GPIOAEN; // enable the clock for GPIOs
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN | RCC_APB2ENR_TIM1EN; // enable SYSCFG for external interrupts & TIM1
__DSB(); // Data Synchronization Barrier
GPIOD->MODER = (1 << 26); // PIND to output mode
GPIOE->MODER = GPIO_MODER_MODER1_0; // PE1 - output
/*
* We start off with setting this is AF. Once done we map it to AF.
* PA8 to be used as alternate function TIM1_CH1
*
* AF details you always find in datasheet
* AF mapping you will find in RM
*/
GPIOA->MODER |= GPIO_MODER_MODER8_1; // PA8 - AF
GPIOA->AFR[1] = ( (GPIOA->AFR[1] && 0xFFFFFFF0 ) | 0x1);
TIM1->CCMR1 = TIM_CCMR1_CC1S_0; // CC1 channel is configured as output
TIM1->CCER = TIM_CCER_CC1P |
TIM_CCER_CC1NP; // Set up rising edge polarity
TIM1->SMCR = TIM_SMCR_TS_0 | TIM_SMCR_TS_2 | // Filtered Timer Input 1 (TI1FP1)
TIM_SMCR_SMS; // External Clock Mode 1
TIM1->ARR = 10; // How many values we will count
TIM1->DIER = TIM_DIER_UIE; // Update Event Interrupt
TIM1->CR1 = TIM_CR1_CEN; // Enable & Start timer
NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); // Set up interrupt handler
SysTick_Config(1600000);
while (1)
{
} /* while */
} /* main */
void TIM1_UP_TIM10_IRQHandler(void)
{
if (TIM1->SR & TIM_SR_UIF)
{
GPIOD->ODR ^= (1 << 13); // Blink
TIM1->SR = ~TIM_SR_UIF; // clear flag - rc_w0 => Read Clear Write 0
}
}
void SysTick_Handler(void)
{
GPIOE->ODR ^= (1 << 1); // PE1 - flapp
}
| |
Fix bugs caused by writing code while half asleep. | #ifdef __sun__
#include <pthread.h>
#include <stdlib.h>
static struct atexit_handler {
void (*f)(void *);
void *p;
void *d;
struct atexit_handler *next;
} *head;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
int __cxa_atexit( void (*f)(void *), void *p, void *d) {
pthread_mutex_lock(&lock);
struct atexit_handler *h = malloc(sizeof(*d));
if (!h) {
pthread_mutex_unlock(&lock);
return 1;
}
h->f = f;
h->p = p;
h->d = d;
h->next = head;
head = h;
pthread_mutex_unlock(&lock);
return 0;
}
void __cxa_finalize(void *d ) {
pthread_mutex_lock(&lock);
struct atexit_handler **last = &head;
for (struct atexit_handler *h = head ; h ; h = h->next) {
if ((h->d == d) || (d == 0)) {
*last = h->next;
h->f(h->p);
free(h);
} else {
last = &head->next;
}
}
pthread_mutex_unlock(&lock);
}
#endif
| #ifdef __sun__
#include <pthread.h>
#include <stdlib.h>
static struct atexit_handler {
void (*f)(void *);
void *p;
void *d;
struct atexit_handler *next;
} *head;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
int __cxa_atexit( void (*f)(void *), void *p, void *d) {
pthread_mutex_lock(&lock);
struct atexit_handler *h = malloc(sizeof(*h));
if (!h) {
pthread_mutex_unlock(&lock);
return 1;
}
h->f = f;
h->p = p;
h->d = d;
h->next = head;
head = h;
pthread_mutex_unlock(&lock);
return 0;
}
void __cxa_finalize(void *d ) {
pthread_mutex_lock(&lock);
struct atexit_handler **last = &head;
for (struct atexit_handler *h = head ; h ; h = h->next) {
if ((h->d == d) || (d == 0)) {
*last = h->next;
h->f(h->p);
free(h);
} else {
last = &h->next;
}
}
pthread_mutex_unlock(&lock);
}
#endif
|
Use different extension detection mechanism | //-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef T_GL_H
#define T_GL_H
#include "GL/glew.h"
#define gglHasExtension(EXTENSION) GLEW_##EXTENSION
#endif
| //-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef T_GL_H
#define T_GL_H
#include "GL/glew.h"
// Slower but reliably detects extensions
#define gglHasExtension(EXTENSION) glewGetExtension("GL_##EXTENSION")
#endif
|
Revert "[static analyzer][test] Test directly that driver sets D__clang_analyzer__" | // RUN: %clang -### --analyze %s 2>&1 | FileCheck %s
// CHECK: -D__clang_analyzer__
| // RUN: %clang --analyze %s
#ifndef __clang_analyzer__
#error __clang_analyzer__ not defined
#endif
|
Use time based seed for generating random numbers. | #ifndef DELAY_H
#define DELAY_H
#include <stdlib.h>
typedef struct drand48_data delay_t;
static inline void delay_init(delay_t * state, int id)
{
srand48_r(id + 1, state);
}
static inline void delay_exec(delay_t * state)
{
long n;
lrand48_r(state, &n);
int j;
for (j = 50; j < 50 + n % 100; ++j) {
__asm__ ("nop");
}
}
#endif /* end of include guard: DELAY_H */
| #ifndef DELAY_H
#define DELAY_H
#include <time.h>
#include <stdlib.h>
typedef struct drand48_data delay_t;
static inline void delay_init(delay_t * state, int id)
{
srand48_r(time(NULL) + id, state);
}
static inline void delay_exec(delay_t * state)
{
long n;
lrand48_r(state, &n);
int j;
for (j = 50; j < 50 + n % 100; ++j) {
__asm__ ("nop");
}
}
#endif /* end of include guard: DELAY_H */
|
Add an OS mutex to Halide runtime. | #ifndef HALIDE_RUNTIME_MUTEX_H
#define HALIDE_RUNTIME_MUTEX_H
#include "HalideRuntime.h"
// Avoid ODR violations
namespace {
// An RAII mutex
struct ScopedMutexLock {
halide_mutex *mutex;
ScopedMutexLock(halide_mutex *mutex) : mutex(mutex) {
halide_mutex_lock(mutex);
}
~ScopedMutexLock() {
halide_mutex_unlock(mutex);
}
};
}
#endif
| |
Add branched thread creation privatization test, where protected and mutex_inits are unsound | extern int __VERIFIER_nondet_int();
#include <pthread.h>
#include <assert.h>
int global = 5;
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
return NULL;
}
int main() {
int r = __VERIFIER_nondet_int();
pthread_t id;
if (r) {
pthread_create(&id, NULL, t_fun, NULL);
}
else {
global = 10;
}
// sync join needs to publish global also to protected/mutex_inits like enter_multithreaded
pthread_mutex_lock(&m);
assert(global == 5); // UNKNOWN!
pthread_mutex_unlock(&m);
return 0;
} | |
Add frames per second counter.. | #ifndef GFX_FPS_H
#define GFX_FPS_H
#include <chrono>
namespace GFX {
class FramesPerSecond
{
public:
FramesPerSecond() : m_millisecs(0.0), m_frames(0)
{
}
void startRender()
{
m_start = std::chrono::high_resolution_clock::now();
}
void stopRender()
{
std::chrono::time_point<std::chrono::high_resolution_clock> stop = std::chrono::high_resolution_clock::now();
++m_frames;
std::cout << "# millisecs: " << std::chrono::duration_cast<std::chrono::milliseconds>(stop - m_start).count() << std::endl;
m_millisecs += std::chrono::duration_cast<std::chrono::milliseconds>(stop - m_start).count();
}
double fps() const
{
return 1000.0 * m_frames / m_millisecs;
}
private:
std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
double m_millisecs;
int m_frames;
};
}
#endif
| |
Add do while loop examples, really | /*
* Author: Jhonatan Casale (jhc)
*
* Contact : jhonatan@jhonatancasale.com
* : casale.jhon@gmail.com
* : https://github.com/jhonatancasale
* : https://twitter.com/jhonatancasale
* : http://jhonatancasale.github.io/
*
* Create date Wed 1 Mar 02:02:10 BRT 2017
*
*/
#include <stdlib.h>
#include <stdio.h>
int main (int argc, char **argv)
{
int value = 0;
do {
printf ("Choose one:\n");
printf ("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: ");
scanf("%i", &value);
} while ( value <= 0 || value > 10 );
int i = 0;
do printf ("%i\n", i);
while ( ++i < value );
return (EXIT_SUCCESS);
}
| |
Simplify and improve definition of DSLog macro | //
// DSLogger.h
// ControlPlane
//
// Created by David Symonds on 22/07/07.
// Modified by Vladimir Beloborodov on 01 Apr 2013.
//
@interface DSLogger : NSObject
+ (void)initialize;
+ (DSLogger *)sharedLogger;
+ (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;
- (id)init;
- (void)dealloc;
- (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;
- (NSString *)buffer;
#define DSLog(format, ...) \
[DSLogger logFromFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] withInfo:[NSString stringWithFormat:(format),##__VA_ARGS__]]
@end
| //
// DSLogger.h
// ControlPlane
//
// Created by David Symonds on 22/07/07.
// Modified by Vladimir Beloborodov on 01 Apr 2013.
//
@interface DSLogger : NSObject
+ (void)initialize;
+ (DSLogger *)sharedLogger;
+ (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;
- (id)init;
- (void)dealloc;
- (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;
- (NSString *)buffer;
#define DSLog(...) \
[DSLogger logFromFunction:@(__PRETTY_FUNCTION__) withInfo:[NSString stringWithFormat:__VA_ARGS__]]
@end
|
Use C++11 `using` instead of `typedef` | #ifndef CPR_TYPES_H
#define CPR_TYPES_H
#include <map>
#include <string>
namespace cpr {
class CaseInsenstiveCompare {
public:
bool operator()(const std::string& a, const std::string& b) const;
private:
static void char_to_lower(char& c);
static std::string to_lower(const std::string& a);
};
typedef std::map<std::string, std::string, CaseInsenstiveCompare> Header;
typedef std::string Url;
}
#endif
| #ifndef CPR_TYPES_H
#define CPR_TYPES_H
#include <map>
#include <string>
namespace cpr {
class CaseInsenstiveCompare {
public:
bool operator()(const std::string& a, const std::string& b) const;
private:
static void char_to_lower(char& c);
static std::string to_lower(const std::string& a);
};
using Header = std::map<std::string, std::string, CaseInsenstiveCompare>;
using Url = std::string;
}
#endif
|
Replace contents property with private array and getter. | //
// FileObject.h
// arc
//
// Created by Jerome Cheng on 19/3/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface FileObject : NSObject {
@private
NSURL* _url;
}
// The name of this object.
@property (strong, nonatomic) NSString* name;
// The full file path of this object.
@property (strong, nonatomic) NSString* path;
// The parent of this object (if any.)
@property (weak, nonatomic) FileObject* parent;
// The contents of this object.
@property id contents;
// Creates a FileObject to represent the given URL.
// url should be an object on the file system.
- (id)initWithURL:(NSURL*)url;
// Creates a FileObject to represent the given URL,
// with its parent set to the given FileObject.
- (id)initWithURL:(NSURL*)url parent:(FileObject*)parent;
// Refreshes the contents of this object by reloading
// them from the file system.
// Returns the contents when done.
- (id)refreshContents;
// Removes this object from the file system.
- (void)remove;
@end
| //
// FileObject.h
// arc
//
// Created by Jerome Cheng on 19/3/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface FileObject : NSObject {
@private
NSURL* _url;
id _contents;
}
// The name of this object.
@property (strong, nonatomic) NSString* name;
// The full file path of this object.
@property (strong, nonatomic) NSString* path;
// The parent of this object (if any.)
@property (weak, nonatomic) FileObject* parent;
// Creates a FileObject to represent the given URL.
// url should be an object on the file system.
- (id)initWithURL:(NSURL*)url;
// Creates a FileObject to represent the given URL,
// with its parent set to the given FileObject.
- (id)initWithURL:(NSURL*)url parent:(FileObject*)parent;
// Refreshes the contents of this object by reloading
// them from the file system.
// Returns the contents when done.
- (id)refreshContents;
// Gets the contents of this object.
- (id)getContents;
// Removes this object from the file system.
- (void)remove;
@end
|
Allow reading from standard input | #ifndef NORCSID
static char rcsid[]= "$Header$";
#endif
#include <stdio.h>
char *filename;
main(argc,argv) char **argv; {
extern int nerrors;
extern int code_in_c;
extern int tabledebug;
extern int verbose;
while (argc >1 && argv[1][0]=='-') {
switch(argv[1][1]) {
case 'c':
code_in_c = 0;
break;
case 'd':
tabledebug++;
break;
case 'v':
verbose++;
break;
default:
error("Unknown flag -%c",argv[1][1]);
}
argc--; argv++;
}
if (argc==2) {
if (freopen(argv[1],"r",stdin)==NULL) {
error("Can't open %s",argv[1]);
exit(-1);
}
filename = argv[1];
} else
error("Usage: %s [-c] [-d] [-v] table",argv[0]);
initemhash();
enterkeyw();
initnodes();
initio();
yyparse();
if (nerrors==0) {
finishio();
statistics();
if (verbose)
hallverbose();
} else {
errorexit();
}
return(nerrors==0 ? 0 : -1);
}
| #ifndef NORCSID
static char rcsid[]= "$Header$";
#endif
#include <stdio.h>
char *filename;
main(argc,argv) char **argv; {
extern int nerrors;
extern int code_in_c;
extern int tabledebug;
extern int verbose;
while (argc >1 && argv[1][0]=='-') {
switch(argv[1][1]) {
case 'c':
code_in_c = 0;
break;
case 'd':
tabledebug++;
break;
case 'v':
verbose++;
break;
default:
error("Unknown flag -%c",argv[1][1]);
}
argc--; argv++;
}
if (argc==2) {
if (freopen(argv[1],"r",stdin)==NULL) {
error("Can't open %s",argv[1]);
exit(-1);
}
filename = argv[1];
}
else if (argc == 1) {
filename = "";
} else
error("Usage: %s [-c] [-d] [-v] [table]",argv[0]);
initemhash();
enterkeyw();
initnodes();
initio();
yyparse();
if (nerrors==0) {
finishio();
statistics();
if (verbose)
hallverbose();
} else {
errorexit();
}
return(nerrors==0 ? 0 : -1);
}
|
Fix ARM RealView EB and VE builds (2) | /** @file
*
* Copyright (c) 2011, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#include <Library/IoLib.h>
#include <Library/ArmPlatformLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Drivers/PL341Dmc.h>
#include <Drivers/SP804Timer.h>
#include <ArmPlatform.h>
/**
Initialize the Secure peripherals and memory regions
If Trustzone is supported by your platform then this function makes the required initialization
of the secure peripherals and memory regions.
**/
VOID
ArmPlatformTrustzoneInit (
VOID
)
{
//ASSERT(FALSE);
DEBUG((EFI_D_ERROR,"Initialize Trustzone Hardware\n"));
}
/**
Initialize controllers that must setup at the early stage
Some peripherals must be initialized in Secure World.
For example, some L2x0 requires to be initialized in Secure World
**/
VOID
ArmPlatformSecInitialize (
VOID
) {
// Do nothing yet
}
/**
Call before jumping to Normal World
This function allows the firmware platform to do extra actions before
jumping to the Normal World
**/
VOID
ArmPlatformSecExtraAction (
IN UINTN CoreId,
OUT UINTN* JumpAddress
)
{
*JumpAddress = PcdGet32(PcdNormalFvBaseAddress);
}
| |
Remove test case's dependency on header file. | // RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-experimental-checks -analyzer-store=region -verify %s
#include <stdlib.h>
void f1() {
int *p = malloc(10);
return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
}
// THIS TEST CURRENTLY FAILS.
void f1_b() {
int *p = malloc(10);
}
void f2() {
int *p = malloc(10);
free(p);
free(p); // expected-warning{{Try to free a memory block that has been released}}
}
// This case tests that storing malloc'ed memory to a static variable which is then returned
// is not leaked. In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
int *f3() {
static int *p = 0;
p = malloc(10); // no-warning
return p;
}
// This case tests that storing malloc'ed memory to a static global variable which is then returned
// is not leaked. In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
static int *p_f4 = 0;
int *f4() {
p_f4 = malloc(10); // no-warning
return p_f4;
}
| // RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-experimental-checks -analyzer-store=region -verify %s
typedef long unsigned int size_t;
void *malloc(size_t);
void free(void *);
void f1() {
int *p = malloc(10);
return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
}
// THIS TEST CURRENTLY FAILS.
void f1_b() {
int *p = malloc(10);
}
void f2() {
int *p = malloc(10);
free(p);
free(p); // expected-warning{{Try to free a memory block that has been released}}
}
// This case tests that storing malloc'ed memory to a static variable which is then returned
// is not leaked. In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
int *f3() {
static int *p = 0;
p = malloc(10); // no-warning
return p;
}
// This case tests that storing malloc'ed memory to a static global variable which is then returned
// is not leaked. In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
static int *p_f4 = 0;
int *f4() {
p_f4 = malloc(10); // no-warning
return p_f4;
}
|
Add files to the master header | //
// AXKCollectionViewTools.h
// Alexander Kolov
//
// Created by Alexander Kolov on 30/10/13.
// Copyright (c) 2013 Alexander Kolov. All rights reserved.
//
#import "UICollectionReusableView+ReuseIdentifier.h"
#import "UICollectionViewCell+IndexPath.h"
#import "UICollectionViewCell+ReuseIdentifier.h"
#import "UITableViewCell+IndexPath.h"
#import "UITableViewCell+ReuseIdentifier.h"
| //
// AXKCollectionViewTools.h
// Alexander Kolov
//
// Created by Alexander Kolov on 30/10/13.
// Copyright (c) 2013 Alexander Kolov. All rights reserved.
//
#import "UICollectionReusableView+ReuseIdentifier.h"
#import "UICollectionViewCell+IndexPath.h"
#import "UICollectionViewCell+ReuseIdentifier.h"
#import "UITableViewCell+IndexPath.h"
#import "UITableViewCell+ReuseIdentifier.h"
#import "UITableViewHeaderFooterView+ReuseIdentifier.h"
|
Fix prototype to make function. | //===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ----*- C++ -*--=//
//
// This functionality is implemented by the lib/BytecodeReader library.
// This library is used to read VM bytecode files from an iostream.
//
// Note that performance of this library is _crucial_ for performance of the
// JIT type applications, so we have designed the bytecode format to support
// quick reading.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_BYTECODE_READER_H
#define LLVM_BYTECODE_READER_H
#include <string>
class Module;
// Parse and return a class...
//
Module *ParseBytecodeFile(const std::string &Filename,
std::string *ErrorStr = 0);
Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize,
std::string *ErrorStr = 0);
#endif
| //===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ----*- C++ -*--=//
//
// This functionality is implemented by the lib/BytecodeReader library.
// This library is used to read VM bytecode files from an iostream.
//
// Note that performance of this library is _crucial_ for performance of the
// JIT type applications, so we have designed the bytecode format to support
// quick reading.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_BYTECODE_READER_H
#define LLVM_BYTECODE_READER_H
#include <string>
class Module;
// Parse and return a class...
//
Module *ParseBytecodeFile(const std::string &Filename,
std::string *ErrorStr = 0);
Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize);
#endif
|
Add header to provide MSVC compatibility | /*!
* @file msvc.h
* @brief Provide MSVC compatibility
* @author koturn
*/
#ifndef KOTLIB_COMPAT_MSVC_H
#define KOTLIB_COMPAT_MSVC_H
#ifndef _MSC_VER
# define _declspec(x)
# define __declspec(x)
#endif
#endif // KOTLIB_COMPAT_MSVC_H
| |
Fix the build breakage on Windows caused by CountTrailingZeros. | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef PLATFORM_UTILS_WIN_H_
#define PLATFORM_UTILS_WIN_H_
#include <intrin.h>
namespace dart {
inline int Utils::CountTrailingZeros(uword x) {
uword result;
#if defined(ARCH_IS_32_BIT)
_BitScanReverse(&result, x);
return __builtin_ctzl(x);
#elif defined(ARCH_IS_64_BIT)
_BitScanReverse64(&result, x);
#else
#error Architecture is not 32-bit or 64-bit.
#endif
return static_cast<int>(result);
};
} // namespace dart
#endif // PLATFORM_UTILS_WIN_H_
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef PLATFORM_UTILS_WIN_H_
#define PLATFORM_UTILS_WIN_H_
#include <intrin.h>
namespace dart {
inline int Utils::CountTrailingZeros(uword x) {
unsigned long result; // NOLINT
#if defined(ARCH_IS_32_BIT)
_BitScanReverse(&result, x);
#elif defined(ARCH_IS_64_BIT)
_BitScanReverse64(&result, x);
#else
#error Architecture is not 32-bit or 64-bit.
#endif
return static_cast<int>(result);
};
} // namespace dart
#endif // PLATFORM_UTILS_WIN_H_
|
Add slots for second lab | #ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <QGroupBox>
#include <QVBoxLayout>
#include <base_window.h>
class MainWindow : public gui::BaseWindow {
public:
MainWindow();
virtual ~MainWindow();
protected:
/**
* Callback for resize window.
*
* @param event[in] Event params.
*/
void resizeEvent(QResizeEvent *event) override;
private:
/** Result image and it's container */
QImage result_image;
QLabel *result_image_label;
};
#endif // MAIN_WINDOW_H
| #ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <QGroupBox>
#include <QVBoxLayout>
#include <base_window.h>
class MainWindow : public gui::BaseWindow {
public:
MainWindow();
virtual ~MainWindow();
protected:
/**
* Callback for resize window.
*
* @param event[in] Event params.
*/
void resizeEvent(QResizeEvent *event) override;
private slots:
void fix_color_correct();
void gray_world();
void gamma_correct();
void contrast_correct();
void hist_normalization();
void hist_equalization();
private:
/** Result image and it's container */
QImage result_image;
QLabel *result_image_label;
};
#endif // MAIN_WINDOW_H
|
Fix poorly worded volume comment. | /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <stddef.h>
/* Default to 1dB per tick. Volume level 100 = 0dB level 0 = -100dB. */
long cras_volume_curve_get_db_for_index(size_t volume)
{
/* dB to cut * 100 */
return (volume - 100) * 100;
}
| /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <stddef.h>
/* Default to 1dB per tick.
* Volume = 100 -> 0dB.
* Volume = 0 -> -100dB. */
long cras_volume_curve_get_db_for_index(size_t volume)
{
/* dB to cut * 100 */
return (volume - 100) * 100;
}
|
Include for OpenCL progs. Similar to the csmith include. Will only work with the minimal version at the moment. | #ifndef RANDOM_RUNTIME_H
#define RANDOM_RUNTIME_H
#include "safe_math_macros.h"
static uint32_t crc32_tab[256];
static uint32_t crc32_context = 0xFFFFFFFFUL;
/*static void
crc32_gentab (void)
{
uint32_t crc;
const uint32_t poly = 0xEDB88320UL;
int i, j;
for (i = 0; i < 256; i++) {
crc = i;
for (j = 8; j > 0; j--) {
if (crc & 1) {
crc = (crc >> 1) ^ poly;
} else {
crc >>= 1;
}
}
crc32_tab[i] = crc;
}
}
static void
crc32_byte (uint8_t b) {
crc32_context =
((crc32_context >> 8) & 0x00FFFFFF) ^
crc32_tab[(crc32_context ^ b) & 0xFF];
}
static void
crc32_8bytes (uint64_t val)
{
crc32_byte ((val>>0) & 0xff);
crc32_byte ((val>>8) & 0xff);
crc32_byte ((val>>16) & 0xff);
crc32_byte ((val>>24) & 0xff);
crc32_byte ((val>>32) & 0xff);
crc32_byte ((val>>40) & 0xff);
crc32_byte ((val>>48) & 0xff);
crc32_byte ((val>>56) & 0xff);
}
static void
transparent_crc (uint64_t val, const __constant char* vname, int flag)
{
crc32_8bytes(val);
}*/
static inline void crc32_gentab (void)
{
}
static inline void
transparent_crc (uint32_t val, const __constant char* vname, int flag)
{
crc32_context += val;
}
#endif /* RANDOM_RUNTIME_H */
| |
Add a TODO comment about boolean division | #pragma once
#include "xchainer/macro.h"
namespace xchainer {
template <typename T>
class ArithmeticOps {
public:
XCHAINER_HOST_DEVICE static T Add(T lhs, T rhs) { return lhs + rhs; }
XCHAINER_HOST_DEVICE static T Multiply(T lhs, T rhs) { return lhs * rhs; }
XCHAINER_HOST_DEVICE static T Divide(T lhs, T rhs) { return lhs / rhs; }
};
template <>
class ArithmeticOps<bool> {
public:
XCHAINER_HOST_DEVICE static bool Add(bool lhs, bool rhs) { return lhs || rhs; }
XCHAINER_HOST_DEVICE static bool Multiply(bool lhs, bool rhs) { return lhs && rhs; }
XCHAINER_HOST_DEVICE static bool Divide(bool lhs, bool rhs) { return lhs && rhs; }
};
} // namespace xchainer
| #pragma once
#include "xchainer/macro.h"
namespace xchainer {
template <typename T>
class ArithmeticOps {
public:
XCHAINER_HOST_DEVICE static T Add(T lhs, T rhs) { return lhs + rhs; }
XCHAINER_HOST_DEVICE static T Multiply(T lhs, T rhs) { return lhs * rhs; }
XCHAINER_HOST_DEVICE static T Divide(T lhs, T rhs) { return lhs / rhs; }
};
template <>
class ArithmeticOps<bool> {
public:
XCHAINER_HOST_DEVICE static bool Add(bool lhs, bool rhs) { return lhs || rhs; }
XCHAINER_HOST_DEVICE static bool Multiply(bool lhs, bool rhs) { return lhs && rhs; }
// TODO(beam2d): It's a tentative implementation. Make distinction between TrueDivide and FloorDivide for better NumPy compatibility.
// The current implementation is of boolean FloorDivide except for warnings.
XCHAINER_HOST_DEVICE static bool Divide(bool lhs, bool rhs) { return lhs && rhs; }
};
} // namespace xchainer
|
Move by machine word size | #ifndef __STDARG_H
#define __STDARG_H
#include "sys/types.h"
typedef void *va_list;
#define va_start(l, arg) l = (void *)&arg
#define va_arg(l, type) (*(type *)(l += __WORDSIZE / 8))
#define va_end(l)
#endif
| #ifndef __STDARG_H
#define __STDARG_H
#include "sys/types.h"
typedef void *va_list;
#define va_start(l, arg) l = (void *)&arg
/*
* va_arg assumes arguments are promoted to
* machine-word size when pushed onto the stack
*/
#define va_arg(l, type) (*(type *)(l += sizeof *l))
#define va_end(l)
#endif
|
Switch from class property to methods | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
Accessors for Global Constants.
*/
@interface FBConfiguration : NSObject
/*! If set to YES will ask TestManagerDaemon for element visibility */
@property (class, nonatomic, assign) BOOL shouldUseTestManagerForVisibilityDetection;
/* The maximum typing frequency for all typing activities */
@property (class, nonatomic, assign) NSUInteger maxTypingFrequency;
/**
Switch for enabling/disabling reporting fake collection view cells by Accessibility framework.
If set to YES it will report also invisible cells.
*/
+ (void)shouldShowFakeCollectionViewCells:(BOOL)showFakeCells;
/**
The range of ports that the HTTP Server should attempt to bind on launch
*/
+ (NSRange)bindingPortRange;
/**
YES if verbose logging is enabled. NO otherwise.
*/
+ (BOOL)verboseLoggingEnabled;
@end
NS_ASSUME_NONNULL_END
| /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
Accessors for Global Constants.
*/
@interface FBConfiguration : NSObject
/*! If set to YES will ask TestManagerDaemon for element visibility */
+ (void)setShouldUseTestManagerForVisibilityDetection:(BOOL)value;
+ (BOOL)shouldUseTestManagerForVisibilityDetection;
/* The maximum typing frequency for all typing activities */
+ (void)setMaxTypingFrequency:(NSUInteger)value;
+ (NSUInteger)maxTypingFrequency;
/**
Switch for enabling/disabling reporting fake collection view cells by Accessibility framework.
If set to YES it will report also invisible cells.
*/
+ (void)shouldShowFakeCollectionViewCells:(BOOL)showFakeCells;
/**
The range of ports that the HTTP Server should attempt to bind on launch
*/
+ (NSRange)bindingPortRange;
/**
YES if verbose logging is enabled. NO otherwise.
*/
+ (BOOL)verboseLoggingEnabled;
@end
NS_ASSUME_NONNULL_END
|
Remove stale comment which used to explain why we had a special 31-bit freelist for DMA, back when this was applicable. | /* $OpenBSD: vmparam.h,v 1.9 2011/05/30 22:25:22 oga Exp $ */
/* public domain */
#ifndef _MACHINE_VMPARAM_H_
#define _MACHINE_VMPARAM_H_
#define VM_PHYSSEG_MAX 32 /* Max number of physical memory segments */
/*
* On Origin and Octane families, DMA to 32-bit PCI devices is restricted.
*
* Systems with physical memory after the 2GB boundary need to ensure
* memory which may used for DMA transfers is allocated from the low
* memory range.
*
* Other systems, like the O2, do not have such a restriction, but can not
* have more than 2GB of physical memory, so this doesn't affect them.
*/
#include <mips64/vmparam.h>
#endif /* _MACHINE_VMPARAM_H_ */
| /* $OpenBSD: vmparam.h,v 1.10 2014/07/13 15:48:32 miod Exp $ */
/* public domain */
#ifndef _MACHINE_VMPARAM_H_
#define _MACHINE_VMPARAM_H_
#define VM_PHYSSEG_MAX 32 /* Max number of physical memory segments */
#include <mips64/vmparam.h>
#endif /* _MACHINE_VMPARAM_H_ */
|
Fix for crashes in iOS 10 | //
// class_getSubclasses.h
// iActiveRecord
//
// Created by Alex Denisov on 21.03.12.
// Copyright (c) 2012 okolodev.org. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
static NSArray *class_getSubclasses(Class parentClass) {
int numClasses = objc_getClassList(NULL, 0);
Class classes[sizeof(Class) * numClasses];
numClasses = objc_getClassList(classes, numClasses);
NSMutableArray *result = [NSMutableArray array];
for (NSInteger i = 0; i < numClasses; i++) {
Class superClass = classes[i];
do {
superClass = class_getSuperclass(superClass);
} while (superClass && superClass != parentClass);
if (superClass == nil) {
continue;
}
[result addObject:classes[i]];
}
return result;
}
| //
// class_getSubclasses.h
// iActiveRecord
//
// Created by Alex Denisov on 21.03.12.
// Copyright (c) 2012 okolodev.org. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
static NSArray *class_getSubclasses(Class parentClass) {
int numClasses = objc_getClassList(NULL, 0);
Class *classes = NULL;
classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
NSMutableArray *result = [NSMutableArray array];
for (NSInteger i = 0; i < numClasses; i++) {
Class superClass = classes[i];
do {
superClass = class_getSuperclass(superClass);
} while (superClass && superClass != parentClass);
if (superClass == nil) {
continue;
}
[result addObject:classes[i]];
}
free(classes);
return result;
}
|
Fix some GCC initialization warnings | #pragma once
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>
namespace dev
{
namespace eth
{
namespace jit
{
using byte = uint8_t;
using bytes = std::vector<byte>;
using u256 = boost::multiprecision::uint256_t;
using bigint = boost::multiprecision::cpp_int;
struct NoteChannel {}; // FIXME: Use some log library?
enum class ReturnCode
{
Stop = 0,
Return = 1,
Suicide = 2,
BadJumpDestination = 101,
OutOfGas = 102,
StackTooSmall = 103,
BadInstruction = 104,
LLVMConfigError = 201,
LLVMCompileError = 202,
LLVMLinkError = 203,
};
/// Representation of 256-bit value binary compatible with LLVM i256
// TODO: Replace with h256
struct i256
{
uint64_t a;
uint64_t b;
uint64_t c;
uint64_t d;
};
static_assert(sizeof(i256) == 32, "Wrong i265 size");
#define UNTESTED assert(false)
}
}
}
| #pragma once
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>
namespace dev
{
namespace eth
{
namespace jit
{
using byte = uint8_t;
using bytes = std::vector<byte>;
using u256 = boost::multiprecision::uint256_t;
using bigint = boost::multiprecision::cpp_int;
struct NoteChannel {}; // FIXME: Use some log library?
enum class ReturnCode
{
Stop = 0,
Return = 1,
Suicide = 2,
BadJumpDestination = 101,
OutOfGas = 102,
StackTooSmall = 103,
BadInstruction = 104,
LLVMConfigError = 201,
LLVMCompileError = 202,
LLVMLinkError = 203,
};
/// Representation of 256-bit value binary compatible with LLVM i256
// TODO: Replace with h256
struct i256
{
uint64_t a = 0;
uint64_t b = 0;
uint64_t c = 0;
uint64_t d = 0;
};
static_assert(sizeof(i256) == 32, "Wrong i265 size");
#define UNTESTED assert(false)
}
}
}
|
Improve checks for vla-argument test | // RUN: %ocheck 0 %s
// RUN: %ocheck 0 %s -fstack-protector-all
extern void abort(void);
as, bs, fs;
static int a(){ as++; return 2; }
static int b(){ bs++; return 2; }
static int f(int p[a()][b()])
{
fs++;
return p[0][0] + p[0][1] + p[1][0] + p[1][1];
}
static void assert(_Bool b)
{
if(!b)
abort();
}
int main()
{
int ar[a()][b()];
assert(as == 1);
assert(bs == 1);
assert(fs == 0);
ar[0][0] = 5;
ar[0][1] = 4;
ar[1][0] = 3;
ar[1][1] = 2;
assert(as == 1);
assert(bs == 1);
assert(fs == 0);
assert(f(ar) == 14);
assert(as == 2);
assert(bs == 2);
assert(fs == 1);
return 0;
}
| // RUN: %ocheck 0 %s
// RUN: %ocheck 0 %s -fstack-protector-all
extern void abort(void);
as, bs, fs;
static int a(){ as++; return 2; }
static int b(){ bs++; return 2; }
static int f(int p[a()][b()])
{
fs++;
return p[0][0] // 5
+ p[0][1] // 4
+ p[1][0] // 3
+ p[1][1] // 2
+ sizeof(p) // sizeof(T (*)[...]) = 8
+ sizeof(p[0]) // 2 * sizeof(int) = 8
+ sizeof(p[1][2]); // sizeof(int) = 4
}
static void assert(_Bool b)
{
if(!b)
abort();
}
int main()
{
int ar[a()][b()];
assert(as == 1);
assert(bs == 1);
assert(fs == 0);
ar[0][0] = 5;
ar[0][1] = 4;
ar[1][0] = 3;
ar[1][1] = 2;
assert(as == 1);
assert(bs == 1);
assert(fs == 0);
assert(f(ar) == 34);
assert(as == 2);
assert(bs == 2);
assert(fs == 1);
return 0;
}
|
Remove __attribute__((weak)) on function prototype. It has a different meaning on prototypes then it does on definitions. It is not needed on the prototype and causes build failures for static codegen | /* ===-- int_util.h - internal utility functions ----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is dual licensed under the MIT and the University of Illinois Open
* Source Licenses. See LICENSE.TXT for details.
*
* ===-----------------------------------------------------------------------===
*
* This file is not part of the interface of this library.
*
* This file defines non-inline utilities which are available for use in the
* library. The function definitions themselves are all contained in int_util.c
* which will always be compiled into any compiler-rt library.
*
* ===-----------------------------------------------------------------------===
*/
#ifndef INT_UTIL_H
#define INT_UTIL_H
/** \brief Trigger a program abort (or panic for kernel code). */
#define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \
__FUNCTION__)
void compilerrt_abort_impl(const char *file, int line,
const char *function)
#ifndef KERNEL_USE
__attribute__((weak))
#endif
__attribute__((noreturn)) __attribute__((visibility("hidden")));
#endif /* INT_UTIL_H */
| /* ===-- int_util.h - internal utility functions ----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is dual licensed under the MIT and the University of Illinois Open
* Source Licenses. See LICENSE.TXT for details.
*
* ===-----------------------------------------------------------------------===
*
* This file is not part of the interface of this library.
*
* This file defines non-inline utilities which are available for use in the
* library. The function definitions themselves are all contained in int_util.c
* which will always be compiled into any compiler-rt library.
*
* ===-----------------------------------------------------------------------===
*/
#ifndef INT_UTIL_H
#define INT_UTIL_H
/** \brief Trigger a program abort (or panic for kernel code). */
#define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \
__FUNCTION__)
void compilerrt_abort_impl(const char *file, int line,
const char *function) __attribute__((noreturn));
#endif /* INT_UTIL_H */
|
Fix for binary files on Windows | #include <stdio.h>
#include <stdlib.h>
#include "../lib/libunshield.h"
int main(int argc, char** argv)
{
unsigned seed = 0;
FILE* input = NULL;
FILE* output = NULL;
size_t size;
unsigned char buffer[16384];
if (argc != 3)
{
fprintf(stderr,
"Syntax:\n"
" %s INPUT-FILE OUTPUT-FILE\n",
argv[0]);
exit(1);
}
input = fopen(argv[1], "r");
if (!input)
{
fprintf(stderr,
"Failed to open %s for reading\n",
argv[1]);
exit(2);
}
output = fopen(argv[2], "w");
if (!output)
{
fprintf(stderr,
"Failed to open %s for writing\n",
argv[2]);
exit(3);
}
while ((size = fread(buffer, 1, sizeof(buffer), input)) != 0)
{
unshield_deobfuscate(buffer, size, &seed);
if (fwrite(buffer, 1, size, output) != size)
{
fprintf(stderr,
"Failed to write %lu bytes to %s\n",
(unsigned long)size, argv[2]);
exit(4);
}
}
fclose(input);
fclose(output);
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
#include "../lib/libunshield.h"
int main(int argc, char** argv)
{
unsigned seed = 0;
FILE* input = NULL;
FILE* output = NULL;
size_t size;
unsigned char buffer[16384];
if (argc != 3)
{
fprintf(stderr,
"Syntax:\n"
" %s INPUT-FILE OUTPUT-FILE\n",
argv[0]);
exit(1);
}
input = fopen(argv[1], "rb");
if (!input)
{
fprintf(stderr,
"Failed to open %s for reading\n",
argv[1]);
exit(2);
}
output = fopen(argv[2], "wb");
if (!output)
{
fprintf(stderr,
"Failed to open %s for writing\n",
argv[2]);
exit(3);
}
while ((size = fread(buffer, 1, sizeof(buffer), input)) != 0)
{
unshield_deobfuscate(buffer, size, &seed);
if (fwrite(buffer, 1, size, output) != size)
{
fprintf(stderr,
"Failed to write %lu bytes to %s\n",
(unsigned long)size, argv[2]);
exit(4);
}
}
fclose(input);
fclose(output);
return 0;
}
|
Add header file to git | #ifndef _LISPY_H
#define _LISPY_H
#include "lib/mpc.h"
/* Compile these functions if we're on Windows */
#ifdef _WIN32
static char buffer[2048];
char* readline(char* prompt) {
fputs(prompt, stdout);
fgets(buffer, 2048, stdin);
char* cpy = malloc(strlen(buffer) + 1);
strcpy(cpy, buffer);
cpy[strlen(cpy) - 1] = "\0";
return cpy;
}
void add_history(char* unused) {}
#elif __APPLE__
#include <editline/readline.h>
#else
#include <editline/readline.h>
#include <editline/history.h>
#endif
/***************************
* Macros, Enums, and Structs
***************************/
#define LASSERT(args, cond, err) if (!(cond)) { lval_del(args); return lval_err(err); }
/* lval possible types */
enum { LVAL_NUM, LVAL_ERR, LVAL_SYM, LVAL_SEXPR, LVAL_QEXPR };
/* Lisp Value struct */
typedef struct lval {
int type;
long num;
/* String data for err and sym types */
char* err;
char* sym;
/* Count and pointer to a list of lvals */
int count;
struct lval** cell;
} lval;
/**********************
* Function declarations
**********************/
lval* lval_num(long);
lval* lval_err(char*);
lval* lval_sym(char*);
lval* lval_sexpr(void);
lval* lval_qepxr(void);
void lval_del(lval*);
lval* lval_add(lval*, lval*);
void lval_expr_print(lval*, char, char);
void lval_print(lval*);
void lval_println(lval*);
lval* lval_read_num(mpc_ast_t*);
lval* lval_read(mpc_ast_t*);
lval* lval_pop(lval*, int);
lval* lval_take(lval*, int);
lval* lval_eval(lval*);
lval* lval_eval_sexpr(lval*);
lval* builtin(lval*, char*);
lval* builtin_op(lval*, char*);
lval* builtin_head(lval*);
lval* builtin_tail(lval*);
lval* builtin_list(lval*);
lval* builtin_eval(lval*);
lval* builtin_join(lval*);
lval* lval_join(lval*, lval*);
#endif | |
Add methods to notify FolderView delegate when edit mode is toggled. | //
// FolderViewControllerDelegate.h
// arc
//
// Created by Jerome Cheng on 17/4/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "File.h"
#import "Folder.h"
@class FolderViewController;
@protocol FolderViewControllerDelegate <NSObject>
- (void)folderViewController:(FolderViewController *)sender selectedFile:(id<File>)file;
- (void)folderViewController:(FolderViewController *)sender selectedFolder:(id<Folder>)folder;
@end
| //
// FolderViewControllerDelegate.h
// arc
//
// Created by Jerome Cheng on 17/4/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "File.h"
#import "Folder.h"
@class FolderViewController;
@protocol FolderViewControllerDelegate <NSObject>
// Allows delegate to know which file or folder was selected in navigation mode.
- (void)folderViewController:(FolderViewController *)sender selectedFile:(id<File>)file;
- (void)folderViewController:(FolderViewController *)sender selectedFolder:(id<Folder>)folder;
// Allows the delegate to know if the controller has entered or left editing mode.
- (void)folderViewController:(FolderViewController *)folderviewController
DidEnterEditModeAnimate:(BOOL)animate;
- (void)folderViewController:(FolderViewController *)folderviewController DidExitEditModeAnimate:(BOOL)animate;
@end
|
Add test case for casting longs to function pointers | void abort();
int add(int a, int b) { return a + b; }
int sub(int a, int b) { return a - b; }
int mul(int a, int b) { return a * b; }
int div(int a, int b) { return a / b; }
int rem(int a, int b) { return a % b; }
long arr[5] = {(long)&add, (long)&sub, (long)&mul, (long)&div, (long)&rem };
int main() {
int i;
int sum = 0;
for (i = 0; i < 10000; i++) {
int (*p)(int x, int y) = (int (*)(int x, int y))arr[i % 5];
sum += p(i, 2);
}
if (sum != 44991000) {
abort();
}
}
| |
Synchronize logical grouping of defines | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \
(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8))
#define PT_DISPATCH_RETAIN_RELEASE 1
#endif
#if (!defined(PT_DISPATCH_RETAIN_RELEASE))
#define PT_PRECISE_LIFETIME __attribute__((objc_precise_lifetime))
#define PT_PRECISE_LIFETIME_UNUSED __attribute__((objc_precise_lifetime, unused))
#else
#define PT_PRECISE_LIFETIME
#define PT_PRECISE_LIFETIME_UNUSED
#endif
| #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \
(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8))
#define PT_DISPATCH_RETAIN_RELEASE 1
#else
#define PT_DISPATCH_RETAIN_RELEASE 0
#endif
#if PT_DISPATCH_RETAIN_RELEASE
#define PT_PRECISE_LIFETIME
#define PT_PRECISE_LIFETIME_UNUSED
#else
#define PT_PRECISE_LIFETIME __attribute__((objc_precise_lifetime))
#define PT_PRECISE_LIFETIME_UNUSED __attribute__((objc_precise_lifetime, unused))
#endif
|
Fix clang's stupid warning to work around a bug in OS X headers... | #ifndef _OBJC_MESSAGE_H_
#define _OBJC_MESSAGE_H_
#if defined(__x86_64) || defined(__i386) || defined(__arm__) || \
defined(__mips_n64) || defined(__mips_n32)
/**
* Standard message sending function. This function must be cast to the
* correct types for the function before use. The first argument is the
* receiver and the second the selector.
*
* Note that this function is not available on all architectures. For a more
* portable solution to sending arbitrary messages, consider using
* objc_msg_lookup_sender() and then calling the returned IMP directly.
*
* This version of the function is used for all messages that return either an
* integer, a pointer, or a small structure value that is returned in
* registers. Be aware that calling conventions differ between operating
* systems even within the same architecture, so take great care if using this
* function for small (two integer) structures.
*/
id objc_msgSend(id self, SEL _cmd, ...);
/**
* Standard message sending function. This function must be cast to the
* correct types for the function before use. The first argument is the
* receiver and the second the selector.
*
* Note that this function is not available on all architectures. For a more
* portable solution to sending arbitrary messages, consider using
* objc_msg_lookup_sender() and then calling the returned IMP directly.
*
* This version of the function is used for all messages that return a
* structure that is not returned in registers. Be aware that calling
* conventions differ between operating systems even within the same
* architecture, so take great care if using this function for small (two
* integer) structures.
*/
#ifdef __cplusplus
id objc_msgSend_stret(id self, SEL _cmd, ...);
#else
void objc_msgSend_stret(id self, SEL _cmd, ...);
#endif
/**
* Standard message sending function. This function must be cast to the
* correct types for the function before use. The first argument is the
* receiver and the second the selector.
*
* Note that this function is not available on all architectures. For a more
* portable solution to sending arbitrary messages, consider using
* objc_msg_lookup_sender() and then calling the returned IMP directly.
*
* This version of the function is used for all messages that return floating
* point values.
*/
long double objc_msgSend_fpret(id self, SEL _cmd, ...);
#endif
#endif //_OBJC_MESSAGE_H_
| |
Use GCC's __FUNCTION__ for ACPI_GET_FUNCTION_NAME | #define ACPI_MACHINE_WIDTH 64
#define ACPI_SINGLE_THREADED
#define ACPI_DEBUG_OUTPUT
#define ACPI_DISASSEMBLER
#define ACPI_USE_LOCAL_CACHE
#define ACPI_INLINE inline
#define ACPI_USE_NATIVE_DIVIDE
// Depends on threading support
#define ACPI_DEBUGGER
#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
// Depends on debugger support
//#define ACPI_DBG_TRACK_ALLOCATIONS
#define ACPI_PHYS_BASE 0x100000000
#if 0
#define AcpiException(ModName, Line, Status, Format, ...) \
AcpiOsPrintf(ACPI_MSG_EXCEPTION "%s, " Format, \
AcpiFormatException(Status), \
## __VA_ARGS__)
#endif
#include <stdint.h>
#include <stdarg.h>
#define AcpiOsPrintf printf
#define AcpiOsVprintf vprintf
| #define ACPI_MACHINE_WIDTH 64
#define ACPI_SINGLE_THREADED
#define ACPI_DEBUG_OUTPUT
#define ACPI_DISASSEMBLER
#define ACPI_USE_LOCAL_CACHE
#define ACPI_INLINE inline
#define ACPI_USE_NATIVE_DIVIDE
// Depends on threading support
#define ACPI_DEBUGGER
#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
// Depends on debugger support
//#define ACPI_DBG_TRACK_ALLOCATIONS
#define ACPI_PHYS_BASE 0x100000000
#if 0
#define AcpiException(ModName, Line, Status, Format, ...) \
AcpiOsPrintf(ACPI_MSG_EXCEPTION "%s, " Format, \
AcpiFormatException(Status), \
## __VA_ARGS__)
#endif
#define ACPI_GET_FUNCTION_NAME __FUNCTION__
#include <stdint.h>
#include <stdarg.h>
#define AcpiOsPrintf printf
#define AcpiOsVprintf vprintf
|
Implement outline of "radar window" | #include <stdlib.h>
#include <ncurses.h>
/**
* The main function, called when atcso is started (duh).
*/
int main(int argc, char** argv) {
initscr();
raw(); // Disable line buffering
noecho(); // Don't show things the user is typing
printw("hai wurld");
refresh();
while (getch() != 'q'); // Wait for the user to hit `q' to quit
endwin();
return EXIT_SUCCESS;
}
| #include <stdlib.h>
#include <ncurses.h>
#include <time.h>
typedef struct {
} AtcsoData;
void mainloop();
WINDOW *createRadarWin();
void updateRadarWin(AtcsoData *data, WINDOW *radarWin);
/**
* The main function, called when atcso is started (duh).
*/
int main(int argc, char **argv) {
initscr();
raw(); // Disable line buffering
noecho(); // Don't show things the user is typing
nodelay(stdscr, TRUE); // Non-blocking getch()
mainloop(); // Start the game!
endwin();
return EXIT_SUCCESS;
}
/**
* The main loop: runs infinitely until the game is ended.
*/
void mainloop() {
// get all our windows
refresh();
WINDOW *radarWin = createRadarWin();
// TODO put this somewhere... better
const int TICK_DELAY = 2;
// the main loop
int ch;
time_t lastTick = time(NULL);
AtcsoData data;
for (;;) {
if (difftime(time(NULL), lastTick) > TICK_DELAY) {
updateRadarWin(&data, radarWin);
lastTick += TICK_DELAY;
}
if ((ch = getch()) != ERR) {
switch (ch) {
case 'q':
case 'Q':
goto cleanup;
}
}
}
cleanup:
delwin(radarWin);
}
/**
* Creates the radar window, the biggest one that has all the planes and stuff.
*/
WINDOW *createRadarWin() {
WINDOW *radarWin = newwin(21, 60, 0, 0);
for (int i = 0; i < 59; ++i) waddch(radarWin, '-');
waddch(radarWin, ' ');
for (int i = 0; i < 19; ++i) {
waddstr(radarWin, "| ");
for (int j = 0; j < 28; ++j) waddstr(radarWin, ". ");
waddstr(radarWin, "| ");
}
for (int i = 0; i < 59; ++i) waddch(radarWin, '-');
waddch(radarWin, ' ');
wrefresh(radarWin);
return radarWin;
}
/**
* Update and refresh the radar window.
*/
void updateRadarWin(AtcsoData *data, WINDOW *radarWin) {
// TODO do stuff
}
|
Add missing include for TLSSocket |
/** \addtogroup netsocket */
/** @{*/
/* nsapi.h - The network socket API
* Copyright (c) 2015 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NSAPI_H
#define NSAPI_H
// entry point for nsapi types
#include "nsapi_types.h"
#ifdef __cplusplus
// entry point for C++ api
#include "netsocket/SocketAddress.h"
#include "netsocket/NetworkStack.h"
#include "netsocket/NetworkInterface.h"
#include "netsocket/EthInterface.h"
#include "netsocket/WiFiInterface.h"
#include "netsocket/CellularBase.h"
#include "netsocket/MeshInterface.h"
#include "netsocket/Socket.h"
#include "netsocket/UDPSocket.h"
#include "netsocket/TCPSocket.h"
#include "netsocket/TCPServer.h"
#endif
#endif
/** @}*/
|
/** \addtogroup netsocket */
/** @{*/
/* nsapi.h - The network socket API
* Copyright (c) 2015 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NSAPI_H
#define NSAPI_H
// entry point for nsapi types
#include "nsapi_types.h"
#ifdef __cplusplus
// entry point for C++ api
#include "netsocket/SocketAddress.h"
#include "netsocket/NetworkStack.h"
#include "netsocket/NetworkInterface.h"
#include "netsocket/EthInterface.h"
#include "netsocket/WiFiInterface.h"
#include "netsocket/CellularBase.h"
#include "netsocket/MeshInterface.h"
#include "netsocket/Socket.h"
#include "netsocket/UDPSocket.h"
#include "netsocket/TCPSocket.h"
#include "netsocket/TCPServer.h"
#include "netsocket/TLSSocket.h"
#endif
#endif
/** @}*/
|
Add assert, more print info | #include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <setjmp.h>
jmp_buf try;
void handler(int sig) {
static int i = 0;
write(2, "stack overflow\n", 15);
longjmp(try, ++i);
_exit(1);
}
unsigned recurse(unsigned x) {
return recurse(x)+1;
}
int main() {
char* stack;
stack = malloc(sizeof(stack) * SIGSTKSZ);
stack_t ss = {
.ss_size = SIGSTKSZ,
.ss_sp = stack,
};
struct sigaction sa = {
.sa_handler = handler,
.sa_flags = SA_ONSTACK
};
sigaltstack(&ss, 0);
sigfillset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, 0);
if (setjmp(try) < 3) {
recurse(0);
} else {
printf("caught exception!\n");
}
return 0;
}
| #include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <setjmp.h>
jmp_buf try;
void handler(int sig) {
static int i = 0;
printf("stack overflow %d\n", i);
longjmp(try, ++i);
assert(0);
}
unsigned recurse(unsigned x) {
return recurse(x)+1;
}
int main() {
char* stack;
stack = malloc(sizeof(stack) * SIGSTKSZ);
stack_t ss = {
.ss_size = SIGSTKSZ,
.ss_sp = stack,
};
struct sigaction sa = {
.sa_handler = handler,
.sa_flags = SA_ONSTACK
};
sigaltstack(&ss, 0);
sigfillset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, 0);
if (setjmp(try) < 3) {
recurse(0);
} else {
printf("caught exception!\n");
}
return 0;
}
|
Add first order dimensional sweep updating |
// Upwind updater
void updater_first_order_dimensional_splitting(real* q,
const real* aux,
const int nx,
const int ny,
const real* amdq,
const real* apdq,
const real* wave,
const real* wave_speeds,
const rp_grid_params grid_params
)
{
int col, row, idx_left, idx_center, idx_up, idx_out_x, idx_out_y;
const int num_ghost = grid_params.num_ghost;
const int num_states = grid_params.num_states;
// const int num_waves = rp_grid_params.num_waves;
#pragma omp parallel for schedule(runtime) nowait
for(row = num_ghost; row <= ny + num_ghost; ++row) {
for(col = num_ghost; col <= nx + num_ghost; ++col) {
idx_left = col + row*(nx + 2*num_ghost) - 1;
idx_up = col + (row - 1)*(nx + 2*num_ghost);
idx_center = idx_left + 1;
idx_out_x = (col - num_ghost) + (row - num_ghost) * (nx + 1);
idx_out_y = idx_out_x + ((nx + 1)*(ny + 1));
for(int state=0; state < num_states; ++state){
q[idx_left*num_states + state] -= amdq[idx_out_x*num_states + state];
q[idx_up*num_states + state] -= amdq[idx_out_y*num_states + state];
q[idx_center*num_states + state] -= apdq[idx_out_x*num_states + state];
q[idx_center*num_states + state] -= apdq[idx_out_y*num_states + state];
}
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.