Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Fix "No new line at end of file" warning.
// AnalyticsUtils.h // Copyright (c) 2014 Segment.io. All rights reserved. #import <Foundation/Foundation.h> #define SEGStringize_helper(x) #x #define SEGStringize(x) @SEGStringize_helper(x) NSURL *SEGAnalyticsURLForFilename(NSString *filename); // Async Utils dispatch_queue_t seg_dispatch_queue_create_specific(const char *label, dispatch_queue_attr_t attr); BOOL seg_dispatch_is_on_specific_queue(dispatch_queue_t queue); void seg_dispatch_specific(dispatch_queue_t queue, dispatch_block_t block, BOOL waitForCompletion); void seg_dispatch_specific_async(dispatch_queue_t queue, dispatch_block_t block); void seg_dispatch_specific_sync(dispatch_queue_t queue, dispatch_block_t block); // Logging void SEGSetShowDebugLogs(BOOL showDebugLogs); void SEGLog(NSString *format, ...); // JSON Utils NSDictionary *SEGCoerceDictionary(NSDictionary *dict); NSString *SEGIDFA(); NSString *SEGEventNameForScreenTitle(NSString *title);
// AnalyticsUtils.h // Copyright (c) 2014 Segment.io. All rights reserved. #import <Foundation/Foundation.h> #define SEGStringize_helper(x) #x #define SEGStringize(x) @SEGStringize_helper(x) NSURL *SEGAnalyticsURLForFilename(NSString *filename); // Async Utils dispatch_queue_t seg_dispatch_queue_create_specific(const char *label, dispatch_queue_attr_t attr); BOOL seg_dispatch_is_on_specific_queue(dispatch_queue_t queue); void seg_dispatch_specific(dispatch_queue_t queue, dispatch_block_t block, BOOL waitForCompletion); void seg_dispatch_specific_async(dispatch_queue_t queue, dispatch_block_t block); void seg_dispatch_specific_sync(dispatch_queue_t queue, dispatch_block_t block); // Logging void SEGSetShowDebugLogs(BOOL showDebugLogs); void SEGLog(NSString *format, ...); // JSON Utils NSDictionary *SEGCoerceDictionary(NSDictionary *dict); NSString *SEGIDFA(); NSString *SEGEventNameForScreenTitle(NSString *title);
Add space, commit to main
// // MapAnnotationList.h // GrizSpace // // Created by Kevin Scott on 3/15/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import "MapAnnotation.h" @interface MapAnnotationList : NSObject { //int currentAnnotationIndex; //the currently selected annotation index } //@property (nonatomic, readwrite) bool currentAnnotationIndexSet; //used to determin if the current annotation index is set. @property (nonatomic, readwrite) NSMutableArray* myAnnotationItems; //gets the list of annotation items -(MapAnnotation*) GetNextAnnotation; //gets the next annotation item -(MapAnnotation*) GetCurrentAnnotation; //gets the current annotation item @end
// // MapAnnotationList.h // GrizSpace // // Created by Kevin Scott on 3/15/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import "MapAnnotation.h" @interface MapAnnotationList : NSObject { //int currentAnnotationIndex; //the currently selected annotation index } //@property (nonatomic, readwrite) bool currentAnnotationIndexSet; //used to determin if the current annotation index is set. @property (nonatomic, readwrite) NSMutableArray* myAnnotationItems; //gets the list of annotation items -(MapAnnotation*) GetNextAnnotation; //gets the next annotation item -(MapAnnotation*) GetCurrentAnnotation; //gets the current annotation item @end
Test for animation which hasn't been implemented yet.
//main void cog_init(); void cog_mainloop(); void cog_destroy();
//main void cog_init(); void cog_mainloop(); void cog_destroy(); //anim typedef struct cog_sprite { }cog_sprite; cog_sprite* cog_add_anim(char* animimg, int milliseconds, ...); void cog_play_anim(cog_sprite* sprite);
Allow building executable without any project code.
#include <stdio.h> #include <stdint.h> #if PROJECT == 1 # include "project_1.h" #else # error Unsupported project number in PROJECT macro. Valid values: 1 #endif int main(int argc, char **argv) { printf("Hello, world!\n"); # if PROJECT == 1 project_1_report(); # endif return 0; }
#include <stdio.h> #include <stdint.h> #if PROJECT == 0 # // NOTE(bja, 2017-02): Building main with no project code. #elif PROJECT == 1 # include "project_1.h" #else # error "Unsupported project number in PROJECT macro. Valid values: 0, 1" #endif int main(int argc, char **argv) { printf("Hello, world!\n"); # if PROJECT == 1 project_1_report(); # endif return 0; }
Make mocked functions take std::string to allow == compare
#ifndef __EVIL_TEST_SYSCALLS_MOCK_H #define __EVIL_TEST_SYSCALLS_MOCK_H #include <gmock/gmock.h> #include <string> #include <stack> #include "os/syscalls.h" namespace evil { class SyscallsMock { private: static thread_local std::stack<SyscallsMock *> _instance_stack; public: SyscallsMock() { _instance_stack.push(this); } ~SyscallsMock() { _instance_stack.pop(); } static SyscallsMock *instance() { return _instance_stack.top(); } MOCK_METHOD2(_access, int(const char *path, int mode)); MOCK_METHOD1(_close, int(int fd)); MOCK_METHOD1(_isatty, int(int fd)); MOCK_METHOD2(_kill, int(long pid, int sig)); MOCK_METHOD3(_open, int(const char *path, int flags, int mode)); MOCK_METHOD0(_getpid, long(void)); MOCK_METHOD3(_write, ssize_t(int fd, const void *buf, size_t count)); MOCK_METHOD1(_sbrk, void *(ptrdiff_t increment)); MOCK_METHOD1(_exit, void(int exit_code)); }; } // namespace evil #endif // __EVIL_TEST_SYSCALLS_MOCK_H
#ifndef __EVIL_TEST_SYSCALLS_MOCK_H #define __EVIL_TEST_SYSCALLS_MOCK_H #include <gmock/gmock.h> #include <string> #include <stack> #include "os/syscalls.h" namespace evil { class SyscallsMock { private: static thread_local std::stack<SyscallsMock *> _instance_stack; public: SyscallsMock() { _instance_stack.push(this); } ~SyscallsMock() { _instance_stack.pop(); } static SyscallsMock *instance() { return _instance_stack.top(); } MOCK_METHOD2(_access, int(const std::string &path, int mode)); MOCK_METHOD1(_close, int(int fd)); MOCK_METHOD1(_isatty, int(int fd)); MOCK_METHOD2(_kill, int(long pid, int sig)); MOCK_METHOD3(_open, int(const std::string &path, int flags, int mode)); MOCK_METHOD0(_getpid, long(void)); MOCK_METHOD3(_write, ssize_t(int fd, const void *buf, size_t count)); MOCK_METHOD1(_sbrk, void *(ptrdiff_t increment)); MOCK_METHOD1(_exit, void(int exit_code)); }; } // namespace evil #endif // __EVIL_TEST_SYSCALLS_MOCK_H
Move BankingMode enum from base class to MBC1
#pragma once #include <vector> #include "types.h" class MemoryBankController { public: MemoryBankController() = delete; MemoryBankController(const std::vector<u8> &rom, std::vector<u8> &ram) : rom(rom), ram(ram) {} virtual ~MemoryBankController() {} virtual u8 get8(uint address) const = 0; virtual void set8(uint address, u8 value) = 0; enum class BankingMode { ROM, RAM }; protected: const std::vector<u8> &rom; std::vector<u8> &ram; uint active_rom_bank = 1; uint active_ram_bank = 0; bool ram_enabled = false; BankingMode banking_mode = BankingMode::ROM; }; class MBC1 final : public MemoryBankController { public: using MemoryBankController::MemoryBankController; u8 get8(uint address) const override; void set8(uint address, u8 value) override; };
#pragma once #include <vector> #include "types.h" class MemoryBankController { public: MemoryBankController() = delete; MemoryBankController(const std::vector<u8> &rom, std::vector<u8> &ram) : rom(rom), ram(ram) {} virtual ~MemoryBankController() {} virtual u8 get8(uint address) const = 0; virtual void set8(uint address, u8 value) = 0; protected: const std::vector<u8> &rom; std::vector<u8> &ram; uint active_rom_bank = 1; uint active_ram_bank = 0; bool ram_enabled = false; }; class MBC1 final : public MemoryBankController { enum class BankingMode { ROM, RAM }; BankingMode banking_mode = BankingMode::ROM; public: using MemoryBankController::MemoryBankController; u8 get8(uint address) const override; void set8(uint address, u8 value) override; };
Add third_party/ prefix to ppapi include for checkdeps.
// 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 WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_ #define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_ #include "ppapi/c/pp_var.h" #define PPB_PRIVATE_INTERFACE "PPB_Private;1" typedef enum _ppb_ResourceString { PPB_RESOURCE_STRING_PDF_GET_PASSWORD = 0, } PP_ResourceString; typedef struct _ppb_Private { // Returns a localized string. PP_Var (*GetLocalizedString)(PP_ResourceString string_id); } PPB_Private; #endif // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_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 WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_ #define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_ #include "third_party/ppapi/c/pp_var.h" #define PPB_PRIVATE_INTERFACE "PPB_Private;1" typedef enum _ppb_ResourceString { PPB_RESOURCE_STRING_PDF_GET_PASSWORD = 0, } PP_ResourceString; typedef struct _ppb_Private { // Returns a localized string. PP_Var (*GetLocalizedString)(PP_ResourceString string_id); } PPB_Private; #endif // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_
Use provided byteorder convertions on GLIBC systems
#ifndef JAGUAR_HELPER_H_ #define JAGUAR_HELPER_H_ #include <boost/detail/endian.hpp> #include <stdint.h> #include "jaguar_api.h" #ifdef BOOST_LITTLE_ENDIAN #define htole16(x) x #define htole32(x) x #define le16toh(x) x #define le32toh(x) x #elif BOOST_BIG_ENDIAN #error big endian architectures are unsupported #else #error unknown endiannes #endif namespace jaguar { int16_t double_to_s8p8(double x); uint16_t double_to_u8p8(double x); int32_t double_to_s16p16(double x); double s8p8_to_double(int16_t x); double s16p16_to_double(int32_t x); uint32_t pack_id(uint8_t num, Manufacturer::Enum man, DeviceType::Enum type, APIClass::Enum api_class, uint8_t api_index); }; #endif
#ifndef JAGUAR_HELPER_H_ #define JAGUAR_HELPER_H_ #include <boost/detail/endian.hpp> #include <stdint.h> #include "jaguar_api.h" #ifndef __GLIBC__ # ifdef BOOST_LITTLE_ENDIAN # define htole16(x) x # define htole32(x) x # define le16toh(x) x # define le32toh(x) x # elif BOOST_BIG_ENDIAN # error big endian architectures are unsupported # else # error unknown endiannes # endif #endif namespace jaguar { int16_t double_to_s8p8(double x); uint16_t double_to_u8p8(double x); int32_t double_to_s16p16(double x); double s8p8_to_double(int16_t x); double s16p16_to_double(int32_t x); uint32_t pack_id(uint8_t num, Manufacturer::Enum man, DeviceType::Enum type, APIClass::Enum api_class, uint8_t api_index); }; #endif
Add TrackedValue to test/support. Thanks to Louis Dionne
#ifndef SUPPORT_TRACKED_VALUE_H #define SUPPORT_TRACKED_VALUE_H #include <cassert> struct TrackedValue { enum State { CONSTRUCTED, MOVED_FROM, DESTROYED }; State state; TrackedValue() : state(State::CONSTRUCTED) {} TrackedValue(TrackedValue const& t) : state(State::CONSTRUCTED) { assert(t.state != State::MOVED_FROM && "copying a moved-from object"); assert(t.state != State::DESTROYED && "copying a destroyed object"); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES TrackedValue(TrackedValue&& t) : state(State::CONSTRUCTED) { assert(t.state != State::MOVED_FROM && "double moving from an object"); assert(t.state != State::DESTROYED && "moving from a destroyed object"); t.state = State::MOVED_FROM; } #endif TrackedValue& operator=(TrackedValue const& t) { assert(state != State::DESTROYED && "copy assigning into destroyed object"); assert(t.state != State::MOVED_FROM && "copying a moved-from object"); assert(t.state != State::DESTROYED && "copying a destroyed object"); state = t.state; return *this; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES TrackedValue& operator=(TrackedValue&& t) { assert(state != State::DESTROYED && "move assigning into destroyed object"); assert(t.state != State::MOVED_FROM && "double moving from an object"); assert(t.state != State::DESTROYED && "moving from a destroyed object"); state = t.state; t.state = State::MOVED_FROM; return *this; } #endif ~TrackedValue() { assert(state != State::DESTROYED && "double-destroying an object"); state = State::DESTROYED; } }; #endif // SUPPORT_TRACKED_VALUE_H
Fix nasty sign propagation bug on gcc and 32 bit architectures.
#include "ruby.h" #include "narray.h" VALUE na_address(VALUE self) { struct NARRAY *ary; void * ptr; VALUE ret; GetNArray(self,ary); ptr = ary->ptr; ret = ULL2NUM( (unsigned long long int) ptr); return ret; } void Init_narray_ffi_c() { ID id; VALUE klass; id = rb_intern("NArray"); klass = rb_const_get(rb_cObject, id); rb_define_private_method(klass, "address", na_address, 0); }
#include "ruby.h" #include "narray.h" VALUE na_address(VALUE self) { struct NARRAY *ary; void * ptr; VALUE ret; GetNArray(self,ary); ptr = ary->ptr; ret = ULL2NUM( sizeof(ptr) == 4 ? (unsigned long long int) (unsigned long int) ptr : (unsigned long long int) ptr ); return ret; } void Init_narray_ffi_c() { ID id; VALUE klass; id = rb_intern("NArray"); klass = rb_const_get(rb_cObject, id); rb_define_private_method(klass, "address", na_address, 0); }
Add compile option for sqlite db upgrades.
/* Uncomment to compile with tcpd/libwrap support. */ //#define WITH_WRAP /* Compile with database upgrading support? If disabled, mosquitto won't * automatically upgrade old database versions. */ //#define WITH_DB_UPGRADE /* Compile with memory tracking support? If disabled, mosquitto won't track * heap memory usage nor export '$SYS/broker/heap/current size', but will use * slightly less memory and CPU time. */ #define WITH_MEMORY_TRACKING
/* Uncomment to compile with tcpd/libwrap support. */ //#define WITH_WRAP /* Compile with database upgrading support? If disabled, mosquitto won't * automatically upgrade old database versions. */ //#define WITH_DB_UPGRADE /* Compile with memory tracking support? If disabled, mosquitto won't track * heap memory usage nor export '$SYS/broker/heap/current size', but will use * slightly less memory and CPU time. */ #define WITH_MEMORY_TRACKING /* Compile with the ability to upgrade from old style sqlite persistent * databases to the new mosquitto format. This means a dependency on sqlite. It * isn't needed for new installations. */ #define WITH_SQLITE_UPGRADE
Fix per Noris Datum's E-Mail.
#ifndef CONFIG_EXPORTER_H #define CONFIG_EXPORTER_H class ConfigClass; class ConfigObject; class ConfigValue; class ConfigExporter { protected: ConfigExporter(void) { } ~ConfigExporter() { } public: virtual void field(const ConfigValue *, const std::string&) = 0; virtual void object(const ConfigClass *, const ConfigObject *) = 0; virtual void value(const ConfigValue *, const std::string&) = 0; }; #endif /* !CONFIG_EXPORTER_H */
#ifndef CONFIG_EXPORTER_H #define CONFIG_EXPORTER_H class ConfigClass; class ConfigObject; class ConfigValue; class ConfigExporter { protected: ConfigExporter(void) { } virtual ~ConfigExporter() { } public: virtual void field(const ConfigValue *, const std::string&) = 0; virtual void object(const ConfigClass *, const ConfigObject *) = 0; virtual void value(const ConfigValue *, const std::string&) = 0; }; #endif /* !CONFIG_EXPORTER_H */
Support notifications for SD cards.
#define SOCK_PATH "/var/run/devd.pipe" #define REGEX "subsystem=CDEV type=(CREATE|DESTROY) cdev=(da[0-9]+[a-z]+[0-9]?[a-z]?)"
#define SOCK_PATH "/var/run/devd.pipe" #define REGEX "subsystem=CDEV type=(CREATE|DESTROY) cdev=((da|mmcsd)[0-9]+[a-z]+[0-9]?[a-z]?)"
Add this header back, its existance is an SVR4-ELF tradition. Our ELF hints bits are still a seperate file.
/*- * Copyright (c) 1997 John D. Polstra. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _ELF_H_ #define _ELF_H_ #include <sys/types.h> #include <machine/elf.h> #endif /* !_ELF_H_ */
Check size of unsigned long
/* * Copyright 2014, General Dynamics C4 Systems * * This software may be distributed and modified according to the terms of * the GNU General Public License version 2. Note that NO WARRANTY is provided. * See "LICENSE_GPLv2.txt" for details. * * @TAG(GD_GPL) */ #ifndef __ARCH_TYPES_H #define __ARCH_TYPES_H #include <assert.h> #include <stdint.h> compile_assert(long_is_32bits, sizeof(unsigned long) == 4) typedef unsigned long word_t; typedef word_t vptr_t; typedef word_t paddr_t; typedef word_t pptr_t; typedef word_t cptr_t; typedef word_t dev_id_t; typedef word_t cpu_id_t; typedef word_t node_id_t; typedef word_t dom_t; /* for libsel4 headers that the kernel shares */ typedef word_t seL4_Word; typedef cptr_t seL4_CPtr; typedef uint32_t seL4_Uint32; typedef uint8_t seL4_Uint8; typedef node_id_t seL4_NodeId; typedef paddr_t seL4_PAddr; typedef dom_t seL4_Domain; #endif
/* * Copyright 2014, General Dynamics C4 Systems * * This software may be distributed and modified according to the terms of * the GNU General Public License version 2. Note that NO WARRANTY is provided. * See "LICENSE_GPLv2.txt" for details. * * @TAG(GD_GPL) */ #ifndef __ARCH_TYPES_H #define __ARCH_TYPES_H #include <config.h> #include <assert.h> #include <stdint.h> #if defined(CONFIG_ARCH_IA32) compile_assert(long_is_32bits, sizeof(unsigned long) == 4) #elif defined(CONFIG_ARCH_X86_64) compile_assert(long_is_64bits, sizeof(unsigned long) == 8) #endif typedef unsigned long word_t; typedef word_t vptr_t; typedef word_t paddr_t; typedef word_t pptr_t; typedef word_t cptr_t; typedef word_t dev_id_t; typedef word_t cpu_id_t; typedef word_t node_id_t; typedef word_t dom_t; /* for libsel4 headers that the kernel shares */ typedef word_t seL4_Word; typedef cptr_t seL4_CPtr; typedef uint32_t seL4_Uint32; typedef uint8_t seL4_Uint8; typedef node_id_t seL4_NodeId; typedef paddr_t seL4_PAddr; typedef dom_t seL4_Domain; #endif
Add compact mode for phone landscape orientation
// // constants.h // AESTextEncryption // // Created by Evgenii Neumerzhitckii on 21/02/2015. // Copyright (c) 2015 Evgenii Neumerzhitckii. All rights reserved. // #define aesCompactHeight 400 #define aesPasswordTopMargin 11 #define aesPasswordTopMargin_compact 4 #define aesMessageTopMargin 10 #define aesMessageTopMargin_compact 0 #define aesPasswordHeightMargin 40 #define aesPasswordHeightMargin_compact 30
// // Created by Evgenii Neumerzhitckii on 21/02/2015. // Copyright (c) 2015 Evgenii Neumerzhitckii. All rights reserved. // #define aesCompactHeight 400 #define aesPasswordTopMargin 11 #define aesPasswordTopMargin_compact 4 #define aesMessageTopMargin 10 #define aesMessageTopMargin_compact 0 #define aesPasswordHeightMargin 40 #define aesPasswordHeightMargin_compact 30
Add lorito_pmc_init to the proper header.
#include "lorito.h" #ifndef LORITO_INTERP_H_GUARD #define LORITO_INTERP_H_GUARD Lorito_Ctx * lorito_ctx_init(Lorito_Ctx *next_ctx, Lorito_Codeseg *codeseg); Lorito_Interp * lorito_init(); int lorito_run(Lorito_Interp *interp); #endif /* LORITO_INTERP_H_GUARD */
#include "lorito.h" #ifndef LORITO_INTERP_H_GUARD #define LORITO_INTERP_H_GUARD Lorito_Ctx * lorito_ctx_init(Lorito_Ctx *next_ctx, Lorito_Codeseg *codeseg); Lorito_PMC * lorito_pmc_init(Lorito_Interp *interp, int size); Lorito_Interp * lorito_init(); int lorito_run(Lorito_Interp *interp); #endif /* LORITO_INTERP_H_GUARD */
Make sure callbacks are called for user events
#include "pocl_cl.h" #include "pocl_timing.h" CL_API_ENTRY cl_int CL_API_CALL POname(clSetUserEventStatus)(cl_event event , cl_int execution_status ) CL_API_SUFFIX__VERSION_1_1 { /* Must be a valid user event */ POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT); POCL_RETURN_ERROR_COND((event->command_type != CL_COMMAND_USER), CL_INVALID_EVENT); /* Can only be set to CL_COMPLETE (0) or negative values */ POCL_RETURN_ERROR_COND((execution_status > CL_COMPLETE), CL_INVALID_VALUE); /* Can only be done once */ POCL_RETURN_ERROR_COND((event->status <= CL_COMPLETE), CL_INVALID_OPERATION); POCL_LOCK_OBJ (event); event->status = execution_status; if (execution_status == CL_COMPLETE) { pocl_broadcast (event); } POCL_UNLOCK_OBJ (event); return CL_SUCCESS; } POsym(clSetUserEventStatus)
#include "pocl_cl.h" #include "pocl_timing.h" CL_API_ENTRY cl_int CL_API_CALL POname(clSetUserEventStatus)(cl_event event , cl_int execution_status ) CL_API_SUFFIX__VERSION_1_1 { /* Must be a valid user event */ POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT); POCL_RETURN_ERROR_COND((event->command_type != CL_COMMAND_USER), CL_INVALID_EVENT); /* Can only be set to CL_COMPLETE (0) or negative values */ POCL_RETURN_ERROR_COND((execution_status > CL_COMPLETE), CL_INVALID_VALUE); /* Can only be done once */ POCL_RETURN_ERROR_COND((event->status <= CL_COMPLETE), CL_INVALID_OPERATION); POCL_LOCK_OBJ (event); event->status = execution_status; if (execution_status == CL_COMPLETE) { pocl_broadcast (event); pocl_event_updated (event, CL_COMPLETE); } POCL_UNLOCK_OBJ (event); return CL_SUCCESS; } POsym(clSetUserEventStatus)
Fix a warning in the new DWARFheader. Add a new line at the end of the file.
//===-- DWARFRelocMap.h -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_DEBUGINFO_DWARFRELOCMAP_H #define LLVM_DEBUGINFO_DWARFRELOCMAP_H #include "llvm/ADT/DenseMap.h" namespace llvm { typedef DenseMap<uint64_t, std::pair<uint8_t, int64_t> > RelocAddrMap; } // namespace llvm #endif // LLVM_DEBUGINFO_DWARFRELOCMAP_H
//===-- DWARFRelocMap.h -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_DEBUGINFO_DWARFRELOCMAP_H #define LLVM_DEBUGINFO_DWARFRELOCMAP_H #include "llvm/ADT/DenseMap.h" namespace llvm { typedef DenseMap<uint64_t, std::pair<uint8_t, int64_t> > RelocAddrMap; } // namespace llvm #endif // LLVM_DEBUGINFO_DWARFRELOCMAP_H
Handle the name collision (with WinSock.h) for NO_ADDRESS
// Machine types typedef unsigned char Byte; /* 8 bits */ typedef unsigned short SWord; /* 16 bits */ typedef unsigned int DWord; /* 32 bits */ typedef unsigned int dword; /* 32 bits */ typedef unsigned int Word; /* 32 bits */ typedef unsigned int ADDRESS; /* 32-bit unsigned */ #define STD_SIZE 32 // Standard size #define NO_ADDRESS ((ADDRESS)-1) // For invalid ADDRESSes #ifndef _MSC_VER typedef long unsigned long QWord; // 64 bits #else typedef unsigned __int64 QWord; #endif #if defined(_MSC_VER) #pragma warning(disable:4390) #endif #if defined(_MSC_VER) && _MSC_VER <= 1200 // For MSVC 5 or 6: warning about debug into truncated to 255 chars #pragma warning(disable:4786) #endif
/* * types.h: some often used basic type definitions * $Revision$ */ #ifndef __TYPES_H__ #define __TYPES_H__ // Machine types typedef unsigned char Byte; /* 8 bits */ typedef unsigned short SWord; /* 16 bits */ typedef unsigned int DWord; /* 32 bits */ typedef unsigned int dword; /* 32 bits */ typedef unsigned int Word; /* 32 bits */ typedef unsigned int ADDRESS; /* 32-bit unsigned */ #define STD_SIZE 32 // Standard size // Note: there is a known name collision with NO_ADDRESS in WinSock.h #ifdef NO_ADDRESS #undef NO_ADDRESS #endif #define NO_ADDRESS ((ADDRESS)-1) // For invalid ADDRESSes #ifndef _MSC_VER typedef long unsigned long QWord; // 64 bits #else typedef unsigned __int64 QWord; #endif #if defined(_MSC_VER) #pragma warning(disable:4390) #endif #if defined(_MSC_VER) && _MSC_VER <= 1200 // For MSVC 5 or 6: warning about debug into truncated to 255 chars #pragma warning(disable:4786) #endif #endif // #ifndef __TYPES_H__
Add override keyword to overridden method
#pragma once #include "bpftrace.h" #include "log.h" #include "pass_manager.h" #include "visitors.h" namespace bpftrace { namespace ast { class NodeCounter : public Visitor { public: void Visit(Node &node) { count_++; Visitor::Visit(node); } size_t get_count() { return count_; }; private: size_t count_ = 0; }; Pass CreateCounterPass() { auto fn = [](Node &n, PassContext &ctx) { NodeCounter c; c.Visit(n); auto node_count = c.get_count(); auto max = ctx.b.ast_max_nodes_; if (bt_verbose) { LOG(INFO) << "node count: " << node_count; } if (node_count >= max) { LOG(ERROR) << "node count (" << node_count << ") exceeds the limit (" << max << ")"; return PassResult::Error("node count exceeded"); } return PassResult::Success(); }; return Pass("NodeCounter", fn); } } // namespace ast } // namespace bpftrace
#pragma once #include "bpftrace.h" #include "log.h" #include "pass_manager.h" #include "visitors.h" namespace bpftrace { namespace ast { class NodeCounter : public Visitor { public: void Visit(Node &node) override { count_++; Visitor::Visit(node); } size_t get_count() { return count_; }; private: size_t count_ = 0; }; Pass CreateCounterPass() { auto fn = [](Node &n, PassContext &ctx) { NodeCounter c; c.Visit(n); auto node_count = c.get_count(); auto max = ctx.b.ast_max_nodes_; if (bt_verbose) { LOG(INFO) << "node count: " << node_count; } if (node_count >= max) { LOG(ERROR) << "node count (" << node_count << ") exceeds the limit (" << max << ")"; return PassResult::Error("node count exceeded"); } return PassResult::Success(); }; return Pass("NodeCounter", fn); } } // namespace ast } // namespace bpftrace
Add warning test for -mgpopt option.
// REQUIRES: mips-registered-target // RUN: %clang -### -c -target mips-mti-elf %s -mgpopt 2>&1 | FileCheck -check-prefix=IMPLICIT %s // IMPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with the implicit usage of-mabicalls // RUN: %clang -### -c -target mips-mti-elf %s -mgpopt -mabicalls 2>&1 | FileCheck -check-prefix=EXPLICIT %s // EXPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with -mabicalls
Convert also 0x80..0x9f characters to '?'
/* Copyright (c) 2004 Timo Sirainen */ #include "lib.h" #include "str.h" #include "str-sanitize.h" void str_sanitize_append(string_t *dest, const char *src, size_t max_len) { const char *p; for (p = src; *p != '\0'; p++) { if ((unsigned char)*p < 32) break; } str_append_n(dest, src, (size_t)(p - src)); for (; *p != '\0' && max_len > 0; p++, max_len--) { if ((unsigned char)*p < 32) str_append_c(dest, '?'); else str_append_c(dest, *p); } if (*p != '\0') { str_truncate(dest, str_len(dest)-3); str_append(dest, "..."); } } const char *str_sanitize(const char *src, size_t max_len) { string_t *str; str = t_str_new(I_MIN(max_len, 256)); str_sanitize_append(str, src, max_len); return str_c(str); }
/* Copyright (c) 2004 Timo Sirainen */ #include "lib.h" #include "str.h" #include "str-sanitize.h" void str_sanitize_append(string_t *dest, const char *src, size_t max_len) { const char *p; for (p = src; *p != '\0'; p++) { if (((unsigned char)*p & 0x7f) < 32) break; } str_append_n(dest, src, (size_t)(p - src)); for (; *p != '\0' && max_len > 0; p++, max_len--) { if (((unsigned char)*p & 0x7f) < 32) str_append_c(dest, '?'); else str_append_c(dest, *p); } if (*p != '\0') { str_truncate(dest, str_len(dest)-3); str_append(dest, "..."); } } const char *str_sanitize(const char *src, size_t max_len) { string_t *str; str = t_str_new(I_MIN(max_len, 256)); str_sanitize_append(str, src, max_len); return str_c(str); }
Hide internal function declaration on ES2 builds.
#ifndef Magnum_Implementation_maxTextureSize_h #define Magnum_Implementation_maxTextureSize_h /* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013, 2014, 2015 Vladimír Vondruš <mosra@centrum.cz> 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. */ #include "Magnum/OpenGL.h" namespace Magnum { namespace Implementation { GLint maxTextureSideSize(); GLint max3DTextureDepth(); GLint maxTextureArrayLayers(); GLint maxCubeMapTextureSideSize(); }} #endif
#ifndef Magnum_Implementation_maxTextureSize_h #define Magnum_Implementation_maxTextureSize_h /* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013, 2014, 2015 Vladimír Vondruš <mosra@centrum.cz> 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. */ #include "Magnum/OpenGL.h" namespace Magnum { namespace Implementation { GLint maxTextureSideSize(); GLint max3DTextureDepth(); #ifndef MAGNUM_TARGET_GLES2 GLint maxTextureArrayLayers(); #endif GLint maxCubeMapTextureSideSize(); }} #endif
Subtract one old school sector
#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <getopt.h> #include <sys/uio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> #include "utils.h" #include "logSpeed.h" int keepRunning = 1; int main(int argc, char *argv[]) { // int index = handle_args(argc, argv); int index = 1; // signal(SIGTERM, intHandler); // signal(SIGINT, intHandler); for (size_t i = index; i < argc; i++) { int fd = open(argv[i], O_WRONLY | O_EXCL | O_DIRECT); if (fd >= 0) { size_t bdsize = blockDeviceSizeFromFD(fd); trimDevice(fd, argv[i], 0, bdsize); // only sending 1GiB for now close(fd); } else { perror("open"); } } return 0; }
#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <getopt.h> #include <sys/uio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> #include "utils.h" #include "logSpeed.h" int keepRunning = 1; int main(int argc, char *argv[]) { // int index = handle_args(argc, argv); int index = 1; // signal(SIGTERM, intHandler); // signal(SIGINT, intHandler); for (size_t i = index; i < argc; i++) { int fd = open(argv[i], O_RDWR | O_EXCL | O_DIRECT ); if (fd >= 0) { size_t bdsize = blockDeviceSizeFromFD(fd); trimDevice(fd, argv[i], 0, bdsize - 512); close(fd); } else { perror("open"); } } return 0; }
Add fakes for common test cases
#ifndef GLOBAL_FAKES_H_ #define GLOBAL_FAKES_H_ #include "../fff3.h" void global_void_func(void); DECLARE_FAKE_VOID_FUNC0(global_void_func); #endif /* GLOBAL_FAKES_H_ */
#ifndef GLOBAL_FAKES_H_ #define GLOBAL_FAKES_H_ #include "../fff3.h" //// Imaginary production code header file /// void voidfunc1(int); void voidfunc2(char, char); long longfunc0(); enum MYBOOL { FALSE = 899, TRUE }; struct MyStruct { int x; int y; }; enum MYBOOL enumfunc(); struct MyStruct structfunc(); //// End Imaginary production code header file /// DECLARE_FAKE_VOID_FUNC1(voidfunc1, int); DECLARE_FAKE_VOID_FUNC2(voidfunc2, char, char); DECLARE_FAKE_VALUE_FUNC0(long, longfunc0); DECLARE_FAKE_VALUE_FUNC0(enum MYBOOL, enumfunc0); DECLARE_FAKE_VALUE_FUNC0(struct MyStruct, structfunc0); #endif /* GLOBAL_FAKES_H_ */
Fix this up per llvm-gcc r109819.
// RUN: not %llvmgcc -std=gnu99 %s -S |& grep "error: alignment for" int foo(int a) { int var[a] __attribute__((__aligned__(32))); return 4; }
// RUN: %llvmgcc_only -std=gnu99 %s -S |& grep "warning: alignment for" int foo(int a) { int var[a] __attribute__((__aligned__(32))); return 4; }
Update C header to match capi.rs function names.
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. #ifndef _MP4PARSE_RUST_H #define _MP4PARSE_RUST_H #ifdef __cplusplus extern "C" { #endif struct mp4parse_state; struct mp4parse_state* mp4parse_state_new(void); void mp4parse_state_free(struct mp4parse_state* state); int32_t mp4parse_state_feed(struct mp4parse_state* state, uint8_t *buffer, size_t size); #ifdef __cplusplus } #endif #endif
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. #ifndef _MP4PARSE_RUST_H #define _MP4PARSE_RUST_H #ifdef __cplusplus extern "C" { #endif struct mp4parse_state; struct mp4parse_state* mp4parse_new(void); void mp4parse_free(struct mp4parse_state* state); int32_t mp4parse_read(struct mp4parse_state* state, uint8_t *buffer, size_t size); #ifdef __cplusplus } #endif #endif
Set default values for Cell members.
#ifndef RWTE_COORDS_H #define RWTE_COORDS_H struct Cell { int row, col; inline bool operator==(const Cell& other) const { return row == other.row && col == other.col; } inline bool operator!=(const Cell& other) const { return row != other.row || col != other.col; } inline bool operator< (const Cell& other) const { return row < other.row || col < other.col; } inline bool operator> (const Cell& other) const { return row > other.row || col > other.col; } inline bool operator<=(const Cell& other) const { return row < other.row || col < other.col || (row == other.row && col == other.col); } inline bool operator>=(const Cell& other) const { return row > other.row || col > other.col || (row == other.row && col == other.col); } }; #endif // RWTE_COORDS_H
#ifndef RWTE_COORDS_H #define RWTE_COORDS_H struct Cell { int row = 0; int col = 0; inline bool operator==(const Cell& other) const { return row == other.row && col == other.col; } inline bool operator!=(const Cell& other) const { return row != other.row || col != other.col; } inline bool operator< (const Cell& other) const { return row < other.row || col < other.col; } inline bool operator> (const Cell& other) const { return row > other.row || col > other.col; } inline bool operator<=(const Cell& other) const { return row < other.row || col < other.col || (row == other.row && col == other.col); } inline bool operator>=(const Cell& other) const { return row > other.row || col > other.col || (row == other.row && col == other.col); } }; #endif // RWTE_COORDS_H
Change update_period to 15 seconds
const char *field_sep = " \u2022 "; const char *time_fmt = "%x %I:%M %p"; const int update_period = 90; char * loadavg(void) { double avgs[3]; if (getloadavg(avgs, 3) < 0) { perror("getloadavg"); exit(1); } return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]); } char * prettytime(void) { return mktimes(time_fmt, NULL); } static char *(*forder[])(void) = { loadavg, prettytime, NULL };
const char *field_sep = " \u2022 "; const char *time_fmt = "%x %I:%M %p"; const int update_period = 15; char * loadavg(void) { double avgs[3]; if (getloadavg(avgs, 3) < 0) { perror("getloadavg"); exit(1); } return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]); } char * prettytime(void) { return mktimes(time_fmt, NULL); } static char *(*forder[])(void) = { loadavg, prettytime, NULL };
Update adapter version number to 6.4.3.0
// // Copyright © 2019 Google. All rights reserved. // static NSString *const kGADMAdapterVungleVersion = @"6.4.2.1"; static NSString *const kGADMAdapterVungleApplicationID = @"application_id"; static NSString *const kGADMAdapterVunglePlacementID = @"placementID"; static NSString *const kGADMAdapterVungleErrorDomain = @"com.google.mediation.vungle";
// // Copyright © 2019 Google. All rights reserved. // static NSString *const kGADMAdapterVungleVersion = @"6.4.3.0"; static NSString *const kGADMAdapterVungleApplicationID = @"application_id"; static NSString *const kGADMAdapterVunglePlacementID = @"placementID"; static NSString *const kGADMAdapterVungleErrorDomain = @"com.google.mediation.vungle";
Add helper functions to safely release Windows COM resources, and arrays of COM resources.
// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // angleutils.h: Common ANGLE utilities. #ifndef COMMON_ANGLEUTILS_H_ #define COMMON_ANGLEUTILS_H_ // A macro to disallow the copy constructor and operator= functions // This must be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) template <typename T, unsigned int N> inline unsigned int ArraySize(T(&)[N]) { return N; } #if defined(_MSC_VER) #define snprintf _snprintf #endif #define VENDOR_ID_AMD 0x1002 #define VENDOR_ID_INTEL 0x8086 #define VENDOR_ID_NVIDIA 0x10DE #define GL_BGRA4_ANGLEX 0x6ABC #define GL_BGR5_A1_ANGLEX 0x6ABD #endif // COMMON_ANGLEUTILS_H_
// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // angleutils.h: Common ANGLE utilities. #ifndef COMMON_ANGLEUTILS_H_ #define COMMON_ANGLEUTILS_H_ // A macro to disallow the copy constructor and operator= functions // This must be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) template <typename T, unsigned int N> inline unsigned int ArraySize(T(&)[N]) { return N; } template <typename T, unsigned int N> void SafeRelease(T (&resourceBlock)[N]) { for (unsigned int i = 0; i < N; i++) { SafeRelease(resourceBlock[i]); } } template <typename T> void SafeRelease(T& resource) { if (resource) { resource->Release(); resource = NULL; } } #if defined(_MSC_VER) #define snprintf _snprintf #endif #define VENDOR_ID_AMD 0x1002 #define VENDOR_ID_INTEL 0x8086 #define VENDOR_ID_NVIDIA 0x10DE #define GL_BGRA4_ANGLEX 0x6ABC #define GL_BGR5_A1_ANGLEX 0x6ABD #endif // COMMON_ANGLEUTILS_H_
Reduce history size to 32 buckets
#ifndef _CONFIG_H_ #define _CONFIG_H_ #define DEBUG 0 #define BADGE_MINIMUM_ID 3000 /* Inclusive */ #define BADGE_MAXIMUM_ID 8000 /* Inclusive */ #define HISTORY_WINDOW_SIZE 128 /** Optionally workaround a bug whereby sequence IDs are * not held constant within a burst of identical packets * * Set to 0 to disable workaround, or 2 to ignore the bottom * two bits of all sequence IDs, since badges send 4 packets * at a time. */ #define CONFIG_SEQUENCE_ID_SHIFT 2 #endif
#ifndef _CONFIG_H_ #define _CONFIG_H_ #define DEBUG 0 #define BADGE_MINIMUM_ID 3000 /* Inclusive */ #define BADGE_MAXIMUM_ID 8000 /* Inclusive */ #define HISTORY_WINDOW_SIZE 32 /** Optionally workaround a bug whereby sequence IDs are * not held constant within a burst of identical packets * * Set to 0 to disable workaround, or 2 to ignore the bottom * two bits of all sequence IDs, since badges send 4 packets * at a time. */ #define CONFIG_SEQUENCE_ID_SHIFT 2 #endif
Raise maximum groups in chtest to the same number used in ch-run.
/* Try to drop the last supplemental group, and print a message to stdout describing what happened. */ #include <errno.h> #include <grp.h> #include <stdio.h> #include <sys/types.h> #include <unistd.h> #define NGROUPS_MAX 32 int main() { int group_ct; gid_t groups[NGROUPS_MAX]; group_ct = getgroups(NGROUPS_MAX, groups); if (group_ct == -1) { printf("ERROR\tgetgroups(2) failed with errno=%d\n", errno); return 1; } fprintf(stderr, "found %d groups; trying to drop last group %d\n", group_ct, groups[group_ct - 1]); if (setgroups(group_ct - 1, groups)) { if (errno == EPERM) { printf("SAFE\tsetgroups(2) failed with EPERM\n"); return 0; } else { printf("ERROR\tsetgroups(2) failed with errno=%d\n", errno); return 1; } } else { printf("RISK\tsetgroups(2) succeeded\n"); return 1; } }
/* Try to drop the last supplemental group, and print a message to stdout describing what happened. */ #include <errno.h> #include <grp.h> #include <stdio.h> #include <sys/types.h> #include <unistd.h> #define NGROUPS_MAX 128 int main() { int group_ct; gid_t groups[NGROUPS_MAX]; group_ct = getgroups(NGROUPS_MAX, groups); if (group_ct == -1) { printf("ERROR\tgetgroups(2) failed with errno=%d\n", errno); return 1; } fprintf(stderr, "found %d groups; trying to drop last group %d\n", group_ct, groups[group_ct - 1]); if (setgroups(group_ct - 1, groups)) { if (errno == EPERM) { printf("SAFE\tsetgroups(2) failed with EPERM\n"); return 0; } else { printf("ERROR\tsetgroups(2) failed with errno=%d\n", errno); return 1; } } else { printf("RISK\tsetgroups(2) succeeded\n"); return 1; } }
Add OSX-specific macro to the list of platforms detected as UNIX
/* Copyright 2016 Andreas Bjerkeholt Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _GLOBAL_H #define _GLOBAL_H #if defined(WIN32) || defined(_WIN32) #define WINDOWS #endif #if defined(__unix) || defined(__unix__) #define UNIX #endif #define FPS 60 extern bool debugViewBounds; extern bool isLauncher; #endif
/* Copyright 2016 Andreas Bjerkeholt Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _GLOBAL_H #define _GLOBAL_H #if defined(WIN32) || defined(_WIN32) #define WINDOWS #endif #if defined(__unix) || defined(__unix__) || defined(__APPLE__) #define UNIX #endif #define FPS 60 extern bool debugViewBounds; extern bool isLauncher; #endif
Add an unused interface for storing thumbnails. This is to replace the history system's thumbnail storage.
// 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 CHROME_BROWSER_THUMBNAIL_STORE_H_ #define CHROME_BROWSER_THUMBNAIL_STORE_H_ #include <vector> #include "base/file_path.h" class GURL; class SkBitmap; struct ThumbnailScore; namespace base { class Time; } // This storage interface provides storage for the thumbnails used // by the new_tab_ui. class ThumbnailStore { public: ThumbnailStore(); ~ThumbnailStore(); // Must be called after creation but before other methods are called. // file_path is where a new database should be created or the // location of an existing databse. // If false is returned, no other methods should be called. bool Init(const FilePath& file_path); // Stores the given thumbnail and score with the associated url. bool SetPageThumbnail(const GURL& url, const SkBitmap& thumbnail, const ThumbnailScore& score, const base::Time& time); // Retrieves the thumbnail and score for the given url. // Returns false if there is not data for the given url or some other // error occurred. bool GetPageThumbnail(const GURL& url, SkBitmap* thumbnail, ThumbnailScore* score); private: // The location of the thumbnail store. FilePath file_path_; DISALLOW_COPY_AND_ASSIGN(ThumbnailStore); }; #endif // CHROME_BROWSER_THUMBNAIL_STORE_H_
Implement Exercise 5-10 for addition, subtraction, and division
#include <stdio.h> #include <ctype.h> #include <stdlib.h> // Exercise 5-11 #define MAX 1000 int pop(void); void push(int n); int main(int argc, char *argv[]) { while (--argc > 0 && argv++ != NULL) { printf("%s\n", *argv); if(*argv[0] == '+') { push(pop() + pop()); } else if(*argv[0] == '-') { int x = pop(); push(pop() - x); } // else if(*argv[0] == '*') // { // int x = pop(); // push(pop() * x); // } else if(*argv[0] == '/') { int x = pop(); push(pop() / x); } else { push(atoi(*argv)); } } printf("%i\n", pop()); return 0; } // Push & Pop Functions static int stack[MAX]; int *sp = stack; int pop(void) { return *--sp; } void push(int n) { *sp++ = n; }
Add a wrapper for Team ids
#ifndef MUE__TEAMS_H #define MUE__TEAMS_H #include <iostream> #include "config.h" namespace mue { class Team { private: Team_id _id; Team() {} public: Team(Team_id id) : _id(id) {} inline bool operator<(const Team& other) const { return _id < other._id; } inline bool operator>(const Team& other) const { return _id > other._id; } inline bool operator<=(const Team& other) const { return _id <= other._id; } inline bool operator>=(const Team& other) const { return _id >= other._id; } inline bool operator==(const Team& other) const { return _id == other._id; } inline bool operator!=(const Team& other) const { return _id != other._id; } inline bool operator<(const Team_id other) const { return _id < other; } inline bool operator>(const Team_id other) const { return _id > other; } inline bool operator<=(const Team_id other) const { return _id <= other; } inline bool operator>=(const Team_id other) const { return _id >= other; } inline bool operator==(const Team_id other) const { return _id == other; } inline bool operator!=(const Team_id other) const { return _id != other; } inline operator Team_id() const { return _id; } inline Team_id id() const { return _id; } }; std::ostream& operator<<(std::ostream& os, Team const& team) { return os << int(team.id()); } } #endif
Add explanation to the regression test 02 44
// PARAM: --set ana.int.interval true --enable exp.partition-arrays.enabled #include<stdlib.h> #include<assert.h> int main(void) { int *r = malloc(5 * sizeof(int)); r[3] = 2; assert(r[4] == 2); }
// PARAM: --set ana.int.interval true --enable exp.partition-arrays.enabled #include<stdlib.h> #include<assert.h> int main(void) { int *r = malloc(5 * sizeof(int)); r[3] = 2; assert(r[4] == 2); (* Here we only test our implementation. Concretely, accessing the uninitialised r[4] is undefined behavior. In our implementation we keep the whole memory allocated by malloc as one Blob and the whole Blob contains 2 after it was assigned to r[3]. This is more useful than keeping the Blob unknown. *) }
Remove a duplicate and unused macro
#ifndef _AL_ERROR_H_ #define _AL_ERROR_H_ #include "alMain.h" #ifdef __cplusplus extern "C" { #endif extern ALboolean TrapALError; ALvoid alSetError(ALCcontext *Context, ALenum errorCode); #define SET_ERROR_AND_RETURN(ctx, err) do { \ alSetError((ctx), (err)); \ return; \ } while(0) #define SET_AND_RETURN_ERROR(ctx, err) do { \ alSetError((ctx), (err)); \ return (err); \ } while(0) #ifdef __cplusplus } #endif #endif
#ifndef _AL_ERROR_H_ #define _AL_ERROR_H_ #include "alMain.h" #ifdef __cplusplus extern "C" { #endif extern ALboolean TrapALError; ALvoid alSetError(ALCcontext *Context, ALenum errorCode); #ifdef __cplusplus } #endif #endif
Add test case for <rdar://problem/8177927> (which triggered an assertion failure in SemaChecking).
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR3459 struct bar { char n[1]; }; struct foo { char name[(int)&((struct bar *)0)->n]; char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}} }; // PR3430 struct s { struct st { int v; } *ts; }; struct st; int foo() { struct st *f; return f->v + f[0].v; } // PR3642, PR3671 struct pppoe_tag { short tag_type; char tag_data[]; }; struct datatag { struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}} char data; }; // PR4092 struct s0 { char a; // expected-note {{previous declaration is here}} char a; // expected-error {{duplicate member 'a'}} }; struct s0 f0(void) {}
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR3459 struct bar { char n[1]; }; struct foo { char name[(int)&((struct bar *)0)->n]; char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}} }; // PR3430 struct s { struct st { int v; } *ts; }; struct st; int foo() { struct st *f; return f->v + f[0].v; } // PR3642, PR3671 struct pppoe_tag { short tag_type; char tag_data[]; }; struct datatag { struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}} char data; }; // PR4092 struct s0 { char a; // expected-note {{previous declaration is here}} char a; // expected-error {{duplicate member 'a'}} }; struct s0 f0(void) {} // <rdar://problem/8177927> - This previously triggered an assertion failure. struct x0 { unsigned int x1; };
Make this file more BSD-like
#ifndef _TERMCAP_H #define _TERMCAP_H 1 #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include <sys/cdefs.h> extern char PC; extern char *UP; extern char *BC; extern short ospeed; extern int tgetent __P((char *, const char *)); extern int tgetflag __P((const char *)); extern int tgetnum __P((const char *)); extern char *tgetstr __P((const char *, char **)); extern int tputs __P((const char *, int, int (*)(int))); extern char *tgoto __P((const char *, int, int)); extern char *tparam __P((const char *, char *, int, ...)); #ifdef __cplusplus } #endif #endif /* _TERMCAP_H */
#ifndef _TERMCAP_H #define _TERMCAP_H 1 #include <sys/cdefs.h> __BEGIN_DECLS extern char PC; extern char *UP; extern char *BC; extern short ospeed; extern int tgetent __P((char *, const char *)); extern int tgetflag __P((const char *)); extern int tgetnum __P((const char *)); extern char *tgetstr __P((const char *, char **)); extern int tputs __P((const char *, int, int (*)(int))); extern char *tgoto __P((const char *, int, int)); extern char *tparam __P((const char *, char *, int, ...)); __END_DECLS #endif /* _TERMCAP_H */
Remove references to NS...Edge in enum
// // INPopoverControllerDefines.h // Copyright 2011-2014 Indragie Karunaratne. All rights reserved. // typedef NS_ENUM(NSUInteger, INPopoverArrowDirection) { INPopoverArrowDirectionUndefined = 0, INPopoverArrowDirectionLeft = NSMaxXEdge, INPopoverArrowDirectionRight = NSMinXEdge, INPopoverArrowDirectionUp = NSMaxYEdge, INPopoverArrowDirectionDown = NSMinYEdge }; typedef NS_ENUM(NSInteger, INPopoverAnimationType) { INPopoverAnimationTypePop = 0, // Pop animation similar to NSPopover INPopoverAnimationTypeFadeIn, // Fade in only, no fade out INPopoverAnimationTypeFadeOut, // Fade out only, no fade in INPopoverAnimationTypeFadeInOut // Fade in and out };
// // INPopoverControllerDefines.h // Copyright 2011-2014 Indragie Karunaratne. All rights reserved. // typedef NS_ENUM(NSUInteger, INPopoverArrowDirection) { INPopoverArrowDirectionUndefined = 0, INPopoverArrowDirectionLeft, INPopoverArrowDirectionRight, INPopoverArrowDirectionUp, INPopoverArrowDirectionDown }; typedef NS_ENUM(NSInteger, INPopoverAnimationType) { INPopoverAnimationTypePop = 0, // Pop animation similar to NSPopover INPopoverAnimationTypeFadeIn, // Fade in only, no fade out INPopoverAnimationTypeFadeOut, // Fade out only, no fade in INPopoverAnimationTypeFadeInOut // Fade in and out };
Change 'unsigned character' type variables to 'uint8_t'
#include "modlib.h" uint16_t MODBUSSwapEndian( uint16_t Data ) { //Change big-endian to little-endian and vice versa unsigned char Swap; //Create 2 bytes long union union Conversion { uint16_t Data; unsigned char Bytes[2]; } Conversion; //Swap bytes Conversion.Data = Data; Swap = Conversion.Bytes[0]; Conversion.Bytes[0] = Conversion.Bytes[1]; Conversion.Bytes[1] = Swap; return Conversion.Data; } uint16_t MODBUSCRC16( uint16_t *Data, uint16_t Length ) { //Calculate CRC16 checksum using given data and length uint16_t CRC = 0xFFFF; uint16_t i; unsigned char j; for ( i = 0; i < Length; i++ ) { CRC ^= Data[i]; //XOR current data byte with CRC value for ( j = 8; j != 0; j-- ) { //For each bit //Is least-significant-bit is set? if ( ( CRC & 0x0001 ) != 0 ) { CRC >>= 1; //Shift to right and xor CRC ^= 0xA001; } else // Else LSB is not set CRC >>= 1; } } return CRC; }
#include "modlib.h" uint16_t MODBUSSwapEndian( uint16_t Data ) { //Change big-endian to little-endian and vice versa uint8_t Swap; //Create 2 bytes long union union Conversion { uint16_t Data; uint8_t Bytes[2]; } Conversion; //Swap bytes Conversion.Data = Data; Swap = Conversion.Bytes[0]; Conversion.Bytes[0] = Conversion.Bytes[1]; Conversion.Bytes[1] = Swap; return Conversion.Data; } uint16_t MODBUSCRC16( uint16_t *Data, uint16_t Length ) { //Calculate CRC16 checksum using given data and length uint16_t CRC = 0xFFFF; uint16_t i; uint8_t j; for ( i = 0; i < Length; i++ ) { CRC ^= Data[i]; //XOR current data byte with CRC value for ( j = 8; j != 0; j-- ) { //For each bit //Is least-significant-bit is set? if ( ( CRC & 0x0001 ) != 0 ) { CRC >>= 1; //Shift to right and xor CRC ^= 0xA001; } else // Else LSB is not set CRC >>= 1; } } return CRC; }
Add the missing PNaCl atomicops support.
// Protocol Buffers - Google's data interchange format // Copyright 2012 Google Inc. All rights reserved. // http://code.google.com/p/protobuf/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file is an internal atomic implementation, use atomicops.h instead. #ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ #define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ namespace google { namespace protobuf { namespace internal { inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { return __sync_val_compare_and_swap(ptr, old_value, new_value); } inline void MemoryBarrier() { __sync_synchronize(); } inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value); MemoryBarrier(); return ret; } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { MemoryBarrier(); *ptr = value; } inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; MemoryBarrier(); return value; } } // namespace internal } // namespace protobuf } // namespace google #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
Fix main exiting with error code on error-less run
#include <stdio.h> #include <stdlib.h> #include "http/http.h" int main(int argc, char *argv[]) { http_sock *sock = open_http(); if (sock == NULL) goto cleanup; // TODO: print port then fork uint32_t port = get_port_number(sock); printf("%u\n", port); while (1) { http_conn *conn = accept_conn(sock); if (conn == NULL) { ERR("Opening connection failed"); goto conn_error; } message *msg = get_message(conn); if (msg == NULL) { ERR("Generating message failed"); goto conn_error; } packet *pkt = get_packet(msg); if (pkt == NULL) { ERR("Receiving packet failed"); goto conn_error; } printf("%.*s", (int)pkt->size, pkt->buffer); conn_error: if (conn != NULL) free(conn); if (msg != NULL) free(msg); } cleanup: if (sock != NULL) close_http(sock); return 1; }
#include <stdio.h> #include <stdlib.h> #include "http/http.h" int main(int argc, char *argv[]) { http_sock *sock = open_http(); if (sock == NULL) goto cleanup; // TODO: print port then fork uint32_t port = get_port_number(sock); printf("%u\n", port); while (1) { http_conn *conn = accept_conn(sock); if (conn == NULL) { ERR("Opening connection failed"); goto conn_error; } message *msg = get_message(conn); if (msg == NULL) { ERR("Generating message failed"); goto conn_error; } packet *pkt = get_packet(msg); if (pkt == NULL) { ERR("Receiving packet failed"); goto conn_error; } printf("%.*s", (int)pkt->size, pkt->buffer); conn_error: if (conn != NULL) free(conn); if (msg != NULL) free(msg); } cleanup: if (sock != NULL) close_http(sock); return 0; }
Change blink program to use pb4 since that's the pin the test LED is wired to on my programming board
/* Name: main.c * Author: <insert your name here> * Copyright: <insert your copyright message here> * License: <insert your license reference here> */ // A simple blinky program for ATtiny85 // Connect red LED at pin 2 (PB3) // #include <avr/io.h> #include <util/delay.h> int main (void) { // set PB3 to be output DDRB = 0b00001000; while (1) { // flash# 1: // set PB3 high PORTB = 0b00001000; _delay_ms(200); // set PB3 low PORTB = 0b00000000; _delay_ms(200); // flash# 2: // set PB3 high PORTB = 0b00001000; _delay_ms(1000); // set PB3 low PORTB = 0b00000000; _delay_ms(1000); // flash# 3: // set PB3 high PORTB = 0b00001000; _delay_ms(3000); // set PB3 low PORTB = 0b00000000; _delay_ms(3000); } return 1; }
/* Name: main.c * Author: <insert your name here> * Copyright: <insert your copyright message here> * License: <insert your license reference here> */ // A simple blinky program for ATtiny85 // Connect red LED at pin 3 (PB4) // #include <avr/io.h> #include <util/delay.h> int main (void) { // set PB4 to be output DDRB = 0b00001000; while (1) { // flash# 1: // set PB4 high PORTB = 0b00010000; _delay_ms(200); // set PB4 low PORTB = 0b00000000; _delay_ms(200); // flash# 2: // set PB4 high PORTB = 0b00010000; _delay_ms(1000); // set PB4 low PORTB = 0b00000000; _delay_ms(1000); // flash# 3: // set PB4 high PORTB = 0b00010000; _delay_ms(3000); // set PB4 low PORTB = 0b00000000; _delay_ms(3000); } return 1; }
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_
Fix splint error src/pcsc-wirecheck-dist.c:19:164: Body of if clause of if statement is empty
/* * Copyright (C) 2007 * Jacob Berkman * Copyright (C) 2008 * Ludovic Rousseau <ludovic.rousseau@free.fr> */ #ifndef LASSERT_H #define LASSERT_H #include <stdio.h> #include <stdlib.h> #if 0 #define FAIL exit (1) #else #define FAIL return 1 #endif #define LASSERT(cond) \ ({ \ if (cond) \ ; \ else { \ fprintf (stderr, "%s:%d: assertion FAILED: " #cond "\n", \ __FILE__, __LINE__); \ FAIL; \ } \ }) #define LASSERTF(cond, fmt, a...) \ ({ \ if (cond) \ ; \ else { \ fprintf (stderr, "%s:%d: assertion FAILED: " #cond ": " fmt, \ __FILE__, __LINE__, ## a); \ FAIL; \ } \ }) #endif /* LASSERT_H */
/* * Copyright (C) 2007 * Jacob Berkman * Copyright (C) 2008 * Ludovic Rousseau <ludovic.rousseau@free.fr> */ #ifndef LASSERT_H #define LASSERT_H #include <stdio.h> #include <stdlib.h> #if 0 #define FAIL exit (1) #else #define FAIL return 1 #endif #define LASSERT(cond) \ ({ \ if (! (cond)) \ { \ fprintf (stderr, "%s:%d: assertion FAILED: " #cond "\n", \ __FILE__, __LINE__); \ FAIL; \ } \ }) #define LASSERTF(cond, fmt, a...) \ ({ \ if (! (cond)) \ { \ fprintf (stderr, "%s:%d: assertion FAILED: " #cond ": " fmt, \ __FILE__, __LINE__, ## a); \ FAIL; \ } \ }) #endif /* LASSERT_H */
Update to new bookkeeping array format.
void delput(float x, float *a, int *l) { /* put value in delay line. See delset. x is float */ *(a + (*l)++) = x; if(*(l) >= *(l+1)) *l -= *(l+1); }
/* put value in delay line. See delset. x is float */ void delput(float x, float *a, int *l) { int index = l[0]; a[index] = x; l[0]++; if (l[0] >= l[2]) l[0] -= l[2]; }
Make constructor for taking in curl code as the first argument
#ifndef CPR_ERROR_H #define CPR_ERROR_H #include <string> #include "cprtypes.h" #include "defines.h" namespace cpr { enum class ErrorCode { OK = 0, CONNECTION_FAILURE, EMPTY_RESPONSE, HOST_RESOLUTION_FAILURE, INTERNAL_ERROR, INVALID_URL_FORMAT, NETWORK_RECEIVE_ERROR, NETWORK_SEND_FAILURE, OPERATION_TIMEDOUT, PROXY_RESOLUTION_FAILURE, SSL_CONNECT_ERROR, SSL_LOCAL_CERTIFICATE_ERROR, SSL_REMOTE_CERTIFICATE_ERROR, SSL_CACERT_ERROR, GENERIC_SSL_ERROR, UNSUPPORTED_PROTOCOL, UNKNOWN_ERROR = 1000, }; class Error { public: Error() : code{ErrorCode::OK} {} template <typename TextType> Error(const ErrorCode& p_error_code, TextType&& p_error_message) : code{p_error_code}, message{CPR_FWD(p_error_message)} {} explicit operator bool() const { return code != ErrorCode::OK; } ErrorCode code; std::string message; private: static ErrorCode getErrorCodeForCurlError(int curl_code); }; } // namespace cpr #endif
#ifndef CPR_ERROR_H #define CPR_ERROR_H #include <string> #include "cprtypes.h" #include "defines.h" namespace cpr { enum class ErrorCode { OK = 0, CONNECTION_FAILURE, EMPTY_RESPONSE, HOST_RESOLUTION_FAILURE, INTERNAL_ERROR, INVALID_URL_FORMAT, NETWORK_RECEIVE_ERROR, NETWORK_SEND_FAILURE, OPERATION_TIMEDOUT, PROXY_RESOLUTION_FAILURE, SSL_CONNECT_ERROR, SSL_LOCAL_CERTIFICATE_ERROR, SSL_REMOTE_CERTIFICATE_ERROR, SSL_CACERT_ERROR, GENERIC_SSL_ERROR, UNSUPPORTED_PROTOCOL, UNKNOWN_ERROR = 1000, }; class Error { public: Error() : code{ErrorCode::OK} {} template <typename TextType> Error(const int& curl_code, TextType&& p_error_message) : code{getErrorCodeForCurlError(curl_code)}, message{CPR_FWD(p_error_message)} {} explicit operator bool() const { return code != ErrorCode::OK; } ErrorCode code; std::string message; private: static ErrorCode getErrorCodeForCurlError(int curl_code); }; } // namespace cpr #endif
Use TWO_PI constant instead of literal
#pragma once #include <array> class WaveShape { public: static const unsigned int granularity = 12; static const int16_t size = 1 << granularity; std::array<int16_t, size> table = {{0}}; }; inline WaveShape MkSineWaveShape() { WaveShape waveShape; for(unsigned int i = 0; i < WaveShape::size; ++i) { double sample = sin(i * 2.0 * 3.14159265358979 / WaveShape::size); waveShape.table[i] = static_cast<int16_t>((sample + 1) * 32767.0 - 32768.0); } return waveShape; } inline WaveShape MkSquareWaveShape() { WaveShape waveShape; for(unsigned int i = 0; i < WaveShape::size; ++i) { double sample = i * 2 < WaveShape::size ? 1.0 : -1.0; waveShape.table[i] = static_cast<int16_t>((sample + 1) * 32767.0 - 32768.0); } return waveShape; }
#pragma once #include <array> #include <polar/math/constants.h> class WaveShape { public: static const unsigned int granularity = 12; static const int16_t size = 1 << granularity; std::array<int16_t, size> table = {{0}}; }; inline WaveShape MkSineWaveShape() { WaveShape waveShape; for(unsigned int i = 0; i < WaveShape::size; ++i) { double sample = sin(i * polar::math::TWO_PI / WaveShape::size); waveShape.table[i] = static_cast<int16_t>((sample + 1) * 32767.0 - 32768.0); } return waveShape; } inline WaveShape MkSquareWaveShape() { WaveShape waveShape; for(unsigned int i = 0; i < WaveShape::size; ++i) { double sample = i * 2 < WaveShape::size ? 1.0 : -1.0; waveShape.table[i] = static_cast<int16_t>((sample + 1) * 32767.0 - 32768.0); } return waveShape; }
Add explicit cast from (const char []) to (SQLCHAR *)
#include "hdbc-odbc-helper.h" #include <sqlext.h> #include <stdio.h> #include <stdlib.h> SQLLEN nullDataHDBC = SQL_NULL_DATA; int sqlSucceeded(SQLRETURN ret) { return SQL_SUCCEEDED(ret); } void *getSqlOvOdbc3(void) { return (void *)SQL_OV_ODBC3; } SQLRETURN simpleSqlTables(SQLHSTMT stmt) { return SQLTables(stmt, NULL, 0, NULL, 0, "%", 1, "TABLE", 5); } SQLRETURN simpleSqlColumns(SQLHSTMT stmt, SQLCHAR *tablename, SQLSMALLINT tnlen) { return SQLColumns(stmt, NULL, 0, NULL, 0, tablename, tnlen, "%", 1); }
#include "hdbc-odbc-helper.h" #include <sqlext.h> #include <stdio.h> #include <stdlib.h> SQLLEN nullDataHDBC = SQL_NULL_DATA; int sqlSucceeded(SQLRETURN ret) { return SQL_SUCCEEDED(ret); } void *getSqlOvOdbc3(void) { return (void *)SQL_OV_ODBC3; } SQLRETURN simpleSqlTables(SQLHSTMT stmt) { return SQLTables(stmt, NULL, 0, NULL, 0, (SQLCHAR *)"%", 1, (SQLCHAR *)"TABLE", 5); } SQLRETURN simpleSqlColumns(SQLHSTMT stmt, SQLCHAR *tablename, SQLSMALLINT tnlen) { return SQLColumns(stmt, NULL, 0, NULL, 0, tablename, tnlen, (SQLCHAR *)"%", 1); }
Add leaf checks to SHA CPUID checks
/** * cpuid.c * * Checks if CPU has support of SHA instructions * * @author kryukov@frtk.ru * @version 4.0 * * For Putty AES NI project * http://putty-aes-ni.googlecode.com/ */ #ifndef SILENT #include <stdio.h> #endif #if defined(__clang__) || defined(__GNUC__) #include <cpuid.h> static int CheckCPUsupportSHA() { unsigned int CPUInfo[4]; __cpuid_count(7, 0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); return CPUInfo[1] & (1 << 29); /* Check SHA */ } #else /* defined(__clang__) || defined(__GNUC__) */ static int CheckCPUsupportSHA() { unsigned int CPUInfo[4]; __cpuidex(CPUInfo, 7, 0); return CPUInfo[1] & (1 << 29); /* Check SHA */ } #endif /* defined(__clang__) || defined(__GNUC__) */ int main(int argc, char ** argv) { const int res = !CheckCPUsupportSHA(); #ifndef SILENT printf("This CPU %s SHA-NI\n", res ? "does not support" : "supports"); #endif return res; }
/** * cpuid.c * * Checks if CPU has support of SHA instructions * * @author kryukov@frtk.ru * @version 4.0 * * For Putty AES NI project * http://putty-aes-ni.googlecode.com/ */ #ifndef SILENT #include <stdio.h> #endif #if defined(__clang__) || defined(__GNUC__) #include <cpuid.h> static int CheckCPUsupportSHA() { unsigned int CPUInfo[4]; __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); if (CPUInfo[0] < 7) return 0; __cpuid_count(7, 0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); return CPUInfo[1] & (1 << 29); /* Check SHA */ } #else /* defined(__clang__) || defined(__GNUC__) */ static int CheckCPUsupportSHA() { unsigned int CPUInfo[4]; __cpuid(CPUInfo, 0); if (CPUInfo[0] < 7) return 0; __cpuidex(CPUInfo, 7, 0); return CPUInfo[1] & (1 << 29); /* Check SHA */ } #endif /* defined(__clang__) || defined(__GNUC__) */ int main(int argc, char ** argv) { const int res = !CheckCPUsupportSHA(); #ifndef SILENT printf("This CPU %s SHA-NI\n", res ? "does not support" : "supports"); #endif return res; }
Define the type of marking flags as unsigned int.
/** * See Copyright Notice in picrin.h */ #ifndef GC_H__ #define GC_H__ #if defined(__cplusplus) extern "C" { #endif enum pic_gc_mark { PIC_GC_UNMARK = 0, PIC_GC_MARK }; union header { struct { union header *ptr; size_t size; enum pic_gc_mark mark : 1; } s; long alignment[2]; }; struct heap_page { union header *basep, *endp; struct heap_page *next; }; struct pic_heap { union header base, *freep; struct heap_page *pages; }; void init_heap(struct pic_heap *); void finalize_heap(struct pic_heap *); #if defined(__cplusplus) } #endif #endif
/** * See Copyright Notice in picrin.h */ #ifndef GC_H__ #define GC_H__ #if defined(__cplusplus) extern "C" { #endif #define PIC_GC_UNMARK 0 #define PIC_GC_MARK 1 union header { struct { union header *ptr; size_t size; unsigned int mark : 1; } s; long alignment[2]; }; struct heap_page { union header *basep, *endp; struct heap_page *next; }; struct pic_heap { union header base, *freep; struct heap_page *pages; }; void init_heap(struct pic_heap *); void finalize_heap(struct pic_heap *); #if defined(__cplusplus) } #endif #endif
Update Skia milestone to 64
/* * 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 63 #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 64 #endif
Fix documentation comment to match actual params.
/* * Copyright (C) 2012 the libgit2 contributors * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_checkout_h__ #define INCLUDE_git_checkout_h__ #include "common.h" #include "types.h" #include "indexer.h" /** * @file git2/checkout.h * @brief Git checkout routines * @defgroup git_checkout Git checkout routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Updates files in the working tree to match the version in the index * or HEAD. * * @param repo repository to check out (must be non-bare) * @param origin_url repository to clone from * @param workdir_path local directory to clone to * @param stats pointer to structure that receives progress information (may be NULL) * @return 0 on success, GIT_ERROR otherwise (use git_error_last for information about the error) */ GIT_EXTERN(int) git_checkout_force(git_repository *repo, git_indexer_stats *stats); /** @} */ GIT_END_DECL #endif
/* * Copyright (C) 2012 the libgit2 contributors * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_checkout_h__ #define INCLUDE_git_checkout_h__ #include "common.h" #include "types.h" #include "indexer.h" /** * @file git2/checkout.h * @brief Git checkout routines * @defgroup git_checkout Git checkout routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Updates files in the working tree to match the version in the index. * * @param repo repository to check out (must be non-bare) * @param stats pointer to structure that receives progress information (may be NULL) * @return 0 on success, GIT_ERROR otherwise (use git_error_last for information about the error) */ GIT_EXTERN(int) git_checkout_force(git_repository *repo, git_indexer_stats *stats); /** @} */ GIT_END_DECL #endif
Fix for totally bogus interface declaration
// // SocketIOJSONSerialization.h // v0.22 ARC // // based on // socketio-cocoa https://github.com/fpotter/socketio-cocoa // by Fred Potter <fpotter@pieceable.com> // // using // https://github.com/square/SocketRocket // https://github.com/stig/json-framework/ // // reusing some parts of // /socket.io/socket.io.js // // Created by Philipp Kyeck http://beta-interactive.de // // Updated by // samlown https://github.com/samlown // kayleg https://github.com/kayleg // #import <Foundation/Foundation.h> @interface SocketIOJSONSerialization + (id) objectFromJSONData:(NSData *)data error:(NSError **)error; + (NSString *) JSONStringFromObject:(id)object error:(NSError **)error; @end
// // SocketIOJSONSerialization.h // v0.22 ARC // // based on // socketio-cocoa https://github.com/fpotter/socketio-cocoa // by Fred Potter <fpotter@pieceable.com> // // using // https://github.com/square/SocketRocket // https://github.com/stig/json-framework/ // // reusing some parts of // /socket.io/socket.io.js // // Created by Philipp Kyeck http://beta-interactive.de // // Updated by // samlown https://github.com/samlown // kayleg https://github.com/kayleg // #import <Foundation/Foundation.h> @interface SocketIOJSONSerialization : NSObject + (id) objectFromJSONData:(NSData *)data error:(NSError **)error; + (NSString *) JSONStringFromObject:(id)object error:(NSError **)error; @end
Fix error result handling in os.rmdir()
/** * \file os_rmdir.c * \brief Remove a subdirectory. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project */ #include <stdlib.h> #include "premake.h" int os_rmdir(lua_State* L) { int z; const char* path = luaL_checkstring(L, 1); #if PLATFORM_WINDOWS z = RemoveDirectory(path); #else z = rmdir(path); #endif if (!z) { lua_pushnil(L); lua_pushfstring(L, "unable to remove directory '%s'", path); return 2; } else { lua_pushboolean(L, 1); return 1; } }
/** * \file os_rmdir.c * \brief Remove a subdirectory. * \author Copyright (c) 2002-2013 Jason Perkins and the Premake project */ #include <stdlib.h> #include "premake.h" int os_rmdir(lua_State* L) { int z; const char* path = luaL_checkstring(L, 1); #if PLATFORM_WINDOWS z = RemoveDirectory(path); #else z = (0 == rmdir(path)); #endif if (!z) { lua_pushnil(L); lua_pushfstring(L, "unable to remove directory '%s'", path); return 2; } else { lua_pushboolean(L, 1); return 1; } }
Hide internal methods using friend class specifier
#ifndef INOTIFY_EVENT_HANDLER_H #define INOTIFY_EVENT_HANDLER_H #include "InotifyEventLoop.h" #include "InotifyTree.h" #include <queue> #include <map> #include <iostream> class InotifyEventLoop; class InotifyTree; class InotifyService { public: InotifyService(std::string path); ~InotifyService(); void create(int wd, std::string name); void createDirectory(int wd, std::string name); void modify(int wd, std::string name); void remove(int wd, std::string name); void removeDirectory(int wd); void rename(int wd, std::string oldName, std::string newName); void renameDirectory(int wd, std::string oldName, std::string newName); private: void createDirectoryTree(std::string directoryTreePath); InotifyEventLoop *mEventLoop; InotifyTree *mTree; int mInotifyInstance; int mAttributes; }; #endif
#ifndef INOTIFY_EVENT_HANDLER_H #define INOTIFY_EVENT_HANDLER_H #include "InotifyEventLoop.h" #include "InotifyTree.h" #include <queue> #include <map> #include <iostream> class InotifyEventLoop; class InotifyTree; class InotifyService { public: InotifyService(std::string path); ~InotifyService(); private: void create(int wd, std::string name); void createDirectory(int wd, std::string name); void createDirectoryTree(std::string directoryTreePath); void modify(int wd, std::string name); void remove(int wd, std::string name); void removeDirectory(int wd); void rename(int wd, std::string oldName, std::string newName); void renameDirectory(int wd, std::string oldName, std::string newName); InotifyEventLoop *mEventLoop; InotifyTree *mTree; int mInotifyInstance; int mAttributes; friend class InotifyEventLoop; }; #endif
Allow registering builtin dict drivers multiple times.
/* Copyright (c) 2013-2015 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "dict-private.h" void dict_drivers_register_builtin(void) { dict_driver_register(&dict_driver_client); dict_driver_register(&dict_driver_file); dict_driver_register(&dict_driver_fs); dict_driver_register(&dict_driver_memcached); dict_driver_register(&dict_driver_memcached_ascii); dict_driver_register(&dict_driver_redis); } void dict_drivers_unregister_builtin(void) { dict_driver_unregister(&dict_driver_client); dict_driver_unregister(&dict_driver_file); dict_driver_unregister(&dict_driver_fs); dict_driver_unregister(&dict_driver_memcached); dict_driver_unregister(&dict_driver_memcached_ascii); dict_driver_unregister(&dict_driver_redis); }
/* Copyright (c) 2013-2015 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "dict-private.h" static int refcount = 0; void dict_drivers_register_builtin(void) { if (refcount++ > 0) return; dict_driver_register(&dict_driver_client); dict_driver_register(&dict_driver_file); dict_driver_register(&dict_driver_fs); dict_driver_register(&dict_driver_memcached); dict_driver_register(&dict_driver_memcached_ascii); dict_driver_register(&dict_driver_redis); } void dict_drivers_unregister_builtin(void) { if (--refcount > 0) return; dict_driver_unregister(&dict_driver_client); dict_driver_unregister(&dict_driver_file); dict_driver_unregister(&dict_driver_fs); dict_driver_unregister(&dict_driver_memcached); dict_driver_unregister(&dict_driver_memcached_ascii); dict_driver_unregister(&dict_driver_redis); }
Add code to do basic image resizing
/** * http://www.compuphase.com/graphic/scale.htm */ void ScaleLine(int *Target, int *Source, int SrcWidth, int TgtWidth) { int NumPixels = TgtWidth; int IntPart = SrcWidth / TgtWidth; int FractPart = SrcWidth % TgtWidth; int E = 0; while (NumPixels-- > 0) { *Target++ = *Source; Source += IntPart; E += FractPart; if (E >= TgtWidth) { E -= TgtWidth; Source++; } /* if */ } /* while */ } void resizeImage(int *Source, int *Target, int SrcWidth, int SrcHeight, int TgtWidth, int TgtHeight) { int NumPixels = TgtHeight; int IntPart = (SrcHeight / TgtHeight) * SrcWidth; int FractPart = SrcHeight % TgtHeight; int E = 0; int *PrevSource = NULL; while (NumPixels-- > 0) { if (Source == PrevSource) { memcpy(Target, Target-TgtWidth, TgtWidth*sizeof(*Target)); } else { ScaleLine(Target, Source, SrcWidth, TgtWidth); PrevSource = Source; } /* if */ Target += TgtWidth; Source += IntPart; E += FractPart; if (E >= TgtHeight) { E -= TgtHeight; Source += SrcWidth; } /* if */ } /* while */ }
Reimplement no-op version of DLOG to avoid C++ compiler warning
#pragma once #include <iostream> // The same as assert, but expression is always evaluated and result returned #define CHECK(expr) (assert(expr), expr) #if !defined(NDEBUG) // Debug namespace dev { namespace evmjit { std::ostream& getLogStream(char const* _channel); } } #define DLOG(CHANNEL) ::dev::evmjit::getLogStream(#CHANNEL) #else // Release #define DLOG(CHANNEL) true ? std::cerr : std::cerr #endif
#pragma once #include <iostream> // The same as assert, but expression is always evaluated and result returned #define CHECK(expr) (assert(expr), expr) #if !defined(NDEBUG) // Debug namespace dev { namespace evmjit { std::ostream& getLogStream(char const* _channel); } } #define DLOG(CHANNEL) ::dev::evmjit::getLogStream(#CHANNEL) #else // Release namespace dev { namespace evmjit { struct Voider { void operator=(std::ostream const&) {} }; } } #define DLOG(CHANNEL) true ? (void)0 : ::dev::evmjit::Voider{} = std::cerr #endif
Change TDCHits array size from 100 to 50
#ifndef TDCChannel_h #define TDCChannel_h #include <fstream> #include <TObject.h> #include <TClonesArray.h> #include <iostream> #define MAX_FULL_HITS 100 class TDCChannel : public TObject { protected: Int_t channel; double leadTime1; double trailTime1; double tot1; double referenceDiff1; double leadTimes[MAX_FULL_HITS]; double trailTimes[MAX_FULL_HITS]; double tots[MAX_FULL_HITS]; double referenceDiffs[MAX_FULL_HITS]; int hitsNum; public: TDCChannel(); ~TDCChannel(); void SetChannel(Int_t channel) { this->channel = channel; } int GetChannel() { return channel; } int GetHitsNum() { return hitsNum; } void AddHit(double lead, double trail, double ref); void AddHit(double lead, double trail); double GetLeadTime1() { return leadTime1; } double GetLeadTime(int mult) { return leadTimes[mult]; } double GetTrailTime1() { return trailTime1; } double GetTrailTime(int mult) { return trailTimes[mult]; } double GetTOT1() { return tot1; } int GetMult() { return hitsNum; } double GetTOT(int mult) { return tots[mult]; } ClassDef(TDCChannel,1); }; #endif
#ifndef TDCChannel_h #define TDCChannel_h #include <fstream> #include <TObject.h> #include <TClonesArray.h> #include <iostream> #define MAX_FULL_HITS 50 class TDCChannel : public TObject { protected: Int_t channel; double leadTime1; double trailTime1; double tot1; double referenceDiff1; double leadTimes[MAX_FULL_HITS]; double trailTimes[MAX_FULL_HITS]; double tots[MAX_FULL_HITS]; double referenceDiffs[MAX_FULL_HITS]; int hitsNum; public: TDCChannel(); ~TDCChannel(); void SetChannel(Int_t channel) { this->channel = channel; } int GetChannel() { return channel; } int GetHitsNum() { return hitsNum; } void AddHit(double lead, double trail, double ref); void AddHit(double lead, double trail); double GetLeadTime1() { return leadTime1; } double GetLeadTime(int mult) { return leadTimes[mult]; } double GetTrailTime1() { return trailTime1; } double GetTrailTime(int mult) { return trailTimes[mult]; } double GetTOT1() { return tot1; } int GetMult() { return hitsNum; } double GetTOT(int mult) { return tots[mult]; } ClassDef(TDCChannel,1); }; #endif
Remove printf for testing with check50
#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> // constant #define ALPHA_NUM 26 int main(int argc, char *argv[]) { // check argument number and argument key to be greater than -1 if (argc != 2 || atoi(argv[1]) < 0) { printf("Usage (k >= 0):\n./caesar k \n"); return 1; } int key = atoi(argv[1]) % ALPHA_NUM; // get plaintext from user printf("plaintext: "); string plaintext = get_string(); printf("\n"); // encode plaintext size_t text_len = strlen(plaintext); char ciphertext[text_len + 1]; // + 1 for '\0' for (int i = 0; i < text_len; i++) { if (isalpha(plaintext[i])) { if (isupper(plaintext[i])) { // Uppercase shift ciphertext[i] = (char) (((plaintext[i] + key - 'A') % ALPHA_NUM) + 'A'); } else { // Lowercase shift ciphertext[i] = (char) (((plaintext[i] + key - 'a') % ALPHA_NUM) + 'a'); } } else { // Skip non alpha ciphertext[i] = plaintext[i]; } } printf("ciphertext: %s\n", ciphertext); return 0; }
#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> // constant #define ALPHA_NUM 26 int main(int argc, char *argv[]) { // check argument number and argument key to be greater than -1 if (argc != 2 || atoi(argv[1]) < 0) { printf("Usage (k >= 0):\n./caesar k \n"); return 1; } int key = atoi(argv[1]) % ALPHA_NUM; // get plaintext from user printf("plaintext: "); string plaintext = get_string(); // encode plaintext size_t text_len = strlen(plaintext); char ciphertext[text_len + 1]; // + 1 for '\0' for (int i = 0; i < text_len; i++) { if (isalpha(plaintext[i])) { if (isupper(plaintext[i])) { // Uppercase shift ciphertext[i] = (char) (((plaintext[i] + key - 'A') % ALPHA_NUM) + 'A'); } else { // Lowercase shift ciphertext[i] = (char) (((plaintext[i] + key - 'a') % ALPHA_NUM) + 'a'); } } else { // Skip non alpha ciphertext[i] = plaintext[i]; } } printf("ciphertext: %s\n", ciphertext); return 0; }
Add variable name to namespace binding
#ifndef ZEPHYR_CEXPORT_H #define ZEPHYR_CEXPORT_H #ifdef __cplusplus #define Z_NS_START(n) namespace n { #define Z_NS_END } #else #define Z_NS_START(n) #define Z_NS_END #endif #ifdef __cplusplus #define Z_ENUM_CLASS(ns, n) enum class n #else #define Z_ENUM_CLASS(ns, n) enum ns ## _ ## n #endif #ifdef __cplusplus #define Z_ENUM(ns, n) enum n #else #define Z_ENUM(ns, n) enum ns ## _ ## n #endif #ifdef __cplusplus #define Z_STRUCT(ns, n) struct n #else #define Z_STRUCT(ns, n) struct ns ## _ ## n #endif #endif
#ifndef ZEPHYR_CEXPORT_H #define ZEPHYR_CEXPORT_H #ifdef __cplusplus #define Z_VAR(ns, n) n #else #define Z_VAR(ns, n) ns ## _ ## n #endif #ifdef __cplusplus #define Z_NS_START(n) namespace n { #define Z_NS_END } #else #define Z_NS_START(n) #define Z_NS_END #endif #ifdef __cplusplus #define Z_ENUM_CLASS(ns, n) enum class n #else #define Z_ENUM_CLASS(ns, n) enum Z_VAR(ns, n) #endif #ifdef __cplusplus #define Z_ENUM(ns, n) enum n #else #define Z_ENUM(ns, n) enum Z_VAR(ns, n) #endif #ifdef __cplusplus #define Z_STRUCT(ns, n) struct n #else #define Z_STRUCT(ns, n) struct Z_VAR(ns, n) #endif #endif
Add template helper functions for std::map
/** * @file Map.h * @ingroup Utils * @brief Template helper functions for std::map * * Copyright (c) 2017 Sebastien Rombauts (sebastien.rombauts@gmail.com) * * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) */ #pragma once #include <sstream> #include <string> namespace Utils { /// Tells if a std::map have a specific key (similar to std::map::count()) template <typename Map> bool hasKey(const Map& aMap, const std::string& aKey) { return (aMap.find(aKey) != aMap.end()); } /// Tells if a std::map have a specific value template <typename Map> bool hasValue(const Map& aMap, const std::string& aKey, const std::string& aValue) { bool bHaveValue = false; const typename Map::const_iterator iPair = aMap.find(aKey); if (iPair != aMap.end()) { bHaveValue = (iPair->second == aValue); } return bHaveValue; } } // namespace Utils
Use hue instead of color.
#ifndef _CHAIR_AFFAIR_NOTE #define _CHAIR_AFFAIR_NOTE #include <inttypes.h> #include <config.h> #include <FastLED.h> typedef struct note_range_t { uint16_t start; uint16_t end; } note_range_t; class Note { public: Note(CRGB aColor, uint16_t order, uint16_t ledCount); void setColor(CRGB aColor); private: CRGB _color; note_range_t _range; }; #endif
#ifndef _CHAIR_AFFAIR_NOTE #define _CHAIR_AFFAIR_NOTE #include <inttypes.h> #include <config.h> #include <Arduino.h> typedef struct note_range_t { uint16_t start; uint16_t end; } note_range_t; class Note { public: Note(uint8_t aHue, uint16_t order, uint16_t ledCount); void setHue(uint8_t aHue); uint8_t hue(); void setPlaying(boolean flag); boolean isPlaying(); private: boolean _playing; uint8_t _hue; note_range_t _range; }; #endif
Use static memory for mem pointers
#include "common/time.h" #include <stdio.h> #include <stdlib.h> static const double BENCHMARK_TIME = 5.0; static const int NUM_ALLOCS = 1000000; int main(int argc, const char** argv) { printf("Benchmark: Allocate/free %d memory chunks (4-128 bytes)...\n", NUM_ALLOCS); fflush(stdout); double best_time = 1e9; const double start_t = get_time(); while (get_time() - start_t < BENCHMARK_TIME) { const double t0 = get_time(); void* addresses[NUM_ALLOCS]; for (int i = 0; i < NUM_ALLOCS; ++i) { const int memory_size = ((i % 32) + 1) * 4; addresses[i] = malloc(memory_size); ((char*)addresses[i])[0] = 1; } for (int i = 0; i < NUM_ALLOCS; ++i) { free(addresses[i]); } double dt = get_time() - t0; if (dt < best_time) { best_time = dt; } } printf("%f ns / alloc\n", (best_time / (double)NUM_ALLOCS) * 1000000000.0); fflush(stdout); return 0; }
#include "common/time.h" #include <stdio.h> #include <stdlib.h> static const double BENCHMARK_TIME = 5.0; #define NUM_ALLOCS 1000000 static void* s_addresses[NUM_ALLOCS]; int main(int argc, const char** argv) { printf("Benchmark: Allocate/free %d memory chunks (4-128 bytes)...\n", NUM_ALLOCS); fflush(stdout); double best_time = 1e9; const double start_t = get_time(); while (get_time() - start_t < BENCHMARK_TIME) { const double t0 = get_time(); for (int i = 0; i < NUM_ALLOCS; ++i) { const int memory_size = ((i % 32) + 1) * 4; s_addresses[i] = malloc(memory_size); ((char*)s_addresses[i])[0] = 1; } for (int i = 0; i < NUM_ALLOCS; ++i) { free(s_addresses[i]); } double dt = get_time() - t0; if (dt < best_time) { best_time = dt; } } printf("%f ns / alloc\n", (best_time / (double)NUM_ALLOCS) * 1000000000.0); fflush(stdout); return 0; }
Disable Ctrl-V (and Ctrl-O on macOS)
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> struct termios orig_termios; void disable_raw_mode() { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } void enable_raw_mode() { tcgetattr(STDIN_FILENO, &orig_termios); atexit(disable_raw_mode); struct termios raw = orig_termios; raw.c_iflag &= ~(IXON); raw.c_lflag &= ~(ECHO | ICANON | ISIG); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enable_raw_mode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') { if (iscntrl(c)) { printf("%d\n", c); } else { printf("%d ('%c')\n", c, c); } } return 0; }
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> struct termios orig_termios; void disable_raw_mode() { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } void enable_raw_mode() { tcgetattr(STDIN_FILENO, &orig_termios); atexit(disable_raw_mode); struct termios raw = orig_termios; raw.c_iflag &= ~(IXON); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enable_raw_mode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') { if (iscntrl(c)) { printf("%d\n", c); } else { printf("%d ('%c')\n", c, c); } } return 0; }
Add List Search function declaration
#include <stdlib.h> #ifndef __LIST_H__ #define __LIST_H__ struct ListNode; struct List; typedef struct ListNode ListNode; typedef struct List List; List* List_Create(void); void List_Destroy(List* l); ListNode* ListNode_Create(void *); void ListNode_Destroy(ListNode* n); #endif
#include <stdlib.h> #ifndef __LIST_H__ #define __LIST_H__ struct ListNode; struct List; typedef struct ListNode ListNode; typedef struct List List; List* List_Create(void); void List_Destroy(List* l); ListNode* ListNode_Create(void *); void ListNode_Destroy(ListNode* n); ListNode* List_Search(List* l, void* k, int f(void*, void*)); #endif
Debug check analysis for both sides.
#include <stdio.h> #include "forsyth.h" int main(int argc, char* argv[]) { FILE * stream; int FEN_status; if (argc < 2) FEN_status = load_FEN( "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" ); else FEN_status = load_FEN(argv[1]); #if defined(TEST_MATE_IN_ONE) memcpy(&square(a8), "nk....bq", 8); memcpy(&square(a7), "ppp.r...", 8); memcpy(&square(a6), "........", 8); memcpy(&square(a5), "........", 8); memcpy(&square(a4), "........", 8); memcpy(&square(a3), "........", 8); memcpy(&square(a2), "...R.PPP", 8); memcpy(&square(a1), "QB....KN", 8); #endif if (FEN_status != FEN_OK) { fprintf(stderr, "(%i): FEN record is corrupt!\n\n", FEN_status); return (FEN_status); } stream = (argc < 3) ? stdout : fopen(argv[2], "w"); load_Forsyth(stream); fclose(stream); return 0; }
#include <stdio.h> #include "forsyth.h" #include "check.h" int main(int argc, char* argv[]) { FILE * stream; int FEN_status; if (argc < 2) FEN_status = load_FEN( "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" ); else FEN_status = load_FEN(argv[1]); #if defined(TEST_MATE_IN_ONE) memcpy(&square(a8), "nk....bq", 8); memcpy(&square(a7), "ppp.r...", 8); memcpy(&square(a6), "........", 8); memcpy(&square(a5), "........", 8); memcpy(&square(a4), "........", 8); memcpy(&square(a3), "........", 8); memcpy(&square(a2), "...R.PPP", 8); memcpy(&square(a1), "QB....KN", 8); #endif if (FEN_status != FEN_OK) { fprintf(stderr, "(%i): FEN record is corrupt!\n\n", FEN_status); return (FEN_status); } stream = (argc < 3) ? stdout : fopen(argv[2], "w"); load_Forsyth(stream); fclose(stream); if (in_check(WHITE)) puts("White is in check."); if (in_check(BLACK)) puts("Black is in check."); return 0; }
Fix compilation on Linux / Windows
// This is a queue that can be accessed from multiple threads safely. // // It's not well optimized, and requires obtaining a lock every time you check for a new value. #pragma once #include <mutex> #include <optional> #include <queue> template <class T> class SynchronizedQueue { std::condition_variable cv_; std::mutex lock_; std::queue<T> q_; public: void push(T && t) { std::unique_lock l(lock_); q_.push(std::move(t)); cv_.notify_one(); } std::optional<T> get() { std::unique_lock l(lock_); if(q_.empty()) { return std::nullopt; } T t = std::move(q_.front()); q_.pop(); return t; } T get_blocking() { std::unique_lock l(lock_); while(q_.empty()) { cv_.wait(l); } T t = std::move(q_.front()); q_.pop(); return std::move(t); } };
// This is a queue that can be accessed from multiple threads safely. // // It's not well optimized, and requires obtaining a lock every time you check for a new value. #pragma once #include <condition_variable> #include <mutex> #include <optional> #include <queue> template <class T> class SynchronizedQueue { std::condition_variable cv_; std::mutex lock_; std::queue<T> q_; public: void push(T && t) { std::unique_lock l(lock_); q_.push(std::move(t)); cv_.notify_one(); } std::optional<T> get() { std::unique_lock l(lock_); if(q_.empty()) { return std::nullopt; } T t = std::move(q_.front()); q_.pop(); return t; } T get_blocking() { std::unique_lock l(lock_); while(q_.empty()) { cv_.wait(l); } T t = std::move(q_.front()); q_.pop(); return std::move(t); } };
Fix gcc global reg extension test to work.
#include <stdio.h> int c; __thread int d; register int R1 __asm__ ("%" "i5"); int main(void) { c = 3; R1 = 5; d = 4; printf("C: %d\n", c); printf("D: %d\n", d); printf("R1: %d\n", R1); R1 *= 2; printf("R1: %d\n", R1); return 0; }
#include <stdio.h> int c; __thread int d; register int R1 __asm__ ("%" "r15"); int main(void) { c = 3; R1 = 5; d = 4; printf("C: %d\n", c); printf("D: %d\n", d); printf("R1: %d\n", R1); R1 *= 2; printf("R1: %d\n", R1); return 0; }
Remove broken helper for message blocks
/* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012 Intel Corporation. All rights reserved. * * * 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. * * This program 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 General Public License for more details. * * 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 St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define COLOR_OFF "\x1B[0m" #define COLOR_BLUE "\x1B[0;34m" static inline void begin_message(void) { rl_message(""); printf("\r%*c\r", rl_end, ' '); } static inline void end_message(void) { rl_clear_message(); } void rl_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
/* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012 Intel Corporation. All rights reserved. * * * 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. * * This program 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 General Public License for more details. * * 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 St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define COLOR_OFF "\x1B[0m" #define COLOR_BLUE "\x1B[0;34m" void rl_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
Fix code in header documentation
#import <Foundation/Foundation.h> #import <Foundation/NSEnumerator.h> #import "BSNullabilityCompat.h" NS_ASSUME_NONNULL_BEGIN /** * A BSPropertySet represents the set of a Class' properties that will be injected into class instances after * the instances are created. * * If a */ @interface BSPropertySet : NSObject<NSFastEnumeration> /** * Returns a BSPropertySet for the given class, representing the properties named in the argument list. This * method is for use by classes within their implementation of bsProperties. * * For example, suppose there is a class that has a property called "eventLogger" of type EventLogger *. * * Suppose we want to inject two of the properties - address and color. We could implement bsProperties * like this: * * \code * * + (BSPropertySet *)bsProperties { * BSPropertySet *propertySet = [BSPropertySet propertySetWithClass:self propertyNames:@"address" @"color", nil]; * [propertySet bind:@"address" toKey:@"my home address" * * } * * \endcode */ + (BSPropertySet *)propertySetWithClass:(Class)owningClass propertyNames:(NSString *)property1, ... NS_REQUIRES_NIL_TERMINATION; - (void)bindProperty:(NSString *)propertyName toKey:(id)key; @end NS_ASSUME_NONNULL_END
#import <Foundation/Foundation.h> #import <Foundation/NSEnumerator.h> #import "BSNullabilityCompat.h" NS_ASSUME_NONNULL_BEGIN /** * A BSPropertySet represents the set of a Class' properties that will be injected into class instances after * the instances are created. * * If a */ @interface BSPropertySet : NSObject<NSFastEnumeration> /** * Returns a BSPropertySet for the given class, representing the properties named in the argument list. This * method is for use by classes within their implementation of bsProperties. * * For example, suppose there is a class that has a property called "eventLogger" of type EventLogger *. * * Suppose we want to inject two of the properties - address and color. We could implement bsProperties * like this: * * \code * * + (BSPropertySet *)bsProperties { * BSPropertySet *propertySet = [BSPropertySet propertySetWithClass:self propertyNames:@"address" @"color", nil]; * [propertySet bind:@"address" toKey:@"my home address"]; * return propertySet; * } * * \endcode */ + (BSPropertySet *)propertySetWithClass:(Class)owningClass propertyNames:(NSString *)property1, ... NS_REQUIRES_NIL_TERMINATION; - (void)bindProperty:(NSString *)propertyName toKey:(id)key; @end NS_ASSUME_NONNULL_END
Add missing header for printf
// Copyright(c) 2016 artopantone. // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once #include <kompositum/visitor.h> namespace Kompositum { class Printer : public Visitor { public: void visit(Leaf* leaf) override { doIndentation(); printf("- Leaf (%lu)\n", leaf->getID()); } void visit(Composite* composite) override { doIndentation(); indent++; if (!composite->hasChildren()) { printf("- Composite (%lu): empty\n", composite->getID()); } else { printf("+ Composite (%lu):\n", composite->getID()); composite->visitChildren(*this); } indent--; } private: void doIndentation() const { for (auto i = 0u; i < indent; ++i) printf("+--"); } unsigned int indent = 0; }; } // namespace Kompositum
// Copyright(c) 2016 artopantone. // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once #include <kompositum/visitor.h> #include <cstdio> namespace Kompositum { class Printer : public Visitor { public: void visit(Leaf* leaf) override { doIndentation(); printf("- Leaf (%lu)\n", leaf->getID()); } void visit(Composite* composite) override { doIndentation(); indent++; if (!composite->hasChildren()) { printf("- Composite (%lu): empty\n", composite->getID()); } else { printf("+ Composite (%lu):\n", composite->getID()); composite->visitChildren(*this); } indent--; } private: void doIndentation() const { for (auto i = 0u; i < indent; ++i) printf("+--"); } unsigned int indent = 0; }; } // namespace Kompositum
Change back to real-length pomodoros and breaks
// ---------------------------------------------------------------------------- // pomodoro_config - Defines the parameters for various pomodoro technique bits // Copyright (c) 2013 Jonathan Speicher (jon.speicher@gmail.com) // Licensed under the MIT license: http://opensource.org/licenses/MIT // ---------------------------------------------------------------------------- #pragma once // Defines the duration of a pomodoro. #define POMODORO_MINUTES 0 #define POMODORO_SECONDS 10 // Defines the duration of a break. #define BREAK_MINUTES 0 #define BREAK_SECONDS 5
// ---------------------------------------------------------------------------- // pomodoro_config - Defines the parameters for various pomodoro technique bits // Copyright (c) 2013 Jonathan Speicher (jon.speicher@gmail.com) // Licensed under the MIT license: http://opensource.org/licenses/MIT // ---------------------------------------------------------------------------- #pragma once // Defines the duration of a pomodoro. #define POMODORO_MINUTES 25 #define POMODORO_SECONDS 0 // Defines the duration of a break. #define BREAK_MINUTES 5 #define BREAK_SECONDS 0
Disable attempt to generate dictionary for private classes
#ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ function Roo* ; #pragma link C++ class RooLinkedList- ; #pragma link C++ class RooRealVar- ; #pragma link C++ class RooAbsBinning- ; #pragma link off class RooErrorHandler ; #pragma link C++ class RooRandomizeParamMCSModule::UniParam ; #pragma link C++ class RooRandomizeParamMCSModule::GausParam ; #endif
#ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ function Roo* ; #pragma link C++ class RooLinkedList- ; #pragma link C++ class RooRealVar- ; #pragma link C++ class RooAbsBinning- ; #pragma link off class RooErrorHandler ; #endif
Fix case sensitivity issue with the rename dialog
#pragma once #include <QtWidgets/QDialog> #include "binaryninjaapi.h" #include "uitypes.h" class BINARYNINJAUIAPI TextDialog: public QDialog { Q_OBJECT QWidget* m_parent; QString m_title; QString m_msg; QStringList m_options; Qt::WindowFlags m_flags; QString m_qSettingsListName; int m_historySize; QString m_historyEntry; QString m_initialText; public: TextDialog(QWidget* parent, const QString& title, const QString& msg, const QString& qSettingsListName, const std::string& initialText = ""); TextDialog(QWidget* parent, const QString& title, const QString& msg, const QString& qSettingsListName, const QString& initialText); QString getItem(bool& ok); void setInitialText(const std::string& initialText) { m_initialText = QString::fromStdString(initialText); } void commitHistory(); };
#pragma once #include <QtWidgets/QDialog> #include <QtWidgets/QComboBox> #include <QtWidgets/QLabel> #include "binaryninjaapi.h" #include "uitypes.h" #include "binaryninjaapi.h" class BINARYNINJAUIAPI TextDialog: public QDialog { Q_OBJECT QString m_qSettingsListName; int m_historySize; QString m_historyEntry; QString m_initialText; QStringList m_historyEntries; QLabel* m_messageText; QComboBox* m_combo; public: TextDialog(QWidget* parent, const QString& title, const QString& msg, const QString& qSettingsListName, const std::string& initialText = ""); TextDialog(QWidget* parent, const QString& title, const QString& msg, const QString& qSettingsListName, const QString& initialText); QString getItem(); void setInitialText(const std::string& initialText) { m_initialText = QString::fromStdString(initialText); } void commitHistory(); };
Add version number and get rid if a.out name.
typedef struct { int cluster; /* Condor Cluster # */ int proc; /* Condor Proc # */ int job_class; /* STANDARD, VANILLA, PVM, PIPE, ... */ uid_t uid; /* Execute job under this UID */ gid_t gid; /* Execute job under this pid */ pid_t virt_pid; /* PVM virt pid of this process */ int soft_kill_sig; /* Use this signal for a soft kill */ char *a_out_name; /* Where to get executable file */ char *cmd; /* Command name given by the user */ char *args; /* Command arguments given by the user */ char *env; /* Environment variables */ char *iwd; /* Initial working directory */ BOOLEAN ckpt_wanted; /* Whether user wants checkpointing */ BOOLEAN is_restart; /* Whether this run is a restart */ BOOLEAN coredump_limit_exists; /* Whether user wants to limit core size */ int coredump_limit; /* Limit in bytes */ } STARTUP_INFO; /* Should eliminate starter knowing the a.out name. Should go to shadow for instructions on how to fetch the executable - e.g. local file with name <name> or get it from TCP port <x> on machine <y>. */
typedef struct { int version_num; /* version of this structure */ int cluster; /* Condor Cluster # */ int proc; /* Condor Proc # */ int job_class; /* STANDARD, VANILLA, PVM, PIPE, ... */ uid_t uid; /* Execute job under this UID */ gid_t gid; /* Execute job under this gid */ pid_t virt_pid; /* PVM virt pid of this process */ int soft_kill_sig; /* Use this signal for a soft kill */ char *cmd; /* Command name given by the user */ char *args; /* Command arguments given by the user */ char *env; /* Environment variables */ char *iwd; /* Initial working directory */ BOOLEAN ckpt_wanted; /* Whether user wants checkpointing */ BOOLEAN is_restart; /* Whether this run is a restart */ BOOLEAN coredump_limit_exists; /* Whether user wants to limit core size */ int coredump_limit; /* Limit in bytes */ } STARTUP_INFO; #define STARTUP_VERSION 1 /* Should eliminate starter knowing the a.out name. Should go to shadow for instructions on how to fetch the executable - e.g. local file with name <name> or get it from TCP port <x> on machine <y>. */
Add header file with declarations for NT timers
#pragma once #include <minwindef.h> //#include <ntstatus.h> // Can't include ntdef.h because it clashes with winnt.h //#include <ntdef.h> typedef _Return_type_success_(return >= 0) LONG NTSTATUS; typedef void* POBJECT_ATTRIBUTES; typedef enum _TIMER_TYPE { NotificationTimer, SynchronizationTimer } TIMER_TYPE; #pragma comment(lib, "ntdll.lib") extern "C" { NTSYSAPI NTSTATUS NTAPI NtCancelTimer( IN HANDLE TimerHandle, OUT PBOOLEAN CurrentState OPTIONAL); NTSYSAPI NTSTATUS NTAPI NtCreateTimer( OUT PHANDLE TimerHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN TIMER_TYPE TimerType); typedef void(CALLBACK * PTIMER_APC_ROUTINE)( IN PVOID TimerContext, IN ULONG TimerLowValue, IN LONG TimerHighValue ); NTSYSAPI NTSTATUS NTAPI NtSetTimer( IN HANDLE TimerHandle, IN PLARGE_INTEGER DueTime, IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL, IN PVOID TimerContext OPTIONAL, IN BOOLEAN ResumeTimer, IN LONG Period OPTIONAL, OUT PBOOLEAN PreviousState OPTIONAL); NTSYSAPI NTSTATUS NTAPI NtSetTimerResolution( IN ULONG RequestedResolution, IN BOOLEAN Set, OUT PULONG ActualResolution ); NTSYSAPI NTSTATUS NTAPI NtQueryTimerResolution( OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG ActualResolution ); }
Enable to replace "new" operator
#if defined(_MSC_VER) && !defined(NDEBUG) && defined(_CRTDBG_MAP_ALLOC) && !defined(MSVCDBG_H) #define MSVCDBG_H /*! * @file msvcdbg.h * @brief Memory debugger for msvc * @author koturn */ #include <crtdbg.h> static void __msvc_init_memory_check__(void); #pragma section(".CRT$XCU", read) __declspec(allocate(".CRT$XCU")) void (* __msvc_init_memory_check___)(void) = __msvc_init_memory_check__; /*! * @brief Enable heap management */ static void __msvc_init_memory_check__(void) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_DELAY_FREE_MEM_DF); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); } #endif
#if defined(_MSC_VER) && !defined(NDEBUG) && defined(_CRTDBG_MAP_ALLOC) && !defined(MSVCDBG_H) #define MSVCDBG_H /*! * @file msvcdbg.h * @brief Memory debugger for msvc * @author koturn */ #include <crtdbg.h> #define MSVCDBG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #ifdef MSVCDBG_REPLACE_NEW # define new MSVCDBG_NEW #endif static void __msvc_init_memory_check__(void); #pragma section(".CRT$XCU", read) __declspec(allocate(".CRT$XCU")) void (* __msvc_init_memory_check___)(void) = __msvc_init_memory_check__; /*! * @brief Enable heap management */ static void __msvc_init_memory_check__(void) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_DELAY_FREE_MEM_DF); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); } #endif
Use Q_SIGNALS / Q_EMIT macros instead of signals / emit
#pragma once #include <QtWidgets/QLabel> class BINARYNINJAUIAPI ClickableLabel: public QLabel { Q_OBJECT public: ClickableLabel(QWidget* parent = nullptr, const QString& name = ""): QLabel(parent) { setText(name); } signals: void clicked(); protected: void mouseReleaseEvent(QMouseEvent* event) override { if (event->button() == Qt::LeftButton) emit clicked(); } };
#pragma once #include <QtWidgets/QLabel> class BINARYNINJAUIAPI ClickableLabel: public QLabel { Q_OBJECT public: ClickableLabel(QWidget* parent = nullptr, const QString& name = ""): QLabel(parent) { setText(name); } Q_SIGNALS: void clicked(); protected: void mouseReleaseEvent(QMouseEvent* event) override { if (event->button() == Qt::LeftButton) Q_EMIT clicked(); } };
Convert the embedded test to the bitmap API
#include <hwloc.h> #include <stdio.h> /* The body of the test is in a separate .c file and a separate library, just to ensure that hwloc didn't force compilation with visibility flags enabled. */ int do_test(void) { mytest_hwloc_topology_t topology; unsigned depth; hwloc_cpuset_t cpu_set; /* Just call a bunch of functions to see if we can link and run */ printf("*** Test 1: cpuset alloc\n"); cpu_set = mytest_hwloc_cpuset_alloc(); if (NULL == cpu_set) return 1; printf("*** Test 2: topology init\n"); if (0 != mytest_hwloc_topology_init(&topology)) return 1; printf("*** Test 3: topology load\n"); if (0 != mytest_hwloc_topology_load(topology)) return 1; printf("*** Test 4: topology get depth\n"); depth = mytest_hwloc_topology_get_depth(topology); if (depth < 0) return 1; printf(" Max depth: %u\n", depth); printf("*** Test 5: topology destroy\n"); mytest_hwloc_topology_destroy(topology); printf("*** Test 6: cpuset free\n"); mytest_hwloc_cpuset_free(cpu_set); return 0; }
#include <hwloc.h> #include <stdio.h> /* The body of the test is in a separate .c file and a separate library, just to ensure that hwloc didn't force compilation with visibility flags enabled. */ int do_test(void) { mytest_hwloc_topology_t topology; unsigned depth; hwloc_bitmap_t cpu_set; /* Just call a bunch of functions to see if we can link and run */ printf("*** Test 1: bitmap alloc\n"); cpu_set = mytest_hwloc_bitmap_alloc(); if (NULL == cpu_set) return 1; printf("*** Test 2: topology init\n"); if (0 != mytest_hwloc_topology_init(&topology)) return 1; printf("*** Test 3: topology load\n"); if (0 != mytest_hwloc_topology_load(topology)) return 1; printf("*** Test 4: topology get depth\n"); depth = mytest_hwloc_topology_get_depth(topology); if (depth < 0) return 1; printf(" Max depth: %u\n", depth); printf("*** Test 5: topology destroy\n"); mytest_hwloc_topology_destroy(topology); printf("*** Test 6: bitmap free\n"); mytest_hwloc_bitmap_free(cpu_set); return 0; }
Remove some unused classes and methods.
/* Copyright (c) 2009 Stephen Kelly <steveire@gmail.com> */ #ifndef PARSER_H #define PARSER_H #include <QStringList> #include "token.h" #include "node.h" namespace Grantlee { class AbstractNodeFactory; class TagLibraryInterface; class Filter; } class ParserPrivate; namespace Grantlee { class GRANTLEE_EXPORT Parser : public QObject { Q_OBJECT public: Parser( QList<Token> tokenList, QStringList pluginDirs, QObject *parent ); ~Parser(); NodeList parse(QStringList stopAt, QObject *parent); NodeList parse(QObject *parent); Filter *getFilter(const QString &name); void skipPast(const QString &tag); Token nextToken(); bool hasNextToken(); void loadLib(const QString &name); void emitError(int errorNumber, const QString &message); protected: void addTag(QObject *); void getBuiltInLibrary(); void getDefaultLibrary(); void prependToken(Token token); signals: void error(int type, const QString &message); private: Q_DECLARE_PRIVATE(Parser); ParserPrivate *d_ptr; }; } #endif
/* Copyright (c) 2009 Stephen Kelly <steveire@gmail.com> */ #ifndef PARSER_H #define PARSER_H #include <QStringList> #include "token.h" #include "node.h" namespace Grantlee { class Filter; } class ParserPrivate; namespace Grantlee { class GRANTLEE_EXPORT Parser : public QObject { Q_OBJECT public: Parser( QList<Token> tokenList, QStringList pluginDirs, QObject *parent ); ~Parser(); NodeList parse(QStringList stopAt, QObject *parent); NodeList parse(QObject *parent); Filter *getFilter(const QString &name); void skipPast(const QString &tag); Token nextToken(); bool hasNextToken(); void loadLib(const QString &name); void emitError(int errorNumber, const QString &message); protected: void prependToken(Token token); signals: void error(int type, const QString &message); private: Q_DECLARE_PRIVATE(Parser); ParserPrivate *d_ptr; }; } #endif
Add missing file needed for arm to compile
/* Wrapper around clone system call. Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <errno.h> /* This routine is jumped to by all the syscall handlers, to stash * an error number into errno. */ int attribute_hidden __syscall_error (int err_no) { __set_errno (err_no); return -1; }
Fix warning of non-virtual destructor
#ifndef FORMAT_H #define FORMAT_H #include <cstddef> #include <cstring> // memmove class Format { public: Format(void *p, size_t s = 0) : fp((char *)p), size(s) {}; virtual size_t Leanify(size_t size_leanified = 0) { if (size_leanified) { memmove(fp - size_leanified, fp, size); fp -= size_leanified; } return size; } protected: // pointer to the file content char *fp; // size of the file size_t size; }; #endif
#ifndef FORMAT_H #define FORMAT_H #include <cstddef> #include <cstring> // memmove class Format { public: Format(void *p, size_t s = 0) : fp((char *)p), size(s) {}; virtual ~Format() {}; virtual size_t Leanify(size_t size_leanified = 0) { if (size_leanified) { memmove(fp - size_leanified, fp, size); fp -= size_leanified; } return size; } protected: // pointer to the file content char *fp; // size of the file size_t size; }; #endif
Add newline at the end of the file.
/******************************************************************** * * * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * * by the Xiph.Org Foundation http://www.xiph.org/ * * * ******************************************************************** function: last mod: $Id: toplevel.h,v 1.1 2003/06/04 01:31:46 mauricio Exp $ ********************************************************************/ /*from dbm huffman pack patch*/ extern void write_Qtables(oggpack_buffer* opb); extern void write_HuffmanSet(oggpack_buffer* opb, HUFF_ENTRY **hroot); extern void read_Qtables(oggpack_buffer* opb); extern void read_HuffmanSet(oggpack_buffer* opb); extern void InitHuffmanSetPlay( PB_INSTANCE *pbi );
/******************************************************************** * * * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * * by the Xiph.Org Foundation http://www.xiph.org/ * * * ******************************************************************** function: last mod: $Id: toplevel.h,v 1.2 2003/06/07 23:34:56 giles Exp $ ********************************************************************/ /*from dbm huffman pack patch*/ extern void write_Qtables(oggpack_buffer* opb); extern void write_HuffmanSet(oggpack_buffer* opb, HUFF_ENTRY **hroot); extern void read_Qtables(oggpack_buffer* opb); extern void read_HuffmanSet(oggpack_buffer* opb); extern void InitHuffmanSetPlay( PB_INSTANCE *pbi );
Add new abstract animation class
#pragma once #include "MeterWnd.h" class Animation { public: Animation(MeterWnd &meterWnd) : _meterWnd(meterWnd) { } virtual bool Animate() = 0; virtual void Reset() = 0; protected: MeterWnd &_meterWnd; };
Use pragma once instead of ifdef
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
#pragma once #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; };
Add HW_LED_STATUS pin to Zero 2W board
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Zero 2W" #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO14) #define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO15)
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Zero 2W" #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) #define MICROPY_HW_LED_STATUS (&pin_GPIO29) #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO14) #define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO15)
Add header guards. Properly name function.
#include "kputs.c" void abort(void) { // TODO: Add proper kernel panic. kputs("Kernel Panic! abort()\n"); while ( 1 ) { } }
#ifndef KABORT_C #define KABORT_C #include "kputs.c" void kabort(void) { // TODO: Add proper kernel panic. kputs("Kernel Panic! abort()\n"); while ( 1 ) { } } #endif
Add GCC diagnostic warning macros
/************************************************************************** * * Copyright 2013-2014 RAD Game Tools and Valve Software * All Rights Reserved. * * 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. * **************************************************************************/ #if defined(__GNUC__) #define GCC_DIAGNOSTIC_STR(s) #s #define GCC_DIAGNOSTIC_JOINSTR(x,y) GCC_DIAGNOSTIC_STR(x ## y) #define GCC_DIAGNOSTIC_DO_PRAGMA(x) _Pragma (#x) #define GCC_DIAGNOSTIC_PRAGMA(x) GCC_DIAGNOSTIC_DO_PRAGMA(GCC diagnostic x) #define GCC_DIAGNOSTIC_PUSH() GCC_DIAGNOSTIC_PRAGMA(push) #define GCC_DIAGNOSTIC_IGNORED(x) GCC_DIAGNOSTIC_PRAGMA(ignored GCC_DIAGNOSTIC_JOINSTR(-W,x)) #define GCC_DIAGNOSTIC_POP() GCC_DIAGNOSTIC_PRAGMA(pop) #else #define GCC_DIAGNOSTIC_PUSH() #define GCC_DIAGNOSTIC_IGNORED(x) #define GCC_DIAGNOSTIC_POP() #endif
Fix format ptr from unsigned int to unsigned long
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* replace_format_ptr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jlagneau <jlagneau@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/04/19 10:28:27 by jlagneau #+# #+# */ /* Updated: 2017/04/19 10:32:52 by jlagneau ### ########.fr */ /* */ /* ************************************************************************** */ #include <libft.h> #include <ft_printf.h> int replace_format_ptr(char *format, char *pos, va_list ap) { int ret; char *tmp; char *data; tmp = NULL; if (!(tmp = ft_itoa_base(va_arg(ap, unsigned int), BASE_HEX_LOWER))) return (-1); if (ft_strcmp(tmp, "0") == 0) data = ft_strdup("(nil)"); else data = ft_strjoin("0x", tmp); ret = replace_format(format, data, pos, 2); ft_strdel(&data); ft_strdel(&tmp); return (ret); }
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* replace_format_ptr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jlagneau <jlagneau@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/04/19 10:28:27 by jlagneau #+# #+# */ /* Updated: 2017/04/19 12:10:38 by jlagneau ### ########.fr */ /* */ /* ************************************************************************** */ #include <libft.h> #include <ft_printf.h> int replace_format_ptr(char *format, char *pos, va_list ap) { int ret; char *tmp; char *data; tmp = NULL; if (!(tmp = ft_ltoa_base(va_arg(ap, unsigned long), BASE_HEX_LOWER))) return (-1); if (ft_strcmp(tmp, "0") == 0) data = ft_strdup("(nil)"); else data = ft_strjoin("0x", tmp); ret = replace_format(format, data, pos, 2); ft_strdel(&data); ft_strdel(&tmp); return (ret); }
Update lab3 skeleton code to properly source ACLK from VLO
/* Based on msp430g2xx3_wdt_02.c from the TI Examples */ #include <msp430.h> int main(void) { WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer IE1 |= WDTIE; // Enable WDT interrupt P1DIR |= BIT0; // Set P1.0 to output direction __bis_SR_register(GIE); // Enable interrupts while (1) { __bis_SR_register(LPM3_bits); // Enter LPM3 w/interrupt P1OUT ^= BIT0; } } // Watchdog Timer interrupt service routine #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void) #else #error Compiler not supported! #endif { __bic_SR_register_on_exit(LPM3_bits); }
/* Based on msp430g2xx3_wdt_02.c from the TI Examples */ #include <msp430.h> int main(void) { BCSCTL3 |= LFXT1S_2; // ACLK = VLO WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer IE1 |= WDTIE; // Enable WDT interrupt P1DIR |= BIT0; // Set P1.0 to output direction __bis_SR_register(GIE); // Enable interrupts while (1) { __bis_SR_register(LPM3_bits); // Enter LPM3 w/interrupt P1OUT ^= BIT0; } } // Watchdog Timer interrupt service routine #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void) #else #error Compiler not supported! #endif { __bic_SR_register_on_exit(LPM3_bits); }
Define convenient ISR function pointer type
#pragma once extern void _service_interrupt(void); extern void isr0(void); extern void isr1(void); extern void isr2(void); extern void isr3(void); extern void isr4(void); extern void isr5(void); extern void isr6(void); extern void isr7(void); extern void isr8(void); extern void isr9(void); extern void isr10(void); extern void isr11(void); extern void isr12(void); extern void isr13(void); extern void isr14(void); extern void isr15(void); extern void isr16(void); extern void isr17(void); extern void isr18(void); extern void isr19(void); extern void isr20(void); extern void isr21(void); extern void isr22(void); extern void isr23(void); extern void isr24(void); extern void isr25(void); extern void isr26(void); extern void isr27(void); extern void isr28(void); extern void isr29(void); extern void isr30(void); extern void isr31(void); extern void isr32(void); extern void isr33(void); extern void isr34(void);
#pragma once extern void _service_interrupt(void); typedef void (*isr_f)(void); extern void isr0(void); extern void isr1(void); extern void isr2(void); extern void isr3(void); extern void isr4(void); extern void isr5(void); extern void isr6(void); extern void isr7(void); extern void isr8(void); extern void isr9(void); extern void isr10(void); extern void isr11(void); extern void isr12(void); extern void isr13(void); extern void isr14(void); extern void isr15(void); extern void isr16(void); extern void isr17(void); extern void isr18(void); extern void isr19(void); extern void isr20(void); extern void isr21(void); extern void isr22(void); extern void isr23(void); extern void isr24(void); extern void isr25(void); extern void isr26(void); extern void isr27(void); extern void isr28(void); extern void isr29(void); extern void isr30(void); extern void isr31(void); extern void isr32(void); extern void isr33(void); extern void isr34(void);
Make function parameter names consistent between header and impl.
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_TFG_PASSES_BUILDER_H_ #define TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_TFG_PASSES_BUILDER_H_ #include "mlir/Pass/PassManager.h" // from @llvm-project namespace mlir { namespace tfg { // Constructs the default graph/function-level TFG pass pipeline. void DefaultGrapplerPipeline(PassManager& mgr); // Constructs the default module-level TFG pass pipeline. void DefaultModuleGrapplerPipeline(PassManager& mgr); // Add a remapper pass to the given pass manager. void RemapperPassBuilder(PassManager& mgr); } // namespace tfg } // namespace mlir #endif // TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_TFG_PASSES_BUILDER_H_
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_TFG_PASSES_BUILDER_H_ #define TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_TFG_PASSES_BUILDER_H_ #include "mlir/Pass/PassManager.h" // from @llvm-project namespace mlir { namespace tfg { // Constructs the default graph/function-level TFG pass pipeline. void DefaultGrapplerPipeline(PassManager& manager); // Constructs the default module-level TFG pass pipeline. void DefaultModuleGrapplerPipeline(PassManager& manager); // Add a remapper pass to the given pass manager. void RemapperPassBuilder(PassManager& manager); } // namespace tfg } // namespace mlir #endif // TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_TFG_PASSES_BUILDER_H_
Add buffer overflow safety to CDISPLAY
#pragma once #include <sched.h> /* sched_getcpu() */ #include <stdio.h> /* printf() */ /** ************************************************************************** * \brief * preprocessor conditional printf formatter output * * \details * Input arguments are equivalent to printf. referrence printf man pages * for api details * ************************************************************************** */ #if defined(__ADTS_DISPLAY) #define CDISPLAY(_format, ...) \ do { \ char _buffer[256] = {0}; \ \ sprintf(_buffer, _format, ## __VA_ARGS__); \ printf("%3d %4d %-25.25s %-30.30s %s\n", \ sched_getcpu(), __LINE__, __FILE__, __FUNCTION__, _buffer); \ \ /* Serialize console output on exit/error */ \ fflush(stdout); \ } while(0); #else #define CDISPLAY(_format, ...) /* compile disabled */ #endif /** ************************************************************************** * \details * Count digits in decimal number * ************************************************************************** */ inline size_t adts_digits_decimal( int32_t val ) { size_t digits = 0; while (val) { val /= 10; digits++; } return digits; } /* adts_digits_decimal() */
#pragma once #include <sched.h> /* sched_getcpu() */ #include <stdio.h> /* printf() */ /** ************************************************************************** * \brief * preprocessor conditional printf formatter output * * \details * Input arguments are equivalent to printf. referrence printf man pages * for api details * ************************************************************************** */ #if defined(__ADTS_DISPLAY) #define CDISPLAY(_format, ...) \ do { \ char _buffer[256] = {0}; \ size_t _limit = sizeof(_buffer) - 1; \ \ snprintf(_buffer, _limit, _format, ## __VA_ARGS__); \ printf("%3d %4d %-25.25s %-30.30s %s\n", \ sched_getcpu(), __LINE__, __FILE__, __FUNCTION__, _buffer); \ \ /* Serialize console output on exit/error */ \ fflush(stdout); \ } while(0); #else #define CDISPLAY(_format, ...) /* compile disabled */ #endif /** ************************************************************************** * \details * Count digits in decimal number * ************************************************************************** */ inline size_t adts_digits_decimal( int32_t val ) { size_t digits = 0; while (val) { val /= 10; digits++; } return digits; } /* adts_digits_decimal() */
Add line break after import
#import <Foundation/Foundation.h> #define API_VERSION "1" #define BASE_URL "https://www.cine.io/api/" #define SDK_VERSION "0.6.1" #define USER_AGENT "cineio-ios" extern NSString* const BaseUrl; extern NSString* const UserAgent;
#import <Foundation/Foundation.h> #define API_VERSION "1" #define BASE_URL "https://www.cine.io/api/" #define SDK_VERSION "0.6.1" #define USER_AGENT "cineio-ios" extern NSString* const BaseUrl; extern NSString* const UserAgent;