Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Disable secure function warnings via pragma | /*=========================================================================
This file is part of the XIOT library.
Copyright (C) 2008-2009 EDF R&D
Author: Kristian Sons (xiot@actor3d.com)
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
The XIOT library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser Public License for more details.
You should have received a copy of the GNU Lesser Public License
along with XIOT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301 USA
=========================================================================*/
#ifndef __XIOTConfigure_h
#define __XIOTConfigure_h
#include "xiot_export.h"
#if defined(_MSC_VER)
#pragma warning(disable : 4275) /* non-DLL-interface base class used */
#pragma warning(disable : 4251) /* needs to have dll-interface to be used by clients */
/* No warning for safe windows only functions */
#define _CRT_SECURE_NO_WARNINGS
#endif
#endif // __x3dexporterConfigure_h
| /*=========================================================================
This file is part of the XIOT library.
Copyright (C) 2008-2009 EDF R&D
Author: Kristian Sons (xiot@actor3d.com)
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
The XIOT library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser Public License for more details.
You should have received a copy of the GNU Lesser Public License
along with XIOT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301 USA
=========================================================================*/
#ifndef __XIOTConfigure_h
#define __XIOTConfigure_h
#include "xiot_export.h"
#if defined(_MSC_VER)
#pragma warning(disable : 4275) /* non-DLL-interface base class used */
#pragma warning(disable : 4251) /* needs to have dll-interface to be used by clients */
#pragma warning(disable : 4996) /* */
#endif
#endif // __x3dexporterConfigure_h
|
Change parent class from LinearAllocator to Allocator. | #include "LinearAllocator.h"
#ifndef STACKALLOCATOR_H
#define STACKALLOCATOR_H
class StackAllocator : public LinearAllocator {
public:
/* Allocation of real memory */
StackAllocator(const long totalSize);
/* Frees all memory */
virtual ~StackAllocator();
/* Allocate virtual memory */
virtual void* Allocate(const std::size_t size, const std::size_t alignment) override;
/* Frees virtual memory */
virtual void Free(void* ptr) override;
};
#endif /* STACKALLOCATOR_H */ | #include "Allocator.h"
#ifndef STACKALLOCATOR_H
#define STACKALLOCATOR_H
class StackAllocator : public Allocator {
protected:
/* Offset from the start of the memory block */
std::size_t m_offset;
public:
/* Allocation of real memory */
StackAllocator(const long totalSize);
/* Frees all memory */
virtual ~StackAllocator();
/* Allocate virtual memory */
virtual void* Allocate(const std::size_t size, const std::size_t alignment) override;
/* Frees virtual memory */
virtual void Free(void* ptr) override;
/* Frees all virtual memory */
virtual void Reset() override;
};
#endif /* STACKALLOCATOR_H */ |
Update with new lefty, fixing many bugs and supporting new features | /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* Lefteris Koutsofios - AT&T Bell Laboratories */
#ifndef _DISPLAY_H
#define _DISPLAY_H
void Dinit(void);
void Dterm(void);
void Dtrace(Tobj, int);
#endif /* _DISPLAY_H */
#ifdef __cplusplus
}
#endif
| /* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
* This software is part of the graphviz package *
* http://www.graphviz.org/ *
* *
* Copyright (c) 1994-2004 AT&T Corp. *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Corp. *
* *
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* Lefteris Koutsofios - AT&T Labs Research */
#ifndef _DISPLAY_H
#define _DISPLAY_H
void Dinit (void);
void Dterm (void);
void Dtrace (Tobj, int);
#endif /* _DISPLAY_H */
#ifdef __cplusplus
}
#endif
|
Add the user stack module. | /* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
* stack_user.c
*
* Code which interfaces ocfs2 with fs/dlm and a userspace stack.
*
* Copyright (C) 2007 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include "stackglue.h"
static int __init user_stack_init(void)
{
return 0;
}
static void __exit user_stack_exit(void)
{
}
MODULE_AUTHOR("Oracle");
MODULE_DESCRIPTION("ocfs2 driver for userspace cluster stacks");
MODULE_LICENSE("GPL");
module_init(user_stack_init);
module_exit(user_stack_exit);
| |
Add callbacks for live query | //
// AVSubscription.h
// AVOS
//
// Created by Tang Tianyong on 15/05/2017.
// Copyright © 2017 LeanCloud Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AVQuery.h"
#import "AVDynamicObject.h"
NS_ASSUME_NONNULL_BEGIN
@protocol AVSubscriptionDelegate <NSObject>
@end
@interface AVSubscriptionOptions : AVDynamicObject
@end
@interface AVSubscription : NSObject
@property (nonatomic, weak, nullable) id<AVSubscriptionDelegate> delegate;
@property (nonatomic, strong, readonly) AVQuery *query;
@property (nonatomic, strong, readonly, nullable) AVSubscriptionOptions *options;
- (instancetype)initWithQuery:(AVQuery *)query
options:(nullable AVSubscriptionOptions *)options;
@end
NS_ASSUME_NONNULL_END
| //
// AVSubscription.h
// AVOS
//
// Created by Tang Tianyong on 15/05/2017.
// Copyright © 2017 LeanCloud Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AVQuery.h"
#import "AVDynamicObject.h"
@class AVSubscription;
NS_ASSUME_NONNULL_BEGIN
@protocol AVSubscriptionDelegate <NSObject>
- (void)subscription:(AVSubscription *)subscription objectDidEnter:(id)object;
- (void)subscription:(AVSubscription *)subscription objectDidLeave:(id)object;
- (void)subscription:(AVSubscription *)subscription objectDidCreate:(id)object;
- (void)subscription:(AVSubscription *)subscription objectDidUpdate:(id)object;
- (void)subscription:(AVSubscription *)subscription objectDidDelete:(id)object;
- (void)subscription:(AVSubscription *)subscription userDidLogin:(AVUser *)user;
@end
@interface AVSubscriptionOptions : AVDynamicObject
@end
@interface AVSubscription : NSObject
@property (nonatomic, weak, nullable) id<AVSubscriptionDelegate> delegate;
@property (nonatomic, strong, readonly) AVQuery *query;
@property (nonatomic, strong, readonly, nullable) AVSubscriptionOptions *options;
- (instancetype)initWithQuery:(AVQuery *)query
options:(nullable AVSubscriptionOptions *)options;
@end
NS_ASSUME_NONNULL_END
|
Add missing Q_OBJECT to PassabilityAgent | #ifndef PASSABILITYAGENT_H
#define PASSABILITYAGENT_H
#include <QPointF>
#include <QObject>
#include "quickpather_global.h"
class AbstractEntity;
// Not pure abstract, because we want it to be usable in the Q_PROPERTY macro
// and not force derived classes to multiply derive from it and QObject.
class QUICKPATHERSHARED_EXPORT PassabilityAgent : public QObject
{
public:
virtual bool isPassable(const QPointF &pos, AbstractEntity *entity);
};
#endif // PASSABILITYAGENT_H
| #ifndef PASSABILITYAGENT_H
#define PASSABILITYAGENT_H
#include <QPointF>
#include <QObject>
#include "quickpather_global.h"
class AbstractEntity;
// Not pure abstract, because we want it to be usable in the Q_PROPERTY macro
// and not force derived classes to multiply derive from it and QObject.
class QUICKPATHERSHARED_EXPORT PassabilityAgent : public QObject
{
Q_OBJECT
public:
virtual bool isPassable(const QPointF &pos, AbstractEntity *entity);
};
#endif // PASSABILITYAGENT_H
|
Use my_sleep instead of nanosleep for portability | /* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <NdbSleep.h>
int
NdbSleep_MilliSleep(int milliseconds){
int result = 0;
struct timespec sleeptime;
sleeptime.tv_sec = milliseconds / 1000;
sleeptime.tv_nsec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000;
result = nanosleep(&sleeptime, NULL);
return result;
}
int
NdbSleep_SecSleep(int seconds){
int result = 0;
result = sleep(seconds);
return result;
}
| /* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <my_sys.h>
#include <NdbSleep.h>
int
NdbSleep_MilliSleep(int milliseconds){
my_sleep(milliseconds*1000);
return 0;
#if 0
int result = 0;
struct timespec sleeptime;
sleeptime.tv_sec = milliseconds / 1000;
sleeptime.tv_nsec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000;
result = nanosleep(&sleeptime, NULL);
return result;
#endif
}
int
NdbSleep_SecSleep(int seconds){
int result = 0;
result = sleep(seconds);
return result;
}
|
Fix ACPICA word-size types - u64 didn't match UINT64 | #define ACPI_MACHINE_WIDTH 64
#define ACPI_SINGLE_THREADED
#define ACPI_USE_LOCAL_CACHE
#define ACPI_INLINE inline
#define ACPI_USE_NATIVE_DIVIDE
#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
#ifdef ACPI_FULL_DEBUG
#define ACPI_DEBUG_OUTPUT
#define ACPI_DISASSEMBLER
// Depends on threading support
#define ACPI_DEBUGGER
//#define ACPI_DBG_TRACK_ALLOCATIONS
#define ACPI_GET_FUNCTION_NAME __FUNCTION__
#else
#define ACPI_GET_FUNCTION_NAME ""
#endif
#define ACPI_PHYS_BASE 0x100000000
#include <stdint.h>
#include <stdarg.h>
#define AcpiOsPrintf printf
#define AcpiOsVprintf vprintf
struct acpi_table_facs;
uint32_t AcpiOsReleaseGlobalLock(struct acpi_table_facs* facs);
uint32_t AcpiOsAcquireGlobalLock(struct acpi_table_facs* facs);
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acquired) Acquired = AcpiOsAcquireGlobalLock(GLptr)
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pending) Pending = AcpiOsReleaseGlobalLock(GLptr)
| #define ACPI_MACHINE_WIDTH 64
#define ACPI_SINGLE_THREADED
#define ACPI_USE_LOCAL_CACHE
#define ACPI_INLINE inline
#define ACPI_USE_NATIVE_DIVIDE
#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
#ifdef ACPI_FULL_DEBUG
#define ACPI_DEBUG_OUTPUT
#define ACPI_DISASSEMBLER
// Depends on threading support
#define ACPI_DEBUGGER
//#define ACPI_DBG_TRACK_ALLOCATIONS
#define ACPI_GET_FUNCTION_NAME __FUNCTION__
#else
#define ACPI_GET_FUNCTION_NAME ""
#endif
#define ACPI_PHYS_BASE 0x100000000
#include <stdint.h>
#include <stdarg.h>
#define AcpiOsPrintf printf
#define AcpiOsVprintf vprintf
struct acpi_table_facs;
uint32_t AcpiOsReleaseGlobalLock(struct acpi_table_facs* facs);
uint32_t AcpiOsAcquireGlobalLock(struct acpi_table_facs* facs);
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acquired) Acquired = AcpiOsAcquireGlobalLock(GLptr)
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pending) Pending = AcpiOsReleaseGlobalLock(GLptr)
#define COMPILER_DEPENDENT_UINT64 uint64_t
#define COMPILER_DEPENDENT_UINT32 uint32_t
|
Add virtual toString() to Matcher | #ifndef HAMCREST_MATCHER_H
#define HAMCREST_MATCHER_H
#include "selfdescribing.h"
namespace Hamcrest {
class Description;
/**
* A matcher over acceptable values.
* A matcher is able to describe itself to give feedback when it fails.
*
* @see BaseMatcher
*/
template <typename T>
class Matcher : public SelfDescribing
{
public:
virtual ~Matcher() {}
/**
* Evaluates the matcher for argument <var>item</var>.
*
* @param item the object against which the matcher is evaluated.
* @return <code>true</code> if <var>item</var> matches, otherwise <code>false</code>.
*
* @see BaseMatcher
*/
virtual bool matches(const T &item) const = 0;
/**
* Generate a description of why the matcher has not accepted the item.
* The description will be part of a larger description of why a matching
* failed, so it should be concise.
* This method assumes that <code>matches(item)</code> is false, but
* will not check this.
*
* @param item The item that the Matcher has rejected.
* @param mismatchDescription
* The description to be built or appended to.
*/
virtual void describeMismatch(const T &item, Description &mismatchDescription) const = 0;
};
} // namespace Hamcrest
#endif // HAMCREST_MATCHER_H
| #ifndef HAMCREST_MATCHER_H
#define HAMCREST_MATCHER_H
#include "selfdescribing.h"
namespace Hamcrest {
class Description;
/**
* A matcher over acceptable values.
* A matcher is able to describe itself to give feedback when it fails.
*
* @see BaseMatcher
*/
template <typename T>
class Matcher : public SelfDescribing
{
public:
virtual ~Matcher() {}
/**
* Evaluates the matcher for argument <var>item</var>.
*
* @param item the object against which the matcher is evaluated.
* @return <code>true</code> if <var>item</var> matches, otherwise <code>false</code>.
*
* @see BaseMatcher
*/
virtual bool matches(const T &item) const = 0;
/**
* Generate a description of why the matcher has not accepted the item.
* The description will be part of a larger description of why a matching
* failed, so it should be concise.
* This method assumes that <code>matches(item)</code> is false, but
* will not check this.
*
* @param item The item that the Matcher has rejected.
* @param mismatchDescription
* The description to be built or appended to.
*/
virtual void describeMismatch(const T &item, Description &mismatchDescription) const = 0;
virtual QString toString() const = 0;
};
} // namespace Hamcrest
#endif // HAMCREST_MATCHER_H
|
Add missing parameter name in bd_is_plugin_available protype | #include <glib.h>
#ifndef BD_LIB
#define BD_LIB
#include "plugins.h"
#include "plugin_apis/lvm.h"
gboolean bd_init (BDPluginSpec *force_plugins);
gboolean bd_reinit (BDPluginSpec *force_plugins, gboolean replace);
gchar** bd_get_available_plugin_names ();
gboolean bd_is_plugin_available (BDPlugin);
#endif /* BD_LIB */
| #include <glib.h>
#ifndef BD_LIB
#define BD_LIB
#include "plugins.h"
#include "plugin_apis/lvm.h"
gboolean bd_init (BDPluginSpec *force_plugins);
gboolean bd_reinit (BDPluginSpec *force_plugins, gboolean replace);
gchar** bd_get_available_plugin_names ();
gboolean bd_is_plugin_available (BDPlugin plugin);
#endif /* BD_LIB */
|
Fix 'make distcheck' (homebrew acceptance test) | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2013 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <internal.h> /* getenv, sytem, snprintf */
int main(void)
{
#ifndef WIN32
char *srcdir = getenv("srcdir");
char command[FILENAME_MAX];
int status;
snprintf(command, FILENAME_MAX, "%s/tools/cbc version 2>&1", srcdir);
status = system(command);
if (status == -1 || WIFSIGNALED(status) || WEXITSTATUS(status) != 0) {
return 1;
}
snprintf(command, FILENAME_MAX, "%s/tools/cbc help 2>&1", srcdir);
if (status == -1 || WIFSIGNALED(status) || WEXITSTATUS(status) != 0) {
return 1;
}
#endif
return 0;
}
| /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2013 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <internal.h> /* getenv, system, snprintf */
int main(void)
{
#ifndef WIN32
int status;
status = system("./tools/cbc version 2>&1");
if (status == -1 || WIFSIGNALED(status) || WEXITSTATUS(status) != 0) {
return 1;
}
status = system("./tools/cbc help 2>&1");
if (status == -1 || WIFSIGNALED(status) || WEXITSTATUS(status) != 0) {
return 1;
}
#endif
return 0;
}
|
Add initial work on a commmon C interface. | #ifndef __MEMORY_ACCESS__
#define __MEMORY_ACCESS__
//TODO: File level documentations.
//TODO: Define the different process_handle_t
#define pid_t uint_t
/**
* This struct represents an error.
*
* error_number is the error as returned by the OS, 0 for no error.
* description is a null-terminated string.
**/
typedef struct {
int error_number;
char *description;
} error_t;
/**
* This struct represents the error releated parts of a response to a function
* call.
*
* fatal_error may point to an error_t that made the operation fail or be NULL.
* soft_errors may be an array of non-fatal errors or be NULL.
* soft_errors_count is the number errors in soft_errors (0 for no array).
* soft_errors_capacity is the capacity of soft_errors (0 for no array).
**/
typedef struct {
error_t *fatal_error;
error_t *soft_errors;
size_t soft_errors_count;
size_t soft_errors_capacity;
} response_errors_t;
/**
* This struct represents a region of readable contiguos memory of a process.
*
* No readable memory can be contiguos to this region, it's maximal in its
* upper bound.
*
* Note that this region is not necessary equivalent to the OS's region.
**/
typedef struct {
void *start_address;
size_t length;
} memory_region_t;
/**
* Response for an open_process_handle request, with the handle and any possible
* error.
**/
typedef struct {
response_errors_t errors;
process_handle_t process_handle;
} process_handle_response_t;
//TODO: Add doc.
process_handle_response_t *open_process_handle(pid_t pid);
//TODO: Add doc.
response_errors_t *close_process_handle(process_handle_t *process_handle);
//TODO: Add doc.
memory_region_response_t get_next_readable_memory_region(
process_handle_t handle, void *start_address);
#endif /* __MEMORY_ACCESS__ */
| |
Use a spool directory under /tmp for testing purposes | #include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "../marquise.h"
void test_init() {
marquise_ctx *ctx = marquise_init("test");
g_assert_nonnull(ctx);
}
int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/marquise_init/init", test_init);
return g_test_run();
}
| #include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "../marquise.h"
void test_init() {
setenv("MARQUISE_SPOOL_DIR", "/tmp", 1);
mkdir("/tmp/marquisetest", 0700);
marquise_ctx *ctx = marquise_init("marquisetest");
g_assert_nonnull(ctx);
}
int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/marquise_init/init", test_init);
return g_test_run();
}
|
Set null byte in allocated data dir path | #include <stdlib.h>
#include <pwd.h>
#include <string.h>
#include <sys/stat.h>
#include <gtk/gtk.h>
#include "gh-datastore.h"
#include "gh-main-window.h"
char *
data_dir_path ()
{
uid_t uid = getuid ();
struct passwd *pw = getpwuid (uid);
char *home_dir = pw->pw_dir;
char *data_dir = "/.ghighlighter-c";
int length = strlen (home_dir);
length = length + strlen (data_dir);
char *result = malloc (length + sizeof (char));
strcat (result, home_dir);
strcat (result, data_dir);
return result;
}
void
setup_environment (char *data_dir)
{
mkdir (data_dir, 0755);
}
int
main (int argc, char *argv[])
{
char *data_dir = data_dir_path ();
setup_environment (data_dir);
sqlite3 *db = gh_datastore_open_db (data_dir);
free (data_dir);
GtkWidget *window;
gtk_init (&argc, &argv);
window = gh_main_window_create ();
gtk_widget_show_all (window);
gtk_main ();
sqlite3_close (db);
return 0;
}
| #include <stdlib.h>
#include <pwd.h>
#include <string.h>
#include <sys/stat.h>
#include <gtk/gtk.h>
#include "gh-datastore.h"
#include "gh-main-window.h"
char *
data_dir_path ()
{
uid_t uid = getuid ();
struct passwd *pw = getpwuid (uid);
char *home_dir = pw->pw_dir;
char *data_dir = "/.ghighlighter-c";
int length = strlen (home_dir);
length = length + strlen (data_dir);
char *result = malloc (length + sizeof (char));
result[0] = '\0';
strcat (result, home_dir);
strcat (result, data_dir);
return result;
}
void
setup_environment (char *data_dir)
{
mkdir (data_dir, 0755);
}
int
main (int argc, char *argv[])
{
char *data_dir = data_dir_path ();
setup_environment (data_dir);
sqlite3 *db = gh_datastore_open_db (data_dir);
free (data_dir);
GtkWidget *window;
gtk_init (&argc, &argv);
window = gh_main_window_create ();
gtk_widget_show_all (window);
gtk_main ();
sqlite3_close (db);
return 0;
}
|
Remove trailing semicolons from macros | /**
* @file
*
* @brief Some common functions operating on plugins.
*
* If you include this file you have full access to elektra's internals
* and your test might not be ABI compatible with the next release.
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
#include <tests_internal.h>
#define PLUGIN_OPEN(NAME) \
KeySet * modules = ksNew (0, KS_END); \
elektraModulesInit (modules, 0); \
Key * errorKey = keyNew ("", KEY_END); \
Plugin * plugin = elektraPluginOpen (NAME, modules, conf, errorKey); \
succeed_if (output_warnings (errorKey), "warnings in kdbOpen for plugin " NAME); \
succeed_if (output_error (errorKey), "error in kdbOpen for plugin " NAME); \
keyDel (errorKey); \
exit_if_fail (plugin != 0, "could not open " NAME " plugin");
#define PLUGIN_CLOSE() \
elektraPluginClose (plugin, 0); \
elektraModulesClose (modules, 0); \
ksDel (modules);
| /**
* @file
*
* @brief Some common functions operating on plugins.
*
* If you include this file you have full access to elektra's internals
* and your test might not be ABI compatible with the next release.
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
#include <tests_internal.h>
#define PLUGIN_OPEN(NAME) \
KeySet * modules = ksNew (0, KS_END); \
elektraModulesInit (modules, 0); \
Key * errorKey = keyNew ("", KEY_END); \
Plugin * plugin = elektraPluginOpen (NAME, modules, conf, errorKey); \
succeed_if (output_warnings (errorKey), "warnings in kdbOpen for plugin " NAME); \
succeed_if (output_error (errorKey), "error in kdbOpen for plugin " NAME); \
keyDel (errorKey); \
exit_if_fail (plugin != 0, "could not open " NAME " plugin")
#define PLUGIN_CLOSE() \
elektraPluginClose (plugin, 0); \
elektraModulesClose (modules, 0); \
ksDel (modules)
|
Fix include path so that make install doesn't screw it. |
#include <link-grammar/link-features.h>
LINK_BEGIN_DECLS
void viterbi_parse(const char * sentence, Dictionary dict);
LINK_END_DECLS
|
#include "../link-grammar/link-features.h"
LINK_BEGIN_DECLS
void viterbi_parse(const char * sentence, Dictionary dict);
LINK_END_DECLS
|
Make Igor parser exception extend NSException | @interface DEIgorParserException : NSObject
+ (NSException *)exceptionWithReason:(NSString *)reason scanner:(NSScanner *)scanner;
@end
| @interface DEIgorParserException : NSException
+ (NSException *)exceptionWithReason:(NSString *)reason scanner:(NSScanner *)scanner;
@end
|
Fix includes in chez022 test | #include <malloc.h>
#include <string.h>
typedef struct {
int val;
char* str;
} Stuff;
Stuff* mkThing() {
static int num = 0;
Stuff* x = malloc(sizeof(Stuff));
x->val = num++;
x->str = malloc(20);
strcpy(x->str,"Hello");
return x;
}
char* getStr(Stuff* x) {
return x->str;
}
void freeThing(Stuff* x) {
printf("Freeing %d %s\n", x->val, x->str);
free(x->str);
free(x);
}
| #include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct {
int val;
char* str;
} Stuff;
Stuff* mkThing() {
static int num = 0;
Stuff* x = malloc(sizeof(Stuff));
x->val = num++;
x->str = malloc(20);
strcpy(x->str,"Hello");
return x;
}
char* getStr(Stuff* x) {
return x->str;
}
void freeThing(Stuff* x) {
printf("Freeing %d %s\n", x->val, x->str);
free(x->str);
free(x);
}
|
Fix Travis for decoder tests | //!compile = {cc} {ccflags} -c -o {ofile} {infile} && {cc} {ccflags} -o {outfile} {ofile} {driver} ../libdbrew.a -I../include
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include "dbrew.h"
int f1(int);
// possible jump target
int f2(int x) { return x; }
int main()
{
// Decode the function.
Rewriter* r = dbrew_new();
// to get rid of changing addresses, assume gen code to be 200 bytes max
dbrew_config_function_setname(r, (uintptr_t) f1, "f1");
dbrew_config_function_setsize(r, (uintptr_t) f1, 200);
dbrew_decode_print(r, (uintptr_t) f1, 1);
return 0;
}
| //!compile = as -c -o {ofile} {infile} && {cc} {ccflags} -o {outfile} {ofile} {driver} ../libdbrew.a -I../include
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include "dbrew.h"
int f1(int);
// possible jump target
int f2(int x) { return x; }
int main()
{
// Decode the function.
Rewriter* r = dbrew_new();
// to get rid of changing addresses, assume gen code to be 200 bytes max
dbrew_config_function_setname(r, (uintptr_t) f1, "f1");
dbrew_config_function_setsize(r, (uintptr_t) f1, 200);
dbrew_decode_print(r, (uintptr_t) f1, 1);
return 0;
}
|
Add failing test without threadescape | // PARAM: --set ana.activated "['base','mallocWrapper','threadflag']"
#include <pthread.h>
int g = 10;
void* t(void *v) {
int* p = (int*) v;
*p = 4711;
}
int main(void){
int l = 42;
pthread_t tid;
pthread_create(&tid, NULL, t, (void *)&l);
pthread_join(tid, NULL);
assert(l==42); //UNKNOWN!
return 0;
}
| |
FIx sound(..)modifier compaibility with old maps | #pragma once
#include "augs/math/declare_math.h"
#include "augs/audio/distance_model.h"
struct sound_effect_modifier {
// GEN INTROSPECTOR struct sound_effect_modifier
real32 gain = 1.f;
real32 pitch = 1.f;
real32 max_distance = -1.f;
real32 reference_distance = -1.f;
real32 doppler_factor = 1.f;
augs::distance_model distance_model = augs::distance_model::NONE;
int repetitions = 1;
bool fade_on_exit = true;
bool disable_velocity = false;
bool always_direct_listener = false;
pad_bytes<1> pad;
// END GEN INTROSPECTOR
};
| #pragma once
#include "augs/math/declare_math.h"
#include "augs/audio/distance_model.h"
struct sound_effect_modifier {
// GEN INTROSPECTOR struct sound_effect_modifier
real32 gain = 1.f;
real32 pitch = 1.f;
real32 max_distance = -1.f;
real32 reference_distance = -1.f;
real32 doppler_factor = 1.f;
char repetitions = 1;
bool fade_on_exit = true;
bool disable_velocity = false;
bool always_direct_listener = false;
augs::distance_model distance_model = augs::distance_model::NONE;
// END GEN INTROSPECTOR
};
|
Use new mul function in LabellerFrameData::project. | #ifndef SRC_FORCES_LABELLER_FRAME_DATA_H_
#define SRC_FORCES_LABELLER_FRAME_DATA_H_
#include <Eigen/Core>
#include <iostream>
namespace Forces
{
/**
* \brief
*
*
*/
class LabellerFrameData
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
LabellerFrameData(double frameTime, Eigen::Matrix4f projection,
Eigen::Matrix4f view)
: frameTime(frameTime), projection(projection), view(view),
viewProjection(projection * view)
{
}
const double frameTime;
const Eigen::Matrix4f projection;
const Eigen::Matrix4f view;
const Eigen::Matrix4f viewProjection;
Eigen::Vector3f project(Eigen::Vector3f vector) const
{
Eigen::Vector4f projected =
viewProjection * Eigen::Vector4f(vector.x(), vector.y(), vector.z(), 1);
std::cout << "projected" << projected / projected.w() << std::endl;
return projected.head<3>() / projected.w();
}
};
} // namespace Forces
#endif // SRC_FORCES_LABELLER_FRAME_DATA_H_
| #ifndef SRC_FORCES_LABELLER_FRAME_DATA_H_
#define SRC_FORCES_LABELLER_FRAME_DATA_H_
#include "../eigen.h"
#include <iostream>
namespace Forces
{
/**
* \brief
*
*
*/
class LabellerFrameData
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
LabellerFrameData(double frameTime, Eigen::Matrix4f projection,
Eigen::Matrix4f view)
: frameTime(frameTime), projection(projection), view(view),
viewProjection(projection * view)
{
}
const double frameTime;
const Eigen::Matrix4f projection;
const Eigen::Matrix4f view;
const Eigen::Matrix4f viewProjection;
Eigen::Vector3f project(Eigen::Vector3f vector) const
{
Eigen::Vector4f projected = mul(viewProjection, vector);
return projected.head<3>() / projected.w();
}
};
} // namespace Forces
#endif // SRC_FORCES_LABELLER_FRAME_DATA_H_
|
Add fs-related structures and stub functions | /**
* @file devfs_dvfs.c
* @brief
* @author Denis Deryugin <deryugin.denis@gmail.com>
* @version 0.1
* @date 2015-09-28
*/
/* This is stub */
| /**
* @file devfs_dvfs.c
* @brief
* @author Denis Deryugin <deryugin.denis@gmail.com>
* @version 0.1
* @date 2015-09-28
*/
#include <fs/dvfs.h>
#include <util/array.h>
static int devfs_destroy_inode(struct inode *inode) {
return 0;
}
static int devfs_iterate(struct inode *next, struct inode *parent, struct dir_ctx *ctx) {
return 0;
}
static struct inode *devfs_lookup(char const *name, struct dentry const *dir) {
return NULL;
}
static int devfs_pathname(struct inode *inode, char *buf, int flags) {
return 0;
}
static int devfs_mount_end(struct super_block *sb) {
return 0;
}
static int devfs_open(struct inode *node, struct file *file) {
return 0;
}
static size_t devfs_read(struct file *desc, void *buf, size_t size) {
return 0;
}
static int devfs_ioctl(struct file *desc, int request, ...) {
return 0;
}
struct super_block_operations devfs_sbops = {
.destroy_inode = devfs_destroy_inode,
};
struct inode_operations devfs_iops = {
.lookup = devfs_lookup,
.iterate = devfs_iterate,
.pathname = devfs_pathname,
};
struct file_operations devfs_fops = {
.open = devfs_open,
.read = devfs_read,
.ioctl = devfs_ioctl,
};
static int devfs_fill_sb(struct super_block *sb, struct block_dev *dev) {
sb->sb_iops = &devfs_iops;
sb->sb_fops = &devfs_fops;
sb->sb_ops = &devfs_sbops;
return 0;
}
static struct dumb_fs_driver devfs_dumb_driver = {
.name = "devfs",
.fill_sb = devfs_fill_sb,
.mount_end = devfs_mount_end,
};
ARRAY_SPREAD_DECLARE(struct dumb_fs_driver *, dumb_drv_tab);
ARRAY_SPREAD_ADD(dumb_drv_tab, &devfs_dumb_driver);
|
Make tokenized_sentence a structure (i.e., all fields public). | // This file is part of MorphoDiTa <http://github.com/ufal/morphodita/>.
//
// Copyright 2015 Institute of Formal and Applied Linguistics, Faculty of
// Mathematics and Physics, Charles University in Prague, Czech Republic.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include "common.h"
#include "tokenizer.h"
namespace ufal {
namespace morphodita {
class tokenized_sentence {
u32string sentence;
vector<token_range> tokens;
};
class gru_tokenizer_factory_trainer {
public:
static bool train(unsigned version, const vector<tokenized_sentence>& data, ostream& os, string& error);
};
} // namespace morphodita
} // namespace ufal
| // This file is part of MorphoDiTa <http://github.com/ufal/morphodita/>.
//
// Copyright 2015 Institute of Formal and Applied Linguistics, Faculty of
// Mathematics and Physics, Charles University in Prague, Czech Republic.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include "common.h"
#include "tokenizer.h"
namespace ufal {
namespace morphodita {
struct tokenized_sentence {
u32string sentence;
vector<token_range> tokens;
};
class gru_tokenizer_factory_trainer {
public:
static bool train(unsigned version, const vector<tokenized_sentence>& data, ostream& os, string& error);
};
} // namespace morphodita
} // namespace ufal
|
Add missing "expected warning". Add compound literal with empty initializer (just to test the analyzer handles it). | // RUN: clang -checker-simple -verify %s
int* f1() {
int x = 0;
return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}
int* f2(int y) {
return &y; // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
}
int* f3(int x, int *y) {
int w = 0;
if (x)
y = &w;
return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}}
}
void* compound_literal(int x) {
if (x)
return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}
struct s { int z; double y; int w; };
return &((struct s){ 2, 0.4, 5 * 8 });
}
| // RUN: clang -checker-simple -verify %s
int* f1() {
int x = 0;
return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}
int* f2(int y) {
return &y; // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
}
int* f3(int x, int *y) {
int w = 0;
if (x)
y = &w;
return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}}
}
void* compound_literal(int x) {
if (x)
return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}
int* array[] = {};
struct s { int z; double y; int w; };
return &((struct s){ 2, 0.4, 5 * 8 }); // expected-warning{{Address of stack memory}}
}
|
Add SAFE_RZCALL to wrap calls that returns zero. | #ifndef SAFE_H
#define SAFE_H
#include "debug.h"
#ifndef DISABLE_SAFE
#define SAFE_STRINGIFY(x) #x
#define SAFE_TOSTRING(x) SAFE_STRINGIFY(x)
#define SAFE_AT __FILE__ ":" SAFE_TOSTRING(__LINE__) ": "
#define SAFE_ASSERT(cond) do { \
if (!(cond)) { \
DEBUG_DUMP(0, "error: " SAFE_AT "%m"); \
DEBUG_BREAK(!(cond)); \
} \
} while (0)
#else
#define SAFE_ASSERT(...)
#endif
#include <stdint.h>
#define SAFE_NNCALL(call) do { \
intptr_t ret = (intptr_t) (call); \
SAFE_ASSERT(ret >= 0); \
} while (0)
#define SAFE_NZCALL(call) do { \
intptr_t ret = (intptr_t) (call); \
SAFE_ASSERT(ret != 0); \
} while (0)
#endif /* end of include guard: SAFE_H */
| #ifndef SAFE_H
#define SAFE_H
#include "debug.h"
#ifndef DISABLE_SAFE
#define SAFE_STRINGIFY(x) #x
#define SAFE_TOSTRING(x) SAFE_STRINGIFY(x)
#define SAFE_AT __FILE__ ":" SAFE_TOSTRING(__LINE__) ": "
#define SAFE_ASSERT(cond) do { \
if (!(cond)) { \
DEBUG_DUMP(0, "error: " SAFE_AT "%m"); \
DEBUG_BREAK(!(cond)); \
} \
} while (0)
#else
#define SAFE_ASSERT(...)
#endif
#include <stdint.h>
#define SAFE_NNCALL(call) do { \
intptr_t ret = (intptr_t) (call); \
SAFE_ASSERT(ret >= 0); \
} while (0)
#define SAFE_NZCALL(call) do { \
intptr_t ret = (intptr_t) (call); \
SAFE_ASSERT(ret != 0); \
} while (0)
#define SAFE_RZCALL(call) do { \
intptr_t ret = (intptr_t) (call); \
SAFE_ASSERT(ret == 0); \
} while (0)
#endif /* end of include guard: SAFE_H */
|
Make parent protected so that the child can know their parents | //=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#ifndef PARSE_NODE_H
#define PARSE_NODE_H
#include <list>
#include "ByteCodeFileWriter.h"
#include "Variables.h"
#include "CompilerException.h"
class ParseNode;
typedef std::list<ParseNode*>::const_iterator NodeIterator;
class StringPool;
class ParseNode {
private:
ParseNode* parent;
std::list<ParseNode*> childs;
public:
ParseNode() : parent(NULL){};
virtual ~ParseNode();
virtual void write(ByteCodeFileWriter& writer);
virtual void checkVariables(Variables& variables) throw (CompilerException);
virtual void checkStrings(StringPool& pool);
virtual void optimize();
void addFirst(ParseNode* node);
void addLast(ParseNode* node);
void replace(ParseNode* old, ParseNode* node);
void remove(ParseNode* node);
NodeIterator begin();
NodeIterator end();
};
#endif
| //=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#ifndef PARSE_NODE_H
#define PARSE_NODE_H
#include <list>
#include "ByteCodeFileWriter.h"
#include "Variables.h"
#include "CompilerException.h"
class ParseNode;
typedef std::list<ParseNode*>::const_iterator NodeIterator;
class StringPool;
class ParseNode {
private:
std::list<ParseNode*> childs;
protected:
ParseNode* parent;
public:
ParseNode() : parent(NULL){};
virtual ~ParseNode();
virtual void write(ByteCodeFileWriter& writer);
virtual void checkVariables(Variables& variables) throw (CompilerException);
virtual void checkStrings(StringPool& pool);
virtual void optimize();
void addFirst(ParseNode* node);
void addLast(ParseNode* node);
void replace(ParseNode* old, ParseNode* node);
void remove(ParseNode* node);
NodeIterator begin();
NodeIterator end();
};
#endif
|
Remove macros which now live in paging.h | #ifndef KMEM_H
#define KMEM_H
#include <stdbool.h>
#include <stdint.h>
#include <arch/x86/paging.h>
#include <libk/kabort.h>
#define KHEAP_PHYS_ROOT ((void*)0x100000)
//#define KHEAP_PHYS_END ((void*)0xc1000000)
#define KHEAP_END_SENTINEL (NULL)
// 1 GB
#define PHYS_MEMORY_SIZE (1*1024*1024*1024)
#define KHEAP_BLOCK_SLOP 32
#define PAGE_ALIGN(x) ((uint32_t)x >> 12)
struct kheap_metadata {
size_t size;
struct kheap_metadata *next;
bool is_free;
};
struct kheap_metadata *root;
struct kheap_metadata *kheap_init();
int kheap_extend();
void kheap_install(struct kheap_metadata *root, size_t initial_heap_size);
void *kmalloc(size_t bytes);
void kfree(void *mem);
void kheap_defragment();
#endif
| #ifndef KMEM_H
#define KMEM_H
#include <stdbool.h>
#include <stdint.h>
#include <arch/x86/paging.h>
#include <libk/kabort.h>
#define KHEAP_PHYS_ROOT ((void*)0x100000)
//#define KHEAP_PHYS_END ((void*)0xc1000000)
#define KHEAP_END_SENTINEL (NULL)
#define KHEAP_BLOCK_SLOP 32
struct kheap_metadata {
size_t size;
struct kheap_metadata *next;
bool is_free;
};
struct kheap_metadata *root;
struct kheap_metadata *kheap_init();
int kheap_extend();
void kheap_install(struct kheap_metadata *root, size_t initial_heap_size);
void *kmalloc(size_t bytes);
void kfree(void *mem);
void kheap_defragment();
#endif
|
Replace BeIDE header by the Pe version | //==================================================================
// MTextAddOn.h
// Copyright 1996 Metrowerks Corporation, All Rights Reserved.
//==================================================================
// This is a proxy class used by Editor add_ons. It does not inherit from BView
// but provides an abstract interface to a text engine.
#ifndef _MTEXTADDON_H
#define _MTEXTADDON_H
#include <SupportKit.h>
class MIDETextView;
class BWindow;
struct entry_ref;
class MTextAddOn
{
public:
MTextAddOn(
MIDETextView& inTextView);
virtual ~MTextAddOn();
virtual const char* Text();
virtual int32 TextLength() const;
virtual void GetSelection(
int32 *start,
int32 *end) const;
virtual void Select(
int32 newStart,
int32 newEnd);
virtual void Delete();
virtual void Insert(
const char* inText);
virtual void Insert(
const char* text,
int32 length);
virtual BWindow* Window();
virtual status_t GetRef(
entry_ref& outRef);
virtual bool IsEditable();
private:
MIDETextView& fText;
};
#endif
| // [zooey, 2005]: made MTextAddon really an abstract class
//==================================================================
// MTextAddOn.h
// Copyright 1996 Metrowerks Corporation, All Rights Reserved.
//==================================================================
// This is a proxy class used by Editor add_ons. It does not inherit from BView
// but provides an abstract interface to a text engine.
#ifndef MTEXTADDON_H
#define MTEXTADDON_H
//#include "HLibHekkel.h"
class BWindow;
struct entry_ref;
class /*IMPEXP_LIBHEKKEL*/ MTextAddOn
{
public:
virtual ~MTextAddOn();
virtual const char* Text() = 0;
virtual int32 TextLength() const = 0;
virtual void GetSelection(int32 *start, int32 *end) const = 0;
virtual void Select(int32 newStart, int32 newEnd) = 0;
virtual void Delete() = 0;
virtual void Insert(const char* inText) = 0;
virtual void Insert(const char* text, int32 length) = 0;
virtual BWindow* Window() = 0;
virtual status_t GetRef(entry_ref& outRef) = 0;
};
#if !__INTEL__
#pragma export on
#endif
extern "C" {
long perform_edit(MTextAddOn *addon);
}
#if !__INTEL__
#pragma export reset
#endif
typedef long (*perform_edit_func)(MTextAddOn *addon);
#endif
|
Fix a bug where we stomp on the : in a host:port in BK_SHOWPROC Also don't assume the socket connected. | #include "system.h"
FILE *
efopen(char *env)
{
char *t, *p;
int port, sock;
unless (t = getenv(env)) return (0);
if (IsFullPath(t)) return (fopen(t, "a"));
if ((p = strchr(t, ':')) && ((port = atoi(p+1)) > 0)) {
*p = 0;
sock = tcp_connect(t, port);
return (fdopen(sock, "w"));
}
return (fopen(DEV_TTY, "w"));
}
| #include "system.h"
FILE *
efopen(char *env)
{
char *t, *p;
int port, sock;
unless (t = getenv(env)) return (0);
if (IsFullPath(t)) return (fopen(t, "a"));
if ((p = strchr(t, ':')) && ((port = atoi(p+1)) > 0)) {
*p = 0;
sock = tcp_connect(t, port);
*p = ':';
if (sock >= 0) return (fdopen(sock, "w"));
}
return (fopen(DEV_TTY, "w"));
}
|
Enable pruning losing captures in qsearch | #ifndef _CONFIG_H
#define _CONFIG_H
#define ENABLE_FUTILITY_DEPTH 1 // TODO: switch to at least 2
#define ENABLE_HISTORY 1
#define ENABLE_KILLERS 1
#define ENABLE_LMR 1
#define ENABLE_NNUE 0
#define ENABLE_NULL_MOVE_PRUNING 1
#define ENABLE_REVERSE_FUTILITY_DEPTH 1 // TODO: switch to at least 2
#define ENABLE_SEE_Q_PRUNE_LOSING_CAPTURES 0
#define ENABLE_SEE_SORTING 0
#define ENABLE_TIMER_STOP_DEEPENING 1
#define ENABLE_TT_CUTOFFS 1
#define ENABLE_TT_MOVES 1
#endif
| #ifndef _CONFIG_H
#define _CONFIG_H
#define ENABLE_FUTILITY_DEPTH 1 // TODO: switch to at least 2
#define ENABLE_HISTORY 1
#define ENABLE_KILLERS 1
#define ENABLE_LMR 1
#define ENABLE_NNUE 0
#define ENABLE_NULL_MOVE_PRUNING 1
#define ENABLE_REVERSE_FUTILITY_DEPTH 1 // TODO: switch to at least 2
#define ENABLE_SEE_Q_PRUNE_LOSING_CAPTURES 1
#define ENABLE_SEE_SORTING 1
#define ENABLE_TIMER_STOP_DEEPENING 1
#define ENABLE_TT_CUTOFFS 1
#define ENABLE_TT_MOVES 1
#endif
|
Make the UIKit shim function properly available | //===--- UIKitOverlayShims.h ---===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===--------------------===//
#ifndef SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
#define SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
@import UIKit;
#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif
#if TARGET_OS_TV || TARGET_OS_IOS
static inline BOOL _swift_UIKit_UIFocusEnvironmentContainsEnvironment(id<UIFocusEnvironment> environment, id<UIFocusEnvironment> otherEnvironment) {
return [UIFocusSystem environment:environment containsEnvironment:otherEnvironment];
}
#endif // TARGET_OS_TV || TARGET_OS_IOS
#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
#endif // SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
| //===--- UIKitOverlayShims.h ---===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===--------------------===//
#ifndef SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
#define SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
@import UIKit;
#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif
#if TARGET_OS_TV || TARGET_OS_IOS
static inline BOOL _swift_UIKit_UIFocusEnvironmentContainsEnvironment(
id<UIFocusEnvironment> environment,
id<UIFocusEnvironment> otherEnvironment
) API_AVAILABLE(ios(11.0), tvos(11.0)) {
return [UIFocusSystem environment:environment containsEnvironment:otherEnvironment];
}
#endif // TARGET_OS_TV || TARGET_OS_IOS
#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
#endif // SWIFT_STDLIB_SHIMS_UIKIT_OVERLAY_H
|
Make square position and dimension accessible | #ifndef SQUARE_H_
#define SQUARE_H_
namespace flat2d
{
class Square
{
protected:
int x, y, w, h;
public:
Square(int px, int py, int dim) : x(px), y(py), w(dim), h(dim) { }
Square(int px, int py, int pw, int ph) : x(px), y(py), w(pw), h(ph) { }
bool containsPoint(int, int) const;
bool operator<(const Square&) const;
bool operator==(const Square&) const;
bool operator!=(const Square&) const;
};
} // namespace flat2d
#endif // SQUARE_H_
| #ifndef SQUARE_H_
#define SQUARE_H_
namespace flat2d
{
class Square
{
protected:
int x, y, w, h;
public:
Square(int px, int py, int dim) : x(px), y(py), w(dim), h(dim) { }
Square(int px, int py, int pw, int ph) : x(px), y(py), w(pw), h(ph) { }
bool containsPoint(int, int) const;
bool operator<(const Square&) const;
bool operator==(const Square&) const;
bool operator!=(const Square&) const;
int getXpos() { return x; }
int getYpos() { return y; }
int getWidth() { return w; }
int getHeight() { return h; }
};
} // namespace flat2d
#endif // SQUARE_H_
|
Update wizzimote timer periph config | #ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Real Time Clock configuration
*/
#define RTC_NUMOF (1)
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */ | #ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Real Time Clock configuration
* @{
*/
#define RTC_NUMOF (1)
/** @} */
/**
* @brief Timer configuration
* @{
*/
#define TIMER_NUMOF (2U)
#define TIMER_0_EN 1
#define TIMER_1_EN 1
/* Timer 0 configuration */
#define TIMER_0_CHANNELS 5
#define TIMER_0_MAX_VALUE (0xffff)
/* TODO(ximus): Finalize this, current setup is not provide 1Mhz */
#define TIMER_0_CLK_TASSEL TASSEL_2 /* SMLCK @ Mhz */
#define TIMER_0_DIV_ID ID__1 /* /1 */
#define TIMER_0_DIV_TAIDEX TAIDEX_4 /* /5 */
/* Timer 1 configuration */
#define TIMER_1_CHANNELS 3
#define TIMER_1_MAX_VALUE (0xffff)
#define TIMER_1_CLK_TASSEL TASSEL_2 /* SMLCK @ Mhz */
#define TIMER_1_DIV_ID ID__1 /* /1 */
#define TIMER_1_DIV_TAIDEX TAIDEX_4 /* /5 */
/** @} */
/**
* @brief wtimer configuration
* @{
*/
/* NOTE(ximus): all msp430's are 16-bit, should be defined in cpu */
#define WTIMER_MASK 0xffff0000 /* 16-bit timers */
/* TODO(ximus): set these correctly. default values for now */
#define WTIMER_USLEEP_UNTIL_OVERHEAD 3
#define WTIMER_OVERHEAD 24
#define WTIMER_BACKOFF 30
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */ |
Add a header for hexagon shared library Change: 130671228 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_PLATFORM_HEXAGON_GEMM_WRAPPER_H_
#define TENSORFLOW_PLATFORM_HEXAGON_GEMM_WRAPPER_H_
// Declaration of APIs provided by hexagon shared library. This header is shared
// with both hexagon library built with qualcomm SDK and tensorflow.
// All functions defined here must have prefix "hexagon_gemm_wrapper" to avoid
// naming conflicts.
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Returns the version of loaded hexagon shared library. Assert if the version
// matches the expected version.
int hexagon_gemm_wrapper_GetVersion();
// TODO(satok): Support gemm APIs via RPC
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // TENSORFLOW_PLATFORM_HEXAGON_GEMM_WRAPPER_H_
| |
Add solution to Exercise 1-2. | /* Experiment to find out what happened when printf's argument string contains
* \c, where c is some character not listed above.
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
printf("\\a produces an audible or visual alert: \a\n");
printf("\\f produces a formfeed: \f\n");
printf("\\r produces a carriage return: \rlololol\n");
printf("\\v produces a vertical tab: \t\n");
return EXIT_SUCCESS;
}
| |
Add a test to make sure that we're lowering the shift amount correctly. | // RUN: %llvmgcc -mssse3 -S -o - %s | llc -mtriple=x86_64-apple-darwin | FileCheck %s
#include <tmmintrin.h>
int main ()
{
#if defined( __SSSE3__ )
#define vec_rld_epi16( _a, _i ) ({ vSInt16 _t = _a; _t = _mm_alignr_epi8( _t, _t, _i ); /*return*/ _t; })
typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16)));
short dtbl[] = {1,2,3,4,5,6,7,8};
vSInt16 *vdtbl = (vSInt16*) dtbl;
vSInt16 v0;
v0 = *vdtbl;
// CHECK: pshufd $57
v0 = vec_rld_epi16( v0, 4 );
return 0;
#endif
}
| |
Fix invalid heap issues with load simulator | #include <Python.h>
static PyObject *
simulate_install(PyObject *self, PyObject *args) {
long cpu_units;
long mem_bytes;
if (!PyArg_ParseTuple(args, "LL", &cpu_units, &mem_bytes)) {
return NULL;
}
char *p;
p = (char *) malloc(mem_bytes);
int j = 0;
for (long i = 0; i < cpu_units; i++) {
j++;
}
free(p);
return Py_BuildValue("i", 0);
}
static PyObject *
simulate_import(PyObject *self, PyObject *args) {
long cpu_units;
long mem_bytes;
if (!PyArg_ParseTuple(args, "LL", &cpu_units, &mem_bytes)) {
return NULL;
}
int j = 0;
for (long i = 0; i < cpu_units; i++) {
j++;
}
PyObject * p = (PyObject *) PyMem_Malloc(mem_bytes);
return p;
}
static PyMethodDef LoadSimulatorMethods[] =
{
{"simulate_install", simulate_install, METH_VARARGS, "simulate install"},
{"simulate_import", simulate_import, METH_VARARGS, "simulate import"},
{ NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC
initload_simulator(void)
{
(void) Py_InitModule("load_simulator", LoadSimulatorMethods);
}
| #include <Python.h>
static PyObject *
simulate_install(PyObject *self, PyObject *args) {
long cpu_units;
long mem_bytes;
if (!PyArg_ParseTuple(args, "LL", &cpu_units, &mem_bytes)) {
return NULL;
}
char *p;
p = (char *) malloc(mem_bytes);
int j = 0;
for (long i = 0; i < cpu_units; i++) {
j++;
}
free(p);
return Py_BuildValue("i", 0);
}
static PyObject *
simulate_import(PyObject *self, PyObject *args) {
long cpu_units;
long mem_bytes;
if (!PyArg_ParseTuple(args, "LL", &cpu_units, &mem_bytes)) {
return NULL;
}
int j = 0;
for (long i = 0; i < cpu_units; i++) {
j++;
}
char * p = malloc(mem_bytes);
return Py_BuildValue("s#", p, mem_bytes);
}
static PyMethodDef LoadSimulatorMethods[] =
{
{"simulate_install", simulate_install, METH_VARARGS, "simulate install"},
{"simulate_import", simulate_import, METH_VARARGS, "simulate import"},
{ NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC
initload_simulator(void)
{
(void) Py_InitModule("load_simulator", LoadSimulatorMethods);
}
|
Add a utility method for aspect fill layouts (incomplete). | //
// BCRectUtilities.h
// MBTI
//
// Created by Seth Kingsley on 9/12/12.
// Copyright (c) 2012 Bushido Coding. All rights reserved.
//
#import "BCMacros.h"
static inline __attribute__((const)) CGRect
BCRectAspectFit(CGRect containerRect, CGSize contentSize)
{
if (contentSize.width == 0)
contentSize.width = 1;
CGFloat contentAspect = contentSize.height / contentSize.width;
if (CGRectGetWidth(containerRect) == 0)
containerRect.size.width = 1;
CGFloat containerAspect = CGRectGetHeight(containerRect) / CGRectGetWidth(containerRect);
CGRect scaledRect;
if (contentAspect >= containerAspect)
{
CGFloat scaledWidth = roundf(CGRectGetHeight(containerRect) * contentAspect);
CGFloat xOffset = roundf((CGRectGetWidth(containerRect) - scaledWidth) / 2);
scaledRect = CGRectMake(CGRectGetMinX(containerRect) + xOffset, CGRectGetMinY(containerRect),
scaledWidth, CGRectGetHeight(containerRect));
}
else
{
CGFloat scaledHeight = roundf(CGRectGetWidth(containerRect) / contentAspect);
CGFloat yOffset = roundf((CGRectGetHeight(containerRect) - scaledHeight) / 2);
scaledRect = CGRectMake(CGRectGetMinX(containerRect), CGRectGetMinY(containerRect) + yOffset,
CGRectGetWidth(containerRect), scaledHeight);
}
POSTCONDITION_C(CGRectContainsRect(containerRect, scaledRect));
POSTCONDITION_C(CGRectEqualToRect(scaledRect, CGRectIntegral(scaledRect)));
POSTCONDITION_C((contentSize.height / contentSize.width) ==
(CGRectGetHeight(scaledRect) / CGRectGetWidth(scaledRect)));
return scaledRect;
}
| |
Add : id number validation | //
// NSString+Input.h
// LYCategory
//
// Created by Rick Luo on 11/25/13.
// Copyright (c) 2013 Luo Yu. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (Input)
#pragma mark EMPTY
- (BOOL)isEmpty;
#pragma mark EMAIL
- (BOOL)isEmail;
#pragma mark SPACE
- (NSString *)trimStartSpace;
- (NSString *)trimSpace;
#pragma mark PHONE NUMBER
- (NSString *)phoneNumber;
- (BOOL)isPhoneNumber;
#pragma mark EMOJI
- (NSString *)replaceEmojiTextWithUnicode;
- (NSString *)replaceEmojiUnicodeWithText;
@end
| //
// NSString+Input.h
// LYCategory
//
// Created by Rick Luo on 11/25/13.
// Copyright (c) 2013 Luo Yu. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (Input)
#pragma mark EMPTY
- (BOOL)isEmpty;
#pragma mark EMAIL
- (BOOL)isEmail;
#pragma mark ID
- (BOOL)isIDNumber;
#pragma mark SPACE
- (NSString *)trimStartSpace;
- (NSString *)trimSpace;
#pragma mark PHONE NUMBER
- (NSString *)phoneNumber;
- (BOOL)isPhoneNumber;
#pragma mark EMOJI
- (NSString *)replaceEmojiTextWithUnicode;
- (NSString *)replaceEmojiUnicodeWithText;
@end
|
Update reference to IOperation to include Internal namespace | #pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_
#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
friend class Transaction;
public:
static bool begin();
// Modifying methods
static bool post(TaskId, SerializedTask&);
static bool put(TaskId, SerializedTask&);
static bool erase(TaskId);
static boost::variant<bool, SerializedTask> get(TaskId);
static std::vector<SerializedTask>
filter(const std::function<bool(SerializedTask)>&);
private:
static DataStore& getInstance();
bool isServing = false;
std::deque<IOperation> operationsQueue;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_DATASTORE_H_
| #pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_
#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
friend class Transaction;
public:
static bool begin();
// Modifying methods
static bool post(TaskId, SerializedTask&);
static bool put(TaskId, SerializedTask&);
static bool erase(TaskId);
static boost::variant<bool, SerializedTask> get(TaskId);
static std::vector<SerializedTask>
filter(const std::function<bool(SerializedTask)>&);
private:
static DataStore& getInstance();
bool isServing = false;
std::deque<Internal::IOperation> operationsQueue;
};
} // namespace DataStore
} // namespace You
#endif // YOU_DATASTORE_DATASTORE_H_
|
Fix typo in parser tests | #include "parser.h"
#include "ast.h"
#include "tests.h"
void test_parse_number();
int main() {
test_parse_number();
return 0;
}
struct token *make_token(enum token_type tk_type, char* str, double dbl,
int number) {
struct token *tk = malloc(sizeof(struct token));
tk->type = tk_type;
if (tk_type == tok_dbl) {
tk->value.dbl = dbl;
} else if (tk_type == tok_number) {
tk->value.number = number;
} else {
tk->value.string = string;
}
return tk;
}
void test_parse_number() {
struct token_list *tkl = make_token_list();
tkl.append(make_token(tok_number, NULL, 0.0, 42);
struct ast_node *result = parse_number(tkl);
EXPECT_EQ(result->val, tkl->head);
EXPECT_EQ(result->num_children, 0);
destroy_token_list(tkl);
}
| #include "parser.h"
#include "ast.h"
#include "tests.h"
void test_parse_number();
int main() {
test_parse_number();
return 0;
}
struct token *make_token(enum token_type tk_type, char* str, double dbl,
int number) {
struct token *tk = malloc(sizeof(struct token));
tk->type = tk_type;
if (tk_type == tok_dbl) {
tk->value.dbl = dbl;
} else if (tk_type == tok_number) {
tk->value.num = number;
} else {
tk->value.string = str;
}
return tk;
}
void test_parse_number() {
struct token_list *tkl = make_token_list();
tkl.append(make_token(tok_number, NULL, 0.0, 42);
struct ast_node *result = parse_number(tkl);
EXPECT_EQ(result->val, tkl->head);
EXPECT_EQ(result->num_children, 0);
destroy_token_list(tkl);
}
|
Add a few macros to support InverterLayer on BASALT | #pragma once
#include <pebble.h>
#include "effects.h"
//number of supported effects on a single effect_layer (must be <= 255)
#define MAX_EFFECTS 4
// structure of effect layer
typedef struct {
Layer* layer;
effect_cb* effects[MAX_EFFECTS];
void* params[MAX_EFFECTS];
uint8_t next_effect;
} EffectLayer;
//creates effect layer
EffectLayer* effect_layer_create(GRect frame);
//destroys effect layer
void effect_layer_destroy(EffectLayer *effect_layer);
//sets effect for the layer
void effect_layer_add_effect(EffectLayer *effect_layer, effect_cb* effect, void* param);
//gets layer
Layer* effect_layer_get_layer(EffectLayer *effect_layer); | #pragma once
#include <pebble.h>
#include "effects.h"
//number of supported effects on a single effect_layer (must be <= 255)
#define MAX_EFFECTS 4
// structure of effect layer
typedef struct {
Layer* layer;
effect_cb* effects[MAX_EFFECTS];
void* params[MAX_EFFECTS];
uint8_t next_effect;
} EffectLayer;
//creates effect layer
EffectLayer* effect_layer_create(GRect frame);
//destroys effect layer
void effect_layer_destroy(EffectLayer *effect_layer);
//sets effect for the layer
void effect_layer_add_effect(EffectLayer *effect_layer, effect_cb* effect, void* param);
//gets layer
Layer* effect_layer_get_layer(EffectLayer *effect_layer);
// Recreate inverter_layer for BASALT
#ifndef PBL_PLATFORM_APLITE
#define InverterLayer EffectLayer
#define inverter_layer_create(frame)({ EffectLayer* _el=effect_layer_create(frame); effect_layer_add_effect(_el,effect_invert,NULL);_el; })
#define inverter_layer_get_layer effect_layer_get_layer
#define inverter_layer_destroy effect_layer_destroy
#endif |
Remove unneed inclusion of unistd.h | /*
* libaacs by Doom9 ppl 2009, 2010
*/
#ifndef AACS_H_
#define AACS_H_
#include <stdint.h>
#include <unistd.h>
#include "mkb.h"
#include "../file/configfile.h"
#define LIBAACS_VERSION "1.0"
typedef struct aacs AACS;
struct aacs {
uint8_t pk[16], mk[16], vuk[16], vid[16];
uint8_t *uks; // unit key array (size = 16 * num_uks, each key is at 16-byte offset)
uint16_t num_uks; // number of unit keys
uint8_t iv[16];
CONFIGFILE *kf;
};
AACS *aacs_open(const char *path, const char *keyfile_path);
void aacs_close(AACS *aacs);
int aacs_decrypt_unit(AACS *aacs, uint8_t *buf, uint32_t len, uint64_t offset);
uint8_t *aacs_get_vid(AACS *aacs);
#endif /* AACS_H_ */
| /*
* libaacs by Doom9 ppl 2009, 2010
*/
#ifndef AACS_H_
#define AACS_H_
#include <stdint.h>
#include "mkb.h"
#include "../file/configfile.h"
#define LIBAACS_VERSION "1.0"
typedef struct aacs AACS;
struct aacs {
uint8_t pk[16], mk[16], vuk[16], vid[16];
uint8_t *uks; // unit key array (size = 16 * num_uks, each key is at 16-byte offset)
uint16_t num_uks; // number of unit keys
uint8_t iv[16];
CONFIGFILE *kf;
};
AACS *aacs_open(const char *path, const char *keyfile_path);
void aacs_close(AACS *aacs);
int aacs_decrypt_unit(AACS *aacs, uint8_t *buf, uint32_t len, uint64_t offset);
uint8_t *aacs_get_vid(AACS *aacs);
#endif /* AACS_H_ */
|
Fix o_builtin_print and o_assign cases not breaking. | #include "lily_impl.h"
#include "lily_symtab.h"
#include "lily_opcode.h"
static void builtin_print(lily_symbol *s)
{
if (s->val_type == vt_str)
lily_impl_send_html(((lily_strval *)s->sym_value)->str);
}
void lily_vm_execute(lily_symbol *sym)
{
lily_symbol **regs;
int *code, ci;
regs = lily_impl_malloc(8 * sizeof(lily_symbol *));
code = sym->code_data->code;
ci = 0;
while (1) {
switch (code[ci]) {
case o_load_reg:
regs[code[ci+1]] = (lily_symbol *)code[ci+2];
ci += 3;
break;
case o_builtin_print:
builtin_print(regs[code[ci+1]]);
ci += 2;
case o_assign:
regs[code[ci]]->sym_value = (void *)code[ci+1];
regs[code[ci]]->val_type = (lily_val_type)code[ci+2];
ci += 3;
case o_vm_return:
free(regs);
return;
}
}
}
| #include "lily_impl.h"
#include "lily_symtab.h"
#include "lily_opcode.h"
static void builtin_print(lily_symbol *s)
{
if (s->val_type == vt_str)
lily_impl_send_html(((lily_strval *)s->sym_value)->str);
}
void lily_vm_execute(lily_symbol *sym)
{
lily_symbol **regs;
int *code, ci;
regs = lily_impl_malloc(8 * sizeof(lily_symbol *));
code = sym->code_data->code;
ci = 0;
while (1) {
switch (code[ci]) {
case o_load_reg:
regs[code[ci+1]] = (lily_symbol *)code[ci+2];
ci += 3;
break;
case o_builtin_print:
builtin_print(regs[code[ci+1]]);
ci += 2;
break;
case o_assign:
regs[code[ci]]->sym_value = (void *)code[ci+1];
regs[code[ci]]->val_type = (lily_val_type)code[ci+2];
ci += 3;
break;
case o_vm_return:
free(regs);
return;
}
}
}
|
Fix for compiler error in r4154 | /*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkStippleMaskFilter_DEFINED
#define SkStippleMaskFilter_DEFINED
#include "SkMaskFilter.h"
/**
* Simple MaskFilter that creates a screen door stipple pattern
*/
class SkStippleMaskFilter : public SkMaskFilter {
public:
SkStippleMaskFilter() : INHERITED() {
}
virtual bool filterMask(SkMask* dst, const SkMask& src,
const SkMatrix& matrix,
SkIPoint* margin) SK_OVERRIDE;
// getFormat is from SkMaskFilter
virtual SkMask::Format getFormat() SK_OVERRIDE {
return SkMask::kA8_Format;
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter);
protected:
SkStippleMaskFilter::SkStippleMaskFilter(SkFlattenableReadBuffer& buffer)
: SkMaskFilter(buffer) {
}
private:
typedef SkMaskFilter INHERITED;
};
#endif // SkStippleMaskFilter_DEFINED | /*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkStippleMaskFilter_DEFINED
#define SkStippleMaskFilter_DEFINED
#include "SkMaskFilter.h"
/**
* Simple MaskFilter that creates a screen door stipple pattern
*/
class SkStippleMaskFilter : public SkMaskFilter {
public:
SkStippleMaskFilter() : INHERITED() {
}
virtual bool filterMask(SkMask* dst, const SkMask& src,
const SkMatrix& matrix,
SkIPoint* margin) SK_OVERRIDE;
// getFormat is from SkMaskFilter
virtual SkMask::Format getFormat() SK_OVERRIDE {
return SkMask::kA8_Format;
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter);
protected:
SkStippleMaskFilter(SkFlattenableReadBuffer& buffer)
: SkMaskFilter(buffer) {
}
private:
typedef SkMaskFilter INHERITED;
};
#endif // SkStippleMaskFilter_DEFINED
|
Fix a bug in emulator persistent storage | /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Persistence module for emulator */
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#define BUF_SIZE 1024
static void get_storage_path(char *out)
{
char buf[BUF_SIZE];
readlink("/proc/self/exe", buf, BUF_SIZE);
if (snprintf(out, BUF_SIZE, "%s_persist", buf) >= BUF_SIZE)
out[BUF_SIZE - 1] = '\0';
}
FILE *get_persistent_storage(const char *tag, const char *mode)
{
char buf[BUF_SIZE];
char path[BUF_SIZE];
/*
* The persistent storage with tag 'foo' for test 'bar' would
* be named 'bar_persist_foo'
*/
get_storage_path(buf);
if (snprintf(path, BUF_SIZE, "%s_%s", buf, tag) >= BUF_SIZE)
path[BUF_SIZE - 1] = '\0';
return fopen(path, mode);
}
void release_persistent_storage(FILE *ps)
{
fclose(ps);
}
| /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Persistence module for emulator */
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#define BUF_SIZE 1024
static void get_storage_path(char *out)
{
char buf[BUF_SIZE];
int sz;
sz = readlink("/proc/self/exe", buf, BUF_SIZE);
buf[sz] = '\0';
if (snprintf(out, BUF_SIZE, "%s_persist", buf) >= BUF_SIZE)
out[BUF_SIZE - 1] = '\0';
}
FILE *get_persistent_storage(const char *tag, const char *mode)
{
char buf[BUF_SIZE];
char path[BUF_SIZE];
/*
* The persistent storage with tag 'foo' for test 'bar' would
* be named 'bar_persist_foo'
*/
get_storage_path(buf);
if (snprintf(path, BUF_SIZE, "%s_%s", buf, tag) >= BUF_SIZE)
path[BUF_SIZE - 1] = '\0';
return fopen(path, mode);
}
void release_persistent_storage(FILE *ps)
{
fclose(ps);
}
|
Add missing import in umbrella header | @import Foundation;
@import CoreData;
FOUNDATION_EXPORT double SyncVersionNumber;
FOUNDATION_EXPORT const unsigned char SyncVersionString[];
#import <Sync/SYNCPropertyMapper.h>
#import <Sync/NSEntityDescription+SYNCPrimaryKey.h>
| @import Foundation;
@import CoreData;
FOUNDATION_EXPORT double SyncVersionNumber;
FOUNDATION_EXPORT const unsigned char SyncVersionString[];
#import <Sync/SYNCPropertyMapper.h>
#import <Sync/NSEntityDescription+SYNCPrimaryKey.h>
#import <Sync/NSManagedObject+SYNCPropertyMapperHelpers.h>
|
Fix return value of reevaluate in local search | #pragma once
#include <cstddef>
#include <utility>
template <class Type, class Mut, class Eval, class Init> struct local_search {
local_search(Mut &mutator, Eval &evaluator, Init &initializer)
: _mutator(mutator)
, _evaluator(evaluator)
, _initializer(initializer) {
_initializer.apply(_solution_a);
_score_a = _evaluator(_solution_a);
}
void run(const std::size_t iterations) {
for (std::size_t i = 0; i != iterations; ++i)
_step();
}
void reevaluate() { return _score_a = _evaluator.apply(_solution_a); }
private:
Type _solution_a;
Type _solution_b;
double _score_a;
double _score_b;
Mut &_mutator;
Eval &_evaluator;
Init &_initializer;
void _step() {
_solution_b = _solution_a;
_mutator.apply(_solution_b);
_score_b = _evaluator.apply(_solution_b);
if (_score_a <= _score_b) {
using std::swap;
swap(_solution_a, _solution_b);
swap(_score_a, _score_b);
}
}
};
| #pragma once
#include <cstddef>
#include <utility>
template <class Type, class Mut, class Eval, class Init> struct local_search {
local_search(Mut &mutator, Eval &evaluator, Init &initializer)
: _mutator(mutator)
, _evaluator(evaluator)
, _initializer(initializer) {
_initializer.apply(_solution_a);
_score_a = _evaluator(_solution_a);
}
void run(const std::size_t iterations) {
for (std::size_t i = 0; i != iterations; ++i)
_step();
}
double reevaluate() { return _score_a = _evaluator.apply(_solution_a); }
private:
Type _solution_a;
Type _solution_b;
double _score_a;
double _score_b;
Mut &_mutator;
Eval &_evaluator;
Init &_initializer;
void _step() {
_solution_b = _solution_a;
_mutator.apply(_solution_b);
_score_b = _evaluator.apply(_solution_b);
if (_score_a <= _score_b) {
using std::swap;
swap(_solution_a, _solution_b);
swap(_score_a, _score_b);
}
}
};
|
Add convenient method to stub API responses | //
// PKTStubs.h
// PodioKit
//
// Created by Romain Briche on 30/01/14.
// Copyright (c) 2014 Citrix Systems, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <OHHTTPStubs/OHHTTPStubs.h>
void (^stubResponseFromFile)(NSString *, NSString *) = ^(NSString *path, NSString *responseFilename) {
NSDictionary *headers = @{@"Content-Type": @"application/json; charset=utf-8"};
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [[[request URL] path] isEqualToString:path];
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
return [OHHTTPStubsResponse responseWithFileAtPath:OHPathForFileInDocumentsDir(responseFilename) statusCode:200 headers:headers];
}];
};
void (^stubResponseFromObject)(NSString *, id) = ^(NSString *path, id responseObject) {
NSDictionary *headers = @{@"Content-Type": @"application/json; charset=utf-8"};
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [[[request URL] path] isEqualToString:path];
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
NSData *data = [NSJSONSerialization dataWithJSONObject:responseObject options:0 error:NULL];
return [OHHTTPStubsResponse responseWithData:data statusCode:200 headers:headers];
}];
};
void (^stubResponseWithStatusCode)(NSString *, int) = ^(NSString *path, int statusCode) {
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [[[request URL] path] isEqualToString:path];
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
return [OHHTTPStubsResponse responseWithData:[NSData data] statusCode:statusCode headers:nil];
}];
};
void (^stubResponseWithTime)(NSString *, int, int) = ^(NSString *path, int requestTime, int responseTime) {
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [[[request URL] path] isEqualToString:path];
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
return [[OHHTTPStubsResponse responseWithData:[NSData data] statusCode:200 headers:nil] requestTime:requestTime responseTime:responseTime];
}];
};
| |
Fix dependency generation crash test to run clang and clean up after itself. | // RUN: touch %t
// RUN: chmod 0 %t
// %clang -E -dependency-file bla -MT %t -MP -o %t -x c /dev/null
// rdar://9286457
| // RUN: touch %t
// RUN: chmod 0 %t
// RUN: not %clang_cc1 -E -dependency-file bla -MT %t -MP -o %t -x c /dev/null 2>&1 | FileCheck %s
// RUN: rm -f %t
// CHECK: error: unable to open output file
// rdar://9286457
|
Clean up 1: Removed old comment and vs fixed some line endings. | #ifndef RPLNN_TEXTURE_H
#define RPLNN_TEXTURE_H
struct texture;
/* Should create a version of this which doesn't malloc (basically just give memory block as a parameter). */
struct texture *texture_create(const char *file_name);
void texture_destroy(struct texture **texture);
/* Just create a stryct vec2_int texture_get_size func */
void texture_get_info(struct texture *texture, uint32_t **buf, struct vec2_int **size);
#endif /* RPLNN_TEXTURE_H */
| #ifndef RPLNN_TEXTURE_H
#define RPLNN_TEXTURE_H
struct texture;
/* Should create a version of this which doesn't malloc (basically just give memory block as a parameter). */
struct texture *texture_create(const char *file_name);
void texture_destroy(struct texture **texture);
void texture_get_info(struct texture *texture, uint32_t **buf, struct vec2_int **size);
#endif /* RPLNN_TEXTURE_H */
|
Add additional nested struct redefinition test | // RUN: %ucc -fsyntax-only %s
struct B
{
int i;
};
struct Global
{
char *s;
};
f()
{
struct A
{
int i;
struct Global g;
} a;
struct B
{
int j, k;
};
a.g.s = "hi";
struct B;
struct B b;
b.k = 3;
{
struct B x = { .k = 5 };
}
}
struct R
{
struct R *next;
};
struct R r = { &r };
| |
Declare size_t as unsigned long | /******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation
* All rights reserved.
* This program and the accompanying materials
* are made available under the terms of the BSD License
* which accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php
*
* Contributors:
* IBM Corporation - initial implementation
*****************************************************************************/
#ifndef _STDDEF_H
#define _STDDEF_H
#define NULL ((void *)0)
typedef unsigned int size_t;
#endif
| /******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation
* All rights reserved.
* This program and the accompanying materials
* are made available under the terms of the BSD License
* which accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php
*
* Contributors:
* IBM Corporation - initial implementation
*****************************************************************************/
#ifndef _STDDEF_H
#define _STDDEF_H
#define NULL ((void *)0)
typedef unsigned long size_t;
#endif
|
Add g_autoptr() support for GParamSpec | /*
* Copyright © 2015 Canonical Limited
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GClosure, g_closure_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset)
| /*
* Copyright © 2015 Canonical Limited
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GClosure, g_closure_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GParamSpec, g_param_spec_unref)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset)
|
Add solution for problem 10 | /*
* The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
*
* Find the sum of all the primes below two million.
*/
#include <stdio.h>
#include <stdint.h>
#include "euler.h"
#define PROBLEM 10
int
main(int argc, char **argv)
{
uint64_t sum = 0, number = 0;
do {
number++;
if(is_prime(number)) {
sum += number;
}
} while(number != 2000000);
printf("%llu\n", sum);
return(0);
}
| |
Add a return statement to spcTokenize. | #include <stdlib.h>
#include <stdio.h>
#include types.c
#include <string.h>
/* We can:
Set something equal to something
Function calls
Function definitions
Returning things -- delimiter '<'
Printing things
Iffing */
struct call parseCall(char* statement);
struct function parseFunction(char* statement);
char* fixSpacing(char* code) {
char* fixedCode = malloc(sizeof(char) * (strlen(code) + 1));
fixedCode = strcpy(fixedCode, code);
char* doubleSpace = strstr(fixedCode, " ");
char* movingIndex;
for( ; doubleSpace; doubleSpace = strstr(fixedCode, " ")) {
for(movingIndex = doubleSpace; movingIndex&; movingIndex++) {
movingIndex[0] = movingIndex[1];
}
}
return fixedCode;
}
char** spcTokenize(char* regCode) {
int n = 0;
int i;
for(i = 0; regCode[i]; i++) {
if(regCode[i] == ' ') {
n++;
}
}
char** spcTokens = malloc(sizeof(char*) * (n+1));
int k;
for(i = 0; i < n+1; i++) {
k = strchr(regCode, ' ') - regCode;
regCode[k] = NULL;
spcTokens[i] = regCode + k + 1;
}
}
| #include <stdlib.h>
#include <stdio.h>
#include types.c
#include <string.h>
/* We can:
Set something equal to something
Function calls
Function definitions
Returning things -- delimiter '<'
Printing things
Iffing */
char* fixSpacing(char* code) {
char* fixedCode = malloc(sizeof(char) * (strlen(code) + 1));
fixedCode = strcpy(fixedCode, code);
char* doubleSpace = strstr(fixedCode, " ");
char* movingIndex;
for( ; doubleSpace; doubleSpace = strstr(fixedCode, " ")) {
for(movingIndex = doubleSpace; movingIndex&; movingIndex++) {
movingIndex[0] = movingIndex[1];
}
}
return fixedCode;
}
char** spcTokenize(char* regCode) {
int n = 0;
int i;
for(i = 0; regCode[i]; i++) {
if(regCode[i] == ' ') {
n++;
}
}
char** spcTokens = malloc(sizeof(char*) * (n+1));
int k;
for(i = 0; i < n+1; i++) {
k = strchr(regCode, ' ') - regCode;
regCode[k] = NULL;
spcTokens[i] = regCode + k + 1;
}
return spcTokens;
}
|
Fix typo in message and add colors | #include <stdio.h>
#include <ctype.h>
#include "debug.h"
#ifndef NDEBUG
regex_t _comp;
// Initialize the regular expression used for restricting debug output
static void __attribute__ ((constructor)) premain()
{
if (regcomp(&_comp, DCOMPONENT, REG_EXTENDED|REG_ICASE|REG_NOSUB))
die("mayb not a valid regexp: %s", DCOMPONENT);
}
// Print a hexdump of the given block
void hexdump(const void * const ptr, const unsigned len)
{
const char * const buf = (const char * const)ptr;
for (unsigned i = 0; i < len; i += 16) {
fprintf(stderr, "%06x: ", i);
for (unsigned j = 0; j < 16; j++)
if (i+j < len)
fprintf(stderr, "%02hhx ", buf[i+j]);
else
fprintf(stderr, " ");
fprintf(stderr, " ");
for (unsigned j = 0; j < 16; j++)
if (i+j < len)
fprintf(stderr, "%c",
isprint(buf[i+j]) ? buf[i+j] : '.');
fprintf(stderr, "\n");
}
}
#endif
| #include <stdio.h>
#include <ctype.h>
#include "debug.h"
#ifndef NDEBUG
char *col[6] = { MAG, RED, YEL, CYN, BLU, GRN };
regex_t _comp;
// Initialize the regular expression used for restricting debug output
static void __attribute__ ((constructor)) premain()
{
if (regcomp(&_comp, DCOMPONENT, REG_EXTENDED|REG_ICASE|REG_NOSUB))
die("may not be a valid regexp: %s", DCOMPONENT);
}
// Print a hexdump of the given block
void hexdump(const void * const ptr, const unsigned len)
{
const char * const buf = (const char * const)ptr;
for (unsigned i = 0; i < len; i += 16) {
fprintf(stderr, "%06x: ", i);
for (unsigned j = 0; j < 16; j++)
if (i+j < len)
fprintf(stderr, "%02hhx ", buf[i+j]);
else
fprintf(stderr, " ");
fprintf(stderr, " ");
for (unsigned j = 0; j < 16; j++)
if (i+j < len)
fprintf(stderr, "%c",
isprint(buf[i+j]) ? buf[i+j] : '.');
fprintf(stderr, "\n");
}
}
#endif
|
Use of vpiHandle requires inclusion of vpi_user. | // -*- c++ -*-
/*
Copyright 2019 Alain Dargelas
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.
*/
/*
* File: VpiListener.h
* Author: alaindargelas
*
* Created on December 14, 2019, 10:03 PM
*/
#ifndef UHDM_VPILISTENER_CLASS_H
#define UHDM_VPILISTENER_CLASS_H
#include "headers/uhdm_forward_decl.h"
namespace UHDM {
class VpiListener {
public:
// Use implicit constructor to initialize all members
// VpiListener()
virtual ~VpiListener() {}
<VPI_LISTENER_METHODS>
protected:
};
};
#endif
| // -*- c++ -*-
/*
Copyright 2019 Alain Dargelas
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.
*/
/*
* File: VpiListener.h
* Author: alaindargelas
*
* Created on December 14, 2019, 10:03 PM
*/
#ifndef UHDM_VPILISTENER_CLASS_H
#define UHDM_VPILISTENER_CLASS_H
#include "headers/uhdm_forward_decl.h"
#include "include/vpi_user.h"
namespace UHDM {
class VpiListener {
public:
// Use implicit constructor to initialize all members
// VpiListener()
virtual ~VpiListener() {}
<VPI_LISTENER_METHODS>
};
} // namespace UHDM
#endif
|
Include vjConfig.h rather than mstring.h to get the basic_string implmentation. | #ifndef _VJ_DEVICE_INTERFACE_H_
#define _VJ_DEVICE_INTERFACE_H_
//: Base class for simplified interfaces
//
// Interfaces provide an easier way to access proxy objects from
// within user applications. <br> <br>
//
// Users can simply declare a local interface variable and use it
// as a smart_ptr for the proxy
//
//! NOTE: The init function should be called in the init function of the user
//+ application
#include <mstring.h>
class vjDeviceInterface
{
public:
vjDeviceInterface() : mProxyIndex(-1)
{;}
//: Initialize the object
//! ARGS: proxyName - String name of the proxy to connect to
void init(string proxyName);
//: Return the index of the proxy
int getProxyIndex()
{ return mProxyIndex; }
protected:
int mProxyIndex; //: The index of the proxy
};
#endif
| #ifndef _VJ_DEVICE_INTERFACE_H_
#define _VJ_DEVICE_INTERFACE_H_
//: Base class for simplified interfaces
//
// Interfaces provide an easier way to access proxy objects from
// within user applications. <br> <br>
//
// Users can simply declare a local interface variable and use it
// as a smart_ptr for the proxy
//
//! NOTE: The init function should be called in the init function of the user
//+ application
#include <vjConfig.h>
class vjDeviceInterface
{
public:
vjDeviceInterface() : mProxyIndex(-1)
{;}
//: Initialize the object
//! ARGS: proxyName - String name of the proxy to connect to
void init(string proxyName);
//: Return the index of the proxy
int getProxyIndex()
{ return mProxyIndex; }
protected:
int mProxyIndex; //: The index of the proxy
};
#endif
|
Add sample C code for comparing serializations | #include <stdlib.h>
#include <stdio.h>
#include <dbus/dbus.h>
void main(int argc, char* argv[]) {
DBusMessage* m;
dbus_uint32_t arg_a = 0x11223344;
char arg_b = 0x42;
const dbus_uint64_t array[] = {};
const dbus_uint64_t *arg_c = array;
char arg_d = 0x23;
char* wire;
int len;
m = dbus_message_new_method_call(NULL,
"/",
NULL,
"Test");
dbus_message_append_args(m,
DBUS_TYPE_UINT32, &arg_a,
DBUS_TYPE_BYTE, &arg_b,
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, &arg_c, 0,
DBUS_TYPE_BYTE, &arg_d,
DBUS_TYPE_INVALID);
dbus_message_marshal(m, &wire, &len);
for (int i = 0; i < len; i++) {
printf("%02x", wire[i]);
if ( (i+1) % 8) {
printf(" ");
} else {
printf("\n");
}
}
exit(0);
}
| |
Use standard smart pointers by default. | #ifndef SAUCE_MEMORY_H_
#define SAUCE_MEMORY_H_
#if SAUCE_STD_SMART_PTR
#include <sauce/internal/memory/std.h>
#elif SAUCE_STD_TR1_SMART_PTR
#include <sauce/internal/memory/tr1.h>
#elif SAUCE_BOOST_SMART_PTR
#include <sauce/internal/memory/boost.h>
#else
#error Please define SAUCE_STD_SMART_PTR, SAUCE_STD_TR1_SMART_PTR or SAUCE_BOOST_SMART_PTR
#endif
#endif // SAUCE_MEMORY_H_
| #ifndef SAUCE_MEMORY_H_
#define SAUCE_MEMORY_H_
#if SAUCE_STD_SMART_PTR
#include <sauce/internal/memory/std.h>
#elif SAUCE_STD_TR1_SMART_PTR
#include <sauce/internal/memory/tr1.h>
#elif SAUCE_BOOST_SMART_PTR
#include <sauce/internal/memory/boost.h>
#else
#include <sauce/internal/memory/std.h>
#endif
#endif // SAUCE_MEMORY_H_
|
Fix Win32 implementation of Now() | #ifndef WEBDRIVERXX_DETAIL_TIME_H
#define WEBDRIVERXX_DETAIL_TIME_H
#include "error_handling.h"
#include "../types.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <time.h>
#endif
namespace webdriverxx {
namespace detail {
TimePoint Now() {
#ifdef _WIN32
FILETIME time;
::GetSystemTimeAsFileTime(&time);
return (static_cast<TimePoint>(time.dwHighDateTime) << 32)
+ time.dwLowDateTime;
#else
timeval time = {};
WEBDRIVERXX_CHECK(0 == gettimeofday(&time, nullptr), "gettimeofday failure");
return static_cast<TimePoint>(time.tv_sec)*1000 + time.tv_usec/1000;
#endif
}
void Sleep(Duration milliseconds) {
#ifdef _WIN32
::Sleep(static_cast<DWORD>(milliseconds));
#else
timespec time = { static_cast<time_t>(milliseconds/1000),
static_cast<long>(milliseconds%1000)*1000000 };
while (nanosleep(&time, &time)) {}
#endif
}
} // namespace detail
} // namespace webdriverxx
#endif
| #ifndef WEBDRIVERXX_DETAIL_TIME_H
#define WEBDRIVERXX_DETAIL_TIME_H
#include "error_handling.h"
#include "../types.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <time.h>
#endif
namespace webdriverxx {
namespace detail {
TimePoint Now() {
#ifdef _WIN32
FILETIME time;
::GetSystemTimeAsFileTime(&time);
return ((static_cast<TimePoint>(time.dwHighDateTime) << 32)
+ time.dwLowDateTime)/10000;
#else
timeval time = {};
WEBDRIVERXX_CHECK(0 == gettimeofday(&time, nullptr), "gettimeofday failure");
return static_cast<TimePoint>(time.tv_sec)*1000 + time.tv_usec/1000;
#endif
}
void Sleep(Duration milliseconds) {
#ifdef _WIN32
::Sleep(static_cast<DWORD>(milliseconds));
#else
timespec time = { static_cast<time_t>(milliseconds/1000),
static_cast<long>(milliseconds%1000)*1000000 };
while (nanosleep(&time, &time)) {}
#endif
}
} // namespace detail
} // namespace webdriverxx
#endif
|
Move static function into macro to circumvent unused function waringn-erros. | #ifndef SRC_UTILS_CUDA_HELPER_H_
#define SRC_UTILS_CUDA_HELPER_H_
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
#include <stdexcept>
static void HandleError(cudaError_t error, const char *file, int line)
{
if (error != cudaSuccess)
{
printf("%s in %s at line %d\n", cudaGetErrorString(error), file, line);
throw std::runtime_error(cudaGetErrorString(error));
}
}
#define HANDLE_ERROR(error) (HandleError(error, __FILE__, __LINE__))
#define HANDLE_NULL(a) \
{ \
if (a == NULL) \
{ \
printf("Host memory failed in %s at line %d\n", __FILE__, __LINE__); \
exit(EXIT_FAILURE); \
} \
}
#endif // SRC_UTILS_CUDA_HELPER_H_
| #ifndef SRC_UTILS_CUDA_HELPER_H_
#define SRC_UTILS_CUDA_HELPER_H_
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
#include <stdexcept>
#define HANDLE_ERROR(error) \
{ \
if (error != cudaSuccess) \
{ \
printf("%s in %s at line %d\n", cudaGetErrorString(error), __FILE__, \
__LINE__); \
throw std::runtime_error(cudaGetErrorString(error)); \
} \
}
#define HANDLE_NULL(a) \
{ \
if (a == NULL) \
{ \
printf("Host memory failed in %s at line %d\n", __FILE__, __LINE__); \
exit(EXIT_FAILURE); \
} \
}
#endif // SRC_UTILS_CUDA_HELPER_H_
|
Update revno in config file | //---------------------------------------------------------------------------------------
// This file is part of the Lomse library.
// Do not alter layout. Will affect CMakeLists.txt data extraction code
//
// | All values aligned here
#define LOMSE_VERSION_MAJOR 0
#define LOMSE_VERSION_MINOR 16
#define LOMSE_VERSION_TYPE ' '
#define LOMSE_VERSION_PATCH 2
#define LOMSE_VERSION_REVNO 134
#define LOMSE_VERSION_DATE "2016-01-25 12:41:25 +01:00"
| //---------------------------------------------------------------------------------------
// This file is part of the Lomse library.
// Do not alter layout. Will affect CMakeLists.txt data extraction code
//
// | All values aligned here
#define LOMSE_VERSION_MAJOR 0
#define LOMSE_VERSION_MINOR 16
#define LOMSE_VERSION_TYPE ' '
#define LOMSE_VERSION_PATCH 2
#define LOMSE_VERSION_REVNO 139
#define LOMSE_VERSION_DATE "2016-01-25 13:59:34 +01:00"
|
Use correct variable for number of tests | #include <stdlib.h>
#include <stdio.h>
#include <check.h>
#include "check_check.h"
int main (void)
{
int n;
SRunner *sr;
fork_setup();
setup_fixture();
sr = srunner_create (make_master_suite());
srunner_add_suite(sr, make_list_suite());
srunner_add_suite(sr, make_msg_suite());
srunner_add_suite(sr, make_log_suite());
srunner_add_suite(sr, make_limit_suite());
srunner_add_suite(sr, make_fork_suite());
srunner_add_suite(sr, make_fixture_suite());
srunner_add_suite(sr, make_pack_suite());
setup();
printf ("Ran %d tests in subordinate suite\n", sub_nfailed);
srunner_run_all (sr, CK_NORMAL);
cleanup();
fork_teardown();
teardown_fixture();
n = srunner_ntests_failed(sr);
srunner_free(sr);
return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
| #include <stdlib.h>
#include <stdio.h>
#include <check.h>
#include "check_check.h"
int main (void)
{
int n;
SRunner *sr;
fork_setup();
setup_fixture();
sr = srunner_create (make_master_suite());
srunner_add_suite(sr, make_list_suite());
srunner_add_suite(sr, make_msg_suite());
srunner_add_suite(sr, make_log_suite());
srunner_add_suite(sr, make_limit_suite());
srunner_add_suite(sr, make_fork_suite());
srunner_add_suite(sr, make_fixture_suite());
srunner_add_suite(sr, make_pack_suite());
setup();
printf ("Ran %d tests in subordinate suite\n", sub_ntests);
srunner_run_all (sr, CK_NORMAL);
cleanup();
fork_teardown();
teardown_fixture();
n = srunner_ntests_failed(sr);
srunner_free(sr);
return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
|
Debug label inline function bug | // ucc -g tim.c
_Noreturn void abort()
{
__builtin_unreachable();
}
void realloc()
{
int local = 5;
abort();
}
| |
Check that assignments to NMEM memory for some basic types | /*
* Copyright (c) 2002-2004, Index Data
* See the file LICENSE for details.
*
* $Id: tstnmem.c,v 1.2 2004-09-29 20:15:48 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <yaz/nmem.h>
int main (int argc, char **argv)
{
void *cp;
NMEM n;
int j;
nmem_init();
n = nmem_create();
if (!n)
exit (1);
for (j = 1; j<500; j++)
{
cp = nmem_malloc(n, j);
if (!cp)
exit(2);
}
for (j = 2000; j<20000; j+= 2000)
{
cp = nmem_malloc(n, j);
if (!cp)
exit(3);
}
nmem_destroy(n);
nmem_exit();
exit(0);
}
| /*
* Copyright (c) 2002-2004, Index Data
* See the file LICENSE for details.
*
* $Id: tstnmem.c,v 1.3 2005-01-05 10:29:42 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <yaz/nmem.h>
int main (int argc, char **argv)
{
void *cp;
NMEM n;
int j;
nmem_init();
n = nmem_create();
if (!n)
exit (1);
for (j = 1; j<500; j++)
{
cp = nmem_malloc(n, j);
if (!cp)
exit(2);
if (sizeof(long) >= j)
*(long*) cp = 123L;
#if HAVE_LONG_LONG
if (sizeof(long long) >= j)
*(long long*) cp = 123L;
#endif
if (sizeof(double) >= j)
*(double*) cp = 12.2;
}
for (j = 2000; j<20000; j+= 2000)
{
cp = nmem_malloc(n, j);
if (!cp)
exit(3);
}
nmem_destroy(n);
nmem_exit();
exit(0);
}
|
Use '--replace-whitespace' option for scsi_id | #define DEFAULT_GETUID "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
#define DEFAULT_UDEVDIR "/dev"
#define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath"
#define DEFAULT_SELECTOR "round-robin 0"
#define DEFAULT_ALIAS_PREFIX "mpath"
#define DEFAULT_FEATURES "0"
#define DEFAULT_HWHANDLER "0"
#define DEFAULT_MINIO 1000
#define DEFAULT_MINIO_RQ 1
#define DEFAULT_PGPOLICY FAILOVER
#define DEFAULT_FAILBACK -FAILBACK_MANUAL
#define DEFAULT_RR_WEIGHT RR_WEIGHT_NONE
#define DEFAULT_NO_PATH_RETRY NO_PATH_RETRY_UNDEF
#define DEFAULT_PGTIMEOUT -PGTIMEOUT_NONE
#define DEFAULT_USER_FRIENDLY_NAMES 0
#define DEFAULT_VERBOSITY 2
#define DEFAULT_CHECKINT 5
#define MAX_CHECKINT(a) (a << 2)
#define DEFAULT_PIDFILE "/var/run/multipathd.pid"
#define DEFAULT_SOCKET "/var/run/multipathd.sock"
#define DEFAULT_CONFIGFILE "/etc/multipath.conf"
#define DEFAULT_BINDINGS_FILE "/etc/multipath/bindings"
char * set_default (char * str);
| #define DEFAULT_GETUID "/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/%n"
#define DEFAULT_UDEVDIR "/dev"
#define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath"
#define DEFAULT_SELECTOR "round-robin 0"
#define DEFAULT_ALIAS_PREFIX "mpath"
#define DEFAULT_FEATURES "0"
#define DEFAULT_HWHANDLER "0"
#define DEFAULT_MINIO 1000
#define DEFAULT_MINIO_RQ 1
#define DEFAULT_PGPOLICY FAILOVER
#define DEFAULT_FAILBACK -FAILBACK_MANUAL
#define DEFAULT_RR_WEIGHT RR_WEIGHT_NONE
#define DEFAULT_NO_PATH_RETRY NO_PATH_RETRY_UNDEF
#define DEFAULT_PGTIMEOUT -PGTIMEOUT_NONE
#define DEFAULT_USER_FRIENDLY_NAMES 0
#define DEFAULT_VERBOSITY 2
#define DEFAULT_CHECKINT 5
#define MAX_CHECKINT(a) (a << 2)
#define DEFAULT_PIDFILE "/var/run/multipathd.pid"
#define DEFAULT_SOCKET "/var/run/multipathd.sock"
#define DEFAULT_CONFIGFILE "/etc/multipath.conf"
#define DEFAULT_BINDINGS_FILE "/etc/multipath/bindings"
char * set_default (char * str);
|
Fix o_builtin_print and o_assign cases not breaking. | #include "lily_impl.h"
#include "lily_symtab.h"
#include "lily_opcode.h"
static void builtin_print(lily_symbol *s)
{
if (s->val_type == vt_str)
lily_impl_send_html(((lily_strval *)s->sym_value)->str);
}
void lily_vm_execute(lily_symbol *sym)
{
lily_symbol **regs;
int *code, ci;
regs = lily_impl_malloc(8 * sizeof(lily_symbol *));
code = sym->code_data->code;
ci = 0;
while (1) {
switch (code[ci]) {
case o_load_reg:
regs[code[ci+1]] = (lily_symbol *)code[ci+2];
ci += 3;
break;
case o_builtin_print:
builtin_print(regs[code[ci+1]]);
ci += 2;
case o_assign:
regs[code[ci]]->sym_value = (void *)code[ci+1];
regs[code[ci]]->val_type = (lily_val_type)code[ci+2];
ci += 3;
case o_vm_return:
free(regs);
return;
}
}
}
| #include "lily_impl.h"
#include "lily_symtab.h"
#include "lily_opcode.h"
static void builtin_print(lily_symbol *s)
{
if (s->val_type == vt_str)
lily_impl_send_html(((lily_strval *)s->sym_value)->str);
}
void lily_vm_execute(lily_symbol *sym)
{
lily_symbol **regs;
int *code, ci;
regs = lily_impl_malloc(8 * sizeof(lily_symbol *));
code = sym->code_data->code;
ci = 0;
while (1) {
switch (code[ci]) {
case o_load_reg:
regs[code[ci+1]] = (lily_symbol *)code[ci+2];
ci += 3;
break;
case o_builtin_print:
builtin_print(regs[code[ci+1]]);
ci += 2;
break;
case o_assign:
regs[code[ci]]->sym_value = (void *)code[ci+1];
regs[code[ci]]->val_type = (lily_val_type)code[ci+2];
ci += 3;
break;
case o_vm_return:
free(regs);
return;
}
}
}
|
Make the struct bigger, to ensure it is returned by struct return. | // RUN: %llvmgcc %s -S -fnested-functions -o - | grep {sret *%agg.result}
struct X { int m, n, o, p; };
struct X p(int n) {
struct X c(int m) {
struct X x;
x.m = m;
x.n = n;
return x;
}
return c(n);
}
| // RUN: %llvmgcc %s -S -fnested-functions -o - | grep {sret *%agg.result}
struct X { long m, n, o, p; };
struct X p(int n) {
struct X c(int m) {
struct X x;
x.m = m;
x.n = n;
return x;
}
return c(n);
}
|
Add octApron test where bigint is required | // SKIP PARAM: --sets ana.activated[+] octApron
#include <assert.h>
void main() {
// requires bigint, not int64
unsigned long long x, y, z;
if (x < y && y < z) {
assert(x < y);
assert(y < z);
assert(x < z);
if (18446744073709551612ull <= x && z <= 18446744073709551615ull) {
assert(18446744073709551612ull <= x);
assert(x <= 18446744073709551613ull);
assert(18446744073709551613ull <= y);
assert(y <= 18446744073709551614ull);
assert(18446744073709551614ull <= z);
assert(z <= 18446744073709551615ull);
assert(x >= x - x); // avoid base from answering to check if octApron doesn't say x == -3
assert(y >= y - y); // avoid base from answering to check if octApron doesn't say y == -3
assert(z >= z - z); // avoid base from answering to check if octApron doesn't say z == -3
}
}
}
| |
Add platform names in orbit_platform.h | //
// orbit_platforms.h
// OrbitVM
//
// Created by Cesar Parent on 2016-11-14.
// Copyright © 2016 cesarparent. All rights reserved.
//
#ifndef OrbitPlatforms_h
#define OrbitPlatforms_h
#if __STDC_VERSION__ >= 199901L
#define ORBIT_FLEXIBLE_ARRAY_MEMB
#else
#define ORBIT_FLEXIBLE_ARRRAY_MEMB 0
#endif
#endif /* OrbitPlatforms_h */
| //
// orbit_platforms.h
// OrbitVM
//
// Created by Cesar Parent on 2016-11-14.
// Copyright © 2016 cesarparent. All rights reserved.
//
#ifndef OrbitPlatforms_h
#define OrbitPlatforms_h
#ifdef _WIN32
#define ORBIT_PLATFORM "Windows"
#elif __APPLE__
#include "TargetConditionals.h"
#if TARGET_IPHONE_SIMULATOR
#define ORBIT_PLATFORM "iOS-x86"
#elif TARGET_OS_IPHONE
#define ORBIT_PLATFORM "iOS-arm"
#elif TARGET_OS_MAC
#define ORBIT_PLATFORM "macOS"
#endif
#elif __linux__
#define ORBIT_PLATFORM "Linux"
#elif __unix__
#define ORBIT_PLATFORM "UNIX"
#else
#define ORBIT_PLATFORM "Unknown Platform"
#endif
#if __STDC_VERSION__ >= 199901L
#define ORBIT_FLEXIBLE_ARRAY_MEMB
#else
#define ORBIT_FLEXIBLE_ARRRAY_MEMB 0
#endif
#endif /* OrbitPlatforms_h */
|
Define HAVE_RB_DEFINE_ALLOC_FUNC for postgres gem. | /* Stub file provided for C extensions that expect it. All regular
* defines and prototypes are in ruby.h
*/
#define RUBY
/* These are defines directly related to MRI C-API symbols that the
* mkmf.rb discovery code (e.g. have_func("rb_str_set_len")) would
* attempt to find by linking against libruby. Rubinius does not
* have an appropriate lib to link against, so we are adding these
* explicit defines for now.
*/
#define HAVE_RB_STR_SET_LEN
| /* Stub file provided for C extensions that expect it. All regular
* defines and prototypes are in ruby.h
*/
#define RUBY
/* These are defines directly related to MRI C-API symbols that the
* mkmf.rb discovery code (e.g. have_func("rb_str_set_len")) would
* attempt to find by linking against libruby. Rubinius does not
* have an appropriate lib to link against, so we are adding these
* explicit defines for now.
*/
#define HAVE_RB_STR_SET_LEN
#define HAVE_RB_DEFINE_ALLOC_FUNC
|
Fix warnings building with GCC 5 | #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
#define ACQUIRE_IMAGE_PIXELS(im, x, y, w, h, ex) ({ \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
AcquireImagePixels(im, x, y, w, h, ex); \
_Pragma("GCC diagnostic pop") \
})
#else
#define ACQUIRE_IMAGE_PIXELS(im, x, y, w, h, ex) AcquireImagePixels(im, x, y, w, h, ex)
#endif
| #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || (__GNUC__ > 4)
#define ACQUIRE_IMAGE_PIXELS(im, x, y, w, h, ex) ({ \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
AcquireImagePixels(im, x, y, w, h, ex); \
_Pragma("GCC diagnostic pop") \
})
#else
#define ACQUIRE_IMAGE_PIXELS(im, x, y, w, h, ex) AcquireImagePixels(im, x, y, w, h, ex)
#endif
|
Add search terms and authors section to enum | typedef NS_ENUM(NSInteger, StatsSection) {
StatsSectionGraph,
StatsSectionPeriodHeader,
StatsSectionEvents,
StatsSectionPosts,
StatsSectionReferrers,
StatsSectionClicks,
StatsSectionCountry,
StatsSectionVideos,
StatsSectionComments,
StatsSectionTagsCategories,
StatsSectionFollowers,
StatsSectionPublicize,
StatsSectionWebVersion
};
typedef NS_ENUM(NSInteger, StatsSubSection) {
StatsSubSectionCommentsByAuthor = 100,
StatsSubSectionCommentsByPosts,
StatsSubSectionFollowersDotCom,
StatsSubSectionFollowersEmail,
StatsSubSectionNone
};
| typedef NS_ENUM(NSInteger, StatsSection) {
StatsSectionGraph,
StatsSectionPeriodHeader,
StatsSectionEvents,
StatsSectionPosts,
StatsSectionReferrers,
StatsSectionClicks,
StatsSectionCountry,
StatsSectionVideos,
StatsSectionAuthors,
StatsSectionSearchTerms,
StatsSectionComments,
StatsSectionTagsCategories,
StatsSectionFollowers,
StatsSectionPublicize,
StatsSectionWebVersion
};
typedef NS_ENUM(NSInteger, StatsSubSection) {
StatsSubSectionCommentsByAuthor = 100,
StatsSubSectionCommentsByPosts,
StatsSubSectionFollowersDotCom,
StatsSubSectionFollowersEmail,
StatsSubSectionNone
};
|
Add the stub for task graph | /// \file task_graph.h
/// Defines the TaskGraph class
/// \author A0112054Y
#pragma once
#ifndef YOU_QUERYENGINE_INTERNAL_TASK_GRAPH_H_
#define YOU_QUERYENGINE_INTERNAL_TASK_GRAPH_H_
#include <vector>
#include "../api.h"
namespace You {
namespace QueryEngine {
namespace Internal {
/// Defines the task dependency graph
class TaskGraph {
};
} // namespace Internal
} // namespace QueryEngine
} // namespace You
#endif // YOU_QUERYENGINE_INTERNAL_TASK_GRAPH_H_
| |
Add test for LSB-clearing in marquise_hash_identifier | #include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "../marquise.h"
void test_hash_identifier() {
const char *id = "hostname:fe1.example.com,metric:BytesUsed,service:memory,";
size_t id_len = strlen(id);
uint64_t address = marquise_hash_identifier((const unsigned char*) id, id_len);
g_assert_cmpint(address, ==, 7602883380529707052);
}
int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/marquise_hash_identifier/hash", test_hash_identifier);
return g_test_run();
}
| #include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "../marquise.h"
void test_hash_identifier() {
const char *id = "hostname:fe1.example.com,metric:BytesUsed,service:memory,";
size_t id_len = strlen(id);
uint64_t address = marquise_hash_identifier((const unsigned char*) id, id_len);
g_assert_cmpint(address, ==, 7602883380529707052);
}
void test_hash_clear_lsb() {
const char *id = "bytes:tx,collection_point:syd1,ip:110.173.152.33,";
size_t id_len = strlen(id);
uint64_t address = marquise_hash_identifier((const unsigned char*) id, id_len);
g_assert_cmpint(address, ==, -8873247187777138600);
}
int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/marquise_hash_identifier/hash", test_hash_identifier);
g_test_add_func("/marquise_hash_identifier/clear_lsb", test_hash_clear_lsb);
return g_test_run();
}
|
Add 'env' in hopes of making this test pass on Windows. | #include "some_struct.h"
void foo() {
struct X x;
x.
// RUN: CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:4:5 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: FieldDecl:{ResultType int}{TypedText m} (35) (parent: StructDecl 'X')
| #include "some_struct.h"
void foo() {
struct X x;
x.
// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:4:5 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: FieldDecl:{ResultType int}{TypedText m} (35) (parent: StructDecl 'X')
|
Add the prototype for removePoint | /** Author : Paul TREHIOU & Victor SENE
* Date : November 2014
**/
#include <stdlib.h>
#include <stdio.h>
/**
* Declaration Point structure
* x - real wich is the abscisse of the point
* y - real wich is the ordinate of the point
*/
typedef struct
{
double x;
double y;
}Point;
/**
* Declaration of the Element structure
* value - value of the point of the current element of the polygon
* next - pointer on the next element
* previous - pointer on the previous element
*/
typedef struct pointelem{
Point value;
struct pointelem* next;
struct pointelem* previous;
}PointElement;
/**
* Declaration of the Polygon
*/
typedef struct {
PointElement* head;
int size;
}Polygon;
/**
* Function wich create a point with a specified abscisse and ordinate
* abscisse - real
* ordinate - real
* return a new point
*/
Point createPoint(double abscisse, double ordinate);
/**
* Function wich create a new empty Polygon
* return the new empty polygon
*/
Polygon createPolygon();
/**
* Function wich add a point at the end of an existing polygon
* inpoly - Polygon
* inpoint - Point
* return a new polygon
*/
Polygon addPoint(Polygon inpoly, Point inpoint);
| /** Author : Paul TREHIOU & Victor SENE
* Date : November 2014
**/
#include <stdlib.h>
#include <stdio.h>
/**
* Declaration Point structure
* x - real wich is the abscisse of the point
* y - real wich is the ordinate of the point
*/
typedef struct
{
double x;
double y;
}Point;
/**
* Declaration of the Element structure
* value - value of the point of the current element of the polygon
* next - pointer on the next element
* previous - pointer on the previous element
*/
typedef struct pointelem{
Point value;
struct pointelem* next;
struct pointelem* previous;
}PointElement;
/**
* Declaration of the Polygon
*/
typedef struct {
PointElement* head;
int size;
}Polygon;
/**
* Function wich create a point with a specified abscisse and ordinate
* abscisse - real
* ordinate - real
* return a new point
*/
Point createPoint(double abscisse, double ordinate);
/**
* Function wich create a new empty Polygon
* return the new empty polygon
*/
Polygon createPolygon();
/**
* Function wich add a point at the end of an existing polygon
* inpoly - Polygon
* inpoint - Point
* return a new polygon
*/
Polygon addPoint(Polygon inpoly, Point inpoint);
/**
* Function wich remove a point at a given place in an existing polygon
* inpoly - Polygon
* index - int
* return a new polygon
*/
Polygon removePoint(Polygon inpoly, int index);
|
Add sharable methods to header file | // ext/foo/foo_vector.h
// Declarations for wrapped struct
#ifndef FOO_VECTOR_H
#define FOO_VECTOR_H
#include <ruby.h>
#include <math.h>
// Ruby 1.8.7 compatibility patch
#ifndef DBL2NUM
#define DBL2NUM( dbl_val ) rb_float_new( dbl_val )
#endif
void init_foo_vector( VALUE parent_module );
// This is the struct that the rest of the code wraps
typedef struct _fv {
double x;
double y;
double z;
} FVStruct;
#endif | // ext/foo/foo_vector.h
// Declarations for wrapped struct
#ifndef FOO_VECTOR_H
#define FOO_VECTOR_H
#include <ruby.h>
#include <math.h>
// Ruby 1.8.7 compatibility patch
#ifndef DBL2NUM
#define DBL2NUM( dbl_val ) rb_float_new( dbl_val )
#endif
void init_foo_vector( VALUE parent_module );
// This is the struct that the rest of the code wraps
typedef struct _fv {
double x;
double y;
double z;
} FVStruct;
FVStruct *create_fv_struct();
void destroy_fv_struct( FVStruct *fv );
FVStruct *copy_fv_struct( FVStruct *orig );
double fv_magnitude( FVStruct *fv );
#endif |
Clean up C Compiler warning about declaration of variables. | #ifdef USE_INSTANT_OSX
#include "hitimes_interval.h"
#include <mach/mach.h>
#include <mach/mach_time.h>
/* All this OSX code is adapted from http://developer.apple.com/library/mac/#qa/qa1398/_index.html */
/*
* returns the conversion factor, this value is used to convert
* the value from hitimes_get_current_instant() into seconds
*/
long double hitimes_instant_conversion_factor()
{
static mach_timebase_info_data_t s_timebase_info;
static long double conversion_factor;
/**
* If this is the first time we've run, get the timebase.
* We can use denom == 0 to indicate that s_timebase_info is
* uninitialised because it makes no sense to have a zero
* denominator is a fraction.
*/
if ( s_timebase_info.denom == 0 ) {
(void) mach_timebase_info(&s_timebase_info);
uint64_t nano_conversion = s_timebase_info.numer / s_timebase_info.denom;
conversion_factor = (long double) (nano_conversion) * (1e9l);
}
return conversion_factor;
}
/*
* returns the mach absolute time, which has no meaning outside of a conversion
* factor.
*/
hitimes_instant_t hitimes_get_current_instant()
{
return mach_absolute_time();
}
#endif
| #ifdef USE_INSTANT_OSX
#include "hitimes_interval.h"
#include <mach/mach.h>
#include <mach/mach_time.h>
/* All this OSX code is adapted from http://developer.apple.com/library/mac/#qa/qa1398/_index.html */
/*
* returns the conversion factor, this value is used to convert
* the value from hitimes_get_current_instant() into seconds
*/
long double hitimes_instant_conversion_factor()
{
static mach_timebase_info_data_t s_timebase_info;
static long double conversion_factor;
static uint64_t nano_conversion;
/**
* If this is the first time we've run, get the timebase.
* We can use denom == 0 to indicate that s_timebase_info is
* uninitialised because it makes no sense to have a zero
* denominator is a fraction.
*/
if ( s_timebase_info.denom == 0 ) {
mach_timebase_info(&s_timebase_info);
nano_conversion = s_timebase_info.numer / s_timebase_info.denom;
conversion_factor = (long double) (nano_conversion) * (1e9l);
}
return conversion_factor;
}
/*
* returns the mach absolute time, which has no meaning outside of a conversion
* factor.
*/
hitimes_instant_t hitimes_get_current_instant()
{
return mach_absolute_time();
}
#endif
|
Revert 75430 because it's causing failures in dom_checker_tests. : Increase the minimum interval for timers on background tabs to reduce their CPU consumption. | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
#define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
namespace webkit_glue {
// Chromium sets the minimum interval timeout to 4ms, overriding the
// default of 10ms. We'd like to go lower, however there are poorly
// coded websites out there which do create CPU-spinning loops. Using
// 4ms prevents the CPU from spinning too busily and provides a balance
// between CPU spinning and the smallest possible interval timer.
const double kForegroundTabTimerInterval = 0.004;
// Provides control over the minimum timer interval for background tabs.
const double kBackgroundTabTimerInterval = 1.0;
} // namespace webkit_glue
#endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
| // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
#define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
namespace webkit_glue {
// Chromium sets the minimum interval timeout to 4ms, overriding the
// default of 10ms. We'd like to go lower, however there are poorly
// coded websites out there which do create CPU-spinning loops. Using
// 4ms prevents the CPU from spinning too busily and provides a balance
// between CPU spinning and the smallest possible interval timer.
const double kForegroundTabTimerInterval = 0.004;
// Provides control over the minimum timer interval for background tabs.
const double kBackgroundTabTimerInterval = 0.004;
} // namespace webkit_glue
#endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
|
Fix parameter names for svd.impute | /* r-svd-impute.h
*/
#ifndef _R_SVD_IMPUTE_H
#define _R_SVD_IMPUTE_H
SEXP R_svd_impute (SEXP xx, SEXP KK, SEXP tol, SEXP maxiter);
#endif /* _R_SVD_IMPUTE_H */
| /* r-svd-impute.h
*/
#ifndef _R_SVD_IMPUTE_H
#define _R_SVD_IMPUTE_H
SEXP R_svd_impute (SEXP x, SEXP k, SEXP tol, SEXP maxiter);
#endif /* _R_SVD_IMPUTE_H */
|
Disable function exception specification warning only in cl (Visual Studio). | /**
* machina
*
* Copyright (c) 2011, drmats
* All rights reserved.
*
* https://github.com/drmats/machina
*/
#ifndef __PLATFORM_H_
#define __PLATFORM_H_ 1
#if defined(linux) || defined(__linux) || defined(__linux__)
#undef __LINUX__
#define __LINUX__ 1
#endif
#if defined(WIN32) || defined(_WIN32)
#undef __WIN32__
#define __WIN32__ 1
#endif
#ifdef __WIN32__
#pragma warning( disable : 4290 )
#endif
#endif
| /**
* machina
*
* Copyright (c) 2011, drmats
* All rights reserved.
*
* https://github.com/drmats/machina
*/
#ifndef __PLATFORM_H_
#define __PLATFORM_H_ 1
#if defined(linux) || defined(__linux) || defined(__linux__)
#undef __LINUX__
#define __LINUX__ 1
#endif
#if defined(WIN32) || defined(_WIN32)
#undef __WIN32__
#define __WIN32__ 1
#endif
#if defined(__WIN32__) && defined(_MSC_VER)
#pragma warning( disable : 4290 )
#endif
#endif
|
Fix msvc compile error and improve 64 bit compatibility | #include <Python.h>
static PyObject* websocket_mask(PyObject* self, PyObject* args) {
const char* mask;
int mask_len;
const char* data;
int data_len;
int i;
if (!PyArg_ParseTuple(args, "s#s#", &mask, &mask_len, &data, &data_len)) {
return NULL;
}
PyObject* result = PyBytes_FromStringAndSize(NULL, data_len);
if (!result) {
return NULL;
}
char* buf = PyBytes_AsString(result);
for (i = 0; i < data_len; i++) {
buf[i] = data[i] ^ mask[i % 4];
}
return result;
}
static PyMethodDef methods[] = {
{"websocket_mask", websocket_mask, METH_VARARGS, ""},
{NULL, NULL, 0, NULL}
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef speedupsmodule = {
PyModuleDef_HEAD_INIT,
"speedups",
NULL,
-1,
methods
};
PyMODINIT_FUNC
PyInit_speedups() {
return PyModule_Create(&speedupsmodule);
}
#else // Python 2.x
PyMODINIT_FUNC
initspeedups() {
Py_InitModule("tornado.speedups", methods);
}
#endif
| #define PY_SSIZE_T_CLEAN
#include <Python.h>
static PyObject* websocket_mask(PyObject* self, PyObject* args) {
const char* mask;
Py_ssize_t mask_len;
const char* data;
Py_ssize_t data_len;
Py_ssize_t i;
PyObject* result;
char* buf;
if (!PyArg_ParseTuple(args, "s#s#", &mask, &mask_len, &data, &data_len)) {
return NULL;
}
result = PyBytes_FromStringAndSize(NULL, data_len);
if (!result) {
return NULL;
}
buf = PyBytes_AsString(result);
for (i = 0; i < data_len; i++) {
buf[i] = data[i] ^ mask[i % 4];
}
return result;
}
static PyMethodDef methods[] = {
{"websocket_mask", websocket_mask, METH_VARARGS, ""},
{NULL, NULL, 0, NULL}
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef speedupsmodule = {
PyModuleDef_HEAD_INIT,
"speedups",
NULL,
-1,
methods
};
PyMODINIT_FUNC
PyInit_speedups() {
return PyModule_Create(&speedupsmodule);
}
#else // Python 2.x
PyMODINIT_FUNC
initspeedups() {
Py_InitModule("tornado.speedups", methods);
}
#endif
|
Add my name to the copyright notice. | /* Return the copyright string. This is updated manually. */
#include "Python.h"
static char cprt[] =
"Copyright (c) 2000 BeOpen.com.\n\
All Rights Reserved.\n\
\n\
Copyright (c) 1995-2000 Corporation for National Research Initiatives.\n\
All Rights Reserved.\n\
\n\
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n\
All Rights Reserved.";
const char *
Py_GetCopyright(void)
{
return cprt;
}
| /* Return the copyright string. This is updated manually. */
#include "Python.h"
static char cprt[] =
"\
Copyright (c) 2000, 2001 Guido van Rossum.\n\
All Rights Reserved.\n\
\n\
Copyright (c) 2000 BeOpen.com.\n\
All Rights Reserved.\n\
\n\
Copyright (c) 1995-2000 Corporation for National Research Initiatives.\n\
All Rights Reserved.\n\
\n\
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n\
All Rights Reserved.";
const char *
Py_GetCopyright(void)
{
return cprt;
}
|
Fix shared_component build for Ozone platform. | // Copyright (c) 2013 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 OZONE_PLATFORM_OZONE_PLATFORM_WAYLAND_H_
#define OZONE_PLATFORM_OZONE_PLATFORM_WAYLAND_H_
namespace ui {
class OzonePlatform;
// Constructor hook for use in ozone_platform_list.cc
OzonePlatform* CreateOzonePlatformWayland();
} // namespace ui
#endif // OZONE_PLATFORM_OZONE_PLATFORM_WAYLAND_H_
| // Copyright (c) 2013 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 OZONE_PLATFORM_OZONE_PLATFORM_WAYLAND_H_
#define OZONE_PLATFORM_OZONE_PLATFORM_WAYLAND_H_
#include "ozone/platform/ozone_export_wayland.h"
namespace ui {
class OzonePlatform;
// Constructor hook for use in ozone_platform_list.cc
OZONE_WAYLAND_EXPORT OzonePlatform* CreateOzonePlatformWayland();
} // namespace ui
#endif // OZONE_PLATFORM_OZONE_PLATFORM_WAYLAND_H_
|
Add missing newline at end of file. | /*
* Describes all ncp_lib kernel functions
*
* $FreeBSD$
*/
#ifndef _NCP_MOD_H_
#define _NCP_MOD_H_
/* order of calls in syscall table relative to offset in system table */
#define NCP_SE(callno) (callno+sysentoffset)
#define NCP_CONNSCAN NCP_SE(0)
#define NCP_CONNECT NCP_SE(1)
#define NCP_INTFN NCP_SE(2)
#define SNCP_REQUEST NCP_SE(3)
#endif /* !_NCP_MOD_H_ */ | /*
* Describes all ncp_lib kernel functions
*
* $FreeBSD$
*/
#ifndef _NCP_MOD_H_
#define _NCP_MOD_H_
/* order of calls in syscall table relative to offset in system table */
#define NCP_SE(callno) (callno+sysentoffset)
#define NCP_CONNSCAN NCP_SE(0)
#define NCP_CONNECT NCP_SE(1)
#define NCP_INTFN NCP_SE(2)
#define SNCP_REQUEST NCP_SE(3)
#endif /* !_NCP_MOD_H_ */
|
Fix build on OSX 10.9. | // 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 CONTENT_COMMON_GPU_SURFACE_HANDLE_TYPES_MAC_H_
#define CONTENT_COMMON_GPU_SURFACE_HANDLE_TYPES_MAC_H_
#include <OpenGL/CGLIOSurface.h>
#include "base/basictypes.h"
#include "ui/base/cocoa/remote_layer_api.h"
namespace content {
// The surface handle passed between the GPU and browser process may refer to
// an IOSurface or a CAContext. These helper functions must be used to identify
// and translate between the types.
enum SurfaceHandleType {
kSurfaceHandleTypeInvalid,
kSurfaceHandleTypeIOSurface,
kSurfaceHandleTypeCAContext,
};
SurfaceHandleType GetSurfaceHandleType(uint64 surface_handle);
CAContextID CAContextIDFromSurfaceHandle(uint64 surface_handle);
IOSurfaceID IOSurfaceIDFromSurfaceHandle(uint64 surface_handle);
uint64 SurfaceHandleFromIOSurfaceID(IOSurfaceID io_surface_id);
uint64 SurfaceHandleFromCAContextID(CAContextID ca_context_id);
} // namespace content
#endif // CONTENT_COMMON_GPU_HANDLE_TYPES_MAC_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 CONTENT_COMMON_GPU_SURFACE_HANDLE_TYPES_MAC_H_
#define CONTENT_COMMON_GPU_SURFACE_HANDLE_TYPES_MAC_H_
#include <IOSurface/IOSurface.h>
#include <OpenGL/CGLIOSurface.h>
#include "base/basictypes.h"
#include "ui/base/cocoa/remote_layer_api.h"
namespace content {
// The surface handle passed between the GPU and browser process may refer to
// an IOSurface or a CAContext. These helper functions must be used to identify
// and translate between the types.
enum SurfaceHandleType {
kSurfaceHandleTypeInvalid,
kSurfaceHandleTypeIOSurface,
kSurfaceHandleTypeCAContext,
};
SurfaceHandleType GetSurfaceHandleType(uint64 surface_handle);
CAContextID CAContextIDFromSurfaceHandle(uint64 surface_handle);
IOSurfaceID IOSurfaceIDFromSurfaceHandle(uint64 surface_handle);
uint64 SurfaceHandleFromIOSurfaceID(IOSurfaceID io_surface_id);
uint64 SurfaceHandleFromCAContextID(CAContextID ca_context_id);
} // namespace content
#endif // CONTENT_COMMON_GPU_HANDLE_TYPES_MAC_H_
|
Increase version to 1.46 in preparation for new release | #pragma once
// const float in a header file can lead to duplication of the storage
// but I don't really care in this case. Just don't do it with a header
// that is included hundreds of times.
const float kCurrentVersion = 1.45f;
// Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version
// increment that won't trigger the new-version checks, handy for minor
// releases that I don't want to bother users about.
//#define VERSION_SUFFIX 'b'
| #pragma once
// const float in a header file can lead to duplication of the storage
// but I don't really care in this case. Just don't do it with a header
// that is included hundreds of times.
const float kCurrentVersion = 1.46f;
// Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version
// increment that won't trigger the new-version checks, handy for minor
// releases that I don't want to bother users about.
//#define VERSION_SUFFIX 'b'
|
Fix issue with static consts | #ifndef __parse_type_h__
#define __parse_type_h__
typedef enum
{
PARSE_TYPE_NONE,
PARSE_TYPE_LOGICAL,
PARSE_TYPE_CHARACTER,
PARSE_TYPE_INTEGER,
PARSE_TYPE_REAL,
PARSE_TYPE_COMPLEX,
PARSE_TYPE_BYTE,
} parse_type_e;
typedef struct
{
parse_type_e type;
unsigned kind;
unsigned count;
} parse_type_t;
static const parse_type_t PARSE_TYPE_INTEGER_DEFAULT =
{
.type = PARSE_TYPE_INTEGER,
.kind = 0,
.count = 0,
};
static const parse_type_t PARSE_TYPE_REAL_DEFAULT =
{
.type = PARSE_TYPE_REAL,
.kind = 0,
.count = 0,
};
unsigned parse_type(
const sparse_t* src, const char* ptr,
parse_type_t* type);
#endif
| #ifndef __parse_type_h__
#define __parse_type_h__
typedef enum
{
PARSE_TYPE_NONE,
PARSE_TYPE_LOGICAL,
PARSE_TYPE_CHARACTER,
PARSE_TYPE_INTEGER,
PARSE_TYPE_REAL,
PARSE_TYPE_COMPLEX,
PARSE_TYPE_BYTE,
} parse_type_e;
typedef struct
{
parse_type_e type;
unsigned kind;
unsigned count;
} parse_type_t;
#define PARSE_TYPE_INTEGER_DEFAULT (parse_type_t)\
{\
.type = PARSE_TYPE_INTEGER,\
.kind = 0,\
.count = 0,\
}
#define PARSE_TYPE_REAL_DEFAULT (parse_type_t)\
{\
.type = PARSE_TYPE_REAL,\
.kind = 0,\
.count = 0,\
}
unsigned parse_type(
const sparse_t* src, const char* ptr,
parse_type_t* type);
#endif
|
Use A0 instead 10 as button down input PIN | #pragma once
#include <core.h>
#define DHT22_PIN 6
#define DHT22_SAMPLE_RATE 3000
#define TEMPORATURE_TARGET (204)
#define HEATER_PIN 10
#define HEATER_ACTION_DELAY (15*60) // minimal seconds to open/close heater, prevent switch heater too frequently.
// pin connect to 315/433 transmitter
#define TRANSMIT_PIN 8
// Log temperature and humidity every 5mins
#define TEMPE_HUMI_LOG_INTERVAL ((uint32_t)5 * 60 * 1000)
#define DISPLAY_PIN1 5
#define DISPLAY_PIN2 4
#define DISPLAY_PIN3 3
#define DISPLAY_PIN4 2
#define DISPLAY_PIN5 11
#define DISPLAY_PIN6 12
extern core::idType idTempe, idHumi;
// Set digital value idHeaterReq to turn on/off, heater module
// has a throttle inside to prevent turn on/off too frequently,
// idHeaterAct digtial value is the heater actual state.
extern core::idType idHeaterReq, idHeaterAct;
#define KEY_MODE_PIN 7
#define KEY_UP_PIN 9
#define KEY_DOWN_PIN 10
#define KEY_SETUP_PIN 13
extern core::idType idKeyMode, idKeyUp, idKeyDown, idKeySetup;
| #pragma once
#include <core.h>
#define DHT22_PIN 6
#define DHT22_SAMPLE_RATE 3000
#define TEMPORATURE_TARGET (204)
#define HEATER_PIN 10
#define HEATER_ACTION_DELAY (15*60) // minimal seconds to open/close heater, prevent switch heater too frequently.
// pin connect to 315/433 transmitter
#define TRANSMIT_PIN 8
// Log temperature and humidity every 5mins
#define TEMPE_HUMI_LOG_INTERVAL ((uint32_t)5 * 60 * 1000)
#define DISPLAY_PIN1 5
#define DISPLAY_PIN2 4
#define DISPLAY_PIN3 3
#define DISPLAY_PIN4 2
#define DISPLAY_PIN5 11
#define DISPLAY_PIN6 12
extern core::idType idTempe, idHumi;
// Set digital value idHeaterReq to turn on/off, heater module
// has a throttle inside to prevent turn on/off too frequently,
// idHeaterAct digtial value is the heater actual state.
extern core::idType idHeaterReq, idHeaterAct;
#define KEY_MODE_PIN 7
#define KEY_UP_PIN 9
#define KEY_DOWN_PIN A0
#define KEY_SETUP_PIN 13
extern core::idType idKeyMode, idKeyUp, idKeyDown, idKeySetup;
|
Add test case for invariant generation for unions. | // PARAM: --set trans.activated[+] "assert"
// Running the assert transformation on this test yields in code that is not compilable by gcc
struct s {
int a;
int b;
};
union u {
struct s str;
int i;
};
int main(){
union u un;
struct s* ptr;
un.str.a = 1;
un.str.b = 2;
ptr = &un.str;
int r;
int x;
if(r){
x = 2;
} else {
x = 3;
}
return 0;
}
| |
Add BOOL typedef becuase BOOLEAN is too verbose. | #ifndef CONSTANTS_H
#define CONSTANTS_H
#if !defined(__STDC__) && !defined(__cplusplus)
#define const
#endif
/*
Set up a boolean variable type. Since this definition could conflict
with other reasonable definition of BOOLEAN, i.e. using an enumeration,
it is conditional.
*/
#ifndef BOOLEAN_TYPE_DEFINED
typedef int BOOLEAN;
#endif
#if defined(TRUE)
# undef TRUE
# undef FALSE
#endif
static const int TRUE = 1;
static const int FALSE = 0;
/*
Useful constants for turning seconds into larger units of time. Since
these constants may have already been defined elsewhere, they are
conditional.
*/
#ifndef TIME_CONSTANTS_DEFINED
static const int MINUTE = 60;
static const int HOUR = 60 * 60;
static const int DAY = 24 * 60 * 60;
#endif
/*
This is for use with strcmp() and related functions which will return
0 upon a match.
*/
#ifndef MATCH
static const int MATCH = 0;
#endif
#endif
| #ifndef CONSTANTS_H
#define CONSTANTS_H
#if !defined(__STDC__) && !defined(__cplusplus)
#define const
#endif
/*
Set up a boolean variable type. Since this definition could conflict
with other reasonable definition of BOOLEAN, i.e. using an enumeration,
it is conditional.
*/
#ifndef BOOLEAN_TYPE_DEFINED
typedef int BOOLEAN;
typedef int BOOL;
#endif
#if defined(TRUE)
# undef TRUE
# undef FALSE
#endif
static const int TRUE = 1;
static const int FALSE = 0;
/*
Useful constants for turning seconds into larger units of time. Since
these constants may have already been defined elsewhere, they are
conditional.
*/
#ifndef TIME_CONSTANTS_DEFINED
static const int MINUTE = 60;
static const int HOUR = 60 * 60;
static const int DAY = 24 * 60 * 60;
#endif
/*
This is for use with strcmp() and related functions which will return
0 upon a match.
*/
#ifndef MATCH
static const int MATCH = 0;
#endif
#endif
|
Fix wrong namespace in recently-added shim header. | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_CORE_SHIMS_CC_KERNELS_REGISTER_H_
#define TENSORFLOW_LITE_CORE_SHIMS_CC_KERNELS_REGISTER_H_
#include "tensorflow/lite/kernels/register.h"
#endif // TENSORFLOW_LITE_CORE_SHIMS_CC_KERNELS_REGISTER_H_
| /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_CORE_SHIMS_CC_KERNELS_REGISTER_H_
#define TENSORFLOW_LITE_CORE_SHIMS_CC_KERNELS_REGISTER_H_
#include "tensorflow/lite/kernels/register.h"
namespace tflite_shims {
namespace ops {
namespace builtin {
using BuiltinOpResolver = ::tflite::ops::builtin::BuiltinOpResolver;
} // namespace builtin
} // namespace ops
} // namespace tflite_shims
#endif // TENSORFLOW_LITE_CORE_SHIMS_CC_KERNELS_REGISTER_H_
|
Add cpp comment stripping bug | #ifdef GNU_VARIADIC
# define FOO(args...) do { foo(args); } while (0)
#else
# define FOO(...) do { foo(__VA_ARGS__); } while (0)
#endif
#define BAR(x) FOO("x"); FOO(")");
void
foo(char *a)
{
BAR();
}
| |
Test case for returning structs by value (missing from previous checkin) | struct S {
int a;
};
struct S foo () {
struct S s;
int i;
s.a = i;
return s;
}
int main()
{
int u;
u = foo().a;
}
| |
Add Hamming weigth in C | #include <stdint.h>
int32_t NumberOfSetBits(int32_t i)
{
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
} | |
Clarify class comment for ExtensionMessageHandler. | // 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#pragma once
#include "content/browser/renderer_host/render_view_host_observer.h"
class Profile;
struct ExtensionHostMsg_DomMessage_Params;
// Filters and dispatches extension-related IPC messages that arrive from
// renderer/extension processes. This object is created for renderers and also
// ExtensionHost/BackgroundContents. Contrast this with ExtensionTabHelper,
// which is only created for TabContents.
class ExtensionMessageHandler : public RenderViewHostObserver {
public:
// |sender| is guaranteed to outlive this object.
explicit ExtensionMessageHandler(RenderViewHost* render_view_host);
virtual ~ExtensionMessageHandler();
// RenderViewHostObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message);
private:
// Message handlers.
void OnPostMessage(int port_id, const std::string& message);
void OnRequest(const ExtensionHostMsg_DomMessage_Params& params);
DISALLOW_COPY_AND_ASSIGN(ExtensionMessageHandler);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_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 CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
#pragma once
#include "content/browser/renderer_host/render_view_host_observer.h"
class Profile;
struct ExtensionHostMsg_DomMessage_Params;
// Filters and dispatches extension-related IPC messages that arrive from
// renderers. There is one of these objects for each RenderViewHost in Chrome.
// Contrast this with ExtensionTabHelper, which is only created for TabContents.
class ExtensionMessageHandler : public RenderViewHostObserver {
public:
// |sender| is guaranteed to outlive this object.
explicit ExtensionMessageHandler(RenderViewHost* render_view_host);
virtual ~ExtensionMessageHandler();
// RenderViewHostObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message);
private:
// Message handlers.
void OnPostMessage(int port_id, const std::string& message);
void OnRequest(const ExtensionHostMsg_DomMessage_Params& params);
DISALLOW_COPY_AND_ASSIGN(ExtensionMessageHandler);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.