Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add missing copyright in the other file.
void __cxa_finalize(void *d ); extern void __dso_handle; __attribute((destructor)) static void cleanup(void) { __cxa_finalize(&__dso_handle); }
/** * Copyright (c) 2012 David Chisnall. * This work was funded by TBricks. * * 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. * */ void __cxa_finalize(void *d ); extern void __dso_handle; __attribute((destructor)) static void cleanup(void) { __cxa_finalize(&__dso_handle); }
Remove unnecessary forward class declaration
// // PMPinboardService.h // Pinmarker // // Created by Kyle Stevens on 9/24/14. // Copyright (c) 2014 kilovolt42. All rights reserved. // @class PMBookmark; @interface PMPinboardService : NSObject + (void)requestAPITokenForAPIToken:(NSString *)token success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure; + (void)requestAPITokenForUsername:(NSString *)username password:(NSString *)password success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure; + (void)requestTagsForAPIToken:(NSString *)token success:(void (^)(NSDictionary *))success failure:(void (^)(NSError *))failure; + (void)requestPostForURL:(NSString *)url APIToken:(NSString *)token success:(void (^)(NSDictionary *))success failure:(void (^)(NSError *))failure; + (void)postBookmarkParameters:(NSDictionary *)parameters APIToken:(NSString *)token success:(void (^)(id))success failure:(void (^)(NSError *, id))failure; @end
// // PMPinboardService.h // Pinmarker // // Created by Kyle Stevens on 9/24/14. // Copyright (c) 2014 kilovolt42. All rights reserved. // @interface PMPinboardService : NSObject + (void)requestAPITokenForAPIToken:(NSString *)token success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure; + (void)requestAPITokenForUsername:(NSString *)username password:(NSString *)password success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure; + (void)requestTagsForAPIToken:(NSString *)token success:(void (^)(NSDictionary *))success failure:(void (^)(NSError *))failure; + (void)requestPostForURL:(NSString *)url APIToken:(NSString *)token success:(void (^)(NSDictionary *))success failure:(void (^)(NSError *))failure; + (void)postBookmarkParameters:(NSDictionary *)parameters APIToken:(NSString *)token success:(void (^)(id))success failure:(void (^)(NSError *, id))failure; @end
Fix mistake in example benchmark that is supposed to be correct. The NaN and infinity cases were not considered.
#ifdef KLEE #include "klee/klee.h" #endif #include <assert.h> #include <stdio.h> #include "math.h" int main() { float a; #ifdef KLEE klee_make_symbolic(&a, sizeof(a), "a"); #endif float b = a - a; assert(sin(b) == 0.0f); return 0; }
#ifdef KLEE #include "klee/klee.h" #endif #include <assert.h> #include <stdio.h> #include "math.h" int main() { float a = 0.0f; #ifdef KLEE klee_make_symbolic(&a, sizeof(a), "a"); #endif if (isnan(a) || isinf(a)) { // assertion won't hold in these cases so exit early return 0; } float b = a - a; assert(sin(b) == 0.0f); return 0; }
Add parsers header to root header
// // TrailsKit.h // TrailsKit // // Created by Mike Mertsock on 1/1/13. // Copyright (c) 2013 Esker Apps. All rights reserved. // #ifndef TrailsKit_TrailsKit_h #define TrailsKit_TrailsKit_h #import "TrailsKitGeometry.h" #import "TKGPXPolylineMapper.h" #import "TrailsKitUI.h" #import "TrailsKitTypes.h" #endif
// // TrailsKit.h // TrailsKit // // Created by Mike Mertsock on 1/1/13. // Copyright (c) 2013 Esker Apps. All rights reserved. // #ifndef TrailsKit_TrailsKit_h #define TrailsKit_TrailsKit_h #import "TrailsKitGeometry.h" #import "TrailsKitParsers.h" #import "TrailsKitTypes.h" #import "TrailsKitUI.h" #endif
REMOVE commented out START_WITHOUT_MENU so we start with a menu
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #include "GameState.h" #include "StartState.h" #include "LevelSelectState.h" #include <vector> #define START_WITHOUT_MENU class GameStateHandler { private: std::vector<GameState*> m_stateStack; std::vector<GameState*> m_statesToRemove; public: GameStateHandler(); ~GameStateHandler(); int ShutDown(); int Initialize(ComponentHandler* cHandler, Camera* cameraRef); int Update(float dt, InputHandler* inputHandler); //Push a state to the stack int PushStateToStack(GameState* state); private: }; #endif
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #include "GameState.h" #include "StartState.h" #include "LevelSelectState.h" #include <vector> //#define START_WITHOUT_MENU class GameStateHandler { private: std::vector<GameState*> m_stateStack; std::vector<GameState*> m_statesToRemove; public: GameStateHandler(); ~GameStateHandler(); int ShutDown(); int Initialize(ComponentHandler* cHandler, Camera* cameraRef); int Update(float dt, InputHandler* inputHandler); //Push a state to the stack int PushStateToStack(GameState* state); private: }; #endif
Improve user info name consistency
@import CoreData; static NSString * const HYPPropertyMapperCustomRemoteKey = @"mapper.remote.key"; @interface NSManagedObject (HYPPropertyMapper) - (void)hyp_fillWithDictionary:(NSDictionary *)dictionary; - (NSDictionary *)hyp_dictionary; @end
@import CoreData; static NSString * const HYPPropertyMapperCustomRemoteKey = @"hyper.remoteKey"; @interface NSManagedObject (HYPPropertyMapper) - (void)hyp_fillWithDictionary:(NSDictionary *)dictionary; - (NSDictionary *)hyp_dictionary; @end
Update driver version to 5.02.00-k19
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2010 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k18"
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2010 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k19"
Add missing FFMPEG_ prefix to multiple inclusion guard.
/* * AVC helper functions for muxers * Copyright (c) 2008 Aurelien Jacobs <aurel@gnuage.org> * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVC_H #define AVC_H #include <stdint.h> #include "avio.h" int ff_avc_parse_nal_units(const uint8_t *buf_in, uint8_t **buf, int *size); int ff_isom_write_avcc(ByteIOContext *pb, const uint8_t *data, int len); const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end); #endif /* AVC_H */
/* * AVC helper functions for muxers * Copyright (c) 2008 Aurelien Jacobs <aurel@gnuage.org> * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef FFMPEG_AVC_H #define FFMPEG_AVC_H #include <stdint.h> #include "avio.h" int ff_avc_parse_nal_units(const uint8_t *buf_in, uint8_t **buf, int *size); int ff_isom_write_avcc(ByteIOContext *pb, const uint8_t *data, int len); const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end); #endif /* FFMPEG_AVC_H */
Set trm inherit signals by default
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_trmnew.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ncoden <ncoden@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/05/08 12:26:49 by ncoden #+# #+# */ /* Updated: 2015/05/30 16:29:30 by ncoden ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" t_trm *ft_trmnew(void) { t_trm *trm; char *name; if (!(name = ft_envget("TERM"))) return (NULL); if (!(trm = (t_trm *)ft_memalloc(sizeof(t_trm)))) return (NULL); if ((tgetent(NULL, name))) { if (tcgetattr(ft_trmgetout(), &trm->opts) != -1) return (trm); } free(trm); return (NULL); }
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_trmnew.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ncoden <ncoden@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/05/08 12:26:49 by ncoden #+# #+# */ /* Updated: 2015/06/06 16:14:04 by ncoden ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" t_trm *ft_trmnew(void) { t_trm *trm; char *name; if (!(name = ft_envget("TERM"))) return (NULL); if (!(trm = (t_trm *)ft_memalloc(sizeof(t_trm)))) return (NULL); if ((tgetent(NULL, name))) { if (tcgetattr(ft_trmgetout(), &trm->opts) != -1) { trm->inherit_signal = TRUE; return (trm); } } free(trm); return (NULL); }
Make this easier to compile
#include "cycy/stdio.h" int puts(const char * string) { int i = 0; while (string[i] != NULL) { putchar(string[i++]); } putc('\n'); return i + 1; }
#include "cycy/stdio.h" int puts(const char * string) { int i = 0; while (string[i] != NULL) { putchar(string[i]); i = i + 1; } putc('\n'); return i + 1; }
Add tests for ugly ternary operator
/* name: TEST041 description: Test for bug parsing ternary operators output: test041.c:36: error: type mismatch in conditional expression F1 I G2 F1 main { \ A3 I i A4 P p S6 foo M7 I i A8 S6 foo A3 A3 #I0 !I #W0 #W0 ?W gI :I A4 A3 #I0 !I #P0 #P0 ?P :P A4 A3 #I0 !I #P0 #P0 ?P :P A4 A3 #I0 !I #P0 #P0 ?P :P test041.c:36: error: incompatible types when assigning test041.c:37: error: used struct/union type value where scalar is required test041.c:38: warning: 'i' defined but not used test041.c:38: warning: 'foo' defined but not used */ int main(void) { int i; void *p; struct foo {int i;} foo; i = i ? 0 : 0l; p = i ? (void *) 0 : 0; p = i ? 0 : (void *) 0; p = i ? 0 : (const void *) 0; p = i ? 2 : p; foo ? 1 : 2; }
Fix invalid return value in API test
/*=== *** test1 (duk_safe_call) inherited value top at end: 0 ==> rc=0, result='undefined' ===*/ static duk_ret_t my_constructor(duk_context *ctx) { return 1; } static duk_ret_t test1(duk_context *ctx) { duk_push_global_object(ctx); duk_push_c_function(ctx, my_constructor, 0); /* constructor (function) */ duk_push_object(ctx); /* prototype object -> [ global cons proto ] */ duk_push_string(ctx, "inherited value"); duk_put_prop_string(ctx, -2, "inherited"); /* set proto.inherited = "inherited value" */ duk_put_prop_string(ctx, -2, "prototype"); /* set cons.prototype = proto; stack -> [ global cons ] */ duk_put_prop_string(ctx, -2, "MyConstructor"); /* set global.MyConstructor = cons; stack -> [ global ] */ duk_pop(ctx); duk_eval_string(ctx, "var obj = new MyConstructor(); print(obj.inherited);"); duk_pop(ctx); printf("top at end: %ld\n", (long) duk_get_top(ctx)); return 0; } void test(duk_context *ctx) { TEST_SAFE_CALL(test1); }
/*=== *** test1 (duk_safe_call) inherited value top at end: 0 ==> rc=0, result='undefined' ===*/ static duk_ret_t my_constructor(duk_context *ctx) { return 0; } static duk_ret_t test1(duk_context *ctx) { duk_push_global_object(ctx); duk_push_c_function(ctx, my_constructor, 0); /* constructor (function) */ duk_push_object(ctx); /* prototype object -> [ global cons proto ] */ duk_push_string(ctx, "inherited value"); duk_put_prop_string(ctx, -2, "inherited"); /* set proto.inherited = "inherited value" */ duk_put_prop_string(ctx, -2, "prototype"); /* set cons.prototype = proto; stack -> [ global cons ] */ duk_put_prop_string(ctx, -2, "MyConstructor"); /* set global.MyConstructor = cons; stack -> [ global ] */ duk_pop(ctx); duk_eval_string(ctx, "var obj = new MyConstructor(); print(obj.inherited);"); duk_pop(ctx); printf("top at end: %ld\n", (long) duk_get_top(ctx)); return 0; } void test(duk_context *ctx) { TEST_SAFE_CALL(test1); }
Add in a mechanism for interacting with the RMC llvm pass.
#ifndef RMC_CORE_H #define RMC_CORE_H #include "atomic.h" #ifdef HAS_RMC #error "no you don't" #else /* Dummy version that should work. */ #define XEDGE(x, y) do { } while (0) #define VEDGE(x, y) do { } while (0) /* Just stick a visibility barrier after every label. This isn't good * or anything, but it probably works. */ /* This is unhygenic in a nasty way. */ #define L(label, stmt) stmt; vis_barrier() #endif #endif
#ifndef RMC_CORE_H #define RMC_CORE_H #include "atomic.h" #ifdef HAS_RMC /* We signal our labels and edges to our LLVM pass in a *really* hacky * way to avoid needing to modify the frontend. Labelled statements * are wrapped in two goto labels to force them into their own basic * block (labelled statements don't fundamentally *need* to be in * their own basic block, but it makes things convenient) and edges * are specified by calling a dummy function __rmc_edge_register with * the labels as arguments (using computed goto to get the labels). * * This is really quite fragile; optimization passes will easily * destroy this information. The RMC pass should be run *before* any * real optimization passes are run but *after* mem2reg. */ extern void __rmc_edge_register(int is_vis, void *src, void *dst); #define RMC_EDGE(t, x, y) __rmc_edge_register(t, &&_rmc_##x, &&_rmc_##y) #define XEDGE(x, y) RMC_EDGE(0, x, y) #define VEDGE(x, y) RMC_EDGE(1, x, y) /* This is unhygenic in a nasty way. */ /* The (void)0s are because declarations can't directly follow labels, * apparently. */ #define L(label, stmt) \ _rmc_##label: (void)0; \ stmt; \ _rmc_end_##label: __attribute__((unused)) (void)0 #else /* Dummy version that should work. */ #define XEDGE(x, y) do { } while (0) #define VEDGE(x, y) do { } while (0) /* Just stick a visibility barrier after every label. This isn't good * or anything, but it probably works. */ /* This is unhygenic in a nasty way. */ #define L(label, stmt) stmt; vis_barrier() #endif /* HAS_RMC */ #endif
Add a greater-than-or-equal-to-zero assert to LOOKUP().
#ifndef MISC_H #define MISC_H #include <stdlib.h> #include <stdio.h> #include <assert.h> #include "types.h" #define ARR_LEN(a) (sizeof(a) / sizeof(a[0])) #define LOOKUP(key, table) (assert(key < ARR_LEN(table)), table[key]) static inline void* xmalloc(size_t s) { void* p = malloc(s); if (!p) { perror("malloc"); abort(); } return p; } static inline void* xcalloc(size_t s) { void* p = calloc(1, s); if (!p) { perror("calloc"); abort(); } return p; } static inline void xfree(void* p) { free(p); } extern struct config* config; #endif /* MISC_H */
#ifndef MISC_H #define MISC_H #include <stdlib.h> #include <stdio.h> #include <assert.h> #include "types.h" #define ARR_LEN(a) (sizeof(a) / sizeof(a[0])) #define LOOKUP(key, table) (assert(key < ARR_LEN(table)), \ assert(key >= 0), \ table[key]) static inline void* xmalloc(size_t s) { void* p = malloc(s); if (!p) { perror("malloc"); abort(); } return p; } static inline void* xcalloc(size_t s) { void* p = calloc(1, s); if (!p) { perror("calloc"); abort(); } return p; } static inline void xfree(void* p) { free(p); } extern struct config* config; #endif /* MISC_H */
Test for arithmetic on pointer to vla
// RUN: %check -e %s void init(int (*p)[]) { p[0][0] = 1; // CHECK: error: arithmetic on pointer to incomplete type int[] }
Add link to explanation of what we mean by zombie The person triaging / debugging a zombie crash may never have heard of this before.
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #define CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #pragma once #import <Foundation/Foundation.h> // You should think twice every single time you use anything from this // namespace. namespace ObjcEvilDoers { // Enable zombies. Returns NO if it fails to enable. // // When |zombieAllObjects| is YES, all objects inheriting from // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie // is queried to determine whether to make the object a zombie. // // |zombieCount| controls how many zombies to store before freeing the // oldest. Set to 0 to free objects immediately after making them // zombies. BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount); // Disable zombies. void ZombieDisable(); } // namespace ObjcEvilDoers @interface NSObject (CrZombie) - (BOOL)shouldBecomeCrZombie; @end #endif // CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #define CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #pragma once #import <Foundation/Foundation.h> // You should think twice every single time you use anything from this // namespace. namespace ObjcEvilDoers { // Enable zombie object debugging. This implements a variant of Apple's // NSZombieEnabled which can help expose use-after-free errors where messages // are sent to freed Objective-C objects in production builds. // // Returns NO if it fails to enable. // // When |zombieAllObjects| is YES, all objects inheriting from // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie // is queried to determine whether to make the object a zombie. // // |zombieCount| controls how many zombies to store before freeing the // oldest. Set to 0 to free objects immediately after making them // zombies. BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount); // Disable zombies. void ZombieDisable(); } // namespace ObjcEvilDoers @interface NSObject (CrZombie) - (BOOL)shouldBecomeCrZombie; @end #endif // CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
Use ofstreamTS to avoid touching the .gen.cc, .gen.h output if unchanged.
// emitcode.h see license.txt for copyright and terms of use // track state of emitted code so I can emit #line too #ifndef EMITCODE_H #define EMITCODE_H #include <fstream.h> // ofstream #include "str.h" // stringBuffer #include "srcloc.h" // SourceLoc class EmitCode : public stringBuilder { private: // data ofstream os; // stream to write to string fname; // filename for emitting #line int line; // current line number public: // funcs EmitCode(rostring fname); ~EmitCode(); string const &getFname() const { return fname; } // get current line number; flushes internally int getLine(); // flush data in stringBuffer to 'os' void flush(); }; // return a #line directive for the given location string lineDirective(SourceLoc loc); // emit a #line directive to restore reporting to the // EmitCode file itself (the 'sb' argument must be an EmitFile object) stringBuilder &restoreLine(stringBuilder &sb); #endif // EMITCODE_H
// emitcode.h see license.txt for copyright and terms of use // track state of emitted code so I can emit #line too #ifndef EMITCODE_H #define EMITCODE_H #include "str.h" // stringBuffer #include "srcloc.h" // SourceLoc #include "ofstreamts.h" // ofstreamTS class EmitCode : public stringBuilder { private: // data ofstreamTS os; // stream to write to string fname; // filename for emitting #line int line; // current line number public: // funcs EmitCode(rostring fname); ~EmitCode(); string const &getFname() const { return fname; } // get current line number; flushes internally int getLine(); // flush data in stringBuffer to 'os' void flush(); }; // return a #line directive for the given location string lineDirective(SourceLoc loc); // emit a #line directive to restore reporting to the // EmitCode file itself (the 'sb' argument must be an EmitFile object) stringBuilder &restoreLine(stringBuilder &sb); #endif // EMITCODE_H
Add extern "C" wrapper to main header, for C++
#ifndef __INSECT_H__ #define __INSECT_H__ #include "insect/crawler.h" #include "insect/records.h" /* basic file API */ #include "insect/file/stat.h" #ifdef USE_THREADS #include "insect/concurrent/thread.h" #endif /* USE_THREADS */ #endif /* __INSECT_H__ */
#ifndef __INSECT_H__ #define __INSECT_H__ #ifdef __cplusplus extern "C" { #endif /* C++ */ #include "insect/crawler.h" #include "insect/records.h" /* basic file API */ #include "insect/file/stat.h" #ifdef USE_THREADS #include "insect/concurrent/thread.h" #endif /* USE_THREADS */ #ifdef __cplusplus } /* extern "C" */ #endif /* C++ */ #endif /* __INSECT_H__ */
Remove unused code, keep in bx.
/* * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) * * This file is part of libbitcoin. * * libbitcoin is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LIBBITCOIN_COMPAT_H #define LIBBITCOIN_COMPAT_H #ifdef _MSC_VER // There is no <endian.h> for MSVC but it is always little endian. #ifndef __LITTLE_ENDIAN__ # undef __BIG_ENDIAN__ # define __LITTLE_ENDIAN__ #endif #endif #ifdef _MSC_VER // For SET_BINARY_FILE_MODE #include <fcntl.h> #include <io.h> #include <stdio.h> #endif // Sets the _fmode global variable, which controls the default translation // mode for file I/O operations. #ifdef _MSC_VER #define BC_SET_BINARY_FILE_MODE(mode) \ _setmode(_fileno(stdin), if_else(mode, _O_BINARY, _O_TEXT)) #else #define BC_SET_BINARY_FILE_MODE(mode) #endif #endif
/* * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) * * This file is part of libbitcoin. * * libbitcoin is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LIBBITCOIN_COMPAT_H #define LIBBITCOIN_COMPAT_H #ifdef _MSC_VER // There is no <endian.h> for MSVC but it is always little endian. #ifndef __LITTLE_ENDIAN__ # undef __BIG_ENDIAN__ # define __LITTLE_ENDIAN__ #endif #endif #endif
Add packed attribute to Config
#pragma once #include <Arduino.h> #include "stepper.h" enum StepMode : uint8_t { StepHalf = 1, StepFull = 2, StepBoth = 3 }; enum BrakeMode : uint8_t { BrakeNone = 0, BrakeAlways = 1, BrakeSmart = 2 }; struct Config { StepMode stepMode; BrakeMode brakeMode; uint32_t tickTime; uint32_t homeTime; uint32_t fixTime; int16_t maxSteps; // Maximale Anzahl an Schritten die die Firmware maximal machen darf (nach unten) int16_t homeSteps; int16_t fixSteps; // Anzahl an Schritten die die Firmware macht um eine Kugel nach unten zu fahren (ignoriert dabei maxSteps) uint16_t brakeTicks; uint16_t minStepDelta; // Unterschied zwischen derzeitiger Hhe und Zielhhe ab wann die Kugel bewegt werden soll }; extern Config config; // setzt die Standard Config void setDefaultConfig(); // prft Config auf invalide Werte boolean checkConfig(Config* config);
#pragma once #include <Arduino.h> #include "stepper.h" enum StepMode : uint8_t { StepHalf = 1, StepFull = 2, StepBoth = 3 }; enum BrakeMode : uint8_t { BrakeNone = 0, BrakeAlways = 1, BrakeSmart = 2 }; struct Config { StepMode stepMode; BrakeMode brakeMode; uint32_t tickTime; uint32_t homeTime; uint32_t fixTime; int16_t maxSteps; // Maximale Anzahl an Schritten die die Firmware maximal machen darf (nach unten) int16_t homeSteps; int16_t fixSteps; // Anzahl an Schritten die die Firmware macht um eine Kugel nach unten zu fahren (ignoriert dabei maxSteps) uint16_t brakeTicks; uint16_t minStepDelta; // Unterschied zwischen derzeitiger Hhe und Zielhhe ab wann die Kugel bewegt werden soll } __attribute__((__packed__)); extern Config config; // setzt die Standard Config void setDefaultConfig(); // prft Config auf invalide Werte boolean checkConfig(Config* config);
Test for arithmetic on pointer to vla
// RUN: %check -e %s void init(int (*p)[]) { p[0][0] = 1; // CHECK: error: arithmetic on pointer to incomplete type int[] }
Clean up converting float to double
# define RAD_TO_DEG 57.29577951308232087 /* 180/PI */ # define DEG_TO_RAD 0.0174532925199433 /* PI/180 */ VALUE mgrs_to_lat_long(VALUE klass) { VALUE mgrs_grid = rb_iv_get(klass, "@grid"); char* grid = StringValuePtr(mgrs_grid); double lat, lng; Convert_MGRS_To_Geodetic(grid, &lat, &lng); VALUE lat_lng_array = rb_ary_new(); rb_ary_push(lat_lng_array, rb_float_new(lat*RAD_TO_DEG)); rb_ary_push(lat_lng_array, rb_float_new(lng*RAD_TO_DEG)); return lat_lng_array; } VALUE lat_long_to_mgrs(VALUE klass) { VALUE iv_latitude = rb_funcall(rb_iv_get(klass, "@latitude" ), rb_intern("to_s"), 0), iv_longitude = rb_funcall(rb_iv_get(klass, "@longitude"), rb_intern("to_s"), 0); double latitude = rb_str_to_dbl(iv_latitude, Qfalse), longitude = rb_str_to_dbl(iv_longitude, Qfalse); char grid[15]; Convert_Geodetic_To_MGRS(latitude*DEG_TO_RAD, longitude*DEG_TO_RAD, 5, grid); return rb_str_new2(grid); }
# define RAD_TO_DEG 57.29577951308232087 /* 180/PI */ # define DEG_TO_RAD 0.0174532925199433 /* PI/180 */ VALUE mgrs_to_lat_long(VALUE klass) { VALUE mgrs_grid = rb_iv_get(klass, "@grid"); char* grid = StringValuePtr(mgrs_grid); double lat, lng; Convert_MGRS_To_Geodetic(grid, &lat, &lng); VALUE lat_lng_array = rb_ary_new(); rb_ary_push(lat_lng_array, rb_float_new(lat*RAD_TO_DEG)); rb_ary_push(lat_lng_array, rb_float_new(lng*RAD_TO_DEG)); return lat_lng_array; } VALUE lat_long_to_mgrs(VALUE klass) { double latitude = rb_num2dbl(rb_iv_get(klass, "@latitude")), longitude = rb_num2dbl(rb_iv_get(klass, "@longitude")); char grid[15]; Convert_Geodetic_To_MGRS(latitude*DEG_TO_RAD, longitude*DEG_TO_RAD, 5, grid); return rb_str_new2(grid); }
Fix ugly pointer return bug
#include "syshead.h" #include "tcp_socket.h" #define MAX_TCP_SOCKETS 128 static int cur_fd = 3; static struct tcp_socket tcp_sockets[MAX_TCP_SOCKETS]; void init_tcp_sockets() { memset(tcp_sockets, 0, sizeof(struct tcp_socket) * MAX_TCP_SOCKETS); } struct tcp_socket *alloc_tcp_socket() { struct tcp_socket *sock; for (int i = 0; i<MAX_TCP_SOCKETS; i++) { sock = &tcp_sockets[i]; if (sock->fd == 0) { sock->fd = cur_fd++; sock->state = CLOSED; return sock; } } /* No space left, error case */ return NULL; } void free_tcp_socket(struct tcp_socket *sock) { } struct tcp_socket *get_tcp_socket(int sockfd) { struct tcp_socket sk; for (int i = 0; i<MAX_TCP_SOCKETS; i++) { sk = tcp_sockets[i]; if (sk.fd == sockfd) return &sk; } return NULL; }
#include "syshead.h" #include "tcp_socket.h" #define MAX_TCP_SOCKETS 128 static int cur_fd = 3; static struct tcp_socket tcp_sockets[MAX_TCP_SOCKETS]; void init_tcp_sockets() { memset(tcp_sockets, 0, sizeof(struct tcp_socket) * MAX_TCP_SOCKETS); } struct tcp_socket *alloc_tcp_socket() { struct tcp_socket *sock; for (int i = 0; i<MAX_TCP_SOCKETS; i++) { sock = &tcp_sockets[i]; if (sock->fd == 0) { sock->fd = cur_fd++; sock->state = CLOSED; return sock; } } /* No space left, error case */ return NULL; } void free_tcp_socket(struct tcp_socket *sock) { } struct tcp_socket *get_tcp_socket(int sockfd) { struct tcp_socket *sk; for (int i = 0; i<MAX_TCP_SOCKETS; i++) { sk = &tcp_sockets[i]; if (sk->fd == sockfd) return sk; } return NULL; }
Rebuild with alias -- trying to fix commit error message
// // CMIDISequence+Debug.h // CMIDI // // Created by CHARLES GILLINGHAM on 9/20/15. // Copyright (c) 2015 CharlesGillingham. All rights reserved. // #import "CMIDISequence.h" @interface CMIDISequence (Debug) + (BOOL) testWithMessageList: (NSArray *) msgs; + (BOOL) testWithMIDIFile: (NSURL *) fileName; @end
Correct name of read_mostly section.
#ifndef _ASM_CRIS_ARCH_CACHE_H #define _ASM_CRIS_ARCH_CACHE_H #include <arch/hwregs/dma.h> /* A cache-line is 32 bytes. */ #define L1_CACHE_BYTES 32 #define L1_CACHE_SHIFT 5 #define __read_mostly __attribute__((__section__(".data.read_mostly"))) void flush_dma_list(dma_descr_data *descr); void flush_dma_descr(dma_descr_data *descr, int flush_buf); #define flush_dma_context(c) \ flush_dma_list(phys_to_virt((c)->saved_data)); void cris_flush_cache_range(void *buf, unsigned long len); void cris_flush_cache(void); #endif /* _ASM_CRIS_ARCH_CACHE_H */
#ifndef _ASM_CRIS_ARCH_CACHE_H #define _ASM_CRIS_ARCH_CACHE_H #include <arch/hwregs/dma.h> /* A cache-line is 32 bytes. */ #define L1_CACHE_BYTES 32 #define L1_CACHE_SHIFT 5 #define __read_mostly __attribute__((__section__(".data..read_mostly"))) void flush_dma_list(dma_descr_data *descr); void flush_dma_descr(dma_descr_data *descr, int flush_buf); #define flush_dma_context(c) \ flush_dma_list(phys_to_virt((c)->saved_data)); void cris_flush_cache_range(void *buf, unsigned long len); void cris_flush_cache(void); #endif /* _ASM_CRIS_ARCH_CACHE_H */
Update version number to 8.02.01-k6.
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2008 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.02.01-k5" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 2 #define QLA_DRIVER_PATCH_VER 1 #define QLA_DRIVER_BETA_VER 0
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2008 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.02.01-k6" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 2 #define QLA_DRIVER_PATCH_VER 1 #define QLA_DRIVER_BETA_VER 0
Fix up the embarassing mess of path seeding. Yikes. :(
/* Path handling. This was copied from Lua, with some minor adjustments. The biggest one is the lack of Windows support, because I don't have my Windows box setup for Lily yet (I'd rather make sure Windows works all at once). */ #define LILY_MAJOR "0" #define LILY_MINOR "13" #define LILY_VERSION_DIR LILY_MAJOR "." LILY_MINOR #define LILY_BASE_DIR "/usr/local/" #define LILY_SHARE_DIR LILY_ROOT "share/lua/" LUA_VDIR "/" #define LILY_CDIR LILY_ROOT "lib/lua/" LUA_VDIR "/" /* So, by default, Lily will attempt to load .lly files from these directories. */ #define LILY_PATH_SEED \ LILY_BASE_DIR "share/" LILY_VERSION_DIR "/;" \ LILY_BASE_DIR "lib/" LILY_VERSION_DIR "/;" \ "./;"
/* Path handling. This was copied from Lua, with some minor adjustments. The biggest one is the lack of Windows support, because I don't have my Windows box setup for Lily yet (I'd rather make sure Windows works all at once). */ #define LILY_MAJOR "0" #define LILY_MINOR "13" #define LILY_VERSION_DIR LILY_MAJOR "_" LILY_MINOR #define LILY_BASE_DIR "/usr/local/" #define LILY_SHARE_DIR LILY_BASE_DIR "share/lily/" LILY_VERSION_DIR "/" #define LILY_LIB_DIR LILY_BASE_DIR "lib/lily/" LILY_VERSION_DIR "/" /* This is where Lily will attempt to import new files from. If the parser is loading from a file, then the directory of the first file is added as the very last path to search. */ #define LILY_PATH_SEED \ LILY_SHARE_DIR ";" \ LILY_LIB_DIR ";" \ "./;"
Throw a more useful exceptoin when proxy connection fails.
#ifndef __HTTP_TUNNEL_H__ #define __HTTP_TUNNEL_H__ // Copyright (c) 2009 - Decho Corp. #include "auth.h" namespace HTTP { template <class T> Stream::ptr tunnel(T &conn, const std::string &proxy, const std::string &target) { Request requestHeaders; requestHeaders.requestLine.method = CONNECT; requestHeaders.requestLine.uri = target; requestHeaders.request.host = proxy; requestHeaders.general.connection.insert("Proxy-Connection"); requestHeaders.general.proxyConnection.insert("Keep-Alive"); ClientRequest::ptr request = conn.request(requestHeaders); if (request->response().status.status == HTTP::OK) { return request->stream(); } else { throw std::runtime_error("proxy connection failed"); } } } #endif
#ifndef __HTTP_TUNNEL_H__ #define __HTTP_TUNNEL_H__ // Copyright (c) 2009 - Decho Corp. #include "auth.h" namespace HTTP { template <class T> Stream::ptr tunnel(T &conn, const std::string &proxy, const std::string &target) { Request requestHeaders; requestHeaders.requestLine.method = CONNECT; requestHeaders.requestLine.uri = target; requestHeaders.request.host = proxy; requestHeaders.general.connection.insert("Proxy-Connection"); requestHeaders.general.proxyConnection.insert("Keep-Alive"); ClientRequest::ptr request = conn.request(requestHeaders); if (request->response().status.status == HTTP::OK) { return request->stream(); } else { throw InvalidResponseException("proxy connection failed", request->response()); } } } #endif
Return a QStringList wrapper instead of a python list in Converter::toPython.
namespace Shiboken { inline bool Converter<QStringList>::isConvertible(PyObject* pyObj) { return StdListConverter<QStringList>::isConvertible(pyObj); } inline QStringList Converter<QStringList>::toCpp(PyObject* pyObj) { return StdListConverter<QStringList>::toCpp(pyObj); } inline PyObject* Converter<QStringList>::toPython(const QStringList& cppObj) { return StdListConverter<QStringList>::toPython(cppObj); } }
namespace Shiboken { inline bool Converter<QStringList>::isConvertible(PyObject* pyObj) { return StdListConverter<QStringList>::isConvertible(pyObj); } inline QStringList Converter<QStringList>::toCpp(PyObject* pyObj) { return StdListConverter<QStringList>::toCpp(pyObj); } inline PyObject* Converter<QStringList>::toPython(const QStringList& cppObj) { return ValueTypeConverter<QStringList>::toPython(cppObj); } }
Make the UIAlertView unit test header consistent.
// // UIAlertViewBlocksKitTest.h // BlocksKit // // Created by Zachary Waldowski on 12/20/11. // Copyright (c) 2011 Dizzy Technology. All rights reserved. // #import <GHUnitIOS/GHUnit.h> #import "BlocksKit/BlocksKit.h" @interface UIAlertViewBlocksKitTest : GHTestCase @end
// // UIAlertViewBlocksKitTest.h // BlocksKit Unit Tests // #import <GHUnitIOS/GHUnit.h> #import "BlocksKit/BlocksKit.h" @interface UIAlertViewBlocksKitTest : GHTestCase - (void)testInit; - (void)testAddButtonWithHandler; - (void)testSetCancelButtonWithHandler; - (void)testDelegationBlocks; @end
Change the spec (comment) of th_validate()
/* * $Id: thinp.h,v 1.2 2001-05-17 17:58:56 thep Exp $ * thinp.h - Thai string input sequence filtering * Created: 2001-05-17 */ #ifndef THAI_THINP_H #define THAI_THINP_H #include <thai/thailib.h> BEGIN_CDECL /* * strictness of input sequence checking, according to WTT 2.0 */ typedef enum { ISC_PASSTHROUGH = 0, ISC_BASICCHECK = 1, ISC_STRICT = 2 } strict_t; /* * Is c2 allowed to be placed after c1? * Returns: non-zero if yes, 0 otherwise */ extern int th_iscompose(thchar_t c1, thchar_t c2, strict_t s); /* * Is c2 allowed to be placed after c1? And if not, swap them. * Returns: non-zero if the swap happenned, 0 otherwise */ extern int th_validate(thchar_t *c1, thchar_t *c2, strict_t s); END_CDECL #endif /* THAI_THINP_H */
/* * $Id: thinp.h,v 1.3 2001-05-17 18:15:04 thep Exp $ * thinp.h - Thai string input sequence filtering * Created: 2001-05-17 */ #ifndef THAI_THINP_H #define THAI_THINP_H #include <thai/thailib.h> BEGIN_CDECL /* * strictness of input sequence checking, according to WTT 2.0 */ typedef enum { ISC_PASSTHROUGH = 0, ISC_BASICCHECK = 1, ISC_STRICT = 2 } strict_t; /* * Is c2 allowed to be placed after c1? * Returns: non-zero if yes, 0 otherwise */ extern int th_iscompose(thchar_t c1, thchar_t c2, strict_t s); /* * Is *c2 allowed to be placed after *c1? And if not, and if swapping * them makes it valid, do it. * Returns: 1 if (*c1, *c2) is a valid sequence in the first place * 2 if (*c1, *c2) has been swapped and the sequence becomes valid * 0 if (*c1, *c2) is invalid, no matter how */ extern int th_validate(thchar_t *c1, thchar_t *c2, strict_t s); END_CDECL #endif /* THAI_THINP_H */
Fix imports for React Native 0.48.x.
#if __has_include("RCTBridgeModule.h") #import "RCTBridgeModule.h" #else #import <React/RCTBridgeModule.h> #endif #if __has_include("RCTEventEmitter.h") #import "RCTEventEmitter.h" #else #import <React/RCTEventEmitter.h> #endif @interface KontaktBeacons : RCTEventEmitter <RCTBridgeModule> @end
#if __has_include(<React/RCTBridgeModule.h>) #import <React/RCTBridgeModule.h> #else #import "RCTBridgeModule.h" #endif #if __has_include(<React/RCTEventEmitter.h>) #import <React/RCTEventEmitter.h> #else #import "RCTEventEmitter.h" #endif @interface KontaktBeacons : RCTEventEmitter <RCTBridgeModule> @end
Update the version number to 0.9 for a beta build.
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 6 #define CLIENT_VERSION_BUILD 2 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2013 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 9 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE false // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2014 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
Add a test for checking that custom diagnostic visitors are working.
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-output=text -verify %s // This file is for testing enhanced diagnostics produced by the default BugReporterVisitors. int getPasswordAndItem() { int err = 0; int *password; // expected-note {{Variable 'password' declared without an initial value}} if (password == 0) { // expected-warning {{The left operand of '==' is a garbage value}} // expected-note {{The left operand of '==' is a garbage value}} err = *password; } return err; }
Add a small C header file to wrap our assembly.
struct gcm_args { unsigned char* plaintext; unsigned int plain_len; unsigned char* additional_data; unsigned int additional_data_len; unsigned char* iv; unsigned char* expanded_key_ptr; unsigned char* ciphertext_ptr; unsigned char* tag_ptr; unsigned char* tmp_ptr; // Should point to a buffer of (at least) 8*64 bits }; extern void gcm_encrypt(struct gcm_args* args);
Add missing file from OptimizeARC => LLVMPasses transition.
//===--- LLVMARCOpts.h - LLVM level ARC Opts Utility Declarations ---------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// #include "swift/Basic/LLVM.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Function.h" #include "llvm/ADT/StringSwitch.h" namespace swift { enum RT_Kind { /// An instruction with this classification is known to not access (read or /// write) memory. RT_NoMemoryAccessed, /// SwiftHeapObject *swift_retain(SwiftHeapObject *object) RT_Retain, // void swift_retain_noresult(SwiftHeapObject *object) RT_RetainNoResult, // (i64,i64,i64) swift_retainAndReturnThree(SwiftHeapObject *obj, i64,i64,i64) RT_RetainAndReturnThree, /// void swift_release(SwiftHeapObject *object) RT_Release, /// SwiftHeapObject *swift_allocObject(SwiftHeapMetadata *metadata, /// size_t size, size_t alignment) RT_AllocObject, /// void objc_release(%objc_object* %P) RT_ObjCRelease, /// %objc_object* objc_retain(%objc_object* %P) RT_ObjCRetain, /// This is not a runtime function that we support. Maybe it is not a call, /// or is a call to something we don't care about. RT_Unknown, }; /// classifyInstruction - Take a look at the specified instruction and classify /// it into what kind of runtime entrypoint it is, if any. inline RT_Kind classifyInstruction(const llvm::Instruction &I) { if (!I.mayReadOrWriteMemory()) return RT_NoMemoryAccessed; // Non-calls or calls to indirect functions are unknown. auto *CI = dyn_cast<llvm::CallInst>(&I); if (CI == 0) return RT_Unknown; llvm::Function *F = CI->getCalledFunction(); if (F == 0) return RT_Unknown; return llvm::StringSwitch<RT_Kind>(F->getName()) .Case("swift_retain", RT_Retain) .Case("swift_retain_noresult", RT_RetainNoResult) .Case("swift_release", RT_Release) .Case("swift_allocObject", RT_AllocObject) .Case("swift_retainAndReturnThree", RT_RetainAndReturnThree) .Case("objc_release", RT_ObjCRelease) .Case("objc_retain", RT_ObjCRetain) .Default(RT_Unknown); } } // end namespace swift
Add a real test case for bitfield.
#include <check.h> #include "bitfield.h" START_TEST (test_foo) { fail_unless(1 == 2); } END_TEST Suite* bitfieldSuite(void) { Suite* s = suite_create("bitfield"); TCase *tc_core = tcase_create("core"); tcase_add_test(tc_core, test_foo); suite_add_tcase(s, tc_core); return s; } int main(void) { int numberFailed; Suite* s = bitfieldSuite(); SRunner *sr = srunner_create(s); srunner_run_all(sr, CK_NORMAL); numberFailed = srunner_ntests_failed(sr); srunner_free(sr); return (numberFailed == 0) ? 0 : 1; }
#include <check.h> #include <stdint.h> #include "bitfield.h" START_TEST (test_size) { uint8_t data = 0xFF; fail_unless(getBitField(&data, 0, 4) == 0xF); } END_TEST Suite* bitfieldSuite(void) { Suite* s = suite_create("bitfield"); TCase *tc_core = tcase_create("core"); tcase_add_test(tc_core, test_size); suite_add_tcase(s, tc_core); return s; } int main(void) { int numberFailed; Suite* s = bitfieldSuite(); SRunner *sr = srunner_create(s); srunner_run_all(sr, CK_NORMAL); numberFailed = srunner_ntests_failed(sr); srunner_free(sr); return (numberFailed == 0) ? 0 : 1; }
Add swap counting in bubbleSort
/* Author: Dan Wilder * * School: University of Missouri - St. Louis * Semester: Fall 2015 * Class: CS 3130 - Design and Analysis of Algorithms * Instructor: Galina N. Piatnitskaia */ #include "sort_algorithms.h" void swap(int *x, int *y) { int temp = *x; *x = *y *y = temp; } void bubbleSort(int arr[], int size) { /* with swaps counting. */ int i, j; for (i = 0; i <= size-1; ++i) for (j = size; j >= i+1; --j) if (arr[j] < arr[j-1]) swap(&arr[j], &arr[j-1]); }
/* Author: Dan Wilder * * School: University of Missouri - St. Louis * Semester: Fall 2015 * Class: CS 3130 - Design and Analysis of Algorithms * Instructor: Galina N. Piatnitskaia */ #include "sort_algorithms.h" void swap(int *x, int *y) { int temp = *x; *x = *y *y = temp; } void bubbleSort(int arr[], int size) { /* with swaps counting. */ int i, j, swaps; for (i = 0; i <= size-1; ++i) { swaps = 0; for (j = size; j >= i+1; --j) if (arr[j] < arr[j-1]) { swap(&arr[j], &arr[j-1]); ++swaps; } if (swaps == 0) break; } }
Add allocation helper macro ARCH_CACHE_BYTES()
#ifndef ARCH_CACHE_H #define ARCH_CACHE_H 1 #include "uuid.h" #include "record.h" #define ARCH_CACHE_MIN 31 typedef struct arch_cache_bucket { arch_uuid_t uuid; arch_record_t *record; struct arch_cache_bucket *next; } arch_cache_bucket_t; typedef struct arch_cache { struct arch_cache *old; size_t size, entries; arch_cache_bucket_t *slots[]; } arch_cache_t; arch_record_t *arch_cache_get(arch_cache_t *cache, arch_uuid_t uuid); bool arch_cache_set(arch_cache_t *cache, arch_record_t *record); #endif
#ifndef ARCH_CACHE_H #define ARCH_CACHE_H 1 #include "uuid.h" #include "record.h" #define ARCH_CACHE_MIN 31 typedef struct arch_cache_bucket { arch_uuid_t uuid; arch_record_t *record; struct arch_cache_bucket *next; } arch_cache_bucket_t; typedef struct arch_cache { struct arch_cache *old; size_t size, entries; arch_cache_bucket_t *slots[]; } arch_cache_t; #define ARCH_CACHE_BYTES(elts) (sizeof(arch_cache_t) + sizeof(arch_cache_bucket_t) * elts) arch_record_t *arch_cache_get(arch_cache_t *cache, arch_uuid_t uuid); bool arch_cache_set(arch_cache_t *cache, arch_record_t *record); #endif
Move CreateWindow undef to make its purpose more clear
#pragma once #include <ionMath.h> #include "CWindow.h" #undef CreateWindow enum class EWindowType { Fullscreen, Windowed }; class CWindowManager : public Singleton<CWindowManager>, public IEventListener { public: void Init(); void PollEvents(); bool ShouldClose() const; bool Run(); CWindow * CreateWindow(vec2i const & Size, std::string const & Title, EWindowType const Type); protected: CWindow * PrimaryWindow; std::map<GLFWwindow *, CWindow *> Windows; static void KeyCallback(GLFWwindow * window, int key, int scancode, int action, int mods); static void MouseButtonCallback(GLFWwindow * window, int button, int action, int mods); static void MouseScrollCallback(GLFWwindow * window, double xoffset, double yoffset); static void MouseCursorCallback(GLFWwindow * window, double xpos, double ypos); static void CharCallback(GLFWwindow * window, unsigned int c); private: friend class Singleton<CWindowManager>; CWindowManager(); };
#pragma once #include <ionMath.h> #include "CWindow.h" enum class EWindowType { Fullscreen, Windowed }; class CWindowManager : public Singleton<CWindowManager>, public IEventListener { public: void Init(); void PollEvents(); bool ShouldClose() const; bool Run(); #undef CreateWindow CWindow * CreateWindow(vec2i const & Size, std::string const & Title, EWindowType const Type); protected: CWindow * PrimaryWindow; std::map<GLFWwindow *, CWindow *> Windows; static void KeyCallback(GLFWwindow * window, int key, int scancode, int action, int mods); static void MouseButtonCallback(GLFWwindow * window, int button, int action, int mods); static void MouseScrollCallback(GLFWwindow * window, double xoffset, double yoffset); static void MouseCursorCallback(GLFWwindow * window, double xpos, double ypos); static void CharCallback(GLFWwindow * window, unsigned int c); private: friend class Singleton<CWindowManager>; CWindowManager(); };
Add an empty initialize implementation in order to avoid the compilation error
/****************************************************************************** * This file is part of the Gluon Development Platform * Copyright (c) 2011 Laszlo Papp <lpapp@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef GLUON_CREATOR_VCSTOOLPLUGIN_H #define GLUON_CREATOR_VCSTOOLPLUGIN_H #include <creator/lib/toolplugin.h> namespace GluonCreator { class VcsToolPlugin : public ToolPlugin { Q_OBJECT public: VcsToolPlugin( QObject* parent, const QList<QVariant>& params ); ~VcsToolPlugin(); protected: QWidget* createTool( KXmlGuiWindow* parent ); }; } #endif // GLUON_CREATOR_MESSAGEDOCKPLUGIN_H
/****************************************************************************** * This file is part of the Gluon Development Platform * Copyright (c) 2011 Laszlo Papp <lpapp@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef GLUON_CREATOR_VCSTOOLPLUGIN_H #define GLUON_CREATOR_VCSTOOLPLUGIN_H #include <creator/lib/toolplugin.h> namespace GluonCreator { class VcsToolPlugin : public ToolPlugin { Q_OBJECT public: VcsToolPlugin( QObject* parent, const QList<QVariant>& params ); ~VcsToolPlugin(); void initialize() {} protected: QWidget* createTool( KXmlGuiWindow* parent ); }; } #endif // GLUON_CREATOR_MESSAGEDOCKPLUGIN_H
Include ButtonNode in header file
#pragma once #include "misc/welcome.hpp" #include "misc/ota.hpp" #include "Bme280Node.hpp" #include "ContactNode.hpp" #include "DHT22Node.hpp" #include "RelayNode.hpp"
#pragma once #include "misc/welcome.hpp" #include "misc/ota.hpp" #include "Bme280Node.hpp" #include "ButtonNode.hpp" #include "ContactNode.hpp" #include "DHT22Node.hpp" #include "RelayNode.hpp"
Implement generic check of bitvec_to_int()
/* Unit tests for small utility routines. * * SCL; 2016 */ #include <stdlib.h> #include "common.h" #include "tests_common.h" #include "gr1c_util.h" int main( int argc, char **argv ) { vartype bv[] = {0,1,0,1}; if (bitvec_to_int( bv, 4 ) != 0xA) { ERRPRINT( "bitvec_to_int( [0,1,0,1], 4) != 0xA" ); abort(); } return 0; }
/* Unit tests for small utility routines. * * SCL; 2016 */ #include <stdlib.h> #include <assert.h> #include "common.h" #include "tests_common.h" #include "gr1c_util.h" void print_arr( FILE *fp, vartype *arr, int len ) { int k; assert( len > 0 ); fprintf( fp, "[" ); for (k = 0; k < len; k++) { fprintf( fp, "%d", arr[k] ); if (k < len-1) fprintf( fp, "," ); } fprintf( fp, "]" ); } void check_bitvec_to_int( vartype *bv, int len, int expected ) { if (bitvec_to_int( bv, len ) != expected) { ERRPRINT( "Unexpected return value of bitvec_to_int" ); fprintf( stderr, "bitvec_to_int( " ); print_arr( stderr, bv, len ); fprintf( stderr, ", %d ) != 0x%X\n\n", len, expected ); abort(); } } int main( int argc, char **argv ) { vartype bv_A[] = {0,1,0,1}; check_bitvec_to_int( bv_A, 4, 0xA ); return 0; }
Add function to combine multiple hash digests.
#ifndef VAST_UTIL_HASH_COMBINE_H #define VAST_UTIL_HASH_COMBINE_H #include <cstddef> namespace vast { namespace util { // Hashes 128-bit input down to 64 bits. // @note Taken from Google's CityHash; licence: MIT inline size_t hash_128_to_64(size_t upper, size_t lower) { static size_t const k_mul = 0x9ddfea08eb382d69ull; auto a = (lower ^ upper) * k_mul; a ^= (a >> 47); auto b = (upper ^ a) * k_mul; b ^= (b >> 47); b *= k_mul; return b; } /// Convenience function to combine multiple hash digests. /// @param x The value to hash. /// @returns The hash value of *x*. template <typename T> size_t hash_combine(T const& x) { return std::hash<T>{}(x); } /// Combines multiple hash digests. /// @param x The first value to hash. /// @param xs The remaining values to hash and combine with *x*. /// @returns The combined hash value of *x* and all *xs*. template <typename T, typename... Ts> size_t hash_combine(T const& x, Ts const&... xs) { return hash_128_to_64(hash_combine(x), hash_combine(xs...)); } } // namespace util } // namespace vast #endif
Fix -march= name for x86-64.
// RUN: %llvmgcc %s -c -Os -m32 -emit-llvm -o - | llc -march=x86 -mtriple=i386-apple-darwin10 | FileCheck %s -check-prefix=DARWIN32 // RUN: %llvmgcc %s -c -Os -m64 -emit-llvm -o - | llc -march=x86_64 -mtriple=x86_64-apple-darwin10 | FileCheck %s -check-prefix=DARWIN64 extern void func(const char *, const char *); void long_function_name() { func("%s: the function name", __func__); } // DARWIN64: .align 3 // DARWIN64: ___func__. // DARWIN64: .asciz "long_function_name" // DARWIN32: .align 2 // DARWIN32: ___func__. // DARWIN32: .asciz "long_function_name"
// RUN: %llvmgcc %s -c -Os -m32 -emit-llvm -o - | llc -march=x86 -mtriple=i386-apple-darwin10 | FileCheck %s -check-prefix=DARWIN32 // RUN: %llvmgcc %s -c -Os -m64 -emit-llvm -o - | llc -march=x86-64 -mtriple=x86_64-apple-darwin10 | FileCheck %s -check-prefix=DARWIN64 extern void func(const char *, const char *); void long_function_name() { func("%s: the function name", __func__); } // DARWIN64: .align 3 // DARWIN64: ___func__. // DARWIN64: .asciz "long_function_name" // DARWIN32: .align 2 // DARWIN32: ___func__. // DARWIN32: .asciz "long_function_name"
Add missing include; fixes build break
namespace opencog { // This type is returned from the agent_finder_api when loading a python module // containing agents or requests struct requests_and_agents_t { std::vector<std::string> agents; std::vector<std::string> requests; std::vector<std::string> req_summary; std::vector<std::string> req_description; std::vector<bool> req_is_shell; std::string err_string; }; }
#include <opencog/atomspace/AtomSpace.h> namespace opencog { // This type is returned from the agent_finder_api when loading a python module // containing agents or requests struct requests_and_agents_t { std::vector<std::string> agents; std::vector<std::string> requests; std::vector<std::string> req_summary; std::vector<std::string> req_description; std::vector<bool> req_is_shell; std::string err_string; }; }
Implement Exercise 5-10 for multiplication
#include <stdio.h> #include <ctype.h> #include <stdlib.h> // Exercise 5-11 #define MAX 1000 int pop(void); void push(int n); int main(int argc, char *argv[]) { while (--argc > 0 && argv++ != NULL) { printf("%s\n", *argv); if(*argv[0] == '+') { push(pop() + pop()); } else if(*argv[0] == '-') { int x = pop(); push(pop() - x); } // else if(*argv[0] == '*') // { // int x = pop(); // push(pop() * x); // } else if(*argv[0] == '/') { int x = pop(); push(pop() / x); } else { push(atoi(*argv)); } } printf("%i\n", pop()); return 0; } // Push & Pop Functions static int stack[MAX]; int *sp = stack; int pop(void) { return *--sp; } void push(int n) { *sp++ = n; }
#include <stdio.h> #include <ctype.h> #include <stdlib.h> // Exercise 5-11 #define MAX 1000 int pop(void); void push(int n); int main(int argc, char *argv[]) { while (--argc > 0 && argv++ != NULL) { printf("%s\n", *argv); if(*argv[0] == '+') { push(pop() + pop()); } else if(*argv[0] == '-') { int x = pop(); push(pop() - x); } // * needed to be entered as '*' in the command line else if(*argv[0] == '*') { int x = pop(); push(pop() * x); } else if(*argv[0] == '/') { int x = pop(); push(pop() / x); } else { push(atoi(*argv)); } } printf("%i\n", pop()); return 0; } // Push & Pop Functions static int stack[MAX]; int *sp = stack; int pop(void) { return *--sp; } void push(int n) { *sp++ = n; }
Add Resharper printf argument type checking and formatting to Log()
#ifndef _LOG_H #define _LOG_H #include "_global.h" void Log(const char* format, ...); #endif
#ifndef _LOG_H #define _LOG_H #include "_global.h" #if defined(__RESHARPER__) #define PRINTF_ATTR(FormatIndex, FirstToCheck) \ [[gnu::format(printf, FormatIndex, FirstToCheck)]] #elif defined(__GNUC__) #define PRINTF_ATTR(FormatIndex, FirstToCheck) \ __attribute__((format(printf, FormatIndex, FirstToCheck))) #else #define PRINTF_ATTR(FormatIndex, FirstToCheck) #endif PRINTF_ATTR(1, 2) void Log(const char* format, ...); #endif
Write usage() message on stderr.
#define _XOPEN_SOURCE 500 #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include "arg.h" char *argv0; void usage() { printf("usage: %s [-t usec] [-F]\n", argv0); exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { char buffer; size_t nread; useconds_t useconds = 1000000; // default 1 second unsigned int flush = 0; ARGBEGIN { case 't': useconds = atoi(EARGF(usage())); break; case 'F': flush = 1; break; default: usage(); } ARGEND; while((nread = fread(&buffer, 1, sizeof buffer, stdin)) > 0) { usleep(useconds); fwrite(&buffer, 1, nread, stdout); if(flush) { fflush(stdout); } } return EXIT_SUCCESS; }
#define _XOPEN_SOURCE 500 #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include "arg.h" char *argv0; void usage() { fprintf(stderr, "usage: %s [-t usec] [-F]\n", argv0); exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { char buffer; size_t nread; useconds_t useconds = 1000000; // default 1 second unsigned int flush = 0; ARGBEGIN { case 't': useconds = atoi(EARGF(usage())); break; case 'F': flush = 1; break; default: usage(); } ARGEND; while((nread = fread(&buffer, 1, sizeof buffer, stdin)) > 0) { usleep(useconds); fwrite(&buffer, 1, nread, stdout); if(flush) { fflush(stdout); } } return EXIT_SUCCESS; }
Add character string comment test
int main() { // Issue: 3: error: empty character constant ''; // Issue: 6: error: multiple characters in character constant 'ab'; }
int main() { // Issue: 3: error: empty character constant ''; // Issue: 6: error: multiple characters in character constant 'ab'; // Issue: 9: error: multiple characters in character constant '/*'; }
Add macros for min and max
#ifndef __EULER__ #define __EULER__ #define KNRM "\x1B[0m" #define KRED "\x1B[31m" #define KGRN "\x1B[32m" int check(int, int, int); void error(const char *str); #endif
#ifndef __EULER__ #define __EULER__ #define KNRM "\x1B[0m" #define KRED "\x1B[31m" #define KGRN "\x1B[32m" #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) int check(int, int, int); void error(const char *str); #endif
Remove inclusion of a non-existing header file
#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "spellutil.h" #include "dictionary.h" typedef struct word_count { int value; } count; int parse_file(const char *filename, spell_hashtable *table) { FILE *file = fopen(filename, "r"); int _errno; char *line = NULL; size_t len = 0; ssize_t read; char *word; count *c; count default_count; default_count.value = 1; if (file == NULL) { _errno = errno; fprintf(stderr, "fopen failed for file %s", filename); return errno; } while ((read = getline(&line, &len, file)) != -1) { while ((word = strchr(line, ' ')) != NULL) { c = (count *) spell_hashtable_get(table, word); if (c == NULL) { spell_hashtable_add(table, word, &default_count); } else { c->value++; spell_hashtable_add(table, word, c); } free(line); } } fclose(file); return 0; }
#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "spellutil.h" typedef struct word_count { int value; } count; int parse_file(const char *filename, spell_hashtable *table) { FILE *file = fopen(filename, "r"); int _errno; char *line = NULL; size_t len = 0; ssize_t read; char *word; count *c; count default_count; default_count.value = 1; if (file == NULL) { _errno = errno; fprintf(stderr, "fopen failed for file %s", filename); return errno; } while ((read = getline(&line, &len, file)) != -1) { while ((word = strchr(line, ' ')) != NULL) { c = (count *) spell_hashtable_get(table, word); if (c == NULL) { spell_hashtable_add(table, word, &default_count); } else { c->value++; spell_hashtable_add(table, word, c); } free(line); } } fclose(file); return 0; }
Remove conditional branch in IRQ handler
#include <irq.h> void irq_enable() { __asm__ __volatile__ ( "mrs r0, cpsr\n" "bic r0, r0, #0x80\n" "msr cpsr, r0\n" ); } void irq_disable() { __asm__ __volatile__ ( "mrs r0, cpsr\n" "orr r0, #0xc0\n" "msr cpsr, r0\n" ); } void handler_swi() { uart0_send("In SWI!\n"); irq_enable(); } void handler_irq() { volatile unsigned int *reg = (unsigned int *) PIC_IRQ_STATUS; switch (*reg) { case PIC_UART0_BIT: uart0_irq_handler(); break; } #if 0 __asm__ __volatile__ ( "mrs r0, cpsr\n" "bic r0, r0, #0x1F\n" "orr r0, r0, #0x12\n" // enter SVC mode "msr cpsr, r0\n" "subs pc, lr, #4\n" ); #endif }
#include <irq.h> #include <uart.h> void (*pl190_isr_vectors[IRQ_COUNT])(void) = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, uart0_irq_handler, 0, 0, 0 }; void irq_enable() { __asm__ __volatile__ ( "mrs r0, cpsr\n" "bic r0, r0, #0x80\n" "msr cpsr, r0\n" ); } void irq_disable() { __asm__ __volatile__ ( "mrs r0, cpsr\n" "orr r0, #0xc0\n" "msr cpsr, r0\n" ); } void handler_swi() { uart0_send("In SWI!\n"); irq_enable(); } void handler_irq() { unsigned int reg_irq_status = *((volatile unsigned int *) PIC_IRQ_STATUS); int irq_n = 0; while (reg_irq_status >>= 1) irq_n++; pl190_isr_vectors[irq_n](); }
Update test case for llvm summary format changes in D17592.
// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s // CHECK: <FUNCTION_SUMMARY_BLOCK // CHECK-NEXT: <PERMODULE_ENTRY // CHECK-NEXT: <PERMODULE_ENTRY // CHECK-NEXT: </FUNCTION_SUMMARY_BLOCK __attribute__((noinline)) void foo() {} int main() { foo(); }
// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s // CHECK: <GLOBALVAL_SUMMARY_BLOCK // CHECK-NEXT: <PERMODULE // CHECK-NEXT: <PERMODULE // CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK __attribute__((noinline)) void foo() {} int main() { foo(); }
Add Gradient* codec header to all-codecs header
#pragma once #include "AbsWrapperCodec.h" #include "AddWrapperCodec.h" #include "BillowWrapperCodec.h" #include "BlendWrapperCodec.h" #include "CacheWrapperCodec.h" #include "CheckerboardWrapperCodec.h" #include "ClampWrapperCodec.h" #include "ConstWrapperCodec.h" #include "CornerCombinerBaseWrapperCodec.h" #include "CurveWrapperCodec.h" #include "CylindersWrapperCodec.h" #include "DisplaceWrapperCodec.h" #include "ExpWrapperCodec.h" #include "ExponentWrapperCodec.h" #include "ForwardWrapperCodec.h" #include "InvertWrapperCodec.h" #include "MaxWrapperCodec.h" #include "MinWrapperCodec.h" #include "MultiplyWrapperCodec.h" #include "NormLPQWrapperCodec.h" #include "NoiseSourcesCodec.h" #include "PerlinWrapperCodec.h" #include "PowWrapperCodec.h" #include "PowerWrapperCodec.h" #include "RidgedMultiWrapperCodec.h" #include "RotatePointWrapperCodec.h" #include "ScaleBiasWrapperCodec.h" #include "ScalePointCodec.h" #include "SelectWrapperCodec.h" #include "SpheresWrapperCodec.h" #include "TerraceWrapperCodec.h" #include "TranslatePointWrapperCodec.h" #include "TurbulenceWrapperCodec.h" #include "VoronoiWrapperCodec.h"
#pragma once #include "AbsWrapperCodec.h" #include "AddWrapperCodec.h" #include "BillowWrapperCodec.h" #include "BlendWrapperCodec.h" #include "CacheWrapperCodec.h" #include "CheckerboardWrapperCodec.h" #include "ClampWrapperCodec.h" #include "ConstWrapperCodec.h" #include "CornerCombinerBaseWrapperCodec.h" #include "CurveWrapperCodec.h" #include "CylindersWrapperCodec.h" #include "DisplaceWrapperCodec.h" #include "ExpWrapperCodec.h" #include "ExponentWrapperCodec.h" #include "ForwardWrapperCodec.h" #include "GradientWrapperCodec.h" #include "InvertWrapperCodec.h" #include "MaxWrapperCodec.h" #include "MinWrapperCodec.h" #include "MultiplyWrapperCodec.h" #include "NormLPQWrapperCodec.h" #include "NoiseSourcesCodec.h" #include "PerlinWrapperCodec.h" #include "PowWrapperCodec.h" #include "PowerWrapperCodec.h" #include "RidgedMultiWrapperCodec.h" #include "RotatePointWrapperCodec.h" #include "ScaleBiasWrapperCodec.h" #include "ScalePointCodec.h" #include "SelectWrapperCodec.h" #include "SpheresWrapperCodec.h" #include "TerraceWrapperCodec.h" #include "TranslatePointWrapperCodec.h" #include "TurbulenceWrapperCodec.h" #include "VoronoiWrapperCodec.h"
Revert 75430 because it's causing failures in dom_checker_tests. : Increase the minimum interval for timers on background tabs to reduce their CPU consumption.
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_ #define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_ namespace webkit_glue { // Chromium sets the minimum interval timeout to 4ms, overriding the // default of 10ms. We'd like to go lower, however there are poorly // coded websites out there which do create CPU-spinning loops. Using // 4ms prevents the CPU from spinning too busily and provides a balance // between CPU spinning and the smallest possible interval timer. const double kForegroundTabTimerInterval = 0.004; // Provides control over the minimum timer interval for background tabs. const double kBackgroundTabTimerInterval = 1.0; } // namespace webkit_glue #endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_ #define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_ namespace webkit_glue { // Chromium sets the minimum interval timeout to 4ms, overriding the // default of 10ms. We'd like to go lower, however there are poorly // coded websites out there which do create CPU-spinning loops. Using // 4ms prevents the CPU from spinning too busily and provides a balance // between CPU spinning and the smallest possible interval timer. const double kForegroundTabTimerInterval = 0.004; // Provides control over the minimum timer interval for background tabs. const double kBackgroundTabTimerInterval = 0.004; } // namespace webkit_glue #endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
Clean up test, use proper structuring functions
#include "openflow_flowtable.h" #include "mut.h" #include <stdint.h> #include "common_def.h" extern void openflow_flowtable_set_defaults(void); extern uint8_t openflow_flowtable_ip_compare(uint32_t ip_1, uint32_t ip_2, uint8_t ip_len); TESTSUITE_BEGIN TEST_BEGIN("Flowtable Modification") openflow_flowtable_init(); ofp_flow_mod mod; uint16_t error_code, error_type; mod.flags = OFPFF_SEND_FLOW_REM; mod.command = OFPFC_ADD; mod.match.wildcards = OFPFW_ALL; mod.out_port = OFPP_NONE; openflow_flowtable_modify(&mod, &error_type, &error_code); openflow_flowtable_release(); TEST_END TESTSUITE_END
#include "openflow_flowtable.h" #include "mut.h" #include <stdint.h> #include "common_def.h" extern void openflow_flowtable_set_defaults(void); extern uint8_t openflow_flowtable_ip_compare(uint32_t ip_1, uint32_t ip_2, uint8_t ip_len); TESTSUITE_BEGIN TEST_BEGIN("Flowtable Modification") openflow_flowtable_init(); ofp_flow_mod mod; uint16_t error_code, error_type; memset(&mod, 0, sizeof(ofp_flow_mod)); mod.flags = htons(OFPFF_SEND_FLOW_REM); mod.command = htons(OFPFC_ADD); mod.match.wildcards = htons(OFPFW_ALL); mod.out_port = htons(OFPP_NONE); mod.header.length = htons(0); mod.priority = htons(19); openflow_flowtable_modify(&mod, &error_type, &error_code); openflow_flowtable_release(); TEST_END TESTSUITE_END
Add some synchronization modes to reflection view along with a context menu.
#pragma once #include <QtGui/QMouseEvent> #include <QtGui/QPaintEvent> #include <QtWidgets/QWidget> #include "binaryninjaapi.h" #include "dockhandler.h" #include "uitypes.h" class ContextMenuManager; class DisassemblyContainer; class Menu; class ViewFrame; class BINARYNINJAUIAPI ReflectionView: public QWidget, public DockContextHandler { Q_OBJECT Q_INTERFACES(DockContextHandler) ViewFrame* m_frame; BinaryViewRef m_data; DisassemblyContainer* m_disassemblyContainer; public: ReflectionView(ViewFrame* frame, BinaryViewRef data); ~ReflectionView(); virtual void notifyViewLocationChanged(View* view, const ViewLocation& viewLocation) override; virtual void notifyVisibilityChanged(bool visible) override; virtual bool shouldBeVisible(ViewFrame* frame) override; protected: virtual void contextMenuEvent(QContextMenuEvent* event) override; };
#pragma once #include <QtGui/QMouseEvent> #include <QtGui/QPaintEvent> #include <QtWidgets/QWidget> #include "binaryninjaapi.h" #include "dockhandler.h" #include "uitypes.h" class ContextMenuManager; class DisassemblyContainer; class Menu; class ViewFrame; class BINARYNINJAUIAPI ReflectionView: public QWidget, public DockContextHandler { Q_OBJECT Q_INTERFACES(DockContextHandler) ViewFrame* m_frame; BinaryViewRef m_data; DisassemblyContainer* m_disassemblyContainer; std::map<BNFunctionGraphType, BNFunctionGraphType> m_ilMap; bool m_ilSync; bool m_locationSync; public: ReflectionView(ViewFrame* frame, BinaryViewRef data); ~ReflectionView(); void toggleILSync(); void toggleLocationSync(); virtual void notifyViewLocationChanged(View* view, const ViewLocation& viewLocation) override; virtual void notifyVisibilityChanged(bool visible) override; virtual bool shouldBeVisible(ViewFrame* frame) override; protected: virtual void contextMenuEvent(QContextMenuEvent* event) override; };
Print exceptions to console if exist.
/* * driver - driver for loading mruby source code */ #include <stdio.h> #include "mruby.h" #include "mruby/compile.h" #include "mruby/irep.h" /* The generated mruby bytecodes are stored in this array */ extern const char app_irep[]; int webruby_internal_run(mrb_state* mrb) { mrb_load_irep(mrb, app_irep); return (mrb->exc == NULL) ? (0) : (1); } int webruby_internal_run_bytecode(mrb_state* mrb, const char *bc) { mrb_load_irep(mrb, bc); return (mrb->exc == NULL) ? (0) : (1); } int webruby_internal_run_source(mrb_state* mrb, const char *s) { mrb_load_string(mrb, s); return (mrb->exc == NULL) ? (0) : (1); }
/* * driver - driver for loading mruby source code */ #include <stdio.h> #include "mruby.h" #include "mruby/compile.h" #include "mruby/irep.h" /* The generated mruby bytecodes are stored in this array */ extern const char app_irep[]; static int check_and_print_errors(mrb_state* mrb) { if (mrb->exc) { mrb_p(mrb, mrb_obj_value(mrb->exc)); return 1; } return 0; } int webruby_internal_run(mrb_state* mrb) { mrb_load_irep(mrb, app_irep); return check_and_print_errors(mrb); } int webruby_internal_run_bytecode(mrb_state* mrb, const char *bc) { mrb_load_irep(mrb, bc); return check_and_print_errors(mrb); } int webruby_internal_run_source(mrb_state* mrb, const char *s) { mrb_load_string(mrb, s); return check_and_print_errors(mrb); }
Add milliseconds to timeval test
#include <stdlib.h> #include <time.h> #include <detest/detest.h> #include <disco/time.h> void test_zero_milliseconds_to_timeval() { size_t milliseconds = 0; struct timeval t = milliseconds_to_timeval(milliseconds); expect(t.tv_sec == 0 && t.tv_usec == 0); } void test_one_millisecond_to_timeval() { size_t milliseconds = 1; struct timeval t = milliseconds_to_timeval(milliseconds); expect(t.tv_sec == 0 && t.tv_usec == 1000); } void test_one_thousand_milliseconds_to_timeval() { size_t milliseconds = 1000; struct timeval t = milliseconds_to_timeval(milliseconds); expect(t.tv_sec == 1 && t.tv_usec == 0); } int main() { add_test(test_zero_milliseconds_to_timeval); add_test(test_one_millisecond_to_timeval); add_test(test_one_thousand_milliseconds_to_timeval); return run_tests(); }
#include <stdlib.h> #include <time.h> #include <detest/detest.h> #include <disco/time.h> void test_zero_milliseconds_to_timeval() { size_t milliseconds = 0; struct timeval t = milliseconds_to_timeval(milliseconds); expect(t.tv_sec == 0 && t.tv_usec == 0); } void test_one_millisecond_to_timeval() { size_t milliseconds = 1; struct timeval t = milliseconds_to_timeval(milliseconds); expect(t.tv_sec == 0 && t.tv_usec == 1000); } void test_one_thousand_milliseconds_to_timeval() { size_t milliseconds = 1000; struct timeval t = milliseconds_to_timeval(milliseconds); expect(t.tv_sec == 1 && t.tv_usec == 0); } void test_one_thousand_and_one_milliseconds_to_timeval() { size_t milliseconds = 1001; struct timeval t = milliseconds_to_timeval(milliseconds); expect(t.tv_sec == 1 && t.tv_usec == 1000); } int main() { add_test(test_zero_milliseconds_to_timeval); add_test(test_one_millisecond_to_timeval); add_test(test_one_thousand_milliseconds_to_timeval); add_test(test_one_thousand_and_one_milliseconds_to_timeval); return run_tests(); }
Fix wrong pins header from being included, add mask to DAC control register
/* * This file is part of GreatFET */ #include "usb_api_dac.h" #include "usb.h" #include "usb_queue.h" #include "usb_endpoint.h" #include <stddef.h> #include <greatfet_core.h> #include <dac.h> #include <pins_greatfet.h> usb_request_status_t usb_vendor_request_dac_set( usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage) { usb_endpoint_init(&usb0_endpoint_bulk_in); if (stage == USB_TRANSFER_STAGE_SETUP) { // set J2_P5 up as a DAC pin scu_pinmux(SCU_PINMUX_GPIO2_3, SCU_GPIO_FAST | SCU_GPIO_PUP | SCU_CONF_FUNCTION0); static struct gpio_t dac_pin = GPIO(2, 3); gpio_input(&dac_pin); DAC_CR = DAC_CR_VALUE(endpoint->setup.value); DAC_CTRL = DAC_CTRL_DMA_ENA(1); usb_transfer_schedule_ack(endpoint->in); } return USB_REQUEST_STATUS_OK; }
/* * This file is part of GreatFET */ #include "usb_api_dac.h" #include "usb.h" #include "usb_queue.h" #include "usb_endpoint.h" #include <stddef.h> #include <greatfet_core.h> #include <dac.h> #include <pins.h> usb_request_status_t usb_vendor_request_dac_set( usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage) { usb_endpoint_init(&usb0_endpoint_bulk_in); if (stage == USB_TRANSFER_STAGE_SETUP) { // set J2_P5 up as a DAC pin scu_pinmux(SCU_PINMUX_GPIO2_3, SCU_GPIO_FAST | SCU_GPIO_PUP | SCU_CONF_FUNCTION0); static struct gpio_t dac_pin = GPIO(2, 3); gpio_input(&dac_pin); DAC_CR = DAC_CR_VALUE(endpoint->setup.value) && DAC_CR_VALUE_MASK; DAC_CTRL = DAC_CTRL_DMA_ENA(1); usb_transfer_schedule_ack(endpoint->in); } return USB_REQUEST_STATUS_OK; }
Add terminal to common widgets
/** * @file BlynkWidgets.h * @author Volodymyr Shymanskyy * @license This project is released under the MIT License (MIT) * @copyright Copyright (c) 2015 Volodymyr Shymanskyy * @date Mar 2015 * @brief */ #include "WidgetLED.h" #include "WidgetLCD.h" //#include <WidgetTerminal.h> // No Print.h on Spark? #include "WidgetBridge.h" // Cannot auto-include WidgetSD, as it has library dependency
/** * @file BlynkWidgets.h * @author Volodymyr Shymanskyy * @license This project is released under the MIT License (MIT) * @copyright Copyright (c) 2015 Volodymyr Shymanskyy * @date Mar 2015 * @brief */ #include "WidgetLED.h" #include "WidgetLCD.h" #include "WidgetTerminal.h" #include "WidgetBridge.h" // Cannot auto-include WidgetSD, as it has library dependency
Fix mispelled separate compilation macro.
#ifndef _NPY_PRIVATE_BUFFER_H_ #define _NPY_PRIVATE_BUFFER_H_ #ifdef NPY_ENABLE_MULTIPLE_COMPILATION extern NPY_NO_EXPORT PyBufferProcs array_as_buffer; #else NPY_NO_EXPORT PyBufferProcs array_as_buffer; #endif #endif
#ifndef _NPY_PRIVATE_BUFFER_H_ #define _NPY_PRIVATE_BUFFER_H_ #ifdef NPY_ENABLE_SEPARATE_COMPILATION extern NPY_NO_EXPORT PyBufferProcs array_as_buffer; #else NPY_NO_EXPORT PyBufferProcs array_as_buffer; #endif #endif
Fix for include path slighlty incorrect
/* Copyright (c) 2008, Stig Brautaset. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #import <Statistics/SBStatistics.h>
/* Copyright (c) 2008, Stig Brautaset. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #import "SBStatistics.h"
Add virtual functions to handle mouse movments and Resize
/* The Halfling Project - A Graphics Engine and Projects * * The Halfling Project is the legal property of Adrian Astley * Copyright Adrian Astley 2013 */ #ifndef GAME_STATE_MANAGER_H #define GAME_STATE_MANAGER_H namespace Common { class GameStateManagerBase { public: virtual bool Initialize() = 0; virtual void Shutdown() = 0; /** * Return the wanted period of time between update() calls. * * IE: If you want update to be called 20 times a second, this * should return 50. * * NOTE: This should probably be inlined. * NOTE: This will only be called at the beginning of HalflingEngine::Run() * TODO: Contemplate the cost/benefit of calling this once per frame * * @return The period in milliseconds */ virtual double GetUpdatePeriod() = 0; /** * Called every time the game logic should be updated. The frequency * of this being called is determined by getUpdatePeriod() */ virtual void Update() = 0; virtual void GamePaused() = 0; virtual void GameUnpaused() = 0; }; } // End of namespace Common #endif
/* The Halfling Project - A Graphics Engine and Projects * * The Halfling Project is the legal property of Adrian Astley * Copyright Adrian Astley 2013 */ #ifndef GAME_STATE_MANAGER_H #define GAME_STATE_MANAGER_H namespace Common { class GameStateManagerBase { public: virtual bool Initialize() = 0; virtual void Shutdown() = 0; /** * Return the wanted period of time between update() calls. * * IE: If you want update to be called 20 times a second, this * should return 50. * * NOTE: This should probably be inlined. * NOTE: This will only be called at the beginning of HalflingEngine::Run() * TODO: Contemplate the cost/benefit of calling this once per frame * * @return The period in milliseconds */ virtual double GetUpdatePeriod() = 0; /** * Called every time the game logic should be updated. The frequency * of this being called is determined by getUpdatePeriod() */ virtual void Update() = 0; virtual void OnResize(int newClientWidth, int newClientHeight) = 0; virtual void GamePaused() = 0; virtual void GameUnpaused() = 0; virtual void MouseDown(WPARAM buttonState, int x, int y) = 0; virtual void MouseUp(WPARAM buttonState, int x, int y) = 0; virtual void MouseMove(WPARAM buttonState, int x, int y) = 0; virtual void MouseWheel(int zDelta) = 0; }; } // End of namespace Common #endif
Fix missing namespace qualification in classify macros
#pragma once /// Tags the current test case if the specified condition is true. If any tags /// are specified after the condition, those will be used. Otherwise, a string /// version of the condition itself will be used as the tag. #define RC_CLASSIFY(condition, ...) \ do { \ if (condition) { \ detail::classify(#condition, {__VA_ARGS__}); \ } \ } while (false) /// Tags the current test case with the given values which will be converted to /// strings. #define RC_TAG(...) detail::tag({__VA_ARGS__}) #include "Classify.hpp"
#pragma once /// Tags the current test case if the specified condition is true. If any tags /// are specified after the condition, those will be used. Otherwise, a string /// version of the condition itself will be used as the tag. #define RC_CLASSIFY(condition, ...) \ do { \ if (condition) { \ ::rc::detail::classify(#condition, {__VA_ARGS__}); \ } \ } while (false) /// Tags the current test case with the given values which will be converted to /// strings. #define RC_TAG(...) ::rc::detail::tag({__VA_ARGS__}) #include "Classify.hpp"
Add include required to compile on linux.
/** Copyright (c) 2017 Ryan Porter You may use, distribute, or modify this code under the terms of the MIT license. */ #ifndef POLY_CHECKSUM_H #define POLY_CHECKSUM_H // based on code found at http://www.relisoft.com/science/CrcOptim.html class PolyChecksum { public: PolyChecksum(); virtual void putBytes(void* bytes, size_t dataSize); virtual int getResult(); public: unsigned long _table[256]; unsigned long _register = 0; unsigned long _key = 0x04c11db7; }; #endif
/** Copyright (c) 2017 Ryan Porter You may use, distribute, or modify this code under the terms of the MIT license. */ #ifndef POLY_CHECKSUM_H #define POLY_CHECKSUM_H #include <cstddef> // based on code found at http://www.relisoft.com/science/CrcOptim.html class PolyChecksum { public: PolyChecksum(); virtual void putBytes(void* bytes, size_t dataSize); virtual int getResult(); public: unsigned long _table[256]; unsigned long _register = 0; unsigned long _key = 0x04c11db7; }; #endif
Fix bizarre bug in "altitude [climb|descend]"
#include "input.h" #include "command.h" TreeNode curNode; char curPlane, extra; void initializeInput() { initializeCommands(); curPlane = 0; } void handleInput(char ch, AtcsoData *data, WINDOW *msgWin) { if (!curPlane) { if (ch >= 'a' && ch <= 'z') { curPlane = ch; curNode = commands; waddch(msgWin, ch); waddch(msgWin, ':'); wrefresh(msgWin); } } else if (ch == '\n') { if (curNode.func) { (*curNode.func)(data, curPlane, extra); curPlane = 0; werase(msgWin); wrefresh(msgWin); } } else { extra = '\0'; if (ch >= '0' && ch <= '9') { extra = ch; ch = '#'; } for (int i = 0; i < curNode.nChildren; ++i) { if (curNode.children[i].hotkey == ch) { curNode = curNode.children[i]; waddch(msgWin, ' '); if (extra) { wprintw(msgWin, curNode.str, extra); } else { waddstr(msgWin, curNode.str); } wrefresh(msgWin); break; } } } }
#include "input.h" #include "command.h" TreeNode curNode; char curPlane, extra; void initializeInput() { initializeCommands(); curPlane = 0; } void handleInput(char ch, AtcsoData *data, WINDOW *msgWin) { if (!curPlane) { if (ch >= 'a' && ch <= 'z') { curPlane = ch; curNode = commands; waddch(msgWin, ch); waddch(msgWin, ':'); wrefresh(msgWin); } } else if (ch == '\n') { if (curNode.func) { (*curNode.func)(data, curPlane, extra); curPlane = 0; werase(msgWin); wrefresh(msgWin); } } else { extra = ch; if (ch >= '0' && ch <= '9') ch = '#'; for (int i = 0; i < curNode.nChildren; ++i) { if (curNode.children[i].hotkey == ch) { curNode = curNode.children[i]; waddch(msgWin, ' '); if (ch == '#') { wprintw(msgWin, curNode.str, extra); } else { waddstr(msgWin, curNode.str); } wrefresh(msgWin); break; } } } }
Add AGPLv3 legalese boilerplate to the source files.
#include <stdio.h> #include <config.h> int main(void) { puts("This is " PACKAGE_STRING); return 0; }
/* This file is part of nsafepass Copyright 2015 Sergey Kvachonok nsafepass is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. */ #include <stdio.h> #include <config.h> int main(void) { puts("This is " PACKAGE_STRING); return 0; }
Test program for the pad factory
#include <gst/gst.h> static GstCapsFactory mpeg2dec_sink_caps = { "mpeg2deccaps", "video/mpeg", "mpegtype", GST_PROPS_LIST ( GST_PROPS_INT(1), GST_PROPS_INT(2) ), NULL }; static GstCapsFactory mpeg2dec_src_caps = { "name", "video/raw", "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC ('Y','V','1','2'), GST_PROPS_FOURCC_INT (0x56595559) ), "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096), NULL }; static GstCapsFactory raw_sink_caps = { NULL }; static GstPadFactory pad_caps = { "src", GST_PAD_FACTORY_SRC, GST_PAD_FACTORY_ALWAYS, GST_PAD_FACTORY_CAPS ( "videocaps", "video/raw", "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC_INT (0x32315659), GST_PROPS_FOURCC ('Y','U','Y','V') ), "height", GST_PROPS_INT_RANGE (16, 4096) ), GST_PAD_FACTORY_CAPS ( "videocaps2", "video/raw", "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC_INT (0x32315659) ), "height", GST_PROPS_INT_RANGE (16, 256) ), NULL }; static GstCaps *sinkcaps = NULL, *rawcaps = NULL; static GstPadTemplate *temp; int main(int argc,char *argv[]) { gboolean testret; xmlDocPtr doc; xmlNodePtr parent; doc = xmlNewDoc ("1.0"); doc->root = xmlNewDocNode (doc, NULL, "Capabilities", NULL); _gst_type_initialize (); sinkcaps = gst_caps_register (&mpeg2dec_sink_caps); parent = xmlNewChild (doc->root, NULL, "Capabilities1", NULL); gst_caps_save_thyself (sinkcaps, parent); rawcaps = gst_caps_register (&mpeg2dec_src_caps); parent = xmlNewChild (doc->root, NULL, "Capabilities2", NULL); gst_caps_save_thyself (rawcaps, parent); temp = gst_padtemplate_new (&pad_caps); parent = xmlNewChild (doc->root, NULL, "Padtemplate", NULL); gst_padtemplate_save_thyself (temp, parent); xmlDocDump(stdout, doc); return 0; }
Update compilation instructions for minimal C example.
/* Minimal C SDL example. This code is in the public domain. Compile with: gcc `sdl2-config --cflags` `sdl2-config --libs` minc.c */ #include <unistd.h> #include <assert.h> #include <stdio.h> #include "SDL.h" int main(int argc, char** argv) { assert (SDL_Init(SDL_INIT_VIDEO) == 0); SDL_Window *w = SDL_CreateWindow ("SDL OpenGL (C)", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL); assert (w); SDL_Delay (3000); SDL_DestroyWindow (w); SDL_Quit (); return 0; }
/* Minimal C SDL example. This code is in the public domain. Compile with: gcc -o minc minc.c `sdl2-config --cflags --libs` */ #include <unistd.h> #include <assert.h> #include <stdio.h> #include "SDL.h" int main(int argc, char** argv) { assert (SDL_Init(SDL_INIT_VIDEO) == 0); SDL_Window *w = SDL_CreateWindow ("SDL OpenGL (C)", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL); assert (w); SDL_Delay (3000); SDL_DestroyWindow (w); SDL_Quit (); return 0; }
Test case to use the correct Cmp mode
char glob = -1; int main(void) { char x = 126; while (x > 0) { x++; printf("%d\n", x); if (x == -125) break; } return 0; }
Change test to get rid of gcc warning
int puts(const char *); int noop(void); int foo(char *list[5]) { puts(list[0]); puts(list[1]); return sizeof(list); } int prints(int n, ...) { return n; } char s1[] = "Hello"; char *s2 = "World"; int main() { int size = 0; char *words[2]; words[0] = s1; words[1] = s2; size = foo(words); size = size + sizeof(words); size = size + prints(2, "hei", "hoi"); return size; }
int puts(const char *); int noop(void); int foo(char *list[5]) { puts(list[0]); puts(list[1]); return sizeof(list[6]); } int prints(int n, ...) { return n; } char s1[] = "Hello"; char *s2 = "World"; int main() { int size = 0; char *words[2]; words[0] = s1; words[1] = s2; size = foo(words); size = size + sizeof(words); size = size + prints(2, "hei", "hoi"); return size; }
Split buffer overflow test case into two test cases, removing out logic that was commented out.
// RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s struct tea_cheese { unsigned magic; }; typedef struct tea_cheese kernel_tea_cheese_t; extern kernel_tea_cheese_t _wonky_gesticulate_cheese; // This test case exercises the ElementRegion::getRValueType() logic. void foo( void ) { kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese; struct load_wine *cmd = (void*) &wonky[1]; cmd = cmd; char *p = (void*) &wonky[1]; //*p = 1; // this is also an out-of-bound access. kernel_tea_cheese_t *q = &wonky[1]; // This test case tests both the RegionStore logic (doesn't crash) and // the out-of-bounds checking. We don't expect the warning for now since // out-of-bound checking is temporarily disabled. kernel_tea_cheese_t r = *q; // expected-warning{{Access out-of-bound array element (buffer overflow)}} }
// RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s struct tea_cheese { unsigned magic; }; typedef struct tea_cheese kernel_tea_cheese_t; extern kernel_tea_cheese_t _wonky_gesticulate_cheese; // This test case exercises the ElementRegion::getRValueType() logic. void test1( void ) { kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese; struct load_wine *cmd = (void*) &wonky[1]; cmd = cmd; char *p = (void*) &wonky[1]; kernel_tea_cheese_t *q = &wonky[1]; // This test case tests both the RegionStore logic (doesn't crash) and // the out-of-bounds checking. We don't expect the warning for now since // out-of-bound checking is temporarily disabled. kernel_tea_cheese_t r = *q; // expected-warning{{Access out-of-bound array element (buffer overflow)}} } void test1_b( void ) { kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese; struct load_wine *cmd = (void*) &wonky[1]; cmd = cmd; char *p = (void*) &wonky[1]; *p = 1; // expected-warning{{Access out-of-bound array element (buffer overflow)}} }
Add constants for outer join states in executor.
/*------------------------------------------------------------------------- * * execdefs.h * * * * Copyright (c) 1994, Regents of the University of California * * $Id: execdefs.h,v 1.4 1999/02/13 23:21:22 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef EXECDEFS_H #define EXECDEFS_H /* ---------------- * ExecutePlan() tuplecount definitions * ---------------- */ #define ALL_TUPLES 0 /* return all tuples */ #define ONE_TUPLE 1 /* return only one tuple */ /* ---------------- * constants used by ExecMain * ---------------- */ #define EXEC_RUN 3 #define EXEC_FOR 4 #define EXEC_BACK 5 #define EXEC_RETONE 6 #define EXEC_RESULT 7 /* ---------------- * Merge Join states * ---------------- */ #define EXEC_MJ_INITIALIZE 1 #define EXEC_MJ_JOINMARK 2 #define EXEC_MJ_JOINTEST 3 #define EXEC_MJ_JOINTUPLES 4 #define EXEC_MJ_NEXTOUTER 5 #define EXEC_MJ_TESTOUTER 6 #define EXEC_MJ_NEXTINNER 7 #define EXEC_MJ_SKIPINNER 8 #define EXEC_MJ_SKIPOUTER 9 #endif /* EXECDEFS_H */
/*------------------------------------------------------------------------- * * execdefs.h * * * * Copyright (c) 1994, Regents of the University of California * * $Id: execdefs.h,v 1.5 1999/02/23 07:37:31 thomas Exp $ * *------------------------------------------------------------------------- */ #ifndef EXECDEFS_H #define EXECDEFS_H /* ---------------- * ExecutePlan() tuplecount definitions * ---------------- */ #define ALL_TUPLES 0 /* return all tuples */ #define ONE_TUPLE 1 /* return only one tuple */ /* ---------------- * constants used by ExecMain * ---------------- */ #define EXEC_RUN 3 #define EXEC_FOR 4 #define EXEC_BACK 5 #define EXEC_RETONE 6 #define EXEC_RESULT 7 /* ---------------- * Merge Join states * ---------------- */ #define EXEC_MJ_INITIALIZE 1 #define EXEC_MJ_JOINMARK 2 #define EXEC_MJ_JOINTEST 3 #define EXEC_MJ_JOINTUPLES 4 #define EXEC_MJ_NEXTOUTER 5 #define EXEC_MJ_TESTOUTER 6 #define EXEC_MJ_NEXTINNER 7 #define EXEC_MJ_SKIPINNER 8 #define EXEC_MJ_SKIPOUTER 9 #define EXEC_MJ_FILLINNER 10 #define EXEC_MJ_FILLOUTER 11 #endif /* EXECDEFS_H */
Fix path in header file
// Copyright 2015. All Rights Reserved. // Author: pxtian2008@gmail.com (Xiaotian Pei) #ifndef EXAMPLES_COREUTILS_WC_MOCK_H_ #define EXAMPLES_COREUTILS_WC_MOCK_H_ #include "examples/coreutils/wc.h" #include "third_party/gmock/gmock.h" namespace coreutils { class MockFile : public File { public: MOCK_METHOD2(Open, bool(const char* filename, const char* mode)); MOCK_METHOD0(Close, bool()); MOCK_METHOD2(Read, int(char* buffer, int buf_size)); MOCK_METHOD0(Eof, bool()); }; } // namespace coreutils #endif // EXAMPLES_COREUTILS_WC_MOCK_H_
// Copyright 2015. All Rights Reserved. // Author: pxtian2008@gmail.com (Xiaotian Pei) #ifndef EXAMPLES_COREUTILS_WC_MOCK_H_ #define EXAMPLES_COREUTILS_WC_MOCK_H_ #include "examples/wc.h" #include "third_party/gmock/gmock.h" namespace coreutils { class MockFile : public File { public: MOCK_METHOD2(Open, bool(const char* filename, const char* mode)); MOCK_METHOD0(Close, bool()); MOCK_METHOD2(Read, int(char* buffer, int buf_size)); MOCK_METHOD0(Eof, bool()); }; } // namespace coreutils #endif // EXAMPLES_COREUTILS_WC_MOCK_H_
Make ScopedOleInitializer work on windows if you aren't including build_config already.
// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_ #define CHROME_APP_SCOPED_OLE_INITIALIZER_H_ // Wraps OLE initialization in a cross-platform class meant to be used on the // stack so init/uninit is done with scoping. This class is ok for use by // non-windows platforms; it just doesn't do anything. #if defined(OS_WIN) #include <ole2.h> class ScopedOleInitializer { public: ScopedOleInitializer() { int ole_result = OleInitialize(NULL); DCHECK(ole_result == S_OK); } ~ScopedOleInitializer() { OleUninitialize(); } }; #else class ScopedOleInitializer { public: // Empty, this class does nothing on non-win32 systems. Empty ctor is // necessary to avoid "unused variable" warning on gcc. ScopedOleInitializer() { } }; #endif #endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_
// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_ #define CHROME_APP_SCOPED_OLE_INITIALIZER_H_ #include "base/logging.h" #include "build/build_config.h" // Wraps OLE initialization in a cross-platform class meant to be used on the // stack so init/uninit is done with scoping. This class is ok for use by // non-windows platforms; it just doesn't do anything. #if defined(OS_WIN) #include <ole2.h> class ScopedOleInitializer { public: ScopedOleInitializer() { int ole_result = OleInitialize(NULL); DCHECK(ole_result == S_OK); } ~ScopedOleInitializer() { OleUninitialize(); } }; #else class ScopedOleInitializer { public: // Empty, this class does nothing on non-win32 systems. Empty ctor is // necessary to avoid "unused variable" warning on gcc. ScopedOleInitializer() { } }; #endif #endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_
Add two classes [as yet unused] needed for upcoming IDB Blob support.
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef WebBlobInfo_h #define WebBlobInfo_h #include "WebCommon.h" #include "WebString.h" namespace blink { class WebBlobInfo { public: WebBlobInfo() : m_isFile(false) , m_size(-1) , m_lastModified(0) { } WebBlobInfo(const WebString& uuid, const WebString& type, long long size) : m_isFile(false) , m_uuid(uuid) , m_type(type) , m_size(size) , m_lastModified(0) { } WebBlobInfo(const WebString& uuid, const WebString& filePath, const WebString& fileName, const WebString& type) : m_isFile(true) , m_uuid(uuid) , m_type(type) , m_size(-1) , m_filePath(filePath) , m_fileName(fileName) , m_lastModified(0) { } WebBlobInfo(const WebString& uuid, const WebString& filePath, const WebString& fileName, const WebString& type, double lastModified, long long size) : m_isFile(true) , m_uuid(uuid) , m_type(type) , m_size(size) , m_filePath(filePath) , m_fileName(fileName) , m_lastModified(lastModified) { } bool isFile() const { return m_isFile; } const WebString& uuid() const { return m_uuid; } const WebString& type() const { return m_type; } long long size() const { return m_size; } const WebString& filePath() const { return m_filePath; } const WebString& fileName() const { return m_fileName; } double lastModified() const { return m_lastModified; } private: bool m_isFile; WebString m_uuid; WebString m_type; // MIME type long long m_size; WebString m_filePath; // Only for File WebString m_fileName; // Only for File double m_lastModified; // Only for File }; } // namespace blink #endif
Fix conflicting IPC command type constants with i3's
#ifndef _SWAY_IPC_H #define _SWAY_IPC_H #define event_mask(ev) (1 << (ev & 0x7F)) enum ipc_command_type { IPC_COMMAND = 0, IPC_GET_WORKSPACES = 1, IPC_SUBSCRIBE = 2, IPC_GET_OUTPUTS = 3, IPC_GET_TREE = 4, IPC_GET_MARKS = 5, IPC_GET_BAR_CONFIG = 6, IPC_GET_VERSION = 7, IPC_GET_INPUTS = 8, IPC_GET_CLIPBOARD = 9, IPC_GET_SEATS = 10, // Events send from sway to clients. Events have the highest bits set. IPC_EVENT_WORKSPACE = ((1<<31) | 0), IPC_EVENT_OUTPUT = ((1<<31) | 1), IPC_EVENT_MODE = ((1<<31) | 2), IPC_EVENT_WINDOW = ((1<<31) | 3), IPC_EVENT_BARCONFIG_UPDATE = ((1<<31) | 4), IPC_EVENT_BINDING = ((1<<31) | 5), IPC_EVENT_MODIFIER = ((1<<31) | 6), IPC_EVENT_INPUT = ((1<<31) | 7), }; #endif
#ifndef _SWAY_IPC_H #define _SWAY_IPC_H #define event_mask(ev) (1 << (ev & 0x7F)) enum ipc_command_type { // i3 command types - see i3's I3_REPLY_TYPE constants IPC_COMMAND = 0, IPC_GET_WORKSPACES = 1, IPC_SUBSCRIBE = 2, IPC_GET_OUTPUTS = 3, IPC_GET_TREE = 4, IPC_GET_MARKS = 5, IPC_GET_BAR_CONFIG = 6, IPC_GET_VERSION = 7, // sway-specific command types IPC_GET_INPUTS = 100, IPC_GET_CLIPBOARD = 101, IPC_GET_SEATS = 102, // Events sent from sway to clients. Events have the highest bits set. IPC_EVENT_WORKSPACE = ((1<<31) | 0), IPC_EVENT_OUTPUT = ((1<<31) | 1), IPC_EVENT_MODE = ((1<<31) | 2), IPC_EVENT_WINDOW = ((1<<31) | 3), IPC_EVENT_BARCONFIG_UPDATE = ((1<<31) | 4), IPC_EVENT_BINDING = ((1<<31) | 5), IPC_EVENT_MODIFIER = ((1<<31) | 6), IPC_EVENT_INPUT = ((1<<31) | 7), }; #endif
Change test model define prefix
// // TETestModels.h // FLUX // // Created by Alex Faizullov on 10/28/16. // Copyright © 2016 Alexey Fayzullov. All rights reserved. // #import <Foundation/Foundation.h> #import <FLUX/FLXStore.h> #define te_defineStoreTestDouble(name) \ \ @interface name : FLXStore <NSObject *> \ \ @end \ \ @implementation name \ \ + (id)defaultState { return [NSObject new]; } \ \ @end \ \ te_defineStoreTestDouble(FLXFakeStore) te_defineStoreTestDouble(FLXTestStore)
// // TETestModels.h // FLUX // // Created by Alex Faizullov on 10/28/16. // Copyright © 2016 Alexey Fayzullov. All rights reserved. // #import <Foundation/Foundation.h> #import <FLUX/FLXStore.h> #define flx_defineStoreTestDouble(name) \ \ @interface name : FLXStore <NSObject *> \ \ @end \ \ @implementation name \ \ + (id)defaultState { return [NSObject new]; } \ \ @end \ \ flx_defineStoreTestDouble(FLXFakeStore) flx_defineStoreTestDouble(FLXTestStore)
Add platform include to installations header
// Copyright 2020 Google LLC // // 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 FIREBASE_FIS_CLIENT_CPP_SRC_INSTALLATIONS_INTERNAL_H_ #define FIREBASE_FIS_CLIENT_CPP_SRC_INSTALLATIONS_INTERNAL_H_ // InstallationsInternal is defined in these 2 files, one implementation for // each OS. #if FIREBASE_PLATFORM_ANDROID || FIREBASE_ANDROID_FOR_DESKTOP #include "installations/src/android/installations_android.h" #elif FIREBASE_PLATFORM_IOS #include "installations/src/ios/installations_ios.h" #else #include "installations/src/stub/installations_stub.h" #endif // FIREBASE_PLATFORM_ANDROID, FIREBASE_PLATFORM_IOS #endif // FIREBASE_FIS_CLIENT_CPP_SRC_INSTALLATIONS_INTERNAL_H_
// Copyright 2020 Google LLC // // 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 FIREBASE_FIS_CLIENT_CPP_SRC_INSTALLATIONS_INTERNAL_H_ #define FIREBASE_FIS_CLIENT_CPP_SRC_INSTALLATIONS_INTERNAL_H_ #include "app/src/include/firebase/internal/platform.h" // InstallationsInternal is defined in these 2 files, one implementation for // each OS. #if FIREBASE_PLATFORM_ANDROID || FIREBASE_ANDROID_FOR_DESKTOP #include "installations/src/android/installations_android.h" #elif FIREBASE_PLATFORM_IOS #include "installations/src/ios/installations_ios.h" #else #include "installations/src/stub/installations_stub.h" #endif // FIREBASE_PLATFORM_ANDROID, FIREBASE_PLATFORM_IOS #endif // FIREBASE_FIS_CLIENT_CPP_SRC_INSTALLATIONS_INTERNAL_H_
Fix Puzzle board .h file reference
// // Sudoku 9by9 Solver and Analyzer // #include "Sudoku9by9Board.h" class Sudoku9by9SolverAnalyzer { private: Sudoku9by9Board *board_ptr; int number_of_solutions; public: Sudoku9by9SolverAnalyzer(); Sudoku9by9SolverAnalyzer(Sudoku9by9Board *board_ptr); bool NextTryOrBackTrack(int i, int j, bool backtrack); void Solve(void); bool Cell_Conflict_Check(int p, int i, int j); int get_number_of_solutions(void); ~Sudoku9by9SolverAnalyzer(); };
// // Sudoku 9by9 Solver and Analyzer // #include "Sudoku9by9PuzzleBoard.h" class Sudoku9by9SolverAnalyzer { private: Sudoku9by9Board *board_ptr; int number_of_solutions; public: Sudoku9by9SolverAnalyzer(); Sudoku9by9SolverAnalyzer(Sudoku9by9Board *board_ptr); bool NextTryOrBackTrack(int i, int j, bool backtrack); void Solve(void); bool Cell_Conflict_Check(int p, int i, int j); int get_number_of_solutions(void); ~Sudoku9by9SolverAnalyzer(); };
Change arguments order in HTML Element initializer for convenience
// // HTMLElement.h // HTMLKit // // Created by Iska on 05/10/14. // Copyright (c) 2014 BrainCookie. All rights reserved. // #import <Foundation/Foundation.h> #import "HTMLNamespaces.h" #import "HTMLNode.h" @interface HTMLElement : HTMLNode @property (nonatomic, assign, readonly) HTMLNamespace htmlNamespace; @property (nonatomic, copy, readonly) NSString *tagName; @property (nonatomic, strong) NSMutableDictionary *attributes; @property (nonatomic, copy) NSString *elementId; @property (nonatomic, copy) NSString *className; - (instancetype)initWithTagName:(NSString *)tagName; - (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes; - (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes namespace:(HTMLNamespace)htmlNamespace; - (BOOL)hasAttribute:(NSString *)name; - (NSString *)objectForKeyedSubscript:(NSString *)name; - (void)setObject:(NSString *)value forKeyedSubscript:(NSString *)attribute; - (void)removeAttribute:(NSString *)name; @end
// // HTMLElement.h // HTMLKit // // Created by Iska on 05/10/14. // Copyright (c) 2014 BrainCookie. All rights reserved. // #import <Foundation/Foundation.h> #import "HTMLNamespaces.h" #import "HTMLNode.h" @interface HTMLElement : HTMLNode @property (nonatomic, assign, readonly) HTMLNamespace htmlNamespace; @property (nonatomic, copy, readonly) NSString *tagName; @property (nonatomic, strong) NSMutableDictionary *attributes; @property (nonatomic, copy) NSString *elementId; @property (nonatomic, copy) NSString *className; - (instancetype)initWithTagName:(NSString *)tagName; - (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes; - (instancetype)initWithTagName:(NSString *)tagName namespace:(HTMLNamespace)htmlNamespace attributes:(NSDictionary *)attributes; - (BOOL)hasAttribute:(NSString *)name; - (NSString *)objectForKeyedSubscript:(NSString *)name; - (void)setObject:(NSString *)value forKeyedSubscript:(NSString *)attribute; - (void)removeAttribute:(NSString *)name; @end
Change getbuiltin interface to get the name as an object.
/*********************************************************** Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Stichting Mathematisch Centrum or CWI not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /* Built-in module interface */ extern object *getbuiltin PROTO((char *));
/*********************************************************** Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Stichting Mathematisch Centrum or CWI not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /* Built-in module interface */ extern object *getbuiltin PROTO((object *));
Add beginning of what will become files shared between runtime and compiler.
#ifndef BFC_TYPES_H #define BFC_TYPES_H #ifndef __cplusplus # include <stdint.h> #else # include <cstdint> #endif typedef bfc_cell uint8_t; #endif /* !BFC_TYPES_H */
Make mapper init function protected
#ifndef MAPPER_H #define MAPPER_H #include <cstdint> #include <vector> #include <CartMemory.h> #include <Mirroring.h> class Mapper { public: Mapper(CartMemory mem) : cartMemory(mem) { init(); }; Mirroring getMirroring() { return cartMemory.mirroring; }; virtual void init() { }; virtual uint8_t readPrg(uint16_t addr) { }; virtual void writePrg(uint16_t addr, uint8_t value) { }; virtual uint8_t readChr(uint16_t addr) { }; virtual void writeChr(uint16_t addr, uint8_t value) { }; protected: CartMemory cartMemory; }; #endif
#ifndef MAPPER_H #define MAPPER_H #include <cstdint> #include <vector> #include <CartMemory.h> #include <Mirroring.h> class Mapper { public: Mapper(CartMemory mem) : cartMemory(mem) { init(); }; Mirroring getMirroring() { return cartMemory.mirroring; }; virtual uint8_t readPrg(uint16_t addr) { }; virtual void writePrg(uint16_t addr, uint8_t value) { }; virtual uint8_t readChr(uint16_t addr) { }; virtual void writeChr(uint16_t addr, uint8_t value) { }; protected: virtual void init() { }; CartMemory cartMemory; }; #endif
Simplify loop body of memcpy
#include <stddef.h> void* memcpy(void* restrict destination, const void* restrict source, size_t length) { char* restrict dst = destination; const char* restrict src = source; /* I know this is naive, but compiler will optimized this because we have restrict. */ for (; length; --length) { *dst = *src; ++dst; ++src; } return destination; }
#include <stddef.h> void* memcpy(void* restrict destination, const void* restrict source, size_t length) { char* restrict dst = destination; const char* restrict src = source; /* I know this is naive, but compiler will optimized this because we have restrict. */ for (; length; --length) *dst++ = *src++; return destination; }
Include some comments about each method
#include <Arduino.h> class MotorShield { public: MotorShield(uint8_t leftSpeedPin, uint8_t leftDirPin, uint8_t rightSpeedPin, uint8_t rightDirPin); void init(); void forward(); void backward(); void stop(); void fullSpeed(); void stopLeft(); void stopRight(); uint8_t getMaxSpeed(); uint8_t getMinSpeed(); uint8_t getLeftSpeedPin(); uint8_t getLeftDirPin(); uint8_t getRightSpeedPin(); uint8_t getRightDirPin(); uint8_t getLeftSpeed(); uint8_t getRightSpeed(); void setSpeed(uint8_t); void setLeftSpeed(uint8_t); void setRightSpeed(uint8_t); private: uint8_t leftSpeedPin, leftDirPin, rightSpeedPin, rightDirPin, maxSpeed, minSpeed, leftSpeed, rightSpeed; };
#include <Arduino.h> class MotorShield { public: MotorShield(uint8_t leftSpeedPin, uint8_t leftDirPin, uint8_t rightSpeedPin, uint8_t rightDirPin); // Initialization method. Must be called in Arduino's setup() function. void init(); // Makes left and right motors go in the forward direction. void forward(); // Makes left and right motors go in the backward direction. void backward(); // Stops both left and right motors. void stop(); // Puts both left and right motors at the maximum speed. void fullSpeed(); // Stops left motor. void stopLeft(); // Stops right motor. void stopRight(); // Returns the maximum allowed speed. uint8_t getMaxSpeed(); // Returns the minimum allowed speed. uint8_t getMinSpeed(); // Returns the pin used to control left motor speed. uint8_t getLeftSpeedPin(); // Returns the pin used to control left motor direction. uint8_t getLeftDirPin(); // Returns the pin used to control right motor speed. uint8_t getRightSpeedPin(); // Returns the pin used to control right motor direction. uint8_t getRightDirPin(); // Returns the current speed of the left motor. uint8_t getLeftSpeed(); // Returns the current speed of the right motor. uint8_t getRightSpeed(); // Sets the speed of both left and right motors. void setSpeed(uint8_t); // Sets the speed of the left motor. void setLeftSpeed(uint8_t); // Sets the speed of the right motor. void setRightSpeed(uint8_t); private: uint8_t leftSpeedPin, leftDirPin, rightSpeedPin, rightDirPin, maxSpeed, minSpeed, leftSpeed, rightSpeed; };
Remove unimplemented line of code
#include <truth/panic.h> #include <truth/cpu.h> #include <truth/types.h> #include <truth/log.h> #include <truth/slab.h> #include <truth/heap.h> #include <truth/physical_allocator.h> string Logo = str("\n" " _.-.\n" " .-. `) | .-.\n" " _.'`. .~./ \\.~. .`'._\n" " .-' .'.'.'.-| |-.'.'.'. '-.\n" " `'`'`'`'` \\ / `'`'`'`'`\n" " /||\\\n" " //||\\\\\n" "\n" " The Kernel of Truth\n"); void kernel_main(void *multiboot_tables) { assert_ok(init_log("log")); log(Logo); logf("\tVersion %d.%d.%d\n\tCommit %s\n\t%s\n\tCPU Time %ld\n", kernel_major, kernel_minor, kernel_patch, vcs_version, project_website, cpu_time()); init_interrupts(); init_physical_allocator(multiboot_tables); init_slab(); assert_ok(init_heap()); assert_ok(init_modules(multiboot_tables)); halt(); }
#include <truth/panic.h> #include <truth/cpu.h> #include <truth/types.h> #include <truth/log.h> #include <truth/slab.h> #include <truth/heap.h> #include <truth/physical_allocator.h> string Logo = str("\n" " _.-.\n" " .-. `) | .-.\n" " _.'`. .~./ \\.~. .`'._\n" " .-' .'.'.'.-| |-.'.'.'. '-.\n" " `'`'`'`'` \\ / `'`'`'`'`\n" " /||\\\n" " //||\\\\\n" "\n" " The Kernel of Truth\n"); void kernel_main(void *multiboot_tables) { assert_ok(init_log("log")); log(Logo); logf("\tVersion %d.%d.%d\n\tCommit %s\n\t%s\n\tCPU Time %ld\n", kernel_major, kernel_minor, kernel_patch, vcs_version, project_website, cpu_time()); init_interrupts(); init_physical_allocator(multiboot_tables); init_slab(); assert_ok(init_heap()); halt(); }
Use Qt types for integers
/* * Application configuration */ #pragma once #include <QtCore> typedef struct { QString type; quint64 frequency; qint64 nco; qint64 transverter; unsigned int rate; unsigned int decimation; unsigned int bandwidth; int freq_corr_ppb; } device_config_t; typedef struct { } audio_config_t; typedef struct { unsigned int version; device_config_t input; audio_config_t audio; } app_config_t; // error codes #define APP_CONFIG_OK 0 #define APP_CONFIG_EINVAL 1 // invalid function paramter #define APP_CONFIG_EFILE 2 // error loading or saving file #define APP_CONFIG_EDATA 3 // data error (e.g. missing required config record) class AppConfig { public: explicit AppConfig(); virtual ~AppConfig(); int load(const QString &filename); void save(void); void close(void); app_config_t *getDataPtr(void) { return &app_config; } private: void readDeviceConf(void); void saveDeviceConf(void); private: QSettings *settings; app_config_t app_config; };
/* * Application configuration */ #pragma once #include <QtCore> typedef struct { QString type; quint64 frequency; qint64 nco; qint64 transverter; quint32 rate; quint32 decimation; quint32 bandwidth; qint32 freq_corr_ppb; } device_config_t; typedef struct { } audio_config_t; typedef struct { unsigned int version; device_config_t input; audio_config_t audio; } app_config_t; // error codes #define APP_CONFIG_OK 0 #define APP_CONFIG_EINVAL 1 // invalid function paramter #define APP_CONFIG_EFILE 2 // error loading or saving file #define APP_CONFIG_EDATA 3 // data error (e.g. missing required config record) class AppConfig { public: explicit AppConfig(); virtual ~AppConfig(); int load(const QString &filename); void save(void); void close(void); app_config_t *getDataPtr(void) { return &app_config; } private: void readDeviceConf(void); void saveDeviceConf(void); private: QSettings *settings; app_config_t app_config; };
Update comment of selection sort to include time complexity precisely
#ifndef INCLUDE_ALGORITHMS_SELECTION_SORT_H_ #define INCLUDE_ALGORITHMS_SELECTION_SORT_H_ #include <stddef.h> #include <vector> #include <functional> #include "sort_interface.h" /* This class implements sorting of elements using selection sort algorithm The time complexity to sort is quadratic and is insensitive to input, which mean that the algorithm will take quadratic time even if the input is sorted. However the data movement is minimal. The algorithm does linear number of swaps to sort the elements. Each element is moved into its final position once. */ namespace algorithms { template <typename _tp> class SelectionSort : public SortInterface<_tp> { public: typedef _tp value_type; static void Sort(std::vector<value_type>& elements, std::function<bool(const value_type&, const value_type&)> comparer = std::less<value_type>()) { for (size_t index = 0; index < elements.size(); ++index) { auto min = index; for (size_t cnt = index + 1; cnt < elements.size(); ++cnt) { if (comparer(elements[cnt], elements[min])) min = cnt; } std::swap(elements[min], elements[index]); } } }; } #endif //INCLUDE_ALGORITHMS_SELECTION_SORT_H_
#ifndef INCLUDE_ALGORITHMS_SELECTION_SORT_H_ #define INCLUDE_ALGORITHMS_SELECTION_SORT_H_ #include <stddef.h> #include <vector> #include <functional> #include "sort_interface.h" /* This class implements sorting of elements using selection sort algorithm The time complexity to sort is quadratic (N2/4) and is insensitive to input, which mean that the algorithm will take quadratic time even if the input is sorted. However the data movement is minimal. The algorithm does linear number of swaps to sort the elements. Each element is moved into its final position once. */ namespace algorithms { template <typename _tp> class SelectionSort : public SortInterface<_tp> { public: typedef _tp value_type; static void Sort(std::vector<value_type>& elements, std::function<bool(const value_type&, const value_type&)> comparer = std::less<value_type>()) { for (size_t index = 0; index < elements.size(); ++index) { auto min = index; for (size_t cnt = index + 1; cnt < elements.size(); ++cnt) { if (comparer(elements[cnt], elements[min])) min = cnt; } std::swap(elements[min], elements[index]); } } }; } #endif //INCLUDE_ALGORITHMS_SELECTION_SORT_H_
Fix bug in shape yaml emit
#pragma once #include "geometry.h" #include "yaml_utils.h" #include <vector> #include <boost/shared_ptr.hpp> #include <librevenge/librevenge.h> namespace libpagemaker { class PMDPage { std::vector<boost::shared_ptr<PMDLineSet> > m_shapes; public: PMDPage() : m_shapes() { } void addShape(boost::shared_ptr<PMDLineSet> shape) { m_shapes.push_back(shape); } unsigned numShapes() const { return m_shapes.size(); } boost::shared_ptr<const PMDLineSet> getShape(unsigned i) const { return m_shapes.at(i); } void emitYaml(yaml_emitter_t *emitter) const { yamlIndirectForeach(emitter, "shapes", m_shapes); } }; } /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
#pragma once #include "geometry.h" #include "yaml_utils.h" #include <vector> #include <boost/shared_ptr.hpp> #include <librevenge/librevenge.h> namespace libpagemaker { class PMDPage { std::vector<boost::shared_ptr<PMDLineSet> > m_shapes; public: PMDPage() : m_shapes() { } void addShape(boost::shared_ptr<PMDLineSet> shape) { m_shapes.push_back(shape); } unsigned numShapes() const { return m_shapes.size(); } boost::shared_ptr<const PMDLineSet> getShape(unsigned i) const { return m_shapes.at(i); } void emitYaml(yaml_emitter_t *emitter) const { yamlBeginMap(emitter); yamlIndirectForeach(emitter, "shapes", m_shapes); yamlEndMap(emitter); } }; } /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Fix "lt", "gt" & "eq"-selectors declarations
// // CSSStructuralPseudoSelector.h // HTMLKit // // Created by Iska on 11/10/15. // Copyright © 2015 BrainCookie. All rights reserved. // @class CSSSelector; NS_ASSUME_NONNULL_BEGIN extern CSSSelector * rootSelector(); extern CSSSelector * emptySelector(); extern CSSSelector * parentSelector(); extern CSSSelector * buttonSelector(); extern CSSSelector * checkboxSelector(); extern CSSSelector * fileSelector(); extern CSSSelector * headerSelector(); extern CSSSelector * imageSelector(); extern CSSSelector * inputSelector(); extern CSSSelector * linkSelector(); extern CSSSelector * passwordSelector(); extern CSSSelector * radioSelector(); extern CSSSelector * resetSelector(); extern CSSSelector * submitSelector(); extern CSSSelector * textSelector(); extern CSSSelector * enabledSelector(); extern CSSSelector * disabledSelector(); extern CSSSelector * checkedSelector(); extern CSSSelector * optionalSelector(); extern CSSSelector * requiredSelector(); extern CSSSelector * ltSelector(); extern CSSSelector * gtSelector(); extern CSSSelector * eqSelector(); NS_ASSUME_NONNULL_END
// // CSSStructuralPseudoSelector.h // HTMLKit // // Created by Iska on 11/10/15. // Copyright © 2015 BrainCookie. All rights reserved. // @class CSSSelector; NS_ASSUME_NONNULL_BEGIN extern CSSSelector * rootSelector(); extern CSSSelector * emptySelector(); extern CSSSelector * parentSelector(); extern CSSSelector * buttonSelector(); extern CSSSelector * checkboxSelector(); extern CSSSelector * fileSelector(); extern CSSSelector * headerSelector(); extern CSSSelector * imageSelector(); extern CSSSelector * inputSelector(); extern CSSSelector * linkSelector(); extern CSSSelector * passwordSelector(); extern CSSSelector * radioSelector(); extern CSSSelector * resetSelector(); extern CSSSelector * submitSelector(); extern CSSSelector * textSelector(); extern CSSSelector * enabledSelector(); extern CSSSelector * disabledSelector(); extern CSSSelector * checkedSelector(); extern CSSSelector * optionalSelector(); extern CSSSelector * requiredSelector(); extern CSSSelector * ltSelector(NSUInteger index); extern CSSSelector * gtSelector(NSUInteger index); extern CSSSelector * eqSelector(NSInteger index); NS_ASSUME_NONNULL_END
Add rlc/debug to parameter list
// 3GPP LTE RLC: 4G Radio Link Control protocol interface // Parameters for RLC AM const char *const rlc_parameter_names[] = { /* RLC mode AM/UM/TM */ "rlc/mode", /* AM */ "maxRetxThreshold", "amWindowSize", "pollPDU", "pollByte", "t-StatusProhibit", "t-PollRetransmit", /* AM & UM */ "t-Reordering", /* UM */ "SN-FieldLength.rx", "SN-FieldLength.tx", /* PDCP */ "headerCompression", "pdcp-SN-Size", "statusReportRequired", "discardTimer", "maxCID", "profiles", "pdcp/t-Reordering", "", NULL };
// 3GPP LTE RLC: 4G Radio Link Control protocol interface // Parameters for RLC AM const char *const rlc_parameter_names[] = { /* RLC mode AM/UM/TM */ "rlc/mode", "rlc/debug", /* AM */ "maxRetxThreshold", "amWindowSize", "pollPDU", "pollByte", "t-StatusProhibit", "t-PollRetransmit", /* AM & UM */ "t-Reordering", /* UM */ "SN-FieldLength.rx", "SN-FieldLength.tx", /* PDCP */ "headerCompression", "pdcp-SN-Size", "statusReportRequired", "discardTimer", "maxCID", "profiles", "pdcp/t-Reordering", "", NULL };
Improve style and naming conventions
#ifndef COMMON_H_INCLUDED #define COMMON_H_INCLUDED #include <string> #include <vector> #include <numeric> #include <iostream> #include "../include/Console.h" // Common functions and data to share across all files. namespace Common { void ClearScreen(); int input(); void ColourPrint(std::string, Console::EColour colour); void Sleep(int ms); int RandomInt(int min, int max); template <typename T> T RandomEvent(std::vector<int> weights, std::vector<T> outcomes) { std::vector <int> events; int k = 0; for (auto it : weights) { for (int i = 0; i < it; i++) { events.push_back(k); } k++; } int denominator = std::accumulate(weights.begin(), weights.end(), 0); int rIndex = Common::RandomInt(0, denominator-1); int outIndex = events.at(rIndex); return outcomes.at(outIndex); } // Indicates if the game is still going. extern bool IsPlaying; extern const int SLEEP_MS; // Number of items held in inventory. extern const int NUM_ITEMS; } #endif // COMMON_H_INCLUDED
#ifndef COMMON_H_INCLUDED #define COMMON_H_INCLUDED #include <string> #include <vector> #include <numeric> #include <iostream> #include "../include/Console.h" // Common functions and data to share across all files. namespace Common { void ClearScreen(); int input(); void ColourPrint(std::string, Console::EColour colour); void Sleep(int ms); int RandomInt(int min, int max); template <typename T> T RandomEvent(std::vector<int> weights, std::vector<T> outcomes) { std::vector <int> indices; int index = 0; // The possible indices for the outcomes vector for (int weight : weights) { for (int i = 0; i < weight; i++) { indices.push_back(index); } index++; } int randomIndex = indices.at(RandomInt(0, indices.size()-1)); return outcomes.at(randomIndex); } // Indicates if the game is still going. extern bool IsPlaying; extern const int SLEEP_MS; // Number of items held in inventory. extern const int NUM_ITEMS; } #endif // COMMON_H_INCLUDED
Test code quality for variable length array references.
// RUN: %llvmgcc -S %s -o - | grep {getelementptr i32} extern void f(int *); int e(int m, int n) { int x[n]; f(x); return x[m]; }
Add type arguments support :)
#import <Foundation/Foundation.h> #import "NSObject+BlockObservation.h" @interface KVOMutableArray : NSMutableArray<NSFastEnumeration, NSMutableCopying, NSCoding, NSCopying> - (NSMutableArray*)arr; - (instancetype)init; - (instancetype)initWithMutableArray:(NSMutableArray*)array NS_DESIGNATED_INITIALIZER; - (BOOL)isEqualToArray:(KVOMutableArray*)array; - (AMBlockToken*)addObserverWithTask:(AMBlockTask)task; // Warning!! [NSKeyedUnarchiver unarchiveObject] will return NSMutableArray // see http://stackoverflow.com/questions/18874493/nsmutablearray-subclass-not-calling-subclasss-initwithcoder-when-unarchiving - (void)encodeWithCoder:(NSCoder *)encoder; // Warning!! [kvoMutableArray copy] may return NSArray - (id)copyWithZone:(NSZone *)zone; @end
#import <Foundation/Foundation.h> #import "NSObject+BlockObservation.h" @interface KVOMutableArray<ObjectType> : NSMutableArray<NSFastEnumeration, NSMutableCopying, NSCoding, NSCopying> - (NSMutableArray*)arr; - (instancetype)init; - (instancetype)initWithMutableArray:(NSMutableArray*)array NS_DESIGNATED_INITIALIZER; - (BOOL)isEqualToArray:(KVOMutableArray*)array; - (AMBlockToken*)addObserverWithTask:(AMBlockTask)task; // Warning!! [NSKeyedUnarchiver unarchiveObject] will return NSMutableArray // see http://stackoverflow.com/questions/18874493/nsmutablearray-subclass-not-calling-subclasss-initwithcoder-when-unarchiving - (void)encodeWithCoder:(NSCoder *)encoder; // Warning!! [kvoMutableArray copy] may return NSArray - (id)copyWithZone:(NSZone *)zone; @end
Revert 167434 - build fix
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_AURA_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_ #define CHROME_BROWSER_UI_AURA_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/chrome_browser_main_extra_parts.h" namespace aura { class DesktopStackingClient; } class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts { public: ChromeBrowserMainExtraPartsAura(); virtual ~ChromeBrowserMainExtraPartsAura(); // Overridden from ChromeBrowserMainExtraParts: virtual void PreProfileInit() OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE; private: scoped_ptr<views::DesktopStackingClient> stacking_client_; DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura); }; #endif // CHROME_BROWSER_UI_AURA_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_AURA_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_ #define CHROME_BROWSER_UI_AURA_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/chrome_browser_main_extra_parts.h" namespace views { class DesktopStackingClient; } class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts { public: ChromeBrowserMainExtraPartsAura(); virtual ~ChromeBrowserMainExtraPartsAura(); // Overridden from ChromeBrowserMainExtraParts: virtual void PreProfileInit() OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE; private: scoped_ptr<views::DesktopStackingClient> stacking_client_; DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura); }; #endif // CHROME_BROWSER_UI_AURA_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_
Add BBAAPIError code for 409 conflict
// // BBAAPIErrors.h // BBAAPI // // Created by Owen Worley on 11/08/2014. // Copyright (c) 2014 Blinkbox Books. All rights reserved. // NS_ENUM(NSInteger, BBAAPIError) { /** * Used when needed parameter is not supplied to the method * or when object is supplied but it has wrong type or * for example one of it's needed properties is not set */ BBAAPIWrongUsage = 700, /** * Error returned when for any reason API call cannot connect to the server */ BBAAPIErrorCouldNotConnect = 701, /** * Returned when call cannot be authenticated, or when server returns 401 */ BBAAPIErrorUnauthorised = 702, /** * Used when server cannot find a resource and returns 404 */ BBAAPIErrorNotFound = 703, /** * Used when server returns 500 */ BBAAPIServerError = 704, /** * Used when server returns 403 */ BBAAPIErrorForbidden = 705, /** * Used when we cannot decode or read data returned from the server */ BBAAPIUnreadableData = 706, /** * Used when the server returns a 400 (Bad Request) */ BBAAPIBadRequest = 707, };
// // BBAAPIErrors.h // BBAAPI // // Created by Owen Worley on 11/08/2014. // Copyright (c) 2014 Blinkbox Books. All rights reserved. // NS_ENUM(NSInteger, BBAAPIError) { /** * Used when needed parameter is not supplied to the method * or when object is supplied but it has wrong type or * for example one of it's needed properties is not set */ BBAAPIWrongUsage = 700, /** * Error returned when for any reason API call cannot connect to the server */ BBAAPIErrorCouldNotConnect = 701, /** * Returned when call cannot be authenticated, or when server returns 401 */ BBAAPIErrorUnauthorised = 702, /** * Used when server cannot find a resource and returns 404 */ BBAAPIErrorNotFound = 703, /** * Used when server returns 500 */ BBAAPIServerError = 704, /** * Used when server returns 403 */ BBAAPIErrorForbidden = 705, /** * Used when we cannot decode or read data returned from the server */ BBAAPIUnreadableData = 706, /** * Used when the server returns a 400 (Bad Request) */ BBAAPIErrorBadRequest = 707, /** * Used when the server returns a 409 (Conflict) */ BBAAPIErrorConflict = 708, };
Include a couple more important headers.
#include "main.h" #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <errno.h> #include <cstdio>
#include "main.h" #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <arpa/nameser.h> #include <netdb.h> #include <resolv.h> #include <errno.h> #include <cstdio>