Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add User-Agent to prevent from blocked by Douban.fm | // main.c
// Main Program for HWP Media Center
//
// Author : Weipeng He <heweipeng@gmail.com>
// Copyright (c) 2014, All rights reserved.
#include "utils.h"
#include <stdio.h>
#include <curl/curl.h>
size_t write_data(void *buffer, size_t size, size_t nmemb, void *dstr) {
d_string* str = (d_string*) dstr;
dstr_ncat(str, buffer, size * nmemb);
return nmemb;
}
int main(int argc, char** argv) {
CURL* curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
d_string* content = dstr_alloc();
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, content);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
printf("size=%d, cap=%d\n%s", content->size, content->cap, content->str);
dstr_free(content);
curl_easy_cleanup(curl);
}
return 0;
}
| // main.c
// Main Program for HWP Media Center
//
// Author : Weipeng He <heweipeng@gmail.com>
// Copyright (c) 2014, All rights reserved.
#include "utils.h"
#include <stdio.h>
#include <curl/curl.h>
size_t write_data(void *buffer, size_t size, size_t nmemb, void *dstr) {
d_string* str = (d_string*) dstr;
dstr_ncat(str, buffer, size * nmemb);
return nmemb;
}
int main(int argc, char** argv) {
CURL* curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "hwp");
d_string* content = dstr_alloc();
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, content);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
fprintf(stderr, "Failed to connect: %s\n", curl_easy_strerror(res));
}
printf("size=%d, cap=%d\n%s", content->size, content->cap, content->str);
dstr_free(content);
curl_easy_cleanup(curl);
}
return 0;
}
|
Return the Module being materialized to avoid always calling getModule(). | //===-- llvm/ModuleProvider.h - Interface for module providers --*- C++ -*-===//
//
// This file provides an abstract interface for loading a module from some
// place. This interface allows incremental or random access loading of
// functions from the file. This is useful for applications like JIT compilers
// or interprocedural optimizers that do not need the entire program in memory
// at the same time.
//
//===----------------------------------------------------------------------===//
#ifndef MODULEPROVIDER_H
#define MODULEPROVIDER_H
class Function;
class Module;
class ModuleProvider {
protected:
Module *TheModule;
ModuleProvider();
public:
virtual ~ModuleProvider();
/// getModule - returns the module this provider is encapsulating.
///
Module* getModule() { return TheModule; }
/// materializeFunction - make sure the given function is fully read.
///
virtual void materializeFunction(Function *F) = 0;
/// materializeModule - make sure the entire Module has been completely read.
///
void materializeModule();
/// releaseModule - no longer delete the Module* when provider is destroyed.
///
virtual Module* releaseModule() {
// Since we're losing control of this Module, we must hand it back complete
materializeModule();
Module *tempM = TheModule;
TheModule = 0;
return tempM;
}
};
#endif
| //===-- llvm/ModuleProvider.h - Interface for module providers --*- C++ -*-===//
//
// This file provides an abstract interface for loading a module from some
// place. This interface allows incremental or random access loading of
// functions from the file. This is useful for applications like JIT compilers
// or interprocedural optimizers that do not need the entire program in memory
// at the same time.
//
//===----------------------------------------------------------------------===//
#ifndef MODULEPROVIDER_H
#define MODULEPROVIDER_H
class Function;
class Module;
class ModuleProvider {
protected:
Module *TheModule;
ModuleProvider();
public:
virtual ~ModuleProvider();
/// getModule - returns the module this provider is encapsulating.
///
Module* getModule() { return TheModule; }
/// materializeFunction - make sure the given function is fully read.
///
virtual void materializeFunction(Function *F) = 0;
/// materializeModule - make sure the entire Module has been completely read.
///
Module* materializeModule();
/// releaseModule - no longer delete the Module* when provider is destroyed.
///
virtual Module* releaseModule() {
// Since we're losing control of this Module, we must hand it back complete
materializeModule();
Module *tempM = TheModule;
TheModule = 0;
return tempM;
}
};
#endif
|
Allow other operating systems that use X11 to use it | /* Copyright [2013-2018] [Aaron Springstroh, Minimal Graphics Library]
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 __WINDOW__
#define __WINDOW__
#if defined(_WIN32)
#include <min/win32_window.h>
namespace min
{
using window = min::win32_window;
}
#elif __linux__
#include <min/x_window.h>
namespace min
{
using window = min::x_window;
}
#endif
#endif
| /* Copyright [2013-2018] [Aaron Springstroh, Minimal Graphics Library]
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 __WINDOW__
#define __WINDOW__
#if defined(_WIN32)
#include <min/win32_window.h>
namespace min
{
using window = min::win32_window;
}
#else
#include <min/x_window.h>
namespace min
{
using window = min::x_window;
}
#endif
#endif
|
Remove not needed property_get function form cutils stubs | /*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_PROPERTIES_H
#define __CUTILS_PROPERTIES_H
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PROPERTY_KEY_MAX 32
#define PROPERTY_VALUE_MAX 92
/* property_get: returns the length of the value which will never be
** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated.
** (the length does not include the terminating zero).
**
** If the property read fails or returns an empty value, the default
** value is used (if nonnull).
*/
static inline int property_get(const char *key, char *value,
const char *default_value)
{
const char *env;
env = getenv(key);
if (!env)
env = default_value;
if (!value || !env)
return 0;
strncpy(value, env, PROPERTY_VALUE_MAX);
return strlen(value);
}
/* property_set: returns 0 on success, < 0 on failure
*/
static inline int property_set(const char *key, const char *value)
{
return setenv(key, value, 0);
}
#ifdef __cplusplus
}
#endif
#endif
| /*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_PROPERTIES_H
#define __CUTILS_PROPERTIES_H
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
/* property_set: returns 0 on success, < 0 on failure
*/
static inline int property_set(const char *key, const char *value)
{
return setenv(key, value, 0);
}
#ifdef __cplusplus
}
#endif
#endif
|
Enforce IPC data sharing with MPU | #include "../../libtock/tock.h"
#include <stdio.h>
#define IPC_DRIVER 0x4c
static void rot13_callback(int pid, int len, int arg2, void* ud) {
char* buf = (char*)arg2;
int length = buf[0];
if (length > len - 1) {
length = len - 1;
}
buf++;
for (int i = 0; i < len; ++i) {
if (buf[i] >= 'a' && buf[i] <= 'z') {
buf[i] = (((buf[i] - 'a') + 13) % 26) + 'a';
} else if (buf[i] >= 'A' && buf[i] <= 'Z') {
buf[i] = (((buf[i] - 'A') + 13) % 26) + 'A';
}
}
command(IPC_DRIVER, pid, 0);
}
int main() {
subscribe(IPC_DRIVER, 0, rot13_callback, 0);
while (1) {
yield();
}
return 0;
}
| #include <tock.h>
#define IPC_DRIVER 0x4c
struct rot13_buf {
int8_t length;
char buf[31];
};
static void rot13_callback(int pid, int len, int buf, void* ud) {
struct rot13_buf *rb = (struct rot13_buf*)buf;
int length = rb->length;
if (length > len - 1) {
length = len - 1;
}
for (int i = 0; i < length; ++i) {
if (rb->buf[i] >= 'a' && rb->buf[i] <= 'z') {
rb->buf[i] = (((rb->buf[i] - 'a') + 13) % 26) + 'a';
} else if (rb->buf[i] >= 'A' && rb->buf[i] <= 'Z') {
rb->buf[i] = (((rb->buf[i] - 'A') + 13) % 26) + 'A';
}
}
command(IPC_DRIVER, pid, 0);
}
int main() {
subscribe(IPC_DRIVER, 0, rot13_callback, NULL);
return 0;
}
|
Increase the size of the memory pool frame | #include <libsccmn.h>
#include <openssl/rand.h>
#include <sys/mman.h>
#define FRAME_SIZE (3*4096)
#define MEMPAGE_SIZE (4096)
void _logging_init(void);
void _frame_init(struct frame * this, uint8_t * data, size_t capacity, struct frame_pool_zone * zone);
| #include <libsccmn.h>
#include <openssl/rand.h>
#include <sys/mman.h>
// Frame size should be above 16kb, which is a maximum record size of 16kB for SSLv3/TLSv1
// See https://www.openssl.org/docs/manmaster/ssl/SSL_read.html
#define FRAME_SIZE (5*4096)
#define MEMPAGE_SIZE (4096)
void _logging_init(void);
void _frame_init(struct frame * this, uint8_t * data, size_t capacity, struct frame_pool_zone * zone);
|
Fix the first (sic!) Segmentation fault | // vim: sw=4 ts=4 et :
#include "config.h"
// Parser for win_ section
conf_t win_conf(char *key) {
conf_t rc;
rc.ival = 0;
(void)key;
return rc;
}
// Prefixes for config sections/subsections with parser pointers
struct conf_prefix {
char *prefix;
conf_t (*parser)(char *);
} pr_global[] = {
{ "win_", win_conf }
};
// Entry point to get all config values
conf_t conf(char *key) {
conf_t rc;
for (size_t i = 0; i < sizeof(pr_global); i++) {
if (strstr(key, pr_global[i].prefix) == 0) {
rc = win_conf(key + strlen(pr_global[i].prefix));
break;
}
}
return rc;
}
| // vim: sw=4 ts=4 et :
#include "config.h"
#include "itmmorgue.h"
// Parser for win_ section
conf_t win_conf(char *key) {
conf_t rc;
// TODO implement real parser
if (key == strstr(key, "area_y")) rc.ival = 3;
if (key == strstr(key, "area_x")) rc.ival = 2;
if (key == strstr(key, "area_max_y")) rc.ival = 10;
if (key == strstr(key, "area_max_x")) rc.ival = 45;
if (key == strstr(key, "area_state")) rc.ival = 2;
return rc;
}
// Prefixes for config sections/subsections with parser pointers
struct conf_prefix {
char *prefix;
conf_t (*parser)(char *);
} pr_global[] = {
{ "win_", win_conf }
};
// Entry point to get all config values
conf_t conf(char *key) {
conf_t rc;
for (size_t i = 0;
i < sizeof(pr_global) / sizeof(struct conf_prefix);
i++) {
if (key == strstr(key, pr_global[i].prefix)) {
rc = win_conf(key + strlen(pr_global[i].prefix));
break;
}
}
return rc;
}
|
Enable reverse futility at depth 1 | #ifndef _CONFIG_H
#define _CONFIG_H
#define ENABLE_FUTILITY_DEPTH 1 // TODO: switch to at least 2
#define ENABLE_HISTORY 1
#define ENABLE_KILLERS 1
#define ENABLE_LMR 1
#define ENABLE_NNUE 0
#define ENABLE_NULL_MOVE_PRUNING 1
#define ENABLE_REVERSE_FUTILITY_DEPTH 0 // TODO: switch to at least 2
#define ENABLE_TT_CUTOFFS 1
#define ENABLE_TT_MOVES 1
#endif
| #ifndef _CONFIG_H
#define _CONFIG_H
#define ENABLE_FUTILITY_DEPTH 1 // TODO: switch to at least 2
#define ENABLE_HISTORY 1
#define ENABLE_KILLERS 1
#define ENABLE_LMR 1
#define ENABLE_NNUE 0
#define ENABLE_NULL_MOVE_PRUNING 1
#define ENABLE_REVERSE_FUTILITY_DEPTH 1 // TODO: switch to at least 2
#define ENABLE_TT_CUTOFFS 1
#define ENABLE_TT_MOVES 1
#endif
|
Allow passing an event loop to XapianServer | #ifndef XAPIAND_INCLUDED_SERVER_H
#define XAPIAND_INCLUDED_SERVER_H
#include <ev++.h>
#include "threadpool.h"
#include "database.h"
const int XAPIAND_HTTP_PORT_DEFAULT = 8880;
const int XAPIAND_BINARY_PORT_DEFAULT = 8890;
class XapiandServer : public Task {
private:
ev::dynamic_loop loop;
ev::sig sig;
ev::async quit;
ev::io http_io;
int http_sock;
ev::io binary_io;
int binary_sock;
DatabasePool database_pool;
void bind_http();
void bind_binary();
void io_accept_http(ev::io &watcher, int revents);
void io_accept_binary(ev::io &watcher, int revents);
void signal_cb(ev::sig &signal, int revents);
void quit_cb(ev::async &watcher, int revents);
public:
XapiandServer(int http_sock_, int binary_sock_);
~XapiandServer();
void run();
};
#endif /* XAPIAND_INCLUDED_SERVER_H */
| #ifndef XAPIAND_INCLUDED_SERVER_H
#define XAPIAND_INCLUDED_SERVER_H
#include <ev++.h>
#include "threadpool.h"
#include "database.h"
const int XAPIAND_HTTP_PORT_DEFAULT = 8880;
const int XAPIAND_BINARY_PORT_DEFAULT = 8890;
class XapiandServer : public Task {
private:
ev::dynamic_loop dynamic_loop;
ev::loop_ref *loop;
ev::sig sig;
ev::async quit;
ev::io http_io;
int http_sock;
ev::io binary_io;
int binary_sock;
DatabasePool database_pool;
void bind_http();
void bind_binary();
void io_accept_http(ev::io &watcher, int revents);
void io_accept_binary(ev::io &watcher, int revents);
void signal_cb(ev::sig &signal, int revents);
void quit_cb(ev::async &watcher, int revents);
public:
XapiandServer(int http_sock_, int binary_sock_, ev::loop_ref *loop_=NULL);
~XapiandServer();
void run();
};
#endif /* XAPIAND_INCLUDED_SERVER_H */
|
Update Skia milestone to 91 | /*
* 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 90
#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 91
#endif
|
Increment version to clean things up | /*
* Paramer.h
*
* Created on: Aug 20, 2015
* Author: fsedlaze
*/
#ifndef PARAMER_H_
#define PARAMER_H_
#include <string.h>
#include <string>
#include <vector>
#include <stdlib.h>
#include <iostream>
#include <ctime>
class Parameter {
private:
Parameter() {
min_freq=-1;
version ="1.0.4";
}
~Parameter() {
}
static Parameter* m_pInstance;
public:
std::string version;
int max_dist;
int max_caller;
bool use_type;
bool use_strand;
bool dynamic_size;
int min_length;
float min_freq;
int min_support;
static Parameter* Instance() {
if (!m_pInstance) {
m_pInstance = new Parameter;
}
return m_pInstance;
}
double meassure_time(clock_t begin ,std::string msg){
return 0;
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
std::cout << msg<<" " << elapsed_secs<<std::endl;
return elapsed_secs;
}
};
#endif /* PARAMER_H_ */
| /*
* Paramer.h
*
* Created on: Aug 20, 2015
* Author: fsedlaze
*/
#ifndef PARAMER_H_
#define PARAMER_H_
#include <string.h>
#include <string>
#include <vector>
#include <stdlib.h>
#include <iostream>
#include <ctime>
class Parameter {
private:
Parameter() {
min_freq=-1;
version ="1.0.5";
}
~Parameter() {
}
static Parameter* m_pInstance;
public:
std::string version;
int max_dist;
int max_caller;
bool use_type;
bool use_strand;
bool dynamic_size;
int min_length;
float min_freq;
int min_support;
static Parameter* Instance() {
if (!m_pInstance) {
m_pInstance = new Parameter;
}
return m_pInstance;
}
double meassure_time(clock_t begin ,std::string msg){
return 0;
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
std::cout << msg<<" " << elapsed_secs<<std::endl;
return elapsed_secs;
}
};
#endif /* PARAMER_H_ */
|
Set default debug level to none. | /**
* This file is part of the librailcan library.
*
* Copyright (C) 2015 Reinder Feenstra <reinderfeenstra@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#include "librailcan.h"
#include <string.h>
int debug_level = LIBRAILCAN_DEBUGLEVEL_DEBUG;//LIBRAILCAN_DEBUGLEVEL_NONE;
int librailcan_set_debug_level( int level )
{
if( level < LIBRAILCAN_DEBUGLEVEL_NONE ||
level > LIBRAILCAN_DEBUGLEVEL_DEBUG )
return LIBRAILCAN_STATUS_INVALID_PARAM;
debug_level = level;
return LIBRAILCAN_STATUS_SUCCESS;
}
| /**
* This file is part of the librailcan library.
*
* Copyright (C) 2015 Reinder Feenstra <reinderfeenstra@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#include "librailcan.h"
#include <string.h>
int debug_level = LIBRAILCAN_DEBUGLEVEL_NONE;
int librailcan_set_debug_level( int level )
{
if( level < LIBRAILCAN_DEBUGLEVEL_NONE ||
level > LIBRAILCAN_DEBUGLEVEL_DEBUG )
return LIBRAILCAN_STATUS_INVALID_PARAM;
debug_level = level;
return LIBRAILCAN_STATUS_SUCCESS;
}
|
Copy end of string in xstrdup |
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "cc.h"
static void
out_of_memory(void)
{
/* TODO: deal with out of memory errors */
error("out of memory");
}
void *
xmalloc(size_t size)
{
register void *p = malloc(size);
if (!p)
out_of_memory();
return p;
}
void *
xcalloc(size_t nmemb, size_t size)
{
register size_t nbytes = nmemb * size;
register void *p = xmalloc(nbytes);
return memset(p, nbytes, 0);
}
char *
xstrdup(const char *s)
{
register size_t len = strlen(s);
register char *p = xmalloc(len);
return memcpy(p, s, len);
}
void *
xrealloc(void *buff, register size_t size)
{
register void *p = realloc(buff, size);
if (!p)
out_of_memory();
return p;
}
|
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "cc.h"
static void
out_of_memory(void)
{
/* TODO: deal with out of memory errors */
error("out of memory");
}
void *
xmalloc(size_t size)
{
register void *p = malloc(size);
if (!p)
out_of_memory();
return p;
}
void *
xcalloc(size_t nmemb, size_t size)
{
register size_t nbytes = nmemb * size;
register void *p = xmalloc(nbytes);
return memset(p, nbytes, 0);
}
char *
xstrdup(const char *s)
{
register size_t len = strlen(s) + 1;
register char *p = xmalloc(len);
return memcpy(p, s, len);
}
void *
xrealloc(void *buff, register size_t size)
{
register void *p = realloc(buff, size);
if (!p)
out_of_memory();
return p;
}
|
Test null statements. Just because. | int main(void)
{
int i = 0;
while (1) {
if (i == 42) break;
i += 1;
}
return i;
}
| int main(void)
{
int i = 0;;;
while (1) {
if (i == 42) break;
i += 1;
}
return i;
}
|
Add a file that should have been added with changeset: 3564:36fb63a6d3b7 | /* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is [Open Source Virtual Machine.].
*
* The Initial Developer of the Original Code is
* Adobe System Incorporated.
* Portions created by the Initial Developer are Copyright (C) 2004-2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adobe AS3 Team
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __avmplus_ClassClosure_inlines__
#define __avmplus_ClassClosure_inlines__
namespace avmplus
{
REALLY_INLINE ScriptObject* ClassClosure::prototypePtr()
{
return prototype;
}
REALLY_INLINE VTable* ClassClosure::ivtable() const
{
return vtable->ivtable;
}
// Called from C++ to alloc a new instance. Generated code calls createInstance directly.
REALLY_INLINE ScriptObject* ClassClosure::newInstance()
{
VTable* ivtable = this->ivtable();
return ivtable->createInstance(this, ivtable);
}
}
#endif /* __avmplus_ClassClosure_inlines__ */
| |
Use better header for std::pair. | #pragma once
#include <algorithm>
#include "Types.h"
class CGsCachedArea
{
public:
typedef uint64 DirtyPageHolder;
enum
{
MAX_DIRTYPAGES_SECTIONS = 8,
MAX_DIRTYPAGES = sizeof(DirtyPageHolder) * 8 * MAX_DIRTYPAGES_SECTIONS
};
CGsCachedArea();
void SetArea(uint32 psm, uint32 bufPtr, uint32 bufWidth, uint32 height);
std::pair<uint32, uint32> GetPageRect() const;
uint32 GetPageCount() const;
uint32 GetSize() const;
void Invalidate(uint32, uint32);
bool IsPageDirty(uint32) const;
void SetPageDirty(uint32);
bool HasDirtyPages() const;
void ClearDirtyPages();
private:
uint32 m_psm = 0;
uint32 m_bufPtr = 0;
uint32 m_bufWidth = 0;
uint32 m_height = 0;
DirtyPageHolder m_dirtyPages[MAX_DIRTYPAGES_SECTIONS];
};
| #pragma once
#include <utility>
#include "Types.h"
class CGsCachedArea
{
public:
typedef uint64 DirtyPageHolder;
enum
{
MAX_DIRTYPAGES_SECTIONS = 8,
MAX_DIRTYPAGES = sizeof(DirtyPageHolder) * 8 * MAX_DIRTYPAGES_SECTIONS
};
CGsCachedArea();
void SetArea(uint32 psm, uint32 bufPtr, uint32 bufWidth, uint32 height);
std::pair<uint32, uint32> GetPageRect() const;
uint32 GetPageCount() const;
uint32 GetSize() const;
void Invalidate(uint32, uint32);
bool IsPageDirty(uint32) const;
void SetPageDirty(uint32);
bool HasDirtyPages() const;
void ClearDirtyPages();
private:
uint32 m_psm = 0;
uint32 m_bufPtr = 0;
uint32 m_bufWidth = 0;
uint32 m_height = 0;
DirtyPageHolder m_dirtyPages[MAX_DIRTYPAGES_SECTIONS];
};
|
Fix compile ui.shell, fckng non-standard behaviour | #ifndef STINGRAYKIT_METAPROGRAMMING_TYPECOMPLETENESS_H
#define STINGRAYKIT_METAPROGRAMMING_TYPECOMPLETENESS_H
// Copyright (c) 2011 - 2017, GS Group, https://github.com/GSGroup
// Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
// provided that the above copyright notice and this permission notice appear in all copies.
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stingraykit/metaprogramming/CompileTimeAssert.h>
namespace stingray
{
template < typename T > struct StaticAssertCompleteType : CompileTimeAssert<sizeof(T)> { typedef T ValueT; };
}
#endif
| #ifndef STINGRAYKIT_METAPROGRAMMING_TYPECOMPLETENESS_H
#define STINGRAYKIT_METAPROGRAMMING_TYPECOMPLETENESS_H
// Copyright (c) 2011 - 2017, GS Group, https://github.com/GSGroup
// Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
// provided that the above copyright notice and this permission notice appear in all copies.
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stingraykit/metaprogramming/CompileTimeAssert.h>
namespace stingray
{
template < typename T > struct StaticAssertCompleteType : CompileTimeAssert<sizeof(T) == sizeof(T)> { typedef T ValueT; };
}
#endif
|
Set Type A1 retimer to unknown | /* Copyright 2021 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.
*/
#include "base_fw_config.h"
#include "board_fw_config.h"
bool board_is_convertible(void)
{
return 1;
}
bool board_has_kblight(void)
{
return (get_fw_config_field(FW_CONFIG_KBLIGHT_OFFSET,
FW_CONFIG_KBLIGHT_WIDTH) == FW_CONFIG_KBLIGHT_YES);
}
enum board_usb_c1_mux board_get_usb_c1_mux(void)
{
return USB_C1_MUX_PS8818;
};
enum board_usb_a1_retimer board_get_usb_a1_retimer(void)
{
return USB_A1_RETIMER_PS8811;
};
| /* Copyright 2021 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.
*/
#include "base_fw_config.h"
#include "board_fw_config.h"
bool board_is_convertible(void)
{
return 1;
}
bool board_has_kblight(void)
{
return (get_fw_config_field(FW_CONFIG_KBLIGHT_OFFSET,
FW_CONFIG_KBLIGHT_WIDTH) == FW_CONFIG_KBLIGHT_YES);
}
enum board_usb_c1_mux board_get_usb_c1_mux(void)
{
return USB_C1_MUX_PS8818;
};
enum board_usb_a1_retimer board_get_usb_a1_retimer(void)
{
return USB_A1_RETIMER_UNKNOWN;
};
|
Define helper to send perf events for socket context | /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
/* Copyright Authors of Cilium */
#ifndef __BPF_HELPERS_SOCK__
#define __BPF_HELPERS_SOCK__
#include <linux/bpf.h>
#include "helpers.h"
/* Only used helpers in Cilium go below. */
/* Events for user space */
static int BPF_FUNC_REMAP(sock_event_output, struct bpf_sock_addr *sock, void *map,
__u64 index, const void *data, __u32 size) =
(void *)BPF_FUNC_perf_event_output;
#endif /* __BPF_HELPERS_SOCK__ */
| |
Add test for large unsigned long constants in expressions | // PARAM: --enable ana.int.def_exc --disable ana.int.interval
#include<assert.h>
// Some unsigned long constant that is larger than 2^63-1
#define SIZE_MAX 18446744073709551615UL
int foo(){
int top;
int a = 3;
if (top < SIZE_MAX / (8 * sizeof(int))){ // parts of the expression errorneously evaluate to bottom
assert(1);
}
return 0;
}
| |
Hide global data symbols related to signal tables | #ifndef __POSIX_SIGNAL_SIGTABLES_H
typedef struct {
int signal;
char *name;
} Signal;
typedef struct {
int len;
int items[];
} SignalVector;
extern const Signal signals[];
extern const int nsigs;
extern int max_signum;
#define SIGOFFSET(SIG) ((SIG) - 1)
void
InitSignalTables (void);
SignalVector*
CreateSignalVector (void);
void
FreeSignalVector(
SignalVector *svPtr
);
int
GetSignalIdFromObj (
Tcl_Interp *interp,
Tcl_Obj *nameObj
);
#define __POSIX_SIGNAL_SIGTABLES_H
#endif /* __POSIX_SIGNAL_SIGTABLES_H */
/* vim: set ts=8 sts=4 sw=4 sts=4 noet: */
| #ifndef __POSIX_SIGNAL_SIGTABLES_H
typedef struct {
int signal;
char *name;
} Signal;
typedef struct {
int len;
int items[];
} SignalVector;
MODULE_SCOPE const Signal signals[];
MODULE_SCOPE const int nsigs;
MODULE_SCOPE int max_signum;
#define SIGOFFSET(SIG) ((SIG) - 1)
void
InitSignalTables (void);
SignalVector*
CreateSignalVector (void);
void
FreeSignalVector(
SignalVector *svPtr
);
int
GetSignalIdFromObj (
Tcl_Interp *interp,
Tcl_Obj *nameObj
);
#define __POSIX_SIGNAL_SIGTABLES_H
#endif /* __POSIX_SIGNAL_SIGTABLES_H */
/* vim: set ts=8 sts=4 sw=4 sts=4 noet: */
|
Fix a warning that causes compile error in G++ | // Submission #3365787
#include <stdio.h>
#define MAXN 8
#define TRUE 1
#define FALSE 0
int len;
unsigned char used[MAXN] = { FALSE };
char s[MAXN], generated[MAXN];
void dfs(int depth)
{
if (depth == len) puts(generated);
else {
int i;
for (i = 0; i < len; ++i) if (!used[i]) {
used[i] = TRUE;
generated[depth] = s[i];
dfs(depth + 1);
used[i] = FALSE;
}
}
}
int main()
{
gets(s);
len = strlen(s);
dfs(0);
return 0;
}
| // Submission #3365787
#include <stdio.h>
#include <string.h>
#define MAXN 8
#define TRUE 1
#define FALSE 0
int len;
unsigned char used[MAXN] = { FALSE };
char s[MAXN], generated[MAXN];
void dfs(int depth)
{
if (depth == len) puts(generated);
else {
int i;
for (i = 0; i < len; ++i) if (!used[i]) {
used[i] = TRUE;
generated[depth] = s[i];
dfs(depth + 1);
used[i] = FALSE;
}
}
}
int main()
{
gets(s);
len = strlen(s);
dfs(0);
return 0;
}
|
Move function declarations outside of the if-block | #ifndef _AL_THUNK_H_
#define _AL_THUNK_H_
#include "config.h"
#include "AL/al.h"
#include "AL/alc.h"
#ifdef __cplusplus
extern "C" {
#endif
#if (SIZEOF_VOIDP > SIZEOF_UINT)
void alThunkInit(void);
void alThunkExit(void);
ALuint alThunkAddEntry(ALvoid * ptr);
void alThunkRemoveEntry(ALuint index);
ALvoid *alThunkLookupEntry(ALuint index);
#define ALTHUNK_INIT() alThunkInit()
#define ALTHUNK_EXIT() alThunkExit()
#define ALTHUNK_ADDENTRY(p) alThunkAddEntry(p)
#define ALTHUNK_REMOVEENTRY(i) alThunkRemoveEntry(i)
#define ALTHUNK_LOOKUPENTRY(i) alThunkLookupEntry(i)
#else
#define ALTHUNK_INIT()
#define ALTHUNK_EXIT()
#define ALTHUNK_ADDENTRY(p) ((ALuint)p)
#define ALTHUNK_REMOVEENTRY(i)
#define ALTHUNK_LOOKUPENTRY(i) ((ALvoid*)(i))
#endif // (SIZEOF_VOIDP > SIZEOF_INT)
#ifdef __cplusplus
}
#endif
#endif //_AL_THUNK_H_
| #ifndef _AL_THUNK_H_
#define _AL_THUNK_H_
#include "config.h"
#include "AL/al.h"
#include "AL/alc.h"
#ifdef __cplusplus
extern "C" {
#endif
void alThunkInit(void);
void alThunkExit(void);
ALuint alThunkAddEntry(ALvoid * ptr);
void alThunkRemoveEntry(ALuint index);
ALvoid *alThunkLookupEntry(ALuint index);
#if (SIZEOF_VOIDP > SIZEOF_UINT)
#define ALTHUNK_INIT() alThunkInit()
#define ALTHUNK_EXIT() alThunkExit()
#define ALTHUNK_ADDENTRY(p) alThunkAddEntry(p)
#define ALTHUNK_REMOVEENTRY(i) alThunkRemoveEntry(i)
#define ALTHUNK_LOOKUPENTRY(i) alThunkLookupEntry(i)
#else
#define ALTHUNK_INIT()
#define ALTHUNK_EXIT()
#define ALTHUNK_ADDENTRY(p) ((ALuint)p)
#define ALTHUNK_REMOVEENTRY(i)
#define ALTHUNK_LOOKUPENTRY(i) ((ALvoid*)(i))
#endif // (SIZEOF_VOIDP > SIZEOF_INT)
#ifdef __cplusplus
}
#endif
#endif //_AL_THUNK_H_
|
Remove leading underscores as part of style clean up | // abort.h
// hdpirun
//
// Utility header to abort the program on an unrecoverable error. Prints the message (printf format) and closes any open resources
//
// Author: Robbie Duncan
// Copyright: Copyright (c) 2016 Robbie Duncan
// License: See LICENSE
//
#import "log.h"
#import <stdio.h>
#ifndef ABORT_H
#define ABORT_H
#define __ABORT(message,...) __LOG(__LOG_CRITICAL,message,##__VA_ARGS__);if (__logFile!=stdout){fclose(__logFile);};exit(1);
#endif
| // abort.h
// hdpirun
//
// Utility header to abort the program on an unrecoverable error. Prints the message (printf format) and closes any open resources
//
// Author: Robbie Duncan
// Copyright: Copyright (c) 2016 Robbie Duncan
// License: See LICENSE
//
#import "log.h"
#import <stdio.h>
#ifndef ABORT_H
#define ABORT_H
#define ABORT(message,...) __LOG(__LOG_CRITICAL,message,##__VA_ARGS__);if (__logFile!=stdout){fclose(__logFile);};exit(1);
#endif
|
Add new template for bench on c | #include <stdio.h>
#include <time.h>
static long n = 10000;
int
main(int argc, char* argv[]) {
long i;
clock_t t;
t = clock();
for (i = 0; i < n; ++i) {
{{_cursor_}}
}
printf("%ld\n", clock() - t);
return 0;
}
| |
Update driver version to 5.02.00-k12 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k11"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k12"
|
Fix MSVC error C2133 : unknown size of multi-dimensional static const arrays (despite supposed support of C99). Have not confirmed if this breaks anything yet. |
/* encrypted keys */
static const uint32_t internal_device_number = 0;
static const uint8_t internal_dk_list[][21] = {
{
},
};
static const uint8_t internal_pk_list[][16] = {
{
},
};
static const uint8_t internal_hc_list[][112] = {
{
},
};
/* customize this function to "hide" the keys in the binary */
static void decrypt_key(uint8_t *out, const uint8_t *in, size_t size)
{
memcpy(out, in, size);
}
|
/* encrypted keys */
static const uint32_t internal_device_number = 0;
static const uint8_t internal_dk_list[][21] = {
{ 0 },
};
static const uint8_t internal_pk_list[][16] = {
{ 0 },
};
static const uint8_t internal_hc_list[][112] = {
{ 0 },
};
/* customize this function to "hide" the keys in the binary */
static void decrypt_key(uint8_t *out, const uint8_t *in, size_t size)
{
memcpy(out, in, size);
}
|
Change /version output to be more like -version | #include "server/bedrock.h"
#include "server/command.h"
void command_version(struct bedrock_client *client, int bedrock_attribute_unused argc, const char bedrock_attribute_unused **argv)
{
command_reply(client, "Bedrock version %d.%d%s Compiled on %s %s.", BEDROCK_VERSION_MAJOR, BEDROCK_VERSION_MINOR, BEDROCK_VERSION_EXTRA, __DATE__, __TIME__);
}
| #include "server/bedrock.h"
#include "server/command.h"
void command_version(struct bedrock_client *client, int bedrock_attribute_unused argc, const char bedrock_attribute_unused **argv)
{
command_reply(client, "Bedrock version %d.%d%s, built on %s %s.", BEDROCK_VERSION_MAJOR, BEDROCK_VERSION_MINOR, BEDROCK_VERSION_EXTRA, __DATE__, __TIME__);
}
|
Remove volatile from test (decl_equal doesn't check properly for now) | int f(int x[static volatile /*const*/ 10])
{
return *++x;
}
main()
{
int x[5];
x[1] = 2;
f(x);
//int y[1];
//int *y;
//#define y (void *)0
//pipe(y);
}
| int f(int x[static /*const*/ 10])
{
return *++x;
}
main()
{
int x[5];
x[1] = 2;
f(x);
//int y[1];
//int *y;
//#define y (void *)0
//pipe(y);
}
|
Reword this comment. Don't mention outs(), as that's not what this code is actually testing for. | //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains functions used to do a variety of low-level, often
// system-specific, tasks.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_SYSTEMUTILS_H
#define LLVM_SUPPORT_SYSTEMUTILS_H
#include <string>
namespace llvm {
class raw_ostream;
namespace sys { class Path; }
/// Determine if the raw_ostream provided is connected to the outs() and
/// displayed or not (to a console window). If so, generate a warning message
/// advising against display of bitcode and return true. Otherwise just return
/// false
/// @brief Check for output written to a console
bool CheckBitcodeOutputToConsole(
raw_ostream &stream_to_check, ///< The stream to be checked
bool print_warning = true ///< Control whether warnings are printed
);
/// FindExecutable - Find a named executable, giving the argv[0] of program
/// being executed. This allows us to find another LLVM tool if it is built in
/// the same directory. If the executable cannot be found, return an
/// empty string.
/// @brief Find a named executable.
sys::Path FindExecutable(const std::string &ExeName,
const char *Argv0, void *MainAddr);
} // End llvm namespace
#endif
| //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains functions used to do a variety of low-level, often
// system-specific, tasks.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_SYSTEMUTILS_H
#define LLVM_SUPPORT_SYSTEMUTILS_H
#include <string>
namespace llvm {
class raw_ostream;
namespace sys { class Path; }
/// Determine if the raw_ostream provided is connected to a terminal. If so,
/// generate a warning message to errs() advising against display of bitcode
/// and return true. Otherwise just return false.
/// @brief Check for output written to a console
bool CheckBitcodeOutputToConsole(
raw_ostream &stream_to_check, ///< The stream to be checked
bool print_warning = true ///< Control whether warnings are printed
);
/// FindExecutable - Find a named executable, giving the argv[0] of program
/// being executed. This allows us to find another LLVM tool if it is built in
/// the same directory. If the executable cannot be found, return an
/// empty string.
/// @brief Find a named executable.
sys::Path FindExecutable(const std::string &ExeName,
const char *Argv0, void *MainAddr);
} // End llvm namespace
#endif
|
Use final for virtual methods on private impl of mbgl::View | #ifndef QMAPBOXGL_P_H
#define QMAPBOXGL_P_H
#include <mbgl/map/map.hpp>
#include <mbgl/map/view.hpp>
#include <mbgl/storage/default_file_source.hpp>
namespace mbgl {
class Map;
class FileSource;
} // namespace mbgl
class QOpenGLContext;
class QMapboxGLPrivate : public mbgl::View
{
public:
explicit QMapboxGLPrivate(QMapboxGL *q);
virtual ~QMapboxGLPrivate();
// mbgl::View implementation.
void activate() override {}
void deactivate() override;
void notify() override {}
void invalidate(std::function<void()> renderCallback) override;
mbgl::DefaultFileSource fileSource;
mbgl::Map map;
int lastX = 0;
int lastY = 0;
QOpenGLContext *context = nullptr;
QMapboxGL *q_ptr;
};
#endif // QMAPBOXGL_P_H
| #ifndef QMAPBOXGL_P_H
#define QMAPBOXGL_P_H
#include <mbgl/map/map.hpp>
#include <mbgl/map/view.hpp>
#include <mbgl/storage/default_file_source.hpp>
namespace mbgl {
class Map;
class FileSource;
} // namespace mbgl
class QOpenGLContext;
class QMapboxGLPrivate : public mbgl::View
{
public:
explicit QMapboxGLPrivate(QMapboxGL *q);
virtual ~QMapboxGLPrivate();
// mbgl::View implementation.
void activate() final {}
void deactivate() final;
void notify() final {}
void invalidate(std::function<void()> renderCallback) final;
mbgl::DefaultFileSource fileSource;
mbgl::Map map;
int lastX = 0;
int lastY = 0;
QOpenGLContext *context = nullptr;
QMapboxGL *q_ptr;
};
#endif // QMAPBOXGL_P_H
|
Add a test case for PR1086 | // RUN: %llvmgcc -S %s -o - | llvm-as | llc -march=c | \
// RUN: grep '(unsigned short'
int Z = -1;
int test(unsigned short X, short Y) { return X+Y+Z; }
| |
Choose between value and const reference type | ///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
Copyright(c) 2014 jwellbelove
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 __ETL_PARAMETER__
#define __ETL_PARAMETER__
namespace etl
{
//*************************************************************************
/// Determine how to pass parameters.
//*************************************************************************
template <typename U, const bool should_pass_by_value>
struct parameter_type;
//*************************************************************************
/// Pass by value.
//*************************************************************************
template <typename U>
struct parameter_type<U, true>
{
typedef U type;
};
//*************************************************************************
/// Pass by const reference.
//*************************************************************************
template <typename U>
struct parameter_type<U, false>
{
typedef const U& type;
};
}
#endif
| |
Fix illegal (double underscore) include guard. | #ifndef SIMHASH_TOKENIZERS__UTIL_H
#define SIMHASH_TOKENIZERS__UTIL_H
#include <string.h>
namespace Simhash {
struct Strspn {
/* Return the length of the token starting at last */
const char* operator()(const char* last) {
size_t s = strspn(last,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
return (*last != '\0') ? last + s : NULL;
}
};
}
#endif
| #ifndef SIMHASH_TOKENIZERS_STRSPN_H
#define SIMHASH_TOKENIZERS_STRSPN_H
#include <string.h>
namespace Simhash {
struct Strspn {
/* Return the length of the token starting at last */
const char* operator()(const char* last) {
size_t s = strspn(last,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
return (*last != '\0') ? last + s : NULL;
}
};
}
#endif
|
Remove comment that is no longer applicable | /*
* This file is covered by the Internet Software Consortium (ISC) License
* Reference: ../License.txt
*
* __nohang_waitpid is linked directly into Synth but it's related to synthexec
* so let's keep the C files together.
* return:
* 0 when process is still running
* 1 when process exited normally
* 2 when process exited with error
*
* __launch_process takes a pointer to an array of null-terminated string
* pointers are returns the pid of the child process, or -1 upon failure
*/
#include <sys/types.h>
#include <sys/wait.h>
u_int8_t
__nohang_waitpid (pid_t process_pid)
{
int status = 0;
int pid = waitpid (process_pid, &status, WNOHANG);
if (pid == 0)
{
return 0;
}
if (WIFEXITED (status) && (WEXITSTATUS (status) == 0))
{
return 1;
}
else
{
return 2;
}
}
| /*
* This file is covered by the Internet Software Consortium (ISC) License
* Reference: ../License.txt
*
* __nohang_waitpid is linked directly into Synth but it's related to synthexec
* so let's keep the C files together.
* return:
* 0 when process is still running
* 1 when process exited normally
* 2 when process exited with error
*/
#include <sys/types.h>
#include <sys/wait.h>
u_int8_t
__nohang_waitpid (pid_t process_pid)
{
int status = 0;
int pid = waitpid (process_pid, &status, WNOHANG);
if (pid == 0)
{
return 0;
}
if (WIFEXITED (status) && (WEXITSTATUS (status) == 0))
{
return 1;
}
else
{
return 2;
}
}
|
Increment version number to 1.41 | #pragma once
// const float in a header file can lead to duplication of the storage
// but I don't really care in this case. Just don't do it with a header
// that is included hundreds of times.
const float kCurrentVersion = 1.40f;
| #pragma once
// const float in a header file can lead to duplication of the storage
// but I don't really care in this case. Just don't do it with a header
// that is included hundreds of times.
const float kCurrentVersion = 1.41f;
|
Use rand instead of arc4random (linux doesn't support it) | #include "redislite.h"
#include <string.h>
static void test_add_key(redislite *db)
{
int rnd = arc4random();
char key[14];
sprintf(key, "%d", rnd);
int size = strlen(key);
redislite_insert_key(db, key, size, 0);
}
int main() {
redislite *db = redislite_open_database("test.db");
int i;
for (i=0; i < 100; i++)
test_add_key(db);
redislite_close_database(db);
return 0;
}
| #include "redislite.h"
#include <string.h>
static void test_add_key(redislite *db)
{
int rnd = rand();
char key[14];
sprintf(key, "%d", rnd);
int size = strlen(key);
redislite_insert_key(db, key, size, 0);
}
int main() {
redislite *db = redislite_open_database("test.db");
int i;
for (i=0; i < 100; i++)
test_add_key(db);
redislite_close_database(db);
return 0;
}
|
Remove unused members in fqindexedarray structure |
/*
* Copyright 2017 Brandon Yannoni
*
* 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 INDEXED_ARRAY_QUEUE_H
#define INDEXED_ARRAY_QUEUE_H
#include <pthread.h>
#include "../function_queue_element.h"
#include "../function_queue.h"
#include "../qterror.h"
/*
* This structure is used to store the function queue elements and any
* persistant data necessary for the manipulation procedures.
*/
struct fqindexedarray {
/* a pointer to an element array */
struct function_queue_element* elements;
pthread_mutex_t lock; /* unused */
pthread_cond_t wait; /* unused */
unsigned int front; /* the index of the "first" element */
unsigned int back; /* the index of the "last" element */
};
extern const struct fqdispatchtable fqdispatchtableia;
#endif
|
/*
* Copyright 2017 Brandon Yannoni
*
* 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 INDEXED_ARRAY_QUEUE_H
#define INDEXED_ARRAY_QUEUE_H
#include <pthread.h>
#include "../function_queue_element.h"
#include "../function_queue.h"
#include "../qterror.h"
/*
* This structure is used to store the function queue elements and any
* persistant data necessary for the manipulation procedures.
*/
struct fqindexedarray {
/* a pointer to an element array */
struct function_queue_element* elements;
unsigned int front; /* the index of the "first" element */
unsigned int back; /* the index of the "last" element */
};
extern const struct fqdispatchtable fqdispatchtableia;
#endif
|
Add delegate for profile view controller. | //
// ProfileViewController.h
// PlayPlan
//
// Created by Zeacone on 15/11/8.
// Copyright © 2015年 Zeacone. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "PlayPlan.h"
@class ProfileViewController;
@protocol MainDelegate <NSObject>
- (void)dismissViewController:(MainViewController *)mainViewController;
@end
@interface ProfileViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@end
| //
// ProfileViewController.h
// PlayPlan
//
// Created by Zeacone on 15/11/8.
// Copyright © 2015年 Zeacone. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "PlayPlan.h"
@class ProfileViewController;
@protocol MainDelegate <NSObject>
- (void)dismissViewController:(ProfileViewController *)mainViewController;
@end
@interface ProfileViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@end
|
Remove partial availability warning by adding API_AVAILABLE. | //
// VYNFCNDEFPayloadParser.h
// VYNFCKit
//
// Created by Vince Yuan on 7/8/17.
// Copyright © 2017 Vince Yuan. 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>
@class NFCNDEFPayload, VYNFCNDEFMessageHeader;
@interface VYNFCNDEFPayloadParser : NSObject
+ (nullable id)parse:(nullable NFCNDEFPayload *)payload;
+ (nullable VYNFCNDEFMessageHeader *)parseMessageHeader:(nullable unsigned char*)payloadBytes length:(NSUInteger)length;
@end
| //
// VYNFCNDEFPayloadParser.h
// VYNFCKit
//
// Created by Vince Yuan on 7/8/17.
// Copyright © 2017 Vince Yuan. 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>
@class NFCNDEFPayload, VYNFCNDEFMessageHeader;
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface VYNFCNDEFPayloadParser : NSObject
+ (nullable id)parse:(nullable NFCNDEFPayload *)payload;
+ (nullable VYNFCNDEFMessageHeader *)parseMessageHeader:(nullable unsigned char*)payloadBytes length:(NSUInteger)length;
@end
|
Implement dirty unallocatable memory mapped alloc. | char* file_to_buffer(const char *filename) {
struct stat sb;
stat(filename, &sb);
char *buffer = (char*) malloc(sb.st_size * sizeof(char));
FILE *f = fopen(filename, "rb");
assert(fread((void*) buffer, sizeof(char), sb.st_size, f));
fclose(f);
return buffer;
}
| char* file_to_buffer(const char *filename) {
struct stat sb;
stat(filename, &sb);
char *buffer = (char*) malloc(sb.st_size * sizeof(char));
FILE *f = fopen(filename, "rb");
assert(fread((void*) buffer, sizeof(char), sb.st_size, f));
fclose(f);
return buffer;
}
void* mmalloc(size_t sz, char *filename) {
int fd = open(filename, O_RDWR | O_CREAT, 0666);
assert(fd != -1);
char v = 0;
for (size_t i = 0; i < sz; i++) {
assert(write(fd, &v, sizeof(char)));
}
void *map = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
madvise(map, sz, MADV_RANDOM);
return map;
}
|
Define HAVE_SIGACTION to 1 in Xcode build | //===-- Config.h ------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_HOST_CONFIG_H
#define LLDB_HOST_CONFIG_H
#if defined(__APPLE__)
// This block of code only exists to keep the Xcode project working in the
// absence of a configuration step.
#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
#define HAVE_SYS_EVENT_H 1
#define HAVE_PPOLL 0
#else
#error This file is only used by the Xcode build.
#endif
#endif // #ifndef LLDB_HOST_CONFIG_H
| //===-- Config.h ------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_HOST_CONFIG_H
#define LLDB_HOST_CONFIG_H
#if defined(__APPLE__)
// This block of code only exists to keep the Xcode project working in the
// absence of a configuration step.
#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
#define HAVE_SYS_EVENT_H 1
#define HAVE_PPOLL 0
#define HAVE_SIGACTION 1
#else
#error This file is only used by the Xcode build.
#endif
#endif // #ifndef LLDB_HOST_CONFIG_H
|
Fix double / float mismatch | #pragma once
#include "Vector3.h"
typedef Vector3 Color;
class Material
{
public:
Material();
virtual ~Material();
void setColor(Color& color);
Color getColor(void) const;
void setDiffuse(double diffuse);
double getDiffuse(void) const;
void setReflection(double refl);
double GetReflection(void) const;
double getSpecular(void) const;
protected:
Color color;
float refl;
float diff;
};
| #pragma once
#include "Vector3.h"
typedef Vector3 Color;
class Material
{
public:
Material();
virtual ~Material();
void setColor(Color& color);
Color getColor(void) const;
void setDiffuse(double diffuse);
double getDiffuse(void) const;
void setReflection(double refl);
double GetReflection(void) const;
double getSpecular(void) const;
protected:
Color color;
double refl;
double diff;
};
|
Use ANSI sequences to ensure line clearing | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STTY "/bin/stty "
const char RAW[] = STTY "raw";
const char COOKED[] = STTY "cooked";
const char default_str[] = "I AM AN IDIOT ";
int main(int argc, char **argv) {
system(RAW);
const char *str;
if ( argc == 2 )
str = argv[1];
else
str = default_str;
size_t len = strlen(str);
while ( 1 ) {
for ( size_t i = 0 ; i < len ; i++ ) {
getchar();
printf("\r");
for ( size_t j = 0 ; j <= i ; j++ ) {
printf("%c", str[j]);
}
}
system(COOKED);
printf("\n");
system(RAW);
}
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STTY "/bin/stty "
const char RAW[] = STTY "raw";
const char COOKED[] = STTY "cooked";
const char default_str[] = "I AM AN IDIOT ";
int main(int argc, char **argv) {
system(RAW);
const char *str;
if ( argc == 2 )
str = argv[1];
else
str = default_str;
size_t len = strlen(str);
while ( 1 ) {
for ( size_t i = 0 ; i < len ; i++ ) {
getchar();
printf("\x1b[2K\r");
for ( size_t j = 0 ; j <= i ; j++ ) {
printf("%c", str[j]);
}
}
system(COOKED);
printf("\n");
system(RAW);
}
return 0;
}
|
Define sql5_export so that things compile. | /*
* The contents of this file are subject to the MonetDB Public License
* Version 1.1 (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.monetdb.org/Legal/MonetDBLicense
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is the MonetDB Database System.
*
* The Initial Developer of the Original Code is CWI.
* Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
* Copyright August 2008-2012 MonetDB B.V.
* All Rights Reserved.
*/
#ifndef SQL_READLINETOOLS_H_INCLUDED
#define SQL_READLINETOOLS_H_INCLUDED
#include "mal_client.h"
sql5_export int SQLreadConsole(Client cntxt);
#endif /* SQL_READLINETOOLS_H_INCLUDED */
| /*
* The contents of this file are subject to the MonetDB Public License
* Version 1.1 (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.monetdb.org/Legal/MonetDBLicense
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is the MonetDB Database System.
*
* The Initial Developer of the Original Code is CWI.
* Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
* Copyright August 2008-2012 MonetDB B.V.
* All Rights Reserved.
*/
#ifndef SQL_READLINETOOLS_H_INCLUDED
#define SQL_READLINETOOLS_H_INCLUDED
#ifdef WIN32
#ifndef LIBSQL
#define sql5_export extern __declspec(dllimport)
#else
#define sql5_export extern __declspec(dllexport)
#endif
#else
#define sql5_export extern
#endif
#include "mal_client.h"
sql5_export int SQLreadConsole(Client cntxt);
#endif /* SQL_READLINETOOLS_H_INCLUDED */
|
Remove ctor and dtor of IOperation to make it a pure virtual class | #pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATION_H_
#include <unordered_map>
#include "../task_typedefs.h"
namespace You {
namespace DataStore {
/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
/// The constructor
/// \param stask the serialized task the operation need to work with
explicit IOperation(SerializedTask& stask);
virtual ~IOperation();
/// Executes the operation
virtual bool run() = 0;
protected:
TaskId taskId;
SerializedTask task;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_INTERNAL_OPERATION_H_
| #pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATION_H_
#include <unordered_map>
#include "../task_typedefs.h"
namespace You {
namespace DataStore {
/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
/// Executes the operation
virtual bool run() = 0;
protected:
TaskId taskId;
SerializedTask task;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_INTERNAL_OPERATION_H_
|
Add automation for arduino board selection for compilation | #ifndef __ACONFIG_H_
#define __ACONFIG_H_
/* This must be before alphabetically before all other files that reference these settings for the compiler to work
* or you may get vtable errors.
*/
/* This section is for devices and their configuration. IF you have not setup you pins with the
* standard configuration of the OpenROV kits, you should probably clone the cape or controlboard
* and change the pin definitions there. Things not wired to specific pins but on the I2C bus will
* have the address defined in this file.
*/
//Kit:
#define HAS_STD_CAPE (0)
#define HAS_STD_PILOT (1)
#define HAS_OROV_CONTROLLERBOARD_25 (0)
#define HAS_STD_LIGHTS (1)
#define HAS_STD_CALIBRATIONLASERS (0)
#define HAS_STD_2X1_THRUSTERS (1)
#define HAS_STD_CAMERAMOUNT (1)
//After Market:
#define HAS_POLOLU_MINIMUV (0)
#define HAS_MS5803_14BA (0)
#define MS5803_14BA_I2C_ADDRESS 0x76
#define HAS_MPU9150 (0)
#define MPU9150_EEPROM_START 2
#endif
| #ifndef __ACONFIG_H_
#define __ACONFIG_H_
/* This must be before alphabetically before all other files that reference these settings for the compiler to work
* or you may get vtable errors.
*/
/* This section is for devices and their configuration. IF you have not setup you pins with the
* standard configuration of the OpenROV kits, you should probably clone the cape or controlboard
* and change the pin definitions there. Things not wired to specific pins but on the I2C bus will
* have the address defined in this file.
*/
//Kit:
#define HAS_STD_PILOT (1)
/* The definitions are done in th
#define HAS_STD_CAPE (0)
#define HAS_OROV_CONTROLLERBOARD_25 (0)
*/
#include "BoardConfig.h"
#define HAS_STD_LIGHTS (1)
#define HAS_STD_CALIBRATIONLASERS (1)
#define HAS_STD_2X1_THRUSTERS (1)
#define HAS_STD_CAMERAMOUNT (1)
//After Market:
#define HAS_POLOLU_MINIMUV (0)
#define HAS_MS5803_14BA (0)
#define MS5803_14BA_I2C_ADDRESS 0x76
#define HAS_MPU9150 (0)
#define MPU9150_EEPROM_START 2
#endif
|
Add Timer implementation for C++. | #ifndef TIMER_H
#define TIMER_H
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
using namespace std;
class Timer {
private:
timeval startTime;
public:
void start(){
gettimeofday(&startTime, NULL);
}
double stop(){
timeval endTime;
long seconds, useconds;
double duration;
gettimeofday(&endTime, NULL);
seconds = endTime.tv_sec - startTime.tv_sec;
useconds = endTime.tv_usec - startTime.tv_usec;
duration = seconds + useconds/1000000.0;
return duration;
}
static void printTime(double duration){
printf("%5.6f seconds\n", duration);
}
};
#endif // TIMER_H
| |
Include ltdl.h if we have it. | /*
* The LLVM Compiler Infrastructure
*
* This file was developed by the LLVM research group and is distributed under
* the University of Illinois Open Source License. See LICENSE.TXT for details.
*
******************************************************************************
*
* Description:
* This header file is the autoconf replacement for dlfcn.h (if it lives
* on the system).
*/
#ifndef _CONFIG_DLFCN_H
#define _CONFIG_DLFCN_H
#include "llvm/Config/config.h"
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#endif
| /*
* The LLVM Compiler Infrastructure
*
* This file was developed by the LLVM research group and is distributed under
* the University of Illinois Open Source License. See LICENSE.TXT for details.
*
******************************************************************************
*
* Description:
* This header file is the autoconf replacement for dlfcn.h (if it lives
* on the system).
*/
#ifndef _CONFIG_DLFCN_H
#define _CONFIG_DLFCN_H
#include "llvm/Config/config.h"
#ifdef HAVE_LTDL_H
#include <ltdl.h>
#endif
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#endif
|
Fix compiler warning about redundant comma | /*
* socketcan/can/raw.h
*
* Definitions for raw CAN sockets
*
* Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Urs Thuermann <urs.thuermann@volkswagen.de>
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved.
*
*/
#ifndef CAN_RAW_H
#define CAN_RAW_H
#include <socketcan/can.h>
#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
/* for socket options affecting the socket (not the global system) */
enum {
CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */
CAN_RAW_ERR_FILTER, /* set filter for error frames */
CAN_RAW_LOOPBACK, /* local loopback (default:on) */
CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */
CAN_RAW_FD_FRAMES, /* allow CAN FD frames (default:off) */
};
#endif
| /*
* socketcan/can/raw.h
*
* Definitions for raw CAN sockets
*
* Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Urs Thuermann <urs.thuermann@volkswagen.de>
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved.
*
*/
#ifndef CAN_RAW_H
#define CAN_RAW_H
#include <socketcan/can.h>
#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
/* for socket options affecting the socket (not the global system) */
enum {
CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */
CAN_RAW_ERR_FILTER, /* set filter for error frames */
CAN_RAW_LOOPBACK, /* local loopback (default:on) */
CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */
CAN_RAW_FD_FRAMES /* allow CAN FD frames (default:off) */
};
#endif
|
Use EGA color constant for background | #ifndef APRTERM_H
#define APRTERM_H
#include <SDL2/SDL.h>
#ifndef VERSION
#define VERSION "UNKNOWN"
#endif /* VERSION */
#ifndef RESOURCE_DIR
#define RESOURCE_DIR "."
#endif /* RESOURCE_DIR */
/* Font info */
#define FONT_FILE "vga8x16.png"
#define CHAR_WIDTH 8
#define CHAR_HEIGHT 16
#define FONT_COLS 32
#define FONT_LINES 8
/* Screen info */
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_ROWS (SCREEN_HEIGHT / CHAR_HEIGHT)
#define SCREEN_COLS (SCREEN_WIDTH / CHAR_WIDTH)
/* Terminal settings */
#define BACKGROUND_COLOR {0, 0, 0, 255}
#define FOREGROUND_COLOR EGA_GRAY
#endif /* APRTERM_H */
| #ifndef APRTERM_H
#define APRTERM_H
#include <SDL2/SDL.h>
#ifndef VERSION
#define VERSION "UNKNOWN"
#endif /* VERSION */
#ifndef RESOURCE_DIR
#define RESOURCE_DIR "."
#endif /* RESOURCE_DIR */
/* Font info */
#define FONT_FILE "vga8x16.png"
#define CHAR_WIDTH 8
#define CHAR_HEIGHT 16
#define FONT_COLS 32
#define FONT_LINES 8
/* Screen info */
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_ROWS (SCREEN_HEIGHT / CHAR_HEIGHT)
#define SCREEN_COLS (SCREEN_WIDTH / CHAR_WIDTH)
/* Terminal settings */
#define BACKGROUND_COLOR EGA_BLACK
#define FOREGROUND_COLOR EGA_GRAY
#endif /* APRTERM_H */
|
Add move assignment method to Optional<> | /*
*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_GPRPP_OPTIONAL_H
#define GRPC_CORE_LIB_GPRPP_OPTIONAL_H
namespace grpc_core {
/* A make-shift alternative for absl::Optional. This can be removed in favor of
* that once absl dependencies can be introduced. */
template <typename T>
class Optional {
public:
Optional() : value_() {}
void set(const T& val) {
value_ = val;
set_ = true;
}
bool has_value() const { return set_; }
void reset() { set_ = false; }
T value() const { return value_; }
private:
T value_;
bool set_ = false;
};
} /* namespace grpc_core */
#endif /* GRPC_CORE_LIB_GPRPP_OPTIONAL_H */
| /*
*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_GPRPP_OPTIONAL_H
#define GRPC_CORE_LIB_GPRPP_OPTIONAL_H
#include <grpc/support/port_platform.h>
#include <utility>
namespace grpc_core {
/* A make-shift alternative for absl::Optional. This can be removed in favor of
* that once absl dependencies can be introduced. */
template <typename T>
class Optional {
public:
Optional() : value_() {}
void set(const T& val) {
value_ = val;
set_ = true;
}
void set(T&& val) {
value_ = std::move(val);
set_ = true;
}
bool has_value() const { return set_; }
void reset() { set_ = false; }
T value() const { return value_; }
private:
T value_;
bool set_ = false;
};
} /* namespace grpc_core */
#endif /* GRPC_CORE_LIB_GPRPP_OPTIONAL_H */
|
Fix MIPS template in master | /**
* @file
*
* @date Mar 21, 2013
* @author: Anton Bondarev
*/
struct sleepq;
struct event;
void sched_wake_all(struct sleepq *sq) {
}
int sched_sleep_ms(struct sleepq *sq, unsigned long timeout) {
return 0;
}
int sched_sleep_locked_ms(struct sleepq *sq, unsigned long timeout) {
return 0;
}
int sched_sleep_ns(struct sleepq *sq, unsigned long timeout) {
return 0;
}
int sched_sleep_us(struct sleepq *sq, unsigned long timeout) {
return 0;
}
int sched_sleep_locked_us(struct sleepq *sq, unsigned long timeout) {
return 0;
}
int sched_sleep_locked_ns(struct sleepq *sq, unsigned long timeout) {
return 0;
}
| /**
* @file
*
* @date Mar 21, 2013
* @author: Anton Bondarev
*/
struct sleepq;
struct event;
void sched_wake_all(struct sleepq *sq) {
}
int sched_sleep(struct sleepq *sq, unsigned long timeout) {
return 0;
}
int sched_sleep_locked(struct sleepq *sq, unsigned long timeout) {
return 0;
}
|
Add List Node creation function declaration | #include <stdlib.h>
#ifndef __LIST_H__
#define __LIST_H__
struct ListNode;
struct List;
typedef struct ListNode ListNode;
typedef struct List List;
List* List_Create(void);
void List_Destroy(List* l);
#endif | #include <stdlib.h>
#ifndef __LIST_H__
#define __LIST_H__
struct ListNode;
struct List;
typedef struct ListNode ListNode;
typedef struct List List;
List* List_Create(void);
void List_Destroy(List* l);
ListNode* ListNode_Create(void *);
#endif |
Add qstr - query string utility | // ** QueryString
//
// This program reads chars from stdin without echo and put to stdout.
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
int main(int argc, char * args[])
{
struct termios old_tio, new_tio;
unsigned char c;
/* get the terminal settings for stdin */
tcgetattr(STDIN_FILENO, &old_tio);
/* we want to keep the old setting to restore them a the end */
new_tio = old_tio;
/* disable canonical mode (buffered i/o) and local echo */
new_tio.c_lflag &= (~ICANON & ~ECHO);
/* set the new settings immediately */
tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
while ((c = getchar()) != '\n')
{
putchar(c);
};
/* restore the former settings */
tcsetattr(STDIN_FILENO, TCSANOW, &old_tio);
return 0;
}
| |
Comment out the code to subclass CairoContext | #ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Python.h>
#include <pygobject.h>
#include <pango/pangocairo.h>
#include <pycairo.h>
void pycluttercairo_register_classes (PyObject *d);
void pycluttercairo_add_constants (PyObject *module, const gchar *strip_prefix);
extern PyMethodDef pycluttercairo_functions[];
extern PyTypeObject PyClutterCairoContext_Type;
Pycairo_CAPI_t *Pycairo_CAPI;
DL_EXPORT(void)
initcluttercairo (void)
{
PyObject *m, *d;
/* perform any initialisation required by the library here */
m = Py_InitModule ("cluttercairo", pycluttercairo_functions);
d = PyModule_GetDict (m);
Pycairo_IMPORT;
if (Pycairo_CAPI == NULL)
return;
#if 0
PyClutterCairoContext_Type.tp_base = &PycairoContext_Type;
if (PyType_Ready(&PyClutterCairoContext_Type) < 0) {
g_return_if_reached ();
}
#endif
init_pygobject ();
pycluttercairo_register_classes (d);
Py_INCREF (&PyClutterCairoContext_Type);
PyModule_AddObject (m, "CairoContext",
(PyObject *) &PyClutterCairoContext_Type)
;
}
| #ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Python.h>
#include <pygobject.h>
#include <pango/pangocairo.h>
#include <pycairo.h>
void pycluttercairo_register_classes (PyObject *d);
void pycluttercairo_add_constants (PyObject *module, const gchar *strip_prefix);
extern PyMethodDef pycluttercairo_functions[];
#if 0
extern PyTypeObject PyClutterCairoContext_Type;
#endif
Pycairo_CAPI_t *Pycairo_CAPI;
DL_EXPORT(void)
initcluttercairo (void)
{
PyObject *m, *d;
/* perform any initialisation required by the library here */
m = Py_InitModule ("cluttercairo", pycluttercairo_functions);
d = PyModule_GetDict (m);
Pycairo_IMPORT;
if (Pycairo_CAPI == NULL)
return;
#if 0
PyClutterCairoContext_Type.tp_base = &PycairoContext_Type;
if (PyType_Ready(&PyClutterCairoContext_Type) < 0) {
g_return_if_reached ();
}
#endif
init_pygobject ();
pycluttercairo_register_classes (d);
#if 0
Py_INCREF (&PyClutterCairoContext_Type);
PyModule_AddObject (m, "CairoContext",
(PyObject *) &PyClutterCairoContext_Type)
;
#endif
if (PyErr_Occurred ()) {
Py_FatalError ("unable to initialise cluttercairo module");
}
}
|
Add example that should work | // SKIP PARAM: --set solver td3 --set ana.activated "['base','threadid','threadflag','mallocWrapper','apron','escape']" --set ana.path_sens[+] threadflag --set ana.base.privatization none --set ana.apron.privatization mutex-meet-tid
// Copy of 45 01 for apron
#include <pthread.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
int g, h;
void *foo(void* p){
sleep(2);
int* ip = ((int*) p);
printf("ip is %d\n", *ip);
*ip = 42;
return NULL;
}
int main(){
int x = 0;
int *xp = &x;
pthread_t thread;
int y;
g = y;
h = y;
pthread_create(&thread, NULL, foo, xp);
sleep(4); // to make sure that we actually fail the assert when running.
assert(x == 42); //UNKNOWN!
assert(x == 0); //UNKNOWN!
assert(x <= 50);
assert(g==h);
pthread_join(thread, NULL);
return 0;
}
| |
Change ordering of fields in DayPeriod |
// Copyright 2015 Malcolm Inglis <http://minglis.id.au>
//
// This file is part of Libtime.
//
// Libtime is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// Libtime is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
// more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Libtime. If not, see <https://gnu.org/licenses/>.
#ifndef LIBTIME_DAYPERIOD_H
#define LIBTIME_DAYPERIOD_H
#include <time.h>
#include <libtypes/types.h>
#include "daytime.h"
typedef struct dayperiod {
DayTime start;
ulong duration;
} DayPeriod;
DayTime
dayperiod__end( DayPeriod );
bool
dayperiod__contains( DayPeriod,
DayTime );
#endif // ifndef LIBTIME_DAYPERIOD_H
|
// Copyright 2015 Malcolm Inglis <http://minglis.id.au>
//
// This file is part of Libtime.
//
// Libtime is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// Libtime is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
// more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Libtime. If not, see <https://gnu.org/licenses/>.
#ifndef LIBTIME_DAYPERIOD_H
#define LIBTIME_DAYPERIOD_H
#include <time.h>
#include <libtypes/types.h>
#include "daytime.h"
typedef struct dayperiod {
ulong duration;
DayTime start;
} DayPeriod;
DayTime
dayperiod__end(
DayPeriod );
bool
dayperiod__contains(
DayPeriod,
DayTime );
#endif // ifndef LIBTIME_DAYPERIOD_H
|
Add links to related react-native-macos issues | // Most (if not all) of this file could probably go away once react-native-macos's version of RCTUIKit.h makes its way upstream.
// https://github.com/microsoft/react-native-macos/issues/242
#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
#define RNSVGColor UIColor
#define RNSVGPlatformView UIView
#define RNSVGTextView UILabel
#define RNSVGView UIView
#else // TARGET_OS_OSX [
#import <React/RCTUIKit.h>
#define RNSVGColor NSColor
#define RNSVGPlatformView NSView
#define RNSVGTextView NSTextView
@interface RNSVGView : RCTUIView
@property CGPoint center;
@property (nonatomic, strong) RNSVGColor *tintColor;
@end
// TODO: These could probably be a part of react-native-macos
@interface NSImage (RNSVGMacOSExtensions)
@property (readonly) CGImageRef CGImage;
@end
@interface NSValue (RNSVGMacOSExtensions)
+ (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform;
+ (NSValue *)valueWithCGPoint:(CGPoint)point;
@property (readonly) CGAffineTransform CGAffineTransformValue;
@property (readonly) CGPoint CGPointValue;
@end
#endif // ] TARGET_OS_OSX
| // Most (if not all) of this file could probably go away once react-native-macos's version of RCTUIKit.h makes its way upstream.
// https://github.com/microsoft/react-native-macos/issues/242
#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
#define RNSVGColor UIColor
#define RNSVGPlatformView UIView
#define RNSVGTextView UILabel
#define RNSVGView UIView
#else // TARGET_OS_OSX [
#import <React/RCTUIKit.h>
#define RNSVGColor NSColor
#define RNSVGPlatformView NSView
#define RNSVGTextView NSTextView
@interface RNSVGView : RCTUIView
@property CGPoint center;
@property (nonatomic, strong) RNSVGColor *tintColor;
@end
// TODO: These could probably be a part of react-native-macos
// See https://github.com/microsoft/react-native-macos/issues/658 and https://github.com/microsoft/react-native-macos/issues/659
@interface NSImage (RNSVGMacOSExtensions)
@property (readonly) CGImageRef CGImage;
@end
@interface NSValue (RNSVGMacOSExtensions)
+ (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform;
+ (NSValue *)valueWithCGPoint:(CGPoint)point;
@property (readonly) CGAffineTransform CGAffineTransformValue;
@property (readonly) CGPoint CGPointValue;
@end
#endif // ] TARGET_OS_OSX
|
Remove BTM_DEF_LOCAL_NAME define. product model name is used as default | /*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTM_DEF_LOCAL_NAME "hammerhead"
#define BTA_DISABLE_DELAY 100 /* in milliseconds */
#endif
| /*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTA_DISABLE_DELAY 100 /* in milliseconds */
#endif
|
Fix state definition for UriEndPointElement | #ifndef __KMS_URI_END_POINT_STATE_H__
#define __KMS_URI_END_POINT_STATE_H__
G_BEGIN_DECLS
typedef enum
{
KMS_URI_END_POINT_STATE_STOP,
KMS_URI_END_POINT_STATE_START,
KMS_URI_END_POINT_STATE_PLAY
} KmsUriEndPointState;
G_END_DECLS
#endif /* __KMS_URI_END_POINT_STATE__ */
| #ifndef __KMS_URI_END_POINT_STATE_H__
#define __KMS_URI_END_POINT_STATE_H__
G_BEGIN_DECLS
typedef enum
{
KMS_URI_END_POINT_STATE_STOP,
KMS_URI_END_POINT_STATE_START,
KMS_URI_END_POINT_STATE_PAUSE
} KmsUriEndPointState;
G_END_DECLS
#endif /* __KMS_URI_END_POINT_STATE__ */
|
Remove extra warning in typedef/init/func test | // RUN: %check -e %s
typedef int f(void) // CHECK: error: typedef storage on function
{
return 3;
}
typedef char c = 3; // CHECK: error: initialised typedef
main()
{
int *p = (__typeof(*p))0; // CHECK: !/warn/
for(int _Alignas(long) x = 0; x; x++); // CHECK: !/warn/
return f(); // CHECK: !/warn/
}
| // RUN: %check -e %s
typedef int f(void) // CHECK: error: typedef storage on function
{
return 3;
}
typedef char c = 3; // CHECK: error: initialised typedef
main()
{
int *p = (__typeof(*p))0; // can't check here - we think p is used uninit
for(int _Alignas(long) x = 0; x; x++); // CHECK: !/warn/
return f(); // CHECK: !/warn/
}
|
Disable negative test in shadowcallstack. | // RUN: %clang_scs -D INCLUDE_RUNTIME %s -o %t
// RUN: %run %t
// RUN: %clang_scs %s -o %t
// RUN: not --crash %run %t
// Basic smoke test for the runtime
#include "libc_support.h"
#ifdef INCLUDE_RUNTIME
#include "minimal_runtime.h"
#else
#define scs_main main
#endif
int scs_main(void) {
scs_fputs_stdout("In main.\n");
return 0;
}
| // RUN: %clang_scs %s -o %t
// RUN: %run %t
// Basic smoke test for the runtime
#include "libc_support.h"
#include "minimal_runtime.h"
int scs_main(void) {
scs_fputs_stdout("In main.\n");
return 0;
}
|
Remove extraneous header file comment | //
// CSCustomBanner.h
// CommuteStream
//
// Created by David Rogers on 5/3/14.
// Copyright (c) 2014 CommuteStream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GADCustomEventBanner.h"
#import "GADCustomEventBannerDelegate.h"
#import "GADBannerView.h"
#import "GADBannerViewDelegate.h"
#import "CSNetworkEngine.h"
@interface CSCustomBanner : NSObject <GADCustomEventBanner, GADBannerViewDelegate, UIGestureRecognizerDelegate> {
GADBannerView *bannerView_;
}
@property (nonatomic, strong) CSNetworkEngine *csNetworkEngine;
-(void)buildWebView:(NSMutableDictionary*)dict;
+ (NSString *)getIdfa;
+ (NSString *)getMacSha:(NSString *)deviceAddress;
@end | #import <Foundation/Foundation.h>
#import "GADCustomEventBanner.h"
#import "GADCustomEventBannerDelegate.h"
#import "GADBannerView.h"
#import "GADBannerViewDelegate.h"
#import "CSNetworkEngine.h"
@interface CSCustomBanner : NSObject <GADCustomEventBanner, GADBannerViewDelegate, UIGestureRecognizerDelegate> {
GADBannerView *bannerView_;
}
@property (nonatomic, strong) CSNetworkEngine *csNetworkEngine;
-(void)buildWebView:(NSMutableDictionary*)dict;
+ (NSString *)getIdfa;
+ (NSString *)getMacSha:(NSString *)deviceAddress;
@end |
Use GModule instead of libdl to load unit test symbols | #include <config.h>
#include <dlfcn.h>
#include <test-fixtures/test-unit.h>
int
main (int argc, char **argv)
{
const CoglUnitTest *unit_test;
int i;
if (argc != 2)
{
g_printerr ("usage %s UNIT_TEST\n", argv[0]);
exit (1);
}
/* Just for convenience in case people try passing the wrapper
* filenames for the UNIT_TEST argument we normalize '-' characters
* to '_' characters... */
for (i = 0; argv[1][i]; i++)
{
if (argv[1][i] == '-')
argv[1][i] = '_';
}
unit_test = dlsym (RTLD_DEFAULT, argv[1]);
if (!unit_test)
{
g_printerr ("Unknown test name \"%s\"\n", argv[1]);
return 1;
}
test_utils_init (unit_test->requirement_flags,
unit_test->known_failure_flags);
unit_test->run ();
test_utils_fini ();
return 0;
}
| #include <config.h>
#include <gmodule.h>
#include <test-fixtures/test-unit.h>
int
main (int argc, char **argv)
{
GModule *main_module;
const CoglUnitTest *unit_test;
int i;
if (argc != 2)
{
g_printerr ("usage %s UNIT_TEST\n", argv[0]);
exit (1);
}
/* Just for convenience in case people try passing the wrapper
* filenames for the UNIT_TEST argument we normalize '-' characters
* to '_' characters... */
for (i = 0; argv[1][i]; i++)
{
if (argv[1][i] == '-')
argv[1][i] = '_';
}
main_module = g_module_open (NULL, /* use main module */
0 /* flags */);
if (!g_module_symbol (main_module, argv[1], (void **) &unit_test))
{
g_printerr ("Unknown test name \"%s\"\n", argv[1]);
return 1;
}
test_utils_init (unit_test->requirement_flags,
unit_test->known_failure_flags);
unit_test->run ();
test_utils_fini ();
return 0;
}
|
Add support for wrapping a shared_ptr to a const | /*ckwg +5
* Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef VISTK_PYTHON_PYTHON_WRAP_CONST_SHARED_PTR_H
#define VISTK_PYTHON_PYTHON_WRAP_CONST_SHARED_PTR_H
#include <boost/python/pointee.hpp>
#include <boost/shared_ptr.hpp>
// Retrieved from http://mail.python.org/pipermail/cplusplus-sig/2006-November/011329.html
namespace boost
{
namespace python
{
template <typename T>
inline
T*
get_pointer(boost::shared_ptr<T const> const& p)
{
return const_cast<T*>(p.get());
}
template <typename T>
struct pointee<boost::shared_ptr<T const> >
{
typedef T type;
};
}
}
#endif // VISTK_PYTHON_PYTHON_WRAP_CONST_SHARED_PTR_H
| |
Change TestString score to signed int | #include<stdint.h>
#include<string>
#include<stdexcept>
#include<vector>
// styled according to the Google C++ Style guide
// https://google.github.io/styleguide/cppguide.html
struct TestString {
std::string s;
uint8_t key;
uint32_t score;
};
TestString CreateTestString(std::string input_string, uint8_t input_key);
std::vector<TestString> FilterNonPrintable(std::vector<TestString> input_strings);
std::vector<TestString> FilterExcessivePunctuation(std::vector<TestString> input_strings, uint16_t punc_threshold);
| #include<stdint.h>
#include<string>
#include<stdexcept>
#include<vector>
// styled according to the Google C++ Style guide
// https://google.github.io/styleguide/cppguide.html
struct TestString {
std::string s;
uint8_t key;
int32_t score;
};
TestString CreateTestString(std::string input_string, uint8_t input_key);
std::vector<TestString> FilterNonPrintable(std::vector<TestString> input_strings);
std::vector<TestString> FilterExcessivePunctuation(std::vector<TestString> input_strings, uint16_t punc_threshold);
|
Add regression test where mine-lazy used to crash due to multiple paths | #include <pthread.h>
struct options {
unsigned short number_of_threads ;
unsigned short cur_threads ;
};
struct flags {
unsigned char debug ;
};
struct options o ;
struct flags f ;
int cleaner_start(void)
{
// make unknown
int r;
o.cur_threads = r;
o.number_of_threads = r;
f.debug = r;
return 0;
}
int thread_start()
{
return 0;
}
pthread_mutex_t main_thread_count_mutex = PTHREAD_MUTEX_INITIALIZER;
int main(int argc , char **argv )
{
pthread_t c_tid ;
pthread_create(& c_tid, NULL, & cleaner_start, NULL);
int x = 0;
pthread_mutex_lock(& main_thread_count_mutex);
while ((int )o.cur_threads >= (int )o.number_of_threads) {
pthread_mutex_unlock(& main_thread_count_mutex);
if (f.debug) {
x = 1; // do something
}
// missing lock?
}
pthread_mutex_unlock(& main_thread_count_mutex);
// mine-lazy gets here with two paths and crashes
pthread_create(& c_tid, NULL, & thread_start, NULL);
return (0);
} | |
Correct locaiton of msado15 for x64 dev platform | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#include <io.h>
#include <fcntl.h>
// import ADODB
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")
| // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#include <io.h>
#include <fcntl.h>
// import ADODB
#import "C:\Program Files (x86)\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")
|
Increase size of section buffer | #ifndef DSMCC_TS_H
#define DSMCC_TS_H
#include <stdint.h>
#define DSMCC_TSPARSER_BUFFER_SIZE (4096 + 188)
struct dsmcc_tsparser_buffer
{
uint16_t pid;
int si_seen;
int in_section;
int cont;
uint8_t data[DSMCC_TSPARSER_BUFFER_SIZE];
struct dsmcc_tsparser_buffer *next;
};
#endif
| #ifndef DSMCC_TS_H
#define DSMCC_TS_H
#include <stdint.h>
#define DSMCC_TSPARSER_BUFFER_SIZE 8192
struct dsmcc_tsparser_buffer
{
uint16_t pid;
int si_seen;
int in_section;
int cont;
uint8_t data[DSMCC_TSPARSER_BUFFER_SIZE];
struct dsmcc_tsparser_buffer *next;
};
#endif
|
Change SAMpling Rate to 44.1K, ready for wav playing | #ifndef __SETTING_H__
#define __SETTING_H__
#define DITHERING_AMP 768;
#define BUFFER_NUM 4
#define STAGE_NUM 4
#define SAMPLE_NUM 256
#define SAMPLE_MAX 2047
#define SAMPLING_RATE 45 /* In Kilo Hz, Make Sure it can divide 45000*/
#define SAMPLE_PERIOD (1.0f / SAMPLING_RATE)
#define Q_1 1048576
#define Q_MULT_SHIFT 11
#define BLOCK_PERIOD ((float)SAMPLE_NUM / SAMPLING_RATE)
#define DELAY_BANK(x) DELAY_BANK_##x
#define DELAY_BANK_0 0xD0200000
#define DELAY_BANK_1 0xD0300000
#define DELAY_BANK_2 0xD0400000
#define DELAY_BANK_3 0xD0500000
#define DELAY_BANK_4 0xD0600000
#endif //__SETTING_H__
| #ifndef __SETTING_H__
#define __SETTING_H__
#define DITHERING_AMP 768;
#define BUFFER_NUM 4
#define STAGE_NUM 4
#define SAMPLE_NUM 256
#define SAMPLE_MAX 2047
#define SAMPLING_RATE 44.1 /* In Kilo Hz, Make Sure it can divide 45000*/
#define SAMPLE_PERIOD (1.0f / SAMPLING_RATE)
#define Q_1 1048576
#define Q_MULT_SHIFT 11
#define BLOCK_PERIOD ((float)SAMPLE_NUM / SAMPLING_RATE)
#define DELAY_BANK(x) DELAY_BANK_##x
#define DELAY_BANK_0 0xD0200000
#define DELAY_BANK_1 0xD0300000
#define DELAY_BANK_2 0xD0400000
#define DELAY_BANK_3 0xD0500000
#define DELAY_BANK_4 0xD0600000
#endif //__SETTING_H__
|
Add general library header file for user convenience | /*
liblightmodbus - a lightweight, multiplatform Modbus library
Copyright (C) 2017 Jacek Wieczorek <mrjjot@gmail.com>
This file is part of liblightmodbus.
Liblightmodbus 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.
Liblightmodbus 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 LIGHTMODBUS_H
#define LIGHTMODBUS_H
//This is for user convenience only
#include "core.h"
#include "master.h"
#include "slave.h"
#endif | |
Add conversion from OpenSim array to vector | //__________________________________________________________________________
// Author(s): Claudio Pizzolato - October 2013
// email: claudio.pizzolato@griffithuni.edu.au
//
// DO NOT REDISTRIBUTE WITHOUT PERMISSION
//__________________________________________________________________________
//
#ifndef ArrayConverter_h
#define ArrayConverter_h
class ArrayConverter{
public:
template<typename T>
static void toStdVector(const OpenSim::Array<T>& srcArray, std::vector<T>& dstVector) {
dstVector.clear();
int size = srcArray.getSize();
dstVector.resize(size);
for(int i = 0; i < size; ++i)
dstVector.at(i) = srcArray.get(i);
}
template<typename T>
static void fromStdVector(OpenSim::Array<T>& dstArray, const std::vector<T>& srcVector) {
for(typename vector<T>::const_iterator it(srcVector.begin()); it != srcVector.end(); ++it)
dstArray.append(*it);
}
};
#endif | |
Declare option "+" for TTreePlayer | /* @(#)root/treeplayer:$Name: $:$Id: LinkDef.h,v 1.1.1.1 2000/05/16 17:00:44 rdm Exp $ */
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TTreePlayer;
#pragma link C++ class TPacketGenerator;
#pragma link C++ class TTreeFormula-;
#endif
| /* @(#)root/treeplayer:$Name: $:$Id: LinkDef.h,v 1.2 2000/07/06 17:20:52 brun Exp $ */
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TTreePlayer+;
#pragma link C++ class TPacketGenerator;
#pragma link C++ class TTreeFormula-;
#endif
|
Debug info for init dunction. | /*
This file is part of libcapwap.
libcapwap 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.
libcapwap 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gnutls/gnutls.h>
int dtls_gnutls_init()
{
gnutls_global_init();
return 1;
}
| /*
This file is part of libcapwap.
libcapwap 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.
libcapwap 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gnutls/gnutls.h>
#include "cw_log.h"
int dtls_gnutls_init()
{
cw_dbg(DBG_CW_INFO,"Init SSL library - using GnuTLS");
gnutls_global_init();
return 1;
}
|
Increase the sampling rate to 200khz | #ifndef __SETTING_H__
#define __SETTING_H__
#define BUFFER_NUM 4
#define STAGE_NUM 4
#define SAMPLE_NUM 256
#define SAMPLE_MAX 2047
#define SAMPLING_RATE 100 /* In Kilo Hz, Make Sure it can divide 45000*/
#define SAMPLE_PREIOD 1 / SAMPLE_RATE
#define BLOCK_PREIOD SAMPLE_NUM / SAMPLING_RATE
#define DELAY_BANK(x) DELAY_BANK_##x
#define DELAY_BANK_0 0xD0200000
#define DELAY_BANK_1 0xD0300000
#define DELAY_BANK_2 0xD0400000
#define DELAY_BANK_3 0xD0500000
#define DELAY_BANK_4 0xD0600000
#endif //__SETTING_H__
| #ifndef __SETTING_H__
#define __SETTING_H__
#define BUFFER_NUM 4
#define STAGE_NUM 4
#define SAMPLE_NUM 256
#define SAMPLE_MAX 2047
#define SAMPLING_RATE 200 /* In Kilo Hz, Make Sure it can divide 45000*/
#define SAMPLE_PREIOD 1 / SAMPLE_RATE
#define BLOCK_PREIOD SAMPLE_NUM / SAMPLING_RATE
#define DELAY_BANK(x) DELAY_BANK_##x
#define DELAY_BANK_0 0xD0200000
#define DELAY_BANK_1 0xD0300000
#define DELAY_BANK_2 0xD0400000
#define DELAY_BANK_3 0xD0500000
#define DELAY_BANK_4 0xD0600000
#endif //__SETTING_H__
|
Add ammo and score fields to the player object | //
// WulfGame/Game/Player.h
// Copyright (C) 2012 Lexi Robinson
// This code is freely available under the MIT licence.
//
#pragma once
#include <glm/glm.hpp>
#include "WulfConstants.h"
#include "Game/InputManager.h"
#include "Game/Constants.h"
#include "Game/Entity.h"
#include "Map/Map.h"
namespace Wulf {
class Player : public Entity {
public:
Player();
~Player() {};
void ProcessUserInput(const Input::Data& input, const double dtime);
void ProcessMapInput(const Map::Map& map);
#ifdef FREE_VIEW
glm::vec3 GetUp() const { return mUp; }
#endif
Difficulty GetDifficulty() const { return mDifficulty; }
void SetDifficulty(Difficulty nDiff) { mDifficulty = nDiff; }
private:
Difficulty mDifficulty;
#ifdef FREE_VIEW
float fhViewAngle;
float fvViewAngle;
glm::vec3 mUp;
#else
float fViewAngle;
#endif
Player(Player& other);
Player& operator=(Player& other);
};
}
| //
// WulfGame/Game/Player.h
// Copyright (C) 2012 Lexi Robinson
// This code is freely available under the MIT licence.
//
#pragma once
#include <glm/glm.hpp>
#include "WulfConstants.h"
#include "Game/InputManager.h"
#include "Game/Constants.h"
#include "Game/Entity.h"
#include "Map/Map.h"
namespace Wulf {
class Player : public Entity {
public:
Player();
~Player() {};
void ProcessUserInput(const Input::Data& input, const double dtime);
void ProcessMapInput(const Map::Map& map);
#ifdef FREE_VIEW
glm::vec3 GetUp() const { return mUp; }
#endif
byte Ammo;
word Score;
Difficulty GetDifficulty() const { return mDifficulty; }
void SetDifficulty(Difficulty nDiff) { mDifficulty = nDiff; }
private:
Difficulty mDifficulty;
#ifdef FREE_VIEW
float fhViewAngle;
float fvViewAngle;
glm::vec3 mUp;
#else
float fViewAngle;
#endif
Player(Player& other);
Player& operator=(Player& other);
};
}
|
Add program to print whole words on new line | #include <stdio.h>
#define IN 1 /* inside a word */
#define OUT 0 /* outside a word */
/* print words on a new line */
int main()
{
int state = OUT;
int c = 0;
int nl = 0;
int nw = 0;
int nc = 0;
while ((c = getchar()) != EOF) {
++nc;
if (c == '\n') {
++nl;
}
if (c == '\n' || c == '\t' || c == ' ') {
if (state == IN) {
putchar('\n');
}
state = OUT;
} else if (state == OUT) {
state = IN;
++nw;
putchar(c);
} else {
putchar(c);
}
}
printf("c: %d\nw: %d\nl: %d\n", nc, nw, nl);
}
| |
Use __i386__ instead of i386 in an ifdef. | /* $NetBSD: ieeefp.h,v 1.4 1998/01/09 08:03:43 perry Exp $ */
/*
* Written by J.T. Conklin, Apr 6, 1995
* Public domain.
*/
#ifndef _IEEEFP_H_
#define _IEEEFP_H_
#include <sys/cdefs.h>
#include <machine/ieeefp.h>
#ifdef i386
#include <machine/floatingpoint.h>
#else
extern fp_rnd fpgetround __P((void));
extern fp_rnd fpsetround __P((fp_rnd));
extern fp_except fpgetmask __P((void));
extern fp_except fpsetmask __P((fp_except));
extern fp_except fpgetsticky __P((void));
extern fp_except fpsetsticky __P((fp_except));
#endif /* i386 */
#endif /* _IEEEFP_H_ */
| /* $NetBSD: ieeefp.h,v 1.4 1998/01/09 08:03:43 perry Exp $ */
/*
* Written by J.T. Conklin, Apr 6, 1995
* Public domain.
*/
#ifndef _IEEEFP_H_
#define _IEEEFP_H_
#include <sys/cdefs.h>
#include <machine/ieeefp.h>
#ifdef __i386__
#include <machine/floatingpoint.h>
#else /* !__i386__ */
extern fp_rnd fpgetround __P((void));
extern fp_rnd fpsetround __P((fp_rnd));
extern fp_except fpgetmask __P((void));
extern fp_except fpsetmask __P((fp_except));
extern fp_except fpgetsticky __P((void));
extern fp_except fpsetsticky __P((fp_except));
#endif /* __i386__ */
#endif /* _IEEEFP_H_ */
|
Add example where it is better to keep last expression | // PARAM: --sets solver td3 --enable ana.int.interval --disable ana.int.trier --disable exp.fast_global_inits --sets exp.partition-arrays.keep-expr "last" --enable exp.partition-arrays.enabled --set ana.activated "['base','expRelation','octagon']"
void main(void) {
example1();
}
void example1(void) {
int a[42];
a[40] = 2;
int i = 0;
while(i < 41) {
a[i] = 0;
i++;
}
assert(a[2] == 0);
assert(a[3] == 0);
}
| |
Update CWOS boot welcome messages | #include <uart.h>
#include <irq.h>
void cwos_boot()
{
uart_init();
uart0_send("Hello CWOS World\n");
irq_enable();
trigger_swi();
while (1) {
}
}
| #include <uart.h>
#include <irq.h>
void cwos_boot()
{
uart_init();
uart0_send("Hello CWOS World\n");
uart0_send("Press any key to see echo:\n");
irq_enable();
while (1) {
}
}
|
Fix clang warning in tests for Chrome OS | // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#pragma once
#include <string>
#include <vector>
#include "chrome/browser/chromeos/login/user_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockUserManager : public UserManager {
public:
MockUserManager() {}
virtual ~MockUserManager() {}
MOCK_CONST_METHOD0(GetUsers, std::vector<User>());
MOCK_METHOD0(OffTheRecordUserLoggedIn, void());
MOCK_METHOD1(UserLoggedIn, void(const std::string&));
MOCK_METHOD1(RemoveUser, void(const std::string&));
MOCK_METHOD1(IsKnownUser, bool(const std::string&));
MOCK_CONST_METHOD0(logged_in_user, const User&());
MOCK_METHOD0(current_user_is_owner, bool());
MOCK_METHOD1(set_current_user_is_owner, void(bool));
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
| // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#pragma once
#include <string>
#include <vector>
#include "chrome/browser/chromeos/login/user_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockUserManager : public UserManager {
public:
MockUserManager() {}
virtual ~MockUserManager() {}
MOCK_CONST_METHOD0(GetUsers, std::vector<User>());
MOCK_METHOD0(OffTheRecordUserLoggedIn, void());
MOCK_METHOD1(UserLoggedIn, void(const std::string&));
MOCK_METHOD2(RemoveUser, void(const std::string&, RemoveUserDelegate*));
MOCK_METHOD1(IsKnownUser, bool(const std::string&));
MOCK_CONST_METHOD0(logged_in_user, const User&());
MOCK_CONST_METHOD0(current_user_is_owner, bool());
MOCK_METHOD1(set_current_user_is_owner, void(bool));
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
|
Reduce jitter on network communication by enabling NO_DELAY, but still make large packets within a update cycle. | #ifndef SP2_IO_NETWORK_SOCKET_BASE_H
#define SP2_IO_NETWORK_SOCKET_BASE_H
#include <io/network/socketBase.h>
#include <SFML/System/NonCopyable.hpp>
namespace sp {
namespace io {
namespace network {
class SocketBase : sf::NonCopyable
{
public:
void setBlocking(bool blocking);
void setNoDelay(bool no_delay);
void setTimeout(int milliseconds);
protected:
bool isLastErrorNonBlocking();
int handle = -1;
bool blocking = true;
friend class Selector;
};
}//namespace network
}//namespace io
}//namespace sp
#endif//SP2_IO_NETWORK_SOCKET_BASE_H
| #ifndef SP2_IO_NETWORK_SOCKET_BASE_H
#define SP2_IO_NETWORK_SOCKET_BASE_H
#include <io/network/socketBase.h>
#include <SFML/System/NonCopyable.hpp>
namespace sp {
namespace io {
namespace network {
class SocketBase : sf::NonCopyable
{
public:
void setBlocking(bool blocking);
void setTimeout(int milliseconds);
protected:
bool isLastErrorNonBlocking();
int handle = -1;
bool blocking = true;
friend class Selector;
};
}//namespace network
}//namespace io
}//namespace sp
#endif//SP2_IO_NETWORK_SOCKET_BASE_H
|
Fix a chicken-and-egg problem: this files implements SSP support, so we cannot compile it with -fstack-protector[-all] flags (or it will self-recurse); this is ensured in sys/conf/files. This OTOH means that checking for defines __SSP__ and __SSP_ALL__ to determine if we should be compiling the support is impossible (which it was trying, resulting in an empty object file). Fix this by always compiling the symbols in this files. It's good because it allows us to always have SSP support, and then compile with SSP selectively. | #include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/libkern.h>
#if defined(__SSP__) || defined(__SSP_ALL__)
long __stack_chk_guard[8] = {};
void __stack_chk_fail(void);
void
__stack_chk_fail(void)
{
panic("stack overflow detected; backtrace may be corrupted");
}
#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
static void
__stack_chk_init(void *dummy __unused)
{
size_t i;
long guard[__arraycount(__stack_chk_guard)];
arc4rand(guard, sizeof(guard), 0);
for (i = 0; i < __arraycount(guard); i++)
__stack_chk_guard[i] = guard[i];
}
/* SI_SUB_EVENTHANDLER is right after SI_SUB_LOCK used by arc4rand() init. */
SYSINIT(stack_chk, SI_SUB_EVENTHANDLER, SI_ORDER_ANY, __stack_chk_init, NULL);
#endif
| #include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/libkern.h>
long __stack_chk_guard[8] = {};
void __stack_chk_fail(void);
void
__stack_chk_fail(void)
{
panic("stack overflow detected; backtrace may be corrupted");
}
#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
static void
__stack_chk_init(void *dummy __unused)
{
size_t i;
long guard[__arraycount(__stack_chk_guard)];
arc4rand(guard, sizeof(guard), 0);
for (i = 0; i < __arraycount(guard); i++)
__stack_chk_guard[i] = guard[i];
}
/* SI_SUB_EVENTHANDLER is right after SI_SUB_LOCK used by arc4rand() init. */
SYSINIT(stack_chk, SI_SUB_EVENTHANDLER, SI_ORDER_ANY, __stack_chk_init, NULL);
|
Add test for 0x00E0 (clear screen) | #include <assert.h>
#include "../src/chip8.c"
void test_clear_screen(void) {
int i;
chip8_t * chip8 = chip8_new();
chip8->memory[0x200] = 0x00;
chip8->memory[0x201] = 0xE0;
chip8_fetch_current_opcode(chip8);
chip8_decode_current_opcode(chip8);
i = 0;
while (i < 64 * 32) {
assert(chip8->memory[i++] == 0);
}
}
int main(int argc, char ** argv) {
test_clear_screen();
}
| |
Use CLOCK_MONOTONIC as default timer clock to align with kenel events. | //-----------------------------------
// Copyright Pierric Gimmig 2013-2017
//-----------------------------------
#pragma once
#include "BaseTypes.h"
#include "Platform.h"
#include "Utils.h"
//-----------------------------------------------------------------------------
typedef uint64_t TickType;
//-----------------------------------------------------------------------------
#ifdef _WIN32
inline void clock_gettime(uint32_t, struct timespec* spec) {
__int64 time;
GetSystemTimeAsFileTime((FILETIME*)&time);
spec->tv_sec = time / 10000000i64;
spec->tv_nsec = time % 10000000i64 * 100;
}
#endif
//-----------------------------------------------------------------------------
inline TickType OrbitTicks(uint32_t a_Clock = 0 /*CLOCK_REALTIME*/) {
timespec ts;
clock_gettime(a_Clock, &ts);
return 1000000000ll * ts.tv_sec + ts.tv_nsec;
}
//-----------------------------------------------------------------------------
inline double MicroSecondsFromTicks(TickType a_Start, TickType a_End) {
return double((a_End - a_Start)) * 0.001;
}
//-----------------------------------------------------------------------------
inline TickType TicksFromMicroseconds(double a_Micros) {
return (TickType)(a_Micros * 1000);
}
| //-----------------------------------
// Copyright Pierric Gimmig 2013-2017
//-----------------------------------
#pragma once
#include "BaseTypes.h"
#include "Platform.h"
#include "Utils.h"
//-----------------------------------------------------------------------------
typedef uint64_t TickType;
//-----------------------------------------------------------------------------
#ifdef _WIN32
inline void clock_gettime(uint32_t, struct timespec* spec) {
__int64 time;
GetSystemTimeAsFileTime((FILETIME*)&time);
spec->tv_sec = time / 10000000i64;
spec->tv_nsec = time % 10000000i64 * 100;
}
#endif
//-----------------------------------------------------------------------------
inline TickType OrbitTicks(uint32_t a_Clock = 1 /*CLOCK_MONOTONIC*/) {
timespec ts;
clock_gettime(a_Clock, &ts);
return 1000000000ll * ts.tv_sec + ts.tv_nsec;
}
//-----------------------------------------------------------------------------
inline double MicroSecondsFromTicks(TickType a_Start, TickType a_End) {
return double((a_End - a_Start)) * 0.001;
}
//-----------------------------------------------------------------------------
inline TickType TicksFromMicroseconds(double a_Micros) {
return (TickType)(a_Micros * 1000);
}
|
Add comment to test linking it back to the original Bugzilla PR. | // RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-pc-linux-gnu
int printf(char const*,...);
void percentm(void) {
printf("%m");
}
| // RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-pc-linux-gnu
// PR 4142 - support glibc extension to printf: '%m' (which prints strerror(errno)).
int printf(char const*,...);
void percentm(void) {
printf("%m");
}
|
Fix C file coding style | struct Inner
{
int x;
};
struct Outer
{
struct Inner inner_embed;
struct Inner* inner_var;
};
void modify_via_outer(struct Outer* s)
{
s->inner_embed.x = 10;
s->inner_var->x = 15;
}
void modify_inner(struct Inner* s)
{
s->x = 5;
}
| typedef struct Inner
{
int x;
} Inner;
typedef struct Outer
{
struct Inner inner_embed;
struct Inner* inner_var;
} Outer;
void modify_via_outer(Outer* s)
{
s->inner_embed.x = 10;
s->inner_var->x = 15;
}
void modify_inner(Inner* s)
{
s->x = 5;
}
|
Send the "* BYE Logging out" before closing mailbox. | /* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "commands.h"
int cmd_logout(struct client *client)
{
client_send_line(client, "* BYE Logging out");
if (client->mailbox != NULL) {
/* this could be done at client_disconnect() as well,
but eg. mbox rewrite takes a while so the waiting is
better to happen before "OK" message. */
mailbox_close(client->mailbox);
client->mailbox = NULL;
}
client_send_tagline(client, "OK Logout completed.");
client_disconnect(client);
return TRUE;
}
| /* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "commands.h"
int cmd_logout(struct client *client)
{
client_send_line(client, "* BYE Logging out");
o_stream_uncork(client->output);
if (client->mailbox != NULL) {
/* this could be done at client_disconnect() as well,
but eg. mbox rewrite takes a while so the waiting is
better to happen before "OK" message. */
mailbox_close(client->mailbox);
client->mailbox = NULL;
}
client_send_tagline(client, "OK Logout completed.");
client_disconnect(client);
return TRUE;
}
|
Reduce the cost of getting the thread pointer by one jump on x86-64 | /*
* Copyright (c) 2012 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <errno.h>
#include "native_client/src/untrusted/irt/irt.h"
#include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
static int nacl_irt_tls_init(void *thread_ptr) {
return -NACL_SYSCALL(tls_init)(thread_ptr);
}
static void *nacl_irt_tls_get(void) {
return NACL_SYSCALL(tls_get)();
}
const struct nacl_irt_tls nacl_irt_tls = {
nacl_irt_tls_init,
nacl_irt_tls_get,
};
| /*
* Copyright (c) 2012 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <errno.h>
#include "native_client/src/untrusted/irt/irt.h"
#include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
static int nacl_irt_tls_init(void *thread_ptr) {
return -NACL_SYSCALL(tls_init)(thread_ptr);
}
const struct nacl_irt_tls nacl_irt_tls = {
nacl_irt_tls_init,
NACL_SYSCALL(tls_get),
};
|
Allow user to override default Xorg server binary | #ifndef XORGGTEST_DEFINES
#define XORGGTEST_DEFINES
#define DEFAULT_XORG_LOGFILE "/tmp/Xorg.GTest.log"
#define DEFAULT_XORG_SERVER "Xorg"
#define DEFAULT_DISPLAY 133
#endif
| #ifndef XORGGTEST_DEFINES
#define XORGGTEST_DEFINES
#define DEFAULT_XORG_LOGFILE "/tmp/Xorg.GTest.log"
#define DEFAULT_DISPLAY 133
/* Allow user to override default Xorg server*/
#ifndef DEFAULT_XORG_SERVER
#define DEFAULT_XORG_SERVER "Xorg"
#endif
#endif
|
Use int, not ParseErrorType, to allow -1 | // Copyright 2016 Mitchell Kember. Subject to the MIT License.
#ifndef PARSE_H
#define PARSE_H
#include "error.h"
#include "expr.h"
// ParseResult contains the result of parsing text. The 'expr' field has a
// meaningful value if and only if 'err_type' is -1.
struct ParseResult {
size_t chars_read;
struct Expression expr;
enum ParseErrorType err_type;
};
// Parses a string as an s-expression of pairs, symbols, and numbers. On
// success, returns the parse result with 'err_type' set to -1. Otherwise,
// returns the error type in the parse result.
struct ParseResult parse(const char *text);
#endif
| // Copyright 2016 Mitchell Kember. Subject to the MIT License.
#ifndef PARSE_H
#define PARSE_H
#include "error.h"
#include "expr.h"
// ParseResult contains the result of parsing text. The 'expr' field has a
// meaningful value if and only if 'err_type' is -1.
struct ParseResult {
size_t chars_read; // number of characters read
struct Expression expr; // parsed expression
int err_type; // -1 or a ParseErrorType value
};
// Parses a string as an s-expression of pairs, symbols, and numbers. On
// success, returns the parse result with 'err_type' set to -1. Otherwise,
// returns a ParseErrorType in the result.
struct ParseResult parse(const char *text);
#endif
|
Make including malloc on MacOS compatible | #pragma once
#include <fstream>
#include <string>
#include <cerrno>
#include <clocale>
#include <vector>
#include <iostream>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cairo.h>
#include <gtkmm.h>
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include "../litehtml/include/litehtml.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include <fontconfig/fontconfig.h>
#include <cairo-ft.h>
#include <gdk/gdk.h>
#include <cairomm/context.h>
#include <curl/curl.h>
#include <Poco/URI.h>
extern std::string urljoin(const std::string &base, const std::string &relative);
| #pragma once
#include <fstream>
#include <string>
#include <cerrno>
#include <clocale>
#include <vector>
#include <iostream>
#include <stdlib.h>
#ifdef __APPLE__
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <memory.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cairo.h>
#include <gtkmm.h>
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include "../litehtml/include/litehtml.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include <fontconfig/fontconfig.h>
#include <cairo-ft.h>
#include <gdk/gdk.h>
#include <cairomm/context.h>
#include <curl/curl.h>
#include <Poco/URI.h>
extern std::string urljoin(const std::string &base, const std::string &relative);
|
Fix possible invalid write on Windows-specific `strtok_r` stub | /*
* public domain strtok_r() by Charlie Gordon
*
* from comp.lang.c 9/14/2007
*
* http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
*
* (Declaration that it's public domain):
* http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
*/
#include <string.h>
#ifdef __MINGW32__
# ifndef strtok_r
char* strtok_r(char *str, const char *delim, char **nextp)
{
char *ret;
if (str == NULL)
str = *nextp;
str += strspn(str, delim);
if (*str == '\0')
return NULL;
ret = str;
str += strcspn(str, delim);
if (*str)
*str++ = '\0';
*nextp = str;
return ret;
}
# endif /* !strtok_r */
#endif /* __MINGW32__ */
| /*
* public domain strtok_r() by Charlie Gordon
*
* from comp.lang.c 9/14/2007
*
* http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
*
* (Declaration that it's public domain):
* http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
*/
#include <string.h>
#ifdef __MINGW32__
# ifndef strtok_r
char* strtok_r(char *str, const char *delim, char **nextp)
{
char *ret;
if (str == NULL)
str = *nextp;
str += strspn(str, delim);
if (*str == '\0')
{
*nextp = str;
return NULL;
}
ret = str;
str += strcspn(str, delim);
if (*str)
*str++ = '\0';
*nextp = str;
return ret;
}
# endif /* !strtok_r */
#endif /* __MINGW32__ */
|
Add the blank line at the end of file to pass ICC compiler. | /** @file
Page fault handler that does nothing.
Copyright (c) 2010, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
/**
The dummy handler that does nothing.
The function is only used by systems that don't use paging but need
build pass.
**/
VOID
PageFaultHandlerHook (
VOID
)
{
} | /** @file
Page fault handler that does nothing.
Copyright (c) 2010, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
/**
The dummy handler that does nothing.
The function is only used by systems that don't use paging but need
build pass.
**/
VOID
PageFaultHandlerHook (
VOID
)
{
}
|
Remove annoying debug log message | #include <arch/x64/interrupts.h>
#include <arch/x64/pic.h>
#include <arch/x64/port.h>
#include <truth/interrupts.h>
#include <truth/log.h>
#include <truth/scheduler.h>
#define Timer_IRQ_Number 0x20
#define Timer_Magic_Number 1193180
#define Timer_Chan_0 0x40
#define Timer_Chan_1 0x41
#define Timer_Chan_2 0x42
#define Timer_Command_Reg 0x43
#define RW_Oneshot_Square 0x36
static void timer_interrupt_handler(struct interrupt_cpu_state *unused(r)) {
log(Log_Error, "tick");
scheduler_yield();
}
void timer_init(void) {
interrupt_register_handler(Timer_IRQ_Number, timer_interrupt_handler);
}
void timer_set_phase(uint8_t hertz) {
uint8_t divisor = Timer_Magic_Number / hertz;
write_port(Timer_Command_Reg, RW_Oneshot_Square);
write_port(Timer_Chan_0, divisor & 0xff);
write_port(Timer_Chan_0, divisor >> 8);
pic_enable(Timer_IRQ_Number);
}
void timer_fini(void) {
interrupt_unregister_handler(Timer_IRQ_Number, timer_interrupt_handler);
}
| #include <arch/x64/interrupts.h>
#include <arch/x64/pic.h>
#include <arch/x64/port.h>
#include <truth/interrupts.h>
#include <truth/log.h>
#include <truth/scheduler.h>
#define Timer_IRQ_Number 0x20
#define Timer_Magic_Number 1193180
#define Timer_Chan_0 0x40
#define Timer_Chan_1 0x41
#define Timer_Chan_2 0x42
#define Timer_Command_Reg 0x43
#define RW_Oneshot_Square 0x36
static void timer_interrupt_handler(struct interrupt_cpu_state *unused(r)) {
scheduler_yield();
}
void timer_init(void) {
interrupt_register_handler(Timer_IRQ_Number, timer_interrupt_handler);
}
void timer_set_phase(uint8_t hertz) {
uint8_t divisor = Timer_Magic_Number / hertz;
write_port(Timer_Command_Reg, RW_Oneshot_Square);
write_port(Timer_Chan_0, divisor & 0xff);
write_port(Timer_Chan_0, divisor >> 8);
pic_enable(Timer_IRQ_Number);
}
void timer_fini(void) {
interrupt_unregister_handler(Timer_IRQ_Number, timer_interrupt_handler);
}
|
Modify session id and first test of logger | #include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
FILE* logfile;
void init() {
// Change the umask so we can write to log files
umask(0);
// We should initialize and open log files here
logfile = fopen("./creddit.log", "a");
if (logfile == NULL) {
printf("Failed to create file with error: %d\n", errno);
exit(errno);
}
}
void run() {
}
int main() {
pid_t pid = fork();
// Check to see if there was an error with the fork
if (pid < 0) exit(1);
// If we are the child, then we do the heavy lifting
if (pid == 0) {
init();
run();
}
// Elsewise, we are the parent and we want to exit gracefully
exit(0);
}
| #include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
FILE* logfile;
void init() {
// Change the umask so we can write to log files
umask(0);
// We should initialize and open log files here
logfile = fopen("./creddit.log", "a");
if (logfile == NULL) {
printf("Failed to create file with error: %d\n", errno);
exit(errno);
}
// Now we need to get a new unique SID so we aren't an orphan
// Remember our parent has died.
if (setsid() < 0) {
fprintf(logfile, "Could not set our SID: %d\n", errno);
exit(errno);
}
}
void run() {
}
int main() {
pid_t pid = fork();
// Check to see if there was an error with the fork
if (pid < 0) exit(1);
// If we are the child, then we do the heavy lifting
if (pid == 0) {
init();
run();
}
// Elsewise, we are the parent and we want to exit gracefully
exit(0);
}
|
Fix english language for new line length | #include "num2words.h"
const Language LANG_ENGLISH = {
.hours = {
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve"
},
.phrases = {
"*$1 o'clock ",
"five past *$1 ",
"ten past *$1 ",
"quarter past *$1 ",
"twenty past *$1 ",
"twenty five past *$1 ",
"half past *$1 ",
"twenty five to *$2 ",
"twenty to *$2 ",
"quarter to *$2 ",
"ten to *$2 ",
"five to *$2 "
},
#ifdef PBL_PLATFORM_CHALK
.greetings = {
"Good morning ",
"Good day ",
"Good evening ",
"Good night "
},
#else
.greetings = {
"Good mor- ning ",
"Good day ",
"Good even- ing ",
"Good night "
},
#endif
.connection_lost = "Where is your phone? "
};
| #include "num2words.h"
const Language LANG_ENGLISH = {
.hours = {
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve"
},
#ifdef PBL_PLATFORM_CHALK
.phrases = {
"*$1 o'clock ",
"five past *$1 ",
"ten past *$1 ",
"quarter past *$1 ",
"twenty past *$1 ",
"twenty five past *$1 ",
"half past *$1 ",
"twenty five to *$2 ",
"twenty to *$2 ",
"quarter to *$2 ",
"ten to *$2 ",
"five to *$2 "
},
.greetings = {
"Good morning ",
"Good day ",
"Good evening ",
"Good night "
},
#else
.phrases = {
"*$1 o'clock ",
"five past *$1 ",
"ten past *$1 ",
"quarter past *$1 ",
"twenty past *$1 ",
"twenty five past *$1 ",
"half past *$1 ",
"twenty five to *$2 ",
"twenty to *$2 ",
"quarter to *$2 ",
"ten to *$2 ",
"five to *$2 "
},
.greetings = {
"Good mor- ning ",
"Good day ",
"Good even- ing ",
"Good night "
},
#endif
.connection_lost = "Where is your phone? "
};
|
Use __VA_ARGS__ for better portability | /* $Id$ */
#ifndef __log_h__
#define __log_h__
#include "internal.h"
#define UNSHIELD_LOG_LEVEL_LOWEST 0
#define UNSHIELD_LOG_LEVEL_ERROR 1
#define UNSHIELD_LOG_LEVEL_WARNING 2
#define UNSHIELD_LOG_LEVEL_TRACE 3
#define UNSHIELD_LOG_LEVEL_HIGHEST 4
#ifdef __cplusplus
extern "C"
{
#endif
void _unshield_log(int level, const char* file, int line, const char* format, ...);
#define unshield_trace(format, args...) \
_unshield_log(UNSHIELD_LOG_LEVEL_TRACE,__FUNCTION__, __LINE__, format, ##args)
#define unshield_warning(format, args...) \
_unshield_log(UNSHIELD_LOG_LEVEL_WARNING,__FUNCTION__, __LINE__, format, ##args)
#define unshield_warning_unless(cond, format, args...) \
if (!(cond)) \
_unshield_log(UNSHIELD_LOG_LEVEL_WARNING,__FUNCTION__, __LINE__, format, ##args)
#define unshield_error(format, args...) \
_unshield_log(UNSHIELD_LOG_LEVEL_ERROR,__FUNCTION__, __LINE__, format, ##args)
#ifdef __cplusplus
}
#endif
#endif
| /* $Id$ */
#ifndef __log_h__
#define __log_h__
#include "internal.h"
#define UNSHIELD_LOG_LEVEL_LOWEST 0
#define UNSHIELD_LOG_LEVEL_ERROR 1
#define UNSHIELD_LOG_LEVEL_WARNING 2
#define UNSHIELD_LOG_LEVEL_TRACE 3
#define UNSHIELD_LOG_LEVEL_HIGHEST 4
#ifdef __cplusplus
extern "C"
{
#endif
void _unshield_log(int level, const char* file, int line, const char* format, ...);
#define unshield_trace(format, ...) \
_unshield_log(UNSHIELD_LOG_LEVEL_TRACE,__FUNCTION__, __LINE__, format, ##__VA_ARGS__)
#define unshield_warning(format, ...) \
_unshield_log(UNSHIELD_LOG_LEVEL_WARNING,__FUNCTION__, __LINE__, format, ##__VA_ARGS__)
#define unshield_error(format, ...) \
_unshield_log(UNSHIELD_LOG_LEVEL_ERROR,__FUNCTION__, __LINE__, format, ##__VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif
|
Add line length example from chapter 1-9 | //
// Created by matti on 14.9.2015.
//
#include <stdio.h>
#define MAXLINE 1000
int getnewline(char line[], int maxline);
void copy(char to[], char from[]);
main() {
int len;
int max;
char line[MAXLINE];
char longest[MAXLINE];
max = 0;
while ((len = getnewline(line, MAXLINE)) > 0) {
if (len > max) {
max = len;
copy(longest, line);
}
}
if (max > 0) {
printf("%s", longest);
}
return 0;
}
int getnewline(char s[], int lim) {
int c, i;
for (i=0; i < lim-1 && (c=getchar()) != EOF && c != '\n'; ++i) {
s[i] = c;
}
if (c == '\n') {
s[i] = c;
++i;
}
s[i] = '\0';
return i;
}
void copy(char to[], char from[]) {
int i;
i = 0;
while((to[i] = from[i]) != '\0'){
++i;
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.