Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Replace <MacHeaders> by specific required header files | #include <MacHeaders>
#include <string.h>
/* Interface used by tokenizer.c */
guesstabsize(path)
char *path;
{
char s[256];
int refnum;
Handle h;
int tabsize = 0;
s[0] = strlen(path);
strncpy(s+1, path, s[0]);
refnum = OpenResFile(s);
/* printf("%s --> refnum=%d\n", path, refnum); */
if (refnum == -1)
return 0;
UseResFile(refnum);
h = GetIndResource('ETAB', 1);
if (h != 0) {
tabsize = (*(short**)h)[1];
/* printf("tabsize=%d\n", tabsize); */
}
CloseResFile(refnum);
return tabsize;
}
| #include <Types.h>
#include <Files.h>
#include <OSUtils.h>
#include <Resources.h>
#include <string.h>
/* Interface used by tokenizer.c */
guesstabsize(path)
char *path;
{
char s[256];
int refnum;
Handle h;
int tabsize = 0;
s[0] = strlen(path);
strncpy(s+1, path, s[0]);
refnum = OpenResFile(s);
/* printf("%s --> refnum=%d\n", path, refnum); */
if (refnum == -1)
return 0;
UseResFile(refnum);
h = GetIndResource('ETAB', 1);
if (h != 0) {
tabsize = (*(short**)h)[1];
/* printf("tabsize=%d\n", tabsize); */
}
CloseResFile(refnum);
return tabsize;
}
|
Use fprintf() to ensure message printing | /* There is no include guard here - by purpose. This file can be included
* after system includes that redefine the assert() macro.
* The actual problem for which this file got separated from utilities.h
* happens in the sat-solver code, when local include files include
* Solver.h which in turn includes the system's assert.h. */
#include "error.h" /* for prt_error() */
#ifndef STRINGIFY
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#endif /* STRINGIFY */
#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)
#ifdef _WIN32
#define DEBUG_TRAP (*((volatile int*) 0x0) = 42)
#else
#define DEBUG_TRAP __builtin_trap()
#endif
#define assert(ex, ...) { \
if (!(ex)) { \
prt_error("Fatal error: \nAssertion (" #ex ") failed at " FILELINE ": " __VA_ARGS__); \
prt_error("\n"); \
DEBUG_TRAP; /* leave stack trace in debugger */ \
} \
}
| /* There is no include guard here - by purpose. This file can be included
* after system includes that redefine the assert() macro.
* The actual problem for which this file got separated from utilities.h
* happens in the sat-solver code, when local include files include
* Solver.h which in turn includes the system's assert.h. */
#include "error.h" /* for prt_error() */
#ifndef STRINGIFY
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#endif /* STRINGIFY */
#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)
#ifdef _WIN32
#define DEBUG_TRAP (*((volatile int*) 0x0) = 42)
#else
#define DEBUG_TRAP __builtin_trap()
#endif
#define assert(ex, ...) { \
if (!(ex)) { \
fprintf(stderr, "Fatal error: \nAssertion (" #ex ") failed at " FILELINE ": " __VA_ARGS__); \
fprintf(stderr, "\n"); \
DEBUG_TRAP; /* leave stack trace in debugger */ \
} \
}
|
Fix copy/paste error in header guard | /*=========================================================================
Program: Visomics
Copyright (c) Kitware, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#ifndef __voMongoSaveDialog_h
#define __voMongoSaveDialog_h
// Qt includes
#include <QDialog>
class voRemoteAnalysisConnectionDialogPrivate;
class voRemoteAnalysisConnectionDialog : public QDialog
{
Q_OBJECT
public:
typedef QDialog Superclass;
voRemoteAnalysisConnectionDialog(QWidget* newParent = 0);
virtual ~voRemoteAnalysisConnectionDialog();
QString Url();
QString User();
QString Password();
private:
QScopedPointer<voRemoteAnalysisConnectionDialogPrivate> d_ptr;
Q_DECLARE_PRIVATE(voRemoteAnalysisConnectionDialog);
Q_DISABLE_COPY(voRemoteAnalysisConnectionDialog);
void loadSettings();
private slots:
void saveSettings();
};
#endif
| /*=========================================================================
Program: Visomics
Copyright (c) Kitware, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#ifndef __voRemoteAnalysisConnectionDialog_h
#define __voRemoteAnalysisConnectionDialog_h
// Qt includes
#include <QDialog>
class voRemoteAnalysisConnectionDialogPrivate;
class voRemoteAnalysisConnectionDialog : public QDialog
{
Q_OBJECT
public:
typedef QDialog Superclass;
voRemoteAnalysisConnectionDialog(QWidget* newParent = 0);
virtual ~voRemoteAnalysisConnectionDialog();
QString Url();
QString User();
QString Password();
private:
QScopedPointer<voRemoteAnalysisConnectionDialogPrivate> d_ptr;
Q_DECLARE_PRIVATE(voRemoteAnalysisConnectionDialog);
Q_DISABLE_COPY(voRemoteAnalysisConnectionDialog);
void loadSettings();
private slots:
void saveSettings();
};
#endif
|
Mark OS X only implementations in BrowserMainParts. | // Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#include "brightray/browser/browser_main_parts.h"
namespace atom {
class AtomBrowserBindings;
class Browser;
class NodeBindings;
class AtomBrowserMainParts : public brightray::BrowserMainParts {
public:
AtomBrowserMainParts();
virtual ~AtomBrowserMainParts();
static AtomBrowserMainParts* Get();
AtomBrowserBindings* atom_bindings() { return atom_bindings_.get(); }
Browser* browser() { return browser_.get(); }
protected:
// Implementations of brightray::BrowserMainParts.
virtual brightray::BrowserContext* CreateBrowserContext() OVERRIDE;
// Implementations of content::BrowserMainParts.
virtual void PostEarlyInitialization() OVERRIDE;
virtual void PreMainMessageLoopStart() OVERRIDE;
virtual void PreMainMessageLoopRun() OVERRIDE;
virtual void PostDestroyThreads() OVERRIDE;
private:
scoped_ptr<AtomBrowserBindings> atom_bindings_;
scoped_ptr<Browser> browser_;
scoped_ptr<NodeBindings> node_bindings_;
static AtomBrowserMainParts* self_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);
};
} // namespace atom
#endif // ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
| // Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#include "brightray/browser/browser_main_parts.h"
namespace atom {
class AtomBrowserBindings;
class Browser;
class NodeBindings;
class AtomBrowserMainParts : public brightray::BrowserMainParts {
public:
AtomBrowserMainParts();
virtual ~AtomBrowserMainParts();
static AtomBrowserMainParts* Get();
AtomBrowserBindings* atom_bindings() { return atom_bindings_.get(); }
Browser* browser() { return browser_.get(); }
protected:
// Implementations of brightray::BrowserMainParts.
virtual brightray::BrowserContext* CreateBrowserContext() OVERRIDE;
// Implementations of content::BrowserMainParts.
virtual void PostEarlyInitialization() OVERRIDE;
virtual void PreMainMessageLoopRun() OVERRIDE;
#if defined(OS_MACOSX)
virtual void PreMainMessageLoopStart() OVERRIDE;
virtual void PostDestroyThreads() OVERRIDE;
#endif
private:
scoped_ptr<AtomBrowserBindings> atom_bindings_;
scoped_ptr<Browser> browser_;
scoped_ptr<NodeBindings> node_bindings_;
static AtomBrowserMainParts* self_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);
};
} // namespace atom
#endif // ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
|
Update MiniGraph to work with FlowGraphWidet. | #pragma once
#include <QtGui/QMouseEvent>
#include <QtGui/QPaintEvent>
#include <QtWidgets/QWidget>
#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "uitypes.h"
class ContextMenuManager;
class DisassemblyView;
class Menu;
class ViewFrame;
class BINARYNINJAUIAPI MiniGraph: public QWidget, public DockContextHandler
{
Q_OBJECT
DisassemblyView* m_disassemblyView = nullptr;
public:
MiniGraph(QWidget* parent);
~MiniGraph();
virtual void notifyViewChanged(ViewFrame* frame) override;
virtual bool shouldBeVisible(ViewFrame* frame) override;
protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void scrollTo(int x, int y);
public Q_SLOTS:
void notifyUpdate();
};
| #pragma once
#include <QtGui/QMouseEvent>
#include <QtGui/QPaintEvent>
#include <QtWidgets/QWidget>
#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "uitypes.h"
class ContextMenuManager;
class FlowGraphWidget;
class Menu;
class ViewFrame;
class BINARYNINJAUIAPI MiniGraph: public QWidget, public DockContextHandler
{
Q_OBJECT
FlowGraphWidget* m_flowGraphWidget = nullptr;
public:
MiniGraph(QWidget* parent);
~MiniGraph();
virtual void notifyViewChanged(ViewFrame* frame) override;
virtual bool shouldBeVisible(ViewFrame* frame) override;
protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void scrollTo(int x, int y);
public Q_SLOTS:
void notifyUpdate();
};
|
Disable scanf interceptor on windows. | //===-- sanitizer_platform_interceptors.h -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines macro telling whether sanitizer tools can/should intercept
// given library functions on a given platform.
//
//===----------------------------------------------------------------------===//
#include "sanitizer_internal_defs.h"
#if !defined(_WIN32)
# define SI_NOT_WINDOWS 1
#else
# define SI_NOT_WINDOWS 0
#endif
#if defined(__linux__) && !defined(ANDROID)
# define SI_LINUX_NOT_ANDROID 1
#else
# define SI_LINUX_NOT_ANDROID 0
#endif
# define SANITIZER_INTERCEPT_READ SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PREAD SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_WRITE SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PWRITE SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PREAD64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PWRITE64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PRCTL SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_SCANF 1
| //===-- sanitizer_platform_interceptors.h -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines macro telling whether sanitizer tools can/should intercept
// given library functions on a given platform.
//
//===----------------------------------------------------------------------===//
#include "sanitizer_internal_defs.h"
#if !defined(_WIN32)
# define SI_NOT_WINDOWS 1
#else
# define SI_NOT_WINDOWS 0
#endif
#if defined(__linux__) && !defined(ANDROID)
# define SI_LINUX_NOT_ANDROID 1
#else
# define SI_LINUX_NOT_ANDROID 0
#endif
# define SANITIZER_INTERCEPT_READ SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PREAD SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_WRITE SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PWRITE SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PREAD64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PWRITE64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PRCTL SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_SCANF SI_NOT_WINDOWS
|
Include nearby object protocol file | //
// NearbyObjectProtocol.h
// ARIS
//
// Created by Brian Deith on 5/15/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
enum {
NearbyObjectNPC = 1,
NearbyObjectItem = 2,
NearbyObjectNode = 3
};
typedef UInt32 nearbyObjectKind;
@protocol NearbyObjectProtocol
- (NSString *)name;
- (nearbyObjectKind)kind;
- (BOOL)forcedDisplay;
- (void)display;
@end
| |
Reorganize and reduce visibility for raw XML access methods | #pragma once
#include <unordered_map>
#include <string>
#include "TinyXml2\tinyxml2.h"
class Skin;
#define SETTINGS_APP L"SettingsUI.exe"
class Settings {
public:
static Settings *Instance();
static std::wstring AppDir();
static std::wstring SettingsApp();
std::wstring LanguagesDir();
std::wstring LanguageName();
Skin *CurrentSkin();
std::wstring SkinName();
std::wstring SkinXML();
std::wstring SkinXML(std::wstring skinName);
bool HasSetting(std::string elementName);
bool IsEnabled(std::string elementName);
std::wstring GetText(std::string elementName);
int GetInt(std::string elementName);
bool NotifyIconEnabled();
bool SoundEffectsEnabled();
std::unordered_map<int, int> Hotkeys();
void Reload();
private:
static Settings *instance;
static std::wstring _appDir;
std::wstring _file;
tinyxml2::XMLDocument _xml;
tinyxml2::XMLElement *_root;
Skin *_skin;
Settings();
}; | #pragma once
#include <unordered_map>
#include <string>
#include "TinyXml2\tinyxml2.h"
class Skin;
#define SETTINGS_APP L"SettingsUI.exe"
class Settings {
public:
static Settings *Instance();
void Reload();
static std::wstring AppDir();
static std::wstring SettingsApp();
std::wstring LanguagesDir();
std::wstring LanguageName();
Skin *CurrentSkin();
std::wstring SkinName();
std::wstring SkinXML();
std::wstring SkinXML(std::wstring skinName);
bool NotifyIconEnabled();
bool SoundEffectsEnabled();
std::unordered_map<int, int> Hotkeys();
private:
Settings();
static Settings *instance;
static std::wstring _appDir;
std::wstring _file;
tinyxml2::XMLDocument _xml;
tinyxml2::XMLElement *_root;
Skin *_skin;
bool HasSetting(std::string elementName);
bool IsEnabled(std::string elementName);
std::wstring GetText(std::string elementName);
int GetInt(std::string elementName);
}; |
Add script to test install | #include <cblas.h>
#include <stdio.h>
void main()
{
double A[ 6 ] = { 1.0, 2.0, 1.0, -3.0, 4.0, -1.0 };
double B[ 6 ] = { 1.0, 2.0, 1.0, -3.0, 4.0, -1.0 };
double C[ 9 ] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
int i = 0;
cblas_dgemm( CblasColMajor, CblasNoTrans, CblasTrans, 3, 3, 2, 1, A, 3, B, 3, 2, C, 3 );
for( i = 0; i < 9; i++ ) {
printf( "%lf ", C[ i ] );
}
printf( "\n" );
}
| |
Add regression test where unprotected read must forget relation | // PARAM: --sets ana.activated[+] octApron
#include <pthread.h>
#include <assert.h>
int g = 1;
void *t_fun(void *arg) {
g = 2; // write something non-initial so base wouldn't find success
return NULL;
}
int main(void) {
int x, y;
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
x = g;
y = g;
// unlock(m_g)-s must forget relation with unprotected
assert(x == y); // UNKNOWN!
return 0;
}
| |
Move more stuff to eigen helper header | #ifndef EIGEN_HELPER_H
#define EIGEN_HELPER_H
#include <Eigen/Dense>
template<typename Derived>
inline bool isFucked(const Eigen::MatrixBase<Derived>& x)
{
return !((x.array() == x.array())).all() && !( (x - x).array() == (x - x).array()).all();
}
#endif
| #ifndef EIGEN_HELPER_H
#define EIGEN_HELPER_H
#include "ros/ros.h"
#include <Eigen/Dense>
template<typename Derived>
inline bool isFucked(const Eigen::MatrixBase<Derived>& x)
{
return !((x.array() == x.array())).all() && !( (x - x).array() == (x - x).array()).all();
}
inline Eigen::MatrixXd getMatrixParam(ros::NodeHandle nh, std::string name)
{
XmlRpc::XmlRpcValue matrix;
nh.getParam(name, matrix);
try
{
const int rows = matrix.size();
const int cols = matrix[0].size();
Eigen::MatrixXd X(rows,cols);
for (int i = 0; i < rows; ++i)
for (int j = 0; j < cols; ++j)
X(i,j) = matrix[i][j];
return X;
}
catch(...)
{
ROS_ERROR("Error in getMatrixParam. Returning 1-by-1 zero matrix.");
return Eigen::MatrixXd::Zero(1,1);
}
}
inline void printEigen(std::string name, const Eigen::MatrixXd &x)
{
std::stringstream ss;
ss << name << " = " << std::endl << x;
ROS_INFO_STREAM(ss.str());
}
inline Eigen::MatrixXd pinv(const Eigen::MatrixXd &X)
{
Eigen::MatrixXd X_pinv = X.transpose() * ( X*X.transpose() ).inverse();
if (isFucked(X_pinv))
{
ROS_WARN("Could not compute pseudoinverse. Returning transpose.");
return X.transpose();
}
return X_pinv;
}
#endif
|
Add more simple taint tests. | // RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,experimental.security.ArrayBoundV2 -verify %s
int scanf(const char *restrict format, ...);
int getchar(void);
#define BUFSIZE 10
int Buffer[BUFSIZE];
void bufferFoo1(void)
{
int n;
scanf("%d", &n);
Buffer[n] = 1; // expected-warning {{Out of bound memory access }}
}
void bufferScanfArithmetic1(int x) {
int n;
scanf("%d", &n);
int m = (n - 3);
Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}
void bufferScanfArithmetic2(int x) {
int n;
scanf("%d", &n);
int m = (n + 3) * x;
Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}
void scanfArg() {
int t;
scanf("%d", t); // expected-warning {{Pointer argument is expected}}
}
| // RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,experimental.security.ArrayBoundV2 -verify %s
int scanf(const char *restrict format, ...);
int getchar(void);
#define BUFSIZE 10
int Buffer[BUFSIZE];
void bufferScanfDirect(void)
{
int n;
scanf("%d", &n);
Buffer[n] = 1; // expected-warning {{Out of bound memory access }}
}
void bufferScanfArithmetic1(int x) {
int n;
scanf("%d", &n);
int m = (n - 3);
Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}
void bufferScanfArithmetic2(int x) {
int n;
scanf("%d", &n);
int m = 100 / (n + 3) * x;
Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}
void bufferScanfAssignment(int x) {
int n;
scanf("%d", &n);
int m;
if (x > 0) {
m = n;
Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}
}
void scanfArg() {
int t;
scanf("%d", t); // expected-warning {{Pointer argument is expected}}
}
void bufferGetchar(int x) {
int m = getchar();
Buffer[m] = 1; //expected-warning {{Out of bound memory access }}
}
|
Define target value types in a form usable by target-independent code | //===- CodeGen/ValueTypes.h - Low-Level Target independ. types --*- C++ -*-===//
//
// This file defines the set of low-level target independent types which various
// values in the code generator are. This allows the target specific behavior
// of instructions to be described to target independent passes.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_VALUETYPES_H
#define LLVM_CODEGEN_VALUETYPES_H
/// MVT namespace - This namespace defines the ValueType enum, which contains
/// the various low-level value types.
///
namespace MVT { // MRF = Machine Register Flags
enum ValueType {
Other = 0 << 0, // This is a non-standard value
i1 = 1 << 0, // This is a 1 bit integer value
i8 = 1 << 1, // This is an 8 bit integer value
i16 = 1 << 2, // This is a 16 bit integer value
i32 = 1 << 3, // This is a 32 bit integer value
i64 = 1 << 4, // This is a 64 bit integer value
i128 = 1 << 5, // This is a 128 bit integer value
f32 = 1 << 6, // This is a 32 bit floating point value
f64 = 1 << 7, // This is a 64 bit floating point value
f80 = 1 << 8, // This is a 80 bit floating point value
f128 = 1 << 9, // This is a 128 bit floating point value
};
};
#endif
| |
Add CompilerBarrier() and MemoryBarrier() functions. | // Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved.
// Please see the AUTHORS file for details. Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.
#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_
#define UNLIKELY(x) __builtin_expect((x), 0)
#define LIKELY(x) __builtin_expect((x), 1)
#define cache_aligned __attribute__((aligned(64)))
#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))
const size_t kSystemPageSize = 4096;
always_inline size_t PadSize(size_t size, size_t multiple) {
return (size + multiple - 1) / multiple * multiple;
}
#endif // SCALLOC_COMMON_H_
| // Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved.
// Please see the AUTHORS file for details. Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.
#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_
#define UNLIKELY(x) __builtin_expect((x), 0)
#define LIKELY(x) __builtin_expect((x), 1)
#define cache_aligned __attribute__((aligned(64)))
#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))
const size_t kSystemPageSize = 4096;
// Prohibit reordering of instructions by the compiler.
inline void CompilerBarrier() {
__asm__ __volatile__("" : : : "memory");
}
// Full memory fence on x86-64
inline void MemoryBarrier() {
__asm__ __volatile__("mfence" : : : "memory");
}
always_inline size_t PadSize(size_t size, size_t multiple) {
return (size + multiple - 1) / multiple * multiple;
}
#endif // SCALLOC_COMMON_H_
|
Add empty string to exit words | #include "input.h"
#include <ctype.h>
#include <stdio.h>
#include <string.h>
void read_line(char *p)
{
if (fgets(p, MAX_SIZE, stdin) == NULL){
p[0] = '\0';
return;
}
remove_space(p);
}
int is_exit(const char* p)
{
const char* exit_words[] = {
"exit",
"quit",
"bye",
};
int len = (int)(sizeof(exit_words) / sizeof(char*));
int i;
if (strlen(p) == 0){
return (1);
}
for (i = 0; i < len; i++){
if (strcmp(p, exit_words[i]) == 0){
return (1);
}
}
return (0);
}
void remove_space(char* p)
{
int i, j;
i = j = 0;
while (p[i] != '\0'){
while (isspace(p[j])){
j++;
}
while (!isspace(p[j])){
p[i] = p[j];
if (p[i] == '\0'){
break;
}
else {
i++;
j++;
}
}
}
}
| #include "input.h"
#include <ctype.h>
#include <stdio.h>
#include <string.h>
void read_line(char *p)
{
if (fgets(p, MAX_SIZE, stdin) == NULL){
p[0] = '\0';
return;
}
remove_space(p);
}
int is_exit(const char* p)
{
const char* exit_words[] = {
"",
"exit",
"quit",
"bye",
};
int len = (int)(sizeof(exit_words) / sizeof(char*));
int i;
if (strlen(p) == 0){
return (1);
}
for (i = 0; i < len; i++){
if (strcmp(p, exit_words[i]) == 0){
return (1);
}
}
return (0);
}
void remove_space(char* p)
{
int i, j;
i = j = 0;
while (p[i] != '\0'){
while (isspace(p[j])){
j++;
}
while (!isspace(p[j])){
p[i] = p[j];
if (p[i] == '\0'){
break;
}
else {
i++;
j++;
}
}
}
}
|
Update files, Alura, Introdução a C - Parte 2, Aula 2.2 | #include <stdio.h>
int main() {
int notas[10];
notas[0] = 10;
notas[2] = 9;
notas[3] = 8;
notas[9] = 4;
printf("%d %d %d\n", notas[0], notas[2], notas[9]);
} | #include <stdio.h>
int main() {
char palavrasecreta[20];
sprintf(palavrasecreta, "MELANCIA");
printf("%s\n", palavrasecreta);
/*
palavrasecreta[0] = 'M';
palavrasecreta[1] = 'E';
palavrasecreta[2] = 'L';
palavrasecreta[3] = 'A';
palavrasecreta[4] = 'N';
palavrasecreta[5] = 'C';
palavrasecreta[6] = 'I';
palavrasecreta[7] = 'A';
printf("%c%c%c%c%c%c%c%c\n", palavrasecreta[0], palavrasecreta[1], palavrasecreta[2], palavrasecreta[3], palavrasecreta[4], palavrasecreta[5], palavrasecreta[6], palavrasecreta[7]);
*/
}
|
Add cgltf_parse_file and cgltf_load_buffers to test program |
#define CGLTF_IMPLEMENTATION
#include "../cgltf.h"
#include <stdio.h>
int main(int argc, char** argv)
{
if (argc < 2)
{
printf("err\n");
return -1;
}
FILE* f = fopen(argv[1], "rb");
if (!f)
{
return -2;
}
fseek(f, 0, SEEK_END);
long size = ftell(f);
fseek(f, 0, SEEK_SET);
void* buf = malloc(size);
fread(buf, size, 1, f);
fclose(f);
cgltf_options options = {0};
cgltf_data* data = NULL;
cgltf_result result = cgltf_parse(&options, buf, size, &data);
printf("Result: %d\n", result);
if (result == cgltf_result_success)
{
printf("Type: %u\n", data->file_type);
printf("Meshes: %lu\n", data->meshes_count);
}
free(buf);
cgltf_free(data);
return result;
}
|
#define CGLTF_IMPLEMENTATION
#include "../cgltf.h"
#include <stdio.h>
int main(int argc, char** argv)
{
if (argc < 2)
{
printf("err\n");
return -1;
}
cgltf_options options = {0};
cgltf_data* data = NULL;
cgltf_result result = cgltf_parse_file(&options, argv[1], &data);
if (result == cgltf_result_success)
result = cgltf_load_buffers(&options, data, argv[1]);
printf("Result: %d\n", result);
if (result == cgltf_result_success)
{
printf("Type: %u\n", data->file_type);
printf("Meshes: %lu\n", data->meshes_count);
}
cgltf_free(data);
return result;
}
|
Remove an unneeded header and forward declaration | //===-- PPC32TargetMachine.h - PowerPC/Darwin TargetMachine ---*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the PowerPC/Darwin specific subclass of TargetMachine.
//
//===----------------------------------------------------------------------===//
#ifndef POWERPC_DARWIN_TARGETMACHINE_H
#define POWERPC_DARWIN_TARGETMACHINE_H
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/PassManager.h"
#include "PowerPCTargetMachine.h"
#include <set>
namespace llvm {
class GlobalValue;
class IntrinsicLowering;
class PPC32TargetMachine : public PowerPCTargetMachine {
public:
PPC32TargetMachine(const Module &M, IntrinsicLowering *IL);
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
/// get machine code emitted. This uses a MachineCodeEmitter object to handle
/// actually outputting the machine code and resolving things like the address
/// of functions. This method should returns true if machine code emission is
/// not supported.
///
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);
static unsigned getModuleMatchQuality(const Module &M);
};
} // end namespace llvm
#endif
| //===-- PPC32TargetMachine.h - PowerPC/Darwin TargetMachine ---*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the PowerPC/Darwin specific subclass of TargetMachine.
//
//===----------------------------------------------------------------------===//
#ifndef POWERPC_DARWIN_TARGETMACHINE_H
#define POWERPC_DARWIN_TARGETMACHINE_H
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/PassManager.h"
#include "PowerPCTargetMachine.h"
namespace llvm {
class IntrinsicLowering;
class PPC32TargetMachine : public PowerPCTargetMachine {
public:
PPC32TargetMachine(const Module &M, IntrinsicLowering *IL);
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
/// get machine code emitted. This uses a MachineCodeEmitter object to handle
/// actually outputting the machine code and resolving things like the address
/// of functions. This method should returns true if machine code emission is
/// not supported.
///
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);
static unsigned getModuleMatchQuality(const Module &M);
};
} // end namespace llvm
#endif
|
Fix U32 and S32 on LP64 architectures. | /*
Mace - http://www.macehq.cx
Copyright 1999-2004
See the file README for more information
*/
#ifndef GLOBALS_H
#define GLOBALS_H
#ifndef _MaceTypes
#define _MaceTypes
typedef unsigned char U8;
typedef char S8;
typedef unsigned short U16;
typedef signed short S16;
//Note: on 64-bit machines, replace "long" with "int"
typedef unsigned long U32;
typedef signed long S32;
#endif
void App_Exit(void);
//Same as App_Exit2(), except that this calls setdis()
void App_Exit2(void);
U16 FlipW(U16 a);
U32 FlipL(U32 a);
void HexW (U16 n, char * String);
void HexL (U32 n, char * String);
#endif //GLOBALS_H
| /*
Mace - http://www.macehq.cx
Copyright 1999-2004
See the file README for more information
*/
#ifndef GLOBALS_H
#define GLOBALS_H
#ifndef _MaceTypes
#define _MaceTypes
typedef unsigned char U8;
typedef signed char S8;
typedef unsigned short U16;
typedef signed short S16;
//Note: on 64-bit machines, replace "long" with "int"
#if __LP64__
typedef unsigned int U32;
typedef signed int S32;
#else
typedef unsigned long U32;
typedef signed long S32;
#endif
#endif
void App_Exit(void);
//Same as App_Exit2(), except that this calls setdis()
void App_Exit2(void);
U16 FlipW(U16 a);
U32 FlipL(U32 a);
void HexW (U16 n, char * String);
void HexL (U32 n, char * String);
#endif //GLOBALS_H
|
Add test for signed wrap-around with ana.int.wrap_on_signed_overflow | //PARAM: --disable ana.int.interval --enable ana.int.wrap_on_signed_overflow
#include <assert.h>
int main(){
int a = 0;
// maximum value for long long
signed long long s = 9223372036854775807;
assert(s > 9223372036854775806);
signed long long t = s + 2;
// Signed overflow - The following assertion only works with ana.int.wrap_on_signed_overflow enabled
assert(t == -9223372036854775807);
return 0;
}
| |
Add workaround for broken builders | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef DISABLE_OPTIMIZE_H
#define DISABLE_OPTIMIZE_H 1
/* avoid wasting time trying to optimize those countless test functions */
#if defined(__clang__)
/*
* Works for Alk since clang-3.5.
* Unfortunately it looks like Apple have their own versioning scheme for
* clang, because mine (Trond) reports itself as 5.1 and does not have
* the pragma.
*/
#if ((__clang_major__ * 0x100 + __clang_minor) >= 0x305) && !defined(__APPLE__)
#pragma clang optimize off
#endif
#elif defined(__GNUC__)
/*
* gcc docs indicate that pragma optimize is supported since 4.4. Earlier
* versions will emit harmless warning.
*/
#if ((__GNUC__ * 0x100 + __GNUC_MINOR__) >= 0x0404)
#pragma GCC optimize ("O0")
#endif
#endif /* __GNUC__ */
#endif
| /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef DISABLE_OPTIMIZE_H
#define DISABLE_OPTIMIZE_H 1
/* According to MB-11846 we have some misconfigured vm's unable to
* compile the source code without enabling optimization. Add a workaround
* for those vm's until they're fixed
*/
#ifndef COUCHBASE_OPTIMIZE_BREAKDANCER_TEST
/* avoid wasting time trying to optimize those countless test functions */
#if defined(__clang__)
/*
* Works for Alk since clang-3.5.
* Unfortunately it looks like Apple have their own versioning scheme for
* clang, because mine (Trond) reports itself as 5.1 and does not have
* the pragma.
*/
#if ((__clang_major__ * 0x100 + __clang_minor) >= 0x305) && !defined(__APPLE__)
#pragma clang optimize off
#endif
#elif defined(__GNUC__)
/*
* gcc docs indicate that pragma optimize is supported since 4.4. Earlier
* versions will emit harmless warning.
*/
#if ((__GNUC__ * 0x100 + __GNUC_MINOR__) >= 0x0404)
#pragma GCC optimize ("O0")
#endif
#endif /* __GNUC__ */
#endif /* COUCHBASE_OPTIMIZE_BREAKDANCER_TEST */
#endif
|
Initialize DeviceFuncs::ifuncs_ to zero in constructor | // 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 PPAPI_CPP_MODULE_IMPL_H_
#define PPAPI_CPP_MODULE_IMPL_H_
#include "ppapi/cpp/module.h"
namespace {
template <typename T> class DeviceFuncs {
public:
explicit DeviceFuncs(const char* ifname) : ifname_(ifname) {}
operator T const*() {
if (!funcs_) {
funcs_ = reinterpret_cast<T const*>(
pp::Module::Get()->GetBrowserInterface(ifname_));
}
return funcs_;
}
// This version doesn't check for existence of the function object. It is
// used so that, for DeviceFuncs f, the expression:
// if (f) f->doSomething();
// checks the existence only once.
T const* operator->() const { return funcs_; }
private:
DeviceFuncs(const DeviceFuncs&other);
DeviceFuncs &operator=(const DeviceFuncs &other);
const char* ifname_;
T const* funcs_;
};
} // namespace
#endif // PPAPI_CPP_MODULE_IMPL_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 PPAPI_CPP_MODULE_IMPL_H_
#define PPAPI_CPP_MODULE_IMPL_H_
#include "ppapi/cpp/module.h"
namespace {
template <typename T> class DeviceFuncs {
public:
explicit DeviceFuncs(const char* ifname) : ifname_(ifname), funcs_(NULL) {}
operator T const*() {
if (!funcs_) {
funcs_ = reinterpret_cast<T const*>(
pp::Module::Get()->GetBrowserInterface(ifname_));
}
return funcs_;
}
// This version doesn't check for existence of the function object. It is
// used so that, for DeviceFuncs f, the expression:
// if (f) f->doSomething();
// checks the existence only once.
T const* operator->() const { return funcs_; }
private:
DeviceFuncs(const DeviceFuncs&other);
DeviceFuncs &operator=(const DeviceFuncs &other);
const char* ifname_;
T const* funcs_;
};
} // namespace
#endif // PPAPI_CPP_MODULE_IMPL_H_
|
Add xhtml-im and w3c xhtml namespace |
#define WOCKY_XMPP_NS_STREAM \
(const gchar *)"http://etherx.jabber.org/streams"
#define WOCKY_XMPP_NS_TLS \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-tls"
#define WOCKY_XMPP_NS_SASL_AUTH \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-sasl"
|
#define WOCKY_XMPP_NS_STREAM \
(const gchar *)"http://etherx.jabber.org/streams"
#define WOCKY_XMPP_NS_TLS \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-tls"
#define WOCKY_XMPP_NS_SASL_AUTH \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-sasl"
#define WOCKY_XMPP_NS_XHTML_IM \
(const gchar *)"http://jabber.org/protocol/xhtml-im"
#define WOCKY_W3C_NS_XHTML \
(const gchar *)"http://www.w3.org/1999/xhtml"
|
Update header comment to reflect the current state of the source. | //
// Copyright (c) 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
#import <GData/GData.h>
#import "GPSyncProtocol.h"
// Source for documents, spreadsheets, and presentations in Google Docs.
// Note: presentations currently won't have content data.
@interface GPDocsSync : NSObject <GPSyncSource> {
id<GPSyncManager> manager_; // weak reference
GDataServiceGoogleDocs* docService_;
GDataServiceGoogleSpreadsheet* spreadsheetService_;
NSMutableArray* docsToInflate_;
}
@end
| //
// Copyright (c) 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
#import <GData/GData.h>
#import "GPSyncProtocol.h"
// Source for documents, spreadsheets, presentations, and PDFs in Google Docs.
// Note: PDFs currently won't have content data.
@interface GPDocsSync : NSObject <GPSyncSource> {
id<GPSyncManager> manager_; // weak reference
GDataServiceGoogleDocs* docService_;
GDataServiceGoogleSpreadsheet* spreadsheetService_;
NSMutableArray* docsToInflate_;
}
@end
|
Copy constructor added to Login class | /**
* The login information to access a server
*
* This class combines login, password and vhost
*
* @copyright 2014 Copernica BV
*/
/**
* Set up namespace
*/
namespace AMQP {
/**
* Class definition
*/
class Login
{
private:
/**
* The username
* @var string
*/
std::string _user;
/**
* The password
* @var string
*/
std::string _password;
public:
/**
* Constructor
* @param user
* @param password
*/
Login(const std::string &user, const std::string &password) :
_user(user), _password(password) {}
/**
* Constructor
*/
Login() :
_user("guest"), _password("guest") {}
/**
* Destructor
*/
virtual ~Login() {}
/**
* String representation in SASL PLAIN mode
* @return string
*/
std::string saslPlain()
{
// we need an initial string
std::string result("\0", 1);
// append other elements
return result.append(_user).append("\0",1).append(_password);
}
};
/**
* End of namespace
*/
}
| /**
* The login information to access a server
*
* This class combines login, password and vhost
*
* @copyright 2014 Copernica BV
*/
/**
* Set up namespace
*/
namespace AMQP {
/**
* Class definition
*/
class Login
{
private:
/**
* The username
* @var string
*/
std::string _user;
/**
* The password
* @var string
*/
std::string _password;
public:
/**
* Constructor
* @param user
* @param password
*/
Login(const std::string &user, const std::string &password) :
_user(user), _password(password) {}
/**
* Copy constructor
* @param login
*/
Login(const Login &login) :
_user(login._user), _password(login._password) {}
/**
* Constructor
*/
Login() :
_user("guest"), _password("guest") {}
/**
* Destructor
*/
virtual ~Login() {}
/**
* String representation in SASL PLAIN mode
* @return string
*/
std::string saslPlain()
{
// we need an initial string
std::string result("\0", 1);
// append other elements
return result.append(_user).append("\0",1).append(_password);
}
};
/**
* End of namespace
*/
}
|
Remove special cxxmodules case now that gVersionCheck is on ROOT::. | // @(#)root/base:$Id$
// Author: Fons Rademakers 9/5/2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TVersionCheck
#define ROOT_TVersionCheck
//////////////////////////////////////////////////////////////////////////
// //
// TVersionCheck //
// //
// Used to check if the shared library or plugin is compatible with //
// the current version of ROOT. //
// //
//////////////////////////////////////////////////////////////////////////
#ifdef R__CXXMODULES
#ifndef ROOT_TObject
#error "Building with modules currently requires this file to be #included through TObject.h"
#endif
#endif // R__CXXMODULES
#include "RVersion.h"
class TVersionCheck {
public:
TVersionCheck(int versionCode); // implemented in TSystem.cxx
};
// FIXME: Due to a modules bug: https://llvm.org/bugs/show_bug.cgi?id=31056
// our .o files get polluted with the gVersionCheck symbol despite it was not
// visible in this TU.
#ifndef R__CXXMODULES
#ifndef __CINT__
namespace ROOT {
static TVersionCheck gVersionCheck(ROOT_VERSION_CODE);
}
#endif
#endif
#endif
| // @(#)root/base:$Id$
// Author: Fons Rademakers 9/5/2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TVersionCheck
#define ROOT_TVersionCheck
//////////////////////////////////////////////////////////////////////////
// //
// TVersionCheck //
// //
// Used to check if the shared library or plugin is compatible with //
// the current version of ROOT. //
// //
//////////////////////////////////////////////////////////////////////////
#include "RVersion.h"
class TVersionCheck {
public:
TVersionCheck(int versionCode); // implemented in TSystem.cxx
};
namespace ROOT {
static TVersionCheck gVersionCheck(ROOT_VERSION_CODE);
}
#endif
|
Support Pre 0.40 and Post 0.40 React Native. | //
// RNUnifiedContacts.h
// RNUnifiedContacts
//
// Created by Joshua Pinter on 2016-03-23.
// Copyright © 2016 Joshua Pinter. All rights reserved.
//
#ifndef RNUnifiedContacts_Bridging_Header_h
#define RNUnifiedContacts_Bridging_Header_h
#import <React/RCTBridgeModule.h>
#endif /* RNUnifiedContacts_Bridging_Header_h */
| //
// RNUnifiedContacts.h
// RNUnifiedContacts
//
// Created by Joshua Pinter on 2016-03-23.
// Copyright © 2016 Joshua Pinter. All rights reserved.
//
#ifndef RNUnifiedContacts_Bridging_Header_h
#define RNUnifiedContacts_Bridging_Header_h
#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif
#endif /* RNUnifiedContacts_Bridging_Header_h */
|
Make IOperation destructor virtual, remove redundant default | #pragma once
#ifndef YOU_DATASTORE_OPERATION_H_
#define YOU_DATASTORE_OPERATION_H_
#include <unordered_map>
#include "datastore.h"
namespace You {
namespace DataStore {
/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
IOperation() = default;
~IOperation() = default;
/// Executes the operation
virtual void run(DataStore::STask) = 0;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_OPERATION_H_
| #pragma once
#ifndef YOU_DATASTORE_OPERATION_H_
#define YOU_DATASTORE_OPERATION_H_
#include <unordered_map>
#include "datastore.h"
namespace You {
namespace DataStore {
/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
IOperation();
virtual ~IOperation();
/// Executes the operation
virtual void run(DataStore::STask) = 0;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_OPERATION_H_
|
Remove two unused PPAPI-related typedefs | /*
* Copyright (c) 2011 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.
*/
#ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_PPAPI_H_
#define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_PPAPI_H_ 1
#include <stddef.h>
#include "ppapi/c/ppp.h"
struct PP_StartFunctions {
int32_t (*PPP_InitializeModule)(PP_Module module_id,
PPB_GetInterface get_browser_interface);
void (*PPP_ShutdownModule)();
const void *(*PPP_GetInterface)(const char *interface_name);
};
struct PP_ThreadFunctions {
/*
* This is a cut-down version of pthread_create()/pthread_join().
* We omit thread creation attributes and the thread's return value.
*
* We use uintptr_t as the thread ID type because pthread_t is not
* part of the stable ABI; a user thread library might choose an
* arbitrary size for its own pthread_t.
*/
int (*thread_create)(uintptr_t *tid,
void (*func)(void *thread_argument),
void *thread_argument);
int (*thread_join)(uintptr_t tid);
};
typedef void (*PP_StartFunc)(const struct PP_StartFunctions *funcs);
typedef void (*PP_RegisterThreadFuncs)(const struct PP_ThreadFunctions *funcs);
#endif
| /*
* Copyright (c) 2011 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.
*/
#ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_PPAPI_H_
#define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_PPAPI_H_ 1
#include <stddef.h>
#include "ppapi/c/ppp.h"
struct PP_StartFunctions {
int32_t (*PPP_InitializeModule)(PP_Module module_id,
PPB_GetInterface get_browser_interface);
void (*PPP_ShutdownModule)();
const void *(*PPP_GetInterface)(const char *interface_name);
};
struct PP_ThreadFunctions {
/*
* This is a cut-down version of pthread_create()/pthread_join().
* We omit thread creation attributes and the thread's return value.
*
* We use uintptr_t as the thread ID type because pthread_t is not
* part of the stable ABI; a user thread library might choose an
* arbitrary size for its own pthread_t.
*/
int (*thread_create)(uintptr_t *tid,
void (*func)(void *thread_argument),
void *thread_argument);
int (*thread_join)(uintptr_t tid);
};
#endif
|
Add newline at end of file, clang compiler warning. | //===-- GetOpt.h ------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#pragma once
#ifndef _MSC_VER
#include <unistd.h>
#include <getopt.h>
#else
#include <lldb/Host/windows/GetOptInc.h>
#endif | //===-- GetOpt.h ------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#pragma once
#ifndef _MSC_VER
#include <unistd.h>
#include <getopt.h>
#else
#include <lldb/Host/windows/GetOptInc.h>
#endif
|
Fix a typo (thanks to Robert Hatcher) | // @(#)root/hist:$Name: $:$Id: TH1I.h,v 1.1 2002/05/18 11:02:49 brun Exp $
// Author: Rene Brun 08/09/2003
/*************************************************************************
* 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. *
*************************************************************************/
#ifndef ROOT_TH1I
#define ROOT_TH1I
//////////////////////////////////////////////////////////////////////////
// //
// TH1I //
// //
// 1-Dim histogram with a 4 bits integer per channel //
// //
//////////////////////////////////////////////////////////////////////////
#ifndef ROOT_TH1
#include "TH1.h"
#endif
#endif
| // @(#)root/hist:$Name: $:$Id: TH1I.h,v 1.1 2003/09/08 12:50:23 brun Exp $
// Author: Rene Brun 08/09/2003
/*************************************************************************
* 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. *
*************************************************************************/
#ifndef ROOT_TH1I
#define ROOT_TH1I
//////////////////////////////////////////////////////////////////////////
// //
// TH1I //
// //
// 1-Dim histogram with a 32 bits integer per channel //
// //
//////////////////////////////////////////////////////////////////////////
#ifndef ROOT_TH1
#include "TH1.h"
#endif
#endif
|
Mark init as unavailable for ObjectStore | // For License please refer to LICENSE file in the root of FastEasyMapping project
#import "FEMObjectStore.h"
@class NSManagedObjectContext;
@interface FEMManagedObjectStore : FEMObjectStore
- (nonnull instancetype)initWithContext:(nonnull NSManagedObjectContext *)context NS_DESIGNATED_INITIALIZER;
@property (nonatomic, strong, readonly, nonnull) NSManagedObjectContext *context;
@property (nonatomic) BOOL saveContextOnCommit;
@end | // For License please refer to LICENSE file in the root of FastEasyMapping project
#import "FEMObjectStore.h"
NS_ASSUME_NONNULL_BEGIN
@class NSManagedObjectContext;
@interface FEMManagedObjectStore : FEMObjectStore
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithContext:(NSManagedObjectContext *)context NS_DESIGNATED_INITIALIZER;
@property (nonatomic, strong, readonly) NSManagedObjectContext *context;
@property (nonatomic) BOOL saveContextOnCommit;
@end
NS_ASSUME_NONNULL_END |
Add empty header to fix internal project. | /*
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_
#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_
#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_
| |
Add macros for targeting Windows XP | /* Various definitions needed for compatibility with various
compilers (MSC) and platforms (Windows). */
#ifndef BASE_DEFS_H
#define BASE_DEFS_H
#ifdef _MSC_VER
#if !defined(__cplusplus)
#define inline __inline
#endif
#define __attribute__(x)
#endif
#ifdef _WIN32
/* Target Windows XP */
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#endif
#endif
| |
Fix comment on shouldSkipAuthorization property | /* Copyright (c) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// GTLBatchQuery.h
//
#import "GTLQuery.h"
@interface GTLBatchQuery : NSObject <GTLQueryProtocol> {
@private
NSMutableArray *queries_;
NSMutableDictionary *requestIDMap_;
BOOL skipAuthorization_;
}
// Queries included in this batch. Each query should have a unique requestID.
@property (retain) NSArray *queries;
// Clients may set this to NO to disallow authorization. Defaults to YES.
@property (assign) BOOL shouldSkipAuthorization;
+ (id)batchQuery;
+ (id)batchQueryWithQueries:(NSArray *)array;
- (void)addQuery:(GTLQuery *)query;
- (GTLQuery *)queryForRequestID:(NSString *)requestID;
@end
| /* Copyright (c) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// GTLBatchQuery.h
//
#import "GTLQuery.h"
@interface GTLBatchQuery : NSObject <GTLQueryProtocol> {
@private
NSMutableArray *queries_;
NSMutableDictionary *requestIDMap_;
BOOL skipAuthorization_;
}
// Queries included in this batch. Each query should have a unique requestID.
@property (retain) NSArray *queries;
// Clients may set this to YES to disallow authorization. Defaults to NO.
@property (assign) BOOL shouldSkipAuthorization;
+ (id)batchQuery;
+ (id)batchQueryWithQueries:(NSArray *)array;
- (void)addQuery:(GTLQuery *)query;
- (GTLQuery *)queryForRequestID:(NSString *)requestID;
@end
|
Add a sample program for testing memory search. | //Compile this program with -O0
#include <stdlib.h>
#include <unistd.h>
int main(void) {
char *in_data_segment[] = "0xC0xA0xF0xE";
char in_stack[] = {0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf};
char *in_heap = malloc(7 * sizeof(char));
in_heap[0] = 0xb;
in_heap[1] = 0xe;
in_heap[2] = 0xb;
in_heap[3] = 0xe;
in_heap[4] = 0xf;
in_heap[5] = 0xe;
in_heap[6] = 0x0;
for (;;) sleep(1);
return 0;
}
| |
Include <stdint.h> for MS Visual Studio 2010 and above | #ifndef _MATH_MT_H_
#define _MATH_MT_H_
//#if defined(_MSC_VER) && (_MSC_VER <= 1600) // sufficient
#if defined(_MSC_VER) // better?
typedef unsigned __int32 uint32_t;
#elif defined(__linux__) || defined(__GLIBC__) || defined(__WIN32__) || defined(__APPLE__)
#include <stdint.h>
#elif defined(__osf__)
#include <inttypes.h>
#else
#include <sys/types.h>
#endif
enum { N = 624, M = 397 };
struct mt {
uint32_t mt[N];
int mti;
uint32_t seed;
};
struct mt *mt_init(void);
void mt_free(struct mt *self);
uint32_t mt_get_seed(struct mt *self);
void mt_init_seed(struct mt *self, uint32_t seed);
void mt_setup_array(struct mt *self, uint32_t *array, int n);
double mt_genrand(struct mt *self);
#endif
| #ifndef _MATH_MT_H_
#define _MATH_MT_H_
#if defined(_MSC_VER) && (_MSC_VER < 1600) // for MS Visual Studio prior to 2010
typedef unsigned __int32 uint32_t;
#elif defined(__linux__) || defined(__GLIBC__) || defined(__WIN32__) || defined(_MSC_VER) || defined(__APPLE__)
#include <stdint.h>
#elif defined(__osf__)
#include <inttypes.h>
#else
#include <sys/types.h>
#endif
enum { N = 624, M = 397 };
struct mt {
uint32_t mt[N];
int mti;
uint32_t seed;
};
struct mt *mt_init(void);
void mt_free(struct mt *self);
uint32_t mt_get_seed(struct mt *self);
void mt_init_seed(struct mt *self, uint32_t seed);
void mt_setup_array(struct mt *self, uint32_t *array, int n);
double mt_genrand(struct mt *self);
#endif
|
Add preprocessor if check example | /**
* Copyright (c) 2015, Trellis-Logic
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* The datasheet specifies this location should be on a dword boundary
*/
#define HARDWARE_WIDGET_BASE_REGISTER_LOCATION 0x1000
struct hardware_widget
{
void *base_register_location;
};
struct hardware_widget g_hardware_widget;
/**
* Initializes structure with parameters for access of the hardware widget
* @param hardware_widget The structure to initialize
*/
#if ((HARDWARE_WIDGET_BASE_REGISTER_LOCATION & 0x3) != 0 )
#error "Hardware widget datatsheet specifies the base register should be at a DWORD boundary!"
#endif
static void init_hardware(struct hardware_widget *widget)
{
widget->base_register_location=(void *)HARDWARE_WIDGET_BASE_REGISTER_LOCATION;
}
int main(void)
{
init_hardware(&g_hardware_widget);
}
| |
Allow version suffix from command line | #ifndef QGC_CONFIGURATION_H
#define QGC_CONFIGURATION_H
#include <QString>
/** @brief Polling interval in ms */
#define SERIAL_POLL_INTERVAL 4
/** @brief Heartbeat emission rate, in Hertz (times per second) */
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 2.0.3 (beta)"
namespace QGC
{
const QString APPNAME = "QGROUNDCONTROL";
const QString ORG_NAME = "QGROUNDCONTROL.ORG"; //can be customized by forks to e.g. mycompany.com to maintain separate Settings for customized apps
const QString ORG_DOMAIN = "org.qgroundcontrol";//can be customized by forks
const int APPLICATIONVERSION = 203; // 2.0.3
}
#endif // QGC_CONFIGURATION_H
| #ifndef QGC_CONFIGURATION_H
#define QGC_CONFIGURATION_H
#include <QString>
/** @brief Polling interval in ms */
#define SERIAL_POLL_INTERVAL 4
/** @brief Heartbeat emission rate, in Hertz (times per second) */
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION_BASE "v2.0.3"
#define QGC_APPLICATION_VERSION_SUFFIX ".234 (Daily Build)"
#ifdef QGC_APPLICATION_VERSION_SUFFIX
#define QGC_APPLICATION_VERSION QGC_APPLICATION_VERSION_BASE QGC_APPLICATION_VERSION_SUFFIX
#else
#define QGC_APPLICATION_VERSION QGC_APPLICATION_VERSION_BASE " (Developer Build)"
#endif
namespace QGC
{
const QString APPNAME = "QGROUNDCONTROL";
const QString ORG_NAME = "QGROUNDCONTROL.ORG"; //can be customized by forks to e.g. mycompany.com to maintain separate Settings for customized apps
const QString ORG_DOMAIN = "org.qgroundcontrol";//can be customized by forks
const int APPLICATIONVERSION = 203; // 2.0.3
}
#endif // QGC_CONFIGURATION_H
|
Add cookie entry for auxilary match data. | #ifndef CJET_FETCH_H
#define CJET_FETCH_H
#include "json/cJSON.h"
#include "list.h"
#include "peer.h"
typedef int (*match_func)(const char *fetch_path, const char *state_path);
struct path_matcher {
char *fetch_path;
match_func match_function;
};
struct fetch {
char *fetch_id;
const struct peer *peer;
struct list_head next_fetch;
struct path_matcher matcher[12];
};
cJSON *add_fetch_to_peer(struct peer *p, cJSON *params);
void remove_all_fetchers_from_peer(struct peer *p);
#endif
| #ifndef CJET_FETCH_H
#define CJET_FETCH_H
#include "json/cJSON.h"
#include "list.h"
#include "peer.h"
typedef int (*match_func)(const char *fetch_path, const char *state_path);
struct path_matcher {
char *fetch_path;
match_func match_function;
uintptr_t cookie;
};
struct fetch {
char *fetch_id;
const struct peer *peer;
struct list_head next_fetch;
struct path_matcher matcher[12];
};
cJSON *add_fetch_to_peer(struct peer *p, cJSON *params);
void remove_all_fetchers_from_peer(struct peer *p);
#endif
|
Fix compilation broken for linux |
#ifndef _H_STREAM_QUEUE_MANAGER
#define _H_STREAM_QUEUE_MANAGER
/* ****************************************************************************
*
* FILE QueuesManager.h
*
* AUTHOR Andreu Urruela Planas
*
* All the queues contained in the system
*
*/
#include "au/map.h" // au::map
namespace samson {
namespace stream
{
class Queue;
class Block;
class QueuesManager
{
au::map< std::string , Queue > queues; // Map with the current queues
public:
QueuesManager();
std::string getStatus();
void addBlock( std::string queue , Block *b);
};
}
}
#endif |
#ifndef _H_STREAM_QUEUE_MANAGER
#define _H_STREAM_QUEUE_MANAGER
/* ****************************************************************************
*
* FILE QueuesManager.h
*
* AUTHOR Andreu Urruela Planas
*
* All the queues contained in the system
*
*/
#include "au/map.h" // au::map
#include <string>
namespace samson {
namespace stream
{
class Queue;
class Block;
class QueuesManager
{
au::map< std::string , Queue > queues; // Map with the current queues
public:
QueuesManager();
std::string getStatus();
void addBlock( std::string queue , Block *b);
};
}
}
#endif
|
Add missing part of test | template <typename T> struct S;
template<typename T> void c(T)
{
}
template <> struct S <int>
{
void a()
{
c(&S<int>::b);
}
void b() {}
};
| |
Change forward declaration to import for convenience. | //
// OCHamcrest - HCSelfDescribing.h
// Copyright 2013 hamcrest.org. See LICENSE.txt
//
// Created by: Jon Reid, http://qualitycoding.org/
// Docs: http://hamcrest.github.com/OCHamcrest/
// Source: https://github.com/hamcrest/OCHamcrest
//
#import <Foundation/Foundation.h>
@protocol HCDescription;
/**
The ability of an object to describe itself.
@ingroup core
*/
@protocol HCSelfDescribing <NSObject>
/**
Generates a description of the object.
The description may be part of a description of a larger object of which this is just a
component, so it should be worded appropriately.
@param description The description to be built or appended to.
*/
- (void)describeTo:(id<HCDescription>)description;
@end
| //
// OCHamcrest - HCSelfDescribing.h
// Copyright 2013 hamcrest.org. See LICENSE.txt
//
// Created by: Jon Reid, http://qualitycoding.org/
// Docs: http://hamcrest.github.com/OCHamcrest/
// Source: https://github.com/hamcrest/OCHamcrest
//
#import <Foundation/Foundation.h>
#import "HCDescription.h"
/**
The ability of an object to describe itself.
@ingroup core
*/
@protocol HCSelfDescribing <NSObject>
/**
Generates a description of the object.
The description may be part of a description of a larger object of which this is just a
component, so it should be worded appropriately.
@param description The description to be built or appended to.
*/
- (void)describeTo:(id<HCDescription>)description;
@end
|
Fix symFileVersion not being initialized in ArmipsArguments constructor | #pragma once
#include "../Util/FileClasses.h"
#include "../Util/Util.h"
#include "FileManager.h"
#define ARMIPS_VERSION_MAJOR 0
#define ARMIPS_VERSION_MINOR 10
#define ARMIPS_VERSION_REVISION 0
enum class ArmipsMode { FILE, MEMORY };
struct LabelDefinition
{
std::wstring name;
int64_t value;
};
struct EquationDefinition
{
std::wstring name;
std::wstring value;
};
struct ArmipsArguments
{
// common
ArmipsMode mode;
int symFileVersion;
bool errorOnWarning;
bool silent;
StringList* errorsResult;
std::vector<EquationDefinition> equList;
std::vector<LabelDefinition> labels;
// file mode
std::wstring inputFileName;
std::wstring tempFileName;
std::wstring symFileName;
bool useAbsoluteFileNames;
// memory mode
std::shared_ptr<AssemblerFile> memoryFile;
std::wstring content;
ArmipsArguments()
{
mode = ArmipsMode::FILE;
errorOnWarning = false;
silent = false;
errorsResult = nullptr;
useAbsoluteFileNames = true;
}
};
bool runArmips(ArmipsArguments& arguments);
| #pragma once
#include "../Util/FileClasses.h"
#include "../Util/Util.h"
#include "FileManager.h"
#define ARMIPS_VERSION_MAJOR 0
#define ARMIPS_VERSION_MINOR 10
#define ARMIPS_VERSION_REVISION 0
enum class ArmipsMode { FILE, MEMORY };
struct LabelDefinition
{
std::wstring name;
int64_t value;
};
struct EquationDefinition
{
std::wstring name;
std::wstring value;
};
struct ArmipsArguments
{
// common
ArmipsMode mode;
int symFileVersion;
bool errorOnWarning;
bool silent;
StringList* errorsResult;
std::vector<EquationDefinition> equList;
std::vector<LabelDefinition> labels;
// file mode
std::wstring inputFileName;
std::wstring tempFileName;
std::wstring symFileName;
bool useAbsoluteFileNames;
// memory mode
std::shared_ptr<AssemblerFile> memoryFile;
std::wstring content;
ArmipsArguments()
{
mode = ArmipsMode::FILE;
symFileVersion = 0;
errorOnWarning = false;
silent = false;
errorsResult = nullptr;
useAbsoluteFileNames = true;
}
};
bool runArmips(ArmipsArguments& arguments);
|
Use __attribute__s if __GNUC__ defined | /* Copyright 2014-2015 Drew Thoreson
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _COMPILER_H
#define _COMPILER_H
#if __STDC_VERSION__ < 201112L
#define _Static_assert(cond, msg) \
extern char navi_static_assert_fail[1/(cond)]
#define _Noreturn
#define _Alignas(n) __attribute__((aligned(n)))
#endif
/*
* GCC 2.96 or compatible required
*/
#if defined(__GNUC__)
#if __GNUC__ > 3
#undef offsetof
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif
/* Optimization: Condition @x is likely */
#define likely(x) __builtin_expect(!!(x), 1)
/* Optimization: Condition @x is unlikely */
#define unlikely(x) __builtin_expect(!!(x), 0)
#define __used __attribute__((used))
#define __unused __attribute__((unused))
#else
#define likely(x) (x)
#define unlikely(x) (x)
#define __used
#define __unused
#endif /* defined(__GNUC__) */
#endif /* _COMPILER_H */
| /* Copyright 2014-2015 Drew Thoreson
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _COMPILER_H
#define _COMPILER_H
#if __STDC_VERSION__ < 201112L
#define _Static_assert(cond, msg) \
extern char navi_static_assert_fail[1/(cond)]
#ifdef __GNUC__
#define _Noreturn __attribute__((noreturn))
#define _Alignas(n) __attribute__((aligned(n)))
#else
#define _Noreturn
#define _Alignas(n)
#pragma message "*** WARNING: _Alignas defined as NOP ***"
#endif
#endif
/*
* GCC 2.96 or compatible required
*/
#if defined(__GNUC__)
/* Optimization: Condition @x is likely */
#define likely(x) __builtin_expect(!!(x), 1)
/* Optimization: Condition @x is unlikely */
#define unlikely(x) __builtin_expect(!!(x), 0)
#define __used __attribute__((used))
#define __unused __attribute__((unused))
#else
#define likely(x) (x)
#define unlikely(x) (x)
#define __used
#define __unused
#endif /* defined(__GNUC__) */
#endif /* _COMPILER_H */
|
Add missing word in comment | //PARAM: --enable witness.yaml.enabled --enable ana.int.interval
#include <stdlib.h>
int foo(int* ptr1, int* ptr2){
int result;
if(ptr1 == ptr2){
result = 0;
} else {
result = 1;
}
// Look at the generated witness.yml to check whether there contradictory precondition_loop_invariant[s]
return result;
}
int main(){
int five = 5;
int five2 = 5;
int y = foo(&five, &five);
int z = foo(&five, &five2);
assert(y != z);
return 0;
}
| //PARAM: --enable witness.yaml.enabled --enable ana.int.interval
#include <stdlib.h>
int foo(int* ptr1, int* ptr2){
int result;
if(ptr1 == ptr2){
result = 0;
} else {
result = 1;
}
// Look at the generated witness.yml to check whether there are contradictory precondition_loop_invariant[s]
return result;
}
int main(){
int five = 5;
int five2 = 5;
int y = foo(&five, &five);
int z = foo(&five, &five2);
assert(y != z);
return 0;
}
|
Fix arguments count check in test inotify program | /*
This is a simple C program which is a stub for the FS monitor.
It takes one argument which would be a directory to monitor. In this case,
the filename is discarded after argument validation.
Every minute the
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main (int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "Not enough arguments");
exit(EXIT_FAILURE);
}
while (1) {
fprintf(stdout, "{ \"key\": \"value\" }\n");
fflush(stdout);
fprintf(stderr, "tick\n");
sleep(1);
}
}
| /*
This is a simple C program which is a stub for the FS monitor.
It takes one argument which would be a directory to monitor. In this case,
the filename is discarded after argument validation.
Every minute the
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main (int argc, char **argv) {
if (argc < 2) {
fprintf(stderr, "Not enough arguments");
exit(EXIT_FAILURE);
}
while (1) {
fprintf(stdout, "{ \"key\": \"value\" }\n");
fflush(stdout);
fprintf(stderr, "tick\n");
sleep(1);
}
}
|
Add a missing file... fix that compile error. | /***************************************************************************
* Copyright (C) 2006 *
* *
* Jason Kivlighn (jkivlighn@gmail.com) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef USDA_UNIT_DATA_H
#define USDA_UNIT_DATA_H
#include <klocale.h>
#include <qstring.h>
struct unit_data {
const char *name;
const char *plural;
};
static unit_data unit_data_list[] = {
{"bag","bags"},
{"block","blocks"},
{"bottle","bottles"},
{"box","boxes"},
{"bunch","bunches"},
{"can","cans"},
{"cone","cones"},
{"container","containers"},
{"cube","cubes"},
{"cup","cups"},
{"fl oz","fl oz"},
{"glass","glasses"},
{"item","items"},
{"loaf","loaves"},
{"large","large"},
{"lb","lbs"},
{"junior","junior"},
{"leaf","leaves"},
{"medium","medium"},
{"oz","oz"},
{"pack","packs"},
{"package","packages"},
{"packet","packets"},
{"piece","pieces"},
{"pouch","pouches"},
{"quart","quarts"},
{"scoop","scoops"},
{"sheet","sheets"},
{"slice","slices"},
{"small","small"},
{"spear","spears"},
{"sprout","spouts"},
{"sprig","sprigs"},
{"square","squares"},
{"stalk","stalks"},
{"stem","stems"},
{"strip","strips"},
{"tablespoon","tablespoons"},
{"tbsp","tbsp"},
{"teaspoon","teaspoons"},
{"tsp","tsp"},
{"tube","tubes"},
{"unit","units"},
{0,0}
};
static const char * prep_data_list[] = {
"chopped",
"diced",
"sliced",
"crumbled",
"crushed",
"ground",
"grated",
"mashed",
"melted",
"packed",
"pureed",
"quartered",
"thawed",
"shredded",
"sifted",
"pared",
"flaked",
"unpacked",
"unsifted",
"unthawed",
"pitted",
"peeled",
"cooked",
"hulled",
"shelled",
"raw",
"whipped",
0
};
bool parseUSDAUnitAndPrep( const QString &string, QString &unit, QString &prep );
#endif //USDA_UNIT_DATA_H
| |
Add TODO test where ambiguous pointer invariant could refine pointer | // modified from 27/09
#include <assert.h>
int main() {
int a = 1;
int b = 1;
int *x;
int rnd;
if (rnd)
x = &a;
else
x = &b;
assert(*x == 1);
b = 2;
assert(a == 1);
if (*x > 1) { // invariant rules out x == &a
assert(x == &b); // TODO
assert(*x == 2); // TODO
}
return 0;
} | |
Make sure we've enabled interrupts before calling halt.. | /*
* Part of Jari Komppa's zx spectrum suite
* https://github.com/jarikomppa/speccy
* released under the unlicense, see http://unlicense.org
* (practically public domain)
*/
// xxxsmbbb
// where b = border color, m is mic, s is speaker
void port254(const unsigned char color) __z88dk_fastcall
{
color; // color is in l
// Direct border color setting
__asm
ld a,l
ld hl, #_port254tonebit
or a, (hl)
out (254),a
__endasm;
}
// practically waits for retrace
void do_halt()
{
__asm
halt
__endasm;
}
| /*
* Part of Jari Komppa's zx spectrum suite
* https://github.com/jarikomppa/speccy
* released under the unlicense, see http://unlicense.org
* (practically public domain)
*/
// xxxsmbbb
// where b = border color, m is mic, s is speaker
void port254(const unsigned char color) __z88dk_fastcall
{
color; // color is in l
// Direct border color setting
__asm
ld a,l
ld hl, #_port254tonebit
or a, (hl)
out (254),a
__endasm;
}
// practically waits for retrace
void do_halt()
{
__asm
ei
halt
__endasm;
}
|
Use Framework style import statements for pod Framework compatibility | //
// SGCachePromise.h
// Pods
//
// Created by James Van-As on 13/05/15.
//
//
#import "Promise.h"
#import "MGEvents.h"
typedef void(^SGCacheFetchCompletion)(id obj);
typedef void(^SGCacheFetchFail)(NSError *error, BOOL wasFatal);
typedef void(^SGCacheFetchOnRetry)();
@interface SGCachePromise : PMKPromise
@property (nonatomic, copy) SGCacheFetchOnRetry onRetry;
@property (nonatomic, copy) SGCacheFetchFail onFail;
@end
| //
// SGCachePromise.h
// Pods
//
// Created by James Van-As on 13/05/15.
//
//
#import <PromiseKit/Promise.h>
#import <MGEvents/MGEvents.h>
typedef void(^SGCacheFetchCompletion)(id obj);
typedef void(^SGCacheFetchFail)(NSError *error, BOOL wasFatal);
typedef void(^SGCacheFetchOnRetry)();
@interface SGCachePromise : PMKPromise
@property (nonatomic, copy) SGCacheFetchOnRetry onRetry;
@property (nonatomic, copy) SGCacheFetchFail onFail;
@end
|
Test case distilled from sed. | typedef enum { FALSE, TRUE } flagT;
struct Word
{
short bar;
short baz;
flagT final:1;
short quux;
} *word_limit;
void foo ()
{
word_limit->final = (word_limit->final && word_limit->final);
}
| |
Make this a proper forwarding header rather than a duplication what's under pagespeed/util/ | /*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Author: gagansingh@google.com (Gagan Singh)
#ifndef NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
#define NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
#include "net/instaweb/util/public/string_util.h"
#include "third_party/re2/src/re2/re2.h"
using re2::RE2;
// Converts a Google StringPiece into an RE2 StringPiece. These are of course
// the same basic thing but are declared in distinct namespaces and as far as
// C++ type-checking is concerned they are incompatible.
//
// TODO(jmarantz): In the re2 code itself there are no references to
// re2::StringPiece, always just plain StringPiece, so if we can
// arrange to get the right definition #included we should be all set.
// We could somehow rewrite '#include "re2/stringpiece.h"' to
// #include Chromium's stringpiece then everything would just work.
inline re2::StringPiece StringPieceToRe2(StringPiece sp) {
return re2::StringPiece(sp.data(), sp.size());
}
#endif // NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
| /*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Author: gagansingh@google.com (Gagan Singh)
#ifndef NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
#define NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
// TODO(morlovich): Remove this forwarding header and change all references.
#include "pagespeed/kernel/util/re2.h"
#endif // NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
|
Update RingOpenGL 1.1 - Add Constant (Source Code) : GL_FALSE | #include "ring.h"
/*
OpenGL 1.1 Extension
Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/
#include <GL/glew.h>
#include <GL/glut.h>
RING_FUNC(ring_get_gl_zero)
{
RING_API_RETNUMBER(GL_ZERO);
}
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
}
| #include "ring.h"
/*
OpenGL 1.1 Extension
Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/
#include <GL/glew.h>
#include <GL/glut.h>
RING_FUNC(ring_get_gl_zero)
{
RING_API_RETNUMBER(GL_ZERO);
}
RING_FUNC(ring_get_gl_false)
{
RING_API_RETNUMBER(GL_FALSE);
}
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
ring_vm_funcregister("get_gl_false",ring_get_gl_false);
}
|
Debug macro for seeding random generator. | // CppUtils.h
#pragma once
#include <algorithm>
#include <functional>
#include <vector>
#include <random>
using namespace System;
namespace CppUtils {
public ref class Random
{
public:
double Random::random_double()
{
return Random::random_in_range(0.0, 1.0);
}
double Random::random_in_range(double min, double max)
{
std::uniform_real_distribution<float> distribution(min, max);
std::random_device rd;
std::default_random_engine e(rd());
return distribution(e);
}
std::vector<double> Random::random_vector(double len, double min, double max)
{
auto result = std::vector<double>();
std::uniform_real_distribution<float> distribution(min, max);
std::mt19937 engine;
auto generator = bind(distribution, engine);
generate(result.begin(), result.end(), generator);
return result;
}
};
}
| // CppUtils.h
#pragma once
#ifdef DEBUG
#define SEED(x) 100
#else
#define SEED(x) x
#endif
#include <algorithm>
#include <functional>
#include <vector>
#include <random>
using namespace System;
namespace CppUtils {
public ref class Random
{
public:
double Random::random_double()
{
return Random::random_in_range(0.0, 1.0);
}
double Random::random_in_range(double min, double max)
{
std::uniform_real_distribution<float> distribution(min, max);
std::random_device rd;
std::default_random_engine e(SEED(rd()));
return distribution(e);
}
std::vector<double> Random::random_vector(double len, double min, double max)
{
auto result = std::vector<double>();
std::uniform_real_distribution<float> distribution(min, max);
std::random_device rd;
std::default_random_engine engine(SEED(rd()));
auto generator = bind(distribution, engine);
std::generate(result.begin(), result.end(), generator);
return result;
}
};
}
|
Add a RUN line to get a hint on why the test is failing at the buildbots. | // This uses a headermap with this entry:
// someheader.h -> Product/someheader.h
// RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H 2> %t.out
// RUN: FileCheck %s -input-file %t.out
// CHECK: Product/someheader.h
// CHECK: system/usr/include/someheader.h
// CHECK: system/usr/include/someheader.h
#include "someheader.h"
#include <someheader.h>
#include <someheader.h>
| // This uses a headermap with this entry:
// someheader.h -> Product/someheader.h
// RUN: %clang_cc1 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H
// RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H 2> %t.out
// RUN: FileCheck %s -input-file %t.out
// CHECK: Product/someheader.h
// CHECK: system/usr/include/someheader.h
// CHECK: system/usr/include/someheader.h
#include "someheader.h"
#include <someheader.h>
#include <someheader.h>
|
Delete printing, show usage if arguments are not enough | #include "estimator.h"
#include <stdio.h>
int main(int argc, char** argv) {
void* estimator = create_estimator(argv[1]);
candidates_t* candidates = estimate(estimator, argv[2]);
for(unsigned int i = 0; i < candidates->candidates[0]->size; i++) {
printf("x: %4lu y: %4lu confidence: %.4f \n",
candidates->candidates[0]->parts[i]->x,
candidates->candidates[0]->parts[i]->y,
candidates->candidates[0]->confidence[i]);
}
printf("\n");
destroy_estimator(estimator);
free_candidates(candidates);
}
| #include <stdio.h>
#include <stdlib.h>
#include "estimator.h"
int main(int argc, char** argv) {
//test();
if(argc < 3) {
printf("Usage: PartsBasedDetector1 model_file image_file\n");
exit(0);
}
void* estimator = create_estimator(argv[1]);
candidates_t* candidates = estimate(estimator, argv[2]);
print_candidate(candidates->candidates[0]);
destroy_estimator(estimator);
free_candidates(candidates);
}
|
Remove compiler warning due to old-style function definition | /* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include "pthreadP.h"
int
pthread_spin_lock (lock)
pthread_spinlock_t *lock;
{
unsigned int val;
do
__asm__ volatile ("tas.b @%1; movt %0"
: "=&r" (val)
: "r" (lock)
: "memory");
while (val == 0);
return 0;
}
| /* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include "pthreadP.h"
int
pthread_spin_lock (pthread_spinlock_t *lock)
{
unsigned int val;
do
__asm__ volatile ("tas.b @%1; movt %0"
: "=&r" (val)
: "r" (lock)
: "memory");
while (val == 0);
return 0;
}
|
Increase the size of the read buffer fpo testing. | #ifndef CJET_CONFIG_H
#define CJET_CONFIG_H
#define SERVER_PORT 11122
#define LISTEN_BACKLOG 40
#define MAX_MESSAGE_SIZE 128
/* Linux specific configs */
#define MAX_EPOLL_EVENTS 100
#endif
| #ifndef CJET_CONFIG_H
#define CJET_CONFIG_H
#define SERVER_PORT 11122
#define LISTEN_BACKLOG 40
#define MAX_MESSAGE_SIZE 250
/* Linux specific configs */
#define MAX_EPOLL_EVENTS 100
#endif
|
Make ports constexpr to further reduce binary size | /*
* atlstd.h
*
* Created: 3/31/2017 12:29:59 AM
* Author: Vadim Zabavnov
*/
#ifndef ATLSTD_H_
#define ATLSTD_H_
#include <atlport.h>
namespace atl {
namespace std {
using namespace atl;
// standard ports
#ifdef PORTA
const Port PortA = Port(_SFR_IO_ADDR(PORTA), _SFR_IO_ADDR(DDRA), _SFR_IO_ADDR(PINA));
#endif
#ifdef PORTB
const Port PortB = Port(_SFR_IO_ADDR(PORTB), _SFR_IO_ADDR(DDRB), _SFR_IO_ADDR(PINB));
#endif
#ifdef PORTC
const Port PortC = Port(_SFR_IO_ADDR(PORTC), _SFR_IO_ADDR(DDRC), _SFR_IO_ADDR(PINC));
#endif
#ifdef PORTD
const Port PortD = Port(_SFR_IO_ADDR(PORTD), _SFR_IO_ADDR(DDRD), _SFR_IO_ADDR(PIND));
#endif
}
}
#endif /* ATLSTD_H_ */ | /*
* atlstd.h
*
* Created: 3/31/2017 12:29:59 AM
* Author: Vadim Zabavnov
*/
#ifndef ATLSTD_H_
#define ATLSTD_H_
#include <atlport.h>
namespace atl {
namespace std {
using namespace atl;
// standard ports
#ifdef PORTA
constexpr Port PortA = Port(_SFR_IO_ADDR(PORTA), _SFR_IO_ADDR(DDRA), _SFR_IO_ADDR(PINA));
#endif
#ifdef PORTB
constexpr Port PortB = Port(_SFR_IO_ADDR(PORTB), _SFR_IO_ADDR(DDRB), _SFR_IO_ADDR(PINB));
#endif
#ifdef PORTC
constexpr Port PortC = Port(_SFR_IO_ADDR(PORTC), _SFR_IO_ADDR(DDRC), _SFR_IO_ADDR(PINC));
#endif
#ifdef PORTD
constexpr Port PortD = Port(_SFR_IO_ADDR(PORTD), _SFR_IO_ADDR(DDRD), _SFR_IO_ADDR(PIND));
#endif
}
}
#endif /* ATLSTD_H_ */ |
Add minor comment for log_open | // cc log_example.c log.c
#include "log.h"
int main(int argc, const char *argv[])
{
log_open("example", NULL, 0);
/* set log level to info, also the default level */
log_setlevel(LOG_INFO);
/* debug mesage won't be seen */
log_debug("debug message");
/* but info and warn message can be seen */
log_info("info message");
log_warn("warn message");
return 0;
}
| // cc log_example.c log.c
#include "log.h"
int main(int argc, const char *argv[])
{
/* open global logger to stderr (by setting filename to NULL) */
log_open("example", NULL, 0);
/* set log level to info, also the default level */
log_setlevel(LOG_INFO);
/* debug mesage won't be seen */
log_debug("debug message");
/* but info and warn message can be seen */
log_info("info message");
log_warn("warn message");
return 0;
}
|
Integrate terminal renderer for testing | #include <stdio.h>
#include <stdlib.h>
#include "apricosterm.h"
#include "screen.h"
int main(int argc, char** argv) {
SDL_Event event;
initScreen("Potato", SCREEN_WIDTH, SCREEN_HEIGHT);
char done = 0;
while(!done) {
while(SDL_PollEvent(&event)) {
switch(event.key.keysym.sym) {
case SDLK_ESCAPE:
done = 1;
break;
}
}
SDL_Delay(100);
updateWindow();
}
destroyScreen();
return EXIT_SUCCESS;
}
| #include <stdio.h>
#include <stdlib.h>
#include "apricosterm.h"
#include "screen.h"
#include "terminalrenderer.h"
#include "managedtextures.h"
int main(int argc, char** argv) {
SDL_Event event;
initScreen("Potato", SCREEN_WIDTH, SCREEN_HEIGHT);
char done = 0;
termRendererInit();
SDL_StartTextInput();
while(!done) {
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
case SDLK_ESCAPE:
done = 1;
break;
case SDLK_RETURN:
terminalNewLine(1, 1);
break;
case SDLK_BACKSPACE:
terminalBackspace(1);
break;
default:
break;
}
break;
case SDL_TEXTINPUT:
terminalPutStr(event.text.text);
break;
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
SDL_Delay(10);
terminalRefresh();
}
SDL_StopTextInput();
destroyAllTextures();
destroyScreen();
return EXIT_SUCCESS;
}
|
Work on stash retrieval, memory allocation | /**
* repo.c
*
* Copyright (C) 2017 Nickolas Burr <nickolasburr@gmail.com>
*/
#include "repo.h"
/**
* Get all stashes for a repository.
*/
struct stash *get_stashes (struct repo *r) {
return r->stashes;
}
/**
* Set a copy of all stashes for a repository in memory.
*/
void set_stashes (struct repo *r) {
// @todo: Build this function out.
char *cmd;
FILE *fp;
printf("set_stashes -> r->path -> %s\n", r->path);
sprintf(cmd, "/usr/bin/git -C %s -- stash list", r->path);
fp = popen(cmd, "r");
if (!fp) {
printf("Could not open pipe!\n");
exit(EXIT_FAILURE);
}
while (fgets(r->stashes->entries, (sizeof(r->stashes->entries) - 1), fp) != NULL) {
printf("%s\n", r->stashes->entries);
}
pclose(fp);
}
/**
* Check if the worktree has changed since our last check.
*/
int has_worktree_changed (struct repo *r) {
return 1;
}
| /**
* repo.c
*
* Copyright (C) 2017 Nickolas Burr <nickolasburr@gmail.com>
*/
#include "repo.h"
/**
* Get all stash entries for a repository.
*/
struct stash *get_stash (struct repo *r) {
return r->stash;
}
/**
* Set a copy of all stash entries for a repository.
*/
void set_stash (struct repo *r) {
char *cmd;
FILE *fp;
// Allocate space for command string
cmd = ALLOC(sizeof(char) * (strlen(r->path) + 100));
sprintf(cmd, "/usr/bin/git -C %s stash list", r->path);
printf("set_stashes -> cmd -> %s\n", cmd);
fp = popen(cmd, "r");
if (!fp) {
printf("Could not open pipe!\n");
exit(EXIT_FAILURE);
}
while (fgets(r->stash->entries, (sizeof(r->stash->entries) - 1), fp) != NULL) {
printf("%s\n", r->stash->entries);
}
// Free space allocated for commnad string
FREE(cmd);
pclose(fp);
}
/**
* Check if the worktree has changed since the last check.
*/
int has_worktree_changed (struct repo *r) {
return 1;
}
|
Add buttons for driving, and swap intake and arm buttons | task usercontrol(){
int DY, DT;
bool armsLocked = false;
while(true){
//Driving
DY = threshold(PAIRED_CH2, 15);
DT = threshold(PAIRED_CH1, 15);
drive(DY, DT);
//Pistons (toggle)
if(PAIRED_BTN7R){
pistons(!PISTON_POS);
waitUntil(!PAIRED_BTN7R);
}
//Arms
if(PAIRED_BTN7L){
armsLocked = !armsLocked;
waitUntil(!PAIRED_BTN7L);
}
if(armsLocked){
arms(ARM_LOCK);
} else {
arms((PAIRED_BTN6U - PAIRED_BTN6D) * MAX_POWER);
}
//Lift
lift((PAIRED_BTN7U - PAIRED_BTN7D) * MAX_POWER);
//Intake
intake((PAIRED_BTN5U - PAIRED_BTN5D) * MAX_POWER);
}
}
| task usercontrol(){
int DY, DT;
bool armsLocked = false;
while(true){
//Driving
DY = threshold(PAIRED_CH2, 15) + (PAIRED_BTN8U * MAX_POWER) - (PAIRED_BTN8D * MAX_POWER);
DT = threshold(PAIRED_CH1, 15) + (PAIRED_BTN8R * MAX_POWER) - (PAIRED_BTN8L * MAX_POWER);
drive(DY, DT);
//Pistons (toggle)
if(PAIRED_BTN7R){
pistons(!PISTON_POS);
waitUntil(!PAIRED_BTN7R);
}
//Arms
if(PAIRED_BTN7L){
armsLocked = !armsLocked;
waitUntil(!PAIRED_BTN7L);
}
if(armsLocked){
arms(ARM_LOCK);
} else {
arms(threshold(PAIRED_CH3, 15) + ((PAIRED_BTN5U - PAIRED_BTN5D) * MAX_POWER));
}
//Lift
lift((PAIRED_BTN7U - PAIRED_BTN7D) * MAX_POWER);
//Intake
intake((PAIRED_BTN6U - PAIRED_BTN6D) * MAX_POWER);
}
}
|
Use weak attribute for the autocompleteDelegate property of SMLTextView. | //
// SMLTextViewPrivate.h
// Fragaria
//
// Created by Daniele Cattaneo on 26/02/15.
//
//
#import <Cocoa/Cocoa.h>
#import "SMLTextView.h"
#import "SMLAutoCompleteDelegate.h"
@interface SMLTextView ()
/** The autocomplete delegate for this text view. This property is private
* because it is set to an internal object when MGSFragaria's autocomplete
* delegate is set to nil. */
@property id<SMLAutoCompleteDelegate> autocompleteDelegate;
/** The controller which manages the accessory user interface for this text
* view. */
@property (readonly) MGSExtraInterfaceController *interfaceController;
/** Instances of this class will perform syntax highlighting in text views. */
@property (readonly) SMLSyntaxColouring *syntaxColouring;
@end
| //
// SMLTextViewPrivate.h
// Fragaria
//
// Created by Daniele Cattaneo on 26/02/15.
//
//
#import <Cocoa/Cocoa.h>
#import "SMLTextView.h"
#import "SMLAutoCompleteDelegate.h"
@interface SMLTextView ()
/** The autocomplete delegate for this text view. This property is private
* because it is set to an internal object when MGSFragaria's autocomplete
* delegate is set to nil. */
@property (weak) id<SMLAutoCompleteDelegate> autocompleteDelegate;
/** The controller which manages the accessory user interface for this text
* view. */
@property (readonly) MGSExtraInterfaceController *interfaceController;
/** Instances of this class will perform syntax highlighting in text views. */
@property (readonly) SMLSyntaxColouring *syntaxColouring;
@end
|
Use vpx_integer.h instead of stdint.h | /*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef LIBVPX_TEST_ACM_RANDOM_H_
#define LIBVPX_TEST_ACM_RANDOM_H_
#include <stdint.h>
#include <stdlib.h>
namespace libvpx_test {
class ACMRandom {
public:
explicit ACMRandom(int seed) {
Reset(seed);
}
void Reset(int seed) {
srand(seed);
}
uint8_t Rand8(void) {
return (rand() >> 8) & 0xff;
}
int PseudoUniform(int range) {
return (rand() >> 8) % range;
}
int operator()(int n) {
return PseudoUniform(n);
}
static int DeterministicSeed(void) {
return 0xbaba;
}
};
} // namespace libvpx_test
#endif // LIBVPX_TEST_ACM_RANDOM_H_
| /*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef LIBVPX_TEST_ACM_RANDOM_H_
#define LIBVPX_TEST_ACM_RANDOM_H_
#include <stdlib.h>
#include "vpx/vpx_integer.h"
namespace libvpx_test {
class ACMRandom {
public:
explicit ACMRandom(int seed) {
Reset(seed);
}
void Reset(int seed) {
srand(seed);
}
uint8_t Rand8(void) {
return (rand() >> 8) & 0xff;
}
int PseudoUniform(int range) {
return (rand() >> 8) % range;
}
int operator()(int n) {
return PseudoUniform(n);
}
static int DeterministicSeed(void) {
return 0xbaba;
}
};
} // namespace libvpx_test
#endif // LIBVPX_TEST_ACM_RANDOM_H_
|
Allow setting user id/hmac key via command line params for setpin | #ifndef COMMAND_LINE_FLAGS_H_
#define COMMAND_LINE_FLAGS_H_
#include "kinetic/kinetic.h"
#include "gflags/gflags.h"
DEFINE_string(host, "localhost", "Kinetic Host");
DEFINE_uint64(port, 8123, "Kinetic Port");
DEFINE_uint64(timeout, 30, "Timeout");
void parse_flags(int *argc, char*** argv, std::unique_ptr<kinetic::ConnectionHandle>& connection) {
google::ParseCommandLineFlags(argc, argv, true);
kinetic::ConnectionOptions options;
options.host = FLAGS_host;
options.port = FLAGS_port;
options.user_id = 1;
options.hmac_key = "asdfasdf";
kinetic::KineticConnectionFactory kinetic_connection_factory = kinetic::NewKineticConnectionFactory();
if (!kinetic_connection_factory.NewConnection(options, FLAGS_timeout, connection).ok()) {
printf("Unable to connect\n");
exit(1);
}
}
#endif // COMMAND_LINE_FLAGS_H_
| #ifndef COMMAND_LINE_FLAGS_H_
#define COMMAND_LINE_FLAGS_H_
#include "kinetic/kinetic.h"
#include "gflags/gflags.h"
DEFINE_string(host, "localhost", "Kinetic Host");
DEFINE_uint64(port, 8123, "Kinetic Port");
DEFINE_uint64(timeout, 30, "Timeout");
DEFINE_uint64(user_id, 1, "Kinetic User ID");
DEFINE_string(hmac_key, "asdfasdf", "Kinetic User HMAC key");
void parse_flags(int *argc, char*** argv, std::unique_ptr<kinetic::ConnectionHandle>& connection) {
google::ParseCommandLineFlags(argc, argv, true);
kinetic::ConnectionOptions options;
options.host = FLAGS_host;
options.port = FLAGS_port;
options.user_id = FLAGS_user_id;
options.hmac_key = FLAGS_hmac_key;
kinetic::KineticConnectionFactory kinetic_connection_factory = kinetic::NewKineticConnectionFactory();
if (!kinetic_connection_factory.NewConnection(options, FLAGS_timeout, connection).ok()) {
printf("Unable to connect\n");
exit(1);
}
}
#endif // COMMAND_LINE_FLAGS_H_
|
Replace MPI source code instead of executive binary file. User will compile the source with its own mpi implementation. |
#include <stdlib.h>
#include <stdio.h>
#include <mpi.h>
main(int argc, char **argv)
{
register double width;
double sum = 0, lsum;
register int intervals, i;
int nproc, iproc;
MPI_Win sum_win;
if (MPI_Init(&argc, &argv) != MPI_SUCCESS) exit(1);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
MPI_Comm_rank(MPI_COMM_WORLD, &iproc);
MPI_Win_create(&sum, sizeof(sum), sizeof(sum),
0, MPI_COMM_WORLD, &sum_win);
MPI_Win_fence(0, sum_win);
intervals = atoi(argv[1]);
width = 1.0 / intervals;
lsum = 0;
for (i=iproc; i<intervals; i+=nproc) {
register double x = (i + 0.5) * width;
lsum += 4.0 / (1.0 + x * x);
}
lsum *= width;
MPI_Accumulate(&lsum, 1, MPI_DOUBLE, 0, 0,
1, MPI_DOUBLE, MPI_SUM, sum_win);
MPI_Win_fence(0, sum_win);
if (iproc == 0) {
printf("Estimation of pi is %f\n", sum);
}
MPI_Finalize();
return(0);
}
| |
Set tempdir to null by default | #pragma once
#include <QObject>
#include <QProcess>
#include <QString>
#include "Config/AmigaUAEConfig.h"
class QTemporaryDir;
namespace prodbg {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class AmigaUAE : public QObject
{
Q_OBJECT
public:
AmigaUAE(QObject* parent);
~AmigaUAE();
bool openFile();
void runExecutable(const QString& filename);
bool validateSettings();
void launchUAE();
void killProcess();
// TODO: Structure this better
QProcess* m_uaeProcess;
uint16_t m_setFileId;
uint16_t m_setHddPathId;
QString m_uaeExe;
QString m_config;
QString m_cmdLineArgs;
QString m_dh0Path;
QString m_fileToRun;
QString m_localExeToRun;
QString m_romPath;
bool m_copyFiles;
bool m_skipUAELaunch;
AmigaUAEConfig::ConfigMode m_configMode;
private:
Q_SLOT void started();
Q_SLOT void errorOccurred(QProcess::ProcessError error);
QTemporaryDir* m_tempDir;
void readSettings();
bool m_running = false;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
| #pragma once
#include <QObject>
#include <QProcess>
#include <QString>
#include "Config/AmigaUAEConfig.h"
class QTemporaryDir;
namespace prodbg {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class AmigaUAE : public QObject
{
Q_OBJECT
public:
AmigaUAE(QObject* parent);
~AmigaUAE();
bool openFile();
void runExecutable(const QString& filename);
bool validateSettings();
void launchUAE();
void killProcess();
// TODO: Structure this better
QProcess* m_uaeProcess;
uint16_t m_setFileId;
uint16_t m_setHddPathId;
QString m_uaeExe;
QString m_config;
QString m_cmdLineArgs;
QString m_dh0Path;
QString m_fileToRun;
QString m_localExeToRun;
QString m_romPath;
bool m_copyFiles;
bool m_skipUAELaunch;
AmigaUAEConfig::ConfigMode m_configMode;
private:
Q_SLOT void started();
Q_SLOT void errorOccurred(QProcess::ProcessError error);
QTemporaryDir* m_tempDir = nullptr;
void readSettings();
bool m_running = false;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
|
Fix missing PopupAt overrides on windows/linux | // Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
#define ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
#include <map>
#include <memory>
#include "atom/browser/api/atom_api_menu.h"
#include "base/memory/weak_ptr.h"
#include "ui/display/screen.h"
#include "ui/views/controls/menu/menu_runner.h"
namespace atom {
namespace api {
class MenuViews : public Menu {
public:
MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
protected:
void PopupAt(
Window* window, int x, int y, int positioning_item) override;
void ClosePopupAt(int32_t window_id) override;
private:
// window ID -> open context menu
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
base::WeakPtrFactory<MenuViews> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(MenuViews);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
| // Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
#define ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
#include <map>
#include <memory>
#include "atom/browser/api/atom_api_menu.h"
#include "base/memory/weak_ptr.h"
#include "ui/display/screen.h"
#include "ui/views/controls/menu/menu_runner.h"
namespace atom {
namespace api {
class MenuViews : public Menu {
public:
MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
protected:
void PopupAt(
Window* window, int x, int y, int positioning_item,
CloseCallback callback) override;
void ClosePopupAt(int32_t window_id) override;
private:
// window ID -> open context menu
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
base::WeakPtrFactory<MenuViews> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(MenuViews);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
|
Make instructions / cycle counters more useful | #pragma once
template<typename B, typename R> static void ParseRecordsBenchmark(benchmark::State &state, const simdjson::padded_string &json) {
// Warmup and equality check (make sure the data is right!)
B bench;
bench.SetUp();
if (!bench.Run(json)) { state.SkipWithError("warmup tweet reading failed"); return; }
{
R reference;
reference.SetUp();
if (!reference.Run(json)) { state.SkipWithError("reference tweet reading failed"); return; }
// assert(bench.Records() == reference.Records());
reference.TearDown();
}
// Run the benchmark
event_collector<true> events;
events.start();
for (SIMDJSON_UNUSED auto _ : state) {
if (!bench.Run(json)) { state.SkipWithError("tweet reading failed"); return; }
}
state.SetBytesProcessed(json.size() * state.iterations());
state.SetItemsProcessed(bench.Records().size() * state.iterations());
auto counts = events.end();
if (events.has_events()) {
state.counters["Instructions"] = counts.instructions();
state.counters["Cycles"] = counts.cycles();
state.counters["Branch Misses"] = counts.branch_misses();
state.counters["Cache References"] = counts.cache_references();
state.counters["Cache Misses"] = counts.cache_misses();
}
}
| #pragma once
template<typename B, typename R> static void ParseRecordsBenchmark(benchmark::State &state, const simdjson::padded_string &json) {
// Warmup and equality check (make sure the data is right!)
B bench;
bench.SetUp();
if (!bench.Run(json)) { state.SkipWithError("warmup tweet reading failed"); return; }
{
R reference;
reference.SetUp();
if (!reference.Run(json)) { state.SkipWithError("reference tweet reading failed"); return; }
// assert(bench.Records() == reference.Records());
reference.TearDown();
}
// Run the benchmark
event_collector<true> events;
events.start();
for (SIMDJSON_UNUSED auto _ : state) {
if (!bench.Run(json)) { state.SkipWithError("tweet reading failed"); return; }
}
auto bytes = json.size() * state.iterations();
state.SetBytesProcessed(bytes);
state.SetItemsProcessed(bench.Records().size() * state.iterations());
auto counts = events.end();
if (events.has_events()) {
state.counters["Ins./Byte"] = double(counts.instructions()) / double(bytes);
state.counters["Ins./Cycle"] = double(counts.instructions()) / double(counts.cycles());
state.counters["Cycles/Byte"] = double(counts.cycles()) / double(bytes);
state.counters["BranchMiss"] = benchmark::Counter(counts.branch_misses(), benchmark::Counter::kAvgIterations);
state.counters["CacheMiss"] = benchmark::Counter(counts.cache_misses(), benchmark::Counter::kAvgIterations);
state.counters["CacheRef"] = benchmark::Counter(counts.cache_references(), benchmark::Counter::kAvgIterations);
}
}
|
Fix methods return type ampersand location (NFC) | //===--- Algorithm.h - ------------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines helper algorithms, some of which are ported from C++14,
// which may not be available on all platforms yet.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_ALGORITHM_H
#define SWIFT_BASIC_ALGORITHM_H
namespace swift {
/// Returns the minimum of `a` and `b`, or `a` if they are equivalent.
template <typename T>
constexpr const T& min(const T &a, const T &b) {
return !(b < a) ? a : b;
}
/// Returns the maximum of `a` and `b`, or `a` if they are equivalent.
template <typename T>
constexpr const T& max(const T &a, const T &b) {
return (a < b) ? b : a;
}
} // end namespace swift
#endif /* SWIFT_BASIC_ALGORITHM_H */
| //===--- Algorithm.h - ------------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines helper algorithms, some of which are ported from C++14,
// which may not be available on all platforms yet.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_ALGORITHM_H
#define SWIFT_BASIC_ALGORITHM_H
namespace swift {
/// Returns the minimum of `a` and `b`, or `a` if they are equivalent.
template <typename T>
constexpr const T &min(const T &a, const T &b) {
return !(b < a) ? a : b;
}
/// Returns the maximum of `a` and `b`, or `a` if they are equivalent.
template <typename T>
constexpr const T &max(const T &a, const T &b) {
return (a < b) ? b : a;
}
} // end namespace swift
#endif /* SWIFT_BASIC_ALGORITHM_H */
|
Add test for path-sensitive uninit-val detection involving struct field. | // RUN: clang -checker-simple -verify %s
struct FPRec {
void (*my_func)(int * x);
};
int bar(int x);
int f1_a(struct FPRec* foo) {
int x;
(*foo->my_func)(&x);
return bar(x)+1; // no-warning
}
int f1_b() {
int x;
return bar(x)+1; // expected-warning{{Pass-by-value argument in function is undefined.}}
}
int f2() {
int x;
if (x+1) // expected-warning{{Branch}}
return 1;
return 2;
}
int f2_b() {
int x;
return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
}
int f3(void) {
int i;
int *p = &i;
if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
return 0;
else
return 1;
}
| // RUN: clang -checker-simple -verify %s
struct FPRec {
void (*my_func)(int * x);
};
int bar(int x);
int f1_a(struct FPRec* foo) {
int x;
(*foo->my_func)(&x);
return bar(x)+1; // no-warning
}
int f1_b() {
int x;
return bar(x)+1; // expected-warning{{Pass-by-value argument in function is undefined.}}
}
int f2() {
int x;
if (x+1) // expected-warning{{Branch}}
return 1;
return 2;
}
int f2_b() {
int x;
return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
}
int f3(void) {
int i;
int *p = &i;
if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
return 0;
else
return 1;
}
// RUN: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
};
struct s global;
void g(int);
void f4() {
int a;
if (global.data == 0)
a = 3;
if (global.data == 0)
g(a); // no-warning
}
|
Allow passing ints as arg | #include <stdio.h>
static
int r( int n )
{
printf("%d\n", n);
if (n <= 1)
return n;
if (n%2)
return r((n*3)+1);
return r(n/2);
}
int main ( void )
{
puts("Basic collatz fun - recursive C function");
r(15);
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
static
long r( long n )
{
printf("%ld\n", n);
if (n <= 1)
return n;
if (n%2)
return r((n*3)+1);
return r(n/2);
}
int main (int argc, char **argv)
{
long n = 15;
if (argc > 1)
n = strtol(argv[1], NULL, 10);
puts("Basic collatz fun - recursive C function");
r(n);
return 0;
}
|
Change tabs to spaces, Lets nip this one in the bud. | #include <linux/module.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <adm/uaccess.h>
// Module Stuff
MODULE_LICENCE("Apache"); // Change this to "GPL" if you get annoyed about
// the kernal playing a crying fit about non GPL stuff
MODULE_DESCRIPTION("A Markov device driver.");
MODULE_AUTHOR("Ben Cartwright-Cox");
static int dev_open(struct inode *, struct file *);
static int dev_rls(struct inode *, struct file *);
static ssize_t dev_read(strict file *, char *, size_t, loff_t *);
static ssize_t dev_write(strict file *, const char *, size_t, loff_t *);
| #include <linux/module.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <adm/uaccess.h>
// Module Stuff
MODULE_LICENCE("Apache"); // Change this to "GPL" if you get annoyed about
// the kernal playing a crying fit about non GPL stuff
MODULE_DESCRIPTION("A Markov device driver.");
MODULE_AUTHOR("Ben Cartwright-Cox");
static int dev_open(struct inode *, struct file *);
static int dev_rls(struct inode *, struct file *);
static ssize_t dev_read(strict file *, char *, size_t, loff_t *);
static ssize_t dev_write(strict file *, const char *, size_t, loff_t *);
|
Remove prototypes for nonexistent functions | #ifndef ASSOC_H
#define ASSOC_H
struct assoc {
/* how many powers of 2's worth of buckets we use */
unsigned int hashpower;
/* Main hash table. This is where we look except during expansion. */
hash_item** primary_hashtable;
/*
* Previous hash table. During expansion, we look here for keys that haven't
* been moved over to the primary yet.
*/
hash_item** old_hashtable;
/* Number of items in the hash table. */
unsigned int hash_items;
/* Flag: Are we in the middle of expanding now? */
bool expanding;
/*
* During expansion we migrate values with bucket granularity; this is how
* far we've gotten so far. Ranges from 0 .. hashsize(hashpower - 1) - 1.
*/
unsigned int expand_bucket;
/*
* serialise access to the hashtable
*/
cb_mutex_t lock;
};
/* associative array */
ENGINE_ERROR_CODE assoc_init(struct default_engine *engine);
void assoc_destroy(void);
hash_item *assoc_find(struct default_engine *engine, uint32_t hash,
const hash_key* key);
int assoc_insert(struct default_engine *engine, uint32_t hash,
hash_item *item);
void assoc_delete(struct default_engine *engine, uint32_t hash,
const hash_key* key);
int start_assoc_maintenance_thread(struct default_engine *engine);
void stop_assoc_maintenance_thread(struct default_engine *engine);
#endif
| #ifndef ASSOC_H
#define ASSOC_H
struct assoc {
/* how many powers of 2's worth of buckets we use */
unsigned int hashpower;
/* Main hash table. This is where we look except during expansion. */
hash_item** primary_hashtable;
/*
* Previous hash table. During expansion, we look here for keys that haven't
* been moved over to the primary yet.
*/
hash_item** old_hashtable;
/* Number of items in the hash table. */
unsigned int hash_items;
/* Flag: Are we in the middle of expanding now? */
bool expanding;
/*
* During expansion we migrate values with bucket granularity; this is how
* far we've gotten so far. Ranges from 0 .. hashsize(hashpower - 1) - 1.
*/
unsigned int expand_bucket;
/*
* serialise access to the hashtable
*/
cb_mutex_t lock;
};
/* associative array */
ENGINE_ERROR_CODE assoc_init(struct default_engine *engine);
void assoc_destroy(void);
hash_item *assoc_find(struct default_engine *engine, uint32_t hash,
const hash_key* key);
int assoc_insert(struct default_engine *engine, uint32_t hash,
hash_item *item);
void assoc_delete(struct default_engine *engine, uint32_t hash,
const hash_key* key);
#endif
|
Check that the gcc front-end is not doing inlining when not doing unit-at-a-time. | // RUN: %llvmgcc -S %s -O0 -o - -mllvm --disable-llvm-optzns | grep bar
// Check that the gcc inliner is turned off.
#include <stdio.h>
static __inline__ __attribute__ ((always_inline))
int bar (int x)
{
return 4;
}
void
foo ()
{
long long b = 1;
int Y = bar (4);
printf ("%d\n", Y);
}
| |
Modify void parseContents(0) as pure virtual function. | /*
* NovelProcessTool.h
*
* Created on: 2015年2月19日
* Author: nemo
*/
#ifndef SRC_NOVELPROCESSTOOL_H_
#define SRC_NOVELPROCESSTOOL_H_
#include <string>
#include <fstream>
#include <vector>
using namespace std;
class NovelProcessTool {
public:
NovelProcessTool();
virtual ~NovelProcessTool();
protected:
/// Check the work directory.
void checkWorkingDirectory();
/// Open in and out file.
int fileOpen(string novelName);
/// Close in and out files.
void fileClosed();
/// Analysis the temp folder.
void analysisFile();
fstream _fileInStream; ///< The file input stream.
fstream _fileOutStream; ///< The file out stream.
string _tempDir; ///< The temp folder directory path.
string _resultDir; ///< The result folder directory path.
vector<string> _inputNovel; ///< The input file name.
};
#endif /* SRC_NOVELPROCESSTOOL_H_ */
| /*
* NovelProcessTool.h
*
* Created on: 2015年2月19日
* Author: nemo
*/
#ifndef SRC_NOVELPROCESSTOOL_H_
#define SRC_NOVELPROCESSTOOL_H_
#include <string>
#include <fstream>
#include <vector>
using namespace std;
class NovelProcessTool {
public:
NovelProcessTool();
virtual ~NovelProcessTool();
protected:
/// Check the work directory.
void checkWorkingDirectory();
/// Open in and out file.
int fileOpen(string novelName);
/// Close in and out files.
void fileClosed();
/// Analysis the temp folder.
void analysisFile();
/// Novel tool action, implement in sub class.
virtual void parseContents() = 0;
fstream _fileInStream; ///< The file input stream.
fstream _fileOutStream; ///< The file out stream.
string _tempDir; ///< The temp folder directory path.
string _resultDir; ///< The result folder directory path.
vector<string> _inputNovel; ///< The input file name.
};
#endif /* SRC_NOVELPROCESSTOOL_H_ */
|
Support WS2812Serial Library on Teensy T4 | #ifndef __INC_FASTLED_ARM_MXRT1062_H
#define __INC_FASTLED_ARM_MXRT1062_H
#include "fastpin_arm_mxrt1062.h"
#include "fastspi_arm_mxrt1062.h"
#include "clockless_arm_mxrt1062.h"
#include "block_clockless_arm_mxrt1062.h"
#endif
| #ifndef __INC_FASTLED_ARM_MXRT1062_H
#define __INC_FASTLED_ARM_MXRT1062_H
#include "fastpin_arm_mxrt1062.h"
#include "fastspi_arm_mxrt1062.h"
#include "../k20/octows2811_controller.h"
#include "../k20/ws2812serial_controller.h"
#include "../k20/smartmatrix_t3.h"
#include "clockless_arm_mxrt1062.h"
#include "block_clockless_arm_mxrt1062.h"
#endif
|
Fix check the libextobjc when it is framework | //
// NSObject+ASPropertyAttributes.h
// AppScaffold Cocoa Category
//
// Created by Whirlwind on 15/4/3.
// Copyright (c) 2015年 AppScaffold. All rights reserved.
//
#import <Foundation/Foundation.h>
#if __has_include("EXTRuntimeExtensions.h")
// This category need pod 'libextobjc'
#import "EXTRuntimeExtensions.h"
@interface NSObject (PropertyAttributes)
+ (ext_propertyAttributes *)copyPropertyAttributesByName:(NSString *)name;
@end
#endif
| //
// NSObject+ASPropertyAttributes.h
// AppScaffold Cocoa Category
//
// Created by Whirlwind on 15/4/3.
// Copyright (c) 2015年 AppScaffold. All rights reserved.
//
#import <Foundation/Foundation.h>
#if __has_include(<libextobjc/EXTRuntimeExtensions.h>)
// This category need pod 'libextobjc'
#import <libextobjc/EXTRuntimeExtensions.h>
@interface NSObject (PropertyAttributes)
+ (ext_propertyAttributes *)copyPropertyAttributesByName:(NSString *)name;
@end
#endif
|
Create RightStick X and Y value get Function | #ifndef OI_H
#define OI_H
#include "WPILib.h"
#include "RobotMap.h"
#include <math.h>
class OI
{
private:
Joystick joystick;
public:
OI();
inline float GetXplusY(){
float val;
val = FractionOmitted(joystick.GetY() + joystick.GetX());
if(val > 1.2) val = 1.2;
if(val < -1.2) val = -1.2;
return val;
}
inline float GetXminusY(){
float val;
val = FractionOmitted(joystick.GetY() - joystick.GetX());
if(val > 1.2) val = 1.2;
if(val < -1.2) val = -1.2;
return val;
}
inline float GetStickX(){ return FractionOmitted(joystick.GetX()); }
inline float GetStickY(){ return FractionOmitted(joystick.GetY()); }
inline float GetStickTwist(){ return FractionOmitted(joystick.GetTwist()); }
inline float GetStickThrottle(){ return FractionOmitted(joystick.GetThrottle()); }
inline float FractionOmitted(float original){
if(fabsf(original) < 0.01 ){
original = 0;
}
return original;
}
};
#endif
| #ifndef OI_H
#define OI_H
#include "WPILib.h"
#include "RobotMap.h"
#include <math.h>
class OI
{
private:
Joystick joystick;
public:
OI();
inline float GetXplusY(){
float val;
val = FractionOmitted(joystick.GetY() + joystick.GetX());
if(val > 1.2) val = 1.2;
if(val < -1.2) val = -1.2;
return val;
}
inline float GetXminusY(){
float val;
val = FractionOmitted(joystick.GetY() - joystick.GetX());
if(val > 1.2) val = 1.2;
if(val < -1.2) val = -1.2;
return val;
}
inline float GetStickX(){ return FractionOmitted(joystick.GetX()); }
inline float GetStickY(){ return FractionOmitted(joystick.GetY()); }
inline float GetStickTwist(){ return FractionOmitted(joystick.GetTwist()); }
inline float GetStickThrottle(){ return FractionOmitted(joystick.GetThrottle()); }
inline float GetStickRightX(){ return FractionOmitted(joystick.GetRawAxis(5)); }
inline float GetStcikRightY(){ return FractionOmitted(joystick.GetRawAxis(6)); }
inline float FractionOmitted(float original){
if(fabsf(original) < 0.01 ){
original = 0;
}
return original;
}
};
#endif
|
Remove prototype for removed function | #ifndef SDL_EVENTS_H
#define SDL_EVENTS_H
#include "common.h"
#include "gba-thread.h"
#include <SDL.h>
#define SDL_BINDING_KEY 0x53444C4B
#define SDL_BINDING_BUTTON 0x53444C42
struct GBAVideoSoftwareRenderer;
struct GBASDLEvents {
struct GBAInputMap* bindings;
SDL_Joystick* joystick;
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Window* window;
int fullscreen;
int windowUpdated;
#endif
};
bool GBASDLInitEvents(struct GBASDLEvents*);
void GBASDLDeinitEvents(struct GBASDLEvents*);
void GBASDLHandleEvent(struct GBAThread* context, struct GBASDLEvents* sdlContext, const union SDL_Event* event);
enum GBAKey GBASDLMapButtonToKey(int button);
#endif
| #ifndef SDL_EVENTS_H
#define SDL_EVENTS_H
#include "common.h"
#include "gba-thread.h"
#include <SDL.h>
#define SDL_BINDING_KEY 0x53444C4B
#define SDL_BINDING_BUTTON 0x53444C42
struct GBAVideoSoftwareRenderer;
struct GBASDLEvents {
struct GBAInputMap* bindings;
SDL_Joystick* joystick;
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Window* window;
int fullscreen;
int windowUpdated;
#endif
};
bool GBASDLInitEvents(struct GBASDLEvents*);
void GBASDLDeinitEvents(struct GBASDLEvents*);
void GBASDLHandleEvent(struct GBAThread* context, struct GBASDLEvents* sdlContext, const union SDL_Event* event);
#endif
|
Fix silly think-o in tests. | // RUN: %clang_cc1 -triple arm64-apple-ios -O3 -emit-llvm -o - %s | FileCheck %s
void f0(void *a, void *b) {
__clear_cache(a,b);
// CHECK: call {{.*}} @__clear_cache
}
// CHECK: call {{.*}} @llvm.aarch64.rbit.i32(i32 %a)
void rbit(unsigned a) {
__builtin_arm_rbit(a);
}
// CHECK: call {{.*}} @llvm.aarch64.rbit.i64(i64 %a)
void rbit64(unsigned long long a) {
__builtin_arm_rbit64(a);
}
| // RUN: %clang_cc1 -triple arm64-apple-ios -O3 -emit-llvm -o - %s | FileCheck %s
void f0(void *a, void *b) {
__clear_cache(a,b);
// CHECK: call {{.*}} @__clear_cache
}
// CHECK: call {{.*}} @llvm.aarch64.rbit.i32(i32 %a)
unsigned rbit(unsigned a) {
return __builtin_arm_rbit(a);
}
// CHECK: call {{.*}} @llvm.aarch64.rbit.i64(i64 %a)
unsigned long long rbit64(unsigned long long a) {
return __builtin_arm_rbit64(a);
}
|
Add noreturn attribute to fatal_error | #ifndef UTIL_H
#define UTIL_H
#define estr(x) #x
#define ENUM(x) estr(x)
void exec_error(const char *msg, ...);
void fatal_error(const char *msg, ...);
typedef enum { FALSE, TRUE } BOOL;
#endif
| #ifndef UTIL_H
#define UTIL_H
#define estr(x) #x
#define ENUM(x) estr(x)
void exec_error(const char *msg, ...);
#ifdef _MSC_VER
__declspec(noreturn)
#endif
void fatal_error(const char *msg, ...)
#ifdef __GNUC__
__attribute__((noreturn))
#endif
;
typedef enum { FALSE, TRUE } BOOL;
#endif
|
Add the problem of 'Bugs in removeHead'. | /*
* PROBLEM
* Discuss the stack data structure. Implement a stack in C using either a linked list or a dynamic array, and justify your decision.
* Design the interface to your stack to be complete, consistent, and easy to use.
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
typedef struct Element {
struct Element *next;
void *data;
} Element;
bool push (Element **stack, void *data){
Element *elem = malloc(sizeof(Element));
if (!elem) return false;
elem->data = data;
elem->next = *stack;
*stack = elem;
return true;
}
bool pop( Element **stack, void **data ) {
Element *elem;
if (!(elem=*stack)) return false;
*data = elem->data;
*stack = elem->next;
free(elem);
return true;
}
bool createStack( Element **stack ) {
*stack = NULL;
return true;
}
bool deleteStack ( Element **stack ){
Element *next;
while ( *stack ) {
next = (*stack)->next;
free (*stack);
*stack = next;
}
return true;
}
void main() {
}
| #include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
typedef struct Element {
struct Element *next;
void *data;
} Element;
/*
* PROBLEM
* Discuss the stack data structure. Implement a stack in C using either a linked list or a dynamic array, and justify your decision.
* Design the interface to your stack to be complete, consistent, and easy to use.
*
* The solution contains the following push, pop, createStack, and deleteStack functions.
*/
bool push (Element **stack, void *data){
Element *elem = malloc(sizeof(Element));
if (!elem) return false;
elem->data = data;
elem->next = *stack;
*stack = elem;
return true;
}
bool pop( Element **stack, void **data ) {
Element *elem;
if (!(elem=*stack)) return false;
*data = elem->data;
*stack = elem->next;
free(elem);
return true;
}
bool createStack( Element **stack ) {
*stack = NULL;
return true;
}
bool deleteStack ( Element **stack ){
Element *next;
while ( *stack ) {
next = (*stack)->next;
free (*stack);
*stack = next;
}
return true;
}
/*
* PROBLEM
* Find and fix the bugs in the following C function that is supposed to remove the head element from a singly linked list:
* void removeHead (ListElement *head) {
* free(head); // Line 1
* head = head->next; // Line 2
* }
*/
void removeHead (Element **head) {
Element *temp;
if (head && *head) {
temp = (*head)->next;
free (*head);
*head = temp;
}
}
void main() {
}
|
Add some basic documentation for graylog_log | //
// MCGraylog.h
// MCGraylog
//
// Created by Jordan on 2013-05-06.
// Copyright (c) 2013 Marketcircle. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef enum {
GraylogLogLevelEmergency = 0,
GraylogLogLevelAlert = 1,
GraylogLogLevelCritical = 2,
GraylogLogLevelError = 3,
GraylogLogLevelWarning = 4,
GraylogLogLevelNotice = 5,
GraylogLogLevelInformational = 6,
GraylogLogLevelDebug = 7
} GraylogLogLevel;
/**
* Perform some up front work needed for all future log messages
*
* @return 0 on success, otherwise -1.
*/
int graylog_init(const char* address, const char* port);
void graylog_log(GraylogLogLevel lvl,
const char* facility,
const char* msg,
NSDictionary *data);
| //
// MCGraylog.h
// MCGraylog
//
// Created by Jordan on 2013-05-06.
// Copyright (c) 2013 Marketcircle. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef enum {
GraylogLogLevelEmergency = 0,
GraylogLogLevelAlert = 1,
GraylogLogLevelCritical = 2,
GraylogLogLevelError = 3,
GraylogLogLevelWarning = 4,
GraylogLogLevelNotice = 5,
GraylogLogLevelInformational = 6,
GraylogLogLevelDebug = 7
} GraylogLogLevel;
/**
* Perform some up front work needed for all future log messages
*
* @return 0 on success, otherwise -1.
*/
int graylog_init(const char* address, const char* port);
/**
* Log a message to the Graylog server (or some other compatible service).
*
* @param lvl Log level, the severity of the message
* @param facility Arbitrary string indicating the subsystem the message came
* from (i.e. sync, persistence, etc.)
* @param msg The actual log message
* @param data Any additional information that might be useful that is JSON
* serializable (e.g. numbers, strings, arrays, dictionaries)
*/
void graylog_log(GraylogLogLevel lvl,
const char* facility,
const char* msg,
NSDictionary* data);
|
Fix wrong bool definition in VirtIO library interface | //////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2007 Qumranet All Rights Reserved
//
// Module Name:
// osdep.h
//
// Abstract:
// Windows OS dependent definitions of data types
//
// Author:
// Yan Vugenfirer - February 2007.
//
//////////////////////////////////////////////////////////////////////////////////////////
#if defined(IGNORE_VIRTIO_OSDEP_H)
// to make simulation environment easy
#include "external_os_dep.h"
#else
#ifndef __OS_DEP_H
#define __OS_DEP_H
#include <ntddk.h>
#define ktime_t ULONGLONG
#define ktime_get() KeQueryPerformanceCounter(NULL).QuadPart
#define likely(x) x
#define unlikely(x) x
#define ENOSPC 1
#define BUG_ON(a) ASSERT(!(a))
#define WARN_ON(a)
#define BUG() ASSERT(0)
#if !defined(__cplusplus) && !defined(bool)
#define bool int
#define false FALSE
#define true TRUE
#endif
#define inline __forceinline
#ifdef DBG
#define DEBUG
#endif
#define mb() KeMemoryBarrier()
#define rmb() KeMemoryBarrier()
#define wmb() KeMemoryBarrier()
#define SMP_CACHE_BYTES 64
#endif
#endif
| //////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2007 Qumranet All Rights Reserved
//
// Module Name:
// osdep.h
//
// Abstract:
// Windows OS dependent definitions of data types
//
// Author:
// Yan Vugenfirer - February 2007.
//
//////////////////////////////////////////////////////////////////////////////////////////
#if defined(IGNORE_VIRTIO_OSDEP_H)
// to make simulation environment easy
#include "external_os_dep.h"
#else
#ifndef __OS_DEP_H
#define __OS_DEP_H
#include <ntddk.h>
#define ktime_t ULONGLONG
#define ktime_get() KeQueryPerformanceCounter(NULL).QuadPart
#define likely(x) x
#define unlikely(x) x
#define ENOSPC 1
#define BUG_ON(a) ASSERT(!(a))
#define WARN_ON(a)
#define BUG() ASSERT(0)
#if !defined(__cplusplus) && !defined(bool)
// Important note: in MSFT C++ bool length is 1 bytes
// C++ does not define length of bool
// inconsistent definition of 'bool' may create compatibility problems
#define bool u8
#define false FALSE
#define true TRUE
#endif
#define inline __forceinline
#ifdef DBG
#define DEBUG
#endif
#define mb() KeMemoryBarrier()
#define rmb() KeMemoryBarrier()
#define wmb() KeMemoryBarrier()
#define SMP_CACHE_BYTES 64
#endif
#endif
|
Make the destructor public. ddunbar, lemme know if you'd prefer a different fix, just trying to get the build bots happy again. | //===--- CodeGenAction.h - LLVM Code Generation Frontend Action -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/FrontendAction.h"
#include "llvm/ADT/OwningPtr.h"
namespace llvm {
class Module;
}
namespace clang {
class CodeGenAction : public ASTFrontendAction {
private:
unsigned Act;
llvm::OwningPtr<llvm::Module> TheModule;
protected:
CodeGenAction(unsigned _Act);
~CodeGenAction();
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
llvm::StringRef InFile);
virtual void EndSourceFileAction();
public:
/// takeModule - Take the generated LLVM module, for use after the action has
/// been run. The result may be null on failure.
llvm::Module *takeModule();
};
class EmitAssemblyAction : public CodeGenAction {
public:
EmitAssemblyAction();
};
class EmitBCAction : public CodeGenAction {
public:
EmitBCAction();
};
class EmitLLVMAction : public CodeGenAction {
public:
EmitLLVMAction();
};
class EmitLLVMOnlyAction : public CodeGenAction {
public:
EmitLLVMOnlyAction();
};
class EmitObjAction : public CodeGenAction {
public:
EmitObjAction();
};
}
| //===--- CodeGenAction.h - LLVM Code Generation Frontend Action -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/FrontendAction.h"
#include "llvm/ADT/OwningPtr.h"
namespace llvm {
class Module;
}
namespace clang {
class CodeGenAction : public ASTFrontendAction {
private:
unsigned Act;
llvm::OwningPtr<llvm::Module> TheModule;
protected:
CodeGenAction(unsigned _Act);
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
llvm::StringRef InFile);
virtual void EndSourceFileAction();
public:
~CodeGenAction();
/// takeModule - Take the generated LLVM module, for use after the action has
/// been run. The result may be null on failure.
llvm::Module *takeModule();
};
class EmitAssemblyAction : public CodeGenAction {
public:
EmitAssemblyAction();
};
class EmitBCAction : public CodeGenAction {
public:
EmitBCAction();
};
class EmitLLVMAction : public CodeGenAction {
public:
EmitLLVMAction();
};
class EmitLLVMOnlyAction : public CodeGenAction {
public:
EmitLLVMOnlyAction();
};
class EmitObjAction : public CodeGenAction {
public:
EmitObjAction();
};
}
|
Fix printing of names in stack dumps. | /* go-traceback.c -- stack backtrace for Go.
Copyright 2012 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
#include "config.h"
#include "runtime.h"
#include "go-string.h"
/* Print a stack trace for the current goroutine. */
void
runtime_traceback ()
{
uintptr pcbuf[100];
int32 c;
c = runtime_callers (1, pcbuf, sizeof pcbuf / sizeof pcbuf[0]);
runtime_printtrace (pcbuf, c);
}
void
runtime_printtrace (uintptr *pcbuf, int32 c)
{
int32 i;
for (i = 0; i < c; ++i)
{
struct __go_string fn;
struct __go_string file;
int line;
if (__go_file_line (pcbuf[i], &fn, &file, &line)
&& runtime_showframe (fn.__data))
{
runtime_printf ("%s\n", fn.__data);
runtime_printf ("\t%s:%d\n", file.__data, line);
}
}
}
| /* go-traceback.c -- stack backtrace for Go.
Copyright 2012 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
#include "config.h"
#include "runtime.h"
#include "go-string.h"
/* Print a stack trace for the current goroutine. */
void
runtime_traceback ()
{
uintptr pcbuf[100];
int32 c;
c = runtime_callers (1, pcbuf, sizeof pcbuf / sizeof pcbuf[0]);
runtime_printtrace (pcbuf, c);
}
void
runtime_printtrace (uintptr *pcbuf, int32 c)
{
int32 i;
for (i = 0; i < c; ++i)
{
struct __go_string fn;
struct __go_string file;
int line;
if (__go_file_line (pcbuf[i], &fn, &file, &line)
&& runtime_showframe (fn.__data))
{
runtime_printf ("%S\n", fn);
runtime_printf ("\t%S:%d\n", file, line);
}
}
}
|
Use condor_fix_signal.h, not <signal.h>, and include <sys/ioctl.h> properly. Also, NT specific changes committed to main trunk. | #include "_condor_fix_types.h"
#include "condor_fix_stdio.h"
#include <stdlib.h>
#include "condor_fix_unistd.h"
#include "condor_fix_limits.h"
#include "condor_fix_string.h"
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#if !defined(SUNOS41)
#include <signal.h>
#endif
| #if defined(WIN32)
#define NOGDI
#define NOUSER
#define NOSOUND
#include <winsock2.h>
#include <windows.h>
#include "_condor_fix_nt.h"
#include <stdlib.h>
#else
#include "_condor_fix_types.h"
#include "condor_fix_stdio.h"
#include <stdlib.h>
#include "condor_fix_unistd.h"
#include "condor_fix_limits.h"
#include "condor_fix_string.h"
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include "condor_fix_signal.h"
#if defined(Solaris)
# define BSD_COMP
#endif
#include <sys/ioctl.h>
#if defined(Solaris)
# undef BSD_COMP
#endif
#endif // defined(WIN32)
|
Enable escape in 31/04 for global-history to pass | // PARAM: --enable ana.int.interval --enable exp.partition-arrays.enabled --set ana.activated "['base', 'mallocWrapper', 'expRelation', 'var_eq']"
int *tmp;
int main ()
{
int pathbuf[2];
int *bound = pathbuf + sizeof(pathbuf)/sizeof(*pathbuf) - 1;
int *p = pathbuf;
while (p <= bound) {
*p = 1;
p++;
}
return 0;
}
| // PARAM: --enable ana.int.interval --enable exp.partition-arrays.enabled --set ana.activated "['base', 'mallocWrapper', 'escape', 'expRelation', 'var_eq']"
int *tmp;
int main ()
{
int pathbuf[2];
int *bound = pathbuf + sizeof(pathbuf)/sizeof(*pathbuf) - 1;
int *p = pathbuf;
while (p <= bound) {
*p = 1;
p++;
}
return 0;
}
|
Add race test where all accesses don't race | #include <pthread.h>
#include <stdio.h>
int myglobal;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
return NULL;
}
void *t_fun2(void *arg) {
pthread_mutex_lock(&mutex1);
myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex1);
return NULL;
}
int main(void) {
pthread_t id, id2;
pthread_create(&id, NULL, t_fun, NULL); // enter multithreaded
myglobal = 5; // NORACE
pthread_create(&id2, NULL, t_fun2, NULL);
pthread_mutex_lock(&mutex2);
myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex2);
return 0;
}
| |
Add TODOs for future work |
int asserter_is_false(int);
int set_empty(void);
int set_size(int);
int set_add(int, int);
int main(void)
{
// set_empty tests
if (asserter_is_false(set_empty() == 0)) return __LINE__;
// set_add tests
if (asserter_is_false(set_add(set_empty(), 0) != set_empty())) return __LINE__;
if (asserter_is_false(set_add(set_empty(), 1) != set_add(set_empty(), 2))) return __LINE__;
if (asserter_is_false(set_add(set_add(set_empty(), 1), 2) != set_add(set_empty(), 2))) return __LINE__;
if (asserter_is_false(set_add(set_add(set_empty(), 1), 1) == set_add(set_empty(), 1))) return __LINE__;
// set_size tests
if (asserter_is_false(set_size(set_empty()) == 0)) return __LINE__;
if (asserter_is_false(set_size(set_add(set_empty(), 1)) == 1)) return __LINE__;
if (asserter_is_false(set_size(set_add(set_add(set_empty(), 1), 2)) == 2)) return __LINE__;
return 0;
}
|
int asserter_is_false(int);
int set_empty(void);
int set_size(int);
int set_add(int, int);
int main(void)
{
// set_empty tests
if (asserter_is_false(set_empty() == 0)) return __LINE__;
// set_add tests
if (asserter_is_false(set_add(set_empty(), 0) != set_empty())) return __LINE__;
if (asserter_is_false(set_add(set_empty(), 1) != set_add(set_empty(), 2))) return __LINE__;
if (asserter_is_false(set_add(set_add(set_empty(), 1), 2) != set_add(set_empty(), 2))) return __LINE__;
if (asserter_is_false(set_add(set_add(set_empty(), 1), 1) == set_add(set_empty(), 1))) return __LINE__;
// TODO: add bigger than sizeof(int) * 8 elements
// set_size tests
if (asserter_is_false(set_size(set_empty()) == 0)) return __LINE__;
if (asserter_is_false(set_size(set_add(set_empty(), 1)) == 1)) return __LINE__;
if (asserter_is_false(set_size(set_add(set_add(set_empty(), 1), 2)) == 2)) return __LINE__;
// TODO: add more than sizeof(int) * 8 elements
return 0;
}
|
Change default socket path to /var/run/ | #ifndef __CR_SERVICE_H__
#define __CR_SERVICE_H__
#include "protobuf/rpc.pb-c.h"
#define CR_DEFAULT_SERVICE_ADDRESS "/tmp/criu_service.socket"
#define MAX_MSG_SIZE 1024
int cr_service(bool deamon_mode);
int send_criu_dump_resp(int socket_fd, bool success, bool restored);
extern struct _cr_service_client *cr_service_client;
extern unsigned int service_sk_ino;
#endif
| #ifndef __CR_SERVICE_H__
#define __CR_SERVICE_H__
#include "protobuf/rpc.pb-c.h"
#define CR_DEFAULT_SERVICE_ADDRESS "/var/run/criu_service.socket"
#define MAX_MSG_SIZE 1024
int cr_service(bool deamon_mode);
int send_criu_dump_resp(int socket_fd, bool success, bool restored);
extern struct _cr_service_client *cr_service_client;
extern unsigned int service_sk_ino;
#endif
|
Check that void function can return a value |
#include <stddef.h>
#include <stdint.h>
#include "cc1.h"
Symbol *curfun;
extern Node *convert(Node *np, Type *tp1, char iscast);
static void
Return(void)
{
Node *np;
Type *tp = curfun->type->type;
expect(RETURN);
np = expr();
if (np->type != tp) {
if ((np = convert(np, tp, 0)) == NULL)
error("incorrect type in return");
}
emitret(tp);
emitexp(np);
}
void
compound(void)
{
expect('{');
while (!accept('}')) {
switch (yytoken) {
case TYPE: case SCLASS: case TQUALIFIER:
decl();
break;
case RETURN:
Return();
break;
default:
emitexp(expr());
}
expect(';');
}
}
|
#include <stddef.h>
#include <stdint.h>
#include "cc1.h"
Symbol *curfun;
extern Node *convert(Node *np, Type *tp1, char iscast);
static void
Return(void)
{
Node *np;
Type *tp = curfun->type->type;
expect(RETURN);
np = expr();
if (np->type != tp) {
if (tp == voidtype)
warn(1, "function returning void returns a value");
else if ((np = convert(np, tp, 0)) == NULL)
error("incorrect type in return");
}
emitret(tp);
emitexp(np);
}
void
compound(void)
{
expect('{');
while (!accept('}')) {
switch (yytoken) {
case TYPE: case SCLASS: case TQUALIFIER:
decl();
break;
case RETURN:
Return();
break;
default:
emitexp(expr());
}
expect(';');
}
}
|
Fix testcase when building on darwin | // RUN: %clang -S %s -o - | FileCheck %s -check-prefix=ALLOWED
// RUN: not %clang -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED
int \uaccess = 0;
// ALLOWED: "곎ss":
// ALLOWED-NOT: "\uaccess":
// DENIED: warning: universal character names are only valid in C99 or C++; treating as '\' followed by identifier [-Wunicode]
// DENIED: error: expected identifier or '('
| // RUN: %clang --target=x86_64--linux-gnu -S %s -o - | FileCheck %s -check-prefix=ALLOWED
// RUN: not %clang --target=x86_64--linux-gnu -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED
int \uaccess = 0;
// ALLOWED: "곎ss":
// ALLOWED-NOT: "\uaccess":
// DENIED: warning: universal character names are only valid in C99 or C++; treating as '\' followed by identifier [-Wunicode]
// DENIED: error: expected identifier or '('
|
Add test case for hex floating point constants in < C99 mode - For: rdar://6096838 | /* RUN: clang -fsyntax-only -verify %s &&
* RUN: clang -std=gnu89 -fsyntax-only -verify %s &&
* RUN: clang -DPEDANTIC -pedantic -std=gnu89 -fsyntax-only -verify %s
*/
#ifdef PEDANTIC
long double d = 0x0.0000003ffffffff00000p-16357L; /* expected-warning {{ hexadecimal floating constants are a C99 feature }} */
#else
long double d = 0x0.0000003ffffffff00000p-16357L;
#endif
| |
UPDATE AIComp struct to initiate all variables except array | #ifndef AIDLL_AI_AICOMPONENT_H
#define AIDLL_AI_AICOMPONENT_H
#include <DirectXMath.h>
enum Pattern : int
{
AI_LINEAR = 1,
AI_CIRCULAR,
AI_ROUNTRIP,
AI_RANDOM,
AI_NONE = -1
};
__declspec(align(16)) struct AIComponent
{
// System variables
int AP_active = 0;
int AP_entityID = -1;
// AI variables
bool AP_triggered; // Trigger handling
int AP_time; // How long the component is active
float AP_speed; // Movement speed
DirectX::XMVECTOR AP_dir; // Normalised direction vector
DirectX::XMVECTOR AP_position;// Current position
int AP_pattern; // Traversing of waypoints
int AP_direction; // Direction in array, might be removed due to AP_pattern's existance
int AP_nextWaypointID; // Index to next waypoint
int AP_latestWaypointID; // Index to latest visited waypoint
int AP_nrOfWaypoint; // Nr of waypoints used in array
DirectX::XMVECTOR AP_waypoints[8];
void* operator new(size_t i) { return _aligned_malloc(i, 16); };
void operator delete(void* p) { _aligned_free(p); };
};
#endif | #ifndef AIDLL_AI_AICOMPONENT_H
#define AIDLL_AI_AICOMPONENT_H
#include <DirectXMath.h>
enum Pattern : int
{
AI_LINEAR = 1,
AI_CIRCULAR,
AI_ROUNTRIP,
AI_RANDOM,
AI_NONE = -1
};
__declspec(align(16)) struct AIComponent
{
// System variables
int AP_active = 0;
int AP_entityID = -1;
// AI variables
bool AP_triggered = false; // Trigger handling
int AP_time = 0; // How long the component is active
float AP_speed = 0; // Movement speed
DirectX::XMVECTOR AP_dir = DirectX::XMVECTOR();// Normalised direction vector
DirectX::XMVECTOR AP_position = DirectX::XMVECTOR();// Current position
int AP_pattern = AI_NONE; // Traversing of waypoints
int AP_direction = 0; // Direction in array, might be removed due to AP_pattern's existance
int AP_nextWaypointID = 0; // Index to next waypoint
int AP_latestWaypointID = 1;// Index to latest visited waypoint
int AP_nrOfWaypoint = 0; // Nr of waypoints used in array
DirectX::XMVECTOR AP_waypoints[8];
void* operator new(size_t i) { return _aligned_malloc(i, 16); };
void operator delete(void* p) { _aligned_free(p); };
};
#endif |
Revert changes on .h file. | /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
*
* libhostile
*
* Copyright (C) 2011 Data Differential, http://datadifferential.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 3 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
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#if defined(HAVE_LIBHOSTILE) && HAVE_LIBHOSTILE
void set_recv_close(bool arg, int frequency, int not_until_arg);
void set_send_close(bool arg, int frequency, int not_until_arg);
#else
#define set_recv_close(__arg, __frequency, __not_until_arg)
#define set_send_close(__arg, __frequency, __not_until_arg)
#endif
#ifdef __cplusplus
}
#endif
| /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
*
* libhostile
*
* Copyright (C) 2011 Data Differential, http://datadifferential.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 3 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
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
void set_recv_close(bool arg, int frequency, int not_until_arg);
void set_send_close(bool arg, int frequency, int not_until_arg);
#ifdef __cplusplus
}
#endif
|
Add full/half option for tree. | /*Build: gcc -std=c99 -o xmas3 xmas3.c*/
#include <stdlib.h>
#include <stdio.h>
int print_tree(int length)
{
int i = 0, j = 0;
for (i = 0;i<length;i++)
{
for (j = 0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
int main(int argc, char*argv[])
{
if (argc != 2)
{
printf("USAGE: %s [length]\n", argv[0]);
exit(-1);
}
int length = atoi(argv[1]);
print_tree(length);
return 0;
}
| /*Build: gcc -std=c99 -o xmas3 xmas3.c*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void usage(char *argv0)
{
printf("USAGE: %s [height] [half|full]\n", argv0);
exit(-1);
}
int print_tree(int height, char half)
{
int i = 0, j = 0;
if (half) // Half tree
{
for (i = 0;i < height;i++)
{
for (j = 0;j <= i;j++)
{
printf("*");
}
printf("\n");
}
}
else if (!half) // full tree
{
int max_width = 2 * (height - 1) + 1;
for (i = 0;i < height;i++)
{
int width = i + height;
for (j = 0;j < width;j++)
{
if (j < (height-1) - i)
printf(" ");
else
printf("*");
}
printf("\n");
}
}
return 0;
}
int main(int argc, char *argv[])
{
if (argc != 3)
usage(argv[0]);
int height = atoi(argv[1]);
char half = -1;
if (!strncmp("half", argv[2], sizeof 4))
half = 1;
else if(!strncmp("full", argv[2], sizeof 4))
half = 0;
else
usage(argv[0]);
print_tree(height, half);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.