Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add types, allow for subroutines. | struct stack_node {
struct stack_node *cdr;
int data;
char type;
}
struct subroutine {
struct stack_node *nodes;
int num_nodes;
}
| #define T_INT 0
#define T_CHAR 1
#define T_SBRTN 2
struct stack_node {
struct stack_node *cdr;
union node_data data;
}
union node_data {
struct subroutine srtine;
int numval;
char type;
}
struct subroutine {
struct stack_node *nodes;
int num_nodes;
}
|
Use uint32_t for compilation unit index instead of uint16_t. | /*
* Copyright (C) 2011 The Android Open Source Project
*
* 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 ART_SRC_UTILS_LLVM_H_
#define ART_SRC_UTILS_LLVM_H_
#include "stringprintf.h"
#include <llvm/Analysis/Verifier.h>
#include <stdint.h>
#include <string>
namespace art {
#ifndef NDEBUG
#define VERIFY_LLVM_FUNCTION(func) llvm::verifyFunction(func, llvm::PrintMessageAction)
#else
#define VERIFY_LLVM_FUNCTION(func)
#endif
inline static std::string ElfFuncName(uint16_t idx) {
return StringPrintf("Art%u", static_cast<unsigned int>(idx));
}
class CStringLessThanComparator {
public:
bool operator()(const char* lhs, const char* rhs) const {
return (strcmp(lhs, rhs) < 0);
}
};
} // namespace art
#endif // ART_SRC_UTILS_LLVM_H_
| /*
* Copyright (C) 2011 The Android Open Source Project
*
* 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 ART_SRC_UTILS_LLVM_H_
#define ART_SRC_UTILS_LLVM_H_
#include "stringprintf.h"
#include <llvm/Analysis/Verifier.h>
#include <stdint.h>
#include <string>
namespace art {
#ifndef NDEBUG
#define VERIFY_LLVM_FUNCTION(func) llvm::verifyFunction(func, llvm::PrintMessageAction)
#else
#define VERIFY_LLVM_FUNCTION(func)
#endif
inline static std::string ElfFuncName(uint32_t idx) {
return StringPrintf("Art%u", static_cast<unsigned int>(idx));
}
class CStringLessThanComparator {
public:
bool operator()(const char* lhs, const char* rhs) const {
return (strcmp(lhs, rhs) < 0);
}
};
} // namespace art
#endif // ART_SRC_UTILS_LLVM_H_
|
Refactor to clean up isr written variable | #ifndef EMBEDDEDHELPERLIBRARY_ISR_WRITTEN_VARIABLE_H
#define EMBEDDEDHELPERLIBRARY_ISR_WRITTEN_VARIABLE_H
#include "rvalue.h"
namespace ehl
{
template<typename T>
class isr_written_variable
{
private:
mutable volatile bool modified;
volatile T value;
public:
isr_written_variable() = default;
isr_written_variable(T initial_value)
:value{as_rvalue(initial_value)}
{
}
isr_written_variable& operator=(isr_written_variable const& other)
{
value = other.value;
modified = true;
return *this;
}
isr_written_variable<T>& operator=(T new_value)
{
value = as_rvalue(new_value);
modified = true;
return *this;
}
operator T() const
{
modified = false;
T v = value;
while(modified)
{
modified = false;
v = value;
}
return v;
}
};
}
#endif //EMBEDDEDHELPERLIBRARY_ISR_WRITTEN_VARIABLE_H
| #ifndef EMBEDDEDHELPERLIBRARY_ISR_WRITTEN_VARIABLE_H
#define EMBEDDEDHELPERLIBRARY_ISR_WRITTEN_VARIABLE_H
#include "rvalue.h"
namespace ehl
{
template<typename T>
class isr_written_variable
{
private:
mutable volatile bool modified;
volatile T value;
public:
isr_written_variable() = default;
isr_written_variable(T initial_value)
:value{as_rvalue(initial_value)}
{
}
isr_written_variable& operator=(isr_written_variable const& other)
{
value = other.value;
modified = true;
return *this;
}
isr_written_variable<T>& operator=(T new_value)
{
value = as_rvalue(new_value);
modified = true;
return *this;
}
operator T() const
{
while(true)
{
modified = false;
T v = value;
if(!modified)
return v;
}
}
};
}
#endif //EMBEDDEDHELPERLIBRARY_ISR_WRITTEN_VARIABLE_H
|
Fix uchar vs. char in natnet_sender_t; add natnet_packet_t | #ifndef OPTITRACK_WIRE_H_
#define OPTITRACK_WIRE_H_
#include <stdint.h>
typedef enum {
NAT_PING = 0,
NAT_PINGRESPONSE = 1,
NAT_REQUEST = 2,
NAT_RESPONSE = 3,
NAT_REQUEST_MODELDEF = 4,
NAT_MODELDEF = 5,
NAT_REQUEST_FRAMEOFDATA = 6,
NAT_FRAMEOFDATA = 7,
NAT_MESSAGESTRING = 8,
NAT_UNRECOGNIZED_REQUEST = 100
} natnet_msg_id_t;
typedef struct {
uint16_t type;
uint16_t sz;
} natnet_msg_header_t;
#define MAX_NAMELENGTH 256
typedef struct {
char name[MAX_NAMELENGTH];
char app_version[4];
char natnet_version[4];
} natnet_sender_t;
#endif//OPTITRACK_WIRE_H_
| #ifndef OPTITRACK_WIRE_H_
#define OPTITRACK_WIRE_H_
#include <stdint.h>
typedef enum {
NAT_PING = 0,
NAT_PINGRESPONSE = 1,
NAT_REQUEST = 2,
NAT_RESPONSE = 3,
NAT_REQUEST_MODELDEF = 4,
NAT_MODELDEF = 5,
NAT_REQUEST_FRAMEOFDATA = 6,
NAT_FRAMEOFDATA = 7,
NAT_MESSAGESTRING = 8,
NAT_UNRECOGNIZED_REQUEST = 100
} natnet_msg_id_t;
typedef struct {
uint16_t type;
uint16_t sz;
} natnet_msg_header_t;
#define MAX_NAMELENGTH 256
#define MAX_PACKETSIZE 100000
typedef struct {
char name[MAX_NAMELENGTH];
unsigned char app_version[4];
unsigned char natnet_version[4];
} natnet_sender_t;
typedef struct {
natnet_msg_header_t header;
union {
unsigned char byteData [MAX_PACKETSIZE];
unsigned int intData [MAX_PACKETSIZE / sizeof(unsigned int)];
float floatData[MAX_PACKETSIZE / sizeof(float)];
natnet_sender_t sender;
} data;
} natnet_packet_t;
#endif//OPTITRACK_WIRE_H_
|
Add a "counted copying iterator". | #pragma once
#include <cstddef>
namespace scratch {
template<class T>
struct counted_copying_iterator {
using value_type = T;
using difference_type = ptrdiff_t;
using pointer = const T *;
using reference = const T&;
using iterator_category = random_access_iterator_tag;
explicit counted_copying_iterator() noexcept = default;
explicit counted_copying_iterator(size_t c, const T& t) noexcept : m_count(c), m_t(&t) {}
const T& operator*() const noexcept { return *m_t; }
const T *operator->() const noexcept { return m_t; }
const T& operator[](difference_type) const noexcept { return m_t; }
auto& operator+=(int i) noexcept { m_count -= i; return *this; }
auto& operator++() noexcept { return *this += 1; }
auto operator++(int) noexcept { auto old = *this; ++*this; return old; }
auto& operator-=(int i) noexcept { m_count += i; return *this; }
auto& operator--() noexcept { return *this -= 1; }
auto operator--(int) noexcept { auto old = *this; --*this; return old; }
difference_type operator-(const counted_copying_iterator& rhs) const noexcept { return rhs.m_count - m_count; }
bool operator==(const counted_copying_iterator& rhs) const noexcept { return m_count == rhs.m_count; }
bool operator!=(const counted_copying_iterator& rhs) const noexcept { return m_count != rhs.m_count; }
private:
size_t m_count = 0;
const T *m_t = nullptr;
};
template<class T> auto operator-(counted_copying_iterator<T> a, ptrdiff_t b) noexcept { a -= b; return a; }
template<class T> auto operator+(counted_copying_iterator<T> a, ptrdiff_t b) noexcept { a += b; return a; }
template<class T> auto operator+(ptrdiff_t b, counted_copying_iterator<T> a) noexcept { a += b; return a; }
} // namespace scratch
| |
Add line endings for Mac OS. | #ifndef __COMMONS_H
#define __COMMONS_H
#ifdef __APPLE__
#define ENDLINE '\r'
#else
#define ENDLINE '\n'
#endif
#endif
| |
Make include guard name for color.h be compliant with our standard | #ifndef TRN_RGB_COLOR_H
#define TRN_RGB_COLOR_H
#include <stdbool.h>
typedef struct {
float red;
float green;
float blue;
} TrnColor;
extern TrnColor const TRN_WHITE;
extern TrnColor const TRN_RED;
extern TrnColor const TRN_GREEN;
extern TrnColor const TRN_BLUE;
extern TrnColor const TRN_YELLOW;
extern TrnColor const TRN_ORANGE;
extern TrnColor const TRN_TURQUOISE;
extern TrnColor const TRN_PURPLE;
extern TrnColor const TRN_CYAN;
bool trn_color_equal(TrnColor const left, TrnColor const right);
#endif
| #ifndef TRN_COLOR_H
#define TRN_COLOR_H
#include <stdbool.h>
typedef struct {
float red;
float green;
float blue;
} TrnColor;
extern TrnColor const TRN_WHITE;
extern TrnColor const TRN_RED;
extern TrnColor const TRN_GREEN;
extern TrnColor const TRN_BLUE;
extern TrnColor const TRN_YELLOW;
extern TrnColor const TRN_ORANGE;
extern TrnColor const TRN_TURQUOISE;
extern TrnColor const TRN_PURPLE;
extern TrnColor const TRN_CYAN;
bool trn_color_equal(TrnColor const left, TrnColor const right);
#endif
|
Remove AI_ADDRCONFIG, since the netlink socket is missing CLOEXEC and gets inherited by children. | #include <netdb.h>
#include "asyncaddrinfo.h"
#include "peer.h"
#include "resolve.h"
void resolve_init() {
asyncaddrinfo_init(2);
}
void resolve_cleanup() {
asyncaddrinfo_cleanup();
}
void resolve(struct peer *peer, const char *node, const char *service, int flags) {
struct addrinfo hints = {
.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | flags,
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
};
peer->fd = asyncaddrinfo_resolve(node, service, &hints);
peer_epoll_add(peer, EPOLLIN);
}
int resolve_result(struct peer *peer, struct addrinfo **addrs) {
int err = asyncaddrinfo_result(peer->fd, addrs);
peer->fd = -1;
return err;
}
| #include <netdb.h>
#include "asyncaddrinfo.h"
#include "peer.h"
#include "resolve.h"
void resolve_init() {
asyncaddrinfo_init(2);
}
void resolve_cleanup() {
asyncaddrinfo_cleanup();
}
void resolve(struct peer *peer, const char *node, const char *service, int flags) {
struct addrinfo hints = {
.ai_flags = AI_V4MAPPED | flags,
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
};
peer->fd = asyncaddrinfo_resolve(node, service, &hints);
peer_epoll_add(peer, EPOLLIN);
}
int resolve_result(struct peer *peer, struct addrinfo **addrs) {
int err = asyncaddrinfo_result(peer->fd, addrs);
peer->fd = -1;
return err;
}
|
Add cabecalho para as funcoes (modularizando) | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define PI 3.14
float soluc (float, float);
float radians_degrees (float);
float degrees_radians (float);
| |
Add command to check bulk sync stats | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2013 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/kotaka.h>
#include <kotaka/paths/string.h>
#include <kotaka/paths/system.h>
#include <kotaka/paths/verb.h>
#include <kotaka/paths/thing.h>
inherit LIB_VERB;
string *query_parse_methods()
{
return ({ "raw" });
}
void main(object actor, mapping roles)
{
object user;
float interval;
user = query_user();
if (user->query_class() < 2) {
send_out("You do not have sufficient access rights to query the bulk sync system.\n");
return;
}
send_out(BULKD->query_pending() + " objects pending.\n");
return;
}
| |
Set the GTK+ backward compatibility check to 2.21.2. | #ifndef __GTK_COMPAT_H__
#define __GTK_COMPAT_H__
#include <gtk/gtk.h>
/* Provide a compatibility layer for accessor functions introduced
* in GTK+ 2.22 which we need to build with sealed GDK.
* That way it is still possible to build with GTK+ 2.20.
*/
#if !GTK_CHECK_VERSION(2, 21, 0)
#define gdk_drag_context_get_actions(context) (context)->actions
#define gdk_drag_context_get_suggested_action(context) (context)->suggested_action
#define gdk_drag_context_get_selected_action(context) (context)->action
#endif /* GTK_CHECK_VERSION(2, 21, 0) */
#endif /* __GTK_COMPAT_H__ */
| #ifndef __GTK_COMPAT_H__
#define __GTK_COMPAT_H__
#include <gtk/gtk.h>
/* Provide a compatibility layer for accessor functions introduced
* in GTK+ 2.22 which we need to build with sealed GDK.
* That way it is still possible to build with GTK+ 2.20.
*/
#if !GTK_CHECK_VERSION(2,21,2)
#define gdk_drag_context_get_actions(context) (context)->actions
#define gdk_drag_context_get_suggested_action(context) (context)->suggested_action
#define gdk_drag_context_get_selected_action(context) (context)->action
#endif /* GTK_CHECK_VERSION(2, 21, 0) */
#endif /* __GTK_COMPAT_H__ */
|
Make reply parser result optional | /*
Copyright 2019 The Matrix.org Foundation C.I.C
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#import <Foundation/Foundation.h>
#import "MXReplyEventParts.h"
#import "MXEvent.h"
NS_ASSUME_NONNULL_BEGIN
/**
Reply event parser.
*/
@interface MXReplyEventParser : NSObject
- (MXReplyEventParts*)parse:(MXEvent*)replyEvent;
@end
NS_ASSUME_NONNULL_END
| /*
Copyright 2019 The Matrix.org Foundation C.I.C
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#import <Foundation/Foundation.h>
#import "MXReplyEventParts.h"
#import "MXEvent.h"
NS_ASSUME_NONNULL_BEGIN
/**
Reply event parser.
*/
@interface MXReplyEventParser : NSObject
- (nullable MXReplyEventParts*)parse:(MXEvent*)replyEvent;
@end
NS_ASSUME_NONNULL_END
|
Add imports to Bridging Header. | //
// Use this file to import your target's public headers that you would like to expose to Swift.
//
| //
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import <Parse/Parse.h>
#import <Bolts/Bolts.h>
#import <AWSiOSSDKv2/AWSCore.h>
#import <AWSiOSSDKv2/S3.h>
#import <AWSiOSSDKv2/DynamoDB.h>
#import <AWSiOSSDKv2/SQS.h>
#import <AWSiOSSDKv2/SNS.h> |
Fix for legacy QT compatibility | #ifndef MACDOCKICONHANDLER_H
#define MACDOCKICONHANDLER_H
#include <QtCore/QObject>
class QMenu;
class QIcon;
class QWidget;
class objc_object;
/** Macintosh-specific dock icon handler.
*/
class MacDockIconHandler : public QObject
{
Q_OBJECT
public:
~MacDockIconHandler();
QMenu *dockMenu();
void setIcon(const QIcon &icon);
static MacDockIconHandler *instance();
void handleDockIconClickEvent();
signals:
void dockIconClicked();
public slots:
private:
MacDockIconHandler();
objc_object *m_dockIconClickEventHandler;
QWidget *m_dummyWidget;
QMenu *m_dockMenu;
};
#endif // MACDOCKICONCLICKHANDLER_H
| #ifndef MACDOCKICONHANDLER_H
#define MACDOCKICONHANDLER_H
#include <QtCore/QObject>
class QMenu;
class QIcon;
class QWidget;
#ifdef __OBJC__
@class DockIconClickEventHandler;
#else
class DockIconClickEventHandler;
#endif
/** Macintosh-specific dock icon handler.
*/
class MacDockIconHandler : public QObject
{
Q_OBJECT
public:
~MacDockIconHandler();
QMenu *dockMenu();
void setIcon(const QIcon &icon);
static MacDockIconHandler *instance();
void handleDockIconClickEvent();
signals:
void dockIconClicked();
public slots:
private:
MacDockIconHandler();
DockIconClickEventHandler *m_dockIconClickEventHandler;
QWidget *m_dummyWidget;
QMenu *m_dockMenu;
};
#endif // MACDOCKICONCLICKHANDLER_H
|
Make the alternative cmac 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_CCM_ALT
#define MBEDTLS_CMAC_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-2019, 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_CCM_ALT
//#define MBEDTLS_CMAC_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__
|
Make use of mutex easier to see | #include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include "uv.h"
static uv_mutex_t mutex;
static uv_thread_t thread;
static int crit_data = 0;
static void thread_cb(void* arg) {
uv_mutex_lock(&mutex);
printf("thread mutex start\n");
crit_data = 2;
printf("thread mutex end\n");
uv_mutex_unlock(&mutex);
}
int main() {
assert(0 == uv_mutex_init(&mutex));
assert(0 == uv_thread_create(&thread, thread_cb, NULL));
uv_mutex_lock(&mutex);
printf("main mutex start\n");
sleep(1);
crit_data = 1;
printf("main mutex end\n");
uv_mutex_unlock(&mutex);
uv_thread_join(&thread);
uv_mutex_destroy(&mutex);
return 0;
}
| #include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include "uv.h"
static uv_mutex_t mutex;
static uv_thread_t thread;
static void thread_cb(void* arg) {
printf("thread_cb\n");
uv_mutex_lock(&mutex);
printf("thread mutex\n");
uv_mutex_unlock(&mutex);
}
int main() {
assert(0 == uv_mutex_init(&mutex));
assert(0 == uv_thread_create(&thread, thread_cb, NULL));
uv_mutex_lock(&mutex);
printf("main mutex start\n");
sleep(1);
printf("main mutex end\n");
uv_mutex_unlock(&mutex);
uv_thread_join(&thread);
uv_mutex_destroy(&mutex);
return 0;
}
|
Fix stub implementation (add missing sigaction decl) | /**
* @file
* @brief Stubs for standard signals.
*
* @date 07.10.2013
* @author Eldar Abusalimov
*/
#ifndef KERNEL_THREAD_SIGSTD_STUB_H_
#define KERNEL_THREAD_SIGSTD_STUB_H_
#include <errno.h>
#define SIGSTD_MIN 0
#define SIGSTD_MAX -1
struct sigstd_data { }; /* stub */
static inline struct sigstd_data * sigstd_data_init(
struct sigstd_data *sigstd_data) {
return sigstd_data;
}
static inline int sigstd_raise(struct sigstd_data *data, int sig) {
return -ENOSYS;
}
static inline void sigstd_handle(struct sigstd_data *data,
struct sigaction *sig_table) {
/* no-op */
}
#endif /* KERNEL_THREAD_SIGSTD_STUB_H_ */
| /**
* @file
* @brief Stubs for standard signals.
*
* @date 07.10.2013
* @author Eldar Abusalimov
*/
#ifndef KERNEL_THREAD_SIGSTD_STUB_H_
#define KERNEL_THREAD_SIGSTD_STUB_H_
#include <errno.h>
#include <signal.h>
#define SIGSTD_MIN 0
#define SIGSTD_MAX -1
struct sigstd_data { }; /* stub */
static inline struct sigstd_data * sigstd_data_init(
struct sigstd_data *sigstd_data) {
return sigstd_data;
}
static inline int sigstd_raise(struct sigstd_data *data, int sig) {
return -ENOSYS;
}
static inline void sigstd_handle(struct sigstd_data *data,
struct sigaction *sig_table) {
/* no-op */
}
#endif /* KERNEL_THREAD_SIGSTD_STUB_H_ */
|
Add test based on getTable.c. | /* liblouis Braille Translation and Back-Translation Library
Copyright (C) 2012 James Teh <jamie@nvaccess.org>
Copyright (C) 2015 Davy Kager <mail@davykager.nl>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "liblouis.h"
int
main(int argc, char **argv)
{
const char *goodTable = "en-us-g1.ctb";
const char *badTable = "bad.ctb";
int result = 0;
if (lou_checkTable(goodTable) == 0)
{
printf("Getting %s failed, expected success\n", goodTable);
result = 1;
}
if (lou_checkTable(badTable) != 0)
{
printf("Getting %s succeeded, expected failure\n", badTable);
result = 1;
}
if (lou_checkTable(goodTable) == 0)
{
printf("Getting %s failed, expected success\n", goodTable);
result = 1;
}
lou_free();
return result;
}
| |
Make FORCE_LONG_ENUM actually force a long instead of an int | /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef __LIBSEL4_MACROS_H
#define __LIBSEL4_MACROS_H
#include <autoconf.h>
/*
* Some compilers attempt to pack enums into the smallest possible type.
* For ABI compatability with the kernel, we need to ensure they remain
* the same size as an 'int'.
*/
#define SEL4_FORCE_LONG_ENUM(type) \
_enum_pad_ ## type = (1U << ((sizeof(int)*8) - 1)) - 1
#ifndef CONST
#define CONST __attribute__((__const__))
#endif
#ifndef PURE
#define PURE __attribute__((__pure__))
#endif
#define SEL4_OFFSETOF(type, member) __builtin_offsetof(type, member)
#ifdef CONFIG_LIB_SEL4_INLINE_INVOCATIONS
#define LIBSEL4_INLINE static inline
#else
#define LIBSEL4_INLINE __attribute__((noinline)) __attribute__((unused)) __attribute__((weak))
#endif
#endif
| /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef __LIBSEL4_MACROS_H
#define __LIBSEL4_MACROS_H
#include <autoconf.h>
/*
* Some compilers attempt to pack enums into the smallest possible type.
* For ABI compatability with the kernel, we need to ensure they remain
* the same size as a 'long'.
*/
#define SEL4_FORCE_LONG_ENUM(type) \
_enum_pad_ ## type = (1ULL << ((sizeof(long)*8) - 1)) - 1
#ifndef CONST
#define CONST __attribute__((__const__))
#endif
#ifndef PURE
#define PURE __attribute__((__pure__))
#endif
#define SEL4_OFFSETOF(type, member) __builtin_offsetof(type, member)
#ifdef CONFIG_LIB_SEL4_INLINE_INVOCATIONS
#define LIBSEL4_INLINE static inline
#else
#define LIBSEL4_INLINE __attribute__((noinline)) __attribute__((unused)) __attribute__((weak))
#endif
#endif
|
Add fuller definition of Stream<Byte> | #ifndef C_BYTESTREAM_H
#define C_BYTESTREAM_H
#include "ByteListener.h"
#include "ByteProducer.h"
#include "ByteSubscription.h"
typedef struct ByteStream {
void (*add_listener) (struct ByteStream *self, ByteListener *listener);
void (*remove_listener) (struct ByteStream *self, ByteListener *listener);
void *(*subscribe) (struct ByteStream *self, ByteListener *listener);
ByteSubscription *(*unsubscribe) (struct ByteStream *self, ByteListener *listener);
} ByteStream;
ByteStream *byte_stream_create (ByteProducer *producer);
#endif // C_BYTESTREAM_H
| #ifndef C_BYTESTREAM_H
#define C_BYTESTREAM_H
#include "ByteListener.h"
#include "ByteProducer.h"
#include "ByteSubscription.h"
#include "ByteListenerInternal.h"
#include "ByteProducerInternal.h"
#include "VariableLengthArray.h"
typedef uint8_t Boolean;
typedef Byte (*byte_steam_map_function) (Byte value);
typedef Boolean (*byte_steam_filter_function) (Byte value);
typedef struct ByteStream {
void (*add_listener) (struct ByteStream *self, ByteListener *listener);
void (*remove_listener) (struct ByteStream *self, ByteListener *listener);
void *(*subscribe) (struct ByteStream *self, ByteListener *listener);
ByteSubscription *(*unsubscribe) (struct ByteStream *self, ByteListener *listener);
ByteListenerInternal *_internal_listener;
ByteProducerInternal *_producer;
VariableLengthArray *_internal_listeners;
int _stop_id;
int _error;
void (*_teardown) (struct ByteStream *self);
void (*_stop_now) (struct ByteStream *self);
void (*_add) (struct ByteStream *self, ByteListenerInternal *listener);
void (*_remove) (struct ByteStream *self, ByteListenerInternal *listener);
struct ByteStream *(*map) (struct ByteStream *self, byte_steam_map_function map);
struct ByteStream *(*mapTo) (struct ByteStream *self, Byte value);
struct ByteStream *(*filter) (struct ByteStream *self, byte_steam_filter_function filter);
struct ByteStream *(*take) (struct ByteStream *self, int count);
struct ByteStream *(*drop) (struct ByteStream *self, int count);
struct ByteStream *(*last) (struct ByteStream *self);
} ByteStream;
ByteStream *byte_stream_create (ByteProducer *producer);
ByteStream *byte_stream_never ();
ByteStream *byte_stream_empty ();
ByteStream *byte_stream_throw ();
ByteStream *byte_stream_from_array (Byte array[]);
ByteStream *byte_stream_periodic (int milliseconds);
ByteStream *byte_stream_merge (ByteStream streams[]);
#endif // C_BYTESTREAM_H
|
Fix off-by-one error in C code | #include "gradient_decent.h"
void decend_cpu(int len, double rate, double momentum, double regulariser,
const double* weights,
const double* gradient,
const double* last,
double* outputWeights, double* outputMomentum) {
for (int i = 0; i <= len; i++) {
outputMomentum[i] = momentum * last[i] - rate * gradient[i];
outputWeights[i] = weights[i] + outputMomentum[i] - (rate * regulariser) * weights[i];
}
}
| #include "gradient_decent.h"
void decend_cpu(int len, double rate, double momentum, double regulariser,
const double* weights,
const double* gradient,
const double* last,
double* outputWeights, double* outputMomentum) {
for (int i = 0; i < len; i++) {
outputMomentum[i] = momentum * last[i] - rate * gradient[i];
outputWeights[i] = weights[i] + outputMomentum[i] - (rate * regulariser) * weights[i];
}
}
|
Add devtools trace events for Timeline EmbedderCallback notification | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_COMMON_DEVTOOLS_INSTRUMENTATION_H_
#define ANDROID_WEBVIEW_COMMON_DEVTOOLS_INSTRUMENTATION_H_
#include "base/debug/trace_event.h"
namespace android_webview {
namespace devtools_instrumentation {
namespace internal {
const char kCategory[] = "Java,devtools";
const char kEmbedderCallback[] = "EmbedderCallback";
const char kCallbackNameArgument[] = "callbackName";
} // namespace internal
class ScopedEmbedderCallbackTask {
public:
ScopedEmbedderCallbackTask(const char* callback_name) {
TRACE_EVENT_BEGIN1(internal::kCategory,
internal::kEmbedderCallback,
internal::kCallbackNameArgument,
callback_name);
}
~ScopedEmbedderCallbackTask() {
TRACE_EVENT_END0(internal::kCategory,
internal::kEmbedderCallback);
}
private:
DISALLOW_COPY_AND_ASSIGN(ScopedEmbedderCallbackTask);
};
} // namespace devtools_instrumentation
} // namespace android_webview
#endif // ANDROID_WEBVIEW_COMMON_DEVTOOLS_INSTRUMENTATION_H_
| // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_COMMON_DEVTOOLS_INSTRUMENTATION_H_
#define ANDROID_WEBVIEW_COMMON_DEVTOOLS_INSTRUMENTATION_H_
#include "base/debug/trace_event.h"
namespace android_webview {
namespace devtools_instrumentation {
namespace internal {
const char kCategory[] = "Java,devtools,disabled-by-default-devtools.timeline";
const char kEmbedderCallback[] = "EmbedderCallback";
const char kCallbackNameArgument[] = "callbackName";
} // namespace internal
class ScopedEmbedderCallbackTask {
public:
ScopedEmbedderCallbackTask(const char* callback_name) {
TRACE_EVENT_BEGIN1(internal::kCategory,
internal::kEmbedderCallback,
internal::kCallbackNameArgument,
callback_name);
}
~ScopedEmbedderCallbackTask() {
TRACE_EVENT_END0(internal::kCategory,
internal::kEmbedderCallback);
}
private:
DISALLOW_COPY_AND_ASSIGN(ScopedEmbedderCallbackTask);
};
} // namespace devtools_instrumentation
} // namespace android_webview
#endif // ANDROID_WEBVIEW_COMMON_DEVTOOLS_INSTRUMENTATION_H_
|
Increment version number, since the new AHRS would break setting loading | #ifndef QGC_CONFIGURATION_H
#define QGC_CONFIGURATION_H
#include <QString>
/** @brief Polling interval in ms */
#define SERIAL_POLL_INTERVAL 9
/** @brief Heartbeat emission rate, in Hertz (times per second) */
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 1.0.9 (beta)"
namespace QGC
{
const QString APPNAME = "QGROUNDCONTROL";
const QString COMPANYNAME = "QGROUNDCONTROL";
const int APPLICATIONVERSION = 109; // 1.0.9
}
#endif // QGC_CONFIGURATION_H
| #ifndef QGC_CONFIGURATION_H
#define QGC_CONFIGURATION_H
#include <QString>
/** @brief Polling interval in ms */
#define SERIAL_POLL_INTERVAL 9
/** @brief Heartbeat emission rate, in Hertz (times per second) */
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 1.0.10 (beta)"
namespace QGC
{
const QString APPNAME = "QGROUNDCONTROL";
const QString COMPANYNAME = "QGROUNDCONTROL";
const int APPLICATIONVERSION = 109; // 1.0.9
}
#endif // QGC_CONFIGURATION_H
|
Fix clash in cpp tokens | #ifndef EXPR_TOK_H
#define EXPR_TOK_H
extern expr_n tok_cur_num;
extern enum tok
{
tok_ident = -1,
tok_num = -2,
tok_eof = 0,
tok_lparen = '(',
tok_rparen = ')',
/* operators returned as char-value,
* except for double-char ops
*/
/* binary */
tok_multiply = '*',
tok_divide = '/',
tok_modulus = '%',
tok_plus = '+',
tok_minus = '-',
tok_xor = '^',
tok_or = '|',
tok_and = '&',
tok_orsc = -1,
tok_andsc = -2,
tok_shiftl = -3,
tok_shiftr = -4,
/* unary - TODO */
tok_not = '!',
tok_bnot = '~',
/* comparison */
tok_eq = -5,
tok_ne = -6,
tok_le = -7,
tok_lt = '<',
tok_ge = -8,
tok_gt = '>',
/* ternary */
tok_question = '?',
tok_colon = ':',
#define MIN_OP -8
} tok_cur;
void tok_next(void);
void tok_begin(char *);
const char *tok_last(void);
#endif
| #ifndef EXPR_TOK_H
#define EXPR_TOK_H
extern expr_n tok_cur_num;
extern enum tok
{
tok_ident = -1,
tok_num = -2,
tok_eof = 0,
tok_lparen = '(',
tok_rparen = ')',
/* operators returned as char-value,
* except for double-char ops
*/
/* binary */
tok_multiply = '*',
tok_divide = '/',
tok_modulus = '%',
tok_plus = '+',
tok_minus = '-',
tok_xor = '^',
tok_or = '|',
tok_and = '&',
tok_orsc = -3,
tok_andsc = -4,
tok_shiftl = -5,
tok_shiftr = -6,
/* unary - TODO */
tok_not = '!',
tok_bnot = '~',
/* comparison */
tok_eq = -7,
tok_ne = -8,
tok_le = -9,
tok_lt = '<',
tok_ge = -10,
tok_gt = '>',
/* ternary */
tok_question = '?',
tok_colon = ':',
#define MIN_OP -10
} tok_cur;
void tok_next(void);
void tok_begin(char *);
const char *tok_last(void);
#endif
|
Fix wrong MIDR_EL1 value for Neoverse E1 | /*
* Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef NEOVERSE_E1_H
#define NEOVERSE_E1_H
#include <lib/utils_def.h>
#define NEOVERSE_E1_MIDR U(0x410FD060)
/*******************************************************************************
* CPU Extended Control register specific definitions.
******************************************************************************/
#define NEOVERSE_E1_ECTLR_EL1 S3_0_C15_C1_4
/*******************************************************************************
* CPU Auxiliary Control register specific definitions.
******************************************************************************/
#define NEOVERSE_E1_CPUACTLR_EL1 S3_0_C15_C1_0
/*******************************************************************************
* CPU Power Control register specific definitions.
******************************************************************************/
#define NEOVERSE_E1_CPUPWRCTLR_EL1 S3_0_C15_C2_7
#define NEOVERSE_E1_CPUPWRCTLR_EL1_CORE_PWRDN_BIT (U(1) << 0)
#endif /* NEOVERSE_E1_H */
| /*
* Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef NEOVERSE_E1_H
#define NEOVERSE_E1_H
#include <lib/utils_def.h>
#define NEOVERSE_E1_MIDR U(0x410FD4A0)
/*******************************************************************************
* CPU Extended Control register specific definitions.
******************************************************************************/
#define NEOVERSE_E1_ECTLR_EL1 S3_0_C15_C1_4
/*******************************************************************************
* CPU Auxiliary Control register specific definitions.
******************************************************************************/
#define NEOVERSE_E1_CPUACTLR_EL1 S3_0_C15_C1_0
/*******************************************************************************
* CPU Power Control register specific definitions.
******************************************************************************/
#define NEOVERSE_E1_CPUPWRCTLR_EL1 S3_0_C15_C2_7
#define NEOVERSE_E1_CPUPWRCTLR_EL1_CORE_PWRDN_BIT (U(1) << 0)
#endif /* NEOVERSE_E1_H */
|
Fix a wrong filename mentioned in a comment | //===-- interception_linux.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
// Linux-specific interception methods.
//===----------------------------------------------------------------------===//
#ifdef __linux__
#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
# error "interception_mac.h should be included from interception library only"
#endif
#ifndef INTERCEPTION_LINUX_H
#define INTERCEPTION_LINUX_H
namespace __interception {
// returns true if a function with the given name was found.
bool GetRealFunctionAddress(const char *func_name, void **func_addr);
} // namespace __interception
#define INTERCEPT_FUNCTION_LINUX(func) \
::__interception::GetRealFunctionAddress(#func, (void**)&REAL(func))
#endif // INTERCEPTION_LINUX_H
#endif // __linux__
| //===-- interception_linux.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
// Linux-specific interception methods.
//===----------------------------------------------------------------------===//
#ifdef __linux__
#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
# error "interception_linux.h should be included from interception library only"
#endif
#ifndef INTERCEPTION_LINUX_H
#define INTERCEPTION_LINUX_H
namespace __interception {
// returns true if a function with the given name was found.
bool GetRealFunctionAddress(const char *func_name, void **func_addr);
} // namespace __interception
#define INTERCEPT_FUNCTION_LINUX(func) \
::__interception::GetRealFunctionAddress(#func, (void**)&REAL(func))
#endif // INTERCEPTION_LINUX_H
#endif // __linux__
|
Add unit test for big clipboard device message | #include <assert.h>
#include <string.h>
#include "device_msg.h"
#include <stdio.h>
static void test_deserialize_clipboard(void) {
const unsigned char input[] = {
DEVICE_MSG_TYPE_CLIPBOARD,
0x00, 0x03, // text length
0x41, 0x42, 0x43, // "ABC"
};
struct device_msg msg;
ssize_t r = device_msg_deserialize(input, sizeof(input), &msg);
assert(r == 6);
assert(msg.type == DEVICE_MSG_TYPE_CLIPBOARD);
assert(msg.clipboard.text);
assert(!strcmp("ABC", msg.clipboard.text));
device_msg_destroy(&msg);
}
int main(void) {
test_deserialize_clipboard();
return 0;
}
| #include <assert.h>
#include <string.h>
#include "device_msg.h"
#include <stdio.h>
static void test_deserialize_clipboard(void) {
const unsigned char input[] = {
DEVICE_MSG_TYPE_CLIPBOARD,
0x00, 0x03, // text length
0x41, 0x42, 0x43, // "ABC"
};
struct device_msg msg;
ssize_t r = device_msg_deserialize(input, sizeof(input), &msg);
assert(r == 6);
assert(msg.type == DEVICE_MSG_TYPE_CLIPBOARD);
assert(msg.clipboard.text);
assert(!strcmp("ABC", msg.clipboard.text));
device_msg_destroy(&msg);
}
static void test_deserialize_clipboard_big(void) {
unsigned char input[DEVICE_MSG_SERIALIZED_MAX_SIZE];
input[0] = DEVICE_MSG_TYPE_CLIPBOARD;
input[1] = DEVICE_MSG_TEXT_MAX_LENGTH >> 8; // MSB
input[2] = DEVICE_MSG_TEXT_MAX_LENGTH & 0xff; // LSB
memset(input + 3, 'a', DEVICE_MSG_TEXT_MAX_LENGTH);
struct device_msg msg;
ssize_t r = device_msg_deserialize(input, sizeof(input), &msg);
assert(r == DEVICE_MSG_SERIALIZED_MAX_SIZE);
assert(msg.type == DEVICE_MSG_TYPE_CLIPBOARD);
assert(msg.clipboard.text);
assert(strlen(msg.clipboard.text) == DEVICE_MSG_TEXT_MAX_LENGTH);
assert(msg.clipboard.text[0] == 'a');
device_msg_destroy(&msg);
}
int main(void) {
test_deserialize_clipboard();
test_deserialize_clipboard_big();
return 0;
}
|
Clean skel for guest tuple iterator tests | #ifndef TEST_GUEST_TUPLE_ITERATOR_H
#define TEST_GUEST_TUPLE_ITERATOR_H
#include <cxxtest/TestSuite.h>
#include <unordered_set>
#include <vector>
#include "teams.h"
#include "guest_tuple_iterator.h"
class TestSeenTable : public CxxTest::TestSuite
{
private:
std::vector<mue::Team> make_testteams(int num)
{
std::vector<mue::Team> teams;
for (mue::Team_id i = 0; i < num; ++i)
teams.push_back(mue::Team(i));
return teams;
}
public:
void testFooBar(void)
{
}
};
#endif
| #ifndef TEST_GUEST_TUPLE_ITERATOR_H
#define TEST_GUEST_TUPLE_ITERATOR_H
#include <cxxtest/TestSuite.h>
#include <unordered_set>
#include <vector>
#include "teams.h"
#include "guest_tuple_iterator.h"
class TestSeenTable : public CxxTest::TestSuite
{
public:
void testFooBar(void)
{
}
};
#endif
|
Fix include from last checkin. | #ifdef sgi
#include <sys/fpu.h>
/*
THE FOLLOWING FUNCTION
sets the special "flush zero" but (FS, bit 24) in the
Control Status Register of the FPU of R4k and beyond
so that the result of any underflowing operation will
be clamped to zero, and no exception of any kind will
be generated on the CPU. This has no effect on
an R3000.
*/
void flush_all_underflows_to_zero()
{
union fpc_csr f;
f.fc_word = get_fpc_csr();
f.fc_struct.flush = 1;
set_fpc_csr(f.fc_word);
}
#endif
#ifdef LINUX
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void sigfpe_handler(int sig)
{
fprintf(stderr,
"\nRTcmix FATAL ERROR: floating point exception halted process.\n");
exit(1);
}
#endif
| #ifdef sgi
#include <sys/fpu.h>
/*
THE FOLLOWING FUNCTION
sets the special "flush zero" but (FS, bit 24) in the
Control Status Register of the FPU of R4k and beyond
so that the result of any underflowing operation will
be clamped to zero, and no exception of any kind will
be generated on the CPU. This has no effect on
an R3000.
*/
void flush_all_underflows_to_zero()
{
union fpc_csr f;
f.fc_word = get_fpc_csr();
f.fc_struct.flush = 1;
set_fpc_csr(f.fc_word);
}
#endif
#ifdef LINUX
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
void sigfpe_handler(int sig)
{
fprintf(stderr,
"\nRTcmix FATAL ERROR: floating point exception halted process.\n");
exit(1);
}
#endif
|
Add test for non macro alike functions with paranthesis | /*
name: TEST061
description: Test for macros without arguments but with parenthesis
error:
output:
G3 I F "main
{
\
h #I1
}
*/
#define X (2)
#define L (0)
#define H (1)
#define Q(x) x
int
main(void)
{
return X == L + H + Q(1);
}
| |
Determine initial properties and functions | //
// JTFadingInfoViewController.h
// JTFadingInfoViewController
//
// Created by DCL_JT on 2015/07/29.
// Copyright (c) 2015年 Junichi Tsurukawa. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface JTFadingInfoViewController : UIViewController
@end
| //
// JTFadingInfoViewController.h
// JTFadingInfoViewController
//
// Created by DCL_JT on 2015/07/29.
// Copyright (c) 2015年 Junichi Tsurukawa. All rights reserved.
//
#import <UIKit/UIKit.h>
#pragma mark - Fade in/out options
typedef enum {
FadeInFromAbove = 1,
FadeInFromBelow,
FadeInFromLeft,
FadeInFromRight
} FadeInType;
typedef enum {
FadeOutToAbove = 1,
FadeOutToBelow,
FadeOutToLeft,
FadeOutToRight
} FadeOutType;
@interface JTFadingInfoViewController : UIViewController
#pragma mark - Functions
/*
* Add subView with Selected Type of Fading in.
*
* @param view A view to be added.
* @param fadeType A Type of Fading when appering.
*
*/
- (void)addSubView:(UIView *)view WithFade:(FadeInType)fadeType;
/*
* Remove subView from SuperView with Selected Type of Fading out.
*
* @param fadeType A Type of Fading when disappering.
*
*/
- (void)removeFromSuperViewWithFade: (FadeInType)fadeType;
/*
* ~SOME DESCRIPTION GOES HERE~
*
* @param fadeInType A Type of Fading when appering.
*
* @param duration Time for displaying the view.
*
* @param fadeOutType A Type of Fading when disappering.
*/
- (void)showSubView: (UIView *)view withAppearType: (FadeInType)fadeInType
showDuration: (float)duration
withDisapperType: (FadeOutType)fadeOutType;
#pragma mark - Properties
#pragma Shadow
/** A Boolean value for whether the shadow effect is enabled or not. */
@property BOOL isShadowEnabled;
#pragma Animatoins
/** A float represeting the time for displaying this view itself. If 0, view will not disapper */
@property float displayDuration;
/** A float representing the time the view is appeared by. */
@property float appearingDuration;
/** A float representing the time the view is disappeared by. */
@property float disappearingDuration;
@end
|
Use offsetof() to compute the memory block header size. | /*
* pmpa_internals.h
* Part of pmpa
* Copyright (c) 2014 Philip Wernersbach
*
* Dual-Licensed under the Public Domain and the Unlicense.
* Choose the one that you prefer.
*/
#ifndef HAVE_PMPA_INTERNALS_H
#include <stdbool.h>
#include <pmpa.h>
typedef struct {
pmpa_memory_int size;
bool allocated;
char data;
} pmpa_memory_block;
#define PMPA_MEMORY_BLOCK_HEADER_SIZE ( sizeof(pmpa_memory_int) + sizeof(bool) )
#ifdef PMPA_UNIT_TEST
#define PMPA_STATIC_UNLESS_TESTING
extern PMPA_STATIC_UNLESS_TESTING __thread pmpa_memory_block *master_memory_block;
extern PMPA_STATIC_UNLESS_TESTING __thread pmpa_memory_int master_memory_block_size;
#else
#define PMPA_STATIC_UNLESS_TESTING static
#endif
#define HAVE_PMPA_INTERNALS_H
#endif | /*
* pmpa_internals.h
* Part of pmpa
* Copyright (c) 2014 Philip Wernersbach
*
* Dual-Licensed under the Public Domain and the Unlicense.
* Choose the one that you prefer.
*/
#ifndef HAVE_PMPA_INTERNALS_H
#include <stddef.h>
#include <stdbool.h>
#include <pmpa.h>
typedef struct {
pmpa_memory_int size;
bool allocated;
char data;
} pmpa_memory_block;
#define PMPA_MEMORY_BLOCK_HEADER_SIZE ( offsetof(pmpa_memory_block, data) )
#ifdef PMPA_UNIT_TEST
#define PMPA_STATIC_UNLESS_TESTING
extern PMPA_STATIC_UNLESS_TESTING __thread pmpa_memory_block *master_memory_block;
extern PMPA_STATIC_UNLESS_TESTING __thread pmpa_memory_int master_memory_block_size;
#else
#define PMPA_STATIC_UNLESS_TESTING static
#endif
#define HAVE_PMPA_INTERNALS_H
#endif |
Add header for Bmp custom type | #ifndef RCR_LEVEL1PAYLOAD_BMP180_H_
#define RCR_LEVEL1PAYLOAD_BMP180_H_
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
namespace rcr {
namespace level1payload {
} // namespace level1_payload
} // namespace rcr
#endif // RCR_LEVEL1PAYLOAD_BMP180_H_
| |
Add the missing nullability annotation | //
// MagicalImportFunctions.h
// Magical Record
//
// Created by Saul Mora on 3/7/12.
// Copyright (c) 2012 Magical Panda Software LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <MagicalRecord/MagicalRecordXcode7CompatibilityMacros.h>
NSDateFormatter * __MR_nonnull MR_dateFormatterWithFormat(NSString *format);
NSDate * __MR_nonnull MR_adjustDateForDST(NSDate *__MR_nonnull date);
NSDate * __MR_nonnull MR_dateFromString(NSString *__MR_nonnull value, NSString *__MR_nonnull format);
NSDate * __MR_nonnull MR_dateFromNumber(NSNumber *__MR_nonnull value, BOOL milliseconds);
NSNumber * __MR_nonnull MR_numberFromString(NSString *__MR_nonnull value);
NSString * __MR_nonnull MR_attributeNameFromString(NSString *__MR_nonnull value);
NSString * __MR_nonnull MR_primaryKeyNameFromString(NSString *__MR_nonnull value);
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
UIColor * __MR_nullable MR_colorFromString(NSString *__MR_nonnull serializedColor);
#else
#import <AppKit/AppKit.h>
NSColor * __MR_nullable MR_colorFromString(NSString *__MR_nonnull serializedColor);
#endif
NSInteger * __MR_nullable MR_newColorComponentsFromString(NSString *__MR_nonnull serializedColor);
| //
// MagicalImportFunctions.h
// Magical Record
//
// Created by Saul Mora on 3/7/12.
// Copyright (c) 2012 Magical Panda Software LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <MagicalRecord/MagicalRecordXcode7CompatibilityMacros.h>
NSDateFormatter * __MR_nonnull MR_dateFormatterWithFormat(NSString *__MR_nonnull format);
NSDate * __MR_nonnull MR_adjustDateForDST(NSDate *__MR_nonnull date);
NSDate * __MR_nonnull MR_dateFromString(NSString *__MR_nonnull value, NSString *__MR_nonnull format);
NSDate * __MR_nonnull MR_dateFromNumber(NSNumber *__MR_nonnull value, BOOL milliseconds);
NSNumber * __MR_nonnull MR_numberFromString(NSString *__MR_nonnull value);
NSString * __MR_nonnull MR_attributeNameFromString(NSString *__MR_nonnull value);
NSString * __MR_nonnull MR_primaryKeyNameFromString(NSString *__MR_nonnull value);
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
UIColor * __MR_nullable MR_colorFromString(NSString *__MR_nonnull serializedColor);
#else
#import <AppKit/AppKit.h>
NSColor * __MR_nullable MR_colorFromString(NSString *__MR_nonnull serializedColor);
#endif
NSInteger * __MR_nullable MR_newColorComponentsFromString(NSString *__MR_nonnull serializedColor);
|
Speed up default blink to disambiguate from default program on Sparkfun board. | #include <stdio.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include "esp_wifi.h"
#include "esp_system.h"
void app_main(void)
{
gpio_set_direction(GPIO_NUM_5, GPIO_MODE_OUTPUT);
int level = 0;
while (true) {
printf("Hello, world.\n");
gpio_set_level(GPIO_NUM_5, level);
level = !level;
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
| #include <stdio.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include "esp_wifi.h"
#include "esp_system.h"
void app_main(void)
{
gpio_set_direction(GPIO_NUM_5, GPIO_MODE_OUTPUT);
int level = 0;
while (true) {
printf("Hello, world.\n");
gpio_set_level(GPIO_NUM_5, level);
level = !level;
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
|
Check that @ arguments that aren't files are handled | // Make sure that arguments that begin with @ are left as is in the argument
// stream, and also that @file arguments continue to be processed.
// RUN: echo "%s -D FOO" > %t.args
// RUN: %clang -rpath @executable_path/../lib @%t.args -### 2>&1 | FileCheck %s
// CHECK: "-D" "FOO"
// CHECK: "-rpath" "@executable_path/../lib"
| |
Add tests for land, takeoff, position control funs | #pragma once
#include <aerial_autonomy/actions_guards/base_functors.h>
#include <aerial_autonomy/logic_states/base_state.h>
#include <aerial_autonomy/robot_systems/uav_system.h>
#include <aerial_autonomy/basic_events.h>
#include <aerial_autonomy/types/completed_event.h>
#include <parsernode/common.h>
using namespace basic_events;
template <class LogicStateMachineT>
struct LandTransitionActionFunctor_
: ActionFunctor<Land, UAVSystem, LogicStateMachineT> {
void run(const Land &, UAVSystem &robot_system, LogicStateMachineT &) {
robot_system.land();
}
};
// TODO (Gowtham) How to abort Land??
template <class LogicStateMachineT>
struct LandInternalActionFunctor_
: InternalActionFunctor<UAVSystem, LogicStateMachineT> {
void run(const InternalTransitionEvent &, UAVSystem &robot_system,
LogicStateMachineT &logic_state_machine) {
parsernode::common::quaddata data = robot_system.getUAVData();
// Can also use uav status here TODO (Gowtham)
if (data.altitude < 0.1) {
logic_state_machine.process_event(Completed());
}
}
};
template <class LogicStateMachineT>
using Landing_ = BaseState<UAVSystem, LogicStateMachineT,
LandInternalActionFunctor_<LogicStateMachineT>>;
| #pragma once
#include <aerial_autonomy/actions_guards/base_functors.h>
#include <aerial_autonomy/logic_states/base_state.h>
#include <aerial_autonomy/robot_systems/uav_system.h>
#include <aerial_autonomy/basic_events.h>
#include <aerial_autonomy/types/completed_event.h>
#include <parsernode/common.h>
using namespace basic_events;
template <class LogicStateMachineT>
struct LandTransitionActionFunctor_
: ActionFunctor<Land, UAVSystem, LogicStateMachineT> {
void run(const Land &, UAVSystem &robot_system, LogicStateMachineT &) {
robot_system.land();
}
};
// TODO (Gowtham) How to abort Land??
template <class LogicStateMachineT>
struct LandInternalActionFunctor_
: InternalActionFunctor<UAVSystem, LogicStateMachineT> {
void run(const InternalTransitionEvent &, UAVSystem &robot_system,
LogicStateMachineT &logic_state_machine) {
parsernode::common::quaddata data = robot_system.getUAVData();
std::cout << data.altitude << std::endl;
// Can also use uav status here TODO (Gowtham)
if (data.altitude < 0.1) {
logic_state_machine.process_event(Completed());
}
}
};
template <class LogicStateMachineT>
using Landing_ = BaseState<UAVSystem, LogicStateMachineT,
LandInternalActionFunctor_<LogicStateMachineT>>;
|
Correct error on previous commit. | /**
* Copyright 2017 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
void *aker_malloc(size_t size)
{
return aker_malloc(size);
}
void aker_free (void *ptr)
{
aker_free(ptr);
}
| /**
* Copyright 2017 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
void *aker_malloc(size_t size)
{
return malloc(size);
}
void aker_free (void *ptr)
{
free(ptr);
}
|
Add an example for simple loops | // PARAM: --enable dbg.debug --enable ana.int.interval
int main() {
int t1 = 0, t2 = 0;
int i;
for (i = 0; i < 5; i++) {
t1++;
t2--;
}
assert(t1 == i); //SUCCESS!
t1 = 5;
t2 = 5;
for (i = 5; i > 0; i--) {
t1++;
t2--;
}
assert(t2 == i); //SUCCESS!
t1 = 0;
t2 = 0;
for (i = 0; i < 5; i--) {
t1++;
t2--;
}
assert(t1 == i); //FAIL!
return 0;
} | |
Copy dragImageView from bibdesk to skim | //
// BDSKDragImageView.h
// Bibdesk
//
// Created by Christiaan Hofman on 28/11/05.
/*
This software is Copyright (c) 2005,2006,2007
Christiaan Hofman. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
- Neither the name of Christiaan Hofman nor the names of any
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.
*/
#import <Cocoa/Cocoa.h>
@interface BDSKDragImageView : NSImageView {
id delegate;
BOOL highlight;
}
- (id)delegate;
- (void)setDelegate:(id)newDelegate;
@end
@interface NSObject (BDSKDragImageViewDelegate)
- (NSDragOperation)dragImageView:(BDSKDragImageView *)view validateDrop:(id <NSDraggingInfo>)sender;
- (BOOL)dragImageView:(BDSKDragImageView *)view acceptDrop:(id <NSDraggingInfo>)sender;
- (BOOL)dragImageView:(BDSKDragImageView *)view writeDataToPasteboard:(NSPasteboard *)pasteboard;
- (NSArray *)dragImageView:(BDSKDragImageView *)view namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination;
- (NSImage *)dragImageForDragImageView:(BDSKDragImageView *)view;
@end
| |
Add problematic example, bot in invariant | int main ()
{
int tmp;
int p_9 = 60;
tmp = (p_9 +1) % 0;
if ((p_9 +1) % 0) {
tmp = 1;
}
return (0);
}
| |
Use clock_gettime if have (linux/bsd but not apple) | /**
* Copyright (c) 2015, Chao Wang <hit9@icloud.com>
*/
#include <time.h>
#include <sys/time.h>
/* Get timestamp (in milliseconds) for now. */
double
datetime_stamp_now(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (1000000 * tv.tv_sec + tv.tv_usec) / 1000.0;
}
| /**
* Copyright (c) 2015, Chao Wang <hit9@icloud.com>
*/
#include <assert.h>
#include <time.h>
#include <sys/time.h>
/* Get timestamp (in milliseconds) for now. */
double
datetime_stamp_now(void)
{
#if defined CLOCK_REALTIME
struct timespec ts;
int rc = clock_gettime(CLOCK_REALTIME, &ts);
assert(rc == 0);
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000.0;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return (1000000 * tv.tv_sec + tv.tv_usec) / 1000.0;
#endif
}
|
Add newline at end of file | // 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.
// Common IPC messages used for child processes.
// Multiply-included message file, hence no include guard.
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START ChildProcessMsgStart
// Messages sent from the browser to the child process.
// Tells the child process it should stop.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_AskBeforeShutdown)
// Sent in response to ChildProcessHostMsg_ShutdownRequest to tell the child
// process that it's safe to shutdown.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_Shutdown)
#if defined(IPC_MESSAGE_LOG_ENABLED)
// Tell the child process to begin or end IPC message logging.
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled,
bool /* on or off */)
#endif
// Messages sent from the child process to the browser.
IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest)
// Get the list of proxies to use for |url|, as a semicolon delimited list
// of "<TYPE> <HOST>:<PORT>" | "DIRECT".
IPC_SYNC_MESSAGE_CONTROL1_2(ChildProcessHostMsg_ResolveProxy,
GURL /* url */,
int /* network error */,
std::string /* proxy list */) | // 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.
// Common IPC messages used for child processes.
// Multiply-included message file, hence no include guard.
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START ChildProcessMsgStart
// Messages sent from the browser to the child process.
// Tells the child process it should stop.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_AskBeforeShutdown)
// Sent in response to ChildProcessHostMsg_ShutdownRequest to tell the child
// process that it's safe to shutdown.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_Shutdown)
#if defined(IPC_MESSAGE_LOG_ENABLED)
// Tell the child process to begin or end IPC message logging.
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled,
bool /* on or off */)
#endif
// Messages sent from the child process to the browser.
IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest)
// Get the list of proxies to use for |url|, as a semicolon delimited list
// of "<TYPE> <HOST>:<PORT>" | "DIRECT".
IPC_SYNC_MESSAGE_CONTROL1_2(ChildProcessHostMsg_ResolveProxy,
GURL /* url */,
int /* network error */,
std::string /* proxy list */)
|
Add bulk sync daemon back again | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2013 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/>.
*/
object queue;
static void create()
{
}
| |
Add documentation that Xcode can find | //
// MMMarkdown.h
// MMMarkdown
//
// Copyright (c) 2012 Matt Diephouse.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <Foundation/Foundation.h>
@interface MMMarkdown : NSObject
+ (NSString *)HTMLStringWithMarkdown:(NSString *)string error:(__autoreleasing NSError **)error __attribute__((nonnull(1)));
@end
| //
// MMMarkdown.h
// MMMarkdown
//
// Copyright (c) 2012 Matt Diephouse.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <Foundation/Foundation.h>
@interface MMMarkdown : NSObject
/*! Converts a Markdown string to HTML.
*
* @param string A Markdown string. Must not be nil.
* @param error Out parameter used if an error occurs while parsing the Markdown. May be NULL.
* @return An HTML string.
*/
+ (NSString *)HTMLStringWithMarkdown:(NSString *)string error:(__autoreleasing NSError **)error __attribute__((nonnull(1)));
@end
|
Rename the custom assert name to reflect the underlying method | #import <Foundation/Foundation.h>
/**
Custom asserts that provide better error messages when the assert fails.
*/
/**
Assert that @p array contains @p object
*/
#define TDTXCTAssertContains(array, object) \
XCTAssertTrue([(array) containsObject:(object)], @"Expected %@ to contain %@", (array), (object))
/**
Assert that @p string contains @p substring
*/
#define TDTXCTAssertContainsString(string, substring) \
XCTAssertTrue([(string) tdt_containsString:(substring)], @"Expected %@ to contain %@", (string), (substring))
/**
Assert that @p a is <= @p b.
*/
#define TDTXCTAssertEarlierEqualDate(a, b) \
XCTAssertTrue([(a) tdt_isEarlierThanOrEqualToDate:(b)], @"Expected %@ to be earlier than or same as %@", (a), (b))
| #import <Foundation/Foundation.h>
/**
Custom asserts that provide better error messages when the assert fails.
*/
/**
Assert that @p array contains @p object
*/
#define TDTXCTAssertContains(array, object) \
XCTAssertTrue([(array) containsObject:(object)], @"Expected %@ to contain %@", (array), (object))
/**
Assert that @p string contains @p substring
*/
#define TDTXCTAssertContainsString(string, substring) \
XCTAssertTrue([(string) tdt_containsString:(substring)], @"Expected %@ to contain %@", (string), (substring))
/**
Assert that @p a is <= @p b.
*/
#define TDTXCTAssertEarlierThanOrEqualToDate(a, b) \
XCTAssertTrue([(a) tdt_isEarlierThanOrEqualToDate:(b)], @"Expected %@ to be earlier than or equal to %@", (a), (b))
|
Use spaces instead of tabs | #include <pal.h>
/**
*
* Element wise inversion (reciprocal) of elements in 'a'.
*
* @param a Pointer to input vector
*
* @param c Pointer to output vector
*
* @param n Size of 'a' and 'c' vector.
*
* @param p Number of processor to use (task parallelism)
*
* @param team Team to work with
*
* @return None
*
*/
#include <math.h>
void p_inv_f32(const float *a, float *c, int n, int p, p_team_t team)
{
int i;
float cur;
for (i = 0; i < n; i++) {
cur = *(a + i);
union {
float f;
uint32_t x;
} u = {cur};
/* First approximation */
u.x = 0x7EF312AC - u.x;
/* Refine */
u.f = u.f * (2 - u.f * cur);
u.f = u.f * (2 - u.f * cur);
*(c + i) = u.f;
}
}
| #include <pal.h>
/**
*
* Element wise inversion (reciprocal) of elements in 'a'.
*
* @param a Pointer to input vector
*
* @param c Pointer to output vector
*
* @param n Size of 'a' and 'c' vector.
*
* @param p Number of processor to use (task parallelism)
*
* @param team Team to work with
*
* @return None
*
*/
#include <math.h>
void p_inv_f32(const float *a, float *c, int n, int p, p_team_t team)
{
int i;
float cur;
for (i = 0; i < n; i++) {
cur = *(a + i);
union {
float f;
uint32_t x;
} u = {cur};
/* First approximation */
u.x = 0x7EF312AC - u.x;
/* Refine */
u.f = u.f * (2 - u.f * cur);
u.f = u.f * (2 - u.f * cur);
*(c + i) = u.f;
}
}
|
Add header file for public interface | #ifndef ORVIBO_H
#define ORVIBO_H
#include <net/ethernet.h>
#include <stdbool.h>
enum orvibo_event {
ORVIBO_EVENT_DISCOVER,
ORVIBO_EVENT_SUBSCRIBE,
ORVIBO_EVENT_UNSUBSCRIBE,
ORVIBO_EVENT_OFF,
ORVIBO_EVENT_ON
};
enum orvibo_state {
ORVIBO_STATE_UNKNOWN,
ORVIBO_STATE_OFF,
ORVIBO_STATE_ON
};
struct orvibo_socket;
typedef void (*ORVIBO_EVENT_HANDLER) (struct orvibo_socket *, enum orvibo_event);
bool
orvibo_start(ORVIBO_EVENT_HANDLER handler);
bool
orvibo_stop(void);
struct orvibo_socket *
orvibo_socket_create(const unsigned char mac[static ETHER_ADDR_LEN]);
void
orvibo_socket_destroy(struct orvibo_socket *socket);
const unsigned char *
orvibo_socket_mac(const struct orvibo_socket *socket);
const char *
orvibo_socket_ip(const struct orvibo_socket *socket);
bool
orvibo_socket_subscribed(const struct orvibo_socket *socket);
enum orvibo_state
orvibo_socket_state(const struct orvibo_socket *socket);
bool
orvibo_socket_discover(struct orvibo_socket *socket);
bool
orvibo_socket_subscribe(struct orvibo_socket *socket);
bool
orvibo_socket_unsubscribe(struct orvibo_socket *socket);
bool
orvibo_socket_off(struct orvibo_socket *socket);
bool
orvibo_socket_on(struct orvibo_socket *socket);
#endif
| |
Add license header to private file manager header | #import "SPTPersistentCacheFileManager.h"
#import <SPTPersistentCache/SPTPersistentCacheOptions.h>
NS_ASSUME_NONNULL_BEGIN
/// Private interface exposed for testability.
@interface SPTPersistentCacheFileManager ()
@property (nonatomic, copy, readonly) SPTPersistentCacheOptions *options;
@property (nonatomic, copy, readonly, nullable) SPTPersistentCacheDebugCallback debugOutput;
@property (nonatomic, strong, readonly) NSFileManager *fileManager;
@end
NS_ASSUME_NONNULL_END
| /*
* Copyright (c) 2016 Spotify AB.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#import "SPTPersistentCacheFileManager.h"
#import <SPTPersistentCache/SPTPersistentCacheOptions.h>
NS_ASSUME_NONNULL_BEGIN
/// Private interface exposed for testability.
@interface SPTPersistentCacheFileManager ()
@property (nonatomic, copy, readonly) SPTPersistentCacheOptions *options;
@property (nonatomic, copy, readonly, nullable) SPTPersistentCacheDebugCallback debugOutput;
@property (nonatomic, strong, readonly) NSFileManager *fileManager;
@end
NS_ASSUME_NONNULL_END
|
Add missing test case from D41171 commit | // RUN: %libomp-compile-and-run | FileCheck %s
// REQUIRES: ompt
#include "callback.h"
#include <omp.h>
int main()
{
#pragma omp parallel num_threads(1)
{
}
ompt_set_callback(ompt_callback_parallel_begin, NULL);
#pragma omp parallel num_threads(1)
{
}
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_idle'
// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_parallel_begin:
// CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_end:
// CHECK-NOT: {{^}}[[THREAD_ID]]: ompt_event_parallel_begin:
// CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_end:
return 0;
}
| |
Use DataTypes.h instead of stdint.h. | //===- llvm/System/Atomic.h - Atomic Operations -----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the llvm::sys atomic operations.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SYSTEM_ATOMIC_H
#define LLVM_SYSTEM_ATOMIC_H
#include <stdint.h>
namespace llvm {
namespace sys {
void MemoryFence();
typedef uint32_t cas_flag;
cas_flag CompareAndSwap(volatile cas_flag* ptr,
cas_flag new_value,
cas_flag old_value);
}
}
#endif
| //===- llvm/System/Atomic.h - Atomic Operations -----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the llvm::sys atomic operations.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SYSTEM_ATOMIC_H
#define LLVM_SYSTEM_ATOMIC_H
#include "llvm/Support/DataTypes.h"
namespace llvm {
namespace sys {
void MemoryFence();
typedef uint32_t cas_flag;
cas_flag CompareAndSwap(volatile cas_flag* ptr,
cas_flag new_value,
cas_flag old_value);
}
}
#endif
|
Transform the fortran result of this executable to free form. | /* Auxiliary program: write the include file for determining
PLplot's floating-point type
*/
#include <stdio.h>
#include <stdlib.h>
#include "plConfig.h"
main(int argc, char *argv[] )
{
FILE *outfile;
char *kind;
outfile = fopen( "plflt.inc", "w" ) ;
#ifdef PL_DOUBLE
kind = "1.0d0";
#else
kind = "1.0";
#endif
fprintf( outfile, "C NOTE: Generated code\n");
fprintf( outfile, "C\n");
fprintf( outfile, "C Type of floating-point numbers in PLplot\n");
fprintf( outfile, "C\n");
fprintf( outfile, " integer, parameter :: plf = kind(%s)\n", kind);
fprintf( outfile, " integer, parameter :: plflt = plf\n");
fclose( outfile);
}
| /* Auxiliary program: write the include file for determining
PLplot's floating-point type
*/
#include <stdio.h>
#include <stdlib.h>
#include "plConfig.h"
main(int argc, char *argv[] )
{
FILE *outfile;
char *kind;
outfile = fopen( "plflt.inc", "w" ) ;
#ifdef PL_DOUBLE
kind = "1.0d0";
#else
kind = "1.0";
#endif
fprintf( outfile, "! NOTE: Generated code\n");
fprintf( outfile, "!\n");
fprintf( outfile, "! Type of floating-point numbers in PLplot\n");
fprintf( outfile, "!\n");
fprintf( outfile, " integer, parameter :: plf = kind(%s)\n", kind);
fprintf( outfile, " integer, parameter :: plflt = plf\n");
fclose( outfile);
}
|
Add Cytron Maker Zero SAMD21 | #define MICROPY_HW_BOARD_NAME "Cytron Maker Zero SAMD21"
#define MICROPY_HW_MCU_NAME "samd21g18"
#define MICROPY_HW_LED_TX &pin_PA27
#define MICROPY_HW_LED_RX &pin_PB03
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
#define DEFAULT_SPI_BUS_SCK (&pin_PB11)
#define DEFAULT_SPI_BUS_MOSI (&pin_PB10)
#define DEFAULT_SPI_BUS_MISO (&pin_PA12)
#define DEFAULT_UART_BUS_RX (&pin_PA11)
#define DEFAULT_UART_BUS_TX (&pin_PA10)
// USB is always used internally so skip the pin objects for it.
#define IGNORE_PIN_PA24 1
#define IGNORE_PIN_PA25 1
// Connected to a crystal
#define IGNORE_PIN_PA00 1
#define IGNORE_PIN_PA01 1
// SWD-only
#define IGNORE_PIN_PA30 1
#define IGNORE_PIN_PA31 1
| |
Test long size and timeval to long conversion | #include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
int main(int argc, char **argv) {
struct timeval tv;
struct timezone tz;
struct tm *tm;
gettimeofday(&tv, &tz);
tm = localtime(&tv.tv_sec);
char timestr[128];
size_t length = strftime(timestr, 128, "%F %T", tm);
snprintf(timestr+length, 128-length, ".%ld", tv.tv_usec/1000);
printf("Time string: %s\n", timestr);
} | #include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include "../../bluez-5.28/lib/bluetooth.h"
int main(int argc, char **argv) {
struct timeval tv;
struct timezone tz;
struct tm *tm;
gettimeofday(&tv, &tz);
tm = localtime(&tv.tv_sec);
char timestr[128];
size_t length = strftime(timestr, 128, "%F %T", tm);
snprintf(timestr+length, 128-length, ".%ld", tv.tv_usec/1000);
printf("Time string: %s\n", timestr);
long ms = htobl(tv.tv_sec)*1000 + htobl(tv.tv_usec)/1000;
int64_t ms64 = htobl(tv.tv_sec)*1000 + htobl(tv.tv_usec)/1000;
printf("Sizeof(long) = %d, ms=%ld, ms64=%ld\n", sizeof(ms), ms, ms64);
} |
Add comment to explicitly identify Chain of Responsibility | //
// OCHamcrest - HCReturnTypeHandler.h
// Copyright 2014 hamcrest.org. See LICENSE.txt
//
// Created by: Jon Reid, http://qualitycoding.org/
// Docs: http://hamcrest.github.com/OCHamcrest/
// Source: https://github.com/hamcrest/OCHamcrest
//
#import <Foundation/Foundation.h>
@interface HCReturnTypeHandler : NSObject
@property (nonatomic, strong) HCReturnTypeHandler *successor;
- (instancetype)initWithType:(char const *)handlerType;
- (id)valueForReturnType:(char const *)type fromInvocation:(NSInvocation *)invocation;
@end
| //
// OCHamcrest - HCReturnTypeHandler.h
// Copyright 2014 hamcrest.org. See LICENSE.txt
//
// Created by: Jon Reid, http://qualitycoding.org/
// Docs: http://hamcrest.github.com/OCHamcrest/
// Source: https://github.com/hamcrest/OCHamcrest
//
#import <Foundation/Foundation.h>
/**
Chain-of-responsibility for handling NSInvocation return types.
*/
@interface HCReturnTypeHandler : NSObject
@property (nonatomic, strong) HCReturnTypeHandler *successor;
- (instancetype)initWithType:(char const *)handlerType;
- (id)valueForReturnType:(char const *)type fromInvocation:(NSInvocation *)invocation;
@end
|
Move include within include guards. | /**
* For conditions of distribution and use, see copyright notice in license.txt
*
* @file WorldLogicInterface.h
* @brief
*/
#include "ServiceInterface.h"
#ifndef incl_Interfaces_WorldLogicInterface_h
#define incl_Interfaces_WorldLogicInterface_h
#include "ForwardDefines.h"
#include <QObject>
class QString;
namespace Foundation
{
class WorldLogicInterface : public QObject, public ServiceInterface
{
Q_OBJECT
public:
/// Default constructor.
WorldLogicInterface() {}
/// Destructor.
virtual ~WorldLogicInterface() {}
/// Returns user's avatar entity.
virtual Scene::EntityPtr GetUserAvatarEntity() const = 0;
/// Returns currently active camera entity.
virtual Scene::EntityPtr GetCameraEntity() const = 0;
/// Returns entity with certain entity component in it or null if not found.
/// @param entity_id Entity ID.
/// @param component Type name of the component.
virtual Scene::EntityPtr GetEntityWithComponent(uint entity_id, const QString &component) const = 0;
/// Hack function for getting EC_AvatarAppearance info to UiModule
virtual const QString &GetAvatarAppearanceProperty(const QString &name) const = 0;
signals:
/// Emitted just before we start to delete world (scene).
void AboutToDeleteWorld();
};
}
#endif
| /**
* For conditions of distribution and use, see copyright notice in license.txt
*
* @file WorldLogicInterface.h
* @brief
*/
#ifndef incl_Interfaces_WorldLogicInterface_h
#define incl_Interfaces_WorldLogicInterface_h
#include "ServiceInterface.h"
#include "ForwardDefines.h"
#include <QObject>
class QString;
namespace Foundation
{
class WorldLogicInterface : public QObject, public ServiceInterface
{
Q_OBJECT
public:
/// Default constructor.
WorldLogicInterface() {}
/// Destructor.
virtual ~WorldLogicInterface() {}
/// Returns user's avatar entity.
virtual Scene::EntityPtr GetUserAvatarEntity() const = 0;
/// Returns currently active camera entity.
virtual Scene::EntityPtr GetCameraEntity() const = 0;
/// Returns entity with certain entity component in it or null if not found.
/// @param entity_id Entity ID.
/// @param component Type name of the component.
virtual Scene::EntityPtr GetEntityWithComponent(uint entity_id, const QString &component) const = 0;
/// Hack function for getting EC_AvatarAppearance info to UiModule
virtual const QString &GetAvatarAppearanceProperty(const QString &name) const = 0;
signals:
/// Emitted just before we start to delete world (scene).
void AboutToDeleteWorld();
};
}
#endif
|
Fix clang build that have been broken by 81364. | // 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 CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#define CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#include "base/basictypes.h"
#include "content/browser/browser_message_filter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaType.h"
class GURL;
class QuotaDispatcherHost : public BrowserMessageFilter {
public:
~QuotaDispatcherHost();
bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok);
private:
void OnQueryStorageUsageAndQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type);
void OnRequestStorageQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type,
int64 requested_size);
};
#endif // CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_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 CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#define CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#include "base/basictypes.h"
#include "content/browser/browser_message_filter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaType.h"
class GURL;
class QuotaDispatcherHost : public BrowserMessageFilter {
public:
~QuotaDispatcherHost();
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok);
private:
void OnQueryStorageUsageAndQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type);
void OnRequestStorageQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type,
int64 requested_size);
};
#endif // CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
|
Save value history as circular array, print function for debug | // stdio for file I/O
#include <stdio.h>
int main(int argc, char *argv[]) {
int status = 1;
float value;
while(status != EOF) {
status = fscanf(stdin, "%f\n", &value);
if(status == 1)
fprintf(stdout, "%f\n", value);
else
fprintf(stdout, "Error reading data (%d)\n", status);
}
}
| // stdio for file I/O
#include <stdio.h>
#define HISTORY_SIZE 5
void print_values(float *values, int current_i) {
// Print values to stdout, starting from one after newest (oldest) and
// circle around to newest
int i = current_i;
for(i = current_i; i < current_i + HISTORY_SIZE; i++) {
fprintf(stdout, "%.1f, ", values[i%HISTORY_SIZE]);
}
fprintf(stdout, "\n");
}
int main(int argc, char *argv[]) {
int status = 1;
int values_i = 0;
float v;
float values[HISTORY_SIZE];
// Read floats to values, circle around after filling buffer
while(status != EOF) {
status = fscanf(stdin, "%f\n", &v);
if(status == 1) {
values[values_i] = v;
values_i = (values_i+1) % HISTORY_SIZE;
print_values(values, values_i);
//fprintf(stdout, "%f\n", v);
} else {
fprintf(stdout, "Error reading data (%d)\n", status);\
}
}
}
|
Join is a safe filter. | /*
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
*/
#ifndef JOINFILTER_H
#define JOINFILTER_H
#include "filter.h"
using namespace Grantlee;
class GRANTLEE_EXPORT JoinFilter : public Filter
{
Q_OBJECT
public:
JoinFilter(QObject *parent = 0);
Grantlee::SafeString doFilter(const QVariant &input, const Grantlee::SafeString &argument = QString(), bool autoescape=false) const;
};
#endif
| /*
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
*/
#ifndef JOINFILTER_H
#define JOINFILTER_H
#include "filter.h"
using namespace Grantlee;
class GRANTLEE_EXPORT JoinFilter : public Filter
{
Q_OBJECT
public:
JoinFilter(QObject *parent = 0);
Grantlee::SafeString doFilter(const QVariant &input, const Grantlee::SafeString &argument = QString(), bool autoescape=false) const;
bool isSafe() { return true; }
};
#endif
|
Adjust the comment on get_order() to describe the size==0 case | #ifndef __ASM_GENERIC_GETORDER_H
#define __ASM_GENERIC_GETORDER_H
#ifndef __ASSEMBLY__
#include <linux/compiler.h>
/* Pure 2^n version of get_order */
static inline __attribute_const__ int get_order(unsigned long size)
{
int order;
size = (size - 1) >> (PAGE_SHIFT - 1);
order = -1;
do {
size >>= 1;
order++;
} while (size);
return order;
}
#endif /* __ASSEMBLY__ */
#endif /* __ASM_GENERIC_GETORDER_H */
| #ifndef __ASM_GENERIC_GETORDER_H
#define __ASM_GENERIC_GETORDER_H
#ifndef __ASSEMBLY__
#include <linux/compiler.h>
/**
* get_order - Determine the allocation order of a memory size
* @size: The size for which to get the order
*
* Determine the allocation order of a particular sized block of memory. This
* is on a logarithmic scale, where:
*
* 0 -> 2^0 * PAGE_SIZE and below
* 1 -> 2^1 * PAGE_SIZE to 2^0 * PAGE_SIZE + 1
* 2 -> 2^2 * PAGE_SIZE to 2^1 * PAGE_SIZE + 1
* 3 -> 2^3 * PAGE_SIZE to 2^2 * PAGE_SIZE + 1
* 4 -> 2^4 * PAGE_SIZE to 2^3 * PAGE_SIZE + 1
* ...
*
* The order returned is used to find the smallest allocation granule required
* to hold an object of the specified size.
*
* The result is undefined if the size is 0.
*
* This function may be used to initialise variables with compile time
* evaluations of constants.
*/
static inline __attribute_const__ int get_order(unsigned long size)
{
int order;
size = (size - 1) >> (PAGE_SHIFT - 1);
order = -1;
do {
size >>= 1;
order++;
} while (size);
return order;
}
#endif /* __ASSEMBLY__ */
#endif /* __ASM_GENERIC_GETORDER_H */
|
Test commit in master4 branch | file4.c - r1
Test checkin in master1-updated
Test checkin in master2
| file4.c - r1
Test checkin in master1-updated - updated_by_master
Test checkin in master2
Test checkin in master3
Test checkin in master4
|
Disable board.SPI() for Challenger NB RP2040 WiFi | #define MICROPY_HW_BOARD_NAME "Challenger NB RP2040 WiFi"
#define MICROPY_HW_MCU_NAME "rp2040"
#define DEFAULT_UART_BUS_TX (&pin_GPIO16)
#define DEFAULT_UART_BUS_RX (&pin_GPIO17)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO0)
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO1)
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO22)
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO23)
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO24)
| #define MICROPY_HW_BOARD_NAME "Challenger NB RP2040 WiFi"
#define MICROPY_HW_MCU_NAME "rp2040"
#define DEFAULT_UART_BUS_TX (&pin_GPIO16)
#define DEFAULT_UART_BUS_RX (&pin_GPIO17)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO0)
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO1)
|
Make it so that stdin/stdout/stderr will be set as line buffered (newlib has to think they're ttys if we have fcntl, which we do now). | /* KallistiOS ##version##
newlib_isatty.c
Copyright (C)2004 Dan Potter
*/
#include <sys/reent.h>
int isatty(int fd) {
return 0;
}
int _isatty_r(struct _reent *reent, int fd) {
return 0;
}
| /* KallistiOS ##version##
newlib_isatty.c
Copyright (C) 2004 Dan Potter
Copyright (C) 2012 Lawrence Sebald
*/
#include <sys/reent.h>
int isatty(int fd) {
/* Make sure that stdin, stdout, and stderr are shown as ttys, otherwise
they won't be set as line-buffered. */
if(fd >= 0 && fd <= 2) {
return 1;
}
return 0;
}
int _isatty_r(struct _reent *reent, int fd) {
/* Make sure that stdin, stdout, and stderr are shown as ttys, otherwise
they won't be set as line-buffered.*/
if(fd >= 0 && fd <= 2) {
return 1;
}
return 0;
}
|
Simplify a bit as special treatment is no longer needed for HPUX. | #ifndef TIMEVAL_H
#define TIMEVAL_H
#if defined(ULTRIX42) || defined(ULTRIX43) || defined(HPUX9)
#if !defined(_ALL_SOURCE)
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
struct itimerval {
struct timeval it_interval; /* timer interval */
struct timeval it_value; /* current value */
};
#endif /* _ALL_SOURCE */
#else
#include <sys/time.h>
#endif
#endif
| #ifndef TIMEVAL_H
#define TIMEVAL_H
#if defined(ULTRIX43) && !defined(_ALL_SOURCE)
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
struct itimerval {
struct timeval it_interval; /* timer interval */
struct timeval it_value; /* current value */
};
#else
# include <sys/time.h>
#endif
#endif
|
Add function prototype for setting current geometry. Rename function prototype for grid virtual size set. | #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
Evas_Object *e_smart_monitor_add(Evas *evas);
void e_smart_monitor_crtc_set(Evas_Object *obj, Ecore_X_Randr_Crtc crtc, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch);
void e_smart_monitor_output_set(Evas_Object *obj, Ecore_X_Randr_Output output);
void e_smart_monitor_grid_set(Evas_Object *obj, Evas_Object *grid, Evas_Coord gx, Evas_Coord gy, Evas_Coord gw, Evas_Coord gh);
void e_smart_monitor_virtual_size_set(Evas_Object *obj, Evas_Coord vw, Evas_Coord vh);
void e_smart_monitor_background_set(Evas_Object *obj, Evas_Coord dx, Evas_Coord dy);
# endif
#endif
| #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
Evas_Object *e_smart_monitor_add(Evas *evas);
void e_smart_monitor_crtc_set(Evas_Object *obj, Ecore_X_Randr_Crtc crtc, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch);
void e_smart_monitor_output_set(Evas_Object *obj, Ecore_X_Randr_Output output);
void e_smart_monitor_grid_set(Evas_Object *obj, Evas_Object *grid, Evas_Coord gx, Evas_Coord gy, Evas_Coord gw, Evas_Coord gh);
void e_smart_monitor_grid_virtual_size_set(Evas_Object *obj, Evas_Coord vw, Evas_Coord vh);
void e_smart_monitor_background_set(Evas_Object *obj, Evas_Coord dx, Evas_Coord dy);
void e_smart_monitor_current_geometry_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
# endif
#endif
|
Fix ecommerce methods to take properties dictionary | //
// SEGEcommerce.h
// Analytics
//
// Created by Travis Jeffery on 7/17/14.
// Copyright (c) 2014 Segment.io. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol SEGEcommerce <NSObject>
- (void)viewedProduct;
- (void)removedProduct;
- (void)addedProduct;
- (void)completedOrder;
@end
| //
// SEGEcommerce.h
// Analytics
//
// Created by Travis Jeffery on 7/17/14.
// Copyright (c) 2014 Segment.io. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol SEGEcommerce <NSObject>
@optional
- (void)viewedProduct:(NSDictionary *)properties;
- (void)removedProduct:(NSDictionary *)properties;
- (void)addedProduct:(NSDictionary *)properties;
- (void)completedOrder:(NSDictionary *)properties;
@end
|
Add NaN/Inf check for low-pass filter. | // Copyright (c) 2017 Franka Emika GmbH
// Use of this source code is governed by the Apache-2.0 license, see LICENSE
#pragma once
#include <cmath>
/**
* @file lowpass_filter.h
* Contains functions for filtering signals with a low-pass filter.
*/
namespace franka {
/**
* Maximum cutoff frequency
*/
constexpr double kMaxCutoffFrequency = 1000.0;
/**
* Default cutoff frequency
*/
constexpr double kDefaultCutoffFrequency = 100.0;
/**
* Applies a first-order low-pass filter
*
* @param[in] sample_time Sample time constant
* @param[in] y Current value of the signal to be filtered
* @param[in] y_last Value of the signal to be filtered in the previous time step
* @param[in] cutoff_frequency Cutoff frequency of the low-pass filter
*
* @return Filtered value.
*/
inline double lowpassFilter(double sample_time, double y, double y_last, double cutoff_frequency) {
double gain = sample_time / (sample_time + (1.0 / (2.0 * M_PI * cutoff_frequency)));
return gain * y + (1 - gain) * y_last;
}
} // namespace franka
| // Copyright (c) 2017 Franka Emika GmbH
// Use of this source code is governed by the Apache-2.0 license, see LICENSE
#pragma once
#include <cmath>
/**
* @file lowpass_filter.h
* Contains functions for filtering signals with a low-pass filter.
*/
namespace franka {
/**
* Maximum cutoff frequency
*/
constexpr double kMaxCutoffFrequency = 1000.0;
/**
* Default cutoff frequency
*/
constexpr double kDefaultCutoffFrequency = 100.0;
/**
* Applies a first-order low-pass filter
*
* @param[in] sample_time Sample time constant
* @param[in] y Current value of the signal to be filtered
* @param[in] y_last Value of the signal to be filtered in the previous time step
* @param[in] cutoff_frequency Cutoff frequency of the low-pass filter
* @throw std::invalid_argument if y is infinite or NaN.
*
* @return Filtered value.
*/
inline double lowpassFilter(double sample_time, double y, double y_last, double cutoff_frequency) {
if (!std::isfinite(y)){
throw std::invalid_argument("Commanding value is infinite or NaN.");
}
double gain = sample_time / (sample_time + (1.0 / (2.0 * M_PI * cutoff_frequency)));
return gain * y + (1 - gain) * y_last;
}
} // namespace franka
|
Add xhtml-im and w3c xhtml namespace |
#define GIBBER_XMPP_NS_STREAM \
(const gchar *)"http://etherx.jabber.org/streams"
#define GIBBER_XMPP_NS_TLS \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-tls"
#define GIBBER_XMPP_NS_SASL_AUTH \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-sasl"
|
#define GIBBER_XMPP_NS_STREAM \
(const gchar *)"http://etherx.jabber.org/streams"
#define GIBBER_XMPP_NS_TLS \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-tls"
#define GIBBER_XMPP_NS_SASL_AUTH \
(const gchar *)"urn:ietf:params:xml:ns:xmpp-sasl"
#define GIBBER_XMPP_NS_XHTML_IM \
(const gchar *)"http://jabber.org/protocol/xhtml-im"
#define GIBBER_W3C_NS_XHTML \
(const gchar *)"http://www.w3.org/1999/xhtml"
|
Add test for octApron combine forgetting return assign in function | // SKIP PARAM: --sets ana.activated[+] octApron
#include <assert.h>
int f(int x) {
return x + 1;
}
int main(void) {
int y = 42;
y = f(y);
// combine should forget callee's y after substituting arg vars with args to avoid bottom in #ret substitute
assert(y);
return 0;
}
| |
Update files, Alura, Introdução a C - Parte 2, Aula 2.6 | #include <stdio.h>
#include <string.h>
int main() {
char palavrasecreta[20];
sprintf(palavrasecreta, "MELANCIA");
int acertou = 0;
int enforcou = 0;
char chutes[26];
int tentativas = 0;
do {
for(int i = 0; i < strlen(palavrasecreta); i++) {
int achou = 0;
for(int j = 0; j < tentativas; j++) {
if(chutes[j] == palavrasecreta[i]) {
achou = 1;
break;
}
}
if(achou) {
printf("%c ", palavrasecreta[i]);
} else {
printf("_ ");
}
}
printf("\n");
char chute;
scanf(" %c", &chute);
chutes[tentativas] = chute;
tentativas++;
} while(!acertou && !enforcou);
}
| #include <stdio.h>
#include <string.h>
int main() {
char palavrasecreta[20];
sprintf(palavrasecreta, "MELANCIA");
int acertou = 0;
int enforcou = 0;
char chutes[26];
int tentativas = 0;
do {
for(int i = 0; i < strlen(palavrasecreta); i++) {
int achou = 0;
for(int j = 0; j < tentativas; j++) {
if(chutes[j] == palavrasecreta[i]) {
achou = 1;
break;
}
}
if(achou) {
printf("%c ", palavrasecreta[i]);
} else {
printf("_ ");
}
}
printf("\n");
char chute;
printf("Qual letra? ");
scanf(" %c", &chute);
chutes[tentativas] = chute;
tentativas++;
} while(!acertou && !enforcou);
}
|
Change for new config system | /*===========================================================================*
| fpbasis.c
| Copyright (c) 1996-97 Applied Logic Systems, Inc.
|
| -- Floating point math abstractions
|
*===========================================================================*/
#include "defs.h"
#include "fpbasis.h"
#ifdef MacOS
#include <fp.h>
#endif
int is_ieee_nan PARAMS( (double) );
int is_ieee_inf PARAMS( (double) );
int
is_ieee_nan(v)
double v;
{
return isnan(v);
}
int
is_ieee_inf(v)
double v;
{
#ifdef SOLARIS
switch (fpclass(v)) {
case FP_NINF:
return(1);
case FP_PINF:
return(1);
default:
return(0);
}
#elif defined(WIN32) || defined(AIX)
return !finite(v);
#elif defined(MacOS)
return !isfinite(v);
#elif (defined(__sgi) && defined(__mips))
return(!finite(v));
#else
return isinf(v);
#endif
}
| /*===========================================================================*
| fpbasis.c
| Copyright (c) 1996-97 Applied Logic Systems, Inc.
|
| -- Floating point math abstractions
|
*===========================================================================*/
#include "defs.h"
#include "fpbasis.h"
#ifdef MacOS
#include <fp.h>
#endif
int is_ieee_nan PARAMS( (double) );
int is_ieee_inf PARAMS( (double) );
int
is_ieee_nan(v)
double v;
{
return isnan(v);
}
int
is_ieee_inf(v)
double v;
{
#if defined(SOLARIS) || defined(UNIX_SOLARIS)
switch (fpclass(v)) {
case FP_NINF:
return(1);
case FP_PINF:
return(1);
default:
return(0);
}
#elif defined(WIN32) || defined(AIX)
return !finite(v);
#elif defined(MacOS)
return !isfinite(v);
#elif (defined(__sgi) && defined(__mips))
return(!finite(v));
#else
return isinf(v);
#endif
}
|
Add while loop examples, really | /*
* Author: Jhonatan Casale (jhc)
*
* Contact : jhonatan@jhonatancasale.com
* : casale.jhon@gmail.com
* : https://github.com/jhonatancasale
* : https://twitter.com/jhonatancasale
* : http://jhonatancasale.github.io/
*
* Create date Wed 1 Mar 01:51:51 BRT 2017
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
int main (int argc, char **argv)
{
char str[] = "Hello, world!";
int i = 0;
while ( str[i] != '\0' ) {
printf ("%c\n", str[i]);
i++;
}
printf ("\n");
i = 0;
while ( str[i] != '\0' )
printf ("%c", toupper(str[i++]));
printf ("\n");
return (EXIT_SUCCESS);
}
| |
Make chrome use the static square vb when drawing rects. | #ifndef GrGLConfig_chrome_DEFINED
#define GrGLConfig_chrome_DEFINED
#define GR_SUPPORT_GLES2 1
// gl2ext.h will define these extensions macros but Chrome doesn't provide
// prototypes.
#define GL_OES_mapbuffer 0
#define GL_IMG_multisampled_render_to_texture 0
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#define GR_GL_FUNC
#define GR_GL_PROC_ADDRESS(X) &X
// chrome always assumes BGRA
#define GR_GL_32BPP_COLOR_FORMAT GR_BGRA
// glGetError() forces a sync with gpu process on chrome
#define GR_GL_CHECK_ERROR_START 0
#endif
| #ifndef GrGLConfig_chrome_DEFINED
#define GrGLConfig_chrome_DEFINED
#define GR_SUPPORT_GLES2 1
// gl2ext.h will define these extensions macros but Chrome doesn't provide
// prototypes.
#define GL_OES_mapbuffer 0
#define GL_IMG_multisampled_render_to_texture 0
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#define GR_GL_FUNC
#define GR_GL_PROC_ADDRESS(X) &X
// chrome always assumes BGRA
#define GR_GL_32BPP_COLOR_FORMAT GR_BGRA
// glGetError() forces a sync with gpu process on chrome
#define GR_GL_CHECK_ERROR_START 0
// Using the static vb precludes batching rect-to-rect draws
// because there are matrix changes between each one.
// Chrome was getting top performance on Windows with
// batched rect-to-rect draws. But there seems to be some
// regression that now causes any dynamic VB data to perform
// very poorly. In any event the static VB seems to get equal
// perf to what batching was producing and it always seems to
// be better on Linux.
#define GR_STATIC_RECT_VB 1
#endif
|
Add persistent history to shell | #include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "linenoise.h"
char* findPrompt();
void executeCommand(const char *text);
int main() {
int childPid;
int child_status;
char *line;
char *prompt;
prompt = findPrompt();
while((line = linenoise(prompt)) != NULL) {
if (line[0] != '\0') {
linenoiseHistoryAdd(line);
childPid = fork();
if(childPid == 0) {
executeCommand(line);
} else {
wait(&child_status);
}
}
free(line);
}
return 0;
}
char* findPrompt() {
return "$ ";
}
void executeCommand(const char *text) {
execlp(text, text, NULL);
}
| #include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include "linenoise.h"
#define HISTORY_FILE ".beaksh_history"
char* findPrompt();
char* getHistoryPath();
void executeCommand(const char *text);
int main() {
int childPid;
int child_status;
char *line;
char *prompt;
prompt = findPrompt();
char *historyPath = getHistoryPath();
linenoiseHistoryLoad(historyPath);
while((line = linenoise(prompt)) != NULL) {
if (line[0] != '\0') {
linenoiseHistoryAdd(line);
linenoiseHistorySave(historyPath);
childPid = fork();
if(childPid == 0) {
executeCommand(line);
} else {
wait(&child_status);
}
}
free(line);
}
if(historyPath)
free(historyPath);
return EXIT_SUCCESS;
}
char* findPrompt() {
return "$ ";
}
/*
Resolve dotfile path for history. Returns NULL if file can't be resolved.
*/
char* getHistoryPath() {
char *home = getenv("HOME");
if(!home)
return NULL;
int home_path_len = strnlen(home, MAXPATHLEN);
int history_path_len = home_path_len + strlen(HISTORY_FILE) + 1;
char *result;
if((result = malloc(history_path_len + 1)) == NULL) {
fprintf(stderr, "Problem resolving path for history file, no history will be recorded\n");
return NULL;
}
strncpy(result, home, home_path_len);
strncat(result, "/", 1);
strncat(result, HISTORY_FILE, strlen(HISTORY_FILE));
return result;
}
void executeCommand(const char *text) {
execlp(text, text, NULL);
}
|
Add a shooter program, and speed reader. | #pragma config(Sensor, dgtl4, LeftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl11, RightEncoder, sensorQuadEncoder)
#pragma config(Motor, port8, Shooter8, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, Shooter9, tmotorVex393_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task Shooting()
{
int last_clicks_left = 0;
int last_clicks_right = 0;
while(true)
{
motor[Shooter8] = 50;
motor[Shooter9] = 50;
//get current
int current_right_clicks = SensorValue[RightEncoder];
int current_left_clicks = SensorValue[LeftEncoder];
//calculate elapsed
int elapsed_right_clicks = current_right_clicks - last_clicks_right;
int elapsed_left_clicks = current_left_clicks - last_clicks_left;
//print
writeDebugStreamLine("elapsed_right_clicks: %d", elapsed_right_clicks);
writeDebugStreamLine("elapese_left_clicks: %d", elapsed_left_clicks);
//save current to last
last_clicks_left = current_left_clicks;
last_clicks_right = current_right_clicks;
delay(100);
}
}
task main()
{
startTask(Shooting);
}
| |
Change type creation from define to typedef. | #ifndef __TOURH__
#define __TOURH__
#include <stdio.h>
#include <stdlib.h>
#define tour int*
#define city int
//initializes a new tour
tour create_tour(int ncities);
//returns true if the tour t is shorter than
//a distance indicated by dist
int is_shtr(tour t, int dist);
//defines the starter point of a tour
void strt_point(tour t, city c);
//defines a new tour changing the order of two cities
void swap_cities(tour* t, city c1, city c2);
#endif | #ifndef __TOURH__
#define __TOURH__
#include <stdio.h>
#include <stdlib.h>
typedef int* tour;
typedef int city;
//inicializa um tour
tour create_tour(int ncities);
//popula um tour pre-definido com cidades
void populate_tour(tour t, int ncities);
//retorna true se a distancia total do
//tour t for menor que dist
int is_shoter(tour t, int dist);
//define a cidade inicial de um tour
void start_point(tour t, city c);
//inverte a posição de duas cidades no tour
void swap_cities(tour t, int c1, int c2);
#endif |
Add prototypes for popen()/pclose() for OSF1 machines. | #ifndef FIX_STDIO_H
#define FIX_STDIO_H
#include <stdio.h>
/*
For some reason the stdio.h on Ultrix 4.3 fails to provide a prototype
for pclose() if _POSIX_SOURCE is defined - even though it does
provide a prototype for popen().
*/
#if defined(ULTRIX43)
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__STDC__) || defined(__cplusplus)
int pclose( FILE *__stream );
#else
int pclose();
#endif
#if defined(__cplusplus)
}
#endif
#endif /* ULTRIX43 */
#endif
| #ifndef FIX_STDIO_H
#define FIX_STDIO_H
#include <stdio.h>
#if defined(__cplusplus)
extern "C" {
#endif
/*
For some reason the stdio.h on OSF1 fails to provide prototypes
for popen() and pclose() if _POSIX_SOURCE is defined.
*/
#if defined(OSF1)
#if defined(__STDC__) || defined(__cplusplus)
FILE *popen( char *, char * );
int pclose( FILE *__stream );
#else
FILE *popen();
int pclose();
#endif
#endif /* OSF1 */
/*
For some reason the stdio.h on Ultrix 4.3 fails to provide a prototype
for pclose() if _POSIX_SOURCE is defined - even though it does
provide a prototype for popen().
*/
#if defined(ULTRIX43)
#if defined(__STDC__) || defined(__cplusplus)
int pclose( FILE *__stream );
#else
int pclose();
#endif
#endif /* ULTRIX43 */
#if defined(__cplusplus)
}
#endif
#endif
|
Support wu-ftpd-like chrooting in /etc/passwd. If home directory ends with "/./", it's chrooted to. | /* Copyright (C) 2002-2003 Timo Sirainen */
#include "config.h"
#undef HAVE_CONFIG_H
#ifdef USERDB_PASSWD
#include "common.h"
#include "userdb.h"
#include <pwd.h>
static void passwd_lookup(const char *user, userdb_callback_t *callback,
void *context)
{
struct user_data data;
struct passwd *pw;
pw = getpwnam(user);
if (pw == NULL) {
if (errno != 0)
i_error("getpwnam(%s) failed: %m", user);
else if (verbose)
i_info("passwd(%s): unknown user", user);
callback(NULL, context);
return;
}
memset(&data, 0, sizeof(data));
data.uid = pw->pw_uid;
data.gid = pw->pw_gid;
data.virtual_user = data.system_user = pw->pw_name;
data.home = pw->pw_dir;
callback(&data, context);
}
struct userdb_module userdb_passwd = {
NULL, NULL,
passwd_lookup
};
#endif
| /* Copyright (C) 2002-2003 Timo Sirainen */
#include "config.h"
#undef HAVE_CONFIG_H
#ifdef USERDB_PASSWD
#include "common.h"
#include "userdb.h"
#include <pwd.h>
static void passwd_lookup(const char *user, userdb_callback_t *callback,
void *context)
{
struct user_data data;
struct passwd *pw;
size_t len;
pw = getpwnam(user);
if (pw == NULL) {
if (errno != 0)
i_error("getpwnam(%s) failed: %m", user);
else if (verbose)
i_info("passwd(%s): unknown user", user);
callback(NULL, context);
return;
}
memset(&data, 0, sizeof(data));
data.uid = pw->pw_uid;
data.gid = pw->pw_gid;
data.virtual_user = data.system_user = pw->pw_name;
len = strlen(pw->pw_dir);
if (len < 3 || strcmp(pw->pw_dir + len - 3, "/./") != 0)
data.home = pw->pw_dir;
else {
/* wu-ftpd uses <chroot>/./<dir>. We don't support
the dir after chroot, but this should work well enough. */
data.home = t_strndup(pw->pw_dir, len-3);
data.chroot = TRUE;
}
callback(&data, context);
}
struct userdb_module userdb_passwd = {
NULL, NULL,
passwd_lookup
};
#endif
|
Add exceptions parsing (not tested yet) | #include "master.h"
//Master configurations
MODBUSMasterStatus MODBUSMaster;
void MODBUSParseResponse( uint8_t *Frame, uint8_t FrameLength )
{
//This function parses response from master
//Calling it will lead to losing all data and exceptions stored in MODBUSMaster (space will be reallocated)
//Allocate memory for union and copy frame to it
union MODBUSParser *Parser = malloc( FrameLength );
memcpy( ( *Parser ).Frame, Frame, FrameLength );
if ( MODBUS_MASTER_BASIC )
MODBUSParseResponseBasic( Parser );
//Free used memory
free( Parser );
}
void MODBUSMasterInit( )
{
//Very basic init of master side
MODBUSMaster.Request.Frame = malloc( 8 );
MODBUSMaster.Request.Length = 0;
MODBUSMaster.Data = malloc( sizeof( MODBUSData ) );
MODBUSMaster.DataLength = 0;
}
| #include "master.h"
//Master configurations
MODBUSMasterStatus MODBUSMaster;
void MODBUSParseException( union MODBUSParser *Parser )
{
//Parse exception frame and write data to MODBUSMaster structure
//Allocate memory for exception parser
union MODBUSException *Exception = malloc( sizeof( union MODBUSException ) );
memcpy( ( *Exception ).Frame, ( *Parser ).Frame, sizeof( union MODBUSException ) );
//Check CRC
if ( MODBUSCRC16( ( *Exception ).Frame, 3 ) != ( *Exception ).Exception.CRC )
{
free( Exception );
return;
}
//Copy data
MODBUSMaster.Exception.Address = ( *Exception ).Exception.Address;
MODBUSMaster.Exception.Function = ( *Exception ).Exception.Function;
MODBUSMaster.Exception.Code = ( *Exception ).Exception.ExceptionCode;
MODBUSMaster.Error = 1;
free( Exception );
}
void MODBUSParseResponse( uint8_t *Frame, uint8_t FrameLength )
{
//This function parses response from master
//Calling it will lead to losing all data and exceptions stored in MODBUSMaster (space will be reallocated)
//Allocate memory for union and copy frame to it
union MODBUSParser *Parser = malloc( FrameLength );
memcpy( ( *Parser ).Frame, Frame, FrameLength );
//Check if frame is exception response
if ( ( *Parser ).Base.Function & 128 )
{
MODBUSParseException( Parser );
}
else
{
if ( MODBUS_MASTER_BASIC )
MODBUSParseResponseBasic( Parser );
}
//Free used memory
free( Parser );
}
void MODBUSMasterInit( )
{
//Very basic init of master side
MODBUSMaster.Request.Frame = malloc( 8 );
MODBUSMaster.Request.Length = 0;
MODBUSMaster.Data = malloc( sizeof( MODBUSData ) );
MODBUSMaster.DataLength = 0;
}
|
Use updated mavlink library v2 | //Move this directory to ~/sketchbook/libraries
// and clone https://github.com/mavlink/c_library.git inside
// git clone https://github.com/mavlink/c_library.git ~/sketchbook/libraries/MavlinkForArduino
#include "c_library/ardupilotmega/mavlink.h"
| //Move this directory to ~/sketchbook/libraries
// and clone https://github.com/mavlink/c_library_v2.git inside
// git clone https://github.com/mavlink/c_library_V2.git ~/Arduino/libraries/MavlinkForArduino/c_library_v2
#include "c_library_v2/ardupilotmega/mavlink.h"
|
Use the correct definition for memset. | // RUN: %clang_cc1 %s -emit-llvm -o - | grep llvm.memset | count 3
#ifndef memset
void *memset(void*, int, unsigned long);
#endif
#ifndef bzero
void bzero(void*, unsigned long);
#endif
void test(int* X, char *Y) {
// CHECK: call i8* llvm.memset
memset(X, 4, 1000);
// CHECK: call void bzero
bzero(Y, 100);
}
| // RUN: %clang_cc1 %s -emit-llvm -o - | grep llvm.memset | count 3
typedef __SIZE_TYPE__ size_t;
void *memset(void*, int, size_t);
void bzero(void*, size_t);
void test(int* X, char *Y) {
// CHECK: call i8* llvm.memset
memset(X, 4, 1000);
// CHECK: call void bzero
bzero(Y, 100);
}
|
Resolve q3 (pythonic way? so close) | #include <stdio.h>
int ssearch(int number, int target){
if (number == 0)
if (target == 0) return 1;
else return 0;
else
return ssearch(number/10, target) + (number % 10 == target);
}
int main(){
printf("%d\n", ssearch(762021192, 2));
return 0;
}
| |
Use quotes for local include | //
// VOKAlertHelper.h
// VOKUtilities
//
// Created by Rachel Hyman on 6/15/15.
// Copyright (c) 2015 Vokal. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <VOKAlertAction.h>
typedef void(^VOKAlertHelperActionBlock)(void);
NS_ASSUME_NONNULL_BEGIN
@interface VOKAlertHelper : NSObject
/**
* Displays an alert in the OS-appropriate fashion.
*
* @param viewController View controller responsible for presenting the alert.
* @param title Title for the alert.
* @param message Message for the alert.
* @param buttons Array of VOKAlertAction objects that correspond to button(s). Must have at least one object.
*/
+ (void)showAlertFromViewController:(UIViewController *)viewController
withTitle:(nullable NSString *)title
message:(nullable NSString *)message
buttons:(NSArray<VOKAlertAction *> *)buttons;
@end
NS_ASSUME_NONNULL_END
| //
// VOKAlertHelper.h
// VOKUtilities
//
// Created by Rachel Hyman on 6/15/15.
// Copyright (c) 2015 Vokal. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "VOKAlertAction.h"
typedef void(^VOKAlertHelperActionBlock)(void);
NS_ASSUME_NONNULL_BEGIN
@interface VOKAlertHelper : NSObject
/**
* Displays an alert in the OS-appropriate fashion.
*
* @param viewController View controller responsible for presenting the alert.
* @param title Title for the alert.
* @param message Message for the alert.
* @param buttons Array of VOKAlertAction objects that correspond to button(s). Must have at least one object.
*/
+ (void)showAlertFromViewController:(UIViewController *)viewController
withTitle:(nullable NSString *)title
message:(nullable NSString *)message
buttons:(NSArray<VOKAlertAction *> *)buttons;
@end
NS_ASSUME_NONNULL_END
|
Update disambiguation VC base class | #import "WMFArticleListTableViewController.h"
@interface WMFDisambiguationPagesViewController : WMFArticleListTableViewController
@property (nonatomic, strong, readonly) MWKArticle* article;
- (instancetype)initWithArticle:(MWKArticle*)article dataStore:(MWKDataStore*)dataStore;
@end
| #import "WMFArticleListDataSourceTableViewController.h"
@interface WMFDisambiguationPagesViewController : WMFArticleListDataSourceTableViewController
@property (nonatomic, strong, readonly) MWKArticle* article;
- (instancetype)initWithArticle:(MWKArticle*)article dataStore:(MWKDataStore*)dataStore;
@end
|
Use uint8_t and uint32_t in SHA-1 implementation. | /***************************************************************************/
/* sha.h */
/* */
/* SHA-1 code header file. */
/* Taken from the public domain implementation by Peter C. Gutmann */
/* on 2 Sep 1992, modified by Carl Ellison to be SHA-1. */
/***************************************************************************/
#ifndef _SHA_H_
#define _SHA_H_
/* Define APG_LITTLE_ENDIAN if the machine is little-endian */
#define APG_LITTLE_ENDIAN
/* Useful defines/typedefs */
typedef unsigned char BYTE ;
typedef unsigned long LONG ;
/* The SHA block size and message digest sizes, in bytes */
#define SHA_BLOCKSIZE 64
#define SHA_DIGESTSIZE 20
/* The structure for storing SHA info */
typedef struct {
LONG digest[ 5 ] ; /* Message digest */
LONG countLo, countHi ; /* 64-bit bit count */
LONG data[ 16 ] ; /* SHA data buffer */
LONG slop ; /* # of bytes saved in data[] */
} apg_SHA_INFO ;
void apg_shaInit( apg_SHA_INFO *shaInfo ) ;
void apg_shaUpdate( apg_SHA_INFO *shaInfo, BYTE *buffer, int count ) ;
void apg_shaFinal( apg_SHA_INFO *shaInfo, BYTE hash[SHA_DIGESTSIZE] ) ;
#endif /* _SHA_H_ */
| /***************************************************************************/
/* sha.h */
/* */
/* SHA-1 code header file. */
/* Taken from the public domain implementation by Peter C. Gutmann */
/* on 2 Sep 1992, modified by Carl Ellison to be SHA-1. */
/***************************************************************************/
#ifndef _SHA_H_
#define _SHA_H_
#include <stdint.h>
/* Define APG_LITTLE_ENDIAN if the machine is little-endian */
#define APG_LITTLE_ENDIAN
/* Useful defines/typedefs */
typedef uint8_t BYTE ;
typedef uint32_t LONG ;
/* The SHA block size and message digest sizes, in bytes */
#define SHA_BLOCKSIZE 64
#define SHA_DIGESTSIZE 20
/* The structure for storing SHA info */
typedef struct {
LONG digest[ 5 ] ; /* Message digest */
LONG countLo, countHi ; /* 64-bit bit count */
LONG data[ 16 ] ; /* SHA data buffer */
LONG slop ; /* # of bytes saved in data[] */
} apg_SHA_INFO ;
void apg_shaInit( apg_SHA_INFO *shaInfo ) ;
void apg_shaUpdate( apg_SHA_INFO *shaInfo, BYTE *buffer, int count ) ;
void apg_shaFinal( apg_SHA_INFO *shaInfo, BYTE hash[SHA_DIGESTSIZE] ) ;
#endif /* _SHA_H_ */
|
Use stdint.h instead of cstdint | #pragma once
#include <cstdint>
#include <string>
class SystemError
{
public:
SystemError(int errorno, const std::string& syscall, const std::string& message, const std::string& path)
: m_errorno(errorno), m_syscall(syscall), m_message(message), m_path(path)
{}
int errorno() const { return m_errorno; }
const char* syscall() const { return m_syscall.c_str(); }
const char* message() const { return m_message.c_str(); }
const char* path() const { return m_path.c_str(); }
private:
int m_errorno;
std::string m_syscall;
std::string m_message;
std::string m_path;
};
struct DiskUsage {
uint64_t available;
uint64_t free;
uint64_t total;
};
DiskUsage GetDiskUsage(const char* path);
| #pragma once
#include <stdint.h>
#include <string>
class SystemError
{
public:
SystemError(int errorno, const std::string& syscall, const std::string& message, const std::string& path)
: m_errorno(errorno), m_syscall(syscall), m_message(message), m_path(path)
{}
int errorno() const { return m_errorno; }
const char* syscall() const { return m_syscall.c_str(); }
const char* message() const { return m_message.c_str(); }
const char* path() const { return m_path.c_str(); }
private:
int m_errorno;
std::string m_syscall;
std::string m_message;
std::string m_path;
};
struct DiskUsage {
uint64_t available;
uint64_t free;
uint64_t total;
};
DiskUsage GetDiskUsage(const char* path);
|
Include <assert.h> to prevent linking error (unknown symbol 'assert'). | #include <ucontext.h>
#include "x86-decoder.h"
#include "unwind.h"
void
unw_init_arch(void)
{
x86_family_decoder_init();
}
void
unw_init_cursor_arch(ucontext_t* context, unw_cursor_t *cursor)
{
mcontext_t * mctxt = &(context->uc_mcontext);
#ifdef __CRAYXT_CATAMOUNT_TARGET
cursor->pc = (void *) mctxt->sc_rip;
cursor->bp = (void **) mctxt->sc_rbp;
cursor->sp = (void **) mctxt->sc_rsp;
#else
cursor->pc = (void *) mctxt->gregs[REG_RIP];
cursor->bp = (void **) mctxt->gregs[REG_RBP];
cursor->sp = (void **) mctxt->gregs[REG_RSP];
#endif
}
int
unw_get_reg_arch(unw_cursor_t *cursor, int reg_id, void **reg_value)
{
assert(reg_id == UNW_REG_IP);
*reg_value = cursor->pc;
return 0;
}
| #include <ucontext.h>
#include <assert.h>
#include "x86-decoder.h"
#include "unwind.h"
void
unw_init_arch(void)
{
x86_family_decoder_init();
}
void
unw_init_cursor_arch(ucontext_t* context, unw_cursor_t *cursor)
{
mcontext_t * mctxt = &(context->uc_mcontext);
#ifdef __CRAYXT_CATAMOUNT_TARGET
cursor->pc = (void *) mctxt->sc_rip;
cursor->bp = (void **) mctxt->sc_rbp;
cursor->sp = (void **) mctxt->sc_rsp;
#else
cursor->pc = (void *) mctxt->gregs[REG_RIP];
cursor->bp = (void **) mctxt->gregs[REG_RBP];
cursor->sp = (void **) mctxt->gregs[REG_RSP];
#endif
}
int
unw_get_reg_arch(unw_cursor_t *cursor, int reg_id, void **reg_value)
{
assert(reg_id == UNW_REG_IP);
*reg_value = cursor->pc;
return 0;
}
|
Remove unused protocol conformance from sample | #import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIAlertViewDelegate, UIActionSheetDelegate>
@property (nonatomic, strong) Class alertControllerClass;
@property (nonatomic, strong) IBOutlet UIButton *showAlertButton;
@property (nonatomic, strong) IBOutlet UIButton *showActionSheetButton;
@property (nonatomic, assign) BOOL alertDefaultActionExecuted;
@property (nonatomic, assign) BOOL alertCancelActionExecuted;
@property (nonatomic, assign) BOOL alertDestroyActionExecuted;
- (IBAction)showAlert:(id)sender;
- (IBAction)showActionSheet:(id)sender;
@end
| #import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (nonatomic, strong) Class alertControllerClass;
@property (nonatomic, strong) IBOutlet UIButton *showAlertButton;
@property (nonatomic, strong) IBOutlet UIButton *showActionSheetButton;
@property (nonatomic, assign) BOOL alertDefaultActionExecuted;
@property (nonatomic, assign) BOOL alertCancelActionExecuted;
@property (nonatomic, assign) BOOL alertDestroyActionExecuted;
- (IBAction)showAlert:(id)sender;
- (IBAction)showActionSheet:(id)sender;
@end
|
Use boost::move rather than std::move which seems to hate some versions ofr G++ | #ifndef FUTURE_H_INCLUDED
#define FUTURE_H_INCLUDED
#include <boost/thread/thread.hpp>
#include <boost/thread/future.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility/result_of.hpp>
namespace thread {
template<typename Func>
boost::shared_future<typename boost::result_of<Func()>::type> submit_task(Func f) {
typedef typename boost::result_of<Func()>::type ResultType;
typedef boost::packaged_task<ResultType> PackagedTaskType;
PackagedTaskType task(f);
boost::shared_future<ResultType> res(task.get_future());
boost::thread task_thread(std::move(task));
return res;
}
}
#endif // FUTURE_H_INCLUDED
| #ifndef FUTURE_H_INCLUDED
#define FUTURE_H_INCLUDED
#include <boost/thread/thread.hpp>
#include <boost/thread/future.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility/result_of.hpp>
namespace thread {
template<typename Func>
boost::shared_future<typename boost::result_of<Func()>::type> submit_task(Func f) {
typedef typename boost::result_of<Func()>::type ResultType;
typedef boost::packaged_task<ResultType> PackagedTaskType;
PackagedTaskType task(f);
boost::shared_future<ResultType> res(task.get_future());
boost::thread task_thread(boost::move(task));
return res;
}
}
#endif // FUTURE_H_INCLUDED
|
Fix test case and convert fully to FileCheck. | // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
int g();
int foo(int i) {
return g(i);
}
int g(int i) {
return g(i);
}
// rdar://6110827
typedef void T(void);
void test3(T f) {
f();
}
int a(int);
int a() {return 1;}
// RUN: grep 'define void @f0()' %t
void f0() {}
void f1();
// RUN: grep 'call void @f1()' %t
void f2(void) {
f1(1, 2, 3);
}
// RUN: grep 'define void @f1()' %t
void f1() {}
// RUN: grep 'define .* @f3' %t | not grep -F '...'
struct foo { int X, Y, Z; } f3() {
while (1) {}
}
// PR4423 - This shouldn't crash in codegen
void f4() {}
void f5() { f4(42); }
// Qualifiers on parameter types shouldn't make a difference.
static void f6(const float f, const float g) {
}
void f7(float f, float g) {
f6(f, g);
// CHECK: define void @f7(float{{.*}}, float{{.*}})
// CHECK: call void @f6(float{{.*}}, float{{.*}})
}
| // RUN: %clang_cc1 %s -emit-llvm -o - -verify | FileCheck %s
int g();
int foo(int i) {
return g(i);
}
int g(int i) {
return g(i);
}
// rdar://6110827
typedef void T(void);
void test3(T f) {
f();
}
int a(int);
int a() {return 1;}
void f0() {}
// CHECK: define void @f0()
void f1();
void f2(void) {
// CHECK: call void @f1()
f1(1, 2, 3);
}
// CHECK: define void @f1()
void f1() {}
// CHECK: define {{.*}} @f3()
struct foo { int X, Y, Z; } f3() {
while (1) {}
}
// PR4423 - This shouldn't crash in codegen
void f4() {}
void f5() { f4(42); } //expected-warning {{too many arguments}}
// Qualifiers on parameter types shouldn't make a difference.
static void f6(const float f, const float g) {
}
void f7(float f, float g) {
f6(f, g);
// CHECK: define void @f7(float{{.*}}, float{{.*}})
// CHECK: call void @f6(float{{.*}}, float{{.*}})
}
|
Fix error() if srcLoc.file is null or !srcLoc.isValid() | #pragma once
#include <fstream>
#include <llvm/ADT/StringRef.h>
inline std::ostream& operator<<(std::ostream& stream, llvm::StringRef string) {
return stream.write(string.data(), string.size());
}
template<typename... Args>
[[noreturn]] inline void error(SrcLoc srcLoc, Args&&... args) {
std::cout << srcLoc.file << ':';
if (srcLoc.isValid()) std::cout << srcLoc.line << ':' << srcLoc.column << ':';
std::cout << " error: ";
using expander = int[];
(void)expander{0, (void(std::cout << std::forward<Args>(args)), 0)...};
// Output caret.
std::ifstream file(srcLoc.file);
while (--srcLoc.line) file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::string line;
std::getline(file, line);
std::cout << '\n' << line << '\n';
while (--srcLoc.column) std::cout << ' ';
std::cout << "^\n";
exit(1);
}
| #pragma once
#include <fstream>
#include <llvm/ADT/StringRef.h>
inline std::ostream& operator<<(std::ostream& stream, llvm::StringRef string) {
return stream.write(string.data(), string.size());
}
template<typename... Args>
[[noreturn]] inline void error(SrcLoc srcLoc, Args&&... args) {
if (srcLoc.file) {
std::cout << srcLoc.file << ':';
if (srcLoc.isValid()) std::cout << srcLoc.line << ':' << srcLoc.column << ':';
} else {
std::cout << "<unknown file>:";
}
std::cout << " error: ";
using expander = int[];
(void)expander{0, (void(std::cout << std::forward<Args>(args)), 0)...};
if (srcLoc.file && srcLoc.isValid()) {
// Output caret.
std::ifstream file(srcLoc.file);
while (--srcLoc.line) file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::string line;
std::getline(file, line);
std::cout << '\n' << line << '\n';
while (--srcLoc.column) std::cout << ' ';
std::cout << "^\n";
}
exit(1);
}
|
Convert to pragma once in test functions | #ifndef MMSTESTFUNC_H
#define MMSTESTFUNC_H
#include "Function.h"
#include "FunctionInterface.h"
class MMSTestFunc;
template <>
InputParameters validParams<MMSTestFunc>();
/**
* Function of RHS for manufactured solution in spatial_constant_helmholtz test
*/
class MMSTestFunc : public Function, public FunctionInterface
{
public:
MMSTestFunc(const InputParameters & parameters);
virtual Real value(Real t, const Point & p) const override;
protected:
Real _length;
const Function & _a;
const Function & _b;
Real _d;
Real _h;
Real _g_0_real;
Real _g_0_imag;
Real _g_l_real;
Real _g_l_imag;
MooseEnum _component;
};
#endif // MMSTESTFUNC_H
| #pragma once
#include "Function.h"
#include "FunctionInterface.h"
class MMSTestFunc;
template <>
InputParameters validParams<MMSTestFunc>();
/**
* Function of RHS for manufactured solution in spatial_constant_helmholtz test
*/
class MMSTestFunc : public Function, public FunctionInterface
{
public:
MMSTestFunc(const InputParameters & parameters);
virtual Real value(Real t, const Point & p) const override;
protected:
Real _length;
const Function & _a;
const Function & _b;
Real _d;
Real _h;
Real _g_0_real;
Real _g_0_imag;
Real _g_l_real;
Real _g_l_imag;
MooseEnum _component;
};
|
Make MinimumUsedBitsTracker thread safe for both reads and writes | // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <algorithm>
#include <vespa/document/bucket/bucketid.h>
namespace storage {
/**
* Utility class for keeping track of the lowest used bits count seen
* across a set of buckets.
*
* Not threadsafe by itself.
*/
class MinimumUsedBitsTracker
{
uint32_t _minUsedBits;
public:
MinimumUsedBitsTracker()
: _minUsedBits(58)
{}
/**
* Returns true if new bucket led to a decrease in the used bits count.
*/
bool update(const document::BucketId& bucket) {
if (bucket.getUsedBits() < _minUsedBits) {
_minUsedBits = bucket.getUsedBits();
return true;
}
return false;
}
uint32_t getMinUsedBits() const {
return _minUsedBits;
}
void setMinUsedBits(uint32_t minUsedBits) {
_minUsedBits = minUsedBits;
}
};
}
| // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/document/bucket/bucketid.h>
#include <atomic>
namespace storage {
/**
* Utility class for keeping track of the lowest used bits count seen
* across a set of buckets.
*
* Thread safe for reads and writes.
*/
class MinimumUsedBitsTracker
{
std::atomic<uint32_t> _min_used_bits;
public:
constexpr MinimumUsedBitsTracker() noexcept
: _min_used_bits(58)
{}
/**
* Returns true iff new bucket led to a decrease in the used bits count.
*/
bool update(const document::BucketId& bucket) noexcept {
const uint32_t bucket_bits = bucket.getUsedBits();
uint32_t current_bits = _min_used_bits.load(std::memory_order_relaxed);
if (bucket_bits < current_bits) {
while (!_min_used_bits.compare_exchange_strong(current_bits, bucket_bits,
std::memory_order_relaxed,
std::memory_order_relaxed))
{
if (bucket_bits >= current_bits) {
return false; // We've raced with another writer that had lower or equal bits to our own bucket.
}
}
return true;
}
return false;
}
[[nodiscard]] uint32_t getMinUsedBits() const noexcept {
return _min_used_bits.load(std::memory_order_relaxed);
}
void setMinUsedBits(uint32_t minUsedBits) noexcept {
_min_used_bits.store(minUsedBits, std::memory_order_relaxed);
}
};
}
|
Add step for each player on choose your cat scene |
#include "debug.h"
#include "input.h"
#include "scene.h"
#include "sound.h"
#include "controller.h"
#include "controllers/chooseyourcat.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
NEW_CONTROLLER(ChooseYourCat);
static void p1_confirm() {
Sound_playSE(FX_SELECT);
Scene_close();
Scene_load(SCENE_PRESSSTART);
}
static void p2_confirm() {
Sound_playSE(FX_SELECT);
Scene_close();
Scene_load(SCENE_PRESSSTART);
}
static void ChooseYourCatController_init() {
EVENT_ASSOCIATE(press, P1_MARU, p1_confirm);
EVENT_ASSOCIATE(press, P2_MARU, p2_confirm);
logprint(success_msg);
}
|
#include "debug.h"
#include "input.h"
#include "scene.h"
#include "sound.h"
#include "controller.h"
#include "scenes/chooseyourcat.h"
#include "controllers/chooseyourcat.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
static int P1_HAS_CHOSEN = false;
/* false -> P1 escolhe o gato;
true -> P2 escolhe o gato. */
NEW_CONTROLLER(ChooseYourCat);
static void p1_confirm() {
if (!P1_HAS_CHOSEN) {
Sound_playSE(FX_SELECT);
P1_HAS_CHOSEN = true;
}
}
static void p2_confirm() {
if (P1_HAS_CHOSEN) {
/* code */
Sound_playSE(FX_SELECT);
Scene_close();
Scene_load(SCENE_PRESSSTART);
}
}
static void ChooseYourCatController_init() {
EVENT_ASSOCIATE(press, P1_MARU, p1_confirm);
EVENT_ASSOCIATE(press, P2_MARU, p2_confirm);
logprint(success_msg);
}
|
Add c version of trackerstate example | /** @file
@brief Implementation
@date 2014
@author
Ryan Pavlik
<ryan@sensics.com>
<http://sensics.com>
*/
/*
// Copyright 2014 Sensics, Inc.
//
// All rights reserved.
//
// (Final version intended to be licensed under
// the Apache License, Version 2.0)
*/
/* Internal Includes */
#include <osvr/ClientKit/ContextC.h>
#include <osvr/ClientKit/InterfaceC.h>
#include <osvr/ClientKit/InterfaceStateC.h>
/* Library/third-party includes */
/* - none */
// Standard includes
#include <stdio.h>
int main() {
OSVR_ClientContext ctx =
osvrClientInit("org.opengoggles.exampleclients.TrackerState");
OSVR_ClientInterface lefthand = NULL;
/* This is just one of the paths. You can also use:
* /me/hands/right
* /me/head
*/
osvrClientGetInterface(ctx, "/me/hands/left", &lefthand);
// Pretend that this is your application's mainloop.
int i;
for (i = 0; i < 1000000; ++i) {
osvrClientUpdate(ctx);
if (i % 100) {
// Every so often let's read the tracker state.
// Similar methods exist for all other stock report types.
OSVR_PoseState state;
OSVR_TimeValue timestamp;
OSVR_ReturnCode ret =
osvrGetPoseState(lefthand, ×tamp, &state);
if (ret != OSVR_RETURN_SUCCESS) {
printf("No pose state!\n");
} else {
printf("Got POSE state: Position = (%f, %f, %f), orientation = "
"(%f, %f, "
"%f, %f)\n",
report->pose.translation.data[0],
report->pose.translation.data[1],
report->pose.translation.data[2],
osvrQuatGetW(&(report->pose.rotation)),
osvrQuatGetX(&(report->pose.rotation)),
osvrQuatGetY(&(report->pose.rotation)),
osvrQuatGetZ(&(report->pose.rotation)));
}
}
}
osvrClientShutdown(ctx);
printf("Library shut down, exiting.\n");
return 0;
}
| |
Add a testcase for svn r129964 (Neon load/store intrinsic alignments). | // RUN: %clang_cc1 -triple thumbv7-apple-darwin \
// RUN: -target-abi apcs-gnu \
// RUN: -target-cpu cortex-a8 \
// RUN: -mfloat-abi soft \
// RUN: -target-feature +soft-float-abi \
// RUN: -ffreestanding \
// RUN: -emit-llvm -w -o - %s | FileCheck %s
#include <arm_neon.h>
// Radar 9311427: Check that alignment specifier is used in Neon load/store
// intrinsics.
typedef float AlignedAddr __attribute__ ((aligned (16)));
void t1(AlignedAddr *addr1, AlignedAddr *addr2) {
// CHECK: call <4 x float> @llvm.arm.neon.vld1.v4f32(i8* %{{.*}}, i32 16)
float32x4_t a = vld1q_f32(addr1);
// CHECK: call void @llvm.arm.neon.vst1.v4f32(i8* %{{.*}}, <4 x float> %{{.*}}, i32 16)
vst1q_f32(addr2, a);
}
| |
Declare PPB_Core as a struct, not a class. (Prevents Clang warning) | // Copyright 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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CORE_H_
#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CORE_H_
#include "native_client/src/include/nacl_macros.h"
class PPB_Core;
namespace ppapi_proxy {
// Implements the untrusted side of the PPB_Core interface.
// We will also need an rpc service to implement the trusted side, which is a
// very thin wrapper around the PPB_Core interface returned from the browser.
class PluginCore {
public:
// Return an interface pointer usable by PPAPI plugins.
static const PPB_Core* GetInterface();
// Mark the calling thread as the main thread for IsMainThread.
static void MarkMainThread();
private:
NACL_DISALLOW_COPY_AND_ASSIGN(PluginCore);
};
} // namespace ppapi_proxy
#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CORE_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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CORE_H_
#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CORE_H_
#include "native_client/src/include/nacl_macros.h"
struct PPB_Core;
namespace ppapi_proxy {
// Implements the untrusted side of the PPB_Core interface.
// We will also need an rpc service to implement the trusted side, which is a
// very thin wrapper around the PPB_Core interface returned from the browser.
class PluginCore {
public:
// Return an interface pointer usable by PPAPI plugins.
static const PPB_Core* GetInterface();
// Mark the calling thread as the main thread for IsMainThread.
static void MarkMainThread();
private:
NACL_DISALLOW_COPY_AND_ASSIGN(PluginCore);
};
} // namespace ppapi_proxy
#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CORE_H_
|
Fix C solution for Problem039 | #include <stdio.h>
#define MAX 1000
int main() {
int i, j, k, maxP;
int ps[1001];
for(i = 1; i <= MAX; i++) {
for(j = i;j <= MAX; j++) {
for(k = j; (k * k) < (i * i + j * j); k++);
if((i * i + j * j) == (k * k) && (i + j + k) <= MAX) {
ps[i+j+k]++;
}
}
}
for(i = 1; i <= MAX; i++) {
if(ps[maxP] < ps[i])
maxP = i;
}
printf("%d\n",maxP);
return 0;
}
| #include <stdio.h>
#define MAX 1000
int main() {
int i, j , k, maxP = 1;
int ps[1001];
for (i=0; i <= MAX; ps[++i] =0);
for(i = 1; i <= MAX; i++) {
for(j = i;j <= MAX; j++) {
for(k = j; (k * k) < (i * i + j * j); k++);
if((i * i + j * j) == (k * k) && (i + j + k) <= MAX) {
ps[i+j+k] += 1;
}
}
}
for(i = 1; i <= MAX; i++) {
if(ps[maxP] < ps[i])
maxP = i;
}
printf("%d\n",maxP);
return 0;
}
|
Fix typo in step function comment | {% import "common_macros.inc.c" as util with context -%}
{% set stepfun = g.stepFunctions[targetStep] -%}
#include "{{g.name}}.h"
/**
* Step function defintion for "{{stepfun.collName}}"
*/
void {{util.qualified_step_name(stepfun)}}({{ util.print_tag(stepfun.tag, typed=True)
}}{{ util.print_bindings(stepfun.inputItems, typed=True)
}}{{util.g_ctx_param()}}) {
{% if stepfun.rangedInputItems %}
//
// INPUTS
//
{% call util.render_indented(1) -%}
{{ util.render_step_inputs(stepfun.rangedInputItems) }}
{% endcall -%}
{% endif %}
//
// OUTPUTS
//
{% call util.render_indented(1) -%}
{{ util.render_step_outputs(stepfun.outputs) }}
{%- endcall %}
}
| {% import "common_macros.inc.c" as util with context -%}
{% set stepfun = g.stepFunctions[targetStep] -%}
#include "{{g.name}}.h"
/**
* Step function definition for "{{stepfun.collName}}"
*/
void {{util.qualified_step_name(stepfun)}}({{ util.print_tag(stepfun.tag, typed=True)
}}{{ util.print_bindings(stepfun.inputItems, typed=True)
}}{{util.g_ctx_param()}}) {
{% if stepfun.rangedInputItems %}
//
// INPUTS
//
{% call util.render_indented(1) -%}
{{ util.render_step_inputs(stepfun.rangedInputItems) }}
{% endcall -%}
{% endif %}
//
// OUTPUTS
//
{% call util.render_indented(1) -%}
{{ util.render_step_outputs(stepfun.outputs) }}
{%- endcall %}
}
|
Mark _slave_entry to never return | /*
* Copyright (c) 2012-2016
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com
*/
#include <sys/cdefs.h>
#include <smpc/smc.h>
#include <cpu/instructions.h>
#include <cpu/frt.h>
#include <cpu/intc.h>
#include <cpu/map.h>
#include <cpu/slave.h>
static void _slave_entry(void);
static void _default_entry(void);
static void (*_entry)(void) = _default_entry;
void
cpu_slave_init(void)
{
smpc_smc_sshoff_call();
cpu_slave_entry_clear();
cpu_intc_ihr_set(INTC_INTERRUPT_SLAVE_ENTRY, _slave_entry);
smpc_smc_sshon_call();
}
void
cpu_slave_entry_set(void (*entry)(void))
{
_entry = (entry != NULL) ? entry : _default_entry;
}
static void
_slave_entry(void)
{
while (true) {
while (((cpu_frt_status_get()) & FRTCS_ICF) == 0x00);
cpu_frt_control_chg((uint8_t)~FRTCS_ICF);
_entry();
}
}
static void
_default_entry(void)
{
}
| /*
* Copyright (c) 2012-2016
* See LICENSE for details.
*
* Israel Jacquez <mrkotfw@gmail.com
*/
#include <sys/cdefs.h>
#include <smpc/smc.h>
#include <cpu/instructions.h>
#include <cpu/frt.h>
#include <cpu/intc.h>
#include <cpu/map.h>
#include <cpu/slave.h>
static void _slave_entry(void);
static void _default_entry(void);
static void (*_entry)(void) = _default_entry;
void
cpu_slave_init(void)
{
smpc_smc_sshoff_call();
cpu_slave_entry_clear();
cpu_intc_ihr_set(INTC_INTERRUPT_SLAVE_ENTRY, _slave_entry);
smpc_smc_sshon_call();
}
void
cpu_slave_entry_set(void (*entry)(void))
{
_entry = (entry != NULL) ? entry : _default_entry;
}
static void __noreturn
_slave_entry(void)
{
while (true) {
while (((cpu_frt_status_get()) & FRTCS_ICF) == 0x00);
cpu_frt_control_chg((uint8_t)~FRTCS_ICF);
_entry();
}
}
static void
_default_entry(void)
{
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.