Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add basic test for integer constans
/* name: TEST022 description: Basic test for int constants comments: This test is done for z80 data types output: F1 G1 F1 main { - A2 I i A3 N u A2 #I1 :I A2 #IFFFF :I A2 #IFFFF :I A2 #IFFFF :I A2 #IFFFF :I A2 #I3 :I A2 #I1 :I A2 #I0 :I A3 #N1 :N A3 #NFFFF :N A3 #NFFFF :N A3 #NFFFF :N A3 #NFFFF :N A3 #N0 :N A3 #N3 :N A3 #N0 :N y #I0 } */ int main(void) { int i; unsigned u; i = 1; i = -1; i = -1l; i = -1u; i = -1ll; i = 32766 + 1 & 3; i = (int) 32768 < 0; i = -1u < 0; u = 1; u = -1; u = -1l; u = -1u; u = -1ll; u = (unsigned) 32768 < 0; u = 32766 + 1 & 3; u = -1u < 0; return 0; }
Fix a typo pointed about by gabor.
//===--- MacroBuilder.h - CPP Macro building utilitiy -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines the MacroBuilder utility class. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_MACROBUILDER_H #define LLVM_CLANG_BASIC_MACROBUILDER_H #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" namespace clang { class MacroBuilder { llvm::raw_ostream &Out; public: MacroBuilder(llvm::raw_ostream &Output) : Out(Output) {} /// Append a #define line for macro of the form "#define Name Value\n". void defineMacro(const llvm::Twine &Name, const llvm::Twine &Value = "1") { Out << "#define " << Name << ' ' << Value << '\n'; } /// Append a #undef line for Name. Name should be of the form XXX /// and we emit "#undef XXX". void undefineMacro(const llvm::Twine &Name) { Out << "#undef " << Name << '\n'; } /// Directly append Str and a newline to the underlying buffer. void append(const llvm::Twine &Str) { Out << Str << '\n'; } }; } // end namespace clang #endif
//===--- MacroBuilder.h - CPP Macro building utility ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines the MacroBuilder utility class. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_MACROBUILDER_H #define LLVM_CLANG_BASIC_MACROBUILDER_H #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" namespace clang { class MacroBuilder { llvm::raw_ostream &Out; public: MacroBuilder(llvm::raw_ostream &Output) : Out(Output) {} /// Append a #define line for macro of the form "#define Name Value\n". void defineMacro(const llvm::Twine &Name, const llvm::Twine &Value = "1") { Out << "#define " << Name << ' ' << Value << '\n'; } /// Append a #undef line for Name. Name should be of the form XXX /// and we emit "#undef XXX". void undefineMacro(const llvm::Twine &Name) { Out << "#undef " << Name << '\n'; } /// Directly append Str and a newline to the underlying buffer. void append(const llvm::Twine &Str) { Out << Str << '\n'; } }; } // end namespace clang #endif
Fix __BITS_PER_LONG value for x32 builds
#ifndef __ASM_X86_BITSPERLONG_H #define __ASM_X86_BITSPERLONG_H #ifdef __x86_64__ # define __BITS_PER_LONG 64 #else # define __BITS_PER_LONG 32 #endif #include <asm-generic/bitsperlong.h> #endif /* __ASM_X86_BITSPERLONG_H */
#ifndef __ASM_X86_BITSPERLONG_H #define __ASM_X86_BITSPERLONG_H #if defined(__x86_64__) && !defined(__ILP32__) # define __BITS_PER_LONG 64 #else # define __BITS_PER_LONG 32 #endif #include <asm-generic/bitsperlong.h> #endif /* __ASM_X86_BITSPERLONG_H */
ADD ui and text comps to menustate
#ifndef SSPAPPLICATION_GAMESTATES_MENUSTATE_H #define SSPAPPLICATION_GAMESTATES_MENUSTATE_H #include "GameState.h" class MenuState : public GameState { private: public: MenuState(); ~MenuState(); int ShutDown(); int Initialize(GameStateHandler* gsh, ComponentHandler* cHandler); int Update(float dt, InputHandler * inputHandler); private: }; #endif
#ifndef SSPAPPLICATION_GAMESTATES_MENUSTATE_H #define SSPAPPLICATION_GAMESTATES_MENUSTATE_H #include "GameState.h" #include "../GraphicsDLL/GraphicsComponent.h" class MenuState : public GameState { private: const static int m_NR_OF_MENU_ITEMS = 2; UIComponent* m_uiComps[NR_OF_MENU_ITEMS]; TextComponent* m_textComps[NR_OF_MENU_ITEMS]; public: MenuState(); ~MenuState(); int ShutDown(); int Initialize(GameStateHandler* gsh, ComponentHandler* cHandler); int Update(float dt, InputHandler * inputHandler); private: }; #endif
Fix compilation error when disabling zlib support
#ifndef DSMCC_COMPRESS_H #define DSMCC_COMPRESS_H #include <stdbool.h> #include "dsmcc-config.h" #include "dsmcc-debug.h" #ifdef HAVE_ZLIB bool dsmcc_inflate_file(const char *filename); #else static inline bool dsmcc_inflate_file(const char *filename) { DSMCC_ERROR("Compression support is disabled in this build"); return false; } #endif #endif /* DSMCC_COMPRESS_H */
#ifndef DSMCC_COMPRESS_H #define DSMCC_COMPRESS_H #include <stdbool.h> #include "dsmcc-config.h" #include "dsmcc-debug.h" #ifdef HAVE_ZLIB bool dsmcc_inflate_file(const char *filename); #else static inline bool dsmcc_inflate_file(const char *filename) { (void) filename; DSMCC_ERROR("Compression support is disabled in this build"); return false; } #endif #endif /* DSMCC_COMPRESS_H */
Test inability to inline certain functions
// RUN: %check -e %s #define always_inline __attribute((always_inline)) always_inline hidden(int); void always_inline __attribute((noinline)) noinline(void) { } always_inline void print(const char *fmt, ...) { } always_inline void old(a, b) int a, b; { } always_inline void addr(int x) { int *p = &x; *p = 3; } always_inline void write(int x) { x++; } always_inline void rec(int depth) { if(depth < 5) rec(depth + 1); // CHECK: can't always_inline function: can't see function } always_inline int should_inline() { return 3; } main() { should_inline(); // CHECK: !/warn|error/ rec(0); // CHECK: !/warn|error/ hidden(3); // CHECK: error: can't always_inline function: can't see function noinline(); // CHECK: error: can't always_inline noinline function print("hi", 3); // CHECK: error: can't always_inline function: variadic function print("hi"); // CHECK: error: can't always_inline function: variadic function old(3, 1); // CHECK: error: can't always_inline function: unspecified argument count function addr(5); // CHECK: error: can't always_inline function: argument written or addressed write(2); // CHECK: error: can't always_inline function: argument written or addressed }
Load balance & foreign message queue refactored.
#include "./p7r_api.h" #include "./p7r_root_alloc.h" static struct p7r_poolized_meta { int startup_channel[2]; } meta_singleton; static void p7r_poolized_main_entrance(void *argument) { struct p7r_poolized_meta *meta = argument; struct p7r_delegation channel_hint; for (;;) { channel_hint = p7r_delegate(P7R_DELEGATION_READ, meta->startup_channel[0]); // XXX currently do nothing - 'tis wrong for fd under LT mode, so we write nothing to startup channel for now } } int p7r_poolize(struct p7r_config config) { if (pipe(meta_singleton.startup_channel) == -1) return -1; int ret = p7r_init(config); if (ret < 0) return close(meta_singleton.startup_channel[0]), close(meta_singleton.startup_channel[1]), ret; return p7r_poolized_main_entrance(&meta_singleton), 0; }
#include "./p7r_api.h" #include "./p7r_root_alloc.h" static struct p7r_poolized_meta { int startup_channel[2]; } meta_singleton; static void p7r_poolized_main_entrance(void *argument) { struct p7r_poolized_meta *meta = argument; struct p7r_delegation channel_hint; for (;;) { channel_hint = p7r_delegate(P7R_DELEGATION_READ, meta->startup_channel[0]); // XXX currently do nothing - 'tis wrong for fd under LT mode, so we write nothing to startup channel for now } } static int p7r_poolize(struct p7r_config config) { if (pipe(meta_singleton.startup_channel) == -1) return -1; int ret = p7r_init(config); if (ret < 0) return close(meta_singleton.startup_channel[0]), close(meta_singleton.startup_channel[1]), ret; return p7r_poolized_main_entrance(&meta_singleton), 0; }
Change safety guard to PATH_MAX because Solaris doesn't know NAME_MAX
/* ISC license. */ #include <limits.h> #include <string.h> #include <sys/stat.h> #include <errno.h> #include <s6-rc/s6rc-utils.h> int s6rc_livedir_prefixsize (char const *live, size_t *n) { struct stat st ; size_t llen = strlen(live) ; char sfn[llen + 8] ; memcpy(sfn, live, llen) ; memcpy(sfn + llen, "/prefix", 8) ; if (stat(sfn, &st) < 0) { if (errno != ENOENT) return 0 ; *n = 0 ; return 1 ; } if (!S_ISREG(st.st_mode)) return (errno = EINVAL, 0) ; if (st.st_size > NAME_MAX) return (errno = ENAMETOOLONG, 0) ; *n = st.st_size ; return 1 ; }
/* ISC license. */ #include <limits.h> #include <string.h> #include <sys/stat.h> #include <errno.h> #include <s6-rc/s6rc-utils.h> int s6rc_livedir_prefixsize (char const *live, size_t *n) { struct stat st ; size_t llen = strlen(live) ; char sfn[llen + 8] ; memcpy(sfn, live, llen) ; memcpy(sfn + llen, "/prefix", 8) ; if (stat(sfn, &st) < 0) { if (errno != ENOENT) return 0 ; *n = 0 ; return 1 ; } if (!S_ISREG(st.st_mode)) return (errno = EINVAL, 0) ; if (st.st_size > PATH_MAX) return (errno = ENAMETOOLONG, 0) ; *n = st.st_size ; return 1 ; }
Fix overflow in test case
struct test { int a[3]; char b[2]; long c; }; int sum(struct test *t) { int sum = 0; sum += t->a[0] + t->a[1] + t->a[2]; sum += t->b[0] + t->b[1] + t->b[2]; sum += t->c; return sum; } int main() { struct test t1 = { .a = { 1, 2, 3 }, .b = { 'a', 'c' }, .c = -1 }; struct test t2 = t1; t2.b[0] = 32; t2.a[0] = 12; t2.a[2] = 1; return (sum(&t1) + sum(&t2)) % 256; }
struct test { int a[3]; char b[2]; long c; }; int sum(struct test *t) { int sum = 0; sum += t->a[0] + t->a[1] + t->a[2]; sum += t->b[0] + t->b[1]; sum += t->c; return sum; } int main() { struct test t1 = { .a = { 1, 2, 3 }, .b = { 'a', 'c' }, .c = -1 }; struct test t2 = t1; t2.b[0] = 32; t2.a[0] = 12; t2.a[2] = 1; return (sum(&t1) + sum(&t2)) % 256; }
Add Error handring to removePointsByRange()
#ifndef POINTS_DOWNSAMPLER_H #define POINTS_DOWNSAMPLER_H static pcl::PointCloud<pcl::PointXYZI> removePointsByRange(pcl::PointCloud<pcl::PointXYZI> scan, double min_range, double max_range) { pcl::PointCloud<pcl::PointXYZI> narrowed_scan; narrowed_scan.header = scan.header; double square_min_range = min_range * min_range; double square_max_range = max_range * max_range; for(pcl::PointCloud<pcl::PointXYZI>::const_iterator iter = scan.begin(); iter != scan.end(); ++iter) { const pcl::PointXYZI &p = *iter; // p.x = iter->x; // p.y = iter->y; // p.z = iter->z; // p.intensity = iter->intensity; double square_distance = p.x * p.x + p.y * p.y; if(square_min_range <= square_distance && square_distance <= square_max_range){ narrowed_scan.points.push_back(p); } } #if 1 return narrowed_scan; #else return scan; // This is a only tempolary patch for Localization problem. #endif } #endif // POINTS_DOWNSAMPLER_H
#ifndef POINTS_DOWNSAMPLER_H #define POINTS_DOWNSAMPLER_H static pcl::PointCloud<pcl::PointXYZI> removePointsByRange(pcl::PointCloud<pcl::PointXYZI> scan, double min_range, double max_range) { pcl::PointCloud<pcl::PointXYZI> narrowed_scan; narrowed_scan.header = scan.header; #if 1 // This error handling should be detemind. if( min_range>=max_range ) { ROS_ERROR_ONCE("min_range>=max_range @(%lf, %lf)", min_range, max_range ); return scan; } #endif double square_min_range = min_range * min_range; double square_max_range = max_range * max_range; for(pcl::PointCloud<pcl::PointXYZI>::const_iterator iter = scan.begin(); iter != scan.end(); ++iter) { const pcl::PointXYZI &p = *iter; // p.x = iter->x; // p.y = iter->y; // p.z = iter->z; // p.intensity = iter->intensity; double square_distance = p.x * p.x + p.y * p.y; if(square_min_range <= square_distance && square_distance <= square_max_range){ narrowed_scan.points.push_back(p); } } return narrowed_scan; } #endif // POINTS_DOWNSAMPLER_H
Allow specifyign hackc compiler id with C define
/** * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the "hack" directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #define CAML_NAME_SPACE #include <caml/memory.h> #include <caml/alloc.h> #include <string.h> #include "hphp/util/embedded-data.h" #define BUF_SIZE 64 static const char section_name[] = "build_id"; static const char default_id[] = "hackc-unknown-version"; value hh_get_compiler_id(void) { CAMLparam0(); char buf[BUF_SIZE]; ssize_t len = hphp_read_embedded_data(section_name, buf, BUF_SIZE); value result; if (len < 0) { result = caml_alloc_string(strlen(default_id)); memcpy(String_val(result), default_id, strlen(default_id)); CAMLreturn(result); } else { result = caml_alloc_string(len); memcpy(String_val(result), buf, len); CAMLreturn(result); } }
/** * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the "hack" directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #define CAML_NAME_SPACE #include <caml/memory.h> #include <caml/alloc.h> #include <string.h> #include "hphp/util/embedded-data.h" #define BUF_SIZE 64 static const char section_name[] = "build_id"; static const char default_id[] = "hackc-unknown-version"; #define STRINGIFY_HELPER(x) #x #define STRINGIFY_VALUE(x) STRINGIFY_HELPER(x) value hh_get_compiler_id(void) { CAMLparam0(); #ifdef HACKC_COMPILER_ID const char buf[] = STRINGIFY_VALUE(HACKC_COMPILER_ID); const ssize_t len = sizeof(buf) - 1; #else char buf[BUF_SIZE]; const ssize_t len = hphp_read_embedded_data(section_name, buf, BUF_SIZE); #endif value result; if (len < 0) { result = caml_alloc_string(strlen(default_id)); memcpy(String_val(result), default_id, strlen(default_id)); CAMLreturn(result); } else { result = caml_alloc_string(len); memcpy(String_val(result), buf, len); CAMLreturn(result); } }
Move the structure definition on a better place
/** Author : Paul TREHIOU & Victor SENE * Date : November 2014 **/ /** * Declaration Point structure * x - real wich is the abscisse of the point * y - real wich is the ordinate of the point */ typedef struct { float x; float y; }Point; /** * Function wich create a point with a specified abscisse and ordinate * abscisse - real * ordinate - real * return a new point */ Point createPoint(float abscisse, float ordinate); /** * Declaration of the Element structure * value - value of the point of the current element of the polygon * next - pointer on the next element * previous - pointer on the previous element */ typedef struct pointelem{ Point value; pointelem* next; pointelem* previous; }PointElement; /** * Declaration of the Polygon */ typedef PointElement* Polygon;
/** Author : Paul TREHIOU & Victor SENE * Date : November 2014 **/ /** * Declaration Point structure * x - real wich is the abscisse of the point * y - real wich is the ordinate of the point */ typedef struct { float x; float y; }Point; /** * Declaration of the Element structure * value - value of the point of the current element of the polygon * next - pointer on the next element * previous - pointer on the previous element */ typedef struct pointelem{ Point value; pointelem* next; pointelem* previous; }PointElement; /** * Declaration of the Polygon */ typedef PointElement* Polygon; /** * Function wich create a point with a specified abscisse and ordinate * abscisse - real * ordinate - real * return a new point */ Point createPoint(float abscisse, float ordinate);
Fix for GCC 4.6 compatibility
#ifndef OPTIONFIELDPAIRS_H #define OPTIONFIELDPAIRS_H #include "optioni.h" typedef std::pair<std::string, std::string> FieldPair; typedef std::vector<FieldPair> FieldPairs; class OptionFieldPairs : public OptionI<std::vector<std::pair<std::string, std::string> > > { public: OptionFieldPairs(std::string name); virtual Json::Value asJSON() const override; virtual void set(Json::Value &value) override; }; #endif // OPTIONFIELDPAIRS_H
#ifndef OPTIONFIELDPAIRS_H #define OPTIONFIELDPAIRS_H #include "optioni.h" #include "common.h" typedef std::pair<std::string, std::string> FieldPair; typedef std::vector<FieldPair> FieldPairs; class OptionFieldPairs : public OptionI<std::vector<std::pair<std::string, std::string> > > { public: OptionFieldPairs(std::string name); virtual Json::Value asJSON() const OVERRIDE; virtual void set(Json::Value &value) OVERRIDE; }; #endif // OPTIONFIELDPAIRS_H
Change some function prototypes around
#include "opt.h" CorkOpt * corkopt_init(int argc, char *argv[]) { CorkOpt *co; if ((co = malloc(sizeof(CorkOpt))) == NULL) return NULL; co->argc = argc; co->argv = argv; return co; } static void corkopt_fini(CorkOpt *co) { } void corkopt_add(CorkOpt *co, int shortopt, const char *longopt, const char *helptext, const int flags) { CorkOptElement *coe; if ((coe = malloc(sizeof(CorkOptElement))) == NULL) return; coe->short_opt = shortopt; coe->long_opt = longopt; coe->help_text = helptext; coe->flags = flags; corklist_append(co->opts, coe); return; }
#include "opt.h" CorkOpt * corkopt_init(void) { CorkOpt *co; if ((co = malloc(sizeof(CorkOpt))) == NULL) return NULL; co->args = corklist_create(); return co; } void corkopt_fini(CorkOpt *co) { } void corkopt_add(CorkOpt *co, int shortopt, const char *longopt, const char *helptext, const int flags) { CorkOptElement *coe; if ((coe = malloc(sizeof(CorkOptElement))) == NULL) return; coe->short_opt = shortopt; coe->long_opt = longopt; coe->help_text = helptext; coe->flags = flags; corklist_append(co->opts, coe); return; }
Use the option "+" to force the new style Streamer for all classes in bench.
#ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class THit!+; #pragma link C++ class TObjHit+; #pragma link C++ class TSTLhit; #pragma link C++ class TSTLhitList; #pragma link C++ class TSTLhitDeque; #pragma link C++ class TSTLhitSet; #pragma link C++ class TSTLhitMultiset; #pragma link C++ class TSTLhitMap; #pragma link C++ class TSTLhitMultiMap; //#pragma link C++ class TSTLhitHashSet; //#pragma link C++ class TSTLhitHashMultiset; #pragma link C++ class pair<int,THit>; #pragma link C++ class TSTLhitStar; #pragma link C++ class TSTLhitStarList; #pragma link C++ class TSTLhitStarDeque; #pragma link C++ class TSTLhitStarSet; #pragma link C++ class TSTLhitStarMultiSet; #pragma link C++ class TSTLhitStarMap; #pragma link C++ class TSTLhitStarMultiMap; #pragma link C++ class pair<int,THit*>; #pragma link C++ class TCloneshit+; #endif
#ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class THit!+; #pragma link C++ class TObjHit+; #pragma link C++ class TSTLhit+; #pragma link C++ class TSTLhitList+; #pragma link C++ class TSTLhitDeque+; #pragma link C++ class TSTLhitSet+; #pragma link C++ class TSTLhitMultiset+; #pragma link C++ class TSTLhitMap+; #pragma link C++ class TSTLhitMultiMap+; //#pragma link C++ class TSTLhitHashSet; //#pragma link C++ class TSTLhitHashMultiset; #pragma link C++ class pair<int,THit>+; #pragma link C++ class TSTLhitStar+; #pragma link C++ class TSTLhitStarList+; #pragma link C++ class TSTLhitStarDeque+; #pragma link C++ class TSTLhitStarSet+; #pragma link C++ class TSTLhitStarMultiSet+; #pragma link C++ class TSTLhitStarMap+; #pragma link C++ class TSTLhitStarMultiMap+; #pragma link C++ class pair<int,THit*>+; #pragma link C++ class TCloneshit+; #endif
Make Job::cancel and Job::pause public slots
// vim:cindent:cino=\:0:et:fenc=utf-8:ff=unix:sw=4:ts=4: #ifndef CONVEYOR_JOB_H #define CONVEYOR_JOB_H (1) #include <QList> #include <QObject> #include <QScopedPointer> #include <QString> #include <conveyor/fwd.h> #include <conveyor/jobstatus.h> namespace conveyor { class Job : public QObject { Q_OBJECT public: ~Job (void); int id (void) const; QString name (void) const; JobState state (void) const; JobConclusion conclusion (void) const; int currentStepProgress (void) const; QString currentStepName (void) const; void cancel (void); void pause (void); signals: void changed (const Job *); private: Job (Conveyor * conveyor, int const & id); QScopedPointer <JobPrivate> m_private; void emitChanged (void); friend class Conveyor; friend class ConveyorPrivate; friend class JobAddedMethod; friend class JobChangedMethod; friend class JobPrivate; friend class Printer; friend class PrinterPrivate; }; } #endif
// vim:cindent:cino=\:0:et:fenc=utf-8:ff=unix:sw=4:ts=4: #ifndef CONVEYOR_JOB_H #define CONVEYOR_JOB_H (1) #include <QList> #include <QObject> #include <QScopedPointer> #include <QString> #include <conveyor/fwd.h> #include <conveyor/jobstatus.h> namespace conveyor { class Job : public QObject { Q_OBJECT public: ~Job (void); int id (void) const; QString name (void) const; JobState state (void) const; JobConclusion conclusion (void) const; int currentStepProgress (void) const; QString currentStepName (void) const; public slots: void cancel (void); void pause (void); signals: void changed (const Job *); private: Job (Conveyor * conveyor, int const & id); QScopedPointer <JobPrivate> m_private; void emitChanged (void); friend class Conveyor; friend class ConveyorPrivate; friend class JobAddedMethod; friend class JobChangedMethod; friend class JobPrivate; friend class Printer; friend class PrinterPrivate; }; } #endif
Add more rationale as to how this exception is different from others.
//--------------------------------------------------------------------*- C++ -*- // CLING - the C++ LLVM-based InterpreterG :) // author: Axel Naumann <axel@cern.ch> //------------------------------------------------------------------------------ #ifndef CLING_COMPILATIONEXCEPTION_H #define CLING_COMPILATIONEXCEPTION_H #include <stdexcept> #include <string> #include "cling/Interpreter/RuntimeException.h" namespace cling { class Interpreter; class MetaProcessor; //\brief Exception pull us out of JIT (llvm + clang) errors. class CompilationException: public virtual runtime::InterpreterException, public virtual std::runtime_error { public: CompilationException(const std::string& reason): std::runtime_error(reason) {} ~CompilationException() throw(); // vtable pinned to UserInterface.cpp virtual const char* what() const throw() { return std::runtime_error::what(); } }; } #endif // CLING_COMPILATIONEXCEPTION_H
//--------------------------------------------------------------------*- C++ -*- // CLING - the C++ LLVM-based InterpreterG :) // author: Axel Naumann <axel@cern.ch> //------------------------------------------------------------------------------ #ifndef CLING_COMPILATIONEXCEPTION_H #define CLING_COMPILATIONEXCEPTION_H #include <stdexcept> #include <string> #include "cling/Interpreter/RuntimeException.h" namespace cling { class Interpreter; class MetaProcessor; ///\brief Exception that pulls cling out of runtime-compilation (llvm + clang) /// errors. /// /// If user code provokes an llvm::unreachable it will cause this exception /// to be thrown. Given that this is at the process's runtime and an /// interpreter error it inherits from InterpreterException and runtime_error. /// Note that this exception is *not* thrown during the execution of the /// user's code but during its compilation (at runtime). class CompilationException: public virtual runtime::InterpreterException, public virtual std::runtime_error { public: CompilationException(const std::string& reason): std::runtime_error(reason) {} ~CompilationException() throw(); // vtable pinned to UserInterface.cpp virtual const char* what() const throw() { return std::runtime_error::what(); } }; } #endif // CLING_COMPILATIONEXCEPTION_H
Mark this test as requiring and x86 registered target.
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -o - #define __MM_MALLOC_H #include <x86intrin.h> // No warnings. extern __m256i a; int __attribute__((target("avx"))) bar(__m256i a) { return _mm256_extract_epi32(a, 3); } int baz() { return bar(a); } int __attribute__((target("avx"))) qq_avx(__m256i a) { return _mm256_extract_epi32(a, 3); } int qq_noavx() { return 0; } extern __m256i a; int qq() { if (__builtin_cpu_supports("avx")) return qq_avx(a); else return qq_noavx(); }
// REQUIRES: x86-registered-target // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -o - #define __MM_MALLOC_H #include <x86intrin.h> // No warnings. extern __m256i a; int __attribute__((target("avx"))) bar(__m256i a) { return _mm256_extract_epi32(a, 3); } int baz() { return bar(a); } int __attribute__((target("avx"))) qq_avx(__m256i a) { return _mm256_extract_epi32(a, 3); } int qq_noavx() { return 0; } extern __m256i a; int qq() { if (__builtin_cpu_supports("avx")) return qq_avx(a); else return qq_noavx(); }
Enable 64 bit atomics on ARM64.
/*------------------------------------------------------------------------- * * arch-arm.h * Atomic operations considerations specific to ARM * * Portions Copyright (c) 2013-2017, PostgreSQL Global Development Group * * NOTES: * * src/include/port/atomics/arch-arm.h * *------------------------------------------------------------------------- */ /* intentionally no include guards, should only be included by atomics.h */ #ifndef INSIDE_ATOMICS_H #error "should be included via atomics.h" #endif /* * 64 bit atomics on arm are implemented using kernel fallbacks and might be * slow, so disable entirely for now. * XXX: We might want to change that at some point for AARCH64 */ #define PG_DISABLE_64_BIT_ATOMICS
/*------------------------------------------------------------------------- * * arch-arm.h * Atomic operations considerations specific to ARM * * Portions Copyright (c) 2013-2017, PostgreSQL Global Development Group * * NOTES: * * src/include/port/atomics/arch-arm.h * *------------------------------------------------------------------------- */ /* intentionally no include guards, should only be included by atomics.h */ #ifndef INSIDE_ATOMICS_H #error "should be included via atomics.h" #endif /* * 64 bit atomics on ARM32 are implemented using kernel fallbacks and thus * might be slow, so disable entirely. On ARM64 that problem doesn't exist. */ #if !defined(__aarch64__) && !defined(__aarch64) #define PG_DISABLE_64_BIT_ATOMICS #endif /* __aarch64__ || __aarch64 */
Rename and don't spit out all the sanity output when running on the CI server.
#include "unity.h" #include "unity_fixture.h" #include "Utils/IO/ArrayIO.h" #include "Utils/IO/BlockMapIO.h" #include "Utils/IO/ImageIO.h" #include "Utils/IO/HistogramIO.h" #include <stdio.h> #include <stdlib.h> bool IsUnderCI = false ; TEST_GROUP(DataStructures); TEST_SETUP(DataStructures) { IsUnderCI = (getenv("CI") != NULL); } TEST_TEAR_DOWN(DataStructures) { } TEST(DataStructures, BlockMap_SanityCheck) { BlockMap blockMap = BlockMapIO_ConstructFromFile("DataStructures/101_1.tif.12.Equalize.blocks.dat"); if (!IsUnderCI) { BlockMapIO_Printf(&blockMap); } } TEST(DataStructures, Image_SanityCheck) { UInt8Array2D image = ImageIO_ConstructFromFile("DataStructures/101_1.tif.12.Equalize.image.dat"); if (!IsUnderCI) { ImageIO_Printf(&image); } } TEST(DataStructures, Histogram_SanityCheck) { Int16Array3D histogram = HistogramIO_ConstructFromFile("DataStructures/101_1.tif.12.Equalize.histgram.dat"); if (!IsUnderCI) { HistogramIO_Printf(&histogram); } }
Set correct name for boost IPC
#ifndef QTIPCSERVER_H #define QTIPCSERVER_H // Define Bitcoin-Qt message queue name #define BITCOINURI_QUEUE_NAME "BitcoinURI" void ipcScanRelay(int argc, char *argv[]); void ipcInit(int argc, char *argv[]); #endif // QTIPCSERVER_H
#ifndef QTIPCSERVER_H #define QTIPCSERVER_H // Define Bitcoin-Qt message queue name #define BITCOINURI_QUEUE_NAME "CrainCoinURI" void ipcScanRelay(int argc, char *argv[]); void ipcInit(int argc, char *argv[]); #endif // QTIPCSERVER_H
Adjust for sigset_t to intrmask_t renaming.
/* libunwind - a platform-independent unwind library Copyright (c) 2004-2005 Hewlett-Packard Development Company, L.P. Contributed by David Mosberger-Tang <davidm@hpl.hp.com> This file is part of libunwind. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "unwind_i.h" HIDDEN pthread_mutex_t hppa_lock = PTHREAD_MUTEX_INITIALIZER; HIDDEN int tdep_needs_initialization = 1; HIDDEN void tdep_init (void) { intrmask_t saved_mask; sigfillset (&unwi_full_mask); sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask); mutex_lock (&hppa_lock); { if (!tdep_needs_initialization) /* another thread else beat us to it... */ goto out; mi_init (); dwarf_init (); #ifndef UNW_REMOTE_ONLY hppa_local_addr_space_init (); #endif tdep_needs_initialization = 0; /* signal that we're initialized... */ } out: mutex_unlock (&hppa_lock); sigprocmask (SIG_SETMASK, &saved_mask, NULL); }
Add BST Pre/Post order walk 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); BSTNode* BSTNode_Create(void* k); void BST_Inorder_Tree_Walk(BST* T, void (f)(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); void BST_Inorder_Tree_Walk(BST* T, void (f)(void*)); void BST_Preorder_Tree_Walk(BST* T, void (f)(void*)); void BST_Postorder_Tree_Walk(BST* T, void (f)(void*)); #endif
Extend size of text in Message
// Copyright 2014-2016 the project authors as listed in the AUTHORS file. // All rights reserved. Use of this source code is governed by the // license that can be found in the LICENSE file. #ifndef _MESSAGE_QUEUE #define _MESSAGE_QUEUE // note that on the arduino we have to be careful of how much memory we // use so the depth of the message queue needs to be kept small #define MAX_MESSAGES 8 #define MAX_MESSAGE_TEXT_LENGTH 32 typedef struct Message { void* device; int type; long timestamp; unsigned long code; float value; char text[MAX_MESSAGE_TEXT_LENGTH]; Message* next; } Message; class MessageQueue { private: Message messages[MAX_MESSAGES]; Message* newMessages; Message* freeMessages; public: MessageQueue(void); Message* getFreeMessage(void); void enqueueMessage(Message* message); Message* dequeueMessages(void); void returnMessages(Message* messages, Message* lastMessage); }; #endif
// Copyright 2014-2016 the project authors as listed in the AUTHORS file. // All rights reserved. Use of this source code is governed by the // license that can be found in the LICENSE file. #ifndef _MESSAGE_QUEUE #define _MESSAGE_QUEUE // note that on the arduino we have to be careful of how much memory we // use so the depth of the message queue needs to be kept small #define MAX_MESSAGES 8 #define MAX_MESSAGE_TEXT_LENGTH 64 typedef struct Message { void* device; int type; long timestamp; unsigned long code; float value; char text[MAX_MESSAGE_TEXT_LENGTH]; Message* next; } Message; class MessageQueue { private: Message messages[MAX_MESSAGES]; Message* newMessages; Message* freeMessages; public: MessageQueue(void); Message* getFreeMessage(void); void enqueueMessage(Message* message); Message* dequeueMessages(void); void returnMessages(Message* messages, Message* lastMessage); }; #endif
Add line break in default error formatter
#ifndef BANDIT_DEFAULT_FAILURE_FORMATTER_H #define BANDIT_DEFAULT_FAILURE_FORMATTER_H namespace bandit { namespace detail { struct default_failure_formatter : public failure_formatter { std::string format(const assertion_exception& err) const { std::stringstream ss; if(err.file_name().size()) { ss << err.file_name(); if(err.line_number()) { ss << ":" << err.line_number(); } ss << ": "; } ss << err.what(); return ss.str(); } }; }} #endif
#ifndef BANDIT_DEFAULT_FAILURE_FORMATTER_H #define BANDIT_DEFAULT_FAILURE_FORMATTER_H namespace bandit { namespace detail { struct default_failure_formatter : public failure_formatter { std::string format(const assertion_exception& err) const { std::stringstream ss; if(err.file_name().size()) { ss << err.file_name(); if(err.line_number()) { ss << ":" << err.line_number(); } ss << ": "; } ss << std::endl << err.what(); return ss.str(); } }; }} #endif
Change defined(_HF_ARCH_LINUX) -> defined(__linux__) for public includes
#ifdef __cplusplus extern "C" { #endif /* * buf: input fuzzing data * len: size of the 'buf' data * * Return value: should return 0 */ int LLVMFuzzerTestOneInput(const uint8_t * buf, size_t len); /* * argc: ptr to main's argc * argv: ptr to main's argv * * Return value: ignored */ int LLVMFuzzerInitialize(int *argc, char ***argv); /* * * An alternative for LLVMFuzzerTestOneInput() * * buf_ptr: will be set to input fuzzing data * len_ptr: will be set to the size of the input fuzzing data */ void HF_ITER(const uint8_t ** buf_ptr, size_t * len_ptr); #if defined(_HF_ARCH_LINUX) /* * Enter Linux namespaces * * cloneFlags: see 'man unshare' */ bool linuxEnterNs(uintptr_t cloneFlags); /* * Bring network interface up * * ifacename: name of the interface, typically "lo" */ bool linuxIfaceUp(const char *ifacename); /* * Mount tmpfs over a mount point * * dst: mount point for tmfs */ bool linuxMountTmpfs(const char *dst); #endif /* defined(_HF_ARCH_LINUX) */ #ifdef __cplusplus } /* extern "C" */ #endif
#ifdef __cplusplus extern "C" { #endif /* * buf: input fuzzing data * len: size of the 'buf' data * * Return value: should return 0 */ int LLVMFuzzerTestOneInput(const uint8_t * buf, size_t len); /* * argc: ptr to main's argc * argv: ptr to main's argv * * Return value: ignored */ int LLVMFuzzerInitialize(int *argc, char ***argv); /* * * An alternative for LLVMFuzzerTestOneInput() * * buf_ptr: will be set to input fuzzing data * len_ptr: will be set to the size of the input fuzzing data */ void HF_ITER(const uint8_t ** buf_ptr, size_t * len_ptr); #if defined(__linux__) /* * Enter Linux namespaces * * cloneFlags: see 'man unshare' */ bool linuxEnterNs(uintptr_t cloneFlags); /* * Bring network interface up * * ifacename: name of the interface, typically "lo" */ bool linuxIfaceUp(const char *ifacename); /* * Mount tmpfs over a mount point * * dst: mount point for tmfs */ bool linuxMountTmpfs(const char *dst); #endif /* defined(__linux__) */ #ifdef __cplusplus } /* extern "C" */ #endif
Remove extraneous string.h from listing 1
# include <stdio.h> # include <libmill.h> # include <string.h> coroutine void f(int index) { printf("Worker %d\n", index); } int main(int argc, char **argv) { for(int i=1;i<=10; i++) { go(f(i)); } return 0; }
# include <stdio.h> # include <libmill.h> coroutine void f(int index) { printf("Worker %d\n", index); } int main(int argc, char **argv) { for(int i=1;i<=10; i++) { go(f(i)); } return 0; }
Use \177 instead of a special character inserted with a hex editor
#define L for(char*c=a[1],y;*c;)printf("%c%c%c%c",(y="w$]m.k{o"[*c++-48])&u/4?124:32,y&u?95:32,y&u/2?124:32,*c?32:10);u*=8; main(int u,char**a){u=1;L;L;L}
#define L for(char*c=a[1],y;*c;)printf("%c%c%c%c",(y="w$]m.k{%\177o"[*c++-48])&u/4?124:32,y&u?95:32,y&u/2?124:32,*c?32:10);u*=8; main(int u,char**a){u=1;L;L;L}
Add space inside the regular expression.
// RUN: %clang_profgen -o %t -O3 %s // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t // RUN: llvm-profdata merge -o %t.profdata %t.profraw // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s void __llvm_profile_reset_counters(void); void foo(int); int main(void) { foo(0); __llvm_profile_reset_counters(); foo(1); return 0; } void foo(int N) { // CHECK-LABEL: define{{(dso_local)?}} void @foo( // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[FOO:[0-9]+]] if (N) {} } // CHECK: ![[FOO]] = !{!"branch_weights", i32 2, i32 1}
// RUN: %clang_profgen -o %t -O3 %s // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t // RUN: llvm-profdata merge -o %t.profdata %t.profraw // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s void __llvm_profile_reset_counters(void); void foo(int); int main(void) { foo(0); __llvm_profile_reset_counters(); foo(1); return 0; } void foo(int N) { // CHECK-LABEL: define{{( dso_local)?}} void @foo( // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[FOO:[0-9]+]] if (N) {} } // CHECK: ![[FOO]] = !{!"branch_weights", i32 2, i32 1}
Add util status bar layer
#pragma once #include <pebble.h> #ifndef PBL_PLATFORM_BASALT typedef struct StatusBarLayer StatusBarLayer; struct StatusBarLayer; static inline StatusBarLayer *status_bar_layer_create(void) { return NULL; } static inline void status_bar_layer_destroy(StatusBarLayer *status_bar_layer) { } static inline Layer *status_bar_layer_get_layer(StatusBarLayer *status_bar_layer) { return (Layer *)status_bar_layer; } static inline void status_bar_layer_add_to_window(Window *window, StatusBarLayer *status_bar_layer) { window_set_fullscreen(window, false); } static inline void status_bar_layer_remove_from_window(Window *window, StatusBarLayer *status_bar_layer) { window_set_fullscreen(window, true); } #else static inline void status_bar_layer_add_to_window(Window *window, StatusBarLayer *status_bar_layer) { layer_add_child(window_get_root_layer(window), status_bar_layer_get_layer(status_bar_layer)); } static inline void status_bar_layer_remove_from_window(Window *window, StatusBarLayer *status_bar_layer) { layer_remove_from_parent(status_bar_layer_get_layer(status_bar_layer)); } #endif
Use Is2Power instead of ctz
#ifndef IV_LV5_RADIO_BLOCK_SIZE_H_ #define IV_LV5_RADIO_BLOCK_SIZE_H_ #include <iv/static_assert.h> #include <iv/arith.h> namespace iv { namespace lv5 { namespace radio { class Block; static const std::size_t kBlockSize = core::Size::KB * 4; static const uintptr_t kBlockMask = ~static_cast<uintptr_t>(kBlockSize - 1); // must be 2^n size IV_STATIC_ASSERT((1 << core::math::detail::CTZ<kBlockSize>::value) == kBlockSize); } } } // namespace iv::lv5::radio #endif // IV_LV5_RADIO_BLOCK_SIZE_H_
#ifndef IV_LV5_RADIO_BLOCK_SIZE_H_ #define IV_LV5_RADIO_BLOCK_SIZE_H_ #include <iv/static_assert.h> namespace iv { namespace lv5 { namespace radio { namespace detail_block_size { template<std::size_t x> struct Is2Power { static const bool value = x > 1 && (x & (x - 1)) == 0; }; } // namespace detail_block_size class Block; static const std::size_t kBlockSize = core::Size::KB * 4; static const uintptr_t kBlockMask = ~static_cast<uintptr_t>(kBlockSize - 1); // must be 2^n size IV_STATIC_ASSERT(detail_block_size::Is2Power<kBlockSize>::value); } } } // namespace iv::lv5::radio #endif // IV_LV5_RADIO_BLOCK_SIZE_H_
Use lowercase underscore for variable name
#ifndef CPR_ERROR_H #define CPR_ERROR_H #include <string> #include "cprtypes.h" #include "defines.h" namespace cpr { enum class ErrorCode { OK = 0, CONNECTION_FAILURE, EMPTY_RESPONSE, HOST_RESOLUTION_FAILURE, INTERNAL_ERROR, INVALID_URL_FORMAT, NETWORK_RECEIVE_ERROR, NETWORK_SEND_FAILURE, OPERATION_TIMEDOUT, PROXY_RESOLUTION_FAILURE, SSL_CONNECT_ERROR, SSL_LOCAL_CERTIFICATE_ERROR, SSL_REMOTE_CERTIFICATE_ERROR, SSL_CACERT_ERROR, GENERIC_SSL_ERROR, UNSUPPORTED_PROTOCOL, UNKNOWN_ERROR = 1000, }; ErrorCode getErrorCodeForCurlError(int curlCode); //int so we don't have to include curl.h class Error { public: Error() : code{ErrorCode::OK}, message{""} {} template <typename ErrorCodeType, typename TextType> Error(ErrorCode& p_error_code, TextType&& p_error_message) : code{p_error_code}, message{CPR_FWD(p_error_message)} {} ErrorCode code; std::string message; //allow easy checking of errors with: // if(error) { do something; } explicit operator bool() const { return code != ErrorCode::OK; } }; } // namespace cpr #endif
#ifndef CPR_ERROR_H #define CPR_ERROR_H #include <string> #include "cprtypes.h" #include "defines.h" namespace cpr { enum class ErrorCode { OK = 0, CONNECTION_FAILURE, EMPTY_RESPONSE, HOST_RESOLUTION_FAILURE, INTERNAL_ERROR, INVALID_URL_FORMAT, NETWORK_RECEIVE_ERROR, NETWORK_SEND_FAILURE, OPERATION_TIMEDOUT, PROXY_RESOLUTION_FAILURE, SSL_CONNECT_ERROR, SSL_LOCAL_CERTIFICATE_ERROR, SSL_REMOTE_CERTIFICATE_ERROR, SSL_CACERT_ERROR, GENERIC_SSL_ERROR, UNSUPPORTED_PROTOCOL, UNKNOWN_ERROR = 1000, }; ErrorCode getErrorCodeForCurlError(int curl_code); //int so we don't have to include curl.h class Error { public: Error() : code{ErrorCode::OK}, message{""} {} template <typename ErrorCodeType, typename TextType> Error(ErrorCode& p_error_code, TextType&& p_error_message) : code{p_error_code}, message{CPR_FWD(p_error_message)} {} ErrorCode code; std::string message; //allow easy checking of errors with: // if(error) { do something; } explicit operator bool() const { return code != ErrorCode::OK; } }; } // namespace cpr #endif
Change c files to header files.
#include <stddef.h> #include <stdint.h> #include "gdt.c" #include "idt.c" #include "isr.c" #include "terminal.h" /* Check if the compiler thinks if we are targeting the wrong operating system. */ #if defined(__linux__) #error "You are not using a cross-compiler, you will most certainly run into trouble" #endif /* This tutorial will only work for the 32-bit ix86 targets. */ #if !defined(__i386__) #error "This tutorial needs to be compiled with a ix86-elf compiler" #endif void kernel_main() { gdt_install(); idt_install(); isrs_install(); term_initialize(); term_writestring("Interrupt?\n"); int i = 5; i = i / 0; term_writestring("Hello, Kernel!"); }
#include <stddef.h> #include <stdint.h> #include "gdt.h" #include "idt.h" #include "isr.h" #include "terminal.h" /* Check if the compiler thinks if we are targeting the wrong operating system. */ #if defined(__linux__) #error "You are not using a cross-compiler, you will most certainly run into trouble" #endif /* This tutorial will only work for the 32-bit ix86 targets. */ #if !defined(__i386__) #error "This tutorial needs to be compiled with a ix86-elf compiler" #endif void kernel_main() { gdt_install(); idt_install(); isrs_install(); term_initialize(); term_writestring("Interrupt?\n"); int i = 5; i = i / 0; term_writestring("Hello, Kernel!"); }
Isolate all PHP compatability stuff into its own file
#ifndef PHP_FE_END # define PHP_FE_END { NULL, NULL, NULL } #endif #ifndef HASH_KEY_NON_EXISTENT # define HASH_KEY_NON_EXISTENT HASH_KEY_NON_EXISTANT #endif
Fix fwd decl for windows.
//--------------------------------------------------------------------*- C++ -*- // CLING - the C++ LLVM-based InterpreterG :) // version: $Id$ // author: Timur Pocheptsov <Timur.Pocheptsov@cern.ch> //------------------------------------------------------------------------------ #ifndef CLING_DISPLAY_H #define CLING_DISPLAY_H #include <string> namespace llvm { class raw_ostream; } namespace cling { void DisplayClasses(llvm::raw_ostream &stream, const class Interpreter *interpreter, bool verbose); void DisplayClass(llvm::raw_ostream &stream, const Interpreter *interpreter, const char *className, bool verbose); void DisplayGlobals(llvm::raw_ostream &stream, const Interpreter *interpreter); void DisplayGlobal(llvm::raw_ostream &stream, const Interpreter *interpreter, const std::string &name); } #endif
//--------------------------------------------------------------------*- C++ -*- // CLING - the C++ LLVM-based InterpreterG :) // version: $Id$ // author: Timur Pocheptsov <Timur.Pocheptsov@cern.ch> //------------------------------------------------------------------------------ #ifndef CLING_DISPLAY_H #define CLING_DISPLAY_H #include <string> namespace llvm { class raw_ostream; } namespace cling { class Interpreter; void DisplayClasses(llvm::raw_ostream &stream, const Interpreter *interpreter, bool verbose); void DisplayClass(llvm::raw_ostream &stream, const Interpreter *interpreter, const char *className, bool verbose); void DisplayGlobals(llvm::raw_ostream &stream, const Interpreter *interpreter); void DisplayGlobal(llvm::raw_ostream &stream, const Interpreter *interpreter, const std::string &name); } #endif
Increment version number since we forked for beta.
/** * @file llversionviewer.h * @brief * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #ifndef LL_LLVERSIONVIEWER_H #define LL_LLVERSIONVIEWER_H const S32 LL_VERSION_MAJOR = 2; const S32 LL_VERSION_MINOR = 1; const S32 LL_VERSION_PATCH = 2; const S32 LL_VERSION_BUILD = 0; const char * const LL_CHANNEL = "Second Life Developer"; #endif
/** * @file llversionviewer.h * @brief * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #ifndef LL_LLVERSIONVIEWER_H #define LL_LLVERSIONVIEWER_H const S32 LL_VERSION_MAJOR = 2; const S32 LL_VERSION_MINOR = 2; const S32 LL_VERSION_PATCH = 1; const S32 LL_VERSION_BUILD = 0; const char * const LL_CHANNEL = "Second Life Developer"; #endif
Add ending null-byte to binaries
#include <binary.h> #include <assert.h> #include <crc32.h> /* API ************************************************************************/ Binary *binary_new(Scope *scope, size_t size) { Binary *binary = scope_alloc(scope, sizeof(Binary) + size); binary->size = size; binary->header = ref_header(TYPEID_BINARY, 0); memset(binary->data, 0, binary->size); return binary; } Binary *binary(Scope *scope, const uint8_t *data, size_t size) { Binary *binary = scope_alloc(scope, sizeof(Binary) + size); binary->size = size; binary->header = ref_header(TYPEID_BINARY, 0); memcpy(binary->data, data, size); return binary; } uint32_t binary_hash32(uint32_t hash, Binary *binary) { assert(binary != NULL); return crc32(hash, binary->data, binary->size); }
#include <binary.h> #include <assert.h> #include <crc32.h> /* API ************************************************************************/ Binary *binary_new(Scope *scope, size_t size) { Binary *binary = scope_alloc(scope, sizeof(Binary) + size + 1); binary->size = size; binary->header = ref_header(TYPEID_BINARY, 0); memset(binary->data, 0, binary->size + 1); return binary; } Binary *binary(Scope *scope, const uint8_t *data, size_t size) { Binary *binary = scope_alloc(scope, sizeof(Binary) + size + 1); binary->size = size; binary->header = ref_header(TYPEID_BINARY, 0); memcpy(binary->data, data, size + 1); return binary; } uint32_t binary_hash32(uint32_t hash, Binary *binary) { assert(binary != NULL); return crc32(hash, binary->data, binary->size); }
Format previos commit with clang-formatter
#ifndef MAP_EVENT_LISTENER_H #define MAP_EVENT_LISTENER_H #include "cocos2d.h" namespace tsg { namespace map { class IMapEventListener { public: virtual void onMapLoad(cocos2d::TMXTiledMap *) = 0; virtual void onViewCoordinatesChanged(cocos2d::Vec2) =0; virtual void onNightTime() =0; virtual void onDayTime() =0; virtual void onGameHourPassed() =0; virtual ~IMapEventListener(){}; }; } } #endif
#ifndef MAP_EVENT_LISTENER_H #define MAP_EVENT_LISTENER_H #include "cocos2d.h" namespace tsg { namespace map { class IMapEventListener { public: virtual void onMapLoad(cocos2d::TMXTiledMap *) = 0; virtual void onViewCoordinatesChanged(cocos2d::Vec2) = 0; virtual void onNightTime() = 0; virtual void onDayTime() = 0; virtual void onGameHourPassed() = 0; virtual ~IMapEventListener(){}; }; } } #endif
Remove public headers from umbrella header
#import <Foundation/Foundation.h> //! Project version number for Quick. FOUNDATION_EXPORT double QuickVersionNumber; //! Project version string for Quick. FOUNDATION_EXPORT const unsigned char QuickVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <Quick/PublicHeader.h> #import <Quick/QuickSpec.h> #import <Quick/QCKDSL.h> #import <Quick/QuickConfiguration.h>
#import <Foundation/Foundation.h> //! Project version number for Quick. FOUNDATION_EXPORT double QuickVersionNumber; //! Project version string for Quick. FOUNDATION_EXPORT const unsigned char QuickVersionString[]; #import <Quick/QuickSpec.h>
Put method declaration back into category header
// // ORKCollectionResult+MORK.h // MORK // // Created by Nolan Carroll on 4/23/15. // Copyright (c) 2015 Medidata Solutions. All rights reserved. // #import "ORKResult.h" @interface ORKTaskResult (MORK) @property (readonly) NSArray *mork_fieldDataFromResults; @end
// // ORKCollectionResult+MORK.h // MORK // // Created by Nolan Carroll on 4/23/15. // Copyright (c) 2015 Medidata Solutions. All rights reserved. // #import "ORKResult.h" @interface ORKTaskResult (MORK) - (NSArray *)mork_getFieldDataFromResults; @end
Introduce |HasPartial()|, |HasPublic()|, and so on in |WithModifiers| class for ease of accessing modifiers.
// Copyright 2014-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_COMPILER_AST_WITH_MODIFIERS_H_ #define ELANG_COMPILER_AST_WITH_MODIFIERS_H_ #include "elang/compiler/modifiers.h" namespace elang { namespace compiler { namespace ast { ////////////////////////////////////////////////////////////////////// // // WithModifiers // class WithModifiers { public: Modifiers modifiers() const { return modifiers_; } protected: explicit WithModifiers(Modifiers modifiers); ~WithModifiers(); private: Modifiers modifiers_; DISALLOW_COPY_AND_ASSIGN(WithModifiers); }; } // namespace ast } // namespace compiler } // namespace elang #endif // ELANG_COMPILER_AST_WITH_MODIFIERS_H_
// Copyright 2014-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_COMPILER_AST_WITH_MODIFIERS_H_ #define ELANG_COMPILER_AST_WITH_MODIFIERS_H_ #include "elang/compiler/modifiers.h" namespace elang { namespace compiler { namespace ast { ////////////////////////////////////////////////////////////////////// // // WithModifiers // class WithModifiers { public: Modifiers modifiers() const { return modifiers_; } #define V(name, string, details) \ bool Has##name() const { return modifiers_.Has##name(); } FOR_EACH_MODIFIER(V) #undef V protected: explicit WithModifiers(Modifiers modifiers); ~WithModifiers(); private: Modifiers modifiers_; DISALLOW_COPY_AND_ASSIGN(WithModifiers); }; } // namespace ast } // namespace compiler } // namespace elang #endif // ELANG_COMPILER_AST_WITH_MODIFIERS_H_
Change header to C style.
/** * File: dump.h * Author: Scott Bennett */ #ifndef DUMP_H #define DUMP_H void dumpMemory(); void dumpProgramRegisters(); void dumpProcessorRegisters(); #endif /* DUMP_H */
/* * File: dump.h * Author: Scott Bennett */ #ifndef DUMP_H #define DUMP_H void dumpMemory(); void dumpProgramRegisters(); void dumpProcessorRegisters(); #endif /* DUMP_H */
Remove broken prototype, starting out clean
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netdb.h> #include <netinet/in.h> #include <sys/uio.h> #define SERVER "127.0.0.1" #define BUFLEN 512 // max length of buffer #define PORT 3000 // destination port void die(const char *s) { perror(s); exit(1); } int main() { struct sockaddr_in si_other; int s, slen = sizeof(si_other); char buf[BUFLEN]; if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { die("socket"); } memset((char*)&si_other, 0, sizeof(si_other)); si_other.sin_family = AF_INET; si_other.sin_port = htons(PORT); if (inet_aton(SERVER, &si_other.sin_addr) == 0) { fprintf(stderr, "inet_aton() failed\n"); exit(1); } while (1) { printf("Enter message:\n"); const char* msg = "hello"; if (sendto(s, msg, strlen(msg), 0, (struct sockaddr*) &si_other, slen) == -1) { die("sendto()"); } memset(buf, '\0', BUFLEN); break; } close(s); return 0; }
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> __attribute__((noreturn)) void failed(const char* s) { perror(s); exit(1); } int main() { int s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (s == -1) { failed("socket()"); } }
Add basic cmd options handling
#include <config.h> #include "utest.h" int __attribute__((weak)) main (void) { return ut_run_all_tests() == 0; }
#include <config.h> #include "utest.h" #include <unistd.h> #include <getopt.h> #include <stdio.h> static struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { NULL, 0, 0, 0 } }; int __attribute__((weak)) main (int argc, char **argv) { int c; while (1) { int option_index; c = getopt_long(argc, argv, "hV", options, &option_index); if (c == -1) { break; } switch (c) { case 'h': printf("Help!\n"); break; case 'V': printf("Version!\n"); break; } } return ut_run_all_tests() == 0; }
Fix path seperator for Windows.
// Test ld invocation on Solaris targets. // Check sparc-sun-solaris2.1 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=sparc-sun-solaris2.11 \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/sparc-sun-solaris2.11 \ // RUN: | FileCheck %s // CHECK: "-cc1" "-triple" "sparc-sun-solaris2.11" // CHECK: ld{{.*}}" // CHECK: "--dynamic-linker" "{{.*}}/usr/lib/ld.so.1" // CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o" // CHECK: "{{.*}}/usr/lib/crti.o" // CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o" // CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o" // CHECK: "{{.*}}/usr/lib/crtn.o"
// Test ld invocation on Solaris targets. // Check sparc-sun-solaris2.1 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=sparc-sun-solaris2.11 \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/sparc-sun-solaris2.11 \ // RUN: | FileCheck %s // CHECK: "-cc1" "-triple" "sparc-sun-solaris2.11" // CHECK: ld{{.*}}" // CHECK: "--dynamic-linker" "{{.*}}/usr/lib/ld.so.1" // CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crt1.o" // CHECK: "{{.*}}/usr/lib/crti.o" // CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtbegin.o" // CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtend.o" // CHECK: "{{.*}}/usr/lib/crtn.o"
Use socketcan data structures and defines
#include <stdint.h> typedef uint8_t __u8; typedef uint32_t __u32; /* special address description flags for the CAN_ID */ #define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */ #define CAN_RTR_FLAG 0x40000000U /* remote transmission request */ #define CAN_ERR_FLAG 0x20000000U /* error message frame */ /* valid bits in CAN ID for frame formats */ #define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */ #define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */ #define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */ typedef __u32 canid_t; #define CAN_SFF_ID_BITS11 #define CAN_EFF_ID_BITS29 typedef __u32 can_err_mask_t; #define CAN_MAX_DLC 8 #define CAN_MAX_DLEN 8 struct can_frame { canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ __u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */ __u8 __pad; /* padding */ __u8 __res0; /* reserved / padding */ __u8 __res1; /* reserved / padding */ __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8))); }; struct can_filter { canid_t can_id; canid_t can_mask; };
Add a test for line continuation.
// Copyright 2012 Rui Ueyama <rui314@gmail.com> // This program is free software licensed under the MIT license. #include "test.h" #define stringify(x) #x void digraph(void) { expect_string("[", stringify(<:)); expect_string("]", stringify(:>)); expect_string("{", stringify(<%)); expect_string("}", stringify(%>)); expect_string("#", stringify(%:)); expect_string("% :", stringify(% :)); expect_string("##", stringify(%:%:)); expect_string("#%", stringify(%:%)); } void testmain(void) { print("lexer"); digraph(); }
// Copyright 2012 Rui Ueyama <rui314@gmail.com> // This program is free software licensed under the MIT license. #include "test.h" #define stringify(x) #x void digraph(void) { expect_string("[", stringify(<:)); expect_string("]", stringify(:>)); expect_string("{", stringify(<%)); expect_string("}", stringify(%>)); expect_string("#", stringify(%:)); expect_string("% :", stringify(% :)); expect_string("##", stringify(%:%:)); expect_string("#%", stringify(%:%)); } void escape(void) { int value = 10; expect(10, val\ ue); } void testmain(void) { print("lexer"); digraph(); escape(); }
Put comment right next to class def
#ifndef TRIANGLESTRIPGLWIDGET_H #define TRIANGLESTRIPGLWIDGET_H #include "GLWidget.h" #include <cmath> /** * Draws a trapezoid on screen using a triangle strip. Strips can be thought of * lists of vertices, where each triangle in the list is composed of some * adjacent group of three vertices. The vertices are colored for easy viewing. * * @author Aaron Faanes, ported by Brett Langford * */ class TriangleStripGLWidget : public GLWidget { public: TriangleStripGLWidget(QWidget* parent = 0); protected: void render(); }; TriangleStripGLWidget::TriangleStripGLWidget(QWidget* parent) : GLWidget(parent) {} void TriangleStripGLWidget::render() { glBegin(GL_TRIANGLE_STRIP); glColor3f(1, 0, 0); glVertex2f(0, 0); glColor3f(1, 1, 0); glVertex2f(50, 0); glColor3f(0, 1, 0); glVertex2f(25, 50); glColor3f(0, 1, 1); glVertex2f(75, 50); glColor3f(0, 0, 1); glVertex2f(50, 100); glEnd(); } #endif // TRIANGLESTRIPGLWIDGET_H
#ifndef TRIANGLESTRIPGLWIDGET_H #define TRIANGLESTRIPGLWIDGET_H #include "GLWidget.h" #include <cmath> /** * Draws a trapezoid on screen using a triangle strip. Strips can be thought of * lists of vertices, where each triangle in the list is composed of some * adjacent group of three vertices. The vertices are colored for easy viewing. * * @author Aaron Faanes, ported by Brett Langford * */ class TriangleStripGLWidget : public GLWidget { public: TriangleStripGLWidget(QWidget* parent = 0); protected: void render(); }; TriangleStripGLWidget::TriangleStripGLWidget(QWidget* parent) : GLWidget(parent) {} void TriangleStripGLWidget::render() { glBegin(GL_TRIANGLE_STRIP); glColor3f(1, 0, 0); glVertex2f(0, 0); glColor3f(1, 1, 0); glVertex2f(50, 0); glColor3f(0, 1, 0); glVertex2f(25, 50); glColor3f(0, 1, 1); glVertex2f(75, 50); glColor3f(0, 0, 1); glVertex2f(50, 100); glEnd(); } #endif // TRIANGLESTRIPGLWIDGET_H
Add prototypes for randr_changed_get and randr_changes_apply functions.
#ifdef E_TYPEDEFS #else # ifndef E_SMART_RANDR_H # define E_SMART_RANDR_H Evas_Object *e_smart_randr_add(Evas *evas); void e_smart_randr_current_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h); void e_smart_randr_monitors_create(Evas_Object *obj); void e_smart_randr_monitor_add(Evas_Object *obj, Evas_Object *mon); void e_smart_randr_monitor_del(Evas_Object *obj, Evas_Object *mon); # endif #endif
#ifdef E_TYPEDEFS #else # ifndef E_SMART_RANDR_H # define E_SMART_RANDR_H Evas_Object *e_smart_randr_add(Evas *evas); void e_smart_randr_current_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h); void e_smart_randr_monitors_create(Evas_Object *obj); void e_smart_randr_monitor_add(Evas_Object *obj, Evas_Object *mon); void e_smart_randr_monitor_del(Evas_Object *obj, Evas_Object *mon); Eina_Bool e_smart_randr_changed_get(Evas_Object *obj); void e_smart_randr_changes_apply(Evas_Object *obj, Ecore_X_Window root); # endif #endif
Add start of messaging interface.
// Messages are the scrolling messages within the UI. // This file contains update and retrieval functions. #include "7drltypes.h" #define MAX_MSG_SIZE ( 80 ) static int oldest_message = ( MAX_MESSAGES - 1 ); char messages[ MAX_MESSAGES ][ MAX_MSG_SIZE ]; void init_messages( void ) { bzero( messages, ( size_t ) sizeof( messages ) ); return; } void add_message( char *message ) { } char *get_message( int pos ) { return NULL; }
Update the version after tagging
#ifndef PHP_SHMT_H #define PHP_SHMT_H #define PHP_SHMT_EXTNAME "SHMT" #define PHP_SHMT_EXTVER "1.0.1" #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ extern zend_module_entry shmt_module_entry; #define phpext_shmt_ptr &shmt_module_entry; #endif /* PHP_SHMT_H */
#ifndef PHP_SHMT_H #define PHP_SHMT_H #define PHP_SHMT_EXTNAME "SHMT" #define PHP_SHMT_EXTVER "1.0.2dev" #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ extern zend_module_entry shmt_module_entry; #define phpext_shmt_ptr &shmt_module_entry; #endif /* PHP_SHMT_H */
Make it harder to accidentally steal ownership of a RAIIHelper resource
#pragma once #include <utility> namespace shk { template< typename T, typename Return, Return (Free)(T), T EmptyValue = nullptr> class RAIIHelper { public: RAIIHelper(T obj) : _obj(obj) {} RAIIHelper(const RAIIHelper &) = delete; RAIIHelper &operator=(const RAIIHelper &) = delete; RAIIHelper(RAIIHelper &&other) : _obj(other._obj) { other._obj = EmptyValue; } ~RAIIHelper() { if (_obj != EmptyValue) { Free(_obj); } } explicit operator bool() const { return _obj != EmptyValue; } T get() const { return _obj; } private: T _obj; }; } // namespace shk
#pragma once #include <utility> namespace shk { template< typename T, typename Return, Return (Free)(T), T EmptyValue = nullptr> class RAIIHelper { public: explicit RAIIHelper(T obj) : _obj(obj) {} RAIIHelper(const RAIIHelper &) = delete; RAIIHelper &operator=(const RAIIHelper &) = delete; RAIIHelper(RAIIHelper &&other) : _obj(other._obj) { other._obj = EmptyValue; } ~RAIIHelper() { if (_obj != EmptyValue) { Free(_obj); } } explicit operator bool() const { return _obj != EmptyValue; } T get() const { return _obj; } private: T _obj; }; } // namespace shk
Add note about how protocol conformance checking works.
// // VOKMappableModel.h // VOKCoreData // #import "VOKCoreDataManager.h" /** * Any models that conform to this protocol will be automatically registered for mapping with the shared instance * of VOKCoreDataManager. */ @protocol VOKMappableModel <NSObject> ///@return an array of VOKManagedObjectMap objects mapping foreign keys to local keys. + (NSArray *)coreDataMaps; ///@return the key name to use to uniquely compare two instances of a class. + (NSString *)uniqueKey; // If an optional method isn't defined, the default VOKManagedObjectMap behavior/value will be used. @optional ///@return whether to ignore remote null/nil values are ignored when updating. + (BOOL)ignoreNullValueOverwrites; ///@return whether to warn about incorrect class types when receiving null/nil values for optional properties. + (BOOL)ignoreOptionalNullValues; ///@return completion block to run after importing each foreign dictionary. + (VOKPostImportBlock)importCompletionBlock; @end
// // VOKMappableModel.h // VOKCoreData // #import "VOKCoreDataManager.h" /** * Any models that conform to this protocol will be automatically registered for mapping with the shared instance * of VOKCoreDataManager. * * Note that runtime protocol-conformance is based on declared conformance (the angle-bracketed protocol name appended * to the interface) and not by checking that the required methods are implemented. If you ignore the compiler * warnings about failing to implement required methods, your app will crash. */ @protocol VOKMappableModel <NSObject> ///@return an array of VOKManagedObjectMap objects mapping foreign keys to local keys. + (NSArray *)coreDataMaps; ///@return the key name to use to uniquely compare two instances of a class. + (NSString *)uniqueKey; // If an optional method isn't defined, the default VOKManagedObjectMap behavior/value will be used. @optional ///@return whether to ignore remote null/nil values are ignored when updating. + (BOOL)ignoreNullValueOverwrites; ///@return whether to warn about incorrect class types when receiving null/nil values for optional properties. + (BOOL)ignoreOptionalNullValues; ///@return completion block to run after importing each foreign dictionary. + (VOKPostImportBlock)importCompletionBlock; @end
Add file for reading/writing settings. Oops.
#include <stdio.h> #include <stdlib.h> #include "therm.h" /* Loads settings from persistent storage, returning the number of items read, or -1 on error. */ int persistent_load() { FILE *f = fopen(SAVEPATH, "r"); float pid[6]; int ret = 0; if(!f) { return -1; } ret += fread(&wanted_temperature, sizeof(wanted_temperature), 1, f); ret += fread(&wanted_humidity, sizeof(wanted_humidity), 1, f); ret += fread(pid, sizeof(float), 6, f); pid_setvalues(pid[0], pid[1], pid[2], pid[3], pid[4], pid[5]); fclose(f); return ret; } /* Writes settings to persistent storage, returning the number of items written, or -1 on error. */ int persistent_write() { FILE *f = fopen(SAVEPATH, "w"); float pid[6]; int ret = 0; if(!f) { fprintf(stderr, "Couldn't open " SAVEPATH " for writing.\n"); return -1; } ret += fwrite(&wanted_temperature, sizeof(wanted_temperature), 1, f); ret += fwrite(&wanted_humidity, sizeof(wanted_humidity), 1, f); pid_getvalues(pid+0, pid+1, pid+2, pid+3, pid+4, pid+5); ret += fwrite(pid, sizeof(float), 6, f); fclose(f); fprintf(stderr, "Done.\n"); return ret; }
Fix an incomplete copy and paste in my previous patch.
// RUN: not %clang_cc1 %s -cake-is-lie -%0 -%d 2> %t.log // RUN: FileCheck %s -input-file=%t.log // CHECK: unknown argument // CHECK: unknown argument // CHECK: unknown argument // RUN: %clang -S %s -o %t.s -funknown-to-clang-option -Wunknown-to-clang-option -munknown-to-clang-optio // IGNORED: warning: argument unused during compilation: '-funknown-to-clang-option' // IGNORED: warning: argument unused during compilation: '-munknown-to-clang-option' // IGNORED: warning: unknown warning option '-Wunknown-to-clang-option'
// RUN: not %clang_cc1 %s -cake-is-lie -%0 -%d 2> %t.log // RUN: FileCheck %s -input-file=%t.log // CHECK: unknown argument // CHECK: unknown argument // CHECK: unknown argument // RUN: %clang -S %s -o %t.s -funknown-to-clang-option -Wunknown-to-clang-option -munknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s // IGNORED: warning: argument unused during compilation: '-funknown-to-clang-option' // IGNORED: warning: argument unused during compilation: '-munknown-to-clang-option' // IGNORED: warning: unknown warning option '-Wunknown-to-clang-option'
Fix build with clang on non-Mac
// Unwinding stuff missing on some architectures (Mac OS X). #ifndef RUST_UNWIND_H #define RUST_UNWIND_H #ifdef __APPLE__ #include <libunwind.h> typedef int _Unwind_Action; typedef void _Unwind_Context; typedef void _Unwind_Exception; typedef int _Unwind_Reason_Code; #else #include <unwind.h> #endif #endif
// Unwinding stuff missing on some architectures (Mac OS X). #ifndef RUST_UNWIND_H #define RUST_UNWIND_H #ifdef __APPLE__ #include <libunwind.h> typedef void _Unwind_Context; typedef int _Unwind_Reason_Code; #else #include <unwind.h> #endif #if (defined __APPLE__) || (defined __clang__) typedef int _Unwind_Action; typedef void _Unwind_Exception; #endif #endif
Add test for the C API for selections
#include "chemfiles.h" // Force NDEBUG to be undefined #undef NDEBUG #include <assert.h> #include <stdlib.h> int main() { CHFL_TOPOLOGY* topology = chfl_topology(); CHFL_ATOM* O = chfl_atom("O"); CHFL_ATOM* H = chfl_atom("H"); assert(topology != NULL); assert(H != NULL); assert(O != NULL); assert(!chfl_topology_append(topology, H)); assert(!chfl_topology_append(topology, O)); assert(!chfl_topology_append(topology, O)); assert(!chfl_topology_append(topology, H)); assert(!chfl_atom_free(O)); assert(!chfl_atom_free(H)); CHFL_FRAME* frame = chfl_frame(4); assert(!chfl_frame_set_topology(frame, topology)); assert(!chfl_topology_free(topology)); bool* matched = malloc(4 * sizeof(bool)); assert(!chfl_frame_selection(frame, "name O", matched, 4)); assert(matched[0] == false); assert(matched[1] == true); assert(matched[2] == true); assert(matched[3] == false); assert(!chfl_frame_selection(frame, "not index <= 2", matched, 4)); assert(matched[0] == false); assert(matched[1] == false); assert(matched[2] == false); assert(matched[3] == true); free(matched); assert(!chfl_frame_free(frame)); return EXIT_SUCCESS; }
Create a utility to properly parse obj files.
#include <stdlib.h> #include <stdio.h> #include <string.h> typedef struct vector3f { float x, y, z; }VECTOR3F; typedef struct triangle { int32_t v1, v2, v3; }TRIANGLE; typedef struct trianglemesh { int32_t id; TRIANGLE t; // vertices number VECTOR3F v[3]; // vertices coordinates }TRIANGLEMESH; void usage(char *argv0) { fprintf(stdout, "%s <obj filename>\n", argv0); exit(1); } int parse_file(const char *filename) { FILE *fp = NULL; char buf[1024]; int vertices_count = 0; int faces_count = 0; if ((fp = fopen(filename, "r")) == NULL) { fprintf(stderr, "Cannot open file %s.\n", filename); return -1; } // Reading file until the end while (!feof(fp)) { memset(buf, 0, sizeof(buf)); char start_line = 0; // Read a line and save to a buffer. while (fgets(buf, sizeof(buf), fp) != NULL) { // Read the first character of the line sscanf(buf, "%c", &start_line); switch(start_line) { VECTOR3F v; TRIANGLE t; TRIANGLEMESH tm; case 'v': sscanf(buf, "%c %f %f %f", &start_line, &v.x, &v.y, &v.z); vertices_count += 1; fprintf(stdout, "%c %f %f %f\n", start_line, v.x, v.y, v.z); break; case 'f': sscanf(buf, "%c %d %d %d", &start_line, &t.v1, &t.v2, &t.v3); faces_count += 1; fprintf(stdout, "%c %d %d %d\n", start_line, t.v1, t.v2, t.v3); break; default: fprintf(stdout, "Not known start line %c\n", start_line); break; } } } return 0; } int main(int argc, char *argv[]) { if (argc != 2) { usage(argv[0]); } const char* filename = argv[1]; parse_file(filename); return 0; }
Add global initializer SV-COMP test
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; } int g = 1; int main() { __VERIFIER_assert(g == 1); return 0; }
Add verb to touch all clones of a given clonable
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2012 Raymond Jennings * * This program 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. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <kotaka/paths.h> #include <text/paths.h> #include <status.h> inherit LIB_RAWVERB; void main(object actor, string args) { mixed *st; int i, sz; int tcount; if (query_user()->query_class() < 2) { send_out("You do not have sufficient access rights to touch all clones.\n"); return; } st = status(args); if (!st) { send_out("No such object.\n"); return; } sz = status(ST_OTABSIZE); for (i = 0; i < sz; i++) { object obj; obj = find_object(args + "#" + i); if (obj) { call_touch(obj); tcount++; } } send_out(tcount + " objects touched.\n"); }
Add endAllBackgroundTasks to the Public API
// // BackgroundTaskManager.h // // Created by Puru Shukla on 20/02/13. // Copyright (c) 2013 Puru Shukla. All rights reserved. // #import <Foundation/Foundation.h> @interface BackgroundTaskManager : NSObject +(instancetype)sharedBackgroundTaskManager; -(UIBackgroundTaskIdentifier)beginNewBackgroundTask; @end
// // BackgroundTaskManager.h // // Created by Puru Shukla on 20/02/13. // Copyright (c) 2013 Puru Shukla. All rights reserved. // #import <Foundation/Foundation.h> @interface BackgroundTaskManager : NSObject +(instancetype)sharedBackgroundTaskManager; -(UIBackgroundTaskIdentifier)beginNewBackgroundTask; -(void)endAllBackgroundTasks; @end
Add class comment for BmNodeStatsReporter.
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/vespalib/util/threadstackexecutor.h> #include <chrono> #include <mutex> #include <condition_variable> namespace search::bmcluster { class BmCluster; class BmNodeStatsReporter { BmCluster& _cluster; vespalib::ThreadStackExecutor _executor; std::mutex _mutex; std::condition_variable _cond; uint32_t _pending_report; bool _started; bool _stop; void report(); void run_report_loop(std::chrono::milliseconds interval); public: BmNodeStatsReporter(BmCluster& cluster); ~BmNodeStatsReporter(); void start(std::chrono::milliseconds interval); void stop(); void report_now(); }; }
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/vespalib/util/threadstackexecutor.h> #include <chrono> #include <mutex> #include <condition_variable> namespace search::bmcluster { class BmCluster; /* * Class handling background reporting of node stats during feed or * document redistribution. */ class BmNodeStatsReporter { BmCluster& _cluster; vespalib::ThreadStackExecutor _executor; std::mutex _mutex; std::condition_variable _cond; uint32_t _pending_report; bool _started; bool _stop; void report(); void run_report_loop(std::chrono::milliseconds interval); public: BmNodeStatsReporter(BmCluster& cluster); ~BmNodeStatsReporter(); void start(std::chrono::milliseconds interval); void stop(); void report_now(); }; }
Fix DirBrowserFormAction build on FreeBSD
#ifndef NEWSBOAT_DIRBROWSERFORMACTION_H #define NEWSBOAT_DIRBROWSERFORMACTION_H #include <grp.h> #include "configcontainer.h" #include "formaction.h" namespace newsboat { class DirBrowserFormAction : public FormAction { public: DirBrowserFormAction(View*, std::string formstr, ConfigContainer* cfg); ~DirBrowserFormAction() override; void prepare() override; void init() override; KeyMapHintEntry* get_keymap_hint() override; void set_dir(const std::string& d) { dir = d; } std::string id() const override { return "filebrowser"; } std::string title() override; private: void process_operation(Operation op, bool automatic = false, std::vector<std::string>* args = nullptr) override; std::string add_directory(std::string dirname); std::string get_rwx(unsigned short val); std::string get_owner(uid_t uid); std::string get_group(gid_t gid); std::string get_formatted_dirname(std::string dirname, char ftype, mode_t mode); std::string cwd; std::string dir; }; } // namespace newsboat #endif //NEWSBOAT_DIRBROWSERFORMACTION_H
#ifndef NEWSBOAT_DIRBROWSERFORMACTION_H #define NEWSBOAT_DIRBROWSERFORMACTION_H #include <sys/stat.h> #include <grp.h> #include "configcontainer.h" #include "formaction.h" namespace newsboat { class DirBrowserFormAction : public FormAction { public: DirBrowserFormAction(View*, std::string formstr, ConfigContainer* cfg); ~DirBrowserFormAction() override; void prepare() override; void init() override; KeyMapHintEntry* get_keymap_hint() override; void set_dir(const std::string& d) { dir = d; } std::string id() const override { return "filebrowser"; } std::string title() override; private: void process_operation(Operation op, bool automatic = false, std::vector<std::string>* args = nullptr) override; std::string add_directory(std::string dirname); std::string get_rwx(unsigned short val); std::string get_owner(uid_t uid); std::string get_group(gid_t gid); std::string get_formatted_dirname(std::string dirname, char ftype, mode_t mode); std::string cwd; std::string dir; }; } // namespace newsboat #endif //NEWSBOAT_DIRBROWSERFORMACTION_H
Remove redundant commended out code
#ifndef _TILESET_H_ #define _TILESET_H_ #include <SDL.h> //#define TILESET_ROW_LENGTH 8 typedef struct tileset { SDL_Surface *image; SDL_Rect *clip; int length; } tileset; int tilesetLoad(tileset *tSet, char *fileName, int width, int height, int rowLen, int length); void tilesetUnload(tileset *tSet); #endif /* _TILESET_H_ */
#ifndef _TILESET_H_ #define _TILESET_H_ #include <SDL.h> typedef struct tileset { SDL_Surface *image; SDL_Rect *clip; int length; } tileset; int tilesetLoad(tileset *tSet, char *fileName, int width, int height, int rowLen, int length); void tilesetUnload(tileset *tSet); #endif /* _TILESET_H_ */
Load match configs into each local proc.
/* Preprocessor defines added by opencl compiler * #define CONFIGS_PER_PROC */ __kernel void start_trampoline(__global char *match_configs, __global char *output) { __private unsigned int i; for (i = 0; i < 256; i++) { output[i] = CONFIGS_PER_PROC; } write_mem_fence(CLK_GLOBAL_MEM_FENCE); return; }
/* Preprocessor defines added by opencl compiler * #define CONFIGS_PER_PROC */ __kernel void start_trampoline(__global char *match_configs, __global char *output) { __private unsigned int i, startloc; // Per worker match configs. __private char local_match_configs[CONFIGS_PER_PROC * sizeof(char) * 4]; // Read in per worker match configs startloc = get_local_id(0) * CONFIGS_PER_PROC * 4; for (i = 0; i < CONFIGS_PER_PROC * 4; i++) local_match_configs[i] = match_configs[startloc + i]; for (i = 0; i < 256; i++) { output[i] = CONFIGS_PER_PROC; } write_mem_fence(CLK_GLOBAL_MEM_FENCE); return; }
Add note about using yield().
// Calculates the 45th Fibonacci number with a visual indicator. #include <stdio.h> #include <assert.h> #include <libdill.h> // Calculates Fibonacci of x. static int fib(int x) { // Need to yield or spinner will not have any time to spin. int rc = yield(); assert(rc == 0); if (x < 2) return x; return fib(x - 1) + fib(x - 2); } coroutine void spinner(int delay) { const char spinChars[] = {'-', '\\', '|', '/'}; while (1) { for (int i = 0; i < sizeof(spinChars); i++) { printf("\r%c", spinChars[i]); msleep(now() + delay); } } } int main() { // Turn off buffering on stdout otherwise we won't see the spinner. setbuf(stdout, NULL); int rc = go(spinner(100)); assert(rc != -1); const int n = 45; int fibN = fib(n); printf("\rFibonacci(%d) = %d\n", n, fibN); }
// Calculates the 45th Fibonacci number with a visual indicator. // Note: using yield() in fib() may allow the spinner to actually spin, but // fib() takes a lot longer to complete. E.g. Over 2 minutes with yield() // vs. 10 seconds without it. #include <stdio.h> #include <assert.h> #include <libdill.h> // Calculates Fibonacci of x. static int fib(int x) { // Need to yield or spinner will not have any time to spin. int rc = yield(); assert(rc == 0); if (x < 2) return x; return fib(x - 1) + fib(x - 2); } coroutine void spinner(int delay) { const char spinChars[] = {'-', '\\', '|', '/'}; while (1) { for (int i = 0; i < sizeof(spinChars); i++) { printf("\r%c", spinChars[i]); msleep(now() + delay); } } } int main() { // Turn off buffering on stdout otherwise we won't see the spinner. setbuf(stdout, NULL); int rc = go(spinner(500)); assert(rc != -1); const int n = 45; int fibN = fib(n); printf("\rFibonacci(%d) = %d\n", n, fibN); }
Refactor the space tokenizer to be its own function; parse() no longer exists.
#include <stdlib.h> #include <stdio.h> #include types.c #include <string.h> /* We can: Set something equal to something Function calls Function definitions Returning things -- delimiter '<' Printing things Iffing */ struct call parseCall(char* statement); struct function parseFunction(char* statement); char* fixSpacing(char* code) { char* fixedCode = calloc(sizeof(char), strlen(code) + 1); fixedCode = strcpy(fixedCode, code); char* doubleSpace = strstr(fixedCode, " "); char* movingIndex; for( ; doubleSpace; doubleSpace = strstr(fixedCode, " ")) { for(movingIndex = doubleSpace; movingIndex&; movingIndex++) { movingIndex[0] = movingIndex[1]; } } return fixedCode; } struct statement* parse(char* code) { char* regCode = fixSpacing(code); int n = 0; int i; for(i = 0; regCode[i]; i++) { if(regCode[i] == ' ') { n++; } } char** spcTokens = calloc(sizeof(char*), n+1);
#include <stdlib.h> #include <stdio.h> #include types.c #include <string.h> /* We can: Set something equal to something Function calls Function definitions Returning things -- delimiter '<' Printing things Iffing */ struct call parseCall(char* statement); struct function parseFunction(char* statement); char* fixSpacing(char* code) { char* fixedCode = malloc(sizeof(char) * (strlen(code) + 1)); fixedCode = strcpy(fixedCode, code); char* doubleSpace = strstr(fixedCode, " "); char* movingIndex; for( ; doubleSpace; doubleSpace = strstr(fixedCode, " ")) { for(movingIndex = doubleSpace; movingIndex&; movingIndex++) { movingIndex[0] = movingIndex[1]; } } return fixedCode; } char** spcTokenize(char* regCode) { int n = 0; int i; for(i = 0; regCode[i]; i++) { if(regCode[i] == ' ') { n++; } } char** spcTokens = malloc(sizeof(char*) * (n+1)); int k; for(i = 0; i < n+1; i++) { k = strchr(regCode, ' ') - regCode; regCode[k] = NULL; spcTokens[i] = regCode + k + 1; } }
Solve Fire Flowers in c
#include <math.h> #include <stdio.h> int main() { double r1, x1, y1, r2, x2, y2; double distance; while (scanf("%lf %lf %lf %lf %lf %lf", &r1, &x1, &y1, &r2, &x2, &y2) != EOF) { distance = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (r1 >= distance + r2) { puts("RICO"); } else { puts("MORTO"); } } return 0; }
Make all bus events to be signals
#include <gst/gst.h> #include "kms-core.h" static GstElement *pipe = NULL; static G_LOCK_DEFINE(mutex); static gboolean init = FALSE; static gboolean bus_watch(GstBus *bus, GstMessage *message, gpointer data) { KMS_LOG_DEBUG("TODO: implement bus watcher\n"); return TRUE; } void kms_init(gint *argc, gchar **argv[]) { G_LOCK(mutex); if (!init) { GstBus *bus; g_type_init(); gst_init(argc, argv); pipe = gst_pipeline_new(NULL); gst_element_set_state(pipe, GST_STATE_PLAYING); bus = gst_element_get_bus(pipe); gst_bus_add_watch(bus, bus_watch, NULL); init = TRUE; } G_UNLOCK(mutex); } GstElement* kms_get_pipeline() { return pipe; }
#include <gst/gst.h> #include "kms-core.h" static GstElement *pipe = NULL; static G_LOCK_DEFINE(mutex); static gboolean init = FALSE; static gpointer gstreamer_thread(gpointer data) { GMainLoop *loop; loop = g_main_loop_new(NULL, TRUE); g_main_loop_run(loop); return NULL; } void kms_init(gint *argc, gchar **argv[]) { G_LOCK(mutex); if (!init) { GstBus *bus; g_type_init(); gst_init(argc, argv); pipe = gst_pipeline_new(NULL); gst_element_set_state(pipe, GST_STATE_PLAYING); bus = gst_element_get_bus(pipe); gst_bus_add_watch(bus, gst_bus_async_signal_func, NULL); g_thread_create(gstreamer_thread, NULL, TRUE, NULL); init = TRUE; } G_UNLOCK(mutex); } GstElement* kms_get_pipeline() { return pipe; }
Fix `_CHOOSE` to use the copies instead of double execution of side-effects (issue reported by tromp at bitcointalk.org)
#ifndef _EFFECTLESS #define EFFECTLESS /* Macros without multiple execution of side-effects. */ /* Generic min and max without double execution of side-effects: http://stackoverflow.com/questions/3437404/min-and-max-in-c */ #define _CHOOSE(boolop, a, b, uid) \ ({ \ decltype(a) _a_ ## uid = (a); \ decltype(b) _b_ ## uid = (b); \ (a) boolop (b) ? (a) : (b); \ }) #undef MIN #undef MAX #define MIN(a, b) _CHOOSE(<, a, b, __COUNTER__) #define MAX(a, b) _CHOOSE(>, a, b, __COUNTER__) #endif
#ifndef _EFFECTLESS #define EFFECTLESS /* Macros without multiple execution of side-effects. */ /* Generic min and max without double execution of side-effects: http://stackoverflow.com/questions/3437404/min-and-max-in-c */ #define _CHOOSE(boolop, a, b, uid) \ ({ \ decltype(a) _a_ ## uid = (a); \ decltype(b) _b_ ## uid = (b); \ (_a_ ## uid) boolop (_b_ ## uid) ? (_a_ ## uid) : (_b_ ## uid); \ }) #undef MIN #undef MAX #define MIN(a, b) _CHOOSE(<, a, b, __COUNTER__) #define MAX(a, b) _CHOOSE(>, a, b, __COUNTER__) #endif
Make gutted help subsystem shut itself down on next upgrade
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2009, 2012, 2013, 2014 Raymond Jennings * * This program 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. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <kotaka/paths/bigstruct.h> #include <kotaka/paths/system.h> #include <kotaka/privilege.h> inherit LIB_INITD; inherit UTILITY_COMPILE; static void create() { KERNELD->set_global_access("Help", 1); load_dir("obj", 1); load_dir("sys", 1); }
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2009, 2012, 2013, 2014 Raymond Jennings * * This program 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. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <kotaka/paths/bigstruct.h> #include <kotaka/paths/system.h> #include <kotaka/privilege.h> inherit LIB_INITD; inherit UTILITY_COMPILE; static void create() { KERNELD->set_global_access("Help", 1); load_dir("obj", 1); load_dir("sys", 1); } void do_upgrade() { INITD->shutdown_subsystem("Help"); }
Add the MemChunks screen [for kmalloc heavy stats]
/* SPDX-License-Identifier: BSD-2-Clause */ #include <tilck/common/basic_defs.h> #include <tilck/common/string_util.h> #include <tilck/kernel/kmalloc.h> #include <tilck/kernel/cmdline.h> #include "termutil.h" #include "dp_int.h" static debug_kmalloc_chunk_stat chunks_arr[1024]; static void dp_show_chunks(void) { debug_kmalloc_stats stats; int row = dp_screen_start_row; if (!KMALLOC_HEAVY_STATS) { dp_writeln("Not available: recompile with KMALLOC_HEAVY_STATS=1"); return; } debug_kmalloc_get_stats(&stats); if (stats.chunk_sizes_count > ARRAY_SIZE(chunks_arr)) { dp_writeln("Not enough space in chunks_arr!"); return; } debug_kmalloc_get_chunks_info(chunks_arr); for (size_t i = 0; i < stats.chunk_sizes_count; i++) { dp_writeln("Size: %8u -> %6u allocs", chunks_arr[i].size, chunks_arr[i].count); } } static dp_screen dp_chunks_screen = { .index = 5, .label = "MemChunks", .draw_func = dp_show_chunks, .on_keypress_func = NULL, }; __attribute__((constructor)) static void dp_chunks_init(void) { dp_register_screen(&dp_chunks_screen); }
Adjust for the fact that MacOS X and Solaris report maxrss in different units.
#include "../sccs.h" #ifdef WIN32 #include <psapi.h> u64 maxrss(void) { PROCESS_MEMORY_COUNTERS cnt; if (GetProcessMemoryInfo(GetCurrentProcess(), &cnt, sizeof(cnt))) { return (cnt.PeakWorkingSetSize); } return (0); } #else #include <sys/resource.h> u64 maxrss(void) { struct rusage ru; if (!getrusage(RUSAGE_SELF, &ru)) return (1024 * ru.ru_maxrss); return (0); } #endif
#include "../sccs.h" #ifdef WIN32 #include <psapi.h> u64 maxrss(void) { PROCESS_MEMORY_COUNTERS cnt; if (GetProcessMemoryInfo(GetCurrentProcess(), &cnt, sizeof(cnt))) { return (cnt.PeakWorkingSetSize); } return (0); } #else #include <sys/resource.h> u64 maxrss(void) { struct rusage ru; #if defined(sun) int factor = getpagesize(); #elif defined(__APPLE__) int factor = 1; #else int factor = 1024; #endif if (getrusage(RUSAGE_SELF, &ru)) return (0); return (ru.ru_maxrss * factor); } #endif
Make zero a user field
#ifndef __ZERO_FIELD_H__ #define __ZERO_FIELD_H__ #include "Field.h" namespace cigma { class ZeroField; } class cigma::ZeroField : public cigma::Field { public: ZeroField(); ~ZeroField(); void set_shape(int dim, int rank); public: int n_dim() { return dim; } int n_rank() { return rank; } FieldType getType() { return USER_FIELD; } public: bool eval(double *point, double *value); public: int dim; int rank; }; #endif
#ifndef __ZERO_FIELD_H__ #define __ZERO_FIELD_H__ #include "UserField.h" namespace cigma { class ZeroField; } class cigma::ZeroField : public cigma::UserField { public: ZeroField(); ~ZeroField(); void set_shape(int dim, int rank); public: int n_dim() { return dim; } int n_rank() { return rank; } public: bool eval(double *point, double *value); public: int dim; int rank; }; #endif
Add 'LONG_TO_PTR' and 'PTR_TO_LONG' macros
#ifndef PSTOREJNI_H #define PSTOREJNI_H #include <inttypes.h> #ifdef __i386__ #define LONG_TO_PTR(ptr) (void *) (uint32_t) ptr #elif __X86_64__ #define LONG_TO_PTR(ptr) (void *) ptr #endif #define PTR_TO_LONG(ptr) (long) ptr #endif
Update import in main header file
// // MORK.h // MORK // // Created by Nolan Carroll on 4/23/15. // Copyright (c) 2015 Medidata Solutions. All rights reserved. // #import <UIKit/UIKit.h> #import "ORKTaskResult+MORK.h" #import "ORKQuestionResult+MORK.h" //! Project version number for MORK. FOUNDATION_EXPORT double MORKVersionNumber; //! Project version string for MORK. FOUNDATION_EXPORT const unsigned char MORKVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <MORK/PublicHeader.h>
// // MORK.h // MORK // // Created by Nolan Carroll on 4/23/15. // Copyright (c) 2015 Medidata Solutions. All rights reserved. // #import <UIKit/UIKit.h> #import "ORKCollectionResult+MORK.h" #import "ORKQuestionResult+MORK.h" //! Project version number for MORK. FOUNDATION_EXPORT double MORKVersionNumber; //! Project version string for MORK. FOUNDATION_EXPORT const unsigned char MORKVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <MORK/PublicHeader.h>
Clean up versioning commit hash.
/* @(#)root/meta:$Id: 4660ec009138a70261265c65fc5a10398706fbd1 $ */ /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifdef __CINT__ #pragma link C++ class TCling; #endif
/* @(#)root/meta:$Id$ */ /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifdef __CINT__ #pragma link C++ class TCling; #endif
Fix test submitted with r275115 (failed on ppc64 buildbots).
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s // Check that no empty blocks are generated for nested ifs. extern void func(); int f0(int val) { if (val == 0) { func(); } else if (val == 1) { func(); } return 0; } // CHECK-LABEL: define i32 @f0 // CHECK: call void {{.*}} @func // CHECK: call void {{.*}} @func // CHECK: br label %[[RETBLOCK1:[^ ]*]] // CHECK: [[RETBLOCK1]]: // CHECK-NOT: br label // CHECK: ret i32 int f1(int val, int g) { if (val == 0) if (g == 1) { func(); } return 0; } // CHECK-LABEL: define i32 @f1 // CHECK: call void {{.*}} @func // CHECK: br label %[[RETBLOCK2:[^ ]*]] // CHECK: [[RETBLOCK2]]: // CHECK-NOT: br label // CHECK: ret i32
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s // Check that no empty blocks are generated for nested ifs. extern void func(); int f0(int val) { if (val == 0) { func(); } else if (val == 1) { func(); } return 0; } // CHECK-LABEL: define {{.*}} i32 @f0 // CHECK: call void {{.*}} @func // CHECK: call void {{.*}} @func // CHECK: br label %[[RETBLOCK1:[^ ]*]] // CHECK: [[RETBLOCK1]]: // CHECK-NOT: br label // CHECK: ret i32 int f1(int val, int g) { if (val == 0) if (g == 1) { func(); } return 0; } // CHECK-LABEL: define {{.*}} i32 @f1 // CHECK: call void {{.*}} @func // CHECK: br label %[[RETBLOCK2:[^ ]*]] // CHECK: [[RETBLOCK2]]: // CHECK-NOT: br label // CHECK: ret i32
Add a program to test Kiss FFT.
// Taken from: http://stackoverflow.com/a/14537855 #include <math.h> #include <stdio.h> #include <stdlib.h> #ifndef M_PI #define M_PI 3.14159265358979324 #endif #define N 16 #define kiss_fft_scalar double #include "kiss_fftr.h" void TestFftReal(const char *title, const kiss_fft_scalar in[N], kiss_fft_cpx out[N / 2 + 1]) { kiss_fftr_cfg cfg; printf("%s\n", title); if ((cfg = kiss_fftr_alloc(N, 0 /*is_inverse_fft*/, NULL, NULL)) != NULL) { size_t i; kiss_fftr(cfg, in, out); free(cfg); for (i = 0; i < N; i++) { printf(" in[%2zu] = %+f ", i, in[i]); if (i < N / 2 + 1) printf("out[%2zu] = %+f , %+f", i, out[i].r, out[i].i); printf("\n"); } } else { printf("not enough memory?\n"); exit(-1); } } int main(void) { kiss_fft_scalar in[N]; kiss_fft_cpx out[N / 2 + 1]; size_t i; for (i = 0; i < N; i++) in[i] = 0; TestFftReal("Zeroes (real)", in, out); for (i = 0; i < N; i++) in[i] = 1; TestFftReal("Ones (real)", in, out); for (i = 0; i < N; i++) in[i] = sin(2 * M_PI * 4 * i / N); TestFftReal("SineWave (real)", in, out); return 0; }
Use ! instead of |, looks nicer also saves two bytes
#define L for(char*c=a[1],y;*c;)printf("%c%c%c%c",(y="w$]m.k{%\177o"[*c++-48])&u/4?124:32,y&u?95:32,y&u/2?124:32,*c?32:10);u*=8; main(int u,char**a){u=1;L;L;L}
#define L for(char*c=a[1],y;*c;)printf("%c%c%c%c",(y="w$]m.k{%\177o"[*c++-48])&u/4?33:32,y&u?95:32,y&u/2?33:32,*c?32:10);u*=8; main(int u,char**a){u=1;L;L;L}
Enable raw mode in terminal
#include <unistd.h> int main() { char c; while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q'); return 0; }
#include <termios.h> #include <unistd.h> void enableRawMode() { struct termios raw; tcgetattr(STDIN_FILENO, &raw); raw.c_lflag &= ~(ECHO); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enableRawMode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q'); return 0; }
Clear errno, just to be sure.
/* This is not a proper strtod() implementation, but sufficient for Python. Python won't detect floating point constant overflow, though. */ extern int strlen(); extern double atof(); double strtod(p, pp) char *p; char **pp; { if (pp) *pp = p + strlen(p); return atof(p); }
/* This is not a proper strtod() implementation, but sufficient for Python. Python won't detect floating point constant overflow, though. */ extern int errno; extern int strlen(); extern double atof(); double strtod(p, pp) char *p; char **pp; { double res; if (pp) *pp = p + strlen(p); res = atof(p); errno = 0; return res; }
Fix documentation parameter name warnings
@class NSString; /** * Returns a string appropriate for displaying in test output * from the provided value. * * @param value A value that will show up in a test's output. * * @return The string that is returned can be * customized per type by conforming a type to the `TestOutputStringConvertible` * protocol. When stringifying a non-`TestOutputStringConvertible` type, this * function will return the value's debug description and then its * normal description if available and in that order. Otherwise it * will return the result of constructing a string from the value. * * @see `TestOutputStringConvertible` */ extern NSString *_Nonnull NMBStringify(id _Nullable anyObject) __attribute__((warn_unused_result));
@class NSString; /** * Returns a string appropriate for displaying in test output * from the provided value. * * @param anyObject A value that will show up in a test's output. * * @return The string that is returned can be * customized per type by conforming a type to the `TestOutputStringConvertible` * protocol. When stringifying a non-`TestOutputStringConvertible` type, this * function will return the value's debug description and then its * normal description if available and in that order. Otherwise it * will return the result of constructing a string from the value. * * @see `TestOutputStringConvertible` */ extern NSString *_Nonnull NMBStringify(id _Nullable anyObject) __attribute__((warn_unused_result));
Add member variables for storing disk info
#pragma once #include <Windows.h> #include <string> class DiskInfo { public: DiskInfo(wchar_t driveLetter); static std::wstring DriveFileName(wchar_t &driveLetter); static std::wstring DriveFileName(std::wstring &driveLetter); private: HANDLE _devHandle; };
#pragma once #include <Windows.h> #include <string> class DiskInfo { public: DiskInfo(wchar_t driveLetter); static std::wstring DriveFileName(wchar_t &driveLetter); static std::wstring DriveFileName(std::wstring &driveLetter); private: HANDLE _devHandle; std::wstring _productId; std::wstring _vendorId; };
Add Bad Request error code
// // BBAAPIErrors.h // BBAAPI // // Created by Owen Worley on 11/08/2014. // Copyright (c) 2014 Blinkbox Books. All rights reserved. // NS_ENUM(NSInteger, BBAAPIError) { /** * Used when needed parameter is not supplied to the method * or when object is supplied but it has wrong type or * for example one of it's needed properties is not set */ BBAAPIWrongUsage = 700, /** * Error returned when for any reason API call cannot connect to the server */ BBAAPIErrorCouldNotConnect = 701, /** * Returned when call cannot be authenticated, or when server returns 401 */ BBAAPIErrorUnauthorised = 702, /** * Used when server cannot find a resource and returns 404 */ BBAAPIErrorNotFound = 703, /** * Used when server returns 500 */ BBAAPIServerError = 704, /** * Used when server returns 403 */ BBAAPIErrorForbidden = 705, /** * Used when we cannot decode or read data returned from the server */ BBAAPIUnreadableData = 706, };
// // BBAAPIErrors.h // BBAAPI // // Created by Owen Worley on 11/08/2014. // Copyright (c) 2014 Blinkbox Books. All rights reserved. // NS_ENUM(NSInteger, BBAAPIError) { /** * Used when needed parameter is not supplied to the method * or when object is supplied but it has wrong type or * for example one of it's needed properties is not set */ BBAAPIWrongUsage = 700, /** * Error returned when for any reason API call cannot connect to the server */ BBAAPIErrorCouldNotConnect = 701, /** * Returned when call cannot be authenticated, or when server returns 401 */ BBAAPIErrorUnauthorised = 702, /** * Used when server cannot find a resource and returns 404 */ BBAAPIErrorNotFound = 703, /** * Used when server returns 500 */ BBAAPIServerError = 704, /** * Used when server returns 403 */ BBAAPIErrorForbidden = 705, /** * Used when we cannot decode or read data returned from the server */ BBAAPIUnreadableData = 706, /** * Used when the server returns a 400 (Bad Request) */ BBAAPIBadRequest = 707, };
Remove 'using' directive from header, explicitly qualify std namespace.
#ifndef SQREDIR_BLOCKLIST_H #define SQREDIR_BLOCKLIST_H #include <cstdio> #include <string> using namespace std; // reads the given configuration file // returns: true/false for success/failure bool read_config(string filename); // tries to match the Squid request & writes the response to the output stream // input: a request line as passed by Squid // output: response output stream (usually stdout) void match_and_reply(const char* input, FILE* output); #endif
#ifndef SQREDIR_BLOCKLIST_H #define SQREDIR_BLOCKLIST_H #include <cstdio> #include <string> // reads the given configuration file // returns: true/false for success/failure bool read_config(std::string filename); // tries to match the Squid request & writes the response to the output stream // input: a request line as passed by Squid // output: response output stream (usually stdout) void match_and_reply(const char* input, FILE* output); #endif
Change header guard name to do not colide with JPetMCHit
/** * @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may find a copy of the License in the LICENCE file. * * 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. * * @file JPetMCDecayTree.h */ #ifndef _JPETMCHIT_H_ #define _JPETMCHIT_H_ #include "./JPetHit/JPetHit.h" /** * @brief Data class representing a hit of a photon in the scintillator strip based on Monte Carlo simulation. * */ class JPetMCDecayTree : public TObject { public: JPetMCDecayTree(); private: UInt_t fMCMCDecayTreeIndex = 0u; UInt_t fMCVtxIndex = 0u; UInt_t fnVertices = 0u; UInt_t fnTracks = 0u; // add also track and vertices structures ClassDef(JPetMCDecayTree, 1); }; #endif
/** * @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may find a copy of the License in the LICENCE file. * * 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. * * @file JPetMCDecayTree.h */ #ifndef _JPETMCDECAYTREE_H_ #define _JPETMCDECAYTREE_H_ #include "./JPetHit/JPetHit.h" /** * @brief Data class representing a hit of a photon in the scintillator strip based on Monte Carlo simulation. * */ class JPetMCDecayTree : public TObject { public: JPetMCDecayTree(); private: UInt_t fMCMCDecayTreeIndex = 0u; UInt_t fMCVtxIndex = 0u; UInt_t fnVertices = 0u; UInt_t fnTracks = 0u; // add also track and vertices structures ClassDef(JPetMCDecayTree, 1); }; #endif
Delete TickComponent ( because of tick manager )
#pragma once #include "MileObject.h" namespace Mile { /** * ActorComponent Actor ߰ ִ ϴ Component ⺻ ŬԴϴ. */ class Actor; class MILE_API ActorComponent : public MileObject { friend Actor; public: ActorComponent( const MString& NewName ) : bIsTick( false ), OwnerPrivate( nullptr ), TickPriority( 0 ), MileObject( NewName ) { } ActorComponent( ActorComponent&& MovedObject ) : OwnerPrivate( MovedObject.OwnerPrivate ), bIsTick( MovedObject.bIsTick ), TickPriority( MovedObject.TickPriority ), MileObject( std::move( MovedObject ) ) { this->SetOwner( MovedObject.GetOwner( ) ); MovedObject.SetOwner( nullptr ); MovedObject.bIsTick = false; MovedObject.TickPriority = UINT64_MAX; } ActorComponent& operator=( ActorComponent&& MovedObject ) = delete; void SetOwner( Actor* Owner, bool bIsDetachBeforeSetNewOwner = true ); virtual void SetOwnerRecursively( Actor* NewOwner, bool bIsDetachBeforeSetNewOwner = true ); FORCEINLINE Actor* GetOwner( ) const { return OwnerPrivate; } virtual void TickComponent( float DeltaTime ) {} private: Actor* OwnerPrivate; public: bool bIsTick; uint64 TickPriority; }; }
#pragma once #include "MileObject.h" namespace Mile { /** * ActorComponent Actor ߰ ִ ϴ Component ⺻ ŬԴϴ. */ class Actor; class MILE_API ActorComponent : public MileObject { friend Actor; public: ActorComponent( const MString& NewName ) : bIsTick( false ), OwnerPrivate( nullptr ), TickPriority( 0 ), MileObject( NewName ) { } ActorComponent( ActorComponent&& MovedObject ) : OwnerPrivate( MovedObject.OwnerPrivate ), bIsTick( MovedObject.bIsTick ), TickPriority( MovedObject.TickPriority ), MileObject( std::move( MovedObject ) ) { this->SetOwner( MovedObject.GetOwner( ) ); MovedObject.SetOwner( nullptr ); MovedObject.bIsTick = false; MovedObject.TickPriority = UINT64_MAX; } ActorComponent& operator=( ActorComponent&& MovedObject ) = delete; void SetOwner( Actor* Owner, bool bIsDetachBeforeSetNewOwner = true ); virtual void SetOwnerRecursively( Actor* NewOwner, bool bIsDetachBeforeSetNewOwner = true ); FORCEINLINE Actor* GetOwner( ) const { return OwnerPrivate; } virtual void Tick( float DeltaTime ) { UNUSED_PARAM( DeltaTime ); } private: Actor* OwnerPrivate; bool bIsTick; uint64 TickPriority; }; }
Improve compatibility with older ESP32 Arduino core versions
#pragma once #include "esp32-hal.h" #ifndef ESP32 #define ESP32 #endif #define FASTLED_ESP32 #if CONFIG_IDF_TARGET_ARCH_RISCV #define FASTLED_RISCV #endif #if CONFIG_IDF_TARGET_ARCH_XTENSA || CONFIG_XTENSA_IMPL #define FASTLED_XTENSA #endif // Use system millis timer #define FASTLED_HAS_MILLIS typedef volatile uint32_t RoReg; typedef volatile uint32_t RwReg; typedef unsigned long prog_uint32_t; // Default to NOT using PROGMEM here #ifndef FASTLED_USE_PROGMEM # define FASTLED_USE_PROGMEM 0 #endif #ifndef FASTLED_ALLOW_INTERRUPTS # define FASTLED_ALLOW_INTERRUPTS 1 # define INTERRUPT_THRESHOLD 0 #endif #define NEED_CXX_BITS // These can be overridden # define FASTLED_ESP32_RAW_PIN_ORDER
#pragma once #include "esp32-hal.h" #ifndef ESP32 #define ESP32 #endif #define FASTLED_ESP32 #if CONFIG_IDF_TARGET_ARCH_RISCV #define FASTLED_RISCV #else #define FASTLED_XTENSA #endif // Handling for older versions of ESP32 Arduino core #if !defined(ESP_IDF_VERSION) // Older versions of ESP_IDF only supported ESP32 #define CONFIG_IDF_TARGET_ESP32 1 // Define missing version macros. Hard code older version 3.0 since actual version is unknown #define ESP_IDF_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch)) #define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(3, 0, 0) #endif // Use system millis timer #define FASTLED_HAS_MILLIS typedef volatile uint32_t RoReg; typedef volatile uint32_t RwReg; typedef unsigned long prog_uint32_t; // Default to NOT using PROGMEM here #ifndef FASTLED_USE_PROGMEM # define FASTLED_USE_PROGMEM 0 #endif #ifndef FASTLED_ALLOW_INTERRUPTS # define FASTLED_ALLOW_INTERRUPTS 1 # define INTERRUPT_THRESHOLD 0 #endif #define NEED_CXX_BITS // These can be overridden # define FASTLED_ESP32_RAW_PIN_ORDER
Add another debug check to bigstructs
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2012 Raymond Jennings * * This program 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. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <kotaka/assert.h> #include <kotaka/paths.h> #include <kotaka/privilege.h> #include <kotaka/log.h> private object root; static void create() { root = previous_object(); } static void destruct() { } static void check_caller() { ACCESS_CHECK(previous_object() == root); } nomask object query_root() { return root; }
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2012 Raymond Jennings * * This program 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. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <kotaka/assert.h> #include <kotaka/paths.h> #include <kotaka/privilege.h> #include <kotaka/log.h> private object root; static void create() { root = previous_object(); } static void destruct() { } static void check_caller() { ASSERT(root); ACCESS_CHECK(previous_object() == root); } nomask object query_root() { return root; }
Use other format specifers on Windows.
#if defined(WIN32) || defined(_WIN32) || \ defined(__WIN32) && !defined(__CYGWIN__) #include <BaseTsd.h> #include <windows.h> typedef SSIZE_T ssize_t; #endif #ifndef _WIN32 #include <unistd.h> #endif #include <inttypes.h> typedef char *String; typedef char *Pattern; typedef int64_t Long; #if defined NDEBUG #define CHK_INDEX(i, n) #else #define CHK_INDEX_FORMAT_STRING ":%u: bad index: %zd < %zd\n" #define CHK_INDEX(i, n) \ do { \ size_t __si = (size_t)i; \ size_t __ni = (size_t)n; \ if (!(__si < __ni)) { \ printf(__FILE__ CHK_INDEX_FORMAT_STRING, __LINE__, (ssize_t)i, \ (ssize_t)n); \ abort(); \ } \ } while (0) #endif // Array typedef struct { size_t len; size_t capacity; void *data; } Array; // Lambdas typedef struct { void *callback; void *env; void *delete; void *copy; } Lambda; typedef void *LambdaEnv;
#if defined(WIN32) || defined(_WIN32) || \ defined(__WIN32) && !defined(__CYGWIN__) #include <BaseTsd.h> #include <windows.h> typedef SSIZE_T ssize_t; #define SIZE_T_FORMAT_SPECIFIER "%ld" #endif #ifndef _WIN32 #include <unistd.h> #define SIZE_T_FORMAT_SPECIFIER "%zd" #endif #include <inttypes.h> typedef char *String; typedef char *Pattern; typedef int64_t Long; #if defined NDEBUG #define CHK_INDEX(i, n) #else #define CHK_INDEX_FORMAT_STRING ":%u: bad index: " SIZE_T_FORMAT_SPECIFIER " < " SIZE_T_FORMAT_SPECIFIER "\n" #define CHK_INDEX(i, n) \ do { \ size_t __si = (size_t)i; \ size_t __ni = (size_t)n; \ if (!(__si < __ni)) { \ printf(__FILE__ CHK_INDEX_FORMAT_STRING, __LINE__, (ssize_t)i, \ (ssize_t)n); \ abort(); \ } \ } while (0) #endif // Array typedef struct { size_t len; size_t capacity; void *data; } Array; // Lambdas typedef struct { void *callback; void *env; void *delete; void *copy; } Lambda; typedef void *LambdaEnv;
Add an Allocator interface that indicates if memory is zero init
/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "SkBitmap.h" #include "SkCodec.h" /** * Abstract subclass of SkBitmap's allocator. * Allows the allocator to indicate if the memory it allocates * is zero initialized. */ class SkBRDAllocator : public SkBitmap::Allocator { public: /** * Indicates if the memory allocated by this allocator is * zero initialized. */ virtual SkCodec::ZeroInitialized zeroInit() const = 0; };
Use compiler_rt version of clz and ctz
/* Copyright 2014 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef __CROS_EC_CONFIG_CORE_H #define __CROS_EC_CONFIG_CORE_H /* Linker binary architecture and format */ #define BFD_ARCH arm #define BFD_FORMAT "elf32-littlearm" /* Emulate the CLZ/CTZ instructions since the CPU core is lacking support */ #define CONFIG_SOFTWARE_CLZ #define CONFIG_SOFTWARE_CTZ #define CONFIG_SOFTWARE_PANIC #define CONFIG_ASSEMBLY_MULA32 #endif /* __CROS_EC_CONFIG_CORE_H */
/* Copyright 2014 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef __CROS_EC_CONFIG_CORE_H #define __CROS_EC_CONFIG_CORE_H /* Linker binary architecture and format */ #define BFD_ARCH arm #define BFD_FORMAT "elf32-littlearm" /* * Emulate the CLZ/CTZ instructions since the CPU core is lacking support. * When building with clang, we rely on compiler_rt to provide this support. */ #ifndef __clang__ #define CONFIG_SOFTWARE_CLZ #define CONFIG_SOFTWARE_CTZ #endif /* __clang__ */ #define CONFIG_SOFTWARE_PANIC #define CONFIG_ASSEMBLY_MULA32 #endif /* __CROS_EC_CONFIG_CORE_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
Fix stratified sampler to use minstd_rand
#ifndef STRATIFIED_SAMPLER_H #define STRATIFIED_SAMPLER_H #include <random> #include <memory> #include <array> #include <vector> #include "sampler.h" /* * A stratified sampler, generates multipled jittered * samples per pixel in its sample region */ class StratifiedSampler : public Sampler { const int spp; std::mt19937 rng; std::uniform_real_distribution<float> distrib; public: StratifiedSampler(int x_start, int x_end, int y_start, int y_end, int spp); /* * Get some {x, y} positions to sample in the space being sampled * If the sampler has finished sampling samples will be empty */ void get_samples(std::vector<Sample> &samples) override; /* * Get subsamplers that divide the space to be sampled * into count disjoint subsections where each samples a w x h * section of the original sampler */ std::vector<std::unique_ptr<Sampler>> get_subsamplers(int w, int h) const override; private: /* * Generate a 2d pattern of stratified samples and return them * sample positions will be normalized between [0, 1) */ void sample2d(std::vector<Sample> &samples); }; #endif
#ifndef STRATIFIED_SAMPLER_H #define STRATIFIED_SAMPLER_H #include <random> #include <memory> #include <array> #include <vector> #include "sampler.h" /* * A stratified sampler, generates multipled jittered * samples per pixel in its sample region */ class StratifiedSampler : public Sampler { const int spp; std::minstd_rand rng; std::uniform_real_distribution<float> distrib; public: StratifiedSampler(int x_start, int x_end, int y_start, int y_end, int spp); /* * Get some {x, y} positions to sample in the space being sampled * If the sampler has finished sampling samples will be empty */ void get_samples(std::vector<Sample> &samples) override; /* * Get subsamplers that divide the space to be sampled * into count disjoint subsections where each samples a w x h * section of the original sampler */ std::vector<std::unique_ptr<Sampler>> get_subsamplers(int w, int h) const override; private: /* * Generate a 2d pattern of stratified samples and return them * sample positions will be normalized between [0, 1) */ void sample2d(std::vector<Sample> &samples); }; #endif
Fix crash when dragging a thread state track
// Copyright (c) 2020 The Orbit 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 ORBIT_GL_THREAD_STATE_TRACK_H_ #define ORBIT_GL_THREAD_STATE_TRACK_H_ #include "Track.h" // This is a track dedicated to displaying thread states in different colors // and with the corresponding tooltips. // It is a thin sub-track of ThreadTrack, added above the callstack track (EventTrack). // The colors are determined only by the states, not by the color assigned to the thread. class ThreadStateTrack final : public Track { public: ThreadStateTrack(TimeGraph* time_graph, int32_t thread_id); Type GetType() const override { return kThreadStateTrack; } void Draw(GlCanvas* canvas, PickingMode picking_mode, float z_offset) override; void UpdatePrimitives(uint64_t min_tick, uint64_t max_tick, PickingMode picking_mode, float z_offset) override; void OnPick(int x, int y) override; void OnRelease() override { picked_ = false; }; float GetHeight() const override { return size_[1]; } bool IsEmpty() const; private: std::string GetThreadStateSliceTooltip(PickingId id) const; }; #endif // ORBIT_GL_THREAD_STATE_TRACK_H_
// Copyright (c) 2020 The Orbit 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 ORBIT_GL_THREAD_STATE_TRACK_H_ #define ORBIT_GL_THREAD_STATE_TRACK_H_ #include "Track.h" // This is a track dedicated to displaying thread states in different colors // and with the corresponding tooltips. // It is a thin sub-track of ThreadTrack, added above the callstack track (EventTrack). // The colors are determined only by the states, not by the color assigned to the thread. class ThreadStateTrack final : public Track { public: ThreadStateTrack(TimeGraph* time_graph, int32_t thread_id); Type GetType() const override { return kThreadStateTrack; } void Draw(GlCanvas* canvas, PickingMode picking_mode, float z_offset) override; void UpdatePrimitives(uint64_t min_tick, uint64_t max_tick, PickingMode picking_mode, float z_offset) override; void OnPick(int x, int y) override; void OnDrag(int, int) override {} void OnRelease() override { picked_ = false; }; float GetHeight() const override { return size_[1]; } bool IsEmpty() const; private: std::string GetThreadStateSliceTooltip(PickingId id) const; }; #endif // ORBIT_GL_THREAD_STATE_TRACK_H_
Fix return value for logging channel write
/* * Copyright 2019 The Project Oak 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. */ #ifndef OAK_SERVER_LOGGING_CHANNEL_H #define OAK_SERVER_LOGGING_CHANNEL_H #include "oak/server/channel.h" namespace oak { // A channel implementation that only has a send half, which logs to stderr the data written to it. class LoggingChannelHalf final : public ChannelHalf { public: uint32_t Write(absl::Span<const char> data) override { std::string log_message(data.cbegin(), data.cend()); LOG(INFO) << "LOG: " << log_message; }; }; } // namespace oak #endif // OAK_SERVER_LOGGING_CHANNEL_H
/* * Copyright 2019 The Project Oak 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. */ #ifndef OAK_SERVER_LOGGING_CHANNEL_H #define OAK_SERVER_LOGGING_CHANNEL_H #include "oak/server/channel.h" namespace oak { // A channel implementation that only has a send half, which logs to stderr the data written to it. class LoggingChannelHalf final : public ChannelHalf { public: uint32_t Write(absl::Span<const char> data) override { std::string log_message(data.cbegin(), data.cend()); LOG(INFO) << "LOG: " << log_message; return data.size(); } }; } // namespace oak #endif // OAK_SERVER_LOGGING_CHANNEL_H
Fix the spdlog issue on 32bit systems: Failed getting file size from fd
#pragma once #ifdef _WIN32 #include <SDKDDKVer.h> //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> #define tstring std::wstring #define WidenHelper(x) L##x #define LITERAL(x) WidenHelper(x) #else // ifdef _WIN32 #define tstring std::string #define LITERAL(x) (x) #endif /* Don't let Python.h #define (v)snprintf as macro because they are implemented properly in Visual Studio since 2015. */ #if defined(_MSC_VER) && _MSC_VER >= 1900 # define HAVE_SNPRINTF 1 #endif #include <queue> #include <random> #include <string> #include <vector> #include <unordered_set> #include <unordered_map> #include "third_party/spdlog/spdlog.h"
#pragma once #ifdef _WIN32 #include <SDKDDKVer.h> //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> #define tstring std::wstring #define WidenHelper(x) L##x #define LITERAL(x) WidenHelper(x) #else // ifdef _WIN32 #define tstring std::string #define LITERAL(x) (x) // Prevents this error: Failed getting file size from fd: Value too large for defined data type #define _FILE_OFFSET_BITS 64 #endif /* Don't let Python.h #define (v)snprintf as macro because they are implemented properly in Visual Studio since 2015. */ #if defined(_MSC_VER) && _MSC_VER >= 1900 # define HAVE_SNPRINTF 1 #endif #include <queue> #include <random> #include <string> #include <vector> #include <unordered_set> #include <unordered_map> #include "third_party/spdlog/spdlog.h"
Adjust this to the wonky syntax that GCC expects.
// RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llvm-dis | grep llvm.used | grep foo | grep X int X __attribute__((used)); int Y; void foo() __attribute__((used)); void foo() {}
// RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llvm-dis | grep llvm.used | grep foo | grep X int X __attribute__((used)); int Y; __attribute__((used)) void foo() {}
Fix grammatical error in comment.
/*------------------------------------------------------------------------- * * nodes.c * support code for nodes (now that we get rid of the home-brew * inheritance system, our support code for nodes get much simpler) * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $PostgreSQL: pgsql/src/backend/nodes/nodes.c,v 1.22 2003/11/29 19:51:49 pgsql Exp $ * * HISTORY * Andrew Yu Oct 20, 1994 file creation * *------------------------------------------------------------------------- */ #include "postgres.h" #include "nodes/nodes.h" /* * Support for newNode() macro */ Node *newNodeMacroHolder;
/*------------------------------------------------------------------------- * * nodes.c * support code for nodes (now that we have removed the home-brew * inheritance system, our support code for nodes is much simpler) * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $PostgreSQL: pgsql/src/backend/nodes/nodes.c,v 1.23 2004/05/06 06:11:01 neilc Exp $ * * HISTORY * Andrew Yu Oct 20, 1994 file creation * *------------------------------------------------------------------------- */ #include "postgres.h" #include "nodes/nodes.h" /* * Support for newNode() macro */ Node *newNodeMacroHolder;