Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Make a program that is incrementing a variable with number based on user input using the following data: If user inputs - increments with : 1 - 5 2 - 9 3 - 18 4 - 34 5 - 59 6 - 95
#include <stdio.h> #include <math.h> int main() { int userInput = 0; unsigned long number = 0; while(1) { printf("Please enter a number between 1 and 6:"); scanf("%d", &userInput); unsigned long incrementor = 0; switch(userInput) { case 1: incrementor += 5; break; case 2: incrementor += 9; break; case 3: incrementor += 18; break; case 4: incrementor += 34; break; case 5: incrementor += 59; break; case 6: incrementor += 95; break; default: printf("You have inputed incorrect number!\n"); } number += incrementor; printf("Current number : %d \n", number); } return 0; }
Remove duplicate content in file.
// Copyright (c) 2014 The Chromium Embedded Framework 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 CEF_LIBCEF_DLL_CEF_MACROS_H_ #define CEF_LIBCEF_DLL_CEF_MACROS_H_ #pragma once #ifdef BUILDING_CEF_SHARED #include "base/macros.h" #else // !BUILDING_CEF_SHARED // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) #endif // !BUILDING_CEF_SHARED #endif // CEF_LIBCEF_DLL_CEF_MACROS_H_ // Copyright (c) 2014 The Chromium Embedded Framework 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 CEF_LIBCEF_DLL_CEF_MACROS_H_ #define CEF_LIBCEF_DLL_CEF_MACROS_H_ #pragma once #ifdef BUILDING_CEF_SHARED #include "base/macros.h" #else // !BUILDING_CEF_SHARED // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) #endif // !BUILDING_CEF_SHARED #endif // CEF_LIBCEF_DLL_CEF_MACROS_H_
// Copyright (c) 2014 The Chromium Embedded Framework 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 CEF_LIBCEF_DLL_CEF_MACROS_H_ #define CEF_LIBCEF_DLL_CEF_MACROS_H_ #pragma once #ifdef BUILDING_CEF_SHARED #include "base/macros.h" #else // !BUILDING_CEF_SHARED // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) #endif // !BUILDING_CEF_SHARED #endif // CEF_LIBCEF_DLL_CEF_MACROS_H_
Add declaration and stubs for rotations
#include <stdlib.h> #include "avl.h" /* * * * forward declarations * * */ static void destroy_subtree( struct avl_el* node //!< A node to destroy ); /* * * * interface implementation * * */ struct avl* avl_alloc(void) { return calloc(1, sizeof(struct avl)); } int avl_destroy( struct avl* avl //!< The avl tree ) { if (avl && avl->root) { destroy_subtree(avl->root); } free(avl); return 1; } /* * * * implementation of internal functions * * */ static void destroy_subtree( struct avl_el* node //!< A node to destroy ) { if (node->l) { destroy_subtree(node->l); } if (node->r) { destroy_subtree(node->r); } free(node); }
#include <stdlib.h> #include "avl.h" /* * * * forward declarations * * */ static void destroy_subtree( struct avl_el* node //!< A node to destroy ); /** * Rotate a node counter-clockwise * * @return new root or NULL, if the rotation could not be performed */ static struct avl_el* rotate_left( struct avl_el* node //!< The node to rotate ); /** * Rotate a node clockwise * * @return new root or NULL, if the rotation could not be performed */ static struct avl_el* rotate_right( struct avl_el* node //!< The node to rotate ); /* * * * interface implementation * * */ struct avl* avl_alloc(void) { return calloc(1, sizeof(struct avl)); } int avl_destroy( struct avl* avl //!< The avl tree ) { if (avl && avl->root) { destroy_subtree(avl->root); } free(avl); return 1; } /* * * * implementation of internal functions * * */ static void destroy_subtree( struct avl_el* node //!< A node to destroy ) { if (node->l) { destroy_subtree(node->l); } if (node->r) { destroy_subtree(node->r); } free(node); } static struct avl_el* rotate_left( struct avl_el* node ) { return 0; } static struct avl_el* rotate_right( struct avl_el* node ) { return 0; }
Fix compile error on chrome bots
/* * Copyright 2021 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef GrSlug_DEFINED #define GrSlug_DEFINED #include "include/private/chromium/Slug.h" // TODO: Update Chrome to use sktext::gpu classes and remove these using GrTextReferenceFrame = sktext::gpu::TextReferenceFrame; using GrSlug = sktext::gpu::Slug; #endif // GrSlug_DEFINED
/* * Copyright 2021 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef GrSlug_DEFINED #define GrSlug_DEFINED #include "include/private/chromium/Slug.h" // TODO: Update Chrome to use sktext::gpu classes and remove these using GrSlug = sktext::gpu::Slug; #endif // GrSlug_DEFINED
Exclude Clang on Windows too. Comment this up a bit.
/* * Copyright 2014 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkBlitRow_opts_SSE4_DEFINED #define SkBlitRow_opts_SSE4_DEFINED #include "SkBlitRow.h" /* Check if we are able to build assembly code, GCC/AT&T syntax. * Had problems with LLVM-GCC 4.2. * MemorySanitizer cannot handle assembly code. */ #if (defined(__clang__) || (defined(__GNUC__) && !defined(SK_BUILD_FOR_MAC))) \ && !defined(MEMORY_SANITIZER) extern "C" void S32A_Opaque_BlitRow32_SSE4_asm(SkPMColor* SK_RESTRICT dst, const SkPMColor* SK_RESTRICT src, int count, U8CPU alpha); #define SK_ATT_ASM_SUPPORTED #endif #endif
/* * Copyright 2014 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkBlitRow_opts_SSE4_DEFINED #define SkBlitRow_opts_SSE4_DEFINED #include "SkBlitRow.h" /* Check if we are able to build assembly code, GCC/AT&T syntax: * 1) Clang and GCC are generally OK. OS X's old LLVM-GCC 4.2 can't handle it; * 2) We're intentionally not linking this in even when supported (Clang) on Windows; * 3) MemorySanitizer cannot instrument assembly at all. */ #if /* 1)*/ (defined(__clang__) || (defined(__GNUC__) && !defined(SK_BUILD_FOR_MAC))) \ /* 2)*/ && !defined(SK_BUILD_FOR_WIN) \ /* 3)*/ && !defined(MEMORY_SANITIZER) extern "C" void S32A_Opaque_BlitRow32_SSE4_asm(SkPMColor* SK_RESTRICT dst, const SkPMColor* SK_RESTRICT src, int count, U8CPU alpha); #define SK_ATT_ASM_SUPPORTED #endif #endif
Add header function for monitors_create.
#ifdef E_TYPEDEFS #else # ifndef E_SMART_RANDR_H # define E_SMART_RANDR_H Evas_Object *e_smart_randr_add(Evas *evas); # endif #endif
#ifdef E_TYPEDEFS #else # ifndef E_SMART_RANDR_H # define E_SMART_RANDR_H Evas_Object *e_smart_randr_add(Evas *evas); void e_smart_randr_monitors_create(Evas_Object *obj); # endif #endif
Add old file from week2
#include <stdio.h> #include <fcntl.h> #include <unistd.h> int main() { int fd1, fd2; fd1 = open("f1", O_RDWR); fd2 = open("f1", O_RDWR); lseek(fd1, -5, SEEK_END); lseek(fd2, 4, SEEK_SET); write(fd1, "xyzw", 4); write(fd2, "12", 2); char buff[10]; int count; lseek(fd1, 0, SEEK_SET); while (count = read(fd1, buff, 10)) write(1, buff, count); close(fd1); close(fd2); return 0; }
Convert utils to pragma once
#ifndef ELKENUMS_H #define ELKENUMS_H /** ElkEnums contains various enumerations useful in ELK, such as real/imag component definitions in * Kernels, BCs, etc. */ namespace elk { enum ComponentEnum { REAL, IMAGINARY }; } // namespace elk #endif // ELKENUMS_H
#pragma once /** ElkEnums contains various enumerations useful in ELK, such as real/imag component definitions in * Kernels, BCs, etc. */ namespace elk { enum ComponentEnum { REAL, IMAGINARY }; } // namespace elk
Add test for strtod function
/** * @file * @brief * * @date 26.02.13 * @author Alexander Lapshin */ #include <embox/test.h> #include <stdlib.h> EMBOX_TEST_SUITE("standard library"); TEST_CASE("Check strtod function") { test_assert_equal(0, (int) atof("0.0")); test_assert_equal(10, (int) (10 * atof("1.0"))); test_assert_equal(-10, (int) (10 * atof("-1.0"))); test_assert_equal(11, (int) (10 * atof("1.1"))); test_assert_equal(11, (int) (100 * atof("0.11"))); test_assert_equal(-11, (int) (10 * atof("-1.1"))); test_assert_equal(-110,(int) atof("-1.1E+2")); test_assert_equal(-1, (int) (100 * atof("-0.1e-1"))); test_assert_equal(10, (int) atof("0.1E2")); }
/** * @file * @brief * * @date 26.02.13 * @author Alexander Lapshin */ #include <embox/test.h> #include <stdlib.h> EMBOX_TEST_SUITE("standard library"); TEST_CASE("Check strtod function") { test_assert_equal(0, (int) atof("0.0")); test_assert_equal(10, (int) (10 * atof("1.0"))); test_assert_equal(-10, (int) (10 * atof("-1.0"))); test_assert_equal(11, (int) (10 * atof("1.1"))); test_assert_equal(11, (int) (100 * atof("0.11"))); test_assert_equal(-11, (int) (10 * atof("-1.1"))); test_assert_equal(-110,(int) atof("-1.1E+2")); test_assert_equal(-1, (int) (100 * atof("-0.1e-1"))); test_assert_equal(10, (int) atof("0.1E2")); }
Fix character frequency map to be sorted in ascending order
#include "pair.h" pair new_pair( const char c, const int freq ) { pair p; p.c = c; p.freq = freq; return p; } int compare_freq( const void *a, const void *b ) { const pair *ia = ( const pair * ) a; const pair *ib = ( const pair * ) b; return ib->freq - ia->freq; }
#include "pair.h" pair new_pair( const char c, const int freq ) { pair p; p.c = c; p.freq = freq; return p; } int compare_freq( const void *a, const void *b ) { const pair *ia = ( const pair * ) a; const pair *ib = ( const pair * ) b; return ia->freq - ib->freq; }
Fix uninitialed member variable in ParticlesShape
// This file is a part of the OpenSurgSim project. // Copyright 2013, SimQuest Solutions 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 SURGSIM_MATH_PARTICLESSHAPE_INL_H #define SURGSIM_MATH_PARTICLESSHAPE_INL_H namespace SurgSim { namespace Math { template <class V> ParticlesShape::ParticlesShape(const SurgSim::DataStructures::Vertices<V>& other) : DataStructures::Vertices<DataStructures::EmptyData>(other) { update(); } template <class V> ParticlesShape& ParticlesShape::operator=(const SurgSim::DataStructures::Vertices<V>& other) { DataStructures::Vertices<DataStructures::EmptyData>::operator=(other); update(); return *this; } }; // namespace Math }; // namespace SurgSim #endif
// This file is a part of the OpenSurgSim project. // Copyright 2013-2016, SimQuest Solutions 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 SURGSIM_MATH_PARTICLESSHAPE_INL_H #define SURGSIM_MATH_PARTICLESSHAPE_INL_H namespace SurgSim { namespace Math { template <class V> ParticlesShape::ParticlesShape(const SurgSim::DataStructures::Vertices<V>& other) : DataStructures::Vertices<DataStructures::EmptyData>(other), m_radius(0.0) { update(); } template <class V> ParticlesShape& ParticlesShape::operator=(const SurgSim::DataStructures::Vertices<V>& other) { DataStructures::Vertices<DataStructures::EmptyData>::operator=(other); update(); return *this; } }; // namespace Math }; // namespace SurgSim #endif
Define convenient FATAL_ERROR() and FATAL_ERROR_IF() macros
/* * Copyright 2006 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ // This module contains some basic debugging facilities. // Originally comes from shared/commandlineflags/checks.h #ifndef WEBRTC_BASE_CHECKS_H_ #define WEBRTC_BASE_CHECKS_H_ namespace rtc { // Prints an error message to stderr and aborts execution. void Fatal(const char* file, int line, const char* format, ...); } // namespace rtc // The UNREACHABLE macro is very useful during development. #define UNREACHABLE() \ rtc::Fatal(__FILE__, __LINE__, "unreachable code") #endif // WEBRTC_BASE_CHECKS_H_
/* * Copyright 2006 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ // This module contains some basic debugging facilities. // Originally comes from shared/commandlineflags/checks.h #ifndef WEBRTC_BASE_CHECKS_H_ #define WEBRTC_BASE_CHECKS_H_ namespace rtc { // Prints an error message to stderr and aborts execution. void Fatal(const char* file, int line, const char* format, ...); } // namespace rtc // Trigger a fatal error (which aborts the process and prints an error // message). FATAL_ERROR_IF may seem a lot like assert, but there's a crucial // difference: it's always "on". This means that it can be used to check for // regular errors that could actually happen, not just programming errors that // supposedly can't happen---but triggering a fatal error will kill the process // in an ugly way, so it's not suitable for catching errors that might happen // in production. #define FATAL_ERROR(msg) do { rtc::Fatal(__FILE__, __LINE__, msg); } while (0) #define FATAL_ERROR_IF(x) do { if (x) FATAL_ERROR("check failed"); } while (0) // The UNREACHABLE macro is very useful during development. #define UNREACHABLE() FATAL_ERROR("unreachable code") #endif // WEBRTC_BASE_CHECKS_H_
Add enum values: Timeout, Invalid, NoSupport to eErrorCode
/* <License> Copyright 2015 Virtium Technology 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. </License> */ #ifndef __ErrorCodes_h__ #define __ErrorCodes_h__ namespace vtStor { enum eErrorCode { None = 0, Unknown, Memory, Io, }; enum eOnErrorBehavior { Stop = 0, Continue, }; } #endif __ErrorCodes_h__
/* <License> Copyright 2015 Virtium Technology 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. </License> */ #ifndef __ErrorCodes_h__ #define __ErrorCodes_h__ namespace vtStor { enum eErrorCode { None = 0, Unknown, Memory, Io, Timeout, NoSupport, Invalid, }; enum eOnErrorBehavior { Stop = 0, Continue, }; } #endif __ErrorCodes_h__
Disable clang diagnostics pragma on windows
#ifndef ORBIT_LINUX_TRACING_LOGGING_H_ #define ORBIT_LINUX_TRACING_LOGGING_H_ // TODO: Move logging to OrbitBase once we have clearer plans for such module. #include <cstdio> #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" #define LOG(format, ...) fprintf(stderr, format "\n", ##__VA_ARGS__) #define ERROR(format, ...) LOG("Error: " format, ##__VA_ARGS__) #pragma clang diagnostic pop #endif // ORBIT_LINUX_TRACING_LOGGING_H_
#ifndef ORBIT_LINUX_TRACING_LOGGING_H_ #define ORBIT_LINUX_TRACING_LOGGING_H_ // TODO: Move logging to OrbitBase once we have clearer plans for such module. #include <cstdio> #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" #endif #define LOG(format, ...) fprintf(stderr, format "\n", ##__VA_ARGS__) #define ERROR(format, ...) LOG("Error: " format, ##__VA_ARGS__) #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // ORBIT_LINUX_TRACING_LOGGING_H_
Fix again error: include of non-modular header inside framework module
// // IRHTTPJSONOperation.h // IRKit // // Created by Masakazu Ohtsuka on 2013/12/02. // // #import "ISHTTPOperation.h" @interface IRHTTPJSONOperation : ISHTTPOperation @end
// // IRHTTPJSONOperation.h // IRKit // // Created by Masakazu Ohtsuka on 2013/12/02. // // // #import "ISHTTPOperation.h" @import ISHTTPOperation; @interface IRHTTPJSONOperation : ISHTTPOperation @end
Add note on supported field value types.
// // CLuceneSearchService.h // BRFullTextSearch // // Created by Matt on 6/28/13. // Copyright (c) 2013 Blue Rocket. Distributable under the terms of the Apache License, Version 2.0. // #import <Foundation/Foundation.h> #import "BRSearchService.h" @interface CLuceneSearchService : NSObject <BRSearchService> // after this many updates, perform an optimize for faster searches @property (nonatomic) NSInteger indexUpdateOptimizeThreshold; // the bundle to load resources such as stop words from; defaults to [NSBundle mainBundle]; // the resource must be named "stop-words.txt" @property (nonatomic, strong) NSBundle *bundle; // the default language to use for text analyzers; defaults to "en" @property (nonatomic, strong ) NSString *defaultAnalyzerLanguage; - (id)initWithIndexPath:(NSString *)indexPath; // can call to reset the cached lucene::search::Searcher, to pick up changes to the index; // only thread safe if called from the main thread; only needed if after indexing you need // to search immediately from the main thread before the searcher is automatically reset on // the next main thread run loop execution. - (void)resetSearcher; // the NSUserDefaults key used to track the number of index updates between optimizations - (NSString *)userDefaultsIndexUpdateCountKey; @end
// // CLuceneSearchService.h // BRFullTextSearch // // Implementation of BRSearchService using CLucene. When indexing, only NSString, or // NSArray/NSSet with NSString values, are supported as field values. // // Created by Matt on 6/28/13. // Copyright (c) 2013 Blue Rocket. Distributable under the terms of the Apache License, Version 2.0. // #import <Foundation/Foundation.h> #import "BRSearchService.h" @interface CLuceneSearchService : NSObject <BRSearchService> // after this many updates, perform an optimize for faster searches @property (nonatomic) NSInteger indexUpdateOptimizeThreshold; // the bundle to load resources such as stop words from; defaults to [NSBundle mainBundle]; // the resource must be named "stop-words.txt" @property (nonatomic, strong) NSBundle *bundle; // the default language to use for text analyzers; defaults to "en" @property (nonatomic, strong ) NSString *defaultAnalyzerLanguage; - (id)initWithIndexPath:(NSString *)indexPath; // can call to reset the cached lucene::search::Searcher, to pick up changes to the index; // only thread safe if called from the main thread; only needed if after indexing you need // to search immediately from the main thread before the searcher is automatically reset on // the next main thread run loop execution. - (void)resetSearcher; // the NSUserDefaults key used to track the number of index updates between optimizations - (NSString *)userDefaultsIndexUpdateCountKey; @end
Fix unsigned/signed comparison in UfopaediaCategory::EventOccurred
#pragma once #include "framework/stage.h" #include "framework/includes.h" #include "ufopaediaentry.h" namespace OpenApoc { class UfopaediaCategory : public Stage // , public std::enable_shared_from_this<UfopaediaCategory> { private: Form *menuform; StageCmd stageCmd; void SetCatOffset(int Direction); public: UString ID; UString Title; UString BodyInformation; UString BackgroundImageFilename; std::vector<std::shared_ptr<UfopaediaEntry>> Entries; int ViewingEntry; UfopaediaCategory(Framework &fw, tinyxml2::XMLElement *Element); ~UfopaediaCategory(); // Stage control virtual void Begin() override; virtual void Pause() override; virtual void Resume() override; virtual void Finish() override; virtual void EventOccurred(Event *e) override; virtual void Update(StageCmd *const cmd) override; virtual void Render() override; virtual bool IsTransition() override; void SetTopic(int Index); void SetupForm(); void SetPrevCat(); void SetNextCat(); }; }; // namespace OpenApoc
#pragma once #include "framework/stage.h" #include "framework/includes.h" #include "ufopaediaentry.h" namespace OpenApoc { class UfopaediaCategory : public Stage // , public std::enable_shared_from_this<UfopaediaCategory> { private: Form *menuform; StageCmd stageCmd; void SetCatOffset(int Direction); public: UString ID; UString Title; UString BodyInformation; UString BackgroundImageFilename; std::vector<std::shared_ptr<UfopaediaEntry>> Entries; unsigned int ViewingEntry; UfopaediaCategory(Framework &fw, tinyxml2::XMLElement *Element); ~UfopaediaCategory(); // Stage control virtual void Begin() override; virtual void Pause() override; virtual void Resume() override; virtual void Finish() override; virtual void EventOccurred(Event *e) override; virtual void Update(StageCmd *const cmd) override; virtual void Render() override; virtual bool IsTransition() override; void SetTopic(int Index); void SetupForm(); void SetPrevCat(); void SetNextCat(); }; }; // namespace OpenApoc
Add missing header to git
#ifndef AL_BACKENDS_BASE_H #define AL_BACKENDS_BASE_H #include "alMain.h" struct ALCbackendVtable; typedef struct ALCbackend { const struct ALCbackendVtable *vtbl; ALCdevice *mDevice; } ALCbackend; struct ALCbackendVtable { void (*const Destruct)(ALCbackend *state); ALCenum (*const open)(ALCbackend*, const ALCchar*); void (*const close)(ALCbackend*); ALCboolean (*reset)(ALCbackend*); ALCboolean (*start)(ALCbackend*); void (*stop)(ALCbackend*); ALint64 (*getLatency)(ALCbackend*); void (*const Delete)(ALCbackend *state); }; #define DEFINE_ALCBACKEND_VTABLE(T) \ static void T##_ALCbackend_Destruct(ALCbackend *obj) \ { T##_Destruct(STATIC_UPCAST(T, ALCbackend, obj)); } \ static ALCenum T##_ALCbackend_open(ALCbackend *obj, const ALCchar *p1) \ { return T##_open(STATIC_UPCAST(T, ALCbackend, obj), p1); } \ static void T##_ALCbackend_close(ALCbackend *obj) \ { T##_close(STATIC_UPCAST(T, ALCbackend, obj)); } \ static ALCboolean T##_ALCbackend_reset(ALCbackend *obj) \ { return T##_reset(STATIC_UPCAST(T, ALCbackend, obj)); } \ static ALCboolean T##_ALCbackend_start(ALCbackend *obj) \ { return T##_start(STATIC_UPCAST(T, ALCbackend, obj)); } \ static void T##_ALCbackend_stop(ALCbackend *obj) \ { T##_stop(STATIC_UPCAST(T, ALCbackend, obj)); } \ static ALint64 T##_ALCbackend_getLatency(ALCbackend *obj) \ { return T##_getLatency(STATIC_UPCAST(T, ALCbackend, obj)); } \ static void T##_ALCbackend_Delete(ALCbackend *obj) \ { T##_Delete(STATIC_UPCAST(T, ALCbackend, obj)); } \ \ static const struct ALCbackendVtable T##_ALCbackend_vtable = { \ T##_ALCbackend_Destruct, \ \ T##_ALCbackend_open, \ T##_ALCbackend_close, \ T##_ALCbackend_reset, \ T##_ALCbackend_start, \ T##_ALCbackend_stop, \ T##_ALCbackend_getLatency, \ \ T##_ALCbackend_Delete, \ } #endif /* AL_BACKENDS_BASE_H */
Add an IPI used for testing proper operation of delivering IPIs.
/* * $FreeBSD$ */ #ifndef _MACHINE_SMP_H_ #define _MACHINE_SMP_H_ #ifdef _KERNEL /* * Interprocessor interrupts for SMP. The following values are indices * into the IPI vector table. The SAL gives us the vector used for AP * wake-up. Keep the IPI_AP_WAKEUP at index 0. */ #define IPI_AP_WAKEUP 0 #define IPI_AST 1 #define IPI_CHECKSTATE 2 #define IPI_INVLTLB 3 #define IPI_RENDEZVOUS 4 #define IPI_STOP 5 #define IPI_COUNT 6 #ifndef LOCORE extern int mp_hardware; extern int mp_ipi_vector[]; void ipi_all(int ipi); void ipi_all_but_self(int ipi); void ipi_selected(u_int64_t cpus, int ipi); void ipi_self(int ipi); #endif /* !LOCORE */ #endif /* _KERNEL */ #endif /* !_MACHINE_SMP_H */
/* * $FreeBSD$ */ #ifndef _MACHINE_SMP_H_ #define _MACHINE_SMP_H_ #ifdef _KERNEL /* * Interprocessor interrupts for SMP. The following values are indices * into the IPI vector table. The SAL gives us the vector used for AP * wake-up. Keep the IPI_AP_WAKEUP at index 0. */ #define IPI_AP_WAKEUP 0 #define IPI_AST 1 #define IPI_CHECKSTATE 2 #define IPI_INVLTLB 3 #define IPI_RENDEZVOUS 4 #define IPI_STOP 5 #define IPI_TEST 6 #define IPI_COUNT 7 #ifndef LOCORE extern int mp_hardware; extern int mp_ipi_vector[]; void ipi_all(int ipi); void ipi_all_but_self(int ipi); void ipi_selected(u_int64_t cpus, int ipi); void ipi_self(int ipi); #endif /* !LOCORE */ #endif /* _KERNEL */ #endif /* !_MACHINE_SMP_H */
Remove debug logging and disable test on ppc64be
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s // Crashes on powerpc64be // XFAIL: target-is-powerpc64be #include "test.h" int var; void *Thread(void *x) { pthread_exit(&var); return 0; } int main() { pthread_t t; pthread_create(&t, 0, Thread, 0); void *retval = 0; pthread_join(t, &retval); if (retval != &var) { fprintf(stderr, "Unexpected return value\n"); exit(1); } fprintf(stderr, "PASS\n"); return 0; } // CHECK-NOT: WARNING: ThreadSanitizer: // CHECK: PASS
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s // Crashes on powerpc64be // UNSUPPORTED: powerpc64 #include "test.h" int var; void *Thread(void *x) { pthread_exit(&var); return 0; } int main() { pthread_t t; pthread_create(&t, 0, Thread, 0); void *retval = 0; pthread_join(t, &retval); if (retval != &var) { fprintf(stderr, "Unexpected return value\n"); exit(1); } fprintf(stderr, "PASS\n"); return 0; } // CHECK-NOT: WARNING: ThreadSanitizer: // CHECK: PASS
Fix so that no workaround is required.
/* See LICENSE file for copyright and license details. */ #include "internals.h" void libzahl_realloc(z_t a, size_t need) { #if defined(__clang__) /* https://llvm.org/bugs/show_bug.cgi?id=26930 */ volatile size_t j; #else # define j i #endif size_t i, x; zahl_char_t *new; /* Find n such that n is a minimal power of 2 ≥ need. */ if (likely((need & (~need + 1)) != need)) { need |= need >> 1; need |= need >> 2; need |= need >> 4; for (j = sizeof(need), x = 8; j; j >>= 1, x <<= 1) need |= need >> x; need += 1; } i = libzahl_msb_nz_zu(need); if (likely(libzahl_pool_n[i])) { libzahl_pool_n[i]--; new = libzahl_pool[i][libzahl_pool_n[i]]; zmemcpy(new, a->chars, a->alloced); zfree(a); a->chars = new; } else { a->chars = realloc(a->chars, need * sizeof(zahl_char_t)); if (!a->chars) { if (!errno) /* sigh... */ errno = ENOMEM; libzahl_failure(errno); } } a->alloced = need; }
/* See LICENSE file for copyright and license details. */ #include "internals.h" void libzahl_realloc(z_t a, size_t need) { size_t i, x; zahl_char_t *new; /* Find n such that n is a minimal power of 2 ≥ need. */ if (likely((need & (~need + 1)) != need)) { need |= need >> 1; need |= need >> 2; need |= need >> 4; for (i = sizeof(need), x = 8; (i >>= 1); x <<= 1) need |= need >> x; need += 1; } i = libzahl_msb_nz_zu(need); if (likely(libzahl_pool_n[i])) { libzahl_pool_n[i]--; new = libzahl_pool[i][libzahl_pool_n[i]]; zmemcpy(new, a->chars, a->alloced); zfree(a); a->chars = new; } else { a->chars = realloc(a->chars, need * sizeof(zahl_char_t)); if (!a->chars) { if (!errno) /* sigh... */ errno = ENOMEM; libzahl_failure(errno); } } a->alloced = need; }
Fix per Noris Datum's E-Mail.
#ifndef CONFIG_EXPORTER_H #define CONFIG_EXPORTER_H class ConfigClass; class ConfigObject; class ConfigValue; class ConfigExporter { protected: ConfigExporter(void) { } ~ConfigExporter() { } public: virtual void field(const ConfigValue *, const std::string&) = 0; virtual void object(const ConfigClass *, const ConfigObject *) = 0; virtual void value(const ConfigValue *, const std::string&) = 0; }; #endif /* !CONFIG_EXPORTER_H */
#ifndef CONFIG_EXPORTER_H #define CONFIG_EXPORTER_H class ConfigClass; class ConfigObject; class ConfigValue; class ConfigExporter { protected: ConfigExporter(void) { } virtual ~ConfigExporter() { } public: virtual void field(const ConfigValue *, const std::string&) = 0; virtual void object(const ConfigClass *, const ConfigObject *) = 0; virtual void value(const ConfigValue *, const std::string&) = 0; }; #endif /* !CONFIG_EXPORTER_H */
Fix import to fix Flutter build
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. #ifndef RUNTIME_PLATFORM_FLOATING_POINT_H_ #define RUNTIME_PLATFORM_FLOATING_POINT_H_ #include <cmath> inline double fmod_ieee(double x, double y) { return fmod(x, y); } inline double atan2_ieee(double y, double x) { return atan2(y, x); } #endif // RUNTIME_PLATFORM_FLOATING_POINT_H_
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. #ifndef RUNTIME_PLATFORM_FLOATING_POINT_H_ #define RUNTIME_PLATFORM_FLOATING_POINT_H_ #include <math.h> inline double fmod_ieee(double x, double y) { return fmod(x, y); } inline double atan2_ieee(double y, double x) { return atan2(y, x); } #endif // RUNTIME_PLATFORM_FLOATING_POINT_H_
Set default nullptr value on animation sheet texture
/* Copyright 2015 Ahnaf Siddiqui 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 D_ANIMATION_SHEET_H #define D_ANIMATION_SHEET_H #include "D_typedefs.h" #include "D_Texture.h" namespace Diamond { struct AnimationSheet { Texture *sprite_sheet; /** The length of time in type of tD_delta of one animation frame */ tD_delta frame_length = 100; uint16_t num_frames = 1; uint8_t rows = 1, columns = 1; }; } #endif // D_ANIMATION_SHEET_H
/* Copyright 2015 Ahnaf Siddiqui 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 D_ANIMATION_SHEET_H #define D_ANIMATION_SHEET_H #include "D_typedefs.h" #include "D_Texture.h" namespace Diamond { struct AnimationSheet { Texture *sprite_sheet = nullptr; /** The length of time in type of tD_delta of one animation frame */ tD_delta frame_length = 100; uint16_t num_frames = 1; uint8_t rows = 1, columns = 1; }; } #endif // D_ANIMATION_SHEET_H
Define clock frequency before includes
/* * @file main.c * @brief Set PORTC I/O pins using data direction register, * read input from pins and set high PORTC.0 2 and 3 * if input pin PORTC.6 is high. * @date 06 Jun 2016 10:28 PM */ #include <avr/io.h> #include <util/delay.h> #define __DELAY_BACKWARD_COMPATIBLE__ #ifndef F_CPU #define F_CPU 16000000UL /* 16 MHz clock speed */ #endif int main(void) { DDRC = 0x0F; PORTC = 0x0C; /* lets assume a 4V supply comes to PORTC.6 and Vcc = 5V */ if (PINC == 0b01000000) { PORTC = 0x0B; _delay_ms(1000); /* delay 1s */ } else { PORTC = 0x00; } return 0; }
/* * @file main.c * @brief Set PORTC I/O pins using data direction register, * read input from pins and set high PORTC.0 2 and 3 * if input pin PORTC.6 is high. * @date 06 Jun 2016 10:28 PM */ #define __DELAY_BACKWARD_COMPATIBLE__ #ifndef F_CPU #define F_CPU 16000000UL /* 16 MHz clock speed */ #endif #include <avr/io.h> #include <util/delay.h> int main(void) { DDRC = 0x0F; PORTC = 0x0C; /* lets assume a 4V supply comes to PORTC.6 and Vcc = 5V */ if (PINC == 0b01000000) { PORTC = 0x0B; _delay_ms(1000); /* delay 1s */ } else { PORTC = 0x00; } return 0; }
Fix compile error for ML300/403
/* * arch/ppc/platforms/4xx/virtex.h * * Include file that defines the Xilinx Virtex-II Pro processor * * Author: MontaVista Software, Inc. * source@mvista.com * * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the * terms of the GNU General Public License version 2. This program is licensed * "as is" without any warranty of any kind, whether express or implied. */ #ifdef __KERNEL__ #ifndef __ASM_VIRTEX_H__ #define __ASM_VIRTEX_H__ /* serial defines */ #include <asm/ibm405.h> /* Ugly, ugly, ugly! BASE_BAUD defined here to keep 8250.c happy. */ #if !defined(BASE_BAUD) #define BASE_BAUD (0) /* dummy value; not used */ #endif /* Device type enumeration for platform bus definitions */ #ifndef __ASSEMBLY__ enum ppc_sys_devices { VIRTEX_UART, }; #endif #endif /* __ASM_VIRTEX_H__ */ #endif /* __KERNEL__ */
/* * arch/ppc/platforms/4xx/virtex.h * * Include file that defines the Xilinx Virtex-II Pro processor * * Author: MontaVista Software, Inc. * source@mvista.com * * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the * terms of the GNU General Public License version 2. This program is licensed * "as is" without any warranty of any kind, whether express or implied. */ #ifdef __KERNEL__ #ifndef __ASM_VIRTEX_H__ #define __ASM_VIRTEX_H__ /* serial defines */ #include <asm/ibm405.h> /* Ugly, ugly, ugly! BASE_BAUD defined here to keep 8250.c happy. */ #if !defined(BASE_BAUD) #define BASE_BAUD (0) /* dummy value; not used */ #endif /* Device type enumeration for platform bus definitions */ #ifndef __ASSEMBLY__ enum ppc_sys_devices { VIRTEX_UART, NUM_PPC_SYS_DEVS, }; #endif #endif /* __ASM_VIRTEX_H__ */ #endif /* __KERNEL__ */
Add header for ANX7491 retimer
/* Copyright 2021 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * * ANX7491:10G USB 3.2 Re-timer (1-Port) */ #ifndef __CROS_EC_USB_RETIMER_ANX7491_H #define __CROS_EC_USB_RETIMER_ANX7491_H /* I2C interface addresses */ #define ANX7491_I2C_ADDR0_FLAGS 0x10 #define ANX7491_I2C_ADDR1_FLAGS 0x14 #define ANX7491_I2C_ADDR2_FLAGS 0x16 #define ANX7491_I2C_ADDR3_FLAGS 0x11 #endif /* __CROS_EC_USB_RETIMER_ANX7491_H */
Change import priority of RCTBridgeModule
#if __has_include("RCTBridgeModule.h") #import "RCTBridgeModule.h" #else #import <React/RCTBridgeModule.h> #endif #import <UIKit/UIKit.h> #include <libkern/OSAtomic.h> #include <execinfo.h> @interface ReactNativeExceptionHandler : NSObject <RCTBridgeModule> + (void) replaceNativeExceptionHandlerBlock:(void (^)(NSException *exception, NSString *readeableException))nativeCallbackBlock; + (void) releaseExceptionHold; @end
#if __has_include(<React/RCTBridgeModule.h>) #import <React/RCTBridgeModule.h> #else #import "RCTBridgeModule.h" #endif #import <UIKit/UIKit.h> #include <libkern/OSAtomic.h> #include <execinfo.h> @interface ReactNativeExceptionHandler : NSObject <RCTBridgeModule> + (void) replaceNativeExceptionHandlerBlock:(void (^)(NSException *exception, NSString *readeableException))nativeCallbackBlock; + (void) releaseExceptionHold; @end
Include new header in old header for backwards compatibility.
// The libMesh Finite Element Library. // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifndef LIBMESH_STRING_TO_ENUM_H #define LIBMESH_STRING_TO_ENUM_H // C++ includes #include <string> namespace libMesh { namespace Utility { /** * \returns the enumeration of type \p T which matches the string \p s. */ template <typename T> T string_to_enum (const std::string & s); } // namespace Utility } // namespace libMesh #endif // LIBMESH_STRING_TO_ENUM_H
// The libMesh Finite Element Library. // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifndef LIBMESH_STRING_TO_ENUM_H #define LIBMESH_STRING_TO_ENUM_H // libMesh includes #include "libmesh/enum_to_string.h" // backwards compatibility // C++ includes #include <string> namespace libMesh { namespace Utility { /** * \returns the enumeration of type \p T which matches the string \p s. */ template <typename T> T string_to_enum (const std::string & s); } // namespace Utility } // namespace libMesh #endif // LIBMESH_STRING_TO_ENUM_H
Implement the new optional getRegisterInfo
//===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===// // // This file declares the X86 specific subclass of TargetMachine. // //===----------------------------------------------------------------------===// #ifndef X86TARGETMACHINE_H #define X86TARGETMACHINE_H #include "llvm/Target/TargetMachine.h" #include "X86InstrInfo.h" class X86TargetMachine : public TargetMachine { X86InstrInfo instrInfo; public: X86TargetMachine(); virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; } virtual const MachineSchedInfo &getSchedInfo() const { abort(); } virtual const MachineRegInfo &getRegInfo() const { abort(); } virtual const MachineFrameInfo &getFrameInfo() const { abort(); } virtual const MachineCacheInfo &getCacheInfo() const { abort(); } virtual const MachineOptInfo &getOptInfo() const { abort(); } /// addPassesToJITCompile - Add passes to the specified pass manager to /// implement a fast dynamic compiler for this target. Return true if this is /// not supported for this target. /// virtual bool addPassesToJITCompile(PassManager &PM); }; #endif
//===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===// // // This file declares the X86 specific subclass of TargetMachine. // //===----------------------------------------------------------------------===// #ifndef X86TARGETMACHINE_H #define X86TARGETMACHINE_H #include "llvm/Target/TargetMachine.h" #include "X86InstrInfo.h" class X86TargetMachine : public TargetMachine { X86InstrInfo instrInfo; public: X86TargetMachine(); virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; } virtual const MachineSchedInfo &getSchedInfo() const { abort(); } virtual const MachineRegInfo &getRegInfo() const { abort(); } virtual const MachineFrameInfo &getFrameInfo() const { abort(); } virtual const MachineCacheInfo &getCacheInfo() const { abort(); } virtual const MachineOptInfo &getOptInfo() const { abort(); } virtual const MRegisterInfo *getRegisterInfo() const { return &instrInfo.getRegisterInfo(); } /// addPassesToJITCompile - Add passes to the specified pass manager to /// implement a fast dynamic compiler for this target. Return true if this is /// not supported for this target. /// virtual bool addPassesToJITCompile(PassManager &PM); }; #endif
Add a bit more threshold
#ifndef BORDERS_H #define BORDERS_H #include <cstdlib> #include <cmath> /** A line will be considered as having content if 0.25% of it is filled. */ const float filledRatioLimit = 0.0025; /** When the threshold is closer to 1, less content will be cropped. **/ #define THRESHOLD 0.65 const uint16_t redThreshold_RGB_565 = ((uint16_t)(31.0 * THRESHOLD)) << (5 + 6); const uint8_t redTreshold_RGB_A8888 = (uint8_t)(255.0 * THRESHOLD); const uint8_t redTreshold_A8 = (uint8_t)(255.0 * THRESHOLD); struct Borders { int left, top, right, bottom; }; Borders findBorders_ARGB_8888(const void *pixels, int width, int height); Borders findBorders_RGB_565(const void *pixels, int width, int height); Borders findBorders_A8(const void *pixels, int width, int height); #endif //BORDERS_H
#ifndef BORDERS_H #define BORDERS_H #include <cstdlib> #include <cmath> /** A line will be considered as having content if 0.25% of it is filled. */ const float filledRatioLimit = 0.0025; /** When the threshold is closer to 1, less content will be cropped. **/ #define THRESHOLD 0.75 const uint16_t redThreshold_RGB_565 = ((uint16_t)(31.0 * THRESHOLD)) << (5 + 6); const uint8_t redTreshold_RGB_A8888 = (uint8_t)(255.0 * THRESHOLD); const uint8_t redTreshold_A8 = (uint8_t)(255.0 * THRESHOLD); struct Borders { int left, top, right, bottom; }; Borders findBorders_ARGB_8888(const void *pixels, int width, int height); Borders findBorders_RGB_565(const void *pixels, int width, int height); Borders findBorders_A8(const void *pixels, int width, int height); #endif //BORDERS_H
Add test of namespaces and structs/unions
/* name: TEST015 description: Stress namespace mechanism output: test015.c:21: warning: 's1' defined but not used S7 s2 ( M8 I s ) S4 s1 ( M5 I s M9 S7 s2 ) S2 s ( M10 S4 s1 ) G11 S2 s F1 G12 F1 main { - j L2 A3 S2 s2 L4 yI G11 M10 .S4 M5 .I G11 M10 .S4 M9 .S7 M8 .I +I L2 yI A3 M10 .S4 M9 .S7 M8 .I } */ #line 1 struct s { struct s1 { int s; struct s2 { int s; } s2; } s1; } s; int main(void) { goto s2; struct s s2; s1: return s.s1.s + s.s1.s2.s; s2: return s2.s1.s2.s; }
Add const to hw_button_enabled() definition.
#ifndef CONTROL_LOOP_INL_H #define CONTROL_LOOP_INL_H #include "board.h" #include "bitband.h" namespace hardware { inline bool ControlLoop::hw_button_enabled() { return MEM_ADDR(BITBAND(reinterpret_cast<uint32_t>(&(GPIOF->IDR)), GPIOF_HW_SWITCH_PIN)); } } #endif
#ifndef CONTROL_LOOP_INL_H #define CONTROL_LOOP_INL_H #include "board.h" #include "bitband.h" namespace hardware { inline bool ControlLoop::hw_button_enabled() const { return MEM_ADDR(BITBAND(reinterpret_cast<uint32_t>(&(GPIOF->IDR)), GPIOF_HW_SWITCH_PIN)); } } #endif
Add missing cstddef header for size_t
#ifndef FORMAT_H #define FORMAT_H #include <cstring> // memmove class Format { public: Format(void *p, size_t s = 0) : fp((char *)p), size(s) {}; size_t Leanify(size_t size_leanified = 0) { if (size_leanified) { memmove(fp - size_leanified, fp, size); fp -= size_leanified; } return size; } protected: // pointer to the file content char *fp; // size of the file size_t size; }; #endif
#ifndef FORMAT_H #define FORMAT_H #include <cstddef> #include <cstring> // memmove class Format { public: Format(void *p, size_t s = 0) : fp((char *)p), size(s) {}; size_t Leanify(size_t size_leanified = 0) { if (size_leanified) { memmove(fp - size_leanified, fp, size); fp -= size_leanified; } return size; } protected: // pointer to the file content char *fp; // size of the file size_t size; }; #endif
Remove some debug output from decode initialization.
#include "vpx_ports/config.h" #include "opencl/vp8_opencl.h" #include "opencl/vp8_decode_cl.h" #include <stdio.h> extern int cl_init_dequant(); extern int cl_destroy_dequant(); int cl_decode_destroy(){ int err; err = cl_destroy_dequant(); return CL_SUCCESS; } int cl_decode_init() { int err; printf("Initializing opencl decoder-specific programs/kernels"); //Initialize programs to null value //Enables detection of if they've been initialized as well. cl_data.dequant_program = NULL; err = cl_init_dequant(); if (err != CL_SUCCESS) return err; printf(" .. done\n"); return CL_SUCCESS; }
#include "vpx_ports/config.h" #include "../../common/opencl/vp8_opencl.h" #include "vp8_decode_cl.h" #include <stdio.h> extern int cl_init_dequant(); extern int cl_destroy_dequant(); int cl_decode_destroy(){ int err; err = cl_destroy_dequant(); return CL_SUCCESS; } int cl_decode_init() { int err; printf("Initializing opencl decoder-specific programs/kernels"); //Initialize programs to null value //Enables detection of if they've been initialized as well. cl_data.dequant_program = NULL; err = cl_init_dequant(); if (err != CL_SUCCESS) return err; return CL_SUCCESS; }
Drop another unused libunw cursor member.
// // This software was produced with support in part from the Defense Advanced // Research Projects Agency (DARPA) through AFRL Contract FA8650-09-C-1915. // Nothing in this work should be construed as reflecting the official policy or // position of the Defense Department, the United States government, or // Rice University. // #ifndef UNW_DATATYPES_SPECIFIC_H #define UNW_DATATYPES_SPECIFIC_H #include <libunwind.h> #include <unwind/common/fence_enum.h> #include <hpcrun/loadmap.h> #include <utilities/ip-normalized.h> typedef struct { load_module_t* lm; } intvl_t; typedef struct hpcrun_unw_cursor_t { void* pc_unnorm; fence_enum_t fence; // Details on which fence stopped an unwind unw_cursor_t uc; // normalized ip for first instruction in enclosing function ip_normalized_t the_function; ip_normalized_t pc_norm; } hpcrun_unw_cursor_t; #endif // UNW_DATATYPES_SPECIFIC_H
// // This software was produced with support in part from the Defense Advanced // Research Projects Agency (DARPA) through AFRL Contract FA8650-09-C-1915. // Nothing in this work should be construed as reflecting the official policy or // position of the Defense Department, the United States government, or // Rice University. // #ifndef UNW_DATATYPES_SPECIFIC_H #define UNW_DATATYPES_SPECIFIC_H #include <libunwind.h> #include <unwind/common/fence_enum.h> #include <hpcrun/loadmap.h> #include <utilities/ip-normalized.h> typedef struct { load_module_t* lm; } intvl_t; typedef struct hpcrun_unw_cursor_t { void* pc_unnorm; unw_cursor_t uc; // normalized ip for first instruction in enclosing function ip_normalized_t the_function; ip_normalized_t pc_norm; } hpcrun_unw_cursor_t; #endif // UNW_DATATYPES_SPECIFIC_H
Add octApron test where threadenter doesn't remove locals
// SKIP PARAM: --sets ana.activated[+] octApron #include <pthread.h> #include <assert.h> void *t_fun(void *arg) { int x; // threadenter shouldn't pass value for x here assert(x == 3); // UNKNOWN! return NULL; } int main(void) { int x = 3; pthread_t id; pthread_create(&id, NULL, t_fun, NULL); return 0; }
Bring in POSIX message queue header file.
/*- * Copyright (c) 2005 David Xu <davidxu@freebsd.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _MQUEUE_H_ #define _MQUEUE_H_ #include <sys/types.h> #include <sys/mqueue.h> struct sigevent; struct timespec; int mq_close(mqd_t); int mq_getattr(mqd_t, struct mq_attr *); int mq_notify(mqd_t, const struct sigevent *); mqd_t mq_open(const char *, int, ...); ssize_t mq_receive(mqd_t, char *, size_t, unsigned *); int mq_send(mqd_t, const char *, size_t, unsigned); int mq_setattr(mqd_t, const struct mq_attr *__restrict, struct mq_attr *__restrict); ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, const struct timespec *__restrict); int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *); int mq_unlink(const char *); #endif
Add trampoline code to call function withn respect to the incoming JSON method.
#include <stdint.h> #include <stdio.h> #include "compiler.h" #include "cJSON.h" #include "parse.h" int parse_message(const char *msg, uint32_t length) { cJSON *root; const char *end_parse; root = cJSON_ParseWithOpts(msg, &end_parse, 0); if (unlikely(root == NULL)) { fprintf(stderr, "Could not parse JSON!\n"); return -1; } else { uint32_t parsed_length = end_parse - msg; if (unlikely(parsed_length != length)) { fprintf(stderr, "length of parsed JSON does not match message length!\n"); return -1; } cJSON_Delete(root); return 0; } }
#include <stdint.h> #include <stdio.h> #include <string.h> #include "compiler.h" #include "cJSON.h" #include "parse.h" int parse_message(const char *msg, uint32_t length) { cJSON *root; const char *end_parse; root = cJSON_ParseWithOpts(msg, &end_parse, 0); if (unlikely(root == NULL)) { fprintf(stderr, "Could not parse JSON!\n"); return -1; } else { cJSON *method; const char *method_string; uint32_t parsed_length = end_parse - msg; if (unlikely(parsed_length != length)) { fprintf(stderr, "length of parsed JSON does not match message length!\n"); return -1; } method = cJSON_GetObjectItem(root, "method"); if (unlikely(method == NULL)) { goto no_method; } method_string = method->valuestring; if (unlikely(method_string == NULL)) { goto no_method; } if (strcmp(method_string, "set") == 0) { } else if (strcmp(method_string, "post") == 0) { } else if (strcmp(method_string, "add") == 0) { } else if (strcmp(method_string, "remove") == 0) { } else if (strcmp(method_string, "call") == 0) { } else if (strcmp(method_string, "fetch") == 0) { } else if (strcmp(method_string, "unfetch") == 0) { } else { fprintf(stderr, "Unsupported method: %s!\n", method_string); goto unsupported_method; } cJSON_Delete(root); return 0; no_method: fprintf(stderr, "Can not find supported method!\n"); unsupported_method: cJSON_Delete(root); return -1; } }
Fix webp compile warnings on windows
/* * Copyright 2015 Google, Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ // FIXME: Workaround for skbug.com/4037 // Some of our test machines have an older version of clang that does not // have // __builtin_bswap16 // // But libwebp expects the builtin. We can change that by using this config.h // file, which replaces the checks in endian_inl.h to decide whether we have // particular builtins. #ifdef __builtin_bswap64(x) #define HAVE_BUILTIN_BSWAP64 #endif #ifdef __builtin_bswap32(x) #define HAVE_BUILTIN_BSWAP32 #endif #ifdef __builtin_bswap16(x) #define HAVE_BUILTIN_BSWAP16 #endif
/* * Copyright 2015 Google, Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ // FIXME: Workaround for skbug.com/4037 // Some of our test machines have an older version of clang that does not // have // __builtin_bswap16 // // But libwebp expects the builtin. We can change that by using this config.h // file, which replaces the checks in endian_inl.h to decide whether we have // particular builtins. #ifdef __builtin_bswap64 #define HAVE_BUILTIN_BSWAP64 #endif #ifdef __builtin_bswap32 #define HAVE_BUILTIN_BSWAP32 #endif #ifdef __builtin_bswap16 #define HAVE_BUILTIN_BSWAP16 #endif
Remove logger ids loop from sample
#ifndef MYTHREAD_H #define MYTHREAD_H #include <QThread> #include "easylogging++.h" class MyThread : public QThread { Q_OBJECT public: MyThread(int id) : threadId(id) {} private: int threadId; protected: void run() { LINFO <<"Writing from a thread " << threadId; LVERBOSE(2) << "This is verbose level 2 logging from thread #" << threadId; // Following line will be logged only once from second running thread (which every runs second into // this line because of interval 2) LWARNING_EVERY_N(2) << "This will be logged only once from thread who every reaches this line first. Currently running from thread #" << threadId; for (int i = 1; i <= 10; ++i) { LVERBOSE_EVERY_N(2, 3) << "Verbose level 3 log every two times. This is at " << i << " from thread #" << threadId; } // Following line will be logged once with every thread because of interval 1 LINFO_EVERY_N(1) << "This interval log will be logged with every thread, this one is from thread #" << threadId; LINFO_IF(threadId == 2) << "This log is only for thread 2 and is ran by thread #" << threadId; std::vector<std::string> myLoggers; easyloggingpp::Loggers::getAllLogIdentifiers(myLoggers); for (unsigned int i = 0; i < myLoggers.size(); ++i) { std::cout << "Logger ID [" << myLoggers.at(i) << "]"; } easyloggingpp::Configurations c; c.parseFromText("*ALL:\n\nFORMAT = %level"); } }; #endif
#ifndef MYTHREAD_H #define MYTHREAD_H #include <QThread> #include "easylogging++.h" class MyThread : public QThread { Q_OBJECT public: MyThread(int id) : threadId(id) {} private: int threadId; protected: void run() { LINFO <<"Writing from a thread " << threadId; LVERBOSE(2) << "This is verbose level 2 logging from thread #" << threadId; // Following line will be logged only once from second running thread (which every runs second into // this line because of interval 2) LWARNING_EVERY_N(2) << "This will be logged only once from thread who every reaches this line first. Currently running from thread #" << threadId; for (int i = 1; i <= 10; ++i) { LVERBOSE_EVERY_N(2, 3) << "Verbose level 3 log every two times. This is at " << i << " from thread #" << threadId; } // Following line will be logged once with every thread because of interval 1 LINFO_EVERY_N(1) << "This interval log will be logged with every thread, this one is from thread #" << threadId; LINFO_IF(threadId == 2) << "This log is only for thread 2 and is ran by thread #" << threadId; } }; #endif
Set up actual compiler detections. Only supports gcc and msvc at the moment
#ifndef OI_OS #define OI_OS 1 #if defined(_WIN32) || defined(__WIN32__) # define OI_WIN # ifdef _MSC_VER # define OI_MSVC # else # define OI_GCC # endif # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include <windows.h> #elif defined(linux) || defined(__linux) # define OI_LINUX # define OI_GCC # ifndef _XOPEN_SOURCE # define _XOPEN_SOURCE 500 # endif # ifndef __USE_UNIX98 # define __USE_UNIX98 # endif #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) # define OI_MAC # define OI_GCC #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # define OI_FreeBSD # define OI_GCC #else # warning oi does not recognize OS # define OI_UNKNOWN_OS # define OI_UNKNOWN_COMPILER #endif #endif
#ifndef OI_OS #define OI_OS 1 #if defined(__GNUC__) # define OI_GCC #elif defined(_MSC_VER) # define OI_MSVC #else # warning oi does not recognize compiler # define OI_UNKNOWN_CC #endif #if defined(_WIN32) || defined(__WIN32__) # define OI_WIN # # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # # include <windows.h> # #elif defined(linux) || defined(__linux) # define OI_LINUX # # ifndef _XOPEN_SOURCE # define _XOPEN_SOURCE 500 # endif # # ifndef __USE_UNIX98 # define __USE_UNIX98 # endif # #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) # define OI_MAC # #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # define OI_FreeBSD # #else # warning oi does not recognize OS # define OI_UNKNOWN_OS #endif #endif
Call _exit instead of exit on assertion failure.
#include <errno.h> #include <unistd.h> #include "iobuf.h" static const char errmsg[] = "ibuf_refill called with non-empty buffer!\n"; int ibuf_refill(ibuf* in) { iobuf* io; unsigned oldlen; unsigned rd; io = &(in->io); if (io->flags) return 0; if (io->bufstart != 0) { if (io->bufstart < io->buflen) { write(1, errmsg, sizeof errmsg); exit(1); /* io->buflen -= io->bufstart; */ /* memcpy(io->buffer, io->buffer+io->bufstart, io->buflen); */ } else io->buflen = 0; io->bufstart = 0; } oldlen = io->buflen; if(io->buflen < io->bufsize) { if (io->timeout && !iobuf_timeout(io, 0)) return 0; rd = read(io->fd, io->buffer+io->buflen, io->bufsize-io->buflen); if(rd == (unsigned)-1) IOBUF_SET_ERROR(io); else if(rd == 0) io->flags |= IOBUF_EOF; else { io->buflen += rd; io->offset += rd; } } return io->buflen > oldlen; }
#include <errno.h> #include <unistd.h> #include "iobuf.h" static const char errmsg[] = "ibuf_refill called with non-empty buffer!\n"; int ibuf_refill(ibuf* in) { iobuf* io; unsigned oldlen; unsigned rd; io = &(in->io); if (io->flags) return 0; if (io->bufstart != 0) { if (io->bufstart < io->buflen) { write(1, errmsg, sizeof errmsg); _exit(1); /* io->buflen -= io->bufstart; */ /* memcpy(io->buffer, io->buffer+io->bufstart, io->buflen); */ } else io->buflen = 0; io->bufstart = 0; } oldlen = io->buflen; if(io->buflen < io->bufsize) { if (io->timeout && !iobuf_timeout(io, 0)) return 0; rd = read(io->fd, io->buffer+io->buflen, io->bufsize-io->buflen); if(rd == (unsigned)-1) IOBUF_SET_ERROR(io); else if(rd == 0) io->flags |= IOBUF_EOF; else { io->buflen += rd; io->offset += rd; } } return io->buflen > oldlen; }
Add Perry Metzger's wrapper to run the svnserve process setgid, since this can be very helpful to svn+ssh users. Quoting from the comments:
/* * Wrapper to run the svnserve process setgid. * The idea is to avoid the problem that some interpreters like bash * invoked by svnserve in hook scripts will reset the effective gid to * the real gid, nuking the effect of an ordinary setgid svnserve binary. * Sadly, to set the real gid portably, you need to be root, if only * for a moment. * Also smashes the environment to something known, so that games * can't be played to try to break the security of the hook scripts, * by setting IFS, PATH, and similar means. */ /* * Written by Perry Metzger, and placed into the public domain. */ #include <stdio.h> #include <unistd.h> #define REAL_PATH "/usr/bin/svnserve.real" char *newenv[] = { "PATH=/bin:/usr/bin", "SHELL=/bin/sh", NULL }; int main(int argc, char **argv) { if (setgid(getegid()) == -1) { perror("setgid(getegid())"); return 1; } if (seteuid(getuid()) == -1) { perror("seteuid(getuid())"); return 1; } execve(REAL_PATH, argv, newenv); perror("attempting to exec " REAL_PATH " failed"); return 1; }
Correct macro spelling to fix Linux build
// For conditions of distribution and use, see copyright notice in LICENSE #pragma once #if defined (_WINDOWS) #if defined(WEBSOCKET_MODULE_EXPORTS) #define WEBSOCKET_SERVER_MODULE_API __declspec(dllexport) #else #define WEBSOCKET_SERVER_MODULE_API __declspec(dllimport) #endif #else #define WEBSOCKET_MODULE_API #endif
// For conditions of distribution and use, see copyright notice in LICENSE #pragma once #if defined (_WINDOWS) #if defined(WEBSOCKET_MODULE_EXPORTS) #define WEBSOCKET_SERVER_MODULE_API __declspec(dllexport) #else #define WEBSOCKET_SERVER_MODULE_API __declspec(dllimport) #endif #else #define WEBSOCKET_SERVER_MODULE_API #endif
Fix compilation error, cast was missing
#include <mbstr.h> #include <stdlib.h> #include "../intern.h" #ifdef __cplusplus extern "C" { #endif char* __mbschr (char* str, mbchar_t c) { if (c < 0x80) { return __strchr(str, c); } else { char buf[sizeof(mbchar_t)+1]; *((mbchar_t*)buf) = c; buf[__min(sizeof(mbchar_t),MBMAXLEN)] = '\0'; return __strstr(str, buf); } } char* mbschr (char* str, mbchar_t c) \ _WEAK_ALIAS_OF("__mbschr"); #ifdef __cplusplus } #endif
#include <mbstr.h> #include <stdlib.h> #include "../intern.h" #ifdef __cplusplus extern "C" { #endif char* __mbschr (char* str, mbchar_t c) { if (c < 0x80) { return __strchr(str, c); } else { char buf[sizeof(mbchar_t)+1]; *((mbchar_t*)buf) = c; buf[__min(sizeof(mbchar_t),(size_t)MBMAXLEN)] = '\0'; return __strstr(str, buf); } } char* mbschr (char* str, mbchar_t c) \ _WEAK_ALIAS_OF("__mbschr"); #ifdef __cplusplus } #endif
Use ISR for serial loopback instead of a blocking read
// Takes in a character at a time and sends it right back out, // displaying the ASCII value on the LEDs. // Uses interrupt system instead of a blocking read. #include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include "USART.h" // Single character for serial TX/RX and "byte received" flag volatile char a; volatile uint8_t newbyte; // Run when USART receives a new byte. // Reading from and writing to UDR0 trigger critical side-effects. // UDR0 *must* be read inside this ISR. // Otherwise, RXC0 will not be cleared, and another interrupt will follow. // See 20.7.3 in the datasheet. ISR(USART_RX_vect) { a = UDR0; // Assigning to an lvalue also clears RXC0 UDR0 = a; // Writes to TX shift register (echoes a back out) newbyte = 1; } int main(void) { initUSART(); // Set the RX Complete Interrupt Enable 0 bit UCSR0B |= (1 << RXCIE0); sei(); // All DDRB pins to output mode DDRB = 0xff; newbyte = 0; while (1) { // Light up PORTB in the ASCII binary representation of a if (newbyte) { PORTB = a; newbyte = 0; } } return 0; }
Increment version number to 1.32
#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.31f;
#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.32f;
Add unsound negative int to unsigned int branch invariant test
// PARAM: --enable ana.int.def_exc --enable ana.int.interval // ldv-benchmarks: u__linux-concurrency_safety__drivers---net---ethernet---amd---pcnet32.ko.c #include <assert.h> int main() { int debug_value = -1; if ((unsigned int)debug_value > 31U) assert(1); // reachable else assert(1); // NOWARN (unreachable) return 0; }
Add missing CONTENT_EXPORT to fix Linux shared build after r112415
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #pragma once class TabContents; namespace content { class DevToolsFrontendWindowDelegate; // Installs delegate for DevTools front-end loaded into |client_tab_contents|. void SetupDevToolsFrontendDelegate( TabContents* client_tab_contents, DevToolsFrontendWindowDelegate* delegate); } #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #pragma once class TabContents; namespace content { class DevToolsFrontendWindowDelegate; // Installs delegate for DevTools front-end loaded into |client_tab_contents|. CONTENT_EXPORT void SetupDevToolsFrontendDelegate( TabContents* client_tab_contents, DevToolsFrontendWindowDelegate* delegate); } #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_
Revert "bluetooth: Our kernel is missing CLOCK_BOOTTIME_ALARM (alarmtimer)"
/* * Copyright 2013 The Android Open Source Project * * 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 _BDROID_BUILDCFG_H #define _BDROID_BUILDCFG_H #define BTA_DISABLE_DELAY 100 /* in milliseconds */ #define BLE_VND_INCLUDED TRUE #define BTM_BLE_ADV_TX_POWER {-21, -15, -7, 1, 9} /* Defined if the kernel does not have support for CLOCK_BOOTTIME_ALARM */ #define KERNEL_MISSING_CLOCK_BOOTTIME_ALARM TRUE #endif
/* * Copyright 2013 The Android Open Source Project * * 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 _BDROID_BUILDCFG_H #define _BDROID_BUILDCFG_H #define BTA_DISABLE_DELAY 100 /* in milliseconds */ #define BLE_VND_INCLUDED TRUE #define BTM_BLE_ADV_TX_POWER {-21, -15, -7, 1, 9} #endif
Fix typo in include file
// Copyright 2016 Pierre Fourgeaud #ifndef PF_CONSOLELOGGER_H_ #define PF_CONSOLELOGGER_H_ #include <iostream> #include <string> #include "./iloglistener.h" #include "./Logger.h" /** * @brief The FileLogger class * * Logger that will write the ouput to the console (cerr or cout depending on log level) */ class ConsoleLogger : public ILogListener { public: ConsoleLogger() {} /** * Virtual destructor */ virtual ~ConsoleLogger() {} /** * @brief Notify Mandatory method to implement for every log listener. * Will be called everytime there is a new message to ouput it to the console. * * if iLevel Critical or Error, output to cerr, otherwise to cout * * @param iLog The message * @param iLevel The log level */ virtual void Notify(const std::string& iMsg, ELogLevel iLevel) { if (iLevel <= ELogLevel::Error) { std::cerr << iMsg; } else { std::cout << iMsg; } } }; #endif // PF_CONSOLELOGGER_H_
// Copyright 2016 Pierre Fourgeaud #ifndef PF_CONSOLELOGGER_H_ #define PF_CONSOLELOGGER_H_ #include <iostream> #include <string> #include "./iloglistener.h" #include "./logger.h" /** * @brief The FileLogger class * * Logger that will write the ouput to the console (cerr or cout depending on log level) */ class ConsoleLogger : public ILogListener { public: ConsoleLogger() {} /** * Virtual destructor */ virtual ~ConsoleLogger() {} /** * @brief Notify Mandatory method to implement for every log listener. * Will be called everytime there is a new message to ouput it to the console. * * if iLevel Critical or Error, output to cerr, otherwise to cout * * @param iLog The message * @param iLevel The log level */ virtual void Notify(const std::string& iMsg, ELogLevel iLevel) { if (iLevel <= ELogLevel::Error) { std::cerr << iMsg; } else { std::cout << iMsg; } } }; #endif // PF_CONSOLELOGGER_H_
Add a testcase for WockyXmppConnection and check its istantiation
#include <stdio.h> #include <unistd.h> #include <glib.h> #include <wocky/wocky-xmpp-connection.h> #include <wocky/wocky-transport.h> #include "test-transport.h" #include <check.h> START_TEST (test_instantiation) { WockyXmppConnection *connection; TestTransport *transport; g_type_init(); transport = test_transport_new(NULL, NULL); connection = wocky_xmpp_connection_new(WOCKY_TRANSPORT(transport)); fail_if (connection == NULL); connection = wocky_xmpp_connection_new(NULL); fail_if (connection == NULL); } END_TEST TCase * make_wocky_xmpp_connection_tcase (void) { TCase *tc = tcase_create ("XMPP Connection"); tcase_add_test (tc, test_instantiation); return tc; }
Add PipePairSimple which allows a user to simply construct a single object which implements a PipePair.
#ifndef IO_PIPE_PAIR_SIMPLE_H #define IO_PIPE_PAIR_SIMPLE_H #include <io/pipe_simple.h> #include <io/pipe_simple_wrapper.h> class PipePairSimple : public PipePair { PipeSimpleWrapper<PipePairSimple> *incoming_pipe_; PipeSimpleWrapper<PipePairSimple> *outgoing_pipe_; protected: PipePairSimple(void) : incoming_pipe_(NULL), outgoing_pipe_(NULL) { } public: virtual ~PipePairSimple() { if (incoming_pipe_ != NULL) { delete incoming_pipe_; incoming_pipe_ = NULL; } if (outgoing_pipe_ != NULL) { delete outgoing_pipe_; outgoing_pipe_ = NULL; } } protected: virtual bool incoming_process(Buffer *, Buffer *) = 0; virtual bool outgoing_process(Buffer *, Buffer *) = 0; public: Pipe *get_incoming(void) { ASSERT(incoming_pipe_ == NULL); incoming_pipe_ = new PipeSimpleWrapper<PipePairSimple>(this, &PipePairSimple::incoming_process); return (incoming_pipe_); } Pipe *get_outgoing(void) { ASSERT(outgoing_pipe_ == NULL); outgoing_pipe_ = new PipeSimpleWrapper<PipePairSimple>(this, &PipePairSimple::outgoing_process); return (outgoing_pipe_); } }; #endif /* !IO_PIPE_PAIR_SIMPLE_H */
Remove item from umbrella header.
//////////////////////////////////////////////////////////////////////////////// // // JASPER BLUES // Copyright 2012 Jasper Blues // All Rights Reserved. // // NOTICE: Jasper Blues permits you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// #import "XCAbstractDefinition.h" #import "XCGroup.h" #import "XCClassDefinition.h" #import "XCFileOperationQueue.h" #import "XCFrameworkDefinition.h" #import "XCProject.h" #import "XCSourceFile.h" #import "XCSourceFileDefinition.h" #import "XCSubProjectDefinition.h" #import "XCTarget.h" #import "XCEnumUtils.h" #import "XCXibDefinition.h"
//////////////////////////////////////////////////////////////////////////////// // // JASPER BLUES // Copyright 2012 Jasper Blues // All Rights Reserved. // // NOTICE: Jasper Blues permits you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// #import "XCAbstractDefinition.h" #import "XCGroup.h" #import "XCClassDefinition.h" #import "XCFileOperationQueue.h" #import "XCFrameworkDefinition.h" #import "XCProject.h" #import "XCSourceFile.h" #import "XCSourceFileDefinition.h" #import "XCSubProjectDefinition.h" #import "XCTarget.h" #import "XCXibDefinition.h"
Include required header in source
#ifndef MACRO_H_ #define MACRO_H_ #include <stdio.h> #define HEX_PRINT(X,Y) { int zz; for(zz = 0; zz < Y; zz++) fprintf(stderr, "%02X", X[zz]); fprintf(stderr, "\n"); } #define MKINT_BE16(X) ( (X)[0] << 8 | (X)[1] ) #define MKINT_BE24(X) ( (X)[0] << 16 | (X)[1] << 8 | (X)[2] ) #define MKINT_BE32(X) ( (X)[0] << 24 | (X)[1] << 16 | (X)[2] << 8 | (X)[3] ) #define X_FREE(X) do { if (X) free(X); X = NULL; } while(0) #endif /* MACRO_H_ */
Add nullability info to root ModelObject
// // ETA_ModelObject.h // ETA-SDK // // Created by Laurie Hufford on 7/11/13. // Copyright (c) 2013 eTilbudsavis. All rights reserved. // #import "Mantle.h" #import "NSValueTransformer+ETAPredefinedValueTransformers.h" @interface ETA_ModelObject : MTLModel <MTLJSONSerializing> // setting either uuid or ern will keep the other updated @property (nonatomic, readwrite, strong) NSString* uuid; // will always be lowercase, no matter the input case @property (nonatomic, readwrite, strong) NSString* ern; + (NSString*) APIEndpoint; // base class returns nil. + (NSString*) ernForItemID:(NSString*)itemID; //uses the API Endpoint to generate the ern + (instancetype) objectFromJSONDictionary:(NSDictionary*)JSONDictionary; - (NSDictionary*) JSONDictionary; + (NSArray*) objectsFromJSONArray:(NSArray*)JSONArray; @end
// // ETA_ModelObject.h // ETA-SDK // // Created by Laurie Hufford on 7/11/13. // Copyright (c) 2013 eTilbudsavis. All rights reserved. // #import "Mantle.h" #import "NSValueTransformer+ETAPredefinedValueTransformers.h" @interface ETA_ModelObject : MTLModel <MTLJSONSerializing> // setting either uuid or ern will keep the other updated @property (nonatomic, readwrite, strong, nonnull) NSString* uuid; // will always be lowercase, no matter the input case @property (nonatomic, readwrite, strong, nonnull) NSString* ern; + (nullable NSString*) APIEndpoint; // base class returns nil. + (nullable NSString*) ernForItemID:(nullable NSString*)itemID; //uses the API Endpoint to generate the ern + (nullable instancetype) objectFromJSONDictionary:(nullable NSDictionary*)JSONDictionary; - (nullable NSDictionary*) JSONDictionary; + (nullable NSArray*) objectsFromJSONArray:(nullable NSArray*)JSONArray; @end
Add new header file. (or: xcode is stupid)
// // BDSKOAIGroupServer.h // Bibdesk // // Created by Christiaan Hofman on 1/1/07. // Copyright 2007 __MyCompanyName__. All rights reserved. // #import <Cocoa/Cocoa.h> #import "BDSKSearchGroup.h" @class BDSKServerInfo; @interface BDSKOAIGroupServer : NSObject <BDSKSearchGroupServer> { BDSKSearchGroup *group; BDSKServerInfo *serverInfo; NSString *searchTerm; NSString *resumptionToken; NSArray *sets; NSString *filePath; NSURLDownload *URLDownload; BOOL failedDownload; BOOL isRetrieving; BOOL needsReset; int availableResults; int fetchedResults; } - (void)setServerInfo:(BDSKServerInfo *)info; - (BDSKServerInfo *)serverInfo; - (void)setSearchTerm:(NSString *)string; - (NSString *)searchTerm; - (void)setSets:(NSArray *)newSets; - (NSArray *)sets; - (void)setResumptionToken:(NSString *)newResumptionToken; - (NSString *)resumptionToken; - (void)resetSearch; - (void)fetchSets; - (void)fetch; - (void)startDownloadFromURL:(NSURL *)theURL; @end
Update driver version to 8.07.00.18-k
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2014 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.07.00.16-k" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 7 #define QLA_DRIVER_PATCH_VER 0 #define QLA_DRIVER_BETA_VER 0
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2014 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.07.00.18-k" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 7 #define QLA_DRIVER_PATCH_VER 0 #define QLA_DRIVER_BETA_VER 0
Rename delegate from MKMapViewDelegate to REMarkerClusterDelegate
// // DemoViewController.h // REMarkerClustererExample // // Created by Roman Efimov on 7/9/12. // Copyright (c) 2012 Roman Efimov. All rights reserved. // #import <UIKit/UIKit.h> #import "REMarkerClusterer.h" @interface DemoViewController : UIViewController <MKMapViewDelegate> @property (strong, readonly, nonatomic) MKMapView *mapView; @property (strong, readonly, nonatomic) REMarkerClusterer *clusterer; @end
// // DemoViewController.h // REMarkerClustererExample // // Created by Roman Efimov on 7/9/12. // Copyright (c) 2012 Roman Efimov. All rights reserved. // #import <UIKit/UIKit.h> #import "REMarkerClusterer.h" @interface DemoViewController : UIViewController <REMarkerClusterDelegate> @property (strong, readonly, nonatomic) MKMapView *mapView; @property (strong, readonly, nonatomic) REMarkerClusterer *clusterer; @end
Update iOS SDK Minor Version
// ---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // ---------------------------------------------------------------------------- #ifndef WindowsAzureMobileServices_WindowsAzureMobileServices_h #define WindowsAzureMobileServices_WindowsAzureMobileServices_h #import "MSClient.h" #import "MSTable.h" #import "MSQuery.h" #import "MSUser.h" #import "MSFilter.h" #import "MSError.h" #import "MSLoginController.h" #import "MSPush.h" #define WindowsAzureMobileServicesSdkMajorVersion 1 #define WindowsAzureMobileServicesSdkMinorVersion 1 #define WindowsAzureMobileServicesSdkBuildVersion 0 #endif
// ---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // ---------------------------------------------------------------------------- #ifndef WindowsAzureMobileServices_WindowsAzureMobileServices_h #define WindowsAzureMobileServices_WindowsAzureMobileServices_h #import "MSClient.h" #import "MSTable.h" #import "MSQuery.h" #import "MSUser.h" #import "MSFilter.h" #import "MSError.h" #import "MSLoginController.h" #import "MSPush.h" #define WindowsAzureMobileServicesSdkMajorVersion 1 #define WindowsAzureMobileServicesSdkMinorVersion 2 #define WindowsAzureMobileServicesSdkBuildVersion 0 #endif
Check for return value for asprintf
#include <stdio.h> #include <stdlib.h> /* for free */ #include <string.h> /* for strcmp */ #include <strings.h> #include <platform/cbassert.h> static void test_asprintf(void) { char *result = 0; (void)asprintf(&result, "test 1"); cb_assert(strcmp(result, "test 1") == 0); free(result); (void)asprintf(&result, "test %d", 2); cb_assert(strcmp(result, "test 2") == 0); free(result); (void)asprintf(&result, "%c%c%c%c %d", 't', 'e', 's', 't', 3); cb_assert(strcmp(result, "test 3") == 0); free(result); } int main(void) { test_asprintf(); return 0; }
#include <stdio.h> #include <stdlib.h> /* for free */ #include <string.h> /* for strcmp */ #include <strings.h> #include <platform/cbassert.h> static void test_asprintf(void) { char *result = 0; cb_assert(asprintf(&result, "test 1") > 0); cb_assert(strcmp(result, "test 1") == 0); free(result); cb_assert(asprintf(&result, "test %d", 2) > 0); cb_assert(strcmp(result, "test 2") == 0); free(result); cb_assert(asprintf(&result, "%c%c%c%c %d", 't', 'e', 's', 't', 3) > 0); cb_assert(strcmp(result, "test 3") == 0); free(result); } int main(void) { test_asprintf(); return 0; }
Mark Devcoin release version 0.8.9.0.
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 8 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2021 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 9 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2021 // 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
Remove duplicate definition of MessageAuthenticationCode::name()
/* * Base class for message authentiction codes * (C) 1999-2007 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #ifndef BOTAN_MESSAGE_AUTH_CODE_BASE_H__ #define BOTAN_MESSAGE_AUTH_CODE_BASE_H__ #include <botan/buf_comp.h> #include <botan/sym_algo.h> #include <botan/scan_name.h> #include <string> namespace Botan { /** * This class represents Message Authentication Code (MAC) objects. */ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, public SymmetricAlgorithm { public: /** * Verify a MAC. * @param in the MAC to verify as a byte array * @param length the length of param in * @return true if the MAC is valid, false otherwise */ virtual bool verify_mac(const byte in[], size_t length); /** * Get a new object representing the same algorithm as *this */ virtual MessageAuthenticationCode* clone() const = 0; /** * Get the name of this algorithm. * @return name of this algorithm */ virtual std::string name() const = 0; typedef SCAN_Name Spec; }; } #endif
/* * Base class for message authentiction codes * (C) 1999-2007 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #ifndef BOTAN_MESSAGE_AUTH_CODE_BASE_H__ #define BOTAN_MESSAGE_AUTH_CODE_BASE_H__ #include <botan/buf_comp.h> #include <botan/sym_algo.h> #include <botan/scan_name.h> #include <string> namespace Botan { /** * This class represents Message Authentication Code (MAC) objects. */ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, public SymmetricAlgorithm { public: /** * Verify a MAC. * @param in the MAC to verify as a byte array * @param length the length of param in * @return true if the MAC is valid, false otherwise */ virtual bool verify_mac(const byte in[], size_t length); /** * Get a new object representing the same algorithm as *this */ virtual MessageAuthenticationCode* clone() const = 0; typedef SCAN_Name Spec; }; } #endif
Use C calling convention when header is included by C++ code
#ifndef _SHAKE_H_ #define _SHAKE_H_ #include "shake_private.h" struct shakeDev; /* libShake functions */ int shakeInit(); void shakeQuit(); void shakeListDevices(); int shakeNumOfDevices(); shakeDev *shakeOpen(unsigned int id); void shakeClose(shakeDev *dev); int shakeQuery(shakeDev *dev); void shakeSetGain(shakeDev *dev, int gain); void shakeInitEffect(shakeEffect *effect, shakeEffectType type); int shakeUploadEffect(shakeDev *dev, shakeEffect effect); void shakeEraseEffect(shakeDev *dev, int id); void shakePlay(shakeDev *dev, int id); void shakeStop(shakeDev *dev, int id); #endif /* _SHAKE_H_ */
#ifndef _SHAKE_H_ #define _SHAKE_H_ #ifdef __cplusplus extern "C" { #endif #include "shake_private.h" struct shakeDev; /* libShake functions */ int shakeInit(); void shakeQuit(); void shakeListDevices(); int shakeNumOfDevices(); shakeDev *shakeOpen(unsigned int id); void shakeClose(shakeDev *dev); int shakeQuery(shakeDev *dev); void shakeSetGain(shakeDev *dev, int gain); void shakeInitEffect(shakeEffect *effect, shakeEffectType type); int shakeUploadEffect(shakeDev *dev, shakeEffect effect); void shakeEraseEffect(shakeDev *dev, int id); void shakePlay(shakeDev *dev, int id); void shakeStop(shakeDev *dev, int id); #ifdef __cplusplus } #endif #endif /* _SHAKE_H_ */
Add replacement functionality following initialization segment
#! /usr/bin/tcc -run #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct slot { ssize_t size; char *row; } slot; slot line; slot *text; char *ptr; int main(void) { ptr = "this is my story"; line.row = ptr; line.size = strlen(ptr); text = malloc(10*sizeof(slot)); text[0] = line; printf("text[0].row = %s\n",text[0].row); ptr = "this is my song"; line.row = ptr; line.size = strlen(ptr); text[1] = line; printf("text[1].row = %s\n",text[1].row); printf("text[0].row = %s\n",text[0].row); ptr = "tell me your song"; line.row = ptr; line.size = strlen(ptr); text[3] = line; printf("text[3].row = %s\n",text[3].row); return 0; }
#! /usr/bin/tcc -run #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct slot { ssize_t size; char *row; } slot; slot line; slot *text; slot *old; slot *new; char *ptr; int main(void) { text = malloc(10*sizeof(slot)); old = malloc(10*sizeof(slot)); new = malloc(10*sizeof(slot)); ptr = "this is my story"; line.row = ptr; line.size = strlen(ptr); text[0] = line; ptr = "this is my song"; line.row = ptr; line.size = strlen(ptr); text[1] = line; ptr = "tell me your song"; line.row = ptr; line.size = strlen(ptr); text[3] = line; printf("text[3].row = %s\n",text[3].row); old = text; int j; for (j = 0; j < 10; j++) {old[j] = text[j];} printf("old[1].row = %s\n",old[1].row); printf("old[3].row = %s\n",old[3].row); slot newline; ptr = "hello world"; newline.row = ptr; newline.size = strlen(ptr); for (j = 0; j < 10; j++) {if (j != 3) {old[j] = text[j];} else {old[j] = newline;} } printf("\n"); printf("old[3].row = %s\n",old[3].row); printf("old[1].row = %s\n",old[1].row); return 0; }
Add documentation to Point3 typedefs
/****************************************************************************** ** ** Copyright (C) 2009-2011 Kyle Lutz <kyle.r.lutz@gmail.com> ** ** This file is part of chemkit. For more information see ** <http://www.chemkit.org>. ** ** chemkit 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 3 of the License, or ** (at your option) any later version. ** ** chemkit 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 chemkit. If not, see <http://www.gnu.org/licenses/>. ** ******************************************************************************/ #ifndef CHEMKIT_POINT3_H #define CHEMKIT_POINT3_H #include "chemkit.h" #include "genericpoint.h" namespace chemkit { /// A three-dimensional point. typedef GenericPoint<Float> Point3; typedef GenericPoint<float> Point3f; typedef GenericPoint<double> Point3d; } // end chemkit namespace #endif // CHEMKIT_POINT3_H
/****************************************************************************** ** ** Copyright (C) 2009-2011 Kyle Lutz <kyle.r.lutz@gmail.com> ** ** This file is part of chemkit. For more information see ** <http://www.chemkit.org>. ** ** chemkit 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 3 of the License, or ** (at your option) any later version. ** ** chemkit 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 chemkit. If not, see <http://www.gnu.org/licenses/>. ** ******************************************************************************/ #ifndef CHEMKIT_POINT3_H #define CHEMKIT_POINT3_H #include "chemkit.h" #include "genericpoint.h" namespace chemkit { /// A three-dimensional point. typedef GenericPoint<Float> Point3; /// A three-dimensional point containing \c float values. typedef GenericPoint<float> Point3f; /// A three-dimensional point containing \c double values. typedef GenericPoint<double> Point3d; } // end chemkit namespace #endif // CHEMKIT_POINT3_H
Fix tls value passed during clone
/* Copyright (C) 2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/>.  */ /* Value passed to 'clone' for initialization of the thread register. */ #define TLS_VALUE (pd + 1) /* Get the real implementation. */ #include <sysdeps/pthread/createthread.c>
/* Copyright (C) 2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/>.  */ /* Value passed to 'clone' for initialization of the thread register. */ #define TLS_VALUE ((void *) (pd) \ + TLS_PRE_TCB_SIZE + TLS_INIT_TCB_SIZE) /* Get the real implementation. */ #include <sysdeps/pthread/createthread.c>
Fix error result handling in os.rmdir()
/** * \file os_rmdir.c * \brief Remove a subdirectory. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project */ #include <stdlib.h> #include "premake.h" int os_rmdir(lua_State* L) { int z; const char* path = luaL_checkstring(L, 1); #if PLATFORM_WINDOWS z = RemoveDirectory(path); #else z = rmdir(path); #endif if (!z) { lua_pushnil(L); lua_pushfstring(L, "unable to remove directory '%s'", path); return 2; } else { lua_pushboolean(L, 1); return 1; } }
/** * \file os_rmdir.c * \brief Remove a subdirectory. * \author Copyright (c) 2002-2013 Jason Perkins and the Premake project */ #include <stdlib.h> #include "premake.h" int os_rmdir(lua_State* L) { int z; const char* path = luaL_checkstring(L, 1); #if PLATFORM_WINDOWS z = RemoveDirectory(path); #else z = (0 == rmdir(path)); #endif if (!z) { lua_pushnil(L); lua_pushfstring(L, "unable to remove directory '%s'", path); return 2; } else { lua_pushboolean(L, 1); return 1; } }
Change session length to 60s
/* * Copyright 2016 Adam Chyła, adam@chyla.org * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef SRC_APACHE_ANALYZER_DETAIL_SESSION_LENGTH_H #define SRC_APACHE_ANALYZER_DETAIL_SESSION_LENGTH_H namespace apache { namespace analyzer { namespace detail { constexpr int SESSION_LENGTH = 3 * 60; } } } #endif /* SRC_APACHE_ANALYZER_DETAIL_SESSION_LENGTH_H */
/* * Copyright 2016 Adam Chyła, adam@chyla.org * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef SRC_APACHE_ANALYZER_DETAIL_SESSION_LENGTH_H #define SRC_APACHE_ANALYZER_DETAIL_SESSION_LENGTH_H namespace apache { namespace analyzer { namespace detail { constexpr int SESSION_LENGTH = 60; } } } #endif /* SRC_APACHE_ANALYZER_DETAIL_SESSION_LENGTH_H */
Remove getZip() which got there by mistake
#ifndef QUAZIP_TEST_QUAZIP_H #define QUAZIP_TEST_QUAZIP_H #include <QObject> class TestQuaZip: public QObject { Q_OBJECT private slots: void getFileList_data(); void getFileList(); void getZip(); }; #endif // QUAZIP_TEST_QUAZIP_H
#ifndef QUAZIP_TEST_QUAZIP_H #define QUAZIP_TEST_QUAZIP_H #include <QObject> class TestQuaZip: public QObject { Q_OBJECT private slots: void getFileList_data(); void getFileList(); }; #endif // QUAZIP_TEST_QUAZIP_H
Delete main widget in BasicUi
#ifndef BASICUI_H_ #define BASICUI_H_ #include <QMainWindow> class MainWidget; class Workspace; class BasicUi: public QMainWindow { Q_OBJECT public: BasicUi(QWidget *parent = 0); void setWorkspace(Workspace *); private: MainWidget *mainWidget; // QGridLayout *layout; // QPushButton *editModeButton; // EditWidget *editWidget; // PlayWidget *playWidget; // bool editMode; // Workspace *wsp; // Controller *controller; }; #endif
#ifndef BASICUI_H_ #define BASICUI_H_ #include <QMainWindow> class MainWidget; class Workspace; class BasicUi: public QMainWindow { Q_OBJECT public: BasicUi(QWidget *parent = 0); void setWorkspace(Workspace *); ~BasicUi(){ if(NULL != mainWidget) delete mainWidget; } private: MainWidget *mainWidget; // QGridLayout *layout; // QPushButton *editModeButton; // EditWidget *editWidget; // PlayWidget *playWidget; // bool editMode; // Workspace *wsp; // Controller *controller; }; #endif
Add simple test case to make sure driver can generate executables. - Hopefully Chris can pardon one executable test.
// RUN: clang-driver -ccc-echo -o %t %s &> %t.log && // Make sure we used clang. // RUN: grep 'clang" .*hello.c' %t.log && // RUN: %t > %t.out && // RUN: grep "I'm a little driver, short and stout." %t.out #include <stdio.h> int main() { printf("I'm a little driver, short and stout."); return 0; }
Add missing new files for revision 32092
#include <complex> #ifndef __hpux using namespace std; #endif #pragma create TClass std::complex<int>+; #pragma create TClass std::complex<long>+; #pragma create TClass std::complex<float>+; #pragma create TClass std::complex<double>+; #ifdef G__NATIVELONGLONG #pragma create TClass std::complex<long long>+; // #pragma create TClass std::complex<long double>+; #endif
Initialize argv vectors using compound literals.
#include "pipe.h" #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { /* Command argument vectors. */ char *more_argv[] = { "more", NULL }; char *less_argv[] = { "less", NULL }; char *pager_argv[] = { getenv("PAGER"), NULL }; char *sort_argv[] = { "sort", NULL }; char *printenv_argv[] = { "printenv", NULL }; char **grep_argv = argv; grep_argv[0] = "grep"; /* Construct pipeline. */ /* file argv err next fallback */ command_t more = { "more", more_argv, 0, NULL, NULL}; command_t less = { "less", less_argv, 0, NULL, &more }; command_t pager = { getenv("PAGER"), pager_argv, 0, NULL, &less }; command_t sort = { "sort", sort_argv, 0, &pager, NULL }; command_t grep = { "grep", grep_argv, 0, &sort, NULL }; command_t printenv = { "printenv", printenv_argv, 0, &sort, NULL }; if (argc > 1) { /* Arguments given: Run grep as well. */ printenv.next = &grep; } /* Run pipeline. */ run_pipeline(&printenv, STDIN_FILENO); return 0; }
#include "pipe.h" #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { char *pager_env = getenv("PAGER"); /* Construct pipeline. */ /* file argv err next fallback */ command_t more = {"more", (char *[]){"more", NULL}, 0, NULL, NULL}; command_t less = {"less", (char *[]){"less", NULL}, 0, NULL, &more}; command_t pager = {pager_env, (char *[]){pager_env, NULL}, 0, NULL, &less}; command_t sort = {"sort", (char *[]){"sort", NULL}, 0, &pager, NULL}; command_t grep = {"grep", argv, 0, &sort, NULL}; command_t printenv = {"printenv", (char *[]){"printenv", NULL}, 0, &sort, NULL}; if (argc > 1) { /* Arguments given: Run grep as well. */ printenv.next = &grep; argv[0] = "grep"; } /* Run pipeline. */ run_pipeline(&printenv, STDIN_FILENO); return 0; }
Prepare for more SEE tests
/* Make sure assert is not disabled */ #ifdef NDEBUG #undef NDEBUG #endif #include <stdio.h> #include <assert.h> #include "see.h" #include "fen.h" void test_see() { chess_state_t s; int result; int pos_from = D3; int pos_to = E5; int type = KNIGHT; int capture_type = PAWN; int special = MOVE_CAPTURE; move_t move = pos_from << MOVE_POS_FROM_SHIFT | pos_to << MOVE_POS_TO_SHIFT | type << MOVE_TYPE_SHIFT | capture_type << MOVE_CAPTURE_TYPE_SHIFT | special << MOVE_SPECIAL_FLAGS_SHIFT; assert(FEN_read(&s, "1k1r3q/1ppn3p/p4b2/4p3/8/P2N2P1/1PP1R1BP/2K1Q3 w - -")); result = see(&s, move); assert(result == -225/5); } int main() { BITBOARD_init(); test_see(); return 0; }
/* Make sure assert is not disabled */ #ifdef NDEBUG #undef NDEBUG #endif #include <stdio.h> #include <assert.h> #include "see.h" #include "fen.h" void test_see(const char *fen, short expected_result) { chess_state_t s; int result; int pos_from = D3; int pos_to = E5; int type = KNIGHT; int capture_type = PAWN; int special = MOVE_CAPTURE; move_t move = pos_from << MOVE_POS_FROM_SHIFT | pos_to << MOVE_POS_TO_SHIFT | type << MOVE_TYPE_SHIFT | capture_type << MOVE_CAPTURE_TYPE_SHIFT | special << MOVE_SPECIAL_FLAGS_SHIFT; assert(FEN_read(&s, fen)); result = see(&s, move); printf("%s\n", fen); printf("\tresult %d (%d centipawns)\n", result, result*5); assert(result == expected_result); } int main() { BITBOARD_init(); test_see("1k1r3q/1ppn3p/p4b2/4p3/8/P2N2P1/1PP1R1BP/2K1Q3 w - -", -225/5); return 0; }
Resolve 'control reaches end of non-void function'
#include <inttypes.h> #include <stdlib.h> #include <unistd.h> #include <stdbool.h> #include "tock.h" #pragma GCC diagnostic ignored "-Wunused-parameter" void yield_for(bool *cond) { while(!*cond) { yield(); } } void yield() { asm volatile("push {lr}\nsvc 0\npop {pc}" ::: "memory", "r0"); } int subscribe(uint32_t driver, uint32_t subscribe, subscribe_cb cb, void* userdata) { asm volatile("svc 1\nbx lr" ::: "memory", "r0"); } int command(uint32_t driver, uint32_t command, int data) { asm volatile("svc 2\nbx lr" ::: "memory", "r0"); } int allow(uint32_t driver, uint32_t allow, void* ptr, size_t size) { asm volatile("svc 3\nbx lr" ::: "memory", "r0"); } int memop(uint32_t op_type, int arg1) { asm volatile("svc 4\nbx lr" ::: "memory", "r0"); } bool driver_exists(uint32_t driver) { int ret = command(driver, 0, 0); return ret >= 0; }
#include <inttypes.h> #include <stdlib.h> #include <unistd.h> #include <stdbool.h> #include "tock.h" #pragma GCC diagnostic ignored "-Wunused-parameter" void yield_for(bool *cond) { while(!*cond) { yield(); } } void yield() { asm volatile("push {lr}\nsvc 0\npop {pc}" ::: "memory", "r0"); } int subscribe(uint32_t driver, uint32_t subscribe, subscribe_cb cb, void* userdata) { register int ret __asm__ ("r0"); asm volatile("svc 1" ::: "memory", "r0"); return ret; } int command(uint32_t driver, uint32_t command, int data) { register int ret __asm__ ("r0"); asm volatile("svc 2\nbx lr" ::: "memory", "r0"); return ret; } int allow(uint32_t driver, uint32_t allow, void* ptr, size_t size) { register int ret __asm__ ("r0"); asm volatile("svc 3\nbx lr" ::: "memory", "r0"); return ret; } int memop(uint32_t op_type, int arg1) { register int ret __asm__ ("r0"); asm volatile("svc 4\nbx lr" ::: "memory", "r0"); return ret; } bool driver_exists(uint32_t driver) { int ret = command(driver, 0, 0); return ret >= 0; }
Add first stub for HSM unit test
#include "mbb/test.h" #include "mbb/hsm.h" #include "mbb/debug.h" MHSM_DEFINE_STATE(state_a, NULL); MHSM_DEFINE_STATE(state_a1, &state_a); MHSM_DEFINE_STATE(state_a11, &state_a1); mhsm_state_t *state_a_fun(mhsm_hsm_t *hsm, mhsm_event_t event) { switch (event.id) { case MHSM_EVENT_INITIAL: return &state_a1; } return &state_a; } mhsm_state_t *state_a1_fun(mhsm_hsm_t *hsm, mhsm_event_t event) { switch (event.id) { case MHSM_EVENT_INITIAL: return &state_a11; } return &state_a1; } mhsm_state_t *state_a11_fun(mhsm_hsm_t *hsm, mhsm_event_t event) { switch (event.id) { case MHSM_EVENT_ENTRY: MDBG_PRINT_LN("a11 entry"); break; } return &state_a11; } char *test_initial_transition() { mhsm_hsm_t hsm; mhsm_initialise(&hsm, NULL, &state_a); mhsm_dispatch_event(&hsm, MHSM_EVENT_INITIAL); MUNT_ASSERT(mhsm_current_state(&hsm) == &state_a11); return 0; }
Fix inclusion order, per Andreas.
/*------------------------------------------------------------------------- * * pqsignal.c * reliable BSD-style signal(2) routine stolen from RWW who stole it * from Stevens... * * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.15 2002/06/20 20:29:54 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other * things need it... * *------------------------------------------------------------------------- */ #include <stdlib.h> #include <signal.h> #include "pqsignal.h" pqsigfunc pqsignal(int signo, pqsigfunc func) { #if !defined(HAVE_POSIX_SIGNALS) return signal(signo, func); #else struct sigaction act, oact; act.sa_handler = func; sigemptyset(&act.sa_mask); act.sa_flags = 0; if (signo != SIGALRM) act.sa_flags |= SA_RESTART; if (sigaction(signo, &act, &oact) < 0) return SIG_ERR; return oact.sa_handler; #endif /* !HAVE_POSIX_SIGNALS */ }
/*------------------------------------------------------------------------- * * pqsignal.c * reliable BSD-style signal(2) routine stolen from RWW who stole it * from Stevens... * * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.16 2002/11/04 14:27:21 tgl Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other * things need it... * *------------------------------------------------------------------------- */ #include "pqsignal.h" #include <signal.h> pqsigfunc pqsignal(int signo, pqsigfunc func) { #if !defined(HAVE_POSIX_SIGNALS) return signal(signo, func); #else struct sigaction act, oact; act.sa_handler = func; sigemptyset(&act.sa_mask); act.sa_flags = 0; if (signo != SIGALRM) act.sa_flags |= SA_RESTART; if (sigaction(signo, &act, &oact) < 0) return SIG_ERR; return oact.sa_handler; #endif /* !HAVE_POSIX_SIGNALS */ }
Use the XirSys defaults for room and application.
// // PHCredentials.h // PerchRTC // // Created by Sam Symons on 2015-05-08. // Copyright (c) 2015 Perch Communications. All rights reserved. // #ifndef PerchRTC_PHCredentials_h #define PerchRTC_PHCredentials_h #error Please enter your XirSys credentials (http://xirsys.com/pricing/) static NSString *kPHConnectionManagerDomain = @""; static NSString *kPHConnectionManagerApplication = @""; static NSString *kPHConnectionManagerXSUsername = @""; static NSString *kPHConnectionManagerXSSecretKey = @""; #ifdef DEBUG static NSString *kPHConnectionManagerDefaultRoomName = @""; #else static NSString *kPHConnectionManagerDefaultRoomName = @""; #endif #endif
// // PHCredentials.h // PerchRTC // // Created by Sam Symons on 2015-05-08. // Copyright (c) 2015 Perch Communications. All rights reserved. // #ifndef PerchRTC_PHCredentials_h #define PerchRTC_PHCredentials_h #error Please enter your XirSys credentials (http://xirsys.com/pricing/) static NSString *kPHConnectionManagerDomain = @""; static NSString *kPHConnectionManagerApplication = @"default"; static NSString *kPHConnectionManagerXSUsername = @""; static NSString *kPHConnectionManagerXSSecretKey = @""; #ifdef DEBUG static NSString *kPHConnectionManagerDefaultRoomName = @"default"; #else static NSString *kPHConnectionManagerDefaultRoomName = @"default"; #endif #endif
Make test more robust by writing stdout/stderr to different files.
// RUN: c-index-test -test-load-source local %s -ivfsoverlay %t/does-not-exist.yaml &> %t.out // RUN: FileCheck -check-prefix=STDERR %s < %t.out // STDERR: fatal error: virtual filesystem overlay file '{{.*}}' not found // RUN: FileCheck %s < %t.out // CHECK: missing_vfs.c:[[@LINE+1]]:6: FunctionDecl=foo:[[@LINE+1]]:6 void foo(void);
// RUN: c-index-test -test-load-source local %s -ivfsoverlay %t/does-not-exist.yaml > %t.stdout 2> %t.stderr // RUN: FileCheck -check-prefix=STDERR %s < %t.stderr // STDERR: fatal error: virtual filesystem overlay file '{{.*}}' not found // RUN: FileCheck %s < %t.stdout // CHECK: missing_vfs.c:[[@LINE+1]]:6: FunctionDecl=foo:[[@LINE+1]]:6 void foo(void);
Call the c functions instead of passing a pointer
#include <Python.h> #include <sys/personality.h> int Cget_personality(void) { unsigned long int persona = 0xffffffff; return personality(persona); } static PyObject* get_personality(PyObject* self) { return Py_BuildValue("i", Cget_personality); } int Cset_personality(void) { unsigned long int persona = READ_IMPLIES_EXEC; return personality(persona); } static PyObject* set_personality(PyObject* self) { return Py_BuildValue("i", Cset_personality); } static PyMethodDef personality_methods[] = { {"get_personality", (PyCFunction)get_personality, METH_NOARGS, "Returns the personality value"}, {"set_personality", (PyCFunction)set_personality, METH_NOARGS, "Sets the personality value"}, /* {"version", (PyCFunction)version, METH_NOARGS, "Returns the version number"}, */ {NULL, NULL, 0, NULL} }; static struct PyModuleDef pypersonality = { PyModuleDef_HEAD_INIT, "personality", "Module to manipulate process execution domain", -1, personality_methods }; PyMODINIT_FUNC PyInit_pypersonality(void) { return PyModule_Create(&pypersonality); }
#include <Python.h> #include <sys/personality.h> #include <stdint.h> int Cget_personality(void) { unsigned long persona = 0xffffffffUL; return personality(persona); } static PyObject* get_personality(PyObject* self) { return Py_BuildValue("i", Cget_personality()); } int Cset_personality(unsigned long persona) { return personality(persona); } static PyObject* set_personality(PyObject* self, PyObject *args) { unsigned long persona = READ_IMPLIES_EXEC; //Py_Args_ParseTuple(args, "i", &persona); return Py_BuildValue("i", Cset_personality(persona)); } static PyMethodDef personality_methods[] = { {"get_personality", (PyCFunction)get_personality, METH_NOARGS, "Returns the personality value"}, {"set_personality", (PyCFunction)set_personality, METH_NOARGS, "Sets the personality value"}, /* {"version", (PyCFunction)version, METH_NOARGS, "Returns the version number"}, */ {NULL, NULL, 0, NULL} }; static struct PyModuleDef pypersonality = { PyModuleDef_HEAD_INIT, "personality", "Module to manipulate process execution domain", -1, personality_methods }; PyMODINIT_FUNC PyInit_pypersonality(void) { return PyModule_Create(&pypersonality); }
Make header file compatible with C++
#ifndef PG_QUERY_H #define PG_QUERY_H typedef struct { char* message; // exception message char* filename; // source of exception (e.g. parse.l) int lineno; // source of exception (e.g. 104) int cursorpos; // char in query at which exception occurred } PgQueryError; typedef struct { char* parse_tree; char* stderr_buffer; PgQueryError* error; } PgQueryParseResult; typedef struct { char* normalized_query; PgQueryError* error; } PgQueryNormalizeResult; void pg_query_init(void); PgQueryNormalizeResult pg_query_normalize(char* input); PgQueryParseResult pg_query_parse(char* input); #endif
#ifndef PG_QUERY_H #define PG_QUERY_H typedef struct { char* message; // exception message char* filename; // source of exception (e.g. parse.l) int lineno; // source of exception (e.g. 104) int cursorpos; // char in query at which exception occurred } PgQueryError; typedef struct { char* parse_tree; char* stderr_buffer; PgQueryError* error; } PgQueryParseResult; typedef struct { char* normalized_query; PgQueryError* error; } PgQueryNormalizeResult; #ifdef __cplusplus extern "C" { #endif void pg_query_init(void); PgQueryNormalizeResult pg_query_normalize(char* input); PgQueryParseResult pg_query_parse(char* input); #ifdef __cplusplus } #endif #endif
Remove superfluous default db definition
#ifndef TEST_HELPER_C #define TEST_HELPER_C (1) #include "MMDB.h" #define MMDB_DEFAULT_DATABASE "/usr/local/share/GeoIP/GeoIP2-City.mmdb" typedef union { struct in_addr v4; struct in6_addr v6; } in_addrX; char *get_test_db_fname(void); void ip_to_num(MMDB_s * mmdb, char *ipstr, in_addrX * dest_ipnum); int dbl_cmp(double a, double b); #endif
#ifndef TEST_HELPER_C #define TEST_HELPER_C (1) #include "MMDB.h" typedef union { struct in_addr v4; struct in6_addr v6; } in_addrX; char *get_test_db_fname(void); void ip_to_num(MMDB_s * mmdb, char *ipstr, in_addrX * dest_ipnum); int dbl_cmp(double a, double b); #endif
Check for under/overflow in Timeout constructor. Codestyle fixes.
#ifndef CPR_TIMEOUT_H #define CPR_TIMEOUT_H #include <cstdint> #include <chrono> namespace cpr { class Timeout { public: Timeout(const std::chrono::milliseconds& timeout) : ms(timeout) {} Timeout(const std::int32_t& timeout) : ms(timeout) {} std::chrono::milliseconds ms; }; } // namespace cpr #endif
#ifndef CPR_TIMEOUT_H #define CPR_TIMEOUT_H #include <cstdint> #include <chrono> #include <limits> #include <stdexcept> namespace cpr { class Timeout { public: Timeout(const std::chrono::milliseconds& duration) : ms{duration} { if(ms.count() > std::numeric_limits<long>::max()) { throw std::overflow_error("cpr::Timeout: timeout value overflow."); } if(ms.count() < std::numeric_limits<long>::min()) { throw std::underflow_error("cpr::Timeout: timeout value underflow."); } } Timeout(const std::int32_t& milliseconds) : Timeout{std::chrono::milliseconds(milliseconds)} {} std::chrono::milliseconds ms; }; } // namespace cpr #endif
Fix printf format, remove unused variables
/* * Copyright (c) 2016, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #pragma once #include <string> #include <vector> #include <folly/Conv.h> namespace facebook { namespace memcache { class McReply; namespace cpp2 { class McStatsReply; } template <class ThriftType> class TypedThriftReply; class StatsReply { public: template <typename V> void addStat(folly::StringPiece name, V value) { stats_.push_back(make_pair(name.str(), folly::to<std::string>(value))); } McReply getMcReply(); TypedThriftReply<cpp2::McStatsReply> getReply(); private: std::vector<std::pair<std::string, std::string>> stats_; }; }} // facebook::memcache
/* * Copyright (c) 2016, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #pragma once #include <string> #include <vector> #include <folly/Conv.h> namespace facebook { namespace memcache { class McReply; namespace cpp2 { class McStatsReply; } template <class ThriftType> class TypedThriftReply; class StatsReply { public: template <typename V> void addStat(folly::StringPiece name, V&& value) { stats_.emplace_back(name.str(), folly::to<std::string>(std::forward<V>(value))); } McReply getMcReply(); TypedThriftReply<cpp2::McStatsReply> getReply(); private: std::vector<std::pair<std::string, std::string>> stats_; }; }} // facebook::memcache
Disable test; what it's testing for is wrong.
// RUN: %llvmgcc %s -S -o - -fno-math-errno | grep llvm.sqrt #include <math.h> float foo(float X) { // Check that this compiles to llvm.sqrt when errno is ignored. return sqrtf(X); }
// RUN: %llvmgcc %s -S -o - -fno-math-errno | grep llvm.sqrt // llvm.sqrt has undefined behavior on negative inputs, so it is // inappropriate to translate C/C++ sqrt to this. // XFAIL: * #include <math.h> float foo(float X) { // Check that this compiles to llvm.sqrt when errno is ignored. return sqrtf(X); }
Add compile time assert macro
/** * Thanks to http://stackoverflow.com/users/68204/rberteig * http://stackoverflow.com/questions/807244/c-compiler-asserts-how-to-implement */ /** A compile time assertion check. * * Validate at compile time that the predicate is true without * generating code. This can be used at any point in a source file * where typedef is legal. * * On success, compilation proceeds normally. * * On failure, attempts to typedef an array type of negative size. The * offending line will look like * typedef assertion_failed_file_h_42[-1] * where file is the content of the second parameter which should * typically be related in some obvious way to the containing file * name, 42 is the line number in the file on which the assertion * appears, and -1 is the result of a calculation based on the * predicate failing. * * \param predicate The predicate to test. It must evaluate to * something that can be coerced to a normal C boolean. * * \param file A sequence of legal identifier characters that should * uniquely identify the source file in which this condition appears. */ #define CASSERT(predicate, file) _impl_CASSERT_LINE(predicate,__LINE__,file) #define _impl_PASTE(a,b) a##b #define _impl_CASSERT_LINE(predicate, line, file) \ typedef char _impl_PASTE(assertion_failed_##file##_,line)[2*!!(predicate)-1];
Add flag for emacs so it realizes it's C++ code
//*************************************************************************** // class Unique: // Mixin class for classes that should never be copied. // // Purpose: // This mixin disables both the copy constructor and the // assignment operator. It also provides a default equality operator. // // History: // 09/24/96 - vadve - Created (adapted from dHPF). // //*************************************************************************** #ifndef UNIQUE_H #define UNIQUE_H #include <assert.h> class Unique { protected: /*ctor*/ Unique () {} /*dtor*/ virtual ~Unique () {} public: virtual bool operator== (const Unique& u1) const; virtual bool operator!= (const Unique& u1) const; private: // // Disable the copy constructor and the assignment operator // by making them both private: // /*ctor*/ Unique (Unique&) { assert(0); } virtual Unique& operator= (const Unique& u1) { assert(0); return *this; } }; // Unique object equality. inline bool Unique::operator==(const Unique& u2) const { return (bool) (this == &u2); } // Unique object inequality. inline bool Unique::operator!=(const Unique& u2) const { return (bool) !(this == &u2); } #endif
//************************************************************-*- C++ -*- // class Unique: // Mixin class for classes that should never be copied. // // Purpose: // This mixin disables both the copy constructor and the // assignment operator. It also provides a default equality operator. // // History: // 09/24/96 - vadve - Created (adapted from dHPF). // //*************************************************************************** #ifndef UNIQUE_H #define UNIQUE_H #include <assert.h> class Unique { protected: /*ctor*/ Unique () {} /*dtor*/ virtual ~Unique () {} public: virtual bool operator== (const Unique& u1) const; virtual bool operator!= (const Unique& u1) const; private: // // Disable the copy constructor and the assignment operator // by making them both private: // /*ctor*/ Unique (Unique&) { assert(0); } virtual Unique& operator= (const Unique& u1) { assert(0); return *this; } }; // Unique object equality. inline bool Unique::operator==(const Unique& u2) const { return (bool) (this == &u2); } // Unique object inequality. inline bool Unique::operator!=(const Unique& u2) const { return (bool) !(this == &u2); } #endif
Fix GCC bug based code (allows to compile with clang)
/* Chrome Linux plugin * * This software is released under either the GNU Library General Public * License (see LICENSE.LGPL). * * Note that the only valid version of the LGPL license as far as this * project is concerned is the original GNU Library General Public License * Version 2.1, February 1999 */ #ifndef LABELS_H #define LABELS_H #define USER_CANCEL 1 #define READER_NOT_FOUND 5 #define UNKNOWN_ERROR 5 #define CERT_NOT_FOUND 2 #define INVALID_HASH 17 #define ONLY_HTTPS_ALLOWED 19 #include <map> #include <string> #include <vector> class Labels { private: int selectedLanguage; std::map<std::string,std::string[3]> labels; std::map<int,std::string[3]> errors; std::map<std::string, int> languages; void init(); public: Labels(); void setLanguage(std::string language); std::string get(std::string labelKey); std::string getError(int errorCode); }; extern Labels l10nLabels; #endif /* LABELS_H */
/* Chrome Linux plugin * * This software is released under either the GNU Library General Public * License (see LICENSE.LGPL). * * Note that the only valid version of the LGPL license as far as this * project is concerned is the original GNU Library General Public License * Version 2.1, February 1999 */ #ifndef LABELS_H #define LABELS_H #define USER_CANCEL 1 #define READER_NOT_FOUND 5 #define UNKNOWN_ERROR 5 #define CERT_NOT_FOUND 2 #define INVALID_HASH 17 #define ONLY_HTTPS_ALLOWED 19 #include <map> #include <string> #include <vector> class Labels { private: int selectedLanguage; std::map<std::string,std::vector<std::string> > labels; std::map<int,std::vector<std::string> > errors; std::map<std::string, int> languages; void init(); public: Labels(); void setLanguage(std::string language); std::string get(std::string labelKey); std::string getError(int errorCode); }; extern Labels l10nLabels; #endif /* LABELS_H */
Test for rev 73205 (PR 4349)
// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep svars2 | grep {\\\[2 x \\\[2 x i8\\\]\\\]} // RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep svars2 | grep {i32 1} | count 1 // RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep svars3 | grep {\\\[2 x i16\\\]} // RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep svars3 | grep {i32 1} | count 1 // RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep svars4 | grep {\\\[2 x \\\[2 x i8\\\]\\\]} | count 1 // RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep svars4 | grep {i32 1, i32 1} | count 1 // PR 4349 union reg { unsigned char b[2][2]; unsigned short w[2]; unsigned int d; }; struct cpu { union reg pc; }; extern struct cpu cpu; struct svar { void *ptr; }; struct svar svars1[] = { { &((cpu.pc).w[0]) } }; struct svar svars2[] = { { &((cpu.pc).b[0][1]) } }; struct svar svars3[] = { { &((cpu.pc).w[1]) } }; struct svar svars4[] = { { &((cpu.pc).b[1][1]) } };
Remove abs_to_virt() now all users have been fixed
#ifndef _ASM_POWERPC_ABS_ADDR_H #define _ASM_POWERPC_ABS_ADDR_H #ifdef __KERNEL__ /* * c 2001 PPC 64 Team, IBM Corp * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include <linux/memblock.h> #include <asm/types.h> #include <asm/page.h> #include <asm/prom.h> /* Convenience macros */ #define virt_to_abs(va) __pa(va) #define abs_to_virt(aa) __va(aa) #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_ABS_ADDR_H */
#ifndef _ASM_POWERPC_ABS_ADDR_H #define _ASM_POWERPC_ABS_ADDR_H #ifdef __KERNEL__ /* * c 2001 PPC 64 Team, IBM Corp * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include <linux/memblock.h> #include <asm/types.h> #include <asm/page.h> #include <asm/prom.h> /* Convenience macros */ #define virt_to_abs(va) __pa(va) #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_ABS_ADDR_H */
Include std headers instead of C ones
// // Created by bentoo on 29.11.16. // #ifndef GAME_ASSERT_H #define GAME_ASSERT_H #include <assert.h> #include <cstdio> #include <cstdlib> #include <utility> #include "DebugSourceInfo.h" #ifdef _MSC_VER #define YAGE_BREAK __debugbreak() #elif __MINGW32__ #define YAGE_BREAK __builtin_trap() #else #include <signal.h> #define YAGE_BREAK raise(SIGTRAP) #endif #ifndef NDEBUG #define YAGE_ASSERT(predicate, message, ... ) (predicate) ? ((void)0) \ : (Utils::Assert(DEBUG_SOURCE_INFO, message, ##__VA_ARGS__), YAGE_BREAK, ((void)0)) #else #define YAGE_ASSERT(predicate, message, ... ) (void(0)) #endif namespace Utils { struct Assert { static char buffer[256]; template <typename ... Args> Assert(Utils::DebugSourceInfo info, const char* message, Args&& ... args) { std::snprintf(buffer, sizeof(buffer), message, std::forward<Args>(args)...); std::fprintf(stderr, "Assert failed!\n\tfile %s, line %zu,\nreason : %s", info.file, info.line, buffer); } }; } #endif //GAME_ASSERT_H
// // Created by bentoo on 29.11.16. // #ifndef GAME_ASSERT_H #define GAME_ASSERT_H #include <cassert> #include <cstdio> #include <cstdlib> #include <utility> #include "DebugSourceInfo.h" #ifdef _MSC_VER #define YAGE_BREAK __debugbreak() #elif __MINGW32__ #define YAGE_BREAK __builtin_trap() #else #include <csignal> #define YAGE_BREAK raise(SIGTRAP) #endif #ifndef NDEBUG #define YAGE_ASSERT(predicate, message, ... ) (predicate) ? ((void)0) \ : (Utils::Assert(DEBUG_SOURCE_INFO, message, ##__VA_ARGS__), YAGE_BREAK, ((void)0)) #else #define YAGE_ASSERT(predicate, message, ... ) (void(0)) #endif namespace Utils { struct Assert { static char buffer[256]; template <typename ... Args> Assert(Utils::DebugSourceInfo info, const char* message, Args&& ... args) { std::snprintf(buffer, sizeof(buffer), message, std::forward<Args>(args)...); std::fprintf(stderr, "Assert failed!\n\tfile %s, line %zu,\nreason : %s", info.file, info.line, buffer); } }; } #endif //GAME_ASSERT_H
Add list of functions for SDP power supply
#ifndef __SDP2XXX_H___ #define __SDP2XXX_H___ "SESS__\r" "ENDS__\r" "CCOM__??\r" "GCOM__\r" "GMAX__\r" "GOVP__\r" "GETD__\r" "GETS__\r" "GETM__\r" "GETM__?\r" "GETP__\r" "GETP__?\r" "GPAL__\r" "VOLT__?\r" "CURR__?\r" "SOVP__?\r" "SOUT__1\r" "SOUT__0\r" "POWW__?\r" "POWW__?\r" "PROM__?\r" "PROP__?\r" "RUNM__?\r" "RUNP__?\r" "STOP__\r" #endif
Add missing file for ARCH = AVR.
/* * RELIC is an Efficient LIbrary for Cryptography * Copyright (C) 2007-2011 RELIC Authors * * This file is part of RELIC. RELIC is legal property of its developers, * whose names are not listed here. Please refer to the COPYRIGHT file * for contact information. * * RELIC 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. * * RELIC 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 RELIC. If not, see <http://www.gnu.org/licenses/>. */ /** * @file * * Implementation of AVR-dependent routines. * * @version $Id$ * @ingroup arch */ /*============================================================================*/ /* Public definitions */ /*============================================================================*/ void arch_init(void) { } void arch_clean(void) { }
Remove commit and rollback method
#pragma once #ifndef YOU_DATASTORE_DATASTORE_H_ #define YOU_DATASTORE_DATASTORE_H_ #include <cstdint> #include <functional> #include <unordered_map> #include "pugixml.hpp" namespace You { namespace DataStore { class DataStore { public: /// Test classes friend class DataStoreAPITest; /// typedefs /// typedef for Serialized Task typedef std::unordered_map<std::wstring, std::wstring> STask; /// typedef for Task ID typedef int64_t TaskId; DataStore() = default; ~DataStore() = default; /// Insert a task into the datastore void post(STask); /// Update the content of a task void put(TaskId, STask); /// Get a task STask get(TaskId); /// Delete a task void erase(TaskId); /// Commits the changes void commit(); /// Roll back to the last commited changes void rollback(); /// Get a list of tasks that passes the filter std::vector<STask> filter(const std::function<bool(STask)>&); private: static const std::wstring FILE_PATH; pugi::xml_document document; /// Saves the xml object to a file /// Returns true if operation successful and false otherwise bool saveData(); /// Loads the xml file into the xml object void loadData(); }; } // namespace DataStore } // namespace You #endif // YOU_DATASTORE_DATASTORE_H_
#pragma once #ifndef YOU_DATASTORE_DATASTORE_H_ #define YOU_DATASTORE_DATASTORE_H_ #include <cstdint> #include <functional> #include <unordered_map> #include "pugixml.hpp" namespace You { namespace DataStore { class DataStore { public: /// Test classes friend class DataStoreAPITest; /// typedefs /// typedef for Serialized Task typedef std::unordered_map<std::wstring, std::wstring> STask; /// typedef for Task ID typedef int64_t TaskId; DataStore() = default; ~DataStore() = default; /// Insert a task into the datastore void post(STask); /// Update the content of a task void put(TaskId, STask); /// Get a task STask get(TaskId); /// Delete a task void erase(TaskId); /// Get a list of tasks that passes the filter std::vector<STask> filter(const std::function<bool(STask)>&); private: static const std::wstring FILE_PATH; pugi::xml_document document; /// Saves the xml object to a file /// Returns true if operation successful and false otherwise bool saveData(); /// Loads the xml file into the xml object void loadData(); }; } // namespace DataStore } // namespace You #endif // YOU_DATASTORE_DATASTORE_H_
Use g_value_clear as clear function
/* * Copyright © 2015 Canonical Limited * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the licence, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. * * Author: Ryan Lortie <desrt@desrt.ca> */ #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) #error "Only <glib-object.h> can be included directly." #endif G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref) G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset)
/* * Copyright © 2015 Canonical Limited * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the licence, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. * * Author: Ryan Lortie <desrt@desrt.ca> */ #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) #error "Only <glib-object.h> can be included directly." #endif G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref) G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_clear)
Add a generic rack-pinion steering subsystem.
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Generic rack-pinion steering model. // // ============================================================================= #ifndef GENERIC_RACKPINION_H #define GENERIC_RACKPINION_H #include "subsys/steering/ChRackPinion.h" class Generic_RackPinion : public chrono::ChRackPinion { public: Generic_RackPinion(const std::string& name) : ChRackPinion(name) {} ~Generic_RackPinion() {} virtual double GetSteeringLinkMass() const { return 9.0; } virtual const chrono::ChVector<>& GetSteeringLinkInertia() const { return chrono::ChVector<>(1, 1, 1); } virtual double GetSteeringLinkCOM() const { return 0.0; } virtual double GetSteeringLinkRadius() const { return 0.03; } virtual double GetSteeringLinkLength() const { return 0.896; } virtual double GetPinionRadius() const { return 0.1; } virtual double GetMaxAngle() const { return 0.87; } }; #endif
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
Fix warnings in one of the tests.
#include <traildb.h> #include <assert.h> #include <stdlib.h> #include <string.h> #include <stdio.h> int main(int argc, char** argv) { ((void) argc); ((void) argv); for ( int i1 = 0; i1 < 10000; ++i1 ) { uint8_t hex_uuid[33]; uint8_t hex_uuid2[33]; uint8_t uuid[16]; uint8_t uuid2[16]; for ( int i2 = 0; i2 < 16; ++i2 ) { uuid[i2] = random(); } tdb_cookie_hex(uuid, hex_uuid); tdb_cookie_raw(hex_uuid, uuid2); assert(!memcmp(uuid, uuid2, 16)); for ( int i2 = 0; i2 < 32; ++i2 ) { hex_uuid[i2] = random() % 16; hex_uuid[i2] += '0'; if ( hex_uuid[i2] > '9' ) { hex_uuid[i2] -= ('9'+1); hex_uuid[i2] += 'a'; } } tdb_cookie_raw(hex_uuid, uuid); tdb_cookie_hex(uuid, hex_uuid2); assert(!memcmp(hex_uuid, hex_uuid2, 32)); } return 0; }
#include <traildb.h> #include <assert.h> #include <stdlib.h> #include <string.h> #include <stdio.h> int main(int argc, char** argv) { ((void) argc); ((void) argv); for ( int i1 = 0; i1 < 10000; ++i1 ) { uint8_t hex_uuid[33]; uint8_t hex_uuid2[33]; uint8_t uuid[16]; uint8_t uuid2[16]; for ( int i2 = 0; i2 < 16; ++i2 ) { uuid[i2] = rand(); } tdb_cookie_hex(uuid, hex_uuid); tdb_cookie_raw(hex_uuid, uuid2); assert(!memcmp(uuid, uuid2, 16)); for ( int i2 = 0; i2 < 32; ++i2 ) { hex_uuid[i2] = rand() % 16; hex_uuid[i2] += '0'; if ( hex_uuid[i2] > '9' ) { hex_uuid[i2] -= ('9'+1); hex_uuid[i2] += 'a'; } } tdb_cookie_raw(hex_uuid, uuid); tdb_cookie_hex(uuid, hex_uuid2); assert(!memcmp(hex_uuid, hex_uuid2, 32)); } return 0; }