Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Update Skia milestone to 100 | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 99
#endif
| /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 100
#endif
|
Tweak a minor alignment issue. | #pragma once
#include "helpers.h"
#include "nvidia_interface_datatypes.h"
#include <vector>
#include <memory>
class NvidiaGPU;
class NVLIB_EXPORTED NvidiaApi
{
public:
NvidiaApi();
~NvidiaApi();
int getGPUCount();
std::shared_ptr<NvidiaGPU> getGPU(int index);
private:
bool GPUloaded = false;
std::vector<std::shared_ptr<NvidiaGPU>> gpus;
bool ensureGPUsLoaded();
};
class NVLIB_EXPORTED NvidiaGPU
{
public:
friend class NvidiaApi;
float getCoreClock();
float getMemoryClock();
float getGPUUsage();
float getFBUsage();
float getVidUsage();
float getBusUsage();
private:
NV_PHYSICAL_GPU_HANDLE handle;
NvidiaGPU(NV_PHYSICAL_GPU_HANDLE handle);
struct NVIDIA_CLOCK_FREQUENCIES frequencies;
bool reloadFrequencies();
float getClockForSystem(NVIDIA_CLOCK_SYSTEM system);
float getUsageForSystem(NVIDIA_DYNAMIC_PSTATES_SYSTEM system);
};
| #pragma once
#include "helpers.h"
#include "nvidia_interface_datatypes.h"
#include <vector>
#include <memory>
class NvidiaGPU;
class NVLIB_EXPORTED NvidiaApi
{
public:
NvidiaApi();
~NvidiaApi();
int getGPUCount();
std::shared_ptr<NvidiaGPU> getGPU(int index);
private:
std::vector<std::shared_ptr<NvidiaGPU>> gpus;
bool ensureGPUsLoaded();
bool GPUloaded = false;
};
class NVLIB_EXPORTED NvidiaGPU
{
public:
friend class NvidiaApi;
float getCoreClock();
float getMemoryClock();
float getGPUUsage();
float getFBUsage();
float getVidUsage();
float getBusUsage();
private:
NV_PHYSICAL_GPU_HANDLE handle;
NvidiaGPU(NV_PHYSICAL_GPU_HANDLE handle);
struct NVIDIA_CLOCK_FREQUENCIES frequencies;
bool reloadFrequencies();
float getClockForSystem(NVIDIA_CLOCK_SYSTEM system);
float getUsageForSystem(NVIDIA_DYNAMIC_PSTATES_SYSTEM system);
};
|
Bump portable version to 0.2.6-pre | #define PORTABLE_VERSION_TEXT "0.2.5"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 5
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 1
| #define PORTABLE_VERSION_TEXT "0.2.6-pre"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 6
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 0
|
Update portable version to unreleased | #define PORTABLE_VERSION_TEXT "0.2.4"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 4
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 1
| #define PORTABLE_VERSION_TEXT "0.2.5-pre"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 5
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 0
|
Rewrite of odd/even number program for arbitrary number of inputs using switch statement | /* lab4.c: Read integers and print out the sum of all even and odd
* numbers separately */
#include <stdio.h>
int main() {
int num = 0;
int even_sum = 0;
int odd_sum = 0;
do {
printf("Enter an integer: ");
fflush(stdout);
scanf("%d",&num);
switch (num % 2) {
case 0:
even_sum += num;
break;
default:
odd_sum += num;
}
} while (num != 0);
printf("Sum of evens: %d\n", even_sum);
printf("Sum of odds: %d\n", odd_sum);
return 0;
} | |
Handle Ctrl-Z to suspend the process. | #include <stdio.h>
#include <stdlib.h>
#include <termbox.h>
#include "editor.h"
#include "util.h"
int main(int argc, char *argv[]) {
debug_init();
editor_t editor;
cursor_t cursor;
editor_init(&editor, &cursor, argc > 1 ? argv[1] : NULL);
int err = tb_init();
if (err) {
fprintf(stderr, "tb_init() failed with error code %d\n", err);
return 1;
}
atexit(tb_shutdown);
editor_draw(&editor);
struct tb_event ev;
while (tb_poll_event(&ev)) {
switch (ev.type) {
case TB_EVENT_KEY:
editor_handle_key_press(&editor, &ev);
break;
case TB_EVENT_RESIZE:
editor_draw(&editor);
break;
default:
break;
}
}
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <termbox.h>
#include "editor.h"
#include "util.h"
// termbox catches ctrl-z as a regular key event. To suspend the process as
// normal, manually raise SIGTSTP.
//
// Not 100% sure why we need to shutdown termbox, but the terminal gets all
// weird if we don't. Mainly copied this approach from here:
// https://github.com/nsf/godit/blob/master/suspend_linux.go
static void suspend(editor_t *editor) {
tb_shutdown();
raise(SIGTSTP);
int err = tb_init();
if (err) {
fprintf(stderr, "tb_init() failed with error code %d\n", err);
exit(1);
}
editor_draw(editor);
}
int main(int argc, char *argv[]) {
debug_init();
editor_t editor;
cursor_t cursor;
editor_init(&editor, &cursor, argc > 1 ? argv[1] : NULL);
int err = tb_init();
if (err) {
fprintf(stderr, "tb_init() failed with error code %d\n", err);
return 1;
}
atexit(tb_shutdown);
editor_draw(&editor);
struct tb_event ev;
while (tb_poll_event(&ev)) {
switch (ev.type) {
case TB_EVENT_KEY:
if (ev.key == TB_KEY_CTRL_Z) {
suspend(&editor);
} else {
editor_handle_key_press(&editor, &ev);
}
break;
case TB_EVENT_RESIZE:
editor_draw(&editor);
break;
default:
break;
}
}
return 0;
}
|
Use low end of supervisor heap | #ifndef MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
#define MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
#include <stdbool.h>
#include "py/gc.h"
#include "py/misc.h"
#include "supervisor/memory.h"
#define _PM_ALLOCATOR _PM_allocator_impl
#define _PM_FREE(x) (_PM_free_impl((x)), (x)=NULL, (void)0)
static inline void *_PM_allocator_impl(size_t sz) {
if (gc_alloc_possible()) {
return m_malloc(sz + sizeof(void*), true);
} else {
supervisor_allocation *allocation = allocate_memory(align32_size(sz), true);
return allocation ? allocation->ptr : NULL;
}
}
static inline void _PM_free_impl(void *ptr_in) {
supervisor_allocation *allocation = allocation_from_ptr(ptr_in);
if (allocation) {
free_memory(allocation);
}
}
#endif
| #ifndef MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
#define MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
#include <stdbool.h>
#include "py/gc.h"
#include "py/misc.h"
#include "supervisor/memory.h"
#define _PM_ALLOCATOR _PM_allocator_impl
#define _PM_FREE(x) (_PM_free_impl((x)), (x)=NULL, (void)0)
static inline void *_PM_allocator_impl(size_t sz) {
if (gc_alloc_possible()) {
return m_malloc(sz + sizeof(void*), true);
} else {
supervisor_allocation *allocation = allocate_memory(align32_size(sz), false);
return allocation ? allocation->ptr : NULL;
}
}
static inline void _PM_free_impl(void *ptr_in) {
supervisor_allocation *allocation = allocation_from_ptr(ptr_in);
if (allocation) {
free_memory(allocation);
}
}
#endif
|
Fix a missed file in previous change. | // -*- C++ -*-
#ifndef _writer_verilog_task_h_
#define _writer_verilog_task_h_
#include "writer/verilog/resource.h"
namespace iroha {
namespace writer {
namespace verilog {
class Task : public Resource {
public:
Task(const IResource &res, const Table &table);
virtual void BuildResource();
virtual void BuildInsn(IInsn *insn, State *st);
static bool IsTask(const Table &table);
static string TaskEnablePin(const ITable &tab, const ITable *caller);
static const int kTaskEntryStateId;
private:
void BuildTaskResource();
void BuildTaskCallResource();
void BuildCallWire(IResource *caller);
void BuildTaskCallInsn(IInsn *insn, State *st);
void AddPort(const IModule *mod, IResource *caller);
void AddWire(const IModule *mod, IResource *caller);
static string TaskPinPrefix(const ITable &tab, const ITable *caller);
static string TaskAckPin(const ITable &tab, const ITable *caller);
};
} // namespace verilog
} // namespace writer
} // namespace iroha
#endif // _writer_verilog_task_h_
| // -*- C++ -*-
#ifndef _writer_verilog_task_h_
#define _writer_verilog_task_h_
#include "writer/verilog/resource.h"
namespace iroha {
namespace writer {
namespace verilog {
class Task : public Resource {
public:
Task(const IResource &res, const Table &table);
virtual void BuildResource();
virtual void BuildInsn(IInsn *insn, State *st);
static bool IsTask(const Table &table);
static string TaskEnablePin(const ITable &tab, const ITable *caller);
static const int kTaskEntryStateId;
private:
void BuildTaskResource();
void BuildTaskCallResource();
void BuildCallWire(IResource *caller);
void BuildTaskCallInsn(IInsn *insn, State *st);
void AddPort(const IModule *mod, IResource *caller, bool upward);
void AddWire(const IModule *mod, IResource *caller);
static string TaskPinPrefix(const ITable &tab, const ITable *caller);
static string TaskAckPin(const ITable &tab, const ITable *caller);
};
} // namespace verilog
} // namespace writer
} // namespace iroha
#endif // _writer_verilog_task_h_
|
Update GameStateManager to use new base class name | /* The Halfling Project - A Graphics Engine and Projects
*
* The Halfling Project is the legal property of Adrian Astley
* Copyright Adrian Astley 2013
*/
#ifndef CRATE_DEMO_GAME_STATE_MANAGER_H
#define CRATE_DEMO_GAME_STATE_MANAGER_H
#include "common/game_state_manager_interface.h"
namespace CrateDemo {
class GameStateManager : public Common::IGameStateManager {
public:
GameStateManager();
private:
public:
bool Initialize();
void Shutdown();
/**
* Return the wanted period of time between update() calls.
*
* IE: If you want update to be called 20 times a second, this
* should return 50.
*
* NOTE: This should probably be inlined.
* NOTE: This will only be called at the beginning of HalflingEngine::Run()
* TODO: Contemplate the cost/benefit of calling this once per frame
*
* @return The period in milliseconds
*/
inline double GetUpdatePeriod() { return 30.0; }
/**
* Called every time the game logic should be updated. The frequency
* of this being called is determined by getUpdatePeriod()
*/
void Update();
void GamePaused();
void GameUnpaused();
};
} // End of namespace CrateDemo
#endif
| /* The Halfling Project - A Graphics Engine and Projects
*
* The Halfling Project is the legal property of Adrian Astley
* Copyright Adrian Astley 2013
*/
#ifndef CRATE_DEMO_GAME_STATE_MANAGER_H
#define CRATE_DEMO_GAME_STATE_MANAGER_H
#include "common/game_state_manager_base.h"
namespace CrateDemo {
class GameStateManager : public Common::GameStateManagerBase {
public:
GameStateManager();
private:
public:
bool Initialize();
void Shutdown();
/**
* Return the wanted period of time between update() calls.
*
* IE: If you want update to be called 20 times a second, this
* should return 50.
*
* NOTE: This should probably be inlined.
* NOTE: This will only be called at the beginning of HalflingEngine::Run()
* TODO: Contemplate the cost/benefit of calling this once per frame
*
* @return The period in milliseconds
*/
inline double GetUpdatePeriod() { return 30.0; }
/**
* Called every time the game logic should be updated. The frequency
* of this being called is determined by getUpdatePeriod()
*/
void Update();
void GamePaused();
void GameUnpaused();
};
} // End of namespace CrateDemo
#endif
|
Add Fibonacci algorithm in C | #include <stdio.h>
int i, v, num1 = 0, num2 = 1, temp;
int main() {
// Enter here number of times fib number is calculated;
scanf("%d", &v);
printf("Fibonacci numbers:");
for (i; i <= v; i++) {
// This prints fibonacci number;
printf("%d, ", num1);
// This calculates fibonacci number;
temp = num1 + num2;
num1 = num2;
num2 = temp;
}
return 0;
}
| |
Make sure that for AIX 3.2 we get ushort defined when we need it, but not doubly defined... | #if defined(__cplusplus) && !defined(OSF1) /* GNU G++ */
# include "fix_gnu_fcntl.h"
#elif defined(AIX32) /* AIX bsdcc */
typedef unsigned short ushort;
# include <fcntl.h>
#elif defined(HPUX9) /* HPUX 9 */
# define fcntl __condor_hide_fcntl
# include <fcntl.h>
# undef fcntl
int fcntl( int fd, int req, int arg );
#else /* Everybody else */
# include <fcntl.h>
#endif
| #if defined(__cplusplus) && !defined(OSF1) /* GNU G++ */
# include "fix_gnu_fcntl.h"
#elif defined(AIX32) /* AIX bsdcc */
# if !defined(_ALL_SOURCE)
typedef ushort_t ushort;
# endif
# include <fcntl.h>
#elif defined(HPUX9) /* HPUX 9 */
# define fcntl __condor_hide_fcntl
# include <fcntl.h>
# undef fcntl
int fcntl( int fd, int req, int arg );
#else /* Everybody else */
# include <fcntl.h>
#endif
|
Implement left and right macros | #ifndef TURING_H_
#define TURING_H_
#define TAPE_LEN 1024
#define turing_error(...) fprintf(stderr, __VA_ARGS__);\
return TURING_ERROR
typedef int bool;
typedef enum {
TURING_OK,
TURING_HALT,
TURING_ERROR
} turing_status_t;
typedef struct Turing {
bool *tape;
bool *p;
} Turing;
Turing *init_turing();
void free_turing(Turing *turing);
turing_status_t move_head(Turing *turing, int direction);
turing_status_t execute_instruction(Turing *turing, char *program);
turing_status_t execute_definite_instruction(Turing *turing, char *program);
#endif // TURING_H_
| #ifndef TURING_H_
#define TURING_H_
#define TAPE_LEN 1024
#define turing_error(...) fprintf(stderr, __VA_ARGS__);\
return TURING_ERROR
#define move_head_left(t) move_head(t, 0)
#define move_head_right(t) move_head(t, 1)
typedef int bool;
typedef enum {
TURING_OK,
TURING_HALT,
TURING_ERROR
} turing_status_t;
typedef struct Turing {
bool *tape;
bool *p;
} Turing;
Turing *init_turing();
void free_turing(Turing *turing);
turing_status_t move_head(Turing *turing, int direction);
turing_status_t execute_instruction(Turing *turing, char *program);
turing_status_t execute_definite_instruction(Turing *turing, char *program);
#endif // TURING_H_
|
Update registration version for 100.3 | // Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//
#ifndef ArcGISRuntimeToolkit_H
#define ArcGISRuntimeToolkit_H
#include <QQmlExtensionPlugin>
#include "ToolkitCommon.h"
namespace Esri
{
namespace ArcGISRuntime
{
namespace Toolkit
{
class TOOLKIT_EXPORT ArcGISRuntimeToolkit : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
explicit ArcGISRuntimeToolkit(QObject* parent = nullptr);
void registerTypes(const char* uri);
static void registerToolkitTypes(const char* uri = "Esri.ArcGISRuntime.Toolkit.CppApi");
private:
static constexpr int s_versionMajor = 100;
static constexpr int s_versionMinor = 2;
};
} // Toolkit
} // ArcGISRuntime
} // Esri
#endif // ArcGISRuntimeToolkit_H
| // Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//
#ifndef ArcGISRuntimeToolkit_H
#define ArcGISRuntimeToolkit_H
#include <QQmlExtensionPlugin>
#include "ToolkitCommon.h"
namespace Esri
{
namespace ArcGISRuntime
{
namespace Toolkit
{
class TOOLKIT_EXPORT ArcGISRuntimeToolkit : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
explicit ArcGISRuntimeToolkit(QObject* parent = nullptr);
void registerTypes(const char* uri);
static void registerToolkitTypes(const char* uri = "Esri.ArcGISRuntime.Toolkit.CppApi");
private:
static constexpr int s_versionMajor = 100;
static constexpr int s_versionMinor = 3;
};
} // Toolkit
} // ArcGISRuntime
} // Esri
#endif // ArcGISRuntimeToolkit_H
|
Use the new log API | #include "Enesim.h"
int main(int argc, char **argv)
{
Enesim_Renderer *r;
Enesim_Surface *s;
Enesim_Log *error = NULL;
enesim_init();
r = enesim_renderer_rectangle_new();
enesim_renderer_shape_fill_color_set(r, 0xffffffff);
/* we dont set any property to force the error */
s = enesim_surface_new(ENESIM_FORMAT_ARGB8888, 320, 240);
if (!enesim_renderer_draw(r, s, ENESIM_ROP_FILL, NULL, 0, 0, &error))
{
enesim_log_dump(error);
enesim_log_delete(error);
}
enesim_shutdown();
return 0;
}
| #include "Enesim.h"
int main(int argc, char **argv)
{
Enesim_Renderer *r;
Enesim_Surface *s;
Enesim_Log *error = NULL;
enesim_init();
r = enesim_renderer_rectangle_new();
enesim_renderer_shape_fill_color_set(r, 0xffffffff);
/* we dont set any property to force the error */
s = enesim_surface_new(ENESIM_FORMAT_ARGB8888, 320, 240);
if (!enesim_renderer_draw(r, s, ENESIM_ROP_FILL, NULL, 0, 0, &error))
{
enesim_log_dump(error);
enesim_log_unref(error);
}
enesim_shutdown();
return 0;
}
|
Add (prototype of) concurrent queue. | #include <mutex>
#include <deque>
#ifndef SRC_CONCURRENT_QUEUE_H
#define SRC_CONCURRENT_QUEUE_H
/* Concurrent queue
* so far just make sure it is consisten, no performance optimizations
* but interface should be general enought to replace queue with faster one
*/
template< typename T >
struct ConcurrentQueue {
void enqueue( const T &data ) {
Guard g{ _lock };
_queue.push_back( data );
g.unlock();
_cond.notify_one();
}
/** get and pop head of queue, this will block if queue is empty
*/
T dequeue() {
Guard g{ _lock };
while ( _queue.empty() )
_cond.wait( g );
T data = _queue.front();
_queue.pop_front();
return data;
}
/** not safe
*/
bool empty() {
Guard g{ _lock };
return _queue.empty();
}
private:
std::mutex _lock;
std::deque< T > _queue;
std::condition_variable _cond;
using Guard = std::unique_lock< std::mutex >;
};
#endif // SRC_CONCURRENT_QUEUE_H
| |
Fix lock-unlock copy-paste mistake in 04/37 | #include <pthread.h>
int g;
int *g1;
int *g2;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
pthread_mutex_lock(&mutex);
(*g1)++; // RACE!
pthread_mutex_lock(&mutex);
return NULL;
}
int main(void) {
pthread_t id;
int x;
g1 = g2 = &g;
pthread_create(&id, NULL, t_fun, NULL);
(*g2)++; // RACE!
pthread_join (id, NULL);
return 0;
}
| #include <pthread.h>
int g;
int *g1;
int *g2;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
pthread_mutex_lock(&mutex);
(*g1)++; // RACE!
pthread_mutex_unlock(&mutex);
return NULL;
}
int main(void) {
pthread_t id;
int x;
g1 = g2 = &g;
pthread_create(&id, NULL, t_fun, NULL);
(*g2)++; // RACE!
pthread_join (id, NULL);
return 0;
}
|
Correct type, gcc-3.4.5 fails, thanks nitinkg for reporting/testing | /* vi: set sw=4 ts=4: */
/*
* getrusage() for uClibc
*
* Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*
* GNU Library General Public License (LGPL) version 2 or later.
*/
#include "syscalls.h"
#include <unistd.h>
#include <wait.h>
_syscall2(int, getrusage, int, who, struct rusage *, usage);
| /* vi: set sw=4 ts=4: */
/*
* getrusage() for uClibc
*
* Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*
* GNU Library General Public License (LGPL) version 2 or later.
*/
#include "syscalls.h"
#include <unistd.h>
#include <wait.h>
_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage);
|
Add backup implementation of std::make_unique. | //
// pch.h
// Header for standard system include files.
//
#ifndef _divida_precompiled_header_h_
#define _divida_precompiled_header_h_
#ifdef WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#include <algorithm>
#include <iomanip>
#include <string>
#include <sstream>
#endif
| //
// pch.h
// Header for standard system include files.
//
#ifndef _divida_precompiled_header_h_
#define _divida_precompiled_header_h_
#ifdef WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#include <algorithm>
#include <iomanip>
#include <memory>
#include <string>
#include <sstream>
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
namespace std
{
template<typename T, typename ...Args>
unique_ptr<T> make_unique(Args&& ...args)
{
return unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}
#endif
#endif
|
Revert "Updating ambient light to 2.0 API." | #include "ambient_light.h"
#include "tock.h"
typedef struct {
int intensity;
bool fired;
} ambient_light_data_t;
// callback for synchronous reads
static void ambient_light_cb(int intensity,
__attribute__ ((unused)) int unused1,
__attribute__ ((unused)) int unused2, void* ud) {
ambient_light_data_t* result = (ambient_light_data_t*)ud;
result->intensity = intensity;
result->fired = true;
}
int ambient_light_read_intensity_sync(int* lux_value) {
int err;
ambient_light_data_t result = {0};
result.fired = false;
err = ambient_light_subscribe(ambient_light_cb, (void*)(&result));
if (err < TOCK_SUCCESS) {
return err;
}
err = ambient_light_start_intensity_reading();
if (err < TOCK_SUCCESS) {
return err;
}
yield_for(&result.fired);
*lux_value = result.intensity;
return TOCK_SUCCESS;
}
int ambient_light_subscribe(subscribe_cb callback, void* userdata) {
return subscribe(DRIVER_NUM_AMBIENT_LIGHT, 0, callback, userdata);
}
int ambient_light_start_intensity_reading(void) {
return command(DRIVER_NUM_AMBIENT_LIGHT, 1, 0, 0);
}
| #include "ambient_light.h"
#include "tock.h"
typedef struct {
int intensity;
bool fired;
} ambient_light_data_t;
// internal callback for faking synchronous reads
static void ambient_light_cb(int intensity,
__attribute__ ((unused)) int unused1,
__attribute__ ((unused)) int unused2, void* ud) {
ambient_light_data_t* result = (ambient_light_data_t*)ud;
result->intensity = intensity;
result->fired = true;
}
int ambient_light_read_intensity_sync(int* lux_value) {
int err;
ambient_light_data_t result = {0};
result.fired = false;
err = ambient_light_subscribe(ambient_light_cb, (void*)(&result));
if (err < TOCK_SUCCESS) {
return err;
}
err = ambient_light_start_intensity_reading();
if (err < TOCK_SUCCESS) {
return err;
}
yield_for(&result.fired);
*lux_value = result.intensity;
return TOCK_SUCCESS;
}
int ambient_light_subscribe(subscribe_cb callback, void* userdata) {
return subscribe(DRIVER_NUM_AMBIENT_LIGHT, 0, callback, userdata);
}
int ambient_light_start_intensity_reading(void) {
return command(DRIVER_NUM_AMBIENT_LIGHT, 1, 0, 0);
}
|
Remove declaration of unimplemented method | #ifndef ALIPHOSPREPROCESSOR_H
#define ALIPHOSPREPROCESSOR_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
/* $Id$ */
///////////////////////////////////////////////////////////////////////////////
// Class AliPHOSPreprocessor
///////////////////////////////////////////////////////////////////////////////
#include "AliPreprocessor.h"
class AliPHOSPreprocessor : public AliPreprocessor {
public:
AliPHOSPreprocessor();
AliPHOSPreprocessor(const char* detector, AliShuttleInterface* shuttle);
protected:
virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
virtual UInt_t Process(TMap* valueSet);
ClassDef(AliPHOSPreprocessor,0);
};
#endif
| #ifndef ALIPHOSPREPROCESSOR_H
#define ALIPHOSPREPROCESSOR_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
/* $Id$ */
///////////////////////////////////////////////////////////////////////////////
// Class AliPHOSPreprocessor
///////////////////////////////////////////////////////////////////////////////
#include "AliPreprocessor.h"
class AliPHOSPreprocessor : public AliPreprocessor {
public:
AliPHOSPreprocessor();
AliPHOSPreprocessor(const char* detector, AliShuttleInterface* shuttle);
protected:
virtual UInt_t Process(TMap* valueSet);
ClassDef(AliPHOSPreprocessor,0);
};
#endif
|
Add working bubble sort implementation | #ifndef SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
#define SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
namespace sorting {
namespace bubble {
template <class T>
void BubbleSort(T * const array, const int N)
/**
* Bubble sort: Bubble sort
* Scaling:
* Best case:
* Worst case:
* Useful:
*
*/
{
}
} // namespace bubble
} // namespace sorting
#endif // SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
| #ifndef SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
#define SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
namespace sorting {
namespace bubble {
template <class T>
void BubbleSort(T * const array, const int N)
/**
* Bubble sort: Bubble sort
* Scaling:
* Best case:
* Worst case:
* Useful:
*
*/
{
int pass_count = 0; // Number of pass over the array.
int swap_count = 0; // Number of swap for a single pass.
// Pass over the array while the swap count is non-null.
do
{
// It's a new pass; reset the count of swap.
swap_count = 0;
// Iterate over the array, skipping the last item
for (int i = 0 ; i < N-1 ; i++)
{
// Swap elements if next one is "smaller" and register the swap.
if (array[i] > array[i+1])
{
std::swap(array[i], array[i+1]);
swap_count++;
}
}
pass_count++;
} while (swap_count != 0);
}
} // namespace bubble
} // namespace sorting
#endif // SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
|
Add Statistical Mode Finding Algorithm | // Patrick Yevsukov
// 2013 CC BY-NC-SA 4.0
// Excerpt From github.com/PatrickYevsukov/Statistics-Calculator
// I devised this algorithm to identify the statistical mode or
// modes of a dataset. It requires one pass through the set to
// identify the set's mode or mode's.
// This algorithm works by keeping track of the number of times a
// unique value occurs in the set. If a unique value has occurred
// more times than the ones before it, it is added to the list of
// modes. As the loop continues all values which occur this number
// of times are added to the list of modes, unless another unique
// value occurs more times than the currently identified modes. If
// this happens, the mode array indexing variable is reset to zero
// and the previously identified values are overwritten by the new
// modes. When finished, the mode array indexing variable will be
// one less than the number of modes.
// This algorithm requires a set of values in which all instances
// of a unique value are listed next to one another.
#include <stdio.h>
#include <stdlib.h>
#define MAX_SAMPLE 25
double *
SampleMode(double *, int *);
double *
SampleMode(double *sample, int *sample_size)
{
int ii = 0;
int kk = 0;
int num_modes = 0;
int previous_freq = 0;
int current_freq = 1; // Every value must occur at least once
double *modes = NULL;
modes = (double *) malloc(MAX_SAMPLE * sizeof *modes);
for (ii = 0; ii <= *sample_size - 1; ii++)
{
if (sample[ii] == sample[ii + 1])
{
current_freq++;
}
else
{
if (current_freq > previous_freq)
{
kk = 0; // Reset
previous_freq = current_freq;
modes[kk] = sample[ii];
}
else if (current_freq == previous_freq)
{
kk++;
modes[kk] = sample[ii];
}
current_freq = 1; // Reset
}
}
num_modes = kk + 1;
return modes;
}
| |
Rename function to the new version. |
#ifndef UNITS_UNIT_H_
#define UNITS_UNIT_H_
#include <SFML/Graphics.hpp>
#include "engine/instance.h"
#include "base/aliases.h"
class Unit : public Instance {
public:
Unit();
virtual ~Unit();
virtual void Step(sf::Time elapsed);
void set_life(unsigned life) {
life_ = life;
}
unsigned life() {
return life_;
}
void set_position(Vec2f pos) {
sprite_.set_position(pos);
}
Vec2f position() {
return sprite_.getPosition();
}
void set_movement_speed(Vec2f movement_speed) {
movement_speed_ = movement_speed;
}
void set_attack_speed(unsigned attack_speed) {
attack_speed_ = attack_speed;
}
protected:
unsigned life_;
unsigned damage_;
unsigned attack_speed_;
Vec2f movement_speed_;
};
#endif // UNITS_UNIT_H_
|
#ifndef UNITS_UNIT_H_
#define UNITS_UNIT_H_
#include <SFML/Graphics.hpp>
#include "engine/instance.h"
#include "base/aliases.h"
class Unit : public Instance {
public:
Unit();
virtual ~Unit();
virtual void Step(sf::Time elapsed);
void set_life(unsigned life) {
life_ = life;
}
unsigned life() {
return life_;
}
void set_position(Vec2f pos) {
sprite_.set_position(pos);
}
Vec2f position() {
return sprite_.position();
}
void set_movement_speed(Vec2f movement_speed) {
movement_speed_ = movement_speed;
}
void set_attack_speed(unsigned attack_speed) {
attack_speed_ = attack_speed;
}
protected:
unsigned life_;
unsigned damage_;
unsigned attack_speed_;
Vec2f movement_speed_;
};
#endif // UNITS_UNIT_H_
|
Add signatures for content retrieval methods. | //
// FileSystem.h
// arc
//
// Created by Jerome Cheng on 19/3/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Folder.h"
@interface FileSystem : NSObject {
@private
Folder *_rootFolder; // The root folder.
}
// Returns the root folder of the entire file system.
- (Folder*)getRootFolder;
// Returns the single FileSystem instance.
+ (FileSystem*)getInstance;
@end
| //
// FileSystem.h
// arc
//
// Created by Jerome Cheng on 19/3/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Folder.h"
@interface FileSystem : NSObject {
@private
Folder *_rootFolder; // The root folder.
}
// Returns the root folder of the entire file system.
- (Folder*)getRootFolder;
// Returns the single FileSystem instance.
+ (FileSystem*)getInstance;
// Returns an NSArray of FileObjects, corresponding to the contents
// of the given folder.
- (NSArray*)getFolderContents:(Folder*)folder;
// Returns an NSString containing the contents of the given file.
- (NSString*)getFileContents:(File*)file;
@end
|
Add utility functions for converting to and from AngleAxis | #ifndef CERBERUS_H
#define CERBERUS_H
#include <iostream>
#include "ceres/ceres.h"
using namespace std;
using namespace ceres;
class Cerberus {
public:
Cerberus();
Solver::Options options;
LossFunction *loss;
Problem problem;
Solver::Summary summary;
void solve();
};
#endif | #ifndef CERBERUS_H
#define CERBERUS_H
#include <iostream>
#include "ceres/ceres.h"
#include "ceres/rotation.h"
using namespace std;
using namespace ceres;
class Cerberus {
public:
Cerberus();
Solver::Options options;
LossFunction *loss;
Problem problem;
Solver::Summary summary;
void solve();
};
// Rt is a 4x3 transformation matrix of the form [R|t]. result is a
// 6-dimensional vector with first three terms representing axis, magnitude
// angle, and the last three terms represent translation
template <typename T> void TransformationMatrixToAngleAxisAndTranslation(T *Rt, T *result) {
RotationMatrixToAngleAxis<T>(MatrixAdapter<const T, 4, 1>(Rt), result);
result[3] = Rt[3];
result[4] = Rt[7];
result[5] = Rt[11];
}
// At is a 6-dimensional vector with first three terms representing axis,
// magnitude angle, and the last three terms represent translation. Rt is a
// 4x3 transformation matrix of the form [R|t].
template <typename T> void AngleAxisAndTranslationToTransformationMatrix(const T *At, T *result) {
AngleAxisToRotationMatrix<T>(At, MatrixAdapter<T, 4, 1>(result));
result[3] = At[3];
result[7] = At[4];
result[11] = At[5];
}
#endif |
Fix typo in my last commit. | // RUN: not %clang_cc1 -E -dependency-file bla -MT %t/doesnotexist/bla.o -MP -o $t/doesnotexist/bla.o -x c /dev/null 2>&1 | FileCheck %s
// CHECK: error: unable to open output file
// rdar://9286457
| // RUN: not %clang_cc1 -E -dependency-file bla -MT %t/doesnotexist/bla.o -MP -o %t/doesnotexist/bla.o -x c /dev/null 2>&1 | FileCheck %s
// CHECK: error: unable to open output file
// rdar://9286457
|
Update imports in umbrella header. | //
// PublicHeaders.h
// Insider
//
// Created by Alexandru Maimescu on 3/2/16.
// Copyright © 2016 Alex Maimescu. All rights reserved.
//
#ifndef PublicHeaders_h
#define PublicHeaders_h
// GCDWebServer https://github.com/swisspol/GCDWebServer
#import <Insider/GCDWebServer.h>
#import <Insider/GCDWebServerURLEncodedFormRequest.h>
#import <Insider/GCDWebServerDataResponse.h>
// iOS-System-Services https://github.com/Shmoopi/iOS-System-Services
#import <Insider/SystemServices.h>
#endif /* PublicHeaders_h */
| //
// PublicHeaders.h
// Insider
//
// Created by Alexandru Maimescu on 3/2/16.
// Copyright © 2016 Alex Maimescu. All rights reserved.
//
#ifndef PublicHeaders_h
#define PublicHeaders_h
// GCDWebServer https://github.com/swisspol/GCDWebServer
#import "GCDWebServer.h"
#import "GCDWebServerURLEncodedFormRequest.h"
#import "GCDWebServerDataResponse.h"
// iOS-System-Services https://github.com/Shmoopi/iOS-System-Services
#import "SystemServices.h"
#endif /* PublicHeaders_h */
|
Disable ENV when disable DFS. | /*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#include <rtthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>
#include "libc.h"
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif
int _EXFUN(putenv,(char *__string));
int libc_system_init(void)
{
#if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE)
rt_device_t dev_console;
dev_console = rt_console_get_device();
if (dev_console)
{
#if defined(RT_USING_POSIX)
libc_stdio_set_console(dev_console->parent.name, O_RDWR);
#else
libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
#endif
}
#endif
/* set PATH and HOME */
putenv("PATH=/bin");
putenv("HOME=/home");
#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
pthread_system_init();
#endif
return 0;
}
INIT_COMPONENT_EXPORT(libc_system_init);
| /*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#include <rtthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>
#include "libc.h"
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif
int _EXFUN(putenv,(char *__string));
int libc_system_init(void)
{
#if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE)
rt_device_t dev_console;
dev_console = rt_console_get_device();
if (dev_console)
{
#if defined(RT_USING_POSIX)
libc_stdio_set_console(dev_console->parent.name, O_RDWR);
#else
libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
#endif
}
/* set PATH and HOME */
putenv("PATH=/bin");
putenv("HOME=/home");
#endif
#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
pthread_system_init();
#endif
return 0;
}
INIT_COMPONENT_EXPORT(libc_system_init);
|
Use %s in test, not hard coded name. | // RUN: clang-cc -Eonly optimize.c -DOPT_O2 -O2 -verify &&
#ifdef OPT_O2
#ifndef __OPTIMIZE__
#error "__OPTIMIZE__ not defined"
#endif
#ifdef __OPTIMIZE_SIZE
#error "__OPTIMIZE_SIZE__ defined"
#endif
#endif
// RUN: clang-cc -Eonly optimize.c -DOPT_O0 -O0 -verify &&
#ifdef OPT_O0
#ifdef __OPTIMIZE__
#error "__OPTIMIZE__ defined"
#endif
#ifdef __OPTIMIZE_SIZE
#error "__OPTIMIZE_SIZE__ defined"
#endif
#endif
// RUN: clang-cc -Eonly optimize.c -DOPT_OS -Os -verify
#ifdef OPT_OS
#ifndef __OPTIMIZE__
#error "__OPTIMIZE__ not defined"
#endif
#ifndef __OPTIMIZE_SIZE
#error "__OPTIMIZE_SIZE__ not defined"
#endif
#endif
| // RUN: clang-cc -Eonly %s -DOPT_O2 -O2 -verify &&
#ifdef OPT_O2
#ifndef __OPTIMIZE__
#error "__OPTIMIZE__ not defined"
#endif
#ifdef __OPTIMIZE_SIZE
#error "__OPTIMIZE_SIZE__ defined"
#endif
#endif
// RUN: clang-cc -Eonly %s -DOPT_O0 -O0 -verify &&
#ifdef OPT_O0
#ifdef __OPTIMIZE__
#error "__OPTIMIZE__ defined"
#endif
#ifdef __OPTIMIZE_SIZE
#error "__OPTIMIZE_SIZE__ defined"
#endif
#endif
// RUN: clang-cc -Eonly %s -DOPT_OS -Os -verify
#ifdef OPT_OS
#ifndef __OPTIMIZE__
#error "__OPTIMIZE__ not defined"
#endif
#ifndef __OPTIMIZE_SIZE
#error "__OPTIMIZE_SIZE__ not defined"
#endif
#endif
|
Add Cytron Maker Zero SAMD21 | /*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "supervisor/board.h"
#include "mpconfigboard.h"
#include "hal/include/hal_gpio.h"
void board_init(void) {
}
bool board_requests_safe_mode(void) {
return false;
}
void reset_board(void) {
}
void board_deinit(void) {
}
| |
Replace include with forward declaration | /*
* This file is part of libbdplus
* Copyright (C) 2015 VideoLAN
*
* 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, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef FILE_DEFAULT_H_
#define FILE_DEFAULT_H_
#include "filesystem.h"
#include "util/attributes.h"
BD_PRIVATE BDPLUS_FILE_H *file_open_default(void *root_path, const char *file_name);
#endif /* FILE_DEFAULT_H_ */
| /*
* This file is part of libbdplus
* Copyright (C) 2015 VideoLAN
*
* 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, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef FILE_DEFAULT_H_
#define FILE_DEFAULT_H_
#include "util/attributes.h"
struct bdplus_file;
BD_PRIVATE struct bdplus_file *file_open_default(void *root_path, const char *file_name);
#endif /* FILE_DEFAULT_H_ */
|
Put new codecs in module codec header | #pragma once
#include "AbsWrapperCodec.h"
#include "AddWrapperCodec.h"
#include "BillowWrapperCodec.h"
#include "BlendWrapperCodec.h"
#include "CacheWrapperCodec.h"
#include "CheckerboardWrapperCodec.h"
#include "ClampWrapperCodec.h"
#include "ConstWrapperCodec.h"
#include "CurveWrapperCodec.h"
#include "CylindersWrapperCodec.h"
#include "DisplaceWrapperCodec.h"
#include "ExponentWrapperCodec.h"
#include "InvertWrapperCodec.h"
#include "MaxWrapperCodec.h"
#include "MinWrapperCodec.h"
#include "MultiplyWrapperCodec.h"
#include "NoiseSourcesCodec.h"
#include "PerlinWrapperCodec.h"
#include "PowerWrapperCodec.h"
#include "RidgedMultiWrapperCodec.h"
#include "RotatePointWrapperCodec.h"
#include "ScaleBiasWrapperCodec.h"
#include "ScalePointCodec.h"
#include "SelectWrapperCodec.h"
#include "SpheresWrapperCodec.h"
#include "TerraceWrapperCodec.h"
#include "TranslatePointWrapperCodec.h"
#include "TurbulenceWrapperCodec.h"
#include "VoronoiWrapperCodec.h"
| #pragma once
#include "AbsWrapperCodec.h"
#include "AddWrapperCodec.h"
#include "BillowWrapperCodec.h"
#include "BlendWrapperCodec.h"
#include "CacheWrapperCodec.h"
#include "CheckerboardWrapperCodec.h"
#include "ClampWrapperCodec.h"
#include "ConstWrapperCodec.h"
#include "CornerCombinerBaseWrapperCodec.h"
#include "CurveWrapperCodec.h"
#include "CylindersWrapperCodec.h"
#include "DisplaceWrapperCodec.h"
#include "ExpWrapperCodec.h"
#include "ExponentWrapperCodec.h"
#include "ForwardWrapperCodec.h"
#include "InvertWrapperCodec.h"
#include "MaxWrapperCodec.h"
#include "MinWrapperCodec.h"
#include "MultiplyWrapperCodec.h"
#include "NormLPQWrapperCodec.h"
#include "NoiseSourcesCodec.h"
#include "PerlinWrapperCodec.h"
#include "PowWrapperCodec.h"
#include "PowerWrapperCodec.h"
#include "RidgedMultiWrapperCodec.h"
#include "RotatePointWrapperCodec.h"
#include "ScaleBiasWrapperCodec.h"
#include "ScalePointCodec.h"
#include "SelectWrapperCodec.h"
#include "SpheresWrapperCodec.h"
#include "TerraceWrapperCodec.h"
#include "TranslatePointWrapperCodec.h"
#include "TurbulenceWrapperCodec.h"
#include "VoronoiWrapperCodec.h"
|
Use if includes for fb/tiwtter | #import "ArtsyToken.h"
#import "ArtsyAuthentication.h"
#import "ArtsyAuthentication+Facebook.h"
#import "ArtsyAuthentication+Twitter.h" | #import "ArtsyToken.h"
#import "ArtsyAuthentication.h"
#if __has_include("ArtsyAuthentication+Facebook.h")
#import "ArtsyAuthentication+Facebook.h"
#endif
#if __has_include("ArtsyAuthentication+Twitter.h")
#import "ArtsyAuthentication+Twitter.h"
#endif
|
Print longer than 80 chars | #include <stdio.h>
#define MAXLINE 81
#define MAXLENGTH 1000
int getline(char line[]);
/* print line longer than 80 characters */
int main(void)
{
int len;
char line[MAXLENGTH];
while ((len = getline(line)) > 0)
if (len > MAXLINE) {
printf("%s", line);
}
return 0;
}
int getline(char s[]) {
int c, i;
for (i=0; (c=getchar()) != EOF && c!='\n'; ++i)
s[i] = c;
if (c== '\n') {
s[i] = c;
++i;
}
s[i] = '\0';
return i;
}
| |
Rename get(TaskId) to getAllTask (QueryEngine does not need it) | #pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_
#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
friend class Transaction;
public:
static bool begin();
// Modifying methods
static bool post(TaskId, SerializedTask&);
static bool put(TaskId, SerializedTask&);
static bool erase(TaskId);
static boost::variant<bool, SerializedTask> get(TaskId);
static std::vector<SerializedTask>
filter(const std::function<bool(SerializedTask)>&);
private:
static DataStore& get();
bool isServing = false;
std::deque<Internal::IOperation> operationsQueue;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_DATASTORE_H_
| #pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_
#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
friend class Transaction;
public:
static bool begin();
// Modifying methods
static bool post(TaskId, SerializedTask&);
static bool put(TaskId, SerializedTask&);
static bool erase(TaskId);
static std::vector<SerializedTask> getAllTask();
static std::vector<SerializedTask>
filter(const std::function<bool(SerializedTask)>&);
private:
static DataStore& get();
bool isServing = false;
std::deque<Internal::IOperation> operationsQueue;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_DATASTORE_H_
|
Make the codes in the order. | #include "libmypy.h"
char hellofunc_docs[] = "Hello world description.";
PyMethodDef helloworld_funcs[] = {
{ "hello",
(PyCFunction)hello,
METH_NOARGS,
hellofunc_docs},
{ NULL}
};
struct PyModuleDef helloworld_mod = {
PyModuleDef_HEAD_INIT,
"helloworld",
"This is hello world module.",
-1,
helloworld_funcs,
NULL,
NULL,
NULL,
NULL
};
void PyInit_helloworld(void) {
PyModule_Create(&helloworld_mod);
}
| #include "libmypy.h"
char hellofunc_docs[] = "Hello world description.";
PyMethodDef helloworld_funcs[] = {
{ "hello",
(PyCFunction)hello,
METH_NOARGS,
hellofunc_docs},
{ NULL}
};
char helloworldmod_docs[] = "This is hello world module.";
PyModuleDef helloworld_mod = {
PyModuleDef_HEAD_INIT,
"helloworld",
helloworldmod_docs,
-1,
helloworld_funcs,
NULL,
NULL,
NULL,
NULL
};
void PyInit_helloworld(void) {
PyModule_Create(&helloworld_mod);
}
|
Add a timeout for read | #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag &= ~(OPOST);
raw.c_cflag |= (CS8);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enableRawMode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q') {
if (iscntrl(c)) {
printf("%d\r\n", c);
} else {
printf("%d ('%c')\r\n", c, c);
}
}
return 0;
}
| #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag &= ~(OPOST);
raw.c_cflag |= (CS8);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
raw.c_cc[VMIN] = 0;
raw.c_cc[VTIME] = 1;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enableRawMode();
while (1) {
char c = '\0';
read(STDIN_FILENO, &c, 1);
if (iscntrl(c)) {
printf("%d\r\n", c);
} else {
printf("%d ('%c')\r\n", c, c);
}
if (c == 'q') break;
}
return 0;
}
|
Reduce initial number of mutations | #ifndef MUTATION_RATE_GENE_H
#define MUTATION_RATE_GENE_H
#include "Gene.h"
#include <string>
#include <memory>
#include <map>
#include "Game/Color.h"
//! The gene controls how much of the genome mutates per Genome::mutate() event.
class Mutation_Rate_Gene : public Gene
{
public:
std::string name() const noexcept override;
//! Controls how many changes a call to Genome::mutate() makes to the Gene collections.
//
//! \returns An integer number that determines the number of point mutations the Genome::mutate() makes.
int mutation_count() const noexcept;
void gene_specific_mutation() noexcept override;
std::unique_ptr<Gene> duplicate() const noexcept override;
protected:
std::map<std::string, double> list_properties() const noexcept override;
void load_properties(const std::map<std::string, double>& properties) override;
private:
double mutated_components_per_mutation = 100.0;
double score_board(const Board& board, Color perspective, size_t prior_real_moves) const noexcept override;
};
#endif // MUTATION_RATE_GENE_H
| #ifndef MUTATION_RATE_GENE_H
#define MUTATION_RATE_GENE_H
#include "Gene.h"
#include <string>
#include <memory>
#include <map>
#include "Game/Color.h"
//! The gene controls how much of the genome mutates per Genome::mutate() event.
class Mutation_Rate_Gene : public Gene
{
public:
std::string name() const noexcept override;
//! Controls how many changes a call to Genome::mutate() makes to the Gene collections.
//
//! \returns An integer number that determines the number of point mutations the Genome::mutate() makes.
int mutation_count() const noexcept;
void gene_specific_mutation() noexcept override;
std::unique_ptr<Gene> duplicate() const noexcept override;
protected:
std::map<std::string, double> list_properties() const noexcept override;
void load_properties(const std::map<std::string, double>& properties) override;
private:
double mutated_components_per_mutation = 1.0;
double score_board(const Board& board, Color perspective, size_t prior_real_moves) const noexcept override;
};
#endif // MUTATION_RATE_GENE_H
|
Fix to Use specified Font mosamosa. | //
// Constants.h
// yamiHikariGame
//
// Created by slightair on 2013/07/28.
//
//
#ifndef yamiHikariGame_Constants_h
#define yamiHikariGame_Constants_h
#define SpriteSheetImageFileName "spriteSheet.pvr.ccz"
#define DefaultFontName "mosamosa"
#define DefaultFontSize 24
#define StaminaMax 1000
#define SEItemGet "SE001.mp3"
#define SEGameOver "SE002.mp3"
#define SEBadItemGet "SE004.mp3"
#define SoundEffectVolume 0.15
#endif
| //
// Constants.h
// yamiHikariGame
//
// Created by slightair on 2013/07/28.
//
//
#ifndef yamiHikariGame_Constants_h
#define yamiHikariGame_Constants_h
#define SpriteSheetImageFileName "spriteSheet.pvr.ccz"
#define DefaultFontName "mosamosa.ttf"
#define DefaultFontSize 24
#define StaminaMax 1000
#define SEItemGet "SE001.mp3"
#define SEGameOver "SE002.mp3"
#define SEBadItemGet "SE004.mp3"
#define SoundEffectVolume 0.15
#endif
|
Add initial data structures for mapping | #ifndef GRAPH_H
#define GRAPH_H
#include <unordered_map>
#include <unordered_set>
template<typename T>
class Graph {
public:
void connect(const T &a, const T &b);
const std::unordered_set<T>& get_vertex_ids() const;
inline const std::unordered_set<T>& get_neighbors(const T &vertex_id) const {
return vertices_.at(vertex_id)->adjacent_ids_;
}
~Graph();
private:
struct Vertex {
T id_;
std::unordered_set<Vertex*> adjacent_;
std::unordered_set<T> adjacent_ids_;
Vertex(const T &id) : id_(id) {}
bool has_neighbor(Vertex *v) const {
return adjacent_.find(v) != adjacent_.end();
}
void add_neighbor(Vertex* v) {
adjacent_.insert(v);
adjacent_ids_.insert(v->id_);
}
};
std::unordered_map<T, Vertex*> vertices_;
std::unordered_set<T> vertex_ids;
Vertex* get_vertex(const T &a) const;
Vertex* get_or_insert(const T &a);
};
template class Graph<int>;
#endif
| #ifndef GRAPH_H
#define GRAPH_H
#include <unordered_map>
#include <unordered_set>
template<typename T>
class Graph {
public:
void connect(const T &a, const T &b);
const std::unordered_set<T>& get_vertex_ids() const;
inline const std::unordered_set<T>& get_neighbors(const T &vertex_id) const {
return vertices_.at(vertex_id)->adjacent_ids_;
}
~Graph();
private:
struct Vertex {
T id_;
std::unordered_set<Vertex*> adjacent_;
std::unordered_set<T> adjacent_ids_;
Vertex(const T &id) : id_(id) {}
bool has_neighbor(Vertex *v) const {
return adjacent_.find(v) != adjacent_.end();
}
void add_neighbor(Vertex* v) {
adjacent_.insert(v);
adjacent_ids_.insert(v->id_);
}
};
std::unordered_map<T, Vertex*> vertices_;
std::unordered_set<T> vertex_ids;
std::unordered_map<T, int> alias_id;
std::vector<int> reverse_mapping;
Vertex* get_vertex(const T &a) const;
Vertex* get_or_insert(const T &a);
};
template class Graph<int>;
#endif
|
Add get_supported_rf_protocols() method to driver | /* mbed Microcontroller Library
* Copyright (c) 2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_NFC_CONTROLLER_DRIVER_H
#define MBED_NFC_CONTROLLER_DRIVER_H
#include <stdint.h>
#include "events/EventQueue.h"
#include "stack/nfc_errors.h"
#include "stack/transceiver/transceiver.h"
#include "stack/platform/scheduler.h"
namespace mbed {
namespace nfc {
struct NFCControllerDriver {
virtual void initialize(scheduler_timer_t* pTimer) = 0;
virtual transceiver_t* get_transceiver() const = 0;
};
} // namespace nfc
} // namespace mbed
#endif
| /* mbed Microcontroller Library
* Copyright (c) 2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_NFC_CONTROLLER_DRIVER_H
#define MBED_NFC_CONTROLLER_DRIVER_H
#include <stdint.h>
#include "events/EventQueue.h"
#include "stack/nfc_errors.h"
#include "stack/transceiver/transceiver.h"
#include "stack/platform/scheduler.h"
namespace mbed {
namespace nfc {
struct NFCControllerDriver {
virtual void initialize(scheduler_timer_t* pTimer) = 0;
virtual transceiver_t* get_transceiver() const = 0;
virtual nfc_rf_protocols_bitmask_t get_supported_rf_protocols() const = 0;
};
} // namespace nfc
} // namespace mbed
#endif
|
Remove extern references for OC_*_QUANT_MIN. | /********************************************************************
* *
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function:
last mod: $Id$
********************************************************************/
#if !defined(_quant_H)
# define _quant_H (1)
# include "theora/codec.h"
# include "ocintrin.h"
typedef ogg_uint16_t oc_quant_table[64];
typedef oc_quant_table oc_quant_tables[64];
/*Maximum scaled quantizer value.*/
#define OC_QUANT_MAX (1024<<2)
/*Minimum scaled DC coefficient frame quantizer value for intra and inter
modes.*/
extern unsigned OC_DC_QUANT_MIN[2];
/*Minimum scaled AC coefficient frame quantizer value for intra and inter
modes.*/
extern unsigned OC_AC_QUANT_MIN[2];
void oc_dequant_tables_init(oc_quant_table *_dequant[2][3],
int _pp_dc_scale[64],const th_quant_info *_qinfo);
#endif
| /********************************************************************
* *
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function:
last mod: $Id$
********************************************************************/
#if !defined(_quant_H)
# define _quant_H (1)
# include "theora/codec.h"
# include "ocintrin.h"
typedef ogg_uint16_t oc_quant_table[64];
typedef oc_quant_table oc_quant_tables[64];
/*Maximum scaled quantizer value.*/
#define OC_QUANT_MAX (1024<<2)
void oc_dequant_tables_init(oc_quant_table *_dequant[2][3],
int _pp_dc_scale[64],const th_quant_info *_qinfo);
#endif
|
Add ADC channel enumeration to chip | /* Copyright 2017 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* MCHP MEC specific ADC module for Chrome EC */
#ifndef __CROS_EC_ADC_CHIP_H
#define __CROS_EC_ADC_CHIP_H
/* Data structure to define ADC channels. */
struct adc_t {
const char *name;
int factor_mul;
int factor_div;
int shift;
int channel;
};
/*
* Boards must provide this list of ADC channel definitions.
* This must match the enum adc_channel list provided by the board.
*/
extern const struct adc_t adc_channels[];
/* Minimum and maximum values returned by adc_read_channel(). */
#define ADC_READ_MIN 0
#define ADC_READ_MAX 1023
/* Just plain id mapping for code readability */
#define MCHP_ADC_CH(x) (x)
#endif /* __CROS_EC_ADC_CHIP_H */
| /* Copyright 2017 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* MCHP MEC specific ADC module for Chrome EC */
#ifndef __CROS_EC_ADC_CHIP_H
#define __CROS_EC_ADC_CHIP_H
/* Data structure to define ADC channels. */
struct adc_t {
const char *name;
int factor_mul;
int factor_div;
int shift;
int channel;
};
/* List of ADC channels */
enum chip_adc_channel {
CHIP_ADC_CH0 = 0,
CHIP_ADC_CH1,
CHIP_ADC_CH2,
CHIP_ADC_CH3,
CHIP_ADC_CH4,
CHIP_ADC_CH5,
CHIP_ADC_CH6,
CHIP_ADC_CH7,
CHIP_ADC_COUNT,
};
/*
* Boards must provide this list of ADC channel definitions.
* This must match the enum adc_channel list provided by the board.
*/
extern const struct adc_t adc_channels[];
/* Minimum and maximum values returned by adc_read_channel(). */
#define ADC_READ_MIN 0
#define ADC_READ_MAX 1023
/* Just plain id mapping for code readability */
#define MCHP_ADC_CH(x) (x)
#endif /* __CROS_EC_ADC_CHIP_H */
|
Add (deactivated) casting test for congruence domain | // PARAM: --disable ana.int.def_exc --enable ana.int.interval
// Ensures that the cast_to function handles casting for congruences correctly.
// TODO: Implement appropriate cast_to function, enable for congruences only and adjust test if necessary.
#include <assert.h>
#include <stdio.h>
int main(){
int c = 128;
for (int i = 0; i < 1; i++) {
c = c - 150;
}
char k = (char) c;
printf ("k: %d", k);
assert (k == -22); //UNKNOWN
k = k + 150;
assert (k == 0); //UNKNOWN!
}
| |
Fix a __i386 bug in gcc | #ifndef _CONCAT_H_
#define _CONCAT_H_
/// Utitilies to make a unique variable name.
#define CONCAT_LINE(x) CONCAT(x, __LINE__)
#define CONCAT(a, b) CONCAT_INDIRECT(a, b)
#define CONCAT_INDIRECT(a, b) a ## b
#endif
| #ifndef _CONCAT_H_
#define _CONCAT_H_
/// Utitilies to make a unique variable name.
#define CONCAT_LINE(x) CONCAT(x ## _foreach__, __LINE__)
#define CONCAT(a, b) CONCAT_INDIRECT(a, b)
#define CONCAT_INDIRECT(a, b) a ## b
#endif
|
Add class for retrieving system color scheme settings | #pragma once
#include <Windows.h>
#include "../Logger.h"
#include <math.h>
#include <algorithm>
#include <dwmapi.h>
#pragma comment(lib, "Dwmapi.lib")
class SystemColors {
struct DWMColorizationParams {
UINT ColorizationColor;
UINT ColorizationAfterglow;
UINT ColorizationColorBalance;
UINT ColorizationAfterglowBalance;
UINT ColorizationBlurBalance;
UINT ColorizationGlassReflectionIntensity;
UINT ColorizationOpaqueBlend;
};
public:
SystemColors() {
HMODULE dwm = LoadLibrary(L"dwmapi.dll");
HRESULT(WINAPI *DwmGetColorizationParameters) (DWMColorizationParams *colorparam);
*(FARPROC *) &DwmGetColorizationParameters = GetProcAddress(dwm, (LPCSTR) 127);
DWMColorizationParams params;
DwmGetColorizationParameters(¶ms);
CLOG(L"-> %x", params.ColorizationColor);
CLOG(L"-> %x", params.ColorizationAfterglow);
CLOG(L"-> %d", params.ColorizationColorBalance);
CLOG(L"-> %d", params.ColorizationAfterglowBalance);
CLOG(L"-> %x", params.ColorizationBlurBalance);
CLOG(L"-> %x", params.ColorizationGlassReflectionIntensity);
CLOG(L"-> %x", params.ColorizationOpaqueBlend);
COLORREF base = RGB(217, 217, 217);
DWORD val;
BOOL opaque;
DwmGetColorizationColor(&val, &opaque);
CLOG(L"=> %x", val);
}
}; | |
Add a view for a packed array of C strings. | //This Source Code Form is subject to the terms of the Mozilla Public
//License, v. 2.0. If a copy of the MPL was not distributed with this
//file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include <stddef.h>
#include <string.h>
#include "Common.h"
namespace ej {
//! Represents a view on a list of C strings packed in an array
template <typename T = const char, size_t ALIGNMENT = alignof(T)>
class CStringsView {
public:
typedef T value_type;
typedef size_t size_type;
static_assert((ALIGNMENT & (ALIGNMENT - 1)) == 0 && ALIGNMENT >= alignof(value_type));
private:
value_type *Start;
value_type *Finish;
public:
constexpr CStringsView() noexcept : Start(nullptr), Finish(nullptr) {
}
constexpr CStringsView(value_type *start, value_type *finish) noexcept : Start(start), Finish(finish) {
}
template <size_t N>
constexpr CStringsView(value_type (&a)[N]) noexcept : Start(a), Finish(a + N) {
}
constexpr void assign(value_type *start, value_type *finish) noexcept {
Start = start;
Finish = finish;
}
template <size_t N>
constexpr void assign(value_type (&a)[N]) noexcept {
assign(a, a + N);
}
constexpr size_type size() const noexcept {
size_type n = 0;
for (auto iter = Start, end = Finish; iter < end;) {
auto length = strlen(iter);
iter += length + 1;
if constexpr (ALIGNMENT != alignof(value_type)) {
iter = reinterpret_cast<value_type *>(((reinterpret_cast<uintptr_t>(iter) + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT);
}
n++;
}
return n;
}
constexpr bool empty() const noexcept {
return Start == Finish;
}
template <typename Function>
EJ_ALWAYS_INLINE void for_each(Function f) const noexcept {
for (auto iter = Start, end = Finish; iter < end;) {
auto n = strlen(iter);
f(iter, n);
iter += n + 1;
if constexpr (ALIGNMENT != alignof(value_type)) {
iter = reinterpret_cast<value_type *>(((reinterpret_cast<uintptr_t>(iter) + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT);
}
}
}
};
}
| |
Fix test failing on Linux | // Check that calling dispatch_once from a report callback works.
// RUN: %clang_tsan %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
#include <dispatch/dispatch.h>
#include <pthread.h>
#include <stdio.h>
long g = 0;
long h = 0;
void f() {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
g++;
});
h++;
}
void __tsan_on_report() {
fprintf(stderr, "Report.\n");
f();
}
int main() {
fprintf(stderr, "Hello world.\n");
f();
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_unlock(&mutex); // Unlock of an unlocked mutex
fprintf(stderr, "g = %ld.\n", g);
fprintf(stderr, "h = %ld.\n", h);
fprintf(stderr, "Done.\n");
}
// CHECK: Hello world.
// CHECK: Report.
// CHECK: g = 1
// CHECK: h = 2
// CHECK: Done.
| // Check that calling dispatch_once from a report callback works.
// RUN: %clang_tsan %s -o %t
// RUN: not %env_tsan_opts=ignore_noninstrumented_modules=0 %run %t 2>&1 | FileCheck %s
#include <dispatch/dispatch.h>
#include <pthread.h>
#include <stdio.h>
long g = 0;
long h = 0;
void f() {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
g++;
});
h++;
}
void __tsan_on_report() {
fprintf(stderr, "Report.\n");
f();
}
int main() {
fprintf(stderr, "Hello world.\n");
f();
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_unlock(&mutex); // Unlock of an unlocked mutex
fprintf(stderr, "g = %ld.\n", g);
fprintf(stderr, "h = %ld.\n", h);
fprintf(stderr, "Done.\n");
}
// CHECK: Hello world.
// CHECK: Report.
// CHECK: g = 1
// CHECK: h = 2
// CHECK: Done.
|
Fix the file name case problem for building code in Linux system | /* mbed Microcontroller Library
* Copyright (c) 2015-2017 Nuvoton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H
#include "NANO100Series.h"
#include "cmsis_nvic.h"
// Support linker-generated symbol as start of relocated vector table.
#if defined(__CC_ARM)
extern uint32_t Image$$ER_IRAMVEC$$ZI$$Base;
#elif defined(__ICCARM__)
#elif defined(__GNUC__)
extern uint32_t __start_vector_table__;
#endif
#endif
| /* mbed Microcontroller Library
* Copyright (c) 2015-2017 Nuvoton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H
#include "Nano100Series.h"
#include "cmsis_nvic.h"
// Support linker-generated symbol as start of relocated vector table.
#if defined(__CC_ARM)
extern uint32_t Image$$ER_IRAMVEC$$ZI$$Base;
#elif defined(__ICCARM__)
#elif defined(__GNUC__)
extern uint32_t __start_vector_table__;
#endif
#endif
|
Change method-name to something more appropriate | #include "unity.h"
#include "cpuid.h"
void test_GetVendorName_should_ReturnGenuineIntel(void) {
char expected[20] = "GenuineIntel";
char actual[20];
get_vendor_name(actual);
TEST_ASSERT_EQUAL_STRING(expected, actual);
}
void test_GetVendorSignature_should_asdf(void) {
uint32_t exp_ebx = 0x756e6547; // translates to "Genu"
uint32_t exp_ecx = 0x6c65746e; // translates to "ineI"
uint32_t exp_edx = 0x49656e69; // translates to "ntel"
cpuid_info_t sig;
sig = get_vendor_signature();
TEST_ASSERT_EQUAL_UINT32(exp_ebx, sig.ebx);
TEST_ASSERT_EQUAL_UINT32(exp_ecx, sig.ecx);
TEST_ASSERT_EQUAL_UINT32(exp_edx, sig.edx);
}
void test_GetProcessorSignature_should_ReturnFamily6(void) {
unsigned int expected = 0x6;
unsigned int family;
uint32_t processor_signature = get_processor_signature();
family = (processor_signature >> 8) & 0xf;
TEST_ASSERT_EQUAL_UINT(expected, family);
}
| #include "unity.h"
#include "cpuid.h"
void test_GetVendorName_should_ReturnGenuineIntel(void) {
char expected[20] = "GenuineIntel";
char actual[20];
get_vendor_name(actual);
TEST_ASSERT_EQUAL_STRING(expected, actual);
}
void test_GetVendorSignature_should_ReturnCorrectCpuIdValues(void) {
uint32_t exp_ebx = 0x756e6547; // translates to "Genu"
uint32_t exp_ecx = 0x6c65746e; // translates to "ineI"
uint32_t exp_edx = 0x49656e69; // translates to "ntel"
cpuid_info_t sig;
sig = get_vendor_signature();
TEST_ASSERT_EQUAL_UINT32(exp_ebx, sig.ebx);
TEST_ASSERT_EQUAL_UINT32(exp_ecx, sig.ecx);
TEST_ASSERT_EQUAL_UINT32(exp_edx, sig.edx);
}
void test_GetProcessorSignature_should_ReturnFamily6(void) {
unsigned int expected = 0x6;
unsigned int family;
uint32_t processor_signature = get_processor_signature();
family = (processor_signature >> 8) & 0xf;
TEST_ASSERT_EQUAL_UINT(expected, family);
}
|
Add probably useless _printf(x,y) macro | /*
* print_helpers.h
*
* Created on: Nov 29, 2014
* Author: Konstantin Gredeskoul
* Code: https://github.com/kigster
*
* (c) 2014 All rights reserved, MIT License.
*/
#ifndef printv
#define printv(X,Y) (Serial.print(X) || Serial.println(Y))
#endif
| /*
* print_helpers.h
*
* Created on: Nov 29, 2014
* Author: Konstantin Gredeskoul
* Code: https://github.com/kigster
*
* (c) 2014 All rights reserved, MIT License.
*/
#ifndef printv
#define printv(X,Y) (Serial.print(X) || Serial.println(Y))
#endif
#ifndef _printf
#define _printf(X,Y) (Serial.printf(X, Y))
#endif
|
Update with new lefty, fixing many bugs and supporting new features | /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* Lefteris Koutsofios - AT&T Bell Laboratories */
#ifndef _PARSE_H
#define _PARSE_H
typedef struct Psrc_t {
int flag;
char *s;
FILE *fp;
int tok;
int lnum;
} Psrc_t;
void Pinit(void);
void Pterm(void);
Tobj Punit(Psrc_t *);
Tobj Pfcall(Tobj, Tobj);
Tobj Pfunction(char *, int);
#endif /* _PARSE_H */
#ifdef __cplusplus
}
#endif
| /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* Lefteris Koutsofios - AT&T Labs Research */
#ifndef _PARSE_H
#define _PARSE_H
typedef struct Psrc_t {
int flag;
char *s;
FILE *fp;
int tok;
int lnum;
} Psrc_t;
void Pinit (void);
void Pterm (void);
Tobj Punit (Psrc_t *);
Tobj Pfcall (Tobj, Tobj);
Tobj Pfunction (char *, int);
#endif /* _PARSE_H */
#ifdef __cplusplus
}
#endif
|
Add Code For nth Fibonacci Number in c | #include<stdio.h>
long long int fibonacci(long long int n)
{
//Because first fibonacci number is 0 and second fibonacci number is 1.
if(n==1 || n==2)
{
return (n-1);
}
else
{
//store last fibonacci number
long long int a=1;
//store second last fibonacci number
long long int b=0;
//store current fibonacci number
long long int nth_Fib;
for(long long int i=3;i<=n;i++)
{
nth_Fib = a+b;
b = a;
a = nth_Fib;
}
return nth_Fib;
}
}
int main()
{
long long int n;
printf("Enter a Number : ");
scanf("%lli",&n);
if(n<1)
{
printf("Number must be greater than 0");
}
else
{
long long int nth_Fib = fibonacci(n);
printf("Fibonacci Number is %lli",nth_Fib);
}
return 0;
} | |
Hide the system's version of the prototype for select(). We define it in "condor_fdset.h". | #ifndef FIX_LIMITS_H
#define FIX_LIMITS_H
#if defined(HPUX9)
# define select _hide_select
#endif
#include <limits.h>
#if defined(HPUX9)
# undef select
#endif
#endif
| |
Remove fieldWithID:withIndexPath:inForms: from public header | @import Foundation;
#import "HYPFormField.h"
@interface HYPFormsManager : NSObject
@property (nonatomic, strong) NSMutableArray *forms;
@property (nonatomic, strong) NSMutableDictionary *hiddenFields;
@property (nonatomic, strong) NSMutableDictionary *hiddenSections;
@property (nonatomic, strong) NSArray *disabledFieldsIDs;
@property (nonatomic, strong) NSMutableDictionary *values;
- (instancetype)initWithJSON:(id)JSON
initialValues:(NSDictionary *)initialValues
disabledFieldIDs:(NSArray *)disabledFieldIDs
disabled:(BOOL)disabled;
- (instancetype)initWithForms:(NSMutableArray *)forms
initialValues:(NSDictionary *)initialValues;
- (NSArray *)invalidFormFields;
- (NSDictionary *)requiredFormFields;
- (NSMutableDictionary *)valuesForFormula:(HYPFormField *)field;
- (HYPFormField *)fieldWithID:(NSString *)fieldID
withIndexPath:(BOOL)withIndexPath;
- (HYPFormField *)fieldWithID:(NSString *)fieldID
withIndexPath:(BOOL)withIndexPath
inForms:(NSArray *)forms;
@end
| @import Foundation;
#import "HYPFormField.h"
@interface HYPFormsManager : NSObject
@property (nonatomic, strong) NSMutableArray *forms;
@property (nonatomic, strong) NSMutableDictionary *hiddenFields;
@property (nonatomic, strong) NSMutableDictionary *hiddenSections;
@property (nonatomic, strong) NSArray *disabledFieldsIDs;
@property (nonatomic, strong) NSMutableDictionary *values;
- (instancetype)initWithJSON:(id)JSON
initialValues:(NSDictionary *)initialValues
disabledFieldIDs:(NSArray *)disabledFieldIDs
disabled:(BOOL)disabled;
- (instancetype)initWithForms:(NSMutableArray *)forms
initialValues:(NSDictionary *)initialValues;
- (NSArray *)invalidFormFields;
- (NSDictionary *)requiredFormFields;
- (NSMutableDictionary *)valuesForFormula:(HYPFormField *)field;
- (HYPFormField *)fieldWithID:(NSString *)fieldID
withIndexPath:(BOOL)withIndexPath;
@end
|
Change the type of Customer::id to std::size_t | #ifndef VRPSOLVER_CUSTOMER_H
#define VRPSOLVER_CUSTOMER_H
namespace VrpSolver {
class Customer {
public:
Customer(unsigned int id, std::size_t demand)
: id_(id), demand_(demand) {}
unsigned int id() const {
return id_;
}
std::size_t demand() const {
return demand_;
}
private:
Customer();
unsigned int id_;
std::size_t demand_;
};
} // namespace VrpSolver
#endif // VRPSOLVER_CUSTOMER_H
| #ifndef VRPSOLVER_CUSTOMER_H
#define VRPSOLVER_CUSTOMER_H
namespace VrpSolver {
class Customer {
public:
Customer(std::size_t id, std::size_t demand)
: id_(id), demand_(demand) {}
std::size_t id() const {
return id_;
}
std::size_t demand() const {
return demand_;
}
private:
Customer();
std::size_t id_;
std::size_t demand_;
};
} // namespace VrpSolver
#endif // VRPSOLVER_CUSTOMER_H
|
Add comments for header file | //
// PBRequest.h
// Pbind <https://github.com/wequick/Pbind>
//
// Created by galen on 15/2/12.
// Copyright (c) 2015-present, Wequick.net. All rights reserved.
//
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
//
#import <Foundation/Foundation.h>
/**
An instance of PBRequest defines the base factors of fetching a data.
@discussion Cause the private ProtocolBuffer.framework use the same class name,
we had to rename it as _PBRequest, but owe to the ability of `@compatibility_alias` annotation,
we can also use PBRequest in our source code.
*/
@interface _PBRequest : NSObject
@property (nonatomic, strong) NSString *action; // Interface action.
@property (nonatomic, strong) NSString *method; // Interface action.
@property (nonatomic, strong) NSDictionary *params; // Major params.
@property (nonatomic, strong) NSDictionary *extParams; // Minor params.
/**
Whether the response data should be mutable, default is NO.
@discussion if set to YES then will convert all the response data from NSDictionary to PBDictionary in nested.
*/
@property (nonatomic, assign) BOOL requiresMutableResponse;
@end
@compatibility_alias PBRequest _PBRequest;
| //
// PBRequest.h
// Pbind <https://github.com/wequick/Pbind>
//
// Created by galen on 15/2/12.
// Copyright (c) 2015-present, Wequick.net. All rights reserved.
//
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
//
#import <Foundation/Foundation.h>
/**
An instance of PBRequest defines the base factors of fetching a data.
@discussion Cause the private ProtocolBuffer.framework use the same class name,
we had to rename it as _PBRequest, but owe to the ability of `@compatibility_alias` annotation,
we can also use PBRequest in our source code.
*/
@interface _PBRequest : NSObject
/**
The API name for the request.
*/
@property (nonatomic, strong) NSString *action;
/**
The method for the request which defined in RESTFul way.
@discussion Include:
- get
- post
- put
- patch
- delete
*/
@property (nonatomic, strong) NSString *method;
/**
The parameters for the request.
*/
@property (nonatomic, strong) NSDictionary *params;
/**
Whether the response data should be mutable, default is NO.
@discussion if set to YES then will convert all the response data from NSDictionary to PBDictionary in nested.
*/
@property (nonatomic, assign) BOOL requiresMutableResponse;
@end
@compatibility_alias PBRequest _PBRequest;
|
Update header + licence information | /*
* rbcoremidi.c
* rbcoremidi
*
* Created by cypher on 15.07.08.
* Copyright 2008 Nuclear Squid. All rights reserved.
*
*/
#include <ruby.h>
VALUE crbCoreMidi;
void Init_rbcoremidi (void)
{
// Add the initialization code of your module here.
}
| /*
* Copyright 2008 Markus Prinz
* Released unter an MIT licence
*
*/
#include <ruby.h>
VALUE crbCoreMidi;
void Init_rbcoremidi (void)
{
// Add the initialization code of your module here.
}
|
Update execvp error message on file not found | #include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int
main(int argc, char **argv)
{
pid_t pid;
assert(argc > 0);
if (argc < 2) {
printf("usage: %s command [arguments...]\n", argv[0]);
return 1;
}
pid = fork();
if (pid < 0) {
perror("fork");
return 1;
}
if (pid == 0) {
execvp(argv[1], argv + 1);
perror("execvp");
return 1;
}
assert(pid > 0);
if (wait(NULL) != pid) {
perror("wait");
return 1;
}
return 0;
}
| #include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int
main(int argc, char **argv)
{
pid_t pid;
assert(argc > 0);
if (argc < 2) {
printf("usage: %s command [arguments...]\n", argv[0]);
return 1;
}
pid = fork();
if (pid < 0) {
perror("fork");
return 1;
}
if (pid == 0) {
execvp(argv[1], argv + 1);
perror(argv[1]);
return 1;
}
assert(pid > 0);
if (wait(NULL) != pid) {
perror("wait");
return 1;
}
return 0;
}
|
Add unittest to unittest group in doxygen | //===--------------------------------------------------------------------------------*- C++ -*-===//
// _
// | |
// __| | __ ___ ___ ___
// / _` |/ _` \ \ /\ / / '_ |
// | (_| | (_| |\ V V /| | | |
// \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain
//
//
// This file is distributed under the MIT License (MIT).
// See LICENSE.txt for details.
//
//===------------------------------------------------------------------------------------------===//
#ifndef DAWN_UNITTEST_UNITTESTLOGGER_H
#define DAWN_UNITTEST_UNITTESTLOGGER_H
#include "dawn/Support/Logging.h"
namespace dawn {
/// @brief Simple logger to std::cout for debugging purposes
class UnittestLogger : public LoggerInterface {
public:
void log(LoggingLevel level, const std::string& message, const char* file, int line) override;
};
} // namespace dawn
#endif
| //===--------------------------------------------------------------------------------*- C++ -*-===//
// _
// | |
// __| | __ ___ ___ ___
// / _` |/ _` \ \ /\ / / '_ |
// | (_| | (_| |\ V V /| | | |
// \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain
//
//
// This file is distributed under the MIT License (MIT).
// See LICENSE.txt for details.
//
//===------------------------------------------------------------------------------------------===//
#ifndef DAWN_UNITTEST_UNITTESTLOGGER_H
#define DAWN_UNITTEST_UNITTESTLOGGER_H
#include "dawn/Support/Logging.h"
namespace dawn {
/// @brief Simple logger to `std::cout` for debugging purposes
/// @ingroup unittest
class UnittestLogger : public LoggerInterface {
public:
void log(LoggingLevel level, const std::string& message, const char* file, int line) override;
};
} // namespace dawn
#endif
|
Include the component implementation include helper instead of the individual components in Components.h. | // THIS FILE IS AUTO GENERATED, EDIT AT YOUR OWN RISK
//% L
#ifndef COMPONENTS_ENTITIES_H_
#define COMPONENTS_ENTITIES_H_
//% L
#include "Components.h"
//% L
{% for component in components %}
#include "{{component.get_type_name()}}.h"
{% endfor %}
//% L
// Entity definitions
//% L
{% for entity in entities %}
//% L
// Definition of {{entity.get_type_name()}}
//% L
class {{entity.get_type_name()}}: public Entity {
//* The vtables for each entities are statically defined
static const MessageHandler messageHandlers[];
static const int componentOffsets[];
//% L
public:
//* Default constructor
{{entity.get_type_name()}}(
{% for (i, attrib) in enumerate(general.common_entity_attributes) %}
{% if i != 0 %}, {% endif %} {{attrib.get_declaration()}}
{% endfor %}
);
virtual ~{{entity.get_type_name()}}();
//% L
//* The components
{% for component in entity.get_components() %}
{{component.get_type_name()}} {{component.get_variable_name()}};
{% endfor %}
};
//% L
{% endfor %}
//% LL
#endif // COMPONENTS_ENTITIES_H_
//% L
| // THIS FILE IS AUTO GENERATED, EDIT AT YOUR OWN RISK
//% L
#ifndef COMPONENTS_ENTITIES_H_
#define COMPONENTS_ENTITIES_H_
//% L
#include "Components.h"
#include "ComponentImplementationInclude.h"
//% L
// Entity definitions
//% L
{% for entity in entities %}
//% L
// Definition of {{entity.get_type_name()}}
//% L
class {{entity.get_type_name()}}: public Entity {
//* The vtables for each entities are statically defined
static const MessageHandler messageHandlers[];
static const int componentOffsets[];
//% L
public:
//* Default constructor
{{entity.get_type_name()}}(
{% for (i, attrib) in enumerate(general.common_entity_attributes) %}
{% if i != 0 %}, {% endif %} {{attrib.get_declaration()}}
{% endfor %}
);
virtual ~{{entity.get_type_name()}}();
//% L
//* The components
{% for component in entity.get_components() %}
{{component.get_type_name()}} {{component.get_variable_name()}};
{% endfor %}
};
//% L
{% endfor %}
//% LL
#endif // COMPONENTS_ENTITIES_H_
//% L
|
Add a test case for microtask dispatch with many arguments | // RUN: %libomp-compile-and-run
#include <stdio.h>
int main()
{
int i1 = 0;
int i2 = 1;
int i3 = 2;
int i4 = 3;
int i5 = 4;
int i6 = 6;
int i7 = 7;
int i8 = 8;
int i9 = 9;
int i10 = 10;
int i11 = 11;
int i12 = 12;
int i13 = 13;
int i14 = 14;
int i15 = 15;
int i16 = 16;
int r = 0;
#pragma omp parallel for firstprivate(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16) reduction(+:r)
for (int i = 0; i < i16; i++) {
r += i + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12 + i13 + i14 + i15 + i16;
}
int rf = 2216;
if (r != rf) {
fprintf(stderr, "r should be %d but instead equals %d\n", rf, r);
return 1;
}
return 0;
}
| |
Make a test work if run by the super-user | // RUN: %clang_profgen -o %t -O3 %s
// RUN: touch %t.profraw
// RUN: chmod -w %t.profraw
// RUN: env LLVM_PROFILE_FILE=%t.profraw LLVM_PROFILE_VERBOSE_ERRORS=1 %run %t 1 2>&1 | FileCheck %s
// RUN: chmod +w %t.profraw
int main(int argc, const char *argv[]) {
if (argc < 2)
return 1;
return 0;
}
// CHECK: LLVM Profile: Failed to write file
| // RUN: %clang_profgen -o %t -O3 %s
// RUN: env LLVM_PROFILE_FILE="/" LLVM_PROFILE_VERBOSE_ERRORS=1 %run %t 1 2>&1 | FileCheck %s
int main(int argc, const char *argv[]) {
if (argc < 2)
return 1;
return 0;
}
// CHECK: LLVM Profile: Failed to write file
|
Update update and create block signatures. |
#pragma mark Forward Declarations
@class AFObjectProvider;
#pragma mark Type Definitions
typedef void (^AFObjectUpdateBlock)(AFObjectProvider *provider, id object, NSDictionary *values);
typedef id (^AFObjectCreateBlock)(AFObjectProvider *provider, NSDictionary *values);
#pragma mark - Class Interface
@interface AFObjectModel : NSObject
#pragma mark - Properties
@property (nonatomic, strong) Class myClass;
@property (nonatomic, copy) NSArray *idProperties;
@property (nonatomic, copy) NSDictionary *propertyKeyMap;
@property (nonatomic, copy) NSDictionary *collectionTypeMap;
@property (nonatomic, copy) AFObjectUpdateBlock updateBlock;
@property (nonatomic, copy) AFObjectCreateBlock createBlock;
#pragma mark - Constructors
- (id)initWithClass: (Class)myClass
idProperties: (NSArray *)idProperties
propertyKeyMap: (NSDictionary *)propertyKeyMap
collectionTypeMap: (NSDictionary *)collectionTypeMap
updateBlock: (AFObjectUpdateBlock)updateBlock
createBlock: (AFObjectCreateBlock)createBlock;
#pragma mark - Static Methods
+ (id)objectModelWithClass: (Class)myClass
idProperties: (NSArray *)idProperties
propertyKeyMap: (NSDictionary *)propertyKeyMap
collectionTypeMap: (NSDictionary *)collectionTypeMap
updateBlock: (AFObjectUpdateBlock)updateBlock
createBlock: (AFObjectCreateBlock)createBlock;
@end // @interface AFObjectModel |
#pragma mark Forward Declarations
@class AFObjectProvider;
#pragma mark Type Definitions
typedef void (^AFObjectUpdateBlock)(id provider, id object, NSDictionary *values);
typedef id (^AFObjectCreateBlock)(id provider, NSDictionary *values);
#pragma mark - Class Interface
@interface AFObjectModel : NSObject
#pragma mark - Properties
@property (nonatomic, strong) Class myClass;
@property (nonatomic, copy) NSArray *idProperties;
@property (nonatomic, copy) NSDictionary *propertyKeyMap;
@property (nonatomic, copy) NSDictionary *collectionTypeMap;
@property (nonatomic, copy) AFObjectUpdateBlock updateBlock;
@property (nonatomic, copy) AFObjectCreateBlock createBlock;
#pragma mark - Constructors
- (id)initWithClass: (Class)myClass
idProperties: (NSArray *)idProperties
propertyKeyMap: (NSDictionary *)propertyKeyMap
collectionTypeMap: (NSDictionary *)collectionTypeMap
updateBlock: (AFObjectUpdateBlock)updateBlock
createBlock: (AFObjectCreateBlock)createBlock;
#pragma mark - Static Methods
+ (id)objectModelWithClass: (Class)myClass
idProperties: (NSArray *)idProperties
propertyKeyMap: (NSDictionary *)propertyKeyMap
collectionTypeMap: (NSDictionary *)collectionTypeMap
updateBlock: (AFObjectUpdateBlock)updateBlock
createBlock: (AFObjectCreateBlock)createBlock;
@end // @interface AFObjectModel |
Correct fuzzy and fragile IRQ_RETVAL() definition | #ifndef _LINUX_IRQRETURN_H
#define _LINUX_IRQRETURN_H
/**
* enum irqreturn
* @IRQ_NONE interrupt was not from this device
* @IRQ_HANDLED interrupt was handled by this device
* @IRQ_WAKE_THREAD handler requests to wake the handler thread
*/
enum irqreturn {
IRQ_NONE = (0 << 0),
IRQ_HANDLED = (1 << 0),
IRQ_WAKE_THREAD = (1 << 1),
};
typedef enum irqreturn irqreturn_t;
#define IRQ_RETVAL(x) ((x) != IRQ_NONE)
#endif
| #ifndef _LINUX_IRQRETURN_H
#define _LINUX_IRQRETURN_H
/**
* enum irqreturn
* @IRQ_NONE interrupt was not from this device
* @IRQ_HANDLED interrupt was handled by this device
* @IRQ_WAKE_THREAD handler requests to wake the handler thread
*/
enum irqreturn {
IRQ_NONE = (0 << 0),
IRQ_HANDLED = (1 << 0),
IRQ_WAKE_THREAD = (1 << 1),
};
typedef enum irqreturn irqreturn_t;
#define IRQ_RETVAL(x) ((x) ? IRQ_HANDLED : IRQ_NONE)
#endif
|
Define a few internal macros for easy use of run_once functions | /*
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <openssl/crypto.h>
#define DEFINE_RUN_ONCE(init) \
static int init(void); \
int init##_ossl_ret_ = 0; \
void init##_ossl_(void) \
{ \
init##_ossl_ret_ = init(); \
} \
static int init(void)
#define DECLARE_RUN_ONCE(init) \
extern int init##_ossl_ret_; \
void init##_ossl_(void);
#define DEFINE_RUN_ONCE_STATIC(init) \
static int init(void); \
static int init##_ossl_ret_ = 0; \
static void init##_ossl_(void) \
{ \
init##_ossl_ret_ = init(); \
} \
static int init(void)
/*
* RUN_ONCE - use CRYPTO_THREAD_run_once, and check if the init succeeded
* @once: pointer to static object of type CRYPTO_ONCE
* @init: function name that was previously given to DEFINE_RUN_ONCE,
* DEFINE_RUN_ONCE_STATIC or DECLARE_RUN_ONCE.
*
* The return value is 1 on success or 0 in case of error.
*/
#define RUN_ONCE(once, init) \
(CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
| |
Allow use of inline keyword in c++/c99 mode | /* Copyright 2013 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Common types
*/
#ifndef BROTLI_DEC_TYPES_H_
#define BROTLI_DEC_TYPES_H_
#include <stddef.h> /* for size_t */
#ifndef _MSC_VER
#include <inttypes.h>
#ifdef __STRICT_ANSI__
#define BROTLI_INLINE
#else /* __STRICT_ANSI__ */
#define BROTLI_INLINE inline
#endif
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef long long int int64_t;
#define BROTLI_INLINE __forceinline
#endif /* _MSC_VER */
#endif /* BROTLI_DEC_TYPES_H_ */
| /* Copyright 2013 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Common types
*/
#ifndef BROTLI_DEC_TYPES_H_
#define BROTLI_DEC_TYPES_H_
#include <stddef.h> /* for size_t */
#ifndef _MSC_VER
#include <inttypes.h>
#if defined(__cplusplus) || !defined(__STRICT_ANSI__) \
|| __STDC_VERSION__ >= 199901L
#define BROTLI_INLINE inline
#else
#define BROTLI_INLINE
#endif
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef long long int int64_t;
#define BROTLI_INLINE __forceinline
#endif /* _MSC_VER */
#endif /* BROTLI_DEC_TYPES_H_ */
|
Fix compilation for case-sensitive file systems. | #ifndef __FILTERIMPORTEREXPORTER_H__
#define __FILTERIMPORTEREXPORTER_H__
#include <qvalueList.h>
class KMFilter;
class KConfig;
namespace KMail
{
/**
@short Utility class that provides persisting of filters to/from KConfig.
@author Till Adam <till@kdab.net>
*/
class FilterImporterExporter
{
public:
FilterImporterExporter( bool popFilter = false );
virtual ~FilterImporterExporter();
/** Export the given filter rules to a file which
* is asked from the user. The list to export is also
* presented for confirmation/selection. */
void exportFilters( const QValueList<KMFilter*> & );
/** Import filters. Ask the user where to import them from
* and which filters to import. */
QValueList<KMFilter*> importFilters();
static void writeFiltersToConfig( const QValueList<KMFilter*>& filters, KConfig* config, bool bPopFilter );
static QValueList<KMFilter*> readFiltersFromConfig( KConfig* config, bool bPopFilter );
private:
bool mPopFilter;
};
}
#endif /* __FILTERIMPORTEREXPORTER_H__ */
| #ifndef __FILTERIMPORTEREXPORTER_H__
#define __FILTERIMPORTEREXPORTER_H__
#include <qvaluelist.h>
class KMFilter;
class KConfig;
namespace KMail
{
/**
@short Utility class that provides persisting of filters to/from KConfig.
@author Till Adam <till@kdab.net>
*/
class FilterImporterExporter
{
public:
FilterImporterExporter( bool popFilter = false );
virtual ~FilterImporterExporter();
/** Export the given filter rules to a file which
* is asked from the user. The list to export is also
* presented for confirmation/selection. */
void exportFilters( const QValueList<KMFilter*> & );
/** Import filters. Ask the user where to import them from
* and which filters to import. */
QValueList<KMFilter*> importFilters();
static void writeFiltersToConfig( const QValueList<KMFilter*>& filters, KConfig* config, bool bPopFilter );
static QValueList<KMFilter*> readFiltersFromConfig( KConfig* config, bool bPopFilter );
private:
bool mPopFilter;
};
}
#endif /* __FILTERIMPORTEREXPORTER_H__ */
|
Add client test program to measure speed of message handling. | #include <arpa/inet.h>
#include <endian.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
int main()
{
struct sockaddr_in serv_addr;
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
serv_addr.sin_port = htons(11122);
int fd = socket(AF_INET, SOCK_STREAM, 0);
static const int tcp_nodelay_on = 1;
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &tcp_nodelay_on, sizeof(tcp_nodelay_on)) < 0) {
fprintf(stderr, "Could not set TCP_NODELAY\n");
return EXIT_FAILURE;
}
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
fprintf(stderr, "Failed to connect with server\n");
return EXIT_FAILURE;
}
char buffer[1000];
char *write_ptr = buffer;
const char msg[] = "bla";
uint32_t len = strlen(msg);
len = htobe32(len);
memcpy(write_ptr, &len, sizeof(len));
write_ptr += sizeof(len);
memcpy(write_ptr, msg, strlen(msg));
int i;
for (i = 0; i < 1000000; i++) {
write(fd, buffer, sizeof(len) + strlen(msg));
uint32_t msg_len;
ssize_t got = read(fd, &msg_len, sizeof(msg_len));
if (got != sizeof(msg_len)) {
fprintf(stderr, "could not read enough for msg_len: %zd\n", got);
return EXIT_FAILURE;
}
msg_len = be32toh(msg_len);
if (msg_len != be32toh(len)) {
fprintf(stderr, "msglen != len\n");
}
char read_buffer[1000];
got = read(fd, read_buffer, msg_len);
if (got != msg_len) {
fprintf(stderr, "could not read enough of message!\n");
}
read_buffer[msg_len] = '\0';
if (strcmp(read_buffer, msg) != 0) {
fprintf(stderr, "received message not the same like send!\n");
}
}
close(fd);
return EXIT_SUCCESS;
}
| |
Add UNLIKELY for compiler optimization | #ifndef LYNX_BASE_COMPILER_SPECIFIC_H_
#define LYNX_BASE_COMPILER_SPECIFIC_H_
#if !defined(UNLIKELY)
#if defined(COMPILER_GCC)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define UNLIKELY(x) (x)
#endif
#endif
#endif | |
Remove my copyright. This file includes simply i386's one now. | /*-
* Copyright (C) 2005 TAKAHASHI Yoshihiro. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _PC98_INCLUDE_CLOCK_H_
#define _PC98_INCLUDE_CLOCK_H_
#include <i386/clock.h>
#endif /* _PC98_INCLUDE_CLOCK_H_ */
| /*-
* This file is in the public domain.
*/
/* $FreeBSD$ */
#include <i386/clock.h>
|
Add android main for sdl | #pragma once
#include "onair/okui/config.h"
#if SCRAPS_ANDROID
#include <SDL2/SDL_main.h>
#include <jni.h>
extern "C" {
/* Called before SDL_main() to initialize JNI bindings in SDL library */
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
/* Start up the SDL app */
JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
{
int i;
int argc;
int status;
/* This interface could expand with ABI negotiation, callbacks, etc. */
SDL_Android_Init(env, cls);
SDL_SetMainReady();
/* Prepare the arguments. */
int len = env->GetArrayLength((jobjectArray)array);
char* argv[1 + len + 1];
argc = 0;
/* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
*/
argv[argc++] = SDL_strdup("app_process");
for (i = 0; i < len; ++i) {
const char* utf;
char* arg = NULL;
jstring string = (jstring)env->GetObjectArrayElement((jobjectArray)array, i);
if (string) {
utf = env->GetStringUTFChars(string, 0);
if (utf) {
arg = SDL_strdup(utf);
env->ReleaseStringUTFChars(string, utf);
}
env->DeleteLocalRef(string);
}
if (!arg) {
arg = SDL_strdup("");
}
argv[argc++] = arg;
}
argv[argc] = NULL;
/* Run the application. */
status = SDL_main(argc, argv);
/* Release the arguments. */
for (i = 0; i < argc; ++i) {
SDL_free(argv[i]);
}
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
/* exit(status); */
return status;
}
}
#endif
| |
Fix not yet corrected NAMESPACE macro | #pragma once
#if !defined( NS_CONCAT_ )
#define NS_CONCAT_( A, B ) A##B
#endif /* !defined( NS_CONCAT ) */
#if !defined( NS_CONCAT )
#define NS_CONCAT( A, B ) NS_CONCAT_( A, B )
#endif /* !defined( NS_CONCAT ) */
#if !defined( NAMESPACE )
#define NAMESPACE
#endif /* !defined( NAMESPACE ) */
#if !defined( NS )
#define NS(name) NS_CONCAT( NAMESPACE, name )
#endif /* !defined( NS ) */
/* end: sixtracklib/_impl/namespace_begin.h */
| #pragma once
#if !defined( NS_CONCAT_ )
#define NS_CONCAT_( A, B ) A##B
#endif /* !defined( NS_CONCAT ) */
#if !defined( NS_CONCAT )
#define NS_CONCAT( A, B ) NS_CONCAT_( A, B )
#endif /* !defined( NS_CONCAT ) */
#if !defined( __NAMESPACE )
#define __NAMESPACE
#endif /* !defined( __NAMESPACE ) */
#if !defined( NS )
#define NS(name) NS_CONCAT( __NAMESPACE, name )
#endif /* !defined( NS ) */
/* end: sixtracklib/_impl/namespace_begin.h */
|
Change interface of IsPointQuery() in header file | //===----------------------------------------------------------------------===//
//
// Peloton
//
// index_util.h
//
// Identification: src/include/index/index_util.h
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#pragma once
#include "index/index.h"
namespace peloton {
namespace index {
void ConstructIntervals(oid_t leading_column_id,
const std::vector<Value> &values,
const std::vector<oid_t> &key_column_ids,
const std::vector<ExpressionType> &expr_types,
std::vector<std::pair<Value, Value>> &intervals);
void FindMaxMinInColumns(oid_t leading_column_id,
const std::vector<Value> &values,
const std::vector<oid_t> &key_column_ids,
const std::vector<ExpressionType> &expr_types,
std::map<oid_t, std::pair<Value, Value>> &non_leading_columns);
bool HasNonOptimizablePredicate(const std::vector<ExpressionType> &expr_types);
bool IsPointQuery(const IndexMetadata *metadata_p,
const std::vector<oid_t> &tuple_column_id_list,
const std::vector<ExpressionType> &expr_list);
} // End index namespace
} // End peloton namespace
| //===----------------------------------------------------------------------===//
//
// Peloton
//
// index_util.h
//
// Identification: src/include/index/index_util.h
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#pragma once
#include "index/index.h"
namespace peloton {
namespace index {
void ConstructIntervals(oid_t leading_column_id,
const std::vector<Value> &values,
const std::vector<oid_t> &key_column_ids,
const std::vector<ExpressionType> &expr_types,
std::vector<std::pair<Value, Value>> &intervals);
void FindMaxMinInColumns(oid_t leading_column_id,
const std::vector<Value> &values,
const std::vector<oid_t> &key_column_ids,
const std::vector<ExpressionType> &expr_types,
std::map<oid_t, std::pair<Value, Value>> &non_leading_columns);
bool HasNonOptimizablePredicate(const std::vector<ExpressionType> &expr_types);
bool IsPointQuery(const IndexMetadata *metadata_p,
const std::vector<oid_t> &tuple_column_id_list,
const std::vector<ExpressionType> &expr_list,
std::vector<std::pair<oid_t, oid_t>> &value_index_list);
} // End index namespace
} // End peloton namespace
|
Use <> import syntax for umbrella header | //
// Motif.h
// Motif
//
// Created by Eric Horacek on 3/29/15.
// Copyright (c) 2015 Eric Horacek. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for Motif.
FOUNDATION_EXPORT double MotifVersionNumber;
//! Project version string for Motif.
FOUNDATION_EXPORT const unsigned char MotifVersionString[];
#import "MTFBackwardsCompatableNullability.h"
#import "MTFTheme.h"
#import "MTFThemeClass.h"
#import "MTFThemeClassApplicable.h"
#import "MTFDynamicThemeApplier.h"
#import "MTFThemeParser.h"
#import "NSObject+ThemeClassAppliers.h"
#import "NSObject+ThemeClassName.h"
#import "MTFReverseTransformedValueClass.h"
#import "MTFObjCTypeValueTransformer.h"
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#import "MTFScreenBrightnessThemeApplier.h"
#import "MTFColorFromStringTransformer.h"
#import "MTFEdgeInsetsFromStringTransformer.h"
#import "MTFPointFromStringTransformer.h"
#import "MTFRectFromStringTransformer.h"
#import "MTFSizeFromStringTransformer.h"
#endif
| //
// Motif.h
// Motif
//
// Created by Eric Horacek on 3/29/15.
// Copyright (c) 2015 Eric Horacek. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for Motif.
FOUNDATION_EXPORT double MotifVersionNumber;
//! Project version string for Motif.
FOUNDATION_EXPORT const unsigned char MotifVersionString[];
#import <Motif/MTFBackwardsCompatableNullability.h>
#import <Motif/MTFTheme.h>
#import <Motif/MTFThemeClass.h>
#import <Motif/MTFThemeClassApplicable.h>
#import <Motif/MTFDynamicThemeApplier.h>
#import <Motif/MTFThemeParser.h>
#import <Motif/NSObject+ThemeClassAppliers.h>
#import <Motif/NSObject+ThemeClassName.h>
#import <Motif/MTFReverseTransformedValueClass.h>
#import <Motif/MTFObjCTypeValueTransformer.h>
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#import <Motif/MTFScreenBrightnessThemeApplier.h>
#import <Motif/MTFColorFromStringTransformer.h>
#import <Motif/MTFEdgeInsetsFromStringTransformer.h>
#import <Motif/MTFPointFromStringTransformer.h>
#import <Motif/MTFRectFromStringTransformer.h>
#import <Motif/MTFSizeFromStringTransformer.h>
#endif
|
Rename the radio event handler. | #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "radio.h"
void radio_event_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
radio_packet_t packet;
packet.len = 4;
radio_init(radio_event_handler);
NRF_GPIO->DIR = 1 << 18;
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
radio_send(&packet);
NRF_GPIO->OUTSET = 1 << 18;
nrf_delay_us(100000);
NRF_GPIO->OUTCLR = 1 << 18;
nrf_delay_us(100000);
}
}
| #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "radio.h"
void radio_evt_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;
radio_init(radio_evt_handler);
NRF_GPIO->DIR = 1 << 18;
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
radio_send(&packet);
NRF_GPIO->OUTSET = 1 << 18;
nrf_delay_us(100000);
NRF_GPIO->OUTCLR = 1 << 18;
nrf_delay_us(100000);
}
}
|
Fix incorrect is_sorted implementation in the test suite | /*
* Copyright (c) 2015-2018 Morwenn
* SPDX-License-Identifier: MIT
*/
#ifndef CPPSORT_TESTSUITE_ALGORITHM_H_
#define CPPSORT_TESTSUITE_ALGORITHM_H_
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <functional>
#include <iterator>
#include <cpp-sort/utility/as_function.h>
#include <cpp-sort/utility/functional.h>
namespace helpers
{
template<
typename Iterator,
typename Compare = std::less<>,
typename Projection = cppsort::utility::identity
>
auto is_sorted(Iterator first, Iterator last,
Compare compare={}, Projection projection={})
-> bool
{
auto&& comp = cppsort::utility::as_function(compare);
auto&& proj = cppsort::utility::as_function(projection);
for (auto it = std::next(first) ; it != last ; ++it) {
if (comp(proj(*it), proj(*first))) {
return false;
}
}
return true;
}
template<
typename ForwardIterator,
typename T,
typename Projection = cppsort::utility::identity
>
auto iota(ForwardIterator first, ForwardIterator last,
T value, Projection projection={})
-> void
{
auto&& proj = cppsort::utility::as_function(projection);
while (first != last)
{
proj(*first++) = value;
++value;
}
}
}
#endif // CPPSORT_TESTSUITE_ALGORITHM_H_
| /*
* Copyright (c) 2015-2021 Morwenn
* SPDX-License-Identifier: MIT
*/
#ifndef CPPSORT_TESTSUITE_ALGORITHM_H_
#define CPPSORT_TESTSUITE_ALGORITHM_H_
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <functional>
#include <cpp-sort/utility/as_function.h>
#include <cpp-sort/utility/functional.h>
namespace helpers
{
template<
typename Iterator,
typename Compare = std::less<>,
typename Projection = cppsort::utility::identity
>
constexpr auto is_sorted(Iterator first, Iterator last,
Compare compare={}, Projection projection={})
-> bool
{
auto&& comp = cppsort::utility::as_function(compare);
auto&& proj = cppsort::utility::as_function(projection);
if (first == last) {
return true;
}
auto next = first;
while (++next != last) {
if (comp(proj(*next), proj(*first))) {
return false;
}
++first;
}
return true;
}
template<
typename ForwardIterator,
typename T,
typename Projection = cppsort::utility::identity
>
auto iota(ForwardIterator first, ForwardIterator last,
T value, Projection projection={})
-> void
{
auto&& proj = cppsort::utility::as_function(projection);
while (first != last)
{
proj(*first++) = value;
++value;
}
}
}
#endif // CPPSORT_TESTSUITE_ALGORITHM_H_
|
Make assembly prologue match new memory map | #ifndef RAM_H_
#define RAM_H_
#define RAM_BASE (1ULL << 12)
#define RAM_END ((1ULL << 16) - 1)
#endif
| #ifndef RAM_H_
#define RAM_H_
#define RAM_BASE (1ULL << 12)
#define RAM_END ((1ULL << 14) - 1)
#endif
|
Remove phys_to_abs() now all users have been removed | #ifndef _ASM_POWERPC_ABS_ADDR_H
#define _ASM_POWERPC_ABS_ADDR_H
#ifdef __KERNEL__
/*
* c 2001 PPC 64 Team, IBM Corp
*
* 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/memblock.h>
#include <asm/types.h>
#include <asm/page.h>
#include <asm/prom.h>
#define phys_to_abs(pa) (pa)
/* Convenience macros */
#define virt_to_abs(va) __pa(va)
#define abs_to_virt(aa) __va(aa)
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_ABS_ADDR_H */
| #ifndef _ASM_POWERPC_ABS_ADDR_H
#define _ASM_POWERPC_ABS_ADDR_H
#ifdef __KERNEL__
/*
* c 2001 PPC 64 Team, IBM Corp
*
* 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/memblock.h>
#include <asm/types.h>
#include <asm/page.h>
#include <asm/prom.h>
/* Convenience macros */
#define virt_to_abs(va) __pa(va)
#define abs_to_virt(aa) __va(aa)
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_ABS_ADDR_H */
|
Add C to F program | #include <stdio.h>
/* print Celsius to Fahrenheit table
* for Fahrenheit 0, 20, ..., 300 */
int main()
{
float fahr;
float cel;
int lower;
int upper;
int step;
lower = 0; /* lower bound for the table */
upper = 150; /* upper bound for the table */
step = 10; /* amount to step by */
printf(" C \t");
printf(" F \n");
cel = lower;
while (cel <= upper) {
fahr = (9.0 / 5.0 * cel) + 32.0;
/* cel = (5.0 / 9.0) * (fahr - 32.0); */
printf("%6.0f\t%3.1f\n", cel, fahr);
cel += step;
}
}
| |
Reorder function definitions to match their order in the header file. | /**
* Win32 UTF-8 wrapper
*
* ----
*
* shlwapi.dll functions.
*/
#include <Shlwapi.h>
#include "win32_utf8.h"
BOOL STDAPICALLTYPE PathMatchSpecU(
__in LPCSTR pszFile,
__in LPCSTR pszSpec
)
{
BOOL ret;
WCHAR_T_DEC(pszFile);
WCHAR_T_DEC(pszSpec);
WCHAR_T_CONV(pszFile);
WCHAR_T_CONV(pszSpec);
ret = PathMatchSpecW(pszFile_w, pszSpec_w);
VLA_FREE(pszFile_w);
VLA_FREE(pszSpec_w);
return ret;
}
BOOL STDAPICALLTYPE PathFileExistsU(
__in LPCSTR pszPath
)
{
BOOL ret;
WCHAR_T_DEC(pszPath);
WCHAR_T_CONV(pszPath);
ret = PathFileExistsW(pszPath_w);
VLA_FREE(pszPath_w);
return ret;
}
BOOL STDAPICALLTYPE PathRemoveFileSpecU(
__inout LPSTR pszPath
)
{
// Hey, let's re-write the function to also handle forward slashes
// while we're at it!
LPSTR newPath = PathFindFileNameA(pszPath);
if((newPath) && (newPath != pszPath)) {
newPath[0] = TEXT('\0');
return 1;
}
return 0;
}
| /**
* Win32 UTF-8 wrapper
*
* ----
*
* shlwapi.dll functions.
*/
#include <Shlwapi.h>
#include "win32_utf8.h"
BOOL STDAPICALLTYPE PathFileExistsU(
__in LPCSTR pszPath
)
{
BOOL ret;
WCHAR_T_DEC(pszPath);
WCHAR_T_CONV_VLA(pszPath);
ret = PathFileExistsW(pszPath_w);
VLA_FREE(pszPath_w);
return ret;
}
BOOL STDAPICALLTYPE PathMatchSpecU(
__in LPCSTR pszFile,
__in LPCSTR pszSpec
)
{
BOOL ret;
WCHAR_T_DEC(pszFile);
WCHAR_T_DEC(pszSpec);
WCHAR_T_CONV(pszFile);
WCHAR_T_CONV(pszSpec);
ret = PathMatchSpecW(pszFile_w, pszSpec_w);
VLA_FREE(pszFile_w);
VLA_FREE(pszSpec_w);
return ret;
}
BOOL STDAPICALLTYPE PathRemoveFileSpecU(
__inout LPSTR pszPath
)
{
// Hey, let's re-write the function to also handle forward slashes
// while we're at it!
LPSTR newPath = PathFindFileNameA(pszPath);
if((newPath) && (newPath != pszPath)) {
newPath[0] = TEXT('\0');
return 1;
}
return 0;
}
|
Add a centralized dispatcher for softnet interrupts. This is so that we won't need to change every arch on a softnet change. | /* $NetBSD: netisr_dispatch.h,v 1.2 2000/07/02 04:40:47 cgd Exp $ */
/*
* netisr_dispatch: This file is included by the
* machine dependant softnet function. The
* DONETISR macro should be set before including
* this file. i.e.:
*
* softintr() {
* ...do setup stuff...
* #define DONETISR(bit, fn) do { ... } while (0)
* #include <net/netisr_dispatch.h>
* #undef DONETISR
* ...do cleanup stuff.
* }
*/
#ifndef _NET_NETISR_H_
#error <net/netisr.h> must be included before <net/netisr_dispatch.h>
#endif
/*
* When adding functions to this list, be sure to add headers to provide
* their prototypes in <net/netisr.h> (if necessary).
*/
#ifdef INET
#include "ether.h"
#if NETHER > 0
DONETISR(NETISR_ARP,arpintr);
#endif
DONETISR(NETISR_IP,ipintr);
#endif
#ifdef INET6
DONETISR(NETISR_IPV6,ip6intr);
#endif
#ifdef NETATALK
DONETISR(NETISR_ATALK,atintr);
#endif
#ifdef IMP
DONETISR(NETISR_IMP,impintr);
#endif
#ifdef IPX
DONETISR(NETISR_IPX,ipxintr);
#endif
#ifdef NS
DONETISR(NETISR_NS,nsintr);
#endif
#ifdef ISO
DONETISR(NETISR_ISO,clnlintr);
#endif
#ifdef CCITT
DONETISR(NETISR_CCITT,ccittintr);
#endif
#ifdef NATM
DONETISR(NETISR_NATM,natmintr);
#endif
#include "ppp.h"
#if NPPP > 0
DONETISR(NETISR_PPP,pppintr);
#endif
#include "bridge.h"
#if NBRIDGE > 0
DONETISR(NETISR_BRIDGE,bridgeintr);
#endif
| |
Replace modulo by AND gatter | /* Copyright (c) 2012 Fritz Grimpen
*
* Permission is hereby granted, unalloc 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.
*/
#define F_DICT_STRUCTS
#include <f/dict.h>
#define SLOT(h) (((h) * (F_DICT_SLOTS_COUNT - 1)) % F_DICT_SLOTS_COUNT)
#define BUCKET(d, h) ((h) % (d)->buckets_cnt)
| /* Copyright (c) 2012 Fritz Grimpen
*
* Permission is hereby granted, unalloc 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.
*/
#define F_DICT_STRUCTS
#include <f/dict.h>
#define SLOT(h) (((h) * (F_DICT_SLOTS_COUNT - 1)) & (F_DICT_SLOTS_COUNT - 1))
#define BUCKET(d, h) ((h) % (d)->buckets_cnt)
|
Revert accidental uncommenting of TYPE_ANIMATION |
#pragma once
// assume that visuals and code are the same here....
// and also assuming our screen is square :)
#define VISUALS_WIDTH 504
#define VISUALS_HEIGHT 504
#define CODE_WIDTH VISUALS_WIDTH
#define CODE_HEIGHT VISUALS_HEIGHT
#define CODE_X_POS 520 // via the tech staff
//if this is defined, we will wait for type animation
#define TYPE_ANIMATION
#define USE_MIDI_PARAM_SYNC
// if this is defined, we will disable all sound playback inside this app, and instead send
// OpenSoundControl messages which can be used to trigger sounds in another program (e.g. Ableton Live)
//#define USE_EXTERNAL_SOUNDS |
#pragma once
// assume that visuals and code are the same here....
// and also assuming our screen is square :)
#define VISUALS_WIDTH 504
#define VISUALS_HEIGHT 504
#define CODE_WIDTH VISUALS_WIDTH
#define CODE_HEIGHT VISUALS_HEIGHT
#define CODE_X_POS 520 // via the tech staff
//if this is defined, we will wait for type animation
//#define TYPE_ANIMATION
#define USE_MIDI_PARAM_SYNC
// if this is defined, we will disable all sound playback inside this app, and instead send
// OpenSoundControl messages which can be used to trigger sounds in another program (e.g. Ableton Live)
//#define USE_EXTERNAL_SOUNDS |
Add logging etc. to lock release code. | // -*- c++ -*-
#ifndef LOCKS_H
#define LOCKS_H
#include <pthread.h>
namespace locks {
template <typename L>
void unlocker(void* lock_ptr)
{
L* lock = (L*) lock_ptr;
lock->unlock();
}
template <typename L>
void unlocker_checked(void* lock_ptr)
{
L& lock = *((L*) lock_ptr);
if (lock)
lock.unlock();
}
}
#endif /* LOCKS_H */
| // -*- c++ -*-
#ifndef LOCKS_H
#define LOCKS_H
#include <cstdio>
#include <pthread.h>
namespace locks {
template <typename L>
void unlocker(void* lock_ptr)
{
L* lock = (L*) lock_ptr;
fprintf(stderr, "Releasing lock (unchecked) during cancellation!\n");
lock->unlock();
}
template <typename L>
void unlocker_checked(void* lock_ptr)
{
L& lock = *((L*) lock_ptr);
if (lock.owns_lock()) {
fprintf(stderr, "Releasing lock (checked) during cancellation!\n");
lock.unlock();
}
}
}
#endif /* LOCKS_H */
|
Add missing macro from last commit. | #ifndef LIST_H
#define LIST_H
#define NEXT_NODE(node) node->next
#define FINDTAILNODE(x) if(x)while(x->next)x=x->next;
#define ADDNODEAFTER(x,t) if(x){t=x->next; x->next=malloc(sizeof(*t)); x->next->next=t;}
#endif
| #ifndef LIST_H
#define LIST_H
#define NEXT_NODE(node) node->next
#define FINDTAILNODE(x) if(x)while(x->next)x=x->next;
#define ADDNODE(x,t) if(x){t=x; x=malloc(sizeof(*x)); x->next=t;}
#define ADDNODEAFTER(x,t) if(x){t=x->next; x->next=malloc(sizeof(*t)); x->next->next=t;}
#endif
|
Fix possible divide by zero error | #ifndef UTIL_H
#define UTIL_H
#include <chrono>
#include <numeric>
#include <iterator>
#include <array>
#include <algorithm>
namespace util
{
class Timer
{
public:
Timer() = default;
Timer(bool start_running);
~Timer() = default;
void start();
void stop();
float stop_seconds();
float seconds();
private:
std::chrono::high_resolution_clock::time_point start_time;
std::chrono::high_resolution_clock::time_point stop_time;
};
namespace math
{
template<typename T> int mean(T collection)
{
return std::accumulate(std::begin(collection), std::end(collection), 0) / std::size(collection);
}
} // namespace math
} // namespace util
#endif // UTIL_H
| #ifndef UTIL_H
#define UTIL_H
#include <chrono>
#include <numeric>
#include <iterator>
#include <array>
#include <algorithm>
namespace util
{
class Timer
{
public:
Timer() = default;
Timer(bool start_running);
~Timer() = default;
void start();
void stop();
float stop_seconds();
float seconds();
private:
std::chrono::high_resolution_clock::time_point start_time;
std::chrono::high_resolution_clock::time_point stop_time;
};
namespace math
{
template<typename T> int mean(T collection)
{
if (std::size(collection) == 0)
return 0;
return std::accumulate(std::begin(collection), std::end(collection), 0) / std::size(collection);
}
} // namespace math
} // namespace util
#endif // UTIL_H
|
Fix narrowing conversion from double to float | #ifndef AL_MATH_DEFS_H
#define AL_MATH_DEFS_H
#include <math.h>
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif
#define F_PI (3.14159265358979323846f)
#define F_PI_2 (1.57079632679489661923f)
#define F_TAU (6.28318530717958647692f)
#define SQRTF_3 1.73205080756887719318f
constexpr inline float Deg2Rad(float x) noexcept { return x * float{M_PI/180.0}; }
constexpr inline float Rad2Deg(float x) noexcept { return x * float{180.0/M_PI}; }
#endif /* AL_MATH_DEFS_H */
| #ifndef AL_MATH_DEFS_H
#define AL_MATH_DEFS_H
#include <math.h>
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif
#define F_PI (3.14159265358979323846f)
#define F_PI_2 (1.57079632679489661923f)
#define F_TAU (6.28318530717958647692f)
#define SQRTF_3 1.73205080756887719318f
constexpr inline float Deg2Rad(float x) noexcept { return x * static_cast<float>(M_PI/180.0); }
constexpr inline float Rad2Deg(float x) noexcept { return x * static_cast<float>(180.0/M_PI); }
#endif /* AL_MATH_DEFS_H */
|
Fix incorrect LED header bit order | #ifndef PLATFORM_HW_H__
#define PLATFORM_HW_H__
#include <stdbool.h>
#include "color.h"
#include "stm32f0xx_hal.h"
#include "stm32f0xx_hal_gpio.h"
#define LED_CHAIN_LENGTH 10
#define USER_BUTTON_PORT (GPIOA)
#define USER_BUTTON_PIN (GPIO_PIN_0)
#define LED_SPI_INSTANCE (SPI1)
#pragma pack(push) /* push current alignment to stack */
#pragma pack(1) /* set alignment to 1 byte boundary */
union platformHW_LEDRegister {
uint8_t raw[4];
struct {
//header/global brightness is 0bAAABBBBB
//A = 1
//B = integer brightness divisor from 0x0 -> 0x1F
uint8_t const header :3;
//3 bits always, 5 bits global brightness, 8B, 8G, 8R
//Glob = 0xE1 = min bright
//uint8_t const globalHeader :8;
uint8_t globalBrightness :5;
struct color_ColorRGB color;
};
};
#pragma pack(pop) /* restore original alignment from stack */
bool platformHW_Init(void);
bool platformHW_SpiInit(SPI_HandleTypeDef * const spi, SPI_TypeDef* spiInstance);
void platformHW_UpdateLEDs(SPI_HandleTypeDef* spi);
#endif//PLATFORM_HW_H__
| #ifndef PLATFORM_HW_H__
#define PLATFORM_HW_H__
#include <stdbool.h>
#include "color.h"
#include "stm32f0xx_hal.h"
#include "stm32f0xx_hal_gpio.h"
#define LED_CHAIN_LENGTH 10
#define USER_BUTTON_PORT (GPIOA)
#define USER_BUTTON_PIN (GPIO_PIN_0)
#define LED_SPI_INSTANCE (SPI1)
#pragma pack(push) /* push current alignment to stack */
#pragma pack(1) /* set alignment to 1 byte boundary */
union platformHW_LEDRegister {
uint8_t raw[4];
struct {
//3 bits always, 5 bits global brightness, 8B, 8G, 8R
//Glob = 0xE1 = min bright
uint8_t globalBrightness :5;
//header/global brightness is 0bAAABBBBB
//A = 1
//B = integer brightness divisor from 0x0 -> 0x1F
uint8_t const header :3;
struct color_ColorRGB color;
};
};
#pragma pack(pop) /* restore original alignment from stack */
bool platformHW_Init(void);
bool platformHW_SpiInit(SPI_HandleTypeDef * const spi, SPI_TypeDef* spiInstance);
void platformHW_UpdateLEDs(SPI_HandleTypeDef* spi);
#endif//PLATFORM_HW_H__
|
Simplify string duplication function a bit. | #ifndef CJET_STRING_H
#define CJET_STRING_H
#include <stdlib.h>
#include <string.h>
static inline char *duplicate_string(const char *s)
{
size_t length = strlen(s);
char *new_string = malloc(length + 1);
if (unlikely(new_string == NULL)) {
return NULL;
}
strncpy(new_string, s, length + 1);
return new_string;
}
#endif
| #ifndef CJET_STRING_H
#define CJET_STRING_H
#include <stdlib.h>
#include <string.h>
static inline char *duplicate_string(const char *s)
{
size_t length = strlen(s);
char *new_string = malloc(length + 1);
if (unlikely(new_string != NULL)) {
strncpy(new_string, s, length + 1);
}
return new_string;
}
#endif
|
Revise license and add missing prototype | /*
usart0s.h - C interface to routine written in assembler
Compile the corresponding assembler file with
#define C_COMPAT_ASM_CODE 1
Copyright (c) 2015 Igor Mikolic-Torreira. All right reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef usart0s_h
#define usart0s_h
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
void sendUSART0( uint8_t byteToSend );
#ifdef __cplusplus
}
#endif
#endif
| /*
usart0s.h - C interface to routine written in assembler
The MIT License (MIT)
Copyright (c) 2015 Igor Mikolic-Torreira
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 usart0s_h
#define usart0s_h
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
void enableUSART0();
void sendUSART0( uint8_t byteToSend );
#ifdef __cplusplus
}
#endif
#endif
|
Declare libunwind-entry-points as PROTECTED to ensure local uses get resolved within the library itself. | /* libunwind - a platform-independent unwind library
Copyright (C) 2002 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
PROTECTED int
unw_set_caching_policy (unw_addr_space_t as, unw_caching_policy_t policy)
{
if (unw.needs_initialization)
ia64_init ();
#ifndef HAVE___THREAD
if (policy == UNW_CACHE_PER_THREAD)
policy = UNW_CACHE_GLOBAL;
#endif
if (policy == as->caching_policy)
return 0; /* no change */
as->caching_policy = policy;
/* Ensure caches are empty (and initialized). */
unw_flush_cache (as, 0, 0);
return 0;
}
| |
Add test for SCA region store. | // RUN: clang -checker-simple -verify %s
void f(void) {
void (*p)(void);
p = f;
p = &f;
p();
(*p)();
}
| // RUN: clang -checker-simple -verify %s
void f(void) {
void (*p)(void);
p = f;
p = &f;
p();
(*p)();
}
void g(void (*fp)(void));
void f2() {
g(f);
}
|
Remove requirement for a .csv suffix. Print warning if working with file that have suffix other than .csv | #ifndef QTCSVFILECHECKER_H
#define QTCSVFILECHECKER_H
#include <QString>
#include <QFileInfo>
namespace QtCSV
{
// Check if path to csv file is valid
// @input:
// - filePath - string with absolute path to csv-file
// @output:
// - bool - True if file is OK, else False
inline bool CheckFile(const QString& filePath)
{
QFileInfo fileInfo(filePath);
if ( fileInfo.isAbsolute() && "csv" == fileInfo.suffix() )
{
return true;
}
return false;
}
}
#endif // QTCSVFILECHECKER_H
| #ifndef QTCSVFILECHECKER_H
#define QTCSVFILECHECKER_H
#include <QString>
#include <QFileInfo>
#include <QDebug>
namespace QtCSV
{
// Check if path to csv file is valid
// @input:
// - filePath - string with absolute path to csv-file
// @output:
// - bool - True if file is OK, else False
inline bool CheckFile(const QString& filePath)
{
QFileInfo fileInfo(filePath);
if ( fileInfo.isAbsolute() && fileInfo.isFile() )
{
if ( "csv" != fileInfo.suffix() )
{
qDebug() << __FUNCTION__ <<
"Warning - file suffix is not .csv";
}
return true;
}
return false;
}
}
#endif // QTCSVFILECHECKER_H
|
Disable -Wimplicit-fallthrough when including tinyformat | #pragma once
#define TINYFORMAT_USE_VARIADIC_TEMPLATES
#include "dependencies/tinyformat/tinyformat.h"
#include "library/strings.h"
namespace OpenApoc
{
template <typename... Args> static UString format(const UString &fmt, Args &&... args)
{
return tfm::format(fmt.cStr(), std::forward<Args>(args)...);
}
UString tr(const UString &str, const UString domain = "ufo_string");
} // namespace OpenApoc
| #pragma once
#define TINYFORMAT_USE_VARIADIC_TEMPLATES
#ifdef __GNUC__
// Tinyformat has a number of non-annotated switch fallthrough cases
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
#include "dependencies/tinyformat/tinyformat.h"
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include "library/strings.h"
namespace OpenApoc
{
template <typename... Args> static UString format(const UString &fmt, Args &&... args)
{
return tfm::format(fmt.cStr(), std::forward<Args>(args)...);
}
UString tr(const UString &str, const UString domain = "ufo_string");
} // namespace OpenApoc
|
Remove trailing spaces in test case. | // PARAM: --enable ana.int.interval
#include <stdlib.h>
#include <assert.h>
int main() {
unsigned long ul;
if (ul <= 0UL) {
__goblint_check(ul == 0UL);
} else {
__goblint_check(ul != 0UL);
}
if (ul > 0UL) {
__goblint_check(ul != 0UL);
} else {
__goblint_check(ul == 0UL);
}
if (! (ul > 0UL)) {
__goblint_check(ul == 0UL);
} else {
__goblint_check(ul != 0UL);
}
unsigned int iu;
if (iu <= 0UL) {
__goblint_check(iu == 0UL);
} else {
__goblint_check(iu != 0UL);
}
if (iu > 0UL) {
__goblint_check(iu != 0UL);
} else {
__goblint_check(iu == 0UL);
}
if (! (iu > 0UL)) {
__goblint_check(iu == 0UL);
} else {
__goblint_check(iu != 0UL);
}
int i;
if (! (i > 0)) {
} else {
__goblint_check(i != 0);
}
return 0;
} | // PARAM: --enable ana.int.interval
#include <stdlib.h>
#include <assert.h>
int main() {
unsigned long ul;
if (ul <= 0UL) {
__goblint_check(ul == 0UL);
} else {
__goblint_check(ul != 0UL);
}
if (ul > 0UL) {
__goblint_check(ul != 0UL);
} else {
__goblint_check(ul == 0UL);
}
if (! (ul > 0UL)) {
__goblint_check(ul == 0UL);
} else {
__goblint_check(ul != 0UL);
}
unsigned int iu;
if (iu <= 0UL) {
__goblint_check(iu == 0UL);
} else {
__goblint_check(iu != 0UL);
}
if (iu > 0UL) {
__goblint_check(iu != 0UL);
} else {
__goblint_check(iu == 0UL);
}
if (! (iu > 0UL)) {
__goblint_check(iu == 0UL);
} else {
__goblint_check(iu != 0UL);
}
int i;
if (! (i > 0)) {
} else {
__goblint_check(i != 0);
}
return 0;
}
|
Increment version to 4.9.1 for new development work. | #ifndef WSGI_VERSION_H
#define WSGI_VERSION_H
/* ------------------------------------------------------------------------- */
/*
* Copyright 2007-2021 GRAHAM DUMPLETON
*
* 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.
*/
/* ------------------------------------------------------------------------- */
/* Module version information. */
#define MOD_WSGI_MAJORVERSION_NUMBER 4
#define MOD_WSGI_MINORVERSION_NUMBER 9
#define MOD_WSGI_MICROVERSION_NUMBER 0
#define MOD_WSGI_VERSION_STRING "4.9.0"
/* ------------------------------------------------------------------------- */
#endif
/* vi: set sw=4 expandtab : */
| #ifndef WSGI_VERSION_H
#define WSGI_VERSION_H
/* ------------------------------------------------------------------------- */
/*
* Copyright 2007-2021 GRAHAM DUMPLETON
*
* 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.
*/
/* ------------------------------------------------------------------------- */
/* Module version information. */
#define MOD_WSGI_MAJORVERSION_NUMBER 4
#define MOD_WSGI_MINORVERSION_NUMBER 9
#define MOD_WSGI_MICROVERSION_NUMBER 1
#define MOD_WSGI_VERSION_STRING "4.9.1.dev1"
/* ------------------------------------------------------------------------- */
#endif
/* vi: set sw=4 expandtab : */
|
Update license in header file | /*
* statistic_histogram.h
*
*/
#ifndef STATISTIC_HISTOGRAM_H_
#define STATISTIC_HISTOGRAM_H_
#include <stdio.h>
#include <vector>
class Statistic_histogram
{
public:
Statistic_histogram(std::string h_name, const ssize_t domain_start, const ssize_t domain_end, const size_t range_size);
void inc_val(uint64_t val);
size_t report(char * report_buffer, size_t report_buffer_size);
private:
std::string name;
ssize_t dstart;
ssize_t dend;
size_t rsize;
typedef std::vector<uint64_t>::iterator hv_iterator;
std::vector<uint64_t> hval;
};
#endif /* STATISTIC_HISTOGRAM_H_ */
| /*
Copyright (c) 2015, Edward Haas
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of st_histogram nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
statistic_histogram.h
*/
#ifndef STATISTIC_HISTOGRAM_H_
#define STATISTIC_HISTOGRAM_H_
#include <stdio.h>
#include <vector>
class Statistic_histogram
{
public:
Statistic_histogram(std::string h_name, const ssize_t domain_start, const ssize_t domain_end, const size_t range_size);
void inc_val(uint64_t val);
size_t report(char * report_buffer, size_t report_buffer_size);
private:
std::string name;
ssize_t dstart;
ssize_t dend;
size_t rsize;
typedef std::vector<uint64_t>::iterator hv_iterator;
std::vector<uint64_t> hval;
};
#endif /* STATISTIC_HISTOGRAM_H_ */
|
Solve To Carry or not to Carry in c | #include <stdio.h>
int main() {
unsigned int a, b;
while (scanf("%u %u", &a, &b) != EOF) {
printf("%u\n", a ^ b);
}
return 0;
}
| |
Add C++ and shared library stuff to header file | #ifndef FRAMEGRAB_H_
#define FRAMEGRAB_H_
#include <unistd.h>
typedef void *fg_handle;
/* fourcc constants */
#define FG_FORMAT_YUYV 0x56595559
#define FG_FORMAT_RGB24 0x33424752
struct fg_image {
int width;
int height;
int format;
};
fg_handle fg_init(char *, int);
int fg_deinit(fg_handle);
int fg_start(fg_handle);
int fg_stop(fg_handle);
int fg_set_format(fg_handle, struct fg_image *);
int fg_get_format(fg_handle, struct fg_image *);
int fg_get_frame(fg_handle, void *, size_t len);
int fg_write_jpeg(char *, int, struct fg_image *, void *);
#endif
| #ifndef FRAMEGRAB_H_
#define FRAMEGRAB_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
# ifdef BUILDING_DLL
# define EXPORT __declspec(dllexport)
# else
# define EXPORT __declspec(dllimport)
# endif
#elif __GNUC__ >= 4 || defined(__HP_cc)
# define EXPORT __attribute__((visibility ("default")))
#elif defined(__SUNPRO_C)
# define EXPORT __global
#else
# define EXPORT
#endif
typedef void *fg_handle;
/* fourcc constants */
#define FG_FORMAT_YUYV 0x56595559
#define FG_FORMAT_RGB24 0x33424752
struct fg_image {
int width;
int height;
int format;
};
EXPORT fg_handle fg_init(char *, int);
EXPORT int fg_deinit(fg_handle);
EXPORT int fg_start(fg_handle);
EXPORT int fg_stop(fg_handle);
EXPORT int fg_set_format(fg_handle, struct fg_image *);
EXPORT int fg_get_format(fg_handle, struct fg_image *);
EXPORT int fg_get_frame(fg_handle, void *, size_t len);
EXPORT int fg_write_jpeg(char *, int, struct fg_image *, void *);
#ifdef __cplusplus
}
#endif
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.