Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Fix extra fread after EOF, non-wires-crossed version.
/*===- count.c - The 'count' testing tool ---------------------------------===*\ * * The LLVM Compiler Infrastructure * * This file is distributed under the University of Illinois Open Source * License. See LICENSE.TXT for details. * \*===----------------------------------------------------------------------===*/ #include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { unsigned Count, NumLines, NumRead; char Buffer[4096], *End; if (argc != 2) { fprintf(stderr, "usage: %s <expected line count>\n", argv[0]); return 2; } Count = strtol(argv[1], &End, 10); if (*End != '\0' && End != argv[1]) { fprintf(stderr, "%s: invalid count argument '%s'\n", argv[0], argv[1]); return 2; } NumLines = 0; while ((NumRead = fread(Buffer, 1, sizeof(Buffer), stdin))) { unsigned i; for (i = 0; i != NumRead; ++i) if (Buffer[i] == '\n') ++NumLines; } if (!feof(stdin)) { fprintf(stderr, "%s: error reading stdin\n", argv[0]); return 3; } if (Count != NumLines) { fprintf(stderr, "Expected %d lines, got %d.\n", Count, NumLines); return 1; } return 0; }
/*===- count.c - The 'count' testing tool ---------------------------------===*\ * * The LLVM Compiler Infrastructure * * This file is distributed under the University of Illinois Open Source * License. See LICENSE.TXT for details. * \*===----------------------------------------------------------------------===*/ #include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { unsigned Count, NumLines, NumRead; char Buffer[4096], *End; if (argc != 2) { fprintf(stderr, "usage: %s <expected line count>\n", argv[0]); return 2; } Count = strtol(argv[1], &End, 10); if (*End != '\0' && End != argv[1]) { fprintf(stderr, "%s: invalid count argument '%s'\n", argv[0], argv[1]); return 2; } NumLines = 0; do { unsigned i; NumRead = fread(Buffer, 1, sizeof(Buffer), stdin); for (i = 0; i != NumRead; ++i) if (Buffer[i] == '\n') ++NumLines; } while (NumRead == sizeof(Buffer)); if (!feof(stdin)) { fprintf(stderr, "%s: error reading stdin\n", argv[0]); return 3; } if (Count != NumLines) { fprintf(stderr, "Expected %d lines, got %d.\n", Count, NumLines); return 1; } return 0; }
Update import to be compatible with KSCrash 1.8.8+
// // BugsnagSink.h // // Created by Conrad Irwin on 2014-10-01. // // Copyright (c) 2014 Bugsnag, Inc. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall remain in place // in this source code. // // 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. // #import <Foundation/Foundation.h> #import <KSCrash/KSCrash.h> @interface BugsnagSink : NSObject <KSCrashReportFilter> @end
// // BugsnagSink.h // // Created by Conrad Irwin on 2014-10-01. // // Copyright (c) 2014 Bugsnag, Inc. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall remain in place // in this source code. // // 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. // #import <Foundation/Foundation.h> #import <KSCrash/KSCrashReportFilter.h> @interface BugsnagSink : NSObject <KSCrashReportFilter> @end
Remove unneeded method from private header
/* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2013-2014 Cocos2D Authors * * 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. */ #import "CCActionManager.h" @interface CCActionManager () -(void)migrateActions:(id)target from:(CCActionManager*)oldManager; @end
/* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2013-2014 Cocos2D Authors * * 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. */ #import "CCActionManager.h" @interface CCActionManager () // TODO eliminate file @end
Return success rather than failure from shutdown() on FileDescriptor, since it is entirely immaterial.
#ifndef FILE_DESCRIPTOR_H #define FILE_DESCRIPTOR_H #include <io/channel.h> class FileDescriptor : public Channel { LogHandle log_; protected: int fd_; public: FileDescriptor(int); ~FileDescriptor(); virtual Action *close(EventCallback *); virtual Action *read(size_t, EventCallback *); virtual Action *write(Buffer *, EventCallback *); virtual bool shutdown(bool, bool) { return (false); } }; #endif /* !FILE_DESCRIPTOR_H */
#ifndef FILE_DESCRIPTOR_H #define FILE_DESCRIPTOR_H #include <io/channel.h> class FileDescriptor : public Channel { LogHandle log_; protected: int fd_; public: FileDescriptor(int); ~FileDescriptor(); virtual Action *close(EventCallback *); virtual Action *read(size_t, EventCallback *); virtual Action *write(Buffer *, EventCallback *); virtual bool shutdown(bool, bool) { return (true); } }; #endif /* !FILE_DESCRIPTOR_H */
Structure defining information starter needs from the shadow to start up a user job.
typedef struct { int cluster; /* Condor Cluster # */ int proc; /* Condor Proc # */ int job_class; /* STANDARD, VANILLA, PVM, PIPE, ... */ uid_t uid; /* Execute job under this UID */ gid_t gid; /* Execute job under this pid */ pid_t virt_pid; /* PVM virt pid of this process */ int soft_kill_sig; /* Use this signal for a soft kill */ char *a_out_name; /* Where to get executable file */ char *cmd; /* Command name given by the user */ char *args; /* Command arguments given by the user */ char *env; /* Environment variables */ char *iwd; /* Initial working directory */ BOOLEAN ckpt_wanted; /* Whether user wants checkpointing */ BOOLEAN is_restart; /* Whether this run is a restart */ BOOLEAN coredump_limit_exists; /* Whether user wants to limit core size */ int coredump_limit; /* Limit in bytes */ } STARTUP_INFO;
Add a bit_value function for the numeric value of a single bit
#pragma once #include "../definitions.h" #include "log.h" namespace bitwise { inline u16 compose_bytes(const u8 high, const u8 low) { return static_cast<u16>((high << 8) + low); } inline bool check_bit(const u8 value, const u8 bit) { return (value & (1 << bit)) != 0; } inline u8 set_bit(const u8 value, const u8 bit) { auto value_set = value | (1 << bit); return static_cast<u8>(value_set); } inline u8 clear_bit(const u8 value, const u8 bit) { auto value_cleared = value & ~(1 << bit); return static_cast<u8>(value_cleared); } inline u8 set_bit_to(const u8 value, const u8 bit, bool bit_on) { return bit_on ? set_bit(value, bit) : clear_bit(value, bit); } } // namespace bitwise
#pragma once #include "../definitions.h" #include "log.h" namespace bitwise { inline u16 compose_bytes(const u8 high, const u8 low) { return static_cast<u16>((high << 8) + low); } inline bool check_bit(const u8 value, const u8 bit) { return (value & (1 << bit)) != 0; } inline u8 bit_value(const u8 value, const u8 bit) { return (value >> bit) & 1; } inline u8 set_bit(const u8 value, const u8 bit) { auto value_set = value | (1 << bit); return static_cast<u8>(value_set); } inline u8 clear_bit(const u8 value, const u8 bit) { auto value_cleared = value & ~(1 << bit); return static_cast<u8>(value_cleared); } inline u8 set_bit_to(const u8 value, const u8 bit, bool bit_on) { return bit_on ? set_bit(value, bit) : clear_bit(value, bit); } } // namespace bitwise
Add a mechanism for handling fatal errors (and reboots)
/* * Copyright (C) 2014 INRIA * * This file is subject to the terms and conditions of the GNU Lesser General * Public License. See the file LICENSE in the top level directory for more * details. */ /** * @addtogroup core_util * @{ * * @file crash.h * @brief Crash handling header * * Define a panic() function that allows to stop/reboot the system * when an unrecoverable problem has occured. * * @author Kévin Roussel <Kevin.Roussel@inria.fr> */ #ifndef __CRASH_H #define __CRASH_H #include "kernel.h" /** Handle an unrecoverable error by halting or rebooting the system. A numeric code indicating the failure reason can be given as the ::crash_code parameter. Detailing the failure is possible using the ::message parameter. This function should serve a similar purpose than the panic() function of Unix/Linux kernels. if DEVELHELP macro is defined, system will be halted; system will be rebooted otherwise. WARNING: this function NEVER returns! */ NORETURN void core_panic(int crash_code, const char *message); /** @} */ #endif /* __CRASH_H */
Add class for the progress window
#pragma once #include "../Controls/Dialog.h" #include "../resource.h" class ProgressWindow : public Dialog { public: ProgressWindow() : Dialog(L"3RVX-UpdateProgress", MAKEINTRESOURCE(IDD_DOWNLOAD)) { ShowWindow(Dialog::DialogHandle(), SW_SHOWNORMAL); } };
Add a test that local submodule visibility has no effect on debug info
// RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited -dwarf-ext-refs \ // RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \ // RUN: %s -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s #include "DebugSubmoduleA.h" #include "DebugSubmoduleB.h" // CHECK: !DICompileUnit // CHECK-NOT: !DICompileUnit // CHECK: !DIModule(scope: ![[PARENT:.*]], name: "DebugSubmoduleA" // CHECK: [[PARENT]] = !DIModule(scope: null, name: "DebugSubmodules" // CHECK: !DIModule(scope: ![[PARENT]], name: "DebugSubmoduleB" // CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}DebugSubmodules // CHECK-SAME: dwoId: // CHECK-NOT: !DICompileUnit
// RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited -dwarf-ext-refs \ // RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \ // RUN: %s -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s // // RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited -dwarf-ext-refs \ // RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \ // RUN: -fmodules-local-submodule-visibility \ // RUN: %s -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s #include "DebugSubmoduleA.h" #include "DebugSubmoduleB.h" // CHECK: !DICompileUnit // CHECK-NOT: !DICompileUnit // CHECK: !DIModule(scope: ![[PARENT:.*]], name: "DebugSubmoduleA" // CHECK: [[PARENT]] = !DIModule(scope: null, name: "DebugSubmodules" // CHECK: !DIModule(scope: ![[PARENT]], name: "DebugSubmoduleB" // CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}DebugSubmodules // CHECK-SAME: dwoId: // CHECK-NOT: !DICompileUnit
Update example with new constraints on map/reduce prototype.
#include <gmp.h> #include "m-array.h" #include "m-algo.h" ARRAY_DEF(mpz, mpz_t, M_CLASSIC_OPLIST(mpz)) ALGO_DEF(array_mpz, ARRAY_OPLIST(mpz, M_CLASSIC_OPLIST(mpz))) static inline void my_mpz_inc(mpz_t d, const mpz_t a){ mpz_add(d, d, a); } static inline void my_mpz_sqr(mpz_t d, const mpz_t a){ mpz_mul(d, a, a); } int main(void) { mpz_t z; mpz_init_set_ui(z, 1); array_mpz_t a; array_mpz_init(a); array_mpz_push_back(a, z); for(size_t i = 2 ; i < 1000; i++) { mpz_mul_ui(z, z, i); array_mpz_push_back(a, z); } /* z = sum (a[i]^2) */ array_mpz_map_reduce (&z, a, my_mpz_inc, my_mpz_sqr); gmp_printf ("Z=%Zd\n", z); array_mpz_clear(a); mpz_clear(z); }
#include <gmp.h> #include "m-array.h" #include "m-algo.h" ARRAY_DEF(mpz, mpz_t, M_CLASSIC_OPLIST(mpz)) ALGO_DEF(array_mpz, ARRAY_OPLIST(mpz, M_CLASSIC_OPLIST(mpz))) static inline void my_mpz_inc(mpz_t *d, const mpz_t a){ mpz_add(*d, *d, a); } static inline void my_mpz_sqr(mpz_t *d, const mpz_t a){ mpz_mul(*d, a, a); } int main(void) { mpz_t z; mpz_init_set_ui(z, 1); array_mpz_t a; array_mpz_init(a); array_mpz_push_back(a, z); for(size_t i = 2 ; i < 1000; i++) { mpz_mul_ui(z, z, i); array_mpz_push_back(a, z); } /* z = sum (a[i]^2) */ array_mpz_map_reduce (&z, a, my_mpz_inc, my_mpz_sqr); gmp_printf ("Z=%Zd\n", z); array_mpz_clear(a); mpz_clear(z); }
Add a debugging print macro.
#ifndef util_h #define util_h #define min(a,b) ((a)<(b)?(a):(b)) int warn(const char *s); void v(); #endif /*util_h*/
#ifndef util_h #define util_h #define min(a,b) ((a)<(b)?(a):(b)) int warn(const char *s); void v(); #ifdef DEBUG #define dprintf(fmt, args...) fprintf(stderr, fmt, ##args) #else #define dprintf(fmt, ...) (0) #endif #endif /*util_h*/
Add generic response structure inside prd_fw_msg
/* Copyright 2017 IBM Corp. * * 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 __PRD_FW_MSG_H #define __PRD_FW_MSG_H #include <types.h> /* Messaging structure for the opaque channel between OPAL and HBRT. This * format is used for the firmware_request and firmware_notify interfaces */ enum { PRD_FW_MSG_TYPE_REQ_NOP = 0, PRD_FW_MSG_TYPE_RESP_NOP = 1, }; struct prd_fw_msg { __be64 type; }; #define PRD_FW_MSG_BASE_SIZE sizeof(__be64) #endif /* __PRD_FW_MSG_H */
/* Copyright 2017 IBM Corp. * * 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 __PRD_FW_MSG_H #define __PRD_FW_MSG_H #include <types.h> /* Messaging structure for the opaque channel between OPAL and HBRT. This * format is used for the firmware_request and firmware_notify interfaces */ enum { PRD_FW_MSG_TYPE_REQ_NOP = 0, PRD_FW_MSG_TYPE_RESP_NOP = 1, PRD_FW_MSG_TYPE_RESP_GENERIC = 2, PRD_FW_MSG_TYPE_REQ_HCODE_UPDATE = 3, PRD_FW_MSG_TYPE_HBRT_FSP = 4, PRD_FW_MSG_TYPE_ERROR_LOG = 5, PRD_FW_MSG_TYPE_FSP_HBRT = 6, }; struct prd_fw_msg { __be64 type; union { struct { __be64 status; } generic_resp; }; }; #define PRD_FW_MSG_BASE_SIZE sizeof(__be64) #endif /* __PRD_FW_MSG_H */
Disable freetype stream support, avoiding FILE interface.
/* custom ftoption.h which selects the minimum features needed by mupdf */ #include <freetype/config/ftoption.h> #undef FT_CONFIG_OPTION_USE_LZW #undef FT_CONFIG_OPTION_USE_ZLIB #undef FT_CONFIG_OPTION_USE_BZIP2 #undef FT_CONFIG_OPTION_USE_PNG #undef FT_CONFIG_OPTION_USE_HARFBUZZ #undef FT_CONFIG_OPTION_MAC_FONTS #undef FT_CONFIG_OPTION_INCREMENTAL #undef TT_CONFIG_OPTION_EMBEDDED_BITMAPS #undef TT_CONFIG_OPTION_SFNT_NAMES #undef TT_CONFIG_OPTION_GX_VAR_SUPPORT #undef TT_CONFIG_OPTION_BDF #undef T1_CONFIG_OPTION_NO_AFM #undef T1_CONFIG_OPTION_NO_MM_SUPPORT #undef CFF_CONFIG_OPTION_OLD_ENGINE
/* custom ftoption.h which selects the minimum features needed by mupdf */ #include <freetype/config/ftoption.h> #undef FT_CONFIG_OPTION_USE_LZW #undef FT_CONFIG_OPTION_USE_ZLIB #undef FT_CONFIG_OPTION_USE_BZIP2 #undef FT_CONFIG_OPTION_USE_PNG #undef FT_CONFIG_OPTION_USE_HARFBUZZ #undef FT_CONFIG_OPTION_MAC_FONTS #undef FT_CONFIG_OPTION_INCREMENTAL #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT #undef TT_CONFIG_OPTION_EMBEDDED_BITMAPS #undef TT_CONFIG_OPTION_SFNT_NAMES #undef TT_CONFIG_OPTION_GX_VAR_SUPPORT #undef TT_CONFIG_OPTION_BDF #undef T1_CONFIG_OPTION_NO_AFM #undef T1_CONFIG_OPTION_NO_MM_SUPPORT #undef CFF_CONFIG_OPTION_OLD_ENGINE
Fix up prototypes for read() and write() on Suns.
#ifndef FIX_UNISTD_H #define FIX_UNISTD_H #include <unistd.h> /* For some reason the g++ include files on Ultrix 4.3 fail to provide these prototypes, even though the Ultrix 4.2 versions did... Once again, OSF1 also chokes, unless _AES_SOURCE(?) is defined JCP */ #if defined(ULTRIX43) || defined(SUNOS41) || defined(OSF1) #if defined(__cplusplus) extern "C" { #endif #if defined(SUNOS41) || defined(ULTRIX43) typedef unsigned long ssize_t; #endif #if defined(__STDC__) || defined(__cplusplus) int symlink( const char *, const char * ); void *sbrk( ssize_t ); int gethostname( char *, int ); #else int symlink(); char *sbrk(); int gethostname(); #endif #if defined(__cplusplus) } #endif #endif /* ULTRIX43 */ #endif
#ifndef FIX_UNISTD_H #define FIX_UNISTD_H #if defined(SUNOS41) # define read _hide_read # define write _hide_write #endif #include <unistd.h> #if defined(SUNOS41) # undef read # undef write #endif /* For some reason the g++ include files on Ultrix 4.3 fail to provide these prototypes, even though the Ultrix 4.2 versions did... Once again, OSF1 also chokes, unless _AES_SOURCE(?) is defined JCP */ #if defined(ULTRIX43) || defined(SUNOS41) || defined(OSF1) #if defined(__cplusplus) extern "C" { #endif #if defined(SUNOS41) || defined(ULTRIX43) typedef unsigned long ssize_t; #endif #if defined(__STDC__) || defined(__cplusplus) int symlink( const char *, const char * ); void *sbrk( ssize_t ); int gethostname( char *, int ); # if defined(SUNOS41) ssize_t read( int, void *, size_t ); ssize_t write( int, const void *, size_t ); # endif #else int symlink(); char *sbrk(); int gethostname(); #endif #if defined(__cplusplus) } #endif #endif /* ULTRIX43 */ #endif
Add C implementation for problem 2
#include <stdio.h> int main(int argc, char *argv[]){ int s, a, b, c; s = 0; a = 1; b = 1; c = a + b; while(c < 4000000L){ s += c; a = b + c; b = a + c; c = a + b; } printf("%d\n", s); }
Correct the allowed size of the uuid code
#ifndef hcidumpinternal_H #define hcidumpinternal_H #include <stdbool.h> #include <stdint.h> typedef struct beacon_info { char uuid[20]; int32_t code; int32_t manufacturer; int32_t major; int32_t minor; int32_t power; int32_t calibrated_power; int32_t rssi; int64_t time; } beacon_info; // The callback function invoked for each beacon event seen by hcidumpinternal // const char * uuid, int32_t code, int32_t manufacturer, int32_t major, int32_t minor, int32_t power, int32_t rssi, int64_t time typedef bool (*beacon_event)(const beacon_info *); // The function hcidumpinternal exports int32_t scan_frames(int32_t dev, beacon_event callback); #endif
#ifndef hcidumpinternal_H #define hcidumpinternal_H #include <stdbool.h> #include <stdint.h> typedef struct beacon_info { char uuid[36]; int32_t code; int32_t manufacturer; int32_t major; int32_t minor; int32_t power; int32_t calibrated_power; int32_t rssi; int64_t time; } beacon_info; // The callback function invoked for each beacon event seen by hcidumpinternal // const char * uuid, int32_t code, int32_t manufacturer, int32_t major, int32_t minor, int32_t power, int32_t rssi, int64_t time typedef bool (*beacon_event)(const beacon_info *); // The function hcidumpinternal exports int32_t scan_frames(int32_t dev, beacon_event callback); #endif
Fix find&replace error in CornerCombinerBase codec
#pragma once #include <spotify/json.hpp> #include <noise/noise.h> #include "noise/module/Wrapper.h" #include "noise/module/CornerCombinerBase.h" namespace spotify { namespace json { template<> struct default_codec_t<noise::module::Wrapper<noise::module::CornerCombinerBase>> { using CornerCombinerBaseWrapper = noise::module::Wrapper<noise::module::CornerCombinerBase>; static codec::object_t<CornerCombinerBaseWrapper> codec() { auto codec = codec::object<CornerCombinerBaseWrapper>(); codec.required("type", codec::eq<std::string>("CornerCombinerBase")); codec.optional("Power", [](CornerCombinerBase CornerCombinerBaseWrapper& mw) {return mw.module.GetPower(); }, [](CornerCombinerBaseWrapper& mw, double power) {mw.module.SetPower(power); }); return codec; } }; } }
#pragma once #include <spotify/json.hpp> #include <noise/noise.h> #include "noise/module/Wrapper.h" #include "noise/module/CornerCombinerBase.h" namespace spotify { namespace json { template<> struct default_codec_t<noise::module::Wrapper<noise::module::CornerCombinerBase>> { using CornerCombinerBaseWrapper = noise::module::Wrapper<noise::module::CornerCombinerBase>; static codec::object_t<CornerCombinerBaseWrapper> codec() { auto codec = codec::object<CornerCombinerBaseWrapper>(); codec.required("type", codec::eq<std::string>("CornerCombinerBase")); codec.optional("Power", [](const CornerCombinerBaseWrapper& mw) {return mw.module.GetPower(); }, [](CornerCombinerBaseWrapper& mw, double power) {mw.module.SetPower(power); }); return codec; } }; } }
Allow overrideSettings to take a nil value.
/* Copyright 2012 Moblico Solutions LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or 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 <MoblicoSDK/MLCService.h> @class MLCSettings; NS_ASSUME_NONNULL_BEGIN typedef void(^MLCSettingsServiceCompletionHandler)(id _Nullable MLCSettings, NSError * _Nullable error, NSHTTPURLResponse * _Nullable response); @interface MLCSettingsService : MLCService + (instancetype)readSettings:(MLCSettingsServiceCompletionHandler)handler; + (MLCSettings *)settings; + (void)overrideSettings:(NSDictionary *)settings; @end @interface MLCSettings : NSObject - (nullable id)objectForKey:(NSString *)key; - (nullable id)objectForKeyedSubscript:(NSString *)key; @end NS_ASSUME_NONNULL_END
/* Copyright 2012 Moblico Solutions LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or 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 <MoblicoSDK/MLCService.h> @class MLCSettings; NS_ASSUME_NONNULL_BEGIN typedef void(^MLCSettingsServiceCompletionHandler)(id _Nullable MLCSettings, NSError * _Nullable error, NSHTTPURLResponse * _Nullable response); @interface MLCSettingsService : MLCService + (instancetype)readSettings:(MLCSettingsServiceCompletionHandler)handler; + (MLCSettings *)settings; + (void)overrideSettings:(nullable NSDictionary *)settings; @end @interface MLCSettings : NSObject - (nullable id)objectForKey:(NSString *)key; - (nullable id)objectForKeyedSubscript:(NSString *)key; @end NS_ASSUME_NONNULL_END
Remove the import for EKNDeskTopViewController.h
// // EKNAppDelegate.h // EdKeyNote // // Created by canviz on 9/22/14. // Copyright (c) 2014 canviz. All rights reserved. // #import <UIKit/UIKit.h> #import "EKNDeskTopViewController.h" #import "EKNLoginViewController.h" @interface EKNAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) EKNLoginViewController *viewController; @property (strong, nonatomic) UINavigationController *naviController; @end
// // EKNAppDelegate.h // EdKeyNote // // Created by canviz on 9/22/14. // Copyright (c) 2014 canviz. All rights reserved. // #import <UIKit/UIKit.h> #import "EKNLoginViewController.h" @interface EKNAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) EKNLoginViewController *viewController; @property (strong, nonatomic) UINavigationController *naviController; @end
Define USE_GUSI if USE_GUSI1 or USE_GUSI2 is defined.
/* ** Config file for dynamically-loaded ppc/cfm68k plugin modules. */ /* #define USE_GUSI1 /* Stdio implemented with GUSI */ #define USE_GUSI2 /* Stdio implemented with GUSI */ #define WITH_THREAD /* Use thread support (needs GUSI 2, not GUSI 1) */ #define USE_MSL /* Use MSL libraries */ #ifdef USE_MSL #define MSL_USE_PRECOMPILED_HEADERS 0 /* Don't use precomp headers: we include our own */ #include <ansi_prefix.mac.h> #endif
/* ** Config file for dynamically-loaded ppc/cfm68k plugin modules. */ /* #define USE_GUSI1 /* Stdio implemented with GUSI */ #define USE_GUSI2 /* Stdio implemented with GUSI */ #if defined(USE_GUSI1) || defined(USE_GUSI2) #define USE_GUSI #endif #define WITH_THREAD /* Use thread support (needs GUSI 2, not GUSI 1) */ #define USE_MSL /* Use MSL libraries */ #ifdef USE_MSL #define MSL_USE_PRECOMPILED_HEADERS 0 /* Don't use precomp headers: we include our own */ #include <ansi_prefix.mac.h> #endif
Fix comments: these are not trailing comments
//===---- CodeCompleteOptions.h - Code Completion Options -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H #define LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H /// Options controlling the behavior of code completion. class CodeCompleteOptions { public: ///< Show macros in code completion results. unsigned IncludeMacros : 1; ///< Show code patterns in code completion results. unsigned IncludeCodePatterns : 1; ///< Show top-level decls in code completion results. unsigned IncludeGlobals : 1; ///< Show brief documentation comments in code completion results. unsigned IncludeBriefComments : 1; CodeCompleteOptions() : IncludeMacros(0), IncludeCodePatterns(0), IncludeGlobals(1), IncludeBriefComments(0) { } }; #endif
//===---- CodeCompleteOptions.h - Code Completion Options -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H #define LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H /// Options controlling the behavior of code completion. class CodeCompleteOptions { public: /// Show macros in code completion results. unsigned IncludeMacros : 1; /// Show code patterns in code completion results. unsigned IncludeCodePatterns : 1; /// Show top-level decls in code completion results. unsigned IncludeGlobals : 1; /// Show brief documentation comments in code completion results. unsigned IncludeBriefComments : 1; CodeCompleteOptions() : IncludeMacros(0), IncludeCodePatterns(0), IncludeGlobals(1), IncludeBriefComments(0) { } }; #endif
Change include to fix compilation.
#pragma once #include <gsl/gsl_byte> #include <gsl/span> namespace Halley { class IMessage { public: virtual ~IMessage() {} virtual size_t getSerializedSize() = 0; virtual void serializeTo(gsl::span<gsl::byte> dst) = 0; }; }
#pragma once #include <gsl/gsl> namespace Halley { class IMessage { public: virtual ~IMessage() {} virtual size_t getSerializedSize() = 0; virtual void serializeTo(gsl::span<gsl::byte> dst) = 0; }; }
Add accessor function prototypes for reoptimizer support passes. Make accessors return FunctionPass* as appropriate.
//===- Transforms/Instrumentation.h - Instrumentation passes ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This files defines constructor functions for instrumentation passes. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H #define LLVM_TRANSFORMS_INSTRUMENTATION_H namespace llvm { class Pass; //===----------------------------------------------------------------------===// // Support for inserting LLVM code to print values at basic block and function // exits. // Pass *createTraceValuesPassForFunction(); // Just trace function entry/exit Pass *createTraceValuesPassForBasicBlocks(); // Trace BB's and methods } // End llvm namespace #endif
//===- Transforms/Instrumentation.h - Instrumentation passes ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This files defines constructor functions for instrumentation passes. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H #define LLVM_TRANSFORMS_INSTRUMENTATION_H namespace llvm { class ModulePass; class FunctionPass; // Reoptimizer support pass: add instrumentation calls to back-edges of loops ModulePass *createLoopInstrumentationPass (); // Reoptimizer support pass: combine multiple back-edges w/ same target into one FunctionPass *createCombineBranchesPass(); // Reoptimizer support pass: emit table of global functions FunctionPass *createEmitFunctionTablePass (); //===----------------------------------------------------------------------===// // Support for inserting LLVM code to print values at basic block and function // exits. // // Just trace function entry/exit FunctionPass *createTraceValuesPassForBasicBlocks(); // Trace BB's and methods FunctionPass *createTraceValuesPassForFunction(); } // End llvm namespace #endif
Update Feather RP2040 to 8MB
#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040" #define MICROPY_HW_MCU_NAME "rp2040" #define MICROPY_HW_NEOPIXEL (&pin_GPIO16) #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) #define DEFAULT_SPI_BUS_SCK (&pin_GPIO18) #define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19) #define DEFAULT_SPI_BUS_MISO (&pin_GPIO20) // #define DEFAULT_UART_BUS_RX (&pin_PA11) // #define DEFAULT_UART_BUS_TX (&pin_PA10) // Flash chip is GD25Q32 connected over QSPI #define TOTAL_FLASH_SIZE (4 * 1024 * 1024)
#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040" #define MICROPY_HW_MCU_NAME "rp2040" #define MICROPY_HW_NEOPIXEL (&pin_GPIO16) #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) #define DEFAULT_SPI_BUS_SCK (&pin_GPIO18) #define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19) #define DEFAULT_SPI_BUS_MISO (&pin_GPIO20) // #define DEFAULT_UART_BUS_RX (&pin_PA11) // #define DEFAULT_UART_BUS_TX (&pin_PA10) // Flash chip is GD25Q64 connected over QSPI #define TOTAL_FLASH_SIZE (8 * 1024 * 1024)
Add brackets around SERIAL_ERROR definition for compatibility
#ifndef _SERIAL_H_ #define _SERIAL_H_ #include "hardware/packet.h" #define SERIAL_SUCCESS 1 #define SERIAL_ERROR !SERIAL_SUCCESS unsigned int serial_connect(char device[]); unsigned int serial_transmit(struct Packet packet); unsigned int serial_close(); #endif
#ifndef _SERIAL_H_ #define _SERIAL_H_ #include "hardware/packet.h" #define SERIAL_SUCCESS 1 #define SERIAL_ERROR (!SERIAL_SUCCESS) unsigned int serial_connect(char device[]); unsigned int serial_transmit(struct Packet packet); unsigned int serial_close(); #endif
Add FreeBSD as platform supporting malloc_usable_size
#ifndef PECTOR_MALLOC_ALLOCATOR_COMPAT_H #define PECTOR_MALLOC_ALLOCATOR_COMPAT_H #ifdef __APPLE__ #include <malloc/malloc.h> #else #include <malloc.h> #endif #if defined __GNUC__ || defined _WIN32 || defined __APPLE__ #define PT_SIZE_AWARE_COMPAT #if defined __GNUC__ && !defined _WIN32 && !defined __APPLE__ #define PT_MALLOC_USABLE_SIZE(p) malloc_usable_size(p) #elif defined _WIN32 #define PT_MALLOC_USABLE_SIZE(p) _msize(p) #elif defined __APPLE__ #define PTçMALLOC_USABLE_SIZE(p) malloc_size(p) #endif #endif // defined __GNUC__ || defined _WIN32 || defined __APPLE__ #endif
#ifndef PECTOR_MALLOC_ALLOCATOR_COMPAT_H #define PECTOR_MALLOC_ALLOCATOR_COMPAT_H #ifdef __APPLE__ #include <malloc/malloc.h> #else #include <malloc.h> #endif #if defined __GNUC__ || defined _WIN32 || defined __APPLE__ || defined __FreeBSD__ #define PT_SIZE_AWARE_COMPAT #if defined _WIN32 #define PT_MALLOC_USABLE_SIZE(p) _msize(p) #elif defined __APPLE__ #define PT_MALLOC_USABLE_SIZE(p) malloc_size(p) #elif defined __GNUC__ || defined __FreeBSD__ #define PT_MALLOC_USABLE_SIZE(p) malloc_usable_size(p) #endif #endif // defined __GNUC__ || defined _WIN32 || defined __APPLE__ #endif
Add new functions to header
/****************************** * AUTHOR : GUSTAVO MARTINS * USE AS YOU WISH * DATE : 11/25/2015 * LANG : ANSI C * DESCR : A VERY SIMPLE * 3D VECTOR LIBRARY ******************************/ #ifndef TVECTOR_H #define TVECTOR_H typedef struct SVector *TVector; TVector createVector(double x, double y, double z); TVector createNullVector(); void freeVector(TVector vec); double getX(TVector vec); double getY(TVector vec); double getZ(TVector vec); void setX(TVector vec, double x); void setY(TVector vec, double y); void setZ(TVector vec, double z); double getLength(TVector vec); void normalizeVector(TVector vec); double doDotProduct(TVector vecA, TVector vecB, double angle); TVector doScalarProduct(TVector vec, double scalar); TVector doCrossProduct(TVector vecA, TVector vecB); TVector doNormalize(TVector vec); TVector createCopyVector(TVector vec); #endif
/****************************** * AUTHOR : GUSTAVO MARTINS * USE AS YOU WISH * DATE : 11/25/2015 * LANG : ANSI C * DESCR : A VERY SIMPLE * 3D VECTOR LIBRARY ******************************/ #ifndef TVECTOR_H #define TVECTOR_H typedef struct SVector *TVector; TVector createVector(double x, double y, double z); TVector createNullVector(); void freeVector(TVector vec); double getX(TVector vec); double getY(TVector vec); double getZ(TVector vec); void setX(TVector vec, double x); void setY(TVector vec, double y); void setZ(TVector vec, double z); double getLength(TVector vec); void normalizeVector(TVector vec); double doDotProduct(TVector vecA, TVector vecB, double angle); TVector doScalarProduct(TVector vec, double scalar); TVector doCrossProduct(TVector vecA, TVector vecB); TVector doSum(TVector vecA, TVector vecB); TVector doSub(TVector vecA, TVector vecB); TVector doNormalize(TVector vec); TVector createCopyVector(TVector vec); #endif
Include use case of epsilon
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "suspect.h" suspect_context("Euler's Method", suspect_test("Predicts y_{n+1} to within the expected threshhold", suspect_assert("Expected 1 < 0", -1 < 0); ) suspect_test("Does not explode", suspect_assert("Expected -1 < 0", -1 < 0); ) suspect_test("Knows about Tony", suspect_assert("Tony is a dork", 2 < 1); ) )
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "suspect.h" suspect_context("Euler's Method", suspect_test("Expect actual to be within epsilon of target", float actual = 5.426; float epsilon = 0.01; float target = 5.00; suspect_epsilon(actual,epsilon,target); ) suspect_test("Does not explode", suspect_assert("Expected -1 < 0", -1 < 0); ) suspect_test("Knows about Tony", suspect_assert("Tony is a dork", 2 < 1); ) )
Update ch1/ex3 v2 exercise with more readable code
#include <stdio.h> float K_5_BY_9 = 5.0 / 9.0; float K_32 = 32; int main(void) { float fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; printf("|-----------|\n"); printf("|%4s|%6s|\n", "F", "C"); printf("|-----------|\n"); fahr = lower; while (fahr <= upper) { celsius = K_5_BY_9 * (fahr - K_32); printf("|%4.0f|%6.1f|\n", fahr, celsius); fahr = fahr + step; } printf("|-----------|\n"); return 0; }
#include <stdio.h> float K_5_BY_9 = 5.0 / 9.0; float K_32 = 32; int SUCCESS = 0; int main(void) { float fahrenheit, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; printf("|-----------|\n"); printf("|%4s|%6s|\n", "F", "C"); printf("|-----------|\n"); fahrenheit = lower; while (fahrenheit <= upper) { celsius = K_5_BY_9 * (fahrenheit - K_32); printf("|%4.0f|%6.1f|\n", fahrenheit, celsius); fahrenheit = fahrenheit + step; } printf("|-----------|\n"); return SUCCESS; }
Fix descriptive comment at top of file.
/* node.h : interface to node functions, private to libsvn_fs * * ==================================================================== * Copyright (c) 2000 CollabNet. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * ==================================================================== */ #ifndef SVN_LIBSVN_FS_TXN_H #define SVN_LIBSVN_FS_TXN_H /* Create a new `transactions' table for the new filesystem FS. FS->env must already be open; this sets FS->nodes. */ svn_error_t *svn_fs__create_transactions (svn_fs_t *fs); /* Open the existing `transactions' table for the filesystem FS. FS->env must already be open; this sets FS->nodes. */ svn_error_t *svn_fs__open_transactions (svn_fs_t *fs); /* Return a pointer to the ID of TXN. The return value is live for as long as TXN is. */ char *svn_fs__txn_id (svn_fs_txn_t *txn); #endif /* SVN_LIBSVN_FS_TXN_H */ /* * local variables: * eval: (load-file "../svn-dev.el") * end: */
/* txn.h : interface to Subversion transactions, private to libsvn_fs * * ==================================================================== * Copyright (c) 2000 CollabNet. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * ==================================================================== */ #ifndef SVN_LIBSVN_FS_TXN_H #define SVN_LIBSVN_FS_TXN_H /* Create a new `transactions' table for the new filesystem FS. FS->env must already be open; this sets FS->nodes. */ svn_error_t *svn_fs__create_transactions (svn_fs_t *fs); /* Open the existing `transactions' table for the filesystem FS. FS->env must already be open; this sets FS->nodes. */ svn_error_t *svn_fs__open_transactions (svn_fs_t *fs); /* Return a pointer to the ID of TXN. The return value is live for as long as TXN is. */ char *svn_fs__txn_id (svn_fs_txn_t *txn); #endif /* SVN_LIBSVN_FS_TXN_H */ /* * local variables: * eval: (load-file "../svn-dev.el") * end: */
Add user data to Game struct
/* * Copyright (C) 2015 Luke San Antonio * All rights reserved. */ #pragma once #include "../common/id_map.hpp" #include "boat.h" #include "../collisionlib/motion.h" namespace redc { namespace sail { struct Player { std::string name; bool spawned; Hull_Desc boat_config; collis::Motion boat_motion; }; struct Game { ID_Map<Player> players; }; } }
/* * Copyright (C) 2015 Luke San Antonio * All rights reserved. */ #pragma once #include "../common/id_map.hpp" #include "boat.h" #include "../collisionlib/motion.h" namespace redc { namespace sail { struct Player { std::string name; bool spawned; Hull_Desc boat_config; collis::Motion boat_motion; void* userdata; }; struct Game { ID_Map<Player> players; }; } }
Fix declaration of alloc function.
/* $Id$ */ #include "ruby_libxml.h" VALUE cXMLState; VALUE LIBXML_STATE = Qnil; static int dummy = 0; void ruby_xml_state_free(int dummy) { xmlCleanupParser(); LIBXML_STATE = Qnil; } VALUE ruby_xml_state_alloc() { #ifdef DEBUG fprintf(stderr, "Allocating state"); #endif xmlInitParser(); return Data_Wrap_Struct(cXMLState, NULL, ruby_xml_state_free, &dummy); } // Rdoc needs to know #ifdef RDOC_NEVER_DEFINED mXML = rb_define_module("XML"); #endif void ruby_init_state(void) { VALUE rb_mSingleton; cXMLState = rb_define_class_under(mXML, "State", rb_cObject); /* Mixin singleton so only one xml state object can be created. */ rb_require("singleton"); rb_mSingleton = rb_const_get(rb_cObject, rb_intern("Singleton")); rb_include_module(cXMLState, rb_mSingleton); rb_define_alloc_func(cXMLState, ruby_xml_state_alloc); /* Create one instance of the state object that is used to initalize and cleanup libxml. Then register it with the garbage collector so its not freed until the process exists.*/ LIBXML_STATE = rb_class_new_instance(0, NULL, cXMLState); rb_global_variable(&LIBXML_STATE); }
/* $Id$ */ #include "ruby_libxml.h" VALUE cXMLState; VALUE LIBXML_STATE = Qnil; static int dummy = 0; void ruby_xml_state_free(int dummy) { xmlCleanupParser(); LIBXML_STATE = Qnil; } VALUE ruby_xml_state_alloc(VALUE klass) { #ifdef DEBUG fprintf(stderr, "Allocating state"); #endif xmlInitParser(); return Data_Wrap_Struct(cXMLState, NULL, ruby_xml_state_free, &dummy); } // Rdoc needs to know #ifdef RDOC_NEVER_DEFINED mXML = rb_define_module("XML"); #endif void ruby_init_state(void) { VALUE rb_mSingleton; cXMLState = rb_define_class_under(mXML, "State", rb_cObject); /* Mixin singleton so only one xml state object can be created. */ rb_require("singleton"); rb_mSingleton = rb_const_get(rb_cObject, rb_intern("Singleton")); rb_include_module(cXMLState, rb_mSingleton); rb_define_alloc_func(cXMLState, ruby_xml_state_alloc); /* Create one instance of the state object that is used to initalize and cleanup libxml. Then register it with the garbage collector so its not freed until the process exists.*/ LIBXML_STATE = rb_class_new_instance(0, NULL, cXMLState); rb_global_variable(&LIBXML_STATE); }
Create a constructor and deconstructor for the peer structure.
#include <miknet/miknet.h> int mikpeer (miknode_t *n) { int sock, i, pos = 0; struct sockaddr_storage addr; socklen_t addrlen; sock = accept(n->tcp, (struct sockaddr *)&addr, &addrlen); if (sock < 0) return mik_debug(ERR_SOCKET); if (n->peerc >= n->peermax) { close(sock); return ERR_PEER_MAX; } n->peerc++; for (i = 0; i < n->peermax; ++i) { if (n->peers[i].state == MIK_DISC) { pos = i; break; } } n->peers[pos].state = MIK_CONN; n->peers[pos].tcp = sock; n->peers[pos].addr = addr; n->peers[pos].addrlen = addrlen; n->peers[pos].sent = 0; n->peers[pos].recvd = 0; return 0; } int mikpeer_close (mikpeer_t *p) { close(p->tcp); memset(&p->addr, 0, sizeof(struct sockaddr_storage)); p->state = MIK_DISC; p->tcp = 0; p->addrlen = 0; p->sent = 0; p->recvd = 0; return 0; }
Add color for error log
#pragma once #include <cstdio> namespace happyntrain { #define LOG(message, level, ...) \ printf("[" level "] %s-%d " message "\n", __FILE__, __LINE__, ##__VA_ARGS__); #define INFO(message, ...) LOG(message, "INFO", ##__VA_ARGS__); #define DEBUG(message, ...) LOG(message, "DEBUG", ##__VA_ARGS__); #define ERROR(message, ...) LOG(message, "ERROR", ##__VA_ARGS__); // end happyntrain }
#pragma once #include <cstdio> namespace happyntrain { #define LOG(message, level, ...) \ printf("[%5s] %s-%d " message "\n", level, __FILENAME__, __LINE__, \ ##__VA_ARGS__); #define INFO(message, ...) LOG(message, "INFO", ##__VA_ARGS__); #define DEBUG(message, ...) LOG(message, "DEBUG", ##__VA_ARGS__); #define ERROR(message, ...) \ LOG("\x1b[31m" message "\x1b[0m", "ERROR", ##__VA_ARGS__); // end happyntrain }
Check the client_setup() return value
#include <stdio.h> #include <stdlib.h> #include <wayland-client.h> #include <time.h> #include "client.h" #include "log.h" struct client_state *state; void sway_terminate(void) { client_teardown(state); exit(1); } int main(int argc, char **argv) { init_log(L_INFO); state = client_setup(); uint8_t r = 0, g = 0, b = 0; long last_ms = 0; int rs; do { struct timespec spec; clock_gettime(CLOCK_MONOTONIC, &spec); long ms = round(spec.tv_nsec / 1.0e6); cairo_set_source_rgb(state->cairo, r, g, b); cairo_rectangle(state->cairo, 0, 0, 100, 100); cairo_fill(state->cairo); rs = client_render(state); if (ms - last_ms > 100) { r++; if (r == 0) { g++; if (g == 0) { b++; } } ms = last_ms; } } while (rs); client_teardown(state); return 0; }
#include <stdio.h> #include <stdlib.h> #include <wayland-client.h> #include <time.h> #include "client.h" #include "log.h" struct client_state *state; void sway_terminate(void) { client_teardown(state); exit(1); } int main(int argc, char **argv) { init_log(L_INFO); if (!(state = client_setup())) { return -1; } uint8_t r = 0, g = 0, b = 0; long last_ms = 0; int rs; do { struct timespec spec; clock_gettime(CLOCK_MONOTONIC, &spec); long ms = round(spec.tv_nsec / 1.0e6); cairo_set_source_rgb(state->cairo, r, g, b); cairo_rectangle(state->cairo, 0, 0, 100, 100); cairo_fill(state->cairo); rs = client_render(state); if (ms - last_ms > 100) { r++; if (r == 0) { g++; if (g == 0) { b++; } } ms = last_ms; } } while (rs); client_teardown(state); return 0; }
Use QGst::init/cleanup in the tests to properly register the ValueVTables for the gstreamer types.
/* Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com> 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 program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef QGSTTEST_H #define QGSTTEST_H #include <QtTest/QtTest> #include <gst/gst.h> class QGstTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase() { gst_init(NULL, NULL); } void cleanupTestCase() { gst_deinit(); } }; #endif
/* Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com> 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 program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef QGSTTEST_H #define QGSTTEST_H #include <QtTest/QtTest> #include <QGst/Global> #include <gst/gst.h> class QGstTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase() { QGst::init(); } void cleanupTestCase() { QGst::cleanup(); } }; #endif
Make sure none of the __asan_gen_ global strings end up in the symbol table, add a test.
// Make sure __asan_gen_* strings do not end up in the symbol table. // RUN: %clang_asan %s -o %t.exe // RUN: nm %t.exe | grep __asan_gen_ || exit 0 int x, y, z; int main() { return 0; }
Add solution for problem 1
/* * Multiples of 3 and 5 * * If we list all the natural numbers below 10 that are multiples of 3 or 5, * we get 3, 5, 6 and 9. The sum of these multiples is 23. * * Find the sum of all the multiples of 3 or 5 below 1000 */ #include <stdio.h> int main(void) { int sum = 0, i = 0; while (i < 1000) { if (i % 3 == 0 || i % 5 == 0) sum += i; i++; } printf("%i\n", sum); return 0; }
Change some char type variables to unsigned char
/* * OLSRd Quagga plugin * * Copyright (C) 2006-2008 Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de> * Copyright (C) 2007-2010 Vasilis Tsiligiannis <acinonyxs@yahoo.gr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation or - at your option - under * the terms of the GNU General Public Licence version 2 but can be * linked to any BSD-Licenced Software with public available sourcecode * */ /* ------------------------------------------------------------------------- * File : common.h * Description : common header file * ------------------------------------------------------------------------- */ #define OPTION_EXPORT 1 /* Zebra route types */ #define ZEBRA_ROUTE_OLSR 11 #define ZEBRA_ROUTE_MAX 13 struct zebra { char status; // internal status char options; // internal options int sock; // Socket to zebra... char redistribute[ZEBRA_ROUTE_MAX]; char distance; char flags; char *sockpath; unsigned int port; char version; }; extern struct zebra zebra; /* * Local Variables: * c-basic-offset: 2 * indent-tabs-mode: nil * End: */
/* * OLSRd Quagga plugin * * Copyright (C) 2006-2008 Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de> * Copyright (C) 2007-2010 Vasilis Tsiligiannis <acinonyxs@yahoo.gr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation or - at your option - under * the terms of the GNU General Public Licence version 2 but can be * linked to any BSD-Licenced Software with public available sourcecode * */ /* ------------------------------------------------------------------------- * File : common.h * Description : common header file * ------------------------------------------------------------------------- */ #define OPTION_EXPORT 1 /* Zebra route types */ #define ZEBRA_ROUTE_OLSR 11 #define ZEBRA_ROUTE_MAX 13 struct zebra { unsigned char status; unsigned char options; int sock; unsigned char redistribute[ZEBRA_ROUTE_MAX]; unsigned char distance; unsigned char flags; char *sockpath; unsigned int port; unsigned char version; }; extern struct zebra zebra; /* * Local Variables: * c-basic-offset: 2 * indent-tabs-mode: nil * End: */
Add address property to object
// // GeocodeItem.h // bikepath // // Created by Farheen Malik on 8/19/14. // Copyright (c) 2014 Bike Path. All rights reserved. // #import <Foundation/Foundation.h> @interface GeocodeItem : NSObject @end
// // GeocodeItem.h // bikepath // // Created by Farheen Malik on 8/19/14. // Copyright (c) 2014 Bike Path. All rights reserved. // #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> #import <GoogleMaps/GoogleMaps.h> @interface GeocodeItem : NSObject @property NSString *latitude; @property NSString *longitude; @property CLLocation *position; @property NSString *address; @property (readonly) NSDate *creationDate; @end
Include the necessary headers to make the swift-runtime-reporting test work.
// library.h // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // // ----------------------------------------------------------------------------- // From swift's include/swift/Runtime/Debug.h file. struct RuntimeErrorDetails { uintptr_t version; const char *errorType; const char *currentStackDescription; uintptr_t framesToSkip; void *memoryAddress; struct Thread { const char *description; uint64_t threadID; uintptr_t numFrames; void **frames; }; uintptr_t numExtraThreads; Thread *threads; struct FixIt { const char *filename; uintptr_t startLine; uintptr_t startColumn; uintptr_t endLine; uintptr_t endColumn; const char *replacementText; }; struct Note { const char *description; uintptr_t numFixIts; FixIt *fixIts; }; uintptr_t numFixIts; FixIt *fixIts; uintptr_t numNotes; Note *notes; }; enum: uintptr_t { RuntimeErrorFlagNone = 0, RuntimeErrorFlagFatal = 1 << 0 }; extern "C" void _swift_runtime_on_report(uintptr_t flags, const char *message, RuntimeErrorDetails *details);
// library.h // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // // ----------------------------------------------------------------------------- #include <stdint.h> // From swift's include/swift/Runtime/Debug.h file. struct RuntimeErrorDetails { uintptr_t version; const char *errorType; const char *currentStackDescription; uintptr_t framesToSkip; void *memoryAddress; struct Thread { const char *description; uint64_t threadID; uintptr_t numFrames; void **frames; }; uintptr_t numExtraThreads; Thread *threads; struct FixIt { const char *filename; uintptr_t startLine; uintptr_t startColumn; uintptr_t endLine; uintptr_t endColumn; const char *replacementText; }; struct Note { const char *description; uintptr_t numFixIts; FixIt *fixIts; }; uintptr_t numFixIts; FixIt *fixIts; uintptr_t numNotes; Note *notes; }; enum: uintptr_t { RuntimeErrorFlagNone = 0, RuntimeErrorFlagFatal = 1 << 0 }; extern "C" void _swift_runtime_on_report(uintptr_t flags, const char *message, RuntimeErrorDetails *details);
Add a temporary dummy header file to make an internal refactoring process go more smoothly.
// This is a placeholder to allow include-path compatibility with code written // inside Google. #ifndef STRINGS_STRINGPIECE_UTILS_H_ #define STRINGS_STRINGPIECE_UTILS_H_ #endif // STRINGS_STRINGPIECE_UTILS_H_
Fix the call trace when resumed from hibernation
/* * Common powerpc suspend code for 32 and 64 bits * * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include <linux/sched.h> #include <asm/system.h> #include <asm/current.h> #include <asm/mmu_context.h> void save_processor_state(void) { /* * flush out all the special registers so we don't need * to save them in the snapshot */ flush_fp_to_thread(current); flush_altivec_to_thread(current); flush_spe_to_thread(current); #ifdef CONFIG_PPC64 hard_irq_disable(); #endif } void restore_processor_state(void) { #ifdef CONFIG_PPC32 switch_mmu_context(NULL, current->active_mm); #endif }
/* * Common powerpc suspend code for 32 and 64 bits * * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include <linux/sched.h> #include <asm/system.h> #include <asm/current.h> #include <asm/mmu_context.h> void save_processor_state(void) { /* * flush out all the special registers so we don't need * to save them in the snapshot */ flush_fp_to_thread(current); flush_altivec_to_thread(current); flush_spe_to_thread(current); #ifdef CONFIG_PPC64 hard_irq_disable(); #endif } void restore_processor_state(void) { #ifdef CONFIG_PPC32 switch_mmu_context(current->active_mm, current->active_mm); #endif }
Add missing include for make_unique
/* Copyright 2016 Streampunk Media Ltd. 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 PERSIST_H #define PERSIST_H namespace streampunk { class Persist { public: static std::unique_ptr<Persist> makeNew(Local<Object> object) { return std::make_unique<Persist>(object); } Persist(Local<Object> object) : mPersistObj(object) {} ~Persist() { mPersistObj.Reset(); } private: Nan::Persistent<Object> mPersistObj; }; } // namespace streampunk #endif
/* Copyright 2016 Streampunk Media Ltd. 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 PERSIST_H #define PERSIST_H #include <memory> namespace streampunk { class Persist { public: static std::unique_ptr<Persist> makeNew(Local<Object> object) { return std::make_unique<Persist>(object); } Persist(Local<Object> object) : mPersistObj(object) {} ~Persist() { mPersistObj.Reset(); } private: Nan::Persistent<Object> mPersistObj; }; } // namespace streampunk #endif
Add list_iter for circular list test.
#include <stdio.h> #include <stdlib.h> #include <cl_list.h> #include <cl_iterator.h> #define QTD 100
#include <stdio.h> #include <stdlib.h> #include <cl_list.h> #include <cl_iterator.h> #define QTD 100 void print_list_iter(cl_list_root *list) { iterator_c *i = cl_iter_create(list, FORWARD); printf("["); if (i != NULL) { do { printf("'%d', ", *((int *) cl_iter_item(i))); } while (cl_iter_next(i) && cl_iter_is_item(i, list->head)); }; printf("]\n"); cl_iter_free(i); } int main() { return EXIT_SUCCESS; }
Add comment saying that even though the a.out file name is here, it really shouldn't be.
typedef struct { int cluster; /* Condor Cluster # */ int proc; /* Condor Proc # */ int job_class; /* STANDARD, VANILLA, PVM, PIPE, ... */ uid_t uid; /* Execute job under this UID */ gid_t gid; /* Execute job under this pid */ pid_t virt_pid; /* PVM virt pid of this process */ int soft_kill_sig; /* Use this signal for a soft kill */ char *a_out_name; /* Where to get executable file */ char *cmd; /* Command name given by the user */ char *args; /* Command arguments given by the user */ char *env; /* Environment variables */ char *iwd; /* Initial working directory */ BOOLEAN ckpt_wanted; /* Whether user wants checkpointing */ BOOLEAN is_restart; /* Whether this run is a restart */ BOOLEAN coredump_limit_exists; /* Whether user wants to limit core size */ int coredump_limit; /* Limit in bytes */ } STARTUP_INFO;
typedef struct { int cluster; /* Condor Cluster # */ int proc; /* Condor Proc # */ int job_class; /* STANDARD, VANILLA, PVM, PIPE, ... */ uid_t uid; /* Execute job under this UID */ gid_t gid; /* Execute job under this pid */ pid_t virt_pid; /* PVM virt pid of this process */ int soft_kill_sig; /* Use this signal for a soft kill */ char *a_out_name; /* Where to get executable file */ char *cmd; /* Command name given by the user */ char *args; /* Command arguments given by the user */ char *env; /* Environment variables */ char *iwd; /* Initial working directory */ BOOLEAN ckpt_wanted; /* Whether user wants checkpointing */ BOOLEAN is_restart; /* Whether this run is a restart */ BOOLEAN coredump_limit_exists; /* Whether user wants to limit core size */ int coredump_limit; /* Limit in bytes */ } STARTUP_INFO; /* Should eliminate starter knowing the a.out name. Should go to shadow for instructions on how to fetch the executable - e.g. local file with name <name> or get it from TCP port <x> on machine <y>. */
Update for station2: Initial version (I.Hrivnacova)
// $Id$ // Category: sector // // Enum AliMpStationType // --------------------- // Enumeration for refering to bending and non-bending planes. // // Authors: David Guez, Ivana Hrivnacova; IPN Orsay #ifndef ALI_MP_STATION_TYPE_H #define ALI_MP_STATION_TYPE_H enum AliMpStationType { kStation1, // station 1 kStation2, // station 2 }; #endif //ALI_MP_STATION_TYPE_H
Set removed item's prev/next pointers to NULL.
#ifndef LLIST_H #define LLIST_H /* Doubly linked list */ #define DLLIST_PREPEND(list, item) STMT_START { \ (item)->prev = NULL; \ (item)->next = *(list); \ if (*(list) != NULL) (*(list))->prev = (item); \ *(list) = (item); \ } STMT_END #define DLLIST_REMOVE(list, item) STMT_START { \ if ((item)->prev == NULL) \ *(list) = (item)->next; \ else \ (item)->prev->next = (item)->next; \ if ((item)->next != NULL) \ (item)->next->prev = (item)->prev; \ } STMT_END #endif
#ifndef LLIST_H #define LLIST_H /* Doubly linked list */ #define DLLIST_PREPEND(list, item) STMT_START { \ (item)->prev = NULL; \ (item)->next = *(list); \ if (*(list) != NULL) (*(list))->prev = (item); \ *(list) = (item); \ } STMT_END #define DLLIST_REMOVE(list, item) STMT_START { \ if ((item)->prev == NULL) \ *(list) = (item)->next; \ else \ (item)->prev->next = (item)->next; \ if ((item)->next != NULL) { \ (item)->next->prev = (item)->prev; \ (item)->next = NULL; \ } \ (item)->prev = NULL; \ } STMT_END #endif
Use _vscprintf() for mingw-w64 compilers
#include <stdarg.h> #include <stdio.h> #include <stdlib.h> int vasprintf(char **ret, const char *fmt, va_list ap) { char *buf; int len; size_t buflen; va_list ap2; #ifdef _MSC_VER ap2 = ap; len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( ) #else va_copy(ap2, ap); len = vsnprintf(NULL, 0, fmt, ap2); #endif if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) { len = vsnprintf(buf, buflen, fmt, ap); *ret = buf; } else { *ret = NULL; len = -1; } va_end(ap2); return len; }
#include <stdarg.h> #include <stdio.h> #include <stdlib.h> int vasprintf(char **ret, const char *fmt, va_list ap) { char *buf; int len; size_t buflen; va_list ap2; #if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR) ap2 = ap; len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( ) #else va_copy(ap2, ap); len = vsnprintf(NULL, 0, fmt, ap2); #endif if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) { len = vsnprintf(buf, buflen, fmt, ap); *ret = buf; } else { *ret = NULL; len = -1; } va_end(ap2); return len; }
Change to use IRequest instead (use interfaces for classes where possible)
// Copyright 2010-2015 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #pragma once #include "Stdafx.h" using namespace CefSharp; namespace CefSharp { namespace Internals { public ref class CefRequestCallbackWrapper : public IRequestCallback { private: MCefRefPtr<CefRequestCallback> _callback; CefRequestWrapper^ _requestWrapper; internal: CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback) : CefRequestCallbackWrapper(callback, nullptr) { } CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback, CefRequestWrapper^ requestWrapper) : _callback(callback), _requestWrapper(requestWrapper) { } !CefRequestCallbackWrapper() { _callback = NULL; } ~CefRequestCallbackWrapper() { this->!CefRequestCallbackWrapper(); if (_requestWrapper != nullptr) { delete _requestWrapper; } } public: virtual void Continue(bool allow) { _callback->Continue(allow); delete this; } virtual void Cancel() { _callback->Cancel(); delete this; } }; } }
// Copyright 2010-2015 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #pragma once #include "Stdafx.h" using namespace CefSharp; namespace CefSharp { namespace Internals { public ref class CefRequestCallbackWrapper : public IRequestCallback { private: MCefRefPtr<CefRequestCallback> _callback; IRequest^ _request; internal: CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback) : CefRequestCallbackWrapper(callback, nullptr) { } CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback, IRequest^ request) : _callback(callback), _request(request) { } !CefRequestCallbackWrapper() { _callback = NULL; } ~CefRequestCallbackWrapper() { this->!CefRequestCallbackWrapper(); if (_request != nullptr) { delete _request; } } public: virtual void Continue(bool allow) { _callback->Continue(allow); delete this; } virtual void Cancel() { _callback->Cancel(); delete this; } }; } }
Allow choice of D2D on compiler command line.
// Scintilla source code edit control /** @file PlatWin.h ** Implementation of platform facilities on Windows. **/ // Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. extern bool IsNT(); extern void Platform_Initialise(void *hInstance); extern void Platform_Finalise(); #if defined(_MSC_VER) extern bool LoadD2D(); extern ID2D1Factory *pD2DFactory; extern IDWriteFactory *pIDWriteFactory; #endif
// Scintilla source code edit control /** @file PlatWin.h ** Implementation of platform facilities on Windows. **/ // Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. extern bool IsNT(); extern void Platform_Initialise(void *hInstance); extern void Platform_Finalise(); #if defined(USE_D2D) extern bool LoadD2D(); extern ID2D1Factory *pD2DFactory; extern IDWriteFactory *pIDWriteFactory; #endif
Update comments of SecretConstant file
// // SecretConstant.example.h // PHPHub // // Created by Aufree on 9/30/15. // Copyright (c) 2015 ESTGroup. All rights reserved. // #if DEBUG #define Client_id @"kHOugsx4dmcXwvVbmLkd" #define Client_secret @"PuuFCrF94MloSbSkxpwS" #else #define Client_id @"Set up a client id for production env" #define Client_secret @"Set up a client secret for production env" #endif #define UMENG_APPKEY @"Set up UMEng App Key" #define UMENG_QQ_ID @"Set up qq id" #define UMENG_QQ_APPKEY @"Set up qq appkey" #define WX_APP_ID @"Set up weixin app id" #define WX_APP_SECRET @"Set up weixin app secret" #define TRACKING_ID @"Set up google anlytics tracking id"
// // SecretConstant.example.h // PHPHub // // Created by Aufree on 9/30/15. // Copyright (c) 2015 ESTGroup. All rights reserved. // #if DEBUG #define Client_id @"kHOugsx4dmcXwvVbmLkd" #define Client_secret @"PuuFCrF94MloSbSkxpwS" #else #define Client_id @"" // Set up a client id for production environment #define Client_secret @"" // Set up a client secret for production environment #endif #define UMENG_APPKEY @"" // Set up UMEng App Key #define UMENG_QQ_ID @"" // Set up QQ id #define UMENG_QQ_APPKEY @"" // Set up QQ appkey #define WX_APP_ID @"" // Set up wechat app id #define WX_APP_SECRET @"" // Set up wechat app secret #define JPush_APP_KEY @"" // Set up Jpush App Key #define TRACKING_ID @"" // Set up google anlytics tracking id
Create contents of .h file
#ifndef ANN_H #define ANN_H #endif
#ifndef ANN_H #define ANN_H #define INPUTS 3 #define HIDDEN 5 #define OUTPUTS 2 #define ROWS 5 typedef struct { double input[HIDDEN][INPUTS + 1]; double hidden[ROWS - 3][HIDDEN][HIDDEN + 1]; double output[OUTPUTS][HIDDEN + 1]; } Links; typedef struct { int input[INPUTS]; int hidden[ROWS - 2][HIDDEN]; int output[OUTPUTS]; } Neurons; typedef struct { Links weights; Links slopes; Neurons values; } ANN; void ann_create(ANN *ann) void ann_mutate(ANN *ann, double increment) void ann_calculate(ANN *ann, double increment) void ann_save(ANN *ann, char *filename) void ann_load(ANN *ann, char *filename) #endif
Allow user to choose if they want :)
#include <stdio.h> #include <stdlib.h> #include <string.h> #define STTY "/bin/stty " const char RAW[] = STTY "raw"; const char COOKED[] = STTY "cooked"; int main() { system(RAW); char str[] = "I AM AN IDIOT "; size_t len = strlen(str); while ( 1 ) { for ( size_t i = 0 ; i < len ; i++ ) { getchar(); printf("\b%c", str[i]); } system(COOKED); printf("\n"); system(RAW); } return 0; }
#include <stdio.h> #include <stdlib.h> #include <string.h> #define STTY "/bin/stty " const char RAW[] = STTY "raw"; const char COOKED[] = STTY "cooked"; const char default_str[] = "I AM AN IDIOT "; int main(int argc, char **argv) { system(RAW); const char *str; if ( argc == 2 ) str = argv[1]; else str = default_str; size_t len = strlen(str); while ( 1 ) { for ( size_t i = 0 ; i < len ; i++ ) { getchar(); printf("\b%c", str[i]); } system(COOKED); printf("\n"); system(RAW); } return 0; }
Add booting substate for message
// // TKDApp.h // Tokaido // // Created by Mucho Besos on 10/25/12. // Copyright (c) 2012 Tilde. All rights reserved. // #import <Cocoa/Cocoa.h> typedef enum : NSUInteger { TKDAppOff, TKDAppBooting, TKDAppOn, TKDAppShuttingDown } TKDAppState; @interface TKDApp : MTLModel @property (nonatomic, copy) NSString *appName; @property (nonatomic, copy) NSString *appDirectoryPath; @property (nonatomic, copy) NSString *appHostname; @property (nonatomic, copy) NSString *appIconPath; @property (nonatomic, assign) TKDAppState state; @property (nonatomic, assign) BOOL usesYAMLfile; /** This can be used to init an TKD app instance with a directory, provided the directory includes a Tokaido.yaml file with the following entries: app_name: App Name hostname: app.local app_icon: ./icon.png */ - (id)initWithTokaidoDirectory:(NSURL *)url; - (void)showInFinder; - (void)openInBrowser; - (void)serializeToYAML; @end
// // TKDApp.h // Tokaido // // Created by Mucho Besos on 10/25/12. // Copyright (c) 2012 Tilde. All rights reserved. // #import <Cocoa/Cocoa.h> typedef enum : NSUInteger { TKDAppOff, TKDAppBooting, TKDAppOn, TKDAppShuttingDown } TKDAppState; typedef enum : NSUInteger { TKDAppBundling, TKDAppBundleFailed, TKDAppStartingServer } TKDAppBootingSubstate; @interface TKDApp : MTLModel @property (nonatomic, copy) NSString *appName; @property (nonatomic, copy) NSString *appDirectoryPath; @property (nonatomic, copy) NSString *appHostname; @property (nonatomic, copy) NSString *appIconPath; @property (nonatomic, assign) TKDAppState state; @property (nonatomic, assign) TKDAppBootingSubstate bootingSubstate; @property (nonatomic, assign) BOOL usesYAMLfile; /** This can be used to init an TKD app instance with a directory, provided the directory includes a Tokaido.yaml file with the following entries: app_name: App Name hostname: app.local app_icon: ./icon.png */ - (id)initWithTokaidoDirectory:(NSURL *)url; - (void)showInFinder; - (void)openInBrowser; - (void)serializeToYAML; @end
Make pointer arithmetic warning go away
#include "coro.h" #include "stack.h" #include <assert.h> #include <stdlib.h> #include <string.h> coro *coro_spawn(coro *me, coro_func f, size_t ssize) { coro *c = (coro*)malloc(sizeof(coro)); assert(c != NULL); c->running = 0; c->base = malloc(ssize); assert(c->base != NULL); c->stack = c->base + ssize; memset(c->base, 0, ssize); makestack(&me->stack, &c->stack, f, c); return c; } coro *coro_init() { coro *me = (coro*)malloc(sizeof(coro)); me->running = 1; // We don't need to free this (it's just the main stack segment) // so ignore it. me->base = NULL; // This'll get overridden when we swapstacks out of here. me->stack = NULL; return me; } void destroy_coro(coro *c) { free(c->base); free(c); }
#include "coro.h" #include "stack.h" #include <assert.h> #include <stdlib.h> #include <string.h> coro *coro_spawn(coro *me, coro_func f, size_t ssize) { coro *c = (coro*)malloc(sizeof(coro)); assert(c != NULL); c->running = 0; c->base = malloc(ssize); assert(c->base != NULL); c->stack = (char*) c->base + ssize; memset(c->base, 0, ssize); makestack(&me->stack, &c->stack, f, c); return c; } coro *coro_init() { coro *me = (coro*)malloc(sizeof(coro)); me->running = 1; // We don't need to free this (it's just the main stack segment) // so ignore it. me->base = NULL; // This'll get overridden when we swapstacks out of here. me->stack = NULL; return me; } void destroy_coro(coro *c) { free(c->base); free(c); }
Mark some functions as pure
#ifndef SEQUENCE_H #define SEQUENCE_H #include "object.h" typedef enum IterType_ {ITERLIST, ITERVECTOR} IterType; typedef struct Iter_ { IterType type; union { struct { Object *node; bool first; } list; struct { Object *object; int index; } vec; } u; } Iter; bool object_isseq(Object *object); Iter seq_iter(Object *object); Object *iter_next(Iter *iter); int seq_len(Object *object); Object *seq_nth(Object *object, int n); #endif
#ifndef SEQUENCE_H #define SEQUENCE_H #include "object.h" typedef enum IterType_ {ITERLIST, ITERVECTOR} IterType; typedef struct Iter_ { IterType type; union { struct { Object *node; bool first; } list; struct { Object *object; int index; } vec; } u; } Iter; bool object_isseq(Object *object) __attribute__ ((pure)); Iter seq_iter(Object *object); Object *iter_next(Iter *iter); int seq_len(Object *object) __attribute__ ((pure)); Object *seq_nth(Object *object, int n) __attribute__ ((pure)); #endif
Include missing necessary include <set>
#pragma once #include <unistd.h> #include <iostream> #include <list> #include <map> #include <mutex> #include <unordered_map> #include <queue> #include <sstream> #include <thread> #include <tuple> #include <vector>
#pragma once #include <unistd.h> #include <iostream> #include <list> #include <map> #include <mutex> #include <unordered_map> #include <queue> #include <sstream> #include <set> #include <thread> #include <tuple> #include <vector>
Make the list of x64 processor names inclusive enough to compile the Alien plugin on 64-bit linux.
/* * 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
/* * 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|__x86_64|__x86_64__ # include "x64ia32abicc.c" #endif
Transpose the second matrix in the C reference for MatMul.
#include <stdlib.h> #include "MatMulC.h" void MatMulC(int rows, int len, double *a, double *b, double *c) { int i,j,k; for( i = 0; i < rows; i++ ) { for( j = 0; j < rows; j+=2 ) { double sum0 = 0.0; double sum1 = 0.0; for( k = 0; k < rows; k++ ) { sum0 += a[i*rows+k] * b[k*rows + j]; sum1 += a[i*rows+k] * b[k*rows + j + 1]; } c[i*rows + j] = sum0; c[i*rows + j+1] = sum1; } } }
#include <stdlib.h> #include "MatMulC.h" void MatMulC(int rows, int len, double *a, double *bin, double *c) { int i,j,k; double *b = malloc(len * sizeof(double)); // Transpose bin with result in b. for(int n = 0; n < len; n++ ) { b[n] = bin[rows * (n % rows) + (n / rows)]; } for( i = 0; i < rows; i++ ) { for( j = 0; j < rows; j+=2 ) { double sum0 = 0.0; double sum1 = 0.0; for( k = 0; k < rows; k++ ) { sum0 += a[i*rows+k] * b[j*rows + k]; sum1 += a[i*rows+k] * b[(j + 1)*rows + k]; } c[i*rows + j] = sum0; c[i*rows + j+1] = sum1; } } free(b); }
Add default value to id on constructor
#ifndef _LINEARLAYOUT_H_ #define _LINEARLAYOUT_H_ #include <Element.h> #include <Command.h> #define FW_VERTICAL 1 #define FW_HORIZONTAL 2 class LinearLayout : public Element { public: LinearLayout(int _direction, int _id) : Element(_id), direction(_direction) { } bool isA(const std::string & className) override { if (className == "LinearLayout") return true; return Element::isA(className); } protected: void create() override { Command c(Command::CREATE_LINEAR_LAYOUT, getParentInternalId(), getInternalId()); c.setValue(direction); sendCommand(c); } private: int direction = FW_VERTICAL; }; #endif
#ifndef _LINEARLAYOUT_H_ #define _LINEARLAYOUT_H_ #include <Element.h> #include <Command.h> #define FW_VERTICAL 1 #define FW_HORIZONTAL 2 class LinearLayout : public Element { public: LinearLayout(int _direction, int _id = 0) : Element(_id), direction(_direction) { } bool isA(const std::string & className) override { if (className == "LinearLayout") return true; return Element::isA(className); } protected: void create() override { Command c(Command::CREATE_LINEAR_LAYOUT, getParentInternalId(), getInternalId()); c.setValue(direction); sendCommand(c); } private: int direction = FW_VERTICAL; }; #endif
Initialize all members of ScopeMeasure
#ifndef NEWSBOAT_SCOPEMEASURE_H_ #define NEWSBOAT_SCOPEMEASURE_H_ #include <sys/time.h> #include <string> #include "logger.h" namespace newsboat { class ScopeMeasure { public: ScopeMeasure(const std::string& func, Level ll = Level::DEBUG); ~ScopeMeasure(); void stopover(const std::string& son = ""); private: struct timeval tv1, tv2; std::string funcname; Level lvl; }; } // namespace newsboat #endif /* NEWSBOAT_SCOPEMEASURE_H_ */
#ifndef NEWSBOAT_SCOPEMEASURE_H_ #define NEWSBOAT_SCOPEMEASURE_H_ #include <sys/time.h> #include <string> #include "logger.h" namespace newsboat { class ScopeMeasure { public: ScopeMeasure(const std::string& func, Level ll = Level::DEBUG); ~ScopeMeasure(); void stopover(const std::string& son = ""); private: struct timeval tv1 = {}, tv2 = {}; std::string funcname; Level lvl = Level::DEBUG; }; } // namespace newsboat #endif /* NEWSBOAT_SCOPEMEASURE_H_ */
Fix mistake FOX and reorder EXPORT/IMPORT
#ifndef TGBOT_EXPORT_H #define TGBOT_EXPORT_H #ifndef TGBOT_API #ifdef TGBOT_DLL #if defined _WIN32 || defined __CYGWIN__ #define TGBOT_HELPER_DLL_IMPORT __declspec(dllimport) #define TGBOT_HELPER_DLL_EXPORT __declspec(dllexport) #else #if __GNUC__ >= 4 #define TGBOT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default"))) #define TGBOT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default"))) #else #define TGBOT_HELPER_DLL_IMPORT #define TGBOT_HELPER_DLL_EXPORT #endif #endif #ifdef TgBot_EXPORTS #define TGBOT_API TGBOT_HELPER_DLL_EXPORT #else #define FOX_API TGBOT_HELPER_DLL_IMPORT #endif #else #define TGBOT_API #endif #endif #endif //TGBOT_EXPORT_H
#ifndef TGBOT_EXPORT_H #define TGBOT_EXPORT_H #ifndef TGBOT_API #ifdef TGBOT_DLL #if defined _WIN32 || defined __CYGWIN__ #define TGBOT_HELPER_DLL_EXPORT __declspec(dllexport) #define TGBOT_HELPER_DLL_IMPORT __declspec(dllimport) #else #if __GNUC__ >= 4 #define TGBOT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default"))) #define TGBOT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default"))) #else #define TGBOT_HELPER_DLL_EXPORT #define TGBOT_HELPER_DLL_IMPORT #endif #endif #ifdef TgBot_EXPORTS #define TGBOT_API TGBOT_HELPER_DLL_EXPORT #else #define TGBOT_API TGBOT_HELPER_DLL_IMPORT #endif #else #define TGBOT_API #endif #endif #endif //TGBOT_EXPORT_H
Revert "[test] Address TestConcurrentMany*.py flakiness on macOS"
#include <atomic> #include <thread> typedef std::atomic<int> pseudo_barrier_t; static inline void pseudo_barrier_wait(pseudo_barrier_t &barrier) { --barrier; while (barrier > 0) std::this_thread::yield(); } static inline void pseudo_barrier_init(pseudo_barrier_t &barrier, int count) { barrier = count; }
#include <atomic> // Note that although hogging the CPU while waiting for a variable to change // would be terrible in production code, it's great for testing since it avoids // a lot of messy context switching to get multiple threads synchronized. typedef std::atomic<int> pseudo_barrier_t; #define pseudo_barrier_wait(barrier) \ do \ { \ --(barrier); \ while ((barrier).load() > 0) \ ; \ } while (0) #define pseudo_barrier_init(barrier, count) \ do \ { \ (barrier) = (count); \ } while (0)
Add missing header into for DragNDrop category on StatesContoller
// // StatesController+DragNDrop.h // States // // Created by Dmitry Rodionov on 13/06/16. // Copyright © 2016 Internals Exposed. All rights reserved. // #import "StatesController.h" @interface StatesController (DragNDrop) @end
// // StatesController+DragNDrop.h // States // // Created by Dmitry Rodionov on 13/06/16. // Copyright © 2016 Internals Exposed. All rights reserved. // #import "StatesController.h" @interface StatesController (DragNDrop) // This category implements the following NSTableViewDataSources methods: - (BOOL)tableView: (NSTableView *)tableView writeRowsWithIndexes: (NSIndexSet *)rowIndexes toPasteboard: (NSPasteboard *)pboard; - (NSDragOperation)tableView: (NSTableView *)tableView validateDrop: (id <NSDraggingInfo>)info proposedRow: (NSInteger)row proposedDropOperation: (NSTableViewDropOperation)dropOperation; - (BOOL)tableView: (NSTableView *)tableView acceptDrop: (id <NSDraggingInfo>)info row: (NSInteger)row dropOperation: (NSTableViewDropOperation)dropOperation; @end
Add more files to the PCH for faster compiles.
//@author A0094446X #pragma once #ifndef YOU_GUI_STDAFX_H_ #define YOU_GUI_STDAFX_H_ #include <QtWidgets> #endif // YOU_GUI_STDAFX_H_
//@author A0094446X #pragma once #ifndef YOU_GUI_STDAFX_H_ #define YOU_GUI_STDAFX_H_ #include <memory> #include <QApplication> #include <QList> #include <QWidget> #include <QtWidgets> #include <boost/date_time/gregorian/greg_month.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #endif // YOU_GUI_STDAFX_H_
Add groupbox to control header
#pragma once #include "Control.h" #include "Button.h" #include "Checkbox.h" #include "ComboBox.h" #include "Label.h" #include "ListView.h" #include "Spinner.h" #include "EditBox.h"
#pragma once #include "Control.h" #include "Button.h" #include "Checkbox.h" #include "ComboBox.h" #include "GroupBox.h" #include "Label.h" #include "ListView.h" #include "Spinner.h" #include "EditBox.h"
Add a sink function for nbtk.Action
#include <pygobject.h> #include <clutter/clutter.h> void pynbtk_register_classes (PyObject *d); void pynbtk_add_constants (PyObject *module, const gchar *prefix); extern PyMethodDef pynbtk_functions[]; DL_EXPORT(void) init_nbtk(void) { PyObject *m, *d; init_pygobject_check (2, 12, 0); m = Py_InitModule ("_nbtk", pynbtk_functions); d = PyModule_GetDict (m); pynbtk_register_classes (d); pynbtk_add_constants (m, "NBTK_"); if (PyErr_Occurred ()) { Py_FatalError ("can't initialise module nbtk"); } }
#include <pygobject.h> #include <nbtk/nbtk.h> void pynbtk_register_classes (PyObject *d); void pynbtk_add_constants (PyObject *module, const gchar *prefix); extern PyMethodDef pynbtk_functions[]; static void sink_nbtkaction (GObject *object) { if (g_object_is_floating (object)) g_object_ref_sink (object); } DL_EXPORT(void) init_nbtk(void) { PyObject *m, *d; init_pygobject_check (2, 12, 0); pygobject_register_sinkfunc (NBTK_TYPE_ACTION, sink_nbtkaction); m = Py_InitModule ("_nbtk", pynbtk_functions); d = PyModule_GetDict (m); pynbtk_register_classes (d); pynbtk_add_constants (m, "NBTK_"); if (PyErr_Occurred ()) { Py_FatalError ("can't initialise module nbtk"); } }
Add comment for the speed threshold
// // ADLivelyCollectionView.h // ADLivelyCollectionView // // Created by Romain Goyet on 18/04/12. // Copyright (c) 2012 Applidium. All rights reserved. // #import <UIKit/UIKit.h> extern NSTimeInterval ADLivelyDefaultDuration; typedef NSTimeInterval (^ADLivelyTransform)(CALayer * layer, float speed); extern ADLivelyTransform ADLivelyTransformCurl; extern ADLivelyTransform ADLivelyTransformFade; extern ADLivelyTransform ADLivelyTransformFan; extern ADLivelyTransform ADLivelyTransformFlip; extern ADLivelyTransform ADLivelyTransformHelix; extern ADLivelyTransform ADLivelyTransformTilt; extern ADLivelyTransform ADLivelyTransformWave; extern ADLivelyTransform ADLivelyTransformGrow; @interface ADLivelyCollectionView : UICollectionView <UICollectionViewDelegate, UICollectionViewDataSource> { id <UICollectionViewDelegate> _preLivelyDelegate; id <UICollectionViewDataSource> _preLivelyDataSource; CGPoint _lastScrollPosition; CGPoint _currentScrollPosition; ADLivelyTransform _transformBlock; } - (CGPoint)scrollSpeed; - (void)setInitialCellTransformBlock:(ADLivelyTransform)block; @property (nonatomic, assign) CGFloat speedThreshold; @end
// // ADLivelyCollectionView.h // ADLivelyCollectionView // // Created by Romain Goyet on 18/04/12. // Copyright (c) 2012 Applidium. All rights reserved. // #import <UIKit/UIKit.h> extern NSTimeInterval ADLivelyDefaultDuration; typedef NSTimeInterval (^ADLivelyTransform)(CALayer * layer, float speed); extern ADLivelyTransform ADLivelyTransformCurl; extern ADLivelyTransform ADLivelyTransformFade; extern ADLivelyTransform ADLivelyTransformFan; extern ADLivelyTransform ADLivelyTransformFlip; extern ADLivelyTransform ADLivelyTransformHelix; extern ADLivelyTransform ADLivelyTransformTilt; extern ADLivelyTransform ADLivelyTransformWave; extern ADLivelyTransform ADLivelyTransformGrow; @interface ADLivelyCollectionView : UICollectionView <UICollectionViewDelegate, UICollectionViewDataSource> { id <UICollectionViewDelegate> _preLivelyDelegate; id <UICollectionViewDataSource> _preLivelyDataSource; CGPoint _lastScrollPosition; CGPoint _currentScrollPosition; ADLivelyTransform _transformBlock; } - (CGPoint)scrollSpeed; - (void)setInitialCellTransformBlock:(ADLivelyTransform)block; @property (nonatomic, assign) CGFloat speedThreshold; // optional, disables animations when exceeding this speed @end
Add TODO re: command mode cursor.
#include "mode.h" #include <stdlib.h> #include <string.h> #include <termbox.h> #include "buf.h" #include "editor.h" static void command_mode_key_pressed(editor_t *editor, struct tb_event *ev) { char ch; switch (ev->key) { case TB_KEY_ESC: buf_printf(editor->status, ""); editor->mode = normal_mode(); return; case TB_KEY_BACKSPACE2: buf_delete(editor->status, editor->status->len - 1, 1); if (editor->status->len == 0) { editor->mode = normal_mode(); return; } return; case TB_KEY_ENTER: { char *command = strdup(editor->status->buf + 1); editor_execute_command(editor, command); free(command); editor->mode = normal_mode(); return; } case TB_KEY_SPACE: ch = ' '; break; default: ch = ev->ch; } char s[2] = {ch, '\0'}; buf_insert(editor->status, s, editor->status->len); } static editing_mode_t impl = {command_mode_key_pressed}; editing_mode_t *command_mode(void) { return &impl; }
#include "mode.h" #include <stdlib.h> #include <string.h> #include <termbox.h> #include "buf.h" #include "editor.h" // TODO(isbadawi): Command mode needs a cursor, but modes don't affect drawing. static void command_mode_key_pressed(editor_t *editor, struct tb_event *ev) { char ch; switch (ev->key) { case TB_KEY_ESC: buf_printf(editor->status, ""); editor->mode = normal_mode(); return; case TB_KEY_BACKSPACE2: buf_delete(editor->status, editor->status->len - 1, 1); if (editor->status->len == 0) { editor->mode = normal_mode(); return; } return; case TB_KEY_ENTER: { char *command = strdup(editor->status->buf + 1); editor_execute_command(editor, command); free(command); editor->mode = normal_mode(); return; } case TB_KEY_SPACE: ch = ' '; break; default: ch = ev->ch; } char s[2] = {ch, '\0'}; buf_insert(editor->status, s, editor->status->len); } static editing_mode_t impl = {command_mode_key_pressed}; editing_mode_t *command_mode(void) { return &impl; }
Copy documentation wording from UITextView+RACSignalSupport.h
// // UIActionSheet+RACSignalSupport.h // ReactiveCocoa // // Created by Dave Lee on 2013-06-22. // Copyright (c) 2013 GitHub, Inc. All rights reserved. // #import <UIKit/UIKit.h> @class RACDelegateProxy; @class RACSignal; @interface UIActionSheet (RACSignalSupport) // A delegate proxy which will be set as the receiver's delegate when any of the // methods in this category are used. @property (nonatomic, strong, readonly) RACDelegateProxy *rac_delegateProxy; // Creates a signal for button clicks on the receiver. // // When this method is invoked, the receiver's `delegate` will be set to // the `rac_delegateProxy` if it is not already. Any existing delegate will be // set as the proxy's `rac_proxiedDelegate`. // // Returns a signal which will send the index of the specific button clicked. // The signal will complete when the receiver is deallocated. - (RACSignal *)rac_buttonClickedSignal; @end
// // UIActionSheet+RACSignalSupport.h // ReactiveCocoa // // Created by Dave Lee on 2013-06-22. // Copyright (c) 2013 GitHub, Inc. All rights reserved. // #import <UIKit/UIKit.h> @class RACDelegateProxy; @class RACSignal; @interface UIActionSheet (RACSignalSupport) // A delegate proxy which will be set as the receiver's delegate when any of the // methods in this category are used. @property (nonatomic, strong, readonly) RACDelegateProxy *rac_delegateProxy; // Creates a signal for button clicks on the receiver. // // When this method is invoked, the `rac_delegateProxy` will become the // receiver's delegate. Any previous delegate will become the -[RACDelegateProxy // rac_proxiedDelegate], so that it receives any messages that the proxy doesn't // know how to handle. Setting the receiver's `delegate` afterward is // considered undefined behavior. // // Returns a signal which will send the index of the specific button clicked. // The signal will complete when the receiver is deallocated. - (RACSignal *)rac_buttonClickedSignal; @end
Fix typos, add instruction memory
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> static int RegisterFile[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int main() { int data_memory[1024]; char string_memeory[2014]; }
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> static int RegisterFile[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int main() { int data_memory[1024]; char* string_memory[2014]; char* instructions[100]; }
Add some tests with RMWs
#include <stddef.h> #include "atomic.h" #include "rmc.h" /// // Needs to live somewhere else at some point // Argh, what do we name these. #include "stdatomic.h" #define atomic_fixup(e) ((_Atomic(__typeof__(*e))*)(e)) #define rmc_compare_exchange_strong(object, expected, desired) \ atomic_compare_exchange_strong_explicit(atomic_fixup(object), expected, \ desired, memory_order_relaxed, memory_order_relaxed) #define rmc_compare_exchange_weak(object, expected, desired) \ atomic_compare_exchange_weak_explicit(atomic_fixup(object), expected, \ desired, memory_order_relaxed, memory_order_relaxed) #define rmc_exchange(object, desired) \ atomic_exchange_explicit(atomic_fixup(object), desired, memory_order_relaxed) #define rmc_fetch_add(object, operand) \ atomic_fetch_add_explicit(atomic_fixup(object), operand, memory_order_relaxed) #define rmc_fetch_and(object, operand) \ atomic_fetch_and_explicit(atomic_fixup(object), operand, memory_order_relaxed) #define rmc_fetch_or(object, operand) \ atomic_fetch_or_explicit(atomic_fixup(object), operand, memory_order_relaxed) #define rmc_fetch_sub(object, operand) \ atomic_fetch_sub_explicit(atomic_fixup(object), operand, memory_order_relaxed) #define rmc_fetch_xor(object, operand) \ atomic_fetch_xor_explicit(atomic_fixup(object), operand, memory_order_relaxed) /// typedef struct mutex_t { int locked; } mutex_t; void mutex_lock_bad(mutex_t *lock) { XEDGE(lock, post); int expected; do { expected = 0; } while (!L(lock, rmc_compare_exchange_weak(&lock->locked, &expected, 1))); } void mutex_lock(mutex_t *lock) { XEDGE(lock, loop_out); XEDGE(loop_out, post); int expected; do { expected = 0; } while (L(lock, rmc_compare_exchange_weak(&lock->locked, &expected, 1)) == 0); L(loop_out, 0); } void mutex_unlock(mutex_t *lock) { VEDGE(pre, unlock); L(unlock, lock->locked = 0); } int nus(int *x) { return rmc_fetch_and(x, 1337); }
Update Skia milestone to 109
/* * 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 108 #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 109 #endif
Add a codec for TileLocation
#pragma once #include <spotify/json.hpp> #include "TileLocation.h" using namespace spotify::json::codec; namespace spotify { namespace json { template<> struct default_codec_t<TileLocation> { static object_t<TileLocation> codec() { auto codec = object<TileLocation>(); codec.required("filename", &TileLocation::filename); codec.required("x", &TileLocation::x); codec.required("y", &TileLocation::y); return codec; } }; } }
Make room for 8 processors in the bus.
#ifndef AC_TLM_BUS_H_ #define AC_TLM_BUS_H_ #include <systemc> #include "ac_tlm_protocol.H" #include "ac_tlm_port.H" #include "ac_memport.H" // using statements using tlm::tlm_transport_if; //#define DEBUG /// Namespace to isolate bus from ArchC namespace user { /// A TLM bus class ac_tlm_bus : public sc_module, public ac_tlm_transport_if // Using ArchC TLM protocol { public: // Memory communication port ac_tlm_port DM_port; /// Exposed port with ArchC interface sc_export< ac_tlm_transport_if > target_export[4]; /** * Implementation of TLM transport method that * handle packets of the protocol doing apropriate actions. * This method must be implemented (required by SystemC TLM). * @param request is a received request packet * @return A response packet to be send */ ac_tlm_rsp transport( const ac_tlm_req &request ) { return DM_port->transport(request); } /** * Default constructor. */ ac_tlm_bus(sc_module_name module_name); /** * Default destructor. */ ~ac_tlm_bus(); }; }; #endif //AC_TLM_BUS_H_
#ifndef AC_TLM_BUS_H_ #define AC_TLM_BUS_H_ #include <systemc> #include "ac_tlm_protocol.H" #include "ac_tlm_port.H" #include "ac_memport.H" // using statements using tlm::tlm_transport_if; //#define DEBUG /// Namespace to isolate bus from ArchC namespace user { /// A TLM bus class ac_tlm_bus : public sc_module, public ac_tlm_transport_if // Using ArchC TLM protocol { public: // Memory communication port ac_tlm_port DM_port; /// Exposed port with ArchC interface sc_export< ac_tlm_transport_if > target_export[8]; /** * Implementation of TLM transport method that * handle packets of the protocol doing apropriate actions. * This method must be implemented (required by SystemC TLM). * @param request is a received request packet * @return A response packet to be send */ ac_tlm_rsp transport( const ac_tlm_req &request ) { return DM_port->transport(request); } /** * Default constructor. */ ac_tlm_bus(sc_module_name module_name); /** * Default destructor. */ ~ac_tlm_bus(); }; }; #endif //AC_TLM_BUS_H_
Handle the condition where BS is typed while the cursor is at the first position on either of the last two lines of the screen. Ie. append contents of current line to the previous line and scroll the next line's contents up.
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for * * details. If they are missing then this copy is in violation of * * the copyright conditions. */ /* ** lib_insdel.c ** ** The routine winsdel(win, n). ** positive n insert n lines above current line ** negative n delete n lines starting from current line ** */ #include <stdlib.h> #include "curses.priv.h" #include "terminfo.h" int winsdelln(WINDOW *win, int n) { int ret, sscroll, stop, sbot; T(("winsdel(%x,%d) called", win, n)); if (n == 0) return OK; if (n < 0 && win->_cury - n >= win->_maxy) /* request to delete too many lines */ /* should we truncate to an appropriate number? */ return ERR; sscroll = win->_scroll; stop = win->_regtop; sbot = win->_regbottom; win->_scroll = TRUE; win->_regtop = win->_cury; if (win->_regtop > win->_regbottom) win->_regbottom = win->_maxy; ret = wscrl(win, -n); win->_scroll = sscroll; win->_regtop = stop; win->_regbottom = sbot; return ret; }
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for * * details. If they are missing then this copy is in violation of * * the copyright conditions. */ /* ** lib_insdel.c ** ** The routine winsdel(win, n). ** positive n insert n lines above current line ** negative n delete n lines starting from current line ** */ #include <stdlib.h> #include "curses.priv.h" #include "terminfo.h" int winsdelln(WINDOW *win, int n) { int ret, sscroll, stop, sbot; T(("winsdel(%x,%d) called", win, n)); if (n == 0) return OK; if (n == -1 && win->_cury == win->_maxy) return wclrtoeol(win); if (n < 0 && win->_cury - n > win->_maxy) /* request to delete too many lines */ /* should we truncate to an appropriate number? */ return ERR; sscroll = win->_scroll; stop = win->_regtop; sbot = win->_regbottom; win->_scroll = TRUE; win->_regtop = win->_cury; if (win->_regtop > win->_regbottom) win->_regbottom = win->_maxy; ret = wscrl(win, -n); win->_scroll = sscroll; win->_regtop = stop; win->_regbottom = sbot; return ret; }
Print newline on clean exit.
#include <stdio.h> #include "common.h" #include "wisp.h" #include "lisp.h" /* parser crap */ extern FILE *yyin; int yyparse (); void parser_init (); extern int interactive; extern char *prompt; /* Initilize all the systems. */ void init () { /* These *must* be called in this order. */ object_init (); symtab_init (); cons_init (); eval_init (); lisp_init (); parser_init (); } int main (int argc, char **argv) { (void) argc; (void) argv; init (); /* Load core lisp code. */ interactive = 0; yyin = fopen ("core.wisp", "r"); if (yyin == NULL) { fprintf (stderr, "error: could not load core lisp.\n"); exit (EXIT_FAILURE); } yyparse (); fclose (yyin); /* yy_flush_buffer(); */ /* Run interaction. */ interactive = 1; printf ("Happy hacking!\n%s", prompt); yyin = stdin; yyparse (); }
#include <stdio.h> #include "common.h" #include "wisp.h" #include "lisp.h" /* parser crap */ extern FILE *yyin; int yyparse (); void parser_init (); extern int interactive; extern char *prompt; /* Initilize all the systems. */ void init () { /* These *must* be called in this order. */ object_init (); symtab_init (); cons_init (); eval_init (); lisp_init (); parser_init (); } int main (int argc, char **argv) { (void) argc; (void) argv; init (); /* Load core lisp code. */ interactive = 0; yyin = fopen ("core.wisp", "r"); if (yyin == NULL) { fprintf (stderr, "error: could not load core lisp.\n"); exit (EXIT_FAILURE); } yyparse (); fclose (yyin); /* yy_flush_buffer(); */ /* Run interaction. */ interactive = 1; printf ("Happy hacking!\n%s", prompt); yyin = stdin; yyparse (); printf ("\n"); }
Debug label inline function bug
// ucc -g tim.c _Noreturn void abort() { __builtin_unreachable(); } void realloc() { int local = 5; abort(); }
Remove unicode from cpp bug example
#define typename(x) _Generic((x), \ _Bool: "_BoolÓ, unsigned char: "unsigned charÓ, \ char: "char", signed char: "signed char", \ void *: "pointer to voidÓ, int *: "pointer to int", \ default: "other")
#define typename(x) _Generic((x), \ _Bool: "_Bool", unsigned char: "unsigned char", \ char: "char", signed char: "signed char", \ void *: "pointer to void", int *: "pointer to int", \ default: "other")
Make subcommands' argc/argv compatible with getopt
#include "goontools.h" void usage(char* prog) { fprintf(stderr, "\n"); fprintf(stderr, "Usage: %s <subcommand> <subcommand arguments>\n", prog); fprintf(stderr, "\n"); fprintf(stderr, "subcommands:\n"); fprintf(stderr, " index index file\n"); fprintf(stderr, " sort sort file\n"); fprintf(stderr, " view view/slice file\n"); fprintf(stderr, "\n"); } int dispatch(int argc, char *argv[]) { char *subcommands[] = { "index", "view", "sort", NULL // sentinel }; Subcommand dispatch[] = { &goonindex, &goonview, &goonsort }; char **s; for (s = subcommands; *s != NULL; s += 1) { if (strcmp(argv[1], *s) == 0) { break; } } if (*s == NULL) { usage(argv[0]); return -1; } return dispatch[s-subcommands](argc-2, argv+2); } int main(int argc, char *argv[]) { if (argc == 1) { usage(argv[0]); return EXIT_FAILURE; } if (dispatch(argc, argv) != 0) { return EXIT_FAILURE; } return EXIT_SUCCESS; }
#include "goontools.h" void usage(char* prog) { fprintf(stderr, "\n"); fprintf(stderr, "Usage: %s <subcommand> <subcommand arguments>\n", prog); fprintf(stderr, "\n"); fprintf(stderr, "subcommands:\n"); fprintf(stderr, " index index file\n"); fprintf(stderr, " sort sort file\n"); fprintf(stderr, " view view/slice file\n"); fprintf(stderr, "\n"); } int dispatch(int argc, char *argv[]) { char *subcommands[] = { "index", "view", "sort", NULL // sentinel }; Subcommand dispatch[] = { &goonindex, &goonview, &goonsort }; char **s; for (s = subcommands; *s != NULL; s += 1) { if (strcmp(argv[1], *s) == 0) { break; } } if (*s == NULL) { usage(argv[0]); return -1; } return dispatch[s-subcommands](argc-1, argv+1); } int main(int argc, char *argv[]) { if (argc == 1) { usage(argv[0]); return EXIT_FAILURE; } if (dispatch(argc, argv) != 0) { return EXIT_FAILURE; } return EXIT_SUCCESS; }
Set the header protection to end with _H.
#ifndef TIME_HAO #define TIME_HAO #include <time.h> class Timer_hao { public: double seconds; int timing_flag; time_t timerinit,timerend; Timer_hao(); Timer_hao(double); Timer_hao(const Timer_hao& ); ~Timer_hao(); Timer_hao& operator = (const Timer_hao&); void init(); void end(); void print_init() const; void print_end() const; void print_accumulation() const; }; struct tm second_to_tm(double); #endif
#ifndef TIME_HAO_H #define TIME_HAO_H #include <time.h> class Timer_hao { public: double seconds; int timing_flag; time_t timerinit,timerend; Timer_hao(); Timer_hao(double); Timer_hao(const Timer_hao& ); ~Timer_hao(); Timer_hao& operator = (const Timer_hao&); void init(); void end(); void print_init() const; void print_end() const; void print_accumulation() const; }; struct tm second_to_tm(double); #endif
Update number of armies on wastelands
// This program is free software licenced under MIT Licence. You can // find a copy of this licence in LICENCE.txt in the top directory of // source code. // #ifndef SETTINGS_H_INCLUDED #define SETTINGS_H_INCLUDED #include <vector> #include <tuple> /** * This file contains gereral configuration and thing whoch should be in the * global scope */ using AdjencyList = std::vector<std::vector<int>>; using Placements = std::vector<std::pair<int, int>>; using Movements = std::vector<std::tuple<int, int, int>>; #define NEUTRAL_ARMIES 2 #define WASTELAND_ARMIES 10 enum class Player { ME, ENEMY, NEUTRAL }; enum class Request { NONE, PICK_STARTING_REGION, PLACE_ARMIES, ATTACK_TRANSFER }; #endif // MAIN_H_INCLUDED
// This program is free software licenced under MIT Licence. You can // find a copy of this licence in LICENCE.txt in the top directory of // source code. // #ifndef SETTINGS_H_INCLUDED #define SETTINGS_H_INCLUDED #include <vector> #include <tuple> /** * This file contains gereral configuration and thing whoch should be in the * global scope */ using AdjencyList = std::vector<std::vector<int>>; using Placements = std::vector<std::pair<int, int>>; using Movements = std::vector<std::tuple<int, int, int>>; #define NEUTRAL_ARMIES 2 #define WASTELAND_ARMIES 6 enum class Player { ME, ENEMY, NEUTRAL }; enum class Request { NONE, PICK_STARTING_REGION, PLACE_ARMIES, ATTACK_TRANSFER }; #endif // MAIN_H_INCLUDED
Add RoomBubbleCellData.h and MXKRoomBubbleTableViewCell+Riot.h to Objective-C bridging header.
// // Use this file to import your target's public headers that you would like to expose to Swift. // @import MatrixSDK; @import MatrixKit; #import "WebViewViewController.h" #import "RiotNavigationController.h" #import "ThemeService.h" #import "TableViewCellWithCheckBoxAndLabel.h" #import "RecentsDataSource.h" #import "AvatarGenerator.h" #import "EncryptionInfoView.h" #import "EventFormatter.h" #import "MediaPickerViewController.h" #import "AppDelegate.h"
// // Use this file to import your target's public headers that you would like to expose to Swift. // @import MatrixSDK; @import MatrixKit; #import "WebViewViewController.h" #import "RiotNavigationController.h" #import "ThemeService.h" #import "TableViewCellWithCheckBoxAndLabel.h" #import "RecentsDataSource.h" #import "AvatarGenerator.h" #import "EncryptionInfoView.h" #import "EventFormatter.h" #import "MediaPickerViewController.h" #import "AppDelegate.h" #import "RoomBubbleCellData.h" #import "MXKRoomBubbleTableViewCell+Riot.h"
Use 8MB as the default stack size in CilkPlus.
#ifndef CILKPLUS_H #define CILKPLUS_H #include <cilk/cilk.h> #define fibril #define fibril_t __attribute__((unused)) int #define fibril_init(fp) #define fibril_join(fp) cilk_sync #define fibril_fork_nrt(fp, fn, ag) cilk_spawn fn ag #define fibril_fork_wrt(fp, rt, fn, ag) rt = cilk_spawn fn ag #define fibril_rt_init(n) #define fibril_rt_exit() #define fibril_rt_nprocs(n) \ (n > 0 ? __cilkrts_set_param("nworkers", #n) : __cilkrts_get_nworkers()) #endif /* end of include guard: CILKPLUS_H */
#ifndef CILKPLUS_H #define CILKPLUS_H #include <cilk/cilk.h> #define fibril #define fibril_t __attribute__((unused)) int #define fibril_init(fp) #define fibril_join(fp) cilk_sync #define fibril_fork_nrt(fp, fn, ag) cilk_spawn fn ag #define fibril_fork_wrt(fp, rt, fn, ag) rt = cilk_spawn fn ag #define fibril_rt_init(n) (__cilkrts_set_param("stack size", "0x800000")) #define fibril_rt_exit() #define fibril_rt_nprocs(n) \ (n > 0 ? __cilkrts_set_param("nworkers", #n) : __cilkrts_get_nworkers()) #endif /* end of include guard: CILKPLUS_H */
Fix C declaration errors on ARM.
#include <stdio.h> void SpinYetAgain() { volatile unsigned int count = 0; for(int i=0; i<1000; i++) { count++; } } void SpinSomeMore() { volatile unsigned int count = 0; for(int i=0; i<1000; i++) { count++; } SpinYetAgain(); } void Spin() { volatile unsigned int count = 0; for(int i=0; i<1000; i++) { count++; } SpinSomeMore(); } int main(int argc, char* argv[]) { while(1) { Spin(); } }
#include <stdio.h> void SpinYetAgain() { volatile unsigned int count = 0; int i; for(i=0; i<1000; i++) { count++; } } void SpinSomeMore() { volatile unsigned int count = 0; int i; for(i=0; i<1000; i++) { count++; } SpinYetAgain(); } void Spin() { volatile unsigned int count = 0; int i; for(i=0; i<1000; i++) { count++; } SpinSomeMore(); } int main(int argc, char* argv[]) { while(1) { Spin(); } }
Set debug level to 2 and use a suitable printf function
// project-specific definitions for otaa sensor //#define CFG_eu868 1 //#define CFG_us915 1 //#define CFG_au921 1 #define CFG_as923 1 #define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_JP //#define CFG_in866 1 #define CFG_sx1276_radio 1 //#define LMIC_USE_INTERRUPTS
// project-specific definitions for otaa sensor //#define CFG_eu868 1 //#define CFG_us915 1 //#define CFG_au921 1 #define CFG_as923 1 #define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_JP //#define CFG_in866 1 #define CFG_sx1276_radio 1 //#define LMIC_USE_INTERRUPTS #define LMIC_DEBUG_LEVEL 2 #define LMIC_DEBUG_PRINTF_FN lmic_printf
Fix compilation warnings when using clang.
#ifndef KVAZAAR_INTERNAL_H_ #define KVAZAAR_INTERNAL_H_ /***************************************************************************** * This file is part of Kvazaar HEVC encoder. * * Copyright (C) 2013-2015 Tampere University of Technology and others (see * COPYING file). * * Kvazaar 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. * * Kvazaar 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 General Public License along * with Kvazaar. If not, see <http://www.gnu.org/licenses/>. ****************************************************************************/ #include "kvazaar.h" // Forward declarations. typedef struct encoder_state_t encoder_state_t; typedef struct encoder_control_t encoder_control_t; typedef struct kvz_encoder { encoder_control_t* control; encoder_state_t* states; unsigned num_encoder_states; unsigned cur_state_num; unsigned frames_started; unsigned frames_done; size_t bitstream_length; } kvz_encoder; #endif // KVAZAAR_INTERNAL_H_
#ifndef KVAZAAR_INTERNAL_H_ #define KVAZAAR_INTERNAL_H_ /***************************************************************************** * This file is part of Kvazaar HEVC encoder. * * Copyright (C) 2013-2015 Tampere University of Technology and others (see * COPYING file). * * Kvazaar 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. * * Kvazaar 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 General Public License along * with Kvazaar. If not, see <http://www.gnu.org/licenses/>. ****************************************************************************/ #include "kvazaar.h" // Forward declarations. struct encoder_state_t; struct encoder_control_t; struct kvz_encoder { struct encoder_control_t* control; struct encoder_state_t* states; unsigned num_encoder_states; unsigned cur_state_num; unsigned frames_started; unsigned frames_done; size_t bitstream_length; }; #endif // KVAZAAR_INTERNAL_H_
Add basic operation function declaration
#include <stdlib.h> #ifndef __STACK_H__ #define __STACK_H__ struct Stack; typedef struct Stack Stack; #endif
#include <stdlib.h> #ifndef __STACK_H__ #define __STACK_H__ struct Stack; typedef struct Stack Stack; void Push(Stack s, void* e); void* Pop(Stack s); int Stack_Empty(Stack s); #endif
Change remaining glTbufferMask3DFX to an instance method.
/* * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz> * * This program is distributed under the terms of the MIT license. * See the included MIT-LICENSE file for the terms of this license. * * 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 "common.h" /* OpenGL 3DFX extensions */ /* #208 - GL_3DFX_tbuffer */ GL_FUNC_LOAD_1(TbufferMask3DFX,GLvoid, GLuint, "GL_3DFX_tbuffer") void gl_init_functions_ext_3dfx(VALUE module) { /* #208 - GL_3DFX_tbuffer */ rb_define_module_function(module, "glTbufferMask3DFX", gl_TbufferMask3DFX, 1); }
/* * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz> * * This program is distributed under the terms of the MIT license. * See the included MIT-LICENSE file for the terms of this license. * * 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 "common.h" /* OpenGL 3DFX extensions */ /* #208 - GL_3DFX_tbuffer */ GL_FUNC_LOAD_1(TbufferMask3DFX,GLvoid, GLuint, "GL_3DFX_tbuffer") void gl_init_functions_ext_3dfx(VALUE klass) { /* #208 - GL_3DFX_tbuffer */ rb_define_method(klass, "glTbufferMask3DFX", gl_TbufferMask3DFX, 1); }
Replace long with int in the C version to improve performance.
#include <stdio.h> #include <stdlib.h> #include <math.h> int isPrime(unsigned long x) { if (sqrt(x) - (unsigned long)sqrt(x) == 0) return 0; for (unsigned long i = 2; i < ceil(sqrt(x)); i++) if (x % i == 0) return 0; return 1; } int main( int argc, char** argv) { unsigned long max = atol(argv[1]); unsigned long *a = malloc(sizeof(unsigned long) * max); unsigned long x = 2; for (unsigned long i = 0; i < max; x++) if (isPrime(x)) a[i++] = x; for (unsigned long i = 0; i < max; i++) printf("%lu\n", (unsigned long)a[i]); return 0; }
#include <stdio.h> #include <stdlib.h> #include <math.h> int isPrime(unsigned int x) { if (sqrt(x) - (unsigned int)sqrt(x) == 0) return 0; for (unsigned int i = 2; i < ceil(sqrt(x)); i++) if (x % i == 0) return 0; return 1; } int main( int argc, char** argv) { unsigned int max = atol(argv[1]); unsigned int *a = malloc(sizeof(unsigned int) * max); unsigned int x = 2; for (unsigned int i = 0; i < max; x++) if (isPrime(x)) a[i++] = x; for (unsigned int i = 0; i < max; i++) printf("%u\n", (unsigned int)a[i]); return 0; }
Fix compilation on MacOSX (common symbols not allowed with MH_DYLIB output format)
#ifdef _WIN32 #define DL_EXPORT __declspec( dllexport ) #else #define DL_EXPORT #endif DL_EXPORT int TestDynamicLoaderData; DL_EXPORT void TestDynamicLoaderFunction() { }
#ifdef _WIN32 #define DL_EXPORT __declspec( dllexport ) #else #define DL_EXPORT #endif DL_EXPORT int TestDynamicLoaderData = 0; DL_EXPORT void TestDynamicLoaderFunction() { }
Add sys file required for IEEE fp functions.
/* * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _FLOATINGPOINT_H_ #define _FLOATINGPOINT_H_ #include <machine/ieeefp.h> #endif /* !_FLOATINGPOINT_H_ */
Correct line endings that got mixed up in r320088; NFC.
// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | FileCheck %s // CHECK: has_fallthrough #if __has_c_attribute(fallthrough) int has_fallthrough(); #endif // CHECK: does_not_have_selectany #if !__has_c_attribute(selectany) int does_not_have_selectany(); #endif
// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | FileCheck %s // CHECK: has_fallthrough #if __has_c_attribute(fallthrough) int has_fallthrough(); #endif // CHECK: does_not_have_selectany #if !__has_c_attribute(selectany) int does_not_have_selectany(); #endif
Disable fuzz_full test until fixed
#include <stdio.h> #include <stdlib.h> #include "rxvm.h" #include "test_common.h" #include "test_modules.h" #define NUM_MODS 7 const testmod_t mods[NUM_MODS] = { test_rxvm_err, test_rxvm_match, test_rxvm_search, test_rxvm_search_nomatch, test_rxvm_compile, test_fuzz_rxvm_match, test_fuzz_full_rxvm_match }; int main (void) { testmod_t module; int i; int ret; int count; count = 1; ret = 0; printf("1..%d\n", NUM_TESTS); /* Run all test modules */ for (i = 0; i < NUM_MODS; ++i) { module = mods[i]; ret += (*module)(&count); } return ret; }
#include <stdio.h> #include <stdlib.h> #include "rxvm.h" #include "test_common.h" #include "test_modules.h" //#define NUM_MODS 7 #define NUM_MODS 6 const testmod_t mods[NUM_MODS] = { test_rxvm_err, test_rxvm_match, test_rxvm_search, test_rxvm_search_nomatch, test_rxvm_compile, test_fuzz_rxvm_match, //test_fuzz_full_rxvm_match }; int main (void) { testmod_t module; int i; int ret; int count; count = 1; ret = 0; printf("1..%d\n", NUM_TESTS); /* Run all test modules */ for (i = 0; i < NUM_MODS; ++i) { module = mods[i]; ret += (*module)(&count); } return ret; }
Disable raw mode when exiting
#include <termios.h> #include <unistd.h> void enableRawMode() { struct termios raw; tcgetattr(STDIN_FILENO, &raw); raw.c_lflag &= ~(ECHO); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enableRawMode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q'); return 0; }
#include <stdlib.h> #include <termios.h> #include <unistd.h> struct termios orig_termios; void disableRawMode() { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } void enableRawMode() { tcgetattr(STDIN_FILENO, &orig_termios); atexit(disableRawMode); struct termios raw = orig_termios; raw.c_lflag &= ~(ECHO); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enableRawMode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q'); return 0; }
Revert "with Xcode4.4 __weak typeof(o) is all that's needed for weak references"
// // BBlock.h // BBlock // // Created by David Keegan on 4/10/12. // Copyright (c) 2012 David Keegan. All rights reserved. // #import <Foundation/Foundation.h> /// For when you need a weak reference of an object, example: `BBlockWeakObject(obj) wobj = obj;` #define BBlockWeakObject(o) __weak typeof(o) /// For when you need a weak reference to self, example: `BBlockWeakSelf wself = self;` #define BBlockWeakSelf BBlockWeakObject(self) @interface BBlock : NSObject /// Execute the block on the main thread + (void)dispatchOnMainThread:(void (^)())block; /// Exectute the block on a background thread but in a synchronous queue + (void)dispatchOnSynchronousQueue:(void (^)())block; /// Exectute the block on a background thread but in a synchronous queue, /// This queue should only be used for writing files to disk. + (void)dispatchOnSynchronousFileQueue:(void (^)())block; + (void)dispatchOnDefaultPriorityConcurrentQueue:(void (^)())block; + (void)dispatchOnLowPriorityConcurrentQueue:(void (^)())block; + (void)dispatchOnHighPriorityConcurrentQueue:(void (^)())block; @end
// // BBlock.h // BBlock // // Created by David Keegan on 4/10/12. // Copyright (c) 2012 David Keegan. All rights reserved. // #import <Foundation/Foundation.h> /// For when you need a weak reference of an object, example: `BBlockWeakObject(obj) wobj = obj;` #define BBlockWeakObject(o) __weak __typeof__((__typeof__(o))o) /// For when you need a weak reference to self, example: `BBlockWeakSelf wself = self;` #define BBlockWeakSelf BBlockWeakObject(self) @interface BBlock : NSObject /// Execute the block on the main thread + (void)dispatchOnMainThread:(void (^)())block; /// Exectute the block on a background thread but in a synchronous queue + (void)dispatchOnSynchronousQueue:(void (^)())block; /// Exectute the block on a background thread but in a synchronous queue, /// This queue should only be used for writing files to disk. + (void)dispatchOnSynchronousFileQueue:(void (^)())block; + (void)dispatchOnDefaultPriorityConcurrentQueue:(void (^)())block; + (void)dispatchOnLowPriorityConcurrentQueue:(void (^)())block; + (void)dispatchOnHighPriorityConcurrentQueue:(void (^)())block; @end
Document on getters of argc and argv
#include <stdint.h> void __wasm_call_ctors(void); int __argc(void); void __argv(uintptr_t[static 1]); void __args(char[static 1]); int main(int, char**); void _start(void) { int argc = __argc(); char* argv[argc + 1]; __argv((uintptr_t*)argv); char args[(uintptr_t)argv[argc]]; __args(args); for (int i = 0; i < argc; ++i) argv[i] = args + (uintptr_t)argv[i]; argv[argc] = (void*)0; __wasm_call_ctors(); main(argc, argv); }
#include <stdint.h> void __wasm_call_ctors(void); /*! * `argc` getter * * This function returns 0 if passing arguments to main() is unsupported. */ int __argc(void); /*! * `argv` builder * * This function stores `argv` as offset from `argv[0]`, * and appends `sizeof(args)`. * * For example, if the command line is `foo -c alfa`, * { 0, 4, 7, 12 } will be written because * * argv[0] = args + 0 * argv[1] = args + 4 * argv[2] = args + 7 * sizeof(args) = 12 * * See __args() for format of `args`. */ void __argv(uintptr_t* argv); /*! * This function stores null-separated command line. * * For example, if the command line is `foo -c alfa`, * it is stored as `"foo\0-c\0alfa"`. * Note that there is an implied '\0' at the end of a string. */ void __args(char* args); int main(int argc, char** argv); void _start(void) { int argc = __argc(); char* argv[argc + 1]; __argv((uintptr_t*)argv); char args[argc ? (uintptr_t)argv[argc] : 0]; __args(args); for (int i = 0; i < argc; ++i) argv[i] = args + (uintptr_t)argv[i]; argv[argc] = (void*)0; __wasm_call_ctors(); main(argc, argv); }
Print the number of solutions.
// Copyright (c) 2016 Ed Schouten <ed@nuxi.nl> // // This file is distributed under a 2-clause BSD license. // See the LICENSE file for details. #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include "infiniteloop.h" static bool print_solution(const struct il_solution *s, void *thunk) { char buf[1024]; if (!il_solution_print(s, buf, sizeof(buf))) { fprintf(stderr, "Failed to print solution\n"); exit(1); } printf("-- SOLUTION --\n%s\n", buf); return true; } int main(void) { char buf[1024]; size_t len = fread(buf, 1, sizeof(buf) - 1, stdin); buf[len] = '\0'; struct il_problem p; if (!il_problem_parse(buf, &p)) { fprintf(stderr, "Failed to parse input\n"); return 1; } il_solve(&p, print_solution, NULL); return 0; }
// Copyright (c) 2016 Ed Schouten <ed@nuxi.nl> // // This file is distributed under a 2-clause BSD license. // See the LICENSE file for details. #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include "infiniteloop.h" static unsigned int solutions_found = 0; static bool print_solution(const struct il_solution *s, void *thunk) { char buf[1024]; if (!il_solution_print(s, buf, sizeof(buf))) { fprintf(stderr, "Failed to print solution\n"); exit(1); } printf("-- SOLUTION --\n%s\n", buf); ++solutions_found; return true; } int main(void) { char buf[1024]; size_t len = fread(buf, 1, sizeof(buf) - 1, stdin); buf[len] = '\0'; struct il_problem p; if (!il_problem_parse(buf, &p)) { fprintf(stderr, "Failed to parse input\n"); return 1; } il_solve(&p, print_solution, NULL); printf("-- FOUND %u SOLUTIONS --\n", solutions_found); return 0; }
Add file with dummy client info
// // MHClientSecret.h // MyHub // // Created by Arcterus on 1/14/14. // Copyright (c) 2014 kRaken Research. All rights reserved. // #ifndef MyHub_MHClientSecret_h #define MyHub_MHClientSecret_h #define CLIENT_ID "1234567890" #define CLIENT_SECRET "1234567890abcdef" #endif