Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Make usage of NSArray literals a little bit simpler in equal() | #import "Expecta.h"
EXPMatcherInterface(_equal, (id expected));
EXPMatcherInterface(equal, (id expected)); // to aid code completion
#define equal(expected) _equal(EXPObjectify((expected)))
| #import "Expecta.h"
EXPMatcherInterface(_equal, (id expected));
EXPMatcherInterface(equal, (id expected)); // to aid code completion
#define equal(...) _equal(EXPObjectify((__VA_ARGS__)))
|
Move some ProceduralMaze public methods to private | #ifndef __PROCEDURALMAZE_H__
#define __PROCEDURALMAZE_H__
#include "maze.h"
#include <map>
class ProceduralMaze
{
private:
int width;
int height;
public:
std::map<std::tuple<int, int>, int> grid;
ProceduralMaze(int width, int height);
void generate();
void clearGrid();
std::vector<std::tuple<int, int>> getAdjCells(std::tuple<int, int> center, Tile tile_state);
};
#endif | #ifndef __PROCEDURALMAZE_H__
#define __PROCEDURALMAZE_H__
#include "maze.h"
#include <map>
class ProceduralMaze
{
private:
int width;
int height;
std::map<std::tuple<int, int>, int> grid;
void clearGrid();
std::vector<std::tuple<int, int>> getAdjCells(std::tuple<int, int> center, Tile tile_state);
public:
ProceduralMaze(int width, int height);
void generate();
void print();
std::map<std::tuple<int, int>, int> getGrid() { return grid; }
};
#endif |
Add 30 Days of Code Day 0 in C. | #include <stdio.h>
int main() {
// Declare a variable named 'input_string' to hold our input.
char input_string[105];
// Read a full line of input from stdin and save it to our variable, input_string.
scanf("%[^\n]", input_string);
// Print a string literal saying "Hello, World." to stdout using printf.
printf("Hello, World.\n");
// TODO: Write a line of code here that prints the contents of input_string to stdout.
printf("%s", input_string);
return 0;
} | |
Save each node in User Defined Functions | /*****************************************************************************
* PROGRAM NAME: CNodeO.h
* PROGRAMMER: Wei Sun wsun@vt.edu
* PURPOSE: Define the node object in user defined function
*****************************************************************************/
#ifndef COPASI_CNodeO
#define COPASI_CNodeO
#include <string>
#include <vector>
#include "copasi.h"
#include "model/model.h"
#include "utilities/utilities.h"
#include "function/function.h"
class CNodeO: public CNodeK
{
private:
/**
* Title of the node.
*/
string mTitle;
/**
* Type of the node's Datum.
*/
C_INT32 mDatumType;
/**
* I String of the node
*/
string mI;
/**
* J String of the node
*/
string mJ;
public:
/**
* Default constructor
*/
CNodeO();
/**
* Constructor for operator
* @param "const string" title
* @param "const C_INT32" type
* @param "const string" i_str
* @param "const string" j_str
*/
CNodeO(string title, C_INT32 type, string i_str, string j_str);
/**
* Destructor
*/
~CNodeO();
/**
* Delete
*/
void cleanup();
/**
* Loads an object with data coming from a CReadConfig object.
* (CReadConfig object reads an input stream)
* @param pconfigbuffer reference to a CReadConfig object.
* @return Fail
*/
C_INT32 load(CReadConfig & configbuffer);
/**
* Saves the contents of the object to a CWriteConfig object.
* (Which usually has a file attached but may also have socket)
* @param pconfigbuffer reference to a CWriteConfig object.
* @return Fail
*/
C_INT32 save(CWriteConfig & configbuffer) const;
/**
* Retrieving the Title of a node
* @return string
*/
string getTitle() const;
/**
* Retrieving I String of a node
* @return string
*/
string getIString() const;
/**
* Retrieving J String of a node
* @return string
*/
string getJString() const;
/**
* Setting Title of the node
* @param "const string" &title
*/
void setTitle(const string& title);
/**
* Setting I String of the node
* @param "const string" &i_string
*/
void setIString(const string & i_string);
/**
* Setting I String of the node
* @param "const string" &j_string
*/
void setJString(const string & j_string);
/**
* Get the node's Datum type
*/
C_INT32 getDatumType() const;
/**
* Set the node's Datum Type
*/
void setDatumType(const C_INT32 datumType);
};
#endif
| |
Add test for unsigned array index. | // RUN: clang -checker-simple -verify %s &&
// RUN: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
int data_array[10];
};
typedef struct {
int data;
} STYPE;
void g1(struct s* p);
void f(void) {
int a[10];
int (*p)[10];
p = &a;
(*p)[3] = 1;
struct s d;
struct s *q;
q = &d;
q->data = 3;
d.data_array[9] = 17;
}
void f2() {
char *p = "/usr/local";
char (*q)[4];
q = &"abc";
}
void f3() {
STYPE s;
}
void f4() {
int a[] = { 1, 2, 3};
int b[3] = { 1, 2 };
}
void f5() {
struct s data;
g1(&data);
}
void f6() {
char *p;
p = __builtin_alloca(10);
p[1] = 'a';
}
struct s2;
void g2(struct s2 *p);
void f7() {
struct s2 *p = __builtin_alloca(10);
g2(p);
}
| // RUN: clang -checker-simple -verify %s &&
// RUN: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
int data_array[10];
};
typedef struct {
int data;
} STYPE;
void g1(struct s* p);
void f(void) {
int a[10];
int (*p)[10];
p = &a;
(*p)[3] = 1;
struct s d;
struct s *q;
q = &d;
q->data = 3;
d.data_array[9] = 17;
}
void f2() {
char *p = "/usr/local";
char (*q)[4];
q = &"abc";
}
void f3() {
STYPE s;
}
void f4() {
int a[] = { 1, 2, 3};
int b[3] = { 1, 2 };
}
void f5() {
struct s data;
g1(&data);
}
void f6() {
char *p;
p = __builtin_alloca(10);
p[1] = 'a';
}
struct s2;
void g2(struct s2 *p);
void f7() {
struct s2 *p = __builtin_alloca(10);
g2(p);
}
void f8() {
int a[10];
a[sizeof(a) - 1] = 1;
}
|
Fix width param name in put_video_frame_rx function pointer. | #ifndef __VIDEO_RX_H__
#define __VIDEO_RX_H__
#include "libavformat/avformat.h"
typedef struct DecodedFrame {
AVFrame* pFrameRGB;
uint8_t *buffer;
} DecodedFrame;
typedef struct FrameManager {
enum PixelFormat pix_fmt;
void (*put_video_frame_rx)(uint8_t *data, int with, int height, int nframe);
DecodedFrame* (*get_decoded_frame_buffer)(int width, int height);
void (*release_decoded_frame_buffer)(void);
} FrameManager;
int start_video_rx(const char* sdp, int maxDelay, FrameManager *frame_manager);
int stop_video_rx();
#endif /* __VIDEO_RX_H__ */
| #ifndef __VIDEO_RX_H__
#define __VIDEO_RX_H__
#include "libavformat/avformat.h"
typedef struct DecodedFrame {
AVFrame* pFrameRGB;
uint8_t *buffer;
} DecodedFrame;
typedef struct FrameManager {
enum PixelFormat pix_fmt;
void (*put_video_frame_rx)(uint8_t *data, int width, int height, int nframe);
DecodedFrame* (*get_decoded_frame_buffer)(int width, int height);
void (*release_decoded_frame_buffer)(void);
} FrameManager;
int start_video_rx(const char* sdp, int maxDelay, FrameManager *frame_manager);
int stop_video_rx();
#endif /* __VIDEO_RX_H__ */
|
Add missing prototype for fake_writev(). | #ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H
#ifdef TESTING
#ifdef __cplusplus
extern "C" {
#endif
int fake_read(int fd, void *buf, size_t count);
int fake_send(int fd, void *buf, size_t count, int flags);
#ifdef __cplusplus
}
#endif
#define READ fake_read
#define SEND fake_send
#define WRITEV fake_writev
#else
#define READ read
#define SEND send
#define WRITEV writev
#endif
#endif
| #ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H
#ifdef TESTING
#ifdef __cplusplus
extern "C" {
#endif
int fake_read(int fd, void *buf, size_t count);
int fake_send(int fd, void *buf, size_t count, int flags);
int fake_writev(int fd, const struct iovec *iov, int iovcnt);
#ifdef __cplusplus
}
#endif
#define READ fake_read
#define SEND fake_send
#define WRITEV fake_writev
#else
#define READ read
#define SEND send
#define WRITEV writev
#endif
#endif
|
Add class for holding transmission interfaces. | ///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013, PAL Robotics S.L.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of hiDOF, Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
//////////////////////////////////////////////////////////////////////////////
/// \author Adolfo Rodriguez Tsouroukdissian
#ifndef TRANSMISSION_INTERFACE_ROBOT_TRANSMISSIONS_H
#define TRANSMISSION_INTERFACE_ROBOT_TRANSMISSIONS_H
#include <hardware_interface/internal/interface_manager.h>
#include <hardware_interface/robot_hw.h>
namespace transmission_interface
{
/**
* \brief Robot transmissions interface.
*
* This class provides a standardized interface to a set of robot transmission interfaces that allow to map between
* actuator and joint spaces. It is meant to be used as a building block for robot hardware abstractions.
*
* This class implements a 1-to-1 map between the names of transmission interface types and instances of those
* interface types.
*/
class RobotTransmissions : public hardware_interface::InterfaceManager {};
} // namespace
#endif // header guard
| |
Make include guard more specific. | /*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2013 Scientific Computing and Imaging Institute,
University of Utah.
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.
*/
/// \author James Hughes
/// \date October 2013
#ifndef NAMESPACES_H
#define NAMESPACES_H
// 'Forward declaration' of namespaces.
namespace CPM_SPIRE_NS {}
namespace CPM_SPIRE_SCIRUN_NS {
// Renaming namespaces in our top level.
namespace spire = CPM_SPIRE_NS;
} // namespace CPM_SPIRE_SCIRUN_NS
#endif
| /*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2013 Scientific Computing and Imaging Institute,
University of Utah.
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.
*/
/// \author James Hughes
/// \date October 2013
#ifndef MODULE_SPIRE_SCIRUN_NAMESPACES_H
#define MODULE_SPIRE_SCIRUN_NAMESPACES_H
// 'Forward declaration' of namespaces.
namespace CPM_SPIRE_NS {}
namespace CPM_SPIRE_SCIRUN_NS {
namespace spire = CPM_SPIRE_NS;
} // namespace CPM_SPIRE_SCIRUN_NS
#endif
|
Add nodoc for beta fields. | #if __has_include(<Braintree/BraintreeVenmo.h>)
#import <Braintree/BraintreeCore.h>
#else
#import <BraintreeCore/BraintreeCore.h>
#endif
/**
Contains information about a Venmo Account payment method
*/
@interface BTVenmoAccountNonce : BTPaymentMethodNonce
/**
The email associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *email;
/**
The external ID associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *externalId;
/**
The first name associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *firstName;
/**
The last name associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *lastName;
/**
The phone number associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *phoneNumber;
/**
The username associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *username;
@end
| #if __has_include(<Braintree/BraintreeVenmo.h>)
#import <Braintree/BraintreeCore.h>
#else
#import <BraintreeCore/BraintreeCore.h>
#endif
/**
Contains information about a Venmo Account payment method
*/
@interface BTVenmoAccountNonce : BTPaymentMethodNonce
/**
:nodoc:
The email associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *email;
/**
:nodoc:
The external ID associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *externalId;
/**
:nodoc:
The first name associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *firstName;
/**
:nodoc:
The last name associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *lastName;
/**
:nodoc:
The phone number associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *phoneNumber;
/**
The username associated with the Venmo account
*/
@property (nonatomic, nullable, readonly, copy) NSString *username;
@end
|
Add headers to request data | #ifndef APIMOCK_REQUESTDATA_H
#define APIMOCK_REQUESTDATA_H
#include <string>
namespace ApiMock {
struct RequestData {
enum HTTP_VERSION {
HTTP_1_1,
} httpVersion;
enum METHOD {
GET,
POST,
PUT,
DELETE,
} method;
std::string requestUri;
};
}
#endif | #ifndef APIMOCK_REQUESTDATA_H
#define APIMOCK_REQUESTDATA_H
#include <string>
#include <unordered_map>
namespace ApiMock {
struct RequestData {
enum HTTP_VERSION {
HTTP_1_1,
} httpVersion;
enum METHOD {
GET,
POST,
PUT,
DELETE,
} method;
std::string requestUri;
std::unordered_map<std::string, std::string> headers;
};
}
#endif |
Fix grammar mistake in comment. | /*
* Generic NUMBBO runtime implementation.
*
* Other language interfaces might want to replace this so that memory
* allocation and error handling goes through the respective language
* runtime.
*/
#include <stdio.h>
#include <stdlib.h>
#include "numbbo.h"
void numbbo_error(const char *message) {
fprintf(stderr, "FATAL ERROR: %s\n", message);
exit(EXIT_FAILURE);
}
void numbbo_warning(const char *message) {
fprintf(stderr, "WARNING: %s\n", message);
}
void *numbbo_allocate_memory(size_t size) {
void *data = malloc(size);
if (data == NULL)
numbbo_error("numbbo_allocate_memory() failed.");
return data;
}
void numbbo_free_memory(void *data) {
free(data);
}
| /*
* Generic NUMBBO runtime implementation.
*
* Other language interfaces might want to replace this so that memory
* allocation and error handling go through the respective language
* runtime.
*/
#include <stdio.h>
#include <stdlib.h>
#include "numbbo.h"
void numbbo_error(const char *message) {
fprintf(stderr, "FATAL ERROR: %s\n", message);
exit(EXIT_FAILURE);
}
void numbbo_warning(const char *message) {
fprintf(stderr, "WARNING: %s\n", message);
}
void *numbbo_allocate_memory(size_t size) {
void *data = malloc(size);
if (data == NULL)
numbbo_error("numbbo_allocate_memory() failed.");
return data;
}
void numbbo_free_memory(void *data) {
free(data);
}
|
Add solution to Exercise 1-5. | /* Modify the temperature conversion program to print the table in reverse
* order, that is, from 300 degrees to 0. */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
printf("F\tC\n=============\n");
float i;
for (i = 300; i >= 0; i -= 20) {
printf("%3.0f\t%5.1f\n", i, (5.0 / 9.0) * (i - 32.0));
}
return EXIT_SUCCESS;
}
| |
Update Skia milestone to 106 | /*
* 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 105
#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 106
#endif
|
Update Skia milestone to 71 | /*
* 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 70
#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 71
#endif
|
Update Skia milestone to 63 | /*
* 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 62
#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 63
#endif
|
Make this test case more portable by removing its dependency on system header files. | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region --verify %s
// Test if the 'storage' region gets properly initialized after it is cast to
// 'struct sockaddr *'.
#include <sys/types.h>
#include <sys/socket.h>
void f(int sock) {
struct sockaddr_storage storage;
struct sockaddr* sockaddr = (struct sockaddr*)&storage;
socklen_t addrlen = sizeof(storage);
getsockname(sock, sockaddr, &addrlen);
switch (sockaddr->sa_family) { // no-warning
default:
;
}
}
struct s {
struct s *value;
};
void f1(struct s **pval) {
int *tbool = ((void*)0);
struct s *t = *pval;
pval = &(t->value);
tbool = (int *)pval; // Should record the cast-to type here.
char c = (unsigned char) *tbool; // Should use cast-to type to create symbol.
if (*tbool == -1)
(void)3;
}
void f2(const char *str) {
unsigned char ch, cl, *p;
p = (unsigned char *)str;
ch = *p++; // use cast-to type 'unsigned char' to create element region.
cl = *p++;
if(!cl)
cl = 'a';
}
| // RUN: clang-cc -triple x86_64-apple-darwin9 -analyze -checker-cfref -analyzer-store=region --verify %s
// Test if the 'storage' region gets properly initialized after it is cast to
// 'struct sockaddr *'.
typedef unsigned char __uint8_t;
typedef unsigned int __uint32_t;
typedef __uint32_t __darwin_socklen_t;
typedef __uint8_t sa_family_t;
typedef __darwin_socklen_t socklen_t;
struct sockaddr { sa_family_t sa_family; };
struct sockaddr_storage {};
void f(int sock) {
struct sockaddr_storage storage;
struct sockaddr* sockaddr = (struct sockaddr*)&storage;
socklen_t addrlen = sizeof(storage);
getsockname(sock, sockaddr, &addrlen);
switch (sockaddr->sa_family) { // no-warning
default:
;
}
}
struct s {
struct s *value;
};
void f1(struct s **pval) {
int *tbool = ((void*)0);
struct s *t = *pval;
pval = &(t->value);
tbool = (int *)pval; // Should record the cast-to type here.
char c = (unsigned char) *tbool; // Should use cast-to type to create symbol.
if (*tbool == -1)
(void)3;
}
void f2(const char *str) {
unsigned char ch, cl, *p;
p = (unsigned char *)str;
ch = *p++; // use cast-to type 'unsigned char' to create element region.
cl = *p++;
if(!cl)
cl = 'a';
}
|
Use -target instead of triple and use FileCheck. | // RUN: %clang -### %s -c -o tmp.o -triple i686-pc-linux-gnu -integrated-as -Wa,--noexecstack 2>&1 | grep "mnoexecstack"
| // RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as -Wa,--noexecstack 2>&1 | FileCheck %s
// CHECK: "-cc1" {{.*}} "-mnoexecstack"
|
Test clang option for the Memory Tagging Extension | // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+memtag %s 2>&1 | FileCheck %s
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+memtag %s 2>&1 | FileCheck %s
// CHECK: "-target-feature" "+mte"
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+nomemtag %s 2>&1 | FileCheck %s --check-prefix=NOMTE
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+nomemtag %s 2>&1 | FileCheck %s --check-prefix=NOMTE
// NOMTE: "-target-feature" "-mte"
// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENTMTE
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a %s 2>&1 | FileCheck %s --check-prefix=ABSENTMTE
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a %s 2>&1 | FileCheck %s --check-prefix=ABSENTMTE
// ABSENTMTE-NOT: "-target-feature" "+mte"
// ABSENTMTE-NOT: "-target-feature" "-mte"
| |
Change definition of Image struct so all width/height fields are signed integers. Add fields to Image struct that deal with collision masking. | typedef struct
{
unsigned long long int width,height;
long long int handle_x,handle_y;
GLuint texture;
SDL_Surface *surface;
GLuint mask;
} Image;
void bb_fatal_error(char *msg);
| typedef struct
{
long long int width,height;
long long int width_frames,height_frames;
long long int handle_x,handle_y;
GLuint *textures;
SDL_Surface *surface;
GLuint mask_color;
unsigned long long int **masks;
unsigned long long int mask_width;
unsigned long long int mask_height;
} Image;
void bb_fatal_error(char *msg);
|
Add use_ino to see if it helps our rename replay bug. | /* $Id$ */
/*
* %PSC_START_COPYRIGHT%
* -----------------------------------------------------------------------------
* Copyright (c) 2006-2010, Pittsburgh Supercomputing Center (PSC).
*
* Permission to use, copy, and modify this software and its documentation
* without fee for personal use or non-commercial use within your organization
* is hereby granted, provided that the above copyright notice is preserved in
* all copies and that the copyright and this permission notice appear in
* supporting documentation. Permission to redistribute this software to other
* organizations or individuals is not permitted without the written permission
* of the Pittsburgh Supercomputing Center. PSC makes no representations about
* the suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
* -----------------------------------------------------------------------------
* %PSC_END_COPYRIGHT%
*/
#ifndef _FUSE_LISTENER_H_
#define _FUSE_LISTENER_H_
#include <fuse_lowlevel.h>
#define FUSE_OPTIONS "allow_other,max_write=134217728,big_writes"
void slash2fuse_listener_exit(void);
int slash2fuse_listener_init(void);
int slash2fuse_listener_start(void);
int slash2fuse_newfs(const char *, struct fuse_chan *);
extern int exit_fuse_listener;
#endif /* _FUSE_LISTENER_H_ */
| /* $Id$ */
/*
* %PSC_START_COPYRIGHT%
* -----------------------------------------------------------------------------
* Copyright (c) 2006-2010, Pittsburgh Supercomputing Center (PSC).
*
* Permission to use, copy, and modify this software and its documentation
* without fee for personal use or non-commercial use within your organization
* is hereby granted, provided that the above copyright notice is preserved in
* all copies and that the copyright and this permission notice appear in
* supporting documentation. Permission to redistribute this software to other
* organizations or individuals is not permitted without the written permission
* of the Pittsburgh Supercomputing Center. PSC makes no representations about
* the suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
* -----------------------------------------------------------------------------
* %PSC_END_COPYRIGHT%
*/
#ifndef _FUSE_LISTENER_H_
#define _FUSE_LISTENER_H_
#include <fuse_lowlevel.h>
/* The following options are explained in FUSE README file */
#define FUSE_OPTIONS "use_ino,allow_other,max_write=134217728,big_writes"
void slash2fuse_listener_exit(void);
int slash2fuse_listener_init(void);
int slash2fuse_listener_start(void);
int slash2fuse_newfs(const char *, struct fuse_chan *);
extern int exit_fuse_listener;
#endif /* _FUSE_LISTENER_H_ */
|
Add new typedef for values sent to setsockopt(). |
#ifndef AT_NETWORK_H
#define AT_NETWORK_H
// Under Windows, define stuff that we need
#ifdef _MSC_VER
#include <winsock.h>
#define MAXHOSTNAMELEN 64
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define MSG_WAITALL 0
typedef SOCKET Socket;
typedef int socklen_t;
typedef char SocketOptionFlag;
#else
#include <unistd.h>
#include <string.h>
#include <netdb.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/select.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
typedef int Socket;
typedef int SocketOptionFlag;
#endif
void initNetwork();
void cleanupNetwork();
Socket openSocket(int domain, int type, int protocol);
void closeSocket(Socket socket);
void setBlockingFlag(Socket socket, bool block);
bool getBlockingFlag(Socket socket);
#endif
|
#ifndef AT_NETWORK_H
#define AT_NETWORK_H
// Under Windows, define stuff that we need
#ifdef _MSC_VER
#include <winsock.h>
#define MAXHOSTNAMELEN 64
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define MSG_WAITALL 0
typedef SOCKET Socket;
typedef int socklen_t;
typedef char SocketOptionFlag;
typedef int SocketOptionValue;
#else
#include <unistd.h>
#include <string.h>
#include <netdb.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/select.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
typedef int Socket;
typedef int SocketOptionFlag;
typedef int SocketOptionValue;
#endif
void initNetwork();
void cleanupNetwork();
Socket openSocket(int domain, int type, int protocol);
void closeSocket(Socket socket);
void setBlockingFlag(Socket socket, bool block);
bool getBlockingFlag(Socket socket);
#endif
|
Add TODO to replace ratpoison. | /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Maps and raises the specified window id (integer).
*/
#include <X11/Xlib.h>
#include <stdlib.h>
int main(int argc, char** argv) {
if (argc != 2) return 2;
Display* display = XOpenDisplay(NULL);
if (!display) return 1;
XMapRaised(display, atoi(argv[1]));
XCloseDisplay(display);
return 0;
}
| /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Maps and raises the specified window id (integer).
*/
/* TODO: use XResizeWindow to do the +1 width ratpoison hack.
* And at this point, we might as well use XMoveResizeWindow, rename this to
* wmtool and unmap the previously-mapped window, and perhaps call the
* equivalent of XRefresh, eliminating the need for ratpoison entirely (!!).
*/
#include <X11/Xlib.h>
#include <stdlib.h>
int main(int argc, char** argv) {
if (argc != 2) return 2;
Display* display = XOpenDisplay(NULL);
if (!display) return 1;
XMapRaised(display, atoi(argv[1]));
XCloseDisplay(display);
return 0;
}
|
Test to ensure that data layout is generated correctly for host platform. This is for PR1242. | // Testcase for PR1242
// RUN: %llvmgcc -c %s -o %t && lli --force-interpreter=1 %t
#include <stdlib.h>
#define NDIM 3
#define BODY 01
typedef double vector[NDIM];
typedef struct bnode* bodyptr;
// { i16, double, [3 x double], i32, i32, [3 x double], [3 x double], [3 x
// double], double, \2 *, \2 * }
struct bnode {
short int type;
double mass;
vector pos;
int proc;
int new_proc;
vector vel;
vector acc;
vector new_acc;
double phi;
bodyptr next;
bodyptr proc_next;
} body;
#define Type(x) ((x)->type)
#define Mass(x) ((x)->mass)
#define Pos(x) ((x)->pos)
#define Proc(x) ((x)->proc)
#define New_Proc(x) ((x)->new_proc)
#define Vel(x) ((x)->vel)
#define Acc(x) ((x)->acc)
#define New_Acc(x) ((x)->new_acc)
#define Phi(x) ((x)->phi)
#define Next(x) ((x)->next)
#define Proc_Next(x) ((x)->proc_next)
bodyptr ubody_alloc(int p)
{
register bodyptr tmp;
tmp = (bodyptr)malloc(sizeof(body));
Type(tmp) = BODY;
Proc(tmp) = p;
Proc_Next(tmp) = NULL;
New_Proc(tmp) = p;
return tmp;
}
int main(int argc, char** argv) {
bodyptr b = ubody_alloc(17);
return 0;
}
| |
Fix clang warning in tests for Chrome OS | // 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_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#pragma once
#include <string>
#include <vector>
#include "chrome/browser/chromeos/login/user_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockUserManager : public UserManager {
public:
MockUserManager() {}
virtual ~MockUserManager() {}
MOCK_CONST_METHOD0(GetUsers, std::vector<User>());
MOCK_METHOD0(OffTheRecordUserLoggedIn, void());
MOCK_METHOD1(UserLoggedIn, void(const std::string&));
MOCK_METHOD1(RemoveUser, void(const std::string&));
MOCK_METHOD1(IsKnownUser, bool(const std::string&));
MOCK_CONST_METHOD0(logged_in_user, const User&());
MOCK_METHOD0(current_user_is_owner, bool());
MOCK_METHOD1(set_current_user_is_owner, void(bool));
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_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_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
#pragma once
#include <string>
#include <vector>
#include "chrome/browser/chromeos/login/user_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockUserManager : public UserManager {
public:
MockUserManager() {}
virtual ~MockUserManager() {}
MOCK_CONST_METHOD0(GetUsers, std::vector<User>());
MOCK_METHOD0(OffTheRecordUserLoggedIn, void());
MOCK_METHOD1(UserLoggedIn, void(const std::string&));
MOCK_METHOD2(RemoveUser, void(const std::string&, RemoveUserDelegate*));
MOCK_METHOD1(IsKnownUser, bool(const std::string&));
MOCK_CONST_METHOD0(logged_in_user, const User&());
MOCK_CONST_METHOD0(current_user_is_owner, bool());
MOCK_METHOD1(set_current_user_is_owner, void(bool));
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
|
Fix the run line for this test. | // RUN: clang -fsyntax-only %s
%:include <stdio.h>
%:ifndef BUFSIZE
%:define BUFSIZE 512
%:endif
void copy(char d<::>, const char s<::>, int len)
<%
while (len-- >= 0)
<%
d<:len:> = s<:len:>;
%>
%>
| // RUN: clang -fsyntax-only -verify < %s
%:include <stdio.h>
%:ifndef BUFSIZE
%:define BUFSIZE 512
%:endif
void copy(char d<::>, const char s<::>, int len)
<%
while (len-- >= 0)
<%
d<:len:> = s<:len:>;
%>
%>
|
Check error codes when sending. | #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "gpio.h"
#include "led.h"
#include "radio.h"
void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
{
gpio_pin_toggle(i);
nrf_delay_us(50000);
}
}
}
void radio_evt_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;
radio_init(radio_evt_handler);
gpio_pins_cfg_out(LED_START, LED_STOP);
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
radio_send(&packet);
gpio_pin_toggle(LED0);
nrf_delay_us(1000000);
}
}
| #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "nrf51.h"
#include "nrf_delay.h"
#include "error.h"
#include "gpio.h"
#include "led.h"
#include "radio.h"
void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
{
gpio_pin_toggle(i);
nrf_delay_us(50000);
}
}
}
void radio_evt_handler(radio_evt_t * evt)
{
}
int main(void)
{
uint8_t i = 0;
uint32_t err_code;
radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;
radio_init(radio_evt_handler);
gpio_pins_cfg_out(LED_START, LED_STOP);
while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);
gpio_pin_toggle(LED0);
nrf_delay_us(1000000);
}
}
|
Add comment for why USDTHelper is static | #pragma once
#include <string>
#include <vector>
struct usdt_probe_entry
{
std::string path;
std::string provider;
std::string name;
int num_locations;
};
typedef std::vector<usdt_probe_entry> usdt_probe_list;
class USDTHelper
{
public:
static usdt_probe_entry find(int pid,
const std::string &target,
const std::string &provider,
const std::string &name);
static usdt_probe_list probes_for_provider(const std::string &provider);
static usdt_probe_list probes_for_pid(int pid);
static usdt_probe_list probes_for_path(const std::string &path);
static void read_probes_for_pid(int pid);
static void read_probes_for_path(const std::string &path);
};
| #pragma once
#include <string>
#include <vector>
struct usdt_probe_entry
{
std::string path;
std::string provider;
std::string name;
int num_locations;
};
typedef std::vector<usdt_probe_entry> usdt_probe_list;
// Note this class is fully static because bcc_usdt_foreach takes a function
// pointer callback without a context variable. So we must keep global state.
class USDTHelper
{
public:
static usdt_probe_entry find(int pid,
const std::string &target,
const std::string &provider,
const std::string &name);
static usdt_probe_list probes_for_provider(const std::string &provider);
static usdt_probe_list probes_for_pid(int pid);
static usdt_probe_list probes_for_path(const std::string &path);
static void read_probes_for_pid(int pid);
static void read_probes_for_path(const std::string &path);
};
|
Use strong storage for component local image | #import <UIKit/UIKit.h>
#import "HUBComponentImageData.h"
NS_ASSUME_NONNULL_BEGIN
/**
* Protocol defining the public API for a builder that builds image data objects
*
* This builder acts like a mutable model counterpart for `HUBComponentImageData`, with the key
* difference that they are not related by inheritance.
*
* All properties are briefly documented as part of this protocol, but for more extensive
* documentation and use case examples, see the full documentation in the `HUBComponentImageData`
* protocol definition.
*
* In order to successfully build an image data object (and not return nil), the builder must
* have either have a non-nil `URL` or `iconIdentifier` property.
*/
@protocol HUBComponentImageDataBuilder <NSObject>
/// The style that the image should be rendered in
@property (nonatomic) HUBComponentImageStyle style;
/// Any HTTP URL of a remote image that should be downloaded and then rendered
@property (nonatomic, copy, nullable) NSURL *URL;
/// Any local image that should be used, either as a placeholder or a permanent image
@property (nonatomic, copy, nullable) UIImage *localImage;
/// Any identifier of an icon that should be used with the image, either as a placeholder or permanent image
@property (nonatomic, copy, nullable) NSString *iconIdentifier;
@end
NS_ASSUME_NONNULL_END
| #import <UIKit/UIKit.h>
#import "HUBComponentImageData.h"
NS_ASSUME_NONNULL_BEGIN
/**
* Protocol defining the public API for a builder that builds image data objects
*
* This builder acts like a mutable model counterpart for `HUBComponentImageData`, with the key
* difference that they are not related by inheritance.
*
* All properties are briefly documented as part of this protocol, but for more extensive
* documentation and use case examples, see the full documentation in the `HUBComponentImageData`
* protocol definition.
*
* In order to successfully build an image data object (and not return nil), the builder must
* have either have a non-nil `URL` or `iconIdentifier` property.
*/
@protocol HUBComponentImageDataBuilder <NSObject>
/// The style that the image should be rendered in
@property (nonatomic) HUBComponentImageStyle style;
/// Any HTTP URL of a remote image that should be downloaded and then rendered
@property (nonatomic, copy, nullable) NSURL *URL;
/// Any local image that should be used, either as a placeholder or a permanent image
@property (nonatomic, strong, nullable) UIImage *localImage;
/// Any identifier of an icon that should be used with the image, either as a placeholder or permanent image
@property (nonatomic, copy, nullable) NSString *iconIdentifier;
@end
NS_ASSUME_NONNULL_END
|
Make this destructor virtual to placate GCC's warnings. | //===- PCHDeserializationListener.h - Decl/Type PCH Read Events -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the PCHDeserializationListener class, which is notified
// by the PCHReader whenever a type or declaration is deserialized.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_PCH_DESERIALIZATION_LISTENER_H
#define LLVM_CLANG_FRONTEND_PCH_DESERIALIZATION_LISTENER_H
#include "clang/Frontend/PCHBitCodes.h"
namespace clang {
class Decl;
class QualType;
class PCHDeserializationListener {
protected:
~PCHDeserializationListener() {}
public:
/// \brief A type was deserialized from the PCH. The ID here has the qualifier
/// bits already removed, and T is guaranteed to be locally unqualified
virtual void TypeRead(pch::TypeID ID, QualType T) = 0;
/// \brief A decl was deserialized from the PCH.
virtual void DeclRead(pch::DeclID ID, const Decl *D) = 0;
};
}
#endif
| //===- PCHDeserializationListener.h - Decl/Type PCH Read Events -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the PCHDeserializationListener class, which is notified
// by the PCHReader whenever a type or declaration is deserialized.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_PCH_DESERIALIZATION_LISTENER_H
#define LLVM_CLANG_FRONTEND_PCH_DESERIALIZATION_LISTENER_H
#include "clang/Frontend/PCHBitCodes.h"
namespace clang {
class Decl;
class QualType;
class PCHDeserializationListener {
protected:
virtual ~PCHDeserializationListener() {}
public:
/// \brief A type was deserialized from the PCH. The ID here has the qualifier
/// bits already removed, and T is guaranteed to be locally unqualified
virtual void TypeRead(pch::TypeID ID, QualType T) = 0;
/// \brief A decl was deserialized from the PCH.
virtual void DeclRead(pch::DeclID ID, const Decl *D) = 0;
};
}
#endif
|
Increase the delay before producing exception in the Monitor IDE test app | /* Monitor-IDE integration test
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
void app_main(void)
{
int *p = (int *)4;
vTaskDelay(1000 / portTICK_PERIOD_MS);
*p = 0;
}
| /* Monitor-IDE integration test
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
void app_main(void)
{
int *p = (int *)4;
vTaskDelay(2000 / portTICK_PERIOD_MS);
*p = 0;
}
|
Remove unused special case for Mac OS X | /*
* Copyright 2008 The Native Client 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 SERVICE_RUNTIME_NACL_SYSCALL_H__
#define SERVICE_RUNTIME_NACL_SYSCALL_H__
#if !NACL_MACOSX || defined(NACL_STANDALONE)
extern int NaClSyscallSeg();
#else
// This declaration is used only on Mac OSX for Chrome build
extern int NaClSyscallSeg() __attribute__((weak_import));
#endif
#endif
| /*
* Copyright 2008 The Native Client 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 SERVICE_RUNTIME_NACL_SYSCALL_H__
#define SERVICE_RUNTIME_NACL_SYSCALL_H__
extern int NaClSyscallSeg();
#endif
|
Include qtwebkitversion.h to work in newer qtwebkit | #include "SocketCommand.h"
class Version : public SocketCommand {
Q_OBJECT
public:
Version(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
| #include "qtwebkitversion.h"
#include "SocketCommand.h"
class Version : public SocketCommand {
Q_OBJECT
public:
Version(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
|
Add comment for recalled message | //
// AVIMRecalledMessage.h
// AVOS
//
// Created by Tang Tianyong on 26/06/2017.
// Copyright © 2017 LeanCloud Inc. All rights reserved.
//
#import "AVIMTypedMessage.h"
NS_ASSUME_NONNULL_BEGIN
@interface AVIMRecalledMessage : AVIMTypedMessage <AVIMTypedMessageSubclassing>
@end
NS_ASSUME_NONNULL_END
| //
// AVIMRecalledMessage.h
// AVOS
//
// Created by Tang Tianyong on 26/06/2017.
// Copyright © 2017 LeanCloud Inc. All rights reserved.
//
#import "AVIMTypedMessage.h"
NS_ASSUME_NONNULL_BEGIN
/**
This class is a type of messages that have been recalled by its sender.
*/
@interface AVIMRecalledMessage : AVIMTypedMessage <AVIMTypedMessageSubclassing>
@end
NS_ASSUME_NONNULL_END
|
Add test for octApron combine where arg vars conflict | // SKIP PARAM: --sets ana.activated[+] octApron
#include <assert.h>
int f(int x) {
return x + 1;
}
int g(int x) {
int y;
y = f(x);
assert(y == x + 1);
return x;
}
int main(void) {
int z, w;
w = g(z);
assert(z == w);
return 0;
}
| |
Add more rationale as to how this exception is different from others. | //--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Axel Naumann <axel@cern.ch>
//------------------------------------------------------------------------------
#ifndef CLING_COMPILATIONEXCEPTION_H
#define CLING_COMPILATIONEXCEPTION_H
#include <stdexcept>
#include <string>
#include "cling/Interpreter/RuntimeException.h"
namespace cling {
class Interpreter;
class MetaProcessor;
//\brief Exception pull us out of JIT (llvm + clang) errors.
class CompilationException:
public virtual runtime::InterpreterException,
public virtual std::runtime_error {
public:
CompilationException(const std::string& reason):
std::runtime_error(reason) {}
~CompilationException() throw(); // vtable pinned to UserInterface.cpp
virtual const char* what() const throw() {
return std::runtime_error::what(); }
};
}
#endif // CLING_COMPILATIONEXCEPTION_H
| //--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Axel Naumann <axel@cern.ch>
//------------------------------------------------------------------------------
#ifndef CLING_COMPILATIONEXCEPTION_H
#define CLING_COMPILATIONEXCEPTION_H
#include <stdexcept>
#include <string>
#include "cling/Interpreter/RuntimeException.h"
namespace cling {
class Interpreter;
class MetaProcessor;
///\brief Exception that pulls cling out of runtime-compilation (llvm + clang)
/// errors.
///
/// If user code provokes an llvm::unreachable it will cause this exception
/// to be thrown. Given that this is at the process's runtime and an
/// interpreter error it inherits from InterpreterException and runtime_error.
/// Note that this exception is *not* thrown during the execution of the
/// user's code but during its compilation (at runtime).
class CompilationException:
public virtual runtime::InterpreterException,
public virtual std::runtime_error {
public:
CompilationException(const std::string& reason):
std::runtime_error(reason) {}
~CompilationException() throw(); // vtable pinned to UserInterface.cpp
virtual const char* what() const throw() {
return std::runtime_error::what(); }
};
}
#endif // CLING_COMPILATIONEXCEPTION_H
|
Add mpiCC source for MPI test | #include "mpi.h"
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv) {
// Variables used per process
int myid, numprocs;
int myresult = 0;
// Global variables
int DATA_SIZE = argc;
int data[DATA_SIZE], result;
// Chunk control variables
int i, low, high, size;
//-------------------------------------------
// INIT
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
//-------------------------------------------
// PROCESS 0 GETS THE DATA
if (myid == 0) {
// Get data from args
for (i = 0; i < argc; ++i) {
data[i] = argv[i];
}
}
// Distribute the Data
MPI_Bcast(data, MAXSIZE, MPI_INT, 0, MPI_COMM_WORLD);
//-------------------------------------------
// EACH PROCESS COMPUTES ITS PART
size = DATA_SIZE/numprocs;
low = myid * size;
high = low + size;
for (i = low; i < high; ++i) {
myresult += data[i];
}
//printf("I got %d from %d\n", myresult, myid);
//-------------------------------------------
// COMPUTE GLOBAL SUM
MPI_Reduce(&myresult, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
//-------------------------------------------
// PROCESS 0 PRINTS THE RESULT
if (myid == 0) {
printf("%d\n", result);
}
//-------------------------------------------
// FINISH
MPI_Finalize();
} | |
Fix ARC warning in demo project. | //
// SVProgressHUDAppDelegate.h
// SVProgressHUD
//
// Created by Sam Vermette on 27.03.11.
// Copyright 2011 Sam Vermette. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *__weak window;
ViewController *__weak viewController;
}
@property (weak, nonatomic) IBOutlet UIWindow *window;
@property (weak, nonatomic) IBOutlet ViewController *viewController;
@end
| //
// SVProgressHUDAppDelegate.h
// SVProgressHUD
//
// Created by Sam Vermette on 27.03.11.
// Copyright 2011 Sam Vermette. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : NSObject <UIApplicationDelegate>
@property (strong, nonatomic) IBOutlet UIWindow *window;
@property (strong, nonatomic) IBOutlet ViewController *viewController;
@end
|
Remove unnecessary member variable in SerializationOperation | #pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATIONS_SERIALIZATION_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATIONS_SERIALIZATION_OPERATION_H_
#include "../operation.h"
namespace You {
namespace DataStore {
namespace Internal {
class SerializationOperation : public IOperation {
public:
/// Serialize task to an xml node
static void serialize(const SerializedTask&, pugi::xml_node&);
/// Deserialize task from an xml node
static SerializedTask deserialize(const pugi::xml_node&);
private:
/// The new task contents.
SerializedTask task;
};
} // namespace Internal
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_INTERNAL_OPERATIONS_SERIALIZATION_OPERATION_H_
| #pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATIONS_SERIALIZATION_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATIONS_SERIALIZATION_OPERATION_H_
#include "../operation.h"
namespace You {
namespace DataStore {
namespace Internal {
class SerializationOperation : public IOperation {
public:
/// Serialize task to an xml node
static void serialize(const SerializedTask&, pugi::xml_node&);
/// Deserialize task from an xml node
static SerializedTask deserialize(const pugi::xml_node&);
};
} // namespace Internal
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_INTERNAL_OPERATIONS_SERIALIZATION_OPERATION_H_
|
Remove "fmgr.h" include in cube contrib --- caused crash on a Gentoo builfarm member. | /* contrib/cube/cubedata.h */
#include "fmgr.h"
#define CUBE_MAX_DIM (100)
typedef struct NDBOX
{
int32 vl_len_; /* varlena header (do not touch directly!) */
unsigned int dim;
double x[1];
} NDBOX;
#define DatumGetNDBOX(x) ((NDBOX*)DatumGetPointer(x))
#define PG_GETARG_NDBOX(x) DatumGetNDBOX( PG_DETOAST_DATUM(PG_GETARG_DATUM(x)) )
#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x)
| /* contrib/cube/cubedata.h */
#define CUBE_MAX_DIM (100)
typedef struct NDBOX
{
int32 vl_len_; /* varlena header (do not touch directly!) */
unsigned int dim;
double x[1];
} NDBOX;
#define DatumGetNDBOX(x) ((NDBOX*)DatumGetPointer(x))
#define PG_GETARG_NDBOX(x) DatumGetNDBOX( PG_DETOAST_DATUM(PG_GETARG_DATUM(x)) )
#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x)
|
Add IWYU tags to headers TF is re-exporting. | /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// Simple benchmarking facility.
#ifndef TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_
#define TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_
#include "tensorflow/core/platform/platform.h"
#if defined(PLATFORM_GOOGLE)
#include "tensorflow/core/platform/google/test_benchmark.h"
#else
#include "tensorflow/core/platform/default/test_benchmark.h"
#endif // PLATFORM_GOOGLE
#endif // TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_
| /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// Simple benchmarking facility.
#ifndef TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_
#define TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_
#include "tensorflow/core/platform/platform.h"
#if defined(PLATFORM_GOOGLE)
#include "tensorflow/core/platform/google/test_benchmark.h" // IWYU pragma: export
#else
#include "tensorflow/core/platform/default/test_benchmark.h" // IWYU pragma: export
#endif // PLATFORM_GOOGLE
#endif // TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_
|
Add externs for use in C++ code | #ifndef __TINYARG_H__
#define __TINYARG_H__
struct tiny_args_t;
bool tiny_args_parse(struct tiny_args_t* args, int argc, const char* argv[]);
void tiny_args_add_bool(struct tiny_args_t** args,
char short_opt,
const char* long_opt,
bool* flag,
const char* desc);
void tiny_args_add_str(struct tiny_args_t** args,
char short_opt,
const char* long_opt,
char* str,
size_t str_len,
const char* desc);
void tiny_args_usage(const char* process_name, struct tiny_args_t* args);
void tiny_args_destroy(struct tiny_args_t* args);
#endif /* __TINYARG_H__ */
| #ifndef __TINYARG_H__
#define __TINYARG_H__
#ifdef __cplusplus
extern "C"
{
#endif
struct tiny_args_t;
bool tiny_args_parse(struct tiny_args_t* args, int argc, const char* argv[]);
void tiny_args_add_bool(struct tiny_args_t** args,
char short_opt,
const char* long_opt,
bool* flag,
const char* desc);
void tiny_args_add_str(struct tiny_args_t** args,
char short_opt,
const char* long_opt,
char* str,
size_t str_len,
const char* desc);
void tiny_args_usage(const char* process_name, struct tiny_args_t* args);
void tiny_args_destroy(struct tiny_args_t* args);
#ifdef __cplusplus
}
#endif
#endif /* __TINYARG_H__ */
|
Change file header to C style | /**
* File: bool.h
* Author: Cindy Norris
*/
#define TRUE 1
#define FALSE 0
typedef int bool;
| /*
* File: bool.h
* Author: Cindy Norris
*/
#define TRUE 1
#define FALSE 0
typedef int bool;
|
Add einsum to the one file build | /*
* This file includes all the .c files needed for a complete multiarray module.
* This is used in the case where separate compilation is not enabled
*
* Note that the order of the includs matters
*/
#include "common.c"
#include "scalartypes.c"
#include "scalarapi.c"
#include "datetime.c"
#include "arraytypes.c"
#include "hashdescr.c"
#include "numpyos.c"
#include "descriptor.c"
#include "flagsobject.c"
#include "ctors.c"
#include "iterators.c"
#include "mapping.c"
#include "number.c"
#include "getset.c"
#include "sequence.c"
#include "methods.c"
#include "convert_datatype.c"
#include "convert.c"
#include "shape.c"
#include "item_selection.c"
#include "calculation.c"
#include "usertypes.c"
#include "refcount.c"
#include "conversion_utils.c"
#include "buffer.c"
#include "new_iterator.c"
#include "new_iterator_pywrap.c"
#include "lowlevel_strided_loops.c"
#include "dtype_transfer.c"
#ifndef Py_UNICODE_WIDE
#include "ucsnarrow.c"
#endif
#include "arrayobject.c"
#include "numpymemoryview.c"
#include "multiarraymodule.c"
| /*
* This file includes all the .c files needed for a complete multiarray module.
* This is used in the case where separate compilation is not enabled
*
* Note that the order of the includs matters
*/
#include "common.c"
#include "scalartypes.c"
#include "scalarapi.c"
#include "datetime.c"
#include "arraytypes.c"
#include "hashdescr.c"
#include "numpyos.c"
#include "descriptor.c"
#include "flagsobject.c"
#include "ctors.c"
#include "iterators.c"
#include "mapping.c"
#include "number.c"
#include "getset.c"
#include "sequence.c"
#include "methods.c"
#include "convert_datatype.c"
#include "convert.c"
#include "shape.c"
#include "item_selection.c"
#include "calculation.c"
#include "usertypes.c"
#include "refcount.c"
#include "conversion_utils.c"
#include "buffer.c"
#include "new_iterator.c"
#include "new_iterator_pywrap.c"
#include "lowlevel_strided_loops.c"
#include "dtype_transfer.c"
#include "einsum.c"
#ifndef Py_UNICODE_WIDE
#include "ucsnarrow.c"
#endif
#include "arrayobject.c"
#include "numpymemoryview.c"
#include "multiarraymodule.c"
|
Make sure TestRedefinitionsInInlines.py actually inlines. | #include <stdio.h>
void test1(int) __attribute__ ((always_inline));
void test2(int) __attribute__ ((always_inline));
void test2(int b) {
printf("test2(%d)\n", b); //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"])
}
void test1(int a) {
printf("test1(%d)\n", a);
test2(a+1);//% self.dbg.HandleCommand("step")
//% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["24"])
}
int main() {
test2(42);
test1(23);
}
| #include <stdio.h>
inline void test1(int) __attribute__ ((always_inline));
inline void test2(int) __attribute__ ((always_inline));
void test2(int b) {
printf("test2(%d)\n", b); //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"])
}
void test1(int a) {
printf("test1(%d)\n", a);
test2(a+1);//% self.dbg.HandleCommand("step")
//% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["24"])
}
int main() {
test2(42);
test1(23);
}
|
Fix warnings in OpenViewCore module | /*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef __QVTKFramebufferObjectRenderer_h
#define __QVTKFramebufferObjectRenderer_h
#include <QQuickFramebufferObject>
#include "QVTKQuickItem.h"
#include <MitkOpenViewCoreExports.h>
class vtkInternalOpenGLRenderWindow;
//! Part of Qml rendering prototype, see QmlMitkRenderWindowItem.
class MITKOPENVIEWCORE_EXPORT QVTKFramebufferObjectRenderer : public QQuickFramebufferObject::Renderer
{
public:
bool m_neverRendered;
bool m_readyToRender;
vtkInternalOpenGLRenderWindow *m_vtkRenderWindow;
QVTKQuickItem *m_vtkQuickItem;
public:
QVTKFramebufferObjectRenderer(vtkInternalOpenGLRenderWindow *rw);
~QVTKFramebufferObjectRenderer();
virtual void synchronize(QQuickFramebufferObject * item);
virtual void render();
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size);
friend class vtkInternalOpenGLRenderWindow;
};
#endif
| /*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef __QVTKFramebufferObjectRenderer_h
#define __QVTKFramebufferObjectRenderer_h
#include <QQuickFramebufferObject>
#include "QVTKQuickItem.h"
#include <MitkOpenViewCoreExports.h>
class vtkInternalOpenGLRenderWindow;
//! Part of Qml rendering prototype, see QmlMitkRenderWindowItem.
class MITKOPENVIEWCORE_EXPORT QVTKFramebufferObjectRenderer : public QQuickFramebufferObject::Renderer
{
public:
vtkInternalOpenGLRenderWindow *m_vtkRenderWindow;
bool m_neverRendered;
bool m_readyToRender;
QVTKQuickItem *m_vtkQuickItem;
public:
QVTKFramebufferObjectRenderer(vtkInternalOpenGLRenderWindow *rw);
~QVTKFramebufferObjectRenderer();
virtual void synchronize(QQuickFramebufferObject * item);
virtual void render();
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size);
friend class vtkInternalOpenGLRenderWindow;
};
#endif
|
Remove prototypes for static methods | /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#ifndef _CPU_H_
#define _CPU_H_
#include <cpu/cache.h>
#include <cpu/divu.h>
#include <cpu/dmac.h>
#include <cpu/dual.h>
#include <cpu/endian.h>
#include <cpu/frt.h>
#include <cpu/instructions.h>
#include <cpu/intc.h>
#include <cpu/registers.h>
#include <cpu/sync.h>
#include <cpu/wdt.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern void cpu_init(void);
extern void _slave_polling_entry(void);
extern void _slave_ici_entry(void);
extern void _exception_illegal_instruction(void);
extern void _exception_illegal_slot(void);
extern void _exception_cpu_address_error(void);
extern void _exception_dma_address_error(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !_CPU_H_ */
| /*
* Copyright (c) 2012-2016 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com>
*/
#ifndef _CPU_H_
#define _CPU_H_
#include <cpu/cache.h>
#include <cpu/divu.h>
#include <cpu/dmac.h>
#include <cpu/dual.h>
#include <cpu/endian.h>
#include <cpu/frt.h>
#include <cpu/instructions.h>
#include <cpu/intc.h>
#include <cpu/registers.h>
#include <cpu/sync.h>
#include <cpu/wdt.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern void cpu_init(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !_CPU_H_ */
|
Clone with/without VM sample working now | #define _GNU_SOURCE
#include <sched.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static int child_func(void* arg) {
return 0;
}
int main(int argc, char** argv) {
// Stack for child.
const int STACK_SIZE = 65536;
char* stack = malloc(STACK_SIZE);
if (!stack) {
perror("malloc");
exit(1);
}
unsigned long flags = 0;
if (clone(child_func, stack + STACK_SIZE, flags | SIGCHLD, NULL) == -1) {
perror("clone");
exit(1);
}
int status;
pid_t pid = waitpid(-1, &status, 0);
if (pid == -1) {
perror("waitpid");
exit(1);
}
printf(" Child PID=%ld\n", (long)pid);
return 0;
}
| #define _GNU_SOURCE
#include <sched.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static int child_func(void* arg) {
char* buf = (char*)arg;
strcpy(buf, "hello");
return 0;
}
int main(int argc, char** argv) {
// Stack for child.
const int STACK_SIZE = 65536;
char* stack = malloc(STACK_SIZE);
if (!stack) {
perror("malloc");
exit(1);
}
unsigned long flags = 0;
if (argc > 1 && !strcmp(argv[1], "vm")) {
flags |= CLONE_VM;
}
char buf[100] = {0};
if (clone(child_func, stack + STACK_SIZE, flags | SIGCHLD, buf) == -1) {
perror("clone");
exit(1);
}
int status;
pid_t pid = waitpid(-1, &status, 0);
if (pid == -1) {
perror("waitpid");
exit(1);
}
printf("Child exited. buf = \"%s\"\n", buf);
return 0;
}
|
Change the sample to pass message from parent as well | // We have to define the _GNU_SOURCE to get access to clone(2) and the CLONE_*
// flags from sched.h
#define _GNU_SOURCE
#include <sched.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static int child_func(void* arg) {
char* buf = (char*)arg;
strcpy(buf, "hello");
return 0;
}
int main(int argc, char** argv) {
// Allocate stack for child task.
const int STACK_SIZE = 65536;
char* stack = malloc(STACK_SIZE);
if (!stack) {
perror("malloc");
exit(1);
}
// When called with the command-line argument "vm", set the CLONE_VM flag on.
unsigned long flags = 0;
if (argc > 1 && !strcmp(argv[1], "vm")) {
flags |= CLONE_VM;
}
char buf[100] = {0};
if (clone(child_func, stack + STACK_SIZE, flags | SIGCHLD, buf) == -1) {
perror("clone");
exit(1);
}
int status;
if (wait(&status) == -1) {
perror("wait");
exit(1);
}
printf("Child exited with status %d. buf = \"%s\"\n", status, buf);
return 0;
}
| // We have to define the _GNU_SOURCE to get access to clone(2) and the CLONE_*
// flags from sched.h
#define _GNU_SOURCE
#include <sched.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static int child_func(void* arg) {
char* buf = (char*)arg;
printf("Child sees buf = \"%s\"\n", buf);
strcpy(buf, "hello from child");
return 0;
}
int main(int argc, char** argv) {
// Allocate stack for child task.
const int STACK_SIZE = 65536;
char* stack = malloc(STACK_SIZE);
if (!stack) {
perror("malloc");
exit(1);
}
// When called with the command-line argument "vm", set the CLONE_VM flag on.
unsigned long flags = 0;
if (argc > 1 && !strcmp(argv[1], "vm")) {
flags |= CLONE_VM;
}
char buf[100];
strcpy(buf, "hello from parent");
if (clone(child_func, stack + STACK_SIZE, flags | SIGCHLD, buf) == -1) {
perror("clone");
exit(1);
}
int status;
if (wait(&status) == -1) {
perror("wait");
exit(1);
}
printf("Child exited with status %d. buf = \"%s\"\n", status, buf);
return 0;
}
|
Use ++i instead of i++ | /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_
#include "tensorflow/lite/kernels/internal/common.h"
namespace tflite {
namespace reference_integer_ops {
template <typename InputT, typename OutputT>
inline void LookupTable(const InputT* input_data, int num_elements,
const OutputT* lut, OutputT* output_data) {
for (int i = 0; i < num_elements; i++) {
output_data[i] = LUTLookup(input_data[i], lut);
}
}
} // namespace reference_integer_ops
} // namespace tflite
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_
| /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_
#include "tensorflow/lite/kernels/internal/common.h"
namespace tflite {
namespace reference_integer_ops {
template <typename InputT, typename OutputT>
inline void LookupTable(const InputT* input_data, int num_elements,
const OutputT* lut, OutputT* output_data) {
for (int i = 0; i < num_elements; ++i) {
output_data[i] = LUTLookup(input_data[i], lut);
}
}
} // namespace reference_integer_ops
} // namespace tflite
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_
|
Update Skia milestone to 87 | /*
* 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 86
#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 87
#endif
|
Add automation for arduino board selection for compilation | #ifndef __ACONFIG_H_
#define __ACONFIG_H_
/* This must be before alphabetically before all other files that reference these settings for the compiler to work
* or you may get vtable errors.
*/
/* This section is for devices and their configuration. IF you have not setup you pins with the
* standard configuration of the OpenROV kits, you should probably clone the cape or controlboard
* and change the pin definitions there. Things not wired to specific pins but on the I2C bus will
* have the address defined in this file.
*/
//Kit:
#define HAS_STD_CAPE (0)
#define HAS_STD_PILOT (1)
#define HAS_OROV_CONTROLLERBOARD_25 (0)
#define HAS_STD_LIGHTS (1)
#define HAS_STD_CALIBRATIONLASERS (0)
#define HAS_STD_2X1_THRUSTERS (1)
#define HAS_STD_CAMERAMOUNT (1)
//After Market:
#define HAS_POLOLU_MINIMUV (0)
#define HAS_MS5803_14BA (0)
#define MS5803_14BA_I2C_ADDRESS 0x76
#define HAS_MPU9150 (0)
#define MPU9150_EEPROM_START 2
#endif
| #ifndef __ACONFIG_H_
#define __ACONFIG_H_
/* This must be before alphabetically before all other files that reference these settings for the compiler to work
* or you may get vtable errors.
*/
/* This section is for devices and their configuration. IF you have not setup you pins with the
* standard configuration of the OpenROV kits, you should probably clone the cape or controlboard
* and change the pin definitions there. Things not wired to specific pins but on the I2C bus will
* have the address defined in this file.
*/
//Kit:
#define HAS_STD_PILOT (1)
/* The definitions are done in th
#define HAS_STD_CAPE (0)
#define HAS_OROV_CONTROLLERBOARD_25 (0)
*/
#include "BoardConfig.h"
#define HAS_STD_LIGHTS (1)
#define HAS_STD_CALIBRATIONLASERS (1)
#define HAS_STD_2X1_THRUSTERS (1)
#define HAS_STD_CAMERAMOUNT (1)
//After Market:
#define HAS_POLOLU_MINIMUV (0)
#define HAS_MS5803_14BA (0)
#define MS5803_14BA_I2C_ADDRESS 0x76
#define HAS_MPU9150 (0)
#define MPU9150_EEPROM_START 2
#endif
|
Add manual test where mine-W is more precise than mine-lazy due to extern global init top | // SKIP
#include <pthread.h>
#include <stdlib.h>
extern int optind ;
pthread_t hthread ;
void *signal_waiter(void *arg )
{
}
int main(int argc , char **argv )
{
pthread_create(& hthread, NULL, & signal_waiter, NULL);
if (optind >= argc) {
if (optind == argc) {
// mine-lazy priv should also read Unknown int, not Unknown here
exit(1);
}
}
return (0);
} | |
Update Skia milestone to 90 | /*
* 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 89
#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 90
#endif
|
Add the Async Log implementation | //
// AsyncLog.c
// Ctest
//
// Created by Yanjiu Huang on 3/24/14.
// Copyright (c) 2014 Yanjiu Huang. All rights reserved.
//
#include <stdio.h>
#include "AsyncLog.h"
void async_log_error(const char* format,...){
}
void async_log_debug(const char* format,...){
}
void async_log_info(const char* format,...){
} | //
// AsyncLog.c
// Ctest
//
// Created by Yanjiu Huang on 3/24/14.
// Copyright (c) 2014 Yanjiu Huang. All rights reserved.
//
#include <stdio.h>
#include <stdarg.h>
#include "AsyncLog.h"
void async_log_error(const char* format, ...){
va_list arg;
va_start(arg, format);
vfprintf(stderr, format, arg);
va_end(arg);
}
void async_log_debug(const char* format, ...){
va_list arg;
va_start(arg, format);
vfprintf(stdout, format, arg);
va_end(arg);
}
void async_log_info(const char* format, ...){
va_list arg;
va_start(arg, format);
vfprintf(stdout, format, arg);
va_end(arg);
} |
Fix extra semicolor causing build failure | /*
This file is part of the kblog library.
Copyright (c) 2007 Christian Weilbach <christian_weilbach@web.de>
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 BLOGPOSTING_P_H
#define BLOGPOSTING_P_H
#include "blogposting.h"
#include <KDateTime>
#include <QStringList>
namespace KBlog{
class BlogPostingPrivate
{
public:
friend class Blog;
bool mPublished;
BlogPosting *q_ptr;
QString mPostingId;
QString mTitle;
QString mContent;
QStringList mCategories;
QString mError;
BlogPosting::Status mStatus;
KDateTime mCreationDateTime;
KDateTime mModificationDateTime;
Q_DECLARE_PUBLIC(BlogPosting);
};
} // namespace
#endif
| /*
This file is part of the kblog library.
Copyright (c) 2007 Christian Weilbach <christian_weilbach@web.de>
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 BLOGPOSTING_P_H
#define BLOGPOSTING_P_H
#include "blogposting.h"
#include <KDateTime>
#include <QStringList>
namespace KBlog{
class BlogPostingPrivate
{
public:
friend class Blog;
bool mPublished;
BlogPosting *q_ptr;
QString mPostingId;
QString mTitle;
QString mContent;
QStringList mCategories;
QString mError;
BlogPosting::Status mStatus;
KDateTime mCreationDateTime;
KDateTime mModificationDateTime;
Q_DECLARE_PUBLIC(BlogPosting)
};
} // namespace
#endif
|
Add missing EC28J60 arch definition file | /*
* Copyright (c) 2013, CETIC.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ENC28J60_ARCH_H
#define ENC28J60_ARCH_H
#include <inttypes.h>
/* ENC28J60 architecture-specific SPI functions that are called by the
enc28j60 driver and must be implemented by the platform code */
void enc28j60_arch_spi_init(void);
void enc28j60_arch_spi_write(uint8_t data);
uint8_t enc28j60_arch_spi_read(void);
void enc28j60_arch_spi_select(void);
void enc28j60_arch_spi_deselect(void);
#endif
| |
Add more files into gen-files | #ifndef __PLATFORM_H__
#define __PLATFORM_H__
#define BuildPlatform_NAME "x86_64-unknown-linux"
#define HostPlatform_NAME "x86_64-unknown-linux"
#define TargetPlatform_NAME "x86_64-unknown-linux"
#define x86_64_unknown_linux_BUILD 1
#define x86_64_unknown_linux_HOST 1
#define x86_64_unknown_linux_TARGET 1
#define x86_64_BUILD_ARCH 1
#define x86_64_HOST_ARCH 1
#define x86_64_TARGET_ARCH 1
#define BUILD_ARCH "x86_64"
#define HOST_ARCH "x86_64"
#define TARGET_ARCH "x86_64"
#define LLVM_TARGET "x86_64-unknown-linux"
#define linux_BUILD_OS 1
#define linux_HOST_OS 1
#define linux_TARGET_OS 1
#define BUILD_OS "linux"
#define HOST_OS "linux"
#define TARGET_OS "linux"
#define unknown_BUILD_VENDOR 1
#define unknown_HOST_VENDOR 1
#define unknown_TARGET_VENDOR 1
#define BUILD_VENDOR "unknown"
#define HOST_VENDOR "unknown"
#define TARGET_VENDOR "unknown"
#endif /* __PLATFORM_H__ */
| |
Add anonymous nested struct test | // RUN: %ocheck 3 %s
struct nest {
union {
struct {
union {
int i;
};
};
};
};
int main()
{
struct nest n = {
.i = 2
};
n.i++;
return n.i;
}
| |
Fix link error when component=shared_library is set | // 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 UI_BASE_IME_CHARACTER_COMPOSER_H_
#define UI_BASE_IME_CHARACTER_COMPOSER_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
#include "base/string_util.h"
namespace ui {
// A class to recognize compose and dead key sequence.
// Outputs composed character.
//
// TODO(hashimoto): support unicode character composition starting with
// Ctrl-Shift-U. http://crosbug.com/15925
class CharacterComposer {
public:
CharacterComposer();
~CharacterComposer();
void Reset();
// Filters keypress.
// Returns true if the keypress is recognized as a part of composition
// sequence.
bool FilterKeyPress(unsigned int keycode);
// Returns a string consisting of composed character.
// Empty string is returned when there is no composition result.
const string16& composed_character() const {
return composed_character_;
}
private:
// Remembers keypresses previously filtered.
std::vector<unsigned int> compose_buffer_;
// A string representing the composed character.
string16 composed_character_;
DISALLOW_COPY_AND_ASSIGN(CharacterComposer);
};
} // namespace ui
#endif // UI_BASE_IME_CHARACTER_COMPOSER_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 UI_BASE_IME_CHARACTER_COMPOSER_H_
#define UI_BASE_IME_CHARACTER_COMPOSER_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
#include "base/string_util.h"
#include "ui/base/ui_export.h"
namespace ui {
// A class to recognize compose and dead key sequence.
// Outputs composed character.
//
// TODO(hashimoto): support unicode character composition starting with
// Ctrl-Shift-U. http://crosbug.com/15925
class UI_EXPORT CharacterComposer {
public:
CharacterComposer();
~CharacterComposer();
void Reset();
// Filters keypress.
// Returns true if the keypress is recognized as a part of composition
// sequence.
bool FilterKeyPress(unsigned int keycode);
// Returns a string consisting of composed character.
// Empty string is returned when there is no composition result.
const string16& composed_character() const {
return composed_character_;
}
private:
// Remembers keypresses previously filtered.
std::vector<unsigned int> compose_buffer_;
// A string representing the composed character.
string16 composed_character_;
DISALLOW_COPY_AND_ASSIGN(CharacterComposer);
};
} // namespace ui
#endif // UI_BASE_IME_CHARACTER_COMPOSER_H_
|
Add missing header guard and extern C block | /*
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* This header exists solely to allow drivers meant for the native_posix board
* to be used directly in the nrf52_bsim board.
* Note that such reuse should be done with great care.
*
* The command line arguments parsing logic from native_posix was born as a copy
* of the one from the BabbleSim's libUtil library
* They are therefore mostly equal except for types and functions names.
*
* This header converts these so the native_posix call to dynamically register
* command line arguments is passed to the nrf52_bsim one
*/
#include "../native_posix/cmdline_common.h"
static inline void native_add_command_line_opts(struct args_struct_t *args)
{
void bs_add_extra_dynargs(struct args_struct_t *args);
bs_add_extra_dynargs(args);
}
| /*
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* This header exists solely to allow drivers meant for the native_posix board
* to be used directly in the nrf52_bsim board.
* Note that such reuse should be done with great care.
*
* The command line arguments parsing logic from native_posix was born as a copy
* of the one from the BabbleSim's libUtil library
* They are therefore mostly equal except for types and functions names.
*
* This header converts these so the native_posix call to dynamically register
* command line arguments is passed to the nrf52_bsim one
*/
#ifndef BOARDS_POSIX_NRF52_BSIM_CMDLINE_H
#define BOARDS_POSIX_NRF52_BSIM_CMDLINE_H
#include "../native_posix/cmdline_common.h"
#ifdef __cplusplus
extern "C" {
#endif
static inline void native_add_command_line_opts(struct args_struct_t *args)
{
void bs_add_extra_dynargs(struct args_struct_t *args);
bs_add_extra_dynargs(args);
}
#ifdef __cplusplus
}
#endif
#endif /* BOARDS_POSIX_NRF52_BSIM_CMDLINE_H */
|
Remove silly import of UIKit | //
// Atomic.h
// Atomic
//
// Created by Adlai Holler on 12/5/15.
// Copyright © 2015 Adlai Holler. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for Atomic.
FOUNDATION_EXPORT double AtomicVersionNumber;
//! Project version string for Atomic.
FOUNDATION_EXPORT const unsigned char AtomicVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Atomic/PublicHeader.h>
| //
// Atomic.h
// Atomic
//
// Created by Adlai Holler on 12/5/15.
// Copyright © 2015 Adlai Holler. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for Atomic.
FOUNDATION_EXPORT double AtomicVersionNumber;
//! Project version string for Atomic.
FOUNDATION_EXPORT const unsigned char AtomicVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Atomic/PublicHeader.h>
|
Fix 28/36 to actually be race free | #include <pthread.h>
#include "racemacros.h"
int g;
int *g1;
int *g2;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
pthread_mutex_lock(&mutex);
access(*g1);
pthread_mutex_lock(&mutex);
return NULL;
}
int main(void) {
g1 = g2 = &g;
create_threads(t);
assert_racefree(*g2); // UNKNOWN
join_threads(t);
return 0;
}
| #include <pthread.h>
#include "racemacros.h"
int g;
int *g1;
int *g2;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
pthread_mutex_lock(&mutex);
access(*g1);
pthread_mutex_lock(&mutex);
return NULL;
}
int main(void) {
g1 = g2 = &g;
create_threads(t);
pthread_mutex_lock(&mutex);
assert_racefree(*g2);
pthread_mutex_lock(&mutex);
join_threads(t);
return 0;
}
|
Add switch pin definitions, fix pin for backlight | #ifndef ADAPTERBOARD_H
#define ADAPTERBOARD_H
#include <RGBLed.h>
#define LED_R 13
#define LED_G 9
#define LED_B 10
#define BACKLIGHT_PIN 0
class AdapterBoard
{
public:
AdapterBoard();
void init();
void poll();
private:
RGBLed led;
Backlight backlight;
};
#endif
| #ifndef ADAPTERBOARD_H
#define ADAPTERBOARD_H
#include <RGBLed.h>
#define LED_R 13
#define LED_G 9
#define LED_B 10
#define BACKLIGHT_PIN 11
#define SW_ON 4
#define SW_UP 12
#define SW_DOWN 6
class AdapterBoard
{
public:
AdapterBoard();
void init();
void poll();
private:
RGBLed led;
Backlight backlight;
};
#endif
|
Add todo comment on at() functions. | //-----------------------------------------------------------------------------
// Element Access
//-----------------------------------------------------------------------------
template<class T>
T& matrix<T>::at( std::size_t row, std::size_t col ){
return data_.at(row*cols_+col);
}
template<class T>
const T& matrix<T>::at( std::size_t row, std::size_t col ) const{
return data_.at(row*cols_+col);
}
template<class T>
typename matrix<T>::matrix_row matrix<T>::operator[]( std::size_t row ){
return 0;
}
template<class T>
const typename matrix<T>::matrix_row matrix<T>::operator[](
std::size_t row ) const{
return 0;
}
| //-----------------------------------------------------------------------------
// Element Access
//-----------------------------------------------------------------------------
template<class T>
T& matrix<T>::at( std::size_t row, std::size_t col ){
// TODO throw if out of bounds
return data_.at(row*cols_+col);
}
template<class T>
const T& matrix<T>::at( std::size_t row, std::size_t col ) const{
// TODO throw if out of bounds
return data_.at(row*cols_+col);
}
template<class T>
typename matrix<T>::matrix_row matrix<T>::operator[]( std::size_t row ){
return 0;
}
template<class T>
const typename matrix<T>::matrix_row matrix<T>::operator[](
std::size_t row ) const{
return 0;
}
|
Move struct definition to header as it is reused in different cpp files | typedef struct Bundle Bundle;
struct Bundle {
MatrixServer* matrix;
Db* db;
int epfd;
int threadNo; //for init only, not used in the threads
std::string portNo; //for init only, not used in the threads
};
| |
Add BST inorder traversal function implementation | #include "bst.h"
static void BST_Transplant(BST* T, BSTNode* u, BSTNode* v);
struct BSTNode
{
BSTNode* left;
BSTNode* right;
BSTNode* p;
void* k;
};
struct BST
{
BSTNode* root;
};
BST* BST_Create(void)
{
BST* T = (BST* )malloc(sizeof(BST));
T->root = NULL;
return T;
}
BSTNode* BSTNode_Create(void* k)
{
BSTNode* n = (BSTNode* )malloc(sizeof(BSTNode));
n->left = NULL;
n->right = NULL;
n->p = NULL;
n->k = k;
}
| #include "bst.h"
static void BST_Transplant(BST* T, BSTNode* u, BSTNode* v);
struct BSTNode
{
BSTNode* left;
BSTNode* right;
BSTNode* p;
void* k;
};
struct BST
{
BSTNode* root;
};
BST* BST_Create(void)
{
BST* T = (BST* )malloc(sizeof(BST));
T->root = NULL;
return T;
}
BSTNode* BSTNode_Create(void* k)
{
BSTNode* n = (BSTNode* )malloc(sizeof(BSTNode));
n->left = NULL;
n->right = NULL;
n->p = NULL;
n->k = k;
}
void BST_Inorder_Tree_Walk(BSTNode* n, void (f)(void*))
{
if (n != NULL)
{
BST_Inorder_Tree_Walk(n->left, f);
f(n->k);
BST_Inorder_Tree_Walk(n->right, f);
}
}
|
Fix bug with . and .. | #include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char *dircat(char *d1, char *d2)
{
char *new = malloc(strlen(d1) + strlen(d2) + 2);
sprintf(new, "%s/%s", d1, d2);
return new;
}
void dirwalk(char *name, void (*func)(char *, void *), void *ctx)
{
DIR *dir = opendir(name);
struct dirent *d;
func(name, ctx);
readdir(dir); readdir(dir); /* Ignore "." and ".." */
while ((d = readdir(dir)) != NULL) {
if (d->d_type == DT_DIR && d->d_name[0] != '.') {
char *nextdir = dircat(name, d->d_name);
dirwalk(nextdir, func, ctx);
free(nextdir);
}
}
closedir(dir);
}
| #include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char *dircat(char *d1, char *d2)
{
char *new = malloc(strlen(d1) + strlen(d2) + 2);
sprintf(new, "%s/%s", d1, d2);
return new;
}
void dirwalk(char *name, void (*func)(char *, void *), void *ctx)
{
DIR *dir = opendir(name);
struct dirent *d;
func(name, ctx);
while ((d = readdir(dir)) != NULL) {
if (d->d_type == DT_DIR && d->d_name[0] != '.') {
char *nextdir = dircat(name, d->d_name);
dirwalk(nextdir, func, ctx);
free(nextdir);
}
}
closedir(dir);
}
|
Initialize X11 connection and root screen. | // vim:ts=4:sw=4:expandtab
#include <stdlib.h>
#include <stdio.h>
#include "randr.h"
#include "types.h"
#include "globals.h"
int main(void) {
// TODO
}
| // vim:ts=4:sw=4:expandtab
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include "randr.h"
#include "types.h"
#include "globals.h"
xcb_connection_t *connection;
xcb_window_t root;
static void initialize(void) {
int display;
connection = xcb_connect(NULL, &display);
if (xcb_connection_has_error(connection)) {
errx(EXIT_FAILURE, "could not connect to the X server, bailing out.");
}
xcb_screen_t *screen = xcb_aux_get_screen(connection, display);
root = screen->root;
}
int main(void) {
initialize();
xcb_disconnect(connection);
exit(EXIT_SUCCESS);
}
|
Adjust for new LLVM BinaryFormat library in r304864. | //===--- Dwarf.h - DWARF constants ------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines several temporary Swift-specific DWARF constants.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_DWARF_H
#define SWIFT_BASIC_DWARF_H
#include "llvm/Support/Dwarf.h"
namespace swift {
/// The DWARF version emitted by the Swift compiler.
const unsigned DWARFVersion = 4;
static const char MachOASTSegmentName[] = "__SWIFT";
static const char MachOASTSectionName[] = "__ast";
static const char ELFASTSectionName[] = ".swift_ast";
static const char COFFASTSectionName[] = "swiftast";
} // end namespace swift
#endif // SWIFT_BASIC_DWARF_H
| //===--- Dwarf.h - DWARF constants ------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines several temporary Swift-specific DWARF constants.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_DWARF_H
#define SWIFT_BASIC_DWARF_H
#include "llvm/BinaryFormat/Dwarf.h"
namespace swift {
/// The DWARF version emitted by the Swift compiler.
const unsigned DWARFVersion = 4;
static const char MachOASTSegmentName[] = "__SWIFT";
static const char MachOASTSectionName[] = "__ast";
static const char ELFASTSectionName[] = ".swift_ast";
static const char COFFASTSectionName[] = "swiftast";
} // end namespace swift
#endif // SWIFT_BASIC_DWARF_H
|
Store image data in aligned_vector | // This file is distributed under the MIT license.
// See the LICENSE file for details.
#pragma once
#ifndef VSNRAY_COMMON_IMAGE_BASE_H
#define VSNRAY_COMMOM_IMAGE_BASE_H 1
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
#include <visionaray/pixel_format.h>
namespace visionaray
{
class image_base
{
public:
friend class image;
public:
virtual bool load(std::string const& filename);
virtual bool save(std::string const& filename);
size_t width() const;
size_t height() const;
pixel_format format() const;
uint8_t const* data() const;
protected:
size_t width_;
size_t height_;
pixel_format format_ = PF_RGB8;
std::vector<uint8_t> data_;
};
} // visionaray
#endif // VSNRAY_COMMOM_IMAGE_BASE_H
| // This file is distributed under the MIT license.
// See the LICENSE file for details.
#pragma once
#ifndef VSNRAY_COMMON_IMAGE_BASE_H
#define VSNRAY_COMMOM_IMAGE_BASE_H 1
#include <cstddef>
#include <cstdint>
#include <string>
#include <visionaray/aligned_vector.h>
#include <visionaray/pixel_format.h>
namespace visionaray
{
class image_base
{
public:
friend class image;
public:
virtual bool load(std::string const& filename);
virtual bool save(std::string const& filename);
size_t width() const;
size_t height() const;
pixel_format format() const;
uint8_t const* data() const;
protected:
size_t width_;
size_t height_;
pixel_format format_ = PF_RGB8;
aligned_vector<uint8_t> data_;
};
} // visionaray
#endif // VSNRAY_COMMOM_IMAGE_BASE_H
|
Remove left-over from non-generic power control | #ifndef SYSMOBTS_UTILS_H
#define SYSMOBTS_UTILS_H
#include <stdint.h>
#include "femtobts.h"
struct gsm_bts_trx;
int band_femto2osmo(GsmL1_FreqBand_t band);
int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn);
int sysmobts_get_nominal_power(struct gsm_bts_trx *trx);
int sysmobts_get_target_power(struct gsm_bts_trx *trx);
void sysmobts_pa_pwr_init(struct gsm_bts_trx *trx);
void sysmobts_pa_maybe_step(struct gsm_bts_trx *trx);
#endif
| #ifndef SYSMOBTS_UTILS_H
#define SYSMOBTS_UTILS_H
#include <stdint.h>
#include "femtobts.h"
struct gsm_bts_trx;
int band_femto2osmo(GsmL1_FreqBand_t band);
int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn);
int sysmobts_get_nominal_power(struct gsm_bts_trx *trx);
#endif
|
Make the alternative sha512 optional | /*
* mbedtls_device.h
*
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* 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 __MBEDTLS_DEVICE__
#define __MBEDTLS_DEVICE__
#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT
#define MBEDTLS_SHA1_ALT
#define MBEDTLS_SHA256_ALT
#define MBEDTLS_SHA512_ALT
#define MBEDTLS_CCM_ALT
#define MBEDTLS_ECDSA_VERIFY_ALT
#define MBEDTLS_ECDSA_SIGN_ALT
#define MBEDTLS_ECDSA_GENKEY_ALT
#define MBEDTLS_ECDH_GEN_PUBLIC_ALT
#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT
#endif //__MBEDTLS_DEVICE__
| /*
* mbedtls_device.h
*
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* 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 __MBEDTLS_DEVICE__
#define __MBEDTLS_DEVICE__
#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT
#define MBEDTLS_SHA1_ALT
#define MBEDTLS_SHA256_ALT
//#define MBEDTLS_SHA512_ALT
#define MBEDTLS_CCM_ALT
#define MBEDTLS_ECDSA_VERIFY_ALT
#define MBEDTLS_ECDSA_SIGN_ALT
#define MBEDTLS_ECDSA_GENKEY_ALT
#define MBEDTLS_ECDH_GEN_PUBLIC_ALT
#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT
#endif //__MBEDTLS_DEVICE__
|
Add comment about unordered map |
#ifndef __CS_143__Router__
#define __CS_143__Router__
#include <string>
#include "Device.h"
class Router : public Device
{
public:
// Bellman-Ford
//void updateRouting(Packet);
// create static routing table
void addRouting(Packet);
// add a link to the router
void addLink(std::string link_id);
// get proper routing given host id
std::string getRouting(std::string targ_host);
// react to a packet event
void giveEvent(std::unique_ptr<PacketEvent>);
private:
// Routing table maps destination host ids to link ids
std::map<std::string, std::string> routing_table;
// All links connected to this router
std::vector<std::string> links;
};
#endif /* defined(__CS_143__Router__) */
|
#ifndef __CS_143__Router__
#define __CS_143__Router__
#include <string>
#include "Device.h"
class Router : public Device
{
public:
// Bellman-Ford
//void updateRouting(Packet);
// create static routing table
void addRouting(Packet);
// add a link to the router
void addLink(std::string link_id);
// get proper routing given host id
std::string getRouting(std::string targ_host);
// react to a packet event
void giveEvent(std::unique_ptr<PacketEvent>);
private:
// TODO: this could probably be an unordered_map
// Routing table maps destination host ids to link ids
std::map<std::string, std::string> routing_table;
// All links connected to this router
std::vector<std::string> links;
};
#endif /* defined(__CS_143__Router__) */
|
Test run successful after libmesh update | /* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
#ifndef DGOSPREY_REVISION_H
#define DGOSPREY_REVISION_H
#define DGOSPREY_REVISION "git commit 8603d37 on 2015-01-21"
#endif // DGOSPREY_REVISION_H
| /* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
#ifndef DGOSPREY_REVISION_H
#define DGOSPREY_REVISION_H
#define DGOSPREY_REVISION "git commit 660a43d on 2015-02-09"
#endif // DGOSPREY_REVISION_H
|
Replace placeholder with required mask and index properties. | /*
* Copyright (C) 2016 Glyptodon, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef GUACENC_IMAGE_STREAM_H
#define GUACENC_IMAGE_STREAM_H
#include "config.h"
/**
* The current state of an allocated Guacamole image stream.
*/
typedef struct guacenc_image_stream {
/**
* STUB: Placeholder property. This property exists only so that the
* guacenc_image_stream struct can be defined prior to implementation.
*/
int __PLACEHOLDER;
} guacenc_image_stream;
#endif
| /*
* Copyright (C) 2016 Glyptodon, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef GUACENC_IMAGE_STREAM_H
#define GUACENC_IMAGE_STREAM_H
#include "config.h"
/**
* The current state of an allocated Guacamole image stream.
*/
typedef struct guacenc_image_stream {
/**
* The index of the destination layer or buffer.
*/
int index;
/**
* The Guacamole protocol compositing operation (channel mask) to apply
* when drawing the image.
*/
int mask;
} guacenc_image_stream;
#endif
|
Switch to non atomic properties | //
// TSKPinFailureReport.h
// TrustKit
//
// Created by Alban Diquet on 5/27/15.
// Copyright (c) 2015 Data Theorem. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TSKPinFailureReport : NSObject
@property (readonly) NSString *appBundleId;
@property (readonly) NSString *appVersion;
@property (readonly) NSString *notedHostname;
@property (readonly) NSString *serverHostname;
@property (readonly) NSNumber *serverPort;
@property (readonly) NSDate *dateTime;
@property (readonly) BOOL includeSubdomains;
@property (readonly) NSArray *validatedCertificateChain;
@property (readonly) NSArray *knownPins;
// Init with default bundle ID and current time as the date-time
- (instancetype) initWithAppBundleId:(NSString *) appBundleId appVersion:(NSString *)appVersion notedHostname:(NSString *)notedHostname serverHostname:(NSString *)serverHostname port:(NSNumber *)serverPort dateTime:(NSDate *)dateTime includeSubdomains:(BOOL) includeSubdomains validatedCertificateChain:(NSArray *)validatedCertificateChain knownPins:(NSArray *)knownPins;
// Return the report in JSON format for POSTing it
- (NSData *)json;
// Return a request ready to be sent with the report in JSON format in the response's body
- (NSMutableURLRequest *)requestToUri:(NSURL *)reportUri;
@end
| //
// TSKPinFailureReport.h
// TrustKit
//
// Created by Alban Diquet on 5/27/15.
// Copyright (c) 2015 Data Theorem. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TSKPinFailureReport : NSObject
@property (readonly, nonatomic) NSString *appBundleId; // Not part of the HPKP spec
@property (readonly, nonatomic) NSString *appVersion; // Not part of the HPKP spec
@property (readonly, nonatomic) NSString *notedHostname;
@property (readonly, nonatomic) NSString *serverHostname;
@property (readonly, nonatomic) NSNumber *serverPort;
@property (readonly, nonatomic) NSDate *dateTime;
@property (readonly, nonatomic) BOOL includeSubdomains;
@property (readonly, nonatomic) NSArray *validatedCertificateChain;
@property (readonly, nonatomic) NSArray *knownPins;
// Init with default bundle ID and current time as the date-time
- (instancetype) initWithAppBundleId:(NSString *) appBundleId appVersion:(NSString *)appVersion notedHostname:(NSString *)notedHostname serverHostname:(NSString *)serverHostname port:(NSNumber *)serverPort dateTime:(NSDate *)dateTime includeSubdomains:(BOOL) includeSubdomains validatedCertificateChain:(NSArray *)validatedCertificateChain knownPins:(NSArray *)knownPins;
// Return the report in JSON format for POSTing it
- (NSData *)json;
// Return a request ready to be sent with the report in JSON format in the response's body
- (NSMutableURLRequest *)requestToUri:(NSURL *)reportUri;
@end
|
Replace include <map> with <unordered_map> | #ifndef __WORDCOUNTS_H__
#define __WORDCOUNTS_H__
#include <string>
#include <map>
#include <Rcpp.h>
typedef std::unordered_map<std::string, int> hashmap;
class WordCounts
{
private:
hashmap map;
public:
WordCounts();
~WordCounts();
void print();
Rcpp::DataFrame as_data_frame();
void add_word(std::string);
};
#endif
| #ifndef __WORDCOUNTS_H__
#define __WORDCOUNTS_H__
#include <string>
#include <unordered_map>
#include <Rcpp.h>
typedef std::unordered_map<std::string, int> hashmap;
class WordCounts
{
private:
hashmap map;
public:
WordCounts();
~WordCounts();
void print();
Rcpp::DataFrame as_data_frame();
void add_word(std::string);
};
#endif
|
Add a comment explaining why iconv needs a (void*) for its parameter. | #include "h_iconv.h"
// Wrapper functions, since iconv_open et al are macros in libiconv.
iconv_t h_iconv_open(const char *tocode, const char *fromcode) {
return iconv_open(tocode, fromcode);
}
void h_iconv_close(iconv_t cd) {
iconv_close(cd);
}
size_t h_iconv(iconv_t cd, char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft) {
return iconv(cd, (void*)inbuf, inbytesleft, outbuf, outbytesleft);
}
| #include "h_iconv.h"
// Wrapper functions, since iconv_open et al are macros in libiconv.
iconv_t h_iconv_open(const char *tocode, const char *fromcode) {
return iconv_open(tocode, fromcode);
}
void h_iconv_close(iconv_t cd) {
iconv_close(cd);
}
size_t h_iconv(iconv_t cd, char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft) {
// Cast inbuf to (void*) so that it works both on Solaris, which expects
// a (const char**), and on other platforms (e.g. Linux), which expect
// a (char **).
return iconv(cd, (void*)inbuf, inbytesleft, outbuf, outbytesleft);
}
|
Fix number of buttons on the host and remove the placeholder macros | #ifndef WProgram_h
#define WProgram_h
#ifndef HOST_MIDIDUINO
#define HOST_MIDIDUINO
#endif
#define _BV(i) (1 << (i))
#define PSTR(s) (s)
#define GUI_NUM_ENCODERS 4
#define GUI_NUM_BUTTONS 4
#define BUTTON_PRESSED(i) false
#define BUTTON_RELEASED(i) false
#define BUTTON_DOWN(i) false
#define BUTTON_UP(i) true
#include <stdio.h>
void handleIncomingMidi();
#define BOARD_ID 0x89
#define SYSEX_BUF_SIZE 8192
#define setLed()
#define clearLed()
#define setLed2()
#define clearLed2()
#define PROGMEM
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
#ifdef __cplusplus
}
#endif
#include "helpers.h"
#include "WMath.h"
#define MIDIDUINO_HANDLE_SYSEX
#include "Midi.h"
#include "MidiClock.h"
#include "MidiUartHost.h"
#include "GUI_private.h"
void hexDump(uint8_t *data, uint16_t len);
#endif /* WProgram_h */
| #ifndef WProgram_h
#define WProgram_h
#ifndef HOST_MIDIDUINO
#define HOST_MIDIDUINO
#endif
#define _BV(i) (1 << (i))
#define PSTR(s) (s)
#define GUI_NUM_ENCODERS 4
#define GUI_NUM_BUTTONS 8
#include <stdio.h>
void handleIncomingMidi();
#define BOARD_ID 0x89
#define SYSEX_BUF_SIZE 8192
#define setLed()
#define clearLed()
#define setLed2()
#define clearLed2()
#define PROGMEM
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
#ifdef __cplusplus
}
#endif
#include "helpers.h"
#include "WMath.h"
#define MIDIDUINO_HANDLE_SYSEX
#include "Midi.h"
#include "MidiClock.h"
#include "MidiUartHost.h"
#include "GUI_private.h"
void hexDump(uint8_t *data, uint16_t len);
#endif /* WProgram_h */
|
Fix fatal typo in code guard | // @(#)root/sqlite:$Id$
// Author: o.freyermuth <o.f@cern.ch>, 01/06/2013
/*************************************************************************
* Copyright (C) 1995-2013, 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_TPgSQLRow
#define ROOT_TPgSQLRow
#ifndef ROOT_TSQLRow
#include "TSQLRow.h"
#endif
#if !defined(__CINT__)
#include <sqlite3.h>
#else
struct sqlite3_stmt;
#endif
class TSQLiteRow : public TSQLRow {
private:
sqlite3_stmt *fResult; // current result set
Bool_t IsValid(Int_t field);
public:
TSQLiteRow(void *result, ULong_t rowHandle);
~TSQLiteRow();
void Close(Option_t *opt="");
ULong_t GetFieldLength(Int_t field);
const char *GetField(Int_t field);
ClassDef(TSQLiteRow,0) // One row of SQLite query result
};
#endif
| // @(#)root/sqlite:
// Author: o.freyermuth <o.f@cern.ch>, 01/06/2013
/*************************************************************************
* Copyright (C) 1995-2013, 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_TSQLiteRow
#define ROOT_TSQLiteRow
#ifndef ROOT_TSQLRow
#include "TSQLRow.h"
#endif
#if !defined(__CINT__)
#include <sqlite3.h>
#else
struct sqlite3_stmt;
#endif
class TSQLiteRow : public TSQLRow {
private:
sqlite3_stmt *fResult; // current result set
Bool_t IsValid(Int_t field);
public:
TSQLiteRow(void *result, ULong_t rowHandle);
~TSQLiteRow();
void Close(Option_t *opt="");
ULong_t GetFieldLength(Int_t field);
const char *GetField(Int_t field);
ClassDef(TSQLiteRow,0) // One row of SQLite query result
};
#endif
|
Fix bug and solves the sequence | /**
https://www.urionlinejudge.com.br/judge/en/problems/view/1098
TODO:
Resolver a formatação da última impressão do loop.
Está:
I=2.0 J=3.0
I=2.0 J=4.0
I=2.0 J=5.0
Mas deveria estar:
I=2 J=3
I=2 J=4
I=2 J=5
*/
#include <stdio.h>
int main(){
double i, j;
i = 0;
do{
for (j = 1; j <= 3; j++){
if (i == (int) i){
printf("I=%.0lf J=%.0lf\n", i, i+j);
} else{
printf("I=%.1lf J=%.1lf\n", i, i+j);
}
}
i += 0.2;
//printf("Finalizando loop... Double: %lf e Float: %d\n", (double) i, (int) i); // debug
} while(i <= 2.0);
return 0;
} | /**
https://www.urionlinejudge.com.br/judge/en/problems/view/1098
*/
#include <stdio.h>
int main(){
int i, j;
float iR, jR;
for(i = 0; i <= 20; i += 2){
for (j = 10; j <= 30; j += 10){
iR = (float) i/10;
jR = (float) (i+j)/10;
if (i % 10) printf("I=%.1f J=%.1f\n", iR, jR);
else printf("I=%.0f J=%.0f\n", iR, jR);
}
}
return 0;
} |
Add rudimentary directory listing command | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2012 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kotaka/paths.h>
#include <kotaka/log.h>
#include <text/paths.h>
inherit LIB_WIZBIN;
void main(string args)
{
mixed **dirinfo;
dirinfo = proxy_call("get_dir", args);
send_out("There are " + sizeof(dirinfo[0]) + " files there.\n");
}
| |
Add stub for PDM sound filter | /**
* @file
* @brief
*
* @author Alexander Kalmuk
* @date 24.08.2018
*/
#include <assert.h>
#include <stm32f4_discovery.h>
#include <pdm_filter.h>
void PDM_Filter_Init(PDMFilter_InitStruct * Filter) {
assert(0);
}
int32_t PDM_Filter_64_MSB(uint8_t* data, uint16_t* dataOut,
uint16_t MicGain, PDMFilter_InitStruct * Filter) {
assert(0);
return -1;
}
int32_t PDM_Filter_64_LSB(uint8_t* data, uint16_t* dataOut,
uint16_t MicGain, PDMFilter_InitStruct * Filter) {
assert(0);
return -1;
}
| |
Increase heapsize for mbedtls library | /*
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <debug.h>
/* mbed TLS headers */
#include <mbedtls/memory_buffer_alloc.h>
#include <mbedtls/platform.h>
/*
* mbed TLS heap
*/
#if (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA)
#define MBEDTLS_HEAP_SIZE (14*1024)
#elif (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA)
#define MBEDTLS_HEAP_SIZE (6*1024)
#endif
static unsigned char heap[MBEDTLS_HEAP_SIZE];
/*
* mbed TLS initialization function
*/
void mbedtls_init(void)
{
static int ready;
if (!ready) {
/* Initialize the mbed TLS heap */
mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
/* Use reduced version of snprintf to save space. */
mbedtls_platform_set_snprintf(tf_snprintf);
ready = 1;
}
}
| /*
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <debug.h>
/* mbed TLS headers */
#include <mbedtls/memory_buffer_alloc.h>
#include <mbedtls/platform.h>
/*
* mbed TLS heap
*/
#if (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA)
#define MBEDTLS_HEAP_SIZE (14*1024)
#elif (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA)
#define MBEDTLS_HEAP_SIZE (7*1024)
#endif
static unsigned char heap[MBEDTLS_HEAP_SIZE];
/*
* mbed TLS initialization function
*/
void mbedtls_init(void)
{
static int ready;
if (!ready) {
/* Initialize the mbed TLS heap */
mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
/* Use reduced version of snprintf to save space. */
mbedtls_platform_set_snprintf(tf_snprintf);
ready = 1;
}
}
|
Fix Unix domain socket headers for Fuchsia | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_BIN_SOCKET_BASE_FUCHSIA_H_
#define RUNTIME_BIN_SOCKET_BASE_FUCHSIA_H_
#if !defined(RUNTIME_BIN_SOCKET_BASE_H_)
#error Do not include socket_base_fuchsia.h directly. Use socket_base.h.
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
#endif // RUNTIME_BIN_SOCKET_BASE_FUCHSIA_H_
| // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_BIN_SOCKET_BASE_FUCHSIA_H_
#define RUNTIME_BIN_SOCKET_BASE_FUCHSIA_H_
#if !defined(RUNTIME_BIN_SOCKET_BASE_H_)
#error Do not include socket_base_fuchsia.h directly. Use socket_base.h.
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/un.h>
#endif // RUNTIME_BIN_SOCKET_BASE_FUCHSIA_H_
|
Add initial layout of hash map implementation | #ifndef JTL_HASH_MAP_H__
#define JTL_HASH_MAP_H__
#include <memory>
namespace jtl {
template <typename Key,
typename Value>
class HashMap {
struct MapNode {
MapNode(Key k, Value v) : key(k), value(v) {}
~MapNode() {
delete key;
delete value;
}
Key key;
Value value;
}; // struct MapNode
class HashMapBase_ {
private:
// bins is an array of pointers to arrays of key-value nodes
MapNode** bins_;
}; // class HashMapBase_
public:
private:
Key* bins_;
}; // class HashMap
} // namespace jtl
#endif
| |
Test that invoking longjmp with an argument of 0 causes setjmp to return 1 | /*
* Copyright 2010 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <setjmp.h>
#include <stdio.h>
static jmp_buf buf;
int main(void) {
volatile int result = -1;
if (!setjmp(buf) ) {
result = 55;
printf("setjmp was invoked\n");
longjmp(buf, 1);
printf("this print statement is not reached\n");
return -1;
} else {
printf("longjmp was invoked\n");
return result;
}
}
| /*
* Copyright 2010 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <setjmp.h>
#include <stdio.h>
#include "native_client/src/include/nacl_assert.h"
static jmp_buf buf;
int trysetjmp(int longjmp_arg) {
volatile int result = -1;
int setjmp_ret = -1;
setjmp_ret = setjmp(buf);
if (!setjmp_ret) {
/* Check that setjmp() doesn't return 0 multiple times */
ASSERT_EQ(result, -1);
result = 55;
printf("setjmp was invoked\n");
longjmp(buf, longjmp_arg);
printf("this print statement is not reached\n");
return -1;
} else {
int expected_ret = longjmp_arg != 0 ? longjmp_arg : 1;
ASSERT_EQ(setjmp_ret, expected_ret);
printf("longjmp was invoked\n");
return result;
}
}
int main(void) {
if (trysetjmp(1) != 55 ||
trysetjmp(0) != 55 ||
trysetjmp(-1) != 55)
return -1;
return 55;
}
|
Update test case; VLA's are now supported. | // RUN: clang -verify -emit-llvm -o - %s
int f0(int x) {
int vla[x];
return vla[x-1]; // expected-error {{cannot compile this return inside scope with VLA yet}}
}
| // RUN: clang -verify -emit-llvm -o - %s
void *x = L"foo"; // expected-error {{cannot compile this wide string yet}}
|
Add test case for less-than comparision on enums. | //PARAM: --enable ana.int.enums --disable ana.int.def_exc
int main(){
int top = rand();
int x,y;
if(top){
x = 1;
} else{
x = 0;
}
assert(x<2);
return 0;
}
| |
Set header location depending on flags | #include <stdlib.h>
#include <stdio.h>
#include "../src/prompt.h"
int main(void)
{
for (;;)
{
char *line = prompt("> ");
if (line == NULL)
break;
printf("You wrote '%s'\n", line);
free(line);
}
prompt_free();
return 0;
}
| #include <stdlib.h>
#include <stdio.h>
#ifdef DEBUG
# include "../src/prompt.h"
#else
# include <prompt.h>
#endif
int main(void)
{
for (;;)
{
char *line = prompt("> ");
if (line == NULL)
break;
printf("You wrote '%s'\n", line);
free(line);
}
prompt_free();
return 0;
}
|
Add some beginning test functions (for jid.c). | /**
* xmp3 - XMPP Proxy
* Copyright (c) 2012 Drexel University
*
* @file jid_test.c
* Unit tests for JID functions.
*/
#include <test-dept.h>
#include <stdlib.h>
#include <stdio.h>
#include "jid.h"
void setup(void) {
}
void teardown(void) {
restore_function(&calloc);
}
static void* always_failing_calloc() {
return NULL;
}
void test_new_bad_malloc(void) {
replace_function(&calloc, &always_failing_calloc);
struct jid* jid = jid_new();
assert_pointer_equals(NULL, jid);
}
void test_from_str1(void) {
struct jid* jid = jid_new_from_str("local@domain/resource");
assert_string_equals("local", jid_local(jid));
assert_string_equals("domain", jid_domain(jid));
assert_string_equals("resource", jid_resource(jid));
jid_del(jid);
}
void test_from_str2(void) {
struct jid* jid = jid_new_from_str("local@domain");
assert_string_equals("local", jid_local(jid));
assert_string_equals("domain", jid_domain(jid));
assert_pointer_equals(NULL, jid_resource(jid));
jid_del(jid);
}
void test_from_str3(void) {
struct jid* jid = jid_new_from_str("domain");
assert_pointer_equals(NULL, jid_local(jid));
assert_string_equals("domain", jid_domain(jid));
assert_pointer_equals(NULL, jid_resource(jid));
jid_del(jid);
}
| |
Add failing test case for enums | // PARAM: --disable ana.int.interval --disable ana.int.def_exc --enable ana.int.enums
void main(){
int n = 1;
for (; n; n++) { // fixed point not reached here
}
return;
} | |
Add target description for KL26Z | /* 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 "target_config.h"
// frdm-k64f target information
const target_cfg_t target_device = {
.board_id = "0000",
.secret = "xxxxxxxx",
.sector_size = 2048,
// Assume memory is regions are same size. Flash algo should ignore requests
// when variable sized sectors exist
// .sector_cnt = ((.flash_end - .flash_start) / .sector_size);
.sector_cnt = (kB(512)/2048),
.flash_start = 0,
.flash_end = kB(512),
.ram_start = 0x1FFF0000,
.ram_end = 0x20010000,
.disc_size = kB(512)
};
| |
Change login logic, add 'l' cmd | #ifndef _LOGINWINDOW_H_
#define _LOGINWINDOW_H_
#include <string>
#include <iostream>
#include "window.h"
using namespace std;
class LoginWindow : public Window {
string name;
string pass;
public:
LoginWindow():Window("Login") {}
const string& getUsername() const {
return name;
}
const string& getPassword() const {
return pass;
}
virtual void handle() {
bool passSet = false;
bool nameSet = false;
do {
drawTitle();
cout << "User: " << name << endl;
cout << "Password: " << pass << endl;
cout << endl << "Write 'u' to edit the username, 'p' to edit the password." << endl;
string cmd = readCommand();
if(cmd == "u") {
string name = readCommand("User > ");
this->name = name;
nameSet = (name != "");
}else if(cmd == "p") {
string pass = readCommand("Pass > ");
this->pass = pass;
passSet = (pass != "");
}
}while(!passSet || !nameSet);
}
};
#endif
| #ifndef _LOGINWINDOW_H_
#define _LOGINWINDOW_H_
#include <string>
#include <iostream>
#include "window.h"
using namespace std;
class LoginWindow : public Window {
string name;
string pass;
public:
LoginWindow():Window("Login") {}
const string& getUsername() const {
return name;
}
const string& getPassword() const {
return pass;
}
virtual void handle() {
bool complete = false;
do {
drawTitle();
cout << "User: " << name << endl;
cout << "Password: " << string(pass.length(),'*') << endl;
cout << endl << "Write 'u' to edit the username, 'p' to edit the password." << endl;
if(pass != "" && name != "") {
cout << "Write 'l' to login." << endl;
}
string cmd = readCommand();
if(cmd == "u") {
string name = readCommand("User > ");
this->name = name;
}else if(cmd == "p") {
string pass = readCommand("Pass > ");
this->pass = pass;
}else if(pass != "" && name != "" && cmd == "l") {
complete = true;
}
}while(!complete);
}
};
#endif
|
Add class comment for proton::bucketdb::RemoveBatchEntry. | // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/document/base/globalid.h>
#include <vespa/document/bucket/bucketid.h>
#include <persistence/spi/types.h>
namespace proton::bucketdb {
class RemoveBatchEntry {
document::GlobalId _gid;
document::BucketId _bucket_id;
storage::spi::Timestamp _timestamp;
uint32_t _doc_size;
public:
RemoveBatchEntry(const document::GlobalId& gid, const document::BucketId& bucket_id, const storage::spi::Timestamp& timestamp, uint32_t doc_size) noexcept
: _gid(gid),
_bucket_id(bucket_id),
_timestamp(timestamp),
_doc_size(doc_size)
{
}
const document::GlobalId& get_gid() const noexcept { return _gid; }
const document::BucketId& get_bucket_id() const noexcept { return _bucket_id; }
const storage::spi::Timestamp& get_timestamp() const noexcept { return _timestamp; }
uint32_t get_doc_size() const noexcept { return _doc_size; }
};
}
| // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/document/base/globalid.h>
#include <vespa/document/bucket/bucketid.h>
#include <persistence/spi/types.h>
namespace proton::bucketdb {
/*
* Class containing meta data for a single document being removed from
* bucket db.
*/
class RemoveBatchEntry {
document::GlobalId _gid;
document::BucketId _bucket_id;
storage::spi::Timestamp _timestamp;
uint32_t _doc_size;
public:
RemoveBatchEntry(const document::GlobalId& gid, const document::BucketId& bucket_id, const storage::spi::Timestamp& timestamp, uint32_t doc_size) noexcept
: _gid(gid),
_bucket_id(bucket_id),
_timestamp(timestamp),
_doc_size(doc_size)
{
}
const document::GlobalId& get_gid() const noexcept { return _gid; }
const document::BucketId& get_bucket_id() const noexcept { return _bucket_id; }
const storage::spi::Timestamp& get_timestamp() const noexcept { return _timestamp; }
uint32_t get_doc_size() const noexcept { return _doc_size; }
};
}
|
Define 'unsigned long' as 'DWORD' for cross-platform | #ifndef _SYSTEMEMORY_H_
#define _SYSTEMEMORY_H_
#include "windows.h"
class SystemMemory
{
private:
MEMORYSTATUSEX memoryStat;
private:
int memoryCall();
public:
int getLoadPercent(int &val);
int getUsage(double &val);
int getTotalByte(DWORD &val);
int getFreeByte(DWORD &val);
};
#endif | #ifndef _SYSTEMEMORY_H_
#define _SYSTEMEMORY_H_
#include "windows.h"
typedef unsigned long DWORD;
class SystemMemory
{
private:
MEMORYSTATUSEX memoryStat;
private:
int memoryCall();
public:
int getLoadPercent(int &val);
int getUsage(double &val);
int getTotalByte(DWORD &val);
int getFreeByte(DWORD &val);
};
#endif |
Move constant declarations to header file | #ifndef FINAL_SEQUENTIALSA_SA_H_
#define FINAL_SEQUENTIALSA_SA_H_
#endif // FINAL_SEQUENTIALSA_SA_H_
| #ifndef FINAL_SEQUENTIALSA_SA_H_
#define FINAL_SEQUENTIALSA_SA_H_
#define TEMPERATURE 100 /*Initial temperature*/
#define TEMPERATURE_DECREMENT 0.99 /*The amount by which teh temperature is decrement each iteration*/
#define TEMPERATURE_FINAL 0.01 /*The coolest temperature, time to stop*/
#define NUMBER_ITERATIONS 1000 /*Total number of iterations to execute before reducing temperature*/
#define ITERATIONS_PER_FILE 5 /*Number of times to run each input file*/
#endif // FINAL_SEQUENTIALSA_SA_H_
|
Add percentage class to main header | #ifndef _GMTK_H_
#define _GMTK_H_
#include "half.h"
#include "angle.h"
#include "vector.h"
#include "matrix.h"
#include "quaternion.h"
#endif//_GMTK_H_ | #ifndef _GMTK_H_
#define _GMTK_H_
#include "half.h"
#include "angle.h"
#include "percent.h"
#include "vector.h"
#include "matrix.h"
#include "quaternion.h"
#endif//_GMTK_H_ |
Disable Ctrl-C and Ctrl-Z (Ctrl-Y on macOS) | #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disable_raw_mode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enable_raw_mode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disable_raw_mode);
struct termios raw = orig_termios;
raw.c_lflag &= ~(ECHO | ICANON);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enable_raw_mode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') {
if (iscntrl(c)) {
printf("%d\n", c);
} else {
printf("%d ('%c')\n", c, c);
}
}
return 0;
}
| #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disable_raw_mode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enable_raw_mode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disable_raw_mode);
struct termios raw = orig_termios;
raw.c_lflag &= ~(ECHO | ICANON | ISIG);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enable_raw_mode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') {
if (iscntrl(c)) {
printf("%d\n", c);
} else {
printf("%d ('%c')\n", c, c);
}
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.