Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add BST Create function implementation | #include "bst.h"
static void BST_Transplant(BST* T, BSTNode* u, BSTNode* v);
struct BSTNode
{
BSTNode* left;
BSTNode* right;
BSTNode* p;
void* k;
};
struct BST
{
BSTNode* root;
};
| #include "bst.h"
static void BST_Transplant(BST* T, BSTNode* u, BSTNode* v);
struct BSTNode
{
BSTNode* left;
BSTNode* right;
BSTNode* p;
void* k;
};
struct BST
{
BSTNode* root;
};
BST* BST_Create(void)
{
BST* T = (BST* )malloc(sizeof(BST));
T->root = NULL;
return T;
}
|
Use an explicit target to test that source fortification is off when building for Darwin with -faddress-sanitizer. | // Make sure AddressSanitizer disables _FORTIFY_SOURCE on Darwin.
// REQUIRES: system-darwin
// RUN: %clang -faddress-sanitizer %s -E -dM -o - | FileCheck %s
// CHECK: #define _FORTIFY_SOURCE 0
| // Make sure AddressSanitizer disables _FORTIFY_SOURCE on Darwin.
// RUN: %clang -faddress-sanitizer %s -E -dM -target x86_64-darwin - | FileCheck %s
// CHECK: #define _FORTIFY_SOURCE 0
|
Add functions to build SM trees | #ifndef SYMBOLICMATHNODE_H
#define SYMBOLICMATHNODE_H
#include <vector>
#include "SymbolicMathNode.h"
namespace SymbolicMath
{
// clang-format off
Node abs(Node a) { return Node(UnaryFunctionType::ABS, a); }
Node acos(Node a) { return Node(UnaryFunctionType::ACOS, a); }
Node acosh(Node a) { return Node(UnaryFunctionType::ACOSH, a); }
Node asin(Node a) { return Node(UnaryFunctionType::ASIN, a); }
Node asinh(Node a) { return Node(UnaryFunctionType::ASINH, a); }
Node atan(Node a) { return Node(UnaryFunctionType::ATAN, a); }
Node atanh(Node a) { return Node(UnaryFunctionType::ATANH, a); }
Node ceil(Node a) { return Node(UnaryFunctionType::CEIL, a); }
Node cos(Node a) { return Node(UnaryFunctionType::COS, a); }
Node cosh(Node a) { return Node(UnaryFunctionType::COSH, a); }
Node cot(Node a) { return Node(UnaryFunctionType::COT, a); }
Node csc(Node a) { return Node(UnaryFunctionType::CSC, a); }
Node erf(Node a) { return Node(UnaryFunctionType::ERF, a); }
Node exp(Node a) { return Node(UnaryFunctionType::EXP, a); }
Node exp2(Node a) { return Node(UnaryFunctionType::EXP2, a); }
Node floor(Node a) { return Node(UnaryFunctionType::FLOOR, a); }
Node log(Node a) { return Node(UnaryFunctionType::LOG, a); }
Node log2(Node a) { return Node(UnaryFunctionType::LOG2, a); }
Node sec(Node a) { return Node(UnaryFunctionType::SEC, a); }
Node sin(Node a) { return Node(UnaryFunctionType::SIN, a); }
Node sinh(Node a) { return Node(UnaryFunctionType::SINH, a); }
Node tan(Node a) { return Node(UnaryFunctionType::TAN, a); }
Node tanh(Node a) { return Node(UnaryFunctionType::TANH, a); }
// clang-format on
// clang-format off
Node atan2(Node a, Node b) { return Node(BinaryFunctionType::ATAN2, a, b); }
Node max(Node a, Node b) { return Node(BinaryFunctionType::MAX, a, b); }
Node min(Node a, Node b) { return Node(BinaryFunctionType::MIN, a, b); }
Node plog(Node a, Node b) { return Node(BinaryFunctionType::PLOG, a, b); }
Node pow(Node a, Node b) { return Node(BinaryFunctionType::POW, a, b); }
// clang-format on
Node
conditional(Node a, Node b, Node c)
{
return Node(ConditionalType::IF, a, b, c);
}
// end namespace SymbolicMath
}
| |
Remove the _POSIX_C_SOURCE def that the sparc doesn't like | /* -*- mode:linux -*- */
/**
* \file timeout.h
*
*
*
* \author Ethan Burns
* \date 2008-12-16
*/
#define _POSIX_C_SOURCE 200112L
void timeout(unsigned int sec);
| /* -*- mode:linux -*- */
/**
* \file timeout.h
*
*
*
* \author Ethan Burns
* \date 2008-12-16
*/
void timeout(unsigned int sec);
|
Drop C linkage for message validators | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2015 Couchbase, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* memcached binary protocol packet validators
*/
#pragma once
#include <memcached/protocol_binary.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef protocol_binary_response_status (*mcbp_package_validate)(void *packet);
/**
* Get the memcached binary protocol validators
*
* @return the array of 0x100 entries for the package
* validators
*/
mcbp_package_validate *get_mcbp_validators(void);
#ifdef __cplusplus
}
#endif
| /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2015 Couchbase, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* memcached binary protocol packet validators
*/
#pragma once
#include <memcached/protocol_binary.h>
typedef protocol_binary_response_status (*mcbp_package_validate)(void *packet);
/**
* Get the memcached binary protocol validators
*
* @return the array of 0x100 entries for the package
* validators
*/
mcbp_package_validate *get_mcbp_validators(void);
|
Fix warning 'Empty paragraph passed to '@discussion' command' | @import Foundation;
@interface NSObject (DPLJSONObject)
/**
Returns a JSON compatible version of the receiver.
@discussion
- NSDictionary and NSArray will call `DPLJSONObject' on all of their items.
- Objects in an NSDictionary not keyed by an NSString will be removed.
- NSNumbers that are NaN or Inf will be represented by a string.
- NSDate objects will be represented as `timeIntervalSinceReferenceDate'.
- JSON incompatible objects will return their description.
- All NSNulls will be removed because who wants an NSNull.
@see NSJSONSerialization
*/
- (id)DPL_JSONObject;
@end
| @import Foundation;
@interface NSObject (DPLJSONObject)
/**
Returns a JSON compatible version of the receiver.
@discussion
- NSDictionary and NSArray will call `DPLJSONObject' on all of their items.
- Objects in an NSDictionary not keyed by an NSString will be removed.
- NSNumbers that are NaN or Inf will be represented by a string.
- NSDate objects will be represented as `timeIntervalSinceReferenceDate'.
- JSON incompatible objects will return their description.
- All NSNulls will be removed because who wants an NSNull.
@see NSJSONSerialization
*/
- (id)DPL_JSONObject;
@end
|
Update to version 9 to match libsetup/tmcd. | /*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003 University of Utah and the Flux Group.
* All rights reserved.
*/
#define TBSERVER_PORT 7777
#define TBSERVER_PORT2 14447
#define MYBUFSIZE 2048
#define BOSSNODE_FILENAME "bossnode"
/*
* As the tmcd changes, incompatable changes with older version of
* the software cause problems. Starting with version 3, the client
* will tell tmcd what version they are. If no version is included,
* assume its DEFAULT_VERSION.
*
* Be sure to update the versions as the TMCD changes. Both the
* tmcc and tmcd have CURRENT_VERSION compiled in, so be sure to
* install new versions of each binary when the current version
* changes. libsetup.pm module also encodes a current version, so be
* sure to change it there too!
*
* Note, this is assumed to be an integer. No need for 3.23.479 ...
* NB: See ron/libsetup.pm. That is version 4! I'll merge that in.
*/
#define DEFAULT_VERSION 2
#define CURRENT_VERSION 8
| /*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003 University of Utah and the Flux Group.
* All rights reserved.
*/
#define TBSERVER_PORT 7777
#define TBSERVER_PORT2 14447
#define MYBUFSIZE 2048
#define BOSSNODE_FILENAME "bossnode"
/*
* As the tmcd changes, incompatable changes with older version of
* the software cause problems. Starting with version 3, the client
* will tell tmcd what version they are. If no version is included,
* assume its DEFAULT_VERSION.
*
* Be sure to update the versions as the TMCD changes. Both the
* tmcc and tmcd have CURRENT_VERSION compiled in, so be sure to
* install new versions of each binary when the current version
* changes. libsetup.pm module also encodes a current version, so be
* sure to change it there too!
*
* Note, this is assumed to be an integer. No need for 3.23.479 ...
* NB: See ron/libsetup.pm. That is version 4! I'll merge that in.
*/
#define DEFAULT_VERSION 2
#define CURRENT_VERSION 9
|
Change server set/get function names | #ifndef GWKV_HT_WRAPPER
#define GWKV_HT_WRAPPER
#include <stdlib.h>
typedef enum {
GET,
SET
} method;
/* Defines for result codes */
#define STORED 0
#define NOT_STORED 1
#define EXISTS 2
#define NOT_FOUND 3
struct {
method method_type,
const char* key,
size_t key_length,
const char* value,
size_t value_length
} operation;
/**
* Wrapper function to set a value in the hashtable
* Returns either STORED or NOT_STORED (defined above)
*/
int
gwkv_memcache_set (memcached_st *ptr,
const char *key,
size_t key_length,
const char *value,
size_t value_length);
/**
* Wrapper function to read a value from the hashtable
* Returns the data if sucessful, or NULL on error
* These correspond to the EXISTS and NOT_FOUND codes above
*/
char*
gwkv_memcached_get (memcached_st *ptr,
const char *key,
size_t key_length,
size_t *value_length);
#endif
| #ifndef GWKV_HT_WRAPPER
#define GWKV_HT_WRAPPER
#include <stdlib.h>
#include "../hashtable/hashtable.h"
typedef enum {
GET,
SET
} method;
/* Defines for result codes */
#define STORED 0
#define NOT_STORED 1
#define EXISTS 2
#define NOT_FOUND 3
struct {
method method_type,
const char* key,
size_t key_length,
const char* value,
size_t value_length
} operation;
/**
* Wrapper function to set a value in the hashtable
* Returns either STORED or NOT_STORED (defined above)
*/
int
gwkv_server_set (memcached_st *ptr,
const char *key,
size_t key_length,
const char *value,
size_t value_length);
/**
* Wrapper function to read a value from the hashtable
* Returns the data if sucessful, or NULL on error
* These correspond to the EXISTS and NOT_FOUND codes above
*/
char*
gwkv_server_get (memcached_st *ptr,
const char *key,
size_t key_length,
size_t *value_length);
#endif
|
Tag 2.1.1 because of the segfault fix. | #ifndef _COMMON_H
#define _COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#ifdef _LINUX
#include <bsd/string.h>
#endif
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlsave.h>
#include <libxml/encoding.h>
#include <libxml/xmlstring.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#ifndef _READLINE
#include <histedit.h>
#else
#include <readline/readline.h>
#include <readline/history.h>
#endif
#define USAGE "[-k database file] [-p password file] [-m cipher mode] [-b] [-v] [-h] [-d]"
#define VERSION "kc 2.1"
#ifndef _READLINE
const char *el_prompt_null(void);
#endif
const char *prompt_str(void);
int malloc_check(void *);
char *get_random_str(size_t, char);
void version(void);
void quit(int);
char debug;
#endif
| #ifndef _COMMON_H
#define _COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#ifdef _LINUX
#include <bsd/string.h>
#endif
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlsave.h>
#include <libxml/encoding.h>
#include <libxml/xmlstring.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#ifndef _READLINE
#include <histedit.h>
#else
#include <readline/readline.h>
#include <readline/history.h>
#endif
#define USAGE "[-k database file] [-p password file] [-m cipher mode] [-b] [-v] [-h] [-d]"
#define VERSION "kc 2.1.1"
#ifndef _READLINE
const char *el_prompt_null(void);
#endif
const char *prompt_str(void);
int malloc_check(void *);
char *get_random_str(size_t, char);
void version(void);
void quit(int);
char debug;
#endif
|
Add file that holds the string hash function. | static inline unsigned int hash_func_string(const char* key)
{
unsigned int hash = 0;
int c;
while ((c = *key++) != 0)
hash = c + (hash << 6) + (hash << 16) - hash;
return hash;
}
| |
Fix Travis build (missing include for size_t) | /**
* @file random.h
* @ingroup CppAlgorithms
* @brief Random utility functions.
*
* Copyright (c) 2013 Sebastien Rombauts (sebastien.rombauts@gmail.com)
*
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
* or copy at http://opensource.org/licenses/MIT)
*/
/**
* @brief Random utility functions.
*/
class Random
{
public:
/**
* @brief Generate a printable alphanumeric character.
*/
static char GenChar();
/**
* @brief Generate a printable alphanumeric string.
*/
static void GenString(char* str, size_t len);
};
| /**
* @file random.h
* @ingroup CppAlgorithms
* @brief Random utility functions.
*
* Copyright (c) 2013 Sebastien Rombauts (sebastien.rombauts@gmail.com)
*
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
* or copy at http://opensource.org/licenses/MIT)
*/
#include <cstddef> // size_t
/**
* @brief Random utility functions.
*/
class Random
{
public:
/**
* @brief Generate a printable alphanumeric character.
*/
static char GenChar();
/**
* @brief Generate a printable alphanumeric string.
*/
static void GenString(char* str, size_t len);
};
|
Add octApron test on signed overflows | // SKIP PARAM: --sets ana.activated[+] octApron --sets sem.int.signed_overflow assume_none --disable ana.int.interval
// copied from signed-overflows/intervals for octApron
int main(void) {
int x = 0;
while(x != 42) {
x++;
assert(x >= 1);
}
}
| |
Include virtual in all methods. | #ifndef __GAME_OBJECT_H__
#define __GAME_OBJECT_H__
#include<iostream>
#include<SDL2/SDL.h>
class GameObject
{
public:
void load(int pX, int pY, int pWidth, int pHeight, std::string pTextureId);
void draw(SDL_Renderer *renderer);
void update();
void clean() { std::cout << "clean game object"; }
protected:
std::string textureId;
int currentFrame;
int currentRow;
int x;
int y;
int width;
int height;
};
#endif
| #ifndef __GAME_OBJECT_H__
#define __GAME_OBJECT_H__
#include<iostream>
#include<SDL2/SDL.h>
class GameObject
{
public:
virtual void load(int pX, int pY, int pWidth, int pHeight, std::string pTextureId);
virtual void draw(SDL_Renderer *renderer);
virtual void update();
virtual void clean() {};
protected:
std::string textureId;
int currentFrame;
int currentRow;
int x;
int y;
int width;
int height;
};
#endif
|
Add missing include for size_t | #ifndef _EXCELFORMUAL_TOKEN_ARRAY_H__
#define _EXCELFORMUAL_TOKEN_ARRAY_H__
#include <vector>
using std::vector;
namespace ExcelFormula{
class Token;
class TokenArray{
public:
TokenArray();
void toVector(vector<Token*>&);
void fromVector(vector<Token*>&);
size_t size() {return m_tokens.size();}
bool isBOF() {return (m_index <= 0)?true:false;}
bool isEOF() {return (m_index >= m_tokens.size())?true:false;}
Token* getCurrent();
Token* getNext();
Token* getPrevious();
Token* add(Token*);
bool moveNext();
void reset(){m_index = 0;}
void releaseAll();
private:
size_t m_index;
vector<Token*> m_tokens;
};
}
#endif
| #ifndef _EXCELFORMUAL_TOKEN_ARRAY_H__
#define _EXCELFORMUAL_TOKEN_ARRAY_H__
#include <vector>
#include <cstddef>
using std::vector;
namespace ExcelFormula{
class Token;
class TokenArray{
public:
TokenArray();
void toVector(vector<Token*>&);
void fromVector(vector<Token*>&);
size_t size() {return m_tokens.size();}
bool isBOF() {return (m_index <= 0)?true:false;}
bool isEOF() {return (m_index >= m_tokens.size())?true:false;}
Token* getCurrent();
Token* getNext();
Token* getPrevious();
Token* add(Token*);
bool moveNext();
void reset(){m_index = 0;}
void releaseAll();
private:
size_t m_index;
vector<Token*> m_tokens;
};
}
#endif
|
Define chdir as a macro. | #ifndef LIBPORT_UNISTD_H
# define LIBPORT_UNISTD_H
# include <libport/detect-win32.h>
# include <libport/windows.hh> // Get sleep wrapper
# include <libport/config.h>
// This is traditional Unix file.
# ifdef LIBPORT_HAVE_UNISTD_H
# include <unistd.h>
# endif
// OSX does not have O_LARGEFILE. No information was found whether
// some equivalent flag is needed or not. Other projects simply do as
// follows.
# ifndef O_LARGEFILE
# define O_LARGEFILE 0
# endif
// This seems to be its WIN32 equivalent.
// http://msdn2.microsoft.com/en-us/library/ms811896(d=printer).aspx#ucmgch09_topic7.
# if defined WIN32 || defined LIBPORT_WIN32
# include <io.h>
# endif
# ifdef WIN32
# include <direct.h>
extern "C"
{
int chdir (const char* path)
{
return _chdir(path);
}
}
# endif
# if !defined LIBPORT_HAVE_GETCWD
# if defined LIBPORT_HAVE__GETCWD
# define getcwd _getcwd
# elif defined LIBPORT_URBI_ENV_AIBO
// Will be defined in libport/unistd.cc.
# else
# error I need either getcwd() or _getcwd()
# endif
# endif
#endif // !LIBPORT_UNISTD_H
| #ifndef LIBPORT_UNISTD_H
# define LIBPORT_UNISTD_H
# include <libport/detect-win32.h>
# include <libport/windows.hh> // Get sleep wrapper
# include <libport/config.h>
// This is traditional Unix file.
# ifdef LIBPORT_HAVE_UNISTD_H
# include <unistd.h>
# endif
// OSX does not have O_LARGEFILE. No information was found whether
// some equivalent flag is needed or not. Other projects simply do as
// follows.
# ifndef O_LARGEFILE
# define O_LARGEFILE 0
# endif
// This seems to be its WIN32 equivalent.
// http://msdn2.microsoft.com/en-us/library/ms811896(d=printer).aspx#ucmgch09_topic7.
# if defined WIN32 || defined LIBPORT_WIN32
# include <io.h>
# endif
# ifdef WIN32
# include <direct.h>
# define chdir _chdir
# endif
# if !defined LIBPORT_HAVE_GETCWD
# if defined LIBPORT_HAVE__GETCWD
# define getcwd _getcwd
# elif defined LIBPORT_URBI_ENV_AIBO
// Will be defined in libport/unistd.cc.
# else
# error I need either getcwd() or _getcwd()
# endif
# endif
#endif // !LIBPORT_UNISTD_H
|
Add type to Collection Property | //
// TSDKCollectionJSON.h
// TeamSnapSDK
//
// Created by Jason Rahaim on 1/10/14.
// Copyright (c) 2014 TeamSnap. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TSDKCollectionJSON : NSObject <NSCoding, NSCopying>
@property (nonatomic, strong) NSURL *_Nullable href;
@property (nonatomic, strong) NSString *_Nullable version;
@property (nonatomic, strong) NSString *_Nullable type;
@property (nonatomic, strong) NSString *_Nullable rel;
@property (nonatomic, strong) NSString *_Nullable errorTitle;
@property (nonatomic, strong) NSString *_Nullable errorMessage;
@property (nonatomic, assign) NSInteger errorCode;
@property (nonatomic, strong) NSMutableDictionary *_Nullable links;
@property (nonatomic, strong) NSMutableDictionary *_Nullable data;
@property (nonatomic, strong) NSMutableDictionary *_Nullable commands;
@property (nonatomic, strong) NSMutableDictionary *_Nullable queries;
@property (nonatomic, strong) id _Nullable collection;
+(NSDictionary *_Nullable)dictionaryToCollectionJSON:(NSDictionary *_Nonnull)dictionary;
- (instancetype _Nullable)initWithCoder:(NSCoder *_Nonnull)aDecoder;
- (instancetype _Nullable)initWithJSON:(NSDictionary *_Nonnull)JSON;
+ (instancetype _Nullable)collectionJSONForEncodedData:(NSData *_Nonnull)objectData;
- (NSString *_Nullable)getObjectiveCHeaderSkeleton;
- (NSData *_Nonnull)dataEncodedForSave;
@end
| //
// TSDKCollectionJSON.h
// TeamSnapSDK
//
// Created by Jason Rahaim on 1/10/14.
// Copyright (c) 2014 TeamSnap. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TSDKCollectionJSON : NSObject <NSCoding, NSCopying>
@property (nonatomic, strong) NSURL *_Nullable href;
@property (nonatomic, strong) NSString *_Nullable version;
@property (nonatomic, strong) NSString *_Nullable type;
@property (nonatomic, strong) NSString *_Nullable rel;
@property (nonatomic, strong) NSString *_Nullable errorTitle;
@property (nonatomic, strong) NSString *_Nullable errorMessage;
@property (nonatomic, assign) NSInteger errorCode;
@property (nonatomic, strong) NSMutableDictionary *_Nullable links;
@property (nonatomic, strong) NSMutableDictionary *_Nullable data;
@property (nonatomic, strong) NSMutableDictionary *_Nullable commands;
@property (nonatomic, strong) NSMutableDictionary *_Nullable queries;
@property (nonatomic, strong) NSMutableArray <TSDKCollectionJSON *> *_Nullable collection;
+ (NSDictionary *_Nullable)dictionaryToCollectionJSON:(NSDictionary *_Nonnull)dictionary;
- (instancetype _Nullable)initWithCoder:(NSCoder *_Nonnull)aDecoder;
- (instancetype _Nullable)initWithJSON:(NSDictionary *_Nonnull)JSON;
+ (instancetype _Nullable)collectionJSONForEncodedData:(NSData *_Nonnull)objectData;
- (NSString *_Nullable)getObjectiveCHeaderSkeleton;
- (NSData *_Nonnull)dataEncodedForSave;
@end
|
Add name to top of file. | #include <stdio.h>
/* Static functions and static global variables are only visible in
* the file that it is declared in. Static variables inside of a
* function have a different meaning and is described below */
void foo()
{
int x = 0;
static int staticx = 0; // initialized once; keeps value between invocations of foo().
x++;
staticx++;
printf("x=%d\n", x);
printf("staticx=%d\n", staticx);
}
int main(void)
{
for(int i=0; i<10; i++)
foo();
}
| // Scott Kuhl
#include <stdio.h>
/* Static functions and static global variables are only visible in
* the file that it is declared in. Static variables inside of a
* function have a different meaning and is described below */
void foo()
{
int x = 0;
static int staticx = 0; // initialized once; keeps value between invocations of foo().
x++;
staticx++;
printf("x=%d\n", x);
printf("staticx=%d\n", staticx);
}
int main(void)
{
for(int i=0; i<10; i++)
foo();
}
|
Fix snprintf on VisualC++ with a conditional define. | /******************************
** Tsunagari Tile Engine **
** config.h **
** Copyright 2011 OmegaSDG **
******************************/
#ifndef CONFIG_H
#define CONFIG_H
// === Default Configuration Settings ===
/* Tsunagari config file. -- Command Line */
#define CLIENT_CONF_FILE "./client.conf"
/* Error verbosity level. -- Command Line */
#define MESSAGE_MODE MM_DEBUG
/* Milliseconds of button down before starting persistent input in
roguelike movement mode. -- Move to World Descriptor */
#define ROGUELIKE_PERSIST_DELAY_INIT 500
/* Milliseconds between persistent input sends in roguelike movement
mode. -- Move to World Descriptor */
#define ROGUELIKE_PERSIST_DELAY_CONSECUTIVE 100
/* Time to live in seconds for empty resource cache entries before they
are deleted. -- Command Line */
#define CACHE_EMPTY_TTL 300
// ===
#endif
| /******************************
** Tsunagari Tile Engine **
** config.h **
** Copyright 2011 OmegaSDG **
******************************/
#ifndef CONFIG_H
#define CONFIG_H
// === Default Configuration Settings ===
/* Tsunagari config file. -- Command Line */
#define CLIENT_CONF_FILE "./client.conf"
/* Error verbosity level. -- Command Line */
#define MESSAGE_MODE MM_DEBUG
/* Milliseconds of button down before starting persistent input in
roguelike movement mode. -- Move to World Descriptor */
#define ROGUELIKE_PERSIST_DELAY_INIT 500
/* Milliseconds between persistent input sends in roguelike movement
mode. -- Move to World Descriptor */
#define ROGUELIKE_PERSIST_DELAY_CONSECUTIVE 100
/* Time to live in seconds for empty resource cache entries before they
are deleted. -- Command Line */
#define CACHE_EMPTY_TTL 300
// ===
// === Compiler Specific Defines ===
/* Fix snprintf for VisualC++. */
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
// ===
#endif
|
Add missing file. Oops :( | // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
#ifndef WEBKIT_GLUE_SCREEN_INFO_H_
#define WEBKIT_GLUE_SCREEN_INFO_H_
#include "base/gfx/rect.h"
namespace webkit_glue {
struct ScreenInfo {
int depth;
int depth_per_component;
bool is_monochrome;
gfx::Rect rect;
gfx::Rect available_rect;
};
} // namespace webkit_glue
#endif // WEBKIT_GLUE_SCREEN_INFO_H_
| |
Fix Krazy warnings: explicit - KreDBImporter | /***************************************************************************
* Copyright © 2004 Jason Kivlighn <jkivlighn@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef KREDBIMPORTER_H
#define KREDBIMPORTER_H
#include <QString>
#include "baseimporter.h"
/** Class to import recipes from any other Krecipes database backend.
* Note: Though independent of database type, the two databases must have the same structure (i.e. be the same version)
* @author Jason Kivlighn
*/
class KreDBImporter : public BaseImporter
{
public:
KreDBImporter( const QString &dbType, const QString &host = QString(), const QString &user = QString(), const QString &pass = QString(), int port = 0 );
virtual ~KreDBImporter();
private:
virtual void parseFile( const QString &file_or_table );
QString dbType;
QString host;
QString user;
QString pass;
int port;
};
#endif //KREDBIMPORTER_H
| /***************************************************************************
* Copyright © 2004 Jason Kivlighn <jkivlighn@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef KREDBIMPORTER_H
#define KREDBIMPORTER_H
#include <QString>
#include "baseimporter.h"
/** Class to import recipes from any other Krecipes database backend.
* Note: Though independent of database type, the two databases must have the same structure (i.e. be the same version)
* @author Jason Kivlighn
*/
class KreDBImporter : public BaseImporter
{
public:
explicit KreDBImporter( const QString &dbType, const QString &host = QString(), const QString &user = QString(), const QString &pass = QString(), int port = 0 );
virtual ~KreDBImporter();
private:
virtual void parseFile( const QString &file_or_table );
QString dbType;
QString host;
QString user;
QString pass;
int port;
};
#endif //KREDBIMPORTER_H
|
Add note about blacklisting interfaces | /*
* Configurables. Adjust these to be appropriate for your system.
*/
/* change blacklist parameters (-b) if necessary */
static const char *ealargs[] = {
"if_dpdk",
"-b 00:00:03.0",
"-c 1",
"-n 1",
};
/* change PORTID to the one your want to use */
#define IF_PORTID 0
/* change to the init method of your NIC driver */
#ifndef PMD_INIT
#define PMD_INIT rte_pmd_init_all
#endif
/* Receive packets in bursts of 16 per read */
#define MAX_PKT_BURST 16
| /*
* Configurables. Adjust these to be appropriate for your system.
*/
/* change blacklist parameters (-b) if necessary
* If you have more than one interface, you will likely want to blacklist
* at least one of them.
*/
static const char *ealargs[] = {
"if_dpdk",
"-b 00:00:03.0",
"-c 1",
"-n 1",
};
/* change PORTID to the one your want to use */
#define IF_PORTID 0
/* change to the init method of your NIC driver */
#ifndef PMD_INIT
#define PMD_INIT rte_pmd_init_all
#endif
/* Receive packets in bursts of 16 per read */
#define MAX_PKT_BURST 16
|
Extend IParser interface: remember parse state - succesfull or not; what part of string was parsed | #pragma once
#include <mixal/config.h>
#include <mixal/parsers_utils.h>
namespace mixal {
class MIXAL_PARSER_LIB_EXPORT IParser
{
public:
std::size_t parse_stream(std::string_view str, std::size_t offset = 0);
protected:
~IParser() = default;
virtual void do_clear() = 0;
virtual std::size_t do_parse_stream(std::string_view str, std::size_t offset) = 0;
};
inline std::size_t IParser::parse_stream(std::string_view str, std::size_t offset /*= 0*/)
{
do_clear();
if (offset > str.size())
{
return InvalidStreamPosition();
}
const auto pos = do_parse_stream(str, offset);
if (IsInvalidStreamPosition(pos))
{
// Parser is in undetermined state.
// Put back in default state for free
do_clear();
}
return pos;
}
} // namespace mixal
| #pragma once
#include <mixal/config.h>
#include <mixal/parsers_utils.h>
namespace mixal {
class MIXAL_PARSER_LIB_EXPORT IParser
{
public:
std::size_t parse_stream(std::string_view str, std::size_t offset = 0);
bool is_valid() const;
std::string_view str() const;
protected:
IParser() = default;
~IParser() = default;
virtual void do_clear() = 0;
virtual std::size_t do_parse_stream(std::string_view str, std::size_t offset) = 0;
private:
void clear();
private:
std::string_view str_;
bool is_valid_{false};
};
inline std::size_t IParser::parse_stream(std::string_view str, std::size_t offset /*= 0*/)
{
clear();
if (offset > str.size())
{
return InvalidStreamPosition();
}
const auto pos = do_parse_stream(str, offset);
if (IsInvalidStreamPosition(pos))
{
// Parser is in undetermined state.
// Put back in default state for free
clear();
return InvalidStreamPosition();
}
is_valid_ = true;
str_ = str.substr(offset, pos - offset);
return pos;
}
inline void IParser::clear()
{
is_valid_ = false;
do_clear();
}
inline bool IParser::is_valid() const
{
return is_valid_;
}
inline std::string_view IParser::str() const
{
return str_;
}
} // namespace mixal
|
Print out values of first two arrays | #include <stdio.h>
int main(int argc, char *argv[]){
int numbers[4] = {0};
char name[4] = {'a'};
//first print them out raw
printf("numbers: %d %d %d %d.\n",
numbers[0],
numbers[1],
numbers[2],
numbers[3]);
printf("name each: %c %c %c %c.\n",
name[0],
name[1],
name[2],
name[3]);
return 0;
} | |
Rewrite matching line to be friendlier to misc buildbots. | // RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
// PR 5995
struct s {
int word;
struct {
int filler __attribute__ ((aligned (8)));
};
};
void func (struct s *s)
{
// CHECK: load %struct.s** %s.addr, align 8
s->word = 0;
}
| // RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
// PR 5995
struct s {
int word;
struct {
int filler __attribute__ ((aligned (8)));
};
};
void func (struct s *s)
{
// CHECK: load %struct.s**{{.*}}align 8
s->word = 0;
}
|
Fix test suite compilation errors | #ifndef EP_TESTSUITE_H
#define EP_TESTSUITE_H 1
#include <memcached/engine.h>
#include <memcached/engine_testapp.h>
#ifdef __cplusplus
extern "C" {
#endif
MEMCACHED_PUBLIC_API
engine_test_t* get_tests(void);
MEMCACHED_PUBLIC_API
bool setup_suite(struct test_harness *th);
#ifdef __cplusplus
}
#endif
#endif
| #ifndef EP_TESTSUITE_H
#define EP_TESTSUITE_H 1
#include <memcached/engine.h>
#include <memcached/engine_testapp.h>
#ifdef __cplusplus
extern "C" {
#endif
MEMCACHED_PUBLIC_API
engine_test_t* get_tests(void);
MEMCACHED_PUBLIC_API
bool setup_suite(struct test_harness *th);
MEMCACHED_PUBLIC_API
bool teardown_suite();
enum test_result prepare(engine_test_t *test);
void cleanup(engine_test_t *test, enum test_result result);
#ifdef __cplusplus
}
#endif
#endif
|
Add empty test to prevent build system complaining. | /*
Copyright (C) 2016 William Hart
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include "flint.h"
#include "fmpz.h"
#include "fmpz_mpoly.h"
#include "ulong_extras.h"
int
main(void)
{
int i;
FLINT_TEST_INIT(state);
flint_printf("void....");
fflush(stdout);
/* Check aliasing of a and c */
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
{
}
FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return 0;
}
| |
Fix InputSize symbol array size. | #ifndef INPUTSTATE_H
#define INPUTSTATE_H
#include <SDL2/SDL.h>
#undef main
#include <map>
class InputState
{
public:
enum KeyFunction { KF_EXIT, KF_FORWARDS, KF_BACKWARDS, KF_ROTATE_SUN };
InputState();
void readInputState();
bool getKeyState(KeyFunction f);
int getAbsoluteMouseX() { return mouse_x; };
int getAbsoluteMouseY() { return mouse_y; };
float getMouseX() { return (float)mouse_x / (float)w; };
float getMouseY() { return (float)mouse_y / (float)h; };
int w, h;
int mouse_x, mouse_y;
private:
Uint8 *keys;
Uint8 key_function_to_keycode[3];
};
#endif
| #ifndef INPUTSTATE_H
#define INPUTSTATE_H
#include <SDL2/SDL.h>
#undef main
#include <map>
class InputState
{
public:
enum KeyFunction { KF_EXIT, KF_FORWARDS, KF_BACKWARDS, KF_ROTATE_SUN };
InputState();
void readInputState();
bool getKeyState(KeyFunction f);
int getAbsoluteMouseX() { return mouse_x; };
int getAbsoluteMouseY() { return mouse_y; };
float getMouseX() { return (float)mouse_x / (float)w; };
float getMouseY() { return (float)mouse_y / (float)h; };
int w, h;
int mouse_x, mouse_y;
private:
Uint8 *keys;
Uint8 key_function_to_keycode[4];
};
#endif
|
Fix integer overflow in jsonp_strdup() | /*
* Copyright (c) 2009-2012 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2011-2012 Basile Starynkevitch <basile@starynkevitch.net>
*
* Jansson is free software; you can redistribute it and/or modify it
* under the terms of the MIT license. See LICENSE for details.
*/
#include <stdlib.h>
#include <string.h>
#include "jansson.h"
#include "jansson_private.h"
/* memory function pointers */
static json_malloc_t do_malloc = malloc;
static json_free_t do_free = free;
void *jsonp_malloc(size_t size)
{
if(!size)
return NULL;
return (*do_malloc)(size);
}
void jsonp_free(void *ptr)
{
if(!ptr)
return;
(*do_free)(ptr);
}
char *jsonp_strdup(const char *str)
{
char *new_str;
new_str = jsonp_malloc(strlen(str) + 1);
if(!new_str)
return NULL;
strcpy(new_str, str);
return new_str;
}
void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn)
{
do_malloc = malloc_fn;
do_free = free_fn;
}
| /*
* Copyright (c) 2009-2012 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2011-2012 Basile Starynkevitch <basile@starynkevitch.net>
*
* Jansson is free software; you can redistribute it and/or modify it
* under the terms of the MIT license. See LICENSE for details.
*/
#include <stdlib.h>
#include <string.h>
#include "jansson.h"
#include "jansson_private.h"
/* memory function pointers */
static json_malloc_t do_malloc = malloc;
static json_free_t do_free = free;
void *jsonp_malloc(size_t size)
{
if(!size)
return NULL;
return (*do_malloc)(size);
}
void jsonp_free(void *ptr)
{
if(!ptr)
return;
(*do_free)(ptr);
}
char *jsonp_strdup(const char *str)
{
char *new_str;
size_t len;
len = strlen(str);
if(len == (size_t)-1)
return NULL;
new_str = jsonp_malloc(len + 1);
if(!new_str)
return NULL;
strcpy(new_str, str);
return new_str;
}
void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn)
{
do_malloc = malloc_fn;
do_free = free_fn;
}
|
Fix link error when component=shared_library is set | // 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_BASE_IME_CHARACTER_COMPOSER_H_
#define UI_BASE_IME_CHARACTER_COMPOSER_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
#include "base/string_util.h"
namespace ui {
// A class to recognize compose and dead key sequence.
// Outputs composed character.
//
// TODO(hashimoto): support unicode character composition starting with
// Ctrl-Shift-U. http://crosbug.com/15925
class CharacterComposer {
public:
CharacterComposer();
~CharacterComposer();
void Reset();
// Filters keypress.
// Returns true if the keypress is recognized as a part of composition
// sequence.
bool FilterKeyPress(unsigned int keycode);
// Returns a string consisting of composed character.
// Empty string is returned when there is no composition result.
const string16& composed_character() const {
return composed_character_;
}
private:
// Remembers keypresses previously filtered.
std::vector<unsigned int> compose_buffer_;
// A string representing the composed character.
string16 composed_character_;
DISALLOW_COPY_AND_ASSIGN(CharacterComposer);
};
} // namespace ui
#endif // UI_BASE_IME_CHARACTER_COMPOSER_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_BASE_IME_CHARACTER_COMPOSER_H_
#define UI_BASE_IME_CHARACTER_COMPOSER_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
#include "base/string_util.h"
#include "ui/base/ui_export.h"
namespace ui {
// A class to recognize compose and dead key sequence.
// Outputs composed character.
//
// TODO(hashimoto): support unicode character composition starting with
// Ctrl-Shift-U. http://crosbug.com/15925
class UI_EXPORT CharacterComposer {
public:
CharacterComposer();
~CharacterComposer();
void Reset();
// Filters keypress.
// Returns true if the keypress is recognized as a part of composition
// sequence.
bool FilterKeyPress(unsigned int keycode);
// Returns a string consisting of composed character.
// Empty string is returned when there is no composition result.
const string16& composed_character() const {
return composed_character_;
}
private:
// Remembers keypresses previously filtered.
std::vector<unsigned int> compose_buffer_;
// A string representing the composed character.
string16 composed_character_;
DISALLOW_COPY_AND_ASSIGN(CharacterComposer);
};
} // namespace ui
#endif // UI_BASE_IME_CHARACTER_COMPOSER_H_
|
Undo change proposed by Philippe. Too many side effects. | #ifndef G__IOSFWD_H
#define G__IOSFWD_H
#include <iostream.h>
typedef basic_streambuf<char, char_traits<char> > streambuf;
#endif
| #ifndef G__IOSFWD_H
#define G__IOSFWD_H
#include <iostream.h>
#endif
|
Implement getting and setting uiImage size in Gtk | // 13 september 2016
#include "uipriv_unix.h"
struct uiImage {
uiUnixControl c;
GtkWidget *widget;
};
uiUnixControlAllDefaults(uiImage)
uiImage *uiNewImage(const char *filename)
{
uiImage *img;
uiUnixNewControl(uiImage, img);
img->widget = gtk_image_new_from_file(filename);
return img;
}
| // 13 september 2016
#include "uipriv_unix.h"
struct uiImage {
uiUnixControl c;
GtkWidget *widget;
};
uiUnixControlAllDefaults(uiImage)
void uiImageSetSize(uiImage *i, unsigned int width, unsigned int height)
{
GdkPixbuf *pixbuf;
pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(i->widget));
pixbuf = gdk_pixbuf_scale_simple(pixbuf,
width,
height,
GDK_INTERP_BILINEAR);
gtk_image_set_from_pixbuf(GTK_IMAGE(i->widget), pixbuf);
g_object_unref(pixbuf);
}
void uiImageGetSize(uiImage *i, unsigned int *width, unsigned int *height)
{
GdkPixbuf *pixbuf;
pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(i->widget));
*width = gdk_pixbuf_get_width(pixbuf);
*height = gdk_pixbuf_get_height(pixbuf);
}
uiImage *uiNewImage(const char *filename)
{
uiImage *img;
uiUnixNewControl(uiImage, img);
img->widget = gtk_image_new_from_file(filename);
return img;
}
|
Replace nil with nullptr in GLContextNSGL to compile correctly | // LAF OS Library
// Copyright (C) 2022 Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef OS_GL_CONTEXT_NSGL_INCLUDED
#define OS_GL_CONTEXT_NSGL_INCLUDED
#pragma once
#include "os/gl/gl_context.h"
namespace os {
class GLContextNSGL : public GLContext {
public:
GLContextNSGL();
~GLContextNSGL();
void setView(id view);
bool isValid() override;
bool createGLContext() override;
void destroyGLContext() override;
void makeCurrent() override;
void swapBuffers() override;
id nsglContext() {
return m_nsgl;
}
private:
id m_nsgl = nil; // NSOpenGLContext
id m_view = nil; // NSView
};
} // namespace os
#endif
| // LAF OS Library
// Copyright (C) 2022 Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef OS_GL_CONTEXT_NSGL_INCLUDED
#define OS_GL_CONTEXT_NSGL_INCLUDED
#pragma once
#include "os/gl/gl_context.h"
namespace os {
class GLContextNSGL : public GLContext {
public:
GLContextNSGL();
~GLContextNSGL();
void setView(id view);
bool isValid() override;
bool createGLContext() override;
void destroyGLContext() override;
void makeCurrent() override;
void swapBuffers() override;
id nsglContext() {
return m_nsgl;
}
private:
id m_nsgl = nullptr; // NSOpenGLContext
id m_view = nullptr; // NSView
};
} // namespace os
#endif
|
Update completion queue header to match code changes | /*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/grpc.h>
#include <v8.h>
namespace grpc {
namespace node {
grpc_completion_queue *GetCompletionQueue();
void CompletionQueueNext();
void CompletionQueueInit(v8::Local<v8::Object> exports);
} // namespace node
} // namespace grpc
| /*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/grpc.h>
#include <v8.h>
namespace grpc {
namespace node {
grpc_completion_queue *GetCompletionQueue();
void CompletionQueueNext();
void CompletionQueueInit(v8::Local<v8::Object> exports);
void CompletionQueueForcePoll();
} // namespace node
} // namespace grpc
|
Allow indexing by operator[] when dimension is 1 | #ifndef SCALAR_INDEXING_NONCONST_H
#define SCALAR_INDEXING_NONCONST_H
// Scalar indexing non-const
//----------------------------------------------------------------------------------------------------------//
template<typename... Args, typename std::enable_if<sizeof...(Args)==dimension_t::value &&
is_arithmetic_pack<Args...>::value,bool>::type =0>
FASTOR_INLINE T& operator()(Args ... args) {
return _data[get_flat_index(args...)];
}
//----------------------------------------------------------------------------------------------------------//
#endif // SCALAR_INDEXING_NONCONST_H
#ifndef SCALAR_INDEXING_CONST_H
#define SCALAR_INDEXING_CONST_H
// Scalar indexing const
//----------------------------------------------------------------------------------------------------------//
template<typename... Args, typename std::enable_if<sizeof...(Args)==dimension_t::value &&
is_arithmetic_pack<Args...>::value,bool>::type =0>
constexpr FASTOR_INLINE const T& operator()(Args ... args) const {
return _data[get_flat_index(args...)];
}
//----------------------------------------------------------------------------------------------------------//
#endif // SCALAR_INDEXING_CONST_H
| #ifndef SCALAR_INDEXING_NONCONST_H
#define SCALAR_INDEXING_NONCONST_H
// Scalar indexing non-const
//----------------------------------------------------------------------------------------------------------//
template<typename... Args, typename std::enable_if<sizeof...(Args)==dimension_t::value &&
is_arithmetic_pack<Args...>::value,bool>::type =0>
FASTOR_INLINE T& operator()(Args ... args) {
return _data[get_flat_index(args...)];
}
template<typename Arg, typename std::enable_if<1==dimension_t::value &&
is_arithmetic_pack<Arg>::value,bool>::type =0>
FASTOR_INLINE T& operator[](Arg arg) {
return _data[get_flat_index(arg)];
}
//----------------------------------------------------------------------------------------------------------//
#endif // SCALAR_INDEXING_NONCONST_H
#ifndef SCALAR_INDEXING_CONST_H
#define SCALAR_INDEXING_CONST_H
// Scalar indexing const
//----------------------------------------------------------------------------------------------------------//
template<typename... Args, typename std::enable_if<sizeof...(Args)==dimension_t::value &&
is_arithmetic_pack<Args...>::value,bool>::type =0>
constexpr FASTOR_INLINE const T& operator()(Args ... args) const {
return _data[get_flat_index(args...)];
}
template<typename Arg, typename std::enable_if<1==dimension_t::value &&
is_arithmetic_pack<Arg>::value,bool>::type =0>
constexpr FASTOR_INLINE const T& operator[](Arg arg) const {
return _data[get_flat_index(arg)];
}
//----------------------------------------------------------------------------------------------------------//
#endif // SCALAR_INDEXING_CONST_H
|
Disable MBEDTLS_HAVE_DATE_TIME as ARMCC does not support gmtime | /**
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
#if defined(DEVICE_TRNG)
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif
#if defined(DEVICE_RTC)
#define MBEDTLS_HAVE_TIME_DATE
#endif
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
#include "mbedtls_device.h"
#endif
| /**
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
#if defined(DEVICE_TRNG)
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
#include "mbedtls_device.h"
#endif
|
Clear bit when writing to VDP2(TVMD) | /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <vdp2/tvmd.h>
#include "vdp-internal.h"
void
vdp2_tvmd_display_clear(void)
{
_state_vdp2()->regs.tvmd &= 0x7FFF;
/* Change the DISP bit during VBLANK */
vdp2_tvmd_vblank_in_wait();
MEMORY_WRITE(16, VDP2(TVMD), _state_vdp2()->regs.tvmd);
}
| /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#include <vdp2/tvmd.h>
#include "vdp-internal.h"
void
vdp2_tvmd_display_clear(void)
{
_state_vdp2()->regs.tvmd &= 0x7EFF;
/* Change the DISP bit during VBLANK */
vdp2_tvmd_vblank_in_wait();
MEMORY_WRITE(16, VDP2(TVMD), _state_vdp2()->regs.tvmd);
}
|
Downgrade "libscp initialized" to LOG_LEVEL_DEBUG, remove line number | /**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2012
*
* 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 libscp_init.c
* @brief libscp initialization code
* @author Simone Fedele
*
*/
#include "libscp_init.h"
//struct log_config* s_log;
/* server API */
int DEFAULT_CC
scp_init()
{
/*
if (0 == log)
{
return 1;
}
*/
//s_log = log;
scp_lock_init();
log_message(LOG_LEVEL_WARNING, "[init:%d] libscp initialized", __LINE__);
return 0;
}
| /**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2012
*
* 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 libscp_init.c
* @brief libscp initialization code
* @author Simone Fedele
*
*/
#include "libscp_init.h"
//struct log_config* s_log;
/* server API */
int DEFAULT_CC
scp_init()
{
/*
if (0 == log)
{
return 1;
}
*/
//s_log = log;
scp_lock_init();
log_message(LOG_LEVEL_DEBUG, "libscp initialized");
return 0;
}
|
Add command to tune bulkd | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2013 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kotaka/paths/kotaka.h>
#include <kotaka/paths/string.h>
#include <kotaka/paths/system.h>
#include <kotaka/paths/text.h>
#include <kotaka/paths/thing.h>
inherit LIB_RAWVERB;
void main(object actor, string args)
{
object user;
float interval;
user = query_user();
if (user->query_class() < 2) {
send_out("You do not have sufficient access rights to tune the bulk sync system.\n");
return;
}
if (args == "") {
send_out("Current bulk sync interval: " + STRINGD->mixed_sprint(BULKD->query_interval()) + "\n");
return;
}
if (!sscanf(args, "%f", interval)) {
send_out("Floats only please.\n");
return;
}
BULKD->set_interval(interval);
send_out("BulkD tuned.\n");
return;
}
| |
Add a new-style constructor for labels | #pragma once
#include "Control.h"
#include "../../3RVX/Logger.h"
class Label : public Control {
public:
Label() {
}
Label(int id, HWND parent) :
Control(id, parent) {
}
}; | #pragma once
#include "Control.h"
#include "../../3RVX/Logger.h"
class Label : public Control {
public:
Label() {
}
Label(int id, HWND parent) :
Control(id, parent) {
}
Label(int id, DialogBase &parent, bool translate = true) :
Control(id, parent, false) {
}
}; |
Make stroke color an IBInspectable property. | #import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
@interface PPSSignatureView : GLKView
@property (assign, nonatomic) UIColor *strokeColor;
@property (assign, nonatomic) BOOL hasSignature;
@property (strong, nonatomic) UIImage *signatureImage;
- (void)erase;
@end
| #import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
@interface PPSSignatureView : GLKView
@property (assign, nonatomic) IBInspectable UIColor *strokeColor;
@property (assign, nonatomic) BOOL hasSignature;
@property (strong, nonatomic) UIImage *signatureImage;
- (void)erase;
@end
|
Add helper functions to safely release Windows COM resources, and arrays of COM resources. | //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angleutils.h: Common ANGLE utilities.
#ifndef COMMON_ANGLEUTILS_H_
#define COMMON_ANGLEUTILS_H_
// A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
template <typename T, unsigned int N>
inline unsigned int ArraySize(T(&)[N])
{
return N;
}
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
#define VENDOR_ID_AMD 0x1002
#define VENDOR_ID_INTEL 0x8086
#define VENDOR_ID_NVIDIA 0x10DE
#define GL_BGRA4_ANGLEX 0x6ABC
#define GL_BGR5_A1_ANGLEX 0x6ABD
#endif // COMMON_ANGLEUTILS_H_
| //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angleutils.h: Common ANGLE utilities.
#ifndef COMMON_ANGLEUTILS_H_
#define COMMON_ANGLEUTILS_H_
// A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
template <typename T, unsigned int N>
inline unsigned int ArraySize(T(&)[N])
{
return N;
}
template <typename T, unsigned int N>
void SafeRelease(T (&resourceBlock)[N])
{
for (unsigned int i = 0; i < N; i++)
{
SafeRelease(resourceBlock[i]);
}
}
template <typename T>
void SafeRelease(T& resource)
{
if (resource)
{
resource->Release();
resource = NULL;
}
}
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
#define VENDOR_ID_AMD 0x1002
#define VENDOR_ID_INTEL 0x8086
#define VENDOR_ID_NVIDIA 0x10DE
#define GL_BGRA4_ANGLEX 0x6ABC
#define GL_BGR5_A1_ANGLEX 0x6ABD
#endif // COMMON_ANGLEUTILS_H_
|
Set pointer to array data to null after free | #ifndef OOC_ARRAY_H_
#define OOC_ARRAY_H_
#define array_malloc(size) calloc(1, (size))
#define array_free free
#include <stdint.h>
#define _lang_array__Array_new(type, size) ((_lang_array__Array) { size, array_malloc((size) * sizeof(type)) });
#if defined(safe)
#define _lang_array__Array_get(array, index, type) ( \
((type*) array.data)[(index < 0 || index >= array.length) ? kean_exception_outOfBoundsException_throw(index, array.length), -1 : index])
#define _lang_array__Array_set(array, index, type, value) \
(((type*) array.data)[(index < 0 || index >= array.length) ? kean_exception_outOfBoundsException_throw(index, array.length), -1 : index] = value)
#else
#define _lang_array__Array_get(array, index, type) ( \
((type*) array.data)[index])
#define _lang_array__Array_set(array, index, type, value) \
(((type*) array.data)[index] = value)
#endif
#define _lang_array__Array_free(array) { array_free(array.data); }
typedef struct {
size_t length;
void* data;
} _lang_array__Array;
#endif
| #ifndef OOC_ARRAY_H_
#define OOC_ARRAY_H_
#define array_malloc(size) calloc(1, (size))
#define array_free free
#include <stdint.h>
#define _lang_array__Array_new(type, size) ((_lang_array__Array) { size, array_malloc((size) * sizeof(type)) });
#if defined(safe)
#define _lang_array__Array_get(array, index, type) ( \
((type*) array.data)[(index < 0 || index >= array.length) ? kean_exception_outOfBoundsException_throw(index, array.length), -1 : index])
#define _lang_array__Array_set(array, index, type, value) \
(((type*) array.data)[(index < 0 || index >= array.length) ? kean_exception_outOfBoundsException_throw(index, array.length), -1 : index] = value)
#else
#define _lang_array__Array_get(array, index, type) ( \
((type*) array.data)[index])
#define _lang_array__Array_set(array, index, type, value) \
(((type*) array.data)[index] = value)
#endif
#define _lang_array__Array_free(array) { array_free(array.data); array.data = NULL; array.length = 0; }
typedef struct {
size_t length;
void* data;
} _lang_array__Array;
#endif
|
Fix order of arguments to fputs | // RUN: %clang_asan -O2 %s -o %t
// RUN: %env_asan_opts=check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// FIXME: sprintf is not intercepted on Windows yet.
// XFAIL: win32
#include <stdio.h>
int main() {
volatile char c = '0';
volatile int x = 12;
volatile float f = 1.239;
volatile char s[] = "34";
volatile char buf[2];
fputs(stderr, "before sprintf");
sprintf((char *)buf, "%c %d %.3f %s\n", c, x, f, s);
fputs(stderr, "after sprintf");
fputs(stderr, (const char *)buf);
return 0;
// Check that size of output buffer is sanitized.
// CHECK-ON: before sprintf
// CHECK-ON-NOT: after sprintf
// CHECK-ON: stack-buffer-overflow
// CHECK-ON-NOT: 0 12 1.239 34
}
| // RUN: %clang_asan -O2 %s -o %t
// RUN: %env_asan_opts=check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// FIXME: sprintf is not intercepted on Windows yet.
// XFAIL: win32
#include <stdio.h>
int main() {
volatile char c = '0';
volatile int x = 12;
volatile float f = 1.239;
volatile char s[] = "34";
volatile char buf[2];
fputs("before sprintf\n", stderr);
sprintf((char *)buf, "%c %d %.3f %s\n", c, x, f, s);
fputs("after sprintf", stderr);
fputs((const char *)buf, stderr);
return 0;
// Check that size of output buffer is sanitized.
// CHECK-ON: before sprintf
// CHECK-ON-NOT: after sprintf
// CHECK-ON: stack-buffer-overflow
// CHECK-ON-NOT: 0 12 1.239 34
}
|
Adjust forward declarations in slobrok. | // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/config/helper/configfetcher.h>
#include <vespa/config/subscription/configuri.h>
#include <vespa/config-stateserver.h>
namespace vespalib {
class HealthProducer;
class MetricsProducer;
class ComponentConfigProducer;
class StateServer;
}
namespace slobrok {
class ReconfigurableStateServer : private config::IFetcherCallback<vespa::config::core::StateserverConfig> {
public:
ReconfigurableStateServer(const config::ConfigUri & configUri,
vespalib::HealthProducer & healt,
vespalib::MetricsProducer & metrics,
vespalib::ComponentConfigProducer & component);
~ReconfigurableStateServer();
private:
void configure(std::unique_ptr<vespa::config::core::StateserverConfig> config) override;
vespalib::HealthProducer & _health;
vespalib::MetricsProducer & _metrics;
vespalib::ComponentConfigProducer & _components;
std::unique_ptr<config::ConfigFetcher> _configFetcher;
std::unique_ptr<vespalib::StateServer> _server;
};
}
| // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/config/helper/configfetcher.h>
#include <vespa/config/subscription/configuri.h>
#include <vespa/config-stateserver.h>
namespace vespalib {
struct HealthProducer;
struct MetricsProducer;
struct ComponentConfigProducer;
class StateServer;
}
namespace slobrok {
class ReconfigurableStateServer : private config::IFetcherCallback<vespa::config::core::StateserverConfig> {
public:
ReconfigurableStateServer(const config::ConfigUri & configUri,
vespalib::HealthProducer & healt,
vespalib::MetricsProducer & metrics,
vespalib::ComponentConfigProducer & component);
~ReconfigurableStateServer();
private:
void configure(std::unique_ptr<vespa::config::core::StateserverConfig> config) override;
vespalib::HealthProducer & _health;
vespalib::MetricsProducer & _metrics;
vespalib::ComponentConfigProducer & _components;
std::unique_ptr<config::ConfigFetcher> _configFetcher;
std::unique_ptr<vespalib::StateServer> _server;
};
}
|
Allow specification of NoiseQuality with an int | #pragma once
#include <spotify/json.hpp>
#include <noise/noise.h>
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<noise::NoiseQuality>
{
using NoiseQuality = noise::NoiseQuality;
static codec::enumeration_t<NoiseQuality, codec::string_t> codec()
{
auto codec = codec::enumeration<NoiseQuality, std::string>({
{NoiseQuality::QUALITY_FAST, "Fast"},
{NoiseQuality::QUALITY_STD, "Standard"},
{NoiseQuality::QUALITY_BEST, "Best"}
});
return codec;
}
};
}
}
| #pragma once
#include <spotify/json.hpp>
#include <noise/noise.h>
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<noise::NoiseQuality>
{
using NoiseQuality = noise::NoiseQuality;
static codec::one_of_t<
codec::enumeration_t<NoiseQuality, codec::number_t<int>>,
codec::enumeration_t<NoiseQuality, codec::string_t>> codec()
{
auto codec_str = codec::enumeration<NoiseQuality, std::string>({
{NoiseQuality::QUALITY_FAST, "Fast"},
{NoiseQuality::QUALITY_STD, "Standard"},
{NoiseQuality::QUALITY_BEST, "Best"}
});
auto codec_int = codec::enumeration<NoiseQuality, int>({
{NoiseQuality::QUALITY_FAST, 0},
{NoiseQuality::QUALITY_STD, 1},
{NoiseQuality::QUALITY_BEST, 2}
});
return codec::one_of(codec_int, codec_str);
}
};
}
}
|
Replace printf with safe write to stdout | #define _GNU_SOURCE
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <sys/mman.h>
void* malloc(size_t size) {
printf("malloc... ");
size += sizeof(size_t);
int page_size = getpagesize();
int rem = size % page_size;
if (rem > 0) {
size += page_size - rem;
}
void* addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if (addr == MAP_FAILED) {
printf("fail\n");
return NULL;
}
printf("ok\n");
*(size_t*)addr = size;
return (size_t*)addr + 1;
}
void free (void *ptr) {
printf("free... ");
size_t* real_ptr = (size_t*)ptr - 1;
if (!munmap(real_ptr, *real_ptr)) {
printf("ok\n");
} else {
printf("fail\n");
}
}
| #define _GNU_SOURCE
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <sys/mman.h>
void* malloc(size_t size) {
write(STDOUT_FILENO, "malloc... ", 10);
size += sizeof(size_t);
int page_size = getpagesize();
int rem = size % page_size;
if (rem > 0) {
size += page_size - rem;
}
void* addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if (addr == MAP_FAILED) {
write(STDOUT_FILENO, "fail\n", 5);
return NULL;
}
write(STDOUT_FILENO, "ok\n", 3);
*(size_t*)addr = size;
return (size_t*)addr + 1;
}
void free (void *ptr) {
write(STDOUT_FILENO, "free... ", 8);
size_t* real_ptr = (size_t*)ptr - 1;
if (!munmap(real_ptr, *real_ptr)) {
write(STDOUT_FILENO, "ok\n", 3);
} else {
write(STDOUT_FILENO, "fail\n", 5);
}
}
|
Make lexer constructor raise exception when file not found. | #include <stdlib.h>
#include "py/lexer.h"
#include "memzip.h"
mp_lexer_t *mp_lexer_new_from_file(const char *filename)
{
void *data;
size_t len;
if (memzip_locate(filename, &data, &len) != MZ_OK) {
return NULL;
}
return mp_lexer_new_from_str_len(qstr_from_str(filename), (const char *)data, (mp_uint_t)len, 0);
}
| #include <stdlib.h>
#include "py/lexer.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "memzip.h"
mp_lexer_t *mp_lexer_new_from_file(const char *filename)
{
void *data;
size_t len;
if (memzip_locate(filename, &data, &len) != MZ_OK) {
mp_raise_OSError(MP_ENOENT);
}
return mp_lexer_new_from_str_len(qstr_from_str(filename), (const char *)data, (mp_uint_t)len, 0);
}
|
Use cluster iterator in to_int function | #include <string.h>
#include <stdbool.h>
#include "roman_convert_to_int.h"
#include "roman_clusters.h"
static const int ERROR = -1;
static bool starts_with(const char *str, RomanCluster cluster);
int roman_convert_to_int(const char *numeral)
{
if (!numeral) return ERROR;
int total = 0;
for (int cluster_index = 0; cluster_index < ROMAN_CLUSTERS_LENGTH; cluster_index++)
{
const RomanCluster cluster = ROMAN_CLUSTERS[cluster_index];
while (starts_with(numeral, cluster))
{
total += cluster.value;
numeral += cluster.length;
}
}
return *numeral ? ERROR : total;
}
static bool starts_with(const char *str, RomanCluster cluster)
{
return strncmp(str, cluster.letters, cluster.length) == 0;
}
| #include <string.h>
#include <stdbool.h>
#include "roman_convert_to_int.h"
#include "roman_clusters.h"
static const int ERROR = -1;
static bool starts_with(const char *str, RomanCluster cluster);
int roman_convert_to_int(const char *numeral)
{
if (!numeral) return ERROR;
int total = 0;
for (const RomanCluster *cluster = roman_cluster_largest();
cluster;
cluster = roman_cluster_next_smaller(cluster)
)
{
while (starts_with(numeral, *cluster))
{
total += cluster->value;
numeral += cluster->length;
}
}
return *numeral ? ERROR : total;
}
static bool starts_with(const char *str, RomanCluster cluster)
{
return strncmp(str, cluster.letters, cluster.length) == 0;
}
|
Revert to AlphaCalculatorMode in options codec | #pragma once
#include <spotify/json.hpp>
#include "Options.h"
#include "metaoutput/codecs/FilenamesCodec.h"
#include "TerrainSpecCodec.h"
#include "TileFormatCodec.h"
using namespace spotify::json::codec;
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<Options>
{
static object_t<Options> codec()
{
auto codec = object<Options>();
codec.required("OutputDirectory", &Options::outputDirectory);
codec.required("Terrains", &Options::terrains);
codec.required("TileFormat", &Options::tileFormat);
codec.required("Cliques", &Options::cliques);
codec.required("MetaOutput", &Options::outputFilenames);
codec.required("CalculatorMode", &Options::CalculatorMode,
codec::enumeration<tilegen::alpha::CalculatorMode, std::string>({
{tilegen::alpha::CalculatorMode::Max, "Max"},
{tilegen::alpha::CalculatorMode::Linear, "Linear"}}));
return codec;
}
};
}
}
| #pragma once
#include <spotify/json.hpp>
#include "Options.h"
#include "metaoutput/codecs/FilenamesCodec.h"
#include "TerrainSpecCodec.h"
#include "TileFormatCodec.h"
using namespace spotify::json::codec;
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<Options>
{
static object_t<Options> codec()
{
auto codec = object<Options>();
codec.required("OutputDirectory", &Options::outputDirectory);
codec.required("Terrains", &Options::terrains);
codec.required("TileFormat", &Options::tileFormat);
codec.required("Cliques", &Options::cliques);
codec.required("MetaOutput", &Options::outputFilenames);
codec.required("AlphaCalculatorMode", &Options::CalculatorMode,
codec::enumeration<tilegen::alpha::CalculatorMode, std::string>({
{tilegen::alpha::CalculatorMode::Max, "Max"},
{tilegen::alpha::CalculatorMode::Linear, "Linear"}}));
return codec;
}
};
}
}
|
Fix a bug in the queue implementation | #include <stddef.h>
#include <kernel/port/data.h>
void enq(Queue *q, List *item) {
item->next = NULL;
if(!q->tail) {
q->head = item;
q->tail = item;
} else {
q->tail->next = item;
}
}
List *deq(Queue *q) {
if(!q->head) {
return NULL;
}
List *ret = q->head;
q->head = q->head->next;
if(!q->head) {
q->tail = NULL;
}
ret->next = NULL;
return ret;
}
| #include <stddef.h>
#include <kernel/port/data.h>
void enq(Queue *q, List *item) {
item->next = NULL;
if(!q->tail) {
q->head = item;
q->tail = item;
} else {
q->tail->next = item;
q->tail = item;
}
}
List *deq(Queue *q) {
if(!q->head) {
return NULL;
}
List *ret = q->head;
q->head = q->head->next;
if(!q->head) {
q->tail = NULL;
}
ret->next = NULL;
return ret;
}
|
Reimplement InsertPointGuard to avoid LLVM ABI incompatibility. | #pragma once
#include "preprocessor/llvm_includes_start.h"
#include <llvm/IR/IRBuilder.h>
#include "preprocessor/llvm_includes_end.h"
namespace dev
{
namespace eth
{
namespace jit
{
class RuntimeManager;
/// Base class for compiler helpers like Memory, GasMeter, etc.
class CompilerHelper
{
protected:
CompilerHelper(llvm::IRBuilder<>& _builder);
CompilerHelper(const CompilerHelper&) = delete;
CompilerHelper& operator=(CompilerHelper) = delete;
/// Reference to the IR module being compiled
llvm::Module* getModule();
/// Reference to the main module function
llvm::Function* getMainFunction();
/// Reference to parent compiler IR builder
llvm::IRBuilder<>& m_builder;
llvm::IRBuilder<>& getBuilder() { return m_builder; }
llvm::CallInst* createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args);
friend class RuntimeHelper;
};
/// Compiler helper that depends on runtime data
class RuntimeHelper : public CompilerHelper
{
protected:
RuntimeHelper(RuntimeManager& _runtimeManager);
RuntimeManager& getRuntimeManager() { return m_runtimeManager; }
private:
RuntimeManager& m_runtimeManager;
};
using InsertPointGuard = llvm::IRBuilderBase::InsertPointGuard;
}
}
}
| #pragma once
#include "preprocessor/llvm_includes_start.h"
#include <llvm/IR/IRBuilder.h>
#include "preprocessor/llvm_includes_end.h"
namespace dev
{
namespace eth
{
namespace jit
{
class RuntimeManager;
/// Base class for compiler helpers like Memory, GasMeter, etc.
class CompilerHelper
{
protected:
CompilerHelper(llvm::IRBuilder<>& _builder);
CompilerHelper(const CompilerHelper&) = delete;
CompilerHelper& operator=(CompilerHelper) = delete;
/// Reference to the IR module being compiled
llvm::Module* getModule();
/// Reference to the main module function
llvm::Function* getMainFunction();
/// Reference to parent compiler IR builder
llvm::IRBuilder<>& m_builder;
llvm::IRBuilder<>& getBuilder() { return m_builder; }
llvm::CallInst* createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args);
friend class RuntimeHelper;
};
/// Compiler helper that depends on runtime data
class RuntimeHelper : public CompilerHelper
{
protected:
RuntimeHelper(RuntimeManager& _runtimeManager);
RuntimeManager& getRuntimeManager() { return m_runtimeManager; }
private:
RuntimeManager& m_runtimeManager;
};
struct InsertPointGuard
{
explicit InsertPointGuard(llvm::IRBuilderBase& _builder): m_builder(_builder), m_insertPoint(_builder.saveIP()) {}
~InsertPointGuard() { m_builder.restoreIP(m_insertPoint); }
private:
llvm::IRBuilderBase& m_builder;
decltype(m_builder.saveIP()) m_insertPoint;
};
}
}
}
|
Add alpha intrinsics, contributed by Rahul Joshi | //===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===//
//
// This file defines a set of enums which allow processing of intrinsic
// functions. Values of these enum types are returned by
// Function::getIntrinsicID.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_INTRINSICS_H
#define LLVM_INTRINSICS_H
/// LLVMIntrinsic Namespace - This namespace contains an enum with a value for
/// every intrinsic/builtin function known by LLVM. These enum values are
/// returned by Function::getIntrinsicID().
///
namespace LLVMIntrinsic {
enum ID {
not_intrinsic = 0, // Must be zero
va_start, // Used to represent a va_start call in C
va_end, // Used to represent a va_end call in C
va_copy, // Used to represent a va_copy call in C
setjmp, // Used to represent a setjmp call in C
longjmp, // Used to represent a longjmp call in C
};
}
#endif
| //===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===//
//
// This file defines a set of enums which allow processing of intrinsic
// functions. Values of these enum types are returned by
// Function::getIntrinsicID.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_INTRINSICS_H
#define LLVM_INTRINSICS_H
/// LLVMIntrinsic Namespace - This namespace contains an enum with a value for
/// every intrinsic/builtin function known by LLVM. These enum values are
/// returned by Function::getIntrinsicID().
///
namespace LLVMIntrinsic {
enum ID {
not_intrinsic = 0, // Must be zero
va_start, // Used to represent a va_start call in C
va_end, // Used to represent a va_end call in C
va_copy, // Used to represent a va_copy call in C
setjmp, // Used to represent a setjmp call in C
longjmp, // Used to represent a longjmp call in C
//===------------------------------------------------------------------===//
// This section defines intrinsic functions used to represent Alpha
// instructions...
//
alpha_ctlz, // CTLZ (count leading zero): counts the number of leading
// zeros in the given ulong value
alpha_cttz, // CTTZ (count trailing zero): counts the number of trailing
// zeros in the given ulong value
alpha_ctpop, // CTPOP (count population): counts the number of ones in
// the given ulong value
alpha_umulh, // UMULH (unsigned multiply quadword high): Takes two 64-bit
// (ulong) values, and returns the upper 64 bits of their
// 128 bit product as a ulong
};
}
#endif
|
Work better on various versions of clang. |
#pragma once
#include <cassert>
#include <string>
#define assert2(expr, str) \
((expr) \
? __ASSERT_VOID_CAST (0)\
: __assert_fail ((std::string(__STRING(expr)) + "; " + (str)).c_str(), __FILE__, __LINE__, __ASSERT_FUNCTION))
|
#pragma once
#include <cassert>
#include <string>
#if __GNUC__
#define assert2(expr, str) \
((expr) \
? __ASSERT_VOID_CAST (0)\
: __assert_fail ((std::string(__STRING(expr)) + "; " + (str)).c_str(), __FILE__, __LINE__, __ASSERT_FUNCTION))
#elif __clang__
#define assert2(expr, str) \
((expr) \
? (void)(0)\
: __assert_rtn ((std::string(__STRING(expr)) + "; " + (str)).c_str(), __FILE__, __LINE__, __func__))
#else
#define assert2(expr, str) assert(expr)
#endif
|
Update the OpenSSH addendum string for the buffer handling fix. | /* $OpenBSD: version.h,v 1.37 2003/04/01 10:56:46 markus Exp $ */
/* $FreeBSD$ */
#ifndef SSH_VERSION
#define SSH_VERSION (ssh_version_get())
#define SSH_VERSION_BASE "OpenSSH_3.6.1p1"
#define SSH_VERSION_ADDENDUM "FreeBSD-20030423"
const char *ssh_version_get(void);
void ssh_version_set_addendum(const char *add);
#endif /* SSH_VERSION */
| /* $OpenBSD: version.h,v 1.37 2003/04/01 10:56:46 markus Exp $ */
/* $FreeBSD$ */
#ifndef SSH_VERSION
#define SSH_VERSION (ssh_version_get())
#define SSH_VERSION_BASE "OpenSSH_3.6.1p1"
#define SSH_VERSION_ADDENDUM "FreeBSD-20030916"
const char *ssh_version_get(void);
void ssh_version_set_addendum(const char *add);
#endif /* SSH_VERSION */
|
Make things depend on the compiler (G++, bsdcc, others) rather than on specific platforms. | #if defined(AIX32) && defined(__cplusplus )
# include "fix_gnu_fcntl.h"
#elif defined(AIX32) && !defined(__cplusplus )
typedef unsigned short ushort;
# include <fcntl.h>
#elif defined(ULTRIX42) && defined(__cplusplus )
# include "fix_gnu_fcntl.h"
#else
# include <fcntl.h>
#endif
| #if defined(__cplusplus) && !defined(OSF1) /* GNU G++ */
# include "fix_gnu_fcntl.h"
#elif defined(AIX32) /* AIX bsdcc */
# typedef unsigned short ushort;
# include <fcntl.h>
#else /* Everybody else */
# include <fcntl.h>
#endif
|
Clarify class comment for ExtensionMessageHandler. | // 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#pragma once
#include "content/browser/renderer_host/render_view_host_observer.h"
class Profile;
struct ExtensionHostMsg_DomMessage_Params;
// Filters and dispatches extension-related IPC messages that arrive from
// renderer/extension processes. This object is created for renderers and also
// ExtensionHost/BackgroundContents. Contrast this with ExtensionTabHelper,
// which is only created for TabContents.
class ExtensionMessageHandler : public RenderViewHostObserver {
public:
// |sender| is guaranteed to outlive this object.
explicit ExtensionMessageHandler(RenderViewHost* render_view_host);
virtual ~ExtensionMessageHandler();
// RenderViewHostObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message);
private:
// Message handlers.
void OnPostMessage(int port_id, const std::string& message);
void OnRequest(const ExtensionHostMsg_DomMessage_Params& params);
DISALLOW_COPY_AND_ASSIGN(ExtensionMessageHandler);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_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 CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#pragma once
#include "content/browser/renderer_host/render_view_host_observer.h"
class Profile;
struct ExtensionHostMsg_DomMessage_Params;
// Filters and dispatches extension-related IPC messages that arrive from
// renderers. There is one of these objects for each RenderViewHost in Chrome.
// Contrast this with ExtensionTabHelper, which is only created for TabContents.
class ExtensionMessageHandler : public RenderViewHostObserver {
public:
// |sender| is guaranteed to outlive this object.
explicit ExtensionMessageHandler(RenderViewHost* render_view_host);
virtual ~ExtensionMessageHandler();
// RenderViewHostObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message);
private:
// Message handlers.
void OnPostMessage(int port_id, const std::string& message);
void OnRequest(const ExtensionHostMsg_DomMessage_Params& params);
DISALLOW_COPY_AND_ASSIGN(ExtensionMessageHandler);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
|
Use Foundation framework instead of UIKit. | //
// ReactiveAlamofire.h
// ReactiveAlamofire
//
// Created by Srdan Rasic on 23/04/16.
// Copyright © 2016 ReactiveKit. All rights reserved.
//
//! Project version number for ReactiveAlamofire.
FOUNDATION_EXPORT double ReactiveAlamofireVersionNumber;
//! Project version string for ReactiveAlamofire.
FOUNDATION_EXPORT const unsigned char ReactiveAlamofireVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <ReactiveAlamofire/PublicHeader.h>
| //
// ReactiveAlamofire.h
// ReactiveAlamofire
//
// Created by Srdan Rasic on 23/04/16.
// Copyright © 2016 ReactiveKit. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for ReactiveAlamofire.
FOUNDATION_EXPORT double ReactiveAlamofireVersionNumber;
//! Project version string for ReactiveAlamofire.
FOUNDATION_EXPORT const unsigned char ReactiveAlamofireVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <ReactiveAlamofire/PublicHeader.h>
|
Send only one packet at a time. | #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "gpio.h"
#include "leds.h"
#include "radio.h"
void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
{
led_toggle(i);
nrf_delay_us(50000);
}
}
}
void radio_evt_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
uint32_t err_code;
leds_init();
radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;
radio_init(radio_evt_handler);
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
led_toggle(LED0);
nrf_delay_us(1000000);
}
}
| #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "gpio.h"
#include "leds.h"
#include "radio.h"
void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
{
led_toggle(i);
nrf_delay_us(50000);
}
}
}
void radio_evt_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
uint32_t err_code;
leds_init();
radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;
radio_init(radio_evt_handler);
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
led_toggle(LED0);
nrf_delay_us(1000000);
}
}
|
Add pragmas to differentiate init method types | //
// GITBlob.h
// CocoaGit
//
// Created by Geoffrey Garside on 29/06/2008.
// Copyright 2008 ManicPanda.com. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "GITObject.h"
@interface GITBlob : GITObject {
NSData * data;
}
#pragma mark -
#pragma mark Properties
@property(retain) NSData * data;
#pragma mark -
#pragma mark Init Methods
- (id)initWithContentsOfFile:(NSString*)filePath;
- (id)initWithData:(NSData*)dataContent;
#pragma mark -
#pragma mark Instance Methods
- (BOOL)write;
- (BOOL)writeWithError:(NSError**)errorPtr;
@end
| //
// GITBlob.h
// CocoaGit
//
// Created by Geoffrey Garside on 29/06/2008.
// Copyright 2008 ManicPanda.com. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "GITObject.h"
@interface GITBlob : GITObject {
NSData * data;
}
#pragma mark -
#pragma mark Properties
@property(retain) NSData * data;
#pragma mark -
#pragma mark Reading existing Blob objects
- (id)initFromHash:(NSString*)objectHash;
#pragma mark -
#pragma mark Creating new Blob objects
- (id)initWithData:(NSData*)dataContent;
- (id)initWithContentsOfFile:(NSString*)filePath;
#pragma mark -
#pragma mark Instance Methods
- (BOOL)write;
- (BOOL)writeWithError:(NSError**)errorPtr;
@end
|
Add API to detect SCU base address from CP15 | #ifndef __ASMARM_ARCH_SCU_H
#define __ASMARM_ARCH_SCU_H
#define SCU_PM_NORMAL 0
#define SCU_PM_DORMANT 2
#define SCU_PM_POWEROFF 3
#ifndef __ASSEMBLER__
unsigned int scu_get_core_count(void __iomem *);
void scu_enable(void __iomem *);
int scu_power_mode(void __iomem *, unsigned int);
#endif
#endif
| #ifndef __ASMARM_ARCH_SCU_H
#define __ASMARM_ARCH_SCU_H
#define SCU_PM_NORMAL 0
#define SCU_PM_DORMANT 2
#define SCU_PM_POWEROFF 3
#ifndef __ASSEMBLER__
#include <asm/cputype.h>
static inline bool scu_a9_has_base(void)
{
return read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9;
}
static inline unsigned long scu_a9_get_base(void)
{
unsigned long pa;
asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (pa));
return pa;
}
unsigned int scu_get_core_count(void __iomem *);
void scu_enable(void __iomem *);
int scu_power_mode(void __iomem *, unsigned int);
#endif
#endif
|
Define some more common ip22 CPU features. | /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2003 Ralf Baechle
*/
#ifndef __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
#define __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
/*
* IP22 with a variety of processors so we can't use defaults for everything.
*/
#define cpu_has_mips16 0
#define cpu_has_divec 0
#define cpu_has_cache_cdex_p 1
#define cpu_has_prefetch 0
#define cpu_has_mcheck 0
#define cpu_has_ejtag 0
#define cpu_has_llsc 1
#define cpu_has_vtag_icache 0 /* Needs to change for R8000 */
#define cpu_has_dc_aliases (PAGE_SIZE < 0x4000)
#define cpu_has_ic_fills_f_dc 0
#define cpu_has_dsp 0
#define cpu_has_nofpuex 0
#define cpu_has_64bits 1
#endif /* __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H */
| /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2003 Ralf Baechle
*/
#ifndef __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
#define __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
/*
* IP22 with a variety of processors so we can't use defaults for everything.
*/
#define cpu_has_tlb 1
#define cpu_has_4kex 1
#define cpu_has_4ktlb 1
#define cpu_has_fpu 1
#define cpu_has_32fpr 1
#define cpu_has_counter 1
#define cpu_has_mips16 0
#define cpu_has_divec 0
#define cpu_has_cache_cdex_p 1
#define cpu_has_prefetch 0
#define cpu_has_mcheck 0
#define cpu_has_ejtag 0
#define cpu_has_llsc 1
#define cpu_has_vtag_icache 0 /* Needs to change for R8000 */
#define cpu_has_dc_aliases (PAGE_SIZE < 0x4000)
#define cpu_has_ic_fills_f_dc 0
#define cpu_has_dsp 0
#define cpu_has_nofpuex 0
#define cpu_has_64bits 1
#endif /* __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H */
|
Remove all trace functions from pre 0.0.1 prototyping | #include "cearth_network.h"
void
blob_init(blob *b)
{
b->size = 0;
}
void
blob_add_int8(blob *b, int8_t i)
{
b->data[b->size] = i;
b->size++;
}
void
blob_add_str(blob *b, char *str)
{
int len = strlen(str);
strcpy((char *)b->data+b->size, str);
b->size += len;
}
| #include "cearth_network.h"
|
Add a single linked list | #include <stdio.h>
#include <stdlib.h>
typedef struct list_t {
int data;
struct list_t *next;
} list_t;
list_t *insert_start(list_t *list, int data) {
list_t *node = malloc(sizeof(list_t));
node->data = data;
node->next = list;
return node;
}
list_t *insert_end(list_t *list, int data) {
list_t *node = malloc(sizeof(list_t));
node->data = data;
node->next = list;
if (list == NULL)
return node;
list_t *temp = list;
while (temp->next != NULL)
temp = temp->next;
temp->next = node;
node->next = NULL;
return list;
}
list_t *remove_first(list_t *list) {
if (list == NULL)
return NULL;
list_t *next = list->next;
free(list);
return next;
}
void print_list(list_t *list) {
while (list != NULL) {
printf("%d ", list->data);
list = list->next;
}
printf("\n");
}
int main(void) {
list_t *list = NULL;
list = insert_start(list, 6);
list = insert_start(list, 3);
list = insert_start(list, 1);
print_list(list);
list = remove_first(list);
print_list(list);
list = insert_end(list, 12);
list = insert_end(list, 13);
list = insert_end(list, 14);
print_list(list);
} | |
Fix header file inclusion/define problems with xmalloc & Co and ruby | #ifndef H_RPM_RB
#define H_RPM_RB
/**
* \file ruby/rpm-rb.h
* \ingroup rb_c
*
* RPM Ruby bindings "RPM" module
*/
#include "system.h"
#include <rpmiotypes.h>
#include <rpmtypes.h>
#include <rpmtag.h>
#undef xmalloc
#undef xcalloc
#undef xrealloc
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#include <ruby.h>
#pragma GCC diagnostic warning "-Wstrict-prototypes"
/**
* The "RPM" Ruby module.
*/
extern VALUE rpmModule;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Defines the "RPM" Ruby module and makes it known to the Interpreter.
*/
void Init_rpm(void);
/**
* Raises a Ruby exception (RPM::Error).
*
* @param error The return code leading to the exception
* @param message A message to include in the exception.
*/
void rpm_rb_raise(rpmRC error, char *message);
#ifdef __cplusplus
}
#endif
#endif /* H_RPM_RB */
| #ifndef H_RPM_RB
#define H_RPM_RB
/**
* \file ruby/rpm-rb.h
* \ingroup rb_c
*
* RPM Ruby bindings "RPM" module
*/
#include "system.h"
#include <rpmiotypes.h>
#include <rpmtypes.h>
#include <rpmtag.h>
/**
* The "RPM" Ruby module.
*/
extern VALUE rpmModule;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Defines the "RPM" Ruby module and makes it known to the Interpreter.
*/
void Init_rpm(void);
/**
* Raises a Ruby exception (RPM::Error).
*
* @param error The return code leading to the exception
* @param message A message to include in the exception.
*/
void rpm_rb_raise(rpmRC error, char *message);
#ifdef __cplusplus
}
#endif
#endif /* H_RPM_RB */
|
Add structure for stack frame | #pragma once
namespace cpu {
struct stack_frame {
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
uint32_t esi;
uint32_t edi;
uint32_t ebp;
uint32_t eax;
uint16_t ds, __ds;
uint16_t es, __es;
uint16_t fs, __fs;
uint16_t gs, __gs;
uint32_t eip;
uint16_t cs, __cs;
uint32_t eflags;
uint32_t esp;
uint16_t ss, __ss;
};
} // namespace cpu
| |
Use mt64_context instead of mp_rand_ctx | #ifndef _RSA_H_
#define _RSA_H_
#include "mpi.h"
/* Everything must be kept private except for n and e.
* (n,e) is the public key, (n,d) is the private key. */
typedef struct {
mpi_t n; /* modulus n = pq */
mpi_t phi; /* phi = (p-1)(q-1) */
mpi_t e; /* public exponent 1 < e < phi s.t. gcd(e,phi)=1 */
mpi_t d; /* secret exponent 1 < d < phi s.t. ed=1 (mod phi) */
} rsa_ctx;
void rsa_init(rsa_ctx *rsa, unsigned bits, mp_rand_ctx *rand_ctx);
void rsa_free(rsa_ctx *rsa);
/* Transform cleartext into encrypted data. */
void rsa_encrypt(rsa_ctx *ctx, const void *input, unsigned input_size,
void *output, unsigned *output_size);
/* Transform encrypted data back to cleartext. */
void rsa_decrypt(rsa_ctx *ctx, const void *input, unsigned input_size,
void *output, unsigned *output_size);
#endif /* !_RSA_H_ */
| #ifndef _RSA_H_
#define _RSA_H_
#include "mpi.h"
/* Everything must be kept private except for n and e.
* (n,e) is the public key, (n,d) is the private key. */
typedef struct {
mpi_t n; /* modulus n = pq */
mpi_t phi; /* phi = (p-1)(q-1) */
mpi_t e; /* public exponent 1 < e < phi s.t. gcd(e,phi)=1 */
mpi_t d; /* secret exponent 1 < d < phi s.t. ed=1 (mod phi) */
} rsa_ctx;
void rsa_init(rsa_ctx *rsa, unsigned bits, mt64_context *rand_ctx);
void rsa_free(rsa_ctx *rsa);
/* Transform cleartext into encrypted data. */
void rsa_encrypt(rsa_ctx *ctx, const void *input, unsigned input_size,
void *output, unsigned *output_size);
/* Transform encrypted data back to cleartext. */
void rsa_decrypt(rsa_ctx *ctx, const void *input, unsigned input_size,
void *output, unsigned *output_size);
#endif /* !_RSA_H_ */
|
Add regression test for PR15823 | // RUN: %clang %s -Wl,-as-needed -o %t && %run %t
// Regression test for PR15823
// (http://llvm.org/bugs/show_bug.cgi?id=15823).
#include <stdio.h>
#include <time.h>
int main() {
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return 0;
}
| |
Rename isFile -> exists in header file too | //
// file_API.h
// Forge
//
// Copyright (c) 2020 Trigger Corp. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface file_API : NSObject
+ (void)getImage:(ForgeTask*)task;
+ (void)getVideo:(ForgeTask*)task;
+ (void)getFileFromSourceDirectory:(ForgeTask*)task resource:(NSString*)resource;
+ (void)getURLFromSourceDirectory:(ForgeTask*)task resource:(NSString*)resource;
+ (void)getScriptPath:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)getScriptURL:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)isFile:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)info:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)base64:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)string:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)remove:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)cacheURL:(ForgeTask*)task url:(NSString*)url;
+ (void)saveURL:(ForgeTask*)task url:(NSString*)url;
+ (void)clearCache:(ForgeTask*)task;
+ (void)getStorageSizeInformation:(ForgeTask*)task;
@end
| //
// file_API.h
// Forge
//
// Copyright (c) 2020 Trigger Corp. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface file_API : NSObject
+ (void)getImage:(ForgeTask*)task;
+ (void)getVideo:(ForgeTask*)task;
+ (void)getFileFromSourceDirectory:(ForgeTask*)task resource:(NSString*)resource;
+ (void)getURLFromSourceDirectory:(ForgeTask*)task resource:(NSString*)resource;
+ (void)getScriptPath:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)getScriptURL:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)exists:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)info:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)base64:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)string:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)remove:(ForgeTask*)task file:(NSDictionary*)file;
+ (void)cacheURL:(ForgeTask*)task url:(NSString*)url;
+ (void)saveURL:(ForgeTask*)task url:(NSString*)url;
+ (void)clearCache:(ForgeTask*)task;
+ (void)getStorageSizeInformation:(ForgeTask*)task;
@end
|
Add proper import for NIMutableViewModel | //
// Copyright 2011-2014 NimbusKit
//
// 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.
//
#import "NIMutableTableViewModel.h"
@interface NIMutableTableViewModel (Private)
@property (nonatomic, strong) NSMutableArray* sections; // Array of NITableViewModelSection
@property (nonatomic, strong) NSMutableArray* sectionIndexTitles;
@property (nonatomic, strong) NSMutableDictionary* sectionPrefixToSectionIndex;
@end
@interface NITableViewModelSection (Mutable)
- (NSMutableArray *)mutableRows;
@end
| //
// Copyright 2011-2014 NimbusKit
//
// 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.
//
#import "NIMutableTableViewModel.h"
#import "NITableViewModel+Private.h"
@interface NIMutableTableViewModel (Private)
@property (nonatomic, strong) NSMutableArray* sections; // Array of NITableViewModelSection
@property (nonatomic, strong) NSMutableArray* sectionIndexTitles;
@property (nonatomic, strong) NSMutableDictionary* sectionPrefixToSectionIndex;
@end
@interface NITableViewModelSection (Mutable)
- (NSMutableArray *)mutableRows;
@end
|
Remove declaration of IrtInit(), which is no longer defined anywhere | /*
* 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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PPRUNTIME_H_
#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PPRUNTIME_H_
#include "native_client/src/include/portability.h"
#include "native_client/src/untrusted/irt/irt_ppapi.h"
EXTERN_C_BEGIN
// Initialize srpc connection to the browser. Some APIs like manifest file
// opening do not need full ppapi initialization and so can be used after
// this function returns.
int IrtInit(void);
// The entry point for the main thread of the PPAPI plugin process.
int PpapiPluginMain(void);
void PpapiPluginRegisterThreadCreator(
const struct PP_ThreadFunctions* new_funcs);
EXTERN_C_END
#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PPRUNTIME_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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PPRUNTIME_H_
#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PPRUNTIME_H_
#include "native_client/src/include/portability.h"
#include "native_client/src/untrusted/irt/irt_ppapi.h"
EXTERN_C_BEGIN
// The entry point for the main thread of the PPAPI plugin process.
int PpapiPluginMain(void);
void PpapiPluginRegisterThreadCreator(
const struct PP_ThreadFunctions* new_funcs);
EXTERN_C_END
#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PPRUNTIME_H_
|
Fix SAUL read error return | /*
* Copyright (C) 2018 HAW-Hamburg
*
* 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 drivers_sds011
* @{
*
* @file
* @brief SAUL adaption for SDS011 sensor
*
* @author Michel Rottleuthner <michel.rottleuthner@haw-hamburg.de>
*
* @}
*/
#include <string.h>
#include "saul.h"
#include "sds011.h"
#include "xtimer.h"
static int _read(const void *dev, phydat_t *res)
{
sds011_data_t data;
if (sds011_read((sds011_t *)dev, &data) == SDS011_OK) {
res->val[0] = data.pm_2_5;
res->val[1] = data.pm_10;
res->unit = UNIT_GPM3;
res->scale = -7;
return 2;
}
return ECANCELED;
}
const saul_driver_t sds011_saul_driver = {
.read = _read,
.write = saul_notsup,
.type = SAUL_SENSE_PM
};
| /*
* Copyright (C) 2018 HAW-Hamburg
*
* 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 drivers_sds011
* @{
*
* @file
* @brief SAUL adaption for SDS011 sensor
*
* @author Michel Rottleuthner <michel.rottleuthner@haw-hamburg.de>
*
* @}
*/
#include <string.h>
#include "saul.h"
#include "sds011.h"
#include "xtimer.h"
static int _read(const void *dev, phydat_t *res)
{
sds011_data_t data;
if (sds011_read((sds011_t *)dev, &data) == SDS011_OK) {
res->val[0] = data.pm_2_5;
res->val[1] = data.pm_10;
res->unit = UNIT_GPM3;
res->scale = -7;
return 2;
}
return -ECANCELED;
}
const saul_driver_t sds011_saul_driver = {
.read = _read,
.write = saul_notsup,
.type = SAUL_SENSE_PM
};
|
Add SPI bit modify command definition | #ifndef MCP2515_LIB_DEFINITIONS_H_
#define MCP2515_LIB_DEFINITIONS_H_
/*******************************************************************************
SPI Commands
*******************************************************************************/
#define SPI_READ 0x03
/*******************************************************************************
Register Addresses - specific info about each register can be found in the
datasheet.
*******************************************************************************/
#define CANINTF 0x2C
/*******************************************************************************
Interrupt Flag Bit Masks - each bit mask aligns with a position in the CANINTF
register. Specific info about each flag can be found in the datasheet.
*******************************************************************************/
#define MERRF 0x80
#define WAKIF 0x40
#define ERRIF 0x20
#define TX2IF 0x10
#define TX1IF 0x08
#define TX0IF 0x04
#define RX1IF 0x02
#define RX0IF 0x01
/*******************************************************************************
Flag Test Macro - determines whether the specified flag is set.
- flags: a value read from the CANINTF register
- bit_mask: one of the Interrupt Flag Bit Masks
*******************************************************************************/
#define IS_FLAG_SET(flags, bit_mask) (flags & bit_mask)
#endif
| #ifndef MCP2515_LIB_DEFINITIONS_H_
#define MCP2515_LIB_DEFINITIONS_H_
/*******************************************************************************
SPI Commands
*******************************************************************************/
#define SPI_READ 0x03
#define SPI_BIT_MODIFY 0x05
/*******************************************************************************
Register Addresses - specific info about each register can be found in the
datasheet.
*******************************************************************************/
#define CANINTF 0x2C
/*******************************************************************************
Interrupt Flag Bit Masks - each bit mask aligns with a position in the CANINTF
register. Specific info about each flag can be found in the datasheet.
*******************************************************************************/
#define MERRF 0x80
#define WAKIF 0x40
#define ERRIF 0x20
#define TX2IF 0x10
#define TX1IF 0x08
#define TX0IF 0x04
#define RX1IF 0x02
#define RX0IF 0x01
/*******************************************************************************
Flag Test Macro - determines whether the specified flag is set.
- flags: a value read from the CANINTF register
- bit_mask: one of the Interrupt Flag Bit Masks
*******************************************************************************/
#define IS_FLAG_SET(flags, bit_mask) (flags & bit_mask)
#endif
|
Comment out unnecessary use of gvio.h |
#ifndef CSETTINGS_H
#define CSETTINGS_H
class MdiChild;
#include <QDialog>
#include <QString>
#include "ui_settings.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gvc.h"
#include "gvio.h"
class CFrmSettings : public QDialog
{
Q_OBJECT
public:
CFrmSettings();
int runSettings(MdiChild* m);
int showSettings(MdiChild* m);
int cur;
int drawGraph();
MdiChild* getActiveWindow();
QString graphData;
private slots:
void outputSlot();
void addSlot();
void helpSlot();
void cancelSlot();
void okSlot();
void newSlot();
void openSlot();
void saveSlot();
private:
//Actions
Agraph_t* graph;
MdiChild* activeWindow;
GVC_t* gvc;
QAction* outputAct;
QAction* addAct;
QAction* helpAct;
QAction* cancelAct;
QAction* okAct;
QAction* newAct;
QAction* openAct;
QAction* saveAct;
//METHODS
QString buildOutputFile(QString _fileName);
void addAttribute(QString _scope,QString _name,QString _value);
bool loadLayouts();
bool loadRenderers();
void refreshContent();
void saveContent();
void setActiveWindow(MdiChild* m);
bool loadGraph(MdiChild* m);
bool createLayout();
bool renderLayout();
};
#endif
|
#ifndef CSETTINGS_H
#define CSETTINGS_H
class MdiChild;
#include <QDialog>
#include <QString>
#include "ui_settings.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gvc.h"
/* #include "gvio.h" */
class CFrmSettings : public QDialog
{
Q_OBJECT
public:
CFrmSettings();
int runSettings(MdiChild* m);
int showSettings(MdiChild* m);
int cur;
int drawGraph();
MdiChild* getActiveWindow();
QString graphData;
private slots:
void outputSlot();
void addSlot();
void helpSlot();
void cancelSlot();
void okSlot();
void newSlot();
void openSlot();
void saveSlot();
private:
//Actions
Agraph_t* graph;
MdiChild* activeWindow;
GVC_t* gvc;
QAction* outputAct;
QAction* addAct;
QAction* helpAct;
QAction* cancelAct;
QAction* okAct;
QAction* newAct;
QAction* openAct;
QAction* saveAct;
//METHODS
QString buildOutputFile(QString _fileName);
void addAttribute(QString _scope,QString _name,QString _value);
bool loadLayouts();
bool loadRenderers();
void refreshContent();
void saveContent();
void setActiveWindow(MdiChild* m);
bool loadGraph(MdiChild* m);
bool createLayout();
bool renderLayout();
};
#endif
|
Add helper macro to log scope entry and exit | //----------------------------------------------------------------------------
//
// "Copyright Centre National d'Etudes Spatiales"
//
// License: LGPL-2
//
// See LICENSE.txt file in the top level directory for more details.
//
//----------------------------------------------------------------------------
// $Id$
#ifndef ossimTraceHelpers_h
#define ossimTraceHelpers_h
#include <ossim/base/ossimTrace.h>
#include <ossim/base/ossimNotify.h>
namespace ossimplugins {
/** Helper class to log automatically entering and leaving scopes.
* @warning Not meant to be used directly. Use \c SCOPED_LOG instead.
*/
struct ScopedLogger
{
ScopedLogger(ossimTrace & channel, char const* module, ossimNotifyLevel level = ossimNotifyLevel_DEBUG)
: m_channel(channel)
, MODULE(module)
{
if (m_channel()) {
ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
}
}
~ScopedLogger() {
if (m_channel()) {
ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " left...\n";
}
}
private:
ScopedLogger(ScopedLogger const&);
ScopedLogger& operator=(ScopedLogger const&);
ossimTrace & m_channel;
char const* MODULE;
};
#define SCOPED_LOG(channel, msg) \
SCOPED_LOG_NAME(__LINE__)(channel, msg)
#define SCOPED_LOG_NAME(x) \
SCOPED_LOG_NAME0(x)
#define SCOPED_LOG_NAME0(x) \
ossimplugins::ScopedLogger slog ## x
} // ossimplugins namespace
#endif // ossimTraceHelpers_h
| |
Add memory control method to support OneNAND sync burst read | /*
* linux/include/asm-arm/mach/flash.h
*
* Copyright (C) 2003 Russell King, All Rights Reserved.
*
* 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 ASMARM_MACH_FLASH_H
#define ASMARM_MACH_FLASH_H
struct mtd_partition;
/*
* map_name: the map probe function name
* name: flash device name (eg, as used with mtdparts=)
* width: width of mapped device
* init: method called at driver/device initialisation
* exit: method called at driver/device removal
* set_vpp: method called to enable or disable VPP
* parts: optional array of mtd_partitions for static partitioning
* nr_parts: number of mtd_partitions for static partitoning
*/
struct flash_platform_data {
const char *map_name;
const char *name;
unsigned int width;
int (*init)(void);
void (*exit)(void);
void (*set_vpp)(int on);
struct mtd_partition *parts;
unsigned int nr_parts;
};
#endif
| /*
* linux/include/asm-arm/mach/flash.h
*
* Copyright (C) 2003 Russell King, All Rights Reserved.
*
* 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 ASMARM_MACH_FLASH_H
#define ASMARM_MACH_FLASH_H
struct mtd_partition;
struct mtd_info;
/*
* map_name: the map probe function name
* name: flash device name (eg, as used with mtdparts=)
* width: width of mapped device
* init: method called at driver/device initialisation
* exit: method called at driver/device removal
* set_vpp: method called to enable or disable VPP
* mmcontrol: method called to enable or disable Sync. Burst Read in OneNAND
* parts: optional array of mtd_partitions for static partitioning
* nr_parts: number of mtd_partitions for static partitoning
*/
struct flash_platform_data {
const char *map_name;
const char *name;
unsigned int width;
int (*init)(void);
void (*exit)(void);
void (*set_vpp)(int on);
void (*mmcontrol)(struct mtd_info *mtd, int sync_read);
struct mtd_partition *parts;
unsigned int nr_parts;
};
#endif
|
Test showing no flow through aggregate init | void sink(void *o);
void *user_input(void);
struct AB {
void *a;
void *b;
};
struct Outer {
struct AB nestedAB;
struct AB *pointerAB;
};
void absink(struct AB *ab) {
sink(ab->a); // flow x3 [NOT DETECTED]
sink(ab->b); // no flow
}
int struct_init(void) {
struct AB ab = { user_input(), 0 };
sink(ab.a); // flow [NOT DETECTED]
sink(ab.b); // no flow
absink(&ab);
struct Outer outer = {
{ user_input(), 0 },
&ab,
};
sink(outer.nestedAB.a); // flow [NOT DETECTED]
sink(outer.nestedAB.b); // no flow
sink(outer.pointerAB->a); // flow [NOT DETECTED]
sink(outer.pointerAB->b); // no flow
absink(&outer.nestedAB);
absink(outer.pointerAB);
}
| |
Make some change to check if new branch is created. | #pragma once
//MathLib.h
#ifndef _MATHLIB_
#define _MATHLIB_
#endif | #pragma once
//MathLib.h
#ifndef _MATHLIB_
#define _MATHLIB_
//Make some change to check if new branch is created.
#endif |
Add test that passes union to unknown function | #include <stdlib.h>
#include <stdio.h>
typedef struct list {
int val;
struct list *next;
} list_t;
typedef union either {
int value;
struct list node;
} either_t;
// void mutate_either(either_t e){
// list_t *next = e.node.next;
// next->val = 42;
// }
int main(){
list_t first;
list_t second;
first.next = &second;
first.val = 1;
second.next = NULL;
second.val = 2;
either_t e;
e.node = first;
// When passing a union to an unknown function, reachable memory should be invalidated
mutate_either(e);
assert(second.val == 2); //UNKNOWN!
return 0;
}
| |
Move to namespace include/use model | #ifndef ZEPHYR_CEXPORT_H
#define ZEPHYR_CEXPORT_H
#ifdef __cplusplus
#define Z_VAR(ns, n) n
#else
#define Z_VAR(ns, n) ns ## _ ## n
#endif
#ifdef __cplusplus
#define Z_NS_START(n) namespace n {
#define Z_NS_END }
#else
#define Z_NS_START(n)
#define Z_NS_END
#endif
#ifdef __cplusplus
#define Z_ENUM_CLASS(ns, n) enum class n
#else
#define Z_ENUM_CLASS(ns, n) enum Z_VAR(ns, n)
#endif
#ifdef __cplusplus
#define Z_ENUM(ns, n) enum n
#else
#define Z_ENUM(ns, n) enum Z_VAR(ns, n)
#endif
#ifdef __cplusplus
#define Z_STRUCT(ns, n) struct n
#else
#define Z_STRUCT(ns, n) struct Z_VAR(ns, n)
#endif
#endif
| #ifndef ZEPHYR_CEXPORT_H
#define ZEPHYR_CEXPORT_H
/* declare a namespaced name */
#ifdef __cplusplus
#define ZD(ns)
#else
#define ZD(ns) ns_
#endif
/* use a namespaced name */
#ifdef __cplusplus
#define ZU(ns) ns::
#else
#define ZU(ns) ns_
#endif
/* declare a namespace */
#ifdef __cplusplus
#define Z_NS_START(n) namespace n {
#define Z_NS_END }
#else
#define Z_NS_START(n)
#define Z_NS_END
#endif
/* enum class vs enum */
#ifdef __cplusplus
#define Z_ENUM_CLASS enum class
#else
#define Z_ENUM_CLASS enum
#endif
#endif
|
Change the function of find_tree_path | #ifndef __GRAPH_H__
#define __GRAPH_H__
#include "resources.h"
class graph {
private: //For data structures
struct vertex;
struct edge {
vertex *endpoint;
edge *opposite_edge, *next_edge;
double direction;
bool in_tree;
uint index;
conductor_info elect_info;
edge();
};
struct vertex {
edge *first_edge;
bool bfs_mark;
vertex();
};
vertex *vertex_memory_pool;
edge *edge_memory_pool;
uint vertex_number, edge_number;
private: //For internal functions
void add_edge(edge *, vertex *, vertex *, conductor_info, char, uint);
void find_tree_path(vertex *, vertex *, std::vector<edge *> &);
arma::cx_rowvec flow_conservation_equation(vertex *);
std::pair<arma::cx_rowvec, comp> circular_equation(vertex *, edge *);
void bfs(vertex *, arma::cx_mat &, arma::cx_vec &, uint &);
void find_all_circular(arma::cx_mat &, arma::cx_vec &, uint &);
public: //For user ports
graph(uint, const std::vector<conductor> &);
void get_current(std::vector<comp> &);
~graph();
};
#endif
| #ifndef __GRAPH_H__
#define __GRAPH_H__
#include "resources.h"
class graph {
private: //For data structures
struct vertex;
struct edge {
vertex *endpoint;
edge *opposite_edge, *next_edge;
double direction;
bool in_tree;
uint index;
conductor_info elect_info;
edge();
};
struct vertex {
edge *first_edge;
bool bfs_mark;
vertex();
};
vertex *vertex_memory_pool;
edge *edge_memory_pool;
uint vertex_number, edge_number;
private: //For internal functions
void add_edge(edge *, vertex *, vertex *, conductor_info, char, uint);
void find_tree_path(uint, vertex *, vertex *, std::vector<edge *> &);
arma::cx_rowvec flow_conservation_equation(vertex *);
std::pair<arma::cx_rowvec, comp> circular_equation(vertex *, edge *);
void bfs(vertex *, arma::cx_mat &, arma::cx_vec &, uint &);
void find_all_circular(arma::cx_mat &, arma::cx_vec &, uint &);
public: //For user ports
graph(uint, const std::vector<conductor> &);
void get_current(std::vector<comp> &);
~graph();
};
#endif
|
Test use of arm_neon.h with -fno-lax-vector-conversions. | // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -verify %s
// RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -verify %s
#include <arm_neon.h>
// Radar 8228022: Should not report incompatible vector types.
int32x2_t test(int32x2_t x) {
return vshr_n_s32(x, 31);
}
| // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -verify %s
// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -fno-lax-vector-conversions -verify %s
// RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -verify %s
#include <arm_neon.h>
// Radar 8228022: Should not report incompatible vector types.
int32x2_t test(int32x2_t x) {
return vshr_n_s32(x, 31);
}
|
Add valuetype as "standard" type | #ifndef JIVE_VSDG_TYPES_H
#define JIVE_VSDG_TYPES_H
#include <jive/vsdg/basetype.h>
#include <jive/vsdg/statetype.h>
#include <jive/vsdg/controltype.h>
#endif
| #ifndef JIVE_VSDG_TYPES_H
#define JIVE_VSDG_TYPES_H
#include <jive/vsdg/basetype.h>
#include <jive/vsdg/statetype.h>
#include <jive/vsdg/controltype.h>
#include <jive/vsdg/valuetype.h>
#endif
|
Add a simple server abstraction. | #ifndef IO_SOCKET_SIMPLE_SERVER_H
#define IO_SOCKET_SIMPLE_SERVER_H
#include <io/socket/socket.h>
/*
* XXX
* This is just one level up from using macros. Would be nice to use abstract
* base classes and something a bit tidier.
*/
template<typename A, typename C, typename L>
class SimpleServer {
LogHandle log_;
A arg_;
L *server_;
Action *accept_action_;
Action *close_action_;
Action *stop_action_;
public:
SimpleServer(LogHandle log, A arg, SocketAddressFamily family, const std::string& interface)
: log_(log),
arg_(arg),
server_(NULL),
accept_action_(NULL),
close_action_(NULL),
stop_action_(NULL)
{
server_ = L::listen(family, interface);
if (server_ == NULL)
HALT(log_) << "Unable to create listener.";
INFO(log_) << "Listening on: " << server_->getsockname();
EventCallback *cb = callback(this, &SimpleServer::accept_complete);
accept_action_ = server_->accept(cb);
Callback *scb = callback(this, &SimpleServer::stop);
stop_action_ = EventSystem::instance()->register_interest(EventInterestStop, scb);
}
~SimpleServer()
{
ASSERT(server_ == NULL);
ASSERT(accept_action_ == NULL);
ASSERT(close_action_ == NULL);
ASSERT(stop_action_ == NULL);
}
private:
void accept_complete(Event e)
{
accept_action_->cancel();
accept_action_ = NULL;
switch (e.type_) {
case Event::Done:
break;
case Event::Error:
ERROR(log_) << "Accept error: " << e;
break;
default:
ERROR(log_) << "Unexpected event: " << e;
break;
}
if (e.type_ == Event::Done) {
Socket *client = (Socket *)e.data_;
INFO(log_) << "Accepted client: " << client->getpeername();
new C(arg_, client);
}
EventCallback *cb = callback(this, &SimpleServer::accept_complete);
accept_action_ = server_->accept(cb);
}
void close_complete(void)
{
close_action_->cancel();
close_action_ = NULL;
ASSERT(server_ != NULL);
delete server_;
server_ = NULL;
delete this;
}
void stop(void)
{
stop_action_->cancel();
stop_action_ = NULL;
accept_action_->cancel();
accept_action_ = NULL;
ASSERT(close_action_ == NULL);
Callback *cb = callback(this, &SimpleServer::close_complete);
close_action_ = server_->close(cb);
}
};
#endif /* !IO_SOCKET_SIMPLE_SERVER_H */
| |
Remove unnecessary inclusion of dst.h | #ifndef _NET_EVENT_H
#define _NET_EVENT_H
/*
* Generic netevent notifiers
*
* Authors:
* Tom Tucker <tom@opengridcomputing.com>
* Steve Wise <swise@opengridcomputing.com>
*
* Changes:
*/
#ifdef __KERNEL__
#include <net/dst.h>
struct netevent_redirect {
struct dst_entry *old;
struct dst_entry *new;
};
enum netevent_notif_type {
NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */
NETEVENT_PMTU_UPDATE, /* arg is struct dst_entry ptr */
NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */
};
extern int register_netevent_notifier(struct notifier_block *nb);
extern int unregister_netevent_notifier(struct notifier_block *nb);
extern int call_netevent_notifiers(unsigned long val, void *v);
#endif
#endif
| #ifndef _NET_EVENT_H
#define _NET_EVENT_H
/*
* Generic netevent notifiers
*
* Authors:
* Tom Tucker <tom@opengridcomputing.com>
* Steve Wise <swise@opengridcomputing.com>
*
* Changes:
*/
#ifdef __KERNEL__
struct dst_entry;
struct netevent_redirect {
struct dst_entry *old;
struct dst_entry *new;
};
enum netevent_notif_type {
NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */
NETEVENT_PMTU_UPDATE, /* arg is struct dst_entry ptr */
NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */
};
extern int register_netevent_notifier(struct notifier_block *nb);
extern int unregister_netevent_notifier(struct notifier_block *nb);
extern int call_netevent_notifiers(unsigned long val, void *v);
#endif
#endif
|
Fix for older MSVC compilers without operator<< for long longs (not tested on MSVC6) |
#ifndef LOG_H
#define LOG_H
#include "types.h"
#include <fstream>
class Statement;
class Exp;
class LocationSet;
class RTL;
class Log
{
public:
Log() { }
virtual Log &operator<<(const char *str) = 0;
virtual Log &operator<<(Statement *s);
virtual Log &operator<<(Exp *e);
virtual Log &operator<<(RTL *r);
virtual Log &operator<<(int i);
virtual Log &operator<<(char c);
virtual Log &operator<<(double d);
virtual Log &operator<<(ADDRESS a);
virtual Log &operator<<(LocationSet *l);
Log &operator<<(std::string& s) {return operator<<(s.c_str());}
virtual ~Log() {};
virtual void tail();
};
class FileLogger : public Log {
protected:
std::ofstream out;
public:
FileLogger(); // Implemented in boomerang.cpp
void tail();
virtual Log &operator<<(const char *str) {
out << str << std::flush;
return *this;
}
virtual ~FileLogger() {};
};
#endif
|
#ifndef LOG_H
#define LOG_H
#include "types.h"
#include <fstream>
class Statement;
class Exp;
class LocationSet;
class RTL;
class Log
{
public:
Log() { }
virtual Log &operator<<(const char *str) = 0;
virtual Log &operator<<(Statement *s);
virtual Log &operator<<(Exp *e);
virtual Log &operator<<(RTL *r);
virtual Log &operator<<(int i);
virtual Log &operator<<(char c);
virtual Log &operator<<(double d);
virtual Log &operator<<(ADDRESS a);
virtual Log &operator<<(LocationSet *l);
Log &operator<<(std::string& s) {return operator<<(s.c_str());}
virtual ~Log() {};
virtual void tail();
};
class FileLogger : public Log {
protected:
std::ofstream out;
public:
FileLogger(); // Implemented in boomerang.cpp
void tail();
virtual Log &operator<<(const char *str) {
out << str << std::flush;
return *this;
}
virtual ~FileLogger() {};
};
// For older MSVC compilers
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
static std::ostream& operator<<(std::ostream& s, QWord val)
{
char szTmp[42]; // overkill, but who counts
sprintf(szTmp, "%I64u", val);
s << szTmp;
return s;
}
#endif
#endif
|
Remove private headers from global public header | #ifndef StateMachine_StateMachine_h
#define StateMachine_StateMachine_h
#import "LSStateMachine.h"
#import "LSEvent.h"
#import "LSTransition.h"
#import "LSStateMachineMacros.h"
#endif
| #ifndef StateMachine_StateMachine_h
#define StateMachine_StateMachine_h
#import "LSStateMachine.h"
#import "LSStateMachineMacros.h"
#endif
|
Make code not have a -Warray-parameter warning. | #ifndef SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
#define SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
#include <sys/types.h>
#include <cstdint>
#include <string>
#include <vector>
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/syscall.h"
namespace sandbox2 {
namespace syscalls {
constexpr int kMaxArgs = 6;
} // namespace syscalls
class SyscallTable {
public:
struct Entry;
// Returns the syscall table for the architecture.
static SyscallTable get(sapi::cpu::Architecture arch);
int size() { return data_.size(); }
absl::string_view GetName(int syscall) const;
std::vector<std::string> GetArgumentsDescription(
int syscall, const uint64_t values[syscalls::kMaxArgs], pid_t pid) const;
private:
constexpr SyscallTable() = default;
explicit constexpr SyscallTable(absl::Span<const Entry> data) : data_(data) {}
const absl::Span<const Entry> data_;
};
} // namespace sandbox2
#endif // SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
| #ifndef SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
#define SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
#include <sys/types.h>
#include <cstdint>
#include <string>
#include <vector>
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/syscall.h"
namespace sandbox2 {
namespace syscalls {
constexpr int kMaxArgs = 6;
} // namespace syscalls
class SyscallTable {
public:
struct Entry;
// Returns the syscall table for the architecture.
static SyscallTable get(sapi::cpu::Architecture arch);
int size() { return data_.size(); }
absl::string_view GetName(int syscall) const;
std::vector<std::string> GetArgumentsDescription(int syscall,
const uint64_t values[],
pid_t pid) const;
private:
constexpr SyscallTable() = default;
explicit constexpr SyscallTable(absl::Span<const Entry> data) : data_(data) {}
const absl::Span<const Entry> data_;
};
} // namespace sandbox2
#endif // SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
|
Add Notifier base class, complements Observer | #ifndef TE_OBSERVER_H
#define TE_OBSERVER_H
namespace te
{
template <class EventType>
class Observer
{
public:
virtual ~Observer() {}
virtual void onNotify(const EventType& evt) = 0;
};
}
#endif
| #ifndef TE_OBSERVER_H
#define TE_OBSERVER_H
#include <vector>
#include <memory>
#include <cassert>
namespace te
{
template <class EventType>
class Observer
{
public:
virtual ~Observer() {}
virtual void onNotify(const EventType& evt) = 0;
};
template <class EventType>
class Notifier
{
public:
virtual ~Notifier() {}
void addObserver(std::shared_ptr<Observer<EventType>> newObserver)
{
assert(newObserver);
if (std::find(mObservers.begin(), mObservers.end(), newObserver) == mObservers.end()) {
mObservers.push_back(newObserver);
}
}
protected:
void notify(const EventType& evt)
{
std::for_each(std::begin(mObservers), std::end(mObservers), [&evt](std::shared_ptr<Observer<EventType>>& pObserver) {
pObserver->onNotify(evt);
});
}
private:
std::vector<std::shared_ptr<Observer<EventType>>> mObservers;
};
}
#endif
|
Update slide event method definition | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <Windows.h>
#include <CommCtrl.h>
#include "Control.h"
class Slider : public Control {
public:
Slider(int id, DialogBase &parent) :
Control(id, parent, false) {
}
void Buddy(Control *buddy, bool bottomOrRight = true);
int Position();
void Position(int position);
/// <summary>Sets the range (min, max) for the slider control.</summary>
/// <param name="lo">Lower bound for the slider.</param>
/// <param name="hi">Upper bound for the slider.</param>
void Range(int lo, int hi);
virtual BOOL CALLBACK Notification(NMHDR *nHdr);
private:
HWND _buddyWnd;
public:
/* Event Handlers */
std::function<void(NMTRBTHUMBPOSCHANGING *pc)> OnSlide;
}; | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <Windows.h>
#include <CommCtrl.h>
#include "Control.h"
class Slider : public Control {
public:
Slider(int id, DialogBase &parent) :
Control(id, parent, false) {
}
void Buddy(Control *buddy, bool bottomOrRight = true);
int Position();
void Position(int position);
/// <summary>Sets the range (min, max) for the slider control.</summary>
/// <param name="lo">Lower bound for the slider.</param>
/// <param name="hi">Upper bound for the slider.</param>
void Range(int lo, int hi);
virtual BOOL CALLBACK Notification(NMHDR *nHdr);
private:
HWND _buddyWnd;
public:
/* Event Handlers */
std::function<bool()> OnSlide;
}; |
Add WBS support on Bluedroid (1/6) | /*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTA_DISABLE_DELAY 100 /* in milliseconds */
#endif
| /*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTA_DISABLE_DELAY 100 /* in milliseconds */
#define BTM_WBS_INCLUDED TRUE
#define BTIF_HF_WBS_PREFERRED TRUE
#endif
|
Set a default value for boolean options (false). | #ifndef MLPACK_IO_OPTION_IMPL_H
#define MLPACK_IO_OPTION_IMPL_H
#include "io.h"
namespace mlpack {
/*
* @brief Registers a parameter with IO.
* This allows the registration of parameters at program start.
*/
template<typename N>
Option<N>::Option(bool ignoreTemplate,
N defaultValue,
const char* identifier,
const char* description,
const char* parent,
bool required) {
if (ignoreTemplate)
IO::Add(identifier, description, parent, required);
else {
IO::Add<N>(identifier, description, parent, required);
//Create the full pathname.
std::string pathname = IO::SanitizeString(parent) + std::string(identifier);
IO::GetParam<N>(pathname.c_str()) = defaultValue;
}
}
/*
* @brief Registers a flag parameter with IO.
*/
template<typename N>
Option<N>::Option(const char* identifier,
const char* description,
const char* parent) {
IO::AddFlag(identifier, description, parent);
}
}; // namespace mlpack
#endif
| #ifndef MLPACK_IO_OPTION_IMPL_H
#define MLPACK_IO_OPTION_IMPL_H
#include "io.h"
namespace mlpack {
/*
* @brief Registers a parameter with IO.
* This allows the registration of parameters at program start.
*/
template<typename N>
Option<N>::Option(bool ignoreTemplate,
N defaultValue,
const char* identifier,
const char* description,
const char* parent,
bool required) {
if (ignoreTemplate)
IO::Add(identifier, description, parent, required);
else {
IO::Add<N>(identifier, description, parent, required);
// Create the full pathname to set the default value.
std::string pathname = IO::SanitizeString(parent) + std::string(identifier);
IO::GetParam<N>(pathname.c_str()) = defaultValue;
}
}
/*
* @brief Registers a flag parameter with IO.
*/
template<typename N>
Option<N>::Option(const char* identifier,
const char* description,
const char* parent) {
IO::AddFlag(identifier, description, parent);
// Set the default value (false).
std::string pathname = IO::SanitizeString(parent) + std::string(identifier);
IO::GetParam<bool>(pathname.c_str()) = false;
}
}; // namespace mlpack
#endif
|
Add TMCVerbose to the list of mc classes | // @(#)root/mc:$Name: $:$Id: LinkDef.h,v 1.2 2002/04/26 08:46:10 brun Exp $
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ global gMC;
#pragma link C++ enum PDG_t;
#pragma link C++ enum TMCProcess;
#pragma link C++ class TVirtualMC+;
#pragma link C++ class TVirtualMCApplication+;
#pragma link C++ class TVirtualMCStack+;
#pragma link C++ class TVirtualMCDecayer+;
#endif
| // @(#)root/mc:$Name: $:$Id: LinkDef.h,v 1.2 2002/04/26 09:25:02 brun Exp $
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ global gMC;
#pragma link C++ enum PDG_t;
#pragma link C++ enum TMCProcess;
#pragma link C++ class TVirtualMC+;
#pragma link C++ class TVirtualMCApplication+;
#pragma link C++ class TVirtualMCStack+;
#pragma link C++ class TVirtualMCDecayer+;
#pragma link C++ class TMCVerbose+;
#endif
|
Remove friend function in FFTServer. | #ifndef FFTW_HAO_H
#define FFTW_HAO_H
#include "fftw_define.h"
class FFTServer
{
int dimen;
int* n;
int L;
std::complex<double>* inforw;
std::complex<double>* outforw;
std::complex<double>* inback;
std::complex<double>* outback;
fftw_plan planforw;
fftw_plan planback;
public:
FFTServer();
FFTServer(int Dc, const int* Nc, char format); //'C' Column-major: fortran style; 'R' Row-major: c style;
FFTServer(const FFTServer& x);
~FFTServer();
FFTServer& operator = (const FFTServer& x);
std::complex<double>* fourier_forw(const std::complex<double>* inarray);
std::complex<double>* fourier_back(const std::complex<double>* inarray);
friend void FFTServer_void_construction_test();
friend void FFTServer_param_construction_test();
friend void FFTServer_equal_construction_test();
friend void FFTServer_equal_test();
};
#endif
| #ifndef FFTW_HAO_H
#define FFTW_HAO_H
#include "fftw_define.h"
class FFTServer
{
public:
int dimen;
int* n;
int L;
std::complex<double>* inforw;
std::complex<double>* outforw;
std::complex<double>* inback;
std::complex<double>* outback;
fftw_plan planforw;
fftw_plan planback;
FFTServer();
FFTServer(int Dc, const int* Nc, char format); //'C' Column-major: fortran style; 'R' Row-major: c style;
FFTServer(const FFTServer& x);
~FFTServer();
FFTServer& operator = (const FFTServer& x);
std::complex<double>* fourier_forw(const std::complex<double>* inarray);
std::complex<double>* fourier_back(const std::complex<double>* inarray);
};
#endif
|
Remove some of ACPICA's x32 support | #include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define ACPI_MACHINE_WIDTH __INTPTR_WIDTH__
#define ACPI_SINGLE_THREADED
#define ACPI_USE_LOCAL_CACHE
#define ACPI_USE_NATIVE_DIVIDE
#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
#undef ACPI_GET_FUNCTION_NAME
#ifdef ACPI_FULL_DEBUG
//#define ACPI_DBG_TRACK_ALLOCATIONS
#define ACPI_GET_FUNCTION_NAME __FUNCTION__
#else
#define ACPI_GET_FUNCTION_NAME ""
#endif
static const uintptr_t ACPI_PHYS_BASE = 0x1000000;
#define AcpiOsPrintf printf
#define AcpiOsVprintf vprintf
struct acpi_table_facs;
uint32_t AcpiOsReleaseGlobalLock(struct acpi_table_facs* facs);
uint32_t AcpiOsAcquireGlobalLock(struct acpi_table_facs* facs);
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acquired) Acquired = AcpiOsAcquireGlobalLock(GLptr)
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pending) Pending = AcpiOsReleaseGlobalLock(GLptr)
#define COMPILER_DEPENDENT_UINT64 uint64_t
#define COMPILER_DEPENDENT_UINT32 uint32_t
| #include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define ACPI_MACHINE_WIDTH __INTPTR_WIDTH__
#define ACPI_SINGLE_THREADED
#define ACPI_USE_LOCAL_CACHE
#define ACPI_USE_NATIVE_DIVIDE
#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
#undef ACPI_GET_FUNCTION_NAME
#ifdef ACPI_FULL_DEBUG
//#define ACPI_DBG_TRACK_ALLOCATIONS
#define ACPI_GET_FUNCTION_NAME __FUNCTION__
#else
#define ACPI_GET_FUNCTION_NAME ""
#endif
static const uint64_t ACPI_PHYS_BASE = 0x100000000;
#define AcpiOsPrintf printf
#define AcpiOsVprintf vprintf
struct acpi_table_facs;
uint32_t AcpiOsReleaseGlobalLock(struct acpi_table_facs* facs);
uint32_t AcpiOsAcquireGlobalLock(struct acpi_table_facs* facs);
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acquired) Acquired = AcpiOsAcquireGlobalLock(GLptr)
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pending) Pending = AcpiOsReleaseGlobalLock(GLptr)
#define COMPILER_DEPENDENT_UINT64 uint64_t
#define COMPILER_DEPENDENT_UINT32 uint32_t
|
Add Visual Studio 2013 fix from omnus | #ifndef _client_h_
#define _client_h_
#define DEFAULT_PORT 4080
void client_enable();
void client_disable();
int get_client_enabled();
void client_connect(char *hostname, int port);
void client_start();
void client_stop();
void client_send(char *data);
char *client_recv();
void client_version(int version);
void client_login(const char *username, const char *identity_token);
void client_position(float x, float y, float z, float rx, float ry);
void client_chunk(int p, int q, int key);
void client_block(int x, int y, int z, int w);
void client_light(int x, int y, int z, int w);
void client_sign(int x, int y, int z, int face, const char *text);
void client_talk(const char *text);
#endif
| #ifndef _client_h_
#define _client_h_
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
#define DEFAULT_PORT 4080
void client_enable();
void client_disable();
int get_client_enabled();
void client_connect(char *hostname, int port);
void client_start();
void client_stop();
void client_send(char *data);
char *client_recv();
void client_version(int version);
void client_login(const char *username, const char *identity_token);
void client_position(float x, float y, float z, float rx, float ry);
void client_chunk(int p, int q, int key);
void client_block(int x, int y, int z, int w);
void client_light(int x, int y, int z, int w);
void client_sign(int x, int y, int z, int face, const char *text);
void client_talk(const char *text);
#endif
|
Update prototype of maskInterrupt to match implementations. | /*
* Copyright 2014, General Dynamics C4 Systems
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
*/
#ifndef __MACHINE_HARDWARE_H
#define __MACHINE_HARDWARE_H
#include <types.h>
#include <arch/machine/hardware.h>
#include <plat/machine/hardware.h>
#include <plat/machine.h>
void handleReservedIRQ(irq_t irq);
void handleSpuriousIRQ(void);
/** MODIFIES: [*] */
void ackInterrupt(irq_t irq);
/** MODIFIES: [*] */
irq_t getActiveIRQ(void);
/** MODIFIES: [*] */
bool_t isIRQPending(void);
/** MODIFIES: [*] */
void maskInterrupt(bool_t enable, irq_t irq);
#endif
| /*
* Copyright 2014, General Dynamics C4 Systems
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
*/
#ifndef __MACHINE_HARDWARE_H
#define __MACHINE_HARDWARE_H
#include <types.h>
#include <arch/machine/hardware.h>
#include <plat/machine/hardware.h>
#include <plat/machine.h>
void handleReservedIRQ(irq_t irq);
void handleSpuriousIRQ(void);
/** MODIFIES: [*] */
void ackInterrupt(irq_t irq);
/** MODIFIES: [*] */
irq_t getActiveIRQ(void);
/** MODIFIES: [*] */
bool_t isIRQPending(void);
/** MODIFIES: [*] */
void maskInterrupt(bool_t disable, irq_t irq);
#endif
|
Fix bug in parser tests | #include "parser.h"
#include "ast.h"
#include "tests.h"
void test_parse_number();
int main() {
test_parse_number();
return 0;
}
struct token *make_token(enum token_type tk_type, char* str, double dbl,
int number) {
struct token *tk = malloc(sizeof(struct token));
tk->type = tk_type;
if (tk_type == tok_dbl) {
tk->value.dbl = dbl;
} else if (tk_type == tok_number) {
tk->value.num = number;
} else {
tk->value.string = str;
}
return tk;
}
void test_parse_number() {
struct token_list *tkl = make_token_list();
tkl.append(make_token(tok_number, NULL, 0.0, 42);
struct ast_node *result = parse_number(tkl);
EXPECT_EQ(result->val, tkl->head);
EXPECT_EQ(result->num_children, 0);
destroy_token_list(tkl);
}
| #include "parser.h"
#include "ast.h"
#include "tests.h"
void test_parse_number();
int main() {
test_parse_number();
return 0;
}
struct token *make_token(enum token_type tk_type, char* str, double dbl,
int number) {
struct token *tk = malloc(sizeof(struct token));
tk->type = tk_type;
if (tk_type == tok_dbl) {
tk->value.dbl = dbl;
} else if (tk_type == tok_number) {
tk->value.num = number;
} else {
tk->value.string = str;
}
return tk;
}
void test_parse_number() {
struct token_list *tkl = make_token_list();
struct token *tk = make_token(tok_number, NULL, 0.0, 42);
append_token_list(tkl, tk);
struct ast_node *result = parse_number(tkl);
EXPECT_EQ(result->val, tk);
EXPECT_EQ(result->num_children, 0);
destroy_token_list(tkl);
}
|
Fix release mode compile error. | // Copyright (c) 2012 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
#ifndef CLIENT_ENCODER_WIN_DSHOW_UTIL_H_
#define CLIENT_ENCODER_WIN_DSHOW_UTIL_H_
#include <ios>
#include "webmdshow/common/hrtext.hpp"
#include "webmdshow/common/odbgstream.hpp"
// Extracts error from the HRESULT, and outputs its hex and decimal values.
#define HRLOG(X) \
" {" << #X << "=" << X << "/" << std::hex << X << std::dec << " (" << \
hrtext(X) << ")}"
#endif // CLIENT_ENCODER_WIN_DSHOW_UTIL_H_
| // Copyright (c) 2012 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
#ifndef CLIENT_ENCODER_WIN_DSHOW_UTIL_H_
#define CLIENT_ENCODER_WIN_DSHOW_UTIL_H_
#include <ios>
#include "webmdshow/common/odbgstream.hpp" // NOLINT
// Above include NOLINT'd because it *must always* come before hrtext.
#include "webmdshow/common/hrtext.hpp"
// Extracts error from the HRESULT, and outputs its hex and decimal values.
#define HRLOG(X) \
" {" << #X << "=" << X << "/" << std::hex << X << std::dec << " (" << \
hrtext(X) << ")}"
#endif // CLIENT_ENCODER_WIN_DSHOW_UTIL_H_
|
Add list LinkDef file for JPetTreeHeader | #ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;
#pragma link C++ struct JPetTreeHeader::ProcessingStageInfo+;
#pragma link C++ class JPetTreeHeader;
#endif
| |
Add C implementation for problem 4. | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void reverse_string(char *str){
// skip null
if (str == 0){ return; }
// skip empty string
if (*str == 0){ return; }
// get range
char *start = str;
char *end = start + strlen(str) - 1; // -1 for \0
char temp;
// reverse
while (end > start){
temp = *start;
*start = *end;
*end = temp;
++start;
--end;
}
}
int is_palindrome_number(int n){
char n_str[10], r_str[10];
snprintf(n_str, sizeof(n_str), "%d", n); // convert int to str
snprintf(r_str, sizeof(r_str), "%d", n);
reverse_string(0);
reverse_string(r_str);
if(strcmp(n_str, r_str) == 0){
return 0;
}else{
return -1;
}
}
int main(int argc, char *argv[]){
int x, y, v, largest_number;
for(x = 100; x < 999; x++){
for(y = 100; y < 999; y++){
v = x * y;
if(v > largest_number){
if(is_palindrome_number(v) == 0){
largest_number = v;
}
}
}
}
printf("%d\n", largest_number);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.