Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Remove test for obsolete function stat64. | /*
* Copyright 2010 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can
* be found in the LICENSE file.
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#pragma GCC diagnostic ignored "-Wnonnull"
#define KNOWN_FILE_SIZE 30
int main(int argc, char** argv) {
struct stat st;
struct stat64 st64;
if (2 != argc) {
printf("Usage: sel_ldr test_stat.nexe test_stat_data\n");
return 1;
}
st.st_size = 0;
st64.st_size = 0;
assert(-1 == stat(NULL, &st));
assert(EFAULT == errno);
assert(-1 == stat(".", NULL));
assert(EFAULT == errno);
errno = 0;
assert(0 == stat(argv[1], &st));
assert(0 == errno);
assert(KNOWN_FILE_SIZE == st.st_size);
assert(-1 == stat64(NULL, &st64));
assert(EFAULT == errno);
assert(-1 == stat64(".", NULL));
assert(EFAULT == errno);
errno = 0;
assert(0 == stat64(argv[1], &st64));
assert(0 == errno);
assert(KNOWN_FILE_SIZE == st64.st_size);
return 0;
}
| /*
* Copyright 2010 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can
* be found in the LICENSE file.
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#pragma GCC diagnostic ignored "-Wnonnull"
#define KNOWN_FILE_SIZE 30
int main(int argc, char** argv) {
struct stat st;
if (2 != argc) {
printf("Usage: sel_ldr test_stat.nexe test_stat_data\n");
return 1;
}
st.st_size = 0;
assert(-1 == stat(NULL, &st));
assert(EFAULT == errno);
assert(-1 == stat(".", NULL));
assert(EFAULT == errno);
errno = 0;
assert(0 == stat(argv[1], &st));
assert(0 == errno);
assert(KNOWN_FILE_SIZE == st.st_size);
return 0;
}
|
Add cartesian_value_product template meta function | #ifndef LIB_MART_COMMON_GUARD_TMP_H
#define LIB_MART_COMMON_GUARD_TMP_H
/**
* tmp.h (mart-common)
*
* Copyright (C) 2015-2017: Michael Balszun <michael.balszun@mytum.de>
*
* This software may be modified and distributed under the terms
* of the MIT license. See either the LICENSE file in the library's root
* directory or http://opensource.org/licenses/MIT for details.
*
* @author: Michael Balszun <michael.balszun@mytum.de>
* @brief: template meta programming helpers
*
*/
/* ######## INCLUDES ######### */
/* Standard Library Includes */
/* Proprietary Library Includes */
#include "../cpp_std/type_traits.h"
#include "../cpp_std/utility.h"
/* Project Includes */
/* ~~~~~~~~ INCLUDES ~~~~~~~~~ */
namespace mart {
namespace tmp {
template<class T, std::size_t N>
struct c_array {
const T t[N];
constexpr T operator[](size_t i) const {
return t[i];
}
static constexpr size_t size() { return N; }
};
template<class T, T ... Is, template<class, T...> class sequence>
constexpr c_array<T, sizeof...(Is)> to_carray(sequence<T, Is...>) {
return { {Is...}};
}
// watch out: on gcc, you can't use parameters itself to generate the returntype, but have to create a new value of the type
namespace detail_cartesian_value_product {
template<
template<class ... > class Comb,
class V1, class V2,
template< V1, V2 > class T,
class List1,
class List2,
std::size_t ... Is
>
auto impl(List1, List2, mart::index_sequence<Is...>)
-> Comb < T <
to_carray(List1{})[Is / List2::size()],
to_carray(List2{})[Is % List2::size()]
> ...
>;
}
template<
template<class ... > class Comb,
class V1, class V2,
template< V1, V2 > class T,
class List1,
class List2
>
auto cartesian_value_product(List1 l1, List2 l2 )
-> decltype(detail_cartesian_value_product::impl<Comb,V1,V2,T>(l1, l2, mart::make_index_sequence<List1::size()*List2::size()>{}));
}
}
#endif
| |
Print something about "Secure Notes" while iterating | //
// main.c
// secure-notes-exporter
//
// Created by Greg Hurrell on 5/9/14.
// Copyright (c) 2014 Greg Hurrell. All rights reserved.
//
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
int main(int argc, const char * argv[])
{
// create query
CFStringRef keys[] = { kSecReturnAttributes, kSecMatchLimit, kSecClass };
CFTypeRef values[] = { kCFBooleanTrue, kSecMatchLimitAll, kSecClassGenericPassword };
CFDictionaryRef query = CFDictionaryCreate(
kCFAllocatorDefault,
(const void **)keys,
(const void **)values,
3,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks
);
// get search results
CFArrayRef items = nil;
OSStatus status = SecItemCopyMatching(query, (CFTypeRef *)&items);
CFRelease(query);
assert(status == 0);
CFShow(items);
CFRelease(items);
return 0;
}
| //
// main.c
// secure-notes-exporter
//
// Created by Greg Hurrell on 5/9/14.
// Copyright (c) 2014 Greg Hurrell. All rights reserved.
//
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
void printItem(const void *value, void *context) {
CFDictionaryRef dictionary = value;
CFNumberRef itemType = CFDictionaryGetValue(dictionary, kSecAttrType);
CFNumberRef noteType = (CFNumberRef)context;
if (!itemType || !CFEqual(itemType, noteType)) {
// not a note
return;
}
CFShow(noteType);
}
int main(int argc, const char * argv[])
{
// create query
CFStringRef keys[] = { kSecReturnAttributes, kSecMatchLimit, kSecClass };
CFTypeRef values[] = { kCFBooleanTrue, kSecMatchLimitAll, kSecClassGenericPassword };
CFDictionaryRef query = CFDictionaryCreate(
kCFAllocatorDefault,
(const void **)keys,
(const void **)values,
3,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks
);
// get search results
CFArrayRef items = nil;
OSStatus status = SecItemCopyMatching(query, (CFTypeRef *)&items);
CFRelease(query);
assert(status == 0);
// iterate over "Secure Note" items
CFRange range = CFRangeMake(0, CFArrayGetCount(items));
SInt32 note = 'note';
CFNumberRef noteRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, ¬e);
CFArrayApplyFunction(items, range, printItem, (void *)noteRef);
CFRelease(noteRef);
CFRelease(items);
return 0;
}
|
Add EOL at EOF to appease source utils like unifdef | //===- Mem2Reg.h - The -mem2reg pass, a wrapper around the Utils lib ------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This pass is a simple pass wrapper around the PromoteMemToReg function call
// exposed by the Utils library.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_UTILS_MEM2REG_H
#define LLVM_TRANSFORMS_UTILS_MEM2REG_H
#include "llvm/IR/Function.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
class PromotePass : public PassInfoMixin<PromotePass> {
public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
}
#endif // LLVM_TRANSFORMS_UTILS_MEM2REG_H | //===- Mem2Reg.h - The -mem2reg pass, a wrapper around the Utils lib ------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This pass is a simple pass wrapper around the PromoteMemToReg function call
// exposed by the Utils library.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_UTILS_MEM2REG_H
#define LLVM_TRANSFORMS_UTILS_MEM2REG_H
#include "llvm/IR/Function.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
class PromotePass : public PassInfoMixin<PromotePass> {
public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
}
#endif // LLVM_TRANSFORMS_UTILS_MEM2REG_H
|
Add bug testcase for GH-337 | /*
* Bug in duk_is_primitive() prior to Duktape 1.3.0: returns 1 for invalid
* index.
*
* https://github.com/svaarala/duktape/issues/337
*/
/*===
*** test_1 (duk_safe_call)
0
final top: 0
==> rc=0, result='undefined'
*** test_2 (duk_safe_call)
0
final top: 0
==> rc=0, result='undefined'
*** test_3 (duk_safe_call)
1
0
final top: 1
==> rc=0, result='undefined'
===*/
static duk_ret_t test_1(duk_context *ctx) {
printf("%ld\n", (long) duk_is_primitive(ctx, -1));
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
static duk_ret_t test_2(duk_context *ctx) {
printf("%ld\n", (long) duk_is_primitive(ctx, DUK_INVALID_INDEX));
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
static duk_ret_t test_3(duk_context *ctx) {
duk_push_null(ctx);
printf("%ld\n", (long) duk_is_primitive(ctx, 0)); /* valid */
printf("%ld\n", (long) duk_is_primitive(ctx, 1)); /* invalid */
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
void test(duk_context *ctx) {
TEST_SAFE_CALL(test_1);
TEST_SAFE_CALL(test_2);
TEST_SAFE_CALL(test_3);
}
| |
Modify test 02/86 so it fails if spurious warning is produced | #include<pthread.h>
#include<assert.h>
int counter = 0;
pthread_mutex_t lock1;
void* producer(void* param) {
pthread_mutex_lock(&lock1);
counter = 0;
pthread_mutex_unlock(&lock1);
}
void* consumer(void* param) {
pthread_mutex_lock(&lock1);
int bla = counter >= 0;
// This should not produce a warning about the privatization being unsound
assert(counter >= 0);
pthread_mutex_unlock(&lock1);
}
int main() {
pthread_t thread;
pthread_t thread2;
pthread_create(&thread,NULL,producer,NULL);
pthread_create(&thread2,NULL,consumer,NULL);
}
| //PARAM: --disable warn.assert
#include<pthread.h>
#include<assert.h>
int counter = 0;
pthread_mutex_t lock1;
void* producer(void* param) {
pthread_mutex_lock(&lock1);
counter = 0;
pthread_mutex_unlock(&lock1);
}
void* consumer(void* param) {
pthread_mutex_lock(&lock1);
int bla = counter >= 0;
// This should not produce a warning about the privatization being unsound
assert(counter >= 0); //NOWARN
pthread_mutex_unlock(&lock1);
}
int main() {
pthread_t thread;
pthread_t thread2;
pthread_create(&thread,NULL,producer,NULL);
pthread_create(&thread2,NULL,consumer,NULL);
}
|
Enable the nRF52 built-in DC/DC converter | /*
* Copyright (C) 2019 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup boards_nrf52832-mdk
* @{
*
* @file
* @brief Peripheral configuration for the nRF52832-MDK
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
*/
#ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#include "periph_cpu.h"
#include "cfg_clock_32_1.h"
#include "cfg_i2c_default.h"
#include "cfg_rtt_default.h"
#include "cfg_spi_default.h"
#include "cfg_timer_default.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name UART configuration
* @{
*/
#define UART_NUMOF (1U)
#define UART_PIN_RX GPIO_PIN(0,19)
#define UART_PIN_TX GPIO_PIN(0,20)
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */
| /*
* Copyright (C) 2019 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup boards_nrf52832-mdk
* @{
*
* @file
* @brief Peripheral configuration for the nRF52832-MDK
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
*/
#ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#include "periph_cpu.h"
#include "cfg_clock_32_1.h"
#include "cfg_i2c_default.h"
#include "cfg_rtt_default.h"
#include "cfg_spi_default.h"
#include "cfg_timer_default.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name UART configuration
* @{
*/
#define UART_NUMOF (1U)
#define UART_PIN_RX GPIO_PIN(0,19)
#define UART_PIN_TX GPIO_PIN(0,20)
/** @} */
/**
* @brief Enable the internal DC/DC converter
*/
#define NRF5X_ENABLE_DCDC
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */
|
Change over to KostaKow's version of this | /****************************************************************************
* Simple definitions to aid platform portability
* Author: Bill Forster
* License: MIT license. Full text of license is in associated file LICENSE
* Copyright 2010-2014, Bill Forster <billforsternz at gmail dot com>
****************************************************************************/
#ifndef PORTABILITY_H
#define PORTABILITY_H
#include <stdint.h> // int32_t etc.
// Windows
#ifdef WIN32
#include <Windows.h>
#include <string.h>
#define strcmpi _strcmpi
#define THC_WINDOWS // Triple Happy Chess, Windows specific code
#define WINDOWS_FIX_LATER // Windows only fix later on Mac
// Mac
#else
unsigned long GetTickCount();
typedef unsigned char byte;
int strcmpi( const char *s, const char *t ); // return 0 if case insensitive match
#define THC_MAC // Triple Happy Chess, Mac specific code
#define MAC_FIX_LATER // Things not yet done on the Mac
#endif
//#define DebugPrintfInner printf //temp
#endif // PORTABILITY_H
| /****************************************************************************
* Simple definitions to aid platform portability
* Author: Bill Forster
* License: MIT license. Full text of license is in associated file LICENSE
* Copyright 2010-2014, Bill Forster <billforsternz at gmail dot com>
****************************************************************************/
#ifndef PORTABILITY_H
#define PORTABILITY_H
#include <stdint.h> // int32_t etc.
//CHOOSE ONE:
//#define TARRASCH_UNIX 1
//#define TARRASCH_WINDOWS 1
//#define TARRASCH_OSX 1
#ifdef WIN32
#define TARRASCH_WINDOWS 1
#else
#define TARRASCH_UNIX 1
#endif
#include <stdint.h> // int32_t etc.
#if TARRASCH_UNIX
#include <string.h>
typedef uint8_t byte;
#define THC_MAC
#define MAC_FIX_LATER
unsigned long GetTickCount();
int strcmpi(const char *s, const char *t);
#elif TARRASCH_WINDOWS
#include <Windows.h>
#include <string.h>
#define strcmpi _strcmpi
#define THC_WINDOWS // Triple Happy Chess, Windows specific code
#define WINDOWS_FIX_LATER // Windows only fix later on Mac
#elif TARRASCH_OSX
unsigned long GetTickCount();
typedef unsigned char byte;
int strcmpi( const char *s, const char *t ); // return 0 if case insensitive match
#define THC_MAC // Triple Happy Chess, Mac specific code
#define MAC_FIX_LATER // Things not yet done on the Mac
#else
#error Unknown Platform!
#endif
//#define DebugPrintfInner printf //temp
#endif // PORTABILITY_H
|
Drop the default polling interval to 100ms | #ifndef POLLING_THREAD_H
#define POLLING_THREAD_H
#include <cstdint>
#include <chrono>
#include <map>
#include <uv.h>
#include "../thread.h"
#include "../status.h"
#include "../result.h"
#include "polled_root.h"
const std::chrono::milliseconds DEFAULT_POLL_INTERVAL = std::chrono::milliseconds(500);
const uint_fast64_t DEFAULT_POLL_THROTTLE = 1000;
class PollingThread : public Thread {
public:
PollingThread(uv_async_t *main_callback);
~PollingThread();
void collect_status(Status &status) override;
private:
Result<> body() override;
Result<> cycle();
Result<OfflineCommandOutcome> handle_offline_command(const CommandPayload *command) override;
Result<CommandOutcome> handle_add_command(const CommandPayload *command) override;
Result<CommandOutcome> handle_remove_command(const CommandPayload *payload) override;
std::chrono::milliseconds poll_interval;
uint_fast64_t poll_throttle;
std::map<ChannelID, PolledRoot> roots;
};
#endif
| #ifndef POLLING_THREAD_H
#define POLLING_THREAD_H
#include <cstdint>
#include <chrono>
#include <map>
#include <uv.h>
#include "../thread.h"
#include "../status.h"
#include "../result.h"
#include "polled_root.h"
const std::chrono::milliseconds DEFAULT_POLL_INTERVAL = std::chrono::milliseconds(100);
const uint_fast64_t DEFAULT_POLL_THROTTLE = 1000;
class PollingThread : public Thread {
public:
PollingThread(uv_async_t *main_callback);
~PollingThread();
void collect_status(Status &status) override;
private:
Result<> body() override;
Result<> cycle();
Result<OfflineCommandOutcome> handle_offline_command(const CommandPayload *command) override;
Result<CommandOutcome> handle_add_command(const CommandPayload *command) override;
Result<CommandOutcome> handle_remove_command(const CommandPayload *payload) override;
std::chrono::milliseconds poll_interval;
uint_fast64_t poll_throttle;
std::map<ChannelID, PolledRoot> roots;
};
#endif
|
Add a missing header include for assert.h | #ifndef __CORE_SET__
#define __CORE_SET__
#include <set>
class CoreSet : public std::set<int>
{
public:
int getPrevCore(int coreId) {
auto curr = this->find(coreId);
assert(curr != this->end());
curr--;
// This was the first element, start over
if (curr == this->end())
curr--;
return *curr;
}
int getNextCore(int coreId) {
auto curr = this->find(coreId);
assert(curr != this->end());
curr++;
// This was the last element, start over
if (curr == this->end())
curr = this->begin();
return *curr;
}
};
#endif
| #ifndef __CORE_SET__
#define __CORE_SET__
#include "assert.h"
#include <set>
class CoreSet : public std::set<int>
{
public:
int getPrevCore(int coreId) {
auto curr = this->find(coreId);
assert(curr != this->end());
curr--;
// This was the first element, start over
if (curr == this->end())
curr--;
return *curr;
}
int getNextCore(int coreId) {
auto curr = this->find(coreId);
assert(curr != this->end());
curr++;
// This was the last element, start over
if (curr == this->end())
curr = this->begin();
return *curr;
}
};
#endif
|
Test reported by Axel, our FreeBSD user. This file is the postprocessed result from a FreeBSD machine. This command fails: | # 1 "wchar1.c"
# 1 "testharness.h" 1
extern int printf(const char *, ...);
extern void exit(int);
# 1 "wchar1.c" 2
# 1 "/usr/include/stddef.h" 1 3
# 1 "/usr/include/machine/ansi.h" 1 3
typedef int __attribute__((__mode__(__DI__))) __int64_t;
typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
typedef __signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef int __intptr_t;
typedef unsigned int __uintptr_t;
typedef union {
char __mbstate8[128];
__int64_t _mbstateL;
} __mbstate_t;
# 41 "/usr/include/stddef.h" 2 3
typedef int ptrdiff_t;
typedef int rune_t;
typedef unsigned int size_t;
typedef int wchar_t;
# 2 "wchar1.c" 2
int main() {
wchar_t *wbase = L"Hello" L", world";
char * w = (char *)wbase;
char * s = "Hello" ", world";
int i;
for (i=0; i < 10; i++) {
if (w[i * sizeof(wchar_t)] != s[i]) {
{ printf("Error %d\n", 1 ); exit( 1 ); } ;
}
if (w[i * sizeof(wchar_t)+ 1] != 0) {
{ printf("Error %d\n", 2 ); exit( 2 ); } ;
}
}
{ printf("Success\n"); exit(0); } ;
}
| |
Document return value of FileUrlReader's reload() and write_config() | #ifndef NEWSBOAT_FILEURLREADER_H_
#define NEWSBOAT_FILEURLREADER_H_
#include <string>
#include "urlreader.h"
namespace newsboat {
class FileUrlReader : public UrlReader {
public:
explicit FileUrlReader(const std::string& file = "");
nonstd::optional<std::string> reload() override;
std::string get_source() override;
/// \brief Write URLs back to the input file.
///
/// This method is used after importing feeds from OPML.
nonstd::optional<std::string> write_config();
private:
const std::string filename;
};
}
#endif /* NEWSBOAT_FILEURLREADER_H_ */
| #ifndef NEWSBOAT_FILEURLREADER_H_
#define NEWSBOAT_FILEURLREADER_H_
#include <string>
#include "urlreader.h"
namespace newsboat {
class FileUrlReader : public UrlReader {
public:
explicit FileUrlReader(const std::string& file = "");
/// \brief Load URLs from the urls file.
///
/// \return A non-value on success, an error message otherwise.
nonstd::optional<std::string> reload() override;
std::string get_source() override;
/// \brief Write URLs back to the urls file.
///
/// \return A non-value on success, an error message otherwise.
nonstd::optional<std::string> write_config();
private:
const std::string filename;
};
}
#endif /* NEWSBOAT_FILEURLREADER_H_ */
|
Fix unknown type name 'size_t' error | /*
// Copyright (c) 2019 Intel Corporation
//
// 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 OC_CLOCK_UTIL_H
#define OC_CLOCK_UTIL_H
#include "oc_config.h"
size_t oc_clock_time_rfc3339(char *out_buf, size_t out_buf_len);
size_t oc_clock_encode_time_rfc3339(oc_clock_time_t time, char *out_buf,
size_t out_buf_len);
oc_clock_time_t oc_clock_parse_time_rfc3339(const char *in_buf,
size_t in_buf_len);
#endif /* OC_CLOCK_UTIL_H */
| /*
// Copyright (c) 2019 Intel Corporation
//
// 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 OC_CLOCK_UTIL_H
#define OC_CLOCK_UTIL_H
#include "oc_config.h"
#include <stddef.h>
size_t oc_clock_time_rfc3339(char *out_buf, size_t out_buf_len);
size_t oc_clock_encode_time_rfc3339(oc_clock_time_t time, char *out_buf,
size_t out_buf_len);
oc_clock_time_t oc_clock_parse_time_rfc3339(const char *in_buf,
size_t in_buf_len);
#endif /* OC_CLOCK_UTIL_H */
|
Revise test case due to the change from CUDA 10+. | // REQUIRES: clang-driver
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target
//
// Verify that CUDA device commands do not get OpenMP flags.
//
// RUN: %clang -no-canonical-prefixes -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
//
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux-gnu"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc"
| // REQUIRES: clang-driver
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target
//
// Verify that CUDA device commands do not get OpenMP flags.
//
// RUN: %clang -no-canonical-prefixes -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
//
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary"{{( "--cuda")?}} "-64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux-gnu"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc"
|
Use deleted instead of private constructors | #ifndef LINUXFFBEFFECTFACTORY_H
#define LINUXFFBEFFECTFACTORY_H
#include "globals.h"
#include "linuxffbconditioneffect.h"
#include "linuxffbconstanteffect.h"
#include "ffbnulleffect.h"
#include "linuxffbperiodiceffect.h"
#include "linuxffbrampeffect.h"
#include "linuxffbrumbleeffect.h"
class LinuxFFBEffectFactory
{
public:
static std::shared_ptr<FFBEffect> createEffect(FFBEffectTypes type);
private:
LinuxFFBEffectFactory() {};
};
#endif // LINUXFFBEFFECTFACTORY_H
| #ifndef LINUXFFBEFFECTFACTORY_H
#define LINUXFFBEFFECTFACTORY_H
#include "globals.h"
#include "linuxffbconditioneffect.h"
#include "linuxffbconstanteffect.h"
#include "ffbnulleffect.h"
#include "linuxffbperiodiceffect.h"
#include "linuxffbrampeffect.h"
#include "linuxffbrumbleeffect.h"
class LinuxFFBEffectFactory
{
public:
static std::shared_ptr<FFBEffect> createEffect(FFBEffectTypes type);
LinuxFFBEffectFactory() = delete;
};
#endif // LINUXFFBEFFECTFACTORY_H
|
Fix compiler error about undeclared type | @class TRTemperature;
@interface TRWeatherUpdate : NSObject
@property (nonatomic, copy, readonly) NSString *city;
@property (nonatomic, copy, readonly) NSString *state;
@property (nonatomic, copy, readonly) NSString *conditionsDescription;
@property (nonatomic, readonly) TRTemperature *currentTemperature;
@property (nonatomic, readonly) TRTemperature *currentHigh;
@property (nonatomic, readonly) TRTemperature *currentLow;
@property (nonatomic, readonly) TRTemperature *yesterdaysTemperature;
@property (nonatomic, readonly) CGFloat windSpeed;
@property (nonatomic, readonly) CGFloat windBearing;
@property (nonatomic, readonly) NSDate *date;
@property (nonatomic, copy, readonly) NSArray *dailyForecasts;
- (instancetype)initWithPlacemark:(CLPlacemark *)placemark currentConditionsJSON:(id)currentConditionsJSON yesterdaysConditionsJSON:(id)yesterdaysConditionsJSON;
@end
#import "TRAnalyticsEvent.h"
@interface TRWeatherUpdate (TRAnalytics) <TRAnalyticsEvent>
@end
| @class CLPlacemark;
@class TRTemperature;
@interface TRWeatherUpdate : NSObject
@property (nonatomic, copy, readonly) NSString *city;
@property (nonatomic, copy, readonly) NSString *state;
@property (nonatomic, copy, readonly) NSString *conditionsDescription;
@property (nonatomic, readonly) TRTemperature *currentTemperature;
@property (nonatomic, readonly) TRTemperature *currentHigh;
@property (nonatomic, readonly) TRTemperature *currentLow;
@property (nonatomic, readonly) TRTemperature *yesterdaysTemperature;
@property (nonatomic, readonly) CGFloat windSpeed;
@property (nonatomic, readonly) CGFloat windBearing;
@property (nonatomic, readonly) NSDate *date;
@property (nonatomic, copy, readonly) NSArray *dailyForecasts;
- (instancetype)initWithPlacemark:(CLPlacemark *)placemark currentConditionsJSON:(id)currentConditionsJSON yesterdaysConditionsJSON:(id)yesterdaysConditionsJSON;
@end
#import "TRAnalyticsEvent.h"
@interface TRWeatherUpdate (TRAnalytics) <TRAnalyticsEvent>
@end
|
Add a test for r228510. | /*-
* Copyright (c) 2010 Jilles Tjoelker
* 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$
*/
#include <sys/select.h>
#include <err.h>
#include <stdio.h>
#include <unistd.h>
/*
* Check that pipes can be selected for writing in the reverse direction.
*/
int
main(int argc, char *argv[])
{
int pip[2];
fd_set set;
int n;
if (pipe(pip) == -1)
err(1, "FAIL: pipe");
FD_ZERO(&set);
FD_SET(pip[0], &set);
n = select(pip[1] + 1, NULL, &set, NULL, &(struct timeval){ 0, 0 });
if (n != 1)
errx(1, "FAIL: select initial reverse direction");
n = write(pip[0], "x", 1);
if (n != 1)
err(1, "FAIL: write reverse direction");
FD_ZERO(&set);
FD_SET(pip[0], &set);
n = select(pip[1] + 1, NULL, &set, NULL, &(struct timeval){ 0, 0 });
if (n != 1)
errx(1, "FAIL: select reverse direction after write");
printf("PASS\n");
return (0);
}
| |
Add insertOrAssign helper for maps | #ifndef TE_AUXILIARY_H
#define TE_AUXILIARY_H
struct SDL_Rect;
namespace te
{
struct Vector2i;
class Rectangle;
bool checkCollision(const SDL_Rect& a, const SDL_Rect& b);
bool checkCollision(const Rectangle& a, const Rectangle& b);
SDL_Rect getIntersection(const SDL_Rect& a, const SDL_Rect& b);
SDL_Rect getIntersection(const Rectangle& a, const Rectangle& b);
Vector2i getCenter(const SDL_Rect& rect);
Vector2i getCenter(const Rectangle& rect);
void handlePaddleCollision(Rectangle& ball, const Rectangle& paddle, float dt, float velocityScalar = 200.f);
void handleWallCollision(Rectangle& ball, const Rectangle& wall, float dt);
}
#endif
| #ifndef TE_AUXILIARY_H
#define TE_AUXILIARY_H
#include <map>
struct SDL_Rect;
namespace te
{
struct Vector2i;
class Rectangle;
bool checkCollision(const SDL_Rect& a, const SDL_Rect& b);
bool checkCollision(const Rectangle& a, const Rectangle& b);
SDL_Rect getIntersection(const SDL_Rect& a, const SDL_Rect& b);
SDL_Rect getIntersection(const Rectangle& a, const Rectangle& b);
Vector2i getCenter(const SDL_Rect& rect);
Vector2i getCenter(const Rectangle& rect);
void handlePaddleCollision(Rectangle& ball, const Rectangle& paddle, float dt, float velocityScalar = 200.f);
void handleWallCollision(Rectangle& ball, const Rectangle& wall, float dt);
template <class K, class V>
void insertOrAssign(std::map<K,V>& map, std::pair<K, V>&& kvPair)
{
auto it = map.find(kvPair.first);
if (it == map.end())
{
map.insert(std::move(kvPair));
}
else
{
it->second = std::move(kvPair.second);
}
}
template <class K, class V>
void insertOrAssign(std::map<K, V>& map, const std::pair<K, V>& kvPair)
{
auto it = map.find(kvPair.first);
if (it != map.end())
{
map.insert(kvPair);
}
else
{
it->second = kvPair.second;
}
}
}
#endif
|
Add a default constructor for FormData. There are too many places that create FormDatas, and we shouldn't need to initialize user_submitted for each call site. | // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_FORM_DATA_H__
#define WEBKIT_GLUE_FORM_DATA_H__
#include <vector>
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/form_field.h"
namespace webkit_glue {
// Holds information about a form to be filled and/or submitted.
struct FormData {
// The name of the form.
string16 name;
// GET or POST.
string16 method;
// The URL (minus query parameters) containing the form.
GURL origin;
// The action target of the form.
GURL action;
// true if this form was submitted by a user gesture and not javascript.
bool user_submitted;
// A vector of all the input fields in the form.
std::vector<FormField> fields;
// Used by FormStructureTest.
inline bool operator==(const FormData& form) const {
return (name == form.name &&
StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
origin == form.origin &&
action == form.action &&
user_submitted == form.user_submitted &&
fields == form.fields);
}
};
} // namespace webkit_glue
#endif // WEBKIT_GLUE_FORM_DATA_H__
| // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_FORM_DATA_H__
#define WEBKIT_GLUE_FORM_DATA_H__
#include <vector>
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/form_field.h"
namespace webkit_glue {
// Holds information about a form to be filled and/or submitted.
struct FormData {
// The name of the form.
string16 name;
// GET or POST.
string16 method;
// The URL (minus query parameters) containing the form.
GURL origin;
// The action target of the form.
GURL action;
// true if this form was submitted by a user gesture and not javascript.
bool user_submitted;
// A vector of all the input fields in the form.
std::vector<FormField> fields;
FormData() : user_submitted(false) {}
// Used by FormStructureTest.
inline bool operator==(const FormData& form) const {
return (name == form.name &&
StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
origin == form.origin &&
action == form.action &&
user_submitted == form.user_submitted &&
fields == form.fields);
}
};
} // namespace webkit_glue
#endif // WEBKIT_GLUE_FORM_DATA_H__
|
Remove apparently uneccessary extern C stuff | extern "C" {
#include <sys/types.h>
}
class Instrument {
public:
float start;
float dur;
int cursamp;
int chunksamps;
int endsamp;
int nsamps;
unsigned long chunkstart;
int sfile_on; // a soundfile is open (for closing later)
int fdIndex; // index into unix input file desc. table
int inputchans;
double inputsr;
off_t fileOffset; // current offset in file for this inst
int mytag; // for note tagging/rtupdate()
Instrument();
virtual ~Instrument();
virtual int init(float*, short);
virtual int run();
virtual float getstart();
virtual float getdur();
virtual int getendsamp();
virtual void setendsamp(int);
virtual void setchunk(int);
virtual void setchunkstart(int);
private:
void gone(); // decrements reference to input soundfile
};
extern void heapify(Instrument *Iptr);
extern void heapSched(Instrument *Iptr);
extern int rtsetoutput(float, float, Instrument*);
extern int rtsetinput(float, Instrument*);
extern int rtaddout(float*);
extern int rtbaddout(float*, int);
extern "C" int rtgetin(float*, Instrument*, int);
extern float rtupdate(int, int); // tag, p-field for return value
| #include <sys/types.h>
class Instrument {
public:
float start;
float dur;
int cursamp;
int chunksamps;
int endsamp;
int nsamps;
unsigned long chunkstart;
int sfile_on; // a soundfile is open (for closing later)
int fdIndex; // index into unix input file desc. table
int inputchans;
double inputsr;
off_t fileOffset; // current offset in file for this inst
int mytag; // for note tagging/rtupdate()
Instrument();
virtual ~Instrument();
virtual int init(float*, short);
virtual int run();
virtual float getstart();
virtual float getdur();
virtual int getendsamp();
virtual void setendsamp(int);
virtual void setchunk(int);
virtual void setchunkstart(int);
private:
void gone(); // decrements reference to input soundfile
};
extern void heapify(Instrument *Iptr);
extern void heapSched(Instrument *Iptr);
extern int rtsetoutput(float, float, Instrument*);
extern int rtsetinput(float, Instrument*);
extern int rtaddout(float*);
extern int rtbaddout(float*, int);
extern int rtgetin(float*, Instrument*, int);
extern float rtupdate(int, int); // tag, p-field for return value
|
Include stdint.h instead of stdio.h. | // RUN: clang -checker-simple -verify %s
#include <stdlib.h>
int f1(int * p) {
// This branch should be infeasible
// because __imag__ p is 0.
if (!p && __imag__ (intptr_t) p)
*p = 1; // no-warning
// If p != 0 then this branch is feasible; otherwise it is not.
if (__real__ (intptr_t) p)
*p = 1; // no-warning
*p = 2; // expected-warning{{Dereference of null pointer}}
}
| // RUN: clang -checker-simple -verify %s
#include <stdint.h>
int f1(int * p) {
// This branch should be infeasible
// because __imag__ p is 0.
if (!p && __imag__ (intptr_t) p)
*p = 1; // no-warning
// If p != 0 then this branch is feasible; otherwise it is not.
if (__real__ (intptr_t) p)
*p = 1; // no-warning
*p = 2; // expected-warning{{Dereference of null pointer}}
}
|
Add compare function of quadruple precision | /* This file is part of Metallic, a C++ library for WebAssembly.
*
* Copyright (C) 2017 Chen-Pang He <chen.pang.he@jdh8.org>
*
* This Source Code Form is subject to the terms of the Mozilla
* Public License v. 2.0. If a copy of the MPL was not distributed
* with this file, You can obtain one at http://mozilla.org/MPL/2.0/
*/
#include "isunorderedq.h"
int __cmptf2(long double x, long double y)
{
__int128 a = *(__int128*)&x;
__int128 b = *(__int128*)&y;
if ((a|b) << 1 == 0)
return 0;
if (isunorderedq(x, y))
return 1;
int sign = (a & b) >> 127;
return ((a > b) - (a < b) + sign) ^ sign;
}
| |
Add BSD 3-clause open source header | /*
* The Homework Database
*
* Authors:
* Oliver Sharma and Joe Sventek
* {oliver, joe}@dcs.gla.ac.uk
*
* (c) 2009. All rights reserved.
*/
#ifndef OCLIB_UTIL_H
#define OCLIB_UTIL_H
#include "config.h"
#include "logdefs.h"
#include <stdio.h>
/* -------- [MESSAGE] -------- */
#ifdef NMSG
#define MSG (void)
#else
#define MSG printf("DBSERVER> "); printf
#endif
#endif
| /*
* Copyright (c) 2013, Court of the University of Glasgow
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the University of Glasgow nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
*/
/*
* The Homework Database
*
* Authors:
* Oliver Sharma and Joe Sventek
* {oliver, joe}@dcs.gla.ac.uk
*
*/
#ifndef OCLIB_UTIL_H
#define OCLIB_UTIL_H
#include "config.h"
#include "logdefs.h"
#include <stdio.h>
/* -------- [MESSAGE] -------- */
#ifdef NMSG
#define MSG (void)
#else
#define MSG printf("DBSERVER> "); printf
#endif
#endif
|
Change return value of hrtime from seconds to nano seconds. | #include "couv-private.h"
static int couv_hrtime(lua_State *L) {
lua_pushnumber(L, uv_hrtime() / 1e9);
return 1;
}
static const struct luaL_Reg functions[] = {
{ "hrtime", couv_hrtime },
{ NULL, NULL }
};
int luaopen_couv_native(lua_State *L) {
lua_createtable(L, 0, ARRAY_SIZE(functions) - 1);
couvL_setfuncs(L, functions, 0);
luaopen_couv_loop(L);
luaopen_couv_buffer(L);
luaopen_couv_fs(L);
luaopen_couv_ipaddr(L);
luaopen_couv_handle(L);
luaopen_couv_pipe(L);
luaopen_couv_stream(L);
luaopen_couv_tcp(L);
luaopen_couv_timer(L);
luaopen_couv_tty(L);
luaopen_couv_udp(L);
return 1;
}
| #include "couv-private.h"
static int couv_hrtime(lua_State *L) {
lua_pushnumber(L, uv_hrtime());
return 1;
}
static const struct luaL_Reg functions[] = {
{ "hrtime", couv_hrtime },
{ NULL, NULL }
};
int luaopen_couv_native(lua_State *L) {
lua_createtable(L, 0, ARRAY_SIZE(functions) - 1);
couvL_setfuncs(L, functions, 0);
luaopen_couv_loop(L);
luaopen_couv_buffer(L);
luaopen_couv_fs(L);
luaopen_couv_ipaddr(L);
luaopen_couv_handle(L);
luaopen_couv_pipe(L);
luaopen_couv_stream(L);
luaopen_couv_tcp(L);
luaopen_couv_timer(L);
luaopen_couv_tty(L);
luaopen_couv_udp(L);
return 1;
}
|
Disable divide by zero warning for VS6 to avoid modifying function implementation. | #include "v3p_f2c.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef KR_headers
integer pow_ii(ap, bp) integer *ap, *bp;
#else
integer pow_ii(integer *ap, integer *bp)
#endif
{
integer pow, x, n;
unsigned long u;
x = *ap;
n = *bp;
if (n <= 0) {
if (n == 0 || x == 1)
return 1;
if (x != -1)
return x == 0 ? 1/x : 0;
n = -n;
}
u = n;
for(pow = 1; ; )
{
if(u & 01)
pow *= x;
if(u >>= 1)
x *= x;
else
break;
}
return(pow);
}
#ifdef __cplusplus
}
#endif
| #include "v3p_f2c.h"
#ifdef __cplusplus
extern "C" {
#endif
/* The divide by zero below appears to be perhaps on purpose to create
a numerical exception. */
#ifdef _MSC_VER
# pragma warning (disable: 4723) /* potential divide by 0 */
#endif
#ifdef KR_headers
integer pow_ii(ap, bp) integer *ap, *bp;
#else
integer pow_ii(integer *ap, integer *bp)
#endif
{
integer pow, x, n;
unsigned long u;
x = *ap;
n = *bp;
if (n <= 0) {
if (n == 0 || x == 1)
return 1;
if (x != -1)
return x == 0 ? 1/x : 0;
n = -n;
}
u = n;
for(pow = 1; ; )
{
if(u & 01)
pow *= x;
if(u >>= 1)
x *= x;
else
break;
}
return(pow);
}
#ifdef __cplusplus
}
#endif
|
Duplicate RCTMethodInfo while building iOS app | //
// OAuthManager.h
//
// Created by Ari Lerner on 5/31/16.
// Copyright © 2016 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif
#if __has_include("RCTLinkingManager.h")
#import "RCTLinkingManager.h"
#else
#import <React/RCTLinkingManager.h>
#endif
@class OAuthClient;
static NSString *kAuthConfig = @"OAuthManager";
@interface OAuthManager : NSObject <RCTBridgeModule, UIWebViewDelegate>
+ (instancetype) sharedManager;
+ (BOOL)setupOAuthHandler:(UIApplication *)application;
+ (BOOL)handleOpenUrl:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
- (BOOL) _configureProvider:(NSString *) name andConfig:(NSDictionary *) config;
- (NSDictionary *) getConfigForProvider:(NSString *)name;
@property (nonatomic, strong) NSDictionary *providerConfig;
@property (nonatomic, strong) NSArray *callbackUrls;
@end
| //
// OAuthManager.h
//
// Created by Ari Lerner on 5/31/16.
// Copyright © 2016 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#if __has_include(<React/RCTBridgeModule.h>)
#import <React/RCTBridgeModule.h>
#else
#import "RCTBridgeModule.h"
#endif
#if __has_include(<React/RCTLinkingManager.h>)
#import <React/RCTLinkingManager.h>
#else
#import "RCTLinkingManager.h"
#endif
@class OAuthClient;
static NSString *kAuthConfig = @"OAuthManager";
@interface OAuthManager : NSObject <RCTBridgeModule, UIWebViewDelegate>
+ (instancetype) sharedManager;
+ (BOOL)setupOAuthHandler:(UIApplication *)application;
+ (BOOL)handleOpenUrl:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
- (BOOL) _configureProvider:(NSString *) name andConfig:(NSDictionary *) config;
- (NSDictionary *) getConfigForProvider:(NSString *)name;
@property (nonatomic, strong) NSDictionary *providerConfig;
@property (nonatomic, strong) NSArray *callbackUrls;
@end
|
Add "TA_String *name" to TA_AddDataSourceParamPriv | #ifndef TA_ADDDATASOURCEPARAM_PRIV_H
#define TA_ADDDATASOURCEPARAM_PRIV_H
/* The following is a private copy of the user provided
* parameters for a TA_AddDataSource call.
*
* Code is in 'ta_data_interface.c'
*/
typedef struct
{
TA_SourceId id;
TA_SourceFlag flags;
TA_Period period;
TA_String *location;
TA_String *info;
TA_String *username;
TA_String *password;
TA_String *category;
TA_String *country;
TA_String *exchange;
TA_String *type;
TA_String *symbol;
} TA_AddDataSourceParamPriv;
/* Function to alloc/free a TA_AddDataSourceParamPriv. */
TA_AddDataSourceParamPriv *TA_AddDataSourceParamPrivAlloc( const TA_AddDataSourceParam *param );
TA_RetCode TA_AddDataSourceParamPrivFree( TA_AddDataSourceParamPriv *toBeFreed );
#endif
| #ifndef TA_ADDDATASOURCEPARAM_PRIV_H
#define TA_ADDDATASOURCEPARAM_PRIV_H
/* The following is a private copy of the user provided
* parameters for a TA_AddDataSource call.
*
* Code is in 'ta_data_interface.c'
*/
typedef struct
{
TA_SourceId id;
TA_SourceFlag flags;
TA_Period period;
TA_String *location;
TA_String *info;
TA_String *username;
TA_String *password;
TA_String *category;
TA_String *country;
TA_String *exchange;
TA_String *type;
TA_String *symbol;
TA_String *name;
} TA_AddDataSourceParamPriv;
/* Function to alloc/free a TA_AddDataSourceParamPriv. */
TA_AddDataSourceParamPriv *TA_AddDataSourceParamPrivAlloc( const TA_AddDataSourceParam *param );
TA_RetCode TA_AddDataSourceParamPrivFree( TA_AddDataSourceParamPriv *toBeFreed );
#endif
|
Fix broken signal connection CVS_SILENT | //
// C++ Interface: getdetailstask
//
// Description:
//
//
// Author: SUSE AG <>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef GETDETAILSTASK_H
#define GETDETAILSTASK_H
#include "gwerror.h"
#include "requesttask.h"
/**
This task fetches the details for a set of user IDs from the server. Sometimes we get an event that only has a DN, and we need other details before showing the event to the user.
@author SUSE AG
*/
using namespace GroupWise;
class GetDetailsTask : public RequestTask
{
Q_OBJECT
public:
GetDetailsTask( Task * parent );
~GetDetailsTask();
bool take( Transfer * transfer );
void userDNs( const QStringList & userDNs );
signals:
void gotContactUserDetails( const ContactDetails & );
protected:
GroupWise::ContactDetails extractUserDetails( Field::MultiField * details );
};
#endif
| //
// C++ Interface: getdetailstask
//
// Description:
//
//
// Author: SUSE AG <>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef GETDETAILSTASK_H
#define GETDETAILSTASK_H
#include "gwerror.h"
#include "requesttask.h"
/**
This task fetches the details for a set of user IDs from the server. Sometimes we get an event that only has a DN, and we need other details before showing the event to the user.
@author SUSE AG
*/
using namespace GroupWise;
class GetDetailsTask : public RequestTask
{
Q_OBJECT
public:
GetDetailsTask( Task * parent );
~GetDetailsTask();
bool take( Transfer * transfer );
void userDNs( const QStringList & userDNs );
signals:
void gotContactUserDetails( const GroupWise::ContactDetails & );
protected:
GroupWise::ContactDetails extractUserDetails( Field::MultiField * details );
};
#endif
|
Add a default constructor for FormData. There are too many places that create FormDatas, and we shouldn't need to initialize user_submitted for each call site. | // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_FORM_DATA_H__
#define WEBKIT_GLUE_FORM_DATA_H__
#include <vector>
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/form_field.h"
namespace webkit_glue {
// Holds information about a form to be filled and/or submitted.
struct FormData {
// The name of the form.
string16 name;
// GET or POST.
string16 method;
// The URL (minus query parameters) containing the form.
GURL origin;
// The action target of the form.
GURL action;
// true if this form was submitted by a user gesture and not javascript.
bool user_submitted;
// A vector of all the input fields in the form.
std::vector<FormField> fields;
// Used by FormStructureTest.
inline bool operator==(const FormData& form) const {
return (name == form.name &&
StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
origin == form.origin &&
action == form.action &&
user_submitted == form.user_submitted &&
fields == form.fields);
}
};
} // namespace webkit_glue
#endif // WEBKIT_GLUE_FORM_DATA_H__
| // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_FORM_DATA_H__
#define WEBKIT_GLUE_FORM_DATA_H__
#include <vector>
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/form_field.h"
namespace webkit_glue {
// Holds information about a form to be filled and/or submitted.
struct FormData {
// The name of the form.
string16 name;
// GET or POST.
string16 method;
// The URL (minus query parameters) containing the form.
GURL origin;
// The action target of the form.
GURL action;
// true if this form was submitted by a user gesture and not javascript.
bool user_submitted;
// A vector of all the input fields in the form.
std::vector<FormField> fields;
FormData() : user_submitted(false) {}
// Used by FormStructureTest.
inline bool operator==(const FormData& form) const {
return (name == form.name &&
StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
origin == form.origin &&
action == form.action &&
user_submitted == form.user_submitted &&
fields == form.fields);
}
};
} // namespace webkit_glue
#endif // WEBKIT_GLUE_FORM_DATA_H__
|
Use forward declaration for MeterWnd | #pragma once
#include "MeterWnd.h"
class Animation {
public:
virtual bool Animate(MeterWnd *meterWnd) = 0;
virtual void Reset(MeterWnd *meterWnd) = 0;
}; | #pragma once
class MeterWnd;
class Animation {
public:
virtual bool Animate(MeterWnd *meterWnd) = 0;
virtual void Reset(MeterWnd *meterWnd) = 0;
}; |
Update barrier test to new api. | /****************************************************
* This is a test that will test barriers *
****************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include "carbon_user.h"
#include "capi.h"
#include "sync_api.h"
carbon_barrier_t my_barrier;
// Functions executed by threads
void* test_wait_barrier(void * threadid);
int main(int argc, char* argv[]) // main begins
{
CarbonStartSim();
const unsigned int num_threads = 5;
carbon_thread_t threads[num_threads];
barrierInit(&my_barrier, num_threads);
for(unsigned int i = 0; i < num_threads; i++)
threads[i] = CarbonSpawnThread(test_wait_barrier, (void *) i);
for(unsigned int i = 0; i < num_threads; i++)
CarbonJoinThread(threads[i]);
printf("Finished running barrier test!.\n");
CarbonStopSim();
return 0;
} // main ends
void* test_wait_barrier(void *threadid)
{
for (unsigned int i = 0; i < 50; i++)
barrierWait(&my_barrier);
return NULL;
}
| /****************************************************
* This is a test that will test barriers *
****************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include "carbon_user.h"
#include "capi.h"
#include "sync_api.h"
carbon_barrier_t my_barrier;
// Functions executed by threads
void* test_wait_barrier(void * threadid);
int main(int argc, char* argv[]) // main begins
{
CarbonStartSim();
const unsigned int num_threads = 5;
carbon_thread_t threads[num_threads];
CarbonBarrierInit(&my_barrier, num_threads);
for(unsigned int i = 0; i < num_threads; i++)
threads[i] = CarbonSpawnThread(test_wait_barrier, (void *) i);
for(unsigned int i = 0; i < num_threads; i++)
CarbonJoinThread(threads[i]);
printf("Finished running barrier test!.\n");
CarbonStopSim();
return 0;
} // main ends
void* test_wait_barrier(void *threadid)
{
for (unsigned int i = 0; i < 50; i++)
CarbonBarrierWait(&my_barrier);
return NULL;
}
|
Add path helpers which handle paths relative to project root. | #ifndef SRC_UTILS_PATH_HELPER_H_
#define SRC_UTILS_PATH_HELPER_H_
#include <QFile>
#include <QUrl>
#include <QDir>
#include <QCoreApplication>
#include <string>
inline QString absolutePathOfRelativeUrl(QUrl url)
{
return QDir(QCoreApplication::applicationDirPath())
.absoluteFilePath(url.toLocalFile());
}
inline std::string absolutePathOfRelativePath(std::string relativePath)
{
return QDir(QCoreApplication::applicationDirPath())
.absoluteFilePath(QString(relativePath.c_str()))
.toStdString();
}
#endif // SRC_UTILS_PATH_HELPER_H_
| #ifndef SRC_UTILS_PATH_HELPER_H_
#define SRC_UTILS_PATH_HELPER_H_
#include <QFile>
#include <QUrl>
#include <QDir>
#include <QCoreApplication>
#include <string>
#include "./project_root.h"
inline QString relativeApplicationToProjectRootPath()
{
return QDir(QCoreApplication::applicationDirPath())
.relativeFilePath(QString(PROJECT_ROOT));
}
inline QString absolutePathOfRelativeUrl(QUrl url)
{
return QDir(QCoreApplication::applicationDirPath())
.absoluteFilePath(url.toLocalFile());
}
inline QString absolutePathOfProjectRelativePath(QString path)
{
return QDir(QDir(QCoreApplication::applicationDirPath())
.absoluteFilePath(relativeApplicationToProjectRootPath()))
.absoluteFilePath(path);
}
inline QString absolutePathOfProjectRelativeUrl(QUrl url)
{
return absolutePathOfProjectRelativePath(url.toLocalFile());
}
inline std::string absolutePathOfRelativePath(std::string relativePath)
{
return QDir(QCoreApplication::applicationDirPath())
.absoluteFilePath(QString(relativePath.c_str()))
.toStdString();
}
inline std::string absolutePathOfProjectRelativePath(std::string relativePath)
{
return absolutePathOfProjectRelativePath(QString(relativePath.c_str()))
.toStdString();
}
#endif // SRC_UTILS_PATH_HELPER_H_
|
Fix bug in SPYWAIT helpers | #ifndef NEOVIM_QT_TEST_COMMON
#define NEOVIM_QT_TEST_COMMON
// This is just a fix for QSignalSpy::wait
// http://stackoverflow.com/questions/22390208/google-test-mock-with-qt-signals
#define SPYWAIT(spy) (spy.count()>0||spy.wait())
#define SPYWAIT2(spy, time) (spy.count()>0||spy.wait(time))
#endif
| #ifndef NEOVIM_QT_TEST_COMMON
#define NEOVIM_QT_TEST_COMMON
// This is just a fix for QSignalSpy::wait
// http://stackoverflow.com/questions/22390208/google-test-mock-with-qt-signals
bool SPYWAIT(QSignalSpy &spy, int timeout=10000)
{
return spy.count()>0||spy.wait(timeout);
}
bool SPYWAIT2(QSignalSpy &spy, int timeout=5000)
{
return spy.count()>0||spy.wait(timeout);
}
#endif
|
Add a regression test for disabled client mode | /*
* Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include "s2n_test.h"
#include <stdlib.h>
#include <s2n.h>
int main(int argc, char **argv)
{
struct s2n_connection *conn;
BEGIN_TEST();
EXPECT_NULL(conn = s2n_connection_new(S2N_CLIENT, &err));
EXPECT_SUCCESS(setenv("S2N_ENABLE_INSECURE_CLIENT", "1", 0));
EXPECT_NOT_NULL(conn = s2n_connection_new(S2N_CLIENT, &err));
END_TEST();
}
| |
Adjust ISL enum to make it bss eligible | // Copyright 2020 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#pragma once
#include "tx_api.h"
namespace pw::sync::backend {
struct NativeInterruptSpinLock {
enum class State {
kUnlocked = 1,
kLockedFromInterrupt = 2,
kLockedFromThread = 3,
};
State state; // Used to detect recursion and interrupt context escapes.
UINT saved_interrupt_mask;
UINT saved_preemption_threshold;
};
using NativeInterruptSpinLockHandle = NativeInterruptSpinLock&;
} // namespace pw::sync::backend
| // Copyright 2020 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#pragma once
#include "tx_api.h"
namespace pw::sync::backend {
struct NativeInterruptSpinLock {
enum class State {
kUnlocked = 0,
kLockedFromInterrupt = 1,
kLockedFromThread = 2,
};
State state; // Used to detect recursion and interrupt context escapes.
UINT saved_interrupt_mask;
UINT saved_preemption_threshold;
};
using NativeInterruptSpinLockHandle = NativeInterruptSpinLock&;
} // namespace pw::sync::backend
|
Add content for test case setInvalid-1 | // Copyright 2018 Eotvos Lorand University, Budapest, Hungary
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This test case contains data identical to the included one.
#include "test_l2fwd_test.c"
| |
Update documentation for pointer type change | #ifndef LACO_UTIL_H
#define LACO_UTIL_H
struct LacoState;
/**
* Load a line into the lua stack to be evaluated later
*
* param pointer to LacoState
*
* return -1 if there is no line input to load
*/
int laco_load_line(struct LacoState* laco);
/**
* Called after laco_load_line, this evaluated the line as a function and
* hands of the result for printing
*
* param pointer to LacoState
*/
void laco_handle_line(struct LacoState* laco);
/**
* Kills the loop with exiting message if specified
*
* param pointer to LacoState
* param exit with status
* param error message
*/
void laco_kill(struct LacoState* laco, int status, const char* message);
/**
* When there is a value on the lua stack, it will print out depending on
* the type it is
*
* param pointer to lua_State
*
* return LUA_ERRSYNTAX if the value has some error
*/
int laco_print_type(struct LacoState* laco);
/**
* Prints out and pops off errors pushed into the lua stack
*
* param pointer to lua_State
* param incoming lua stack status
*/
void laco_report_error(struct LacoState* laco, int status);
int laco_is_match(const char** matches, const char* test_string);
#endif /* LACO_UTIL_H */
| #ifndef LACO_UTIL_H
#define LACO_UTIL_H
struct LacoState;
/**
* Load a line into the lua stack to be evaluated later
*
* param pointer to LacoState
*
* return -1 if there is no line input to load
*/
int laco_load_line(struct LacoState* laco);
/**
* Called after laco_load_line, this evaluated the line as a function and
* hands of the result for printing
*
* param pointer to LacoState
*/
void laco_handle_line(struct LacoState* laco);
/**
* Kills the loop with exiting message if specified
*
* param pointer to LacoState
* param exit with status
* param error message
*/
void laco_kill(struct LacoState* laco, int status, const char* message);
/**
* When there is a value on the lua stack, it will print out depending on
* the type it is
*
* param pointer to LacoState
*
* return LUA_ERRSYNTAX if the value has some error
*/
int laco_print_type(struct LacoState* laco);
/**
* Prints out and pops off errors pushed into the lua stack
*
* param pointer to LacoState
* param incoming lua stack status
*/
void laco_report_error(struct LacoState* laco, int status);
int laco_is_match(const char** matches, const char* test_string);
#endif /* LACO_UTIL_H */
|
Add missing include for fd_set declaration | #pragma once
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <errno.h>
#define emsg(s, d) \
fprintf(stderr, "%s(%d): %s %s\n", __func__, __LINE__, s, strerror(d))
#define err(s) emsg(s, errno)
#define err2(fmt, ...) \
do { \
int errno_tmp__ = errno; \
fprintf(stderr, "%s(%d): %s " fmt "\n", __func__, __LINE__, \
strerror(errno_tmp__), __VA_ARGS__); \
} while (0)
#define errstring(s) fprintf(stderr, "%s(%d): %s\n", __func__, __LINE__, s)
void server_usage(void);
int get_accept_fds(const char *host, const char *port, int **fds);
int init_fdset(const int *const fds, size_t nfds, fd_set *fdset);
struct addrinfo *get_connect_addr(const char *host, const char *port);
int open_socket(const char *host, const char *port);
const char * hostname(struct sockaddr * sa, socklen_t length);
| #pragma once
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netdb.h>
#include <string.h>
#include <errno.h>
#define emsg(s, d) \
fprintf(stderr, "%s(%d): %s %s\n", __func__, __LINE__, s, strerror(d))
#define err(s) emsg(s, errno)
#define err2(fmt, ...) \
do { \
int errno_tmp__ = errno; \
fprintf(stderr, "%s(%d): %s " fmt "\n", __func__, __LINE__, \
strerror(errno_tmp__), __VA_ARGS__); \
} while (0)
#define errstring(s) fprintf(stderr, "%s(%d): %s\n", __func__, __LINE__, s)
void server_usage(void);
int get_accept_fds(const char *host, const char *port, int **fds);
int init_fdset(const int *const fds, size_t nfds, fd_set *fdset);
struct addrinfo *get_connect_addr(const char *host, const char *port);
int open_socket(const char *host, const char *port);
const char * hostname(struct sockaddr * sa, socklen_t length);
|
Add constant formatting string for creating hexadecimal chunks. | #ifndef CONSTANTS_INCLUDED
#define WORDLENGTH 11
#define NUMWORDS 65536
#define WORDFILE "words.txt"
#define HEX_CHUNK_LENGTH 4
#define CONSTANTS_INCLUDED
#endif
| #ifndef CONSTANTS_INCLUDED
#define WORDLENGTH 11
#define NUMWORDS 65536
#define WORDFILE "words.txt"
#define HEX_CHUNK_LENGTH 4
#define HEX_CHUNK_FORMAT "%04X"
#define CONSTANTS_INCLUDED
#endif
|
Add documentation for GET_MAP command | #ifndef NET_H
#define NET_H
typedef enum Command {GET_STATE = 'S',
SHOOT = 'F', GET_MAP = 'M', ERROR = 'E'} Command;
#define PORTNUM 7979 /* Port Number */
#define MAXRCVLEN 128 /* Maximal Length of Received Value */
#endif /* NET_H */
| #ifndef NET_H
#define NET_H
/*
* command args reply
*
* GET_MAP none map_seed map_length map_height
*/
typedef enum Command {GET_STATE = 'S',
SHOOT = 'F', GET_MAP = 'M', ERROR = 'E'} Command;
#define PORTNUM 7979 /* Port Number */
#define MAXRCVLEN 128 /* Maximal Length of Received Value */
#endif /* NET_H */
|
Add new option to enable/disable compression | #ifndef CTCONFIG_H
#define CTCONFIG_H
//#define ENABLE_ASSERT_CHECKS
//#define CT_NODE_DEBUG
//#define ENABLE_INTEGRITY_CHECK
//#define ENABLE_COUNTERS
//#define ENABLE_PAGING
//#define SNAPPY_COMPRESSION
#endif // CTCONFIG_H
| #ifndef CTCONFIG_H
#define CTCONFIG_H
//#define ENABLE_ASSERT_CHECKS
//#define CT_NODE_DEBUG
//#define ENABLE_INTEGRITY_CHECK
//#define ENABLE_COUNTERS
//#define ENABLE_PAGING
#define ENABLE_COMPRESSION
//#define SNAPPY_COMPRESSION
#endif // CTCONFIG_H
|
Add conditional for BSS cleanup |
extern unsigned int __bss_start__,__bss_end__;
extern unsigned int ___ctors, ___ctors_end;
extern char __end__;
static char *start_brk = &__end__;
extern void _Z4loopv();
extern void _Z5setupv();
void ___clear_bss()
{
unsigned int *ptr = &__bss_start__;
while (ptr!=&__bss_end__) {
*ptr = 0;
ptr++;
}
}
void ___do_global_ctors()
{
unsigned int *ptr = &___ctors;
while (ptr!=&___ctors_end) {
((void(*)(void))(*ptr))();
ptr++;
}
}
void __cxa_pure_virtual()
{
// Abort here.
}
void exit(){
}
#ifndef NOMAIN
int main(int argc, char **argv)
{
_Z5setupv();
while (1) {
_Z4loopv();
}
}
#endif
void __attribute__((noreturn)) _premain(void)
{
___clear_bss();
___do_global_ctors();
main(0,0);
while(1);
}
void *sbrk(int inc)
{
start_brk+=inc;
return start_brk;
}
|
extern unsigned int __bss_start__,__bss_end__;
extern unsigned int ___ctors, ___ctors_end;
extern char __end__;
static char *start_brk = &__end__;
extern void _Z4loopv();
extern void _Z5setupv();
void ___clear_bss()
{
unsigned int *ptr = &__bss_start__;
while (ptr!=&__bss_end__) {
*ptr = 0;
ptr++;
}
}
void ___do_global_ctors()
{
unsigned int *ptr = &___ctors;
while (ptr!=&___ctors_end) {
((void(*)(void))(*ptr))();
ptr++;
}
}
void __cxa_pure_virtual()
{
// Abort here.
}
void exit(){
}
#ifndef NOMAIN
int main(int argc, char **argv)
{
_Z5setupv();
while (1) {
_Z4loopv();
}
}
#endif
void __attribute__((noreturn)) _premain(void)
{
#ifndef NOCLEARBSS
___clear_bss();
#endif
___do_global_ctors();
main(0,0);
while(1);
}
void *sbrk(int inc)
{
start_brk+=inc;
return start_brk;
}
|
Replace empty arguments definition with void for compatibility | #ifndef _PARSER_H_
#define _PARSER_H_
#include <Python.h>
#include "circular_buffer.h"
typedef enum {
COMPLETE_DATA,
MISSING_DATA,
INVALID_DATA,
PARSE_FATAL_ERROR,
} parse_result;
typedef enum {
PART_CHOOSER,
PART_SINGLE_SIZED,
PART_COUNT,
PART_INLINE,
PART_SIZE,
PART_PYSTRING,
PART_PYINT,
PART_ERROR,
} part_type;
typedef enum {
TYPE_SINGLE_VALUE,
TYPE_LIST_OF_SINGLE_VALUES,
TYPE_LIST_OF_TUPLES
} result_type;
typedef struct {
long parts_count, current_part, next_part_size;
part_type expected_type;
PyObject *result_root, *list;
int result_type;
Py_ssize_t list_length, list_filled;
} parser_state;
PyObject *parser_get_results();
parse_result parser_parse_part(parser_state *s, circular_buffer *buffer);
parse_result parser_parse_unit(parser_state *s, circular_buffer *buffer);
#endif // _PARSER_H_
| #ifndef _PARSER_H_
#define _PARSER_H_
#include <Python.h>
#include "circular_buffer.h"
typedef enum {
COMPLETE_DATA,
MISSING_DATA,
INVALID_DATA,
PARSE_FATAL_ERROR,
} parse_result;
typedef enum {
PART_CHOOSER,
PART_SINGLE_SIZED,
PART_COUNT,
PART_INLINE,
PART_SIZE,
PART_PYSTRING,
PART_PYINT,
PART_ERROR,
} part_type;
typedef enum {
TYPE_SINGLE_VALUE,
TYPE_LIST_OF_SINGLE_VALUES,
TYPE_LIST_OF_TUPLES
} result_type;
typedef struct {
long parts_count, current_part, next_part_size;
part_type expected_type;
PyObject *result_root, *list;
int result_type;
Py_ssize_t list_length, list_filled;
} parser_state;
PyObject *parser_get_results(void);
parse_result parser_parse_part(parser_state *s, circular_buffer *buffer);
parse_result parser_parse_unit(parser_state *s, circular_buffer *buffer);
#endif // _PARSER_H_
|
Fix up the appinfo test | #include <stdlib.h>
#include <gio/gio.h>
int
main (int argc, char *argv[])
{
const gchar *envvar;
gint pid_from_env;
envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
g_assert (envvar != NULL);
pid_from_env = atoi (envvar);
g_assert_cmpint (pid_from_env, ==, getpid ());
envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE");
g_assert_cmpstr (envvar, ==, g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL));
return 0;
}
| #include <stdlib.h>
#include <gio/gio.h>
int
main (int argc, char *argv[])
{
const gchar *envvar;
g_test_init (&argc, &argv, NULL);
envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE");
if (envvar != NULL)
{
gchar *expected;
gint pid_from_env;
expected = g_test_build_filename (G_TEST_DIST, "appinfo-test.desktop", NULL);
g_assert_cmpstr (envvar, ==, expected);
g_free (expected);
envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
g_assert (envvar != NULL);
pid_from_env = atoi (envvar);
g_assert_cmpint (pid_from_env, ==, getpid ());
}
return 0;
}
|
Make the network mock play nice with stubCall (…) | //
// MCKNetworkMock.h
// mocka
//
// Created by Markus Gasser on 26.10.2013.
// Copyright (c) 2013 konoma GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
@class MCKNetworkMock;
@class MCKNetworkRequestMatcher;
@class MCKMockingContext;
typedef MCKNetworkRequestMatcher*(^MCKNetworkActivity)(id url);
@interface MCKNetworkMock : NSObject
#pragma mark - Initialization
- (instancetype)initWithMockingContext:(MCKMockingContext *)context;
#pragma mark - Network Control
@property (nonatomic, readonly, getter = isEnabled) BOOL enabled;
- (void)disable;
- (void)enable;
- (void)startObservingNetworkCalls;
#pragma mark - Stubbing and Verification DSL
@property (nonatomic, readonly) MCKNetworkActivity GET;
@property (nonatomic, readonly) MCKNetworkActivity PUT;
@property (nonatomic, readonly) MCKNetworkActivity POST;
@property (nonatomic, readonly) MCKNetworkActivity DELETE;
@end
#define MCKNetwork _mck_getNetworkMock(self, __FILE__, __LINE__)
#ifndef MCK_DISABLE_NICE_SYNTAX
#define Network MCKNetwork
#endif
extern MCKNetworkMock* _mck_getNetworkMock(id testCase, const char *fileName, NSUInteger lineNumber);
| //
// MCKNetworkMock.h
// mocka
//
// Created by Markus Gasser on 26.10.2013.
// Copyright (c) 2013 konoma GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
@class MCKNetworkMock;
@class MCKNetworkRequestMatcher;
@class MCKMockingContext;
typedef MCKNetworkRequestMatcher*(^MCKNetworkActivity)(id url);
@interface MCKNetworkMock : NSObject
#pragma mark - Initialization
- (instancetype)initWithMockingContext:(MCKMockingContext *)context;
#pragma mark - Network Control
@property (nonatomic, readonly, getter = isEnabled) BOOL enabled;
- (void)disable;
- (void)enable;
- (void)startObservingNetworkCalls;
#pragma mark - Stubbing and Verification DSL
@property (nonatomic, readonly) MCKNetworkActivity GET;
@property (nonatomic, readonly) MCKNetworkActivity PUT;
@property (nonatomic, readonly) MCKNetworkActivity POST;
@property (nonatomic, readonly) MCKNetworkActivity DELETE;
@end
#define MCKNetwork (id)_mck_getNetworkMock(self, __FILE__, __LINE__)
#ifndef MCK_DISABLE_NICE_SYNTAX
#define Network MCKNetwork
#endif
extern MCKNetworkMock* _mck_getNetworkMock(id testCase, const char *fileName, NSUInteger lineNumber);
|
Add quiet fixture for commandline tests | /*
* Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file test/test-common/QuietCommandlineTest.h
* @author Pawel Wieczorek <p.wieczorek2@samsung.com>
* @version 1.0
* @brief Fixture for tests of commandline parsers with no output to std::cout nor std::cerr
*/
#ifndef TEST_TEST_COMMON_QUIETCOMMANDLINETEST_H_
#define TEST_TEST_COMMON_QUIETCOMMANDLINETEST_H_
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include "BaseCommandlineTest.h"
class QuietCommandlineTest : public BaseCommandlineTest {
public:
void clearOutput(void) {
m_cerr.str(std::string());
m_cout.str(std::string());
}
void getOutput(std::string &out, std::string &err) const {
err = m_cerr.str();
out = m_cout.str();
}
protected:
virtual void SetUp(void) {
m_cerrBackup.reset(std::cerr.rdbuf());
std::cerr.rdbuf(m_cerr.rdbuf());
m_coutBackup.reset(std::cout.rdbuf());
std::cout.rdbuf(m_cout.rdbuf());
}
virtual void TearDown(void) {
destroy_argv();
std::cerr.rdbuf(m_cerrBackup.release());
std::cout.rdbuf(m_coutBackup.release());
}
std::unique_ptr<std::streambuf> m_cerrBackup;
std::unique_ptr<std::streambuf> m_coutBackup;
std::stringstream m_cerr;
std::stringstream m_cout;
};
#endif /* TEST_TEST_COMMONS_QUIETCOMMANDLINETEST_H_ */
| |
Use unsigned long long for uint64_t. Fixes part of the windows buildbot. | // RUN: %clang_cc1 -emit-llvm -o - %s
// PR1386
typedef unsigned long uint64_t;
struct X {
unsigned char pad : 4;
uint64_t a : 64;
} __attribute__((packed)) x;
uint64_t f(void)
{
return x.a;
}
| // RUN: %clang_cc1 -emit-llvm -o - %s
// PR1386
typedef unsigned long long uint64_t;
struct X {
unsigned char pad : 4;
uint64_t a : 64;
} __attribute__((packed)) x;
uint64_t f(void)
{
return x.a;
}
|
Make sure the colorizer is reset | #ifndef BANDIT_COLORED_REPORTER_H
#define BANDIT_COLORED_REPORTER_H
#include <ostream>
#include <bandit/reporters/colorizer.h>
#include <bandit/reporters/progress_reporter.h>
namespace bandit { namespace detail {
struct colored_reporter : public progress_reporter
{
colored_reporter(std::ostream& stm,
const failure_formatter& failure_formatter,
const colorizer& colorizer)
: progress_reporter(failure_formatter), stm_(stm), colorizer_(colorizer)
{}
protected:
std::ostream& stm_;
const detail::colorizer& colorizer_;
};
}}
#endif
| #ifndef BANDIT_COLORED_REPORTER_H
#define BANDIT_COLORED_REPORTER_H
#include <ostream>
#include <bandit/reporters/colorizer.h>
#include <bandit/reporters/progress_reporter.h>
namespace bandit { namespace detail {
struct colored_reporter : public progress_reporter
{
colored_reporter(std::ostream& stm,
const failure_formatter& failure_formatter,
const colorizer& colorizer)
: progress_reporter(failure_formatter), stm_(stm), colorizer_(colorizer)
{}
virtual ~colored_reporter()
{
stm_ << colorizer_.reset();
}
protected:
std::ostream& stm_;
const detail::colorizer& colorizer_;
};
}}
#endif
|
Address -Wsign-conversion in emscripten build | #include "os_common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
FILE *os_fopen(const char *path, const char *mode)
{
FILE *f = NULL;
if (path[0] == '/' && strncmp(path, "/dev", 4)) {
// absolute path, needs to be construed relative to mountpoint
size_t need = 1 + snprintf(NULL, 0, MOUNT_POINT "%s", path);
char *buf = malloc(need);
snprintf(buf, need, MOUNT_POINT "%s", path);
f = fopen(buf, mode);
free(buf);
} else {
// either a relative path or a device path -- don't mangle path
// default behaviour, os_preamble() has already chdir()ed correctly
f = fopen(path, mode);
}
return f;
}
| #include "os_common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
FILE *os_fopen(const char *path, const char *mode)
{
FILE *f = NULL;
if (path[0] == '/' && strncmp(path, "/dev", 4)) {
// absolute path, needs to be construed relative to mountpoint
int need = 1 + snprintf(NULL, 0, MOUNT_POINT "%s", path);
char *buf = malloc((size_t)need);
snprintf(buf, (size_t)need, MOUNT_POINT "%s", path);
f = fopen(buf, mode);
free(buf);
} else {
// either a relative path or a device path -- don't mangle path
// default behaviour, os_preamble() has already chdir()ed correctly
f = fopen(path, mode);
}
return f;
}
|
Change SET_ERRNO to be inline function | /**
* @file
* @brief
*
* @author Anton Kozlov
* @date 25.06.2012
*/
#ifndef COMPAT_POSIX_POSIX_ERRNO_H_
#define COMPAT_POSIX_POSIX_ERRNO_H_
#include <kernel/task/resource/errno.h>
#define errno (*task_self_resource_errno())
#define SET_ERRNO(e) \
({ errno = e; -1; /* to let 'return SET_ERRNO(...)' */ })
#endif /* COMPAT_POSIX_POSIX_ERRNO_H_ */
| /**
* @file
* @brief
*
* @author Anton Kozlov
* @date 25.06.2012
*/
#ifndef COMPAT_POSIX_POSIX_ERRNO_H_
#define COMPAT_POSIX_POSIX_ERRNO_H_
#include <kernel/task/resource/errno.h>
#include <compiler.h>
#define errno (*task_self_resource_errno())
static inline int SET_ERRNO(int err) {
errno = err;
return -1;
}
#endif /* COMPAT_POSIX_POSIX_ERRNO_H_ */
|
Correct status printout for FI | #define _POSIX_C_SOURCE 1
#include <unistd.h>
#include <inttypes.h>
#include <stdio.h>
#define STATUS_FORMAT "\r\033[2K\t[%" PRId64 "%%] Packets(finished/total): %" PRId64 "/%" PRId64
#define STATUS_FORMAT_FI "\r\033[2K\t[%" PRId64 "%%] Rays(finished/total): %" PRId64 "/%" PRId64
static inline void
print_progress (const int64_t current, const int64_t total)
{
if (isatty(fileno(stderr)))
{
fprintf(stderr, STATUS_FORMAT,
current * 100 / total,
current,
total);
}
}
static inline void
print_progress_fi (const int64_t current, const int64_t total)
{
if (isatty(fileno(stderr)))
{
fprintf(stderr, STATUS_FORMAT_FI,
current * 100 / total,
current,
total);
}
}
| #define _POSIX_C_SOURCE 1
#include <unistd.h>
#include <inttypes.h>
#include <stdio.h>
#define STATUS_FORMAT "\r\033[2K\t[%" PRId64 "%%] Packets(finished/total): %" PRId64 "/%" PRId64
#define STATUS_FORMAT_FI "\r\033[2K\t[%" PRId64 "%%] Bins(finished/total): %" PRId64 "/%" PRId64
static inline void
print_progress (const int64_t current, const int64_t total)
{
if (isatty(fileno(stderr)))
{
fprintf(stderr, STATUS_FORMAT,
current * 100 / total,
current,
total);
}
}
static inline void
print_progress_fi (const int64_t current, const int64_t total)
{
if (isatty(fileno(stderr)))
{
fprintf(stderr, STATUS_FORMAT_FI,
current * 100 / total,
current,
total);
}
}
|
Revert "PTA: use bitvector-based points-to set representation" | #ifndef DG_POINTS_TO_SET_H_
#define DG_POINTS_TO_SET_H_
#include "dg/PointerAnalysis/PointsToSets/OffsetsSetPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/SimplePointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/SeparateOffsetsPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/PointerIdPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/SmallOffsetsPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/AlignedSmallOffsetsPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/AlignedPointerIdPointsToSet.h"
namespace dg {
namespace pta {
//using PointsToSetT = OffsetsSetPointsToSet;
using PointsToSetT = PointerIdPointsToSet;
using PointsToMapT = std::map<Offset, PointsToSetT>;
} // namespace pta
} // namespace dg
#endif
| #ifndef DG_POINTS_TO_SET_H_
#define DG_POINTS_TO_SET_H_
#include "dg/PointerAnalysis/PointsToSets/OffsetsSetPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/SimplePointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/SeparateOffsetsPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/PointerIdPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/SmallOffsetsPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/AlignedSmallOffsetsPointsToSet.h"
#include "dg/PointerAnalysis/PointsToSets/AlignedPointerIdPointsToSet.h"
namespace dg {
namespace pta {
using PointsToSetT = OffsetsSetPointsToSet;
using PointsToMapT = std::map<Offset, PointsToSetT>;
} // namespace pta
} // namespace dg
#endif
|
Fix compilation on non-windows, had not tested this before and was missinga platform include. |
/* Copyright 2013 Jonne Nauha / jonne@adminotech.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(__MINGW32__) && !defined(OGRE_STATIC_LIB)
# ifdef RenderSystem_Headless_EXPORTS
# define _OgreHeadlessExport __declspec(dllexport)
# else
# if defined(__MINGW32__)
# define _OgreHeadlessExport
# else
# define _OgreHeadlessExport __declspec(dllimport)
# endif
# endif
#elif defined (OGRE_GCC_VISIBILITY)
# define _OgreHeadlessExport __attribute__ ((visibility("default")))
#else
# define _OgreHeadlessExport
#endif
|
/* Copyright 2013 Jonne Nauha / jonne@adminotech.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "OgrePrerequisites.h"
#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(__MINGW32__) && !defined(OGRE_STATIC_LIB)
# ifdef RenderSystem_Headless_EXPORTS
# define _OgreHeadlessExport __declspec(dllexport)
# else
# if defined(__MINGW32__)
# define _OgreHeadlessExport
# else
# define _OgreHeadlessExport __declspec(dllimport)
# endif
# endif
#elif defined (OGRE_GCC_VISIBILITY)
# define _OgreHeadlessExport __attribute__ ((visibility("default")))
#else
# define _OgreHeadlessExport
#endif
|
Solve undefined symbol issue spelling the right class name in the linkdef. | /*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifdef __ROOTCLING__
// All these are there for the autoloading
#pragma link C++ class ROOT::Experimental::TDataFrame-;
#pragma link C++ class ROOT::Experimental::TDF::TInterface<ROOT::Detail::TDF::TFilterBase>-;
#pragma link C++ class ROOT::Experimental::TDF::TInterface<ROOT::Detail::TDF::TCustomColumnBase>-;
#pragma link C++ class ROOT::Detail::TLoopManager-;
#endif
| /*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifdef __ROOTCLING__
// All these are there for the autoloading
#pragma link C++ class ROOT::Experimental::TDataFrame-;
#pragma link C++ class ROOT::Experimental::TDF::TInterface<ROOT::Detail::TDF::TFilterBase>-;
#pragma link C++ class ROOT::Experimental::TDF::TInterface<ROOT::Detail::TDF::TCustomColumnBase>-;
#pragma link C++ class ROOT::Detail::TDF::TLoopManager-;
#endif
|
Fix the sep and esep attributes to allow additive margins in addition to scaled margins. | /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef CLUSTEREDGES_H
#define CLUSTEREDGES_H
#include <render.h>
extern int compoundEdges(graph_t * g, double SEP, int splines);
#endif
#ifdef __cplusplus
}
#endif
| /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef CLUSTEREDGES_H
#define CLUSTEREDGES_H
#include <render.h>
#include <adjust.h>
extern int compoundEdges(graph_t * g, expand_t* pm, int splines);
#endif
#ifdef __cplusplus
}
#endif
|
Add missing new line character | #include <stdio.h>
int main(void)
{
printf("Hello world!");
return 0;
} | #include <stdio.h>
int main(void)
{
printf("Hello world!\n");
return 0;
} |
Swap two overloads to make g++ happy. | #ifndef PL_ZERO_UTIL_H
#define PL_ZERO_UTIL_H
#include <sstream>
namespace pl0 {
#if defined(_MSC_VER) || defined(__GNUC__)
namespace polyfill {
template <typename T, typename... Args>
void fold_write_stream(std::ostringstream &oss, T value, Args... args) {
oss << value;
fold_write_stream(oss, args...);
}
template <typename T>
void fold_write_stream(std::ostringstream &oss, T value) {
oss << value;
}
}
#endif
class general_error {
std::string message_;
public:
template <typename... Args>
general_error(Args... args) {
std::ostringstream oss;
#if defined(_MSC_VER) || defined(__GNUC__)
// Visual Studio 2017 does not support fold expression now.
// We need to make a polyfill.
polyfill::fold_write_stream(oss, args...);
#else
oss << ... << args;
#endif
message_ = oss.str();
}
const std::string &what() const { return message_; }
};
}
#endif
| #ifndef PL_ZERO_UTIL_H
#define PL_ZERO_UTIL_H
#include <sstream>
namespace pl0 {
#if defined(_MSC_VER) || defined(__GNUC__)
namespace polyfill {
template <typename T>
void fold_write_stream(std::ostringstream &oss, T value) {
oss << value;
}
template <typename T, typename... Args>
void fold_write_stream(std::ostringstream &oss, T value, Args... args) {
oss << value;
fold_write_stream(oss, args...);
}
}
#endif
class general_error {
std::string message_;
public:
template <typename... Args>
general_error(Args... args) {
std::ostringstream oss;
#if defined(_MSC_VER) || defined(__GNUC__)
// Visual Studio 2017 does not support fold expression now.
// We need to make a polyfill.
polyfill::fold_write_stream(oss, args...);
#else
oss << ... << args;
#endif
message_ = oss.str();
}
const std::string &what() const { return message_; }
};
}
#endif
|
Add stub for LLA coordinates. | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2021 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
| |
Correct after list API changes. | #include "std/list.h"
#include "std/memory.h"
#include "std/stack.h"
struct Stack {
NodeT *list;
AtomPoolT *pool;
};
StackT *NewStack(AtomPoolT *pool) {
StackT *stack = NEW_S(StackT);
stack->list = NewList();
stack->pool = pool;
StackPushNew(stack);
return stack;
}
void DeleteStack(StackT *stack) {
if (stack) {
DeleteList(stack->list);
DeleteAtomPool(stack->pool);
DELETE(stack);
}
}
void StackReset(StackT *stack) {
ResetList(stack->list);
ResetAtomPool(stack->pool);
}
void StackRemove(StackT *stack) {
AtomFree(stack->pool, ListPopFront(stack->list));
}
PtrT StackPeek(StackT *stack, size_t index) {
return ListGetNth(stack->list, index);
}
PtrT StackTop(StackT *stack) {
return ListGetNth(stack->list, 0);
}
PtrT StackPushNew(StackT *stack) {
PtrT item = AtomNew0(stack->pool);
ListPushFront(stack->list, item);
return item;
}
size_t StackSize(StackT *stack) {
return ListSize(stack->list);
}
| #include "std/list.h"
#include "std/memory.h"
#include "std/stack.h"
struct Stack {
ListT *list;
AtomPoolT *pool;
};
StackT *NewStack(AtomPoolT *pool) {
StackT *stack = NEW_S(StackT);
stack->list = NewList();
stack->pool = pool;
StackPushNew(stack);
return stack;
}
void DeleteStack(StackT *stack) {
if (stack) {
DeleteList(stack->list);
DeleteAtomPool(stack->pool);
DELETE(stack);
}
}
void StackReset(StackT *stack) {
ResetList(stack->list);
ResetAtomPool(stack->pool);
}
void StackRemove(StackT *stack) {
AtomFree(stack->pool, ListPopFront(stack->list));
}
PtrT StackPeek(StackT *stack, size_t index) {
return ListGet(stack->list, index);
}
PtrT StackTop(StackT *stack) {
return ListGet(stack->list, 0);
}
PtrT StackPushNew(StackT *stack) {
PtrT item = AtomNew0(stack->pool);
ListPushFront(stack->list, item);
return item;
}
size_t StackSize(StackT *stack) {
return ListSize(stack->list);
}
|
Fix a type of return value | #pragma once
// #define private public // for tests
#include "common.h"
// associations of units
#define IVCO VCO
#define IVCF VCF
#define IVCA VCA
#define IEG EG
#define ILFO LFO
#define ISlewRateLimiter SlewRateLimiter
#define IVoice Voice
#define ISynthCore SynthCore
#include "vco.h"
#include "vcf.h"
#include "vca.h"
#include "eg.h"
#include "lfo.h"
#include "slew-rate-limiter.h"
#include "voice.h"
#include "synth-core.h"
template <uint8_t T>
class Synth {
public:
INLINE static void initialize() {
ISynthCore<0>::initialize();
}
INLINE static void receive_midi_byte(uint8_t b) {
return ISynthCore<0>::receive_midi_byte(b);
}
INLINE static int8_t clock() {
return ISynthCore<0>::clock();
}
};
| #pragma once
// #define private public // for tests
#include "common.h"
// associations of units
#define IVCO VCO
#define IVCF VCF
#define IVCA VCA
#define IEG EG
#define ILFO LFO
#define ISlewRateLimiter SlewRateLimiter
#define IVoice Voice
#define ISynthCore SynthCore
#include "vco.h"
#include "vcf.h"
#include "vca.h"
#include "eg.h"
#include "lfo.h"
#include "slew-rate-limiter.h"
#include "voice.h"
#include "synth-core.h"
template <uint8_t T>
class Synth {
public:
INLINE static void initialize() {
ISynthCore<0>::initialize();
}
INLINE static void receive_midi_byte(uint8_t b) {
ISynthCore<0>::receive_midi_byte(b);
}
INLINE static int8_t clock() {
return ISynthCore<0>::clock();
}
};
|
Change votes to use double. | #ifndef PROPOSER_H
#define PROPOSER_H
#include <boost/shared_ptr.hpp>
#include <vector>
#include <map>
#include "proctor/detector.h"
#include "proctor/database_entry.h"
namespace pcl
{
namespace proctor
{
struct Candidate {
std::string id;
float votes;
};
class Proposer {
public:
typedef boost::shared_ptr<Proposer> Ptr;
typedef boost::shared_ptr<const Proposer> ConstPtr;
typedef boost::shared_ptr<std::map<std::string, Entry> > DatabasePtr;
typedef boost::shared_ptr<const std::map<std::string, Entry> > ConstDatabasePtr;
Proposer()
{}
void
setDatabase(const DatabasePtr database)
{
database_ = database;
}
virtual void
getProposed(int max_num, Entry &query, std::vector<std::string> &input, std::vector<std::string> &output) = 0;
virtual void
selectBestCandidates(int max_num, vector<Candidate> &ballot, std::vector<std::string> &output);
protected:
DatabasePtr database_;
};
}
}
#endif
| #ifndef PROPOSER_H
#define PROPOSER_H
#include <boost/shared_ptr.hpp>
#include <vector>
#include <map>
#include "proctor/detector.h"
#include "proctor/database_entry.h"
namespace pcl
{
namespace proctor
{
struct Candidate {
std::string id;
double votes;
};
class Proposer {
public:
typedef boost::shared_ptr<Proposer> Ptr;
typedef boost::shared_ptr<const Proposer> ConstPtr;
typedef boost::shared_ptr<std::map<std::string, Entry> > DatabasePtr;
typedef boost::shared_ptr<const std::map<std::string, Entry> > ConstDatabasePtr;
Proposer()
{}
void
setDatabase(const DatabasePtr database)
{
database_ = database;
}
virtual void
getProposed(int max_num, Entry &query, std::vector<std::string> &input, std::vector<std::string> &output) = 0;
virtual void
selectBestCandidates(int max_num, vector<Candidate> &ballot, std::vector<std::string> &output);
protected:
DatabasePtr database_;
};
}
}
#endif
|
Mark ObjC magic as "internal use only" | #import <Foundation/Foundation.h>
void memorySafeExecuteSelector(Class klass, SEL selector);
| #import <Foundation/Foundation.h>
/**
Internal Fleet use only
*/
void memorySafeExecuteSelector(Class klass, SEL selector);
|
Fix nvic vectors number to 16 + 91 | /* mbed Microcontroller Library - cmsis_nvic
* Copyright (c) 2009-2011 ARM Limited. All rights reserved.
*
* CMSIS-style functionality to support dynamic vectors
*/
#ifndef MBED_CMSIS_NVIC_H
#define MBED_CMSIS_NVIC_H
#include <stdint.h>
#define NVIC_NUM_VECTORS (16 + 81) // CORE + MCU Peripherals
#define NVIC_USER_IRQ_OFFSET 16
#include "stm32f429xx.h"
#ifdef __cplusplus
extern "C" {
#endif
void NVIC_Relocate(void);
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
uint32_t NVIC_GetVector(IRQn_Type IRQn);
#ifdef __cplusplus
}
#endif
#endif
| /* mbed Microcontroller Library - cmsis_nvic
* Copyright (c) 2009-2011 ARM Limited. All rights reserved.
*
* CMSIS-style functionality to support dynamic vectors
*/
#ifndef MBED_CMSIS_NVIC_H
#define MBED_CMSIS_NVIC_H
#include <stdint.h>
#define NVIC_NUM_VECTORS (16 + 91) // CORE + MCU Peripherals
#define NVIC_USER_IRQ_OFFSET 16
#include "stm32f429xx.h"
#ifdef __cplusplus
extern "C" {
#endif
void NVIC_Relocate(void);
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
uint32_t NVIC_GetVector(IRQn_Type IRQn);
#ifdef __cplusplus
}
#endif
#endif
|
Add new optionnal constructor parameter to set Sample::primitiveId at construction time | #ifndef TYPES_H
#define TYPES_H
#include "primitive.h"
#include <vector>
#include "eigen3/Eigen/StdVector"
namespace InputGen{
namespace Application{
typedef double Scalar;
typedef typename InputGen::LinearPrimitive<InputGen::Application::Scalar> Primitive;
//! \brief sample storing a position and its assignment
struct Sample: public Primitive::vec{
typedef Primitive::vec Base;
typedef Base::Scalar Scalar;
int primitiveId;
inline Sample(): Base(), primitiveId(-1) {}
template <class Derived>
inline Sample(const Derived&v): Base(v), primitiveId(-1) {}
inline Sample(const Scalar&x,
const Scalar&y,
const Scalar&z): Base(x,y,z), primitiveId(-1) {}
};
typedef std::vector<Sample,
Eigen::aligned_allocator<Sample> > PointSet;
}
}
#endif // TYPES_H
| #ifndef TYPES_H
#define TYPES_H
#include "primitive.h"
#include <vector>
#include "eigen3/Eigen/StdVector"
namespace InputGen{
namespace Application{
typedef double Scalar;
typedef typename InputGen::LinearPrimitive<InputGen::Application::Scalar> Primitive;
//! \brief sample storing a position and its assignment
struct Sample: public Primitive::vec{
typedef Primitive::vec Base;
typedef Base::Scalar Scalar;
int primitiveId;
inline Sample(int id = -1): Base(), primitiveId(id) {}
template <class Derived>
inline Sample(const Derived&v, int id = -1): Base(v), primitiveId(id) {}
inline Sample(const Scalar&x,
const Scalar&y,
const Scalar&z,
int id = -1): Base(x,y,z), primitiveId(id) {}
};
typedef std::vector<Sample,
Eigen::aligned_allocator<Sample> > PointSet;
}
}
#endif // TYPES_H
|
Update reference to IOperation to include Internal namespace | #pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_
#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
friend class Transaction;
public:
static bool begin();
// Modifying methods
static bool post(TaskId, SerializedTask&);
static bool put(TaskId, SerializedTask&);
static bool erase(TaskId);
static boost::variant<bool, SerializedTask> get(TaskId);
static std::vector<SerializedTask>
filter(const std::function<bool(SerializedTask)>&);
private:
static DataStore& getInstance();
bool isServing = false;
std::deque<IOperation> operationsQueue;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_DATASTORE_H_
| #pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_
#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
friend class Transaction;
public:
static bool begin();
// Modifying methods
static bool post(TaskId, SerializedTask&);
static bool put(TaskId, SerializedTask&);
static bool erase(TaskId);
static boost::variant<bool, SerializedTask> get(TaskId);
static std::vector<SerializedTask>
filter(const std::function<bool(SerializedTask)>&);
private:
static DataStore& getInstance();
bool isServing = false;
std::deque<Internal::IOperation> operationsQueue;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_DATASTORE_H_
|
Add 'explicit' keyword to single argument ctor | #ifndef PRIMARY_VIRTUALSECONDARY_H_
#define PRIMARY_VIRTUALSECONDARY_H_
#include <string>
#include "libaktualizr/types.h"
#include "managedsecondary.h"
namespace Primary {
class VirtualSecondaryConfig : public ManagedSecondaryConfig {
public:
VirtualSecondaryConfig() : ManagedSecondaryConfig(Type) {}
VirtualSecondaryConfig(const Json::Value& json_config);
static std::vector<VirtualSecondaryConfig> create_from_file(const boost::filesystem::path& file_full_path);
void dump(const boost::filesystem::path& file_full_path) const;
public:
static const char* const Type;
};
class VirtualSecondary : public ManagedSecondary {
public:
explicit VirtualSecondary(Primary::VirtualSecondaryConfig sconfig_in);
~VirtualSecondary() override = default;
std::string Type() const override { return VirtualSecondaryConfig::Type; }
data::InstallationResult putMetadata(const Uptane::Target& target) override;
data::InstallationResult putRoot(const std::string& root, bool director) override;
data::InstallationResult sendFirmware(const Uptane::Target& target) override;
data::InstallationResult install(const Uptane::Target& target) override;
bool ping() const override { return true; }
};
} // namespace Primary
#endif // PRIMARY_VIRTUALSECONDARY_H_
| #ifndef PRIMARY_VIRTUALSECONDARY_H_
#define PRIMARY_VIRTUALSECONDARY_H_
#include <string>
#include "libaktualizr/types.h"
#include "managedsecondary.h"
namespace Primary {
class VirtualSecondaryConfig : public ManagedSecondaryConfig {
public:
VirtualSecondaryConfig() : ManagedSecondaryConfig(Type) {}
explicit VirtualSecondaryConfig(const Json::Value& json_config);
static std::vector<VirtualSecondaryConfig> create_from_file(const boost::filesystem::path& file_full_path);
void dump(const boost::filesystem::path& file_full_path) const;
public:
static const char* const Type;
};
class VirtualSecondary : public ManagedSecondary {
public:
explicit VirtualSecondary(Primary::VirtualSecondaryConfig sconfig_in);
~VirtualSecondary() override = default;
std::string Type() const override { return VirtualSecondaryConfig::Type; }
data::InstallationResult putMetadata(const Uptane::Target& target) override;
data::InstallationResult putRoot(const std::string& root, bool director) override;
data::InstallationResult sendFirmware(const Uptane::Target& target) override;
data::InstallationResult install(const Uptane::Target& target) override;
bool ping() const override { return true; }
};
} // namespace Primary
#endif // PRIMARY_VIRTUALSECONDARY_H_
|
Enable this test only for Darwin. | // RUN: %llvmgcc %s -S -O0 -o - | FileCheck %s
// REQUIRES: disabled
// Radar 9156771
typedef struct RGBColor {
unsigned short red;
unsigned short green;
unsigned short blue;
} RGBColor;
RGBColor func();
RGBColor X;
void foo() {
//CHECK: store i48
X = func();
}
| // RUN: %llvmgcc %s -S -O0 -o - | FileCheck %s
// XTARGET: x86_64-apple-darwin
// Radar 9156771
typedef struct RGBColor {
unsigned short red;
unsigned short green;
unsigned short blue;
} RGBColor;
RGBColor func();
RGBColor X;
void foo() {
//CHECK: store i48
X = func();
}
|
Test where the variables are stored in memory | /**
* How to run
* $ gcc -o show_stored_address show_stored_address.c
* $ ./show_stored_address
*/
#include <stdio.h>
#include <stdlib.h>
char global_str[] = "global string";
static char static_global_str[] = "static global string";
void show_stored_address()
{
char local_str[] = "local string";
static char static_local_str[] = "static local string";
char *malloc_str = NULL;
malloc_str = (char *) malloc(32);
if (malloc_str) {
sprintf(malloc_str, "%s", "malloc string");
}
printf("%p: %s \n", local_str, local_str);
printf("%p: %s \n", static_local_str, static_local_str);
printf("%p: %s \n", global_str, global_str);
printf("%p: %s \n", static_global_str, static_global_str);
printf("%p: %s \n", malloc_str, malloc_str);
printf("%p: %s \n", "literal string", "literal string");
}
int main(int argc, char *argv[])
{
printf("Hello, world!\n");
show_stored_address();
return 0;
}
/*
Console output:
$ gcc -o show_stored_address show_stored_address.c
$ ./show_stored_address
$ ./show_stored_address
Hello, world!
0xffffcbbb: local string
0x100402040: static local string
0x100402010: global string
0x100402020: static global string
0x600000440: malloc string
0x100403009: literal string
The variables are stored in one of stack, static(data segment) or heap regions
*/
| |
Fix grammar bug in example | /*
* Copyright 2011-2013 Gregory Banks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <np.h>
#include <stdio.h>
static void test_segv(void)
{
fprintf(stderr, "About to do follow a NULL pointer\n");
*(char *)0 = 0;
}
| /*
* Copyright 2011-2013 Gregory Banks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <np.h>
#include <stdio.h>
static void test_segv(void)
{
fprintf(stderr, "About to follow a NULL pointer\n");
*(char *)0 = 0;
}
|
Add relational traces cluster-based example | // SKIP PARAM: --sets ana.activated[+] octApron --sets exp.solver.td3.side_widen cycle_self
// requires cycle_self to pass
#include <pthread.h>
#include <assert.h>
int g = 42;
int h = 42;
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
int x; // rand
pthread_mutex_lock(&B);
pthread_mutex_lock(&A);
g = x;
h = x - 17;
pthread_mutex_unlock(&A);
pthread_mutex_lock(&A);
h = x;
pthread_mutex_unlock(&A);
pthread_mutex_unlock(&B);
return NULL;
}
void *t2_fun(void *arg) {
int x, y;
pthread_mutex_lock(&A);
x = g;
y = h;
pthread_mutex_unlock(&A);
assert(y <= x); // requires cycle_self
return NULL;
}
void *t3_fun(void *arg) {
int x, y;
pthread_mutex_lock(&B);
pthread_mutex_lock(&A);
x = g;
y = h;
pthread_mutex_unlock(&A);
pthread_mutex_unlock(&B);
assert(y == x);
return NULL;
}
int main(void) {
int x, y;
pthread_t id, id2, id3;
pthread_create(&id, NULL, t_fun, NULL);
pthread_create(&id2, NULL, t2_fun, NULL);
pthread_create(&id3, NULL, t3_fun, NULL);
// thread 4
pthread_mutex_lock(&A);
x = g;
y = h;
pthread_mutex_lock(&B);
assert(y == x);
pthread_mutex_unlock(&B);
pthread_mutex_unlock(&A);
assert(y == x);
return 0;
}
| |
Correct case of include file to build on Linux. | #include "FreeRTOS.h"
#include "Semphr.h"
#include "task.h"
/* The interrupt entry point. */
void vEMAC_ISR_Wrapper( void ) __attribute__((naked));
/* The handler that does the actual work. */
void vEMAC_ISR_Handler( void );
extern xSemaphoreHandle xEMACSemaphore;
void vEMAC_ISR_Handler( void )
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
/* Clear the interrupt. */
MAC_INTCLEAR = 0xffff;
VICVectAddr = 0;
/* Ensure the uIP task is not blocked as data has arrived. */
xSemaphoreGiveFromISR( xEMACSemaphore, &xHigherPriorityTaskWoken );
if( xHigherPriorityTaskWoken )
{
/* Giving the semaphore woke a task. */
portYIELD_FROM_ISR();
}
}
/*-----------------------------------------------------------*/
void vEMAC_ISR_Wrapper( void )
{
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Call the handler. This must be a separate function unless you can
guarantee that no stack will be used. */
vEMAC_ISR_Handler();
/* Restore the context of whichever task is going to run next. */
portRESTORE_CONTEXT();
}
| #include "FreeRTOS.h"
#include "semphr.h"
#include "task.h"
/* The interrupt entry point. */
void vEMAC_ISR_Wrapper( void ) __attribute__((naked));
/* The handler that does the actual work. */
void vEMAC_ISR_Handler( void );
extern xSemaphoreHandle xEMACSemaphore;
void vEMAC_ISR_Handler( void )
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
/* Clear the interrupt. */
MAC_INTCLEAR = 0xffff;
VICVectAddr = 0;
/* Ensure the uIP task is not blocked as data has arrived. */
xSemaphoreGiveFromISR( xEMACSemaphore, &xHigherPriorityTaskWoken );
if( xHigherPriorityTaskWoken )
{
/* Giving the semaphore woke a task. */
portYIELD_FROM_ISR();
}
}
/*-----------------------------------------------------------*/
void vEMAC_ISR_Wrapper( void )
{
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Call the handler. This must be a separate function unless you can
guarantee that no stack will be used. */
vEMAC_ISR_Handler();
/* Restore the context of whichever task is going to run next. */
portRESTORE_CONTEXT();
}
|
Increase max heap size to 15,000 ConsCells. | #ifndef MCLISP_ALLOC_H_
#define MCLISP_ALLOC_H_
#include <array>
#include <cstddef>
#include <list>
#include "cons.h"
namespace mclisp
{
class ConsAllocator
{
public:
typedef std::size_t size_type;
ConsAllocator();
ConsCell* Allocate();
std::list<ConsCell*> Allocate(size_type n);
void Deallocate(ConsCell* p);
inline size_type max_size() const { return free_list_.size(); }
inline const ConsCell* oob_pointer() const { return &heap_.front() - 1; }
static constexpr size_type max_heap_size() { return kMaxHeapSize; }
private:
static constexpr size_type kMaxHeapSize = 1500;
std::list<ConsCell*> free_list_;
std::array<ConsCell, kMaxHeapSize> heap_;
};
namespace Alloc
{
void Init();
void Shutdown();
const mclisp::ConsCell* AtomMagic();
mclisp::ConsCell* Allocate();
} // namespace Alloc
} // namespace mclisp
#endif // MCLISP_ALLOC_H_
| #ifndef MCLISP_ALLOC_H_
#define MCLISP_ALLOC_H_
#include <array>
#include <cstddef>
#include <list>
#include "cons.h"
namespace mclisp
{
class ConsAllocator
{
public:
typedef std::size_t size_type;
ConsAllocator();
ConsCell* Allocate();
std::list<ConsCell*> Allocate(size_type n);
void Deallocate(ConsCell* p);
inline size_type max_size() const { return free_list_.size(); }
inline const ConsCell* oob_pointer() const { return &heap_.front() - 1; }
static constexpr size_type max_heap_size() { return kMaxHeapSize; }
private:
static constexpr size_type kMaxHeapSize = 15000;
std::list<ConsCell*> free_list_;
std::array<ConsCell, kMaxHeapSize> heap_;
};
namespace Alloc
{
void Init();
void Shutdown();
const mclisp::ConsCell* AtomMagic();
mclisp::ConsCell* Allocate();
} // namespace Alloc
} // namespace mclisp
#endif // MCLISP_ALLOC_H_
|
Check it out with two items! | #include <stdio.h>
#include <stdlib.h>
#include "list.h"
typedef struct _hash_t {
int sum;
int len;
} hash_t;
hash_t hash(char word[]) {
hash_t ret = {0,0};
int i;
for (i = 0; word[i] != '\0'; i++) {
ret.sum += word[i];
}
ret.len = i;
return ret;
}
int eq(hash_t h1, hash_t h2) {
return (h1.sum == h2.sum) && (h1.len == h2.len);
}
int is_anagram(char w1[], char w2[]) {
return eq(hash(w1), hash(w2));
}
char** collect_anagrams(char* anagrams[], int len) {
char** ret = (char**) malloc(len * sizeof(char));
return ret;
}
int main(int argc, char* argv[]) {
char* input[] = {"lol", "llo"};
char* output[2];
collect_anagrams(input, 2);
list_t* list = list_new();
list = list_append(list, "lol");
pretty_print(list);
}
| #include <stdio.h>
#include <stdlib.h>
#include "list.h"
typedef struct _hash_t {
int sum;
int len;
} hash_t;
hash_t hash(char word[]) {
hash_t ret = {0,0};
int i;
for (i = 0; word[i] != '\0'; i++) {
ret.sum += word[i];
}
ret.len = i;
return ret;
}
int eq(hash_t h1, hash_t h2) {
return (h1.sum == h2.sum) && (h1.len == h2.len);
}
int is_anagram(char w1[], char w2[]) {
return eq(hash(w1), hash(w2));
}
char** collect_anagrams(char* anagrams[], int len) {
char** ret = (char**) malloc(len * sizeof(char));
return ret;
}
int main(int argc, char* argv[]) {
char* input[] = {"lol", "llo"};
char* output[2];
collect_anagrams(input, 2);
list_t* list = list_new();
list = list_append(list, "lol");
list = list_append(list, "lool");
pretty_print(list);
}
|
Add insert node at nth position | /*
Input Format
You have to complete the Node* Insert(Node* head, int data, int position) method which takes three arguments - the head of the linked list, the integer to insert and the position at which the integer must be inserted. You should NOT read any input from stdin/console. position will always be between 0 and the number of the elements in the list (inclusive).
Output Format
Insert the new node at the desired position and return the head of the updated linked list. Do NOT print anything to stdout/console.
Sample Input
NULL, data = 3, position = 0
3 --> NULL, data = 4, position = 0
Sample Output
3 --> NULL
4 --> 3 --> NULL
Explanation
1. we have an empty list and position 0. 3 becomes head.
2. 4 is added to position 0, hence 4 becomes head.
Note
For the purpose of evaluation the list has been initialised with a node with data=2. Ignore it, this is done to avoid printing empty lists while comparing output.
*/
/*
Insert Node at a given position in a linked list
head can be NULL
First element in the linked list is at position 0
Node is defined as
struct Node
{
int data;
struct Node *next;
}
*/
Node* InsertNth(Node *head, int data, int position)
{
Node* temp = (Node*)malloc(sizeof(Node));
temp->data = data;
temp->next=NULL;
Node* prev;
prev = head;
if(position == 0){
temp->next=head;
head=temp;
}
else{
for(int i =0; i< position-1; i++){
if(prev->next!=NULL)
prev = prev->next;
}
temp->next = prev->next;
prev->next = temp;
}
return head;
}
| |
Return cdr for mark continuation. | /*
SMAL
Copyright (c) 2011 Kurt A. Stephens
*/
#include "smal/smal.h"
#include "smal/thread.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h> /* memset() */
#include <unistd.h> /* getpid() */
#include <assert.h>
typedef void *my_oop;
typedef struct my_cons {
my_oop car, cdr;
} my_cons;
static smal_type *my_cons_type;
static void * my_cons_mark (void *ptr)
{
#if 0
smal_mark_ptr_n(ptr, 2, (void**) &((my_cons *) ptr)->car);
return 0;
#else
smal_mark_ptr(ptr, ((my_cons *) ptr)->car);
return ((my_cons *) ptr)->cdr;
#endif
}
void my_print_stats()
{
smal_stats stats = { 0 };
int i;
smal_global_stats(&stats);
for ( i = 0; smal_stats_names[i]; ++ i ) {
fprintf(stdout, " %16lu %s\n", (unsigned long) (((size_t*) &stats)[i]), smal_stats_names[i]);
}
fprintf(stderr, "\n");
}
| /*
SMAL
Copyright (c) 2011 Kurt A. Stephens
*/
#include "smal/smal.h"
#include "smal/thread.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h> /* memset() */
#include <unistd.h> /* getpid() */
#include <assert.h>
typedef void *my_oop;
typedef struct my_cons {
my_oop car, cdr;
} my_cons;
static smal_type *my_cons_type;
static void * my_cons_mark (void *ptr)
{
smal_mark_ptr(ptr, ((my_cons *) ptr)->car);
return ((my_cons *) ptr)->cdr;
}
void my_print_stats()
{
smal_stats stats = { 0 };
int i;
smal_global_stats(&stats);
for ( i = 0; smal_stats_names[i]; ++ i ) {
fprintf(stdout, " %16lu %s\n", (unsigned long) (((size_t*) &stats)[i]), smal_stats_names[i]);
}
fprintf(stderr, "\n");
}
|
Update the versioning for macOS Big Sur | #include <sys/utsname.h>
#include <wchar.h>
#include <stdlib.h>
#define OS_VERSION_MAX_SIZE 128
wchar_t* getOS() {
struct utsname system_info;
if (uname(&system_info) != 0) return NULL;
wchar_t* os = malloc(sizeof(os) * OS_VERSION_MAX_SIZE);
#ifdef __APPLE__
int version = atoi(system_info.release);
// Since Darwin 5.1 (released 2001), Darwin xx corresponds to Mac OS X 10.(xx - 4)
const wchar_t* format;
if (version < 5) {
format = L"Mac OS X";
} else {
format = L"Mac OS X 10.%d";
}
if (swprintf(os, OS_VERSION_MAX_SIZE, format, version - 4) == -1) {
#else
if (swprintf(os, OS_VERSION_MAX_SIZE, L"%s %s", system_info.sysname, system_info.release) == -1) {
#endif
free(os);
os = NULL;
}
return os;
}
| #include <sys/utsname.h>
#include <wchar.h>
#include <stdlib.h>
#define OS_VERSION_MAX_SIZE 128
wchar_t* getOS() {
struct utsname system_info;
if (uname(&system_info) != 0) return NULL;
wchar_t* os = malloc(sizeof(os) * OS_VERSION_MAX_SIZE);
#ifdef __APPLE__
int major_version = atoi(system_info.release);
int minor_version = atoi(system_info.release + 3);
// Since Darwin 5.1 (released 2001), Darwin xx corresponds to Mac OS X 10.(xx - 4)
// Since Darwin 20.1 (released 2020), Darwin xx.yy corresponds to Mac OS X (xx - 9).(yy - 1)
const wchar_t* format;
if (major_version < 5) {
format = L"Mac OS X";
} else if (major_version < 20) {
format = L"Mac OS X %d.%d";
minor_version = major_version - 4;
major_version = 10;
} else {
format = L"Mac OS X %d.%d";
minor_version = minor_version - 1;
major_version = major_version - 9;
}
if (swprintf(os, OS_VERSION_MAX_SIZE, format, major_version, minor_version) == -1) {
#else
if (swprintf(os, OS_VERSION_MAX_SIZE, L"%s %s", system_info.sysname, system_info.release) == -1) {
#endif
free(os);
os = NULL;
}
return os;
}
|
Convert to 'using' syntax for type aliases | #ifndef EMULATOR_REGISTER_H
#define EMULATOR_REGISTER_H
#include <cstdint>
template <typename T>
class Register {
public:
Register() {};
void set(const T new_value) { val = new_value; };
T value() const { return val; };
void increment() { val += 1; };
void decrement() { val -= 1; };
private:
T val;
};
typedef Register<uint8_t> ByteRegister;
typedef Register<uint16_t> WordRegister;
class RegisterPair {
public:
RegisterPair(ByteRegister& low, ByteRegister& high);
void set_low(const uint8_t byte);
void set_high(const uint8_t byte);
void set_low(const ByteRegister& byte);
void set_high(const ByteRegister& byte);
void set(const uint16_t word);
uint8_t low() const;
uint8_t high() const;
uint16_t value() const;
void increment();
void decrement();
private:
ByteRegister& low_byte;
ByteRegister& high_byte;
};
class Offset {
public:
Offset(uint8_t val) : val(val) {};
Offset(ByteRegister& reg) : val(reg.value()) {};
uint8_t value() { return val; }
private:
uint8_t val;
};
#endif
| #ifndef EMULATOR_REGISTER_H
#define EMULATOR_REGISTER_H
#include <cstdint>
template <typename T>
class Register {
public:
Register() {};
void set(const T new_value) { val = new_value; };
T value() const { return val; };
void increment() { val += 1; };
void decrement() { val -= 1; };
private:
T val;
};
using ByteRegister = Register<uint8_t>;
using WordRegister = Register<uint16_t>;
class RegisterPair {
public:
RegisterPair(ByteRegister& low, ByteRegister& high);
void set_low(const uint8_t byte);
void set_high(const uint8_t byte);
void set_low(const ByteRegister& byte);
void set_high(const ByteRegister& byte);
void set(const uint16_t word);
uint8_t low() const;
uint8_t high() const;
uint16_t value() const;
void increment();
void decrement();
private:
ByteRegister& low_byte;
ByteRegister& high_byte;
};
class Offset {
public:
Offset(uint8_t val) : val(val) {};
Offset(ByteRegister& reg) : val(reg.value()) {};
uint8_t value() { return val; }
private:
uint8_t val;
};
#endif
|
Add a small hack to satisfy build with gcc on smartos64 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "config.h"
#if !defined(HAVE_HTONLL) && !defined(WORDS_BIGENDIAN)
uint64_t couchstore_byteswap64(uint64_t val)
{
size_t ii;
uint64_t ret = 0;
for (ii = 0; ii < sizeof(uint64_t); ii++) {
ret <<= 8;
ret |= val & 0xff;
val >>= 8;
}
return ret;
}
#endif
| /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "config.h"
#if !defined(HAVE_HTONLL) && !defined(WORDS_BIGENDIAN)
uint64_t couchstore_byteswap64(uint64_t val)
{
size_t ii;
uint64_t ret = 0;
for (ii = 0; ii < sizeof(uint64_t); ii++) {
ret <<= 8;
ret |= val & 0xff;
val >>= 8;
}
return ret;
}
#elif defined(__GNUC__)
// solaris boxes contains a ntohll/htonll method, but
// it seems like the gnu linker doesn't like to use
// an archive without _any_ symbols in it ;)
int unreferenced_symbol_to_satisfy_the_linker;
#endif
|
Make sure the rtcp BYE gets sent | /* *
* This file is part of Feng
*
* Copyright (C) 2007 by LScube team <team@streaming.polito.it>
* See AUTHORS for more details
*
* Feng 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.
*
* Feng 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Feng; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* */
#include <fenice/schedule.h>
#include <fenice/rtp.h>
#include <fenice/rtcp.h>
extern schedule_list sched[ONE_FORK_MAX_CONNECTION];
void schedule_stop(int id)
{
RTCP_send_packet(sched[id].rtp_session,SR);
RTCP_send_packet(sched[id].rtp_session,BYE);
sched[id].rtp_session->pause=1;
sched[id].rtp_session->started=0;
//sched[id].rtsp_session->cur_state=READY_STATE;
}
| /* *
* This file is part of Feng
*
* Copyright (C) 2007 by LScube team <team@streaming.polito.it>
* See AUTHORS for more details
*
* Feng 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.
*
* Feng 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Feng; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* */
#include <fenice/schedule.h>
#include <fenice/rtp.h>
#include <fenice/rtcp.h>
extern schedule_list sched[ONE_FORK_MAX_CONNECTION];
void schedule_stop(int id)
{
RTCP_send_packet(sched[id].rtp_session,SR);
RTCP_send_packet(sched[id].rtp_session,BYE);
RTCP_flush(sched[id].session);
sched[id].rtp_session->pause=1;
sched[id].rtp_session->started=0;
//sched[id].rtsp_session->cur_state=READY_STATE;
}
|
Add tests for enabling / disabling shouldRasterize | /* Copyright (c) 2014-present, 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.
*/
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>
#import <AsyncDisplayKit/ASDisplayNode.h>
#define ASSnapshotVerifyNode(node__, identifier__) \
{ \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayer(node__.layer, identifier__); \
}
@interface ASSnapshotTestCase : FBSnapshotTestCase
/**
* Hack for testing. ASDisplayNode lacks an explicit -render method, so we manually hit its layout & display codepaths.
*/
+ (void)hackilySynchronouslyRecursivelyRenderNode:(ASDisplayNode *)node;
@end
| /* Copyright (c) 2014-present, 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.
*/
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>
#import <AsyncDisplayKit/ASDisplayNode.h>
#define ASSnapshotVerifyNode(node__, identifier__) \
{ \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayer(node__.layer, identifier__); \
[node__ setShouldRasterizeDescendants:YES]; \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayer(node__.layer, identifier__); \
[node__ setShouldRasterizeDescendants:NO]; \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayer(node__.layer, identifier__); \
}
@interface ASSnapshotTestCase : FBSnapshotTestCase
/**
* Hack for testing. ASDisplayNode lacks an explicit -render method, so we manually hit its layout & display codepaths.
*/
+ (void)hackilySynchronouslyRecursivelyRenderNode:(ASDisplayNode *)node;
@end
|
Add missing include for the AT45DB flash driver | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 __AT45DB_H__
#define __AT45DB_H__
#include <hal/hal_flash_int.h>
#include <hal/hal_spi.h>
#ifdef __cplusplus
extern "C" {
#endif
struct at45db_dev {
struct hal_flash hal;
struct hal_spi_settings *settings;
int spi_num;
void *spi_cfg; /** Low-level MCU SPI config */
int ss_pin;
uint32_t baudrate;
uint16_t page_size; /** Page size to be used, valid: 512 and 528 */
uint8_t disable_auto_erase; /** Reads and writes auto-erase by default */
};
struct at45db_dev * at45db_default_config(void);
int at45db_read(const struct hal_flash *dev, uint32_t addr, void *buf,
uint32_t len);
int at45db_write(const struct hal_flash *dev, uint32_t addr, const void *buf,
uint32_t len);
int at45db_erase_sector(const struct hal_flash *dev, uint32_t sector_address);
int at45db_sector_info(const struct hal_flash *dev, int idx, uint32_t *address,
uint32_t *sz);
int at45db_init(const struct hal_flash *dev);
#ifdef __cplusplus
}
#endif
#endif /* __AT45DB_H__ */
| |
Redefine error codes as consts | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <string>
#include <unordered_map>
#define GENERR 0x100
#define SKINERR 0x200
#define SYSERR 0x400
#define GENERR_NOTFOUND GENERR + 1
#define GENERR_SETTINGSFILE GENERR + 2
#define GENERR_MISSING_XML GENERR + 3
#define SKINERR_INVALID_SKIN SKINERR + 1
#define SKINERR_INVALID_OSD SKINERR + 2
#define SKINERR_INVALID_METER SKINERR + 3
#define SKINERR_INVALID_SLIDER SKINERR + 4
#define SKINERR_INVALID_BG SKINERR + 5
#define SKINERR_INVALID_SLIDERTYPE SKINERR + 7
#define SKINERR_NOTFOUND SKINERR + 8
#define SKINERR_MISSING_XML SKINERR + 9
#define SKINERR_READERR SKINERR + 10
#define SYSERR_REGISTERCLASS SYSERR + 1
#define SYSERR_CREATEWINDOW SYSERR + 2
class Error {
public:
static void ErrorMessage(unsigned int error, std::wstring detail = L"");
static void ErrorMessageDie(unsigned int error, std::wstring detail = L"");
private:
static std::unordered_map<int, std::wstring> errorMap;
static wchar_t *ErrorType(unsigned int error);
}; | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <string>
#include <unordered_map>
class Error {
public:
static void ErrorMessage(unsigned int error, std::wstring detail = L"");
static void ErrorMessageDie(unsigned int error, std::wstring detail = L"");
private:
static std::unordered_map<int, std::wstring> errorMap;
static wchar_t *ErrorType(unsigned int error);
public:
static const int GENERR = 0x100;
static const int SKINERR = 0x200;
static const int SYSERR = 0x300;
static const int GENERR_NOTFOUND = GENERR + 1;
static const int GENERR_MISSING_XML = GENERR + 3;
static const int SKINERR_INVALID_SKIN = SKINERR + 1;
static const int SKINERR_INVALID_SLIDERTYPE = SKINERR + 7;
static const int SKINERR_NOTFOUND = SKINERR + 8;
static const int SKINERR_MISSING_XML = SKINERR + 9;
static const int SKINERR_XMLPARSE = SKINERR + 10;
static const int SYSERR_REGISTERCLASS = SYSERR + 1;
static const int SYSERR_CREATEWINDOW = SYSERR + 2;
}; |
Define PACK macro for structs and etc | #pragma once
#ifdef _MSC_VER
#define PACK(DECL) __pragma(pack(push, 1)) DECL __pragma(pack(pop))
#else
#define PACK(DECL) DECL __attribute__((__packed__))
#endif
| |
Add implementation of atomic ops with libatomic instead of gcc builtins | #ifndef ATOMIC_GCC_BUILTINS_INCLUDED
#define ATOMIC_GCC_BUILTINS_INCLUDED
/*Modified by David Lowes 2015 - Zend Technologies LTD. LICENSE??*/
#define make_atomic_add_body(S) \
v= __atomic_fetch_add(a, v, __ATOMIC_RELAXED);
#define make_atomic_fas_body(S) \
v= __sync_lock_test_and_set(a, v);
#define make_atomic_cas_body(S) \
int ## S sav; \
int ## S cmp_val= *cmp; \
sav= __sync_val_compare_and_swap(a, cmp_val, set);\
if (!(ret= (sav == cmp_val))) *cmp= sav
#ifdef MY_ATOMIC_MODE_DUMMY
#define make_atomic_load_body(S) ret= *a
#define make_atomic_store_body(S) *a= v
#define MY_ATOMIC_MODE "gcc-builtins-up"
#elif defined(HAVE_GCC_C11_ATOMICS)
#define MY_ATOMIC_MODE "gcc-atomics-smp"
#define make_atomic_load_body(S) \
ret= __atomic_load_n(a, __ATOMIC_SEQ_CST)
#define make_atomic_store_body(S) \
__atomic_store_n(a, v, __ATOMIC_SEQ_CST)
#else
#define MY_ATOMIC_MODE "gcc-builtins-smp"
#define make_atomic_load_body(S) \
ret= __sync_fetch_and_or(a, 0);
#define make_atomic_store_body(S) \
(void) __sync_lock_test_and_set(a, v);
#endif
#endif /* ATOMIC_GCC_BUILTINS_INCLUDED */
| |
Revert r352732: [libFuzzer] replace slow std::mt19937 with a much faster std::minstd_rand | //===- FuzzerRandom.h - Internal header for the Fuzzer ----------*- C++ -* ===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// fuzzer::Random
//===----------------------------------------------------------------------===//
#ifndef LLVM_FUZZER_RANDOM_H
#define LLVM_FUZZER_RANDOM_H
#include <random>
namespace fuzzer {
class Random : public std::minstd_rand {
public:
Random(unsigned int seed) : std::minstd_rand(seed) {}
result_type operator()() { return this->std::minstd_rand::operator()(); }
size_t Rand() { return this->operator()(); }
size_t RandBool() { return Rand() % 2; }
size_t operator()(size_t n) { return n ? Rand() % n : 0; }
intptr_t operator()(intptr_t From, intptr_t To) {
assert(From < To);
intptr_t RangeSize = To - From + 1;
return operator()(RangeSize) + From;
}
};
} // namespace fuzzer
#endif // LLVM_FUZZER_RANDOM_H
| //===- FuzzerRandom.h - Internal header for the Fuzzer ----------*- C++ -* ===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// fuzzer::Random
//===----------------------------------------------------------------------===//
#ifndef LLVM_FUZZER_RANDOM_H
#define LLVM_FUZZER_RANDOM_H
#include <random>
namespace fuzzer {
class Random : public std::mt19937 {
public:
Random(unsigned int seed) : std::mt19937(seed) {}
result_type operator()() { return this->std::mt19937::operator()(); }
size_t Rand() { return this->operator()(); }
size_t RandBool() { return Rand() % 2; }
size_t operator()(size_t n) { return n ? Rand() % n : 0; }
intptr_t operator()(intptr_t From, intptr_t To) {
assert(From < To);
intptr_t RangeSize = To - From + 1;
return operator()(RangeSize) + From;
}
};
} // namespace fuzzer
#endif // LLVM_FUZZER_RANDOM_H
|
Update vtable offsets for 2014-06-11 TF2 update. | /*
* hooks.h
* StatusSpec project
*
* Copyright (c) 2014 thesupremecommander
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#pragma once
#include "stdafx.h"
#include <map>
#define CLIENT_DLL
#define GLOWS_ENABLE
#include "cdll_int.h"
#include "KeyValues.h"
#include "igameresources.h"
#include "vgui/vgui.h"
#include "vgui/IPanel.h"
#include "cbase.h"
#include "c_basecombatcharacter.h"
#include "glow_outline_effect.h"
#include <sourcehook/sourcehook_impl.h>
#include <sourcehook/sourcehook.h>
using namespace vgui;
class C_TFPlayer;
#if defined _WIN32
#define OFFSET_GETGLOWOBJECT 220
#define OFFSET_GETGLOWEFFECTCOLOR 221
#define OFFSET_UPDATEGLOWEFFECT 222
#define OFFSET_DESTROYGLOWEFFECT 223
#endif
static std::map<EHANDLE, int> onDataChangedHooks;
extern SourceHook::ISourceHook *g_SHPtr;
extern int g_PLID; | /*
* hooks.h
* StatusSpec project
*
* Copyright (c) 2014 thesupremecommander
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#pragma once
#include "stdafx.h"
#include <map>
#define CLIENT_DLL
#define GLOWS_ENABLE
#include "cdll_int.h"
#include "KeyValues.h"
#include "igameresources.h"
#include "vgui/vgui.h"
#include "vgui/IPanel.h"
#include "cbase.h"
#include "c_basecombatcharacter.h"
#include "glow_outline_effect.h"
#include <sourcehook/sourcehook_impl.h>
#include <sourcehook/sourcehook.h>
using namespace vgui;
class C_TFPlayer;
#if defined _WIN32
#define OFFSET_GETGLOWEFFECTCOLOR 223
#define OFFSET_UPDATEGLOWEFFECT 224
#define OFFSET_DESTROYGLOWEFFECT 225
#endif
static std::map<EHANDLE, int> onDataChangedHooks;
extern SourceHook::ISourceHook *g_SHPtr;
extern int g_PLID; |
Patch from Bernardo Innocenti: Remove use of cast-as-l-value extension, removed in GCC 3.5. |
#include <errno.h>
#include <asm/ptrace.h>
#include <sys/syscall.h>
int
ptrace(int request, int pid, int addr, int data)
{
long ret;
long res;
if (request > 0 && request < 4) (long *)data = &ret;
__asm__ volatile ("movel %1,%/d0\n\t"
"movel %2,%/d1\n\t"
"movel %3,%/d2\n\t"
"movel %4,%/d3\n\t"
"movel %5,%/d4\n\t"
"trap #0\n\t"
"movel %/d0,%0"
:"=g" (res)
:"i" (__NR_ptrace), "g" (request), "g" (pid),
"g" (addr), "g" (data) : "%d0", "%d1", "%d2", "%d3", "%d4");
if (res >= 0) {
if (request > 0 && request < 4) {
__set_errno(0);
return (ret);
}
return (int) res;
}
__set_errno(-res);
return -1;
}
|
#include <errno.h>
#include <asm/ptrace.h>
#include <sys/syscall.h>
int
ptrace(int request, int pid, int addr, int data)
{
long ret;
long res;
if (request > 0 && request < 4) data = (int)&ret;
__asm__ volatile ("movel %1,%/d0\n\t"
"movel %2,%/d1\n\t"
"movel %3,%/d2\n\t"
"movel %4,%/d3\n\t"
"movel %5,%/d4\n\t"
"trap #0\n\t"
"movel %/d0,%0"
:"=g" (res)
:"i" (__NR_ptrace), "g" (request), "g" (pid),
"g" (addr), "g" (data) : "%d0", "%d1", "%d2", "%d3", "%d4");
if (res >= 0) {
if (request > 0 && request < 4) {
__set_errno(0);
return (ret);
}
return (int) res;
}
__set_errno(-res);
return -1;
}
|
Add utility to check whether a point is inside a rect | /*
* rect_utils.h
*
* Author: Ming Tsang
* Copyright (c) 2014 Ming Tsang
* Refer to LICENSE for details
*/
#pragma once
#include <cstdint>
#include "libutils/type/coord.h"
#include "libutils/type/rect.h"
namespace utils
{
namespace type
{
class RectUtils
{
public:
/**
* Return whether @a point is rested inside @a rect
*
* @param rect
* @param point
* @return
* @see IsInsidePx()
*/
static bool IsInside(const Rect &rect, const Coord &point)
{
return (point.x > rect.coord.x
&& point.x < static_cast<int32_t>(rect.coord.x + rect.size.w)
&& point.y > rect.coord.y
&& point.y < static_cast<int32_t>(rect.coord.y + rect.size.h));
}
/**
* Return whether a pixel at @a point is rested inside an image region
* @a rect. The difference between IsInsidePx() and IsInside() is that
* the top and left edges are inclusive in this method, useful when dealing
* with pixel
*
* @param rect
* @param point
* @return
* @see IsInside()
*/
static bool IsInsidePx(const Rect &rect, const Coord &point)
{
return (point.x >= rect.coord.x
&& point.x < static_cast<int32_t>(rect.coord.x + rect.size.w)
&& point.y >= rect.coord.y
&& point.y < static_cast<int32_t>(rect.coord.y + rect.size.h));
}
};
}
}
| |
Fix formatting to match libdispatch coding style. | /*
* Copyright (c) 2013-2016 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* 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.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#include "internal.h"
#include "shims.h"
#if !HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size) {
size_t res = strlen(dst) + strlen(src) + 1;
if (size > 0) {
size_t n = size - 1;
strncpy(dst, src, n);
dst[n] = 0;
}
return res;
}
#endif
| /*
* Copyright (c) 2013-2016 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* 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.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#include "internal.h"
#include "shims.h"
#if !HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size)
{
size_t res = strlen(dst) + strlen(src) + 1;
if (size > 0) {
size_t n = size - 1;
strncpy(dst, src, n);
dst[n] = 0;
}
return res;
}
#endif
|
Use '__x86_64__' instead of '__X86_64__' | #ifndef PSTOREJNI_H
#define PSTOREJNI_H
#include <inttypes.h>
#ifdef __i386__
#define LONG_TO_PTR(ptr) (void *) (uint32_t) ptr
#elif __X86_64__
#define LONG_TO_PTR(ptr) (void *) ptr
#endif
#define PTR_TO_LONG(ptr) (long) ptr
#endif
| #ifndef PSTOREJNI_H
#define PSTOREJNI_H
#include <inttypes.h>
#ifdef __i386__
#define LONG_TO_PTR(ptr) (void *) (uint32_t) ptr
#elif __x86_64__
#define LONG_TO_PTR(ptr) (void *) ptr
#endif
#define PTR_TO_LONG(ptr) (long) ptr
#endif
|
Revert "use old import syntax for HockeySDK" | #import <HockeySDK/HockeySDK.h>
@interface BITHockeyManager (WMFExtensions) <BITHockeyManagerDelegate>
/**
* Configure and startup in one line.
* This will call the methods below as part of the configuration process.
* This method will use the current bundle id of the app
*/
- (void)wmf_setupAndStart;
/**
* Configure the alert to be displayed when a user is prompeted to send a crash report
*/
- (void)wmf_setupCrashNotificationAlert;
@end
| @import HockeySDK;
@interface BITHockeyManager (WMFExtensions) <BITHockeyManagerDelegate>
/**
* Configure and startup in one line.
* This will call the methods below as part of the configuration process.
* This method will use the current bundle id of the app
*/
- (void)wmf_setupAndStart;
/**
* Configure the alert to be displayed when a user is prompeted to send a crash report
*/
- (void)wmf_setupCrashNotificationAlert;
@end
|
Fix IPC BAR scom address | // IBM_PROLOG_BEGIN_TAG
// This is an automatically generated prolog.
//
// $Source: src/include/sys/interrupt.h $
//
// IBM CONFIDENTIAL
//
// COPYRIGHT International Business Machines Corp. 2011
//
// p1
//
// Object Code Only (OCO) source materials
// Licensed Internal Code Source Materials
// IBM HostBoot Licensed Internal Code
//
// The source code for this program is not published or other-
// wise divested of its trade secrets, irrespective of what has
// been deposited with the U.S. Copyright Office.
//
// Origin: 30
//
// IBM_PROLOG_END
#ifndef __INTERRUPT_H
#define __INTERRUPT_H
extern const char* INTR_MSGQ;
/**
* INTR constants
*/
enum
{
ICPBAR_SCOM_ADDR = 0x020109c9, //!< for P8, P7 = 0x02011C09
// This BAR value agrees with simics (for now)
ICPBAR_VAL = 0x03FBFF90, //!< ICPBAR value bits[0:29]>>34
};
#endif
| // IBM_PROLOG_BEGIN_TAG
// This is an automatically generated prolog.
//
// $Source: src/include/sys/interrupt.h $
//
// IBM CONFIDENTIAL
//
// COPYRIGHT International Business Machines Corp. 2011
//
// p1
//
// Object Code Only (OCO) source materials
// Licensed Internal Code Source Materials
// IBM HostBoot Licensed Internal Code
//
// The source code for this program is not published or other-
// wise divested of its trade secrets, irrespective of what has
// been deposited with the U.S. Copyright Office.
//
// Origin: 30
//
// IBM_PROLOG_END
#ifndef __INTERRUPT_H
#define __INTERRUPT_H
extern const char* INTR_MSGQ;
/**
* INTR constants
*/
enum
{
ICPBAR_SCOM_ADDR = 0x020109ca, //!< for P8, P7 = 0x02011C09
// This BAR value agrees with simics (for now)
ICPBAR_VAL = 0x03FBFF90, //!< ICPBAR value bits[0:29]>>34
};
#endif
|
Add regression test for exp.precious_globs | // PARAM: --set exp.earlyglobs true --set exp.precious_globs[+] "'g'"
int g = 10;
int main(void){
g = 100;
assert(g==100);
return 0;
} | |
Add constant test for congruence domain | // PARAM: --enable ana.int.congruence --disable ana.int.def_exc
// This test ensures that operations on constant congr. classes (i.e. classes of the form {k} : arbitrary integer k) yield concrete vals
int main() {
// basic arithmetic operators
int a = 1;
int b = 2;
int c = -1;
int d = -2;
assert (a + b == 3); assert (a + d == -1);
assert (a * b == 2); assert (b * c == -2);
assert (a / b == 0); assert (d / c == 2);
assert (b % a == 0); assert (d % c == 0);
assert (-a == -1); assert (-d == 2);
// logical operators
int zero = 0;
int one = 1;
unsigned int uns_z = 0;
assert ((zero || one) == 1); assert ((zero || zero) == 0); assert ((one || one) == 1);
assert ((zero && one) == 0); assert ((zero && zero) == 0); assert ((one && one) == 1);
assert (!one == 0); assert (!zero == 1);
// bitwise operators
assert ((zero & zero) == 0); assert ((zero & one) == 0); assert ((one & zero) == 0); assert ((one & one) == 1);
assert ((zero | zero) == 0); assert ((zero | one) == 1); assert ((one | zero) == 1); assert ((one | one) == 1);
assert ((zero ^ zero) == 0); assert ((zero ^ one) == 1); assert ((one ^ zero) == 1); assert ((one ^ one) == 0);
assert (~zero == -1); assert (~uns_z == 4294967295);
// shift-left
unsigned char m = 136;
assert ((m << 1) == 16);
//shift-right missing as only top() is returned currently
// comparisons
assert ((a < b) == 1);
assert ((a > b) == 0);
assert ((a == b) == 0);
assert ((a != b) == 1);
return 0;
} | |
Change the default VKVoteStatus value to VKVoteStatusNone This is necessary because unvoted items don't send a "voteValue" field so the voteStatusJSONTransformer is never called | //
// VKVotable.h
// VoatKit
//
// Created by Amar Ramachandran on 6/26/15.
// Copyright © 2015 AmarJayR. All rights reserved.
//
#import "VKCreated.h"
typedef NS_ENUM(NSUInteger, VKVoteStatus) {
VKVoteStatusUpvoted,
VKVoteStatusDownvoted,
VKVoteStatusNone
};
@interface VKVotable : VKCreated
/**
The total number of upvotes.
*/
@property (nonatomic, assign, readonly) NSNumber* upvotes;
/**
The total number of downvotes.
*/
@property (nonatomic, assign, readonly) NSNumber* downvotes;
/**
The object's score.
*/
@property (nonatomic, assign, readonly) NSNumber* score;
/**
The current user's vote status for this object.
*/
@property (nonatomic, assign, readonly) VKVoteStatus voteStatus;
/**
Whether the current user has upvoted this object.
*/
- (BOOL)upvoted;
/**
Whether the current user has downvoted this object.
*/
- (BOOL)downvoted;
/**
Whether the current user has voted on this object.
*/
- (BOOL)voted;
@end
| //
// VKVotable.h
// VoatKit
//
// Created by Amar Ramachandran on 6/26/15.
// Copyright © 2015 AmarJayR. All rights reserved.
//
#import "VKCreated.h"
typedef NS_ENUM(NSUInteger, VKVoteStatus) {
VKVoteStatusNone,
VKVoteStatusUpvoted,
VKVoteStatusDownvoted
};
@interface VKVotable : VKCreated
/**
The total number of upvotes.
*/
@property (nonatomic, assign, readonly) NSNumber* upvotes;
/**
The total number of downvotes.
*/
@property (nonatomic, assign, readonly) NSNumber* downvotes;
/**
The object's score.
*/
@property (nonatomic, assign, readonly) NSNumber* score;
/**
The current user's vote status for this object.
*/
@property (nonatomic, assign, readonly) VKVoteStatus voteStatus;
/**
Whether the current user has upvoted this object.
*/
- (BOOL)upvoted;
/**
Whether the current user has downvoted this object.
*/
- (BOOL)downvoted;
/**
Whether the current user has voted on this object.
*/
- (BOOL)voted;
@end
|
Fix comparison between properties (compare the ID) | /***************************************************************************
* Copyright (C) 2003 by Unai Garro *
* ugarro@users.sourceforge.net *
* *
* 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. *
***************************************************************************/
#ifndef INGREDIENTPROPERTYLIST_H
#define INGREDIENTPROPERTYLIST_H
#include <qptrlist.h>
#include "ingredientproperty.h"
/**
@author Unai Garro
*/
class PropertyPtrList: public QPtrList <IngredientProperty>
{
public:
PropertyPtrList(){};
~PropertyPtrList(){};
protected:
virtual int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2){return (*((int*)item1)-*((int*)item2));};
};
class IngredientPropertyList{
public:
IngredientPropertyList();
~IngredientPropertyList();
IngredientProperty* getFirst(void);
IngredientProperty* getNext(void);
IngredientProperty* getElement(int index);
void clear(void);
bool isEmpty(void);
void add(IngredientProperty &element);
void append(IngredientProperty *property);
int find(IngredientProperty* it);
IngredientProperty* at(int pos);
private:
PropertyPtrList list;
};
#endif
| /***************************************************************************
* Copyright (C) 2003 by Unai Garro *
* ugarro@users.sourceforge.net *
* *
* 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. *
***************************************************************************/
#ifndef INGREDIENTPROPERTYLIST_H
#define INGREDIENTPROPERTYLIST_H
#include <qptrlist.h>
#include "ingredientproperty.h"
/**
@author Unai Garro
*/
class PropertyPtrList: public QPtrList <IngredientProperty>
{
public:
PropertyPtrList(){};
~PropertyPtrList(){};
protected:
virtual int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2){return (((IngredientProperty*)item1)->id-((IngredientProperty*)item2)->id);};
};
class IngredientPropertyList{
public:
IngredientPropertyList();
~IngredientPropertyList();
IngredientProperty* getFirst(void);
IngredientProperty* getNext(void);
IngredientProperty* getElement(int index);
void clear(void);
bool isEmpty(void);
void add(IngredientProperty &element);
void append(IngredientProperty *property);
int find(IngredientProperty* it);
IngredientProperty* at(int pos);
private:
PropertyPtrList list;
};
#endif
|
Split transform methods into to/from | #pragma once
class VolumeTransformation {
public:
virtual float Transform(float vol) = 0;
}; | #pragma once
class VolumeTransformation {
public:
/// <summary>
/// Transforms a given volume level to a new ("virtual") level based on a
/// formula or set of rules (e.g., a volume curve transformation).
/// </summary>
virtual float ToVirtual(float vol) = 0;
/// <summary>
/// Given a transformed ("virtual") volume value, this function reverts it
/// back to its original value (assuming the given value was produced
/// by the ToVirtual() function).
/// </summary>
virtual float FromVirtual(float vol) = 0;
}; |
Update for Arduino Due and refresh of files to make sure they are the latest |
/**
* FreeIMU calibration header. Automatically generated by octave AccMagnCalib.m.
* Do not edit manually unless you know what you are doing.
*/
/* // following example of calibration.h
#define CALIBRATION_H
const int acc_off_x = 205;
const int acc_off_y = -39;
const int acc_off_z = 1063;
const float acc_scale_x = 7948.565970;
const float acc_scale_y = 8305.469320;
const float acc_scale_z = 8486.650841;
const int magn_off_x = 67;
const int magn_off_y = -59;
const int magn_off_z = 26;
const float magn_scale_x = 527.652115;
const float magn_scale_y = 569.016790;
const float magn_scale_z = 514.710857;
*/
|
/**
* FreeIMU calibration header. Automatically generated by FreeIMU_GUI.
* Do not edit manually unless you know what you are doing.
*/
#define CALIBRATION_H
const int acc_off_x = 163;
const int acc_off_y = 119;
const int acc_off_z = -622;
const float acc_scale_x = 16387.035965;
const float acc_scale_y = 16493.176991;
const float acc_scale_z = 16517.294625;
const int magn_off_x = 26;
const int magn_off_y = -128;
const int magn_off_z = 43;
const float magn_scale_x = 528.171092;
const float magn_scale_y = 485.462478;
const float magn_scale_z = 486.973938;
|
CREATE mailbox<hierarchy separator> failed always. | /* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "commands.h"
int cmd_create(Client *client)
{
const char *mailbox;
/* <mailbox> */
if (!client_read_string_args(client, 1, &mailbox))
return FALSE;
if (!client_verify_mailbox_name(client, mailbox, FALSE, TRUE))
return TRUE;
if (mailbox[strlen(mailbox)-1] == client->storage->hierarchy_sep) {
/* name ends with hierarchy separator - client is just
informing us that it wants to create a mailbox under
this name. we don't need that information. */
} else if (!client->storage->create_mailbox(client->storage, mailbox)) {
client_send_storage_error(client);
return TRUE;
}
client_send_tagline(client, "OK Create completed.");
return TRUE;
}
| /* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "commands.h"
int cmd_create(Client *client)
{
const char *mailbox;
int ignore;
/* <mailbox> */
if (!client_read_string_args(client, 1, &mailbox))
return FALSE;
ignore = mailbox[strlen(mailbox)-1] == client->storage->hierarchy_sep;
if (ignore) {
/* name ends with hierarchy separator - client is just
informing us that it wants to create a mailbox under
this name. we don't need that information, but verify
that the mailbox name is valid */
mailbox = t_strndup(mailbox, strlen(mailbox)-1);
}
if (!client_verify_mailbox_name(client, mailbox, FALSE, !ignore))
return TRUE;
if (!ignore &&
!client->storage->create_mailbox(client->storage, mailbox)) {
client_send_storage_error(client);
return TRUE;
}
client_send_tagline(client, "OK Create completed.");
return TRUE;
}
|
Add a codec for Tile struct | #pragma once
#include <spotify/json.hpp>
#include "Tile.h"
using namespace spotify::json::codec;
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<Tile>
{
static object_t<Tile> codec()
{
auto codec = object<Tile>();
codec.required("corners", &Tile::corners);
codec.required("filename", &Tile::filename);
codec.required("x", &Tile::x);
codec.required("y", &Tile::y);
return codec;
}
};
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.