Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Change buffer sizes to ease stk5.
#include "../../include/mid.h" #include <SDL/SDL_error.h> #include <stdarg.h> #include <errno.h> #include <string.h> enum { Bufsz = 1024 }; static char curerr[Bufsz + 1]; void seterrstr(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vsnprintf(curerr, Bufsz + 1, fmt, ap); va_end(ap); } const char *miderrstr(void){ int err = errno; if (curerr[0] != '\0') { static char retbuf[Bufsz + 1]; strncpy(retbuf, curerr, Bufsz); retbuf[Bufsz] = '\0'; curerr[0] = '\0'; return retbuf; } const char *e = SDL_GetError(); if(e[0] != '\0') return e; return strerror(err); }
#include "../../include/mid.h" #include <SDL/SDL_error.h> #include <stdarg.h> #include <errno.h> #include <string.h> enum { Bufsz = 1024 }; static char curerr[Bufsz]; void seterrstr(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vsnprintf(curerr, Bufsz, fmt, ap); va_end(ap); } const char *miderrstr(void){ int err = errno; if (curerr[0] != '\0') { static char retbuf[Bufsz]; strncpy(retbuf, curerr, Bufsz - 1); retbuf[Bufsz - 1] = '\0'; curerr[0] = '\0'; return retbuf; } const char *e = SDL_GetError(); if(e[0] != '\0') return e; return strerror(err); }
Add an explanation for graphics_*_draw prototype
#ifndef __GRAPHICS_TB_H__ #define __GRAPHICS_TB_H__ #include <termbox.h> #include "models.h" #include "graphics.h" typedef struct {} graphics_tb_t; // graphics_tb initialize the graphic module. graphics_tb_t *graphics_tb_init(); // graphics_tb_draw draws the given state on the screen. void graphics_tb_draw(void *context, state_to_draw_t *state); // graphics_tb_quit terminate the graphic module. void graphics_tb_quit(graphics_tb_t *tg); #endif
#ifndef __GRAPHICS_TB_H__ #define __GRAPHICS_TB_H__ #include <termbox.h> #include "models.h" #include "graphics.h" typedef struct {} graphics_tb_t; // graphics_tb initializes the graphic module. graphics_tb_t *graphics_tb_init(); // graphics_tb_draw draws the given state on the screen. // // We do not use `graphics_tb_t *tg` but `void *context` because this function // is used as a callback and the caller shouldn't have to know about // graphics_tb. This way, this module is pluggable. void graphics_tb_draw(void *context, state_to_draw_t *state); // graphics_tb_quit terminates the graphic module. void graphics_tb_quit(graphics_tb_t *tg); #endif
Include configured padding in offset calculation.
// Copyright 2017, Jeffrey E. Bedard #include "text_widget.h" #include "XSTextWidget.h" #include "font.h" #include "xdata.h" short xstatus_draw_text_widget(struct XSTextWidget * widget) { xcb_connection_t * xc = widget->connection; struct JBDim font_size = xstatus_get_font_size(); xcb_image_text_8(xc, widget->buffer_size, xstatus_get_window(xc), xstatus_get_gc(xc), widget->offset, font_size.height, widget->buffer); return widget->offset + font_size.width * widget->buffer_size; }
// Copyright 2017, Jeffrey E. Bedard #include "text_widget.h" #include "XSTextWidget.h" #include "config.h" #include "font.h" #include "xdata.h" short xstatus_draw_text_widget(struct XSTextWidget * widget) { xcb_connection_t * xc = widget->connection; struct JBDim font_size = xstatus_get_font_size(); xcb_image_text_8(xc, widget->buffer_size, xstatus_get_window(xc), xstatus_get_gc(xc), widget->offset, font_size.height, widget->buffer); return widget->offset + font_size.width * widget->buffer_size + XSTATUS_CONST_PAD; }
Revert "Handle MSVC's definition of __cplusplus"
/* * Copyright 2018 NVIDIA Corporation * * 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. */ #pragma once #ifdef _MSC_VER #define THRUST_CPP_VER _MSVC_LANG #else #define THRUST_CPP_VER __cplusplus #endif #if THRUST_CPP_VER < 201103L #define THRUST_CPP03 #define THRUST_CPP_DIALECT 2003 #elif THRUST_CPP_VER < 201402L #define THRUST_CPP11 #define THRUST_CPP_DIALECT 2011 #elif THRUST_CPP_VER < 201703L #define THRUST_CPP14 #define THRUST_CPP_DIALECT 2014 #else #define THRUST_CPP17 #define THRUST_CPP_DIALECT 2017 #endif #undef THRUST_CPP_VER
/* * Copyright 2018 NVIDIA Corporation * * 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. */ #pragma once #if __cplusplus < 201103L #define THRUST_CPP03 #define THRUST_CPP_DIALECT 2003 #elif __cplusplus < 201402L #define THRUST_CPP11 #define THRUST_CPP_DIALECT 2011 #elif __cplusplus < 201703L #define THRUST_CPP14 #define THRUST_CPP_DIALECT 2014 #else #define THRUST_CPP17 #define THRUST_CPP_DIALECT 2017 #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 prototypes for no longer existing functions
/* * $Id$ */ #include "common.h" #include "miniobj.h" extern struct evbase *mgt_evb; /* mgt_child.c */ void mgt_run(int dflag); void mgt_start_child(void); void mgt_stop_child(void); extern pid_t mgt_pid, child_pid; /* mgt_cli.c */ void mgt_cli_init(void); void mgt_cli_setup(int fdi, int fdo, int verbose); int mgt_cli_askchild(int *status, char **resp, const char *fmt, ...); void mgt_cli_start_child(int fdi, int fdo); void mgt_cli_stop_child(void); /* mgt_vcc.c */ void mgt_vcc_init(void); int mgt_vcc_default(const char *bflag, const char *fflag); int mgt_push_vcls_and_start(int *status, char **p); /* tcp.c */ int open_tcp(const char *port); #include "stevedore.h" extern struct stevedore sma_stevedore; extern struct stevedore smf_stevedore; #include "hash_slinger.h" extern struct hash_slinger hsl_slinger; extern struct hash_slinger hcl_slinger;
/* * $Id$ */ #include "common.h" #include "miniobj.h" extern struct evbase *mgt_evb; /* mgt_child.c */ void mgt_run(int dflag); extern pid_t mgt_pid, child_pid; /* mgt_cli.c */ void mgt_cli_init(void); void mgt_cli_setup(int fdi, int fdo, int verbose); int mgt_cli_askchild(int *status, char **resp, const char *fmt, ...); void mgt_cli_start_child(int fdi, int fdo); void mgt_cli_stop_child(void); /* mgt_vcc.c */ void mgt_vcc_init(void); int mgt_vcc_default(const char *bflag, const char *fflag); int mgt_push_vcls_and_start(int *status, char **p); /* tcp.c */ int open_tcp(const char *port); #include "stevedore.h" extern struct stevedore sma_stevedore; extern struct stevedore smf_stevedore; #include "hash_slinger.h" extern struct hash_slinger hsl_slinger; extern struct hash_slinger hcl_slinger;
Switch version numbers to 0.8.1.99
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 1 #define CLIENT_VERSION_BUILD 99 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE false // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
Fix conditional compilation mechanism for ios
#import "CoreDataAdditions/NSManagedObject+TDTAdditions.h" #import "CoreDataAdditions/NSManagedObjectContext+TDTAdditions.h" #import "CoreDataAdditions/TDTCoreDataUtilityMacros.h" #ifdef TARGET_IPHONE_OS #import "CoreDataAdditions/NSFetchedResultsController+TDTAdditions.h" #endif
#import "CoreDataAdditions/NSManagedObject+TDTAdditions.h" #import "CoreDataAdditions/NSManagedObjectContext+TDTAdditions.h" #import "CoreDataAdditions/TDTCoreDataUtilityMacros.h" #import "TargetConditionals.h" #if TARGET_OS_IPHONE #import "CoreDataAdditions/NSFetchedResultsController+TDTAdditions.h" #endif
Add stubs for fp 16.16 handling rountines.
#ifndef __STD_FP16_H__ #define __STD_FP16_H__ typedef struct { int16_t integer; uint16_t fraction; } Q16T; void CastFloatQ16(Q16T *result asm("a0"), float value asm("fp0")); void CastIntQ16(Q16T *result asm("a0"), int value asm("d0")); void IAddQ16(Q16T *result asm("a0"), Q16T value asm("d0")); #endif
Move unknown enum entry to top.
#import <WebKit/WebKit.h> typedef NS_ENUM (NSInteger, WMFWKScriptMessageType) { WMFWKScriptMessagePeek, WMFWKScriptMessageConsoleMessage, WMFWKScriptMessageClickLink, WMFWKScriptMessageClickImage, WMFWKScriptMessageClickReference, WMFWKScriptMessageClickEdit, WMFWKScriptMessageNonAnchorTouchEndedWithoutDragging, WMFWKScriptMessageLateJavascriptTransform, WMFWKScriptMessageArticleState, WMFWKScriptMessageUnknown }; @interface WKScriptMessage (WMFScriptMessage) + (WMFWKScriptMessageType)wmf_typeForMessageName:(NSString*)name; + (Class)wmf_expectedMessageBodyClassForType:(WMFWKScriptMessageType)type; @end
#import <WebKit/WebKit.h> typedef NS_ENUM (NSInteger, WMFWKScriptMessageType) { WMFWKScriptMessageUnknown, WMFWKScriptMessagePeek, WMFWKScriptMessageConsoleMessage, WMFWKScriptMessageClickLink, WMFWKScriptMessageClickImage, WMFWKScriptMessageClickReference, WMFWKScriptMessageClickEdit, WMFWKScriptMessageNonAnchorTouchEndedWithoutDragging, WMFWKScriptMessageLateJavascriptTransform, WMFWKScriptMessageArticleState }; @interface WKScriptMessage (WMFScriptMessage) + (WMFWKScriptMessageType)wmf_typeForMessageName:(NSString*)name; + (Class)wmf_expectedMessageBodyClassForType:(WMFWKScriptMessageType)type; @end
Add a (broken) test for consume-style things where we compare the pointer.
#define REQUIRE_EXPLICIT_ATOMICS 1 #include "rmc.h" int foo; // LLVM will want to propagate the knowledge that p == &foo into the // conditional, breaking our chain. We need to make sure that doesn't // happen. The optimization is performed by -gvn. int test(_Rmc(int *)* pp) { XEDGE(a, b); int *p = L(a, rmc_load(pp)); if (p == &foo) { return L(b, *p); } return -1; }
Remove usage of non standard identity struct
/** ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** * Copyright 2017 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** */ #ifndef XENIA_BASE_BIT_FIELD_H_ #define XENIA_BASE_BIT_FIELD_H_ #include <cstdint> #include <cstdlib> #include <type_traits> namespace xe { // Bitfield, where position starts at the LSB. template <typename T, size_t position, size_t n_bits> struct bf { bf() = default; inline operator T() const { return value(); } inline T value() const { return static_cast<T>((storage & mask()) >> position); } // For enum values, we strip them down to an underlying type. typedef typename std::conditional<std::is_enum<T>::value, std::underlying_type<T>, std::identity<T>>::type::type value_type; inline value_type mask() const { return (((value_type)~0) >> (8 * sizeof(value_type) - n_bits)) << position; } value_type storage; }; } // namespace xe #endif // XENIA_BASE_BIT_FIELD_H_
/** ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** * Copyright 2017 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** */ #ifndef XENIA_BASE_BIT_FIELD_H_ #define XENIA_BASE_BIT_FIELD_H_ #include <cstdint> #include <cstdlib> #include <type_traits> namespace xe { // Bitfield, where position starts at the LSB. template <typename T, size_t position, size_t n_bits> struct bf { bf() = default; inline operator T() const { return value(); } inline T value() const { return static_cast<T>((storage & mask()) >> position); } // For enum values, we strip them down to an underlying type. typedef typename std::conditional<std::is_enum<T>::value, std::underlying_type<T>, std::remove_reference<T>>::type::type value_type; inline value_type mask() const { return (((value_type)~0) >> (8 * sizeof(value_type) - n_bits)) << position; } value_type storage; }; } // namespace xe #endif // XENIA_BASE_BIT_FIELD_H_
Set LC_ALL to UTF-8 so that SSH is clean.
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pwd.h> int main(int argc, char** argv) { struct passwd *passwd = getpwuid(getuid()); int errno = setreuid(geteuid(), geteuid()); // errno = execle("/usr/bin/id", (char *) 0, envp); if (errno == 0 && passwd != 0) { // CHECKIT_USER will contain the name of the user that invoked us. char user_evar[100]; snprintf(user_evar, 80, "CHECKIT_USER=%s", passwd->pw_name); // Use a nice clean PATH. char * envp[] = { "PATH=/bin:/usr/bin" , "HOME=/home2/ling572_00" , "JAVA_HOME=/usr/java/latest" , "JAVA_OPTS=-Xmx300m -Xms140m" , user_evar , (char *) 0 }; // Do it! errno = execve("/home2/ling572_00/Projects/CheckIt/bin/check_it.groovy", argv, envp); } printf("An error occured %d\n", errno); return errno; }
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pwd.h> int main(int argc, char** argv) { struct passwd *passwd = getpwuid(getuid()); int errno = setreuid(geteuid(), geteuid()); // errno = execle("/usr/bin/id", (char *) 0, envp); if (errno == 0 && passwd != 0) { // CHECKIT_USER will contain the name of the user that invoked us. char user_evar[100]; snprintf(user_evar, 80, "CHECKIT_USER=%s", passwd->pw_name); // Use a nice clean PATH. char * envp[] = { "PATH=/bin:/usr/bin" , "HOME=/home2/ling572_00" , "JAVA_HOME=/usr/java/latest" , "JAVA_OPTS=-Xmx300m -Xms140m" , "LC_ALL=en_US.UTF-8" , user_evar , (char *) 0 }; // Do it! errno = execve("/home2/ling572_00/Projects/CheckIt/bin/check_it.groovy", argv, envp); } printf("An error occured %d\n", errno); return errno; }
Refactor Matrix3x3 to internally use Vector3's
#ifndef COMMON_MATRIX_H #define COMMON_MATRIX_H /* * Printipi/common/matrix.h * (c) 2014 Colin Wallace * * This file exposes classes and templates used to construct 3x3 matrices. * Matrices are useful in applying linear transformations. Notably, they can be used to adjust coordinates to a different coordinate-space in order to account for an unlevel bed. */ class Matrix3x3 { float a00, a01, a02; float a10, a11, a12; float a20, a21, a22; public: Matrix3x3() : a00(0), a01(0), a02(0), a10(0), a11(0), a12(0), a20(0), a21(0), a22(0) {} Matrix3x3(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22) : a00(a00), a01(a01), a02(a02), a10(a10), a11(a11), a12(a12), a20(a20), a21(a21), a22(a22) {} template <typename VecT> VecT transform(const VecT &xyz) const { return VecT( a00*xyz.x() + a01*xyz.y() + a02*xyz.z(), a10*xyz.x() + a11*xyz.y() + a12*xyz.z(), a20*xyz.x() + a21*xyz.y() + a22*xyz.z() ); } }; #endif
#ifndef COMMON_MATRIX_H #define COMMON_MATRIX_H #include "common/vector3.h" /* * Matrices are useful in applying linear transformations. * Notably, they can be used to adjust coordinates to a different coordinate-space in order to account for an unlevel bed. */ class Matrix3x3 { //r0, r1, r2 each represent one row of the matrix. Vector3f r0, r1, r2; public: Matrix3x3() : r0(), r1(), r2() {} Matrix3x3(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22) : r0(a00, a01, a02), r1(a10, a11, a12), r2(a20, a21, a22) {} template <typename VecT> VecT transform(const VecT &xyz) const { return VecT(r0.dot(xyz), r1.dot(xyz), r2.dot(xyz)); } }; #endif
Add a structure that defines ARP headers
#ifndef ARP_H_ #define ARP_H_ /* * Address Resolution Protocol. * See RFC 826 for protocol description. * - https://tools.ietf.org/html/rfc826 */ struct arphdr { uint16_t ar_hrd; /* hardware type, one of: */ #define ARPHRD_ETHER 1 /* ethernet */ #define ARPHRD_FRELAY 15 /* frame relay */ uint16_t ar_pro; /* protocol type */ uint8_t ar_hln; /* length of hardware address */ uint8_t ar_pln; /* length of protocol address */ uint16_t ar_op; /* arp opcode, one of: */ #define ARPOP_REQUEST 1 /* arp request */ #define ARPOP_REPLY 2 /* arp reply */ #define ARPOP_REVREQUEST 3 /* rarp request */ #define ARPOP_REVREPLY 4 /* rarp reply */ #define ARPOP_INVREQUEST 8 /* InArp request */ #define ARPOP_INVREPLY 9 /* InArp reply */ /* * The remaining fields are variable in size, * according to the sizes above. */ #ifdef COMMENT_ONLY uint8_t ar_sha[]; /* sender hardware address */ uint8_t ar_spa[]; /* sender protocol address */ uint8_t ar_tha[]; /* target hardware address */ uint8_t ar_tpa[]; /* target protocol address */ #endif }; #endif /* end of include guard: ARP_H_ */
Add test case that shows a leak we don't catch.
// RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-experimental-checks -analyzer-store=region -verify %s #include <stdlib.h> void f1() { int *p = malloc(10); return; // expected-warning{{Allocated memory never released. Potential memory leak.}} } void f2() { int *p = malloc(10); free(p); free(p); // expected-warning{{Try to free a memory block that has been released}} }
// RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-experimental-checks -analyzer-store=region -verify %s #include <stdlib.h> void f1() { int *p = malloc(10); return; // expected-warning{{Allocated memory never released. Potential memory leak.}} } // THIS TEST CURRENTLY FAILS. void f1_b() { int *p = malloc(10); } void f2() { int *p = malloc(10); free(p); free(p); // expected-warning{{Try to free a memory block that has been released}} }
Add some more test function stubs
#include <CUnit/CUnit.h> #include <CUnit/Basic.h> #include <utils/hashmap.h> void test_hashmap_create(void) { return; } int main(int argc, char **argv) { CU_pSuite suite = NULL; if(CU_initialize_registry() != CUE_SUCCESS) { return CU_get_error(); } // Init suite suite = CU_add_suite("Hashmap", NULL, NULL); if(suite == NULL) { goto end; } // Add tests if(CU_add_test(suite, "test of hashmap_create", test_hashmap_create) == NULL) { goto end; } // Run tests CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); end: CU_cleanup_registry(); return CU_get_error(); }
#include <CUnit/CUnit.h> #include <CUnit/Basic.h> #include <utils/hashmap.h> void test_hashmap_create(void) { return; } void test_hashmap_free(void) { return; } void test_hashmap_delete(void) { return; } void test_hashmap_insert(void) { return; } void test_hashmap_get(void) { return; } void test_hashmap_iterator(void) { return; } int main(int argc, char **argv) { CU_pSuite suite = NULL; if(CU_initialize_registry() != CUE_SUCCESS) { return CU_get_error(); } // Init suite suite = CU_add_suite("Hashmap", NULL, NULL); if(suite == NULL) { goto end; } // Add tests if(CU_add_test(suite, "Test for hashmap create", test_hashmap_create) == NULL) { goto end; } if(CU_add_test(suite, "Test for hashmap delete operation", test_hashmap_delete) == NULL) { goto end; } if(CU_add_test(suite, "Test for hashmap insert operation", test_hashmap_insert) == NULL) { goto end; } if(CU_add_test(suite, "Test for hashmap get operation", test_hashmap_get) == NULL) { goto end; } if(CU_add_test(suite, "Test for hashmap iterator", test_hashmap_iterator) == NULL) { goto end; } if(CU_add_test(suite, "Test for hashmap free operation", test_hashmap_free) == NULL) { goto end; } // Run tests CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); end: CU_cleanup_registry(); return CU_get_error(); }
Add empty definitions for __VERIFIER_atomic_begin and end
void __VERIFIER_error() { abort(); } // Some files define __VERIFIER_assume, some declare as extern. What happens when redefined? void __VERIFIER_assume(int expression) { if (!expression) { LOOP: goto LOOP; }; return; } // #define __VERIFIER_nondet(X) X __VERIFIER_nondet_##X() { X val; return val; } #define __VERIFIER_nondet2(X, Y) X __VERIFIER_nondet_##Y() { X val; return val; } #define __VERIFIER_nondet(X) __VERIFIER_nondet2(X, X) __VERIFIER_nondet2(_Bool, bool) __VERIFIER_nondet(char) __VERIFIER_nondet2(unsigned char, uchar) // int __VERIFIER_nondet_int() { int val; return val; } __VERIFIER_nondet(int) __VERIFIER_nondet2(unsigned int, uint) __VERIFIER_nondet(long) __VERIFIER_nondet2(unsigned long, ulong) // void* __VERIFIER_nondet_pointer() { void* val; return val; } __VERIFIER_nondet2(void*, pointer)
void __VERIFIER_error() { abort(); } // Some files define __VERIFIER_assume, some declare as extern. What happens when redefined? void __VERIFIER_assume(int expression) { if (!expression) { LOOP: goto LOOP; }; return; } // #define __VERIFIER_nondet(X) X __VERIFIER_nondet_##X() { X val; return val; } #define __VERIFIER_nondet2(X, Y) X __VERIFIER_nondet_##Y() { X val; return val; } #define __VERIFIER_nondet(X) __VERIFIER_nondet2(X, X) __VERIFIER_nondet2(_Bool, bool) __VERIFIER_nondet(char) __VERIFIER_nondet2(unsigned char, uchar) // int __VERIFIER_nondet_int() { int val; return val; } __VERIFIER_nondet(int) __VERIFIER_nondet2(unsigned int, uint) __VERIFIER_nondet(long) __VERIFIER_nondet2(unsigned long, ulong) // void* __VERIFIER_nondet_pointer() { void* val; return val; } __VERIFIER_nondet2(void*, pointer) void __VERIFIER_atomic_begin() { } // TODO: use atomic marker in Goblint void __VERIFIER_atomic_end() { } // TODO: use atomic marker in Goblint
Add finite field operations in c
#include <stdio.h> #include <stdlib.h> // Chunk of a finite field element. typedef unsigned char chunk; // Number of chunks per element. #define N 10 // A finite field element. typedef struct { chunk v[N]; }* number; // Helper macro. #define FOR(i) for (int i = 0; i < N; i++) number new_number() { number n = malloc(sizeof(number)); FOR(i) { n->v[i] = 0x00; } return n; } void print(char* label, number n) { printf("%s: ", label); for (int i = N - 1; i >= 0; i--) { printf("%02x", n->v[i]); } printf("\n"); } void add(number a, number b, number result) { chunk carry = 0; chunk sum; FOR(i) { sum = a->v[i] + b->v[i] + carry; carry = sum < a->v[i] || (sum == a->v[i] && b->v[i] != 0); result->v[i] = sum; } } void sub(number a, number b, number result) { chunk carry = 0; chunk sum; FOR(i) { sum = a->v[i] - b->v[i] - carry; carry = a->v[i] < b->v[i] || sum > a->v[i]; result->v[i] = sum; } } int main() { number a = new_number(); a->v[0] = 0x01; number b = new_number(); b->v[0] = 0xFF; b->v[1] = 0xFF; number c = new_number(); print("a", a); print("b", b); add(a, b, c); print("a+b", c); sub(c, b, c); print("a+b-b", c); c->v[0] = 0x00; print("c", c); sub(c, a, c); print("-a", c); }
Disable the DAL's radio IRQ handler so we can use our own.
/** * MicroBitCustomConfig.h * * This file is automatically included by the microbit DAL compilation * process. Use this to define any custom configration options needed * for your build of the micro:bit runtime. * * See microbit-dal/inc/MicroBitConfig.h for a complete list of options. * Any options you define here will take prescedence over those defined there. */ #ifndef MICROBIT_CUSTOM_CONFIG_H #define MICROBIT_CUSTOM_CONFIG_H #define MICROBIT_HEAP_REUSE_SD 0 #define MICROBIT_BLE_ENABLED 0 #define MICROBIT_BLE_BLUEZONE 0 #define MICROBIT_BLE_DFU_SERVICE 0 #define MICROBIT_BLE_EVENT_SERVICE 0 #define MICROBIT_BLE_DEVICE_INFORMATION_SERVICE 0 #define MICROBIT_BLE_PAIRING_MODE 0 #endif
/** * MicroBitCustomConfig.h * * This file is automatically included by the microbit DAL compilation * process. Use this to define any custom configration options needed * for your build of the micro:bit runtime. * * See microbit-dal/inc/MicroBitConfig.h for a complete list of options. * Any options you define here will take prescedence over those defined there. */ #ifndef MICROBIT_CUSTOM_CONFIG_H #define MICROBIT_CUSTOM_CONFIG_H #define MICROBIT_HEAP_REUSE_SD 0 #define MICROBIT_BLE_ENABLED 0 #define MICROBIT_BLE_BLUEZONE 0 #define MICROBIT_BLE_DFU_SERVICE 0 #define MICROBIT_BLE_EVENT_SERVICE 0 #define MICROBIT_BLE_DEVICE_INFORMATION_SERVICE 0 #define MICROBIT_BLE_PAIRING_MODE 0 #define MICROBIT_RADIO_ENABLED 0 #endif
Update version number to 8.01.07-k1.
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2005 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.01.05-k4" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 1 #define QLA_DRIVER_PATCH_VER 5 #define QLA_DRIVER_BETA_VER 0
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2005 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.01.07-k1" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 1 #define QLA_DRIVER_PATCH_VER 7 #define QLA_DRIVER_BETA_VER 0
Update formatting, remove CII vars
static char rcsid[] = "$Id: H:/drh/idioms/book/RCS/except.doc,v 1.10 1997/02/21 19:43:55 drh Exp $"; #include "assert.h" const Except_T Assert_Failed = { "Assertion failed" }; void (assert)(int e) { assert(e); }
/** * assert.c * * Copyright (C) 2017 Nickolas Burr <nickolasburr@gmail.com> */ #include "assert.h" const Except_T Assert_Failed = { "Assertion failed" }; void (assert)(int e) { assert(e); }
Use correct file io function for binary reads
#include <stdlib.h> #include <stdio.h> #include "diskio.h" char* loadDataFromDiskFile(char* fileName) { FILE* diskFile = fopen(fileName, "rb"); if(diskFile == NULL) return NULL; char* diskData = (char*)malloc(sizeof(char) * DISK_SIZE); if(!fgets(diskData, DISK_SIZE, diskFile)) { if(diskFile) fclose(diskFile); free(diskData); return NULL; } fclose(diskFile); return diskData; } int saveDiskFile(char* fileName, char* data) { FILE* diskFile = fopen(fileName, "wb"); if(!diskFile) return -1; if(!fwrite(data, sizeof(char), DISK_SIZE, diskFile)) { fclose(diskFile); return -1; } fclose(diskFile); return 1; } void freeDiskData(char* diskData) { free(diskData); } char* getSegmentData(char* data, int tracknum, int sectornum) { return &data[ ((tracknum & TRACK_ID_MASK) * TRACK_SIZE) + ((sectornum & SECTOR_ID_MASK) * SECTOR_SIZE) ]; }
#include <stdlib.h> #include <stdio.h> #include "diskio.h" char* loadDataFromDiskFile(char* fileName) { FILE* diskFile = fopen(fileName, "rb"); if(diskFile == NULL) return NULL; char* diskData = (char*)malloc(sizeof(char) * DISK_SIZE); /* TODO: Return null if bytes read is less than expected*/ if(!fread(diskData, sizeof(char), DISK_SIZE, diskFile)){ if(diskFile) fclose(diskFile); free(diskData); return NULL; } fclose(diskFile); return diskData; } int saveDiskFile(char* fileName, char* data) { FILE* diskFile = fopen(fileName, "wb"); if(!diskFile) return -1; if(!fwrite(data, sizeof(char), DISK_SIZE, diskFile)) { fclose(diskFile); return -1; } fclose(diskFile); return 1; } void freeDiskData(char* diskData) { free(diskData); } char* getSegmentData(char* data, int tracknum, int sectornum) { return &data[ ((tracknum & TRACK_ID_MASK) * TRACK_SIZE) + ((sectornum & SECTOR_ID_MASK) * SECTOR_SIZE) ]; }
Fix wrong eth payload data type
#ifndef ETHERNET_H_ #define ETHERNET_H_ #include <linux/if_ether.h> struct eth_hdr { unsigned char dst_mac[6]; unsigned char src_mac[6]; unsigned short ethertype; unsigned char* payload; }; struct eth_hdr* init_eth_hdr(char* buf); void print_eth_hdr(struct eth_hdr *ehdr); #endif
#ifndef ETHERNET_H_ #define ETHERNET_H_ #include <linux/if_ether.h> struct eth_hdr { unsigned char dst_mac[6]; unsigned char src_mac[6]; unsigned short ethertype; unsigned char payload[]; }; struct eth_hdr* init_eth_hdr(char* buf); void print_eth_hdr(struct eth_hdr *ehdr); #endif
Send the "* BYE Logging out" before closing mailbox.
/* Copyright (C) 2002 Timo Sirainen */ #include "common.h" #include "commands.h" int cmd_logout(struct client *client) { client_send_line(client, "* BYE Logging out"); if (client->mailbox != NULL) { /* this could be done at client_disconnect() as well, but eg. mbox rewrite takes a while so the waiting is better to happen before "OK" message. */ mailbox_close(client->mailbox); client->mailbox = NULL; } client_send_tagline(client, "OK Logout completed."); client_disconnect(client); return TRUE; }
/* Copyright (C) 2002 Timo Sirainen */ #include "common.h" #include "commands.h" int cmd_logout(struct client *client) { client_send_line(client, "* BYE Logging out"); o_stream_uncork(client->output); if (client->mailbox != NULL) { /* this could be done at client_disconnect() as well, but eg. mbox rewrite takes a while so the waiting is better to happen before "OK" message. */ mailbox_close(client->mailbox); client->mailbox = NULL; } client_send_tagline(client, "OK Logout completed."); client_disconnect(client); return TRUE; }
Change the EFM32 reset type to a software reset
/* CMSIS-DAP Interface Firmware * Copyright (c) 2009-2013 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "RTL.h" #include "debug_cm.h" #include "target_reset.h" #include "swd_host.h" #include "DAP_Config.h" void target_before_init_debug(void) { return; } uint8_t target_unlock_sequence(void) { return 1; } uint8_t target_set_state(TARGET_RESET_STATE state) { return swd_set_target_state_hw(state); } uint8_t security_bits_set(uint32_t addr, uint8_t *data, uint32_t size) { return 0; }
/* CMSIS-DAP Interface Firmware * Copyright (c) 2009-2013 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "RTL.h" #include "debug_cm.h" #include "target_reset.h" #include "swd_host.h" #include "DAP_Config.h" void target_before_init_debug(void) { return; } uint8_t target_unlock_sequence(void) { return 1; } uint8_t target_set_state(TARGET_RESET_STATE state) { return swd_set_target_state_sw(state); } uint8_t security_bits_set(uint32_t addr, uint8_t *data, uint32_t size) { return 0; }
Add a missing prototype (callGetLocaleInfoEx())
#include "link-includes.h" // Already declared in link-includes.h // const char * linkgrammar_get_dict_locale(Dictionary dict); // const char * linkgrammar_get_version(void); // const char * linkgrammar_get_dict_version(Dictionary dict); void dictionary_setup_locale(Dictionary dict); void dictionary_setup_defines(Dictionary dict); void afclass_init(Dictionary dict); bool afdict_init(Dictionary dict); void affix_list_add(Dictionary afdict, Afdict_class *, const char *);
#include "link-includes.h" #include "utilities.h" // Already declared in link-includes.h // const char * linkgrammar_get_dict_locale(Dictionary dict); // const char * linkgrammar_get_version(void); // const char * linkgrammar_get_dict_version(Dictionary dict); void dictionary_setup_locale(Dictionary dict); void dictionary_setup_defines(Dictionary dict); void afclass_init(Dictionary dict); bool afdict_init(Dictionary dict); void affix_list_add(Dictionary afdict, Afdict_class *, const char *); #ifdef __MINGW32__ int callGetLocaleInfoEx(LPCWSTR, LCTYPE, LPWSTR, int); #endif /* __MINGW32__ */
Add missing initialization of time resolution
// // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Harshit Jain <hjain.itbhu@gmail.com> // #ifndef GEODATATIMESTAMPPRIVATE_H #define GEODATATIMESTAMPPRIVATE_H #include <QDateTime> #include "GeoDataTypes.h" #include <GeoDataTimeStamp.h> namespace Marble { class GeoDataTimeStampPrivate { public: QDateTime m_when; GeoDataTimeStamp::TimeResolution m_resolution; }; } // namespace Marble #endif //GEODATATIMESTAMPPRIVATE_H
// // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Harshit Jain <hjain.itbhu@gmail.com> // #ifndef GEODATATIMESTAMPPRIVATE_H #define GEODATATIMESTAMPPRIVATE_H #include <QDateTime> #include "GeoDataTypes.h" #include <GeoDataTimeStamp.h> namespace Marble { class GeoDataTimeStampPrivate { public: QDateTime m_when; GeoDataTimeStamp::TimeResolution m_resolution; GeoDataTimeStampPrivate(); }; GeoDataTimeStampPrivate::GeoDataTimeStampPrivate() : m_resolution( GeoDataTimeStamp::SecondResolution ) { // nothing to do } } // namespace Marble #endif //GEODATATIMESTAMPPRIVATE_H
Add newline to end of file
// // AardvarkDefines.h // Aardvark // // Created by Dan Federman on 10/4/14. // Copyright (c) 2014 Square, Inc. All rights reserved. // /** Provides the ability to verify key paths at compile time. If "keyPath" does not exist, a compile-time error will be generated. Example: // Verifies "isFinished" exists on "operation". NSString *key = ARKKeyPath(operation, isFinished); // Verifies "isFinished" exists on self. NSString *key = ARKSelfKeyPath(isFinished); */ #define ARKKeyPath(object, keyPath) \ ({ if (NO) { (void)((object).keyPath); } @#keyPath; }) #define ARKSelfKeyPath(keyPath) ARKKeyPath(self, keyPath) /** Throws a caught exception and returns "return_statement" if "condition" is false. Example: ARKCheckCondition(isProperlyConfigured, nil, @"Foo was not properly configured."); */ #define ARKCheckCondition(condition, result, desc, ...) \ do { \ if (!(condition)) { \ @try { \ NSAssert(condition, (desc), ##__VA_ARGS__); \ } @catch (NSException *exception) { \ NSLog(@"Aardvark API Misuse: %s %@", __PRETTY_FUNCTION__, exception.reason); \ return result;\ } \ } \ } while(0)
// // AardvarkDefines.h // Aardvark // // Created by Dan Federman on 10/4/14. // Copyright (c) 2014 Square, Inc. All rights reserved. // /** Provides the ability to verify key paths at compile time. If "keyPath" does not exist, a compile-time error will be generated. Example: // Verifies "isFinished" exists on "operation". NSString *key = ARKKeyPath(operation, isFinished); // Verifies "isFinished" exists on self. NSString *key = ARKSelfKeyPath(isFinished); */ #define ARKKeyPath(object, keyPath) \ ({ if (NO) { (void)((object).keyPath); } @#keyPath; }) #define ARKSelfKeyPath(keyPath) ARKKeyPath(self, keyPath) /** Throws a caught exception and returns "return_statement" if "condition" is false. Example: ARKCheckCondition(isProperlyConfigured, nil, @"Foo was not properly configured."); */ #define ARKCheckCondition(condition, result, desc, ...) \ do { \ if (!(condition)) { \ @try { \ NSAssert(condition, (desc), ##__VA_ARGS__); \ } @catch (NSException *exception) { \ NSLog(@"Aardvark API Misuse: %s %@", __PRETTY_FUNCTION__, exception.reason); \ return result;\ } \ } \ } while(0)
Change bool to a macro instead of typedef
#ifndef _UCC_STDBOOL_H #define _UCC_STDBOOL_H #define __bool_true_false_are_defined 1 typedef _Bool bool; #define bool bool #define false 0 #define true 1 #endif
#ifndef _UCC_STDBOOL_H #define _UCC_STDBOOL_H #define __bool_true_false_are_defined 1 #define bool _Bool #define false 0 #define true 1 #endif
Fix up merge with the ARM tree
/* * arch/arm/mach-shark/include/mach/io.h * * by Alexander Schulz * * derived from: * arch/arm/mach-ebsa110/include/mach/io.h * Copyright (C) 1997,1998 Russell King */ #ifndef __ASM_ARM_ARCH_IO_H #define __ASM_ARM_ARCH_IO_H #define PCIO_BASE 0xe0000000 #define IO_SPACE_LIMIT 0xffffffff #define __io(a) __typesafe_io(PCIO_BASE + (a)) #define __mem_pci(addr) (addr) #endif
/* * arch/arm/mach-shark/include/mach/io.h * * by Alexander Schulz * * derived from: * arch/arm/mach-ebsa110/include/mach/io.h * Copyright (C) 1997,1998 Russell King */ #ifndef __ASM_ARM_ARCH_IO_H #define __ASM_ARM_ARCH_IO_H #define PCIO_BASE 0xe0000000 #define IO_SPACE_LIMIT 0xffffffff #define __io(a) __typesafe_io(PCIO_BASE + (a)) #define __mem_pci(addr) (addr) #endif
Comment out the c for now
#include <ruby.h> #include <stdint.h> static VALUE rb_integer_to_bson(VALUE self) { const int32_t v = NUM2INT(self); const char bytes[4] = { v & 255, (v >> 8) & 255, (v >> 16) & 255, (v >> 24) & 255 }; return rb_str_new(bytes, 4); } void Init_native() { VALUE bson = rb_const_get(rb_cObject, rb_intern("BSON")); VALUE integer = rb_const_get(bson, rb_intern("Integer")); rb_remove_method(integer, "to_bson"); rb_define_method(integer, "to_bson", rb_integer_to_bson, 0); }
#include <ruby.h> #include <stdint.h> static VALUE rb_integer_to_bson(VALUE self) { /* const int32_t v = NUM2INT(self); */ /* const char bytes[4] = { v & 255, (v >> 8) & 255, (v >> 16) & 255, (v >> 24) & 255 }; */ /* return rb_str_new(bytes, 4); */ } void Init_native() { /* VALUE bson = rb_const_get(rb_cObject, rb_intern("BSON")); */ /* VALUE integer = rb_const_get(bson, rb_intern("Integer")); */ /* rb_remove_method(integer, "to_bson"); */ /* rb_define_method(integer, "to_bson", rb_integer_to_bson, 0); */ }
Return the result of debugged functions, and flush stderr on exit.
#include <string.h> #include "iobuf/iobuf.h" #include "msg/msg.h" #include "str/str.h" void NL(void) { obuf_putc(&outbuf, LF); } void debugstr(const str* s) { obuf_puts(&outbuf, "len="); obuf_putu(&outbuf, s->len); obuf_puts(&outbuf, " size="); obuf_putu(&outbuf, s->size); if (s->s == 0) obuf_puts(&outbuf, " s is NULL"); else { obuf_puts(&outbuf, " s="); obuf_putstr(&outbuf, s); } NL(); } void debugstrfn(int result, const str* s) { obuf_puts(&outbuf, "result="); obuf_puti(&outbuf, result); obuf_putc(&outbuf, ' '); debugstr(s); } void debugfn(int result) { obuf_puts(&outbuf, "result="); obuf_puti(&outbuf, result); NL(); } #define MAIN void selftest(void) MAIN; int main(void) { selftest(); obuf_flush(&outbuf); return 0; }
#include <string.h> #include "iobuf/iobuf.h" #include "msg/msg.h" #include "str/str.h" void NL(void) { obuf_putc(&outbuf, LF); } void debugstr(const str* s) { obuf_puts(&outbuf, "len="); obuf_putu(&outbuf, s->len); obuf_puts(&outbuf, " size="); obuf_putu(&outbuf, s->size); if (s->s == 0) obuf_puts(&outbuf, " s is NULL"); else { obuf_puts(&outbuf, " s="); obuf_putstr(&outbuf, s); } NL(); } int debugstrfn(int result, const str* s) { obuf_puts(&outbuf, "result="); obuf_puti(&outbuf, result); obuf_putc(&outbuf, ' '); debugstr(s); return result; } int debugfn(int result) { obuf_puts(&outbuf, "result="); obuf_puti(&outbuf, result); NL(); return result; } #define MAIN void selftest(void) MAIN; int main(void) { selftest(); obuf_flush(&outbuf); obuf_flush(&errbuf); return 0; }
Make sure plan and currency are not readonly
// // PSTCKTransactionParams.h // Paystack // #import <Foundation/Foundation.h> #import "PSTCKFormEncodable.h" /** * Representation of the transaction to perform on a card */ @interface PSTCKTransactionParams : NSObject<PSTCKFormEncodable> @property (nonatomic, copy, nonnull) NSString *email; @property (nonatomic) NSUInteger amount; @property (nonatomic, copy, nullable) NSString *reference; @property (nonatomic, copy, nullable) NSString *subaccount; @property (nonatomic) NSInteger transaction_charge; @property (nonatomic, copy, nullable) NSString *bearer; @property (nonatomic, readonly, nullable) NSString *metadata; @property (nonatomic, readonly, nullable) NSString *plan; @property (nonatomic, readonly, nullable) NSString *currency; - (nullable PSTCKTransactionParams *) setMetadataValue:(nonnull NSString*)value forKey:(nonnull NSString*)key error:(NSError * _Nullable __autoreleasing * _Nonnull) error; - (nullable PSTCKTransactionParams *) setCustomFieldValue:(nonnull NSString*)value displayedAs:(nonnull NSString*)display_name error:(NSError * _Nullable __autoreleasing * _Nonnull) error; @end
// // PSTCKTransactionParams.h // Paystack // #import <Foundation/Foundation.h> #import "PSTCKFormEncodable.h" /** * Representation of the transaction to perform on a card */ @interface PSTCKTransactionParams : NSObject<PSTCKFormEncodable> @property (nonatomic, copy, nonnull) NSString *email; @property (nonatomic) NSUInteger amount; @property (nonatomic, copy, nullable) NSString *reference; @property (nonatomic, copy, nullable) NSString *subaccount; @property (nonatomic) NSInteger transaction_charge; @property (nonatomic, copy, nullable) NSString *bearer; @property (nonatomic, readonly, nullable) NSString *metadata; @property (nonatomic, nullable) NSString *plan; @property (nonatomic, nullable) NSString *currency; - (nullable PSTCKTransactionParams *) setMetadataValue:(nonnull NSString*)value forKey:(nonnull NSString*)key error:(NSError * _Nullable __autoreleasing * _Nonnull) error; - (nullable PSTCKTransactionParams *) setCustomFieldValue:(nonnull NSString*)value displayedAs:(nonnull NSString*)display_name error:(NSError * _Nullable __autoreleasing * _Nonnull) error; @end
Change type of DeclSpecs to uint16_t
#ifndef DECL_H #define DECL_H #include <stdlib.h> typedef enum DeclSpec { DECL_SPEC_NONE = 0x0, DECL_SPEC_FLOAT = 0x1, DECL_SPEC_INT = 0x2, DECL_SPEC_SIGNED = 0x4, DECL_SPEC_UNSIGNED = 0x8, DECL_SPEC_VOID = 0x10, } DeclSpec; typedef size_t DeclSpecs; #endif
#ifndef DECL_H #define DECL_H #include <stdint.h> typedef enum DeclSpec { DECL_SPEC_NONE = 0x0, DECL_SPEC_FLOAT = 0x1, DECL_SPEC_INT = 0x2, DECL_SPEC_SIGNED = 0x4, DECL_SPEC_UNSIGNED = 0x8, DECL_SPEC_VOID = 0x10, } DeclSpec; typedef uint16_t DeclSpecs; #endif
Remove gard around of the prototype declaration of rb_get_kwargs for Ruby 2.1.x
#ifndef DLIB_MISSING_H #define DLIB_MISSING_H #include <ruby/ruby.h> #if defined(__cplusplus) extern "C" { #if 0 } /* satisfy cc-mode */ #endif #endif #ifndef HAVE_RB_GET_KWARGS int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values); #endif #if defined(__cplusplus) #if 0 { /* satisfy cc-mode */ #endif } /* extern "C" { */ #endif #endif /* DLIB_MISSING_H */
#ifndef DLIB_MISSING_H #define DLIB_MISSING_H #include <ruby/ruby.h> #if defined(__cplusplus) extern "C" { #if 0 } /* satisfy cc-mode */ #endif #endif int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values); #if defined(__cplusplus) #if 0 { /* satisfy cc-mode */ #endif } /* extern "C" { */ #endif #endif /* DLIB_MISSING_H */
Enable a WebP AID to show its animation one time
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 // b/145995037 #define SK_LEGACY_WEBP_LOOP_COUNT #endif // SkUserConfigManual_DEFINED
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
Reset EnvType and changed objdefs.h
#ifndef _RTUPDATE_H_ #define _RTUPDATE_H_ 1 #define MAXPUPARR 100 #define MAXPUPS 20 #define NOPUPDATE 78787878 // hopefully never a real p-value! /* For rtperf */ /* DJT: modified to work with JG's objlib.h */ typedef enum { NONE, ATTACK, DECAY, SUSTAIN, RELEASE, END } EnvType; GLOBAL int curtag; /* current note tag */ GLOBAL int tags_on; /* using note tags for rtupdates */ GLOBAL int tag_sem; /* contains the values to be updated -- a recirculating array */ GLOBAL float pupdatevals[MAXPUPARR][MAXPUPS]; #endif
#ifndef _RTUPDATE_H_ #define _RTUPDATE_H_ 1 #define MAXPUPARR 100 #define MAXPUPS 20 #define NOPUPDATE 78787878 // hopefully never a real p-value! /* For rtperf */ /* DJT: modified to work with JG's objlib.h */ typedef enum { NONE, RISE, SUSTAIN, DECAY } EnvType; #ifndef GLOBAL #define GLOBAL extern #endif GLOBAL int curtag; /* current note tag */ GLOBAL int tags_on; /* using note tags for rtupdates */ GLOBAL int tag_sem; /* contains the values to be updated -- a recirculating array */ GLOBAL float pupdatevals[MAXPUPARR][MAXPUPS]; #endif
Reduce character size to 2 units
#pragma once #include <cmath> #include <tuple> namespace Component { struct Warpgate { int16_t id; float min_x; float min_y; float min_z; float max_x; float max_y; float max_z; static constexpr float character_size = 2000.f; uint16_t dest_map; static constexpr inline float squared(float x) { return x * x; } std::tuple<float, float, float> get_center() const { return {(max_x + min_x) / 2.f, (max_y + min_y) / 2.f, (max_z + min_z) / 2.f}; } bool is_point_in(float x, float y, [[maybe_unused]] float z) { float dist_squared = squared(character_size); if (x < min_x) dist_squared -= squared(x - min_x); else if (x > max_x) dist_squared -= squared(x - max_x); if (y < min_y) dist_squared -= squared(y - min_y); else if (y > max_y) dist_squared -= squared(y - max_y); //if (z < min_z) dist_squared -= squared(z - min_z); //else if (z > max_z) dist_squared -= squared(z - max_z); return dist_squared > 0; } }; }
#pragma once #include <cmath> #include <tuple> namespace Component { struct Warpgate { int16_t id; float min_x; float min_y; float min_z; float max_x; float max_y; float max_z; static constexpr float character_size = 200.f; uint16_t dest_map; static constexpr inline float squared(float x) { return x * x; } std::tuple<float, float, float> get_center() const { return {(max_x + min_x) / 2.f, (max_y + min_y) / 2.f, (max_z + min_z) / 2.f}; } bool is_point_in(float x, float y, [[maybe_unused]] float z) { float dist_squared = squared(character_size); if (x < min_x) dist_squared -= squared(x - min_x); else if (x > max_x) dist_squared -= squared(x - max_x); if (y < min_y) dist_squared -= squared(y - min_y); else if (y > max_y) dist_squared -= squared(y - max_y); //if (z < min_z) dist_squared -= squared(z - min_z); //else if (z > max_z) dist_squared -= squared(z - max_z); return dist_squared > 0; } }; }
FIX typo: 0.21-nextç -> 0.21.0-next
#ifndef SRC_APP_CONTEXTBROKER_VERSION_H_ #define SRC_APP_CONTEXTBROKER_VERSION_H_ /* * * Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U * * This file is part of Orion Context Broker. * * Orion Context Broker is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Orion Context Broker 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 Affero * General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. * * For those usages not covered by this license please contact with * iot_support at tid dot es * * Author: Ken Zangelin */ #define ORION_VERSION "0.21.0-nextç" #endif // SRC_APP_CONTEXTBROKER_VERSION_H_
#ifndef SRC_APP_CONTEXTBROKER_VERSION_H_ #define SRC_APP_CONTEXTBROKER_VERSION_H_ /* * * Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U * * This file is part of Orion Context Broker. * * Orion Context Broker is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Orion Context Broker 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 Affero * General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. * * For those usages not covered by this license please contact with * iot_support at tid dot es * * Author: Ken Zangelin */ #define ORION_VERSION "0.21.0-next" #endif // SRC_APP_CONTEXTBROKER_VERSION_H_
Move SH4 definitions to header file
#ifndef __sh4_h__ #define __sh4_h__ enum { SH4_BASE = 0x4000, Rm, Rn, FRm, FRn, i8, i20, Pr15, // [R15++] Dn, // [--Rn] Pn, // [Rn++] dn, // [Rn] dn0, // [Rn+R0] d4n, // [Rn+d4] d12n, // [Rn+d12] Dm, // [--Rm] Pm, // [Rm++] dm, // [Rm] dm0, // [Rm+R0] d4m, // [Rm+d4] d12m, // [Rm+d12] dmp, // [Rm+PC] d8g, // [GBR+d8] dr0g, // [GBR+R0] d8p, // [PC+d8] j8, j12, _fT, _fS, _fM, _fQ, SIZE_FLOAT = 'f' << SIZE_SHIFT, R0 = TYPE_REG+SIZE_DWORD, R15 = TYPE_REG+SIZE_DWORD+15, PC = TYPE_REG+SIZE_DWORD+16, rMACH, rMACL, rPR, rSGR, rDSR, rFPUL, rA0, rX0, rX1, rY0, rY1, rDBR, rGBR, rVBR, rTBR, rSSR, rSR, rSPC, rMOD, rRS, rRE, }; #endif
Add centralized header which would include all other debug headers (memdeb, glitching at the moment).
/* * Copyright (c) 2019 Sippy Software, Inc., http://www.sippysoft.com * 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. * */ /* Do not include directly, droppen in automatically */ #include "rtpp_memdeb.h" #include "rtpp_autoglitch.h"
Add test where address containing unknown should escape known
#include <pthread.h> #include <assert.h> int *p; void *t_fun(void *arg) { if (arg != NULL) { *((int*)arg) = 42; } return NULL; } int main() { pthread_t id, id2; int *r; // unknown int i = 5; pthread_create(&id, NULL, t_fun, NULL); // enter multithreaded p = r; p = &i; pthread_create(&id2, NULL, t_fun, p); // i should escape, even if p contains unknown assert(i == 5); // UNKNOWN! return 0; }
Add new file that was forgotten.
#ifndef HALIDE_BUF_SIZE_H #define HALIDE_BUF_SIZE_H // TODO: in new buffer_t, add an inline method to do this and kill this file. // Compute the total amount of memory we'd need to allocate on gpu to // represent a given buffer (using the same strides as the host // allocation). WEAK size_t buf_size(const buffer_t *buf) { size_t size = buf->elem_size; for (size_t i = 0; i < sizeof(buf->stride) / sizeof(buf->stride[0]); i++) { size_t positive_stride; if (buf->stride[i] < 0) { positive_stride = (size_t)-buf->stride[i]; } else { positive_stride = (size_t)buf->stride[i]; } size_t total_dim_size = buf->elem_size * buf->extent[i] * positive_stride; if (total_dim_size > size) { size = total_dim_size; } } return size; } #endif // HALIDE_BUF_SIZE_H
Introduce |CodeBufferUser::code_buffer()| to use |CodeBuffer::EmitJump()| for 'br' instruction emitter.
// Copyright 2015 Project Vogue. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_ #define ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_ #include "base/basictypes.h" namespace elang { namespace lir { class CodeBuffer; struct Value; ////////////////////////////////////////////////////////////////////// // // CodeBufferUser // class CodeBufferUser { protected: explicit CodeBufferUser(CodeBuffer* code_buffer); ~CodeBufferUser(); void AssociateValue(Value value); void Emit16(int data); void Emit32(uint32_t data); void Emit64(uint64_t data); void Emit8(int data); private: CodeBuffer* const code_buffer_; DISALLOW_COPY_AND_ASSIGN(CodeBufferUser); }; } // namespace lir } // namespace elang #endif // ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_
// Copyright 2015 Project Vogue. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_ #define ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_ #include "base/basictypes.h" namespace elang { namespace lir { class CodeBuffer; struct Value; ////////////////////////////////////////////////////////////////////// // // CodeBufferUser // class CodeBufferUser { protected: explicit CodeBufferUser(CodeBuffer* code_buffer); ~CodeBufferUser(); CodeBuffer* code_buffer() const { return code_buffer_; } void AssociateValue(Value value); void Emit16(int data); void Emit32(uint32_t data); void Emit64(uint64_t data); void Emit8(int data); private: CodeBuffer* const code_buffer_; DISALLOW_COPY_AND_ASSIGN(CodeBufferUser); }; } // namespace lir } // namespace elang #endif // ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_
Add List Node destroy 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 *); #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); #endif
Improve BOM test from r195877
// RUN: %clang -E -frewrite-includes -I %S/Inputs %s -o - | %clang -fsyntax-only -Xclang -verify -x c - // expected-no-diagnostics #include "rewrite-includes-bom.h"
// RUN: grep '^\xEF\xBB\xBF' %S/Inputs/rewrite-includes-bom.h // RUN: %clang_cc1 -E -frewrite-includes -I %S/Inputs %s -o - | %clang_cc1 -fsyntax-only -verify -x c - | not grep '\xEF\xBB\xBF' // expected-no-diagnostics #include "rewrite-includes-bom.h"
Add getIds to file manager
#ifndef _FILE_MANAGER_INTERFACE_ #define _FILE_MANAGER_INTERFACE_ #include <string> #include <cstdint> class FileManagerInterface { public: virtual bool send( const std::string & host, const unsigned short host_port, std::string & file_path, uint64_t from = 0, uint64_t to = -1) = 0; virtual ~FileManagerInterface(){}; }; #endif // _FILE_MANAGER_INTERFACE_
#ifndef _FILE_MANAGER_INTERFACE_ #define _FILE_MANAGER_INTERFACE_ #include <string> #include <cstdint> class FileManagerInterface { public: virtual uint64_t send( const std::string & host, const unsigned short host_port, std::string & file_path, uint64_t from = 0, uint64_t to = -1) = 0; virtual std::std::vector<uint64_t> getIds() = 0; virtual ~FileManagerInterface(){}; }; #endif // _FILE_MANAGER_INTERFACE_
Enumerate strided array data types
/** * @license Apache-2.0 * * Copyright (c) 2018 The Stdlib Authors. * * 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. */ /** * Header file for strided array data types. */ #ifndef STDLIB_STRIDED_DTYPES_H #define STDLIB_STRIDED_DTYPES_H enum STDLIB_STRIDED_DTYPES { STDLIB_BOOL = 0, STDLIB_INT8 = 1, STDLIB_UINT8 = 2, STDLIB_INT16 = 3, STDLIB_UINT16 = 4, STDLIB_INT32 = 5, STDLIB_UINT32 = 6, STDLIB_INT64 = 7, STDLIB_UINT64 = 8, STDLIB_INT128 = 9, STDLIB_UINT128 = 10, STDLIB_FLOAT16 = 20, STDLIB_FLOAT32 = 21, STDLIB_FLOAT64 = 22, STDLIB_FLOAT128 = 23 }; #endif // !STDLIB_STRIDED_DTYPES_H
Add another test for pretty printing if-then-else
int f(int d) { int i = 0, j, k, l; if (d%2==0) if (d%3==0) i+=2; else i+=3; if (d%2==0) { if (d%3==0) i+=7; } else i+=11; l = d; if (d%2==0) while (l--) if (1) i+=13; else i+=17; l = d; if (d%2==0) { while (l--) if (1) i+=21; } else i+=23; if (d==0) i+=27; else if (d%2==0) if (d%3==0) i+=29; else if (d%5==0) if (d%7==0) i+=31; else i+=33; return i; } int main() { int i,k=0; for(i=0;i<255;i++) { k+=f(i); } printf("Result: %d\n",k); }
Fix typo in C template
#include <display.h> /* Warning! C support in KnightOS is highly experimental. Your milage may vary. */ void main(void) { SCREEN *screen; get_lcd_lock(); screen = screen_allocate(); screen_clear(screen); draw_string(screen, 0, 0, "Hello world!"); screen_draw(screen); while (1); }
#include <display.h> /* Warning! C support in KnightOS is highly experimental. Your mileage may vary. */ void main(void) { SCREEN *screen; get_lcd_lock(); screen = screen_allocate(); screen_clear(screen); draw_string(screen, 0, 0, "Hello world!"); screen_draw(screen); while (1); }
Add BSTNode Create function declaration
#include <stdlib.h> #ifndef __BST_H__ #define __BST_H__ struct BSTNode; struct BST; typedef struct BSTNode BSTNode; typedef struct BST BST; BST* BST_Create(void); #endif
#include <stdlib.h> #ifndef __BST_H__ #define __BST_H__ struct BSTNode; struct BST; typedef struct BSTNode BSTNode; typedef struct BST BST; BST* BST_Create(void); BSTNode* BSTNode_Create(void* k); #endif
Add a mssissing file at previous commit
//Vertigo v2.0 board setting #define USE_FUTABA #define USE_IMU_MPU9250 #define USE_ADS1246_MPX6115A #define STM32F427X
Fix GLContext::createGLContext() impl (must return a value)
// LAF OS Library // Copyright (C) 2022 Igara Studio S.A. // Copyright (C) 2015-2016 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. #ifndef OS_GL_CONTEXT_INCLUDED #define OS_GL_CONTEXT_INCLUDED #pragma once namespace os { class GLContext { public: virtual ~GLContext() { } virtual bool isValid() { return false; } virtual bool createGLContext() { } virtual void destroyGLContext() { } virtual void makeCurrent() { } virtual void swapBuffers() { } }; } // namespace os #endif
// LAF OS Library // Copyright (C) 2022 Igara Studio S.A. // Copyright (C) 2015-2016 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. #ifndef OS_GL_CONTEXT_INCLUDED #define OS_GL_CONTEXT_INCLUDED #pragma once namespace os { class GLContext { public: virtual ~GLContext() { } virtual bool isValid() { return false; } virtual bool createGLContext() { return false; } virtual void destroyGLContext() { } virtual void makeCurrent() { } virtual void swapBuffers() { } }; } // namespace os #endif
Use a dummy target so the test passes when default target is for a toolchain implements useIntegratedAs() -> true
// RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s // CHECK: cc1as // CHECK: -mrelax-all // RUN: %clang -### -fintegrated-as -c -save-temps %s 2>&1 | FileCheck %s -check-prefix FIAS // FIAS: cc1as // RUN: %clang -### -fno-integrated-as -S %s 2>&1 \ // RUN: | FileCheck %s -check-prefix NOFIAS // NOFIAS-NOT: cc1as // NOFIAS: -cc1 // NOFIAS: -no-integrated-as
// RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s // CHECK: cc1as // CHECK: -mrelax-all // RUN: %clang -### -fintegrated-as -c -save-temps %s 2>&1 | FileCheck %s -check-prefix FIAS // FIAS: cc1as // RUN: %clang -target none -### -fno-integrated-as -S %s 2>&1 \ // RUN: | FileCheck %s -check-prefix NOFIAS // NOFIAS-NOT: cc1as // NOFIAS: -cc1 // NOFIAS: -no-integrated-as
Fix sockops map name for testing
/* * Copyright (C) 2018 Authors of Cilium * * 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 */ #ifndef SOCK_OPS_MAP #define SOCK_OPS_MAP cilium_sock_ops #endif #define SOCKOPS_MAP_SIZE 65535
/* * Copyright (C) 2018-2019 Authors of Cilium * * 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 */ #ifndef SOCK_OPS_MAP #define SOCK_OPS_MAP cilium_sock_ops #endif #define SOCKOPS_MAP_SIZE 65535 #ifndef CALLS_MAP #define CALLS_MAP test_cilium_calls #endif
Define the Glib functions as module functions.
#include <ruby.h> #include <glib.h> static VALUE utf8_size(VALUE self, VALUE string) { VALUE result; Check_Type(string, T_STRING); result = ULONG2NUM(g_utf8_strlen(StringValuePtr(string), RSTRING(string)->len)); return result; } static VALUE utf8_upcase(VALUE self, VALUE string) { VALUE result; gchar *temp; Check_Type(string, T_STRING); temp = g_utf8_strup(StringValuePtr(string), RSTRING(string)->len); result = rb_str_new2(temp); return result; } static VALUE utf8_downcase(VALUE self, VALUE string) { VALUE result; gchar *temp; Check_Type(string, T_STRING); temp = g_utf8_strdown(StringValuePtr(string), RSTRING(string)->len); result = rb_str_new2(temp); return result; } void Init_glib() { VALUE mGlib; mGlib = rb_define_module("Glib"); rb_define_method(mGlib, "utf8_size", utf8_size, 1); rb_define_method(mGlib, "utf8_upcase", utf8_upcase, 1); rb_define_method(mGlib, "utf8_downcase", utf8_downcase, 1); }
#include <ruby.h> #include <glib.h> static VALUE utf8_size(VALUE self, VALUE string) { VALUE result; Check_Type(string, T_STRING); result = ULONG2NUM(g_utf8_strlen(StringValuePtr(string), RSTRING(string)->len)); return result; } static VALUE utf8_upcase(VALUE self, VALUE string) { VALUE result; gchar *temp; Check_Type(string, T_STRING); temp = g_utf8_strup(StringValuePtr(string), RSTRING(string)->len); result = rb_str_new2(temp); return result; } static VALUE utf8_downcase(VALUE self, VALUE string) { VALUE result; gchar *temp; Check_Type(string, T_STRING); temp = g_utf8_strdown(StringValuePtr(string), RSTRING(string)->len); result = rb_str_new2(temp); return result; } void Init_glib() { VALUE mGlib; mGlib = rb_define_module("Glib"); rb_define_module_function(mGlib, "utf8_size", utf8_size, 1); rb_define_module_function(mGlib, "utf8_upcase", utf8_upcase, 1); rb_define_module_function(mGlib, "utf8_downcase", utf8_downcase, 1); }
Add a copy constructor and * overload
#pragma once #ifndef TESTING_UTIL_H #define TESTING_UTIL_H 1 #include <Python.h> /** Use RAII to Py_XDECREF a pointer. Inspired by std::unique_ptr. */ template <class T> class py_ptr { private: T* m_ptr; public: py_ptr() : m_ptr(nullptr) {} py_ptr(T* ptr) : m_ptr(ptr) {} ~py_ptr() { Py_XDECREF(m_ptr); } void reset(T* ptr) { Py_XDECREF(m_ptr); m_ptr = ptr; } T* get() { return m_ptr; } T* operator->() { return m_ptr; } }; /** A concrete PyObject instance of py_ptr. */ class PyObject_ptr : public py_ptr<PyObject> { public: PyObject_ptr(PyObject *ptr) : py_ptr(ptr) {} }; PyCodeObject* CompileCode(const char*); #endif // !TESTING_UTIL_H
#pragma once #ifndef TESTING_UTIL_H #define TESTING_UTIL_H 1 #include <Python.h> /** Use RAII to Py_XDECREF a pointer. Inspired by std::unique_ptr. */ template <class T> class py_ptr { private: T* m_ptr; public: py_ptr() : m_ptr(nullptr) {} py_ptr(T* ptr) : m_ptr(ptr) {} py_ptr(const py_ptr& copy) { m_ptr = copy.get(); Py_INCREF(m_ptr); } ~py_ptr() { Py_XDECREF(m_ptr); } void reset(T* ptr) { Py_XDECREF(m_ptr); m_ptr = ptr; } T* get() { return m_ptr; } T* operator->() { return m_ptr; } T* operator*() { return m_ptr; } }; /** A concrete PyObject instance of py_ptr. */ class PyObject_ptr : public py_ptr<PyObject> { public: PyObject_ptr(PyObject *ptr) : py_ptr(ptr) {} }; PyCodeObject* CompileCode(const char*); #endif // !TESTING_UTIL_H
Enable and disable raw mode in terminal
#include <unistd.h> int main(int argc, char *argv[]) { char c; // Read 1 byte at a time while(read(STDIN_FILENO, &c, 1) == 1); return 0; }
#include <ctype.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <termios.h> struct termios orig_termios; void enableRawMode(); void disableRawMode(); int main(int argc, char *argv[]) { enableRawMode(); // Read 1 byte at a time while(1){ char input = '\0'; // Input from user read(STDIN_FILENO, &input, 1); if(iscntrl(input)) { printf("%d\r\n", input); } else { printf("%d ('%c')\r\n", input, input); } if(input == 'q') break; } return 0; } void enableRawMode(){ tcgetattr(STDIN_FILENO, &orig_termios); atexit(disableRawMode); struct termios raw; tcgetattr(STDIN_FILENO,&raw); // Flags to enable raw mode raw.c_iflag &= ~(BRKINT | ICRNL | IXON | ISTRIP | INPCK); raw.c_oflag &= ~(OPOST); raw.c_cflag |= (CS8); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); // raw.c_cc[VMIN] = 0; // Value sets minimum number of bytes of input needed bfore read() can return. Set so it returns right away raw.c_cc[VTIME] = 1; // Maximum amount of time read waits to return, in tenths of seconds tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } void disableRawMode(){ tcsetattr(STDERR_FILENO,TCSAFLUSH,&orig_termios); }
Use same int 64 type
// Copyright 2014 Toggl Desktop developers. #ifndef SRC_PROXY_H_ #define SRC_PROXY_H_ #include <string> #include "./types.h" #include "Poco/Types.h" namespace kopsik { class Proxy { public: Proxy() : host(""), port(0), username(""), password("") {} bool IsConfigured() const; bool HasCredentials() const; std::string String() const; std::string host; Poco::UInt16 port; std::string username; std::string password; }; } // namespace kopsik #endif // SRC_PROXY_H_
// Copyright 2014 Toggl Desktop developers. #ifndef SRC_PROXY_H_ #define SRC_PROXY_H_ #include <string> #include "./types.h" #include "Poco/Types.h" namespace kopsik { class Proxy { public: Proxy() : host(""), port(0), username(""), password("") {} bool IsConfigured() const; bool HasCredentials() const; std::string String() const; std::string host; Poco::UInt64 port; std::string username; std::string password; }; } // namespace kopsik #endif // SRC_PROXY_H_
Implement a new RemoveSuccessor function
//===-- Transform/Utils/BasicBlockUtils.h - BasicBlock Utilities -*- C++ -*-==// // // This family of functions perform manipulations on basic blocks, and // instructions contained within basic blocks. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_UTILS_BASICBLOCK_H #define LLVM_TRANSFORMS_UTILS_BASICBLOCK_H // FIXME: Move to this file: BasicBlock::removePredecessor, BB::splitBasicBlock #include "llvm/BasicBlock.h" class Instruction; // ReplaceInstWithValue - Replace all uses of an instruction (specified by BI) // with a value, then remove and delete the original instruction. // void ReplaceInstWithValue(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Value *V); // ReplaceInstWithInst - Replace the instruction specified by BI with the // instruction specified by I. The original instruction is deleted and BI is // updated to point to the new instruction. // void ReplaceInstWithInst(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Instruction *I); // ReplaceInstWithInst - Replace the instruction specified by From with the // instruction specified by To. Note that this is slower than providing an // iterator directly, because the basic block containing From must be searched // for the instruction. // void ReplaceInstWithInst(Instruction *From, Instruction *To); #endif
//===-- Transform/Utils/BasicBlockUtils.h - BasicBlock Utilities -*- C++ -*-==// // // This family of functions perform manipulations on basic blocks, and // instructions contained within basic blocks. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_UTILS_BASICBLOCK_H #define LLVM_TRANSFORMS_UTILS_BASICBLOCK_H // FIXME: Move to this file: BasicBlock::removePredecessor, BB::splitBasicBlock #include "llvm/BasicBlock.h" class Instruction; // ReplaceInstWithValue - Replace all uses of an instruction (specified by BI) // with a value, then remove and delete the original instruction. // void ReplaceInstWithValue(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Value *V); // ReplaceInstWithInst - Replace the instruction specified by BI with the // instruction specified by I. The original instruction is deleted and BI is // updated to point to the new instruction. // void ReplaceInstWithInst(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Instruction *I); // ReplaceInstWithInst - Replace the instruction specified by From with the // instruction specified by To. // void ReplaceInstWithInst(Instruction *From, Instruction *To); // RemoveSuccessor - Change the specified terminator instruction such that its // successor #SuccNum no longer exists. Because this reduces the outgoing // degree of the current basic block, the actual terminator instruction itself // may have to be changed. In the case where the last successor of the block is // deleted, a return instruction is inserted in its place which can cause a // suprising change in program behavior if it is not expected. // void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum); #endif
Add a component splitter filter.
// --------------------------------------------------------------------- // // Copyright (C) 2019 by the SampleFlow authors. // // This file is part of the SampleFlow library. // // The deal.II library is free software; you can use it, 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 full text of the license can be found in the file LICENSE.md at // the top level directory of deal.II. // // --------------------------------------------------------------------- #ifndef SAMPLEFLOW_FILTERS_COMPONENT_SPLITTER_H #define SAMPLEFLOW_FILTERS_COMPONENT_SPLITTER_H #include <sampleflow/filter.h> namespace SampleFlow { namespace Filters { template <typename InputType> class ComponentSplitter : public Filter<InputType, typename InputType::value_type> { public: ComponentSplitter (const unsigned int selected_component); virtual boost::optional<std::pair<InputType, AuxiliaryData> > filter (InputType sample, AuxiliaryData aux_data) override; private: const unsigned int selected_component; }; template <typename InputType> ComponentSplitter<InputType>:: ComponentSplitter (const unsigned int selected_component) : selected_component(selected_component) {} template <typename InputType> boost::optional<std::pair<InputType, AuxiliaryData> > ComponentSplitter<InputType>:: filter (InputType sample, AuxiliaryData aux_data) { return { std::move(sample[selected_component]), std::move(aux_data)}; } } } #endif
Add one empty header file
// The MIT License (MIT) // // Copyright (c) 2016 Northeastern University // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #ifndef CORE_INCLUDE_CUDNN_UTILITY_H_ #define CORE_INCLUDE_CUDNN_UTILITY_H_ #include "cudnn.h" namespace dnnmark { } // namespace dnnmark #endif // CORE_INCLUDE_CUDNN_UTILITY_H_
Use scoped_ptr for Panel in PanelBrowserWindowGTK.
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #include "chrome/browser/ui/gtk/browser_window_gtk.h" class Panel; class PanelBrowserWindowGtk : public BrowserWindowGtk { public: PanelBrowserWindowGtk(Browser* browser, Panel* panel); virtual ~PanelBrowserWindowGtk() {} // BrowserWindowGtk overrides virtual void Init() OVERRIDE; // BrowserWindow overrides virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; protected: // BrowserWindowGtk overrides virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge) OVERRIDE; virtual bool HandleTitleBarLeftMousePress( GdkEventButton* event, guint32 last_click_time, gfx::Point last_click_position) OVERRIDE; virtual void SaveWindowPosition() OVERRIDE; virtual void SetGeometryHints() OVERRIDE; virtual bool UseCustomFrame() OVERRIDE; private: void SetBoundsImpl(); Panel* panel_; DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk); }; #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #include "chrome/browser/ui/gtk/browser_window_gtk.h" class Panel; class PanelBrowserWindowGtk : public BrowserWindowGtk { public: PanelBrowserWindowGtk(Browser* browser, Panel* panel); virtual ~PanelBrowserWindowGtk() {} // BrowserWindowGtk overrides virtual void Init() OVERRIDE; // BrowserWindow overrides virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; protected: // BrowserWindowGtk overrides virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge) OVERRIDE; virtual bool HandleTitleBarLeftMousePress( GdkEventButton* event, guint32 last_click_time, gfx::Point last_click_position) OVERRIDE; virtual void SaveWindowPosition() OVERRIDE; virtual void SetGeometryHints() OVERRIDE; virtual bool UseCustomFrame() OVERRIDE; private: void SetBoundsImpl(); scoped_ptr<Panel> panel_; DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk); }; #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_
Call lib init/cleanup in C client test.
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <mosquitto.h> static int run = -1; void on_connect(struct mosquitto *mosq, void *obj, int rc) { if(rc){ exit(1); }else{ mosquitto_disconnect(mosq); } } void on_disconnect(struct mosquitto *mosq, void *obj, int rc) { run = rc; } int main(int argc, char *argv[]) { int rc; struct mosquitto *mosq; mosq = mosquitto_new("01-con-discon-success", true, NULL); mosquitto_connect_callback_set(mosq, on_connect); mosquitto_disconnect_callback_set(mosq, on_disconnect); rc = mosquitto_connect(mosq, "localhost", 1888, 60); while(run == -1){ mosquitto_loop(mosq, -1); } return run; }
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <mosquitto.h> static int run = -1; void on_connect(struct mosquitto *mosq, void *obj, int rc) { if(rc){ exit(1); }else{ mosquitto_disconnect(mosq); } } void on_disconnect(struct mosquitto *mosq, void *obj, int rc) { run = rc; } int main(int argc, char *argv[]) { int rc; struct mosquitto *mosq; mosquitto_lib_init(); mosq = mosquitto_new("01-con-discon-success", true, NULL); mosquitto_connect_callback_set(mosq, on_connect); mosquitto_disconnect_callback_set(mosq, on_disconnect); rc = mosquitto_connect(mosq, "localhost", 1888, 60); while(run == -1){ mosquitto_loop(mosq, -1); } mosquitto_lib_cleanup(); return run; }
Allow to set custom DTB/OS_CALL addresses
#ifndef CONFIG_H #define CONFIG_H //#define QEMU #define SIM #define OS_CALL 0xC0000000 #define DTB 0xC3000000 #endif
#ifndef CONFIG_H #define CONFIG_H //#define QEMU #define SIM #ifndef OS_CALL #define OS_CALL 0xC0000000 #endif #ifndef DTB #define DTB 0xC3000000 #endif #endif
Print the message from SK_ABORT in stack traces
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT #define SK_SUPPORT_STROKEANDFILL // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #include <android/log.h> #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT #define SK_SUPPORT_STROKEANDFILL // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "skia" #define SK_ABORT(...) __android_log_assert(nullptr, LOG_TAG, ##__VA_ARGS__) #endif // SkUserConfigManual_DEFINED
Add a typedef for iterators.
// Copyright (c) 2014 Rob Rix. All rights reserved. #import <Foundation/Foundation.h> @protocol REDIterable <NSObject> @property (readonly) id(^red_iterator)(void); @end
// Copyright (c) 2014 Rob Rix. All rights reserved. #import <Foundation/Foundation.h> /// A nullary block iterating the elements of a collection over successive calls. /// /// \return The next object in the collection, or nil if it has iterated the entire collection. typedef id (^REDIteratingBlock)(void); /// A collection which can be iterated. @protocol REDIterable <NSObject> /// An iterator for this collection. @property (readonly) REDIteratingBlock red_iterator; @end
Fix clang-6 compile error (virtual destructor)
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import <memory> #include <fabric/IFabricPlatformUIOperationManager.h> @class RCTFabricPlatformUIOperationManager; namespace facebook { namespace react { /** * Connector class (from C++ to ObjC++) to allow FabricUIManager to invoke native UI operations/updates. * UIKit-related impl doesn't live here, but this class gets passed to the FabricUIManager C++ impl directly. */ class RCTFabricPlatformUIOperationManagerConnector : public IFabricPlatformUIOperationManager { public: RCTFabricPlatformUIOperationManagerConnector(); ~RCTFabricPlatformUIOperationManagerConnector(); void performUIOperation(); private: void *self_; RCTFabricPlatformUIOperationManager *manager_; }; } // namespace react } // namespace facebook /** * Actual ObjC++ implementation of the UI operations. */ @interface RCTFabricPlatformUIOperationManager : NSObject - (void)performUIOperation; @end
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import <memory> #include <fabric/IFabricPlatformUIOperationManager.h> @class RCTFabricPlatformUIOperationManager; namespace facebook { namespace react { /** * Connector class (from C++ to ObjC++) to allow FabricUIManager to invoke native UI operations/updates. * UIKit-related impl doesn't live here, but this class gets passed to the FabricUIManager C++ impl directly. */ class RCTFabricPlatformUIOperationManagerConnector : public IFabricPlatformUIOperationManager { public: RCTFabricPlatformUIOperationManagerConnector(); virtual ~RCTFabricPlatformUIOperationManagerConnector(); void performUIOperation(); private: void *self_; RCTFabricPlatformUIOperationManager *manager_; }; } // namespace react } // namespace facebook /** * Actual ObjC++ implementation of the UI operations. */ @interface RCTFabricPlatformUIOperationManager : NSObject - (void)performUIOperation; @end
Use tab characters in help text.
// Copyright 2016, Jeffrey E. Bedard #include "xstatus.h" #include "config.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> static const char helptext[] = "DESCRIPTION: Simple X toolbar for minimalistic" " window managers.\n" "USAGE: xstatus [-d DELAY][-f FILE][-h]\n" "\t-d DELAY Set delay between status updates," " in seconds.\n" "\t-f FILE Set FILE to be continuously polled and" " displayed.\n" "\t-h Print this usage information. \n" "Copyright 2016, Jeffrey E. Bedard <jefbed@gmail.com>\n" "Project page: https://github.com/jefbed/xstatus\n"; int main(int argc, char ** argv) { char *filename=XSTATUS_STATUS_FILE; uint8_t delay=1; int opt; while((opt = getopt(argc, argv, "d:f:h")) != -1) { switch(opt) { case 'd': delay=atoi(optarg); break; case 'f': filename=optarg; break; case 'h': default: write(2, helptext, sizeof(helptext)); exit(0); } } run_xstatus(filename, delay); }
// Copyright 2016, Jeffrey E. Bedard #include "xstatus.h" #include "config.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> static const char helptext[] = "DESCRIPTION: Simple X toolbar for minimalistic" " window managers.\n" "USAGE: xstatus [-d DELAY][-f FILE][-h]\n" "\t-d DELAY\tSet delay between status updates," " in seconds.\n" "\t-f FILE\t\tSet FILE to be continuously polled and" " displayed.\n" "\t-h\t\tPrint this usage information.\n" "Copyright 2016, Jeffrey E. Bedard <jefbed@gmail.com>\n" "Project page: https://github.com/jefbed/xstatus\n"; int main(int argc, char ** argv) { char *filename=XSTATUS_STATUS_FILE; uint8_t delay=1; int opt; while((opt = getopt(argc, argv, "d:f:h")) != -1) { switch(opt) { case 'd': delay=atoi(optarg); break; case 'f': filename=optarg; break; case 'h': default: write(2, helptext, sizeof(helptext)); exit(0); } } run_xstatus(filename, delay); }
Add test for overloading with _Complex in C
// RUN: clang -fsyntax-only -verify %s char *foo(float) __attribute__((__overloadable__)); // expected-note 3 {{candidate function}} void test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) { char *cp1 = foo(fv); char *cp2 = foo(dv); // Note: GCC and EDG reject these two, but they are valid C99 conversions char *cp3 = foo(fc); char *cp4 = foo(dc); } int *foo(float _Complex) __attribute__((__overloadable__)); // expected-note 3 {{candidate function}} void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) { char *cp1 = foo(fv); char *cp2 = foo(dv); // expected-error{{call to 'foo' is ambiguous; candidates are:}} int *ip = foo(fc); int *lp = foo(dc); // expected-error{{call to 'foo' is ambiguous; candidates are:}} } long *foo(double _Complex) __attribute__((__overloadable__)); // expected-note {{candidate function}} void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) { char *cp1 = foo(fv); char *cp2 = foo(dv); // expected-error{{call to 'foo' is ambiguous; candidates are:}} int *ip = foo(fc); long *lp = foo(dc); } char *promote_or_convert(double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}} int *promote_or_convert(long double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}} void test_promote_or_convert(float f, float _Complex fc) { char *cp = promote_or_convert(fc); // expected-error{{call to 'promote_or_convert' is ambiguous; candidates are:}} int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous; candidates are:}} } char *promote_or_convert2(float) __attribute__((__overloadable__)); int *promote_or_convert2(double _Complex) __attribute__((__overloadable__)); void test_promote_or_convert2(float _Complex fc) { int *cp = promote_or_convert2(fc); } char *promote_or_convert3(int _Complex) __attribute__((__overloadable__)); int *promote_or_convert3(long _Complex) __attribute__((__overloadable__)); void test_promote_or_convert3(short _Complex sc) { char *cp = promote_or_convert3(sc); }
Tweak the kobo mxcfb cdecl
// standard Linux framebuffer headers #include <linux/fb.h> #include <linux/ioctl.h> // specialized eink framebuffer headers typedef unsigned int uint; #include "include/mxcfb-kobo.h" #include "cdecl.h" cdecl_struct(mxcfb_rect) cdecl_struct(mxcfb_alt_buffer_data) cdecl_struct(mxcfb_update_data) cdecl_const(MXCFB_SEND_UPDATE)
// standard Linux framebuffer headers #include <linux/fb.h> #include <linux/ioctl.h> // specialized eink framebuffer headers typedef unsigned int uint; #include "include/mxcfb-kobo.h" #include "cdecl.h" cdecl_struct(mxcfb_rect) cdecl_struct(mxcfb_alt_buffer_data) cdecl_struct(mxcfb_update_data) cdecl_const(MXCFB_SEND_UPDATE) /* Might come in handy one day... */ cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) /* Aura */ cdecl_struct(mxcfb_update_data_org) cdecl_const(MXCFB_SEND_UPDATE_ORG)
Fix typo so all arguments are loaded.
#include "js.h" int main(int argc, char **argv) { js_State *J; int i; J = js_newstate(); for (i = 1; i < argc; i++) { js_loadfile(J, argv[1]); // js_run(J); } js_close(J); return 0; }
#include "js.h" int main(int argc, char **argv) { js_State *J; int i; J = js_newstate(); for (i = 1; i < argc; i++) { js_loadfile(J, argv[i]); // js_run(J); } js_close(J); return 0; }
Add LinkList reverese using recursion and print using recursion
#include <stdio.h> #include <stdlib.h> /* Linked List Implementation in C */ // This program aims at "Revering the Link List" typedef struct node{ int data; struct node *link; } node; node* head; //global variable void insert_append(int x){ node* temp; temp = (node*)malloc(sizeof(node)); temp->data = x; temp->link=NULL; if(head!=NULL){ node* temp_travel; temp_travel =head; while(temp_travel->link != NULL){ temp_travel = temp_travel->link; } temp_travel->link = temp; return; } head =temp; return; } void reverse(node *current){ if(current->link == NULL){ head = current; return; } reverse(current->link); node* temp; temp = current->link; temp->link= current; current->link=NULL; return; } //This is recursive print void print(node* p){ if (p == NULL) { return; } printf(" %d",p->data); print(p->link); return; } int main(){ head = NULL; //empty list insert_append(1); //list is: 1 insert_append(2); //list is: 1 2 insert_append(3); //list is: 1 2 3 insert_append(4); //list is: 1 2 3 4 insert_append(5); //list is: 1 2 3 4 5 printf("list is:"); print(head); printf("\n"); reverse(head); //list is : 5 4 3 2 1 printf("Reverse list is:"); print(head); printf("\n"); return 0; }
Add inline C function to import and cache Python functions.
#ifndef NPY_IMPORT_H #define NPY_IMPORT_H #include <Python.h> #include <assert.h> /*! \brief Fetch and cache Python function. * * Import a Python function and cache it for use. The function checks if * cache is NULL, and if not NULL imports the Python function specified by * \a module and \a function, increments its reference count, and stores * the result in \a cache. Usually \a cache will be a static variable and * should be initialized to NULL. On error \a cache will contain NULL on * exit, * * @param module Absolute module name. * @param function Function name. * @param cache Storage location for imported function. */ NPY_INLINE void npy_cache_pyfunc(const char *module, const char *function, PyObject **cache) { if (*cache == NULL) { PyObject *mod = PyImport_ImportModule(module); if (mod != NULL) { *cache = PyObject_GetAttrString(mod, function); Py_DECREF(mod); } } } #endif
Add unsound dereferencing of unknown function pointer from ddverify pcwd
// PARAM: --disable sem.unknown_function.invalidate.globals --disable sem.unknown_function.spawn // extracted from ddverify pcwd // header declarations struct file_operations { void (*ioctl)(); }; struct miscdevice { struct file_operations *fops; }; struct cdev { struct file_operations *ops; }; // implementation stub struct ddv_cdev { struct cdev *cdevp; }; #define MAX_CDEV_SUPPORT 1 struct cdev fixed_cdev[MAX_CDEV_SUPPORT]; struct ddv_cdev cdev_registered[MAX_CDEV_SUPPORT]; int cdev_add(struct cdev *p) { cdev_registered[0].cdevp = p; return 0; } int misc_register(struct miscdevice *misc) { fixed_cdev[0].ops = misc->fops; return cdev_add(&fixed_cdev[0]); } void call_cdev_functions() { int cdev_no = 0; if (cdev_registered[cdev_no].cdevp->ops->ioctl) { (* cdev_registered[cdev_no].cdevp->ops->ioctl)(); } } // concrete program void pcwd_ioctl() { assert(1); // reachable } static const struct file_operations pcwd_fops = { .ioctl = pcwd_ioctl }; static struct miscdevice pcwd_miscdev = { .fops = &pcwd_fops }; int main() { misc_register(&pcwd_miscdev); void (*fp)(struct ddv_cdev*); // unknown function pointer fp(&cdev_registered); // invalidates argument! call_cdev_functions(); return 0; }
Use gtk_widget_show_all instead of just show
#include <gtk/gtk.h> #include "main-window.h" int main (int argc, char *argv[]) { GtkWidget *window; gtk_init(&argc, &argv); window = main_window_create(); gtk_widget_show(window); gtk_main(); return 0; }
#include <gtk/gtk.h> #include "main-window.h" int main (int argc, char *argv[]) { GtkWidget *window; gtk_init(&argc, &argv); window = main_window_create(); gtk_widget_show_all(window); gtk_main(); return 0; }
Change an old Option.h to Argument.h
/* ArgParser - C++ Argument Parser reflecting the python module ArgParse. Copyright (C) 2014-2015 Matthew Scott Krafczyk 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, 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, see <http://www.gnu.org/licenses/>. */ #ifndef ARGPARSE_ArgParse_HDR #define ARGPARSE_ArgParse_HDR #include "ArgParse/Message.h" #include "ArgParse/Option.h" #include "ArgParse/ArgParser.h" #endif
/* ArgParser - C++ Argument Parser reflecting the python module ArgParse. Copyright (C) 2014-2015 Matthew Scott Krafczyk 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, 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, see <http://www.gnu.org/licenses/>. */ #ifndef ARGPARSE_ArgParse_HDR #define ARGPARSE_ArgParse_HDR #include "ArgParse/Message.h" #include "ArgParse/Argument.h" #include "ArgParse/ArgParser.h" #endif
Fix asm generation with mlcd -a
#ifndef MLCD_COMMON_H #define MLCD_COMMON_H #define BYTE_TO_ASCII(byte) \ (byte & 0x80 ? '#' : ' '), \ (byte & 0x40 ? '#' : ' '), \ (byte & 0x20 ? '#' : ' '), \ (byte & 0x10 ? '#' : ' '), \ (byte & 0x08 ? '#' : ' '), \ (byte & 0x04 ? '#' : ' '), \ (byte & 0x02 ? '#' : ' '), \ (byte & 0x01 ? '#' : ' ') #define MLCD_WIDTH 48 #define MLCD_HEIGHT 32 #define MLCD_BYTES ((MLCD_WIDTH * MLCD_HEIGHT) / 8) #endif /* MLCD_COMMON_H */
#ifndef MLCD_COMMON_H #define MLCD_COMMON_H #define BYTE_TO_ASCII(byte) \ (byte & 0x80 ? '1' : '0'), \ (byte & 0x40 ? '1' : '0'), \ (byte & 0x20 ? '1' : '0'), \ (byte & 0x10 ? '1' : '0'), \ (byte & 0x08 ? '1' : '0'), \ (byte & 0x04 ? '1' : '0'), \ (byte & 0x02 ? '1' : '0'), \ (byte & 0x01 ? '1' : '0') #define MLCD_WIDTH 48 #define MLCD_HEIGHT 32 #define MLCD_BYTES ((MLCD_WIDTH * MLCD_HEIGHT) / 8) #endif /* MLCD_COMMON_H */
Use <> instead of ""
// // Use this file to import your target's public headers that you would like to expose to Swift. // #import "Konashi.h" #import "Colorkit.h" #import <EstimoteSDK/EstimoteSDK.h> #import "ActionSheetPicker.h"
// // Use this file to import your target's public headers that you would like to expose to Swift. // #import <Konashi.h> #import <Colorkit.h> #import <EstimoteSDK/EstimoteSDK.h> #import <ActionSheetPicker.h>
Fix for compiler error in r4154
/* * Copyright 2012 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkStippleMaskFilter_DEFINED #define SkStippleMaskFilter_DEFINED #include "SkMaskFilter.h" /** * Simple MaskFilter that creates a screen door stipple pattern */ class SkStippleMaskFilter : public SkMaskFilter { public: SkStippleMaskFilter() : INHERITED() { } virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkIPoint* margin) SK_OVERRIDE; // getFormat is from SkMaskFilter virtual SkMask::Format getFormat() SK_OVERRIDE { return SkMask::kA8_Format; } SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter); protected: SkStippleMaskFilter::SkStippleMaskFilter(SkFlattenableReadBuffer& buffer) : SkMaskFilter(buffer) { } private: typedef SkMaskFilter INHERITED; }; #endif // SkStippleMaskFilter_DEFINED
/* * Copyright 2012 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkStippleMaskFilter_DEFINED #define SkStippleMaskFilter_DEFINED #include "SkMaskFilter.h" /** * Simple MaskFilter that creates a screen door stipple pattern */ class SkStippleMaskFilter : public SkMaskFilter { public: SkStippleMaskFilter() : INHERITED() { } virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkIPoint* margin) SK_OVERRIDE; // getFormat is from SkMaskFilter virtual SkMask::Format getFormat() SK_OVERRIDE { return SkMask::kA8_Format; } SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter); protected: SkStippleMaskFilter(SkFlattenableReadBuffer& buffer) : SkMaskFilter(buffer) { } private: typedef SkMaskFilter INHERITED; }; #endif // SkStippleMaskFilter_DEFINED
Remove stuff moved to interrupts header
#pragma once #include <truth/types.h> // The state of the CPU before an interrupt occurs. struct cpu_state; // Interrupt Service Routine function signature. // ISRs with this signature are installed to a dispatch table. typedef void (isr_f)(struct cpu_state *); /* Install an interrupt handler. * The handler will have the interrupt number @num, and when triggered it will * execute @function. If @privileged is set to false, the interrupt will be * able to be raised by ring 3 code. If false, it will only be able to be * raised by ring 0 code. @return 0 if the interrupt is successfully installed * and -1 if that interrupt number has already been registered. */ int install_interrupt(uint8_t num, isr_f function); // Sets up CPU interrupt tables and initializes interrupts void interrupts_init(void); // Disable interrupts extern void disable_interrupts(void); // Enable interrupts extern void enable_interrupts(void); // Halt CPU extern void halt(void); // Gets the CPU time step counter value extern uint64_t cpu_time(void);
#pragma once #include <truth/types.h> // Halt CPU. extern void halt(void); // Gets the CPU time step counter value. extern uint64_t cpu_time(void); // Puts CPU into sleep state until awoken by interrupt. void cpu_sleep_state(void);
Store employee information in an array of structs
/* lab5.c: Employee records */ #include <stdio.h> #include <string.h> struct Employee { char last[16]; char first[11]; char title[16]; int salary; }; int main() { struct Employee employees[BUFSIZ]; for (int i = 0; i < BUFSIZ; i++) { printf("Enter the last name: "); fflush(stdout); /* To keep cursor on same line as prompt */ gets(employees[i].last); if (strlen(employees[i].last) > 0) { printf("Enter the first name: "); fflush(stdout); gets(employees[i].first); printf("Enter the job title: "); fflush(stdout); gets(employees[i].title); printf("Enter the salary: "); fflush(stdout); scanf("%d", &employees[i].salary); getchar(); /* eat newline */ } else { for (int j = 0; j < i; j++) { printf("%s %s, %s (%d)\n", employees[j].first, employees[j].last, employees[j].title, employees[j].salary); } break; } } }
Check that the mmap goes in the right place.
#include <fcntl.h> #include <stdio.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include "distributed.h" #include "stddefines.h" void shm_init() { int fd; /* Map the shmem region */ fd = open(SHM_DEV, O_RDWR); CHECK_ERROR(fd < 0); shm_base = mmap(SHM_LOC, SHM_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 1*getpagesize()); CHECK_ERROR(shm_base == MAP_FAILED); }
#include <fcntl.h> #include <stdio.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include "distributed.h" #include "stddefines.h" void shm_init() { int fd; /* Map the shmem region */ fd = open(SHM_DEV, O_RDWR); CHECK_ERROR(fd < 0); shm_base = mmap(SHM_LOC, SHM_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 1*getpagesize()); CHECK_ERROR(shm_base != SHM_LOC); }
Define __restrict__ and __restrict as synonyms for restrict.
#define _LP64 1 #define __8cc__ 1 #define __ELF__ 1 #define __LP64__ 1 #define __SIZEOF_DOUBLE__ 8 #define __SIZEOF_FLOAT__ 4 #define __SIZEOF_INT__ 4 #define __SIZEOF_LONG_DOUBLE__ 8 #define __SIZEOF_LONG_LONG__ 8 #define __SIZEOF_LONG__ 8 #define __SIZEOF_POINTER__ 8 #define __SIZEOF_PTRDIFF_T__ 8 #define __SIZEOF_SHORT__ 2 #define __SIZEOF_SIZE_T__ 8 #define __STDC_HOSTED__ 1 #define __STDC_NO_ATOMICS__ 1 #define __STDC_NO_COMPLEX__ 1 #define __STDC_NO_THREADS__ 1 #define __STDC_NO_VLA__ 1 #define __STDC_VERSION__ 201112L #define __STDC__ 1 #define __amd64 1 #define __amd64__ 1 #define __gnu_linux__ 1 #define __linux 1 #define __linux__ 1 #define __unix 1 #define __unix__ 1 #define __x86_64 1 #define __x86_64__ 1 #define linux 1
#define _LP64 1 #define __8cc__ 1 #define __ELF__ 1 #define __LP64__ 1 #define __SIZEOF_DOUBLE__ 8 #define __SIZEOF_FLOAT__ 4 #define __SIZEOF_INT__ 4 #define __SIZEOF_LONG_DOUBLE__ 8 #define __SIZEOF_LONG_LONG__ 8 #define __SIZEOF_LONG__ 8 #define __SIZEOF_POINTER__ 8 #define __SIZEOF_PTRDIFF_T__ 8 #define __SIZEOF_SHORT__ 2 #define __SIZEOF_SIZE_T__ 8 #define __STDC_HOSTED__ 1 #define __STDC_NO_ATOMICS__ 1 #define __STDC_NO_COMPLEX__ 1 #define __STDC_NO_THREADS__ 1 #define __STDC_NO_VLA__ 1 #define __STDC_VERSION__ 201112L #define __STDC__ 1 #define __amd64 1 #define __amd64__ 1 #define __gnu_linux__ 1 #define __linux 1 #define __linux__ 1 #define __unix 1 #define __unix__ 1 #define __x86_64 1 #define __x86_64__ 1 #define linux 1 #define __restrict restrict #define __restrict__ restrict
Add 'core' pseudo package for docgen to target.
/** library core Psuedo root of all pre-registered modules. This is a fake module created to link together all of the modules that are automatically loaded in the interpreter. Except for the `builtin` module, all modules listed here can be imported from any file inside of the interpreter. This is unlike other modules, which are loaded using relative paths. These modules can be imported like `import sys`, then used like `print(sys.argv)`. The `builtin` module is unique because the classes, enums, and functions are the foundation of the interpreter. Instead of requiring it to be imported, the contents of `builtin` are instead available without a namespace. */ /** PackageFiles lily_pkg_builtin.c lily_pkg_random.c lily_pkg_sys.c lily_pkg_time.c */
Fix another Linux build error
// Copyright 2015-2017 Directive Games Limited - All Rights Reserved #pragma once #include "JsonArchive.h" #include "IHttpRequest.h" #include "Core.h" #include "Interfaces/IHttpRequest.h" RAPIDJSON_API DECLARE_LOG_CATEGORY_EXTERN(JsonUtilsLog, Log, All); class RAPIDJSON_API JsonUtils { public: template<class T> static bool ParseResponse(FHttpResponsePtr response, T& parsed) { const auto respStr = response->GetContentAsString(); bool success = JsonArchive::LoadObject(*respStr, parsed); if (!success) { UE_LOG(JsonUtilsLog, Error, TEXT("Failed to parse json response '%s'"), *respStr); } return success; } };
// Copyright 2015-2017 Directive Games Limited - All Rights Reserved #pragma once #include "JsonArchive.h" #include "IHttpRequest.h" #include "Core.h" #include "Interfaces/IHttpRequest.h" #include "Interfaces/IHttpResponse.h" RAPIDJSON_API DECLARE_LOG_CATEGORY_EXTERN(JsonUtilsLog, Log, All); class RAPIDJSON_API JsonUtils { public: template<class T> static bool ParseResponse(FHttpResponsePtr response, T& parsed) { const auto respStr = response->GetContentAsString(); bool success = JsonArchive::LoadObject(*respStr, parsed); if (!success) { UE_LOG(JsonUtilsLog, Error, TEXT("Failed to parse json response '%s'"), *respStr); } return success; } };
Change documentation to fit return of NSNumber
// // OCTClient+Activity.h // OctoKit // // Created by Piet Brauer on 14.02.14. // Copyright (c) 2014 GitHub. All rights reserved. // #import "OCTClient.h" @class RACSignal; @class OCTRepository; @interface OCTClient (Activity) // Check if the user starred the `repository`. // // repository - The repository used to check the starred status. Cannot be nil. // // Returns a signal, which will send completed on success. If the client // is not `authenticated`, the signal will error immediately. - (RACSignal *)hasUserStarredRepository:(OCTRepository *)repository; // Star the given `repository` // // repository - The repository to star. Cannot be nil. // // Returns a signal, which will send completed on success. If the client // is not `authenticated`, the signal will error immediately. - (RACSignal *)starRepository:(OCTRepository *)repository; // Unstar the given `repository` // // repository - The repository to unstar. Cannot be nil. // // Returns a signal, which will send completed on success. If the client // is not `authenticated`, the signal will error immediately. - (RACSignal *)unstarRepository:(OCTRepository *)repository; @end
// // OCTClient+Activity.h // OctoKit // // Created by Piet Brauer on 14.02.14. // Copyright (c) 2014 GitHub. All rights reserved. // #import "OCTClient.h" @class RACSignal; @class OCTRepository; @interface OCTClient (Activity) // Check if the user starred the `repository`. // // repository - The repository used to check the starred status. Cannot be nil. // // Returns a signal, which will send a NSNumber valued @YES or @NO. // If the client is not `authenticated`, the signal will error immediately. - (RACSignal *)hasUserStarredRepository:(OCTRepository *)repository; // Star the given `repository` // // repository - The repository to star. Cannot be nil. // // Returns a signal, which will send completed on success. If the client // is not `authenticated`, the signal will error immediately. - (RACSignal *)starRepository:(OCTRepository *)repository; // Unstar the given `repository` // // repository - The repository to unstar. Cannot be nil. // // Returns a signal, which will send completed on success. If the client // is not `authenticated`, the signal will error immediately. - (RACSignal *)unstarRepository:(OCTRepository *)repository; @end
Add Appledoc to the header
#import <UIKit/UIKit.h> @interface BCBalancedMultilineLabel : UILabel @end
#import <UIKit/UIKit.h> /** * A simple label subclass that draws itself such that each of its * lines have as close to the same length as possible. It can be * used anywhere that you could use an ordinary `UILabel` by simply * changing the instantiated class. */ @interface BCBalancedMultilineLabel : UILabel @end
Set m_view to 0 in GlContext ctor
/* * Copyright 2011-2016 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ #ifndef BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD #define BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD #if BX_PLATFORM_OSX namespace bgfx { namespace gl { struct SwapChainGL; struct GlContext { GlContext() : m_context(0) { } void create(uint32_t _width, uint32_t _height); void destroy(); void resize(uint32_t _width, uint32_t _height, uint32_t _flags); uint64_t getCaps() const; SwapChainGL* createSwapChain(void* _nwh); void destroySwapChain(SwapChainGL* _swapChain); void swap(SwapChainGL* _swapChain = NULL); void makeCurrent(SwapChainGL* _swapChain = NULL); void import(); bool isValid() const { return 0 != m_context; } void* m_view; void* m_context; }; } /* namespace gl */ } // namespace bgfx #endif // BX_PLATFORM_OSX #endif // BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD
/* * Copyright 2011-2016 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ #ifndef BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD #define BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD #if BX_PLATFORM_OSX namespace bgfx { namespace gl { struct SwapChainGL; struct GlContext { GlContext() : m_context(0) , m_view(0) { } void create(uint32_t _width, uint32_t _height); void destroy(); void resize(uint32_t _width, uint32_t _height, uint32_t _flags); uint64_t getCaps() const; SwapChainGL* createSwapChain(void* _nwh); void destroySwapChain(SwapChainGL* _swapChain); void swap(SwapChainGL* _swapChain = NULL); void makeCurrent(SwapChainGL* _swapChain = NULL); void import(); bool isValid() const { return 0 != m_context; } void* m_view; void* m_context; }; } /* namespace gl */ } // namespace bgfx #endif // BX_PLATFORM_OSX #endif // BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD
Check that logassert() fails properly
#define UTL_MAIN #include "utl.h" int main(int argc, char *argv[]) { logopen("t_logassert.log","w"); logassert(5>10); logassert(utl_ret(0)); logcheck(3/utl_ret(0) == 0); logclose(); }
Fix @import compatibility with .mm files
// // Lottie.h // Pods // // Created by brandon_withrow on 1/27/17. // // @import Foundation; #ifndef Lottie_h #define Lottie_h //! Project version number for Lottie. FOUNDATION_EXPORT double LottieVersionNumber; //! Project version string for Lottie. FOUNDATION_EXPORT const unsigned char LottieVersionString[]; #import "LOTAnimationTransitionController.h" #import "LOTAnimationView.h" #endif /* Lottie_h */
// // Lottie.h // Pods // // Created by brandon_withrow on 1/27/17. // // #if __has_feature(modules) @import Foundation; #else #import <Foundation/Foundation.h> #endif #ifndef Lottie_h #define Lottie_h //! Project version number for Lottie. FOUNDATION_EXPORT double LottieVersionNumber; //! Project version string for Lottie. FOUNDATION_EXPORT const unsigned char LottieVersionString[]; #import "LOTAnimationTransitionController.h" #import "LOTAnimationView.h" #endif /* Lottie_h */
Add a benchmark for higher memory intensity
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> void nop( int delay ){ int tmp,i; for( i=0; i<delay; i++ ) tmp = i + tmp; } int main(int argc, char **argv) { int SEED = 2; int MEM_SIZE = 1024 * 1024; // *32 bits (number of ints) int DURATION = 6 * 1000 * 1000; //us int DELAY_OPS = 1000; //us between mem requests int count = 0; int opt; while( ( opt = getopt( argc, argv, "s:d:p:" ) ) != -1 ){ switch( opt ){ case 's': MEM_SIZE = 1024 * 1024 * atoi(optarg); // *32 MB break; case 'd': DURATION = atoi(optarg); // seconds break; case 'p': DELAY_OPS = atoi(optarg); // us break; default: break; } } int * mem = ( int* ) malloc( sizeof( int ) * MEM_SIZE ); int elapsed = 0; int tmp; srand( SEED ); while( elapsed < DURATION ){ int read_addr = count % MEM_SIZE; tmp = mem[read_addr]; elapsed += DELAY_OPS; count += 16; //nop(DELAY_OPS); } }
Add an example of code that uses failing_allocs.
#include "../failing_allocs.h" #include <assert.h> #include <stdlib.h> USE_FAILING_ALLOCS typedef struct{ int* some_ints; size_t count; } Container; Container* Container_create(size_t count) { Container* new_container = calloc(1, sizeof(Container)); if(!new_container) goto error; new_container->some_ints = malloc(5 * sizeof(int)); if(!new_container->some_ints) goto error; int* new_ints = realloc(new_container->some_ints, count * sizeof(int)); if(!new_ints) goto error; new_container->some_ints = new_ints; new_container->count = count; return new_container; error: if(new_container) { if(new_container->some_ints) free(new_container->some_ints); free(new_container); } return NULL; } void Container_delete(Container* container) { if(container) { if(container->some_ints) free(container->some_ints); free(container); } } int main(void) { int i = 0; for(i = 0; i < 10; i++) { Container* container = Container_create(100); if(!container) continue; assert(container->count == 100); Container_delete(container); } FREE_FAILING_ALLOCS return 0; }
Disable auto linking on windows so that CMake settings are not overriden.
#ifndef SOFAPYTHON_PYTHON_H #define SOFAPYTHON_PYTHON_H // This header simply includes Python.h, taking care of platform-specific stuff // It should be included before any standard headers: // "Since Python may define some pre-processor definitions which affect the // standard headers on some systems, you must include Python.h before any // standard headers are included." #if defined(_MSC_VER) && defined(_DEBUG) // undefine _DEBUG since we want to always link agains the release version of // python and pyconfig.h automatically links debug version if _DEBUG is defined. // ocarre: no we don't, in debug on Windows we cannot link with python release, if we want to build SofaPython in debug we have to compile python in debug //# undef _DEBUG # include <Python.h> //# define _DEBUG #elif defined(__APPLE__) && defined(__MACH__) # include <Python/Python.h> #else # include <Python.h> #endif #endif
#ifndef SOFAPYTHON_PYTHON_H #define SOFAPYTHON_PYTHON_H // This header simply includes Python.h, taking care of platform-specific stuff // It should be included before any standard headers: // "Since Python may define some pre-processor definitions which affect the // standard headers on some systems, you must include Python.h before any // standard headers are included." #if defined(_WIN32) # define MS_NO_COREDLL // deactivate pragma linking on Win32 done in Python.h #endif #if defined(_MSC_VER) && defined(_DEBUG) // undefine _DEBUG since we want to always link agains the release version of // python and pyconfig.h automatically links debug version if _DEBUG is defined. // ocarre: no we don't, in debug on Windows we cannot link with python release, if we want to build SofaPython in debug we have to compile python in debug //# undef _DEBUG # include <Python.h> //# define _DEBUG #elif defined(__APPLE__) && defined(__MACH__) # include <Python/Python.h> #else # include <Python.h> #endif #endif
Fix UI arrow artifact in Cross References and Search widgets.
#pragma once #include "uitypes.h" #include <QtWidgets/QToolButton> #include <QtCore/QParallelAnimationGroup> #include <QtWidgets/QScrollArea> #include <QtCore/QPropertyAnimation> class BINARYNINJAUIAPI ExpandableGroup : public QWidget { Q_OBJECT private: QToolButton* m_button; QParallelAnimationGroup* m_animation; QScrollArea* m_content; int m_duration = 100; private Q_SLOTS: void toggled(bool expanded); public: explicit ExpandableGroup( QLayout* contentLayout, const QString& title = "", QWidget* parent = nullptr, bool expanded = false); void setupAnimation(QLayout* contentLayout); void setTitle(const QString& title) { m_button->setText(title); } void toggle(bool expanded); };
#pragma once #include "uitypes.h" #include <QtWidgets/QLabel> #include <QtWidgets/QToolButton> #include <QtCore/QParallelAnimationGroup> #include <QtWidgets/QScrollArea> #include <QtCore/QPropertyAnimation> class BINARYNINJAUIAPI ExpandableGroup : public QWidget { Q_OBJECT private: QToolButton* m_button; QLabel* m_title; QParallelAnimationGroup* m_animation; QScrollArea* m_content; int m_duration = 100; private Q_SLOTS: void toggled(bool expanded); public: explicit ExpandableGroup(QLayout* contentLayout, const QString& title = "", QWidget* parent = nullptr, bool expanded = false); void setupAnimation(QLayout* contentLayout); void setTitle(const QString& title) { m_title->setText(title); } void toggle(bool expanded); };
Add wrapper for SDL2_image lib
/* The MIT License (MIT) Copyright (c) 2016 tagener-noisu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef SDL_IMAGE_WRAPPER_H #define SDL_IMAGE_WRAPPER_H 1 //------------------------------------------------------------------- #include <SDL_image.h> #include "wrapper/exceptions.h" //------------------------------------------------------------------- namespace SDL { namespace IMG { static_assert(SDL_IMAGE_MAJOR_VERSION == 2, "Only version 2.x of SDL_image is supported"); template<class ErrorHandler =Throw> class SdlImage { ErrorHandler handle_error; public: SdlImage(int flags =0) { if ((IMG_Init(flags) & flags) != flags) handle_error(SDL_GetError()); } ~SdlImage() { IMG_Quit(); } }; template<> class SdlImage<NoChecking> { int st; public: SdlImage(int flags =0) :st {IMG_Init(flags)} {} int state() const { return st; } ~SdlImage() { IMG_Quit(); } }; using SafeSdlImage = SdlImage<Throw>; using UnsafeSdlImage = SdlImage<NoChecking>; //------------------------------------------------------------------- inline SDL_Surface* Load(const char* file) { return IMG_Load(file); } } // namespace } // namespace //------------------------------------------------------------------- #endif
Improve [NSArray flatten] doc formatting
// // NSArray+EKFlatten.h // EnumeratorKit // // Created by Adam Sharp on 23/07/13. // Copyright (c) 2013 Adam Sharp. All rights reserved. // #import <Foundation/Foundation.h> #import "NSArray+EKEnumerable.h" /** * Extends NSArray with a single method `-flatten` to recursively * build a single-level array with all objects from all child arrays. */ @interface NSArray (EKFlatten) /** * Recursively builds a new array by adding all objects from all child * arrays. The order of children is preserved. For example: * * [@[@[@1, @2], @3] flatten] // => @[@1, @2, @3] * * and * * @[@1, @[@2, @[@3, @4]], @5, @[@6]] // => @[@1, @2, @3, @4, @5, @6] */ - (NSArray *)flatten; @end
// // NSArray+EKFlatten.h // EnumeratorKit // // Created by Adam Sharp on 23/07/13. // Copyright (c) 2013 Adam Sharp. All rights reserved. // #import <Foundation/Foundation.h> #import "NSArray+EKEnumerable.h" /** Extends NSArray with a single method `-flatten` to recursively build a single-level array with all objects from all child arrays. */ @interface NSArray (EKFlatten) /** Recursively builds a new array by adding all objects from all child arrays. The order of children is preserved. For example: [@[@[@1, @2], @3] flatten] // => @[@1, @2, @3] and @[@1, @[@2, @[@3, @4]], @5, @[@6]] // => @[@1, @2, @3, @4, @5, @6] */ - (NSArray *)flatten; @end
Adjust declaration for returning int
#ifndef IPC_H #define IPC_H #include "../process/process.h" void current_fds(proc_t *proc); #endif
#ifndef IPC_H #define IPC_H int current_fds(char *pidstr); #endif
Add constructor with title attached
#ifndef _ACTIONBAR_H_ #define _ACTIONBAR_H_ #include <InputElement.h> #include <Command.h> #include <FWPlatform.h> class ActionBar : public Element { public: ActionBar() { } bool isA(const std::string & className) override { if (className == "ActionBar") return true; return Element::isA(className); } protected: void initialize(FWPlatform * _platform) override { Element::initialize(_platform); Command c(Command::CREATE_ACTIONBAR, getParentInternalId(), getInternalId()); sendCommand(c); } }; #endif
#ifndef _ACTIONBAR_H_ #define _ACTIONBAR_H_ #include <InputElement.h> #include <Command.h> #include <FWPlatform.h> class ActionBar : public Element { public: ActionBar() { } ActionBar(const char * _title) : title(_title) { } bool isA(const std::string & className) override { if (className == "ActionBar") return true; return Element::isA(className); } protected: void initialize(FWPlatform * _platform) override { Element::initialize(_platform); Command c(Command::CREATE_ACTIONBAR, getParentInternalId(), getInternalId()); c.setTextValue(title); sendCommand(c); } const char * title; }; #endif