Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add test case for single block
int main() { int b = 2, c = 3, d = 4; int a = b + c; b = a - d; int e = b + c; int f = a - d; return 0; }
Add queuesize test with constant capacity
// SKIP PARAM: --set ana.activated[+] apron --set ana.apron.domain octagon --enable ana.apron.threshold_widening // TODO: why needs threshold widening to succeed when queuesize doesn't? #include <pthread.h> #include <assert.h> #define CAPACITY 1000 int used; int free; pthread_mutex_t Q = PTHREAD_MUTEX_INITIALIZER; void pop() { pthread_mutex_lock(&Q); assert(free >= 0); assert(free <= CAPACITY); assert(used >= 0); assert(used <= CAPACITY); assert(used + free == CAPACITY); if (used >= 1) { used--; free++; } assert(free >= 0); assert(free <= CAPACITY); assert(used >= 0); assert(used <= CAPACITY); assert(used + free == CAPACITY); pthread_mutex_unlock(&Q); } void push() { pthread_mutex_lock(&Q); assert(free >= 0); assert(free <= CAPACITY); assert(used >= 0); assert(used <= CAPACITY); assert(used + free == CAPACITY); if (free >= 1) { free--; used++; } assert(free >= 0); assert(free <= CAPACITY); assert(used >= 0); assert(used <= CAPACITY); assert(used + free == CAPACITY); pthread_mutex_unlock(&Q); } void *worker(void *arg) { while (1) pop(); return NULL; } int main() { free = CAPACITY; used = 0; assert(free >= 0); assert(free <= CAPACITY); assert(used >= 0); assert(used <= CAPACITY); assert(used + free == CAPACITY); pthread_t worker1; pthread_t worker2; pthread_create(&worker1, NULL, worker, NULL); pthread_create(&worker2, NULL, worker, NULL); while (1) push(); return 0; }
Make `unsupported` actually be a bool...
#pragma once #include "llvm/ADT/StringRef.h" #include <set> #include <map> #include "Types.h" // TODO: This shouldn't really be here. More restructuring needed... struct hipCounter { llvm::StringRef hipName; ConvTypes countType; ApiTypes countApiType; int unsupported; }; #define HIP_UNSUPPORTED -1 /// Macros to ignore. extern const std::set<llvm::StringRef> CUDA_EXCLUDES; /// Maps cuda header names to hip header names. extern const std::map<llvm::StringRef, hipCounter> CUDA_INCLUDE_MAP; /// Maps the names of CUDA types to the corresponding hip types. extern const std::map<llvm::StringRef, hipCounter> CUDA_TYPE_NAME_MAP; /// Map all other CUDA identifiers (function/macro names, enum values) to hip versions. extern const std::map<llvm::StringRef, hipCounter> CUDA_IDENTIFIER_MAP; /** * The union of all the above maps. * * This should be used rarely, but is still needed to convert macro definitions (which can * contain any combination of the above things). AST walkers can usually get away with just * looking in the lookup table for the type of element they are processing, however, saving * a great deal of time. */ const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP();
#pragma once #include "llvm/ADT/StringRef.h" #include <set> #include <map> #include "Types.h" // TODO: This shouldn't really be here. More restructuring needed... struct hipCounter { llvm::StringRef hipName; ConvTypes countType; ApiTypes countApiType; bool unsupported; }; #define HIP_UNSUPPORTED true /// Macros to ignore. extern const std::set<llvm::StringRef> CUDA_EXCLUDES; /// Maps cuda header names to hip header names. extern const std::map<llvm::StringRef, hipCounter> CUDA_INCLUDE_MAP; /// Maps the names of CUDA types to the corresponding hip types. extern const std::map<llvm::StringRef, hipCounter> CUDA_TYPE_NAME_MAP; /// Map all other CUDA identifiers (function/macro names, enum values) to hip versions. extern const std::map<llvm::StringRef, hipCounter> CUDA_IDENTIFIER_MAP; /** * The union of all the above maps. * * This should be used rarely, but is still needed to convert macro definitions (which can * contain any combination of the above things). AST walkers can usually get away with just * looking in the lookup table for the type of element they are processing, however, saving * a great deal of time. */ const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP();
Change character encoding.(Shift_JIS -> UTF-8)
// Title: sleep // Name: sleep.c // Author: Matayoshi // Date: 2010/06/20 // Ver: 1.0.0 #include <stdio.h> #include <stdlib.h> #include <windows.h> int main(int argc, char* argv[]) { // `FbN if(argc < 2) { fprintf(stdout, "Usage: %s msec\n", argv[0]); exit(1); } else { char buf[16]; int wait = 0; // 񂩂琔lɕϊ sscanf(argv[1], "%15c", buf); if(sscanf(buf, "%d", &wait) != 1) { fprintf(stdout, "Usage: %s msec\n", argv[0]); exit(1); } // Ŏw肳ꂽ msec sleep(wait) Sleep(wait); } return 0; }
// Title: sleep // Name: sleep.c // Author: Matayoshi // Date: 2010/06/20 // Ver: 1.0.0 #include <stdio.h> #include <stdlib.h> #include <windows.h> int main(int argc, char* argv[]) { // 引数チェック if(argc < 2) { fprintf(stdout, "Usage: %s msec\n", argv[0]); exit(1); } else { char buf[16]; int wait = 0; // 文字列から数値に変換 sscanf(argv[1], "%15c", buf); if(sscanf(buf, "%d", &wait) != 1) { fprintf(stdout, "Usage: %s msec\n", argv[0]); exit(1); } // 引数で指定された msec だけ sleep(wait) Sleep(wait); } return 0; }
Rephrase FORCE_READ into something safer.
/* * Copyright 2016, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) */ #pragma once /* macros for forcing the compiler to leave in statments it would * normally optimize away */ #include <utils/attribute.h> #include <utils/stringify.h> /* Macro for doing dummy reads * * Expands to a volatile, unused variable which is set to the value at * a given address. It's volatile to prevent the compiler optimizing * away a variable that is written but never read, and it's unused to * prevent warnings about a variable that's never read. */ #define FORCE_READ(address) \ volatile UNUSED typeof(*address) JOIN(__force__read, __COUNTER__) = *(address)
/* * Copyright 2016, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) */ #pragma once /* macros for forcing the compiler to leave in statments it would * normally optimize away */ #include <utils/attribute.h> #include <utils/stringify.h> /* Macro for doing dummy reads * * Forces a memory read access to the given address. */ #define FORCE_READ(address) \ do { \ typeof(*(address)) *_ptr = (address); \ asm volatile ("" : "=m"(*_ptr) : "r"(*_ptr)); \ } while (0)
Use Daniel's trick for XFAIL'd tests
const char *s0 = m0; int s1 = m1; const char *s2 = m0; // FIXME: This test fails inexplicably on Windows in a manner that makes it // look like standard error isn't getting flushed properly. // RUN: true // RUNx: echo '#define m0 ""' > %t.h // RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h // RUNx: echo '' > %t.h // RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr // RUNx: grep "modified" %t.stderr // RUNx: echo '#define m0 000' > %t.h // RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h // RUNx: echo '' > %t.h // RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr // RUNx: grep "modified" %t.stderr // RUNx: echo '#define m0 000' > %t.h // RUNx: echo "#define m1 'abcd'" >> %t.h // RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h // RUNx: echo '' > %t.h // RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr // RUNx: grep "modified" %t.stderr
const char *s0 = m0; int s1 = m1; const char *s2 = m0; // FIXME: This test fails inexplicably on Windows in a manner that makes it // look like standard error isn't getting flushed properly. // RUN: false // XFAIL: * // RUN: echo '#define m0 ""' > %t.h // RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h // RUN: echo '' > %t.h // RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr // RUN: grep "modified" %t.stderr // RUN: echo '#define m0 000' > %t.h // RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h // RUN: echo '' > %t.h // RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr // RUN: grep "modified" %t.stderr // RUN: echo '#define m0 000' > %t.h // RUN: echo "#define m1 'abcd'" >> %t.h // RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h // RUN: echo '' > %t.h // RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr // RUN: grep "modified" %t.stderr
Verify if two lists intersect at Y point.
#include "listHelper.h" int intersectNode(struct linkList *l1, struct linkList *l2, int m, int n) { /* l1 \ l2 \ / \/ | | l1 is list1 with length m l2 is list2 with length n here, m is 5 and n is 4 so diff = abs(m-n) = 1 we need to hop 1 step on l1 to reach l2's length. from here on, we loop till end of list and verify id l1 == l2 if l1 == l2 somewhere, we have a Y list */ int diff = abs (m -n ); if ( m > n) { while ( diff ) { diff--; l1 = l1->next; } } if ( n > m ) { while ( diff ) { diff--; l2 = l2->next; } } while (l1 != NULL || l2 != NULL ) { if ( l1 == l2) return l1->data; else { l1 = l1->next; l2 = l2->next; } } } void main() { int dat; struct linkList *list1 = NULL, *list2 = NULL; InsertLinkedList(&list1, 21, 1); /*Insert node in Beginning */ InsertLinkedList(&list1, 31, 2); /*Insert at position 2 */ InsertLinkedList(&list1, 41, 3); InsertLinkedList(&list1, 51, 4); InsertLinkedList(&list1, 61, 5); InsertLinkedList(&list1, 72, 6); InsertLinkedList(&list1, 87, 7); InsertLinkedList(&list2, 91, 1); InsertLinkedList(&list2, 92, 2); InsertLinkedList(&list2, 93, 3); InsertLinkedList(&list2, 94, 4); displayList(list1); displayList(list2); /* build a Y list */ list2->next->next->next->next = list1->next->next->next; displayList(list1); displayList(list2); printf ( "Intersecting node is %d\n", intersectNode(list1, list2, 7, 8)); }
Use using instead of typedef
#ifndef DRAUPNIR_H__ #define DRAUPNIR_H__ #include <cstdint> #include "Sponge.h" #include "CrcSponge.h" #include "CrcSpongeBuilder.h" #include "Constants.h" namespace Draupnir { // utility typedefs typedef CrcSponge<std::uint64_t> CrcSponge64; typedef CrcSponge<std::uint32_t> CrcSponge32; typedef CrcSponge<std::uint16_t> CrcSponge16; typedef CrcSponge<std::uint8_t> CrcSponge8; typedef CrcSpongeBuilder<std::uint64_t> CrcSponge64Builder; typedef CrcSpongeBuilder<std::uint32_t> CrcSponge32Builder; typedef CrcSpongeBuilder<std::uint16_t> CrcSponge16Builder; typedef CrcSpongeBuilder<std::uint8_t> CrcSponge8Builder; } #endif /* DRAUPNIR_H__ */
#ifndef DRAUPNIR_H__ #define DRAUPNIR_H__ #include <cstdint> #include "Sponge.h" #include "CrcSponge.h" #include "CrcSpongeBuilder.h" #include "Constants.h" namespace Draupnir { // utility typedefs using CrcSponge64 = CrcSponge<std::uint64_t>; using CrcSponge32 = CrcSponge<std::uint32_t>; using CrcSponge16 = CrcSponge<std::uint16_t>; using CrcSponge8 = CrcSponge<std::uint8_t >; using CrcSponge64Builder = CrcSpongeBuilder<std::uint64_t>; using CrcSponge32Builder = CrcSpongeBuilder<std::uint32_t>; using CrcSponge16Builder = CrcSpongeBuilder<std::uint16_t>; using CrcSponge8Builder = CrcSpongeBuilder<std::uint8_t >; } #endif /* DRAUPNIR_H__ */
Fix missing thread analysis in 10/24
// PARAM: --enable exp.partition-arrays.enabled #include <pthread.h> pthread_t t_ids[10000]; void *t_fun(void *arg) { return NULL; } int main(void) { for (int i = 0; i < 10000; i++) pthread_create(&t_ids[i], NULL, t_fun, NULL); for (int i = 0; i < 10000; i++) pthread_join (t_ids[i], NULL); return 0; }
// PARAM: --set ana.activated[+] thread --enable exp.partition-arrays.enabled #include <pthread.h> pthread_t t_ids[10000]; void *t_fun(void *arg) { return NULL; } int main(void) { for (int i = 0; i < 10000; i++) pthread_create(&t_ids[i], NULL, t_fun, NULL); for (int i = 0; i < 10000; i++) pthread_join (t_ids[i], NULL); return 0; }
Include local header with quotes instead of angle brackets.
//===-- STLPostfixHeaderMap.h - hardcoded header map for STL ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H #include <HeaderMapCollector.h> namespace clang { namespace find_all_symbols { const HeaderMapCollector::HeaderMap* getSTLPostfixHeaderMap(); } // namespace find_all_symbols } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H
//===-- STLPostfixHeaderMap.h - hardcoded header map for STL ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H #include "HeaderMapCollector.h" namespace clang { namespace find_all_symbols { const HeaderMapCollector::HeaderMap* getSTLPostfixHeaderMap(); } // namespace find_all_symbols } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H
Bump version for openssl security updates
#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 true // 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
#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 1 #define CLIENT_VERSION_BUILD 0 // 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 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
Make sure our iovec abstraction is compatible with Windows WSABUF
/* * Copyright 2014 MongoDB, Inc. * * 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 MONGOC_IOVEC_H #define MONGOC_IOVEC_H #include <bson.h> #ifndef _WIN32 # include <sys/uio.h> #endif BSON_BEGIN_DECLS #ifdef _WIN32 typedef struct { u_long iov_len; char *iov_base; } mongoc_iovec_t; #else typedef struct iovec mongoc_iovec_t; #endif BSON_END_DECLS #endif /* MONGOC_IOVEC_H */
/* * Copyright 2014 MongoDB, Inc. * * 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 MONGOC_IOVEC_H #define MONGOC_IOVEC_H #include <bson.h> #ifdef _WIN32 # include <stddef.h> #else # include <sys/uio.h> #endif BSON_BEGIN_DECLS #ifdef _WIN32 typedef struct { u_long iov_len; char *iov_base; } mongoc_iovec_t; BSON_STATIC_ASSERT(sizeof(mongoc_iovec_t) == sizeof(WSABUF)); BSON_STATIC_ASSERT(offsetof(mongoc_iovec_t, iov_base) == offsetof(WSABUF, buf)); BSON_STATIC_ASSERT(offsetof(mongoc_iovec_t, iov_len) == offsetof(WSABUF, len)); #else typedef struct iovec mongoc_iovec_t; #endif BSON_END_DECLS #endif /* MONGOC_IOVEC_H */
Document full requirements for the beacon mapper
// // Created by Scott Stark on 6/12/15. // #ifndef NATIVESCANNER_BEACONMAPPER_H #define NATIVESCANNER_BEACONMAPPER_H #include <map> #include <string> using namespace std; /** * Map a beacon id to the registered user by querying the application registration rest api */ class BeaconMapper { private: map<int, string> beaconToUser; public: /** * Query the current user registrations to update the beacon minorID to name mappings */ void refresh(); string lookupUser(int minorID); }; #endif //NATIVESCANNER_BEACONMAPPER_H
// // Created by Scott Stark on 6/12/15. // #ifndef NATIVESCANNER_BEACONMAPPER_H #define NATIVESCANNER_BEACONMAPPER_H #include <map> #include <string> using namespace std; /** * Map a beacon id to the registered user by querying the application registration rest api * * Relies on: * git clone https://github.com/open-source-parsers/jsoncpp.git * cd jsoncpp/ * mkdir build * cd build/ * cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON .. * make * make install * * git clone https://github.com/mrtazz/restclient-cpp.git * apt-get install autoconf * apt-get install libtool * apt-get install libcurl4-openssl-dev * cd restclient-cpp/ * ./autogen.sh * ./configure * make * make install */ class BeaconMapper { private: map<int, string> beaconToUser; public: /** * Query the current user registrations to update the beacon minorID to name mappings */ void refresh(); string lookupUser(int minorID); }; #endif //NATIVESCANNER_BEACONMAPPER_H
Add missing event fixture file.
#ifndef VAST_TEST_UNIT_EVENT_FIXTURE_H #define VAST_TEST_UNIT_EVENT_FIXTURE_H #include <vector> #include "vast/event.h" struct event_fixture { event_fixture(); std::vector<vast::event> events; }; #endif
Support RN 0.40 headers while retaining backwards compatibility.
// // RNSketchManager.m // RNSketch // // Created by Jeremy Grancher on 28/04/2016. // Copyright © 2016 Jeremy Grancher. All rights reserved. // #import "RCTViewManager.h" #import "RNSketch.h" @interface RNSketchManager : RCTViewManager @property (strong) RNSketch *sketchView; @end;
// // RNSketchManager.m // RNSketch // // Created by Jeremy Grancher on 28/04/2016. // Copyright © 2016 Jeremy Grancher. All rights reserved. // #if __has_include(<React/RCTViewManager.h>) // React Native >= 0.40 #import <React/RCTViewManager.h> #else // React Native <= 0.39 #import "RCTViewManager.h" #endif #import "RNSketch.h" @interface RNSketchManager : RCTViewManager @property (strong) RNSketch *sketchView; @end;
Add a typedef for iterators.
// Copyright (c) 2014 Rob Rix. All rights reserved. #import <Foundation/Foundation.h> @protocol REDIterable <NSObject> @property (readonly) id(^red_iterator)(void); @end
// Copyright (c) 2014 Rob Rix. All rights reserved. #import <Foundation/Foundation.h> /// A nullary block iterating the elements of a collection over successive calls. /// /// \return The next object in the collection, or nil if it has iterated the entire collection. typedef id (^REDIteratingBlock)(void); /// A collection which can be iterated. @protocol REDIterable <NSObject> /// An iterator for this collection. @property (readonly) REDIteratingBlock red_iterator; @end
Correct case of STDC pragmas
// RUN: %check %s #pragma STDC FENV_ACCESS on _Pragma("STDC FENV_ACCESS on"); // CHECK: warning: unhandled STDC pragma // CHECK: ^warning: extra ';' at global scope #define LISTING(x) PRAGMA(listing on #x) #define PRAGMA(x) _Pragma(#x) LISTING(../listing) // CHECK: warning: unknown pragma 'listing on "../listing"' _Pragma(L"STDC CX_LIMITED_RANGE off") // CHECK: warning: unhandled STDC pragma // CHECK: ^!/warning: extra ';'/ #pragma STDC FP_CONTRACT off main() { }
// RUN: %check %s #pragma STDC FENV_ACCESS ON _Pragma("STDC FENV_ACCESS ON"); // CHECK: warning: unhandled STDC pragma // CHECK: ^warning: extra ';' at global scope #define LISTING(x) PRAGMA(listing on #x) #define PRAGMA(x) _Pragma(#x) LISTING(../listing) // CHECK: warning: unknown pragma 'listing on "../listing"' _Pragma(L"STDC CX_LIMITED_RANGE OFF") // CHECK: warning: unhandled STDC pragma // CHECK: ^!/warning: extra ';'/ #pragma STDC FP_CONTRACT OFF int main() { }
Correct import path to match RN 0.40
#import "RCTBridgeModule.h" @interface KCKeepAwake : NSObject <RCTBridgeModule> @end
#import <React/RCTBridgeModule.h> @interface KCKeepAwake : NSObject <RCTBridgeModule> @end
Fix solution to Exercise 1-12.
/* * A solution to Exercise 1-12 in The C Programming Language (Second Edition). * * This file was written by Damien Dart <damiendart@pobox.com>. This is free * and unencumbered software released into the public domain. For more * information, please refer to the accompanying "UNLICENCE" file. */ #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> int main(void) { int16_t character = 0; bool in_whitespace = false; while ((character = getchar()) != EOF) { if ((character == ' ') || (character == '\t')) { if (in_whitespace == false) { putchar('\n'); in_whitespace = true; } } else { putchar(character); in_whitespace = false; } } return EXIT_SUCCESS; }
/* * A solution to Exercise 1-12 in The C Programming Language (Second Edition). * * This file was written by Damien Dart <damiendart@pobox.com>. This is free * and unencumbered software released into the public domain. For more * information, please refer to the accompanying "UNLICENCE" file. */ #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> int main(void) { int16_t character = 0; bool in_whitespace = false; while ((character = getchar()) != EOF) { if ((character == ' ') || (character == '\t' || character == '\n')) { if (in_whitespace == false) { putchar('\n'); in_whitespace = true; } } else { putchar(character); in_whitespace = false; } } return EXIT_SUCCESS; }
Fix timezone data path for Unix and win32.
/*------------------------------------------------------------------------- * * pgtz.c * Timezone Library Integration Functions * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * * IDENTIFICATION * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.5 2004/05/01 01:38:53 momjian Exp $ * *------------------------------------------------------------------------- */ #include "pgtz.h" #include "tzfile.h" static char tzdir[MAXPGPATH]; static int done_tzdir = 0; char * pg_TZDIR(void) { char *p; if (done_tzdir) return tzdir; #ifndef WIN32 StrNCpy(tzdir, PGDATADIR, MAXPGPATH); #else if (GetModuleFileName(NULL, tzdir, MAXPGPATH) == 0) return NULL; #endif canonicalize_path(tzdir); #if 0 if ((p = last_path_separator(tzdir)) == NULL) return NULL; else *p = '\0'; #endif strcat(tzdir, "/timezone"); done_tzdir = 1; return tzdir; }
/*------------------------------------------------------------------------- * * pgtz.c * Timezone Library Integration Functions * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * * IDENTIFICATION * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.6 2004/05/01 22:07:03 momjian Exp $ * *------------------------------------------------------------------------- */ #include "pgtz.h" #include "tzfile.h" static char tzdir[MAXPGPATH]; static int done_tzdir = 0; char * pg_TZDIR(void) { char *p; if (done_tzdir) return tzdir; #ifndef WIN32 StrNCpy(tzdir, PGDATADIR, MAXPGPATH); #else if (GetModuleFileName(NULL, tzdir, MAXPGPATH) == 0) return NULL; #endif canonicalize_path(tzdir); #ifdef WIN32 /* trim off binary name, then go up a directory */ if ((p = last_path_separator(tzdir)) == NULL) return NULL; else *p = '\0'; strcat(tzdir, "/../share/timezone"); #endif strcat(tzdir, "/timezone"); done_tzdir = 1; return tzdir; }
Remove including <complex.h> in test case, and change to use _Complex instead.
// RUN: %clang -target aarch64-linux-gnuabi %s -O3 -S -emit-llvm -o - | FileCheck %s #include <complex.h> complex long double a, b, c, d; void test_fp128_compound_assign(void) { // CHECK: tail call { fp128, fp128 } @__multc3 a *= b; // CHECK: tail call { fp128, fp128 } @__divtc3 c /= d; }
// RUN: %clang -target aarch64-linux-gnuabi %s -O3 -S -emit-llvm -o - | FileCheck %s _Complex long double a, b, c, d; void test_fp128_compound_assign(void) { // CHECK: tail call { fp128, fp128 } @__multc3 a *= b; // CHECK: tail call { fp128, fp128 } @__divtc3 c /= d; }
Integrate mbed OS RTC with mbed TLS
/** * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #if defined(DEVICE_TRNG) #define MBEDTLS_ENTROPY_HARDWARE_ALT #endif #if defined(MBEDTLS_CONFIG_HW_SUPPORT) #include "mbedtls_device.h" #endif
/** * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #if defined(DEVICE_TRNG) #define MBEDTLS_ENTROPY_HARDWARE_ALT #endif #if defined(DEVICE_RTC) #define MBEDTLS_HAVE_TIME_DATE #endif #if defined(MBEDTLS_CONFIG_HW_SUPPORT) #include "mbedtls_device.h" #endif
Remove 'explicit' on copy constructor
#ifndef CELL_H #define CELL_H #include <map> #include <vector> #include "number.h" class Cell { public: Cell(); explicit Cell(const Cell &rhs); explicit Cell(Cell *value); explicit Cell(bool value); explicit Cell(Number value); explicit Cell(const std::string &value); explicit Cell(const char *value); explicit Cell(const std::vector<Cell> &value); explicit Cell(const std::map<std::string, Cell> &value); Cell &operator=(const Cell &rhs); bool operator==(const Cell &rhs) const; Cell *address_value; bool boolean_value; Number number_value; std::string string_value; std::vector<Cell> array_value; std::map<std::string, Cell> dictionary_value; }; #endif
#ifndef CELL_H #define CELL_H #include <map> #include <vector> #include "number.h" class Cell { public: Cell(); Cell(const Cell &rhs); explicit Cell(Cell *value); explicit Cell(bool value); explicit Cell(Number value); explicit Cell(const std::string &value); explicit Cell(const char *value); explicit Cell(const std::vector<Cell> &value); explicit Cell(const std::map<std::string, Cell> &value); Cell &operator=(const Cell &rhs); bool operator==(const Cell &rhs) const; Cell *address_value; bool boolean_value; Number number_value; std::string string_value; std::vector<Cell> array_value; std::map<std::string, Cell> dictionary_value; }; #endif
Remove getZip() which got there by mistake
#ifndef QUAZIP_TEST_QUAZIP_H #define QUAZIP_TEST_QUAZIP_H #include <QObject> class TestQuaZip: public QObject { Q_OBJECT private slots: void getFileList_data(); void getFileList(); void getZip(); }; #endif // QUAZIP_TEST_QUAZIP_H
#ifndef QUAZIP_TEST_QUAZIP_H #define QUAZIP_TEST_QUAZIP_H #include <QObject> class TestQuaZip: public QObject { Q_OBJECT private slots: void getFileList_data(); void getFileList(); }; #endif // QUAZIP_TEST_QUAZIP_H
Use gint to store index
#ifndef _FAKE_LOCK_SCREEN_PATTERN_H_ #define _FAKE_LOCK_SCREEN_PATTERN_H_ #include <gtk/gtk.h> #if !GTK_CHECK_VERSION(3, 0, 0) typedef struct { gdouble red; gdouble green; gdouble blue; gdouble alpha; } GdkRGBA; #endif typedef struct _FakeLockOption { void *module; gchar *real; gchar *dummy; } FakeLockOption; typedef struct { gboolean marked; gint value; GdkPoint top_left; GdkPoint bottom_right; } FakeLockPatternPoint; typedef enum { FLSP_ONE_STROKE, FLSP_ON_BOARD, FLSP_N_PATTERN, } FakeLockScreenPattern; void flsp_draw_circle(cairo_t *context, gint x, gint y, gint radius, GdkRGBA circle, GdkRGBA border); gboolean is_marked(gint x, gint y, gint *marked, void *user_data); #endif
#ifndef _FAKE_LOCK_SCREEN_PATTERN_H_ #define _FAKE_LOCK_SCREEN_PATTERN_H_ #include <gtk/gtk.h> #if !GTK_CHECK_VERSION(3, 0, 0) typedef struct { gdouble red; gdouble green; gdouble blue; gdouble alpha; } GdkRGBA; #endif typedef struct _FakeLockOption { void *module; gchar *real; gchar *dummy; } FakeLockOption; typedef struct { gint mark; gint value; GdkPoint top_left; GdkPoint bottom_right; } FakeLockPatternPoint; typedef enum { FLSP_ONE_STROKE, FLSP_ON_BOARD, FLSP_N_PATTERN, } FakeLockScreenPattern; void flsp_draw_circle(cairo_t *context, gint x, gint y, gint radius, GdkRGBA circle, GdkRGBA border); gboolean is_marked(gint x, gint y, gint *marked, void *user_data); #endif
Add file to handle executing commands from stdin
#ifndef _WISH_COMMANDER #define _WISH_COMMANDER #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/wait.h> char *exit_color; int execute(char *path, char *arg_arr[]) { int pid; if (!(pid = fork())) { execvp(path, arg_arr); // This is only reached if the execvp function fails exit(-1); } else { int status; wait(&status); return status; } } int get_and_run_userin() { char buff[256]; fgets(buff, sizeof(buff), stdin); // Buff will have space-separated command line arguments, then a newline, // then a terminating null. We can use strsep to get rid of the newline. // Since fgets will terminate on the first newline, we can be certain there // is no next command after it char *ptr_to_buff = buff; char *command = strsep(&ptr_to_buff, "\n"); // Blank lines should just return 0, since a blank command doesn't 'crash' if (!(*command)) { return 0; } int num_args = 1; int i; for (i = 0; command[i]; i++) { if (command[i] == ' ') num_args++; } char *args[num_args + 1]; for (i = 0; i < num_args; i++) { args[i] = strsep(&command, " "); } args[num_args] = NULL; return execute(args[0], args); } #endif
Use a different way of handling no host commands
/* Copyright 2021 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #if !defined(__CROS_EC_HOST_COMMAND_H) || \ defined(__CROS_EC_ZEPHYR_HOST_COMMAND_H) #error "This file must only be included from host_command.h. " \ "Include host_command.h directly" #endif #define __CROS_EC_ZEPHYR_HOST_COMMAND_H #include <init.h> #ifdef CONFIG_PLATFORM_EC_HOSTCMD /** * See include/host_command.h for documentation. */ #define DECLARE_HOST_COMMAND(_command, _routine, _version_mask) \ STRUCT_SECTION_ITERABLE(host_command, _cros_hcmd_##_command) = { \ .command = _command, \ .handler = _routine, \ .version_mask = _version_mask, \ } #else /* !CONFIG_PLATFORM_EC_HOSTCMD */ #ifdef __clang__ #define DECLARE_HOST_COMMAND(command, routine, version_mask) #else #define DECLARE_HOST_COMMAND(command, routine, version_mask) \ enum ec_status (routine)(struct host_cmd_handler_args *args) \ __attribute__((unused)) #endif /* __clang__ */ #endif /* CONFIG_PLATFORM_EC_HOSTCMD */
/* Copyright 2021 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #if !defined(__CROS_EC_HOST_COMMAND_H) || \ defined(__CROS_EC_ZEPHYR_HOST_COMMAND_H) #error "This file must only be included from host_command.h. " \ "Include host_command.h directly" #endif #define __CROS_EC_ZEPHYR_HOST_COMMAND_H #include <init.h> #ifdef CONFIG_PLATFORM_EC_HOSTCMD /** * See include/host_command.h for documentation. */ #define DECLARE_HOST_COMMAND(_command, _routine, _version_mask) \ STRUCT_SECTION_ITERABLE(host_command, _cros_hcmd_##_command) = { \ .command = _command, \ .handler = _routine, \ .version_mask = _version_mask, \ } #else /* !CONFIG_PLATFORM_EC_HOSTCMD */ /* * Create a fake routine to call the function. The linker should * garbage-collect it since it is behind 'if (0)' */ #define DECLARE_HOST_COMMAND(command, routine, version_mask) \ int __remove_ ## command(void) \ { \ if (0) \ routine(NULL); \ return 0; \ } #endif /* CONFIG_PLATFORM_EC_HOSTCMD */
Add header with structs representing basic display types
/* Copyright (c) 2013 Adam Dej Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __DISPLAY_DEVICE_H #define __DISPLAY_DEVICE_H #include <stdint.h> #include <stdbool.h> #ifdef EMBDEGFX_16 typedef uint16_t uintpix; #else typedef uint8_t uintpix; #endif typedef struct { void *data; bool (*set_pixel)(uintpix x, uintpix y, void *data); bool (*unset_pixel)(uintpix x, uintpix y, void *data); bool (*clear_display)(void *data); bool (*commit)(void *data); } DISPLAY_1BIT; typedef struct { //TODO } DISPLAY_8BIT; typedef struct { //TODO } DISPLAY_24BIT; //If none of those modes is suitable feel free to add your own #endif
Remove LTO dependency from test
// RUN: %clang_profgen -o %t -O3 -flto %s // RUN: env LLVM_PROFILE_FILE=%t.profraw %t // RUN: llvm-profdata merge -o %t.profdata %t.profraw // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s int main(int argc, const char *argv[]) { // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof !1 if (argc) return 0; return 1; } // CHECK: !1 = metadata !{metadata !"branch_weights", i32 2, i32 1}
// RUN: %clang_profgen -o %t -O3 %s // RUN: env LLVM_PROFILE_FILE=%t.profraw %t // RUN: llvm-profdata merge -o %t.profdata %t.profraw // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s int main(int argc, const char *argv[]) { // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof !1 if (argc) return 0; return 1; } // CHECK: !1 = metadata !{metadata !"branch_weights", i32 2, i32 1}
Add missing import for UIControl+SAMAdditions.h
// // SAMCategories.h // SAMCategories // // Created by Sam Soffes on 7/17/13. // Copyright 2013 Sam Soffes. All rights reserved. // // Foundation #import "NSArray+SAMAdditions.h" #import "NSData+SAMAdditions.h" #import "NSDate+SAMAdditions.h" #import "NSDictionary+SAMAdditions.h" #import "NSNumber+SAMAdditions.h" #import "NSObject+SAMAdditions.h" #import "NSString+SAMAdditions.h" #import "NSURL+SAMAdditions.h" // UIKit #if TARGET_OS_IPHONE #import "UIApplication+SAMAdditions.h" #import "UIColor+SAMAdditions.h" #import "UIDevice+SAMAdditions.h" #import "UIScreen+SAMAdditions.h" #import "UIScrollView+SAMAdditions.h" #import "UIView+SAMAdditions.h" #import "UIViewController+SAMAdditions.h" #endif
// // SAMCategories.h // SAMCategories // // Created by Sam Soffes on 7/17/13. // Copyright 2013 Sam Soffes. All rights reserved. // // Foundation #import "NSArray+SAMAdditions.h" #import "NSData+SAMAdditions.h" #import "NSDate+SAMAdditions.h" #import "NSDictionary+SAMAdditions.h" #import "NSNumber+SAMAdditions.h" #import "NSObject+SAMAdditions.h" #import "NSString+SAMAdditions.h" #import "NSURL+SAMAdditions.h" // UIKit #if TARGET_OS_IPHONE #import "UIApplication+SAMAdditions.h" #import "UIColor+SAMAdditions.h" #import "UIControl+SAMAdditions.h" #import "UIDevice+SAMAdditions.h" #import "UIScreen+SAMAdditions.h" #import "UIScrollView+SAMAdditions.h" #import "UIView+SAMAdditions.h" #import "UIViewController+SAMAdditions.h" #endif
Test non-finite soft float addition
#include "src/math/reinterpret.h" #include <assert.h> long double __addtf3(long double, long double); static _Bool equivalent(long double x, long double y) { if (x != x) return y != y; return reinterpret(unsigned __int128, x) == reinterpret(unsigned __int128, y); } static _Bool run(long double x, long double y) { return equivalent(x + y, __addtf3(x, y)); } #define TEST(x, y) do { \ _Static_assert(__builtin_constant_p((long double)(x) + (long double)(y)), "This test requires compile-time constants"); \ assert(run(x, y)); \ } while (0)
#include "src/math/reinterpret.h" #include <math.h> #include <assert.h> long double __addtf3(long double, long double); static _Bool run(long double x, long double y) { return reinterpret(unsigned __int128, x + y) == reinterpret(unsigned __int128, __addtf3(x, y)); } int main(void) { assert(isnan(__addtf3(NAN, NAN))); assert(isnan(__addtf3(NAN, INFINITY))); assert(isnan(__addtf3(NAN, 0x1.23456789abcdefp+3L))); assert(isnan(__addtf3(INFINITY, -INFINITY))); assert(run(INFINITY, INFINITY)); assert(run(INFINITY, -0x1.23456789abcdefp+3849L)); }
Fix the build on Windows
#ifndef __CLAR_TEST_ATTR_EXPECT__ #define __CLAR_TEST_ATTR_EXPECT__ enum attr_expect_t { EXPECT_FALSE, EXPECT_TRUE, EXPECT_UNDEFINED, EXPECT_STRING }; struct attr_expected { const char *path; const char *attr; enum attr_expect_t expected; const char *expected_str; }; static inline void attr_check_expected( enum attr_expect_t expected, const char *expected_str, const char *value) { switch (expected) { case EXPECT_TRUE: cl_assert(GIT_ATTR_TRUE(value)); break; case EXPECT_FALSE: cl_assert(GIT_ATTR_FALSE(value)); break; case EXPECT_UNDEFINED: cl_assert(GIT_ATTR_UNSPECIFIED(value)); break; case EXPECT_STRING: cl_assert_strequal(expected_str, value); break; } } #endif
#ifndef __CLAR_TEST_ATTR_EXPECT__ #define __CLAR_TEST_ATTR_EXPECT__ enum attr_expect_t { EXPECT_FALSE, EXPECT_TRUE, EXPECT_UNDEFINED, EXPECT_STRING }; struct attr_expected { const char *path; const char *attr; enum attr_expect_t expected; const char *expected_str; }; GIT_INLINE(void) attr_check_expected( enum attr_expect_t expected, const char *expected_str, const char *value) { switch (expected) { case EXPECT_TRUE: cl_assert(GIT_ATTR_TRUE(value)); break; case EXPECT_FALSE: cl_assert(GIT_ATTR_FALSE(value)); break; case EXPECT_UNDEFINED: cl_assert(GIT_ATTR_UNSPECIFIED(value)); break; case EXPECT_STRING: cl_assert_strequal(expected_str, value); break; } } #endif
Bump the version number for development.
/* * Copyright (C) 2011 by Nelson Elhage * * 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. */ #define REPTYR_VERSION "0.4" int attach_child(pid_t pid, const char *pty, int force_stdio); #define __printf __attribute__((format(printf, 1, 2))) void __printf die(const char *msg, ...); void __printf debug(const char *msg, ...); void __printf error(const char *msg, ...);
/* * Copyright (C) 2011 by Nelson Elhage * * 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. */ #define REPTYR_VERSION "0.4dev" int attach_child(pid_t pid, const char *pty, int force_stdio); #define __printf __attribute__((format(printf, 1, 2))) void __printf die(const char *msg, ...); void __printf debug(const char *msg, ...); void __printf error(const char *msg, ...);
Move method after property declaration
// // EditPatientForm.h // OpenMRS-iOS // // Created by Yousef Hamza on 7/5/15. // Copyright (c) 2015 Erway Software. All rights reserved. // #import "XLForm.h" #import "XLFormViewController.h" #import "MRSPatient.h" @interface EditPatientForm : XLFormViewController <UIAlertViewDelegate> - (instancetype)initWithPatient:(MRSPatient *)patient; @property (nonatomic, strong) MRSPatient *patient; @end
// // EditPatientForm.h // OpenMRS-iOS // // Created by Yousef Hamza on 7/5/15. // Copyright (c) 2015 Erway Software. All rights reserved. // #import "XLForm.h" #import "XLFormViewController.h" #import "MRSPatient.h" @interface EditPatientForm : XLFormViewController <UIAlertViewDelegate> @property (nonatomic, strong) MRSPatient *patient; - (instancetype)initWithPatient:(MRSPatient *)patient; @end
Fix the *longjmp() behaviour - it is legal to reuse a jmp_buf several times. Gets us a working perl 5.8.
/* $OpenBSD: setjmp.h,v 1.6 2001/08/12 12:03:02 heko Exp $ */ /* * machine/setjmp.h: machine dependent setjmp-related information. */ #ifndef __MACHINE_SETJMP_H__ #define __MACHINE_SETJMP_H__ #define _JBLEN 22 /* size, in longs, of a jmp_buf */ #endif /* __MACHINE_SETJMP_H__ */
/* $OpenBSD: setjmp.h,v 1.7 2003/08/01 07:41:33 miod Exp $ */ /* * machine/setjmp.h: machine dependent setjmp-related information. */ #ifndef __MACHINE_SETJMP_H__ #define __MACHINE_SETJMP_H__ #define _JBLEN 21 /* size, in longs, of a jmp_buf */ #endif /* __MACHINE_SETJMP_H__ */
Add the vpsc library for IPSEPCOLA features
/** * \brief A block structure defined over the variables * * A block structure defined over the variables such that each block contains * 1 or more variables, with the invariant that all constraints inside a block * are satisfied by keeping the variables fixed relative to one another * * Authors: * Tim Dwyer <tgdwyer@gmail.com> * * Copyright (C) 2005 Authors * * This version is released under the CPL (Common Public License) with * the Graphviz distribution. * A version is also available under the LGPL as part of the Adaptagrams * project: http://sourceforge.net/projects/adaptagrams. * If you make improvements or bug fixes to this code it would be much * appreciated if you could also contribute those changes back to the * Adaptagrams repository. */ #ifndef SEEN_REMOVEOVERLAP_BLOCKS_H #define SEEN_REMOVEOVERLAP_BLOCKS_H #ifdef RECTANGLE_OVERLAP_LOGGING #define LOGFILE "cRectangleOverlap.log" #endif #include <set> #include <list> class Block; class Variable; class Constraint; /** * A block structure defined over the variables such that each block contains * 1 or more variables, with the invariant that all constraints inside a block * are satisfied by keeping the variables fixed relative to one another */ class Blocks : public std::set<Block*> { public: Blocks(const int n, Variable *vs[]); ~Blocks(void); void mergeLeft(Block *r); void mergeRight(Block *l); void split(Block *b, Block *&l, Block *&r, Constraint *c); std::list<Variable*> *totalOrder(); void cleanup(); double cost(); private: void dfsVisit(Variable *v, std::list<Variable*> *order); void removeBlock(Block *doomed); Variable **vs; int nvs; }; extern long blockTimeCtr; #endif // SEEN_REMOVEOVERLAP_BLOCKS_H
Fix build on FreeBSD after r196141
//===-- lldb-python.h --------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLDB_lldb_python_h_ #define LLDB_lldb_python_h_ // Python.h needs to be included before any system headers in order to avoid redefinition of macros #ifdef LLDB_DISABLE_PYTHON // Python is disabled in this build #else #include <Python/Python.h> #endif // LLDB_DISABLE_PYTHON #endif // LLDB_lldb_python_h_
//===-- lldb-python.h --------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLDB_lldb_python_h_ #define LLDB_lldb_python_h_ // Python.h needs to be included before any system headers in order to avoid redefinition of macros #ifdef LLDB_DISABLE_PYTHON // Python is disabled in this build #else #ifdef __FreeBSD__ #include <Python.h> #else #include <Python/Python.h> #endif #endif // LLDB_DISABLE_PYTHON #endif // LLDB_lldb_python_h_
Initialize variable in the declaration
#include <pal.h> /** * * Converts integer values in 'a' to floating point values. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @param p Number of processor to use (task parallelism) * * @param team Team to work with * * @return None * */ #include <math.h> void p_itof(int *a, float *c, int n, int p, p_team_t team) { int i; for(i = 0; i < n; i++) { *(c + i) = (float)(*(a + i)); } }
#include <pal.h> /** * * Converts integer values in 'a' to floating point values. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @param p Number of processor to use (task parallelism) * * @param team Team to work with * * @return None * */ #include <math.h> void p_itof(int *a, float *c, int n, int p, p_team_t team) { for(int i = 0; i < n; i++) { *(c + i) = (float)(*(a + i)); } }
Move AliD0toKpi* and AliBtoJPSI* from libPWG3base to libPWG3 (Andrea)
#ifdef __CINT__ #pragma link off all glols; #pragma link off all classes; #pragma link off all functions; #endif
#ifdef __CINT__ #pragma link off all glols; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class AliD0toKpi+; #pragma link C++ class AliD0toKpiAnalysis+; #pragma link C++ class AliBtoJPSItoEle+; #pragma link C++ class AliBtoJPSItoEleAnalysis+; #endif
Move run into new method
#include <stdio.h> unsigned int x; char in; void input(void); void main(void){ x = 0; input(); } void input(void){ printf(">> "); /* Bash-like input */ scanf("%c", &in); /* Get char input */ /* Boundary checks */ if(x == 256 || x == -1) x = 0; /* Operators */ switch(in){ case 'i': case 'x': x++; case 'd': x--; case 'o': case 'c': printf("%d\n", x); case 's': case 'k': x = x*x; default: printf("\n"); } input(); /* Loop */ }
#include <stdio.h> unsigned int x; char in; void input(void); void run(char c); void main(void){ x = 0; input(); } void input(void){ printf(">> "); /* Bash-like input */ scanf("%c", &in); /* Get char input */ run(in); input(); /* Loop */ } void run(char c){ /* Boundary checks */ if(x == 256 || x == -1) x = 0; /* Operators */ switch(in){ case 'i': case 'x': x++; case 'd': x--; case 'o': case 'c': printf("%d\n", x); case 's': case 'k': x = x*x; default: printf("\n"); } }
Convert lsapic to new irq_chip functions
/* * LSAPIC Interrupt Controller * * This takes care of interrupts that are generated by the CPU's * internal Streamlined Advanced Programmable Interrupt Controller * (LSAPIC), such as the ITC and IPI interrupts. * * Copyright (C) 1999 VA Linux Systems * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> * Copyright (C) 2000 Hewlett-Packard Co * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com> */ #include <linux/sched.h> #include <linux/irq.h> static unsigned int lsapic_noop_startup (unsigned int irq) { return 0; } static void lsapic_noop (unsigned int irq) { /* nothing to do... */ } static int lsapic_retrigger(unsigned int irq) { ia64_resend_irq(irq); return 1; } struct irq_chip irq_type_ia64_lsapic = { .name = "LSAPIC", .startup = lsapic_noop_startup, .shutdown = lsapic_noop, .enable = lsapic_noop, .disable = lsapic_noop, .ack = lsapic_noop, .retrigger = lsapic_retrigger, };
/* * LSAPIC Interrupt Controller * * This takes care of interrupts that are generated by the CPU's * internal Streamlined Advanced Programmable Interrupt Controller * (LSAPIC), such as the ITC and IPI interrupts. * * Copyright (C) 1999 VA Linux Systems * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> * Copyright (C) 2000 Hewlett-Packard Co * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com> */ #include <linux/sched.h> #include <linux/irq.h> static unsigned int lsapic_noop_startup (struct irq_data *data) { return 0; } static void lsapic_noop (struct irq_data *data) { /* nothing to do... */ } static int lsapic_retrigger(struct irq_data *data) { ia64_resend_irq(data->irq); return 1; } struct irq_chip irq_type_ia64_lsapic = { .name = "LSAPIC", .irq_startup = lsapic_noop_startup, .irq_shutdown = lsapic_noop, .irq_enable = lsapic_noop, .irq_disable = lsapic_noop, .irq_ack = lsapic_noop, .irq_retrigger = lsapic_retrigger, };
Change product Id to string
#ifndef _PURCHASEEVENT_H_ #define _PURCHASEEVENT_H_ #include <Event.h> class PurchaseEvent : public Event { public: enum Type { PURCHASE_STATUS }; PurchaseEvent(double _timestamp, int _productId, Type _type, bool _newPurchase) : Event(_timestamp), type(_type), newPurchase(_newPurchase), productId(_productId) { } Event * dup() const override { return new PurchaseEvent(*this); } void dispatch(EventHandler & element) override; bool isBroadcast() const override { return true; } Type getType() { return type; } bool isNew() { return newPurchase; } int getProductId() { return productId; } private: Type type; bool newPurchase; int productId; }; #endif
#ifndef _PURCHASEEVENT_H_ #define _PURCHASEEVENT_H_ #include <Event.h> class PurchaseEvent : public Event { public: enum Type { PURCHASE_STATUS }; PurchaseEvent(double _timestamp, std::string _productId, Type _type, bool _newPurchase) : Event(_timestamp), type(_type), newPurchase(_newPurchase), productId(_productId) { } Event * dup() const override { return new PurchaseEvent(*this); } void dispatch(EventHandler & element) override; bool isBroadcast() const override { return true; } Type getType() { return type; } bool isNew() { return newPurchase; } std::string getProductId() { return productId; } private: Type type; bool newPurchase; std::string productId; }; #endif
Add uobject stub to make the script generator plugin happy
#pragma once #include <Engine.h> #include "StubUObject.generated.h" // This class is only here to make sure we're visible to UHT. // We need to be visible to UHT so that UE4HaxeExternGenerator works correctly // (as any script generator must return a module name that is visible to UHT) // see IScriptGeneratorPluginInterface::GetGeneratedCodeModuleName for the related code UCLASS() class HAXEINIT_API UObjectStub : public UObject { GENERATED_BODY() };
Add x86 requirement to hopefully fix ppc bots.
// RUN: %clang_cc1 %s -verify -fasm-blocks #define M __asm int 0x2c #define M2 int void t1(void) { M } void t2(void) { __asm int 0x2c } void t3(void) { __asm M2 0x2c } void t4(void) { __asm mov eax, fs:[0x10] } void t5() { __asm { int 0x2c ; } asm comments are fun! }{ } __asm {} } int t6() { __asm int 3 ; } comments for single-line asm __asm {} __asm int 4 return 10; } void t7() { __asm { push ebx mov ebx, 0x07 pop ebx } } void t8() { __asm nop __asm nop __asm nop } void t9() { __asm nop __asm nop ; __asm nop } int t_fail() { // expected-note {{to match this}} __asm __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
// REQUIRES: x86-64-registered-target // RUN: %clang_cc1 %s -verify -fasm-blocks #define M __asm int 0x2c #define M2 int void t1(void) { M } void t2(void) { __asm int 0x2c } void t3(void) { __asm M2 0x2c } void t4(void) { __asm mov eax, fs:[0x10] } void t5() { __asm { int 0x2c ; } asm comments are fun! }{ } __asm {} } int t6() { __asm int 3 ; } comments for single-line asm __asm {} __asm int 4 return 10; } void t7() { __asm { push ebx mov ebx, 0x07 pop ebx } } void t8() { __asm nop __asm nop __asm nop } void t9() { __asm nop __asm nop ; __asm nop } int t_fail() { // expected-note {{to match this}} __asm __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
Add stdbool to the datatype header
// The Mordax Microkernel // (c) Kristian Klomsten Skordal 2013 <kristian.skordal@gmail.com> // Report bugs and issues on <http://github.com/skordal/mordax/issues> #ifndef MORDAX_TYPES_H #define MORDAX_TYPES_H #include <stdint.h> /** Object size type. */ typedef uint32_t size_t; /** Physical pointer type. */ typedef void * physical_ptr; /** 64-bit generic big endian type. */ typedef uint64_t be64; /** 32-bit generic big endian type. */ typedef uint32_t be32; /** 64-bit generic little endian type. */ typedef uint64_t le64; /** 32-bit generic little endian type. */ typedef uint32_t le32; #endif
// The Mordax Microkernel // (c) Kristian Klomsten Skordal 2013 <kristian.skordal@gmail.com> // Report bugs and issues on <http://github.com/skordal/mordax/issues> #ifndef MORDAX_TYPES_H #define MORDAX_TYPES_H #include <stdbool.h> #include <stdint.h> /** Object size type. */ typedef uint32_t size_t; /** Physical pointer type. */ typedef void * physical_ptr; /** 64-bit generic big endian type. */ typedef uint64_t be64; /** 32-bit generic big endian type. */ typedef uint32_t be32; /** 64-bit generic little endian type. */ typedef uint64_t le64; /** 32-bit generic little endian type. */ typedef uint32_t le32; #endif
Tweak display of BIOS memory map
#include "bmmap.h" #include "vty.h" void bmmap_init() { } void bmmap_print() { vty_puts("BIOS memory map:\n"); vty_printf("%d entries at %p\n", *bios_memmap_entries_ptr, bios_memmap_ptr); vty_printf("ADDR LOW ADDR HI LEN LOW LEN HI TYPE RESERVED\n"); for(int i = 0; i < *bios_memmap_entries_ptr; i++) { BmmapEntry * entry = &(*bios_memmap_ptr)[i]; vty_printf("%08x %08x %08x %08x %08x %08x\n", entry->base_addr_low, entry->base_addr_high, entry->length_low, entry->length_high, entry->type, entry->reserved); } }
#include "bmmap.h" #include "vty.h" void bmmap_init() { } void bmmap_print() { vty_puts("BIOS memory map:\n"); vty_printf("%d entries at %p\n", *bios_memmap_entries_ptr, bios_memmap_ptr); vty_printf(" ADDR LEN TYPE RESERVED\n"); for(int i = 0; i < *bios_memmap_entries_ptr; i++) { BmmapEntry * entry = &(*bios_memmap_ptr)[i]; vty_printf("%08x:%08x %08x:%08x %08x %08x\n", entry->base_addr_high, entry->base_addr_low, entry->length_high, entry->length_low, entry->type, entry->reserved); } }
Revert 80939 - Fix clang error TBR=jam@chromium.org
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_ #define CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_ #pragma once #include "content/browser/renderer_host/render_view_host_observer.h" class GURL; struct DesktopNotificationHostMsg_Show_Params; // Per-tab Desktop notification handler. Handles desktop notification IPCs // coming in from the renderer. class DesktopNotificationHandler : public RenderViewHostObserver { public: explicit DesktopNotificationHandler(RenderViewHost* render_view_host); virtual ~DesktopNotificationHandler(); private: // RenderViewHostObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message); // IPC handlers. void OnShow(const DesktopNotificationHostMsg_Show_Params& params); void OnCancel(int notification_id); void OnRequestPermission(const GURL& origin, int callback_id); private: DISALLOW_COPY_AND_ASSIGN(DesktopNotificationHandler); }; #endif // CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_ #define CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_ #pragma once #include "content/browser/renderer_host/render_view_host_observer.h" class GURL; struct DesktopNotificationHostMsg_Show_Params; // Per-tab Desktop notification handler. Handles desktop notification IPCs // coming in from the renderer. class DesktopNotificationHandler : public RenderViewHostObserver { public: explicit DesktopNotificationHandler(RenderViewHost* render_view_host); virtual ~DesktopNotificationHandler(); private: // RenderViewHostObserver implementation. bool OnMessageReceived(const IPC::Message& message); // IPC handlers. void OnShow(const DesktopNotificationHostMsg_Show_Params& params); void OnCancel(int notification_id); void OnRequestPermission(const GURL& origin, int callback_id); private: DISALLOW_COPY_AND_ASSIGN(DesktopNotificationHandler); }; #endif // CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
Convert postprocessors to pragma once
#ifndef REFLECTIONCOEFFICIENT_H #define REFLECTIONCOEFFICIENT_H #include "SidePostprocessor.h" #include "MooseVariableInterface.h" class ReflectionCoefficient; template <> InputParameters validParams<ReflectionCoefficient>(); class ReflectionCoefficient : public SidePostprocessor, public MooseVariableInterface<Real> { public: ReflectionCoefficient(const InputParameters & parameters); virtual void initialize() override; virtual void execute() override; virtual PostprocessorValue getValue() override; virtual void threadJoin(const UserObject & y) override; protected: virtual Real computeReflection(); const VariableValue & _u; unsigned int _qp; private: const VariableValue & _coupled_imag; Real _theta; Real _length; Real _k; Real _coeff; Real _reflection_coefficient; }; #endif // REFLECTIONCOEFFICIENT_H
#pragma once #include "SidePostprocessor.h" #include "MooseVariableInterface.h" class ReflectionCoefficient; template <> InputParameters validParams<ReflectionCoefficient>(); class ReflectionCoefficient : public SidePostprocessor, public MooseVariableInterface<Real> { public: ReflectionCoefficient(const InputParameters & parameters); virtual void initialize() override; virtual void execute() override; virtual PostprocessorValue getValue() override; virtual void threadJoin(const UserObject & y) override; protected: virtual Real computeReflection(); const VariableValue & _u; unsigned int _qp; private: const VariableValue & _coupled_imag; Real _theta; Real _length; Real _k; Real _coeff; Real _reflection_coefficient; };
Use Python.h, not allobjects.h. Don't call initall() (Experimental incompatible change!!!!!!)
/* Entry point for the Windows NT DLL. About the only reason for having this, is so initall() can automatically be called, removing that burden (and possible source of frustration if forgotten) from the programmer. */ #include "windows.h" /* NT and Python share these */ #undef INCREF #undef DECREF #include "config.h" #include "allobjects.h" HMODULE PyWin_DLLhModule = NULL; BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: PyWin_DLLhModule = hInst; initall(); break; case DLL_PROCESS_DETACH: break; } return TRUE; }
/* Entry point for the Windows NT DLL. About the only reason for having this, is so initall() can automatically be called, removing that burden (and possible source of frustration if forgotten) from the programmer. */ #include "windows.h" /* NT and Python share these */ #include "config.h" #include "Python.h" HMODULE PyWin_DLLhModule = NULL; BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: PyWin_DLLhModule = hInst; //initall(); break; case DLL_PROCESS_DETACH: break; } return TRUE; }
Fix layout (delete empty string)
/* * Copyright (C) 2014-2015 Pavel Dolgov * * See the LICENSE file for terms of use. */ #include <stdio.h> #define TOWER1 1 #define TOWER2 3 void hanoi(int a, int n1, int n2) { if (a == 1) { // end of recursion printf("%d %d %d\n", a, n1, n2); } else { int x, na; for (x = TOWER1; x <= TOWER2; x++) { if ((x != n1) && (x != n2)) { na = x; break; } } hanoi(a - 1, n1, na); // recursion printf("%d %d %d\n", a, n1, n2); hanoi(a - 1, na, n2); // recursion } } int main() { int n; scanf("%d", &n); hanoi(n, TOWER1, TOWER2); }
/* * Copyright (C) 2014-2015 Pavel Dolgov * * See the LICENSE file for terms of use. */ #include <stdio.h> #define TOWER1 1 #define TOWER2 3 void hanoi(int a, int n1, int n2) { if (a == 1) { // end of recursion printf("%d %d %d\n", a, n1, n2); } else { int x, na; for (x = TOWER1; x <= TOWER2; x++) { if ((x != n1) && (x != n2)) { na = x; break; } } hanoi(a - 1, n1, na); // recursion printf("%d %d %d\n", a, n1, n2); hanoi(a - 1, na, n2); // recursion } } int main() { int n; scanf("%d", &n); hanoi(n, TOWER1, TOWER2); }
Change styling convention of the variable names
#pragma once // This guarantees that the code is included only once in the game. #include "SFML/Window.hpp" #include "SFML/Graphics.hpp" class Game { public: // Objects declared static are allocated storage in static storage area, and have scope till the end of the program. static void Start(); private: static bool IsExiting(); static void GameLoop(); enum GameState { Uninitialized, ShowingSplash, Paused, ShowingMenu, Playing, Exiting }; // Represents the various states the game can be in. An enum is a user-defined type consisting of a set of named constants called enumerators. static GameState _gameState; static sf::RenderWindow _mainWindow; };
#ifndef GAME_H // This guarentees that the code is included only once in the game. #define GAME_H #include "SFML/Graphics.hpp" #include "SFML/Window.hpp" class Game { public: // Objects declared static are allocated storage in static storage area, and have scope till the end of the program. static void start(); private: static bool is_exiting(); static void game_loop(); enum game_state { Uninitialized, ShowingSplash, Paused, ShowingMenu, Playing, Exiting }; // Represents the various states the game can be in. An enum is a user-defined type consisting of a set of named constants called enumerators. static game_state s_game_state; static sf::RenderWindow s_main_window; }; #endif
Update new files with SymmTensor changes
#ifndef ELASTIC_H #define ELASTIC_H #include "MaterialModel.h" // Forward declarations class ElasticityTensor; class Elastic; template<> InputParameters validParams<Elastic>(); class Elastic : public MaterialModel { public: Elastic( const std::string & name, InputParameters parameters ); virtual ~Elastic(); protected: /// Compute the stress (sigma += deltaSigma) virtual void computeStress(); }; #endif
#ifndef ELASTIC_H #define ELASTIC_H #include "MaterialModel.h" // Forward declarations class ElasticityTensor; class Elastic; template<> InputParameters validParams<Elastic>(); class Elastic : public MaterialModel { public: Elastic( const std::string & name, InputParameters parameters ); virtual ~Elastic(); protected: /// Compute the stress (sigma += deltaSigma) virtual void computeStress(); }; #endif
Work around known GCC 3.4.x problem and use ANSI prototype for dremf().
/* * dremf() wrapper for remainderf(). * * Written by J.T. Conklin, <jtc@wimsey.com> * Placed into the Public Domain, 1994. */ #include "math.h" #include "math_private.h" float dremf(x, y) float x, y; { return remainderf(x, y); }
/* * dremf() wrapper for remainderf(). * * Written by J.T. Conklin, <jtc@wimsey.com> * Placed into the Public Domain, 1994. */ /* $FreeBSD$ */ #include "math.h" #include "math_private.h" float dremf(float x, float y) { return remainderf(x, y); }
Add solution for exercise 16.
#include <stdio.h> #define MAXLINE 10/*00*/ /* maximum input size */ int _getline(char line[], int maxline); /* getline is a library function in POSIX; unfortunately on OS X the -ansi flag doesn't help */ void copy(char to[], char from[]); main() { int len; int max; char line[MAXLINE]; char longest[MAXLINE]; max = 0; while ((len = _getline(line, MAXLINE)) > 0) if (len > max) { max = len; copy(longest, line); } if (max > 0) { /* there was a line */ printf("%d\n", max); printf("%s", longest); } return 0; } /* _getline: read a line into s, return length */ int _getline(char s[], int lim) { int c, i, length; i = length = 0; while ((c = getchar()) != EOF) { ++length; if (i < lim - 1) { s[i] = c; ++i; } if (c == '\n') { break; } } s[i-1] = '\n'; s[i] = '\0'; return length; } /* copy: copy 'from' into 'to'; assume to is big enough */ void copy(char to[], char from[]) { int i; i = 0; while ((to[i] = from[i]) != '\0') ++i; }
Add limits macros for TUINT and TINT
#include <stddef.h> extern int debug; #ifndef NDEBUG #define DBG(...) dbg(__VA_ARGS__) #define DBGON() (debug = 1) #else #define DBG(...) #define DBGON() #endif #define TINT long long #define TUINT unsigned long long #define TFLOAT double struct items { char **s; unsigned n; }; typedef struct alloc Alloc; extern void die(const char *fmt, ...); extern void dbg(const char *fmt, ...); extern void newitem(struct items *items, char *item); extern void *xmalloc(size_t size); extern void *xcalloc(size_t nmemb, size_t size); extern char *xstrdup(const char *s); extern void *xrealloc(void *buff, register size_t size); extern Alloc *alloc(size_t size, size_t nmemb); extern void dealloc(Alloc *allocp); extern void *new(Alloc *allocp); extern void delete(Alloc *allocp, void *p); extern int casecmp(const char *s1, const char *s2); extern int lpack(unsigned char *dst, char *fmt, ...); extern int lunpack(unsigned char *src, char *fmt, ...);
#include <stddef.h> extern int debug; #ifndef NDEBUG #define DBG(...) dbg(__VA_ARGS__) #define DBGON() (debug = 1) #else #define DBG(...) #define DBGON() #endif #define TINT long long #define TUINT unsigned long long #define TUINT_MAX ULLONG_MAX #define TINT_MAX LLONG_MAX #define TFLOAT double struct items { char **s; unsigned n; }; typedef struct alloc Alloc; extern void die(const char *fmt, ...); extern void dbg(const char *fmt, ...); extern void newitem(struct items *items, char *item); extern void *xmalloc(size_t size); extern void *xcalloc(size_t nmemb, size_t size); extern char *xstrdup(const char *s); extern void *xrealloc(void *buff, register size_t size); extern Alloc *alloc(size_t size, size_t nmemb); extern void dealloc(Alloc *allocp); extern void *new(Alloc *allocp); extern void delete(Alloc *allocp, void *p); extern int casecmp(const char *s1, const char *s2); extern int lpack(unsigned char *dst, char *fmt, ...); extern int lunpack(unsigned char *src, char *fmt, ...);
Add test where octApron derives non-integer bounds
// SKIP PARAM: --sets ana.activated[+] octApron #include <assert.h> void main() { int x; if (x <= 10) { assert((x / 3) <= 3); } }
Fix warning for mixing declarations and code in ISO C90.
#include <stdlib.h> #include <stdio.h> #include <assert.h> #include "greatest.h" TEST standalone_pass(void) { PASS(); } /* Add all the definitions that need to be in the test runner's main file. */ GREATEST_MAIN_DEFS(); int main(int argc, char **argv) { (void)argc; (void)argv; /* Initialize greatest, but don't build the CLI test runner code. */ GREATEST_INIT(); RUN_TEST(standalone_pass); /* Print report, but do not exit. */ printf("\nStandard report, as printed by greatest:\n"); GREATEST_PRINT_REPORT(); struct greatest_report_t report; greatest_get_report(&report); printf("\nCustom report:\n"); printf("pass %u, fail %u, skip %u, assertions %u\n", report.passed, report.failed, report.skipped, report.assertions); if (report.failed > 0) { return 1; } return 0; }
#include <stdlib.h> #include <stdio.h> #include <assert.h> #include "greatest.h" TEST standalone_pass(void) { PASS(); } /* Add all the definitions that need to be in the test runner's main file. */ GREATEST_MAIN_DEFS(); int main(int argc, char **argv) { struct greatest_report_t report; (void)argc; (void)argv; /* Initialize greatest, but don't build the CLI test runner code. */ GREATEST_INIT(); RUN_TEST(standalone_pass); /* Print report, but do not exit. */ printf("\nStandard report, as printed by greatest:\n"); GREATEST_PRINT_REPORT(); greatest_get_report(&report); printf("\nCustom report:\n"); printf("pass %u, fail %u, skip %u, assertions %u\n", report.passed, report.failed, report.skipped, report.assertions); if (report.failed > 0) { return 1; } return 0; }
Use <endian.h> for byte order helpers
#ifndef LIBTRADING_BYTE_ORDER_H #define LIBTRADING_BYTE_ORDER_H #include "libtrading/types.h" #include <arpa/inet.h> static inline be16 cpu_to_be16(u16 value) { return htons(value); } static inline be32 cpu_to_be32(u32 value) { return htonl(value); } static inline u16 be16_to_cpu(be16 value) { return ntohs(value); } static inline u32 be32_to_cpu(be32 value) { return ntohl(value); } #endif
#ifndef LIBTRADING_BYTE_ORDER_H #define LIBTRADING_BYTE_ORDER_H #include <endian.h> /* * Little Endian */ static inline le16 cpu_to_le16(u16 value) { return htole16(value); } static inline le32 cpu_to_le32(u32 value) { return htole32(value); } static inline le64 cpu_to_le64(u64 value) { return htole64(value); } static inline u16 le16_to_cpu(le16 value) { return le16toh(value); } static inline u32 le32_to_cpu(le32 value) { return le32toh(value); } static inline u64 le64_to_cpu(le64 value) { return le64toh(value); } /* * Big Endian */ static inline be16 cpu_to_be16(u16 value) { return htobe16(value); } static inline be32 cpu_to_be32(u32 value) { return htobe32(value); } static inline be64 cpu_to_be64(u64 value) { return htobe64(value); } static inline u16 be16_to_cpu(be16 value) { return be16toh(value); } static inline u32 be32_to_cpu(be32 value) { return be32toh(value); } static inline u64 be64_to_cpu(be64 value) { return be64toh(value); } #endif
Add copyright and license header.
#import <Cocoa/Cocoa.h> @interface WildcardPattern : NSObject { NSString* pattern_; } - (id) initWithString: (NSString*) s; - (BOOL) isMatch: (NSString*) s; @end
/* * Copyright (c) 2006 KATO Kazuyoshi <kzys@8-p.info> * This source code is released under the MIT license. */ #import <Cocoa/Cocoa.h> @interface WildcardPattern : NSObject { NSString* pattern_; } - (id) initWithString: (NSString*) s; - (BOOL) isMatch: (NSString*) s; @end
Change lua_State pointer to LacoState
#ifndef LACO_UTIL_H #define LACO_UTIL_H struct LacoState; struct lua_State; /** * Load a line into the lua stack to be evaluated later * * param pointer to LacoState * * return -1 if there is no line input to load */ int laco_load_line(struct LacoState* laco); /** * Called after laco_load_line, this evaluated the line as a function and * hands of the result for printing * * param pointer to LacoState */ void laco_handle_line(struct LacoState* laco); /** * Kills the loop with exiting message if specified * * param pointer to LacoState * param exit with status * param error message */ void laco_kill(struct LacoState* laco, int status, const char* message); /** * When there is a value on the lua stack, it will print out depending on * the type it is * * param pointer to lua_State * * return LUA_ERRSYNTAX if the value has some error */ int laco_print_type(struct lua_State* L); /** * Prints out and pops off errors pushed into the lua stack * * param pointer to lua_State * param incoming lua stack status */ void laco_report_error(struct lua_State* L, int status); int laco_is_match(const char** matches, const char* test_string); #endif /* LACO_UTIL_H */
#ifndef LACO_UTIL_H #define LACO_UTIL_H struct LacoState; /** * Load a line into the lua stack to be evaluated later * * param pointer to LacoState * * return -1 if there is no line input to load */ int laco_load_line(struct LacoState* laco); /** * Called after laco_load_line, this evaluated the line as a function and * hands of the result for printing * * param pointer to LacoState */ void laco_handle_line(struct LacoState* laco); /** * Kills the loop with exiting message if specified * * param pointer to LacoState * param exit with status * param error message */ void laco_kill(struct LacoState* laco, int status, const char* message); /** * When there is a value on the lua stack, it will print out depending on * the type it is * * param pointer to lua_State * * return LUA_ERRSYNTAX if the value has some error */ int laco_print_type(struct LacoState* laco); /** * Prints out and pops off errors pushed into the lua stack * * param pointer to lua_State * param incoming lua stack status */ void laco_report_error(struct LacoState* laco, int status); int laco_is_match(const char** matches, const char* test_string); #endif /* LACO_UTIL_H */
Return failure if the unexitable loop ever exits ;)
/* Copyright 2019 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 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. */ /*! *\brief Process group placeholder. * * Does nothing except sitting around until killed. Spawned as extra process in * our process groups so that we can control on our own when the process group * ID is reclaimed to the kernel, namely by killing the entire process group. * This prevents a race condition of our process group getting reclaimed before * we try to kill possibly remaining processes in it, after which we would * possibly kill something else. * * Must be a separate executable so F_CLOEXEC applies as intended. */ #include <unistd.h> int main() { for (;;) { pause(); } return 0; }
/* Copyright 2019 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 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. */ /*! *\brief Process group placeholder. * * Does nothing except sitting around until killed. Spawned as extra process in * our process groups so that we can control on our own when the process group * ID is reclaimed to the kernel, namely by killing the entire process group. * This prevents a race condition of our process group getting reclaimed before * we try to kill possibly remaining processes in it, after which we would * possibly kill something else. * * Must be a separate executable so F_CLOEXEC applies as intended. */ #include <stdlib.h> #include <unistd.h> int main() { for (;;) { pause(); } // Cannot get here. abort(); }
Test case for historical reasons
/** * magical invsqrt function from Quake III code * see: http://www.codemaestro.com/reviews/9 */ float InvSqrt(float x) { float xhalf = 0.5f*x; int i = *(int*)&x; i = 0x5f3759df - (i>>1); x = *(float*)&i; x = x*(1.5f-xhalf*x*x); return x; } int main(void) { int result = InvSqrt(0.00056); printf("Result: %d (should be 42)", result); return result != 42; }
Add missing field for breakpoints
#ifndef DEBUGGER_H #define DEBUGGER_H enum DebuggerState { DEBUGGER_PAUSED, DEBUGGER_RUNNING, DEBUGGER_EXITING }; struct ARMDebugger { enum DebuggerState state; struct ARMCore* cpu; char* lastCommand; }; void ARMDebuggerInit(struct ARMDebugger*, struct ARMCore*); void ARMDebuggerRun(struct ARMDebugger*); void ARMDebuggerEnter(struct ARMDebugger*); #endif
#ifndef DEBUGGER_H #define DEBUGGER_H enum DebuggerState { DEBUGGER_PAUSED, DEBUGGER_RUNNING, DEBUGGER_EXITING }; struct ARMDebugger { enum DebuggerState state; struct ARMCore* cpu; char* lastCommand; struct DebugBreakpoint* breakpoints; }; void ARMDebuggerInit(struct ARMDebugger*, struct ARMCore*); void ARMDebuggerRun(struct ARMDebugger*); void ARMDebuggerEnter(struct ARMDebugger*); #endif
Check args count in test i2c terminal command
#include <stdint.h> #include <string.h> #include "obc.h" #include "system.h" #include "terminal.h" void I2CTestCommandHandler(uint16_t argc, char* argv[]) { UNREFERENCED_PARAMETER(argc); I2CBus* bus; if (strcmp(argv[0], "system") == 0) { bus = Main.I2C.System; } else if (strcmp(argv[0], "payload") == 0) { bus = Main.I2C.Payload; } else { TerminalPuts("Unknown bus\n"); } const uint8_t device = (uint8_t)atoi(argv[1]); const uint8_t* data = (uint8_t*)argv[2]; const size_t dataLength = strlen(argv[2]); uint8_t output[20] = {0}; size_t outputLength = dataLength; const I2CResult result = bus->WriteRead(bus, device, data, dataLength, output, outputLength); if (result == I2CResultOK) { TerminalPuts((char*)output); } else { TerminalPrintf("Error %d\n", result); } }
#include <stdint.h> #include <string.h> #include "obc.h" #include "system.h" #include "terminal.h" void I2CTestCommandHandler(uint16_t argc, char* argv[]) { UNREFERENCED_PARAMETER(argc); if (argc != 3) { TerminalPuts("i2c <system|payload> <device> <data>\n"); return; } I2CBus* bus; if (strcmp(argv[0], "system") == 0) { bus = Main.I2C.System; } else if (strcmp(argv[0], "payload") == 0) { bus = Main.I2C.Payload; } else { TerminalPuts("Unknown bus\n"); } const uint8_t device = (uint8_t)atoi(argv[1]); const uint8_t* data = (uint8_t*)argv[2]; const size_t dataLength = strlen(argv[2]); uint8_t output[20] = {0}; size_t outputLength = dataLength; const I2CResult result = bus->WriteRead(bus, device, data, dataLength, output, outputLength); if (result == I2CResultOK) { TerminalPuts((char*)output); } else { TerminalPrintf("Error %d\n", result); } }
Fix HTMLReader include when using dynamic frameworks
/* Copyright (c) 2012 Curtis Hard - GeekyGoodness */ /* Modified by Denis Zamataev. 2014 */ #import <Foundation/Foundation.h> #import <HTMLReader.h> #import "DZReadability_constants.h" typedef void (^GGReadabilityParserCompletionHandler)( NSString * content ); typedef void (^GGReadabilityParserErrorHandler)( NSError * error ); @interface GGReadabilityParser : NSObject { float loadProgress; @private GGReadabilityParserErrorHandler errorHandler; GGReadabilityParserCompletionHandler completionHandler; GGReadabilityParserOptions options; NSURL * URL; NSURL * baseURL; long long dataLength; NSMutableData * responseData; NSURLConnection * URLConnection; NSURLResponse * URLResponse; } @property ( nonatomic, assign ) float loadProgress; - (id)initWithOptions:(GGReadabilityParserOptions)parserOptions; - (id)initWithURL:(NSURL *)aURL options:(GGReadabilityParserOptions)parserOptions completionHandler:(GGReadabilityParserCompletionHandler)cHandler errorHandler:(GGReadabilityParserErrorHandler)eHandler; - (void)cancel; - (void)render; - (void)renderWithString:(NSString *)string; - (HTMLElement *)processXMLDocument:(HTMLDocument *)XML baseURL:(NSURL *)theBaseURL error:(NSError **)error; @end
/* Copyright (c) 2012 Curtis Hard - GeekyGoodness */ /* Modified by Denis Zamataev. 2014 */ #import <Foundation/Foundation.h> #import "HTMLReader.h" #import "DZReadability_constants.h" typedef void (^GGReadabilityParserCompletionHandler)( NSString * content ); typedef void (^GGReadabilityParserErrorHandler)( NSError * error ); @interface GGReadabilityParser : NSObject { float loadProgress; @private GGReadabilityParserErrorHandler errorHandler; GGReadabilityParserCompletionHandler completionHandler; GGReadabilityParserOptions options; NSURL * URL; NSURL * baseURL; long long dataLength; NSMutableData * responseData; NSURLConnection * URLConnection; NSURLResponse * URLResponse; } @property ( nonatomic, assign ) float loadProgress; - (id)initWithOptions:(GGReadabilityParserOptions)parserOptions; - (id)initWithURL:(NSURL *)aURL options:(GGReadabilityParserOptions)parserOptions completionHandler:(GGReadabilityParserCompletionHandler)cHandler errorHandler:(GGReadabilityParserErrorHandler)eHandler; - (void)cancel; - (void)render; - (void)renderWithString:(NSString *)string; - (HTMLElement *)processXMLDocument:(HTMLDocument *)XML baseURL:(NSURL *)theBaseURL error:(NSError **)error; @end
Add virtual destructor to game state
// // Created by Borin Ouch on 2016-03-22. // #ifndef SFML_TEST_GAME_STATE_H #define SFML_TEST_GAME_STATE_H #include "game.h" class GameState { public: Game* game; virtual void draw(const float dt) = 0; virtual void update(const float dt) = 0; virtual void handleInput() = 0; }; #endif //SFML_TEST_GAME_STATE_H
// // Created by Borin Ouch on 2016-03-22. // #ifndef SFML_TEST_GAME_STATE_H #define SFML_TEST_GAME_STATE_H #include "game.h" class GameState { public: Game* game; virtual void draw(const float dt) = 0; virtual void update(const float dt) = 0; virtual void handleInput() = 0; virtual ~GameState() {}; }; #endif //SFML_TEST_GAME_STATE_H
Add ensure for runtime assertion checking
#ifndef __SH_COMMON_H__ #define __SH_COMMON_H__ #include <stdio.h> #include <stdlib.h> // ensure is kinda like assert but it is always executed #define ensure(p, msg) \ do { \ if (!(p)) { \ burst_into_flames(__FILE__, __LINE__, msg); \ } \ } while(0) void burst_into_flames(const char* file, int line, const char* msg) { printf("%s - %s:%d", msg, file, line); abort(); } #endif
Increase the efficiency of multithreading. This should slightly slightly increase frame rate.
// This is a queue that can be accessed from multiple threads safely. // // It's not well optimized, and requires obtaining a lock every time you check for a new value. #pragma once #include <condition_variable> #include <mutex> #include <optional> #include <queue> template <class T> class SynchronizedQueue { std::condition_variable cv_; std::mutex lock_; std::queue<T> q_; public: void push(T && t) { std::unique_lock l(lock_); q_.push(std::move(t)); cv_.notify_one(); } std::optional<T> get() { std::unique_lock l(lock_); if(q_.empty()) { return std::nullopt; } T t = std::move(q_.front()); q_.pop(); return t; } T get_blocking() { std::unique_lock l(lock_); while(q_.empty()) { cv_.wait(l); } T t = std::move(q_.front()); q_.pop(); return std::move(t); } };
// This is a queue that can be accessed from multiple threads safely. // // It's not well optimized, and requires obtaining a lock every time you check for a new value. #pragma once #include <condition_variable> #include <mutex> #include <optional> #include <queue> template <class T> class SynchronizedQueue { std::condition_variable cv_; std::mutex lock_; std::queue<T> q_; std::atomic_uint64_t input_count{0}, output_count{0}; public: void push(T && t) { std::unique_lock l(lock_); q_.push(std::move(t)); input_count++; cv_.notify_one(); } std::optional<T> get() { if(input_count == output_count) { return std::nullopt; } { std::unique_lock l(lock_); if(q_.empty()) { return std::nullopt; } output_count++; T t = std::move(q_.front()); q_.pop(); return t; } } T get_blocking() { std::unique_lock l(lock_); while(q_.empty()) { cv_.wait(l); } output_count++; T t = std::move(q_.front()); q_.pop(); return std::move(t); } };
Work around sudden disappearance of GdkRegion in GTK+ 2.90.5.
#ifndef __GTK_COMPAT_H__ #define __GTK_COMPAT_H__ #include <gtk/gtk.h> /* Provide a compatibility layer for accessor functions introduced * in GTK+ 2.21.1 which we need to build with sealed GDK. * That way it is still possible to build with GTK+ 2.20. */ #if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 21) \ || (GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION < 1) #define gdk_drag_context_get_actions(context) (context)->actions #define gdk_drag_context_get_suggested_action(context) (context)->suggested_action #define gdk_drag_context_get_selected_action(context) (context)->action #endif #if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION == 1 #define gdk_drag_context_get_selected_action(context) gdk_drag_context_get_action(context) #endif #endif /* __GTK_COMPAT_H__ */
#ifndef __GTK_COMPAT_H__ #define __GTK_COMPAT_H__ #include <gtk/gtk.h> /* Provide a compatibility layer for accessor functions introduced * in GTK+ 2.21.1 which we need to build with sealed GDK. * That way it is still possible to build with GTK+ 2.20. */ #if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 21) \ || (GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION < 1) #define gdk_drag_context_get_actions(context) (context)->actions #define gdk_drag_context_get_suggested_action(context) (context)->suggested_action #define gdk_drag_context_get_selected_action(context) (context)->action #endif #if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION == 1 #define gdk_drag_context_get_selected_action(context) gdk_drag_context_get_action(context) #endif #if GTK_CHECK_VERSION (2,90,5) /* Recreate GdkRegion until we drop GTK2 compatibility. */ #define GdkRegion cairo_region_t #define gdk_region_destroy(region) \ (cairo_region_destroy (region)) #define gdk_region_point_in(region, x, y) \ (cairo_region_contains_point ((region), (x), (y))) #define gdk_region_rectangle(rectangle) \ (((rectangle)->width <= 0 || (rectangle->height <= 0)) ? \ cairo_region_create () : cairo_region_create_rectangle (rectangle)) #endif #endif /* __GTK_COMPAT_H__ */
Increase time tolerance to reduce flakiness on slow systems
#include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include "wclock.h" #ifdef _WIN32 # include <windows.h> static unsigned int sleep(unsigned int x) { Sleep(x * 1000); return 0; } #else # include <unistd.h> #endif int main(void) { double res, t1, t2; wclock clock; if (wclock_init(&clock)) { abort(); } res = wclock_get_res(&clock); printf("%.17g\n", res); assert(res > 0); assert(res < 2e-3); /* presumably the clock has at least ms precision! */ t1 = wclock_get(&clock); printf("%.17g\n", t1); sleep(1); t2 = wclock_get(&clock); printf("%.17g\n", t2); printf("%.17g\n", t2 - t1); assert(fabs(t2 - t1 - 1.) < 1e-1); return 0; }
#include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include "wclock.h" #ifdef _WIN32 # include <windows.h> static unsigned int sleep(unsigned int x) { Sleep(x * 1000); return 0; } #else # include <unistd.h> #endif int main(void) { double res, t1, t2; wclock clock; if (wclock_init(&clock)) { abort(); } res = wclock_get_res(&clock); printf("%.17g\n", res); assert(res > 0); assert(res < 2e-3); /* presumably the clock has at least ms precision! */ t1 = wclock_get(&clock); printf("%.17g\n", t1); sleep(1); t2 = wclock_get(&clock); printf("%.17g\n", t2); printf("%.17g\n", t2 - t1); assert(t2 - t1 >= 0.9 && t2 - t1 < 1.4); return 0; }
Add inline docs for asserts
#include <setjmp.h> #include <stdarg.h> #include <stddef.h> #include <cmocka.h> #include "cbor.h" #ifndef ASSERTIONS_H_ #define ASSERTIONS_H_ void assert_uint8(cbor_item_t* item, uint8_t num); void assert_uint16(cbor_item_t* item, uint16_t num); void assert_uint32(cbor_item_t* item, uint32_t num); void assert_uint64(cbor_item_t* item, uint64_t num); void assert_decoder_result(size_t, enum cbor_decoder_status, struct cbor_decoder_result); // TODO: Docs void assert_decoder_result_nedata(size_t, struct cbor_decoder_result); /** * Check that the streaming decoder will returns a correct CBOR_DECODER_NEDATA * result for all inputs from data[0..1] through data[0..(expected-1)]. */ void assert_minimum_input_size(size_t expected, cbor_data data); #endif
#include <setjmp.h> #include <stdarg.h> #include <stddef.h> #include <cmocka.h> #include "cbor.h" #ifndef ASSERTIONS_H_ #define ASSERTIONS_H_ void assert_uint8(cbor_item_t* item, uint8_t num); void assert_uint16(cbor_item_t* item, uint16_t num); void assert_uint32(cbor_item_t* item, uint32_t num); void assert_uint64(cbor_item_t* item, uint64_t num); /** Assert that result `status` and `read` are equal. */ void assert_decoder_result(size_t read, enum cbor_decoder_status status, struct cbor_decoder_result result); /** * Assert that the result is set to CBOR_DECODER_NEDATA with the given * `cbor_decoder_result.required` value. */ void assert_decoder_result_nedata(size_t required, struct cbor_decoder_result result); /** * Check that the streaming decoder returns a correct CBOR_DECODER_NEDATA * result for all inputs from data[0..1] through data[0..(expected-1)]. */ void assert_minimum_input_size(size_t expected, cbor_data data); #endif
Add or replace user extended attributes on a file.
/* setfattr.c - sets user extended attributes for a file. * * This program can be viewed as a much simpler version of setfattr(1) utility, * used to set, remove and list a file's extended attributes. All this program * can do, however, is to set user EAs. * * Usage * * $ ./setfattr <name> <value> <file> * * <name> - the name of the EA to be set. Note that the `user.` namespace * is added automatically. * <value> - the value to be set. * <file> - the file to which the program should add the EA. * * Author: Renato Mascarenhas Costa */ #include <unistd.h> #include <sys/types.h> #include <sys/xattr.h> #include <stdio.h> #include <stdlib.h> #include <string.h> static void helpAndLeave(const char *progname, int status); static void pexit(const char *fCall); int main(int argc, char *argv[]) { if (argc != 4) { helpAndLeave(argv[0], EXIT_FAILURE); } char ea_name[BUFSIZ]; char *name, *value, *file; name = argv[1]; value = argv[2]; file = argv[3]; snprintf(ea_name, BUFSIZ, "user.%s", name); if (setxattr(file, ea_name, value, strlen(ea_name), 0) == -1) { pexit("setxattr"); } exit(EXIT_SUCCESS); } static void helpAndLeave(const char *progname, int status) { FILE *stream = stderr; if (status == EXIT_SUCCESS) { stream = stdout; } fprintf(stream, "Usage: %s <name> <value> <file>\n", progname); exit(status); } static void pexit(const char *fCall) { perror(fCall); exit(EXIT_FAILURE); }
Use typedef of useconds_t in unistd
#include <sys/types.h> #include <pthread.h> #include "vendor/simclist.h" #ifndef BUZZLOCK_H_ #define BUZZLOCK_H_ #define BZZ_BLACK 1 #define BZZ_GOLD 0 typedef int useconds_t; typedef struct { pid_t id; int color; double waiting_since; } bzz_thread_t; typedef struct { pthread_mutex_t mutex; pthread_cond_t cond; int max_active_threads; int active_threads; useconds_t timeout; list_t threads; list_t waiting_gold_threads; list_t waiting_black_threads; } bzz_t; #include "buzz.h" void* get_thread(int, bzz_t); int full_active_threads(bzz_t); int is_black(bzz_thread_t*); int is_gold(bzz_thread_t*); int is_old(bzz_thread_t*, bzz_t); void add_to_waiting_threads(bzz_thread_t*, bzz_t); void wait(bzz_t); double time_with_usec(); unsigned int num_black_waiting(bzz_t); unsigned int num_gold_waiting(bzz_t); unsigned int num_old_gold_waiting(bzz_t); void add_active(bzz_thread_t*, bzz_t); #endif
#include <sys/types.h> #include <unistd.h> #include <pthread.h> #include "vendor/simclist.h" #ifndef BUZZLOCK_H_ #define BUZZLOCK_H_ #define BZZ_BLACK 1 #define BZZ_GOLD 0 typedef struct { pid_t id; int color; double waiting_since; } bzz_thread_t; typedef struct { pthread_mutex_t mutex; pthread_cond_t cond; int max_active_threads; int active_threads; useconds_t timeout; list_t threads; list_t waiting_gold_threads; list_t waiting_black_threads; } bzz_t; #include "buzz.h" void* get_thread(int, bzz_t); int full_active_threads(bzz_t); int is_black(bzz_thread_t*); int is_gold(bzz_thread_t*); int is_old(bzz_thread_t*, bzz_t); void add_to_waiting_threads(bzz_thread_t*, bzz_t); void wait(bzz_t); double time_with_usec(); unsigned int num_black_waiting(bzz_t); unsigned int num_gold_waiting(bzz_t); unsigned int num_old_gold_waiting(bzz_t); void add_active(bzz_thread_t*, bzz_t); #endif
Remove the declaration of DumpBacktrace.
// Copyright 2011 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may 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 NINJA_UTIL_H_ #define NINJA_UTIL_H_ #pragma once #include <string> // Dump a backtrace to stderr. // |skip_frames| is how many frames to skip; // DumpBacktrace implicitly skips itself already. void DumpBacktrace(int skip_frames); // Log a fatal message, dump a backtrace, and exit. void Fatal(const char* msg, ...); // Canonicalize a path like "foo/../bar.h" into just "bar.h". bool CanonicalizePath(std::string* path, std::string* err); #endif // NINJA_UTIL_H_
// Copyright 2011 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may 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 NINJA_UTIL_H_ #define NINJA_UTIL_H_ #pragma once #include <string> // Log a fatal message, dump a backtrace, and exit. void Fatal(const char* msg, ...); // Canonicalize a path like "foo/../bar.h" into just "bar.h". bool CanonicalizePath(std::string* path, std::string* err); #endif // NINJA_UTIL_H_
Add category headers to global header.
// // UIKitCategory.h // WWCategory // // Created by ww on 2016. 1. 10.. // Copyright © 2016년 Won Woo Choi. All rights reserved. // #import "UIApplication+Keyboard.h" #import "UIBezierPath+Drawing.h" #import "UIColor+CreateColor.h" #import "UIImage+CreateImage.h" #import "UIImage+ImageProcessing.h" #import "UIImageView+CreateImageView.h" #import "UIScreen+Size.h" #import "UIStoryboard+GetInstance.h" #import "UITextField+Color.h" #import "UIView+Capture.h" #import "UIView+Rounding.h"
// // UIKitCategory.h // WWCategory // // Created by ww on 2016. 1. 10.. // Copyright © 2016년 Won Woo Choi. All rights reserved. // #import "UIApplication+Keyboard.h" #import "UIApplication+TopmostViewController.h" #import "UIBarButtonItem+Block.h" #import "UIBezierPath+Drawing.h" #import "UIButton+Align.h" #import "UICollectionView+Register.h" #import "UIColor+CreateColor.h" #import "UIImage+CreateImage.h" #import "UIImage+ImageProcessing.h" #import "UIImageView+CreateImageView.h" #import "UIScreen+Size.h" #import "UIStoryboard+GetInstance.h" #import "UITableView+Register.h" #import "UITextField+Color.h" #import "UIView+Capture.h" #import "UIView+Rounding.h" #import "UIViewController+Present.h"
Add unified state of the game
/* * Copyright (C) 2015 Luke San Antonio * All rights reserved. */ #pragma once #include "../common/id_map.hpp" #include "boat.h" #include "../collisionlib/motion.h" namespace redc { namespace sail { struct Player { std::string name; bool spawned; Hull_Desc boat_config; collis::Motion boat_motion; }; struct Game { ID_Map<Player> players; }; } }
Drop dmalloc.h, not needed. Drop dmalloc.h, not needed. Use strncpy for portability, we do not want this function to rely on mastring.
/** * \file inet_ntop * inet_ntop emulation based on inet_ntoa. * \author Matthias Andree * */ #include "config.h" #ifndef HAVE_INET_NTOP #include "leafnode.h" #include "mastring.h" #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #ifdef WITH_DMALLOC #include <dmalloc.h> #endif #include <string.h> const char * inet_ntop(int af, const void *s, char *dst, int x) { switch (af) { case AF_INET: mastrncpy(dst, inet_ntoa(*(const struct in_addr *)s), x); return dst; break; default: errno = EINVAL; return 0; break; } } #endif
/** * \file inet_ntop * inet_ntop emulation based on inet_ntoa. * \author Matthias Andree * */ #include "config.h" #if !HAVE_INET_NTOP #include "leafnode.h" #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #include <string.h> const char * inet_ntop(int af, const void *s, char *dst, int x) { switch (af) { case AF_INET: strncpy(dst, inet_ntoa(*(const struct in_addr *)s), x); if (x) dst[x-1] = '\0'; return dst; break; default: errno = EINVAL; return 0; break; } } #endif
Add program for testing large openslide_read_region() calls
/* Test program to make a single openslide_read_region() call and write the result as a PPM. */ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <inttypes.h> #include <assert.h> #include <openslide.h> int main(int argc, char **argv) { if (argc != 7) { printf("Arguments: slide out.ppm x y w h\n"); return 1; } char *slide = argv[1]; char *out = argv[2]; int64_t x = atoi(argv[3]); int64_t y = atoi(argv[4]); int64_t w = atoi(argv[5]); int64_t h = atoi(argv[6]); uint32_t *buf = malloc(w * h * 4); openslide_t *osr = openslide_open(slide); assert(osr != NULL); openslide_read_region(osr, buf, x, y, 0, w, h); assert(openslide_get_error(osr) == NULL); openslide_close(osr); FILE *fp; fp = fopen(out, "w"); assert(fp != NULL); fprintf(fp, "P6\n# Extraneous comment\n%"PRIu64" %"PRIu64" 255\n", w, h); for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { uint32_t sample = buf[y * h + x]; // undo premultiplication, more or less double alpha = ((sample >> 24) ?: 1) / 255.0; uint8_t pixel[3] = { ((sample >> 16) & 0xff) / alpha, ((sample >> 8) & 0xff) / alpha, (sample & 0xff) / alpha, }; fwrite(pixel, 1, sizeof(pixel), fp); } } fclose(fp); free(buf); }
Test case for B0 -> mu
#ifndef ALI_DECAYER__H #define ALI_DECAYER__H /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ /* $Id$ */ #include "RVersion.h" #include "TVirtualMCDecayer.h" typedef TVirtualMCDecayer AliDecayer; #if ROOT_VERSION_CODE >= 197633 //Corresponds to Root v3-04-01 typedef enum { kSemiElectronic, kDiElectron, kSemiMuonic, kDiMuon, kBJpsiDiMuon, kBJpsiDiElectron, kBPsiPrimeDiMuon, kBPsiPrimeDiElectron, kPiToMu, kKaToMu, kNoDecay, kHadronicD, kOmega, kPhiKK, kAll, kNoDecayHeavy, kHardMuons, kBJpsi, kWToMuon,kWToCharm, kWToCharmToMuon } Decay_t; #endif #endif //ALI_DECAYER__H
#ifndef ALI_DECAYER__H #define ALI_DECAYER__H /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ /* $Id$ */ #include "RVersion.h" #include "TVirtualMCDecayer.h" typedef TVirtualMCDecayer AliDecayer; #if ROOT_VERSION_CODE >= 197633 //Corresponds to Root v3-04-01 typedef enum { kSemiElectronic, kDiElectron, kSemiMuonic, kDiMuon, kBJpsiDiMuon, kBJpsiDiElectron, kBPsiPrimeDiMuon, kBPsiPrimeDiElectron, kPiToMu, kKaToMu, kNoDecay, kHadronicD, kOmega, kPhiKK, kAll, kNoDecayHeavy, kHardMuons, kBJpsi, kWToMuon,kWToCharm, kWToCharmToMuon, kNewTest } Decay_t; #endif #endif //ALI_DECAYER__H
Delete unneeded pt_regs forward declaration.
/** * @file arch/alpha/oprofile/op_impl.h * * @remark Copyright 2002 OProfile authors * @remark Read the file COPYING * * @author Richard Henderson <rth@twiddle.net> */ #ifndef OP_IMPL_H #define OP_IMPL_H 1 struct pt_regs; extern int null_perf_irq(void); extern int (*perf_irq)(void); /* Per-counter configuration as set via oprofilefs. */ struct op_counter_config { unsigned long enabled; unsigned long event; unsigned long count; /* Dummies because I am too lazy to hack the userspace tools. */ unsigned long kernel; unsigned long user; unsigned long exl; unsigned long unit_mask; }; /* Per-architecture configury and hooks. */ struct op_mips_model { void (*reg_setup) (struct op_counter_config *); void (*cpu_setup) (void * dummy); int (*init)(void); void (*exit)(void); void (*cpu_start)(void *args); void (*cpu_stop)(void *args); char *cpu_type; unsigned char num_counters; }; #endif
/** * @file arch/alpha/oprofile/op_impl.h * * @remark Copyright 2002 OProfile authors * @remark Read the file COPYING * * @author Richard Henderson <rth@twiddle.net> */ #ifndef OP_IMPL_H #define OP_IMPL_H 1 extern int null_perf_irq(void); extern int (*perf_irq)(void); /* Per-counter configuration as set via oprofilefs. */ struct op_counter_config { unsigned long enabled; unsigned long event; unsigned long count; /* Dummies because I am too lazy to hack the userspace tools. */ unsigned long kernel; unsigned long user; unsigned long exl; unsigned long unit_mask; }; /* Per-architecture configury and hooks. */ struct op_mips_model { void (*reg_setup) (struct op_counter_config *); void (*cpu_setup) (void * dummy); int (*init)(void); void (*exit)(void); void (*cpu_start)(void *args); void (*cpu_stop)(void *args); char *cpu_type; unsigned char num_counters; }; #endif
Add a missing "REQUIRES: system-windows" to a Windows-only test.
// Test coverage flag. // // RUN: %clang_cl -### -coverage %s -o foo/bar.o 2>&1 | FileCheck -check-prefix=CLANG-CL-COVERAGE %s // CLANG-CL-COVERAGE-NOT: error: // CLANG-CL-COVERAGE-NOT: warning: // CLANG-CL-COVERAGE-NOT: argument unused // CLANG-CL-COVERAGE-NOT: unknown argument
// Test coverage flag. // REQUIRES: system-windows // // RUN: %clang_cl -### -coverage %s -o foo/bar.o 2>&1 | FileCheck -check-prefix=CLANG-CL-COVERAGE %s // CLANG-CL-COVERAGE-NOT: error: // CLANG-CL-COVERAGE-NOT: warning: // CLANG-CL-COVERAGE-NOT: argument unused // CLANG-CL-COVERAGE-NOT: unknown argument
Add passing of request frame to parsing functions
//Basic master parser extern uint8_t MODBUSParseResponseBasic( union MODBUSParser * );
//Basic master parser extern uint8_t MODBUSParseResponseBasic( union MODBUSParser *, union MODBUSParser * );
Change the solver handling of arrays. Previously we were calling compat on the pointers underneath matching arrays. However, this led to problems: union { char a[8]; int b[2]; } This is in fact fine, but we'd end up with compat edges between a node pointing to char and a node pointing to int and they wouldn't be congruent so they would end up being WILD. However, if one of them is INDEX, the other should be as well. So we remember whenever an array is compared against another array and we make sure that they have the same flags. However: union { char a[4] __INDEX; int b; } Should fail. So we remember whenever an array is compared with a non-array. Later, if any such array ends up being INDEX we die with an error in the solver.
#include "../small1/testharness.h" // NUMERRORS 1 struct foo { int a[8]; int *b; } gfoo; struct bar { int a[8]; int *b; }; int main() { int * __INDEX p = & gfoo.a[2]; // Force gfoo.a to have a length // This should be Ok, but pbar->b is gfoo.a[7] struct bar *pbar = (struct bar*)&gfoo; gfoo.a[7] = 5; pbar->b = 0; printf("Pointer is %lx\n", (unsigned long)pbar->b); *(pbar->b) = 0; //ERROR(1): Null SUCCESS; }
#include "../small1/testharness.h" #include "../small1/testkinds.h" // NUMERRORS 3 struct foo { int a[8]; int *b; } gfoo; struct bar { int a[8]; int *b; }; #if ERROR == 2 struct s1 { int a[8]; int *b; } * s1; struct s2 { int *c; int d[8]; } * s2; #endif #if ERROR == 3 struct s_with_index { int __INDEX arr[8] __INDEX; } * s1; struct s_with_non_array { int a,b,c,d,e,f,g,h; } * s2; #endif int main() { int * __INDEX p = & gfoo.a[2]; // Force gfoo.a to have a length // This should be Ok, but pbar->b is gfoo.a[7] struct bar *pbar = (struct bar*)&gfoo; pbar->b = 0; gfoo.a[7] = 5; printf("Pointer is %lx\n", (unsigned long)pbar->b); *(pbar->b) = 0; //ERROR(1): Null s1 = s2; if (HAS_KIND(s1, WILD_KIND)) E(2); // ERROR(2):Error #if ERROR == 3 s1 = s2; // ERROR(3): compared with a non-array #endif SUCCESS; }
Update files, Alura, Introdução a C - Parte 2, Aula 4.3
#include <stdio.h> void abertura(int m) { printf("Tabuada do %d\n", m); } int main() { int multiplicador = 2; abertura(multiplicador); for(int i = 1; i <= 10; i++) { printf("%d x %d = %d\n", multiplicador, i, multiplicador * i); } }
Test for parsing assignment in a ?:'s rhs
// RUN: %check -e %s f(int a, int b, int dir) { struct { int x, y; } c = { }; a & b ? c.x += dir : c.y += dir; // CHECK: error: assignment to int/if - not an lvalue }
Add an empty header that will contain defines concerning the document structure
/* libvisio * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111-1301 USA */ #ifndef VSDXDOCUMENTSTRUCTURE_H #define VSDXDOCUMENTSTRUCTURE_H #endif /* VSDXDOCUMENTSTRUCTURE_H */
Add getters for width/height of renderer
#pragma once #include <boost/container/vector.hpp> #include "System.h" class Renderer : public System { protected: uint16_t width = 1280; uint16_t height = 720; Decimal fovPlus = glm::radians(10.0f); Decimal zNear = 0.05f; Decimal zFar = 48.0f; Decimal pixelDistanceFromScreen = 1000.0f; public: bool showFPS = false; uint32_t time = 0; static bool IsSupported() { return false; } Renderer(Polar *engine) : System(engine) {} virtual void MakePipeline(const boost::container::vector<std::string> &) = 0; virtual void SetClearColor(const Point4 &) = 0; virtual Decimal GetUniformDecimal(const std::string &, const Decimal = 0) = 0; virtual Point3 GetUniformPoint3(const std::string &, const Point3 = Point3(0)) = 0; virtual void SetUniform(const std::string &, glm::uint32) = 0; virtual void SetUniform(const std::string &, Decimal) = 0; virtual void SetUniform(const std::string &, Point3) = 0; };
#pragma once #include <boost/container/vector.hpp> #include "System.h" class Renderer : public System { protected: uint16_t width = 1280; uint16_t height = 720; Decimal fovPlus = glm::radians(10.0f); Decimal zNear = 0.05f; Decimal zFar = 48.0f; Decimal pixelDistanceFromScreen = 1000.0f; public: bool showFPS = false; uint32_t time = 0; static bool IsSupported() { return false; } Renderer(Polar *engine) : System(engine) {} inline uint16_t GetWidth() { return width; } inline uint16_t GetHeight() { return height; } virtual void MakePipeline(const boost::container::vector<std::string> &) = 0; virtual void SetClearColor(const Point4 &) = 0; virtual Decimal GetUniformDecimal(const std::string &, const Decimal = 0) = 0; virtual Point3 GetUniformPoint3(const std::string &, const Point3 = Point3(0)) = 0; virtual void SetUniform(const std::string &, glm::uint32) = 0; virtual void SetUniform(const std::string &, Decimal) = 0; virtual void SetUniform(const std::string &, Point3) = 0; };
Add test case for casting addresses to function pointers
void abort(); int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int mul(int a, int b) { return a * b; } int div(int a, int b) { return a / b; } int rem(int a, int b) { return a % b; } long *arr[5] = {(long *)&add, (long *)&sub, (long *)&mul, (long *)&div, (long *)&rem }; int main() { int i; int sum = 0; for (i = 0; i < 10000; i++) { int (*p)(int x, int y) = (int (*)(int x, int y))arr[i % 5]; sum += p(i, 2); } if (sum != 44991000) { abort(); } }
Add a note about FrameAccessor
// // UIView+Sizing.h // aaah // // Created by Stanislaw Pankevich on 5/10/13. // Copyright (c) 2013 IProjecting. All rights reserved. // #import <UIKit/UIKit.h> @interface UIView (Sizing) @property CGPoint origin; @property CGSize size; @property CGFloat x; @property CGFloat y; @property CGFloat height; @property CGFloat width; @property CGFloat centerX; @property CGFloat centerY; @end
// Inspired by FrameAccessor // https://github.com/AlexDenisov/FrameAccessor/ #import <UIKit/UIKit.h> @interface UIView (Sizing) @property CGPoint origin; @property CGSize size; @property CGFloat x; @property CGFloat y; @property CGFloat height; @property CGFloat width; @property CGFloat centerX; @property CGFloat centerY; @end
Fix a WinAPI VirtualFree bug.
// // os/winapi/alloc.h: Low-level WinAPI-based allocators. // // CEN64: Cycle-Accurate Nintendo 64 Simulator. // Copyright (C) 2014, Tyler J. Stachecki. // // This file is subject to the terms and conditions defined in // 'LICENSE', which is part of this source code package. // #include "common.h" #include "os/common/alloc.h" #include <stddef.h> #include <windows.h> // Allocates a block of (R/W/X) memory. void *cen64_alloc(struct cen64_mem *m, size_t size, bool exec) { int access = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; if ((m->ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, access)) == NULL) return NULL; m->size = size; return m->ptr; } // Releases resources acquired by cen64_alloc_init. void cen64_alloc_cleanup(void) { } // Initializes CEN64's low-level allocator. int cen64_alloc_init(void) { return 0; } // Releases resources acquired by cen64_alloc. void cen64_free(struct cen64_mem *m) { VirtualFree(m->ptr, m->size, MEM_RELEASE); }
// // os/winapi/alloc.h: Low-level WinAPI-based allocators. // // CEN64: Cycle-Accurate Nintendo 64 Simulator. // Copyright (C) 2014, Tyler J. Stachecki. // // This file is subject to the terms and conditions defined in // 'LICENSE', which is part of this source code package. // #include "common.h" #include "os/common/alloc.h" #include <stddef.h> #include <windows.h> // Allocates a block of (R/W/X) memory. void *cen64_alloc(struct cen64_mem *m, size_t size, bool exec) { int access = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; if ((m->ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, access)) == NULL) return NULL; m->size = size; return m->ptr; } // Releases resources acquired by cen64_alloc_init. void cen64_alloc_cleanup(void) { } // Initializes CEN64's low-level allocator. int cen64_alloc_init(void) { return 0; } // Releases resources acquired by cen64_alloc. void cen64_free(struct cen64_mem *m) { VirtualFree(m->ptr, 0, MEM_RELEASE); }
Add header to extend server for arduinojson
// ESPasyncJson.h /* Async Response to use with arduinoJson and asyncwebserver Written by Andrew Melvin (SticilFace) with help from me-no-dev and BBlanchon. example of callback in use server.on("/json", HTTP_ANY, [](AsyncWebServerRequest * request) { AsyncJsonResponse * response = new AsyncJsonResponse(); JsonObject& root = response->getRoot(); root["key1"] = "key number one"; JsonObject& nested = root.createNestedObject("nested"); nested["key1"] = "key number one"; response->setLength(); request->send(response); }); */ #pragma once #include <ArduinoJson.h> /* * Json Response * */ class ChunkPrint : public Print{ private: uint8_t* _destination; size_t _to_skip; size_t _to_write; size_t _pos; public: ChunkPrint(uint8_t* destination, size_t from, size_t len) : _destination(destination), _to_skip(from), _to_write(len), _pos{0} {} size_t write(uint8_t c){ if (_to_skip > 0) { _to_skip--; return 0; } else if (_to_write > 0) { _to_write--; _destination[_pos++] = c; return 1; } return 0; } }; class AsyncJsonResponse: public AsyncAbstractResponse { private: DynamicJsonBuffer _jsonBuffer; JsonVariant _root; bool _isValid; public: AsyncJsonResponse(): _isValid{false} { _code = 200; _contentType = "text/json"; _root = _jsonBuffer.createObject(); } ~AsyncJsonResponse() {} JsonVariant & getRoot() { return _root; } bool _sourceValid() { return _isValid; } bool setLength() { _contentLength = _root.measureLength(); if (_contentLength) { _isValid = true; } } size_t _fillBuffer(uint8_t *data, size_t len){ ChunkPrint dest(data, _sentLength, len); _root.printTo( dest ) ; return len; } };
Update includes with stuff I'll need
#pragma once #include <unistd.h> #include <algorithm> #include <exception> #include <iostream> #include <list> #include <map> #include <memory> #include <set> #include <sstream> #include <string> #include <tuple> #include <unordered_map> #include <utility> #include <vector> const std::string BotVersion ("3.0.0-devel"); const unsigned int BotVersionNum = 2800;
#pragma once #include <unistd.h> #include <algorithm> #include <cstdarg> #include <exception> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <string> #include <thread> #include <tuple> #include <unordered_map> #include <utility> #include <vector> const std::string BotVersion ("3.0.0-devel"); const unsigned int BotVersionNum = 2800;
Move functions in correct sectors in game class.
/* * Game.h * * Created on: 30.12.2016 * Author: Stefan */ #include "Deck.h" #include "Dealer.h" #include <memory> #include "GlobalDeclarations.h" #include "PlayerStrategy.h" #ifndef GAME_H_ #define GAME_H_ // Class game is the glue code which binds all other classes together. // It guides the game. class Game { using pPlayer = std::unique_ptr<Player>; public: Game () : _deck(), _dealer(_deck), _players() {} // Not allowed to copy or assign game Game(Game const &) = delete ; void operator=(Game const&) = delete; void AddDecks(); void PlayRound(); void GetStartCards(); void PlayCards(); void Evaluate(); void PutCardsBack(); void RemoveBrokePlayers(); void PrintNumPlayers () const; virtual void SetWagers() = 0; virtual bool PlayAnotherRound () const = 0; protected: virtual ~Game(){}; // Not allowed to polymorphic delete derivatives Deck _deck; Dealer _dealer; // Players are pointers to avoid issues with card pointers std::vector<pPlayer> _players; }; #endif /* GAME_H_ */
/* * Game.h * * Created on: 30.12.2016 * Author: Stefan */ #include "Deck.h" #include "Dealer.h" #include <memory> #include "GlobalDeclarations.h" #include "PlayerStrategy.h" #ifndef GAME_H_ #define GAME_H_ // Class game is the glue code which binds all other classes together. // It guides the game. class Game { using pPlayer = std::unique_ptr<Player>; public: Game () : _deck(), _dealer(_deck), _players() {} // Not allowed to copy or assign game Game(Game const &) = delete ; void operator=(Game const&) = delete; void AddDecks(); void PlayRound(); virtual bool PlayAnotherRound () const = 0; void PrintNumPlayers () const; protected: virtual ~Game(){}; // Not allowed to polymorphic delete derivatives virtual void SetWagers() = 0; Deck _deck; Dealer _dealer; // Players are pointers to avoid issues with card pointers std::vector<pPlayer> _players; private: void GetStartCards(); void PlayCards(); void Evaluate(); void PutCardsBack(); void RemoveBrokePlayers(); }; #endif /* GAME_H_ */
Add StreamRedirector class to handle stream resetting with RAII.
#include <libmesh/libmesh.h> /** * This class uses RAII to control redirecting the libMesh::err stream * to NULL and restoring it around some operation where we do not want * to see output to the screen. */ class StreamRedirector { public: /** * Constructor; saves the original libMesh::err streambuf. */ StreamRedirector() : _errbuf(libMesh::err.rdbuf()) { libMesh::err.rdbuf(libmesh_nullptr); } /** * Destructor: restores the stream. */ ~StreamRedirector() { libMesh::err.rdbuf(_errbuf); } private: std::streambuf * _errbuf; };
Allow specifying number of blocks to test
#include <stdio.h> #include "aes.h" int main(int argc, char **argv) { aes_init(); return 0; }
#include <stdio.h> #include <stdlib.h> #include "aes.h" int main(int argc, char **argv) { long blocks; char *nptr; aes_init(); blocks = 10; if (argc > 1) { long b = strtol(argv[1], &nptr, 10); if (argv[1] != nptr) { blocks = b; } } return 0; }
Remove unused text format constants.
/* * Copyright 2010 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkTextFormatParams_DEFINES #define SkTextFormatParams_DEFINES #include "include/core/SkScalar.h" #include "include/core/SkTypes.h" // Fraction of the text size to lower a strike through line below the baseline. #define kStdStrikeThru_Offset (-SK_Scalar1 * 6 / 21) // Fraction of the text size to lower a underline below the baseline. #define kStdUnderline_Offset (SK_Scalar1 / 9) // Fraction of the text size to use for a strike through or under-line. #define kStdUnderline_Thickness (SK_Scalar1 / 18) // The fraction of text size to embolden fake bold text scales with text size. // At 9 points or below, the stroke width is increased by text size / 24. // At 36 points and above, it is increased by text size / 32. In between, // it is interpolated between those values. static const SkScalar kStdFakeBoldInterpKeys[] = { SK_Scalar1*9, SK_Scalar1*36, }; static const SkScalar kStdFakeBoldInterpValues[] = { SK_Scalar1/24, SK_Scalar1/32, }; static_assert(SK_ARRAY_COUNT(kStdFakeBoldInterpKeys) == SK_ARRAY_COUNT(kStdFakeBoldInterpValues), "mismatched_array_size"); static const int kStdFakeBoldInterpLength = SK_ARRAY_COUNT(kStdFakeBoldInterpKeys); #endif //SkTextFormatParams_DEFINES
/* * Copyright 2010 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkTextFormatParams_DEFINES #define SkTextFormatParams_DEFINES #include "include/core/SkScalar.h" #include "include/core/SkTypes.h" // The fraction of text size to embolden fake bold text scales with text size. // At 9 points or below, the stroke width is increased by text size / 24. // At 36 points and above, it is increased by text size / 32. In between, // it is interpolated between those values. static const SkScalar kStdFakeBoldInterpKeys[] = { SK_Scalar1*9, SK_Scalar1*36, }; static const SkScalar kStdFakeBoldInterpValues[] = { SK_Scalar1/24, SK_Scalar1/32, }; static_assert(SK_ARRAY_COUNT(kStdFakeBoldInterpKeys) == SK_ARRAY_COUNT(kStdFakeBoldInterpValues), "mismatched_array_size"); static const int kStdFakeBoldInterpLength = SK_ARRAY_COUNT(kStdFakeBoldInterpKeys); #endif //SkTextFormatParams_DEFINES
Fix fatal typo in code guard
// @(#)root/sqlite:$Id$ // Author: o.freyermuth <o.f@cern.ch>, 01/06/2013 /************************************************************************* * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_TPgSQLRow #define ROOT_TPgSQLRow #ifndef ROOT_TSQLRow #include "TSQLRow.h" #endif #if !defined(__CINT__) #include <sqlite3.h> #else struct sqlite3_stmt; #endif class TSQLiteRow : public TSQLRow { private: sqlite3_stmt *fResult; // current result set Bool_t IsValid(Int_t field); public: TSQLiteRow(void *result, ULong_t rowHandle); ~TSQLiteRow(); void Close(Option_t *opt=""); ULong_t GetFieldLength(Int_t field); const char *GetField(Int_t field); ClassDef(TSQLiteRow,0) // One row of SQLite query result }; #endif
// @(#)root/sqlite: // Author: o.freyermuth <o.f@cern.ch>, 01/06/2013 /************************************************************************* * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_TSQLiteRow #define ROOT_TSQLiteRow #ifndef ROOT_TSQLRow #include "TSQLRow.h" #endif #if !defined(__CINT__) #include <sqlite3.h> #else struct sqlite3_stmt; #endif class TSQLiteRow : public TSQLRow { private: sqlite3_stmt *fResult; // current result set Bool_t IsValid(Int_t field); public: TSQLiteRow(void *result, ULong_t rowHandle); ~TSQLiteRow(); void Close(Option_t *opt=""); ULong_t GetFieldLength(Int_t field); const char *GetField(Int_t field); ClassDef(TSQLiteRow,0) // One row of SQLite query result }; #endif
Replace 'REQUIRES: nozlib' with '!zlib' because we don't need two ways to say the same thing.
// REQUIRES: nozlib // RUN: %clang -### -fintegrated-as -gz -c %s 2>&1 | FileCheck %s -check-prefix CHECK-WARN // RUN: %clang -### -fintegrated-as -gz=none -c %s 2>&1 | FileCheck -allow-empty -check-prefix CHECK-NOWARN %s // CHECK-WARN: warning: cannot compress debug sections (zlib not installed) // CHECK-NOWARN-NOT: warning: cannot compress debug sections (zlib not installed)
// REQUIRES: !zlib // RUN: %clang -### -fintegrated-as -gz -c %s 2>&1 | FileCheck %s -check-prefix CHECK-WARN // RUN: %clang -### -fintegrated-as -gz=none -c %s 2>&1 | FileCheck -allow-empty -check-prefix CHECK-NOWARN %s // CHECK-WARN: warning: cannot compress debug sections (zlib not installed) // CHECK-NOWARN-NOT: warning: cannot compress debug sections (zlib not installed)
Use macro in example code
#include <stdio.h> #include "bincookie.h" int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: %s [Full path to Cookies.binarycookies file]\n", argv[0]); printf("Example: %s Cookies.binarycookies\n", argv[0]); return 1; } binarycookies_t *bc = binarycookies_init(argv[1]); unsigned int i, j; // Output in Netscape cookies.txt format for (i = 0; i < bc->num_pages; i++) { for (j = 0; j < bc->pages[i]->number_of_cookies; j++) { // domain, flag, path, secure, expiration, name, value printf("%s\t%s\t%s\t%s\t%.f\t%s\t%s\n", bc->pages[i]->cookies[j]->domain, bc->pages[i]->cookies[j]->domain[0] == '.' ? "TRUE" : "FALSE", bc->pages[i]->cookies[j]->path, binarycookies_is_secure(bc->pages[i]->cookies[j]) ? "TRUE" : "FALSE", bc->pages[i]->cookies[j]->expiration_date, bc->pages[i]->cookies[j]->name, bc->pages[i]->cookies[j]->value); } } binarycookies_free(bc); return 0; }
#include <stdio.h> #include "bincookie.h" int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: %s [Full path to Cookies.binarycookies file]\n", argv[0]); printf("Example: %s Cookies.binarycookies\n", argv[0]); return 1; } binarycookies_t *bc = binarycookies_init(argv[1]); unsigned int i, j; // Output in Netscape cookies.txt format for (i = 0; i < bc->num_pages; i++) { for (j = 0; j < bc->pages[i]->number_of_cookies; j++) { // domain, flag, path, secure, expiration, name, value printf("%s\t%s\t%s\t%s\t%.f\t%s\t%s\n", bc->pages[i]->cookies[j]->domain, binarycookies_domain_access_full(bc->pages[i]->cookies[j]) ? "TRUE" : "FALSE", bc->pages[i]->cookies[j]->path, binarycookies_is_secure(bc->pages[i]->cookies[j]) ? "TRUE" : "FALSE", bc->pages[i]->cookies[j]->expiration_date, bc->pages[i]->cookies[j]->name, bc->pages[i]->cookies[j]->value); } } binarycookies_free(bc); return 0; }
Fix C issue in NativeCall tests.
#include <stdio.h> #include <string.h> #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT extern #endif DLLEXPORT void * ReturnSomePointer() { char *x = "Got passed back the pointer I returned"; return x; } DLLEXPORT int CompareSomePointer(void *ptr) { int x = strcmp("Got passed back the pointer I returned", ptr) == 0; return x; } DLLEXPORT void * ReturnNullPointer() { return NULL; } DLLEXPORT void * TakeTwoPointersToInt(int *ptr1, int *ptr2) { return NULL; } DLLEXPORT void * TakeCArrayToInt8(int array[]) { return NULL; }
#include <stdio.h> #include <string.h> #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT extern #endif DLLEXPORT void * ReturnSomePointer() { return strdup("Got passed back the pointer I returned"); } DLLEXPORT int CompareSomePointer(void *ptr) { int x = strcmp("Got passed back the pointer I returned", ptr) == 0; free(ptr); return x; } DLLEXPORT void * ReturnNullPointer() { return NULL; } DLLEXPORT void * TakeTwoPointersToInt(int *ptr1, int *ptr2) { return NULL; } DLLEXPORT void * TakeCArrayToInt8(int array[]) { return NULL; }