Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Fix CPP issue on OS X
#include "gtk2hs_macros.h" #include <gtksourceview/gtksourcebuffer.h> #if GTK_MAJOR_VERSION < 3 #include <gtksourceview/gtksourceiter.h> #endif #include <gtksourceview/gtksourcelanguage.h> #include <gtksourceview/gtksourcelanguagemanager.h> #include <gtksourceview/gtksourcestyle.h> #include <gtksourceview/gtksourcestylescheme.h> #include <gtksourceview/gtksourcestyleschememanager.h> #include <gtksourceview/gtksourceview.h> #include <gtksourceview/gtksourceview-typebuiltins.h> #include <gtksourceview/gtksourceundomanager.h> #include <gtksourceview/gtksourcecompletionitem.h> #include <gtksourceview/gtksourcegutter.h> #include <gtksourceview/gtksourcecompletionprovider.h> #include <gtksourceview/gtksourcecompletionproposal.h> #include <gtksourceview/gtksourcemark.h> #include <gtksourceview/gtksourcecompletioninfo.h>
#ifdef __BLOCKS__ #undef __BLOCKS__ #endif #include "gtk2hs_macros.h" #include <gtksourceview/gtksourcebuffer.h> #if GTK_MAJOR_VERSION < 3 #include <gtksourceview/gtksourceiter.h> #endif #include <gtksourceview/gtksourcelanguage.h> #include <gtksourceview/gtksourcelanguagemanager.h> #include <gtksourceview/gtksourcestyle.h> #include <gtksourceview/gtksourcestylescheme.h> #include <gtksourceview/gtksourcestyleschememanager.h> #include <gtksourceview/gtksourceview.h> #include <gtksourceview/gtksourceview-typebuiltins.h> #include <gtksourceview/gtksourceundomanager.h> #include <gtksourceview/gtksourcecompletionitem.h> #include <gtksourceview/gtksourcegutter.h> #include <gtksourceview/gtksourcecompletionprovider.h> #include <gtksourceview/gtksourcecompletionproposal.h> #include <gtksourceview/gtksourcemark.h> #include <gtksourceview/gtksourcecompletioninfo.h>
Increase version to 1.48 in preparation for new release
#pragma once // const float in a header file can lead to duplication of the storage // but I don't really care in this case. Just don't do it with a header // that is included hundreds of times. const float kCurrentVersion = 1.47f; // Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version // increment that won't trigger the new-version checks, handy for minor // releases that I don't want to bother users about. //#define VERSION_SUFFIX 'b'
#pragma once // const float in a header file can lead to duplication of the storage // but I don't really care in this case. Just don't do it with a header // that is included hundreds of times. const float kCurrentVersion = 1.48f; // Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version // increment that won't trigger the new-version checks, handy for minor // releases that I don't want to bother users about. //#define VERSION_SUFFIX 'b'
Create Binary Tree Maximum Path Sum.c
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int max_v(int a, int b) { return a > b ? a : b; } int max_value; int DFS(struct TreeNode* root) { int left_sum, right_sum; int sum; if (root == NULL) return 0; left_sum = max_v(0, DFS(root->left)); right_sum= max_v(0, DFS(root->right)); sum = left_sum + right_sum + root->val;//a path. max_value = max_v(sum, max_value); return max_v(left_sum, right_sum) + root->val;//return one max path. } int maxPathSum(struct TreeNode* root) { if (root == NULL) return 0; max_value = -999999999; DFS(root); return max_value; }
Remove hyphens from dutch greetings as per recommendation from @eddyh
#include "num2words.h" // Language strings for Dutch const Language LANG_DUTCH = { .hours = { "een", "twee", "drie", "vier", "vijf", "zes", "zeven", "acht", "negen", "tien", "elf", "twaalf" }, .phrases = { "*$1 uur ", "vijf over *$1 ", "tien over *$1 ", "kwart over *$1 ", "tien voor half *$2 ", "vijf voor half *$2 ", "half *$2 ", "vijf over half *$2 ", "tien over half *$2 ", "kwart voor *$2 ", "tien voor *$2 ", "vijf voor *$2 " }, #ifdef PBL_PLATFORM_CHALK .greetings = { "Goede- morgen ", "Goede- middag ", "Goede- avond ", "Goede- nacht " }, #else .greetings = { "Goede- mor- gen ", "Goede- middag ", "Goede- avond ", "Goede- nacht " }, #endif .connection_lost = "Waar is je tele- foon? " };
#include "num2words.h" // Language strings for Dutch const Language LANG_DUTCH = { .hours = { "een", "twee", "drie", "vier", "vijf", "zes", "zeven", "acht", "negen", "tien", "elf", "twaalf" }, .phrases = { "*$1 uur ", "vijf over *$1 ", "tien over *$1 ", "kwart over *$1 ", "tien voor half *$2 ", "vijf voor half *$2 ", "half *$2 ", "vijf over half *$2 ", "tien over half *$2 ", "kwart voor *$2 ", "tien voor *$2 ", "vijf voor *$2 " }, #ifdef PBL_PLATFORM_CHALK .greetings = { "Goede morgen ", "Goede middag ", "Goede avond ", "Goede nacht " }, #else .greetings = { "Goede mor- gen ", "Goede middag ", "Goede avond ", "Goede nacht " }, #endif .connection_lost = "Waar is je tele- foon? " };
Add setting for MSAA sample count
// Copyright (C) 2016 Elviss Strazdins // This file is part of the Ouzel engine. #pragma once #include "CompileConfig.h" namespace ouzel { struct Settings { video::Renderer::Driver driver = #if defined(OUZEL_PLATFORM_OSX) || defined(OUZEL_PLATFORM_IOS) || defined(OUZEL_PLATFORM_TVOS) || defined(OUZEL_PLATFORM_ANDROID) || defined(OUZEL_PLATFORM_LINUX) video::Renderer::Driver::OPENGL; #elif defined(SUPPORTS_DIRECT3D11) video::Renderer::Driver::DIRECT3D11; #endif Size2 size; bool resizable = false; bool fullscreen = false; float targetFPS = 60.0f; std::string title = "ouzel"; }; }
// Copyright (C) 2016 Elviss Strazdins // This file is part of the Ouzel engine. #pragma once #include "CompileConfig.h" namespace ouzel { struct Settings { video::Renderer::Driver driver = #if defined(OUZEL_PLATFORM_OSX) || defined(OUZEL_PLATFORM_IOS) || defined(OUZEL_PLATFORM_TVOS) || defined(OUZEL_PLATFORM_ANDROID) || defined(OUZEL_PLATFORM_LINUX) video::Renderer::Driver::OPENGL; #elif defined(SUPPORTS_DIRECT3D11) video::Renderer::Driver::DIRECT3D11; #endif Size2 size; uint32_t sampleCount = 1; // MSAA sample count bool resizable = false; bool fullscreen = false; float targetFPS = 60.0f; std::string title = "ouzel"; }; }
Use C99 __func__ instead of __FUNCTION__ when not compiling with Visual C++.
/** * Touhou Community Reliant Automatic Patcher * Main DLL * * ---- * * Logging functions. * Log to both a file and, if requested, an on-screen console. * * As of now, we do not enforce char strings to be in UTF-8. */ #pragma once /// --------------- /// Standard output /// --------------- // Basic void log_print(const char *text); // Specific length void log_nprint(const char *text, size_t n); // Formatted void log_vprintf(const char *text, va_list va); void log_printf(const char *text, ...); #define log_func_printf(text, ...) \ log_printf("["__FUNCTION__"]: "##text, __VA_ARGS__) /// --------------- /// ------------- /// Message boxes // Technically not a "logging function", but hey, it has variable arguments. /// ------------- // Basic int log_mbox(const char *caption, const UINT type, const char *text); // Formatted int log_vmboxf(const char *caption, const UINT type, const char *text, va_list va); int log_mboxf(const char *caption, const UINT type, const char *text, ...); /// ------------- void log_init(int console); void log_exit(void);
/** * Touhou Community Reliant Automatic Patcher * Main DLL * * ---- * * Logging functions. * Log to both a file and, if requested, an on-screen console. * * As of now, we do not enforce char strings to be in UTF-8. */ #pragma once /// --------------- /// Standard output /// --------------- // Basic void log_print(const char *text); // Specific length void log_nprint(const char *text, size_t n); // Formatted void log_vprintf(const char *text, va_list va); void log_printf(const char *text, ...); #ifdef _MSC_VER # define log_func_printf(text, ...) \ log_printf("["__FUNCTION__"]: "text, __VA_ARGS__) #else # define log_func_printf(text, ...) \ log_printf("[%s]: "text, __func__, ##__VA_ARGS__) #endif /// --------------- /// ------------- /// Message boxes // Technically not a "logging function", but hey, it has variable arguments. /// ------------- // Basic int log_mbox(const char *caption, const UINT type, const char *text); // Formatted int log_vmboxf(const char *caption, const UINT type, const char *text, va_list va); int log_mboxf(const char *caption, const UINT type, const char *text, ...); /// ------------- void log_init(int console); void log_exit(void);
Prepare function added for Robot modules.
/* * File: robots.h * Author: m79lol * */ #ifndef ROBOT_MODULE_H #define ROBOT_MODULE_H #define ROBOT_COMMAND_FREE 0 #define ROBOT_COMMAND_HAND_CONTROL_BEGIN -1 #define ROBOT_COMMAND_HAND_CONTROL_END -2 class Robot { protected: Robot() {} public: virtual FunctionResult* executeFunction(regval command_index, regval *args) = 0; virtual void axisControl(regval axis_index, regval value) = 0; virtual ~Robot() {} }; class RobotModule { protected: RobotModule() {} public: virtual const char *getUID() = 0; virtual int init() = 0; virtual FunctionData** getFunctions(int *count_functions) = 0; virtual AxisData** getAxis(int *count_axis) = 0; virtual Robot* robotRequire() = 0; virtual void robotFree(Robot *robot) = 0; virtual void final() = 0; virtual void destroy() = 0; virtual ~RobotModule() {} }; typedef RobotModule* (*getRobotModuleObject_t)(); extern "C" { __declspec(dllexport) RobotModule* getRobotModuleObject(); } #endif /* ROBOT_MODULE_H */
/* * File: robots.h * Author: m79lol * */ #ifndef ROBOT_MODULE_H #define ROBOT_MODULE_H #define ROBOT_COMMAND_FREE 0 #define ROBOT_COMMAND_HAND_CONTROL_BEGIN -1 #define ROBOT_COMMAND_HAND_CONTROL_END -2 typedef std::function<void(unsigned short int, const char*, va_list)> t_printf_color_module; class Robot { protected: Robot() {} public: virtual FunctionResult* executeFunction(regval command_index, regval *args) = 0; virtual void axisControl(regval axis_index, regval value) = 0; virtual ~Robot() {} }; class RobotModule { protected: RobotModule() {} public: virtual const char *getUID() = 0; virtual void prepare(t_printf_color_module f_printf) = 0; virtual int init() = 0; virtual FunctionData** getFunctions(int *count_functions) = 0; virtual AxisData** getAxis(int *count_axis) = 0; virtual Robot* robotRequire() = 0; virtual void robotFree(Robot *robot) = 0; virtual void final() = 0; virtual void destroy() = 0; virtual ~RobotModule() {} }; typedef RobotModule* (*getRobotModuleObject_t)(); extern "C" { __declspec(dllexport) RobotModule* getRobotModuleObject(); } #endif /* ROBOT_MODULE_H */
Add definitions for block headers.
// Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved. // Please see the AUTHORS file for details. Use of this source code is governed // by a BSD license that can be found in the LICENSE file. #ifndef SCALLOC_BLOCK_HEADER_H_ #define SCALLOC_BLOCK_HEADER_H_ #include "common.h" #include "freelist.h" enum BlockType { kSlab, kLargeObject, kForward }; class BlockHeader { public: static BlockHeader* GetFromObject(void* p); BlockType type; }; class ForwardHeader : public BlockHeader { public: BlockHeader* forward; }; class SlabHeader : public BlockHeader { public: // read-only properties size_t size_class; size_t remote_flist; // mostly read properties bool active; size_t owner; // thread-local read/write properties uint64_t in_use; Freelist flist; } cache_aligned; class LargeObjectHeader : public BlockHeader { public: size_t size; inline void Reset(size_t size) { this->type = kLargeObject; this->size = size; } } cache_aligned; always_inline BlockHeader* BlockHeader::GetFromObject(void* p) { uintptr_t ptr = reinterpret_cast<uintptr_t>(p); if (UNLIKELY(ptr % kSystemPageSize == 0)) { BlockHeader* bh = reinterpret_cast<BlockHeader*>(ptr - kSystemPageSize); if (bh->type == kForward) { bh = reinterpret_cast<ForwardHeader*>(bh)->forward; } } uintptr_t page_ptr = ptr & ~(kSystemPageSize - 1); BlockHeader* bh = reinterpret_cast<BlockHeader*>(page_ptr); switch (bh->type) { case kForward: return reinterpret_cast<ForwardHeader*>(bh)->forward; case kSlab: case kLargeObject: return bh; default: ErrorOut("unknown block header. type: %d, ptr: %p, page_ptr: %p", bh->type, p, reinterpret_cast<void*>(page_ptr)); } // unreachable... return NULL; } #endif // SCALLOC_BLOCK_HEADER_H_
Add test for octApron combine where forgetting lval is too imprecise
// SKIP PARAM: --sets ana.activated[+] octApron #include <assert.h> int f(int x) { return x + 1; } int main(void) { int y, z; z = y; y = f(y); // local is: y == z // fun is: #ret == x' + 1 // fun args subst (x' -> y) is: #ret == y + 1 // local forget y is: top // fun forget y is: top // fun subst (#ret -> y) is: top // unify is: top // WANT: // local is: y == z // fun is: #ret == x' + 1 // fun args subst (x' -> y) is: #ret == y + 1 // unify is: y == z && #ret == y + 1 (&& #ret == z + 1) // assign (y = #ret) is: // 1. y == z && #ret == y + 1 && y#new == #ret (&& #ret == z + 1 && y#new == z + 1) // 2. y#new == #ret && #ret == z + 1 (&& y#new == z + 1) // 3. y == #ret && #ret == z + 1 (&& y == z + 1) // forget #ret is: y == z + 1 assert(y == z + 1); // TODO return 0; }
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::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 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. */
Add guard code to prevent from relocating vector table
/* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton * * 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 "cmsis_nvic.h" void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { //static volatile uint32_t *vectors = (uint32_t *) NVIC_RAM_VECTOR_ADDRESS; // Put the vectors in SRAM //vectors[IRQn + 16] = vector; } uint32_t NVIC_GetVector(IRQn_Type IRQn) { uint32_t *vectors = (uint32_t*) NVIC_FLASH_VECTOR_ADDRESS; // Return the vector return vectors[IRQn + 16]; }
/* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton * * 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 "cmsis_nvic.h" #include "platform/mbed_error.h" void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { // NOTE: On NANO130, relocating vector table is not supported due to just 16KB small SRAM. // Add guard code to prevent from unsupported relocating. uint32_t vector_static = NVIC_GetVector(IRQn); if (vector_static != vector) { error("No support for relocating vector table"); } } uint32_t NVIC_GetVector(IRQn_Type IRQn) { uint32_t *vectors = (uint32_t*) NVIC_FLASH_VECTOR_ADDRESS; // Return the vector return vectors[IRQn + 16]; }
Add the mini offset utility class
#ifndef EMULATOR_REGISTER_H #define EMULATOR_REGISTER_H #include <cstdint> template <typename T> class Register { public: Register() {}; void set(const T new_value) { val = new_value; }; T value() const { return val; }; void increment() { val += 1; }; void decrement() { val -= 1; }; private: T val; }; typedef Register<uint8_t> ByteRegister; typedef Register<uint16_t> WordRegister; class RegisterPair { public: RegisterPair(ByteRegister& low, ByteRegister& high); void set_low(const uint8_t byte); void set_high(const uint8_t byte); void set_low(const ByteRegister& byte); void set_high(const ByteRegister& byte); void set(const uint16_t word); uint8_t low() const; uint8_t high() const; uint16_t value() const; void increment(); void decrement(); private: ByteRegister& low_byte; ByteRegister& high_byte; }; #endif
#ifndef EMULATOR_REGISTER_H #define EMULATOR_REGISTER_H #include <cstdint> template <typename T> class Register { public: Register() {}; void set(const T new_value) { val = new_value; }; T value() const { return val; }; void increment() { val += 1; }; void decrement() { val -= 1; }; private: T val; }; typedef Register<uint8_t> ByteRegister; typedef Register<uint16_t> WordRegister; class RegisterPair { public: RegisterPair(ByteRegister& low, ByteRegister& high); void set_low(const uint8_t byte); void set_high(const uint8_t byte); void set_low(const ByteRegister& byte); void set_high(const ByteRegister& byte); void set(const uint16_t word); uint8_t low() const; uint8_t high() const; uint16_t value() const; void increment(); void decrement(); private: ByteRegister& low_byte; ByteRegister& high_byte; }; class Offset { public: Offset(uint8_t val) : val(val) {}; Offset(ByteRegister& reg) : val(reg.value()) {}; uint8_t value() { return val; } private: uint8_t val; }; #endif
Add a wrapper lib for common functions
/* * Copyright (c) 2013 Thomas Adam <thomas@xteddy.org> * * 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 MIND, 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. */ /* Provides some wrappers around various syscalls to handle things like * memory/error checking, etc. */ #include <errno.h> #include <stdarg.h> #include <stdio.h> #include "lswm.h" /* Wrapper around asprintf() to handle error code returns. */ int xasprintf(char **out, const char *fmt, ...) { va_list ap; int i; va_start(ap, fmt); i = asprintf(out, fmt, ap); if (i == -1) { /* Then there were problems allocating memory. */ log_fatal("Couldn't allocate memory for asprintf()"); } va_end(ap); return (i); } /* Wrapper for malloc() to handle memory */ void * xmalloc(size_t s) { void *mem; if (s == 0) log_fatal("Cannot pass zero size to malloc()"); if ((mem = malloc(s)) == NULL) log_fatal("malloc() returned NULL"); return (mem); }
Make the constructor for the Lesson 10 explicit
// // Created by monty on 23/11/15. // #ifndef LESSON02_GLES2LESSON_H #define LESSON02_GLES2LESSON_H namespace odb { class GLES2Lesson { void fetchShaderLocations(); void setPerspective(); void prepareShaderProgram(); void clearBuffers(); void resetTransformMatrices(); void printVerboseDriverInformation(); GLuint createProgram(const char *pVertexSource, const char *pFragmentSource); GLuint loadShader(GLenum shaderType, const char *pSource); void drawTrig(Trig &trig, const glm::mat4 &transform); glm::mat4 projectionMatrix; glm::mat4 viewMatrix; GLuint vertexAttributePosition; GLuint modelMatrixAttributePosition; GLuint viewMatrixAttributePosition; GLuint samplerUniformPosition; GLuint textureCoordinatesAttributePosition; GLuint projectionMatrixAttributePosition; GLuint gProgram; GLuint textureId; int *textureData; int textureWidth; int textureHeight; std::vector<Trig> mTrigs; glm::vec3 camera; public: GLES2Lesson(); ~GLES2Lesson(); bool init(float w, float h, const std::string &vertexShader, const std::string &fragmentShader); void setTexture(int *bitmapData, int width, int height, int format); void render(); void shutdown(); void tick(); void reset(); void addTrigs(std::vector<Trig> vector); }; } #endif //LESSON02_GLES2LESSON_H
// // Created by monty on 23/11/15. // #ifndef LESSON02_GLES2LESSON_H #define LESSON02_GLES2LESSON_H namespace odb { class GLES2Lesson { void fetchShaderLocations(); void setPerspective(); void prepareShaderProgram(); void clearBuffers(); void resetTransformMatrices(); void printVerboseDriverInformation(); GLuint createProgram(const char *pVertexSource, const char *pFragmentSource); GLuint loadShader(GLenum shaderType, const char *pSource); void drawTrig(Trig &trig, const glm::mat4 &transform); glm::mat4 projectionMatrix; glm::mat4 viewMatrix; GLuint vertexAttributePosition; GLuint modelMatrixAttributePosition; GLuint viewMatrixAttributePosition; GLuint samplerUniformPosition; GLuint textureCoordinatesAttributePosition; GLuint projectionMatrixAttributePosition; GLuint gProgram; GLuint textureId; int *textureData; int textureWidth; int textureHeight; std::vector<Trig> mTrigs; glm::vec3 camera; public: explicit GLES2Lesson(); ~GLES2Lesson(); bool init(float w, float h, const std::string &vertexShader, const std::string &fragmentShader); void setTexture(int *bitmapData, int width, int height, int format); void render(); void shutdown(); void tick(); void reset(); void addTrigs(std::vector<Trig> vector); }; } #endif //LESSON02_GLES2LESSON_H
Fix MSVC error C2133 : unknown size of multi-dimensional static const arrays (despite supposed support of C99). Have not confirmed if this breaks anything yet.
/* encrypted keys */ static const uint32_t internal_device_number = 0; static const uint8_t internal_dk_list[][21] = { { }, }; static const uint8_t internal_pk_list[][16] = { { }, }; static const uint8_t internal_hc_list[][112] = { { }, }; /* customize this function to "hide" the keys in the binary */ static void decrypt_key(uint8_t *out, const uint8_t *in, size_t size) { memcpy(out, in, size); }
/* encrypted keys */ static const uint32_t internal_device_number = 0; static const uint8_t internal_dk_list[][21] = { { 0 }, }; static const uint8_t internal_pk_list[][16] = { { 0 }, }; static const uint8_t internal_hc_list[][112] = { { 0 }, }; /* customize this function to "hide" the keys in the binary */ static void decrypt_key(uint8_t *out, const uint8_t *in, size_t size) { memcpy(out, in, size); }
Remove dbg_trace from non-debug builds
#include <assert.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include "const.h" extern void logop(int32_t, int32_t); extern void dbg_trace(void); #define dbg_log(...) { if(DEBUG) { printf(__VA_ARGS__); } } #define dbg_assert(condition) { if(DEBUG) { if(!(condition)) dbg_log(#condition); assert(condition); } } #define dbg_assert_message(condition, message) { if(DEBUG && !(condition)) { dbg_log(message); assert(false); } }
#include <assert.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include "const.h" extern void logop(int32_t, int32_t); extern void dbg_trace(void); #define dbg_log(...) { if(DEBUG) { printf(__VA_ARGS__); } } #define dbg_trace(...) { if(DEBUG) { dbg_trace(__VA_ARGS__); } } #define dbg_assert(condition) { if(DEBUG) { if(!(condition)) dbg_log(#condition); assert(condition); } } #define dbg_assert_message(condition, message) { if(DEBUG && !(condition)) { dbg_log(message); assert(false); } }
Fix inline static local warning
// RUN: %check %s // extern extern inline int f() { static int i; return i++; } // static static inline int h() { static int i; return i++; } // neither inline int g() { static int i; // CHECK: warning: static variable in pure-inline function - may differ per file return i++; } // neither, but const inline int g2() { static const int i = 3; // CHECK: !/warn/ return i; } main() { return f() + g() + h(); }
// RUN: %check %s // extern extern inline int f() { static int i; return i++; } // static static inline int h() { static int i; return i++; } // neither inline int g() { static int i; // CHECK: warning: mutable static variable in pure-inline function - may differ per file return i++; } // neither, but const inline int g2() { static const int i = 3; // CHECK: !/warn/ return i; } main() { return f() + g() + h(); }
Change from 3drobotics to diydrones for COMPANYNAME
#ifndef QGC_CONFIGURATION_H #define QGC_CONFIGURATION_H #include <QString> /** @brief Polling interval in ms */ #define SERIAL_POLL_INTERVAL 9 /** @brief Heartbeat emission rate, in Hertz (times per second) */ #define MAVLINK_HEARTBEAT_DEFAULT_RATE 1 #define WITH_TEXT_TO_SPEECH 1 #define QGC_APPLICATION_NAME "APM Planner" #define QGC_APPLICATION_VERSION "v2.0.0 (beta)" namespace QGC { const QString APPNAME = "APMPLANNER"; const QString COMPANYNAME = "3DROBOTICS"; const int APPLICATIONVERSION = 200; // 1.0.9 } #endif // QGC_CONFIGURATION_H
#ifndef QGC_CONFIGURATION_H #define QGC_CONFIGURATION_H #include <QString> /** @brief Polling interval in ms */ #define SERIAL_POLL_INTERVAL 9 /** @brief Heartbeat emission rate, in Hertz (times per second) */ #define MAVLINK_HEARTBEAT_DEFAULT_RATE 1 #define WITH_TEXT_TO_SPEECH 1 #define QGC_APPLICATION_NAME "APM Planner" #define QGC_APPLICATION_VERSION "v2.0.0 (beta)" namespace QGC { const QString APPNAME = "APMPLANNER2"; const QString COMPANYNAME = "DIYDRONES"; const int APPLICATIONVERSION = 200; // 1.0.9 } #endif // QGC_CONFIGURATION_H
Fix typo in tab removal
#ifndef RADIOMULT_H #define RADIOMULT_H #include "NdbMF.h" /* ========= NdbRadioMult ============ */ class NdbRad ioMult : public NdbMF { protected: public: NdbRadioMult() : NdbMF(9, "Multiplicities for radioactive nuclide production") {} ~NdbRadioMult() {} ClassDef(NdbRadioMult,1) }; // NdbRadioMult #endif
#ifndef RADIOMULT_H #define RADIOMULT_H #include "NdbMF.h" /* ========= NdbRadioMult ============ */ class NdbRadioMult : public NdbMF { protected: public: NdbRadioMult() : NdbMF(9, "Multiplicities for radioactive nuclide production") {} ~NdbRadioMult() {} ClassDef(NdbRadioMult,1) }; // NdbRadioMult #endif
Add a missing atomic include
// Copyright (c) 2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_MODALOVERLAY_H #define BITCOIN_QT_MODALOVERLAY_H #include <QDateTime> #include <QWidget> //! The required delta of headers to the estimated number of available headers until we show the IBD progress static constexpr int HEADER_HEIGHT_SYNC_DELTA = 24; namespace Ui { class ModalOverlay; } /** Modal overlay to display information about the chain-sync state */ class ModalOverlay : public QWidget { Q_OBJECT public: explicit ModalOverlay(QWidget *parent); ~ModalOverlay(); public Q_SLOTS: void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress); void setKnownBestHeight(int count, const QDateTime &blockDate); // will show or hide the modal layer void showHide(bool hide = false, bool userRequested = false); void closeClicked(); protected: bool eventFilter(QObject *obj, QEvent *ev); bool event(QEvent *ev); private: Ui::ModalOverlay *ui; std::atomic<int> bestBlockHeight{0}; // best known height (based on the headers) QVector<QPair<qint64, double> > blockProcessTime; bool layerIsVisible; bool userClosed; }; #endif // BITCOIN_QT_MODALOVERLAY_H
// Copyright (c) 2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_MODALOVERLAY_H #define BITCOIN_QT_MODALOVERLAY_H #include <QDateTime> #include <QWidget> #include <atomic> //! The required delta of headers to the estimated number of available headers until we show the IBD progress static constexpr int HEADER_HEIGHT_SYNC_DELTA = 24; namespace Ui { class ModalOverlay; } /** Modal overlay to display information about the chain-sync state */ class ModalOverlay : public QWidget { Q_OBJECT public: explicit ModalOverlay(QWidget *parent); ~ModalOverlay(); public Q_SLOTS: void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress); void setKnownBestHeight(int count, const QDateTime &blockDate); // will show or hide the modal layer void showHide(bool hide = false, bool userRequested = false); void closeClicked(); protected: bool eventFilter(QObject *obj, QEvent *ev); bool event(QEvent *ev); private: Ui::ModalOverlay *ui; std::atomic<int> bestBlockHeight{0}; // best known height (based on the headers) QVector<QPair<qint64, double> > blockProcessTime; bool layerIsVisible; bool userClosed; }; #endif // BITCOIN_QT_MODALOVERLAY_H
Fix type for spilled arguments
#ifndef _INCLUDE_VM_INTERNAL_H #define _INCLUDE_VM_INTERNAL_H #include "vm.h" #include "defs.h" #include "heap.h" typedef struct { vm_value reg[num_regs]; int return_address; int result_register; //TODO type for this should be heap_address int spilled_arguments; // Used for over-saturated calls. } stack_frame ; typedef struct { stack_frame stack[stack_size]; int stack_pointer; int program_pointer; vm_value *const_table; int const_table_length; } vm_state; #define current_frame (state->stack[state->stack_pointer]) #define next_frame (state->stack[state->stack_pointer + 1]) vm_value new_heap_string(char *content); char *read_string(vm_state *state, vm_value string_value); char *value_to_type_string(vm_value value); #endif
#ifndef _INCLUDE_VM_INTERNAL_H #define _INCLUDE_VM_INTERNAL_H #include "vm.h" #include "defs.h" #include "heap.h" typedef struct { vm_value reg[num_regs]; int return_address; int result_register; heap_address spilled_arguments; // Used for over-saturated calls. } stack_frame ; typedef struct { stack_frame stack[stack_size]; int stack_pointer; int program_pointer; vm_value *const_table; int const_table_length; } vm_state; #define current_frame (state->stack[state->stack_pointer]) #define next_frame (state->stack[state->stack_pointer + 1]) vm_value new_heap_string(char *content); char *read_string(vm_state *state, vm_value string_value); char *value_to_type_string(vm_value value); #endif
Add stub for windows socket implementation.
/* *The MIT License (MIT) * * Copyright (c) <2017> <Stephan Gatzka> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <stddef.h> #include "compiler.h" #include "socket.h" cjet_ssize_t socket_read(socket_type sock, void *buf, size_t count) { return 0; } cjet_ssize_t socket_writev_with_prefix(socket_type sock, void *buf, size_t len, struct socket_io_vector *io_vec, unsigned int count) { return 0; } int socket_close(socket_type sock) { return 0; } enum cjet_system_error get_socket_error(void) { return 0; } const char *get_socket_error_msg(enum cjet_system_error err) { return "Hello"; }
Declare gVERSION global as 'extern'.
/* * Author: Brendan Le Foll <brendan.le.foll@intel.com> * Copyright (c) 2014 Intel Corporation. * * SPDX-License-Identifier: MIT */ #pragma once #ifdef __cplusplus extern "C" { #endif const char* gVERSION; const char* gVERSION_SHORT; #ifdef __cplusplus } #endif
/* * Author: Brendan Le Foll <brendan.le.foll@intel.com> * Copyright (c) 2014 Intel Corporation. * * SPDX-License-Identifier: MIT */ #pragma once #ifdef __cplusplus extern "C" { #endif extern const char* gVERSION; extern const char* gVERSION_SHORT; #ifdef __cplusplus } #endif
Add slight tolerance for image differences to visual test macro.
#import <FBSnapshotTestCase/FBSnapshotTestCase.h> #import "UIApplication+VisualTestUtils.h" /** * @function WMFSnapshotVerifyView * * Verify correct appearance of a given view. * * Search all folder suffixes, use default naming conventions. * * @param view The view to verify. */ #define WMFSnapshotVerifyView(view) FBSnapshotVerifyView((view), nil) /** * @function WMFSnapshotVerifyViewForOSAndWritingDirection * * Compares @c view with a reference image matching the current OS version & application writing direction (e.g. * "testLaysOutProperly_9.2_RTL@2x.png"). * * @param view The view to verify. */ #define WMFSnapshotVerifyViewForOSAndWritingDirection(view) \ FBSnapshotVerifyView((view), [[UIApplication sharedApplication] wmf_systemVersionAndWritingDirection]); @interface FBSnapshotTestCase (WMFConvenience) - (void)wmf_verifyMultilineLabelWithText:(id)stringOrAttributedString width:(CGFloat)width; - (void)wmf_verifyCellWithIdentifier:(NSString *)identifier fromTableView:(UITableView *)tableView width:(CGFloat)width configuredWithBlock:(void (^)(UITableViewCell *))block; - (void)wmf_verifyView:(UIView *)view width:(CGFloat)width; - (void)wmf_verifyViewAtWindowWidth:(UIView *)view; @end
#import <FBSnapshotTestCase/FBSnapshotTestCase.h> #import "UIApplication+VisualTestUtils.h" /** * @function WMFSnapshotVerifyView * * Verify correct appearance of a given view. * * Search all folder suffixes, use default naming conventions. * * @param view The view to verify. */ #define WMFSnapshotVerifyView(view) FBSnapshotVerifyView((view), nil) /** * @function WMFSnapshotVerifyViewForOSAndWritingDirection * * Compares @c view with a reference image matching the current OS version & application writing direction (e.g. * "testLaysOutProperly_9.2_RTL@2x.png"). * * @param view The view to verify. */ #define WMFSnapshotVerifyViewForOSAndWritingDirection(view) \ FBSnapshotVerifyViewWithOptions((view), [[UIApplication sharedApplication] wmf_systemVersionAndWritingDirection], FBSnapshotTestCaseDefaultSuffixes(), 0.1); @interface FBSnapshotTestCase (WMFConvenience) - (void)wmf_verifyMultilineLabelWithText:(id)stringOrAttributedString width:(CGFloat)width; - (void)wmf_verifyCellWithIdentifier:(NSString *)identifier fromTableView:(UITableView *)tableView width:(CGFloat)width configuredWithBlock:(void (^)(UITableViewCell *))block; - (void)wmf_verifyView:(UIView *)view width:(CGFloat)width; - (void)wmf_verifyViewAtWindowWidth:(UIView *)view; @end
Add ecommerce protocol to ga
// GoogleAnalyticsIntegration.h // Copyright (c) 2014 Segment.io. All rights reserved. #import <Foundation/Foundation.h> #import "SEGAnalyticsIntegration.h" @interface SEGGoogleAnalyticsIntegration : SEGAnalyticsIntegration @property(nonatomic, copy) NSString *name; @property(nonatomic, assign) BOOL valid; @property(nonatomic, assign) BOOL initialized; @property(nonatomic, copy) NSDictionary *settings; @end
// GoogleAnalyticsIntegration.h // Copyright (c) 2014 Segment.io. All rights reserved. #import <Foundation/Foundation.h> #import "SEGAnalyticsIntegration.h" #import "SEGEcommerce.h" @interface SEGGoogleAnalyticsIntegration : SEGAnalyticsIntegration <SEGEcommerce> @property(nonatomic, copy) NSString *name; @property(nonatomic, assign) BOOL valid; @property(nonatomic, assign) BOOL initialized; @property(nonatomic, copy) NSDictionary *settings; @end
Add time_left and is_active to the proc struct
// // process.h // Project3 // // Created by Stratton Aguilar on 7/3/14. // Copyright (c) 2014 Stratton Aguilar. All rights reserved. // #ifndef Project3_process_h #define Project3_process_h typedef struct { int processNum; int arrivalTime; int lifeTime; int memReq; } PROCESS; #endif
// // process.h // Project3 // // Created by Stratton Aguilar on 7/3/14. // Copyright (c) 2014 Stratton Aguilar. All rights reserved. // #ifndef Project3_process_h #define Project3_process_h typedef struct { int processNum; int arrivalTime; int lifeTime; int memReq; int time_left; int is_active; } PROCESS; #endif
Remove cost from empty ammoboxes till they can be recycled
["Box_T_NATO_Wps_F",5,0,0], ["Box_T_NATO_WpsSpecial_F",5,0,0],
["Box_T_NATO_Wps_F",0,0,0], ["Box_T_NATO_WpsSpecial_F",0,0,0],
Fix signature of clock_init for posix
#include <time.h> #include "clock.h" #include "clock_type.h" extern int clock_init(struct SPDR_Clock **clockp, struct SPDR_Allocator *allocator) { struct timespec res; if (clock_getres(CLOCK_MONOTONIC, &res) != 0 || res.tv_nsec > 1000) { /* unknown clock or insufficient resolution */ return -1; } return clock_init_base(clockp, allocator, 1, 1000); } extern uint64_t clock_ticks(struct SPDR_Clock const *const clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); (void)clock; return ts.tv_sec * 1000000000LL + ts.tv_nsec; }
#include <time.h> #include "clock.h" #include "clock_type.h" extern int clock_init(struct SPDR_Clock **clockp, struct SPDR_Allocator *allocator) { struct timespec res; if (clock_getres(CLOCK_MONOTONIC, &res) != 0 || res.tv_nsec > 1000) { /* unknown clock or insufficient resolution */ return -1; } return clock_init_base(clockp, allocator, 1, 1000); } extern uint64_t clock_ticks(struct SPDR_Clock const *const clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); (void)clock; return ts.tv_sec * 1000000000LL + ts.tv_nsec; }
Introduce XLAT_TYPE and XLAT_TYPE_PAIR macros
#ifndef STRACE_XLAT_H struct xlat { unsigned int val; const char *str; }; # define XLAT(val) { (unsigned)(val), #val } # define XLAT_PAIR(val, str) { (unsigned)(val), str } # define XLAT_END { 0, 0 } #endif
#ifndef STRACE_XLAT_H struct xlat { unsigned int val; const char *str; }; # define XLAT(val) { (unsigned)(val), #val } # define XLAT_PAIR(val, str) { (unsigned)(val), str } # define XLAT_TYPE(type, val) { (type)(val), #val } # define XLAT_TYPE_PAIR(val, str) { (type)(val), str } # define XLAT_END { 0, 0 } #endif
Change default values to -1.
/* * BDSup2Sub++ (C) 2012 Adam T. * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) * and Copyright 2012 Miklos Juhasz (mjuhasz) * * * 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 PALETTEINFO_H #define PALETTEINFO_H class PaletteInfo { public: PaletteInfo(); PaletteInfo(const PaletteInfo* other); PaletteInfo(const PaletteInfo& other); int paletteOffset() { return offset; } void setPaletteOffset(int paletteOffset) { offset = paletteOffset; } int paletteSize() { return size; } void setPaletteSize(int paletteSize) { size = paletteSize; } private: int offset = 0; int size = 0; }; #endif // PALETTEINFO_H
/* * BDSup2Sub++ (C) 2012 Adam T. * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) * and Copyright 2012 Miklos Juhasz (mjuhasz) * * * 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 PALETTEINFO_H #define PALETTEINFO_H class PaletteInfo { public: PaletteInfo(); PaletteInfo(const PaletteInfo* other); PaletteInfo(const PaletteInfo& other); int paletteOffset() { return offset; } void setPaletteOffset(int paletteOffset) { offset = paletteOffset; } int paletteSize() { return size; } void setPaletteSize(int paletteSize) { size = paletteSize; } private: int offset = -1; int size = -1; }; #endif // PALETTEINFO_H
Add the missing Token Space Guid
/** @file GUID for IntelFrameworkModulePkg PCD Token Space Copyright (c) 2009, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #ifndef _INTEL_FRAMEWOKR_MODULEPKG_TOKEN_SPACE_GUID_H_ #define _INTEL_FRAMEWOKR_MODULEPKG_TOKEN_SPACE_GUID_H_ #define INTEL_FRAMEWORK_MODULEPKG_TOKEN_SPACE_GUID \ { \ 0x914AEBE7, 0x4635, 0x459b, { 0xAA, 0x1C, 0x11, 0xE2, 0x19, 0xB0, 0x3A, 0x10 } \ } extern EFI_GUID gEfiIntelFrameworkModulePkgTokenSpaceGuid; #endif
Fix build break from bad merge
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Multiply-included file, hence no include guard. // Inclusion of all message files present in the system. Keep this file // up-to-date when adding a new value to enum IPCMessageStart in // ipc/ipc_message_utils.h to include the corresponding message file. #include "chrome/browser/importer/profile_import_process_messages.h" #include "chrome/common/automation_messages.h" #include "chrome/common/common_message_generator.h" #include "chrome/common/nacl_messages.h" #include "content/common/content_message_generator.h" #include "ppapi/proxy/ppapi_messages.h"
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Multiply-included file, hence no include guard. // Inclusion of all message files present in the system. Keep this file // up-to-date when adding a new value to enum IPCMessageStart in // ipc/ipc_message_utils.h to include the corresponding message file. #include "chrome/browser/importer/profile_import_process_messages.h" #include "chrome/common/common_message_generator.h" #include "chrome/common/nacl_messages.h" #include "content/common/content_message_generator.h" #include "content/common/pepper_messages.h" #include "ppapi/proxy/ppapi_messages.h"
Set size to zero on reset. Else getting the size is incorrect, and later when checking in get() it would pass the check and you'd access a NULL ptr.
/* * Copyright (C) 2013 Klaus Reimer (k@ailis.de) * See COPYING file for copying conditions */ #include "DeviceList.h" #include "Device.h" void setDeviceList(JNIEnv* env, libusb_device** list, int size, jobject object) { SET_POINTER(env, list, object, "deviceListPointer"); jclass cls = (*env)->GetObjectClass(env, object); jfieldID field = (*env)->GetFieldID(env, cls, "size", "I"); (*env)->SetIntField(env, object, field, size); } libusb_device** unwrapDeviceList(JNIEnv* env, jobject list) { UNWRAP_POINTER(env, list, libusb_device**, "deviceListPointer"); } void resetDeviceList(JNIEnv* env, jobject obj) { RESET_POINTER(env, obj, "deviceListPointer"); } /** * Device get(index) */ JNIEXPORT jobject JNICALL METHOD_NAME(DeviceList, get) ( JNIEnv *env, jobject this, jint index ) { jclass cls = (*env)->GetObjectClass(env, this); jfieldID field = (*env)->GetFieldID(env, cls, "size", "I"); int size = (*env)->GetIntField(env, this, field); if (index < 0 || index >= size) return NULL; return wrapDevice(env, unwrapDeviceList(env, this)[index]); }
/* * Copyright (C) 2013 Klaus Reimer (k@ailis.de) * See COPYING file for copying conditions */ #include "DeviceList.h" #include "Device.h" void setDeviceList(JNIEnv* env, libusb_device** list, int size, jobject object) { SET_POINTER(env, list, object, "deviceListPointer"); jclass cls = (*env)->GetObjectClass(env, object); jfieldID field = (*env)->GetFieldID(env, cls, "size", "I"); (*env)->SetIntField(env, object, field, size); } libusb_device** unwrapDeviceList(JNIEnv* env, jobject list) { UNWRAP_POINTER(env, list, libusb_device**, "deviceListPointer"); } void resetDeviceList(JNIEnv* env, jobject obj) { RESET_POINTER(env, obj, "deviceListPointer"); // Reset size to zero too. jclass cls = (*env)->GetObjectClass(env, obj); jfieldID field = (*env)->GetFieldID(env, cls, "size", "I"); (*env)->SetIntField(env, object, field, 0); } /** * Device get(index) */ JNIEXPORT jobject JNICALL METHOD_NAME(DeviceList, get) ( JNIEnv *env, jobject this, jint index ) { jclass cls = (*env)->GetObjectClass(env, this); jfieldID field = (*env)->GetFieldID(env, cls, "size", "I"); int size = (*env)->GetIntField(env, this, field); if (index < 0 || index >= size) return NULL; return wrapDevice(env, unwrapDeviceList(env, this)[index]); }
Make the extern for adv_mcode match the reality: it's u_int8_t, but probably unendiansafely used as u_int16_t.
/* * Exported interface to downloadable microcode for AdvanSys SCSI Adapters * * $FreeBSD$ * * Obtained from: * * Copyright (c) 1995-1999 Advanced System Products, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that redistributions of source * code retain the above copyright notice and this comment without * modification. */ extern u_int16_t adv_mcode[]; extern u_int16_t adv_mcode_size; extern u_int32_t adv_mcode_chksum;
/* * Exported interface to downloadable microcode for AdvanSys SCSI Adapters * * $FreeBSD$ * * Obtained from: * * Copyright (c) 1995-1999 Advanced System Products, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that redistributions of source * code retain the above copyright notice and this comment without * modification. */ extern u_int8_t adv_mcode[]; extern u_int16_t adv_mcode_size; extern u_int32_t adv_mcode_chksum;
Add regression test where TD3 aborting with self-dependency and fixed switch to Narrow is unsound
#include <pthread.h> int myglobal; void *t_fun(void *arg) { myglobal=1; // RACE! return NULL; } int main(void) { pthread_t id; pthread_create(&id, NULL, t_fun, NULL); myglobal = myglobal+1; // RACE! return 0; }
Add missing close for file descriptor
/* Exercise 5-2 */ #include <unistd.h> #include <fcntl.h> #include "tlpi_hdr.h" int main (int argc, char *argv[]) { if (argc != 2) { usageErr("%s filename", argv[0]); } int fd = open(argv[1], O_WRONLY | O_APPEND | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); if (fd == -1) { errExit("open"); } char s[] = "abcdefghi"; char t[] = "jklmnopqr"; if (write(fd, s, strlen(s)) != strlen(s)) { errExit("write 1"); } if (lseek(fd, 0, SEEK_SET) == -1) { errExit("seeking"); } if (write(fd, t, strlen(t)) != strlen(t)) { errExit("write 2"); } exit(EXIT_SUCCESS); }
/* Exercise 5-2 */ #include <unistd.h> #include <fcntl.h> #include "tlpi_hdr.h" int main (int argc, char *argv[]) { if (argc != 2) { usageErr("%s filename", argv[0]); } int fd = open(argv[1], O_WRONLY | O_APPEND | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); if (fd == -1) { errExit("open"); } char s[] = "abcdefghi"; char t[] = "jklmnopqr"; if (write(fd, s, strlen(s)) != strlen(s)) { errExit("write 1"); } if (lseek(fd, 0, SEEK_SET) == -1) { errExit("seeking"); } if (write(fd, t, strlen(t)) != strlen(t)) { errExit("write 2"); } if (close(fd) == -1) { errExit("close output"); } exit(EXIT_SUCCESS); }
Use GModule instead of libdl to load unit test symbols
#include <config.h> #include <dlfcn.h> #include <test-fixtures/test-unit.h> int main (int argc, char **argv) { const CoglUnitTest *unit_test; int i; if (argc != 2) { g_printerr ("usage %s UNIT_TEST\n", argv[0]); exit (1); } /* Just for convenience in case people try passing the wrapper * filenames for the UNIT_TEST argument we normalize '-' characters * to '_' characters... */ for (i = 0; argv[1][i]; i++) { if (argv[1][i] == '-') argv[1][i] = '_'; } unit_test = dlsym (RTLD_DEFAULT, argv[1]); if (!unit_test) { g_printerr ("Unknown test name \"%s\"\n", argv[1]); return 1; } test_utils_init (unit_test->requirement_flags, unit_test->known_failure_flags); unit_test->run (); test_utils_fini (); return 0; }
#include <config.h> #include <gmodule.h> #include <test-fixtures/test-unit.h> int main (int argc, char **argv) { GModule *main_module; const CoglUnitTest *unit_test; int i; if (argc != 2) { g_printerr ("usage %s UNIT_TEST\n", argv[0]); exit (1); } /* Just for convenience in case people try passing the wrapper * filenames for the UNIT_TEST argument we normalize '-' characters * to '_' characters... */ for (i = 0; argv[1][i]; i++) { if (argv[1][i] == '-') argv[1][i] = '_'; } main_module = g_module_open (NULL, /* use main module */ 0 /* flags */); if (!g_module_symbol (main_module, argv[1], (void **) &unit_test)) { g_printerr ("Unknown test name \"%s\"\n", argv[1]); return 1; } test_utils_init (unit_test->requirement_flags, unit_test->known_failure_flags); unit_test->run (); test_utils_fini (); return 0; }
Add missing header pragma directive
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Disable warnings emitted by protoc generated files #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-override" #include "feed.pb.h" #include "visiting.pb.h" #include "maintenance.pb.h" #pragma GCC diagnostic pop
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once // Disable warnings emitted by protoc generated files #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-override" #include "feed.pb.h" #include "visiting.pb.h" #include "maintenance.pb.h" #pragma GCC diagnostic pop
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_
Support to read and extract information from /proc/<pid>/maps
/* gp-proc.c -- Information extracted from /proc -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 _GP_PROC_H #define _GP_PROC_H #define MAP_R_OK 0x01 #define MAP_W_OK 0x02 #define MAP_X_OK 0x04 #define MAP_PRIV 0x08 typedef struct map_info { void* start; void* end; int flags; char* name; } map_info_t; typedef void (* gp_extract_map_callback) (map_info_t* map, void* data); /** * @brief Read the process /proc/<pid>/maps file. * * @param pid the process id. * @param callback the callback execute for each map entry. * @param data the callback data. */ extern void gp_read_proc_maps (int pid, gp_extract_map_callback callback, void *data); #endif
Convert bricks to a std::vector
/* The Breakout class holds all of the game logic. It is derived from the QWidget class to allow it to display in a Qt window. It handles all input events, game updates, and painting events. It also handles the current game state. */ #ifndef BREAKOUT_H #define BREAKOUT_H #include "ball.h" #include "brick.h" #include "paddle.h" #include <QWidget> #include <QKeyEvent> class Breakout : public QWidget { Q_OBJECT public: //Constructor and Destructor Breakout(QWidget *parent = 0); ~Breakout(); protected: //Events void paintEvent(QPaintEvent* event); void timerEvent(QTimerEvent* event); void keyPressEvent(QKeyEvent* event); //Functions dependent on the current game state void startGame(); void pauseGame(); void stopGame(); void victory(); //Function to check for collision of GameObjects void checkCollision(); private: //Variable to keep track of QTimerId int timerId; //The GameObjects Ball* ball; Paddle* paddle; Brick* bricks[30]; //The game states bool gameOver, gameWon, gameStarted, paused; }; #endif // BREAKOUT_H
/* The Breakout class holds all of the game logic. It is derived from the QWidget class to allow it to display in a Qt window. It handles all input events, game updates, and painting events. It also handles the current game state. */ #ifndef BREAKOUT_H #define BREAKOUT_H #include "ball.h" #include "brick.h" #include "paddle.h" #include <QWidget> #include <QKeyEvent> class Breakout : public QWidget { Q_OBJECT public: //Constructor and Destructor Breakout(QWidget *parent = 0); ~Breakout(); protected: //Events void paintEvent(QPaintEvent* event); void timerEvent(QTimerEvent* event); void keyPressEvent(QKeyEvent* event); //Functions dependent on the current game state void startGame(); void pauseGame(); void stopGame(); void victory(); //Function to check for collision of GameObjects void checkCollision(); private: //Variable to keep track of QTimerId int timerId; //The GameObjects Ball* ball; Paddle* paddle; std::vector<Brick*> bricks; //The game states bool gameOver, gameWon, gameStarted, paused; }; #endif // BREAKOUT_H
Add macro for DLL exportation
/*! * @brief Template C-header file * * This is a template C-header file * @author <+AUTHOR+> * @date <+DATE+> * @file <+FILE+> * @version 0.1 */ #ifndef <+FILE_CAPITAL+>_H #define <+FILE_CAPITAL+>_H #if defined(_MSC_VER) # define <+FILE_CAPITAL+>_DLLEXPORT __declspec(dllexport) #elif defined(__GNUC__) # define <+FILE_CAPITAL+>_DLLEXPORT __attribute__((dllexport)) #else # define DLLEXPORT #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ <+CURSOR+> #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* <+FILE_CAPITAL+>_H */
/*! * @brief Template C-header file * * This is a template C-header file * @author <+AUTHOR+> * @date <+DATE+> * @file <+FILE+> * @version 0.1 */ #ifndef <+FILE_CAPITAL+>_H #define <+FILE_CAPITAL+>_H #if defined(_MSC_VER) # define <+FILE_CAPITAL+>_DLLEXPORT __declspec(dllexport) #elif defined(__GNUC__) # define <+FILE_CAPITAL+>_DLLEXPORT __attribute__((dllexport)) #else # define <+FILE_CAPITAL+>_DLLEXPORT #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ <+CURSOR+> #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #undef <+FILE_CAPITAL+>_DLLEXPORT #endif /* <+FILE_CAPITAL+>_H */
Adjust SimpleJoinCount constructor argument type.
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/eval/eval/tensor_function.h> namespace vespalib::eval { /** * Tensor function that will count the number of cells in the result * of a join between two tensors with full mapped overlap consisting * of a single dimension. **/ class SimpleJoinCount : public tensor_function::Op2 { private: uint64_t _dense_factor; public: SimpleJoinCount(const TensorFunction &lhs_in, const TensorFunction &rhs_in, size_t dense_factor_in); InterpretedFunction::Instruction compile_self(const ValueBuilderFactory &factory, Stash &stash) const override; bool result_is_mutable() const override { return true; } uint64_t dense_factor() const { return _dense_factor; } static const TensorFunction &optimize(const TensorFunction &expr, Stash &stash); }; } // namespace
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/eval/eval/tensor_function.h> namespace vespalib::eval { /** * Tensor function that will count the number of cells in the result * of a join between two tensors with full mapped overlap consisting * of a single dimension. **/ class SimpleJoinCount : public tensor_function::Op2 { private: uint64_t _dense_factor; public: SimpleJoinCount(const TensorFunction &lhs_in, const TensorFunction &rhs_in, uint64_t dense_factor_in); InterpretedFunction::Instruction compile_self(const ValueBuilderFactory &factory, Stash &stash) const override; bool result_is_mutable() const override { return true; } uint64_t dense_factor() const { return _dense_factor; } static const TensorFunction &optimize(const TensorFunction &expr, Stash &stash); }; } // namespace
Add flag to stage api change am: f83df73740
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT #define SK_SUPPORT_LEGACY_MATRIX_IMAGEFILTER // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
Add setup code for initial centroids
// // main.c // k-means // // Created by Jamie Bullock on 24/08/2014. // Copyright (c) 2014 Jamie Bullock. All rights reserved. // #include "km.h" #include <stdio.h> int main(int argc, const char * argv[]) { km_textfile textfile = km_textfile_new(); RETURN_ON_ERROR(km_textfile_init(textfile)); RETURN_ON_ERROR(km_textfile_read(textfile, "input-2.csv")); km_pointlist pointlist = km_pointlist_new(km_textfile_num_lines(textfile)); RETURN_ON_ERROR(km_pointlist_fill(pointlist, textfile)); km_pointlist_delete(pointlist); km_textfile_delete(textfile); return 0; }
// // main.c // k-means // // Created by Jamie Bullock on 24/08/2014. // Copyright (c) 2014 Jamie Bullock. All rights reserved. // #include "km.h" #include <stdio.h> enum cluster_id { Adam, Bob, Charley, David, Edward, km_num_cluster_ids_ }; void set_initial_cluster_centroids(km_pointlist pointlist) { km_pointlist_update(pointlist, 0, Adam, -0.357, -0.253); km_pointlist_update(pointlist, 1, Bob, -0.055, 4.392); km_pointlist_update(pointlist, 2, Charley, 2.674, -0.001); km_pointlist_update(pointlist, 3, David, 1.044, -1.251); km_pointlist_update(pointlist, 3, Edward, -1.495, -0.090); } int main(int argc, const char * argv[]) { km_textfile textfile = km_textfile_new(); RETURN_ON_ERROR(km_textfile_init(textfile)); RETURN_ON_ERROR(km_textfile_read(textfile, "input-2.csv")); km_pointlist pointlist = km_pointlist_new(km_textfile_num_lines(textfile)); km_pointlist centroids = km_pointlist_new(km_num_cluster_ids_); RETURN_ON_ERROR(km_pointlist_fill(pointlist, textfile)); set_initial_cluster_centroids(centroids); km_pointlist_delete(pointlist); km_textfile_delete(textfile); return 0; }
Multiply now member of class - link errors when included in multiple cpp files
/* Copyright 2011 Michael Fortin 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 MATRIX2D #define MATRIX2D #include "Coord2D.h" #include "Angle.h" //! Basic 2D matrix class Matrix2D { public: //! First row Coord2D row1; //! Second row Coord2D row2; //! Initialize as rotation matrix Matrix2D(const Angle &in_angle) : row1(cosf(in_angle.radians()), -sinf(in_angle.radians())) , row2(sinf(in_angle.radians()), cosf(in_angle.radians())) {} }; //! Basic multiplication Coord2D operator*(const Matrix2D &in_mat, const Coord2D &in_c2d) { return Coord2D(dot(in_mat.row1, in_c2d), dot(in_mat.row2, in_c2d)); } #endif
/* Copyright 2011 Michael Fortin 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 MATRIX2D #define MATRIX2D #include "Coord2D.h" #include "Angle.h" //! Basic 2D matrix class Matrix2D { public: //! First row Coord2D row1; //! Second row Coord2D row2; //! Initialize as rotation matrix Matrix2D(const Angle &in_angle) : row1(cosf(in_angle.radians()), -sinf(in_angle.radians())) , row2(sinf(in_angle.radians()), cosf(in_angle.radians())) {} //! Basic multiplication Coord2D operator*(const Coord2D &in_c2d) const { return Coord2D(dot(row1, in_c2d), dot(row2, in_c2d)); } }; #endif
Add forgotted notification observer header.
// 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_COMMON_NOTIFICATION_OBSERVER_H_ #define CHROME_COMMON_NOTIFICATION_OBSERVER_H_ class NotificationDetails; class NotificationSource; class NotificationType; // This is the base class for notification observers. When a matching // notification is posted to the notification service, Observe is called. class NotificationObserver { public: virtual ~NotificationObserver(); virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) = 0; }; #endif // CHROME_COMMON_NOTIFICATION_OBSERVER_H_
Fix build on OS X.
#ifndef __TIME_MACH_H__ #define __TIME_MACH_H__ #include "config.h" // macros, bool, uint[XX]_t #include <mach/clock.h> // clock_serv_t, mach_timespec_t, etc. #include <mach/mach.h> // mach_port_deallocate static inline uint64_t get_time(void) { static float adj_const = 0.0F; // Cache the value (it doesn't change) if(adj_const == 0.0F) { mach_timebase_info_data_t ti; mach_timebase_info(&ti); adj_const = ti.numer / ti.denom; } return (uint64_t)mach_absolute_time() * adj_const; } #endif /*__TIME_MACH_H__*/
#ifndef __TIME_MACH_H__ #define __TIME_MACH_H__ #include "config.h" // macros, bool, uint[XX]_t #include <mach/clock.h> // clock_serv_t, mach_timespec_t, etc. #include <mach/mach.h> // mach_port_deallocate #include <mach/mach_time.h> static inline uint64_t get_time(void) { static float adj_const = 0.0F; // Cache the value (it doesn't change) if(adj_const == 0.0F) { mach_timebase_info_data_t ti; mach_timebase_info(&ti); adj_const = ti.numer / ti.denom; } return (uint64_t)mach_absolute_time() * adj_const; } #endif /*__TIME_MACH_H__*/
Fix crash due to uninitialised pointer when displaying a dialog
#pragma once #include <nanogui/screen.h> #include <nanogui/window.h> #include <nanogui/theme.h> class EditorGUI; class Structure; class DialogWindow : public nanogui::Window { public: DialogWindow(EditorGUI *screen, nanogui::Theme *theme); nanogui::Window *getWindow() { return this; } Structure *structure() { return current_structure; } void setStructure( Structure *s); void loadStructure( Structure *s); void clear(); private: EditorGUI *gui; Structure *current_structure; };
#pragma once #include <nanogui/screen.h> #include <nanogui/window.h> #include <nanogui/theme.h> class EditorGUI; class Structure; class DialogWindow : public nanogui::Window { public: DialogWindow(EditorGUI *screen, nanogui::Theme *theme); nanogui::Window *getWindow() { return this; } Structure *structure() { return current_structure; } void setStructure( Structure *s); void loadStructure( Structure *s); void clear(); private: EditorGUI *gui = nullptr; Structure *current_structure = nullptr; };
Solve build error in presubmit
// Copyright (c) 2020 The Orbit 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 ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_ #define ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_ #include <string> #include <vector> class CaptureClientGgpClient { public: CaptureClientGgpClient(std::string grpc_server_address); ~CaptureClientGgpClient(); CaptureClientGgpClient(CaptureClientGgpClient&&); CaptureClientGgpClient& operator=(CaptureClientGgpClient&&); int StartCapture(); int StopAndSaveCapture(); int UpdateSelectedFunctions(std::vector<std::string> capture_functions); void ShutdownService(); private: class CaptureClientGgpClientImpl; std::unique_ptr<CaptureClientGgpClientImpl> pimpl; }; #endif // ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_
// Copyright (c) 2020 The Orbit 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 ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_ #define ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_ #include <memory> #include <string> #include <vector> class CaptureClientGgpClient { public: CaptureClientGgpClient(std::string grpc_server_address); ~CaptureClientGgpClient(); CaptureClientGgpClient(CaptureClientGgpClient&&); CaptureClientGgpClient& operator=(CaptureClientGgpClient&&); int StartCapture(); int StopAndSaveCapture(); int UpdateSelectedFunctions(std::vector<std::string> capture_functions); void ShutdownService(); private: class CaptureClientGgpClientImpl; std::unique_ptr<CaptureClientGgpClientImpl> pimpl; }; #endif // ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_
Remove the static keyword from the _CLC_INLINE macro
#define _CLC_OVERLOAD __attribute__((overloadable)) #define _CLC_DECL #define _CLC_DEF __attribute__((always_inline)) #define _CLC_INLINE __attribute__((always_inline)) static inline
#define _CLC_OVERLOAD __attribute__((overloadable)) #define _CLC_DECL #define _CLC_DEF __attribute__((always_inline)) #define _CLC_INLINE __attribute__((always_inline)) inline
Use the inline exponential function.
#include <pal.h> /* * sinh z = (exp z - exp(-z)) / 2 */ static inline float _p_sinh(const float z) { float exp_z; p_exp_f32(&z, &exp_z, 1); return 0.5f * (exp_z - 1.f / exp_z); } /** * * Calculates the hyperbolic sine of the vector 'a'. Angles are specified * in radians. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @return None * */ void p_sinh_f32(const float *a, float *c, int n) { int i; for (i = 0; i < n; i++) { c[i] = _p_sinh(a[i]); } }
#include <pal.h> #include "p_exp.h" /* * sinh z = (exp z - exp(-z)) / 2 */ static inline float _p_sinh(const float z) { float exp_z = _p_exp(z); return 0.5f * (exp_z - 1.f / exp_z); } /** * * Calculates the hyperbolic sine of the vector 'a'. Angles are specified * in radians. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @return None * */ void p_sinh_f32(const float *a, float *c, int n) { int i; for (i = 0; i < n; i++) { c[i] = _p_sinh(a[i]); } }
Fix indentation by using tabs only
#include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <net/ethernet.h> #include <unistd.h> #include <arpa/inet.h> // The default size is enought to hold a whole ethernet frame (< 1524 bytes) #ifndef PACKET_BUFFER_SIZE #define PACKET_BUFFER_SIZE 2048 #endif static void print_packet(const unsigned char *pkt, size_t pktlen) { while (pktlen--) { printf("%02x", *pkt++); } putchar('\n'); } int main(int argc, char *argv[]) { unsigned char pktbuf[PACKET_BUFFER_SIZE]; int sockfd, res = 0; sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (-1 == sockfd) { perror("socket"); goto error; } while (1) { ssize_t pktlen = read(sockfd, pktbuf, sizeof(pktbuf)); if (pktlen < 0) { perror("read"); continue; } if (pktlen > 0) { print_packet(pktbuf, pktlen); } } close(sockfd); out: return res; error: res = 1; goto out; }
#include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <net/ethernet.h> #include <unistd.h> #include <arpa/inet.h> // The default size is enought to hold a whole ethernet frame (< 1524 bytes) #ifndef PACKET_BUFFER_SIZE #define PACKET_BUFFER_SIZE 2048 #endif static void print_packet(const unsigned char *pkt, size_t pktlen) { while (pktlen--) { printf("%02x", *pkt++); } putchar('\n'); } int main(int argc, char *argv[]) { unsigned char pktbuf[PACKET_BUFFER_SIZE]; int sockfd, res = 0; sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (-1 == sockfd) { perror("socket"); goto error; } while (1) { ssize_t pktlen = read(sockfd, pktbuf, sizeof(pktbuf)); if (pktlen < 0) { perror("read"); continue; } if (pktlen > 0) { print_packet(pktbuf, pktlen); } } close(sockfd); out: return res; error: res = 1; goto out; }
Put all pin information in a single header.
#ifndef Pins_h #define Pins_h /*Motor pins*/ int PWMA = 9; int AIN1 = 8; int AIN2 = 7; int PWMB = 10; int BIN1 = 4; int BIN2 = 5; int STDBY = 6; /*Encoder pins*/ int channelA = 3; //TX = 3 int channelB = 2; //RX = 2 /*Radio pins*/ int CE = A1; //pro micro int CS = A0; //pro micro //int CE = 3; //nano //int CS = 2; //nano #endif
Add modifying article link iterator typedef
#ifndef _ARTICLE_H #define _ARTICLE_H #include <string> #include <vector> /*! * represents a Wikipedia (Mediawiki) and its links */ class Article { public: typedef std::vector<Article*> ArticleLinkStorage; typedef std::vector<Article*>::const_iterator ArticleLinkIterator; /*! Create a new article from a title * \param title The title of the article */ Article(std::string title) : title(title) {}; //! Get the title of the article std::string getTitle() const { return title; } //! get the number of links the article has size_t getNumLinks() const; /*! Add a link to another article * \param[in] article Pointer to the article this article links * to */ void addLink(Article* article) { links.push_back(article); } /*! Get const_iterator to first linked article */ ArticleLinkIterator linkBegin() const { return links.cbegin(); } /*! Get const_iterator to last linked article */ ArticleLinkIterator linkEnd() const { return links.cend(); } private: std::string title; ArticleLinkStorage links; }; #endif //_ARTICLE_H
#ifndef _ARTICLE_H #define _ARTICLE_H #include <string> #include <vector> /*! * represents a Wikipedia (Mediawiki) and its links */ class Article { public: //! representation of links to other articles typedef std::vector<Article*> ArticleLinkStorage; //! representation of iterator over links typedef std::vector<Article*>::iterator ArticleLinkIterator; //! representation of const iterator over links typedef std::vector<Article*>::const_iterator ArticleLinkConstIterator; /*! Create a new article from a title * \param title The title of the article */ Article(std::string title) : title(title) {}; //! Get the title of the article std::string getTitle() const { return title; } //! get the number of links the article has size_t getNumLinks() const; /*! Add a link to another article * \param[in] article Pointer to the article this article links * to */ void addLink(Article* article) { links.push_back(article); } /*! Get const_iterator to first linked article */ ArticleLinkConstIterator linkBegin() const { return links.cbegin(); } /*! Get const_iterator to last linked article */ ArticleLinkConstIterator linkEnd() const { return links.cend(); } private: std::string title; ArticleLinkStorage links; }; #endif //_ARTICLE_H
Add a newline to the end of our log messages
#include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <sys/time.h> void rsp_log(char* format, ...) { char without_ms[64]; char with_ms[64]; struct timeval tv; struct tm *tm; gettimeofday(&tv, NULL); if ((tm = localtime(&tv.tv_sec)) != NULL) { strftime(without_ms, sizeof(without_ms), "%Y-%m-%d %H:%M:%S.%%06u %z", tm); snprintf(with_ms, sizeof(with_ms), without_ms, tv.tv_usec); fprintf(stdout, "[%s] ", with_ms); } va_list argptr; va_start(argptr, format); vfprintf(stdout, format, argptr); va_end(argptr); fflush(stdout); } void rsp_log_error(char* message) { char* error = strerror(errno); char* full_message = malloc(strlen(message) + 3 + strlen(error)); sprintf(full_message, "%s: %s", message, error); rsp_log(full_message); free(full_message); }
#include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <sys/time.h> void rsp_log(char* format, ...) { char without_ms[64]; char with_ms[64]; struct timeval tv; struct tm *tm; gettimeofday(&tv, NULL); if ((tm = localtime(&tv.tv_sec)) != NULL) { strftime(without_ms, sizeof(without_ms), "%Y-%m-%d %H:%M:%S.%%06u %z", tm); snprintf(with_ms, sizeof(with_ms), without_ms, tv.tv_usec); fprintf(stdout, "[%s] ", with_ms); } va_list argptr; va_start(argptr, format); vfprintf(stdout, format, argptr); va_end(argptr); fprintf(stdout, "\n"); fflush(stdout); } void rsp_log_error(char* message) { char* error = strerror(errno); char* full_message = malloc(strlen(message) + 3 + strlen(error)); sprintf(full_message, "%s: %s", message, error); rsp_log(full_message); free(full_message); }
Remove the need for a header and specify a triple so that the type sizes make sense.
// RUN: %clang -S -emit-llvm %s -o /dev/null // XFAIL: mingw,win32 #include <setjmp.h> sigjmp_buf B; int foo() { sigsetjmp(B, 1); bar(); }
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o /dev/null #define _JBLEN ((9 * 2) + 3 + 16) typedef int sigjmp_buf[_JBLEN + 1]; int sigsetjmp(sigjmp_buf env, int savemask); sigjmp_buf B; int foo() { sigsetjmp(B, 1); bar(); }
Add example of suppressing clang -Wcast-align
#include <stdio.h> #include <stdlib.h> struct dummy { double d; }; int main(int argc, char *argv[]) { struct dummy *d; char *p; (void) argc; (void) argv; /* This causes a warning with clang -Wcast-align: * * clang_cast_align.c:13:6: warning: cast from 'char *' to 'struct dummy *' increases required alignment * from 1 to 8 [-Wcast-align] * d = (struct dummy *) p; * * Note that malloc() alignment guarantees are enough to make the * warning harmless, so it'd be nice to suppress. */ p = (char *) malloc(sizeof(struct dummy)); d = (struct dummy *) p; /* Casting through a void pointer suppressed the warning for clang. */ p = (char *) malloc(sizeof(struct dummy)); d = (struct dummy *) (void *) p; return 0; }
Read file passed as argv[1]
int main() { return 0; }
#include <fcntl.h> #include <stdio.h> #include <unistd.h> const char usage[] = "Usage: %s <filenname>\n"; #define READ_SIZE 2048 int main(int argc, char *argv[]) { if (argc != 2) { printf(usage, argv[0]); return 1; } //FILE *file = fopen(argv[1], "r"); int fd = open(argv[1], O_RDONLY); char buf[READ_SIZE]; ssize_t bytes; do { bytes = read(fd, buf, READ_SIZE); if (bytes == -1) { perror("error reading file"); return 1; } write(STDOUT_FILENO, buf, bytes); } while (bytes == READ_SIZE); return 0; }
Declare panic function as noreturn
#ifndef KERN_DIAG #define KERN_DIAG #include <stdarg.h> void panic(const char* diagnostic_message, ...); void shutdown() __attribute__((noreturn)); extern void hang_machine() __attribute__((noreturn)); #ifdef DEBUG #define assert(x) if (!(x)) panic("Assertion failed: " __FILE__ ":%u: " #x, __LINE__) #else #define assert(x) (void) 0 #endif #endif /* KERN_DIAG */
#ifndef KERN_DIAG #define KERN_DIAG #include <stdarg.h> void panic(const char* diagnostic_message, ...) __attribute__((noreturn)); void shutdown() __attribute__((noreturn)); extern void hang_machine() __attribute__((noreturn)); #ifdef DEBUG #define assert(x) if (!(x)) panic("Assertion failed: " __FILE__ ":%u: " #x, __LINE__) #else #define assert(x) (void) 0 #endif #endif /* KERN_DIAG */
Fix "Out of memory? mmap failed" for files larger than 4GB on Windows
#include "../git-compat-util.h" void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) { HANDLE hmap; void *temp; size_t len; struct stat st; uint64_t o = offset; uint32_t l = o & 0xFFFFFFFF; uint32_t h = (o >> 32) & 0xFFFFFFFF; if (!fstat(fd, &st)) len = xsize_t(st.st_size); else die("mmap: could not determine filesize"); if ((length + offset) > len) length = len - offset; if (!(flags & MAP_PRIVATE)) die("Invalid usage of mmap when built with USE_WIN32_MMAP"); hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), 0, PAGE_WRITECOPY, 0, 0, 0); if (!hmap) return MAP_FAILED; temp = MapViewOfFileEx(hmap, FILE_MAP_COPY, h, l, length, start); if (!CloseHandle(hmap)) warning("unable to close file mapping handle\n"); return temp ? temp : MAP_FAILED; } int git_munmap(void *start, size_t length) { return !UnmapViewOfFile(start); }
#include "../git-compat-util.h" void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) { HANDLE hmap; void *temp; off_t len; struct stat st; uint64_t o = offset; uint32_t l = o & 0xFFFFFFFF; uint32_t h = (o >> 32) & 0xFFFFFFFF; if (!fstat(fd, &st)) len = st.st_size; else die("mmap: could not determine filesize"); if ((length + offset) > len) length = xsize_t(len - offset); if (!(flags & MAP_PRIVATE)) die("Invalid usage of mmap when built with USE_WIN32_MMAP"); hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), 0, PAGE_WRITECOPY, 0, 0, 0); if (!hmap) return MAP_FAILED; temp = MapViewOfFileEx(hmap, FILE_MAP_COPY, h, l, length, start); if (!CloseHandle(hmap)) warning("unable to close file mapping handle\n"); return temp ? temp : MAP_FAILED; } int git_munmap(void *start, size_t length) { return !UnmapViewOfFile(start); }
Check that the first and third characters, s and u, are accessed with an alignment of 2 not 1.
// RUN: %llvmgcc -S %s -o - | grep "align 2" | count 6 struct A { char s, t, u, v; short a; }; void q() { struct A a, b; a = b; }
Remove unused header, switch header to fwd decl
/****************************************************************/ /* DO NOT MODIFY THIS HEADER */ /* MOOSE - Multiphysics Object Oriented Simulation Environment */ /* */ /* (c) 2010 Battelle Energy Alliance, LLC */ /* ALL RIGHTS RESERVED */ /* */ /* Prepared by Battelle Energy Alliance, LLC */ /* Under Contract No. DE-AC07-05ID14517 */ /* With the U. S. Department of Energy */ /* */ /* See COPYRIGHT for full restrictions */ /****************************************************************/ #ifndef MESHCHANGEDINTERFACE_H #define MESHCHANGEDINTERFACE_H #include "InputParameters.h" #include "ExecStore.h" #include "MooseEnum.h" // Forward declarations class MeshChangedInterface; template <> InputParameters validParams<MeshChangedInterface>(); /** * Interface for notifications that the mesh has changed. */ class MeshChangedInterface { public: MeshChangedInterface(const InputParameters & params); virtual ~MeshChangedInterface() = default; /** * Called on this object when the mesh changes */ virtual void meshChanged() {} protected: /// Reference to FEProblemBase instance FEProblemBase & _mci_feproblem; }; #endif /* MESHCHANGEDINTERFACE_H */
/****************************************************************/ /* DO NOT MODIFY THIS HEADER */ /* MOOSE - Multiphysics Object Oriented Simulation Environment */ /* */ /* (c) 2010 Battelle Energy Alliance, LLC */ /* ALL RIGHTS RESERVED */ /* */ /* Prepared by Battelle Energy Alliance, LLC */ /* Under Contract No. DE-AC07-05ID14517 */ /* With the U. S. Department of Energy */ /* */ /* See COPYRIGHT for full restrictions */ /****************************************************************/ #ifndef MESHCHANGEDINTERFACE_H #define MESHCHANGEDINTERFACE_H #include "MooseEnum.h" // Forward declarations class FEProblemBase; class InputParameters; class MeshChangedInterface; template <typename T> InputParameters validParams(); template <> InputParameters validParams<MeshChangedInterface>(); /** * Interface for notifications that the mesh has changed. */ class MeshChangedInterface { public: MeshChangedInterface(const InputParameters & params); virtual ~MeshChangedInterface() = default; /** * Called on this object when the mesh changes */ virtual void meshChanged() {} protected: /// Reference to FEProblemBase instance FEProblemBase & _mci_feproblem; }; #endif /* MESHCHANGEDINTERFACE_H */
Add dedicated macros to indicate hot and cold execution paths.
/* * Copyright 2014, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) */ #ifndef _UTILS_ASSUME_H #define _UTILS_ASSUME_H #include <utils/builtin.h> /* This idiom is a way of passing extra information or hints to GCC. It is only * occasionally successful, so don't think of it as a silver optimisation * bullet. */ #define ASSUME(x) \ do { \ if (!(x)) { \ __builtin_unreachable(); \ } \ } while (0) #endif
/* * Copyright 2014, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) */ #ifndef _UTILS_ASSUME_H #define _UTILS_ASSUME_H #include <utils/attribute.h> #include <utils/builtin.h> #include <utils/stringify.h> /* This idiom is a way of passing extra information or hints to GCC. It is only * occasionally successful, so don't think of it as a silver optimisation * bullet. */ #define ASSUME(x) \ do { \ if (!(x)) { \ __builtin_unreachable(); \ } \ } while (0) /* Indicate to the compiler that wherever this macro appears is a cold * execution path. That is, it is not performance critical and likely rarely * used. A perfect example is error handling code. This gives the compiler a * light hint to deprioritise optimisation of this path. */ #define COLD_PATH() \ do { \ JOIN(cold_path_, __COUNTER__): COLD UNUSED; \ } while (0) /* The opposite of `COLD_PATH`. That is, aggressively optimise this path, * potentially at the expense of others. */ #define HOT_PATH() \ do { \ JOIN(hot_path_, __COUNTER__): HOT UNUSED; \ } while (0) #endif
Allow LIBCXXABI_SINGLE_THREADED to be defined by build scripts
//===----------------------------- config.h -------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // // // Defines macros used within the libc++abi project. // //===----------------------------------------------------------------------===// #ifndef LIBCXXABI_CONFIG_H #define LIBCXXABI_CONFIG_H #include <unistd.h> #if defined(_POSIX_THREADS) && _POSIX_THREADS > 0 # define LIBCXXABI_SINGLE_THREADED 0 #else # define LIBCXXABI_SINGLE_THREADED 1 #endif // Set this in the CXXFLAGS when you need it, because otherwise we'd have to // #if !defined(__linux__) && !defined(__APPLE__) && ... // and so-on for *every* platform. #ifndef LIBCXXABI_BAREMETAL # define LIBCXXABI_BAREMETAL 0 #endif #endif // LIBCXXABI_CONFIG_H
//===----------------------------- config.h -------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // // // Defines macros used within the libc++abi project. // //===----------------------------------------------------------------------===// #ifndef LIBCXXABI_CONFIG_H #define LIBCXXABI_CONFIG_H #include <unistd.h> #if !defined(LIBCXXABI_SINGLE_THREADED) && \ defined(_POSIX_THREADS) && _POSIX_THREADS > 0 # define LIBCXXABI_SINGLE_THREADED 0 #else # define LIBCXXABI_SINGLE_THREADED 1 #endif // Set this in the CXXFLAGS when you need it, because otherwise we'd have to // #if !defined(__linux__) && !defined(__APPLE__) && ... // and so-on for *every* platform. #ifndef LIBCXXABI_BAREMETAL # define LIBCXXABI_BAREMETAL 0 #endif #endif // LIBCXXABI_CONFIG_H
Fix naming concern from previous commit. Buddy: Sam
// Copyright eeGeo Ltd (2012-2015), All Rights Reserved #pragma once #include "IInteriorStreamingDialogView.h" #include "InteriorsExplorerViewIncludes.h" #include "AndroidNativeState.h" namespace ExampleApp { namespace InteriorsExplorer { namespace View { class InteriorStreamingDialogView : public IInteriorStreamingDialogView { public: AndroidNativeState& m_nativeState; jclass m_uiViewClass; jobject m_uiView; InteriorStreamingDialogView(AndroidNativeState& nativeState); ~InteriorStreamingDialogView(); void Show(); void Hide(bool interiorLoaded); }; } } }
// Copyright eeGeo Ltd (2012-2015), All Rights Reserved #pragma once #include "IInteriorStreamingDialogView.h" #include "InteriorsExplorerViewIncludes.h" #include "AndroidNativeState.h" namespace ExampleApp { namespace InteriorsExplorer { namespace View { class InteriorStreamingDialogView : public IInteriorStreamingDialogView { public: InteriorStreamingDialogView(AndroidNativeState& nativeState); ~InteriorStreamingDialogView(); void Show(); void Hide(bool interiorLoaded); private: AndroidNativeState& m_nativeState; jclass m_uiViewClass; jobject m_uiView; }; } } }
Support variant 'normal' and don't expect xboard to send colors
#ifndef _CECP_FEATURES_H #define _CECP_FEATURES_H #include <stdio.h> /* Features of the Chess Engine Communication Protocol supported by this program */ const char *cecp_features[] = { "done=0", "usermove=1", "time=0", "draw=0", "sigint=0", "analyze=0", "variants=\"\"", "name=0", "nps=0", "debug=1", "smp=1", "done=1", 0 }; #endif
#ifndef _CECP_FEATURES_H #define _CECP_FEATURES_H #include <stdio.h> /* Features of the Chess Engine Communication Protocol supported by this program */ const char *cecp_features[] = { "done=0", "usermove=1", "time=0", "draw=0", "sigint=0", "analyze=0", "variants=\"normal\"", "colors=0", "name=0", "nps=0", "debug=1", "smp=1", "done=1", 0 }; #endif
Add missing definition for TESS_API
/////////////////////////////////////////////////////////////////////// // File: platform.h // Description: Place holder // // (C) Copyright 2006, Google Inc. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // /////////////////////////////////////////////////////////////////////// #ifndef TESSERACT_PLATFORM_H_ #define TESSERACT_PLATFORM_H_ #ifndef TESS_API # if defined(_WIN32) || defined(__CYGWIN__) # if defined(TESS_EXPORTS) # define TESS_API __declspec(dllexport) # elif defined(TESS_IMPORTS) # define TESS_API __declspec(dllimport) # else # define TESS_API # endif # else # if defined(TESS_EXPORTS) || defined(TESS_IMPORTS) # define TESS_API __attribute__((visibility("default"))) # endif # endif #endif #endif // TESSERACT_PLATFORM_H_
/////////////////////////////////////////////////////////////////////// // File: platform.h // Description: Place holder // // (C) Copyright 2006, Google Inc. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // /////////////////////////////////////////////////////////////////////// #ifndef TESSERACT_PLATFORM_H_ #define TESSERACT_PLATFORM_H_ #ifndef TESS_API # if defined(_WIN32) || defined(__CYGWIN__) # if defined(TESS_EXPORTS) # define TESS_API __declspec(dllexport) # elif defined(TESS_IMPORTS) # define TESS_API __declspec(dllimport) # else # define TESS_API # endif # else # if defined(TESS_EXPORTS) || defined(TESS_IMPORTS) # define TESS_API __attribute__((visibility("default"))) # else # define TESS_API # endif # endif #endif #endif // TESSERACT_PLATFORM_H_
Revert "[Hexagon] Test passes for hexagon target now that the backend correctly generates relocations."
// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/body1.c // RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/body2.c // RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge %t.2.ast %s // expected-no-diagnostics
// XFAIL: hexagon // RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/body1.c // RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/body2.c // RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge %t.2.ast %s // expected-no-diagnostics
Change the way _EXPORT macros look, app_list edition
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_APP_LIST_APP_LIST_EXPORT_H_ #define UI_APP_LIST_APP_LIST_EXPORT_H_ #pragma once // Defines APP_LIST_EXPORT so that functionality implemented by the app_list // module can be exported to consumers. #if defined(COMPONENT_BUILD) #if defined(WIN32) #if defined(APP_LIST_IMPLEMENTATION) #define APP_LIST_EXPORT __declspec(dllexport) #else #define APP_LIST_EXPORT __declspec(dllimport) #endif // defined(APP_LIST_IMPLEMENTATION) #else // defined(WIN32) #define APP_LIST_EXPORT __attribute__((visibility("default"))) #endif #else // defined(COMPONENT_BUILD) #define APP_LIST_EXPORT #endif #endif // UI_APP_LIST_APP_LIST_EXPORT_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_APP_LIST_APP_LIST_EXPORT_H_ #define UI_APP_LIST_APP_LIST_EXPORT_H_ #pragma once // Defines APP_LIST_EXPORT so that functionality implemented by the app_list // module can be exported to consumers. #if defined(COMPONENT_BUILD) #if defined(WIN32) #if defined(APP_LIST_IMPLEMENTATION) #define APP_LIST_EXPORT __declspec(dllexport) #else #define APP_LIST_EXPORT __declspec(dllimport) #endif // defined(APP_LIST_IMPLEMENTATION) #else // defined(WIN32) #if defined(APP_LIST_IMPLEMENTATION) #define APP_LIST_EXPORT __attribute__((visibility("default"))) #else #define APP_LIST_EXPORT #endif #endif #else // defined(COMPONENT_BUILD) #define APP_LIST_EXPORT #endif #endif // UI_APP_LIST_APP_LIST_EXPORT_H_
Add missing extern "C" declaration to header
#ifndef MYPAINTTESTSURFACE_H #define MYPAINTTESTSURFACE_H #include <mypaint-surface.h> typedef MyPaintSurface * (*MyPaintTestsSurfaceFactory)(gpointer user_data); int mypaint_test_surface_run(int argc, char **argv, MyPaintTestsSurfaceFactory surface_factory, gchar *title, gpointer user_data); #endif // MYPAINTTESTSURFACE_H
#ifndef MYPAINTTESTSURFACE_H #define MYPAINTTESTSURFACE_H #include <mypaint-surface.h> #include <mypaint-glib-compat.h> G_BEGIN_DECLS typedef MyPaintSurface * (*MyPaintTestsSurfaceFactory)(gpointer user_data); int mypaint_test_surface_run(int argc, char **argv, MyPaintTestsSurfaceFactory surface_factory, gchar *title, gpointer user_data); G_END_DECLS #endif // MYPAINTTESTSURFACE_H
Fix argument order in mp_exch
#include <tommath.h> #ifdef BN_MP_EXCH_C /* LibTomMath, multiple-precision integer library -- Tom St Denis * * LibTomMath is a library that provides multiple-precision * integer arithmetic as well as number theoretic functionality. * * The library was designed directly after the MPI library by * Michael Fromberger but has been written from scratch with * additional optimizations in place. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /* swap the elements of two integers, for cases where you can't simply swap the * mp_int pointers around */ void mp_exch MPA(mp_int * a, mp_int * b) { mp_int t; if(MANAGED(a) || MANAGED(b)) { mp_init_copy(MPST, &t, a); mp_copy(MPST, a, b); mp_copy(MPST, b, &t); mp_clear(&t); return; } t = *a; *a = *b; *b = t; } #endif /* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */ /* $Revision: 1.4 $ */ /* $Date: 2006/12/28 01:25:13 $ */
#include <tommath.h> #ifdef BN_MP_EXCH_C /* LibTomMath, multiple-precision integer library -- Tom St Denis * * LibTomMath is a library that provides multiple-precision * integer arithmetic as well as number theoretic functionality. * * The library was designed directly after the MPI library by * Michael Fromberger but has been written from scratch with * additional optimizations in place. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /* swap the elements of two integers, for cases where you can't simply swap the * mp_int pointers around */ void mp_exch MPA(mp_int * a, mp_int * b) { mp_int t; if(MANAGED(a) || MANAGED(b)) { mp_init(&t); // copy a to t mp_copy(MPST, a, &t); // copy b to a mp_copy(MPST, b, a); // copy t to b mp_copy(MPST, &t, b); mp_clear(&t); return; } t = *a; *a = *b; *b = t; } #endif /* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */ /* $Revision: 1.4 $ */ /* $Date: 2006/12/28 01:25:13 $ */
Change dump buttons and add hold button
void dc_dump() { if (vexRT[Btn7U]) dump_set(-127); else if (vexRT[Btn7D]) dump_set(127); else dump_set(0); }
void dc_dump() { if (vexRT[Btn6U]) dump_set(-127); else if (vexRT[Btn6D]) dump_set(127); else if (vexRT[Btn5U]) dump_set(-15); else dump_set(0); }
Put a lock around kalloc*
#include <stddef.h> #include <kernel/port/heap.h> #include <kernel/port/units.h> #include <kernel/port/stdio.h> #include <kernel/port/panic.h> /* round_up returns `n` rounded to the next value that is zero * modulo `align`. */ static uintptr_t round_up(uintptr_t n, uintptr_t align) { if (n % align) { return n + (align - (n % align)); } return n; } uintptr_t heap_next, heap_end; void heap_init(uintptr_t start, uintptr_t end) { heap_next = start; heap_end = end; } void *kalloc_align(uintptr_t size, uintptr_t alignment) { heap_next = round_up(heap_next, alignment); uintptr_t ret = heap_next; heap_next += size; if(heap_next > heap_end) { panic("Out of space!"); } return (void*)ret; } void *kalloc(uintptr_t size) { return kalloc_align(size, sizeof(uintptr_t)); } void kfree(void *ptr, uintptr_t size) { }
#include <stddef.h> #include <kernel/port/heap.h> #include <kernel/port/units.h> #include <kernel/port/stdio.h> #include <kernel/port/panic.h> #include <kernel/arch/lock.h> static mutex_t heap_lock; /* round_up returns `n` rounded to the next value that is zero * modulo `align`. */ static uintptr_t round_up(uintptr_t n, uintptr_t align) { if (n % align) { return n + (align - (n % align)); } return n; } uintptr_t heap_next, heap_end; void heap_init(uintptr_t start, uintptr_t end) { heap_next = start; heap_end = end; } void *kalloc_align(uintptr_t size, uintptr_t alignment) { wait_acquire(&heap_lock); heap_next = round_up(heap_next, alignment); uintptr_t ret = heap_next; heap_next += size; if(heap_next > heap_end) { panic("Out of space!"); } release(&heap_lock); return (void*)ret; } void *kalloc(uintptr_t size) { return kalloc_align(size, sizeof(uintptr_t)); } void kfree(void *ptr, uintptr_t size) { }
Fix header defines based on ARC version
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \ (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8)) #define PT_DISPATCH_RETAIN_RELEASE 1 #endif #if !defined(PT_DISPATCH_RETAIN_RELEASE) #define PT_PRECISE_LIFETIME #define PT_PRECISE_LIFETIME_UNUSED #else #define PT_PRECISE_LIFETIME __attribute__((objc_precise_lifetime)) #define PT_PRECISE_LIFETIME_UNUSED __attribute__((objc_precise_lifetime, unused)) #endif
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \ (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8)) #define PT_DISPATCH_RETAIN_RELEASE 1 #endif #if (!defined(PT_DISPATCH_RETAIN_RELEASE)) #define PT_PRECISE_LIFETIME __attribute__((objc_precise_lifetime)) #define PT_PRECISE_LIFETIME_UNUSED __attribute__((objc_precise_lifetime, unused)) #else #define PT_PRECISE_LIFETIME #define PT_PRECISE_LIFETIME_UNUSED #endif
Add bitmap test case which reveals a bug
/** * @file * * @date Oct 21, 2013 * @author Eldar Abusalimov */ #include <embox/test.h> #include <util/bitmap.h> EMBOX_TEST_SUITE("util/bitmap test"); #define TEST_BITMAP_SZ 100 TEST_CASE() { BITMAP_DECL(bitmap, TEST_BITMAP_SZ); bitmap_clear_all(bitmap, TEST_BITMAP_SZ); test_assert_equal(bitmap_find_first_set_bit(bitmap, TEST_BITMAP_SZ), TEST_BITMAP_SZ /* not found */ ); for (int i = TEST_BITMAP_SZ-1; i >= 0; --i) { bitmap_set_bit(bitmap, i); test_assert_not_zero(bitmap_test_bit(bitmap, i)); test_assert_equal(bitmap_find_first_set_bit(bitmap, TEST_BITMAP_SZ), i); } }
/** * @file * * @date Oct 21, 2013 * @author Eldar Abusalimov */ #include <embox/test.h> #include <string.h> #include <util/bitmap.h> EMBOX_TEST_SUITE("util/bitmap test"); #define TEST_ALINGED_SZ 64 #define TEST_UNALINGED_SZ 100 TEST_CASE("aligned size with red zone after an array") { BITMAP_DECL(bitmap, TEST_ALINGED_SZ + 1); memset(bitmap, 0xAA, sizeof(bitmap)); bitmap_clear_all(bitmap, TEST_ALINGED_SZ); test_assert_equal(bitmap_find_first_bit(bitmap, TEST_ALINGED_SZ), TEST_ALINGED_SZ /* not found */ ); } TEST_CASE("unaligned size") { BITMAP_DECL(bitmap, TEST_UNALINGED_SZ); bitmap_clear_all(bitmap, TEST_UNALINGED_SZ); test_assert_equal(bitmap_find_first_bit(bitmap, TEST_UNALINGED_SZ), TEST_UNALINGED_SZ /* not found */ ); for (int i = TEST_UNALINGED_SZ-1; i >= 0; --i) { bitmap_set_bit(bitmap, i); test_assert_not_zero(bitmap_test_bit(bitmap, i)); test_assert_equal(bitmap_find_first_bit(bitmap, TEST_UNALINGED_SZ), i); } }
Make this test not rely on a backend being registered.
// REQUIRES: powerpc-registered-target // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -S -o - %s | FileCheck %s // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -fno-lax-vector-conversions -S -o - %s | FileCheck %s // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -x c++ -S -o - %s | FileCheck %s #include <altivec.h> // Verify that simply including <altivec.h> does not generate any code // (i.e. all inline routines in the header are marked "static") // CHECK: .text // CHECK-NEXT: .file // CHECK-NEXT: {{^$}} // CHECK-NEXT: .ident{{.*$}} // CHECK-NEXT: .section ".note.GNU-stack","",@progbits // CHECK-NOT: .
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -emit-llvm -fno-lax-vector-conversions -o - %s | FileCheck %s // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -emit-llvm -x c++ -o - %s | FileCheck %s #include <altivec.h> // Verify that simply including <altivec.h> does not generate any code // (i.e. all inline routines in the header are marked "static") // CHECK: target triple = "powerpc64- // CHECK-NEXT: {{^$}} // CHECK-NEXT: llvm.ident
Add throw() declaration to avoid dead code coverage
#ifndef BigFix_Error_h #define BigFix_Error_h #include <exception> #include <stddef.h> namespace BigFix { class Error : public std::exception { public: template <size_t n> explicit Error( const char ( &literal )[n] ) : m_what( literal ) { } virtual const char* what() const throw(); private: const char* m_what; }; } #endif
#ifndef BigFix_Error_h #define BigFix_Error_h #include <exception> #include <stddef.h> namespace BigFix { class Error : public std::exception { public: template <size_t n> explicit Error( const char ( &literal )[n] ) throw() : m_what( literal ) { } virtual const char* what() const throw(); private: const char* m_what; }; } #endif
Add RadioHead nRF24 node 'driver' skeleton
/* * This file is part of the KNOT Project * * Copyright (c) 2015, CESAR. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the CESAR nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL CESAR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <errno.h> #include <stdio.h> #include "node.h" static int nrf24_probe(void) { return -ENOSYS; } static void nrf24_remove(void) { } static int nrf24_listen(void) { return -ENOSYS; } static int nrf24_accept(int srv_sockfd) { return -ENOSYS; } static ssize_t nrf24_recv(int sockfd, void *buffer, size_t len) { return -ENOSYS; } static ssize_t nrf24_send(int sockfd, const void *buffer, size_t len) { return -ENOSYS; } static struct node_ops nrf24_ops = { .name = "Radio Head: nRF24", .probe = nrf24_probe, .remove = nrf24_remove, .listen = nrf24_listen, .accept = nrf24_accept, .recv = nrf24_recv, .send = nrf24_send }; /* * The following functions MAY be implemented as plugins * initialization functions, avoiding function calls such * as manager@manager_start()->node@node_init()-> * manager@node_ops_register()->node@node_probe() */ int node_init(void) { return node_ops_register(&nrf24_ops); } void node_exit(void) { }
Add random array and struct test code for SCA.
// RUN: clang -checker-simple -verify %s struct s {}; void f(void) { int a[10]; int (*p)[10]; p = &a; (*p)[3] = 1; struct s d; struct s *q; q = &d; }
// RUN: clang -checker-simple -verify %s struct s { int data; int data_array[10]; }; void f(void) { int a[10]; int (*p)[10]; p = &a; (*p)[3] = 1; struct s d; struct s *q; q = &d; q->data = 3; d.data_array[9] = 17; }
Add member variable for brightness controller
// Copyright (c) 2015, Matthew Malensek. // Distributed under the BSD 2-Clause License (see LICENSE.txt for details) #pragma once #include "OSD.h" class BrightnessOSD : public OSD { public: BrightnessOSD(); virtual void Hide(); virtual void ProcessHotkeys(HotkeyInfo &hki); private: MeterWnd _mWnd; virtual void OnDisplayChange(); virtual LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); };
// Copyright (c) 2015, Matthew Malensek. // Distributed under the BSD 2-Clause License (see LICENSE.txt for details) #pragma once #include "OSD.h" class BrightnessOSD : public OSD { public: BrightnessOSD(); virtual void Hide(); virtual void ProcessHotkeys(HotkeyInfo &hki); private: MeterWnd _mWnd; BrightnessController *_brightnessCtrl; virtual void OnDisplayChange(); virtual LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); };
Add vector add/sub/mul/div by scalar tests (PR27085)
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s // PR27085 typedef unsigned char uchar4 __attribute__ ((vector_size (4))); // CHECK: @add2 // CHECK: add <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2> uchar4 add2(uchar4 v) { return v + 2; } // CHECK: @sub2 // CHECK: sub <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2> uchar4 sub2(uchar4 v) { return v - 2; } // CHECK: @mul2 // CHECK: mul <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2> uchar4 mul2(uchar4 v) { return v * 2; } // CHECK: @div2 // CHECK: udiv <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2> uchar4 div2(uchar4 v) { return v / 2; } typedef __attribute__(( ext_vector_type(4) )) unsigned char uchar4_ext; // CHECK: @div3_ext // CHECK: udiv <4 x i8> %{{.*}}, <i8 3, i8 3, i8 3, i8 3> uchar4_ext div3_ext(uchar4_ext v) { return v / 3; }
Add missing @protocol forward declaration
// // GITRepo+Protected.h // CocoaGit // // Created by Geoffrey Garside on 05/08/2008. // Copyright 2008 ManicPanda.com. All rights reserved. // @interface GITRepo () - (NSString*)objectPathFromHash:(NSString*)hash; - (NSData*)dataWithContentsOfHash:(NSString*)hash; - (void)extractFromData:(NSData*)data type:(NSString**)theType size:(NSUInteger*)theSize andData:(NSData**)theData; #pragma mark - #pragma mark Object instanciation methods - (id <GITObject>)objectWithHash:(NSString*)hash; - (GITCommit*)commitWithHash:(NSString*)hash; - (GITTag*)tagWithHash:(NSString*)hash; - (GITTree*)treeWithHash:(NSString*)hash; - (GITBlob*)blobWithHash:(NSString*)hash; @end
// // GITRepo+Protected.h // CocoaGit // // Created by Geoffrey Garside on 05/08/2008. // Copyright 2008 ManicPanda.com. All rights reserved. // @protocol GITObject; @interface GITRepo () - (NSString*)objectPathFromHash:(NSString*)hash; - (NSData*)dataWithContentsOfHash:(NSString*)hash; - (void)extractFromData:(NSData*)data type:(NSString**)theType size:(NSUInteger*)theSize andData:(NSData**)theData; #pragma mark - #pragma mark Object instanciation methods - (id <GITObject>)objectWithHash:(NSString*)hash; - (GITCommit*)commitWithHash:(NSString*)hash; - (GITTag*)tagWithHash:(NSString*)hash; - (GITTree*)treeWithHash:(NSString*)hash; - (GITBlob*)blobWithHash:(NSString*)hash; @end
Improve and document CSV::Writer interface
#ifndef _CSVWRITER_H_ #define _CSVWRITER_H_ #include <string> #include <istream> #include <stdexcept> namespace CSV { class Writer { public: static const char CSV_SEP = '|'; Writer(std::ostream& output); Writer operator<< (const std::string& data); Writer next(); private: std::ostream& output; bool isFirstValue; std::string clean(const std::string&); }; } #endif
#ifndef _CSVWRITER_H_ #define _CSVWRITER_H_ #include <string> #include <istream> #include <stdexcept> namespace CSV { class Writer { public: static const char CSV_SEP = ','; /** * Construct a CSV::Writer that uses ',' as value separator. */ Writer(std::ostream& output); /** * Write the given value to the csv file */ Writer operator<< (const std::string& data); /** * Advance to the next line */ Writer next(); protected: /** * Clean up (escape) the given value to be used in this object. * Note: This is called internally in operator<<(const std::string&) */ std::string clean(const std::string& data); private: std::ostream& output; bool isFirstValue; }; } #endif
Add TODO to replace downloadTimeoutSeconds property with session config timeout.
/* Copyright 2018 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @import Foundation; /// PBManifest handles downloading and parsing a list of packages to fetch and install. @interface PBManifest : NSObject - (instancetype)init NS_UNAVAILABLE; /// Designated initializer. - (instancetype)initWithURL:(NSURL *)manifestURL NS_DESIGNATED_INITIALIZER; /// Download and parse the manifest. - (void)downloadManifest; /// Return list of packages in the manifest for the given track. - (NSArray *)packagesForTrack:(NSString *)track; /// The NSURLSession to use for downloading packages. If not set, a default one will be used. @property NSURLSession *session; /// The number of seconds to allow downloading before timing out. Defaults to 300 (5 minutes). @property NSUInteger downloadTimeoutSeconds; /// The number of download attempts before giving up. Defaults to 5. @property NSUInteger downloadAttemptsMax; @end
/* Copyright 2018 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @import Foundation; /// PBManifest handles downloading and parsing a list of packages to fetch and install. @interface PBManifest : NSObject - (instancetype)init NS_UNAVAILABLE; /// Designated initializer. - (instancetype)initWithURL:(NSURL *)manifestURL NS_DESIGNATED_INITIALIZER; /// Download and parse the manifest. - (void)downloadManifest; /// Return list of packages in the manifest for the given track. - (NSArray *)packagesForTrack:(NSString *)track; /// The NSURLSession to use for downloading packages. If not set, a default one will be used. @property NSURLSession *session; /// The number of seconds to allow downloading before timing out. Defaults to 300 (5 minutes). /// TODO(nguyenphillip): use session config's timeoutIntervalForResource to handle timeouts, and /// make session a required argument of initializer for both PBManifest and PBPackageInstaller. @property NSUInteger downloadTimeoutSeconds; /// The number of download attempts before giving up. Defaults to 5. @property NSUInteger downloadAttemptsMax; @end
Add own versions of _countof and ZeroMemory
#pragma once #ifdef _MSC_VER #define SL_CALL __vectorcall #else #define SL_CALL #endif
#pragma once #include <string> #if 0 int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; } int Strnicmp(const char* str1, const char* str2, int count) { int d = 0; while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } return d; } #endif #ifdef _MSC_VER #define SL_CALL __vectorcall #else #define SL_CALL #endif #define COUNT_OF(X) (sizeof(X) / sizeof((X)[0])) #define ZERO_MEM(X, Y) (memset(X, 0, Y));
Check static locals aren't duplicated when inlined
// RUN: %ocheck 0 %s // RUN: %check %s __attribute((always_inline)) inline void *f(unsigned size) { static char malloc_buf[16]; // CHECK: warning: mutable static variable in pure-inline function - may differ per file static void *ptr = malloc_buf; // CHECK: warning: mutable static variable in pure-inline function - may differ per file void *ret = ptr; ptr += size; return ret; } main() { char *a = f(2); char *b = f(1); if(a + 2 != b) abort(); return 0; }
ADD definition again to start without menu
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #include "GameState.h" #include "StartState.h" #include "LevelSelectState.h" #include <vector> //#define START_WITHOUT_MENU class GameStateHandler { private: std::vector<GameState*> m_stateStack; std::vector<GameState*> m_statesToRemove; public: GameStateHandler(); ~GameStateHandler(); int ShutDown(); int Initialize(ComponentHandler* cHandler, Camera* cameraRef, std::string levelPath = NULL); int Update(float dt, InputHandler* inputHandler); //Push a state to the stack int PushStateToStack(GameState* state); private: }; #endif
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H #include "GameState.h" #include "StartState.h" #include "LevelSelectState.h" #include <vector> #define START_WITHOUT_MENU class GameStateHandler { private: std::vector<GameState*> m_stateStack; std::vector<GameState*> m_statesToRemove; public: GameStateHandler(); ~GameStateHandler(); int ShutDown(); int Initialize(ComponentHandler* cHandler, Camera* cameraRef, std::string levelPath = NULL); int Update(float dt, InputHandler* inputHandler); //Push a state to the stack int PushStateToStack(GameState* state); private: }; #endif
Add useful Altivec types, taken from with permission from x264 authors
/* * Copyright (c) 2006 Guillaume Poirier <gpoirier@mplayerhq.hu> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /*********************************************************************** * Vector types **********************************************************************/ #define vec_u8_t vector unsigned char #define vec_s8_t vector signed char #define vec_u16_t vector unsigned short #define vec_s16_t vector signed short #define vec_u32_t vector unsigned int #define vec_s32_t vector signed int /*********************************************************************** * Null vector **********************************************************************/ #define LOAD_ZERO const vec_u8_t zerov = vec_splat_u8( 0 ) #define zero_u8v (vec_u8_t) zerov #define zero_s8v (vec_s8_t) zerov #define zero_u16v (vec_u16_t) zerov #define zero_s16v (vec_s16_t) zerov #define zero_u32v (vec_u32_t) zerov #define zero_s32v (vec_s32_t) zerov
Add bell curve random number generator
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2013 Raymond Jennings * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ float rnd() { /* use 30 bits of randomness */ return ldexp((float)random(1 << 30), -30); } float pi() { return atan(1.0) * 4.0; } int dice(int faces, int count) { int sum; while (count) { sum += random(faces) + 1; count--; } return sum; }
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2013 Raymond Jennings * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ float rnd() { /* use 30 bits of randomness */ return ldexp((float)random(1 << 30), -30); } float bell_rnd(int degree) { float sum; int i; for (i = 0; i < degree; i++) { sum += rnd(); } return sum / (float)degree; } float pi() { return atan(1.0) * 4.0; } int dice(int faces, int count) { int sum; while (count) { sum += random(faces) + 1; count--; } return sum; }
Add definitions for the GPIO memory port configurations
/* linux/arch/arm/plat-s3c64xx/include/mach/regs-gpio-memport.h * * Copyright 2008 Openmoko, Inc. * Copyright 2008 Simtec Electronics * Ben Dooks <ben@simtec.co.uk> * http://armlinux.simtec.co.uk/ * * S3C64XX - GPIO memory port register definitions */ #ifndef __ASM_PLAT_S3C64XX_REGS_GPIO_MEMPORT_H #define __ASM_PLAT_S3C64XX_REGS_GPIO_MEMPORT_H __FILE__ #define S3C64XX_MEM0CONSTOP S3C64XX_GPIOREG(0x1B0) #define S3C64XX_MEM1CONSTOP S3C64XX_GPIOREG(0x1B4) #define S3C64XX_MEM0CONSLP0 S3C64XX_GPIOREG(0x1C0) #define S3C64XX_MEM0CONSLP1 S3C64XX_GPIOREG(0x1C4) #define S3C64XX_MEM1CONSLP S3C64XX_GPIOREG(0x1C8) #define S3C64XX_MEM0DRVCON S3C64XX_GPIOREG(0x1D0) #define S3C64XX_MEM1DRVCON S3C64XX_GPIOREG(0x1D4) #endif /* __ASM_PLAT_S3C64XX_REGS_GPIO_MEMPORT_H */
Update files, Alura, Introdução a C - Parte 2, Aula 2.4
#include <stdio.h> int main() { char palavrasecreta[20]; sprintf(palavrasecreta, "MELANCIA"); int acertou = 0; int enforcou = 0; do { // comecar o nosso jogo!! } while(!acertou && !enforcou); }
#include <stdio.h> #include <string.h> int main() { char palavrasecreta[20]; sprintf(palavrasecreta, "MELANCIA"); int acertou = 0; int enforcou = 0; do { char chute; scanf("%c", &chute); for(int i = 0; i < strlen(palavrasecreta); i++) { if(palavrasecreta[i] == chute) { printf("A posição %d tem essa letra!\n", i); } } } while(!acertou && !enforcou); }
Fix warning: implicit declaration of function memset
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <signal.h> #include "daemon.h" void daemon_exit_handler(int sig) { //Here we release resources #ifdef DAEMON_PID_FILE_NAME unlink(DAEMON_PID_FILE_NAME); #endif _exit(EXIT_FAILURE); } void init_signals(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = daemon_exit_handler; if( sigaction(SIGTERM, &sa, NULL) != 0) daemon_error_exit("Can't set daemon_exit_handler: %m\n"); signal(SIGCHLD, SIG_IGN); // ignore child signal(SIGTSTP, SIG_IGN); // ignore tty signals signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); signal(SIGHUP, SIG_IGN); } int main(void) { daemonize(); init_signals(); while(1) { // Here а routine of daemon printf("%s: daemon is run\n", DAEMON_NAME); sleep(10); } return EXIT_SUCCESS; // good job (we interrupted (finished) main loop) }
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <signal.h> #include "daemon.h" void daemon_exit_handler(int sig) { //Here we release resources #ifdef DAEMON_PID_FILE_NAME unlink(DAEMON_PID_FILE_NAME); #endif _exit(EXIT_FAILURE); } void init_signals(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = daemon_exit_handler; if( sigaction(SIGTERM, &sa, NULL) != 0) daemon_error_exit("Can't set daemon_exit_handler: %m\n"); signal(SIGCHLD, SIG_IGN); // ignore child signal(SIGTSTP, SIG_IGN); // ignore tty signals signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); signal(SIGHUP, SIG_IGN); } int main(void) { daemonize(); init_signals(); while(1) { // Here а routine of daemon printf("%s: daemon is run\n", DAEMON_NAME); sleep(10); } return EXIT_SUCCESS; // good job (we interrupted (finished) main loop) }
Add a test file for matrix functions
#include <stdio.h> #include <stdlib.h> #include "matrix.h" int main() { matrix *a = new_matrix(3, 4); int i; for (i = 0; i < a->rows; i++) { int j; for (j = 0; j < a->cols; j++) { a->contents[i][j] = i * a->cols + j; } } print_matrix(a); printf("\n\n"); matrix *b = new_matrix(4, 5); for (i = 0; i < b->rows; i++) { int j; for (j = 0; j < b->cols; j++) { b->contents[i][j] = i * b->cols + j; } } print_matrix(b); printf("\n\n"); matrix *c = cross_product(a, b); print_matrix(c); printf("\n\n"); scalar_multiply(a, 3); print_matrix(a); free_matrix(a); free_matrix(b); free_matrix(c); return 0; }
Use explicit constructor for File to resolve template deductions
#ifndef CPR_MULTIPART_H #define CPR_MULTIPART_H #include <initializer_list> #include <string> #include <vector> #include "defines.h" namespace cpr { struct File { template <typename StringType> File(StringType&& filepath) : filepath{CPR_FWD(filepath)} {} std::string filepath; }; struct Part { Part(const std::string& name, const std::string& value, const std::string& content_type = {}) : name{name}, value{value}, content_type{content_type}, is_file{false} {} Part(const std::string& name, const int& value, const std::string& content_type = {}) : name{name}, value{std::to_string(value)}, content_type{content_type}, is_file{false} { } Part(const std::string& name, const File& file, const std::string& content_type = {}) : name{name}, value{file.filepath}, content_type{content_type}, is_file{true} {} std::string name; std::string value; std::string content_type; bool is_file; }; class Multipart { public: Multipart(const std::initializer_list<Part>& parts); std::vector<Part> parts; }; } // namespace cpr #endif
#ifndef CPR_MULTIPART_H #define CPR_MULTIPART_H #include <initializer_list> #include <string> #include <vector> #include "defines.h" namespace cpr { struct File { template <typename StringType> explicit File(StringType&& filepath) : filepath{CPR_FWD(filepath)} {} std::string filepath; }; struct Part { Part(const std::string& name, const std::string& value, const std::string& content_type = {}) : name{name}, value{value}, content_type{content_type}, is_file{false} {} Part(const std::string& name, const int& value, const std::string& content_type = {}) : name{name}, value{std::to_string(value)}, content_type{content_type}, is_file{false} { } Part(const std::string& name, const File& file, const std::string& content_type = {}) : name{name}, value{file.filepath}, content_type{content_type}, is_file{true} {} std::string name; std::string value; std::string content_type; bool is_file; }; class Multipart { public: Multipart(const std::initializer_list<Part>& parts); std::vector<Part> parts; }; } // namespace cpr #endif
Fix case of an include to support crossplatform compilation.
#include "telit_HE910.h" namespace openxc { namespace server_task { void openxc::server_task::firmwareCheck(TelitDevice* device); void openxc::server_task::flushDataBuffer(TelitDevice* device); void openxc::server_task::commandCheck(TelitDevice* device); } }
#include "telit_he910.h" namespace openxc { namespace server_task { void openxc::server_task::firmwareCheck(TelitDevice* device); void openxc::server_task::flushDataBuffer(TelitDevice* device); void openxc::server_task::commandCheck(TelitDevice* device); } }
Align free agents (team index 255) with the rest
#include <stdio.h> #include "player_key.h" bool_t key_is_goalie(player_key_t *key) { return key->position == 'G'; } void show_key_player(player_key_t *key, size_t ofs_key) { size_t i; printf("T: %2u NO: %2u POS: %c NAME: %-15s %-15s", key->team, key->jersey, key->position, key->first, key->last); printf(" OFS_KEY: %4x OFS_ATT: %4x OFS_CAR: %4x OFS_SEA: %4x", ofs_key, key->ofs_attributes, key->ofs_career_stats, key->ofs_season_stats); printf(" UNKNOWN: "); for (i = 0; i < sizeof(key->unknown); i++) { printf("%3u ", key->unknown[i]); } }
#include <stdio.h> #include "player_key.h" bool_t key_is_goalie(player_key_t *key) { return key->position == 'G'; } void show_key_player(player_key_t *key, size_t ofs_key) { size_t i; printf("T: %3u NO: %2u POS: %c NAME: %-15s %-15s", key->team, key->jersey, key->position, key->first, key->last); printf(" OFS_KEY: %4x OFS_ATT: %4x OFS_CAR: %4x OFS_SEA: %4x", ofs_key, key->ofs_attributes, key->ofs_career_stats, key->ofs_season_stats); printf(" UNKNOWN: "); for (i = 0; i < sizeof(key->unknown); i++) { printf("%3u ", key->unknown[i]); } }
Fix bug in timer comparison
/* Copyright (C) 2015 George White <stonehippo@gmail.com>, All rights reserved. See https://raw.githubusercontent.com/stonehippo/sploder/master/LICENSE.txt for license details. */ // ******************* Timing helpers ******************* void startTimer(long &timer) { timer = millis(); } boolean isTimerExpired(long &timer, int expiration) { long current = millis() - timer; return current > expiration; } void clearTimer(long &timer) { timer = 0; }
/* Copyright (C) 2015 George White <stonehippo@gmail.com>, All rights reserved. See https://raw.githubusercontent.com/stonehippo/sploder/master/LICENSE.txt for license details. */ // ******************* Timing helpers ******************* void startTimer(long &timer) { timer = millis(); } boolean isTimerExpired(long &timer, long expiration) { long current = millis() - timer; return current > expiration; } void clearTimer(long &timer) { timer = 0; }
Switch version numbers to 0.8.1.99
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 1 #define CLIENT_VERSION_BUILD 99 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE false // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
Add missing definition for include guard
#ifndef CCSPEC_H_ #include "ccspec/expectation_target.h" #include "ccspec/matcher.h" #include "ccspec/matchers.h" #endif // CCSPEC_H_
#ifndef CCSPEC_H_ #define CCSPEC_H_ #include "ccspec/expectation_target.h" #include "ccspec/matcher.h" #include "ccspec/matchers.h" #endif // CCSPEC_H_