Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Remove const modifier from LabelState members. | #ifndef SRC_FORCES_LABEL_STATE_H_
#define SRC_FORCES_LABEL_STATE_H_
#include <Eigen/Core>
#include <string>
#include <map>
namespace Forces
{
class Force;
/**
* \brief Encapsulates state for a label necessary for the simulation
*
* This consists of label and anchor positions in 2D and 3D, as well as
* the label's size, text and its id.
*
* It also stores the last force values for debugging purposes.
*/
class LabelState
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
LabelState(int id, std::string text, Eigen::Vector3f anchorPosition,
Eigen::Vector2f size);
const int id;
Eigen::Vector3f anchorPosition;
Eigen::Vector3f labelPosition;
Eigen::Vector2f size;
Eigen::Vector2f anchorPosition2D;
Eigen::Vector2f labelPosition2D;
float labelPositionDepth;
const std::string text;
std::map<Force *, Eigen::Vector2f> forces;
};
} // namespace Forces
#endif // SRC_FORCES_LABEL_STATE_H_
| #ifndef SRC_FORCES_LABEL_STATE_H_
#define SRC_FORCES_LABEL_STATE_H_
#include <Eigen/Core>
#include <string>
#include <map>
namespace Forces
{
class Force;
/**
* \brief Encapsulates state for a label necessary for the simulation
*
* This consists of label and anchor positions in 2D and 3D, as well as
* the label's size, text and its id.
*
* It also stores the last force values for debugging purposes.
*/
class LabelState
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
LabelState(int id, std::string text, Eigen::Vector3f anchorPosition,
Eigen::Vector2f size);
int id;
Eigen::Vector3f anchorPosition;
Eigen::Vector3f labelPosition;
Eigen::Vector2f size;
Eigen::Vector2f anchorPosition2D;
Eigen::Vector2f labelPosition2D;
float labelPositionDepth;
std::string text;
std::map<Force *, Eigen::Vector2f> forces;
};
} // namespace Forces
#endif // SRC_FORCES_LABEL_STATE_H_
|
Add alg to find repetead values in a matrix | /**
Having fun with multidimensinal arrays.
*/
#include <stdio.h>
/**
TODO: Dada uma matriz inteira Maxb, imprima o número de linhas e colunas
nulas (apenas com valores zerados, matematicamente falando)
da matriz.
*/
#define ROWS_QTT 4
#define COLS_QTT 5
int main(){
/*
Dada uma matriz Amxm, imprima quantas vezes se repete cada valor.
Should be a function like writeRepeatedValuesQtts(args).
*/
int matrix[ROWS_QTT][COLS_QTT] = {
{2, 3, 18, 9, 8},
{1, 15, 2, 9, 6},
{3, 5, 100, 99, 77},
{12, 10, 3, 7, 18}
};
int i, j, k;
char hasFoundRepeteadValue; /* it's a flag! */
int repetitions[ROWS_QTT * COLS_QTT][2]; /* r[0]: repeated number, r[1]: its repeated times */
int repetitionsSize = 0; /* if C doesnt have dinamic sizes, I'll create my own */
for (i = 0; i < ROWS_QTT; i++){
for (j = 0; j < COLS_QTT; j++){
hasFoundRepeteadValue = 0;
/* has this value been stored previously?... */
for (k = 0; k < repetitionsSize; k++){
if (repetitions[k][0] == matrix[i][j]){
/* ... yes! raise our flag and increase the repeated times quantity for this founded number */
hasFoundRepeteadValue = 1;
repetitions[k][1]++;
break;
}
}
if (!hasFoundRepeteadValue){
/* ... no! so it's a new value, store it at a new position and increase the position quantity */
repetitions[repetitionsSize][0] = matrix[i][j];
repetitions[repetitionsSize][1] = 1;
repetitionsSize++;
}
}
}
for(i = 0; i < repetitionsSize; i++){
if (repetitions[i][1] > 1)
printf("%d se repetiu %d vezes.\n", repetitions[i][0], repetitions[i][1]);
}
return 0;
} | |
Revert 75430 because it's causing failures in dom_checker_tests. : Increase the minimum interval for timers on background tabs to reduce their CPU consumption. | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
#define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
namespace webkit_glue {
// Chromium sets the minimum interval timeout to 4ms, overriding the
// default of 10ms. We'd like to go lower, however there are poorly
// coded websites out there which do create CPU-spinning loops. Using
// 4ms prevents the CPU from spinning too busily and provides a balance
// between CPU spinning and the smallest possible interval timer.
const double kForegroundTabTimerInterval = 0.004;
// Provides control over the minimum timer interval for background tabs.
const double kBackgroundTabTimerInterval = 1.0;
} // namespace webkit_glue
#endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
| // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
#define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
namespace webkit_glue {
// Chromium sets the minimum interval timeout to 4ms, overriding the
// default of 10ms. We'd like to go lower, however there are poorly
// coded websites out there which do create CPU-spinning loops. Using
// 4ms prevents the CPU from spinning too busily and provides a balance
// between CPU spinning and the smallest possible interval timer.
const double kForegroundTabTimerInterval = 0.004;
// Provides control over the minimum timer interval for background tabs.
const double kBackgroundTabTimerInterval = 0.004;
} // namespace webkit_glue
#endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
|
Use option + for TAttParticle and TPrimary | /* @(#)root/eg:$Name: $:$Id: LinkDef.h,v 1.2 2000/09/06 15:15:18 brun Exp $ */
/*************************************************************************
* 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 __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TParticle-;
#pragma link C++ class TAttParticle;
#pragma link C++ class TPrimary;
#pragma link C++ class TGenerator-;
#pragma link C++ class TDatabasePDG+;
#pragma link C++ class TParticlePDG+;
#endif
| /* @(#)root/eg:$Name: $:$Id: LinkDef.h,v 1.3 2000/09/08 16:42:12 brun Exp $ */
/*************************************************************************
* 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 __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TParticle-;
#pragma link C++ class TAttParticle+;
#pragma link C++ class TPrimary+;
#pragma link C++ class TGenerator+;
#pragma link C++ class TDatabasePDG+;
#pragma link C++ class TParticlePDG+;
#endif
|
Add regression test for SV-COMP atomics soundness | // PARAM: --enable ana.sv-comp.functions
#include <pthread.h>
#include <assert.h>
extern void __VERIFIER_atomic_begin();
extern void __VERIFIER_atomic_end();
int myglobal = 5;
void *t_fun(void *arg) {
__VERIFIER_atomic_begin();
assert(myglobal == 5); // TODO
myglobal++;
assert(myglobal == 6); // TODO
__VERIFIER_atomic_end();
return NULL;
}
int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
assert(myglobal == 5); // UNKNOWN!
__VERIFIER_atomic_begin();
assert(myglobal == 5); // UNKNOWN!
__VERIFIER_atomic_end();
pthread_join (id, NULL);
return 0;
}
| |
Add <stdlib.h> to GStreamer code | #ifndef SRTP_H
#define SRTP_H
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "srtp2/srtp.h"
typedef struct rtp_packet {
void *data;
int len;
} rtp_packet;
srtp_t *srtp_create_session(void *client_write_key, void *server_write_key, char *profile);
rtp_packet *srtp_decrypt_packet(srtp_t * sess, void *data, int len);
#endif
| #ifndef SRTP_H
#define SRTP_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "srtp2/srtp.h"
typedef struct rtp_packet {
void *data;
int len;
} rtp_packet;
srtp_t *srtp_create_session(void *client_write_key, void *server_write_key, char *profile);
rtp_packet *srtp_decrypt_packet(srtp_t *sess, void *data, int len);
#endif
|
Kill unused DIE_PAGE_FAULT enum value. | #ifndef _SPARC64_KDEBUG_H
#define _SPARC64_KDEBUG_H
/* Nearly identical to x86_64/i386 code. */
#include <linux/notifier.h>
struct pt_regs;
/*
* These are only here because kprobes.c wants them to implement a
* blatant layering violation. Will hopefully go away soon once all
* architectures are updated.
*/
static inline int register_page_fault_notifier(struct notifier_block *nb)
{
return 0;
}
static inline int unregister_page_fault_notifier(struct notifier_block *nb)
{
return 0;
}
extern void bad_trap(struct pt_regs *, long);
/* Grossly misnamed. */
enum die_val {
DIE_OOPS = 1,
DIE_DEBUG, /* ta 0x70 */
DIE_DEBUG_2, /* ta 0x71 */
DIE_DIE,
DIE_TRAP,
DIE_TRAP_TL1,
DIE_CALL,
DIE_PAGE_FAULT,
};
#endif
| #ifndef _SPARC64_KDEBUG_H
#define _SPARC64_KDEBUG_H
/* Nearly identical to x86_64/i386 code. */
#include <linux/notifier.h>
struct pt_regs;
/*
* These are only here because kprobes.c wants them to implement a
* blatant layering violation. Will hopefully go away soon once all
* architectures are updated.
*/
static inline int register_page_fault_notifier(struct notifier_block *nb)
{
return 0;
}
static inline int unregister_page_fault_notifier(struct notifier_block *nb)
{
return 0;
}
extern void bad_trap(struct pt_regs *, long);
/* Grossly misnamed. */
enum die_val {
DIE_OOPS = 1,
DIE_DEBUG, /* ta 0x70 */
DIE_DEBUG_2, /* ta 0x71 */
DIE_DIE,
DIE_TRAP,
DIE_TRAP_TL1,
DIE_CALL,
};
#endif
|
Add example for memory logging support | #define ZF_LOG_LEVEL ZF_LOG_INFO
#define ZF_LOG_TAG "MAIN"
#include <zf_log.h>
int main(int argc, char *argv[])
{
zf_log_set_tag_prefix("hello");
ZF_LOGI("You will see the number of arguments: %i", argc);
ZF_LOGD("You will NOT see the first argument: %s", *argv);
zf_log_set_output_level(ZF_LOG_WARN);
ZF_LOGW("You will see this WARNING message");
ZF_LOGI("You will NOT see this INFO message");
return 0;
}
| #define ZF_LOG_LEVEL ZF_LOG_INFO
#define ZF_LOG_TAG "MAIN"
#include <zf_log.h>
int main(int argc, char *argv[])
{
zf_log_set_tag_prefix("hello");
ZF_LOGI("You will see the number of arguments: %i", argc);
ZF_LOGD("You will NOT see the first argument: %s", *argv);
zf_log_set_output_level(ZF_LOG_WARN);
ZF_LOGW("You will see this WARNING message");
ZF_LOGI("You will NOT see this INFO message");
const char data[] =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Aliquam pharetra orci id velit porttitor tempus.";
ZF_LOGW_MEM(data, sizeof(data), "Lorem ipsum at %p:", data);
return 0;
}
|
Fix misspelling in execrise 2 in chapter 1 | /**
* Exercise 1-2
*
* Experiment to find out what happens when prints's argument string contains \c,
* where c is some character not listed above.
*
* The C Programming Language - the second edition
* by Brian Kernighan and Dennis Ritchie
*
* Author: Li Zhineng <lizhineng@gmail.com>
* URL: https://zhineng.li
* File: 1-2-backslash-c.c
* Date: 2017-01-01
*/
#include <stdio.h>
main()
{
printf("hello, world\n\c");
}
| /**
* Exercise 1-2
*
* Experiment to find out what happens when printfs's argument string contains \c,
* where c is some character not listed above.
*
* The C Programming Language - the second edition
* by Brian Kernighan and Dennis Ritchie
*
* Author: Li Zhineng <lizhineng@gmail.com>
* URL: https://zhineng.li
* File: 1-2-backslash-c.c
* Date: 2017-01-01
*/
#include <stdio.h>
main()
{
printf("hello, world\n\c");
}
|
Add in a bad user option. Exists in GConf but not on the server. | #ifndef __EAS_TEST_USER_H__
#define __EAS_TEST_USER_H__
#define TEST_ACCOUNT_ID ("good.user@cstylianou.com")
// Password: "G00dP@55w0rd"
#endif
| #ifndef __EAS_TEST_USER_H__
#define __EAS_TEST_USER_H__
#define TEST_ACCOUNT_ID ("good.user@cstylianou.com")
// Password: "G00dP@55w0rd"
// #define TEST_ACCOUNT_ID ("bad.user@cstylianou.com")
#endif
|
Add Fatorial Recursica em C | #include<stdio.h>
int fatorial(int n){
if(n==1) return 1;
return (n * fatorial(n-1));
}
int main(){
printf("%d\n", fatorial(5));
return 0;
}
| |
Convert from id to instancetype | #import "AFImageCacheOperation.h"
#pragma mark Type Definitions
// Block that transforms one image into another.
typedef AFImageCacheOperation *(^AFImageCacheOperationCreateBlock)(NSURL *url, AFImageTransform *transform,
NSCache *cache, BOOL refresh, AFImageCompletionBlock completionBlock);
#pragma mark Class Interface
@interface AFImageCache : NSObject
#pragma mark - Properties
// Allows overriding the creation of image cache operations.
@property (nonatomic, copy) AFImageCacheOperationCreateBlock imageCacheOperationCreateBlock;
#pragma mark - Static Methods
+ (id)sharedInstance;
#pragma mark - Instance Methods
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
completionBlock: (AFImageCompletionBlock)completionBlock;
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
refresh: (BOOL)refresh
completionBlock: (AFImageCompletionBlock)completionBlock;
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
transform: (AFImageTransform *)transform
completionBlock: (AFImageCompletionBlock)completionBlock;
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
transform: (AFImageTransform *)transform
refresh: (BOOL)refresh
completionBlock: (AFImageCompletionBlock)completionBlock;
@end // @interface AFImageCache | #import "AFImageCacheOperation.h"
#pragma mark Type Definitions
// Block that transforms one image into another.
typedef AFImageCacheOperation *(^AFImageCacheOperationCreateBlock)(NSURL *url, AFImageTransform *transform,
NSCache *cache, BOOL refresh, AFImageCompletionBlock completionBlock);
#pragma mark Class Interface
@interface AFImageCache : NSObject
#pragma mark - Properties
// Allows overriding the creation of image cache operations.
@property (nonatomic, copy) AFImageCacheOperationCreateBlock imageCacheOperationCreateBlock;
#pragma mark - Static Methods
+ (instancetype)sharedInstance;
#pragma mark - Instance Methods
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
completionBlock: (AFImageCompletionBlock)completionBlock;
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
refresh: (BOOL)refresh
completionBlock: (AFImageCompletionBlock)completionBlock;
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
transform: (AFImageTransform *)transform
completionBlock: (AFImageCompletionBlock)completionBlock;
- (AFImageCacheOperation *)imageWithURL: (NSURL *)url
transform: (AFImageTransform *)transform
refresh: (BOOL)refresh
completionBlock: (AFImageCompletionBlock)completionBlock;
@end // @interface AFImageCache |
Fix test due to mempool internal change. | /* EINA - EFL data type library
* Copyright (C) 2008 Cedric Bail
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#include "Eina.h"
#include "eina_suite.h"
START_TEST(eina_simple)
{
fail_if(!eina_init());
fail_if(eina_shutdown() != 0);
}
END_TEST
void eina_test_main(TCase *tc)
{
tcase_add_test(tc, eina_simple);
}
| /* EINA - EFL data type library
* Copyright (C) 2008 Cedric Bail
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#include "Eina.h"
#include "eina_suite.h"
#include <stdio.h>
START_TEST(eina_simple)
{
/* Eina_error as already been initialized by eina_hash
that was called by eina_mempool_init that's why we don't have 0 here */
fail_if(eina_init() != 2);
fail_if(eina_shutdown() != 1);
}
END_TEST
void eina_test_main(TCase *tc)
{
tcase_add_test(tc, eina_simple);
}
|
Update version string for next RC | /*
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
*************************************************************************
*/
#ifndef _KOPETE_VERSION_H_
#define _KOPETE_VERSION_H_
#define KOPETE_VERSION_STRING "0.40.0"
#define KOPETE_VERSION_MAJOR 0
#define KOPETE_VERSION_MINOR 40
#define KOPETE_VERSION_RELEASE 0
#define KOPETE_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))
#define KOPETE_VERSION \
KOPETE_MAKE_VERSION(KOPETE_VERSION_MAJOR,KOPETE_VERSION_MINOR,KOPETE_VERSION_RELEASE)
#define KOPETE_IS_VERSION(a,b,c) ( KOPETE_VERSION >= KOPETE_MAKE_VERSION(a,b,c) )
#endif // _KOPETE_VERSION_H_
| /*
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
*************************************************************************
*/
#ifndef _KOPETE_VERSION_H_
#define _KOPETE_VERSION_H_
#define KOPETE_VERSION_STRING "0.40.3"
#define KOPETE_VERSION_MAJOR 0
#define KOPETE_VERSION_MINOR 40
#define KOPETE_VERSION_RELEASE 3
#define KOPETE_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))
#define KOPETE_VERSION \
KOPETE_MAKE_VERSION(KOPETE_VERSION_MAJOR,KOPETE_VERSION_MINOR,KOPETE_VERSION_RELEASE)
#define KOPETE_IS_VERSION(a,b,c) ( KOPETE_VERSION >= KOPETE_MAKE_VERSION(a,b,c) )
#endif // _KOPETE_VERSION_H_
|
Include PKCBaseAPI in umbrella header | //
// PodioKitCore.h
// PodioKitCore
//
// Created by Sebastian Rehnby on 12/02/15.
// Copyright (c) 2015 Citrix Systems, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PKCMacros.h"
#import "PKCConstants.h"
#import "PKCClient.h"
#import "PKCRequest.h"
#import "PKCResponse.h"
#import "PKCKeychain.h"
#import "PKCKeychainTokenStore.h"
#import "PKCDatastore.h"
#import "PKCOAuth2Token.h"
#import "PKCFile.h"
#import "PKCPushCredential.h"
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#import "PKCFile+UIImage.h"
#import "UIButton+PKCRemoteImage.h"
#import "UIImageView+PKCRemoteImage.h"
#endif | //
// PodioKitCore.h
// PodioKitCore
//
// Created by Sebastian Rehnby on 12/02/15.
// Copyright (c) 2015 Citrix Systems, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PKCMacros.h"
#import "PKCConstants.h"
#import "PKCClient.h"
#import "PKCRequest.h"
#import "PKCResponse.h"
#import "PKCKeychain.h"
#import "PKCKeychainTokenStore.h"
#import "PKCDatastore.h"
#import "PKCBaseAPI.h"
#import "PKCOAuth2Token.h"
#import "PKCFile.h"
#import "PKCPushCredential.h"
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#import "PKCFile+UIImage.h"
#import "UIButton+PKCRemoteImage.h"
#import "UIImageView+PKCRemoteImage.h"
#endif |
Test optional Armv8.5-A random number extension | // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+rng %s 2>&1 | FileCheck %s
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+rng %s 2>&1 | FileCheck %s
// CHECK: "-target-feature" "+rand"
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+norng %s 2>&1 | FileCheck %s --check-prefix=NORAND
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+norng %s 2>&1 | FileCheck %s --check-prefix=NORAND
// NORAND: "-target-feature" "-rand"
// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENTRAND
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a %s 2>&1 | FileCheck %s --check-prefix=ABSENTRAND
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a %s 2>&1 | FileCheck %s --check-prefix=ABSENTRAND
// ABSENTRAND-NOT: "-target-feature" "+rand"
// ABSENTRAND-NOT: "-target-feature" "-rand"
| |
Fix call convention for wglGetProcAddress on Windows-i686 | #ifndef _GLIMPL_H_
#define _GLIMPL_H_
#ifndef GLFUNC_MAGIC_START
#include "fptr_struct.h"
#endif
#define GET_GLIMPL_VARIABLE(_name_) \
(((struct glimpl *)DATA_PTR(obj))->_name_)
#define SET_GLIMPL_VARIABLE(_name_,_val_) \
((struct glimpl *)DATA_PTR(obj))->_name_ = (_val_)
/* at least GL_MAX_VERTEX_ATTRIBS - usually 16 or 32 on today's high-end cards */
#define _MAX_VERTEX_ATTRIBS 64
extern VALUE g_default_glimpl;
struct glimpl {
struct glfunc_ptrs glfuncs;
int opengl_version[2]; /* major, minor */
char *opengl_extensions;
void * (* load_gl_function)(VALUE self, const char *name,int raise);
VALUE current_feed_buffer;
VALUE current_sel_buffer;
VALUE Vertex_ptr;
VALUE Normal_ptr;
VALUE Color_ptr;
VALUE Index_ptr;
VALUE TexCoord_ptr;
VALUE EdgeFlag_ptr;
VALUE FogCoord_ptr; /* OpenGL 1.4 */
VALUE SecondaryColor_ptr; /* OpenGL 1.4 */
VALUE VertexAttrib_ptr[_MAX_VERTEX_ATTRIBS];
VALUE error_checking;
VALUE inside_begin_end;
void *dl;
void * (* fptr_GetProcAddress)(const char *name);
};
#endif /* _GLIMPL_H_ */
| #ifndef _GLIMPL_H_
#define _GLIMPL_H_
#ifndef GLFUNC_MAGIC_START
#include "fptr_struct.h"
#endif
#define GET_GLIMPL_VARIABLE(_name_) \
(((struct glimpl *)DATA_PTR(obj))->_name_)
#define SET_GLIMPL_VARIABLE(_name_,_val_) \
((struct glimpl *)DATA_PTR(obj))->_name_ = (_val_)
/* at least GL_MAX_VERTEX_ATTRIBS - usually 16 or 32 on today's high-end cards */
#define _MAX_VERTEX_ATTRIBS 64
extern VALUE g_default_glimpl;
struct glimpl {
struct glfunc_ptrs glfuncs;
int opengl_version[2]; /* major, minor */
char *opengl_extensions;
void * (* load_gl_function)(VALUE self, const char *name,int raise);
VALUE current_feed_buffer;
VALUE current_sel_buffer;
VALUE Vertex_ptr;
VALUE Normal_ptr;
VALUE Color_ptr;
VALUE Index_ptr;
VALUE TexCoord_ptr;
VALUE EdgeFlag_ptr;
VALUE FogCoord_ptr; /* OpenGL 1.4 */
VALUE SecondaryColor_ptr; /* OpenGL 1.4 */
VALUE VertexAttrib_ptr[_MAX_VERTEX_ATTRIBS];
VALUE error_checking;
VALUE inside_begin_end;
void *dl;
void * (APIENTRY * fptr_GetProcAddress)(const char *name);
};
#endif /* _GLIMPL_H_ */
|
Fix Android x86_64 build when using traditional headers | // Copyright 2017 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CRASHPAD_COMPAT_ANDROID_SYS_USER_H_
#define CRASHPAD_COMPAT_ANDROID_SYS_USER_H_
// This is needed for traditional headers.
#include <sys/types.h>
#include_next <sys/user.h>
#endif // CRASHPAD_COMPAT_ANDROID_SYS_USER_H_
| |
Add comment for constant PARSE_SUCCESS | // Copyright 2016 Mitchell Kember. Subject to the MIT License.
#ifndef PARSE_H
#define PARSE_H
#include "expr.h"
#define PARSE_SUCCESS (-1)
// ParseResult contains the result of parsing text. The 'expr' field has a
// meaningful value if and only if 'err_type' is PARSE_SUCCESS.
struct ParseResult {
size_t chars_read; // number of characters read
struct Expression expr; // parsed expression
int err_type; // PARSE_SUCCESS or a ParseErrorType value
};
// Parses a string as an s-expression of pairs, symbols, and numbers. On
// success, returns the parse result with 'err_type' set to PARSE_SUCCESS.
// Otherwise, returns a ParseErrorType in the result.
struct ParseResult parse(const char *text);
#endif
| // Copyright 2016 Mitchell Kember. Subject to the MIT License.
#ifndef PARSE_H
#define PARSE_H
#include "expr.h"
// Constant indicating that a parse was successful.
#define PARSE_SUCCESS (-1)
// ParseResult contains the result of parsing text. The 'expr' field has a
// meaningful value if and only if 'err_type' is PARSE_SUCCESS.
struct ParseResult {
size_t chars_read; // number of characters read
struct Expression expr; // parsed expression
int err_type; // PARSE_SUCCESS or a ParseErrorType value
};
// Parses a string as an s-expression of pairs, symbols, and numbers. On
// success, returns the parse result with 'err_type' set to PARSE_SUCCESS.
// Otherwise, returns a ParseErrorType in the result.
struct ParseResult parse(const char *text);
#endif
|
Define _NETBSD_SOURCE macro to make 'strndup' declaration visible on NetBSD | //
// substr.c
// AnsiLove/C
//
// Copyright (C) 2011-2016 Stefan Vogt, Brian Cassidy, Frederic Cambus.
// All rights reserved.
//
// This source code is licensed under the BSD 3-Clause License.
// See the file LICENSE for details.
//
#define _XOPEN_SOURCE 700
#include <string.h>
char *substr(char *str, size_t begin, size_t len)
{
if (str == 0 || strlen(str) == 0)
return 0;
return strndup(str + begin, len);
}
| //
// substr.c
// AnsiLove/C
//
// Copyright (C) 2011-2016 Stefan Vogt, Brian Cassidy, Frederic Cambus.
// All rights reserved.
//
// This source code is licensed under the BSD 3-Clause License.
// See the file LICENSE for details.
//
#define _XOPEN_SOURCE 700
#define _NETBSD_SOURCE
#include <string.h>
char *substr(char *str, size_t begin, size_t len)
{
if (str == 0 || strlen(str) == 0)
return 0;
return strndup(str + begin, len);
}
|
Move operator| in details namespace | #pragma once
#include <utility>
#include <pipe/traits.h>
namespace pipe { namespace algorithm {
template <typename Generator, typename Algorithm, typename _ = std::enable_if<pipe::is_generator<Generator>::value>::type>
auto operator|(Generator& gen, Algorithm algorithm)
{
return algorithm(std::move(gen));
}
}} // namespace pipe::algorithm
| #pragma once
#include <utility>
#include <pipe/traits.h>
namespace pipe { namespace algorithm { namespace details {
template <typename Generator, typename Algorithm, typename _ = std::enable_if<pipe::is_generator<Generator>::value>::type>
auto operator|(Generator& gen, Algorithm algorithm)
{
return algorithm(std::move(gen));
}
}}} // namespace pipe::algorithm::details
|
Add a slight bit more functionality to the UART echo app so that it can blink some lights with numerical inputs. This can help determine whether or not the AVR is receiving the correct data, even though it is echoing it back anyway. | #include <avr/interrupt.h>
#include "uart.h"
int main (void) {
uart_enable(UM_Asynchronous);
sei();
unsigned char c = 0;
do {
c = uart_receive();
uart_transmit(c);
} while (c);
return 0;
}
| #include <avr/interrupt.h>
#include <util/delay.h>
#include "uart.h"
int main (void) {
uart_enable(UM_Asynchronous);
sei();
DDRB = 0xFF;
unsigned char c = 0;
do {
c = uart_receive();
// Do some blinking if we receive a number between 1 and 9.
if (c >= '1' && c <= '9') {
for (int i = 0; i < (c-'0'); ++i) {
PORTB = 0xFF;
_delay_ms(100);
PORTB = 0x00;
_delay_ms(100);
}
}
uart_transmit(c);
} while (1);
return 0;
}
|
Add feature to on-demand reactify classes | //
// MTRReactiveEngine.h
// Reactor
//
// Created by Ty Cobb on 1/15/15.
// Copyright (c) 2015 cobb. All rights reserved.
//
@import Foundation;
@interface MTRReactiveEngine : NSObject
/**
@brief Adds reactivity to marked classes
Sweeps the class list for classes adopting @c MTRReactive, and swizzles their
property setters/getters to add reactivity.
*/
+ (void)engage;
@end
| //
// MTRReactiveEngine.h
// Reactor
//
// Created by Ty Cobb on 1/15/15.
// Copyright (c) 2015 cobb. All rights reserved.
//
@import Foundation;
@protocol MTRReactive;
@interface MTRReactiveEngine : NSObject
/**
@brief Adds reactivity to marked classes
Sweeps the class list for classes adopting @c MTRReactive, and swizzles their
property setters/getters to add reactivity.
*/
+ (void)engage;
/**
@brief Manually adds reactivity to marked classes
Use this method if you want to have on-demand reactification.
*/
+ (void)reactify:(Class<MTRReactive>)klass;
@end
|
Update comment to reflect dictionary layout. | //
// PluginDelegate.h
// arc
//
// Created by Yong Michael on 6/4/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ArcAttributedString.h"
#import "File.h"
typedef enum {
kMCQSettingType,
kRangeSettingType,
kBoolSettingType
} kSettingType;
@protocol PluginDelegate <NSObject>
// Returns an array of NSStrings
// eg: [@"fontFamily", @"fontSize"]
@property (nonatomic, strong) NSArray *settingKeys;
// Returns a NSDictionary of properties for setting
// eg: [pluginInstance propertiesFor:@"fontFamily"]
// returns:
// {
// type: kMCQSettingType,
// values: [A, B, C, D]
// }
- (NSDictionary *)propertiesFor:(NSString *)settingKey;
// Returns Default Value for given setting
- (id<NSObject>)defaultValueFor:(NSString *)settingKey;
// Exec Method (Middleware)
+ (void)arcAttributedString:(ArcAttributedString*)arcAttributedString
ofFile:(id<File>)file
delegate:(id)delegate;
@end
| //
// PluginDelegate.h
// arc
//
// Created by Yong Michael on 6/4/13.
// Copyright (c) 2013 nus.cs3217. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ArcAttributedString.h"
#import "File.h"
typedef enum {
kMCQSettingType,
kRangeSettingType,
kBoolSettingType
} kSettingType;
@protocol PluginDelegate <NSObject>
// Returns an array of NSStrings
// eg: [@"fontFamily", @"fontSize"]
@property (nonatomic, strong) NSArray *settingKeys;
// Returns a NSDictionary of properties for setting
// eg: [pluginInstance propertiesFor:@"fontFamily"]
// returns:
// {
// type: kMCQSettingType,
// labels: ["Inconsolata", "Source Code Pro", "Ubuntu Monospace"]
// values: ["Inconsolata", "SourceCodePro-Regular", "Ubuntu Mono Regular"]
// }
- (NSDictionary *)propertiesFor:(NSString *)settingKey;
// Returns Default Value for given setting
- (id<NSObject>)defaultValueFor:(NSString *)settingKey;
// Exec Method (Middleware)
+ (void)arcAttributedString:(ArcAttributedString*)arcAttributedString
ofFile:(id<File>)file
delegate:(id)delegate;
@end
|
Define a struct to represent 2d positions. | #include <stdlib.h>
/**
* @author: Hendrik Werner
*/
int main() {
return EXIT_SUCCESS;
}
| #include <stdlib.h>
/**
* @author: Hendrik Werner
*/
typedef struct Position {
int row;
int col;
} Position;
int main() {
return EXIT_SUCCESS;
}
|
Allow for building index on the outside. | // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "dense_tensor.h"
namespace vespalib::tensor {
/**
* Class for building a dense tensor by inserting cell values directly into underlying array of cells.
*/
class DirectDenseTensorBuilder
{
public:
using Cells = DenseTensor::Cells;
using Address = DenseTensor::Address;
private:
eval::ValueType _type;
Cells _cells;
static size_t calculateCellAddress(const Address &address, const eval::ValueType &type) {
size_t result = 0;
for (size_t i = 0; i < address.size(); ++i) {
result *= type.dimensions()[i].size;
result += address[i];
}
return result;
}
public:
DirectDenseTensorBuilder(const eval::ValueType &type_in);
~DirectDenseTensorBuilder();
void insertCell(const Address &address, double cellValue) {
_cells[calculateCellAddress(address, _type)] = cellValue;
}
Tensor::UP build();
};
}
| // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "dense_tensor.h"
namespace vespalib::tensor {
/**
* Class for building a dense tensor by inserting cell values directly into underlying array of cells.
*/
class DirectDenseTensorBuilder
{
public:
using Cells = DenseTensor::Cells;
using Address = DenseTensor::Address;
private:
eval::ValueType _type;
Cells _cells;
static size_t calculateCellAddress(const Address &address, const eval::ValueType &type) {
size_t result = 0;
for (size_t i = 0; i < address.size(); ++i) {
result *= type.dimensions()[i].size;
result += address[i];
}
return result;
}
public:
DirectDenseTensorBuilder(const eval::ValueType &type_in);
~DirectDenseTensorBuilder();
void insertCell(const Address &address, double cellValue) {
insertCell(calculateCellAddress(address, _type), cellValue);
}
void insertCell(size_t index, double cellValue) {
_cells[index] = cellValue;
}
Tensor::UP build();
};
}
|
Fix terminal widget on Spark Core | /**
* @file WidgetTerminal.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief
*/
#ifndef WidgetTerminal_h
#define WidgetTerminal_h
#include <Print.h>
#include <Blynk/BlynkApi.h>
class WidgetTerminal
: public Print
{
public:
WidgetTerminal(int vPin)
: mPin(vPin), mOutQty(0)
{}
virtual size_t write(uint8_t byte) {
mOutBuf[mOutQty++] = byte;
if (mOutQty >= sizeof(mOutBuf)) {
flush();
}
return 1;
}
void flush() {
if (mOutQty) {
Blynk.virtualWrite(mPin, mOutBuf, mOutQty);
mOutQty = 0;
}
}
using Print::write;
private:
uint8_t mPin;
uint8_t mOutBuf[32];
uint8_t mOutQty;
};
#endif
| /**
* @file WidgetTerminal.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief
*/
#ifndef WidgetTerminal_h
#define WidgetTerminal_h
#include <Print.h>
#if !defined(SPARK) // On Spark this is auto-included
#include <Blynk/BlynkApi.h>
#endif
class WidgetTerminal
: public Print
{
public:
WidgetTerminal(int vPin)
: mPin(vPin), mOutQty(0)
{}
virtual size_t write(uint8_t byte) {
mOutBuf[mOutQty++] = byte;
if (mOutQty >= sizeof(mOutBuf)) {
flush();
}
return 1;
}
void flush() {
if (mOutQty) {
Blynk.virtualWrite(mPin, mOutBuf, mOutQty);
mOutQty = 0;
}
}
using Print::write;
private:
uint8_t mPin;
uint8_t mOutBuf[32];
uint8_t mOutQty;
};
#endif
|
Add the necessary includes and forward declarations such that the class can be compiled independently. | // @(#)root/meta:$Name: $:$Id: TVirtualIsAProxy.h,v 1.1 2005/05/27 16:42:58 pcanal Exp $
// Author: Markus Frank 20/05/2005
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TVirtualIsAProxy
#define ROOT_TVirtualIsAProxy
//////////////////////////////////////////////////////////////////////////
// //
// TClass //
// //
// Virtual IsAProxy base class. //
// //
//////////////////////////////////////////////////////////////////////////
class TVirtualIsAProxy {
public:
virtual ~TVirtualIsAProxy() { }
virtual void SetClass(TClass *cl) = 0;
virtual TClass* operator()(const void *obj) = 0;
};
#endif // ROOT_TVirtualIsAProxy
| // @(#)root/meta:$Name: $:$Id: TVirtualIsAProxy.h,v 1.2 2005/06/08 18:51:36 rdm Exp $
// Author: Markus Frank 20/05/2005
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TVirtualIsAProxy
#define ROOT_TVirtualIsAProxy
//////////////////////////////////////////////////////////////////////////
// //
// TClass //
// //
// Virtual IsAProxy base class. //
// //
//////////////////////////////////////////////////////////////////////////
class TClass;
class TVirtualIsAProxy {
public:
virtual ~TVirtualIsAProxy() { }
virtual void SetClass(TClass *cl) = 0;
virtual TClass* operator()(const void *obj) = 0;
};
#endif // ROOT_TVirtualIsAProxy
|
Include URL in common includes | //
// KBSCloudApp.h
//
// Created by Keith Smiley
// Copyright (c) 2013 Keith Smiley. All rights reserved.
//
#ifndef _KBSCLOUDAPP_
#define _KBSCLOUDAPP_
#import "KBSCloudAppUser.h"
#import "KBSCloudAppAPI.h"
NS_ENUM(NSInteger, KBSCloudAppAPIErrorCode) {
KBSCloudAppNoUserOrPass,
KBSCloudAppAPIInvalidUser,
KBSCloudAppInternalError
};
static NSString * const KBSCloudAppAPIErrorDomain = @"com.keithsmiley.cloudappapi";
static NSString * const baseAPI = @"http://my.cl.ly/";
static NSString * const baseShortURL = @"cl.ly";
static NSString * const itemsPath = @"items";
static NSString * const accountPath = @"account";
#endif
| //
// KBSCloudApp.h
//
// Created by Keith Smiley
// Copyright (c) 2013 Keith Smiley. All rights reserved.
//
#ifndef _KBSCLOUDAPP_
#define _KBSCLOUDAPP_
#import "KBSCloudAppUser.h"
#import "KBSCloudAppAPI.h"
#import "KBSCloudAppURL.h"
NS_ENUM(NSInteger, KBSCloudAppAPIErrorCode) {
KBSCloudAppNoUserOrPass,
KBSCloudAppAPIInvalidUser,
KBSCloudAppInternalError
};
static NSString * const KBSCloudAppAPIErrorDomain = @"com.keithsmiley.cloudappapi";
static NSString * const baseAPI = @"http://my.cl.ly/";
static NSString * const baseShortURL = @"cl.ly";
static NSString * const itemsPath = @"items";
static NSString * const accountPath = @"account";
#endif
|
Use the full UUID for the K20DX | /* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "MK20D5.h"
#include "read_uid.h"
void read_unique_id(uint32_t * id) {
*id = SIM->UIDL ^ SIM->UIDML ^ SIM->UIDMH ^ SIM->UIDH;
}
| /* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "MK20D5.h"
#include "read_uid.h"
void read_unique_id(uint32_t * id) {
id[0] = SIM->UIDL;
id[1] = SIM->UIDML;
id[2] = SIM->UIDMH;
id[3] = SIM->UIDH;
}
|
Add support for openbsd, test on openbsd 6.8 | #include <fcntl.h>
#include <kvm.h>
#include <sys/sysctl.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
int main(int argc,char** args) {
kvm_t* kd;
// Get a handle to libkvm interface
kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "error: ");
pid_t pid;
pid = getpid();
struct kinfo_proc * kp;
int p_count;
// Get the kinfo_proc2 for this process by its pid
kp = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &p_count);
printf("got %i kinfo_proc2 for pid %i\n", p_count, pid);
// /usr/include/sys/sysctl.h details the kinfo_proc2 struct
time_t proc_start_time;
proc_start_time = kp->p_ustart_sec;
kvm_close(kd);
printf("sleeping for 15 seconds\n");
sleep(15);
printf("Process started at %s\n", ctime(&proc_start_time));
time_t current_time;
current_time = time(NULL);
printf("Current time after nap %s\n", ctime(¤t_time));
return 0;
}
| |
Fix speed of ultrasonic display | /*==============================================================================================*/
/*==============================================================================================*/
#include "QuadCopterConfig.h"
/* Connection methods of Ultrasonic */
#define ULT_USE_UART2 1
#define ULT_USE_PWM 0
Ultrasonic_t Ultrasonic = {
.lenHigh = 0,
.lenLow = 0,
.d = 0
};
/*==============================================================================================*/
/*==============================================================================================*
**函數 : us100_distant
**功能 : get 1 calculated distant data from the data received by USART
**輸入 : Ultrasonic.lenHigh, Ultrasonic.lenLow
**輸出 : Ultrasonic.d (mm)
**使用 : print_us100_distant();
**==============================================================================================*/
/*==============================================================================================*/
void print_us100_distance(){
#if ULT_USE_UART2
serial2.putc('U');
vTaskDelay(500);
Ultrasonic.lenHigh = serial2.getc();
Ultrasonic.lenLow = serial2.getc();
Ultrasonic.d = (Ultrasonic.lenHigh*256 + Ultrasonic.lenLow)*0.1;
serial.printf("Distance: ");
serial.printf("%d",Ultrasonic.d);
serial.printf(" cm\n\r");
vTaskDelay(30);
#endif
}
| /*==============================================================================================*/
/*==============================================================================================*/
#include "QuadCopterConfig.h"
/* Connection methods of Ultrasonic */
#define ULT_USE_UART2 1
#define ULT_USE_PWM 0
Ultrasonic_t Ultrasonic = {
.lenHigh = 0,
.lenLow = 0,
.d = 0
};
/*==============================================================================================*/
/*==============================================================================================*
**函數 : us100_distant
**功能 : get 1 calculated distant data from the data received by USART
**輸入 : Ultrasonic.lenHigh, Ultrasonic.lenLow
**輸出 : Ultrasonic.d (mm)
**使用 : print_us100_distant();
**==============================================================================================*/
/*==============================================================================================*/
void print_us100_distance(){
#if ULT_USE_UART2
serial2.putc('U');
vTaskDelay(70);
Ultrasonic.lenHigh = serial2.getc();
Ultrasonic.lenLow = serial2.getc();
Ultrasonic.d = (Ultrasonic.lenHigh*256 + Ultrasonic.lenLow)*0.1;
serial.printf("Distance: ");
serial.printf("%d",Ultrasonic.d);
serial.printf(" cm\n\r");
vTaskDelay(30);
#endif
}
|
Test for trim functions added. | #include <stdio.h>
#include <axis2_error_default.h>
#include <axis2_log.h>
#include <axis2_string.h>
void test_strltrim(const axis2_env_t *env)
{
axis2_char_t s[100]=" abcd efgh ";
axis2_char_t *trimmed;
trimmed = AXIS2_STRLTRIM(s, " \t\r\n");
if (0 == AXIS2_STRCMP(trimmed, "abcd efgh "))
printf("AXIS2_STRLTRIM successful\n");
else
printf("AXIS2_STRLTRIM failed [%s]\n", trimmed);
}
void test_strrtrim(const axis2_env_t *env)
{
axis2_char_t s[100]=" abcd efgh ";
axis2_char_t *trimmed;
trimmed = AXIS2_STRRTRIM(s, " \t\r\n");
if (0 == AXIS2_STRCMP(trimmed, " abcd efgh"))
printf("AXIS2_STRRTRIM successful\n");
else
printf("AXIS2_STRRTRIM failed [%s]\n", trimmed);
}
void test_strtrim(const axis2_env_t *env)
{
axis2_char_t s[100]=" abcd efgh ";
axis2_char_t *trimmed;
trimmed = AXIS2_STRTRIM(s, " \t\r\n");
if (0 == AXIS2_STRCMP(trimmed, "abcd efgh"))
printf("AXIS2_STRTRIM successful\n");
else
printf("AXIS2_STRTRIM failed [%s]\n", trimmed);
}
void run_test_string(axis2_env_t *env)
{
if (!env)
return;
test_strltrim(env);
test_strrtrim(env);
test_strtrim(env);
}
| |
Fix mouse position over an `S2D_FIXED` viewport | // input.c
#include "../include/simple2d.h"
/*
* Get the mouse coordinates relative to the viewport
*/
void S2D_GetMouseOnViewport(S2D_Window *window, int wx, int wy, int *x, int *y) {
double scale; // viewport scale factor
int w, h; // width and height of scaled viewport
switch (window->viewport.mode) {
case S2D_FIXED:
*x = wx; *y = wy;
break;
case S2D_SCALE:
S2D_GL_GetViewportScale(window, &w, &h, &scale);
*x = wx * 1 / scale - (window->width - w) / (2.0 * scale);
*y = wy * 1 / scale - (window->height - h) / (2.0 * scale);
break;
case S2D_STRETCH:
*x = wx * window->viewport.width / (double)window->width;
*y = wy * window->viewport.height / (double)window->height;
break;
}
}
| // input.c
#include "../include/simple2d.h"
/*
* Get the mouse coordinates relative to the viewport
*/
void S2D_GetMouseOnViewport(S2D_Window *window, int wx, int wy, int *x, int *y) {
double scale; // viewport scale factor
int w, h; // width and height of scaled viewport
switch (window->viewport.mode) {
case S2D_FIXED:
*x = wx / (window->orig_width / (double)window->viewport.width);
*y = wy / (window->orig_height / (double)window->viewport.height);
break;
case S2D_SCALE:
S2D_GL_GetViewportScale(window, &w, &h, &scale);
*x = wx * 1 / scale - (window->width - w) / (2.0 * scale);
*y = wy * 1 / scale - (window->height - h) / (2.0 * scale);
break;
case S2D_STRETCH:
*x = wx * window->viewport.width / (double)window->width;
*y = wy * window->viewport.height / (double)window->height;
break;
}
}
|
Add Diagonal Diff for NxN matrix | /*
Input Format
The first line contains a single integer N. The next N lines contain N integers (each) describing the matrix.
Constraints
1≤N≤100
−100≤A[i]≤100
Output Format
Output a single integer equal to the absolute difference in the sums across the diagonals.
Sample Input
3
11 2 4
4 5 6
10 8 -12
Sample Output
15
Explanation
The first diagonal of the matrix is:
11
5
-12
Sum across the first diagonal = 11+5-12= 4
The second diagonal of the matrix is:
4
5
10
Sum across the second diagonal = 4+5+10 = 19
Difference: |4-19| =15
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n,i,j;
scanf("%d",&n);
int A[n][n];
int d1=0;
int d2=0;
for(i=0; i<n ; i++){
for(j=0; j<n; j++){
scanf("%d ",&A[i][j]);
}
}
for(i=0; i<n ;i++){
d1 = d1 + A[i][i];
d2 = d2 + A[i][n-1-i];
}
printf("%d\n", abs(d1-d2));
return 0;
}
| |
Add standalone test for Vale SHA2-256 | #include "sha256_main_i.h"
int main()
{
uint8_t plaintext[3U] = { (uint8_t)0x61U, (uint8_t)0x62U, (uint8_t)0x63U };
uint32_t plaintext_len = (uint32_t)3U;
uint32_t output[8];
uint32_t output_len = (uint32_t)32U;
/*
// This is equivalent to what sha256_main_i_SHA256_Complete does:
uint32_t h[8];
uint8_t unprocessed[64];
sha256_main_i_SHA256Context ctx;
ctx.H = h;
ctx.unprocessed_bytes = unprocessed;
ctx.num_unprocessed_bytes = 0;
ctx.num_total_bytes = 0;
sha256_main_i_SHA256_Init(&ctx);
sha256_main_i_SHA256_Update(&ctx, plaintext, 0, 3);
sha256_main_i_SHA256_Final(&ctx, output);
*/
sha256_main_i_SHA256_Complete(plaintext, 0, 3, output);
/*
// Reverse byte order of 4-byte chunks of output
for (int i = 0; i < 8; i++) {
uint32_t v = ((uint32_t *) output)[i];
output[i * 4] = v >> 24;
output[i * 4 + 1] = v >> 16;
output[i * 4 + 2] = v >> 8;
output[i * 4 + 3] = v;
}
*/
printf("Expected digest : ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad\n");
printf("4-byte chunks of digest as uint32_t's: ");
for (int i = 0; i < 8; i++) {
printf("%02x", ((uint32_t *) output)[i]);
}
printf("\n");
printf("Digest byte by byte : ");
for (int i = 0; i < 32; i++) {
printf("%02x", ((uint8_t *) output)[i]);
}
printf("\n");
return 0;
}
| |
Fix misleading dbl header include protection test. | /*
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
* Licenced under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
*/
#include <stdio.h>
#ifndef _LIBNSGIF_LOG_H_
#define _LIBNSGIF_LOG_H_
#ifdef NDEBUG
# define LOG(x) ((void) 0)
#else
# ifdef __GNUC__
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
# elif defined(__CC_NORCROFT)
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
# else
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
# endif
#endif
#endif
| /*
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
* Licenced under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
*/
#include <stdio.h>
#ifndef _LIBNSBMP_LOG_H_
#define _LIBNSBMP_LOG_H_
#ifdef NDEBUG
# define LOG(x) ((void) 0)
#else
# ifdef __GNUC__
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
# elif defined(__CC_NORCROFT)
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
# else
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
# endif
#endif
#endif
|
Fix regresscapi. This file wasn't checked in | #include <stdio.h>
#include "c_interface.h"
int main() {
VC vc = vc_createValidityChecker();
vc_setFlags(vc,'n');
vc_setFlags(vc,'d');
vc_setFlags(vc,'p');
vc_setFlags(vc,'m');
Expr q;
Expr asserts;
const char* s = "(benchmark fg.smt\n"
":logic QF_AUFBV\n"
":extrafuns ((x_32 BitVec[32]))\n"
":extrafuns ((y32 BitVec[32]))\n"
":assumption true\n)\n";
vc_parseMemExpr(vc,s,&q,&asserts);
vc_printExpr(vc, q);
vc_printExpr(vc, asserts);
printf("\n");
vc_Destroy(vc);
}
| |
Convert BUG() to use unreachable() | #ifndef __ASM_BUG_H
#define __ASM_BUG_H
#include <linux/compiler.h>
#include <asm/sgidefs.h>
#ifdef CONFIG_BUG
#include <asm/break.h>
static inline void __noreturn BUG(void)
{
__asm__ __volatile__("break %0" : : "i" (BRK_BUG));
/* Fool GCC into thinking the function doesn't return. */
while (1)
;
}
#define HAVE_ARCH_BUG
#if (_MIPS_ISA > _MIPS_ISA_MIPS1)
static inline void __BUG_ON(unsigned long condition)
{
if (__builtin_constant_p(condition)) {
if (condition)
BUG();
else
return;
}
__asm__ __volatile__("tne $0, %0, %1"
: : "r" (condition), "i" (BRK_BUG));
}
#define BUG_ON(C) __BUG_ON((unsigned long)(C))
#define HAVE_ARCH_BUG_ON
#endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */
#endif
#include <asm-generic/bug.h>
#endif /* __ASM_BUG_H */
| #ifndef __ASM_BUG_H
#define __ASM_BUG_H
#include <linux/compiler.h>
#include <asm/sgidefs.h>
#ifdef CONFIG_BUG
#include <asm/break.h>
static inline void __noreturn BUG(void)
{
__asm__ __volatile__("break %0" : : "i" (BRK_BUG));
unreachable();
}
#define HAVE_ARCH_BUG
#if (_MIPS_ISA > _MIPS_ISA_MIPS1)
static inline void __BUG_ON(unsigned long condition)
{
if (__builtin_constant_p(condition)) {
if (condition)
BUG();
else
return;
}
__asm__ __volatile__("tne $0, %0, %1"
: : "r" (condition), "i" (BRK_BUG));
}
#define BUG_ON(C) __BUG_ON((unsigned long)(C))
#define HAVE_ARCH_BUG_ON
#endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */
#endif
#include <asm-generic/bug.h>
#endif /* __ASM_BUG_H */
|
Check magic and output header fields | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "scp.h"
unsigned char scp_processheader(FILE *scpfile)
{
return 0;
}
void scp_processtrack(FILE *scpfile, const unsigned char track)
{
}
int main(int argc, char **argv)
{
unsigned char numtracks;
unsigned char track;
FILE *fp;
if (argc!=2)
{
printf("Specify .scp on command line\n");
return 1;
}
fp=fopen(argv[1], "rb");
if (fp==NULL)
{
printf("Unable to open file\n");
return 2;
}
numtracks=scp_processheader(fp);
for (track=0; track<numtracks; track++)
scp_processtrack(fp, track);
fclose(fp);
return 0;
}
| #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "scp.h"
struct scp_header header;
unsigned char scp_processheader(FILE *scpfile)
{
fread(&header, 1, sizeof(header), scpfile);
if (strncmp((char *)&header.magic, SCP_MAGIC, strlen(SCP_MAGIC))!=0)
{
printf("Not an SCP file\n");
return 0;
}
printf("SCP magic detected\n");
printf("Version: %d.%d\n", header.version>>4, header.version&0x0f);
printf("Disk type: %d %d\n", header.disktype>>4, header.disktype&0x0f);
printf("Revolutions: %d\n", header.revolutions);
printf("Tracks: %d to %d\n", header.starttrack, header.endtrack);
printf("Flags: 0x%.2x\n", header.flags);
printf("Bitcell encoding: %d bits\n", header.bitcellencoding==0?16:header.bitcellencoding);
printf("Heads: %d\n", header.heads);
printf("Resolution: %dns\n", (header.resolution+1)*SCP_BASE_NS);
printf("Checksum: 0x%.8x\n", header.checksum);
printf("Tracks in SCP: %d\n", header.endtrack-header.starttrack);
return 0;
}
void scp_processtrack(FILE *scpfile, const unsigned char track)
{
}
int main(int argc, char **argv)
{
unsigned char numtracks;
unsigned char track;
FILE *fp;
if (argc!=2)
{
printf("Specify .scp on command line\n");
return 1;
}
fp=fopen(argv[1], "rb");
if (fp==NULL)
{
printf("Unable to open file\n");
return 2;
}
numtracks=scp_processheader(fp);
for (track=0; track<numtracks; track++)
scp_processtrack(fp, track);
fclose(fp);
return 0;
}
|
Include UIKit to h file, because change pch to h for two files in main project and refactor all needed includes. | //
// MFSideMenuShadow.h
// MFSideMenuDemoSearchBar
//
// Created by Michael Frederick on 5/13/13.
// Copyright (c) 2013 Frederick Development. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MFSideMenuShadow : NSObject
@property (nonatomic, assign) BOOL enabled;
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, assign) CGFloat opacity;
@property (nonatomic, strong) UIColor *color;
@property (nonatomic, assign) UIView *shadowedView;
+ (MFSideMenuShadow *)shadowWithView:(UIView *)shadowedView;
+ (MFSideMenuShadow *)shadowWithColor:(UIColor *)color radius:(CGFloat)radius opacity:(CGFloat)opacity;
- (void)draw;
- (void)shadowedViewWillRotate;
- (void)shadowedViewDidRotate;
@end
| //
// MFSideMenuShadow.h
// MFSideMenuDemoSearchBar
//
// Created by Michael Frederick on 5/13/13.
// Copyright (c) 2013 Frederick Development. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface MFSideMenuShadow : NSObject
@property (nonatomic, assign) BOOL enabled;
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, assign) CGFloat opacity;
@property (nonatomic, strong) UIColor *color;
@property (nonatomic, assign) UIView *shadowedView;
+ (MFSideMenuShadow *)shadowWithView:(UIView *)shadowedView;
+ (MFSideMenuShadow *)shadowWithColor:(UIColor *)color radius:(CGFloat)radius opacity:(CGFloat)opacity;
- (void)draw;
- (void)shadowedViewWillRotate;
- (void)shadowedViewDidRotate;
@end
|
Add collection of basic BLE types shared accross all layers. | /* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
*
* 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 BLE_TYPES_H_
#define BLE_TYPES_H_
#include <stddef.h>
#include <stdint.h>
namespace ble {
/**
* A connection handle is an unsigned integer capable of holding a pointer.
* The real type (either a pointer to an object or an integer) is opaque and
* platform dependent.
*/
typedef uintptr_t connection_handle_t;
/**
* Model an attribute handle in a GATT database.
*/
typedef uint16_t attribute_handle_t;
/**
* Model an inclusive range of GATT attributes handles.
*/
struct attribute_handle_range_t {
attribute_handle_t begin;
attribute_handle_t end;
friend bool operator==(
const attribute_handle_range_t& lhs, const attribute_handle_range_t& rhs
) {
return (lhs.begin == rhs.begin) && (lhs.end == rhs.end);
}
friend bool operator!=(
const attribute_handle_range_t& lhs, const attribute_handle_range_t& rhs
) {
return !(lhs == rhs);
}
};
/**
* Construct an attribute_handle_range_t from its start and end handle.
* @note This function is defined instead of a constructor to keep "POD-ness"
* of attribute_handle_range_t.
*/
static inline attribute_handle_range_t attribute_handle_range(
attribute_handle_t begin,
attribute_handle_t end
) {
attribute_handle_range_t result = {
begin,
end
};
return result;
}
} // namespace ble
#endif /* BLE_TYPES_H_ */
| |
Add tests for new Neon vector type attributes. | // RUN: %clang_cc1 %s -fsyntax-only -verify
typedef float float32_t;
typedef signed char poly8_t;
typedef short poly16_t;
typedef unsigned long long uint64_t;
// Define some valid Neon types.
typedef __attribute__((neon_vector_type(2))) int int32x2_t;
typedef __attribute__((neon_vector_type(4))) int int32x4_t;
typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t;
// The attributes must have a single argument.
typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{attribute requires 1 argument(s)}}
// The number of elements must be an ICE.
typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{attribute requires integer constant}}
// Only certain element types are allowed.
typedef __attribute__((neon_vector_type(2))) double double_elt; // expected-error{{invalid vector element type}}
typedef __attribute__((neon_vector_type(4))) void* ptr_elt; // expected-error{{invalid vector element type}}
typedef __attribute__((neon_polyvector_type(4))) float32_t bad_poly_elt; // expected-error{{invalid vector element type}}
struct aggr { signed char c; };
typedef __attribute__((neon_vector_type(8))) struct aggr aggregate_elt; // expected-error{{invalid vector element type}}
// The total vector size must be 64 or 128 bits.
typedef __attribute__((neon_vector_type(1))) int int32x1_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
typedef __attribute__((neon_vector_type(3))) int int32x3_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
| |
Use `using` instead of `typedef` | // MIT License
// Copyright (c) 2017 Zhuhao Wang
// 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.
#pragma once
#include <system_error>
namespace nekit {
namespace utils {
typedef std::error_code Error;
} // namespace utils
} // namespace nekit
| // MIT License
// Copyright (c) 2017 Zhuhao Wang
// 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.
#pragma once
#include <system_error>
namespace nekit {
namespace utils {
using Error = std::error_code;
} // namespace utils
} // namespace nekit
|
Rename Kernel setter methods arguments | /*
* kernel.h - base kernel class
* @author Vyacheslav Kompan kompan.vo@phystech.edu
* Copyright 2018 MIPT-MIPS
*/
#ifndef KERNEL_H
#define KERNEL_H
/* Simulator modules */
#include <memory/memory.h>
#include <simulator.h>
/* Generic C++ */
#include <memory>
class Kernel {
std::weak_ptr<Simulator> sim;
std::shared_ptr<FuncMemory> mem;
public:
static std::shared_ptr<Kernel> create_kernel() {
return std::make_shared<Kernel>();
}
void set_simulator( std::shared_ptr<Simulator> sim) { this->sim = sim; }
void set_memory( std::shared_ptr<FuncMemory> mem) { this->mem = std::move( mem); }
/* Return false if simulator should be stopped, e.g. on 'exit' syscall */
virtual bool execute() { return true; }
Kernel() = default;
Kernel( const Kernel&) = delete;
Kernel( Kernel&&) = delete;
Kernel operator=( const Kernel&) = delete;
Kernel operator=( Kernel&&) = delete;
};
#endif //KERNEL_H
| /*
* kernel.h - base kernel class
* @author Vyacheslav Kompan kompan.vo@phystech.edu
* Copyright 2018 MIPT-MIPS
*/
#ifndef KERNEL_H
#define KERNEL_H
/* Simulator modules */
#include <memory/memory.h>
#include <simulator.h>
/* Generic C++ */
#include <memory>
class Kernel {
std::weak_ptr<Simulator> sim;
std::shared_ptr<FuncMemory> mem;
public:
static std::shared_ptr<Kernel> create_kernel() {
return std::make_shared<Kernel>();
}
void set_simulator( std::shared_ptr<Simulator> s) { sim = s; }
void set_memory( std::shared_ptr<FuncMemory> m) { mem = std::move( m); }
/* Return false if simulator should be stopped, e.g. on 'exit' syscall */
virtual bool execute() { return true; }
Kernel() = default;
Kernel( const Kernel&) = delete;
Kernel( Kernel&&) = delete;
Kernel operator=( const Kernel&) = delete;
Kernel operator=( Kernel&&) = delete;
};
#endif //KERNEL_H
|
Move various multi-dispatch data structures into a header file, plus way that we'll be able to get at the dispatcher list, dispatcher info stash and so forth. | /* This is how a Code looks on the inside. Once again, C struct that should
* match what P6opaque computes for the Code class. */
typedef struct {
PMC *st; /* S-table, though we don't care about that here. */
PMC *sc; /* Serialization context, though we don't care about that here. */
PMC *spill; /* Attribute spill storage. */
PMC *_do; /* Lower-level code object. */
PMC *signature; /* Signature object. */
PMC *dispatchees; /* List of dispatchees, if any. */
PMC *dispatcher_info; /* Holder for any extra dispatcher info. */
} Rakudo_Code;
/* Represents a candidate. We extract various bits of information about it when
* we are building the sorted candidate list and store them in here for fast
* access during a dispatch. */
typedef struct {
PMC *sub; /* The sub that is the candidate. */
PMC *signature; /* The signature of the sub. */
PMC **types; /* Class or role type constraints for each parameter. */
PMC **constraints; /* Refinement type constraints for each parameter. */
INTVAL num_types; /* Number of entries in the above two arrays. */
INTVAL min_arity; /* Number of required positional arguments. */
INTVAL max_arity; /* Number of required and optional positional arguments. */
INTVAL bind_check; /* A true value if any parameters have constraints and/or are named. */
STRING *req_named; /* Name of one required named argument, if any. This is to allow us
* to quickly rule out candidates disambiguated by a required named
* argument, as is the common case for traits. */
} Rakudo_md_candidate_info;
/* Overall multi-dispatcher info, which we will hang off the dispatcher
* info slot in a dispatcher sub. */
typedef struct {
Rakudo_md_candidate_info **candidates;
/* XXX TODO: Cache goes here also. */
} Rakudo_md_info;
/* Represents the produced information about a candidate as well as the graph
* edges originating from it. The edges array contains pointers to the edges
* in the graph that we have arrows to. */
typedef struct candidate_graph_node {
Rakudo_md_candidate_info *info;
struct candidate_graph_node **edges;
INTVAL edges_in;
INTVAL edges_out;
} Rakudo_md_candidate_graph_node;
| |
Remove use of g_set_prgname in main(). | #include "config.h"
#include <glib.h>
#include <telepathy-glib/run.h>
#include <telepathy-glib/debug.h>
#include "salut-connection-manager.h"
#include "salut-avahi-discovery-client.h"
#include "debug.h"
static TpBaseConnectionManager *
salut_create_connection_manager (void)
{
return TP_BASE_CONNECTION_MANAGER (
g_object_new (SALUT_TYPE_CONNECTION_MANAGER,
"backend-type", SALUT_TYPE_AVAHI_DISCOVERY_CLIENT,
NULL));
}
int
main (int argc, char **argv)
{
g_type_init ();
g_thread_init (NULL);
g_set_prgname ("telepathy-salut");
#ifdef ENABLE_DEBUG
tp_debug_divert_messages (g_getenv ("SALUT_LOGFILE"));
debug_set_flags_from_env ();
if (g_getenv ("SALUT_PERSIST"))
tp_debug_set_persistent (TRUE);
#endif
return tp_run_connection_manager ("telepathy-salut", VERSION,
salut_create_connection_manager,
argc, argv);
}
| #include "config.h"
#include <glib.h>
#include <telepathy-glib/run.h>
#include <telepathy-glib/debug.h>
#include "salut-connection-manager.h"
#include "salut-avahi-discovery-client.h"
#include "debug.h"
static TpBaseConnectionManager *
salut_create_connection_manager (void)
{
return TP_BASE_CONNECTION_MANAGER (
g_object_new (SALUT_TYPE_CONNECTION_MANAGER,
"backend-type", SALUT_TYPE_AVAHI_DISCOVERY_CLIENT,
NULL));
}
int
main (int argc, char **argv)
{
g_type_init ();
g_thread_init (NULL);
#ifdef ENABLE_DEBUG
tp_debug_divert_messages (g_getenv ("SALUT_LOGFILE"));
debug_set_flags_from_env ();
if (g_getenv ("SALUT_PERSIST"))
tp_debug_set_persistent (TRUE);
#endif
return tp_run_connection_manager ("telepathy-salut", VERSION,
salut_create_connection_manager,
argc, argv);
}
|
Fix public/private members and doxygen comments | #ifndef PAWN_STRUCTURE_GENE_H
#define PAWN_STRUCTURE_GENE_H
#include <string>
#include <map>
#include "Genes/Gene.h"
#include "Game/Piece.h"
#include "Game/Color.h"
class Board;
class Pawn_Structure_Gene : public Clonable_Gene<Pawn_Structure_Gene>
{
public:
Pawn_Structure_Gene() noexcept;
std::string name() const noexcept override;
double score_board(const Board& board, Piece_Color perspective, size_t depth, double game_progress) const noexcept override;
private:
double opening_guarded_by_pawn = 1.0;
double opening_guarded_by_pawn_in_one_move = 1.0;
double opening_guarded_by_piece = 1.0;
double endgame_guarded_by_pawn = 1.0;
double endgame_guarded_by_pawn_in_one_move = 1.0;
double endgame_guarded_by_piece = 1.0;
void gene_specific_mutation() noexcept override;
void adjust_properties(std::map<std::string, double>& properties) const noexcept override;
void load_gene_properties(const std::map<std::string, double>& properties) override;
void normalize_guard_scores() noexcept;
};
#endif // PAWN_STRUCTURE_GENE_H
| #ifndef PAWN_STRUCTURE_GENE_H
#define PAWN_STRUCTURE_GENE_H
#include <string>
#include <map>
#include "Genes/Gene.h"
#include "Game/Piece.h"
#include "Game/Color.h"
class Board;
//! \brief A gene to evaluate how well pawns are protected.
class Pawn_Structure_Gene : public Clonable_Gene<Pawn_Structure_Gene>
{
public:
Pawn_Structure_Gene() noexcept;
std::string name() const noexcept override;
private:
double opening_guarded_by_pawn = 1.0;
double opening_guarded_by_pawn_in_one_move = 1.0;
double opening_guarded_by_piece = 1.0;
double endgame_guarded_by_pawn = 1.0;
double endgame_guarded_by_pawn_in_one_move = 1.0;
double endgame_guarded_by_piece = 1.0;
double score_board(const Board& board, Piece_Color perspective, size_t depth, double game_progress) const noexcept override;
void gene_specific_mutation() noexcept override;
void adjust_properties(std::map<std::string, double>& properties) const noexcept override;
void load_gene_properties(const std::map<std::string, double>& properties) override;
void normalize_guard_scores() noexcept;
};
#endif // PAWN_STRUCTURE_GENE_H
|
Change name of parameter in bubbleSort | /* Author: Dan Wilder
*
* School: University of Missouri - St. Louis
* Semester: Fall 2015
* Class: CS 3130 - Design and Analysis of Algorithms
* Instructor: Galina N. Piatnitskaia
*/
#include "sort_algorithms.h"
void swap(int *x, int *y) {
int temp = *x;
*x = *y
*y = temp;
}
void bubbleSort(int arr[], int n) {
/* with swaps counting. n is the size of arr.
*/
int i, j;
for (i = 0; i <= n-1; ++i)
for (j = n; j >= i+1; --j)
if (arr[j] < arr[j-1])
swap(&arr[j], &arr[j-1]);
}
| /* Author: Dan Wilder
*
* School: University of Missouri - St. Louis
* Semester: Fall 2015
* Class: CS 3130 - Design and Analysis of Algorithms
* Instructor: Galina N. Piatnitskaia
*/
#include "sort_algorithms.h"
void swap(int *x, int *y) {
int temp = *x;
*x = *y
*y = temp;
}
void bubbleSort(int arr[], int size) {
/* with swaps counting.
*/
int i, j;
for (i = 0; i <= size-1; ++i)
for (j = size; j >= i+1; --j)
if (arr[j] < arr[j-1])
swap(&arr[j], &arr[j-1]);
}
|
Update type in SettingsService callback. | /*
Copyright 2012 Moblico Solutions LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this work except in compliance with the License.
You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#import <MoblicoSDK/MLCService.h>
@class MLCSettings;
NS_ASSUME_NONNULL_BEGIN
typedef void(^MLCSettingsServiceCompletionHandler)(id _Nullable MLCSettings, NSError * _Nullable error, NSHTTPURLResponse * _Nullable response);
@interface MLCSettingsService : MLCService
+ (instancetype)readSettings:(MLCSettingsServiceCompletionHandler)handler;
+ (MLCSettings *)settings;
+ (void)overrideSettings:(nullable NSDictionary *)settings;
@end
@interface MLCSettings : NSObject
- (nullable id)objectForKey:(NSString *)key;
- (nullable id)objectForKeyedSubscript:(NSString *)key;
@end
NS_ASSUME_NONNULL_END
| /*
Copyright 2012 Moblico Solutions LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this work except in compliance with the License.
You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#import <MoblicoSDK/MLCService.h>
@class MLCSettings;
NS_ASSUME_NONNULL_BEGIN
typedef void(^MLCSettingsServiceCompletionHandler)(MLCSettings * _Nullable MLCSettings, NSError * _Nullable error, NSHTTPURLResponse * _Nullable response);
@interface MLCSettingsService : MLCService
+ (instancetype)readSettings:(MLCSettingsServiceCompletionHandler)handler;
+ (MLCSettings *)settings;
+ (void)overrideSettings:(nullable NSDictionary *)settings;
@end
@interface MLCSettings : NSObject
- (nullable id)objectForKey:(NSString *)key;
- (nullable id)objectForKeyedSubscript:(NSString *)key;
@end
NS_ASSUME_NONNULL_END
|
Add getter for lua state | //
// Created by Dawid Drozd aka Gelldur on 08.10.17.
//
#pragma once
#include <map>
#include <string>
#include <vector>
#include <bee/Beehive.h>
namespace cocos2d
{
class CCNode;
}
namespace Bee
{
class Graph;
class Node;
class Cocos2dxBeehive
{
public:
Cocos2dxBeehive(const std::vector<std::string>& searchPaths);
~Cocos2dxBeehive();
cocos2d::CCNode* createView(const std::string& content);
cocos2d::CCNode* findViewById(const std::string& id);
private:
Graph* _graph;
std::shared_ptr<sel::State> _state;
Bee::Beehive _beehive;
void addRelation(Node* nodeParent, Node* nodeChild);
};
}
| //
// Created by Dawid Drozd aka Gelldur on 08.10.17.
//
#pragma once
#include <map>
#include <string>
#include <vector>
#include <bee/Beehive.h>
namespace cocos2d
{
class CCNode;
}
namespace Bee
{
class Graph;
class Node;
class Cocos2dxBeehive
{
public:
Cocos2dxBeehive(const std::vector<std::string>& searchPaths);
~Cocos2dxBeehive();
cocos2d::CCNode* createView(const std::string& content);
cocos2d::CCNode* findViewById(const std::string& id);
const std::shared_ptr<sel::State>& getState()
{
return _state;
}
private:
Graph* _graph;
std::shared_ptr<sel::State> _state;
Bee::Beehive _beehive;
void addRelation(Node* nodeParent, Node* nodeChild);
};
}
|
Fix OnLoad signature and configure command parameters properly | #include "redismodule.h"
#include <stdlib.h>
int HelloworldRand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
RedisModule_ReplyWithLongLong(ctx,rand());
return REDISMODULE_OK;
}
int RedisModule_OnLoad(RedisModuleCtx *ctx) {
if (RedisModule_Init(ctx,"testmodule",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedisModule_CreateCommand(ctx,"testmodule.simple",
HelloworldRand_RedisCommand,
"write deny-oom",1,2,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
} | #include "redismodule.h"
#include <stdlib.h>
int HelloworldRand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
RedisModule_ReplyWithLongLong(ctx,rand());
return REDISMODULE_OK;
}
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
if (RedisModule_Init(ctx,"testmodule",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedisModule_CreateCommand(ctx,"testmodule.simple",
HelloworldRand_RedisCommand,
"readonly",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
} |
Add skipped base union field pointer unsoundness test | // SKIP
// TODO: be sound and claim that assert may hold instead of must not hold
// assert passes when compiled
#include <assert.h>
union u {
int fst;
float snd;
};
int main() {
union u a;
void *p = &a.fst;
void *q = &a.snd;
assert(p == q);
return 0;
}
| |
Fix a typo in the VMOV implementation. | //
// arch/x86_64/rsp/vmov.c
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "common.h"
#include "rsp/cpu.h"
#include "rsp/rsp.h"
__m128i rsp_vmov(struct rsp *rsp,
unsigned src, unsigned e, unsigned dest, unsigned de) {
uint16_t data;
// Get the element from VT.
data = rsp->cp2.div_in = rsp->cp2.regs[src].e[e];
// Write out the upper part of the result.
rsp->cp2.regs[dest].e[de] = data;
return rsp_vect_load_unshuffled_operand(rsp->cp2.regs[dest].e);
}
| //
// arch/x86_64/rsp/vmov.c
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "common.h"
#include "rsp/cpu.h"
#include "rsp/rsp.h"
__m128i rsp_vmov(struct rsp *rsp,
unsigned src, unsigned e, unsigned dest, unsigned de) {
uint16_t data;
// Get the element from VT.
data = rsp->cp2.regs[src].e[e];
// Write out the upper part of the result.
rsp->cp2.regs[dest].e[de] = data;
return rsp_vect_load_unshuffled_operand(rsp->cp2.regs[dest].e);
}
|
Change the ilst content (2) | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_trmsignalhook.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ncoden <ncoden@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/05/14 17:12:55 by ncoden #+# #+# */
/* Updated: 2015/05/18 16:04:52 by ncoden ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_trmsignalhook(t_trm *trm, char sig, void (*func)(void *),
void *data)
{
t_ilst_evnt *event;
if ((event = (t_ilst_evnt *)ft_ilstpushfront__(sizeof(t_ilst_evnt),
(t_ilst **)&trm->on_signal, sig)))
{
event->event.func = func;
event->event.data = data;
}
}
| /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_trmsignalhook.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ncoden <ncoden@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/05/14 17:12:55 by ncoden #+# #+# */
/* Updated: 2015/05/23 23:50:08 by ncoden ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_trmsignalhook(t_trm *trm, char sig, void (*func)(void *),
void *data)
{
t_ilst_evnt *event;
if ((event = (t_ilst_evnt *)ft_ilstpush__(sizeof(t_ilst_evnt),
(t_ilst **)&trm->on_signal, sig)))
{
event->event.func = func;
event->event.data = data;
}
}
|
Use QString() as default paramater for an empty string | /*
* Copyright (C) 2014 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* 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 DATABASE_H
#define DATABASE_H
#include <QtCore>
#include "appstream-qt_global.h"
#include "component.h"
namespace Appstream {
class DatabasePrivate;
class ASQTSHARED_EXPORT Database : public QObject
{
Q_OBJECT
public:
Database(QObject *parent = 0);
~Database();
bool open();
Component* getComponentById(QString id);
QList<Component*> getAllComponents();
QList<Component*> getComponentsByKind(Component::Kind kind);
QList<Component*> findComponentsByString(QString searchTerms, QString categories = "");
private:
DatabasePrivate *priv;
};
} // End of namespace: Appstream
#endif // DATABASE_H
| /*
* Copyright (C) 2014 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* 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 DATABASE_H
#define DATABASE_H
#include <QtCore>
#include "appstream-qt_global.h"
#include "component.h"
namespace Appstream {
class DatabasePrivate;
class ASQTSHARED_EXPORT Database : public QObject
{
Q_OBJECT
public:
Database(QObject *parent = 0);
~Database();
bool open();
Component* getComponentById(QString id);
QList<Component*> getAllComponents();
QList<Component*> getComponentsByKind(Component::Kind kind);
QList<Component*> findComponentsByString(QString searchTerms, QString categories = QString());
private:
DatabasePrivate *priv;
};
} // End of namespace: Appstream
#endif // DATABASE_H
|
Fix stupid error for Linux build. | // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_GPU_GPU_CONFIG_H_
#define CHROME_GPU_GPU_CONFIG_H_
// This file declares common preprocessor configuration for the GPU process.
#include "build/build_config.h"
#if defined(OS_LINUX) && !defined(ARCH_CPU_X86)
// Only define GLX support for Intel CPUs for now until we can get the
// proper dependencies and build setup for ARM.
#define GPU_USE_GLX
#endif
#endif // CHROME_GPU_GPU_CONFIG_H_
| // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_GPU_GPU_CONFIG_H_
#define CHROME_GPU_GPU_CONFIG_H_
// This file declares common preprocessor configuration for the GPU process.
#include "build/build_config.h"
#if defined(OS_LINUX) && defined(ARCH_CPU_X86)
// Only define GLX support for Intel CPUs for now until we can get the
// proper dependencies and build setup for ARM.
#define GPU_USE_GLX
#endif
#endif // CHROME_GPU_GPU_CONFIG_H_
|
Improve a macro to reference its parameter | #ifndef _AL_THUNK_H_
#define _AL_THUNK_H_
#include "config.h"
#include "AL/al.h"
#include "AL/alc.h"
#ifdef __cplusplus
extern "C" {
#endif
void alThunkInit(void);
void alThunkExit(void);
ALuint alThunkAddEntry(ALvoid * ptr);
void alThunkRemoveEntry(ALuint index);
ALvoid *alThunkLookupEntry(ALuint index);
#if (SIZEOF_VOIDP > SIZEOF_UINT)
#define ALTHUNK_INIT() alThunkInit()
#define ALTHUNK_EXIT() alThunkExit()
#define ALTHUNK_ADDENTRY(p) alThunkAddEntry(p)
#define ALTHUNK_REMOVEENTRY(i) alThunkRemoveEntry(i)
#define ALTHUNK_LOOKUPENTRY(i) alThunkLookupEntry(i)
#else
#define ALTHUNK_INIT()
#define ALTHUNK_EXIT()
#define ALTHUNK_ADDENTRY(p) ((ALuint)p)
#define ALTHUNK_REMOVEENTRY(i)
#define ALTHUNK_LOOKUPENTRY(i) ((ALvoid*)(i))
#endif // (SIZEOF_VOIDP > SIZEOF_INT)
#ifdef __cplusplus
}
#endif
#endif //_AL_THUNK_H_
| #ifndef _AL_THUNK_H_
#define _AL_THUNK_H_
#include "config.h"
#include "AL/al.h"
#include "AL/alc.h"
#ifdef __cplusplus
extern "C" {
#endif
void alThunkInit(void);
void alThunkExit(void);
ALuint alThunkAddEntry(ALvoid *ptr);
void alThunkRemoveEntry(ALuint index);
ALvoid *alThunkLookupEntry(ALuint index);
#if (SIZEOF_VOIDP > SIZEOF_UINT)
#define ALTHUNK_INIT() alThunkInit()
#define ALTHUNK_EXIT() alThunkExit()
#define ALTHUNK_ADDENTRY(p) alThunkAddEntry(p)
#define ALTHUNK_REMOVEENTRY(i) alThunkRemoveEntry(i)
#define ALTHUNK_LOOKUPENTRY(i) alThunkLookupEntry(i)
#else
#define ALTHUNK_INIT()
#define ALTHUNK_EXIT()
#define ALTHUNK_ADDENTRY(p) ((ALuint)p)
#define ALTHUNK_REMOVEENTRY(i) ((ALvoid)i)
#define ALTHUNK_LOOKUPENTRY(i) ((ALvoid*)(i))
#endif // (SIZEOF_VOIDP > SIZEOF_INT)
#ifdef __cplusplus
}
#endif
#endif //_AL_THUNK_H_
|
Allow for messages in HistFactory exceptions. | // @(#)root/roostats:$Id$
// Author: George Lewis, Kyle Cranmer
/*************************************************************************
* Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef HISTFACTORY_EXCEPTION
#define HISTFACTORY_EXCEPTION
#include <iostream>
#include <exception>
namespace RooStats{
namespace HistFactory{
class hf_exc: public std::exception
{
virtual const char* what() const noexcept
{
return "HistFactory - Exception";
}
};
}
}
//static hf_exc bad_hf;
#endif
| // @(#)root/roostats:$Id$
// Author: George Lewis, Kyle Cranmer
/*************************************************************************
* Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef HISTFACTORY_EXCEPTION
#define HISTFACTORY_EXCEPTION
#include <exception>
#include <string>
namespace RooStats{
namespace HistFactory{
class hf_exc: public std::exception
{
public:
hf_exc(std::string message = "") : _message("HistFactory - Exception " + message) { }
virtual const char* what() const noexcept
{
return _message.c_str();
}
private:
const std::string _message;
};
}
}
#endif
|
Make draft compile with ZeroMQ 4.3.0 | #if ZMQ_VERSION_MINOR == 2
#ifdef ZMQ_BUILD_DRAFT_API
#define ZMQ42HASDRAFT
#endif
#endif
#ifndef ZMQ42HASDRAFT
#define ZMQ_SERVER -12
#define ZMQ_CLIENT -13
#define ZMQ_RADIO -14
#define ZMQ_DISH -15
#define ZMQ_GATHER -16
#define ZMQ_SCATTER -17
#define ZMQ_DGRAM -18
#endif
| #if ZMQ_VERSION_MINOR >= 2
#ifdef ZMQ_BUILD_DRAFT_API
#define ZMQ42HASDRAFT
#endif
#endif
#ifndef ZMQ42HASDRAFT
#define ZMQ_SERVER -12
#define ZMQ_CLIENT -13
#define ZMQ_RADIO -14
#define ZMQ_DISH -15
#define ZMQ_GATHER -16
#define ZMQ_SCATTER -17
#define ZMQ_DGRAM -18
#endif
|
Add some comments to explain why the DMA32 physseg is really 2**31 bytes long. Prompted by deraadt@ long ago. | /* $OpenBSD: vmparam.h,v 1.3 2009/05/08 18:42:04 miod Exp $ */
#ifndef _SGI_VMPARAM_H_
#define _SGI_VMPARAM_H_
#define VM_PHYSSEG_MAX 32 /* Max number of physical memory segments */
#define VM_NFREELIST 2
#define VM_FREELIST_DMA32 1 /* memory under 2GB suitable for DMA */
#include <mips64/vmparam.h>
#endif /* _SGI_VMPARAM_H_ */
| /* $OpenBSD: vmparam.h,v 1.4 2009/10/14 20:18:26 miod Exp $ */
/* public domain */
#ifndef _SGI_VMPARAM_H_
#define _SGI_VMPARAM_H_
#define VM_PHYSSEG_MAX 32 /* Max number of physical memory segments */
/*
* On Origin and Octane families, DMA to 32-bit PCI devices is restricted.
*
* Systems with physical memory after the 2GB boundary needs to ensure
* memory which may used for DMA transfers is allocated from the low
* memory range.
*
* Other systems, like the O2, do not have such a restriction, but can not
* have more than 2GB of physical memory, so this doesn't affect them.
*/
#define VM_NFREELIST 2
#define VM_FREELIST_DMA32 1 /* memory suitable for 32-bit DMA */
#include <mips64/vmparam.h>
#endif /* _SGI_VMPARAM_H_ */
|
Reduce nap time to 15 minutes as mentioned in docs | /* See LICENSE file for copyright and license details. */
/* Notification, remove DNOTIFY in config.mk if you don't want it */
static char *notifycmd = ""; /* Uses given command if not compiled by DNOTIFY */
static char *notifyext = ""; /* Notify with extra command (eg. play an alarm) */
/*
* This is the array which defines all the timer that will be used.
* It will be repeated after all of it is executed.
*/
static Timers timers[] = {
/* timer(s) comment */
{ 1500, "Time to start working!"},
{ 300, "Time to start resting!"},
{ 1500, "Time to start working!"},
{ 300, "Time to start resting!"},
{ 1500, "Time to start working!"},
{ 300, "Time to start resting!"},
{ 1500, "Time to start working!"},
{ 1200, "Time to take a nap!" },
};
| /* See LICENSE file for copyright and license details. */
/* Notification, remove DNOTIFY in config.mk if you don't want it */
static char *notifycmd = ""; /* Uses given command if not compiled by DNOTIFY */
static char *notifyext = ""; /* Notify with extra command (eg. play an alarm) */
/*
* This is the array which defines all the timer that will be used.
* It will be repeated after all of it is executed.
*/
static Timers timers[] = {
/* timer(s) comment */
{ 1500, "Time to start working!"},
{ 300, "Time to start resting!"},
{ 1500, "Time to start working!"},
{ 300, "Time to start resting!"},
{ 1500, "Time to start working!"},
{ 300, "Time to start resting!"},
{ 1500, "Time to start working!"},
{ 900, "Time to take a nap!" },
};
|
Add a test to the previous commit. | // RUN: %clang_cc1 -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o %t %s
void *f0()
{
return __builtin_thread_pointer();
}
| // RUN: %clang_cc1 -Wall -Werror -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o - %s | FileCheck %s
void *f0()
{
return __builtin_thread_pointer();
}
void f1(char *a, char *b) {
__clear_cache(a,b);
}
// CHECK: call void @__clear_cache
|
Use new api for terminal tests | #include "test_parser_p.h"
void terminal_success(void **state) {
grammar_t *grammar = grammar_init(
non_terminal("HelloWorld"),
rule_init("HelloWorld",
terminal("hello world")
), 1
);
parse_t *result = parse("hello world", grammar);
assert_int_equal(result->length, 11);
assert_int_equal(result->start, 0);
assert_int_equal(result->n_children, 1);
assert_int_equal(result->children[0].n_children, 0);
}
void terminal_failure(void **state) {
grammar_t *grammar = grammar_init(
non_terminal("HelloWorld"),
rule_init("HelloWorld",
terminal("hello world")
), 1
);
parse_t *result = parse("nope", grammar);
assert_null(result);
}
| #include "test_parser_p.h"
void terminal_success(void **state) {
grammar_t *grammar = grammar_init(
non_terminal("HelloWorld"),
rule_init("HelloWorld",
terminal("hello world")
), 1
);
parse_result_t *result = parse("hello world", grammar);
assert_non_null(result);
assert_true(is_success(result));
parse_t *suc = result->data.result;
assert_int_equal(suc->length, 11);
assert_int_equal(suc->start, 0);
assert_int_equal(suc->n_children, 1);
assert_int_equal(suc->children[0].n_children, 0);
}
void terminal_failure(void **state) {
grammar_t *grammar = grammar_init(
non_terminal("HelloWorld"),
rule_init("HelloWorld",
terminal("hello world")
), 1
);
parse_result_t *result = parse("nope", grammar);
assert_non_null(result);
assert_true(is_error(result));
}
|
Print times in fixed columns. | #include <time.h>
clock_t calc_time0,calc_time1;
double calc_time;
#define TIME_ON calc_time0=clock();
#define TIME_OFF(msg) calc_time1=clock(); \
calc_time=(double)(calc_time1-calc_time0)/CLOCKS_PER_SEC; \
std::cout<<msg<<": iterations="<<i \
<<" CPU Time="<<std::fixed<<calc_time \
<<" iter/s="<<i/calc_time<<std::endl<<std::flush;
| #include <time.h>
#include <sstream>
#include <iostream>
clock_t calc_time0,calc_time1;
double calc_time;
void printTime(const std::string& msg, long long iterations, double iterPerSec) {
std::stringstream ss;
ss << msg;
while (ss.tellp() < 30) {
ss << ' ';
}
ss << " iterations=" << iterations;
while (ss.tellp() < 60) {
ss << ' ';
}
ss <<" CPU Time="<<std::fixed<<calc_time;
while (ss.tellp() < 80) {
ss << ' ';
}
ss <<" iter/s="<<iterPerSec<<std::endl;
std::cout << ss.str() << std::flush;
}
#define TIME_ON calc_time0=clock();
#define TIME_OFF(msg) calc_time1=clock(); \
calc_time=(double)(calc_time1-calc_time0)/CLOCKS_PER_SEC; \
printTime(msg, i, i/calc_time);
|
Use correct variable for number of tests | #include <stdlib.h>
#include <stdio.h>
#include <check.h>
#include "check_check.h"
int main (void)
{
int n;
SRunner *sr;
fork_setup();
setup_fixture();
sr = srunner_create (make_master_suite());
srunner_add_suite(sr, make_list_suite());
srunner_add_suite(sr, make_msg_suite());
srunner_add_suite(sr, make_log_suite());
srunner_add_suite(sr, make_limit_suite());
srunner_add_suite(sr, make_fork_suite());
srunner_add_suite(sr, make_fixture_suite());
srunner_add_suite(sr, make_pack_suite());
setup();
printf ("Ran %d tests in subordinate suite\n", sub_nfailed);
srunner_run_all (sr, CK_NORMAL);
cleanup();
fork_teardown();
teardown_fixture();
n = srunner_ntests_failed(sr);
srunner_free(sr);
return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
| #include <stdlib.h>
#include <stdio.h>
#include <check.h>
#include "check_check.h"
int main (void)
{
int n;
SRunner *sr;
fork_setup();
setup_fixture();
sr = srunner_create (make_master_suite());
srunner_add_suite(sr, make_list_suite());
srunner_add_suite(sr, make_msg_suite());
srunner_add_suite(sr, make_log_suite());
srunner_add_suite(sr, make_limit_suite());
srunner_add_suite(sr, make_fork_suite());
srunner_add_suite(sr, make_fixture_suite());
srunner_add_suite(sr, make_pack_suite());
setup();
printf ("Ran %d tests in subordinate suite\n", sub_ntests);
srunner_run_all (sr, CK_NORMAL);
cleanup();
fork_teardown();
teardown_fixture();
n = srunner_ntests_failed(sr);
srunner_free(sr);
return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
|
Upgrade version number to 0.2.0 | #ifndef _MAIN_H_
#define _MAIN_H_
#define PROGRAM_MAJOR_VERSION 0
#define PROGRAM_MINOR_VERSION 1
#define PROGRAM_PATCH_VERSION 1
extern int quit;
#endif /* _MAIN_H_ */
| #ifndef _MAIN_H_
#define _MAIN_H_
#define PROGRAM_MAJOR_VERSION 0
#define PROGRAM_MINOR_VERSION 2
#define PROGRAM_PATCH_VERSION 0
extern int quit;
#endif /* _MAIN_H_ */
|
Add mathextras.h to wtf to give win32 roundf/lroundf support. | /*
* Copyright (C) 2006 Apple Computer, 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 <math.h>
#if PLATFORM(WIN)
inline float roundf(float num)
{
return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f);
}
inline long lroundf(float num)
{
return num > 0 ? num + 0.5f : ceilf(num - 0.5f);
}
#endif
| |
Remove useless unit testing definitions. | /*
* minunit.h
*
* Source: http://www.jera.com/techinfo/jtns/jtn002.html
*/
#include <stdio.h>
extern int tests_run;
#define mu_assert(message, test) do { \
if (!(test)) { \
return message; \
} \
} while (0)
#define mu_run_test(test, name) do { \
test_head(name); \
char const * message = test(); \
tests_run++; \
if (message) { \
test_failure; \
printf(" * %s\n", message); \
} else { \
test_success; \
} \
} while (0)
#define test_head(name) printf("Test %s... ", name)
#define test_success printf("[OK]\n")
#define test_failure printf("[FAIL]\n") | /*
* minunit.h
*
* Source: http://www.jera.com/techinfo/jtns/jtn002.html
*/
#include <stdio.h>
extern int tests_run;
#define mu_assert(message, test) do { \
if (!(test)) { \
return message; \
} \
} while (0)
#define mu_run_test(test, name) do { \
printf("Test %s... ", name); \
char const * message = test(); \
tests_run++; \
if (message) { \
if (message[0] != '\0') { \
printf("[FAIL]\n * %s\n", message); \
} else { \
printf("[OK]\n"); \
} \
} else { \
printf("\n"); \
} \
} while (0)
|
Add test for OpenCL vector initializer codegen | // RUN: clang-cc %s -emit-llvm -o - | not grep 'extractelement' &&
// RUN: clang-cc %s -emit-llvm -o - | not grep 'insertelement' &&
// RUN: clang-cc %s -emit-llvm -o - | grep 'shufflevector'
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(4) )) float float4;
float2 test1(float4 V) {
return V.xy + V.wz;
}
float4 test2(float4 V) {
float2 W = V.ww;
return W.xyxy + W.yxyx;
}
| // RUN: clang-cc %s -x cl -emit-llvm -o - | not grep 'extractelement' &&
// RUN: clang-cc %s -x cl -emit-llvm -o - | not grep 'insertelement' &&
// RUN: clang-cc %s -x cl -emit-llvm -o - | grep 'shufflevector'
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(4) )) float float4;
float2 test1(float4 V) {
return V.xy + V.wz;
}
float4 test2(float4 V) {
float2 W = V.ww;
return W.xyxy + W.yxyx;
}
float4 test3(float4 V1, float4 V2) { return (float4)(V1.zw, V2.xy); }
|
Remove a temporary fn that never got used | /*
Copyright 2011 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.
Author: lode.vandevenne@gmail.com (Lode Vandevenne)
Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
*/
#include "hash.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define HASH_SHIFT 5
#define HASH_MASK 32767
extern ZopfliHash* ZopfliInitHash(size_t window_size);
extern void ZopfliResetHash(size_t window_size, ZopfliHash* h);
extern void ZopfliCleanHash(ZopfliHash* h);
extern void ZopfliUpdateHash(const unsigned char* array, size_t pos, size_t end, ZopfliHash* h);
extern void ZopfliWarmupHash(const unsigned char* array, size_t pos, size_t end, ZopfliHash* h);
| /*
Copyright 2011 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.
Author: lode.vandevenne@gmail.com (Lode Vandevenne)
Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
*/
#include "hash.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define HASH_SHIFT 5
#define HASH_MASK 32767
extern ZopfliHash* ZopfliInitHash(size_t window_size);
extern void ZopfliResetHash(size_t window_size, ZopfliHash* h);
extern void ZopfliCleanHash(ZopfliHash* h);
extern void ZopfliUpdateHash(const unsigned char* array, size_t pos, size_t end, ZopfliHash* h);
extern void ZopfliWarmupHash(const unsigned char* array, size_t pos, size_t end, ZopfliHash* h);
|
Change version number to 8.1.0 | /*******************************************************************
* This file is part of the Emulex Linux Device Driver for *
* Fibre Channel Host Bus Adapters. *
* Copyright (C) 2004-2005 Emulex. All rights reserved. *
* EMULEX and SLI are trademarks of Emulex. *
* www.emulex.com *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of version 2 of the GNU General *
* Public License as published by the Free Software Foundation. *
* This program is distributed in the hope that it will be useful. *
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
* DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
* TO BE LEGALLY INVALID. See the GNU General Public License for *
* more details, a copy of which can be found in the file COPYING *
* included with this package. *
*******************************************************************/
#define LPFC_DRIVER_VERSION "8.0.30"
#define LPFC_DRIVER_NAME "lpfc"
#define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \
LPFC_DRIVER_VERSION
#define LPFC_COPYRIGHT "Copyright(c) 2004-2005 Emulex. All rights reserved."
#define DFC_API_VERSION "0.0.0"
| /*******************************************************************
* This file is part of the Emulex Linux Device Driver for *
* Fibre Channel Host Bus Adapters. *
* Copyright (C) 2004-2005 Emulex. All rights reserved. *
* EMULEX and SLI are trademarks of Emulex. *
* www.emulex.com *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of version 2 of the GNU General *
* Public License as published by the Free Software Foundation. *
* This program is distributed in the hope that it will be useful. *
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
* DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
* TO BE LEGALLY INVALID. See the GNU General Public License for *
* more details, a copy of which can be found in the file COPYING *
* included with this package. *
*******************************************************************/
#define LPFC_DRIVER_VERSION "8.1.0"
#define LPFC_DRIVER_NAME "lpfc"
#define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \
LPFC_DRIVER_VERSION
#define LPFC_COPYRIGHT "Copyright(c) 2004-2005 Emulex. All rights reserved."
#define DFC_API_VERSION "0.0.0"
|
Add function prototype for monitor clone set. | #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
Evas_Object *e_smart_monitor_add(Evas *evas);
void e_smart_monitor_crtc_set(Evas_Object *obj, Ecore_X_Randr_Crtc crtc, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch);
void e_smart_monitor_output_set(Evas_Object *obj, Ecore_X_Randr_Output output);
void e_smart_monitor_grid_set(Evas_Object *obj, Evas_Object *grid, Evas_Coord gx, Evas_Coord gy, Evas_Coord gw, Evas_Coord gh);
void e_smart_monitor_grid_virtual_size_set(Evas_Object *obj, Evas_Coord vw, Evas_Coord vh);
void e_smart_monitor_background_set(Evas_Object *obj, Evas_Coord dx, Evas_Coord dy);
void e_smart_monitor_current_geometry_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
# endif
#endif
| #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
Evas_Object *e_smart_monitor_add(Evas *evas);
void e_smart_monitor_crtc_set(Evas_Object *obj, Ecore_X_Randr_Crtc crtc, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch);
Ecore_X_Randr_Crtc e_smart_monitor_crtc_get(Evas_Object *obj);
void e_smart_monitor_output_set(Evas_Object *obj, Ecore_X_Randr_Output output);
void e_smart_monitor_grid_set(Evas_Object *obj, Evas_Object *grid, Evas_Coord gx, Evas_Coord gy, Evas_Coord gw, Evas_Coord gh);
void e_smart_monitor_grid_virtual_size_set(Evas_Object *obj, Evas_Coord vw, Evas_Coord vh);
void e_smart_monitor_background_set(Evas_Object *obj, Evas_Coord dx, Evas_Coord dy);
void e_smart_monitor_current_geometry_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
void e_smart_monitor_clone_set(Evas_Object *obj, Evas_Object *parent);
# endif
#endif
|
Fix missing stdint.h on py2.7 vc9 | #ifndef GUFUNC_SCHEDULER
#define GUFUNC_SCHEDULER
#include <stdint.h>
#ifndef __SIZEOF_POINTER__
/* MSVC doesn't define __SIZEOF_POINTER__ */
#if defined(_WIN64)
#define intp int64_t
#define uintp uint64_t
#elif defined(_WIN32)
#define intp int
#define uintp unsigned
#else
#error "cannot determine size of intp"
#endif
#elif __SIZEOF_POINTER__ == 8
#define intp int64_t
#define uintp uint64_t
#else
#define intp int
#define uintp unsigned
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void do_scheduling(intp num_dim, intp *dims, uintp num_threads, intp *sched, intp debug);
#ifdef __cplusplus
}
#endif
#endif
| #ifndef GUFUNC_SCHEDULER
#define GUFUNC_SCHEDULER
/* define int64_t and uint64_t for VC9 */
#ifdef _MSC_VER
#define int64_t signed __int64
#define uint64_t unsigned __int64
#else
#include <stdint.h>
#endif
#ifndef __SIZEOF_POINTER__
/* MSVC doesn't define __SIZEOF_POINTER__ */
#if defined(_WIN64)
#define intp int64_t
#define uintp uint64_t
#elif defined(_WIN32)
#define intp int
#define uintp unsigned
#else
#error "cannot determine size of intp"
#endif
#elif __SIZEOF_POINTER__ == 8
#define intp int64_t
#define uintp uint64_t
#else
#define intp int
#define uintp unsigned
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void do_scheduling(intp num_dim, intp *dims, uintp num_threads, intp *sched, intp debug);
#ifdef __cplusplus
}
#endif
#endif
|
Fix mac bustage (more still). | // -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2006 George Staikos <staikos@kde.org>
*
* 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; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef KJS_UNICODE_H
#define KJS_UNICODE_H
#include <wtf/Platform.h>
#if USE(QT4_UNICODE)
#include "qt4/UnicodeQt4.h"
#elif USE(ICU_UNICODE)
#include <wtf/icu/UnicodeIcu.h>
#else
#error "Unknown Unicode implementation"
#endif
#endif
// vim: ts=2 sw=2 et
| // -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2006 George Staikos <staikos@kde.org>
*
* 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; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef KJS_UNICODE_H
#define KJS_UNICODE_H
#include <wtf/Platform.h>
#if USE(QT4_UNICODE)
#include "qt4/UnicodeQt4.h"
#elif USE(ICU_UNICODE)
#include <wtf/unicode/icu/UnicodeIcu.h>
#else
#error "Unknown Unicode implementation"
#endif
#endif
// vim: ts=2 sw=2 et
|
Clear existing divisor before setting it. | #include <kernel/x86/apic.h>
#include <kernel/port/mmio.h>
void apic_timer_init(uint8_t int_no, uint8_t divisor, uint8_t mode) {
/** set the divisor: **/
uint32_t reg = get32(DIVIDE_CONF);
reg &= ~0xf;
/* The representation of the divisor in the divide configuration
* register is... weird. We're normalizing it a bit here; it's split up
* within the register, and for some reason 7 is divide by 1, where as
* the rest are a perfect 2^(n-1). See the intel manual for the
* details. */
if (divisor == 0) divisor = 7;
else divisor -= 1;
reg |= (divisor & 0x3) | ((divisor & 0x4)<<1);
put32(DIVIDE_CONF, reg);
/** set the lvt entry: **/
LVTEnt lvt_ent;
lvt_ent.raw = get32(LVT_TIMER);
lvt_ent.v.timer_mode = mode;
lvt_ent.v.vector = int_no;
lvt_ent.v.masked = 0;
put32(LVT_TIMER, lvt_ent.raw);
}
void apic_timer_set(uint32_t value) {
put32(INITIAL_COUNT, value);
}
| #include <kernel/x86/apic.h>
#include <kernel/port/mmio.h>
void apic_timer_init(uint8_t int_no, uint8_t divisor, uint8_t mode) {
/** set the divisor: **/
uint32_t reg = get32(DIVIDE_CONF);
reg &= ~0xf;
/* The representation of the divisor in the divide configuration
* register is... weird. We're normalizing it a bit here; it's split up
* within the register, and for some reason 7 is divide by 1, where as
* the rest are a perfect 2^(n-1). See the intel manual for the
* details. */
if (divisor == 0) divisor = 7;
else divisor -= 1;
/* Clear the low 4 bits; the rest is reserved and shouldn't be touched. */
reg &= ~0xf;
reg |= (divisor & 0x3) | ((divisor & 0x4)<<1);
put32(DIVIDE_CONF, reg);
/** set the lvt entry: **/
LVTEnt lvt_ent;
lvt_ent.raw = get32(LVT_TIMER);
lvt_ent.v.timer_mode = mode;
lvt_ent.v.vector = int_no;
lvt_ent.v.masked = 0;
put32(LVT_TIMER, lvt_ent.raw);
}
void apic_timer_set(uint32_t value) {
put32(INITIAL_COUNT, value);
}
|
Add reference for almost_equal function | #ifndef H_NUMERIC
#define H_NUMERIC
#include <cmath>
#include <limits>
template<class T>
typename std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type
almost_equal(T x, T y, int ulp=2)
{
// the machine epsilon has to be scaled to the magnitude of the values used
// and multiplied by the desired precision in ULPs (units in the last place)
return std::abs(x-y) <= std::numeric_limits<T>::epsilon() * std::abs(x+y) * ulp
// unless the result is subnormal
|| std::abs(x-y) < std::numeric_limits<T>::min();
}
template<class T>
T half(T x){}
template <>
float half(float x){return 0.5f * x;}
template <>
double half(double x){return 0.5 * x;}
#endif
| #ifndef H_NUMERIC
#define H_NUMERIC
#include <cmath>
#include <limits>
/**
* @brief use of machine epsilon to compare floating-point values for equality
* http://en.cppreference.com/w/cpp/types/numeric_limits/epsilon
*/
template<class T>
typename std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type
almost_equal(T x, T y, int ulp=2)
{
// the machine epsilon has to be scaled to the magnitude of the values used
// and multiplied by the desired precision in ULPs (units in the last place)
return std::abs(x-y) <= std::numeric_limits<T>::epsilon() * std::abs(x+y) * ulp
// unless the result is subnormal
|| std::abs(x-y) < std::numeric_limits<T>::min();
}
template<class T>
T half(T x){}
template <>
float half(float x){return 0.5f * x;}
template <>
double half(double x){return 0.5 * x;}
#endif
|
Annotate RLMAssertThrows' block argument with noescape | ////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import <XCTest/XCTestCase.h>
// An XCTestCase that invokes each test in an autorelease pool
// Works around a swift 1.1 limitation where `super` can't be used in a block
@interface RLMAutoreleasePoolTestCase : XCTestCase
@end
FOUNDATION_EXTERN void RLMAssertThrows(XCTestCase *self, dispatch_block_t block, NSString *message, NSString *fileName, NSUInteger lineNumber);
// Forcibly deallocate the RLMRealm for the given path on the main thread
// Will cause crashes if it's alive for a reason other than being leaked by RLMAssertThrows
FOUNDATION_EXTERN void RLMDeallocateRealm(NSString *path);
| ////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import <XCTest/XCTestCase.h>
// An XCTestCase that invokes each test in an autorelease pool
// Works around a swift 1.1 limitation where `super` can't be used in a block
@interface RLMAutoreleasePoolTestCase : XCTestCase
@end
FOUNDATION_EXTERN void RLMAssertThrows(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, NSString *message, NSString *fileName, NSUInteger lineNumber);
// Forcibly deallocate the RLMRealm for the given path on the main thread
// Will cause crashes if it's alive for a reason other than being leaked by RLMAssertThrows
FOUNDATION_EXTERN void RLMDeallocateRealm(NSString *path);
|
Add an unused interface for storing thumbnails. This is to replace the history system's thumbnail storage. | // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_THUMBNAIL_STORE_H_
#define CHROME_BROWSER_THUMBNAIL_STORE_H_
#include <vector>
#include "base/file_path.h"
class GURL;
class SkBitmap;
struct ThumbnailScore;
namespace base {
class Time;
}
// This storage interface provides storage for the thumbnails used
// by the new_tab_ui.
class ThumbnailStore {
public:
ThumbnailStore();
~ThumbnailStore();
// Must be called after creation but before other methods are called.
// file_path is where a new database should be created or the
// location of an existing databse.
// If false is returned, no other methods should be called.
bool Init(const FilePath& file_path);
// Stores the given thumbnail and score with the associated url.
bool SetPageThumbnail(const GURL& url,
const SkBitmap& thumbnail,
const ThumbnailScore& score,
const base::Time& time);
// Retrieves the thumbnail and score for the given url.
// Returns false if there is not data for the given url or some other
// error occurred.
bool GetPageThumbnail(const GURL& url,
SkBitmap* thumbnail,
ThumbnailScore* score);
private:
// The location of the thumbnail store.
FilePath file_path_;
DISALLOW_COPY_AND_ASSIGN(ThumbnailStore);
};
#endif // CHROME_BROWSER_THUMBNAIL_STORE_H_
| |
Add <string> explicitly for Windows complaining without it | #ifndef _BIGINT_H_
#define _BIGINT_H_
#include <memory>
namespace Erpiko {
/**
* BigInt is the class of big integer representation.
*/
class BigInt {
public:
/**
* Constructor
*/
BigInt();
/**
* Constructor from long integer
* @param value to be initialized
*/
BigInt(unsigned long value);
/**
* Creates a new BigInt and initialized with the value specified in the string
* @param string string containing the value. If it is prefixed with 0x then it is considered as hex string
* @return the new BigInt with the value set
*/
static BigInt* fromString(const std::string string);
virtual ~BigInt();
/**
* Creates hex string representation of the BigInt
* @return string containing hex string
*/
const std::string toHexString() const;
/**
* Operator ==
**/
bool operator== (const BigInt& other) const;
/**
* Operator =
**/
void operator= (const BigInt& other);
/**
* Operator =
**/
void operator= (const unsigned long value);
/**
* Operator =.
* @param string the new value specified as string. String must be valid or the value will not change.
**/
void operator= (const std::string string);
private:
class Impl;
std::unique_ptr<Impl> impl;
};
} // namespace Erpiko
#endif // _BIGINT_H_
| #ifndef _BIGINT_H_
#define _BIGINT_H_
#include <string>
#include <memory>
namespace Erpiko {
/**
* BigInt is the class of big integer representation.
*/
class BigInt {
public:
/**
* Constructor
*/
BigInt();
/**
* Constructor from long integer
* @param value to be initialized
*/
BigInt(unsigned long value);
/**
* Creates a new BigInt and initialized with the value specified in the string
* @param string string containing the value. If it is prefixed with 0x then it is considered as hex string
* @return the new BigInt with the value set
*/
static BigInt* fromString(const std::string string);
virtual ~BigInt();
/**
* Creates hex string representation of the BigInt
* @return string containing hex string
*/
const std::string toHexString() const;
/**
* Operator ==
**/
bool operator== (const BigInt& other) const;
/**
* Operator =
**/
void operator= (const BigInt& other);
/**
* Operator =
**/
void operator= (const unsigned long value);
/**
* Operator =.
* @param string the new value specified as string. String must be valid or the value will not change.
**/
void operator= (const std::string string);
private:
class Impl;
std::unique_ptr<Impl> impl;
};
} // namespace Erpiko
#endif // _BIGINT_H_
|
Replace custom IMAGEDIR_MAX with PATH_MAX, ala 13616d1 | #include "defs.h"
void locate_library_executable(int argc, char *argv[])
{
DWORD l;
char *endpath;
#ifdef DLL
HANDLE dll;
#endif
l = GetModuleFileName(NULL, executable_path, IMAGEDIR_MAX);
if (l == 0 || l >= IMAGEDIR_MAX) fatal_error(FE_INFND, 0);
#ifdef DLL
dll = GetModuleHandle(DLL_NAME);
if (dll == NULL) fatal_error(FE_INFND, 0);
l = GetModuleFileName(dll, library_path, IMAGEDIR_MAX);
if (l == 0 || l >= IMAGEDIR_MAX) fatal_error(FE_INFND, 0);
#else
strcpy(library_path, executable_path);
#endif /* DLL */
strcpy(library_dir, library_path);
endpath = strrchr(library_dir, '\\');
if (endpath == NULL) fatal_error(FE_INFND, 0);
endpath++; /* include the \ */
*endpath = 0;
}
| #include "defs.h"
void locate_library_executable(int argc, char *argv[])
{
DWORD l;
char *endpath;
#ifdef DLL
HANDLE dll;
#endif
l = GetModuleFileName(NULL, executable_path, PATH_MAX);
if (l == 0 || l >= PATH_MAX) fatal_error(FE_INFND, 0);
#ifdef DLL
dll = GetModuleHandle(DLL_NAME);
if (dll == NULL) fatal_error(FE_INFND, 0);
l = GetModuleFileName(dll, library_path, PATH_MAX);
if (l == 0 || l >= PATH_MAX) fatal_error(FE_INFND, 0);
#else
strcpy(library_path, executable_path);
#endif /* DLL */
strcpy(library_dir, library_path);
endpath = strrchr(library_dir, '\\');
if (endpath == NULL) fatal_error(FE_INFND, 0);
endpath++; /* include the \ */
*endpath = 0;
}
|
Set about dialog program name | #include <gtk/gtk.h>
GtkWidget *
gh_about_dialog_create ()
{
GtkWidget *dialog;
dialog = gtk_about_dialog_new ();
static gchar const *title = "About ghighlighter";
gtk_window_set_title (GTK_WINDOW (dialog), title);
return dialog;
}
| #include <gtk/gtk.h>
GtkWidget *
gh_about_dialog_create ()
{
GtkWidget *dialog;
dialog = gtk_about_dialog_new ();
static gchar const *title = "About ghighlighter";
static gchar const *program_name = "ghighlighter";
gtk_window_set_title (GTK_WINDOW (dialog), title);
gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (dialog), program_name);
return dialog;
}
|
Add new header file. (or: xcode is stupid) | //
// BDSKOAIGroupServer.h
// Bibdesk
//
// Created by Christiaan Hofman on 1/1/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "BDSKSearchGroup.h"
@class BDSKServerInfo;
@interface BDSKOAIGroupServer : NSObject <BDSKSearchGroupServer>
{
BDSKSearchGroup *group;
BDSKServerInfo *serverInfo;
NSString *searchTerm;
NSString *resumptionToken;
NSArray *sets;
NSString *filePath;
NSURLDownload *URLDownload;
BOOL failedDownload;
BOOL isRetrieving;
BOOL needsReset;
int availableResults;
int fetchedResults;
}
- (void)setServerInfo:(BDSKServerInfo *)info;
- (BDSKServerInfo *)serverInfo;
- (void)setSearchTerm:(NSString *)string;
- (NSString *)searchTerm;
- (void)setSets:(NSArray *)newSets;
- (NSArray *)sets;
- (void)setResumptionToken:(NSString *)newResumptionToken;
- (NSString *)resumptionToken;
- (void)resetSearch;
- (void)fetchSets;
- (void)fetch;
- (void)startDownloadFromURL:(NSURL *)theURL;
@end
| |
Change functions to handle idioma | #include <stdlib.h>
#include <string.h>
#include "config.h"
struct Config load_config(char *arquivo) {
}
struct Idioma load_idioma(char *idioma){
char *local_idioma;
int loaded;
strcpy(local_idioma, "local aqui");
strcat(local_idioma, idioma);
strcat(local_idioma, ".conf");
loaded = 1;
while(loaded) {
strcpy(local_idioma, "local aqui");
strcat(local_idioma, idioma);
strcat(local_idioma, ".conf");
//Abre idioma
FILE *arquivo = fopen(local_idioma, "r");
if(file) {
loaded = 0;
}
else {
printf("Arquivo de idioma não localizado\n");
printf("Will try to load the default language\n");
}
}
} | #include <stdlib.h>
#include <string.h>
#include "config.h"
struct Config load_config(char *arquivo) {
}
void load_idioma(struct Idioma *idioma, char *key, char *content){
}
void clean_idioma(struct Idioma *idioma) {
free(idioma);
}
|
Make UInt safe on Transaction Params by not using pointer | //
// PSTCKTransactionParams.h
// Paystack
//
#import <Foundation/Foundation.h>
#import "PSTCKFormEncodable.h"
/**
* Representation of a user's credit card details. You can assemble these with information that your user enters and
* then create Paystack tokens with them using an PSTCKAPIClient. @see https://paystack.com/docs/api#cards
*/
@interface PSTCKTransactionParams : NSObject<PSTCKFormEncodable>
@property (nonatomic, copy, nonnull) NSString *email;
@property (nonatomic, nonnull) NSUInteger *amount;
@property (nonatomic, copy, nullable) NSString *reference;
@property (nonatomic, copy, nullable) NSString *subaccount;
@property (nonatomic, nullable) NSUInteger *transactionCharge;
@property (nonatomic, copy, nullable) NSString *bearer;
@property (nonatomic, copy, nullable) NSString *metadata;
@end
| //
// PSTCKTransactionParams.h
// Paystack
//
#import <Foundation/Foundation.h>
#import "PSTCKFormEncodable.h"
/**
* Representation of a user's credit card details. You can assemble these with information that your user enters and
* then create Paystack tokens with them using an PSTCKAPIClient. @see https://paystack.com/docs/api#cards
*/
@interface PSTCKTransactionParams : NSObject<PSTCKFormEncodable>
@property (nonatomic, copy, nonnull) NSString *email;
@property (nonatomic) NSUInteger amount;
@property (nonatomic, copy, nullable) NSString *reference;
@property (nonatomic, copy, nullable) NSString *subaccount;
@property (nonatomic) NSUInteger transactionCharge;
@property (nonatomic, copy, nullable) NSString *bearer;
@property (nonatomic, copy, nullable) NSString *metadata;
@end
|
Synchronize the mailbox after expunging messages to actually get them expunged. | /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
| /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
else if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
|
Update Skia milestone to 88 | /*
* 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 87
#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 88
#endif
|
Revert "[FIXED] not use allocator, for async draw" | #ifndef _GUM_GLYPH_STYLE_ID_H_
#define _GUM_GLYPH_STYLE_ID_H_
#include "gum/GlyphStyle.h"
#include <cu/cu_macro.h>
#include <cu/cu_stl.h>
namespace gum
{
class GlyphStyle;
class GlyphStyleID
{
public:
int Gen(const GlyphStyle& style);
private:
static int Hash(const GlyphStyle& style);
private:
static const int HASH_CAP = 197;
private:
int m_next_id;
std::vector<std::pair<GlyphStyle, int> > m_hash[HASH_CAP];
std::pair<GlyphStyle, int> m_last;
CU_SINGLETON_DECLARATION(GlyphStyleID)
}; // GlyphStyleID
}
#endif // _GUM_GLYPH_STYLE_ID_H_ | #ifndef _GUM_GLYPH_STYLE_ID_H_
#define _GUM_GLYPH_STYLE_ID_H_
#include "gum/GlyphStyle.h"
#include <cu/cu_macro.h>
#include <cu/cu_stl.h>
namespace gum
{
class GlyphStyle;
class GlyphStyleID
{
public:
int Gen(const GlyphStyle& style);
private:
static int Hash(const GlyphStyle& style);
private:
static const int HASH_CAP = 197;
private:
int m_next_id;
CU_VEC<std::pair<GlyphStyle, int> > m_hash[HASH_CAP];
std::pair<GlyphStyle, int> m_last;
CU_SINGLETON_DECLARATION(GlyphStyleID)
}; // GlyphStyleID
}
#endif // _GUM_GLYPH_STYLE_ID_H_ |
Use -fPIC -shared in a test instead of -dynamiclib | // Test __llvm_profile_get_filename when the on-line merging mode is enabled.
//
// RUN: %clang_pgogen -dynamiclib -o %t.dso %p/Inputs/instrprof-get-filename-dso.c
// RUN: %clang_pgogen -o %t %s %t.dso
// RUN: env LLVM_PROFILE_FILE="%t-%m.profraw" %run %t
#include <string.h>
const char *__llvm_profile_get_filename(void);
extern const char *get_filename_from_DSO(void);
int main(int argc, const char *argv[]) {
const char *filename1 = __llvm_profile_get_filename();
const char *filename2 = get_filename_from_DSO();
// Exit with code 1 if the two filenames are the same.
return strcmp(filename1, filename2) == 0;
}
| // Test __llvm_profile_get_filename when the on-line merging mode is enabled.
//
// RUN: %clang_pgogen -fPIC -shared -o %t.dso %p/../Inputs/instrprof-get-filename-dso.c
// RUN: %clang_pgogen -o %t %s %t.dso
// RUN: env LLVM_PROFILE_FILE="%t-%m.profraw" %run %t
#include <string.h>
const char *__llvm_profile_get_filename(void);
extern const char *get_filename_from_DSO(void);
int main(int argc, const char *argv[]) {
const char *filename1 = __llvm_profile_get_filename();
const char *filename2 = get_filename_from_DSO();
// Exit with code 1 if the two filenames are the same.
return strcmp(filename1, filename2) == 0;
}
|
Check if two strings are permutations by checking their character counts | //
// main.c
// Check if two strings are permutations by checking if they have identical character counts.
//
// Created by Jack Zuban on 8/20/17.
// Copyright © 2017 Jack Zuban. All rights reserved.
//
#include <stdio.h>
#include <stdbool.h>
bool areStringsHaveSameLength(char *str1, char *str2)
{
while (*str1 && *str2) {
str1++;
str2++;
}
return (*str1 == '\0' && *str2 == '\0');
}
bool isPermutation(char *str1, char *str2)
{
bool areStringsHaveSameLength(char *str1, char *str2);
int charactersFrequency[127] = {};
if (! areStringsHaveSameLength(str1, str2)) {
return false;
}
while (*str1) {
charactersFrequency[(int) *str1]++;
str1++;
}
while (*str2) {
charactersFrequency[(int) *str2]--;
if (charactersFrequency[(int) *str2] < 0) {
return false;
}
str2++;
}
return true;
}
int main(void) {
bool isPermutation(char *str1, char *str2);
char str1[80];
char str2[80];
printf("First string: ");
fgets(str1, 79, stdin);
printf("Second string: ");
fgets(str2, 79, stdin);
printf("Strings are: %s\n", isPermutation(str1, str2) ? "permutations." : "not permutations.");
return 0;
}
| |
Remove debug information from VMOV code | //
// arch/x86_64/rsp/vmov.c
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "common.h"
#include "rsp/cpu.h"
#include "rsp/rsp.h"
__m128i rsp_vmov(struct rsp *rsp,
unsigned src, unsigned e, unsigned dest, rsp_vect_t vt_shuffle) {
uint16_t data;
// Copy element into data
memcpy(&data, (e & 0x7) + (uint16_t *)&vt_shuffle, sizeof(uint16_t));
printf("src %d dest %d el %x data %x\n", src, dest, e, data);
fflush(stdout);
// Write out the upper part of the result.
rsp->cp2.regs[dest].e[e & 0x7] = data;
return rsp_vect_load_unshuffled_operand(rsp->cp2.regs[dest].e);
}
| //
// arch/x86_64/rsp/vmov.c
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "common.h"
#include "rsp/cpu.h"
#include "rsp/rsp.h"
__m128i rsp_vmov(struct rsp *rsp,
unsigned src, unsigned e, unsigned dest, rsp_vect_t vt_shuffle) {
uint16_t data;
// Copy element into data
memcpy(&data, (e & 0x7) + (uint16_t *)&vt_shuffle, sizeof(uint16_t));
// Write out the upper part of the result.
rsp->cp2.regs[dest].e[e & 0x7] = data;
return rsp_vect_load_unshuffled_operand(rsp->cp2.regs[dest].e);
}
|
Add a simple reference count API that is simply a thin wrapper API around atomic operations on ints. | /*-
* Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org>
* 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 author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef __SYS_REFCOUNT_H__
#define __SYS_REFCOUNT_H__
#include <machine/atomic.h>
static __inline void
refcount_init(volatile u_int *count, u_int value)
{
*count = value;
}
static __inline void
refcount_acquire(volatile u_int *count)
{
atomic_add_acq_int(count, 1);
}
static __inline int
refcount_release(volatile u_int *count)
{
/* XXX: Should this have a rel membar? */
return (atomic_fetchadd_int(count, -1) == 1);
}
#endif /* ! __SYS_REFCOUNT_H__ */
| |
Make AcpiInitializeTables to dynamically alloc tables | /* SPDX-License-Identifier: BSD-2-Clause */
#include <tilck/common/basic_defs.h>
#include <tilck/common/printk.h>
#include <tilck/kernel/sched.h>
#include "osl.h"
#include <3rd_party/acpi/acpi.h>
#include <3rd_party/acpi/acexcep.h>
static ACPI_TABLE_DESC acpi_tables[16];
void
early_init_acpi_module(void)
{
ACPI_STATUS rc;
rc = AcpiInitializeSubsystem();
if (rc != AE_OK)
panic("AcpiInitializeSubsystem() failed with: %d", rc);
rc = AcpiInitializeTables(acpi_tables, 16, false);
if (rc != AE_OK)
panic("AcpiInitializeTables() failed with: %d", rc);
}
| /* SPDX-License-Identifier: BSD-2-Clause */
#include <tilck/common/basic_defs.h>
#include <tilck/common/printk.h>
#include <tilck/kernel/sched.h>
#include "osl.h"
#include <3rd_party/acpi/acpi.h>
#include <3rd_party/acpi/acexcep.h>
void
early_init_acpi_module(void)
{
ACPI_STATUS rc;
rc = AcpiInitializeSubsystem();
if (rc != AE_OK)
panic("AcpiInitializeSubsystem() failed with: %d", rc);
rc = AcpiInitializeTables(NULL, 0, true);
if (rc != AE_OK)
panic("AcpiInitializeTables() failed with: %d", rc);
}
|
Replace fizz server cert with leaf cert returned from verification | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <fizz/protocol/CertificateVerifier.h>
namespace quic::test {
class TestCertificateVerifier : public fizz::CertificateVerifier {
public:
~TestCertificateVerifier() override = default;
void verify(const std::vector<std::shared_ptr<const fizz::PeerCert>>&)
const override {
return;
}
[[nodiscard]] std::vector<fizz::Extension> getCertificateRequestExtensions()
const override {
return std::vector<fizz::Extension>();
}
};
inline std::unique_ptr<fizz::CertificateVerifier>
createTestCertificateVerifier() {
return std::make_unique<TestCertificateVerifier>();
}
} // namespace quic::test
| /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <fizz/protocol/CertificateVerifier.h>
namespace quic::test {
class TestCertificateVerifier : public fizz::CertificateVerifier {
public:
~TestCertificateVerifier() override = default;
std::shared_ptr<const folly::AsyncTransportCertificate> verify(
const std::vector<std::shared_ptr<const fizz::PeerCert>>& certs)
const override {
return certs.front();
}
[[nodiscard]] std::vector<fizz::Extension> getCertificateRequestExtensions()
const override {
return std::vector<fizz::Extension>();
}
};
inline std::unique_ptr<fizz::CertificateVerifier>
createTestCertificateVerifier() {
return std::make_unique<TestCertificateVerifier>();
}
} // namespace quic::test
|
Use correct syntax for windows DLL export | #ifdef _WIN32
#define LIB_FUNC __declspec(dllimport)
#else
#define LIB_FUNC
#endif
void LIB_FUNC printBuildType();
| #ifdef _WIN32
#define LIB_FUNC __declspec(dllexport)
#else
#define LIB_FUNC
#endif
void LIB_FUNC printBuildType();
|
Change forward declaration of HttpRequestInfo from class to struct to fix build breakage. | // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_SPDY_SPDY_HTTP_UTILS_H_
#define NET_SPDY_SPDY_HTTP_UTILS_H_
#pragma once
#include "net/spdy/spdy_framer.h"
namespace net {
class HttpResponseInfo;
class HttpRequestInfo;
// Convert a SpdyHeaderBlock into an HttpResponseInfo.
// |headers| input parameter with the SpdyHeaderBlock.
// |info| output parameter for the HttpResponseInfo.
// Returns true if successfully converted. False if there was a failure
// or if the SpdyHeaderBlock was invalid.
bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers,
HttpResponseInfo* response);
// Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from
// a HttpRequestInfo block.
void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
spdy::SpdyHeaderBlock* headers,
bool direct);
} // namespace net
#endif // NET_SPDY_SPDY_HTTP_UTILS_H_
| // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_SPDY_SPDY_HTTP_UTILS_H_
#define NET_SPDY_SPDY_HTTP_UTILS_H_
#pragma once
#include "net/spdy/spdy_framer.h"
namespace net {
class HttpResponseInfo;
struct HttpRequestInfo;
// Convert a SpdyHeaderBlock into an HttpResponseInfo.
// |headers| input parameter with the SpdyHeaderBlock.
// |info| output parameter for the HttpResponseInfo.
// Returns true if successfully converted. False if there was a failure
// or if the SpdyHeaderBlock was invalid.
bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers,
HttpResponseInfo* response);
// Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from
// a HttpRequestInfo block.
void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
spdy::SpdyHeaderBlock* headers,
bool direct);
} // namespace net
#endif // NET_SPDY_SPDY_HTTP_UTILS_H_
|
Add example that needs Apron heterogeneous join strengthening | // SKIP PARAM: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.activated[-] threadJoins --enable ana.apron.threshold_widening --set ana.apron.privatization protection --enable ana.apron.strengthening
// Fig 5a from Miné 2014
// Example for join strengthening
#include <pthread.h>
#include <stdio.h>
int x;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
int top;
while(top) {
pthread_mutex_lock(&mutex);
if(x<100) {
x++;
}
pthread_mutex_unlock(&mutex);
}
return NULL;
}
int main(void) {
int top, top2;
pthread_t id;
pthread_t id2;
pthread_create(&id, NULL, t_fun, NULL);
pthread_create(&id2, NULL, t_fun, NULL);
pthread_mutex_lock(&mutex);
assert(x <= 100);
pthread_mutex_unlock(&mutex);
return 0;
}
| |
Create function to check if text_input is a valid number | #include <stdio.h>
#include <string.h>
// Declare functions
void get_input();
// Global variables
char text_input[32];
int running = 1;
// Main Section
int main() {
while (running == 1) {
if (strcmp(text_input, "q") == 0) {
running = 0;
printf("Goodbye!\n");
}
else {
get_input();
printf("The message is %s\n", text_input);
}
}
return 0;
}
// Define functions
void get_input() {
// Get the string
printf("Please enter a number or (q) to quit\n");
fgets(text_input, 32, stdin);
// Get the length of the string
int length = strlen(text_input) -1;
// Remove the newline at the end of the string if it existss
if (text_input[length] == '\n') {
text_input[length] = '\0';
}
}
| #include <stdio.h>
#include <string.h>
// Declare functions
void get_input();
int is_valid_number();
// Global variables
char text_input[32];
int running = 1;
// Main Section
int main() {
while (running == 1) {
if (strcmp(text_input, "q") == 0) {
running = 0;
printf("Goodbye!\n");
}
else {
get_input();
if(is_valid_number() == 0) {
printf("The message is %s\n", text_input);
}
}
}
return 0;
}
// Define functions
void get_input() {
// Get the string
printf("Please enter a number or (q) to quit\n");
fgets(text_input, 32, stdin);
// Get the length of the string
int length = strlen(text_input) -1;
// Remove the newline at the end of the string if it existss
if (text_input[length] == '\n') {
text_input[length] = '\0';
}
}
// Check if string is a valid number
int is_valid_number() {
char *ptr;
long number;
number = strtol(text_input, &ptr, 10);
if (strlen(ptr) == 0) {
return 0;
} else {
printf("Not a valid number\n");
return 1;
}
}
|
Include io.h for mingw builds | /**
* @file utils.h
* @brief Storj utilities.
*
* Helper utilities
*/
#ifndef STORJ_UTILS_H
#define STORJ_UTILS_H
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <stdbool.h>
#ifdef _WIN32
#include <windows.h>
#include <time.h>
ssize_t pread(int fd, void *buf, size_t count, uint64_t offset);
#else
#include <sys/time.h>
#endif
int hex2str(unsigned length, uint8_t *data, char *buffer);
void print_int_array(uint8_t *array, unsigned length);
int str2hex(unsigned length, char *data, uint8_t *buffer);
char *str_concat_many(int count, ...);
void random_buffer(uint8_t *buf, size_t len);
uint64_t shard_size(int hops);
uint64_t get_time_milliseconds();
void memset_zero(void *v, size_t n);
#endif /* STORJ_UTILS_H */
| /**
* @file utils.h
* @brief Storj utilities.
*
* Helper utilities
*/
#ifndef STORJ_UTILS_H
#define STORJ_UTILS_H
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <stdbool.h>
#ifdef _WIN32
#include <windows.h>
#include <time.h>
#include <io.h>
ssize_t pread(int fd, void *buf, size_t count, uint64_t offset);
#else
#include <sys/time.h>
#endif
int hex2str(unsigned length, uint8_t *data, char *buffer);
void print_int_array(uint8_t *array, unsigned length);
int str2hex(unsigned length, char *data, uint8_t *buffer);
char *str_concat_many(int count, ...);
void random_buffer(uint8_t *buf, size_t len);
uint64_t shard_size(int hops);
uint64_t get_time_milliseconds();
void memset_zero(void *v, size_t n);
#endif /* STORJ_UTILS_H */
|
Allow passing RNG seed as program argument | /* headers */
#include <stdlib.h>
#include <time.h>
#include "lattice.h"
#include "clusters.h"
#include "io_helpers.h"
/* main body function */
int main(int argc, char ** argv)
{
int L; /* square lattice size */
double p; /* occupation probability of each lattice site */
int *lattice; /* lattice array */
/* read input arguments; if none provided fallback to default values */
if (argc == 3) {
L = atoi(argv[1]);
p = atof(argv[2]);
} else {
L = 10;
p = 0.4;
}
/* initialize random number generator seed */
srand(time(NULL));
/* allocate lattice */
lattice = allocate_lattice(L, L);
/* populate lattice with given probability */
populate_lattice(p, lattice, L, L);
/* print the generated lattice for visualization */
print_lattice(lattice, L, L, 1);
/* label clusters and print result */
label_clusters(lattice, L, L);
print_lattice(lattice, L, L, 1);
/* free memory before leaving */
free(lattice);
return 0;
}
| /* headers */
#include <stdlib.h>
#include <time.h>
#include "lattice.h"
#include "clusters.h"
#include "io_helpers.h"
/* main body function */
int main(int argc, char ** argv)
{
int L; /* square lattice size */
double p; /* occupation probability of each lattice site */
int *lattice; /* lattice array */
unsigned int random_seed; /* random number generator seed */
/* read input arguments; if none provided fallback to default values */
if (argc == 3 || argc == 4) {
L = atoi(argv[1]);
p = atof(argv[2]);
if (argc == 4) {
random_seed = atoi(argv[3]);
} else {
random_seed = (unsigned int)time(NULL);
}
} else {
L = 10;
p = 0.4;
random_seed = (unsigned int)time(NULL);
}
/* initialize random number generator seed */
srand(random_seed);
/* allocate lattice */
lattice = allocate_lattice(L, L);
/* populate lattice with given probability */
populate_lattice(p, lattice, L, L);
/* print the generated lattice for visualization */
print_lattice(lattice, L, L, 1);
/* label clusters and print result */
label_clusters(lattice, L, L);
print_lattice(lattice, L, L, 1);
/* free memory before leaving */
free(lattice);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.