Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Fix clang's stupid warning to work around a bug in OS X headers... | #ifndef _OBJC_MESSAGE_H_
#define _OBJC_MESSAGE_H_
#if defined(__x86_64) || defined(__i386) || defined(__arm__) || \
defined(__mips_n64) || defined(__mips_n32)
/**
* Standard message sending function. This function must be cast to the
* correct types for the function before use. The first argument is the
* receiver and the second the selector.
*
* Note that this function is not available on all architectures. For a more
* portable solution to sending arbitrary messages, consider using
* objc_msg_lookup_sender() and then calling the returned IMP directly.
*
* This version of the function is used for all messages that return either an
* integer, a pointer, or a small structure value that is returned in
* registers. Be aware that calling conventions differ between operating
* systems even within the same architecture, so take great care if using this
* function for small (two integer) structures.
*/
id objc_msgSend(id self, SEL _cmd, ...);
/**
* Standard message sending function. This function must be cast to the
* correct types for the function before use. The first argument is the
* receiver and the second the selector.
*
* Note that this function is not available on all architectures. For a more
* portable solution to sending arbitrary messages, consider using
* objc_msg_lookup_sender() and then calling the returned IMP directly.
*
* This version of the function is used for all messages that return a
* structure that is not returned in registers. Be aware that calling
* conventions differ between operating systems even within the same
* architecture, so take great care if using this function for small (two
* integer) structures.
*/
#ifdef __cplusplus
id objc_msgSend_stret(id self, SEL _cmd, ...);
#else
void objc_msgSend_stret(id self, SEL _cmd, ...);
#endif
/**
* Standard message sending function. This function must be cast to the
* correct types for the function before use. The first argument is the
* receiver and the second the selector.
*
* Note that this function is not available on all architectures. For a more
* portable solution to sending arbitrary messages, consider using
* objc_msg_lookup_sender() and then calling the returned IMP directly.
*
* This version of the function is used for all messages that return floating
* point values.
*/
long double objc_msgSend_fpret(id self, SEL _cmd, ...);
#endif
#endif //_OBJC_MESSAGE_H_
| |
Fix compilation against wlroots without X11 backend | #include <wlr/backend/multi.h>
#include <wlr/backend/wayland.h>
#include <wlr/backend/x11.h>
#include "sway/commands.h"
#include "sway/server.h"
#include "log.h"
static void create_output(struct wlr_backend *backend, void *data) {
bool *done = data;
if (*done) {
return;
}
if (wlr_backend_is_wl(backend)) {
wlr_wl_output_create(backend);
*done = true;
} else if (wlr_backend_is_x11(backend)) {
wlr_x11_output_create(backend);
*done = true;
}
}
/**
* This command is intended for developer use only.
*/
struct cmd_results *cmd_create_output(int argc, char **argv) {
sway_assert(wlr_backend_is_multi(server.backend),
"Expected a multi backend");
bool done = false;
wlr_multi_for_each_backend(server.backend, create_output, &done);
if (!done) {
return cmd_results_new(CMD_INVALID, "create_output",
"Can only create outputs for Wayland or X11 backends");
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
| #include <wlr/config.h>
#include <wlr/backend/multi.h>
#include <wlr/backend/wayland.h>
#ifdef WLR_HAS_X11_BACKEND
#include <wlr/backend/x11.h>
#endif
#include "sway/commands.h"
#include "sway/server.h"
#include "log.h"
static void create_output(struct wlr_backend *backend, void *data) {
bool *done = data;
if (*done) {
return;
}
if (wlr_backend_is_wl(backend)) {
wlr_wl_output_create(backend);
*done = true;
}
#ifdef WLR_HAS_X11_BACKEND
else if (wlr_backend_is_x11(backend)) {
wlr_x11_output_create(backend);
*done = true;
}
#endif
}
/**
* This command is intended for developer use only.
*/
struct cmd_results *cmd_create_output(int argc, char **argv) {
sway_assert(wlr_backend_is_multi(server.backend),
"Expected a multi backend");
bool done = false;
wlr_multi_for_each_backend(server.backend, create_output, &done);
if (!done) {
return cmd_results_new(CMD_INVALID, "create_output",
"Can only create outputs for Wayland or X11 backends");
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
|
Add systemFile declaration to helper library | #ifndef HELPER_H
#define HELPER_H
/*Helper function for calculating ABSOLUTE maximum of two floats
Will return maximum absolute value (ignores sign) */
float helpFindMaxAbsFloat(float a, float b) {
float aAbs = abs(a);
float bAbs = abs(b);
if (aAbs > bAbs) {
return aAbs;
} else {
return bAbs;
}
}
//Helper function for calculating ABSOLUTE minimum of two floats
//Will return minimum absolute value (ignores sign)
float helpFindMinAbsFloat(float a, float b) {
float aAbs = abs(a);
float bAbs = abs(b);
if (aAbs < bAbs) {
return aAbs;
} else {
return bAbs;
}
}
//Helper function for calculating contraints of a float
float constrain(float x, float lowerBound, float upperBound){
if(x<lowerBound){
return lowerBound;
}else if(x>upperBound){
return upperBound;
}else{
return x;
}
}
#endif
| #ifndef HELPER_H
#define HELPER_H
#pragma systemFile
/*Helper function for calculating ABSOLUTE maximum of two floats
Will return maximum absolute value (ignores sign) */
float helpFindMaxAbsFloat(float a, float b) {
float aAbs = abs(a);
float bAbs = abs(b);
if (aAbs > bAbs) {
return aAbs;
} else {
return bAbs;
}
}
//Helper function for calculating ABSOLUTE minimum of two floats
//Will return minimum absolute value (ignores sign)
float helpFindMinAbsFloat(float a, float b) {
float aAbs = abs(a);
float bAbs = abs(b);
if (aAbs < bAbs) {
return aAbs;
} else {
return bAbs;
}
}
//Helper function for calculating contraints of a float
float constrain(float x, float lowerBound, float upperBound){
if(x<lowerBound){
return lowerBound;
}else if(x>upperBound){
return upperBound;
}else{
return x;
}
}
#endif
|
Remove over specific header file. | /** @file
The file contain all library function for Ifr Operations.
Copyright (c) 2007 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _IFRLIBRARY_INTERNAL_H_
#define _IFRLIBRARY_INTERNAL_H_
#include <Uefi.h>
#include <Guid/GlobalVariable.h>
#include <Protocol/DevicePath.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiString.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/IfrSupportLib.h>
#include <Library/PcdLib.h>
#include <MdeModuleHii.h>
extern EFI_GUID mIfrVendorGuid;
#endif
| /** @file
The file contain all library function for Ifr Operations.
Copyright (c) 2007 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _IFRLIBRARY_INTERNAL_H_
#define _IFRLIBRARY_INTERNAL_H_
#include <Uefi.h>
#include <Protocol/DevicePath.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiString.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/IfrSupportLib.h>
#include <Library/PcdLib.h>
#include <MdeModuleHii.h>
extern EFI_GUID mIfrVendorGuid;
#endif
|
Fix error for short names | // Start of tuning.h.
static char* load_tuning_file(const char *fname,
void *cfg,
int (*set_size)(void*, const char*, size_t)) {
const int max_line_len = 1024;
char* line = (char*) malloc(max_line_len);
FILE *f = fopen(fname, "r");
if (f == NULL) {
snprintf(line, max_line_len, "Cannot open file: %s", strerror(errno));
return line;
}
int lineno = 0;
while (fgets(line, max_line_len, f) != NULL) {
lineno++;
char *eql = strstr(line, "=");
if (eql) {
*eql = 0;
int value = atoi(eql+1);
if (set_size(cfg, line, value) != 0) {
strncpy(eql+1, line, max_line_len-strlen(line)-1);
snprintf(line, max_line_len, "Unknown name '%s' on line %d.", eql+1, lineno);
return line;
}
} else {
snprintf(line, max_line_len, "Invalid line %d (must be of form 'name=int').",
lineno);
return line;
}
}
free(line);
return NULL;
}
// End of tuning.h.
| // Start of tuning.h.
static char* load_tuning_file(const char *fname,
void *cfg,
int (*set_size)(void*, const char*, size_t)) {
const int max_line_len = 1024;
char* line = (char*) malloc(max_line_len);
FILE *f = fopen(fname, "r");
if (f == NULL) {
snprintf(line, max_line_len, "Cannot open file: %s", strerror(errno));
return line;
}
int lineno = 0;
while (fgets(line, max_line_len, f) != NULL) {
lineno++;
char *eql = strstr(line, "=");
if (eql) {
*eql = 0;
int value = atoi(eql+1);
if (set_size(cfg, line, value) != 0) {
char* err = (char*) malloc(max_line_len + 50);
snprintf(err, max_line_len + 50, "Unknown name '%s' on line %d.", line, lineno);
free(line);
return err;
}
} else {
snprintf(line, max_line_len, "Invalid line %d (must be of form 'name=int').",
lineno);
return line;
}
}
free(line);
return NULL;
}
// End of tuning.h.
|
Remove "static inline" from C code. | // +build cortexm3 cortexm4 cortexm4f
static inline
uint bits$leadingZeros32(uint32 u) {
uint n;
asm volatile ("clz %0, %1" : "=r" (n) : "r" (u));
return n;
}
static inline
uint bits$leadingZerosPtr(uintptr u) {
uint n;
asm volatile ("clz %0, %1" : "=r" (n) : "r" (u));
return n;
}
static inline
uint bits$leadingZeros64(uint64 u) {
uint n;
asm volatile (
"clz %0, %R1\n\t"
"cmp %0, 32\n\t"
"itt eq\n\t"
"clzeq %0, %Q1\n\t"
"addeq %0, 32\n\t"
: "=&r" (n)
: "r" (u)
: "cc"
);
return n;
} | // +build cortexm3 cortexm4 cortexm4f
uint
bits$leadingZeros32(uint32 u) {
uint n;
asm volatile ("clz %0, %1":"=r" (n):"r"(u));
return n;
}
uint
bits$leadingZerosPtr(uintptr u) {
uint n;
asm volatile ("clz %0, %1":"=r" (n):"r"(u));
return n;
}
uint
bits$leadingZeros64(uint64 u) {
uint n;
asm volatile ("clz %0, %R1\n\t"
"cmp %0, 32\n\t"
"itt eq\n\t"
"clzeq %0, %Q1\n\t"
"addeq %0, 32\n\t"
:"=&r" (n)
:"r"(u)
:"cc");
return n;
}
|
Use memset instead of bzero | /* Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <string.h>
libc_hidden_proto(bzero)
/* Clear memory. Can't alias to bzero because it's not defined in the
same translation unit. */
void
__aeabi_memclr (void *dest, size_t n)
{
bzero (dest, n);
}
/* Versions of the above which may assume memory alignment. */
strong_alias (__aeabi_memclr, __aeabi_memclr4)
strong_alias (__aeabi_memclr, __aeabi_memclr8)
| /* Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <string.h>
libc_hidden_proto(memset)
/* Clear memory. Can't alias to bzero because it's not defined in the
same translation unit. */
void
__aeabi_memclr (void *dest, size_t n)
{
memset (dest, 0, n);
}
/* Versions of the above which may assume memory alignment. */
strong_alias (__aeabi_memclr, __aeabi_memclr4)
strong_alias (__aeabi_memclr, __aeabi_memclr8)
|
Add track_* flags to analysis options to let caller strip it down. | #ifndef CC_ANALYSIS_ANALYSIS_OPTIONS_H_
#define CC_ANALYSIS_ANALYSIS_OPTIONS_H_
#include <cstddef>
struct AnalysisOptions {
AnalysisOptions() :
destutter_max_consecutive(3),
replace_html_entities(true)
{}
// Preprocessing.
size_t destutter_max_consecutive;
// Tokenization.
bool replace_html_entities;
};
#endif // CC_ANALYSIS_ANALYSIS_OPTIONS_H_
| #ifndef CC_ANALYSIS_ANALYSIS_OPTIONS_H_
#define CC_ANALYSIS_ANALYSIS_OPTIONS_H_
#include <cstddef>
struct AnalysisOptions {
AnalysisOptions() :
track_index_translation(true),
destutter_max_consecutive(3),
track_chr2drop(true),
replace_html_entities(true)
{}
// General flags:
// * Map tokens to spans in the original text.
bool track_index_translations;
// Preprocessing flags:
// * Maximum number of consecutive code points before we start dropping them.
// * Whether to keep track of code point drop counts from destuttering.
size_t destutter_max_consecutive;
bool track_chr2drop;
// Tokenization flags:
// * Whether to replace HTML entities in the text with their Unicode
// equivalents.
bool replace_html_entities;
};
#endif // CC_ANALYSIS_ANALYSIS_OPTIONS_H_
|
Fix iconv warnings on MinGW | #include <iconv.h>
#ifdef WIN32
typedef const char ** readstat_iconv_inbuf_t;
#else
typedef char ** readstat_iconv_inbuf_t;
#endif
typedef struct readstat_charset_entry_s {
int code;
char name[32];
} readstat_charset_entry_t;
| #include <iconv.h>
#ifdef WINICONV_CONST
typedef const char ** readstat_iconv_inbuf_t;
#else
typedef char ** readstat_iconv_inbuf_t;
#endif
typedef struct readstat_charset_entry_s {
int code;
char name[32];
} readstat_charset_entry_t;
|
Add hiredis libuv adapter support. | // Author: Hong Jen-Yee (PCMan) (pcman.hong@appier.com)
#ifndef __libredisCluster_adapters_libuvadapter_h__
#define __libredisCluster_adapters_libuvadapter_h__
#include "adapter.h" // for Adapter
extern "C"
{
#include <hiredis/adapters/libuv.h> // for redisLibeventAttach()
}
namespace RedisCluster
{
// Wrap hiredis libuv adapter.
class LibUvAdapter : public Adapter
{
public:
explicit LibUvAdapter( uv_loop_t* loop = uv_default_loop() ) : loop_( loop ) {}
virtual ~LibUvAdapter() {}
public:
virtual int attachContext( redisAsyncContext &ac ) override
{
return redisLibuvAttach( &ac, loop_ );
}
private:
uv_loop_t* loop_;
}; // class Adapter
} // namespace RedisCluster
#endif // __libredisCluster_adapters_libuvadapter_h__
| |
Add support for fast peripheral clock in mcux sim driver | /*
* Copyright (c) 2017, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_
#define KINETIS_SIM_CORESYS_CLK 0
#define KINETIS_SIM_PLATFORM_CLK 1
#define KINETIS_SIM_BUS_CLK 2
#define KINETIS_SIM_LPO_CLK 19
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_ */
| /*
* Copyright (c) 2017, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_
#define KINETIS_SIM_CORESYS_CLK 0
#define KINETIS_SIM_PLATFORM_CLK 1
#define KINETIS_SIM_BUS_CLK 2
#define KINETIS_SIM_FAST_PERIPHERAL_CLK 5
#define KINETIS_SIM_LPO_CLK 19
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_ */
|
Fix HOST_NAME_MAX not found error on Mac OSX. POSIX compliance pls. | #ifndef _WISH_PROMPT
#define _WISH_PROMPT
/*
* The wish shell prompt has its own format characters, much like how bash,
* zsh, fish, and ksh all have their own formatting characters.
*
* %u - The username of the current user
* %h - The hostname
* %d~n - The top n levels of the working directory. If n is not provided
* then the entire working directory is displayed. (i.e. %d, %d~2)
* This assumes that 0 <= n <= 9.
* %t - The time in 24 hour format
* %T - The time in 12 hour (AM/PM) format
* %% - The percent symbol
*
*
* NOTES:
*
* If there is a % at the end of the prompt, it will be implied that it is %%.
* An unrecognized formatting character will be interpretted literally.
*/
char *PROMPT;
char *get_format_substitution(char *prompt_var);
void load_prompt_defaults();
void load_prompt_config();
void prompt(char *current_working_dir);
#endif
| #ifndef _WISH_PROMPT
#define _WISH_PROMPT
/*
* The wish shell prompt has its own format characters, much like how bash,
* zsh, fish, and ksh all have their own formatting characters.
*
* %u - The username of the current user
* %h - The hostname
* %d~n - The top n levels of the working directory. If n is not provided
* then the entire working directory is displayed. (i.e. %d, %d~2)
* This assumes that 0 <= n <= 9.
* %t - The time in 24 hour format
* %T - The time in 12 hour (AM/PM) format
* %% - The percent symbol
*
*
* NOTES:
*
* If there is a % at the end of the prompt, it will be implied that it is %%.
* An unrecognized formatting character will be interpretted literally.
*/
char *PROMPT;
char *get_format_substitution(char *prompt_var);
void load_prompt_defaults();
void load_prompt_config();
void prompt(char *current_working_dir);
#endif
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif
|
Remove functions that are private. | #ifndef HAL2_H
#define HAL2_H
// Mechanical constants
extern int const MAIN_MOTOR_PWM_TOP = 255;
extern int const MAIN_MOTOR_BRAKE_SPEED = 120;
extern int const MAIN_MOTOR_MIN_SPEED = 150;
extern int const MAIN_MOTOR_MED_SPEED = 254;
extern int const MAIN_MOTOR_MAX_SPEED = 255;
extern int const MAGNET_OPEN_WAIT = 5; // 10ths of a second
void init(void);
void main_motor_stop();
void main_motor_cw_open(uint8_t speed);
void main_motor_ccw_close(uint8_t speed);
void set_main_motor_speed(int speed);
int get_main_motor_speed();
void aux_motor_stop();
void aux_motor_cw_close();
void aux_motor_ccw_open();
void magnet_off();
void magnet_on();
bool door_nearly_open();
bool door_fully_open();
bool door_fully_closed();
bool sensor_proximity();
bool button_openclose();
bool button_stop();
bool main_encoder();
bool aux_outdoor_limit();
bool aux_indoor_limit();
bool door_nearly_closed();
bool aux_encoder();
#endif
| #ifndef HAL2_H
#define HAL2_H
// Mechanical constants
extern int const MAIN_MOTOR_PWM_TOP = 255;
extern int const MAIN_MOTOR_BRAKE_SPEED = 120;
extern int const MAIN_MOTOR_MIN_SPEED = 150;
extern int const MAIN_MOTOR_MED_SPEED = 254;
extern int const MAIN_MOTOR_MAX_SPEED = 255;
extern int const MAGNET_OPEN_WAIT = 5; // 10ths of a second
void init(void);
void main_motor_stop();
void main_motor_cw_open(uint8_t speed);
void main_motor_ccw_close(uint8_t speed);
void aux_motor_stop();
void aux_motor_cw_close();
void aux_motor_ccw_open();
void magnet_off();
void magnet_on();
bool door_nearly_open();
bool door_fully_open();
bool door_fully_closed();
bool sensor_proximity();
bool button_openclose();
bool button_stop();
bool main_encoder();
bool aux_outdoor_limit();
bool aux_indoor_limit();
bool door_nearly_closed();
bool aux_encoder();
#endif
|
Tweak for benchmark. fib(0-91) 1987925/second | #include <stdio.h>
#include <assert.h>
#include "api.h"
#include "lib/math.c"
#include "lib/test.c"
static jack_state_t* state;
static intptr_t jack_fib(intptr_t n) {
jack_new_integer(state, n);
jack_function_call(state, 1, 1);
return jack_get_integer(state, -1);
}
int main() {
for (int j = 0; j < 0x1; ++j) {
state = jack_new_state(15);
jack_call(state, jack_math, 0);
jack_map_get_symbol(state, -1, "fib");
jack_new_list(state);
// 1 - fib
// 2 - list
for (intptr_t i = 0; i <= 91; ++i) {
printf("fib(%ld) = %ld\n", i, jack_fib(i));
jack_list_push(state, 2);
}
jack_dump_state(state);
jack_free_state(state);
}
return 0;
}
| #include <stdio.h>
#include <assert.h>
#include "api.h"
#include "lib/math.c"
#include "lib/test.c"
static jack_state_t* state;
static intptr_t jack_fib(intptr_t n) {
jack_new_integer(state, n);
jack_function_call(state, 1, 1);
return jack_get_integer(state, -1);
}
int main() {
state = jack_new_state(20);
jack_call(state, jack_math, 0);
jack_map_get_symbol(state, -1, "fib");
jack_new_list(state);
// 1 - fib
// 2 - list
for (int j = 0; j < 0x10000; ++j) {
printf("Generation %d\n", j);
for (intptr_t i = 0; i <= 91; ++i) {
jack_fib(i);
// printf("fib(%ld) = %ld\n", i, jack_fib(i));
jack_pop(state);
// jack_list_push(state, 2);
}
}
jack_dump_state(state);
jack_free_state(state);
return 0;
}
|
Fix gyro measurement noise variance | #include <systemlib/param/param.h>
/*PARAM_DEFINE_FLOAT(NAME,0.0f);*/
PARAM_DEFINE_FLOAT(KF_V_GYRO, 1.0f);
PARAM_DEFINE_FLOAT(KF_V_ACCEL, 1.0f);
PARAM_DEFINE_FLOAT(KF_R_MAG, 1.0f);
PARAM_DEFINE_FLOAT(KF_R_GPS_VEL, 1.0f);
PARAM_DEFINE_FLOAT(KF_R_GPS_POS, 5.0f);
PARAM_DEFINE_FLOAT(KF_R_GPS_ALT, 5.0f);
PARAM_DEFINE_FLOAT(KF_R_PRESS_ALT, 0.1f);
PARAM_DEFINE_FLOAT(KF_R_ACCEL, 1.0f);
PARAM_DEFINE_FLOAT(KF_FAULT_POS, 10.0f);
PARAM_DEFINE_FLOAT(KF_FAULT_ATT, 10.0f);
PARAM_DEFINE_FLOAT(KF_ENV_G, 9.765f);
PARAM_DEFINE_FLOAT(KF_ENV_MAG_DIP, 60.0f);
PARAM_DEFINE_FLOAT(KF_ENV_MAG_DEC, 0.0f);
| #include <systemlib/param/param.h>
/*PARAM_DEFINE_FLOAT(NAME,0.0f);*/
PARAM_DEFINE_FLOAT(KF_V_GYRO, 0.008f);
PARAM_DEFINE_FLOAT(KF_V_ACCEL, 1.0f);
PARAM_DEFINE_FLOAT(KF_R_MAG, 1.0f);
PARAM_DEFINE_FLOAT(KF_R_GPS_VEL, 1.0f);
PARAM_DEFINE_FLOAT(KF_R_GPS_POS, 5.0f);
PARAM_DEFINE_FLOAT(KF_R_GPS_ALT, 5.0f);
PARAM_DEFINE_FLOAT(KF_R_PRESS_ALT, 0.1f);
PARAM_DEFINE_FLOAT(KF_R_ACCEL, 1.0f);
PARAM_DEFINE_FLOAT(KF_FAULT_POS, 10.0f);
PARAM_DEFINE_FLOAT(KF_FAULT_ATT, 10.0f);
PARAM_DEFINE_FLOAT(KF_ENV_G, 9.765f);
PARAM_DEFINE_FLOAT(KF_ENV_MAG_DIP, 60.0f);
PARAM_DEFINE_FLOAT(KF_ENV_MAG_DEC, 0.0f);
|
Implement a simple ASCII text image dumper. | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <arpa/inet.h>
#include "idx.h"
int main(int argc, char **argv){
if(argc<2){
printf("Usage: \n");
printf("readlabels t10k-labels-idx1-ubyte \n");
exit(1);
}
char *slabelfname = argv[1];
IDX1_DATA idxdata;
if(!fread_idx1_file( slabelfname, &idxdata)){
printf("The datafile '%s' is not a valid IDX_1 file.\n", slabelfname);
exit(2);
}
//printf("Length: %d\n", idxdata.length);
int i;
for(i=0;i<idxdata.length;i++){
// printf("DATA[%05d] = %02d\n", i, idxdata.data[i]);
printf("%d\n", idxdata.data[i]);
}
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <arpa/inet.h>
#include "idx.h"
int main(int argc, char **argv){
if(argc<2){
printf("Usage: \n");
printf("readimages t10k-images-idx3-ubyte \n");
exit(1);
}
char *slabelfname = argv[1];
IDX3_DATA idxdata;
if(!fread_idx3_file( slabelfname, &idxdata)){
printf("The datafile '%s' is not a valid IDX3 file.\n", slabelfname);
exit(2);
}
//printf("Length: %d\n", idxdata.length);
int i;
int x;
int y;
int ibase;
int rbase;
unsigned char pxl;
for(i=0;i<idxdata.nimages;i++){
ibase = i * idxdata.nrows * idxdata.ncols;
printf("Image %05d ( %010d ):\n", i + 1, ibase);
for(y=0;y<idxdata.nrows;y++){
rbase = ibase + y*idxdata.ncols;
for(x=0;x<idxdata.ncols;x++){
// printf("DATA[%05d] = %02d\n", i, idxdata.data[i]);
pxl = idxdata.data[ rbase + x ];
if(pxl){
printf("%02X", pxl);
}else{
printf(" ");
}
}
printf("\n");
}
printf("========================================================\n");
}
return 0;
}
|
Make closure inclusion test visible (to be used from the priced zone part). | #ifndef UDBM_STUBS_H_
#define UDBM_STUBS_H_
#include <vector>
typedef std::vector<int> carray_t;
#define get_cvector(x) ((carray_t*)Data_custom_val(x))
#define get_dbm_ptr(x) static_cast<dbm_t*>(Data_custom_val(x))
#endif // UDBM_STUBS_H_
| #ifndef UDBM_STUBS_H_
#define UDBM_STUBS_H_
#include <vector>
typedef std::vector<int> carray_t;
#define get_cvector(x) ((carray_t*)Data_custom_val(x))
#define get_dbm_ptr(x) static_cast<dbm_t*>(Data_custom_val(x))
bool
dbm_closure_leq(const raw_t * const dr1, const raw_t * const dr2, cindex_t dim,
const std::vector<int> &lbounds, const std::vector<int> &ubounds);
#endif // UDBM_STUBS_H_
|
Add a generic driver model. | // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All right reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Radu Serban
// =============================================================================
//
//
// =============================================================================
#ifndef GENERIC_FUNCDRIVER_H
#define GENERIC_FUNCDRIVER_H
#include "subsys/ChDriver.h"
class Generic_FuncDriver : public chrono::ChDriver
{
public:
Generic_FuncDriver() {}
~Generic_FuncDriver() {}
virtual void Update(double time)
{
if (time < 0.5)
m_throttle = 0;
else if (time < 1.5)
m_throttle = 0.4 * (time - 0.5);
else
m_throttle = 0.4;
if (time < 4)
m_steering = 0;
else if (time < 6)
m_steering = 0.25 * (time - 4);
else if (time < 10)
m_steering = -0.25 * (time - 6) + 0.5;
else
m_steering = -0.5;
}
};
#endif
| |
Switch to runtime library choice instead of compile time. | #include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include "firebase.h"
#include "serial.h"
#include "gpio.h"
#define _USE_SERIAL_
#ifdef _USE_SERIAL_
void (*send_command)(bool, int) = send_command_serial;
void (*init_sender)() = init_sender_serial;
#else
void (*send_command)(bool, int) = send_command_gpio;
void (*init_sender)() = init_sender_gpio;
#endif
void parse_event_string(char* event) {
bool isOn = (strncmp(event, "on", 2) == 0);
send_command(isOn, event[strlen(event)-1] - '0');
}
int main(int argc, char *argv[]) {
init_sender();
if(argc > 1) {
printf("Commanding remote\n\n");
bool isOn = strcmp(argv[1], "on") == 0 ? true : false;
send_command(isOn, argv[2][0] - '0');
} else {
firebase_set_url("https://test.firebaseio.com/me.json");
firebase_set_callback("/event", parse_event_string);
sleep(10);
while (true) {
firebase_subscribe();
sleep(30);
}
}
return 0;
}
| #include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include "firebase.h"
#include "serial.h"
#include "gpio.h"
bool useSerial = true;
void init_sender() {
if (useSerial) {
init_sender_serial();
} else {
init_sender_gpio();
}
}
void send_command(bool isOn, int device) {
if (useSerial) {
send_command_serial(isOn, device);
} else {
send_command_gpio(isOn, device);
}
}
void parse_event_string(char* event) {
bool isOn = (strncmp(event, "on", 2) == 0);
send_command(isOn, event[strlen(event)-1] - '0');
}
int main(int argc, char *argv[]) {
init_sender();
if(argc > 1) {
printf("Commanding remote\n\n");
bool isOn = strcmp(argv[1], "on") == 0 ? true : false;
send_command(isOn, argv[2][0] - '0');
} else {
firebase_set_url("https://test.firebaseio.com/me.json");
firebase_set_callback("/event", parse_event_string);
sleep(10);
while (true) {
firebase_subscribe();
sleep(30);
}
}
return 0;
}
|
Update driver version to 5.02.00-k5 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k4"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k5"
|
Remove unused st_le*() and ld_le* functions | /*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _ASM_POWERPC_SWAB_H
#define _ASM_POWERPC_SWAB_H
#include <uapi/asm/swab.h>
static __inline__ __u16 ld_le16(const volatile __u16 *addr)
{
__u16 val;
__asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
return val;
}
static __inline__ void st_le16(volatile __u16 *addr, const __u16 val)
{
__asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
}
static __inline__ __u32 ld_le32(const volatile __u32 *addr)
{
__u32 val;
__asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
return val;
}
static __inline__ void st_le32(volatile __u32 *addr, const __u32 val)
{
__asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
}
#endif /* _ASM_POWERPC_SWAB_H */
| /*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _ASM_POWERPC_SWAB_H
#define _ASM_POWERPC_SWAB_H
#include <uapi/asm/swab.h>
#endif /* _ASM_POWERPC_SWAB_H */
|
Fix error result handling in os.rmdir() | /**
* \file os_rmdir.c
* \brief Remove a subdirectory.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include <stdlib.h>
#include "premake.h"
int os_rmdir(lua_State* L)
{
int z;
const char* path = luaL_checkstring(L, 1);
#if PLATFORM_WINDOWS
z = RemoveDirectory(path);
#else
z = rmdir(path);
#endif
if (!z)
{
lua_pushnil(L);
lua_pushfstring(L, "unable to remove directory '%s'", path);
return 2;
}
else
{
lua_pushboolean(L, 1);
return 1;
}
}
| /**
* \file os_rmdir.c
* \brief Remove a subdirectory.
* \author Copyright (c) 2002-2013 Jason Perkins and the Premake project
*/
#include <stdlib.h>
#include "premake.h"
int os_rmdir(lua_State* L)
{
int z;
const char* path = luaL_checkstring(L, 1);
#if PLATFORM_WINDOWS
z = RemoveDirectory(path);
#else
z = (0 == rmdir(path));
#endif
if (!z)
{
lua_pushnil(L);
lua_pushfstring(L, "unable to remove directory '%s'", path);
return 2;
}
else
{
lua_pushboolean(L, 1);
return 1;
}
}
|
Add a function return status enum | #ifndef SAXBOPHONE_RISKY_RISKY_H
#define SAXBOPHONE_RISKY_RISKY_H
#include <stdint.h>
#ifdef __cplusplus
extern "C"{
#endif
typedef struct version_t {
uint8_t major;
uint8_t minor;
uint8_t patch;
} version_t;
extern const version_t VERSION;
#ifdef __cplusplus
} // extern "C"
#endif
// end of header file
#endif
| #ifndef SAXBOPHONE_RISKY_RISKY_H
#define SAXBOPHONE_RISKY_RISKY_H
#include <stdint.h>
#ifdef __cplusplus
extern "C"{
#endif
// struct for representing version of RISKY
typedef struct version_t {
uint8_t major;
uint8_t minor;
uint8_t patch;
} version_t;
// enum for storing information about the error status of a function
typedef enum status_t {
UNKNOWN = 0,
MALLOC_REFUSED,
IMPOSSIBLE_CONDITION,
SUCCESS,
} status_t;
extern const version_t VERSION;
#ifdef __cplusplus
} // extern "C"
#endif
// end of header file
#endif
|
Add a missing 'nonatomic' keyword in a property declaration. | //
// KPTableSection.h
// KSPFetchedResultsController
//
// Created by Konstantin Pavlikhin on 05.09.14.
// Copyright (c) 2015 Konstantin Pavlikhin. All rights reserved.
//
#import <Foundation/Foundation.h>
// * * *.
@class NSManagedObject;
// * * *.
@interface KSPTableSection : NSObject
- (nullable instancetype) initWithSectionName: (nonnull NSObject*) sectionName nestedObjects: (nullable NSArray<NSManagedObject*>*) nestedObjects;
@property(readwrite, copy, nonatomic, nonnull) NSObject* sectionName;
// Collection KVO-compatible property.
@property(readonly, nullable) NSArray<__kindof NSManagedObject*>* nestedObjects;
- (void) insertObject: (nonnull NSManagedObject*) object inNestedObjectsAtIndex: (NSUInteger) index;
@end
| //
// KPTableSection.h
// KSPFetchedResultsController
//
// Created by Konstantin Pavlikhin on 05.09.14.
// Copyright (c) 2015 Konstantin Pavlikhin. All rights reserved.
//
#import <Foundation/Foundation.h>
// * * *.
@class NSManagedObject;
// * * *.
@interface KSPTableSection : NSObject
- (nullable instancetype) initWithSectionName: (nonnull NSObject*) sectionName nestedObjects: (nullable NSArray<NSManagedObject*>*) nestedObjects;
@property(readwrite, copy, nonatomic, nonnull) NSObject* sectionName;
// Collection KVO-compatible property.
@property(readonly, nonatomic, nullable) NSArray<__kindof NSManagedObject*>* nestedObjects;
- (void) insertObject: (nonnull NSManagedObject*) object inNestedObjectsAtIndex: (NSUInteger) index;
@end
|
Add Objective-C headers to umbrella header to make project compile | #import <Foundation/Foundation.h>
FOUNDATION_EXPORT double NimbleVersionNumber;
FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
| #import <Foundation/Foundation.h>
FOUNDATION_EXPORT double NimbleVersionNumber;
FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
#import "DSL.h"
#import "NMBExceptionCapture.h"
|
Remove unused declaration of BuildAppListModel() function. | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SHELL_EXAMPLE_FACTORY_H_
#define ASH_SHELL_EXAMPLE_FACTORY_H_
#pragma once
namespace app_list {
class AppListModel;
class AppListViewDelegate;
}
namespace views {
class View;
}
namespace ash {
namespace shell {
void CreatePointyBubble(views::View* anchor_view);
void CreateLockScreen();
// Creates a window showing samples of commonly used widgets.
void CreateWidgetsWindow();
void BuildAppListModel(app_list::AppListModel* model);
app_list::AppListViewDelegate* CreateAppListViewDelegate();
} // namespace shell
} // namespace ash
#endif // ASH_SHELL_EXAMPLE_FACTORY_H_
| // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SHELL_EXAMPLE_FACTORY_H_
#define ASH_SHELL_EXAMPLE_FACTORY_H_
#pragma once
namespace app_list {
class AppListViewDelegate;
}
namespace views {
class View;
}
namespace ash {
namespace shell {
void CreatePointyBubble(views::View* anchor_view);
void CreateLockScreen();
// Creates a window showing samples of commonly used widgets.
void CreateWidgetsWindow();
app_list::AppListViewDelegate* CreateAppListViewDelegate();
} // namespace shell
} // namespace ash
#endif // ASH_SHELL_EXAMPLE_FACTORY_H_
|
Make create_branch() return errors if the branch target is too large | /*
* Copyright 2008 Michael Ellerman, IBM Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/kernel.h>
#include <asm/code-patching.h>
void patch_instruction(unsigned int *addr, unsigned int instr)
{
*addr = instr;
asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (addr));
}
void patch_branch(unsigned int *addr, unsigned long target, int flags)
{
patch_instruction(addr, create_branch(addr, target, flags));
}
unsigned int create_branch(const unsigned int *addr,
unsigned long target, int flags)
{
unsigned int instruction;
if (! (flags & BRANCH_ABSOLUTE))
target = target - (unsigned long)addr;
/* Mask out the flags and target, so they don't step on each other. */
instruction = 0x48000000 | (flags & 0x3) | (target & 0x03FFFFFC);
return instruction;
}
| /*
* Copyright 2008 Michael Ellerman, IBM Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/kernel.h>
#include <asm/code-patching.h>
void patch_instruction(unsigned int *addr, unsigned int instr)
{
*addr = instr;
asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (addr));
}
void patch_branch(unsigned int *addr, unsigned long target, int flags)
{
patch_instruction(addr, create_branch(addr, target, flags));
}
unsigned int create_branch(const unsigned int *addr,
unsigned long target, int flags)
{
unsigned int instruction;
long offset;
offset = target;
if (! (flags & BRANCH_ABSOLUTE))
offset = offset - (unsigned long)addr;
/* Check we can represent the target in the instruction format */
if (offset < -0x2000000 || offset > 0x1fffffc || offset & 0x3)
return 0;
/* Mask out the flags and target, so they don't step on each other. */
instruction = 0x48000000 | (flags & 0x3) | (offset & 0x03FFFFFC);
return instruction;
}
|
Add asm/mtrr.h include for some builds | /*
* arch/x86_64/kernel/bugs.c
*
* Copyright (C) 1994 Linus Torvalds
* Copyright (C) 2000 SuSE
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/alternative.h>
#include <asm/processor.h>
void __init check_bugs(void)
{
identify_cpu(&boot_cpu_data);
mtrr_bp_init();
#if !defined(CONFIG_SMP)
printk("CPU: ");
print_cpu_info(&boot_cpu_data);
#endif
alternative_instructions();
}
| /*
* arch/x86_64/kernel/bugs.c
*
* Copyright (C) 1994 Linus Torvalds
* Copyright (C) 2000 SuSE
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/alternative.h>
#include <asm/processor.h>
#include <asm/mtrr.h>
void __init check_bugs(void)
{
identify_cpu(&boot_cpu_data);
mtrr_bp_init();
#if !defined(CONFIG_SMP)
printk("CPU: ");
print_cpu_info(&boot_cpu_data);
#endif
alternative_instructions();
}
|
Update driver version to 5.03.00-k8 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k7"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k8"
|
Bring in the TinyGettext header file. | /* Copyright (c) 2013 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Bring in the TinyGettext header file.
*/
#ifndef INCLUDED_TINYGETTEXT
#define INCLUDED_TINYGETTEXT
#if MSC_VERSION
# pragma warning(push)
# pragma warning(disable:4251) // "class X needs to have dll-interface to be used by clients of class Y"
# pragma warning(disable:4800) // "forcing value to bool 'true' or 'false' (performance warning)"
#endif
#include <tinygettext/tinygettext.hpp>
#include <tinygettext/po_parser.hpp>
#include <tinygettext/log.hpp>
#if MSC_VERSION
# pragma warning(pop)
#endif
#endif // INCLUDED_TINYGETTEXT
| |
Fix number of hidden rows in Neurons struct | #include <stdio.h>
#define INPUTS 3
#define HIDDEN 5
#define OUTPUTS 2
#define ROWS 5
typedef struct {
double input[HIDDEN][INPUTS];
double hidden[ROWS - 3][HIDDEN][HIDDEN];
double output[OUTPUTS][HIDDEN];
} Links;
typedef struct {
int input[INPUTS];
int hidden[ROWS - 3][HIDDEN];
int output[OUTPUTS];
} Neurons;
typedef struct {
Links weights;
Neurons values;
} ANN;
int main(void)
{
return 0;
}
| #include <stdio.h>
#define INPUTS 3
#define HIDDEN 5
#define OUTPUTS 2
#define ROWS 5
typedef struct {
double input[HIDDEN][INPUTS];
double hidden[ROWS - 3][HIDDEN][HIDDEN];
double output[OUTPUTS][HIDDEN];
} Links;
typedef struct {
int input[INPUTS];
int hidden[ROWS - 2][HIDDEN];
int output[OUTPUTS];
} Neurons;
typedef struct {
Links weights;
Neurons values;
} ANN;
int main(void)
{
return 0;
}
|
Make emit explicit inherit for now | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2013 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kotaka/log.h>
#include <kotaka/paths.h>
#include <text/paths.h>
#include <thing/paths.h>
#include <type.h>
inherit "emit";
| /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2013 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kotaka/log.h>
#include <kotaka/paths.h>
#include <text/paths.h>
#include <thing/paths.h>
#include <type.h>
|
Remove unused method from header. | //
// LGHTTPRequest.h
// AutoPkgr
//
// Created by Eldon Ahrold on 8/9/14.
// Copyright 2014-2015 The Linde Group, 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.
//
#import <Foundation/Foundation.h>
@class LGHTTPCredential;
@interface LGHTTPRequest : NSObject
- (void)retrieveDistributionPoints:(LGHTTPCredential *)credential
reply:(void (^)(NSDictionary *distributionPoints, NSError *error))reply;
- (void)retrieveDistributionPoints:(LGHTTPCredential *)credential
redirect:(void (^)(NSString *redirect))redirect
reply:(void (^)(NSDictionary *distributionPoints, NSError *error))reply;
- (void)retrieveDistributionPoints2:(LGHTTPCredential *)credential
reply:(void (^)(NSDictionary *distributionPoints, NSError *error))reply;
@end
| //
// LGHTTPRequest.h
// AutoPkgr
//
// Created by Eldon Ahrold on 8/9/14.
// Copyright 2014-2015 The Linde Group, 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.
//
#import <Foundation/Foundation.h>
@class LGHTTPCredential;
@interface LGHTTPRequest : NSObject
- (void)retrieveDistributionPoints:(LGHTTPCredential *)credential
reply:(void (^)(NSDictionary *distributionPoints, NSError *error))reply;
- (void)retrieveDistributionPoints2:(LGHTTPCredential *)credential
reply:(void (^)(NSDictionary *distributionPoints, NSError *error))reply;
@end
|
Fix stub message having a wrong name | /* Swfdec
* Copyright (C) 2007 Pekka Lampila <pekka.lampila@iki.fi>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "swfdec_as_internal.h"
#include "swfdec_debug.h"
SWFDEC_AS_NATIVE (2205, 0, swfdec_file_reference_list_browse)
void
swfdec_file_reference_list_browse (SwfdecAsContext *cx, SwfdecAsObject *object,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SWFDEC_STUB ("FileReference.browse");
}
| /* Swfdec
* Copyright (C) 2007 Pekka Lampila <pekka.lampila@iki.fi>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "swfdec_as_internal.h"
#include "swfdec_debug.h"
SWFDEC_AS_NATIVE (2205, 0, swfdec_file_reference_list_browse)
void
swfdec_file_reference_list_browse (SwfdecAsContext *cx, SwfdecAsObject *object,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SWFDEC_STUB ("FileReferenceList.browse");
}
|
Fix declarations for file-by-file compile. | /*
* tré – Copyright (c) 2005–2007,2009,2012 Sven Michael Klose <pixel@copei.de>
*/
#ifndef TRE_APPLY_H
#define TRE_APPLY_H
extern treptr function_arguments (treptr);
extern treptr trefuncall (treptr func, treptr args);
extern treptr trebuiltin_call_compiled (void * fun, treptr args);
extern bool trebuiltin_is_compiled_funcall (treptr);
extern treptr trefuncall_compiled (treptr func, treptr args, bool do_eval);
void treapply_init ();
#endif /* #ifndef TRE_APPLY_H */
| /*
* tré – Copyright (c) 2005–2007,2009,2012 Sven Michael Klose <pixel@copei.de>
*/
#ifndef TRE_APPLY_H
#define TRE_APPLY_H
extern treptr function_arguments (treptr);
extern treptr trefuncall (treptr func, treptr args);
extern treptr trebuiltin_call_compiled (void * fun, treptr args);
extern bool trebuiltin_is_compiled_funcall (treptr);
extern bool trebuiltin_is_compiled_closure (treptr);
extern treptr trefuncall_compiled (treptr func, treptr args, bool do_eval);
void treapply_init ();
#endif /* #ifndef TRE_APPLY_H */
|
Include request data and status codes | #ifndef APIMOCK_H
#define APIMOCK_H
#include "core/server.h"
#include "core/exceptions.h"
#include "http/requestdata.h"
#endif | #ifndef APIMOCK_H
#define APIMOCK_H
#include "core/server.h"
#include "core/exceptions.h"
#include "http/requestdata.h"
#include "http/requestdata.h"
#include "http/statuscodes.h"
#endif |
Make the TemplateLoader constructor private for the Singleton pattern. | /*
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
*/
#ifndef TEMPLATE_H
#define TEMPLATE_H
#include "context.h"
#include "node.h"
#include "grantlee_export.h"
class GRANTLEE_EXPORT Template //: public QObject
{
// Q_OBJECT
public:
Template(const QString &templateString, QStringList dirs );
QString render( Context *c );
NodeList nodeList();
// TODO: Remove this. ??
void setNodeList(const NodeList &list);
private:
void parse();
NodeList compileString(const QString &str);
QStringList m_pluginDirs;
NodeList m_nodelist;
};
class GRANTLEE_EXPORT TemplateLoader
{
public:
static TemplateLoader* instance();
void setTemplateDirs(const QStringList &dirs);
void setPluginDirs(const QStringList &dirs);
void setTheme(const QString &themeName);
void injectTemplate(const QString &name, const QString &content);
Template loadFromString(const QString &content);
Template loadByName(const QString &name);
TemplateLoader();
private:
Template loadFromFile(const QString &fileName);
QString m_themeName;
QStringList m_templateDirs;
QStringList m_pluginDirs;
static TemplateLoader* m_instance;
QHash<QString, QString> m_namedTemplates;
};
#endif
| /*
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
*/
#ifndef TEMPLATE_H
#define TEMPLATE_H
#include "context.h"
#include "node.h"
#include "grantlee_export.h"
class GRANTLEE_EXPORT Template //: public QObject
{
// Q_OBJECT
public:
Template(const QString &templateString, QStringList dirs );
QString render( Context *c );
NodeList nodeList();
// TODO: Remove this. ??
void setNodeList(const NodeList &list);
private:
void parse();
NodeList compileString(const QString &str);
QStringList m_pluginDirs;
NodeList m_nodelist;
};
class GRANTLEE_EXPORT TemplateLoader
{
public:
static TemplateLoader* instance();
void setTemplateDirs(const QStringList &dirs);
void setPluginDirs(const QStringList &dirs);
void setTheme(const QString &themeName);
void injectTemplate(const QString &name, const QString &content);
Template loadFromString(const QString &content);
Template loadByName(const QString &name);
private:
TemplateLoader();
Template loadFromFile(const QString &fileName);
QString m_themeName;
QStringList m_templateDirs;
QStringList m_pluginDirs;
static TemplateLoader* m_instance;
QHash<QString, QString> m_namedTemplates;
};
#endif
|
Fix the test added in r240710. | // REQUIRES: x86-registered-target
// REQUIRES: arm-registered-target
// RUN: %clang -target i386-apple-darwin10 -miphonesimulator-version-min=7.0 -arch i386 -S -o - %s | FileCheck %s
// RUN: %clang -target i386-apple-darwin10 -miphoneos-version-min=7.0 -arch armv7s -S -o - %s | FileCheck %s
int main() { return 0; }
// CHECK: .ios_version_min 7, 0
| // REQUIRES: x86-registered-target
// REQUIRES: arm-registered-target
// RUN: %clang -target i386-apple-darwin10 -miphonesimulator-version-min=7.0 -arch i386 -S -o - %s | FileCheck %s
// RUN: %clang -target armv7s-apple-darwin10 -miphoneos-version-min=7.0 -arch armv7s -S -o - %s | FileCheck %s
int main() { return 0; }
// CHECK: .ios_version_min 7, 0
|
Make test subsystem load itself properly | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2012 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kotaka/log.h>
#include <kotaka/paths.h>
inherit LIB_INITD;
static void create()
{
LOGD->post_message("test", LOG_DEBUG, "Test subsystem loaded");
}
| /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2012 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kotaka/log.h>
#include <kotaka/paths.h>
inherit LIB_INITD;
inherit UTILITY_COMPILE;
static void create()
{
LOGD->post_message("test", LOG_DEBUG, "Test subsystem loading...");
load_dir("obj", 1);
load_dir("sys", 1);
LOGD->post_message("test", LOG_DEBUG, "Test subsystem loaded");
}
|
Remove nonstandard enum forward decl. | /*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2012 Scientific Computing and Imaging Institute,
University of Utah.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef CORE_COMMAND_COMMANDFACTORY_H
#define CORE_COMMAND_COMMANDFACTORY_H
#include <Core/Command/Share.h>
namespace SCIRun
{
namespace Core
{
namespace GlobalCommands
{
class GlobalCommand;
enum Commands;
class SCISHARE CommandFactory
{
public:
virtual ~CommandFactory();
virtual GlobalCommand* create(Commands command) = 0;
};
}
}
}
#endif
| /*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2012 Scientific Computing and Imaging Institute,
University of Utah.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef CORE_COMMAND_COMMANDFACTORY_H
#define CORE_COMMAND_COMMANDFACTORY_H
#include <Core/Command/Command.h>
#include <Core/Command/Share.h>
namespace SCIRun
{
namespace Core
{
namespace GlobalCommands
{
class GlobalCommand;
class SCISHARE CommandFactory
{
public:
virtual ~CommandFactory();
virtual GlobalCommand* create(Commands command) = 0;
};
}
}
}
#endif
|
Add new example for algorithm | #include "m-dict.h"
#include "m-array.h"
#include "m-algo.h"
#include "m-string.h"
DICT_DEF2(dict, string_t, int)
#define M_OPL_dict_t() DICT_OPLIST(dict, STRING_OPLIST, M_DEFAULT_OPLIST)
ARRAY_DEF(vector_int, int)
#define M_OPL_vector_int_t() ARRAY_OPLIST(vector_int)
#define start_with(pattern, item) \
string_start_with_str_p((item).key, (pattern))
#define get_value(out, item) ((out) = (item).value)
int main(void)
{
int s;
M_LET(keys, vector_int_t)
M_LET( (m, (STRING_CTE("foo"), 1), (STRING_CTE("bar"), 42), (STRING_CTE("bluez"), 7), (STRING_CTE("stop"), 789) ), tmp, dict_t) {
/* Extract all elements of 'm' that starts with 'b' */
ALGO_EXTRACT(tmp, dict_t, m, dict_t, start_with, "b");
/* Extract the values of theses elements */
ALGO_TRANSFORM(keys, vector_int_t, tmp, dict_t, get_value);
/* Sum theses values */
ALGO_REDUCE(s, keys, vector_int_t, sum);
printf("Sum of elements starting with 'b' is: %d\n", s);
}
return 0;
}
| |
Create a type to cast Ruby's C functions to a thing C++ is happy with. | extern "C" {
#include "ruby.h"
}
void Define_Document();
void Define_Page();
void Define_PageSet();
| #ifndef __PDFIUM_RUBY_H__
#define __PDFIUM_RUBY_H__
extern "C" {
#include "ruby.h"
}
// Inspired by https://github.com/jasonroelofs/rice/blob/1740a6d12c99fce8c21eda3c5385738318ab9172/rice/detail/ruby.hpp#L33-L37
// Casts C functions into a type that C++ is happy calling
extern "C" typedef VALUE (*CPP_RUBY_METHOD_FUNC)(ANYARGS);
void Define_Document();
void Define_Page();
void Define_PageSet();
#endif |
Add another case to qualifier-removal test | // RUN: %check %s
struct A
{
int i;
};
int f(const void *p)
{
struct A *a = p; // CHECK: warning: implicit cast removes qualifiers (const)
struct A *b = (struct A *)p; // CHECK: !/warning:.*cast removes qualifiers/
(void)a;
(void)b;
}
| // RUN: %check %s
struct A
{
int i;
};
void take(void *);
int f(const void *p)
{
struct A *a = p; // CHECK: warning: implicit cast removes qualifiers (const)
struct A *b = (struct A *)p; // CHECK: !/warning:.*cast removes qualifiers/
(void)a;
(void)b;
const char c = 5;
take(&c); // CHECK: warning: implicit cast removes qualifiers (const)
}
|
Move a non portable test to FileCheck, from Jonathan Gray! | // RUN: %clang -S -v -o %t %s 2>&1 | not grep -w -- -g
// RUN: %clang -S -v -o %t %s -g 2>&1 | grep -w -- -g
// RUN: %clang -S -v -o %t %s -g0 2>&1 | not grep -w -- -g
// RUN: %clang -S -v -o %t %s -g -g0 2>&1 | not grep -w -- -g
// RUN: %clang -S -v -o %t %s -g0 -g 2>&1 | grep -w -- -g
| // RUN: %clang -S -v -o %t %s 2>&1 | FileCheck %s
// CHECK-NOT: -g
// RUN: %clang -S -v -o %t %s -g 2>&1 | FileCheck %s
// CHECK: -g
// RUN: %clang -S -v -o %t %s -g0 2>&1 | FileCheck %s
// CHECK-NOT: -g
// RUN: %clang -S -v -o %t %s -g -g0 2>&1 | FileCheck %s
// CHECK-NOT: -g
// RUN: %clang -S -v -o %t %s -g0 -g 2>&1 | FileCheck %s
// CHECK: -g
|
Add command to use it | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2012 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kotaka/paths.h>
#include <account/paths.h>
#include <game/paths.h>
#include <text/paths.h>
#include <text/parse.h>
inherit LIB_RAWVERB;
void main(object actor, string args)
{
string name;
if (query_user()->query_class() < 2) {
send_out("You have insufficient access to post on the DGD channel.\n");
return;
}
name = query_user()->query_name();
CHANNELD->post_message("dgd", name, args);
}
| |
Work around more GCC nonsense | //------------------------------------------------------------------------------
// Enum.h
// Various enum utilities.
//
// File is under the MIT license; see LICENSE for details.
//------------------------------------------------------------------------------
#pragma once
#define UTIL_ENUM_ELEMENT(x) x,
#define UTIL_ENUM_STRING(x) #x,
#define ENUM(name, elements) \
enum class name { elements(UTIL_ENUM_ELEMENT) }; \
inline string_view toString(name e) { \
static const char* strings[] = { elements(UTIL_ENUM_STRING) }; \
return strings[static_cast<std::underlying_type_t<name>>(e)]; \
} \
inline std::ostream& operator<<(std::ostream& os, name e) { return os << toString(e); }
#define ENUM_MEMBER(name, elements) \
enum name { elements(UTIL_ENUM_ELEMENT) }; \
friend string_view toString(name e) { \
static const char* strings[] = { elements(UTIL_ENUM_STRING) }; \
return strings[static_cast<std::underlying_type_t<name>>(e)]; \
} | //------------------------------------------------------------------------------
// Enum.h
// Various enum utilities.
//
// File is under the MIT license; see LICENSE for details.
//------------------------------------------------------------------------------
#pragma once
#define UTIL_ENUM_ELEMENT(x) x,
#define UTIL_ENUM_STRING(x) #x,
#define ENUM(name, elements) \
enum class name { elements(UTIL_ENUM_ELEMENT) }; \
inline string_view toString(name e) { \
static const char* strings[] = { elements(UTIL_ENUM_STRING) }; \
return strings[static_cast<std::underlying_type_t<name>>(e)]; \
} \
inline std::ostream& operator<<(std::ostream& os, name e) { return os << toString(e); }
#define ENUM_MEMBER(name, elements) \
enum name { elements(UTIL_ENUM_ELEMENT) }; \
friend string_view toString(name e) { \
static const char* strings[] = { elements(UTIL_ENUM_STRING) }; \
return strings[static_cast<std::underlying_type_t<name>>(e)]; \
}
|
Fix undefined GLint in Mac builds |
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkMesaGLContext_DEFINED
#define SkMesaGLContext_DEFINED
#include "SkGLContext.h"
#if SK_MESA
class SkMesaGLContext : public SkGLContext {
private:
typedef intptr_t Context;
public:
SkMesaGLContext();
virtual ~SkMesaGLContext();
virtual void makeCurrent() const SK_OVERRIDE;
class AutoContextRestore {
public:
AutoContextRestore();
~AutoContextRestore();
private:
Context fOldContext;
GLint fOldWidth;
GLint fOldHeight;
GLint fOldFormat;
void* fOldImage;
};
protected:
virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
virtual void destroyGLContext() SK_OVERRIDE;
private:
Context fContext;
GrGLubyte *fImage;
};
#endif
#endif
|
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkMesaGLContext_DEFINED
#define SkMesaGLContext_DEFINED
#include "SkGLContext.h"
#if SK_MESA
class SkMesaGLContext : public SkGLContext {
private:
typedef intptr_t Context;
public:
SkMesaGLContext();
virtual ~SkMesaGLContext();
virtual void makeCurrent() const SK_OVERRIDE;
class AutoContextRestore {
public:
AutoContextRestore();
~AutoContextRestore();
private:
Context fOldContext;
GrGLint fOldWidth;
GrGLint fOldHeight;
GrGLint fOldFormat;
void* fOldImage;
};
protected:
virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
virtual void destroyGLContext() SK_OVERRIDE;
private:
Context fContext;
GrGLubyte *fImage;
};
#endif
#endif
|
Make static member method private | #ifndef CPR_ERROR_H
#define CPR_ERROR_H
#include <string>
#include "cprtypes.h"
#include "defines.h"
namespace cpr {
enum class ErrorCode {
OK = 0,
CONNECTION_FAILURE,
EMPTY_RESPONSE,
HOST_RESOLUTION_FAILURE,
INTERNAL_ERROR,
INVALID_URL_FORMAT,
NETWORK_RECEIVE_ERROR,
NETWORK_SEND_FAILURE,
OPERATION_TIMEDOUT,
PROXY_RESOLUTION_FAILURE,
SSL_CONNECT_ERROR,
SSL_LOCAL_CERTIFICATE_ERROR,
SSL_REMOTE_CERTIFICATE_ERROR,
SSL_CACERT_ERROR,
GENERIC_SSL_ERROR,
UNSUPPORTED_PROTOCOL,
UNKNOWN_ERROR = 1000,
};
class Error {
public:
Error() : code{ErrorCode::OK} {}
template <typename TextType>
Error(const ErrorCode& p_error_code, TextType&& p_error_message)
: code{p_error_code}, message{CPR_FWD(p_error_message)} {}
explicit operator bool() const {
return code != ErrorCode::OK;
}
ErrorCode code;
std::string message;
static ErrorCode getErrorCodeForCurlError(int curl_code);
};
} // namespace cpr
#endif
| #ifndef CPR_ERROR_H
#define CPR_ERROR_H
#include <string>
#include "cprtypes.h"
#include "defines.h"
namespace cpr {
enum class ErrorCode {
OK = 0,
CONNECTION_FAILURE,
EMPTY_RESPONSE,
HOST_RESOLUTION_FAILURE,
INTERNAL_ERROR,
INVALID_URL_FORMAT,
NETWORK_RECEIVE_ERROR,
NETWORK_SEND_FAILURE,
OPERATION_TIMEDOUT,
PROXY_RESOLUTION_FAILURE,
SSL_CONNECT_ERROR,
SSL_LOCAL_CERTIFICATE_ERROR,
SSL_REMOTE_CERTIFICATE_ERROR,
SSL_CACERT_ERROR,
GENERIC_SSL_ERROR,
UNSUPPORTED_PROTOCOL,
UNKNOWN_ERROR = 1000,
};
class Error {
public:
Error() : code{ErrorCode::OK} {}
template <typename TextType>
Error(const ErrorCode& p_error_code, TextType&& p_error_message)
: code{p_error_code}, message{CPR_FWD(p_error_message)} {}
explicit operator bool() const {
return code != ErrorCode::OK;
}
ErrorCode code;
std::string message;
private:
static ErrorCode getErrorCodeForCurlError(int curl_code);
};
} // namespace cpr
#endif
|
Update import style to add RN 40.0+ compatibility | //
// RNInstabugSDK.h
// RNInstabugSDK
//
// Created by Mark Miyashita on 10/11/16.
// Copyright © 2016 Mark Miyashita. All rights reserved.
//
#import "RCTBridgeModule.h"
#import "RCTConvert.h"
#import "RCTUtils.h"
@interface RNInstabugSDK : NSObject <RCTBridgeModule>
@end
| //
// RNInstabugSDK.h
// RNInstabugSDK
//
// Created by Mark Miyashita on 10/11/16.
// Copyright © 2016 Mark Miyashita. All rights reserved.
//
#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#import "RCTConvert.h"
#import "RCTUtils.h"
#else
#import "React/RCTBridgeModule.h"
#import "React/RCTConvert.h"
#import "React/RCTUtils.h"
#endif
@interface RNInstabugSDK : NSObject <RCTBridgeModule>
@end
|
Fix issue in options index. | #include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "cmd.h"
void sh_exit() {
exit(0);
}
void sh_pid() {
printf("%d\n", getpid());
}
void sh_ppid() {
printf("%d\n", getppid());
}
void sh_cd(cmd_args_t args) {
char* dir;
if (args.size == 1) {
dir = getenv("HOME");
} else {
dir = args.args[1];
}
chdir(dir);
}
void sh_pwd() {
char* cwd = getcwd(NULL, 0);
printf("%s\n", cwd);
free(cwd);
}
void sh_set(cmd_args_t args) {
setenv(args.args[0], args.args[1], true);
}
void sh_get(cmd_args_t args) {
char* val = getenv(args.args[0]);
if (val == NULL) {
printf("(NULL)\n");
} else {
printf("%s\n", val);
}
}
| #include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "cmd.h"
void sh_exit() {
exit(0);
}
void sh_pid() {
printf("%d\n", getpid());
}
void sh_ppid() {
printf("%d\n", getppid());
}
void sh_cd(cmd_args_t args) {
char* dir;
if (args.size == 1) {
dir = getenv("HOME");
} else {
dir = args.args[1];
}
chdir(dir);
}
void sh_pwd() {
char* cwd = getcwd(NULL, 0);
printf("%s\n", cwd);
free(cwd);
}
void sh_set(cmd_args_t args) {
setenv(args.args[1], args.args[2], true);
}
void sh_get(cmd_args_t args) {
char* val = getenv(args.args[1]);
if (val == NULL) {
printf("(NULL)\n");
} else {
printf("%s\n", val);
}
}
|
Fix erro cb return value | /*
* Copyright 2016 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "rpm-helper.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data)
{
dE("RPM: %s", rpmlogRecMessage(rec));
return RPMLOG_EXIT; // don't perform default logging
void rpmLibsPreload()
{
rpmReadConfigFiles(NULL, NULL);
}
| /*
* Copyright 2016 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "rpm-helper.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data)
{
dE("RPM: %s", rpmlogRecMessage(rec));
return RPMLOG_DEFAULT;
}
void rpmLibsPreload()
{
rpmReadConfigFiles(NULL, NULL);
}
|
Update get_dir, get_file decls, add get_pipe decl | /**
* utils.h
*
* Copyright (C) 2017 Nickolas Burr <nickolasburr@gmail.com>
*/
#ifndef GIT_STASHD_UTILS_H
#define GIT_STASHD_UTILS_H
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "common.h"
#include "signals.h"
#ifdef __APPLE__
#include <limits.h>
#else
#include <linux/limits.h>
#endif
/**
* String utilities
*/
int compare(char *one, char *two);
char *concat(char *buf, char *str);
char *copy(char *buf, char *str);
/**
* Filesystem utilities
*/
DIR *get_dir(const char *path);
FILE *get_file(const char *filename, const char *filemode);
int is_dir(const char *path);
int is_file(const char *path);
int is_link(const char *path);
int is_sock(const char *path);
int is_fifo(const char *path);
int is_block(const char *path);
int is_char(const char *path);
/**
* Type utilities
*/
int is_null(void *ptr);
#endif /* GIT_STASHD_UTILS_H */
| /**
* utils.h
*
* Copyright (C) 2017 Nickolas Burr <nickolasburr@gmail.com>
*/
#ifndef GIT_STASHD_UTILS_H
#define GIT_STASHD_UTILS_H
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "common.h"
#include "signals.h"
#ifdef __APPLE__
#include <limits.h>
#else
#include <linux/limits.h>
#endif
/**
* String utilities
*/
int compare(char *one, char *two);
char *concat(char *buf, char *str);
char *copy(char *buf, char *str);
/**
* Filesystem utilities
*/
DIR *get_dir(const char *path, int *error);
FILE *get_file(const char *filename, const char *filemode, int *error);
FILE *get_pipe(char *command, char *mode, int *error);
int is_dir(const char *path);
int is_file(const char *path);
int is_link(const char *path);
int is_sock(const char *path);
int is_fifo(const char *path);
int is_block(const char *path);
int is_char(const char *path);
/**
* Type utilities
*/
int is_null(void *ptr);
#endif /* GIT_STASHD_UTILS_H */
|
Fix up definition of off_t for DecAlpha OSF/1 v1.3. | #ifndef FIX_TYPES_H
#define FIX_TYPES_H
#include <sys/types.h>
/*
The system include file defines this in terms of bzero(), but ANSI says
we should use memset().
*/
#if defined(OSF1)
#undef FD_ZERO
#define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
#endif
/*
Various non-POSIX conforming files which depend on sys/types.h will
need these extra definitions...
*/
typedef unsigned int u_int;
#if defined(AIX32)
typedef unsigned short ushort;
#endif
#if defined(ULTRIX42) || defined(ULTRIX43)
typedef char * caddr_t;
#endif
#if defined(AIX32)
typedef unsigned long rlim_t;
#endif
#endif
| #ifndef FIX_TYPES_H
#define FIX_TYPES_H
// OSF/1 has this as an "unsigned long", but this is incorrect. It
// is used by lseek(), and must be able to hold negative values.
#if defined(OSF1)
#define off_t _hide_off_t
#endif
#include <sys/types.h>
#if defined(OSF1)
#undef off_t
typedef long off_t;
#endif
/*
The system include file defines this in terms of bzero(), but ANSI says
we should use memset().
*/
#if defined(OSF1)
#undef FD_ZERO
#define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
#endif
/*
Various non-POSIX conforming files which depend on sys/types.h will
need these extra definitions...
*/
typedef unsigned int u_int;
#if defined(AIX32)
typedef unsigned short ushort;
#endif
#if defined(ULTRIX42) || defined(ULTRIX43)
typedef char * caddr_t;
#endif
#if defined(AIX32)
typedef unsigned long rlim_t;
#endif
#endif
|
Update testcase to show that we don't emit an error for sizes <= 32-bits. | // RUN: %clang_cc1 -triple i386-apple-darwin9 -verify %s
// <rdar://problem/12415959>
typedef unsigned int u_int32_t;
typedef u_int32_t uint32_t;
typedef unsigned long long u_int64_t;
typedef u_int64_t uint64_t;
int main () {
uint32_t msr = 0x8b;
uint64_t val = 0;
__asm__ volatile("wrmsr"
:
: "c" (msr),
"a" ((val & 0xFFFFFFFFUL)), // expected-error {{invalid input size for constraint 'a'}}
"d" (((val >> 32) & 0xFFFFFFFFUL)));
}
| // RUN: %clang_cc1 -triple i386-apple-darwin9 -verify %s
// <rdar://problem/12415959>
typedef unsigned int u_int32_t;
typedef u_int32_t uint32_t;
typedef unsigned long long u_int64_t;
typedef u_int64_t uint64_t;
int main () {
// Error out if size is > 32-bits.
uint32_t msr = 0x8b;
uint64_t val = 0;
__asm__ volatile("wrmsr"
:
: "c" (msr),
"a" ((val & 0xFFFFFFFFUL)), // expected-error {{invalid input size for constraint 'a'}}
"d" (((val >> 32) & 0xFFFFFFFFUL)));
// Don't error out if the size of the destination is <= 32 bits.
unsigned char data;
unsigned int port;
__asm__ volatile("outb %0, %w1" : : "a" (data), "Nd" (port)); // No error expected.
}
|
Add header file for ap_hook_post_read_request to suppress compiler warnings | #include <uuid/uuid.h>
#include "httpd.h"
#include "http_config.h"
static int generate_uuid(request_rec *r)
{
char *uuid_str;
uuid_t uuid;
uuid_generate_random(uuid);
uuid_str = (char *)apr_palloc(r->pool, sizeof(char)*37);
uuid_unparse_lower(uuid, uuid_str);
apr_table_setn(r->subprocess_env, "UUID", uuid_str);
return DECLINED;
}
static void register_hooks(apr_pool_t *p)
{
ap_hook_post_read_request(generate_uuid, NULL, NULL, APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA uuid_module = {
STANDARD20_MODULE_STUFF,
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server configs */
NULL, /* command apr_table_t */
register_hooks /* register hooks */
};
| #include <uuid/uuid.h>
#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
static int generate_uuid(request_rec *r)
{
char *uuid_str;
uuid_t uuid;
uuid_generate_random(uuid);
uuid_str = (char *)apr_palloc(r->pool, sizeof(char)*37);
uuid_unparse_lower(uuid, uuid_str);
apr_table_setn(r->subprocess_env, "UUID", uuid_str);
return DECLINED;
}
static void register_hooks(apr_pool_t *p)
{
ap_hook_post_read_request(generate_uuid, NULL, NULL, APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA uuid_module = {
STANDARD20_MODULE_STUFF,
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server configs */
NULL, /* command apr_table_t */
register_hooks /* register hooks */
};
|
Print error messages to stderr. | #include <stdio.h>
#include "libsass/sass_interface.h"
int main(int argc, char** argv)
{
int ret;
if (argc < 2) {
printf("Usage: sassc [INPUT FILE]\n");
return 0;
}
struct sass_file_context* ctx = sass_new_file_context();
ctx->options.include_paths = "";
ctx->options.image_path = "images";
ctx->options.output_style = SASS_STYLE_NESTED;
ctx->input_path = argv[1];
sass_compile_file(ctx);
if (ctx->error_status) {
if (ctx->error_message)
printf("%s", ctx->error_message);
else
printf("An error occured; no error message available.\n");
ret = 1;
}
else if (ctx->output_string) {
printf("%s", ctx->output_string);
ret = 0;
}
else {
printf("Unknown internal error.\n");
ret = 2;
}
sass_free_file_context(ctx);
return ret;
}
| #include <stdio.h>
#include "libsass/sass_interface.h"
int main(int argc, char** argv)
{
int ret;
if (argc < 2) {
printf("Usage: sassc [INPUT FILE]\n");
return 0;
}
struct sass_file_context* ctx = sass_new_file_context();
ctx->options.include_paths = "";
ctx->options.image_path = "images";
ctx->options.output_style = SASS_STYLE_NESTED;
ctx->input_path = argv[1];
sass_compile_file(ctx);
if (ctx->error_status) {
if (ctx->error_message)
fprintf(stderr, "%s", ctx->error_message);
else
fprintf(stderr, "An error occured; no error message available.\n");
ret = 1;
}
else if (ctx->output_string) {
printf("%s", ctx->output_string);
ret = 0;
}
else {
fprintf(stderr, "Unknown internal error.\n");
ret = 2;
}
sass_free_file_context(ctx);
return ret;
}
|
Add an enum_to_string util function | /*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2021 Hugo Beauzée-Luyssen, Videolabs, VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#pragma once
#include <type_traits>
#include <string>
namespace medialibrary
{
namespace utils
{
template <typename T>
std::string enum_to_string( T value )
{
static_assert( std::is_enum<T>::value, "This must be used with enum types" );
return std::to_string( static_cast<std::underlying_type_t<T>>( value ) );
}
}
}
| |
Patch from Fabio Massimo Di Nitto: Fix includes | #include <sys/types.h>
#include <linux/unistd.h>
#include <gettid.h>
#include <errno.h>
/* Patch from Adam Conrad / Ubuntu: Don't use _syscall macro */
#ifdef __NR_gettid
pid_t gettid (void)
{
return syscall(__NR_gettid);
}
#else
#warn "gettid not available -- substituting with pthread_self()"
#include <pthread.h>
pid_t gettid (void)
{
return (pid_t)pthread_self();
}
#endif
| #include <sys/types.h>
#include <sys/syscall.h>
#include <linux/unistd.h>
#include <gettid.h>
#include <errno.h>
#include <unistd.h>
/* Patch from Adam Conrad / Ubuntu: Don't use _syscall macro */
#ifdef __NR_gettid
pid_t gettid (void)
{
return syscall(__NR_gettid);
}
#else
#warn "gettid not available -- substituting with pthread_self()"
#include <pthread.h>
pid_t gettid (void)
{
return (pid_t)pthread_self();
}
#endif
|
Fix test added in 6fe29dd | typedef int myint;
myint x = (myint)1;
| typedef int myint;
myint x = (myint)1;
int
main(void)
{
return x-1;
}
|
Change any tabs to spaces | #ifndef SIMULATOR_H
#define SIMULATOR_H
#include "ros/ros.h"
#include "dynamics.h"
#include "sensor_msgs/Imu.h"
#include "sensor_msgs/FluidPressure.h"
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Wrench.h"
#include "geometry_msgs/Pose.h"
#include "vortex_msgs/Float64ArrayStamped.h"
#include </usr/include/armadillo>
typedef std::vector<double> stdvec;
class Simulator {
public:
Simulator(unsigned int f,
ros::NodeHandle nh);
void thrustCallback(const vortex_msgs::Float64ArrayStamped &msg);
void spin();
private:
void poseArmaToMsg(const arma::vec &e,
geometry_msgs::Pose &m);
void twistArmaToMsg(const arma::vec &e,
geometry_msgs::Twist &m);
unsigned int frequency;
ros::NodeHandle nh;
ros::Subscriber wrenchSub;
ros::Publisher posePub;
ros::Publisher twistPub;
ros::Publisher imuPub;
ros::Publisher pressurePub;
Dynamics *dynamics;
arma::vec u;
};
#endif
| #ifndef SIMULATOR_H
#define SIMULATOR_H
#include "ros/ros.h"
#include "dynamics.h"
#include "sensor_msgs/Imu.h"
#include "sensor_msgs/FluidPressure.h"
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Wrench.h"
#include "geometry_msgs/Pose.h"
#include "vortex_msgs/Float64ArrayStamped.h"
#include </usr/include/armadillo>
typedef std::vector<double> stdvec;
class Simulator {
public:
Simulator(unsigned int f,
ros::NodeHandle nh);
void thrustCallback(const vortex_msgs::Float64ArrayStamped &msg);
void spin();
private:
void poseArmaToMsg(const arma::vec &e,
geometry_msgs::Pose &m);
void twistArmaToMsg(const arma::vec &e,
geometry_msgs::Twist &m);
unsigned int frequency;
ros::NodeHandle nh;
ros::Subscriber wrenchSub;
ros::Publisher posePub;
ros::Publisher twistPub;
ros::Publisher imuPub;
ros::Publisher pressurePub;
Dynamics *dynamics;
arma::vec u;
};
#endif
|
Add the begginning of lab1 | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int port;
char *directory;
// Command Line Arguments //
if (argc < 3) {
printf("usage: %s <port> <dir>\n", argv[0]);
return 1;
}
port = atoi(argv[1]);
directory = argv[2];
if (port <= 0) {
printf("Invalid port provided.\n");
return 1;
}
// TODO server
return 0;
} | |
Fix a path in the translation loop test | /* liblouis Braille Translation and Back-Translation Library
Copyright (C) 2014 Mesar Hameed <mesar.hameed@gmail.com>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "liblouis.h"
#include "brl_checks.h"
/* Demonstrates infinite translation loop.
* Originally reported at: http://www.freelists.org/post/liblouis-liblouisxml/Translating-com-with-UEBCg2ctb-causes-infinite-loop
*/
int main(int argc, char **argv)
{
int result = 0;
const char *text = "---.com";
const char *expected = "";
result |= check_translation("UEBC-g2.ctb", text, NULL, expected);
lou_free();
return result;
}
| /* liblouis Braille Translation and Back-Translation Library
Copyright (C) 2014 Mesar Hameed <mesar.hameed@gmail.com>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "liblouis.h"
#include "brl_checks.h"
/* Demonstrates infinite translation loop.
* Originally reported at: http://www.freelists.org/post/liblouis-liblouisxml/Translating-com-with-UEBCg2ctb-causes-infinite-loop
*/
int main(int argc, char **argv)
{
int result = 0;
const char *text = "---.com";
const char *expected = "";
result |= check_translation("tables/UEBC-g2.ctb", text, NULL, expected);
lou_free();
return result;
}
|
Fix for last commit: adding new test file forgotten. | // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
// expected-no-diagnostics
int foo(int a, int b) {
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
a += b; b -= a;
return a + b;
}
| |
Use ds_linked_list_length() instead of the size struct member. | #include <stdio.h>
#include <datastructs.h>
int main(){
typedef struct user_data {
char name[100];
char email[100];
} user_data;
user_data a = {"John Doe", "john.doe@mail_server.com"};
user_data b = {"Jack Smith", "jack.smith@mail_server.com"};
user_data c = {"Jane Plain", "jane.plain@mail_server.com"};
user_data d = {"Mary Merry", "mary.merry@mail_server.com"};
user_data* data = NULL;
// list creation:
ds_linked_list* list = ds_linked_list_create();
ds_linked_list_insert_at(list, &a, 0);
ds_linked_list_add(list, &b);
ds_linked_list_add(list, &c);
ds_linked_list_add(list, &d);
int i;
for (i = 0; i < list->size; i ++){
data = ds_linked_list_get(list, i);
printf("Name: %s, Email: %s\n", data->name, data->email );
}
ds_linked_list_delete(&list);
}
| #include <stdio.h>
#include <datastructs.h>
int main(){
typedef struct user_data {
char name[100];
char email[100];
} user_data;
user_data a = {"John Doe", "john.doe@mail_server.com"};
user_data b = {"Jack Smith", "jack.smith@mail_server.com"};
user_data c = {"Jane Plain", "jane.plain@mail_server.com"};
user_data d = {"Mary Merry", "mary.merry@mail_server.com"};
user_data* data = NULL;
// list creation:
ds_linked_list* list = ds_linked_list_create();
ds_linked_list_insert_at(list, &a, 0);
ds_linked_list_add(list, &b);
ds_linked_list_add(list, &c);
ds_linked_list_add(list, &d);
int i;
for (i = 0; i < ds_linked_list_length(list); i ++){
data = ds_linked_list_get(list, i);
printf("Name: %s, Email: %s\n", data->name, data->email );
}
ds_linked_list_delete(&list);
}
|
Add Roman Numerals to homework | #include <stdio.h>
#include <string.h>
int getRomanValue(char number);
int checkRomanValue(char romanNumber[20]);
int main()
{
char romanNumber[20];
int i, curNum;
while(1)
{
curNum=0;
printf("Input roman number: ");
scanf("%s", romanNumber);
if(checkRomanN(romanNumber)==0)
{
printf("Input a valid roman number\n");
continue;
}
for(i=0; i<strlen(romanNumber); i++)
{
if(getRomanValue(romanNumber[i])<getRomanValue(romanNumber[i+1]))
{
curNum+=getRomanValue(romanNumber[i+1]) - getRomanValue(romanNumber[i]);
i++;
}
else
curNum+=getRomanValue(romanNumber[i]);
}
if(curNum>256)
{
printf("Number is larger than 256\n");
continue;
}
else
{
printf("Roman number in decimal is: %d\n", curNum);
break;
}
}
return 1;
}
int getRomanValue(char number)
{
int value;
switch(number){
case 'I':
value=1;
break;
case 'V':
value=5;
break;
case 'X':
value=10;
break;
case 'L':
value=50;
break;
case 'C':
value=100;
break;
}
return value;
}
int checkRomanN(char romanNumber[20]) //Function to check if inputted string is valid with roman numerals rules
{
int numerals[5]={0}, correct=1, i; // 0 - I 1 - V 2 - X 3 - L 4 - C XIX
for(i=0;i<strlen(romanNumber);i++)
{
if(romanNumber[i]!='I' && romanNumber[i]!='V' && romanNumber[i]!='X' && romanNumber[i]!='L' && romanNumber[i]!='C')
{
switch(romanNumber[i]){
case 'I':
numerals[0]++;
break;
case 'V':
numerals[1]++;
break;
case 'X':
numerals[2]++;
break;
case 'L':
numerals[3]++;
break;
case 'C':
numerals[4]++;
break;
}
}
}
for(i=0;i<5;i++)
{
if(numerals[i]>3)
return 0;
}
return 1;
}
| |
Fix static linking problem with LuaJIT | #ifndef COMPAT_H
#define COMPAT_H
#include "lua.h"
#include "lauxlib.h"
#if LUA_VERSION_NUM==501
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
void *luaL_testudata ( lua_State *L, int arg, const char *tname);
#endif
#endif
| #ifndef COMPAT_H
#define COMPAT_H
#include "lua.h"
#include "lauxlib.h"
#if LUA_VERSION_NUM==501
#define luaL_setfuncs socket_setfuncs
#define luaL_testudata socket_testudata
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
void *luaL_testudata ( lua_State *L, int arg, const char *tname);
#endif
#endif
|
Solve Average 2 in c | #include <stdio.h>
int main() {
float a, b, c;
scanf("%f", &a);
scanf("%f", &b);
scanf("%f", &c);
printf("MEDIA = %.1f\n", (a * 2.0 + b * 3.0 + c * 5.0) / 10.0);
return 0;
}
| |
Use PLClang.h in umbrella header | /*
* Author: Landon Fuller <landonf@plausible.coop>
*
* Copyright (c) 2013 Plausible Labs Cooperative, Inc.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import "PLClangSourceIndex.h"
#import "PLClangTranslationUnit.h" | /*
* Author: Landon Fuller <landonf@plausible.coop>
*
* Copyright (c) 2013 Plausible Labs Cooperative, Inc.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import "PLClang.h"
|
Include <string> to fix a compile issue in 4.12 and 4.13. | // Copyright (C) 2011 Carl Rogers
// Released under MIT License
// Simplied by Weichao Qiu (qiuwch@gmail.com) from https://github.com/rogersce/cnpy
#pragma once
#include <vector>
namespace cnpy {
template<typename T>
std::vector<char> create_npy_header(const T* data, const std::vector<int> shape);
template<typename T>
std::vector<char>& operator+=(std::vector<char>& lhs, const T rhs) {
//write in little endian
for (char byte = 0; byte < sizeof(T); byte++) {
char val = *((char*)&rhs + byte);
lhs.push_back(val);
}
return lhs;
}
template<>
std::vector<char>& operator+=(std::vector<char>& lhs, const std::string rhs);
template<>
std::vector<char>& operator+=(std::vector<char>& lhs, const char* rhs);
}
| // Copyright (C) 2011 Carl Rogers
// Released under MIT License
// Simplied by Weichao Qiu (qiuwch@gmail.com) from https://github.com/rogersce/cnpy
#pragma once
#include <vector>
#include <string>
namespace cnpy {
template<typename T>
std::vector<char> create_npy_header(const T* data, const std::vector<int> shape);
template<typename T>
std::vector<char>& operator+=(std::vector<char>& lhs, const T rhs) {
//write in little endian
for (char byte = 0; byte < sizeof(T); byte++) {
char val = *((char*)&rhs + byte);
lhs.push_back(val);
}
return lhs;
}
template<>
std::vector<char>& operator+=(std::vector<char>& lhs, const std::string rhs);
template<>
std::vector<char>& operator+=(std::vector<char>& lhs, const char* rhs);
}
|
Update driver version to 5.04.00-k6 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2013 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.04.00-k5"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2013 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.04.00-k6"
|
Add documentation comments for method | //
// NAPlaybackIndicatorView.h
// PlaybackIndicator
//
// Created by Yuji Nakayama on 1/27/14.
// Copyright (c) 2014 Yuji Nakayama. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NAPlaybackIndicatorView : UIView
- (void)startAnimating;
- (void)stopAnimating;
@property (nonatomic, readonly, getter=isAnimating) BOOL animating;
@end
| //
// NAPlaybackIndicatorView.h
// PlaybackIndicator
//
// Created by Yuji Nakayama on 1/27/14.
// Copyright (c) 2014 Yuji Nakayama. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NAPlaybackIndicatorView : UIView
/**
Starts the oscillating animation of the bars.
*/
- (void)startAnimating;
/**
Stop the oscillating animation of the bars.
*/
- (void)stopAnimating;
/**
Whether the receiver is animating.
*/
@property (nonatomic, readonly, getter=isAnimating) BOOL animating;
@end
|
Fix the constants so it will work correctly. Also add the possibility of a different Product ID so the dongles can be set to a mode that Windows machines with the CSR drivers won't switch them to HCI mode. | #include <stdio.h>
#include <libusb-1.0/libusb.h>
int main (int argc, char ** argv) {
char data[] = { 0x01, 0x05, 0, 0, 0, 0, 0, 0, 0 };
libusb_init(NULL);
libusb_device_handle* h = libusb_open_device_with_vid_pid(NULL, 0x0a12, 0x100b);
if (!h) {
printf("No device in HID mode found\n");
} else {
libusb_detach_kernel_driver(h, 0);
printf("%d\n", libusb_claim_interface(h, 0));
libusb_control_transfer(h, LIBUSB_ENDPOINT_OUT|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE, LIBUSB_REQUEST_GET_CONFIGURATION, 0x0301, 0, data, 9, 10000);
libusb_release_interface(h, 0);
libusb_close(h);
}
libusb_exit(NULL);
return 0;
}
| #include <stdio.h>
#include <libusb-1.0/libusb.h>
int main (int argc, char ** argv) {
char data[] = { 0x01, 0x05, 0, 0, 0, 0, 0, 0, 0 };
libusb_init(NULL);
/* using the default pskeys, devices from the factory are a12:100d in HID mode */
libusb_device_handle* h = libusb_open_device_with_vid_pid(NULL, 0x0a12, 0x100b);
if (!h)
/* Alternatively, a12:100c can be set by the dongler to prevent CSR's software
stack from auto-switching to HCI mode */
h = libusb_open_device_with_vid_pid(NULL, 0x0a12, 0x100c);
if (!h) {
printf("No device in HID mode found\n");
} else {
libusb_detach_kernel_driver(h, 0);
printf("This should say 0: %d\n", libusb_claim_interface(h, 0));
libusb_control_transfer(h, LIBUSB_ENDPOINT_OUT|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0301, 0, data, 9, 10000);
libusb_release_interface(h, 0);
libusb_close(h);
}
libusb_exit(NULL);
return 0;
}
|
Add missing file in previous commit. | //===-- llvm/CodeGen/GlobalISel/CallLowering.h - Call lowering --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file describes how to lower LLVM calls to machine code calls.
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
#define LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Function.h"
namespace llvm {
// Forward declarations.
class MachineIRBuilder;
class TargetLowering;
class Value;
class CallLowering {
const TargetLowering *TLI;
protected:
/// Getter for generic TargetLowering class.
const TargetLowering *getTLI() const {
return TLI;
}
/// Getter for target specific TargetLowering class.
template <class XXXTargetLowering>
const XXXTargetLowering *getTLI() const {
return static_cast<const XXXTargetLowering *>(TLI);
}
public:
CallLowering(const TargetLowering *TLI) : TLI(TLI) {}
virtual ~CallLowering() {}
/// This hook must be implemented to lower outgoing return values, described
/// by \p Val, into the specified virtual register \p VReg.
/// This hook is used by GlobalISel.
///
/// \return True if the lowering succeeds, false otherwise.
virtual bool LowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
unsigned VReg) const {
return false;
}
/// This hook must be implemented to lower the incoming (formal)
/// arguments, described by \p Args, for GlobalISel. Each argument
/// must end up in the related virtual register described by VRegs.
/// In other words, the first argument should end up in VRegs[0],
/// the second in VRegs[1], and so on.
/// \p MIRBuilder is set to the proper insertion for the argument
/// lowering.
///
/// \return True if the lowering succeeded, false otherwise.
virtual bool
LowerFormalArguments(MachineIRBuilder &MIRBuilder,
const Function::ArgumentListType &Args,
const SmallVectorImpl<unsigned> &VRegs) const {
return false;
}
};
} // End namespace llvm.
#endif
| |
Move JSON parser into libslax | /*
* $Id$
*
* Copyright (c) 2013, Juniper Networks, Inc.
* All rights reserved.
* This SOFTWARE is licensed under the LICENSE provided in the
* ../Copyright file. By downloading, installing, copying, or otherwise
* using the SOFTWARE, you agree to be bound by the terms of that
* LICENSE.
*
* jsonwriter.h -- turn json-oriented XML into json text
*/
int
slaxJsonWriteNode (slaxWriterFunc_t func, void *data, xmlNodePtr nodep,
unsigned flags);
int
slaxJsonWriteDoc (slaxWriterFunc_t func, void *data, xmlDocPtr docp,
unsigned flags);
#define JWF_ROOT (1<<0) /* Root node */
#define JWF_ARRAY (1<<1) /* Inside array */
#define JWF_NODESET (1<<2) /* Top of a nodeset */
#define JWF_PRETTY (1<<3) /* Pretty print (newlines) */
#define JWF_OPTIONAL_QUOTES (1<<4) /* Don't use quotes unless needed */
| |
Make c bindings compile on strict compilers | /*
** Author(s):
** - Cedric GESTES <gestes@aldebaran-robotics.com>
**
** Copyright (C) 2010 Aldebaran Robotics
*/
#include <qi/qi.h>
#include <stdio.h>
int main(int argc, char **argv)
{
qi_client_t *client = qi_client_create("simplecli", argv[1]);
qi_message_t *message = qi_message_create();
qi_message_t *ret = qi_message_create();
qi_message_write_string(message, "master.locateService::s:s");
qi_message_write_string(message, "master.listServices::{ss}:");
qi_client_call(client, "master.locateService::s:s", message, ret);
char *result = qi_message_read_string(ret);
printf("locate returned: %s\n", result);
return 0;
}
| /*
** Author(s):
** - Cedric GESTES <gestes@aldebaran-robotics.com>
**
** Copyright (C) 2010 Aldebaran Robotics
*/
#include <qi/qi.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char *result;
qi_client_t *client = qi_client_create("simplecli", argv[1]);
qi_message_t *message = qi_message_create();
qi_message_t *ret = qi_message_create();
qi_message_write_string(message, "master.locateService::s:s");
qi_message_write_string(message, "master.listServices::{ss}:");
qi_client_call(client, "master.locateService::s:s", message, ret);
result = qi_message_read_string(ret);
printf("locate returned: %s\n", result);
return 0;
}
|
Change the ssw_navigationBarShadowImage to the @optional | //
// SloppySwiperViewControllerProtocol.h
// Pods
//
// Created by Yu Sugawara on 7/8/15.
//
//
#import <UIKit/UIKit.h>
@protocol SloppySwiperViewControllerProtocol <NSObject>
- (UIBarStyle)ssw_navigationBarStyle;
- (UIColor *)ssw_navigationBarColor;
- (UIColor *)ssw_navigationBarItemColor;
- (UIImage *)ssw_navigationBarShadowImage;
@end
| //
// SloppySwiperViewControllerProtocol.h
// Pods
//
// Created by Yu Sugawara on 7/8/15.
//
//
#import <UIKit/UIKit.h>
@protocol SloppySwiperViewControllerProtocol <NSObject>
- (UIBarStyle)ssw_navigationBarStyle;
- (UIColor *)ssw_navigationBarColor;
- (UIColor *)ssw_navigationBarItemColor;
@optional
- (UIImage *)ssw_navigationBarShadowImage;
@end
|
Update master branch version to 1.3 | //-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
#define CHAKRA_CORE_MAJOR_VERSION 1
#define CHAKRA_CORE_MINOR_VERSION 2
#define CHAKRA_CORE_VERSION_RELEASE 0
#define CHAKRA_CORE_VERSION_PRERELEASE 0
#define CHAKRA_CORE_VERSION_RELEASE_QFE 0
#define CHAKRA_VERSION_RELEASE 0
// NOTE: need to update the GUID in ByteCodeCacheReleaseFileVersion.h as well
| //-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
#define CHAKRA_CORE_MAJOR_VERSION 1
#define CHAKRA_CORE_MINOR_VERSION 3
#define CHAKRA_CORE_VERSION_RELEASE 0
#define CHAKRA_CORE_VERSION_PRERELEASE 0
#define CHAKRA_CORE_VERSION_RELEASE_QFE 0
#define CHAKRA_VERSION_RELEASE 0
// NOTE: need to update the GUID in ByteCodeCacheReleaseFileVersion.h as well
|
Add stub for XYZ coordinates. | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2021 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
| |
Return const & from getters | #ifndef SUBSCRIPTION_H
#define SUBSCRIPTION_H
#include <memory>
#include <sstream>
#include <string>
#include "../../message.h"
#include "../../result.h"
class WindowsWorkerPlatform;
class Subscription
{
public:
Subscription(ChannelID channel,
HANDLE root,
const std::wstring &path,
bool recursive,
WindowsWorkerPlatform *platform);
~Subscription();
Result<bool> schedule(LPOVERLAPPED_COMPLETION_ROUTINE fn);
Result<> use_network_size();
BYTE *get_written(DWORD written_size);
Result<std::string> get_root_path();
std::wstring make_absolute(const std::wstring &sub_path);
Result<> stop(const CommandID command);
CommandID get_command_id() const { return command; }
ChannelID get_channel() const { return channel; }
WindowsWorkerPlatform *get_platform() const { return platform; }
bool is_terminating() const { return terminating; }
private:
CommandID command;
ChannelID channel;
WindowsWorkerPlatform *platform;
std::wstring path;
HANDLE root;
OVERLAPPED overlapped;
bool recursive;
bool terminating;
DWORD buffer_size;
std::unique_ptr<BYTE[]> buffer;
std::unique_ptr<BYTE[]> written;
};
#endif
| #ifndef SUBSCRIPTION_H
#define SUBSCRIPTION_H
#include <memory>
#include <sstream>
#include <string>
#include "../../message.h"
#include "../../result.h"
class WindowsWorkerPlatform;
class Subscription
{
public:
Subscription(ChannelID channel,
HANDLE root,
const std::wstring &path,
bool recursive,
WindowsWorkerPlatform *platform);
~Subscription();
Result<bool> schedule(LPOVERLAPPED_COMPLETION_ROUTINE fn);
Result<> use_network_size();
BYTE *get_written(DWORD written_size);
Result<std::string> get_root_path();
std::wstring make_absolute(const std::wstring &sub_path);
Result<> stop(const CommandID command);
const CommandID &get_command_id() const { return command; }
const ChannelID &get_channel() const { return channel; }
WindowsWorkerPlatform *get_platform() const { return platform; }
const bool &is_recursive() const { return recursive; }
const bool &is_terminating() const { return terminating; }
private:
CommandID command;
ChannelID channel;
WindowsWorkerPlatform *platform;
std::wstring path;
HANDLE root;
OVERLAPPED overlapped;
bool recursive;
bool terminating;
DWORD buffer_size;
std::unique_ptr<BYTE[]> buffer;
std::unique_ptr<BYTE[]> written;
};
#endif
|
Use version with replaced \177 | #define L for(char*c=a[1],y;*c;)printf("%c%c%c%c",(y="w$]m.k{%\177o"[*c++-48])&u/4?33:32,y&u?95:32,y&u/2?33:32,*c?32:10);u*=8;
main(int u,char**a){u=1;L;L;L} | #define L for(char*c=a[1],y;*c;)printf("%c%c%c%c",(y="w$]m.k{%o"[*c++-48])&u/4?33:32,y&u?95:32,y&u/2?33:32,*c?32:10);u*=8;
main(int u,char**a){u=1;L;L;L} |
Add solution for problem 6 | #include <stdio.h>
#include <math.h>
#include "euler.h"
#define PROBLEM 6
#define ANSWER 25164150
int
main(int argc, char **argv)
{
double sum = 0, square = 0;
for(double x = 0; x <= 100; x++) {
sum += pow(x, 2.0);
square += x;
}
square = pow(square, 2.0);
double result = square - sum;
return check(PROBLEM, ANSWER, result);
}
| |
Add a new test case | // RUN: rm -fr %t.prof
// RUN: %clang_pgogen=%t.prof/ -o %t.gen.cs -O2 %s
// RUN: %t.gen.cs
// RUN: llvm-profdata merge -o %t.cs.profdata %t.prof/
// Check context sensitive profile
// RUN: %clang_profuse=%t.cs.profdata -O2 -emit-llvm -S %s -o - | FileCheck %s --check-prefix=CS
//
// RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
// RUN: %t.gen.cis
// RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
// Check context insenstive profile
// RUN: %clang_profuse=%t.cis.profdata -O2 -emit-llvm -S %s -o - | FileCheck %s --check-prefix=CIS
int g1 = 1;
int g2 = 2;
static void toggle(int t) {
if (t & 1)
g1 *= t;
else
g2 *= t;
}
int main() {
int i;
// CS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]
// CIS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD:[0-9]+]]
toggle(g1);
// CS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]]
// CIS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD:[0-9]+]]
toggle(g2);
return 0;
}
// CS: ![[PD1]] = !{!"branch_weights", i32 0, i32 1}
// CS: ![[PD2]] = !{!"branch_weights", i32 1, i32 0}
// CIS: ![[PD]] = !{!"branch_weights", i32 2, i32 2}
| |
Move nullable to the property attributes | //
// RZFReleaseNotes.h
// FreshAir
//
// Created by Brian King on 1/26/16.
// Copyright © 2016 Raizlabs. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class RZFRelease, RZFFeature;
@interface RZFReleaseNotes : NSObject
+ (instancetype)releaseNotesWithURL:(NSURL *)URL error:(NSError **)error;
+ (instancetype)releaseNotesWithData:(NSData *)data error:(NSError **)error;
@property (strong, nonatomic) NSArray<RZFRelease *> *releases;
@property (strong, nonatomic) NSURL *upgradeURL;
@property (strong, nonatomic) NSString * __nullable minimumVersion;
@property (strong, nonatomic, readonly) NSArray<RZFFeature *> *features;
- (BOOL)isUpgradeRequiredForVersion:(NSString *)version;
- (NSArray<RZFRelease *> *)releasesSupportingSystemVersion:(NSString *)systemVersion;
- (NSArray<RZFFeature *> *)featuresFromVersion:(NSString *)lastVersion toVersion:(NSString *)currentVersion;
@end
NS_ASSUME_NONNULL_END | //
// RZFReleaseNotes.h
// FreshAir
//
// Created by Brian King on 1/26/16.
// Copyright © 2016 Raizlabs. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class RZFRelease, RZFFeature;
@interface RZFReleaseNotes : NSObject
+ (instancetype)releaseNotesWithURL:(NSURL *)URL error:(NSError **)error;
+ (instancetype)releaseNotesWithData:(NSData *)data error:(NSError **)error;
@property (strong, nonatomic) NSArray<RZFRelease *> *releases;
@property (strong, nonatomic) NSURL *upgradeURL;
@property (strong, nonatomic, nullable) NSString *minimumVersion;
@property (strong, nonatomic, readonly) NSArray<RZFFeature *> *features;
- (BOOL)isUpgradeRequiredForVersion:(NSString *)version;
- (NSArray<RZFRelease *> *)releasesSupportingSystemVersion:(NSString *)systemVersion;
- (NSArray<RZFFeature *> *)featuresFromVersion:(NSString *)lastVersion toVersion:(NSString *)currentVersion;
@end
NS_ASSUME_NONNULL_END |
Change to a more standard errno in pt_strerror_r() |
#include <assert.h>
#include <string.h>
#include <errno.h>
#include "pt_error.h"
static struct {
const enum pt_error err;
const char* const str;
} pt_error_map[PT_LAST] = {
{ PT_SUCCESS, "Success" },
};
static char* pt_strncpy(char* dst, const char* src, size_t n)
{
if(n > 0) {
int len = strnlen(src, n);
(void) memcpy(dst, src, len - 1);
dst[len] = '\0';
}
return dst;
}
int pt_strerror_r(enum pt_error err, char* buf, size_t len)
{
int ret = 0;
if(len > 0) {
if(err < PT_LAST && err >= PT_SUCCESS) {
assert(err == pt_error_map[err].err);
(void) pt_strncpy(buf, pt_error_map[err].str, len);
if(strlen(pt_error_map[err].str) >= len) {
errno = EOVERFLOW;
ret = 1;
}
} else {
errno = EINVAL;
ret = 1;
}
}
return ret;
}
|
#include <assert.h>
#include <string.h>
#include <errno.h>
#include "pt_error.h"
static struct {
const enum pt_error err;
const char* const str;
} pt_error_map[PT_LAST] = {
{ PT_SUCCESS, "Success" },
};
static char*
pt_strncpy(char* dst, const char* src, size_t n)
{
if(n > 0) {
int len = strnlen(src, n);
(void) memcpy(dst, src, len - 1);
dst[len] = '\0';
}
return dst;
}
int
pt_strerror_r(enum pt_error err, char* buf, size_t len)
{
int ret = 0;
if(len > 0) {
if(err < PT_LAST && err >= PT_SUCCESS) {
assert(err == pt_error_map[err].err);
(void) pt_strncpy(buf, pt_error_map[err].str, len);
if(strlen(pt_error_map[err].str) >= len) {
errno = ERANGE;
ret = 1;
}
} else {
errno = EINVAL;
ret = 1;
}
}
return ret;
}
|
Test commit in feature branch | file4.c - r1
Test checkin in master1-updated
Test checkin in master2
| file4.c - r1
Test checkin in master1-updated - updated2
Test checkin in master2
Test checkin in master3
|
Add test case for hidden alias | #include <stdlib.h>
volatile int func() {
return 4;
}
volatile int func2() __attribute__ ((visibility ("hidden"), alias ("func")));
int main() {
if (func2() != 4) {
abort();
}
}
| |
Add unicode to supported type codes | #pragma once
namespace turbodbc {
/**
* This enumeration assigns integer values to certain database types
*/
enum class type_code : int {
boolean = 0, ///< boolean type
integer = 10, ///< integer types
floating_point = 20, ///< floating point types
string = 30, ///< string types
timestamp = 40, ///< timestamp types
date = 41 ///< date type
};
}
| #pragma once
namespace turbodbc {
/**
* This enumeration assigns integer values to certain database types
*/
enum class type_code : int {
boolean = 0, ///< boolean type
integer = 10, ///< integer types
floating_point = 20, ///< floating point types
string = 30, ///< string types
unicode = 31, ///< unicode types
timestamp = 40, ///< timestamp types
date = 41 ///< date type
};
}
|
Convert this test to FileCheck instead of grepping LLVM IR. | // RUN: %clang_cc1 -emit-llvm < %s | grep 'fastcallcc' | count 6
// RUN: %clang_cc1 -emit-llvm < %s | grep 'stdcallcc' | count 6
void __attribute__((fastcall)) f1(void);
void __attribute__((stdcall)) f2(void);
void __attribute__((fastcall)) f3(void) {
f1();
}
void __attribute__((stdcall)) f4(void) {
f2();
}
// PR5280
void (__attribute__((fastcall)) *pf1)(void) = f1;
void (__attribute__((stdcall)) *pf2)(void) = f2;
void (__attribute__((fastcall)) *pf3)(void) = f3;
void (__attribute__((stdcall)) *pf4)(void) = f4;
int main(void) {
f3(); f4();
pf1(); pf2(); pf3(); pf4();
return 0;
}
| // RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
void __attribute__((fastcall)) f1(void);
void __attribute__((stdcall)) f2(void);
void __attribute__((fastcall)) f3(void) {
// CHECK: define x86_fastcallcc void @f3()
f1();
// CHECK: call x86_fastcallcc void @f1()
}
void __attribute__((stdcall)) f4(void) {
// CHECK: define x86_stdcallcc void @f4()
f2();
// CHECK: call x86_stdcallcc void @f2()
}
// PR5280
void (__attribute__((fastcall)) *pf1)(void) = f1;
void (__attribute__((stdcall)) *pf2)(void) = f2;
void (__attribute__((fastcall)) *pf3)(void) = f3;
void (__attribute__((stdcall)) *pf4)(void) = f4;
int main(void) {
f3(); f4();
// CHECK: call x86_fastcallcc void @f3()
// CHECK: call x86_stdcallcc void @f4()
pf1(); pf2(); pf3(); pf4();
// CHECK: call x86_fastcallcc void %tmp()
// CHECK: call x86_stdcallcc void %tmp1()
// CHECK: call x86_fastcallcc void %tmp2()
// CHECK: call x86_stdcallcc void %tmp3()
return 0;
}
|
Fix client crash from changing item to nothing | #include "server/client.h"
#include "server/packet.h"
#include "blocks/items.h"
void packet_send_entity_equipment(struct client *client, struct client *c, uint16_t slot, struct item *item, uint16_t damage)
{
bedrock_packet packet;
struct item_stack stack;
stack.id = item->id;
stack.count = 1;
stack.metadata = damage;
packet_init(&packet, SERVER_ENTITY_EQUIPMENT);
packet_pack_int(&packet, &c->id, sizeof(c->id));
packet_pack_int(&packet, &slot, sizeof(slot));
packet_pack_slot(&packet, &stack);
client_send_packet(client, &packet);
}
| #include "server/client.h"
#include "server/packet.h"
#include "blocks/items.h"
void packet_send_entity_equipment(struct client *client, struct client *c, uint16_t slot, struct item *item, uint16_t damage)
{
bedrock_packet packet;
struct item_stack stack;
stack.id = item->id ? item->id : -1;
stack.count = 1;
stack.metadata = damage;
packet_init(&packet, SERVER_ENTITY_EQUIPMENT);
packet_pack_int(&packet, &c->id, sizeof(c->id));
packet_pack_int(&packet, &slot, sizeof(slot));
packet_pack_slot(&packet, &stack);
client_send_packet(client, &packet);
}
|
Use placement new to initalise objects |
#pragma once
template<class T, size_t BufferSize, class StarvationCallbacks>
class AllocationPool {
public:
~AllocationPool()
{
while (!m_FreeList.empty())
{
delete m_FreeList.front();
m_FreeList.pop_front();
}
}
T* Allocate()
{
if (m_FreeList.Size() <= BufferSize)
{
try
{
return new T;
}
catch (std::bad_alloc& ex)
{
if (m_FreeList.size() == BufferSize)
{
StarvationCallbacks.OnStartingUsingBuffer();
}
else if (m_FreeList.empty())
{
StarvationCallbacks.OnBufferEmpty();
// Try again until the memory is avalable
return Allocate();
}
}
}
T* ret = m_FreeList.front();
m_FreeList.pop_front();
return ret;
}
void Free(T* ptr)
{
m_FreeList.push_front(ptr);
if (m_FreeList.size() == BufferSize)
{
StarvationCallbacks.OnStopUsingBuffer();
}
}
private:
std::list<T*> m_FreeList;
}
|
#pragma once
template<class T, size_t BufferSize, class StarvationCallbacks>
class AllocationPool {
public:
~AllocationPool()
{
while (!m_FreeList.empty())
{
delete m_FreeList.front();
m_FreeList.pop_front();
}
}
T* Allocate()
{
if (m_FreeList.Size() <= BufferSize)
{
try
{
return new T;
}
catch (std::bad_alloc& ex)
{
if (m_FreeList.size() == BufferSize)
{
StarvationCallbacks.OnStartingUsingBuffer();
}
else if (m_FreeList.empty())
{
StarvationCallbacks.OnBufferEmpty();
// Try again until the memory is avalable
return Allocate();
}
}
}
// placement new, used to initalize the object
T* ret = new (m_FreeList.front()) T;
m_FreeList.pop_front();
return ret;
}
void Free(T* ptr)
{
// placement destruct.
ptr->~T();
m_FreeList.push_front(ptr);
if (m_FreeList.size() == BufferSize)
{
StarvationCallbacks.OnStopUsingBuffer();
}
}
private:
std::list<void *> m_FreeList;
}
|
Write more brief function descriptions. | #ifndef CORRCHECK_H
#define CORRCHECK_H
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <dirent.h>
#include <iostream>
#include <map>
#include <openssl/ssl.h>
#include <string>
#include <sys/stat.h>
#include <vector>
#include "corrcheck_defines.h"
#include "File.h"
int create_database(const std::string& directory);
int update_database();
int verify_database(const std::string& directory);
int write_database(const std::string& directory, const File* file_list);
#endif
| #ifndef CORRCHECK_H
#define CORRCHECK_H
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <dirent.h>
#include <iostream>
#include <map>
#include <openssl/ssl.h>
#include <string>
#include <sys/stat.h>
#include <vector>
#include "corrcheck_defines.h"
#include "File.h"
/*
Create a .corrcheckdb of the files in a directory given by 'directory'.
Returns SUCCESS (0) if no errors occur; returns FAILURE (1) otherwise.
*/
int create_database(const std::string& directory);
/*
---NOT IMPLEMENTED---
Rewrite the .corrcheckdb of the files in a directory while notifying of
apparent changes since creation or last update.
*/
int update_database();
/*
Check the .corrcheckdb of the files in a directory given by 'directory' and
notify of apparent changes since creation or last update. This function does not
modify the .corrcheckdb file.
*/
int verify_database(const std::string& directory);
/*
Write a .corrcheckdb in the directory given by 'directory' based on the list of
files given as 'file_list', overwriting any that may already be present.
*/
int write_database(const std::string& directory, const File* file_list);
#endif
|
Expand web::BrowserState to add GetPath() method | // Copyright 2013 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 IOS_WEB_PUBLIC_BROWSER_STATE_H_
#define IOS_WEB_PUBLIC_BROWSER_STATE_H_
#include "base/supports_user_data.h"
namespace net {
class URLRequestContextGetter;
}
namespace web {
// This class holds the context needed for a browsing session.
// It lives on the UI thread. All these methods must only be called on the UI
// thread.
class BrowserState : public base::SupportsUserData {
public:
~BrowserState() override;
// Return whether this BrowserState is incognito. Default is false.
virtual bool IsOffTheRecord() const = 0;
// Returns the request context information associated with this
// BrowserState.
virtual net::URLRequestContextGetter* GetRequestContext() = 0;
protected:
BrowserState();
};
} // namespace web
#endif // IOS_WEB_PUBLIC_BROWSER_STATE_H_
| // Copyright 2013 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 IOS_WEB_PUBLIC_BROWSER_STATE_H_
#define IOS_WEB_PUBLIC_BROWSER_STATE_H_
#include "base/supports_user_data.h"
namespace base {
class FilePath;
}
namespace net {
class URLRequestContextGetter;
}
namespace web {
// This class holds the context needed for a browsing session.
// It lives on the UI thread. All these methods must only be called on the UI
// thread.
class BrowserState : public base::SupportsUserData {
public:
~BrowserState() override;
// Return whether this BrowserState is incognito. Default is false.
virtual bool IsOffTheRecord() const = 0;
// Retrieves the path where the BrowserState data is stored.
virtual base::FilePath GetPath() const = 0;
// Returns the request context information associated with this
// BrowserState.
virtual net::URLRequestContextGetter* GetRequestContext() = 0;
protected:
BrowserState();
};
} // namespace web
#endif // IOS_WEB_PUBLIC_BROWSER_STATE_H_
|
Add level field in playercontroller | #ifndef SCORE_H_INCLUDED
#define SCORE_H_INCLUDED
#define FOOD1_SCORE 15 //Titik
#define FOOD2_SCORE 100 //Sedap Malam
#define FOOD3_SCORE 300 //Menyan
#define FOOD4_SCORE 500 //Melati
#define FOOD5_SCORE 700 //Kopi Hitam
typedef struct{
char *name;
int score;
int lives;
int foodCount;
pacmanController peciman;
ghostController ghost1;
ghostController ghost2;
ghostController ghost3;
ghostController ghost4;
} playerControl;
void initScore(playerControl *player);
void initLives(playerControl *player);
void incScore(int food, playerControl *player);
void eatFood(playerControl *player);
void incLives(playerControl *player, int *liveGiven);
int randomise(int min, int max);
int foodType(int x);
void spawnFood(MapController *map, int posX, int posY);
void despawnFood(MapController *map, int posX, int posY);
void randFoodPos();
void drawNumber(int x, int posX, int posY, int posisi);
void printScore(int score, int posX, int posY);
void printLives(int lives, int posX, int posY);
#endif // SCORE_H_INCLUDED
| #ifndef SCORE_H_INCLUDED
#define SCORE_H_INCLUDED
#define FOOD1_SCORE 15 //Titik
#define FOOD2_SCORE 100 //Sedap Malam
#define FOOD3_SCORE 300 //Menyan
#define FOOD4_SCORE 500 //Melati
#define FOOD5_SCORE 700 //Kopi Hitam
typedef struct{
char *name;
int score;
int lives;
int foodCount;
int level;
pacmanController peciman;
ghostController ghost1;
ghostController ghost2;
ghostController ghost3;
ghostController ghost4;
} playerControl;
void initScore(playerControl *player);
void initLives(playerControl *player);
void incScore(int food, playerControl *player);
void eatFood(playerControl *player);
void incLives(playerControl *player, int *liveGiven);
int randomise(int min, int max);
int foodType(int x);
void spawnFood(MapController *map, int posX, int posY);
void despawnFood(MapController *map, int posX, int posY);
void randFoodPos();
void drawNumber(int x, int posX, int posY, int posisi);
void printScore(int score, int posX, int posY);
void printLives(int lives, int posX, int posY);
#endif // SCORE_H_INCLUDED
|
Remove extraneous ; on function definition | #pragma once
#include <cstdint>
inline uint16_t compose_bytes(const uint8_t low, const uint8_t high) {
return (high << 8) + low;
};
inline bool check_bit(const uint8_t value, int bit) {
return (value & (1 << bit)) != 0;
};
inline uint8_t set_bit(const uint8_t value, int bit) {
return static_cast<uint8_t>(value | (1 << bit));
}
| #pragma once
#include <cstdint>
inline uint16_t compose_bytes(const uint8_t low, const uint8_t high) {
return (high << 8) + low;
}
inline bool check_bit(const uint8_t value, int bit) {
return (value & (1 << bit)) != 0;
}
inline uint8_t set_bit(const uint8_t value, int bit) {
return static_cast<uint8_t>(value | (1 << bit));
}
|
Add support for MS 'EVEN' directive | // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fasm-blocks -emit-llvm -o - | FileCheck %s
// CHECK: .byte 64
// CHECK: .byte 64
// CHECK: .byte 64
// CHECK: .even
void t1() {
__asm {
.byte 64
.byte 64
.byte 64
EVEN
mov eax, ebx
}
}
| // REQUIRES: x86-registered-target
// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
// CHECK: .byte 64
// CHECK: .byte 64
// CHECK: .byte 64
// CHECK: .even
void t1() {
__asm {
.byte 64
.byte 64
.byte 64
EVEN
mov eax, ebx
}
}
|
Add Chapter 27, exercise 14 | /* Chapter 27, exercise 14: write a function that takes an array of int as input
and finds the smallest and the largest elements as well as the median and
mean; return the result in a struct holding the values */
#include<stddef.h>
#include<string.h>
#include<stdlib.h>
#include<assert.h>
#include<stdio.h>
struct Result {
int min;
int max;
double median;
double mean;
};
int cmpint(const void* a, const void* b)
{
int aa = *(int*)a;
int bb = *(int*)b;
if (aa<bb)
return -1;
else if (bb<aa)
return 1;
else
return 0;
}
int array_sum(int* int_array, size_t size)
{
int sum = 0;
int i;
for (i = 0; i<size; ++i)
sum += int_array[i];
return sum;
}
struct Result* array_data(int* int_array, size_t size)
{
assert(int_array);
assert(size > 0);
{
int* array_cpy = (int*)malloc(size*sizeof(int)); /* copy to play with */
struct Result* res = (struct Result*)malloc(sizeof(struct Result));
memcpy(array_cpy,int_array,size*sizeof(int));
qsort(array_cpy,size,sizeof(int),cmpint);
res->min = array_cpy[0];
res->max = array_cpy[size-1];
if (size % 2) /* odd number of elements */
res->median = array_cpy[size/2];
else /* even number - median is mean of two elements */
res->median = (array_cpy[size/2-1] + array_cpy[size/2]) / 2.0;
res->mean = (double)array_sum(int_array,size) / size;
free(array_cpy);
return res;
}
}
void print_result(struct Result* res)
{
printf("min: %d\nmax: %d\nmean: %f\nmedian: %f\n",
res->min,res->max,res->mean,res->median);
}
int main()
{
int arr1[] = { 3, 2, 5, 4, 1 };
int arr2[] = { 5, 1, 7, 4, 8, 4 };
struct Result* res1 = array_data(arr1,sizeof(arr1)/sizeof(int));
struct Result* res2 = array_data(arr2,sizeof(arr2)/sizeof(int));
printf("arr1:\n");
print_result(res1);
printf("\narr2:\n");
print_result(res2);
free(res1);
free(res2);
}
| |
Add two more check to x.chk_env a) make sure host name have at least one dot b) add a http test | #include <stdio.h>
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
#endif
int
gethost_main()
{
extern char *sccs_gethost();
char *host;
#ifdef WIN32
setmode(1, _O_BINARY);
#endif
host = sccs_gethost();
if ((host == NULL) || (*host == '\0')) return (1);
printf("%s\n", host);
return (0);
}
| #include <stdio.h>
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
#endif
int
gethost_main()
{
extern char *sccs_gethost();
char *host;
#ifdef WIN32
setmode(1, _O_BINARY);
#endif
host = sccs_gethost();
if ((host == NULL) || (*host == '\0')) return (1);
printf("%s\n", host);
/* make isure we have a good domain name */
if (strchr(host, '.') == NULL) return (1);
return (0);
}
|
Refactor render method to make it simpler | #ifndef RASTERIZER_H
#define RASTERIZER_H
#include <string>
#include "Renderer.h"
class Rasterizer : public Renderer {
private:
const float k_a = 0.1;
const RGBColor AMBIENT_COLOR = RGBColor(1.0f, 1.0f, 1.0f);
public:
Rasterizer();
Rasterizer(World* world, const uint16_t image_width, const uint16_t image_height);
~Rasterizer();
const RGBColor shade(const GeometryObject& object, const Triangle3D& triangle, const Point3D point_in_triangle) const override;
void render(const std::string output_path) override;
private:
const RGBColor phongShading(const Material& material, const RGBColor& base_color, const Triangle3D& triangle, const Point3D& point_in_triangle) const;
const RGBColor blinnPhongShading(const Material& material, const RGBColor& base_color, const Triangle3D& triangle, const Point3D& point_in_triangle) const;
};
#endif /* RASTERIZER_H */
| #ifndef RASTERIZER_H
#define RASTERIZER_H
#include <string>
#include "Renderer.h"
class Rasterizer : public Renderer {
private:
const float k_a = 0.1;
const RGBColor AMBIENT_COLOR = RGBColor(1.0f, 1.0f, 1.0f);
public:
Rasterizer();
Rasterizer(World* world, const uint16_t image_width, const uint16_t image_height);
~Rasterizer();
const RGBColor shade(const GeometryObject& object, const Triangle3D& triangle, const Point3D point_in_triangle) const override;
void render(const std::string output_path) override;
private:
const Triangle2D toRaster(const Triangle3D& triangle_world) const;
const float getDepth(const Triangle3D& triangle_world, const Triangle2D& triangle_raster, const Point2D& pixel_raster) const;
const RGBColor phongShading(const Material& material, const RGBColor& base_color, const Triangle3D& triangle, const Point3D& point_in_triangle) const;
const RGBColor blinnPhongShading(const Material& material, const RGBColor& base_color, const Triangle3D& triangle, const Point3D& point_in_triangle) const;
};
#endif /* RASTERIZER_H */
|
Print welcome message with application name and newline. | /* shadowVIC – Copyright (c) 2015 Sven Michael Klose <pixel@hugbox.org> */
#include <stdio.h>
#include "types.h"
#include "config.h"
#include "6502.h"
#include "shadowvic.h"
#include "joystick.h"
#include "video.h"
#include "sync.h"
#define FALSE 0
#define TRUE 1
int
main (int argc, char * argv[])
{
struct vic20_config config = {
.is_expanded = FALSE,
.use_paddles = FALSE,
.manual_screen_updates = FALSE,
.frames_per_second = 50,
.frame_interceptor = NULL
};
printf ("shadowVIC – https://github.com/SvenMichaelKlose/shadowvic/");
joystick_open ();
video_open ();
video_map ();
vic20_open (&config);
vic20_emulate (m[0xfffc] + (m[0xfffd] << 8));
vic20_close ();
video_close ();
joystick_close ();
return 0;
}
| /* shadowVIC – Copyright (c) 2015 Sven Michael Klose <pixel@hugbox.org> */
#include <stdio.h>
#include "types.h"
#include "config.h"
#include "6502.h"
#include "shadowvic.h"
#include "joystick.h"
#include "video.h"
#include "sync.h"
#define FALSE 0
#define TRUE 1
int
main (int argc, char * argv[])
{
struct vic20_config config = {
.is_expanded = FALSE,
.use_paddles = FALSE,
.manual_screen_updates = FALSE,
.frames_per_second = 50,
.frame_interceptor = NULL
};
printf ("picoVIC – https://github.com/SvenMichaelKlose/shadowvic/\n");
joystick_open ();
video_open ();
video_map ();
vic20_open (&config);
vic20_emulate (m[0xfffc] + (m[0xfffd] << 8));
vic20_close ();
video_close ();
joystick_close ();
return 0;
}
|
Send '0x5A' across UART continuously. |
#include "main.h"
#include <msp430.h>
#include "led_driver.h"
int main(void)
{
WDTCTL = WDTPW + WDTHOLD;
led_initialize((led_addresses_s*)P1IN_);
P1DIR = 0x04;
P1SEL = 0x06;
UCA0CTL0 = 0x00;
UCA0CTL1 = UCSSEL_3;
UCA0BR0 = 104;
UCA0BR1 = 0x00;
UCA0MCTL = 0x03 << 4;
set_led_color(LED_GREEN);
while(1)
{
if(UCA0STAT & 0x01 == 0x00)
{
UCA0TXBUF = 0x5a;
}
}
}
|
#include "main.h"
#include <msp430.h>
#include "led_driver.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
//Set clock to 1MHz
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
led_initialize((led_addresses_s*)P1IN_);
P1DIR |= 0x04;
P1SEL |= 0x06;
P1SEL2 |= 0x06;
UCA0CTL0 |= 0x00;
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 = 104;
UCA0BR1 = 0x00;
UCA0MCTL = UCBRS0;
UCA0CTL1 &= ~UCSWRST;
set_led_color(LED_GREEN);
while(1)
{
if((IFG2 & UCA0TXIFG) == UCA0TXIFG)
{
UCA0TXBUF = 0x5a;
}
//IE2 |= UCA0TXIE; // Enable USCI_A0 TX interrupt
//__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
}
#pragma vector=USCIAB0TX_VECTOR
__interrupt void TX_Ready(void)
{
if((IFG2 & UCA0TXIFG) == UCA0TXIFG)
{
UCA0TXBUF = 0x5a;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.