Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Make these a bit more correct
// // Copyright 2013 Jeff Bush // // 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. // // // Symbols that need to be defined to use C++. These are stubs and don't // actually do anything // namespace __cxxabiv1 { class __class_type_info { public: __class_type_info() {} virtual ~__class_type_info() {} }; class __si_class_type_info { public: __si_class_type_info() {} virtual ~__si_class_type_info() {} }; __class_type_info cti; __si_class_type_info sicti; } void operator delete(void *ptr) throw() { } extern "C" void __dso_handle() { } extern "C" void __cxa_atexit() { }
// // Copyright 2013 Jeff Bush // // 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. // // // Symbols that need to be defined to use C++. These are stubs and don't // actually do anything // namespace __cxxabiv1 { class __class_type_info { public: __class_type_info() {} virtual ~__class_type_info() {} }; class __si_class_type_info { public: __si_class_type_info() {} virtual ~__si_class_type_info() {} }; __class_type_info cti; __si_class_type_info sicti; } void operator delete(void *ptr) throw() { } void *__dso_handle; extern "C" void __cxa_atexit(void (*f)(void *), void *objptr, void *dso) { }
Add a codec for Tileset
#pragma once #include <spotify/json.hpp> #include "Tileset.h" using namespace spotify::json::codec; namespace spotify { namespace json { template<> struct default_codec_t<Tileset> { static object_t<Tileset> codec() { auto codec = object<Tileset>(); codec.required("resolution", &Tileset::resolution); codec.required("filename", &Tileset::filename); codec.required("x", &Tileset::x); codec.required("y", &Tileset::y); codec.required("terrains", &Tileset::terrains); return codec; } }; } }
Define data types for structured command handling
#ifndef LACO_COMMANDS_H #define LACO_COMMANDS_H struct LacoState; /** * Gets passed ever line to see if it matches one of the REPL command. If it * does, that command will be executed. */ void laco_handle_command(struct LacoState* laco, char* line); #endif /* LACO_COMMANDS_H */
#ifndef LACO_COMMANDS_H #define LACO_COMMANDS_H struct LacoState; typedef void (*LacoHandler)(struct LacoState* laco, const char** arguments); struct LacoCommand { const char** matches; LacoHandler handler; }; /** * Gets passed ever line to see if it matches one of the REPL command. If it * does, that command will be executed. */ void laco_handle_command(struct LacoState* laco, char* line); #endif /* LACO_COMMANDS_H */
Verify array of colors is contigous
/* * Copyright (C) 2015 Luke San Antonio * All rights reserved. */ #pragma once #include "glad/glad.h" #include "../texture.h" namespace game { namespace gfx { namespace gl { struct GL_Texture : public Texture { void allocate_(Vec<int> const&, Image_Format) noexcept override; inline void blit_data_(Volume<int> const& vol, Color const* data) noexcept override { // Fuck it, it might work. blit_data_(vol, Data_Type::Integer, data); } inline void blit_data_(Volume<int> const& vol, float const* data) noexcept override { blit_data_(vol, Data_Type::Float, data); } void blit_data_(Volume<int> const&, Data_Type, void const*) noexcept override; GLuint tex_id; GLenum texture_type; Image_Format format_; void bind(unsigned int loc) const noexcept; }; } } }
/* * Copyright (C) 2015 Luke San Antonio * All rights reserved. */ #pragma once #include "glad/glad.h" #include "../texture.h" namespace game { namespace gfx { namespace gl { struct GL_Texture : public Texture { void allocate_(Vec<int> const&, Image_Format) noexcept override; inline void blit_data_(Volume<int> const& vol, Color const* data) noexcept override { // Fuck it, it might work. static_assert(sizeof(Color) == sizeof(Color::c_t) * 4, "Color struct must not have any padding."); blit_data_(vol, Data_Type::Integer, data); } inline void blit_data_(Volume<int> const& vol, float const* data) noexcept override { blit_data_(vol, Data_Type::Float, data); } void blit_data_(Volume<int> const&, Data_Type, void const*) noexcept override; GLuint tex_id; GLenum texture_type; Image_Format format_; void bind(unsigned int loc) const noexcept; }; } } }
Adjust declaration for taskstats io call
#ifndef DISK_H #define DISK_H #include "../process/process.h" #ifdef __i386__ #define IOPRIO_GET 290 #elif __x86_64__ #define IOPRIO_GET 252 #endif #define IOPRIO_WHO_PROCESS 1 #define IOPRIO_CLASS_SHIFT (13) #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) #define PRIOLEN 8 char *filesystem_type(void); int ioprio_get(int pid); char *ioprio_class(int pid); char *ioprio_class_nice(int pid); void proc_io(proc_t *procs); #endif
#ifndef DISK_H #define DISK_H #include <stdint.h> #include "../process/process.h" #ifdef __i386__ #define IOPRIO_GET 290 #elif __x86_64__ #define IOPRIO_GET 252 #endif #define IOPRIO_WHO_PROCESS 1 #define IOPRIO_CLASS_SHIFT (13) #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) #define PRIOLEN 8 char *filesystem_type(void); int ioprio_get(int pid); char *ioprio_class(int pid); char *ioprio_class_nice(int pid); uint64_t get_process_taskstat_io(int pid, char field); #endif
Remove deprecated function and use class to define a Point
#pragma once struct Point{ double x,y; Point(); /* first double input param: x coordinate. second double input param: y coordinate. */ Point(double,double); bool operator<(Point)const; bool operator==(Point)const; }; double dist(Point a,Point b);
#pragma once class Point{ public: double x,y; Point(); /* first double input param: x coordinate. second double input param: y coordinate. */ Point(double,double); bool operator<(Point)const; bool operator==(Point)const; };
Change another float to double.
#include <string.h> #include "proxrcmds.h" #include "sim-hab.h" void cb_set_resource(bionet_resource_t *resource, bionet_value_t *value) { double data; double content; int id; bionet_node_t *node; bionet_value_get_float(value, &data); if(data < 0 || data > 255) return; node = bionet_resource_get_node(resource); // get index of resource //FIXME: probably a better way to do this for(int i=0; i<16; i++) { char buf[5]; char name[24]; strcpy(name, "Potentiometer\0"); sprintf(buf,"%d", i); int len = strlen(buf); buf[len] = '\0'; strcat(name, buf); if(bionet_resource_matches_id(resource, name)) { id = i; // command proxr to adjust to new value set_potentiometer(id, (int)data); // set resources datapoint to new value content = data*POT_CONVERSION; bionet_resource_set_double(resource, content, NULL); hab_report_datapoints(node); return; } } }
#include <string.h> #include "proxrcmds.h" #include "sim-hab.h" void cb_set_resource(bionet_resource_t *resource, bionet_value_t *value) { double data; double content; int id; bionet_node_t *node; bionet_value_get_double(value, &data); if(data < 0 || data > 255) return; node = bionet_resource_get_node(resource); // get index of resource //FIXME: probably a better way to do this for(int i=0; i<16; i++) { char buf[5]; char name[24]; strcpy(name, "Potentiometer\0"); sprintf(buf,"%d", i); int len = strlen(buf); buf[len] = '\0'; strcat(name, buf); if(bionet_resource_matches_id(resource, name)) { id = i; // command proxr to adjust to new value set_potentiometer(id, (int)data); // set resources datapoint to new value content = data*POT_CONVERSION; bionet_resource_set_double(resource, content, NULL); hab_report_datapoints(node); return; } } }
Use the new assert() macro
#include <assert.h> #include "fnv_1a.h" uint128_t fnv_1a(const void * restrict const buf, const size_t len, const size_t skip_pos, const size_t skip_len) { assert((skip_pos <= len) && (skip_pos + skip_len <= len)); static const uint128_t prime = (((uint128_t)0x0000000001000000) << 64) | 0x000000000000013B; uint128_t hash = (((uint128_t)0x6C62272E07BB0142) << 64) | 0x62B821756295C58D; // two consecutive loops should be faster than one loop with an "if" const uint8_t * restrict const bytes = buf; for (size_t i = 0; i < skip_pos; i++) { hash ^= bytes[i]; hash *= prime; } for (size_t i = skip_pos + skip_len; i < len; i++) { hash ^= bytes[i]; hash *= prime; } return hash; }
#include "fnv_1a.h" #include "debug.h" uint128_t fnv_1a(const void * restrict const buf, const size_t len, const size_t skip_pos, const size_t skip_len) { assert((skip_pos <= len) && (skip_pos + skip_len <= len), "len %zu, skip_pos %zu, skip_len %zu", len, skip_pos, skip_len); static const uint128_t prime = (((uint128_t)0x0000000001000000) << 64) | 0x000000000000013B; uint128_t hash = (((uint128_t)0x6C62272E07BB0142) << 64) | 0x62B821756295C58D; // two consecutive loops should be faster than one loop with an "if" const uint8_t * restrict const bytes = buf; for (size_t i = 0; i < skip_pos; i++) { hash ^= bytes[i]; hash *= prime; } for (size_t i = skip_pos + skip_len; i < len; i++) { hash ^= bytes[i]; hash *= prime; } return hash; }
Update outdated comments in the XML parser header
// // RKXMLParser.h // // Created by Jeremy Ellison on 2011-02-28. // Copyright 2011 RestKit // // 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. // #import <Foundation/Foundation.h> #import "../../RKParser.h" /** This is a dead simple XML parser that uses libxml2 to parse an XML document into a dictionary. It is designed specifically for use with RestKit. It does not support any fanciness like Namespaces, DTDs, or other nonsense. It does not save attributes on tags, it only cares about nested content and text. */ @interface RKXMLParserLibXML : NSObject <RKParser> { } - (NSDictionary*)parseXML:(NSString*)XML; @end
// // RKXMLParser.h // // Created by Jeremy Ellison on 2011-02-28. // Copyright 2011 RestKit // // 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. // #import <Foundation/Foundation.h> #import "../../RKParser.h" /** This is a dead simple XML parser that uses libxml2 to parse an XML document into a dictionary. It is designed specifically for use with RestKit. It does not support any fanciness like Namespaces, DTDs, or other nonsense. It handles text nodes, attributes, and nesting structures and builds key-value coding compliant representations of the XML structure. It currently does not support XML generation -- only parsing. */ @interface RKXMLParserLibXML : NSObject <RKParser> { } - (NSDictionary *)parseXML:(NSString *)XML; @end
Update Skia milestone to 59
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 58 #endif
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 59 #endif
Restructure implementation and documentation of DATA/libbad_data_t
/** * @file include/libbad_base.h * @author Bryce Davis * @date 19 November 2015 * @brief Header file for internal libbad declarations * @copyright Copyright (c) 2015, Bryce Davis. Released under the MIT License. * See LICENSE.txt for details. */ #ifndef _LIBBAD_BASE_H #define _LIBBAD_BASE_H /** * @typedef A convenience typedef for long long ints. */ typedef long long int llint; /** * @typedef A convenience typedef for long doubles. */ typedef long double ldouble; /** * @union DATA * @brief A data value for libbad data structures. * * A DATA can hold either a long long int, a long double, or a pointer. Takes * up 16 bytes. */ typedef union libbad_data_t { llint data_int; ldouble data_dbl; void* data_ptr; } DATA; #endif
/** * @file include/libbad_base.h * @author Bryce Davis * @date 19 November 2015 * @brief Header file for internal libbad declarations * @copyright Copyright (c) 2015, Bryce Davis. Released under the MIT License. * See LICENSE.txt for details. */ #ifndef _LIBBAD_BASE_H #define _LIBBAD_BASE_H /** * A convenience typedef for long long ints. */ typedef long long int llint; /** * A convenience typedef for long doubles. */ typedef long double ldouble; /** * @union libbad_data_t * @brief A data value for libbad data structures. * * An instance of libbad_data_t can hold either a long long int, a long double, * or a pointer. Takes up 16 bytes. */ union libbad_data_t { llint data_int; /**< A long long integer value (8 bytes) */ ldouble data_dbl; /**< A long double value (16 bytes) */ void* data_ptr; /**< A pointer value (8 bytes) */ }; /** * Use DATA instead of "union libbad_data_t" */ typedef union libbad_data_t DATA; #endif
Make an abstract DataValue class, and implement Double and IntegerValues
#include <vector> #include <map> #include <string> using namespace std; #ifndef OBJECTS_H #define OBJECTS_H union DataValue { string val_s; long int val_i; float val_f; double val_d; }; typedef map<string, DataValue> DataMap; typedef map<string, DataValue>::iterator DataIterator; class DataInstance { private: int weight; DataMap dataStore; public: DataInstance(); ~DataInstance(); }; class DataObject { private: vector<DataInstance> instances; public: DataObject(); ~DataObject(); }; #endif
#ifndef OBJECTS_H #define OBJECTS_H #include <vector> #include <map> #include <string> using namespace std; class IntDataValue : public DataValue { private: public: IntDataValue(int val): value(val); void compareWith(DataValue &I) { if(I.value < this->value) return -1; else if(I.value == this->value) return 0; return 1; } void updateTo(DataValue &I) { this->value = I.value; } int value; }; class DoubleDataValue : public DataValue { private: public: DoubleDataValue(double val): value(val); void compareWith(DataValue &I) { if(this->value < I.value) return -1; else if(I.value == this->value) return 0; return 1; } void updateTo(DataValue &I) { this->value = I.value; } double value; }; class DataValue { public: DataValue(); // CompareWith(I): return -1 if lesser, 0 if equal, 1 if greater virtual void compareWith(DataValue &I) = 0; // UpdateTo(I): updates value of current object to match I virtual void updateTo(DataValue &I) = 0; void updateIfLargerThan(DataValue &I) { /*Implement : check for typeId matching*/ if(this->compareWith(I)==1) this->updateTo(I); } ~DataValue(); }; typedef map<string, DataValue> DataMap; typedef map<string, DataValue>::iterator DataIterator; class DataInstance { private: int weight; DataMap dataStore; public: DataInstance(); DataInstance(DataInstance &instance); ~DataInstance(); }; class DataObject { private: vector<DataInstance> instances; public: DataObject(); ~DataObject(); }; #endif
Replace all user modules with token
// email=foo@bar.com // branch=master #ifndef __USER_MODULES_H__ #define __USER_MODULES_H__ #define LUA_USE_BUILTIN_STRING // for string.xxx() #define LUA_USE_BUILTIN_TABLE // for table.xxx() #define LUA_USE_BUILTIN_COROUTINE // for coroutine.xxx() #define LUA_USE_BUILTIN_MATH // for math.xxx(), partially work // #define LUA_USE_BUILTIN_IO // for io.xxx(), partially work // #define LUA_USE_BUILTIN_OS // for os.xxx(), not work // #define LUA_USE_BUILTIN_DEBUG // for debug.xxx(), not work #define LUA_USE_MODULES #ifdef LUA_USE_MODULES #define LUA_USE_MODULES_NODE #define LUA_USE_MODULES_FILE #define LUA_USE_MODULES_GPIO #define LUA_USE_MODULES_WIFI #define LUA_USE_MODULES_NET #define LUA_USE_MODULES_PWM #define LUA_USE_MODULES_I2C #define LUA_USE_MODULES_SPI #define LUA_USE_MODULES_TMR #define LUA_USE_MODULES_ADC #define LUA_USE_MODULES_UART #define LUA_USE_MODULES_OW #define LUA_USE_MODULES_BIT #define LUA_USE_MODULES_MQTT #define LUA_USE_MODULES_COAP #define LUA_USE_MODULES_U8G #define LUA_USE_MODULES_WS2812 #define LUA_USE_MODULES_CJSON #endif /* LUA_USE_MODULES */ #endif /* __USER_MODULES_H__ */
// email=foo@bar.com // branch=master #ifndef __USER_MODULES_H__ #define __USER_MODULES_H__ #define LUA_USE_BUILTIN_STRING // for string.xxx() #define LUA_USE_BUILTIN_TABLE // for table.xxx() #define LUA_USE_BUILTIN_COROUTINE // for coroutine.xxx() #define LUA_USE_BUILTIN_MATH // for math.xxx(), partially work // #define LUA_USE_BUILTIN_IO // for io.xxx(), partially work // #define LUA_USE_BUILTIN_OS // for os.xxx(), not work // #define LUA_USE_BUILTIN_DEBUG // for debug.xxx(), not work #define LUA_USE_MODULES #ifdef LUA_USE_MODULES // user modules #endif /* LUA_USE_MODULES */ #endif /* __USER_MODULES_H__ */
Add a test forgotten in r339088.
// RUN: %clang_analyze_cc1 -analyzer-checker=unix.StdCLibraryFunctions -verify %s // RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s // RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s // RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s // RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s // This test tests crashes that occur when standard functions are available // for inlining. // expected-no-diagnostics int isdigit(int _) { return !0; } void test_redefined_isdigit(int x) { int (*func)(int) = isdigit; for (; func(x);) // no-crash ; }
Make sh4 build works again adding a temporary work-around iby redefining __always_inline to inline until gcc 4.x.x will get fixed.
/* We can't use the real errno in ldso, since it has not yet * been dynamicly linked in yet. */ #include "sys/syscall.h" extern int _dl_errno; #undef __set_errno #define __set_errno(X) {(_dl_errno) = (X);}
/* We can't use the real errno in ldso, since it has not yet * been dynamicly linked in yet. */ #include "sys/syscall.h" extern int _dl_errno; #undef __set_errno #define __set_errno(X) {(_dl_errno) = (X);} #warning !!! __always_inline redefined waiting for the fixed gcc #ifdef __always_inline #undef __always_inline #define __always_inline inline #endif
Make a few things `inline`.
#pragma once #include "../../includes.h" namespace MOSS { namespace Interrupts { void disable_hw_int(void) { __asm__ __volatile__("cli"); } void enable_hw_int(void) { __asm__ __volatile__("sti"); } /*void fire(int n) { //Adapted from http://www.brokenthorn.com/Resources/OSDev15.html //Self-modifying code! asm( " movb al, [%0]" " movb [genint+1], al" " jmp genint" "genint:" " int 0" : //out :"n"(n) //in :"%al" //clobbered ); }*/ void fire_int13h(void) { __asm__ __volatile__("int $0x13"); } }}
#pragma once #include "../../includes.h" namespace MOSS { namespace Interrupts { inline void disable_hw_int(void) { __asm__ __volatile__("cli"); } inline void enable_hw_int(void) { __asm__ __volatile__("sti"); } /*inline void fire(int n) { //Adapted from http://www.brokenthorn.com/Resources/OSDev15.html //Self-modifying code! asm( " movb al, [%0]" " movb [genint+1], al" " jmp genint" "genint:" " int 0" : //out :"n"(n) //in :"%al" //clobbered ); }*/ inline void fire_int13h(void) { __asm__ __volatile__("int $0x13"); } }}
Add mode_t typedef when missing
/*! * Filename: zt_path.h * Description: path utils * * Author: Jason L. Shiffer <jshiffer@zerotao.org> * Copyright: * Copyright (C) 2010-2011, Jason L. Shiffer. * See file COPYING for details */ #ifndef _ZT_PATH_ #define _ZT_PATH_ #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif /* HAVE_SYS_STAT_H */ #include <zt.h> BEGIN_C_DECLS typedef enum { zt_mkdir_create_parent = 1, }zt_mkdir_flags; int zt_mkdir(char * path, mode_t mode, zt_mkdir_flags flags); END_C_DECLS #endif /* _ZT_PATH_ */
/*! * Filename: zt_path.h * Description: path utils * * Author: Jason L. Shiffer <jshiffer@zerotao.org> * Copyright: * Copyright (C) 2010-2011, Jason L. Shiffer. * See file COPYING for details */ #ifndef _ZT_PATH_ #define _ZT_PATH_ #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> # else typedef unsigned int mode_t; #endif /* HAVE_SYS_STAT_H */ #include <zt.h> BEGIN_C_DECLS typedef enum { zt_mkdir_create_parent = 1, }zt_mkdir_flags; int zt_mkdir(char * path, mode_t mode, zt_mkdir_flags flags); END_C_DECLS #endif /* _ZT_PATH_ */
Add some minor cleanups to the lease code.
#include "system.h" #include "sccs.h" #include "logging.h" extern int test_release; extern unsigned build_timet; int version_main(int ac, char **av) { char buf[100]; float exp; if (ac == 2 && streq("--help", av[1])) { system("bk help version"); return (0); } if (sccs_cd2root(0, 0) == -1) { getMsg("version", " ", 0, 0, stdout); return (0); } getMsg("version", bk_model(buf, sizeof(buf)), 0, 0, stdout); if (test_release) { exp = ((time_t)build_timet - time(0)) / (24*3600.0) + 14; if (exp > 0) { printf("Expires in: %.1f days (test release).\n", exp); } else { printf("Expired (test release).\n"); } } return (0); }
#include "system.h" #include "sccs.h" #include "logging.h" extern int test_release; extern unsigned build_timet; int version_main(int ac, char **av) { char buf[100]; float exp; if (ac == 2 && streq("--help", av[1])) { system("bk help version"); return (0); } lease_check(0); /* disable lease check */ if (sccs_cd2root(0, 0) == -1) { getMsg("version", " ", 0, 0, stdout); return (0); } getMsg("version", bk_model(buf, sizeof(buf)), 0, 0, stdout); if (test_release) { exp = ((time_t)build_timet - time(0)) / (24*3600.0) + 14; if (exp > 0) { printf("Expires in: %.1f days (test release).\n", exp); } else { printf("Expired (test release).\n"); } } return (0); }
Add `sys/types.h` include for `pid_t`.
#ifndef THEFT_CALL_INTERNAL_H #define THEFT_CALL_INTERNAL_H #include "theft_call.h" #include "theft_bloom.h" #include <assert.h> #include <unistd.h> #include <sys/wait.h> #include <poll.h> #include <signal.h> #include <errno.h> static enum theft_trial_res theft_call_inner(struct theft_run_info *run_info, void **args); static enum theft_trial_res parent_handle_child_call(struct theft_run_info *run_info, pid_t pid, int fd); #endif
#ifndef THEFT_CALL_INTERNAL_H #define THEFT_CALL_INTERNAL_H #include "theft_call.h" #include "theft_bloom.h" #include <assert.h> #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> #include <poll.h> #include <signal.h> #include <errno.h> static enum theft_trial_res theft_call_inner(struct theft_run_info *run_info, void **args); static enum theft_trial_res parent_handle_child_call(struct theft_run_info *run_info, pid_t pid, int fd); #endif
Add stub for windows file authentication implementation.
/* *The MIT License (MIT) * * Copyright (c) <2017> <Stephan Gatzka> * * 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 <stddef.h> #include "json/cJSON.h" const cJSON *credentials_ok(const char *user_name, char *passwd) { return NULL; } cJSON *change_password(const struct peer *p, const cJSON *request, const char *user_name, char *passwd) { return NULL; }
Add macro to identify apple mac os x as unix
#ifndef NWG_COMMON_SOCKET_INCLUDE_H_ #define NWG_COMMON_SOCKET_INCLUDE_H_ #ifdef __unix__ #include <netinet/in.h> #include <sys/socket.h> #endif /* __unix__ */ #ifdef _WIN32 #include <winsock2.h> #include <windows.h> typedef int socklen_t; #undef FD_SETSIZE #define FD_SETSIZE 2048 #endif /* _WIN32 */ #include <fcntl.h> #include <unistd.h> #endif /* NWG_COMMON_SOCKET_INCLUDE_H_ */
#ifndef NWG_COMMON_SOCKET_INCLUDE_H_ #define NWG_COMMON_SOCKET_INCLUDE_H_ #if !defined(__unix__) && (defined(__APPLE__) && defined(__MACH__)) #define __unix__ 1 #endif #ifdef __unix__ #include <netinet/in.h> #include <sys/socket.h> #endif /* __unix__ */ #ifdef _WIN32 #include <winsock2.h> #include <windows.h> typedef int socklen_t; #undef FD_SETSIZE #define FD_SETSIZE 2048 #endif /* _WIN32 */ #include <fcntl.h> #include <unistd.h> #endif /* NWG_COMMON_SOCKET_INCLUDE_H_ */
Change -ffp-contract=fast test to run on Aarch64
// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=powerpc-apple-darwin10 -S -o - %s | FileCheck %s // REQUIRES: powerpc-registered-target float fma_test1(float a, float b, float c) { // CHECK: fmadds float x = a * b; float y = x + c; return y; }
// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=aarch64-apple-darwin -S -o - %s | FileCheck %s // REQUIRES: aarch64-registered-target float fma_test1(float a, float b, float c) { // CHECK: fmadd float x = a * b; float y = x + c; return y; }
Fix duplicate React library import error conflict w/certain pods
// // OAuthManager.h // // Created by Ari Lerner on 5/31/16. // Copyright © 2016 Facebook. All rights reserved. // #import <Foundation/Foundation.h> #if __has_include(<React/RCTBridgeModule.h>) #import <React/RCTBridgeModule.h> #else #import "RCTBridgeModule.h" #endif #if __has_include("RCTLinkingManager.h") #import "RCTLinkingManager.h" #else #import <React/RCTLinkingManager.h> #endif @class OAuthClient; static NSString *kAuthConfig = @"OAuthManager"; @interface OAuthManager : NSObject <RCTBridgeModule, UIWebViewDelegate> + (instancetype) sharedManager; + (BOOL)setupOAuthHandler:(UIApplication *)application; + (BOOL)handleOpenUrl:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; - (BOOL) _configureProvider:(NSString *) name andConfig:(NSDictionary *) config; - (NSDictionary *) getConfigForProvider:(NSString *)name; @property (nonatomic, strong) NSDictionary *providerConfig; @property (nonatomic, strong) NSArray *callbackUrls; @end
// // OAuthManager.h // // Created by Ari Lerner on 5/31/16. // Copyright © 2016 Facebook. All rights reserved. // #import <Foundation/Foundation.h> #if __has_include(<React/RCTBridgeModule.h>) #import <React/RCTBridgeModule.h> #else #import "RCTBridgeModule.h" #endif #if __has_include(<React/RCTLinkingManager.h>) #import <React/RCTLinkingManager.h> #else #import "RCTLinkingManager.h" #endif @class OAuthClient; static NSString *kAuthConfig = @"OAuthManager"; @interface OAuthManager : NSObject <RCTBridgeModule, UIWebViewDelegate> + (instancetype) sharedManager; + (BOOL)setupOAuthHandler:(UIApplication *)application; + (BOOL)handleOpenUrl:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; - (BOOL) _configureProvider:(NSString *) name andConfig:(NSDictionary *) config; - (NSDictionary *) getConfigForProvider:(NSString *)name; @property (nonatomic, strong) NSDictionary *providerConfig; @property (nonatomic, strong) NSArray *callbackUrls; @end
Add Task 02 for Homework 02
#include <stdio.h> #include <string.h> #define MAX_LENGTH 400 char* find(char*, char); int main() { char input[MAX_LENGTH], symbol, *found; fgets(input, MAX_LENGTH + 1, stdin); scanf("%c", &symbol); found = find(input, symbol); printf("%d", (int)(found ? found - input : -1)); return 0; } char* find(char *haystack, char needle) { int length = strlen(haystack); for (int i = 0; i < length; i++) { if (haystack[i] == needle) { return &haystack[i]; } } return NULL; }
Fix circular reference but in uart_init()
#include <mikoto/char_driver.h> #include <mikoto/uart.h> static int uart_write(const char *s); static struct char_driver_operations uart_ops = { .write = uart_write, }; static struct char_driver uart_driver = { .name = "UART", }; void uart_init(void) { struct char_driver *uart = get_uart_driver_instance(); uart->ops = &uart_ops; } struct char_driver * get_uart_driver_instance(void) { if (!uart_driver.ops) uart_init(); return &uart_driver; } static int uart_write(const char *s) { while (*s) { while (*(UART0 + UARTFR) & UARTFR_TXFF) ; *UART0 = *s; s++; } return 0; }
#include <mikoto/char_driver.h> #include <mikoto/uart.h> static int uart_write(const char *s); static struct char_driver_operations uart_ops = { .write = uart_write, }; static struct char_driver uart_driver = { .name = "UART", }; static void uart_init(void) { uart_driver.ops = &uart_ops; } struct char_driver * get_uart_driver_instance(void) { if (!uart_driver.ops) uart_init(); return &uart_driver; } static int uart_write(const char *s) { while (*s) { while (*(UART0 + UARTFR) & UARTFR_TXFF) ; *UART0 = *s; s++; } return 0; }
Add default config for USB OTG HS peripheral
/* * Copyright (C) 2019 Koen Zandberg * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @ingroup boards_common_stm32 * @{ * * @file * @brief Common configuration for STM32 OTG HS peripheral with FS phy * * @author Koen Zandberg <koen@bergzand.net> */ #ifndef CFG_USB_OTG_HS_FS_H #define CFG_USB_OTG_HS_FS_H #include "periph_cpu.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Enable the full speed USB OTG peripheral */ #define STM32_USB_OTG_HS_ENABLED /** * @name common USB OTG FS configuration * @{ */ static const stm32_usb_otg_fshs_config_t stm32_usb_otg_fshs_config[] = { { .periph = (uint8_t *)USB_OTG_HS_PERIPH_BASE, .rcc_mask = RCC_AHB1ENR_OTGHSEN, .phy = STM32_USB_OTG_PHY_BUILTIN, .type = STM32_USB_OTG_HS, .irqn = OTG_HS_IRQn, .ahb = AHB1, .dm = GPIO_PIN(PORT_B, 14), .dp = GPIO_PIN(PORT_B, 15), .af = GPIO_AF12, } }; /** @} */ /** * @brief Number of available USB OTG peripherals */ #define USBDEV_NUMOF ARRAY_SIZE(stm32_usb_otg_fshs_config) #ifdef __cplusplus } #endif #endif /* CFG_USB_OTG_HS_FS_H */ /** @} */
Update to the API change of a while ago.
#ifdef NO_PORT #include "mono/interpreter/interp.h" MonoPIFunc mono_create_trampoline (MonoMethod *method) { g_error ("Unsupported arch"); return NULL; } void * mono_create_method_pointer (MonoMethod *method) { g_error ("Unsupported arch"); return NULL; } #endif
#ifdef NO_PORT #include "mono/interpreter/interp.h" MonoPIFunc mono_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor) { g_error ("Unsupported arch"); return NULL; } void * mono_create_method_pointer (MonoMethod *method) { g_error ("Unsupported arch"); return NULL; } #endif
Add a missing override from r167851. Hopefully this unbreaks the CrOS Clang build.
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_MESSAGE_CENTER_BASE_FORMAT_VIEW_H_ #define UI_MESSAGE_CENTER_BASE_FORMAT_VIEW_H_ #include "ui/message_center/message_view.h" #include "ui/message_center/notification_list.h" namespace views { class ImageView; } namespace message_center { // A comprehensive message view. class BaseFormatView : public MessageView { public: BaseFormatView(NotificationList::Delegate* list_delegate, const NotificationList::Notification& notification); virtual ~BaseFormatView(); // MessageView virtual void SetUpView() OVERRIDE; // views::ButtonListener virtual void ButtonPressed(views::Button* sender, const ui::Event& event); protected: BaseFormatView(); DISALLOW_COPY_AND_ASSIGN(BaseFormatView); }; } // namespace message_center #endif // UI_MESSAGE_CENTER_BASE_FORMAT_VIEW_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_MESSAGE_CENTER_BASE_FORMAT_VIEW_H_ #define UI_MESSAGE_CENTER_BASE_FORMAT_VIEW_H_ #include "ui/message_center/message_view.h" #include "ui/message_center/notification_list.h" namespace views { class ImageView; } namespace message_center { // A comprehensive message view. class BaseFormatView : public MessageView { public: BaseFormatView(NotificationList::Delegate* list_delegate, const NotificationList::Notification& notification); virtual ~BaseFormatView(); // MessageView virtual void SetUpView() OVERRIDE; // views::ButtonListener virtual void ButtonPressed(views::Button* sender, const ui::Event& event) OVERRIDE; protected: BaseFormatView(); DISALLOW_COPY_AND_ASSIGN(BaseFormatView); }; } // namespace message_center #endif // UI_MESSAGE_CENTER_BASE_FORMAT_VIEW_H_
Add A0 as alias to pot pin.
#include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_POTENTIOMETER), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_TOUCH), MP_ROM_PTR(&pin_PA07) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
#include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_POTENTIOMETER), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_TOUCH), MP_ROM_PTR(&pin_PA07) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Add description of the `chrono::fea` namespace
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= #ifndef CHCHRONO_H #define CHCHRONO_H // Definition of the main module and sub-modules in the main Chrono library /** @defgroup chrono Chrono::Engine @brief Core Functionality @{ @defgroup chrono_physics Physics objects @defgroup chrono_geometry Geometric objects @defgroup chrono_collision Collision objects @defgroup chrono_assets Asset objects @defgroup chrono_solver Solver @defgroup chrono_timestepper Time integrators @defgroup chrono_functions Function objects @defgroup chrono_particles Particle factory @defgroup chrono_serialization Serialization @defgroup chrono_utils Utility classes @defgroup chrono_fea Finite Element Analysis @{ @defgroup fea_nodes Nodes @defgroup fea_elements Elements @defgroup fea_constraints Constraints @defgroup fea_contact Contact @defgroup fea_math Mathematical support @defgroup fea_utils Utility classes @} @} */ /// @addtogroup chrono /// @{ /// This is the main namespace for the Chrono package. namespace chrono {} /// @} chrono #endif
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= #ifndef CHCHRONO_H #define CHCHRONO_H // Definition of the main module and sub-modules in the main Chrono library /** @defgroup chrono Chrono::Engine @brief Core Functionality @{ @defgroup chrono_physics Physics objects @defgroup chrono_geometry Geometric objects @defgroup chrono_collision Collision objects @defgroup chrono_assets Asset objects @defgroup chrono_solver Solver @defgroup chrono_timestepper Time integrators @defgroup chrono_functions Function objects @defgroup chrono_particles Particle factory @defgroup chrono_serialization Serialization @defgroup chrono_utils Utility classes @defgroup chrono_fea Finite Element Analysis @{ @defgroup fea_nodes Nodes @defgroup fea_elements Elements @defgroup fea_constraints Constraints @defgroup fea_contact Contact @defgroup fea_math Mathematical support @defgroup fea_utils Utility classes @} @} */ /// @addtogroup chrono /// @{ /// Main namespace for the Chrono package. namespace chrono { /// Namespace for FEA classes. namespace fea {} } /// @} chrono #endif
Add prototype for property set command
/* * 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 <account/paths.h> #include <game/paths.h> #include <text/paths.h> inherit LIB_VERB; void main(object actor, string args) { string *users; object user; object obj; string oname; string pname; mixed pvalue; user = query_user(); if (user->query_class() < 2) { send_out("You do not have sufficient access rights to set object properties.\n"); return; } if (sscanf(args, "%s %s %s", oname, pname, pvalue) != 3) { send_out("Usage: pset <object> <property name> <value>\n"); return; } obj = find_object(oname); if (!obj) { send_out(oname + ": No such object.\n"); return; } pvalue = PARSE_VALUE->parse(pvalue); obj->set_property(pname, pvalue); }
Add newline after printing flake
/* ***************************************************************************** * ___ _ _ _ _ * / _ \ __ _| |_| |__(_) |_ ___ * | (_) / _` | / / '_ \ | _(_-< * \___/\__,_|_\_\_.__/_|\__/__/ * Copyright (c) 2015 Romain Picard * * 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 <stdio.h> #include "sysflake.h" int main(void) { printf("%016llX", sysflake_generate()); return 0; }
/* ***************************************************************************** * ___ _ _ _ _ * / _ \ __ _| |_| |__(_) |_ ___ * | (_) / _` | / / '_ \ | _(_-< * \___/\__,_|_\_\_.__/_|\__/__/ * Copyright (c) 2015 Romain Picard * * 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 <stdio.h> #include "sysflake.h" int main(void) { printf("%016llX\n", sysflake_generate()); return 0; }
Add serialization to Node class.
#ifndef SRC_NODE_H_ #define SRC_NODE_H_ #include "./render_data.h" /** * \brief * * */ class Node { public: virtual ~Node() { } virtual void render(const RenderData &renderData) = 0; protected: Node() { } }; #endif // SRC_NODE_H_
#ifndef SRC_NODE_H_ #define SRC_NODE_H_ #include "./render_data.h" #include <boost/serialization/serialization.hpp> #include <boost/serialization/access.hpp> #include <boost/serialization/nvp.hpp> /** * \brief * * */ class Node { public: virtual ~Node() { } virtual void render(const RenderData &renderData) = 0; protected: Node() { } private: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, unsigned int version) const {}; }; #endif // SRC_NODE_H_
Add a small bit of documentation
// // HLSTextView.h // CoconutKit // // Created by Samuel Défago on 03.11.11. // Copyright (c) 2011 Hortis. All rights reserved. // // TODO: - move automatically with the keyboard // - dismiss when tapping outside @interface HLSTextView : UITextView /** * The text to be displayed when the text view is empty. Default is nil */ @property (nonatomic, retain) NSString *placeholderText; /** * The color of the placeholder text. Default is light gray */ @property (nonatomic, retain) UIColor *placeholderTextColor; @end
// // HLSTextView.h // CoconutKit // // Created by Samuel Défago on 03.11.11. // Copyright (c) 2011 Hortis. All rights reserved. // /** * Lightweight UITextView subclass providing more functionalities */ @interface HLSTextView : UITextView /** * The text to be displayed when the text view is empty. Default is nil */ @property (nonatomic, retain) NSString *placeholderText; /** * The color of the placeholder text. Default is light gray */ @property (nonatomic, retain) UIColor *placeholderTextColor; @end
Make sgi port compile again.
/* $OpenBSD: iockbcvar.h,v 1.3 2010/12/03 18:29:56 shadchin Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ int iockbc_cnattach();
/* $OpenBSD: iockbcvar.h,v 1.4 2010/12/04 11:23:43 jsing Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ int iockbc_cnattach(void);
Use keysym to keycode mapping in C
//////////////////////////////////////////////////////////////////////////////// #ifdef __linux__ #include <stdio.h> #include <X11/Xlib.h> #include <X11/Intrinsic.h> #include <X11/extensions/XTest.h> Display *fakekey_dis; void fakekey_init(void) { fakekey_dis = XOpenDisplay(NULL); } void fakekey_press(int code) { XTestFakeKeyEvent(fakekey_dis, code, True, 0); XFlush(fakekey_dis); } void fakekey_release(int code) { XTestFakeKeyEvent(fakekey_dis, code, False, 0); XFlush(fakekey_dis); } #else void fakekey_init(void) { } void fakekey_press(int code) { } void fakekey_release(int code) { } #endif
//////////////////////////////////////////////////////////////////////////////// #ifdef __linux__ #include <stdio.h> #include <X11/Xlib.h> #include <X11/Intrinsic.h> #include <X11/extensions/XTest.h> Display *fakekey_dis; void fakekey_init(void) { fakekey_dis = XOpenDisplay(NULL); } void fakekey_press(int keysym) { XTestFakeKeyEvent(fakekey_dis, XKeysymToKeycode(fakekey_dis, keysym), True, 0); XFlush(fakekey_dis); } void fakekey_release(int keysym) { XTestFakeKeyEvent(fakekey_dis, XKeysymToKeycode(fakekey_dis, keysym), False, 0); XFlush(fakekey_dis); } #else void fakekey_init(void) { } void fakekey_press(int keysym) { } void fakekey_release(int keysym) { } #endif
Fix too big timeout in long poller.
#ifndef TGBOT_TGLONGPOLL_H #define TGBOT_TGLONGPOLL_H #include "tgbot/Bot.h" #include "tgbot/Api.h" #include "tgbot/EventHandler.h" namespace TgBot { /** * @brief This class handles long polling and updates parsing. * * @ingroup net */ class TgLongPoll { public: TgLongPoll(const Api* api, const EventHandler* eventHandler, int32_t, int32_t, const std::shared_ptr<std::vector<std::string>>&); TgLongPoll(const Bot& bot, int32_t = 100, int32_t = 60, const std::shared_ptr<std::vector<std::string>>& = nullptr); /** * @brief Starts long poll. After new update will come, this method will parse it and send to EventHandler which invokes your listeners. Designed to be executed in a loop. */ void start(); private: const Api* _api; const EventHandler* _eventHandler; int32_t _lastUpdateId = 0; int32_t _limit; int32_t _timeout; std::shared_ptr<std::vector<std::string>> _allowupdates; }; } #endif //TGBOT_TGLONGPOLL_H
#ifndef TGBOT_TGLONGPOLL_H #define TGBOT_TGLONGPOLL_H #include "tgbot/Bot.h" #include "tgbot/Api.h" #include "tgbot/EventHandler.h" namespace TgBot { /** * @brief This class handles long polling and updates parsing. * * @ingroup net */ class TgLongPoll { public: TgLongPoll(const Api* api, const EventHandler* eventHandler, int32_t, int32_t, const std::shared_ptr<std::vector<std::string>>&); TgLongPoll(const Bot& bot, int32_t = 100, int32_t = 10, const std::shared_ptr<std::vector<std::string>>& = nullptr); /** * @brief Starts long poll. After new update will come, this method will parse it and send to EventHandler which invokes your listeners. Designed to be executed in a loop. */ void start(); private: const Api* _api; const EventHandler* _eventHandler; int32_t _lastUpdateId = 0; int32_t _limit; int32_t _timeout; std::shared_ptr<std::vector<std::string>> _allowupdates; }; } #endif //TGBOT_TGLONGPOLL_H
Change hook level parameter name to hookRange
// // MOAspects.h // MOAspects // // Created by Hiromi Motodera on 2015/03/15. // Copyright (c) 2015年 MOAI. All rights reserved. // #import <Foundation/Foundation.h> typedef NS_ENUM(NSInteger, MOAspectsPosition) { MOAspectsPositionBefore, MOAspectsPositionAfter }; typedef NS_ENUM(NSInteger, MOAspectsHookRange) { MOAspectsHookRangeAll = -1, MOAspectsHookRangeTargetOnly = -2 }; @interface MOAspects : NSObject + (BOOL)hookInstanceMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition usingBlock:(id)block; + (BOOL)hookInstanceMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition hookLevel:(MOAspectsHookRange)hookLevel usingBlock:(id)block; + (BOOL)hookClassMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition usingBlock:(id)block; + (BOOL)hookClassMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition hookLevel:(MOAspectsHookRange)hookLevel usingBlock:(id)block; @end
// // MOAspects.h // MOAspects // // Created by Hiromi Motodera on 2015/03/15. // Copyright (c) 2015年 MOAI. All rights reserved. // #import <Foundation/Foundation.h> typedef NS_ENUM(NSInteger, MOAspectsPosition) { MOAspectsPositionBefore, MOAspectsPositionAfter }; typedef NS_ENUM(NSInteger, MOAspectsHookRange) { MOAspectsHookRangeAll = -1, MOAspectsHookRangeTargetOnly = -2 }; @interface MOAspects : NSObject + (BOOL)hookInstanceMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition usingBlock:(id)block; + (BOOL)hookInstanceMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition hookLevel:(MOAspectsHookRange)hookRange usingBlock:(id)block; + (BOOL)hookClassMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition usingBlock:(id)block; + (BOOL)hookClassMethodForClass:(Class)clazz selector:(SEL)selector aspectsPosition:(MOAspectsPosition)aspectsPosition hookLevel:(MOAspectsHookRange)hookRange usingBlock:(id)block; @end
Reset default settings to stock kit configuration
#ifndef __SETTINGS_H_ #define __SETTINGS_H_ #include <Arduino.h> #include "Device.h" // This section is for devices and their configuration //Kit: #define HAS_STD_LIGHTS (1) #define LIGHTS_PIN 5 #define HAS_STD_CAPE (1) #define HAS_STD_2X1_THRUSTERS (1) #define HAS_STD_PILOT (1) #define HAS_STD_CAMERAMOUNT (1) #define CAMERAMOUNT_PIN 3 #define CAPE_VOLTAGE_PIN 0 #define CAPE_CURRENT_PIN 3 //After Market: #define HAS_STD_CALIBRATIONLASERS (0) #define CALIBRATIONLASERS_PIN 6 #define HAS_POLOLU_MINIMUV (1) #define HAS_MS5803_14BA (0) #define MS5803_14BA_I2C_ADDRESS 0x76 #define MIDPOINT 1500 #define LOGGING (1) class Settings : public Device { public: static int smoothingIncriment; //How aggressive the throttle changes static int deadZone_min; static int deadZone_max; static int capability_bitarray; Settings():Device(){}; void device_setup(); void device_loop(Command cmd); }; #endif
#ifndef __SETTINGS_H_ #define __SETTINGS_H_ #include <Arduino.h> #include "Device.h" // This section is for devices and their configuration //Kit: #define HAS_STD_LIGHTS (1) #define LIGHTS_PIN 5 #define HAS_STD_CAPE (1) #define HAS_STD_2X1_THRUSTERS (1) #define HAS_STD_PILOT (1) #define HAS_STD_CAMERAMOUNT (1) #define CAMERAMOUNT_PIN 3 #define CAPE_VOLTAGE_PIN 0 #define CAPE_CURRENT_PIN 3 //After Market: #define HAS_STD_CALIBRATIONLASERS (0) #define CALIBRATIONLASERS_PIN 6 #define HAS_POLOLU_MINIMUV (0) #define HAS_MS5803_14BA (0) #define MS5803_14BA_I2C_ADDRESS 0x76 #define MIDPOINT 1500 #define LOGGING (1) class Settings : public Device { public: static int smoothingIncriment; //How aggressive the throttle changes static int deadZone_min; static int deadZone_max; static int capability_bitarray; Settings():Device(){}; void device_setup(); void device_loop(Command cmd); }; #endif
Make eth header fields unsigned
struct eth_hdr { unsigned char dst_mac[6]; unsigned char src_mac[6]; short ethertype; char* payload; }; struct eth_hdr* init_eth_hdr(char* buf); void print_eth_hdr(struct eth_hdr *ehdr);
#ifndef ETHERNET_H_ #define ETHERNET_H_ #include <linux/if_ether.h> struct eth_hdr { unsigned char dst_mac[6]; unsigned char src_mac[6]; unsigned short ethertype; unsigned char* payload; }; struct eth_hdr* init_eth_hdr(char* buf); void print_eth_hdr(struct eth_hdr *ehdr); #endif
Add a newline after printing the lattice
#include "io_helpers.h" #include <stdio.h> void print_lattice(int * lattice, int rows, int columns, int with_borders) { int i, j; for (i = 0; i < rows; i++) { if (with_borders) { for (j = 0; j < columns; j++) { printf("------"); } printf("-\n"); } for (j = 0; j < columns; j++) { if (with_borders) { putchar('|'); putchar(' '); } if (lattice[i*columns + j] == 1) { printf(" x "); } else if (lattice[i*columns + j] > 1) { printf("%03d", lattice[i*columns + j]); } else { if (with_borders) { putchar(' '); putchar(' '); putchar(' '); } else { printf(" o "); } } if (with_borders) { putchar(' '); if (j == columns - 1) { putchar('|'); } } else { if (j < columns - 1) { putchar(' '); } } } putchar('\n'); } if (with_borders) { for (j = 0; j < columns; j++) { printf("------"); } printf("-\n"); } }
#include "io_helpers.h" #include <stdio.h> void print_lattice(int * lattice, int rows, int columns, int with_borders) { int i, j; for (i = 0; i < rows; i++) { if (with_borders) { for (j = 0; j < columns; j++) { printf("------"); } printf("-\n"); } for (j = 0; j < columns; j++) { if (with_borders) { putchar('|'); putchar(' '); } if (lattice[i*columns + j] == 1) { printf(" x "); } else if (lattice[i*columns + j] > 1) { printf("%03d", lattice[i*columns + j]); } else { if (with_borders) { putchar(' '); putchar(' '); putchar(' '); } else { printf(" o "); } } if (with_borders) { putchar(' '); if (j == columns - 1) { putchar('|'); } } else { if (j < columns - 1) { putchar(' '); } } } putchar('\n'); } if (with_borders) { for (j = 0; j < columns; j++) { printf("------"); } printf("-\n"); } else { putchar('\n'); } }
Add test case where array is passed to unknown function.
#include <stdlib.h> #include <stdio.h> #include <assert.h> #define LENGTH 10 typedef struct arr { int *ptrs[LENGTH]; } arr_t; // int mutate_array(arr_t a){ // int t = rand(); // for(int i=0; i<LENGTH; i++) { // *(a.ptrs[i]) = t; // } // } int main(){ arr_t a; int xs[LENGTH]; for(int i=0; i<LENGTH; i++){ xs[i] = 0; a.ptrs[i] = &xs[0]; } // When passing an arrays to an unknown function, reachable memory should be invalidated mutate_array(a); assert(xs[0] == 0); //UNKNOWN! return 0; }
Fix missing include under OSX
#ifndef SEQUENCINGRUNWIDGET_H #define SEQUENCINGRUNWIDGET_H #include <QWidget> #include "NGSD.h" namespace Ui { class SequencingRunWidget; } class SequencingRunWidget : public QWidget { Q_OBJECT public: SequencingRunWidget(QWidget* parent, QString run_id); ~SequencingRunWidget(); signals: void openProcessedSampleTab(QString ps_name); protected slots: void updateGUI(); void openSelectedSamples(); private: Ui::SequencingRunWidget* ui_; QString run_id_; NGSD db_; }; #endif // SEQUENCINGRUNWIDGET_H
#ifndef SEQUENCINGRUNWIDGET_H #define SEQUENCINGRUNWIDGET_H #include <QWidget> #include <QAction> #include "NGSD.h" namespace Ui { class SequencingRunWidget; } class SequencingRunWidget : public QWidget { Q_OBJECT public: SequencingRunWidget(QWidget* parent, QString run_id); ~SequencingRunWidget(); signals: void openProcessedSampleTab(QString ps_name); protected slots: void updateGUI(); void openSelectedSamples(); private: Ui::SequencingRunWidget* ui_; QString run_id_; NGSD db_; }; #endif // SEQUENCINGRUNWIDGET_H
Update utility functions to work with pyp-topics.
#ifndef DICT_H_ #define DICT_H_ #include <cassert> #include <cstring> #include <tr1/unordered_map> #include <string> #include <vector> #include <boost/functional/hash.hpp> #include "wordid.h" class Dict { typedef std::tr1::unordered_map<std::string, WordID, boost::hash<std::string> > Map; public: Dict() : b0_("<bad0>") { words_.reserve(1000); } inline int max() const { return words_.size(); } inline WordID Convert(const std::string& word, bool frozen = false) { Map::iterator i = d_.find(word); if (i == d_.end()) { if (frozen) return 0; words_.push_back(word); d_[word] = words_.size(); return words_.size(); } else { return i->second; } } inline const std::string& Convert(const WordID& id) const { if (id == 0) return b0_; assert(id <= words_.size()); return words_[id-1]; } void clear() { words_.clear(); d_.clear(); } private: const std::string b0_; std::vector<std::string> words_; Map d_; }; #endif
#ifndef DICT_H_ #define DICT_H_ #include <cassert> #include <cstring> #include <tr1/unordered_map> #include <string> #include <vector> #include <boost/functional/hash.hpp> #include "wordid.h" class Dict { typedef std::tr1::unordered_map<std::string, WordID, boost::hash<std::string> > Map; public: Dict() : b0_("<bad0>") { words_.reserve(1000); } inline int max() const { return words_.size(); } inline WordID Convert(const std::string& word, bool frozen = false) { Map::iterator i = d_.find(word); if (i == d_.end()) { if (frozen) return 0; words_.push_back(word); d_[word] = words_.size(); return words_.size(); } else { return i->second; } } inline WordID Convert(const std::vector<std::string>& words, bool frozen = false) { std::string word= ""; for (std::vector<std::string>::const_iterator it=words.begin(); it != words.end(); ++it) { if (it != words.begin()) word += "__"; word += *it; } return Convert(word, frozen); } inline const std::string& Convert(const WordID& id) const { if (id == 0) return b0_; assert(id <= words_.size()); return words_[id-1]; } void clear() { words_.clear(); d_.clear(); } private: const std::string b0_; std::vector<std::string> words_; Map d_; }; #endif
Include stdlib for free and realloc
#ifndef ABUF_H #define ABUF_H #include <string.h> #define ABUF_INIT { NULL, 0} struct abuf{ char *b; int len; }; void abAppend(struct abuf*, const char*, int); void abFree(struct abuf*); #endif
#ifndef ABUF_H #define ABUF_H #include <stdlib.h> #include <string.h> #define ABUF_INIT { NULL, 0} struct abuf{ char *b; int len; }; void abAppend(struct abuf*, const char*, int); void abFree(struct abuf*); #endif
Add a note about error checking, fix description and include stdio.h .
/* scan: Esitmate length of a mpeg file and compare to length from exact scan. copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis */ #include "mpg123.h" int main(int argc, char **argv) { mpg123_handle *m; int i; mpg123_init(); m = mpg123_new(NULL, NULL); for(i = 1; i < argc; ++i) { off_t a, b; mpg123_open(m, argv[i]); a = mpg123_length(m); mpg123_scan(m); b = mpg123_length(m); printf("File %i: estimated %li vs. scanned %li\n", i, (long)a, (long)b); } mpg123_delete(m); mpg123_exit(); return 0; }
/* scan: Estimate length (sample count) of a mpeg file and compare to length from exact scan. copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis */ /* Note the lack of error checking here. While it would be nicer to inform the user about troubles, libmpg123 is designed _not_ to bite you on operations with invalid handles , etc. You just jet invalid results on invalid operations... */ #include <stdio.h> #include "mpg123.h" int main(int argc, char **argv) { mpg123_handle *m; int i; mpg123_init(); m = mpg123_new(NULL, NULL); for(i = 1; i < argc; ++i) { off_t a, b; mpg123_open(m, argv[i]); a = mpg123_length(m); mpg123_scan(m); b = mpg123_length(m); printf("File %i: estimated %li vs. scanned %li\n", i, (long)a, (long)b); } mpg123_delete(m); mpg123_exit(); return 0; }
Use the new throw function
#pragma once #include <string> // std::string #include <sqlite3.h> #include <system_error> // std::error_code, std::system_error #include "error_code.h" namespace sqlite_orm { namespace internal { inline sqlite3 *open_db(std::string const&filename) { sqlite3 *result {nullptr}; if(sqlite3_open(filename.c_str(), &result) != SQLITE_OK){ throw std::system_error(std::error_code(sqlite3_errcode(result), get_sqlite_error_category()), get_error_message(result, "opening '", filename, "'. ")); } return result; } struct database_connection { explicit database_connection(const std::string &filename): db {open_db(filename) } { } ~database_connection() { sqlite3_close(this->db); } sqlite3* get_db() { return this->db; } protected: sqlite3 *db; }; } }
#pragma once #include <string> // std::string #include <sqlite3.h> #include <system_error> // std::error_code, std::system_error #include "error_code.h" namespace sqlite_orm { namespace internal { inline sqlite3 *open_db(std::string const&filename) { sqlite3 *result {nullptr}; if(sqlite3_open(filename.c_str(), &result) != SQLITE_OK){ throw_error(result, "opening '", filename, "'. "); } return result; } struct database_connection { explicit database_connection(const std::string &filename): db {open_db(filename) } {} ~database_connection() { sqlite3_close(this->db); } sqlite3* get_db() { return this->db; } protected: sqlite3 *db; }; } }
Define new number for new exposure rate calc
/* $Id: Output_def.h,v 1.16 2007-10-18 20:30:58 phruksar Exp $ */ #ifndef _OUTPUT_DEF_H #define _OUTPUT_DEF_H #define OUTFMT_HEAD 0 #define OUTFMT_UNITS 1 #define OUTFMT_COMP 2 #define OUTFMT_NUM 4 #define OUTFMT_ACT 8 #define OUTFMT_HEAT 16 #define OUTFMT_ALPHA 32 #define OUTFMT_BETA 64 #define OUTFMT_GAMMA 128 #define OUTFMT_SRC 256 #define OUTFMT_CDOSE 512 #define OUTFMT_ADJ 1024 #define OUTFMT_EXP 2048 #define OUTFMT_WDR 4096 #define OUTNORM_KG -2 #define OUTNORM_G -1 #define OUTNORM_NULL 0 #define OUTNORM_CM3 1 #define OUTNORM_M3 2 #define OUTNORM_VOL_INT 100 #define BQ_CI 2.7027e-11 #define CM3_M3 1e-6 #define G_KG 1e-3 #endif
/* $Id: Output_def.h,v 1.17 2008-07-31 18:08:50 phruksar Exp $ */ #ifndef _OUTPUT_DEF_H #define _OUTPUT_DEF_H #define OUTFMT_HEAD 0 #define OUTFMT_UNITS 1 #define OUTFMT_COMP 2 #define OUTFMT_NUM 4 #define OUTFMT_ACT 8 #define OUTFMT_HEAT 16 #define OUTFMT_ALPHA 32 #define OUTFMT_BETA 64 #define OUTFMT_GAMMA 128 #define OUTFMT_SRC 256 #define OUTFMT_CDOSE 512 #define OUTFMT_ADJ 1024 #define OUTFMT_EXP 2048 #define OUTFMT_EXP_CYL_VOL 4096 #define OUTFMT_WDR 8192 #define OUTNORM_KG -2 #define OUTNORM_G -1 #define OUTNORM_NULL 0 #define OUTNORM_CM3 1 #define OUTNORM_M3 2 #define OUTNORM_VOL_INT 100 #define BQ_CI 2.7027e-11 #define CM3_M3 1e-6 #define G_KG 1e-3 #endif
Add stdlib.h to header. Needed for size_t
/** * Copyright (c) 2013-2014 Tomas Dzetkulic * Copyright (c) 2013-2014 Pavol Rusnak * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __RAND_H__ #define __RAND_H__ #include <stdint.h> void init_rand(void); int finalize_rand(void); uint32_t random32(void); void random_buffer(uint8_t *buf, size_t len); #endif
/** * Copyright (c) 2013-2014 Tomas Dzetkulic * Copyright (c) 2013-2014 Pavol Rusnak * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __RAND_H__ #define __RAND_H__ #include <stdlib.h> #include <stdint.h> void init_rand(void); int finalize_rand(void); uint32_t random32(void); void random_buffer(uint8_t *buf, size_t len); #endif
Set copy/move constructors to deleted
#ifndef SCANNER_H #define SCANNER_H #include <QString> #include <QChar> #include <QVector> #include "token.h" /** * @class Scanner * @brief Class representing a scanner (lexical analyzer). It takes a file path as input and generates tokens, either lazily or as a QVector. */ class Scanner { public: Scanner(const QString& sourcePath); /** * @brief Accessor to the vecotr of tokens parsed at construction time. * @return const reference to the vector of tokens. */ const QVector<Token>& tokens() const {return _tokens;} private: QChar peek() const; //Current character QChar next() const; //Read next character void advance(); Token nextToken(); //Utility functions for nextToken(). Token parseAlphaNum(); //Parse an expression that starts with a letter : identifiers, reserved words, bool literals Token parseStringLiteral(); Token parseCharLiteral(); Token parseNumberLiteral(); void skipComment(); QString fileContent; QVector<Token> _tokens; int currentChar = 0; int currentLine = 1; int currentRow = 1; }; #endif // SCANNER_H
#ifndef SCANNER_H #define SCANNER_H #include <QString> #include <QChar> #include <QVector> #include "token.h" /** * @class Scanner * @brief Class representing a scanner (lexical analyzer). It takes a file path as input and generates tokens, either lazily or as a QVector. */ class Scanner { public: Scanner(const QString& sourcePath); Scanner() = delete; Scanner(const Scanner& src) = delete; Scanner(Scanner &&src) = delete; Scanner& operator= (const Scanner& src) = delete; Scanner& operator= (Scanner&& src) = delete; /** * @brief Accessor to the vecotr of tokens parsed at construction time. * @return const reference to the vector of tokens. */ const QVector<Token>& tokens() const {return _tokens;} private: QChar peek() const; //Current character QChar next() const; //Read next character void advance(); Token nextToken(); //Utility functions for nextToken(). Token parseAlphaNum(); //Parse an expression that starts with a letter : identifiers, reserved words, bool literals Token parseStringLiteral(); Token parseCharLiteral(); Token parseNumberLiteral(); void skipComment(); QString fileContent; QVector<Token> _tokens; int currentChar = 0; int currentLine = 1; int currentRow = 1; }; #endif // SCANNER_H
Add documentation for new stp_theme property
// // UINavigationBar+Stripe_Theme.h // Stripe // // Created by Jack Flintermann on 5/17/16. // Copyright © 2016 Stripe, Inc. All rights reserved. // #import <UIKit/UIKit.h> #import "STPTheme.h" NS_ASSUME_NONNULL_BEGIN /** * This allows quickly setting the appearance of a `UINavigationBar` to match your application. This is useful if you're presenting an `STPAddCardViewController` or `STPPaymentMethodsViewController` inside a `UINavigationController`. */ @interface UINavigationBar (Stripe_Theme) /** * Sets the navigation bar's appearance to the desired theme. This will affect the bar's `tintColor` and `barTintColor` properties, as well as the color of the single-pixel line at the bottom of the navbar. * * @param theme the theme to use to style the navigation bar. @see STPTheme.h */ - (void)stp_setTheme:(STPTheme *)theme __attribute__((deprecated)); @property (nonatomic, nullable, retain) STPTheme *stp_theme; @end NS_ASSUME_NONNULL_END void linkUINavigationBarThemeCategory(void);
// // UINavigationBar+Stripe_Theme.h // Stripe // // Created by Jack Flintermann on 5/17/16. // Copyright © 2016 Stripe, Inc. All rights reserved. // #import <UIKit/UIKit.h> #import "STPTheme.h" NS_ASSUME_NONNULL_BEGIN /** * This allows quickly setting the appearance of a `UINavigationBar` to match your application. This is useful if you're presenting an `STPAddCardViewController` or `STPPaymentMethodsViewController` inside a `UINavigationController`. */ @interface UINavigationBar (Stripe_Theme) /** * Sets the navigation bar's appearance to the desired theme. This will affect the bar's `tintColor` and `barTintColor` properties, as well as the color of the single-pixel line at the bottom of the navbar. * * @param theme the theme to use to style the navigation bar. @see STPTheme.h * @deprecated Use the `stp_theme` property instead */ - (void)stp_setTheme:(STPTheme *)theme __attribute__((deprecated)); /** * Sets the navigation bar's appearance to the desired theme. This will affect the bar's `tintColor` and `barTintColor` properties, as well as the color of the single-pixel line at the bottom of the navbar. * Stripe view controllers will use their navigation bar's theme for their UIBarButtonItems instead of their own theme if it is not nil. * * @see STPTheme.h */ @property (nonatomic, nullable, retain) STPTheme *stp_theme; @end NS_ASSUME_NONNULL_END void linkUINavigationBarThemeCategory(void);
Make the modulus visible in Modular_Reducer
/* * Modular Reducer * (C) 1999-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ #ifndef BOTAN_MODULAR_REDUCER_H__ #define BOTAN_MODULAR_REDUCER_H__ #include <botan/numthry.h> namespace Botan { /* * Modular Reducer */ class BOTAN_DLL Modular_Reducer { public: BigInt reduce(const BigInt& x) const; /** * Multiply mod p */ BigInt multiply(const BigInt& x, const BigInt& y) const { return reduce(x * y); } /** * Square mod p */ BigInt square(const BigInt& x) const { return reduce(Botan::square(x)); } /** * Cube mod p */ BigInt cube(const BigInt& x) const { return multiply(x, this->square(x)); } bool initialized() const { return (mod_words != 0); } Modular_Reducer() { mod_words = 0; } Modular_Reducer(const BigInt& mod); private: BigInt modulus, modulus_2, mu; u32bit mod_words, mod2_words, mu_words; }; } #endif
/* * Modular Reducer * (C) 1999-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ #ifndef BOTAN_MODULAR_REDUCER_H__ #define BOTAN_MODULAR_REDUCER_H__ #include <botan/numthry.h> namespace Botan { /* * Modular Reducer */ class BOTAN_DLL Modular_Reducer { public: const BigInt& get_modulus() const { return modulus; } BigInt reduce(const BigInt& x) const; /** * Multiply mod p */ BigInt multiply(const BigInt& x, const BigInt& y) const { return reduce(x * y); } /** * Square mod p */ BigInt square(const BigInt& x) const { return reduce(Botan::square(x)); } /** * Cube mod p */ BigInt cube(const BigInt& x) const { return multiply(x, this->square(x)); } bool initialized() const { return (mod_words != 0); } Modular_Reducer() { mod_words = 0; } Modular_Reducer(const BigInt& mod); private: BigInt modulus, modulus_2, mu; u32bit mod_words, mod2_words, mu_words; }; } #endif
Test case for some AVX builtins. Patch by Syoyo Fujita!
// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s // Don't include mm_malloc.h, it's system specific. #define __MM_MALLOC_H #include <immintrin.h> // // Test LLVM IR codegen of cmpXY instructions // __m128d test_cmp_pd(__m128d a, __m128d b) { // Expects that the third argument in LLVM IR is immediate expression // CHECK: @llvm.x86.sse2.cmp.pd({{.*}}, i8 13) return _mm_cmp_pd(a, b, _CMP_GE_OS); } __m128d test_cmp_ps(__m128 a, __m128 b) { // Expects that the third argument in LLVM IR is immediate expression // CHECK: @llvm.x86.sse.cmp.ps({{.*}}, i8 13) return _mm_cmp_ps(a, b, _CMP_GE_OS); } __m256d test_cmp_pd256(__m256d a, __m256d b) { // Expects that the third argument in LLVM IR is immediate expression // CHECK: @llvm.x86.avx.cmp.pd.256({{.*}}, i8 13) return _mm256_cmp_pd(a, b, _CMP_GE_OS); } __m256d test_cmp_ps256(__m256 a, __m256 b) { // Expects that the third argument in LLVM IR is immediate expression // CHECK: @llvm.x86.avx.cmp.ps.256({{.*}}, i8 13) return _mm256_cmp_ps(a, b, _CMP_GE_OS); } __m128d test_cmp_sd(__m128d a, __m128d b) { // Expects that the third argument in LLVM IR is immediate expression // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 13) return _mm_cmp_sd(a, b, _CMP_GE_OS); } __m128d test_cmp_ss(__m128 a, __m128 b) { // Expects that the third argument in LLVM IR is immediate expression // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 13) return _mm_cmp_ss(a, b, _CMP_GE_OS); }
Add in path field in board_t
#ifndef DASHBOARD_H #define DASHBOARD_H #include <sys/types.h> #include "src/process/process.h" typedef struct { char *fieldbar; int max_x; int max_y; int prev_x; int prev_y; proc_t *process_list; } board_t; void print_usage(void); char set_sort_option(char *opt); void dashboard_mainloop(char attr_sort); void get_process_stats(proc_t *process_list, uid_t euid, long memtotal); #endif
#ifndef DASHBOARD_H #define DASHBOARD_H #include <sys/types.h> #include "src/process/process.h" #define STAT_PATHMAX 32 typedef struct { uid_t euid; int max_x; int max_y; int prev_x; int prev_y; char path[STAT_PATHMAX]; char *fieldbar; long memtotal; proc_t *process_list; } board_t; void print_usage(void); char set_sort_option(char *opt); void dashboard_mainloop(char attr_sort); void get_process_stats(board_t *dashboard); #endif
Add 'DiscreteImput' Modbus data type
#define _MASTERTYPES #include <inttypes.h> //Declarations for master types typedef enum { Register = 0, Coil = 1 } MODBUSDataType; //MODBUS data types enum (coil, register, input, etc.) typedef struct { uint8_t Address; //Device address uint8_t Function; //Function called, in which exception occured uint8_t Code; //Exception code } MODBUSException; //Parsed exception data typedef struct { uint8_t Address; //Device address MODBUSDataType DataType; //Data type uint16_t Register; //Register, coil, input ID uint16_t Value; //Value of data } MODBUSData; typedef struct { uint8_t Length; //Length of frame, if it's equal to 0, frame is not ready uint8_t *Frame; //Request frame content } MODBUSRequestStatus; //Type containing information about frame that is set up at master side typedef struct { MODBUSData *Data; //Data read from slave MODBUSException Exception; //Optional exception read MODBUSRequestStatus Request; //Formatted request for slave uint8_t DataLength; //Count of data type instances read from slave uint8_t Error; //Have any error occured? uint8_t Finished; //Is parsing finished? } MODBUSMasterStatus; //Type containing master device configuration data
#define _MASTERTYPES #include <inttypes.h> //Declarations for master types typedef enum { Register = 0, Coil = 1, DiscreteInput = 2 } MODBUSDataType; //MODBUS data types enum (coil, register, input, etc.) typedef struct { uint8_t Address; //Device address uint8_t Function; //Function called, in which exception occured uint8_t Code; //Exception code } MODBUSException; //Parsed exception data typedef struct { uint8_t Address; //Device address MODBUSDataType DataType; //Data type uint16_t Register; //Register, coil, input ID uint16_t Value; //Value of data } MODBUSData; typedef struct { uint8_t Length; //Length of frame, if it's equal to 0, frame is not ready uint8_t *Frame; //Request frame content } MODBUSRequestStatus; //Type containing information about frame that is set up at master side typedef struct { MODBUSData *Data; //Data read from slave MODBUSException Exception; //Optional exception read MODBUSRequestStatus Request; //Formatted request for slave uint8_t DataLength; //Count of data type instances read from slave uint8_t Error; //Have any error occured? uint8_t Finished; //Is parsing finished? } MODBUSMasterStatus; //Type containing master device configuration data
Remove dependency to node_events.h. Because it removed from Node since v0.5.2
#ifndef __TAGGER_H__ #define __TAGGER_H__ #include <v8.h> #include <node.h> #include <node_events.h> #include <mecab.h> #include <stdio.h> using namespace v8; namespace MeCabBinding { class Tagger : node::ObjectWrap { public: static void Initialize(const Handle<Object> target); bool initialized(); const char* Parse(const char* input); const mecab_node_t* ParseToNode(const char* input); Tagger(const char* arg); ~Tagger(); protected: static Handle<Value> New(const Arguments& args); static Handle<Value> Parse(const Arguments& args); static Handle<Value> ParseToNode(const Arguments& args); static Handle<Value> Version(const Arguments& args); private: mecab_t* mecab; mecab_node_t* mecabNode; }; } // namespace MeCabBinding #endif // __TAGGER_H__
#ifndef __TAGGER_H__ #define __TAGGER_H__ #include <v8.h> #include <node.h> #include <mecab.h> #include <stdio.h> using namespace v8; namespace MeCabBinding { class Tagger : node::ObjectWrap { public: static void Initialize(const Handle<Object> target); bool initialized(); const char* Parse(const char* input); const mecab_node_t* ParseToNode(const char* input); Tagger(const char* arg); ~Tagger(); protected: static Handle<Value> New(const Arguments& args); static Handle<Value> Parse(const Arguments& args); static Handle<Value> ParseToNode(const Arguments& args); static Handle<Value> Version(const Arguments& args); private: mecab_t* mecab; mecab_node_t* mecabNode; }; } // namespace MeCabBinding #endif // __TAGGER_H__
Remove strong declaration from primitive type
// // RNSoundPlayer // // Created by Johnson Su on 2018-07-10. // #import <React/RCTBridgeModule.h> #import <AVFoundation/AVFoundation.h> #import <React/RCTEventEmitter.h> @interface RNSoundPlayer : RCTEventEmitter <RCTBridgeModule, AVAudioPlayerDelegate> @property (nonatomic, strong) AVAudioPlayer *player; @property (nonatomic, strong) AVPlayer *avPlayer; @property (nonatomic, strong) int loopCount; @end
// // RNSoundPlayer // // Created by Johnson Su on 2018-07-10. // #import <React/RCTBridgeModule.h> #import <AVFoundation/AVFoundation.h> #import <React/RCTEventEmitter.h> @interface RNSoundPlayer : RCTEventEmitter <RCTBridgeModule, AVAudioPlayerDelegate> @property (nonatomic, strong) AVAudioPlayer *player; @property (nonatomic, strong) AVPlayer *avPlayer; @property (nonatomic) int loopCount; @end
Add comment to public QUID functions
#ifndef QUID_H_INCLUDED #define QUID_H_INCLUDED #define UIDS_PER_TICK 1024 /* Generate identifiers per tick interval */ #define EPOCH_DIFF 11644473600LL /* Conversion needed for EPOCH to UTC */ #define RND_SEED_CYCLE 4096 /* Generate new random seed after interval */ /* * Identifier structure */ struct quid { unsigned long time_low; /* Time lover half */ unsigned short time_mid; /* Time middle half */ unsigned short time_hi_and_version; /* Time upper half and structure version */ unsigned char clock_seq_hi_and_reserved; /* Clock sequence */ unsigned char clock_seq_low; /* Clock sequence lower half */ unsigned char node[6]; /* Node allocation, filled with random memory data */ } __attribute__((packed)); typedef unsigned long long int cuuid_time_t; /* * Create new QUID */ void quid_create(struct quid *); int quidcmp(const struct quid *a, const struct quid *b); void quidtostr(char *s, struct quid *u); #endif // QUID_H_INCLUDED
#ifndef QUID_H_INCLUDED #define QUID_H_INCLUDED #define UIDS_PER_TICK 1024 /* Generate identifiers per tick interval */ #define EPOCH_DIFF 11644473600LL /* Conversion needed for EPOCH to UTC */ #define RND_SEED_CYCLE 4096 /* Generate new random seed after interval */ /* * Identifier structure */ struct quid { unsigned long time_low; /* Time lover half */ unsigned short time_mid; /* Time middle half */ unsigned short time_hi_and_version; /* Time upper half and structure version */ unsigned char clock_seq_hi_and_reserved; /* Clock sequence */ unsigned char clock_seq_low; /* Clock sequence lower half */ unsigned char node[6]; /* Node allocation, filled with random memory data */ } __attribute__((packed)); typedef unsigned long long int cuuid_time_t; /* * Create new QUID */ void quid_create(struct quid *); /* * Compare to QUID keys */ int quidcmp(const struct quid *a, const struct quid *b); /* * Convert QUID key to string */ void quidtostr(char *s, struct quid *u); #endif // QUID_H_INCLUDED
Make offset a protected var.
#include "Allocator.h" #ifndef LINEARALLOCATOR_H #define LINEARALLOCATOR_H class LinearAllocator : public Allocator { private: /* Offset from the start of the memory block */ long m_offset; public: /* Allocation of real memory */ LinearAllocator(const long totalSize); /* Frees all memory */ virtual ~LinearAllocator(); /* Allocate virtual memory */ virtual void* Allocate(const std::size_t size, const std::size_t alignment) override; /* Frees virtual memory */ virtual void Free(void* ptr) override; /* Frees all virtual memory */ virtual void Reset() override; }; #endif /* LINEARALLOCATOR_H */
#include "Allocator.h" #ifndef LINEARALLOCATOR_H #define LINEARALLOCATOR_H class LinearAllocator : public Allocator { protected: /* Offset from the start of the memory block */ long m_offset; public: /* Allocation of real memory */ LinearAllocator(const long totalSize); /* Frees all memory */ virtual ~LinearAllocator(); /* Allocate virtual memory */ virtual void* Allocate(const std::size_t size, const std::size_t alignment) override; /* Frees virtual memory */ virtual void Free(void* ptr) override; /* Frees all virtual memory */ virtual void Reset() override; }; #endif /* LINEARALLOCATOR_H */
Update year in a copyright notice
/************************************************************************* * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * Author: Danilo Piparo - CERN * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifdef __CLING__ #pragma link C++ namespace ROOT::VecOps; #pragma link C++ class ROOT::VecOps::RVec<bool>-; #pragma link C++ class ROOT::VecOps::RVec<float>-; #pragma link C++ class ROOT::VecOps::RVec<double>-; #pragma link C++ class ROOT::VecOps::RVec<char>-; #pragma link C++ class ROOT::VecOps::RVec<short>-; #pragma link C++ class ROOT::VecOps::RVec<int>-; #pragma link C++ class ROOT::VecOps::RVec<long>-; #pragma link C++ class ROOT::VecOps::RVec<long long>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned char>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned short>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned int>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned long>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned long long>-; #endif
/************************************************************************* * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * Author: Danilo Piparo - CERN * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifdef __CLING__ #pragma link C++ namespace ROOT::VecOps; #pragma link C++ class ROOT::VecOps::RVec<bool>-; #pragma link C++ class ROOT::VecOps::RVec<float>-; #pragma link C++ class ROOT::VecOps::RVec<double>-; #pragma link C++ class ROOT::VecOps::RVec<char>-; #pragma link C++ class ROOT::VecOps::RVec<short>-; #pragma link C++ class ROOT::VecOps::RVec<int>-; #pragma link C++ class ROOT::VecOps::RVec<long>-; #pragma link C++ class ROOT::VecOps::RVec<long long>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned char>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned short>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned int>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned long>-; #pragma link C++ class ROOT::VecOps::RVec<unsigned long long>-; #endif
Fix the value of MCOUNT_INSN_OFFSET
#ifndef __ASM_SH_FTRACE_H #define __ASM_SH_FTRACE_H #ifdef CONFIG_FUNCTION_TRACER #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ #ifndef __ASSEMBLY__ extern void mcount(void); #define MCOUNT_ADDR ((long)(mcount)) #ifdef CONFIG_DYNAMIC_FTRACE #define CALLER_ADDR ((long)(ftrace_caller)) #define STUB_ADDR ((long)(ftrace_stub)) #define MCOUNT_INSN_OFFSET ((STUB_ADDR - CALLER_ADDR) >> 1) struct dyn_arch_ftrace { /* No extra data needed on sh */ }; #endif /* CONFIG_DYNAMIC_FTRACE */ static inline unsigned long ftrace_call_adjust(unsigned long addr) { /* 'addr' is the memory table address. */ return addr; } #endif /* __ASSEMBLY__ */ #endif /* CONFIG_FUNCTION_TRACER */ #endif /* __ASM_SH_FTRACE_H */
#ifndef __ASM_SH_FTRACE_H #define __ASM_SH_FTRACE_H #ifdef CONFIG_FUNCTION_TRACER #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ #ifndef __ASSEMBLY__ extern void mcount(void); #define MCOUNT_ADDR ((long)(mcount)) #ifdef CONFIG_DYNAMIC_FTRACE #define CALL_ADDR ((long)(ftrace_call)) #define STUB_ADDR ((long)(ftrace_stub)) #define MCOUNT_INSN_OFFSET ((STUB_ADDR - CALL_ADDR) - 4) struct dyn_arch_ftrace { /* No extra data needed on sh */ }; #endif /* CONFIG_DYNAMIC_FTRACE */ static inline unsigned long ftrace_call_adjust(unsigned long addr) { /* 'addr' is the memory table address. */ return addr; } #endif /* __ASSEMBLY__ */ #endif /* CONFIG_FUNCTION_TRACER */ #endif /* __ASM_SH_FTRACE_H */
Change noreturn attribute tests into static asserts
// RUN: %ocheck 0 %s _Noreturn void exit(int); void g(int i) { } int f(int p) { (p == 5 ? exit : g)(2); // this shouldn't be thought of as unreachable return 7; } main() { f(4); return 0; }
// RUN: %ucc -fsyntax-only %s _Noreturn void exit(int); __attribute((noreturn)) void exit2(int); void g(int i); _Static_assert( !__builtin_has_attribute(g, noreturn), ""); _Static_assert( __builtin_has_attribute(exit, noreturn), ""); _Static_assert( __builtin_has_attribute(exit2, noreturn), ""); _Static_assert( !__builtin_has_attribute( (1 ? exit : g), noreturn), ""); _Static_assert( !__builtin_has_attribute( (1 ? exit2 : g), noreturn), "");
Include board_arm_def.h through the platform's header
/* * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <arch_helpers.h> #include <board_arm_def.h> #include <console.h> #include <debug.h> #include <errno.h> #include <norflash.h> #include <platform.h> #include <stdint.h> /* * ARM common implementation for error handler */ void plat_error_handler(int err) { int ret; switch (err) { case -ENOENT: case -EAUTH: /* Image load or authentication error. Erase the ToC */ INFO("Erasing FIP ToC from flash...\n"); nor_unlock(PLAT_ARM_FIP_BASE); ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); if (ret != 0) { ERROR("Cannot erase ToC\n"); } else { INFO("Done\n"); } break; default: /* Unexpected error */ break; } (void)console_flush(); /* Loop until the watchdog resets the system */ for (;;) wfi(); }
/* * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <arch_helpers.h> #include <console.h> #include <debug.h> #include <errno.h> #include <norflash.h> #include <platform.h> #include <platform_def.h> #include <stdint.h> /* * ARM common implementation for error handler */ void plat_error_handler(int err) { int ret; switch (err) { case -ENOENT: case -EAUTH: /* Image load or authentication error. Erase the ToC */ INFO("Erasing FIP ToC from flash...\n"); nor_unlock(PLAT_ARM_FIP_BASE); ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); if (ret != 0) { ERROR("Cannot erase ToC\n"); } else { INFO("Done\n"); } break; default: /* Unexpected error */ break; } (void)console_flush(); /* Loop until the watchdog resets the system */ for (;;) wfi(); }
Add protocol for view to return readable properties dictionary (CLURecordableProperties) for View Structure recordable module
// // CLUViewRecordableProperties.h // Clue // // Created by Ahmed Sulaiman on 5/27/16. // Copyright © 2016 Ahmed Sulaiman. All rights reserved. // #import <Foundation/Foundation.h> @protocol CLUViewRecordableProperties <NSObject> @required - (NSMutableDictionary *)clue_viewPropertiesDictionary; @end
Revert "Remove const from ThreadChecker in NullAudioPoller."
/* * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef AUDIO_NULL_AUDIO_POLLER_H_ #define AUDIO_NULL_AUDIO_POLLER_H_ #include "modules/audio_device/include/audio_device_defines.h" #include "rtc_base/messagehandler.h" #include "rtc_base/thread_checker.h" namespace webrtc { namespace internal { class NullAudioPoller final : public rtc::MessageHandler { public: explicit NullAudioPoller(AudioTransport* audio_transport); ~NullAudioPoller(); protected: void OnMessage(rtc::Message* msg) override; private: rtc::ThreadChecker thread_checker_; AudioTransport* const audio_transport_; int64_t reschedule_at_; }; } // namespace internal } // namespace webrtc #endif // AUDIO_NULL_AUDIO_POLLER_H_
/* * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef AUDIO_NULL_AUDIO_POLLER_H_ #define AUDIO_NULL_AUDIO_POLLER_H_ #include "modules/audio_device/include/audio_device_defines.h" #include "rtc_base/messagehandler.h" #include "rtc_base/thread_checker.h" namespace webrtc { namespace internal { class NullAudioPoller final : public rtc::MessageHandler { public: explicit NullAudioPoller(AudioTransport* audio_transport); ~NullAudioPoller(); protected: void OnMessage(rtc::Message* msg) override; private: const rtc::ThreadChecker thread_checker_; AudioTransport* const audio_transport_; int64_t reschedule_at_; }; } // namespace internal } // namespace webrtc #endif // AUDIO_NULL_AUDIO_POLLER_H_
Return type of tellg() is implementation defined
#include <string> #include <fstream> #ifndef LOADER #define LOADER namespace lyrics { using std::string; using std::istream; class Loader { public: bool Load( const string name, char *&data, unsigned int &size ) { using std::ifstream; using std::ios; using std::ios_base; ifstream input( name, ios::in | ios::binary ); if ( !input ) { // TODO: return false; } if ( !IStreamSize( input, size ) ) { // TODO: return false; } data = new char [size]; if ( data == nullptr ) { // TODO: return false; } input.read( data , size ); input.close(); return true; } private: bool IStreamSize( istream &input, unsigned int &size ) { using std::ios_base; using std::streamoff; streamoff off; input.seekg( 0, ios_base::end ); off = input.tellg(); input.seekg( 0, ios_base::beg ); if ( off == -1 ) { return false; } size = off; return true; } }; } #endif
#include <string> #include <fstream> #ifndef LOADER #define LOADER namespace lyrics { using std::string; using std::istream; class Loader { public: bool Load( const string name, char *&data, unsigned int &size ) { using std::ifstream; using std::ios; using std::ios_base; ifstream input( name, ios::in | ios::binary ); if ( !input ) { // TODO: return false; } if ( !IStreamSize( input, size ) ) { // TODO: return false; } data = new char [size]; if ( data == nullptr ) { // TODO: return false; } input.read( data , size ); input.close(); return true; } private: bool IStreamSize( istream &input, unsigned int &size ) { using std::ios_base; input.seekg( 0, ios_base::end ); auto off = input.tellg(); input.seekg( 0, ios_base::beg ); if ( off == decltype( off )( -1 ) ) { return false; } size = off; return true; } }; } #endif
Fix default LUT size and precision for expander
/** * \file GainExpanderFilter.h */ #ifndef ATK_DYNAMIC_GAINEXPANDERFILTER_H #define ATK_DYNAMIC_GAINEXPANDERFILTER_H #include <vector> #include <ATK/Dynamic/GainFilter.h> #include "config.h" namespace ATK { /** * Gain "expander". Computes a new amplitude/volume gain based on threshold, slope and the power of the input signal */ template<typename DataType_> class ATK_DYNAMIC_EXPORT GainExpanderFilter : public GainFilter<DataType_> { protected: typedef GainFilter<DataType_> Parent; using typename Parent::DataType; using Parent::ratio; using Parent::softness; using Parent::recomputeFuture; using Parent::recomputeLUT; public: GainExpanderFilter(int nb_channels = 1, size_t LUTsize = 128*1024, size_t LUTprecision = 64); ~GainExpanderFilter(); protected: DataType_ computeGain(DataType_ value) const override final; }; } #endif
/** * \file GainExpanderFilter.h */ #ifndef ATK_DYNAMIC_GAINEXPANDERFILTER_H #define ATK_DYNAMIC_GAINEXPANDERFILTER_H #include <vector> #include <ATK/Dynamic/GainFilter.h> #include "config.h" namespace ATK { /** * Gain "expander". Computes a new amplitude/volume gain based on threshold, slope and the power of the input signal */ template<typename DataType_> class ATK_DYNAMIC_EXPORT GainExpanderFilter : public GainFilter<DataType_> { protected: typedef GainFilter<DataType_> Parent; using typename Parent::DataType; using Parent::ratio; using Parent::softness; using Parent::recomputeFuture; using Parent::recomputeLUT; public: GainExpanderFilter(int nb_channels = 1, size_t LUTsize = 128*1024, size_t LUTprecision = 1024); ~GainExpanderFilter(); protected: DataType_ computeGain(DataType_ value) const override final; }; } #endif
Add c program for shutting down the board.
/** * Main Program to shutdown the raspberry pi. This process needs to be run as root to allow this. * All this program does is to run the shutdown command. If the process has the setuid bit enabled and belongs to root this should work. */ #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main() { /* Disable output */ system("i2cset -y 1 0x10 0x07 0x20"); system("i2cset -y 1 0x10 0x08 0x20"); system("i2cset -y 1 0x11 0x07 0x20"); system("i2cset -y 1 0x11 0x08 0x20"); system("i2cset -y 1 0x12 0x07 0x20"); system("i2cset -y 1 0x12 0x08 0x20"); system("i2cset -y 1 0x13 0x07 0x20"); system("i2cset -y 1 0x13 0x08 0x20"); /* Shutdown */ system("shutdown -h -P now"); }
Use FOUNDATION_EXTERN for global variable
// // FLEXNetworkObserver.h // Derived from: // // PDAFNetworkDomainController.h // PonyDebugger // // Created by Mike Lewis on 2/27/12. // // Licensed to Square, Inc. under one or more contributor license agreements. // See the LICENSE file distributed with this work for the terms under // which Square, Inc. licenses this file to you. // #import <Foundation/Foundation.h> extern NSString *const kFLEXNetworkObserverEnabledStateChangedNotification; /// This class swizzles NSURLConnection and NSURLSession delegate methods to observe events in the URL loading system. /// High level network events are sent to the default FLEXNetworkRecorder instance which maintains the request history and caches response bodies. @interface FLEXNetworkObserver : NSObject /// Swizzling occurs when the observer is enabled for the first time. /// This reduces the impact of FLEX if network debugging is not desired. /// NOTE: this setting persists between launches of the app. + (void)setEnabled:(BOOL)enabled; + (BOOL)isEnabled; @end
// // FLEXNetworkObserver.h // Derived from: // // PDAFNetworkDomainController.h // PonyDebugger // // Created by Mike Lewis on 2/27/12. // // Licensed to Square, Inc. under one or more contributor license agreements. // See the LICENSE file distributed with this work for the terms under // which Square, Inc. licenses this file to you. // #import <Foundation/Foundation.h> FOUNDATION_EXTERN NSString *const kFLEXNetworkObserverEnabledStateChangedNotification; /// This class swizzles NSURLConnection and NSURLSession delegate methods to observe events in the URL loading system. /// High level network events are sent to the default FLEXNetworkRecorder instance which maintains the request history and caches response bodies. @interface FLEXNetworkObserver : NSObject /// Swizzling occurs when the observer is enabled for the first time. /// This reduces the impact of FLEX if network debugging is not desired. /// NOTE: this setting persists between launches of the app. + (void)setEnabled:(BOOL)enabled; + (BOOL)isEnabled; @end
Rename namespaces in scheduler mock.
/** * @file testUtils.h * @author Konrad Zemek * @copyright (C) 2014 ACK CYFRONET AGH * @copyright This software is released under the MIT license cited in 'LICENSE.txt' */ #ifndef VEILHELPERS_SCHEDULER_MOCK_H #define VEILHELPERS_SCHEDULER_MOCK_H #include "scheduler.h" #include <gmock/gmock.h> class MockScheduler: public veil::Scheduler { public: MockScheduler() : veil::Scheduler{0} { } MOCK_METHOD1(post, void(const std::function<void()>&)); MOCK_METHOD2(schedule, std::function<void()>(const std::chrono::milliseconds, std::function<void()>)); }; #endif // VEILHELPERS_SCHEDULER_MOCK_H
/** * @file testUtils.h * @author Konrad Zemek * @copyright (C) 2014 ACK CYFRONET AGH * @copyright This software is released under the MIT license cited in 'LICENSE.txt' */ #ifndef ONEHELPERS_SCHEDULER_MOCK_H #define ONEHELPERS_SCHEDULER_MOCK_H #include "scheduler.h" #include <gmock/gmock.h> class MockScheduler: public one::Scheduler { public: MockScheduler() : one::Scheduler{0} { } MOCK_METHOD1(post, void(const std::function<void()>&)); MOCK_METHOD2(schedule, std::function<void()>(const std::chrono::milliseconds, std::function<void()>)); }; #endif // ONEHELPERS_SCHEDULER_MOCK_H
Declare 'strerror' so that we can use it with errno.
/* ===-- string.h - stub SDK header for compiler-rt -------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===-----------------------------------------------------------------------=== * * This is a stub SDK header file. This file is not part of the interface of * this library nor an official version of the appropriate SDK header. It is * intended only to stub the features of this header required by compiler-rt. * * ===-----------------------------------------------------------------------=== */ #ifndef __STRING_H__ #define __STRING_H__ typedef __SIZE_TYPE__ size_t; int memcmp(const void *, const void *, size_t); void *memcpy(void *, const void *, size_t); void *memset(void *, int, size_t); char *strcat(char *, const char *); char *strcpy(char *, const char *); char *strdup(const char *); size_t strlen(const char *); char *strncpy(char *, const char *, size_t); #endif /* __STRING_H__ */
/* ===-- string.h - stub SDK header for compiler-rt -------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===-----------------------------------------------------------------------=== * * This is a stub SDK header file. This file is not part of the interface of * this library nor an official version of the appropriate SDK header. It is * intended only to stub the features of this header required by compiler-rt. * * ===-----------------------------------------------------------------------=== */ #ifndef __STRING_H__ #define __STRING_H__ typedef __SIZE_TYPE__ size_t; int memcmp(const void *, const void *, size_t); void *memcpy(void *, const void *, size_t); void *memset(void *, int, size_t); char *strcat(char *, const char *); char *strcpy(char *, const char *); char *strdup(const char *); size_t strlen(const char *); char *strncpy(char *, const char *, size_t); /* Determine the appropriate strerror() function. */ #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) # if defined(__i386) # define __STRERROR_NAME "_strerror$UNIX2003" # elif defined(__x86_64__) || defined(__arm) # define __STRERROR_NAME "_strerror" # else # error "unrecognized architecture for targetting OS X" # endif #elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) # if defined(__i386) || defined (__x86_64) || defined(__arm) # define __STRERROR_NAME "_strerror" # else # error "unrecognized architecture for targetting iOS" # endif #else # error "unrecognized architecture for targetting Darwin" #endif char *strerror(int) __asm(__STRERROR_NAME); #endif /* __STRING_H__ */
Add C version of broadcast client
#include <arpa/inet.h> #include <errno.h> #include <sys/socket.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <netinet/in.h> #include <unistd.h> #define BROADCAST_ADDRESS "255.255.255.255" void print_error(const char* message) { size_t message_length = strlen(message); char error_message[message_length + 7]; strcpy(error_message, message); strcpy(error_message + message_length, " (%s)\n"); fprintf(stderr, error_message, strerror(errno)); } int main() { int broadcasting_socket = socket(PF_INET, SOCK_DGRAM, 0); if (broadcasting_socket == -1) { print_error("Failed to create broadcasting socket"); exit(1); } int turn_on_broadcasting = 1; int setsockopt_status = setsockopt(broadcasting_socket, SOL_SOCKET, SO_BROADCAST, &turn_on_broadcasting, sizeof(turn_on_broadcasting)); if (setsockopt_status == -1) { print_error("Failed to turn on broadcasting on"); } struct sockaddr_in broadcast_address; int broadcast_port = 54545; memset(&broadcast_address, 0, sizeof(broadcast_address)); broadcast_address.sin_family = AF_INET; broadcast_address.sin_addr.s_addr = inet_addr(BROADCAST_ADDRESS); broadcast_address.sin_port = htons(broadcast_port); ssize_t sent_bytes_count = sendto(broadcasting_socket, "", 1, 0, (struct sockaddr*) &broadcast_address, sizeof(broadcast_address)); if (sent_bytes_count == -1) { print_error("Failed to send broadcast message"); } int close_status = close(broadcasting_socket); if (close_status == -1) { print_error("Failed to close broadcast socket"); } return 0; }
Add tests for K&R-style functions.
// Copyright 2012 Rui Ueyama <rui314@gmail.com> // This program is free software licensed under the MIT license. #include "test.h" #ifdef __8cc__ #pragma disable_warning #endif void testmain(void) { print("K&R"); expect(3, no_declaration()); } int no_declaration() { return 3; }
Use strcmp instead of checking for pointer
#include "argparse.h" args *args_new() { args *args = NULL; args = malloc(sizeof(args)); if (!args) return NULL; args->opts = NULL; args->operandsc = 0; args->operands = NULL; return args; } void args_free(args *args) { if (args->opts) option_free(args->opts); args->opts = NULL; if (args->operands) operand_free(args->operands); args->operands = NULL; free(args); } int args_add_option(args *args, option *opt) { if (!args || !opt) return EXIT_FAILURE; if (!opt->short_opt && !opt->long_opt) return EXIT_FAILURE; option *last = args->opts; if (last != NULL) { while (last->next != NULL) last = last->next; last->next = opt; } else args->opts = opt; return EXIT_SUCCESS; } int args_help(args *args, FILE *stream) { if (!args || !stream || !args->opts) return EXIT_FAILURE; option *opt = args->opts; while (opt) { option_help(opt, stream); opt = opt->next; } return EXIT_SUCCESS; }
#include "argparse.h" args *args_new() { args *args = NULL; args = malloc(sizeof(args)); if (!args) return NULL; args->opts = NULL; args->operandsc = 0; args->operands = NULL; return args; } void args_free(args *args) { if (args->opts) option_free(args->opts); args->opts = NULL; if (args->operands) operand_free(args->operands); args->operands = NULL; free(args); } int args_add_option(args *args, option *opt) { if (!args || !opt) return EXIT_FAILURE; if (strcmp("", opt->short_opt) == 0 && strcmp("", opt->long_opt) == 0) return EXIT_FAILURE; option *last = args->opts; if (last != NULL) { while (last->next != NULL) last = last->next; last->next = opt; } else args->opts = opt; return EXIT_SUCCESS; } int args_help(args *args, FILE *stream) { if (!args || !stream || !args->opts) return EXIT_FAILURE; option *opt = args->opts; while (opt) { option_help(opt, stream); opt = opt->next; } return EXIT_SUCCESS; }
Allow for further room in the return enum
#ifndef NANOTIME_H #define NANOTIME_H #include <time.h> #ifdef __MACH__ #define NANO extern #else #define NANO #endif typedef enum { NANO_FAILURE = -1, NANO_SUCCESS = 0 } nano_return_t; #define NANO_EXPECTED(X) X == NANO_SUCCESS #define NANO_UNEXPECTED(X) X == NANO_FAILURE NANO nano_return_t nano_second(unsigned long *second); NANO nano_return_t nano_time(long double *time); NANO nano_return_t nano_timespec(struct timespec *now); #endif
#ifndef NANOTIME_H #define NANOTIME_H #include <time.h> #ifdef __MACH__ #define NANO extern #else #define NANO #endif typedef enum { NANO_FAILURE = -1, NANO_SUCCESS = 0 } nano_return_t; #define NANO_EXPECTED(X) (X) == NANO_SUCCESS #define NANO_UNEXPECTED(X) (X) != NANO_SUCCESS NANO nano_return_t nano_second(unsigned long *second); NANO nano_return_t nano_time(long double *time); NANO nano_return_t nano_timespec(struct timespec *now); #endif
Fix for solaris: declare tigetnum
// @(#)root/editline:$Id$ // Author: Axel Naumann, 2009 /************************************************************************* * Copyright (C) 1995-2009, 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 __sun # include R__CURSESHDR extern "C" { // cannot #include term.fH because it #defines move() etc char *tparm(char*, long, long, long, long, long, long, long, long, long); char *tigetstr(char*); char *tgoto(char*, int, int); int tputs(char*, int, int (*)(int)); int tgetflag(char*); int tgetnum(char*); char* tgetstr(char*, char**); int tgetent(char*, const char*); } // un-be-lievable. # undef erase # undef move # undef clear # undef del # undef key_end # undef key_clear # undef key_print #else # include R__CURSESHDR # include <termcap.h> # include <termcap.h> extern "C" int setupterm(const char* term, int fd, int* perrcode); #endif
// @(#)root/editline:$Id$ // Author: Axel Naumann, 2009 /************************************************************************* * Copyright (C) 1995-2009, 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 __sun # include R__CURSESHDR extern "C" { // cannot #include term.h because it #defines move() etc char *tparm(char*, long, long, long, long, long, long, long, long, long); char *tigetstr(char*); int tigetnum(char*); char *tgoto(char*, int, int); int tputs(char*, int, int (*)(int)); int tgetflag(char*); int tgetnum(char*); char* tgetstr(char*, char**); int tgetent(char*, const char*); } // un-be-lievable. # undef erase # undef move # undef clear # undef del # undef key_end # undef key_clear # undef key_print #else # include R__CURSESHDR # include <termcap.h> # include <termcap.h> extern "C" int setupterm(const char* term, int fd, int* perrcode); #endif
Add possibility to disable tests.
#include <CuTest.h> #include <stdio.h> #include <util.h> CuSuite* StrUtilGetSuite(); CuSuite* make_regex_suite(); CuSuite* make_csv_suite(); void RunAllTests(void) { CuString *output = CuStringNew(); CuSuite* suite = CuSuiteNew(); CuSuiteAddSuite(suite, StrUtilGetSuite()); CuSuiteAddSuite(suite, make_regex_suite()); CuSuiteAddSuite(suite, make_csv_suite()); CuSuiteRun(suite); CuSuiteSummary(suite, output); CuSuiteDetails(suite, output); printf("%s\n", output->buffer); } int main(void) { out_fd = stdout; /*For Logging*/ RunAllTests(); }
#include <CuTest.h> #include <stdio.h> #include <util.h> CuSuite* StrUtilGetSuite(); CuSuite* make_regex_suite(); CuSuite* make_csv_suite(); void RunAllTests(void) { CuString *output = CuStringNew(); CuSuite* suite = CuSuiteNew(); #if 1 CuSuiteAddSuite(suite, StrUtilGetSuite()); CuSuiteAddSuite(suite, make_regex_suite()); CuSuiteAddSuite(suite, make_csv_suite()); #endif CuSuiteRun(suite); CuSuiteSummary(suite, output); CuSuiteDetails(suite, output); printf("%s\n", output->buffer); } int main(void) { out_fd = stdout; /*For Logging*/ RunAllTests(); }
Remove time_dep test for now - it is too dependent on exact conditions.
#include "unity.h" #include <math.h> #include <stdlib.h> #include "quac.h" #include "operators.h" #include "solver.h" #include "dm_utilities.h" #include "quantum_gates.h" #include "petsc.h" #include "tests.h" void test_timedep(void) { double *populations; int num_pop; /* Initialize QuaC */ timedep_test(&populations,&num_pop); /* These values assume TSRK3BS */ TEST_ASSERT_EQUAL_FLOAT(populations[0],-1.487990e-04); TEST_ASSERT_EQUAL_FLOAT(populations[1],1.799424e-04); } int main(int argc, char** argv) { UNITY_BEGIN(); QuaC_initialize(argc,argv); RUN_TEST(test_timedep); QuaC_finalize(); return UNITY_END(); }
#include "unity.h" #include <math.h> #include <stdlib.h> #include "quac.h" #include "operators.h" #include "solver.h" #include "dm_utilities.h" #include "quantum_gates.h" #include "petsc.h" #include "tests.h" void test_timedep(void) { double *populations; int num_pop; /* Initialize QuaC */ timedep_test(&populations,&num_pop); /* These values assume TSRK3BS */ /* TEST_ASSERT_EQUAL_FLOAT(0.0,populations[0]); */ /* TEST_ASSERT_EQUAL_FLOAT(0.0,populations[1]); */ } int main(int argc, char** argv) { UNITY_BEGIN(); QuaC_initialize(argc,argv); RUN_TEST(test_timedep); QuaC_finalize(); return UNITY_END(); }
Fix test case to not fail due to imprecison of analysis
//PARAM: --enable ana.int.interval --enable ana.int.enums --exp.privatization "write" #include<pthread.h> // Test case that shows how avoiding reading integral globals can reduce the number of solver evaluations. // Avoiding to evaluate integral globals when setting them reduced the number of necessary evaluations from 62 to 20 in this test case. pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int glob = 10; void* t_fun(void* ptr) { pthread_mutex_lock(&mutex); glob = 3; glob = 4; glob = 1; pthread_mutex_unlock(&mutex); return NULL; } void bar() { glob = 2; } int main() { pthread_t t; pthread_create(&t, NULL, t_fun, NULL); pthread_mutex_lock(&mutex); bar(); pthread_mutex_unlock(&mutex); pthread_join(t, NULL); assert(glob >= 1); assert(glob <= 2); return 0; }
//PARAM: --enable ana.int.interval --enable ana.int.enums --exp.privatization "write" #include<pthread.h> // Test case that shows how avoiding reading integral globals can reduce the number of solver evaluations. // Avoiding to evaluate integral globals when setting them reduced the number of necessary evaluations from 62 to 20 in this test case. pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int glob = 10; void* t_fun(void* ptr) { pthread_mutex_lock(&mutex); glob = 3; glob = 4; glob = 1; pthread_mutex_unlock(&mutex); return NULL; } void bar() { glob = 2; } int main() { pthread_t t; pthread_create(&t, NULL, t_fun, NULL); pthread_mutex_lock(&mutex); bar(); pthread_mutex_unlock(&mutex); pthread_join(t, NULL); assert(glob >= 1); assert(glob <= 2); //UNKNOWN assert(glob <= 10); return 0; }
Fix a build break on Windows X86.
/* ***************************************************************** * * Copyright 2017 Microsoft * * * 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 MEMMEM_H__ #define MEMMEM_H__ #ifdef __cplusplus extern "C" { #endif void *memmem(const void *haystack, size_t haystackLen, const void *needle, size_t needleLen); #ifdef __cplusplus } #endif #endif
/* ***************************************************************** * * Copyright 2017 Microsoft * * * 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 MEMMEM_H__ #define MEMMEM_H__ // crtdefs.h is required for size_t #include <crtdefs.h> #ifdef __cplusplus extern "C" { #endif void *memmem(const void *haystack, size_t haystackLen, const void *needle, size_t needleLen); #ifdef __cplusplus } #endif #endif
Remove C Nokia notice that actually remained from the copyright boilerplate
/* * ga-error.h - Header for Avahi error types * Copyright (C) 2005 Collabora Ltd. * Copyright (C) 2005 Nokia Corporation * * 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; either * version 2.1 of the License, or (at your option) any later version. * * 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GA_ERROR_H__ #define __GA_ERROR_H__ #include <glib-object.h> G_BEGIN_DECLS #include <avahi-common/error.h> GQuark ga_error_quark(void); #define GA_ERROR ga_error_quark() G_END_DECLS #endif /* #ifndef __GA_ERROR_H__ */
/* * ga-error.h - Header for Avahi error types * Copyright (C) 2005 Collabora Ltd. * * 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; either * version 2.1 of the License, or (at your option) any later version. * * 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GA_ERROR_H__ #define __GA_ERROR_H__ #include <glib-object.h> G_BEGIN_DECLS #include <avahi-common/error.h> GQuark ga_error_quark(void); #define GA_ERROR ga_error_quark() G_END_DECLS #endif /* #ifndef __GA_ERROR_H__ */
Remove gen from loadable code
#include "csdl.h" #include <math.h> void tanhtable(FUNC *ftp, FGDATA *ff) { MYFLT *fp = ftp->ftable; MYFLT range = ff->e.p[5]; double step = (double)range/(ff->e.p[3]); int i; double x; for (i=0, x=FL(0.0); i<ff->e.p[3]; i++, x+=step) *fp++ = (MYFLT)tanh(x); } static void gentune(FUNC *ftp, FGDATA *ff) /* Gab 1/3/2005 */ { int j; int notenum; int grade; int numgrades; int basekeymidi; MYFLT basefreq, factor,interval; MYFLT *fp = ftp->ftable, *pp = &(ff->e.p[5]); int nvals = ff->e.pcnt - 4; numgrades = (int) *pp++; interval = *pp++; basefreq = *pp++; basekeymidi= (int) *pp++; nvals = ff->flenp1 - 1; for (j =0; j < nvals; j++) { notenum = j; if (notenum < basekeymidi) { notenum = basekeymidi - notenum; grade = (numgrades-(notenum % numgrades)) % numgrades; factor = - (MYFLT)(int) ((notenum+numgrades-1) / numgrades) ; } else { notenum = notenum - basekeymidi; grade = notenum % numgrades; factor = (MYFLT)(int) (notenum / numgrades); } factor = (MYFLT)pow((double)interval, (double)factor); fp[j] = pp[grade] * factor * basefreq; } } static NGFENS localfgens[] = { { "tanh", (void(*)(void))tanhtable}, { "cpstune", (void(*)(void))gentune}, { NULL, NULL} }; #define S sizeof static OENTRY localops[] = {}; FLINKAGE
#include "csdl.h" #include <math.h> void tanhtable(FUNC *ftp, FGDATA *ff) { MYFLT *fp = ftp->ftable; MYFLT range = ff->e.p[5]; double step = (double)range/(ff->e.p[3]); int i; double x; for (i=0, x=FL(0.0); i<ff->e.p[3]; i++, x+=step) *fp++ = (MYFLT)tanh(x); } static NGFENS localfgens[] = { { "tanh", (void(*)(void))tanhtable}, { NULL, NULL} }; #define S sizeof static OENTRY localops[] = {}; FLINKAGE
Add struct declaration bug - GCC mismatch with Clang
struct A { int i; }; int main(void) { struct B { struct A; struct A a; }; struct B b; b.a.i = 3; return b.a.i; }
Add testcase missed from r181527.
// RUN: %clang -fsyntax-only %s #ifdef __STDC_HOSTED__ #include <tgmath.h> float f; double d; long double l; float complex fc; double complex dc; long double complex lc; // creal _Static_assert(sizeof(creal(f)) == sizeof(f), ""); _Static_assert(sizeof(creal(d)) == sizeof(d), ""); _Static_assert(sizeof(creal(l)) == sizeof(l), ""); _Static_assert(sizeof(creal(fc)) == sizeof(f), ""); _Static_assert(sizeof(creal(dc)) == sizeof(d), ""); _Static_assert(sizeof(creal(lc)) == sizeof(l), ""); // fabs _Static_assert(sizeof(fabs(f)) == sizeof(f), ""); _Static_assert(sizeof(fabs(d)) == sizeof(d), ""); _Static_assert(sizeof(fabs(l)) == sizeof(l), ""); _Static_assert(sizeof(fabs(fc)) == sizeof(f), ""); _Static_assert(sizeof(fabs(dc)) == sizeof(d), ""); _Static_assert(sizeof(fabs(lc)) == sizeof(l), ""); // logb _Static_assert(sizeof(logb(f)) == sizeof(f), ""); _Static_assert(sizeof(logb(d)) == sizeof(d), ""); _Static_assert(sizeof(logb(l)) == sizeof(l), ""); #endif
Check for filenames and numbers to detect possible problems with asan_symbolize.py on -fPIE binaries.
#include <stdlib.h> int main() { char *x = (char*)malloc(10 * sizeof(char)); free(x); return x[5]; } // CHECK: heap-use-after-free // CHECKSLEEP: Sleeping for 1 second // CHECKSTRIP-NOT: #0 0x{{.*}} ({{[/].*}})
#include <stdlib.h> int main() { char *x = (char*)malloc(10 * sizeof(char)); free(x); return x[5]; } // CHECK: heap-use-after-free // CHECK: free // CHECK: main{{.*}}use-after-free.c:4 // CHECK: malloc // CHECK: main{{.*}}use-after-free.c:3 // CHECKSLEEP: Sleeping for 1 second // CHECKSTRIP-NOT: #0 0x{{.*}} ({{[/].*}})
Add a processor-agnostic file to include the relevant processor-specific callout and callback support for the ALien plugin.
/* * xabicc.c - platform-agnostic root for ALien call-outs and callbacks. * * Support for Call-outs and Call-backs from the IA32ABI Plugin. * The plgin is misnamed. It should be the AlienPlugin, but its history * dictates otherwise. */ #if i386|i486|i586|i686 # include "ia32abicc.c" #elif powerpc|ppc # include "ppcia32abicc.c" #elif x86_64|x64 # include "x64ia32abicc.o" #endif
Increment FW_BUILD. Initial release for kl26z_nrf51822_if with CDC support
/* CMSIS-DAP Interface Firmware * Copyright (c) 2009-2013 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef VERSION_H #define VERSION_H #include "stdint.h" // built for bootloader 1xxx //#define FW_BUILD "1203" // build for bootloader 0xxx #define FW_BUILD "0226" void update_html_file(uint8_t *buf, uint32_t bufsize); uint8_t * get_uid_string (void); uint8_t get_len_string_interface(void); uint8_t * get_uid_string_interface(void); void init_auth_config (void); void build_mac_string(uint32_t *uuid_data); #endif
/* CMSIS-DAP Interface Firmware * Copyright (c) 2009-2013 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef VERSION_H #define VERSION_H #include "stdint.h" // built for bootloader 1xxx //#define FW_BUILD "1203" // build for bootloader 0xxx #define FW_BUILD "0227" void update_html_file(uint8_t *buf, uint32_t bufsize); uint8_t * get_uid_string (void); uint8_t get_len_string_interface(void); uint8_t * get_uid_string_interface(void); void init_auth_config (void); void build_mac_string(uint32_t *uuid_data); #endif
Read UART faster to prevent buffer overflows
#ifndef QGC_CONFIGURATION_H #define QGC_CONFIGURATION_H #include <QString> /** @brief Polling interval in ms */ #define SERIAL_POLL_INTERVAL 9 /** @brief Heartbeat emission rate, in Hertz (times per second) */ #define MAVLINK_HEARTBEAT_DEFAULT_RATE 1 #define WITH_TEXT_TO_SPEECH 1 #define QGC_APPLICATION_NAME "QGroundControl" #define QGC_APPLICATION_VERSION "v. 2.0.1 (beta)" namespace QGC { const QString APPNAME = "QGROUNDCONTROL"; const QString ORG_NAME = "QGROUNDCONTROL.ORG"; //can be customized by forks to e.g. mycompany.com to maintain separate Settings for customized apps const QString ORG_DOMAIN = "org.qgroundcontrol";//can be customized by forks const int APPLICATIONVERSION = 201; // 2.0.1 } #endif // QGC_CONFIGURATION_H
#ifndef QGC_CONFIGURATION_H #define QGC_CONFIGURATION_H #include <QString> /** @brief Polling interval in ms */ #define SERIAL_POLL_INTERVAL 5 /** @brief Heartbeat emission rate, in Hertz (times per second) */ #define MAVLINK_HEARTBEAT_DEFAULT_RATE 1 #define WITH_TEXT_TO_SPEECH 1 #define QGC_APPLICATION_NAME "QGroundControl" #define QGC_APPLICATION_VERSION "v. 2.0.1 (beta)" namespace QGC { const QString APPNAME = "QGROUNDCONTROL"; const QString ORG_NAME = "QGROUNDCONTROL.ORG"; //can be customized by forks to e.g. mycompany.com to maintain separate Settings for customized apps const QString ORG_DOMAIN = "org.qgroundcontrol";//can be customized by forks const int APPLICATIONVERSION = 201; // 2.0.1 } #endif // QGC_CONFIGURATION_H
Add c pointer basic example
#include <stdio.h> int main() { /* hi this is a multi-line comment hi. */ // single-line comment printf ("Hello world!\n"); // this works too // some vars and control flow int numDaysInYear = 365; printf ("days per year: %d\n", numDaysInYear); if (numDaysInYear == 366) { printf ("Seems reasonable\n"); } else { int long someReallyLongNumber = 100000000000000L; printf ("Some long number: %ld\n", someReallyLongNumber); } // loops int i; for (i=0; i<5; i++) { printf ("i=%d\n", i); } }
#include <stdio.h> int main() { /* hi this is a multi-line comment hi. */ // single-line comment printf ("Hello world!\n"); // this works too // some vars and control flow int numDaysInYear = 365; printf ("days per year: %d\n", numDaysInYear); if (numDaysInYear == 366) { printf ("Seems reasonable\n"); } else { int long someReallyLongNumber = 100000000000000L; printf ("Some long number: %ld\n", someReallyLongNumber); } // loops int i; for (i=0; i<5; i++) { printf ("i=%d\n", i); } // https://www.seas.gwu.edu/~simhaweb/C/lectures/module2/module2 int x = 5; int *intPtr; // print mem address of variable i printf ("Variable x is located at memory address %lu\n", &x); // extract address of var i into the pointer intPtr = & x; printf ("The int at memory location %lu is %d\n", intPtr, *intPtr); // TODO: examine compiler warnings }
Apply patch for C standards compliance: "All declarations that refer to the same object or function shall have compatible type; otherwise, the behavior is undefined." (That's from ISO/IEC 9899:TC2 final committee draft, section 6.2.7.)
/* $Id$ $Revision$ */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #include "gvplugin.h" extern gvplugin_installed_t gvdevice_types_xlib; static gvplugin_api_t apis[] = { {API_device, &gvdevice_types_xlib}, {(api_t)0, 0}, }; gvplugin_library_t gvplugin_xlib_LTX_library = { "xlib", apis };
/* $Id$ $Revision$ */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #include "gvplugin.h" extern gvplugin_installed_t gvdevice_types_xlib[]; static gvplugin_api_t apis[] = { {API_device, gvdevice_types_xlib}, {(api_t)0, 0}, }; gvplugin_library_t gvplugin_xlib_LTX_library = { "xlib", apis };
Add comment for doxygen for namespace
//===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===// // // This file defines a set of enums which allow processing of intrinsic // functions. Values of these enum types are returned by // Function::getIntrinsicID. // //===----------------------------------------------------------------------===// #ifndef LLVM_INTRINSICS_H #define LLVM_INTRINSICS_H namespace LLVMIntrinsic { enum ID { not_intrinsic = 0, // Must be zero va_start, // Used to represent a va_start call in C va_end, // Used to represent a va_end call in C va_copy, // Used to represent a va_copy call in C setjmp, // Used to represent a setjmp call in C longjmp, // Used to represent a longjmp call in C }; } #endif
//===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===// // // This file defines a set of enums which allow processing of intrinsic // functions. Values of these enum types are returned by // Function::getIntrinsicID. // //===----------------------------------------------------------------------===// #ifndef LLVM_INTRINSICS_H #define LLVM_INTRINSICS_H /// LLVMIntrinsic Namespace - This namespace contains an enum with a value for /// every intrinsic/builtin function known by LLVM. These enum values are /// returned by Function::getIntrinsicID(). /// namespace LLVMIntrinsic { enum ID { not_intrinsic = 0, // Must be zero va_start, // Used to represent a va_start call in C va_end, // Used to represent a va_end call in C va_copy, // Used to represent a va_copy call in C setjmp, // Used to represent a setjmp call in C longjmp, // Used to represent a longjmp call in C }; } #endif
Allow getting raw pointer from MaybeRef
#pragma once #include <gsl/gsl> namespace Halley { // Note: it's important that this class has the same layout and binary structure as a plain pointer template <typename T> class MaybeRef { public: MaybeRef() : pointer(nullptr) {} MaybeRef(T* pointer) : pointer(pointer) {} MaybeRef(T& ref) : pointer(&ref) {} bool hasValue() const { return pointer != nullptr; } T& get() { Expects(pointer != nullptr); return *pointer; } const T& get() const { Expects(pointer != nullptr); return *pointer; } T* operator->() { Expects(pointer != nullptr); return pointer; } const T* operator->() const { Expects(pointer != nullptr); return pointer; } operator bool() const { return pointer != nullptr; } private: T* pointer; }; }
#pragma once #include <gsl/gsl> namespace Halley { // Note: it's important that this class has the same layout and binary structure as a plain pointer template <typename T> class MaybeRef { public: MaybeRef() : pointer(nullptr) {} MaybeRef(T* pointer) : pointer(pointer) {} MaybeRef(T& ref) : pointer(&ref) {} bool hasValue() const { return pointer != nullptr; } T& get() { Expects(pointer != nullptr); return *pointer; } const T& get() const { Expects(pointer != nullptr); return *pointer; } T* operator->() { Expects(pointer != nullptr); return pointer; } const T* operator->() const { Expects(pointer != nullptr); return pointer; } operator bool() const { return pointer != nullptr; } T* tryGet() { return pointer; } const T* tryGet() const { return pointer; } private: T* pointer; }; }
Add some missing definitions for mingw.org
/* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_mingw_compat__ #define INCLUDE_mingw_compat__ #if defined(__MINGW32__) #undef stat #if _WIN32_WINNT >= 0x0601 #define stat __stat64 #else #define stat _stati64 #endif #endif #endif /* INCLUDE_mingw_compat__ */
/* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_mingw_compat__ #define INCLUDE_mingw_compat__ #if defined(__MINGW32__) #undef stat #if _WIN32_WINNT >= 0x0601 #define stat __stat64 #else #define stat _stati64 #endif #if _WIN32_WINNT < 0x0600 && !defined(__MINGW64_VERSION_MAJOR) #undef MemoryBarrier void __mingworg_MemoryBarrier(void); #define MemoryBarrier __mingworg_MemoryBarrier #define VOLUME_NAME_DOS 0x0 #endif #endif #endif /* INCLUDE_mingw_compat__ */
Remove prototypes for static methods
/* * Copyright (c) 2012-2016 Israel Jacquez * See LICENSE for details. * * Israel Jacquez <mrkotfw@gmail.com> */ #ifndef _CPU_H_ #define _CPU_H_ #include <cpu/cache.h> #include <cpu/divu.h> #include <cpu/dmac.h> #include <cpu/dual.h> #include <cpu/endian.h> #include <cpu/frt.h> #include <cpu/instructions.h> #include <cpu/intc.h> #include <cpu/registers.h> #include <cpu/sync.h> #include <cpu/wdt.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ extern void cpu_init(void); extern void _slave_polling_entry(void); extern void _slave_ici_entry(void); extern void _exception_illegal_instruction(void); extern void _exception_illegal_slot(void); extern void _exception_cpu_address_error(void); extern void _exception_dma_address_error(void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* !_CPU_H_ */
/* * Copyright (c) 2012-2016 Israel Jacquez * See LICENSE for details. * * Israel Jacquez <mrkotfw@gmail.com> */ #ifndef _CPU_H_ #define _CPU_H_ #include <cpu/cache.h> #include <cpu/divu.h> #include <cpu/dmac.h> #include <cpu/dual.h> #include <cpu/endian.h> #include <cpu/frt.h> #include <cpu/instructions.h> #include <cpu/intc.h> #include <cpu/registers.h> #include <cpu/sync.h> #include <cpu/wdt.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ extern void cpu_init(void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* !_CPU_H_ */
Make module^p and b^module modules
#pragma once #include <noise/noise.h> #include <cmath> // This is similar to noise::module::Exp. // However, no rescaling is performed, // and no attempt is made to guard against invalid operations. // Make sure the range of the source module // is compatible with the base of the exponential! // This module names its parameter "base" rather than "exponent", // because the formula is pow(base, source_value), // not pow(source_value, exponent). class Exp : public noise::module::Module { public: double base; Exp() : Module(GetSourceModuleCount()), mBase(2.) {}; virtual int GetSourceModuleCount() const { return 1; } void SetBase(double base) { mBase = base; } double GetBase() const { return mBase; } virtual double GetValue(double x, double y, double z) const { return pow(mBase, GetSourceModule(0).GetValue(x,y,z)); }; protected: double mBase; }; // Noise module that raises a source module to an exponent. // No attempt is made to guard against invalid operations. // Make sure the range of the source module // is compatible with the exponent! // The formula is pow(source_value, exponent) class Power : public noise::module::Module { public: double exponent; Power() : Module(GetSourceModuleCount()), mExponent(2.) {}; virtual int GetSourceModuleCount() const { return 1; } void SetExponent(double exponent) { mExponent = exponent; } double GetExponent() const { return mExponent; } virtual double GetValue(double x, double y, double z) const { return pow(GetSourceModule(0).GetValue(x, y, z), mExponent); }; protected: double mExponent; };
Add missing VoidPtr implementation from last commit.
/* * Appcelerator Kroll - licensed under the Apache Public License 2 * see LICENSE in the root folder for details on the license. * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved. */ #ifndef _KR_VOID_PTR_OBJECT_H_ #define _KR_VOID_PTR_OBJECT_H_ #include "../kroll.h" namespace kroll { /** * An object that represents an arbitrary amount of binary data§ */ class KROLL_API VoidPtr : public StaticBoundObject { public: VoidPtr(void* pointer) : StaticBoundObject("VoidPtr"), pointer(pointer) {} void* GetPtr() { return pointer; } private: void* pointer; }; } #endif
Convert module-based imports to relative
#import <Foundation/Foundation.h> #import <Nimble/NMBExceptionCapture.h> #import <Nimble/DSL.h> FOUNDATION_EXPORT double NimbleVersionNumber; FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
#import <Foundation/Foundation.h> #import "NMBExceptionCapture.h" #import "DSL.h" FOUNDATION_EXPORT double NimbleVersionNumber; FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
Enable serialise packet for Cata
/* Copyright (c) 2014-2018 AscEmu Team <http://www.ascemu.org> This file is released under the MIT license. See README-MIT for more information. */ #pragma once #include <cstdint> #include "ManagedPacket.h" namespace AscEmu { namespace Packets { class SmsgWeather : public ManagedPacket { #if VERSION_STRING != Cata public: uint32_t type; float_t density; uint32_t sound; SmsgWeather() : SmsgWeather(0, 0, 0) { } SmsgWeather(uint32_t type, float_t density, uint32_t sound) : ManagedPacket(SMSG_WEATHER, 13), type(type), density(density), sound(sound) { } protected: bool internalSerialise(WorldPacket& packet) override { packet << type << density << sound << uint8_t(0); return true; } bool internalDeserialise(WorldPacket& packet) override { return false; } #endif }; }}
/* Copyright (c) 2014-2018 AscEmu Team <http://www.ascemu.org> This file is released under the MIT license. See README-MIT for more information. */ #pragma once #include <cstdint> #include "ManagedPacket.h" namespace AscEmu { namespace Packets { class SmsgWeather : public ManagedPacket { public: uint32_t type; float_t density; uint32_t sound; SmsgWeather() : SmsgWeather(0, 0, 0) { } SmsgWeather(uint32_t type, float_t density, uint32_t sound) : ManagedPacket(SMSG_WEATHER, 13), type(type), density(density), sound(sound) { } protected: bool internalSerialise(WorldPacket& packet) override { packet << type << density << sound << uint8_t(0); return true; } bool internalDeserialise(WorldPacket& packet) override { return false; } }; }}
Add default implementations of IXmlDeserializing methods.
#ifndef QTXXML_IXMLDESERIALIZING_H #define QTXXML_IXMLDESERIALIZING_H #include "xmlglobal.h" #include <QtCore> QTX_BEGIN_NAMESPACE class IXmlDeserializing { public: virtual ~IXmlDeserializing() {}; virtual IXmlDeserializing *deserializeXmlStartElement(XmlDeserializer *deserializer, const QStringRef & name, const QStringRef & namespaceUri, const QXmlStreamAttributes & attributes) = 0; virtual void deserializeXmlEndElement(XmlDeserializer *deserializer, const QStringRef & name, const QStringRef & namespaceUri) = 0; virtual void deserializeXmlAttributes(XmlDeserializer *deserializer, const QXmlStreamAttributes & attributes) = 0; virtual void deserializeXmlCharacters(XmlDeserializer *deserializer, const QStringRef & text) = 0; }; QTX_END_NAMESPACE #endif // QTXXML_IXMLDESERIALIZING_H
#ifndef QTXXML_IXMLDESERIALIZING_H #define QTXXML_IXMLDESERIALIZING_H #include "xmlglobal.h" #include <QtCore> QTX_BEGIN_NAMESPACE class IXmlDeserializing { public: virtual ~IXmlDeserializing() {}; virtual IXmlDeserializing *deserializeXmlStartElement(XmlDeserializer * deserializer, const QStringRef & name, const QStringRef & namespaceUri, const QXmlStreamAttributes & attributes) { Q_UNUSED(deserializer) Q_UNUSED(name) Q_UNUSED(namespaceUri) Q_UNUSED(attributes) return 0; } virtual void deserializeXmlEndElement(XmlDeserializer *deserializer, const QStringRef & name, const QStringRef & namespaceUri) { Q_UNUSED(deserializer) Q_UNUSED(name) Q_UNUSED(namespaceUri) } virtual void deserializeXmlAttributes(XmlDeserializer *deserializer, const QXmlStreamAttributes & attributes) { Q_UNUSED(deserializer) Q_UNUSED(attributes) } virtual void deserializeXmlCharacters(XmlDeserializer *deserializer, const QStringRef & text) { Q_UNUSED(deserializer) Q_UNUSED(text) } }; QTX_END_NAMESPACE #endif // QTXXML_IXMLDESERIALIZING_H
Add a very simple example which uses FastCGI, a stripped down version of one given by Mike Tsao.
/** * Copyright 2006 Mike Tsao. All rights reserved. * * Hello World using FastCGI and ClearSilver. */ #include "ClearSilver.h" #include <string> #include <fcgi_stdio.h> #include <stdlib.h> #include <stdarg.h> #include <syslog.h> static bool quit = false; static int cs_printf(void *ctx, const char *s, va_list args) { return printf(s, args); } static int cs_write(void *ctx, const char *s, int n) { return fwrite(const_cast<char *>(s), n, 1, FCGI_stdout); } int main(int argc, char **argv, char **envp) { openlog(argv[0], 0, LOG_USER); syslog(LOG_INFO, "%s started.", argv[0]); int hits = 0; while (FCGI_Accept() >= 0) { HDF *hdf = NULL; CGI *cgi = NULL; /* Note that we aren't doing any error handling here, we really should. */ hdf_init(&hdf); // Takes ownership of HDF. cgi_init(&cgi, hdf); hits++; /* Initialize the standard cgiwrap environment. FastCGI already wraps some * of the standard calls that cgiwrap wraps. */ cgiwrap_init_std(argc, argv, environ); /* Then, we install our own wrappers for some cgiwrap calls that aren't * already wrapped in the standard wrappers. */ cgiwrap_init_emu(NULL, NULL, cs_printf, cs_write, NULL, NULL, NULL); hdf_read_file(cgi->hdf, "common.hdf"); hdf_read_file(cgi->hdf, "hello_world.hdf"); cgi_display(cgi, "hello_world.cs"); // This destroys HDF. cgi_destroy(&cgi); } syslog(LOG_INFO, "%s ending.", argv[0]); return 0; }