Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Allow logging to be configured at compilation time. | //
// lelib.h
// lelib
//
// Created by Petr on 27.10.13.
// Copyright (c) 2013 JLizard. All rights reserved.
//
#define LE_DEBUG_LOGS 1
#if LE_DEBUG_LOGS
#define LE_DEBUG(...) NSLog(__VA_ARGS__)
#else
#define LE_DEBUG(...)
#endif
#import "LELog.h"
#import "lecore.h"
| //
// lelib.h
// lelib
//
// Created by Petr on 27.10.13.
// Copyright (c) 2013 JLizard. All rights reserved.
//
#ifndef LE_DEBUG_LOGS
#ifdef DEBUG
#define LE_DEBUG_LOGS 1
#else
#define LE_DEBUG_LOGS 0
#endif
#endif
#if LE_DEBUG_LOGS
#define LE_DEBUG(...) NSLog(__VA_ARGS__)
#else
#define LE_DEBUG(...)
#endif
#import "LELog.h"
#import "lecore.h"
|
Include file for GCC compiler. | /* VString library header file for GCC */
#include <exec/types.h>
APTR AllocVecPooled(__reg("a0") APTR pool, __reg("d0") ULONG size);
APTR CloneMem(__reg("a0") const APTR src, __reg("d0") ULONG size);
APTR CloneMemPooled(__reg("a0") APTR pool, __reg("a1") const APTR src, __reg("d0") ULONG size);
void FreeVecPooled(__reg("a0") APTR pool, __reg("a1") APTR block);
UBYTE* StrCopy(__reg("a0") const UBYTE *s, __reg("a1") UBYTE *d);
UWORD* StrCopyW(__reg("a0") const UWORD *s, __reg("a1") UWORD *d);
ULONG* StrCopyL(__reg("a0") const ULONG *s, __reg("a1") ULONG *d);
ULONG Utf8Size(__reg("d0") ULONG cp);
| |
Remove prototypes for removed functions. | #ifndef INTERRUPTS_H
#define INTERRUPTS_H
#include "types.h"
namespace interrupts {
// Enable interrupts on the CPU.
inline void enable() {
asm volatile("sti");
}
// Enable interrupts on the CPU.
inline void disable() {
asm volatile("cli");
}
struct Registers {
u32 gs, fs, es, ds; // Segment registers.
u32 edi, esi, ebp, esp, ebx, edx, ecx, eax; // From 'pusha' instruction.
u32 interruptNum;
u32 eip, cs, eflags, useresp, ss; // Pushed by CPU on interrupt.
};
using IrqHandlerFn = void (*)(Registers*);
void setIrqHandler(u32 irqNum, IrqHandlerFn handlerFn);
void init();
void initIsrs();
void initIrqs();
void remapPic();
extern "C" void interruptHandler(Registers* regs);
} // namespace interrupts
#endif
| #ifndef INTERRUPTS_H
#define INTERRUPTS_H
#include "types.h"
namespace interrupts {
// Enable interrupts on the CPU.
inline void enable() {
asm volatile("sti");
}
// Enable interrupts on the CPU.
inline void disable() {
asm volatile("cli");
}
struct Registers {
u32 gs, fs, es, ds; // Segment registers.
u32 edi, esi, ebp, esp, ebx, edx, ecx, eax; // From 'pusha' instruction.
u32 interruptNum;
u32 eip, cs, eflags, useresp, ss; // Pushed by CPU on interrupt.
};
using IrqHandlerFn = void (*)(Registers*);
void setIrqHandler(u32 irqNum, IrqHandlerFn handlerFn);
void init();
void remapPic();
extern "C" void interruptHandler(Registers* regs);
} // namespace interrupts
#endif
|
Write rough interface for a map class template | template <class Key, class T>
struct map {
using size_type = std::size_t;
map(size_type bucket_count = /* some default */);
using value_type = std::pair<const Key, T>;
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
// Args are arguments to constructing a value_type
template <class... Args>
iterator emplace(Args &&...args);
iterator find(const Key &);
const iterator find(const Key &) const;
iterator erase(const_iterator);
size_type size() const;
size_type bucket_count() const;
float load_factor() const;
float max_load_factor() const;
void max_load_factor(float);
};
| |
Use a non-blocking select to determine which reads and writes would block | /*
* Test case for appio
* Author: Tushar Mohan
* tusharmohan@gmail.com
*
* Description: This test case reads from standard linux /etc/group
* and writes the output to stdout.
* Statistics are printed at the end of the run.,
*/
#include <papi.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "papi_test.h"
#define NUM_EVENTS 12
int main(int argc, char** argv) {
int Events[NUM_EVENTS];
const char* names[NUM_EVENTS] = {"OPEN_CALLS", "OPEN_FDS", "READ_CALLS", "READ_BYTES", "READ_USEC", "READ_ERR", "READ_INTERRUPTED", "READ_WOULD_BLOCK", "WRITE_CALLS","WRITE_BYTES","WRITE_USEC", "WRITE_WOULD_BLOCK"};
long long values[NUM_EVENTS];
int version = PAPI_library_init (PAPI_VER_CURRENT);
if (version != PAPI_VER_CURRENT) {
fprintf(stderr, "PAPI_library_init version mismatch\n");
exit(1);
}
if (!TESTS_QUIET) fprintf(stderr, "This program will read from stdin and echo it to stdout\n");
int retval;
int e;
for (e=0; e<NUM_EVENTS; e++) {
retval = PAPI_event_name_to_code((char*)names[e], &Events[e]);
if (retval != PAPI_OK) {
fprintf(stderr, "Error getting code for %s\n", names[e]);
exit(2);
}
}
/* Start counting events */
if (PAPI_start_counters(Events, NUM_EVENTS) != PAPI_OK) {
fprintf(stderr, "Error in PAPI_start_counters\n");
exit(1);
}
int bytes = 0;
char buf[1024];
//if (PAPI_read_counters(values, NUM_EVENTS) != PAPI_OK)
// handle_error(1);
//printf("After reading the counters: %lld\n",values[0]);
while ((bytes = read(0, buf, 1024)) > 0) {
write(1, buf, bytes);
}
/* Stop counting events */
if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) {
fprintf(stderr, "Error in PAPI_stop_counters\n");
}
if (!TESTS_QUIET) {
printf("----\n");
for (e=0; e<NUM_EVENTS; e++)
printf("%s: %lld\n", names[e], values[e]);
}
test_pass( __FILE__, NULL, 0 );
return 0;
}
| |
Support for dynamic memory information added for Alpha | #include "papi.h"
int get_memory_info( PAPI_mem_info_t * mem_info ){
int retval = 0;
return PAPI_OK;
}
long _papi_hwd_get_dmem_info(int option){
}
| #include "papi.h"
#include <sys/procfs.h>
#include <stdio.h>
#include <fcntl.h>
int get_memory_info( PAPI_mem_info_t * mem_info ){
int retval = 0;
return PAPI_OK;
}
long _papi_hwd_get_dmem_info(int option){
pid_t pid = getpid();
prpsinfo_t info;
char pfile[256];
int fd;
sprintf(pfile, "/proc/%05d", pid);
if((fd=open(pfile,O_RDONLY)) <0 ) {
DBG((stderr,"PAPI_get_dmem_info can't open /proc/%d\n",pid));
return(PAPI_ESYS);
}
if(ioctl(fd, PIOCPSINFO, &info)<0){
return(PAPI_ESYS);
}
close(fd);
switch(option){
case PAPI_GET_RESSIZE:
return(info.pr_rssize);
case PAPI_GET_SIZE:
return(info.pr_size);
default:
return(PAPI_EINVAL);
}
}
|
Debug level 1 now only shows error messages (and no backgrounding in gmetad). | /**
* @file debug_msg.c Debug Message function
*/
/* $Id$ */
#include "gangliaconf.h"
int debug_level = 0;
/**
* @fn void debug_msg(const char *format, ...)
* Prints the message to STDERR if DEBUG is #defined
* @param format The format of the msg (see printf manpage)
* @param ... Optional arguments
*/
void
debug_msg(const char *format, ...)
{
if (debug_level && format)
{
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
fprintf(stderr,"\n");
va_end(ap);
}
return;
}
| /**
* @file debug_msg.c Debug Message function
*/
/* $Id$ */
#include "gangliaconf.h"
int debug_level = 0;
/**
* @fn void debug_msg(const char *format, ...)
* Prints the message to STDERR if DEBUG is #defined
* @param format The format of the msg (see printf manpage)
* @param ... Optional arguments
*/
void
debug_msg(const char *format, ...)
{
if (debug_level > 1 && format)
{
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
fprintf(stderr,"\n");
va_end(ap);
}
return;
}
|
Make sure CONFIG is static and only imported once. | #include "can/canutil.h"
namespace openxc {
namespace config {
typedef struct {
int messageSetIndex;
} Configuration;
Configuration CONFIG;
} // namespace config
} // namespace openxc
| #ifndef _CONFIG_H_
#define _CONFIG_H_
#include "can/canutil.h"
namespace openxc {
namespace config {
typedef struct {
int messageSetIndex;
} Configuration;
static Configuration CONFIG;
} // namespace config
} // namespace openxc
#endif // _CONFIG_H_
|
Make the testcase even more insane | struct sometimes {
short offset; short bit;
short live_length; short calls_crossed;
} Y;
int main() {
struct sometimes { int X, Y; } S;
S.X = 1;
return Y.offset;
}
| #include <stdio.h>
struct sometimes {
short offset; short bit;
short live_length; short calls_crossed;
} Y;
int main() {
int X;
{
struct sometimes { int X, Y; } S;
S.X = 1;
X = S.X;
}
{
struct sometimes { char X; } S;
S.X = -1;
X += S.X;
}
X += Y.offset;
printf("Result is %d\n", X);
return X;
}
|
Delete junk that snuck into r166498. | // RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify %s
int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
int vbad2;
int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}}
struct {
int mgood1;
} vbad3; // expected-warning{{no previous extern declaration for non-static variable 'vbad3'}}
int vbad4;
int vbad4 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad4'}}
extern int vbad4;
extern int vgood1;
int vgood1;
int vgood1 = 10;
// RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify %s
int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
int vbad2;
int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}}
struct {
int mgood1;
} vbad3; // expected-warning{{no previous extern declaration for non-static variable 'vbad3'}}
int vbad4;
int vbad4 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad4'}}
extern int vbad4;
extern int vgood1;
int vgood1;
int vgood1 = 10;
| // RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify %s
int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
int vbad2;
int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}}
struct {
int mgood1;
} vbad3; // expected-warning{{no previous extern declaration for non-static variable 'vbad3'}}
int vbad4;
int vbad4 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad4'}}
extern int vbad4;
extern int vgood1;
int vgood1;
int vgood1 = 10;
|
Change time type from double to time_t | #ifndef _BINCOOKIE_H
#define _BINCOOKIE_H
#if defined(_MSC_VER)
#define uint32_t DWORD
#else
#include <stdint.h>
#endif
#define binarycookies_is_secure(cookie_ptr) (cookie_ptr->flags & secure)
#define binarycookies_domain_access_full(cookie_ptr) (cookie_ptr->domain[0] == '.')
typedef enum {
secure = 1,
http_only = 1 << 2,
} binarycookies_flag;
typedef struct {
uint32_t size;
unsigned char unk1[4];
binarycookies_flag flags;
unsigned char unk2[4];
double creation_date;
double expiration_date;
char *domain;
char *name;
char *path;
char *value;
} binarycookies_cookie_t;
typedef struct {
unsigned char unk1[4]; // always 0x0 0x0 0x1 0x0
uint32_t number_of_cookies;
binarycookies_cookie_t **cookies;
} binarycookies_page_t;
typedef struct {
unsigned char magic[4]; // "cook"
uint32_t num_pages;
uint32_t *page_sizes;
char **raw_pages;
binarycookies_page_t **pages;
} binarycookies_t;
binarycookies_t *binarycookies_init(const char *file_path);
void binarycookies_free(binarycookies_t *cfile);
#endif // _BINCOOKIE_H
| #ifndef _BINCOOKIE_H
#define _BINCOOKIE_H
#if defined(_MSC_VER)
#define uint32_t DWORD
#else
#include <stdint.h>
#endif
#include <time.h>
#define binarycookies_is_secure(cookie_ptr) (cookie_ptr->flags & secure)
#define binarycookies_domain_access_full(cookie_ptr) (cookie_ptr->domain[0] == '.')
typedef enum {
secure = 1,
http_only = 1 << 2,
} binarycookies_flag;
typedef struct {
uint32_t size;
unsigned char unk1[4];
binarycookies_flag flags;
unsigned char unk2[4];
time_t creation_time;
time_t expiration_time;
char *domain;
char *name;
char *path;
char *value;
} binarycookies_cookie_t;
typedef struct {
unsigned char unk1[4]; // always 0x0 0x0 0x1 0x0
uint32_t number_of_cookies;
binarycookies_cookie_t **cookies;
} binarycookies_page_t;
typedef struct {
unsigned char magic[4]; // "cook"
uint32_t num_pages;
uint32_t *page_sizes;
char **raw_pages;
binarycookies_page_t **pages;
} binarycookies_t;
binarycookies_t *binarycookies_init(const char *file_path);
void binarycookies_free(binarycookies_t *cfile);
#endif // _BINCOOKIE_H
|
Add hello world file which can be used to establish that the I/O routines are working | #include <stdio.h>
// This test program is provided to enable a quick test of PDCLib's console I/O
// functions
int main(int argc, char** argv)
{
printf("Hello world\n");
} | |
Add source for posix timing | #define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#ifdef _POSIX_TIMERS
static clockid_t clock_type;
#endif
/** Checks whether we have support for POSIX timers on this system.
Sets the clock type and queries the resolution (in seconds). Returns 1 if
POSIX timers are supported and 0 otherwise */
int posix_clock_init(double *res){
int ierr;
struct timespec ts;
#ifdef _POSIX_TIMERS
#ifdef _POSIX_MONOTONIC_CLOCK
clock_type = CLOCK_MONOTONIC;
#else
clock_type = CLOCK_REALTIME;
#endif
ierr = clock_getres(clock_type, &ts);
*res = (double)(ts.tv_sec) + 1.0e-9*ts.tv_nsec;
return 1;
#else
/* This system doesn't have support for POSIX timers */
fprintf(stderr, "TIMING: ERROR: POSIX TIMERS not available.\n");
*res = 0.0;
return 0;
#endif
}
/** Returns the current time (in seconds) as measured by the clock selected
in posix_clock_init() */
double posix_clock(void){
int ierr;
struct timespec ts;
double tnow;
#ifdef _POSIX_TIMERS
ierr = clock_gettime(clock_type, &ts);
tnow = (double)(ts.tv_sec) + 1.0e-9*ts.tv_nsec;
#else
tnow = 0.0;
#endif
return tnow;
}
| |
Disable LE's own debug log spam | //
// lelib.h
// lelib
//
// Created by Petr on 27.10.13.
// Copyright (c) 2013,2014 Logentries. All rights reserved.
//
#ifndef LE_DEBUG_LOGS
#ifdef DEBUG
#define LE_DEBUG_LOGS 1
#else
#define LE_DEBUG_LOGS 0
#endif
#endif
#if LE_DEBUG_LOGS
#define LE_DEBUG(...) NSLog(__VA_ARGS__)
#else
#define LE_DEBUG(...)
#endif
#import "LELog.h"
#import "lecore.h"
| //
// lelib.h
// lelib
//
// Created by Petr on 27.10.13.
// Copyright (c) 2013,2014 Logentries. All rights reserved.
//
#ifndef LE_DEBUG_LOGS
// #ifdef DEBUG
// #define LE_DEBUG_LOGS 1
// #else
#define LE_DEBUG_LOGS 0
// #endif
#endif
#if LE_DEBUG_LOGS
#define LE_DEBUG(...) NSLog(__VA_ARGS__)
#else
#define LE_DEBUG(...)
#endif
#import "LELog.h"
#import "lecore.h"
|
Include stddef.h always to make NULL expand correctly in Solaris. | #ifndef __LIB_H
#define __LIB_H
/* default lib includes */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* default system includes - keep these at minimum.. */
#include <string.h> /* strcmp() etc. */
#ifdef HAVE_STRINGS_H
# include <strings.h> /* strcasecmp() etc. */
#endif
#include <stdarg.h> /* va_list is used everywhere */
#include <limits.h> /* INT_MAX, etc. */
#include <errno.h> /* error checking is good */
#include <sys/types.h> /* many other includes want this */
#ifdef HAVE_STDINT_H
# include <stdint.h> /* C99 int types, we mostly need uintmax_t */
#endif
#include "compat.h"
#include "macros.h"
#include "failures.h"
#include "data-stack.h"
#include "mempool.h"
#include "imem.h"
typedef struct buffer buffer_t;
typedef struct buffer string_t;
struct istream;
struct ostream;
#include "array-decl.h" /* ARRAY_DEFINE()s may exist in any header */
#include "strfuncs.h"
size_t nearest_power(size_t num);
void lib_init(void);
void lib_deinit(void);
#endif
| #ifndef __LIB_H
#define __LIB_H
/* default lib includes */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* default system includes - keep these at minimum.. */
#include <stddef.h> /* Solaris defines NULL wrong unless this is used */
#include <string.h> /* strcmp() etc. */
#ifdef HAVE_STRINGS_H
# include <strings.h> /* strcasecmp() etc. */
#endif
#include <stdarg.h> /* va_list is used everywhere */
#include <limits.h> /* INT_MAX, etc. */
#include <errno.h> /* error checking is good */
#include <sys/types.h> /* many other includes want this */
#ifdef HAVE_STDINT_H
# include <stdint.h> /* C99 int types, we mostly need uintmax_t */
#endif
#include "compat.h"
#include "macros.h"
#include "failures.h"
#include "data-stack.h"
#include "mempool.h"
#include "imem.h"
typedef struct buffer buffer_t;
typedef struct buffer string_t;
struct istream;
struct ostream;
#include "array-decl.h" /* ARRAY_DEFINE()s may exist in any header */
#include "strfuncs.h"
size_t nearest_power(size_t num);
void lib_init(void);
void lib_deinit(void);
#endif
|
Add a member to Map for the pending structure | /*
* Copyright (C) 2015 Luke San Antonio
* All rights reserved.
*/
#pragma once
#include "../common/vec.h"
#include "structure.h"
#include "../gfx/immediate_renderer.h"
namespace game
{
using pos_t = Vec<float>;
struct Structure_Instance
{
Structure_Instance(Structure const&, pos_t pos) noexcept;
~Structure_Instance() noexcept = default;
void set_structure_type(Structure const& s) noexcept;
Structure const& structure() const noexcept;
pos_t position;
private:
Structure const* s_type_;
};
void render_structure(gfx::IDriver& d, Structure const& st,
pos_t pos) noexcept;
inline void render_structure_instance(gfx::IDriver& d,
Structure_Instance const& st) noexcept
{
render_structure(d, st.structure(), st.position);
}
struct Map
{
Map(Vec<float> map_extents) noexcept : extents(map_extents) {}
std::vector<Structure_Instance> structures;
Vec<float> extents;
};
bool try_structure_place(Map& map, Structure const& st, pos_t pos,
gfx::Immediate_Renderer* = nullptr) noexcept;
}
| /*
* Copyright (C) 2015 Luke San Antonio
* All rights reserved.
*/
#pragma once
#include "../common/vec.h"
#include "structure.h"
#include "../gfx/immediate_renderer.h"
namespace game
{
using pos_t = Vec<float>;
struct Structure_Instance
{
Structure_Instance(Structure const&, pos_t pos) noexcept;
~Structure_Instance() noexcept = default;
void set_structure_type(Structure const& s) noexcept;
Structure const& structure() const noexcept;
pos_t position;
private:
Structure const* s_type_;
};
void render_structure(gfx::IDriver& d, Structure const& st,
pos_t pos) noexcept;
inline void render_structure_instance(gfx::IDriver& d,
Structure_Instance const& st) noexcept
{
render_structure(d, st.structure(), st.position);
}
struct Map
{
Map(Vec<float> map_extents) noexcept : extents(map_extents) {}
boost::optional<Structure_Instance> pending_structure;
std::vector<Structure_Instance> structures;
Vec<float> extents;
};
bool try_structure_place(Map& map, Structure const& st, pos_t pos,
gfx::Immediate_Renderer* = nullptr) noexcept;
}
|
Fix export header and windows export macros |
#ifndef GPGMEPP_EXPORT_H
#define GPGMEPP_EXPORT_H
#ifdef GPGMEPP_STATIC_DEFINE
# define GPGMEPP_EXPORT
# define GPGMEPP_NO_EXPORT
#else
# ifndef GPGMEPP_EXPORT
# ifdef KF5Gpgmepp_EXPORTS
/* We are building this library */
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
# endif
# endif
# ifndef GPGMEPP_NO_EXPORT
# define GPGMEPP_NO_EXPORT __attribute__((visibility("hidden")))
# endif
#endif
#ifndef GPGMEPP_DEPRECATED
# define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef GPGMEPP_DEPRECATED_EXPORT
# define GPGMEPP_DEPRECATED_EXPORT GPGMEPP_EXPORT GPGMEPP_DEPRECATED
#endif
#ifndef GPGMEPP_DEPRECATED_NO_EXPORT
# define GPGMEPP_DEPRECATED_NO_EXPORT GPGMEPP_NO_EXPORT GPGMEPP_DEPRECATED
#endif
#define DEFINE_NO_DEPRECATED 0
#if DEFINE_NO_DEPRECATED
# define GPGMEPP_NO_DEPRECATED
#endif
#endif
|
#ifndef GPGMEPP_EXPORT_H
#define GPGMEPP_EXPORT_H
#ifdef GPGMEPP_STATIC_DEFINE
# define GPGMEPP_EXPORT
# define GPGMEPP_NO_EXPORT
#else
# ifndef GPGMEPP_EXPORT
# ifdef BUILDING_GPGMEPP
/* We are building this library */
# ifdef WIN32
# define GPGMEPP_EXPORT __declspec(dllexport)
# else
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
# endif
# else
/* We are using this library */
# ifdef WIN32
# define GPGMEPP_EXPORT __declspec(dllimport)
# else
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
# endif
# endif
# endif
# ifndef GPGMEPP_NO_EXPORT
# ifdef WIN32
# define GPGMEPP_NO_EXPORT
# else
# define GPGMEPP_NO_EXPORT __attribute__((visibility("hidden")))
# endif
# endif
#endif
#ifndef GPGMEPP_DEPRECATED
# define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef GPGMEPP_DEPRECATED_EXPORT
# define GPGMEPP_DEPRECATED_EXPORT GPGMEPP_EXPORT GPGMEPP_DEPRECATED
#endif
#ifndef GPGMEPP_DEPRECATED_NO_EXPORT
# define GPGMEPP_DEPRECATED_NO_EXPORT GPGMEPP_NO_EXPORT GPGMEPP_DEPRECATED
#endif
#define DEFINE_NO_DEPRECATED 0
#if DEFINE_NO_DEPRECATED
# define GPGMEPP_NO_DEPRECATED
#endif
#endif
|
Add inOrder_iter() signature to header | #ifndef __STACK__
#define __STACK__
struct btreeNode {
int data;
struct btreeNode * left;
struct btreeNode * right;
};
typedef struct btreeNode * btreeNode_t;
typedef struct {
btreeNode_t root;
}btree;
typedef btree * btree_t;
btree_t newTree(void);
int addNode(btree_t, int);
void inOrder(btree_t);
#endif
| #ifndef __STACK__
#define __STACK__
struct btreeNode {
int data;
struct btreeNode * left;
struct btreeNode * right;
};
typedef struct btreeNode * btreeNode_t;
typedef struct {
btreeNode_t root;
}btree;
typedef btree * btree_t;
btree_t newTree(void);
int addNode(btree_t, int);
void inOrder(btree_t);
void inOrder_iter(btree_t);
#endif
|
Integrate topfish and sfdp into main tree, using GTS for triangulation; remove duplicated code | /* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifndef DELAUNAY_H
#define DELAUNAY_H
#include "sparsegraph.h"
v_data *delaunay_triangulation(double *x, double *y, int n);
int *delaunay_tri (double *x, double *y, int n, int* nedges);
v_data *UG_graph(double *x, double *y, int n, int accurate_computation);
#endif
| |
Fix warnings about major and minor macros | /*
* Copyright (C) 2015 Muhammad Tayyab Akram
*
* 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 SHEENBIDI_PARSER_UNICODE_VERSION_H
#define SHEENBIDI_PARSER_UNICODE_VERSION_H
#include <string>
namespace SheenBidi {
namespace Parser {
class UnicodeVersion {
public:
UnicodeVersion(const std::string &versionLine);
int major() const;
int minor() const;
int micro() const;
const std::string &versionString() const;
private:
int m_major;
int m_minor;
int m_micro;
std::string m_versionString;
};
}
}
#endif
| /*
* Copyright (C) 2015 Muhammad Tayyab Akram
*
* 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 SHEENBIDI_PARSER_UNICODE_VERSION_H
#define SHEENBIDI_PARSER_UNICODE_VERSION_H
#include <string>
#ifdef major
#undef major
#endif
#ifdef minor
#undef minor
#endif
namespace SheenBidi {
namespace Parser {
class UnicodeVersion {
public:
UnicodeVersion(const std::string &versionLine);
int major() const;
int minor() const;
int micro() const;
const std::string &versionString() const;
private:
int m_major;
int m_minor;
int m_micro;
std::string m_versionString;
};
}
}
#endif
|
Add comment explaining memset in ArithmeticFPInputs | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkArithmeticImageFilter_DEFINED
#define SkArithmeticImageFilter_DEFINED
#include "include/core/SkImageFilter.h"
struct ArithmeticFPInputs {
ArithmeticFPInputs(float k0, float k1, float k2, float k3, bool enforcePMColor) {
memset(this, 0, sizeof(*this));
fK[0] = k0;
fK[1] = k1;
fK[2] = k2;
fK[3] = k3;
fEnforcePMColor = enforcePMColor;
}
float fK[4];
bool fEnforcePMColor;
};
// DEPRECATED: Use include/effects/SkImageFilters::Arithmetic
class SK_API SkArithmeticImageFilter {
public:
static sk_sp<SkImageFilter> Make(float k1, float k2, float k3, float k4, bool enforcePMColor,
sk_sp<SkImageFilter> background,
sk_sp<SkImageFilter> foreground,
const SkImageFilter::CropRect* cropRect);
static void RegisterFlattenables();
private:
SkArithmeticImageFilter(); // can't instantiate
};
#endif
| /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkArithmeticImageFilter_DEFINED
#define SkArithmeticImageFilter_DEFINED
#include "include/core/SkImageFilter.h"
struct ArithmeticFPInputs {
ArithmeticFPInputs(float k0, float k1, float k2, float k3, bool enforcePMColor) {
// We copy instances of this struct as the input data blob for the SkSL FP. The FP
// may try to access all of our bytes (for comparison purposes), so be sure to zero out
// any padding after the dangling bool.
memset(this, 0, sizeof(*this));
fK[0] = k0;
fK[1] = k1;
fK[2] = k2;
fK[3] = k3;
fEnforcePMColor = enforcePMColor;
}
float fK[4];
bool fEnforcePMColor;
};
// DEPRECATED: Use include/effects/SkImageFilters::Arithmetic
class SK_API SkArithmeticImageFilter {
public:
static sk_sp<SkImageFilter> Make(float k1, float k2, float k3, float k4, bool enforcePMColor,
sk_sp<SkImageFilter> background,
sk_sp<SkImageFilter> foreground,
const SkImageFilter::CropRect* cropRect);
static void RegisterFlattenables();
private:
SkArithmeticImageFilter(); // can't instantiate
};
#endif
|
Make HAL logging wrapper print to stderr instead of stdout | /*
* Copyright (C) 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define LOG_TAG "BlueZ"
#ifdef __BIONIC__
#include <cutils/log.h>
#else
#include <stdio.h>
#define LOG_INFO " I"
#define LOG_WARN " W"
#define LOG_ERROR " E"
#define LOG_DEBUG " D"
#define ALOG(pri, tag, fmt, arg...) printf(tag pri": " fmt"\n", ##arg)
#endif
#define info(fmt, arg...) ALOG(LOG_INFO, LOG_TAG, fmt, ##arg)
#define warn(fmt, arg...) ALOG(LOG_WARN, LOG_TAG, fmt, ##arg)
#define error(fmt, arg...) ALOG(LOG_ERROR, LOG_TAG, fmt, ##arg)
#define DBG(fmt, arg...) ALOG(LOG_DEBUG, LOG_TAG, "%s:%s() "fmt, __FILE__, \
__func__, ##arg)
| /*
* Copyright (C) 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define LOG_TAG "BlueZ"
#ifdef __BIONIC__
#include <cutils/log.h>
#else
#include <stdio.h>
#define LOG_INFO " I"
#define LOG_WARN " W"
#define LOG_ERROR " E"
#define LOG_DEBUG " D"
#define ALOG(pri, tag, fmt, arg...) fprintf(stderr, tag pri": " fmt"\n", ##arg)
#endif
#define info(fmt, arg...) ALOG(LOG_INFO, LOG_TAG, fmt, ##arg)
#define warn(fmt, arg...) ALOG(LOG_WARN, LOG_TAG, fmt, ##arg)
#define error(fmt, arg...) ALOG(LOG_ERROR, LOG_TAG, fmt, ##arg)
#define DBG(fmt, arg...) ALOG(LOG_DEBUG, LOG_TAG, "%s:%s() "fmt, __FILE__, \
__func__, ##arg)
|
Add an include of gtest-printers.h to appease the buildbots. | //===- Testing/Support/SupportHelpers.h -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
#define LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
namespace llvm {
namespace detail {
struct ErrorHolder {
bool Success;
std::string Message;
};
template <typename T> struct ExpectedHolder : public ErrorHolder {
Optional<T *> Value;
};
inline void PrintTo(const ErrorHolder &Err, std::ostream *Out) {
*Out << (Err.Success ? "succeeded" : "failed");
if (!Err.Success) {
*Out << " (" << StringRef(Err.Message).trim().str() << ")";
}
}
template <typename T>
void PrintTo(const ExpectedHolder<T> &Item, std::ostream *Out) {
if (Item.Success) {
*Out << "succeeded with value \"" << testing::PrintToString(**Item.Value)
<< "\"";
} else {
PrintTo(static_cast<const ErrorHolder &>(Item), Out);
}
}
} // namespace detail
} // namespace llvm
#endif
| //===- Testing/Support/SupportHelpers.h -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
#define LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "gtest/gtest-printers.h"
namespace llvm {
namespace detail {
struct ErrorHolder {
bool Success;
std::string Message;
};
template <typename T> struct ExpectedHolder : public ErrorHolder {
Optional<T *> Value;
};
inline void PrintTo(const ErrorHolder &Err, std::ostream *Out) {
*Out << (Err.Success ? "succeeded" : "failed");
if (!Err.Success) {
*Out << " (" << StringRef(Err.Message).trim().str() << ")";
}
}
template <typename T>
void PrintTo(const ExpectedHolder<T> &Item, std::ostream *Out) {
if (Item.Success) {
*Out << "succeeded with value \"" << ::testing::PrintToString(**Item.Value)
<< "\"";
} else {
PrintTo(static_cast<const ErrorHolder &>(Item), Out);
}
}
} // namespace detail
} // namespace llvm
#endif
|
Add readint and writeint call. |
int fibonacci(int n)
{
if(n == 1)
return 1;
if(n == 2)
return 1;
int x = fibonacci(n - 1);
int y = fibonacci(n - 2);
return x + y;
}
void main()
{
return;
}
|
int fibonacci(int n)
{
if(n == 1)
return 1;
if(n == 2)
return 1;
int x = fibonacci(n - 1);
int y = fibonacci(n - 2);
return x + y;
}
void main()
{
int n = readint();
writeint(fibonacci(n));
return;
}
|
Make static some functions that should be static | #ifndef TIMER_DISPLAY_H
#define TIMER_DISPLAY_H
#include <SevenSegmentExtended.h>
class TimerDisplay : public SevenSegmentExtended
{
public:
TimerDisplay(uint8_t pin_clk, uint8_t pin_dio);
void on();
void off();
void start();
void stop();
void refresh();
private:
unsigned long start_millis;
bool is_running;
static const unsigned long millis_per_second = 1000;
static const unsigned long millis_per_minute = 60 * millis_per_second;
static const unsigned long millis_per_hour = 60 * millis_per_minute;
uint8_t millisToSeconds(unsigned long millis);
uint8_t millisToMinutes(unsigned long millis);
};
#endif
| #ifndef TIMER_DISPLAY_H
#define TIMER_DISPLAY_H
#include <SevenSegmentExtended.h>
class TimerDisplay : public SevenSegmentExtended
{
public:
TimerDisplay(uint8_t pin_clk, uint8_t pin_dio);
void on();
void off();
void start();
void stop();
void refresh();
private:
unsigned long start_millis;
bool is_running;
static const unsigned long millis_per_second = 1000;
static const unsigned long millis_per_minute = 60 * millis_per_second;
static const unsigned long millis_per_hour = 60 * millis_per_minute;
static uint8_t millisToSeconds(unsigned long millis);
static uint8_t millisToMinutes(unsigned long millis);
};
#endif
|
Use gcc attribute for clang too. | #ifdef __GNUC__
#define DLL_PUBLIC __attribute__ ((dllexport))
#else
#define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
#endif
DLL_PUBLIC int libtest_main()
{
return 0;
}
| #if defined(__GNUC__) || defined(__clang__)
# define DLL_PUBLIC __attribute__ ((dllexport))
#else
# define DLL_PUBLIC __declspec(dllexport)
#endif
DLL_PUBLIC int libtest_main()
{
return 0;
}
|
Add example with hack to delay without timer | #include <inc/hw_types.h>
#include <driverlib/sysctl.h>
#include <stdio.h>
#include <string.h>
#include <inc/hw_memmap.h>
#include <inc/hw_sysctl.h>
#include <driverlib/gpio.h>
#include <driverlib/debug.h>
#define DEFAULT_STRENGTH GPIO_STRENGTH_2MA
#define DEFAULT_PULL_TYPE GPIO_PIN_TYPE_STD_WPU
#define PORT_E GPIO_PORTE_BASE
#define PORT_F GPIO_PORTF_BASE
#define PIN_0 GPIO_PIN_0
#define PIN_1 GPIO_PIN_1
#define PIN_2 GPIO_PIN_2
#define PIN_3 GPIO_PIN_3
#define HIGH 0xFF
#define LOW 0x00
void hackDelay() {
int i = 0;
for (i = 0; i < 1000000; i++);
}
void setup() {
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOInput(PORT_E, PIN_0 | PIN_1 | PIN_2 | PIN_3);
GPIOPadConfigSet(PORT_E, PIN_0 | PIN_1 | PIN_2 | PIN_3, DEFAULT_STRENGTH, DEFAULT_PULL_TYPE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(PORT_F, PIN_0 | PIN_1 | PIN_2 | PIN_3);
GPIOPadConfigSet(PORT_F, PIN_0 | PIN_1 | PIN_2 | PIN_3, DEFAULT_STRENGTH, DEFAULT_PULL_TYPE);
}
int main(){
setup();
while (1) {
GPIOPinWrite(PORT_F, PIN_0, HIGH);
hackDelay();
GPIOPinWrite(PORT_F, PIN_0, LOW);
GPIOPinWrite(PORT_F, PIN_2, LOW);
hackDelay();
GPIOPinWrite(PORT_F, PIN_2, HIGH);
GPIOPinWrite(PORT_F, PIN_3, LOW);
hackDelay();
GPIOPinWrite(PORT_F, PIN_3, HIGH);
}
}
| |
Add decl. for new mapping info pass factory method. | //===- lib/Target/SparcV9/MappingInfo.h -------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Data structures to support the Reoptimizer's Instruction-to-MachineInstr
// mapping information gatherer.
//
//===----------------------------------------------------------------------===//
#ifndef MAPPINGINFO_H
#define MAPPINGINFO_H
#include <iosfwd>
#include <vector>
#include <string>
namespace llvm {
class Pass;
Pass *getMappingInfoAsmPrinterPass(std::ostream &out);
class MappingInfo {
struct byteVector : public std::vector <unsigned char> {
void dumpAssembly (std::ostream &Out);
};
std::string comment;
std::string symbolPrefix;
unsigned functionNumber;
byteVector bytes;
public:
void outByte (unsigned char b) { bytes.push_back (b); }
MappingInfo (std::string Comment, std::string SymbolPrefix,
unsigned FunctionNumber) : comment(Comment),
symbolPrefix(SymbolPrefix), functionNumber(FunctionNumber) {}
void dumpAssembly (std::ostream &Out);
unsigned char *getBytes (unsigned &length) {
length = bytes.size(); return &bytes[0];
}
};
} // End llvm namespace
#endif
| //===- lib/Target/SparcV9/MappingInfo.h -------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Data structures to support the Reoptimizer's Instruction-to-MachineInstr
// mapping information gatherer.
//
//===----------------------------------------------------------------------===//
#ifndef MAPPINGINFO_H
#define MAPPINGINFO_H
#include <iosfwd>
#include <vector>
#include <string>
namespace llvm {
class Pass;
Pass *getMappingInfoAsmPrinterPass(std::ostream &out);
Pass *createInternalGlobalMapperPass();
class MappingInfo {
struct byteVector : public std::vector <unsigned char> {
void dumpAssembly (std::ostream &Out);
};
std::string comment;
std::string symbolPrefix;
unsigned functionNumber;
byteVector bytes;
public:
void outByte (unsigned char b) { bytes.push_back (b); }
MappingInfo (std::string Comment, std::string SymbolPrefix,
unsigned FunctionNumber) : comment(Comment),
symbolPrefix(SymbolPrefix), functionNumber(FunctionNumber) {}
void dumpAssembly (std::ostream &Out);
unsigned char *getBytes (unsigned &length) {
length = bytes.size(); return &bytes[0];
}
};
} // End llvm namespace
#endif
|
Resolve build break for rtl8721csm/security_hal_test config. | #ifndef _SECLINK_DRV_H__
#define _SECLINK_DRV_H__
#include <stdint.h>
struct sec_lowerhalf_s;
struct sec_upperhalf_s {
struct sec_lowerhalf_s *lower;
char *path;
int32_t refcnt;
sem_t su_lock;
};
struct sec_ops_s;
struct sec_lowerhalf_s {
struct sec_ops_s *ops;
struct sec_upperhalf_s *parent;
};
int se_register(const char *path, struct sec_lowerhalf_s *lower);
int se_unregister(struct sec_lowerhalf_s *lower);
#endif // _SECLINK_DRV_H__
| #ifndef _SECLINK_DRV_H__
#define _SECLINK_DRV_H__
#include <stdint.h>
#include <semaphore.h>
struct sec_lowerhalf_s;
struct sec_upperhalf_s {
struct sec_lowerhalf_s *lower;
char *path;
int32_t refcnt;
sem_t su_lock;
};
struct sec_ops_s;
struct sec_lowerhalf_s {
struct sec_ops_s *ops;
struct sec_upperhalf_s *parent;
};
int se_register(const char *path, struct sec_lowerhalf_s *lower);
int se_unregister(struct sec_lowerhalf_s *lower);
#endif // _SECLINK_DRV_H__
|
Add BlockingOpCanceled and use im_zstr | #ifndef LIB_MART_COMMON_GUARD_EXPERIMENTAL_NW_EXCEPTIONS_H
#define LIB_MART_COMMON_GUARD_EXPERIMENTAL_NW_EXCEPTIONS_H
#include <exception>
#include "ConstString.h"
namespace mart {
class RuntimeError : public std::exception {
mart::ConstString _msg;
public:
RuntimeError( mart::ConstString message )
: _msg( std::move( message ).createZStr() )
{
}
const char* what() const noexcept override { return _msg.c_str(); }
};
struct InvalidArgument : RuntimeError {
using RuntimeError::RuntimeError;
};
} // namespace mart
#endif | #ifndef LIB_MART_COMMON_GUARD_EXPERIMENTAL_NW_EXCEPTIONS_H
#define LIB_MART_COMMON_GUARD_EXPERIMENTAL_NW_EXCEPTIONS_H
#include <exception>
#include "ConstString.h"
namespace mart {
class RuntimeError : public std::exception {
mba::im_zstr _msg;
public:
RuntimeError( mba::im_zstr message ) noexcept
: _msg( std::move( message ) )
{
}
const char* what() const noexcept override { return _msg.c_str(); }
};
struct InvalidArgument : RuntimeError {
using RuntimeError::RuntimeError;
};
struct BlockingOpCanceled : RuntimeError {
BlockingOpCanceled() noexcept
: RuntimeError( mba::im_zstr( "Blocking operation was canceled" ) )
{
}
using RuntimeError::RuntimeError;
};
} // namespace mart
#endif |
Fix build with enable final | #ifndef GPXMLHANDLER_H
#define GPXMLHANDlER_H
#include <QtXml/QXmlDefaultHandler>
#include <QtCore/QDebug>
class PlaceContainer;
class PlaceMark;
class KAtlasXmlHandler : public QXmlDefaultHandler {
public:
KAtlasXmlHandler();
KAtlasXmlHandler( PlaceContainer* );
bool startDocument();
bool stopDocument();
bool startElement( const QString&, const QString&, const QString &name, const QXmlAttributes& attrs );
bool endElement( const QString&, const QString&, const QString &name );
bool characters( const QString& str );
protected:
PlaceContainer* m_placecontainer;
PlaceMark* m_placemark;
bool m_inKml;
bool m_inPlacemark;
bool m_inPoint;
bool m_coordsset;
QString m_currentText;
inline int popIdx( int population );
};
#endif // GPXMLHANDLER_H
| #ifndef GPXMLHANDLER_H
#define GPXMLHANDLER_H
#include <QtXml/QXmlDefaultHandler>
#include <QtCore/QDebug>
class PlaceContainer;
class PlaceMark;
class KAtlasXmlHandler : public QXmlDefaultHandler {
public:
KAtlasXmlHandler();
KAtlasXmlHandler( PlaceContainer* );
bool startDocument();
bool stopDocument();
bool startElement( const QString&, const QString&, const QString &name, const QXmlAttributes& attrs );
bool endElement( const QString&, const QString&, const QString &name );
bool characters( const QString& str );
protected:
PlaceContainer* m_placecontainer;
PlaceMark* m_placemark;
bool m_inKml;
bool m_inPlacemark;
bool m_inPoint;
bool m_coordsset;
QString m_currentText;
inline int popIdx( int population );
};
#endif // GPXMLHANDLER_H
|
Use _mm_pause rather than __builtin_ia32_pause. | // Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "config.h"
#include <stddef.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sched.h>
#include <unistd.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include "runtime.h"
/* Spin wait. */
void
runtime_procyield (uint32 cnt)
{
volatile uint32 i;
for (i = 0; i < cnt; ++i)
{
#if defined (__i386__) || defined (__x86_64__)
__builtin_ia32_pause ();
#endif
}
}
/* Ask the OS to reschedule this thread. */
void
runtime_osyield (void)
{
sched_yield ();
}
/* Sleep for some number of microseconds. */
void
runtime_usleep (uint32 us)
{
struct timeval tv;
tv.tv_sec = us / 1000000;
tv.tv_usec = us % 1000000;
select (0, NULL, NULL, NULL, &tv);
}
| // Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "config.h"
#include <stddef.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sched.h>
#include <unistd.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#if defined (__i386__) || defined (__x86_64__)
#include <xmmintrin.h>
#endif
#include "runtime.h"
/* Spin wait. */
void
runtime_procyield (uint32 cnt)
{
volatile uint32 i;
for (i = 0; i < cnt; ++i)
{
#if defined (__i386__) || defined (__x86_64__)
_mm_pause ();
#endif
}
}
/* Ask the OS to reschedule this thread. */
void
runtime_osyield (void)
{
sched_yield ();
}
/* Sleep for some number of microseconds. */
void
runtime_usleep (uint32 us)
{
struct timeval tv;
tv.tv_sec = us / 1000000;
tv.tv_usec = us % 1000000;
select (0, NULL, NULL, NULL, &tv);
}
|
Make block size a protected member of a block channel. | #ifndef BLOCK_CHANNEL_H
#define BLOCK_CHANNEL_H
class Action;
class Buffer;
class BlockChannel {
protected:
BlockChannel(void)
{ }
public:
virtual ~BlockChannel()
{ }
virtual Action *close(EventCallback *) = 0;
virtual Action *read(off_t, EventCallback *) = 0;
virtual Action *write(off_t, Buffer *, EventCallback *) = 0;
};
#endif /* !BLOCK_CHANNEL_H */
| #ifndef BLOCK_CHANNEL_H
#define BLOCK_CHANNEL_H
class Action;
class Buffer;
class BlockChannel {
protected:
size_t bsize_;
BlockChannel(size_t bsize)
: bsize_(bsize)
{ }
public:
virtual ~BlockChannel()
{ }
virtual Action *close(EventCallback *) = 0;
virtual Action *read(off_t, EventCallback *) = 0;
virtual Action *write(off_t, Buffer *, EventCallback *) = 0;
};
#endif /* !BLOCK_CHANNEL_H */
|
Fix uninitialised gnu output for "-ansi" flag | #include <string.h>
#include "std.h"
int std_from_str(const char *std, enum c_std *penu, int *gnu)
{
if(!strcmp(std, "-ansi"))
goto std_c90;
if(strncmp(std, "-std=", 5))
return 1;
std += 5;
if(!strncmp(std, "gnu", 3)){
if(gnu)
*gnu = 1;
std += 3;
}else if(*std == 'c'){
if(gnu)
*gnu = 0;
std++;
}else{
return 1;
}
if(!strcmp(std, "99")){
*penu = STD_C99;
}else if(!strcmp(std, "90")){
std_c90:
*penu = STD_C90;
}else if(!strcmp(std, "89")){
*penu = STD_C89;
}else if(!strcmp(std, "11")){
*penu = STD_C11;
}else if(!strcmp(std, "17") || !strcmp(std, "18")){
*penu = STD_C18;
}else{
return 1;
}
return 0;
}
| #include <string.h>
#include "std.h"
int std_from_str(const char *std, enum c_std *penu, int *gnu)
{
if(!strcmp(std, "-ansi")){
if(gnu)
*gnu = 0;
goto std_c90;
}
if(strncmp(std, "-std=", 5))
return 1;
std += 5;
if(!strncmp(std, "gnu", 3)){
if(gnu)
*gnu = 1;
std += 3;
}else if(*std == 'c'){
if(gnu)
*gnu = 0;
std++;
}else{
return 1;
}
if(!strcmp(std, "99")){
*penu = STD_C99;
}else if(!strcmp(std, "90")){
std_c90:
*penu = STD_C90;
}else if(!strcmp(std, "89")){
*penu = STD_C89;
}else if(!strcmp(std, "11")){
*penu = STD_C11;
}else if(!strcmp(std, "17") || !strcmp(std, "18")){
*penu = STD_C18;
}else{
return 1;
}
return 0;
}
|
Fix for recursive template (which somehow builds on Apple LLVM version 7.3.0 (clang-703.0.31) | // -*- Mode: C++ -*-
#include "mapbox_variant/variant.hpp"
#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
// Variant value types for span tags and log payloads.
#ifndef __LIGHTSTEP_VALUE_H__
#define __LIGHTSTEP_VALUE_H__
namespace lightstep {
class Value;
typedef std::unordered_map<std::string, Value> Dictionary;
typedef std::vector<Value> Values;
typedef mapbox::util::variant<bool,
double,
int64_t,
uint64_t,
std::string,
std::nullptr_t,
Values,
Dictionary> variant_type;
class Value : public variant_type {
public:
Value() : variant_type(nullptr) { }
template <typename T>
Value(T&& t) : variant_type(t) { }
std::string to_string() const;
};
} // namespace lighstep
#endif // __LIGHTSTEP_VALUE_H__
| // -*- Mode: C++ -*-
#include "mapbox_variant/variant.hpp"
#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
// Variant value types for span tags and log payloads.
#ifndef __LIGHTSTEP_VALUE_H__
#define __LIGHTSTEP_VALUE_H__
namespace lightstep {
class Value;
typedef std::unordered_map<std::string, Value> Dictionary;
typedef std::vector<Value> Values;
typedef mapbox::util::variant<bool,
double,
int64_t,
uint64_t,
std::string,
std::nullptr_t,
mapbox::util::recursive_wrapper<Values>,
mapbox::util::recursive_wrapper<Dictionary>> variant_type;
class Value : public variant_type {
public:
Value() : variant_type(nullptr) { }
template <typename T>
Value(T&& t) : variant_type(t) { }
std::string to_string() const;
};
} // namespace lighstep
#endif // __LIGHTSTEP_VALUE_H__
|
Make it print something on session open/close | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return PAM_SUCCESS;
}
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
printf("pam_unshare pam_sm_open_session\n");
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
printf("pam_unshare pam_sm_close_session\n");
return PAM_SUCCESS;
}
|
Add BST Predecessor/Successor func declaration | #include <stdlib.h>
#ifndef __BST_H__
#define __BST_H__
struct BSTNode;
struct BST;
typedef struct BSTNode BSTNode;
typedef struct BST BST;
BST* BST_Create(void);
BSTNode* BSTNode_Create(void* k);
void BST_Inorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Preorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Postorder_Tree_Walk(BST* T, void (f)(void*));
BSTNode* BST_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Iterative_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Tree_Minimum(BSTNode* n);
BSTNode* BST_Tree_Maximum(BSTNode* n);
BSTNode* BST_Tree_Root(BST* T);
#endif | #include <stdlib.h>
#ifndef __BST_H__
#define __BST_H__
struct BSTNode;
struct BST;
typedef struct BSTNode BSTNode;
typedef struct BST BST;
BST* BST_Create(void);
BSTNode* BSTNode_Create(void* k);
void BST_Inorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Preorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Postorder_Tree_Walk(BST* T, void (f)(void*));
BSTNode* BST_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Iterative_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Tree_Minimum(BSTNode* n);
BSTNode* BST_Tree_Maximum(BSTNode* n);
BSTNode* BST_Tree_Root(BST* T);
BSTNode* BST_Tree_Successor(BSTNode* n);
BSTNode* BST_Tree_Predecessor(BSTNode* n);
#endif |
Undo commit: "Made all blocks sensors" | //
// Created by dar on 11/25/15.
//
#ifndef C003_SIMPLEBLOCK_H
#define C003_SIMPLEBLOCK_H
#pragma once
#include "Block.h"
class SimpleBlock : public Block {
public:
SimpleBlock(Map *map, int texPos, int x, int y) : Block(map, x, y), texPos(texPos) {
shape.SetAsBox(0.5, 0.5);
b2FixtureDef fixDef;
fixDef.shape = &shape;
fixDef.isSensor = true;
body->CreateFixture(&fixDef);
};
int getTexPos() const {
return texPos;
}
private:
int texPos;
};
#endif //C003_SIMPLEBLOCK_H | //
// Created by dar on 11/25/15.
//
#ifndef C003_SIMPLEBLOCK_H
#define C003_SIMPLEBLOCK_H
#pragma once
#include "Block.h"
class SimpleBlock : public Block {
public:
SimpleBlock(Map *map, int texPos, int x, int y) : Block(map, x, y), texPos(texPos) {
shape.SetAsBox(0.5, 0.5);
b2FixtureDef fixDef;
fixDef.shape = &shape;
fixDef.isSensor = texPos >= 13 * 16;
body->CreateFixture(&fixDef);
};
int getTexPos() const {
return texPos;
}
private:
int texPos;
};
#endif //C003_SIMPLEBLOCK_H |
Add protected persistable property to Node base class. | #ifndef SRC_NODE_H_
#define SRC_NODE_H_
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <memory>
#include "./render_data.h"
#include "./math/obb.h"
class Gl;
/**
* \brief Base class for nodes which are managed by the
* Nodes class
*
* The only virtual method which must be implemented is
* Node::render.
*/
class Node
{
public:
virtual ~Node()
{
}
virtual void render(Gl *gl, RenderData renderData) = 0;
virtual std::shared_ptr<Math::Obb> getObb()
{
return std::shared_ptr<Math::Obb>();
}
protected:
Node()
{
}
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive &ar, unsigned int version) const
{
}
};
#endif // SRC_NODE_H_
| #ifndef SRC_NODE_H_
#define SRC_NODE_H_
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <memory>
#include "./render_data.h"
#include "./math/obb.h"
class Gl;
/**
* \brief Base class for nodes which are managed by the
* Nodes class
*
* The only virtual method which must be implemented is
* Node::render.
*/
class Node
{
public:
virtual ~Node()
{
}
virtual void render(Gl *gl, RenderData renderData) = 0;
virtual std::shared_ptr<Math::Obb> getObb()
{
return std::shared_ptr<Math::Obb>();
}
bool isPersistable()
{
return persistable;
}
protected:
Node()
{
}
bool persistable = true;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive &ar, unsigned int version) const
{
}
};
#endif // SRC_NODE_H_
|
Fix calling by reference in entity | #ifndef __ENTITY_H__
#define __ENTITY_H__
#include "ModuleCollision.h"
class Entity
{
public:
Entity() : Parent(nullptr) {}
Entity(Entity* parent) : Parent(parent) {}
virtual ~Entity() {}
// Entity lifecycle methods
virtual bool Start()
{
return true;
}
virtual bool Start(bool active)
{
this->_active = active;
return true;
}
bool Enable()
{
if (!_active)
return _active = Start();
return true;
}
bool Disable()
{
if (_active)
return _active = !CleanUp();
return false;
}
bool IsEnabled()
{
return _active;
}
virtual void PreUpdate() {}
virtual void Update() {}
virtual void PostUpdate() {}
virtual bool CleanUp()
{
return true;
}
// Callbacks
virtual bool OnCollision(Collider origin, Collider other)
{
return true;
}
public:
Entity* Parent;
private:
bool _active = true;
};
#endif // __ENTITY_H__
| #ifndef __ENTITY_H__
#define __ENTITY_H__
#include "ModuleCollision.h"
#include "Point3.h"
class Entity
{
public:
Entity() : Parent(nullptr) {}
Entity(Entity* parent) : Parent(parent) {}
virtual ~Entity() {}
// Entity lifecycle methods
virtual bool Start()
{
return true;
}
bool Enable()
{
if (!_active)
return _active = Start();
return true;
}
bool Disable()
{
if (_active)
return _active = !CleanUp();
return false;
}
bool IsEnabled()
{
return _active;
}
virtual void PreUpdate() {}
virtual void Update() {}
virtual void PostUpdate() {}
virtual bool CleanUp()
{
return true;
}
// Callbacks
virtual bool OnCollision(Collider& origin, Collider& other)
{
return true;
}
public:
Entity* Parent;
iPoint3 _position;
private:
bool _active = true;
};
#endif // __ENTITY_H__
|
Add DEFINE_X macros, for ref counters, readers and session readers | #ifndef UTIL_H
#define UTIL_H
/*** Utility functions ***/
#define true 1
#define false 0
#define ALLOC(type) ALLOC_N(type, 1)
#define ALLOC_N(type, n) ((type*) xmalloc(sizeof(type) * (n)))
#define MEMCPY(dst, src, type) MEMCPY_N(dst, src, type, 1)
#define MEMCPY_N(dst, src, type, n) (memcpy((dst), (src), sizeof(type) * (n)))
void *xmalloc(size_t);
char *hextoa(const char *, int);
char *strclone(const char *string);
#define STARTS_WITH(x, y) (strncmp((x), (y), strlen(y)) == 0)
#endif /* UTIL_H */
| #ifndef UTIL_H
#define UTIL_H
/*** Utility functions ***/
#define true 1
#define false 0
#define ALLOC(type) ALLOC_N(type, 1)
#define ALLOC_N(type, n) ((type*) xmalloc(sizeof(type) * (n)))
#define MEMCPY(dst, src, type) MEMCPY_N(dst, src, type, 1)
#define MEMCPY_N(dst, src, type, n) (memcpy((dst), (src), sizeof(type) * (n)))
void *xmalloc(size_t);
char *hextoa(const char *, int);
char *strclone(const char *string);
#define STARTS_WITH(x, y) (strncmp((x), (y), strlen(y)) == 0)
#define DEFINE_REFCOUNTERS_FOR(type) \
void sp_##type##_add_ref(sp_##type *x) {} \
void sp_##type##_release(sp_##type *x) {}
#define DEFINE_READER(return_type, kind, field) \
return_type sp_##kind##_##field(sp_##kind *x) \
{ \
return x->field; \
}
#define DEFINE_SESSION_READER(return_type, kind, field) \
return_type sp_##kind##_##field(sp_session *x, sp_##kind *y) \
{ \
return y->field; \
}
#endif /* UTIL_H */
|
Add missing code for command to string conversion. | #include <mqtt3.h>
const char *mqtt_command_to_string(uint8_t command)
{
switch(command){
case CONNACK:
return "CONNACK";
case CONNECT:
return "CONNECT";
case DISCONNECT:
return "DISCONNECT";
case PINGREQ:
return "PINGREQ";
case PINGRESP:
return "PINGRESP";
case PUBACK:
return "PUBACK";
case PUBCOMP:
return "PUBCOMP";
case PUBLISH:
return "PUBLISH";
case PUBREC:
return "PUBREC";
case PUBREL:
return "PUBREL";
case SUBACK:
return "SUBACK";
case SUBSCRIBE:
return "SUBSCRIBE";
case UNSUBACK:
return "UNSUBACK";
case UNSUBSCRIBE:
return "UNSUBSCRIBE";
}
return "UNKNOWN";
}
| |
Update with new lefty, fixing many bugs and supporting new features | /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* Lefteris Koutsofios - AT&T Bell Laboratories */
#ifndef _STR_H
#define _STR_H
void Sinit(void);
void Sterm(void);
char *Spath(char *, Tobj);
char *Sseen(Tobj, char *);
char *Sabstract(Tobj, Tobj);
char *Stfull(Tobj);
char *Ssfull(Tobj, Tobj);
char *Scfull(Tobj, int, int);
#endif /* _STR_H */
#ifdef __cplusplus
}
#endif
| /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* Lefteris Koutsofios - AT&T Labs Research */
#ifndef _STR_H
#define _STR_H
void Sinit (void);
void Sterm (void);
char *Spath (char *, Tobj);
char *Sseen (Tobj, char *);
char *Sabstract (Tobj, Tobj);
char *Stfull (Tobj);
char *Ssfull (Tobj, Tobj);
char *Scfull (Tobj, int, int);
#endif /* _STR_H */
#ifdef __cplusplus
}
#endif
|
Define the BMP180 container class | #ifndef RCR_LEVEL1PAYLOAD_BMP180_H_
#define RCR_LEVEL1PAYLOAD_BMP180_H_
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
namespace rcr {
namespace level1payload {
} // namespace level1_payload
} // namespace rcr
#endif // RCR_LEVEL1PAYLOAD_BMP180_H_
| #ifndef RCR_LEVEL1PAYLOAD_BMP180_H_
#define RCR_LEVEL1PAYLOAD_BMP180_H_
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include <Adafruit_BMP085_Library\Adafruit_BMP085.h>
namespace rcr {
namespace level1payload {
// Encapsulates a BMP180 sensor and providing selected access to its interface.
// Compatable with (at least) the BMP085 and BMP180.
class Bmp180 {
public:
Bmp180();
// Temperature.
// // UNIT: degrees Celcius
float temperature(void);
// Pressure at the sensor.
// UNIT: pascal (N/m^2)
int32_t ambient_pressure(void);
// Pressure altitude: altitude with altimeter setting at 101325 Pascals == 1013.25 millibars
// == 29.92 inches mercury (i.e., std. pressure) // For pressure conversions, visit NOAA
// at: https://www.weather.gov/media/epz/wxcalc/pressureConversion.pdf.
// (Pressure altitude is NOT correct for non-standard pressure or temperature.)
// UNIT: meters
float pressure_altitude(void);
// Only if a humidity sensor is viable, TODO (Nolan Holden):
// Add density altitude:
// pressure altitude corrected for nonstandard temperature.
// Remember: higher density altitude (High, Hot, and Humid) means decreased performance.
// Disallow copying and moving.
Bmp180(const Bmp180&) = delete;
Bmp180& operator=(const Bmp180&) = delete;
private:
Adafruit_BMP085 bmp;
};
} // namespace level1_payload
} // namespace rcr
#endif // RCR_LEVEL1PAYLOAD_BMP180_H_
|
Include config.h before checking HAVE_X11 | /*
* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
*
* Copyright 2009 Nokia.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef SPI_EVENT_SOURCE_H_
#define SPI_EVENT_SOURCE_H_
#ifdef HAVE_X11
#include <X11/Xlib.h>
void spi_events_init (Display *display);
void spi_set_filter (void (*filter) (XEvent*, void*), void* data);
#endif /* HAVE_X11 */
void spi_events_uninit ();
void spi_set_events (long event_mask);
#endif /* SPI_EVENT_SOURCE_H_ */
| /*
* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
*
* Copyright 2009 Nokia.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef SPI_EVENT_SOURCE_H_
#define SPI_EVENT_SOURCE_H_
#include <config.h>
#ifdef HAVE_X11
#include <X11/Xlib.h>
void spi_events_init (Display *display);
void spi_set_filter (void (*filter) (XEvent*, void*), void* data);
#endif /* HAVE_X11 */
void spi_events_uninit ();
void spi_set_events (long event_mask);
#endif /* SPI_EVENT_SOURCE_H_ */
|
Change filecheck line for map 6 | int f(int);
int main(void) {
int *x, *y;
// CHECK: Found
// CHECK: line [[@LINE+1]]
for(int i = 0; i < 100; i++) {
x[9] = 45;
x[i] = f(y[i]);
}
}
| int f(int);
int main(void) {
int *x, *y;
// CHECK: Near miss
for(int i = 0; i < 100; i++) {
x[9] = 45;
x[i] = f(y[i]);
}
}
|
Define a type alias to represent boards. | #include <stdlib.h>
/**
* @author: Hendrik Werner
*/
#define BOARD_HEIGHT 50
#define BOARD_WIDTH 50
typedef struct Position {
int row;
int col;
} Position;
typedef enum Cell {
EMPTY
,SNAKE
,FOOD
} Cell;
int main() {
return EXIT_SUCCESS;
}
| #include <stdlib.h>
/**
* @author: Hendrik Werner
*/
#define BOARD_HEIGHT 50
#define BOARD_WIDTH 50
typedef struct Position {
int row;
int col;
} Position;
typedef enum Cell {
EMPTY
,SNAKE
,FOOD
} Cell;
typedef Cell Board[BOARD_HEIGHT][BOARD_WIDTH];
int main() {
return EXIT_SUCCESS;
}
|
Add source for main executable | #include <stdio.h>
#include "dbg.h"
#include "stats.h"
int main(int argc, char *argv[])
{
dataset *ds = read_data_file(argv[1]);
if (!ds)
return 1;
printf("count %zu\n", ds->n);
printf("min %.5g\n", min(ds));
printf("Q1 %.5g\n", first_quartile(ds));
printf("mean %.5g\n", mean(ds));
printf("median %.5g\n", median(ds));
printf("Q3 %.5g\n", third_quartile(ds));
printf("max %.5g\n", max(ds));
printf("IQR %.5g\n", interquartile_range(ds));
printf("var %.5g\n", var(ds));
printf("sd %.5g\n", sd(ds));
return 0;
}
| |
Add List Delete function declaration | #include <stdlib.h>
#ifndef __LIST_H__
#define __LIST_H__
struct ListNode;
struct List;
typedef struct ListNode ListNode;
typedef struct List List;
List* List_Create(void);
void List_Destroy(List* l);
ListNode* ListNode_Create(void *);
void ListNode_Destroy(ListNode* n);
ListNode* List_Search(List* l, void* k, int (f)(void*, void*));
void List_Insert(List* l, ListNode* n);
#endif | #include <stdlib.h>
#ifndef __LIST_H__
#define __LIST_H__
struct ListNode;
struct List;
typedef struct ListNode ListNode;
typedef struct List List;
List* List_Create(void);
void List_Destroy(List* l);
ListNode* ListNode_Create(void *);
void ListNode_Destroy(ListNode* n);
ListNode* List_Search(List* l, void* k, int (f)(void*, void*));
void List_Insert(List* l, ListNode* n);
void List_Delete(List* l, ListNode* n);
#endif |
Remove our customed `get_unique_file_info` on Windows platform. | /* ----------------------------------------------------------------------------
(c) The University of Glasgow 2006
Useful Win32 bits
------------------------------------------------------------------------- */
#if defined(_WIN32)
#include "HsBase.h"
int get_unique_file_info(int fd, HsWord64 *dev, HsWord64 *ino)
{
HANDLE h = (HANDLE)_get_osfhandle(fd);
BY_HANDLE_FILE_INFORMATION info;
if (GetFileInformationByHandle(h, &info))
{
*dev = info.dwVolumeSerialNumber;
*ino = info.nFileIndexLow
| ((HsWord64)info.nFileIndexHigh << 32);
return 0;
}
return -1;
}
#endif
| /* ----------------------------------------------------------------------------
(c) The University of Glasgow 2006
Useful Win32 bits
------------------------------------------------------------------------- */
#if defined(_WIN32)
#include "HsBase.h"
#endif
|
Remove comment which is impossible :( | #pragma once
#include "config.h"
#define BOOST_LOG_DYN_LINK
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/trivial.hpp>
int main(int argc, char **argv);
boost::log::sources::severity_logger<boost::log::trivial::severity_level> &get_global_logger(void); // TOOD: Make const
| #pragma once
#include "config.h"
#define BOOST_LOG_DYN_LINK
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/trivial.hpp>
int main(int argc, char **argv);
boost::log::sources::severity_logger<boost::log::trivial::severity_level> &get_global_logger(void);
|
Add motor loop tester to see once and for all if possible | #pragma config(Hubs, S1, HTMotor, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, leftMotor, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, rightMotor, tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
motor[leftMotor] =100;
motor[rightMotor] = -100;
wait1Msec(1000);
for(int i=0;i<kNumbOfRealMotors;i++) {
motor[i] = 0;
}
}
| #pragma config(Hubs, S1, HTMotor, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, Michelangelo_FR, tmotorTetrix, PIDControl, reversed, encoder)
#pragma config(Motor, mtr_S1_C1_2, Donatello_FL, tmotorTetrix, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C2_2, Raphael_BR, tmotorTetrix, PIDControl, reversed, encoder)
#pragma config(Motor, mtr_S1_C2_1, Leonardo_BL, tmotorTetrix, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
//If none of these work, I will be very sad.
#define TOTAL_MOTORS kNumbOfTotalMotors
//#define TOTAL_MOTORS kNumbOfRealMotors
//#define TOTAL_MOTORS kNumbOfVirtualMotors
task main()
{
for(int i=0;i<TOTAL_MOTORS;i++) {
motor[i] = 50;
}
wait1Msec(2000);
motor[Michelangelo_FR] = 0;
motor[Donatello_FL] = 0;
motor[Raphael_BR] = 0;
motor[Leonardo_BL] = 0;
}
|
Add in UIKit import into header. | //
// RMUniversalAlert.h
// RMUniversalAlert
//
// Created by Ryan Maxwell on 19/11/14.
// Copyright (c) 2014 Ryan Maxwell. All rights reserved.
//
@class RMUniversalAlert;
typedef void(^RMUniversalAlertCompletionBlock)(RMUniversalAlert *alert, NSInteger buttonIndex);
@interface RMUniversalAlert : NSObject
+ (instancetype)showAlertInViewController:(UIViewController *)viewController
withTitle:(NSString *)title
message:(NSString *)message
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
tapBlock:(RMUniversalAlertCompletionBlock)tapBlock;
+ (instancetype)showActionSheetInViewController:(UIViewController *)viewController
withTitle:(NSString *)title
message:(NSString *)message
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
tapBlock:(RMUniversalAlertCompletionBlock)tapBlock;
@property (readonly, nonatomic) BOOL visible;
@property (readonly, nonatomic) NSInteger cancelButtonIndex;
@property (readonly, nonatomic) NSInteger firstOtherButtonIndex;
@property (readonly, nonatomic) NSInteger destructiveButtonIndex;
@end
| //
// RMUniversalAlert.h
// RMUniversalAlert
//
// Created by Ryan Maxwell on 19/11/14.
// Copyright (c) 2014 Ryan Maxwell. All rights reserved.
//
#import <UIKit/UIKit.h>
@class RMUniversalAlert;
typedef void(^RMUniversalAlertCompletionBlock)(RMUniversalAlert *alert, NSInteger buttonIndex);
@interface RMUniversalAlert : NSObject
+ (instancetype)showAlertInViewController:(UIViewController *)viewController
withTitle:(NSString *)title
message:(NSString *)message
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
tapBlock:(RMUniversalAlertCompletionBlock)tapBlock;
+ (instancetype)showActionSheetInViewController:(UIViewController *)viewController
withTitle:(NSString *)title
message:(NSString *)message
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
tapBlock:(RMUniversalAlertCompletionBlock)tapBlock;
@property (readonly, nonatomic) BOOL visible;
@property (readonly, nonatomic) NSInteger cancelButtonIndex;
@property (readonly, nonatomic) NSInteger firstOtherButtonIndex;
@property (readonly, nonatomic) NSInteger destructiveButtonIndex;
@end
|
Make QUICHE export use new-style default impl. | // Copyright 2019 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 THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
#define THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
#include "net/quiche/common/platform/impl/quiche_export_impl.h"
// quiche_export_impl.h defines the following macros:
// - QUICHE_EXPORT is not meant to be used.
// - QUICHE_EXPORT_PRIVATE is meant for QUICHE functionality that is built in
// Chromium as part of //net, and not fully contained in headers.
// - QUICHE_NO_EXPORT is meant for QUICHE functionality that is either fully
// defined in a header, or is built in Chromium as part of tests or tools.
#endif // THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
| // Copyright 2019 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 THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
#define THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
#include "quiche_platform_impl/quiche_export_impl.h"
// QUICHE_EXPORT is not meant to be used.
#define QUICHE_EXPORT QUICHE_EXPORT_IMPL
// QUICHE_EXPORT_PRIVATE is meant for QUICHE functionality that is built in
// Chromium as part of //net, and not fully contained in headers.
#define QUICHE_EXPORT_PRIVATE QUICHE_EXPORT_PRIVATE_IMPL
// QUICHE_NO_EXPORT is meant for QUICHE functionality that is either fully
// defined in a header, or is built in Chromium as part of tests or tools.
#define QUICHE_NO_EXPORT QUICHE_NO_EXPORT_IMPL
#endif // THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
|
Fix declarations for IsSynced and SyncPercentage | #include "main.h"
#include "addrman.h"
#include "alert.h"
#include "base58.h"
#include "init.h"
#include "noui.h"
#include "rpcserver.h"
#include "txdb.h"
#include <boost/thread.hpp>
#include <boost/filesystem.hpp>
#include "nan.h"
#include "scheduler.h"
#include "core_io.h"
#include "script/bitcoinconsensus.h"
#include "consensus/validation.h"
NAN_METHOD(StartBitcoind);
NAN_METHOD(OnBlocksReady);
NAN_METHOD(OnTipUpdate);
NAN_METHOD(IsStopping);
NAN_METHOD(IsStopped);
NAN_METHOD(StopBitcoind);
NAN_METHOD(GetBlock);
NAN_METHOD(GetTransaction);
NAN_METHOD(GetInfo);
NAN_METHOD(IsSpent);
NAN_METHOD(GetBlockIndex);
NAN_METHOD(GetMempoolOutputs);
NAN_METHOD(AddMempoolUncheckedTransaction);
NAN_METHOD(VerifyScript);
NAN_METHOD(SendTransaction);
NAN_METHOD(EstimateFee);
NAN_METHOD(StartTxMon);
NAN_METHOD(GetProgress);
| #include "main.h"
#include "addrman.h"
#include "alert.h"
#include "base58.h"
#include "init.h"
#include "noui.h"
#include "rpcserver.h"
#include "txdb.h"
#include <boost/thread.hpp>
#include <boost/filesystem.hpp>
#include "nan.h"
#include "scheduler.h"
#include "core_io.h"
#include "script/bitcoinconsensus.h"
#include "consensus/validation.h"
NAN_METHOD(StartBitcoind);
NAN_METHOD(OnBlocksReady);
NAN_METHOD(OnTipUpdate);
NAN_METHOD(IsStopping);
NAN_METHOD(IsStopped);
NAN_METHOD(StopBitcoind);
NAN_METHOD(GetBlock);
NAN_METHOD(GetTransaction);
NAN_METHOD(GetInfo);
NAN_METHOD(IsSpent);
NAN_METHOD(GetBlockIndex);
NAN_METHOD(GetMempoolOutputs);
NAN_METHOD(AddMempoolUncheckedTransaction);
NAN_METHOD(VerifyScript);
NAN_METHOD(SendTransaction);
NAN_METHOD(EstimateFee);
NAN_METHOD(StartTxMon);
NAN_METHOD(SyncPercentage);
NAN_METHOD(IsSynced);
|
Fix SFINAE default arg and add array overload. | #ifndef BF_WRAP_H
#define BF_WRAP_H
#include <type_traits>
#include "object.h"
namespace bf {
template <
typename T,
typename std::enable_if<std::is_integral<T>::value>::type
>
object wrap(T const& x)
{
return {&x, sizeof(T)};
}
template <typename Sequence>
object wrap(Sequence const& s)
{
return {s.data(), s.size()};
}
} // namespace bf
#endif
| #ifndef BF_WRAP_H
#define BF_WRAP_H
#include <type_traits>
#include <vector>
#include "object.h"
namespace bf {
template <
typename T,
typename = typename std::enable_if<std::is_arithmetic<T>::value>::type
>
object wrap(T const& x)
{
return {&x, sizeof(T)};
}
template <
typename T,
size_t N,
typename = typename std::enable_if<std::is_arithmetic<T>::value>::type
>
object wrap(T const (&str)[N])
{
return {&str, N * sizeof(T)};
}
template <
typename T,
typename = typename std::enable_if<std::is_arithmetic<T>::value>::type
>
object wrap(std::vector<T> const& s)
{
return {s.data(), s.size()};
}
inline object wrap(std::string const& str)
{
return {str.data(), str.size()};
}
} // namespace bf
#endif
|
Create Interface for RTP Streamers | #pragma once
#include "media/processing/filter.h"
#include <QHostAddress>
class IRTPStreamer
{
public:
virtual ~IRTPStreamer();
virtual void init(StatisticsInterface *stats) = 0;
virtual void uninit() = 0;
virtual void run() = 0;
virtual void stop() = 0;
// init a session with sessionID to use with add/remove functions
// returns whether operation was successful
virtual bool addPeer(QHostAddress address, uint32_t sessionID) = 0;
// Returns filter to be attached to filter graph. ownership is not transferred.
// removing the peer or stopping the streamer destroys these filters.
virtual std::shared_ptr<Filter> addSendStream(uint32_t peer, uint16_t port, QString codec, uint8_t rtpNum) = 0;
virtual std::shared_ptr<Filter> addReceiveStream(uint32_t peer, uint16_t port, QString codec, uint8_t rtpNum) = 0;
virtual void removeSendVideo(uint32_t sessionID) = 0;
virtual void removeSendAudio(uint32_t sessionID) = 0;
virtual void removeReceiveVideo(uint32_t sessionID) = 0;
virtual void removeReceiveAudio(uint32_t sessionID) = 0;
// removes everything related to this peer
virtual void removePeer(uint32_t sessionID) = 0;
virtual void removeAllPeers() = 0;
};
| |
Add coding to query the screen to KEYP.c | #! /usr/bin/tcc -run
/* a simple keypress decoder */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
struct termios orig_termios;
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_lflag &= ~(ECHO | ICANON);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
char c1 = ' ';
char c2 = ' ';
char c3 = ' ';
char c4 = ' ';
int test(char c) {
c4=c3; c3=c2; c2=c1; c1=c;
int t4 = 27; int t3 = 91; int t2 = 50; int t1 = 126;
char s4 = t4; char s3 = t3; char s2 = t2; char s1 = t1;
int test = (c4==s4) && (c3==s3) && (c2==s2) && (c1==s1);
return test;
}
int main() {
enableRawMode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') {
if (iscntrl(c)) {
printf("%d\n", c);
} else {
printf("%d ('%c')\n", c, c);
}
if (test(c)) {printf("insert\n");}
char buf[32];
unsigned int i = 0;
/* Query screen for cursor location */
if (write(1, "\x1b[6n", 4) != 4) return 0;
while (i < sizeof(buf)-1)
{
if (read(0,buf+i,1) != 1) break;
if (buf[i] == 'R') break;
i++;
}
printf("i = %d\n",i);
buf[i] = '\0';
int x; int y;
if (buf[0] != 27 || buf[1] != '[') return -1;
int leng = strlen(buf);
printf("string length = %d\n",leng);
printf("<esc>[24;80\n");
int j ;
for ( j = 2; j < 7; j++)
printf("j = %d buf[%d] = %d\n", j, j, buf + j);
// sscanf(buf+2,"%d;%d",x,y);
// if (sscanf(buf+2,"%d;%d",x,y) != 2) return -1;
// printf("x = %d , y = %d \n", x,y);
}
return 0;
}
| |
Fix comparison return values and implement Integer truncation | #include <stdio.h>
void putStr(const char *str) {
fputs(str, stdout);
}
| #include <stdio.h>
#include <gmp.h>
void putStr(const char *str) {
fputs(str, stdout);
}
void mpz_set_ull(mpz_t n, unsigned long long ull)
{
mpz_set_ui(n, (unsigned int)(ull >> 32)); /* n = (unsigned int)(ull >> 32) */
mpz_mul_2exp(n, n, 32); /* n <<= 32 */
mpz_add_ui(n, n, (unsigned int)ull); /* n += (unsigned int)ull */
}
unsigned long long mpz_get_ull(mpz_t n)
{
unsigned int lo, hi;
mpz_t tmp;
mpz_init( tmp );
mpz_mod_2exp( tmp, n, 64 ); /* tmp = (lower 64 bits of n) */
lo = mpz_get_ui( tmp ); /* lo = tmp & 0xffffffff */
mpz_div_2exp( tmp, tmp, 32 ); /* tmp >>= 32 */
hi = mpz_get_ui( tmp ); /* hi = tmp & 0xffffffff */
mpz_clear( tmp );
return (((unsigned long long)hi) << 32) + lo;
}
|
Fix include headers after refactor | #pragma once
#include <string_view>
namespace tid {
enum level : int {
parent = -1,
normal = 0,
detail = 1,
pedant = 2,
};
constexpr std::string_view level2sv(level l) noexcept {
switch(l) {
case normal: return "normal";
case detail: return "detail";
case pedant: return "pedant";
case parent: return "parent";
default: return "unknown";
}
}
}
template<typename T>
extern constexpr std::string_view enum2sv(const T &item);
template<typename T>
extern constexpr auto sv2enum(std::string_view item);
template<>
constexpr std::string_view enum2sv(const tid::level &item) {
switch(item) {
case(tid::level::normal): return "normal";
case(tid::level::detail): return "detail";
case(tid::level::pedant): return "pedant";
case(tid::level::parent): return "parent";
default: throw std::runtime_error("Unrecognized tid::level enum");
}
}
template<>
constexpr auto sv2enum<tid::level>(std::string_view item) {
if(item == "normal") return tid::level::normal;
if(item == "detail") return tid::level::detail;
if(item == "pedant") return tid::level::pedant;
if(item == "parent") return tid::level::parent;
throw std::runtime_error("Given item is not a tid::level enum: " + std::string(item));
}
| #pragma once
#include <exception>
#include <string_view>
namespace tid {
enum level : int {
parent = -1,
normal = 0,
detail = 1,
pedant = 2,
};
constexpr std::string_view level2sv(level l) noexcept {
switch(l) {
case normal: return "normal";
case detail: return "detail";
case pedant: return "pedant";
case parent: return "parent";
default: return "unknown";
}
}
}
template<typename T>
extern constexpr std::string_view enum2sv(const T &item);
template<typename T>
extern constexpr auto sv2enum(std::string_view item);
template<>
constexpr std::string_view enum2sv(const tid::level &item) {
switch(item) {
case(tid::level::normal): return "normal";
case(tid::level::detail): return "detail";
case(tid::level::pedant): return "pedant";
case(tid::level::parent): return "parent";
default: throw std::runtime_error("Unrecognized tid::level enum");
}
}
template<>
constexpr auto sv2enum<tid::level>(std::string_view item) {
if(item == "normal") return tid::level::normal;
if(item == "detail") return tid::level::detail;
if(item == "pedant") return tid::level::pedant;
if(item == "parent") return tid::level::parent;
throw std::runtime_error("Given item is not a tid::level enum");
}
|
Add canMove, isInside and validCommand | #include <stdlib.h>
#include "blobsBack.h"
int requestCmd(int player, typeCommand* command) {
command = NULL;
//if()
return 1;
}
| #include <stdlib.h>
#include "blobsBack.h"
int canMove(int player, typeBoard* board) {
int i, j;
for(i = 0; i < board->h; i++) {
for(j = 0; j < board->w; j++) {
if(board->get[i][j].owner == player && board->get[i][j].canMove) {
return 1;
}
}
}
return 0;
}
char* getCommand(typeCommand* command) {
}
int isInside(int x, int y, int w, int h) {
if(x >= 0 && x < w && y >= 0 && y < h)
return 1;
else
return 0;
}
int validCommand(typeCommand* command, typeBoard* board, int player) {
if(!isInside(command->source.x, command->source.y, board->w, board->h))
return 0;
else if(!isInside(command->target.x, command->target.y, board->w, board->h))
return 0;
else if(abs(command->source.x - command->target.x) > 2 || abs(command->source.y - command->target.y) > 2)
return 0;
else if(board->get[command->source.y][command->source.x].owner != player)
return 0;
else if(board->get[command->target.y][command->target.x].owner != 0)
return 0;
else
return 1;
}
|
Add tests for singleton lifetime | #ifndef TESTCASESINGLETON_H
#define TESTCASESINGLETON_H
#include "CppDiFactory.h"
class IEngine
{
public:
virtual double getVolume() const = 0;
virtual ~IEngine() = default;
};
class Engine : public IEngine
{
public:
virtual double getVolume() const override
{
return 10.5;
}
};
TEST_CASE( "Singleton Test", "Check if two instances of a registered singleton are equal" ){
CppDiFactory::DiFactory myFactory;
myFactory.registerSingleton<Engine>().withInterfaces<IEngine>();
auto engine = myFactory.getInstance<IEngine>();
auto engine2 = myFactory.getInstance<IEngine>();
CHECK(engine == engine2);
}
#endif // TESTCASESINGLETON_H
| #ifndef TESTCASESINGLETON_H
#define TESTCASESINGLETON_H
#include "CppDiFactory.h"
namespace testCaseSingleton
{
class IEngine
{
public:
virtual double getVolume() const = 0;
virtual ~IEngine() = default;
};
class Engine : public IEngine
{
private:
static bool _valid;
public:
Engine() { _valid = true; }
virtual ~Engine () { _valid = false; }
virtual double getVolume() const override
{
return 10.5;
}
static bool isValid() { return _valid; }
};
bool Engine::_valid = false;
TEST_CASE( "Singleton Test", "Check if two instances of a registered singleton are equal" ){
CppDiFactory::DiFactory myFactory;
myFactory.registerSingleton<Engine>().withInterfaces<IEngine>();
auto engine = myFactory.getInstance<IEngine>();
auto engine2 = myFactory.getInstance<IEngine>();
CHECK(engine == engine2);
}
TEST_CASE( "Singleton Lifetime test", "Check that the lifetime of the singleton is correct (alive while used)" ){
CppDiFactory::DiFactory myFactory;
myFactory.registerSingleton<Engine>().withInterfaces<IEngine>();
std::shared_ptr<IEngine> spEngine;
std::weak_ptr<IEngine> wpEngine;
// no request yet --> Engine shouldn't exist yet.
CHECK(!Engine::isValid());
//NOTE: use sub-block to ensure that no temporary shared-pointers remain alive
{
//First call to getInstance should create the engine
spEngine = myFactory.getInstance<IEngine>();
CHECK(Engine::isValid());
}
//shared pointer is alive --> engine should still exist
//NOTE: use sub-block to ensure that no temporary shared-pointers remain alive
{
CHECK(Engine::isValid());
//second call should get same instance
wpEngine = myFactory.getInstance<IEngine>();
CHECK(wpEngine.lock() == spEngine);
}
//remove the only shared pointer to the engine (--> engine should get destroyed)
spEngine.reset();
//shared pointer is not alive anymore --> engine should have been destroyed.
CHECK(wpEngine.expired());
CHECK(!Engine::isValid());
}
}
#endif // TESTCASESINGLETON_H
|
Use enum for flag check | #include <stdio.h>
#include "bincookie.h"
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: %s [Full path to Cookies.binarycookies file]\n", argv[0]);
printf("Example: %s Cookies.binarycookies\n", argv[0]);
return 1;
}
binarycookies_t *bc = binarycookies_init(argv[1]);
unsigned int i, j;
uint32_t flags;
// Output in Netscape cookies.txt format
for (i = 0; i < bc->num_pages; i++) {
for (j = 0; j < bc->pages[i]->number_of_cookies; j++) {
flags = bc->pages[i]->cookies[j]->flags;
// domain, flag, path, secure, expiration, name, value
printf("%s\t%s\t%s\t%s\t%.f\t%s\t%s\n",
bc->pages[i]->cookies[j]->url,
bc->pages[i]->cookies[j]->url[0] == '.' ? "TRUE" : "FALSE",
bc->pages[i]->cookies[j]->path,
flags == 1 || flags == 5 ? "TRUE" : "FALSE",
bc->pages[i]->cookies[j]->expiration_date,
bc->pages[i]->cookies[j]->name,
bc->pages[i]->cookies[j]->value);
}
}
binarycookies_free(bc);
return 0;
}
| #include <stdio.h>
#include "bincookie.h"
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: %s [Full path to Cookies.binarycookies file]\n", argv[0]);
printf("Example: %s Cookies.binarycookies\n", argv[0]);
return 1;
}
binarycookies_t *bc = binarycookies_init(argv[1]);
unsigned int i, j;
binarycookies_flag flags;
// Output in Netscape cookies.txt format
for (i = 0; i < bc->num_pages; i++) {
for (j = 0; j < bc->pages[i]->number_of_cookies; j++) {
flags = bc->pages[i]->cookies[j]->flags;
// domain, flag, path, secure, expiration, name, value
printf("%s\t%s\t%s\t%s\t%.f\t%s\t%s\n",
bc->pages[i]->cookies[j]->url,
bc->pages[i]->cookies[j]->url[0] == '.' ? "TRUE" : "FALSE",
bc->pages[i]->cookies[j]->path,
flags == secure || flags == secure_http_only ? "TRUE" : "FALSE",
bc->pages[i]->cookies[j]->expiration_date,
bc->pages[i]->cookies[j]->name,
bc->pages[i]->cookies[j]->value);
}
}
binarycookies_free(bc);
return 0;
}
|
Print irq_num during assert in static irq_attach | /**
* @file
* @brief
*
* @date Mar 12, 2014
* @author: Anton Bondarev
*/
#include <assert.h>
#include <kernel/irq.h>
extern char __static_irq_table_start;
extern char __static_irq_table_end;
#define STATIC_IRQ_TABLE_SIZE \
(((int) &__static_irq_table_end - (int) &__static_irq_table_start) / 4)
int irq_attach(unsigned int irq_nr, irq_handler_t handler, unsigned int flags,
void *dev_id, const char *dev_name) {
assert(irq_nr <= STATIC_IRQ_TABLE_SIZE);
assertf(((void **) &__static_irq_table_start)[irq_nr] != NULL,
"IRQ handler is not assigned with STATIC_IRQ_ATTACH\n");
irqctrl_enable(irq_nr);
return 0;
}
int irq_detach(unsigned int irq_nr, void *dev_id) {
irqctrl_disable(irq_nr);
return 0;
}
void irq_dispatch(unsigned int irq_nr) {
}
| /**
* @file
* @brief
*
* @date Mar 12, 2014
* @author: Anton Bondarev
*/
#include <assert.h>
#include <kernel/irq.h>
extern char __static_irq_table_start;
extern char __static_irq_table_end;
#define STATIC_IRQ_TABLE_SIZE \
(((int) &__static_irq_table_end - (int) &__static_irq_table_start) / 4)
int irq_attach(unsigned int irq_nr, irq_handler_t handler, unsigned int flags,
void *dev_id, const char *dev_name) {
assert(irq_nr <= STATIC_IRQ_TABLE_SIZE);
assertf(((void **) &__static_irq_table_start)[irq_nr] != NULL,
"IRQ(%d) handler is not assigned with STATIC_IRQ_ATTACH\n", irq_nr);
irqctrl_enable(irq_nr);
return 0;
}
int irq_detach(unsigned int irq_nr, void *dev_id) {
irqctrl_disable(irq_nr);
return 0;
}
void irq_dispatch(unsigned int irq_nr) {
}
|
Add 1st part of encoding algorithm | /*
* fibonacci_coding.c
* Author: Duc Thanh Tran
*/
#include <math.h>
/*
* Calculates i-th fibonacci-number (based on Moivre-Binet)
* where we start with 1 and ignore the duplicate 1 at the beginning, i.e.
* the fibonacci sequence is: 1, 2, 3, 5, 8, ...
*/
unsigned int fibonacciNumber(int n)
{
if(n <= 2)
{
return n;
}
double phi = (1 + sqrt(5.0)) / 2.0;
return round(pow(phi,n+1) / sqrt(5.0));
} | /*
* fibonacci_coding.c
* Author: Duc Thanh Tran
*/
#include <math.h>
/*
* Calculates i-th fibonacci-number (based on Moivre-Binet)
* where we start with 1 and ignore the duplicate 1 at the beginning, i.e.
* the fibonacci sequence is: 1, 2, 3, 5, 8, ...
*/
unsigned int fibonacciNumber(int n)
{
if(n <= 2)
{
return n;
}
double phi = (1 + sqrt(5.0)) / 2.0;
return round(pow(phi,n+1) / sqrt(5.0));
}
/*
* Sets the k-th bit in num
*/
inline void setBit(unsigned int *num, int k)
{
*num |= 1 << k;
}
/*
* Encodes a positive integer into a binary codeword with fibonacci numbers as bases
* Adding a 1-bit and reversing the codeword yiels a prefix code
*/
unsigned int encode_fib(unsigned int N)
{
// find highest fibonacci number that is equal or smaller than N
int i = 1;
while(fibonacciNumber(++i) <= N);
i -= 1;
// calculate rest of the Zeckendorf-Representation
unsigned int z_repr = 0;
while(i > 0)
{
if(fibonacciNumber(i) <= N)
{
setBit(&z_repr, i);
N -= fibonacciNumber(i);
// Zeckendorf-Theorem: there are no consecutive 1-bits
i -= 2;
}
else
{
i -= 1;
}
}
// TODO: Zeckendorf representation finished; add 1-bit (UD-property) and reverse bit-representation to achieve prefix-code
return enc;
} |
Add one more check to the micromips attribute test case. NFC | // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
__attribute__((nomicromips(0))) void foo1(); // expected-error {{'nomicromips' attribute takes no arguments}}
__attribute__((micromips(1))) void foo2(); // expected-error {{'micromips' attribute takes no arguments}}
__attribute((nomicromips)) int a; // expected-error {{attribute only applies to functions}}
__attribute((micromips)) int b; // expected-error {{attribute only applies to functions}}
__attribute__((micromips,mips16)) void foo5(); // expected-error {{'micromips' and 'mips16' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__attribute__((mips16,micromips)) void foo6(); // expected-error {{'mips16' and 'micromips' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__attribute((micromips)) void foo7();
__attribute((nomicromips)) void foo8();
| // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
__attribute__((nomicromips(0))) void foo1(); // expected-error {{'nomicromips' attribute takes no arguments}}
__attribute__((micromips(1))) void foo2(); // expected-error {{'micromips' attribute takes no arguments}}
__attribute((nomicromips)) int a; // expected-error {{attribute only applies to functions}}
__attribute((micromips)) int b; // expected-error {{attribute only applies to functions}}
__attribute__((micromips,mips16)) void foo5(); // expected-error {{'micromips' and 'mips16' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__attribute__((mips16,micromips)) void foo6(); // expected-error {{'mips16' and 'micromips' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__attribute((micromips)) void foo7();
__attribute((nomicromips)) void foo8();
__attribute__((mips16)) void foo9(void) __attribute__((micromips)); // expected-error {{'micromips' and 'mips16' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
|
Fix krzy issue for "endswithnewline" | #ifndef QREALPROPERTYWIDGETITEM_H
#define QREALPROPERTYWIDGETITEM_H
#include "widgets/propertywidgetitem.h"
class QDoubleSpinBox;
namespace GluonCreator
{
class QRealPropertyWidgetItem : public PropertyWidgetItem
{
Q_OBJECT
public:
explicit QRealPropertyWidgetItem(QWidget* parent = 0, Qt::WindowFlags f = 0);
~QRealPropertyWidgetItem();
virtual QList<QString> supportedDataTypes() const;
virtual PropertyWidgetItem* instantiate();
public slots:
void setEditValue(const QVariant& value);
void qrealValueChanged(double value);
};
}
#endif | #ifndef QREALPROPERTYWIDGETITEM_H
#define QREALPROPERTYWIDGETITEM_H
#include "widgets/propertywidgetitem.h"
class QDoubleSpinBox;
namespace GluonCreator
{
class QRealPropertyWidgetItem : public PropertyWidgetItem
{
Q_OBJECT
public:
explicit QRealPropertyWidgetItem(QWidget* parent = 0, Qt::WindowFlags f = 0);
~QRealPropertyWidgetItem();
virtual QList<QString> supportedDataTypes() const;
virtual PropertyWidgetItem* instantiate();
public slots:
void setEditValue(const QVariant& value);
void qrealValueChanged(double value);
};
}
#endif
|
Modify methods according to new names in implementation file | //
// AddressGeocoderFactory.h
// bikepath
//
// Created by Farheen Malik on 8/19/14.
// Copyright (c) 2014 Bike Path. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SPGooglePlacesAutocomplete.h"
#import <UIKit/UIKit.h>
#import "GeocodeItem.h"
@interface AddressGeocoderFactory : NSObject
//+ (GeocodeItem*) translateAddressToGeocodeObject:(NSString*)addressString;
+ (NSString*)translateAddresstoUrl:(NSString*)addressString;
//
+ (GeocodeItem*)translateUrlToGeocodedObject:(NSString*)url;
@end
| //
// AddressGeocoderFactory.h
// bikepath
//
// Created by Farheen Malik on 8/19/14.
// Copyright (c) 2014 Bike Path. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SPGooglePlacesAutocomplete.h"
#import <UIKit/UIKit.h>
#import "GeocodeItem.h"
@interface AddressGeocoderFactory : NSObject
//+ (GeocodeItem*) translateAddressToGeocodeObject:(NSString*)addressString;
+ (NSString*)translateAddresstoUrl:(NSString*)addressString;
//
+ (NSMutableDictionary*)translateUrlToGeocodedObject:(NSString*)url;
@end
|
Change test now %ebx is callee-save | // RUN: %ucc -DFIRST -S -o- %s | grep -F 'movl (%%rax), %%eax'
// RUN: %ucc -DSECOND -S -o- %s | grep -F 'movl 4(%%rbx), %%ebx'
#ifdef FIRST
f(int *p)
{
return *p;
// should see that p isn't used after/.retains==1 and not create a new reg,
// but re-use the current
}
#elif defined(SECOND)
struct A
{
int i, j;
};
g(struct A *p)
{
return p->i + p->j;
}
#else
# error neither
#endif
| // RUN: %ucc -DFIRST -S -o- %s | grep -F 'movl (%%rax), %%eax'
// RUN: %ucc -DSECOND -S -o- %s | grep -F 'movl 4(%%rcx), %%ecx'
#ifdef FIRST
f(int *p)
{
return *p;
// should see that p isn't used after/.retains==1 and not create a new reg,
// but re-use the current
}
#elif defined(SECOND)
struct A
{
int i, j;
};
g(struct A *p)
{
return p->i + p->j;
}
#else
# error neither
#endif
|
Add imports that are necessary for clang to parse header files after compilation. | //
// ASAbsoluteLayoutElement.h
// AsyncDisplayKit
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
NS_ASSUME_NONNULL_BEGIN
/**
* Layout options that can be defined for an ASLayoutElement being added to a ASAbsoluteLayoutSpec.
*/
@protocol ASAbsoluteLayoutElement
/**
* @abstract The position of this object within its parent spec.
*/
@property (nonatomic, assign) CGPoint layoutPosition;
#pragma mark Deprecated
@property (nonatomic, assign) ASRelativeSizeRange sizeRange ASDISPLAYNODE_DEPRECATED;
@end
NS_ASSUME_NONNULL_END
| //
// ASAbsoluteLayoutElement.h
// AsyncDisplayKit
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <AsyncDisplayKit/ASBaseDefines.h>
#import <AsyncDisplayKit/ASDimension.h>
NS_ASSUME_NONNULL_BEGIN
/**
* Layout options that can be defined for an ASLayoutElement being added to a ASAbsoluteLayoutSpec.
*/
@protocol ASAbsoluteLayoutElement
/**
* @abstract The position of this object within its parent spec.
*/
@property (nonatomic, assign) CGPoint layoutPosition;
#pragma mark Deprecated
@property (nonatomic, assign) ASRelativeSizeRange sizeRange ASDISPLAYNODE_DEPRECATED;
@end
NS_ASSUME_NONNULL_END
|
Fix fuzzer to compile in C++ mode | /* How to fuzz:
clang main.c -O2 -g -fsanitize=address,fuzzer -o fuzz
cp -r data temp
./fuzz temp/ -dict=gltf.dict -jobs=12 -workers=12
*/
#define CGLTF_IMPLEMENTATION
#include "../cgltf.h"
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
{
cgltf_options options = {0};
cgltf_data* data = NULL;
cgltf_result res = cgltf_parse(&options, Data, Size, &data);
if (res == cgltf_result_success)
{
cgltf_validate(data);
cgltf_free(data);
}
return 0;
}
| /* How to fuzz:
clang main.c -O2 -g -fsanitize=address,fuzzer -o fuzz
cp -r data temp
./fuzz temp/ -dict=gltf.dict -jobs=12 -workers=12
*/
#define CGLTF_IMPLEMENTATION
#include "../cgltf.h"
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
{
cgltf_options options = {cgltf_file_type_invalid};
cgltf_data* data = NULL;
cgltf_result res = cgltf_parse(&options, Data, Size, &data);
if (res == cgltf_result_success)
{
cgltf_validate(data);
cgltf_free(data);
}
return 0;
}
|
Add adding and subtracting operators | //Copyright (c) 2018 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef LAYERINDEX_H
#define LAYERINDEX_H
namespace cura
{
/*
* Struct behaving like a layer number.
*
* This is a facade. It behaves exactly like an integer but is used to indicate
* that it is a layer number.
*/
struct LayerIndex
{
/*
* Casts an integer to a LayerIndex instance.
*/
LayerIndex(int value) : value(value) {};
/*
* Casts the LayerIndex instance to an integer.
*/
operator int() const
{
return value;
}
/*
* The actual layer index.
*
* Note that this could be negative for raft layers.
*/
int value = 0;
};
}
#endif //LAYERINDEX_H | //Copyright (c) 2018 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef LAYERINDEX_H
#define LAYERINDEX_H
namespace cura
{
/*
* Struct behaving like a layer number.
*
* This is a facade. It behaves exactly like an integer but is used to indicate
* that it is a layer number.
*/
struct LayerIndex
{
/*
* Casts an integer to a LayerIndex instance.
*/
LayerIndex(int value) : value(value) {};
/*
* Casts the LayerIndex instance to an integer.
*/
operator int() const
{
return value;
}
LayerIndex operator +(const LayerIndex& other) const
{
return LayerIndex(value + other.value);
}
LayerIndex operator -(const LayerIndex& other) const
{
return LayerIndex(value - other.value);
}
LayerIndex& operator +=(const LayerIndex& other)
{
value += other.value;
return *this;
}
LayerIndex& operator -=(const LayerIndex& other)
{
value -= other.value;
return *this;
}
/*
* The actual layer index.
*
* Note that this could be negative for raft layers.
*/
int value = 0;
};
}
#endif //LAYERINDEX_H |
Fix invalid null precedence value | #ifndef TOKEN_H_
#define TOKEN_H_
#include <iostream>
#include <string>
#include <vector>
enum class TokenType {
NUMBER,
ADD,
SUBTRACT,
MULTIPLY,
DIVIDE,
EXPONENT,
};
enum class OperatorType {
NONE,
UNARY,
BINARY,
EITHER,
};
class Token {
public:
static constexpr unsigned NULL_PRECEDENCE = -1;
// Operators
static const Token ADD;
static const Token SUBTRACT;
static const Token MULTIPLY;
static const Token DIVIDE;
static const Token EXPONENT;
friend bool operator==(const Token& left, const Token& right);
friend bool operator!=(const Token& left, const Token& right);
friend std::ostream& operator<<(std::ostream& out, const Token& token);
public:
Token(TokenType type, const std::string& symbol, unsigned precedence);
static const std::vector<Token>& checkable_tokens();
// Getters
TokenType type() const;
OperatorType operator_type() const;
const std::string& name() const;
const std::string& symbol() const;
double value() const;
unsigned precedence() const;
// Setters
void set_value(double value);
private:
TokenType type_;
const std::string symbol_;
double value_;
const unsigned precedence_;
};
#endif // TOKEN_H_ | #ifndef TOKEN_H_
#define TOKEN_H_
#include <iostream>
#include <string>
#include <vector>
enum class TokenType {
NUMBER,
ADD,
SUBTRACT,
MULTIPLY,
DIVIDE,
EXPONENT,
};
enum class OperatorType {
NONE,
UNARY,
BINARY,
EITHER,
};
class Token {
public:
static constexpr unsigned NULL_PRECEDENCE = 0;
// Operators
static const Token ADD;
static const Token SUBTRACT;
static const Token MULTIPLY;
static const Token DIVIDE;
static const Token EXPONENT;
friend bool operator==(const Token& left, const Token& right);
friend bool operator!=(const Token& left, const Token& right);
friend std::ostream& operator<<(std::ostream& out, const Token& token);
public:
Token(TokenType type, const std::string& symbol, unsigned precedence);
static const std::vector<Token>& checkable_tokens();
// Getters
TokenType type() const;
OperatorType operator_type() const;
const std::string& name() const;
const std::string& symbol() const;
double value() const;
unsigned precedence() const;
// Setters
void set_value(double value);
private:
TokenType type_;
const std::string symbol_;
double value_;
const unsigned precedence_;
};
#endif // TOKEN_H_ |
Increase version for the 4.1 release | // KMail Version Information
//
#ifndef kmversion_h
#define kmversion_h
#define KMAIL_VERSION "1.9.52"
#endif /*kmversion_h*/
| // KMail Version Information
//
#ifndef kmversion_h
#define kmversion_h
#define KMAIL_VERSION "1.10.0"
#endif /*kmversion_h*/
|
Use a EStatusBits 'enum' instead of a 'constexpr static int' (allowing automatic checking for overlaps) | // @(#)root/thread:$Id$
// Author: Bertrand Bellenot 20/10/2004
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TWin32Mutex
#define ROOT_TWin32Mutex
//////////////////////////////////////////////////////////////////////////
// //
// TWin32Mutex //
// //
// This class provides an interface to the Win32 mutex routines. //
// //
//////////////////////////////////////////////////////////////////////////
#include "TMutexImp.h"
#include "Windows4Root.h"
#ifdef __CINT__
struct CRITICAL_SECTION;
#endif
class TWin32Mutex : public TMutexImp {
friend class TWin32Condition;
private:
CRITICAL_SECTION fCritSect;
constexpr static int kIsRecursive = BIT(14);
public:
TWin32Mutex(Bool_t recursive=kFALSE);
virtual ~TWin32Mutex();
Int_t Lock();
Int_t UnLock();
Int_t TryLock();
std::unique_ptr<TVirtualMutex::State> Reset();
void Restore(std::unique_ptr<TVirtualMutex::State> &&);
ClassDef(TWin32Mutex,0) // Win32 mutex lock
};
#endif
| // @(#)root/thread:$Id$
// Author: Bertrand Bellenot 20/10/2004
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TWin32Mutex
#define ROOT_TWin32Mutex
//////////////////////////////////////////////////////////////////////////
// //
// TWin32Mutex //
// //
// This class provides an interface to the Win32 mutex routines. //
// //
//////////////////////////////////////////////////////////////////////////
#include "TMutexImp.h"
#include "Windows4Root.h"
#ifdef __CINT__
struct CRITICAL_SECTION;
#endif
class TWin32Mutex : public TMutexImp {
friend class TWin32Condition;
private:
CRITICAL_SECTION fCritSect;
enum EStatusBits {
kIsRecursive = BIT(14);
}
public:
TWin32Mutex(Bool_t recursive=kFALSE);
virtual ~TWin32Mutex();
Int_t Lock();
Int_t UnLock();
Int_t TryLock();
std::unique_ptr<TVirtualMutex::State> Reset();
void Restore(std::unique_ptr<TVirtualMutex::State> &&);
ClassDef(TWin32Mutex,0) // Win32 mutex lock
};
#endif
|
Change the order of the strings | #include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include "libspell.h"
#include "websters.c"
int
main(int argc, char **argv)
{
size_t i;
char *soundex_code;
FILE *out = fopen("dict/soundex.txt", "w");
if (out == NULL)
err(EXIT_FAILURE, "Failed to open soundex");
for (i = 0; i < sizeof(dict) / sizeof(dict[0]); i++) {
soundex_code = soundex(dict[i]);
if (soundex_code == NULL) {
warnx("No soundex code found for %s", dict[i++]);
continue;
}
fprintf(out, "%s\t%s\n", dict[i], soundex_code);
free(soundex_code);
}
fclose(out);
return 0;
}
| #include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include "libspell.h"
#include "websters.c"
int
main(int argc, char **argv)
{
size_t i;
char *soundex_code;
FILE *out = fopen("dict/soundex.txt", "w");
if (out == NULL)
err(EXIT_FAILURE, "Failed to open soundex");
for (i = 0; i < sizeof(dict) / sizeof(dict[0]); i++) {
soundex_code = soundex(dict[i]);
if (soundex_code == NULL) {
warnx("No soundex code found for %s", dict[i++]);
continue;
}
fprintf(out, "%s\t%s\n", soundex_code, dict[i]);
free(soundex_code);
}
fclose(out);
return 0;
}
|
Add a tool similar to hexdump, but for text files. | /* strdump.c -- similar to hexdump but with ascii strings */
#include <stdio.h>
#include <string.h>
int
strdump(FILE *fo, FILE *fi)
{
int c, n;
n = 0;
fputs("\"", fo);
c = fgetc(fi);
while (c != -1)
{
if (c == '\n' || c == '\r')
fputs("\\n\"\n\"", fo);
else
putc(c, fo);
c = fgetc(fi);
n ++;
}
fputs("\"\n", fo);
return n;
}
int
main(int argc, char **argv)
{
FILE *fo;
FILE *fi;
char name[256];
char *realname;
char *p;
int i, len;
if (argc < 3)
{
fprintf(stderr, "usage: hexdump output.c input.dat\n");
return 1;
}
fo = fopen(argv[1], "wb");
if (!fo)
{
fprintf(stderr, "hexdump: could not open output file\n");
return 1;
}
for (i = 2; i < argc; i++)
{
fi = fopen(argv[i], "rb");
if (!fi)
{
fprintf(stderr, "hexdump: could not open input file\n");
return 1;
}
realname = strrchr(argv[i], '/');
if (!realname)
realname = strrchr(argv[i], '\\');
if (realname)
realname ++;
else
realname = argv[i];
strcpy(name, argv[i]);
p = name;
while (*p)
{
if ((*p == '/') || (*p == '.') || (*p == '\\') || (*p == '-'))
*p = '_';
p ++;
}
fprintf(fo, "const char %s_name[] = \"%s\";\n", name, realname);
fprintf(fo, "const char %s_buf[] = {\n", name);
len = strdump(fo, fi);
fprintf(fo, "};\n");
fprintf(fo, "const int %s_len = %d;\n", name, len);
fprintf(fo, "\n");
fclose(fi);
}
return 0;
}
| |
Revert "Revert "remove unused api on xfermodeimagefilter"" | /*
* Copyright 2013 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkXfermodeImageFilter_DEFINED
#define SkXfermodeImageFilter_DEFINED
#include "SkArithmeticImageFilter.h"
#include "SkBlendMode.h"
#include "SkImageFilter.h"
/**
* This filter takes a SkBlendMode, and uses it to composite the foreground over the background.
* If foreground or background is NULL, the input bitmap (src) is used instead.
*/
class SK_API SkXfermodeImageFilter {
public:
static sk_sp<SkImageFilter> Make(SkBlendMode, sk_sp<SkImageFilter> background,
sk_sp<SkImageFilter> foreground,
const SkImageFilter::CropRect* cropRect);
static sk_sp<SkImageFilter> Make(SkBlendMode mode, sk_sp<SkImageFilter> background) {
return Make(mode, std::move(background), nullptr, nullptr);
}
// Need to update chrome to use SkArithmeticImageFilter instead...
static sk_sp<SkImageFilter> MakeArithmetic(float k1, float k2, float k3, float k4,
bool enforcePMColor, sk_sp<SkImageFilter> background,
sk_sp<SkImageFilter> foreground,
const SkImageFilter::CropRect* cropRect) {
return SkArithmeticImageFilter::Make(k1, k2, k3, k4, enforcePMColor, std::move(background),
std::move(foreground), cropRect);
}
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
private:
SkXfermodeImageFilter(); // can't instantiate
};
#endif
| /*
* Copyright 2013 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkXfermodeImageFilter_DEFINED
#define SkXfermodeImageFilter_DEFINED
#include "SkArithmeticImageFilter.h"
#include "SkBlendMode.h"
#include "SkImageFilter.h"
/**
* This filter takes a SkBlendMode, and uses it to composite the foreground over the background.
* If foreground or background is NULL, the input bitmap (src) is used instead.
*/
class SK_API SkXfermodeImageFilter {
public:
static sk_sp<SkImageFilter> Make(SkBlendMode, sk_sp<SkImageFilter> background,
sk_sp<SkImageFilter> foreground,
const SkImageFilter::CropRect* cropRect);
static sk_sp<SkImageFilter> Make(SkBlendMode mode, sk_sp<SkImageFilter> background) {
return Make(mode, std::move(background), nullptr, nullptr);
}
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
private:
SkXfermodeImageFilter(); // can't instantiate
};
#endif
|
Add missing declaration for init_libdtoolutil() | /**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file config_dtoolutil.h
* @author drose
* @date 2006-11-17
*/
#ifndef CONFIG_DTOOLUTIL_H
#define CONFIG_DTOOLUTIL_H
#include "dtoolbase.h"
// Include this so interrogate can find it.
#include <iostream>
#endif
| /**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file config_dtoolutil.h
* @author drose
* @date 2006-11-17
*/
#ifndef CONFIG_DTOOLUTIL_H
#define CONFIG_DTOOLUTIL_H
#include "dtoolbase.h"
// Include this so interrogate can find it.
#include <iostream>
extern EXPCL_DTOOL_DTOOLUTIL void init_libdtoolutil();
#endif
|
Adjust for new paramter to printStackTrace(). | /*
* java.lang.Throwable.c
*
* Copyright (c) 1996, 1997
* Transvirtual Technologies, Inc. All rights reserved.
*
* See the file "license.terms" for information on usage and redistribution
* of this file.
*/
#include "config.h"
#include "config-io.h"
#include <assert.h>
#include <native.h>
#include "java_io_FileDescriptor.h"
#include "java_io_FileOutputStream.h"
#include "java_io_PrintStream.h"
#include "java_lang_Throwable.h"
#include "../../../kaffe/kaffevm/support.h"
extern Hjava_lang_Object* buildStackTrace(void*);
extern void printStackTrace(struct Hjava_lang_Throwable*, struct Hjava_lang_Object*);
/*
* Fill in stack trace information - don't know what thought.
*/
struct Hjava_lang_Throwable*
java_lang_Throwable_fillInStackTrace(struct Hjava_lang_Throwable* o)
{
unhand(o)->backtrace = buildStackTrace(0);
return (o);
}
/*
* Dump the stack trace to the given stream.
*/
void
java_lang_Throwable_printStackTrace0(struct Hjava_lang_Throwable* o, struct Hjava_lang_Object* p)
{
printStackTrace(o, p);
}
| /*
* java.lang.Throwable.c
*
* Copyright (c) 1996, 1997
* Transvirtual Technologies, Inc. All rights reserved.
*
* See the file "license.terms" for information on usage and redistribution
* of this file.
*/
#include "config.h"
#include "config-io.h"
#include <assert.h>
#include <native.h>
#include "java_io_FileDescriptor.h"
#include "java_io_FileOutputStream.h"
#include "java_io_PrintStream.h"
#include "java_lang_Throwable.h"
#include "../../../kaffe/kaffevm/support.h"
extern Hjava_lang_Object* buildStackTrace(void*);
extern void printStackTrace(struct Hjava_lang_Throwable*, struct Hjava_lang_Object*, int);
/*
* Fill in stack trace information - don't know what thought.
*/
struct Hjava_lang_Throwable*
java_lang_Throwable_fillInStackTrace(struct Hjava_lang_Throwable* o)
{
unhand(o)->backtrace = buildStackTrace(0);
return (o);
}
/*
* Dump the stack trace to the given stream.
*/
void
java_lang_Throwable_printStackTrace0(struct Hjava_lang_Throwable* o, struct Hjava_lang_Object* p)
{
printStackTrace(o, p, 0);
}
|
Add dot product (scalar product) | /**
Produto escalar de dois vetores de N posições.
A.B = axbx + ayby + ... + anbn.
*/
#include <stdio.h>
int produtoEscalar(int sizes, int *v1, int *v2){
int i;
int escalar = 0;
for (i = 0; i < sizes; i++){
escalar += v1[i] * v2[i];
}
return escalar;
}
int main(){
int n;
printf("Dimensão dos vetores: ");
scanf("%d", &n);
int v1[n];
int v2[n];
printf("Escreva os %d elementos inteiros de cada um dos DOIS vetores.\n", n);
int i;
for(i = 0; i < n; i++){
scanf("%d", &v1[i]);
}
for(i = 0; i < n; i++){
scanf("%d", &v2[i]);
}
printf("Produto escalar: %d\n", produtoEscalar(n, v1, v2));
return 0;
} | |
Remove ldXa and stXa defines, unused. | /* asmmacro.h: Assembler macros.
*
* Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
*/
#ifndef _SPARC_ASMMACRO_H
#define _SPARC_ASMMACRO_H
#include <asm/btfixup.h>
#include <asm/asi.h>
#define GET_PROCESSOR4M_ID(reg) \
rd %tbr, %reg; \
srl %reg, 12, %reg; \
and %reg, 3, %reg;
#define GET_PROCESSOR4D_ID(reg) \
lda [%g0] ASI_M_VIKING_TMP1, %reg;
/* All trap entry points _must_ begin with this macro or else you
* lose. It makes sure the kernel has a proper window so that
* c-code can be called.
*/
#define SAVE_ALL_HEAD \
sethi %hi(trap_setup), %l4; \
jmpl %l4 + %lo(trap_setup), %l6;
#define SAVE_ALL \
SAVE_ALL_HEAD \
nop;
/* All traps low-level code here must end with this macro. */
#define RESTORE_ALL b ret_trap_entry; clr %l6;
/* sun4 probably wants half word accesses to ASI_SEGMAP, while sun4c+
likes byte accesses. These are to avoid ifdef mania. */
#define lduXa lduba
#define stXa stba
#endif /* !(_SPARC_ASMMACRO_H) */
| /* asmmacro.h: Assembler macros.
*
* Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
*/
#ifndef _SPARC_ASMMACRO_H
#define _SPARC_ASMMACRO_H
#include <asm/btfixup.h>
#include <asm/asi.h>
#define GET_PROCESSOR4M_ID(reg) \
rd %tbr, %reg; \
srl %reg, 12, %reg; \
and %reg, 3, %reg;
#define GET_PROCESSOR4D_ID(reg) \
lda [%g0] ASI_M_VIKING_TMP1, %reg;
/* All trap entry points _must_ begin with this macro or else you
* lose. It makes sure the kernel has a proper window so that
* c-code can be called.
*/
#define SAVE_ALL_HEAD \
sethi %hi(trap_setup), %l4; \
jmpl %l4 + %lo(trap_setup), %l6;
#define SAVE_ALL \
SAVE_ALL_HEAD \
nop;
/* All traps low-level code here must end with this macro. */
#define RESTORE_ALL b ret_trap_entry; clr %l6;
#endif /* !(_SPARC_ASMMACRO_H) */
|
Change type of view passed to hit test hooks | /*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#import <UIKit/UIKit.h>
typedef UIView *(^CKComponentRootViewHitTestHook)(CKComponentRootView *rootView, CGPoint point, UIEvent *event);
@interface CKComponentRootView ()
/**
Exposes the ability to supplement the hitTest for the root view used in each CKComponentHostingView or
UICollectionViewCell within a CKCollectionViewDataSource.
Each hook will be called in the order they were registered. If any hook returns a view, that will override the return
value of the view's -hitTest:withEvent:. If no hook returns a view, then the super implementation will be invoked.
*/
+ (void)addHitTestHook:(CKComponentRootViewHitTestHook)hook;
/** Returns an array of all registered hit test hooks. */
+ (NSArray *)hitTestHooks;
@end
| /*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#import <UIKit/UIKit.h>
#import <ComponentKit/CKComponentRootView.h>
typedef UIView *(^CKComponentRootViewHitTestHook)(UIView *rootView, CGPoint point, UIEvent *event);
@interface CKComponentRootView ()
/**
Exposes the ability to supplement the hitTest for the root view used in each CKComponentHostingView or
UICollectionViewCell within a CKCollectionViewDataSource.
Each hook will be called in the order they were registered. If any hook returns a view, that will override the return
value of the view's -hitTest:withEvent:. If no hook returns a view, then the super implementation will be invoked.
*/
+ (void)addHitTestHook:(CKComponentRootViewHitTestHook)hook;
/** Returns an array of all registered hit test hooks. */
+ (NSArray *)hitTestHooks;
@end
|
Fix check against nullptr in checkandconvert | // This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_FRAMEWORK_COMPONENT_INL_H
#define SURGSIM_FRAMEWORK_COMPONENT_INL_H
namespace SurgSim
{
namespace Framework
{
template <class Target, class Source>
std::shared_ptr<Target> checkAndConvert(std::shared_ptr<Source> incoming, const std::string& expectedTypeName)
{
auto result = std::dynamic_pointer_cast<Target>(incoming);
SURGSIM_ASSERT(incoming != nullptr && result != nullptr)
<< "Expected " << expectedTypeName << " but received " << incoming->getClassName() << " which cannot "
<< "be converted.";
return result;
};
}
}
#endif
| // This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_FRAMEWORK_COMPONENT_INL_H
#define SURGSIM_FRAMEWORK_COMPONENT_INL_H
namespace SurgSim
{
namespace Framework
{
template <class Target, class Source>
std::shared_ptr<Target> checkAndConvert(std::shared_ptr<Source> incoming, const std::string& expectedTypeName)
{
SURGSIM_ASSERT(incoming != nullptr) << "Incoming pointer can't be nullptr";
auto result = std::dynamic_pointer_cast<Target>(incoming);
SURGSIM_ASSERT(result != nullptr)
<< "Expected " << expectedTypeName << " but received " << incoming->getClassName() << " which cannot "
<< "be converted, in component " << incoming->getFullName() << ".";
return result;
};
}
}
#endif
|
Make sure layer class is destructed first | #ifndef LAYER_H_
#define LAYER_H_
class Layer
{
public:
virtual void render()=0;
virtual void update()=0;
protected:
virtual ~Layer();
};
#endif
| #ifndef LAYER_H_
#define LAYER_H_
//Abstract layer class
class Layer
{
public:
virtual void render()=0;
virtual void update()=0;
protected:
virtual ~Layer() {}
};
#endif
|
Allow to compile with non-GCC compiler. | /* $FreeBSD$ */
#warning "<gnuregex.h> has been replaced by <gnu/regex.h>"
#include <gnu/regex.h>
| /*-
* Copyright (c) 2004 David E. O'Brien
* Copyright (c) 2004 Andrey A. Chernov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifdef __GNUC__
#warning "<gnuregex.h> has been replaced by <gnu/regex.h>"
#endif
#include <gnu/regex.h>
|
Add defines for OSK event ids | #ifndef __LV2_SYSUTIL_H__
#define __LV2_SYSUTIL_H__
#include <ppu-types.h>
#define SYSUTIL_EVENT_SLOT0 0
#define SYSUTIL_EVENT_SLOT1 1
#define SYSUTIL_EVENT_SLOT2 2
#define SYSUTIL_EVENT_SLOT3 3
#define SYSUTIL_EXIT_GAME 0x0101
#define SYSUTIL_DRAW_BEGIN 0x0121
#define SYSUTIL_DRAW_END 0x0122
#define SYSUTIL_MENU_OPEN 0x0131
#define SYSUTIL_MENU_CLOSE 0x0132
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*sysutilCallback)(u64 status,u64 param,void *usrdata);
s32 sysUtilCheckCallback();
s32 sysUtilUnregisterCallback(s32 slot);
s32 sysUtilRegisterCallback(s32 slot,sysutilCallback cb,void *usrdata);
#ifdef __cplusplus
}
#endif
#endif
| #ifndef __LV2_SYSUTIL_H__
#define __LV2_SYSUTIL_H__
#include <ppu-types.h>
#define SYSUTIL_EVENT_SLOT0 0
#define SYSUTIL_EVENT_SLOT1 1
#define SYSUTIL_EVENT_SLOT2 2
#define SYSUTIL_EVENT_SLOT3 3
#define SYSUTIL_EXIT_GAME 0x0101
#define SYSUTIL_DRAW_BEGIN 0x0121
#define SYSUTIL_DRAW_END 0x0122
#define SYSUTIL_MENU_OPEN 0x0131
#define SYSUTIL_MENU_CLOSE 0x0132
#define SYSUTIL_OSK_LOADED 0x0502
#define SYSUTIL_OSK_DONE 0x0503
#define SYSUTIL_OSK_UNLOADED 0x0504
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*sysutilCallback)(u64 status,u64 param,void *usrdata);
s32 sysUtilCheckCallback();
s32 sysUtilUnregisterCallback(s32 slot);
s32 sysUtilRegisterCallback(s32 slot,sysutilCallback cb,void *usrdata);
#ifdef __cplusplus
}
#endif
#endif
|
Split macro into multiple lines. | /* http://www.jera.com/techinfo/jtns/jtn002.html */
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
#define mu_run_test(testname, test) \
do { \
char *message = test(); tests_run++; \
if (message) return message; \
else printf("OK: %s\n", testname); \
} while (0)
extern int tests_run;
| /* http://www.jera.com/techinfo/jtns/jtn002.html */
#define mu_assert(message, test) \
do { \
if (!(test)) \
return message; \
} while (0)
#define mu_run_test(testname, test) \
do { \
char *message = test(); tests_run++; \
if (message) return message; \
else printf("OK: %s\n", testname); \
} while (0)
extern int tests_run;
|
Clean up what looks like a direct class-dump header. | #import "PSControlTableCell.h"
@class UIActivityIndicatorView;
@interface PSSwitchTableCell : PSControlTableCell {
UIActivityIndicatorView *_activityIndicator;
}
@property BOOL loading;
- (BOOL)loading;
- (void)setLoading:(BOOL)loading;
- (id)controlValue;
- (id)newControl;
- (void)setCellEnabled:(BOOL)enabled;
- (void)refreshCellContentsWithSpecifier:(id)specifier;
- (id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier;
- (void)reloadWithSpecifier:(id)specifier animated:(BOOL)animated;
- (BOOL)canReload;
- (void)prepareForReuse;
- (void)layoutSubviews;
- (void)setValue:(id)value;
@end
| #import "PSControlTableCell.h"
@class UIActivityIndicatorView;
@interface PSSwitchTableCell : PSControlTableCell {
UIActivityIndicatorView *_activityIndicator;
}
@property (nonatomic) BOOL loading;
@end
|
Add turn and interested fields per level | /*
* Raphael Kubo da Costa - RA 072201
*
* MC514 - Lab2
*/
#ifndef __THREAD_TREE_H
#define __THREAD_TREE_H
typedef struct
{
size_t n_elem;
pthread_t *list;
} ThreadLevel;
typedef struct
{
size_t height;
ThreadLevel **tree;
} ThreadTree;
ThreadTree *thread_tree_new(size_t numthreads);
void thread_tree_free(ThreadTree *tree);
#endif /* __THREAD_TREE_H */
| /*
* Raphael Kubo da Costa - RA 072201
*
* MC514 - Lab2
*/
#ifndef __THREAD_TREE_H
#define __THREAD_TREE_H
typedef struct
{
size_t *interested;
pthread_t *list;
size_t n_elem;
size_t turn;
} ThreadLevel;
typedef struct
{
size_t height;
ThreadLevel **tree;
} ThreadTree;
ThreadTree *thread_tree_new(size_t numthreads);
void thread_tree_free(ThreadTree *tree);
#endif /* __THREAD_TREE_H */
|
Add new sections for post details | typedef NS_ENUM(NSInteger, StatsSection) {
StatsSectionGraph,
StatsSectionPeriodHeader,
StatsSectionEvents,
StatsSectionPosts,
StatsSectionReferrers,
StatsSectionClicks,
StatsSectionCountry,
StatsSectionVideos,
StatsSectionAuthors,
StatsSectionSearchTerms,
StatsSectionComments,
StatsSectionTagsCategories,
StatsSectionFollowers,
StatsSectionPublicize,
StatsSectionWebVersion
};
typedef NS_ENUM(NSInteger, StatsSubSection) {
StatsSubSectionCommentsByAuthor = 100,
StatsSubSectionCommentsByPosts,
StatsSubSectionFollowersDotCom,
StatsSubSectionFollowersEmail,
StatsSubSectionNone
};
| typedef NS_ENUM(NSInteger, StatsSection) {
StatsSectionGraph,
StatsSectionPeriodHeader,
StatsSectionEvents,
StatsSectionPosts,
StatsSectionReferrers,
StatsSectionClicks,
StatsSectionCountry,
StatsSectionVideos,
StatsSectionAuthors,
StatsSectionSearchTerms,
StatsSectionComments,
StatsSectionTagsCategories,
StatsSectionFollowers,
StatsSectionPublicize,
StatsSectionWebVersion,
StatsSectionPostDetailsGraph,
StatsSectionPostDetailsMonthsYears,
StatsSectionPostDetailsAveragePerDay,
StatsSectionPostDetailsRecentWeeks
};
typedef NS_ENUM(NSInteger, StatsSubSection) {
StatsSubSectionCommentsByAuthor = 100,
StatsSubSectionCommentsByPosts,
StatsSubSectionFollowersDotCom,
StatsSubSectionFollowersEmail,
StatsSubSectionNone
};
|
Add thread member for offloading disk info ops | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <Windows.h>
#include "OSD.h"
class NotifyIcon;
class EjectOSD : public OSD {
public:
EjectOSD();
virtual void Hide();
virtual void ProcessHotkeys(HotkeyInfo &hki);
private:
DWORD _ignoreDrives;
DWORD _latestDrive;
MeterWnd _mWnd;
NotifyIcon *_icon;
std::vector<HICON> _iconImages;
void EjectDrive(std::wstring driveLetter);
DWORD DriveLetterToMask(wchar_t letter);
wchar_t MaskToDriveLetter(DWORD mask);
virtual void OnDisplayChange();
virtual LRESULT WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
}; | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <Windows.h>
#include <thread>
#include "OSD.h"
class NotifyIcon;
class EjectOSD : public OSD {
public:
EjectOSD();
virtual void Hide();
virtual void ProcessHotkeys(HotkeyInfo &hki);
private:
DWORD _ignoreDrives;
DWORD _latestDrive;
MeterWnd _mWnd;
NotifyIcon *_icon;
std::vector<HICON> _iconImages;
std::thread _menuThread;
void EjectDrive(std::wstring driveLetter);
DWORD DriveLetterToMask(wchar_t letter);
wchar_t MaskToDriveLetter(DWORD mask);
virtual void OnDisplayChange();
virtual LRESULT WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
}; |
Add regexString and inputText properties | //
// CAFMatchedTextViewController.h
// Curiosity
//
// Created by Matthew Thomas on 8/26/12.
// Copyright (c) 2012 Matthew Thomas. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CAFMatchedTextViewController : UIViewController
@end
| //
// CAFMatchedTextViewController.h
// Curiosity
//
// Created by Matthew Thomas on 8/26/12.
// Copyright (c) 2012 Matthew Thomas. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CAFMatchedTextViewController : UIViewController
@property (copy, nonatomic) NSString *regexString;
@property (copy, nonatomic) NSString *inputText;
@end
|
Add C implementation of concomp with fork | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#define BUF_SIZE 1024
#define CHILD 0
typedef struct {
char filename[BUF_SIZE];
off_t size;
} SizeMessage;
int main(int argc, const char ** argv) {
/* fork process id */
pid_t pid = -1;
/* Start index at 1 to ignore prog name in args */
int startIndex = 1;
int filesCount = argc - 1;
/* Pipe to communicate sizes from the children to the parent */
int pipe_fd[2];
pipe(pipe_fd);
/* Fork for each file given as an argument */
int childIndex = 0;
for(int i = startIndex; i < argc; i++) {
if((pid = fork()) == -1) {
perror("fork");
exit(EXIT_FAILURE);
}
if(pid == 0) {
/* Child will process current index */
childIndex = i;
break;
}
}
if(pid == CHILD) {
/* Child process closes up input side of pipe */
close(pipe_fd[0]);
SizeMessage msg;
strcpy(msg.filename, argv[childIndex]);
/* Get file size */
struct stat st;
if(stat(msg.filename, &st) == -1) {
perror("stat");
msg.size = -1;
} else {
msg.size = st.st_size;
}
/* Send size message through the output side of pipe */
write(pipe_fd[1], &msg, sizeof(msg));
exit(EXIT_SUCCESS);
} else {
/* Parent process closes up output side of pipe */
close(pipe_fd[1]);
/* Read in size messages from the pipe */
SizeMessage biggest = {0};
SizeMessage evens[filesCount];
int countEvens = 0;
for(int i = startIndex; i < argc; i++) {
SizeMessage msg;
if(read(pipe_fd[0], &msg, sizeof(msg)) == -1) {
perror("read");
}
if(msg.size > biggest.size) {
biggest = msg;
countEvens = 0;
}
if(msg.size == biggest.size) {
evens[countEvens++] = msg;
}
}
/* Display result */
if(countEvens == filesCount) {
printf("All files are even\n");
} else if(countEvens > 1) {
printf("Biggest files are:");
for(int i = 0; i < countEvens; i++) {
printf(" %s", evens[i].filename);
}
printf("\n");
} else {
printf("Biggest file is: %s\n", biggest.filename);
}
}
return EXIT_SUCCESS;
}
| |
Add header file for generic link address | /*
* Copyright (c) 2016 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Public API for network link address
*/
#ifndef __NET_LINKADDR_H__
#define __NET_LINKADDR_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Hardware link address structure
*
* Used to hold the link address information
*/
struct net_linkaddr {
/** The array of byte representing the address */
uint8_t *addr;
/** Length of that address array */
uint8_t len;
};
#ifdef __cplusplus
}
#endif
#endif /* __NET_LINKADDR_H__ */
| |
Create a Linked list from user input string | /* last written on 13/08/2017 22:06:14
owner ise2017001
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
int data;
struct node *next;
};
struct node *createNode (int value) {
struct node *newNode = (struct node *) malloc (sizeof (struct node));
newNode -> data = value;
newNode -> next = NULL;
return newNode;
}
void insertNode (struct node **head_ref, struct node **tail_ref, int value) {
struct node *newNode = createNode (value);
if (*head_ref == NULL) {
*head_ref = newNode;
*tail_ref = newNode;
}
else {
(*tail_ref) -> next = newNode;
*tail_ref = newNode;
}
}
void printList (struct node *head) {
while (head != NULL) {
printf ("%d -> ", head->data);
head = head->next;
}
printf ("NULL\n");
}
void destroyList (struct node *head) {
struct node *nextNode = head;
while (head != NULL) {
nextNode = head -> next;
free (head);
head = nextNode;
}
printf("Killed off all her feelings\n" );
}
int main (int argc, char *argv[]) {
int value;
struct node *head = NULL, *tail = NULL;
char buffer[2048];
char *p = NULL;
fgets (buffer, 2048, stdin);
p = strtok (buffer, "NULL > | \n");
while (p != NULL) {
sscanf (p, "%d", &value);
insertNode (&head, &tail, value);
p = strtok (NULL, "NULL null | > \n");
}
printList (head);
destroyList (head);
head = NULL;
tail = NULL;
return 0;
}
| |
Add missing declaration to header. | /*
* Copyright (c) 2013 by Kyle Isom <kyle@tyrfingr.is>.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef __I2C_H__
#define __I2C_H__
void i2c_init();
int i2c_sendbyte(int, unsigned int, unsigned int, char);
#endif
| /*
* Copyright (c) 2013 by Kyle Isom <kyle@tyrfingr.is>.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef __I2C_H__
#define __I2C_H__
void i2c_init();
int i2c_sendbyte(int, unsigned int, unsigned int, char);
int i2c_readbyte(int, unsigned int, unsigned int, char *);
#endif
|
Make objectModel protocol method static. |
#pragma mark Class Interface
@interface AFObjectModel : NSObject
#pragma mark - Properties
@property (nonatomic, strong, readonly) NSArray *key;
@property (nonatomic, strong, readonly) NSDictionary *mappings;
@property (nonatomic, strong, readonly) NSDictionary *transformers;
#pragma mark - Constructors
- (id)initWithKey: (NSArray *)key
mappings: (NSDictionary *)mappings
transformers: (NSDictionary *)transformers;
#pragma mark - Static Methods
+ (id)objectModelWithKey: (NSArray *)key
mappings: (NSDictionary *)mappings
transformers: (NSDictionary *)transformers;
+ (id)objectModelWithMappings: (NSDictionary *)mappings
transformers: (NSDictionary *)transformers;
+ (id)objectModelWithKey: (NSArray *)key
mappings: (NSDictionary *)mappings;
+ (id)objectModelWithMappings: (NSDictionary *)mappings;
+ (id)objectModelForClass: (Class)myClass;
@end
#pragma mark AFObjectModel Protocol
@protocol AFObjectModel<NSObject>
@required
- (AFObjectModel *)objectModel;
@optional
+ (void)update: (id)value
values: (NSDictionary *)values
provider: (id)provider;
@end |
#pragma mark Class Interface
@interface AFObjectModel : NSObject
#pragma mark - Properties
@property (nonatomic, strong, readonly) NSArray *key;
@property (nonatomic, strong, readonly) NSDictionary *mappings;
@property (nonatomic, strong, readonly) NSDictionary *transformers;
#pragma mark - Constructors
- (id)initWithKey: (NSArray *)key
mappings: (NSDictionary *)mappings
transformers: (NSDictionary *)transformers;
#pragma mark - Static Methods
+ (id)objectModelWithKey: (NSArray *)key
mappings: (NSDictionary *)mappings
transformers: (NSDictionary *)transformers;
+ (id)objectModelWithMappings: (NSDictionary *)mappings
transformers: (NSDictionary *)transformers;
+ (id)objectModelWithKey: (NSArray *)key
mappings: (NSDictionary *)mappings;
+ (id)objectModelWithMappings: (NSDictionary *)mappings;
+ (id)objectModelForClass: (Class)myClass;
@end
#pragma mark AFObjectModel Protocol
@protocol AFObjectModel<NSObject>
@required
+ (AFObjectModel *)objectModel;
@optional
+ (void)update: (id)value
values: (NSDictionary *)values
provider: (id)provider;
@end |
Add one example file for func forward declarations. | /*
Func call with various arg numbers.
And func forward declarations.
*/
void aX(void);
int a1(int param1);
int a2(int param1, param2);
void a3();
void a3(void);
int f(int arg1, char arg2)
{
a1(arg1);
a2(arg1, arg2);
a3();
}
| |
Add a new widget template for all the toolbar buttons in Lumina - still needs testing | //===========================================
// Lumina-DE source code
// Copyright (c) 2013, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
#ifndef _LUMINA_TOOLBAR_WIDGET_H
#define _LUMINA_TOOLBAR_WIDGET_H
#include <QAbstractButton>
#include <QTimer>
#include <QMenu>
#include <QMouseEvent>
#include <QEvent>
class LTBWidget : public QAbstractButton{
Q_OBJECT
public:
enum STATES {IDLE, ACTIVE, INACTIVE, NOTIFICATION};
LTBWidget(QWidget* parent) : QAbstractButton(parent){
timedown = new QTimer(this);
timedown->setSingleShot(true);
connect(timedown, SIGNAL(timeout()), this, SIGNAL(longClicked()) );
}
~LTBWidget(){
delete timedown;
}
void setMenu(QMenu *addmenu){ menu = addmenu; }
void setLongClickTime( int ms ){ timedown->setInterval(ms); }
void setState(STATES newstate){
if(newstate == NOTIFICATION){ pstate = cstate; }
else{ pstate = IDLE; }
cstate = newstate;
updateBackground();
}
public slots:
void showMenu(){ menu->popup( this->pos()); }
private:
QTimer *timedown;
QMenu *menu;
STATES cstate, pstate;
void updateBackground(){
if(cstate == IDLE){ this->setBackgroundRole(QPalette::NoRole); }
else if(cstate == ACTIVE){ this->setBackgroundRole(QPalette::Button); }
else if(cstate == INACTIVE){ this->setBackgroundRole(QPalette::Dark); }
else if(cstate == NOTIFICATION){ this->setBackroundRole(QPalette::Highlight); }
}
signals:
void longClicked();
protected:
void mousePressEvent(QMouseEvent *event){
timedown->start();
event->accept();
}
void mouseReleaseEvent(QMouseEvent *event){
if(timedown->isActive()){ emit clicked(); }
timedown->stop();
event->accept();
}
void enterEvent(QEvent *event){
if(cstate == NOTIFICATION){ cstate = pstate; } //return to non-notification state
if(cstate == IDLE){ this->setBackgroundRole(QPalette::Light); }
event->accept();
}
void exitEvent(QEvent *event){
updateBackground();
event->accept();
}
};
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.