Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Use more common technical term | /**
* @file
*
* @brief
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
#include <kdb.h>
#include <stdio.h>
int main (void)
{
KeySet * config = ksNew (0, KS_END);
Key * root = keyNew ("user/test", KEY_END);
printf ("Open key database\n");
KDB * handle = kdbOpen (root);
printf ("Retrieve key set\n");
kdbGet (handle, config, root);
printf ("Number of key-value pairs: %zu\n", ksGetSize (config));
Key * key = keyNew ("user/test/hello", KEY_VALUE, "elektra", KEY_END);
printf ("Add key %s\n", keyName (key));
ksAppendKey (config, key);
printf ("Number of key-value pairs: %zu\n", ksGetSize (config));
printf ("\n%s, %s\n\n", keyBaseName (key), keyString (key));
// If you want to store the key database on disk, then please uncomment the following two lines
// printf ("Write key set to disk\n");
// kdbSet (handle, config, root);
printf ("Delete mappings inside memory\n");
ksDel (config);
printf ("Close key database\n");
kdbClose (handle, 0);
return 0;
}
| /**
* @file
*
* @brief
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
#include <kdb.h>
#include <stdio.h>
int main (void)
{
KeySet * config = ksNew (0, KS_END);
Key * root = keyNew ("user/test", KEY_END);
printf ("Open key database\n");
KDB * handle = kdbOpen (root);
printf ("Retrieve key set\n");
kdbGet (handle, config, root);
printf ("Number of key-value pairs: %zu\n", ksGetSize (config));
Key * key = keyNew ("user/test/hello", KEY_VALUE, "elektra", KEY_END);
printf ("Add key %s\n", keyName (key));
ksAppendKey (config, key);
printf ("Number of key-value pairs: %zu\n", ksGetSize (config));
printf ("\n%s, %s\n\n", keyBaseName (key), keyString (key));
// If you want to store the key database on disk, then please uncomment the following two lines
// printf ("Write key set to disk\n");
// kdbSet (handle, config, root);
printf ("Delete key-value pairs inside memory\n");
ksDel (config);
printf ("Close key database\n");
kdbClose (handle, 0);
return 0;
}
|
Add default values to VkAllocation | #ifndef VKALLOC_VKALLOC_H
#define VKALLOC_VKALLOC_H
#include <stdlib.h>
#include <stdint.h>
#include <vulkan/vulkan.h>
#ifndef VKA_ALLOC_SIZE
#define VKA_ALLOC_SIZE 1024*1024*4
#endif
struct VkAllocation {
VkDeviceMemory deviceMemory;
uint64_t offset;
uint64_t size;
};
void vkaInit(VkPhysicalDevice physicalDevice, VkDevice device);
void vkaTerminate();
VkAllocation vkAlloc(VkMemoryRequirements requirements);
void vkFree(VkAllocation allocation);
VkAllocation vkHostAlloc(VkMemoryRequirements requirements);
void vkHostFree(VkAllocation allocation);
#endif //VKALLOC_VKALLOC_H
| #ifndef VKALLOC_VKALLOC_H
#define VKALLOC_VKALLOC_H
#include <stdlib.h>
#include <stdint.h>
#include <vulkan/vulkan.h>
#ifndef VKA_ALLOC_SIZE
#define VKA_ALLOC_SIZE 1024*1024*4
#endif
struct VkAllocation {
VkDeviceMemory deviceMemory = VK_NULL_HANDLE;
uint64_t offset = 0;
uint64_t size = 0;
};
void vkaInit(VkPhysicalDevice physicalDevice, VkDevice device);
void vkaTerminate();
VkAllocation vkAlloc(VkMemoryRequirements requirements);
void vkFree(VkAllocation allocation);
VkAllocation vkHostAlloc(VkMemoryRequirements requirements);
void vkHostFree(VkAllocation allocation);
#endif //VKALLOC_VKALLOC_H
|
Add test for incomplete struct pointer. | // RUN: clang -checker-simple -verify %s &&
// RUN: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
int data_array[10];
};
typedef struct {
int data;
} STYPE;
void g1(struct s* p);
void f(void) {
int a[10];
int (*p)[10];
p = &a;
(*p)[3] = 1;
struct s d;
struct s *q;
q = &d;
q->data = 3;
d.data_array[9] = 17;
}
void f2() {
char *p = "/usr/local";
char (*q)[4];
q = &"abc";
}
void f3() {
STYPE s;
}
void f4() {
int a[] = { 1, 2, 3};
int b[3] = { 1, 2 };
}
void f5() {
struct s data;
g1(&data);
}
void f6() {
char *p;
p = __builtin_alloca(10);
p[1] = 'a';
}
| // RUN: clang -checker-simple -verify %s &&
// RUN: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
int data_array[10];
};
typedef struct {
int data;
} STYPE;
void g1(struct s* p);
void f(void) {
int a[10];
int (*p)[10];
p = &a;
(*p)[3] = 1;
struct s d;
struct s *q;
q = &d;
q->data = 3;
d.data_array[9] = 17;
}
void f2() {
char *p = "/usr/local";
char (*q)[4];
q = &"abc";
}
void f3() {
STYPE s;
}
void f4() {
int a[] = { 1, 2, 3};
int b[3] = { 1, 2 };
}
void f5() {
struct s data;
g1(&data);
}
void f6() {
char *p;
p = __builtin_alloca(10);
p[1] = 'a';
}
struct s2;
void g2(struct s2 *p);
void f7() {
struct s2 *p = __builtin_alloca(10);
g2(p);
}
|
Add explicit triple to test to fix arm bots. | // RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
// CHECK: !DIGlobalVariable({{.*}}
// CHECK-NOT: expr:
static const __uint128_t ro = 18446744073709551615;
void bar(__uint128_t);
void foo() { bar(ro); }
| // RUN: %clang_cc1 -triple x86_64-unknown-linux -S -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
// CHECK: !DIGlobalVariable({{.*}}
// CHECK-NOT: expr:
static const __uint128_t ro = 18446744073709551615;
void bar(__uint128_t);
void foo() { bar(ro); }
|
Fix test case, which has a control-reaches-end-of-non-void warning that was being masked by previous bug. | // RUN: clang-cc -fsyntax-only -verify %s
int test() {
void *vp;
int *ip;
char *cp;
struct foo *fp;
struct bar *bp;
short sint = 7;
if (ip < cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
if (cp < fp) {} // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
if (fp < bp) {} // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
if (ip < 7) {} // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
if (sint < ip) {} // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
if (ip == cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
}
| // RUN: clang-cc -fsyntax-only -verify %s
void test() {
void *vp;
int *ip;
char *cp;
struct foo *fp;
struct bar *bp;
short sint = 7;
if (ip < cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
if (cp < fp) {} // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
if (fp < bp) {} // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
if (ip < 7) {} // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
if (sint < ip) {} // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
if (ip == cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
}
|
Make sure the memory is zero when initialising. This caused failing tests on Windows where mGLResource would already be populated with random stuff. | /* vim: set ts=4 sw=4 tw=79 et :*/
/* 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/. */
#ifndef gfxShader_h__
#define gfxShader_h__
#include "GL/glew.h"
class OpenGLShader {
public:
/// The OpenGL Resource ID
GLuint mGLResource;
/// True if the shader compiled successfully
bool mSuccessfullyCompiled;
OpenGLShader(const char* aShaderSource, GLenum aShaderType) :
mSuccessfullyCompiled(false),
mShaderSource(aShaderSource),
mShaderType(aShaderType) {
}
~OpenGLShader() {
if (mGLResource) {
glDeleteShader(mGLResource);
}
}
bool compile();
private:
const char* mShaderSource;
GLenum mShaderType;
};
#endif
| /* vim: set ts=4 sw=4 tw=79 et :*/
/* 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/. */
#ifndef gfxShader_h__
#define gfxShader_h__
#include "GL/glew.h"
class OpenGLShader {
public:
/// The OpenGL Resource ID
GLuint mGLResource;
/// True if the shader compiled successfully
bool mSuccessfullyCompiled;
OpenGLShader(const char* aShaderSource, GLenum aShaderType) :
mSuccessfullyCompiled(false),
mShaderSource(aShaderSource),
mShaderType(aShaderType),
mGLResource(0) {
}
~OpenGLShader() {
if (mGLResource) {
glDeleteShader(mGLResource);
}
}
bool compile();
private:
const char* mShaderSource;
GLenum mShaderType;
};
#endif
|
Fix test so that it XFAILs consistently. | // RUN: %clang_cc1 %s -m32 -emit-llvm -o - | grep {i32 32} | count 3
// XFAIL: *
// XTARGET: powerpc
// Every printf has 'i32 0' for the GEP of the string; no point counting those.
typedef unsigned int Foo __attribute__((aligned(32)));
typedef union{Foo:0;}a;
typedef union{int x; Foo:0;}b;
extern int printf(const char*, ...);
main() {
printf("%ld\n", sizeof(a));
printf("%ld\n", __alignof__(a));
printf("%ld\n", sizeof(b));
printf("%ld\n", __alignof__(b));
}
| // RUN: %clang_cc1 %s -triple powerpc-pc-linux -emit-llvm -o - | grep {i32 32} | count 3
// XFAIL: *
// Every printf has 'i32 0' for the GEP of the string; no point counting those.
typedef unsigned int Foo __attribute__((aligned(32)));
typedef union{Foo:0;}a;
typedef union{int x; Foo:0;}b;
extern int printf(const char*, ...);
main() {
printf("%ld\n", sizeof(a));
printf("%ld\n", __alignof__(a));
printf("%ld\n", sizeof(b));
printf("%ld\n", __alignof__(b));
}
|
Add missing includes for std::abs. | //
// Copyright (c) 2012 Juan Palacios juan.palacios.puyana@gmail.com
// This file is part of minimathlibs.
// Subject to the BSD 2-Clause License
// - see < http://opensource.org/licenses/BSD-2-Clause>
//
#ifndef MATH_UTILS_H__
#define MATH_UTILS_H__
namespace Math {
template <typename T>
struct CompareWithTolerance
{
CompareWithTolerance() : tol_() {}
CompareWithTolerance(T tolerance) : tol_(tolerance) {}
bool operator()(const T& lhs, const T& rhs) const
{
return std::abs(rhs-lhs) <= tol_; // <= to allow for 0 tolerance.
}
private:
T tol_;
};
} // namespace Math
#endif // MATH_UTILS_H__
| //
// Copyright (c) 2012 Juan Palacios juan.palacios.puyana@gmail.com
// This file is part of minimathlibs.
// Subject to the BSD 2-Clause License
// - see < http://opensource.org/licenses/BSD-2-Clause>
//
#ifndef MATH_UTILS_H_
#define MATH_UTILS_H_
#include <cstdlib>
#include <cmath>
namespace Math {
template <typename T>
bool compareWithTolerance(const T& rhs, const T& lhs, const T& tol)
{
using std::abs;
return abs(rhs-lhs) <= tol; // <= to allow for 0 tolerance.
}
template <typename T>
struct CompareWithTolerance
{
CompareWithTolerance() : tol_() {}
CompareWithTolerance(T tolerance) : tol_(tolerance) {}
bool operator()(const T& lhs, const T& rhs) const
{
return compareWithTolerance(rhs, lhs, tol_);
}
private:
T tol_;
};
} // namespace Math
#endif // MATH_UTILS_H_
|
Include Linux or FreeBSD symbols depending on OS we are compiling on. | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef THIRD_PARTY_HWLOC_STATIC_COMPONENTS_H_
#define THIRD_PARTY_HWLOC_STATIC_COMPONENTS_H_
#include <private/internal-components.h>
static const struct hwloc_component* hwloc_static_components[] = {
&hwloc_noos_component,
&hwloc_xml_component,
&hwloc_synthetic_component,
&hwloc_xml_nolibxml_component,
&hwloc_linux_component,
&hwloc_linuxio_component,
#if defined(__x86_64__) || defined(__amd64__) || defined(_M_IX86) || \
defined(_M_X64)
&hwloc_x86_component,
#endif
NULL};
#endif // THIRD_PARTY_HWLOC_STATIC_COMPONENTS_H_
| /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef THIRD_PARTY_HWLOC_STATIC_COMPONENTS_H_
#define THIRD_PARTY_HWLOC_STATIC_COMPONENTS_H_
#include <private/internal-components.h>
static const struct hwloc_component* hwloc_static_components[] = {
&hwloc_noos_component,
&hwloc_xml_component,
&hwloc_synthetic_component,
&hwloc_xml_nolibxml_component,
#ifdef __Linux__
&hwloc_linux_component,
&hwloc_linuxio_component,
#endif
#ifdef __FreeBSD__
&hwloc_freebsd_component,
#endif
#if defined(__x86_64__) || defined(__amd64__) || defined(_M_IX86) || \
defined(_M_X64)
&hwloc_x86_component,
#endif
NULL};
#endif // THIRD_PARTY_HWLOC_STATIC_COMPONENTS_H_
|
Add either class for trivially constructable types | #ifndef UTIL_EITHER_H
#define UTIL_EITHER_H
#include <utility>
namespace util
{
template <typename L, typename R>
class Either
{
public:
bool left(L& x)
{
if (isLeft) x = l;
return isLeft;
}
bool right(R& x)
{
if (!isLeft) x = r;
return !isLeft;
}
private:
template <typename L_, typename R_>
friend Either<L_, R_> Left(L_ x);
template <typename L_, typename R_>
friend Either<L_, R_> Right(R_ x);
bool isLeft;
union
{
L l;
R r;
};
};
template <typename L, typename R>
Either<L, R> Left(L x)
{
Either<L, R> e;
e.isLeft = true;
e.l = std::move(x);
return e;
}
template <typename L, typename R>
Either <L, R> Right(R x)
{
Either<L, R> e;
e.isLeft = false;
e.r = std::move(x);
return e;
}
}
#endif
| |
Update for checkpoint66j and internal consistency | C $Header: /u/gcmpack/MITgcm/pkg/dic/DIC_ATMOS.h,v 1.4 2010/04/11 20:59:27 jmc Exp $
C $Name: $
COMMON /INTERACT_ATMOS_NEEDS/
& co2atmos,
& total_atmos_carbon, total_ocean_carbon,
& total_atmos_carbon_year,
& total_ocean_carbon_year,
& total_atmos_carbon_start,
& total_ocean_carbon_start,
& atpco2
_RL co2atmos(1002)
_RL total_atmos_carbon
_RL total_ocean_carbon
_RL total_atmos_carbon_year
_RL total_atmos_carbon_start
_RL total_ocean_carbon_year
_RL total_ocean_carbon_start
_RL atpco2
| |
Add include guard to SkFontConfigInterface.h | /*
* Copyright 2009-2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
#include "SkFontConfigInterface.h"
#include <fontconfig/fontconfig.h>
class SkFontConfigInterfaceDirect : public SkFontConfigInterface {
public:
SkFontConfigInterfaceDirect();
~SkFontConfigInterfaceDirect() override;
bool matchFamilyName(const char familyName[],
SkFontStyle requested,
FontIdentity* outFontIdentifier,
SkString* outFamilyName,
SkFontStyle* outStyle) override;
SkStreamAsset* openStream(const FontIdentity&) override;
protected:
virtual bool isAccessible(const char* filename);
private:
bool isValidPattern(FcPattern* pattern);
FcPattern* MatchFont(FcFontSet* font_set, const char* post_config_family,
const SkString& family);
typedef SkFontConfigInterface INHERITED;
};
| /*
* Copyright 2009-2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
#ifndef SKFONTCONFIGINTERFACE_DIRECT_H_
#define SKFONTCONFIGINTERFACE_DIRECT_H_
#include "SkFontConfigInterface.h"
#include <fontconfig/fontconfig.h>
class SkFontConfigInterfaceDirect : public SkFontConfigInterface {
public:
SkFontConfigInterfaceDirect();
~SkFontConfigInterfaceDirect() override;
bool matchFamilyName(const char familyName[],
SkFontStyle requested,
FontIdentity* outFontIdentifier,
SkString* outFamilyName,
SkFontStyle* outStyle) override;
SkStreamAsset* openStream(const FontIdentity&) override;
protected:
virtual bool isAccessible(const char* filename);
private:
bool isValidPattern(FcPattern* pattern);
FcPattern* MatchFont(FcFontSet* font_set, const char* post_config_family,
const SkString& family);
typedef SkFontConfigInterface INHERITED;
};
#endif
|
Add a test for llvm-gcc svn 110632. | // RUN: %llvmgcc %s -S -O0 -o - | FileCheck %s
// Radar 8288710: A small aggregate can be passed as an integer. Make sure
// we don't get an error with "input constraint with a matching output
// constraint of incompatible type!"
struct wrapper {
int i;
};
// CHECK: xyz
int test(int i) {
struct wrapper w;
w.i = i;
__asm__("xyz" : "=r" (w) : "0" (w));
return w.i;
}
| |
Fix typo in macro for tls access model | /*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#ifndef _BITS_UCLIBC_ERRNO_H
#define _BITS_UCLIBC_ERRNO_H 1
#ifdef IS_IN_rtld
# undef errno
# define errno _dl_errno
extern int _dl_errno; // attribute_hidden;
#elif defined __UCLIBC_HAS_THREADS__
# include <tls.h>
# if defined USE___THREAD && USE___THREAD
# undef errno
# ifndef NOT_IN_libc
# define errno __libc_errno
# else
# define errno errno
# endif
extern __thread int errno __attribute_tls_model_ie;
# endif /* USE___THREAD */
#endif /* IS_IN_rtld */
#define __set_errno(val) (errno = (val))
#ifndef __ASSEMBLER__
extern int *__errno_location (void) __THROW __attribute__ ((__const__))
# ifdef IS_IN_rtld
attribute_hidden
# endif
;
# if defined __UCLIBC_HAS_THREADS__
# include <tls.h>
# if defined USE___THREAD && USE___THREAD
libc_hidden_proto(__errno_location)
# endif
# endif
#endif /* !__ASSEMBLER__ */
#endif
| /*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#ifndef _BITS_UCLIBC_ERRNO_H
#define _BITS_UCLIBC_ERRNO_H 1
#ifdef IS_IN_rtld
# undef errno
# define errno _dl_errno
extern int _dl_errno; // attribute_hidden;
#elif defined __UCLIBC_HAS_THREADS__
# include <tls.h>
# if defined USE___THREAD && USE___THREAD
# undef errno
# ifndef NOT_IN_libc
# define errno __libc_errno
# else
# define errno errno
# endif
extern __thread int errno attribute_tls_model_ie;
# endif /* USE___THREAD */
#endif /* IS_IN_rtld */
#define __set_errno(val) (errno = (val))
#ifndef __ASSEMBLER__
extern int *__errno_location (void) __THROW __attribute__ ((__const__))
# ifdef IS_IN_rtld
attribute_hidden
# endif
;
# if defined __UCLIBC_HAS_THREADS__
# include <tls.h>
# if defined USE___THREAD && USE___THREAD
libc_hidden_proto(__errno_location)
# endif
# endif
#endif /* !__ASSEMBLER__ */
#endif
|
Fix alloca() redefinition warning on Windows | #if defined __clang__
#pragma clang push
#pragma clang diagnostic ignored "-Wignored-attributes"
#elif defined __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
#endif
#include <amx/amx.h>
#include <amx/amxaux.h>
#include <amx/amxdbg.h>
#if defined __clang_
#pragma clang pop
#elif defined __GNUC__
#pragma GCC pop
#endif
| #if defined __clang__
#pragma clang push
#pragma clang diagnostic ignored "-Wignored-attributes"
#elif defined __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
#endif
#ifdef _WIN32
#include <malloc.h>
#endif
#include <amx/amx.h>
#include <amx/amxaux.h>
#include <amx/amxdbg.h>
#if defined __clang_
#pragma clang pop
#elif defined __GNUC__
#pragma GCC pop
#endif
|
Add solution to Exercise 2-5. | /*
* A solution to Exercise 2-5 in The C Programming Language (Second Edition).
*
* This file was written by Damien Dart, <damiendart@pobox.com>. This is free
* and unencumbered software released into the public domain. For more
* information, please refer to the accompanying "UNLICENCE" file.
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int32_t any(char *, char *);
int main(void)
{
char *test_string_one = "Gooseberries.";
char *test_string_two = "Kiwis.";
printf("%d", any(test_string_one, test_string_two));
return EXIT_SUCCESS;
}
int32_t any(char *string_one, char *string_two)
{
for (uint32_t i = 0; string_one[i] != '\0'; i++) {
for (uint32_t j = 0; string_two[j] != '\0'; j++) {
if (string_one[i] == string_two[j]) {
return i;
}
}
}
return -1;
}
| |
Update GPUImageFillModeType enum to use NS_ENUM | #import <UIKit/UIKit.h>
#import "GPUImageContext.h"
typedef enum {
kGPUImageFillModeStretch, // Stretch to fill the full view, which may distort the image outside of its normal aspect ratio
kGPUImageFillModePreserveAspectRatio, // Maintains the aspect ratio of the source image, adding bars of the specified background color
kGPUImageFillModePreserveAspectRatioAndFill // Maintains the aspect ratio of the source image, zooming in on its center to fill the view
} GPUImageFillModeType;
/**
UIView subclass to use as an endpoint for displaying GPUImage outputs
*/
@interface GPUImageView : UIView <GPUImageInput>
{
GPUImageRotationMode inputRotation;
}
/** The fill mode dictates how images are fit in the view, with the default being kGPUImageFillModePreserveAspectRatio
*/
@property(readwrite, nonatomic) GPUImageFillModeType fillMode;
/** This calculates the current display size, in pixels, taking into account Retina scaling factors
*/
@property(readonly, nonatomic) CGSize sizeInPixels;
@property(nonatomic) BOOL enabled;
/** Handling fill mode
@param redComponent Red component for background color
@param greenComponent Green component for background color
@param blueComponent Blue component for background color
@param alphaComponent Alpha component for background color
*/
- (void)setBackgroundColorRed:(GLfloat)redComponent green:(GLfloat)greenComponent blue:(GLfloat)blueComponent alpha:(GLfloat)alphaComponent;
- (void)setCurrentlyReceivingMonochromeInput:(BOOL)newValue;
@end
| #import <UIKit/UIKit.h>
#import "GPUImageContext.h"
typedef NS_ENUM(NSUInteger, GPUImageFillModeType) {
kGPUImageFillModeStretch, // Stretch to fill the full view, which may distort the image outside of its normal aspect ratio
kGPUImageFillModePreserveAspectRatio, // Maintains the aspect ratio of the source image, adding bars of the specified background color
kGPUImageFillModePreserveAspectRatioAndFill // Maintains the aspect ratio of the source image, zooming in on its center to fill the view
};
/**
UIView subclass to use as an endpoint for displaying GPUImage outputs
*/
@interface GPUImageView : UIView <GPUImageInput>
{
GPUImageRotationMode inputRotation;
}
/** The fill mode dictates how images are fit in the view, with the default being kGPUImageFillModePreserveAspectRatio
*/
@property(readwrite, nonatomic) GPUImageFillModeType fillMode;
/** This calculates the current display size, in pixels, taking into account Retina scaling factors
*/
@property(readonly, nonatomic) CGSize sizeInPixels;
@property(nonatomic) BOOL enabled;
/** Handling fill mode
@param redComponent Red component for background color
@param greenComponent Green component for background color
@param blueComponent Blue component for background color
@param alphaComponent Alpha component for background color
*/
- (void)setBackgroundColorRed:(GLfloat)redComponent green:(GLfloat)greenComponent blue:(GLfloat)blueComponent alpha:(GLfloat)alphaComponent;
- (void)setCurrentlyReceivingMonochromeInput:(BOOL)newValue;
@end
|
Include basictypes.h for DISALLOW macro. | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_EVENT_FILTER_H_
#define UI_AURA_EVENT_FILTER_H_
#pragma once
#include "base/logging.h"
#include "ui/gfx/point.h"
namespace aura {
class Window;
class MouseEvent;
// An object that filters events sent to an owner window, potentially performing
// adjustments to the window's position, size and z-index.
class EventFilter {
public:
explicit EventFilter(Window* owner);
virtual ~EventFilter();
// Try to handle |event| (before the owner's delegate gets a chance to).
// Returns true if the event was handled by the WindowManager and should not
// be forwarded to the owner's delegate.
virtual bool OnMouseEvent(Window* target, MouseEvent* event);
protected:
Window* owner() { return owner_; }
private:
Window* owner_;
DISALLOW_COPY_AND_ASSIGN(EventFilter);
};
} // namespace aura
#endif // UI_AURA_EVENT_FILTER_H_
| // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_EVENT_FILTER_H_
#define UI_AURA_EVENT_FILTER_H_
#pragma once
#include "base/basictypes.h"
namespace aura {
class Window;
class MouseEvent;
// An object that filters events sent to an owner window, potentially performing
// adjustments to the window's position, size and z-index.
class EventFilter {
public:
explicit EventFilter(Window* owner);
virtual ~EventFilter();
// Try to handle |event| (before the owner's delegate gets a chance to).
// Returns true if the event was handled by the WindowManager and should not
// be forwarded to the owner's delegate.
virtual bool OnMouseEvent(Window* target, MouseEvent* event);
protected:
Window* owner() { return owner_; }
private:
Window* owner_;
DISALLOW_COPY_AND_ASSIGN(EventFilter);
};
} // namespace aura
#endif // UI_AURA_EVENT_FILTER_H_
|
Set up basic processing framework | /***************************************************************************************
* MAIN.C
*
* Description: Converts raw ADC reads given via character device to time of flight
*
* (C) 2016 Visaoni
* Licensed under the MIT License.
**************************************************************************************/
int main(void)
{
return 0;
}
| /***************************************************************************************
* MAIN.C
*
* Description: Converts raw ADC reads given via character device to time of flight
*
* (C) 2016 Visaoni
* Licensed under the MIT License.
**************************************************************************************/
#include <stdint.h>
#include <stdio.h>
//#include <unistd.h>
//#include <string.h>
#include <fcntl.h>
#include <sys/poll.h>
// TODO: Get these value from a shared source along with the firmware
#define TIME_BETWEEN_READS_NS 166.7
#define DELAY_TIME_NS 0
#define READS_PER_TX 2000
#define BYTES_PER_READ 2
#define CHARACTER_DEVICE_PATH "/dev/rpmsg_pru31"
#define MAX_BUFFER_SIZE (BYTES_PER_READ * READS_PER_TX)
double find_tof( uint16_t reads[] )
{
size_t max = 0;
size_t i;
for( i = 0; i < READS_PER_TX; i++ )
{
if( reads[i] > reads[max] )
{
max = i;
}
}
return DELAY_TIME_NS + max * TIME_BETWEEN_READS_NS;
}
int main(void)
{
uint8_t buffer[ MAX_BUFFER_SIZE ];
uint16_t* reads = (uint16_t*)buffer; // Assumes little-endian
struct pollfd pollfds[1];
pollfds[0].fd = open( CHARACTER_DEVICE_PATH, O_RDWR );
if( pollfds[0].fd < 0 )
{
printf( "Unable to open char device." );
return -1;
}
// Firmware needs an initial write to grab metadata
// msg contents irrelevant
// TODO: Should probably handle errors better
while( write( pollfds[0].fd, "s", 1 ) < 0 )
{
printf( "Problem with initial send. Retrying..." );
}
while(1)
{
// Grab a whole run and then process
// TODO: Figure out of this is sufficient or if incremental processing is required for performance
size_t total_bytes = 0;
while( total_bytes < MAX_BUFFER_SIZE )
{
total_bytes += read( pollfds[0].fd, buffer + total_bytes, MAX_BUFFER_SIZE - total_bytes );
}
// reads and buffer are aliased
double tof = find_tof( reads );
printf( "Time of flight: %d ns", tof );
}
return 0;
}
|
Add rows and cols assignment. | //-----------------------------------------------------------------------------
// Assignments
//-----------------------------------------------------------------------------
template<class T>
matrix<T>& matrix<T>::operator=(
std::initializer_list<std::initializer_list<T>> init_list){
data_ = make_vector(init_list);
return this;
}
| //-----------------------------------------------------------------------------
// Assignments
//-----------------------------------------------------------------------------
template<class T>
matrix<T>& matrix<T>::operator=(
std::initializer_list<std::initializer_list<T>> init_list){
data_ = make_vector(init_list);
rows_ = init_list.size();
cols_ = (init_list.size() > 0) ? init_list.begin()->size() : 0;
return this;
}
|
Add command to reboot help system | #include <kotaka/paths.h>
#include <game/paths.h>
inherit LIB_BIN;
void main(string args)
{
object user;
user = query_user();
if (user->query_class() < 3) {
send_out("You do not have sufficient access rights to reboot the help system.\n");
return;
}
"~Help/initd"->full_reset();
}
| |
Remove warning and only include needed stuff. | /* EINA - EFL data type library
* Copyright (C) 2008 Cedric Bail
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#include "Eina.h"
EAPI int
eina_init(void)
{
int r;
r = eina_error_init();
r += eina_hash_init();
r += eina_stringshare_init();
r += eina_list_init();
r += eina_array_init();
return r;
}
EAPI int
eina_shutdown(void)
{
int r;
eina_array_shutdown();
eina_list_shutdown();
r = eina_stringshare_shutdown();
r += eina_hash_shutdown();
r += eina_error_shutdown();
return r;
}
| /* EINA - EFL data type library
* Copyright (C) 2008 Cedric Bail
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#include "eina_error.h"
#include "eina_hash.h"
#include "eina_stringshare.h"
#include "eina_list.h"
#include "eina_array.h"
EAPI int
eina_init(void)
{
int r;
r = eina_error_init();
r += eina_hash_init();
r += eina_stringshare_init();
r += eina_list_init();
r += eina_array_init();
return r;
}
EAPI int
eina_shutdown(void)
{
int r;
eina_array_shutdown();
eina_list_shutdown();
r = eina_stringshare_shutdown();
r += eina_hash_shutdown();
r += eina_error_shutdown();
return r;
}
|
Add Linked List implementation of stack | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
/* This is Stack Implementation using a Linked list */
#define MAXSIZE 101
#define BOOL_PRINT(bool_expr) "%s\n", (bool_expr) ? "true" : "false"
typedef struct node{
int data;
struct node* link;
} node;
node* head; //global variable
node* create_newnode(int x){
node* temp;
temp = (node*) malloc (sizeof(node));
temp->data =x;
temp->link=NULL;
return temp;
}
void push(int data){
//this is equivalent to add a node at begining of the linked list
node* temp;
temp =create_newnode(data);
temp->link = head;
head = temp;
}
int pop(){
//this is equivalent to delete a node at begining of the linked list
if(head != NULL ){
node* temp = head;
head = temp->link;
return temp->data;
}
else{
printf("Error: Stack is empty \n");
return -1;
}
}
int isEmpty(){
//this is equivalent to checking if the linked list is empty
if(head != NULL) return false;
else return true;
}
void stack_print(){
//this is equivalent to printing a linked list while traversing
printf("Stack is : ");
node* temp = head;
while(temp != NULL){
printf("%d ", temp->data);
temp = temp->link;
}
printf("\n");
}
int main(){
int i;
printf("is stack empty? \n");
printf(BOOL_PRINT(isEmpty()));
push(10);
push(11);
push(12);
push(15);
i = pop();
printf("Popped data is %d\n",i );
stack_print();
return 0;
} | |
Implement the hyperbolic sine function. | #include <pal.h>
/**
*
* Calculates the hyperbolic sine of the vector 'a'. Angles are specified
* in radians.
*
* @param a Pointer to input vector
*
* @param c Pointer to output vector
*
* @param n Size of 'a' and 'c' vector.
*
* @return None
*
*/
#include <math.h>
void p_sinh_f32(const float *a, float *c, int n)
{
int i;
for (i = 0; i < n; i++) {
*(c + i) = sinhf(*(a + i));
}
}
| #include <pal.h>
/*
* sinh z = (exp z - exp(-z)) / 2
*/
static inline float _p_sinh(const float z)
{
float exp_z;
p_exp_f32(&z, &exp_z, 1);
return 0.5f * (exp_z - 1.f / exp_z);
}
/**
*
* Calculates the hyperbolic sine of the vector 'a'. Angles are specified
* in radians.
*
* @param a Pointer to input vector
*
* @param c Pointer to output vector
*
* @param n Size of 'a' and 'c' vector.
*
* @return None
*
*/
void p_sinh_f32(const float *a, float *c, int n)
{
int i;
for (i = 0; i < n; i++) {
c[i] = _p_sinh(a[i]);
}
}
|
Add internal MD size getter | /**
* Internal MD/hash functions - no crypto, just data.
* This is used to avoid depending on MD_C just to query a length.
*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBEDTLS_MD_INTERNAL_H
#define MBEDTLS_MD_INTERNAL_H
#include "common.h"
#include "mbedtls/md.h"
/** Get the output length of the given hash type
*
* \param md_type The hash type.
*
* \return The output length in bytes, or 0 if not known
*/
static inline unsigned char mbedtls_md_internal_get_size( mbedtls_md_type_t md_type )
{
switch( md_type )
{
#if defined(MBEDTLS_MD5_C) || defined(PSA_WANT_ALG_MD5)
case MBEDTLS_MD_MD5:
return( 16 );
#endif
#if defined(MBEDTLS_RIPEMD160_C) || defined(PSA_WANT_ALG_RIPEMD160) || \
defined(MBEDTLS_SHA1_C) || defined(PSA_WANT_ALG_SHA_1)
case MBEDTLS_MD_RIPEMD160:
case MBEDTLS_MD_SHA1:
return( 20 );
#endif
#if defined(MBEDTLS_SHA224_C) || defined(PSA_WANT_ALG_SHA_224)
case MBEDTLS_MD_SHA224:
return( 28 );
#endif
#if defined(MBEDTLS_SHA256_C) || defined(PSA_WANT_ALG_SHA_256)
case MBEDTLS_MD_SHA256:
return( 32 );
#endif
#if defined(MBEDTLS_SHA384_C) || defined(PSA_WANT_ALG_SHA_384)
case MBEDTLS_MD_SHA384:
return( 48 );
#endif
#if defined(MBEDTLS_SHA512_C) || defined(PSA_WANT_ALG_SHA_512)
case MBEDTLS_MD_SHA512:
return( 64 );
#endif
default:
return( 0 );
}
}
#endif /* MBEDTLS_MD_INTERNAL_H */
| |
Add missing static for inline functions (GCC 5) | /**
* Example of a typical library providing a C-interface
*/
#pragma once
#include "ivi-main-loop-c.h"
#ifdef __cplusplus
extern "C" {
#endif
static IVIMainLoop_EventSource_ReportStatus callbackMyCLibrary(const void *data)
{
printf("callbackMyCLibrary\n");
return IVI_MAIN_LOOP_KEEP_ENABLED;
}
/**
* Initialize the library using the given source manager object where the library is going to add its event sources
*/
inline void my_c_library_init_function(IVIMainLoop_EventSourceManager *sourceManager)
{
IVIMainLoop_TimeOut_CallBack callback = {.function = callbackMyCLibrary, .data = NULL};
IVIMainLoop_TimeOutEventSource *source = ivi_main_loop_timeout_source_new(sourceManager, callback, 300);
ivi_main_loop_timeout_source_enable(source);
}
#ifdef __cplusplus
}
#endif
| /**
* Example of a typical library providing a C-interface
*/
#pragma once
#include "ivi-main-loop-c.h"
#ifdef __cplusplus
extern "C" {
#endif
static IVIMainLoop_EventSource_ReportStatus callbackMyCLibrary(const void *data)
{
printf("callbackMyCLibrary\n");
return IVI_MAIN_LOOP_KEEP_ENABLED;
}
/**
* Initialize the library using the given source manager object where the library is going to add its event sources
*/
static inline void my_c_library_init_function(IVIMainLoop_EventSourceManager *sourceManager)
{
IVIMainLoop_TimeOut_CallBack callback = {.function = callbackMyCLibrary, .data = NULL};
IVIMainLoop_TimeOutEventSource *source = ivi_main_loop_timeout_source_new(sourceManager, callback, 300);
ivi_main_loop_timeout_source_enable(source);
}
#ifdef __cplusplus
}
#endif
|
Test code for ws-eventing server side | #include <pthread.h>
#include <time.h>
#include "ws-eventing.h"
#include "wsman-debug.h"
static char g_event_source_url[] = "http://www.otc_event.com/event_source";
static EventingH g_event_handler;
static void *publish_events(void *soap_handler);
void start_event_source(SoapH soap)
{
pthread_t publiser_thread;
g_event_handler = wse_initialize_server(soap, g_event_source_url);
pthread_create(&publiser_thread, NULL, publish_events, soap);
printf("Eventing source started...\n");
}
void *publish_events(void *soap_handler)
{
char *action_list[] = {"random_event"};
WsePublisherH publisher_handler;
WsXmlDocH event_doc;
struct timespec time_val = {10, 0};
publisher_handler = wse_publisher_initialize((EventingH)g_event_handler, 1, action_list, NULL, NULL);
while(1)
{
nanosleep(&time_val, NULL);
event_doc = ws_xml_create_doc((SoapH)soap_handler, "rootNsUri", "rootName"); //TBD
wse_send_notification(publisher_handler, event_doc, "http://otc.eventing.org/");
}
}
| |
Add black drop-shadow outline to text | #pragma once
#include "Sprite.h"
#include "FontAsset.h"
class Text : public Sprite {
private:
std::shared_ptr<FontAsset> asset;
std::string str;
public:
Text(std::shared_ptr<FontAsset> asset, const std::string str, const Point2 pos = Point2(0), const Origin origin = Origin::BottomLeft,
const Point4 color = Point4(1), const Point2 scale = Point2(-1))
: asset(asset), str(str), Sprite(pos, origin, color, scale) {}
void RenderMe() override final {
SDL(surface = TTF_RenderUTF8_Blended(asset->font, str.data(), { 255, 255, 255, 255 }));
}
void SetText(const std::string str) {
this->str = str;
Render();
}
};
| #pragma once
#include "Sprite.h"
#include "FontAsset.h"
class Text : public Sprite {
private:
std::shared_ptr<FontAsset> asset;
std::string str;
public:
Text(std::shared_ptr<FontAsset> asset, const std::string str, const Point2 pos = Point2(0), const Origin origin = Origin::BottomLeft,
const Point4 color = Point4(1), const Point2 scale = Point2(-1))
: asset(asset), str(str), Sprite(pos, origin, color, scale) {}
void RenderMe() override final {
// we render the outline first to make a drop-shadow effect
SDL(TTF_SetFontOutline(asset->font, 2));
SDL(surface = TTF_RenderUTF8_Blended(asset->font, str.data(), { 0, 0, 0, 255 }));
// then we render the foreground and blit it on top of the outline
SDL(TTF_SetFontOutline(asset->font, 0));
SDL_Surface *fg;
SDL(fg = TTF_RenderUTF8_Blended(asset->font, str.data(), { 255, 255, 255, 255 }));
SDL(SDL_BlitSurface(fg, NULL, surface, NULL));
SDL(SDL_FreeSurface(fg));
}
void SetText(const std::string str) {
this->str = str;
Render();
}
};
|
Add basic memory and io map. |
/* 18 bits => 0x00000 - 0x3FFFF => 256kb */
#define ADDR_W 18
#define ZWC_CS_W 4
#define ZWC_WB_ADR_W ADDR_W - ZMC_CS_W - 3
#define ZWC_CS_SIZE ( (1<<ZWC_WB_ADR_W)-1 )
/*
* 0x00000 - 0x1FFFF: RAM
* 0x20000 - 0x2FFFF: phiIO
* 0x30000 - 0x3FFFF: zwishbone
*
*
*/
#define IO_MASK (1<<(ADDR_W-1))
#define ZWC_MASK (1<<(ADDR_W-2))
/*
* 0x30000 : ZWC_CONFIG
* 0x30004 : ZWC_STATUS
* 0x38000 - 0x37ff : ZWC_0_BASE
* 0x38800 - 0x38ff : ZWC_1_BASE
* 0x38900 - 0x39ff : ZWC_2_BASE
* 0x38a00 - 0x3aff : ZWC_3_BASE
#define ZWC_CONFIG (IO_MASK | ZWC_MASK)
#define ZWC_STATUS (IO_MASK | ZWC_MASK | 4)
#define ZWC_0_BASE (IO_MASK | ZWC_MASK | ZWC_BUS_MASK)
#define ZWC_1_BASE (ZWC_0_BASE + ZWC_CS_SIZE)
#define ZWC_2_BASE (ZWC_1_BASE + ZWC_CS_SIZE)
#define ZWC_3_BASE (ZWC_2_BASE + ZWC_CS_SIZE)
/* etc... */
| |
Make the compare const void. | #ifndef lcthw_List_algos_h
#define lcthw_List_algos_h
#include <lcthw/list.h>
typedef int (*List_compare)(void *a, void *b);
int List_bubble_sort(List *list, List_compare cmp);
List *List_merge_sort(List *list, List_compare cmp);
#endif
| #ifndef lcthw_List_algos_h
#define lcthw_List_algos_h
#include <lcthw/list.h>
typedef int (*List_compare)(const void *a, const void *b);
int List_bubble_sort(List *list, List_compare cmp);
List *List_merge_sort(List *list, List_compare cmp);
#endif
|
Make 'svn mergeinfo' and its underlying APIs error out when talking to a pre-1.5 repository. | /*
* util.c: Repository access utility routines.
*
* ====================================================================
* Copyright (c) 2007 CollabNet. All rights reserved.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://subversion.tigris.org/license-1.html.
* If newer versions of this license are posted there, you may use a
* newer version instead, at your option.
*
* This software consists of voluntary contributions made by many
* individuals. For exact contribution history, see the revision
* history and logs, available at http://subversion.tigris.org/.
* ====================================================================
*/
/* ==================================================================== */
/*** Includes. ***/
#include <apr_pools.h>
#include "svn_types.h"
#include "svn_error.h"
#include "svn_error_codes.h"
#include "svn_ra.h"
#include "svn_private_config.h"
/* Return an error with code SVN_ERR_UNSUPPORTED_FEATURE, and an error
message referencing PATH_OR_URL, if the "server" pointed to be
RA_SESSION doesn't support Merge Tracking (e.g. is pre-1.5).
Perform temporary allocations in POOL. */
svn_error_t *
svn_ra__assert_mergeinfo_capable_server(svn_ra_session_t *ra_session,
const char *path_or_url,
apr_pool_t *pool)
{
svn_boolean_t mergeinfo_capable;
SVN_ERR(svn_ra_has_capability(ra_session, &mergeinfo_capable,
SVN_RA_CAPABILITY_MERGEINFO, pool));
if (! mergeinfo_capable)
{
if (path_or_url == NULL)
{
svn_error_t *err = svn_ra_get_session_url(ra_session, &path_or_url,
pool);
if (err)
{
/* The SVN_ERR_UNSUPPORTED_FEATURE error is more important,
so dummy up the session's URL and chuck this error. */
svn_error_clear(err);
path_or_url = "<repository>";
}
}
return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
_("Retrieval of mergeinfo unsupported by '%s'"),
svn_path_local_style(path_or_url, pool));
}
return SVN_NO_ERROR;
}
| |
Add a definition for FD_SETSIZE. | /*
* Copyright (C) 2014, Galois, Inc.
* This sotware is distributed under a standard, three-clause BSD license.
* Please see the file LICENSE, distributed with this software, for specific
* terms and conditions.
*/
#ifndef MINLIBC_SYS_SELECT_H
#define MINLIBC_SYS_SELECT_H
#include <time.h>
typedef struct {} fd_set;
int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
#define FD_SET(x,y) /* */
#define FD_ZERO(x) /* */
#endif
| /*
* Copyright (C) 2014, Galois, Inc.
* This sotware is distributed under a standard, three-clause BSD license.
* Please see the file LICENSE, distributed with this software, for specific
* terms and conditions.
*/
#ifndef MINLIBC_SYS_SELECT_H
#define MINLIBC_SYS_SELECT_H
#include <time.h>
typedef struct {} fd_set;
int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
#define FD_SET(x,y) /* */
#define FD_ZERO(x) /* */
#define FD_SETSIZE 1024
#endif
|
Fix warning re: signed shift | #ifndef KERNEL_PORT_BITWHACK_H
#define KERNEL_PORT_BITWHACK_H
/* Helpers for bitwhacking. */
/**
* Macros for constructing bit masks.
*
* When bitwise-anded with another value:
*
* MASK_LO(n) masks out the lowest n bits.
* MASK_HI(n) masks out all but the lowest n bits.
* MASK_RANGE(lo, hi) masks out all of the bits on the interval [lo, hi]
* (inclusive).
*
* The KEEP_* macros produce masks that are the inverse of their MASK_*
* counterparts.
*/
#define MASK_LO(bits) ((-1)<<(bits))
#define KEEP_LO(bits) (~MASK_LO(bits))
#define MASK_HI(bits) KEEP_LO(bits)
#define KEEP_HI(bits) MASK_LO(bits)
#define KEEP_RANGE(lo, hi) (MASK_LO(lo) & MASK_HI(hi))
#define MASK_RANGE(lo, hi) (~KEEP_RANGE(lo, hi))
#endif
| #ifndef KERNEL_PORT_BITWHACK_H
#define KERNEL_PORT_BITWHACK_H
/* Helpers for bitwhacking. */
/**
* Macros for constructing bit masks.
*
* When bitwise-anded with another value:
*
* MASK_LO(n) masks out the lowest n bits.
* MASK_HI(n) masks out all but the lowest n bits.
* MASK_RANGE(lo, hi) masks out all of the bits on the interval [lo, hi]
* (inclusive).
*
* The KEEP_* macros produce masks that are the inverse of their MASK_*
* counterparts.
*/
#define MASK_LO(bits) ((~0u)<<(bits))
#define KEEP_LO(bits) (~MASK_LO(bits))
#define MASK_HI(bits) KEEP_LO(bits)
#define KEEP_HI(bits) MASK_LO(bits)
#define KEEP_RANGE(lo, hi) (MASK_LO(lo) & MASK_HI(hi))
#define MASK_RANGE(lo, hi) (~KEEP_RANGE(lo, hi))
#endif
|
Add a test for fmpz_vec_scalar_divexact_fmpz | /*=============================================================================
This file is part of FLINT.
FLINT 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.
FLINT 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 FLINT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2009, 2010 William Hart
Copyright (C) 2010 Sebastian Pancratz
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <mpir.h>
#include "flint.h"
#include "fmpz.h"
#include "fmpz_vec.h"
#include "ulong_extras.h"
int
main(void)
{
int result;
printf("scalar_divexact_fmpz....");
fflush(stdout);
_fmpz_vec_randinit();
// Check aliasing of a and b
for (ulong i = 0; i < 10000UL; i++)
{
fmpz *a, *b, *c;
fmpz_t n;
ulong length = n_randint(100);
fmpz_init(n);
fmpz_randtest(n, 100);
if (n_randint(2))
fmpz_neg(n, n);
a = _fmpz_vec_init(length);
b = _fmpz_vec_init(length);
_fmpz_vec_randtest(a, length, n_randint(200));
_fmpz_vec_scalar_mul_fmpz(b, a, length, n);
_fmpz_vec_scalar_mul_fmpz(a, a, length, n);
result = (_fmpz_vec_equal(a, b, length));
if (!result)
{
printf("FAIL:\n");
_fmpz_vec_print(a, length), printf("\n\n");
_fmpz_vec_print(b, length), printf("\n\n");
abort();
}
_fmpz_vec_clear(a, length);
_fmpz_vec_clear(b, length);
fmpz_clear(n);
}
_fmpz_vec_randclear();
_fmpz_cleanup();
printf("PASS\n");
return 0;
}
| |
Increment version number from 1.32 to 1.40 | #pragma once
// const float in a header file can lead to duplication of the storage
// but I don't really care in this case. Just don't do it with a header
// that is included hundreds of times.
const float kCurrentVersion = 1.32f;
| #pragma once
// const float in a header file can lead to duplication of the storage
// but I don't really care in this case. Just don't do it with a header
// that is included hundreds of times.
const float kCurrentVersion = 1.40f;
|
Add another autoload key for TDataFrameImpl' | /*************************************************************************
* 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::TDataFrameInterface<ROOT::Detail::TDataFrameFilterBase>-;
#pragma link C++ class ROOT::Experimental::TDataFrameInterface<ROOT::Detail::TDataFrameBranchBase>-;
#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::TDataFrameInterface<ROOT::Detail::TDataFrameFilterBase>-;
#pragma link C++ class ROOT::Experimental::TDataFrameInterface<ROOT::Detail::TDataFrameBranchBase>-;
#pragma link C++ class ROOT::Detail::TDataFrameImpl-;
#endif
|
Fix writing to wrong register | /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <vdp2/scrn.h>
#include <assert.h>
#include "vdp2-internal.h"
void
vdp2_scrn_reduction_set(uint8_t scrn, uint16_t horz_reduction)
{
#ifdef DEBUG
/* Check if the background passed is valid */
assert((scrn == SCRN_NBG0) ||
(scrn == SCRN_NBG1));
assert((horz_reduction == SCRN_REDUCTION_NONE) ||
(horz_reduction == SCRN_REDUCTION_HALF) ||
(horz_reduction == SCRN_REDUCTION_QUARTER));
#endif /* DEBUG */
switch (scrn) {
case SCRN_NBG0:
vdp2_state.buffered_regs.zmctl &= 0xFFFC;
vdp2_state.buffered_regs.zmctl |= horz_reduction;
break;
case SCRN_NBG1:
vdp2_state.buffered_regs.zmctl &= 0xFCFF;
vdp2_state.buffered_regs.zmctl |= horz_reduction << 8;
break;
default:
return;
}
/* Write to memory */
MEMORY_WRITE(16, VDP2(MZCTL), vdp2_state.buffered_regs.zmctl);
}
| /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <vdp2/scrn.h>
#include <assert.h>
#include "vdp2-internal.h"
void
vdp2_scrn_reduction_set(uint8_t scrn, uint16_t horz_reduction)
{
#ifdef DEBUG
/* Check if the background passed is valid */
assert((scrn == SCRN_NBG0) ||
(scrn == SCRN_NBG1));
assert((horz_reduction == SCRN_REDUCTION_NONE) ||
(horz_reduction == SCRN_REDUCTION_HALF) ||
(horz_reduction == SCRN_REDUCTION_QUARTER));
#endif /* DEBUG */
switch (scrn) {
case SCRN_NBG0:
vdp2_state.buffered_regs.zmctl &= 0xFFFC;
vdp2_state.buffered_regs.zmctl |= horz_reduction;
break;
case SCRN_NBG1:
vdp2_state.buffered_regs.zmctl &= 0xFCFF;
vdp2_state.buffered_regs.zmctl |= horz_reduction << 8;
break;
default:
return;
}
/* Write to memory */
MEMORY_WRITE(16, VDP2(ZMCTL), vdp2_state.buffered_regs.zmctl);
}
|
Move sample policy logic to be pre-sending request | /*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <proxygen/lib/utils/TraceEventObserver.h>
namespace proxygen {
/*
* A no-op trace event observer
*/
struct NullTraceEventObserver : public TraceEventObserver {
void traceEventAvailable(TraceEvent) noexcept override {}
};
}
| |
FIX cleaned up header file to resemble FSM environment | #ifndef SSPAPPLICATION_AI_LEVELDIRECTOR_H
#define SSPAPPLICATION_AI_LEVELDIRECTOR_H
#include "Observer.h"
#include <vector>
class LevelDirector
{
private: // Variables
/* TEMP STATE STRUCTURE */
static enum State
{
NONE = 0,
START,
DEFAULT,
GOAL
};
State m_currentState;
State m_defaultState;
//State m_goalState;// A state which is the current goal for the FSM
// Change State to State* after temp structure is removed
std::vector<State> m_states;
public:
LevelDirector();
~LevelDirector();
int Shutdown();
int Initialize();
int Update(float deltaTime);
int React(int entityID, EVENT event);
private: // Helper functions
void AddState(State newState);
void SetDefaultState(State state);
bool ChangeState(State state);
};
#endif | #ifndef SSPAPPLICATION_AI_LEVELDIRECTOR_H
#define SSPAPPLICATION_AI_LEVELDIRECTOR_H
#include "Observer.h"
#include <vector>
//#define NUMSTATES 3
namespace FSMEnvironment
{
#pragma region temp
enum Hint
{
NONE = 0,
EXAMPLE
};
struct State
{
int stateID = -1;
int timeDelay = -1;
Hint hint = Hint::NONE;
int CheckTransitions();
void Enter();
void Exit();
void Update(float deltaTime);
};
#pragma endregion
class LevelDirector
{
private: // Variables
State* m_currentState;
State* m_defaultState;
State* m_goalState; // A state which is the current goal for the FSM
int m_goalID;
std::vector<State> m_states;
public:
LevelDirector();
~LevelDirector();
int Shutdown();
int Initialize();
int Update(float deltaTime);
int React(int entityID, EVENT event);
private: // Helper functions
// TODO:
// Depending on what kind of array/vector we end up with to hold our states
// the argument list should be updated accordingly
void AddState(State* newState);
void SetDefaultState(State* state);
bool ChangeState(int state);
};
}
#endif |
Mark venprintf() as static explicitly, not just in the decl | /* See LICENSE file for copyright and license details. */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../util.h"
static void venprintf(int, const char *, va_list);
void
eprintf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
venprintf(EXIT_FAILURE, fmt, ap);
va_end(ap);
}
void
enprintf(int status, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
venprintf(status, fmt, ap);
va_end(ap);
}
void
venprintf(int status, const char *fmt, va_list ap)
{
vfprintf(stderr, fmt, ap);
if(fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
}
exit(status);
}
void
weprintf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
}
}
| /* See LICENSE file for copyright and license details. */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../util.h"
static void venprintf(int, const char *, va_list);
void
eprintf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
venprintf(EXIT_FAILURE, fmt, ap);
va_end(ap);
}
void
enprintf(int status, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
venprintf(status, fmt, ap);
va_end(ap);
}
static void
venprintf(int status, const char *fmt, va_list ap)
{
vfprintf(stderr, fmt, ap);
if(fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
}
exit(status);
}
void
weprintf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
}
}
|
Check system is big endian or little endian function added | #ifdef OS_WINDOWS
#endif
#ifdef LINUX
#define SWAP(valX,valY) \
{ \
typeof (valX) valZ; \
valZ = valX; \
valX = valY; \
valY = valZ; \
}
#endif
/*Swap 2 integer number by xor method*/
void swap2int(int *,int *);
char *decimal_to_binary(size_t);
/*Inverse number like 1136 -> 6311*/
int inverse_number(int);
char * base64_decoder(const char *);
char * base64_encoder(const char *);
char * url_decoder(const char *);
char * url_encoder(const char *);
/*ASCII values convert HEX values*/
char *ascii2hex(const char *,size_t);
/*HEX values convert ASCII values*/
char *hex2ascii(const char *,size_t);
| #ifdef OS_WINDOWS
#endif
#ifdef LINUX
#define SWAP(valX,valY) \
{ \
typeof (valX) valZ; \
valZ = valX; \
valX = valY; \
valY = valZ; \
}
#endif
/*Swap 2 integer number by xor method*/
void swap2int(int *,int *);
char *decimal_to_binary(size_t);
/*Inverse number like 1136 -> 6311*/
int inverse_number(int);
char * base64_decoder(const char *);
char * base64_encoder(const char *);
char * url_decoder(const char *);
char * url_encoder(const char *);
/*ASCII values convert HEX values*/
char *ascii2hex(const char *,size_t);
/*HEX values convert ASCII values*/
char *hex2ascii(const char *,size_t);
const int is_little_endian_ival = 1;
#define is_little_endian() ( ( *((char*) &is_little_endian_ival) ) == 1 ) |
Add new constant for button | //
// Constants.h
// Pods
//
// Created by Danil Tulin on 1/30/16.
//
//
@import Foundation;
#ifndef Constants_h
#define Constants_h
const static NSString *defaultPrimaryColor = @"1A1A1C";
const static NSString *darkPrimaryColor = @"121315";
const static NSInteger bottomToolbarHeight = 50;
const static CGFloat defaultAnimationDuration = .3f;
const static NSInteger predscriptionViewCornerViewOffset = 25;
#endif /* Constants_h */
| //
// Constants.h
// Pods
//
// Created by Danil Tulin on 1/30/16.
//
//
@import Foundation;
#ifndef Constants_h
#define Constants_h
const static NSString *defaultPrimaryColor = @"1A1A1C";
const static NSString *darkPrimaryColor = @"121315";
const static NSInteger bottomToolbarHeight = 50;
const static CGFloat defaultAnimationDuration = .3f;
const static NSInteger predscriptionViewCornerViewOffset = 25;
const static CGSize SERoundButtonsContainerOffset = {25, 20};
#endif /* Constants_h */
|
Change 'if' style for null _callback check | // Copyright 2010-2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
#include "include\cef_callback.h"
namespace CefSharp
{
public ref class CefCallbackWrapper : public ICallback
{
private:
MCefRefPtr<CefCallback> _callback;
public:
CefCallbackWrapper(CefRefPtr<CefCallback> &callback) : _callback(callback)
{
}
!CefCallbackWrapper()
{
_callback = NULL;
}
~CefCallbackWrapper()
{
this->!CefCallbackWrapper();
}
virtual void Cancel()
{
if (_callback.get() == nullptr)
{
return;
}
_callback->Cancel();
delete this;
}
virtual void Continue()
{
if (_callback.get() == nullptr)
{
return;
}
_callback->Continue();
delete this;
}
};
} | // Copyright 2010-2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
#include "include\cef_callback.h"
namespace CefSharp
{
public ref class CefCallbackWrapper : public ICallback
{
private:
MCefRefPtr<CefCallback> _callback;
public:
CefCallbackWrapper(CefRefPtr<CefCallback> &callback) : _callback(callback)
{
}
!CefCallbackWrapper()
{
_callback = NULL;
}
~CefCallbackWrapper()
{
this->!CefCallbackWrapper();
}
virtual void Cancel()
{
if (_callback.get())
{
_callback->Cancel();
delete this;
}
}
virtual void Continue()
{
if (_callback.get())
{
_callback->Continue();
delete this;
}
}
};
} |
Include platform.h instead of ifdef'ing | /*
* Copyright 2013 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_CONFIG_H
#define SRC_CONFIG_H 1
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#ifdef _WIN32
#include <windows.h>
typedef unsigned __int8 cbsasl_uint8_t;
typedef unsigned __int16 cbsasl_uint16_t;
typedef unsigned __int32 cbsasl_uint32_t;
#else
#include <unistd.h>
#include <stdint.h>
typedef uint8_t cbsasl_uint8_t;
typedef uint16_t cbsasl_uint16_t;
typedef uint32_t cbsasl_uint32_t;
#endif
#endif /* SRC_CONFIG_H */
| /*
* Copyright 2013 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_CONFIG_H
#define SRC_CONFIG_H 1
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <platform/platform.h>
typedef uint8_t cbsasl_uint8_t;
typedef uint16_t cbsasl_uint16_t;
typedef uint32_t cbsasl_uint32_t;
#endif /* SRC_CONFIG_H */
|
Fix hppa ldcw alignment issue. | /* $OpenBSD: spinlock.h,v 1.1 1999/01/08 08:25:34 d Exp $ */
#ifndef _MACHINE_SPINLOCK_H_
#define _MACHINE_SPINLOCK_H_
#define _SPINLOCK_UNLOCKED (1)
#define _SPINLOCK_LOCKED (0)
typedef int _spinlock_lock_t;
#endif
| /* $OpenBSD: spinlock.h,v 1.2 2005/12/19 21:30:10 marco Exp $ */
#ifndef _MACHINE_SPINLOCK_H_
#define _MACHINE_SPINLOCK_H_
#define _SPINLOCK_UNLOCKED (1)
#define _SPINLOCK_LOCKED (0)
typedef int _spinlock_lock_t __attribute__((__aligned__(16)));
#endif
|
Synchronize the mailbox after expunging messages to actually get them expunged. | /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
| /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
else if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
|
Add new header file. (or: xcode is stupid) | //
// BDSKOAIGroupServer.h
// Bibdesk
//
// Created by Christiaan Hofman on 1/1/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "BDSKSearchGroup.h"
@class BDSKServerInfo;
@interface BDSKOAIGroupServer : NSObject <BDSKSearchGroupServer>
{
BDSKSearchGroup *group;
BDSKServerInfo *serverInfo;
NSString *searchTerm;
NSString *resumptionToken;
NSArray *sets;
NSString *filePath;
NSURLDownload *URLDownload;
BOOL failedDownload;
BOOL isRetrieving;
BOOL needsReset;
int availableResults;
int fetchedResults;
}
- (void)setServerInfo:(BDSKServerInfo *)info;
- (BDSKServerInfo *)serverInfo;
- (void)setSearchTerm:(NSString *)string;
- (NSString *)searchTerm;
- (void)setSets:(NSArray *)newSets;
- (NSArray *)sets;
- (void)setResumptionToken:(NSString *)newResumptionToken;
- (NSString *)resumptionToken;
- (void)resetSearch;
- (void)fetchSets;
- (void)fetch;
- (void)startDownloadFromURL:(NSURL *)theURL;
@end
| |
Make this test portable on Win32. | // RUN: %clang_cc1 -emit-llvm %s -o - | grep llvm.global.annotations
// RUN: %clang_cc1 -emit-llvm %s -o - | grep llvm.var.annotation | count 3
#include <stdio.h>
/* Global variable with attribute */
int X __attribute__((annotate("GlobalValAnnotation")));
/* Function with attribute */
int foo(int y) __attribute__((annotate("GlobalValAnnotation")))
__attribute__((noinline));
int foo(int y __attribute__((annotate("LocalValAnnotation")))) {
int x __attribute__((annotate("LocalValAnnotation")));
x = 34;
return y + x;
}
int main() {
static int a __attribute__((annotate("GlobalValAnnotation")));
a = foo(2);
printf("hello world%d\n", a);
return 0;
}
| // RUN: %clang_cc1 -emit-llvm %s -o - | grep llvm.global.annotations
// RUN: %clang_cc1 -emit-llvm %s -o - | grep llvm.var.annotation | count 3
/* Global variable with attribute */
int X __attribute__((annotate("GlobalValAnnotation")));
/* Function with attribute */
int foo(int y) __attribute__((annotate("GlobalValAnnotation")))
__attribute__((noinline));
int foo(int y __attribute__((annotate("LocalValAnnotation")))) {
int x __attribute__((annotate("LocalValAnnotation")));
x = 34;
return y + x;
}
int main() {
static int a __attribute__((annotate("GlobalValAnnotation")));
a = foo(2);
return 0;
}
|
Increase PSTR2 buffer (fix broken calibration) | #ifndef PSTR_HELPER_H
#define PSTR_HELPER_H
#include <avr/pgmspace.h>
// Modified PSTR that pushes string into a char* buffer for easy use.
//
// There is only one buffer so this will cause problems if you need to pass two
// strings to one function.
#define PSTR2(x) PSTRtoBuffer_P(PSTR(x))
#define PSTR2_BUFFER_SIZE 32 // May need adjusted depending on your needs.
char *PSTRtoBuffer_P(PGM_P str);
#endif
| #ifndef PSTR_HELPER_H
#define PSTR_HELPER_H
#include <avr/pgmspace.h>
// Modified PSTR that pushes string into a char* buffer for easy use.
//
// There is only one buffer so this will cause problems if you need to pass two
// strings to one function.
#define PSTR2(x) PSTRtoBuffer_P(PSTR(x))
#define PSTR2_BUFFER_SIZE 48 // May need adjusted depending on your needs.
char *PSTRtoBuffer_P(PGM_P str);
#endif
|
Include "libunwind_i.h" instead of "internal.h". | /*
* Copyright (C) 1998, 1999, 2002, 2003, 2005 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com>
*
* Register stack engine related helper functions. This file may be
* used in applications, so be careful about the name-space and give
* some consideration to non-GNU C compilers (though __inline__ is
* fine).
*/
#ifndef RSE_H
#define RSE_H
#include <libunwind.h>
static inline uint64_t
rse_slot_num (uint64_t addr)
{
return (addr >> 3) & 0x3f;
}
/*
* Return TRUE if ADDR is the address of an RNAT slot.
*/
static inline uint64_t
rse_is_rnat_slot (uint64_t addr)
{
return rse_slot_num (addr) == 0x3f;
}
/*
* Returns the address of the RNAT slot that covers the slot at
* address SLOT_ADDR.
*/
static inline uint64_t
rse_rnat_addr (uint64_t slot_addr)
{
return slot_addr | (0x3f << 3);
}
/*
* Calculate the number of registers in the dirty partition starting at
* BSPSTORE and ending at BSP. This isn't simply (BSP-BSPSTORE)/8
* because every 64th slot stores ar.rnat.
*/
static inline uint64_t
rse_num_regs (uint64_t bspstore, uint64_t bsp)
{
uint64_t slots = (bsp - bspstore) >> 3;
return slots - (rse_slot_num(bspstore) + slots)/0x40;
}
/*
* The inverse of the above: given bspstore and the number of
* registers, calculate ar.bsp.
*/
static inline uint64_t
rse_skip_regs (uint64_t addr, long num_regs)
{
long delta = rse_slot_num(addr) + num_regs;
if (num_regs < 0)
delta -= 0x3e;
return addr + ((num_regs + delta/0x3f) << 3);
}
#endif /* RSE_H */
| |
Add missed file in previous revision. | #ifndef THREAD_POSIX_H
#define THREAD_POSIX_H
struct ThreadState {
pthread_t td_;
static void start(pthread_key_t key, Thread *td)
{
pthread_t self = pthread_self();
td->state_->td_ = self;
int rv = pthread_setspecific(key, td);
if (rv == -1) {
ERROR("/thread/state/start") << "Could not set thread-local Thread pointer.";
return;
}
#if defined(__FreeBSD__)
pthread_set_name_np(self, td->name_.c_str());
#elif defined(__APPLE__)
pthread_setname_np(td->name_.c_str());
#endif
}
};
#endif /* !THREAD_POSIX_H */
| |
Include method to return pointer to object gameStateMachine | #ifndef __GAME__
#define __GAME__
#include<vector>
#include<SDL2/SDL.h>
#include"GameObject.h"
#include"GameStateMachine.h"
class Game
{
public:
static Game *getInstance()
{
if (!instance) {
instance = new Game();
}
return instance;
}
bool init(const char *title, int xPosition, int yPosition, int height, int width, bool fullScreen);
void render();
void update();
void handleEvents();
void clean();
bool isRunning() { return running; }
SDL_Renderer *getRenderer() const { return renderer; }
private:
static Game *instance;
bool running;
SDL_Window *window;
SDL_Renderer *renderer;
GameStateMachine *gameStateMachine;
std::vector<GameObject*> gameObjects;
Game() {}
~Game() {}
};
typedef Game TheGame;
#endif
| #ifndef __GAME__
#define __GAME__
#include<vector>
#include<SDL2/SDL.h>
#include"GameObject.h"
#include"GameStateMachine.h"
class Game
{
public:
static Game *getInstance()
{
if (!instance) {
instance = new Game();
}
return instance;
}
bool init(const char *title, int xPosition, int yPosition, int height, int width, bool fullScreen);
void render();
void update();
void handleEvents();
void clean();
bool isRunning() { return running; }
SDL_Renderer *getRenderer() const { return renderer; }
GameStateMachine* getStateMachine() { return gameStateMachine; }
private:
static Game *instance;
bool running;
SDL_Window *window;
SDL_Renderer *renderer;
GameStateMachine *gameStateMachine;
std::vector<GameObject*> gameObjects;
Game() {}
~Game() {}
};
typedef Game TheGame;
#endif
|
Revert D5012627: [FBCode] Switch various calls to folly::setThreadName to set the current thread's name | /*
* Copyright (c) 2017, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <atomic>
#include <string>
#include <thread>
#include <wangle/concurrent/ThreadFactory.h>
#include <folly/Conv.h>
#include <folly/Range.h>
#include <folly/ThreadName.h>
namespace wangle {
class NamedThreadFactory : public ThreadFactory {
public:
explicit NamedThreadFactory(folly::StringPiece prefix)
: prefix_(prefix.str()), suffix_(0) {}
std::thread newThread(folly::Func&& func) override {
auto thread = std::thread([&](folly::Func&& funct) {
folly::setThreadName(folly::to<std::string>(prefix_, suffix_++));
funct();
}, std::move(func));
return thread;
}
void setNamePrefix(folly::StringPiece prefix) {
prefix_ = prefix.str();
}
std::string getNamePrefix() {
return prefix_;
}
private:
std::string prefix_;
std::atomic<uint64_t> suffix_;
};
} // namespace wangle
| /*
* Copyright (c) 2017, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <atomic>
#include <string>
#include <thread>
#include <wangle/concurrent/ThreadFactory.h>
#include <folly/Conv.h>
#include <folly/Range.h>
#include <folly/ThreadName.h>
namespace wangle {
class NamedThreadFactory : public ThreadFactory {
public:
explicit NamedThreadFactory(folly::StringPiece prefix)
: prefix_(prefix.str()), suffix_(0) {}
std::thread newThread(folly::Func&& func) override {
auto thread = std::thread(std::move(func));
folly::setThreadName(
thread.native_handle(),
folly::to<std::string>(prefix_, suffix_++));
return thread;
}
void setNamePrefix(folly::StringPiece prefix) {
prefix_ = prefix.str();
}
std::string getNamePrefix() {
return prefix_;
}
private:
std::string prefix_;
std::atomic<uint64_t> suffix_;
};
} // namespace wangle
|
Remove import `UIKit` from header file | //
// ImageLoader.h
// ImageLoader
//
// Created by Hirohisa Kawasaki on 10/16/14.
// Copyright (c) 2014 Hirohisa Kawasaki. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT double ImageLoaderVersionNumber;
FOUNDATION_EXPORT const unsigned char ImageLoaderVersionString[];
| //
// ImageLoader.h
// ImageLoader
//
// Created by Hirohisa Kawasaki on 10/16/14.
// Copyright (c) 2014 Hirohisa Kawasaki. All rights reserved.
//
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT double ImageLoaderVersionNumber;
FOUNDATION_EXPORT const unsigned char ImageLoaderVersionString[];
|
Add a comment with a 'TODO: add DCHECKS' for class Mutex | // Copyright (c) 2010 Timur Iskhodzhanov. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_MUTEX_H_
#define BASE_MUTEX_H_
#include <pthread.h>
#include "base/common.h"
namespace threading {
class Mutex {
public:
Mutex();
~Mutex();
void Lock();
/*!
Attempts to lock the mutex. If the lock was obtained, this function
returns true. If another thread has locked the mutex, this
function returns false immediately.
If the lock was obtained, the mutex must be unlocked with Unlock()
before another thread can successfully lock it.
*/
bool TryLock();
void Unlock();
private:
pthread_mutex_t mutex_;
DISALLOW_COPY_AND_ASSIGN(Mutex)
};
// A helper class that acquires the given Mutex while the MutexLock is in scope
class MutexLock {
public:
explicit MutexLock(Mutex *m): mutex_(m) {
CHECK(mutex_ != NULL);
mutex_->Lock();
}
~MutexLock() {
mutex_->Unlock();
}
private:
Mutex * const mutex_;
DISALLOW_COPY_AND_ASSIGN(MutexLock)
};
} // namespace threading
#endif // BASE_MUTEX_H_
| // Copyright (c) 2010 Timur Iskhodzhanov. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_MUTEX_H_
#define BASE_MUTEX_H_
#include <pthread.h>
#include "base/common.h"
namespace threading {
// OS-independent wrapper for mutex/critical section synchronization primitive.
// This Mutex is NOT re-entrant!
//
// TODO(DimanNe): add DCHECKs for
// * locking a Mutex twice from the same thread,
// * unlocking a Mutex which is not locked,
// * destroying a locked Mutex.
class Mutex {
public:
Mutex();
~Mutex();
void Lock();
/*!
Attempts to lock the mutex. If the lock was obtained, this function
returns true. If another thread has locked the mutex, this
function returns false immediately.
If the lock was obtained, the mutex must be unlocked with Unlock()
before another thread can successfully lock it.
*/
bool TryLock();
void Unlock();
private:
pthread_mutex_t mutex_;
DISALLOW_COPY_AND_ASSIGN(Mutex)
};
// A helper class that acquires the given Mutex while the MutexLock is in scope
class MutexLock {
public:
explicit MutexLock(Mutex *m): mutex_(m) {
CHECK(mutex_ != NULL);
mutex_->Lock();
}
~MutexLock() {
mutex_->Unlock();
}
private:
Mutex * const mutex_;
DISALLOW_COPY_AND_ASSIGN(MutexLock)
};
} // namespace threading
#endif // BASE_MUTEX_H_
|
Use constant time zero check function | /*
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2016 Cryptography Research, Inc.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*
* Originally written by Mike Hamburg
*/
#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
# define OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
# define ARCH_WORD_BITS 64
static ossl_inline uint64_t word_is_zero(uint64_t a)
{
/* let's hope the compiler isn't clever enough to optimize this. */
return (((__uint128_t) a) - 1) >> 64;
}
static ossl_inline uint128_t widemul(uint64_t a, uint64_t b)
{
return ((uint128_t) a) * b;
}
#endif /* OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H */
| /*
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2016 Cryptography Research, Inc.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*
* Originally written by Mike Hamburg
*/
#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
# define OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
# include "internal/constant_time.h"
# define ARCH_WORD_BITS 64
# define word_is_zero(a) constant_time_is_zero_64(a)
static ossl_inline uint128_t widemul(uint64_t a, uint64_t b)
{
return ((uint128_t) a) * b;
}
#endif /* OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H */
|
Include stdlib.h or declare getenv | #include "Python.h"
#include "osdefs.h"
#ifndef PYTHONPATH
#define PYTHONPATH ".:/usr/local/lib/python"
#endif
/* Return the initial python search path. This is called once from
initsys() to initialize sys.path. The environment variable
PYTHONPATH is fetched and the default path appended. The default
path may be passed to the preprocessor; if not, a system-dependent
default is used. */
char *
getpythonpath()
{
char *path = getenv("PYTHONPATH");
char *defpath = PYTHONPATH;
static char *buf = NULL;
char *p;
int n;
if (path == NULL)
path = "";
n = strlen(path) + strlen(defpath) + 2;
if (buf != NULL) {
free(buf);
buf = NULL;
}
buf = malloc(n);
if (buf == NULL)
Py_FatalError("not enough memory to copy module search path");
strcpy(buf, path);
p = buf + strlen(buf);
if (p != buf)
*p++ = DELIM;
strcpy(p, defpath);
return buf;
}
| #include "Python.h"
#include "osdefs.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#else
extern char *getenv Py_PROTO((const char *));
#endif
#ifndef PYTHONPATH
#define PYTHONPATH ".:/usr/local/lib/python"
#endif
/* Return the initial python search path. This is called once from
initsys() to initialize sys.path. The environment variable
PYTHONPATH is fetched and the default path appended. The default
path may be passed to the preprocessor; if not, a system-dependent
default is used. */
char *
getpythonpath()
{
char *path = getenv("PYTHONPATH");
char *defpath = PYTHONPATH;
static char *buf = NULL;
char *p;
int n;
if (path == NULL)
path = "";
n = strlen(path) + strlen(defpath) + 2;
if (buf != NULL) {
free(buf);
buf = NULL;
}
buf = malloc(n);
if (buf == NULL)
Py_FatalError("not enough memory to copy module search path");
strcpy(buf, path);
p = buf + strlen(buf);
if (p != buf)
*p++ = DELIM;
strcpy(p, defpath);
return buf;
}
|
Use forward declarations to speed up compilation | //
// Created by david on 2019-03-18.
//
#pragma once
#include <general/eigen_tensor_fwd_decl.h>
class class_state_finite;
class class_model_finite;
class class_edges_finite;
class class_tensors_finite;
class class_algorithm_status;
class class_tic_toc;
enum class OptSpace;
enum class OptType;
enum class OptMode;
enum class StateRitz;
namespace tools::finite::opt {
class opt_mps;
using Scalar = std::complex<double>;
extern opt_mps find_excited_state(const class_tensors_finite &tensors, const opt_mps &initial_mps, const class_algorithm_status &status,
OptMode optMode, OptSpace optSpace, OptType optType);
extern opt_mps find_excited_state(const class_tensors_finite &tensors, const class_algorithm_status &status, OptMode optMode, OptSpace optSpace,
OptType optType);
extern Eigen::Tensor<Scalar, 3> find_ground_state(const class_tensors_finite &tensors, StateRitz ritz);
}
| //
// Created by david on 2019-03-18.
//
#pragma once
#include <general/eigen_tensor_fwd_decl.h>
class class_state_finite;
class class_model_finite;
class class_edges_finite;
class class_tensors_finite;
class class_algorithm_status;
class class_tic_toc;
namespace eig {class solver;}
enum class OptSpace;
enum class OptType;
enum class OptMode;
enum class StateRitz;
namespace tools::finite::opt {
class opt_mps;
using Scalar = std::complex<double>;
using real = double;
using cplx = std::complex<double>;
extern void extract_solutions(const opt_mps &initial_mps,const class_tensors_finite &tensors, eig::solver &solver, std::vector<tools::finite::opt::opt_mps> &eigvecs_mps, const std::string & tag = "");
extern opt_mps find_excited_state(const class_tensors_finite &tensors, const opt_mps &initial_mps, const class_algorithm_status &status,
OptMode optMode, OptSpace optSpace, OptType optType);
extern opt_mps find_excited_state(const class_tensors_finite &tensors, const class_algorithm_status &status, OptMode optMode, OptSpace optSpace,
OptType optType);
extern Eigen::Tensor<Scalar, 3> find_ground_state(const class_tensors_finite &tensors, StateRitz ritz);
}
|
Remove unneeded declarations and headers. | /*
* antifreeze.h
* StatusSpec project
*
* Copyright (c) 2014-2015 Forward Command Post
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#pragma once
#include "cdll_int.h"
#include "vgui/VGUI.h"
#include "../modules.h"
class ConCommand;
class ConVar;
class IConVar;
class KeyValues;
namespace vgui {
class EditablePanel;
};
class AntiFreeze : public Module {
public:
AntiFreeze(std::string name);
static bool CheckDependencies(std::string name);
private:
class DisplayPanel;
class RefreshPanel;
DisplayPanel *displayPanel;
RefreshPanel *refreshPanel;
ConVar *display;
ConCommand *display_reload_settings;
ConVar *display_threshold;
ConVar *enabled;
void ChangeDisplayThreshold(IConVar *var, const char *pOldValue, float flOldValue);
void ReloadSettings();
void ToggleDisplay(IConVar *var, const char *pOldValue, float flOldValue);
void ToggleEnabled(IConVar *var, const char *pOldValue, float flOldValue);
}; | /*
* antifreeze.h
* StatusSpec project
*
* Copyright (c) 2014-2015 Forward Command Post
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#pragma once
#include "../modules.h"
class ConCommand;
class ConVar;
class IConVar;
class AntiFreeze : public Module {
public:
AntiFreeze(std::string name);
static bool CheckDependencies(std::string name);
private:
class DisplayPanel;
class RefreshPanel;
DisplayPanel *displayPanel;
RefreshPanel *refreshPanel;
ConVar *display;
ConCommand *display_reload_settings;
ConVar *display_threshold;
ConVar *enabled;
void ChangeDisplayThreshold(IConVar *var, const char *pOldValue, float flOldValue);
void ReloadSettings();
void ToggleDisplay(IConVar *var, const char *pOldValue, float flOldValue);
void ToggleEnabled(IConVar *var, const char *pOldValue, float flOldValue);
}; |
Build number increased to 3. | /* Begin CVS Header
$Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/copasiversion.h,v $
$Revision: 1.3 $
$Name: $
$Author: shoops $
$Date: 2004/02/19 03:28:58 $
End CVS Header */
#ifndef COPASI_VERSION
#define COPASI_VERSION
#define COPASI_VERSION_MAJOR 4
#define COPASI_VERSION_MINOR 0
#define COPASI_VERSION_BUILD 2
#endif // COPASI_VERSION
| /* Begin CVS Header
$Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/copasiversion.h,v $
$Revision: 1.4 $
$Name: $
$Author: shoops $
$Date: 2004/02/20 18:15:46 $
End CVS Header */
#ifndef COPASI_VERSION
#define COPASI_VERSION
#define COPASI_VERSION_MAJOR 4
#define COPASI_VERSION_MINOR 0
#define COPASI_VERSION_BUILD 3
#endif // COPASI_VERSION
|
Check dir have to be done | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* testpath.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sle-guil <sle-guil@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/03/11 16:25:34 by sle-guil #+# #+# */
/* Updated: 2015/03/11 16:48:51 by sle-guil ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int testpath(char *path)
{
int ret;
ft_putendl("boobs");
ret = (access(path, F_OK)) ? 1 : 0;
ret += (access(path, R_OK)) ? 2 : 0;
ret += (access(path, W_OK)) ? 4 : 0;
ret += (access(path, X_OK)) ? 8 : 0;
return (ret);
}
| /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* testpath.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sle-guil <sle-guil@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/03/11 16:25:34 by sle-guil #+# #+# */
/* Updated: 2015/03/12 16:00:13 by sle-guil ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int testpath(char const *path)
{
int ret;
ret = (access(path, F_OK) != -1) ? 1 : 0;
ret += (access(path, X_OK) != -1) ? 8 : 0;
return (ret);
}
|
Remove irrelevant comments borrowed from loongson. | /* $OpenBSD: param.h,v 1.2 2010/10/11 15:51:06 syuu Exp $ */
/* public domain */
#ifndef _MACHINE_PARAM_H_
#define _MACHINE_PARAM_H_
#define MACHINE "octeon"
#define _MACHINE octeon
#define MACHINE_ARCH "mips64"
#define _MACHINE_ARCH mips64
/* not the canonical endianness */
#define MACHINE_CPU "mips64"
#define _MACHINE_CPU mips64
#define MID_MACHINE MID_MIPS64
/*
* The Loongson level 1 cache expects software to prevent virtual
* aliases. Unfortunately, since this cache is physically tagged,
* this would require all virtual address to have the same bits 14
* and 13 as their physical addresses, which is not something the
* kernel can guarantee unless the page size is at least 16KB.
*/
#define PAGE_SHIFT 14
#include <mips64/param.h>
#endif /* _MACHINE_PARAM_H_ */
| /* $OpenBSD: param.h,v 1.3 2011/06/25 19:38:47 miod Exp $ */
/* public domain */
#ifndef _MACHINE_PARAM_H_
#define _MACHINE_PARAM_H_
#define MACHINE "octeon"
#define _MACHINE octeon
#define MACHINE_ARCH "mips64"
#define _MACHINE_ARCH mips64
#define MID_MACHINE MID_MIPS64
#define PAGE_SHIFT 14
#include <mips64/param.h>
#endif /* _MACHINE_PARAM_H_ */
|
Add virtual to methods that get overridden. | /*===- ConfinementForce.h - libSimulation -=====================================
*
* DEMON
*
* This file is distributed under the BSD Open Source License. See LICENSE.TXT
* for details.
*
*===-----------------------------------------------------------------------===*/
#ifndef CONFINEMENTFORCE_H
#define CONFINEMENTFORCE_H
#include "Force.h"
class ConfinementForce : public Force {
public:
ConfinementForce(Cloud * const C, double confineConst)
: Force(C), confine(confineConst) {}
// IMPORTANT: In the above constructor, confineConst must be positive!
~ConfinementForce() {}
void force1(const double currentTime); // rk substep 1
void force2(const double currentTime); // rk substep 2
void force3(const double currentTime); // rk substep 3
void force4(const double currentTime); // rk substep 4
void writeForce(fitsfile * const file, int * const error) const;
void readForce(fitsfile * const file, int * const error);
private:
double confine; // [V/m^2]
void force(const cloud_index currentParticle, const __m128d currentPositionX, const __m128d currentPositionY);
};
#endif // CONFINEMENTFORCE_H
| /*===- ConfinementForce.h - libSimulation -=====================================
*
* DEMON
*
* This file is distributed under the BSD Open Source License. See LICENSE.TXT
* for details.
*
*===-----------------------------------------------------------------------===*/
#ifndef CONFINEMENTFORCE_H
#define CONFINEMENTFORCE_H
#include "Force.h"
class ConfinementForce : public Force {
public:
ConfinementForce(Cloud * const C, double confineConst)
: Force(C), confine(confineConst) {}
// IMPORTANT: In the above constructor, confineConst must be positive!
~ConfinementForce() {}
virtual void force1(const double currentTime); // rk substep 1
virtual void force2(const double currentTime); // rk substep 2
virtual void force3(const double currentTime); // rk substep 3
virtual void force4(const double currentTime); // rk substep 4
virtual void writeForce(fitsfile * const file, int * const error) const;
virtual void readForce(fitsfile * const file, int * const error);
private:
double confine; // [V/m^2]
void force(const cloud_index currentParticle, const __m128d currentPositionX, const __m128d currentPositionY);
};
#endif // CONFINEMENTFORCE_H
|
Convert assembler to use getopt for arguments | //
// main.c
// d16-asm
//
// Created by Michael Nolan on 6/17/16.
// Copyright © 2016 Michael Nolan. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include "parser.h"
#include "assembler.h"
#include <string.h>
#include "instruction.h"
extern int yyparse (FILE* output_file);
extern FILE* yyin;
extern int yydebug;
int main(int argc, const char * argv[]) {
if(argc != 3){
fprintf(stderr, "Usage d16-asm [file] [output]\n");
exit(-1);
}
FILE* f = fopen(argv[1], "r");
FILE* o = fopen(argv[2], "wb");
if(f == NULL){
fprintf(stderr, "Error opening file %s\n",argv[1]);
exit(-1);
}
if(o == NULL){
fprintf(stderr, "Error opening file %s for writing\n",argv[2]);
exit(2);
}
yyin = f;
init_hash_table();
do {
yyparse(o);
} while (!feof(yyin));
fclose(f);
fclose(o);
return 0;
}
| //
// main.c
// d16-asm
//
// Created by Michael Nolan on 6/17/16.
// Copyright © 2016 Michael Nolan. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include "parser.h"
#include "assembler.h"
#include <string.h>
#include "instruction.h"
#include <unistd.h>
extern int yyparse (FILE* output_file);
extern FILE* yyin;
extern int yydebug;
int main(int argc, char * const argv[]) {
FILE *f,*o;
opterr = 0;
int c;
while ((c=getopt(argc,argv,"o:")) != -1){
switch(c){
case 'o':
o = fopen(optarg,"wb");
}
}
if(optind<argc) f = fopen(argv[optind],"r");
else{
fprintf(stderr,"d16: No input files specified\n");
exit(-1);
}
if(o==NULL){
o=fopen("a.out","wb");
}
yyin = f;
init_hash_table();
do {
yyparse(o);
} while (!feof(yyin));
fclose(f);
fclose(o);
return 0;
}
|
Disable SSE41 kernel on 32bit, we don't use intrinsics here anyway. Also disable it for Visual Studio < 2012, broken blendv instruction. | /*
* Copyright 2011-2013 Blender Foundation
*
* 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
*/
#if defined(__x86_64__) || defined(_M_X64)
/* no SSE2 kernel on x86-64, part of regular kernel */
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
#endif
#if defined(i386) || defined(_M_IX86)
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
#endif
| /*
* Copyright 2011-2013 Blender Foundation
*
* 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
*/
#if defined(__x86_64__) || defined(_M_X64)
/* no SSE2 kernel on x86-64, part of regular kernel */
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
/* VC2008 is not ready for sse41, probably broken blendv intrinsic... */
#if defined(_MSC_VER) && (_MSC_VER < 1700)
#undef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
#endif
#endif
#if defined(i386) || defined(_M_IX86)
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#endif
|
Add solution to Exercise 1-8. | /* Write a program to count blanks, tabs, and newlines. */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
uint32_t blank_count, tab_count, newline_count;
int16_t character;
blank_count = tab_count = newline_count = 0;
while ((character = getchar()) != EOF) {
switch (character) {
case ' ':
blank_count++;
break;
case '\t':
tab_count++;
break;
case '\n':
newline_count++;
break;
}
}
printf("Number of blanks: %d\n", blank_count);
printf("Number of tabs: %d\n", tab_count);
printf("Number of newlines: %d\n", newline_count);
return EXIT_SUCCESS;
}
| |
Fix bug in add, copy size. | #include "packet_queue.h"
#include "error.h"
#include "radio.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
uint32_t packet_queue_init(packet_queue_t * queue)
{
queue->head = 0;
queue->tail = 0;
return SUCCESS;
}
bool packet_queue_is_empty(packet_queue_t * queue)
{
return queue->head == queue->tail;
}
bool packet_queue_is_full(packet_queue_t * queue)
{
return abs(queue->head - queue->tail) == PACKET_QUEUE_SIZE;
}
uint32_t packet_queue_add(packet_queue_t * queue, radio_packet_t * packet)
{
if (packet_queue_is_full(queue))
return NO_MEMORY;
memcpy(&queue->packets[0], packet, sizeof(packet));
queue->tail++;
return SUCCESS;
}
uint32_t packet_queue_get(packet_queue_t * queue, radio_packet_t ** packet)
{
if (packet_queue_is_empty(queue))
return NOT_FOUND;
*packet = &queue->packets[queue->head];
queue->head++;
return SUCCESS;
}
| #include "packet_queue.h"
#include "error.h"
#include "radio.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
uint32_t packet_queue_init(packet_queue_t * queue)
{
queue->head = 0;
queue->tail = 0;
return SUCCESS;
}
bool packet_queue_is_empty(packet_queue_t * queue)
{
return queue->head == queue->tail;
}
bool packet_queue_is_full(packet_queue_t * queue)
{
return abs(queue->head - queue->tail) == PACKET_QUEUE_SIZE;
}
uint32_t packet_queue_add(packet_queue_t * queue, radio_packet_t * packet)
{
if (packet_queue_is_full(queue))
return NO_MEMORY;
memcpy(&queue->packets[0], packet, sizeof(*packet));
queue->tail++;
return SUCCESS;
}
uint32_t packet_queue_get(packet_queue_t * queue, radio_packet_t ** packet)
{
if (packet_queue_is_empty(queue))
return NOT_FOUND;
*packet = &queue->packets[queue->head];
queue->head++;
return SUCCESS;
}
|
Add ignored example from traces paper | // PARAM: --enable ana.int.interval --sets exp.solver.td3.side_widen cycle_self
#include <pthread.h>
#include <assert.h>
int g = 6;
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
int x = 1;
pthread_mutex_lock(&A);
assert(g == 6);
assert(x == 1);
g = 5;
assert(g == 5);
assert(x == 1);
pthread_mutex_lock(&B);
assert(g == 5);
assert(x == 1);
pthread_mutex_unlock(&B);
assert(g == 5);
assert(x == 1);
x = g;
assert(x == 5);
g = x + 1;
assert(g == 6);
x = g; // added
assert(g == 6); // added
assert(x == 6); // added
pthread_mutex_unlock(&A);
assert(x == 6); // modified
return NULL;
}
int main(void) {
pthread_t id;
assert(g == 6);
pthread_create(&id, NULL, t_fun, NULL);
assert(5 <= g);
assert(g <= 6);
pthread_join(id, NULL);
return 0;
}
| |
Clarify what types are used where | typedef enum json_type {
JSON_HASH, JSON_ARRAY, JSON_NUMBER, JSON_STRING, JSON_TRUE, JSON_FALSE, JSON_NULL,
JSON_COMMA, JSON_COLON, JSON_ITEM, JSON_KEY, JSON_VALUE,
} json_type;
typedef struct json_object {
json_type type;
struct json_object *parent;
char *string;
double number;
struct json_object **array;
struct json_object **keys;
struct json_object **values;
int length;
int expect;
} json_object;
struct json_pull {
json_object *root;
char *error;
int (*read)(struct json_pull *);
int (*peek)(struct json_pull *);
void *source;
int line;
json_object *container;
};
typedef struct json_pull json_pull;
typedef void (*json_separator_callback)(json_type type, json_pull *j, void *state);
json_pull *json_begin_file(FILE *f);
json_pull *json_begin_string(char *s);
json_object *json_parse(json_pull *j);
json_object *json_parse_with_separators(json_pull *j, json_separator_callback cb, void *state);
void json_free(json_object *j);
json_object *json_hash_get(json_object *o, char *s);
| typedef enum json_type {
// These types can be returned by json_parse()
JSON_HASH, JSON_ARRAY, JSON_NUMBER, JSON_STRING, JSON_TRUE, JSON_FALSE, JSON_NULL,
// These and JSON_HASH and JSON_ARRAY can be called back by json_parse_with_separators()
JSON_COMMA, JSON_COLON,
// These are only used internally as expectations of what comes next
JSON_ITEM, JSON_KEY, JSON_VALUE,
} json_type;
typedef struct json_object {
json_type type;
struct json_object *parent;
char *string;
double number;
struct json_object **array;
struct json_object **keys;
struct json_object **values;
int length;
int expect;
} json_object;
struct json_pull {
json_object *root;
char *error;
int (*read)(struct json_pull *);
int (*peek)(struct json_pull *);
void *source;
int line;
json_object *container;
};
typedef struct json_pull json_pull;
typedef void (*json_separator_callback)(json_type type, json_pull *j, void *state);
json_pull *json_begin_file(FILE *f);
json_pull *json_begin_string(char *s);
json_object *json_parse(json_pull *j);
json_object *json_parse_with_separators(json_pull *j, json_separator_callback cb, void *state);
void json_free(json_object *j);
json_object *json_hash_get(json_object *o, char *s);
|
Remove unnecessary state variable adr_ prefixes | #ifndef __ADR_MAIN_H__
#define __ADR_MAIN_H__
// Libraries //
#include "craftable.h"
#include "resource.h"
#include "villager.h"
#include "location.h"
// Forward Declarations //
struct adr_state {
enum LOCATION adr_loc;
enum FIRE_STATE adr_fire;
enum ROOM_TEMP adr_temp;
unsigned int adr_rs [ALIEN_ALLOY + 1];
unsigned short adr_cs [RIFLE + 1];
unsigned short adr_vs [MUNITIONIST + 1];
};
#endif // __ADR_MAIN_H__
// vim: set ts=4 sw=4 et:
| #ifndef __ADR_MAIN_H__
#define __ADR_MAIN_H__
// Libraries //
#include "craftable.h"
#include "resource.h"
#include "villager.h"
#include "location.h"
// Forward Declarations //
struct adr_state {
enum LOCATION loc;
enum FIRE_STATE fire;
enum ROOM_TEMP temp;
unsigned int rs [ALIEN_ALLOY + 1];
unsigned short cs [RIFLE + 1];
unsigned short vs [MUNITIONIST + 1];
};
#endif // __ADR_MAIN_H__
// vim: set ts=4 sw=4 et:
|
Make frontend floating-point commutivity test X86 specific to avoid cost-model related problems on arm-thumb and hexagon. | // RUN: %clang -O1 -fvectorize -Rpass-analysis=loop-vectorize -emit-llvm -S %s -o - 2>&1 | FileCheck %s
// CHECK: {{.*}}:9:11: remark: loop not vectorized: vectorization requires changes in the order of operations, however IEEE 754 floating-point operations are not commutative; allow commutativity by specifying '#pragma clang loop vectorize(enable)' before the loop or by providing the compiler option '-ffast-math'
double foo(int N) {
double v = 0.0;
for (int i = 0; i < N; i++)
v = v + 1.0;
return v;
}
| // RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown -Rpass-analysis=loop-vectorize -emit-llvm -S %s -o - 2>&1 | FileCheck %s
// CHECK: {{.*}}:9:11: remark: loop not vectorized: vectorization requires changes in the order of operations, however IEEE 754 floating-point operations are not commutative; allow commutativity by specifying '#pragma clang loop vectorize(enable)' before the loop or by providing the compiler option '-ffast-math'
double foo(int N) {
double v = 0.0;
for (int i = 0; i < N; i++)
v = v + 1.0;
return v;
}
|
Add printf __attribute__ to log function. | // Copyright 2015 Ben Trask
// MIT licensed (see LICENSE for details)
#include <stdarg.h>
char *vaasprintf(char const *const fmt, va_list ap);
char *aasprintf(char const *const fmt, ...) __attribute__((format(printf, 1, 2)));
int time_iso8601(char *const out, size_t const max);
void valogf(char const *const fmt, va_list ap);
void alogf(char const *const fmt, ...);
| // Copyright 2015 Ben Trask
// MIT licensed (see LICENSE for details)
#include <stdarg.h>
char *vaasprintf(char const *const fmt, va_list ap);
char *aasprintf(char const *const fmt, ...) __attribute__((format(printf, 1, 2)));
int time_iso8601(char *const out, size_t const max);
void valogf(char const *const fmt, va_list ap);
void alogf(char const *const fmt, ...) __attribute__((format(printf, 1, 2)));
|
Add missing autocleanup for GInitiallyUnowned | /*
* Copyright © 2015 Canonical Limited
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the licence, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset)
| /*
* Copyright © 2015 Canonical Limited
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the licence, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset)
|
Add prototype of non public API of MRI. | #ifndef RUBYSPEC_CAPI_MRI_H
#define RUBYSPEC_CAPI_MRI_H
/* #undef any HAVE_ defines that MRI does not have. */
#undef HAVE_RB_HASH_LOOKUP
#undef HAVE_RB_HASH_SIZE
#undef HAVE_RB_OBJ_FROZEN_P
#undef HAVE_RB_STR_PTR
#undef HAVE_RB_STR_PTR_READONLY
#undef HAVE_THREAD_BLOCKING_REGION
#ifdef RUBY_VERSION_IS_1_9
#undef HAVE_RARRAY
#undef HAVE_RFLOAT
#undef HAVE_RSTRING
#undef HAVE_STR2CSTR
#undef HAVE_RB_STR2CSTR
#undef HAVE_RB_CVAR_SET
#undef HAVE_RB_SET_KCODE
#endif
/* Macros that may not be defined in old versions */
#ifndef RARRAY_PTR
#define RARRAY_PTR(s) (*(VALUE *const *)&RARRAY(s)->ptr)
#endif
#ifndef RARRAY_LEN
#define RARRAY_LEN(s) (*(const long *)&RARRAY(s)->len)
#endif
#ifndef RFLOAT_VALUE
#define RFLOAT_VALUE(v) (RFLOAT(v)->value)
#endif
#endif
| #ifndef RUBYSPEC_CAPI_MRI_H
#define RUBYSPEC_CAPI_MRI_H
/* #undef any HAVE_ defines that MRI does not have. */
#undef HAVE_RB_HASH_LOOKUP
#undef HAVE_RB_HASH_SIZE
#undef HAVE_RB_OBJ_FROZEN_P
#undef HAVE_RB_STR_PTR
#undef HAVE_RB_STR_PTR_READONLY
#undef HAVE_THREAD_BLOCKING_REGION
#ifdef RUBY_VERSION_IS_1_9
#undef HAVE_RARRAY
#undef HAVE_RFLOAT
#undef HAVE_RSTRING
#undef HAVE_STR2CSTR
#undef HAVE_RB_STR2CSTR
#undef HAVE_RB_CVAR_SET
#undef HAVE_RB_SET_KCODE
#endif
/* RubySpec assumes following are public API */
#ifndef rb_proc_new
VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
#endif
#ifndef rb_str_len
int rb_str_len(VALUE);
#endif
#ifndef rb_set_errinfo
void rb_set_errinfo(VALUE);
#endif
/* Macros that may not be defined in old versions */
#ifndef RARRAY_PTR
#define RARRAY_PTR(s) (*(VALUE *const *)&RARRAY(s)->ptr)
#endif
#ifndef RARRAY_LEN
#define RARRAY_LEN(s) (*(const long *)&RARRAY(s)->len)
#endif
#ifndef RFLOAT_VALUE
#define RFLOAT_VALUE(v) (RFLOAT(v)->value)
#endif
#endif
|
Add prototype to read .a files | //===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ----*- C++ -*--=//
//
// This functionality is implemented by the lib/Bytecode/Reader library.
// This library is used to read VM bytecode files from an iostream.
//
// Note that performance of this library is _crucial_ for performance of the
// JIT type applications, so we have designed the bytecode format to support
// quick reading.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_BYTECODE_READER_H
#define LLVM_BYTECODE_READER_H
#include <string>
class Module;
// Parse and return a class...
//
Module *ParseBytecodeFile(const std::string &Filename,
std::string *ErrorStr = 0);
Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned BufferSize,
std::string *ErrorStr = 0);
#endif
| //===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ----*- C++ -*--=//
//
// This functionality is implemented by the lib/Bytecode/Reader library.
// This library is used to read VM bytecode files from an iostream.
//
// Note that performance of this library is _crucial_ for performance of the
// JIT type applications, so we have designed the bytecode format to support
// quick reading.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_BYTECODE_READER_H
#define LLVM_BYTECODE_READER_H
#include <string>
#include <vector>
class Module;
// Parse and return a class...
//
Module *ParseBytecodeFile(const std::string &Filename,
std::string *ErrorStr = 0);
Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned BufferSize,
std::string *ErrorStr = 0);
// ReadArchiveFile - Read bytecode files from the specfied .a file, returning
// true on error, or false on success.
//
bool ReadArchiveFile(const std::string &Filename, std::vector<Module*> &Objects,
std::string *ErrorStr = 0);
#endif
|
Mark init as being unavailable. | //
// SWXSLTransform.h
// This file is part of the "SWXMLMapping" project, and is distributed under the MIT License.
//
// Created by Samuel Williams on 23/02/12.
// Copyright (c) 2012 Samuel Williams. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SWXSLTransform : NSObject {
NSURL * _baseURL;
void * _stylesheet;
}
/// The base URL that was used to load the stylesheet:
@property(nonatomic,strong) NSURL * baseURL;
/// Initialize the XSL stylesheet from the given URL:
- (instancetype) initWithURL:(NSURL *)url NS_DESIGNATED_INITIALIZER;
/// Use the XSL stylesheet to process a string containing XML with a set of arguments.
/// Arguments are typically evaluated by the XSLT processor, so, for example, strings must be passed with an additional set of quotes.
- (NSData *) processDocument:(NSString *)xmlBuffer arguments:(NSDictionary *)arguments;
@end
| //
// SWXSLTransform.h
// This file is part of the "SWXMLMapping" project, and is distributed under the MIT License.
//
// Created by Samuel Williams on 23/02/12.
// Copyright (c) 2012 Samuel Williams. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SWXSLTransform : NSObject {
NSURL * _baseURL;
void * _stylesheet;
}
/// The base URL that was used to load the stylesheet:
@property(nonatomic,strong) NSURL * baseURL;
- (instancetype) init NS_UNAVAILABLE;
/// Initialize the XSL stylesheet from the given URL:
- (instancetype) initWithURL:(NSURL *)url NS_DESIGNATED_INITIALIZER;
/// Use the XSL stylesheet to process a string containing XML with a set of arguments.
/// Arguments are typically evaluated by the XSLT processor, so, for example, strings must be passed with an additional set of quotes.
- (NSData *) processDocument:(NSString *)xmlBuffer arguments:(NSDictionary *)arguments;
@end
|
Enable to treat with std::cout and std::cin | /*!
* @brief Template C++-header file
*
* This is a template C++-header file
* @author <+AUTHOR+>
* @date <+DATE+>
* @file <+FILE+>
* @version 0.1
*/
#ifndef <+FILE_CAPITAL+>_H
#define <+FILE_CAPITAL+>_H
/*!
* @brief Template class
*/
class <+FILEBASE+>
{
private:
public:
<+FILEBASE+>() {
<+CURSOR+>
}
}; // class <+FILEBASE+>
#endif // <+FILE_CAPITAL+>_H
| /*!
* @brief Template C++-header file
*
* This is a template C++-header file
* @author <+AUTHOR+>
* @date <+DATE+>
* @file <+FILE+>
* @version 0.1
*/
#ifndef <+FILE_CAPITAL+>_H
#define <+FILE_CAPITAL+>_H
#include <iostream>
/*!
* @brief Template class
*/
class <+FILE_PASCAL+>
{
private:
public:
<+FILEBASE+>() {
<+CURSOR+>
}
template<typename CharT, typename Traits>
friend std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const CoutTest& this_);
template<typename CharT, typename Traits>
friend std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, CoutTest& this_);
}; // class <+FILE_PASCAL+>
template<typename CharT, typename Traits>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const CoutTest& this_)
{
return os;
}
template<typename CharT, typename Traits>
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, CoutTest& this_)
{
return is;
}
#endif // <+FILE_CAPITAL+>_H
|
Use snprintf() instead of sprintf() | /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include "stack.h"
char *
stack_backtrace(void)
{
extern void *_text_start;
extern void *_text_end;
static char buf[1024];
uintptr_t fp;
uintptr_t pr;
int level;
/* Obtain address of the caller and its frame pointer before it
* is clobbered by any subsequent calls */
STACK_RET_ADDRESS(pr);
STACK_FPTR(fp);
level = 0;
*buf = '\0';
do {
(void)sprintf(buf, "%s #%i 0x%08X in ??? ()\n",
buf, level, (uintptr_t)pr);
pr = STACK_FPTR_RET_ADDRESS_GET(fp);
fp = STACK_FPTR_NEXT_GET(fp);
level++;
} while (((pr >= (uint32_t)&_text_start)) && (pr < ((uint32_t)&_text_end)));
return buf;
}
| /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include "stack.h"
char *
stack_backtrace(void)
{
extern void *_text_start;
extern void *_text_end;
static char buf[256];
uintptr_t fp;
uintptr_t pr;
int level;
/* Obtain address of the caller and its frame pointer before it
* is clobbered by any subsequent calls */
STACK_RET_ADDRESS(pr);
STACK_FPTR(fp);
level = 0;
*buf = '\0';
do {
(void)snprintf(buf, 256, "%s #%i 0x%08X in ??? ()\n",
buf, level, (uintptr_t)pr);
pr = STACK_FPTR_RET_ADDRESS_GET(fp);
fp = STACK_FPTR_NEXT_GET(fp);
level++;
} while (((pr >= (uint32_t)&_text_start)) && (pr < ((uint32_t)&_text_end)));
return buf;
}
|
Set MIDPOINT to 90 instead of 128 (servo lib goes from 0 to 180) | #ifndef __MOTORS_H_
#define __MOTORS_H_
#include <Servo.h>
#define MIDPOINT 128
class Motors {
private:
Servo port, vertical, starbord;
int port_pin, vertical_pin, starbord_pin;
public:
Motors(int p_pin, int v_pin, int s_pin);
void reset();
void go(int p, int v, int s);
void stop();
};
#endif
| #ifndef __MOTORS_H_
#define __MOTORS_H_
#include <Servo.h>
#define MIDPOINT 90
class Motors {
private:
Servo port, vertical, starbord;
int port_pin, vertical_pin, starbord_pin;
public:
Motors(int p_pin, int v_pin, int s_pin);
void reset();
void go(int p, int v, int s);
void stop();
};
#endif
|
Make it even simpler for a script to replace. | #ifndef ROOT_ROOTCoreTeam
#define ROOT_ROOTCoreTeam
namespace ROOT {
namespace ROOTX {
//This string will be updated by external script, reading names from http://root.cern.ch/gitstats/authors.html.
//The string has an internal linkage (it has a definition here, not in rootxx.cxx or rootx-cocoa.mm files.
//So this header can be included in different places (as soon as you know what you're doing).
//Please, do not modify this file.
//[STRINGTOREPLACE
const char * gROOTCoreTeam = "Andrei Gheata, Axel Naumann, Bertrand Bellenot, Cristina Cristescu,"
" Danilo Piparo, Fons Rademakers, Gerardo Ganis, Ilka Antcheva,"
" Lorenzo Moneta, Matevz Tadel, Olivier Couet, Paul Russo, Pere Mato,"
" Philippe Canal, Rene Brun, Timur Pocheptsov, Valeri Onuchin,"
" Vassil Vassilev, Wim Lavrijsen, Wouter Verkerke\n\n";
//STRINGTOREPLACE]
}
}
#endif | #ifndef ROOT_ROOTCoreTeam
#define ROOT_ROOTCoreTeam
namespace ROOT {
namespace ROOTX {
//This string will be updated by external script, reading names from http://root.cern.ch/gitstats/authors.html.
//The names are sorted in alphabetical order.
//The string has an internal linkage (it has a definition here, not in rootxx.cxx or rootx-cocoa.mm files.
//So this header can be included in different places (as soon as you know what you're doing).
//Please, do not modify this file.
const char * gROOTCoreTeam =
//[STRINGTOREPLACE
"Andrei Gheata, Axel Naumann, Bertrand Bellenot, Cristina Cristescu,"
" Danilo Piparo, Fons Rademakers, Gerardo Ganis, Ilka Antcheva,"
" Lorenzo Moneta, Matevz Tadel, Olivier Couet, Paul Russo, Pere Mato,"
" Philippe Canal, Rene Brun, Timur Pocheptsov, Valeri Onuchin,"
" Vassil Vassilev, Wim Lavrijsen, Wouter Verkerke.\n\n";
//STRINGTOREPLACE]
}
}
#endif |
Add test for string pointer analysis | #include <assert.h>
#include <stdlib.h>
int main(){
char* str = "Hello";
char* str2 = "Hello";
char* str3 = "hi";
char* str4 = "other string";
// Unknown since the there may be multiple copies of the same string
__goblint_check(str != str2); // UNKNOWN!
__goblint_check(str == str);
__goblint_check(str != str3);
char *ptr = NULL;
int top = rand();
if(top){
ptr = str2;
} else {
ptr = str3;
}
__goblint_check(*ptr == *str); //UNKNOWN
// This is unknwon due to only keeping one string pointer in abstract address sets
__goblint_check(*ptr == *str4); //UNKNOWN
return 0;
}
| |
Add proper return code to test software. | #include <stdio.h>
int main()
{
printf("Hello, world!\n");
}
| #include <stdio.h>
int main()
{
printf("Hello, world!\n");
return 0;
}
|
Add licenses to empty files. Change: 137204888 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
| |
Remove silly struct that's silly | #ifndef CALC_SCANNER_DEF_H_
#define CALC_SCANNER_DEF_H_
typedef union {
int int_value;
} YYSTYPE;
typedef struct {
int function;
int result;
YYSTYPE lhs;
YYSTYPE rhs;
} BinaryFunction;
class ParserState {
public:
int result;
int eval;
ParserState() : result(0) {
}
};
#endif // CALC_SCANNER_DEF_H_
| #ifndef CALC_SCANNER_DEF_H_
#define CALC_SCANNER_DEF_H_
typedef union {
int int_value;
} YYSTYPE;
class ParserState {
public:
int result;
int eval;
ParserState() : result(0) {
}
};
#endif // CALC_SCANNER_DEF_H_
|
Add ability to extract a single basic block into a new function. | //===-- Transform/Utils/FunctionUtils.h - Function Utils --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This family of functions perform manipulations on functions.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_UTILS_FUNCTION_H
#define LLVM_TRANSFORMS_UTILS_FUNCTION_H
namespace llvm {
class Function;
class Loop;
/// ExtractLoop - rip out a natural loop into a new function
///
Function* ExtractLoop(Loop *L);
}
#endif
| //===-- Transform/Utils/FunctionUtils.h - Function Utils --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This family of functions perform manipulations on functions.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_UTILS_FUNCTION_H
#define LLVM_TRANSFORMS_UTILS_FUNCTION_H
namespace llvm {
class Function;
class Loop;
/// ExtractLoop - rip out a natural loop into a new function
///
Function* ExtractLoop(Loop *L);
/// ExtractBasicBlock - rip out a basic block into a new function
///
Function* ExtractBasicBlock(BasicBlock *BB);
}
#endif
|
Fix rwsem constant bug leading to hangs. | /* rwsem-const.h: RW semaphore counter constants. */
#ifndef _SPARC64_RWSEM_CONST_H
#define _SPARC64_RWSEM_CONST_H
#define RWSEM_UNLOCKED_VALUE 0x00000000
#define RWSEM_ACTIVE_BIAS 0x00000001
#define RWSEM_ACTIVE_MASK 0x0000ffff
#define RWSEM_WAITING_BIAS 0xffff0000
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
#endif /* _SPARC64_RWSEM_CONST_H */
| /* rwsem-const.h: RW semaphore counter constants. */
#ifndef _SPARC64_RWSEM_CONST_H
#define _SPARC64_RWSEM_CONST_H
#define RWSEM_UNLOCKED_VALUE 0x00000000
#define RWSEM_ACTIVE_BIAS 0x00000001
#define RWSEM_ACTIVE_MASK 0x0000ffff
#define RWSEM_WAITING_BIAS (-0x00010000)
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
#endif /* _SPARC64_RWSEM_CONST_H */
|
Add initial support for register and register class representation. Obviously this is not done. | //===- CodeGenRegisters.h - Register and RegisterClass Info -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines structures to encapsulate information gleaned from the
// target register and register class definitions.
//
//===----------------------------------------------------------------------===//
#ifndef CODEGEN_REGISTERS_H
#define CODEGEN_REGISTERS_H
#include <string>
namespace llvm {
class Record;
/// CodeGenRegister - Represents a register definition.
struct CodeGenRegister {
Record *TheDef;
const std::string &getName() const;
CodeGenRegister(Record *R) : TheDef(R) {}
};
struct CodeGenRegisterClass {
};
}
#endif
| |
Add third_party/ prefix to ppapi include for checkdeps. | // 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_PLUGINS_PPB_PRIVATE_H_
#define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_
#include "ppapi/c/pp_var.h"
#define PPB_PRIVATE_INTERFACE "PPB_Private;1"
typedef enum _ppb_ResourceString {
PPB_RESOURCE_STRING_PDF_GET_PASSWORD = 0,
} PP_ResourceString;
typedef struct _ppb_Private {
// Returns a localized string.
PP_Var (*GetLocalizedString)(PP_ResourceString string_id);
} PPB_Private;
#endif // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_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_PLUGINS_PPB_PRIVATE_H_
#define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_
#include "third_party/ppapi/c/pp_var.h"
#define PPB_PRIVATE_INTERFACE "PPB_Private;1"
typedef enum _ppb_ResourceString {
PPB_RESOURCE_STRING_PDF_GET_PASSWORD = 0,
} PP_ResourceString;
typedef struct _ppb_Private {
// Returns a localized string.
PP_Var (*GetLocalizedString)(PP_ResourceString string_id);
} PPB_Private;
#endif // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_
|
Fix for downstream android webview | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
#define SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
typedef long int greg_t;
typedef unsigned long sigset_t;
typedef struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
struct sigcontext uc_mcontext;
sigset_t uc_sigmask;
/* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
int __not_used[32 - (sizeof (sigset_t) / sizeof (int))];
/* Last for extensibility. Eight byte aligned because some
coprocessors require eight byte alignment. */
unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
} ucontext_t;
#endif // SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
| // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
#define SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
#include <asm/sigcontext.h>
typedef long int greg_t;
typedef unsigned long sigset_t;
typedef struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
struct sigcontext uc_mcontext;
sigset_t uc_sigmask;
/* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
int __not_used[32 - (sizeof (sigset_t) / sizeof (int))];
/* Last for extensibility. Eight byte aligned because some
coprocessors require eight byte alignment. */
unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
} ucontext_t;
#endif // SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
|
Document that meta doesn't work. | /* Narcissus
* © 2015 David Given
* This file is redistributable under the terms of the two-clause BSD license;
* see COPYING in the distribution root for the full text.
*/
#ifndef DEVICES_H
#define DEVICES_H
#include <X11/Xlib.h>
struct button
{
int keycode;
uint32_t button;
};
struct chord
{
uint32_t buttons;
int keysym;
};
struct device
{
const char* name;
struct button* buttons;
struct chord* chords;
};
extern const struct device razer_nostromo;
extern const struct device* find_connected_device(Display* display, int* deviceid);
extern const struct device* find_device_by_name(const char* name);
extern void load_device(const struct device* device);
uint32_t keycode_to_button(int keysym);
int decode_chord(uint32_t buttons);
#define MODIFIER_MASK ((1<<24) - 1)
#define CTRL (1<<24)
#define ALT (1<<25)
#define META (1<<26)
#endif
| /* Narcissus
* © 2015 David Given
* This file is redistributable under the terms of the two-clause BSD license;
* see COPYING in the distribution root for the full text.
*/
#ifndef DEVICES_H
#define DEVICES_H
#include <X11/Xlib.h>
struct button
{
int keycode;
uint32_t button;
};
struct chord
{
uint32_t buttons;
int keysym;
};
struct device
{
const char* name;
struct button* buttons;
struct chord* chords;
};
extern const struct device razer_nostromo;
extern const struct device* find_connected_device(Display* display, int* deviceid);
extern const struct device* find_device_by_name(const char* name);
extern void load_device(const struct device* device);
uint32_t keycode_to_button(int keysym);
int decode_chord(uint32_t buttons);
#define MODIFIER_MASK ((1<<24) - 1)
#define CTRL (1<<24)
#define ALT (1<<25)
/* Note: META doesn't work with libfakekey 0.1-8.1 */
#define META (1<<26)
#endif
|
Add generic definitions for LEDs and switches | /*
* Copyright (c) 2016, Texas Instruments Incorporated
*
* 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 __INC_BOARD_H
#define __INC_BOARD_H
#endif /* __INC_BOARD_H */
| /*
* Copyright (c) 2016, Texas Instruments Incorporated
*
* 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 __INC_BOARD_H
#define __INC_BOARD_H
/* Push button switch 2 */
#define SW2_GPIO_PIN 6 /* GPIO22/Pin15 */
#define SW2_GPIO_NAME "GPIO_A2"
/* Push button switch 3 */
#define SW3_GPIO_PIN 5 /* GPIO13/Pin4 */
#define SW3_GPIO_NAME "GPIO_A1"
/* Push button switch 0: Map to SW2 so zephyr button example works */
#define SW0_GPIO_PIN SW2_GPIO_PIN
#define SW0_GPIO_NAME SW2_GPIO_NAME
/* Onboard GREEN LED */
#define LED0_GPIO_PIN 3 /*GPIO11/Pin2 */
#define LED0_GPIO_PORT "GPIO_A1"
#endif /* __INC_BOARD_H */
|
Add a thread-safe socket class. | // -*- mode: c++ -*-
#ifndef _GET_DATA_CHUNK_SERVER_SOCKET_H_
#define _GET_DATA_CHUNK_SERVER_SOCKET_H_
#include <boost/shared_ptr.hpp>
#include <boost/asio.hpp>
class Socket
{
typedef boost::shared_ptr<boost::asio::ip::tcp::socket> SocketImplPtr;
public:
Socket(SocketImplPtr socket);
virtual ~Socket();
private:
SocketImplPtr m_socket;
};
#endif
| |
Fix typo in method signature | #include <stdio.h>
/* Interface to JPEG code */
#include "jpeglib.h"
#include <setjmp.h>
struct error_mgr2 {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct error_mgr2* error_ptr2;
void error_exit (j_common_ptr cinfo);
GLOBAL(void) jpeg_mem_src (j_decompress_ptr cinfo, char * pSourceData, unsigned sourceDataSize);
GLOBAL(int) jpeg_mem_src_newLocationOfData (j_decompress_ptr cinfo, char * pSourceData, unsigned sourceDataSize);
GLOBAL(void) jpeg_mem_dest (j_compress_ptr cinfo, char * pDestination, unsigned *pDestinationSize);
void primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines(
unsigned int,
unsigned int,
int,
unsigned int*,
char*,
char*,
int,
int,
unsigned int,
unsigned int,
char*,
unsigned int*);
void primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines(
char*,
char*,
char*,
unsigned int,
int,
unsigned int*,
unsigned int,
unsigned int,
int);
void primJPEGReadHeaderfromByteArraysizeerrorMgrReadHeader(
char*,
char*,
unsigned int);
char*);
| #include <stdio.h>
/* Interface to JPEG code */
#include "jpeglib.h"
#include <setjmp.h>
struct error_mgr2 {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct error_mgr2* error_ptr2;
void error_exit (j_common_ptr cinfo);
GLOBAL(void) jpeg_mem_src (j_decompress_ptr cinfo, char * pSourceData, unsigned sourceDataSize);
GLOBAL(int) jpeg_mem_src_newLocationOfData (j_decompress_ptr cinfo, char * pSourceData, unsigned sourceDataSize);
GLOBAL(void) jpeg_mem_dest (j_compress_ptr cinfo, char * pDestination, unsigned *pDestinationSize);
void primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines(
unsigned int,
unsigned int,
int,
unsigned int*,
char*,
char*,
int,
int,
unsigned int,
unsigned int,
char*,
unsigned int*);
void primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines(
char*,
char*,
char*,
unsigned int,
int,
unsigned int*,
unsigned int,
unsigned int,
int);
void primJPEGReadHeaderfromByteArraysizeerrorMgrReadHeader(
char*,
char*,
unsigned int,
char*);
|
Add test for nested expansion in macros |
/*
name: TEST028
description: Test of reinterpretation in define
output:
F5
G6 F5 foo
{
\
r "6869 'P
}
*/
#define M(x) x
#define A(a,b) a(b)
char *
foo(void)
{
return A(M,"hi");
}
| |
Fix random algo to evenly distribute. | #include <stdio.h>
#include <stdint.h>
#include "rand.h"
static uint64_t sqrt64(uint64_t n) {
uint64_t g = UINT64_C(1) << 31;
for (uint64_t c = g; c; g |= c) {
if (g * g > n) {
g ^= c;
}
c >>= 1;
}
return g;
}
static uint64_t get_split(uint64_t len) {
uint64_t rnd;
rand_fill(&rnd, sizeof(rnd));
rnd %= (len * len);
return sqrt64(rnd) + 1;
}
int main(int __attribute__ ((unused)) argc, char __attribute__ ((unused)) *argv[]) {
rand_init();
for (uint64_t len = 1397; len;) {
uint64_t consume = get_split(len);
fprintf(stderr, "consume %ju bytes\n", (uintmax_t) consume);
len -= consume;
}
rand_cleanup();
}
| #include <stdio.h>
#include <stdint.h>
#include "rand.h"
static uint64_t get_split(uint64_t total_len, uint64_t remaining_len) {
uint64_t rnd;
rand_fill(&rnd, sizeof(rnd));
rnd %= total_len;
return rnd > remaining_len ? remaining_len : rnd;
}
int main(int __attribute__ ((unused)) argc, char __attribute__ ((unused)) *argv[]) {
rand_init();
uint64_t total_len = 1397;
for (uint64_t remaining = total_len, consume = 0; remaining; remaining -= consume) {
consume = get_split(total_len, remaining);
fprintf(stderr, "consume %ju bytes\n", (uintmax_t) consume);
}
rand_cleanup();
}
|
Add basic test for integer constant folding |
/*
name: TEST019
description: Basic test of constant folding in integer arithmetic operations
output:
test019.c:13: warning: division by 0
test019.c:14: warning: division by 0
F1
G1 F1 main
{
-
A2 I i
A2 #I3 :I
A2 #I1 :I
A2 #I12 :I
A2 #I2 :I
A2 #I0 :I
A2 A2 #I0 %I :I
A2 A2 #I0 %I :I
A2 #I8 :I
A2 #I2 :I
A2 #I4 :I
A2 #IC :I
A2 #I8 :I
A2 #IFFFFFFFD :I
A2 #IFFFFFFF3 :I
A2 #I1 :I
A2 #I0 :I
A2 #I0 :I
A2 #I1 :I
A2 #I0 :I
}
*/
#line 1
int
main(void)
{
int i;
i = 1 + 2;
i = 2 - 1;
i = 3 * 6;
i = 10 / 5;
i = 10 % 5;
i = i % 0;
i = i % 0;
i = 1 << 3;
i = 8 >> 2;
i = 12 & 4;
i = 8 | 4;
i = 12 ^ 4;
i = -(3);
i = ~12;
i = 1 < 3;
i = 2 > 3;
i = 2 >= 3;
i = 2 <= 3;
i = 1 == 0;
}
| |
Add test for preprocessor corner cases | /*
name: TEST044
description: Test of corner cases in #if
output:
test044.c:14: warning: division by 0
test044.c:18: warning: division by 0
test044.c:22: warning: division by 0
test044.c:28: error: parameter of #if is not an integer constant expression
test044.c:29: error: #error 3 != (1,2,3)
*/
/* These should be accepted */
#if 0 != (0 && (0/0))
#error 0 != (0 && (0/0))
#endif
#if 1 != (-1 || (0/0))
#error 1 != (-1 || (0/0))
#endif
#if 3 != (-1 ? 3 : (0/0))
#error 3 != (-1 ? 3 : (0/0))
#endif
/* This is invalid code (it is a constraint violation) */
#if 3 != (1,2,3)
#error 3 != (1,2,3)
#endif
| |
Fix macro replacement: removal of conflict with __name_pool | /**
* @file
* @brief Internal implementation of static slab allocator
*
* @date 07.03.2011
* @author Kirill Tyushev
*/
#ifndef SLAB_STATIC_H_
# error "Do not include this file directly, use <kernel/mm/slab_static.h> instead!"
#endif /* SLAB_STATIC_H_ */
#include <util/binalign.h>
/** cache descriptor */
struct static_cache {
/** pointer to pool */
char* cache_begin;
/** object size */
size_t size;
/** the number of objects stored on each slab */
unsigned int num;
/** the list of free objects in pool */
struct list_head obj_ptr;
/** for initialization */
int hasinit;
};
/** create cache */
#define __STATIC_CACHE_CREATE(name, type, count) \
static char __name_pool[count * binalign_bound(sizeof(type), sizeof(struct list_head))]; \
static static_cache_t name = { \
.num = count, \
.size = binalign_bound(sizeof(type), sizeof(struct list_head)), \
.cache_begin = __name_pool, \
.obj_ptr = {NULL, NULL}, \
.hasinit = 0 }
| /**
* @file
* @brief Internal implementation of static slab allocator
*
* @date 07.03.2011
* @author Kirill Tyushev
*/
#ifndef SLAB_STATIC_H_
# error "Do not include this file directly, use <kernel/mm/slab_static.h> instead!"
#endif /* SLAB_STATIC_H_ */
#include <util/binalign.h>
/** cache descriptor */
struct static_cache {
/** pointer to pool */
char* cache_begin;
/** object size */
size_t size;
/** the number of objects stored on each slab */
unsigned int num;
/** the list of free objects in pool */
struct list_head obj_ptr;
/** for initialization */
int hasinit;
};
/** create cache */
#define __STATIC_CACHE_CREATE(name, type, count) \
static char name ## _pool[count * binalign_bound(sizeof(type), sizeof(struct list_head))]; \
static static_cache_t name = { \
.num = count, \
.size = binalign_bound(sizeof(type), sizeof(struct list_head)), \
.cache_begin = name ## _pool, \
.obj_ptr = {NULL, NULL}, \
.hasinit = 0 }
|
Fix doxygen comments for new header. | #ifndef _ECORE_STR_H
# define _ECORE_STR_H
#ifdef EAPI
#undef EAPI
#endif
#ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
/**
* @file Ecore_Data.h
* @brief Contains threading, list, hash, debugging and tree functions.
*/
# ifdef __cplusplus
extern "C" {
# endif
# ifdef __sgi
# define __FUNCTION__ "unknown"
# ifndef __cplusplus
# define inline
# endif
# endif
/* strlcpy implementation for libc's lacking it */
EAPI size_t ecore_strlcpy(char *dst, const char *src, size_t siz);
#ifdef __cplusplus
}
#endif
#endif /* _ECORE_STR_H */
| #ifndef _ECORE_STR_H
# define _ECORE_STR_H
#ifdef EAPI
#undef EAPI
#endif
#ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
/**
* @file Ecore_Str.h
* @brief Contains useful C string functions.
*/
# ifdef __cplusplus
extern "C" {
# endif
# ifdef __sgi
# define __FUNCTION__ "unknown"
# ifndef __cplusplus
# define inline
# endif
# endif
/* strlcpy implementation for libc's lacking it */
EAPI size_t ecore_strlcpy(char *dst, const char *src, size_t siz);
#ifdef __cplusplus
}
#endif
#endif /* _ECORE_STR_H */
|
Remove unused variable (int i) | #include <stdlib.h>
#include <string.h>
#include "chip8.h"
chip8_t * chip8_new(void) {
int i;
chip8_t * self = (chip8_t *) malloc(sizeof(chip8_t));
// The first 512 bytes are used by the interpreter.
self->program_counter = 0x200;
self->index_register = 0;
self->stack_pointer = 0;
self->opcode = 0;
memcpy(self->memory, chip8_hex_font, 50);
return self;
}
void chip8_free(chip8_t * self) {
free(self);
}
| #include <stdlib.h>
#include <string.h>
#include "chip8.h"
chip8_t * chip8_new(void) {
chip8_t * self = (chip8_t *) malloc(sizeof(chip8_t));
// The first 512 bytes are used by the interpreter.
self->program_counter = 0x200;
self->index_register = 0;
self->stack_pointer = 0;
self->opcode = 0;
memcpy(self->memory, chip8_hex_font, 50);
return self;
}
void chip8_free(chip8_t * self) {
free(self);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.