Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add struct to keep datastore things
#ifndef GWKV_HT_WRAPPER #define GWKV_HT_WRAPPER #include <stdlib.h> #include "../hashtable/hashtable.h" /* Operations the table supports */ typedef enum { GET, SET } method; /* Defines for result codes */ #define STORED 0 #define NOT_STORED 1 #define EXISTS 2 #define NOT_FOUND 3 /* Datatype for wrapping datastore values */ struct { method method_type, const char* key, size_t key_length, const char* value, size_t value_length } operation; /** * Wrapper function to set a value in the hashtable * Returns either STORED or NOT_STORED (defined above) */ int gwkv_server_set (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length); /** * Wrapper function to read a value from the hashtable * Returns the data if sucessful, or NULL on error * These correspond to the EXISTS and NOT_FOUND codes above */ char* gwkv_server_get (memcached_st *ptr, const char *key, size_t key_length, size_t *value_length); #endif
#ifndef GWKV_HT_WRAPPER #define GWKV_HT_WRAPPER #include <stdlib.h> #include "../hashtable/hashtable.h" /* Types of hashing algorithms we support */ typedef enum { MD5 } hash_type; /* All encompassing datatype for server datastore */ struct { ht* hashtable, hash_type hash } gwkv_server; /* Operations the table supports */ typedef enum { GET, SET } method; /* Defines for result codes */ #define STORED 0 #define NOT_STORED 1 #define EXISTS 2 #define NOT_FOUND 3 /* Datatype for wrapping datastore values */ struct { method method_type, const char* key, size_t key_length, const char* value, size_t value_length } operation; /* Initialize a new key/value datastore */ gwkv_server* gwkv_server_init(hash_type hash_algorithm); /** * Wrapper function to set a value in the hashtable * Returns either STORED or NOT_STORED (defined above) */ int gwkv_server_set (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length); /** * Wrapper function to read a value from the hashtable * Returns the data if sucessful, or NULL on error * These correspond to the EXISTS and NOT_FOUND codes above */ char* gwkv_server_get (memcached_st *ptr, const char *key, size_t key_length, size_t *value_length); /* Frees all memory associated with the datastore */ void gwkv_server_free(gwkv_server* server); #endif
Use a static variable to track whether to use AES-NI
#include <stdio.h> #include "aes.h" static void aes_encrypt_block_openssl(const unsigned char *, unsigned char *, const AES_KEY *); static void aes_encrypt_block_aesni(const unsigned char *, unsigned char *, const AES_KEY *); int use_aesni() { return 0; } void aes_encrypt_block(const unsigned char *in, unsigned char *out, const AES_KEY *key) { if (use_aesni()) { aes_encrypt_block_aesni(in, out, key); } else { aes_encrypt_block_openssl(in, out, key); } } static void aes_encrypt_block_openssl(const unsigned char *in, unsigned char *out, const AES_KEY *key) { AES_encrypt(in, out, key); } static void aes_encrypt_block_aesni(const unsigned char *in, unsigned char *out, const AES_KEY *key) { AES_encrypt(in, out, key); }
#include <stdio.h> #include "aes.h" static void aes_encrypt_block_openssl(const unsigned char *, unsigned char *, const AES_KEY *); static void aes_encrypt_block_aesni(const unsigned char *, unsigned char *, const AES_KEY *); int use_aesni() { return 0; } void aes_encrypt_block(const unsigned char *in, unsigned char *out, const AES_KEY *key) { static int aesni; if (aesni == 0) { aesni = use_aesni(); } if (aesni == 1) { aes_encrypt_block_aesni(in, out, key); } else { aes_encrypt_block_openssl(in, out, key); } } static void aes_encrypt_block_openssl(const unsigned char *in, unsigned char *out, const AES_KEY *key) { AES_encrypt(in, out, key); } static void aes_encrypt_block_aesni(const unsigned char *in, unsigned char *out, const AES_KEY *key) { AES_encrypt(in, out, key); }
Make detab actually work reliably.
/* * detab: Replace tabs with blanks. */ #include <stdio.h> #define MAXLINE 10000 /* Max input line length. */ #define TABSTOP 8 /* Set tab stop to eight characters. */ int getaline(char *, int); void detab(char *); /* detab: Replace tabs with blanks. */ int main(void) { char line[MAXLINE]; /* Current input line. */ while (getaline(line, MAXLINE) > 0) { detab(line); printf("%s", line); } return 0; } /* getaline: Read a line into `s'; return length. */ int getaline(char *s, int lim) { int c, i; c = 0; for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i) s[i] = c; if (c == '\n') s[i++] = c; s[i] = '\0'; return i; } /* detab: Replace tabs with blanks. */ void detab(char *s) { int i, j; for (i = 0; s[i] != '\0'; ++i) { if (s[i] == '\t') { for (j = 0; j <= (i % TABSTOP + TABSTOP); ++j) s[i + j] = ' '; i += j; } } }
/* * detab: Replace tabs with blanks. */ #include <stdio.h> #define TABSIZE 8 /* detab: Replace tabs with blanks. */ int main(void) { int ch, i; for (i = 0; (ch = getchar()) != EOF; i++) { if (ch == '\n') i = 0; if (ch == '\t') { putchar(' '); while (i % TABSIZE) { putchar(' '); i++; } } else putchar(ch); } return 0; }
Update deprecation message in HTML Text node
// // HTMLText.h // HTMLKit // // Created by Iska on 26/02/15. // Copyright (c) 2015 BrainCookie. All rights reserved. // #import "HTMLCharacterData.h" NS_ASSUME_NONNULL_BEGIN /** A HTML Text node */ @interface HTMLText : HTMLCharacterData /** Initializes a new HTML text node. @param data The text string. @return A new isntance of a HTML text node. */ - (instancetype)initWithData:(NSString *)data; /** Appends the string to this text node. @param string The string to append. */ - (void)appendString:(NSString *)string __attribute__((deprecated("Use the mutable data property instead."))); @end NS_ASSUME_NONNULL_END
// // HTMLText.h // HTMLKit // // Created by Iska on 26/02/15. // Copyright (c) 2015 BrainCookie. All rights reserved. // #import "HTMLCharacterData.h" NS_ASSUME_NONNULL_BEGIN /** A HTML Text node */ @interface HTMLText : HTMLCharacterData /** Initializes a new HTML text node. @param data The text string. @return A new isntance of a HTML text node. */ - (instancetype)initWithData:(NSString *)data; /** Appends the string to this text node. @param string The string to append. */ - (void)appendString:(NSString *)string __attribute__((deprecated("Use `appendData:` instead."))); @end NS_ASSUME_NONNULL_END
Add in stubbing in of new register allocator.
#include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <stdarg.h> #include <ctype.h> #include <string.h> #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include "parse.h" #include "asm.h" struct Asmbb { int id; char **lbls; size_t nlbls; Insn **insns; size_t ninsns; Bitset *livein; Bitset *liveout; }; void adduses(Insn *i, Bitset *bs) { } void subdefs(Insn *i, Bitset *bs) { }
Clean up smyrna files: remove unnecessary globals modify libraries not to rely on code in cmd/smyrna remove static declarations from .h files remove unnecessary libraries mark unused code and clean up warnings
#ifndef TOPVIEWSETTINGS_H #define TOPVIEWSETTINGS_H #include "smyrnadefs.h" _BB void on_settingsOKBtn_clicked (GtkWidget *widget,gpointer user_data); _BB void on_settingsCancelBtn_clicked (GtkWidget *widget,gpointer user_data); int load_settings_from_graph(Agraph_t *g); int update_graph_from_settings(Agraph_t *g); int show_settings_form(); #endif
/* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifndef TOPVIEWSETTINGS_H #define TOPVIEWSETTINGS_H #include "smyrnadefs.h" _BB void on_settingsOKBtn_clicked(GtkWidget * widget, gpointer user_data); _BB void on_settingsCancelBtn_clicked(GtkWidget * widget, gpointer user_data); extern int load_settings_from_graph(Agraph_t * g); extern int update_graph_from_settings(Agraph_t * g); extern int show_settings_form(); #endif
Create an interface indicating a class requires construction (or constructor-like) logic to be delayed until Arduino setup() function
#ifndef RCR_LEVEL1PAYLOAD_SETUPABLE_H_ #define RCR_LEVEL1PAYLOAD_SETUPABLE_H_ #if defined(ARDUINO) && ARDUINO >= 100 #include "arduino.h" #else #include "WProgram.h" #endif namespace rcr { namespace level1payload { // An interface indicating a class requires construction (or constructor-like) // logic to be delayed until Arduino setup() function. class Setupable { public: // Setup this object. (Especially within the setup() function in the // Arduino program.) virtual void Setup() = 0; // Must provide virtual d'tor and body to prevent memory leak. virtual ~Setupable() {} }; } // namespace level1_payload } // namespace rcr #endif // RCR_LEVEL1PAYLOAD_SETUPABLE_H_
Add configuration file. Unity provides the ability for the user to add this file in order to substitute built in Unity functions for user specific ones. In this case we are using it to redefine UNITY_OUTPUT_CHAR which is used by all the printing functions. By default it is directed to stdout, however to ensure the use of Unity is safe when used with the mbed RTOS the output char macros is redefined to a utest alternative. This alternative will only write a character to stdout if interrupts are enabled. NOTE to allow this configuration file to be used the following macro must be defined for the build: UNITY_INCLUDE_CONFIG_H
/**************************************************************************** * Copyright (c) 2015, 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. **************************************************************************** */ #ifndef UNITY_CONFIG_H #define UNITY_CONFIG_H /* When using unity with the mbed RTOS printing to the serial port using the stdlib is not allowed as it causes a hardfault. Unity has the following define to control how failure messages are written: #ifndef UNITY_OUTPUT_CHAR #include <stdio.h> #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) #endif To make this safe we can define our own version of UNITY_OUTPUT_CHAR and make sure it is thread safe. */ #ifndef UNITY_OUTPUT_CHAR #define UNITY_OUTPUT_CHAR(a) utest_safe_putc(a) #endif //UNITY_OUTPUT_CHAR #endif // UNITY_CONFIG_H
Add example using the pack library
/* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #include <gvc.h> #include <pack.h> int main (int argc, char* argv[]) { graph_t *g; graph_t *sg; FILE *fp; graph_t** cc; int i, ncc; GVC_t *gvc; gvc = gvContext(); if (argc > 1) fp = fopen(argv[1], "r"); else fp = stdin; g = agread(fp); cc = ccomps(g, &ncc, (char*)0); for (i = 0; i < ncc; i++) { sg = cc[i]; nodeInduce (sg); gvLayout(gvc, sg, "neato"); } pack_graph (ncc, cc, g, 0); gvRender(gvc, g, "ps", stdout); for (i = 0; i < ncc; i++) { sg = cc[i]; gvFreeLayout(gvc, sg); agdelete(g, sg); } agclose(g); return (gvFreeContext(gvc)); }
Add Handler for user to handle a http request.
// The MIT License (MIT) // // Copyright(c) 2016 huan.wang // // 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, // #pragma once #include <memory> #include "net/http/context.h" namespace net { namespace http { class Handler { public: virtual void ServeHTTP(std::shared_ptr<Context> ctx) = 0; }; } // !namespace http } // !namespace net
Add subscript operator to Vector3
#pragma once template <typename T> class Vector3 { public: T x, y, z; Vector3(T x, T y, T z) { this->x = x; this->y = y; this->z = z; } }; template <typename T> class Vector4 { public: T x, y, z, w; Vector4() {} Vector4(T x, T y, T z, T w) { this->x = x; this->y = y; this->z = z; this->w = w; } T &operator[](unsigned i) { return (&x)[i]; } };
#pragma once template <typename T> class Vector3 { public: T x, y, z; Vector3(T x, T y, T z) { this->x = x; this->y = y; this->z = z; } T &operator[](unsigned i) { return (&x)[i]; } }; template <typename T> class Vector4 { public: T x, y, z, w; Vector4() {} Vector4(T x, T y, T z, T w) { this->x = x; this->y = y; this->z = z; this->w = w; } T &operator[](unsigned i) { return (&x)[i]; } };
Add an intrusive linked list implementation to eliminate the heap allocations needed for the vectors.
#pragma once namespace caprica { template<typename T> struct IntrusiveLinkedList final { void push_back(T* val) { mSize++; if (front == nullptr) { front = back = val; } else { back->next = val; back = val; } } size_t size() const { return mSize; } private: size_t mSize{ 0 }; T* front{ nullptr }; T* back{ nullptr }; struct ConstIterator final { ConstIterator& operator ++() { if (cur == nullptr) return *this; cur = cur->next; return *this; } const T*& operator *() { return cur; } const T*& operator *() const { return cur; } const T*& operator ->() { return cur; } const T*& operator ->() const { return cur; } bool operator ==(const ConstIterator& other) const { return cur == other.cur; } bool operator !=(const ConstIterator& other) const { return !(*this == other); } private: friend IntrusiveLinkedList; const T* cur{ nullptr }; ConstIterator() = default; ConstIterator(const T* front) : cur(front) { } }; struct Iterator final { Iterator& operator ++() { if (cur == nullptr) return *this; cur = cur->next; return *this; } T*& operator *() { return cur; } const T*& operator *() const { return cur; } T*& operator ->() { return cur; } const T*& operator ->() const { return cur; } bool operator ==(const Iterator& other) const { return cur == other.cur; } bool operator !=(const Iterator& other) const { return !(*this == other); } private: friend IntrusiveLinkedList; T* cur{ nullptr }; Iterator() = default; Iterator(T* front) : cur(front) { } }; public: ConstIterator begin() const { if (!mSize) return ConstIterator(); return ConstIterator(front); } ConstIterator end() const { return ConstIterator(); } Iterator begin() { if (!mSize) return Iterator(); return Iterator(front); } Iterator end() { return Iterator(); } }; }
Add the dispatch header to X_SEMAPHORE
/** ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** * Copyright 2013 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** */ #ifndef XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_ #define XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_ #include "xenia/kernel/xobject.h" #include "xenia/xbox.h" namespace xe { namespace kernel { struct X_SEMAPHORE { // TODO: Make this not empty! }; class XSemaphore : public XObject { public: XSemaphore(KernelState* kernel_state); virtual ~XSemaphore(); void Initialize(int32_t initial_count, int32_t maximum_count); void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header); int32_t ReleaseSemaphore(int32_t release_count); virtual void* GetWaitHandle() { return native_handle_; } private: HANDLE native_handle_; }; } // namespace kernel } // namespace xe #endif // XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_
/** ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** * Copyright 2013 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** */ #ifndef XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_ #define XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_ #include "xenia/kernel/xobject.h" #include "xenia/xbox.h" namespace xe { namespace kernel { struct X_SEMAPHORE { X_DISPATCH_HEADER header; // TODO: Make this not empty! }; class XSemaphore : public XObject { public: XSemaphore(KernelState* kernel_state); virtual ~XSemaphore(); void Initialize(int32_t initial_count, int32_t maximum_count); void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header); int32_t ReleaseSemaphore(int32_t release_count); virtual void* GetWaitHandle() { return native_handle_; } private: HANDLE native_handle_; }; } // namespace kernel } // namespace xe #endif // XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_
Remove unnecessary semicolon after method definitions
#pragma once #include "../definitions.h" class ByteRegister { public: ByteRegister() {}; void set(const u8 new_value) { val = new_value; }; u8 value() const { return val; }; void increment() { val += 1; }; void decrement() { val -= 1; }; private: u8 val; }; class WordRegister { public: WordRegister() {}; void set(const u16 new_value) { val = new_value; }; u16 value() const { return val; }; u8 low() const; u8 high() const; void increment() { val += 1; }; void decrement() { val -= 1; }; private: u16 val; }; class RegisterPair { public: RegisterPair(ByteRegister& high, ByteRegister& low); void set_low(const u8 byte); void set_high(const u8 byte); void set_low(const ByteRegister& byte); void set_high(const ByteRegister& byte); void set(const u16 word); u8 low() const; u8 high() const; u16 value() const; void increment(); void decrement(); private: ByteRegister& low_byte; ByteRegister& high_byte; }; class Offset { public: Offset(u8 val) : val(val) {}; Offset(ByteRegister& reg) : val(reg.value()) {}; u8 value() { return val; } private: u8 val; };
#pragma once #include "../definitions.h" class ByteRegister { public: ByteRegister() {} void set(const u8 new_value) { val = new_value; } u8 value() const { return val; } void increment() { val += 1; } void decrement() { val -= 1; } private: u8 val; }; class WordRegister { public: WordRegister() {} void set(const u16 new_value) { val = new_value; } u16 value() const { return val; } u8 low() const; u8 high() const; void increment() { val += 1; } void decrement() { val -= 1; } private: u16 val; }; class RegisterPair { public: RegisterPair(ByteRegister& high, ByteRegister& low); void set_low(const u8 byte); void set_high(const u8 byte); void set_low(const ByteRegister& byte); void set_high(const ByteRegister& byte); void set(const u16 word); u8 low() const; u8 high() const; u16 value() const; void increment(); void decrement(); private: ByteRegister& low_byte; ByteRegister& high_byte; }; class Offset { public: Offset(u8 val) : val(val) {} Offset(ByteRegister& reg) : val(reg.value()) {} u8 value() { return val; } private: u8 val; };
Clean up suffix array tests.
#include "minunit.h" #include <lcthw/sarray.h> char *test_create_destroy() { char test[] = "abracadabra"; char test2[] = "acadabra"; SuffixArray *sarry = SuffixArray_create(test, sizeof(test)); mu_assert(sarry, "Failed to create."); int at = SuffixArray_find_suffix(sarry, test2, sizeof(test2)); mu_assert(at != -1, "Failed to find the suffix."); at = SuffixArray_find_suffix(sarry, "yo", sizeof("yo")); mu_assert(at == -1, "Should fail to find yo."); SuffixArray_destroy(sarry); return NULL; } char *all_tests() { mu_suite_start(); mu_run_test(test_create_destroy); return NULL; } RUN_TESTS(all_tests);
#include "minunit.h" #include <lcthw/sarray.h> static SuffixArray *sarry = NULL; static char test[] = "abracadabra"; static char test2[] = "acadabra"; char *test_create() { sarry = SuffixArray_create(test, sizeof(test)); mu_assert(sarry, "Failed to create."); return NULL; } char *test_destroy() { SuffixArray_destroy(sarry); return NULL; } char *test_find_suffix() { int at = SuffixArray_find_suffix(sarry, test2, sizeof(test2)); mu_assert(at != -1, "Failed to find the suffix."); at = SuffixArray_find_suffix(sarry, "yo", sizeof("yo")); mu_assert(at == -1, "Should fail to find yo."); return NULL; } char *all_tests() { mu_suite_start(); mu_run_test(test_create); mu_run_test(test_find_suffix); mu_run_test(test_destroy); return NULL; } RUN_TESTS(all_tests);
Mark string functions unused, in case the header is included in files that only use one of them.
#include <string.h> #include <stdint.h> /** * Efficient string hash function. */ static uint32_t string_hash(const char *str) { uint32_t hash = 0; int32_t c; while ((c = *str++)) { hash = c + (hash << 6) + (hash << 16) - hash; } return hash; } /** * Test two strings for equality. */ static int string_compare(const char *str1, const char *str2) { if (str1 == str2) { return 1; } if (str2 == NULL) { return 0; } return strcmp(str1, str2) == 0; }
#include <string.h> #include <stdint.h> /** * Efficient string hash function. */ __attribute__((unused)) static uint32_t string_hash(const char *str) { uint32_t hash = 0; int32_t c; while ((c = *str++)) { hash = c + (hash << 6) + (hash << 16) - hash; } return hash; } /** * Test two strings for equality. */ __attribute__((unused)) static int string_compare(const char *str1, const char *str2) { if (str1 == str2) { return 1; } if (str2 == NULL) { return 0; } return strcmp(str1, str2) == 0; }
Add C++11 compliance check file.
#ifndef CPP11_FEATURES_H #define CPP11_FEATURES_H #if defined(_MSC_VER) && (_MSC_FULL_VER >= 170050727) // for (T t : collection) { } #define CPP11_FOR_EACH // enum class T {}; #define CPP11_ENUM_CLASS #elif defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6) #define CPP11_FOR_EACH #define CPP11_ENUM_CLASS #endif #endif // Include guard.
Add missing license (amd, mit/x11)
#ifndef R600_BLIT_SHADERS_H #define R600_BLIT_SHADERS_H extern const u32 r6xx_ps[]; extern const u32 r6xx_vs[]; extern const u32 r7xx_default_state[]; extern const u32 r6xx_default_state[]; extern const u32 r6xx_ps_size, r6xx_vs_size; extern const u32 r6xx_default_size, r7xx_default_size; #endif
/* * Copyright 2009 Advanced Micro Devices, Inc. * * 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 (including the next * paragraph) 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 COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS 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. * * Authors: * Alex Deucher <alexander.deucher@amd.com> */ #ifndef R600_BLIT_SHADERS_H #define R600_BLIT_SHADERS_H extern const u32 r6xx_ps[]; extern const u32 r6xx_vs[]; extern const u32 r7xx_default_state[]; extern const u32 r6xx_default_state[]; extern const u32 r6xx_ps_size, r6xx_vs_size; extern const u32 r6xx_default_size, r7xx_default_size; #endif
Add tests on how clang currently handles some unknown options.
// RUN: not %clang_cc1 %s -cake-is-lie -%0 -%d 2> %t.log // RUN: FileCheck %s -input-file=%t.log // CHECK: unknown argument // CHECK: unknown argument // CHECK: unknown argument
// RUN: not %clang_cc1 %s -cake-is-lie -%0 -%d 2> %t.log // RUN: FileCheck %s -input-file=%t.log // CHECK: unknown argument // CHECK: unknown argument // CHECK: unknown argument // RUN: %clang -S %s -o %t.s -funknown-to-clang-option -Wunknown-to-clang-option -munknown-to-clang-optio // IGNORED: warning: argument unused during compilation: '-funknown-to-clang-option' // IGNORED: warning: argument unused during compilation: '-munknown-to-clang-option' // IGNORED: warning: unknown warning option '-Wunknown-to-clang-option'
Remove underscores from header guard
/* * %FFILE% * Copyright (C) %YEAR% %USER% <%MAIL%> * * Distributed under terms of the %LICENSE% license. */ #ifndef __%GUARD%__ #define __%GUARD%__ %HERE% #endif /* !__%GUARD%__ */
/* * %FFILE% * Copyright (C) %YEAR% %USER% <%MAIL%> * * Distributed under terms of the %LICENSE% license. */ #ifndef %GUARD% #define %GUARD% %HERE% #endif /* !%GUARD% */
Move static methods outside of class
#ifndef VECTOR_3D_H #define VECTOR_3D_H #include <math.h> namespace classes { struct Point3D { double x, y, z; }; typedef const char* err; class Vector3D { struct Cheshire; Cheshire* smile; static const Point3D nullPoint; static unsigned int idCounter; public: Vector3D(Point3D point = nullPoint); Vector3D(double x, double y = 0.0, double z = 0.0); ~Vector3D(); double getModule() const; void print() const; const Point3D& getPoint() const; Vector3D copy() const; void multiplyByScalar(const double); void normalize(); static Vector3D add(Vector3D&, Vector3D&); static Vector3D substract(Vector3D&, Vector3D&); static Vector3D vectorMultiply(Vector3D&, Vector3D&) ; static double scalarMultiply(Vector3D&, Vector3D&); static double sin(Vector3D&, Vector3D&); static double cos(Vector3D&, Vector3D&); static double angle(Vector3D&, Vector3D&); }; } #endif // VECTOR_3D_H
#ifndef VECTOR_3D_H #define VECTOR_3D_H #include <math.h> namespace classes { struct Point3D { double x, y, z; }; typedef const char* err; class Vector3D { struct Cheshire; Cheshire* smile; static const Point3D nullPoint; static unsigned int idCounter; public: Vector3D(Point3D point = nullPoint); Vector3D(double x, double y = 0.0, double z = 0.0); ~Vector3D(); double getModule() const; void print() const; const Point3D& getPoint() const; Vector3D copy() const; void multiplyByScalar(const double); void normalize(); }; namespace VectorsManip { Vector3D add(Vector3D&, Vector3D&); Vector3D substract(Vector3D&, Vector3D&); Vector3D vectorMultiply(Vector3D&, Vector3D&) ; double scalarMultiply(Vector3D&, Vector3D&); double sin(Vector3D&, Vector3D&); double cos(Vector3D&, Vector3D&); double angle(Vector3D&, Vector3D&); } } #endif // VECTOR_3D_H
Declare routines which support SET keyword = value SQL commands.
/* * Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var' * statements * * $Id: variable.h,v 1.6 1997/09/08 02:39:21 momjian Exp $ * */ enum DateFormat { Date_Postgres, Date_SQL, Date_ISO }; /*-----------------------------------------------------------------------*/ struct PGVariables { struct { bool euro; enum DateFormat format; } date; }; extern struct PGVariables PGVariables; /*-----------------------------------------------------------------------*/ bool SetPGVariable(const char *, const char *); bool GetPGVariable(const char *); bool ResetPGVariable(const char *);
/* * Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var' * statements * * $Id: variable.h,v 1.7 1997/11/07 06:45:16 thomas Exp $ * */ #ifndef VARIABLE_H #define VARIABLE_H 1 enum DateFormat { Date_Postgres, Date_SQL, Date_ISO }; /*-----------------------------------------------------------------------*/ struct PGVariables { struct { bool euro; enum DateFormat format; } date; }; extern struct PGVariables PGVariables; /*-----------------------------------------------------------------------*/ bool SetPGVariable(const char *, const char *); bool GetPGVariable(const char *); bool ResetPGVariable(const char *); extern bool set_date(void); extern bool show_date(void); extern bool reset_date(void); extern bool parse_date(const char *); extern bool set_timezone(void); extern bool show_timezone(void); extern bool reset_timezone(void); extern bool parse_timezone(const char *); extern bool set_cost_heap(void); extern bool show_cost_heap(void); extern bool reset_cost_heap(void); extern bool parse_cost_heap(const char *); extern bool set_cost_index(void); extern bool show_cost_index(void); extern bool reset_cost_index(void); extern bool parse_cost_index(const char *); extern bool set_r_plans(void); extern bool show_r_plans(void); extern bool reset_r_plans(void); extern bool parse_r_plans(const char *); extern bool set_geqo(void); extern bool show_geqo(void); extern bool reset_geqo(void); extern bool parse_geqo(const char *); #endif /* VARIABLE_H */
Use <> instead of \"\"
/* Define the real-function versions of all inline functions defined in signal.h (or bits/sigset.h). */ #include <features.h> #define _EXTERN_INLINE #ifndef __USE_EXTERN_INLINES # define __USE_EXTERN_INLINES 1 #endif #include "signal.h"
/* Define the real-function versions of all inline functions defined in signal.h (or bits/sigset.h). */ #include <features.h> #define _EXTERN_INLINE #ifndef __USE_EXTERN_INLINES # define __USE_EXTERN_INLINES 1 #endif #include <signal.h>
Add a triple to the test.
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s extern void foo_alias (void) __asm ("foo"); inline void foo (void) { return foo_alias (); } extern void bar_alias (void) __asm ("bar"); inline __attribute__ ((__always_inline__)) void bar (void) { return bar_alias (); } extern char *strrchr_foo (const char *__s, int __c) __asm ("strrchr"); extern inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strrchr_foo (const char *__s, int __c) { return __builtin_strrchr (__s, __c); } void f(void) { foo(); bar(); strrchr_foo("", '.'); } // CHECK: define void @f() // CHECK: call void @foo() // CHECK-NEXT: call void @bar() // CHECK-NEXT: call i8* @strrchr( // CHECK-NEXT: ret void // CHECK: declare void @foo() // CHECK: declare void @bar() // CHECK: declare i8* @strrchr(i8*, i32)
// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck %s extern void foo_alias (void) __asm ("foo"); inline void foo (void) { return foo_alias (); } extern void bar_alias (void) __asm ("bar"); inline __attribute__ ((__always_inline__)) void bar (void) { return bar_alias (); } extern char *strrchr_foo (const char *__s, int __c) __asm ("strrchr"); extern inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strrchr_foo (const char *__s, int __c) { return __builtin_strrchr (__s, __c); } void f(void) { foo(); bar(); strrchr_foo("", '.'); } // CHECK: define void @f() // CHECK: call void @foo() // CHECK-NEXT: call void @bar() // CHECK-NEXT: call i8* @strrchr( // CHECK-NEXT: ret void // CHECK: declare void @foo() // CHECK: declare void @bar() // CHECK: declare i8* @strrchr(i8*, i32)
Swap fields in IPv4 header because of little endianness
#ifndef IPV4_H #define IPV4_H #include "syshead.h" #include "netdev.h" #define IPV4 0x04 #define ICMPV4 0x01 struct iphdr { uint8_t version : 4; uint8_t ihl : 4; uint8_t tos; uint16_t len; uint16_t id; uint16_t flags : 3; uint16_t frag_offset : 13; uint8_t ttl; uint8_t proto; uint16_t csum; uint32_t saddr; uint32_t daddr; } __attribute__((packed)); void ipv4_incoming(struct netdev *netdev, struct eth_hdr *hdr); #endif
#ifndef IPV4_H #define IPV4_H #include "syshead.h" #include "netdev.h" #define IPV4 0x04 #define ICMPV4 0x01 struct iphdr { uint8_t ihl : 4; /* TODO: Support Big Endian hosts */ uint8_t version : 4; uint8_t tos; uint16_t len; uint16_t id; uint16_t flags : 3; uint16_t frag_offset : 13; uint8_t ttl; uint8_t proto; uint16_t csum; uint32_t saddr; uint32_t daddr; } __attribute__((packed)); void ipv4_incoming(struct netdev *netdev, struct eth_hdr *hdr); #endif
Include stdio.h in case bzlib.h needs it.
/* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "istream-internal.h" #include "istream-zlib.h" #ifdef HAVE_BZLIB #include <bzlib.h> #define BZLIB_INCLUDE #define gzFile BZFILE #define gzdopen BZ2_bzdopen #define gzclose BZ2_bzclose #define gzread BZ2_bzread #define gzseek BZ2_bzseek #define i_stream_create_zlib i_stream_create_bzlib #include "istream-zlib.c" #endif
/* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "istream-internal.h" #include "istream-zlib.h" #ifdef HAVE_BZLIB #include <stdio.h> #include <bzlib.h> #define BZLIB_INCLUDE #define gzFile BZFILE #define gzdopen BZ2_bzdopen #define gzclose BZ2_bzclose #define gzread BZ2_bzread #define gzseek BZ2_bzseek #define i_stream_create_zlib i_stream_create_bzlib #include "istream-zlib.c" #endif
Fix me missing the name
#pragma once #include "main.h" #include "logmanager.h" #include "modtypes/socket.h" const std::set<unsigned int> sockAPIVersions { 3000 }; class SocketManager { public: std::shared_ptr<Socket> getSocket(const std::string& socketType); private: void removeSocket(const std::string& socketType, void* sockFile, Socket* deletingSocket); }; class SocketLoadFailed : public std::exception { public: SocketLoadFailed(std::string&& desc) : description(std::forward<std::string>(desc)) {} const char* what() const noexcept { return description.c_str(); } private: std::string description; }; class SocketAPIMismatch : public std::exception { public: const char* what() const noexcept { return "The socket module is not compatible with the current module API."; } }; class SocketOperationFailed : public std::exception { public: SocketConnectFailed(std::string&& desc) : description(std::forward<std::string>(desc)) {} const char* what() const noexcept { return description.c_str(); } private: std::string description; };
#pragma once #include "main.h" #include "logmanager.h" #include "modtypes/socket.h" const std::set<unsigned int> sockAPIVersions { 3000 }; class SocketManager { public: std::shared_ptr<Socket> getSocket(const std::string& socketType); private: void removeSocket(const std::string& socketType, void* sockFile, Socket* deletingSocket); }; class SocketLoadFailed : public std::exception { public: SocketLoadFailed(std::string&& desc) : description(std::forward<std::string>(desc)) {} const char* what() const noexcept { return description.c_str(); } private: std::string description; }; class SocketAPIMismatch : public std::exception { public: const char* what() const noexcept { return "The socket module is not compatible with the current module API."; } }; class SocketOperationFailed : public std::exception { public: SocketOperationFailed(std::string&& desc) : description(std::forward<std::string>(desc)) {} const char* what() const noexcept { return description.c_str(); } private: std::string description; };
Update Skia milestone to 83
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 82 #endif
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 83 #endif
Update Skia milestone to 62
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 61 #endif
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 62 #endif
Fix typo in file Header guard
/* * Copyright (c) 2017 - 2020, Broadcom * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef SCP_H_ #define SCP_H #include <stdint.h> int download_scp_patch(void *image, unsigned int image_size); #endif /* SCP_H */
/* * Copyright (c) 2017 - 2020, Broadcom * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef SCP_H #define SCP_H #include <stdint.h> int download_scp_patch(void *image, unsigned int image_size); #endif /* SCP_H */
Remove constness of int fields to enable it to build on VC6.0
#ifndef __REFCACHE_H__ #define __REFCACHE_H__ // Class/Method/Field ID caching // Cache of frequently-used class references struct _classRef { jclass classID; const char *className; }; typedef struct _classRef classRef; // Cache of frequently-used method references struct _methodRef { jmethodID methodID; const int classIndex; const char *methodName; const char *methodSignature; }; typedef struct _methodRef methodRef; // Cache of frequently-used field references struct _fieldRef { jfieldID fieldID; const int classIndex; const char *fieldName; const char *fieldSignature; }; typedef struct _fieldRef fieldRef; class RefCache { public: RefCache(classRef *cr, methodRef *mr, fieldRef *fr) { classRefCache = cr; methodRefCache = mr; fieldRefCache = fr; } jint setUp(JNIEnv *env); void tearDown(JNIEnv *env); private: classRef *classRefCache; methodRef *methodRefCache; fieldRef *fieldRefCache; }; #endif // __REFCACHE_H__
#ifndef __REFCACHE_H__ #define __REFCACHE_H__ // Class/Method/Field ID caching // Cache of frequently-used class references struct _classRef { jclass classID; const char *className; }; typedef struct _classRef classRef; // Cache of frequently-used method references struct _methodRef { jmethodID methodID; int classIndex; // Would be const int if it weren't for VC6 const char *methodName; const char *methodSignature; }; typedef struct _methodRef methodRef; // Cache of frequently-used field references struct _fieldRef { jfieldID fieldID; int classIndex; // Would be const int if it weren't for VC6 const char *fieldName; const char *fieldSignature; }; typedef struct _fieldRef fieldRef; class RefCache { public: RefCache(classRef *cr, methodRef *mr, fieldRef *fr) { classRefCache = cr; methodRefCache = mr; fieldRefCache = fr; } jint setUp(JNIEnv *env); void tearDown(JNIEnv *env); private: classRef *classRefCache; methodRef *methodRefCache; fieldRef *fieldRefCache; }; #endif // __REFCACHE_H__
Install original sfdp files, with development logs; recommit new sfdp files
/* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifndef SFDPINTERNAL_H #define SFDPINTERNAL_H #include <sfdp.h> #ifdef DEBUG extern double _statistics[10]; #endif typedef double real; #endif
Store system clock as milliseconds, not microseconds.
#include "LPC17xx.h" #include "lpc_types.h" #include "lpc17xx_timer.h" #include "timer.h" #define SYSTEM_CLOCK_TIMER LPC_TIM3 #define DELAY_TIMER LPC_TIM0 void TIMER3_IRQHandler() { } void delayMs(int delayInMs) { TIM_TIMERCFG_Type delayTimerConfig; TIM_ConfigStructInit(TIM_TIMER_MODE, &delayTimerConfig); TIM_Init(DELAY_TIMER, TIM_TIMER_MODE, &delayTimerConfig); DELAY_TIMER->PR = 0x00; /* set prescaler to zero */ DELAY_TIMER->MR0 = (SystemCoreClock / 4) / (1000 / delayInMs); //enter delay time DELAY_TIMER->IR = 0xff; /* reset all interrupts */ DELAY_TIMER->MCR = 0x04; /* stop timer on match */ TIM_Cmd(DELAY_TIMER, ENABLE); /* wait until delay time has elapsed */ while (DELAY_TIMER->TCR & 0x01); } unsigned long systemTimeMs() { return SYSTEM_CLOCK_TIMER->TC; } void initializeTimers() { TIM_TIMERCFG_Type systemClockTimerConfig; TIM_ConfigStructInit(TIM_TIMER_MODE, &systemClockTimerConfig); TIM_Init(SYSTEM_CLOCK_TIMER, TIM_TIMER_MODE, &systemClockTimerConfig); TIM_Cmd(SYSTEM_CLOCK_TIMER, ENABLE); }
#include "LPC17xx.h" #include "lpc_types.h" #include "lpc17xx_timer.h" #include "timer.h" #define SYSTEM_CLOCK_TIMER LPC_TIM3 #define DELAY_TIMER LPC_TIM0 void delayMs(int delayInMs) { TIM_TIMERCFG_Type delayTimerConfig; TIM_ConfigStructInit(TIM_TIMER_MODE, &delayTimerConfig); TIM_Init(DELAY_TIMER, TIM_TIMER_MODE, &delayTimerConfig); DELAY_TIMER->PR = 0x00; /* set prescaler to zero */ DELAY_TIMER->MR0 = (SystemCoreClock / 4) / (1000 / delayInMs); //enter delay time DELAY_TIMER->IR = 0xff; /* reset all interrupts */ DELAY_TIMER->MCR = 0x04; /* stop timer on match */ TIM_Cmd(DELAY_TIMER, ENABLE); /* wait until delay time has elapsed */ while (DELAY_TIMER->TCR & 0x01); } unsigned long systemTimeMs() { return SYSTEM_CLOCK_TIMER->TC; } void initializeTimers() { TIM_TIMERCFG_Type systemClockTimerConfig; systemClockTimerConfig.PrescaleOption = TIM_PRESCALE_TICKVAL; systemClockTimerConfig.PrescaleValue = SystemCoreClock / (4 * 1000); TIM_Init(SYSTEM_CLOCK_TIMER, TIM_TIMER_MODE, &systemClockTimerConfig); TIM_Cmd(SYSTEM_CLOCK_TIMER, ENABLE); }
Make Document::add() and remove() static
/* * Copyright (C) 2008-2013 The Communi Project * * This example is free, and not covered by the LGPL license. There is no * restriction applied to their modification, redistribution, using and so on. * You can study them, modify them, use them in your own program - either * completely or partially. */ #ifndef DOCUMENT_H #define DOCUMENT_H #include "textdocument.h" class IrcBuffer; class IrcMessage; class MessageFormatter; class Document : public TextDocument { Q_OBJECT public: Document(IrcBuffer* buffer); ~Document(); IrcBuffer* buffer() const; static Document* instance(IrcBuffer* buffer = 0); public slots: void addBuffer(IrcBuffer* buffer); void removeBuffer(IrcBuffer* buffer); private slots: void receiveMessage(IrcMessage* message); private: struct Private { IrcBuffer* buffer; MessageFormatter* formatter; } d; }; #endif // DOCUMENT_H
/* * Copyright (C) 2008-2013 The Communi Project * * This example is free, and not covered by the LGPL license. There is no * restriction applied to their modification, redistribution, using and so on. * You can study them, modify them, use them in your own program - either * completely or partially. */ #ifndef DOCUMENT_H #define DOCUMENT_H #include "textdocument.h" class IrcBuffer; class IrcMessage; class MessageFormatter; class Document : public TextDocument { Q_OBJECT public: Document(IrcBuffer* buffer); ~Document(); IrcBuffer* buffer() const; static Document* instance(IrcBuffer* buffer = 0); public slots: static void addBuffer(IrcBuffer* buffer); static void removeBuffer(IrcBuffer* buffer); private slots: void receiveMessage(IrcMessage* message); private: struct Private { IrcBuffer* buffer; MessageFormatter* formatter; } d; }; #endif // DOCUMENT_H
Fix compiler warning complaining about un-proto...
/* * Copyright © 2009 CNRS, INRIA, Université Bordeaux 1 * See COPYING in top-level directory. */ #include <private/config.h> #ifdef HAVE_XML #include <hwloc.h> #include "lstopo.h" void output_xml(hwloc_topology_t topology, const char *filename, int verbose_mode) { if (!strcasecmp(filename, "-.xml")) filename = "-"; hwloc_topology_export_xml(topology, filename); } #endif /* HAVE_XML */
/* * Copyright © 2009 CNRS, INRIA, Université Bordeaux 1 * See COPYING in top-level directory. */ #include <private/config.h> #ifdef HAVE_XML #include <hwloc.h> #include <string.h> #include "lstopo.h" void output_xml(hwloc_topology_t topology, const char *filename, int verbose_mode) { if (!strcasecmp(filename, "-.xml")) filename = "-"; hwloc_topology_export_xml(topology, filename); } #endif /* HAVE_XML */
Fix function prototype for sem_wait on freertos
#include <FreeRTOS.h> #include <semphr.h> #include <csp/arch/csp_semaphore.h> #include <csp/csp_debug.h> #include <csp/csp.h> void csp_bin_sem_init(csp_bin_sem_t * sem) { xSemaphoreCreateBinaryStatic(sem); xSemaphoreGive(sem); } int csp_bin_sem_wait(csp_bin_sem_t * sem, uint32_t timeout) { csp_log_lock("Wait: %p", sem); if (timeout != CSP_MAX_TIMEOUT) { timeout = timeout / portTICK_PERIOD_MS; } if (xSemaphoreTake((QueueHandle_t) sem, timeout) == pdPASS) { return CSP_SEMAPHORE_OK; } return CSP_SEMAPHORE_ERROR; } int csp_bin_sem_post(csp_bin_sem_t * sem) { csp_log_lock("Post: %p", sem); if (xSemaphoreGive((QueueHandle_t)sem) == pdPASS) { return CSP_SEMAPHORE_OK; } return CSP_SEMAPHORE_ERROR; }
#include <FreeRTOS.h> #include <semphr.h> #include <csp/arch/csp_semaphore.h> #include <csp/csp_debug.h> #include <csp/csp.h> void csp_bin_sem_init(csp_bin_sem_t * sem) { xSemaphoreCreateBinaryStatic(sem); xSemaphoreGive(sem); } int csp_bin_sem_wait(csp_bin_sem_t * sem, unsigned int timeout) { csp_log_lock("Wait: %p", sem); if (timeout != CSP_MAX_TIMEOUT) { timeout = timeout / portTICK_PERIOD_MS; } if (xSemaphoreTake((QueueHandle_t) sem, timeout) == pdPASS) { return CSP_SEMAPHORE_OK; } return CSP_SEMAPHORE_ERROR; } int csp_bin_sem_post(csp_bin_sem_t * sem) { csp_log_lock("Post: %p", sem); if (xSemaphoreGive((QueueHandle_t)sem) == pdPASS) { return CSP_SEMAPHORE_OK; } return CSP_SEMAPHORE_ERROR; }
Put prototype for syscall() in for OSF/1 machines.
#ifndef _CONDOR_SYSCALLS_H #define _CONDOR_SYSCALLS_H #if defined( AIX32) # include "syscall.aix32.h" #else # include <syscall.h> #endif typedef int BOOL; static const int SYS_LOCAL = 1; static const int SYS_REMOTE = 0; static const int SYS_RECORDED = 2; static const int SYS_MAPPED = 2; static const int SYS_UNRECORDED = 0; static const int SYS_UNMAPPED = 0; #if defined(__cplusplus) extern "C" { #endif int SetSyscalls( int mode ); BOOL LocalSysCalls(); BOOL RemoteSysCalls(); BOOL MappingFileDescriptors(); int REMOTE_syscall( int syscall_num, ... ); #if 0 #if defined(AIX32) && defined(__cplusplus) int syscall( ... ); #elif defined(ULTRIX42) && defined(__cplusplus) int syscall( ... ); #else int syscall( int, ... ); #endif #endif #if defined(__cplusplus) } #endif #endif
#ifndef _CONDOR_SYSCALLS_H #define _CONDOR_SYSCALLS_H #if defined( AIX32) # include "syscall.aix32.h" #else # include <syscall.h> #endif typedef int BOOL; static const int SYS_LOCAL = 1; static const int SYS_REMOTE = 0; static const int SYS_RECORDED = 2; static const int SYS_MAPPED = 2; static const int SYS_UNRECORDED = 0; static const int SYS_UNMAPPED = 0; #if defined(__cplusplus) extern "C" { #endif int SetSyscalls( int mode ); BOOL LocalSysCalls(); BOOL RemoteSysCalls(); BOOL MappingFileDescriptors(); int REMOTE_syscall( int syscall_num, ... ); #if 0 #if defined(AIX32) && defined(__cplusplus) int syscall( ... ); #elif defined(ULTRIX42) && defined(__cplusplus) int syscall( ... ); #else int syscall( int, ... ); #endif #endif #if defined(OSF1) int syscall( int, ... ); #endif #if defined(__cplusplus) } #endif #endif
Simplify test so that it is more portable.
// XFAIL: hexagon // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/a.out // RUN: cd %t.dir && not %clang %s // RUN: test -d %t.dir/a.out // REQUIRES: shell int main() { return 0; }
// RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir // RUN: not %clang %s -c -emit-llvm -o %t.dir // RUN: test -d %t.dir int main() { return 0; }
Fix intermittent build error about non-modular header.
// // BNNSHelpers.h // NumberPad // // Created by Bridger Maxwell on 9/1/16. // Copyright © 2016 Bridger Maxwell. All rights reserved. // #include <Accelerate/Accelerate.h> BNNSFilterParameters createEmptyBNNSFilterParameters();
// // BNNSHelpers.h // NumberPad // // Created by Bridger Maxwell on 9/1/16. // Copyright © 2016 Bridger Maxwell. All rights reserved. // @import Accelerate; BNNSFilterParameters createEmptyBNNSFilterParameters();
Include guard reflects the new project name.
/* * Copyright (c) 2012 Kyle Isom <kyle@tyrfingr.is> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * --------------------------------------------------------------------- */ #ifndef __VOLTAIRE_MAKEDIR_H #define __VOLTAIRE_MAKEDIR_H #include <sys/queue.h> #include <stdio.h> enum E_EXISTS_STATUS { EXISTS_ERROR, EXISTS_NOENT, EXISTS_NOPERM, EXISTS_DIR, EXISTS_FILE }; typedef enum E_EXISTS_STATUS EXISTS_STATUS; int makedirs(const char *, size_t); int rmdirs(const char *, size_t); EXISTS_STATUS path_exists(const char *, size_t); #endif
/* * Copyright (c) 2012 Kyle Isom <kyle@tyrfingr.is> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * --------------------------------------------------------------------- */ #ifndef __DIRUTILS_MAKEDIR_H #define __DIRUTILS_MAKEDIR_H #include <sys/queue.h> #include <stdio.h> enum E_EXISTS_STATUS { EXISTS_ERROR, EXISTS_NOENT, EXISTS_NOPERM, EXISTS_DIR, EXISTS_FILE }; typedef enum E_EXISTS_STATUS EXISTS_STATUS; int makedirs(const char *, size_t); int rmdirs(const char *, size_t); EXISTS_STATUS path_exists(const char *, size_t); #endif
Add back the allocator implementation for WMSDK
// Copyright (c) 2003-2013, LogMeIn, Inc. All rights reserved. // This is part of Xively C library, it is under the BSD 3-Clause license. /** * \file xi_allocator_wmsdk.h * \author Olgierd Humenczuk * \brief Our custom `alloc()` and `free()` [see xi_allocator.h] */ #ifndef __XI_ALLOCATOR_STDLIB_H__ #define __XI_ALLOCATOR_STDLIB_H__ #include <wm_os.h> #ifdef __cplusplus extern "C" { #endif static inline void* xi_alloc( size_t b ) { return ( void* ) os_mem_alloc( b ); } static inline void xi_free( void* p ) { os_mem_free( p ); } #ifdef __cplusplus } #endif #endif
Set thread stack size to 256K
#include <stdlib.h> #include <pthread.h> #include "multithread.h" mt_threads *mt_threads_create(unsigned nthreads) { mt_threads *threads = (mt_threads *) malloc(sizeof(mt_threads)); if (!threads) return NULL; threads->contexts = (mt_context *) malloc(sizeof(mt_context) * nthreads); threads->nthreads = nthreads; unsigned i; for (i = 0; i < nthreads; i++) threads->contexts[i].thread_id = i; return threads; } void mt_threads_free(mt_threads *threads) { free(threads->contexts); free(threads); } void mt_threads_start(mt_threads *threads, void*(*runner)(void *)) { unsigned i; for (i = 0; i < threads->nthreads; i++) pthread_create(&threads->contexts[i].pthread, NULL, runner, &threads->contexts[i]); } void mt_threads_join(mt_threads *threads) { unsigned i; for (i = 0; i < threads->nthreads; i++) pthread_join(threads->contexts[i].pthread, NULL); }
#include <stdlib.h> #include <pthread.h> #include "multithread.h" #define THREAD_STACK_SIZE (256*1024) mt_threads *mt_threads_create(unsigned nthreads) { mt_threads *threads = (mt_threads *) malloc(sizeof(mt_threads)); if (!threads) return NULL; threads->contexts = (mt_context *) malloc(sizeof(mt_context) * nthreads); threads->nthreads = nthreads; unsigned i; for (i = 0; i < nthreads; i++) threads->contexts[i].thread_id = i; return threads; } void mt_threads_free(mt_threads *threads) { free(threads->contexts); free(threads); } void mt_threads_start(mt_threads *threads, void*(*runner)(void *)) { pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE); unsigned i; for (i = 0; i < threads->nthreads; i++) { pthread_create(&threads->contexts[i].pthread, &attr, runner, &threads->contexts[i]); } } void mt_threads_join(mt_threads *threads) { unsigned i; for (i = 0; i < threads->nthreads; i++) pthread_join(threads->contexts[i].pthread, NULL); }
Add tableview editing function to header
#import <Cocoa/Cocoa.h> #import "IPCurveStorage.h" #import "IPCurveView.h" @interface IPSourceController : NSObject <NSTableViewDelegate> { IBOutlet NSTableView * curveSetChooser; IBOutlet IPCurveView * controlPointView; IBOutlet IPCurveStorage * curveStorage; } - (int)numberOfRowsInTableView:(NSTableView *)tableView; - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row; - (void)tableViewSelectionDidChange:(NSNotification *)aNotification; @end
#import <Cocoa/Cocoa.h> #import "IPCurveStorage.h" #import "IPCurveView.h" @interface IPSourceController : NSObject <NSTableViewDelegate> { IBOutlet NSTableView * curveSetChooser; IBOutlet IPCurveView * controlPointView; IBOutlet IPCurveStorage * curveStorage; } - (int)numberOfRowsInTableView:(NSTableView *)tableView; - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row; - (void)tableViewSelectionDidChange:(NSNotification *)aNotification; - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)row; @end
Fix link time bug caused by missing header include.
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 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 TENSORFLOW_PLATFORM_VARIANT_CODING_H_ #define TENSORFLOW_PLATFORM_VARIANT_CODING_H_ #include "tensorflow/core/framework/variant.h" #ifdef PLATFORM_GOOGLE #include "tensorflow/core/platform/google/variant_cord_coding.h" #endif namespace tensorflow { namespace port { // Encodes an array of Variant objects in to the given string. // `variant_array` is assumed to point to an array of `n` Variant objects. void EncodeVariantList(const Variant* variant_array, int64 n, string* out); // Decodes an array of Variant objects from the given string. // `variant_array` is assumed to point to an array of `n` Variant objects. bool DecodeVariantList(const string& in, Variant* variant_array, int64 n); } // end namespace port } // end namespace tensorflow #endif // TENSORFLOW_PLATFORM_VARIANT_CODING_H_
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 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 TENSORFLOW_PLATFORM_VARIANT_CODING_H_ #define TENSORFLOW_PLATFORM_VARIANT_CODING_H_ #include "tensorflow/core/framework/variant.h" #include "tensorflow/core/framework/variant_encode_decode.h" #ifdef PLATFORM_GOOGLE #include "tensorflow/core/platform/google/variant_cord_coding.h" #endif namespace tensorflow { namespace port { // Encodes an array of Variant objects in to the given string. // `variant_array` is assumed to point to an array of `n` Variant objects. void EncodeVariantList(const Variant* variant_array, int64 n, string* out); // Decodes an array of Variant objects from the given string. // `variant_array` is assumed to point to an array of `n` Variant objects. bool DecodeVariantList(const string& in, Variant* variant_array, int64 n); } // end namespace port } // end namespace tensorflow #endif // TENSORFLOW_PLATFORM_VARIANT_CODING_H_
Add correct work of client
#include <unistd.h> #include <stdio.h> #include <master/usage.h> #include <master/arg.h> #include <share/socket.h> #define IP "88.176.106.132" int main(int argc, char *argv[]) { int socket_fd; config_t *config; if (argc < 5) { usage(); return 0; } /* Error on processing arguments */ if ((config = process_args(argc, argv)) == NULL) return 1; socket_fd = create_client_socket(IP, MULTI_PORT); if (socket_fd < 0) return 1; send_file(socket_fd, config->file->input_file); printf("File sent waiting for response\n"); recv_file(socket_fd, config->file->output_file); destroy_config(&config); close(socket_fd); return 0; }
#include <unistd.h> #include <stdio.h> #include <master/usage.h> #include <master/arg.h> #include <share/socket.h> #define IP "88.176.106.132" int main(int argc, char *argv[]) { int socket_fd; config_t *config; if (argc < 5) { usage(); return 0; } /* Error on processing arguments */ if ((config = process_args(argc, argv)) == NULL) return 1; socket_fd = create_client_socket(IP, MULTI_PORT); if (socket_fd < 0) return 1; printf("Preprocessing file %s\n", config->file->input_file); preprocess(config->file); printf("Preprocessing done\n"); printf("Sending file to server for compilation\n"); send_file(socket_fd, config->file->output_file); printf("File sent waiting for response\n"); recv_file(socket_fd, config->file->output_file); printf("File received\n"); destroy_config(&config); close(socket_fd); return 0; }
Change NULL or 0 to nullptr
/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ #pragma once #include <QObject> #include <QUrl> /// Represents a Qml component which can be loaded from a resource. class QmlComponentInfo : public QObject { Q_OBJECT public: QmlComponentInfo(QString title, QUrl url, QUrl icon = QUrl(), QObject* parent = NULL); Q_PROPERTY(QString title READ title CONSTANT) ///< Title for page Q_PROPERTY(QUrl url READ url CONSTANT) ///< Qml source code Q_PROPERTY(QUrl icon READ icon CONSTANT) ///< Icon for page virtual QString title () { return _title; } virtual QUrl url () { return _url; } virtual QUrl icon () { return _icon; } protected: QString _title; QUrl _url; QUrl _icon; };
/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ #pragma once #include <QObject> #include <QUrl> /// Represents a Qml component which can be loaded from a resource. class QmlComponentInfo : public QObject { Q_OBJECT public: QmlComponentInfo(QString title, QUrl url, QUrl icon = QUrl(), QObject* parent = nullptr); Q_PROPERTY(QString title READ title CONSTANT) ///< Title for page Q_PROPERTY(QUrl url READ url CONSTANT) ///< Qml source code Q_PROPERTY(QUrl icon READ icon CONSTANT) ///< Icon for page virtual QString title () { return _title; } virtual QUrl url () { return _url; } virtual QUrl icon () { return _icon; } protected: QString _title; QUrl _url; QUrl _icon; };
Convert the embedded test to the bitmap API
#include <hwloc.h> #include <stdio.h> /* The body of the test is in a separate .c file and a separate library, just to ensure that hwloc didn't force compilation with visibility flags enabled. */ int do_test(void) { mytest_hwloc_topology_t topology; unsigned depth; hwloc_cpuset_t cpu_set; /* Just call a bunch of functions to see if we can link and run */ printf("*** Test 1: cpuset alloc\n"); cpu_set = mytest_hwloc_cpuset_alloc(); if (NULL == cpu_set) return 1; printf("*** Test 2: topology init\n"); if (0 != mytest_hwloc_topology_init(&topology)) return 1; printf("*** Test 3: topology load\n"); if (0 != mytest_hwloc_topology_load(topology)) return 1; printf("*** Test 4: topology get depth\n"); depth = mytest_hwloc_topology_get_depth(topology); if (depth < 0) return 1; printf(" Max depth: %u\n", depth); printf("*** Test 5: topology destroy\n"); mytest_hwloc_topology_destroy(topology); printf("*** Test 6: cpuset free\n"); mytest_hwloc_cpuset_free(cpu_set); return 0; }
#include <hwloc.h> #include <stdio.h> /* The body of the test is in a separate .c file and a separate library, just to ensure that hwloc didn't force compilation with visibility flags enabled. */ int do_test(void) { mytest_hwloc_topology_t topology; unsigned depth; hwloc_bitmap_t cpu_set; /* Just call a bunch of functions to see if we can link and run */ printf("*** Test 1: bitmap alloc\n"); cpu_set = mytest_hwloc_bitmap_alloc(); if (NULL == cpu_set) return 1; printf("*** Test 2: topology init\n"); if (0 != mytest_hwloc_topology_init(&topology)) return 1; printf("*** Test 3: topology load\n"); if (0 != mytest_hwloc_topology_load(topology)) return 1; printf("*** Test 4: topology get depth\n"); depth = mytest_hwloc_topology_get_depth(topology); if (depth < 0) return 1; printf(" Max depth: %u\n", depth); printf("*** Test 5: topology destroy\n"); mytest_hwloc_topology_destroy(topology); printf("*** Test 6: bitmap free\n"); mytest_hwloc_bitmap_free(cpu_set); return 0; }
Include InternalDataStore into Operation interface
#pragma once #ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_ #define YOU_DATASTORE_INTERNAL_OPERATION_H_ #include <unordered_map> #include "../task_typedefs.h" namespace You { namespace DataStore { namespace Internal { /// A pure virtual class of operations to be put into transaction stack class IOperation { public: virtual ~IOperation(); /// Executes the operation virtual bool run() = 0; protected: TaskId taskId; SerializedTask task; }; } // namespace Internal } // namespace DataStore } // namespace You #endif // YOU_DATASTORE_INTERNAL_OPERATION_H_
#pragma once #ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_ #define YOU_DATASTORE_INTERNAL_OPERATION_H_ #include <unordered_map> #include "../task_typedefs.h" #include "internal_datastore.h" namespace You { namespace DataStore { namespace Internal { /// A pure virtual class of operations to be put into transaction stack class IOperation { public: virtual ~IOperation(); /// Executes the operation virtual bool run() = 0; protected: TaskId taskId; SerializedTask task; }; } // namespace Internal } // namespace DataStore } // namespace You #endif // YOU_DATASTORE_INTERNAL_OPERATION_H_
Change outlets from strong to weak references.
// // FlickrViewController.h // PhotoWheel // // Created by Kirby Turner on 12/16/12. // Copyright (c) 2012 White Peak Software Inc. All rights reserved. // #import <UIKit/UIKit.h> @class PhotoAlbum; @interface FlickrViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate, UISearchBarDelegate> @property (nonatomic, strong) IBOutlet UICollectionView *collectionView; @property (nonatomic, strong) IBOutlet UIView *overlayView; @property (nonatomic, strong) IBOutlet UISearchBar *searchBar; @property (nonatomic, strong) IBOutlet UIActivityIndicatorView *activityIndicator; @property (nonatomic, strong) PhotoAlbum *photoAlbum; - (IBAction)save:(id)sender; - (IBAction)cancel:(id)sender; @end
// // FlickrViewController.h // PhotoWheel // // Created by Kirby Turner on 12/16/12. // Copyright (c) 2012 White Peak Software Inc. All rights reserved. // #import <UIKit/UIKit.h> @class PhotoAlbum; @interface FlickrViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate, UISearchBarDelegate> @property (nonatomic, weak) IBOutlet UICollectionView *collectionView; @property (nonatomic, weak) IBOutlet UIView *overlayView; @property (nonatomic, weak) IBOutlet UISearchBar *searchBar; @property (nonatomic, weak) IBOutlet UIActivityIndicatorView *activityIndicator; @property (nonatomic, strong) PhotoAlbum *photoAlbum; - (IBAction)save:(id)sender; - (IBAction)cancel:(id)sender; @end
Add source file for Problem Set 2 (Hacker Edition)
#define _XOPEN_SOURCE #include <cs50.h> #include <stdio.h> #include <string.h> #include <unistd.h> bool dictionaryAttack(string ciphertext); bool bruteForceAttack(string ciphertext); bool next(char* word, int n); int main(int argc, string argv[]) { if (argc != 2) { printf("Usage: ./crack ciphertext\n"); return 1; } if (dictionaryAttack(argv[1])) printf("Password cracked successfully via dictionary attack.\n"); else if (bruteForceAttack(argv[1])) printf("Password cracked successfully via brute force attack.\n"); else printf("Unable to crack password.\n"); } bool dictionaryAttack(string ciphertext) { printf("Dictionary attack initiated.\n"); char word[128]; char salt[2]; strncpy(salt, ciphertext, 2); FILE *wordlist = fopen("/usr/share/dict/words", "r"); while (fgets(word, 128, wordlist)) { // fgets reads new line characters, and we don't want those word[strlen(word) - 1] = '\0'; if (!strcmp(crypt(word, salt), ciphertext)) { printf("Password found: %s\n", word); return true; } } fclose(wordlist); printf("Dictionary attack failed.\n"); return false; } bool bruteForceAttack(string ciphertext) { printf("Brute force attack initiated.\n"); char salt[2]; strncpy(salt, ciphertext, 2); for (int length = 1; length <= 8; length++) { printf("Trying passwords of length %d...\n", length); char* word = calloc(length + 1, sizeof(char)); do { if (!strcmp(crypt(word, salt), ciphertext)) { printf("Password found: %s\n", word); return true; } } while (next(word, length)); } printf("Brute force attack failed.\n"); return false; } bool next(char* word, int length) { for (int i = length - 1; i >= 0; i--) if (word[i] < 127) { word[i]++; for (int j = i+1; j < length; j++) word[j] = 0; return true; } return false; }
Update all-in-one header (add ode.h)
// All-in-one header of nmlib #ifndef NMLIB_H #define NMLIB_H #include "chrono.h" #include "diff.h" #include "fft.h" #include "integral.h" #include "io.h" #include "kalman.h" #include "lp.h" #include "matrix.h" #include "matrix_decomp.h" #include "optimization.h" #include "polynomial.h" #include "random.h" #include "robot.h" #include "route.h" #include "solver.h" #include "sparse.h" #include "spline.h" #include "stat.h" #ifdef NMLIB_DISABLE_NAMESPACE using namespace nmlib; #endif #endif //NMLIB_H
// All-in-one header of nmlib #ifndef NMLIB_H #define NMLIB_H #include "chrono.h" #include "diff.h" #include "fft.h" #include "integral.h" #include "io.h" #include "kalman.h" #include "lp.h" #include "matrix.h" #include "matrix_decomp.h" #include "ode.h" #include "optimization.h" #include "polynomial.h" #include "random.h" #include "robot.h" #include "route.h" #include "solver.h" #include "sparse.h" #include "spline.h" #include "stat.h" #ifdef NMLIB_DISABLE_NAMESPACE using namespace nmlib; #endif #endif //NMLIB_H
Comment on didEndTouchesInRangeSlider and other delegate method
// // YLRangeSliderViewDelegate.h // FantasyRealFootball // // Created by Tom Thorpe on 16/04/2014. // Copyright (c) 2014 Yahoo inc. All rights reserved. // #import <Foundation/Foundation.h> @class TTRangeSlider; @protocol TTRangeSliderDelegate <NSObject> -(void)rangeSlider:(TTRangeSlider *)sender didChangeSelectedMinimumValue:(float)selectedMinimum andMaximumValue:(float)selectedMaximum; @optional - (void)didEndTouchesInRangeSlider:(TTRangeSlider *)sender; @end
// // YLRangeSliderViewDelegate.h // FantasyRealFootball // // Created by Tom Thorpe on 16/04/2014. // Copyright (c) 2014 Yahoo inc. All rights reserved. // #import <Foundation/Foundation.h> @class TTRangeSlider; @protocol TTRangeSliderDelegate <NSObject> /** * Called when the RangeSlider values are changed */ -(void)rangeSlider:(TTRangeSlider *)sender didChangeSelectedMinimumValue:(float)selectedMinimum andMaximumValue:(float)selectedMaximum; @optional /** * Called when the user has finished interacting with the RangeSlider */ - (void)didEndTouchesInRangeSlider:(TTRangeSlider *)sender; @end
Drop ifdefs in favor of more comprehensive code
/* The contents of this file is in the public domain. */ #include <ipify.h> int main(void) { char addr[256]; #if 0 int sd; sd = ipify_connect(); if (sd < 0) return 1; if (!ipify_query(sd, addr, sizeof(addr))) printf("%s\n", addr); return ipify_disconnect(sd); #else if (ipify(addr, sizeof(addr))) return 1; printf("%s\n", addr); return 0; #endif }
/* The contents of this file is in the public domain. */ #include <ipify.h> int main(void) { char addr[256]; int sd; sd = ipify_connect(); if (sd < 0) return 1; if (!ipify_query(sd, addr, sizeof(addr))) printf("%s\n", addr); return ipify_disconnect(sd); }
Make C example more C, less asm
void PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned offset, unsigned numBitplanes, unsigned screenWidthBytes) { int i; copper += offset; for (i = 0; i < numBitplanes; i++) { *(copper+1) = (unsigned)bitplanes; *(copper+3) = ((unsigned)bitplanes >> 16); bitplanes += screenWidthBytes; copper += 4; } } static unsigned short _copperData; static unsigned char _bitplaneData; void TestCall() { PokeBitplanePointers(&_copperData, &_bitplaneData, 3, 4, 5); }
typedef union { unsigned char* ptr; unsigned short word[2]; } word_extract_t; void PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned offset, unsigned numBitplanes, unsigned screenWidthBytes) { int i; copper += offset; for (i = 0; i < numBitplanes; i++) { word_extract_t extract; extract.ptr = bitplanes; *(copper+1) = extract.word[1]; *(copper+3) = extract.word[0]; bitplanes += screenWidthBytes; copper += 4; } } static unsigned short _copperData; static unsigned char _bitplaneData; void TestCall() { PokeBitplanePointers(&_copperData, &_bitplaneData, 3, 4, 5); }
Fix possible memory overflow and remove DEBUG_MAX_BUFFER
/** * `debug.h' - debug.c * * copyright (c) 2014 joseph werle <joseph.werle@gmail.com> */ #ifndef DEBUG_H #define DEBUG_H 1 #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #define DEBUG_MAX_BUFFER 1024 /** * Debug function type */ typedef void (* debug_t) (const char *, ...); /** * Initialize a debug function */ #define debug_init(name) \ void _debug_ ## name (const char *fmt, ...) { \ if (!debug_enabled(#name)) { return; } \ char buf[DEBUG_MAX_BUFFER]; \ va_list args; \ va_start(args, fmt); \ vsprintf(buf, fmt, args); \ printf(#name " - %s\n", buf); \ va_end(args); \ } \ /** * Return a named debug function */ #define debug_get(name) (debug_t) ( _debug_ ## name) /** * Returns `1' if a function is enabled * else `0' */ int debug_enabled (const char *); #endif
/** * `debug.h' - debug.c * * copyright (c) 2014 joseph werle <joseph.werle@gmail.com> */ #ifndef DEBUG_H #define DEBUG_H 1 #include <stdlib.h> #include <stdio.h> #include <stdarg.h> /** * Debug function type */ typedef void (* debug_t) (const char *, ...); /** * Initialize a debug function */ #define debug_init(name) \ void _debug_ ## name (const char *fmt, ...) { \ if (!debug_enabled(#name)) { return; } \ char *buf = NULL; \ va_list args; \ va_start(args, fmt); \ vasprintf(&buf, fmt, args); \ printf(#name " - %s\n", buf); \ va_end(args); \ free(buf); \ } \ /** * Return a named debug function */ #define debug_get(name) (debug_t) ( _debug_ ## name) /** * Returns `1' if a function is enabled * else `0' */ int debug_enabled (const char *); #endif
Make it say "Hello universe."
/* * hello.c - Say hello to the world. * Susumu Ishihara 2015/4/12 */ #include <stdio.h> int main() { printf("Hello world.\n."); printf("Hello susumu.\n"); printf("Added new branch.\n"); return 0; }
/* * hello.c - Say hello to the world. * Susumu Ishihara 2015/4/12 */ #include <stdio.h> int main() { printf("Hello world.\n."); printf("Hello susumu.\n"); printf("Added new branch.\n"); printf("Hello universe.\n"); return 0; }
Add initial test cases for scanf format string checking.
// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s typedef __typeof(sizeof(int)) size_t; typedef struct _FILE FILE; int fscanf(FILE * restrict, const char * restrict, ...) ; int scanf(const char * restrict, ...) ; int sscanf(const char * restrict, const char * restrict, ...) ; void test(const char *s, int *i) { scanf(s, i); // expected-warning{{ormat string is not a string literal}} scanf("%0d", i); // expected-warning{{conversion specifies 0 input characters for field width}} scanf("%00d", i); // expected-warning{{conversion specifies 0 input characters for field width}} }
Use the macros from machine/fsr.h; some minor cleanups.
/* * Written by J.T. Conklin, Apr 10, 1995 * Public domain. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <ieeefp.h> fp_except_t fpsetmask(mask) fp_except_t mask; { fp_except_t old; fp_except_t new; __asm__("st %%fsr,%0" : "=m" (*&old)); new = old; new &= ~(0x1f << 23); new |= ((mask & 0x1f) << 23); __asm__("ld %0,%%fsr" : : "m" (*&new)); return (old >> 23) & 0x1f; }
/* * Written by J.T. Conklin, Apr 10, 1995 * Public domain. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <machine/fsr.h> #include <ieeefp.h> fp_except_t fpsetmask(mask) fp_except_t mask; { fp_except_t old; fp_except_t new; __asm__("st %%fsr,%0" : "=m" (old)); new = old; new &= ~FSR_TEM_MASK; new |= FSR_TEM(mask & FSR_EXC_MASK); __asm__("ld %0,%%fsr" : : "m" (new)); return (FSR_GET_TEM(old)); }
Set removed item's prev/next pointers to NULL.
#ifndef LLIST_H #define LLIST_H /* Doubly linked list */ #define DLLIST_PREPEND(list, item) STMT_START { \ (item)->prev = NULL; \ (item)->next = *(list); \ if (*(list) != NULL) (*(list))->prev = (item); \ *(list) = (item); \ } STMT_END #define DLLIST_REMOVE(list, item) STMT_START { \ if ((item)->prev == NULL) \ *(list) = (item)->next; \ else \ (item)->prev->next = (item)->next; \ if ((item)->next != NULL) \ (item)->next->prev = (item)->prev; \ } STMT_END #endif
#ifndef LLIST_H #define LLIST_H /* Doubly linked list */ #define DLLIST_PREPEND(list, item) STMT_START { \ (item)->prev = NULL; \ (item)->next = *(list); \ if (*(list) != NULL) (*(list))->prev = (item); \ *(list) = (item); \ } STMT_END #define DLLIST_REMOVE(list, item) STMT_START { \ if ((item)->prev == NULL) \ *(list) = (item)->next; \ else \ (item)->prev->next = (item)->next; \ if ((item)->next != NULL) { \ (item)->next->prev = (item)->prev; \ (item)->next = NULL; \ } \ (item)->prev = NULL; \ } STMT_END #endif
Make ScopedOleInitializer work on windows if you aren't including build_config already.
// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_ #define CHROME_APP_SCOPED_OLE_INITIALIZER_H_ // Wraps OLE initialization in a cross-platform class meant to be used on the // stack so init/uninit is done with scoping. This class is ok for use by // non-windows platforms; it just doesn't do anything. #if defined(OS_WIN) #include <ole2.h> class ScopedOleInitializer { public: ScopedOleInitializer() { int ole_result = OleInitialize(NULL); DCHECK(ole_result == S_OK); } ~ScopedOleInitializer() { OleUninitialize(); } }; #else class ScopedOleInitializer { public: // Empty, this class does nothing on non-win32 systems. Empty ctor is // necessary to avoid "unused variable" warning on gcc. ScopedOleInitializer() { } }; #endif #endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_
// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_ #define CHROME_APP_SCOPED_OLE_INITIALIZER_H_ #include "base/logging.h" #include "build/build_config.h" // Wraps OLE initialization in a cross-platform class meant to be used on the // stack so init/uninit is done with scoping. This class is ok for use by // non-windows platforms; it just doesn't do anything. #if defined(OS_WIN) #include <ole2.h> class ScopedOleInitializer { public: ScopedOleInitializer() { int ole_result = OleInitialize(NULL); DCHECK(ole_result == S_OK); } ~ScopedOleInitializer() { OleUninitialize(); } }; #else class ScopedOleInitializer { public: // Empty, this class does nothing on non-win32 systems. Empty ctor is // necessary to avoid "unused variable" warning on gcc. ScopedOleInitializer() { } }; #endif #endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_
Add header guards for test input headers
class PublicPrivate { public: int PublicMemberVar; static int PublicStaticMemberVar; void publicMemberFunc(); typedef int PublicTypedef; struct PublicStruct {}; enum PublicEnum { PublicEnumValue1 }; enum { PublicAnonymousEnumValue }; enum PublicClosedEnum { PublicClosedEnumValue1 } __attribute__((enum_extensibility(closed))); enum PublicOpenEnum { PublicOpenEnumValue1 } __attribute__((enum_extensibility(open))); enum PublicFlagEnum {} __attribute__((flag_enum)); private: int PrivateMemberVar; static int PrivateStaticMemberVar; void privateMemberFunc() {} typedef int PrivateTypedef; struct PrivateStruct {}; enum PrivateEnum { PrivateEnumValue1 }; enum { PrivateAnonymousEnumValue1 }; enum PrivateClosedEnum { PrivateClosedEnumValue1 } __attribute__((enum_extensibility(closed))); enum PrivateOpenEnum { PrivateOpenEnumValue1 } __attribute__((enum_extensibility(open))); enum PrivateFlagEnum {} __attribute__((flag_enum)); };
#ifndef TEST_INTEROP_CXX_CLASS_INPUTS_ACCESS_SPECIFIERS_H #define TEST_INTEROP_CXX_CLASS_INPUTS_ACCESS_SPECIFIERS_H class PublicPrivate { public: int PublicMemberVar; static int PublicStaticMemberVar; void publicMemberFunc(); typedef int PublicTypedef; struct PublicStruct {}; enum PublicEnum { PublicEnumValue1 }; enum { PublicAnonymousEnumValue }; enum PublicClosedEnum { PublicClosedEnumValue1 } __attribute__((enum_extensibility(closed))); enum PublicOpenEnum { PublicOpenEnumValue1 } __attribute__((enum_extensibility(open))); enum PublicFlagEnum {} __attribute__((flag_enum)); private: int PrivateMemberVar; static int PrivateStaticMemberVar; void privateMemberFunc() {} typedef int PrivateTypedef; struct PrivateStruct {}; enum PrivateEnum { PrivateEnumValue1 }; enum { PrivateAnonymousEnumValue1 }; enum PrivateClosedEnum { PrivateClosedEnumValue1 } __attribute__((enum_extensibility(closed))); enum PrivateOpenEnum { PrivateOpenEnumValue1 } __attribute__((enum_extensibility(open))); enum PrivateFlagEnum {} __attribute__((flag_enum)); }; #endif
Add stdin and stdout redirects
#include <stdio.h> #include <fcntl.h> #include <unistd.h> int main(int argc, char* argv[]) { if (argc > 1) { int fdWrite = open(argv[1], O_WRONLY | O_CREAT, 0666); if (fdWrite == -1) { write(2, "Cannot open file", 16); return 1; } int fdRead = open(argv[1], O_RDONLY); if (fdRead == -1) { write(2, "Cannot open file", 16); return 1; } lseek(fdWrite, -1, SEEK_END); char c; while (read(fdRead, &c, 1)) { if (c >= '0' && c <= '9') break; write(fdWrite, &c, 1); } char buff[100]; int readCount; while (readCount = read(fdRead, buff, 100)) write(1, buff, readCount); } else { printf("No file name provided"); } return 0; }
#include <stdio.h> #include <fcntl.h> #include <unistd.h> int main(int argc, char* argv[]) { if (argc > 1) { int stdoutCopy = dup(1); close(1); int fdWrite = open(argv[1], O_WRONLY | O_CREAT | O_APPEND, 0666); if (fdWrite == -1) { write(2, "Cannot open file", 16); return 1; } close(0); int fdRead = open(argv[1], O_RDONLY); if (fdRead == -1) { write(2, "Cannot open file", 16); return 1; } char c; while (read(0, &c, 1) && !(c >= '0' && c <= '9')) { write(1, &c, 1); } char buff[100]; int readCount; close(1); dup(stdoutCopy); while (readCount = read(0, buff, 100)) write(1, buff, readCount); } else { printf("No file name provided"); } return 0; }
Add more helpful C++ error messages
#include "NativeNodeUtils.h" #ifndef __FF_CATCHCVEXCEPTIONWORKER_H__ #define __FF_CATCHCVEXCEPTIONWORKER_H__ struct CatchCvExceptionWorker : public FF::SimpleWorker { public: std::string execute() { try { return executeCatchCvExceptionWorker(); } catch (std::exception e) { return std::string(e.what()); } } virtual std::string executeCatchCvExceptionWorker() = 0; }; #endif
#include "NativeNodeUtils.h" #ifndef __FF_CATCHCVEXCEPTIONWORKER_H__ #define __FF_CATCHCVEXCEPTIONWORKER_H__ struct CatchCvExceptionWorker : public FF::SimpleWorker { public: std::string execute() { try { return executeCatchCvExceptionWorker(); } catch (std::exception &e) { return std::string(e.what()); } } virtual std::string executeCatchCvExceptionWorker() = 0; }; #endif
Add the vpsc library for IPSEPCOLA features
/** * \brief remove overlaps between a set of rectangles. * * 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 REMOVE_RECTANGLE_OVERLAP_H_SEEN #define REMOVE_RECTANGLE_OVERLAP_H_SEEN class Rectangle; void removeRectangleOverlap(Rectangle *rs[], int n, double xBorder, double yBorder); #endif /* !REMOVE_RECTANGLE_OVERLAP_H_SEEN */
Make expected test result endianness-neutral
#include "siphash.h" #include <stdio.h> int main(void) { uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; uint64_t k0 = *(uint64_t*)(key + 0); uint64_t k1 = *(uint64_t*)(key + 8); uint8_t msg[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e}; uint64_t s = siphash24(k0, k1, msg, sizeof(msg)); printf("SipHash-2-4 test: 0x%016llx (expected 0x%016llx)\n", s, 0xa129ca6149be45e5ull); return 0; }
#include "siphash.h" #include <stdio.h> int main(void) { uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; uint64_t k0 = *(uint64_t*)(key + 0); uint64_t k1 = *(uint64_t*)(key + 8); uint8_t msg[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e}; uint8_t res[] = {0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1}; uint64_t r = *(uint64_t*)res; uint64_t s = siphash24(k0, k1, msg, sizeof(msg)); printf("SipHash-2-4 test: 0x%016llx (expected 0x%016llx)\n", s, r); return 0; }
Update this testcase for the new metadata assembler syntax.
// RUN: %clang -g -S -emit-llvm -o - %s | FileCheck %s // RUN: %clang -S -emit-llvm -o - %s | FileCheck %s --check-prefix=NO_DEBUG int main (void) { return 0; } // CHECK: i32 2, !"Debug Info Version", i32 2} // NO_DEBUG-NOT: metadata !"Debug Info Version"
// RUN: %clang -g -S -emit-llvm -o - %s | FileCheck %s // RUN: %clang -S -emit-llvm -o - %s | FileCheck %s --check-prefix=NO_DEBUG int main (void) { return 0; } // CHECK: i32 2, !"Debug Info Version", i32 2} // NO_DEBUG-NOT: !"Debug Info Version"
Make the branches explicit rather than implicit
#include "duktape.h" #include "mininode.h" #include "uv.h" #include <unistd.h> duk_ret_t mn_bi_os_homedir(duk_context *ctx) { char buf[PATH_MAX]; size_t len = sizeof(buf); const int err = uv_os_homedir(buf, &len); if (err) { duk_push_string(ctx, "uv_os_homedir() error!"); duk_throw(ctx); } duk_push_string(ctx, buf); return 1; }
#include "duktape.h" #include "mininode.h" #include "uv.h" #include <unistd.h> duk_ret_t mn_bi_os_homedir(duk_context *ctx) { char buf[PATH_MAX]; size_t len = sizeof(buf); const int err = uv_os_homedir(buf, &len); if (err) { duk_push_string(ctx, "uv_os_homedir() error!"); duk_throw(ctx); } else { duk_push_string(ctx, buf); return 1; } }
Add Logger for dealloc methods.
//////////////////////////////////////////////////////////////////////////////// // // JASPER BLUES // Copyright 2013 Jasper Blues // All Rights Reserved. // // NOTICE: Jasper Blues permits you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// #import "TyphoonDefinition.h" #import "TyphoonInitializer.h" #import "TyphoonPropertyPlaceholderConfigurer.h" #import "TyphoonResource.h" #import "TyphoonBundleResource.h" #import "TyphoonComponentFactory.h" #import "TyphoonComponentFactory+InstanceBuilder.h" #import "TyphoonXmlComponentFactory.h" #import "TyphoonComponentFactoryMutator.h" #import "TyphoonRXMLElement+XmlComponentFactory.h" #import "TyphoonRXMLElement.h" #import "TyphoonTestUtils.h" #import "TyphoonIntrospectionUtils.h" #import "TyphoonAssembly.h" //TODO: Possibly move this to make explicit #import "TyphoonBlockComponentFactory.h" #import "TyphoonAutowire.h" #import "TyphoonShorthand.h"
//////////////////////////////////////////////////////////////////////////////// // // JASPER BLUES // Copyright 2013 Jasper Blues // All Rights Reserved. // // NOTICE: Jasper Blues permits you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// #import "TyphoonDefinition.h" #import "TyphoonInitializer.h" #import "TyphoonPropertyPlaceholderConfigurer.h" #import "TyphoonResource.h" #import "TyphoonBundleResource.h" #import "TyphoonComponentFactory.h" #import "TyphoonComponentFactory+InstanceBuilder.h" #import "TyphoonXmlComponentFactory.h" #import "TyphoonComponentFactoryMutator.h" #import "TyphoonRXMLElement+XmlComponentFactory.h" #import "TyphoonRXMLElement.h" #import "TyphoonTestUtils.h" #import "TyphoonIntrospectionUtils.h" #import "TyphoonAssembly.h" //TODO: Possibly move this to make explicit #import "TyphoonBlockComponentFactory.h" #import "TyphoonAutowire.h" #import "TyphoonShorthand.h" //TODO: Add debug and info level logs #define Typhoon_LogDealloc() NSLog(@"******* %@ in dealloc ****", NSStringFromClass([self class]));
Add compile-time check for bit length of prime field
#ifndef CONSTANTS_H_ #define CONSTANTS_H_ #include <math.h> #define PRIME_FIELD_BINARY_BIT_LENGTH (64) #define LIMB_SIZE_IN_BITS (64) #define LIMB_SIZE_IN_BYTES (LIMB_SIZE_IN_BITS / 8) #define LIMB_SIZE_IN_HEX (LIMB_SIZE_IN_BITS / 4) // +1 is important for basic operations like addition that may overflow to the // next limb #define NUM_LIMBS ((unsigned int) ceil((PRIME_FIELD_BINARY_BIT_LENGTH + 1)/ ((double) LIMB_SIZE_IN_BITS))) #define PRIME_FIELD_FULL_HEX_LENGTH (NUM_LIMBS * LIMB_SIZE_IN_HEX) #endif
#ifndef CONSTANTS_H_ #define CONSTANTS_H_ #include <math.h> // Modify PRIME_FIELD_BINARY_BIT_LENGTH at will #define PRIME_FIELD_BINARY_BIT_LENGTH (131) // Do not modify anything below #define LIMB_SIZE_IN_BITS (64) #define LIMB_SIZE_IN_BYTES (LIMB_SIZE_IN_BITS / 8) #define LIMB_SIZE_IN_HEX (LIMB_SIZE_IN_BITS / 4) #define NUM_LIMBS ((unsigned int) ceil((PRIME_FIELD_BINARY_BIT_LENGTH)/ ((double) LIMB_SIZE_IN_BITS))) #define PRIME_FIELD_FULL_HEX_LENGTH (NUM_LIMBS * LIMB_SIZE_IN_HEX) #if (PRIME_FIELD_BINARY_BIT_LENGTH % LIMB_SIZE_IN_BITS) == 0 #error "PRIME_FIELD_BINARY_BIT_LENGTH must not be a multiple of LIMB_SIZE_IN_BITS" #endif #endif
Add the decoder and field decoder headers to plugin.h
/* This file is part of MAMBO, a low-overhead dynamic binary modification tool: https://github.com/beehive-lab/mambo Copyright 2013-2016 Cosmin Gorgovan <cosmin at linux-geek dot org> 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. */ #include "dbm.h" #include "scanner_public.h" #ifdef __arm__ #include "api/emit_thumb.h" #include "api/emit_arm.h" #elif __aarch64__ #include "api/emit_a64.h" #endif #include "api/helpers.h" #include "scanner_common.h"
/* This file is part of MAMBO, a low-overhead dynamic binary modification tool: https://github.com/beehive-lab/mambo Copyright 2013-2016 Cosmin Gorgovan <cosmin at linux-geek dot org> 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. */ #include "dbm.h" #include "scanner_public.h" #ifdef __arm__ #include "api/emit_thumb.h" #include "api/emit_arm.h" #include "pie/pie-arm-field-decoder.h" #include "pie/pie-arm-decoder.h" #include "pie/pie-thumb-field-decoder.h" #include "pie/pie-thumb-decoder.h" #elif __aarch64__ #include "api/emit_a64.h" #include "pie/pie-a64-field-decoder.h" #include "pie/pie-a64-decoder.h" #endif #include "api/helpers.h" #include "scanner_common.h"
Add a carriage return with the newline
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> struct termios orig_termios; void disableRawMode() { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } void enableRawMode() { tcgetattr(STDIN_FILENO, &orig_termios); atexit(disableRawMode); struct termios raw = orig_termios; raw.c_iflag &= ~(ICRNL | IXON); raw.c_oflag &= ~(OPOST); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enableRawMode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q') { if (iscntrl(c)) { printf("%d\n", c); } else { printf("%d ('%c')\n", c, c); } } return 0; }
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> struct termios orig_termios; void disableRawMode() { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } void enableRawMode() { tcgetattr(STDIN_FILENO, &orig_termios); atexit(disableRawMode); struct termios raw = orig_termios; raw.c_iflag &= ~(ICRNL | IXON); raw.c_oflag &= ~(OPOST); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enableRawMode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q') { if (iscntrl(c)) { printf("%d\r\n", c); } else { printf("%d ('%c')\r\n", c, c); } } return 0; }
Add missing file from previous commit
#include <magick/api.h> #include "macros.h" #include "quantum.h" void image_matrix(const Image *image, double **out, ExceptionInfo *ex) { register long y; register long x; register const PixelPacket *p; unsigned int width = image->columns; for(y = 0; y < image->rows; ++y) { p = ACQUIRE_IMAGE_PIXELS(image, 0, y, width, 1, ex); if (!p) { continue; } for (x = 0; x < width; x++, p++) { // image is GRAY, so all color channels are the same. out[x][y] = ScaleQuantumToChar(p->red) / 255.0; } } }
Rename member field according to the style guide.
// Taken from https://gist.github.com/arvidsson/7231973 #ifndef BITCOIN_REVERSE_ITERATOR_HPP #define BITCOIN_REVERSE_ITERATOR_HPP /** * Template used for reverse iteration in C++11 range-based for loops. * * std::vector<int> v = {1, 2, 3, 4, 5}; * for (auto x : reverse_iterate(v)) * std::cout << x << " "; */ template <typename T> class reverse_range { T &x; public: reverse_range(T &x) : x(x) {} auto begin() const -> decltype(this->x.rbegin()) { return x.rbegin(); } auto end() const -> decltype(this->x.rend()) { return x.rend(); } }; template <typename T> reverse_range<T> reverse_iterate(T &x) { return reverse_range<T>(x); } #endif // BITCOIN_REVERSE_ITERATOR_HPP
// Taken from https://gist.github.com/arvidsson/7231973 #ifndef BITCOIN_REVERSE_ITERATOR_H #define BITCOIN_REVERSE_ITERATOR_H /** * Template used for reverse iteration in C++11 range-based for loops. * * std::vector<int> v = {1, 2, 3, 4, 5}; * for (auto x : reverse_iterate(v)) * std::cout << x << " "; */ template <typename T> class reverse_range { T &m_x; public: reverse_range(T &x) : m_x(x) {} auto begin() const -> decltype(this->m_x.rbegin()) { return m_x.rbegin(); } auto end() const -> decltype(this->m_x.rend()) { return m_x.rend(); } }; template <typename T> reverse_range<T> reverse_iterate(T &x) { return reverse_range<T>(x); } #endif // BITCOIN_REVERSE_ITERATOR_H
Fix the documentation main page
/** \file * This file only exists to contain the front-page of the documentation */ /** \mainpage Documentation of the API if the Tiramisu Compiler * * Tiramisu provides few classes to enable users to represent their program: * - The \ref tiramisu::function class: a function in Tiramisu is equivalent to a function in C. It is composed of multiple computations. Each computation is the equivalent of a statement in C. * - The \ref tiramisu::input class: an input is used to represent inputs passed to Tiramisu. An input can represent a buffer or a scalar. * - The \ref tiramisu::constant class: a constant is designed to represent constants that are supposed to be declared at the beginning of a Tiramisu function. * - The \ref tiramisu::var class: used to represent loop iterators. Usually we declare a var (a loop iterator) and then use it for the declaration of computations. The range of that variable defines the loop range. When use witha buffer it defines the buffer size and when used with an input it defines the input size. * - The \ref tiramisu::computation class: a computation in Tiramisu is the equivalent of a statement in C. It is composed of an expression and an iteration domain. * - The \ref tiramisu::buffer class: a class to represent memory buffers. */
/** \file * This file only exists to contain the front-page of the documentation */ /** \mainpage Documentation of the Tiramisu Compiler API * * Tiramisu provides few classes to enable users to represent their program: * - The \ref tiramisu::function class: used to declare Tiramisu functions. A function in Tiramisu is equivalent to a function in C. It is composed of multiple computations where each computation is the equivalent of a statement in C. * - The \ref tiramisu::input class: used to represent inputs passed to Tiramisu. An input can represent a buffer or a scalar. * - The \ref tiramisu::constant class: a constant is designed to represent constants that are supposed to be declared at the beginning of a Tiramisu function. This can be used only to declare constant scalars. * - The \ref tiramisu::var class: used to represent loop iterators. Usually we declare a var (a loop iterator) and then use it for the declaration of computations. The range of that variable defines the range of the loop around the computation (its iteration domain). When used to declare a buffer it defines the buffer size and when used with an input it defines the input size. * - The \ref tiramisu::computation class: used to declare a computation which is the equivalent of a statement in C. A computation has an expression (tiramisu::expr) and iteration domain defined using an iterator variable. * - The \ref tiramisu::buffer class: a class to represent memory buffers. * - The \ref tiramisu::expr class: used to declare Tiramisu expressions (e.g., 4, 4 + 4, 4 * i, A(i, j), ...). */
Rename MBArtist to MbArtist to make it compile.
/* Get artist by id. * * Usage: * getartist 'artist id' * * $Id$ */ #include <stdio.h> #include <musicbrainz3/mb_c.h> int main(int argc, char **argv) { MBQuery query; MBArtist artist; char data[256]; if (argc < 2) { printf("Usage: getartist 'artist id'\n"); return 1; } mb_webservice_init(); query = mb_query_new(NULL, NULL); artist = mb_query_get_artist_by_id(query, argv[1], NULL); if (!artist) { printf("No artist returned.\n"); mb_query_free(query); return 1; } mb_artist_get_id(artist, data, 256); printf("Id : %s\n", data); mb_artist_get_type(artist, data, 256); printf("Type : %s\n", data); mb_artist_get_name(artist, data, 256); printf("Name : %s\n", data); mb_artist_get_sortname(artist, data, 256); printf("SortName: %s\n", data); mb_artist_free(artist); mb_query_free(query); return 0; }
/* Get artist by id. * * Usage: * getartist 'artist id' * * $Id$ */ #include <stdio.h> #include <musicbrainz3/mb_c.h> int main(int argc, char **argv) { MbQuery query; MbArtist artist; char data[256]; if (argc < 2) { printf("Usage: getartist 'artist id'\n"); return 1; } mb_webservice_init(); query = mb_query_new(NULL, NULL); artist = mb_query_get_artist_by_id(query, argv[1], NULL); if (!artist) { printf("No artist returned.\n"); mb_query_free(query); return 1; } mb_artist_get_id(artist, data, 256); printf("Id : %s\n", data); mb_artist_get_type(artist, data, 256); printf("Type : %s\n", data); mb_artist_get_name(artist, data, 256); printf("Name : %s\n", data); mb_artist_get_sortname(artist, data, 256); printf("SortName: %s\n", data); mb_artist_free(artist); mb_query_free(query); return 0; }
Change comment to eliminate reference to eliminated test double
// MockUIAlertController by Jon Reid, http://qualitycoding.org/about/ // Copyright 2015 Jonathan M. Reid. See LICENSE.txt #import <UIKit/UIKit.h> #import "QCOMockPopoverPresentationController.h" // Convenience import instead of @class /** Captures QCOMockAlertController arguments. */ @interface QCOMockAlertVerifier : NSObject @property (nonatomic, assign) NSUInteger presentedCount; @property (nonatomic, strong) NSNumber *animated; @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *message; @property (nonatomic, assign) UIAlertControllerStyle preferredStyle; @property (nonatomic, readonly) NSArray *actionTitles; @property (nonatomic, strong) QCOMockPopoverPresentationController *popover; - (UIAlertActionStyle)styleForButtonWithTitle:(NSString *)title; - (void)executeActionForButtonWithTitle:(NSString *)title; @end
// MockUIAlertController by Jon Reid, http://qualitycoding.org/about/ // Copyright 2015 Jonathan M. Reid. See LICENSE.txt #import <UIKit/UIKit.h> #import "QCOMockPopoverPresentationController.h" // Convenience import instead of @class /** Captures mocked UIAlertController arguments. */ @interface QCOMockAlertVerifier : NSObject @property (nonatomic, assign) NSUInteger presentedCount; @property (nonatomic, strong) NSNumber *animated; @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *message; @property (nonatomic, assign) UIAlertControllerStyle preferredStyle; @property (nonatomic, readonly) NSArray *actionTitles; @property (nonatomic, strong) QCOMockPopoverPresentationController *popover; - (UIAlertActionStyle)styleForButtonWithTitle:(NSString *)title; - (void)executeActionForButtonWithTitle:(NSString *)title; @end
Fix ARM build in CoreFoundation
//****************************************************************************** // // Copyright (c) 2015 Microsoft Corporation. All rights reserved. // // This code is licensed under the MIT License (MIT). // // 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. // //****************************************************************************** #pragma once #include_next <winnt.h>
//****************************************************************************** // // Copyright (c) 2015 Microsoft Corporation. All rights reserved. // // This code is licensed under the MIT License (MIT). // // 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. // //****************************************************************************** #pragma once #ifdef _ARM_ // winnt.h includes some ARM intrinsics that aren't supported in // clang and cause front end compilation breaks. Because of this, // change the MSC version to be less than what is needed to // support that option. #pragma push_macro("_MSC_FULL_VER") #if (_MSC_FULL_VER >= 170040825) #undef _MSC_FULL_VER #define _MSC_FULL_VER 170040824 #endif #include_next <winnt.h> #pragma pop_macro("_MSC_FULL_VER") #else // Not _ARM_ #include_next <winnt.h> #endif
Add a default value for TEST_SRCDIR
#ifndef __CMPTEST_H__ #define __CMPTEST_H__ #include <stdio.h> #include "sodium.h" #define TEST_NAME_RES TEST_NAME ".res" #define TEST_NAME_OUT TEST_SRCDIR "/" TEST_NAME ".exp" #ifdef HAVE_ARC4RANDOM # undef rand # define rand(X) arc4random(X) #endif FILE *fp_res; int xmain(void); int main(void) { FILE *fp_out; int c; if ((fp_res = fopen(TEST_NAME_RES, "w+")) == NULL) { perror("fopen(" TEST_NAME_RES ")"); return 99; } if (sodium_init() != 0) { return 99; } if (xmain() != 0) { return 99; } rewind(fp_res); if ((fp_out = fopen(TEST_NAME_OUT, "r")) == NULL) { perror("fopen(" TEST_NAME_OUT ")"); return 99; } do { if ((c = fgetc(fp_res)) != fgetc(fp_out)) { return 99; } } while (c != EOF); return 0; } #undef printf #define printf(...) fprintf(fp_res, __VA_ARGS__) #define main xmain #endif
#ifndef __CMPTEST_H__ #define __CMPTEST_H__ #include <stdio.h> #include "sodium.h" #ifndef TEST_SRCDIR # define TEST_SRCDIR "." #endif #define TEST_NAME_RES TEST_NAME ".res" #define TEST_NAME_OUT TEST_SRCDIR "/" TEST_NAME ".exp" #ifdef HAVE_ARC4RANDOM # undef rand # define rand(X) arc4random(X) #endif FILE *fp_res; int xmain(void); int main(void) { FILE *fp_out; int c; if ((fp_res = fopen(TEST_NAME_RES, "w+")) == NULL) { perror("fopen(" TEST_NAME_RES ")"); return 99; } if (sodium_init() != 0) { return 99; } if (xmain() != 0) { return 99; } rewind(fp_res); if ((fp_out = fopen(TEST_NAME_OUT, "r")) == NULL) { perror("fopen(" TEST_NAME_OUT ")"); return 99; } do { if ((c = fgetc(fp_res)) != fgetc(fp_out)) { return 99; } } while (c != EOF); return 0; } #undef printf #define printf(...) fprintf(fp_res, __VA_ARGS__) #define main xmain #endif
Make vu meter react to trigger level
#include <inttypes.h> #include "Effect.h" #include "Inputs.h" #include "Output.h" class Channel { public: Channel(uint8_t _inputId, Output *_output); void read(Inputs *inputs); void setEffect(Effect *newEffect); void runEffect(); inline Effect *getEffect() {return effect;}; uint8_t inputId; Effect *effect; private: uint16_t level; Output *output; };
#include <inttypes.h> #include "Effect.h" #include "Inputs.h" #include "Output.h" class Channel { public: Channel(uint8_t _inputId, Output *_output); void read(Inputs *inputs); void setEffect(Effect *newEffect); void runEffect(); inline Effect *getEffect() {return effect;}; uint8_t inputId; Effect *effect; Output *output; private: uint16_t level; };
Use doubled_t for MIPS defines
/** * mips.h - all the aliases to MIPS ISA * @author Aleksandr Misevich * Copyright 2018 MIPT-MIPS */ #ifndef MIPS_H_ #define MIPS_H_ #include <infra/instrcache/instr_cache_memory.h> #include "mips_instr.h" struct MIPS { using FuncInstr = MIPSInstr; using Register = MIPSRegister; using Memory = InstrMemory<MIPSInstr>; using RegisterUInt = uint32; using RegDstUInt = uint64; }; #endif // MIPS_H_
/** * mips.h - all the aliases to MIPS ISA * @author Aleksandr Misevich * Copyright 2018 MIPT-MIPS */ #ifndef MIPS_H_ #define MIPS_H_ #include <infra/instrcache/instr_cache_memory.h> #include "mips_instr.h" struct MIPS { using FuncInstr = MIPSInstr; using Register = MIPSRegister; using Memory = InstrMemory<MIPSInstr>; using RegisterUInt = uint32; using RegDstUInt = doubled_t<uint32>; // MIPS may produce output to 2x HI/LO register }; #endif // MIPS_H_
Use make_unique in pimpl helper
#ifndef PIMPL_IMPL_H #define PIMPL_IMPL_H #include <utility> template<typename T> pimpl<T>::pimpl() : m{ new T{} } { } template<typename T> template<typename ...Args> pimpl<T>::pimpl( Args&& ...args ) : m{ new T{ std::forward<Args>(args)... } } { } template<typename T> pimpl<T>::~pimpl() { } template<typename T> T* pimpl<T>::operator->() { return m.get(); } template<typename T> const T* pimpl<T>::operator->() const { return m.get(); } template<typename T> T& pimpl<T>::operator*() { return *m.get(); } #endif
#ifndef PIMPL_IMPL_H #define PIMPL_IMPL_H #include "make_unique.h" #include <utility> template<typename T> pimpl<T>::pimpl() : m{ make_unique<T>() } { } template<typename T> template<typename ...Args> pimpl<T>::pimpl( Args&& ...args ) : m{ make_unique<T>(std::forward<Args>(args)...) } { } template<typename T> pimpl<T>::~pimpl() { } template<typename T> T* pimpl<T>::operator->() { return m.get(); } template<typename T> const T* pimpl<T>::operator->() const { return m.get(); } template<typename T> T& pimpl<T>::operator*() { return *m.get(); } #endif
Correct conditional on DD_ERR macro
// // DDMathParserMacros.h // DDMathParser // // Created by Dave DeLong on 2/19/11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import "DDTypes.h" #ifndef ERR_ASSERT #define ERR_ASSERT(_e) NSAssert((_e) != nil, @"NULL out error") #endif #ifndef ERR #define DD_ERR(_c,_f,...) [NSError errorWithDomain:DDMathParserErrorDomain code:(_c) userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:(_f), ##__VA_ARGS__]}] #endif #define DDMathParserDeprecated(_r) __attribute__((deprecated(_r)))
// // DDMathParserMacros.h // DDMathParser // // Created by Dave DeLong on 2/19/11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import "DDTypes.h" #ifndef ERR_ASSERT #define ERR_ASSERT(_e) NSAssert((_e) != nil, @"NULL out error") #endif #ifndef DD_ERR #define DD_ERR(_c,_f,...) [NSError errorWithDomain:DDMathParserErrorDomain code:(_c) userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:(_f), ##__VA_ARGS__]}] #endif #define DDMathParserDeprecated(_r) __attribute__((deprecated(_r)))
Set up syscall() prototype for HP-UX 9 machines.
#ifndef _CONDOR_SYSCALLS_H #define _CONDOR_SYSCALLS_H #if defined( AIX32) # include "syscall.aix32.h" #else # include <syscall.h> #endif typedef int BOOL; static const int SYS_LOCAL = 1; static const int SYS_REMOTE = 0; static const int SYS_RECORDED = 2; static const int SYS_MAPPED = 2; static const int SYS_UNRECORDED = 0; static const int SYS_UNMAPPED = 0; #if defined(__cplusplus) extern "C" { #endif int SetSyscalls( int mode ); BOOL LocalSysCalls(); BOOL RemoteSysCalls(); BOOL MappingFileDescriptors(); int REMOTE_syscall( int syscall_num, ... ); #if 0 #if defined(AIX32) && defined(__cplusplus) int syscall( ... ); #elif defined(ULTRIX42) && defined(__cplusplus) int syscall( ... ); #else int syscall( int, ... ); #endif #endif #if defined(OSF1) int syscall( int, ... ); #endif #if defined(__cplusplus) } #endif #endif
#ifndef _CONDOR_SYSCALLS_H #define _CONDOR_SYSCALLS_H #if defined( AIX32) # include "syscall.aix32.h" #else # include <syscall.h> #endif typedef int BOOL; static const int SYS_LOCAL = 1; static const int SYS_REMOTE = 0; static const int SYS_RECORDED = 2; static const int SYS_MAPPED = 2; static const int SYS_UNRECORDED = 0; static const int SYS_UNMAPPED = 0; #if defined(__cplusplus) extern "C" { #endif int SetSyscalls( int mode ); BOOL LocalSysCalls(); BOOL RemoteSysCalls(); BOOL MappingFileDescriptors(); int REMOTE_syscall( int syscall_num, ... ); #if defined(OSF1) || defined(HPUX9) int syscall( int, ... ); #endif #if defined(__cplusplus) } #endif #endif
Mark one function which return value should follow the GET rule
/* * This file is part of the SDWebImage package. * (c) Olivier Poitrey <rs@dailymotion.com> * (c) Fabrice Aneche * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ #import <Foundation/Foundation.h> #import "SDWebImageCompat.h" typedef NS_ENUM(NSInteger, SDImageFormat) { SDImageFormatUndefined = -1, SDImageFormatJPEG = 0, SDImageFormatPNG, SDImageFormatGIF, SDImageFormatTIFF, SDImageFormatWebP, SDImageFormatHEIC }; @interface NSData (ImageContentType) /** * Return image format * * @param data the input image data * * @return the image format as `SDImageFormat` (enum) */ + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data; /** Convert SDImageFormat to UTType @param format Format as SDImageFormat @return The UTType as CFStringRef */ + (nonnull CFStringRef)sd_UTTypeFromSDImageFormat:(SDImageFormat)format; @end
/* * This file is part of the SDWebImage package. * (c) Olivier Poitrey <rs@dailymotion.com> * (c) Fabrice Aneche * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ #import <Foundation/Foundation.h> #import "SDWebImageCompat.h" typedef NS_ENUM(NSInteger, SDImageFormat) { SDImageFormatUndefined = -1, SDImageFormatJPEG = 0, SDImageFormatPNG, SDImageFormatGIF, SDImageFormatTIFF, SDImageFormatWebP, SDImageFormatHEIC }; @interface NSData (ImageContentType) /** * Return image format * * @param data the input image data * * @return the image format as `SDImageFormat` (enum) */ + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data; /** Convert SDImageFormat to UTType @param format Format as SDImageFormat @return The UTType as CFStringRef */ + (nonnull CFStringRef)sd_UTTypeFromSDImageFormat:(SDImageFormat)format CF_RETURNS_NOT_RETAINED; @end
Make linker script variables accessible
/****************************************************************************** * Copyright (c) 2020 IBM Corporation * All rights reserved. * This program and the accompanying materials * are made available under the terms of the BSD License * which accompanies this distribution, and is available at * http://www.opensource.org/licenses/bsd-license.php * * Contributors: * IBM Corporation - initial implementation *****************************************************************************/ #ifndef _SLOF_OF_H #define _SLOF_OF_H /* from OF.lds */ extern long _slof_text; extern long _slof_text_end; #endif
Add test with extra whitespace in macro defintions and invocations.
#define noargs() 1 # define onearg(foo) foo # define twoargs( x , y ) x y # define threeargs( a , b , c ) a b c noargs ( ) onearg ( 2 ) twoargs ( 3 , 4 ) threeargs ( 5 , 6 , 7 )
Add test for variadic invocation with pointers
/* Area: ffi_call Purpose: Test passing pointers in variable argument lists. Limitations: none. PR: none. Originator: www.frida.re */ /* { dg-do run } */ #include "ffitest.h" #include <stdarg.h> typedef void * T; static T test_fn (T a, T b, ...) { va_list ap; T c; va_start (ap, b); c = va_arg (ap, T); printf ("%p %p %p\n", a, b, c); va_end (ap); return a + 1; } int main (void) { ffi_cif cif; ffi_type* arg_types[3]; T a, b, c; T args[3]; ffi_arg res; arg_types[0] = &ffi_type_pointer; arg_types[1] = &ffi_type_pointer; arg_types[2] = &ffi_type_pointer; CHECK(ffi_prep_cif_var (&cif, FFI_DEFAULT_ABI, 2, 3, &ffi_type_pointer, arg_types) == FFI_OK); a = (T)0x11223344; b = (T)0x55667788; c = (T)0xAABBCCDD; args[0] = &a; args[1] = &b; args[2] = &c; ffi_call (&cif, FFI_FN (test_fn), &res, args); /* { dg-output "0x11223344 0x55667788 0xAABBCCDD" } */ printf("res: %p\n", (T)res); /* { dg-output "\nres: 0x11223345" } */ return 0; }
Put physics FPS to 84 - that's the common value in LX .56. So far it seems it behaves exactly like old LX, needs still testing though.
/* OpenLieroX physic simulation interface code under LGPL created on 9/2/2008 */ #ifndef __PHYSICSLX56_H__ #define __PHYSICSLX56_H__ #include "Physics.h" PhysicsEngine* CreatePhysicsEngineLX56(); #define LX56PhysicsFixedFPS 100 #define LX56PhysicsDT TimeDiff(1000 / LX56PhysicsFixedFPS) #endif
/* OpenLieroX physic simulation interface code under LGPL created on 9/2/2008 */ #ifndef __PHYSICSLX56_H__ #define __PHYSICSLX56_H__ #include "Physics.h" PhysicsEngine* CreatePhysicsEngineLX56(); #define LX56PhysicsFixedFPS 84 #define LX56PhysicsDT TimeDiff(1000 / LX56PhysicsFixedFPS) #endif
Fix NSDate property management attribute assign->strong
// // OpenPGPPublicKey.h // ObjectivePGP // // Created by Marcin Krzyzanowski on 04/05/14. // Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved. // // Tag 6 #import <Foundation/Foundation.h> #import "PGPTypes.h" #import "PGPPacketFactory.h" #import "PGPKeyID.h" #import "PGPFingerprint.h" @class PGPMPI; @interface PGPPublicKeyPacket : PGPPacket <NSCopying> @property (assign, readonly) UInt8 version; @property (assign, readonly) NSDate *createDate; @property (assign, readonly) UInt16 V3validityPeriod; // obsolete @property (assign, readonly) PGPPublicKeyAlgorithm publicKeyAlgorithm; @property (strong, readwrite) NSArray *publicMPIArray; @property (assign, readonly) NSUInteger keySize; @property (strong, nonatomic, readonly) PGPFingerprint *fingerprint; @property (strong, nonatomic, readonly) PGPKeyID *keyID; - (NSData *) exportPacket:(NSError *__autoreleasing*)error; - (NSData *) exportPublicPacketOldStyle; - (NSData *) buildPublicKeyBodyData:(BOOL)forceV4; - (PGPMPI *) publicMPI:(NSString *)identifier; - (NSData *) encryptData:(NSData *)data withPublicKeyAlgorithm:(PGPPublicKeyAlgorithm)publicKeyAlgorithm; @end
// // OpenPGPPublicKey.h // ObjectivePGP // // Created by Marcin Krzyzanowski on 04/05/14. // Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved. // // Tag 6 #import <Foundation/Foundation.h> #import "PGPTypes.h" #import "PGPPacketFactory.h" #import "PGPKeyID.h" #import "PGPFingerprint.h" @class PGPMPI; @interface PGPPublicKeyPacket : PGPPacket <NSCopying> @property (assign, readonly) UInt8 version; @property (strong, readonly) NSDate* createDate; @property (assign, readonly) UInt16 V3validityPeriod; // obsolete @property (assign, readonly) PGPPublicKeyAlgorithm publicKeyAlgorithm; @property (strong, readwrite) NSArray* publicMPIArray; @property (assign, readonly) NSUInteger keySize; @property (strong, nonatomic, readonly) PGPFingerprint* fingerprint; @property (strong, nonatomic, readonly) PGPKeyID* keyID; - (NSData*)exportPacket:(NSError* __autoreleasing*)error; - (NSData*)exportPublicPacketOldStyle; - (NSData*)buildPublicKeyBodyData:(BOOL)forceV4; - (PGPMPI*)publicMPI:(NSString*)identifier; - (NSData*)encryptData:(NSData*)data withPublicKeyAlgorithm:(PGPPublicKeyAlgorithm)publicKeyAlgorithm; @end
Update driver version to 5.02.00-k8
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2010 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k7"
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2010 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k8"
Update driver version to 5.04.00-k2
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2013 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.04.00-k1"
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2013 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.04.00-k2"
Fix obvious issue which probably broke build on windows.
#ifndef _LA_LOG_H #define _LA_LOG_H #include <stdarg.h> #include <stdint.h> #include <stdio.h> #ifndef _WIN32 #include <syslog.h> #else #define LOG_INFO 1 #define LOG_ERR 2 #define LOG_CRIT 3 #endif #include <time.h> void la_log_syslog_open(); void la_log(int priority, const char *format, ...); void la_log_unsuppress(); class LALog { public: LALog() : _time_period_start(time(NULL)) { } void syslog_open(); void log(int priority, const char *format, ...); void log_ap(int priority, const char *format, va_list ap); void unsupress(); bool should_suppress(); bool suppressing() {return _suppressing; } private: // really rough rate limiting for log messages. We could keep a // hash here of formats and selectively supress based on format. bool _suppressing = false; const uint8_t _time_period = 5; // seconds const uint8_t _max_messages_per_time_period = 10; uint32_t _suppressed_message_count = 0; uint8_t _message_count_this_time_period = 0; time_t _time_period_start; bool use_syslog = false; }; #endif
#ifndef _LA_LOG_H #define _LA_LOG_H #include <stdarg.h> #include <stdint.h> #include <stdio.h> #ifndef _WIN32 #include <syslog.h> #else #define LOG_DEBUG 0 #define LOG_INFO 1 #define LOG_ERR 2 #define LOG_CRIT 3 #endif #include <time.h> void la_log_syslog_open(); void la_log(int priority, const char *format, ...); void la_log_unsuppress(); class LALog { public: LALog() : _time_period_start(time(NULL)) { } void syslog_open(); void log(int priority, const char *format, ...); void log_ap(int priority, const char *format, va_list ap); void unsupress(); bool should_suppress(); bool suppressing() {return _suppressing; } private: // really rough rate limiting for log messages. We could keep a // hash here of formats and selectively supress based on format. bool _suppressing = false; const uint8_t _time_period = 5; // seconds const uint8_t _max_messages_per_time_period = 10; uint32_t _suppressed_message_count = 0; uint8_t _message_count_this_time_period = 0; time_t _time_period_start; bool use_syslog = false; }; #endif
Add a missing UIKit import.
/* * This file is part of the FreeStreamer project, * (C)Copyright 2011-2015 Matias Muhonen <mmu@iki.fi> * See the file ''LICENSE'' for using the code. * * https://github.com/muhku/FreeStreamer */ #include "FSFrequencyDomainAnalyzer.h" #define kFSFrequencyPlotViewMaxCount 64 @interface FSFrequencyPlotView : UIView <FSFrequencyDomainAnalyzerDelegate> { float _levels[kFSFrequencyPlotViewMaxCount]; NSUInteger _count; BOOL _drawing; } - (void)frequenceAnalyzer:(FSFrequencyDomainAnalyzer *)analyzer levelsAvailable:(float *)levels count:(NSUInteger)count; - (void)reset; @end
/* * This file is part of the FreeStreamer project, * (C)Copyright 2011-2015 Matias Muhonen <mmu@iki.fi> * See the file ''LICENSE'' for using the code. * * https://github.com/muhku/FreeStreamer */ #import <UIKit/UIKit.h> #include "FSFrequencyDomainAnalyzer.h" #define kFSFrequencyPlotViewMaxCount 64 @interface FSFrequencyPlotView : UIView <FSFrequencyDomainAnalyzerDelegate> { float _levels[kFSFrequencyPlotViewMaxCount]; NSUInteger _count; BOOL _drawing; } - (void)frequenceAnalyzer:(FSFrequencyDomainAnalyzer *)analyzer levelsAvailable:(float *)levels count:(NSUInteger)count; - (void)reset; @end
Fix member access issue stopping compile
#include "logger.h" #include <stdio.h> #include <errno.h> #include <libpp/map-lists.h> #include <libpp/separators.h> #include <libtypes/types.h> Logger logger__new_( Logger options ) { if ( options.log == NULL ) { options.log = logger__default_log; } return options; } int logger__default_log( Logger const logger, LogLevel const level, char const * const format, va_list var_args ) { if ( format == NULL ) { return EINVAL; } else if ( level.severity < logger.min_severity ) { return 0; } char const * const logger_name = logger.s; if ( ( logger_name != NULL && fprintf( stderr, "%s: ", logger_name ) < 0 ) || ( level.name != NULL && fprintf( stderr, "%s: ", level.name ) < 0 ) || vfprintf( stderr, format, var_args ) < 0 || fprintf( stderr, "\n" ) < 0 ) { return EIO; } return 0; } #define DEF_FUNC( L, U ) \ LOG_FUNC_DEF( L, log_level_##L ) PP_MAP_LISTS( DEF_FUNC, PP_SEP_NONE, LOG_LEVELS ) #undef DEF_FUNC
#include "logger.h" #include <stdio.h> #include <errno.h> #include <libpp/map-lists.h> #include <libpp/separators.h> #include <libtypes/types.h> Logger logger__new_( Logger options ) { if ( options.log == NULL ) { options.log = logger__default_log; } return options; } int logger__default_log( Logger const logger, LogLevel const level, char const * const format, va_list var_args ) { if ( format == NULL ) { return EINVAL; } else if ( level.severity < logger.min_severity ) { return 0; } char const * const logger_name = logger.c; if ( ( logger_name != NULL && fprintf( stderr, "%s: ", logger_name ) < 0 ) || ( level.name != NULL && fprintf( stderr, "%s: ", level.name ) < 0 ) || vfprintf( stderr, format, var_args ) < 0 || fprintf( stderr, "\n" ) < 0 ) { return EIO; } return 0; } #define DEF_FUNC( L, U ) \ LOG_FUNC_DEF( L, log_level_##L ) PP_MAP_LISTS( DEF_FUNC, PP_SEP_NONE, LOG_LEVELS ) #undef DEF_FUNC
Use urbit types instead of size_t
/* j/3/xeb.c ** */ #include "all.h" /* functions */ u3_noun u3qc_xeb(u3_atom a) { mpz_t a_mp; if ( __(u3a_is_dog(a)) ) { u3r_mp(a_mp, a); size_t log = mpz_sizeinbase(a_mp, 2); mpz_t b_mp; mpz_init_set_ui(b_mp, log); return u3i_mp(b_mp); } else { mpz_init_set_ui(a_mp, a); c3_d x = mpz_sizeinbase(a_mp, 2); mpz_t b_mp; mpz_init_set_ui(b_mp, x); return u3i_mp(b_mp); } } u3_noun u3wc_xeb( u3_noun cor) { u3_noun a; if ( (u3_none == (a = u3r_at(u3x_sam, cor))) || (c3n == u3ud(a)) ) { return u3m_bail(c3__exit); } else { return u3qc_xeb(a); } }
/* j/3/xeb.c ** */ #include "all.h" /* functions */ u3_noun u3qc_xeb(u3_atom a) { mpz_t a_mp; if ( __(u3a_is_dog(a)) ) { u3r_mp(a_mp, a); c3_d x = mpz_sizeinbase(a_mp, 2); mpz_t b_mp; mpz_init_set_ui(b_mp, x); return u3i_mp(b_mp); } else { mpz_init_set_ui(a_mp, a); c3_d x = mpz_sizeinbase(a_mp, 2); mpz_t b_mp; mpz_init_set_ui(b_mp, x); return u3i_mp(b_mp); } } u3_noun u3wc_xeb( u3_noun cor) { u3_noun a; if ( (u3_none == (a = u3r_at(u3x_sam, cor))) || (c3n == u3ud(a)) ) { return u3m_bail(c3__exit); } else { return u3qc_xeb(a); } }
Add decl of MIN macro
/* * libvirt-utils.h: misc helper APIs for python binding * * Copyright (C) 2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * <http://www.gnu.org/licenses/>. * */ #ifndef __LIBVIRT_UTILS_H__ # define __LIBVIRT_UTILS_H__ # define STREQ(a,b) (strcmp(a,b) == 0) #endif /* __LIBVIRT_UTILS_H__ */
/* * libvirt-utils.h: misc helper APIs for python binding * * Copyright (C) 2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * <http://www.gnu.org/licenses/>. * */ #ifndef __LIBVIRT_UTILS_H__ # define __LIBVIRT_UTILS_H__ # define STREQ(a,b) (strcmp(a,b) == 0) # ifndef MIN # define MIN(a,b) (((a) < (b)) ? (a) : (b)) # endif #endif /* __LIBVIRT_UTILS_H__ */
Add a test case for bit accurate integer types in llvm-gcc. This is XFAILed for now until llvm-gcc changes are committed.
// RUN: %llvmgcc -S %s -o - /dev/null // XFAIL: * #define ATTR_BITS(N) __attribute__((bitwidth(N))) typedef int ATTR_BITS( 4) My04BitInt; typedef int ATTR_BITS(16) My16BitInt; typedef int ATTR_BITS(17) My17BitInt; typedef int ATTR_BITS(37) My37BitInt; typedef int ATTR_BITS(65) My65BitInt; struct MyStruct { My04BitInt i4Field; short ATTR_BITS(12) i12Field; long ATTR_BITS(17) i17Field; My37BitInt i37Field; }; My37BitInt doit( short ATTR_BITS(23) num) { My17BitInt i; struct MyStruct strct; int bitsize1 = sizeof(My17BitInt); int __attribute__((bitwidth(9))) j; int bitsize2 = sizeof(j); int result = bitsize1 + bitsize2; strct.i17Field = result; result += sizeof(struct MyStruct); return result; } int main ( int argc, char** argv) { return (int ATTR_BITS(32)) doit((short ATTR_BITS(23))argc); }
Remove redundant == in Eq
// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://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. #pragma once #include <concepts> namespace sus::ops { // Type `A` and `B` are `Eq<A, B>` if an object of each type can be compared for // equality with the `==` operator. // // TODO: How do we do PartialEq? Can we even? Can we require Ord to be Eq? But // then it depends on ::num? template <class Lhs, class Rhs> concept Eq = requires(const Lhs& lhs, const Rhs& rhs) { { lhs == rhs } -> std::same_as<bool>; { rhs == lhs } -> std::same_as<bool>; }; } // namespace sus::ops
// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://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. #pragma once #include <concepts> namespace sus::ops { // Type `A` and `B` are `Eq<A, B>` if an object of each type can be compared for // equality with the `==` operator. // // TODO: How do we do PartialEq? Can we even? Can we require Ord to be Eq? But // then it depends on ::num? template <class Lhs, class Rhs> concept Eq = requires(const Lhs& lhs, const Rhs& rhs) { { lhs == rhs } -> std::same_as<bool>; }; } // namespace sus::ops
Add Cygwin fixes for sched_get_priority_min() and sched_get_priority_max().
/* * Copyright 2005 The Apache Software Foundation or its licensors, * as applicable. * * 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. * * $Id$ */ #ifndef _ARCH_I386_DEFINITIONS_H_ #define _ARCH_I386_DEFINITIONS_H_ #if !defined(__i386__) #error "This include file is for the i386 architecture only" #endif #define _JC_PAGE_SHIFT 12 /* 4096 byte pages */ #define _JC_STACK_ALIGN 2 #define _JC_BIG_ENDIAN 0 #ifdef __CYGWIN__ #undef _JC_LIBRARY_FMT #define _JC_LIBRARY_FMT "cyg%s.dll" #endif #endif /* _ARCH_I386_DEFINITIONS_H_ */
/* * Copyright 2005 The Apache Software Foundation or its licensors, * as applicable. * * 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. * * $Id$ */ #ifndef _ARCH_I386_DEFINITIONS_H_ #define _ARCH_I386_DEFINITIONS_H_ #if !defined(__i386__) #error "This include file is for the i386 architecture only" #endif #define _JC_PAGE_SHIFT 12 /* 4096 byte pages */ #define _JC_STACK_ALIGN 2 #define _JC_BIG_ENDIAN 0 /* Fixes for Cygwin */ #ifdef __CYGWIN__ #undef _JC_LIBRARY_FMT #define _JC_LIBRARY_FMT "cyg%s.dll" #define sched_get_priority_max(x) (15) #define sched_get_priority_min(x) (1) #endif #endif /* _ARCH_I386_DEFINITIONS_H_ */
Add type aliases for Group
/* vim: set filetype=cpp: */ /** Header file for canonpy. * * Currently it merely contains the definition of the object structure of the * classes defined in canonpy. They are put here in case a C API is intended * to be added for canonpy. */ #ifndef DRUDGE_CANONPY_H #define DRUDGE_CANONPY_H #include <Python.h> #include <memory> #include <libcanon/perm.h> #include <libcanon/sims.h> using libcanon::Simple_perm; using libcanon::Sims_transv; // // Permutation type // ---------------- // /** Object type for canonpy Perm objects. */ // clang-format off typedef struct { PyObject_HEAD Simple_perm perm; } Perm_object; // clang-format on // // Permutation group type // ---------------------- // // clang-format off typedef struct { PyObject_HEAD std::unique_ptr<Sims_transv<Simple_perm>> transv; } Group_object; // clang-format on #endif
/* vim: set filetype=cpp: */ /** Header file for canonpy. * * Currently it merely contains the definition of the object structure of the * classes defined in canonpy. They are put here in case a C API is intended * to be added for canonpy. */ #ifndef DRUDGE_CANONPY_H #define DRUDGE_CANONPY_H #include <Python.h> #include <memory> #include <libcanon/perm.h> #include <libcanon/sims.h> using libcanon::Simple_perm; using libcanon::Sims_transv; // // Permutation type // ---------------- // /** Object type for canonpy Perm objects. */ // clang-format off typedef struct { PyObject_HEAD Simple_perm perm; } Perm_object; // clang-format on // // Permutation group type // ---------------------- // using Transv = Sims_transv<Simple_perm>; using Transv_ptr = std::unique_ptr<Transv>; // clang-format off typedef struct { PyObject_HEAD Transv_ptr transv; } Group_object; // clang-format on #endif