Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add timing and formating for times | #include "stdio.h"
#include "stdlib.h"
#define TRIALS 4
#define MATRIX_SIZE 2048
short A[MATRIX_SIZE][MATRIX_SIZE],
B[MATRIX_SIZE][MATRIX_SIZE],
C[MATRIX_SIZE][MATRIX_SIZE] = {{0}};
int main(int argc, char* argv[])
{
// Initalize array A and B with '1's
for (int i = 0; i < MATRIX_SIZE; ++i)
for (int k = 0; k < MATRIX_SIZE; ++k)
A[i][k] = B[i][k] = 1;
// Iterate through the block sizes
for (int block_size = 4; block_size <= 256; block_size *= 2)
{
// Run TRIALS number of trials for each block size
for (int trial = 0; trial < TRIALS; ++trial)
{
printf("size: %d\n", block_size);
}
}
return 0;
}
| #include "stdio.h"
#include "stdlib.h"
#include "sys/time.h"
#define TRIALS 4
#define MATRIX_SIZE 2048
short A[MATRIX_SIZE][MATRIX_SIZE],
B[MATRIX_SIZE][MATRIX_SIZE],
C[MATRIX_SIZE][MATRIX_SIZE] = {{0}};
int main(int argc, char* argv[])
{
// Initalize array A and B with '1's
for (int i = 0; i < MATRIX_SIZE; ++i)
for (int k = 0; k < MATRIX_SIZE; ++k)
A[i][k] = B[i][k] = 1;
// Show headings
for (int trial = 0; trial < TRIALS; ++trial)
printf(" run%d ,", trial);
puts(" avrg ");
// Iterate through the block sizes
for (int block_size = 4; block_size <= 256; block_size *= 2)
{
// Keep track of the times for this block
time_t block_times[TRIALS];
// Run TRIALS number of trials for each block size
for (int trial = 0; trial < TRIALS; ++trial)
{
struct timeval time_start;
gettimeofday(&time_start, NULL);
// Do work..
struct timeval time_end;
gettimeofday(&time_end, NULL);
// Keep track of the time to do statistics on
block_times[trial] = time_end.tv_usec - time_start.tv_usec;
printf("%06d,", (int) block_times[trial]);
}
int average = 0;
for (int i = 0; i < TRIALS; ++i)
average += (int) block_times[i];
printf("%06d\n", average / TRIALS);
}
return 0;
}
|
Solve a bug with line endings | /* INCLUDES */
#include <stdio.h>
#include "commands.h"
#define MAX_MSG_LENGTH 200 //For the receiving frame... (circular buffer)
int main(int argc, char *argv[]) {
char input_buffer[MAX_MSG_LENGTH];
int input_argc;
char *input_argv[CMD_MAX_N_OPTIONS+CMD_MAX_N_OPTIONS_WITH_ARGS];
int i;
char command_available = 0;
if (argc > 1) {
execute_command(argc-1, &argv[1]);
} else {
while (TRUE) {
// Terminal prompt
printf("\n> ");
// Terminal input
fgets(input_buffer, MAX_MSG_LENGTH-3, stdin);
// Detect end of the command
for (i=0; input_buffer[i]; i++) {
if (input_buffer[i] == '\n' || input_buffer[i] == '\r')
input_buffer[i] = 0;
command_available = 1;
}
if (command_available) {
// Get the command and the arguments in a list
input_argc = separate_args(input_buffer, input_argv);
// Execute the command
if (input_argc) execute_command(input_argc, input_argv);
command_available = 0;
}
}
}
return 0;
}
| /* INCLUDES */
#include <stdio.h>
#include "commands.h"
#define MAX_MSG_LENGTH 200 //For the receiving frame... (circular buffer)
int main(int argc, char *argv[]) {
char input_buffer[MAX_MSG_LENGTH];
int input_argc;
char *input_argv[CMD_MAX_N_OPTIONS+CMD_MAX_N_OPTIONS_WITH_ARGS];
int i;
char command_available = 0;
if (argc > 1) {
execute_command(argc-1, &argv[1]);
} else {
while (TRUE) {
// Terminal prompt
printf("\n> ");
// Terminal input
fgets(input_buffer, MAX_MSG_LENGTH-3, stdin);
// Detect end of the command
for (i=0; input_buffer[i]; i++) {
if (input_buffer[i] == '\n' || input_buffer[i] == '\r') {}
input_buffer[i] = 0;
command_available = 1;
}
}
if (command_available) {
// Get the command and the arguments in a list
input_argc = separate_args(input_buffer, input_argv);
// Execute the command
if (input_argc) execute_command(input_argc, input_argv);
command_available = 0;
}
}
}
return 0;
}
|
Remove all chars from s2 in s1 O(n) | #include <limits.h>
#include <stdio.h>
#include <errno.h>
/* K&R C (Dennis M. Ritchie & Brian W. Kernighan)
Exercise 2-4. Write an alternative version of squeeze(s1,s2)
that deletes each character in s1 that matches any character
in the string s2.
*/
// O(n) solution
int Squeeze(char* s1, const char* s2) {
if (!s1 || !s2) {
errno = EINVAL;
return EINVAL;
}
// dictionary for O(1) char lookup
int chars[UCHAR_MAX] = { 0 };
// save chars in s2 to the dictionary
const char* pchar2 = &s2[0];
while (*pchar2) {
chars[(unsigned char)(*pchar2)] = 1;
++pchar2;
}
char* pchar0 = &s1[0];
char* pchar1 = &s1[0];
while (*pchar1) {
// do not be tempted to move ++pchar1 out of the if-else
// blocks, if you do, make sure you test pchar1 for zero
// char and break out on zero char immediately or else
// you will go past the end of the string corrupting
// memory as you go
if (chars[(unsigned char)(*pchar1)]) {
++pchar1;
} else {
*pchar0 = *pchar1;
++pchar0;
++pchar1;
}
}
*pchar0 = '\0';
return 0;
}
int main(void) {
char s1[] = "C provides six operators for bit manipulation;"
"these may only be applied to integral operands,"
"that is, char, short, int, and long, whether signed or unsigned.";
const char* s2 = "aeiou";
// remove vowels
Squeeze(s1, s2);
printf("%s\n", s1);
getchar();
return 0;
}
| |
UPDATE Uncommented door variables for reacting | #ifndef SSPAPPLICATION_ENTITIES_DOORENTITY_H
#define SSPAPPLICATION_ENTITIES_DOORENTITY_H
#include "Entity.h"
#include <vector>
class DoorEntity :
public Entity
{
private:
/*struct ElementState {
int entityID;
EVENT desiredState;
bool desiredStateReached;
};
std::vector<ElementState> m_elementStates;*/
bool m_isOpened;
float m_minRotation;
float m_maxRotation;
float m_rotateTime;
float m_rotatePerSec;
public:
DoorEntity();
virtual ~DoorEntity();
int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp, float rotateTime = 1.0f, float minRotation = 0.0f, float maxRotation = DirectX::XM_PI / 2.0f);
int Update(float dT, InputHandler* inputHandler);
int React(int entityID, EVENT reactEvent);
bool SetIsOpened(bool isOpened);
bool GetIsOpened();
};
#endif | #ifndef SSPAPPLICATION_ENTITIES_DOORENTITY_H
#define SSPAPPLICATION_ENTITIES_DOORENTITY_H
#include "Entity.h"
#include <vector>
class DoorEntity :
public Entity
{
private:
struct ElementState {
int entityID;
EVENT desiredState;
bool desiredStateReached;
};
std::vector<ElementState> m_elementStates;
bool m_isOpened;
float m_minRotation;
float m_maxRotation;
float m_rotateTime;
float m_rotatePerSec;
public:
DoorEntity();
virtual ~DoorEntity();
int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp, float rotateTime = 1.0f, float minRotation = 0.0f, float maxRotation = DirectX::XM_PI / 2.0f);
int Update(float dT, InputHandler* inputHandler);
int React(int entityID, EVENT reactEvent);
bool SetIsOpened(bool isOpened);
bool GetIsOpened();
};
#endif |
Add C implementation for problem 1 | #include <stdio.h>
#define LIST_SIZE 1000
int divisible_by(int x, int y){
return x % y == 0;
}
int sum_multiples_of(int n1, int n2){
int list[LIST_SIZE], i, s;
s = 0;
for(i = 0; i < LIST_SIZE; i++){
if(divisible_by(i, n1) == 1 || divisible_by(i, n2) == 1){
list[i] = i;
s += i;
}
}
return s;
}
int main(int argc, char *argv[]){
printf("%d\n", sum_multiples_of(3, 5));
}
| |
Switch to 32bit indices for gui rendering |
#pragma once
#include <ionMath.h>
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
#define IM_VEC2_CLASS_EXTRA \
ImVec2(const ion::vec2f& f) { x = f.X; y = f.Y; } \
operator ion::vec2f() const { return ion::vec2f(x,y); }
#define IM_VEC4_CLASS_EXTRA \
ImVec4(const ion::vec4f& f) { x = f.X; y = f.Y; z = f.Z; w = f.W; } \
operator ion::vec4f() const { return ion::vec4f(x,y,z,w); }
#include <imgui.h>
|
#pragma once
#include <ionCore.h>
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
#define IM_VEC2_CLASS_EXTRA \
ImVec2(const ion::vec2f& f) { x = f.X; y = f.Y; } \
operator ion::vec2f() const { return ion::vec2f(x,y); }
#define IM_VEC4_CLASS_EXTRA \
ImVec4(const ion::vec4f& f) { x = f.X; y = f.Y; z = f.Z; w = f.W; } \
operator ion::vec4f() const { return ion::vec4f(x,y,z,w); }
//---- Use 32-bit vertex indices (instead of default: 16-bit) to allow meshes with more than 64K vertices
#define ImDrawIdx unsigned int
#include <imgui.h>
|
Allow use of inline keyword in c++/c99 mode. | /* Copyright 2013 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Common types
*/
#ifndef BROTLI_DEC_TYPES_H_
#define BROTLI_DEC_TYPES_H_
#include <stddef.h> /* for size_t */
#ifndef _MSC_VER
#include <inttypes.h>
#ifdef __STRICT_ANSI__
#define BROTLI_INLINE
#else /* __STRICT_ANSI__ */
#define BROTLI_INLINE inline
#endif
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef long long int int64_t;
#define BROTLI_INLINE __forceinline
#endif /* _MSC_VER */
#endif /* BROTLI_DEC_TYPES_H_ */
| /* Copyright 2013 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Common types
*/
#ifndef BROTLI_DEC_TYPES_H_
#define BROTLI_DEC_TYPES_H_
#include <stddef.h> /* for size_t */
#ifndef _MSC_VER
#include <inttypes.h>
#if defined(__cplusplus) || !defined(__STRICT_ANSI__) \
|| __STDC_VERSION__ >= 199901L
#define BROTLI_INLINE inline
#else
#define BROTLI_INLINE
#endif
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef long long int int64_t;
#define BROTLI_INLINE __forceinline
#endif /* _MSC_VER */
#endif /* BROTLI_DEC_TYPES_H_ */
|
Build Tools: Moved special test flags into -spec | /**
* Copyright (c) 2015 Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __COMMON_SPECIAL_TEST_H
#define __COMMON_SPECIAL_TEST_H
/* Special tests always require GPIO handshaking */
#if (defined _SPECIAL_TEST) && !(defined __HANDSHAKE)
#define _HANDSHAKE 1
#endif
/*
* Special test identifiers for bootrom testing:
*/
/* Allow 3rd stage FW to try to put the chip into standby. */
#define SPECIAL_STANDBY_TEST 1
/*
* STANDBY_TEST plus 3rd stage FW waits for the server to put UniPro to
* hibern8 mode before suspend
* */
#define SPECIAL_GBBOOT_SERVER_STANDBY 2
/* Run the SpiRom at different gear speeds */
#define SPECIAL_GEAR_CHANGE_TEST 3
#endif /* __COMMON_SPECIAL_TEST_H */
| |
Fix compile warning of hash_map in OS X | #ifndef BERRY_COMMON_COMMON_H
#define BERRY_COMMON_COMMON_H
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if ANGEL_MOBILE
#include <sys/time.h>
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iPhone SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#else
#include <CoreFoundation/CoreFoundation.h>
#endif
#else
#ifndef __OBJC__
#include <CoreFoundation/CoreFoundation.h>
#endif
#endif
#endif
#if defined(__APPLE__) || defined(__linux__)
#include <ext/hash_map>
//GCC is picky about what types are allowed to be used as indices to hashes.
// Defining this here lets us use std::strings to index, which is useful.
#define hashmap_ns __gnu_cxx
namespace hashmap_ns
{
template<> struct hash< std::string >
{
size_t operator()( const std::string& x ) const
{
return hash< const char* >()( x.c_str() );
}
};
}
#endif
#endif
| #ifndef BERRY_COMMON_COMMON_H
#define BERRY_COMMON_COMMON_H
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if ANGEL_MOBILE
#include <sys/time.h>
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iPhone SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#else
#include <CoreFoundation/CoreFoundation.h>
#endif
#else
#ifndef __OBJC__
#include <CoreFoundation/CoreFoundation.h>
#endif
#endif
#endif
#if defined(__APPLE__)
#include <unordered_map>
#elif defined(__linux__)
#include <ext/hash_map>
//GCC is picky about what types are allowed to be used as indices to hashes.
// Defining this here lets us use std::strings to index, which is useful.
#define hashmap_ns __gnu_cxx
namespace hashmap_ns
{
template<> struct hash< std::string >
{
size_t operator()( const std::string& x ) const
{
return hash< const char* >()( x.c_str() );
}
};
}
#endif
#endif
|
Switch to NS_ASSUME_NONNULL_BEGIN and _END | ///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
///
#import <Foundation/Foundation.h>
#import "DBHandlerTypes.h"
///
/// Keychain class for storing OAuth tokens.
///
@interface DBSDKKeychain : NSObject
/// Stores a key / value pair in the keychain.
+ (BOOL)storeValueWithKey:(NSString * _Nonnull)key value:(NSString * _Nonnull)value;
/// Retrieves a value from the corresponding key from the keychain.
+ (NSString * _Nullable)retrieveTokenWithKey:(NSString * _Nonnull)key;
/// Retrieves all token uids from the keychain.
+ (NSArray<NSString *> * _Nonnull)retrieveAllTokenIds;
/// Deletes a key / value pair in the keychain.
+ (BOOL)deleteTokenWithKey:(NSString * _Nonnull)key;
/// Deletes all key / value pairs in the keychain.
+ (BOOL)clearAllTokens;
/// Checks if performing a v1 token migration is necessary, and if so, performs it.
+ (BOOL)checkAndPerformV1TokenMigration:(DBTokenMigrationResponseBlock _Nonnull)responseBlock
queue:(NSOperationQueue * _Nullable)queue
appKey:(NSString * _Nonnull)appKey
appSecret:(NSString * _Nonnull)appSecret;
@end
| ///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
///
#import <Foundation/Foundation.h>
#import "DBHandlerTypes.h"
NS_ASSUME_NONNULL_BEGIN
///
/// Keychain class for storing OAuth tokens.
///
@interface DBSDKKeychain : NSObject
/// Stores a key / value pair in the keychain.
+ (BOOL)storeValueWithKey:(NSString *)key value:(NSString *)value;
/// Retrieves a value from the corresponding key from the keychain.
+ (NSString * _Nullable)retrieveTokenWithKey:(NSString *)key;
/// Retrieves all token uids from the keychain.
+ (NSArray<NSString *> *)retrieveAllTokenIds;
/// Deletes a key / value pair in the keychain.
+ (BOOL)deleteTokenWithKey:(NSString *)key;
/// Deletes all key / value pairs in the keychain.
+ (BOOL)clearAllTokens;
/// Checks if performing a v1 token migration is necessary, and if so, performs it.
+ (BOOL)checkAndPerformV1TokenMigration:(DBTokenMigrationResponseBlock)responseBlock
queue:(NSOperationQueue * _Nullable)queue
appKey:(NSString *)appKey
appSecret:(NSString *)appSecret;
@end
NS_ASSUME_NONNULL_END
|
Fix missing string in namespace std compiler error | #ifndef WINDOW_H
#define WINDOW_H
#include <ncurses.h>
#include <array>
#include "../game.h"
// Used to define a datatype for calls to wborder
struct Border {
chtype ls, rs, ts, bs;
chtype tl, tr, bl, br;
};
class Window {
public:
Window(rect dim); // ctor
~Window(); // dtor
void bindWin(WINDOW *newW);
int getChar();
void refresh();
void update();
void clear();
void close();
void cursorPos(vec2ui pos);
void draw(vec2ui pos, char ch, chtype colo);
void draw(vec2ui pos, char ch, chtype colo, int attr);
void drawBorder();
void drawBox();
void write(std::string str);
void write(vec2ui pos, std::string str);
void coloSplash(chtype colo);
rect getDim() { return dim; }
void setBorder(Border b);
protected:
WINDOW *w;
rect dim;
Border border { 0,0,0,0,0,0,0,0 }; // Init to default
};
#endif
| #ifndef WINDOW_H
#define WINDOW_H
#include <ncurses.h>
#include <string>
#include <array>
#include "../game.h"
// Used to define a datatype for calls to wborder
struct Border {
chtype ls, rs, ts, bs;
chtype tl, tr, bl, br;
};
class Window {
public:
Window(rect dim); // ctor
~Window(); // dtor
void bindWin(WINDOW *newW);
int getChar();
void refresh();
void update();
void clear();
void close();
void cursorPos(vec2ui pos);
void draw(vec2ui pos, char ch, chtype colo);
void draw(vec2ui pos, char ch, chtype colo, int attr);
void drawBorder();
void drawBox();
void write(std::string str);
void write(vec2ui pos, std::string str);
void coloSplash(chtype colo);
rect getDim() { return dim; }
void setBorder(Border b);
protected:
WINDOW *w;
rect dim;
Border border { 0,0,0,0,0,0,0,0 }; // Init to default
};
#endif
|
Test case for transparent PTH support. | // RUN: cp %s %t &&
// RUN: xcc -x c-header %t -o %t.pth &&
// RUN: xcc -### -S -include %t -x c /dev/null &> %t.log &&
// RUN: grep '"-token-cache" ".*/pth.c.out.tmp.pth"' %t.log
// RUN: true
| |
Move layoutMargin method and Frame method to public interface of UIView additions category. (mostly for testing purposes and those method should be public IMO anyway) | //
// UIView+CLUViewRecordableAdditions.h
// Clue
//
// Created by Ahmed Sulaiman on 5/27/16.
// Copyright © 2016 Ahmed Sulaiman. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CLUViewRecordableProperties.h"
@interface UIView (CLUViewRecordableAdditions) <CLUViewRecordableProperties>
- (NSDictionary *)clue_colorPropertyDictionaryForColor:(UIColor *)color;
- (NSDictionary *)clue_sizePropertyDictionaryForSize:(CGSize)size;
- (NSDictionary *)clue_fontPropertyDictionaryForFont:(UIFont *)font;
- (NSDictionary *)clue_attributedTextPropertyDictionaryForAttributedString:(NSAttributedString *)attributedText;
@end
| //
// UIView+CLUViewRecordableAdditions.h
// Clue
//
// Created by Ahmed Sulaiman on 5/27/16.
// Copyright © 2016 Ahmed Sulaiman. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CLUViewRecordableProperties.h"
@interface UIView (CLUViewRecordableAdditions) <CLUViewRecordableProperties>
- (NSDictionary *)clue_colorPropertyDictionaryForColor:(UIColor *)color;
- (NSDictionary *)clue_sizePropertyDictionaryForSize:(CGSize)size;
- (NSDictionary *)clue_fontPropertyDictionaryForFont:(UIFont *)font;
- (NSDictionary *)clue_attributedTextPropertyDictionaryForAttributedString:(NSAttributedString *)attributedText;
- (NSDictionary *)clue_layoutMarginsPropertyDictionary;
- (NSDictionary *)clue_frameProprtyDictionary;
@end
|
Remove no longer used SkipEncodingUnusedStreams. | /*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_EXPERIMENTS_H_
#define WEBRTC_EXPERIMENTS_H_
#include "webrtc/typedefs.h"
namespace webrtc {
struct RemoteBitrateEstimatorMinRate {
RemoteBitrateEstimatorMinRate() : min_rate(30000) {}
RemoteBitrateEstimatorMinRate(uint32_t min_rate) : min_rate(min_rate) {}
uint32_t min_rate;
};
struct SkipEncodingUnusedStreams {
SkipEncodingUnusedStreams() : enabled(false) {}
explicit SkipEncodingUnusedStreams(bool set_enabled)
: enabled(set_enabled) {}
virtual ~SkipEncodingUnusedStreams() {}
const bool enabled;
};
struct AimdRemoteRateControl {
AimdRemoteRateControl() : enabled(false) {}
explicit AimdRemoteRateControl(bool set_enabled)
: enabled(set_enabled) {}
virtual ~AimdRemoteRateControl() {}
const bool enabled;
};
} // namespace webrtc
#endif // WEBRTC_EXPERIMENTS_H_
| /*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_EXPERIMENTS_H_
#define WEBRTC_EXPERIMENTS_H_
#include "webrtc/typedefs.h"
namespace webrtc {
struct RemoteBitrateEstimatorMinRate {
RemoteBitrateEstimatorMinRate() : min_rate(30000) {}
RemoteBitrateEstimatorMinRate(uint32_t min_rate) : min_rate(min_rate) {}
uint32_t min_rate;
};
struct AimdRemoteRateControl {
AimdRemoteRateControl() : enabled(false) {}
explicit AimdRemoteRateControl(bool set_enabled)
: enabled(set_enabled) {}
virtual ~AimdRemoteRateControl() {}
const bool enabled;
};
} // namespace webrtc
#endif // WEBRTC_EXPERIMENTS_H_
|
Implement + support in numbers | #pragma once
#include <string>
#include "Program.h"
#include "ThingInstance.h"
class NumberInstance : public ThingInstance {
public:
NumberInstance(int val) : val(val), ThingInstance(NumberInstance::methods) {};
virtual std::string text() const override {
return std::to_string(val);
}
const int val;
static const std::vector<InternalMethod> methods;
};
| #pragma once
#include <string>
#include "Program.h"
#include "ThingInstance.h"
class NumberInstance : public ThingInstance {
public:
NumberInstance(int val) : val(val), ThingInstance(NumberInstance::methods) {};
virtual std::string text() const override {
return std::to_string(val);
}
static void add() {
auto lhs = static_cast<NumberInstance*>(Program::pop().get());
auto rhs = static_cast<NumberInstance*>(Program::pop().get());
auto ptr = PThingInstance(new NumberInstance(lhs->val + rhs->val));
Program::push(ptr);
}
const int val;
static const std::vector<InternalMethod> methods;
};
|
Make the member variables of MDx_HashFunction private instead of protected - no subclass needs access to any of these variables. | /**
* MDx Hash Function
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_MDX_BASE_H__
#define BOTAN_MDX_BASE_H__
#include <botan/hash.h>
namespace Botan {
/**
* MDx Hash Function Base Class
*/
class BOTAN_DLL MDx_HashFunction : public HashFunction
{
public:
MDx_HashFunction(u32bit, u32bit, bool, bool, u32bit = 8);
virtual ~MDx_HashFunction() {}
protected:
void clear() throw();
SecureVector<byte> buffer;
u64bit count;
u32bit position;
private:
void add_data(const byte[], u32bit);
void final_result(byte output[]);
virtual void compress_n(const byte block[], u32bit block_n) = 0;
virtual void copy_out(byte[]) = 0;
virtual void write_count(byte[]);
const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN;
const u32bit COUNT_SIZE;
};
}
#endif
| /**
* MDx Hash Function
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_MDX_BASE_H__
#define BOTAN_MDX_BASE_H__
#include <botan/hash.h>
namespace Botan {
/**
* MDx Hash Function Base Class
*/
class BOTAN_DLL MDx_HashFunction : public HashFunction
{
public:
MDx_HashFunction(u32bit, u32bit, bool, bool, u32bit = 8);
virtual ~MDx_HashFunction() {}
protected:
void add_data(const byte[], u32bit);
void final_result(byte output[]);
virtual void compress_n(const byte block[], u32bit block_n) = 0;
void clear() throw();
virtual void copy_out(byte[]) = 0;
virtual void write_count(byte[]);
private:
SecureVector<byte> buffer;
u64bit count;
u32bit position;
const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN;
const u32bit COUNT_SIZE;
};
}
#endif
|
Add file that should have been in r223027 | //===---- MipsABIInfo.h - Information about MIPS ABI's --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MIPSABIINFO_H
#define MIPSABIINFO_H
namespace llvm {
class MipsABIInfo {
public:
enum class ABI { Unknown, O32, N32, N64, EABI };
protected:
ABI ThisABI;
public:
MipsABIInfo(ABI ThisABI) : ThisABI(ThisABI) {}
static MipsABIInfo Unknown() { return MipsABIInfo(ABI::Unknown); }
static MipsABIInfo O32() { return MipsABIInfo(ABI::O32); }
static MipsABIInfo N32() { return MipsABIInfo(ABI::N32); }
static MipsABIInfo N64() { return MipsABIInfo(ABI::N64); }
static MipsABIInfo EABI() { return MipsABIInfo(ABI::EABI); }
bool IsKnown() const { return ThisABI != ABI::Unknown; }
bool IsO32() const { return ThisABI == ABI::O32; }
bool IsN32() const { return ThisABI == ABI::N32; }
bool IsN64() const { return ThisABI == ABI::N64; }
bool IsEABI() const { return ThisABI == ABI::EABI; }
ABI GetEnumValue() const { return ThisABI; }
/// Ordering of ABI's
/// MipsGenSubtargetInfo.inc will use this to resolve conflicts when given
/// multiple ABI options.
bool operator<(const MipsABIInfo Other) const {
return ThisABI < Other.GetEnumValue();
}
};
}
#endif
| |
Add remote array classes to headers. | //
// SVNetworking.h
// SVNetworking
//
// Created by Nate Stedman on 3/14/14.
// Copyright (c) 2014 Svpply. All rights reserved.
//
#import "NSObject+SVBindings.h"
#import "NSObject+SVMultibindings.h"
#import "SVDataRequest.h"
#import "SVDiskCache.h"
#import "SVFunctional.h"
#import "SVImageView.h"
#import "SVJSONRequest.h"
#import "SVRemoteImage.h"
#import "SVRemoteImageProtocol.h"
#import "SVRemoteDataRequestResource.h"
#import "SVRemoteDataResource.h"
#import "SVRemoteJSONRequestResource.h"
#import "SVRemoteJSONResource.h"
#import "SVRemoteProxyResource.h"
#import "SVRemoteResource.h"
#import "SVRemoteRetainedScaledImage.h"
#import "SVRemoteScaledImage.h"
#import "SVRemoteScaledImageProtocol.h"
#import "SVRequest.h"
| //
// SVNetworking.h
// SVNetworking
//
// Created by Nate Stedman on 3/14/14.
// Copyright (c) 2014 Svpply. All rights reserved.
//
#import "NSObject+SVBindings.h"
#import "NSObject+SVMultibindings.h"
#import "SVDataRequest.h"
#import "SVDiskCache.h"
#import "SVFunctional.h"
#import "SVImageView.h"
#import "SVJSONRequest.h"
#import "SVRemoteArray.h"
#import "SVRemoteImage.h"
#import "SVRemoteImageProtocol.h"
#import "SVRemoteDataRequestResource.h"
#import "SVRemoteDataResource.h"
#import "SVRemoteJSONArray.h"
#import "SVRemoteJSONRequestResource.h"
#import "SVRemoteJSONResource.h"
#import "SVRemoteProxyResource.h"
#import "SVRemoteResource.h"
#import "SVRemoteRetainedScaledImage.h"
#import "SVRemoteScaledImage.h"
#import "SVRemoteScaledImageProtocol.h"
#import "SVRequest.h"
|
Apply HAVE_CONFIG_H condition in src/tests/uiomux_test.h | /*
* UIOMux: a conflict manager for system resources, including UIO devices.
* Copyright (C) 2009 Renesas Technology Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#define INFO(str) \
{ printf ("---- %s ...\n", (str)); }
#define WARN(str) \
{ printf ("%s:%d: warning: %s\n", __FILE__, __LINE__, (str)); }
#define FAIL(str) \
{ printf ("%s:%d: %s\n", __FILE__, __LINE__, (str)); exit(1); }
| /*
* UIOMux: a conflict manager for system resources, including UIO devices.
* Copyright (C) 2009 Renesas Technology Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#define INFO(str) \
{ printf ("---- %s ...\n", (str)); }
#define WARN(str) \
{ printf ("%s:%d: warning: %s\n", __FILE__, __LINE__, (str)); }
#define FAIL(str) \
{ printf ("%s:%d: %s\n", __FILE__, __LINE__, (str)); exit(1); }
|
Change K_32 const value to more readable (with floating point) | #include <stdio.h>
float K_5_BY_9 = 5.0 / 9.0;
float K_32 = 32;
int SUCCESS = 0;
int main(void)
{
float fahrenheit, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
printf("|-----------|\n");
printf("|%4s|%6s|\n", "F", "C");
printf("|-----------|\n");
fahrenheit = lower;
while (fahrenheit <= upper) {
celsius = K_5_BY_9 * (fahrenheit - K_32);
printf("|%4.0f|%6.1f|\n", fahrenheit, celsius);
fahrenheit = fahrenheit + step;
}
printf("|-----------|\n");
return SUCCESS;
}
| #include <stdio.h>
float K_5_BY_9 = 5.0 / 9.0;
float K_32 = 32.0;
int SUCCESS = 0;
int main(void)
{
float fahrenheit, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
printf("|-----------|\n");
printf("|%4s|%6s|\n", "F", "C");
printf("|-----------|\n");
fahrenheit = lower;
while (fahrenheit <= upper) {
celsius = K_5_BY_9 * (fahrenheit - K_32);
printf("|%4.0f|%6.1f|\n", fahrenheit, celsius);
fahrenheit = fahrenheit + step;
}
printf("|-----------|\n");
return SUCCESS;
}
|
Add Sha1 class methods digest() and size() | // LAF Base Library
// Copyright (c) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef BASE_SHA1_H_INCLUDED
#define BASE_SHA1_H_INCLUDED
#pragma once
#include <vector>
#include <string>
extern "C" struct SHA1Context;
namespace base {
class Sha1 {
public:
enum { HashSize = 20 };
Sha1();
explicit Sha1(const std::vector<uint8_t>& digest);
// Calculates the SHA1 of the given file or string.
static Sha1 calculateFromFile(const std::string& fileName);
static Sha1 calculateFromString(const std::string& text);
bool operator==(const Sha1& other) const;
bool operator!=(const Sha1& other) const;
uint8_t operator[](int index) const {
return m_digest[index];
}
private:
std::vector<uint8_t> m_digest;
};
} // namespace base
#endif // BASE_SHA1_H_INCLUDED
| // LAF Base Library
// Copyright (c) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef BASE_SHA1_H_INCLUDED
#define BASE_SHA1_H_INCLUDED
#pragma once
#include <vector>
#include <string>
extern "C" struct SHA1Context;
namespace base {
class Sha1 {
public:
enum { HashSize = 20 };
Sha1();
explicit Sha1(const std::vector<uint8_t>& digest);
// Calculates the SHA1 of the given file or string.
static Sha1 calculateFromFile(const std::string& fileName);
static Sha1 calculateFromString(const std::string& text);
bool operator==(const Sha1& other) const;
bool operator!=(const Sha1& other) const;
uint8_t operator[](int index) const {
return m_digest[index];
}
const uint8_t *digest() const {
return m_digest.data();
}
size_t size() const {
return m_digest.size();
}
private:
std::vector<uint8_t> m_digest;
};
} // namespace base
#endif // BASE_SHA1_H_INCLUDED
|
Define NSS_3_4 so that we get the right code and not Stan code that isn't quite ready. | /* Defines common to all versions of NSS */
#define NSPR20 1
#define MP_API_COMPATIBLE 1
| /* Defines common to all versions of NSS */
#define NSPR20 1
#define MP_API_COMPATIBLE 1
#define NSS_3_4_CODE 1 /* Remove this when we start building NSS 4.0 by default */ |
Update Skia milestone to 52 | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 51
#endif
| /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 52
#endif
|
Add random_trunc function, which truncates (with integer modulus) instead of scaling (with floating point divide and multiply) the base random number. | #ifndef MISC__H__
#define MISC__H__
#include <sysdeps.h>
extern void random_init(uint32 seed);
extern uint32 random_int(void);
#define random_float() (random_int() * (double)(1.0/4294967296.0))
#define random_scale(S) ((unsigned int)(random_float() * (S)))
unsigned long strtou(const char* str, const char** end);
const char* utoa(unsigned long);
char* utoa2(unsigned long, char*);
#endif
| #ifndef MISC__H__
#define MISC__H__
#include <sysdeps.h>
extern void random_init(uint32 seed);
extern uint32 random_int(void);
#define random_float() (random_int() * (double)(1.0/4294967296.0))
#define random_scale(S) ((unsigned int)(random_float() * (S)))
#define random_trunc(T) (random_int() % (T))
unsigned long strtou(const char* str, const char** end);
const char* utoa(unsigned long);
char* utoa2(unsigned long, char*);
#endif
|
Add a private header for user-provided dom libs | /* Egueb_Dom - DOM
* Copyright (C) 2011 - 2013 Jorge Luis Zapata
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _EGUEB_DOM_PRIVATE_H
#define _EGUEB_DOM_PRIVATE_H
/* This file is subject of ABI/API change, use at your own risk
* It is needed in case a lib wants to inherit from the different
* DOM interfaces
*/
#include "private/egueb_dom_node_private.h"
#include "private/egueb_dom_element_private.h"
#include "private/egueb_dom_document_private.h"
#endif
| |
Make sure that the copy of the string is always null terminated | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 "port_sysencoding.h"
#include <string.h>
int port_get_utf8_converted_system_message_length(char *system_message)
{
return strlen(system_message) + 1;
}
void port_convert_system_error_message_to_utf8(char *converted_message,
int buffer_size,
char *system_message)
{
strncpy(converted_message, system_message, buffer_size - 1);
}
| /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 "port_sysencoding.h"
#include <string.h>
int port_get_utf8_converted_system_message_length(char *system_message)
{
return strlen(system_message) + 1;
}
void port_convert_system_error_message_to_utf8(char *converted_message,
int buffer_size,
char *system_message)
{
strncpy(converted_message, system_message, buffer_size - 1);
converted_message[buffer_size - 1] = '\0';
}
|
Remove double underscore from include guard. | /*=========================================================================
Program: DICOM for VTK
Copyright (c) 2012-2015 David Gobbi
All rights reserved.
See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef __readquery_h
#define __readquery_h
#include "vtkDICOMItem.h"
#include "vtkDICOMTagPath.h"
#include <vector>
typedef std::vector<vtkDICOMTagPath> QueryTagList;
//! Read a query file, return 'true' on success.
/*!
* The query file is read into the supplied vtkDICOMItem as a set of
* attribute values. If the ordering within the file is important,
* then a QueryTagList can also be provided. The tags will be pushed
* onto the QueryTagList in the same order as they are encountered in
* the file.
*/
bool dicomcli_readquery(
const char *fname, vtkDICOMItem *query, QueryTagList *ql=0);
//! Read a single query key, return 'true' on success.
bool dicomcli_readkey(
const char *key, vtkDICOMItem *query, QueryTagList *ql=0);
#endif /* __readquery_h */
| /*=========================================================================
Program: DICOM for VTK
Copyright (c) 2012-2015 David Gobbi
All rights reserved.
See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef readquery_h
#define readquery_h
#include "vtkDICOMItem.h"
#include "vtkDICOMTagPath.h"
#include <vector>
typedef std::vector<vtkDICOMTagPath> QueryTagList;
//! Read a query file, return 'true' on success.
/*!
* The query file is read into the supplied vtkDICOMItem as a set of
* attribute values. If the ordering within the file is important,
* then a QueryTagList can also be provided. The tags will be pushed
* onto the QueryTagList in the same order as they are encountered in
* the file.
*/
bool dicomcli_readquery(
const char *fname, vtkDICOMItem *query, QueryTagList *ql=0);
//! Read a single query key, return 'true' on success.
bool dicomcli_readkey(
const char *key, vtkDICOMItem *query, QueryTagList *ql=0);
#endif /* readquery_h */
|
Test for struct return-by-value, both caller and callee | // RUN: %ocheck 0 %s
struct A
{
int x, y, z;
int e, f;
};
void clobber_args()
{
}
struct A f(void)
{
clobber_args(0, 1, 2); // clobber the stret pointer
return (struct A){ 1, 2, 3, 4, 5};
}
int main()
{
struct A a;
a = f();
if(a.x != 1
|| a.y != 2
|| a.z != 3
|| a.e != 4
|| a.f != 5)
{
abort();
}
return 0;
}
| |
Adjust declared types of llair intrinsics | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <stdbool.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* allocation that cannot fail */
void* __llair_alloc(unsigned size);
/* non-deterministic choice */
int __llair_choice();
/* executions that call __llair_unreachable are assumed to be impossible */
__attribute__((noreturn)) void __llair_unreachable();
/* assume a condition */
#define __llair_assume(condition) \
if (!(condition)) \
__llair_unreachable()
/* throw an exception */
__attribute__((noreturn)) void __llair_throw(void* thrown_exception);
/* glibc version */
#define __assert_fail(assertion, file, line, function) abort()
/* macos version */
#define __assert_rtn(function, file, line, assertion) abort()
/*
* threads
*/
typedef int thread_t;
typedef int (*thread_create_routine)(void*);
thread_t sledge_thread_create(thread_create_routine entry, void* arg);
void sledge_thread_resume(thread_t thread);
int sledge_thread_join(thread_t thread);
/*
* cct
*/
void cct_point(void);
#ifdef __cplusplus
}
#endif
| /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <stdbool.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* allocation that cannot fail */
void* __llair_alloc(long size);
/* non-deterministic choice */
long __llair_choice();
/* executions that call __llair_unreachable are assumed to be impossible */
__attribute__((noreturn)) void __llair_unreachable();
/* assume a condition */
#define __llair_assume(condition) \
if (!(condition)) \
__llair_unreachable()
/* throw an exception */
__attribute__((noreturn)) void __llair_throw(void* thrown_exception);
/* glibc version */
#define __assert_fail(assertion, file, line, function) abort()
/* macos version */
#define __assert_rtn(function, file, line, assertion) abort()
/*
* threads
*/
typedef int thread_t;
typedef int (*thread_create_routine)(void*);
thread_t sledge_thread_create(thread_create_routine entry, void* arg);
void sledge_thread_resume(thread_t thread);
int sledge_thread_join(thread_t thread);
/*
* cct
*/
void cct_point(void);
#ifdef __cplusplus
}
#endif
|
Add explaining comment for path property. | //
// FileObject.h
// arc
//
// Created by Jerome Cheng on 19/3/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface FileObject : NSObject {
@protected
NSURL* _url;
id _contents;
BOOL _needsRefresh;
}
// The name of this object.
@property (strong, nonatomic) NSString* name;
// The full file path of this object.
@property (strong, nonatomic) NSString* path;
// The parent of this object (if any.)
@property (weak, nonatomic) FileObject* parent;
// Creates a FileObject to represent the given URL.
// url should be an object on the file system.
- (id)initWithURL:(NSURL*)url;
// Creates a FileObject to represent the given URL,
// with its parent set to the given FileObject.
- (id)initWithURL:(NSURL*)url parent:(FileObject*)parent;
// Refreshes the contents of this object by reloading
// them from the file system.
// Returns the contents when done.
- (id)refreshContents;
// Flags this object as needing its contents refreshed.
- (void)flagForRefresh;
// Gets the contents of this object.
- (id)getContents;
// Removes this object from the file system.
// Returns YES if successful, NO otherwise.
- (BOOL)remove;
@end
| //
// FileObject.h
// arc
//
// Created by Jerome Cheng on 19/3/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface FileObject : NSObject {
@protected
NSURL* _url;
id _contents;
BOOL _needsRefresh;
}
// The name of this object.
@property (strong, nonatomic) NSString* name;
// The full file path of this object. Can be used
// to recreate an NSURL.
@property (strong, nonatomic) NSString* path;
// The parent of this object (if any.)
@property (weak, nonatomic) FileObject* parent;
// Creates a FileObject to represent the given URL.
// url should be an object on the file system.
- (id)initWithURL:(NSURL*)url;
// Creates a FileObject to represent the given URL,
// with its parent set to the given FileObject.
- (id)initWithURL:(NSURL*)url parent:(FileObject*)parent;
// Refreshes the contents of this object by reloading
// them from the file system.
// Returns the contents when done.
- (id)refreshContents;
// Flags this object as needing its contents refreshed.
- (void)flagForRefresh;
// Gets the contents of this object.
- (id)getContents;
// Removes this object from the file system.
// Returns YES if successful, NO otherwise.
- (BOOL)remove;
@end
|
Include "setjmp_i.h". Abstract ia64-specific code into bsp_match() routine. Support any platform with at least 2 EH argument registers. | /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
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. */
#define UNW_LOCAL_ONLY
#include <assert.h>
#include <libunwind.h>
#include <setjmp.h>
#include <signal.h>
#include <stdlib.h>
#include "jmpbuf.h"
#include "setjmp_i.h"
void
_longjmp (jmp_buf env, int val)
{
extern int _UI_longjmp_cont;
unw_context_t uc;
unw_cursor_t c;
unw_word_t sp;
unw_word_t *wp = (unw_word_t *) env;
if (unw_getcontext (&uc) < 0 || unw_init_local (&c, &uc) < 0)
abort ();
do
{
if (unw_get_reg (&c, UNW_REG_SP, &sp) < 0)
abort ();
if (sp != wp[JB_SP])
continue;
if (!bsp_match (&c, wp))
continue;
/* found the right frame: */
assert (UNW_NUM_EH_REGS >= 2);
if (unw_set_reg (&c, UNW_REG_EH + 0, wp[JB_RP]) < 0
|| unw_set_reg (&c, UNW_REG_EH + 1, val) < 0
|| unw_set_reg (&c, UNW_REG_IP,
(unw_word_t) &_UI_longjmp_cont))
abort ();
unw_resume (&c);
abort ();
}
while (unw_step (&c) >= 0);
abort ();
}
#ifdef __GNUC__
void longjmp (jmp_buf env, int val) __attribute__ ((alias ("_longjmp")));
#else
void
longjmp (jmp_buf env, int val)
{
_longjmp (env, val);
}
#endif
| |
Fix this on the bots and make the test more complete by enabling optimizations. | // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
extern void foo_alias (void) __asm ("foo");
inline void foo (void) {
return foo_alias ();
}
extern void bar_alias (void) __asm ("bar");
inline __attribute__ ((__always_inline__)) void bar (void) {
return bar_alias ();
}
void f(void) {
foo();
bar();
}
// CHECK: define void @f()
// CHECK-NEXT: entry:
// CHECK-NEXT: call void @foo()
// CHECK-NEXT: call void @bar()
// CHECK-NEXT: ret void
// CHECK: declare void @foo()
// CHECK: declare void @bar()
| // RUN: %clang_cc1 -emit-llvm %s -O1 -o - | FileCheck %s
extern void foo_alias (void) __asm ("foo");
inline void foo (void) {
return foo_alias ();
}
extern void bar_alias (void) __asm ("bar");
inline __attribute__ ((__always_inline__)) void bar (void) {
return bar_alias ();
}
void f(void) {
foo();
bar();
}
// CHECK: define void @f()
// CHECK: call void @foo()
// CHECK-NEXT: call void @bar()
// CHECK-NEXT: ret void
// CHECK: declare void @foo()
// CHECK: declare void @bar()
|
Add a triple to try to fix the buildbot error. | // RUN: clang-cc -fsyntax-only -verify %s
typedef int i128 __attribute__((__mode__(TI)));
typedef unsigned u128 __attribute__((__mode__(TI)));
int a[((i128)-1 ^ (i128)-2) == 1 ? 1 : -1];
int a[(u128)-1 > 1LL ? 1 : -1];
// PR5435
__uint128_t b = (__uint128_t)-1;
| // RUN: clang-cc -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
typedef int i128 __attribute__((__mode__(TI)));
typedef unsigned u128 __attribute__((__mode__(TI)));
int a[((i128)-1 ^ (i128)-2) == 1 ? 1 : -1];
int a[(u128)-1 > 1LL ? 1 : -1];
// PR5435
__uint128_t b = (__uint128_t)-1;
|
Standardize on nonnull attribute (vs __nonnull__) | //
// DMNotificationObserver.h
// Library
//
// Created by Jonathon Mah on 2011-07-11.
// Copyright 2011 Delicious Monster Software. All rights reserved.
//
#import <Foundation/Foundation.h>
/* The action block is passed the notification, the owner as a parameter (to avoid retain cycles),
* and the triggering observer (so it can easiliy invalidate it if it needs to). */
@class DMNotificationObserver;
typedef void(^DMNotificationActionBlock)(NSNotification *notification, id localOwner, DMNotificationObserver *observer);
@interface DMNotificationObserver : NSObject
+ (id)observerForName:(NSString *)notificationName
object:(id)notificationSender
owner:(id)owner
action:(DMNotificationActionBlock)actionBlock
__attribute__((__nonnull__(1,3,4)));
- (id)initWithName:(NSString *)notificationName
object:(id)notificationSender
owner:(id)owner
action:(DMNotificationActionBlock)actionBlock
__attribute__((__nonnull__(1,3,4)));
- (void)fireAction:(NSNotification *)notification;
- (void)invalidate;
@end
| //
// DMNotificationObserver.h
// Library
//
// Created by Jonathon Mah on 2011-07-11.
// Copyright 2011 Delicious Monster Software. All rights reserved.
//
#import <Foundation/Foundation.h>
/* The action block is passed the notification, the owner as a parameter (to avoid retain cycles),
* and the triggering observer (so it can easiliy invalidate it if it needs to). */
@class DMNotificationObserver;
typedef void(^DMNotificationActionBlock)(NSNotification *notification, id localOwner, DMNotificationObserver *observer);
@interface DMNotificationObserver : NSObject
+ (id)observerForName:(NSString *)notificationName
object:(id)notificationSender
owner:(id)owner
action:(DMNotificationActionBlock)actionBlock
__attribute__((nonnull(1,3,4)));
- (id)initWithName:(NSString *)notificationName
object:(id)notificationSender
owner:(id)owner
action:(DMNotificationActionBlock)actionBlock
__attribute__((nonnull(1,3,4)));
- (void)fireAction:(NSNotification *)notification;
- (void)invalidate;
@end
|
Replace with portable version in C | /* hello.c
build with:
gcc -nostartfiles -fno-asynchronous-unwind-tables -Os -static -o hello hello.c
strip -R .comment -s hello
*/
#include <unistd.h>
const char message[] = "\n"
"Hello from Docker.\n"
"This message shows that your installation appears to be working correctly.\n"
"\n"
"To generate this message, Docker took the following steps:\n"
" 1. The Docker client contacted the Docker daemon.\n"
" 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\n"
" 3. The Docker daemon created a new container from that image which runs the\n"
" executable that produces the output you are currently reading.\n"
" 4. The Docker daemon streamed that output to the Docker client, which sent it\n"
" to your terminal.\n"
"\n"
"To try something more ambitious, you can run an Ubuntu container with:\n"
" $ docker run -it ubuntu bash\n"
"\n"
"Share images, automate workflows, and more with a free Docker Hub account:\n"
" https://hub.docker.com\n"
"\n"
"For more examples and ideas, visit:\n"
" https://docs.docker.com/userguide/\n"
"\n";
void _start()
{
write(1, message, sizeof(message)-1);
_exit(0);
}
| |
Add tests for id generation and ISO date strings | #ifndef ENTRYTESTSUITE
#define ENTRYTESTSUITE
#include <cxxtest/TestSuite.h>
#include "../src/entry.h"
class EntryTestSuite : public CxxTest::TestSuite
{
public:
void testEntryHasGivenTitle(void)
{
testEntry.setTitle("testTitle");
TS_ASSERT_SAME_DATA(testEntry.title().c_str(), "testTitle", 9);
}
diaryengine::Entry testEntry;
};
#endif // ENTRYTESTSUITE
| #ifndef ENTRYTESTSUITE
#define ENTRYTESTSUITE
#include <cxxtest/TestSuite.h>
#include <qt5/QtCore/QDateTime>
#include "../src/entry.h"
class EntryTestSuite : public CxxTest::TestSuite
{
public:
void testTitleCanBeSetCorrectly(void)
{
testEntry.setTitle("testTitle");
TS_ASSERT_SAME_DATA(testEntry.title().c_str(), "testTitle", 9);
}
void testDateCanBeSetCorrectlyWithISOString(void)
{
testEntry.setDate("2007-03-01T13:00:00Z");
TS_ASSERT(testEntry.date() == "2007-03-01T13:00:00Z");
}
void testDateUnderstandsTimeZone(void)
{
testEntry.setDate("2007-03-01T13:00:00+02:00");
TS_ASSERT(testEntry.date() == "2007-03-01T13:00:00+02:00");
}
void testIdRegenerationGeneratesDifferentUUID()
{
testEntry.regenerateId();
long id = testEntry.id();
testEntry.regenerateId();
TS_ASSERT_DIFFERS(testEntry.id(), id);
}
diaryengine::Entry testEntry;
};
#endif // ENTRYTESTSUITE
|
Add another autoload key for TDataFrameImpl' | /*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifdef __ROOTCLING__
// All these are there for the autoloading
#pragma link C++ class ROOT::Experimental::TDataFrame-;
#pragma link C++ class ROOT::Experimental::TDataFrameInterface<ROOT::Detail::TDataFrameFilterBase>-;
#pragma link C++ class ROOT::Experimental::TDataFrameInterface<ROOT::Detail::TDataFrameBranchBase>-;
#endif
| /*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifdef __ROOTCLING__
// All these are there for the autoloading
#pragma link C++ class ROOT::Experimental::TDataFrame-;
#pragma link C++ class ROOT::Experimental::TDataFrameInterface<ROOT::Detail::TDataFrameFilterBase>-;
#pragma link C++ class ROOT::Experimental::TDataFrameInterface<ROOT::Detail::TDataFrameBranchBase>-;
#pragma link C++ class ROOT::Detail::TDataFrameImpl-;
#endif
|
Fix test that wasn't testing anything | // RUN: mkdir -p %t.dir
// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir
// RUN: ls %t.dir | not grep report
// RUN: rm -fR %t.dir
// This tests that we do not currently emit HTML diagnostics for reports that
// cross file boundaries.
#include "html-diags-multifile.h"
#define CALL_HAS_BUG(q) has_bug(q)
void test_call_macro() {
CALL_HAS_BUG(0);
}
| // RUN: mkdir -p %t.dir
// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir %s
// RUN: ls %t.dir | not grep report
// RUN: rm -fR %t.dir
// This tests that we do not currently emit HTML diagnostics for reports that
// cross file boundaries.
#include "html-diags-multifile.h"
#define CALL_HAS_BUG(q) has_bug(q)
void test_call_macro() {
CALL_HAS_BUG(0);
}
|
ADD - Added functional GPIO code to IMU folder | #include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include "mraa.h"
#define thumb_f 8
#define index_f 9
#define middle_f 10
#define ring_f 11
#define pinky_f 12
int running = 0;
int
main(int argc, char** argv)
{
mraa_result_t r = MRAA_SUCCESS;
mraa_init();
fprintf(stdout, "MRAA Version: %s\n", mraa_get_version());
mraa_gpio_context gpio[5];
gpio[0] = mraa_gpio_init(thumb_f);
gpio[1] = mraa_gpio_init(index_f);
gpio[2] = mraa_gpio_init(middle_f);
gpio[3] = mraa_gpio_init(ring_f);
gpio[4] = mraa_gpio_init(pinky_f);
// set direction to OUT
r = mraa_gpio_dir(gpio[0], MRAA_GPIO_OUT);
r = mraa_gpio_dir(gpio[1], MRAA_GPIO_OUT);
r = mraa_gpio_dir(gpio[2], MRAA_GPIO_OUT);
r = mraa_gpio_dir(gpio[3], MRAA_GPIO_OUT);
r = mraa_gpio_dir(gpio[4], MRAA_GPIO_OUT);
while (running == 0) {
mraa_gpio_write(gpio[0], 0);
mraa_gpio_write(gpio[1], 0);
mraa_gpio_write(gpio[2], 0);
mraa_gpio_write(gpio[3], 0);
mraa_gpio_write(gpio[4], 0);
printf("off\n");
sleep(1);
mraa_gpio_write(gpio[0], 1);
mraa_gpio_write(gpio[1], 1);
mraa_gpio_write(gpio[2], 1);
mraa_gpio_write(gpio[3], 1);
mraa_gpio_write(gpio[4], 1);
printf("on\n");
sleep(1);
}
return r;
}
| |
Use right order of nonatomic and strong | /*
PKRevealController - Copyright (C) 2012 Philip Kluz (Philip.Kluz@zuui.org)
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 <UIKit/UIKit.h>
@class PKRevealController;
@interface PKAppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong, readwrite) PKRevealController *revealController;
@property (strong, nonatomic) UIWindow *window;
@end
| /*
PKRevealController - Copyright (C) 2012 Philip Kluz (Philip.Kluz@zuui.org)
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 <UIKit/UIKit.h>
@class PKRevealController;
@interface PKAppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong, readwrite) PKRevealController *revealController;
@property (nonatomic, strong) UIWindow *window;
@end
|
Add some string utility functions. | //
// string.h
// pgf+
//
// Created by Emil Djupfeldt on 2012-06-25.
// Copyright (c) 2012 Chalmers University of Technology. All rights reserved.
//
#ifndef pgf__string_h
#define pgf__string_h
#include <string>
#include <vector>
namespace gf {
static inline std::vector<std::string> split(const std::string& str, char ch) {
std::vector<std::string> ret;
size_t last;
size_t next;
last = 0;
while (true) {
next = str.find(ch, last);
if (next == std::string::npos) {
ret.push_back(str.substr(last));
break;
}
ret.push_back(str.substr(last, next - last));
last = next + 1;
}
return ret;
}
static inline bool isWhiteSpace(char ch) {
return ch == '\r' || ch == '\n' || ch == '\t' || ch == ' ';
}
static inline std::string trim(const std::string& str) {
size_t start;
size_t end;
for (start = 0; start < str.size() ; start++) {
if (!isWhiteSpace(str.at(start))) {
break;
}
}
for (end = str.size(); end > start; end--) {
if (!isWhiteSpace(str.at(end - 1))) {
end--;
break;
}
}
return str.substr(start, end - start);
}
}
#endif
| |
Add copyright and RCS/CVS Id. | int dsinit(int, struct statinfo *, struct statinfo *, struct statinfo *);
int dscmd(char *, char *, int, struct statinfo *);
| /*-
* Copyright (c) 1998 David E. O'Brien
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
*/
int dsinit(int, struct statinfo *, struct statinfo *, struct statinfo *);
int dscmd(char *, char *, int, struct statinfo *);
|
Fix JNI for C instead of C++ | #include "org_bitcoin_NativeSecp256k1.h"
#include "include/secp256k1.h"
JNIEXPORT jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1verify
(JNIEnv* env, jclass classObject, jobject byteBufferObject)
{
unsigned char* data = (unsigned char*) env->GetDirectBufferAddress(byteBufferObject);
int sigLen = *((int*)(data + 32));
int pubLen = *((int*)(data + 32 + 4));
return secp256k1_ecdsa_verify(data, 32, data+32+8, sigLen, data+32+8+sigLen, pubLen);
}
static void __javasecp256k1_attach(void) __attribute__((constructor));
static void __javasecp256k1_detach(void) __attribute__((destructor));
static void __javasecp256k1_attach(void) {
secp256k1_start();
}
static void __javasecp256k1_detach(void) {
secp256k1_stop();
}
| #include "org_bitcoin_NativeSecp256k1.h"
#include "include/secp256k1.h"
JNIEXPORT jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1verify
(JNIEnv* env, jclass classObject, jobject byteBufferObject)
{
unsigned char* data = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject);
int sigLen = *((int*)(data + 32));
int pubLen = *((int*)(data + 32 + 4));
return secp256k1_ecdsa_verify(data, 32, data+32+8, sigLen, data+32+8+sigLen, pubLen);
}
static void __javasecp256k1_attach(void) __attribute__((constructor));
static void __javasecp256k1_detach(void) __attribute__((destructor));
static void __javasecp256k1_attach(void) {
secp256k1_start();
}
static void __javasecp256k1_detach(void) {
secp256k1_stop();
}
|
Change mask size from 5 to 3 | #pragma once
#include "MyImage.h"
#define MASK_SIZE 5
class Pixel {
private:
BYTE blue;
BYTE green;
BYTE red;
public:
Pixel(){
blue;
green;
red;
}
~Pixel(){}
BYTE GetBlue() { return blue; }
BYTE GetGreen() { return green; }
BYTE GetRed() { return red; }
void Set(int _b, int _g, int _r)
{
blue = _b;
green = _g;
red = _r;
}
};
class CPixelProcessing
{
public:
CPixelProcessing(CMyImage*, int, BYTE, BYTE);
~CPixelProcessing(void){}
CMyImage* start(BYTE**);
private:
int nWidth;
int nHeight;
int nBitDepth;
int nOutput;
BYTE nHotVal;
BYTE nDeadVal;
CMyImage *pResult;
BYTE** szResult;
BYTE *temp;
void _8bitImageCorrection(BYTE**);
void _24bitImageCorrection(BYTE**);
int GetMedian(vector<BYTE>);
bool GetPixelState(int, int, int);
bool GetPixelState(int, int, Pixel);
};
| #pragma once
#include "MyImage.h"
#define MASK_SIZE 3
class Pixel {
private:
BYTE blue;
BYTE green;
BYTE red;
public:
Pixel(){
blue;
green;
red;
}
~Pixel(){}
BYTE GetBlue() { return blue; }
BYTE GetGreen() { return green; }
BYTE GetRed() { return red; }
void Set(int _b, int _g, int _r)
{
blue = _b;
green = _g;
red = _r;
}
};
class CPixelProcessing
{
public:
CPixelProcessing(CMyImage*, int, BYTE, BYTE);
~CPixelProcessing(void){}
CMyImage* start(BYTE**);
private:
int nWidth;
int nHeight;
int nBitDepth;
int nOutput;
BYTE nHotVal;
BYTE nDeadVal;
CMyImage *pResult;
BYTE** szResult;
BYTE *temp;
void _8bitImageCorrection(BYTE**);
void _24bitImageCorrection(BYTE**);
int GetMedian(vector<BYTE>);
bool GetPixelState(int, int, int);
bool GetPixelState(int, int, Pixel);
};
|
Use malloc/free as compile failed under MSVC. Ask rpmuller to check if okay. | #include "swap.h"
#include <string.h>
/* Swap generic function */
void swap(void *vp1, void *vp2, int size)
{
char buffer[size];
memcpy(buffer, vp1, size);
memcpy(vp1,vp2,size);
memcpy(vp2,buffer,size);
}
| #include "swap.h"
#include <stdlib.h>
#include <string.h>
/* Swap generic function */
void swap(void *vp1, void *vp2, int size)
{
char* buffer = (char*) malloc(size*sizeof(char));
memcpy(buffer, vp1, size);
memcpy(vp1,vp2,size);
memcpy(vp2,buffer,size);
free(buffer);
}
|
Add missing NSObject protocol declaration. | //******************************************************************************
//
// Copyright (c) 2016 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// 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.
//
//******************************************************************************
#pragma once
#import <SafariServices/SafariServicesExport.h>
#import <Foundation/NSObjCRuntime.h>
@class SFSafariViewController;
@class NSURL;
@class NSString;
@class NSArray;
@protocol SFSafariViewControllerDelegate <NSObject>
- (void)safariViewController:(SFSafariViewController*)controller didCompleteInitialLoad:(BOOL)didLoadSuccessfully;
- (NSArray*)safariViewController:(SFSafariViewController*)controller activityItemsForURL:(NSURL*)URL title:(NSString*)title;
- (void)safariViewControllerDidFinish:(SFSafariViewController*)controller;
@end
| //******************************************************************************
//
// Copyright (c) 2016 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// 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.
//
//******************************************************************************
#pragma once
#import <SafariServices/SafariServicesExport.h>
#import <Foundation/NSObject.h>
@class SFSafariViewController;
@class NSURL;
@class NSString;
@class NSArray;
@protocol SFSafariViewControllerDelegate <NSObject>
- (void)safariViewController:(SFSafariViewController*)controller didCompleteInitialLoad:(BOOL)didLoadSuccessfully;
- (NSArray*)safariViewController:(SFSafariViewController*)controller activityItemsForURL:(NSURL*)URL title:(NSString*)title;
- (void)safariViewControllerDidFinish:(SFSafariViewController*)controller;
@end
|
Handle different sized wchar_t for windows. | // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
// This should pass for any endianness combination of host and target.
// This bit is taken from Sema/wchar.c so we can avoid the wchar.h include.
typedef __WCHAR_TYPE__ wchar_t;
#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
|| defined(_M_X64) || defined(SHORT_WCHAR)
#define WCHAR_T_TYPE unsigned short
#elif defined(__sun) || defined(__AuroraUX__)
#define WCHAR_T_TYPE long
#else /* Solaris or AuroraUX. */
#define WCHAR_T_TYPE int
#endif
// CHECK: @.str = private unnamed_addr constant [72 x i8] c"
extern void foo(const wchar_t* p);
int main (int argc, const char * argv[])
{
foo(L"This is some text");
return 0;
}
| // RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-win32 | FileCheck %s --check-prefix=WIN
// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-apple-darwin | FileCheck %s --check-prefix=DAR
// This should pass for any endianness combination of host and target.
// This bit is taken from Sema/wchar.c so we can avoid the wchar.h include.
typedef __WCHAR_TYPE__ wchar_t;
#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
|| defined(_M_X64) || defined(SHORT_WCHAR)
#define WCHAR_T_TYPE unsigned short
#elif defined(__sun) || defined(__AuroraUX__)
#define WCHAR_T_TYPE long
#else /* Solaris or AuroraUX. */
#define WCHAR_T_TYPE int
#endif
// CHECK-DAR: private unnamed_addr constant [72 x i8] c"
// CHECK-WIN: private unnamed_addr constant [36 x i8] c"
extern void foo(const wchar_t* p);
int main (int argc, const char * argv[])
{
foo(L"This is some text");
return 0;
}
|
Fix header file guard and API definitions | /* Copyright 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Header for tablet_mode.c */
#ifdef CONFIG_TABLET_MODE
/* Return 1 if in tablet mode, 0 otherwise */
int tablet_get_mode(void);
void tablet_set_mode(int mode);
/**
* Interrupt service routine for hall sensor.
*
* HALL_SENSOR_GPIO_L must be defined.
*
* @param signal: GPIO signal
*/
void hall_sensor_isr(enum gpio_signal signal);
/**
* Disables the interrupt on GPIO connected to hall sensor. Additionally, it
* disables the tablet mode switch sub-system and turns off tablet mode. This is
* useful when the same firmware is shared between convertible and clamshell
* devices to turn off hall sensor and tablet mode detection on clamshell.
*/
void hall_sensor_disable(void);
/*
* This must be defined when CONFIG_HALL_SENSOR_CUSTOM is defined. This allows
* a board to override the default behavior that determines if the 360 sensor is
* active: !gpio_get_level(HALL_SENSOR_GPIO_L).
*
* Returns 1 if the 360 sensor is active; otherwise 0.
*/
int board_sensor_at_360(void);
#endif
| /* Copyright 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __CROS_EC_TABLET_MODE_H
#define __CROS_EC_TABLET_MODE_H
/**
* Get tablet mode state
*
* Return 1 if in tablet mode, 0 otherwise
*/
int tablet_get_mode(void);
/**
* Set tablet mode state
*
* @param mode 1: tablet mode. 0 clamshell mode.
*/
void tablet_set_mode(int mode);
/**
* Interrupt service routine for hall sensor.
*
* HALL_SENSOR_GPIO_L must be defined.
*
* @param signal: GPIO signal
*/
void hall_sensor_isr(enum gpio_signal signal);
/**
* Disables the interrupt on GPIO connected to hall sensor. Additionally, it
* disables the tablet mode switch sub-system and turns off tablet mode. This is
* useful when the same firmware is shared between convertible and clamshell
* devices to turn off hall sensor and tablet mode detection on clamshell.
*/
void hall_sensor_disable(void);
/**
* This must be defined when CONFIG_HALL_SENSOR_CUSTOM is defined. This allows
* a board to override the default behavior that determines if the 360 sensor is
* active: !gpio_get_level(HALL_SENSOR_GPIO_L).
*
* Returns 1 if the 360 sensor is active; otherwise 0.
*/
int board_sensor_at_360(void);
#endif /* __CROS_EC_TABLET_MODE_H */
|
Move defines for error strings and dialogs into this file for central tracking of ids. | /*
This header file contains all definitions needed for compatibility issues
Most of them should be defined only if corresponding SYSDEF_XXX macro is
defined (see system/sysdef.h)
*/
#ifndef OSDEFS_H
#define OSDEFS_H
int strcasecmp (const char *str1, const char *str2);
int strncasecmp (char const *dst, char const *src, int maxLen);
char *strdup (const char *str);
#ifdef SYSDEF_ACCESS
int access (const char *path, int mode);
#endif
// The 2D graphics driver used by software renderer on this platform
#define SOFTWARE_2D_DRIVER "crystalspace.graphics2d.mac"
#define OPENGL_2D_DRIVER "crystalspace.graphics2d.defaultgl"
#define GLIDE_2D_DRIVER "crystalspace.graphics3d.glide.2x"
// Sound driver
#define SOUND_DRIVER "crystalspace.sound.driver.mac"
#if defined (SYSDEF_DIR)
# define __NEED_GENERIC_ISDIR
#endif
#define PORT_BYTESEX_BIG_ENDIAN 1
#endif // OSDEFS_H
| /*
This header file contains all definitions needed for compatibility issues
Most of them should be defined only if corresponding SYSDEF_XXX macro is
defined (see system/sysdef.h)
*/
#ifndef OSDEFS_H
#define OSDEFS_H
int strcasecmp (const char *str1, const char *str2);
int strncasecmp (char const *dst, char const *src, int maxLen);
char *strdup (const char *str);
#ifdef SYSDEF_ACCESS
int access (const char *path, int mode);
#endif
// The 2D graphics driver used by software renderer on this platform
#define SOFTWARE_2D_DRIVER "crystalspace.graphics2d.mac"
#define OPENGL_2D_DRIVER "crystalspace.graphics2d.defaultgl"
#define GLIDE_2D_DRIVER "crystalspace.graphics3d.glide.2x"
// Sound driver
#define SOUND_DRIVER "crystalspace.sound.driver.mac"
#if defined (SYSDEF_DIR)
# define __NEED_GENERIC_ISDIR
#endif
#define PORT_BYTESEX_BIG_ENDIAN 1
#ifdef SYSDEF_2DDRIVER_DEFS
#define kArrowCursor 128
#define kGeneralErrorDialog 1026
#define kAskForDepthChangeDialog 1027
#define kErrorStrings 1025
#define kBadDepthString 1
#define kNoDSContext 2
#define kUnableToOpenDSContext 3
#define kUnableToReserveDSContext 4
#define kFatalErrorInGlide 5
#define kFatalErrorInOpenGL2D 6
#define kFatalErrorInOpenGL3D 7
#define kFatalErrorOutOfMemory 8
#define kFatalErrorInDriver2D 9
#endif
#endif // OSDEFS_H
|
Add gyro sensor debug program | #pragma config(Sensor, S1, gyro, sensorI2CHiTechnicGyro)
#define TIME_MAX 0xFFFF
bool initialized = false;
unsigned long lastUpdate = 0;
long getTimeDelta() {
if (!initialized) {
initialized = true;
lastUpdate = nSysTime;
return 0;
}
long delta;
if (nSysTime < lastUpdate) {
// The time has looped around
delta = TIME_MAX - lastUpdate + nSysTime;
lastUpdate = nSysTime;
} else {
delta = nSysTime - lastUpdate;
lastUpdate = nSysTime;
}
return delta;
}
task main() {
int zero = 0;
float angle = 0;
// Find the zero
for (int i = 0; i < 10; i++) {
zero += SensorValue[gyro];
wait1Msec(100);
}
zero /= 10;
while(true) {
angle += ((SensorValue[gyro]) - zero) * getTimeDelta() / 1000.0;
nxtDisplayTextLine(0, "%d", SensorValue[gyro]);
nxtDisplayTextLine(1, "%.4f", angle);
nxtDisplayTextLine(2, "%d", zero);
}
}
| |
Add standard copyright notice; fix style bugs. (Reported by bde) Remove NO_NOLOGIN_LOG option now that we're off the root partition. | /*-
* This program is in the public domain. I couldn't bring myself to
* declare Copyright on a variant of Hello World.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/uio.h>
#include <syslog.h>
#include <unistd.h>
#define MESSAGE "This account is currently not available.\n"
int
main(int argc, char *argv[])
{
#ifndef NO_NOLOGIN_LOG
char *user, *tt;
if ((tt = ttyname(0)) == NULL)
tt = "UNKNOWN";
if ((user = getlogin()) == NULL)
user = "UNKNOWN";
openlog("nologin", LOG_CONS, LOG_AUTH);
syslog(LOG_CRIT, "Attempted login by %s on %s", user, tt);
closelog();
#endif /* NO_NOLOGIN_LOG */
write(STDOUT_FILENO, MESSAGE, sizeof(MESSAGE) - 1);
_exit(1);
}
| /*-
* Copyright (c) 2004 The FreeBSD Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
#define MESSAGE "This account is currently not available.\n"
int
main(int argc, char *argv[])
{
char *user, *tt;
if ((tt = ttyname(0)) == NULL)
tt = "UNKNOWN";
if ((user = getlogin()) == NULL)
user = "UNKNOWN";
openlog("nologin", LOG_CONS, LOG_AUTH);
syslog(LOG_CRIT, "Attempted login by %s on %s", user, tt);
closelog();
printf("%s", MESSAGE);
return 1;
}
|
Make parse() count the spaces in the regularized code string. | #include types.c
#include <string.h>
/* We can:
Set something equal to something
Function calls
Function definitions
Returning things -- delimiter '<'
Printing things
Iffing */
struct call parseCall(char* statement);
struct function parseFunction(char* statement);
char* fixSpacing(char* code) {
char* fixedCode = calloc(sizeof(char), strlen(code) + 1);
fixedCode = strcpy(fixedCode, code);
int n = strlen(fixedCode);
char* doubleSpace = strstr(fixedCode, " ");
char* movingIndex;
for( ; doubleSpace; doubleSpace = strstr(fixedCode, " ")) {
for(movingIndex = doubleSpace; movingIndex&; movingIndex++) {
movingIndex[0] = movingIndex[1];
}
}
return fixedCode;
}
| #include <stdlib.h>
#include <stdio.h>
#include types.c
#include <string.h>
/* We can:
Set something equal to something
Function calls
Function definitions
Returning things -- delimiter '<'
Printing things
Iffing */
struct call parseCall(char* statement);
struct function parseFunction(char* statement);
char* fixSpacing(char* code) {
char* fixedCode = calloc(sizeof(char), strlen(code) + 1);
fixedCode = strcpy(fixedCode, code);
char* doubleSpace = strstr(fixedCode, " ");
char* movingIndex;
for( ; doubleSpace; doubleSpace = strstr(fixedCode, " ")) {
for(movingIndex = doubleSpace; movingIndex&; movingIndex++) {
movingIndex[0] = movingIndex[1];
}
}
return fixedCode;
}
struct statement* parse(char* code) {
char* regCode = fixSpacing(code);
int n = 0;
int i;
for(i = 0; regCode[i]; i++) {
if(regCode[i] == ' ') {
n++;
}
}
char** spcTokens = calloc(sizeof(char*), n+1);
|
Remove the remaining ERR_ constants that are never used or tested for. | /* *
* This file is part of Feng
*
* Copyright (C) 2009 by LScube team <team@lscube.org>
* See AUTHORS for more details
*
* feng 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.
*
* feng 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 feng; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* */
#ifndef FN_UTILS_H
#define FN_UTILS_H
#include "config.h"
#include <time.h>
#include <sys/time.h>
#include <ctype.h>
#include <stdint.h>
#include <sys/types.h>
#include <math.h>
#include <string.h>
/*! autodescriptive error values */
#define ERR_NOERROR 0
#define ERR_GENERIC -1
#define ERR_ALLOC -4
#endif // FN_UTILS_H
| /* *
* This file is part of Feng
*
* Copyright (C) 2009 by LScube team <team@lscube.org>
* See AUTHORS for more details
*
* feng 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.
*
* feng 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 feng; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* */
#ifndef FN_UTILS_H
#define FN_UTILS_H
#include "config.h"
#include <time.h>
#include <sys/time.h>
#include <ctype.h>
#include <stdint.h>
#include <sys/types.h>
#include <math.h>
#include <string.h>
#endif // FN_UTILS_H
|
Fix a few warnings that prevented Travis from compiling | #include "ruby.h"
#include "rtl-sdr.h"
VALUE m_turtleshell = Qnil;
static VALUE m_rtlsdr;
static VALUE turtleshell_count() {
return INT2NUM(rtlsdr_get_device_count());
}
static VALUE turtleshell_new_device() {
char *name;
rtlsdr_dev_t *device = NULL;
int count = rtlsdr_get_device_count();
// ensure we have at least one device
if (!count) { return Qnil; }
name = rtlsdr_get_device_name(0);
device = rtlsdr_open(&device, 0);
VALUE device_hash = rb_hash_new();
rb_hash_aset(device_hash, rb_str_new2("name"), rb_str_new2(rtlsdr_get_device_name(0)));
rb_hash_aset(device_hash, rb_str_new2("device_handle"), device);
return device_hash;
}
void Init_librtlsdr() {
m_turtleshell = rb_define_module("TurtleShell");
m_rtlsdr = rb_define_module_under(m_turtleshell, "RTLSDR");
rb_define_module_function(m_rtlsdr, "count", turtleshell_count, 0);
rb_define_module_function(m_rtlsdr, "first_device", turtleshell_new_device, 0);
}
| #include "ruby.h"
#include "rtl-sdr.h"
VALUE m_turtleshell = Qnil;
VALUE c_device;
static VALUE m_rtlsdr;
static VALUE turtleshell_count() {
return INT2NUM(rtlsdr_get_device_count());
}
static VALUE turtleshell_new_device() {
rtlsdr_dev_t *device = NULL;
VALUE wrapped_device;
VALUE hash;
int count = rtlsdr_get_device_count();
// ensure we have at least one device
if (!count) { return Qnil; }
device = rtlsdr_open(&device, 0);
wrapped_device = Data_Wrap_Struct(c_device, NULL, NULL, device);
hash = rb_hash_new();
rb_hash_aset(hash, rb_str_new2("name"), rb_str_new2(rtlsdr_get_device_name(0)));
rb_hash_aset(hash, rb_str_new2("device_handle"), wrapped_device);
return hash;
}
void Init_librtlsdr() {
m_turtleshell = rb_define_module("TurtleShell");
m_rtlsdr = rb_define_module_under(m_turtleshell, "RTLSDR");
c_device = rb_define_class_under(m_rtlsdr, "Device", rb_cObject);
rb_define_module_function(m_rtlsdr, "count", turtleshell_count, 0);
rb_define_module_function(m_rtlsdr, "first_device", turtleshell_new_device, 0);
}
|
Return with exit code from main functions | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "expression.h"
#include "stream.h"
#include "parser.h"
#include "analyze.h"
#include "generator.h"
#include "backend.h"
#include "optimize.h"
int main(int argc, char *argv[]) {
if (argc < 3) {
fprintf(stderr, "usage: backend-test <input-file> <output-file>\n");
exit(1);
}
FILE *src = fopen(argv[1], "r");
if (src == NULL) {
fprintf(stderr, "backend-test: no such file or directory\n");
return 1;
}
stream *in = open_stream(src);
block_statement *block = parse(in);
close_stream(in);
fclose(src);
analyze(block);
code_system *system = generate(block);
optimize(system);
FILE *out = fopen(argv[2], "w");
if (out == NULL) {
fprintf(stderr, "backend-test: error opening output-file\n");
return 1;
}
backend_write(system, out);
fflush(out);
fclose(out);
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "expression.h"
#include "stream.h"
#include "parser.h"
#include "analyze.h"
#include "generator.h"
#include "backend.h"
#include "optimize.h"
int main(int argc, char *argv[]) {
if (argc < 3) {
fprintf(stderr, "usage: backend-test <input-file> <output-file>\n");
return 1;
}
FILE *src = fopen(argv[1], "r");
if (src == NULL) {
fprintf(stderr, "backend-test: no such file or directory\n");
return 1;
}
stream *in = open_stream(src);
block_statement *block = parse(in);
close_stream(in);
fclose(src);
analyze(block);
code_system *system = generate(block);
optimize(system);
FILE *out = fopen(argv[2], "w");
if (out == NULL) {
fprintf(stderr, "backend-test: error opening output-file\n");
return 1;
}
backend_write(system, out);
fflush(out);
fclose(out);
return 0;
}
|
Add include file for standard unix functions we have to provide for systems like Windows | #ifndef COMPAT_H
#define COMPAT_H
#ifndef HAVE_STRCASECMP
extern int strcasecmp(const char*, const char*);
#endif
#ifndef HAVE_STRNCASECMP
extern int strncasecmp(const char*, const char*, unsigned int);
#endif
#endif
| |
Update driver version to 5.02.00-k2 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2006 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k1"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2006 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k2"
|
Implement double to long double conversion | /* This file is part of Metallic, a runtime library for WebAssembly.
*
* Copyright (C) 2018 Chen-Pang He <chen.pang.he@jdh8.org>
*
* 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/
*/
#include "../../math/reinterpret.h"
#include "../../math/double/normalize.h"
#include <math.h>
#include <stdint.h>
static __int128 _magnitude(int64_t i)
{
if (i >= 0x7FF0000000000000)
return (__int128)0x78 << 120 | (__int128)i << 60;
return i ? ((__int128)0x3C << 120) + ((__int128)_normalize(i) << 60) : 0;
}
long double __extenddftf2(double x)
{
int64_t i = reinterpret(int64_t, fabs(x));
return copysignl(reinterpret(long double, _magnitude(i)), x);
}
| |
Work arounf use of weak when deployment target it iOS 4 | //
// KWFutureObject.h
// iOSFalconCore
//
// Created by Luke Redpath on 13/01/2011.
// Copyright 2011 LJR Software Limited. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef id (^KWFutureObjectBlock)(void);
@interface KWFutureObject : NSObject {
__weak id *objectPointer;
KWFutureObjectBlock block;
}
+ (id)objectWithObjectPointer:(id *)pointer;
+ (id)objectWithReturnValueOfBlock:(KWFutureObjectBlock)block;
- (id)initWithObjectPointer:(id *)pointer;
- (id)initWithBlock:(KWFutureObjectBlock)aBlock;
- (id)object;
@end
| //
// KWFutureObject.h
// iOSFalconCore
//
// Created by Luke Redpath on 13/01/2011.
// Copyright 2011 LJR Software Limited. All rights reserved.
//
#import <Foundation/Foundation.h>
#ifdef __weak
#undef __weak
#define __weak __unsafe_unretained
#endif
typedef id (^KWFutureObjectBlock)(void);
@interface KWFutureObject : NSObject {
__weak id *objectPointer;
KWFutureObjectBlock block;
}
+ (id)objectWithObjectPointer:(id *)pointer;
+ (id)objectWithReturnValueOfBlock:(KWFutureObjectBlock)block;
- (id)initWithObjectPointer:(id *)pointer;
- (id)initWithBlock:(KWFutureObjectBlock)aBlock;
- (id)object;
@end
|
Include file needed for slip rpl-border-router build | /*
Copied from mc1322x/dev/cpu.
This file exists as a work-around for the hardware dependant calls
to slip_arch_init.
Current the prototype for slip_arch_init is slip_arch_init(urb)
and a typical call is something like
slip_arch_init(BAUD2URB(115200))
BAUD2UBR is hardware specific, however. Furthermore, for the sky
platform it's typically defined with #include "dev/uart1.h" (see
rpl-boarder-router/slip-bridge.c), a sky specific file. dev/uart1.h
includes msp430.h which includes the sky contiki-conf.h which
defines BAUD2UBR.
To me, the correct think to pass is simply the baudrate and have the
hardware specific conversion happen inside slip_arch_init.
Notably, most implementations just ignore the passed parameter
anyway. (except AVR)
*/
#ifndef DEV_UART1_H
#define DEV_UART1_H
#define BAUD2UBR(x) x
#endif
| |
Use <functional> instead of <tr/functional> | // Copyright (c) 2017-2019 The Swipp developers
// Copyright (c) 2019-2020 The Neutron Developers
//
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING.daemon or http://www.opensource.org/licenses/mit-license.php.
#ifndef NEUTRON_COLLECTIONHASHING_H
#define NEUTRON_COLLECTIONHASHING_H
#include <cstddef>
#include <utility>
#include <tr1/functional>
#include <boost/functional/hash.hpp>
#include "robinhood.h"
#include "uint256.h"
namespace std
{
template<> struct hash<uint256>
{
size_t operator()(const uint256& v) const
{
return robin_hood::hash_bytes(v.begin(), v.size());
}
};
}
#endif
| // Copyright (c) 2017-2019 The Swipp developers
// Copyright (c) 2019-2020 The Neutron Developers
//
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING.daemon or http://www.opensource.org/licenses/mit-license.php.
#ifndef NEUTRON_COLLECTIONHASHING_H
#define NEUTRON_COLLECTIONHASHING_H
#include <cstddef>
#include <utility>
#include <functional>
#include <boost/functional/hash.hpp>
#include "robinhood.h"
#include "uint256.h"
namespace std
{
template<> struct hash<uint256>
{
size_t operator()(const uint256& v) const
{
return robin_hood::hash_bytes(v.begin(), v.size());
}
};
}
#endif
|
Update files, Alura, Introdução a C, Aula 2.10 | #include <stdio.h>
#define NUMERO_DE_TENTATIVAS 5
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;
for(int i = 1; i <= NUMERO_DE_TENTATIVAS; i++) {
printf("Tentativa %d de %d\n", i, NUMERO_DE_TENTATIVAS);
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
if(chute < 0) {
printf("Você não pode chutar números negativos!\n");
i--;
continue;
}
int acertou = chute == numerosecreto;
int maior = chute > numerosecreto;
int menor = chute < numerosecreto;
if(acertou) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
break;
}
else 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("Fim de jogo!\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;
int tentativas = 1;
while(1) {
printf("Tentativa %d\n", tentativas);
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
if(chute < 0) {
printf("Você não pode chutar números negativos!\n");
continue;
}
int acertou = chute == numerosecreto;
int maior = chute > numerosecreto;
if(acertou) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
break;
}
else 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");
}
tentativas++;
}
printf("Fim de jogo!\n");
printf("Você acertou em %d tentativas!\n", tentativas);
}
|
Remove comment and add include guard | // Copyright 2019 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Adapter utility from fuzzer input to a temporary file, for fuzzing APIs that
// require a file instead of an input buffer.
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include "matio.h"
int MatioRead(const char* file_name) {
mat_t* matfd = Mat_Open(file_name, MAT_ACC_RDONLY);
if (matfd == nullptr) {
return 0;
}
size_t n = 0;
Mat_GetDir(matfd, &n);
Mat_Rewind(matfd);
matvar_t* matvar = nullptr;
while ((matvar = Mat_VarReadNextInfo(matfd)) != nullptr) {
Mat_VarReadDataAll(matfd, matvar);
Mat_VarGetSize(matvar);
Mat_VarFree(matvar);
}
Mat_Close(matfd);
return 0;
}
| // Copyright 2019 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MATIO_WRAP_H_
#define MATIO_WRAP_H_
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include "matio.h"
int MatioRead(const char* file_name) {
mat_t* matfd = Mat_Open(file_name, MAT_ACC_RDONLY);
if (matfd == nullptr) {
return 0;
}
size_t n = 0;
Mat_GetDir(matfd, &n);
Mat_Rewind(matfd);
matvar_t* matvar = nullptr;
while ((matvar = Mat_VarReadNextInfo(matfd)) != nullptr) {
Mat_VarReadDataAll(matfd, matvar);
Mat_VarGetSize(matvar);
Mat_VarFree(matvar);
}
Mat_Close(matfd);
return 0;
}
#endif
|
Use const T& instead of T&& | #pragma once
#include <cuda_runtime.h>
#include "xchainer/error.h"
namespace xchainer {
namespace cuda {
class RuntimeError : public XchainerError {
public:
explicit RuntimeError(cudaError_t error);
cudaError_t error() const noexcept { return error_; }
private:
cudaError_t error_;
};
void CheckError(cudaError_t error);
// Occupancy
#ifdef __CUDACC__
struct GridBlockSize {
int grid_size;
int block_size;
};
template <typename T>
GridBlockSize CudaOccupancyMaxPotentialBlockSize(T&& func, size_t dynamic_smem_size = 0, int block_size_limit = 0) {
GridBlockSize ret;
CheckError(
cudaOccupancyMaxPotentialBlockSize(&ret.grid_size, &ret.block_size, std::forward<T>(func), dynamic_smem_size, block_size_limit));
return ret;
}
#endif // __CUDACC__
} // namespace cuda
} // namespace xchainer
| #pragma once
#include <cuda_runtime.h>
#include "xchainer/error.h"
namespace xchainer {
namespace cuda {
class RuntimeError : public XchainerError {
public:
explicit RuntimeError(cudaError_t error);
cudaError_t error() const noexcept { return error_; }
private:
cudaError_t error_;
};
void CheckError(cudaError_t error);
// Occupancy
#ifdef __CUDACC__
struct GridBlockSize {
int grid_size;
int block_size;
};
template <typename T>
GridBlockSize CudaOccupancyMaxPotentialBlockSize(const T& func, size_t dynamic_smem_size = 0, int block_size_limit = 0) {
GridBlockSize ret = {};
CheckError(
cudaOccupancyMaxPotentialBlockSize(&ret.grid_size, &ret.block_size, func, dynamic_smem_size, block_size_limit));
return ret;
}
#endif // __CUDACC__
} // namespace cuda
} // namespace xchainer
|
Change location of temporary file from /tmp to /var/tmp. This is a repeat of an earlier commit which apparently got lost with the last import. It helps solve the frequently reported problem | /*-
* Copyright (c) 1998 Sendmail, Inc. All rights reserved.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*
* @(#)pathnames.h 8.5 (Berkeley) 5/19/1998
*/
#include <paths.h>
#define _PATH_LOCTMP "/tmp/local.XXXXXX"
| /*-
* Copyright (c) 1998 Sendmail, Inc. All rights reserved.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*
* @(#)pathnames.h 8.5 (Berkeley) 5/19/1998
* $FreeBSD$
*/
#include <paths.h>
#define _PATH_LOCTMP "/var/tmp/local.XXXXXX"
|
Use RNDR in stack protector | /*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdint.h>
#include <arch_helpers.h>
#include <plat/common/platform.h>
#define RANDOM_CANARY_VALUE ((u_register_t) 3288484550995823360ULL)
u_register_t plat_get_stack_protector_canary(void)
{
/*
* Ideally, a random number should be returned instead of the
* combination of a timer's value and a compile-time constant.
* As the virt platform does not have any random number generator,
* this is better than nothing but not necessarily really secure.
*/
return RANDOM_CANARY_VALUE ^ read_cntpct_el0();
}
| /*
* Copyright (c) 2021, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdint.h>
#include <arch_helpers.h>
#include <arch_features.h>
#include <plat/common/platform.h>
#define RANDOM_CANARY_VALUE ((u_register_t) 3288484550995823360ULL)
u_register_t plat_get_stack_protector_canary(void)
{
#if ENABLE_FEAT_RNG
/* Use the RNDR instruction if the CPU supports it */
if (is_armv8_5_rng_present()) {
return read_rndr();
}
#endif
/*
* Ideally, a random number should be returned above. If a random
* number generator is not supported, return instead a
* combination of a timer's value and a compile-time constant.
* This is better than nothing but not necessarily really secure.
*/
return RANDOM_CANARY_VALUE ^ read_cntpct_el0();
}
|
Add printing even and odd numbers in separate threads. | #include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>
#include <unistd.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condition = PTHREAD_COND_INITIALIZER;
bool turn = true;
int counter = 0;
void* even_thread(void* arg)
{
do
{
pthread_mutex_lock(&mutex);
if (counter % 2 == 0)
{
pthread_cond_wait(&condition, &mutex);
}
fprintf(stdout, "%d\n", counter);
fflush(stdout);
counter++;
pthread_cond_signal(&condition);
pthread_mutex_unlock(&mutex);
sleep(3);
} while (1);
}
void* odd_thread(void* arg)
{
do
{
pthread_mutex_lock(&mutex);
if (counter % 2 != 0)
{
pthread_cond_wait(&condition, &mutex);
}
fprintf(stdout, "%d\n", counter);
fflush(stdout);
counter++;
pthread_cond_signal(&condition);
pthread_mutex_unlock(&mutex);
sleep(1);
} while (1);
}
int main(int argc, char** argv)
{
pthread_t odd_thr, even_thr;
int rc = 0;
rc = pthread_create(&odd_thr, NULL, odd_thread, NULL);
if (rc < 0)
{
fprintf(stderr, "Error creating an odd thread! %d\n", errno);
fflush(stderr);
exit(EXIT_FAILURE);
}
rc = pthread_create(&even_thr, NULL, even_thread, NULL);
if (rc < 0)
{
fprintf(stderr, "Error creating an even thread! %d\n", errno);
fflush(stderr);
exit(EXIT_FAILURE);
}
rc = pthread_join(odd_thr, NULL);
if (rc < 0)
{
fprintf(stderr, "Error in pthread_join with odd thread! %d\n", errno);
fflush(stderr);
exit(EXIT_FAILURE);
}
rc = pthread_join(even_thr, NULL);
if (rc < 0)
{
fprintf(stderr, "Error in pthread_join with even thread! %d\n", errno);
fflush(stderr);
exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
} | |
Add string jump state source file including stub | /*
* waysome - wayland based window manager
*
* Copyright in alphabetical order:
*
* Copyright (C) 2014-2015 Julian Ganz
* Copyright (C) 2014-2015 Manuel Messner
* Copyright (C) 2014-2015 Marcel Müller
* Copyright (C) 2014-2015 Matthias Beyer
* Copyright (C) 2014-2015 Nadja Sommerfeld
*
* This file is part of waysome.
*
* waysome 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.
*
* waysome 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 waysome. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stddef.h>
#include <string.h>
#include "serialize/json/keys.h"
#include "serialize/json/states.h"
#include "serialize/json/string_jump_state.h"
/**
* Map for mapping the current state with a string on the next state
*/
static const struct {
enum json_backend_state current;
enum json_backend_state next;
const char* str;
} MAP[] = {
{ .current = STATE_MSG, .next = STATE_UID, .str = UID },
{ .current = STATE_MSG, .next = STATE_TYPE, .str = TYPE },
{ .current = STATE_MSG, .next = STATE_COMMANDS, .str = COMMANDS },
{ .str = NULL },
};
/*
*
* Interface implementation
*
*/
enum json_backend_state
get_next_state_for_string(
enum json_backend_state current,
const unsigned char * str
) {
//!< @todo implement
return 0;
}
| |
Change Interaction Observer Delegate to use Clue Touch model and NSArray instead of NSSet | //
// CLUInteractionObserver.h
// Clue
//
// Created by Ahmed Sulaiman on 6/7/16.
// Copyright © 2016 Ahmed Sulaiman. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@protocol CLUInteractionObserverDelegate <NSObject>
@required
- (void)touchesBegan:(NSSet<UITouch *> *)touches;
- (void)touchesMoved:(NSArray<UITouch *> *)touches;
- (void)touchesEnded:(NSSet<UITouch *> *)touches;
@end
| //
// CLUInteractionObserver.h
// Clue
//
// Created by Ahmed Sulaiman on 6/7/16.
// Copyright © 2016 Ahmed Sulaiman. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CLUTouch.h"
@protocol CLUInteractionObserverDelegate <NSObject>
@required
- (void)touchesBegan:(NSArray<CLUTouch *> *)touches;
- (void)touchesMoved:(NSArray<CLUTouch *> *)touches;
- (void)touchesEnded:(NSArray<CLUTouch *> *)touches;
@end
|
Make close, read and write virtual. | #ifndef FILE_DESCRIPTOR_H
#define FILE_DESCRIPTOR_H
#include <io/channel.h>
class FileDescriptor : public Channel {
LogHandle log_;
protected:
int fd_;
public:
FileDescriptor(int);
~FileDescriptor();
Action *close(EventCallback *);
Action *read(size_t, EventCallback *);
Action *write(Buffer *, EventCallback *);
};
#endif /* !FILE_DESCRIPTOR_H */
| #ifndef FILE_DESCRIPTOR_H
#define FILE_DESCRIPTOR_H
#include <io/channel.h>
class FileDescriptor : public Channel {
LogHandle log_;
protected:
int fd_;
public:
FileDescriptor(int);
~FileDescriptor();
virtual Action *close(EventCallback *);
virtual Action *read(size_t, EventCallback *);
virtual Action *write(Buffer *, EventCallback *);
};
#endif /* !FILE_DESCRIPTOR_H */
|
Add CoreMotion so that types can be detected | //
// SRUtils.h
// Sensorama
//
// Created by Wojciech Koszek (home) on 3/1/16.
// Copyright © 2016 Wojciech Adam Koszek. All rights reserved.
//
@import Foundation;
@import UIKit;
@interface SRUtils : NSObject
+ (UIColor *)mainColor;
+ (NSDictionary *)deviceInfo;
+ (NSString*)computeSHA256DigestForString:(NSString*)input;
+ (BOOL)isSimulator;
+ (NSString *)activityString:(CMMotionActivity *)activity;
+ (NSInteger)activityInteger:(CMMotionActivity *)activity;
@end
| //
// SRUtils.h
// Sensorama
//
// Created by Wojciech Koszek (home) on 3/1/16.
// Copyright © 2016 Wojciech Adam Koszek. All rights reserved.
//
@import Foundation;
@import UIKit;
@import CoreMotion;
@interface SRUtils : NSObject
+ (UIColor *)mainColor;
+ (NSDictionary *)deviceInfo;
+ (NSString*)computeSHA256DigestForString:(NSString*)input;
+ (BOOL)isSimulator;
+ (NSString *)activityString:(CMMotionActivity *)activity;
+ (NSInteger)activityInteger:(CMMotionActivity *)activity;
@end
|
Fix buggy __phys_to_pfn / __pfn_to_phys | /*
* linux/include/asm-arm/map.h
*
* Copyright (C) 1999-2000 Russell King
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Page table mapping constructs and function prototypes
*/
struct map_desc {
unsigned long virtual;
unsigned long pfn;
unsigned long length;
unsigned int type;
};
struct meminfo;
#define MT_DEVICE 0
#define MT_CACHECLEAN 1
#define MT_MINICLEAN 2
#define MT_LOW_VECTORS 3
#define MT_HIGH_VECTORS 4
#define MT_MEMORY 5
#define MT_ROM 6
#define MT_IXP2000_DEVICE 7
#define __phys_to_pfn(paddr) (paddr >> PAGE_SHIFT)
#define __pfn_to_phys(pfn) (pfn << PAGE_SHIFT)
extern void create_memmap_holes(struct meminfo *);
extern void memtable_init(struct meminfo *);
extern void iotable_init(struct map_desc *, int);
extern void setup_io_desc(void);
| /*
* linux/include/asm-arm/map.h
*
* Copyright (C) 1999-2000 Russell King
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Page table mapping constructs and function prototypes
*/
struct map_desc {
unsigned long virtual;
unsigned long pfn;
unsigned long length;
unsigned int type;
};
struct meminfo;
#define MT_DEVICE 0
#define MT_CACHECLEAN 1
#define MT_MINICLEAN 2
#define MT_LOW_VECTORS 3
#define MT_HIGH_VECTORS 4
#define MT_MEMORY 5
#define MT_ROM 6
#define MT_IXP2000_DEVICE 7
#define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT)
#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
extern void create_memmap_holes(struct meminfo *);
extern void memtable_init(struct meminfo *);
extern void iotable_init(struct map_desc *, int);
extern void setup_io_desc(void);
|
Update Skia milestone to 66 | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 65
#endif
| /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 66
#endif
|
Update Skia milestone to 85 | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 84
#endif
| /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_MILESTONE
#define SK_MILESTONE 85
#endif
|
Fix marching cubes unitialized variable |
#pragma once
#include <ionScene/CSimpleMesh.h>
#include "SVolume.h"
struct SMarchingCubesPoint
{
f32 Value;
vec3f Gradient;
SMarchingCubesPoint()
{}
SMarchingCubesPoint(f32 const & value)
: Value(value)
{}
};
typedef SVolume<SMarchingCubesPoint> SMarchingCubesVolume;
void CalculateGradient(SMarchingCubesVolume & Volume);
ion::Scene::CSimpleMesh * MarchingCubes(SMarchingCubesVolume & Volume);
|
#pragma once
#include <ionScene/CSimpleMesh.h>
#include "SVolume.h"
struct SMarchingCubesPoint
{
f32 Value = 0;
vec3f Gradient;
SMarchingCubesPoint()
{}
SMarchingCubesPoint(f32 const & value)
: Value(value)
{}
};
typedef SVolume<SMarchingCubesPoint> SMarchingCubesVolume;
void CalculateGradient(SMarchingCubesVolume & Volume);
ion::Scene::CSimpleMesh * MarchingCubes(SMarchingCubesVolume & Volume);
|
Fix cut off BPM on aplite and basalt | #pragma once
#include <pebble.h>
#define BG_COLOR GColorWhite
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 12)
#define BPM_FONT FONT_KEY_BITHAM_42_BOLD
#define BPM_FONT_HEIGHT 42
#define BPM_DEFAULT "---"
#define BPM_HINT_FONT FONT_KEY_GOTHIC_24_BOLD
#define BPM_HINT_FONT_HEIGHT 24
#define BPM_HINT_TEXT "BPM:"
#define BPM_TEXT_BUFFER_SIZE 10
#define TAP_TIMEOUT_SECONDS 2
| #pragma once
#include <pebble.h>
#define BG_COLOR GColorWhite
#ifdef PBL_ROUND
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 12)
#else
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 2)
#endif
#define BPM_FONT FONT_KEY_BITHAM_42_BOLD
#define BPM_FONT_HEIGHT 42
#define BPM_DEFAULT "---"
#define BPM_HINT_FONT FONT_KEY_GOTHIC_24_BOLD
#define BPM_HINT_FONT_HEIGHT 24
#define BPM_HINT_TEXT "BPM:"
#define BPM_TEXT_BUFFER_SIZE 10
#define TAP_TIMEOUT_SECONDS 2
|
Fix typo in a comment: it's base58, not base48. | #ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H
#include <QValidator>
/** Base48 entry widget validator.
Corrects near-miss characters and refuses characters that are no part of base48.
*/
class BitcoinAddressValidator : public QValidator
{
Q_OBJECT
public:
explicit BitcoinAddressValidator(QObject *parent = 0);
State validate(QString &input, int &pos) const;
static const int MaxAddressLength = 35;
};
#endif // BITCOINADDRESSVALIDATOR_H
| #ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H
#include <QValidator>
/** Base58 entry widget validator.
Corrects near-miss characters and refuses characters that are not part of base58.
*/
class BitcoinAddressValidator : public QValidator
{
Q_OBJECT
public:
explicit BitcoinAddressValidator(QObject *parent = 0);
State validate(QString &input, int &pos) const;
static const int MaxAddressLength = 35;
};
#endif // BITCOINADDRESSVALIDATOR_H
|
Add BSD 3-clause open source header | /*
* The Homework Database
*
* SQL Parser
*
* Authors:
* Oliver Sharma and Joe Sventek
* {oliver, joe}@dcs.gla.ac.uk
*
* (c) 2009. All rights reserved.
*/
#ifndef HWDB_PARSER_H
#define HWDB_PARSER_H
#include "sqlstmts.h"
#include "gram.h"
/* Places parsed output in externally declared global variable:
* sqlstmt stmt
*/
void *sql_parse(char *query);
void reset_statement(void);
void sql_reset_parser(void *bufstate);
void sql_dup_stmt(sqlstmt *dup);
/* Prints externally declared global variable
* sqlstmt stmt
* to standard output
*/
void sql_print();
#endif
| /*
* Copyright (c) 2013, Court of the University of Glasgow
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the University of Glasgow nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* The Homework Database
*
* SQL Parser
*
* Authors:
* Oliver Sharma and Joe Sventek
* {oliver, joe}@dcs.gla.ac.uk
*
*/
#ifndef HWDB_PARSER_H
#define HWDB_PARSER_H
#include "sqlstmts.h"
#include "gram.h"
/* Places parsed output in externally declared global variable:
* sqlstmt stmt
*/
void *sql_parse(char *query);
void reset_statement(void);
void sql_reset_parser(void *bufstate);
void sql_dup_stmt(sqlstmt *dup);
/* Prints externally declared global variable
* sqlstmt stmt
* to standard output
*/
void sql_print();
#endif
|
Add preliminary structure for generic io handling. | /*
*The MIT License (MIT)
*
* Copyright (c) <2016> <Stephan Gatzka>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef CJET_IO_EVENT_H
#define CJET_IO_EVENT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
union io_context {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
};
struct io_event {
union io_context context;
int (*read_function)(union io_context*);
int (*write_function)(union io_context*);
};
#ifdef __cplusplus
}
#endif
#endif
| |
Add the string to search when parsing for token from website | #ifndef _CONFIG_H_
#define _CONFIG_H_
#define LOGINDB_FILE "logindb"
#define LOGINDB_MAX 100
#define LOGINDB_MAXLINE 128
#define LOGIN_COOKIEJAR "cookie"
#define LOGIN_COOKIESIZE 32
#define LOGIN_TOKENSIZE 64
#define LOGIN_URLMAXSIZE 256
static const char *haven_authserv = "moltke.seatribe.se";
static const char *haven_webauth = "www.havenandhearth.com";
static const char *haven_tokenlink = "/autohaven";
static const char *cearth_config_dir = "/.cearth/";
static const char *foo = "test";
#endif
| #ifndef _CONFIG_H_
#define _CONFIG_H_
#define LOGINDB_FILE "logindb"
#define LOGINDB_MAX 100
#define LOGINDB_MAXLINE 128
#define LOGIN_COOKIEJAR "cookie"
#define LOGIN_COOKIESIZE 32
#define LOGIN_TOKENSIZE 64
#define LOGIN_URLMAXSIZE 256
#define LOGIN_TOKSTRSTART "<property name=\"jnlp.haven.authck\" value=\""
static const char *haven_authserv = "moltke.seatribe.se";
static const char *haven_webauth = "www.havenandhearth.com";
static const char *haven_tokenlink = "/autohaven";
static const char *cearth_config_dir = "/.cearth/";
static const char *foo = "test";
#endif
|
Add type definitions of structure documents | #ifndef ARTICLE_ANALYSIS_PROTOCOL_TYPES_H_
#define ARTICLE_ANALYSIS_PROTOCOL_TYPES_H_
#include <string.h>
#include <time.h>
#include <string>
#include <vector>
namespace protocol {
namespace types {
/**
* Type of the document's title string.
*/
typedef std::wstring DocTitle;
/**
* Type of the user name string.
*/
typedef std::string User;
/**
* Type of the document's content string.
*/
typedef std::wstring Content;
/**
* Type of of the time point.
*/
typedef time_t Time;
/**
* Type of the board.
*/
typedef std::string Board;
/**
* Enumerate of the reply mode
*/
enum class ReplyMode : int {
GOOD = 0,
NORMAL,
WOO,
};
/**
* Number of different reply modes.
*/
static constexpr size_t NUM_REPLY_MODES = 3;
/**
* Type of a row of reply message.
*/
struct ReplyMessage {
ReplyMode mode;
User user;
Content message;
ReplyMessage() {}
ReplyMessage(ReplyMode mode, User const& user, Content const& message) :
mode(mode), user(user), message(message) {}
};
/**
* Type of an array of reply messages.
*/
typedef std::vector<ReplyMessage> ReplyMessages;
/**
* Meta data of a document.
*/
struct DocMetaData {
size_t id;
size_t prev_id;
DocTitle title;
User author;
Time post_time;
Board board;
size_t num_reply_rows[NUM_REPLY_MODES];
DocMetaData() {}
DocMetaData(size_t id,
size_t prev_id,
DocTitle const& title,
User const& author,
Time const& post_time,
Board const& board,
size_t num_reply_rows[NUM_REPLY_MODES]) :
id(id), prev_id(prev_id),
title(title), author(author), post_time(post_time), board(board) {
memcpy(this->num_reply_rows, num_reply_rows, sizeof(this->num_reply_rows));
}
};
/**
* Real document content data.
*/
struct DocRealData {
Content content;
ReplyMessages reply_messages;
DocRealData() {}
DocRealData(Content const& content, ReplyMessages const& reply_messages) :
content(content), reply_messages(reply_messages) {}
};
} // namespace types
} // namespace protocol
#endif // ARTICLE_ANALYSIS_PROTOCOL_TYPES_H_
| |
Add method to return path to db file | #include <sqlite3.h>
#include <string.h>
#include <stdlib.h>
char *
gh_db_path (char *data_dir)
{
char *db_file = "/ghighlighter.db";
int length = strlen (data_dir);
length = length + strlen (db_file);
char *path = malloc (length + sizeof (char));
strcat (path, data_dir);
strcat (path, db_file);
return path;
}
| |
Fix ApiAnalyzer complaints about ImageIO headers. | //******************************************************************************
//
// Copyright (c) 2016, Intel Corporation
// Copyright (c) 2016 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// 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.
//
//******************************************************************************
#pragma once
@interface ImageSource : NSObject
@property (nonatomic) NSData *data;
- (instancetype)initWithData:(CFDataRef)data;
- (instancetype)initWithURL:(CFURLRef)url;
- (instancetype)initWithDataProvider:(CGDataProviderRef)provider;
- (CFStringRef)getImageType;
@end | //******************************************************************************
//
// Copyright (c) 2016, Intel Corporation
// Copyright (c) 2016 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// 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.
//
//******************************************************************************
#pragma once
#import <Foundation/NSObject.h>
#import <CoreFoundation/CFData.h>
#import <CoreFoundation/CFURL.h>
#import <CoreGraphics/CoreGraphicsExport.h>
@class NSData;
@interface ImageSource : NSObject
@property (nonatomic) NSData *data;
- (instancetype)initWithData:(CFDataRef)data;
- (instancetype)initWithURL:(CFURLRef)url;
- (instancetype)initWithDataProvider:(CGDataProviderRef)provider;
- (CFStringRef)getImageType;
@end
|
Add string jump state helper interface definition | /*
* waysome - wayland based window manager
*
* Copyright in alphabetical order:
*
* Copyright (C) 2014-2015 Julian Ganz
* Copyright (C) 2014-2015 Manuel Messner
* Copyright (C) 2014-2015 Marcel Müller
* Copyright (C) 2014-2015 Matthias Beyer
* Copyright (C) 2014-2015 Nadja Sommerfeld
*
* This file is part of waysome.
*
* waysome 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.
*
* waysome 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 waysome. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @addtogroup serializer_module "Serializer module"
*
* @{
*/
/**
* @addtogroup serializer_module_json_backend "Serializer JSON backend"
*
* @{
*/
/**
* @addtogroup serializer_module_json_backend_deser "JSON backend deserializer"
*
* Serializer module JSON backend private utilities
*
* @{
*/
#ifndef __WS_SERIALIZE_JSON_DESERIALIZER_STRING_JUMP_TAB_COMMON_H__
#define __WS_SERIALIZE_JSON_DESERIALIZER_STRING_JUMP_TAB_COMMON_H__
#include "serialize/json/states.h"
/**
* Get the next state for the current state and a string
*/
enum json_backend_state
get_next_state_for_string(
enum json_backend_state current,
const unsigned char * str
);
#endif //__WS_SERIALIZE_JSON_DESERIALIZER_STRING_JUMP_TAB_COMMON_H__
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
| |
Add the calculations for the Oxygen Toxicity Unit | /*
Oxygen Toxicity Unit Calulation
*/
#include <math>
double otu_const(double time,
double o2_ratio)
{
double otu = 0.0;
otu = time * pow(( 0.5 / (o2_ratio - 0.5)), (-5/6));
return (otu);
}
double otu_descend(double time,
double o2_ratio_i,
double o2_ratio_f)
{
double otu = 0.0;
otu = ((3/11)*time)/(o2_ratio_f-o2_ratio_i)*((pow((o2_ratio_f - 0.5)/0.5),11/6) - pow((o2_ratio_i - 0.5)/0.5, 11/6));
return otu;
}
| |
Fix case of file name | // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All right reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Radu Serban
// =============================================================================
//
// Base class for a single road wheel (template definition).
// A single road wheel is of type LATERAL_PIN.
//
// =============================================================================
#ifndef CH_SINGLE_ROAD_WHEEL_H
#define CH_SINGLE_ROAD_WHEEL_H
#include "chrono_vehicle/ChApiVehicle.h"
#include "chrono_vehicle/ChSubsysDefs.h"
#include "chrono_vehicle/tracked_vehicle/ChRoadWheel.h"
namespace chrono {
namespace vehicle {
///
///
///
class CH_VEHICLE_API ChSingleRoadWheel : public ChRoadWheel {
public:
ChSingleRoadWheel(const std::string& name ///< [in] name of the subsystem
);
virtual ~ChSingleRoadWheel() {}
/// Return the type of track shoe consistent with this road wheel.
virtual TrackShoeType GetType() const override { return LATERAL_PIN; }
/// Initialize this road wheel subsystem.
virtual void Initialize(ChSharedPtr<ChBodyAuxRef> chassis, ///< [in] handle to the chassis body
const ChVector<>& location ///< [in] location relative to the chassis frame
) override;
/// Add visualization of the road wheel.
/// This (optional) function should be called only after a call to Initialize().
/// It renders the wheel as a textured cylinder.
void AddWheelVisualization() override;
protected:
/// Return the width of the road wheel.
virtual double GetWheelWidth() const = 0;
};
} // end namespace vehicle
} // end namespace chrono
#endif
| |
Add a compatibility layer for zmq 3 | /* Copyright © 2001-2014, Canal TP and/or its affiliates. All rights reserved.
This file is part of Navitia,
the software to build cool stuff with public transport.
Hope you'll enjoy and contribute to this project,
powered by Canal TP (www.canaltp.fr).
Help us simplify mobility and open public transport:
a non ending quest to the responsive locomotion way of traveling!
LICENCE: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Stay tuned using
twitter @navitia
IRC #navitia on freenode
https://groups.google.com/d/forum/navitia
www.navitia.io
*/
/**
* this file provide a compatibility layer between zmq 2 and zmq 3
* by providing a API similar to zmq 2
*/
#pragma once
#include <zmq.hpp>
#if ZMQ_VERSION_MAJOR >= 3
namespace zmq{
void device(int, void *frontend, void *backend){
zmq::proxy(frontend, backend, NULL);
}
}
#endif
| |
Add UNUSED so we get a clean compile. | #include <Elementary.h>
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
EAPI int
elm_modapi_init(void *m)
{
return 1; // succeed always
}
EAPI int
elm_modapi_shutdown(void *m)
{
return 1; // succeed always
}
EAPI Eina_Bool
obj_hook(Evas_Object *obj)
{
return EINA_TRUE;
}
EAPI Eina_Bool
obj_unhook(Evas_Object *obj)
{
return EINA_TRUE;
}
EAPI Eina_Bool
obj_convert_geo_into_coord(const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y)
{
return EINA_FALSE;
}
EAPI Eina_Bool
obj_convert_coord_into_geo(const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat)
{
return EINA_FALSE;
}
EAPI char*
obj_url_request(Evas_Object *obj, int x, int y, int zoom)
{
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
zoom, x, y);
return strdup(buf);
}
| #include <Elementary.h>
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
EAPI int
elm_modapi_init(void *m __UNUSED__)
{
return 1; // succeed always
}
EAPI int
elm_modapi_shutdown(void *m __UNUSED__)
{
return 1; // succeed always
}
EAPI Eina_Bool
obj_hook(Evas_Object *obj __UNUSED__)
{
return EINA_TRUE;
}
EAPI Eina_Bool
obj_unhook(Evas_Object *obj __UNUSED__)
{
return EINA_TRUE;
}
EAPI Eina_Bool
obj_convert_geo_into_coord(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, double lon __UNUSED__, double lat __UNUSED__, int size __UNUSED__, int *x __UNUSED__, int *y __UNUSED__)
{
return EINA_FALSE;
}
EAPI Eina_Bool
obj_convert_coord_into_geo(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, int x __UNUSED__, int y __UNUSED__, int size __UNUSED__, double *lon __UNUSED__, double *lat __UNUSED__)
{
return EINA_FALSE;
}
EAPI char*
obj_url_request(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
{
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
zoom, x, y);
return strdup(buf);
}
|
Add a new example of the new M_LET feature. | #include <stdio.h>
#include "m-string.h"
#include "m-dict.h"
#include "m-array.h"
/* Definition of an associative map string_t --> size_t */
DICT_DEF2(dict_str, string_t, size_t)
#define M_OPL_dict_str_t() DICT_OPLIST(dict_str, STRING_OPLIST, M_DEFAULT_OPLIST)
/* Definition of an array of string_t */
ARRAY_DEF(vector_str, string_t)
#define M_OPL_vector_str_t() ARRAY_OPLIST(vector_str, STRING_OPLIST)
int main(void)
{
// Construct an array of string, performing a convertion of the C const char *
// into a proper string_t at real time and push then into a dynamic array
// that is declared, initialized and cleared.
M_LET( (words, ("This"), ("is"), ("a"), ("useless"), ("sentence"), ("."),
("It"), ("is"), ("used"), ("a"), ("bit"), ("to"), ("count"), ("words"), (".") ),
vector_str_t) {
// Print the arrays.
printf("The words are: ");
vector_str_out_str(stdout, words);
printf("\n");
// Count the words.
M_LET(map, dict_str_t) {
// Count the words:
for M_EACH(w, words, vector_str_t) {
(*dict_str_get_at(map, *w)) ++;
}
// Print the count:
for M_EACH(p, map, dict_str_t) {
printf ("%zu occurences of %s\n", p->value, string_get_cstr(p->key));
}
}
}
}
| |
Allow PS test03 with PS_ALLOW_ENTIRE_STORAGE_FILL flag | #include "val_interfaces.h"
#include "pal_mbed_os_crypto.h"
#include "lifecycle.h"
#ifdef ITS_TEST
void test_entry_s003(val_api_t *val_api, psa_api_t *psa_api);
#elif PS_TEST
#error [NOT_SUPPORTED] Test is too long for CI, thus always fails on timeout.
void test_entry_p003(val_api_t *val_api, psa_api_t *psa_api);
#endif
int main(void)
{
#ifdef ITS_TEST
test_start(test_entry_s003);
#elif PS_TEST
test_start(test_entry_p003);
#endif
}
| #include "val_interfaces.h"
#include "pal_mbed_os_crypto.h"
#include "lifecycle.h"
#ifdef ITS_TEST
void test_entry_s003(val_api_t *val_api, psa_api_t *psa_api);
#elif PS_TEST
#ifndef PS_ALLOW_ENTIRE_STORAGE_FILL
#error [NOT_SUPPORTED] Test is too long for CI, thus always fails on timeout.
#endif
void test_entry_p003(val_api_t *val_api, psa_api_t *psa_api);
#endif
int main(void)
{
#ifdef ITS_TEST
test_start(test_entry_s003);
#elif PS_TEST
test_start(test_entry_p003);
#endif
}
|
Use C99 stdint.h header for types | /*
Mace - http://www.macehq.cx
Copyright 1999-2004
See the file README for more information
*/
#ifndef GLOBALS_H
#define GLOBALS_H
#ifndef _MaceTypes
#define _MaceTypes
typedef unsigned char U8;
typedef signed char S8;
typedef unsigned short U16;
typedef signed short S16;
//Note: on 64-bit machines, replace "long" with "int"
#if __LP64__
typedef unsigned int U32;
typedef signed int S32;
#else
typedef unsigned long U32;
typedef signed long S32;
#endif
#endif
void App_Exit(void);
//Same as App_Exit2(), except that this calls setdis()
void App_Exit2(void);
U16 FlipW(U16 a);
U32 FlipL(U32 a);
void HexW (U16 n, char * String);
void HexL (U32 n, char * String);
#endif //GLOBALS_H
| /*
Mace - http://www.macehq.cx
Copyright 1999-2004
See the file README for more information
*/
#ifndef GLOBALS_H
#define GLOBALS_H
#ifndef _MaceTypes
#define _MaceTypes
#include <stdint.h>
typedef uint8_t U8;
typedef int8_t S8;
typedef uint16_t U16;
typedef int16_t S16;
typedef uint32_t U32;
typedef int32_t S32;
#endif
void App_Exit(void);
//Same as App_Exit2(), except that this calls setdis()
void App_Exit2(void);
U16 FlipW(U16 a);
U32 FlipL(U32 a);
void HexW (U16 n, char * String);
void HexL (U32 n, char * String);
#endif //GLOBALS_H
|
Add one more missing function stub | #include "ecore_xcb_private.h"
EAPI Eina_Bool
ecore_x_input_multi_select(Ecore_X_Window win)
{
return 0;
}
EAPI void
ecore_x_e_comp_sync_counter_set(Ecore_X_Window win, Ecore_X_Sync_Counter counter)
{
}
EAPI void
ecore_x_e_comp_sync_draw_done_send(Ecore_X_Window root, Ecore_X_Window win)
{
}
EAPI Eina_Bool
ecore_x_e_comp_sync_supported_get(Ecore_X_Window root)
{
return 0;
}
| #include "ecore_xcb_private.h"
EAPI void
ecore_x_icccm_protocol_atoms_set(Ecore_X_Window win, Ecore_X_Atom *protos, int num)
{
}
EAPI Eina_Bool
ecore_x_input_multi_select(Ecore_X_Window win)
{
return 0;
}
EAPI void
ecore_x_e_comp_sync_counter_set(Ecore_X_Window win, Ecore_X_Sync_Counter counter)
{
}
EAPI void
ecore_x_e_comp_sync_draw_done_send(Ecore_X_Window root, Ecore_X_Window win)
{
}
EAPI Eina_Bool
ecore_x_e_comp_sync_supported_get(Ecore_X_Window root)
{
return 0;
}
|
Convert the remainder of this test case over to using FileCheck. | // RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2> %t
// RUN: grep -F '"-fblocks"' %t
// RUN: grep -F '"-fpascal-strings"' %t
// RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-wchar %s 2> %t
// RUN: grep -F '"-fno-builtin"' %t
// RUN: grep -F '"-fno-common"' %t
// RUN: grep -F '"-fno-math-errno"' %t
// RUN: grep -F '"-fno-show-source-location"' %t
// RUN: grep -F '"-fshort-wchar"' %t
// RUN: clang -fshort-enums -x c /dev/null 2>&1 | FileCheck -check-prefix=CHECK-SHORT-ENUMS %s
// CHECK-SHORT-ENUMS: compiler does not support '-fshort-enums'
| // RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
// RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
// RUN: clang -fshort-enums -x c /dev/null 2>&1 | FileCheck -check-prefix=CHECK-SHORT-ENUMS %s
// CHECK-OPTIONS1: -fblocks
// CHECK-OPTIONS1: -fpascal-strings
// CHECK-OPTIONS2: -fno-builtin
// CHECK-OPTIONS2: -fno-common
// CHECK-OPTIONS2: -fno-math-errno
// CHECK-OPTIONS2: -fno-show-source-location
// CHECL-OPTIONS2: -fshort-wchar
// CHECK-SHORT-ENUMS: compiler does not support '-fshort-enums'
|
Send two packet at once. | #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "gpio.h"
#include "leds.h"
#include "radio.h"
void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
{
led_toggle(i);
nrf_delay_us(50000);
}
}
}
void radio_evt_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
uint32_t err_code;
leds_init();
radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;
radio_init(radio_evt_handler);
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
led_toggle(LED0);
nrf_delay_us(1000000);
}
}
| #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "gpio.h"
#include "leds.h"
#include "radio.h"
void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
{
led_toggle(i);
nrf_delay_us(50000);
}
}
}
void radio_evt_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
uint32_t err_code;
leds_init();
radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;
radio_init(radio_evt_handler);
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
led_toggle(LED0);
nrf_delay_us(1000000);
}
}
|
Add comment to COIN constant. | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CONSENSUS_AMOUNT_H
#define BITCOIN_CONSENSUS_AMOUNT_H
#include <cstdint>
/** Amount in satoshis (Can be negative) */
typedef int64_t CAmount;
static constexpr CAmount COIN = 100000000;
/** No amount larger than this (in satoshi) is valid.
*
* Note that this constant is *not* the total money supply, which in Bitcoin
* currently happens to be less than 21,000,000 BTC for various reasons, but
* rather a sanity check. As this sanity check is used by consensus-critical
* validation code, the exact value of the MAX_MONEY constant is consensus
* critical; in unusual circumstances like a(nother) overflow bug that allowed
* for the creation of coins out of thin air modification could lead to a fork.
* */
static constexpr CAmount MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
#endif // BITCOIN_CONSENSUS_AMOUNT_H
| // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CONSENSUS_AMOUNT_H
#define BITCOIN_CONSENSUS_AMOUNT_H
#include <cstdint>
/** Amount in satoshis (Can be negative) */
typedef int64_t CAmount;
/** The amount of satoshis in one BTC. */
static constexpr CAmount COIN = 100000000;
/** No amount larger than this (in satoshi) is valid.
*
* Note that this constant is *not* the total money supply, which in Bitcoin
* currently happens to be less than 21,000,000 BTC for various reasons, but
* rather a sanity check. As this sanity check is used by consensus-critical
* validation code, the exact value of the MAX_MONEY constant is consensus
* critical; in unusual circumstances like a(nother) overflow bug that allowed
* for the creation of coins out of thin air modification could lead to a fork.
* */
static constexpr CAmount MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
#endif // BITCOIN_CONSENSUS_AMOUNT_H
|
Switch to direct drive on startup | #define DC_BASE_MODE_OFF 0
#define DC_BASE_MODE_NO_GYRO 1
#define DC_BASE_MODE_GYRO 2
#define DC_BASE_MODE_OVER 3
const string dc_base_mode_names[] = {" OFF", "NO GYRO", " GYRO"};
int dc_base_mode = DC_BASE_MODE_GYRO;
void dc_base_mode_next(void);
#define DC_SHOOTER_MODE_NONE 0
#define DC_SHOOTER_MODE_DIRECT 1
#define DC_SHOOTER_MODE_SLIP 2
#define DC_SHOOTER_MODE_KICKER 3
#define DC_SHOOTER_MODE_OVER 4
const string dc_shooter_mode_names[] = {"NONE ", "DIRECT", "SLIP ", "KICKER"};
int dc_shooter_mode = DC_SHOOTER_MODE_NONE;
void dc_shooter_mode_next(void);
| #define DC_BASE_MODE_OFF 0
#define DC_BASE_MODE_NO_GYRO 1
#define DC_BASE_MODE_GYRO 2
#define DC_BASE_MODE_OVER 3
const string dc_base_mode_names[] = {" OFF", "NO GYRO", " GYRO"};
int dc_base_mode = DC_BASE_MODE_GYRO;
void dc_base_mode_next(void);
#define DC_SHOOTER_MODE_NONE 0
#define DC_SHOOTER_MODE_DIRECT 1
#define DC_SHOOTER_MODE_SLIP 2
#define DC_SHOOTER_MODE_KICKER 3
#define DC_SHOOTER_MODE_OVER 4
const string dc_shooter_mode_names[] = {"NONE ", "DIRECT", "SLIP ", "KICKER"};
int dc_shooter_mode = DC_SHOOTER_MODE_DIRECT; // mode on startup
void dc_shooter_mode_next(void);
|
Remove accidental definitions of MyMem_* | #ifndef NUMBA_PY_MODULE_H_
#define NUMBA_PY_MODULE_H_
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <structmember.h>
#include <frameobject.h>
#define MOD_ERROR_VAL NULL
#define MOD_SUCCESS_VAL(val) val
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
#define MOD_DEF(ob, name, doc, methods) { \
static struct PyModuleDef moduledef = { \
PyModuleDef_HEAD_INIT, name, doc, -1, methods, NULL, NULL, NULL, NULL }; \
ob = PyModule_Create(&moduledef); }
#define MOD_INIT_EXEC(name) PyInit_##name();
#define PyString_AsString PyUnicode_AsUTF8
#define PyString_Check PyUnicode_Check
#define PyString_FromFormat PyUnicode_FromFormat
#define PyString_FromString PyUnicode_FromString
#define PyString_InternFromString PyUnicode_InternFromString
#define PyInt_Type PyLong_Type
#define PyInt_Check PyLong_Check
#define PyInt_CheckExact PyLong_CheckExact
#define PyMem_RawMalloc malloc
#define PyMem_RawRealloc realloc
#define PyMem_RawFree free
#endif /* NUMBA_PY_MODULE_H_ */
| #ifndef NUMBA_PY_MODULE_H_
#define NUMBA_PY_MODULE_H_
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <structmember.h>
#include <frameobject.h>
#define MOD_ERROR_VAL NULL
#define MOD_SUCCESS_VAL(val) val
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
#define MOD_DEF(ob, name, doc, methods) { \
static struct PyModuleDef moduledef = { \
PyModuleDef_HEAD_INIT, name, doc, -1, methods, NULL, NULL, NULL, NULL }; \
ob = PyModule_Create(&moduledef); }
#define MOD_INIT_EXEC(name) PyInit_##name();
#define PyString_AsString PyUnicode_AsUTF8
#define PyString_Check PyUnicode_Check
#define PyString_FromFormat PyUnicode_FromFormat
#define PyString_FromString PyUnicode_FromString
#define PyString_InternFromString PyUnicode_InternFromString
#define PyInt_Type PyLong_Type
#define PyInt_Check PyLong_Check
#define PyInt_CheckExact PyLong_CheckExact
#endif /* NUMBA_PY_MODULE_H_ */
|
Use 3 decimal places, the sun uses 32-bit fp_type which chokes with 4. | /**
* \file fixed_point.h
*
*
*
* \author Ethan Burns
* \date 2009-01-16
*/
#include "stdint.h"
#include <limits>
/* The type of a fixed point value. This should never be larger than
* the size of the type for the 'value' field in the AtomicInt
* class. */
typedef unsigned long fp_type;
#define fp_sqrt2 14142
#define fp_one 10000
#define fp_infinity (numeric_limits<fp_type>::max())
| /**
* \file fixed_point.h
*
*
*
* \author Ethan Burns
* \date 2009-01-16
*/
#include "stdint.h"
#include <limits>
/* The type of a fixed point value. This should never be larger than
* the size of the type for the 'value' field in the AtomicInt
* class. */
typedef unsigned long fp_type;
#define fp_sqrt2 1414
#define fp_one 1000
#define fp_infinity (numeric_limits<fp_type>::max())
|
Fix typing mistake. add code formatting. | ////////////////////////////////////////////////////////////////////////////////
//
// TYPHOON FRAMEWORK
// Copyright 2013, Jasper Blues & Contributors
// All Rights Reserved.
//
// NOTICE: The authors permit you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import "CreditService.h"
#import "Pizza.h"
@protocol PizzaFactory <NSObject>
@property (nonatomic, strong, readonly) id<CreditService> creditService;
- (id<Pizza>)pizzaWithRadius:(double)radius ingredients:(NSArray *)ingrendients;
- (id<Pizza>)smallPizzaWithIngredients:(NSArray *)ingredients;
- (id<Pizza>)mediumPizzaWithIngredients:(NSArray *)ingredients;
- (id<Pizza>)largePizzaWithIngredients:(NSArray *)ingredients;
@end
| ////////////////////////////////////////////////////////////////////////////////
//
// TYPHOON FRAMEWORK
// Copyright 2013, Jasper Blues & Contributors
// All Rights Reserved.
//
// NOTICE: The authors permit you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import "CreditService.h"
#import "Pizza.h"
@protocol PizzaFactory <NSObject>
@property(nonatomic, strong, readonly) id <CreditService> creditService;
- (id <Pizza>)pizzaWithRadius:(double)radius ingredients:(NSArray*)ingredients;
- (id <Pizza>)smallPizzaWithIngredients:(NSArray*)ingredients;
- (id <Pizza>)mediumPizzaWithIngredients:(NSArray*)ingredients;
- (id <Pizza>)largePizzaWithIngredients:(NSArray*)ingredients;
@end
|
Add start and stop params to randint | #include <algorithm>
#include <time.h>
template <typename Container1, typename Container2>
bool sequences_are_equal(const Container1& seq1, const Container2& seq2) {
typedef typename Container1::const_iterator Iter1;
typedef typename Container2::const_iterator Iter2;
typedef std::pair<Iter1, Iter2> IterPair;
IterPair mismatch_pair = std::mismatch(seq1.begin(), seq1.end(),
seq2.begin());
return mismatch_pair.first == seq1.end();
}
struct randint {
int range;
public:
randint(int range) : range(range) {}
int operator()() {
return (rand() / RAND_MAX) * range;
}
};
| #include <algorithm>
template <typename Container1, typename Container2>
bool sequences_are_equal(const Container1& seq1, const Container2& seq2) {
typedef typename Container1::const_iterator Iter1;
typedef typename Container2::const_iterator Iter2;
typedef std::pair<Iter1, Iter2> IterPair;
IterPair mismatch_pair = std::mismatch(seq1.begin(), seq1.end(),
seq2.begin());
return mismatch_pair.first == seq1.end();
}
struct randint {
int start;
int stop;
public:
randint(int stop) : start(0), stop(stop) {}
randint(int start, int stop) : start(start), stop(stop) {}
int operator()() {
return rand() % (this->stop - 1) + start;
}
};
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.