Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Fix runtime bug caused by typo. | /*
* Copyright (c) 2015 Nathan Osman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef QHTTPENGINE_QHTTPBASICAUTHPRIVATE_H
#define QHTTPENGINE_QHTTPBASICAUTHPRIVATE_H
#include <QMap>
#include <QObject>
class QHttpBasicAuthPrivate : public QObject
{
Q_OBJECT
public:
explicit QHttpBasicAuthPrivate(QObject *parent, const QString &realm);
const QString &realm;
QMap<QString, QString> map;
};
#endif // QHTTPENGINE_QHTTPBASICAUTHPRIVATE_H
| /*
* Copyright (c) 2015 Nathan Osman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef QHTTPENGINE_QHTTPBASICAUTHPRIVATE_H
#define QHTTPENGINE_QHTTPBASICAUTHPRIVATE_H
#include <QMap>
#include <QObject>
class QHttpBasicAuthPrivate : public QObject
{
Q_OBJECT
public:
explicit QHttpBasicAuthPrivate(QObject *parent, const QString &realm);
const QString realm;
QMap<QString, QString> map;
};
#endif // QHTTPENGINE_QHTTPBASICAUTHPRIVATE_H
|
Add memory module to package header | /**
* ---------------------------------------------------------------------------
* @file core.h
* @brief The package header.
*
*/
#pragma once
#include "./types.h"
#include "./error.h"
#include "./fault.h"
#include "./trace.h"
#include "./results.h"
#include "./cast.h"
| /**
* ---------------------------------------------------------------------------
* @file core.h
* @brief The package header.
*
*/
#pragma once
#include "./types.h"
#include "./error.h"
#include "./fault.h"
#include "./trace.h"
#include "./results.h"
#include "./cast.h"
#include "./memory.h"
|
Add missing inline for accessing factors in fmpz_mod_poly. | /*=============================================================================
This file is part of FLINT.
FLINT 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.
FLINT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FLINT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2015 Tommy Hofmann
******************************************************************************/
#define FMPZ_MOD_POLY_FACTOR_INLINES_C
#define ulong ulongxx /* interferes with system includes */
#include <stdlib.h>
#include <stdio.h>
#undef ulong
#include <gmp.h>
#include "flint.h"
#include "ulong_extras.h"
#include "nmod_poly.h"
void fmpz_mod_poly_factor_get_fmpz_mod_poly(fmpz_mod_poly_t z, fmpz_mod_poly_factor_t fac, slong i)
{
fmpz_mod_poly_set(z, fac->p + i);
}
| |
Add missing key comparison function parameter | #include <stdlib.h>
#ifndef __BST_H__
#define __BST_H__
struct BSTNode;
struct BST;
typedef struct BSTNode BSTNode;
typedef struct BST BST;
BST* BST_Create(void);
BSTNode* BSTNode_Create(void* k);
void BST_Inorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Preorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Postorder_Tree_Walk(BST* T, void (f)(void*));
BSTNode* BST_Tree_Search(BST* T, void* k, int (f)(void*, void*));
BSTNode* BST_Iterative_Tree_Search(BST* T, void* k, int (f)(void*, void*));
#endif | #include <stdlib.h>
#ifndef __BST_H__
#define __BST_H__
struct BSTNode;
struct BST;
typedef struct BSTNode BSTNode;
typedef struct BST BST;
BST* BST_Create(void);
BSTNode* BSTNode_Create(void* k);
void BST_Inorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Preorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Postorder_Tree_Walk(BST* T, void (f)(void*));
BSTNode* BST_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Iterative_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
#endif |
Add List Node creation function implementation | #include "list.h"
struct ListNode
{
ListNode* prev;
ListNode* next;
void* k;
};
struct List
{
ListNode* head;
};
List* List_Create(void)
{
List* l = (List *)malloc(sizeof(List));
l->head = NULL;
return l;
}
| #include "list.h"
struct ListNode
{
ListNode* prev;
ListNode* next;
void* k;
};
struct List
{
ListNode* head;
};
List* List_Create(void)
{
List* l = (List *)malloc(sizeof(List));
l->head = NULL;
return l;
}
ListNode* ListNode_Create(void* k)
{
ListNode* n = (ListNode *)malloc(sizeof(ListNode));
n->prev = NULL;
n->next = NULL;
n->k = k;
return n;
}
|
Rewrite match line to be friendlier to misc buildbots. | // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
// Radar 8026855
int test (void *src) {
register int w0 asm ("0");
// CHECK: call i32 asm "ldr $0, [$1]", "={ax},r,~{dirflag},~{fpsr},~{flags}"(i8* %tmp)
asm ("ldr %0, [%1]": "=r" (w0): "r" (src));
return w0;
}
| // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
// Radar 8026855
int test (void *src) {
register int w0 asm ("0");
// CHECK: call i32 asm "ldr $0, [$1]", "={ax},r,~{dirflag},~{fpsr},~{flags}"(i8*
asm ("ldr %0, [%1]": "=r" (w0): "r" (src));
return w0;
}
|
Test for new system clock | #ifndef CODETREE_H
#define CODETREE_H
#include "constants.h"
typedef struct operation{
char *sign;
bool isCommunitative;
bool isAssociative;
int precedence;
} Operation;
typedef struct node{
char *name;
Operation *op;
struct node *left;
struct node *right;
bool isRoot;
int rank;
bool isConstant;
} Node;
typedef struct list_item {
struct list_item *left;
struct list_item *right;
Node *data;
} ListItem;
/* functions for tree nodes*/
Operation *newOp(char *sign, int com, int ass, int precedence);
Node *newNode(char *data);
Node *newNodeWithChildren(char *data, Operation *op, Node *left, Node *right);
/* functions for lists */
ListItem * new_list();
ListItem * insert_right(struct list_item *list, Node* data);
ListItem * delete(struct list_item *list);
Node *nodeByName(ListItem* forest, char * name);
#endif /* CODETREE_H */
| #ifndef CODETREE_H
#define CODETREE_H
#include "constants.h"
typedef struct operation{
char *sign;
bool isCommunitative;
bool isAssociative;
int precedence;
} Operation;
typedef struct node{
char *name;
Operation *op;
struct node *left;
struct node *right;
bool isRoot;
int rank;
bool isConstant;
} Node;
typedef struct list_item {
struct list_item *left;
struct list_item *right;
Node *data;
} ListItem;
/* functions for tree nodes*/
Operation *newOp(char *sign, int com, int ass, int precedence);
Node *newNode(char *data);
Node *newNodeWithChildren(char *data, Operation *op, Node *left, Node *right);
/* functions for lists */
ListItem * new_list();
ListItem * insert_right(struct list_item *list, Node* data);
ListItem * delete(struct list_item *list);
Node *nodeByName(ListItem* forest, char * name);
#endif /* CODETREE_H */
|
Fix test due to mempool internal change. | /* EINA - EFL data type library
* Copyright (C) 2008 Cedric Bail
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#include "Eina.h"
#include "eina_suite.h"
START_TEST(eina_simple)
{
fail_if(!eina_init());
fail_if(eina_shutdown() != 0);
}
END_TEST
void eina_test_main(TCase *tc)
{
tcase_add_test(tc, eina_simple);
}
| /* EINA - EFL data type library
* Copyright (C) 2008 Cedric Bail
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#include "Eina.h"
#include "eina_suite.h"
#include <stdio.h>
START_TEST(eina_simple)
{
/* Eina_error as already been initialized by eina_hash
that was called by eina_mempool_init that's why we don't have 0 here */
fail_if(eina_init() != 2);
fail_if(eina_shutdown() != 1);
}
END_TEST
void eina_test_main(TCase *tc)
{
tcase_add_test(tc, eina_simple);
}
|
Add throw to what() function for linux compile | #pragma once
#include <exception>
#include <string>
namespace core {
class Exception :
public std::exception
{
public:
Exception();
virtual ~Exception();
virtual char const * what() const override;
protected:
void setMessage(const std::string& message);
private:
std::string _message;
};
} | #pragma once
#include <exception>
#include <string>
namespace core {
class Exception :
public std::exception
{
public:
Exception();
virtual ~Exception();
virtual char const * what() const throw() override;
protected:
void setMessage(const std::string& message);
private:
std::string _message;
};
} |
Add property for search item object | //
// SearchItem.h
// bikepath
//
// Created by Farheen Malik on 8/15/14.
// Copyright (c) 2014 Bike Path. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SearchItem : NSObject
@end
| //
// SearchItem.h
// bikepath
//
// Created by Farheen Malik on 8/15/14.
// Copyright (c) 2014 Bike Path. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SearchItem : NSObject
@property NSString *searchQuery;
@property (readonly) NSDate *creationDate;
@end
|
Solve Distance Between Two Points in c | #include <math.h>
#include <stdio.h>
int main() {
float x1, y1, x2, y2;
scanf("%f %f", &x1, &y1);
scanf("%f %f", &x2, &y2);
printf("%.4f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}
| |
Add ASH_EXPORT to base class of exported WindowSelectorController. | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_WINDOW_SELECTOR_DELEGATE_H_
#define ASH_WM_WINDOW_SELECTOR_DELEGATE_H_
#include "base/compiler_specific.h"
namespace aura {
class Window;
}
namespace ash {
// Implement this class to handle the selection event from WindowSelector.
class WindowSelectorDelegate {
public:
// Invoked when a window is selected.
virtual void OnWindowSelected(aura::Window* window) = 0;
// Invoked if selection is canceled.
virtual void OnSelectionCanceled() = 0;
protected:
virtual ~WindowSelectorDelegate() {}
};
} // namespace ash
#endif // ASH_WM_WINDOW_SELECTOR_DELEGATE_H_
| // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_WINDOW_SELECTOR_DELEGATE_H_
#define ASH_WM_WINDOW_SELECTOR_DELEGATE_H_
#include "ash/ash_export.h"
#include "base/compiler_specific.h"
namespace aura {
class Window;
}
namespace ash {
// Implement this class to handle the selection event from WindowSelector.
class ASH_EXPORT WindowSelectorDelegate {
public:
// Invoked when a window is selected.
virtual void OnWindowSelected(aura::Window* window) = 0;
// Invoked if selection is canceled.
virtual void OnSelectionCanceled() = 0;
protected:
virtual ~WindowSelectorDelegate() {}
};
} // namespace ash
#endif // ASH_WM_WINDOW_SELECTOR_DELEGATE_H_
|
Add expected fail triple x86_64-pc-windows-gnu to test as x86_64-w64-mingw32 is already there | // RUN: %clang_cc1 %s -o - -emit-llvm | FileCheck %s
// XFAIL: aarch64, arm64, x86_64-pc-win32, x86_64-w64-mingw32
// PR1513
// AArch64 ABI actually requires the reverse of what this is testing: the callee
// does any extensions and remaining bits are unspecified.
// Win64 ABI does expect extensions for type smaller than 64bits.
// Technically this test wasn't written to test that feature, but it's a
// valuable check nevertheless.
struct s{
long a;
long b;
};
void f(struct s a, char *b, signed char C) {
// CHECK: i8 signext
}
| // RUN: %clang_cc1 %s -o - -emit-llvm | FileCheck %s
// XFAIL: aarch64, arm64, x86_64-pc-win32, x86_64-w64-mingw32, x86_64-pc-windows-gnu
// PR1513
// AArch64 ABI actually requires the reverse of what this is testing: the callee
// does any extensions and remaining bits are unspecified.
// Win64 ABI does expect extensions for type smaller than 64bits.
// Technically this test wasn't written to test that feature, but it's a
// valuable check nevertheless.
struct s{
long a;
long b;
};
void f(struct s a, char *b, signed char C) {
// CHECK: i8 signext
}
|
Correct inconsistent use of override. | //===- BreakConstantGEPs.h - Change constant GEPs into GEP instructions --- --//
//
// The SAFECode Compiler
//
// 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 pass changes all GEP constant expressions into GEP instructions. This
// permits the rest of SAFECode to put run-time checks on them if necessary.
//
//===----------------------------------------------------------------------===//
#ifndef BREAKCONSTANTGEPS_H
#define BREAKCONSTANTGEPS_H
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
namespace llvm {
//
// Pass: BreakConstantGEPs
//
// Description:
// This pass modifies a function so that it uses GEP instructions instead of
// GEP constant expressions.
//
struct BreakConstantGEPs : public FunctionPass {
private:
// Private methods
// Private variables
public:
static char ID;
BreakConstantGEPs() : FunctionPass(ID) {}
StringRef getPassName() const override {
return "Remove Constant GEP Expressions";
}
virtual bool runOnFunction (Function & F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
// This pass does not modify the control-flow graph of the function
AU.setPreservesCFG();
}
};
} // namespace llvm
#endif
| //===- BreakConstantGEPs.h - Change constant GEPs into GEP instructions --- --//
//
// The SAFECode Compiler
//
// 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 pass changes all GEP constant expressions into GEP instructions. This
// permits the rest of SAFECode to put run-time checks on them if necessary.
//
//===----------------------------------------------------------------------===//
#ifndef BREAKCONSTANTGEPS_H
#define BREAKCONSTANTGEPS_H
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
namespace llvm {
//
// Pass: BreakConstantGEPs
//
// Description:
// This pass modifies a function so that it uses GEP instructions instead of
// GEP constant expressions.
//
struct BreakConstantGEPs : public FunctionPass {
private:
// Private methods
// Private variables
public:
static char ID;
BreakConstantGEPs() : FunctionPass(ID) {}
StringRef getPassName() const override {
return "Remove Constant GEP Expressions";
}
virtual bool runOnFunction (Function & F) override;
virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
// This pass does not modify the control-flow graph of the function
AU.setPreservesCFG();
}
};
} // namespace llvm
#endif
|
Add all the glue together to have an interpreter actually run. | // This is the actual main program
int
main(int argc, const char *argv[])
{
}
| // This is the actual main program
#include "lorito.h"
#include "microcode.h"
#include "interp.h"
#include "loader.h"
int
main(int argc, const char *argv[])
{
int i;
Lorito_Interp *interp;
if (argc < 2)
{
fprintf(stderr, "Usage: lorito <bytecodefiles>\n");
return 255;
}
interp = lorito_init();
for (i = 1; i < argc; i++)
{
loadbc(interp, argv[i]);
}
return lorito_run(interp);
}
|
Update files, Alura, Introdução a C - Parte 2, Aula 2.3 | #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';
palavrasecreta[8] = '\0';
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]);
*/
}
| #include <stdio.h>
int main() {
char palavrasecreta[20];
sprintf(palavrasecreta, "MELANCIA");
int acertou = 0;
int enforcou = 0;
do {
// comecar o nosso jogo!!
} while(!acertou && !enforcou);
}
|
Add basic test for do while statements | /*
name: TEST008
description: Basic do while loop
output:
F1
G1 F1 main
{
-
A2 I x
A2 #I0 :I
d
L3
A2 A2 #I1 +I :I
j L3 A2 #IA <I
b
L4
d
L5
A2 A2 #I1 +I :I
j L5 A2 #I14 <I
b
L6
yI A2 #I14 -I
}
*/
int
main()
{
int x;
x = 0;
do
x = x + 1;
while(x < 10);
do {
x = x + 1;
} while(x < 20);
return x - 20;
}
| |
Add example for log with formatting args | // cc log_example.c log.c -rdynamic
#include "log.h"
char
make_segmentfault()
{
char *s = NULL;
char ch = s[1]; // segment fault
return ch;
}
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, error message can be seen */
log_info("info message");
log_warn("warn message");
log_error("error message");
/* will log trace back on segmentfault automatically */
make_segmentfault();
return 0;
}
| // cc log_example.c log.c -rdynamic
#include "log.h"
char
make_segmentfault()
{
char *s = NULL;
char ch = s[1]; // segment fault
return ch;
}
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, error message can be seen */
log_info("info message");
log_warn("warn message");
log_error("error message: %s", "someting wrong");
/* will log trace back on segmentfault automatically */
make_segmentfault();
return 0;
}
|
Add SET_STATIC opcode to enum | #pragma once
enum class Opcode {
INVALID = 0,
NOP = 1,
PUSH = 2,
PUSH_STATIC = 3,
POP = 4,
SET = 5,
CALL = 6,
CALL_METHOD = 7,
CALL_INTERNAL = 8,
RETURN = 9,
PRINT = 10,
METHOD_END = 11
};
| #pragma once
enum class Opcode {
INVALID = 0,
NOP = 1,
PUSH = 2, // pushes a reference into the stack
PUSH_STATIC = 3, // pushes static data into the stack
POP = 4, // pop anything to void
SET = 5, // pop a reference from the stack and assign it
SET_STATIC = 6, // set a reference to static data
CALL = 7,
CALL_METHOD = 8,
CALL_INTERNAL = 9,
RETURN = 10,
PRINT = 11,
METHOD_END = 12
};
|
Add a big file test | /*
* 06/21/2016: bigfile2.c
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
main(int argc, char *argv[])
{
long val;
char *buf, *filename;
int error = 0, readonly = 0;
size_t i, j, c, fd, seed, size, bsize, nblocks;
bsize = 5678;
nblocks = 12345;
seed = getpid();
while ((c = getopt(argc, argv, "b:s:n:r")) != -1) {
switch (c) {
case 'b':
bsize = atoi(optarg);
break;
case 's':
seed = atoi(optarg);
break;
case 'n':
nblocks = atoi(optarg);
break;
case 'r':
readonly = 1;
break;
}
}
if (optind > argc - 1) {
printf("Usage: a.out [-s seed] [-b bsize] [-n nblocks ] filename\n");
exit(0);
}
filename = argv[optind];
if (readonly)
fd = open(filename, O_RDONLY);
else
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600);
if (fd < 0) {
printf("Fail to open file, errno = %d\n", errno);
exit(0);
}
buf = malloc(bsize);
if (buf == NULL) {
printf("Fail to allocate memory, errno = %d\n", errno);
exit(0);
}
srandom(seed);
printf("Seed = %d, file size = %ld\n", seed, nblocks * bsize);
for (i = 0; i < nblocks; i++) {
if (readonly)
size = read(fd, buf, bsize);
else {
for (j = 0; j < bsize; j++) {
val = random();
//printf("%lx\n", val);
buf[j] = val & 0xff;
}
size = write(fd, buf, bsize);
}
if (size != bsize) {
printf("Fail to %s file, errno = %d\n",
readonly ? "read" : "write", errno);
break;
}
if (!readonly)
continue;
for (j = 0; j < bsize; j++) {
if (buf[j] != random() & 0xff) {
printf("Unexpected data at offset = %ld\n",
i * nblocks * j);
error++;
break;
}
}
if (error > 20)
break;
}
close(fd);
}
| |
Print name of test before parsing it - easier to identify segfaulting tests. On branch master Your branch is up-to-date with 'github/master'. | /*!
@file main.c
@brief A simple test program for the C library code.
*/
#include "stdio.h"
#include "verilog_parser.h"
int main(int argc, char ** argv)
{
if(argc < 2)
{
printf("ERROR. Please supply at least one file path argument.\n");
return 1;
}
else
{
int F = 0;
for(F = 1; F < argc; F++)
{
// Load the file.
FILE * fh = fopen(argv[F], "r");
// Instance the parser.
verilog_parser parser = verilog_file_parse(fh);
// Parse the file and store the result.
int result = verilog_parse_buffer(parser);
verilog_free_parser(parser);
fclose(fh);
if(result == 0)
{
printf("Parse successful for %s\n",argv[F]);
}
else
{
printf("Parse failed for %s\n",argv[F]);
}
}
}
return 0;
}
| /*!
@file main.c
@brief A simple test program for the C library code.
*/
#include "stdio.h"
#include "verilog_parser.h"
int main(int argc, char ** argv)
{
if(argc < 2)
{
printf("ERROR. Please supply at least one file path argument.\n");
return 1;
}
else
{
int F = 0;
for(F = 1; F < argc; F++)
{
printf("%s", argv[F]);
fflush(stdout);
// Load the file.
FILE * fh = fopen(argv[F], "r");
// Instance the parser.
verilog_parser parser = verilog_file_parse(fh);
// Parse the file and store the result.
int result = verilog_parse_buffer(parser);
verilog_free_parser(parser);
fclose(fh);
if(result == 0)
{
printf(" - Parse successful\n");
}
else
{
printf(" - Parse failed for\n");
}
}
}
return 0;
}
|
Test that simple expressions are simplified at -O0 | // RUN: %clang %s -O0 -emit-llvm -S -o - | FileCheck %s
void foo();
void bar();
void fold_if(int a, int b) {
// CHECK: define {{.*}} @fold_if(
// CHECK-NOT: = phi
// CHECK: }
if (a && b)
foo();
else
bar();
}
void fold_for(int a, int b) {
// CHECK: define {{.*}} @fold_for(
// CHECK-NOT: = phi
// CHECK: }
for (int i = 0; a && i < b; ++i) foo();
for (int i = 0; a || i < b; ++i) bar();
}
| |
Add BST preorder traversal function implementation | #include "bst.h"
static void BST_Transplant(BST* T, BSTNode* u, BSTNode* v);
struct BSTNode
{
BSTNode* left;
BSTNode* right;
BSTNode* p;
void* k;
};
struct BST
{
BSTNode* root;
};
BST* BST_Create(void)
{
BST* T = (BST* )malloc(sizeof(BST));
T->root = NULL;
return T;
}
BSTNode* BSTNode_Create(void* k)
{
BSTNode* n = (BSTNode* )malloc(sizeof(BSTNode));
n->left = NULL;
n->right = NULL;
n->p = NULL;
n->k = k;
}
void BST_Inorder_Tree_Walk(BSTNode* n, void (f)(void*))
{
if (n != NULL)
{
BST_Inorder_Tree_Walk(n->left, f);
f(n->k);
BST_Inorder_Tree_Walk(n->right, f);
}
}
| #include "bst.h"
static void BST_Transplant(BST* T, BSTNode* u, BSTNode* v);
struct BSTNode
{
BSTNode* left;
BSTNode* right;
BSTNode* p;
void* k;
};
struct BST
{
BSTNode* root;
};
BST* BST_Create(void)
{
BST* T = (BST* )malloc(sizeof(BST));
T->root = NULL;
return T;
}
BSTNode* BSTNode_Create(void* k)
{
BSTNode* n = (BSTNode* )malloc(sizeof(BSTNode));
n->left = NULL;
n->right = NULL;
n->p = NULL;
n->k = k;
}
void BST_Inorder_Tree_Walk(BSTNode* n, void (f)(void*))
{
if (n != NULL)
{
BST_Inorder_Tree_Walk(n->left, f);
f(n->k);
BST_Inorder_Tree_Walk(n->right, f);
}
}
void BST_Preorder_Tree_Walk(BSTNode* n, void (f)(void*))
{
if (n != NULL)
{
f(n->k);
BST_Preorder_Tree_Walk(n->left, f);
BST_Preorder_Tree_Walk(n->right, f);
}
}
|
Add missing z_abs. In BSD tradition this is in libm.a. | /*
* cabs() wrapper for hypot().
*
* Written by J.T. Conklin, <jtc@wimsey.com>
* Placed into the Public Domain, 1994.
*/
#include <math.h>
struct complex {
double x;
double y;
};
double
cabs(z)
struct complex z;
{
return hypot(z.x, z.y);
}
| /*
* cabs() wrapper for hypot().
*
* Written by J.T. Conklin, <jtc@wimsey.com>
* Placed into the Public Domain, 1994.
*/
#include <math.h>
struct complex {
double x;
double y;
};
double
cabs(z)
struct complex z;
{
return hypot(z.x, z.y);
}
double
z_abs(z)
struct complex *z;
{
return hypot(z->x, z->y);
}
|
Use sigaction instead of signal | #include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
char **params;
// double fork to avoid zombies and exec the python server
void signal_handler() {
if (fork() == 0) {
execv(params[0], params);
}
return;
}
int main(int argc, char *argv[]) {
int k;
params = (char**)malloc((3+argc-1)*sizeof(char*));
params[0] = "/usr/bin/python";
params[1] = "/server.py";
for (k = 1; k < argc; k++) {
params[k+1] = argv[k];
}
params[argc+1] = NULL;
signal(SIGURG, signal_handler);
while (1) {
pause(); // sleep forever, we're init for the ns
}
return 0;
}
| #include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
char **params;
/*
* Launch the lambda server.
*/
void signal_handler() {
if (fork() == 0) {
execv(params[0], params);
}
return;
}
/*
* Install the handler and block all other signals while handling
* the signal. Reset the signal handler after caught to default.
*/
void install_handler() {
struct sigaction setup_action;
sigset_t block_mask;
sigfillset(&block_mask);
setup_action.sa_handler = signal_handler;
setup_action.sa_mask = block_mask;
setup_action.sa_flags = SA_RESETHAND;
sigaction(SIGURG, &setup_action, NULL);
}
int main(int argc, char *argv[]) {
int k;
params = (char**)malloc((3+argc-1)*sizeof(char*));
params[0] = "/usr/bin/python";
params[1] = "/server.py";
for (k = 1; k < argc; k++) {
params[k+1] = argv[k];
}
params[argc+1] = NULL;
install_handler();
while (1) {
pause(); // sleep forever, we're init for the ns
}
return 0;
}
|
Make LED block compatible with PIL in model reference | #ifndef __MDAQLED_H
#define __MDAQLED_H
#ifndef MATLAB_MEX_FILE
#include "gpio.h"
#endif
void mdaqled_init(void);
void mdaqled_set(unsigned char led, unsigned char state);
#endif
| #ifndef __MDAQLED_H
#define __MDAQLED_H
#if (!defined MATLAB_MEX_FILE) && (!defined MDL_REF_SIM_TGT)
#include "gpio.h"
#endif
void mdaqled_init(void);
void mdaqled_set(unsigned char led, unsigned char state);
#endif
|
Return codes of XLib functions are handled | #include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
int main(int argc, char *argv[])
{
Display *display = XOpenDisplay(NULL);
XkbEvent event;
XkbRF_VarDefsRec varDefs;
XkbStateRec state;
char *tmp = NULL;
char *groups[XkbNumKbdGroups];
int num_groups = 0;
XkbSelectEventDetails(display, XkbUseCoreKbd, XkbStateNotify, XkbGroupLockMask, XkbGroupLockMask);
XkbRF_GetNamesProp(display, &tmp, &varDefs);
groups[num_groups] = strtok(varDefs.layout, ",");
printf("%s\r\n", groups[num_groups]);
while(groups[num_groups])
{
num_groups++;
groups[num_groups] = strtok(NULL, ",");
}
XkbGetState(display, XkbUseCoreKbd, &state);
while (1)
{
XNextEvent(display, &event.core);
printf("%s\r\n", groups[event.state.locked_group]);
}
return XCloseDisplay(display);
}
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
#define DELIMETER ","
#define LAYOUT_FORMAT "%s\r\n"
int main(int argc, char *argv[])
{
int rc = EXIT_FAILURE;
XkbEvent event;
XkbRF_VarDefsRec vd;
XkbStateRec state;
char *groups[XkbNumKbdGroups];
unsigned char num_groups = 0;
char *display_name = NULL;
Display *display = NULL;
if (!(display = XOpenDisplay(display_name)))
goto out;
if (XkbSelectEventDetails(display,
XkbUseCoreKbd,
XkbStateNotify,
XkbGroupLockMask,
XkbGroupLockMask) != True)
goto out_close_display;
if (XkbRF_GetNamesProp(display, NULL, &vd) != True)
goto out_close_display;
while ((groups[num_groups] = strsep(&vd.layout, DELIMETER))) num_groups++;
if (XkbGetState(display, XkbUseCoreKbd, &state) == Success)
printf(LAYOUT_FORMAT, groups[state.locked_group]);
while (1)
if (XNextEvent(display, &event.core) == Success)
printf(LAYOUT_FORMAT, groups[event.state.locked_group]);
XFree(vd.model);
XFree(vd.layout);
XFree(vd.variant);
XFree(vd.options);
out_close_display:
rc = XCloseDisplay(display);
out:
return rc;
}
|
Add fifth exercise from chapter 5. | /*
Program that verifies that duplicated file descriptors share a file offset and
open file status flags.
*/
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
void exitErr(const char* msg);
int main(__attribute__((unused)) int _argc, __attribute__((unused)) char **argv)
{
int fd1, fd2, flagsBefore, flagsAfter;
off_t offsetBefore, offsetAfter, offsetFd2;
fd1 = open("example.txt", O_RDONLY);
fd2 = dup(fd1);
flagsBefore = fcntl(fd1, F_GETFL);
if (flagsBefore == -1)
exitErr("fcntl");
if (fcntl(fd2, F_SETFL, flagsBefore | O_APPEND) == -1)
exitErr("fcntl");
flagsAfter = fcntl(fd1, F_GETFL);
if (flagsAfter == -1)
exitErr("fcntl");
assert(flagsBefore != flagsAfter);
assert(flagsAfter & O_APPEND);
offsetBefore = lseek(fd1, 0, SEEK_CUR);
if (offsetBefore == -1)
exitErr("lseek");
offsetFd2 = lseek(fd2, 10, SEEK_END);
if (offsetFd2 == -1)
exitErr("lseek");
offsetAfter = lseek(fd1, 0, SEEK_CUR);
if (offsetAfter == -1)
exitErr("lseek");
assert(offsetAfter != offsetBefore);
assert(offsetAfter == offsetFd2);
exit(EXIT_SUCCESS);
}
void exitErr(const char *msg)
{
perror(msg);
exit(EXIT_FAILURE);
}
| |
Add skeleton for EBook plugin | /*
*
* OBEX Server
*
* Copyright (C) 2007-2008 Marcel Holtmann <marcel@holtmann.org>
*
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <plugin.h>
#include <logging.h>
#include <libebook/e-book.h>
static int ebook_init(void)
{
DBG("");
return 0;
}
static void ebook_exit(void)
{
DBG("");
}
OBEX_PLUGIN_DEFINE("ebook", ebook_init, ebook_exit)
| |
Include stdlib to get size_t. | #ifndef ITERATOR_H
#define ITERATOR_H
struct iterator {
size_t index;
void *iterable;
void *current;
void *(*next)(struct iterator *this);
void (*destroy)(struct iterator *this);
};
struct iterator *iterator_create(void *iterable, void *(*next)(struct iterator *));
void iterator_destroy(struct iterator *this);
#endif
| #ifndef ITERATOR_H
#define ITERATOR_H
#include <stdlib.h>
struct iterator {
size_t index;
void *iterable;
void *current;
void *(*next)(struct iterator *this);
void (*destroy)(struct iterator *this);
};
struct iterator *iterator_create(void *iterable, void *(*next)(struct iterator *));
void iterator_destroy(struct iterator *this);
#endif
|
Define a whole bunch of new message tags for checkpoint and migration functions. | #if !defined(_CARMIPRO_H)
#define _CARMIPRO_H
#include "pvmsdpro.h"
#define CARMI_FIRST (SM_LAST+1)
#define CARMI_RESPAWN (CARMI_FIRST+1)
#define CARMI_CHKPT (CARMI_FIRST+2)
#define CARMI_ADDHOST (CARMI_FIRST+3)
#endif
| #if !defined(_CARMIPRO_H)
#define _CARMIPRO_H
#include "pvmsdpro.h"
#define CARMI_FIRST (SM_LAST+1)
#define CARMI_RESPAWN (CARMI_FIRST+1)
#define CARMI_CHKPT (CARMI_FIRST+2)
#define CARMI_ADDHOST (CARMI_FIRST+3)
#define CARMI_SPAWN (CARMI_FIRST+4)
#define CARMI_CKPT_ON_VACATE (CARMI_FIRST + 5)
#define CARMI_LAST (CARMI_CKPT_ON_VACATE)
#define CO_CHECK_FIRST (CARMI_LAST+1)
#define CO_CHECK_SIMPLE_CKPT_TASK_TO_FILE (CO_CHECK_FIRST + 1)
#define CO_CHECK_RESTART_TASK_FROM_FILE (CO_CHECK_FIRST + 2)
#define CO_CHECK_SIMPLE_CKPT_TASK (CO_CHECK_FIRST + 3)
#define CO_CHECK_RESTART_TASK (CO_CHECK_FIRST + 4)
#define CO_CHECK_SIMPLE_MIGRATE_TASK_TO_HOST (CO_CHECK_FIRST + 5)
#define CO_CHECK_SIMPLE_MIGRATE_TASK (CO_CHECK_FIRST + 6)
#endif
|
Put the -d option into the usage: message | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <mkdio.h>
float
main(int argc, char **argv)
{
int opt;
int debug = 0;
char *ofile = 0;
extern char version[];
opterr = 1;
while ( (opt=getopt(argc, argv, "do:V")) != EOF ) {
switch (opt) {
case 'd': debug = 1;
break;
case 'V': printf("markdown %s\n", version);
exit(0);
case 'o': if ( ofile ) {
fprintf(stderr, "Too many -o options\n");
exit(1);
}
if ( !freopen(ofile = optarg, "w", stdout) ) {
perror(ofile);
exit(1);
}
break;
default: fprintf(stderr, "usage: markdown [-V] [-o file] [file]\n");
exit(1);
}
}
argc -= optind;
argv += optind;
if ( argc && !freopen(argv[0], "r", stdin) ) {
perror(argv[0]);
exit(1);
}
if ( debug )
mkd_dump(mkd_in(stdin), stdout, 0);
else
markdown(mkd_in(stdin), stdout, 0);
exit(0);
}
| #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <mkdio.h>
float
main(int argc, char **argv)
{
int opt;
int debug = 0;
char *ofile = 0;
extern char version[];
opterr = 1;
while ( (opt=getopt(argc, argv, "do:V")) != EOF ) {
switch (opt) {
case 'd': debug = 1;
break;
case 'V': printf("markdown %s\n", version);
exit(0);
case 'o': if ( ofile ) {
fprintf(stderr, "Too many -o options\n");
exit(1);
}
if ( !freopen(ofile = optarg, "w", stdout) ) {
perror(ofile);
exit(1);
}
break;
default: fprintf(stderr, "usage: markdown [-dV] [-o file] [file]\n");
exit(1);
}
}
argc -= optind;
argv += optind;
if ( argc && !freopen(argv[0], "r", stdin) ) {
perror(argv[0]);
exit(1);
}
if ( debug )
mkd_dump(mkd_in(stdin), stdout, 0);
else
markdown(mkd_in(stdin), stdout, 0);
exit(0);
}
|
Add pragma once to camera auto switch header. | /*
* cameraautoswitch.h
* StatusSpec project
*
* Copyright (c) 2014-2015 Forward Command Post
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#include "igameevents.h"
#include "../modules.h"
class CCommand;
class ConCommand;
class ConVar;
class IConVar;
class CameraAutoSwitch : public Module, IGameEventListener2 {
public:
CameraAutoSwitch();
static bool CheckDependencies();
virtual void FireGameEvent(IGameEvent *event);
private:
class Panel;
Panel *panel;
ConVar *enabled;
ConVar *killer;
ConVar *killer_delay;
void ToggleEnabled(IConVar *var, const char *pOldValue, float flOldValue);
void ToggleKillerEnabled(IConVar *var, const char *pOldValue, float flOldValue);
};
| /*
* cameraautoswitch.h
* StatusSpec project
*
* Copyright (c) 2014-2015 Forward Command Post
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#pragma once
#include "igameevents.h"
#include "../modules.h"
class CCommand;
class ConCommand;
class ConVar;
class IConVar;
class CameraAutoSwitch : public Module, IGameEventListener2 {
public:
CameraAutoSwitch();
static bool CheckDependencies();
virtual void FireGameEvent(IGameEvent *event);
private:
class Panel;
Panel *panel;
ConVar *enabled;
ConVar *killer;
ConVar *killer_delay;
void ToggleEnabled(IConVar *var, const char *pOldValue, float flOldValue);
void ToggleKillerEnabled(IConVar *var, const char *pOldValue, float flOldValue);
};
|
Update files, Alura, Introdução a C, Aula 2.2 | #include <stdio.h>
int main() {
// imprime o cabecalho do nosso jogo
printf("******************************************\n");
printf("* Bem vindo ao nosso jogo de adivinhação *\n");
printf("******************************************\n");
int numerosecreto = 42;
int chute;
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
if(chute == numerosecreto) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
}
else {
printf("Você errou!\n");
printf("Mas não desanime, tente de novo!\n");
}
}
| #include <stdio.h>
int main() {
// imprime o cabecalho do nosso jogo
printf("******************************************\n");
printf("* Bem vindo ao nosso jogo de adivinhação *\n");
printf("******************************************\n");
int numerosecreto = 42;
int chute;
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
if(chute == numerosecreto) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
}
else {
if(chute > numerosecreto) {
printf("Seu chute foi maior que o número secreto\n");
}
if(chute < numerosecreto) {
printf("Seu chute foi menor que o número secreto\n");
}
printf("Você errou!\n");
printf("Mas não desanime, tente de novo!\n");
}
}
|
Remove unused glyph font defines. | #define WIKIGLYPH_FORWARD @"\ue954"
#define WIKIGLYPH_BACKWARD @"\ue955"
#define WIKIGLYPH_DOWN @"\ue956"
#define WIKIGLYPH_X @"\ue95e"
#define WIKIGLYPH_FLAG @"\ue963"
#define WIKIGLYPH_USER_SMILE @"\ue964"
#define WIKIGLYPH_USER_SLEEP @"\ue965"
#define WIKIGLYPH_CC @"\ue969"
#define WIKIGLYPH_CITE @"\ue96b"
#define WIKIGLYPH_PUBLIC_DOMAIN @"\ue96c"
| #define WIKIGLYPH_X @"\ue95e"
#define WIKIGLYPH_FLAG @"\ue963"
#define WIKIGLYPH_USER_SMILE @"\ue964"
#define WIKIGLYPH_USER_SLEEP @"\ue965"
#define WIKIGLYPH_CC @"\ue969"
#define WIKIGLYPH_PUBLIC_DOMAIN @"\ue96c"
|
Add typedef to number of operators. This will help inside code to distinguish from counting particles, forces or operators. | /*===- Operator.h - libSimulation -=============================================
*
* DEMON
*
* This file is distributed under the BSD Open Source License. See LICENSE.TXT
* for details.
*
*===-----------------------------------------------------------------------===*/
#ifndef OPERATOR_H
#define OPERATOR_H
#include "Cloud.h"
class Operator {
public:
Cloud * const cloud;
Operator(Cloud * const myCloud) : cloud(myCloud) {}
virtual ~Operator() {}
virtual void operation1(const double currentTime)=0;
virtual void operation2(const double currentTime)=0;
virtual void operation3(const double currentTime)=0;
virtual void operation4(const double currentTime)=0;
};
#endif // OPERATOR_H
| /*===- Operator.h - libSimulation -=============================================
*
* DEMON
*
* This file is distributed under the BSD Open Source License. See LICENSE.TXT
* for details.
*
*===-----------------------------------------------------------------------===*/
#ifndef OPERATOR_H
#define OPERATOR_H
#include "Cloud.h"
typedef unsigned int operator_index;
class Operator {
public:
Cloud * const cloud;
Operator(Cloud * const myCloud) : cloud(myCloud) {}
virtual ~Operator() {}
virtual void operation1(const double currentTime)=0;
virtual void operation2(const double currentTime)=0;
virtual void operation3(const double currentTime)=0;
virtual void operation4(const double currentTime)=0;
};
#endif // OPERATOR_H
|
Clean up smyrna files: remove unnecessary globals modify libraries not to rely on code in cmd/smyrna remove static declarations from .h files remove unnecessary libraries mark unused code and clean up warnings | /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifndef FILTER_H
#define FILTER_H
#include "btree.h"
typedef struct _tv_filters
{
tv_filter** filters;
int filter_count;
}tv_filters;
int clear_filter(tv_filter* f);
int init_filters(tv_filters* filters);
int add_filter_to_filters(tv_filters* filters,tv_filter* filter);
int clear_filters(tv_filters* filters);
int union_filter(tv_filter* f1,tv_filter* f2);
int intersect_filter(tv_filter* f1,tv_filter* f2);
#endif
| /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifndef FILTER_H
#define FILTER_H
#include "btree.h"
typedef struct _tv_filters {
tv_filter **filters;
int filter_count;
} tv_filters;
int clear_filter(tv_filter * f);
int init_filters(tv_filters * filters);
int add_filter_to_filters(tv_filters * filters, tv_filter * filter);
int clear_filters(tv_filters * filters);
int union_filter(tv_filter * f1, tv_filter * f2);
int intersect_filter(tv_filter * f1, tv_filter * f2);
#endif
|
Add unit tests for rocks.c. | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "cem/rocks.h"
static void test_set_rock_blocks(void) {
const int shape[2] = {10, 20};
double **z = (double**)malloc(sizeof(double*) * shape[0]);
char **rock_type = (char**)malloc(sizeof(char*) * shape[0]);
int i;
char expected[20] = {
'f', 'f', 's', 's', 's',
'f', 'f', 's', 's', 's', 'f', 'f', 's', 's', 's',
'f', 'f', 's', 's', 's'
};
z[0] = (double*)malloc(sizeof(double) * shape[0] * shape[1]);
rock_type[0] = (char*)malloc(sizeof(char) * shape[0] * shape[1]);
for (i=1; i < shape[0]; i++) {
z[i] = z[i-1] + shape[1];
rock_type[i] = rock_type[i-1] + shape[1];
}
set_rock_blocks(rock_type, z, shape[0], shape[1], 2);
for (i=0; i < shape[0]; i++)
g_assert_cmpmem(rock_type[i], shape[1], expected, shape[1]);
free(rock_type[0]);
free(rock_type);
free(z[0]);
free(z);
}
int main(int argc, char* argv[]) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/cem/rocks/set_blocks", &test_set_rock_blocks);
return g_test_run();
}
| |
Make a pointer-signedness warning in testing magically disappear~ | #include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "../marquise.h"
void test_hash_identifier() {
const char *id = "hostname:fe1.example.com,metric:BytesUsed,service:memory,";
size_t id_len = strlen(id);
uint64_t address = marquise_hash_identifier(id, id_len);
g_assert_cmpint(address, ==, 7602883380529707052);
}
int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/marquise_hash_identifier/hash", test_hash_identifier);
return g_test_run();
}
| #include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "../marquise.h"
void test_hash_identifier() {
const char *id = "hostname:fe1.example.com,metric:BytesUsed,service:memory,";
size_t id_len = strlen(id);
uint64_t address = marquise_hash_identifier((const unsigned char*) id, id_len);
g_assert_cmpint(address, ==, 7602883380529707052);
}
int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/marquise_hash_identifier/hash", test_hash_identifier);
return g_test_run();
}
|
Add a header for use from C++ | #ifndef __RSImg_h__
#define __RSImg_h__
#include <stdint.h>
#include <stdio.h>
extern "C" int RSImgFreadPPMP6Header(FILE *file, uint32_t *width, uint32_t *height, uint32_t *headerSize);
#endif
| |
Add primary header with initial API draft. | #ifndef http_h
#define http_h
typedef struct http_context_s http_context;
typedef struct http_session_s http_session;
typedef struct http_request_s http_request;
/*
* A Context is bound to a collection of sessions and
* ongoing requests. Each thread in a process should have its
* own Context to avoid deadlocks and conflicts.
*/
http_context* http_context_create();
void http_context_release(http_context* ctx);
/*
* A session represents an active communication line to a server.
* One or more network sockets may be open to the server to
* fulfill requests. Pipelining will be used if supported by server.
*/
http_session* http_session_open(http_context* ctx, const char* host, int port);
void http_session_close(http_session* session);
http_request* http_request_create(http_session* session, const char* path, http_method method);
http_request* http_request_get(http_session* session, const char* path);
http_request* http_request_post(http_session* session, const char* path);
#endif
| |
Revert "Corregido Error en Funcion restar" | //codigo para hecer pruebas de como funciona github.
//programa simple que suma, resta, multiplica y divide numeros ingresador por pantalla.
#include <stdio.h>
#include <stdlib.h>
void sumar(int a, int b);
void restar(int a,int b);
int main() {
int a,b;
printf("Bienvenido... Ingrese 2 numeros");
printf ("Primer numero: "); scanf ("%d",&a);
printf ("Segundo numero: "); scanf ("%d",&b);
sumar(a,b);
restar(a,b);
//implementar resta, multiplicacion, division
return (EXIT_SUCCESS);
}
void restar(int a,int b){
printf("La resta es: %d",a-b);
}
void sumar(int a, int b){
printf ("La suma es: %d",a+b);
}
| //codigo para hecer pruebas de como funciona github.
//programa simple que suma, resta, multiplica y divide numeros ingresador por pantalla.
#include <stdio.h>
#include <stdlib.h>
void sumar(int a, int b);
void restar(int a,int b);
int main() {
int a,b;
printf ("Primer numero: "); scanf ("%d",&a);
printf ("Segundo numero: "); scanf ("%d",&b);
sumar(a,b);
restar(a,b);
//implementar resta, multiplicacion, division
return (EXIT_SUCCESS);
}
void restar(int a,int b){
print("La resta es: %d",a-b);
}
void sumar(int a, int b){
printf ("La suma es: %d",a+b);
}
|
Fix volume control with ffmpeg 2.3 | #ifndef SRC_CONFIG_H_S6A1C09K
#define SRC_CONFIG_H_S6A1C09K
/* package name */
#define PACKAGE "pianobar"
#define VERSION "2014.06.08-dev"
/* ffmpeg/libav quirks detection
* ffmpeg’s micro versions always start at 100, that’s how we can distinguish
* ffmpeg and libav */
#include <libavfilter/version.h>
/* is "timeout" option present (all versions of ffmpeg, not libav) */
#if LIBAVFILTER_VERSION_MICRO >= 100
#define HAVE_AV_TIMEOUT
#endif
/* does graph_send_command exist (ffmpeg >=2.2) */
#if LIBAVFILTER_VERSION_MAJOR == 4 && \
LIBAVFILTER_VERSION_MICRO >= 100
#define HAVE_AVFILTER_GRAPH_SEND_COMMAND
#endif
/* need avcodec.h (ffmpeg 1.2) */
#if LIBAVFILTER_VERSION_MAJOR == 3 && \
LIBAVFILTER_VERSION_MINOR <= 42 && \
LIBAVFILTER_VERSION_MINOR > 32 && \
LIBAVFILTER_VERSION_MICRO >= 100
#define HAVE_AV_BUFFERSINK_GET_BUFFER_REF
#define HAVE_LIBAVFILTER_AVCODEC_H
#endif
#endif /* SRC_CONFIG_H_S6A1C09K */
| #ifndef SRC_CONFIG_H_S6A1C09K
#define SRC_CONFIG_H_S6A1C09K
/* package name */
#define PACKAGE "pianobar"
#define VERSION "2014.06.08-dev"
/* ffmpeg/libav quirks detection
* ffmpeg’s micro versions always start at 100, that’s how we can distinguish
* ffmpeg and libav */
#include <libavfilter/version.h>
/* is "timeout" option present (all versions of ffmpeg, not libav) */
#if LIBAVFILTER_VERSION_MICRO >= 100
#define HAVE_AV_TIMEOUT
#endif
/* does graph_send_command exist (ffmpeg >=2.2) */
#if LIBAVFILTER_VERSION_MAJOR >= 4 && \
LIBAVFILTER_VERSION_MICRO >= 100
#define HAVE_AVFILTER_GRAPH_SEND_COMMAND
#endif
/* need avcodec.h (ffmpeg 1.2) */
#if LIBAVFILTER_VERSION_MAJOR == 3 && \
LIBAVFILTER_VERSION_MINOR <= 42 && \
LIBAVFILTER_VERSION_MINOR > 32 && \
LIBAVFILTER_VERSION_MICRO >= 100
#define HAVE_AV_BUFFERSINK_GET_BUFFER_REF
#define HAVE_LIBAVFILTER_AVCODEC_H
#endif
#endif /* SRC_CONFIG_H_S6A1C09K */
|
Fix compiler warning for nullable check | //
// BFTaskCenter.h
// Pods
//
// Created by Superbil on 2015/8/22.
//
//
#import "Bolts.h"
@interface BFTaskCenter : NSObject
/*!
A block that can act as a continuation for a task.
*/
typedef void (^BFTaskCenterBlock)(BFTask * _Nonnull task);
+ (nonnull instancetype)defaultCenter;
- (instancetype)initWithExecutor:(BFExecutor *)executor;
- (nullable id)addTaskBlockToCallbacks:(nonnull BFTaskCenterBlock)taskBlock forKey:(nonnull NSString *)key;
- (void)removeTaskBlock:(nonnull id)taskBlock forKey:(nonnull NSString *)key;
- (void)clearAllCallbacksForKey:(nonnull NSString *)key;
- (void)sendToCallbacksWithKey:(nonnull NSString *)key result:(nullable id)result;
- (void)sendToCallbacksWithKey:(nonnull NSString *)key error:(nonnull NSError *)error;
- (nullable BFTaskCompletionSource *)sourceOfSendToCallbacksForKey:(nonnull NSString *)key
executor:(nonnull BFExecutor *)executor
cancellationToken:(nullable BFCancellationToken *)cancellationToken;
@end
| //
// BFTaskCenter.h
// Pods
//
// Created by Superbil on 2015/8/22.
//
//
#import "Bolts.h"
NS_ASSUME_NONNULL_BEGIN
@interface BFTaskCenter : NSObject
/*!
A block that can act as a continuation for a task.
*/
typedef void (^BFTaskCenterBlock)(BFTask * _Nonnull task);
+ (instancetype)defaultCenter;
- (instancetype)initWithExecutor:(nonnull BFExecutor *)executor;
- (nullable id)addTaskBlockToCallbacks:(nonnull BFTaskCenterBlock)taskBlock forKey:(nonnull NSString *)key;
- (void)removeTaskBlock:(nonnull id)taskBlock forKey:(nonnull NSString *)key;
- (void)clearAllCallbacksForKey:(nonnull NSString *)key;
- (void)sendToCallbacksWithKey:(nonnull NSString *)key result:(nullable id)result;
- (void)sendToCallbacksWithKey:(nonnull NSString *)key error:(nonnull NSError *)error;
- (nullable BFTaskCompletionSource *)sourceOfSendToCallbacksForKey:(nonnull NSString *)key
executor:(nonnull BFExecutor *)executor
cancellationToken:(nullable BFCancellationToken *)cancellationToken;
@end
NS_ASSUME_NONNULL_END
|
Unify and simplify a lot of pixomatic code | #pragma once
#include "cal3d/global.h"
#include "cal3d/vector.h"
typedef unsigned long CalColor32; // 32-bit integer, compatible with NSPR
inline CalColor32 CalMakeColor(CalVector cv) {
return
( ( unsigned int ) ( cv.z * 0xff ) << 0) +
( ( ( unsigned int ) ( cv.y * 0xff ) ) << 8 ) +
( ( ( unsigned int ) ( cv.x * 0xff ) ) << 16 ) +
0xff000000;
}
inline CalVector CalVectorFromColor(CalColor32 color) {
return CalVector(
((color >> 16) & 0xff) / float(0xff),
((color >> 8) & 0xff) / float(0xff),
((color >> 0) & 0xff) / float(0xff));
}
| #pragma once
#include "cal3d/global.h"
#include "cal3d/vector.h"
typedef unsigned int CalColor32; // 32-bit integer, compatible with NSPR
inline CalColor32 CalMakeColor(CalVector cv) {
return
( ( unsigned int ) ( cv.z * 0xff ) << 0) +
( ( ( unsigned int ) ( cv.y * 0xff ) ) << 8 ) +
( ( ( unsigned int ) ( cv.x * 0xff ) ) << 16 ) +
0xff000000;
}
inline CalVector CalVectorFromColor(CalColor32 color) {
return CalVector(
((color >> 16) & 0xff) / float(0xff),
((color >> 8) & 0xff) / float(0xff),
((color >> 0) & 0xff) / float(0xff));
}
|
Add some definitions in Framework FV 0.9 spec but not in PI 1.0. | /** @file
This file defines the data structures that are architecturally defined for file
images loaded via the FirmwareVolume protocol. The Firmware Volume specification
is the basis for these definitions.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: FrameworkFimrwareVolumeImageFormat.h
@par Revision Reference:
These definitions are from Firmware Volume Spec 0.9.
**/
#ifndef __FRAMEWORK_FIRMWARE_VOLUME_IMAGE_FORMAT_H__
#define __FRAMEWORK_FIRMWARE_VOLUME_IMAGE_FORMAT_H__
//
// Bit values for AuthenticationStatus
//
#define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001
#define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED 0x000002
#define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED 0x000004
#define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED 0x000008
#define EFI_AGGREGATE_AUTH_STATUS_ALL 0x00000f
#define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE 0x010000
#define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED 0x020000
#define EFI_LOCAL_AUTH_STATUS_NOT_TESTED 0x040000
#define EFI_LOCAL_AUTH_STATUS_TEST_FAILED 0x080000
#define EFI_LOCAL_AUTH_STATUS_ALL 0x0f0000
#endif
| |
Remove width, height and fps variable from YFrame struct | #ifndef __YANIMATED__
#define __YANIMATED__
typedef struct YFrame
{
int current;
int first;
int last;
int width;
int height;
int fps;
YFrame(){};
YFrame(int a_current,
int a_first,
int a_last,
int a_width,
int a_height,
int a_fps):
current(a_current),
first(a_first),
last(a_last),
width(a_width),
height(a_height),
fps(a_fps){};
} YFrame;
#endif /** __YANIMATED__ **/ | #ifndef __YANIMATED__
#define __YANIMATED__
/*!
Store animation frame indexes
*/
typedef struct YFrame
{
//! Default Constructor
YFrame(): current(0),
first(0),
last(0){};
//! Constructor with parameters
/*!
\param Current animation frame index
\param First animation frame index
\param Last animation frame index
*/
YFrame(int a_current,
int a_first,
int a_last):
current(a_current),
first(a_first),
last(a_last){};
int current; //! Current frame index
int first; //! First frame index
int last; //! Last frame index
} YFrame;
#endif /** __YANIMATED__ **/ |
Add standard ANSI-92 data types | /*
* Use and distribution licensed under the Apache license version 2.
*
* See the COPYING file in the root project directory for full text.
*/
#ifndef SQLTOAST_DATA_TYPE_H
#define SQLTOAST_DATA_TYPE_H
namespace sqltoast {
typedef enum data_type {
DATA_TYPE_CHAR,
DATA_TYPE_VARCHAR,
DATA_TYPE_NCHAR,
DATA_TYPE_VARNCHAR,
DATA_TYPE_BIT,
DATA_TYPE_VARBIT,
DATA_TYPE_NUMERIC,
DATA_TYPE_DECIMAL,
DATA_TYPE_INT,
DATA_TYPE_SMALLINT,
DATA_TYPE_FLOAT,
DATA_TYPE_DOUBLE,
DATA_TYPE_DATE,
DATA_TYPE_TIME,
DATA_TYPE_TIMESTAMP,
DATA_TYPE_INTERVAL
} data_type_t;
} // namespace sqltoast
#endif /* SQLTOAST_DATA_TYPE_H */
| |
Add SIG_SWITCH_TIME at Sat, 20 Sep 2014 | #ifndef BITCOIN_TIMESTAMPS_H
#define BITCOIN_TIMESTAMPS_H
static const unsigned int ENTROPY_SWITCH_TIME = 1362791041; // Sat, 09 Mar 2013 01:04:01 GMT
static const unsigned int STAKE_SWITCH_TIME = 1371686400; // Thu, 20 Jun 2013 00:00:00 GMT
static const unsigned int TARGETS_SWITCH_TIME = 1374278400; // Sat, 20 Jul 2013 00:00:00 GMT
static const unsigned int CHAINCHECKS_SWITCH_TIME = 1379635200; // Fri, 20 Sep 2013 00:00:00 GMT
static const unsigned int STAKECURVE_SWITCH_TIME = 1382227200; // Sun, 20 Oct 2013 00:00:00 GMT
static const unsigned int FEE_SWITCH_TIME = 1405814400; // Sun, 20 Jul 2014 00:00:00 GMT
static const unsigned int VALIDATION_SWITCH_TIME = 1408492800; // Wed, 20 Aug 2014 00:00:00 GMT
#endif
| #ifndef BITCOIN_TIMESTAMPS_H
#define BITCOIN_TIMESTAMPS_H
static const unsigned int ENTROPY_SWITCH_TIME = 1362791041; // Sat, 09 Mar 2013 01:04:01 GMT
static const unsigned int STAKE_SWITCH_TIME = 1371686400; // Thu, 20 Jun 2013 00:00:00 GMT
static const unsigned int TARGETS_SWITCH_TIME = 1374278400; // Sat, 20 Jul 2013 00:00:00 GMT
static const unsigned int CHAINCHECKS_SWITCH_TIME = 1379635200; // Fri, 20 Sep 2013 00:00:00 GMT
static const unsigned int STAKECURVE_SWITCH_TIME = 1382227200; // Sun, 20 Oct 2013 00:00:00 GMT
static const unsigned int FEE_SWITCH_TIME = 1405814400; // Sun, 20 Jul 2014 00:00:00 GMT
static const unsigned int VALIDATION_SWITCH_TIME = 1408492800; // Wed, 20 Aug 2014 00:00:00 GMT
static const unsigned int SIG_SWITCH_TIME = 1411171200; // Sat, 20 Sep 2014 00:00:00 GMT
#endif
|
Update default max tip age | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2014-2017 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_VALIDATION_H
#define BITCOIN_VALIDATION_H
#include <stdint.h>
#include <string>
static const int64_t DEFAULT_MAX_TIP_AGE = 1 * 60 * 60; // ~45 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin
extern int64_t nMaxTipAge;
class CBlockIndex;
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
FILE* AppendBlockFile(unsigned int& nFileRet);
bool IsInitialBlockDownload();
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
double GuessVerificationProgress(CBlockIndex* pindex);
#endif // BITCOIN_VALIDATION_H
| // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2014-2017 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_VALIDATION_H
#define BITCOIN_VALIDATION_H
#include <stdint.h>
#include <string>
static const int64_t DEFAULT_MAX_TIP_AGE = 120; // ~45 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin
extern int64_t nMaxTipAge;
class CBlockIndex;
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
FILE* AppendBlockFile(unsigned int& nFileRet);
bool IsInitialBlockDownload();
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
double GuessVerificationProgress(CBlockIndex* pindex);
#endif // BITCOIN_VALIDATION_H
|
Fix missing include of <cerrno> | //===-- xray_emulate_tsc.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 is a part of XRay, a dynamic runtime instrumentation system.
//
//===----------------------------------------------------------------------===//
#ifndef XRAY_EMULATE_TSC_H
#define XRAY_EMULATE_TSC_H
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "xray_defs.h"
#include <cstdint>
#include <time.h>
namespace __xray {
static constexpr uint64_t NanosecondsPerSecond = 1000ULL * 1000 * 1000;
ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
timespec TS;
int result = clock_gettime(CLOCK_REALTIME, &TS);
if (result != 0) {
Report("clock_gettime(2) returned %d, errno=%d.", result, int(errno));
TS.tv_sec = 0;
TS.tv_nsec = 0;
}
CPU = 0;
return TS.tv_sec * NanosecondsPerSecond + TS.tv_nsec;
}
}
#endif // XRAY_EMULATE_TSC_H
| //===-- xray_emulate_tsc.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 is a part of XRay, a dynamic runtime instrumentation system.
//
//===----------------------------------------------------------------------===//
#ifndef XRAY_EMULATE_TSC_H
#define XRAY_EMULATE_TSC_H
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "xray_defs.h"
#include <cerrno>
#include <cstdint>
#include <time.h>
namespace __xray {
static constexpr uint64_t NanosecondsPerSecond = 1000ULL * 1000 * 1000;
ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
timespec TS;
int result = clock_gettime(CLOCK_REALTIME, &TS);
if (result != 0) {
Report("clock_gettime(2) returned %d, errno=%d.", result, int(errno));
TS.tv_sec = 0;
TS.tv_nsec = 0;
}
CPU = 0;
return TS.tv_sec * NanosecondsPerSecond + TS.tv_nsec;
}
}
#endif // XRAY_EMULATE_TSC_H
|
Test getipnodebyname() & gethostbyname() implementations. | /*
* Copyright (C) 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <stdio.h>
#include <sys/socket.h>
#include <lwres/netdb.h>
static void
print_he(struct hostent *he, int error, const char *fun, const char *name) {
char **c;
int i;
if (he != NULL) {
printf("%s(%s):\n", fun, name);
printf("\tname = %s\n", he->h_name);
printf("\taddrtype = %d\n", he->h_addrtype);
printf("\tlength = %d\n", he->h_length);
c = he->h_aliases;
i = 1;
while (*c != NULL) {
printf("\talias[%d] = %s\n", i, *c);
i++;
c++;
}
c = he->h_addr_list;
i = 1;
while (*c != NULL) {
char buf[128];
inet_ntop(he->h_addrtype, c, buf, sizeof (buf));
printf("\taddress[%d] = %s\n", i, buf);
c++;
i++;
}
} else {
printf("%s(%s): error = %d\n", fun, name, error);
}
}
int
main(int argc, char **argv) {
struct hostent *he;
char **c;
int error;
while (argv[1] != NULL) {
he = gethostbyname(argv[1]);
print_he(he, 0 /* XXX h_errno */, "gethostbyname", argv[1]);
he = getipnodebyname(argv[1], AF_INET, AI_DEFAULT|AI_ALL,
&error);
print_he(he, error, "getipnodebyname", argv[1]);
if (he != NULL)
freehostent(he);
argv++;
}
exit(0);
}
| |
Define macro for size of proc parser | #ifndef FILE_UTILS_H
#define FILE_UTILS_H
#include <stdint.h>
#include <string.h>
#include <dirent.h>
#define PATHLEN 32
#define MAXPATH 1024
#define PROC "/proc/"
#define MEMINFO "/proc/meminfo"
#define STATUS "/proc/%s/status"
#define IO_STAT "/proc/%s/io"
#define STAT "/proc/%s/stat"
#define STAT_BUFFER 4096
#define COMM "/proc/%s/comm"
#define COMM_LEN strlen(COMM)
#define FD "/proc/%s/fd"
#define UID "Uid:\t"
char *parse_stat(char *pid, int field);
char *parse_proc(char *path, char *field);
int is_pid(const struct dirent *directory);
char *strip(char *stat);
char *calculate_size(char *field_total, int byte_idx);
uint64_t value_from_string(char *ps_field_value);
#endif
| #ifndef FILE_UTILS_H
#define FILE_UTILS_H
#include <stdint.h>
#include <string.h>
#include <dirent.h>
#define PATHLEN 32
#define MAXPATH 1024
#define PROC_SIZE 1024
#define PROC "/proc/"
#define MEMINFO "/proc/meminfo"
#define STATUS "/proc/%s/status"
#define IO_STAT "/proc/%s/io"
#define STAT "/proc/%s/stat"
#define STAT_BUFFER 4096
#define COMM "/proc/%s/comm"
#define COMM_LEN strlen(COMM)
#define FD "/proc/%s/fd"
#define UID "Uid:\t"
char *parse_stat(char *pid, int field);
char *parse_proc(char *path, char *field);
int is_pid(const struct dirent *directory);
char *strip(char *stat);
char *calculate_size(char *field_total, int byte_idx);
uint64_t value_from_string(char *ps_field_value);
#endif
|
Add imports for the public categories in the umbrella header | //
// HTMLKit.h
// HTMLKit
//
// Created by Iska on 15/09/14.
// Copyright (c) 2014 BrainCookie. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for HTMLKit.
extern double HTMLKitVersionNumber;
//! Project version string for HTMLKit.
extern const unsigned char HTMLKitVersionString[];
#import "HTMLDOM.h"
#import "HTMLParser.h"
#import "HTMLKitErrorDomain.h"
#import "HTMLOrderedDictionary.h"
#import "CSSSelectors.h"
#import "CSSSelectorParser.h"
#import "CSSNthExpressionParser.h"
| //
// HTMLKit.h
// HTMLKit
//
// Created by Iska on 15/09/14.
// Copyright (c) 2014 BrainCookie. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for HTMLKit.
extern double HTMLKitVersionNumber;
//! Project version string for HTMLKit.
extern const unsigned char HTMLKitVersionString[];
#import "HTMLDOM.h"
#import "HTMLParser.h"
#import "HTMLKitErrorDomain.h"
#import "HTMLOrderedDictionary.h"
#import "CSSSelectors.h"
#import "CSSSelectorParser.h"
#import "CSSNthExpressionParser.h"
#import "NSString+HTMLKit.h"
#import "NSCharacterSet+HTMLKit.h"
|
Add new line at end of file | #ifndef JOINABLE_IMPL
#define JOINABLE_IMPL
#include "joinable_types.h"
#include "types/MediaObjectImpl.h"
using ::com::kurento::kms::api::Joinable;
using ::com::kurento::kms::api::Direction;
using ::com::kurento::kms::api::StreamType;
namespace com { namespace kurento { namespace kms {
class JoinableImpl : public virtual Joinable, public virtual MediaObjectImpl {
public:
JoinableImpl();
~JoinableImpl() throw() {};
std::vector<StreamType::type> getStreams(const Joinable& joinable);
void join(const JoinableImpl& to, const Direction::type direction);
void unjoin(const JoinableImpl& to);
void join(const JoinableImpl& to, const StreamType::type stream, const Direction::type direction);
void unjoin(const JoinableImpl& to, const StreamType::type stream);
std::vector<Joinable> &getJoinees();
std::vector<Joinable> &getDirectionJoiness(const Direction::type direction);
std::vector<Joinable> &getJoinees(const StreamType::type stream);
std::vector<Joinable> &getDirectionJoiness(const StreamType::type stream, const Direction::type direction);
};
}}} // com::kurento::kms
#endif /* JOINABLE_IMPL */ | #ifndef JOINABLE_IMPL
#define JOINABLE_IMPL
#include "joinable_types.h"
#include "types/MediaObjectImpl.h"
using ::com::kurento::kms::api::Joinable;
using ::com::kurento::kms::api::Direction;
using ::com::kurento::kms::api::StreamType;
namespace com { namespace kurento { namespace kms {
class JoinableImpl : public virtual Joinable, public virtual MediaObjectImpl {
public:
JoinableImpl();
~JoinableImpl() throw() {};
std::vector<StreamType::type> getStreams(const Joinable& joinable);
void join(const JoinableImpl& to, const Direction::type direction);
void unjoin(const JoinableImpl& to);
void join(const JoinableImpl& to, const StreamType::type stream, const Direction::type direction);
void unjoin(const JoinableImpl& to, const StreamType::type stream);
std::vector<Joinable> &getJoinees();
std::vector<Joinable> &getDirectionJoiness(const Direction::type direction);
std::vector<Joinable> &getJoinees(const StreamType::type stream);
std::vector<Joinable> &getDirectionJoiness(const StreamType::type stream, const Direction::type direction);
};
}}} // com::kurento::kms
#endif /* JOINABLE_IMPL */
|
Add Apron branched thread creation privatization test, where protected is unsound | // SKIP PARAM: --set ana.activated[+] apron
extern int __VERIFIER_nondet_int();
#include <pthread.h>
#include <assert.h>
int g = 5;
int h = 5;
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
return NULL;
}
int main() {
int r = __VERIFIER_nondet_int();
pthread_t id;
if (r) {
pthread_create(&id, NULL, t_fun, NULL);
}
else {
h = 10;
}
// sync join needs to publish globals also to protected/mutex_inits like enter_multithreaded
// might need join strengthening to reveal unsoundness instead of going to top directly
pthread_mutex_lock(&m);
assert(g == h); // UNKNOWN!
pthread_mutex_unlock(&m);
return 0;
} | |
Add MRSHelper functions to Bridging Header | //
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "OpenMRSAPIManager.h"
#import "LocationListTableViewController.h"
#import "UIAlertView+Blocks.h" | //
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "OpenMRSAPIManager.h"
#import "LocationListTableViewController.h"
#import "UIAlertView+Blocks.h"
#import "MRSHelperFunctions.h" |
Add header file for publishing ArduinoJson objects and arrays | /*
PubSubClient_JSON.h - ArduinoJson support for PubSubClient
Copyright (C) 2016 Ian Tester
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include <ArduinoJson.h>
namespace MQTT {
class PublishJSON : public Publish {
public:
//! Publish a JSON object from the ArduinoJson library
/*!
\param topic Topic of the message
\param payload Object of the message
*/
PublishJSON(String topic, ArduinoJson::JsonObject& object) :
Publish(topic, NULL, object.measureLength() + 1)
{
_payload = new uint8_t[_payload_len];
if (_payload != NULL)
object.printTo((char*)_payload, _payload_len);
}
//! Publish a JSON array from the ArduinoJson library
/*!
\param topic Topic of the message
\param payload Array of the message
*/
PublishJSON(String topic, ArduinoJson::JsonArray& array) :
Publish(topic, NULL, array.measureLength() + 1)
{
_payload = new uint8_t[_payload_len];
if (_payload != NULL)
array.printTo((char*)_payload, _payload_len);
}
};
};
| |
Fix compiler warnings in the test suite | inline string
get_file_contents(char *filename)
{
ifstream file(filename, ios::in | ios::ate);
if (!file.is_open())
return string();
streampos sz = file.tellg();
file.seekg(0, ios::beg);
vector<char> v(sz);
file.read(&v[0], sz);
file.close();
string data(v.empty() ? string() : string (v.begin(), v.end()).c_str());
return data;
}
| inline string
get_file_contents(const char *filename)
{
ifstream file(filename, ios::in | ios::ate);
if (!file.is_open())
return string();
streampos sz = file.tellg();
file.seekg(0, ios::beg);
vector<char> v(sz);
file.read(&v[0], sz);
file.close();
string data(v.empty() ? string() : string (v.begin(), v.end()).c_str());
return data;
}
|
Make include flag name match file name. | #ifndef __NEW_ITERATOR_PYWRAP_H
#define __NEW_ITERATOR_PYWRAP_H
NPY_NO_EXPORT PyObject *
NpyIter_NestedIters(PyObject *NPY_UNUSED(self),
PyObject *args, PyObject *kwds);
#endif
| #ifndef __NDITER_PYWRAP_H
#define __NDITER_PYWRAP_H
NPY_NO_EXPORT PyObject *
NpyIter_NestedIters(PyObject *NPY_UNUSED(self),
PyObject *args, PyObject *kwds);
#endif
|
Fix class name and remove GameObject::clean call. | #ifndef __PLAYER_H__
#define __PLAYER_H__
#include<iostream>
#include"GameObject.h"
class PLayer: public GameObject
{
public:
void update();
void clean()
{
GameObject::clean();
std::cout << "clean PLayer";
}
};
#endif
| #ifndef __PLAYER_H__
#define __PLAYER_H__
#include<iostream>
#include"GameObject.h"
class Player: public GameObject
{
public:
void update();
void clean()
{
std::cout << "clean PLayer";
}
};
#endif
|
Remove include of header that doesn't exist (yet). | //===-- DIContext.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 DIContext, and abstract data structure that holds
// debug information data.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_DICONTEXT_H
#define LLVM_DEBUGINFO_DICONTEXT_H
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DILineInfo.h"
namespace llvm {
class raw_ostream;
class DIContext {
public:
virtual ~DIContext();
/// getDWARFContext - get a context for binary DWARF data.
static DIContext *getDWARFContext(bool isLittleEndian,
StringRef infoSection,
StringRef abbrevSection,
StringRef aRangeSection = StringRef(),
StringRef lineSection = StringRef(),
StringRef stringSection = StringRef());
virtual void dump(raw_ostream &OS) = 0;
};
}
#endif
| //===-- DIContext.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 DIContext, and abstract data structure that holds
// debug information data.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_DICONTEXT_H
#define LLVM_DEBUGINFO_DICONTEXT_H
#include "llvm/ADT/StringRef.h"
namespace llvm {
class raw_ostream;
class DIContext {
public:
virtual ~DIContext();
/// getDWARFContext - get a context for binary DWARF data.
static DIContext *getDWARFContext(bool isLittleEndian,
StringRef infoSection,
StringRef abbrevSection,
StringRef aRangeSection = StringRef(),
StringRef lineSection = StringRef(),
StringRef stringSection = StringRef());
virtual void dump(raw_ostream &OS) = 0;
};
}
#endif
|
Add info on I2C address | // Derived from blog post at http://www.ermicro.com/blog/?p=1239
#ifndef __MCP23008_H__
#define __MCP23008_H__
#include <compat/twi.h>
#include "i2c_utils.h"
#define MCP23008_ID 0x40 // MCP23008 I2C Device Identifier (0100, fixed)
#define MCP23008_ADDR 0x00 // MCP23008 I2C Address (000-111 in bits 3..1)
#define MCP23008_IODIR 0x00 // MCP23008 I/O Direction Register
#define MCP23008_GPIO 0x09 // MCP23008 General Purpose I/O Register
#define MCP23008_OLAT 0x0A // MCP23008 Output Latch Register
void write_mcp23008(unsigned char reg_addr,unsigned char data);
unsigned char read_mcp23008(unsigned char reg_addr);
#endif /*__MCP23008_H__*/
| // I/O functions for MCP23008 port expander using I2C/TWI protocol
// Derived from blog post at http://www.ermicro.com/blog/?p=1239
#ifndef __MCP23008_H__
#define __MCP23008_H__
#include <compat/twi.h>
#include "i2c_utils.h"
// About the 7-bit I2C slave address MCP23008:
// - The high bits 7..4 are fixed at 0100.
// - Bits 3..1 are for further addressing (e.g. eeprom page, jumpered pads)
// - Bit 0 is disregarded (the R/W direction is handled separately).
// See http://www.avrbeginners.net/architecture/twi/twi.html#addressing
#define MCP23008 0x40 // MCP23008 I2C device address
#define MCP23008_IODIR 0x00 // MCP23008 I/O Direction Register
#define MCP23008_GPIO 0x09 // MCP23008 General Purpose I/O Register
#define MCP23008_OLAT 0x0A // MCP23008 Output Latch Register
void write_mcp23008(uint8_t reg_addr, uint8_t data);
uint8_t read_mcp23008(uint8_t reg_addr);
#endif /*__MCP23008_H__*/
|
Add "\x" for hex part. |
#pragma once
#include <string>
#include <ostream>
#include <iomanip>
#include <iostream>
struct Hex
{
Hex(char *buffer, size_t size)
: m_buffer(buffer)
, m_size(size)
{
}
friend std::ostream& operator <<(std::ostream &os, const Hex &obj)
{
unsigned char* aschar = (unsigned char*)obj.m_buffer;
for (size_t i = 0; i < obj.m_size; ++i) {
if (isprint(aschar[i])) {
os << aschar[i];
} else {
os << std::hex << std::setw(2) << std::setfill('0') << static_cast<unsigned int> (aschar[i]);
}
}
return os;
}
private:
char *m_buffer;
size_t m_size;
};
|
#pragma once
#include <string>
#include <ostream>
#include <iomanip>
#include <iostream>
struct Hex
{
Hex(char *buffer, size_t size)
: m_buffer(buffer)
, m_size(size)
{
}
friend std::ostream& operator <<(std::ostream &os, const Hex &obj)
{
unsigned char* aschar = (unsigned char*)obj.m_buffer;
for (size_t i = 0; i < obj.m_size; ++i) {
if (isprint(aschar[i])) {
os << aschar[i];
} else {
os << "\\x" << std::hex << std::setw(2) << std::setfill('0') << static_cast<unsigned int> (aschar[i]);
}
}
return os;
}
private:
char *m_buffer;
size_t m_size;
};
|
Add notify() function to print message around function call | #include "gdt.h"
#include "idt.h"
#include "vga.h"
#include "term_printf.h"
void kernel_main()
{
init_term();
term_puts(NAME " booting...");
term_puts("Initializing GDT...");
init_gdt();
term_puts("Initializing IDT...");
init_idt();
term_printf("term_printf is %d%% p%cre %s\n", 100, 'u', "awesome");
__asm__ volatile ("int $2");
}
| #include "gdt.h"
#include "idt.h"
#include "vga.h"
#include "term_printf.h"
void notify(void (*func)(), char *str)
{
term_putsn(str);
func();
term_puts(" done");
}
void kernel_main()
{
init_term();
term_puts(NAME " booting...");
notify(init_gdt, "Initializing GDT...");
notify(init_idt, "Initializing IDT...");
term_printf("term_printf is %d%% p%cre %s\n", 100, 'u', "awesome");
__asm__ volatile ("int $2");
}
|
Address David Blaikie comment by replacing grep with FileCheck. | // test for r305179
// RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | grep '*** IR Dump After Function Integration/Inlining ***'
void foo() {}
| // test for r305179
// RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
// CHECK: *** IR Dump After Function Integration/Inlining ***
void foo() {}
|
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_
|
Revert __udivi3 (word in compiler always 32 bit) | /**
* @file
* @brief
*
* @date 16.05.12
* @author Anton Bondarev
* @author Ilia Vaprol
*/
#include <limits.h>
#include <stdint.h>
#define MASK_DWORD (uint64_t)1 << ((WORD_BIT * 2) - 1)
uint64_t __udivdi3(uint64_t num, uint64_t den) {
uint64_t result = 0;
int steps;
if (den == 0) {
return 0;
}
steps = 0;
result = 0;
while (!(den & MASK_DWORD)) {
den <<= 1;
++steps;
}
do {
result <<= 1;
if (num >= den) {
result |= 1;
num -= den;
}
den >>= 1;
} while (steps--);
return result;
}
| /**
* @file
* @brief
*
* @date 16.05.12
* @author Anton Bondarev
* @author Ilia Vaprol
*/
#include <stdint.h>
uint64_t __udivdi3(uint64_t num, uint64_t den) {
uint64_t result = 0;
int steps;
if (den == 0) {
return 0;
}
steps = 0;
result = 0;
while (!(den & 0x8000000000000000)) {
den <<= 1;
++steps;
}
do {
result <<= 1;
if (num >= den) {
result |= 1;
num -= den;
}
den >>= 1;
} while (steps--);
return result;
}
|
Change long int to int | /*
* Author: hx1997
* Desc: жһȻǷΪƽԸβ
*/
#include <stdio.h>
int is_automorphic(long int num) {
long int sqrd = num * num;
int lsig_digit, lsig_digit_sqrd;
if(num > 44720) return -1;
for(; num > 0; num /= 10, sqrd /= 10) {
lsig_digit = num % 10;
lsig_digit_sqrd = sqrd % 10;
if(lsig_digit != lsig_digit_sqrd) return 0;
}
return 1;
}
int main(void) {
int num_to_check;
printf("Input a non-negative integer less than 44720: ");
scanf(" %d", &num_to_check);
if(num_to_check > 44720)
printf("Invalid input.\n");
else
printf("%d is%s an automorphic number.\n", num_to_check, (is_automorphic(num_to_check) ? "" : " not"));
return 0;
}
| /*
* Author: hx1997
* Desc: жһȻǷΪƽԸβ
*/
#include <stdio.h>
int is_automorphic(int num) {
int sqrd = num * num;
int lsig_digit; int lsig_digit_sqrd;
if(num > 44720) return -1;
for(; num > 0; num /= 10, sqrd /= 10) {
lsig_digit = num % 10;
lsig_digit_sqrd = sqrd % 10;
if(lsig_digit != lsig_digit_sqrd) return 0;
}
return 1;
}
int main(void) {
int num_to_check;
printf("Input a non-negative integer less than 44720: ");
scanf(" %d", &num_to_check);
if(num_to_check > 44720)
printf("Invalid input.\n");
else
printf("%d is%s an automorphic number.\n", num_to_check, (is_automorphic(num_to_check) ? "" : " not"));
return 0;
}
|
Add a test case for diagnostic suppression on a graph with cycles. | // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=true -analyzer-output=text -verify %s
// expected-no-diagnostics
int *returnNull() { return 0; }
int coin();
// Use a float parameter to ensure that the value is unknown. This will create
// a cycle in the generated ExplodedGraph.
void testCycle(float i) {
int *x = returnNull();
int y;
while (i > 0) {
x = returnNull();
y = 2;
i -= 1;
}
*x = 1; // no-warning
y += 1;
}
| |
Update Skia milestone to 102 | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 101
#endif
| /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 102
#endif
|
Test debug label emission with local variables | // RUN: %ocheck 3 %s
g()
{
return 3;
}
main()
{
if(0){
f(); // shouldn't hit a linker error here - dead code
a:
return g();
}
goto a;
}
| // RUN: %ocheck 3 %s -g
// test debug emission too
g()
{
return 3;
}
main()
{
if(0){
int i;
f(); // shouldn't hit a linker error here - dead code
a:
i = 2;
return g(i);
}
goto a;
}
|
Update ROOT version files to v5.34/23. | #ifndef ROOT_RVersion
#define ROOT_RVersion
/* Version information automatically generated by installer. */
/*
* These macros can be used in the following way:
*
* #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4)
* #include <newheader.h>
* #else
* #include <oldheader.h>
* #endif
*
*/
#define ROOT_RELEASE "5.34/22"
#define ROOT_RELEASE_DATE "Oct 10 2014"
#define ROOT_RELEASE_TIME "15:29:14"
#define ROOT_SVN_REVISION 49361
#define ROOT_GIT_COMMIT "v5-34-21-104-gf821c17"
#define ROOT_GIT_BRANCH "heads/v5-34-00-patches"
#define ROOT_VERSION_CODE 336406
#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
| #ifndef ROOT_RVersion
#define ROOT_RVersion
/* Version information automatically generated by installer. */
/*
* These macros can be used in the following way:
*
* #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4)
* #include <newheader.h>
* #else
* #include <oldheader.h>
* #endif
*
*/
#define ROOT_RELEASE "5.34/23"
#define ROOT_RELEASE_DATE "Nov 7 2014"
#define ROOT_RELEASE_TIME "15:06:58"
#define ROOT_SVN_REVISION 49361
#define ROOT_GIT_COMMIT "v5-34-22-106-g4a0dea3"
#define ROOT_GIT_BRANCH "heads/v5-34-00-patches"
#define ROOT_VERSION_CODE 336407
#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
|
Declare public function in header. | /*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEFS
#else
#ifndef E_INT_CONFIG_THEME_H
#define E_INT_CONFIG_THEME_H
EAPI E_Config_Dialog *e_int_config_theme(E_Container *con, const char *params __UNUSED__);
EAPI void e_int_config_theme_import_done(E_Config_Dialog *dia);
EAPI void e_int_config_theme_update(E_Config_Dialog *dia, char *file);
#endif
#endif
| /*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEFS
#else
#ifndef E_INT_CONFIG_THEME_H
#define E_INT_CONFIG_THEME_H
EAPI E_Config_Dialog *e_int_config_theme(E_Container *con, const char *params __UNUSED__);
EAPI void e_int_config_theme_import_done(E_Config_Dialog *dia);
EAPI void e_int_config_theme_update(E_Config_Dialog *dia, char *file);
EAPI void e_int_config_theme_web_done(E_Config_Dialog *dia);
#endif
#endif
|
Update RingOpenGL 1.1 - Add Constant (Source Code) : 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_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
}
| |
Create macros for certain repetitive shifts | #ifndef PHYSICAL_ALLOCATOR_H
#define PHYSICAL_ALLOCATOR_H
typedef uint32_t page_frame_t;
#define PAGE_FRAME_CACHE_SIZE 32
#define PAGE_FRAME_MAP_SIZE (PHYS_MEMORY_SIZE/8/PAGE_SIZE)
// Linear search of page frame bitmap
page_frame_t alloc_frame_helper();
void free_frame(page_frame_t frame);
page_frame_t alloc_frame();
void use_frame(page_frame_t frame);
#endif
| #ifndef PHYSICAL_ALLOCATOR_H
#define PHYSICAL_ALLOCATOR_H
#include <stdint.h>
#include <stddef.h>
#include <libk/kabort.h>
#include <libk/kassert.h>
#include <libk/kputs.h>
#ifdef ARCH_X86
#include <arch/x86/memlayout.h>
#endif
#ifdef ARCH_USERLAND
#include "tests/memlayout.h"
#endif
typedef uint32_t page_frame_t;
#define BIT_INDEX(x) (1 << ((x) % 8))
#define BYTE_INDEX(x) ((x)/8)
#define PAGE_FRAME_CACHE_SIZE 32
#define PAGE_FRAME_MAP_SIZE (PHYS_MEMORY_SIZE/8/PAGE_SIZE)
// Linear search of page frame bitmap
page_frame_t alloc_frame_helper();
void free_frame(page_frame_t frame);
page_frame_t alloc_frame();
void use_frame(page_frame_t frame);
#endif
|
Use a better custom exception code. | /**************************************************************************
*
* Copyright 2015 Jose Fonseca
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OF OR CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
#include <windows.h>
int CALLBACK
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
RaiseException(100, EXCEPTION_NONCONTINUABLE, 0, NULL);
return 0;
}
| /**************************************************************************
*
* Copyright 2015 Jose Fonseca
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OF OR CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
#include <windows.h>
int CALLBACK
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
RaiseException(0xE0000001, EXCEPTION_NONCONTINUABLE, 0, NULL);
return 0;
}
|
Add dummy block implementation for Muen | /*
* Copyright (c) 2017 Contributors as noted in the AUTHORS file
*
* This file is part of Solo5, a unikernel base layer.
*
* Permission to use, copy, modify, and/or distribute this software
* for any purpose with or without fee is hereby granted, provided
* that the above copyright notice and this permission notice appear
* in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "../kernel.h"
/* ukvm block interface */
int solo5_blk_write_sync(uint64_t sec __attribute__((unused)),
uint8_t *data __attribute__((unused)),
int n __attribute__((unused)))
{
return -1;
}
int solo5_blk_read_sync(uint64_t sec __attribute__((unused)),
uint8_t *data __attribute__((unused)),
int *n __attribute__((unused)))
{
return -1;
}
int solo5_blk_sector_size(void)
{
return -1;
}
uint64_t solo5_blk_sectors(void)
{
return 0;
}
int solo5_blk_rw(void)
{
return -1;
}
| |
Remove outdated octApron comment from 06/24 | // PARAM: --set ana.activated[+] "'var_eq'"
// Copy of 04/45 with var_eq enabled
// octApron needs to be included again and fixed
#include <pthread.h>
#include <stdio.h>
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
int *p = (int *) arg;
pthread_mutex_lock(&mutex1);
(*p)++;
pthread_mutex_unlock(&mutex1);
return NULL;
}
int main(void) {
pthread_t id;
int i = 0;
pthread_create(&id, NULL, t_fun, (void *) &i);
pthread_mutex_lock(&mutex2);
assert(i == 0); // UNKNOWN!
pthread_mutex_unlock(&mutex2);
pthread_join (id, NULL);
return 0;
}
| // PARAM: --set ana.activated[+] "'var_eq'"
// Copy of 04/45 with var_eq enabled
#include <pthread.h>
#include <stdio.h>
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
int *p = (int *) arg;
pthread_mutex_lock(&mutex1);
(*p)++;
pthread_mutex_unlock(&mutex1);
return NULL;
}
int main(void) {
pthread_t id;
int i = 0;
pthread_create(&id, NULL, t_fun, (void *) &i);
pthread_mutex_lock(&mutex2);
assert(i == 0); // UNKNOWN!
pthread_mutex_unlock(&mutex2);
pthread_join (id, NULL);
return 0;
}
|
Remove an old stdio.h include from the invalid-array test | // RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
// PR6913
#include <stdio.h>
int main()
{
int x[10][10];
int (*p)[] = x;
int i;
for(i = 0; i < 10; ++i)
{
p[i][i] = i; // expected-error {{subscript of pointer to incomplete type 'int []'}}
}
}
// rdar://13705391
void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
| // RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
// PR6913
int main()
{
int x[10][10];
int (*p)[] = x;
int i;
for(i = 0; i < 10; ++i)
{
p[i][i] = i; // expected-error {{subscript of pointer to incomplete type 'int []'}}
}
}
// rdar://13705391
void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
|
Convert a tab into a space | /*
* File: executeStage.h
* Author: Alex Savarda
*/
#define INSTR_COUNT 16 // Possible size of the instruction set
#ifndef EXECUTESTAGE_H
#define EXECUTESTAGE_H
typedef struct {
unsigned int stat;
unsigned int icode;
unsigned int ifun;
unsigned int valC;
unsigned int valA;
unsigned int valB;
unsigned int dstE;
unsigned int dstM;
unsigned int srcA;
unsigned int srcB;
} eregister;
struct E {
unsigned int stat;
unsigned int icode;
unsigned int ifun;
unsigned int valC;
unsigned int valA;
unsigned int valB;
unsigned int dstE;
unsigned int dstM;
unsigned int srcA;
unsigned int srcB;
};
// Function prototypes
eregister getEregister(void);
void clearEregister(void);
void executeStage();
void initFuncPtrArray(void);
void updateEregister(unsigned int stat, unsigned int icode, unsigned int ifun,
unsigned int valC, unsigned int valA, unsigned int valB,
unsigned int dstE, unsigned int dstM, unsigned int srcA,
unsigned int srcB);
#endif /* EXECUTESTAGE_H */
| /*
* File: executeStage.h
* Author: Alex Savarda
*/
#define INSTR_COUNT 16 // Possible size of the instruction set
#ifndef EXECUTESTAGE_H
#define EXECUTESTAGE_H
typedef struct {
unsigned int stat;
unsigned int icode;
unsigned int ifun;
unsigned int valC;
unsigned int valA;
unsigned int valB;
unsigned int dstE;
unsigned int dstM;
unsigned int srcA;
unsigned int srcB;
} eregister;
struct E {
unsigned int stat;
unsigned int icode;
unsigned int ifun;
unsigned int valC;
unsigned int valA;
unsigned int valB;
unsigned int dstE;
unsigned int dstM;
unsigned int srcA;
unsigned int srcB;
};
// Function prototypes
eregister getEregister(void);
void clearEregister(void);
void executeStage();
void initFuncPtrArray(void);
void updateEregister(unsigned int stat, unsigned int icode, unsigned int ifun,
unsigned int valC, unsigned int valA, unsigned int valB,
unsigned int dstE, unsigned int dstM, unsigned int srcA,
unsigned int srcB);
#endif /* EXECUTESTAGE_H */
|
Remove inclusion of 'parser.h' and fix pointer type | /* This is main header file that is ought to be included as library */
//Include proper header files
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include "parser.h"
//Function prototypes
extern uint16_t MODBUSSwapEndian( uint16_t );
extern uint16_t MODBUSCRC16( uint16_t *, uint16_t );
| /* This is main header file that is ought to be included as library */
//Include proper header files
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
//Function prototypes
extern uint16_t MODBUSSwapEndian( uint16_t );
extern uint16_t MODBUSCRC16( uint8_t *, uint16_t );
|
Fix the small test to use Handle instead of On | #include "Components.h"
class HealthComponent : public HealthComponentBase {
public:
HealthComponent(Entity* entity, int maxHealth, int startHealth, const int& Health): HealthComponentBase(entity, maxHealth, startHealth, Health) {
}
void OnHeal(int amount) {
}
void OnDamage(int amount) {
}
void AttribHealth(int health) {
}
};
class MonsterDieComponent : public MonsterDieComponentBase {
public:
MonsterDieComponent(Entity* entity): MonsterDieComponentBase(entity) {
}
void OnDie() {
}
};
| #include "Components.h"
class HealthComponent : public HealthComponentBase {
public:
HealthComponent(Entity* entity, int maxHealth, int startHealth, const int& Health): HealthComponentBase(entity, maxHealth, startHealth, Health) {
}
void HandleHeal(int amount) {
}
void HandleDamage(int amount) {
}
void AttribHealth(int health) {
}
};
class MonsterDieComponent : public MonsterDieComponentBase {
public:
MonsterDieComponent(Entity* entity): MonsterDieComponentBase(entity) {
}
void HandleDie() {
}
};
|
Use pointers to start of arrays | #include <stdio.h>
int main(int argc, char *argv[]){
//create two arrays we care about
int ages[] = {23,55,15,34,78,12};
char *names[] = {
"Feinb", "Fhilp", "Wastan", "Wustak","Henris","Abkar"
};
//safely get the size of ages
int count = sizeof(ages) / sizeof(int);
int i = 0;
//first way using indexing
for(i = 0; i < count; i++){
printf("%s had lived for %d years.\n", names[i], ages[i]);
}
printf("---\n");
return 0;
} | #include <stdio.h>
int main(int argc, char *argv[]){
//create two arrays we care about
int ages[] = {23,55,15,34,78,12};
char *names[] = {
"Feinb", "Fhilp", "Wastan", "Wustak","Henris","Abkar"
};
//safely get the size of ages
int count = sizeof(ages) / sizeof(int);
int i = 0;
//first way using indexing
for(i = 0; i < count; i++){
printf("%s has lived for %d years.\n", names[i], ages[i]);
}
printf("---\n");
//setup pointers to the start of the arrays
int *cur_age = ages;
char **cur_name = names;
// second way using pointers
for(i = 0; i < count; i++){
printf("%s is %d years old.\n",
*(cur_name+i), *(cur_age+i));
}
printf("---\n");
return 0;
} |
Fix a warning with -pedantic on some old gcc versions | #ifndef IFILE_H
#define IFILE_H
#include <vector>
#include <memory>
#include "IMediaLibrary.h"
#include "ITrackInformation.h"
class IAlbumTrack;
class IShowEpisode;
class ITrackInformation;
class IFile
{
public:
enum Type
{
VideoType, // Any video file, not being a tv show episode
AudioType, // Any kind of audio file, not being an album track
ShowEpisodeType,
AlbumTrackType,
UnknownType,
};
virtual ~IFile() {}
virtual unsigned int id() const = 0;
virtual AlbumTrackPtr albumTrack() = 0;
virtual bool setAlbumTrack(AlbumTrackPtr albumTrack ) = 0;
virtual unsigned int duration() const = 0;
virtual std::shared_ptr<IShowEpisode> showEpisode() = 0;
virtual bool setShowEpisode( ShowEpisodePtr showEpisode ) = 0;
virtual int playCount() const = 0;
virtual const std::string& mrl() const = 0;
virtual bool addLabel( LabelPtr label ) = 0;
virtual bool removeLabel( LabelPtr label ) = 0;
virtual MoviePtr movie() = 0;
virtual bool setMovie( MoviePtr movie ) = 0;
virtual std::vector<std::shared_ptr<ILabel> > labels() = 0;
};
#endif // IFILE_H
| #ifndef IFILE_H
#define IFILE_H
#include <vector>
#include <memory>
#include "IMediaLibrary.h"
#include "ITrackInformation.h"
class IAlbumTrack;
class IShowEpisode;
class ITrackInformation;
class IFile
{
public:
enum Type
{
VideoType, // Any video file, not being a tv show episode
AudioType, // Any kind of audio file, not being an album track
ShowEpisodeType,
AlbumTrackType,
UnknownType
};
virtual ~IFile() {}
virtual unsigned int id() const = 0;
virtual AlbumTrackPtr albumTrack() = 0;
virtual bool setAlbumTrack(AlbumTrackPtr albumTrack ) = 0;
virtual unsigned int duration() const = 0;
virtual std::shared_ptr<IShowEpisode> showEpisode() = 0;
virtual bool setShowEpisode( ShowEpisodePtr showEpisode ) = 0;
virtual int playCount() const = 0;
virtual const std::string& mrl() const = 0;
virtual bool addLabel( LabelPtr label ) = 0;
virtual bool removeLabel( LabelPtr label ) = 0;
virtual MoviePtr movie() = 0;
virtual bool setMovie( MoviePtr movie ) = 0;
virtual std::vector<std::shared_ptr<ILabel> > labels() = 0;
};
#endif // IFILE_H
|
Fix ChromeOS build (C99 break) | /*
* Copyright (c) 2011 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.
*/
/******************************************************************
iLBC Speech Coder ANSI-C Source Code
WebRtcIlbcfix_NearestNeighbor.c
******************************************************************/
#include "defines.h"
void WebRtcIlbcfix_NearestNeighbor(size_t* index,
const size_t* array,
size_t value,
size_t arlength) {
size_t min_diff = (size_t)-1;
for (size_t i = 0; i < arlength; i++) {
const size_t diff =
(array[i] < value) ? (value - array[i]) : (array[i] - value);
if (diff < min_diff) {
*index = i;
min_diff = diff;
}
}
}
| /*
* Copyright (c) 2011 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.
*/
/******************************************************************
iLBC Speech Coder ANSI-C Source Code
WebRtcIlbcfix_NearestNeighbor.c
******************************************************************/
#include "defines.h"
void WebRtcIlbcfix_NearestNeighbor(size_t* index,
const size_t* array,
size_t value,
size_t arlength) {
size_t i;
size_t min_diff = (size_t)-1;
for (i = 0; i < arlength; i++) {
const size_t diff =
(array[i] < value) ? (value - array[i]) : (array[i] - value);
if (diff < min_diff) {
*index = i;
min_diff = diff;
}
}
}
|
Add indent comment for header guard | /*
* chewing-compat.h
*
* Copyright (c) 2014
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_
/** @brief indicate the internal encoding of data processing.
* @since 0.3.0
*/
#define LIBCHEWING_ENCODING "UTF-8"
/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(ChewingContext *ctx) DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(ChewingContext *,
int *zuin_count) DEPRECATED_FOR(chewing_bopomofo_String_static);
CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath) DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd) DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode) DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx) DEPRECATED_FOR(chewing_get_selKey);
#endif
| /*
* chewing-compat.h
*
* Copyright (c) 2014
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_
/* *INDENT-ON* */
/** @brief indicate the internal encoding of data processing.
* @since 0.3.0
*/
#define LIBCHEWING_ENCODING "UTF-8"
/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(ChewingContext *ctx) DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(ChewingContext *,
int *zuin_count) DEPRECATED_FOR(chewing_bopomofo_String_static);
CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath) DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd) DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode) DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx) DEPRECATED_FOR(chewing_get_selKey);
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */
|
Kill hands that reach five fingers | #include <stdio.h>
typedef struct {
int hands[2][2];
int turn;
} Sticks;
void sticks_create(Sticks *sticks) {
sticks->hands[0][0] = 1;
sticks->hands[0][1] = 1;
sticks->hands[1][0] = 1;
sticks->hands[1][1] = 1;
sticks->turn = 0;
}
void sticks_play(Sticks *sticks, int actor, int target) {
sticks->hands[!sticks->turn][target] += sticks->hands[sticks->turn][actor];
sticks->turn = !sticks->turn;
}
int main(void) {
Sticks sticks;
sticks_create(&sticks);
printf("%d\n", sticks.hands[0][0]);
printf("%d\n", sticks.turn);
sticks_play(&sticks, 0, 1);
printf("%d\n", sticks.hands[1][1]);
printf("%d\n", sticks.turn);
}
| #include <stdio.h>
typedef struct {
int hands[2][2];
int turn;
} Sticks;
void sticks_create(Sticks *sticks) {
sticks->hands[0][0] = 1;
sticks->hands[0][1] = 1;
sticks->hands[1][0] = 1;
sticks->hands[1][1] = 1;
sticks->turn = 0;
}
void sticks_play(Sticks *sticks, int actor, int target) {
sticks->hands[!sticks->turn][target] += sticks->hands[sticks->turn][actor];
if (sticks->hands[!sticks->turn][target] >= 5) {
sticks->hands[!sticks->turn][target] = 0;
}
sticks->turn = !sticks->turn;
}
int main(void) {
Sticks sticks;
sticks_create(&sticks);
printf("%d\n", sticks.hands[0][0]);
printf("%d\n", sticks.turn);
sticks_play(&sticks, 0, 1);
printf("%d\n", sticks.hands[1][1]);
printf("%d\n", sticks.turn);
}
|
Add method to check audio device state | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
class VolumeTransformation;
class VolumeController {
public:
struct DeviceInfo {
std::wstring name;
std::wstring id;
};
/// <summary>
/// Retrieves the current volume level as a float, ranging from 0.0 - 1.0
/// </summary>
virtual float Volume() = 0;
/// <summary>Sets the volume level. Valid range: 0.0 - 1.0</summary>
virtual void Volume(float vol) = 0;
virtual bool Muted() = 0;
virtual void Muted(bool mute) = 0;
virtual void ToggleMute() {
(Muted() == true) ? Muted(false) : Muted(true);
}
virtual void AddTransformation(VolumeTransformation *transform) = 0;
virtual void RemoveTransformation(VolumeTransformation *transform) = 0;
public:
static const int MSG_VOL_CHNG = WM_APP + 1080;
static const int MSG_VOL_DEVCHNG = WM_APP + 1081;
}; | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
class VolumeTransformation;
class VolumeController {
public:
struct DeviceInfo {
std::wstring name;
std::wstring id;
};
/// <summary>
/// Retrieves the current volume level as a float, ranging from 0.0 - 1.0
/// </summary>
virtual float Volume() = 0;
/// <summary>Sets the volume level. Valid range: 0.0 - 1.0</summary>
virtual void Volume(float vol) = 0;
virtual bool Muted() = 0;
virtual void Muted(bool mute) = 0;
virtual void ToggleMute() {
(Muted() == true) ? Muted(false) : Muted(true);
}
virtual void Enabled() = 0;
virtual void AddTransformation(VolumeTransformation *transform) = 0;
virtual void RemoveTransformation(VolumeTransformation *transform) = 0;
public:
static const int MSG_VOL_CHNG = WM_APP + 1080;
static const int MSG_VOL_DEVCHNG = WM_APP + 1081;
}; |
Add Vesal's version of 13/24 where mutex-oplus and mutex-meet are more precise than old and mine | // PARAM: --enable ana.int.interval
// Copied & modified from 13/24.
#include <pthread.h>
#include <assert.h>
int g2;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t __global_lock = PTHREAD_MUTEX_INITIALIZER;
void *t2_fun(void *arg) {
pthread_mutex_lock(&mutex2);
pthread_mutex_lock(&__global_lock);
g2++;
pthread_mutex_unlock(&__global_lock); // Write Mine influence: [[g2, __global_lock], t2_fun, {mutex2}] -> 1
pthread_mutex_lock(&__global_lock);
g2--;
pthread_mutex_unlock(&__global_lock); // Write Mine influence: [[g2, __global_lock], t2_fun, {mutex2}] -> 0
pthread_mutex_unlock(&mutex2);
return NULL;
}
int main(void) {
pthread_t id2;
pthread_create(&id2, NULL, t2_fun, NULL);
pthread_mutex_lock(&mutex1);
pthread_mutex_lock(&__global_lock); // Read & join to g2 Mine influence: [[g2, __global_lock], t2_fun, {mutex2}] -> (0 join 1 = Unknown)
assert(0 <= g2); // TODO (widening)
assert(g2 <= 1);
pthread_mutex_unlock(&__global_lock);
pthread_mutex_lock(&mutex2);
pthread_mutex_lock(&__global_lock);
assert(g2 == 0);
pthread_mutex_unlock(&__global_lock);
pthread_mutex_unlock(&mutex2);
pthread_mutex_unlock(&mutex1);
pthread_join(id2, NULL);
return 0;
} | |
Use __typeof__ since typeof is unavailable in our build | #import "AsyncActualValue.h"
namespace CedarAsync {
template<typename T>
struct InTimeMarker {
T(^actualExpression)(void);
const char *fileName;
int lineNumber;
};
template<typename T>
const AsyncActualValue<T> operator,(const InTimeMarker<T> & marker, const Cedar::Matchers::ActualValueMarker & _) {
return AsyncActualValue<T>(marker.fileName, marker.lineNumber, marker.actualExpression);
}
template<typename T>
const AsyncActualValueMatchProxy<T> operator,(const AsyncActualValue<T> & actualValue, bool negate) {
return negate ? actualValue.to_not : actualValue.to;
}
template<typename T, typename MatcherType>
void operator,(const AsyncActualValueMatchProxy<T> & matchProxy, const MatcherType & matcher) {
matchProxy(matcher);
}
}
#ifndef CEDAR_ASYNC_DISALLOW_IN_TIME
#define in_time(x) (InTimeMarker<typeof(x)>){^{return x;}, __FILE__, __LINE__}
#endif
| #import "AsyncActualValue.h"
namespace CedarAsync {
template<typename T>
struct InTimeMarker {
T(^actualExpression)(void);
const char *fileName;
int lineNumber;
};
template<typename T>
const AsyncActualValue<T> operator,(const InTimeMarker<T> & marker, const Cedar::Matchers::ActualValueMarker & _) {
return AsyncActualValue<T>(marker.fileName, marker.lineNumber, marker.actualExpression);
}
template<typename T>
const AsyncActualValueMatchProxy<T> operator,(const AsyncActualValue<T> & actualValue, bool negate) {
return negate ? actualValue.to_not : actualValue.to;
}
template<typename T, typename MatcherType>
void operator,(const AsyncActualValueMatchProxy<T> & matchProxy, const MatcherType & matcher) {
matchProxy(matcher);
}
}
#ifndef CEDAR_ASYNC_DISALLOW_IN_TIME
#define in_time(x) (InTimeMarker<__typeof__(x)>){^{return x;}, __FILE__, __LINE__}
#endif
|
Use OpenSSL engine by default. | /* Copyright 2000-2004 The Apache Software Foundation
*
* 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 SSL_PRIVATE_H
#define SSL_PRIVATE_H
/* OpenSSL headers */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/x509v3.h>
/* Avoid tripping over an engine build installed globally and detected
* when the user points at an explicit non-engine flavor of OpenSSL
*/
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ENGINE_INIT)
#include <openssl/engine.h>
#endif
#endif /* SSL_PRIVATE_H */
| /* Copyright 2000-2004 The Apache Software Foundation
*
* 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 SSL_PRIVATE_H
#define SSL_PRIVATE_H
/* OpenSSL headers */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/x509v3.h>
/* Avoid tripping over an engine build installed globally and detected
* when the user points at an explicit non-engine flavor of OpenSSL
*/
#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
#endif
#endif /* SSL_PRIVATE_H */
|
Fix the constructor of OptimizePass | #pragma once
#include "onnx/onnx_pb.h"
#include "onnx/ir.h"
namespace onnx { namespace optimization {
enum class API_TYPE {
PROTO, IR
};
struct OptimizePass {
std::string name;
API_TYPE type;
explicit OptimizePass(const std::string name, API_TYPE type)
: name(name), type(type) {
}
virtual void optimize(onnx::ModelProto& mp) {}
virtual void optimize(Graph& graph) {}
};
}} // namespace onnx::optimization
| #pragma once
#include "onnx/onnx_pb.h"
#include "onnx/ir.h"
namespace onnx { namespace optimization {
enum class API_TYPE {
PROTO, IR
};
struct OptimizePass {
std::string name;
API_TYPE type;
explicit OptimizePass(const std::string& name, API_TYPE type)
: name(name), type(type) {
}
virtual void optimize(onnx::ModelProto& mp) {}
virtual void optimize(Graph& graph) {}
};
}} // namespace onnx::optimization
|
Add BSD 3-clause open source header | #ifndef _AUTOMATON_H_
#define _AUTOMATON_H_
/*
* type and function definitions for an automaton
*/
#include "event.h"
#include "srpc/srpc.h"
typedef struct automaton Automaton;
void au_init(void);
Automaton *au_create(char *program, RpcConnection rpc, char *ebuf);
int au_destroy(unsigned long id);
void au_publish(unsigned long id, Event *event);
unsigned long au_id(Automaton *au);
Automaton *au_au(unsigned long id);
RpcConnection au_rpc(Automaton *au);
#endif /* _AUTOMATON_H_ */
| #ifndef _AUTOMATON_H_
#define _AUTOMATON_H_
/*
* Copyright (c) 2013, Court of the University of Glasgow
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the University of Glasgow nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* type and function definitions for an automaton
*/
#include "event.h"
#include "srpc/srpc.h"
typedef struct automaton Automaton;
void au_init(void);
Automaton *au_create(char *program, RpcConnection rpc, char *ebuf);
int au_destroy(unsigned long id);
void au_publish(unsigned long id, Event *event);
unsigned long au_id(Automaton *au);
Automaton *au_au(unsigned long id);
RpcConnection au_rpc(Automaton *au);
#endif /* _AUTOMATON_H_ */
|
Make the registering and unregistering of the Notification private | #include "DefSoundDeviceState.h"
#include "AudioEndPointLibraryImpl.h"
// This class is exported from the AudioEndPointLibrary.dll
namespace AudioEndPoint {
class AUDIOENDPOINTLIBRARY_API CAudioEndPointLibrary {
public:
~CAudioEndPointLibrary();
HRESULT OnDeviceStateChanged(LPCWSTR pwstr_device_id, DWORD dw_new_state) const;
HRESULT OnDeviceAdded(LPCWSTR pwstr_device_id) const;
HRESULT OnDeviceRemoved(LPCWSTR pwstr_device_id) const;
HRESULT OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstr_default_device_id) const;
static CAudioEndPointLibrary& GetInstance();
AudioDeviceList GetPlaybackDevices(DefSound::EDeviceState state) const;
AudioDeviceList GetRecordingDevices(DefSound::EDeviceState state) const;
HRESULT RegisterNotificationClient() const;
HRESULT UnRegisterNotificationClient() const;
AudioEndPointLibrarySignals* m_signals1() const
{
return m_signals;
}
__declspec(property(get = m_signals1)) AudioEndPointLibrarySignals* Signals;
private:
CAudioEndPointLibrary(void);
CAudioEndPointLibrary(CAudioEndPointLibrary const&) = delete;
void operator=(CAudioEndPointLibrary const&) = delete;
void Refresh() const;
struct AudioEndPointLibraryImpl;
struct AudioEndPointLibraryDevicesImpl;
AudioEndPointLibraryImpl* m_container;
AudioEndPointLibrarySignals* m_signals;
AudioEndPointLibraryDevicesImpl* m_devices_lists;
};
}
| #include "DefSoundDeviceState.h"
#include "AudioEndPointLibraryImpl.h"
// This class is exported from the AudioEndPointLibrary.dll
namespace AudioEndPoint {
class AUDIOENDPOINTLIBRARY_API CAudioEndPointLibrary {
public:
~CAudioEndPointLibrary();
HRESULT OnDeviceStateChanged(LPCWSTR pwstr_device_id, DWORD dw_new_state) const;
HRESULT OnDeviceAdded(LPCWSTR pwstr_device_id) const;
HRESULT OnDeviceRemoved(LPCWSTR pwstr_device_id) const;
HRESULT OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstr_default_device_id) const;
static CAudioEndPointLibrary& GetInstance();
AudioDeviceList GetPlaybackDevices(DefSound::EDeviceState state) const;
AudioDeviceList GetRecordingDevices(DefSound::EDeviceState state) const;
AudioEndPointLibrarySignals* m_signals1() const
{
return m_signals;
}
__declspec(property(get = m_signals1)) AudioEndPointLibrarySignals* Signals;
private:
CAudioEndPointLibrary(void);
CAudioEndPointLibrary(CAudioEndPointLibrary const&) = delete;
void operator=(CAudioEndPointLibrary const&) = delete;
void Refresh() const;
HRESULT RegisterNotificationClient() const;
HRESULT UnRegisterNotificationClient() const;
struct AudioEndPointLibraryImpl;
struct AudioEndPointLibraryDevicesImpl;
AudioEndPointLibraryImpl* m_container;
AudioEndPointLibrarySignals* m_signals;
AudioEndPointLibraryDevicesImpl* m_devices_lists;
};
}
|
Add fallback implemetation for rint()/round() | /* GTK - The GIMP Toolkit
* Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw>
*
* Author: Chun-wei Fan <fanc999@yahoo.com.tw>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <math.h>
/* Workaround for round() for non-GCC/non-C99 compilers */
#ifndef HAVE_ROUND
static inline double
round (double x)
{
if (x >= 0)
return floor (x + 0.5);
else
return ceil (x - 0.5);
}
#endif
/* Workaround for rint() for non-GCC/non-C99 compilers */
#ifndef HAVE_RINT
static inline double
rint (double x)
{
if (ceil (x + 0.5) == floor (x + 0.5))
{
int a;
a = (int) ceil (x);
if (a % 2 == 0)
return ceil (x);
else
return floor (x);
}
else
{
if (x >= 0)
return floor (x + 0.5);
else
return ceil (x - 0.5);
}
}
#endif | |
Test attribute merging for the availability attribute. | // RUN: %clang_cc1 "-triple" "x86_64-apple-darwin3.0.0-iphoneos" -fsyntax-only -verify %s
void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1)));
void f1(int) __attribute__((availability(ios,introduced=2.1)));
void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0)));
void f3(int) __attribute__((availability(ios,introduced=3.0)));
void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
void test() {
f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}}
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in iOS 3.0}}
f3(0);
f4(0); // expected-error{{f4' is unavailable: obsoleted in iOS 3.0}}
}
| // RUN: %clang_cc1 "-triple" "x86_64-apple-darwin3.0.0-iphoneos" -fsyntax-only -verify %s
void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1)));
void f1(int) __attribute__((availability(ios,introduced=2.1)));
void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0)));
void f3(int) __attribute__((availability(ios,introduced=3.0)));
void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0)));
void f6(int) __attribute__((availability(ios,deprecated=3.0)));
void f6(int) __attribute__((availability(ios,introduced=2.0)));
void test() {
f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}}
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in iOS 3.0}}
f3(0);
f4(0); // expected-error{{f4' is unavailable: obsoleted in iOS 3.0}}
f5(0); // expected-warning{{'f5' is deprecated: first deprecated in iOS 3.0}}
f6(0); // expected-warning{{'f6' is deprecated: first deprecated in iOS 3.0}}
}
|
Change return value of run to bool | #pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATION_H_
#include <unordered_map>
#include "../ds_task_typedefs.h"
namespace You {
namespace DataStore {
/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
/// The constructor
/// \param stask the serialized task the operation need to work with
explicit IOperation(SerializedTask& stask);
virtual ~IOperation();
/// Executes the operation
virtual void run() = 0;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_INTERNAL_OPERATION_H_
| #pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATION_H_
#include <unordered_map>
#include "../ds_task_typedefs.h"
namespace You {
namespace DataStore {
/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
/// The constructor
/// \param stask the serialized task the operation need to work with
explicit IOperation(SerializedTask& stask);
virtual ~IOperation();
/// Executes the operation
virtual bool run() = 0;
protected:
TaskId taskId;
SerializedTask task;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_INTERNAL_OPERATION_H_
|
Comment out conflicting debug macro | /*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file util.h
* @author Tim Hughes <tim@twistedfury.com>
* @date 2015
*/
#pragma once
#include <stdint.h>
#include "compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
void debugf(char const* str, ...);
#else
#define debugf printf
#endif
static inline uint32_t min_u32(uint32_t a, uint32_t b)
{
return a < b ? a : b;
}
static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_)
{
return x < min_ ? min_ : (x > max_ ? max_ : x);
}
#ifdef __cplusplus
}
#endif
| /*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file util.h
* @author Tim Hughes <tim@twistedfury.com>
* @date 2015
*/
#pragma once
#include <stdint.h>
#include "compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
//#ifdef _MSC_VER
void debugf(char const* str, ...);
//#else
//#define debugf printf
//#endif
static inline uint32_t min_u32(uint32_t a, uint32_t b)
{
return a < b ? a : b;
}
static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_)
{
return x < min_ ? min_ : (x > max_ ? max_ : x);
}
#ifdef __cplusplus
}
#endif
|
Use double instead of float | #include <stdio.h>
#include <math.h>
float f(float x) {
return 1/x;
}
int main(int argc, char *argv[]) {
// Integral (1 to 6) of 1/x
float integral;
float a = 1, b = 6;
int n = 2000;
float h;
float x;
h = (b-a)/n;
integral = (f(a) + f(b)) / 2.0;
x = a;
for (int i = 1; i <= n - 1; i++) {
x = x + h;
integral = integral + f(x);
}
integral = integral * h;
float expected = 1.79175946923;
printf("Integral (%.0f to %.0f) of 1/x \n\n", a, b);
printf("Expected result = %.11f\n", expected);
printf("Estimated result = %.11f\n", integral);
printf(" -------------\n");
float difference = expected - integral;
difference = fabsf(difference); // absolute value (no minus sign)
printf("Difference = %.11f\n", difference);
return 0;
}
| #include <stdio.h>
#include <math.h>
double f(double x) { return 1 / x; }
int main(int argc, char *argv[]) {
// Integral (1 to 6) of 1/x
double integral;
int a = 1, b = 6;
int n = 2000;
double h;
double x;
h = (double)(b-a)/n;
integral = (f(a) + f(b)) / 2.0;
x = a;
for (int i = 1; i < n; i++) {
x = x + h;
integral = integral + f(x);
}
integral = integral * h;
double expected = 1.79175946923;
printf("Integral (%d to %d) of 1/x \n\n", a, b);
printf("Expected result = %.11f\n", expected);
printf("Estimated result = %.11f\n", integral);
printf(" -------------\n");
double difference = expected - integral;
difference = fabsf(difference); // absolute value (no minus sign)
printf("Difference = %.11f\n", difference);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.