Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Tweak test to at least use a standard arch, to ensure we try to invoke Clang.
// Check that --sysroot= also applies to header search paths. // RUN: %clang -ccc-host-triple unknown --sysroot=/FOO -### -E %s 2> %t1 // RUN: FileCheck --check-prefix=CHECK-SYSROOTEQ < %t1 %s // CHECK-SYSROOTEQ: "-cc1"{{.*}} "-isysroot" "/FOO" // Apple Darwin uses -isysroot as the syslib root, too. // RUN: touch %t2.o // RUN: %clang -ccc-host-triple i386-apple-darwin10 \ // RUN: -isysroot /FOO -### %t2.o 2> %t2 // RUN: FileCheck --check-prefix=CHECK-APPLE-ISYSROOT < %t2 %s // CHECK-APPLE-ISYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "/FOO" // Check that honor --sysroot= over -isysroot, for Apple Darwin. // RUN: touch %t3.o // RUN: %clang -ccc-host-triple i386-apple-darwin10 \ // RUN: -isysroot /FOO --sysroot=/BAR -### %t3.o 2> %t3 // RUN: FileCheck --check-prefix=CHECK-APPLE-SYSROOT < %t3 %s // CHECK-APPLE-SYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "/BAR"
// Check that --sysroot= also applies to header search paths. // RUN: %clang -ccc-host-triple i386-unk-unk --sysroot=/FOO -### -E %s 2> %t1 // RUN: FileCheck --check-prefix=CHECK-SYSROOTEQ < %t1 %s // CHECK-SYSROOTEQ: "-cc1"{{.*}} "-isysroot" "/FOO" // Apple Darwin uses -isysroot as the syslib root, too. // RUN: touch %t2.o // RUN: %clang -ccc-host-triple i386-apple-darwin10 \ // RUN: -isysroot /FOO -### %t2.o 2> %t2 // RUN: FileCheck --check-prefix=CHECK-APPLE-ISYSROOT < %t2 %s // CHECK-APPLE-ISYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "/FOO" // Check that honor --sysroot= over -isysroot, for Apple Darwin. // RUN: touch %t3.o // RUN: %clang -ccc-host-triple i386-apple-darwin10 \ // RUN: -isysroot /FOO --sysroot=/BAR -### %t3.o 2> %t3 // RUN: FileCheck --check-prefix=CHECK-APPLE-SYSROOT < %t3 %s // CHECK-APPLE-SYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "/BAR"
Add more typedef in minilibc.
#ifndef __TYPES_H__ #define __TYPES_H__ typedef long off_t; typedef unsigned long size_t; typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */ typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; typedef int mode_t; typedef unsigned long clockid_t; typedef int pid_t; typedef unsigned long clock_t; /* clock() */ #ifndef NULL #define NULL (0) #endif #define __u_char_defined #endif
#ifndef __TYPES_H__ #define __TYPES_H__ typedef long off_t; typedef unsigned long size_t; typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */ typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; typedef int mode_t; typedef unsigned long clockid_t; typedef int pid_t; typedef int gid_t; typedef int uid_t; typedef int dev_t; typedef int ino_t; typedef int mode_t; typedef int caddr_t; typedef unsigned int wint_t; typedef unsigned long useconds_t; typedef unsigned long clock_t; /* clock() */ #ifndef NULL #define NULL (0) #endif #define __u_char_defined #endif
Fix compiler warning in Xcode 9
/* OLEContainerScrollView Copyright (c) 2014 Ole Begemann. https://github.com/ole/OLEContainerScrollView */ void swizzleUICollectionViewLayoutFinalizeCollectionViewUpdates(); void swizzleUITableView();
/* OLEContainerScrollView Copyright (c) 2014 Ole Begemann. https://github.com/ole/OLEContainerScrollView */ void swizzleUICollectionViewLayoutFinalizeCollectionViewUpdates(void); void swizzleUITableView(void);
Remove function declarations from header
// // INVector3.h // DominantColor // // Created by Indragie on 12/21/14. // Copyright (c) 2014 Indragie Karunaratne. All rights reserved. // #import <GLKit/GLKit.h> // Wrapping GLKVector3 values in a struct so that it can be used from Swift. typedef struct { float x; float y; float z; } INVector3; GLKVector3 INVector3ToGLKVector3(INVector3 vector); INVector3 GLKVector3ToINVector3(GLKVector3 vector); INVector3 INVector3Add(INVector3 v1, INVector3 v2); INVector3 INVector3DivideScalar(INVector3 vector, float scalar);
// // INVector3.h // DominantColor // // Created by Indragie on 12/21/14. // Copyright (c) 2014 Indragie Karunaratne. All rights reserved. // #import <GLKit/GLKit.h> // Wrapping GLKVector3 values in a struct so that it can be used from Swift. typedef struct { float x; float y; float z; } INVector3; GLKVector3 INVector3ToGLKVector3(INVector3 vector); INVector3 GLKVector3ToINVector3(GLKVector3 vector);
Add surface server side implementation for tests
/* * This file is part of meego-im-framework * * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * Contact: Nokia Corporation (directui@nokia.com) * * If you have questions regarding the use of this file, please contact * Nokia at directui@nokia.com. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation * and appearing in the file LICENSE.LGPL included in the packaging * of this file. */ #ifndef CORE_UTILS_H__ #define CORE_UTILS_H__ #include <QString> #include <QObject> namespace MaliitTestUtils { bool isTestingInSandbox(); QString getTestPluginPath(); QString getTestDataPath(); void waitForSignal(const QObject* object, const char* signal, int timeout); void waitAndProcessEvents(int waitTime); } #endif // CORE_UTILS_H__
/* * This file is part of meego-im-framework * * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * Contact: Nokia Corporation (directui@nokia.com) * * If you have questions regarding the use of this file, please contact * Nokia at directui@nokia.com. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation * and appearing in the file LICENSE.LGPL included in the packaging * of this file. */ #ifndef CORE_UTILS_H__ #define CORE_UTILS_H__ #include <QString> #include <QObject> #include "abstractsurfacegroup.h" #include "abstractsurfacegroupfactory.h" namespace MaliitTestUtils { bool isTestingInSandbox(); QString getTestPluginPath(); QString getTestDataPath(); void waitForSignal(const QObject* object, const char* signal, int timeout); void waitAndProcessEvents(int waitTime); class TestSurfaceGroup : public Maliit::Server::AbstractSurfaceGroup { public: TestSurfaceGroup() {} Maliit::Plugins::AbstractSurfaceFactory *factory() { return 0; } void activate() {} void deactivate() {} void setRotation(Maliit::OrientationAngle) {} }; class TestSurfaceGroupFactory : public Maliit::Server::AbstractSurfaceGroupFactory { public: TestSurfaceGroupFactory() {} QSharedPointer<Maliit::Server::AbstractSurfaceGroup> createSurfaceGroup() { return QSharedPointer<Maliit::Server::AbstractSurfaceGroup>(new TestSurfaceGroup); } }; } #endif // CORE_UTILS_H__
Set correct name for boost IPC
#ifndef QTIPCSERVER_H #define QTIPCSERVER_H // Define Bitcoin-Qt message queue name #define BITCOINURI_QUEUE_NAME "BitcoinURI" void ipcScanRelay(int argc, char *argv[]); void ipcInit(int argc, char *argv[]); #endif // QTIPCSERVER_H
#ifndef QTIPCSERVER_H #define QTIPCSERVER_H // Define Bitcoin-Qt message queue name #define BITCOINURI_QUEUE_NAME "NovaCoinURI" void ipcScanRelay(int argc, char *argv[]); void ipcInit(int argc, char *argv[]); #endif // QTIPCSERVER_H
Clean up the sample include orderings, not that it really matters...
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "sample.h" int main (int argc, char ** argv) { printf ("%d\n", compute_sample (5)); exit (0); }
#include "sample.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main (int argc, char ** argv) { printf ("%d\n", compute_sample (5)); exit (0); }
Fix testcase for 64-bit systems.
// RUN: clang -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis | grep "ret i32 1" | count 3 // <rdr://6115726> int f0() { int x; unsigned short n = 1; int *a = &x; int *b = &x; a = a - n; b -= n; return a == b; } int f1(int *a) { int b = a - (int*) 1; a -= (int*) 1; return b == (int) a; } int f2(int n) { int *b = n + (int*) 1; n += (int*) 1; return b == (int*) n; }
// RUN: clang -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis | grep "ret i32 1" | count 3 // <rdr://6115726> int f0() { int x; unsigned short n = 1; int *a = &x; int *b = &x; a = a - n; b -= n; return a == b; } int f1(int *a) { long b = a - (int*) 1; a -= (int*) 1; return b == (long) a; } int f2(long n) { int *b = n + (int*) 1; n += (int*) 1; return b == (int*) n; }
Add a basic interface for calcterm
typedef CI_Config void*; CI_Result CI_submit(char const* input);
/* * C Interface between calcterm and a calculator. * A shared library must implement this interface * to be loadable by calcterm. */ extern "C" { struct CI_Config { int flag; }; struct CI_Result { char* one_line; char** grid; int y; }; void CI_init( CI_Config* config ); CI_Result* CI_submit( char const* input ); void CI_result_release( CI_Result* result ); } /* extern "C" */
Remove dependency on npcx specific registers
/* Copyright 2020 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. */ #ifndef __ZEPHYR_CHROME_I2C_MAP_H #define __ZEPHYR_CHROME_I2C_MAP_H #include <devicetree.h> #include "config.h" /* We need registers.h to get the chip specific defines for now */ #include "registers.h" #define I2C_PORT_ACCEL I2C_PORT_SENSOR #define I2C_PORT_SENSOR NPCX_I2C_PORT0_0 #define I2C_PORT_USB_C0 NPCX_I2C_PORT1_0 #define I2C_PORT_USB_C1 NPCX_I2C_PORT2_0 #define I2C_PORT_USB_1_MIX NPCX_I2C_PORT3_0 #define I2C_PORT_POWER NPCX_I2C_PORT5_0 #define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 #define I2C_ADDR_EEPROM_FLAGS 0x50 #endif /* __ZEPHYR_CHROME_I2C_MAP_H */
/* Copyright 2020 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. */ #ifndef __ZEPHYR_CHROME_I2C_MAP_H #define __ZEPHYR_CHROME_I2C_MAP_H #include <devicetree.h> #include "config.h" /* We need registers.h to get the chip specific defines for now */ #include "i2c/i2c.h" #define I2C_PORT_ACCEL I2C_PORT_SENSOR #define I2C_PORT_SENSOR NAMED_I2C(sensor) #define I2C_PORT_USB_C0 NAMED_I2C(usb_c0) #define I2C_PORT_USB_C1 NAMED_I2C(usb_c1) #define I2C_PORT_USB_1_MIX NAMED_I2C(usb1_mix) #define I2C_PORT_POWER NAMED_I2C(power) #define I2C_PORT_EEPROM NAMED_I2C(eeprom) #define I2C_ADDR_EEPROM_FLAGS 0x50 #endif /* __ZEPHYR_CHROME_I2C_MAP_H */
Add RDA5981x D_SRAM for heap usage, test program also attached
#include <tinyara/config.h> #include <tinyara/kmalloc.h> /**************************************************************************** * Name: up_addregion * * Description: * Memory may be added in non-contiguous chunks. Additional chunks are * added by calling this function. * ****************************************************************************/ #if CONFIG_MM_REGIONS > 1 void up_addregion(void) { kumm_addregion((FAR void *)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE); } #endif
UPDATE defined start without menu
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #include "GameState.h" #include "StartState.h" #include "LevelSelectState.h" #include <vector> //#define START_WITHOUT_MENU class GameStateHandler { private: std::vector<GameState*> m_stateStack; std::vector<GameState*> m_statesToRemove; public: GameStateHandler(); ~GameStateHandler(); int ShutDown(); int Initialize(ComponentHandler* cHandler, Camera* cameraRef); int Update(float dt, InputHandler* inputHandler); //Push a state to the stack int PushStateToStack(GameState* state); private: }; #endif
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #include "GameState.h" #include "StartState.h" #include "LevelSelectState.h" #include <vector> #define START_WITHOUT_MENU class GameStateHandler { private: std::vector<GameState*> m_stateStack; std::vector<GameState*> m_statesToRemove; public: GameStateHandler(); ~GameStateHandler(); int ShutDown(); int Initialize(ComponentHandler* cHandler, Camera* cameraRef); int Update(float dt, InputHandler* inputHandler); //Push a state to the stack int PushStateToStack(GameState* state); private: }; #endif
Fix exit issue on Vista/Win7Atom
/* * Copyright 2011 The Native Client 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 <stdlib.h> #include "native_client/src/include/portability.h" #include "native_client/src/shared/platform/nacl_exit.h" #include "native_client/src/trusted/service_runtime/nacl_signal.h" void NaClAbort(void) { #ifdef COVERAGE /* Give coverage runs a chance to flush coverage data */ exit((-SIGABRT) & 0xFF); #else /* Return an 8 bit value for SIGABRT */ TerminateProcess(GetCurrentProcess(),(-SIGABRT) & 0xFF); #endif } void NaClExit(int err_code) { #ifdef COVERAGE /* Give coverage runs a chance to flush coverage data */ exit(err_code); #else TerminateProcess(GetCurrentProcess(), err_code); #endif }
/* * Copyright 2011 The Native Client 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 <stdlib.h> #include <stdio.h> #include "native_client/src/include/portability.h" #include "native_client/src/shared/platform/nacl_exit.h" #include "native_client/src/trusted/service_runtime/nacl_signal.h" void NaClAbort(void) { NaClExit(-SIGABRT); } void NaClExit(int err_code) { #ifdef COVERAGE /* Give coverage runs a chance to flush coverage data */ exit(err_code); #else /* If the process is scheduled for termination, wait for it.*/ if (TerminateProcess(GetCurrentProcess(), err_code)) { printf("Terminate passed, but returned.\n"); while(1); } printf("Terminate failed with %d.\n", GetLastError()); /* Otherwise use the standard C process exit to bybass destructors. */ ExitProcess(err_code); #endif }
Change the type of callId property
#import <Foundation/Foundation.h> /** STWServiceCall is the domain model class which represents the Straw Service Call from Browser. */ @interface STWServiceCall : NSObject /** Service name to call */ @property (nonatomic, retain) NSString *service; /** Service Method name to call */ @property (nonatomic, retain) NSString *method; /** Service Method paramter to call */ @property (nonatomic, retain) NSDictionary *params; /** id of the Service Method call */ @property (nonatomic, retain) NSNumber *callId; /** Return the selector's name. @return the selector's name */ - (NSString *)selectorName; /** Return the selector corresponding to the method. @return the selector corresponding to the method */ - (SEL)selector; @end
#import <Foundation/Foundation.h> /** STWServiceCall is the domain model class which represents the Straw Service Call from Browser. */ @interface STWServiceCall : NSObject /** Service name to call */ @property (nonatomic, retain) NSString *service; /** Service Method name to call */ @property (nonatomic, retain) NSString *method; /** Service Method paramter to call */ @property (nonatomic, retain) NSDictionary *params; /** id of the Service Method call */ @property (nonatomic, retain) NSString *callId; /** Return the selector's name. @return the selector's name */ - (NSString *)selectorName; /** Return the selector corresponding to the method. @return the selector corresponding to the method */ - (SEL)selector; @end
Update Skia milestone to 76
/* * 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 75 #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 76 #endif
Fix wrong header for sourceOfSendToCallbacksForKey
// // BFTaskCenter.h // Pods // // Created by Superbil on 2015/8/22. // // #import <Foundation/Foundation.h> #import "Bolts.h" @interface BFTaskCenter : NSObject + (nonnull instancetype)defaultCenter; - (nullable id)addTaskBlockToCallbacks:(nonnull BFContinuationBlock)taskBlock forKey:(nonnull NSString *)key; - (void)removeTaskBlock:(nonnull id)taskBlock forKey:(nonnull NSString *)key; - (void)clearAllCallbacksForKey:(nonnull NSString *)key; - (void)sendToCallbacksWithKey:(nonnull NSString *)key result:(nullable id)result; - (void)sendToCallbacksWithKey:(nonnull NSString *)key error:(nonnull NSError *)error; - (nonnull BFTaskCompletionSource *)sourceOfSendToCallbacksForKey:(nonnull NSString *)key executor:(nonnull BFExecutor *)executor cancellationToken:(nullable BFCancellationToken *)cancellationToken; @end
// // BFTaskCenter.h // Pods // // Created by Superbil on 2015/8/22. // // #import "Bolts.h" @interface BFTaskCenter : NSObject + (nonnull instancetype)defaultCenter; - (nullable id)addTaskBlockToCallbacks:(nonnull BFContinuationBlock)taskBlock forKey:(nonnull NSString *)key; - (void)removeTaskBlock:(nonnull id)taskBlock forKey:(nonnull NSString *)key; - (void)clearAllCallbacksForKey:(nonnull NSString *)key; - (void)sendToCallbacksWithKey:(nonnull NSString *)key result:(nullable id)result; - (void)sendToCallbacksWithKey:(nonnull NSString *)key error:(nonnull NSError *)error; - (nullable BFTaskCompletionSource *)sourceOfSendToCallbacksForKey:(nonnull NSString *)key executor:(nonnull BFExecutor *)executor cancellationToken:(nullable BFCancellationToken *)cancellationToken; @end
Fix lint error, whitespace around &&
#pragma once #ifndef YOU_DATASTORE_DATASTORE_H_ #define YOU_DATASTORE_DATASTORE_H_ #include <deque> #include <functional> #include "boost/variant.hpp" #include "task_typedefs.h" #include "internal/operation.h" #include "transaction.h" namespace You { namespace DataStore { namespace UnitTests {} class DataStore { public: Transaction&& begin(); // Modifying methods bool post(TaskId, SerializedTask&); bool put(TaskId, SerializedTask&); bool erase(TaskId); std::vector<SerializedTask> getAllTask(); private: static DataStore& get(); bool isServing = false; std::deque<Internal::IOperation> operationsQueue; }; } // namespace DataStore } // namespace You #endif // YOU_DATASTORE_DATASTORE_H_
#pragma once #ifndef YOU_DATASTORE_DATASTORE_H_ #define YOU_DATASTORE_DATASTORE_H_ #include <deque> #include <functional> #include "boost/variant.hpp" #include "task_typedefs.h" #include "internal/operation.h" #include "transaction.h" namespace You { namespace DataStore { namespace UnitTests {} class DataStore { public: Transaction && begin(); // Modifying methods bool post(TaskId, SerializedTask&); bool put(TaskId, SerializedTask&); bool erase(TaskId); std::vector<SerializedTask> getAllTask(); private: static DataStore& get(); bool isServing = false; std::deque<Internal::IOperation> operationsQueue; }; } // namespace DataStore } // namespace You #endif // YOU_DATASTORE_DATASTORE_H_
Add unify combine substitute stubs
#pragma once #include <boost/variant.hpp> #include <atomic> #include <vector> namespace grml { enum class BasicType { INT, BOOL, REAL }; struct TypeVariable { int64_t id; TypeVariable() : id(counter++) {} TypeVariable(int64_t i) : id(i) {} friend bool operator==(const TypeVariable& lhs, const TypeVariable& rhs) { return lhs.id == rhs.id; } private: static std::atomic_int64_t counter; }; struct FunctionType; using Type = boost::variant< BasicType, TypeVariable, boost::recursive_wrapper<FunctionType> >; struct FunctionType { using Parameters = std::vector<Type>; Type result; Parameters parameters; FunctionType(Type r, Parameters ps) : result(std::move(r)), parameters(std::move(ps)) {} friend bool operator==(const FunctionType& lhs, const FunctionType& rhs) { return lhs.result == rhs.result && lhs.parameters == rhs.parameters; } }; }
#pragma once #include <boost/variant.hpp> #include <atomic> #include <vector> #include <unordered_map> namespace grml { enum class BasicType { INT, BOOL, REAL }; struct TypeVariable { int64_t id; TypeVariable() : id(counter++) {} TypeVariable(int64_t i) : id(i) {} friend bool operator==(const TypeVariable& lhs, const TypeVariable& rhs) { return lhs.id == rhs.id; } private: static std::atomic_int64_t counter; }; struct FunctionType; using Type = boost::variant< BasicType, TypeVariable, boost::recursive_wrapper<FunctionType> >; struct FunctionType { using Parameters = std::vector<Type>; Type result; Parameters parameters; FunctionType(Type r, Parameters ps) : result(std::move(r)), parameters(std::move(ps)) {} friend bool operator==(const FunctionType& lhs, const FunctionType& rhs) { return lhs.result == rhs.result && lhs.parameters == rhs.parameters; } }; struct TypeVariableHasher { std::size_t operator()(const TypeVariable& tv) const { return tv.id; } }; using Substitution = std::unordered_map<TypeVariable, Type, TypeVariableHasher>; Substitution unify(const Type& lhs, const Type& rhs); Substitution combine(const Substitution& lhs, const Substitution& rhs); Type substitute(const Type& type, const Substitution& substitution); }
Add the class 'CMDLINE'. So the user is able to change default setting.
#ifndef CMDLINE_H #define CMDLINE_H typedef struct cmdOptions{ int populationSize; int geneSize; }cmdoptions_t; class CMDLINE { int argc; char *argv[]; public: CMDLINE (int, char**); // Constructor int parseCommandLine(cmdoptions_t *CMDoptions); private: // Function like help and version int help(); int version(); }; #endif
Exit with a code in debug builds
#include <arch/x64/port.h> #include <truth/panic.h> #define TEST_RESULT_PORT_NUMBER 0xf4 void test_shutdown_status(enum status status) { logf(Log_Debug, "Test shutting down with status %s (%d)\n", status_message(status), status); write_port(status, TEST_RESULT_PORT_NUMBER); halt(); assert(Not_Reached); }
#include <arch/x64/port.h> #include <truth/panic.h> #define Test_Result_Port_Number 0xf4 void test_shutdown_status(enum status status) { logf(Log_Debug, "Test shutting down with status %s (%d)\n", status_message(status), status); write_port(status, Test_Result_Port_Number); }
Clean up some debugging cruft.
#include <errno.h> #include <signal.h> #include <string.h> #include <unistd.h> #include <stdbool.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/types.h> #include <glib.h> #include "td-radio.h" #include "td-radio-scan.h" /* * Send the RESPONDER message to the radio. */ int radio_read(int fd, char* buffer) { bool debug = true; int bytes = 0; memset(buffer, '\0', BUFFER_SZ); if (debug) { g_message("radio_read(): enter"); g_message("\ts_addr = %d", radio_address.sin_addr.s_addr); g_message("\tsin_port = %d", radio_address.sin_port); } socklen_t socklen = sizeof(radio_address); bytes = recvfrom(fd, buffer, BUFFER_SZ, 0, (struct sockaddr *) &radio_address, &socklen); if (debug) { g_message("bytes = %d", bytes); } if (bytes < 0) { g_warning("\tradio_read(): recvfrom failed, %s", strerror(errno)); g_message("\tradio_read(): exit"); } if (debug) { g_message("radio_read(): exit"); } return bytes; }
#include <errno.h> #include <signal.h> #include <string.h> #include <unistd.h> #include <stdbool.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/types.h> #include <glib.h> #include "td-radio.h" #include "td-radio-scan.h" /* * Send the RESPONDER message to the radio. */ int radio_read(int fd, char* buffer) { bool debug = false; int bytes = 0; memset(buffer, '\0', BUFFER_SZ); socklen_t socklen = sizeof(radio_address); bytes = recvfrom(fd, buffer, BUFFER_SZ, 0, 0, 0); if (bytes < 0) { g_warning("\tradio_read(): recvfrom failed, %s", strerror(errno)); g_error("\tradio_read(): exiting..."); } return bytes; }
Make everything work on linux again
#define ASSERT(x) \ do{ \ if(!(x)){ \ printf("failed assert (%d): %s\n", __LINE__, #x); \ exit(1); \ }\ }while(0) #define INIT_SOCKETS_FOR_WINDOWS \ { \ WSADATA out; \ WSAStartup(MAKEWORD(2,2), &out); \ }
#include <stdlib.h> #define ASSERT(x) \ do{ \ if(!(x)){ \ printf("failed assert (%d): %s\n", __LINE__, #x); \ exit(1); \ }\ }while(0) #ifdef _WIN32 #define INIT_SOCKETS_FOR_WINDOWS \ do{ \ WSADATA out; \ WSAStartup(MAKEWORD(2,2), &out); \ } while(0) #else #define INIT_SOCKETS_FOR_WINDOWS do {} while(0) #endif
Set the header protection to end with _H.
#ifndef RANDOM_HAO #define RANDOM_HAO #define SIMPLE_SPRNG #ifdef MPI_HAO #include <mpi.h> #define USE_MPI #endif #include "sprng.h" void random_hao_init(int seed=985456376, int gtype=1); double uniform_hao(); double gaussian_hao(); #endif
#ifndef RANDOM_HAO_H #define RANDOM_HAO_H #define SIMPLE_SPRNG #ifdef MPI_HAO #include <mpi.h> #define USE_MPI #endif #include "sprng.h" void random_hao_init(int seed=985456376, int gtype=1); double uniform_hao(); double gaussian_hao(); #endif
Fix PROV_RC5_CTX's original structure name
/* * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include <openssl/rc5.h> #include "prov/ciphercommon.h" typedef struct prov_blowfish_ctx_st { PROV_CIPHER_CTX base; /* Must be first */ union { OSSL_UNION_ALIGN; RC5_32_KEY ks; /* key schedule */ } ks; unsigned int rounds; /* number of rounds */ } PROV_RC5_CTX; const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_cbc(size_t keybits); const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_ecb(size_t keybits); const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_ofb64(size_t keybits); const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_cfb64(size_t keybits);
/* * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include <openssl/rc5.h> #include "prov/ciphercommon.h" typedef struct prov_rc5_ctx_st { PROV_CIPHER_CTX base; /* Must be first */ union { OSSL_UNION_ALIGN; RC5_32_KEY ks; /* key schedule */ } ks; unsigned int rounds; /* number of rounds */ } PROV_RC5_CTX; const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_cbc(size_t keybits); const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_ecb(size_t keybits); const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_ofb64(size_t keybits); const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_cfb64(size_t keybits);
Add a JsonNode copy test unit
#include <glib/gtestutils.h> #include <json-glib/json-types.h> #include <string.h> static void test_null (void) { JsonNode *node = json_node_new (JSON_NODE_NULL); g_assert_cmpint (node->type, ==, JSON_NODE_NULL); g_assert_cmpint (json_node_get_value_type (node), ==, G_TYPE_INVALID); g_assert_cmpstr (json_node_type_name (node), ==, "NULL"); json_node_free (node); } int main (int argc, char *argv[]) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add_func ("/nodes/null-node", test_null); return g_test_run (); }
#include <glib/gtestutils.h> #include <json-glib/json-types.h> #include <string.h> static void test_copy (void) { JsonNode *node = json_node_new (JSON_NODE_NULL); JsonNode *copy = json_node_copy (node); g_assert_cmpint (node->type, ==, copy->type); g_assert_cmpint (json_node_get_value_type (node), ==, json_node_get_value_type (copy)); g_assert_cmpstr (json_node_type_name (node), ==, json_node_type_name (copy)); json_node_free (copy); json_node_free (node); } static void test_null (void) { JsonNode *node = json_node_new (JSON_NODE_NULL); g_assert_cmpint (node->type, ==, JSON_NODE_NULL); g_assert_cmpint (json_node_get_value_type (node), ==, G_TYPE_INVALID); g_assert_cmpstr (json_node_type_name (node), ==, "NULL"); json_node_free (node); } int main (int argc, char *argv[]) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add_func ("/nodes/null-node", test_null); g_test_add_func ("/nodes/copy-node", test_copy); return g_test_run (); }
Fix build of libc.so after r232620. This caused a duplicate definition of __getCurrentRuneLocale().
#include <sys/cdefs.h> __FBSDID("$FreeBSD$"); /* * Tell <ctype.h> to generate extern versions of all its inline * functions. The extern versions get called if the system doesn't * support inlines or the user defines _DONT_USE_CTYPE_INLINE_ * before including <ctype.h>. */ #define _EXTERNALIZE_CTYPE_INLINES_ #include <ctype.h>
#include <sys/cdefs.h> __FBSDID("$FreeBSD$"); /* * Tell <ctype.h> to generate extern versions of all its inline * functions. The extern versions get called if the system doesn't * support inlines or the user defines _DONT_USE_CTYPE_INLINE_ * before including <ctype.h>. */ #define _EXTERNALIZE_CTYPE_INLINES_ /* * Also make sure <runetype.h> does not generate an inline definition * of __getCurrentRuneLocale(). */ #define __RUNETYPE_INTERNAL #include <ctype.h>
Add vh_json_get in the API
/* * GeeXboX Valhalla: tiny media scanner API. * Copyright (C) 2016 Mathieu Schroeter <mathieu@schroetersa.ch> * * This file is part of libvalhalla. * * libvalhalla is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * libvalhalla is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with libvalhalla; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef VALHALLA_JSON_UTILS_H #define VALHALLA_JSON_UTILS_H #include <json-c/json_tokener.h> char *vh_json_get_str (json_object *json, const char *path); int vh_json_get_int (json_object *json, const char *path); #endif /* VALHALLA_JSON_UTILS_H */
/* * GeeXboX Valhalla: tiny media scanner API. * Copyright (C) 2016 Mathieu Schroeter <mathieu@schroetersa.ch> * * This file is part of libvalhalla. * * libvalhalla is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * libvalhalla is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with libvalhalla; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef VALHALLA_JSON_UTILS_H #define VALHALLA_JSON_UTILS_H #include <json-c/json_tokener.h> json_object *vh_json_get (json_object *json, const char *path); char *vh_json_get_str (json_object *json, const char *path); int vh_json_get_int (json_object *json, const char *path); #endif /* VALHALLA_JSON_UTILS_H */
Add flags success and willRetry to ResponseData
// // AIResponseData.h // AdjustIo // // Created by Christian Wellenbrock on 07.02.14. // Copyright (c) 2014 adeven. All rights reserved. // typedef enum { AIActivityKindUnknown = 0, AIActivityKindSession = 1, AIActivityKindEvent = 2, AIActivityKindRevenue = 3, // only possible when server could be reached because the SDK can't know // whether or not a session might be an install or reattribution AIActivityKindInstall = 4, AIActivityKindReattribution = 5, } AIActivityKind; @interface AIResponseData : NSObject @property (nonatomic, assign) AIActivityKind activityKind; @property (nonatomic, copy) NSString *trackerToken; @property (nonatomic, copy) NSString *trackerName; @property (nonatomic, copy) NSString *error; + (AIResponseData *)dataWithJsonString:(NSString *)string; - (id)initWithJsonString:(NSString *)string; @end
// // AIResponseData.h // AdjustIo // // Created by Christian Wellenbrock on 07.02.14. // Copyright (c) 2014 adeven. All rights reserved. // typedef enum { AIActivityKindUnknown = 0, AIActivityKindSession = 1, AIActivityKindEvent = 2, AIActivityKindRevenue = 3, // only possible when server could be reached because the SDK can't know // whether or not a session might be an install or reattribution AIActivityKindInstall = 4, AIActivityKindReattribution = 5, } AIActivityKind; @class AIActivityPackage; /* * Information about the result of a tracking attempt * * Will be passed to the delegate function adjustIoTrackedActivityWithResponse */ @interface AIResponseData : NSObject // the kind of activity (install, session, event, etc.) // see the AIActivity definition above @property (nonatomic, assign) AIActivityKind activityKind; // true when the activity was tracked successfully // might be true even if response could not be parsed @property (nonatomic, assign) BOOL success; // true if the server was not reachable and the request will be tried again later @property (nonatomic, assign) BOOL willRetry; // nil if activity was tracked successfully and response could be parsed // might be not nil even when activity was tracked successfully @property (nonatomic, copy) NSString *error; // the following attributes are only set when error is nil // (when activity was tracked successfully and response could be parsed) // tracker token of current device @property (nonatomic, copy) NSString *trackerToken; // tracker name of current device @property (nonatomic, copy) NSString *trackerName; + (AIResponseData *)dataWithJsonString:(NSString *)string; + (AIResponseData *)dataWithError:(NSString *)error; - (id)initWithJsonString:(NSString *)string; - (id)initWithError:(NSString *)error; @end
Add testcase that illustrates the problem from r69699 regarding tentative definitions of statics
// RUN: clang-cc -emit-llvm -o %t %s && // RUN: grep '@r = common global \[1 x .*\] zeroinitializer' %t && int r[]; int (*a)[] = &r; struct s0; struct s0 x; // RUN: grep '@x = common global .struct.s0 zeroinitializer' %t && struct s0 y; // RUN: grep '@y = common global .struct.s0 zeroinitializer' %t && struct s0 *f0() { return &y; } struct s0 { int x; }; // RUN: grep '@b = common global \[1 x .*\] zeroinitializer' %t && int b[]; int *f1() { return b; } // Check that the most recent tentative definition wins. // RUN: grep '@c = common global \[4 x .*\] zeroinitializer' %t && int c[]; int c[4]; // RUN: true
// RUN: clang-cc -emit-llvm -o %t %s && // RUN: grep '@r = common global \[1 x .*\] zeroinitializer' %t && int r[]; int (*a)[] = &r; struct s0; struct s0 x; // RUN: grep '@x = common global .struct.s0 zeroinitializer' %t && struct s0 y; // RUN: grep '@y = common global .struct.s0 zeroinitializer' %t && struct s0 *f0() { return &y; } struct s0 { int x; }; // RUN: grep '@b = common global \[1 x .*\] zeroinitializer' %t && int b[]; int *f1() { return b; } // Check that the most recent tentative definition wins. // RUN: grep '@c = common global \[4 x .*\] zeroinitializer' %t && int c[]; int c[4]; // Check that we emit static tentative definitions // RUN: grep '@c5 = internal global \[1 x .*\] zeroinitializer' %t && static int c5[]; static int func() { return c5[0]; } int callfunc() { return func(); } // RUN: true
Increment version number for 3.5 beta2.
/* resource.h KNode, the KDE newsreader Copyright (c) 1999-2005 the KNode authors. See file AUTHORS for details 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US */ #ifndef RESSOURCE_H #define RESSOURCE_H #ifdef HAVE_CONFIG_H #include <config.h> #endif //========= KNode Version Information ============ #define KNODE_VERSION "0.9.91" //================= StatusBar ==================== #define SB_MAIN 4000005 #define SB_GROUP 4000010 #define SB_FILTER 4000030 //================== Folders ===================== #define FOLD_DRAFTS 200010 #define FOLD_SENT 200020 #define FOLD_OUTB 200030 #endif // RESOURCE_H
/* resource.h KNode, the KDE newsreader Copyright (c) 1999-2005 the KNode authors. See file AUTHORS for details 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US */ #ifndef RESSOURCE_H #define RESSOURCE_H #ifdef HAVE_CONFIG_H #include <config.h> #endif //========= KNode Version Information ============ #define KNODE_VERSION "0.9.92" //================= StatusBar ==================== #define SB_MAIN 4000005 #define SB_GROUP 4000010 #define SB_FILTER 4000030 //================== Folders ===================== #define FOLD_DRAFTS 200010 #define FOLD_SENT 200020 #define FOLD_OUTB 200030 #endif // RESOURCE_H
Add SIT151 C PC3 Ex1
#include <stdio.h> typedef struct { char last_name[20]; char first_name[15]; int age; } Person; int ask() { printf("1. Add user\n"); printf("2. Quit\n"); return getchar() - 48; } Person createPerson() { Person p; printf("Last name: "); scanf("%s", p.last_name); printf("First name: "); scanf("%s", p.first_name); printf("Age: "); scanf("%d", &p.age); return p; } int main() { FILE *f; if ((f = fopen("users.txt", "a")) != NULL) { int choice; while ((choice = ask()) != 2) { if (choice == 1) { Person p = createPerson(); fprintf(f, "%s_%s_%d\n", p.last_name, p.first_name, p.age); } } fclose(f); } else { printf("Error while opening users.txt\n"); } return 0; }
Add nullability specifiers to FEMMapBlock
// For License please refer to LICENSE file in the root of FastEasyMapping project #import <Foundation/Foundation.h> typedef __nullable id (^FEMMapBlock)(id value __nonnull);
// For License please refer to LICENSE file in the root of FastEasyMapping project #import <Foundation/Foundation.h> typedef __nullable id (^FEMMapBlock)(__nonnull id value);
Declare initWithDefaultValues in private category
//////////////////////////////////////////////////////////////////////////// // // TIGHTDB CONFIDENTIAL // __________________ // // [2011] - [2014] TightDB Inc // All Rights Reserved. // // NOTICE: All information contained herein is, and remains // the property of TightDB Incorporated and its suppliers, // if any. The intellectual and technical concepts contained // herein are proprietary to TightDB Incorporated // and its suppliers and may be covered by U.S. and Foreign Patents, // patents in process, and are protected by trade secret or copyright law. // Dissemination of this information or reproduction of this material // is strictly forbidden unless prior written permission is obtained // from TightDB Incorporated. // //////////////////////////////////////////////////////////////////////////// #import "RLMObject.h" #import "RLMAccessor.h" #import "RLMObjectSchema.h" // RLMObject accessor and read/write realm @interface RLMObject () <RLMAccessor> @property (nonatomic, readwrite) RLMRealm *realm; @property (nonatomic) RLMObjectSchema *schema; @end
//////////////////////////////////////////////////////////////////////////// // // TIGHTDB CONFIDENTIAL // __________________ // // [2011] - [2014] TightDB Inc // All Rights Reserved. // // NOTICE: All information contained herein is, and remains // the property of TightDB Incorporated and its suppliers, // if any. The intellectual and technical concepts contained // herein are proprietary to TightDB Incorporated // and its suppliers and may be covered by U.S. and Foreign Patents, // patents in process, and are protected by trade secret or copyright law. // Dissemination of this information or reproduction of this material // is strictly forbidden unless prior written permission is obtained // from TightDB Incorporated. // //////////////////////////////////////////////////////////////////////////// #import "RLMObject.h" #import "RLMAccessor.h" #import "RLMObjectSchema.h" // RLMObject accessor and read/write realm @interface RLMObject () <RLMAccessor> -(instancetype)initWithDefaultValues:(BOOL)useDefaults; @property (nonatomic, readwrite) RLMRealm *realm; @property (nonatomic) RLMObjectSchema *schema; @end
Fix incorrect indentation in TExtensionModule struct
#ifndef SUPPORT_H #define SUPPORT_H #include <stdio.h> struct tagTModule; typedef struct tagTExtensionModule { char *module; void *handle; } TExtensionModule; typedef struct tagTExtensions { TExtensionModule *modules; size_t size; } TExtenstions; void path_initPaths(const char *source_path); void path_freePaths(); void path_readModule(struct tagTModule *m); void path_dumpPaths(); FILE *path_findModule(const char *name, char *modulePath); char *path_getFileNameOnly(char *path); char *path_getPathOnly(char *path); TExtensionModule *ext_findModule(const char *moduleName); void ext_insertModule(const char *name, void *handle); void ext_cleanup(void); #endif
#ifndef SUPPORT_H #define SUPPORT_H #include <stdio.h> struct tagTModule; typedef struct tagTExtensionModule { char *module; void *handle; } TExtensionModule; typedef struct tagTExtensions { TExtensionModule *modules; size_t size; } TExtenstions; void path_initPaths(const char *source_path); void path_freePaths(); void path_readModule(struct tagTModule *m); void path_dumpPaths(); FILE *path_findModule(const char *name, char *modulePath); char *path_getFileNameOnly(char *path); char *path_getPathOnly(char *path); TExtensionModule *ext_findModule(const char *moduleName); void ext_insertModule(const char *name, void *handle); void ext_cleanup(void); #endif
Fix compile error on Windows
#include "pycall_internal.h" #if defined(PYCALL_THREAD_WIN32) int pycall_tls_create(pycall_tls_key *tls_key) { *tls_key = TlsAlloc(); return *tls_key == TLS_OUT_OF_INDEXES; } void *pycall_tls_get(pycall_tls_key tls_key) { return TlsGetValue(tls_key); } int pycall_tls_set(pycall_tls_key tls_key, void *ptr) { return TlsSetValue(tls_key, th) == 0; } #endif #if defined(PYCALL_THREAD_PTHREAD) int pycall_tls_create(pycall_tls_key *tls_key) { return pthread_key_create(tls_key, NULL); } void *pycall_tls_get(pycall_tls_key tls_key) { return pthread_getspecific(tls_key); } int pycall_tls_set(pycall_tls_key tls_key, void *ptr) { return pthread_setspecific(tls_key, ptr); } #endif
#include "pycall_internal.h" #if defined(PYCALL_THREAD_WIN32) int pycall_tls_create(pycall_tls_key *tls_key) { *tls_key = TlsAlloc(); return *tls_key == TLS_OUT_OF_INDEXES; } void *pycall_tls_get(pycall_tls_key tls_key) { return TlsGetValue(tls_key); } int pycall_tls_set(pycall_tls_key tls_key, void *ptr) { return 0 == TlsSetValue(tls_key, ptr); } #endif #if defined(PYCALL_THREAD_PTHREAD) int pycall_tls_create(pycall_tls_key *tls_key) { return pthread_key_create(tls_key, NULL); } void *pycall_tls_get(pycall_tls_key tls_key) { return pthread_getspecific(tls_key); } int pycall_tls_set(pycall_tls_key tls_key, void *ptr) { return pthread_setspecific(tls_key, ptr); } #endif
Add tests for alternative timing method
#include "lib/timing.h" task main() { writeDebugStreamLine("Waiting 1 second"); resetTimeDelta(); getTimeDelta(); wait1Msec(1000); writeDebugStreamLine("delta: %d", getTimeDelta()); writeDebugStreamLine("Waiting 5 seconds"); resetTimeDelta(); getTimeDelta(); wait1Msec(5000); writeDebugStreamLine("delta: %d", getTimeDelta()); writeDebugStreamLine("Waiting 10 seconds"); resetTimeDelta(); getTimeDelta(); wait1Msec(10000); writeDebugStreamLine("delta: %d", getTimeDelta()); }
#include "lib/timing.h" task main() { // getTimeDelta() writeDebugStreamLine("Testing getTimeDelta()"); writeDebugStreamLine("Waiting 1 second"); resetTimeDelta(); getTimeDelta(); wait1Msec(1000); writeDebugStreamLine("delta: %d", getTimeDelta()); writeDebugStreamLine("Waiting 5 seconds"); resetTimeDelta(); getTimeDelta(); wait1Msec(5000); writeDebugStreamLine("delta: %d", getTimeDelta()); writeDebugStreamLine("Waiting 10 seconds"); resetTimeDelta(); getTimeDelta(); wait1Msec(10000); writeDebugStreamLine("delta: %d", getTimeDelta()); writeDebugStreamLine("Testing getTimeDeltaTimer() (using default timer)"); writeDebugStreamLine("Waiting 1 second"); resetTimeDeltaTimer(); getTimeDeltaTimer(); wait1Msec(1000); writeDebugStreamLine("delta: %d", getTimeDeltaTimer()); writeDebugStreamLine("Waiting 5 seconds"); resetTimeDeltaTimer(); getTimeDeltaTimer(); wait1Msec(5000); writeDebugStreamLine("delta: %d", getTimeDeltaTimer()); writeDebugStreamLine("Waiting 10 seconds"); resetTimeDeltaTimer(); getTimeDeltaTimer(); wait1Msec(10000); writeDebugStreamLine("delta: %d", getTimeDeltaTimer()); }
Synchronize decl and impl of notify(…)
#import <Foundation/Foundation.h> #import <React/RCTBridgeModule.h> #if __has_include(<React/RCTBridge.h>) // React Native >= 0.40 #import <React/RCTBridge.h> #else // React Native <= 0.39 #import "RCTBridge.h" #endif @class BugsnagConfiguration; @interface BugsnagReactNative: NSObject <RCTBridgeModule> /** * Initializes the crash handler with the default options and using the API key * stored in the Info.plist using the key "BugsnagAPIKey" */ + (void)start; /** * Initializes the crash handler with the default options * @param APIKey the API key to use when sending error reports */ + (void)startWithAPIKey:(NSString *)APIKey; /** * Initializes the crash handler with custom options * @param config the configuration options to use */ + (void)startWithConfiguration:(BugsnagConfiguration *)config; - (void)startWithOptions:(NSDictionary *)options; - (void)leaveBreadcrumb:(NSDictionary *)options; - (void)notify:(NSDictionary *)payload; - (void)setUser:(NSDictionary *)userInfo; - (void)clearUser; - (void)startSession; @end
#import <Foundation/Foundation.h> #import <React/RCTBridgeModule.h> #if __has_include(<React/RCTBridge.h>) // React Native >= 0.40 #import <React/RCTBridge.h> #else // React Native <= 0.39 #import "RCTBridge.h" #endif @class BugsnagConfiguration; @interface BugsnagReactNative: NSObject <RCTBridgeModule> /** * Initializes the crash handler with the default options and using the API key * stored in the Info.plist using the key "BugsnagAPIKey" */ + (void)start; /** * Initializes the crash handler with the default options * @param APIKey the API key to use when sending error reports */ + (void)startWithAPIKey:(NSString *)APIKey; /** * Initializes the crash handler with custom options * @param config the configuration options to use */ + (void)startWithConfiguration:(BugsnagConfiguration *)config; - (void)startWithOptions:(NSDictionary *)options; - (void)leaveBreadcrumb:(NSDictionary *)options; - (void)notify:(NSDictionary *)payload resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject; - (void)setUser:(NSDictionary *)userInfo; - (void)clearUser; - (void)startSession; @end
Fix warning during dictionary generation in no-imt builds
#ifdef __CLING__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; // Only for the autoload, autoparse. No IO of these classes is foreseen! #pragma link C++ class ROOT::Internal::TPoolManager-; #pragma link C++ class ROOT::TThreadExecutor-; #pragma link C++ class ROOT::Experimental::TTaskGroup-; #endif
#ifdef __CLING__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; // Only for the autoload, autoparse. No IO of these classes is foreseen! // Exclude in case ROOT does not have IMT support #ifdef R__USE_IMT #pragma link C++ class ROOT::Internal::TPoolManager-; #pragma link C++ class ROOT::TThreadExecutor-; #pragma link C++ class ROOT::Experimental::TTaskGroup-; #endif #endif
Adjust default max tip age
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2014-2017 The Dash Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_VALIDATION_H #define BITCOIN_VALIDATION_H #include <stdint.h> #include <string> static const int64_t DEFAULT_MAX_TIP_AGE = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin extern int64_t nMaxTipAge; FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); FILE* AppendBlockFile(unsigned int& nFileRet); bool IsInitialBlockDownload(); #endif // BITCOIN_VALIDATION_H
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2014-2017 The Dash Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_VALIDATION_H #define BITCOIN_VALIDATION_H #include <stdint.h> #include <string> static const int64_t DEFAULT_MAX_TIP_AGE = 1 * 60 * 60; // ~45 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin extern int64_t nMaxTipAge; FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); FILE* AppendBlockFile(unsigned int& nFileRet); bool IsInitialBlockDownload(); #endif // BITCOIN_VALIDATION_H
Add comment about thread safety.
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "isequencedtaskexecutor.h" #include <vector> namespace vespalib { struct ExecutorStats; class SyncableThreadExecutor; } namespace search { /** * Class to run multiple tasks in parallel, but tasks with same * id has to be run in sequence. */ class SequencedTaskExecutor final : public ISequencedTaskExecutor { using Stats = vespalib::ExecutorStats; std::unique_ptr<std::vector<std::unique_ptr<vespalib::SyncableThreadExecutor>>> _executors; SequencedTaskExecutor(std::unique_ptr<std::vector<std::unique_ptr<vespalib::SyncableThreadExecutor>>> executor); public: enum class Optimize {LATENCY, THROUGHPUT}; using ISequencedTaskExecutor::getExecutorId; ~SequencedTaskExecutor(); void setTaskLimit(uint32_t taskLimit) override; void executeTask(ExecutorId id, vespalib::Executor::Task::UP task) override; void sync() override; Stats getStats() override; static std::unique_ptr<ISequencedTaskExecutor> create(uint32_t threads, uint32_t taskLimit = 1000, Optimize optimize = Optimize::THROUGHPUT); }; } // namespace search
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "isequencedtaskexecutor.h" #include <vector> namespace vespalib { struct ExecutorStats; class SyncableThreadExecutor; } namespace search { /** * Class to run multiple tasks in parallel, but tasks with same * id has to be run in sequence. */ class SequencedTaskExecutor final : public ISequencedTaskExecutor { using Stats = vespalib::ExecutorStats; std::unique_ptr<std::vector<std::unique_ptr<vespalib::SyncableThreadExecutor>>> _executors; SequencedTaskExecutor(std::unique_ptr<std::vector<std::unique_ptr<vespalib::SyncableThreadExecutor>>> executor); public: enum class Optimize {LATENCY, THROUGHPUT}; using ISequencedTaskExecutor::getExecutorId; ~SequencedTaskExecutor(); void setTaskLimit(uint32_t taskLimit) override; void executeTask(ExecutorId id, vespalib::Executor::Task::UP task) override; void sync() override; Stats getStats() override; /* * Note that if you choose Optimize::THROUGHPUT, you must ensure only a single producer, or synchronize on the outside. */ static std::unique_ptr<ISequencedTaskExecutor> create(uint32_t threads, uint32_t taskLimit = 1000, Optimize optimize = Optimize::LATENCY); }; } // namespace search
Check return value of pclose()
/* See LICENSE file for copyright and license details. */ #include <errno.h> #include <stdio.h> #include <string.h> #include "../util.h" const char * run_command(const char *cmd) { char *p; FILE *fp; if (!(fp = popen(cmd, "r"))) { warn("popen '%s':", cmd); return NULL; } p = fgets(buf, sizeof(buf) - 1, fp); pclose(fp); if (!p) { return NULL; } if ((p = strrchr(buf, '\n'))) { p[0] = '\0'; } return buf[0] ? buf : NULL; }
/* See LICENSE file for copyright and license details. */ #include <errno.h> #include <stdio.h> #include <string.h> #include "../util.h" const char * run_command(const char *cmd) { char *p; FILE *fp; if (!(fp = popen(cmd, "r"))) { warn("popen '%s':", cmd); return NULL; } p = fgets(buf, sizeof(buf) - 1, fp); if (pclose(fp) < 0) { warn("pclose '%s':", cmd); return NULL; } if (!p) { return NULL; } if ((p = strrchr(buf, '\n'))) { p[0] = '\0'; } return buf[0] ? buf : NULL; }
Add comment explaining impact of option in test case
// PARAM: --enable annotation.int.enabled #include <stdlib.h> #include <goblint.h> struct slotvec { size_t size ; char *val ; }; static char slot0[256] ; static struct slotvec slotvec0 = {sizeof(slot0), slot0}; static void install_signal_handlers(void) { { if(!(slotvec0.val == & slot0[0LL])) { reach_error(); abort(); } }; } int main(int argc , char **argv ) { // Goblint used to consider both branches in this condition to be dead, because the meet on addresses with different active int domains was broken { if(!(slotvec0.val == & slot0[0LL])) { reach_error(); abort(); } }; install_signal_handlers(); // Should be reachable __goblint_check(1); return 0; }
// PARAM: --enable annotation.int.enabled // This option enables ALL int domains for globals #include <stdlib.h> #include <goblint.h> struct slotvec { size_t size ; char *val ; }; static char slot0[256] ; static struct slotvec slotvec0 = {sizeof(slot0), slot0}; static void install_signal_handlers(void) { { if(!(slotvec0.val == & slot0[0LL])) { reach_error(); abort(); } }; } int main(int argc , char **argv ) { // Goblint used to consider both branches in this condition to be dead, because the meet on addresses with different active int domains was broken { if(!(slotvec0.val == & slot0[0LL])) { reach_error(); abort(); } }; install_signal_handlers(); // Should be reachable __goblint_check(1); return 0; }
Implement faster natural log function
#include <pal.h> /** * * Calculates the natural logarithm of 'a', (where the base is 'e'=2.71828) * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @param p Number of processor to use (task parallelism) * * @param team Team to work with * * @return None * */ #include <math.h> void p_ln_f32(const float *a, float *c, int n, int p, p_team_t team) { int i; for (i = 0; i < n; i++) { *(c + i) = logf(*(a + i)); } }
#include <pal.h> /** * * Calculates the natural logarithm of 'a', (where the base is 'e'=2.71828) * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @param p Number of processor to use (task parallelism) * * @param team Team to work with * * @return None * */ void p_ln_f32(const float *a, float *c, int n, int p, p_team_t team) { int i; for (i = 0; i < n; i++) { union { float f; uint32_t i; } u = { *(a + i) }; // Calculate the exponent (which is the floor of the logarithm) minus one int e = ((u.i >> 23) & 0xff) - 0x80; // Mask off the exponent, leaving just the mantissa u.i = (u.i & 0x7fffff) + 0x3f800000; // Interpolate using a cubic minimax polynomial derived with // the Remez exchange algorithm. Coefficients courtesy of Alex Kan. // This approximates 1 + log2 of the mantissa. float r = ((0.15824870f * u.f - 1.05187502f) * u.f + 3.04788415f) * u.f - 1.15360271f; // The log2 of the complete value is then the sum // of the previous quantities (the 1's cancel), and // we find the natural log by scaling by log2(e). *(c + i) = (e + r) * 0.69314718f; } }
Remove unused fprintf arg; add comment on _wtoi
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <windows.h> #define URL "https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505\ (v=vs.85).aspx" #define VERSION "0.1.0" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd) { LPWSTR *szArgList; int argCount; szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount); if (szArgList == NULL) { fprintf(stderr, "Unable to parse the command line.\n"); return 255; } if (argCount < 3 || argCount > 4) { fprintf(stderr, "Batch MessageBox v" VERSION "\n", szArgList[0]); fprintf(stderr, "Usage: %ls message title [type]\n\n", szArgList[0]); fprintf(stderr, "Calls MessageBoxW() with the given arguments. See\n" URL "\nfor the possible values of \"type\". " "ERRORLEVEL is the return value or 255 on\nerror.\n"); return 255; } int type = _wtoi(szArgList[3]); int button = MessageBoxW(NULL, szArgList[1], szArgList[2], type); LocalFree(szArgList); return button; }
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <windows.h> #define URL "https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505\ (v=vs.85).aspx" #define VERSION "0.1.0" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd) { LPWSTR *szArgList; int argCount; szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount); if (szArgList == NULL) { fprintf(stderr, "Unable to parse the command line.\n"); return 255; } if (argCount < 3 || argCount > 4) { fprintf(stderr, "Batch MessageBox v" VERSION "\n"); fprintf(stderr, "Usage: %ls message title [type]\n\n", szArgList[0]); fprintf(stderr, "Calls MessageBoxW() with the given arguments. See\n" URL "\nfor the possible values of \"type\". " "ERRORLEVEL is the return value or 255 on\nerror.\n"); return 255; } /* Ignore _wtoi errors. */ int type = _wtoi(szArgList[3]); int button = MessageBoxW(NULL, szArgList[1], szArgList[2], type); LocalFree(szArgList); return button; }
Support comparing Datums against Atoms.
#ifndef DATUM_H #define DATUM_H #include "hexutil/basics/atom.h" // The variant must be wrapped like this, otherwise the compiler will get confused about which overload to use struct Datum { Datum(): value(0) { } Datum(int x): value(x) { } boost::variant<Atom, int, float, std::string> value; Datum& operator=(const Datum& x) { value = x.value; return *this; } bool operator==(const Datum& x) const { return value == x.value; } Datum& operator=(const int& x) { value = x; return *this; } bool operator==(const int& x) const { return boost::get<int>(value) == x; } template<typename T> operator T() const { return boost::get<T>(value); } template<typename T> bool is() const { return boost::get<T>(&value) != nullptr; } template<typename T> const T& get() const { return boost::get<T>(value); } std::string get_as_str() const; Atom get_as_atom() const; int get_as_int() const; }; std::ostream& operator<<(std::ostream& os, const Datum& atom); #endif
#ifndef DATUM_H #define DATUM_H #include "hexutil/basics/atom.h" // The variant must be wrapped like this, otherwise the compiler will get confused about which overload to use struct Datum { Datum(): value(0) { } Datum(int x): value(x) { } Datum(const std::string& x): value(x) { } boost::variant<Atom, int, float, std::string> value; Datum& operator=(const Datum& x) { value = x.value; return *this; } bool operator==(const Datum& x) const { return value == x.value; } Datum& operator=(const Atom& x) { value = x; return *this; } bool operator==(const Atom& x) const { return boost::get<Atom>(value) == x; } Datum& operator=(const int& x) { value = x; return *this; } bool operator==(const int& x) const { return boost::get<int>(value) == x; } template<typename T> operator T() const { return boost::get<T>(value); } template<typename T> bool is() const { return boost::get<T>(&value) != nullptr; } template<typename T> const T& get() const { return boost::get<T>(value); } std::string get_as_str() const; Atom get_as_atom() const; int get_as_int() const; }; std::ostream& operator<<(std::ostream& os, const Datum& atom); #endif
Create IR adaptor for sparta interprocedural facilities
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include "Analyzer.h" #include "CallGraph.h" #include "DexClass.h" #include "MonotonicFixpointIterator.h" namespace sparta_interprocedural { struct AnalysisAdaptorBase { using Function = const DexMethod*; using Program = const Scope&; using CallGraphInterface = call_graph::GraphInterface; // Uses the serial fixpoint iterator by default. The user can override this // type alias to use the parallel fixpoint. template <typename GraphInterface, typename Domain> using FixpointIteratorBase = sparta::MonotonicFixpointIterator<GraphInterface, Domain>; // The summary argument is unused in the adaptor base. Only certain // analyses will require this argument, in which case this function // should be *overriden* in the derived class. template <typename FunctionSummaries> static call_graph::Graph call_graph_of(const Scope& scope, FunctionSummaries* /*summaries*/) { // TODO: build method override graph and merge them together? // TODO: build once and cache it in the memory because the framework // will call it on every top level iteration. return call_graph::single_callee_graph(scope); } }; } // namespace sparta_interprocedural
Add in check to ensure all elements are included.
#include <stdio.h> #include "main.h" int main() { printf("Test goes here.\n"); }
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include "rtree.h" #include "minunit.h" #include "main.h" int tests_run = 0; static char *test_all_kept() { for (int count = 0; count < 1000; count++) { rtree_t *rt = rtree_create(); for (uintptr_t i = 0; i < count; i++) { rtree_add(rt, (void *) i, (double) drand48()); } char *recvd = calloc(count, sizeof(char)); for (int i = 0; i < count; i++) { int pos = (int) ((uintptr_t) rtree_rpop(rt)); recvd[pos]++; } for (int i = 0; i < count; i++) { char *err_msg = calloc(80, sizeof(char)); sprintf(err_msg, "Expected exactly 1 elt with value %d, but was %d\n", i, recvd[i]); mu_assert(err_msg, recvd[i] == 1); free(err_msg); } free(recvd); rtree_destroy(rt); } return 0; } static char *all_tests() { mu_run_test(test_all_kept); return 0; } int main() { char *result = all_tests(); if (result != 0) { printf("%s\n", result); } else { printf("All tests passed.\n"); } printf("Tests run: %d\n", tests_run); return result != 0; }
Change STOv1 fee per recipient to 0.00001000 OMNI
#ifndef OMNICORE_STO_H #define OMNICORE_STO_H #include <stdint.h> #include <set> #include <string> #include <utility> namespace mastercore { //! Comparator for owner/receiver entries struct SendToOwners_compare { bool operator()(const std::pair<int64_t, std::string>& p1, const std::pair<int64_t, std::string>& p2) const; }; //! Fee required to be paid per owner/receiver, nominated in willets const int64_t TRANSFER_FEE_PER_OWNER = 1; const int64_t TRANSFER_FEE_PER_OWNER_V1 = 100; //! Set of owner/receivers, sorted by amount they own or might receive typedef std::set<std::pair<int64_t, std::string>, SendToOwners_compare> OwnerAddrType; /** Determines the receivers and amounts to distribute. */ OwnerAddrType STO_GetReceivers(const std::string& sender, uint32_t property, int64_t amount); } #endif // OMNICORE_STO_H
#ifndef OMNICORE_STO_H #define OMNICORE_STO_H #include <stdint.h> #include <set> #include <string> #include <utility> namespace mastercore { //! Comparator for owner/receiver entries struct SendToOwners_compare { bool operator()(const std::pair<int64_t, std::string>& p1, const std::pair<int64_t, std::string>& p2) const; }; //! Fee required to be paid per owner/receiver, nominated in willets const int64_t TRANSFER_FEE_PER_OWNER = 1; const int64_t TRANSFER_FEE_PER_OWNER_V1 = 1000; //! Set of owner/receivers, sorted by amount they own or might receive typedef std::set<std::pair<int64_t, std::string>, SendToOwners_compare> OwnerAddrType; /** Determines the receivers and amounts to distribute. */ OwnerAddrType STO_GetReceivers(const std::string& sender, uint32_t property, int64_t amount); } #endif // OMNICORE_STO_H
Use Id instead of Header.
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.version.c - version 1.0.3 */ /* $Header: hack.version.c,v 1.5 85/05/09 00:40:41 aeb Exp $ */ #include "date.h" doversion(){ pline("%s 1.0.3 - last edit %s.", ( #ifdef QUEST "Quest" #else "Hack" #endif QUEST ), datestring); return(0); }
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.version.c - version 1.0.3 */ /* $Id$ */ #include "date.h" doversion(){ pline("%s 1.0.3 - last edit %s.", ( #ifdef QUEST "Quest" #else "Hack" #endif QUEST ), datestring); return(0); }
Adjust this test for recent llvm-gcc changes.
// RUN: %llvmgcc -S %s -o - | grep {getelementptr i32} extern void f(int *); int e(int m, int n) { int x[n]; f(x); return x[m]; }
// RUN: %llvmgcc -S %s -o - | grep {getelementptr \\\[0 x i32\\\]} extern void f(int *); int e(int m, int n) { int x[n]; f(x); return x[m]; }
Include nearby object protocol file
// // NearbyObjectProtocol.h // ARIS // // Created by Brian Deith on 5/15/09. // Copyright 2009 __MyCompanyName__. All rights reserved. // enum { NearbyObjectNPC = 1, NearbyObjectItem = 2, NearbyObjectNode = 3 }; typedef UInt32 nearbyObjectKind; @protocol NearbyObjectProtocol - (NSString *)name; - (nearbyObjectKind)kind; - (BOOL)forcedDisplay; - (void)display; @end
Add functions to buld X86 specific constructs
//===-- X86InstrBuilder.h - Functions to aid building x86 insts -*- C++ -*-===// // // This file exposes functions that may be used with BuildMI from the // MachineInstrBuilder.h file to handle X86'isms in a clean way. // // The BuildMem function may be used with the BuildMI function to add entire // memory references in a single, typed, function call. X86 memory references // can be very complex expressions (described in the README), so wrapping them // up behind an easier to use interface makes sense. Descriptions of the // functions are included below. // //===----------------------------------------------------------------------===// #ifndef X86INSTRBUILDER_H #define X86INSTRBUILDER_H #include "llvm/CodeGen/MachineInstrBuilder.h" /// addDirectMem - This function is used to add a direct memory reference to the /// current instruction. Because memory references are always represented with /// four values, this adds: Reg, [1, NoReg, 0] to the instruction /// inline const MachineInstrBuilder &addDirectMem(const MachineInstrBuilder &MIB, unsigned Reg) { return MIB.addReg(Reg).addZImm(1).addMReg(0).addSImm(0); } #endif
Check for control garbage before http garbage, httpd isn't detecting control garbage because it has http whitelisted
#include <kernel/kernel.h> #include <kotaka/paths/account.h> static int is_control_garbage(string input) { if (strlen(input) >= 1 && input[0] < ' ') { return 1; } return 0; } static int is_http_garbage(string input) { if (strlen(input) >= 4 && input[0 .. 3] == "GET ") { return 1; } return 0; } static string garbage(string input) { if (is_http_garbage(input)) { return "http"; } if (is_control_garbage(input)) { return "control"; } return nil; } static void siteban(string ip, string reason) { string creator; mapping ban; ban = ([ ]); creator = DRIVER->creator(object_name(this_object())); ban["message"] = reason; ban["expire"] = time() + 90 * 86400; ban["issuer"] = creator; BAND->ban_site(ip + "/32", ban); }
#include <kernel/kernel.h> #include <kotaka/paths/account.h> static int is_control_garbage(string input) { if (strlen(input) >= 1 && input[0] < ' ') { return 1; } return 0; } static int is_http_garbage(string input) { if (strlen(input) >= 4 && input[0 .. 3] == "GET ") { return 1; } return 0; } static string garbage(string input) { if (is_control_garbage(input)) { return "control"; } if (is_http_garbage(input)) { return "http"; } return nil; } static void siteban(string ip, string reason) { string creator; mapping ban; ban = ([ ]); creator = DRIVER->creator(object_name(this_object())); ban["message"] = reason; ban["expire"] = time() + 90 * 86400; ban["issuer"] = creator; BAND->ban_site(ip + "/32", ban); }
Add first parameter to get_cpuid definition.
#pragma once #include <stdint.h> #include <cpuid.h> #define cpu_equals(name) __builtin_cpu_is(name) #define cpu_supports(feature) __builtin_cpu_supports(feature) #define get_cpuid(a, b, c, d) __get_cpuid(0, a, b, c, d) typedef struct regs { uint32_t gs, fs, es, ds; uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; uint32_t int_no, err_code; uint32_t eip, cs, eflags, useresp, ss; } regs_t; #define IRQ_CHAIN_SIZE 16 #define IRQ_CHAIN_DEPTH 4 typedef void (*irq_handler_t) (regs_t *); typedef int (*irq_handler_chain_t) (regs_t *);
#pragma once #include <stdint.h> #include <cpuid.h> #define cpu_equals(name) __builtin_cpu_is(name) #define cpu_supports(feature) __builtin_cpu_supports(feature) #define get_cpuid(in, a, b, c, d) __get_cpuid(in, a, b, c, d) typedef struct regs { uint32_t gs, fs, es, ds; uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; uint32_t int_no, err_code; uint32_t eip, cs, eflags, useresp, ss; } regs_t; #define IRQ_CHAIN_SIZE 16 #define IRQ_CHAIN_DEPTH 4 typedef void (*irq_handler_t) (regs_t *); typedef int (*irq_handler_chain_t) (regs_t *);
Update RingRayLib - raylib.c - Add Function : bool WindowShouldClose(void)
/* Copyright (c) 2019 Mahmoud Fayed <msfclipper@yahoo.com> */ #define RING_EXTENSION // Don't call : windows.h (Avoid conflict with raylib.h) #include <ring.h> #include <raylib.h> RING_FUNC(ring_InitWindow) { if ( RING_API_PARACOUNT != 3 ) { RING_API_ERROR(RING_API_MISS3PARA); return ; } if ( ! RING_API_ISNUMBER(1) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } if ( ! RING_API_ISNUMBER(2) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } if ( ! RING_API_ISSTRING(3) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } InitWindow( (int ) RING_API_GETNUMBER(1), (int ) RING_API_GETNUMBER(2),RING_API_GETSTRING(3)); } RING_API void ringlib_init(RingState *pRingState) { ring_vm_funcregister("initwindow",ring_InitWindow); }
/* Copyright (c) 2019 Mahmoud Fayed <msfclipper@yahoo.com> */ #define RING_EXTENSION // Don't call : windows.h (Avoid conflict with raylib.h) #include <ring.h> #include <raylib.h> RING_FUNC(ring_InitWindow) { if ( RING_API_PARACOUNT != 3 ) { RING_API_ERROR(RING_API_MISS3PARA); return ; } if ( ! RING_API_ISNUMBER(1) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } if ( ! RING_API_ISNUMBER(2) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } if ( ! RING_API_ISSTRING(3) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } InitWindow( (int ) RING_API_GETNUMBER(1), (int ) RING_API_GETNUMBER(2),RING_API_GETSTRING(3)); } RING_FUNC(ring_WindowShouldClose) { if ( RING_API_PARACOUNT != 0 ) { RING_API_ERROR(RING_API_BADPARACOUNT); return ; } RING_API_RETNUMBER(WindowShouldClose()); } RING_API void ringlib_init(RingState *pRingState) { ring_vm_funcregister("initwindow",ring_InitWindow); ring_vm_funcregister("windowshouldclose",ring_WindowShouldClose); }
Add tiny rng for volume control
uint32_t _rng_state = millis() void init_rng() { _rng_state = 75380540 - millis() for (int i=0; i<100; i++) tiny_prng() } uint32_t tiny_prng() { uint32_t x = _rng_state; x ^= x << 13; x ^= x >> 17; x ^= x << 5; _rng_state = x; return x; }
Add functions, headers & description
/* MIT License Copyright (c) 2017 ZeroUnix 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. */ // **Note: Please read the 'README.md' first // The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the DLLEXPORTPROJ_EXPORTS // symbol defined on the command line. This symbol should not be defined on any project // that uses this DLL. This way any other project whose source files include this file see // DLLEXPORTPROJ_API functions as being imported from a DLL, whereas this DLL sees symbols // defined with this macro as being exported. #ifdef DLLEXPORTPROJ_EXPORTS #define DLLEXPORTPROJ_API __declspec(dllexport) #else #define DLLEXPORTPROJ_API __declspec(dllimport) #endif //Windows Header #include <windows.h> #include <windowsx.h> #include <AccCtrl.h> #include <AclAPI.h> #include <shellapi.h> #include <stdlib.h> DLLEXPORTPROJ_API BOOL AdministratorPrivilege(VOID); DLLEXPORTPROJ_API VOID ElevateCurrentProcess(VOID); DLLEXPORTPROJ_API BOOL IsStartup(LPWSTR pszAppName, LPWSTR hSubKey); DLLEXPORTPROJ_API BOOL RegisterApp(LPWSTR pszAppName, LPWSTR pathToExe, LPWSTR args, LPWSTR hSubKey); DLLEXPORTPROJ_API VOID EnableStartup(LPWSTR pszAppName, LPWSTR args);
Create Vertex struct to hold vertex info
/* The Halfling Project - A Graphics Engine and Projects * * The Halfling Project is the legal property of Adrian Astley * Copyright Adrian Astley 2013 */ #ifndef CRATE_DEMO_GRAPHICS_MANAGER_H #define CRATE_DEMO_GRAPHICS_MANAGER_H #include "common/graphics_manager_base.h" #include <d3d11.h> namespace CrateDemo { class GameStateManager; class GraphicsManager : public Common::GraphicsManagerBase { public: GraphicsManager(GameStateManager *gameStateManager); private: GameStateManager *m_gameStateManager; ID3D11RenderTargetView *m_renderTargetView; public: bool Initialize(int clientWidth, int clientHeight, HWND hwnd); void Shutdown(); void DrawFrame(); void OnResize(int newClientWidth, int newClientHeight); void GamePaused(); void GameUnpaused(); }; } // End of namespace CrateDemo #endif
/* The Halfling Project - A Graphics Engine and Projects * * The Halfling Project is the legal property of Adrian Astley * Copyright Adrian Astley 2013 */ #ifndef CRATE_DEMO_GRAPHICS_MANAGER_H #define CRATE_DEMO_GRAPHICS_MANAGER_H #include "common/graphics_manager_base.h" #include <d3d11.h> #include "DirectXMath.h" namespace CrateDemo { class GameStateManager; struct Vertex { DirectX::XMFLOAT3 pos; DirectX::XMFLOAT4 color; }; class GraphicsManager : public Common::GraphicsManagerBase { public: GraphicsManager(GameStateManager *gameStateManager); private: GameStateManager *m_gameStateManager; ID3D11RenderTargetView *m_renderTargetView; public: bool Initialize(int clientWidth, int clientHeight, HWND hwnd); void Shutdown(); void DrawFrame(); void OnResize(int newClientWidth, int newClientHeight); void GamePaused(); void GameUnpaused(); }; } // End of namespace CrateDemo #endif
Add a virtual destructor to SimpleWebMimeRegistryImpl so that child class destructors get called correctly.
// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. #ifndef WEBMIMEREGISTRY_IMPL_H_ #define WEBMIMEREGISTRY_IMPL_H_ #include "third_party/WebKit/WebKit/chromium/public/WebMimeRegistry.h" namespace webkit_glue { class SimpleWebMimeRegistryImpl : public WebKit::WebMimeRegistry { public: // WebMimeRegistry methods: virtual WebKit::WebMimeRegistry::SupportsType supportsMIMEType( const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsImageMIMEType( const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsJavaScriptMIMEType( const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( const WebKit::WebString&, const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsNonImageMIMEType( const WebKit::WebString&); virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); virtual WebKit::WebString preferredExtensionForMIMEType( const WebKit::WebString&); }; } // namespace webkit_glue #endif // WEBMIMEREGISTRY_IMPL_H_
// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. #ifndef WEBMIMEREGISTRY_IMPL_H_ #define WEBMIMEREGISTRY_IMPL_H_ #include "third_party/WebKit/WebKit/chromium/public/WebMimeRegistry.h" namespace webkit_glue { class SimpleWebMimeRegistryImpl : public WebKit::WebMimeRegistry { public: SimpleWebMimeRegistryImpl() {} virtual ~SimpleWebMimeRegistryImpl() {} // WebMimeRegistry methods: virtual WebKit::WebMimeRegistry::SupportsType supportsMIMEType( const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsImageMIMEType( const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsJavaScriptMIMEType( const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( const WebKit::WebString&, const WebKit::WebString&); virtual WebKit::WebMimeRegistry::SupportsType supportsNonImageMIMEType( const WebKit::WebString&); virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); virtual WebKit::WebString preferredExtensionForMIMEType( const WebKit::WebString&); }; } // namespace webkit_glue #endif // WEBMIMEREGISTRY_IMPL_H_
Clarify that the terminal sends a value upon subscription
// // 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`. // // 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
Drop definitions of unused object attributes
/* * The OpenDiamond Platform for Interactive Search * Version 4 * * Copyright (c) 2002-2005 Intel Corporation * All rights reserved. * * This software is distributed under the terms of the Eclipse Public * License, Version 1.0 which can be found in the file named LICENSE. * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT */ #ifndef _SYS_ATTR_H_ #define _SYS_ATTR_H_ /* * Names for some of the system defined attributes. * XXX update these from the spec. */ #define SIZE "SYS_SIZE" #define UID "SYS_UID" #define GID "SYS_GID" #define BLK_SIZE "SYS_BLKSIZE" #define ATIME "SYS_ATIME" #define MTIME "SYS_MTIME" #define CTIME "SYS_CTIME" #define OBJ_ID "_ObjectID" #define OBJ_DATA "" #define DISPLAY_NAME "Display-Name" #define DEVICE_NAME "Device-Name" #define OBJ_PATH "_path.cstring" #define FLTRTIME "_FIL_TIME.time" #define FLTRTIME_FN "_FIL_TIME_%s.time" #define PERMEABILITY_FN "_FIL_STAT_%s_permeability.float" #endif /* _SYS_ATTR_H_ */
/* * The OpenDiamond Platform for Interactive Search * Version 4 * * Copyright (c) 2002-2005 Intel Corporation * All rights reserved. * * This software is distributed under the terms of the Eclipse Public * License, Version 1.0 which can be found in the file named LICENSE. * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT */ #ifndef _SYS_ATTR_H_ #define _SYS_ATTR_H_ /* * Names for some of the system defined attributes. */ #define OBJ_ID "_ObjectID" #define OBJ_DATA "" #define DISPLAY_NAME "Display-Name" #define DEVICE_NAME "Device-Name" #define FLTRTIME "_FIL_TIME.time" #define FLTRTIME_FN "_FIL_TIME_%s.time" #endif /* _SYS_ATTR_H_ */
Allow GPIO chips to register IRQ mappings.
/* * include/asm-sh/gpio.h * * Generic GPIO API and pinmux table support for SuperH. * * Copyright (c) 2008 Magnus Damm * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. */ #ifndef __ASM_SH_GPIO_H #define __ASM_SH_GPIO_H #include <linux/kernel.h> #include <linux/errno.h> #if defined(CONFIG_CPU_SH3) #include <cpu/gpio.h> #endif #define ARCH_NR_GPIOS 512 #include <linux/sh_pfc.h> #ifdef CONFIG_GPIOLIB static inline int gpio_get_value(unsigned gpio) { return __gpio_get_value(gpio); } static inline void gpio_set_value(unsigned gpio, int value) { __gpio_set_value(gpio, value); } static inline int gpio_cansleep(unsigned gpio) { return __gpio_cansleep(gpio); } static inline int gpio_to_irq(unsigned gpio) { WARN_ON(1); return -ENOSYS; } static inline int irq_to_gpio(unsigned int irq) { WARN_ON(1); return -EINVAL; } #endif /* CONFIG_GPIOLIB */ #endif /* __ASM_SH_GPIO_H */
/* * include/asm-sh/gpio.h * * Generic GPIO API and pinmux table support for SuperH. * * Copyright (c) 2008 Magnus Damm * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. */ #ifndef __ASM_SH_GPIO_H #define __ASM_SH_GPIO_H #include <linux/kernel.h> #include <linux/errno.h> #if defined(CONFIG_CPU_SH3) #include <cpu/gpio.h> #endif #define ARCH_NR_GPIOS 512 #include <linux/sh_pfc.h> #ifdef CONFIG_GPIOLIB static inline int gpio_get_value(unsigned gpio) { return __gpio_get_value(gpio); } static inline void gpio_set_value(unsigned gpio, int value) { __gpio_set_value(gpio, value); } static inline int gpio_cansleep(unsigned gpio) { return __gpio_cansleep(gpio); } static inline int gpio_to_irq(unsigned gpio) { return __gpio_to_irq(gpio); } static inline int irq_to_gpio(unsigned int irq) { return -ENOSYS; } #endif /* CONFIG_GPIOLIB */ #endif /* __ASM_SH_GPIO_H */
Remove private keyword that is not needed
/*************************************************/ /* DO NOT MODIFY THIS HEADER */ /* */ /* MASTODON */ /* */ /* (c) 2015 Battelle Energy Alliance, LLC */ /* ALL RIGHTS RESERVED */ /* */ /* Prepared by Battelle Energy Alliance, LLC */ /* With the U. S. Department of Energy */ /* */ /* See COPYRIGHT for full restrictions */ /*************************************************/ /** * This action automatically creates the displacement Variables and the * velocity, acceleration, stress and strain AuxVariables based on the dimension of the mesh * of the problem. **/ #ifndef MASTODONADDVARIABLEACTION_H #define MASTODONADDVARIABLEACTION_H #include "Action.h" class MastodonAddVariableAction : public Action { public: MastodonAddVariableAction(const InputParameters & params); virtual void act() override; private: }; template <> InputParameters validParams<MastodonAddVariableAction>(); #endif // MASTODONADDVARIABLEACTION_H
/*************************************************/ /* DO NOT MODIFY THIS HEADER */ /* */ /* MASTODON */ /* */ /* (c) 2015 Battelle Energy Alliance, LLC */ /* ALL RIGHTS RESERVED */ /* */ /* Prepared by Battelle Energy Alliance, LLC */ /* With the U. S. Department of Energy */ /* */ /* See COPYRIGHT for full restrictions */ /*************************************************/ /** * This action automatically creates the displacement Variables and the * velocity, acceleration, stress and strain AuxVariables based on the dimension of the mesh * of the problem. **/ #ifndef MASTODONADDVARIABLEACTION_H #define MASTODONADDVARIABLEACTION_H #include "Action.h" class MastodonAddVariableAction : public Action { public: MastodonAddVariableAction(const InputParameters & params); virtual void act() override; }; template <> InputParameters validParams<MastodonAddVariableAction>(); #endif // MASTODONADDVARIABLEACTION_H
Fix a possible crash if a file fails to be closed
// Copyright 2014 Google Inc. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd #ifndef MEDIA_FILE_FILE_CLOSER_H_ #define MEDIA_FILE_FILE_CLOSER_H_ #include "packager/base/logging.h" #include "packager/media/file/file.h" namespace edash_packager { namespace media { /// Used by scoped_ptr to automatically close the file when it goes out of /// scope. struct FileCloser { inline void operator()(File* file) const { if (file != NULL && !file->Close()) { LOG(WARNING) << "Failed to close the file properly: " << file->file_name(); } } }; } // namespace media } // namespace edash_packager #endif // MEDIA_FILE_FILE_CLOSER_H_
// Copyright 2014 Google Inc. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd #ifndef MEDIA_FILE_FILE_CLOSER_H_ #define MEDIA_FILE_FILE_CLOSER_H_ #include "packager/base/logging.h" #include "packager/media/file/file.h" namespace edash_packager { namespace media { /// Used by scoped_ptr to automatically close the file when it goes out of /// scope. struct FileCloser { inline void operator()(File* file) const { if (file != NULL) { const std::string filename = file->file_name(); if (!file->Close()) { LOG(WARNING) << "Failed to close the file properly: " << filename; } } } }; } // namespace media } // namespace edash_packager #endif // MEDIA_FILE_FILE_CLOSER_H_
Set VK_NO_PROTOTYPES for vulkan backend
/* * 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 GrVkDefines_DEFINED #define GrVkDefines_DEFINED #ifdef SK_VULKAN #if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_WIN32) # if !defined(VK_USE_PLATFORM_WIN32_KHR) # define VK_USE_PLATFORM_WIN32_KHR # endif #elif defined(SK_BUILD_FOR_ANDROID) # if !defined(VK_USE_PLATFORM_ANDROID_KHR) # define VK_USE_PLATFORM_ANDROID_KHR # endif #elif defined(SK_BUILD_FOR_UNIX) # if defined(__Fuchsia__) # if !defined(VK_USE_PLATFORM_MAGMA_KHR) # define VK_USE_PLATFORM_MAGMA_KHR # endif # else # if !defined(VK_USE_PLATFORM_XCB_KHR) # define VK_USE_PLATFORM_XCB_KHR # endif # endif #endif #include <vulkan/vulkan.h> #define SKIA_REQUIRED_VULKAN_HEADER_VERSION 17 #if VK_HEADER_VERSION < SKIA_REQUIRED_VULKAN_HEADER_VERSION #error "Vulkan header version is too low" #endif #endif #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 GrVkDefines_DEFINED #define GrVkDefines_DEFINED #ifdef SK_VULKAN #if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_WIN32) # if !defined(VK_USE_PLATFORM_WIN32_KHR) # define VK_USE_PLATFORM_WIN32_KHR # endif #elif defined(SK_BUILD_FOR_ANDROID) # if !defined(VK_USE_PLATFORM_ANDROID_KHR) # define VK_USE_PLATFORM_ANDROID_KHR # endif #elif defined(SK_BUILD_FOR_UNIX) # if defined(__Fuchsia__) # if !defined(VK_USE_PLATFORM_MAGMA_KHR) # define VK_USE_PLATFORM_MAGMA_KHR # endif # else # if !defined(VK_USE_PLATFORM_XCB_KHR) # define VK_USE_PLATFORM_XCB_KHR # endif # endif #endif // We create our own function table and never directly call any functions via vk*(). So no need to // include the prototype functions. #ifndef VK_NO_PROTOTYPES #define VK_NO_PROTOTYPES #endif #include <vulkan/vulkan.h> #define SKIA_REQUIRED_VULKAN_HEADER_VERSION 17 #if VK_HEADER_VERSION < SKIA_REQUIRED_VULKAN_HEADER_VERSION #error "Vulkan header version is too low" #endif #endif #endif
Add a constant for detecting whether we are in debug mode.
// // Constants.h // hashtag-warrior // // Created by Daniel Wood on 20/04/2013. // Copyright (c) 2013 Ossum Games. All rights reserved. // #ifndef hashtag_warrior_Constants_h #define hashtag_warrior_Constants_h // UI & appearance #define kHWBackgroundColor ccc4(142, 193, 218, 255) #define kHWTextColor ccc3(8, 90, 124); #define kHWTextHeadingFamily @"Marker Felt" #define kHWTextBodyFamily @"Arial" // Gameplay #define kHWMinProjectileSize 2.0f // TODO net yet used #define kHWMaxProjectileSize 10.0f // TODO net yet used #define kHWMinProjectileStartVelocity 2.0f // TODO net yet used #define kHWMaxProjectileStartVelocity 8.0f // TODO net yet used #define kHWMinProjectileStartAngle -5 // TODO net yet used #define kHWMaxProjectileStartAngle 30 // TODO net yet used // Environment #define kHWMaxVelocity 10.0f #define kHWForceMagnifier 5 #endif
// // Constants.h // hashtag-warrior // // Created by Daniel Wood on 20/04/2013. // Copyright (c) 2013 Ossum Games. All rights reserved. // #ifndef hashtag_warrior_Constants_h #define hashtag_warrior_Constants_h // UI & appearance #define kHWBackgroundColor ccc4(142, 193, 218, 255) #define kHWTextColor ccc3(8, 90, 124); #define kHWTextHeadingFamily @"Marker Felt" #define kHWTextBodyFamily @"Arial" // Gameplay #define kHWMinProjectileSize 2.0f // TODO net yet used #define kHWMaxProjectileSize 10.0f // TODO net yet used #define kHWMinProjectileStartVelocity 2.0f // TODO net yet used #define kHWMaxProjectileStartVelocity 8.0f // TODO net yet used #define kHWMinProjectileStartAngle -5 // TODO net yet used #define kHWMaxProjectileStartAngle 30 // TODO net yet used // Environment #define kHWMaxVelocity 10.0f #define kHWForceMagnifier 5 // Misc #define kHWIsDebug 0 #endif
Structure member should be function pointer
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_C_PPB_FIND_H_ #define PPAPI_C_PPB_FIND_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" #define PPB_FIND_INTERFACE "PPB_Find;1" typedef struct _ppb_Find { // Updates the number of find results for the current search term. If // there are no matches 0 should be passed in. Only when the plugin has // finished searching should it pass in the final count with finalResult set // to true. void NumberOfFindResultsChanged(PP_Instance instance, int32_t total, bool final_result); // Updates the index of the currently selected search item. void SelectedFindResultChanged(PP_Instance instance, int32_t index); } PPB_Find; #endif // PPAPI_C_PPB_FIND_H_
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_C_PPB_FIND_H_ #define PPAPI_C_PPB_FIND_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" #define PPB_FIND_INTERFACE "PPB_Find;1" typedef struct _ppb_Find { // Updates the number of find results for the current search term. If // there are no matches 0 should be passed in. Only when the plugin has // finished searching should it pass in the final count with finalResult set // to true. void (*NumberOfFindResultsChanged)(PP_Instance instance, int32_t total, bool final_result); // Updates the index of the currently selected search item. void (*SelectedFindResultChanged)(PP_Instance instance, int32_t index); } PPB_Find; #endif // PPAPI_C_PPB_FIND_H_
Add a dummy subtarget to the CPP backend target machine. This will allow us to forward all of the standard TargetMachine calls to the subtarget and still return null as we were before.
//===-- CPPTargetMachine.h - TargetMachine for the C++ backend --*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file declares the TargetMachine that is used by the C++ backend. // //===----------------------------------------------------------------------===// #ifndef CPPTARGETMACHINE_H #define CPPTARGETMACHINE_H #include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" namespace llvm { class formatted_raw_ostream; struct CPPTargetMachine : public TargetMachine { CPPTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) : TargetMachine(T, TT, CPU, FS, Options) {} bool addPassesToEmitFile(PassManagerBase &PM, formatted_raw_ostream &Out, CodeGenFileType FileType, bool DisableVerify, AnalysisID StartAfter, AnalysisID StopAfter) override; const DataLayout *getDataLayout() const override { return nullptr; } }; extern Target TheCppBackendTarget; } // End llvm namespace #endif
//===-- CPPTargetMachine.h - TargetMachine for the C++ backend --*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file declares the TargetMachine that is used by the C++ backend. // //===----------------------------------------------------------------------===// #ifndef CPPTARGETMACHINE_H #define CPPTARGETMACHINE_H #include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetSubtargetInfo.h" namespace llvm { class formatted_raw_ostream; class CPPSubtarget : public TargetSubtargetInfo { }; struct CPPTargetMachine : public TargetMachine { CPPTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) : TargetMachine(T, TT, CPU, FS, Options), Subtarget() {} private: CPPSubtarget Subtarget; public: const CPPSubtarget *getSubtargetImpl() const override { return &Subtarget; } bool addPassesToEmitFile(PassManagerBase &PM, formatted_raw_ostream &Out, CodeGenFileType FileType, bool DisableVerify, AnalysisID StartAfter, AnalysisID StopAfter) override; }; extern Target TheCppBackendTarget; } // End llvm namespace #endif
Include HTTP responses in server
// framework.h #ifndef HEADER_FRAMEWORK #define HEADER_FRAMEWORK // forward declaration typedef struct wookie_framework wookie_framework; /* Send an HTTP request back to the framework */ void *wookie_framework_request(void*); #include "../http_parser/parser.h" #include "../server.h" #include "framework.c" /* Create new framework */ wookie_framework *wookie_new_framework(char*, int); /* Add a route to the framework */ void wookie_add_route(wookie_framework*, wookie_route*); /* Start the framework */ int wookie_start_framework(wookie_framework*); #endif
// framework.h #ifndef HEADER_FRAMEWORK #define HEADER_FRAMEWORK // forward declaration typedef struct wookie_framework wookie_framework; /* Send an HTTP request back to the framework */ void *wookie_framework_request(void*); #include "../http_parser/parser.h" #include "../http_parser/http_response.h" #include "../server.h" #include "framework.c" /* Create new framework */ wookie_framework *wookie_new_framework(char*, int); /* Add a route to the framework */ void wookie_add_route(wookie_framework*, wookie_route*); /* Start the framework */ int wookie_start_framework(wookie_framework*); #endif
Replace tab w/ 4-space indent
#include <sys/inotify.h> #include <unistd.h> #include <sys/wait.h> #include <limits.h> #define BUF_LEN ( sizeof(struct inotify_event) + NAME_MAX + 1 ) int main(int argc, char *argv[]) { int notify; char buf[BUF_LEN]; struct inotify_event *event; const char *watchpath = "/home/ian/.PRINT"; notify = inotify_init(); if (inotify_add_watch(notify, watchpath, IN_CLOSE_WRITE) == -1) return 1; if (chdir(watchpath) !=0) return 1; while (1) { read(notify, buf, BUF_LEN); event = (struct inotify_event *) &buf[0]; if (event->name[0] == '.') continue; if(fork() == 0) { execlp("lpr" ,"-r" , event->name, NULL); return 0; } wait(NULL); unlink(event->name); } }
#include <sys/inotify.h> #include <unistd.h> #include <sys/wait.h> #include <limits.h> #define BUF_LEN ( sizeof(struct inotify_event) + NAME_MAX + 1 ) int main(int argc, char *argv[]) { int notify; char buf[BUF_LEN]; struct inotify_event *event; const char *watchpath = "/home/ian/.PRINT"; notify = inotify_init(); if (inotify_add_watch(notify, watchpath, IN_CLOSE_WRITE) == -1) return 1; if (chdir(watchpath) !=0) return 1; while (1) { read(notify, buf, BUF_LEN); event = (struct inotify_event *) &buf[0]; if (event->name[0] == '.') continue; if(fork() == 0) { execlp("lpr" ,"-r" , event->name, NULL); return 0; } wait(NULL); unlink(event->name); } }
Move variable declarations to while loop
#include <sys/inotify.h> #include <unistd.h> #include <limits.h> #include <cups/cups.h> #define BUF_LEN ( sizeof(struct inotify_event) + NAME_MAX + 1 ) int main(int argc, char *argv[]) { int notify; char buf[BUF_LEN]; struct inotify_event *event; cups_dest_t *dest; char *printer; char *filename; int job_id; const char *watchpath = "/home/ian/.PRINT"; notify = inotify_init(); if (inotify_add_watch(notify, watchpath, IN_CLOSE_WRITE) == -1) return 1; if (chdir(watchpath) !=0) return 1; //Get default printer if ((dest = cupsGetNamedDest(NULL, NULL, NULL)) == NULL ) return 1; printer = dest->name; while (1) { read(notify, buf, BUF_LEN); event = (struct inotify_event *) &buf[0]; filename = event->name; if (filename[0] == '.') continue; job_id = cupsPrintFile(printer, filename, filename, 0, NULL); cupsStartDocument(CUPS_HTTP_DEFAULT, printer, job_id, NULL, CUPS_FORMAT_AUTO, 1); unlink(filename); } }
#include <sys/inotify.h> #include <unistd.h> #include <limits.h> #include <cups/cups.h> #define BUF_LEN ( sizeof(struct inotify_event) + NAME_MAX + 1 ) int main(int argc, char *argv[]) { int notify; cups_dest_t *dest; char *printer; const char *watchpath = "/home/ian/.PRINT"; notify = inotify_init(); if (inotify_add_watch(notify, watchpath, IN_CLOSE_WRITE) == -1) return 1; if (chdir(watchpath) !=0) return 1; //Get default printer if ((dest = cupsGetNamedDest(NULL, NULL, NULL)) == NULL ) return 1; printer = dest->name; while (1) { char buf[BUF_LEN]; struct inotify_event *event; char *filename; int job_id; read(notify, buf, BUF_LEN); event = (struct inotify_event *) &buf[0]; filename = event->name; if (filename[0] == '.') continue; job_id = cupsPrintFile(printer, filename, filename, 0, NULL); cupsStartDocument(CUPS_HTTP_DEFAULT, printer, job_id, NULL, CUPS_FORMAT_AUTO, 1); unlink(filename); } }
Document possibility of sum overflow in MovingAverage
#pragma once #include <array> namespace filter { template <typename T, size_t N> class MovingAverage { public: MovingAverage(T initial_value=static_cast<T>(0)); T output() const; // return average of data in buffer T output(T input); // add new value to buffer and return average private: std::array<T, N> m_data; // circular buffer containing samples size_t m_data_index; // index of oldest circular buffer element T m_sum; // sum of all elements in buffer }; } // namespace filter #include "filter/movingaverage.hh"
#pragma once #include <array> namespace filter { /* * Warning: This class does not protect against sum overflow. It is possible * that the sum of values exceeds the maximum value T can store. */ template <typename T, size_t N> class MovingAverage { public: MovingAverage(T initial_value=static_cast<T>(0)); T output() const; // return average of data in buffer T output(T input); // add new value to buffer and return average private: std::array<T, N> m_data; // circular buffer containing samples size_t m_data_index; // index of oldest circular buffer element T m_sum; // sum of all elements in buffer }; } // namespace filter #include "filter/movingaverage.hh"
FIX physicsDLL include path FOR DLL to work
#ifndef SSPAPPLICATION_CORE_SYSTEM_H #define SSPAPPLICATION_CORE_SYSTEM_H #include <SDL.h> #include <SDL_syswm.h> #include <iostream> #include "../GraphicsDLL/GraphicsHandler.h" #include "../GraphicsDLL/Camera.h" #include "InputHandler.h" #include "../physicsDLL/physicsDLL/PhysicsHandler.h" #pragma comment (lib, "../Debug/PhysicsDLL") const int SCREEN_WIDTH = 1280; const int SCREEN_HEIGHT = 720; class System { private: bool m_fullscreen; bool m_running; //The glorious window handle for the sdl window HWND m_hwnd; HINSTANCE m_hinstance; LPCWSTR m_applicationName; //This is the window we render to SDL_Window* m_window; Camera* m_camera; //These are the subsystems GraphicsHandler* m_graphicsHandler; InputHandler* m_inputHandler; //this is a physicsHandler PhysicsHandler m_physicsHandler; public: System(); ~System(); int Shutdown(); int Initialize(); //Do not place things here without talking to the system designers. Place any update method in the System::Update(float dt) method int Run(); int Update(float deltaTime); private: int HandleEvents(); int FullscreenToggle(); }; #endif
#ifndef SSPAPPLICATION_CORE_SYSTEM_H #define SSPAPPLICATION_CORE_SYSTEM_H #include <SDL.h> #include <SDL_syswm.h> #include <iostream> #include "../GraphicsDLL/GraphicsHandler.h" #include "../GraphicsDLL/Camera.h" #include "InputHandler.h" #include "../physicsDLL/PhysicsHandler.h" #pragma comment (lib, "../Debug/PhysicsDLL") const int SCREEN_WIDTH = 1280; const int SCREEN_HEIGHT = 720; class System { private: bool m_fullscreen; bool m_running; //The glorious window handle for the sdl window HWND m_hwnd; HINSTANCE m_hinstance; LPCWSTR m_applicationName; //This is the window we render to SDL_Window* m_window; Camera* m_camera; //These are the subsystems GraphicsHandler* m_graphicsHandler; InputHandler* m_inputHandler; //this is a physicsHandler PhysicsHandler m_physicsHandler; public: System(); ~System(); int Shutdown(); int Initialize(); //Do not place things here without talking to the system designers. Place any update method in the System::Update(float dt) method int Run(); int Update(float deltaTime); private: int HandleEvents(); int FullscreenToggle(); }; #endif
Make delegate method optional (cancellation is handled automatically when using UINavigationController)
#import <UIKit/UIKit.h> @protocol NBNPhotoChooserViewControllerDelegate; @interface NBNPhotoChooserViewController : UIViewController - (instancetype)initWithDelegate:(id<NBNPhotoChooserViewControllerDelegate>)delegate; - (instancetype)initWithDelegate:(id<NBNPhotoChooserViewControllerDelegate>)delegate maxCellWidth:(CGFloat)maxCellWidth cellSpacing:(CGFloat)cellSpacing; @property (nonatomic) NSString *navigationBarTitle; @property (nonatomic) NSString *cancelButtonTitle; @property (nonatomic) BOOL shouldAnimateImagePickerTransition; @end @protocol NBNPhotoChooserViewControllerDelegate <NSObject> - (void)photoChooserController:(NBNPhotoChooserViewController *)photoChooser didChooseImage:(UIImage *)image; - (void)photoChooserDidCancel:(NBNPhotoChooserViewController *)photoChooser; @end
#import <UIKit/UIKit.h> @protocol NBNPhotoChooserViewControllerDelegate; @interface NBNPhotoChooserViewController : UIViewController - (instancetype)initWithDelegate:(id<NBNPhotoChooserViewControllerDelegate>)delegate; - (instancetype)initWithDelegate:(id<NBNPhotoChooserViewControllerDelegate>)delegate maxCellWidth:(CGFloat)maxCellWidth cellSpacing:(CGFloat)cellSpacing; @property (nonatomic) NSString *navigationBarTitle; @property (nonatomic) NSString *cancelButtonTitle; @property (nonatomic) BOOL shouldAnimateImagePickerTransition; @end @protocol NBNPhotoChooserViewControllerDelegate <NSObject> - (void)photoChooserController:(NBNPhotoChooserViewController *)photoChooser didChooseImage:(UIImage *)image; @optional - (void)photoChooserDidCancel:(NBNPhotoChooserViewController *)photoChooser; @end
Add the vpsc library for IPSEPCOLA features
/** * * Authors: * Tim Dwyer <tgdwyer@gmail.com> * * Copyright (C) 2005 Authors * * This version is released under the CPL (Common Public License) with * the Graphviz distribution. * A version is also available under the LGPL as part of the Adaptagrams * project: http://sourceforge.net/projects/adaptagrams. * If you make improvements or bug fixes to this code it would be much * appreciated if you could also contribute those changes back to the * Adaptagrams repository. */ #ifndef SEEN_REMOVEOVERLAP_VARIABLE_H #define SEEN_REMOVEOVERLAP_VARIABLE_H #include <vector> #include <iostream> class Block; class Constraint; #include "block.h" typedef std::vector<Constraint*> Constraints; class Variable { friend std::ostream& operator <<(std::ostream &os, const Variable &v); public: const int id; // useful in log files double desiredPosition; const double weight; double offset; Block *block; bool visited; Constraints in; Constraints out; char *toString(); inline Variable(const int id, const double desiredPos, const double weight) : id(id) , desiredPosition(desiredPos) , weight(weight) , offset(0) , visited(false) { } inline double Variable::position() const { return block->posn+offset; } //double position() const; ~Variable(void){ in.clear(); out.clear(); } }; #endif // SEEN_REMOVEOVERLAP_VARIABLE_H
Add appledoc header comments to the 'OCKCarePlanEvent' class
#import <CareKit/CareKit.h> typedef void(^CMHCareSaveCompletion)(NSString *_Nullable uploadStatus, NSError *_Nullable error); @interface OCKCarePlanEvent (CMHealth) @property (nonatomic, nonnull, readonly) NSString *cmh_objectId; - (void)cmh_saveWithCompletion:(_Nullable CMHCareSaveCompletion)block; @end
#import <CareKit/CareKit.h> typedef void(^CMHCareSaveCompletion)(NSString *_Nullable uploadStatus, NSError *_Nullable error); /** * This category adds properties and methods to the `OCKCarePlanEvent` class which * allow instances to be identified uniquely and saved to CloudMine's * HIPAA compliant Connected Health Cloud. */ @interface OCKCarePlanEvent (CMHealth) /** * The unique identifier assigned to this event based on its `OCKCarePlanActivity` * identifier, its schedule, and its days since start. * * @warning the CareKit component of this SDK is experimental and subject to change. Your * feedback is welcomed! */ @property (nonatomic, nonnull, readonly) NSString *cmh_objectId; /** * Save a representation of this `OCKCarePlanEvent` isntance to CloudMine. * The event is given a unique identifier based on its `OCKCarePlanActivity` identifier, * its schedule, and its days since start. Saving an event multiple times will update * the instance of that event on CloudMine. The callback will provide a string value * of `created` or `updated` if the operation was successful. * * @warning the CareKit component of this SDK is experimental and subject to change. Your * feedback is welcomed! * * @param block Executes when the request completes successfully or fails with an error. */ - (void)cmh_saveWithCompletion:(_Nullable CMHCareSaveCompletion)block; @end
Add Win32 specific code for CroquetPlugin.
#include <windows.h> #include "CroquetPlugin.h" static int loaded = 0; static HMODULE hAdvApi32 = NULL; static BOOLEAN (*RtlGenRandom)(PVOID, ULONG) = NULL; int ioGatherEntropy(char *bufPtr, int bufSize) { if(!loaded) { loaded = 1; hAdvApi32 = LoadLibrary("advapi32.dll"); (void*)RtlGenRandom = GetProcAddress(hAdvApi32, "SystemFunction036"); } if(!RtlGenRandom) return 0; return RtlGenRandom(bufPtr, bufSize); }
Fix debug logging-only compilation error
/* * linux/fs/ext3/bitmap.c * * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) */ #ifdef EXT3FS_DEBUG #include <linux/buffer_head.h> #include "ext3_fs.h" static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars) { unsigned int i; unsigned long sum = 0; if (!map) return (0); for (i = 0; i < numchars; i++) sum += nibblemap[map->b_data[i] & 0xf] + nibblemap[(map->b_data[i] >> 4) & 0xf]; return (sum); } #endif /* EXT3FS_DEBUG */
/* * linux/fs/ext3/bitmap.c * * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) */ #include <linux/buffer_head.h> #include <linux/jbd.h> #include <linux/ext3_fs.h> #ifdef EXT3FS_DEBUG static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars) { unsigned int i; unsigned long sum = 0; if (!map) return (0); for (i = 0; i < numchars; i++) sum += nibblemap[map->b_data[i] & 0xf] + nibblemap[(map->b_data[i] >> 4) & 0xf]; return (sum); } #endif /* EXT3FS_DEBUG */
Fix Linux shared build by adding missing UI_EXPORT annotations.
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_GFX_FAVICON_SIZE_H_ #define UI_GFX_FAVICON_SIZE_H_ #pragma once namespace gfx { // Size (along each axis) of the favicon. extern const int kFaviconSize; // If the width or height is bigger than the favicon size, a new width/height // is calculated and returned in width/height that maintains the aspect // ratio of the supplied values. void CalculateFaviconTargetSize(int* width, int* height); } // namespace gfx #endif // UI_GFX_FAVICON_SIZE_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_GFX_FAVICON_SIZE_H_ #define UI_GFX_FAVICON_SIZE_H_ #pragma once #include "ui/base/ui_export.h" namespace gfx { // Size (along each axis) of the favicon. UI_EXPORT extern const int kFaviconSize; // If the width or height is bigger than the favicon size, a new width/height // is calculated and returned in width/height that maintains the aspect // ratio of the supplied values. UI_EXPORT void CalculateFaviconTargetSize(int* width, int* height); } // namespace gfx #endif // UI_GFX_FAVICON_SIZE_H_
Use CLOCK_MONOTONIC instead of CLOCK_MONOTONIC_RAW.
#ifndef TIMER_H #define TIMER_H struct timespec t0, t1; /* Start/end time for timer */ /* Timer macros */ #define TIMER_START() clock_gettime(CLOCK_MONOTONIC_RAW, &t0) #define TIMER_STOP() clock_gettime(CLOCK_MONOTONIC_RAW, &t1) #define TIMER_ELAPSED_NS() \ (t1.tv_sec * 1000000000 + t1.tv_nsec) - \ (t0.tv_sec * 1000000000 + t0.tv_nsec) #define TIMER_ELAPSED_US() \ (t1.tv_sec * 1000000 + (double)t1.tv_nsec / 1000) - \ (t0.tv_sec * 1000000 + (double)t0.tv_nsec / 1000) #endif /* TIMER_H */
#ifndef TIMER_H #define TIMER_H struct timespec t0, t1; /* Start/end time for timer */ /* Timer macros */ #define TIMER_START() clock_gettime(CLOCK_MONOTONIC, &t0) #define TIMER_STOP() clock_gettime(CLOCK_MONOTONIC, &t1) #define TIMER_ELAPSED_NS() \ (t1.tv_sec * 1000000000 + t1.tv_nsec) - \ (t0.tv_sec * 1000000000 + t0.tv_nsec) #define TIMER_ELAPSED_US() \ (t1.tv_sec * 1000000 + (double)t1.tv_nsec / 1000) - \ (t0.tv_sec * 1000000 + (double)t0.tv_nsec / 1000) #endif /* TIMER_H */
Add pure virtual isComplete() function.
#ifndef ANIMATION_H #define ANIMATION_H #include <vector> #include "Blittable.h" #include "Logger.h" namespace hm { class Animation { public: Animation(); ~Animation(); void add(Blittable& b); void remove(Blittable& b); void removeAll(); int getUnits(); void setUnits(const int units); unsigned int getFrames(); void setFrames(const unsigned int frames); void setAnimationSpeed(const int units, const unsigned int frames = 1); virtual void animate() = 0; protected: int units; unsigned int frames; std::vector<Blittable*> targets; }; } #endif
#ifndef ANIMATION_H #define ANIMATION_H #include <vector> #include "Blittable.h" #include "Logger.h" namespace hm { class Animation { public: Animation(); ~Animation(); void add(Blittable& b); void remove(Blittable& b); void removeAll(); int getUnits(); void setUnits(const int units); unsigned int getFrames(); void setFrames(const unsigned int frames); void setAnimationSpeed(const int units, const unsigned int frames = 1); virtual void animate() = 0; virtual bool isComplete() = 0; protected: int units; unsigned int frames; std::vector<Blittable*> targets; }; } #endif
Add header file with prototypes that bomalloc needs from the surrounding enviroment
#ifndef __BOMALLOC_SYSTEM #define __BOMALLOC_SYSTEM #include <stdbool.h> #include <stdlib.h> #include <unistd.h> bool speculating(void); void record_allocation(void * p, size_t t); int getuniqueid(void); #endif
Add some inline functions for configuring gpio.
#include "stm8s003_reg.h" typedef enum { PORT_A = PA_ODR, PORT_B = PB_ODR, PORT_C = PB_, PORT_D, PORT_E, PORT_F } port_t; void toggle_port_a_pin(uint8_t pin); void set_high_port_a_pin(uint8_t pin); void set_low_port_a_pin(uint8_t pin); void set
#include "stm8s003_reg.h" #include <stdint.h> struct input_pin_config { bool pull_up_enable; bool interrupt_enable; }; struct output_pin_config { bool open_drain_enable; bool fast_mode_enable; }; inline void set_port_a(uint8_t value) { PA_ODR = value; } inline void toggle_port_a_pin(uint8_t pin) { set_port_a((*(uart16_t *) PA_ODR) ^ ~(1 << pin)); } inline void set_high_port_a_pin(uint8_t pin) { set_port_a((*(uint16_t *) PA_ODR) | (1 << pin)); } inline void set_low_port_a_pin(uint8_t pin) { set_port_a((*(uart16_t *) PA_ODR) & ~(1 << pin)); } inline void read_port_a(uint8_t * value) { &value = (uint16_t *) PA_IDR; } inline bool read_port_a_pin(uint8_t pin) { uint8_t value; read_port_a_pin(value); return value >> pin; } inline void configure_port_a_input_pin(struct input_pin_config * config); inline void configure_port_a_output_pin(struct output_pin_config * config);
Fix compilation error on FreeBSD
/* * $FreeBSD$ * * Smoke test for `ls` utility */ #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include "functional_test.h" int main(int argc, char *argv[]) { while ((opt = getopt_long(argc, argv, short_options, long_options, &option_index)) != -1) { switch(opt) { case 0: /* valid long option */ /* generate the valid command for execution */ snprintf(command, sizeof(command), "/bin/ls --%s > /dev/null", long_options[option_index].name); ret = system(command); if (ret == -1) { fprintf(stderr, "Failed to create child process\n"); exit(EXIT_FAILURE); } if (!WIFEXITED(ret)) { fprintf(stderr, "Child process failed to terminate normally\n"); exit(EXIT_FAILURE); } if (WEXITSTATUS(ret)) fprintf(stderr, "\nValid option '--%s' failed to execute\n", long_options[option_index].name); else printf("Successful: '--%s'\n", long_options[option_index].name); break; case '?': /* invalid long option */ break; default: printf("getopt_long returned character code %o\n", opt); } } exit(EXIT_SUCCESS); }
/* * $FreeBSD$ * * Smoke test for `ls` utility */ #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> #include "functional_test.h" int main(int argc, char *argv[]) { while ((opt = getopt_long(argc, argv, short_options, long_options, &option_index)) != -1) { switch(opt) { case 0: /* valid long option */ /* generate the valid command for execution */ snprintf(command, sizeof(command), "/bin/ls --%s > /dev/null", long_options[option_index].name); ret = system(command); if (ret == -1) { fprintf(stderr, "Failed to create child process\n"); exit(EXIT_FAILURE); } if (!WIFEXITED(ret)) { fprintf(stderr, "Child process failed to terminate normally\n"); exit(EXIT_FAILURE); } if (WEXITSTATUS(ret)) fprintf(stderr, "\nValid option '--%s' failed to execute\n", long_options[option_index].name); else printf("Successful: '--%s'\n", long_options[option_index].name); break; case '?': /* invalid long option */ break; default: printf("getopt_long returned character code %o\n", opt); } } exit(EXIT_SUCCESS); }
Update implementation to hook calls to dlopen.
#include <dlfcn.h> int main(int argc, char* argv[]) { dlopen("1//libcoreclr.so", RTLD_NOW | RTLD_GLOBAL); dlopen("2//libcoreclrtraceptprovider.so", RTLD_LAZY); dlopen("2//libcoreclr.so", RTLD_NOW | RTLD_GLOBAL); return 0; }
//#define _GNU_SOURCE #include <dlfcn.h> #include <stdio.h> #include <string.h> void *dlopen(const char *filename, int flag) { static void* (*dlopenImpl)(const char *filename, int flag) = 0; if(!dlopenImpl) { dlopenImpl = dlsym(RTLD_NEXT, "dlopen"); } if(strcmp(filename, "2//libcoreclrtraceptprovider.so") == 0) { printf("Skip loading 2//libcoreclrtraceptprovider.so.\n"); return 0; } printf("Calling dlopen(%s).\n", filename); return dlopenImpl(filename, flag); } int main(int argc, char* argv[]) { dlopen("1//libcoreclr.so", RTLD_NOW | RTLD_GLOBAL); dlopen("2//libcoreclr.so", RTLD_NOW | RTLD_GLOBAL); return 0; }
Remove deprecated instance() method from Singleton
/// \file /// \brief Singleton design pattern /// /// \author Peter 'png' Hille <peter@das-system-networks.de> #ifndef SINGLETON_HH #define SINGLETON_HH 1 #include <dsnutil/compiler_features.h> namespace dsn { /// \brief Template for singleton classes /// /// This template can be used to implement the "singleton" design pattern /// on any class. template <class Derived> class Singleton { public: /// \brief Access singleton instance /// /// \return Reference to the instance of this singleton. static dsnutil_cpp_DEPRECATED Derived& getInstance() { return instanceRef(); } /// \brief Access singleton instance (by reference) /// /// \return Reference to the initialized singleton instance static Derived& instanceRef() { static Derived instance; return instance; } /// \brief Access singleton instance (by pointer) /// /// \return Pointer to the initialized singleton instance static Derived* instancePtr() { return &instanceRef(); } protected: /// \brief Default constructor /// /// \note This ctor is protected so that derived classes can implement /// their own logics for object initialization while still maintaining /// the impossibility of direct ctor calls! Singleton() {} private: /// \brief Copy constructor /// /// \note This ctor is private to prevent multiple instances of the same /// singleton from being created through object assignments! Singleton(const Singleton&) {} }; } #endif // !SINGLETON_HH
/// \file /// \brief Singleton design pattern /// /// \author Peter 'png' Hille <peter@das-system-networks.de> #ifndef SINGLETON_HH #define SINGLETON_HH 1 namespace dsn { /// \brief Template for singleton classes /// /// This template can be used to implement the "singleton" design pattern /// on any class. template <class Derived> class Singleton { public: /// \brief Access singleton instance (by reference) /// /// \return Reference to the initialized singleton instance static Derived& instanceRef() { static Derived instance; return instance; } /// \brief Access singleton instance (by pointer) /// /// \return Pointer to the initialized singleton instance static Derived* instancePtr() { return &instanceRef(); } protected: /// \brief Default constructor /// /// \note This ctor is protected so that derived classes can implement /// their own logics for object initialization while still maintaining /// the impossibility of direct ctor calls! Singleton() {} private: /// \brief Copy constructor /// /// \note This ctor is private to prevent multiple instances of the same /// singleton from being created through object assignments! Singleton(const Singleton&) {} }; } #endif // !SINGLETON_HH
Fix typo in macro for tls access model
/* * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #ifndef _BITS_UCLIBC_ERRNO_H #define _BITS_UCLIBC_ERRNO_H 1 #ifdef IS_IN_rtld # undef errno # define errno _dl_errno extern int _dl_errno; // attribute_hidden; #elif defined __UCLIBC_HAS_THREADS__ # include <tls.h> # if defined USE___THREAD && USE___THREAD # undef errno # ifndef NOT_IN_libc # define errno __libc_errno # else # define errno errno # endif extern __thread int errno __attribute_tls_model_ie; # endif /* USE___THREAD */ #endif /* IS_IN_rtld */ #define __set_errno(val) (errno = (val)) #ifndef __ASSEMBLER__ extern int *__errno_location (void) __THROW __attribute__ ((__const__)) # ifdef IS_IN_rtld attribute_hidden # endif ; # if defined __UCLIBC_HAS_THREADS__ # include <tls.h> # if defined USE___THREAD && USE___THREAD libc_hidden_proto(__errno_location) # endif # endif #endif /* !__ASSEMBLER__ */ #endif
/* * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #ifndef _BITS_UCLIBC_ERRNO_H #define _BITS_UCLIBC_ERRNO_H 1 #ifdef IS_IN_rtld # undef errno # define errno _dl_errno extern int _dl_errno; // attribute_hidden; #elif defined __UCLIBC_HAS_THREADS__ # include <tls.h> # if defined USE___THREAD && USE___THREAD # undef errno # ifndef NOT_IN_libc # define errno __libc_errno # else # define errno errno # endif extern __thread int errno attribute_tls_model_ie; # endif /* USE___THREAD */ #endif /* IS_IN_rtld */ #define __set_errno(val) (errno = (val)) #ifndef __ASSEMBLER__ extern int *__errno_location (void) __THROW __attribute__ ((__const__)) # ifdef IS_IN_rtld attribute_hidden # endif ; # if defined __UCLIBC_HAS_THREADS__ # include <tls.h> # if defined USE___THREAD && USE___THREAD libc_hidden_proto(__errno_location) # endif # endif #endif /* !__ASSEMBLER__ */ #endif
Fix warning about "comparison between signed and unsigned" in example and make it fully C89 compatible.
#include "C_func_file.h" void multiply_by_10_in_C(double arr[], unsigned int n) { for (int i = 0; i < n; i++) { arr[i] *= 10; } }
#include "C_func_file.h" void multiply_by_10_in_C(double arr[], unsigned int n) { unsigned int i; for (i = 0; i < n; i++) { arr[i] *= 10; } }
Add regression test for TD3 wpoint restart soundness
// PARAM: --enable ana.int.interval #include <pthread.h> #include <assert.h> int g = 0; void *worker(void *arg ) { return NULL; } int main(int argc , char **argv ) { pthread_t tid; pthread_create(& tid, NULL, & worker, NULL); while (g >= 10) { } assert(1); // reachable g++; assert(1); // reachable return 0; }
Update missing iOS header changes
// // FirestackDatabase.h // Firestack // // Created by Ari Lerner on 8/23/16. // Copyright © 2016 Facebook. All rights reserved. // #ifndef FirestackDatabase_h #define FirestackDatabase_h #import "Firebase.h" #import "RCTEventEmitter.h" #import "RCTBridgeModule.h" @interface FirestackDatabase : RCTEventEmitter <RCTBridgeModule> { } @property (nonatomic) NSDictionary *_DBHandles; @property (nonatomic, weak) FIRDatabaseReference *ref; @end #endif
// // FirestackDatabase.h // Firestack // // Created by Ari Lerner on 8/23/16. // Copyright © 2016 Facebook. All rights reserved. // #ifndef FirestackDatabase_h #define FirestackDatabase_h #import "Firebase.h" #import "RCTEventEmitter.h" #import "RCTBridgeModule.h" @interface FirestackDatabase : RCTEventEmitter <RCTBridgeModule> { } @property NSMutableDictionary *dbReferences; @property FIRDatabase *database; @end #endif
Kill off more names to fix this test
// RUN: %clang_cc1 -mrtd -triple i386-unknown-freebsd9.0 -emit-llvm -o - %s | FileCheck %s void baz(int arg); // CHECK: define x86_stdcallcc void @foo(i32 %arg) nounwind void foo(int arg) { // CHECK: call x86_stdcallcc i32 (...)* @bar(i32 %tmp) bar(arg); // CHECK: call x86_stdcallcc void @baz(i32 %tmp1) baz(arg); } // CHECK: declare x86_stdcallcc i32 @bar(...) // CHECK: declare x86_stdcallcc void @baz(i32)
// RUN: %clang_cc1 -mrtd -triple i386-unknown-freebsd9.0 -emit-llvm -o - %s | FileCheck %s void baz(int arg); // CHECK: define x86_stdcallcc void @foo(i32 %arg) nounwind void foo(int arg) { // CHECK: call x86_stdcallcc i32 (...)* @bar(i32 bar(arg); // CHECK: call x86_stdcallcc void @baz(i32 baz(arg); } // CHECK: declare x86_stdcallcc i32 @bar(...) // CHECK: declare x86_stdcallcc void @baz(i32)
Add bs_config for hide bs_cfg_p::Instance () usage
#ifndef BS_CONFIG_PARSER_H #define BS_CONFIG_PARSER_H #include "bs_common.h" #include <map> #include <string> #include <vector> namespace blue_sky { struct wcfg; class BS_API bs_cfg_p { public: friend struct wcfg; typedef std::vector<std::string> vstr_t; typedef std::map<std::string,vstr_t> map_t; void parse_strings (const std::string &str, bool append = false); void read_file (const char *filename); void clear_env_map (); const map_t &env() const; vstr_t getenv(const char *e); private: bs_cfg_p (); map_t env_mp; }; typedef singleton< bs_cfg_p > cfg; } #endif // BS_CONFIG_PARSER_H
#ifndef BS_CONFIG_PARSER_H #define BS_CONFIG_PARSER_H #include "bs_common.h" #include <map> #include <string> #include <vector> namespace blue_sky { struct wcfg; class BS_API bs_cfg_p { public: friend struct wcfg; typedef std::vector<std::string> vstr_t; typedef std::map<std::string,vstr_t> map_t; void parse_strings (const std::string &str, bool append = false); void read_file (const char *filename); void clear_env_map (); const map_t &env() const; vstr_t getenv(const char *e); vstr_t operator[] (const char *e) { return getenv (e); } private: bs_cfg_p (); map_t env_mp; }; typedef singleton< bs_cfg_p > cfg; struct bs_config { bs_cfg_p::vstr_t operator [] (const char *e) { return cfg::Instance ()[e]; } }; } #endif // BS_CONFIG_PARSER_H
Fix stupid error for Linux build.
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_GPU_GPU_CONFIG_H_ #define CHROME_GPU_GPU_CONFIG_H_ // This file declares common preprocessor configuration for the GPU process. #include "build/build_config.h" #if defined(OS_LINUX) && !defined(ARCH_CPU_X86) // Only define GLX support for Intel CPUs for now until we can get the // proper dependencies and build setup for ARM. #define GPU_USE_GLX #endif #endif // CHROME_GPU_GPU_CONFIG_H_
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_GPU_GPU_CONFIG_H_ #define CHROME_GPU_GPU_CONFIG_H_ // This file declares common preprocessor configuration for the GPU process. #include "build/build_config.h" #if defined(OS_LINUX) && defined(ARCH_CPU_X86) // Only define GLX support for Intel CPUs for now until we can get the // proper dependencies and build setup for ARM. #define GPU_USE_GLX #endif #endif // CHROME_GPU_GPU_CONFIG_H_
Use the address of the variable instead of the value itself for the CPUID
/* * Copyright (C) 2014 FU Berlin * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @addtogroup driver_periph * @{ * * @file * @brief Low-level CPUID driver implementation * * @author Thomas Eichinger <thomas.eichinger@fu-berlin.de> */ #include <string.h> #include "periph/cpuid.h" extern volatile uint32_t _cpuid_address; void cpuid_get(void *id) { memcpy(id, (void *)(_cpuid_address), CPUID_ID_LEN); } /** @} */
/* * Copyright (C) 2014 FU Berlin * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @addtogroup driver_periph * @{ * * @file * @brief Low-level CPUID driver implementation * * @author Thomas Eichinger <thomas.eichinger@fu-berlin.de> */ #include <string.h> #include "periph/cpuid.h" extern volatile uint32_t _cpuid_address; void cpuid_get(void *id) { memcpy(id, (void *)(&_cpuid_address), CPUID_ID_LEN); } /** @} */
Add __FILE__, __LINE__ to Lua
/* * proxy.c * lexer proxy for Lua parser -- implements __FILE__ and __LINE__ * Luiz Henrique de Figueiredo * This code is hereby placed in the public domain. * Add <<#include "proxy.c">> just before the definition of luaX_next in llex.c */ #include <string.h> static int nexttoken(LexState *ls, SemInfo *seminfo) { int t=llex(ls,seminfo); if (t==TK_NAME) { if (strcmp(getstr(seminfo->ts),"__FILE__")==0) { t=TK_STRING; seminfo->ts = ls->source; } else if (strcmp(getstr(seminfo->ts),"__LINE__")==0) { t=TK_NUMBER; seminfo->r = ls->linenumber; } } return t; } #define llex nexttoken
/* * proxy.c * lexer proxy for Lua parser -- implements __FILE__ and __LINE__ * Luiz Henrique de Figueiredo * This code is hereby placed in the public domain. * Add <<#include "proxy.c">> just before the definition of luaX_next in llex.c */ /* * Luiz's code changed, per his suggestion, to include some polishing * the name for __FILE__, taken from luaU_undump. * -- Jeffrey Kegler */ #include <string.h> static int nexttoken(LexState *ls, SemInfo *seminfo) { int t = llex (ls, seminfo); if (t == TK_NAME) { if (strcmp (getstr (seminfo->ts), "__FILE__") == 0) { const char *name = ls->source; t = TK_STRING; if (*name == '@' || *name == '=') name = name + 1; else if (*name == LUA_SIGNATURE[0]) name = "binary string"; seminfo->ts = name; } else if (strcmp (getstr (seminfo->ts), "__LINE__") == 0) { t = TK_NUMBER; seminfo->r = ls->linenumber; } } return t; } #define llex nexttoken
Add an incoming request object
#ifndef APIMOCK_INCOMING_REQUEST #define APIMOCK_INCOMING_REQUEST #include <string> namespace ApiMock { class IncomingRequest { public: virtual ~IncomingRequest() {} virtual std::string getRequestAsString() = 0; virtual void sendResponse(const std::string& responseAsString) = 0; }; } #endif
Add rudimentary test for fq_default_poly.
/* Copyright (C) 2021 William Hart This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */ #include "fq_default_poly.h" #include <stdlib.h> #include <stdio.h> #include <gmp.h> #include "flint.h" #include "nmod_poly.h" #include "ulong_extras.h" int main(void) { int i; FLINT_TEST_INIT(state); flint_printf("init/clear...."); fflush(stdout); for (i = 0; i < 100 * flint_test_multiplier(); i++) { fq_default_ctx_t ctx; fq_default_poly_t fq_poly; fmpz_t p; fmpz_init(p); fmpz_set_ui(p, 5); fq_default_ctx_init(ctx, p, 5, "x"); fq_default_poly_init(fq_poly, ctx); fq_default_poly_clear(fq_poly, ctx); fq_default_ctx_clear(ctx); fq_default_ctx_init(ctx, p, 16, "x"); fq_default_poly_init(fq_poly, ctx); fq_default_poly_clear(fq_poly, ctx); fq_default_ctx_clear(ctx); fmpz_set_str(p, "73786976294838206473", 10); fq_default_ctx_init(ctx, p, 1, "x"); fq_default_poly_init(fq_poly, ctx); fq_default_poly_clear(fq_poly, ctx); fq_default_ctx_clear(ctx); fmpz_clear(p); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
Revert D34351084: Migrate from googletest 1.8 to googletest 1.10
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <gmock/gmock.h> #include <react/renderer/scheduler/SurfaceHandler.h> namespace facebook { namespace react { class MockSurfaceHandler : public SurfaceHandler { public: MockSurfaceHandler() : SurfaceHandler("moduleName", 0){}; MOCK_METHOD(void, setDisplayMode, (DisplayMode), (const, noexcept)); MOCK_METHOD(SurfaceId, getSurfaceId, (), (const, noexcept)); }; } // namespace react } // namespace facebook
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <gmock/gmock.h> #include <react/renderer/scheduler/SurfaceHandler.h> namespace facebook { namespace react { class MockSurfaceHandler : public SurfaceHandler { public: MockSurfaceHandler() : SurfaceHandler("moduleName", 0){}; MOCK_QUALIFIED_METHOD1(setDisplayMode, const noexcept, void(DisplayMode)); MOCK_QUALIFIED_METHOD0(getSurfaceId, const noexcept, SurfaceId()); }; } // namespace react } // namespace facebook
Add board support for preliminary testing with Arduino Mega again
// Keyglove controller source code - Special hardware setup file // 7/17/2011 by Jeff Rowberg <jeff@rowberg.net> /* ============================================ Controller code is placed under the MIT license Copyright (c) 2011 Jeff Rowberg 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 _SETUP_BOARD_ATMEGA1280_H_ #define _SETUP_BOARD_ATMEGA1280_H_ void setup_board() { } #endif // _SETUP_BOARD_ATMEGA1280_H_
Fix __libc_sigaction redefinition with static links
/* * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com) * * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. */ #include <../../../../../../../libc/sysdeps/linux/arc/sigaction.c>
/* * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com) * * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. */ /* * ARC syscall ABI only has __NR_rt_sigaction, thus vanilla sigaction does * some SA_RESTORER tricks before calling __syscall_rt_sigaction. * However including that file here causes a redefinition of __libc_sigaction * in static links involving pthreads */ //#include <../../../../../../../libc/sysdeps/linux/arc/sigaction.c>