Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Rename platform flag from UNIX to POSIX | /*
* env.h
*
* Author: Ming Tsang
* Copyright (c) 2014 Ming Tsang
* Refer to LICENSE for details
*/
#pragma once
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if defined(UNIX) || defined(__unix__) || defined(LINUX) || defined(__linux__)
#if !defined(UNIX)
#define UNIX
#endif
#elif defined(_WIN32) || defined(WIN32)
#if !defined(WIN32)
#define WIN32
#endif
#else
#error Unsupported platform
#endif
| /*
* env.h
*
* Author: Ming Tsang
* Copyright (c) 2014 Ming Tsang
* Refer to LICENSE for details
*/
#pragma once
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if defined(UNIX) || defined(__unix__) || defined(LINUX) || defined(__linux__)
#if !defined(POSIX)
#define POSIX
#endif
#elif defined(_WIN32) || defined(WIN32)
#if !defined(WIN32)
#define WIN32
#endif
#else
#error Unsupported platform
#endif
|
Declare intptr_t correctly for 64-bit Windows builds. | /* --------------------------------------------------------------------------
* Name: types.h
* Purpose: Various typedefs and utility macros
* ----------------------------------------------------------------------- */
#ifndef TYPES_H
#define TYPES_H
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifdef _WIN32
typedef int intptr_t;
#endif
#define NELEMS(x) ((int) (sizeof(x) / sizeof(x[0])))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define NOT_USED(x) ((x) = (x))
#ifdef _WIN32
#define INLINE __inline
#else
#define INLINE __inline__
#endif
#ifdef __GNUC__
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#endif /* TYPES_H */
| /* --------------------------------------------------------------------------
* Name: types.h
* Purpose: Various typedefs and utility macros
* ----------------------------------------------------------------------- */
#ifndef TYPES_H
#define TYPES_H
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifdef _MSC_VER
#ifdef _WIN64
typedef __int64 intptr_t;
#else
typedef int intptr_t;
#endif
#endif
#define NELEMS(x) ((int) (sizeof(x) / sizeof(x[0])))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define NOT_USED(x) ((x) = (x))
#ifdef _WIN32
#define INLINE __inline
#else
#define INLINE __inline__
#endif
#ifdef __GNUC__
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#endif /* TYPES_H */
|
Add new synchronized graph sub-view dock widget (Reflection). | #pragma once
#include <QtGui/QMouseEvent>
#include <QtGui/QPaintEvent>
#include <QtWidgets/QWidget>
#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "uitypes.h"
class ContextMenuManager;
class DisassemblyContainer;
class Menu;
class ViewFrame;
class BINARYNINJAUIAPI ReflectionView: public QWidget, public DockContextHandler
{
Q_OBJECT
Q_INTERFACES(DockContextHandler)
ViewFrame* m_frame;
BinaryViewRef m_data;
DisassemblyContainer* m_disassemblyContainer;
public:
ReflectionView(ViewFrame* frame, BinaryViewRef data);
~ReflectionView();
virtual void notifyOffsetChanged(uint64_t offset) override;
virtual void notifyViewChanged(ViewFrame* frame) override;
virtual bool shouldBeVisible(ViewFrame* frame) override;
protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
};
| |
Add new error and warning number | // Explorer loader problem list
// /problem.h
#ifndef PROBLEM_H_
#define PROBLEM_H_
/**错误列表*/
#define ERR_NO_MEM_FOR_ID 1 // 没有可用于中断描述符表的内存
#define ERR_NO_MEM_FOR_SD 2 // 没有可用于储存器描述符表的内存
#define ERR_NO_MEM_FOR_SCTBUF 3 // 没有可用于扇区缓存的内存
#define ERR_NO_MEM_FOR_CONFIG 4 // 没有可以分配给引导配置文件的内存
#define ERR_NO_MEM_FOR_BUFFER 5 // 没有可以分配给缓冲系统的内存
#define ERR_NO_MEM_FOR_FS 6 // 没有可以分配给文件系统的内存
#define ERR_NO_MEM_FOR_MMU 7 // 没有可以分配给MMU的内存
/**警告列表*/
#define WARN_NO_MEM 0x80000001 // 无充足内存
#define WARN_STORAGE_NOT_SUPPORT 0x80000002 // 暂时不支持这个储存器
#endif
| // Explorer loader problem list
// /problem.h
#ifndef PROBLEM_H_
#define PROBLEM_H_
/**错误列表*/
#define ERR_NO_MEM_FOR_ID 1 // 没有可用于中断描述符表的内存
#define ERR_NO_MEM_FOR_SD 2 // 没有可用于储存器描述符表的内存
#define ERR_NO_MEM_FOR_SCTBUF 3 // 没有可用于扇区缓存的内存
#define ERR_NO_MEM_FOR_CONFIG 4 // 没有可以分配给引导配置文件的内存
#define ERR_NO_MEM_FOR_BUFFER 5 // 没有可以分配给缓冲系统的内存
#define ERR_NO_MEM_FOR_FS 6 // 没有可以分配给文件系统的内存
#define ERR_NO_MEM_FOR_MMU 7 // 没有可以分配给MMU的内存
#define ERR_NO_FILE 8 // 没有文件
#define ERR_CONFIG_OVERSIZE 9 // CONFIG.LDR oversized
/**警告列表*/
#define WARN_NO_MEM 0x80000001 // 无充足内存
#define WARN_STORAGE_NOT_SUPPORT 0x80000002 // 暂时不支持这个储存器
#define WARN_SCRIPT_SIZE_BAD 0x80000003 // length of cript incorrect
#endif
|
Rename SPI_START to SPI_ACTIVE and SPI_STOP to SPI_PASSIVE | //
// spi.h
// Ethernet Shield
//
// Created by EFCM van der Werf on 12/28/13.
// Copyright (c) 2013 EFCM van der Werf. All rights reserved.
//
#ifndef COM_SPI_H
#define COM_SPI_H
#include "../config.h"
// Do we want SPI?
#ifdef COM_SPI
#include <inttypes.h>
/**
* SPI config
*/
typedef struct spi_config {
};
/**
* @brief Initialize SPI channel
* @param config Configuration for spi channel
*/
extern void spi_init(spi_config *config);
#define SPI_START(port, pin) (port) &= ~(1 << (pin))
#define SPI_STOP(port, pin) (port) |= (1 << (pin))
#endif // COM_SPI
#endif // COM_SPI_H
| //
// spi.h
// Ethernet Shield
//
// Created by EFCM van der Werf on 12/28/13.
// Copyright (c) 2013 EFCM van der Werf. All rights reserved.
//
#ifndef COM_SPI_H
#define COM_SPI_H
#include "../config.h"
// Do we want SPI?
#ifdef COM_SPI
#include <inttypes.h>
/**
* SPI config
*/
typedef struct spi_config {
};
/**
* @brief Initialize SPI channel
* @param config Configuration for spi channel
*/
extern void spi_init(spi_config *config);
#define SPI_ACTIVE(port, pin) (port) &= ~(1 << (pin))
#define SPI_PASSIVE(port, pin) (port) |= (1 << (pin))
#endif // COM_SPI
#endif // COM_SPI_H
|
Add comments and convenience functions | #pragma once
#include "platform.h"
#include <string>
#include <vector>
#include <unordered_map>
class ShaderProgram {
public:
ShaderProgram();
virtual ~ShaderProgram();
GLint getGlProgram() { return m_glProgram; };
GLint getAttribLocation(const std::string& _attribName);
bool buildFromSourceStrings(const std::string& _fragSrc, const std::string& _vertSrc);
void use();
private:
static GLint s_activeGlProgram;
GLint m_glProgram;
GLint m_glFragmentShader;
GLint m_glVertexShader;
std::unordered_map<std::string, GLint> m_attribMap;
std::string m_fragmentShaderSource;
std::string m_vertexShaderSource;
GLint makeLinkedShaderProgram(GLint _fragShader, GLint _vertShader);
GLint makeCompiledShader(const std::string& _src, GLenum _type);
};
| #pragma once
#include "platform.h"
#include <string>
#include <vector>
#include <unordered_map>
/*
* ShaderProgram - utility class representing an OpenGL shader program
*/
class ShaderProgram {
public:
ShaderProgram();
virtual ~ShaderProgram();
/* Getters */
GLint getGlProgram() { return m_glProgram; };
GLint getGlFragmentShader() { return m_glFragmentShader; };
GLint getGlVertexShader() { return m_glVertexShader; };
/*
* getAttribLocation - fetches the location of a shader attribute, caching the result
*/
GLint getAttribLocation(const std::string& _attribName);
/*
* buildFromSourceStrings - attempts to compile a fragment shader and vertex shader from
* strings representing the source code for each, then links them into a complete program;
* if compiling or linking fails it prints the compiler log, returns false, and keeps the
* program's previous state; if successful it returns true.
*/
bool buildFromSourceStrings(const std::string& _fragSrc, const std::string& _vertSrc);
// TODO: Once we have file system abstractions, provide a method to build a program from file names
/*
* isValid - returns true if this object represents a valid OpenGL shader program
*/
bool isValid() { return m_glProgram != 0; };
/*
* use - binds the program in openGL if it is not already bound.
*/
void use();
private:
static GLint s_activeGlProgram;
GLint m_glProgram;
GLint m_glFragmentShader;
GLint m_glVertexShader;
std::unordered_map<std::string, GLint> m_attribMap;
std::string m_fragmentShaderSource;
std::string m_vertexShaderSource;
GLint makeLinkedShaderProgram(GLint _fragShader, GLint _vertShader);
GLint makeCompiledShader(const std::string& _src, GLenum _type);
};
|
Add getenv() to the arch primitive list | extern void *_brk(void *addr);
extern int _open(char *path, int flags, int perm);
extern int _close(int fd);
extern int _read(int fd, void *buf, size_t n);
extern int _write(int fd, void *buf, size_t n);
extern int _lseek(int fd, long off, int whence);
extern void _Exit(int status);
extern int raise(int sig);
extern void (*signal(int sig, void (*func)(int)))(int);
| extern void *_brk(void *addr);
extern int _open(char *path, int flags, int perm);
extern int _close(int fd);
extern int _read(int fd, void *buf, size_t n);
extern int _write(int fd, void *buf, size_t n);
extern int _lseek(int fd, long off, int whence);
extern void _Exit(int status);
extern int raise(int sig);
extern void (*signal(int sig, void (*func)(int)))(int);
extern getenv(const char *var);
|
Fix 3510563: memory leak in BitmapRegionDecoder. | #ifndef SkBitmapRegionDecoder_DEFINED
#define SkBitmapRegionDecoder_DEFINED
#include "SkBitmap.h"
#include "SkRect.h"
#include "SkImageDecoder.h"
class SkBitmapRegionDecoder {
public:
SkBitmapRegionDecoder(SkImageDecoder *decoder, int width, int height) {
fDecoder = decoder;
fWidth = width;
fHeight = height;
}
virtual ~SkBitmapRegionDecoder() {
delete fDecoder;
}
virtual bool decodeRegion(SkBitmap* bitmap, SkIRect rect,
SkBitmap::Config pref, int sampleSize);
virtual int getWidth() { return fWidth; }
virtual int getHeight() { return fHeight; }
virtual SkImageDecoder* getDecoder() { return fDecoder; }
private:
SkImageDecoder *fDecoder;
int fWidth;
int fHeight;
};
#endif
| #ifndef SkBitmapRegionDecoder_DEFINED
#define SkBitmapRegionDecoder_DEFINED
#include "SkBitmap.h"
#include "SkRect.h"
#include "SkImageDecoder.h"
#include "SkStream.h"
class SkBitmapRegionDecoder {
public:
SkBitmapRegionDecoder(SkImageDecoder *decoder, SkStream *stream,
int width, int height) {
fDecoder = decoder;
fStream = stream;
fWidth = width;
fHeight = height;
}
virtual ~SkBitmapRegionDecoder() {
delete fDecoder;
fStream->unref();
}
virtual bool decodeRegion(SkBitmap* bitmap, SkIRect rect,
SkBitmap::Config pref, int sampleSize);
virtual int getWidth() { return fWidth; }
virtual int getHeight() { return fHeight; }
virtual SkImageDecoder* getDecoder() { return fDecoder; }
private:
SkImageDecoder *fDecoder;
SkStream *fStream;
int fWidth;
int fHeight;
};
#endif
|
Update for Gcc 3.2.1 release. | /* $FreeBSD$ */
#include "ansidecl.h"
#include "version.h"
const char *const version_string = "3.2.1 [FreeBSD] 20021009 (prerelease)";
| /* $FreeBSD$ */
#include "ansidecl.h"
#include "version.h"
const char *const version_string = "3.2.1 [FreeBSD] 20021119 (release)";
|
Remove unused variable in vespa-configproxy-cmd. | // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/stllike/string.h>
#include <vector>
class FRT_Supervisor;
class FRT_Target;
class FRT_RPCRequest;
class FRT_Values;
namespace fnet::frt { class StandaloneFRT; }
struct Flags {
vespalib::string method;
std::vector<vespalib::string> args;
vespalib::string targethost;
int portnumber;
Flags(const Flags &);
Flags & operator=(const Flags &);
Flags();
~Flags();
};
class ProxyCmd
{
private:
std::unique_ptr<fnet::frt::StandaloneFRT> _server;
FRT_Supervisor *_supervisor;
FRT_Target *_target;
FRT_RPCRequest *_req;
Flags _flags;
void initRPC();
void invokeRPC();
void finiRPC();
void printArray(FRT_Values *rvals);
vespalib::string makeSpec();
void autoPrint();
public:
ProxyCmd(const Flags& flags);
virtual ~ProxyCmd();
int action();
};
| // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/stllike/string.h>
#include <vector>
class FRT_Target;
class FRT_RPCRequest;
class FRT_Values;
namespace fnet::frt { class StandaloneFRT; }
struct Flags {
vespalib::string method;
std::vector<vespalib::string> args;
vespalib::string targethost;
int portnumber;
Flags(const Flags &);
Flags & operator=(const Flags &);
Flags();
~Flags();
};
class ProxyCmd
{
private:
std::unique_ptr<fnet::frt::StandaloneFRT> _server;
FRT_Target *_target;
FRT_RPCRequest *_req;
Flags _flags;
void initRPC();
void invokeRPC();
void finiRPC();
void printArray(FRT_Values *rvals);
vespalib::string makeSpec();
void autoPrint();
public:
ProxyCmd(const Flags& flags);
virtual ~ProxyCmd();
int action();
};
|
Add stdio to this file becasue we use FILE. | // Copyright (c) 2006-2008 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 BASE_SCOPED_HANDLE_H_
#define BASE_SCOPED_HANDLE_H_
#include "base/basictypes.h"
#if defined(OS_WIN)
#include "base/scoped_handle_win.h"
#endif
class ScopedStdioHandle {
public:
ScopedStdioHandle()
: handle_(NULL) { }
explicit ScopedStdioHandle(FILE* handle)
: handle_(handle) { }
~ScopedStdioHandle() {
Close();
}
void Close() {
if (handle_) {
fclose(handle_);
handle_ = NULL;
}
}
FILE* get() const { return handle_; }
FILE* Take() {
FILE* temp = handle_;
handle_ = NULL;
return temp;
}
void Set(FILE* newhandle) {
Close();
handle_ = newhandle;
}
private:
FILE* handle_;
DISALLOW_EVIL_CONSTRUCTORS(ScopedStdioHandle);
};
#endif // BASE_SCOPED_HANDLE_H_
| // Copyright (c) 2006-2008 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 BASE_SCOPED_HANDLE_H_
#define BASE_SCOPED_HANDLE_H_
#include <stdio.h>
#include "base/basictypes.h"
#if defined(OS_WIN)
#include "base/scoped_handle_win.h"
#endif
class ScopedStdioHandle {
public:
ScopedStdioHandle()
: handle_(NULL) { }
explicit ScopedStdioHandle(FILE* handle)
: handle_(handle) { }
~ScopedStdioHandle() {
Close();
}
void Close() {
if (handle_) {
fclose(handle_);
handle_ = NULL;
}
}
FILE* get() const { return handle_; }
FILE* Take() {
FILE* temp = handle_;
handle_ = NULL;
return temp;
}
void Set(FILE* newhandle) {
Close();
handle_ = newhandle;
}
private:
FILE* handle_;
DISALLOW_EVIL_CONSTRUCTORS(ScopedStdioHandle);
};
#endif // BASE_SCOPED_HANDLE_H_
|
Fix bootstrapping of GHC with earlier versions |
#include "Rts.h"
static HsInt GenSymCounter = 0;
HsInt genSym(void) {
if (n_capabilities == 1) {
return GenSymCounter++;
} else {
return atomic_inc((StgWord *)&GenSymCounter, 1);
}
}
|
#include "Rts.h"
static HsInt GenSymCounter = 0;
HsInt genSym(void) {
#if defined(THREADED_RTS)
if (n_capabilities == 1) {
return GenSymCounter++;
} else {
return atomic_inc((StgWord *)&GenSymCounter, 1);
}
#else
return GenSymCounter++;
#endif
}
|
Fix compilation when using gcc-4.6. Patch by wanders. | //===- TGPreprocessor.h - Preprocessor for TableGen Files -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class represents the Preprocessor for tablegen files.
//
//===----------------------------------------------------------------------===//
#ifndef TGPREPROCESSOR_H
#define TGPREPROCESSOR_H
#include <vector>
namespace llvm {
class MemoryBuffer;
class SourceMgr;
class tool_output_file;
class TGPPLexer;
class TGPPRange;
class TGPPRecord;
typedef std::vector<TGPPRecord> TGPPRecords;
class TGPreprocessor {
SourceMgr &SrcMgr;
tool_output_file &Out;
TGPPLexer *Lexer;
TGPPRecords *CurRecords;
bool ParseBlock(bool TopLevel);
bool ParseForLoop();
bool ParseRange(TGPPRange *Range);
public:
TGPreprocessor(SourceMgr &SM, tool_output_file &O)
: SrcMgr(SM), Out(O), Lexer(NULL), CurRecords(NULL) {
}
/// PreprocessFile - Main entrypoint for preprocess a tblgen file. These
/// preprocess routines return true on error, or false on success.
bool PreprocessFile();
};
} // namespace llvm
#endif /* TGPREPROCESSOR_H */
| //===- TGPreprocessor.h - Preprocessor for TableGen Files -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class represents the Preprocessor for tablegen files.
//
//===----------------------------------------------------------------------===//
#ifndef TGPREPROCESSOR_H
#define TGPREPROCESSOR_H
#include <vector>
namespace llvm {
class MemoryBuffer;
class SourceMgr;
class tool_output_file;
class TGPPLexer;
class TGPPRange;
class TGPPRecord;
typedef std::vector<TGPPRecord> TGPPRecords;
class TGPreprocessor {
SourceMgr &SrcMgr;
tool_output_file &Out;
TGPPLexer *Lexer;
TGPPRecords *CurRecords;
bool ParseBlock(bool TopLevel);
bool ParseForLoop();
bool ParseRange(TGPPRange *Range);
public:
TGPreprocessor(SourceMgr &SM, tool_output_file &O)
: SrcMgr(SM), Out(O), Lexer(0), CurRecords(0) {
}
/// PreprocessFile - Main entrypoint for preprocess a tblgen file. These
/// preprocess routines return true on error, or false on success.
bool PreprocessFile();
};
} // namespace llvm
#endif /* TGPREPROCESSOR_H */
|
Unify name of the class. | #ifndef FT_SOCK_SOCKET_H_
#define FT_SOCK_SOCKET_H_
struct ft_socket
{
struct ft_context * context;
const char * socket_class;
int ai_family;
int ai_socktype;
int ai_protocol;
struct sockaddr_storage addr;
socklen_t addrlen;
// Custom data fields
void * protocol;
void * data;
};
static inline bool ft_socket_init_(
struct ft_socket * this, const char * socket_class, struct ft_context * context,
int domain, int type, int protocol,
const struct sockaddr * addr, socklen_t addrlen
)
{
assert(this != NULL);
assert(context != NULL);
this->context = context;
this->socket_class = socket_class;
this->ai_family = domain;
this->ai_socktype = type;
this->ai_protocol = protocol;
if (addr != NULL)
{
memcpy(&this->addr, addr, addrlen);
this->addrlen = addrlen;
}
else
{
assert(addrlen == 0);
memset(&this->addr, 0, sizeof(this->addr));
}
this->protocol = NULL;
this->data = NULL;
return true;
}
#endif //FT_SOCK_SOCKET_H_
| #ifndef FT_SOCK_SOCKET_H_
#define FT_SOCK_SOCKET_H_
struct ft_socket
{
struct ft_context * context;
const char * clazz;
int ai_family;
int ai_socktype;
int ai_protocol;
struct sockaddr_storage addr;
socklen_t addrlen;
// Custom data fields
void * protocol;
void * data;
};
static inline bool ft_socket_init_(
struct ft_socket * this, const char * clazz, struct ft_context * context,
int domain, int type, int protocol,
const struct sockaddr * addr, socklen_t addrlen
)
{
assert(this != NULL);
assert(context != NULL);
this->context = context;
this->clazz = clazz;
this->ai_family = domain;
this->ai_socktype = type;
this->ai_protocol = protocol;
if (addr != NULL)
{
memcpy(&this->addr, addr, addrlen);
this->addrlen = addrlen;
}
else
{
assert(addrlen == 0);
memset(&this->addr, 0, sizeof(this->addr));
}
this->protocol = NULL;
this->data = NULL;
return true;
}
#endif //FT_SOCK_SOCKET_H_
|
Check for CPU_COUNT itself, don't check glibc version. | // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <features.h>
#include <sched.h>
// CPU_COUNT is only provided by glibc 2.6 or higher
#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
#define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
static int _CPU_COUNT(unsigned int *set, size_t len) {
int cnt;
cnt = 0;
while (len--)
cnt += __builtin_popcount(*set++);
return cnt;
}
#endif
#include "runtime.h"
#include "defs.h"
int32
getproccount(void)
{
cpu_set_t set;
int32 r, cnt;
cnt = 0;
r = sched_getaffinity(0, sizeof(set), &set);
if(r == 0)
cnt += CPU_COUNT(&set);
return cnt ? cnt : 1;
}
| // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <features.h>
#include <sched.h>
// CPU_COUNT is only provided by glibc 2.6 or higher
#ifndef CPU_COUNT
#define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
static int _CPU_COUNT(unsigned int *set, size_t len) {
int cnt;
cnt = 0;
while (len--)
cnt += __builtin_popcount(*set++);
return cnt;
}
#endif
#include "runtime.h"
#include "defs.h"
int32
getproccount(void)
{
cpu_set_t set;
int32 r, cnt;
cnt = 0;
r = sched_getaffinity(0, sizeof(set), &set);
if(r == 0)
cnt += CPU_COUNT(&set);
return cnt ? cnt : 1;
}
|
Add simplest as possible support size func. | #if defined __AVX__
#include <immintrin.h>
#endif
#ifdef __CUDACC__
#include <cuComplex.h>
typedef cuDoubleComplex complexd;
#elif defined __cplusplus
#include <complex>
typedef std::complex<double> complexd;
#else
#include <complex.h>
typedef double complex complexd;
#endif
struct Double4c
{
complexd XX;
complexd XY;
complexd YX;
complexd YY;
};
struct Double3
{
double u;
double v;
double w;
};
// We have original u,v,w, in meters.
// To go to u,v,w in wavelengths we shall multiply them with freq/SPEED_OF_LIGHT
#ifndef SPEED_OF_LIGHT
#define SPEED_OF_LIGHT 299792458.0
#endif
#ifndef WSTEP_CORRECT
#define WSTEP_CORRECT 0.00001
#endif
struct TaskCfg {
double
min_wave_length
, max_inverse_wave_length
, cellsize
, cellsizeWL
, scale
, scaleWL
, w_step
, w_stepWL
, w_shift
, w_shiftWL
;
};
| #ifndef __SCATTER_GRIDDER_H
#define __SCATTER_GRIDDER_H
#if defined __AVX__
#include <immintrin.h>
#endif
#ifdef __CUDACC__
#include <cuComplex.h>
typedef cuDoubleComplex complexd;
#elif defined __cplusplus
#include <complex>
typedef std::complex<double> complexd;
#else
#include <complex.h>
typedef double complex complexd;
#endif
struct Double4c
{
complexd XX;
complexd XY;
complexd YX;
complexd YY;
};
struct Double3
{
double u;
double v;
double w;
};
// We have original u,v,w, in meters.
// To go to u,v,w in wavelengths we shall multiply them with freq/SPEED_OF_LIGHT
#ifndef SPEED_OF_LIGHT
#define SPEED_OF_LIGHT 299792458.0
#endif
#ifndef WSTEP_CORRECT
#define WSTEP_CORRECT 0.00001
#endif
struct TaskCfg {
double
min_wave_length
, max_inverse_wave_length
, cellsize
, cellsizeWL
, scale
, scaleWL
, w_step
, w_stepWL
, w_shift
, w_shiftWL
;
};
#ifdef __CUDACC__
__device__ __inline__ static
#else
__inline static
#endif
int get_supp(int w) {
if (w < 0) w = -w;
return w * 8 + 1;
}
#endif
|
Add key check and convert key to int | #include <stdio.h>
#include <cs50.h>
int main(void) {
return 0;
} | #include <stdio.h>
#include <cs50.h>
int main(int argc, char *argv[]) {
// check entered key
if (argc != 2 || atoi(argv[1]) < 0) {
printf("Usage: ./caesar k\nWhere k is a non negative integer.\n");
return 1;
}
int key = atoi(argv[1]);
return 0;
}
|
Rename member newDelete -> new_delete. | #ifndef SAUCE_SAUCE_H_
#define SAUCE_SAUCE_H_
#include <sauce/internal/bindings.h>
#include <sauce/internal/new_delete.h>
namespace sauce {
template<typename Module, typename NewDelete = ::sauce::internal::NewDelete>
struct Injector {
friend class SauceTest;
Injector():
newDelete() {}
template<typename Iface>
Iface provide() {
return provide<Iface>(Module::template bindings<Injector<Module> >);
}
template<typename Iface>
void dispose(Iface iface) {
dispose<Iface>(Module::template bindings<Injector<Module> >, iface);
}
private:
const NewDelete newDelete;
template<typename Iface, typename Binding>
Iface provide(Binding *binding (Iface)) {
return Binding::provide(*this);
}
template<typename Iface, typename Binding>
void dispose(Binding *binding (Iface), Iface iface) {
Binding::dispose(*this, iface);
}
};
} // namespace sauce
#endif
| #ifndef SAUCE_SAUCE_H_
#define SAUCE_SAUCE_H_
#include <sauce/internal/bindings.h>
#include <sauce/internal/new_delete.h>
namespace sauce {
template<typename Module, typename NewDelete = ::sauce::internal::NewDelete>
struct Injector {
friend class SauceTest;
Injector():
new_delete() {}
template<typename Iface>
Iface provide() {
return provide<Iface>(Module::template bindings<Injector<Module> >);
}
template<typename Iface>
void dispose(Iface iface) {
dispose<Iface>(Module::template bindings<Injector<Module> >, iface);
}
private:
const NewDelete new_delete;
template<typename Iface, typename Binding>
Iface provide(Binding *binding (Iface)) {
return Binding::provide(*this);
}
template<typename Iface, typename Binding>
void dispose(Binding *binding (Iface), Iface iface) {
Binding::dispose(*this, iface);
}
};
} // namespace sauce
#endif
|
Add arduino uno board configuration | /**
Arduino/Genuino UNO
PIN Configuration
D0-D13 - 14 digital IN/OUT pins
A0-A5 - 6 analog IN, digital OUT pins
LED - D13 is also the on board LED
*/
/**
The outputs to the board. The outputs are written internally.
*/
#include "stream_of_byte.h"
struct riot_arduino_uno_sinks_t {
stream_of_byte *D0;
stream_of_byte *D1;
stream_of_byte *D2;
stream_of_byte *D3;
stream_of_byte *D4;
stream_of_byte *D5;
stream_of_byte *D6;
stream_of_byte *D7;
stream_of_byte *D8;
stream_of_byte *D9;
stream_of_byte *D10;
stream_of_byte *D11;
stream_of_byte *D12;
stream_of_byte *D13;
stream_of_byte *A0;
stream_of_byte *A1;
stream_of_byte *A2;
stream_of_byte *A3;
stream_of_byte *A4;
stream_of_byte *A5;
stream_of_byte *LED;
};
typedef struct riot_arduino_uno_sinks_t riot_arduino_uno_sinks;
| |
Add tests for 0X prefix. | // Copyright 2012 Rui Ueyama <rui314@gmail.com>
// This program is free software licensed under the MIT license.
#include "test.h"
void testmain(void) {
print("numeric constants");
expect(1, 0x1);
expect(17, 0x11);
expect(511, 0777);
expect(11, 0b1011); // GNU extension
expect(11, 0B1011); // GNU extension
expect(3, 3L);
expect(3, 3LL);
expect(3, 3UL);
expect(3, 3LU);
expect(3, 3ULL);
expect(3, 3LU);
expect(3, 3LLU);
expectd(55.3, 55.3);
expectd(200, 2e2);
expectd(0x0.DE488631p8, 0xDE.488631);
expect(4, sizeof(5));
expect(8, sizeof(5L));
expect(4, sizeof(3.0f));
expect(8, sizeof(3.0));
expect(4, sizeof(0xe0));
}
| // Copyright 2012 Rui Ueyama <rui314@gmail.com>
// This program is free software licensed under the MIT license.
#include "test.h"
void testmain(void) {
print("numeric constants");
expect(1, 0x1);
expect(1, 0X1);
expect(17, 0x11);
expect(17, 0X11);
expect(511, 0777);
expect(11, 0b1011); // GNU extension
expect(11, 0B1011); // GNU extension
expect(3, 3L);
expect(3, 3LL);
expect(3, 3UL);
expect(3, 3LU);
expect(3, 3ULL);
expect(3, 3LU);
expect(3, 3LLU);
expectd(55.3, 55.3);
expectd(200, 2e2);
expectd(0x0.DE488631p8, 0xDE.488631);
expect(4, sizeof(5));
expect(8, sizeof(5L));
expect(4, sizeof(3.0f));
expect(8, sizeof(3.0));
expect(4, sizeof(0xe0));
}
|
Use llvm::StringSet instead of std::set. | //===- Config.h -------------------------------------------------*- C++ -*-===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_WASM_CONFIG_H
#define LLD_WASM_CONFIG_H
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "Symbols.h"
using llvm::wasm::WasmGlobal;
#include <set>
namespace lld {
namespace wasm {
struct Configuration {
bool AllowUndefined;
bool Demangle;
bool EmitRelocs;
bool ImportMemory;
bool Relocatable;
bool StripAll;
bool StripDebug;
uint32_t GlobalBase;
uint32_t InitialMemory;
uint32_t MaxMemory;
uint32_t ZStackSize;
llvm::StringRef Entry;
llvm::StringRef OutputFile;
llvm::StringRef Sysroot;
std::set<llvm::StringRef> AllowUndefinedSymbols;
std::vector<llvm::StringRef> SearchPaths;
std::vector<std::pair<Symbol *, WasmGlobal>> SyntheticGlobals;
};
// The only instance of Configuration struct.
extern Configuration *Config;
} // namespace wasm
} // namespace lld
#endif
| //===- Config.h -------------------------------------------------*- C++ -*-===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_WASM_CONFIG_H
#define LLD_WASM_CONFIG_H
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "Symbols.h"
using llvm::wasm::WasmGlobal;
namespace lld {
namespace wasm {
struct Configuration {
bool AllowUndefined;
bool Demangle;
bool EmitRelocs;
bool ImportMemory;
bool Relocatable;
bool StripAll;
bool StripDebug;
uint32_t GlobalBase;
uint32_t InitialMemory;
uint32_t MaxMemory;
uint32_t ZStackSize;
llvm::StringRef Entry;
llvm::StringRef OutputFile;
llvm::StringRef Sysroot;
llvm::StringSet<> AllowUndefinedSymbols;
std::vector<llvm::StringRef> SearchPaths;
std::vector<std::pair<Symbol *, WasmGlobal>> SyntheticGlobals;
};
// The only instance of Configuration struct.
extern Configuration *Config;
} // namespace wasm
} // namespace lld
#endif
|
Document that `randomString` will never return an empty string | #import <Foundation/Foundation.h>
/**
Category methods on commonly used types for generating random instances.
Inspired by Haskell's QuickCheck.
*/
@interface NSString (TDTRandomFixtures)
+ (instancetype)randomString;
@end
@interface NSNumber (TDTRandomFixtures)
+ (instancetype)randomNumber;
@end
@interface NSArray (TDTRandomFixtures)
+ (instancetype)randomArrayOfLength:(NSUInteger)length;
@end
@interface NSURL (TDTRandomFixtures)
+ (instancetype)randomURL;
@end
| #import <Foundation/Foundation.h>
/**
Category methods on commonly used types for generating random instances.
Inspired by Haskell's QuickCheck.
*/
@interface NSString (TDTRandomFixtures)
/**
@return A string consisting of random characters.
It is guranteed to be non empty.
*/
+ (instancetype)randomString;
@end
@interface NSNumber (TDTRandomFixtures)
+ (instancetype)randomNumber;
@end
@interface NSArray (TDTRandomFixtures)
+ (instancetype)randomArrayOfLength:(NSUInteger)length;
@end
@interface NSURL (TDTRandomFixtures)
+ (instancetype)randomURL;
@end
|
Add ruby_inspect macro for use when debugging | // Copyright 2008 Wincent Colaiuta
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <ruby/ruby.h>
#include <stdint.h>
// Wikitext
extern VALUE mWikitext;
// Wikitext::Parser
extern VALUE cWikitextParser;
// Wikitext::Parser::Error
// error raised when scanning fails
extern VALUE eWikitextParserError;
// Wikitext::Parser::Token
extern VALUE cWikitextParserToken;
| // Copyright 2008 Wincent Colaiuta
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <ruby/ruby.h>
#include <stdint.h>
#define ruby_inspect(obj) rb_funcall(rb_mKernel, rb_intern("p"), 1, obj)
// Wikitext
extern VALUE mWikitext;
// Wikitext::Parser
extern VALUE cWikitextParser;
// Wikitext::Parser::Error
// error raised when scanning fails
extern VALUE eWikitextParserError;
// Wikitext::Parser::Token
extern VALUE cWikitextParserToken;
|
Add license comment to the header file. | #ifndef PHP_AMF_H
#define PHP_AMF_H 1
#define PHP_AMF_VERSION "0.1"
#define PHP_AMF_WORLD_EXTNAME "amf"
PHP_FUNCTION(amf_encode);
PHP_FUNCTION(amf_decode);
extern zend_module_entry amf_module_entry;
#define phpext_amf_ptr &amf_module_entry
#endif
| /**
* PHP7 extension for Action Message Format (AMF) encoding and decoding with support for AMF0 and AMF3
*
* amfext (http://emilmalinov.com/amfext)
*
* @copyright Copyright (c) 2015 Emil Malinov
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link http://github.com/emilkm/amfext
* @package amfext
*
* @author Emanuele Ruffaldi emanuele.ruffaldi@gmail.com - original version for PHP 5.2
* @author Emil Malinov - PHP 7.X, PHP 5.X maintenance, unit tests, enhancements, bug fixes
*/
#ifndef PHP_AMF_H
#define PHP_AMF_H 1
#define PHP_AMF_VERSION "0.1"
#define PHP_AMF_WORLD_EXTNAME "amf"
PHP_FUNCTION(amf_encode);
PHP_FUNCTION(amf_decode);
extern zend_module_entry amf_module_entry;
#define phpext_amf_ptr &amf_module_entry
#endif
|
Fix warning ‘This function declaration is not a prototype’ | //
// EXPDefines.h
// Expecta
//
// Created by Luke Redpath on 26/03/2012.
// Copyright (c) 2012 Peter Jihoon Kim. All rights reserved.
//
#ifndef Expecta_EXPDefines_h
#define Expecta_EXPDefines_h
typedef void (^EXPBasicBlock)();
typedef id (^EXPIdBlock)();
typedef BOOL (^EXPBoolBlock)();
typedef NSString *(^EXPStringBlock)();
#endif
| //
// EXPDefines.h
// Expecta
//
// Created by Luke Redpath on 26/03/2012.
// Copyright (c) 2012 Peter Jihoon Kim. All rights reserved.
//
#ifndef Expecta_EXPDefines_h
#define Expecta_EXPDefines_h
typedef void (^EXPBasicBlock)(void);
typedef id (^EXPIdBlock)(void);
typedef BOOL (^EXPBoolBlock)(void);
typedef NSString *(^EXPStringBlock)(void);
#endif
|
Add missing ReCheckSerialReaders and HPReCheckSerialReaders() so pcsc-lite can compile on FreeBSD and others | /*
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
*
* Copyright (C) 2000-2003
* David Corcoran <corcoran@linuxnet.com>
*
* $Id$
*/
/**
* @file
* @brief This provides a search API for hot pluggble devices.
*
* Check for platforms that have their own specific support.
* It's easier and flexible to do it here, rather than
* with automake conditionals in src/Makefile.am.
* No, it's still not a perfect solution design wise.
*/
#include "config.h"
#include "pcsclite.h"
#if !defined(__APPLE__) && !defined(HAVE_LIBUSB) && !defined(__linux__)
LONG HPSearchHotPluggables(void)
{
return 0;
}
ULONG HPRegisterForHotplugEvents(void)
{
return 0;
}
LONG HPStopHotPluggables(void)
{
return 0;
}
#endif
| /*
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
*
* Copyright (C) 2000-2003
* David Corcoran <corcoran@linuxnet.com>
*
* $Id$
*/
/**
* @file
* @brief This provides a search API for hot pluggble devices.
*
* Check for platforms that have their own specific support.
* It's easier and flexible to do it here, rather than
* with automake conditionals in src/Makefile.am.
* No, it's still not a perfect solution design wise.
*/
#include "config.h"
#include "pcsclite.h"
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#if !defined(__APPLE__) && !defined(HAVE_LIBUSB) && !defined(__linux__)
char ReCheckSerialReaders = FALSE;
LONG HPSearchHotPluggables(void)
{
return 0;
}
ULONG HPRegisterForHotplugEvents(void)
{
return 0;
}
LONG HPStopHotPluggables(void)
{
return 0;
}
void HPReCheckSerialReaders(void)
{
ReCheckSerialReaders = TRUE;
}
#endif
|
Use more reliable union value | #include "comm.h"
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
#if defined(PBL_COLOR)
Tuple *background_t = dict_find(iter, AppKeyColorBackground);
if(background_t) {
data_set_color(ColorBackground, (GColor){ .argb = background_t->value->int32 });
}
Tuple *sides_t = dict_find(iter, AppKeyColorSides);
if(sides_t) {
data_set_color(ColorSides, (GColor){ .argb = sides_t->value->int32 });
}
Tuple *face_t = dict_find(iter, AppKeyColorFace);
if(face_t) {
data_set_color(ColorFace, (GColor){ .argb = face_t->value->int32 });
}
#endif
// Other settings
Tuple *anim_t = dict_find(iter, AppKeyAnimations);
if(anim_t) {
data_set_animations(anim_t->value->int32 == 1);
}
Tuple *bluetooth_t = dict_find(iter, AppKeyBluetooth);
if(bluetooth_t) {
data_set_bluetooth_alert(bluetooth_t->value->int32 == 1);
}
// Quit to be reloaded
window_stack_pop_all(true);
}
void comm_init(int inbox, int outbox) {
app_message_register_inbox_received(inbox_received_handler);
app_message_open(inbox, outbox);
}
| #include "comm.h"
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
#if defined(PBL_COLOR)
Tuple *background_t = dict_find(iter, AppKeyColorBackground);
if(background_t) {
data_set_color(ColorBackground, (GColor){ .argb = background_t->value->int8 });
}
Tuple *sides_t = dict_find(iter, AppKeyColorSides);
if(sides_t) {
data_set_color(ColorSides, (GColor){ .argb = sides_t->value->int8 });
}
Tuple *face_t = dict_find(iter, AppKeyColorFace);
if(face_t) {
data_set_color(ColorFace, (GColor){ .argb = face_t->value->int8 });
}
#endif
// Other settings
Tuple *anim_t = dict_find(iter, AppKeyAnimations);
if(anim_t) {
data_set_animations(anim_t->value->int8 == 1);
}
Tuple *bluetooth_t = dict_find(iter, AppKeyBluetooth);
if(bluetooth_t) {
data_set_bluetooth_alert(bluetooth_t->value->int8 == 1);
}
// Quit to be reloaded
window_stack_pop_all(true);
}
void comm_init(int inbox, int outbox) {
app_message_register_inbox_received(inbox_received_handler);
app_message_open(inbox, outbox);
}
|
Rename incorrectly named parameter of numa_cpu_node() | #ifndef _ASM_X86_NUMA_32_H
#define _ASM_X86_NUMA_32_H
extern int numa_off;
extern int pxm_to_nid(int pxm);
#ifdef CONFIG_NUMA
extern int __cpuinit numa_cpu_node(int apicid);
#else /* CONFIG_NUMA */
static inline int numa_cpu_node(int cpu) { return NUMA_NO_NODE; }
#endif /* CONFIG_NUMA */
#ifdef CONFIG_HIGHMEM
extern void set_highmem_pages_init(void);
#else
static inline void set_highmem_pages_init(void)
{
}
#endif
#endif /* _ASM_X86_NUMA_32_H */
| #ifndef _ASM_X86_NUMA_32_H
#define _ASM_X86_NUMA_32_H
extern int numa_off;
extern int pxm_to_nid(int pxm);
#ifdef CONFIG_NUMA
extern int __cpuinit numa_cpu_node(int cpu);
#else /* CONFIG_NUMA */
static inline int numa_cpu_node(int cpu) { return NUMA_NO_NODE; }
#endif /* CONFIG_NUMA */
#ifdef CONFIG_HIGHMEM
extern void set_highmem_pages_init(void);
#else
static inline void set_highmem_pages_init(void)
{
}
#endif
#endif /* _ASM_X86_NUMA_32_H */
|
Add function wrappers for forestclaw.c | /*
Copyright (c) 2012 Carsten Burstedde, Donna Calhoun
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fclaw2d_forestclaw.h>
void fclaw2d_after_regrid(fclaw2d_domain_t *domain)
{
if (fclaw2d_vt()->after_regrid != NULL)
{
fclaw2d_vt()->after_regrid(domain);
}
}
void fclaw2d_problem_setup(fclaw2d_domain_t *domain)
{
/* User defined problem setup */
if (fclaw2d_vt()->problem_setup != NULL)
{
fclaw2d_vt()->problem_setup(domain);
}
}
| |
Fix test from r283913 to unbreak bots | // RUN: %clang -c -isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
// CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: '{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
// RUN: %clang -c -fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
// CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: '{{([A-Za-z]:.*)?}}/FOO'{{$}}
| // REQUIRES: x86-registered-target
// RUN: %clang -target x86_64-apple-darwin -c -isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
// CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: '{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
// RUN: %clang -target x86_64-apple-darwin -c -fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
// CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: '{{([A-Za-z]:.*)?}}/FOO'{{$}}
|
Add internal/common version (number) header file. | /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */
#if !defined INC_PUBNUB_VERSION_INTERNAL
#define INC_PUBNUB_VERSION_INTERNAL
#define PUBNUB_SDK_VERSION "2.2.11"
#endif /* !defined INC_PUBNUB_VERSION_INTERNAL */
| |
Use the -fsanitize=thread flag to unbreak buildbot. | // RUN: %clang -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -O1 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -O2 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -O3 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -target i386-unknown-unknown -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
// Verify that -fthread-sanitizer invokes tsan instrumentation.
int foo(int *a) { return *a; }
// CHECK: __tsan_init
| // RUN: %clang -target i386-unknown-unknown -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -O1 -target i386-unknown-unknown -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -O2 -target i386-unknown-unknown -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -O3 -target i386-unknown-unknown -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -target i386-unknown-unknown -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
// Verify that -fsanitize=thread invokes tsan instrumentation.
int foo(int *a) { return *a; }
// CHECK: __tsan_init
|
Use correct module directory when making keyboard. Previous commit fixed compiler warnings also. | #include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
#include "e_kbd_int.h"
/* local variables */
static E_Kbd_Int *ki = NULL;
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Keyboard" };
EAPI void *
e_modapi_init(E_Module *m)
{
if (!il_kbd_config_init(m)) return NULL;
ki = e_kbd_int_new(mod_dir, mod_dir, mod_dir);
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m)
{
if (ki)
{
e_kbd_int_free(ki);
ki = NULL;
}
il_kbd_config_shutdown();
return 1;
}
EAPI int
e_modapi_save(E_Module *m)
{
return il_kbd_config_save();
}
| #include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
#include "e_kbd_int.h"
/* local variables */
static E_Kbd_Int *ki = NULL;
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Keyboard" };
EAPI void *
e_modapi_init(E_Module *m)
{
if (!il_kbd_config_init(m)) return NULL;
ki = e_kbd_int_new(il_kbd_cfg->mod_dir,
il_kbd_cfg->mod_dir, il_kbd_cfg->mod_dir);
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m)
{
if (ki)
{
e_kbd_int_free(ki);
ki = NULL;
}
il_kbd_config_shutdown();
return 1;
}
EAPI int
e_modapi_save(E_Module *m)
{
return il_kbd_config_save();
}
|
Create and delete rtp connections | #include "rtp/kms-rtp-endpoint.h"
#include <glib.h>
#define LOCALNAME "kms/rtp/1"
static KmsEndpoint*
create_endpoint() {
KmsEndpoint *ep;
gchar *name;
name = g_strdup_printf(LOCALNAME);
ep = g_object_new(KMS_TYPE_RTP_ENDPOINT, "localname", name, NULL);
g_free(name);
return ep;
}
static void
check_endpoint(KmsEndpoint *ep) {
gchar *name;
g_object_get(ep, "localname", &name, NULL);
g_assert(g_strcmp0(name, LOCALNAME) == 0);
g_free(name);
}
gint
main(gint argc, gchar **argv) {
KmsEndpoint *ep;
g_type_init();
ep = create_endpoint();
check_endpoint(ep);
g_object_unref(ep);
return 0;
}
| #include "rtp/kms-rtp-endpoint.h"
#include <glib.h>
#define LOCALNAME "kms/rtp/1"
static KmsEndpoint*
create_endpoint() {
KmsEndpoint *ep;
gchar *name;
name = g_strdup_printf(LOCALNAME);
ep = g_object_new(KMS_TYPE_RTP_ENDPOINT, "localname", name, NULL);
g_free(name);
return ep;
}
static void
check_endpoint(KmsEndpoint *ep) {
gchar *name;
g_object_get(ep, "localname", &name, NULL);
g_assert(g_strcmp0(name, LOCALNAME) == 0);
g_free(name);
}
gint
main(gint argc, gchar **argv) {
KmsEndpoint *ep;
KmsConnection *conn;
g_type_init();
ep = create_endpoint();
check_endpoint(ep);
conn = kms_endpoint_create_connection(ep, KMS_CONNECTION_TYPE_RTP,
NULL);
kms_endpoint_delete_connection(ep, conn, NULL);
g_object_unref(conn);
check_endpoint(ep);
g_object_unref(ep);
return 0;
}
|
Update reflection view to use view location notification. | #pragma once
#include <QtGui/QMouseEvent>
#include <QtGui/QPaintEvent>
#include <QtWidgets/QWidget>
#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "uitypes.h"
class ContextMenuManager;
class DisassemblyContainer;
class Menu;
class ViewFrame;
class BINARYNINJAUIAPI ReflectionView: public QWidget, public DockContextHandler
{
Q_OBJECT
Q_INTERFACES(DockContextHandler)
ViewFrame* m_frame;
BinaryViewRef m_data;
DisassemblyContainer* m_disassemblyContainer;
public:
ReflectionView(ViewFrame* frame, BinaryViewRef data);
~ReflectionView();
virtual void notifyOffsetChanged(uint64_t offset) override;
virtual void notifyViewChanged(ViewFrame* frame) override;
virtual void notifyVisibilityChanged(bool visible) override;
virtual bool shouldBeVisible(ViewFrame* frame) override;
protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
};
| #pragma once
#include <QtGui/QMouseEvent>
#include <QtGui/QPaintEvent>
#include <QtWidgets/QWidget>
#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "uitypes.h"
class ContextMenuManager;
class DisassemblyContainer;
class Menu;
class ViewFrame;
class BINARYNINJAUIAPI ReflectionView: public QWidget, public DockContextHandler
{
Q_OBJECT
Q_INTERFACES(DockContextHandler)
ViewFrame* m_frame;
BinaryViewRef m_data;
DisassemblyContainer* m_disassemblyContainer;
public:
ReflectionView(ViewFrame* frame, BinaryViewRef data);
~ReflectionView();
virtual void notifyViewLocationChanged(View* view, const ViewLocation& viewLocation) override;
virtual void notifyVisibilityChanged(bool visible) override;
virtual bool shouldBeVisible(ViewFrame* frame) override;
protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
};
|
Make sure there's NUL byte at the end of strndupa | #pragma once
#include <unistd.h>
#include <sys/syscall.h>
#ifdef HAVE_LINUX_MODULE_H
#include <linux/module.h>
#endif
#ifndef MODULE_INIT_IGNORE_MODVERSIONS
# define MODULE_INIT_IGNORE_MODVERSIONS 1
#endif
#ifndef MODULE_INIT_IGNORE_VERMAGIC
# define MODULE_INIT_IGNORE_VERMAGIC 2
#endif
#ifndef __NR_finit_module
# define __NR_finit_module -1
#endif
#ifndef HAVE_FINIT_MODULE
#include <errno.h>
static inline int finit_module(int fd, const char *uargs, int flags)
{
if (__NR_finit_module == -1) {
errno = ENOSYS;
return -1;
}
return syscall(__NR_finit_module, fd, uargs, flags);
}
#endif
#if !HAVE_DECL_STRNDUPA
#define strndupa(s, length) \
({ \
size_t __len = strnlen((s), (length)); \
strncpy(alloca(__len + 1), (s), __len); \
})
#endif
| #pragma once
#include <unistd.h>
#include <sys/syscall.h>
#ifdef HAVE_LINUX_MODULE_H
#include <linux/module.h>
#endif
#ifndef MODULE_INIT_IGNORE_MODVERSIONS
# define MODULE_INIT_IGNORE_MODVERSIONS 1
#endif
#ifndef MODULE_INIT_IGNORE_VERMAGIC
# define MODULE_INIT_IGNORE_VERMAGIC 2
#endif
#ifndef __NR_finit_module
# define __NR_finit_module -1
#endif
#ifndef HAVE_FINIT_MODULE
#include <errno.h>
static inline int finit_module(int fd, const char *uargs, int flags)
{
if (__NR_finit_module == -1) {
errno = ENOSYS;
return -1;
}
return syscall(__NR_finit_module, fd, uargs, flags);
}
#endif
#if !HAVE_DECL_STRNDUPA
#define strndupa(s, n) \
({ \
const char *__old = (s); \
size_t __len = strnlen(__old, (n)); \
char *__new = alloca(__len + 1); \
__new[__len] = '\0'; \
memcpy(__new, __old, __len); \
})
#endif
|
Add missing inclusion of crypto_types.h | /** @file
* Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved.
* SPDX-License-Identifier : Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#ifndef _VAL_CLIENT_H_
#define _VAL_CLIENT_H_
#include "val.h"
#include "psa/client.h"
#include "crypto_values.h"
#define INVALID_SID 0x0000FA20
#ifndef CLIENT_TEST_DISPATCHER_SID
#define CLIENT_TEST_DISPATCHER_SID 0x0
#endif
#ifndef SERVER_TEST_DISPATCHER_SID
#define SERVER_TEST_DISPATCHER_SID 0x0
#endif
#endif /* _VAL_CLIENT_H_ */
| /** @file
* Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved.
* SPDX-License-Identifier : Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#ifndef _VAL_CLIENT_H_
#define _VAL_CLIENT_H_
#include "val.h"
#include "psa/client.h"
#include "psa/crypto_types.h"
#include "psa/crypto_values.h"
#define INVALID_SID 0x0000FA20
#ifndef CLIENT_TEST_DISPATCHER_SID
#define CLIENT_TEST_DISPATCHER_SID 0x0
#endif
#ifndef SERVER_TEST_DISPATCHER_SID
#define SERVER_TEST_DISPATCHER_SID 0x0
#endif
#endif /* _VAL_CLIENT_H_ */
|
Include a Ruten code, demonstrating keystroke reading | #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_lflag &= ~(ECHO | ICANON);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enableRawMode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') {
if (iscntrl(c)) {
printf("%d\n", c);
} else {
printf("%d ('%c')\n", c, c);
}
}
return 0;
}
| |
Clarify doc comment about shrinkable::map | #pragma once
#include "rapidcheck/Shrinkable.h"
namespace rc {
namespace shrinkable {
//! Maps the given shrinkable using the given mapping callable.
template<typename T, typename Mapper>
Shrinkable<typename std::result_of<Mapper(T)>::type>
map(Mapper &&mapper, Shrinkable<T> shrinkable);
//! Returns a shrinkable equal to the given shrinkable but with the shrinks
//! (lazily) mapped by the given mapping callable. Since the value is not mapped
//! also the output type is the same as the output type.
template<typename T, typename Mapper>
Shrinkable<T> mapShrinks(Mapper &&mapper, Shrinkable<T> shrinkable);
//! Recursively filters the given shrinkable using the given predicate. Any
//! subtree with a root for which the predicate returns false is discarded,
//! including the passed in root which is why this function returns a `Maybe`.
template<typename T, typename Predicate>
Maybe<Shrinkable<T>> filter(Predicate pred, Shrinkable<T> shrinkable);
//! Given two `Shrinkables`, returns a `Shrinkable` pair that first shrinks the
//! first element and then the second.
template<typename T1, typename T2>
Shrinkable<std::pair<T1, T2>> pair(Shrinkable<T1> s1, Shrinkable<T2> s2);
} // namespace shrinkable
} // namespace rc
#include "Transform.hpp"
| #pragma once
#include "rapidcheck/Shrinkable.h"
namespace rc {
namespace shrinkable {
//! Maps the given shrinkable recursively using the given mapping callable.
template<typename T, typename Mapper>
Shrinkable<typename std::result_of<Mapper(T)>::type>
map(Mapper &&mapper, Shrinkable<T> shrinkable);
//! Returns a shrinkable equal to the given shrinkable but with the shrinks
//! (lazily) mapped by the given mapping callable. Since the value is not mapped
//! also the output type is the same as the output type.
template<typename T, typename Mapper>
Shrinkable<T> mapShrinks(Mapper &&mapper, Shrinkable<T> shrinkable);
//! Recursively filters the given shrinkable using the given predicate. Any
//! subtree with a root for which the predicate returns false is discarded,
//! including the passed in root which is why this function returns a `Maybe`.
template<typename T, typename Predicate>
Maybe<Shrinkable<T>> filter(Predicate pred, Shrinkable<T> shrinkable);
//! Given two `Shrinkables`, returns a `Shrinkable` pair that first shrinks the
//! first element and then the second.
template<typename T1, typename T2>
Shrinkable<std::pair<T1, T2>> pair(Shrinkable<T1> s1, Shrinkable<T2> s2);
} // namespace shrinkable
} // namespace rc
#include "Transform.hpp"
|
Use offsetof() macro instead of expanded form. | /*
Copyright (c) 2012 250bpm s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
#ifndef SP_CONT_INCLUDED
#define SP_CONT_INCLUDED
/* Takes a pointer to a member variable and computes pointer to the structure
that contains it. 'type' is type of the structure, not the member. */
#define sp_cont(ptr, type, member) \
((type*) (((char*) ptr) - ((size_t) &(((type*) 0)->member))))
#endif
| /*
Copyright (c) 2012 250bpm s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
#ifndef SP_CONT_INCLUDED
#define SP_CONT_INCLUDED
#include <stddef.h>
/* Takes a pointer to a member variable and computes pointer to the structure
that contains it. 'type' is type of the structure, not the member. */
#define sp_cont(ptr, type, member) \
((type*) (((char*) ptr) - offsetof(type, member)))
#endif
|
Add license header to the file | namespace libmspub
{
const unsigned EMUS_IN_INCH = 914400;
}
| /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* libmspub
* Version: MPL 1.1 / GPLv2+ / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPLv2+"), or
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
* instead of those above.
*/
#ifndef __MSPUBCONSTANTS_H__
#define __MSPUBCONSTANTS_H__
namespace libmspub
{
const unsigned EMUS_IN_INCH = 914400;
}
#endif /* __MSPUBCONSTANTS_H__ */
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|
Trim unreferenced goo. SDRAM likely should be next, but it is still referenced. | /*-
* JNPR: pltfm.h,v 1.5.2.1 2007/09/10 05:56:11 girish
* $FreeBSD$
*/
#ifndef _MACHINE_PLTFM_H_
#define _MACHINE_PLTFM_H_
/*
* This files contains platform-specific definitions.
*/
#define SDRAM_ADDR_START 0 /* SDRAM addr space */
#define SDRAM_ADDR_END (SDRAM_ADDR_START + (1024*0x100000))
#define SDRAM_MEM_SIZE (SDRAM_ADDR_END - SDRAM_ADDR_START)
#define UART_ADDR_START 0x1ef14000 /* UART */
#define UART_ADDR_END 0x1ef14fff
#define UART_MEM_SIZE (UART_ADDR_END-UART_ADDR_START)
/*
* NS16550 UART address
*/
#ifdef ADDR_NS16550_UART1
#undef ADDR_NS16550_UART1
#endif
#define ADDR_NS16550_UART1 0x1ef14000 /* UART */
#define VADDR_NS16550_UART1 0xbef14000 /* UART */
#endif /* !_MACHINE_PLTFM_H_ */
| /*-
* JNPR: pltfm.h,v 1.5.2.1 2007/09/10 05:56:11 girish
* $FreeBSD$
*/
#ifndef _MACHINE_PLTFM_H_
#define _MACHINE_PLTFM_H_
/*
* This files contains platform-specific definitions.
*/
#define SDRAM_ADDR_START 0 /* SDRAM addr space */
#define SDRAM_ADDR_END (SDRAM_ADDR_START + (1024*0x100000))
#define SDRAM_MEM_SIZE (SDRAM_ADDR_END - SDRAM_ADDR_START)
#endif /* !_MACHINE_PLTFM_H_ */
|
Fix nonsense comment + remove duplicate code. | #include <assert.h>
#include <string.h>
#include "pocl_cl.h"
/*
* Provide the ICD loader the specified function to get the pocl platform.
*
* TODO: the functionality of this seems the same as that of clGetPlatformIDs.
* but we cannot call that, as it is defined in the ICD loader itself.
*
*/
extern struct _cl_platform_id _platforms[1];
CL_API_ENTRY cl_int CL_API_CALL
clIcdGetPlatformIDsKHR(cl_uint num_entries,
cl_platform_id * platforms,
cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0
{
int const num = 1;
int i;
if (platforms != NULL) {
if (num_entries < num)
return CL_INVALID_VALUE;
for (i=0; i<num; ++i)
platforms[i] = &_platforms[i];
}
if (num_platforms != NULL)
*num_platforms = num;
return CL_SUCCESS;
}
| #include <assert.h>
#include <string.h>
#include "pocl_cl.h"
/*
* GetPlatformIDs that support ICD.
* This function is required by the ICD specification.
*/
extern struct _cl_platform_id _platforms[1];
CL_API_ENTRY cl_int CL_API_CALL
clIcdGetPlatformIDsKHR(cl_uint num_entries,
cl_platform_id * platforms,
cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0
{
return clGetPlatformIDs( num_entries, platforms, num_platforms );
}
|
Add log functions for windows. | /*
*The MIT License (MIT)
*
* Copyright (c) <2017> <Stephan Gatzka>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <stdarg.h>
#include <stdio.h>
#include "log.h"
static char log_buffer[200];
void log_err(const char *format, ...)
{
va_list args;
va_start(args, format);
vsnprintf(log_buffer, sizeof(log_buffer), format, args);
printf("%s: %s", "Error", log_buffer);
va_end(args);
}
void log_warn(const char *format, ...)
{
va_list args;
va_start(args, format);
vsnprintf(log_buffer, sizeof(log_buffer), format, args);
printf("%s: %s", "Warning", log_buffer);
va_end(args);
}
void log_info(const char *format, ...)
{
va_list args;
va_start(args, format);
vsnprintf(log_buffer, sizeof(log_buffer), format, args);
printf("%s: %s", "Info", log_buffer); va_end(args);
} | |
Revert the nvcc messages to their default severity instead of the forcing them to be warnings | #ifdef EIGEN_WARNINGS_DISABLED
#undef EIGEN_WARNINGS_DISABLED
#ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
#ifdef _MSC_VER
#pragma warning( pop )
#elif defined __INTEL_COMPILER
#pragma warning pop
#elif defined __clang__
#pragma clang diagnostic pop
#elif defined __NVCC__
#pragma diag_warning code_is_unreachable
#pragma diag_warning initialization_not_reachable
#endif
#endif
#endif // EIGEN_WARNINGS_DISABLED
| #ifdef EIGEN_WARNINGS_DISABLED
#undef EIGEN_WARNINGS_DISABLED
#ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
#ifdef _MSC_VER
#pragma warning( pop )
#elif defined __INTEL_COMPILER
#pragma warning pop
#elif defined __clang__
#pragma clang diagnostic pop
#elif defined __NVCC__
#pragma diag_default code_is_unreachable
#pragma diag_default initialization_not_reachable
#endif
#endif
#endif // EIGEN_WARNINGS_DISABLED
|
Add comment to the Terrain_Gen_Mod struct | /*
* Copyright (C) 2015 Luke San Antonio and Hazza Alkaabi
* All rights reserved.
*/
#pragma once
#include <string>
#include <vector>
#include "../gen/terrain.h"
#include "common.h"
extern "C"
{
#include "lua.h"
}
namespace game { namespace luaint
{
struct Terrain_Gen_Config
{
void add_option(std::string const& name, double def) noexcept;
private:
enum class Option_Type
{
Double
};
struct Option
{
std::string name;
Option_Type type;
union
{
double d_num;
} value;
};
std::vector<Option> options_;
};
struct Terrain_Gen_Mod
{
// Index into registry[naeme] where naeme is some implementation (?)
// defined string.
size_t table_index;
Terrain_Gen_Config config;
};
using Terrain_Gen_Mod_Vector = std::vector<Terrain_Gen_Mod>;
// Use this to initialize a table to return from a lua require call.
Table terrain_preload_table(Terrain_Gen_Mod_Vector&) noexcept;
// Use this to push a grid
void push_grid_table(lua_State*, gen::Grid_Map&) noexcept;
} }
| /*
* Copyright (C) 2015 Luke San Antonio and Hazza Alkaabi
* All rights reserved.
*/
#pragma once
#include <string>
#include <vector>
#include "../gen/terrain.h"
#include "common.h"
extern "C"
{
#include "lua.h"
}
namespace game { namespace luaint
{
struct Terrain_Gen_Config
{
void add_option(std::string const& name, double def) noexcept;
private:
enum class Option_Type
{
Double
};
struct Option
{
std::string name;
Option_Type type;
union
{
double d_num;
} value;
};
std::vector<Option> options_;
};
struct Terrain_Gen_Mod
{
// Index into registry[naeme] where naeme is some implementation (?)
// defined string.
// The value of the registry[naeme][table_index] is the mod lua function.
size_t table_index;
Terrain_Gen_Config config;
};
using Terrain_Gen_Mod_Vector = std::vector<Terrain_Gen_Mod>;
// Use this to initialize a table to return from a lua require call.
Table terrain_preload_table(Terrain_Gen_Mod_Vector&) noexcept;
// Use this to push a grid
void push_grid_table(lua_State*, gen::Grid_Map&) noexcept;
} }
|
Change number of divisions in index to 2^14 | #pragma once
#include <stdint.h>
#include <stdlib.h>
#include "ewok.h"
enum { N_DIVISIONS = 65536, LOG2_DIVISIONS = 16 };
struct indexed_ewah_map {
struct ewah_bitmap *map;
size_t bit_from_division[N_DIVISIONS], ptr_from_division[N_DIVISIONS];
};
/* Build an index on top of an existing libewok EWAH map. */
extern void ewah_build_index(struct indexed_ewah_map *);
/* Test whether a given bit is set in an indexed EWAH map. */
extern bool indexed_ewah_get(struct indexed_ewah_map *, size_t);
| #pragma once
#include <stdint.h>
#include <stdlib.h>
#include "ewok.h"
enum { N_DIVISIONS = 1<<14 };
struct indexed_ewah_map {
struct ewah_bitmap *map;
size_t bit_from_division[N_DIVISIONS], ptr_from_division[N_DIVISIONS];
};
/* Build an index on top of an existing libewok EWAH map. */
extern void ewah_build_index(struct indexed_ewah_map *);
/* Test whether a given bit is set in an indexed EWAH map. */
extern bool indexed_ewah_get(struct indexed_ewah_map *, size_t);
|
Reduce the size of the temp input buffer | #ifndef CONVERTER_H
#define CONVERTER_H
#include "alMain.h"
#include "alu.h"
#ifdef __cpluspluc
extern "C" {
#endif
typedef struct SampleConverter {
enum DevFmtType mSrcType;
enum DevFmtType mDstType;
ALsizei mNumChannels;
ALsizei mSrcTypeSize;
ALsizei mDstTypeSize;
ALint mSrcPrepCount;
ALsizei mFracOffset;
ALsizei mIncrement;
ResamplerFunc mResample;
alignas(16) ALfloat mSrcSamples[BUFFERSIZE+MAX_PRE_SAMPLES+MAX_POST_SAMPLES];
alignas(16) ALfloat mDstSamples[BUFFERSIZE];
struct {
alignas(16) ALfloat mPrevSamples[MAX_PRE_SAMPLES+MAX_POST_SAMPLES];
} Chan[];
} SampleConverter;
SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType dstType, ALsizei numchans, ALsizei srcRate, ALsizei dstRate);
void DestroySampleConverter(SampleConverter **converter);
ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid *src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes);
ALsizei SampleConverterAvailableOut(SampleConverter *converter, ALsizei srcframes);
#ifdef __cpluspluc
}
#endif
#endif /* CONVERTER_H */
| #ifndef CONVERTER_H
#define CONVERTER_H
#include "alMain.h"
#include "alu.h"
#ifdef __cpluspluc
extern "C" {
#endif
typedef struct SampleConverter {
enum DevFmtType mSrcType;
enum DevFmtType mDstType;
ALsizei mNumChannels;
ALsizei mSrcTypeSize;
ALsizei mDstTypeSize;
ALint mSrcPrepCount;
ALsizei mFracOffset;
ALsizei mIncrement;
ResamplerFunc mResample;
alignas(16) ALfloat mSrcSamples[BUFFERSIZE];
alignas(16) ALfloat mDstSamples[BUFFERSIZE];
struct {
alignas(16) ALfloat mPrevSamples[MAX_PRE_SAMPLES+MAX_POST_SAMPLES];
} Chan[];
} SampleConverter;
SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType dstType, ALsizei numchans, ALsizei srcRate, ALsizei dstRate);
void DestroySampleConverter(SampleConverter **converter);
ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid *src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes);
ALsizei SampleConverterAvailableOut(SampleConverter *converter, ALsizei srcframes);
#ifdef __cpluspluc
}
#endif
#endif /* CONVERTER_H */
|
Revert "Possibly fixed alignment warning" | /*
* Copyright (C) 2013-2014 Daniel Nicoletti <dantti12@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PLUGIN_H
#define PLUGIN_H
#define CUTELYST_MODIFIER1 0
#ifdef __cplusplus
extern "C" {
#endif
struct uwsgi_cutelyst {
char *app;
int reload;
};
extern struct uwsgi_cutelyst options;
#ifdef __cplusplus
}
#endif
#endif // PLUGIN_H
| /*
* Copyright (C) 2013-2014 Daniel Nicoletti <dantti12@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PLUGIN_H
#define PLUGIN_H
#define CUTELYST_MODIFIER1 0
#ifdef __cplusplus
extern "C" {
#endif
struct uwsgi_cutelyst {
char *app;
int reload;
} options;
#ifdef __cplusplus
}
#endif
#endif // PLUGIN_H
|
Move heartbeat, location and gexec metrics to a core module that will always be statically linked | #include <metric.h>
#include <gm_mmn.h>
#include <libmetrics.h>
mmodule core_metrics;
/*
** A helper function to determine the number of cpustates in /proc/stat (MKN)
*/
static int core_metrics_init ( apr_pool_t *p )
{
int i;
for (i = 0; core_metrics.metrics_info[i].name != NULL; i++) {
/* Initialize the metadata storage for each of the metrics and then
* store one or more key/value pairs. The define MGROUPS defines
* the key for the grouping attribute. */
MMETRIC_INIT_METADATA(&(core_metrics.metrics_info[i]),p);
MMETRIC_ADD_METADATA(&(core_metrics.metrics_info[i]),MGROUP,"core");
}
return 0;
}
static void core_metrics_cleanup ( void )
{
}
static g_val_t core_metrics_handler ( int metric_index )
{
g_val_t val;
/* The metric_index corresponds to the order in which
the metrics appear in the metric_info array
*/
switch (metric_index) {
case 0:
return gexec_func();
case 1:
return heartbeat_func();
case 2:
return location_func();
}
/* default case */
val.int32 = 0;
return val;
}
static Ganglia_25metric core_metrics_info[] =
{
{0, "gexec", 300, GANGLIA_VALUE_STRING, "", "zero", "%s", UDP_HEADER_SIZE+32, "gexec available"},
{0, "heartbeat", 20, GANGLIA_VALUE_UNSIGNED_INT, "", "", "%u", UDP_HEADER_SIZE+8, "Last heartbeat"},
{0, "location", 1200, GANGLIA_VALUE_STRING, "(x,y,z)", "", "%s", UDP_HEADER_SIZE+12, "Location of the machine"},
{0, NULL}
};
mmodule core_metrics =
{
STD_MMODULE_STUFF,
core_metrics_init,
core_metrics_cleanup,
core_metrics_info,
core_metrics_handler,
};
| |
Add XCHAINER_ASSERT, an alternative assert that forcibly uses the expression syntactically | #pragma once
#ifdef NDEBUG
#define XCHAINER_DEBUG false
#else // NDEBUG
#define XCHAINER_DEBUG true
#endif // NDEBUG
#ifndef XCHAINER_HOST_DEVICE
#ifdef __CUDACC__
#define XCHAINER_HOST_DEVICE __host__ __device__
#else // __CUDA__
#define XCHAINER_HOST_DEVICE
#endif // __CUDACC__
#endif // XCHAINER_HOST_DEVICE
#ifndef XCHAINER_NEVER_REACH
#ifdef NDEBUG
#include <cstdlib>
#define XCHAINER_NEVER_REACH() (std::abort())
#else // NDEBUG
#include <cassert>
#define XCHAINER_NEVER_REACH() \
do { \
assert(false); /* NOLINT(cert-dcl03-c) */ \
std::abort(); \
} while (false)
#endif // NDEBUG
#endif // XCHAINER_NEVER_REACH
| #pragma once
#include <cassert>
#ifdef NDEBUG
#define XCHAINER_DEBUG false
#else // NDEBUG
#define XCHAINER_DEBUG true
#endif // NDEBUG
#define XCHAINER_ASSERT(...) \
do { \
if (XCHAINER_DEBUG) { \
(void)(false && (__VA_ARGS__)); /* maybe unused */ \
assert(__VA_ARGS__); \
} \
} while (false)
#ifndef XCHAINER_HOST_DEVICE
#ifdef __CUDACC__
#define XCHAINER_HOST_DEVICE __host__ __device__
#else // __CUDA__
#define XCHAINER_HOST_DEVICE
#endif // __CUDACC__
#endif // XCHAINER_HOST_DEVICE
#ifndef XCHAINER_NEVER_REACH
#ifdef NDEBUG
#include <cstdlib>
#define XCHAINER_NEVER_REACH() (std::abort())
#else // NDEBUG
#include <cassert>
#define XCHAINER_NEVER_REACH() \
do { \
assert(false); /* NOLINT(cert-dcl03-c) */ \
std::abort(); \
} while (false)
#endif // NDEBUG
#endif // XCHAINER_NEVER_REACH
|
Add default calculation of horizontal & vertical position. | #ifndef __STARTUP_H__
#define __STARTUP_H__
#include "types.h"
#ifndef X
#define X(x) ((x) + 0x81)
#endif
#ifndef Y
#define Y(y) ((y) + 0x2c)
#endif
extern int frameCount;
extern int lastFrameCount;
extern struct List *VBlankEvent;
typedef struct Effect {
/* AmigaOS is active during this step. Loads resources from disk. */
void (*Load)(void);
/* Frees all resources allocated by "Load" step. */
void (*UnLoad)(void);
/*
* Does all initialization steps required to launch the effect.
* 1) Allocate required memory.
* 2) Run all precalc routines.
* 2) Generate copper lists.
* 3) Set up interrupts and DMA channels.
*/
void (*Init)(void);
/* Frees all resources allocated by "Init" step. */
void (*Kill)(void);
/* Renders single frame of an effect. */
void (*Render)(void);
/* Handles all events and returns false to break the loop. */
bool (*HandleEvent)(void);
} EffectT;
#endif
| #ifndef __STARTUP_H__
#define __STARTUP_H__
#include "types.h"
#ifndef X
#define X(x) ((x) + 0x81)
#endif
#ifndef HP
#define HP(x) (X(x) / 2)
#endif
#ifndef Y
#define Y(y) ((y) + 0x2c)
#endif
#ifndef VP
#define VP(y) (Y(y) & 255)
#endif
extern int frameCount;
extern int lastFrameCount;
extern struct List *VBlankEvent;
typedef struct Effect {
/* AmigaOS is active during this step. Loads resources from disk. */
void (*Load)(void);
/* Frees all resources allocated by "Load" step. */
void (*UnLoad)(void);
/*
* Does all initialization steps required to launch the effect.
* 1) Allocate required memory.
* 2) Run all precalc routines.
* 2) Generate copper lists.
* 3) Set up interrupts and DMA channels.
*/
void (*Init)(void);
/* Frees all resources allocated by "Init" step. */
void (*Kill)(void);
/* Renders single frame of an effect. */
void (*Render)(void);
/* Handles all events and returns false to break the loop. */
bool (*HandleEvent)(void);
} EffectT;
#endif
|
Add IPL_ and IST_ constants in preparation for the Amiga ISA-kit | /* $NetBSD: psl.h,v 1.7 1994/10/26 02:06:31 cgd Exp $ */
#ifndef _MACHINE_PSL_H_
#define _MACHINE_PSL_H_
#include <m68k/psl.h>
#endif
| /* $NetBSD: psl.h,v 1.7 1994/10/26 02:06:31 cgd Exp $ */
#ifndef _MACHINE_PSL_H_
#define _MACHINE_PSL_H_
/* Interrupt priority `levels'; not mutually exclusive. */
#define IPL_NONE -1
#define IPL_BIO 3 /* block I/O */
#define IPL_NET 3 /* network */
#define IPL_TTY 4 /* terminal */
#define IPL_CLOCK 4 /* clock */
#define IPL_IMP 4 /* memory allocation */
/* Interrupt sharing types. */
#define IST_NONE 0 /* none */
#define IST_PULSE 1 /* pulsed */
#define IST_EDGE 2 /* edge-triggered */
#define IST_LEVEL 3 /* level-triggered */
#include <m68k/psl.h>
#endif
|
FIX dllcondition to use the correct macro name | #pragma once
#define DLLEXPORT
#ifdef DLLEXPORT
#define DLL_OPERATION __declspec(dllexport)
#endif
#include <iostream>
| #pragma once
#ifdef RESOURCELIB_EXPORTS
#define DLL_OPERATION __declspec(dllexport)
#else
#define DLL_OPERATION __declspec(dllimport)
#endif
#include <iostream>
|
Test fix -- use captured call result instead of hardcoded %2. | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
// Don't include mm_malloc.h, it's system specific.
#define __MM_MALLOC_H
#include <immintrin.h>
int test_bit_scan_forward(int a) {
return _bit_scan_forward(a);
// CHECK: @test_bit_scan_forward
// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(
// CHECK: ret i32 %[[call]]
}
int test_bit_scan_reverse(int a) {
return _bit_scan_reverse(a);
// CHECK: %[[call:.*]] = call i32 @llvm.ctlz.i32(
// CHECK: %[[sub:.*]] = sub nsw i32 31, %2
// CHECK: ret i32 %[[sub]]
}
| // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
// Don't include mm_malloc.h, it's system specific.
#define __MM_MALLOC_H
#include <immintrin.h>
int test_bit_scan_forward(int a) {
return _bit_scan_forward(a);
// CHECK: @test_bit_scan_forward
// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(
// CHECK: ret i32 %[[call]]
}
int test_bit_scan_reverse(int a) {
return _bit_scan_reverse(a);
// CHECK: %[[call:.*]] = call i32 @llvm.ctlz.i32(
// CHECK: %[[sub:.*]] = sub nsw i32 31, %[[call]]
// CHECK: ret i32 %[[sub]]
}
|
Add copyright and license header. | #import <Cocoa/Cocoa.h>
@interface WildcardPattern : NSObject {
NSString* pattern_;
}
- (id) initWithString: (NSString*) s;
- (BOOL) isMatch: (NSString*) s;
@end
| /*
* Copyright (c) 2006 KATO Kazuyoshi <kzys@8-p.info>
* This source code is released under the MIT license.
*/
#import <Cocoa/Cocoa.h>
@interface WildcardPattern : NSObject {
NSString* pattern_;
}
- (id) initWithString: (NSString*) s;
- (BOOL) isMatch: (NSString*) s;
@end
|
Correct casing of EXPORT.h import | #pragma once
#include "Export.h"
#include <set>
#include <vector>
using namespace std;
class DLLEXPORT SetFunctions {
public:
static set<int> set_union_two(set<int>& s1, set<int>& s2);
static set<int> set_intersect_two(set<int>& s1, set<int>& s2);
static set<int> set_intersect_three(set<int>& s1, set<int>& s2, set<int>& s3);
};
| #pragma once
#include "EXPORT.h"
#include <set>
#include <vector>
using namespace std;
class DLLEXPORT SetFunctions {
public:
static set<int> set_union_two(set<int>& s1, set<int>& s2);
static set<int> set_intersect_two(set<int>& s1, set<int>& s2);
static set<int> set_intersect_three(set<int>& s1, set<int>& s2, set<int>& s3);
};
|
Allow data to contain also lowercase hex characters. | /* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "hex-dec.h"
void dec2hex(unsigned char *hexstr, uintmax_t dec, unsigned int hexstr_size)
{
unsigned int i;
for (i = 0; i < hexstr_size; i++) {
unsigned int value = dec & 0x0f;
if (value < 10)
hexstr[hexstr_size-i-1] = value + '0';
else
hexstr[hexstr_size-i-1] = value - 10 + 'A';
dec >>= 4;
}
}
uintmax_t hex2dec(const unsigned char *data, unsigned int len)
{
unsigned int i;
uintmax_t value = 0;
for (i = 0; i < len; i++) {
value = value*0x10;
if (data[i] >= '0' && data[i] <= '9')
value += data[i]-'0';
else if (data[i] >= 'A' && data[i] <= 'F')
value += data[i]-'A' + 10;
else
return 0;
}
return value;
}
| /* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "hex-dec.h"
void dec2hex(unsigned char *hexstr, uintmax_t dec, unsigned int hexstr_size)
{
unsigned int i;
for (i = 0; i < hexstr_size; i++) {
unsigned int value = dec & 0x0f;
if (value < 10)
hexstr[hexstr_size-i-1] = value + '0';
else
hexstr[hexstr_size-i-1] = value - 10 + 'A';
dec >>= 4;
}
}
uintmax_t hex2dec(const unsigned char *data, unsigned int len)
{
unsigned int i;
uintmax_t value = 0;
for (i = 0; i < len; i++) {
value = value*0x10;
if (data[i] >= '0' && data[i] <= '9')
value += data[i]-'0';
else if (data[i] >= 'A' && data[i] <= 'F')
value += data[i]-'A' + 10;
else if (data[i] >= 'a' && data[i] <= 'f')
value += data[i]-'a' + 10;
else
return 0;
}
return value;
}
|
Add a header for use from C++ | #include <stdio.h>
#include <stdint.h>
extern "C" void RSFatalError(char *message);
extern "C" void* RSMallocOrDie(size_t size);
extern "C" void* RSCallocOrDie(size_t size);
extern "C" void RSFReadOrDie(void *dest, size_t size, FILE *file);
extern "C" void RSFWriteOrDie(void *data, size_t size, FILE *file);
extern "C" FILE* RSFOpenOrDie(char *path, char *mode);
extern "C" void RSFCloseOrDie(FILE *file);
extern "C" void* RSReadFileOrDie(char *path, uint32_t *size);
extern "C" int8_t RSReadInt8(uint8_t *data, uint32_t *offset);
extern "C" uint8_t RSReadUInt8(uint8_t *data, uint32_t *offset);
extern "C" int16_t RSReadInt16(uint8_t *data, uint32_t *offset);
extern "C" uint16_t RSReadUInt16(uint8_t *data, uint32_t *offset);
extern "C" int32_t RSReadInt32(uint8_t *data, uint32_t *offset);
extern "C" uint32_t RSReadUInt32(uint8_t *data, uint32_t *offset);
extern "C" int64_t RSReadInt64(uint8_t *data, uint32_t *offset);
extern "C" uint64_t RSReadUInt64(uint8_t *data, uint32_t *offset);
| |
Add TODO. But first we need to parse mime.cache | #ifndef MAGICMATCHER_P_H
#define MAGICMATCHER_P_H
#include "magicmatcher.h"
#include "qmimetype.h"
#include <QtCore/QFileInfo>
QT_BEGIN_NAMESPACE
class FileMatchContext
{
Q_DISABLE_COPY(FileMatchContext)
public:
// Max data to be read from a file
enum { MaxData = 2500 };
explicit FileMatchContext(const QFileInfo &fi);
inline QString fileName() const { return m_fileName; }
// Return (cached) first MaxData bytes of file
QByteArray data();
private:
const QFileInfo m_fileInfo;
const QString m_fileName;
enum State {
// File cannot be read/does not exist
NoDataAvailable,
// Not read yet
DataNotRead,
// Available
DataRead
} m_state;
QByteArray m_data;
};
QT_END_NAMESPACE
#endif // MAGICMATCHER_P_H
| #ifndef MAGICMATCHER_P_H
#define MAGICMATCHER_P_H
#include "magicmatcher.h"
#include "qmimetype.h"
#include <QtCore/QFileInfo>
QT_BEGIN_NAMESPACE
class FileMatchContext
{
Q_DISABLE_COPY(FileMatchContext)
public:
// Max data to be read from a file
// TODO: hardcoded values are no good, this should be done on demand
// in order to respect the spec. Use QIODevice-based code from KMimeMagicRule.
enum { MaxData = 2500 };
explicit FileMatchContext(const QFileInfo &fi);
inline QString fileName() const { return m_fileName; }
// Return (cached) first MaxData bytes of file
QByteArray data();
private:
const QFileInfo m_fileInfo;
const QString m_fileName;
enum State {
// File cannot be read/does not exist
NoDataAvailable,
// Not read yet
DataNotRead,
// Available
DataRead
} m_state;
QByteArray m_data;
};
QT_END_NAMESPACE
#endif // MAGICMATCHER_P_H
|
Fix ccp_io_write() not being static as it should | /**
* @file
* @brief Tools to work with registers
*/
//@{
#ifndef AVARIX_REGISTER_H__
#define AVARIX_REGISTER_H__
#include <avr/io.h>
/** @brief Set a register with I/O CCP disabled
*
* Interrupts are not disabled during the process.
*
* @note This can be achieved in less cycles for some I/O registers but this way
* is generic.
*/
inline void ccp_io_write(volatile uint8_t* addr, uint8_t value)
{
asm volatile (
"out %0, %1\n\t"
"st Z, %3\n\t"
:
: "i" (&CCP)
, "r" (CCP_IOREG_gc)
, "z" ((uint16_t)addr)
, "r" (value)
);
}
#endif
| /**
* @file
* @brief Tools to work with registers
*/
//@{
#ifndef AVARIX_REGISTER_H__
#define AVARIX_REGISTER_H__
#include <avr/io.h>
/** @brief Set a register with I/O CCP disabled
*
* Interrupts are not disabled during the process.
*
* @note This can be achieved in less cycles for some I/O registers but this way
* is generic.
*/
static inline void ccp_io_write(volatile uint8_t* addr, uint8_t value)
{
asm volatile (
"out %0, %1\n\t"
"st Z, %3\n\t"
:
: "i" (&CCP)
, "r" (CCP_IOREG_gc)
, "z" ((uint16_t)addr)
, "r" (value)
);
}
#endif
|
Remove UIKit usage by replacing it with Foundation | //
// msgpack.h
// msgpack
//
// Created by Ricardo Pereira on 13/10/2017.
//
//
#import <UIKit/UIKit.h>
//! Project version number for msgpack.
FOUNDATION_EXPORT double msgpackVersionNumber;
//! Project version string for msgpack.
FOUNDATION_EXPORT const unsigned char msgpackVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <msgpack/PublicHeader.h>
#import "MessagePack.h"
| //
// msgpack.h
// msgpack
//
// Created by Ricardo Pereira on 13/10/2017.
//
//
#import <Foundation/Foundation.h>
//! Project version number for msgpack.
FOUNDATION_EXPORT double msgpackVersionNumber;
//! Project version string for msgpack.
FOUNDATION_EXPORT const unsigned char msgpackVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <msgpack/PublicHeader.h>
#import "MessagePack.h"
|
Add a test for `env_get` | #include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <env.h>
int main(int argc, char** argv) {
char** env = malloc(2 * sizeof(char*));
char* result;
env[0] = "NAME=value";
env[1] = NULL;
result = env_get(env, "NAME");
printf("NAME=%s\n", result);
assert(strcmp(result, "value") == 0);
return 0;
}
| |
Remove nil tokens from conf | //
// config.h
// IRCCloud
//
// Created by Sam Steele on 7/13/13.
// Copyright (c) 2013 IRCCloud, Ltd. All rights reserved.
//
#ifndef IRCCloud_config_h
#define IRCCloud_config_h
#define HOCKEYAPP_TOKEN nil
#define CRASHLYTICS_TOKEN nil
#define CRASHLYTICS_SECRET nil
#endif
| //
// config.h
// IRCCloud
//
// Created by Sam Steele on 7/13/13.
// Copyright (c) 2013 IRCCloud, Ltd. All rights reserved.
//
#ifndef IRCCloud_config_h
#define IRCCloud_config_h
#endif
|
Fix a soundness bug in tagged unions that have fields larger than one word. This fix uses memset to clear such fields, although we could probably optimize this if needed. | #include "../small1/testharness.h"
// NUMERRORS 1
union {
struct {
int *a, *b;
} f1;
int f2;
} __TAGGED u;
int i;
int main() {
u.f2 = 5; // now u.f1.a = 5
u.f1.b = &i; // now the tag says that u.f1 is active
i = * u.f1.a; //ERROR(1): Null-pointer
}
| #include "../small1/testharness.h"
// NUMERRORS 1
union {
struct {
int *a, *b;
} f1;
int f2;
} __TAGGED u;
int i;
int main() {
u.f2 = 5; // now u.f1.a = 5
u.f1.b = &i; // now the tag says that u.f1 is active
i = * u.f1.a; //ERROR(1): Null pointer
}
|
Add a utility header for virvo::Message. | // Virvo - Virtual Reality Volume Rendering
// Copyright (C) 1999-2003 University of Stuttgart, 2004-2005 Brown University
// Contact: Jurgen P. Schulze, jschulze@ucsd.edu
//
// This file is part of Virvo.
//
// Virvo 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 (see license.txt); if not, write to the
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef VV_PRIVATE_MESSAGES_H
#define VV_PRIVATE_MESSAGES_H
#include "../vvparam.h"
#include "../vvrenderer.h"
#include "../vvvecmath.h"
#include <istream>
#include <ostream>
namespace virvo
{
namespace messages
{
struct CameraMatrix
{
// The model-view matrix
vvMatrix view;
// The projection matrix
vvMatrix proj;
CameraMatrix()
{
}
CameraMatrix(vvMatrix const& view, vvMatrix const& proj)
: view(view)
, proj(proj)
{
}
template<class A>
void serialize(A& a, unsigned /*version*/)
{
a & view;
a & proj;
}
};
struct Param
{
// The name of the parameter
vvRenderState::ParameterType name;
// The actual parameter
vvParam value;
Param()
: name(static_cast<vvRenderState::ParameterType>(0))
, value()
{
}
Param(vvRenderState::ParameterType name, vvParam const& value)
: name(name)
, value(value)
{
}
template<class A>
void serialize(A& a, unsigned /*version*/)
{
int t = 0;
a & t; /*name*/
a & value;
name = static_cast<vvRenderState::ParameterType>(t);
}
};
struct WindowResize
{
int w;
int h;
WindowResize()
{
}
WindowResize(int w, int h)
: w(w)
, h(h)
{
}
template<class A>
void serialize(A& a, unsigned /*version*/)
{
a & w;
a & h;
}
};
} // namespace messages
} // namespace virvo
#endif
| |
Change the version number and date. | /* This string is written to the output primary header as CAL_VER. */
# define STIS_CAL_VER "2.28 (09-March-2010) cfitsio test"
| /* This string is written to the output primary header as CAL_VER. */
# define STIS_CAL_VER "2.29 (24-March-2010) cfitsio test"
|
Fix test to pass when the directory name has lld in it. | // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
// AS_LINK-LABEL: clang
// AS_LINK: "-cc1as"
// AS_LINK-LABEL: lld
// AS_LINK: "-flavor" "gnu" "-target" "amdgcn--amdhsa"
// REQUIRES: clang-driver
| // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
// AS_LINK: /clang
// AS_LINK-SAME: "-cc1as"
// AS_LINK: /lld
// AS_LINK-SAME: "-flavor" "gnu" "-target" "amdgcn--amdhsa"
|
Increase XDICT_MAXLENGTH from 9+1 to 15+1. |
#ifndef H_XDICTLIB
#define H_XDICTLIB
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
/*
The |xdict| interface.
*/
#define XDICT_MAXLENGTH 10 /* 0..9 characters */
struct xdict {
struct word_entry *words[XDICT_MAXLENGTH];
size_t cap[XDICT_MAXLENGTH];
size_t len[XDICT_MAXLENGTH];
int sorted;
};
struct word_entry {
char *word;
};
void xdict_init(struct xdict *d);
int xdict_load(struct xdict *d, const char *fname);
int xdict_addword(struct xdict *d, const char *word, int len);
int xdict_remword(struct xdict *d, const char *word, int len);
int xdict_remmatch(struct xdict *d, const char *pat, int len);
void xdict_sort(struct xdict *d);
int xdict_save(struct xdict *d, const char *fname);
void xdict_free(struct xdict *d);
int xdict_find(struct xdict *d, const char *pattern,
int (*f)(const char *, void *), void *info);
int xdict_match_simple(const char *w, const char *p);
int xdict_match(const char *w, const char *p);
#ifdef __cplusplus
}
#endif
#endif
|
#ifndef H_XDICTLIB
#define H_XDICTLIB
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
/*
The |xdict| interface.
*/
#define XDICT_MAXLENGTH 16 /* 0..15 characters */
struct xdict {
struct word_entry *words[XDICT_MAXLENGTH];
size_t cap[XDICT_MAXLENGTH];
size_t len[XDICT_MAXLENGTH];
int sorted;
};
struct word_entry {
char *word;
};
void xdict_init(struct xdict *d);
int xdict_load(struct xdict *d, const char *fname);
int xdict_addword(struct xdict *d, const char *word, int len);
int xdict_remword(struct xdict *d, const char *word, int len);
int xdict_remmatch(struct xdict *d, const char *pat, int len);
void xdict_sort(struct xdict *d);
int xdict_save(struct xdict *d, const char *fname);
void xdict_free(struct xdict *d);
int xdict_find(struct xdict *d, const char *pattern,
int (*f)(const char *, void *), void *info);
int xdict_match_simple(const char *w, const char *p);
int xdict_match(const char *w, const char *p);
#ifdef __cplusplus
}
#endif
#endif
|
Add inner struct iteration example | #include <stdio.h>
typedef struct {
int **y;
int *x;
} _inner;
typedef _inner inner;
typedef struct {
int *g;
inner in[3];
} outer;
void traverse(outer *o) {
static int sss = 5;
inner *in = &(o->in[0]);
for (size_t i = 0; i < 3; i++) {
in->x = &sss;
in++;
sss += 3;
}
}
int main(int argc, char *argv[])
{
outer o2;
traverse(&o2);
return 0;
}
| |
Increment version number to 1.49 | #pragma once
// const float in a header file can lead to duplication of the storage
// but I don't really care in this case. Just don't do it with a header
// that is included hundreds of times.
const float kCurrentVersion = 1.48f;
// Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version
// increment that won't trigger the new-version checks, handy for minor
// releases that I don't want to bother users about.
//#define VERSION_SUFFIX 'b'
| #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.49f;
// Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version
// increment that won't trigger the new-version checks, handy for minor
// releases that I don't want to bother users about.
//#define VERSION_SUFFIX 'b'
|
Make the registers address point to volatile memory. | /*
* copyright 2015 wink saville
*
* licensed under the apache license, version 2.0 (the "license");
* you may not use this file except in compliance with the license.
* you may obtain a copy of the license at
*
* http://www.apache.org/licenses/license-2.0
*
* unless required by applicable law or agreed to in writing, software
* distributed under the license is distributed on an "as is" basis,
* without warranties or conditions of any kind, either express or implied.
* see the license for the specific language governing permissions and
* limitations under the license.
*/
#include "poweroff.h"
#include "inttypes.h"
void poweroff(void) {
uint32_t* pUnlockResetReg = (uint32_t*)0x10000020;
uint32_t* pResetReg = (uint32_t*)0x10000040;
// If qemu is executed with -no-reboot option then
// resetting the board will cause qemu to exit
// and it won't be necessary to ctrl-a, x to exit.
// See http://lists.nongnu.org/archive/html/qemu-discuss/2015-10/msg00057.html
// For arm926ej-s you unlock the reset register
// then reset the board, I'm resetting to level 6
*pUnlockResetReg = 0xA05F;
*pResetReg = 0x106;
}
| /*
* copyright 2015 wink saville
*
* licensed under the apache license, version 2.0 (the "license");
* you may not use this file except in compliance with the license.
* you may obtain a copy of the license at
*
* http://www.apache.org/licenses/license-2.0
*
* unless required by applicable law or agreed to in writing, software
* distributed under the license is distributed on an "as is" basis,
* without warranties or conditions of any kind, either express or implied.
* see the license for the specific language governing permissions and
* limitations under the license.
*/
#include "poweroff.h"
#include "inttypes.h"
void poweroff(void) {
volatile uint32_t* pUnlockResetReg = (uint32_t*)0x10000020;
volatile uint32_t* pResetReg = (uint32_t*)0x10000040;
// If qemu is executed with -no-reboot option then
// resetting the board will cause qemu to exit
// and it won't be necessary to ctrl-a, x to exit.
// See http://lists.nongnu.org/archive/html/qemu-discuss/2015-10/msg00057.html
// For arm926ej-s you unlock the reset register
// then reset the board, I'm resetting to level 6
*pUnlockResetReg = 0xA05F;
*pResetReg = 0x106;
}
|
Remove unused methods in File | #ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include "Partition.h"
#include <vector>
#include <string>
class Directory;
enum class FileType {
File, Directory
};
class File : public HDDBytes {
std::string _name;
public:
std::string getName(){return _name;}
//virtual void setName(const std::string& name) = 0;
//virtual Directory * getParent() = 0; // null => root directory
virtual FileType getType();
virtual Directory * dir() {return nullptr;};
};
class Directory : public virtual File {
public :
virtual std::vector<std::string> getFilesName () = 0;
FileType getType();
virtual File * operator[](const std::string& name) = 0; // nullptr means it does not exists
virtual Directory * dir() {return this;};
};
class FileSystem {
protected :
Partition* _part;
public:
explicit FileSystem (Partition * part);
virtual Directory* getRoot() = 0;
//virtual File* operator [] (const std::string& path) = 0; //return null when path is not valid
};
#endif
| #ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include "Partition.h"
#include <vector>
#include <string>
class Directory;
enum class FileType {
File, Directory
};
class File : public HDDBytes {
public:
virtual FileType getType();
virtual Directory * dir() {return nullptr;};
};
class Directory : public virtual File {
public :
virtual std::vector<std::string> getFilesName () = 0;
FileType getType();
virtual File * operator[](const std::string& name) = 0; // nullptr means it does not exists
virtual Directory * dir() {return this;};
};
class FileSystem {
protected :
Partition* _part;
public:
explicit FileSystem (Partition * part);
virtual Directory* getRoot() = 0;
//virtual File* operator [] (const std::string& path) = 0; //return null when path is not valid
};
#endif
|
Add a member for target code generation. | #ifndef SCC_SYMBOL_HEADER
#define SCC_SYMBOL_HEADER
#include "syntax.h"
typedef struct Symbol
{
int level;
char *name;
// used in semantic analysis
Syntax * declaration;
// used in intermediate code generation
char *var_name;
} Symbol;
Symbol * symbol_new();
void symbol_delete(Symbol * symbol);
#endif | #ifndef SCC_SYMBOL_HEADER
#define SCC_SYMBOL_HEADER
#include "syntax.h"
typedef struct Symbol
{
int level;
char *name;
union
{
// used in semantic analysis
Syntax * declaration;
// used in intermediate code generation
char *var_name;
// used in target code generation
int address;
};
} Symbol;
Symbol * symbol_new();
void symbol_delete(Symbol * symbol);
#endif |
Allow creating EntityId directly from int64_t | #pragma once
#include <cstdint>
#include "halley/bytes/config_node_serializer.h"
namespace Halley {
class World;
struct alignas(8) EntityId {
int64_t value;
EntityId() : value(-1) {}
explicit EntityId(const String& str);
bool isValid() const { return value != -1; }
bool operator==(const EntityId& other) const { return value == other.value; }
bool operator!=(const EntityId& other) const { return value != other.value; }
bool operator<(const EntityId& other) const { return value < other.value; }
bool operator>(const EntityId& other) const { return value > other.value; }
bool operator<=(const EntityId& other) const { return value <= other.value; }
bool operator>=(const EntityId& other) const { return value >= other.value; }
String toString() const;
void serialize(Serializer& s) const;
void deserialize(Deserializer& s);
};
template <>
class ConfigNodeSerializer<EntityId> {
public:
ConfigNode serialize(EntityId id, const EntitySerializationContext& context);
EntityId deserialize(const EntitySerializationContext& context, const ConfigNode& node);
};
}
namespace std {
template<>
struct hash<Halley::EntityId>
{
size_t operator()(const Halley::EntityId& v) const noexcept
{
return std::hash<int64_t>()(v.value);
}
};
}
| #pragma once
#include <cstdint>
#include "halley/bytes/config_node_serializer.h"
namespace Halley {
class World;
struct alignas(8) EntityId {
int64_t value;
EntityId(int64_t value = -1) : value(value) {}
explicit EntityId(const String& str);
bool isValid() const { return value != -1; }
bool operator==(const EntityId& other) const { return value == other.value; }
bool operator!=(const EntityId& other) const { return value != other.value; }
bool operator<(const EntityId& other) const { return value < other.value; }
bool operator>(const EntityId& other) const { return value > other.value; }
bool operator<=(const EntityId& other) const { return value <= other.value; }
bool operator>=(const EntityId& other) const { return value >= other.value; }
String toString() const;
void serialize(Serializer& s) const;
void deserialize(Deserializer& s);
};
template <>
class ConfigNodeSerializer<EntityId> {
public:
ConfigNode serialize(EntityId id, const EntitySerializationContext& context);
EntityId deserialize(const EntitySerializationContext& context, const ConfigNode& node);
};
}
namespace std {
template<>
struct hash<Halley::EntityId>
{
size_t operator()(const Halley::EntityId& v) const noexcept
{
return std::hash<int64_t>()(v.value);
}
};
}
|
Add SessionLog to remember session-level kv | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#ifndef BRPC_SESSION_LOG_H
#define BRPC_SESSION_LOG_H
#include "butil/containers/flat_map.h"
namespace brpc {
class SessionLog {
public:
class Formatter {
public:
virtual ~Formatter() {}
virtual void Print(std::ostream&, const SessionLog&) = 0;
};
typedef butil::FlatMap<std::string, std::string> Map;
typedef Map::const_iterator Iterator;
SessionLog() {}
// Exchange internal fields with another SessionLog.
void Swap(SessionLog &rhs) { _entries.swap(rhs._entries); }
// Reset internal fields as if they're just default-constructed.
void Clear() { _entries.clear(); }
// Get value of a key(case-sensitive)
// Return pointer to the value, NULL on not found.
const std::string* Get(const char* key) const { return _entries.seek(key); }
const std::string* Get(const std::string& key) const { return _entries.seek(key); }
// Set value of a key
void Set(const std::string& key, const std::string& value) { GetOrAdd(key) = value; }
void Set(const std::string& key, const char* value) { GetOrAdd(key) = value; }
// Convert other types to string as well
template <typename T>
void Set(const std::string& key, const T& value) { GetOrAdd(key) = std::to_string(value); }
// Remove a key
void Remove(const char* key) { _entries.erase(key); }
void Remove(const std::string& key) { _entries.erase(key); }
// Get iterators to iterate key/value
Iterator Begin() const { return _entries.begin(); }
Iterator End() const { return _entries.end(); }
// number of key/values
size_t Count() const { return _entries.size(); }
private:
std::string& GetOrAdd(const std::string& key) {
if (!_entries.initialized()) {
_entries.init(29);
}
return _entries[key];
}
Map _entries;
};
} // namespace brpc
#endif // BRPC_SESSION_LOG_H
| |
Update the comment for Graph::GetEdge. | #include "base/base.h"
class Graph {
public:
typedef int16_t Node;
typedef int16_t Degree;
Graph(Node order, Degree degree)
: order_(order),
degree_(degree),
edges_(order * degree, -1) {}
inline Node order() { return order_; }
inline Degree degree() { return degree_; }
// Returns the de
Node GetEdge(Node order_index, Degree degree_index);
private:
const Node order_;
const Degree degree_;
vector<Node> edges_;
};
| #include "base/base.h"
class Graph {
public:
typedef int16_t Node;
typedef int16_t Degree;
Graph(Node order, Degree degree)
: order_(order),
degree_(degree),
edges_(order * degree, -1) {}
inline Node order() { return order_; }
inline Degree degree() { return degree_; }
// Returns the order_index node's degree_index-th edge's node. Returns -1 if
// there is no such an edge.
Node GetEdge(Node order_index, Degree degree_index);
private:
const Node order_;
const Degree degree_;
vector<Node> edges_;
};
|
Change MAX_BUFFER_SIZE to something that is 32 bit aligned. | #ifndef CJET_CONFIG_H
#define CJET_CONFIG_H
#define SERVER_PORT \
11122
#define LISTEN_BACKLOG \
40
#define MAX_MESSAGE_SIZE \
250
/* Linux specific configs */
#define MAX_EPOLL_EVENTS \
100
#endif
| #ifndef CJET_CONFIG_H
#define CJET_CONFIG_H
#define SERVER_PORT \
11122
#define LISTEN_BACKLOG \
40
#define MAX_MESSAGE_SIZE \
256
/* Linux specific configs */
#define MAX_EPOLL_EVENTS \
100
#endif
|
Add signature for sprintf function | #ifndef _STDIO_H_
#define _STDIO_H_
/**
* \file stdio.h
* \brief This file handle the output to the terminal for the user.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EOF
#define EOF -1 /*!< End of file value */
#endif
/**
* \brief Print a formatted string
*
* \param[in] format Format of the string
* \param[in] ... Arguments for format specification
*
* \return Number of characters written
*/
int printf(const char* __restrict format, ...);
/**
* \brief Print a single char
*
* \param c Character to print
*
* \return The character written
*/
int putchar(int c);
/**
* \brief Print a string
*
* \param string The string to print
*
* \return The number of characters written
*/
int puts(const char* string);
#ifdef __cplusplus
}
#endif
#endif
| #ifndef _STDIO_H_
#define _STDIO_H_
/**
* \file stdio.h
* \brief This file handle the output to the terminal for the user.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EOF
#define EOF -1 /*!< End of file value */
#endif
/**
* \brief Print a formatted string
*
* \param[in] format Format of the string
* \param[in] ... Arguments for format specification
*
* \return Number of characters written
*/
int printf(const char* __restrict format, ...);
/**
* \brief Print a formatted string into another string
*
* \param[out] out String we want to write in
* \param[in] format Format of the string
* \param[in] ... Arguments for format specification
*
* \return Number of characters written
*/
int sprintf(char* out, const char* __restrict format, ...);
/**
* \brief Print a single char
*
* \param c Character to print
*
* \return The character written
*/
int putchar(int c);
/**
* \brief Print a string
*
* \param string The string to print
*
* \return The number of characters written
*/
int puts(const char* string);
#ifdef __cplusplus
}
#endif
#endif
|
Convert ConsCell from class to POD. | #ifndef MCLISP_CONS_H_
#define MCLISP_CONS_H_
#include <string>
namespace mclisp
{
class ConsCell
{
public:
ConsCell(): car(nullptr), cdr(nullptr) {}
ConsCell(ConsCell* car, ConsCell* cdr): car(car), cdr(cdr) {}
ConsCell* car;
ConsCell* cdr;
};
bool operator==(const ConsCell& lhs, const ConsCell& rhs);
bool operator!=(const ConsCell& lhs, const ConsCell& rhs);
bool operator< (const ConsCell& lhs, const ConsCell& rhs);
bool operator> (const ConsCell& lhs, const ConsCell& rhs);
bool operator<=(const ConsCell& lhs, const ConsCell& rhs);
bool operator>=(const ConsCell& lhs, const ConsCell& rhs);
std::ostream& operator<<(std::ostream& os, const ConsCell& cons);
extern const ConsCell* kNil;
extern const ConsCell* kT;
void HackToFixNil();
const ConsCell* MakeSymbol(const std::string& name);
const ConsCell* MakeCons(const ConsCell* car, const ConsCell* cdr);
inline bool Symbolp(const ConsCell* c);
inline bool Consp(const ConsCell* c);
const std::string SymbolName(const ConsCell* symbol);
} // namespace mclisp
#endif // MCLISP_CONS_H_
| #ifndef MCLISP_CONS_H_
#define MCLISP_CONS_H_
#include <string>
namespace mclisp
{
struct ConsCell
{
ConsCell* car;
ConsCell* cdr;
};
typedef struct ConsCell ConsCell;
bool operator==(const ConsCell& lhs, const ConsCell& rhs);
bool operator!=(const ConsCell& lhs, const ConsCell& rhs);
bool operator< (const ConsCell& lhs, const ConsCell& rhs);
bool operator> (const ConsCell& lhs, const ConsCell& rhs);
bool operator<=(const ConsCell& lhs, const ConsCell& rhs);
bool operator>=(const ConsCell& lhs, const ConsCell& rhs);
std::ostream& operator<<(std::ostream& os, const ConsCell& cons);
extern const ConsCell* kNil;
extern const ConsCell* kT;
void HackToFixNil();
const ConsCell* MakeSymbol(const std::string& name);
const ConsCell* MakeCons(const ConsCell* car, const ConsCell* cdr);
inline bool Symbolp(const ConsCell* c);
inline bool Consp(const ConsCell* c);
const std::string SymbolName(const ConsCell* symbol);
} // namespace mclisp
#endif // MCLISP_CONS_H_
|
Add newline end end of usage | #include <Python.h>
int main(int argc, char *argv[]) {
PyObject *expr[3];
int i, s, e, r;
char *res;
if(argc<5) {
fprintf(stderr,"Usage: <string> <start> <end> <repeat>\n\n\
Print string[start:end]*repeat");
exit(0);
}
s = atoi(argv[2]);
e = atoi(argv[3]);
r = atoi(argv[4]);
expr[0] = PyString_FromString(argv[1]);
expr[1] = PySequence_GetSlice(expr[0], s, e);
expr[2] = PySequence_Repeat(expr[1], r);
res=PyString_AsString(expr[2]);
printf("'%s'\n",res);
for(i=0; i<3; i++) Py_CLEAR(expr[i]);
return 0;
}
| #include <Python.h>
int main(int argc, char *argv[]) {
PyObject *expr[3];
int i, s, e, r;
char *res;
if(argc<5) {
fprintf(stderr,"Usage: <string> <start> <end> <repeat>\n\n\
Print string[start:end]*repeat\n");
exit(0);
}
s = atoi(argv[2]);
e = atoi(argv[3]);
r = atoi(argv[4]);
expr[0] = PyString_FromString(argv[1]);
expr[1] = PySequence_GetSlice(expr[0], s, e);
expr[2] = PySequence_Repeat(expr[1], r);
res=PyString_AsString(expr[2]);
printf("'%s'\n",res);
for(i=0; i<3; i++) Py_CLEAR(expr[i]);
return 0;
}
|
Add List & ListNode struct declarations | #include <stdlib.h>
#ifndef __LIST_H__
#define __LIST_H__
#endif | #include <stdlib.h>
#ifndef __LIST_H__
#define __LIST_H__
struct ListNode;
struct List;
typedef struct ListNode ListNode;
typedef struct List List;
#endif |
Test that we print MS keyword attributes without a __declspec(...) adornment. | // RUN: %clang_cc1 %s -ast-print -fms-extensions | FileCheck %s
// FIXME: we need to fix the "BoolArgument<"IsMSDeclSpec">"
// hack in Attr.td for attribute "Aligned".
// CHECK: int x __attribute__((aligned(4, 0)));
int x __attribute__((aligned(4)));
// FIXME: Print this at a valid location for a __declspec attr.
// CHECK: int y __declspec(align(4, 1));
__declspec(align(4)) int y;
// CHECK: void foo() __attribute__((const));
void foo() __attribute__((const));
// CHECK: void bar() __attribute__((__const));
void bar() __attribute__((__const));
| // RUN: %clang_cc1 %s -ast-print -fms-extensions | FileCheck %s
// FIXME: we need to fix the "BoolArgument<"IsMSDeclSpec">"
// hack in Attr.td for attribute "Aligned".
// CHECK: int x __attribute__((aligned(4, 0)));
int x __attribute__((aligned(4)));
// FIXME: Print this at a valid location for a __declspec attr.
// CHECK: int y __declspec(align(4, 1));
__declspec(align(4)) int y;
// CHECK: void foo() __attribute__((const));
void foo() __attribute__((const));
// CHECK: void bar() __attribute__((__const));
void bar() __attribute__((__const));
// FIXME: Print these at a valid location for these attributes.
// CHECK: int *p32 __ptr32;
int * __ptr32 p32;
// CHECK: int *p64 __ptr64;
int * __ptr64 p64;
|
Reformat comment into Doxygen comment for file. | #ifndef HALIDE_TOOLS_IMAGE_H
#define HALIDE_TOOLS_IMAGE_H
/*
This allows code that relied on halide_image.h and Halide::Tools::Image to
continue to work with newer versions of Halide where HalideBuffer.h and
Halide::Buffer are the way to work with data.
Besides mapping Halide::Tools::Image to Halide::Buffer, it defines
USING_HALIDE_BUFFER to allow code to conditionally compile for one or the
other.
It is intended as a stop-gap measure until the code can be updated.
*/
#include "HalideBuffer.h"
namespace Halide {
namespace Tools {
#define USING_HALIDE_BUFFER
template< typename T >
using Image = Buffer<T>;
} // namespace Tools
} // mamespace Halide
#endif // #ifndef HALIDE_TOOLS_IMAGE_H
| #ifndef HALIDE_TOOLS_IMAGE_H
#define HALIDE_TOOLS_IMAGE_H
/** \file
*
* This allows code that relied on halide_image.h and
* Halide::Tools::Image to continue to work with newer versions of
* Halide where HalideBuffer.h and Halide::Buffer are the way to work
* with data.
*
* Besides mapping Halide::Tools::Image to Halide::Buffer, it defines
* USING_HALIDE_BUFFER to allow code to conditionally compile for one
* or the other.
*
* It is intended as a stop-gap measure until the code can be updated.
*/
#include "HalideBuffer.h"
namespace Halide {
namespace Tools {
#define USING_HALIDE_BUFFER
template< typename T >
using Image = Buffer<T>;
} // namespace Tools
} // mamespace Halide
#endif // #ifndef HALIDE_TOOLS_IMAGE_H
|
Make 64Bit Friendly, NonStatic for Ubuntu 14.04 delete unneeded files | #include "k2pktdef.h"
#define TRACE2_STA_LEN 7
#define TRACE2_CHAN_LEN 9 /* 4 bytes plus padding for loc and version */
#define TRACE2_NET_LEN 9
#define TRACE2_LOC_LEN 3
#define K2INFO_TYPE_STRING "TYPE_K2INFO_PACKET"
typedef struct {
char net[TRACE2_NET_LEN]; /* Network name */
char sta[TRACE2_STA_LEN]; /* Site name */
qint16 data_type; /* see K2INFO_TYPE #defines below */
quint32 epoch_sent; /* local time sent */
quint16 reserved[5]; /* reserved for future use */
} K2INFO_HEADER;
#define K2INFO_TYPE_HEADER 1 /* k2 header params */
#define K2INFO_TYPE_STATUS 2 /* k2 regular status packet */
#define K2INFO_TYPE_ESTATUS 3 /* k2 extended status packet (old) */
#define K2INFO_TYPE_E2STATUS 4 /* k2 extended status packet v2 */
#define K2INFO_TYPE_COMM 5 /* k2ew packet processing stats */
#define MAX_K2INFOBUF_SIZ 4096
typedef union {
qint8 msg[MAX_K2INFOBUF_SIZ];
K2INFO_HEADER k2info;
} K2infoPacket;
| #include "k2pktdef.h"
#define TRACE2_STA_LEN 7
#define TRACE2_CHAN_LEN 9 /* 4 bytes plus padding for loc and version */
#define TRACE2_NET_LEN 9
#define TRACE2_LOC_LEN 3
#define K2_TIME_CONV ((unsigned long)315532800)
#define K2INFO_TYPE_STRING "TYPE_K2INFO_PACKET"
typedef struct {
char net[TRACE2_NET_LEN]; /* Network name */
char sta[TRACE2_STA_LEN]; /* Site name */
qint16 data_type; /* see K2INFO_TYPE #defines below */
quint32 epoch_sent; /* local time sent */
quint16 reserved[5]; /* reserved for future use */
} K2INFO_HEADER;
#define K2INFO_TYPE_HEADER 1 /* k2 header params */
#define K2INFO_TYPE_STATUS 2 /* k2 regular status packet */
#define K2INFO_TYPE_ESTATUS 3 /* k2 extended status packet (old) */
#define K2INFO_TYPE_E2STATUS 4 /* k2 extended status packet v2 */
#define K2INFO_TYPE_COMM 5 /* k2ew packet processing stats */
#define MAX_K2INFOBUF_SIZ 4096
typedef union {
qint8 msg[MAX_K2INFOBUF_SIZ];
K2INFO_HEADER k2info;
} K2infoPacket;
|
Change type of SIZED_STRING's length to uint32_t | /*
Copyright (c) 2007-2014. The YARA 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 _SIZEDSTR_H
#define _SIZEDSTR_H
#include <stddef.h>
#include <inttypes.h>
//
// This struct is used to support strings containing null chars. The length of
// the string is stored along the string data. However the string data is also
// terminated with a null char.
//
#define SIZED_STRING_FLAGS_NO_CASE 1
#define SIZED_STRING_FLAGS_DOT_ALL 2
#pragma pack(push)
#pragma pack(8)
typedef struct _SIZED_STRING
{
uint64_t length;
uint32_t flags;
char c_string[1];
} SIZED_STRING;
#pragma pack(pop)
int sized_string_cmp(
SIZED_STRING* s1,
SIZED_STRING* s2);
#endif
| /*
Copyright (c) 2007-2014. The YARA 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 _SIZEDSTR_H
#define _SIZEDSTR_H
#include <stddef.h>
#include <inttypes.h>
//
// This struct is used to support strings containing null chars. The length of
// the string is stored along the string data. However the string data is also
// terminated with a null char.
//
#define SIZED_STRING_FLAGS_NO_CASE 1
#define SIZED_STRING_FLAGS_DOT_ALL 2
#pragma pack(push)
#pragma pack(8)
typedef struct _SIZED_STRING
{
uint32_t length;
uint32_t flags;
char c_string[1];
} SIZED_STRING;
#pragma pack(pop)
int sized_string_cmp(
SIZED_STRING* s1,
SIZED_STRING* s2);
#endif
|
Add -fblocks for the test. | // RUN: clang-cc -Wnonnull -fsyntax-only -verify %s
extern void func1 (void (^block1)(), void (^block2)(), int) __attribute__((nonnull));
extern void func3 (void (^block1)(), int, void (^block2)(), int)
__attribute__((nonnull(1,3)));
extern void func4 (void (^block1)(), void (^block2)()) __attribute__((nonnull(1)))
__attribute__((nonnull(2)));
void
foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)())
{
func1(cp1, cp2, i1);
func1(0, cp2, i1); // expected-warning {{argument is null where non-null is required}}
func1(cp1, 0, i1); // expected-warning {{argument is null where non-null is required}}
func1(cp1, cp2, 0);
func3(0, i2, cp3, i3); // expected-warning {{argument is null where non-null is required}}
func3(cp3, i2, 0, i3); // expected-warning {{argument is null where non-null is required}}
func4(0, cp1); // expected-warning {{argument is null where non-null is required}}
func4(cp1, 0); // expected-warning {{argument is null where non-null is required}}
}
| // RUN: clang-cc -fblocks -Wnonnull -fsyntax-only -verify %s
extern void func1 (void (^block1)(), void (^block2)(), int) __attribute__((nonnull));
extern void func3 (void (^block1)(), int, void (^block2)(), int)
__attribute__((nonnull(1,3)));
extern void func4 (void (^block1)(), void (^block2)()) __attribute__((nonnull(1)))
__attribute__((nonnull(2)));
void
foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)())
{
func1(cp1, cp2, i1);
func1(0, cp2, i1); // expected-warning {{argument is null where non-null is required}}
func1(cp1, 0, i1); // expected-warning {{argument is null where non-null is required}}
func1(cp1, cp2, 0);
func3(0, i2, cp3, i3); // expected-warning {{argument is null where non-null is required}}
func3(cp3, i2, 0, i3); // expected-warning {{argument is null where non-null is required}}
func4(0, cp1); // expected-warning {{argument is null where non-null is required}}
func4(cp1, 0); // expected-warning {{argument is null where non-null is required}}
}
|
Read keypresses from the user | int main() {
return 0;
}
| #include <unistd.h>
int main() {
char c;
while (read(STDIN_FILENO, &c, 1) == 1);
return 0;
}
|
Fix bug where XmlLexer::restart() doesn't reset sawEof | // xml_lexer.h see license.txt for copyright and terms of use
#ifndef XML_LEXER_H
#define XML_LEXER_H
#include <stdio.h>
#include "fstream.h" // ifstream
#include "str.h" // string
#include "sm_flexlexer.h" // yyFlexLexer
#include "baselexer.h" // FLEX_OUTPUT_METHOD_DECLS
#include "xml_enum.h" // XTOK_*
class XmlLexer : private yyFlexLexer {
public:
char const *inputFname; // just for error messages
int linenumber;
bool sawEof;
XmlLexer()
: inputFname(NULL)
, linenumber(1) // file line counting traditionally starts at 1
, sawEof(false)
{}
// this is yylex() but does what I want it to with EOF
int getToken();
// have we seen the EOF?
bool haveSeenEof() { return sawEof; }
// this is yytext
char const *currentText() { return this->YYText(); }
// this is yyrestart
void restart(istream *in) { this->yyrestart(in); }
int tok(XmlToken kind);
int svalTok(XmlToken t);
void err(char const *msg);
string tokenKindDesc(int kind) const;
FLEX_OUTPUT_METHOD_DECLS
};
#endif // XML_LEXER_H
| // xml_lexer.h see license.txt for copyright and terms of use
#ifndef XML_LEXER_H
#define XML_LEXER_H
#include <stdio.h>
#include "fstream.h" // ifstream
#include "str.h" // string
#include "sm_flexlexer.h" // yyFlexLexer
#include "baselexer.h" // FLEX_OUTPUT_METHOD_DECLS
#include "xml_enum.h" // XTOK_*
class XmlLexer : private yyFlexLexer {
public:
char const *inputFname; // just for error messages
int linenumber;
bool sawEof;
XmlLexer()
: inputFname(NULL)
, linenumber(1) // file line counting traditionally starts at 1
, sawEof(false)
{}
// this is yylex() but does what I want it to with EOF
int getToken();
// have we seen the EOF?
bool haveSeenEof() { return sawEof; }
// this is yytext
char const *currentText() { return this->YYText(); }
// this is yyrestart
void restart(istream *in) { this->yyrestart(in); sawEof = false; }
int tok(XmlToken kind);
int svalTok(XmlToken t);
void err(char const *msg);
string tokenKindDesc(int kind) const;
FLEX_OUTPUT_METHOD_DECLS
};
#endif // XML_LEXER_H
|
Include cerr and endl in CubeAsset | #ifndef GAMEASSET_H
#define GAMEASSET_H
#include <GL/gl.h>
class GameAsset {
public:
virtual void Draw(GLuint) = 0;
};
#endif
| #ifndef GAMEASSET_H
#define GAMEASSET_H
#include <iostream>
#include <GL/gl.h>
class GameAsset {
public:
virtual void Draw(GLuint) = 0;
};
#endif
|
Update format for Problem 9 | #include "stdio.h"
#include "stdbool.h"
bool checkPythagoreanTriplet (int a, int b, int c);
bool checkPythagoreanTriplet (int a, int b, int c) {
if((a*a) + (b*b) == (c*c)) {
return true;
} else {
return false;
}
}
int main(int argc, char const *argv[]) {
int i;
int j;
int k;
for(i=1; i < 1000; i++) {
for(j=i; j < (1000 - i); j++) {
for(k=j; k < (1000 - j); k++){
if(checkPythagoreanTriplet(i,j,k) && (i + j + k) == 1000) {
printf("%d %d %d\n", i, j, k);
printf("%d\n", (i*j*k));
break;
}
}
}
}
return 0;
}
| #include "stdio.h"
#include "stdbool.h"
bool checkPythagoreanTriplet(int a, int b, int c);
bool checkPythagoreanTriplet(int a, int b, int c)
{
if ((a * a) + (b * b) == (c * c))
{
return true;
}
else
{
return false;
}
}
int main(int argc, char const *argv[])
{
int i;
int j;
int k;
for (i = 1; i < 1000; i++)
{
for (j = i; j < (1000 - i); j++)
{
for (k = j; k < (1000 - j); k++)
{
if (checkPythagoreanTriplet(i, j, k) && (i + j + k) == 1000)
{
printf("%d %d %d\n", i, j, k);
printf("%d\n", (i * j * k));
break;
}
}
}
}
return 0;
}
|
Bring over a test from llvm/test/FrontendC that is for Sema and not CodeGen. | // RUN: not %clang_cc1 -O1 %s -emit-llvm
// PR6913
#include <stdio.h>
int main()
{
int x[10][10];
int (*p)[] = x; // expected-error {{invalid use of array with unspecified bounds}
int i;
for(i = 0; i < 10; ++i)
{
p[i][i] = i;
}
}
| |
Remove duplicate include from Arduino.h | /*
Ultrasonick.h - Library for HC-SR04 Ultrasonic Ranging Module in a minimalist way.
Created by EricK Simoes (@AloErickSimoes), April 3, 2014.
Released into the Creative Commons Attribution-ShareAlike 4.0 International.
*/
#ifndef Ultrasonick_h
#define Ultrasonick_h
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define CM 1
#define INC 0
/**
* TODO: Remove the underscore of the private variables name
* and use static keyword
*/
class Ultrasonick {
public:
Ultrasonick(uint8_t trigPin, uint8_t echoPin);
int distanceRead(uint8_t und);
int distanceRead();
private:
uint8_t _trigPin;
uint8_t _echoPin;
int timing();
};
#endif // Ultrasonic_h
| /*
Ultrasonick.h - Library for HC-SR04 Ultrasonic Ranging Module in a minimalist way.
Created by EricK Simoes (@AloErickSimoes), April 3, 2014.
Released into the Creative Commons Attribution-ShareAlike 4.0 International.
*/
#ifndef Ultrasonick_h
#define Ultrasonick_h
#define CM 1
#define INC 0
/**
* TODO: Remove the underscore of the private variables name
* and use static keyword
*/
class Ultrasonick {
public:
Ultrasonick(uint8_t trigPin, uint8_t echoPin);
int distanceRead(uint8_t und);
int distanceRead();
private:
uint8_t _trigPin;
uint8_t _echoPin;
int timing();
};
#endif // Ultrasonic_h
|
Add new line to new file | #ifndef NINJA_WIN32PORT_H_
#define NINJA_WIN32PORT_H_
#pragma once
/// A 64-bit integer type
typedef unsigned long long int64_t;
typedef unsigned long long uint64_t;
#endif // NINJA_WIN32PORT_H_ | #ifndef NINJA_WIN32PORT_H_
#define NINJA_WIN32PORT_H_
#pragma once
/// A 64-bit integer type
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#endif // NINJA_WIN32PORT_H_
|
Make constructors explicit where adequate | #pragma once
#ifndef COPYFS_LIB_COPYDEVICE_H_
#define COPYFS_LIB_COPYDEVICE_H_
#include <boost/filesystem.hpp>
#include <messmer/fspp/fs_interface/Device.h>
#include "messmer/cpp-utils/macros.h"
namespace copyfs {
namespace bf = boost::filesystem;
class CopyDevice: public fspp::Device {
public:
CopyDevice(const bf::path &rootdir);
virtual ~CopyDevice();
void statfs(const boost::filesystem::path &path, struct ::statvfs *fsstat) override;
const bf::path &RootDir() const;
private:
std::unique_ptr<fspp::Node> Load(const bf::path &path) override;
const bf::path _root_path;
DISALLOW_COPY_AND_ASSIGN(CopyDevice);
};
inline const bf::path &CopyDevice::RootDir() const {
return _root_path;
}
}
#endif
| #pragma once
#ifndef COPYFS_LIB_COPYDEVICE_H_
#define COPYFS_LIB_COPYDEVICE_H_
#include <boost/filesystem.hpp>
#include <messmer/fspp/fs_interface/Device.h>
#include "messmer/cpp-utils/macros.h"
namespace copyfs {
namespace bf = boost::filesystem;
class CopyDevice: public fspp::Device {
public:
explicit CopyDevice(const bf::path &rootdir);
virtual ~CopyDevice();
void statfs(const boost::filesystem::path &path, struct ::statvfs *fsstat) override;
const bf::path &RootDir() const;
private:
std::unique_ptr<fspp::Node> Load(const bf::path &path) override;
const bf::path _root_path;
DISALLOW_COPY_AND_ASSIGN(CopyDevice);
};
inline const bf::path &CopyDevice::RootDir() const {
return _root_path;
}
}
#endif
|
Allow to build with clang-cl | #ifndef stdbool_h
#define stdbool_h
#include <wtypes.h>
/* MSVC doesn't define _Bool or bool in C, but does have BOOL */
/* Note this doesn't pass autoconf's test because (bool) 0.5 != true */
typedef BOOL _Bool;
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1
#endif /* stdbool_h */
| #ifndef stdbool_h
#define stdbool_h
#include <wtypes.h>
/* MSVC doesn't define _Bool or bool in C, but does have BOOL */
/* Note this doesn't pass autoconf's test because (bool) 0.5 != true */
/* Clang-cl uses MSVC headers, so needs msvc_compat, but has _Bool as
* a built-in type. */
#ifndef __clang__
typedef BOOL _Bool;
#endif
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1
#endif /* stdbool_h */
|
Remove unused attribute from Settings Dialog | /* Copyright (c) nasser-sh 2016
*
* Distributed under BSD-style license. See accompanying LICENSE.txt in project
* directory.
*/
#pragma once
#include <afxwin.h>
#include "resource.h"
namespace graphics
{
class CGraphicsApp;
class CSettingsDialog : public CDialog
{
public:
enum { IDD = IDD_SETTINGS_DIALOG };
CSettingsDialog(CGraphicsApp *pApp, CWnd *pParent = nullptr);
virtual ~CSettingsDialog() = default;
BOOL OnInitDialog() override;
void OnOK() override;
private:
CComboBox *m_pMsaaComboBox;
CGraphicsApp *m_pApp;
protected:
DECLARE_MESSAGE_MAP()
};
}
| /* Copyright (c) nasser-sh 2016
*
* Distributed under BSD-style license. See accompanying LICENSE.txt in project
* directory.
*/
#pragma once
#include <afxwin.h>
#include "resource.h"
namespace graphics
{
class CGraphicsApp;
class CSettingsDialog : public CDialog
{
public:
enum { IDD = IDD_SETTINGS_DIALOG };
CSettingsDialog(CGraphicsApp *pApp, CWnd *pParent = nullptr);
virtual ~CSettingsDialog() = default;
BOOL OnInitDialog() override;
void OnOK() override;
private:
CGraphicsApp *m_pApp;
protected:
DECLARE_MESSAGE_MAP()
};
}
|
Remove UIKit import to (hopefully) fix cocoapods travis-CI build | //
// HTCopyableLabel.h
// HotelTonight
//
// Created by Jonathan Sibley on 2/6/13.
// Copyright (c) 2013 Hotel Tonight. All rights reserved.
//
#import <UIKit/UIKit.h>
@class HTCopyableLabel;
@protocol HTCopyableLabelDelegate <NSObject>
@optional
- (NSString *)stringToCopyForCopyableLabel:(HTCopyableLabel *)copyableLabel;
- (CGRect)copyMenuTargetRectInCopyableLabelCoordinates:(HTCopyableLabel *)copyableLabel;
@end
@interface HTCopyableLabel : UILabel
@property (nonatomic, assign) BOOL copyingEnabled; // Defaults to YES
@property (nonatomic, weak) id<HTCopyableLabelDelegate> copyableLabelDelegate;
@property (nonatomic, assign) UIMenuControllerArrowDirection copyMenuArrowDirection; // Defaults to UIMenuControllerArrowDefault
// You may want to add longPressGestureRecognizer to a container view
@property (nonatomic, strong, readonly) UILongPressGestureRecognizer *longPressGestureRecognizer;
@end
| //
// HTCopyableLabel.h
// HotelTonight
//
// Created by Jonathan Sibley on 2/6/13.
// Copyright (c) 2013 Hotel Tonight. All rights reserved.
//
@class HTCopyableLabel;
@protocol HTCopyableLabelDelegate <NSObject>
@optional
- (NSString *)stringToCopyForCopyableLabel:(HTCopyableLabel *)copyableLabel;
- (CGRect)copyMenuTargetRectInCopyableLabelCoordinates:(HTCopyableLabel *)copyableLabel;
@end
@interface HTCopyableLabel : UILabel
@property (nonatomic, assign) BOOL copyingEnabled; // Defaults to YES
@property (nonatomic, weak) id<HTCopyableLabelDelegate> copyableLabelDelegate;
@property (nonatomic, assign) UIMenuControllerArrowDirection copyMenuArrowDirection; // Defaults to UIMenuControllerArrowDefault
// You may want to add longPressGestureRecognizer to a container view
@property (nonatomic, strong, readonly) UILongPressGestureRecognizer *longPressGestureRecognizer;
@end
|
Add virtual in QuitaFileUtil to fix the compilation error in r82441. | // 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 WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_
#define WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_
#include "webkit/fileapi/file_system_file_util.h"
#include "webkit/fileapi/file_system_operation_context.h"
#pragma once
namespace fileapi {
class QuotaFileUtil : public FileSystemFileUtil {
public:
static QuotaFileUtil* GetInstance();
~QuotaFileUtil() {}
static const int64 kNoLimit;
base::PlatformFileError CopyOrMoveFile(
FileSystemOperationContext* fs_context,
const FilePath& src_file_path,
const FilePath& dest_file_path,
bool copy);
// TODO(dmikurube): Charge some amount of quota for directories.
base::PlatformFileError Truncate(
FileSystemOperationContext* fs_context,
const FilePath& path,
int64 length);
friend struct DefaultSingletonTraits<QuotaFileUtil>;
DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil);
protected:
QuotaFileUtil() {}
};
} // namespace fileapi
#endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_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 WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_
#define WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_
#include "webkit/fileapi/file_system_file_util.h"
#include "webkit/fileapi/file_system_operation_context.h"
#pragma once
namespace fileapi {
class QuotaFileUtil : public FileSystemFileUtil {
public:
static QuotaFileUtil* GetInstance();
~QuotaFileUtil() {}
static const int64 kNoLimit;
virtual base::PlatformFileError CopyOrMoveFile(
FileSystemOperationContext* fs_context,
const FilePath& src_file_path,
const FilePath& dest_file_path,
bool copy);
// TODO(dmikurube): Charge some amount of quota for directories.
virtual base::PlatformFileError Truncate(
FileSystemOperationContext* fs_context,
const FilePath& path,
int64 length);
friend struct DefaultSingletonTraits<QuotaFileUtil>;
DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil);
protected:
QuotaFileUtil() {}
};
} // namespace fileapi
#endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_
|
Add machine generated JNI header | /* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ru_exlmoto_spout_SpoutNativeLibProxy */
#ifndef _Included_ru_exlmoto_spout_SpoutNativeLibProxy
#define _Included_ru_exlmoto_spout_SpoutNativeLibProxy
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativeInit
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativeInit
(JNIEnv *, jclass);
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativeDeinit
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativeDeinit
(JNIEnv *, jclass);
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativeSurfaceChanged
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativeSurfaceChanged
(JNIEnv *, jclass, jint, jint);
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativeDraw
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativeDraw
(JNIEnv *, jclass);
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativeKeyDown
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativeKeyDown
(JNIEnv *, jclass, jint);
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativeKeyUp
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativeKeyUp
(JNIEnv *, jclass, jint);
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativePushScore
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativePushScore
(JNIEnv *, jclass, jint, jint);
/*
* Class: ru_exlmoto_spout_SpoutNativeLibProxy
* Method: SpoutNativeGetScore
* Signature: ()[I
*/
JNIEXPORT jintArray JNICALL Java_ru_exlmoto_spout_SpoutNativeLibProxy_SpoutNativeGetScore
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.