Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Fix a JSON sequence encode bug | #ifndef JSON_H_H4Q7QTC4
#define JSON_H_H4Q7QTC4
#include "mfast_json_export.h"
#include "mfast.h"
#include <iostream>
namespace mfast
{
namespace json {
MFAST_JSON_EXPORT bool encode(std::ostream& os,
const ::mfast::aggregate_cref& msg,
unsigned json_object_tag_mask=0);
MFAST_JSON_EXPORT bool encode(std::istream& is,
const ::mfast::sequence_mref& seq,
unsigned json_object_tag_mask=0);
MFAST_JSON_EXPORT bool decode(std::istream& is,
const ::mfast::aggregate_mref& msg,
unsigned json_object_tag_mask=0);
MFAST_JSON_EXPORT bool decode(std::istream& is,
const ::mfast::sequence_mref& seq,
unsigned json_object_tag_mask=0);
} // namespace json
} // namespace mfast
#endif /* end of include guard: JSON_H_H4Q7QTC4 */
| #ifndef JSON_H_H4Q7QTC4
#define JSON_H_H4Q7QTC4
#include "mfast_json_export.h"
#include "mfast.h"
#include <iostream>
namespace mfast
{
namespace json {
MFAST_JSON_EXPORT bool encode(std::ostream& os,
const ::mfast::aggregate_cref& msg,
unsigned json_object_tag_mask=0);
MFAST_JSON_EXPORT bool encode(std::istream& is,
const ::mfast::sequence_cref& seq,
unsigned json_object_tag_mask=0);
MFAST_JSON_EXPORT bool decode(std::istream& is,
const ::mfast::aggregate_mref& msg,
unsigned json_object_tag_mask=0);
MFAST_JSON_EXPORT bool decode(std::istream& is,
const ::mfast::sequence_mref& seq,
unsigned json_object_tag_mask=0);
} // namespace json
} // namespace mfast
#endif /* end of include guard: JSON_H_H4Q7QTC4 */
|
Add newline at end of file. | //===-- PPCMachineFunctionInfo.h - Private data used for PowerPC --*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by James M. Laskey and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the PowerPC specific subclass of MachineFunctionInfo.
//
//===----------------------------------------------------------------------===//
#ifndef PPC_MACHINE_FUNCTION_INFO_H
#define PPC_MACHINE_FUNCTION_INFO_H
#include "llvm/CodeGen/MachineFunction.h"
namespace llvm {
/// PPCFunctionInfo - This class is derived from MachineFunction private
/// PowerPC target-specific information for each MachineFunction.
class PPCFunctionInfo : public MachineFunctionInfo {
private:
/// FramePointerSaveIndex - Frame index of where the old frame pointer is
/// stored. Also used as an anchor for instructions that need to be altered
/// when using frame pointers (dyna_add, dyna_sub.)
int FramePointerSaveIndex;
public:
PPCFunctionInfo(MachineFunction& MF)
: FramePointerSaveIndex(0)
{}
int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
};
} // end of namespace llvm
#endif | //===-- PPCMachineFunctionInfo.h - Private data used for PowerPC --*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by James M. Laskey and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the PowerPC specific subclass of MachineFunctionInfo.
//
//===----------------------------------------------------------------------===//
#ifndef PPC_MACHINE_FUNCTION_INFO_H
#define PPC_MACHINE_FUNCTION_INFO_H
#include "llvm/CodeGen/MachineFunction.h"
namespace llvm {
/// PPCFunctionInfo - This class is derived from MachineFunction private
/// PowerPC target-specific information for each MachineFunction.
class PPCFunctionInfo : public MachineFunctionInfo {
private:
/// FramePointerSaveIndex - Frame index of where the old frame pointer is
/// stored. Also used as an anchor for instructions that need to be altered
/// when using frame pointers (dyna_add, dyna_sub.)
int FramePointerSaveIndex;
public:
PPCFunctionInfo(MachineFunction& MF)
: FramePointerSaveIndex(0)
{}
int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
};
} // end of namespace llvm
#endif
|
Fix type conflict with min/max in shared. | /*
* Rubygame -- Ruby code and bindings to SDL to facilitate game creation
* Copyright (C) 2004-2007 John Croisant
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _RUBYGAME_SHARED_H
#define _RUBYGAME_SHARED_H
#include <SDL.h>
#include <ruby.h>
#include <stdio.h>
/* General */
extern VALUE mRubygame;
extern VALUE eSDLError;
extern VALUE cSurface;
extern VALUE cRect;
extern SDL_Rect *make_rect(int, int, int, int);
extern Uint32 collapse_flags(VALUE);
extern void Init_rubygame_shared();
#ifndef _MSC_VER
extern static inline int max(int, int);
extern static inline int min(int, int);
#endif
#endif
| /*
* Rubygame -- Ruby code and bindings to SDL to facilitate game creation
* Copyright (C) 2004-2007 John Croisant
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _RUBYGAME_SHARED_H
#define _RUBYGAME_SHARED_H
#include <SDL.h>
#include <ruby.h>
#include <stdio.h>
/* General */
extern VALUE mRubygame;
extern VALUE eSDLError;
extern VALUE cSurface;
extern VALUE cRect;
extern SDL_Rect *make_rect(int, int, int, int);
extern Uint32 collapse_flags(VALUE);
extern void Init_rubygame_shared();
#ifndef _MSC_VER
extern inline int max(int, int);
extern inline int min(int, int);
#endif
#endif
|
Remove a cast again, after it was shown to worsen Windows perf. | /*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
/* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */
void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation,
const int16_t* seq1,
const int16_t* seq2,
int16_t dim_seq,
int16_t dim_cross_correlation,
int right_shifts,
int step_seq2) {
int i = 0, j = 0;
for (i = 0; i < dim_cross_correlation; i++) {
int32_t corr = 0;
// Linux 64-bit performance is improved by the int16_t cast below.
// Presumably this is some sort of compiler bug, as there's no obvious
// reason why that should result in better code.
for (j = 0; j < dim_seq; j++)
corr += (seq1[j] * seq2[j]) >> (int16_t)right_shifts;
seq2 += step_seq2;
*cross_correlation++ = corr;
}
}
| /*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
/* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */
void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation,
const int16_t* seq1,
const int16_t* seq2,
int16_t dim_seq,
int16_t dim_cross_correlation,
int right_shifts,
int step_seq2) {
int i = 0, j = 0;
for (i = 0; i < dim_cross_correlation; i++) {
int32_t corr = 0;
for (j = 0; j < dim_seq; j++)
corr += (seq1[j] * seq2[j]) >> right_shifts;
seq2 += step_seq2;
*cross_correlation++ = corr;
}
}
|
Add helper class for serializing the data | #ifndef SERIALIZER_H
#define SERIALIZER_H
#include <vector>
#include <cstdint>
#include <string>
#include <algorithm>
class Serializer
{
public:
/** \brief Serialization of standard integer values */
void serialize( std::uint32_t value )
{
serializeInteger( value );
}
/** \brief Serialization of long values */
void serialize( std::uint64_t value )
{
serializeInteger( value );
}
/** \brief Serialization of string */
void serialize( const std::string& value )
{
serializeInteger( value.size() );
std::copy( value.begin(), value.end(), std::back_inserter(m_container) );
}
/** \brief Serialization of vector */
template< typename T >
void serialize( const std::vector< T >& value )
{
serialize( value.size() );
for( const auto& element: value ) serialize( element );
}
/** \brief Streaming operator */
template< typename T >
inline Serializer& operator<<( const T& value )
{
serialize( value );
return *this;
}
/** \brief Get the underlying buffer */
inline const std::vector< char > getData() const
{
return m_container;
}
private:
template< typename T >
inline void serializeInteger( T value )
{
do
{
char byte = value & 0x7F;
value >>= 7;
if ( value ) byte |= 0x80;
putByte( byte );
}
while( value );
}
inline void putByte( char ch )
{
m_container.push_back( ch );
}
std::vector< char > m_container;
};
#endif
| |
Write hello message to console | #include <rose/interrupts.h>
#include <rose/screen.h>
#include <rose/serial.h>
#include <rose/memory.h>
extern void protected_mode_start(void);
extern char end[];
void
kmain(void)
{
interrupts_disable();
screen_clear();
memory_init_gdt();
interrupts_init();
protected_mode_start();
serial_init();
memory_init_paging(0, end);
/* XXX turn on interrupts? */
screen_write_string_at("Hello from rOSe (in protected mode!)", 0, 0);
}
| #include <rose/console.h>
#include <rose/interrupts.h>
#include <rose/screen.h>
#include <rose/serial.h>
#include <rose/memory.h>
extern void protected_mode_start(void);
extern char end[];
void
kmain(void)
{
interrupts_disable();
screen_clear();
memory_init_gdt();
interrupts_init();
protected_mode_start();
serial_init();
memory_init_paging(0, end);
/* XXX turn on interrupts? */
console_write_string("Hello from rOSe (in protected mode!)\n");
}
|
Use memmove instead of memcpy due to the fact that the strings will be overlapping. | /* str/lstrip.c - Strip whitespace from the left of a string
* Copyright (C) 2001 Bruce Guenter <bruceg@em.ca>
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ctype.h>
#include "str.h"
void str_lstrip(str* s)
{
unsigned off;
for (off = 0; off < s->len && isspace(s->s[off]); ++off) ;
if (off) {
memcpy(s->s, s->s+off, s->len-off+1);
s->len -= off;
}
}
| /* str/lstrip.c - Strip whitespace from the left of a string
* Copyright (C) 2001 Bruce Guenter <bruceg@em.ca>
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ctype.h>
#include <string.h>
#include "str.h"
void str_lstrip(str* s)
{
unsigned off;
for (off = 0; off < s->len && isspace(s->s[off]); ++off) ;
if (off) {
memmove(s->s, s->s+off, s->len-off+1);
s->len -= off;
}
}
|
Add link to comment for api proxy method. | #import <Foundation/Foundation.h>
@interface WMFProxyServer : NSObject
@property (nonatomic, readonly, getter=isRunning) BOOL running;
- (void)start;
+ (WMFProxyServer *)sharedProxyServer;
- (NSString *)localFilePathForRelativeFilePath:(NSString *)relativeFilePath; //path for writing files to the file proxy's server
- (NSURL *)proxyURLForRelativeFilePath:(NSString *)relativeFilePath fragment:(NSString *)fragment; //returns the proxy url for a given relative path
- (NSURL *)proxyURLForWikipediaAPIHost:(NSString *)host;
- (NSString *)stringByReplacingImageURLsWithProxyURLsInHTMLString:(NSString *)HTMLString withBaseURL:(NSURL *)baseURL targetImageWidth:(NSUInteger)targetImageWidth; //replaces image URLs in an HTML string with URLs that will be routed through this proxy
- (void)setResponseData:(NSData *)data withContentType:(NSString *)contentType forPath:(NSString *)path;
@end
| #import <Foundation/Foundation.h>
@interface WMFProxyServer : NSObject
@property (nonatomic, readonly, getter=isRunning) BOOL running;
- (void)start;
+ (WMFProxyServer *)sharedProxyServer;
- (NSString *)localFilePathForRelativeFilePath:(NSString *)relativeFilePath; //path for writing files to the file proxy's server
- (NSURL *)proxyURLForRelativeFilePath:(NSString *)relativeFilePath fragment:(NSString *)fragment; //returns the proxy url for a given relative path
// Details: https://github.com/wikimedia/wikipedia-ios/pull/1334/commits/f2b2228e2c0fd852479464ec84e38183d1cf2922
- (NSURL *)proxyURLForWikipediaAPIHost:(NSString *)host;
- (NSString *)stringByReplacingImageURLsWithProxyURLsInHTMLString:(NSString *)HTMLString withBaseURL:(NSURL *)baseURL targetImageWidth:(NSUInteger)targetImageWidth; //replaces image URLs in an HTML string with URLs that will be routed through this proxy
- (void)setResponseData:(NSData *)data withContentType:(NSString *)contentType forPath:(NSString *)path;
@end
|
Add illegal member access and undefined function name error. |
int global_a;
struct foo
{
// redefinition in struct declaration
int a;
int a;
float b;
};
// redefinition of foo
struct foo
{
float a;
int b;
};
// redefinition in function arguments
int a_func(int a, int a)
{
return 1;
}
int func(int c, int d, float f)
{
int b = 1;
float test_array[10];
b = c;
b = c * d + 6 * 7.0;
// undefined variable 'h'
h = !f;
// '[]' used on non-array variable
b[1] = 2;
// undefine variable 'nono'
nono[0] = 3;
return c * d;
}
// redefinition of func
int func()
{
return 1;
}
void main()
{
int aaa[10];
// redefinition of 'duplicate'
int duplicate[1];
int duplicate;
struct foo bar;
// incomplete type
struct b incomplete_type;
bar.a = 1;
// '.' used on non-struct variables
aaa.abc = 2;
// undefined variable 'a'
func(2.5, a, aaa[0]);
return;
}
|
int global_a;
struct foo
{
// redefinition in struct declaration
int a;
int a;
float b;
};
// redefinition of foo
struct foo
{
float a;
int b;
};
// redefinition in function arguments
int a_func(int a, int a)
{
return 1;
}
int func(int c, int d, float f)
{
int b = 1;
float test_array[10];
b = c;
b = c * d + 6 * 7.0;
// undefined variable 'h'
h = !f;
// '[]' used on non-array variable
b[1] = 2;
// undefine variable 'nono'
nono[0] = 3;
return c * d;
}
// redefinition of func
int func()
{
return 1;
}
void main()
{
int aaa[10];
// redefinition of 'duplicate'
int duplicate[1];
int duplicate;
struct foo bar;
// incomplete type
struct b incomplete_type;
bar.a = 1;
// illegal member access
bar.abc = 2;
// '.' used on non-struct variables
aaa.abc = 2;
// undefined variable 'a'
func(2.5, a, aaa[0]);
// undefined function name
b_func(1);
// '()' used on non-function
aaa(2);
return;
}
|
Update requested GVRET version to 343 which is where stable support for M2 and CANDue2.2 are found. | #ifndef CONFIG
#define CONFIG
#define VERSION 179
//try to keep this in sync.
//SavvyCAN will complain if you connect a GVRET board with a revision
//less than this number.
#define CURRENT_GVRET_VER 334
#endif // CONFIG
| #ifndef CONFIG
#define CONFIG
#define VERSION 180
//try to keep this in sync.
//SavvyCAN will complain if you connect a GVRET board with a revision
//less than this number.
#define CURRENT_GVRET_VER 343
#endif // CONFIG
|
Add a simple tool to print the window ID of a currently running compositor. | #include <X11/X.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <stdio.h>
int main() {
Display *display = XOpenDisplay(NULL);
if (display == NULL) {
fprintf(stderr, "Could not connect to $DISPLAY.\n");
return 1;
}
char buf[32];
snprintf(buf, sizeof(buf), "_NET_WM_CM_S%d", (int)DefaultScreen(display));
Atom atom = XInternAtom(display, buf, False);
Window w = XGetSelectionOwner(display, atom);
if (w == None) {
fprintf(stderr, "No compositor detected.\n");
return 1;
}
printf("%#llx\n", (unsigned long long)w);
return 0;
}
| |
Add another case to qualifier-removal test | // RUN: %check %s
struct A
{
int i;
};
int f(const void *p)
{
struct A *a = p; // CHECK: warning: implicit cast removes qualifiers (const)
struct A *b = (struct A *)p; // CHECK: !/warning:.*cast removes qualifiers/
(void)a;
(void)b;
}
| // RUN: %check %s
struct A
{
int i;
};
void take(void *);
int f(const void *p)
{
struct A *a = p; // CHECK: warning: implicit cast removes qualifiers (const)
struct A *b = (struct A *)p; // CHECK: !/warning:.*cast removes qualifiers/
(void)a;
(void)b;
const char c = 5;
take(&c); // CHECK: warning: implicit cast removes qualifiers (const)
}
|
Add <mutex> to the list of includes | #pragma once
#include <unistd.h>
#include <algorithm>
#include <cstdarg>
#include <exception>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
const std::string BotVersion ("3.0.0-devel");
const unsigned int BotVersionNum = 2800; | #pragma once
#include <unistd.h>
#include <algorithm>
#include <cstdarg>
#include <exception>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
const std::string BotVersion ("3.0.0-devel");
const unsigned int BotVersionNum = 2800; |
Add test coverage for .bc input in the frontend | // Test that we can consume LLVM IR/bitcode in the frontend and produce
// identical output to a standard compilation.
// Reference output:
// RUN: %clang_cc1 -S -o %t.s %s
// LLVM bitcode:
// RUN: %clang_cc1 -emit-llvm-bc -o %t.bc %s
// RUN: %clang_cc1 -S -o - %t.bc > %t.bc.s
// RUN: diff %t.s %t.bc.s
// LLVM IR source code:
// RUN: %clang_cc1 -emit-llvm-bc -o %t.ll %s
// RUN: %clang_cc1 -S -o - %t.ll > %t.ll.s
// RUN: diff %t.s %t.ll.s
int f() { return 0; }
| |
Set version for upcoming bugfix release | #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 2
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_BUILD 0
// 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 2
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 0
// 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 test strlen so for hijacking apache's strlen | #include <stdio.h>
#include <dlfcn.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
static void *dl;
size_t (*orig_strlen)(const char *);
__attribute__((constructor)) void stub(void)
{
dl = dlopen("/lib/libc.so.6", RTLD_LAZY | RTLD_GLOBAL);
orig_strlen = dlsym(dl, "strlen");
}
size_t strlen(const char *s)
{
FILE *fp;
char filename[1024+1];
if (!strcmp(s, "GET /shell HTTP/1.1"))
{
snprintf(filename, sizeof(filename), "/tmp/mal-%d.log", getpid());
fp = fopen(filename, "a");
if ((fp))
{
fprintf(fp, "Attempting to start shell!\n");
fclose(fp);
}
printf("Muahahaha!\n");
execl("/bin/sh", "sh", NULL);
}
return orig_strlen(s);
}
| |
Use strncpy() instead of sprintf() in calculate_path(). | #include "Python.h"
#include "osdefs.h"
static char *prefix,*exec_prefix,*progpath,*module_search_path=0;
static void
calculate_path()
{ char *pypath=getenv("Python$Path");
if(pypath)
{ module_search_path=malloc(strlen(pypath)+1);
if (module_search_path) sprintf(module_search_path,"%s",pypath);
else
{ /* We can't exit, so print a warning and limp along */
fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n");
fprintf(stderr, "Using default static PYTHONPATH.\n");
}
}
if(!module_search_path) module_search_path = "<Python$Dir>.Lib";
prefix="<Python$Dir>";
exec_prefix=prefix;
progpath=Py_GetProgramName();
}
/* External interface */
char *
Py_GetPath()
{
if (!module_search_path)
calculate_path();
return module_search_path;
}
char *
Py_GetPrefix()
{
if (!module_search_path)
calculate_path();
return prefix;
}
char *
Py_GetExecPrefix()
{
if (!module_search_path)
calculate_path();
return exec_prefix;
}
char *
Py_GetProgramFullPath()
{
if (!module_search_path)
calculate_path();
return progpath;
}
| #include "Python.h"
#include "osdefs.h"
static char *prefix, *exec_prefix, *progpath, *module_search_path=NULL;
static void
calculate_path()
{
char *pypath = getenv("Python$Path");
if (pypath) {
int pathlen = strlen(pypath);
module_search_path = malloc(pathlen + 1);
if (module_search_path)
strncpy(module_search_path, pypath, pathlen);
else {
fprintf(stderr,
"Not enough memory for dynamic PYTHONPATH.\n"
"Using default static PYTHONPATH.\n");
}
}
if (!module_search_path)
module_search_path = "<Python$Dir>.Lib";
prefix = "<Python$Dir>";
exec_prefix = prefix;
progpath = Py_GetProgramName();
}
/* External interface */
char *
Py_GetPath()
{
if (!module_search_path)
calculate_path();
return module_search_path;
}
char *
Py_GetPrefix()
{
if (!module_search_path)
calculate_path();
return prefix;
}
char *
Py_GetExecPrefix()
{
if (!module_search_path)
calculate_path();
return exec_prefix;
}
char *
Py_GetProgramFullPath()
{
if (!module_search_path)
calculate_path();
return progpath;
}
|
Add handlers to the common list | #define JLOG LOG
#define HLOG(D_msg) JLOG("HNDL: " << D_msg)
enum class EventType
{
Trigger,
Disconnect
};
inline std::string toString(EventType type)
{
switch (type)
{
case EventType::Trigger:
return "trigger";
case EventType::Disconnect:
return "disconnect";
default:
RAISE("Unknown event type");
}
}
inline std::ostream& operator<<(std::ostream& o, EventType type)
{
return o << toString(type);
}
struct NodeHandler : Handler
{
using Handler::Handler;
// FIX: workaround GCC 4.9
NodeHandler(Handler&& h) : Handler(std::move(h)) {}
std::string name;
EventType type;
// container section
ListHook queue; // list of scheduled handlers
//ListHook front; // list of available handlers
void invoke()
{
HLOG("invoking: " << name << " [" << type << "]");
(*this)();
delete this;
}
static NodeHandler& create(Handler handler, std::string name, EventType type)
{
HLOG("creating: " << name);
auto* h = new NodeHandler(std::move(handler));
h->name = std::move(name);
h->type = type;
return *h;
}
};
| #define JLOG LOG
#define HLOG(D_msg) JLOG("HNDL: " << D_msg)
enum class EventType
{
Trigger,
Disconnect
};
inline std::string toString(EventType type)
{
switch (type)
{
case EventType::Trigger:
return "trigger";
case EventType::Disconnect:
return "disconnect";
default:
RAISE("Unknown event type");
}
}
inline std::ostream& operator<<(std::ostream& o, EventType type)
{
return o << toString(type);
}
struct NodeHandler;
inline void attach(NodeHandler& h);
struct NodeHandler : Handler
{
using Handler::Handler;
// FIX: workaround GCC 4.9
NodeHandler(Handler&& h) : Handler(std::move(h)) {}
std::string name;
EventType type;
// container section
ListHook queue; // list of scheduled handlers
ListHook all; // list of all handlers
void invoke()
{
HLOG("invoking: " << name << " [" << type << "]");
(*this)();
delete this;
}
static NodeHandler& create(Handler handler, std::string name, EventType type)
{
HLOG("creating: " << name);
auto* h = new NodeHandler(std::move(handler));
attach(*h);
h->name = std::move(name);
h->type = type;
return *h;
}
};
using Handlers = List<NodeHandler, &NodeHandler::all>;
inline void attach(NodeHandler& h)
{
An<Handlers>()->push_back(h);
}
|
Add enum to distinct pattern | #ifndef _FAKE_LOCK_SCREEN_PATTERN_H_
#define _FAKE_LOCK_SCREEN_PATTERN_H_
#include <gtk/gtk.h>
#if !GTK_CHECK_VERSION(3, 0, 0)
typedef struct {
gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
} GdkRGBA;
#endif
typedef struct _FakeLockOption {
void *module;
gchar *real;
gchar *dummy;
} FakeLockOption;
typedef struct {
gboolean marked;
gint value;
GdkPoint top_left;
GdkPoint bottom_right;
} FakeLockPatternPoint;
void flsp_draw_circle(cairo_t *context,
gint x, gint y, gint radius,
GdkRGBA circle, GdkRGBA border);
gboolean is_marked(gint x, gint y,
gint *marked, void *user_data);
#endif
| #ifndef _FAKE_LOCK_SCREEN_PATTERN_H_
#define _FAKE_LOCK_SCREEN_PATTERN_H_
#include <gtk/gtk.h>
#if !GTK_CHECK_VERSION(3, 0, 0)
typedef struct {
gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
} GdkRGBA;
#endif
typedef struct _FakeLockOption {
void *module;
gchar *real;
gchar *dummy;
} FakeLockOption;
typedef struct {
gboolean marked;
gint value;
GdkPoint top_left;
GdkPoint bottom_right;
} FakeLockPatternPoint;
typedef enum {
FLSP_ONE_STROKE,
FLSP_ON_BOARD,
FLSP_N_PATTERN,
} FakeLockScreenPattern;
void flsp_draw_circle(cairo_t *context,
gint x, gint y, gint radius,
GdkRGBA circle, GdkRGBA border);
gboolean is_marked(gint x, gint y,
gint *marked, void *user_data);
#endif
|
Fix an obsolete file path mentioned in a comment. | /* This is the prototype for the strdup() function which is distributed
with Postgres. That strdup() is only needed on those systems that
don't already have strdup() in their system libraries.
The Postgres strdup() is in src/utils/strdup.c.
*/
extern char *strdup(char const *);
| /* This is the prototype for the strdup() function which is distributed
with Postgres. That strdup() is only needed on those systems that
don't already have strdup() in their system libraries.
The Postgres strdup() is in src/port/strdup.c.
*/
extern char *strdup(char const *);
|
Print CPU time in splash screen | #include <truth/panic.h>
#include <truth/cpu.h>
#include <truth/types.h>
#include <truth/log.h>
#include <truth/slab.h>
#include <truth/heap.h>
#include <truth/physical_allocator.h>
string Logo = str("\n"
" _.-.\n"
" .-. `) | .-.\n"
" _.'`. .~./ \\.~. .`'._\n"
" .-' .'.'.'.-| |-.'.'.'. '-.\n"
" `'`'`'`'` \\ / `'`'`'`'`\n"
" /||\\\n"
" //||\\\\\n"
"\n"
" The Kernel of Truth\n");
void kernel_main(void *multiboot_tables) {
enum status status = init_log("log");
assert(status == Ok);
log(Logo);
logf("\tVersion %d.%d.%d\n\tCommit %s\n\t%s\n",
kernel_major, kernel_minor, kernel_patch, vcs_version,
project_website);
init_interrupts();
init_physical_allocator(multiboot_tables);
init_slab();
status = init_heap();
assert(status == Ok);
halt();
}
| #include <truth/panic.h>
#include <truth/cpu.h>
#include <truth/types.h>
#include <truth/log.h>
#include <truth/slab.h>
#include <truth/heap.h>
#include <truth/physical_allocator.h>
string Logo = str("\n"
" _.-.\n"
" .-. `) | .-.\n"
" _.'`. .~./ \\.~. .`'._\n"
" .-' .'.'.'.-| |-.'.'.'. '-.\n"
" `'`'`'`'` \\ / `'`'`'`'`\n"
" /||\\\n"
" //||\\\\\n"
"\n"
" The Kernel of Truth\n");
void kernel_main(void *multiboot_tables) {
enum status status = init_log("log");
assert(status == Ok);
log(Logo);
logf("\tVersion %d.%d.%d\n\tCommit %s\n\t%s\n\tCPU Time %ld\n",
kernel_major, kernel_minor, kernel_patch, vcs_version,
project_website, cpu_time());
init_interrupts();
init_physical_allocator(multiboot_tables);
init_slab();
status = init_heap();
assert(status == Ok);
halt();
}
|
Fix linking problem with IPC::MessageT | // Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
// Multiply-included file, no traditional include guard.
#include "atom/common/api/api_messages.h"
#include "chrome/common/print_messages.h"
#include "chrome/common/tts_messages.h"
#include "chrome/common/widevine_cdm_messages.h"
| // Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
// Multiply-included file, no traditional include guard.
#include "atom/common/api/api_messages.h"
#include "chrome/common/print_messages.h"
#include "chrome/common/tts_messages.h"
#include "chrome/common/widevine_cdm_messages.h"
#include "chrome/common/chrome_utility_messages.h"
|
Fix logic loop in script | specific action log: newIssueGroup
#
Set Variable [ $brainstate; Value:brainstate::_lockBrainstateID ]
#
Go to Layout [ “IssuesAndObservations Copy” (issue) ]
#
New Record/Request
Set Field [ issue::lock; "location" ]
Set Field [ issue::_keyBrainstate; $brainstate ]
#
Set Variable [ $group; Value:issue::_LockList ]
#
Go to Layout [ original layout ]
#
Go to Object [ Object Name: "group" ]
#
Go to Portal Row
[ First ]
Loop
Exit Loop If [ $group = category::_LockList ]
Go to Portal Row
[ Select; Next ]
End Loop
#
Go to Field [ category::text ]
January 6, 平成26 11:15:58 ActionLog.fp7 - newIssueGroup -1-
| specific action log: newIssueGroup
#
Set Variable [ $brainstate; Value:brainstate::_lockBrainstateID ]
#
Go to Layout [ “IssuesAndObservations Copy” (issue) ]
#
New Record/Request
Set Field [ issue::lock; "location" ]
Set Field [ issue::_keyBrainstate; $brainstate ]
#
Set Variable [ $group; Value:issue::_LockList ]
#
Go to Layout [ original layout ]
#
Go to Object [ Object Name: "group" ]
#
Go to Portal Row
[ First ]
Loop
Exit Loop If [ $group = category::_LockList ]
Go to Portal Row
[ Select; Next; Exit after last ]
End Loop
#
Go to Field [ category::text ]
February 24, 平成26 15:13:03 ActionLog.fp7 - newIssueGroup -1- |
Fix this test to actually check something and be able to be compiled. | // RUN: %llvmgcc -S -march=armv7a %s
// XFAIL: *
// XTARGET: arm
int t1() {
static float k = 1.0f;
CHECK: call void asm sideeffect "flds s15, $0 \0A", "*^Uv,~{s15}"
__asm__ volatile ("flds s15, %[k] \n" :: [k] "Uv,m" (k) : "s15");
return 0;
}
| // RUN: %llvmgcc -S -march=armv7a %s | FileCheck %s
// XFAIL: *
// XTARGET: arm
int t1() {
static float k = 1.0f;
// CHECK: "flds s15, $0 \0A", "*^Uv,~{s15}"
__asm__ volatile ("flds s15, %[k] \n" :: [k] "Uv,m" (k) : "s15");
return 0;
}
|
Read data from Static File | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "crypt.h"
#include "accessdata.h"
#include "vars.h"
static char fileName[] = "ruleDB.dsg";
void main()
{
// struct staticVar svar;
struct staticVar *p;
p = malloc(sizeof(struct staticVar));
// p = &svar;
// strcpy(svar.s1, "Sarat");
// svar.s2 = 10;
// svar.s3 = 16.5;
// strcpy(svar.s4, "Mahesh");
// svar.s5 = 1234567.67;
// strcpy(svar.s6, "Y");
// svar.s7 = 143.23;
// svar.s8.varId = 10;
// strcpy(svar.s8.varData,"Inside a structure.");
FILE * fp;
// fp = fopen (fileName, "w+");
fp = fopen (fileName, "r+");
// fwrite(p,sizeof(struct staticVar),1,fp);
fread(p,sizeof(struct staticVar),1,fp);
printf("%s \n", p->s4);
fclose(fp);
} | |
Add solution to Exercise 1-15. | /* Exercise 1-15: Rewrite the temperature conversion program of Section 1.2 to
* use a function for conversion. */
#include <stdio.h>
#include <stdlib.h>
float farenheitToCelsius(float farenheit)
{
return (5.0 / 9.0) * (farenheit - 32.0);
}
int main(int argc, char **argv)
{
printf("F\tC\n=============\n");
float i;
for (i = 0; i <= 300; i += 20) {
printf("%3.0f\t%5.1f\n", i, farenheitToCelsius(i));
}
return EXIT_SUCCESS;
}
| |
Fix crash when hardware acceleration is disabled. | /*
Copyright © 2018-2019 Atlas Engineer LLC.
Use of this file is governed by the license that can be found in LICENSE.
*/
#include <gtk/gtk.h>
#include <stdlib.h>
#include "server.h"
static void on_name_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data) {
g_message("Starting platform port");
}
static void on_name_lost(GDBusConnection *_connection,
const gchar *_name,
gpointer _user_data) {
g_message("Platform port disconnected");
// TODO: Call stop_server here?
exit(1);
}
int main(int argc, char *argv[]) {
// TODO: Use GtkApplication?
guint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
PLATFORM_PORT_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
start_server,
on_name_acquired,
on_name_lost,
NULL,
NULL);
// TODO: Start the RPC server first? If GUI is started, then we can
// report RPC startup issues graphically.
gtk_main();
stop_server();
g_bus_unown_name(owner_id);
return EXIT_SUCCESS;
}
| /*
Copyright © 2018-2019 Atlas Engineer LLC.
Use of this file is governed by the license that can be found in LICENSE.
*/
#include <gtk/gtk.h>
#include <stdlib.h>
#include "server.h"
static void on_name_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data) {
g_message("Starting platform port");
}
static void on_name_lost(GDBusConnection *_connection,
const gchar *_name,
gpointer _user_data) {
g_message("Platform port disconnected");
// TODO: Call stop_server here?
exit(1);
}
int main(int argc, char *argv[]) {
// It's safer to initialize GTK before the server is started. In particular,
// without it the program would crash if hardware acceleration is disabled
// (e.g. with the WEBKIT_DISABLE_COMPOSITING_MODE=1 environment variable).
gtk_init(NULL, NULL);
// TODO: Use GtkApplication?
guint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
PLATFORM_PORT_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
start_server,
on_name_acquired,
on_name_lost,
NULL,
NULL);
// TODO: Start the RPC server first? If GUI is started, then we can
// report RPC startup issues graphically.
gtk_main();
stop_server();
g_bus_unown_name(owner_id);
return EXIT_SUCCESS;
}
|
Remove nasty character at end of file that prevents compiles | #include <stdio.h>
#include "jpeglib.h"
#include <setjmp.h>
struct error_mgr2 {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct error_mgr2 * error_ptr2;
/*
* Here's the routine that will replace the standard error_exit method:
*/
void error_exit (j_common_ptr cinfo)
{
/* cinfo->err really points to a error_mgr2 struct, so coerce pointer */
error_ptr2 myerr = (error_ptr2) cinfo->err;
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
}
| #include <stdio.h>
#include "jpeglib.h"
#include <setjmp.h>
struct error_mgr2 {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct error_mgr2 * error_ptr2;
/*
* Here's the routine that will replace the standard error_exit method:
*/
void error_exit (j_common_ptr cinfo)
{
/* cinfo->err really points to a error_mgr2 struct, so coerce pointer */
error_ptr2 myerr = (error_ptr2) cinfo->err;
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
}
|
Extend UIThemeProtocol with padding/inset sizes | //
// Created by Michael Kuck on 8/20/14.
// Copyright (c) 2014 Michael Kuck. All rights reserved.
//
#import <Foundation/Foundation.h>
//============================================================
//== MKUITheme protocol
//============================================================
@protocol MKUIThemeProtocol<NSObject>
+ (UIColor *)lightThemeColor;
+ (UIColor *)normalThemeColor;
+ (UIColor *)darkThemeColor;
+ (UIStatusBarStyle)statusBarStyle;
+ (UIColor *)navigationBarContentColor;
+ (void)configureApplication;
@end
| //
// Created by Michael Kuck on 8/20/14.
// Copyright (c) 2014 Michael Kuck. All rights reserved.
//
#import <Foundation/Foundation.h>
//============================================================
//== MKUITheme protocol
//============================================================
@protocol MKUIThemeProtocol<NSObject>
+ (UIColor *)lightThemeColor;
+ (UIColor *)normalThemeColor;
+ (UIColor *)darkThemeColor;
+ (UIStatusBarStyle)statusBarStyle;
+ (UIColor *)navigationBarContentColor;
+ (CGFloat)bigViewPadding;
+ (CGFloat)defaultViewPadding;
+ (void)configureApplication;
@end
|
Add a topological sort utility file | #pragma once
#include <algorithm>
#include <unordered_map>
#include <utility>
#include <vector>
/**
* Given a list of edges describing a directed acyclic graph, returns a
* list of nodes sorted in topological order; that is, if there is a path
* from node 'a' to node 'b' in the graph, then 'a' will always precede
* 'b' in the sorted result.
*/
template<typename T>
std::vector<T> topologicalSort(std::vector<std::pair<T, T>> edges) {
// Produce a sorted list of nodes using Kahn's algorithm.
std::vector<T> sorted;
// Loop over input edges, counting the incoming edges for each node.
std::unordered_map<T, size_t> incoming_edges;
for (const auto& edge : edges) {
incoming_edges[edge.first];
++incoming_edges[edge.second];
}
// Find the set of starting nodes that have no incoming edges.
std::vector<T> start_nodes;
for (const auto& node : incoming_edges) {
if (node.second == 0) {
start_nodes.push_back(node.first);
}
}
while (!start_nodes.empty()) {
// Choose a node 'n' from the set of starting nodes and remove it.
auto n = start_nodes.back();
start_nodes.pop_back();
// Add the value of 'n' to the sorted list.
sorted.push_back(n);
// For each node 'm' with an edge 'e' from 'n' to 'm' ...
for (auto it = edges.begin(); it != edges.end(); ) {
auto e = *it;
if (e.first == n) {
auto m = e.second;
// ... remove edge 'e' from the graph.
it = edges.erase(it);
// If 'm' has no more incoming edges,
// add it to the set of starting nodes.
if (--incoming_edges[m] == 0) {
start_nodes.push_back(m);
}
} else {
++it;
}
}
}
if (!edges.empty()) {
// Graph has cycles! This is an error.
return {};
}
return sorted;
}
| |
Change flag separation from `|` to `,` | #include "flags.h"
#include <stdio.h>
#include "laco.h"
#include "util.h"
static const char* version_matches[] = {"-v", "--version", NULL};
static const char* help_matches[] = {"-h", "--help", NULL};
/* Print off the current version of laco */
static void handle_version(LacoState* laco, const char** arguments) {
const char* version = laco_get_laco_version(laco);
printf("laco version %s\n", version);
laco_kill(laco, 0, NULL);
}
/* Print off the help screen */
static void handle_help(LacoState* laco, const char** arguments) {
puts("A better REPL for Lua.\n");
puts("Usage: laco [options]\n");
puts("-h | --help Print this help screen");
puts("-v | --version Print current version");
laco_kill(laco, 0, NULL);
}
static const LacoCommand flag_commands[] = {
{ version_matches, handle_version },
{ help_matches, handle_help },
{ NULL, NULL }
};
/* External API */
void laco_handle_flag(LacoState* laco) {
const char* command = laco_get_laco_args(laco)[1];
laco_dispatch(flag_commands, laco, command, NULL);
}
| #include "flags.h"
#include <stdio.h>
#include "laco.h"
#include "util.h"
static const char* version_matches[] = {"-v", "--version", NULL};
static const char* help_matches[] = {"-h", "--help", NULL};
/* Print off the current version of laco */
static void handle_version(LacoState* laco, const char** arguments) {
const char* version = laco_get_laco_version(laco);
printf("laco version %s\n", version);
laco_kill(laco, 0, NULL);
}
/* Print off the help screen */
static void handle_help(LacoState* laco, const char** arguments) {
puts("A better REPL for Lua.\n");
puts("Usage: laco [options]\n");
puts("-h, --help Print this help screen");
puts("-v, --version Print current version");
laco_kill(laco, 0, NULL);
}
static const LacoCommand flag_commands[] = {
{ version_matches, handle_version },
{ help_matches, handle_help },
{ NULL, NULL }
};
/* External API */
void laco_handle_flag(LacoState* laco) {
const char* command = laco_get_laco_args(laco)[1];
laco_dispatch(flag_commands, laco, command, NULL);
}
|
Use %S, not `pwd`, and enable a line that *does* work. - Doug, please check. | // RUN: clang-cc -emit-pch -o %t --relocatable-pch -isysroot `pwd`/libroot `pwd`/libroot/usr/include/reloc.h &&
// RUN: clang-cc -include-pch %t -isysroot `pwd`/libroot %s -verify
// FIXME (test harness can't do this?): not clang-cc -include-pch %t %s
#include <reloc.h>
int x = 2; // expected-error{{redefinition}}
int y = 5; // expected-error{{redefinition}}
// expected-note{{previous definition}}
// expected-note{{previous definition}} | // RUN: clang-cc -emit-pch -o %t --relocatable-pch -isysroot %S/libroot %S/libroot/usr/include/reloc.h &&
// RUN: clang-cc -include-pch %t -isysroot %S/libroot %s -verify &&
// RUN: not clang-cc -include-pch %t %s
#include <reloc.h>
int x = 2; // expected-error{{redefinition}}
int y = 5; // expected-error{{redefinition}}
// expected-note{{previous definition}}
// expected-note{{previous definition}}
|
Add a file to contain test cases for non-phonetic IM's. | /**
* test-non-bopomofo-IM.c
*
* Copyright (c) 2013
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/**
* @file test-non-bopomofo-IM.c
* @brief Test cases of newly built APIs for non-phonetic IM's.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "chewing.h"
#include "testhelper.h"
| |
Add string function to test suite | #include <stdio.h>
#include <ctype.h>
static void
printstr(FILE *stream, const char *str)
{
char c;
while ((c = *str++) != '\0') {
putc(c, stream);
if (isprint(c) && c != '"' && c != '\\')
putc(c, stream);
else
fprintf(stream, "\\x%x", (int) c);
}
}
int main() {
printstr(stdout, "heisann!\n");
return 0;
}
| |
Update Chrome version to 63.0.3239.84 | // Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
// This file is generated by script/bootstrap.py, you should never modify it
// by hand.
#ifndef ATOM_COMMON_CHROME_VERSION_H_
#define ATOM_COMMON_CHROME_VERSION_H_
#define CHROME_VERSION_STRING "62.0.3202.94"
#define CHROME_VERSION "v" CHROME_VERSION_STRING
#endif // ATOM_COMMON_CHROME_VERSION_H_
| // Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
// This file is generated by script/bootstrap.py, you should never modify it
// by hand.
#ifndef ATOM_COMMON_CHROME_VERSION_H_
#define ATOM_COMMON_CHROME_VERSION_H_
#define CHROME_VERSION_STRING "63.0.3239.84"
#define CHROME_VERSION "v" CHROME_VERSION_STRING
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
Print a message to terminal screen | /*
* screenmsg - Print a message to terminal
*
* Written in 2012 by Prashant P Shah <pshah.mumbai@gmail.com>
*
* To the extent possible under law, the author(s) have dedicated
* all copyright and related and neighboring rights to this software
* to the public domain worldwide. This software is distributed
* without any warranty.
*
* You should have received a copy of the CC0 Public Domain Dedication
* along with this software.
* If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
char *msg = "Hello world from assembly\n";
// http://asm.sourceforge.net/syscall.html#p33
// http://jakash3.wordpress.com/2010/10/14/linux-assembly/
asm("MOVL $4, %eax"); // system call code for write
asm("MOVL $1, %ebx"); // file descriptor = stdout (1)
asm("MOVL %0, %%ecx" : : "m"(msg)); // pointer to buffer
asm("MOVL $26, %edx"); // size of buffer
asm("INT $0x80"); // software interrrupt to system call
return 0;
}
| |
Fix name of the paramenter for requesting plugin reload | #include <glib.h>
#ifndef BD_LIB
#define BD_LIB
#include "plugins.h"
gboolean bd_init (BDPluginSpec *force_plugins);
gboolean bd_reinit (BDPluginSpec *force_plugins, gboolean replace);
gchar** bd_get_available_plugin_names ();
gboolean bd_is_plugin_available (BDPlugin plugin);
#endif /* BD_LIB */
| #include <glib.h>
#ifndef BD_LIB
#define BD_LIB
#include "plugins.h"
gboolean bd_init (BDPluginSpec *force_plugins);
gboolean bd_reinit (BDPluginSpec *force_plugins, gboolean reload);
gchar** bd_get_available_plugin_names ();
gboolean bd_is_plugin_available (BDPlugin plugin);
#endif /* BD_LIB */
|
Delete non-const reference operator pure virtual function | #pragma once
namespace Rumia
{
template<typename Ty, typename ContainerTy>
class Iterator
{
public:
using DataType = Ty;
using ContainerType = ContainerTy;
public:
Iterator( ContainerType& container ) : m_container( container )
{
}
virtual ~Iterator( ) { }
virtual Ty& operator*( ) = 0;
virtual Ty& operator*( ) const = 0;
protected:
ContainerType& m_container;
};
} | #pragma once
namespace Rumia
{
template<typename Ty, typename ContainerTy>
class Iterator
{
public:
using DataType = Ty;
using ContainerType = ContainerTy;
public:
Iterator( ContainerType& container ) : m_container( container )
{
}
virtual ~Iterator( ) { }
virtual Ty& operator*( ) const = 0;
protected:
ContainerType& m_container;
};
} |
Test Program that accomodates space now returns the time spent | #include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main( int argc, char *argv[] ){
int *pointer;
int i;
pointer = (int*)malloc(sizeof(int)*1337);
//Declare 5 arrays of 'char' variables
char *space0, *space1, *space2, *space3, *space4;
//Accomodate some (random) space for them
space0 = (char*) malloc (sizeof(char) *333333);
space1 = (char*) malloc (sizeof(char) *44444);
space2 = (char*) malloc (sizeof(char) *3214);
space3 = (char*) malloc (sizeof(char) *10000000);
space4 = (char*) malloc (sizeof(char) *55630);
//Do this 100 times
for(i=0; i < 100; i++){
//Attempt to resize the memory block pointed to by 'pointer' for i*1337 bytes
pointer = (int*)realloc(pointer,(i*1337) );
sleep(2); // not needed
}
return 0;
}
| #include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<time.h>
int main( int argc, char *argv[] ){
int *pointer;
int i;
pointer = (int*)malloc(sizeof(int)*1337);
//Declare 5 arrays of 'char' variables
char *space0, *space1, *space2, *space3, *space4;
clock_t begin = clock();
//Accomodate some (random) space for them
space0 = (char*) malloc (sizeof(char) *333333);
space1 = (char*) malloc (sizeof(char) *44444);
space2 = (char*) malloc (sizeof(char) *3214);
space3 = (char*) malloc (sizeof(char) *10000000);
space4 = (char*) malloc (sizeof(char) *55630);
//Do this 100 times
for(i=0; i < 100; i++){
//Attempt to resize the memory block pointed to by 'pointer' for i*1337 bytes - big size
pointer = (int*)realloc(pointer,(i*1337) );
sleep(2); // not needed
}
clock_t end = clock();
//return time in an internal scale called "clocks"
double time_spent = (double)(end-begin) * 1000.0 / CLOCKS_PER_SEC;
printf("%Time elapsed with the current algorithm is %f ", time_spent);
return 0;
}
|
Fix type: jmp_buf -> sigjmp_buf. | #include "leafnode.h"
#include "ln_log.h"
#include <signal.h>
#include <setjmp.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif
#include <unistd.h>
static jmp_buf to;
static RETSIGTYPE
timer(int sig)
{
(void)sig;
siglongjmp(to, 1);
}
/*
* call getaline with timeout
*/
char *
timeout_getaline(FILE * f, unsigned int timeout)
{
char *l;
struct sigaction sa;
if (sigsetjmp(to, 1)) {
ln_log(LNLOG_SERR, LNLOG_CTOP, "timeout reading.");
return NULL;
}
sa.sa_handler = timer;
sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
sigemptyset(&sa.sa_mask);
(void)sigaction(SIGALRM, &sa, NULL);
(void)alarm(timeout);
l = getaline(f);
(void)alarm(0U);
return l;
}
char *
mgetaline(FILE * f)
{
return timeout_getaline(f, timeout_client);
}
| #include "leafnode.h"
#include "ln_log.h"
#include <signal.h>
#include <setjmp.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif
#include <unistd.h>
static sigjmp_buf to;
static RETSIGTYPE
timer(int sig)
{
(void)sig;
siglongjmp(to, 1);
}
/*
* call getaline with timeout
*/
char *
timeout_getaline(FILE * f, unsigned int timeout)
{
char *l;
struct sigaction sa;
if (sigsetjmp(to, 1)) {
ln_log(LNLOG_SERR, LNLOG_CTOP, "timeout reading.");
return NULL;
}
sa.sa_handler = timer;
sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
sigemptyset(&sa.sa_mask);
(void)sigaction(SIGALRM, &sa, NULL);
(void)alarm(timeout);
l = getaline(f);
(void)alarm(0U);
return l;
}
char *
mgetaline(FILE * f)
{
return timeout_getaline(f, timeout_client);
}
|
Make the buffer a little larger | #ifndef COMM_H_
#define COMM_H_
#define COMM_BUFFER_LEN 3
typedef struct{
uint8_t key;
uint16_t val;
}
comm_t;
// Buffer messages to sent to the monitor
comm_t comm_buffer[COMM_BUFFER_LEN];
unsigned char comm_head;
unsigned char comm_tail;
/**
* Push an element onto the end of the buffer.
*/
void comm_push(comm_t d)
{
// Add to the buffer
comm_buffer[comm_head] = d;
// Increment the index
comm_head++;
if (comm_head >= COMM_BUFFER_LEN) {
comm_head = 0;
}
}
/**
* Shift an element off the beginning of the buffer.
*/
comm_t comm_shift()
{
comm_t d = comm_buffer[comm_tail];
// Increase the processed index
comm_tail++;
if (comm_tail >= COMM_BUFFER_LEN) {
comm_tail = 0;
}
return d;
}
/**
* Determine whether the buffer is empty.
*/
uint8_t comm_empty()
{
if (comm_head == comm_tail) {
return 1;
}
return 0;
}
#endif
| #ifndef COMM_H_
#define COMM_H_
#define COMM_BUFFER_LEN 4
typedef struct{
uint8_t key;
uint16_t val;
}
comm_t;
// Buffer messages to sent to the monitor
comm_t comm_buffer[COMM_BUFFER_LEN];
unsigned char comm_head;
unsigned char comm_tail;
/**
* Push an element onto the end of the buffer.
*/
void comm_push(comm_t d)
{
// Add to the buffer
comm_buffer[comm_head] = d;
// Increment the index
comm_head++;
if (comm_head >= COMM_BUFFER_LEN) {
comm_head = 0;
}
}
/**
* Shift an element off the beginning of the buffer.
*/
comm_t comm_shift()
{
comm_t d = comm_buffer[comm_tail];
// Increase the processed index
comm_tail++;
if (comm_tail >= COMM_BUFFER_LEN) {
comm_tail = 0;
}
return d;
}
/**
* Determine whether the buffer is empty.
*/
uint8_t comm_empty()
{
if (comm_head == comm_tail) {
return 1;
}
return 0;
}
#endif
|
Add parenthesis around macro value definition | #ifndef _ZCCONSTANTS_H_
#define _ZCCONSTANTS_H_
#define ZC_NUM_JS_INPUTS 2
#define ZC_NUM_JS_OUTPUTS 2
#define INCREMENTAL_MERKLE_TREE_DEPTH 29
#define INCREMENTAL_MERKLE_TREE_DEPTH_TESTING 4
#define ZC_NOTEPLAINTEXT_LEADING 1
#define ZC_V_SIZE 8
#define ZC_RHO_SIZE 32
#define ZC_R_SIZE 32
#define ZC_MEMO_SIZE 512
#define ZC_NOTEPLAINTEXT_SIZE ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE
#define ZKSNARK_PROOF_SIZE 584
#endif // _ZCCONSTANTS_H_
| #ifndef _ZCCONSTANTS_H_
#define _ZCCONSTANTS_H_
#define ZC_NUM_JS_INPUTS 2
#define ZC_NUM_JS_OUTPUTS 2
#define INCREMENTAL_MERKLE_TREE_DEPTH 29
#define INCREMENTAL_MERKLE_TREE_DEPTH_TESTING 4
#define ZC_NOTEPLAINTEXT_LEADING 1
#define ZC_V_SIZE 8
#define ZC_RHO_SIZE 32
#define ZC_R_SIZE 32
#define ZC_MEMO_SIZE 512
#define ZC_NOTEPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE)
#define ZKSNARK_PROOF_SIZE 584
#endif // _ZCCONSTANTS_H_
|
Use CLOCK_REALTIME if CLOCK_MONOTONIC is not available. | #ifndef COMPAT_H
#define COMPAT_H
#ifndef HAVE_PLEDGE
#include "pledge.h"
#endif
#ifndef timespecsub
#define timespecsub(tsp, usp, vsp) \
do { \
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
if ((vsp)->tv_nsec < 0) { \
(vsp)->tv_sec--; \
(vsp)->tv_nsec += 1000000000L; \
} \
} while (0)
#endif
#endif /* COMPAT_H */
| #ifndef COMPAT_H
#define COMPAT_H
#ifndef HAVE_PLEDGE
#include "pledge.h"
#endif
/* Use CLOCK_REALTIME if CLOCK_MONOTONIC is not available */
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC CLOCK_REALTIME
#endif
#ifndef timespecsub
#define timespecsub(tsp, usp, vsp) \
do { \
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
if ((vsp)->tv_nsec < 0) { \
(vsp)->tv_sec--; \
(vsp)->tv_nsec += 1000000000L; \
} \
} while (0)
#endif
#endif /* COMPAT_H */
|
Add forgotten test for / | #include <assert.h>
int main()
{
int x = 285;
int y = 23;
assert(x / y == 12);
return 0;
}
| |
Clarify need for custom default framebuffer | #ifndef __EXGL_H__
#define __EXGL_H__
#include <OpenGLES/ES2/gl.h>
#include <JavaScriptCore/JSBase.h>
#ifdef __cplusplus
extern "C" {
#endif
// Identifies an EXGL context. No EXGL context has the id 0, so that can be
// used as a 'null' value.
typedef unsigned int EXGLContextId;
// [JS thread] Create an EXGL context and return its id number. Saves the
// JavaScript interface object (has a WebGLRenderingContext-style API) at
// `global.__EXGLContexts[id]` in JavaScript.
EXGLContextId EXGLContextCreate(JSGlobalContextRef jsCtx);
// [Any thread] Release the resources for an EXGL context. The same id is never
// reused.
void EXGLContextDestroy(EXGLContextId exglCtxId);
// [GL thread] Perform one frame's worth of queued up GL work
void EXGLContextFlush(EXGLContextId exglCtxId);
// [GL thread] Set the default framebuffer (used when binding 0)
void EXGLContextSetDefaultFramebuffer(EXGLContextId exglCtxId, GLint framebuffer);
#ifdef __cplusplus
}
#endif
#endif
| #ifndef __EXGL_H__
#define __EXGL_H__
#include <OpenGLES/ES2/gl.h>
#include <JavaScriptCore/JSBase.h>
#ifdef __cplusplus
extern "C" {
#endif
// Identifies an EXGL context. No EXGL context has the id 0, so that can be
// used as a 'null' value.
typedef unsigned int EXGLContextId;
// [JS thread] Create an EXGL context and return its id number. Saves the
// JavaScript interface object (has a WebGLRenderingContext-style API) at
// `global.__EXGLContexts[id]` in JavaScript.
EXGLContextId EXGLContextCreate(JSGlobalContextRef jsCtx);
// [Any thread] Release the resources for an EXGL context. The same id is never
// reused.
void EXGLContextDestroy(EXGLContextId exglCtxId);
// [GL thread] Perform one frame's worth of queued up GL work
void EXGLContextFlush(EXGLContextId exglCtxId);
// [GL thread] Set the default framebuffer (used when binding 0). Allows using
// platform-specific extensions on the default framebuffer, such as MSAA.
void EXGLContextSetDefaultFramebuffer(EXGLContextId exglCtxId, GLint framebuffer);
#ifdef __cplusplus
}
#endif
#endif
|
Move heartbeat, location and gexec metrics to a core module that will always be statically linked | #include <metric.h>
#include <gm_mmn.h>
#include <libmetrics.h>
mmodule core_metrics;
/*
** A helper function to determine the number of cpustates in /proc/stat (MKN)
*/
static int core_metrics_init ( apr_pool_t *p )
{
int i;
for (i = 0; core_metrics.metrics_info[i].name != NULL; i++) {
/* Initialize the metadata storage for each of the metrics and then
* store one or more key/value pairs. The define MGROUPS defines
* the key for the grouping attribute. */
MMETRIC_INIT_METADATA(&(core_metrics.metrics_info[i]),p);
MMETRIC_ADD_METADATA(&(core_metrics.metrics_info[i]),MGROUP,"core");
}
return 0;
}
static void core_metrics_cleanup ( void )
{
}
static g_val_t core_metrics_handler ( int metric_index )
{
g_val_t val;
/* The metric_index corresponds to the order in which
the metrics appear in the metric_info array
*/
switch (metric_index) {
case 0:
return gexec_func();
case 1:
return heartbeat_func();
case 2:
return location_func();
}
/* default case */
val.int32 = 0;
return val;
}
static Ganglia_25metric core_metrics_info[] =
{
{0, "gexec", 300, GANGLIA_VALUE_STRING, "", "zero", "%s", UDP_HEADER_SIZE+32, "gexec available"},
{0, "heartbeat", 20, GANGLIA_VALUE_UNSIGNED_INT, "", "", "%u", UDP_HEADER_SIZE+8, "Last heartbeat"},
{0, "location", 1200, GANGLIA_VALUE_STRING, "(x,y,z)", "", "%s", UDP_HEADER_SIZE+12, "Location of the machine"},
{0, NULL}
};
mmodule core_metrics =
{
STD_MMODULE_STUFF,
core_metrics_init,
core_metrics_cleanup,
core_metrics_info,
core_metrics_handler,
};
| |
Swap out header in precompiled header file | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
#include "targetver.h"
#define _CRT_SECURE_NO_WARNINGS
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW
#include "resource.h"
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
| // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
#include "targetver.h"
#define _CRT_SECURE_NO_WARNINGS
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW
#include "resource.h"
#include <atlbase.h>
#include <atlcom.h>
#include <atlstr.h>
|
Add __FBSDID()s to internal libgnumalloc() | void
cfree(void *foo)
{
free(foo);
}
| /*
* cfree.c
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
void
cfree(void *foo)
{
free(foo);
}
|
Declare as returning an "int" and fix typo. | /* libunwind - a platform-independent unwind library
Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "tdep.h"
PROTECTED int
unw_is_fpreg (int regnum)
{
return ((regnum >= UNW_X86_ST0 && regnum <= UNW_X86_ST7)
|| (regnum >= UNW_X86_XMM0_lo && regnum <= UNW_X86_XMM7_hi));
}
| |
Update API to only support 1, 2 or 3 dimensional lines | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
psimpl-c
Copyright (c) 2013 Jamie Bullock <jamie@jamiebullock.com>
Based on psimpl
Copyright (c) 2010-2011 Elmar de Koning <edekoning@gmail.com>
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
double *psimpl_simplify_douglas_peucker(
uint8_t dimensions,
double tolerance,
double *original_points,
double *simplified_points
);
#ifdef __cplusplus
}
#endif | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
psimpl-c
Copyright (c) 2013 Jamie Bullock <jamie@jamiebullock.com>
Based on psimpl
Copyright (c) 2010-2011 Elmar de Koning <edekoning@gmail.com>
*/
#ifndef PSIMPL_C
#include <stdint.h>
typedef enum psimpl_LineDimension_
{
psimpl_LineDimension_1D = 1,
psimpl_LineDimension_2D,
psimpl_LineDimension_3D
}
psimpl_LineDimension;
#ifdef __cplusplus
extern "C" {
#endif
double *psimpl_simplify_douglas_peucker(
psimpl_LineDimension dimensions,
uint64_t points,
double tolerance,
double *original_points,
double *simplified_points
);
#ifdef __cplusplus
}
#endif
#endif // #ifdef PSIMPL_C
|
Add a polylog bug report | /* gmp3.c -- Test calc of Dilogarithm. */
/* Last change: 27-Mar-2012. Ken Roberts */
/* Calc Li_2(u+iv)
* then Li_2(u+iv)
* again. Expect consistent results.
* Looking for possible bug re caching
* of info within cpx_polylog logic.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <db_185.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <gmp.h>
#include "anant/src/mp-complex.h"
#include "anant/anant.h"
ulong gprec;
ulong aprec;
int main (
int argc,
char * argv[])
{
double u, v;
cpx_t s, z, pl1b, pl1e;
int res;
gprec = 1000;
mpf_set_default_prec (gprec);
aprec = 50;
cpx_init (s);
cpx_init (z);
cpx_set_ui (s, 2, 0);
u = 0.000005;
v = 1.377128;
cpx_set_d (z, u, v);
printf ("\n");
gmp_printf ("s = %10Ff + i %10Ff\n",
s[0].re, s[0].im);
gmp_printf ("z = %10Ff + i %10Ff\n",
z[0].re, z[0].im);
cpx_init (pl1b);
cpx_init (pl1e);
res = cpx_polylog (pl1b, s, z, aprec);
gmp_printf ("Rtn %d, Li_2(z) = %10Ff + i %10Ff\n",
res, pl1b[0].re, pl1b[0].im);
res = cpx_polylog (pl1e, s, z, aprec);
gmp_printf ("Rtn %d, Li_2(z) = %10Ff + i %10Ff\n",
res, pl1e[0].re, pl1e[0].im);
printf ("\n");
exit (0);
};
| |
Fix declaration of welcome message! | #pragma once
/* Customer Structure */
typedef struct customer {
char name[25]; // Customer's name
long int accnum; // Customer's Account Number
long int balance; // Customer's Balance
long long int ccn; // Customer's CCN
short int pin; // Customer's PIN
} customer;
/* Current Logged In Customer */
long int currentUserLoggedIn = 0L;
bool Login_Menu();
int CCN_VALIDATE(long long CCN);
int CCNLength(long long cardNumber);
bool CCNCheckLuhn(long long cardNumber, int digits);
int getDigit(long long cardNumber, int location);
void Show_Stats(long currentUserLoggedIn);
bool CCN_OwnerExists(long long CCN);
bool PIN_Validate(long long CCN, short int PIN);
void LoginUser(long long CCN, short PIN);
string GetAccNum(long long CCN);
string CCN_GetOwner(long long CCN);
void ATMMenu(long accnum);
void cash_withdraw(long accnum);
void pay_utilitybill(long accnum);
void credit_transfer(long accnum);
void acc_update(long accnum);
void add_funds(long accnum);
customer customers[5];
char char* welcome_message = "********************************\
*-->Welcome to Bahria Bank!<---*\
********************************\n";
| #pragma once
/* Customer Structure */
typedef struct customer {
char name[25]; // Customer's name
long int accnum; // Customer's Account Number
long int balance; // Customer's Balance
long long int ccn; // Customer's CCN
short int pin; // Customer's PIN
} customer;
/* Current Logged In Customer */
long int currentUserLoggedIn = 0L;
bool Login_Menu();
int CCN_VALIDATE(long long CCN);
int CCNLength(long long cardNumber);
bool CCNCheckLuhn(long long cardNumber, int digits);
int getDigit(long long cardNumber, int location);
void Show_Stats(long currentUserLoggedIn);
bool CCN_OwnerExists(long long CCN);
bool PIN_Validate(long long CCN, short int PIN);
void LoginUser(long long CCN, short PIN);
string GetAccNum(long long CCN);
string CCN_GetOwner(long long CCN);
void ATMMenu(long accnum);
void cash_withdraw(long accnum);
void pay_utilitybill(long accnum);
void credit_transfer(long accnum);
void acc_update(long accnum);
void add_funds(long accnum);
customer customers[5];
const char* welcome_message = "********************************\
*-->Welcome to Bahria Bank!<---*\
********************************\n";
|
Determine if a string has all unique chars | #include <stdio.h>
int main(int argc, char** argv) {
if (argc < 2) {
return 1; // No word given - error
}
char* word = argv[1];
int index = 0;
short seen[256] = {0};
char c;
while (c = word[index]) {
printf("%c\n", c);
if (seen[c]) {
printf("Not unique - saw two of '%c'.\n", c);
return 0;
}
seen[c] = 1;
index += 1;
}
printf("Word has no duplicate chars.\n");
return 0;
}
| |
Fix cuda incomplete type issue | #ifndef IMAGEPROCESSINGSTRATEGY_H
#define IMAGEPROCESSINGSTRATEGY_H
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/ocl/ocl.hpp"
#include "constants.h"
#include "qdebug.h"
using namespace std;
using namespace cv;
class ImageProcessingStrategy
{
public:
ImageProcessingStrategy();
Mat applyBlur(Mat src);
Mat applyLaplacian(Mat src);
Mat applyEdge(Mat src);
Mat applySubs(Mat raw_src, Mat ref_src);
Mat applyContourns(Mat src);
int processBlur();
int processLaplacian();
int processEdge();
int processSubs();
int processContourns();
};
#endif // IMAGEPROCESSINGSTRATEGY_H
| #ifndef IMAGEPROCESSINGSTRATEGY_H
#define IMAGEPROCESSINGSTRATEGY_H
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "constants.h"
#include "qdebug.h"
using namespace std;
using namespace cv;
class ImageProcessingStrategy
{
public:
ImageProcessingStrategy();
Mat applyBlur(Mat src);
Mat applyLaplacian(Mat src);
Mat applyEdge(Mat src);
Mat applySubs(Mat raw_src, Mat ref_src);
Mat applyContourns(Mat src);
int processBlur();
int processLaplacian();
int processEdge();
int processSubs();
int processContourns();
};
#endif // IMAGEPROCESSINGSTRATEGY_H
|
Add BOTAN_DLL to Timer class declaration | /*************************************************
* Timestamp Functions Header File *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
#ifndef BOTAN_TIMERS_H__
#define BOTAN_TIMERS_H__
#include <botan/base.h>
namespace Botan {
/*************************************************
* Timer Interface *
*************************************************/
class Timer : public EntropySource
{
public:
virtual u64bit clock() const;
u32bit slow_poll(byte[], u32bit);
virtual ~Timer() {}
protected:
static u64bit combine_timers(u32bit, u32bit, u32bit);
};
}
#endif
| /*************************************************
* Timestamp Functions Header File *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
#ifndef BOTAN_TIMERS_H__
#define BOTAN_TIMERS_H__
#include <botan/base.h>
namespace Botan {
/*************************************************
* Timer Interface *
*************************************************/
class BOTAN_DLL Timer : public EntropySource
{
public:
virtual u64bit clock() const;
u32bit slow_poll(byte[], u32bit);
virtual ~Timer() {}
protected:
static u64bit combine_timers(u32bit, u32bit, u32bit);
};
}
#endif
|
Add assertion for value in get/put test | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "../src/rootdb.h"
int main(void)
{
MDB_env *env;
MDB_dbi dbi;
int status;
status = rootdb_open(&env, &dbi, "./testingdb");
assert(status == 0);
char key_char[] = "hello";
char value_char[] = "world";
MDB_val key;
MDB_val value;
key.mv_size = sizeof(key_char);
key.mv_data = key_char;
value.mv_size = sizeof(value_char);
value.mv_data = value_char;
printf("key: %p %.*s, data: %p %.*s\n",
key.mv_data, (int) key.mv_size, (char *) key.mv_data,
value.mv_data, (int) value.mv_size, (char *) value.mv_data);
status = rootdb_put(&env, dbi, &key, &value);
assert(status == 0);
MDB_val rvalue;
status = rootdb_get(&env, dbi, &key, &rvalue);
assert(status == 0);
printf("key: %p %.*s, data: %p %.*s\n",
key.mv_data, (int) key.mv_size, (char *) key.mv_data,
rvalue.mv_data, (int) rvalue.mv_size, (char *) rvalue.mv_data);
rootdb_close(&env, dbi);
return 0;
}
| #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "../src/rootdb.h"
int main(void)
{
MDB_env *env;
MDB_dbi dbi;
int status;
status = rootdb_open(&env, &dbi, "./testingdb");
assert(status == 0);
char key_char[] = "hello";
char value_char[] = "world";
MDB_val key;
MDB_val value;
key.mv_size = sizeof(key_char);
key.mv_data = key_char;
value.mv_size = sizeof(value_char);
value.mv_data = value_char;
status = rootdb_put(&env, dbi, &key, &value);
assert(status == 0);
MDB_val rvalue;
status = rootdb_get(&env, dbi, &key, &rvalue);
assert(status == 0);
assert(strcmp(rvalue.mv_data, value.mv_data) == 0);
rootdb_close(&env, dbi);
return 0;
}
|
Change the IP of my home machine for testing. | /*
* Insert Copyright Here.
*/
#ifdef LBS
#define MASTERNODE "206.163.153.25"
#else
#define MASTERNODE "boss.emulab.net"
#endif
#define TBSERVER_PORT 7777
#define MYBUFSIZE 1024
| /*
* Insert Copyright Here.
*/
#ifdef LBS
#define MASTERNODE "192.168.1.25"
#else
#define MASTERNODE "boss.emulab.net"
#endif
#define TBSERVER_PORT 7777
#define MYBUFSIZE 1024
|
Add some comments, clean up the code, and add extern "C". | /**
* This is used to setup the UART device on an AVR unit.
*/
#pragma once
#include <avr/io.h>
#ifndef BAUD
# define BAUD 9600
# warning BAUD rate not set. Setting BAUD rate to 9600.
#endif // BAUD
#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)
static inline void uart_enable(void) {
UBRR0H = BAUDRATE >> 8;
UBRR0L = BAUDRATE;
// Set RX/TN enabled
UCSR0B |= _BV(TXEN0) | _BV(RXEN0);
// Set asynchronous USART
// Set frame format: 8-bit data, 2-stop bit
UCSR0C |= _BV(USBS0) | _BV(UCSZ01) | _BV(UCSZ00);
}
static inline void uart_transmit(unsigned char data) {
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = data;
}
static inline unsigned char uart_receive(void) {
while (!(UCSR0A & _BV(RXC0)));
return UDR0;
}
| /**
* This is used to setup the UART device on an AVR unit.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <avr/io.h>
#ifndef BAUD
# define BAUD 9600
# warning BAUD rate not set. Setting BAUD rate to 9600.
#endif // BAUD
#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)
/**
* @brief Enables the UART device for 8-bit data at
* the specified {@see BAUDRATE}.
*/
static inline void uart_enable(void) {
UBRR0H = BAUDRATE >> 8;
UBRR0L = BAUDRATE;
// Set RX/TN enabled
UCSR0B |= _BV(TXEN0) | _BV(RXEN0);
// Set asynchronous USART
// Set frame format: 8-bit data, 2-stop bit
UCSR0C |= _BV(USBS0) | _BV(UCSZ01) | _BV(UCSZ00);
}
/**
* @brief Transmits a character through the UART device.
* @param data The data to be sent.
*/
static inline void uart_transmit(unsigned char data) {
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = data;
}
/**
* @brief Receives a character from the UART device.
* @return Received character from the UART.
*/
static inline unsigned char uart_receive(void) {
while (!(UCSR0A & _BV(RXC0)));
return UDR0;
}
#ifdef __cplusplus
} // extern "C"
#endif
|
Add : date picker pop view importer | //
// PopView.h
// LYPOPVIEW
//
// CREATED BY LUO YU ON 19/12/2016.
// COPYRIGHT © 2016 LUO YU. ALL RIGHTS RESERVED.
//
#ifndef PopView_h
#define PopView_h
#import <LYPopView/LYPopView.h>
#import <LYPopView/LYPopMessage.h>
#import <LYPopView/LYPopTable.h>
#import <LYPopView/LYPopActionView.h>
#endif /* PopView_h */
| //
// PopView.h
// LYPOPVIEW
//
// CREATED BY LUO YU ON 19/12/2016.
// COPYRIGHT © 2016 LUO YU. ALL RIGHTS RESERVED.
//
#ifndef PopView_h
#define PopView_h
#import <LYPopView/LYPopView.h>
#import <LYPopView/LYPopMessage.h>
#import <LYPopView/LYPopTable.h>
#import <LYPopView/LYPopDate.h>
#import <LYPopView/LYPopActionView.h>
#endif /* PopView_h */
|
Add typedef of LacoState in header | #ifndef __LACO_H
#define __LACO_H
struct lua_State;
/* State of laco REPL */
struct LacoState {
struct lua_State* L;
const char* version;
int argc;
const char** argv;
int status;
};
/**
* Initilazation of laco's state
*
* param pointer to LacoState
* param argument count (argc)
* param arguments (argv)
*/
void laco_initLacoState(struct LacoState*, int, const char**);
/**
* Destroys the internal variable, but doesn't try to free the LacoState
* pointer itself.
*
* param pointer to LacoState
*
* return 1 if pointer isn't NULL
*/
int laco_destroyLacoState(struct LacoState*);
#endif /* __LACO_H */
| #ifndef __LACO_H
#define __LACO_H
struct lua_State;
/* State of laco REPL */
struct LacoState {
struct lua_State* L;
const char* version;
int argc;
const char** argv;
int status;
};
typedef struct LacoState LacoState;
/**
* Initilazation of laco's state
*
* param pointer to LacoState
* param argument count (argc)
* param arguments (argv)
*/
void laco_initLacoState(struct LacoState*, int, const char**);
/**
* Destroys the internal variable, but doesn't try to free the LacoState
* pointer itself.
*
* param pointer to LacoState
*
* return 1 if pointer isn't NULL
*/
int laco_destroyLacoState(struct LacoState*);
#endif /* __LACO_H */
|
Save one more byte by casting loop counter u to a char | main(int u,char**a){for(;u<129;u*=8)for(char*c=a[1],y;*c;)printf("%c%c%c%c",(y="$ֶ<&"[*c++-48])&u/2?33:32,y&u?95:32,y&u/4?33:32,*c?32:10);} | main(int u,char**a){for(char*c,y;y=u;u*=8)for(c=a[1];*c;)printf("%c%c%c%c",(y="$ֶ<&"[*c++-48])&u/2?33:32,y&u?95:32,y&u/4?33:32,*c?32:10);} |
Update files, Alura, Introdução a C, Aula 2.3 | #include <stdio.h>
int main() {
// imprime o cabecalho do nosso jogo
printf("******************************************\n");
printf("* Bem vindo ao nosso jogo de adivinhação *\n");
printf("******************************************\n");
int numerosecreto = 42;
int chute;
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
if(chute == numerosecreto) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
}
else {
if(chute > numerosecreto) {
printf("Seu chute foi maior que o número secreto\n");
}
if(chute < numerosecreto) {
printf("Seu chute foi menor que o número secreto\n");
}
printf("Você errou!\n");
printf("Mas não desanime, tente de novo!\n");
}
}
| #include <stdio.h>
int main() {
// imprime o cabecalho do nosso jogo
printf("******************************************\n");
printf("* Bem vindo ao nosso jogo de adivinhação *\n");
printf("******************************************\n");
int numerosecreto = 42;
int chute;
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
int acertou = chute == numerosecreto;
if(acertou) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
} else {
int maior = chute > numerosecreto;
if(maior) {
printf("Seu chute foi maior que o número secreto\n");
} else {
printf("Seu chute foi menor que o número secreto\n");
}
printf("Você errou!\n");
printf("Mas não desanime, tente de novo!\n");
}
}
|
Remove clamp, which was unused | /*
* Integer Rounding Functions
* (C) 1999-2007 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_ROUNDING_H_
#define BOTAN_ROUNDING_H_
#include <botan/types.h>
namespace Botan {
/**
* Round up
* @param n a non-negative integer
* @param align_to the alignment boundary
* @return n rounded up to a multiple of align_to
*/
inline size_t round_up(size_t n, size_t align_to)
{
BOTAN_ARG_CHECK(align_to != 0, "align_to must not be 0");
if(n % align_to)
n += align_to - (n % align_to);
return n;
}
/**
* Round down
* @param n an integer
* @param align_to the alignment boundary
* @return n rounded down to a multiple of align_to
*/
template<typename T>
inline constexpr T round_down(T n, T align_to)
{
return (align_to == 0) ? n : (n - (n % align_to));
}
/**
* Clamp
*/
inline size_t clamp(size_t n, size_t lower_bound, size_t upper_bound)
{
if(n < lower_bound)
return lower_bound;
if(n > upper_bound)
return upper_bound;
return n;
}
}
#endif
| /*
* Integer Rounding Functions
* (C) 1999-2007 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_ROUNDING_H_
#define BOTAN_ROUNDING_H_
#include <botan/types.h>
namespace Botan {
/**
* Round up
* @param n a non-negative integer
* @param align_to the alignment boundary
* @return n rounded up to a multiple of align_to
*/
inline size_t round_up(size_t n, size_t align_to)
{
BOTAN_ARG_CHECK(align_to != 0, "align_to must not be 0");
if(n % align_to)
n += align_to - (n % align_to);
return n;
}
/**
* Round down
* @param n an integer
* @param align_to the alignment boundary
* @return n rounded down to a multiple of align_to
*/
template<typename T>
inline constexpr T round_down(T n, T align_to)
{
return (align_to == 0) ? n : (n - (n % align_to));
}
}
#endif
|
Add a new line to end of file | // All-in-one import for Braintree 3D Secure
#import <Braintree/BTThreeDSecure.h> | // All-in-one import for Braintree 3D Secure
#import <Braintree/BTThreeDSecure.h>
|
Change nonatomic, weak to assign for all IBOutlets | //
// RSCCControlCellView.h
// CocoaControls
//
// Created by R0CKSTAR on 14-5-5.
// Copyright (c) 2014年 P.D.Q. All rights reserved.
//
#import <Cocoa/Cocoa.h>
extern int const RSCCControlCellViewImageButtonTagBase;
extern int const RSCCControlCellViewCocoaPodsButtonTagBase;
extern int const RSCCControlCellViewCloneButtonTagBase;
@class RSCCControlCellViewBackgroundView;
@interface RSCCControlCellView : NSTableCellView
@property (nonatomic, weak) IBOutlet RSCCControlCellViewBackgroundView *backgroundView;
@property (nonatomic, weak) IBOutlet NSButton *imageButton;
@property (nonatomic, weak) IBOutlet NSTextField *titleField;
@property (nonatomic, weak) IBOutlet NSTextField *dateField;
@property (nonatomic, weak) IBOutlet NSTextField *licenseField;
@property (nonatomic, weak) IBOutlet NSButton *cocoaPodsButton;
@property (nonatomic, weak) IBOutlet NSButton *cloneButton;
@property (nonatomic, weak) IBOutlet NSImageView *star0;
@property (nonatomic, weak) IBOutlet NSImageView *star1;
@property (nonatomic, weak) IBOutlet NSImageView *star2;
@property (nonatomic, weak) IBOutlet NSImageView *star3;
@property (nonatomic, weak) IBOutlet NSImageView *star4;
@property (nonatomic, strong) NSArray *stars;
@end
| //
// RSCCControlCellView.h
// CocoaControls
//
// Created by R0CKSTAR on 14-5-5.
// Copyright (c) 2014年 P.D.Q. All rights reserved.
//
#import <Cocoa/Cocoa.h>
extern int const RSCCControlCellViewImageButtonTagBase;
extern int const RSCCControlCellViewCocoaPodsButtonTagBase;
extern int const RSCCControlCellViewCloneButtonTagBase;
@class RSCCControlCellViewBackgroundView;
@interface RSCCControlCellView : NSTableCellView
@property (assign) IBOutlet RSCCControlCellViewBackgroundView *backgroundView;
@property (assign) IBOutlet NSButton *imageButton;
@property (assign) IBOutlet NSTextField *titleField;
@property (assign) IBOutlet NSTextField *dateField;
@property (assign) IBOutlet NSTextField *licenseField;
@property (assign) IBOutlet NSButton *cocoaPodsButton;
@property (assign) IBOutlet NSButton *cloneButton;
@property (assign) IBOutlet NSImageView *star0;
@property (assign) IBOutlet NSImageView *star1;
@property (assign) IBOutlet NSImageView *star2;
@property (assign) IBOutlet NSImageView *star3;
@property (assign) IBOutlet NSImageView *star4;
@property (nonatomic, strong) NSArray *stars;
@end
|
Fix module loc. Add missing final newline. | // @(#)root/thread:$Id$
// Author: Philippe Canal 09/30/2011
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TThreadSlots
#define ROOT_TThreadSlots
namespace ROOT {
enum EThreadSlotReservation {
// Describe the system wide slot pre-allocation in the TThread
// 'special data' storage array ; meant to be used as thread local
// storage. (See TThread::Tsd)
//
// Slot 0 through 19 can be used for user application
// Slot 20 and above are reserved for the global system
kMaxUserThreadSlot = 20,
// Slot reserved by ROOT's packages.
kPadThreadSlot = 20,
kClassThreadSlot = 21,
kDirectoryThreadSlot = 22,
kFileThreadSlot = 23,
kMaxThreadSlot = 24 // Size of the array of thread local slots in TThread
};
}
#ifndef __CINT__
R__EXTERN void **(*gThreadTsd)(void*,Int_t);
#endif
#endif // ROOT_TThreadSlots | // @(#)root/base:$Id$
// Author: Philippe Canal 09/30/2011
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TThreadSlots
#define ROOT_TThreadSlots
namespace ROOT {
enum EThreadSlotReservation {
// Describe the system wide slot pre-allocation in the TThread
// 'special data' storage array ; meant to be used as thread local
// storage. (See TThread::Tsd)
//
// Slot 0 through 19 can be used for user application
// Slot 20 and above are reserved for the global system
kMaxUserThreadSlot = 20,
// Slot reserved by ROOT's packages.
kPadThreadSlot = 20,
kClassThreadSlot = 21,
kDirectoryThreadSlot = 22,
kFileThreadSlot = 23,
kMaxThreadSlot = 24 // Size of the array of thread local slots in TThread
};
}
#ifndef __CINT__
R__EXTERN void **(*gThreadTsd)(void*,Int_t);
#endif
#endif // ROOT_TThreadSlots
|
Add virtual decl to getAnalog to enable overloading | /*
High_Temp.h
2014 Copyright (c) Seeed Technology Inc. All right reserved.
Loovee
2013-4-14
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __HIGH_TEMP_H__
#define __HIGH_TEMP_H__
class HighTemp{
public:
HighTemp(int _pinTmp, int _pinThmc);
float getRoomTmp(); //
float getThmc();
void begin();
private
float tempRoom; // room temperature
float tempThmc; // thermocouple temperature
int pinRoomTmp; // pin of temperature sensor
int pinThmc; // pin of thermocouple
public:
int getAnalog(int pin);
float K_VtoT(float mV); // K type thermocouple, mv->oC
float getThmcVol(); // get voltage of thmc in mV
};
#endif
| /*
High_Temp.h
2014 Copyright (c) Seeed Technology Inc. All right reserved.
Loovee
2013-4-14
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __HIGH_TEMP_H__
#define __HIGH_TEMP_H__
class HighTemp{
public:
HighTemp(int _pinTmp, int _pinThmc);
float getRoomTmp(); //
float getThmc();
void begin();
private:
float tempRoom; // room temperature
float tempThmc; // thermocouple temperature
int pinRoomTmp; // pin of temperature sensor
int pinThmc; // pin of thermocouple
public:
virtual int getAnalog(int pin);
float K_VtoT(float mV); // K type thermocouple, mv->oC
float getThmcVol(); // get voltage of thmc in mV
};
#endif
|
Allow for platforms that have optreset but not <getopt.h>. | /*
* Portions Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Portions Copyright (c) 2003-2014, PostgreSQL Global Development Group
*
* src/include/pg_getopt.h
*/
#ifndef PG_GETOPT_H
#define PG_GETOPT_H
/* POSIX says getopt() is provided by unistd.h */
#include <unistd.h>
/* rely on the system's getopt.h if present */
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
/*
* If we have <getopt.h>, assume it declares these variables, else do that
* ourselves. (We used to just declare them unconditionally, but Cygwin
* doesn't like that.)
*/
#ifndef HAVE_GETOPT_H
extern char *optarg;
extern int optind;
extern int opterr;
extern int optopt;
#ifdef HAVE_INT_OPTRESET
extern int optreset;
#endif
#endif /* HAVE_GETOPT_H */
#ifndef HAVE_GETOPT
extern int getopt(int nargc, char *const * nargv, const char *ostr);
#endif
#endif /* PG_GETOPT_H */
| /*
* Portions Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Portions Copyright (c) 2003-2014, PostgreSQL Global Development Group
*
* src/include/pg_getopt.h
*/
#ifndef PG_GETOPT_H
#define PG_GETOPT_H
/* POSIX says getopt() is provided by unistd.h */
#include <unistd.h>
/* rely on the system's getopt.h if present */
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
/*
* If we have <getopt.h>, assume it declares these variables, else do that
* ourselves. (We used to just declare them unconditionally, but Cygwin
* doesn't like that.)
*/
#ifndef HAVE_GETOPT_H
extern char *optarg;
extern int optind;
extern int opterr;
extern int optopt;
#endif /* HAVE_GETOPT_H */
/*
* Some platforms have optreset but not <getopt.h>. Cygwin, however,
* doesn't like this either.
*/
#if defined(HAVE_INT_OPTRESET) && !defined(__CYGWIN__)
extern int optreset;
#endif
#ifndef HAVE_GETOPT
extern int getopt(int nargc, char *const * nargv, const char *ostr);
#endif
#endif /* PG_GETOPT_H */
|
Switch song updater updateFrequency from NSTimeInterval (length of time) to NSUInteger (number of counter seconds to skip). | //
// FFMSongUpdater.h
// FringeFM
//
// Created by John Sheets on 6/10/12.
// Copyright (c) 2012 John Sheets. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@class FFMSong;
@interface FFMSongUpdater : NSObject
@property (nonatomic, strong) NSImage *icon;
@property (nonatomic) NSTimeInterval updateFrequency;
- (FFMSong *)fetchCurrentSong;
- (BOOL)isServiceAvailable;
- (BOOL)isServicePlaying;
@end
| //
// FFMSongUpdater.h
// FringeFM
//
// Created by John Sheets on 6/10/12.
// Copyright (c) 2012 John Sheets. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@class FFMSong;
@interface FFMSongUpdater : NSObject
@property (nonatomic, strong) NSImage *icon;
@property (nonatomic) NSUInteger updateFrequency;
- (FFMSong *)fetchCurrentSong;
- (BOOL)isServiceAvailable;
- (BOOL)isServicePlaying;
@end
|
Fix typo in header guard | #ifndef _ASM_IPCBUF_H_
#define _ASM_IPCBUF_H
/*
* The ipc64_perm structure for MN10300 architecture.
* Note extra padding because this structure is passed back and forth
* between kernel and user space.
*
* Pad space is left for:
* - 32-bit mode_t and seq
* - 2 miscellaneous 32-bit values
*/
struct ipc64_perm
{
__kernel_key_t key;
__kernel_uid32_t uid;
__kernel_gid32_t gid;
__kernel_uid32_t cuid;
__kernel_gid32_t cgid;
__kernel_mode_t mode;
unsigned short __pad1;
unsigned short seq;
unsigned short __pad2;
unsigned long __unused1;
unsigned long __unused2;
};
#endif /* _ASM_IPCBUF_H */
| #ifndef _ASM_IPCBUF_H
#define _ASM_IPCBUF_H
/*
* The ipc64_perm structure for MN10300 architecture.
* Note extra padding because this structure is passed back and forth
* between kernel and user space.
*
* Pad space is left for:
* - 32-bit mode_t and seq
* - 2 miscellaneous 32-bit values
*/
struct ipc64_perm
{
__kernel_key_t key;
__kernel_uid32_t uid;
__kernel_gid32_t gid;
__kernel_uid32_t cuid;
__kernel_gid32_t cgid;
__kernel_mode_t mode;
unsigned short __pad1;
unsigned short seq;
unsigned short __pad2;
unsigned long __unused1;
unsigned long __unused2;
};
#endif /* _ASM_IPCBUF_H */
|
Optimize counting size of larger sets | int set_empty(void)
{
return 0;
}
int set_size(int set)
{
int size = 0;
while (set)
{
size += set & 1;
set >>= 1;
}
return size;
}
int set_add(int set, int element)
{
return set | (1 << element);
}
| int set_empty(void)
{
return 0;
}
int set_size(int set)
{
/* Bit-Twiddling Hacks */
/* TODO: shall export to bits module to provide more robust solutions
* based on hardware capabilities (eg. popcount instruction) */
set = set - ((set >> 1) & ~(unsigned int)0/3);
set = (set & ~(unsigned int)0/15*3) + ((set >> 2) & ~(unsigned int)0/15*3);
set = (set + (set >> 4)) & ~(unsigned int)0/255*15;
return (set * (~(unsigned int)0/255)) >> (sizeof(int) - 1) * 8;
}
int set_add(int set, int element)
{
return set | (1 << element);
}
|
Make lockname(s) a macro instead of a inline. | #pragma once
#define SPINLOCK_DEBUG 1
// Mutual exclusion lock.
struct spinlock {
u32 locked; // Is the lock held?
#if SPINLOCK_DEBUG
// For debugging:
char *name; // Name of lock.
struct cpu *cpu; // The cpu holding the lock.
uptr pcs[10]; // The call stack (an array of program counters)
// that locked the lock.
#endif
};
static inline const char *lockname(struct spinlock *s)
{
#if SPINLOCK_DEBUG
return s->name ?: "null";
#else
return "unknown";
#endif
}
| #pragma once
#define SPINLOCK_DEBUG 1
// Mutual exclusion lock.
struct spinlock {
u32 locked; // Is the lock held?
#if SPINLOCK_DEBUG
// For debugging:
char *name; // Name of lock.
struct cpu *cpu; // The cpu holding the lock.
uptr pcs[10]; // The call stack (an array of program counters)
// that locked the lock.
#endif
};
#if SPINLOCK_DEBUG
#define lockname(s) ((s)->name ?: "null")
#else
#define lockname(s) ("unknown")
#endif
|
Call `clear` and `refresh` to update screen | #include "backend.h"
#include "frontend.h"
#include <ncurses.h>
int main() {
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE); // make keys work
curs_set(0); // hide cursor
timeout(100);
int xmax;
int ymax;
getmaxyx(stdscr, ymax, xmax);
enum Direction dir = RIGHT;
Board* board = create_board(create_snake(), NULL, xmax, ymax);
int i;
for (i = 0; i < 6; i++) {
add_new_food(board);
}
while(true) {
erase();
display_points(board->snake, ACS_BLOCK);
display_points(board->foods, ACS_DIAMOND);
dir = get_next_move(dir);
enum Status status = move_snake(board, dir);
if (status == FAILURE) break;
}
endwin();
return 0;
}
| #include "backend.h"
#include "frontend.h"
#include <ncurses.h>
int main() {
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE); // make keys work
curs_set(0); // hide cursor
timeout(100);
int xmax;
int ymax;
getmaxyx(stdscr, ymax, xmax);
enum Direction dir = RIGHT;
Board* board = create_board(create_snake(), NULL, xmax, ymax);
int i;
for (i = 0; i < 6; i++) {
add_new_food(board);
}
while(true) {
clear();
display_points(board->snake, ACS_BLOCK);
display_points(board->foods, ACS_DIAMOND);
refresh();
dir = get_next_move(dir);
enum Status status = move_snake(board, dir);
if (status == FAILURE) break;
}
endwin();
return 0;
}
|
Change config dir name to mrrcrypt | // Copyright (c) 2016 Brian Barto
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the MIT License. See LICENSE for more details.
#ifndef MAIN_H
#define MAIN_H 1
#define VERSION "0.1.0"
#define DEFAULT_KEY_NAME "default"
#define DEFAULT_KEY_PATH ".config/mirrorcrypt/"
#define GRID_SIZE 24
#define SUPPORTED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+{}[]|\\:; \n\t\"'<>,.?/~"
#endif
| // Copyright (c) 2016 Brian Barto
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the MIT License. See LICENSE for more details.
#ifndef MAIN_H
#define MAIN_H 1
#define VERSION "0.1.0"
#define DEFAULT_KEY_NAME "default"
#define DEFAULT_KEY_PATH ".config/mrrcrypt/"
#define GRID_SIZE 24
#define SUPPORTED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+{}[]|\\:; \n\t\"'<>,.?/~"
#endif
|
Add fake functions for hardware missing in english breakfast | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include "sw/device/silicon_creator/lib/drivers/lifecycle.h"
#include "sw/device/silicon_creator/lib/drivers/otp.h"
#include "sw/device/silicon_creator/lib/drivers/rstmgr.h"
// TODO(#12905): This file includes fake definitions for the functions that are
// used by the silicon_creator bootstrap implementation but missing in the
// english breakfast top level due to hardware limitations.
#if !OT_IS_ENGLISH_BREAKFAST
#error "This file should be compiled only for the english breakfast top level"
#endif
void lifecycle_hw_rev_get(lifecycle_hw_rev_t *hw_rev) {
*hw_rev = (lifecycle_hw_rev_t){
.chip_gen = 0,
.chip_rev = 0,
};
}
uint32_t otp_read32(uint32_t address) { return kHardenedBoolTrue; }
void rstmgr_reset(void) {
while (true) {
}
}
| |
Fix compilation on FreeBSD and OpenBSD | /*
* setup MY_BPFTIMEVAL as the timeval structure that bpf packets
* will be assoicated with packets from libpcap
*/
#ifdef __OpenBSD__
# define MY_BPFTIMEVAL bpf_timeval
#endif
#ifndef MY_BPFTIMEVAL
# define MY_BPFTIMEVAL timeval
#endif
typedef struct MY_BPFTIMEVAL my_bpftimeval;
/*
* Structure to contain IP addresses
*/
typedef struct {
int af;
union {
struct in_addr a4;
struct in6_addr a6;
} u;
} iaddr;
/*
* plugins can call the logerr() function in the main dnscap
* process.
*/
typedef int logerr_t(const char *fmt, ...);
/*
* Prototype for the plugin "output" function
*/
typedef void output_t(const char *descr,
iaddr from,
iaddr to,
uint8_t proto,
int isfrag,
unsigned sport,
unsigned dport,
my_bpftimeval ts,
const u_char *pkt_copy,
unsigned olen,
const u_char *dnspkt,
unsigned dnslen);
#define DIR_INITIATE 0x0001
#define DIR_RESPONSE 0x0002
| #include <netinet/in.h>
/*
* setup MY_BPFTIMEVAL as the timeval structure that bpf packets
* will be assoicated with packets from libpcap
*/
#ifndef MY_BPFTIMEVAL
# define MY_BPFTIMEVAL timeval
#endif
typedef struct MY_BPFTIMEVAL my_bpftimeval;
/*
* Structure to contain IP addresses
*/
typedef struct {
int af;
union {
struct in_addr a4;
struct in6_addr a6;
} u;
} iaddr;
/*
* plugins can call the logerr() function in the main dnscap
* process.
*/
typedef int logerr_t(const char *fmt, ...);
/*
* Prototype for the plugin "output" function
*/
typedef void output_t(const char *descr,
iaddr from,
iaddr to,
uint8_t proto,
int isfrag,
unsigned sport,
unsigned dport,
my_bpftimeval ts,
const u_char *pkt_copy,
unsigned olen,
const u_char *dnspkt,
unsigned dnslen);
#define DIR_INITIATE 0x0001
#define DIR_RESPONSE 0x0002
|
Fix missing declaration for ShapeInit() | /*
FreeRDP: A Remote Desktop Protocol client.
GDI Shape Functions
Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
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 __GDI_SHAPE_H
#define __GDI_SHAPE_H
#include "gdi.h"
int Ellipse(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
int Polygon(HDC hdc, POINT *lpPoints, int nCount);
int FillRect(HDC hdc, HRECT rect, HBRUSH hbr);
#endif /* __GDI_SHAPE_H */
| /*
FreeRDP: A Remote Desktop Protocol client.
GDI Shape Functions
Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
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 __GDI_SHAPE_H
#define __GDI_SHAPE_H
#include "gdi.h"
void ShapeInit();
int Ellipse(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
int Polygon(HDC hdc, POINT *lpPoints, int nCount);
int FillRect(HDC hdc, HRECT rect, HBRUSH hbr);
#endif /* __GDI_SHAPE_H */
|
Fix build warning for shadowed variable. | #include "support.h"
#include "vio/csync_vio_file_stat.h"
START_TEST (check_csync_vio_file_stat_new)
{
csync_vio_file_stat_t *stat = NULL;
stat = csync_vio_file_stat_new();
fail_if(stat == NULL, NULL);
csync_vio_file_stat_destroy(stat);
}
END_TEST
static Suite *csync_vio_suite(void) {
Suite *s = suite_create("csync_vio_file_stat");
create_case(s, "check_csync_vio_file_stat_new", check_csync_vio_file_stat_new);
return s;
}
int main(void) {
int nf;
Suite *s = csync_vio_suite();
SRunner *sr;
sr = srunner_create(s);
#if 0
srunner_set_fork_status(sr, CK_NOFORK);
#endif
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
| #include "support.h"
#include "vio/csync_vio_file_stat.h"
START_TEST (check_csync_vio_file_stat_new)
{
csync_vio_file_stat_t *tstat = NULL;
tstat = csync_vio_file_stat_new();
fail_if(tstat == NULL, NULL);
csync_vio_file_stat_destroy(tstat);
}
END_TEST
static Suite *csync_vio_suite(void) {
Suite *s = suite_create("csync_vio_file_stat");
create_case(s, "check_csync_vio_file_stat_new", check_csync_vio_file_stat_new);
return s;
}
int main(void) {
int nf;
Suite *s = csync_vio_suite();
SRunner *sr;
sr = srunner_create(s);
#if 0
srunner_set_fork_status(sr, CK_NOFORK);
#endif
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
|
Add `value` parameter to SOMAXCONN binding | #include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/custom.h>
#include <caml/callback.h>
#include <caml/alloc.h>
#include <stdio.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#endif
CAMLprim value stub_get_SOMAXCONN(){
fprintf(stderr, "SOMAXCONN = %d\n", SOMAXCONN);
return (Val_int (SOMAXCONN));
}
| #include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/custom.h>
#include <caml/callback.h>
#include <caml/alloc.h>
#include <stdio.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#endif
CAMLprim value stub_get_SOMAXCONN(value unit){
fprintf(stderr, "SOMAXCONN = %d\n", SOMAXCONN);
return (Val_int (SOMAXCONN));
}
|
Remove designated initializer compiler warnings | //
// AIBHTMLWebView.h
// AIBHTMLWebView
//
// Created by Thomas Parslow on 05/04/2015.
// Copyright (c) 2015 Thomas Parslow. MIT License.
//
#import "RCTView.h"
@class RCTEventDispatcher;
@interface AIBHTMLWebView : RCTView
@property (nonatomic, strong) NSString *HTML;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
@end | //
// AIBHTMLWebView.h
// AIBHTMLWebView
//
// Created by Thomas Parslow on 05/04/2015.
// Copyright (c) 2015 Thomas Parslow. MIT License.
//
#import "RCTView.h"
@class RCTEventDispatcher;
@interface AIBHTMLWebView : RCTView
@property (nonatomic, strong) NSString *HTML;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
@end |
Test the new width functionality | #pragma once
#include "Control.h"
#include "../../3RVX/Logger.h"
class Label : public Control {
public:
Label() {
}
Label(int id, HWND parent) :
Control(id, parent) {
}
virtual bool Text(std::wstring text) {
bool result = Control::Text(text);
if (result == false) {
return false;
}
/* Determine the width of the text */
HDC dc = GetDC(_hWnd);
SIZE sz = { 0 };
GetTextExtentPoint32(dc, &text[0], text.size(), &sz);
/* Update the window size based on the text size */
RECT r = Control::ScreenDimensions();
POINT pt = { r.left, r.top };
ScreenToClient(_parent, &pt);
MoveWindow(_hWnd, pt.x, pt.y, sz.cx, sz.cy, TRUE);
return true;
}
}; | #pragma once
#include "Control.h"
#include "../../3RVX/Logger.h"
class Label : public Control {
public:
Label() {
}
Label(int id, HWND parent) :
Control(id, parent) {
}
virtual bool Text(std::wstring text) {
bool result = Control::Text(text);
if (result == false) {
return false;
}
Width(TextDimensions().cx);
// /* Determine the width of the text */
// HDC dc = GetDC(_hWnd);
// SIZE sz = { 0 };
// GetTextExtentPoint32(dc, &text[0], text.size(), &sz);
// /* Update the window size based on the text size */
// RECT r = Control::ScreenDimensions();
// POINT pt = { r.left, r.top };
// ScreenToClient(_parent, &pt);
// MoveWindow(_hWnd, pt.x, pt.y, sz.cx, sz.cy, TRUE);
return true;
}
}; |
Fix missing void in parameterless call prototype | /*
* ccn/keystore.h
*
* KEYSTORE interface
*
* This is a veneer so that the ccn code can avoid exposure to the
* underlying keystore implementation types
*/
#ifndef CCN_KEYSTORE_DEFINED
#define CCN_KEYSTORE_DEFINED
#include <stddef.h>
struct ccn_keystore;
struct ccn_keystore *ccn_keystore_create();
void ccn_keystore_destroy(struct ccn_keystore **p);
int ccn_keystore_init(struct ccn_keystore *p, char *name, char *password);
const void *ccn_keystore_private_key(struct ccn_keystore *p);
const void *ccn_keystore_public_key(struct ccn_keystore *p);
const void *ccn_keystore_certificate(struct ccn_keystore *p);
#endif
| /*
* ccn/keystore.h
*
* KEYSTORE interface
*
* This is a veneer so that the ccn code can avoid exposure to the
* underlying keystore implementation types
*/
#ifndef CCN_KEYSTORE_DEFINED
#define CCN_KEYSTORE_DEFINED
#include <stddef.h>
struct ccn_keystore;
struct ccn_keystore *ccn_keystore_create(void);
void ccn_keystore_destroy(struct ccn_keystore **p);
int ccn_keystore_init(struct ccn_keystore *p, char *name, char *password);
const void *ccn_keystore_private_key(struct ccn_keystore *p);
const void *ccn_keystore_public_key(struct ccn_keystore *p);
const void *ccn_keystore_certificate(struct ccn_keystore *p);
#endif
|
Remove TODO test comment about OSTreeHash::Parse | #ifndef SOTA_CLIENT_TOOLS_OSTREE_HASH_H_
#define SOTA_CLIENT_TOOLS_OSTREE_HASH_H_
#include <cstdint>
#include <cstring> // memcmp, memcpy
#include <iostream>
#include <string>
class OSTreeHash {
public:
/**
* Parse an OSTree hash from a string. This will normally be a root commit.
* @throws OSTreeCommitParseError on invalid input
* TODO test cases
*/
static OSTreeHash Parse(const std::string& hash);
explicit OSTreeHash(const uint8_t[32]);
std::string string() const;
bool operator<(const OSTreeHash& other) const;
friend std::ostream& operator<<(std::ostream& os, const OSTreeHash& hash);
private:
uint8_t hash_[32];
};
class OSTreeCommitParseError : std::exception {
public:
OSTreeCommitParseError(const std::string bad_hash) : bad_hash_(bad_hash) {}
virtual const char* what() const noexcept { return "Could not parse OSTree commit"; }
std::string bad_hash() const { return bad_hash_; }
private:
std::string bad_hash_;
};
#endif // SOTA_CLIENT_TOOLS_OSTREE_HASH_H_
| #ifndef SOTA_CLIENT_TOOLS_OSTREE_HASH_H_
#define SOTA_CLIENT_TOOLS_OSTREE_HASH_H_
#include <cstdint>
#include <cstring> // memcmp, memcpy
#include <iostream>
#include <string>
class OSTreeHash {
public:
/**
* Parse an OSTree hash from a string. This will normally be a root commit.
* @throws OSTreeCommitParseError on invalid input
*/
static OSTreeHash Parse(const std::string& hash);
explicit OSTreeHash(const uint8_t[32]);
std::string string() const;
bool operator<(const OSTreeHash& other) const;
friend std::ostream& operator<<(std::ostream& os, const OSTreeHash& hash);
private:
uint8_t hash_[32];
};
class OSTreeCommitParseError : std::exception {
public:
OSTreeCommitParseError(const std::string bad_hash) : bad_hash_(bad_hash) {}
virtual const char* what() const noexcept { return "Could not parse OSTree commit"; }
std::string bad_hash() const { return bad_hash_; }
private:
std::string bad_hash_;
};
#endif // SOTA_CLIENT_TOOLS_OSTREE_HASH_H_
|
Fix a memory leak in tests | /*
* Copyright © 2009 CNRS
* Copyright © 2009-2010 INRIA
* Copyright © 2009-2010 Université Bordeaux 1
* See COPYING in top-level directory.
*/
#include <private/config.h>
#include <hwloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
int main(void)
{
hwloc_topology_t topology;
hwloc_bitmap_t cpuset;
hwloc_obj_t obj;
hwloc_topology_init(&topology);
hwloc_topology_load(topology);
hwloc_topology_check(topology);
cpuset = hwloc_bitmap_alloc();
hwloc_bitmap_set(cpuset, 0);
obj = hwloc_topology_insert_misc_object_by_cpuset(topology, cpuset, "test");
hwloc_topology_insert_misc_object_by_parent(topology, obj, "test2");
hwloc_topology_check(topology);
hwloc_topology_destroy(topology);
return 0;
}
| /*
* Copyright © 2009 CNRS
* Copyright © 2009-2010 INRIA
* Copyright © 2009-2010 Université Bordeaux 1
* See COPYING in top-level directory.
*/
#include <private/config.h>
#include <hwloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
int main(void)
{
hwloc_topology_t topology;
hwloc_bitmap_t cpuset;
hwloc_obj_t obj;
hwloc_topology_init(&topology);
hwloc_topology_load(topology);
hwloc_topology_check(topology);
cpuset = hwloc_bitmap_alloc();
hwloc_bitmap_set(cpuset, 0);
obj = hwloc_topology_insert_misc_object_by_cpuset(topology, cpuset, "test");
hwloc_bitmap_free(cpuset);
hwloc_topology_insert_misc_object_by_parent(topology, obj, "test2");
hwloc_topology_check(topology);
hwloc_topology_destroy(topology);
return 0;
}
|
Add include so we get a prototype for syscall() | #include <sys/types.h>
#include <linux/unistd.h>
#include <gettid.h>
#include <errno.h>
/* Patch from Adam Conrad / Ubuntu: Don't use _syscall macro */
#ifdef __NR_gettid
pid_t gettid (void)
{
return syscall(__NR_gettid);
}
#else
#warn "gettid not available -- substituting with pthread_self()"
#include <pthread.h>
pid_t gettid (void)
{
return (pid_t)pthread_self();
}
#endif
| #include <sys/types.h>
#include <linux/unistd.h>
#include <gettid.h>
#include <unistd.h>
#include <errno.h>
/* Patch from Adam Conrad / Ubuntu: Don't use _syscall macro */
#ifdef __NR_gettid
pid_t gettid (void)
{
return syscall(__NR_gettid);
}
#else
#warn "gettid not available -- substituting with pthread_self()"
#include <pthread.h>
pid_t gettid (void)
{
return (pid_t)pthread_self();
}
#endif
|
Use a class instead of a struct | /*ckwg +5
* Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef VISTK_PYTHON_HELPERS_PYTHON_CONVERT_ANY_H
#define VISTK_PYTHON_HELPERS_PYTHON_CONVERT_ANY_H
#include <boost/any.hpp>
#include <Python.h>
/**
* \file python_convert_any.h
*
* \brief Helpers for working with boost::any in Python.
*/
namespace boost
{
namespace python
{
namespace converter
{
struct rvalue_from_python_stage1_data;
}
}
}
struct boost_any_to_object
{
boost_any_to_object();
~boost_any_to_object();
static void* convertible(PyObject* obj);
static PyObject* convert(boost::any const& any);
static void construct(PyObject* obj, boost::python::converter::rvalue_from_python_stage1_data* data);
};
#endif // VISTK_PYTHON_PIPELINE_PYTHON_CONVERT_ANY_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_PYTHON_HELPERS_PYTHON_CONVERT_ANY_H
#define VISTK_PYTHON_HELPERS_PYTHON_CONVERT_ANY_H
#include <boost/any.hpp>
#include <Python.h>
/**
* \file python_convert_any.h
*
* \brief Helpers for working with boost::any in Python.
*/
namespace boost
{
namespace python
{
namespace converter
{
struct rvalue_from_python_stage1_data;
}
}
}
class boost_any_to_object
{
public:
boost_any_to_object();
~boost_any_to_object();
static void* convertible(PyObject* obj);
static PyObject* convert(boost::any const& any);
static void construct(PyObject* obj, boost::python::converter::rvalue_from_python_stage1_data* data);
};
#endif // VISTK_PYTHON_PIPELINE_PYTHON_CONVERT_ANY_H
|
Handle reserved true/false variable names | /* BLACK color, which I presume was defined in graphics.h */
#define BLACK 0
| /* BLACK color, which I presume was defined in the original graphics.h */
#define BLACK 0
/*
All my original cpp files create constant ints named true and
false. This worked with the Borland C++ compiler, but not gcc.
I'll redefine them with a preprocessor macro to be a non-reserved
name, but first I need to include all the system libraries because
they may refer to the actual true/false variables.
*/
#include <alloc.h>
#include <assert.h>
#include <conio.h>
#include <ctype.h>
#include <dos.h>
#include <fstream.h>
#include <stdlib.h>
#include <time.h>
/* Now redefine true/false with non-reserved names */
#define true local_true
#define false local_false
|
Stop using console in demo ROM | // GBT Player v3.0.9
//
// SPDX-License-Identifier: MIT
//
// Copyright (c) 2022, Antonio Niño Díaz <antonio_nd@outlook.com>
#include <gba.h>
#include <stdio.h>
#include "gbt_player.h"
extern const uint8_t *template_data[];
int main(int argc, char *argv[])
{
irqInit();
irqEnable(IRQ_VBLANK);
consoleDemoInit();
iprintf("GBT Player v3.0.9");
gbt_play(template_data, 5);
while (1)
{
VBlankIntrWait();
gbt_update();
}
}
| // GBT Player v3.0.9
//
// SPDX-License-Identifier: MIT
//
// Copyright (c) 2022, Antonio Niño Díaz <antonio_nd@outlook.com>
#include <gba.h>
#include "gbt_player.h"
extern const uint8_t *template_data[];
int main(int argc, char *argv[])
{
irqInit();
irqEnable(IRQ_VBLANK);
gbt_play(template_data, 5);
while (1)
{
VBlankIntrWait();
gbt_update();
}
}
|
Modify the prototype of IFDOpenIFD. | /*
* This wraps the dynamic ifdhandler functions. The abstraction will
* eventually allow multiple card slots in the same terminal.
*
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
*
* Copyright (C) 1999
* David Corcoran <corcoran@linuxnet.com>
*
* $Id$
*/
#ifndef __ifdwrapper_h__
#define __ifdwrapper_h__
#ifdef __cplusplus
extern "C"
{
#endif
LONG IFDOpenIFD(PREADER_CONTEXT, DWORD);
LONG IFDCloseIFD(PREADER_CONTEXT);
LONG IFDPowerICC(PREADER_CONTEXT, DWORD, PUCHAR, PDWORD);
LONG IFDStatusICC(PREADER_CONTEXT, PDWORD, PDWORD, PUCHAR, PDWORD);
LONG IFDControl(PREADER_CONTEXT, PUCHAR, DWORD, PUCHAR, PDWORD);
LONG IFDTransmit(PREADER_CONTEXT, SCARD_IO_HEADER,
PUCHAR, DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER);
LONG IFDSetPTS(PREADER_CONTEXT, DWORD, UCHAR, UCHAR, UCHAR, UCHAR);
LONG IFDSetCapabilities(PREADER_CONTEXT, DWORD, DWORD, PUCHAR);
LONG IFDGetCapabilities(PREADER_CONTEXT, DWORD, PDWORD, PUCHAR);
#ifdef __cplusplus
}
#endif
#endif /* __ifdwrapper_h__ */
| /*
* This wraps the dynamic ifdhandler functions. The abstraction will
* eventually allow multiple card slots in the same terminal.
*
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
*
* Copyright (C) 1999
* David Corcoran <corcoran@linuxnet.com>
*
* $Id$
*/
#ifndef __ifdwrapper_h__
#define __ifdwrapper_h__
#ifdef __cplusplus
extern "C"
{
#endif
LONG IFDOpenIFD(PREADER_CONTEXT);
LONG IFDCloseIFD(PREADER_CONTEXT);
LONG IFDPowerICC(PREADER_CONTEXT, DWORD, PUCHAR, PDWORD);
LONG IFDStatusICC(PREADER_CONTEXT, PDWORD, PDWORD, PUCHAR, PDWORD);
LONG IFDControl(PREADER_CONTEXT, PUCHAR, DWORD, PUCHAR, PDWORD);
LONG IFDTransmit(PREADER_CONTEXT, SCARD_IO_HEADER,
PUCHAR, DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER);
LONG IFDSetPTS(PREADER_CONTEXT, DWORD, UCHAR, UCHAR, UCHAR, UCHAR);
LONG IFDSetCapabilities(PREADER_CONTEXT, DWORD, DWORD, PUCHAR);
LONG IFDGetCapabilities(PREADER_CONTEXT, DWORD, PDWORD, PUCHAR);
#ifdef __cplusplus
}
#endif
#endif /* __ifdwrapper_h__ */
|
Synchronize the mailbox after expunging messages to actually get them expunged. | /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
| /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
else if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
|
Fix bug in dequeue that caused to return always false | #pragma once
#include <mutex>
#include <queue>
// Thread safe implementation of a Queue using a std::queue
template <typename T>
class SafeQueue {
private:
std::queue<T> m_queue;
std::mutex m_mutex;
public:
SafeQueue() {
}
SafeQueue(SafeQueue& other) {
//TODO:
}
~SafeQueue() {
}
bool empty() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_queue.empty();
}
int size() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_queue.size();
}
void enqueue(T& t) {
std::unique_lock<std::mutex> lock(m_mutex);
m_queue.push(t);
}
bool dequeue(T& t) {
std::unique_lock<std::mutex> lock(m_mutex);
if (m_queue.empty()) {
return false;
}
t = std::move(m_queue.front());
m_queue.pop();
}
}; | #pragma once
#include <mutex>
#include <queue>
// Thread safe implementation of a Queue using a std::queue
template <typename T>
class SafeQueue {
private:
std::queue<T> m_queue;
std::mutex m_mutex;
public:
SafeQueue() {
}
SafeQueue(SafeQueue& other) {
//TODO:
}
~SafeQueue() {
}
bool empty() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_queue.empty();
}
int size() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_queue.size();
}
void enqueue(T& t) {
std::unique_lock<std::mutex> lock(m_mutex);
m_queue.push(t);
}
bool dequeue(T& t) {
std::unique_lock<std::mutex> lock(m_mutex);
if (m_queue.empty()) {
return false;
}
t = std::move(m_queue.front());
m_queue.pop();
return true;
}
}; |
Add a ServerProofVerifier interface to QUIC. | // Copyright (c) 2020 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 QUICHE_QUIC_CORE_CRYPTO_SERVER_PROOF_VERIFIER_H_
#define QUICHE_QUIC_CORE_CRYPTO_SERVER_PROOF_VERIFIER_H_
#include <memory>
#include <string>
#include <vector>
#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
namespace quic {
// A ServerProofVerifier checks the certificate chain presented by a client.
class QUIC_EXPORT_PRIVATE ServerProofVerifier {
public:
virtual ~ServerProofVerifier() {}
// VerifyCertChain checks that |certs| is a valid chain. On success, it
// returns QUIC_SUCCESS. On failure, it returns QUIC_FAILURE and sets
// |*error_details| to a description of the problem. In either case it may set
// |*details|, which the caller takes ownership of.
//
// |context| specifies an implementation specific struct (which may be nullptr
// for some implementations) that provides useful information for the
// verifier, e.g. logging handles.
//
// This function may also return QUIC_PENDING, in which case the
// ServerProofVerifier will call back, on the original thread, via |callback|
// when complete. In this case, the ServerProofVerifier will take ownership of
// |callback|.
virtual QuicAsyncStatus VerifyCertChain(
const std::vector<std::string>& certs,
std::string* error_details,
std::unique_ptr<ProofVerifierCallback> callback) = 0;
};
} // namespace quic
#endif // QUICHE_QUIC_CORE_CRYPTO_SERVER_PROOF_VERIFIER_H_
| |
Include glib.h as it uses g* datatypes Added for gnome-config | #ifndef _GDK_PIXBUF_H_
#define _GDK_PIXBUF_H_
#include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_pixbuf.h>
typedef struct {
int ref_count;
ArtPixBuf *art_pixbuf;
void (*unref_func)(void *gdkpixbuf);
} GdkPixBuf;
GdkPixBuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
void gdk_pixbuf_ref (GdkPixBuf *pixbuf);
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
GdkPixBuf *gdk_pixbuf_duplicate (GdkPixBuf *pixbuf);
GdkPixBuf *gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h);
GdkPixBuf *gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle);
void gdk_pixbuf_destroy (GdkPixBuf *pixbuf);
#endif /* _GDK_PIXBUF_H_ */
| #ifndef _GDK_PIXBUF_H_
#define _GDK_PIXBUF_H_
#include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_pixbuf.h>
#include <glib.h>
typedef struct {
int ref_count;
ArtPixBuf *art_pixbuf;
void (*unref_func)(void *gdkpixbuf);
} GdkPixBuf;
GdkPixBuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
void gdk_pixbuf_ref (GdkPixBuf *pixbuf);
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
GdkPixBuf *gdk_pixbuf_duplicate (GdkPixBuf *pixbuf);
GdkPixBuf *gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h);
GdkPixBuf *gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle);
void gdk_pixbuf_destroy (GdkPixBuf *pixbuf);
#endif /* _GDK_PIXBUF_H_ */
|
Add nodiscard to ErrorMessage and ErrorMessageOr | // Copyright (c) 2020 The Orbit 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 ORBIT_BASE_RESULT_H_
#define ORBIT_BASE_RESULT_H_
#include <string>
#include <type_traits>
#include "outcome.hpp"
class ErrorMessage final {
public:
ErrorMessage() = default;
explicit ErrorMessage(std::string message) : message_(std::move(message)) {}
[[nodiscard]] const std::string& message() const { return message_; }
private:
std::string message_;
};
template <typename T, typename E>
using Result = outcome::result<T, E, outcome::policy::terminate>;
template <typename T>
class ErrorMessageOr : public Result<T, ErrorMessage> {
public:
using Result<T, ErrorMessage>::Result;
operator bool() = delete;
operator bool() const = delete;
};
template <typename T>
struct IsErrorMessageOr : std::false_type {};
template <typename T>
struct IsErrorMessageOr<ErrorMessageOr<T>> : std::true_type {};
#endif // ORBIT_BASE_RESULT_H_
| // Copyright (c) 2020 The Orbit 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 ORBIT_BASE_RESULT_H_
#define ORBIT_BASE_RESULT_H_
#include <string>
#include <type_traits>
#include "outcome.hpp"
class [[nodiscard]] ErrorMessage final {
public:
ErrorMessage() = default;
explicit ErrorMessage(std::string message) : message_(std::move(message)) {}
[[nodiscard]] const std::string& message() const { return message_; }
private:
std::string message_;
};
template <typename T, typename E>
using Result = outcome::result<T, E, outcome::policy::terminate>;
template <typename T>
class [[nodiscard]] ErrorMessageOr : public Result<T, ErrorMessage> {
public:
using Result<T, ErrorMessage>::Result;
operator bool() = delete;
operator bool() const = delete;
};
template <typename T>
struct IsErrorMessageOr : std::false_type {};
template <typename T>
struct IsErrorMessageOr<ErrorMessageOr<T>> : std::true_type {};
#endif // ORBIT_BASE_RESULT_H_
|
Test new cursor functionality now implemented in the c1p runtime library. | /*
* Challenger 1P Hello World Program for cc65.
*/
#include <conio.h>
int main(void)
{
static const char hello_world[] =
"Hello world!\r\ncc65 for Challenger 1P";
unsigned int i;
clrscr();
gotoxy(0, 0);
cputs(hello_world);
gotoxy(0, 4);
for (i = 0; i < 256; i += 1) {
if (i != '\n' && i != '\r') {
cputc((unsigned char ) i);
}
}
cputsxy(0, 14, "cputsxy\r\n");
cprintf("cprintf '%s' %d %d\r\n", "string", (int) wherex(), (int) wherey());
cputs("now type something:\r\n");
while (1) {
char c = cgetc();
cputc(c);
}
return 0;
}
| /*
* Challenger 1P Hello World Program for cc65.
*/
#include <conio.h>
int main(void)
{
static const char hello_world[] =
"Hello world!\r\ncc65 for Challenger 1P";
unsigned int i;
clrscr();
/* TODO this should be implicitly done in clrscr() */
gotoxy(0, 0);
cputs(hello_world);
gotoxy(0, 4);
for (i = 0; i < 0x20; i += 1) {
if (i != '\n' && i != '\r') {
cputc((unsigned char ) i);
}
}
cputsxy(0, 8, "cputsxy\r\n");
cprintf("cprintf '%s' %d %d\r\n", "string", (int) wherex(), (int) wherey());
cputs("now type something (vi keys for positioning, "
"'A' cursor on, 'B' cursor off):\r\n");
/* cursor on */
cursor(1);
while (1) {
unsigned char const xpos = wherex();
unsigned char const ypos = wherey();
char const c = cgetc();
/* Test cursor on/off and cursor positioning */
switch (c) {
case 'A':
cursor(1);
break;
case 'B':
cursor(0);
break;
case 'H':
if (xpos > 0) {
gotox(xpos - 1);
}
break;
case 'L':
if (xpos < 24) {
gotox(xpos + 1);
}
break;
case 'K':
if (ypos > 0) {
gotoy(ypos - 1);
}
break;
case 'J':
if (ypos < 24) {
gotoy(ypos + 1);
}
break;
default:
cputc(c);
break;
}
}
return 0;
}
|
Make the cast operator inline for use with CUDA | /*! \file TextureHandle.h
* \author Jared Hoberock
* \brief Defines the interface to an opaque
* pointer type for Textures.
*/
#pragma once
#include <string>
typedef unsigned int TextureHandle;
struct TextureParameter
{
inline TextureParameter(void)
:mHandle(0),mAlias(""){}
inline TextureParameter(const std::string &alias)
:mHandle(0),mAlias(alias){}
inline TextureParameter(const TextureHandle &h)
:mHandle(h),mAlias(""){}
operator TextureHandle (void) const {return mHandle;}
TextureHandle mHandle;
// filename or other alias for a Texture to use during shading
// if this is not '' during preprocess, the texture referred to
// by this alias will be loaded and bound
std::string mAlias;
}; // end TextureParameter
| /*! \file TextureHandle.h
* \author Jared Hoberock
* \brief Defines the interface to an opaque
* pointer type for Textures.
*/
#pragma once
#include <string>
typedef unsigned int TextureHandle;
struct TextureParameter
{
inline TextureParameter(void)
:mHandle(0),mAlias(""){}
inline TextureParameter(const std::string &alias)
:mHandle(0),mAlias(alias){}
inline TextureParameter(const TextureHandle &h)
:mHandle(h),mAlias(""){}
inline operator TextureHandle (void) const {return mHandle;}
TextureHandle mHandle;
// filename or other alias for a Texture to use during shading
// if this is not '' during preprocess, the texture referred to
// by this alias will be loaded and bound
std::string mAlias;
}; // end TextureParameter
|
Make timer ID's start with 1 | /* Copyright (C) 2011-2012 Zeex
*
* 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 <sampgdk/config.h>
#include <sampgdk/a_samp.h>
#include <sampgdk/export.h>
#include "fakeamx.h"
#include "native.h"
#include "timer.h"
#include "generated/a_samp-impl.c"
SAMPGDK_NATIVE(int, SetTimer(int interval, bool repeat, TimerCallback callback, void *param)) {
int timerid;
if (timer_set(&timerid, interval, repeat, (timer_callback)callback, param) >= 0) {
return timerid;
}
return -1;
}
SAMPGDK_NATIVE(bool, KillTimer(int timerid)) {
return timer_kill(timerid) >= 0;
}
| /* Copyright (C) 2011-2012 Zeex
*
* 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 <sampgdk/config.h>
#include <sampgdk/a_samp.h>
#include <sampgdk/export.h>
#include "fakeamx.h"
#include "native.h"
#include "timer.h"
#include "generated/a_samp-impl.c"
SAMPGDK_NATIVE(int, SetTimer(int interval, bool repeat, TimerCallback callback, void *param)) {
int timerid;
if (timer_set(&timerid, interval, repeat, (timer_callback)callback, param) >= 0) {
return timerid + 1;
}
return 0;
}
SAMPGDK_NATIVE(bool, KillTimer(int timerid)) {
return timer_kill(timerid - 1) >= 0;
}
|
Fix a stray -Winconsistent-missing-override warning. |
/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDump_DEFINED
#define SkDump_DEFINED
#include "SkDisplayable.h"
#include "SkMemberInfo.h"
class SkAnimateMaker;
class SkString;
class SkDump : public SkDisplayable {
DECLARE_MEMBER_INFO(Dump);
#ifdef SK_DUMP_ENABLED
SkDump();
bool enable(SkAnimateMaker & ) override;
bool evaluate(SkAnimateMaker &);
bool hasEnable() const override;
static void GetEnumString(SkDisplayTypes , int index, SkString* result);
SkBool displayList;
SkBool eventList;
SkBool events;
SkString name;
SkBool groups;
SkBool posts;
SkString script;
#else
virtual bool enable(SkAnimateMaker & );
virtual bool hasEnable() const;
virtual bool setProperty(int index, SkScriptValue& );
#endif
};
#endif // SkDump_DEFINED
|
/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDump_DEFINED
#define SkDump_DEFINED
#include "SkDisplayable.h"
#include "SkMemberInfo.h"
class SkAnimateMaker;
class SkString;
class SkDump : public SkDisplayable {
DECLARE_MEMBER_INFO(Dump);
#ifdef SK_DUMP_ENABLED
SkDump();
bool enable(SkAnimateMaker & ) override;
bool evaluate(SkAnimateMaker &);
bool hasEnable() const override;
static void GetEnumString(SkDisplayTypes , int index, SkString* result);
SkBool displayList;
SkBool eventList;
SkBool events;
SkString name;
SkBool groups;
SkBool posts;
SkString script;
#else
bool enable(SkAnimateMaker & ) override;
bool hasEnable() const override;
bool setProperty(int index, SkScriptValue& ) override;
#endif
};
#endif // SkDump_DEFINED
|
Add first token, current_symbol and function prototypes | #ifndef OCELOT2_SCANNER_H
#define OCELOT2_SCANNER_H
void get_symbol();
#endif // OCELOT2_SCANNER_H
| #ifndef OCELOT2_SCANNER_H
#define OCELOT2_SCANNER_H
/**
* Tokens
*/
int T_EOF;
int current_symbol;
void scanner_init();
void scanner_token_init();
void scanner_get_symbol();
#endif // OCELOT2_SCANNER_H
|
Make PRECONDITION usable in isolation by compile time define PRECON. | #ifndef __DEBUG_H
#define __DEBUG_H
#ifdef DEBUG
extern bool debug;
extern bool debug_z;
#define DBG if (debug)
#define MSG(x) DBG msg x
#define PRECONDITION(x) if (x); else precondition( #x , __FILE__, __LINE__)
#else
#define DBG if (0)
#define MSG(x)
#define PRECONDITION(x) // nothing
#endif
#endif
| #ifndef __DEBUG_H
#define __DEBUG_H
#ifdef DEBUG
extern bool debug;
extern bool debug_z;
#define DBG if (debug)
#define MSG(x) DBG msg x
#else
#define DBG if (0)
#define MSG(x)
#endif
#if defined(DEBUG) || defined(PRECON)
#define PRECONDITION(x) if (x); else precondition( #x , __FILE__, __LINE__)
#else
#define PRECONDITION(x) // nothing
#endif
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.