Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add the BSD make build machinery | /*
* Hello World Program
* 2013-05-27
*/
#include <stdio.h>
int
main()
{
printf("Hello, World!\g");
return 0;
}
| /*
* Hello World Program
* 2013-05-27
*/
#include <stdio.h>
int
main()
{
printf("Hello, World!\n");
return 0;
}
|
Add flag to stage api change | /*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
#define GR_TEST_UTILS 1
#define SK_BUILD_FOR_ANDROID_FRAMEWORK
#define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024)
#define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
#define SK_USE_FREETYPE_EMBOLDEN
// Disable these Ganesh features
#define SK_DISABLE_REDUCE_OPLIST_SPLITTING
// Check error is expensive. HWUI historically also doesn't check its allocations
#define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0
// Legacy flags
#define SK_IGNORE_GPU_DITHER
#define SK_SUPPORT_DEPRECATED_CLIPOPS
// Staging flags
#define SK_LEGACY_PATH_ARCTO_ENDPOINT
// Needed until we fix https://bug.skia.org/2440
#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
#define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
#define SK_SUPPORT_LEGACY_AA_CHOICE
#define SK_SUPPORT_LEGACY_AAA_CHOICE
#define SK_DISABLE_DAA // skbug.com/6886
#endif // SkUserConfigManual_DEFINED
| /*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
#define GR_TEST_UTILS 1
#define SK_BUILD_FOR_ANDROID_FRAMEWORK
#define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024)
#define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
#define SK_USE_FREETYPE_EMBOLDEN
// Disable these Ganesh features
#define SK_DISABLE_REDUCE_OPLIST_SPLITTING
// Check error is expensive. HWUI historically also doesn't check its allocations
#define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0
// Legacy flags
#define SK_IGNORE_GPU_DITHER
#define SK_SUPPORT_DEPRECATED_CLIPOPS
// Staging flags
#define SK_LEGACY_PATH_ARCTO_ENDPOINT
#define SK_SUPPORT_LEGACY_MATRIX_IMAGEFILTER
// Needed until we fix https://bug.skia.org/2440
#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
#define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
#define SK_SUPPORT_LEGACY_AA_CHOICE
#define SK_SUPPORT_LEGACY_AAA_CHOICE
#define SK_DISABLE_DAA // skbug.com/6886
#endif // SkUserConfigManual_DEFINED
|
Remove two variables which are handled MI now. | /*-
* Copyright (c) 2001 Jake Burkholder.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _MACHINE_CLOCK_H_
#define _MACHINE_CLOCK_H_
extern u_long tick_increment;
extern u_long tick_freq;
extern u_long tick_MHz;
extern int adjkerntz;
extern int wall_cmos_clock;
#endif /* !_MACHINE_CLOCK_H_ */
| /*-
* Copyright (c) 2001 Jake Burkholder.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _MACHINE_CLOCK_H_
#define _MACHINE_CLOCK_H_
extern u_long tick_increment;
extern u_long tick_freq;
extern u_long tick_MHz;
#endif /* !_MACHINE_CLOCK_H_ */
|
Add compose header to CLI | #include <stdio.h>
#include "ot.h"
#include "otdecode.h"
int main(int argc, const char * argv[])
{
char buf[1024];
fputs("Operation 1: ", stdout);
fgets(buf, 1024, stdin);
char p[64];
ot_op* op = ot_new_op(0, p);
ot_decode_err err = ot_decode(op, buf);
if (err != OT_ERR_NONE) {
puts("Error when decoding JSON.");
return err;
}
char buf2[1024];
fputs("Operation 2: ", stdout);
fgets(buf2, 1024, stdin);
ot_op* op2 = ot_new_op(0, p);
err = ot_decode(op2, buf2);
if (err != OT_ERR_NONE) {
puts("Error when decoding JSON.");
return err;
}
ot_op* composed = ot_compose(op, op2);
char* snapshot = ot_snapshot(composed);
puts("Composed: ");
puts(snapshot);
return 0;
}
| #include <stdio.h>
#include "ot.h"
#include "compose.h"
#include "otdecode.h"
int main(int argc, const char * argv[])
{
char buf[1024];
fputs("Operation 1: ", stdout);
fgets(buf, 1024, stdin);
char p[64];
ot_op* op = ot_new_op(0, p);
ot_decode_err err = ot_decode(op, buf);
if (err != OT_ERR_NONE) {
puts("Error when decoding JSON.");
return err;
}
char buf2[1024];
fputs("Operation 2: ", stdout);
fgets(buf2, 1024, stdin);
ot_op* op2 = ot_new_op(0, p);
err = ot_decode(op2, buf2);
if (err != OT_ERR_NONE) {
puts("Error when decoding JSON.");
return err;
}
ot_op* composed = ot_compose(op, op2);
char* snapshot = ot_snapshot(composed);
puts("Composed: ");
puts(snapshot);
return 0;
}
|
Fix test case 11 to set the number of omp threads and make it portable | #include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double sinTable[256];
#pragma omp parallel for
for(int n=0; n<256; ++n)
sinTable[n] = sin(2 * M_PI * n / 256);
// the table is now initialized
}
// RUN: clang -fopenmp -c -g -emit-llvm %s -o %t.1.bc
// RUN: opt -instnamer %t.1.bc -o %t.bc
// RUN: llvm-epp %t.bc -o %t.profile
// RUN: clang -fopenmp -v %t.epp.bc -o %t-exec -lepp-rt -lpthread -lm 2> %t.compile
// RUN: %t-exec > %t.log
// RUN: llvm-epp -p=%t.profile %t.bc 2> %t.decode
// RUN: diff -aub %t.profile %s.txt
| #include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double sinTable[256];
#pragma omp parallel for
for(int n=0; n<256; ++n)
sinTable[n] = sin(2 * M_PI * n / 256);
// the table is now initialized
}
// RUN: clang -fopenmp -c -g -emit-llvm %s -o %t.1.bc
// RUN: opt -instnamer %t.1.bc -o %t.bc
// RUN: llvm-epp %t.bc -o %t.profile
// RUN: clang -fopenmp -v %t.epp.bc -o %t-exec -lepp-rt -lpthread -lm 2> %t.compile
// RUN: OMP_NUM_THREADS=4 %t-exec > %t.log
// RUN: llvm-epp -p=%t.profile %t.bc 2> %t.decode
// RUN: diff -aub %t.profile %s.txt
|
Handle the terminal resizing while suspended, by sending ourselves a SIGWINCH after restoring. | /* A simple Lua module to suspend this process. */
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <lua.h>
#include <lauxlib.h>
int l_kill(lua_State *L)
{
/* Send ourselves the terminal stop signal, equivalent to normally
* pressing ^Z. */
kill(0, SIGTSTP);
return 0;
}
/* The module's functions */
struct luaL_Reg functions[] = {
{ "kill", l_kill },
{ 0, 0 },
};
/* Called when importing this module */
int luaopen_kill(lua_State *L)
{
luaL_newlib(L, functions);
return 1;
}
| /* A simple Lua module to suspend this process. */
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <lua.h>
#include <lauxlib.h>
int l_kill(lua_State *L)
{
/* Send ourselves the terminal stop signal, equivalent to normally
* pressing ^Z. */
kill(0, SIGTSTP);
/* We may have been restored after a window change; pretend we've
* received a WINCH. */
kill(0, SIGWINCH);
return 0;
}
/* The module's functions */
struct luaL_Reg functions[] = {
{ "kill", l_kill },
{ 0, 0 },
};
/* Called when importing this module */
int luaopen_kill(lua_State *L)
{
luaL_newlib(L, functions);
return 1;
}
|
Test standard C interface for ll?seek | #include <sys/stat.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
static long posix(const char path[static 1])
{
struct stat metadata;
assert(!stat(path, &metadata));
return metadata.st_size;
}
static long standard(const char path[static 1])
{
FILE* stream = fopen(path, "rb");
fseek(stream, 0, SEEK_END);
long position = ftell(stream);
fclose(stream);
return position;
}
int main(void)
{
const char path[] = "metallic.a";
assert(posix(path) == standard(path));
assert(!errno);
}
| |
Add a prototype for abs(). | /*
* Copyright (C) 2014, Galois, Inc.
* This sotware is distributed under a standard, three-clause BSD license.
* Please see the file LICENSE, distributed with this software, for specific
* terms and conditions.
*/
#ifndef MINLIBC_STDLIB_H
#define MINLIBC_STDLIB_H
#define NULL 0
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
typedef unsigned long int size_t;
double atof(const char *nptr);
int atoi(const char *nptr);
long int strtol(const char *nptr, char **endptr, int base);
char *getenv(const char *name);
void abort(void);
void exit(int status);
void *malloc(size_t size);
void *realloc(void *ptr, size_t size);
void *calloc(size_t nmemb, size_t size);
void free(void *ptr);
int mkstemp(char *template);
void *bsearch(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *));
int putenv(char *str);
int unsetenv(const char *name);
#endif
| /*
* Copyright (C) 2014, Galois, Inc.
* This sotware is distributed under a standard, three-clause BSD license.
* Please see the file LICENSE, distributed with this software, for specific
* terms and conditions.
*/
#ifndef MINLIBC_STDLIB_H
#define MINLIBC_STDLIB_H
#define NULL 0
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
typedef unsigned long int size_t;
double atof(const char *nptr);
int atoi(const char *nptr);
long int strtol(const char *nptr, char **endptr, int base);
char *getenv(const char *name);
void abort(void);
void exit(int status);
void *malloc(size_t size);
void *realloc(void *ptr, size_t size);
void *calloc(size_t nmemb, size_t size);
void free(void *ptr);
int mkstemp(char *template);
void *bsearch(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *));
int putenv(char *str);
int unsetenv(const char *name);
int abs(int j);
#endif
|
Add methods to joinable to handle streams | #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;
namespace com { namespace kurento { namespace kms {
class JoinableImpl : public virtual Joinable, public virtual MediaObjectImpl {
public:
JoinableImpl();
~JoinableImpl() throw() {};
void join(const JoinableImpl& to, const Direction::type direction);
void unjoin(const JoinableImpl& to);
std::vector<Joinable> &getJoinees();
std::vector<Joinable> &getDirectionJoiness(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 */ |
Change votes to use double. | #ifndef PROPOSER_H
#define PROPOSER_H
#include <boost/shared_ptr.hpp>
#include <vector>
#include <map>
#include "proctor/detector.h"
#include "proctor/database_entry.h"
namespace pcl
{
namespace proctor
{
struct Candidate {
std::string id;
float votes;
};
class Proposer {
public:
typedef boost::shared_ptr<Proposer> Ptr;
typedef boost::shared_ptr<const Proposer> ConstPtr;
typedef boost::shared_ptr<std::map<std::string, Entry> > DatabasePtr;
typedef boost::shared_ptr<const std::map<std::string, Entry> > ConstDatabasePtr;
Proposer()
{}
void
setDatabase(const DatabasePtr database)
{
database_ = database;
}
virtual void
getProposed(int max_num, Entry &query, std::vector<std::string> &input, std::vector<std::string> &output) = 0;
virtual void
selectBestCandidates(int max_num, vector<Candidate> &ballot, std::vector<std::string> &output);
protected:
DatabasePtr database_;
};
}
}
#endif
| #ifndef PROPOSER_H
#define PROPOSER_H
#include <boost/shared_ptr.hpp>
#include <vector>
#include <map>
#include "proctor/detector.h"
#include "proctor/database_entry.h"
namespace pcl
{
namespace proctor
{
struct Candidate {
std::string id;
double votes;
};
class Proposer {
public:
typedef boost::shared_ptr<Proposer> Ptr;
typedef boost::shared_ptr<const Proposer> ConstPtr;
typedef boost::shared_ptr<std::map<std::string, Entry> > DatabasePtr;
typedef boost::shared_ptr<const std::map<std::string, Entry> > ConstDatabasePtr;
Proposer()
{}
void
setDatabase(const DatabasePtr database)
{
database_ = database;
}
virtual void
getProposed(int max_num, Entry &query, std::vector<std::string> &input, std::vector<std::string> &output) = 0;
virtual void
selectBestCandidates(int max_num, vector<Candidate> &ballot, std::vector<std::string> &output);
protected:
DatabasePtr database_;
};
}
}
#endif
|
Adjust for changes in libkcal | /*
KDE2 compatibility for KDE Alarm Daemon and KDE Alarm Daemon GUI.
This file is part of the KDE alarm daemon.
Copyright (c) 2001 David Jarvie <software@astrojar.org.uk>
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., 675 Mass Ave, Cambridge, MA 02139, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef AD_COMPAT_H
#define AD_COMPAT_H
// Compatibility with KDE 2.2
#include <qglobal.h>
#if QT_VERSION < 300
#define QPtrList QList
#define QPtrListIterator QListIterator
#endif
#include <kapp.h>
#if KDE_VERSION < 290
#define Alarm KOAlarm
#endif
#endif
| /*
KDE2 compatibility for KDE Alarm Daemon and KDE Alarm Daemon GUI.
This file is part of the KDE alarm daemon.
Copyright (c) 2001 David Jarvie <software@astrojar.org.uk>
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., 675 Mass Ave, Cambridge, MA 02139, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef AD_COMPAT_H
#define AD_COMPAT_H
// Compatibility with KDE 2.2
#include <qglobal.h>
#if QT_VERSION < 300
#define QPtrList QList
#define QPtrListIterator QListIterator
#endif
#include <kapp.h>
#if KDE_VERSION < 290
#define Alarm KOAlarm
#define uid VUID
#endif
#endif
|
Remove unused declaration of __initramfs_start | #ifndef __OPENRISC_VMLINUX_H_
#define __OPENRISC_VMLINUX_H_
#ifdef CONFIG_BLK_DEV_INITRD
extern char __initrd_start, __initrd_end;
extern char __initramfs_start;
#endif
extern u32 __dtb_start[];
#endif
| #ifndef __OPENRISC_VMLINUX_H_
#define __OPENRISC_VMLINUX_H_
#ifdef CONFIG_BLK_DEV_INITRD
extern char __initrd_start, __initrd_end;
#endif
extern u32 __dtb_start[];
#endif
|
Add macros to check for iOS 8 | //
// GCMDeviceInfo.h
// GCMCocoaExtensions
//
// Created by Jerry Hsu on 11/26/13.
// Copyright (c) 2013 GameChanger. All rights reserved.
//
#import <Foundation/Foundation.h>
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#define IOS7_OR_GREATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
#define PRE_IOS7 SYSTEM_VERSION_LESS_THAN(@"7.0")
@interface GCMDeviceInfo : NSObject
+ (BOOL)isRetinaDisplay;
+ (BOOL)iPad;
@end
| //
// GCMDeviceInfo.h
// GCMCocoaExtensions
//
// Created by Jerry Hsu on 11/26/13.
// Copyright (c) 2013 GameChanger. All rights reserved.
//
#import <Foundation/Foundation.h>
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#define IOS7_OR_GREATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
#define PRE_IOS7 SYSTEM_VERSION_LESS_THAN(@"7.0")
#define IOS8_OR_GREATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
#define PRE_IOS8 SYSTEM_VERSION_LESS_THAN(@"8.0")
@interface GCMDeviceInfo : NSObject
+ (BOOL)isRetinaDisplay;
+ (BOOL)iPad;
@end
|
Adjust RPC parameter qualification for CAmkES changes. | /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#include <Echo.h>
#include <string.h>
void b__init(void) {
}
char * b_echo_string(char *s) {
return strdup(s);
}
int b_echo_int(int i) {
return i;
}
float b_echo_float(float f) {
return f;
}
double b_echo_double(double d) {
return d;
}
int b_echo_mix(double d) {
return d;
}
int b_echo_parameter(int pin, int *pout) {
*pout = pin;
return pin;
}
void b_increment_parameter(int *x) {
*x = *x + 1;
}
| /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#include <Echo.h>
#include <string.h>
void b__init(void) {
}
char * b_echo_string(const char *s) {
return strdup(s);
}
int b_echo_int(int i) {
return i;
}
float b_echo_float(float f) {
return f;
}
double b_echo_double(double d) {
return d;
}
int b_echo_mix(double d) {
return d;
}
int b_echo_parameter(int pin, int *pout) {
*pout = pin;
return pin;
}
void b_increment_parameter(int *x) {
*x = *x + 1;
}
|
Reset a session if implicit reset option is set | #ifndef LIBTRADING_FAST_FEED_H
#define LIBTRADING_FAST_FEED_H
#include "libtrading/proto/fast_session.h"
#include <sys/socket.h>
#include <sys/types.h>
struct fast_feed {
struct fast_session *session;
struct fast_session_cfg cfg;
u64 recv_num;
char xml[128];
char lip[32];
char sip[32];
char ip[32];
bool active;
int port;
};
static inline int socket_setopt(int sockfd, int level, int optname, int optval)
{
return setsockopt(sockfd, level, optname, (void *) &optval, sizeof(optval));
}
static inline struct fast_message *fast_feed_recv(struct fast_feed *feed, int flags)
{
return fast_session_recv(feed->session, flags);
}
int fast_feed_close(struct fast_feed *feed);
int fast_feed_open(struct fast_feed *feed);
#endif /* LIBTRADING_FAST_FEED_H */
| #ifndef LIBTRADING_FAST_FEED_H
#define LIBTRADING_FAST_FEED_H
#include "libtrading/proto/fast_session.h"
#include <sys/socket.h>
#include <sys/types.h>
struct fast_feed {
struct fast_session *session;
struct fast_session_cfg cfg;
u64 recv_num;
char xml[128];
char lip[32];
char sip[32];
char ip[32];
bool active;
int port;
};
static inline int socket_setopt(int sockfd, int level, int optname, int optval)
{
return setsockopt(sockfd, level, optname, (void *) &optval, sizeof(optval));
}
static inline struct fast_message *fast_feed_recv(struct fast_feed *feed, int flags)
{
if (feed->session->reset)
fast_session_reset(feed->session);
return fast_session_recv(feed->session, flags);
}
int fast_feed_close(struct fast_feed *feed);
int fast_feed_open(struct fast_feed *feed);
#endif /* LIBTRADING_FAST_FEED_H */
|
Update driver version to 5.03.00-k2 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k1"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k2"
|
Add an octagn test for handling pointers | void change(int *p) {
(*p)++;
}
int a;
int main() {
a = 5;
int *p = &a;
change(p);
assert(a - 6 == 0);
return 0;
} | |
Remove a deprecation for minor-minor release | //
// SZSmartAlertUtils.h
// SocializeSDK
//
// Created by Nathaniel Griswold on 6/4/12.
// Copyright (c) 2012 Socialize, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SZSmartAlertUtils : NSObject
+ (BOOL)isAvailable;
+ (BOOL)handleNotification:(NSDictionary*)userInfo __attribute__((deprecated("Please use `openNotification:` (which unconditionally opens the notification), instead")));
+ (BOOL)isSocializeNotification:(NSDictionary*)userInfo;
+ (void)registerDeviceToken:(NSData*)deviceToken;
+ (BOOL)openNotification:(NSDictionary*)userInfo;
@end | //
// SZSmartAlertUtils.h
// SocializeSDK
//
// Created by Nathaniel Griswold on 6/4/12.
// Copyright (c) 2012 Socialize, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SZSmartAlertUtils : NSObject
+ (BOOL)isAvailable;
+ (BOOL)handleNotification:(NSDictionary*)userInfo; // __attribute__((deprecated("Please use `openNotification:` (which unconditionally opens the notification), instead")));
+ (BOOL)isSocializeNotification:(NSDictionary*)userInfo;
+ (void)registerDeviceToken:(NSData*)deviceToken;
+ (BOOL)openNotification:(NSDictionary*)userInfo;
@end |
Update / add vec3 => JSON functions | /*
* Copyright (C) 2015 Luke San Antonio
* All rights reserved.
*/
#pragma once
#include "rapidjson/document.h"
#include "glm/glm.hpp"
namespace redc
{
inline glm::vec3 vec3_from_js(rapidjson::Value const& v) noexcept
{
return glm::vec3{v["x"].GetDouble(),v["y"].GetDouble(),v["z"].GetDouble()};
}
}
| /*
* Copyright (C) 2015 Luke San Antonio
* All rights reserved.
*/
#pragma once
#include "rapidjson/document.h"
#include "glm/glm.hpp"
namespace redc
{
inline glm::vec3 vec3_from_js_object(rapidjson::Value const& v) noexcept
{
return glm::vec3{v["x"].GetDouble(),v["y"].GetDouble(),v["z"].GetDouble()};
}
inline glm::vec3 vec3_from_js_array(rapidjson::Value const& v) noexcept
{
return glm::vec3{v[0].GetDouble(),v[1].GetDouble(),v[2].GetDouble()};
}
}
|
Work around an optimization bug in IsPowerOfTwo. | #ifndef LOG2_H
#define LOG2_H
template <typename T>
#ifdef __GNUC__
__attribute__((const))
#endif
static bool IsPowerOfTwo(const T& x)
{
return (x & (x - 1)) == 0;
}
template<typename T>
#ifdef __GNUC__
__attribute__((const))
#endif
static inline unsigned ilog2(T n)
{
// returns the first power of two equal to
// or greater than n. For example ilog2(1) = 0, ilog2(4) = 2, ilog2(5) = 3
unsigned l = 0;
T r = 1;
while (r < n)
{
l++;
r *= 2;
}
return l;
}
#endif
| #ifndef LOG2_H
#define LOG2_H
template <typename T>
#ifdef __GNUC__
__attribute__((const))
#endif
static inline bool IsPowerOfTwo(T x)
{
return (x & (x - 1)) == 0;
}
template<typename T>
#ifdef __GNUC__
__attribute__((const))
#endif
static inline unsigned ilog2(T n)
{
// returns the first power of two equal to
// or greater than n. For example ilog2(1) = 0, ilog2(4) = 2, ilog2(5) = 3
unsigned l = 0;
T r = 1;
while (r < n)
{
l++;
r *= 2;
}
return l;
}
#endif
|
Disable test incompatible with new Android | // RUN: %clang_asan -O2 %s -o %t
// RUN: %env_asan_opts=check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// RUN: %env_asan_opts=check_printf=0 %run %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// FIXME: printf is not intercepted on Windows yet.
// XFAIL: windows-msvc
#include <stdio.h>
int main() {
#ifdef _MSC_VER
// FIXME: The test raises a dialog even though it's XFAILd.
return 42;
#endif
volatile char c = '0';
volatile int x = 12;
volatile float f = 1.239;
volatile char s[] = "34";
volatile int n[1];
printf("%c %d %.3f %s%n\n", c, x, f, s, &n[1]);
return 0;
// Check that %n is sanitized.
// CHECK-ON: stack-buffer-overflow
// CHECK-ON-NOT: 0 12 1.239 34
// CHECK-OFF: 0 12 1.239 34
}
| // RUN: %clang_asan -O2 %s -o %t
// RUN: %env_asan_opts=check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// RUN: %env_asan_opts=check_printf=0 %run %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
// FIXME: printf is not intercepted on Windows yet.
// XFAIL: windows-msvc
// New Bionic rejects %n
// https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336
// UNSUPPORTED: android
#include <stdio.h>
int main() {
#ifdef _MSC_VER
// FIXME: The test raises a dialog even though it's XFAILd.
return 42;
#endif
volatile char c = '0';
volatile int x = 12;
volatile float f = 1.239;
volatile char s[] = "34";
volatile int n[1];
printf("%c %d %.3f %s%n\n", c, x, f, s, &n[1]);
return 0;
// Check that %n is sanitized.
// CHECK-ON: stack-buffer-overflow
// CHECK-ON-NOT: 0 12 1.239 34
// CHECK-OFF: 0 12 1.239 34
}
|
Fix component build with gcc 4.6 on Android. | // Copyright 2014 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 CRYPTO_OPENSSL_BIO_STRING_H_
#define CRYPTO_OPENSSL_BIO_STRING_H_
#include <string>
#include "crypto/crypto_export.h"
// From <openssl/bio.h>
typedef struct bio_st BIO;
namespace crypto {
// Creates a new BIO that can be used with OpenSSL's various output functions,
// and which will write all output directly into |out|. This is primarily
// intended as a utility to reduce the amount of copying and separate
// allocations when performing extensive string modifications or streaming
// within OpenSSL.
//
// Note: |out| must remain valid for the duration of the BIO.
BIO* CRYPTO_EXPORT BIO_new_string(std::string* out);
} // namespace crypto
#endif // CRYPTO_OPENSSL_BIO_STRING_H_
| // Copyright 2014 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 CRYPTO_OPENSSL_BIO_STRING_H_
#define CRYPTO_OPENSSL_BIO_STRING_H_
#include <string>
#include "crypto/crypto_export.h"
// From <openssl/bio.h>
typedef struct bio_st BIO;
namespace crypto {
// Creates a new BIO that can be used with OpenSSL's various output functions,
// and which will write all output directly into |out|. This is primarily
// intended as a utility to reduce the amount of copying and separate
// allocations when performing extensive string modifications or streaming
// within OpenSSL.
//
// Note: |out| must remain valid for the duration of the BIO.
CRYPTO_EXPORT BIO* BIO_new_string(std::string* out);
} // namespace crypto
#endif // CRYPTO_OPENSSL_BIO_STRING_H_
|
Remove useless comment from umbrella header | //
// PathKit.h
// PathKit
//
// Created by Kyle Fuller on 20/11/2014.
// Copyright (c) 2014 Cocode. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for PathKit.
FOUNDATION_EXPORT double PathKitVersionNumber;
//! Project version string for PathKit.
FOUNDATION_EXPORT const unsigned char PathKitVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <PathKit/PublicHeader.h>
| //
// PathKit.h
// PathKit
//
// Created by Kyle Fuller on 20/11/2014.
// Copyright (c) 2014 Cocode. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for PathKit.
FOUNDATION_EXPORT double PathKitVersionNumber;
//! Project version string for PathKit.
FOUNDATION_EXPORT const unsigned char PathKitVersionString[];
|
Copy init brace conformance example, for structs | struct A
{
struct B
{
int i, j;
} b, c;
};
f(struct B *b)
{
struct A fine = {
.b = *b // XXX: should be no missing braces warning
};
struct A bad = {
.b = { *b }
};
}
| |
Add test for update function. | #include <stdlib.h>
#include <glib.h>
#include "bmi/bmi_cem.h"
static void test_bmi_initialize(void) {
BMI_Model *model = (BMI_Model *)malloc(sizeof(BMI_Model));
int status;
register_bmi_cem(model);
status = model->initialize(NULL, &(model->self));
g_assert_cmpint(status, ==, BMI_SUCCESS);
}
static void test_bmi_update(void) {
BMI_Model *model = (BMI_Model *)malloc(sizeof(BMI_Model));
int status;
register_bmi_cem(model);
status = model->initialize(NULL, &(model->self));
g_assert_cmpint(status, ==, BMI_SUCCESS);
status = model->update(&(model->self));
g_assert_cmpint(status, ==, BMI_SUCCESS);
}
int main(int argc, char* argv[]) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/bmi/initialize", &test_bmi_initialize);
// g_test_add_func("/bmi/update", &test_bmi_update);
return g_test_run();
}
| #include <stdlib.h>
#include <glib.h>
#include "bmi/bmi_cem.h"
static void test_bmi_initialize(void) {
BMI_Model *model = (BMI_Model *)malloc(sizeof(BMI_Model));
int status;
register_bmi_cem(model);
status = model->initialize(NULL, &(model->self));
g_assert_cmpint(status, ==, BMI_SUCCESS);
}
static void test_bmi_update(void) {
BMI_Model *model = (BMI_Model *)malloc(sizeof(BMI_Model));
int status;
register_bmi_cem(model);
status = model->initialize(NULL, &(model->self));
g_assert_cmpint(status, ==, BMI_SUCCESS);
status = model->update(&(model->self));
g_assert_cmpint(status, ==, BMI_SUCCESS);
}
int main(int argc, char* argv[]) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/bmi/initialize", &test_bmi_initialize);
g_test_add_func("/bmi/update", &test_bmi_update);
return g_test_run();
}
|
Add our new method to get the list of installed layouts | #ifndef SRC_KEYBORD_LAYOUT_OBSERVER_H_
#define SRC_KEYBORD_LAYOUT_OBSERVER_H_
#include "nan.h"
using namespace v8; // NOLINT
class KeyboardLayoutObserver : public node::ObjectWrap {
public:
static void Init(Handle<Object> target);
void HandleKeyboardLayoutChanged();
private:
KeyboardLayoutObserver(NanCallback *callback);
~KeyboardLayoutObserver();
static NAN_METHOD(New);
static NAN_METHOD(GetCurrentKeyboardLayout);
NanCallback *callback;
};
#endif // SRC_KEYBORD_LAYOUT_OBSERVER_H_
| #ifndef SRC_KEYBORD_LAYOUT_OBSERVER_H_
#define SRC_KEYBORD_LAYOUT_OBSERVER_H_
#include "nan.h"
using namespace v8; // NOLINT
class KeyboardLayoutObserver : public node::ObjectWrap {
public:
static void Init(Handle<Object> target);
void HandleKeyboardLayoutChanged();
private:
KeyboardLayoutObserver(NanCallback *callback);
~KeyboardLayoutObserver();
static NAN_METHOD(New);
static NAN_METHOD(GetCurrentKeyboardLayout);
static NAN_METHOD(GetInstalledKeyboardLayouts);
NanCallback *callback;
};
#endif // SRC_KEYBORD_LAYOUT_OBSERVER_H_
|
Fix UIPanGestureRecognizer property type; add property | @interface UIPanGestureRecognizer (Private)
@property (setter=_setHysteresis:) BOOL _hysteresis;
@end | @interface UIPanGestureRecognizer (Private)
@property (setter=_setHysteresis:) CGFloat _hysteresis;
@property (assign, nonatomic) BOOL failsPastMaxTouches;
@end |
Make ScopedOleInitializer work on windows if you aren't including build_config already. | // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_
#define CHROME_APP_SCOPED_OLE_INITIALIZER_H_
// Wraps OLE initialization in a cross-platform class meant to be used on the
// stack so init/uninit is done with scoping. This class is ok for use by
// non-windows platforms; it just doesn't do anything.
#if defined(OS_WIN)
#include <ole2.h>
class ScopedOleInitializer {
public:
ScopedOleInitializer() {
int ole_result = OleInitialize(NULL);
DCHECK(ole_result == S_OK);
}
~ScopedOleInitializer() {
OleUninitialize();
}
};
#else
class ScopedOleInitializer {
public:
// Empty, this class does nothing on non-win32 systems. Empty ctor is
// necessary to avoid "unused variable" warning on gcc.
ScopedOleInitializer() { }
};
#endif
#endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_
| // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_
#define CHROME_APP_SCOPED_OLE_INITIALIZER_H_
#include "base/logging.h"
#include "build/build_config.h"
// Wraps OLE initialization in a cross-platform class meant to be used on the
// stack so init/uninit is done with scoping. This class is ok for use by
// non-windows platforms; it just doesn't do anything.
#if defined(OS_WIN)
#include <ole2.h>
class ScopedOleInitializer {
public:
ScopedOleInitializer() {
int ole_result = OleInitialize(NULL);
DCHECK(ole_result == S_OK);
}
~ScopedOleInitializer() {
OleUninitialize();
}
};
#else
class ScopedOleInitializer {
public:
// Empty, this class does nothing on non-win32 systems. Empty ctor is
// necessary to avoid "unused variable" warning on gcc.
ScopedOleInitializer() { }
};
#endif
#endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_
|
Format strings and more through test for stack floats | // RUN: %ucc -o %t %s
// RUN: %ocheck 0 %t
// RUN: %t | %output_check 'Hello 5 2.3' 'Hello 5 2.3'
// should run without segfaulting
main()
{
printf("Hello %d %.1f\n",
5,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3); // this causes an infinite loop in glibc's printf()
printf("Hello %d %.1f\n",
5,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3,
2.3, // this causes an infinite loop in glibc's printf()
2.3); // and this causes a crash
// suspect the bug is to do with double alignment when passed as stack arguments
return 0;
}
| // RUN: %ucc -o %t %s
// RUN: %ocheck 0 %t
// RUN: %t | %output_check 'Hello 5 5.9' '7.3 8.7 10.1 11.5 12.9 14.3 15.7 17.1 18.5 19.9' 'Hello 5 15.7' '14.3 12.9 11.5 10.1 8.7 7.3 5.9 4.5 3.1 1.7 0.3'
// should run without segfaulting
main()
{
printf("Hello %d %.1f\n"
"%.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f\n",
5,
5.9,
7.3,
8.7,
10.1,
11.5,
12.9,
14.3,
15.7,
17.1,
18.5,
19.9); // this causes an infinite loop in glibc's printf()
printf("Hello %d %.1f\n"
"%.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f\n",
5,
15.7,
14.3,
12.9,
11.5,
10.1,
8.7,
7.3,
5.9,
4.5,
3.1,
1.7, // this causes an infinite loop in glibc's printf()
0.3); // and this causes a crash
// suspect the bug is to do with double alignment when passed as stack arguments
return 0;
}
|
Remove unused STL string include | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_SUPPORT_CC_TEXT_TOKENIZERS_TOKENIZER_JNI_LIB_H_
#define TENSORFLOW_LITE_SUPPORT_CC_TEXT_TOKENIZERS_TOKENIZER_JNI_LIB_H_
#include <jni.h>
#include <string>
#include "tensorflow_lite_support/cc/text/tokenizers/tokenizer.h"
#include "tensorflow_lite_support/cc/utils/jni_utils.h"
namespace tflite {
namespace support {
jobjectArray nativeTokenize(JNIEnv* env, jlong handle, jstring jtext);
jintArray nativeConvertTokensToIds(JNIEnv* env, jlong handle,
jobjectArray jtokens);
} // namespace support
} // namespace tflite
#endif // TENSORFLOW_LITE_SUPPORT_CC_TEXT_TOKENIZERS_TOKENIZER_JNI_LIB_H_
| /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_SUPPORT_CC_TEXT_TOKENIZERS_TOKENIZER_JNI_LIB_H_
#define TENSORFLOW_LITE_SUPPORT_CC_TEXT_TOKENIZERS_TOKENIZER_JNI_LIB_H_
#include <jni.h>
#include "tensorflow_lite_support/cc/text/tokenizers/tokenizer.h"
#include "tensorflow_lite_support/cc/utils/jni_utils.h"
namespace tflite {
namespace support {
jobjectArray nativeTokenize(JNIEnv* env, jlong handle, jstring jtext);
jintArray nativeConvertTokensToIds(JNIEnv* env, jlong handle,
jobjectArray jtokens);
} // namespace support
} // namespace tflite
#endif // TENSORFLOW_LITE_SUPPORT_CC_TEXT_TOKENIZERS_TOKENIZER_JNI_LIB_H_
|
Add skeleton for callback and a few global vars | /*
* Copyright 2008 Markus Prinz
* Released unter an MIT licence
*
*/
#include <ruby.h>
VALUE crbCoreMidi;
void Init_rbcoremidi (void)
{
// Add the initialization code of your module here.
}
| /*
* Copyright 2008 Markus Prinz
* Released unter an MIT licence
*
*/
#include <ruby.h>
#include <CoreMIDI/CoreMIDI.h>
VALUE callback_proc = Qnil;
MIDIPortRef inPort = NULL;
MIDIClientRef client = NULL;
static void RbMIDIReadProc(const MIDIPacketList* packetList, void* readProcRefCon, void* srcConnRefCon)
{
}
void Init_rbcoremidi (void)
{
// Add the initialization code of your module here.
}
|
Fix the naming of the var's to match the actual naming. | //
// StravaKitOSX.h
// StravaKitOSX
//
// Created by Elmar Tampe on 04/12/14.
//
//
#import <UIKit/UIKit.h>
//! Project version number for StravaKitOSX.
FOUNDATION_EXPORT double StravaKitOSXVersionNumber;
//! Project version string for StravaKitOSX.
FOUNDATION_EXPORT const unsigned char StravaKitOSXVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <StravaKitOSX/PublicHeader.h>
| //
// StravaKit.h
// StravaKit
//
// Created by Elmar Tampe on 04/12/14.
//
//
#import <UIKit/UIKit.h>
//! Project version number for StravaKit.
FOUNDATION_EXPORT double StravaKitVersionNumber;
//! Project version string for StravaKit.
FOUNDATION_EXPORT const unsigned char StravaKitVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <StravaKitOSX/PublicHeader.h>
|
Create file and read options | /* Standard libraries */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int distance, n_ciclists, uniforme;
if (argc != 4) {
fprintf(stderr, "USAGE: %s d n [v|u]\n", argv[0]);
return EXIT_FAILURE;
}
distance = atoi(argv[1]);
n_ciclists = atoi(argv[2]);
if (argv[3][1] != '\0') {
fprintf(stderr, "3rd argument must be 'u' or 'v'\n");
return EXIT_FAILURE;
}
switch (argv[3][0]) {
case 'u': uniforme = 1; break;
case 'v': uniforme = 0; break;
default:
fprintf(stderr, "3rd argument must be 'u' or 'v'\n");
return EXIT_FAILURE;
}
printf("d:%d n:%d uniforme:%d\n", distance, n_ciclists, uniforme);
return EXIT_SUCCESS;
}
| |
Change version, app and window name | #include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#define MY_UUID { 0x78, 0x1D, 0x21, 0x66, 0x09, 0x09, 0x4F, 0x9C, 0x88, 0xFD, 0x89, 0x9B, 0x04, 0xBF, 0x5E, 0x32 }
PBL_APP_INFO(MY_UUID,
"Template App", "Your Company",
1, 0, /* App version */
DEFAULT_MENU_ICON,
APP_INFO_STANDARD_APP);
Window window;
void handle_init(AppContextRef ctx) {
window_init(&window, "Window Name");
window_stack_push(&window, true /* Animated */);
}
void pbl_main(void *params) {
PebbleAppHandlers handlers = {
.init_handler = &handle_init
};
app_event_loop(params, &handlers);
}
| #include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#define MY_UUID { 0x78, 0x1D, 0x21, 0x66, 0x09, 0x09, 0x4F, 0x9C, 0x88, 0xFD, 0x89, 0x9B, 0x04, 0xBF, 0x5E, 0x32 }
PBL_APP_INFO(MY_UUID,
"Pomade", "Jon Speicher",
0, 1, /* App version */
DEFAULT_MENU_ICON,
APP_INFO_STANDARD_APP);
Window window;
void handle_init(AppContextRef ctx) {
window_init(&window, "Pomade");
window_stack_push(&window, true /* Animated */);
}
void pbl_main(void *params) {
PebbleAppHandlers handlers = {
.init_handler = &handle_init
};
app_event_loop(params, &handlers);
}
|
Change warning hint to be more useful | /*-
* Copyright (c) 2004 David E. O'Brien
* Copyright (c) 2004 Andrey A. Chernov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifdef __GNUC__
#warning "<gnuregex.h> has been replaced by <gnu/regex.h>"
#endif
#include <gnu/regex.h>
| /*-
* Copyright (c) 2004 David E. O'Brien
* Copyright (c) 2004 Andrey A. Chernov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifdef __GNUC__
#warning "Use -I/usr/include/gnu and <regex.h> instead of <gnuregex.h>"
#endif
#include <gnu/regex.h>
|
Make emulator run for a little longer in non-interactive mode | //
// Non-interactive test runner just produces register traces and memory dumps
//
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/poll.h>
#include <stdarg.h>
#include "core.h"
#include "debug_info.h"
void runNonInteractive(Core *core)
{
int i;
enableTracing(core);
runQuantum(core);
}
| //
// Non-interactive test runner just produces register traces and memory dumps
//
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/poll.h>
#include <stdarg.h>
#include "core.h"
#include "debug_info.h"
void runNonInteractive(Core *core)
{
int i;
enableTracing(core);
for (i = 0; i < 20; i++)
{
if (!runQuantum(core))
break;
}
}
|
Fix broken connection in quick settings dock | #ifndef SETTINGS_DOCK_H
#define SETTINGS_DOCK_H
#include <QStringList>
#include <QWidget>
#include "dock.h"
namespace Ui
{
class SettingsDock;
}
class Profile;
class QEvent;
class QSettings;
class SettingsDock : public Dock
{
Q_OBJECT
public:
explicit SettingsDock(Profile *profile, QWidget *parent);
~SettingsDock() override;
protected:
void changeEvent(QEvent *event) override;
void saveSettings();
public slots:
void reset();
protected slots:
void chooseFolder();
void save();
void updateCompleters();
private:
Ui::SettingsDock *ui;
Profile *m_profile;
QSettings *m_settings;
QStringList m_lineFilename_completer;
QStringList m_lineFolder_completer;
};
#endif // SETTINGS_DOCK_H
| #ifndef SETTINGS_DOCK_H
#define SETTINGS_DOCK_H
#include <QStringList>
#include <QWidget>
#include "dock.h"
namespace Ui
{
class SettingsDock;
}
class Profile;
class QEvent;
class QSettings;
class SettingsDock : public Dock
{
Q_OBJECT
public:
explicit SettingsDock(Profile *profile, QWidget *parent);
~SettingsDock() override;
protected:
void changeEvent(QEvent *event) override;
public slots:
void reset();
protected slots:
void chooseFolder();
void save();
void saveSettings();
void updateCompleters();
private:
Ui::SettingsDock *ui;
Profile *m_profile;
QSettings *m_settings;
QStringList m_lineFilename_completer;
QStringList m_lineFolder_completer;
};
#endif // SETTINGS_DOCK_H
|
Set hook to block all ICMP packets | #include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
static struct nf_hook_ops nfho;
unsigned int hook_func(unsigned int hooknum,
struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
return NF_DROP;
}
int init_module() {
nfho.hook = hook_func;
nfho.hooknum = NF_INET_PRE_ROUTING;
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho);
return 0;
}
void cleanup_module() {
nf_unregister_hook(&nfho);
}
| #include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
static struct nf_hook_ops nfho;
unsigned int hook_func(unsigned int hooknum,
struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
socket_buff = skb;
if (!socket_buff) {
return NF_ACCEPT;
} else {
ip_header = (stuct iphdr *)skb_network_header(socket_buff); // Network header
// Drop all ICMP packets
if (ip_header->protocol == IPPROTO_ICMP) {
return NF_DROP;
}
}
}
int init_module() {
nfho.hook = hook_func;
nfho.hooknum = NF_INET_PRE_ROUTING;
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho);
return 0;
}
void cleanup_module() {
nf_unregister_hook(&nfho);
}
|
Add warn_unused_result to the ArgParse functions | #ifndef ARGPARSE_ArgObject_HDR
#define ARGPARSE_ArgObject_HDR
#include <string>
namespace ArgParse {
class ArgObject {
public:
typedef int Accept_t;
static const Accept_t No;
static const Accept_t WithArg;
static const Accept_t WithoutArg;
ArgObject();
virtual ~ArgObject();
virtual Accept_t AcceptsArgument(std::string arg) = 0;
virtual int PassArgument(std::string arg, std::string opt, bool with_opt) = 0;
virtual bool IsReady() = 0;
virtual std::string GetHelpText() = 0;
};
}
#endif
| #ifndef ARGPARSE_ArgObject_HDR
#define ARGPARSE_ArgObject_HDR
#include <string>
namespace ArgParse {
class ArgObject {
public:
typedef int Accept_t;
static const Accept_t No;
static const Accept_t WithArg;
static const Accept_t WithoutArg;
ArgObject();
virtual ~ArgObject();
virtual Accept_t AcceptsArgument(std::string arg) __attribute__((warn_unused_result)) = 0;
virtual int PassArgument(std::string arg, std::string opt, bool with_opt) __attribute__((warn_unused_result)) = 0;
virtual bool IsReady() __attribute__((warn_unused_result)) = 0;
virtual std::string GetHelpText() = 0;
};
}
#endif
|
Change get_cycles to always return 0. | /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1998, 1999, 2003 by Ralf Baechle
*/
#ifndef _ASM_TIMEX_H
#define _ASM_TIMEX_H
#ifdef __KERNEL__
#include <asm/mipsregs.h>
/*
* This is the clock rate of the i8253 PIT. A MIPS system may not have
* a PIT by the symbol is used all over the kernel including some APIs.
* So keeping it defined to the number for the PIT is the only sane thing
* for now.
*/
#define CLOCK_TICK_RATE 1193182
/*
* Standard way to access the cycle counter.
* Currently only used on SMP for scheduling.
*
* Only the low 32 bits are available as a continuously counting entity.
* But this only means we'll force a reschedule every 8 seconds or so,
* which isn't an evil thing.
*
* We know that all SMP capable CPUs have cycle counters.
*/
typedef unsigned int cycles_t;
static inline cycles_t get_cycles(void)
{
return read_c0_count();
}
#endif /* __KERNEL__ */
#endif /* _ASM_TIMEX_H */
| /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1998, 1999, 2003 by Ralf Baechle
*/
#ifndef _ASM_TIMEX_H
#define _ASM_TIMEX_H
#ifdef __KERNEL__
#include <asm/mipsregs.h>
/*
* This is the clock rate of the i8253 PIT. A MIPS system may not have
* a PIT by the symbol is used all over the kernel including some APIs.
* So keeping it defined to the number for the PIT is the only sane thing
* for now.
*/
#define CLOCK_TICK_RATE 1193182
/*
* Standard way to access the cycle counter.
* Currently only used on SMP for scheduling.
*
* Only the low 32 bits are available as a continuously counting entity.
* But this only means we'll force a reschedule every 8 seconds or so,
* which isn't an evil thing.
*
* We know that all SMP capable CPUs have cycle counters.
*/
typedef unsigned int cycles_t;
static inline cycles_t get_cycles(void)
{
return 0;
}
#endif /* __KERNEL__ */
#endif /* _ASM_TIMEX_H */
|
Make root object protected to allow access to the root object from within subclasses. | /*=============================================================================
Library: XNAT/Core
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
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 CTKXNATLISTMODEL_H
#define CTKXNATLISTMODEL_H
#include "QAbstractListModel"
#include "ctkXNATCoreExport.h"
class ctkXnatObject;
/**
* @ingroup XNAT_Core
*/
class CTK_XNAT_CORE_EXPORT ctkXnatListModel : public QAbstractListModel
{
Q_OBJECT
public:
ctkXnatListModel();
void setRootObject(ctkXnatObject* root);
ctkXnatObject* rootObject();
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
private:
ctkXnatObject* RootObject;
};
#endif // CTKXNATLISTMODEL_H
| /*=============================================================================
Library: XNAT/Core
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
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 CTKXNATLISTMODEL_H
#define CTKXNATLISTMODEL_H
#include "QAbstractListModel"
#include "ctkXNATCoreExport.h"
class ctkXnatObject;
/**
* @ingroup XNAT_Core
*/
class CTK_XNAT_CORE_EXPORT ctkXnatListModel : public QAbstractListModel
{
Q_OBJECT
public:
ctkXnatListModel();
void setRootObject(ctkXnatObject* root);
ctkXnatObject* rootObject();
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
protected:
ctkXnatObject* RootObject;
};
#endif // CTKXNATLISTMODEL_H
|
Remove protocol from umbrella header | //
// RZCollectionList.h
// RZCollectionList
//
// Created by Nick Donaldson on 6/21/13.
// Copyright (c) 2013 Raizlabs. All rights reserved.
//
/************************************************************
*
* Include this file to get all the collection lists you need!
*
************************************************************/
#import "RZCollectionListProtocol.h"
#import "RZArrayCollectionList.h"
#import "RZFetchedCollectionList.h"
#import "RZFilteredCollectionList.h"
#import "RZSortedCollectionList.h"
#import "RZCompositeCollectionList.h"
#import "RZCollectionListTableViewDataSource.h"
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)
#import "RZcollectionListCollectionViewDataSource.h"
#endif
// Category for helping construct fetch requests
#import "NSFetchRequest+RZCreationHelpers.h" | //
// RZCollectionList.h
// RZCollectionList
//
// Created by Nick Donaldson on 6/21/13.
// Copyright (c) 2013 Raizlabs. All rights reserved.
//
/************************************************************
*
* Include this file to get all the collection lists at once
*
************************************************************/
#import "RZArrayCollectionList.h"
#import "RZFetchedCollectionList.h"
#import "RZFilteredCollectionList.h"
#import "RZSortedCollectionList.h"
#import "RZCompositeCollectionList.h"
#import "RZCollectionListTableViewDataSource.h"
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)
#import "RZcollectionListCollectionViewDataSource.h"
#endif
// Category for helping construct fetch requests
#import "NSFetchRequest+RZCreationHelpers.h" |
Define macros from inttypes.h when not available |
#ifndef _json_inttypes_h_
#define _json_inttypes_h_
#include "json_config.h"
#if defined(_MSC_VER) && _MSC_VER <= 1700
/* Anything less than Visual Studio C++ 10 is missing stdint.h and inttypes.h */
typedef __int32 int32_t;
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX ((int32_t)_I32_MAX)
typedef __int64 int64_t;
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX ((int64_t)_I64_MAX)
#define PRId64 "I64d"
#define SCNd64 "I64d"
#else
#ifdef JSON_C_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/* inttypes.h includes stdint.h */
#endif
#endif
|
#ifndef _json_inttypes_h_
#define _json_inttypes_h_
#include "json_config.h"
#ifdef JSON_C_HAVE_INTTYPES_H
/* inttypes.h includes stdint.h */
#include <inttypes.h>
#else
#include <stdint.h>
#define PRId64 "I64d"
#define SCNd64 "I64d"
#endif
#endif
|
Print format if the length is longer than printf max length | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_vdprintf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jlagneau <jlagneau@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/17 18:58:30 by jlagneau #+# #+# */
/* Updated: 2017/04/22 14:18:29 by jlagneau ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <ft_printf.h>
int ft_vdprintf(int fd, const char *format, va_list ap)
{
int ret;
char str[FT_PRINTF_MAX_LEN];
ft_bzero(str, FT_PRINTF_MAX_LEN);
if (ft_strlen(format) > FT_PRINTF_MAX_LEN - 1)
{
ft_putstr_fd(str, fd);
return (-1);
}
ret = ft_vsprintf(str, format, ap);
ft_putstr_fd(str, fd);
return (ret);
}
| /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_vdprintf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jlagneau <jlagneau@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/17 18:58:30 by jlagneau #+# #+# */
/* Updated: 2017/04/22 14:22:04 by jlagneau ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <ft_printf.h>
int ft_vdprintf(int fd, const char *format, va_list ap)
{
int ret;
char str[FT_PRINTF_MAX_LEN];
ft_bzero(str, FT_PRINTF_MAX_LEN);
if (ft_strlen(format) > FT_PRINTF_MAX_LEN - 1)
{
ft_putstr_fd(format, fd);
return (-1);
}
ret = ft_vsprintf(str, format, ap);
ft_putstr_fd(str, fd);
return (ret);
}
|
Print symbol names in backtrace | #include <kernel/panic.h>
#include <macros.h>
#include <stdio.h>
#include <types.h>
#define MAX_STACK_FRAME 10000
/*
* Walk up the stack and print the locations of each stack frame base.
*/
void bt(void) {
u32 *ebp, *eip;
unsigned int sf = 0;
/* Start form the current stack base */
asm volatile("mov %%ebp, %0" : "=r" (ebp));
/* Continue until you reach a zeroed stack base pointer. The initial ebp
* value is zeroed at boot, but note that this could be corrupted in the
* case of serious memory corruption. To protect against this, we keep
* track of the frame number and break if it exceeds a reasonable
* maximum value. */
while (ebp) {
eip = ebp + 1;
printf("#%d [0x%x]\n", sf, *eip);
ebp = (u32*)*ebp;
sf++;
/* break if exceeded maximum */
if (sf > MAX_STACK_FRAME)
break;
}
}
| #include <kernel/panic.h>
#include <elf.h>
#include <macros.h>
#include <stdio.h>
#include <types.h>
#define MAX_STACK_FRAME 10000
/*
* Walk up the stack and print the locations of each stack frame base.
*/
void bt(void) {
u32 *ebp, *eip;
unsigned int sf = 0;
/* Start form the current stack base */
asm volatile("mov %%ebp, %0" : "=r" (ebp));
/* Continue until you reach a zeroed stack base pointer. The initial ebp
* value is zeroed at boot, but note that this could be corrupted in the
* case of serious memory corruption. To protect against this, we keep
* track of the frame number and break if it exceeds a reasonable
* maximum value. */
while (ebp) {
eip = ebp + 1;
printf("#%d [0x%x] %s\n",
sf, *eip, symbol_from_elf(&kelf, *eip));
ebp = (u32*)*ebp;
sf++;
/* break if exceeded maximum */
if (sf > MAX_STACK_FRAME)
break;
}
}
|
Remove now unused definition of phys_t. | /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
* Copyright (C) 2008 Wind River Systems,
* written by Ralf Baechle
* Copyright (C) 1999 Silicon Graphics, Inc.
*/
#ifndef _ASM_TYPES_H
#define _ASM_TYPES_H
#include <asm-generic/int-ll64.h>
#include <uapi/asm/types.h>
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifndef __ASSEMBLY__
/*
* Don't use phys_addr_t. You've been warned.
*/
#ifdef CONFIG_PHYS_ADDR_T_64BIT
typedef unsigned long long phys_addr_t;
#else
typedef unsigned long phys_addr_t;
#endif
#endif /* __ASSEMBLY__ */
#endif /* _ASM_TYPES_H */
| /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
* Copyright (C) 2008 Wind River Systems,
* written by Ralf Baechle
* Copyright (C) 1999 Silicon Graphics, Inc.
*/
#ifndef _ASM_TYPES_H
#define _ASM_TYPES_H
#include <asm-generic/int-ll64.h>
#include <uapi/asm/types.h>
#endif /* _ASM_TYPES_H */
|
Fix indentation of Assert macros | //
// OCAObject.h
// Objective-Chain
//
// Created by Martin Kiss on 30.12.13.
// Copyright © 2014 Martin Kiss. All rights reserved.
//
#import <Foundation/Foundation.h>
#define OCA_atomic atomic
#define OCALazyGetter(TYPE, PROPERTY) \
@synthesize PROPERTY = _##PROPERTY; \
- (TYPE)PROPERTY { \
if ( ! self->_##PROPERTY) { \
self->_##PROPERTY = [self oca_lazyGetter_##PROPERTY]; \
} \
return self->_##PROPERTY; \
} \
- (TYPE)oca_lazyGetter_##PROPERTY \
#if !defined(NS_BLOCK_ASSERTIONS)
#define OCAAssert(CONDITION, MESSAGE, ...) \
if ( ! (CONDITION) && (( [[NSAssertionHandler currentHandler] \
handleFailureInFunction: [NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
file: [NSString stringWithUTF8String:__FILE__] \
lineNumber: __LINE__ \
description: (MESSAGE), ##__VA_ARGS__], YES)) ) // Will NOT execute appended code, if exception is thrown.
#else
#define OCAAssert(CONDITION, MESSAGE, ...)\
if ( ! (CONDITION) && (( NSLog(@"*** Assertion failure in %s, %s:%d, Condition not satisfied: %s, reason: '" MESSAGE "'", __PRETTY_FUNCTION__, __FILE__, __LINE__, #CONDITION, ##__VA_ARGS__), YES)) ) // Will execute appended code.
#endif
@interface OCAObject : NSObject
@end
| //
// OCAObject.h
// Objective-Chain
//
// Created by Martin Kiss on 30.12.13.
// Copyright © 2014 Martin Kiss. All rights reserved.
//
#import <Foundation/Foundation.h>
#define OCA_atomic atomic
#define OCALazyGetter(TYPE, PROPERTY) \
@synthesize PROPERTY = _##PROPERTY; \
- (TYPE)PROPERTY { \
if ( ! self->_##PROPERTY) { \
self->_##PROPERTY = [self oca_lazyGetter_##PROPERTY]; \
} \
return self->_##PROPERTY; \
} \
- (TYPE)oca_lazyGetter_##PROPERTY \
#if !defined(NS_BLOCK_ASSERTIONS)
#define OCAAssert(CONDITION, MESSAGE, ...) \
if ( ! (CONDITION) && (( [[NSAssertionHandler currentHandler] \
handleFailureInFunction: [NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
file: [NSString stringWithUTF8String:__FILE__] \
lineNumber: __LINE__ \
description: (MESSAGE), ##__VA_ARGS__], YES)) ) // Will NOT execute appended code, if exception is thrown.
#else
#define OCAAssert(CONDITION, MESSAGE, ...)\
if ( ! (CONDITION) && (( NSLog(@"*** Assertion failure in %s, %s:%d, Condition not satisfied: %s, reason: '" MESSAGE "'", __PRETTY_FUNCTION__, __FILE__, __LINE__, #CONDITION, ##__VA_ARGS__), YES)) ) // Will execute appended code.
#endif
@interface OCAObject : NSObject
@end
|
Fix for new Push signature | #pragma once
#ifndef DUKTAPE_H_INCLUDED
#error Duktape.h should be included before this header
#endif
#include <vector>
namespace dukbind
{
template< typename _Type_ >
void Push( duk_context * ctx, const std::vector<_Type_> & table )
{
size_t index, end = table.size();
duk_idx_t arr_idx = duk_push_array( ctx );
for( index = 0; index < end; ++index )
{
Push( ctx, table[ index ], (_Type_*)0 );
duk_put_prop_index( ctx, arr_idx, index );
}
}
std::string Get( duk_context * ctx, const int index, const std::string * );
void Push( duk_context * ctx, const std::string & value );
}
| #pragma once
#ifndef DUKTAPE_H_INCLUDED
#error Duktape.h should be included before this header
#endif
#include <vector>
namespace dukbind
{
template< typename _Type_ >
void Push( duk_context * ctx, const std::vector<_Type_> & table )
{
size_t index, end = table.size();
duk_idx_t arr_idx = duk_push_array( ctx );
for( index = 0; index < end; ++index )
{
Push( ctx, table[ index ] );
duk_put_prop_index( ctx, arr_idx, index );
}
}
std::string Get( duk_context * ctx, const int index, const std::string * );
void Push( duk_context * ctx, const std::string & value );
}
|
Fix C-FFI: added pinned mark | // Copyright (c) <2015> <lummax>
// Licensed under MIT (http://opensource.org/licenses/MIT)
#ifndef RCIMMIXCONS_H
#define RCIMMIXCONS_H
#include <stdint.h>
#include <stdlib.h>
typedef struct {
size_t reference_count;
uint8_t spans_lines;
uint8_t forwarded;
uint8_t logged;
uint8_t marked;
uint8_t new;
} GCHeader;
typedef struct {
size_t object_size;
size_t num_members;
} GCRTTI;
typedef struct {
GCHeader header;
GCRTTI* rtti;
} GCObject;
typedef struct {} RCImmixCons;
RCImmixCons* rcx_create();
GCObject* rcx_allocate(RCImmixCons* collector, GCRTTI* rtti);
void rcx_collect(RCImmixCons* collector, uint8_t evacuation, uint8_t cycle_collect);
void rcx_write_barrier(RCImmixCons* collector, GCObject* object);
void rcx_destroy(RCImmixCons* collector);
#endif
| // Copyright (c) <2015> <lummax>
// Licensed under MIT (http://opensource.org/licenses/MIT)
#ifndef RCIMMIXCONS_H
#define RCIMMIXCONS_H
#include <stdint.h>
#include <stdlib.h>
typedef struct {
size_t reference_count;
uint8_t spans_lines;
uint8_t forwarded;
uint8_t logged;
uint8_t marked;
uint8_t pinned;
uint8_t new;
} GCHeader;
typedef struct {
size_t object_size;
size_t num_members;
} GCRTTI;
typedef struct {
GCHeader header;
GCRTTI* rtti;
} GCObject;
typedef struct {} RCImmixCons;
RCImmixCons* rcx_create();
GCObject* rcx_allocate(RCImmixCons* collector, GCRTTI* rtti);
void rcx_collect(RCImmixCons* collector, uint8_t evacuation, uint8_t cycle_collect);
void rcx_write_barrier(RCImmixCons* collector, GCObject* object);
void rcx_destroy(RCImmixCons* collector);
#endif
|
Remove references to Android from iOS API logger. | // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
#pragma once
#include "Types.h"
#if defined(EEGEO_DROID)
#include <android/log.h>
#define EXAMPLE_LOG(...) __android_log_print(ANDROID_LOG_INFO,"Eegeo_Examples",__VA_ARGS__)
#else
#define EXAMPLE_LOG(...) printf(__VA_ARGS__)
#endif
| // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
#pragma once
#define EXAMPLE_LOG(...) printf(__VA_ARGS__)
|
Fix bug that was causing error building pod in RubyMotion project | //
// Copyright 2012 Ludovic Landry - http://about.me/ludoviclandry
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language governing
// permissions and limitations under the License.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "QRootElement.h"
@interface QImageElement : QEntryElement
@property (nonatomic, strong) UIImage *imageValue;
@property (nonatomic, strong) NSString *imageValueNamed;
@property (nonatomic, assign) float imageMaxLength;
@property(nonatomic) enum UIImagePickerControllerSourceType source;
- (QImageElement *)initWithTitle:(NSString *)title detailImage:(UIImage *)image;
@end
| //
// Copyright 2012 Ludovic Landry - http://about.me/ludoviclandry
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language governing
// permissions and limitations under the License.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "QRootElement.h"
@interface QImageElement : QEntryElement
@property (nonatomic, strong) UIImage *imageValue;
@property (nonatomic, strong) NSString *imageValueNamed;
@property (nonatomic, assign) float imageMaxLength;
@property(nonatomic) UIImagePickerControllerSourceType source;
- (QImageElement *)initWithTitle:(NSString *)title detailImage:(UIImage *)image;
@end
|
Add comment about ROBOTC "linking" |
#pragma config(Motor, port2, shooterleft, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port3, shooterright, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, spinnyintakeofdoomnumber1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, garry, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, therollmodel, tmotorVex393_MC29, openLoop)
#include "controller.h"
#include "drive.h"
#include "drive.c"
task main()
{
while(1) {
motor[shooterleft] = motor[shooterright] = 127;
motor[spinnyintakeofdoomnumber1] = motor[garry] = motor[therollmodel] = 127;
}
}
|
#pragma config(Motor, port2, shooterleft, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port3, shooterright, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, spinnyintakeofdoomnumber1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, garry, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, therollmodel, tmotorVex393_MC29, openLoop)
#include "controller.h"
#include "drive.h"
/* "Link" with other files */
#include "drive.c"
task main()
{
while(1) {
motor[shooterleft] = motor[shooterright] = 127;
motor[spinnyintakeofdoomnumber1] = motor[garry] = motor[therollmodel] = 127;
}
}
|
Add page fault handler to abort on page fault. | #include "terminal.h"
#include "multiboot.h"
#include "pic.h"
#include "keyboard.h"
#include "frame_allocator.h"
#include "paging.h"
#include "assert.h"
//Calling convention on x86-64 System V ABI
//rdi, rsi, rdx, rcx for ints
void kernel_main(uintptr_t pmultiboot) {
init_terminal();
pic_init(0x20, 0x28);
pic_enable_interrupts();
keyboard_init();
add_interrupt_handler(0x21, keyboard_interrupt);
init_multiboot_data(pmultiboot);
init_allocator(&data);
//test();
while(1) {
// struct frame f;
// allocate_frame(&f);
// print_text("Alloc frame num: ");
// print_hex_number(f.number);
// print_newline();
int foo = 10;
int bar = 0xdeadbeef;
size_t baz = 0xcafebabecafebabe;
//terminal_printf("\ntest\ntest2\ntest3\n%x\n%3X\n%#x\n%X\n%zx", foo, foo, bar, bar, baz);
for(int k = 0; k < 50000000; ++k) {}
}
} | #include "terminal.h"
#include "multiboot.h"
#include "pic.h"
#include "keyboard.h"
#include "frame_allocator.h"
#include "paging.h"
#include "assert.h"
//Calling convention on x86-64 System V ABI
//rdi, rsi, rdx, rcx for ints
void page_fault(void) {
terminal_printf("Fault");
assert(0!=0);
}
void kernel_main(uintptr_t pmultiboot) {
init_terminal();
pic_init(0x20, 0x28);
pic_enable_interrupts();
keyboard_init();
add_interrupt_handler(0x21, keyboard_interrupt);
add_interrupt_handler(0x0e, page_fault);
init_multiboot_data(pmultiboot);
init_allocator(&data);
remap_kernel();
//test();
while(1) {
// struct frame f;
// allocate_frame(&f);
// print_text("Alloc frame num: ");
// print_hex_number(f.number);
// print_newline();
int foo = 10;
int bar = 0xdeadbeef;
size_t baz = 0xcafebabecafebabe;
//terminal_printf("\ntest\ntest2\ntest3\n%x\n%3X\n%#x\n%X\n%zx", foo, foo, bar, bar, baz);
for(int k = 0; k < 50000000; ++k) {}
}
} |
Add missing header to Forward codec | #pragma once
#include <spotify/json.hpp>
#include <noise/noise.h>
#include "noise/module/Wrapper.h"
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<noise::module::Wrapper<noise::module::Forward>>
{
using ForwardWrapper = noise::module::Wrapper<noise::module::Forward>;
static codec::object_t<ForwardWrapper> codec()
{
auto codec = codec::object<ForwardWrapper>();
codec.required("type", codec::eq<std::string>("Forward"));
codec.required("SourceModule", codec::ignore_t<int>());
return codec;
}
};
}
}
| #pragma once
#include <spotify/json.hpp>
#include <noise/noise.h>
#include "noise/module/Wrapper.h"
#include "noise/module/Forward.h"
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<noise::module::Wrapper<noise::module::Forward>>
{
using ForwardWrapper = noise::module::Wrapper<noise::module::Forward>;
static codec::object_t<ForwardWrapper> codec()
{
auto codec = codec::object<ForwardWrapper>();
codec.required("type", codec::eq<std::string>("Forward"));
codec.required("SourceModule", codec::ignore_t<int>());
return codec;
}
};
}
}
|
Fix typo on e_RelayDriverChannels declaration | #ifndef _RELAY_EXP_H_
#define _RELAY_EXP_H_
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <onion-mcp23008-driver.h>
#define RELAY_EXP_ADDR_SWITCH_NUM 3
#define RELAY_EXP_ADDR_SWITCH_DEFAULT_VAL "000"
// type definitions
typedef enum e_RelayDriverChannels {
RELAY_EXP_CHANNEL0 = 0,
RELAY_EXP_CHANNEL1,
RELAY_EXP_NUM_CHANNELS,
} ePwmDriverAddr;
int relayDriverInit (int addr);
int relayCheckInit (int addr, int *bInitialized);
int relaySetChannel (int addr, int channel, int state);
int relaySetAllChannels (int addr, int state);
#endif // _RELAY_EXP_H_ | #ifndef _RELAY_EXP_H_
#define _RELAY_EXP_H_
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <onion-mcp23008-driver.h>
#define RELAY_EXP_ADDR_SWITCH_NUM 3
#define RELAY_EXP_ADDR_SWITCH_DEFAULT_VAL "000"
// type definitions
typedef enum e_RelayDriverChannels {
RELAY_EXP_CHANNEL0 = 0,
RELAY_EXP_CHANNEL1,
RELAY_EXP_NUM_CHANNELS,
} eRelayDriverChannels;
int relayDriverInit (int addr);
int relayCheckInit (int addr, int *bInitialized);
int relaySetChannel (int addr, int channel, int state);
int relaySetAllChannels (int addr, int state);
#endif // _RELAY_EXP_H_ |
Check enqueued values in unit test | #include "mbb/test.h"
#include "mbb/queue.h"
#include "mbb/debug.h"
char *test_enqueue_dequeue()
{
int i;
MQUE_DEFINE_STRUCT(int, 5) queue;
MQUE_INITIALISE(&queue);
MUNT_ASSERT(MQUE_IS_EMPTY(&queue));
for (i = 1; i <= 5; i++) {
MUNT_ASSERT(!MQUE_IS_FULL(&queue));
MQUE_ENQUEUE(&queue, i);
}
for (i = 1; i <= 5; i++) {
int head;
MUNT_ASSERT(!MQUE_IS_EMPTY(&queue));
head = MQUE_HEAD(&queue);
MQUE_DEQUEUE(&queue);;
}
MUNT_ASSERT(MQUE_IS_EMPTY(&queue));
return 0;
}
| #include "mbb/test.h"
#include "mbb/queue.h"
#include "mbb/debug.h"
char *test_enqueue_dequeue()
{
int i;
MQUE_DEFINE_STRUCT(int, 5) queue;
MQUE_INITIALISE(&queue);
MUNT_ASSERT(MQUE_IS_EMPTY(&queue));
for (i = 1; i <= 5; i++) {
MUNT_ASSERT(!MQUE_IS_FULL(&queue));
MQUE_ENQUEUE(&queue, i);
}
for (i = 1; i <= 5; i++) {
int head;
MUNT_ASSERT(!MQUE_IS_EMPTY(&queue));
head = MQUE_HEAD(&queue);
MQUE_DEQUEUE(&queue);;
MUNT_ASSERT(head == i);
}
MUNT_ASSERT(MQUE_IS_EMPTY(&queue));
return 0;
}
|
Fix font size on rectangular watches | #pragma once
#include <pebble.h>
#define BG_COLOR GColorWhite
#ifdef PBL_ROUND
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 12)
#else
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 2)
#endif
#define BPM_DEFAULT_BPM_T 1200
#define BPM_FONT FONT_KEY_BITHAM_42_BOLD
#define BPM_FONT_HEIGHT 42
#define BPM_TEXT_INVALID "---"
#define BPM_TEXT_BUFFER_SIZE 10
#define BPM_HINT_FONT FONT_KEY_GOTHIC_24_BOLD
#define BPM_HINT_FONT_HEIGHT 24
#define BPM_HINT_TEXT "Current BPM:"
#define METRONOME_HINT_FONT FONT_KEY_GOTHIC_18_BOLD
#define METRONOME_HINT_FONT_HEIGHT 18
#define METRONOME_HINT_TEXT "Metronome BPM:"
#define METRONOME_VIBE_DURATION_MS 50
#define METRONOME_EDIT_TAP_REPEAT_MS 30
#define TAP_TIMEOUT_SECONDS 2
| #pragma once
#include <pebble.h>
#define BG_COLOR GColorWhite
#ifdef PBL_ROUND
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 12)
#else
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 2)
#endif
#define BPM_DEFAULT_BPM_T 1200
#define BPM_FONT FONT_KEY_BITHAM_42_BOLD
#define BPM_FONT_HEIGHT 42
#define BPM_TEXT_INVALID "---"
#define BPM_TEXT_BUFFER_SIZE 10
#define BPM_HINT_FONT FONT_KEY_GOTHIC_24_BOLD
#define BPM_HINT_FONT_HEIGHT 24
#define BPM_HINT_TEXT "Current BPM:"
#ifdef PBL_ROUND
#define METRONOME_HINT_FONT FONT_KEY_GOTHIC_18_BOLD
#define METRONOME_HINT_FONT_HEIGHT 18
#else
#define METRONOME_HINT_FONT FONT_KEY_GOTHIC_14_BOLD
#define METRONOME_HINT_FONT_HEIGHT 14
#endif
#define METRONOME_HINT_TEXT "Metronome BPM:"
#define METRONOME_VIBE_DURATION_MS 50
#define METRONOME_EDIT_TAP_REPEAT_MS 30
#define TAP_TIMEOUT_SECONDS 2
|
Enable late move pruning at min 4 | #ifndef _CONFIG_H
#define _CONFIG_H
#define ENABLE_COUNTERMOVE_HISTORY 0
#define ENABLE_LMP_MIN_MOVES 0
#define ENABLE_HISTORY_PRUNE_DEPTH 4
#define ENABLE_NNUE 0
#define ENABLE_NNUE_SIMD 0
#endif
| #ifndef _CONFIG_H
#define _CONFIG_H
#define ENABLE_COUNTERMOVE_HISTORY 0
#define ENABLE_LMP_MIN_MOVES 4
#define ENABLE_HISTORY_PRUNE_DEPTH 4
#define ENABLE_NNUE 0
#define ENABLE_NNUE_SIMD 0
#endif
|
Make threshold function use absolute value of threshold value | #include "motion.h"
//Utilities
int threshold(int value, int threshold);
void reset_I2C_sensors(void);
//Driving
void drive(int y, int t = 0){
//y - Forwards/Backwards
//t - Turning (optional parameter)
motor[driveLeftFront] = y+t;
motor[driveRightFront] = y-t;
}
//Mogo (mobile goal lift)
void mogo(int power){
motor[mobilegoal] = power;
}
//Lift
void lift(int power){
motor[liftLeftSplit] = power;
}
//Utilities
int threshold(int value, int threshold){
return abs(value) > threshold ? value : 0;
}
void reset_I2C_sensors(void){
SensorValue[I2C_1] = SensorValue[I2C_2] = SensorValue[I2C_3] = SensorValue[I2C_4] = 0;
}
| #include "motion.h"
//Utilities
int threshold(int value, int threshold);
void reset_I2C_sensors(void);
//Driving
void drive(int y, int t = 0){
//y - Forwards/Backwards
//t - Turning (optional parameter)
motor[driveLeftFront] = y+t;
motor[driveRightFront] = y-t;
}
//Mogo (mobile goal lift)
void mogo(int power){
motor[mobilegoal] = power;
}
//Lift
void lift(int power){
motor[liftLeftSplit] = power;
}
//Utilities
int threshold(int value, int threshold){
return abs(value) > abs(threshold) ? value : 0;
}
void reset_I2C_sensors(void){
SensorValue[I2C_1] = SensorValue[I2C_2] = SensorValue[I2C_3] = SensorValue[I2C_4] = 0;
}
|
Change baud rate to 3mbps | #include <stdint.h>
#define STRIP_BLACK 0x8000
#define STRIP_PIXELS 50
#define USART_BAUD_RATE 115200
extern uint16_t* const strip_data;
void init();
void set_led(uint8_t state);
uint8_t get_button();
uint16_t get_voltage();
uint16_t get_current();
void strip_flush();
uint16_t pack_RGB(uint8_t red, uint8_t green, uint8_t blue);
void strip_refresh();
void strip_refresh_nowait();
void send_str(uint8_t* mem,uint16_t cnt);
int16_t get_char();
| #include <stdint.h>
#define STRIP_BLACK 0x8000
#define STRIP_PIXELS 50
//#define USART_BAUD_RATE 115200
#define USART_BAUD_RATE 3000000
extern uint16_t* const strip_data;
void init();
void set_led(uint8_t state);
uint8_t get_button();
uint16_t get_voltage();
uint16_t get_current();
void strip_flush();
uint16_t pack_RGB(uint8_t red, uint8_t green, uint8_t blue);
void strip_refresh();
void strip_refresh_nowait();
void send_str(uint8_t* mem,uint16_t cnt);
int16_t get_char();
|
Comment file for the moment. | /**
* @file libARSAL/ARSAL.h
* @brief Library global header for libARSAL
* @date 04/12/2013
* @author nicolas.brulez@parrot.com
*/
#ifndef _ARSAL_H_
#define _ARSAL_H_
#include <libARSAL/ARSAL_Endianness.h>
#include <libARSAL/ARSAL_Ftw.h>
#include <libARSAL/ARSAL_Mutex.h>
#include <libARSAL/ARSAL_Print.h>
#include <libARSAL/ARSAL_Sem.h>
#include <libARSAL/ARSAL_Socket.h>
#include <libARSAL/ARSAL_Thread.h>
#include <libARSAL/ARSAL_Time.h>
#endif /* _ARSAL_H_ */
| /**
* @file libARSAL/ARSAL.h
* @brief Library global header for libARSAL
* @date 04/12/2013
* @author nicolas.brulez@parrot.com
*/
#ifndef _ARSAL_H_
#define _ARSAL_H_
#include <libARSAL/ARSAL_Endianness.h>
//#include <libARSAL/ARSAL_Ftw.h>
#include <libARSAL/ARSAL_Mutex.h>
#include <libARSAL/ARSAL_Print.h>
#include <libARSAL/ARSAL_Sem.h>
#include <libARSAL/ARSAL_Socket.h>
#include <libARSAL/ARSAL_Thread.h>
#include <libARSAL/ARSAL_Time.h>
#endif /* _ARSAL_H_ */
|
Fix command in path_nofun SV-COMP example | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
extern int __VERIFIER_nondet_int();
int main()
{
int x, y;
if (__VERIFIER_nondet_int())
{
x = 0;
y = 1;
}
else
{
x = 1;
y = 0;
}
// if (!(x + y == 1))
if (x + y != 1)
__VERIFIER_error();
return 0;
}
// ./goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --set phases '[{}, {"ana": {"activated": ["base", "observer"], "path_sens": ["observer"]}}]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c
// /goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
extern int __VERIFIER_nondet_int();
int main()
{
int x, y;
if (__VERIFIER_nondet_int())
{
x = 0;
y = 1;
}
else
{
x = 1;
y = 0;
}
// if (!(x + y == 1))
if (x + y != 1)
__VERIFIER_error();
return 0;
}
// ./goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --set phases '[{}, {"ana": {"activated": ["base", "observer"], "path_sens": ["observer"]}}]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c
// ./goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c |
Add support for react-native < 0.40 | #import <React/RCTBridgeModule.h>
@interface RNI18n : NSObject <RCTBridgeModule>
@end
| #if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif
@interface RNI18n : NSObject <RCTBridgeModule>
@end
|
Include sys/resource.h for struct rusage | /*
*
* Copyright 2018 Asylo authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include_next <sys/wait.h>
#ifndef ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
#define ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
#ifdef __cplusplus
extern "C" {
#endif
#define WNOHANG 1
pid_t wait3(int *wstatus, int options, struct rusage *rusage);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
| /*
*
* Copyright 2018 Asylo authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include_next <sys/wait.h>
#ifndef ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
#define ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
#include <sys/resource.h>
#ifdef __cplusplus
extern "C" {
#endif
#define WNOHANG 1
pid_t wait3(int *wstatus, int options, struct rusage *rusage);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
|
Add reference to register class to cpureg | #ifndef JIVE_ARCH_REGISTERS_H
#define JIVE_ARCH_REGISTERS_H
typedef struct jive_cpureg jive_cpureg;
typedef struct jive_regcls jive_regcls;
struct jive_cpureg {
const char name[32];
};
#endif
| #ifndef JIVE_ARCH_REGISTERS_H
#define JIVE_ARCH_REGISTERS_H
typedef struct jive_cpureg jive_cpureg;
typedef struct jive_regcls jive_regcls;
struct jive_cpureg {
const jive_regcls * regcls;
const char name[32];
};
#endif
|
Update crash diagnostics test to avoid attempting to write into various directories if possible and to not require %t to have "Output" in the name. | // RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s 2>&1 | FileCheck %s
#pragma clang __debug parser_crash
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
// CHECK: diagnostic msg: {{.*}}Output{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c
| // RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
#pragma clang __debug parser_crash
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
// CHECK: diagnostic msg: {{.*}}{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c
|
Update driver version to 5.02.00-k15 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k14"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k15"
|
Add likely and unlikely macros. | /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef _UTILS_BUILTIN_H
#define _UTILS_BUILTIN_H
/* macros for accessing compiler builtins */
#include <assert.h>
#define CTZ(x) __builtin_ctz(x)
#define CLZ(x) __builtin_clz(x)
#define OFFSETOF(type, member) __builtin_offsetof(type, member)
#define TYPES_COMPATIBLE(t1, t2) __builtin_types_compatible_p(t1, t2)
#define CHOOSE_EXPR(cond, x, y) __builtin_choose_expr(cond, x, y)
#define IS_CONSTANT(expr) __builtin_constant_p(expr)
#define POPCOUNT(x) __builtin_popcount(x)
#define UNREACHABLE() \
do { \
assert(!"unreachable"); \
__builtin_unreachable(); \
} while (0)
#endif /* _UTILS_BUILTIN_H */
| /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef _UTILS_BUILTIN_H
#define _UTILS_BUILTIN_H
/* macros for accessing compiler builtins */
#include <assert.h>
#define CTZ(x) __builtin_ctz(x)
#define CLZ(x) __builtin_clz(x)
#define OFFSETOF(type, member) __builtin_offsetof(type, member)
#define TYPES_COMPATIBLE(t1, t2) __builtin_types_compatible_p(t1, t2)
#define CHOOSE_EXPR(cond, x, y) __builtin_choose_expr(cond, x, y)
#define IS_CONSTANT(expr) __builtin_constant_p(expr)
#define POPCOUNT(x) __builtin_popcount(x)
#define UNREACHABLE() \
do { \
assert(!"unreachable"); \
__builtin_unreachable(); \
} while (0)
/* Borrowed from linux/include/linux/compiler.h */
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif /* _UTILS_BUILTIN_H */
|
Remove empty constructors etc from TASubstance | #ifndef __OBJ_APPLIED_SUB_H
#define __OBJ_APPLIED_SUB_H
#include "obj.h"
// stub object relating to ranger herbalism
class TASubstance : public TObj {
public:
virtual void assignFourValues(int, int, int, int) { }
virtual void getFourValues(int *a, int *b, int *c, int *d) const { *a = *b = *c = *d = 0; }
virtual sstring statObjInfo() const { return sstring(""); }
virtual itemTypeT itemType() const {return ITEM_APPLIED_SUB; }
TASubstance() { }
TASubstance(const TASubstance &a) { }
TASubstance & operator=(const TASubstance &a) {
if (this == &a) return *this;
TObj::operator=(a);
return *this;
}
virtual ~TASubstance() { }
};
#endif
| #ifndef __OBJ_APPLIED_SUB_H
#define __OBJ_APPLIED_SUB_H
#include "obj.h"
// stub object relating to ranger herbalism
class TASubstance : public TObj {
public:
virtual void assignFourValues(int, int, int, int) { }
virtual void getFourValues(int *a, int *b, int *c, int *d) const { *a = *b = *c = *d = 0; }
virtual sstring statObjInfo() const { return sstring(""); }
virtual itemTypeT itemType() const {return ITEM_APPLIED_SUB; }
};
#endif
|
Fix Win32 build for TLS | /* */
#undef VERSION
#define VERSION "1.37.17"
#define BDATE "06 May 2005"
#define LSMDATE "06May05"
/* Debug flags */
#undef DEBUG
#define DEBUG 1
#define TRACEBACK 1
#define SMCHECK
#define TRACE_FILE 1
/* If this is set stdout will not be closed on startup */
#define DEVELOPER 1
/* Debug flags not normally turned on */
/* #define TRACE_JCR_CHAIN 1 */
/* #define TRACE_RES 1 */
/* #define DEBUG_MEMSET 1 */
/* #define DEBUG_MUTEX 1 */
/* Check if header of tape block is zero before writing */
#define DEBUG_BLOCK_ZEROING 1
/* #define FULL_DEBUG 1 */ /* normally on for testing only */
/* Turn this on ONLY if you want all Dmsg() to append to the
* trace file. Implemented mainly for Win32 ...
*/
/* #define SEND_DMSG_TO_FILE 1 */
/* The following are turned on for performance testing */
/* #define NO_ATTRIBUTES_TEST 1 */
/* #define NO_TAPE_WRITE_TEST 1 */
/* #define FD_NO_SEND TEST 1 */
| /* */
#undef VERSION
#define VERSION "1.37.17"
#define BDATE "07 May 2005"
#define LSMDATE "07May05"
/* Debug flags */
#undef DEBUG
#define DEBUG 1
#define TRACEBACK 1
#define SMCHECK
#define TRACE_FILE 1
/* If this is set stdout will not be closed on startup */
#define DEVELOPER 1
/* Debug flags not normally turned on */
/* #define TRACE_JCR_CHAIN 1 */
/* #define TRACE_RES 1 */
/* #define DEBUG_MEMSET 1 */
/* #define DEBUG_MUTEX 1 */
/* Check if header of tape block is zero before writing */
#define DEBUG_BLOCK_ZEROING 1
/* #define FULL_DEBUG 1 */ /* normally on for testing only */
/* Turn this on ONLY if you want all Dmsg() to append to the
* trace file. Implemented mainly for Win32 ...
*/
/* #define SEND_DMSG_TO_FILE 1 */
/* The following are turned on for performance testing */
/* #define NO_ATTRIBUTES_TEST 1 */
/* #define NO_TAPE_WRITE_TEST 1 */
/* #define FD_NO_SEND TEST 1 */
|
Add relational traces example where write would fail | // SKIP PARAM: --sets ana.activated[+] octApron --sets exp.solver.td3.side_widen cycle_self
// requires cycle_self to pass with protection
#include <pthread.h>
#include <assert.h>
int g = 25; // matches write in main
int h = 12; // matches write in main
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
int x; // rand
pthread_mutex_lock(&A);
g = x;
h = x - 12;
pthread_mutex_unlock(&A);
return NULL;
}
int main(void) {
int x, y;
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
pthread_mutex_lock(&A);
g = 25;
h = 12;
pthread_mutex_unlock(&A);
pthread_mutex_lock(&A);
x = g;
y = h;
assert(x >= y); // write would fail this due to disjunctive reading from local and global
pthread_mutex_unlock(&A);
return 0;
}
| |
Remove debugging lines from kernel logger | #include <libk/klog.h>
void initialize_klog() {
initialize_serial_port(COM1);
kputs("initing");
write_serial_string(COM1, "Logger initialized\n");
kputs("inited");
}
void klog(char *message) {
write_serial_string(COM1, message);
}
| #include <libk/klog.h>
void initialize_klog() {
initialize_serial_port(COM1);
write_serial_string(COM1, "Logger initialized!\n");
}
void klog(char *message) {
write_serial_string(COM1, message);
}
|
Add macro to declare SFINAE based traits | #pragma once
#include <type_traits>
#include <iostream>
namespace rc {
namespace detail {
namespace sfinae {
template<typename T, typename = decltype(std::declval<T>() == std::declval<T>())>
std::true_type isEqualityComparable(const T &);
std::false_type isEqualityComparable(...);
template<typename T, typename = decltype(std::cout << std::declval<T>())>
std::true_type isStreamInsertible(const T &);
std::false_type isStreamInsertible(...);
} // namespace sfinae
template<typename T>
using IsEqualityComparable = decltype(
sfinae::isEqualityComparable(std::declval<T>()));
template<typename T>
using IsStreamInsertible = decltype(
sfinae::isStreamInsertible(std::declval<T>()));
} // namespace detail
} // namespace rc
| #pragma once
#include <type_traits>
#include <iostream>
namespace rc {
namespace detail {
#define RC_SFINAE_TRAIT(Name, expression) \
namespace sfinae { \
template<typename T, typename = expression> \
std::true_type test##Name(const T &); \
std::false_type test##Name(...); \
} \
\
template<typename T> \
using Name = decltype(sfinae::test##Name(std::declval<T>()));
RC_SFINAE_TRAIT(IsEqualityComparable,
decltype(std::declval<T>() == std::declval<T>()))
RC_SFINAE_TRAIT(IsStreamInsertible,
decltype(std::cout << std::declval<T>()))
} // namespace detail
} // namespace rc
|
Add DeviceNotFoundException throw on mac | /*
This file is part of Android File Transfer For Linux.
Copyright (C) 2015 Vladimir Menshakov
Android File Transfer For Linux 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.
Android File Transfer For Linux 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 Android File Transfer For Linux.
If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USB_USB_H
#define USB_USB_H
#include <usb/Exception.h>
#include <usb/usb.h>
#define USB_CALL(...) do { int _r_ = (__VA_ARGS__); if (_r_ != kIOReturnSuccess) throw mtp::usb::Exception(#__VA_ARGS__, _r_) ; } while(false)
#endif
| /*
This file is part of Android File Transfer For Linux.
Copyright (C) 2015 Vladimir Menshakov
Android File Transfer For Linux 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.
Android File Transfer For Linux 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 Android File Transfer For Linux.
If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USB_USB_H
#define USB_USB_H
#include <usb/Exception.h>
#include <usb/usb.h>
#include <mtp/usb/DeviceNotFoundException.h>
#define USB_CALL(...) \
do { int _r_ = (__VA_ARGS__); \
switch(_r_) { \
case kIOReturnSuccess : break; \
case kIOReturnNoDevice : throw mtp::usb::DeviceNotFoundException(); \
default: throw mtp::usb::Exception(#__VA_ARGS__, _r_) ; \
} \
} while(false)
#endif
|
Fix the wrong comment on the header guard | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/*
* Copyright (C) 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PHODAV_PATH_H__
#define __PHODAV_PATH_H__
#include "phodav-priv.h"
G_BEGIN_DECLS
struct _Path
{
gchar *path;
GList *locks;
guint32 refs;
};
Path * path_ref (Path *path);
void path_unref (Path *path);
void path_remove_lock (Path *path, DAVLock *lock);
void path_add_lock (Path *path, DAVLock *lock);
G_END_DECLS
#endif /* __PHODAV_LOCK_H__ */
| /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/*
* Copyright (C) 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PHODAV_PATH_H__
#define __PHODAV_PATH_H__
#include "phodav-priv.h"
G_BEGIN_DECLS
struct _Path
{
gchar *path;
GList *locks;
guint32 refs;
};
Path * path_ref (Path *path);
void path_unref (Path *path);
void path_remove_lock (Path *path, DAVLock *lock);
void path_add_lock (Path *path, DAVLock *lock);
G_END_DECLS
#endif /* __PHODAV_PATH_H__ */
|
Add solution to Exercise 2-1. | /* A solution to Exercise 2-1 in The C Programming Language (Second Edition).
*/
#include <float.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
puts("Using macros from standard headers:");
printf(" Range of \"char\": %d to %d\n", SCHAR_MIN, SCHAR_MAX);
printf(" Range of \"unsigned char\": %d to %u\n", 0, UCHAR_MAX);
printf(" Range of \"short\": %d to %d\n", SHRT_MIN, SHRT_MAX);
printf(" Range of \"unsigned short\": %d to %u\n", 0, USHRT_MAX);
printf(" Range of \"int\": %d to %d\n", INT_MIN, INT_MAX);
printf(" Range of \"unsigned int\": %d to %u\n", 0, UINT_MAX);
printf(" Range of \"long\": %ld to %ld\n", LONG_MIN, LONG_MAX);
printf(" Range of \"unsigned long\": %d to %lu\n", 0, ULONG_MAX);
printf(" Range of \"float\": %e to %e\n", FLT_MIN, FLT_MAX);
printf(" Range of \"double\": %e to %e\n", DBL_MIN, DBL_MAX);
printf(" Range of \"long double\": %Le to %Le\n", LDBL_MIN, LDBL_MAX);
/* TODO: Compute ranges. */
return EXIT_SUCCESS;
}
| |
Make renderer to work properly | #include "local-loop.h"
#include "../voxtrees/search.h"
void vox_local_loop (struct vox_node *tree, int n, void (*action) (vox_rnd_context*), \
void (*inc) (vox_rnd_context*), vox_rnd_context *ctx)
{
int i, state, pn;
int depth = 1;
vox_tree_path path;
pn = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);
state = pn;
if (state) action (ctx);
inc (ctx);
for (i=0; i<n; i++)
{
if (state)
{
depth = vox_local_rays_tree_intersection (path, ctx->origin, ctx->dir, ctx->inter, depth, pn);
state = depth;
}
if (!(state)) depth = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);
if (depth) action (ctx);
inc (ctx);
}
}
| #include "local-loop.h"
#include "../voxtrees/search.h"
void vox_local_loop (struct vox_node *tree, int n, void (*action) (vox_rnd_context*), \
void (*inc) (vox_rnd_context*), vox_rnd_context *ctx)
{
int i, state, pn;
int depth = 1;
vox_tree_path path;
pn = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);
state = pn;
if (state) action (ctx);
inc (ctx);
for (i=1; i<n; i++)
{
if (state)
{
depth = vox_local_rays_tree_intersection (path, ctx->origin, ctx->dir, ctx->inter, depth, pn);
state = depth;
}
if (!(state)) depth = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);
if (depth) action (ctx);
inc (ctx);
}
}
|
Add missing includes for fork() and perror() | /*
* This program handles SIGINT and forwards it to another process.
* It is intended to be run as PID 1.
*
* Docker starts processes with "docker run" as PID 1.
* On Linux, the default signal handler for PID 1 ignores any signals.
* Therefore Ctrl-C aka SIGINT is ignored per default.
*/
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
int pid = 0;
void
handle_sigint (int signum)
{
if(pid)
kill(pid, SIGINT);
}
int main(int argc, char *argv[]){
struct sigaction new_action;
int status = -1;
/* Set up the structure to specify the new action. */
new_action.sa_handler = handle_sigint;
sigemptyset (&new_action.sa_mask);
new_action.sa_flags = 0;
sigaction (SIGINT, &new_action, (void*)0);
pid = fork();
if(pid){
wait(&status);
return WEXITSTATUS(status);
}else{
status = execvp(argv[1], &argv[1]);
perror("exec");
return status;
}
}
| /*
* This program handles SIGINT and forwards it to another process.
* It is intended to be run as PID 1.
*
* Docker starts processes with "docker run" as PID 1.
* On Linux, the default signal handler for PID 1 ignores any signals.
* Therefore Ctrl-C aka SIGINT is ignored per default.
*/
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
int pid = 0;
void
handle_sigint (int signum)
{
if(pid)
kill(pid, SIGINT);
}
int main(int argc, char *argv[]){
struct sigaction new_action;
int status = -1;
/* Set up the structure to specify the new action. */
new_action.sa_handler = handle_sigint;
sigemptyset (&new_action.sa_mask);
new_action.sa_flags = 0;
sigaction (SIGINT, &new_action, (void*)0);
pid = fork();
if(pid){
wait(&status);
return WEXITSTATUS(status);
}else{
status = execvp(argv[1], &argv[1]);
perror("exec");
return status;
}
}
|
Fix warnings and errors brought up by VS2012 code analyzer. | /**********************************************************************
*
* PROJECT: Platform library
* FILE: Utils.c
* LICENCE: See Licence.txt
* PURPOSE: Various platform independent utility functions.
*
* (c) Tuomo Jauhiainen 2013
*
**********************************************************************/
#include "Platform/Utils.h"
#ifdef _WIN32
//////////////////////////////////////////////////////////////////////////
// Win32 implementation
//////////////////////////////////////////////////////////////////////////
#include <direct.h>
char* get_working_directory( char* buffer, size_t len )
{
return _getcwd( buffer, (int)len );
}
void exit_app_with_error( const char_t* errormsg )
{
if ( errormsg && *errormsg )
{
MessageBox( 0, errormsg, "Error", MB_OK );
}
SetForegroundWindow( HWND_DESKTOP );
ExitProcess( 1 );
}
#else
//////////////////////////////////////////////////////////////////////////
// POSIX implementation
//////////////////////////////////////////////////////////////////////////
#include <unistd.h>
#include <stdlib.h>
char* get_working_directory( char* buffer, size_t len )
{
return getcwd( buffer, len );
}
void exit_app_with_error( const char_t* errormsg )
{
exit( EXIT_FAILURE );
}
#endif
| /**********************************************************************
*
* PROJECT: Platform library
* FILE: Utils.c
* LICENCE: See Licence.txt
* PURPOSE: Various platform independent utility functions.
*
* (c) Tuomo Jauhiainen 2013
*
**********************************************************************/
#include "Platform/Utils.h"
#ifdef _WIN32
//////////////////////////////////////////////////////////////////////////
// Win32 implementation
//////////////////////////////////////////////////////////////////////////
#include <direct.h>
char* get_working_directory( char* buffer, size_t len )
{
return _getcwd( buffer, (int)len );
}
void exit_app_with_error( const char_t* errormsg )
{
if ( errormsg && *errormsg )
{
MessageBox( 0, errormsg, "Error", MB_OK );
}
ExitProcess( 1 );
}
#else
//////////////////////////////////////////////////////////////////////////
// POSIX implementation
//////////////////////////////////////////////////////////////////////////
#include <unistd.h>
#include <stdlib.h>
char* get_working_directory( char* buffer, size_t len )
{
return getcwd( buffer, len );
}
void exit_app_with_error( const char_t* errormsg )
{
exit( EXIT_FAILURE );
}
#endif
|
Insert 2 UILabel as property : *switchOnLabel, *switchOffLabel, allow the action function - (void)changeHint:(UISwitch *)userSwitch; to access them. | /**************************************************************************************************
* File name : ViewController.h
* Description : Define the ViewController class.
* Creator : Frederick Hsu
* Creation date: Thu. 23 Feb. 2017
* Copyright(C 2017 All rights reserved.
*
**************************************************************************************************/
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
+ (void)initialize;
- (instancetype)init;
- (instancetype)initWithCoder:(NSCoder *)coder;
- (void)awakeFromNib;
- (void)loadView;
- (void)viewDidLoad;
- (void)viewWillLayoutSubviews;
- (void)viewDidLayoutSubviews;
- (void)didReceiveMemoryWarning;
- (void)viewDidAppear:(BOOL)animated;
- (void)viewWillAppear:(BOOL)animated;
- (void)viewWillDisappear:(BOOL)animated;
- (void)viewDidDisappear:(BOOL)animated;
- (void)dealloc;
- (void)changeColor;
@end
| /**************************************************************************************************
* File name : ViewController.h
* Description : Define the ViewController class.
* Creator : Frederick Hsu
* Creation date: Thu. 23 Feb. 2017
* Copyright(C 2017 All rights reserved.
*
**************************************************************************************************/
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (atomic, readwrite) UILabel *switchOnLabel;
@property (atomic, readwrite) UILabel *switchOffLabel;
+ (void)initialize;
- (instancetype)init;
- (instancetype)initWithCoder:(NSCoder *)coder;
- (void)awakeFromNib;
- (void)loadView;
- (void)viewDidLoad;
- (void)viewWillLayoutSubviews;
- (void)viewDidLayoutSubviews;
- (void)didReceiveMemoryWarning;
- (void)viewDidAppear:(BOOL)animated;
- (void)viewWillAppear:(BOOL)animated;
- (void)viewWillDisappear:(BOOL)animated;
- (void)viewDidDisappear:(BOOL)animated;
- (void)dealloc;
- (void)changeColor;
- (void)changeHint:(UISwitch *)userSwitch;
@end
|
Make sure to use proper name mangling | /*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Module: $URL$
Copyright (c) 2006-2010 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCM_ZLIB_H
#define GDCM_ZLIB_H
/* Use the zlib library configured for gdcm. */
#include "gdcmTypes.h"
#ifdef GDCM_USE_SYSTEM_ZLIB
// $ dpkg -S /usr/include/zlib.h
// zlib1g-dev: /usr/include/zlib.h
# include <zlib.h>
#else
# include <gdcmzlib/zlib.h>
#endif
#endif
| /*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Module: $URL$
Copyright (c) 2006-2010 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCM_ZLIB_H
#define GDCM_ZLIB_H
/* Use the zlib library configured for gdcm. */
#include "gdcmTypes.h"
#ifdef GDCM_USE_SYSTEM_ZLIB
// $ dpkg -S /usr/include/zlib.h
// zlib1g-dev: /usr/include/zlib.h
# include <itk_zlib.h>
#else
# include <gdcmzlib/zlib.h>
#endif
#endif
|
Update Client Version for New Code Base | #ifndef CLIENTVERSION_H
#define CLIENTVERSION_H
//
// client versioning
//
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
#define STRINGIZE(X) DO_STRINGIZE(X)
#define DO_STRINGIZE(X) #X
#endif // CLIENTVERSION_H
| #ifndef CLIENTVERSION_H
#define CLIENTVERSION_H
//
// client versioning
//
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 1
// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
#define STRINGIZE(X) DO_STRINGIZE(X)
#define DO_STRINGIZE(X) #X
#endif // CLIENTVERSION_H
|
Add the interface method for OnDisplayChange | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <Windows.h>
#include "../HotkeyProcessor.h"
#include "../MeterWnd/MeterWnd.h"
#include "../Settings.h"
#include "../Window.h"
#include "OSDType.h"
class Monitor;
class OSD : HotkeyProcessor, protected Window {
public:
OSD(LPCWSTR className, HINSTANCE hInstance = NULL);
virtual void Hide() = 0;
virtual void ProcessHotkeys(HotkeyInfo &hki);
bool Enabled();
void Enabled(bool enabled);
protected:
HWND _masterWnd;
Settings *_settings;
void HideOthers(OSDType except);
void InitMeterWnd(MeterWnd &mWnd);
std::vector<Monitor> ActiveMonitors();
void PositionWindow(Monitor monitor, LayeredWnd &lWnd);
void CenterWindowX(Monitor monitor, LayeredWnd &lWnd);
void CenterWindowY(Monitor monitor, LayeredWnd &lWnd);
virtual LRESULT WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
private:
bool _enabled;
}; | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
#include <Windows.h>
#include "../HotkeyProcessor.h"
#include "../MeterWnd/MeterWnd.h"
#include "../Settings.h"
#include "../Window.h"
#include "OSDType.h"
class Monitor;
class OSD : HotkeyProcessor, protected Window {
public:
OSD(LPCWSTR className, HINSTANCE hInstance = NULL);
virtual void Hide() = 0;
virtual void ProcessHotkeys(HotkeyInfo &hki);
bool Enabled();
void Enabled(bool enabled);
/// <summary>
/// This method is called when the system display configuration has changed,
/// which includes monitors being removed or plugged in.
/// </summary>
virtual void OnDisplayChange() = 0;
protected:
HWND _masterWnd;
Settings *_settings;
void HideOthers(OSDType except);
void InitMeterWnd(MeterWnd &mWnd);
std::vector<Monitor> ActiveMonitors();
void PositionWindow(Monitor monitor, LayeredWnd &lWnd);
void CenterWindowX(Monitor monitor, LayeredWnd &lWnd);
void CenterWindowY(Monitor monitor, LayeredWnd &lWnd);
virtual LRESULT WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
private:
bool _enabled;
}; |
Add guarded 'extern "C"' attributes so that this header files can be used from both C and C++ programs. | // Harshad Kasture
//
// This file declares the user level message passing functions used in multithreaded applications
// for the multicore simulator.
#ifndef CAPI_H
#define CAPI_H
typedef int CAPI_return_t;
typedef int CAPI_endpoint_t;
// externed so the names don't get name-mangled
//extern "C" {
CAPI_return_t CAPI_Initialize(int *rank);
CAPI_return_t CAPI_rank(int * rank);
CAPI_return_t CAPI_message_send_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
char * buffer, int size);
CAPI_return_t CAPI_message_receive_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
char * buffer, int size);
//}
#endif
| // Harshad Kasture
//
// This file declares the user level message passing functions used in multithreaded applications
// for the multicore simulator.
#ifndef CAPI_H
#define CAPI_H
typedef int CAPI_return_t;
typedef int CAPI_endpoint_t;
#ifdef __cplusplus
// externed so the names don't get name-mangled
extern "C" {
#endif
CAPI_return_t CAPI_Initialize(int *rank);
CAPI_return_t CAPI_rank(int * rank);
CAPI_return_t CAPI_message_send_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
char * buffer, int size);
CAPI_return_t CAPI_message_receive_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
char * buffer, int size);
#ifdef __cplusplus
}
#endif
#endif
|
Watch for input from stdin and print it. | #include <stdio.h>
#include <sys/select.h>
/* pselect loop test */
int main(int argc, char *argv[])
{
struct timespec timeout;
fd_set readfds;
int fdcount;
while(1){
FD_ZERO(&readfds);
FD_SET(0, &readfds);
timeout.tv_sec = 1;
timeout.tv_nsec = 0;
fdcount = pselect(1, &readfds, NULL, NULL, &timeout, NULL);
printf("loop %d\n", fdcount);
}
return 0;
}
| #include <stdio.h>
#include <sys/select.h>
/* pselect loop test */
int main(int argc, char *argv[])
{
struct timespec timeout;
fd_set readfds;
int fdcount;
char buf[1024];
while(1){
FD_ZERO(&readfds);
FD_SET(0, &readfds);
timeout.tv_sec = 1;
timeout.tv_nsec = 0;
fdcount = pselect(1, &readfds, NULL, NULL, &timeout, NULL);
printf("loop %d\n", fdcount);
if(FD_ISSET(0, &readfds)){
read(0, buf, 1024);
printf("buf: %s\n", buf);
}
}
return 0;
}
|
Add EventSystem shim missed in r588. | #ifndef EVENT_SYSTEM_H
#define EVENT_SYSTEM_H
#include <event/event_thread.h>
/*
* XXX
* This is kind of an awful shim while we move
* towards something thread-oriented.
*/
class EventSystem {
EventThread td_;
private:
EventSystem(void)
: td_()
{ }
~EventSystem()
{ }
public:
Action *poll(const EventPoll::Type& type, int fd, EventCallback *cb)
{
return (td_.poll(type, fd, cb));
}
Action *register_interest(const EventInterest& interest, Callback *cb)
{
return (td_.register_interest(interest, cb));
}
Action *schedule(Callback *cb)
{
return (td_.schedule(cb));
}
Action *timeout(unsigned ms, Callback *cb)
{
return (td_.timeout(ms, cb));
}
void start(void)
{
td_.start();
td_.join();
}
static EventSystem *instance(void)
{
static EventSystem *instance;
if (instance == NULL)
instance = new EventSystem();
return (instance);
}
};
#endif /* !EVENT_SYSTEM_H */
| |
Implement forked registerAllTranslations() as registerMlirTranslations() | // Copyright 2020 Google LLC
//
// 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
//
// https://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.
// This file defines a helper to trigger the registration of all translations
// in and out of MLIR to the system.
//
// Based on MLIR's InitAllTranslations but without translations we don't care
// about.
#ifndef IREE_TOOLS_INIT_TRANSLATIONS_H_
#define IREE_TOOLS_INIT_TRANSLATIONS_H_
namespace mlir {
void registerFromLLVMIRTranslation();
void registerToLLVMIRTranslation();
void registerToSPIRVTranslation();
// This function should be called before creating any MLIRContext if one
// expects all the possible translations to be made available to the context
// automatically.
inline void registerMlirTranslations() {
static bool init_once = []() {
registerFromLLVMIRTranslation();
registerToLLVMIRTranslation();
registerToSPIRVTranslation();
return true;
}();
(void)init_once;
}
} // namespace mlir
#endif // IREE_TOOLS_INIT_TRANSLATIONS_H_
| |
Implement stack with single linked list | #include <stdio.h>
#include <stdlib.h>
typedef struct Node{
int val;
struct Node *next;
}Node;
Node* Push(Node *p, int val){
Node *temp = (struct Node*)malloc(sizeof(struct Node));
temp->val = val;
temp->next = p;
p = temp;
return p;
}
void Pop(Node *p){
if(p == NULL)
return;
printf("%p\n",p);
Node *temp = p;
p = p->next;
printf("%p\n",p);
free(temp);
printf("%p\n",temp);
}
void PRINT(Node *p){
Node *temp = p;
while(temp != NULL){
printf("%d ",temp->val);
temp = temp->next;
}
printf("\n");
}
int main(){
Node *head = NULL;
head = Push(head,3);
head = Push(head,6);
head = Push(head,2);
head = Push(head,1);
head = Push(head,9);
PRINT(head);
head = Pop(head);
head = Pop(head);
head = Pop(head);
PRINT(head);
}
| #include <stdio.h>
#include <stdlib.h>
typedef struct Node{
int val;
struct Node *next;
}Node;
Node* Push(Node *p, int val){
Node *temp = (struct Node*)malloc(sizeof(struct Node));
temp->val = val;
temp->next = p;
p = temp;
return p;
}
Node* Pop(Node *p){
if(p == NULL)
return;
Node *temp = p;
p = p->next;
free(temp);
return p;
}
void PRINT(Node *p){
Node *temp = p;
while(temp != NULL){
printf("%d ",temp->val);
temp = temp->next;
}
printf("\n");
}
int main(){
Node *head = NULL;
head = Push(head,3);
head = Push(head,6);
head = Push(head,2);
head = Push(head,1);
head = Push(head,9);
PRINT(head);
head = Pop(head);
head = Pop(head);
head = Pop(head);
PRINT(head);
}
|
Fix reference to UIImage when compiled for OS X. | //
// MBImageRequest.h
// MBRequest
//
// Created by Sebastian Celis on 3/6/12.
// Copyright (c) 2012 Mobiata, LLC. All rights reserved.
//
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#import <UIKit/UIKit.h>
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#import <Cocoa/Cocoa.h>
#endif
#import "MBHTTPRequest.h"
#if __IPHONE_OS_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(UIImage *image, NSError *error);
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(NSImage *image, NSError *error);
#endif
@interface MBImageRequest : MBHTTPRequest
// The image returned in the response.
@property (atomic, retain, readonly) UIImage *responseImage;
// Performs a basic request and notifies the caller with any data downloaded.
- (void)performImageRequest:(NSURLRequest *)request completionHandler:(MBRequestImageCompletionHandler)completionHandler;
// The callback for image requests.
@property (nonatomic, copy, readonly) MBRequestImageCompletionHandler imageCompletionHandler;
@end
| //
// MBImageRequest.h
// MBRequest
//
// Created by Sebastian Celis on 3/6/12.
// Copyright (c) 2012 Mobiata, LLC. All rights reserved.
//
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#import <UIKit/UIKit.h>
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#import <Cocoa/Cocoa.h>
#endif
#import "MBHTTPRequest.h"
#if __IPHONE_OS_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(UIImage *image, NSError *error);
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(NSImage *image, NSError *error);
#endif
@interface MBImageRequest : MBHTTPRequest
// The image returned in the response.
#if __IPHONE_OS_VERSION_MIN_REQUIRED
@property (atomic, retain, readonly) UIImage *responseImage;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
@property (atomic, retain, readonly) NSImage *responseImage;
#endif
// Performs a basic request and notifies the caller with any data downloaded.
- (void)performImageRequest:(NSURLRequest *)request completionHandler:(MBRequestImageCompletionHandler)completionHandler;
// The callback for image requests.
@property (nonatomic, copy, readonly) MBRequestImageCompletionHandler imageCompletionHandler;
@end
|
Fix an off-by-1 in FTRACE_SYSCALL_MAX. | #ifndef __ASM_SH_FTRACE_H
#define __ASM_SH_FTRACE_H
#ifdef CONFIG_FUNCTION_TRACER
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
#define FTRACE_SYSCALL_MAX (NR_syscalls - 1)
#ifndef __ASSEMBLY__
extern void mcount(void);
#define MCOUNT_ADDR ((long)(mcount))
#ifdef CONFIG_DYNAMIC_FTRACE
#define CALL_ADDR ((long)(ftrace_call))
#define STUB_ADDR ((long)(ftrace_stub))
#define GRAPH_ADDR ((long)(ftrace_graph_call))
#define CALLER_ADDR ((long)(ftrace_caller))
#define MCOUNT_INSN_OFFSET ((STUB_ADDR - CALL_ADDR) - 4)
#define GRAPH_INSN_OFFSET ((CALLER_ADDR - GRAPH_ADDR) - 4)
struct dyn_arch_ftrace {
/* No extra data needed on sh */
};
#endif /* CONFIG_DYNAMIC_FTRACE */
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
/* 'addr' is the memory table address. */
return addr;
}
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */
#endif /* __ASM_SH_FTRACE_H */
| #ifndef __ASM_SH_FTRACE_H
#define __ASM_SH_FTRACE_H
#ifdef CONFIG_FUNCTION_TRACER
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
#define FTRACE_SYSCALL_MAX NR_syscalls
#ifndef __ASSEMBLY__
extern void mcount(void);
#define MCOUNT_ADDR ((long)(mcount))
#ifdef CONFIG_DYNAMIC_FTRACE
#define CALL_ADDR ((long)(ftrace_call))
#define STUB_ADDR ((long)(ftrace_stub))
#define GRAPH_ADDR ((long)(ftrace_graph_call))
#define CALLER_ADDR ((long)(ftrace_caller))
#define MCOUNT_INSN_OFFSET ((STUB_ADDR - CALL_ADDR) - 4)
#define GRAPH_INSN_OFFSET ((CALLER_ADDR - GRAPH_ADDR) - 4)
struct dyn_arch_ftrace {
/* No extra data needed on sh */
};
#endif /* CONFIG_DYNAMIC_FTRACE */
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
/* 'addr' is the memory table address. */
return addr;
}
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */
#endif /* __ASM_SH_FTRACE_H */
|
Add a check to see if DLog is already defined. | //
// LolayHttpClientGlobals.h
// LolayHttpClientGlobals
//
// Created by Bruce Johnson on 5/9/14.
// Copyright (c) 2014 Lolay. All rights reserved.
//
#if DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
# define NSLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(fmt, ...) {}
# define NSLog(...) {}
#endif
| //
// LolayHttpClientGlobals.h
// LolayHttpClientGlobals
//
// Created by Bruce Johnson on 5/9/14.
// Copyright (c) 2014 Lolay. All rights reserved.
//
#ifndef DLog
#if DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
# define NSLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(fmt, ...) {}
# define NSLog(...) {}
#endif
#endif
|
Comment the main for import as a library in the function of the least common divisor (LCD) | #include<stdio.h>
/* CALC GREATEST COMMON DIVISOR BY EUCLIDES ALGORITHM
* r -> remainder
* q -> quotient
*/
int calc_gcd(int n1, int n2, int r, int q){
if (r == 0)
return n2;
return calc_gcd(n2,r,n2 % r, n2 / r);
}
/* FIRE UP THE FUNCTION GCD
*/
int gcd(int n1, int n2){
if ( n1 > n2 )
return calc_gcd(n1, n2, n1 % n2, n1 / n2);
return calc_gcd(n2, n1, n2 % n1, n2 / n1);
}
int main(){
int n1=2366, n2=273;
printf("gcd= %d ",gcd(n1,n2));
return 0;
}
| #include<stdio.h>
/* CALC GREATEST COMMON DIVISOR BY EUCLIDES ALGORITHM
* r -> remainder
* q -> quotient
*/
int calc_gcd(int n1, int n2, int r, int q){
if (r == 0)
return n2;
return calc_gcd(n2,r,n2 % r, n2 / r);
}
/* FIRE UP THE FUNCTION GCD
*/
int gcd(int n1, int n2){
if ( n1 > n2 )
return calc_gcd(n1, n2, n1 % n2, n1 / n2);
return calc_gcd(n2, n1, n2 % n1, n2 / n1);
}
/*
int main(){
int n1=2366, n2=273;
printf("gcd= %d ",gcd(n1,n2));
return 0;
}
*/
|
Add macro for errors in tests | /*ckwg +5
* Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef VISTK_TEST_TEST_COMMON_H
#define VISTK_TEST_TEST_COMMON_H
#define EXPECT_EXCEPTION(exc, code, action) \
do \
{ \
bool got_exception = false; \
\
try \
{ \
code; \
} \
catch (exc& e) \
{ \
got_exception = true; \
\
(void)e.what(); \
} \
catch (std::exception& e) \
{ \
std::cerr << "Error: Unexpected exception: " \
<< e.what() << std::endl; \
\
got_exception = true; \
} \
\
if (!got_exception) \
{ \
std::cerr << "Error: Did not get " \
"expected exception when " \
<< action << std::endl; \
} \
} while (false)
#endif // VISTK_TEST_TEST_COMMON_H
| /*ckwg +5
* Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef VISTK_TEST_TEST_COMMON_H
#define VISTK_TEST_TEST_COMMON_H
#define TEST_ERROR(msg) \
do \
{ \
std::cerr << "Error: " << msg << std::endl; \
} while (false)
#define EXPECT_EXCEPTION(ex, code, action) \
do \
{ \
bool got_exception = false; \
\
try \
{ \
code; \
} \
catch (ex& e) \
{ \
got_exception = true; \
\
(void)e.what(); \
} \
catch (std::exception& e) \
{ \
TEST_ERROR("Unexpected exception: " \
<< e.what()); \
\
got_exception = true; \
} \
\
if (!got_exception) \
{ \
TEST_ERROR("Did not get " \
"expected exception when " \
<< action); \
} \
} while (false)
#endif // VISTK_TEST_TEST_COMMON_H
|
Apply prefix to include guard | //! \file
#ifndef JSONSERIALIZER_H
#define JSONSERIALIZER_H
#include <iostream>
#include "ArticleCollection.h"
namespace WikiWalker
{
/*! Serialize AricleCollection from and to a custom JSON format
*/
class JsonSerializer
{
public:
/*! Serialize ArticleCollection to JSON in an output stream
* \param a pointer to article to be output
* \param os out stream to putput to.
* YOU are responsible for opening and closing the stream
*/
void serialize(const ArticleCollection& collection,
std::ostream& outstream);
};
}
#endif // JSONSERIALIZER_H
| //! \file
#ifndef WIKIWALKER_JSONSERIALIZER_H
#define WIKIWALKER_JSONSERIALIZER_H
#include <iostream>
#include "ArticleCollection.h"
namespace WikiWalker
{
/*! Serialize AricleCollection from and to a custom JSON format
*/
class JsonSerializer
{
public:
/*! Serialize ArticleCollection to JSON in an output stream
* \param a pointer to article to be output
* \param os out stream to putput to.
* YOU are responsible for opening and closing the stream
*/
void serialize(const ArticleCollection& collection,
std::ostream& outstream);
};
}
#endif // WIKIWALKER_JSONSERIALIZER_H
|
Set the header protection to end with _H. | #ifndef MATH_CONTAINER
#define MATH_CONTAINER
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cmath>
/********************************/
/*Find the index during the sort*/
/********************************/
template<typename T> class CompareIndicesByAnotherVectorValues
{
const std::vector<T>* values;
public:
CompareIndicesByAnotherVectorValues(const std::vector<T>* val) : values(val) {}
bool operator() (const size_t & a, const size_t & b) const { return (*values)[a] < (*values)[b]; }
};
template <typename T>
std::vector<size_t> sort_indexes(const std::vector<T> &v)
{
// initialize original index locations
std::vector<size_t> idx(v.size());
for (size_t i = 0; i != idx.size(); ++i) idx[i] = i;
CompareIndicesByAnotherVectorValues<T> idex_comp(&v);
// sort indexes based on comparing values in v
std::sort(idx.begin(), idx.end(), idex_comp);
return idx;
}
/******************************************************/
/*solve the equation cosh(x)=exp(y), input y, return x*/
/******************************************************/
std::complex<double> coshx_eq_expy(double y);
#endif
| #ifndef MATH_CONTAINER_H
#define MATH_CONTAINER_H
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cmath>
/********************************/
/*Find the index during the sort*/
/********************************/
template<typename T> class CompareIndicesByAnotherVectorValues
{
const std::vector<T>* values;
public:
CompareIndicesByAnotherVectorValues(const std::vector<T>* val) : values(val) {}
bool operator() (const size_t & a, const size_t & b) const { return (*values)[a] < (*values)[b]; }
};
template <typename T>
std::vector<size_t> sort_indexes(const std::vector<T> &v)
{
// initialize original index locations
std::vector<size_t> idx(v.size());
for (size_t i = 0; i != idx.size(); ++i) idx[i] = i;
CompareIndicesByAnotherVectorValues<T> idex_comp(&v);
// sort indexes based on comparing values in v
std::sort(idx.begin(), idx.end(), idex_comp);
return idx;
}
/******************************************************/
/*solve the equation cosh(x)=exp(y), input y, return x*/
/******************************************************/
std::complex<double> coshx_eq_expy(double y);
#endif
|
Move LRImageOperation inputs and outputs to an appropriate category | //
// LRImageOperation+Private.h
// iShows
//
// Created by Luis Recuenco on 19/05/13.
// Copyright (c) 2013 Luis Recuenco. All rights reserved.
//
#import "LRImageOperation.h"
@interface LRImageOperation (Private)
// Inputs
@property (nonatomic, strong, readonly) NSURL *url;
@property (nonatomic, assign, readonly) CGSize size;
@property (nonatomic, assign, readonly) BOOL diskCache;
@property (nonatomic, assign, readonly) LRCacheStorageOptions storageOptions;
@property (nonatomic, strong, readonly) NSMutableArray *completionHandlers;
// Outputs
@property (nonatomic, strong, readonly) UIImage *image;
@property (nonatomic, strong, readonly) NSError *error;
@end
| |
Add a comment to mention the memory ownership situation. | //===--- CodeGen/ModuleBuilder.h - Build LLVM from ASTs ---------*- 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 the ModuleBuilder interface.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_CODEGEN_MODULEBUILDER_H
#define LLVM_CLANG_CODEGEN_MODULEBUILDER_H
#include "clang/AST/ASTConsumer.h"
#include <string>
namespace llvm {
class LLVMContext;
class Module;
}
namespace clang {
class Diagnostic;
class LangOptions;
class CodeGenOptions;
class CodeGenerator : public ASTConsumer {
public:
virtual llvm::Module* GetModule() = 0;
virtual llvm::Module* ReleaseModule() = 0;
};
CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
const std::string &ModuleName,
const CodeGenOptions &CGO,
llvm::LLVMContext& C);
}
#endif
| //===--- CodeGen/ModuleBuilder.h - Build LLVM from ASTs ---------*- 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 the ModuleBuilder interface.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_CODEGEN_MODULEBUILDER_H
#define LLVM_CLANG_CODEGEN_MODULEBUILDER_H
#include "clang/AST/ASTConsumer.h"
#include <string>
namespace llvm {
class LLVMContext;
class Module;
}
namespace clang {
class Diagnostic;
class LangOptions;
class CodeGenOptions;
class CodeGenerator : public ASTConsumer {
public:
virtual llvm::Module* GetModule() = 0;
virtual llvm::Module* ReleaseModule() = 0;
};
/// CreateLLVMCodeGen - Create a CodeGenerator instance.
/// It is the responsibility of the caller to call delete on
/// the allocated CodeGenerator instance.
CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
const std::string &ModuleName,
const CodeGenOptions &CGO,
llvm::LLVMContext& C);
}
#endif
|
Change style 0 == Index to Index == 0 | /** @file
Base Library CPU Functions for all architectures.
Copyright (c) 2006 - 2008, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Base.h>
#include <Library/BaseLib.h>
/**
Executes an infinite loop.
Forces the CPU to execute an infinite loop. A debugger may be used to skip
past the loop and the code that follows the loop must execute properly. This
implies that the infinite loop must not cause the code that follow it to be
optimized away.
**/
VOID
EFIAPI
CpuDeadLoop (
VOID
)
{
volatile UINTN Index;
for (Index = 0; 0 == Index;);
}
| /** @file
Base Library CPU Functions for all architectures.
Copyright (c) 2006 - 2008, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Base.h>
#include <Library/BaseLib.h>
/**
Executes an infinite loop.
Forces the CPU to execute an infinite loop. A debugger may be used to skip
past the loop and the code that follows the loop must execute properly. This
implies that the infinite loop must not cause the code that follow it to be
optimized away.
**/
VOID
EFIAPI
CpuDeadLoop (
VOID
)
{
volatile UINTN Index;
for (Index = 0; Index == 0;);
}
|
Add a new frame types. | #ifndef TLSCA_SVR__ALL_H_
#define TLSCA_SVR__ALL_H_
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <ft.h>
#include <tlsca.h>
#include <seacatcc.h>
struct sca_app;
extern struct sca_app sca_app;
#include "config.h"
#include "app.h"
#include "reactor.h"
#include "cntl.h"
#endif //TLSCA_SVR__ALL_H_
| #ifndef TLSCA_SVR__ALL_H_
#define TLSCA_SVR__ALL_H_
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <ft.h>
#include <tlsca.h>
#include <seacatcc.h>
struct sca_app;
extern struct sca_app sca_app;
#include "config.h"
#include "app.h"
#include "reactor.h"
#include "cntl.h"
enum sca_frame_type
{
FT_FRAME_TYPE_SEACATCC_WRITE = 0xFFFFF001,
FT_FRAME_TYPE_SEACATCC_READ = 0xFFFFF002,
};
#endif //TLSCA_SVR__ALL_H_
|
Fix ESSSort to work with non-object properties | //
// NSSortDescriptor+Essentials.h
// Essentials
//
// Created by Martin Kiss on 11.4.14.
// Copyright (c) 2014 iAdverti. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef enum : BOOL {
ESSSortDescending = NO,
ESSSortAscending = YES,
} ESSSort;
@interface NSSortDescriptor (Essentials)
+ (instancetype)sortAscending:(BOOL)ascending;
+ (instancetype)sortAscending:(BOOL)ascending selector:(SEL)selector;
+ (instancetype)randomSortDescriptor;
+ (instancetype)sortDescriptorForViewOriginX;
+ (instancetype)sortDescriptorForViewOriginY;
@end
#define ESSSort(Class, keyPath, ascend) \
(NSSortDescriptor *)({ \
[NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend]; \
})
#define ESSSortUsing(Class, keyPath, ascend, compareSelector) \
(NSSortDescriptor *)({ \
if (NO) { \
Class *object = nil; \
__unused NSComparisonResult r = [object.keyPath compareSelector object.keyPath]; \
} \
SEL selector = NSSelectorFromString(@#compareSelector); \
[NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend selector:selector]; \
})
| //
// NSSortDescriptor+Essentials.h
// Essentials
//
// Created by Martin Kiss on 11.4.14.
// Copyright (c) 2014 iAdverti. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef enum : BOOL {
ESSSortDescending = NO,
ESSSortAscending = YES,
} ESSSort;
@interface NSSortDescriptor (Essentials)
+ (instancetype)sortAscending:(BOOL)ascending;
+ (instancetype)sortAscending:(BOOL)ascending selector:(SEL)selector;
+ (instancetype)randomSortDescriptor;
+ (instancetype)sortDescriptorForViewOriginX;
+ (instancetype)sortDescriptorForViewOriginY;
@end
#define ESSSort(Class, keyPath, ascend) \
(NSSortDescriptor *)({ \
if (NO) { \
Class *object = nil; \
(void)object.keyPath; \
} \
[NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend]; \
})
#define ESSSortUsing(Class, keyPath, ascend, compareSelector) \
(NSSortDescriptor *)({ \
if (NO) { \
Class *object = nil; \
(void)object.keyPath; \
} \
SEL selector = NSSelectorFromString(@#compareSelector); \
[NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend selector:selector]; \
})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.