Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Use different header to be yet more compatible with Windows | #pragma once
#include <string>
#include <vector>
#include <sqltypes.h>
namespace cpp_odbc { namespace level2 {
/**
* @brief This class represents a buffer for u16strings for use with the unixodbc C API.
*/
class u16string_buffer {
public:
/**
* @brief Constructs a new string buffer with the given capacity, i.e., maximum size
* @param capacity Capacity of the buffer
*/
u16string_buffer(signed short int capacity);
/**
* @brief Retrieve the capacity of the buffer (in characters) in a format suitable for passing
* to unixodbc API functions.
*/
signed short int capacity() const;
/**
* @brief Retrieve a pointer to the internal buffer suitable for passing to unixodbc API functions.
* This buffer contains the actual string data. Do not exceed the allocated capacity!
*/
SQLWCHAR * data_pointer();
/**
* @brief Retrieve a pointer to a size buffer suitable for passing to unixodbc API functions.
* This buffer contains the number of significant bytes in the buffer returned by
* data_pointer().
*/
signed short int * size_pointer();
/**
* @brief Conversion operator. Retrieve the buffered data as a string. Bad things will happen if
* the value of size_pointer is larger than the capacity!
*/
operator std::u16string() const;
private:
std::vector<SQLWCHAR> data_;
signed short int used_size_;
};
} }
| #pragma once
#include <string>
#include <vector>
#include <sql.h>
namespace cpp_odbc { namespace level2 {
/**
* @brief This class represents a buffer for u16strings for use with the unixodbc C API.
*/
class u16string_buffer {
public:
/**
* @brief Constructs a new string buffer with the given capacity, i.e., maximum size
* @param capacity Capacity of the buffer
*/
u16string_buffer(signed short int capacity);
/**
* @brief Retrieve the capacity of the buffer (in characters) in a format suitable for passing
* to unixodbc API functions.
*/
signed short int capacity() const;
/**
* @brief Retrieve a pointer to the internal buffer suitable for passing to unixodbc API functions.
* This buffer contains the actual string data. Do not exceed the allocated capacity!
*/
SQLWCHAR * data_pointer();
/**
* @brief Retrieve a pointer to a size buffer suitable for passing to unixodbc API functions.
* This buffer contains the number of significant bytes in the buffer returned by
* data_pointer().
*/
signed short int * size_pointer();
/**
* @brief Conversion operator. Retrieve the buffered data as a string. Bad things will happen if
* the value of size_pointer is larger than the capacity!
*/
operator std::u16string() const;
private:
std::vector<SQLWCHAR> data_;
signed short int used_size_;
};
} }
|
Add ArchBreak to the header. | #ifndef SHUTDOWN_I6F54URD
#define SHUTDOWN_I6F54URD
void ArchShutdown(void);
#endif /* end of include guard: SHUTDOWN_I6F54URD */
| #ifndef SHUTDOWN_I6F54URD
#define SHUTDOWN_I6F54URD
void ArchBreak(void);
void ArchShutdown(void);
#endif /* end of include guard: SHUTDOWN_I6F54URD */
|
Fix gy-30 light sensor i2c address | /**
* @file
* @brief
*
* @date 29.03.2017
* @author Alex Kalmuk
*/
#include <unistd.h>
#include <util/log.h>
#include <drivers/i2c/i2c.h>
#include "gy_30.h"
#define GY30_ADDR 0x46
uint16_t gy_30_read_light_level(unsigned char id) {
uint16_t level = 0;
/* It would be better do not hang here but return error code */
while (0 > i2c_bus_read(id, GY30_ADDR, (uint8_t *) &level, 2))
;
/* The actual value in lx is level / 1.2 */
return (((uint32_t) level) * 5) / 6;
}
void gy_30_setup_mode(unsigned char id, uint8_t mode) {
while (0 > i2c_bus_write(id, GY30_ADDR, &mode, 1))
;
/* Documentation says that we need to wait approximately 180 ms here.*/
usleep(180000);
log_debug("%s\n", "gy_30_setup_mode OK!\n");
}
| /**
* @file
* @brief
*
* @date 29.03.2017
* @author Alex Kalmuk
*/
#include <unistd.h>
#include <util/log.h>
#include <drivers/i2c/i2c.h>
#include "gy_30.h"
/* http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf */
#define GY30_ADDR 0x23
uint16_t gy_30_read_light_level(unsigned char id) {
uint16_t level = 0;
/* It would be better do not hang here but return error code */
while (0 > i2c_bus_read(id, GY30_ADDR, (uint8_t *) &level, 2))
;
/* The actual value in lx is level / 1.2 */
return (((uint32_t) level) * 5) / 6;
}
void gy_30_setup_mode(unsigned char id, uint8_t mode) {
while (0 > i2c_bus_write(id, GY30_ADDR, &mode, 1))
;
/* Documentation says that we need to wait approximately 180 ms here.*/
usleep(180000);
log_debug("%s\n", "gy_30_setup_mode OK!\n");
}
|
Add new API files to umbrella header | /// Umbrella header for the Hub Framework
#import "HUBManager.h"
#import "HUBComponent.h"
#import "HUBComponentModel.h"
#import "HUBComponentRegistry.h"
#import "HUBComponentFallbackHandler.h"
| /// Umbrella header for the Hub Framework
#import "HUBManager.h"
#import "HUBComponent.h"
#import "HUBComponentModel.h"
#import "HUBComponentModelBuilder.h"
#import "HUBComponentImageData.h"
#import "HUBComponentImageDataBuilder.h"
#import "HUBComponentRegistry.h"
#import "HUBComponentFallbackHandler.h"
|
Mend Win32 build broken by 8e1c4386 | #ifndef PLUGIN_H_
#define PLUGIN_H_
#include "plugin_portable.h"
#include <windows.h>
// TODO use __stdcall
#define EXPORT_CALLING __cdecl
#define EXPORT __declspec(dllexport) EXPORT_CALLING
#include "common.h"
// just defined to make compilation work ; ignored
#define RTLD_DEFAULT NULL
#define RTLD_LOCAL -1
#define RTLD_LAZY -1
static inline void *dlopen(const char *name, int flags)
{
// TODO use LoadLibraryEx() and flags ?
return LoadLibrary(name);
}
static inline void *dlsym(void *handle, const char *name)
{
FARPROC g = GetProcAddress(handle, name);
void *h;
*(FARPROC*)&h = g;
return h;
}
static inline char *dlerror(void)
{
static __thread char buf[1024];
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&buf,
sizeof buf, NULL);
return buf;
}
static inline int dlclose(void *handle)
{
return !FreeLibrary(handle);
}
#endif
| #ifndef PLUGIN_H_
#define PLUGIN_H_
#include "plugin_portable.h"
#include <windows.h>
// TODO use __stdcall
#define EXPORT_CALLING __cdecl
#define EXPORT __declspec(dllexport) EXPORT_CALLING
#include "common.h"
// just defined to make compilation work ; ignored
#define RTLD_DEFAULT NULL
#define RTLD_LOCAL -1
#define RTLD_LAZY -1
#define RTLD_NOW -1
static inline void *dlopen(const char *name, int flags)
{
(void)flags;
// TODO use LoadLibraryEx() and flags ?
return LoadLibrary(name);
}
static inline void *dlsym(void *handle, const char *name)
{
FARPROC g = GetProcAddress(handle, name);
void *h;
*(FARPROC*)&h = g;
return h;
}
static inline char *dlerror(void)
{
static __thread char buf[1024];
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&buf,
sizeof buf, NULL);
return buf;
}
static inline int dlclose(void *handle)
{
return !FreeLibrary(handle);
}
#endif
|
Revert "tests: check if gpg-agent command exists in shutdown code" | /**
* @file
*
* @brief module for shutting down the gpg-agent
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#include "gpg_shutdown.h"
#include <stdio.h>
#include <stdlib.h>
/**
* @brief shutdown the gpg-agent
* @retval 0 on success.
* @retval -1 on error.
*/
int ELEKTRA_PLUGIN_FUNCTION (gpgQuitAgent) (void)
{
// check if the gpg-connect-agent command is available
int cmdAvailable = system ("command -v gpg-connect-agent");
if (cmdAvailable != 0)
{
// nothing to do here
return 0;
}
// try to gracefully shut down the gpg-agent
int status = system ("gpg-connect-agent --quiet KILLAGENT /bye");
if (status != 0)
{
// use the hammer
int killStatus = system ("/bin/sh -c \"pgrep \'gpg-agent\' | xargs -d \'\\n\' \'kill\'\"");
if (killStatus != 0)
{
return -1;
}
}
return 0;
}
| /**
* @file
*
* @brief module for shutting down the gpg-agent
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#include "gpg_shutdown.h"
#include <stdio.h>
#include <stdlib.h>
/**
* @brief shutdown the gpg-agent
* @retval 0 on success.
* @retval -1 on error.
*/
int ELEKTRA_PLUGIN_FUNCTION (gpgQuitAgent) (void)
{
// try to gracefully shut down the gpg-agent
int status = system ("gpg-connect-agent --quiet KILLAGENT /bye");
if (status != 0)
{
// use the hammer
int killStatus = system ("/bin/sh -c \"pgrep \'gpg-agent\' | xargs -d \'\\n\' \'kill\'\"");
if (killStatus != 0)
{
return -1;
}
}
return 0;
}
|
Add gtk and x11 headers to linux specific platform header | /**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_BASE_PLATFORM_X11_H_
#define XENIA_BASE_PLATFORM_X11_H_
// NOTE: if you're including this file it means you are explicitly depending
// on Linux headers. Including this file outside of linux platform specific
// source code will break portability
#include "xenia/base/platform.h"
// Xlib is used only for GLX interaction, the window management and input
// events are done with gtk/gdk
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
//Used for window management. Gtk is for GUI and wigets, gdk is for lower
//level events like key presses, mouse events, etc
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#endif // XENIA_BASE_PLATFORM_X11_H_
| |
Add function prototypes and ifndef wrapper | // Configurable constants
int const MAIN_MOTOR_PWM_TOP = 255;
int const MAIN_MOTOR_BRAKE_SPEED = 120;
int const MAIN_MOTOR_MIN_SPEED = 150;
int const MAIN_MOTOR_MED_SPEED = 254;
int const MAIN_MOTOR_MAX_SPEED = 255;
int const MAGNET_OPEN_WAIT = 5; // 10ths of a second
void init(void);
| #ifndef HAL1_H
#define HAL1_H
// Configurable constants
int const MAIN_MOTOR_PWM_TOP = 255;
int const MAIN_MOTOR_BRAKE_SPEED = 120;
int const MAIN_MOTOR_MIN_SPEED = 150;
int const MAIN_MOTOR_MED_SPEED = 254;
int const MAIN_MOTOR_MAX_SPEED = 255;
int const MAGNET_OPEN_WAIT = 5; // 10ths of a second
void init(void);
void main_motor_stop();
void main_motor_cw_open(uint8_t speed);
void main_motor_ccw_close(uint8_t speed);
void set_main_motor_speed(int speed);
int get_main_motor_speed();
void aux_motor_stop();
void aux_motor_cw_close();
void aux_motor_ccw_open();
void magnet_off();
void magnet_on();
bool door_nearly_open();
bool door_fully_open();
bool door_fully_closed();
bool sensor_proximity();
bool button_openclose();
bool button_stop();
bool main_encoder();
bool aux_outdoor_limit();
bool aux_indoor_limit();
bool door_nearly_closed();
bool aux_encoder();
#endif
|
Remove dealloc from header as it is declared in NSObject | #import <Foundation/Foundation.h>
#ifdef __cplusplus
#include <memory>
#include <mx3/mx3.hpp>
#endif
@interface MX3Snapshot : NSObject
// adding this here allows you to include this file from non-objc++ files
// since it is using c++ types
#ifdef __cplusplus
- (instancetype)initWithSnapshot:(std::unique_ptr<mx3::SqlSnapshot>)snapshot;
#endif
- (NSString *) rowAtIndex:(NSUInteger)index;
- (NSUInteger) count;
- (void) dealloc;
@end
| #import <Foundation/Foundation.h>
#ifdef __cplusplus
#include <memory>
#include <mx3/mx3.hpp>
#endif
@interface MX3Snapshot : NSObject
// adding this here allows you to include this file from non-objc++ files
// since it is using c++ types
#ifdef __cplusplus
- (instancetype)initWithSnapshot:(std::unique_ptr<mx3::SqlSnapshot>)snapshot;
#endif
- (NSString *) rowAtIndex:(NSUInteger)index;
- (NSUInteger) count;
@end
|
Fix a build error (Python 3.5) | #pragma once
#if defined(_MSC_VER)
#define round(x) (x >= 0 ? (x + 0.5) : (x - 0.5))
#endif
class WindowFeature {
public:
WindowFeature();
virtual ~WindowFeature();
virtual void apply(double *windowImage, double *descriptorVector) = 0;
unsigned int descriptorLengthPerWindow;
};
| #pragma once
#if _MSC_VER < 1900
#define round(x) (x >= 0 ? (x + 0.5) : (x - 0.5))
#endif
class WindowFeature {
public:
WindowFeature();
virtual ~WindowFeature();
virtual void apply(double *windowImage, double *descriptorVector) = 0;
unsigned int descriptorLengthPerWindow;
};
|
Declare void parameter for RIOT | #include "port/oc_assert.h"
// TODO:
void
abort_impl()
{
}
| #include "port/oc_assert.h"
// TODO:
void
abort_impl(void)
{
}
|
Add stub for auditing in the tester | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2013 Raymond Jennings
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
| |
Implement long double -> double | #include "../../math/reinterpret.h"
#include <stdint.h>
static uint64_t magnitude_(uint64_t high, uint64_t low)
{
if (high > 0x7FFF000000000000 || (high == 0x7FFF000000000000 && low))
return high;
if (high >= 0x43FF000000000000)
return 0x7FF0000000000000;
if (high >= 0x3C01000000000000)
return ((high - 0x3C00000000000000) << 4 | low >> 60) + (((low >> 59 & 1) | low << 4) > 0x8000000000000000);
if (high >= 0x3BCC000000000000) {
double significand = reinterpret(double, (0x8000000000000000 | high << 15) >> 11 | low >> 60 | !!(low << 4));
double coeff = reinterpret(double, ((high >> 48) - 0x3802) << 52);
return reinterpret(uint64_t, significand * coeff);
}
return 0;
}
double __trunctfdf2(long double x)
{
unsigned __int128 i = reinterpret(unsigned __int128, x);
uint64_t high = i >> 64;
return reinterpret(double, magnitude_(high & INT64_MAX, i) | (high & 0x8000000000000000));
}
| |
Make operator-> constexpr and return a T const*. | #ifndef VAST_OPTION_HPP
#define VAST_OPTION_HPP
#include <cppa/option.hpp>
namespace vast {
/// An optional value of `T` with similar semantics as `std::optional`.
template <typename T>
class option : public cppa::option<T>
{
typedef cppa::option<T> super;
public:
#ifdef VAST_HAVE_INHERTING_CONSTRUCTORS
using super::option;
#else
option() = default;
option(T x)
: super(std::move(x))
{
}
template <typename T0, typename T1, typename... Ts>
option(T0&& x0, T1&& x1, Ts&&... args)
: super(std::forward<T0>(x0),
std::forward<T1>(x1),
std::forward<Ts>(args)...)
{
}
option(const option&) = default;
option(option&&) = default;
option& operator=(option const&) = default;
option& operator=(option&&) = default;
#endif
T* operator->() const
{
CPPA_REQUIRE(valid());
return &cppa::option<T>::get();
}
};
} // namespace vast
#endif
| #ifndef VAST_OPTION_HPP
#define VAST_OPTION_HPP
#include <cppa/option.hpp>
namespace vast {
/// An optional value of `T` with similar semantics as `std::optional`.
template <typename T>
class option : public cppa::option<T>
{
typedef cppa::option<T> super;
public:
#ifdef VAST_HAVE_INHERTING_CONSTRUCTORS
using super::option;
#else
option() = default;
option(T x)
: super(std::move(x))
{
}
template <typename T0, typename T1, typename... Ts>
option(T0&& x0, T1&& x1, Ts&&... args)
: super(std::forward<T0>(x0),
std::forward<T1>(x1),
std::forward<Ts>(args)...)
{
}
option(const option&) = default;
option(option&&) = default;
option& operator=(option const&) = default;
option& operator=(option&&) = default;
#endif
constexpr T const* operator->() const
{
return &cppa::option<T>::get();
}
};
} // namespace vast
#endif
|
Check version string only if MMDB_lib_version != NULL | #include "MMDB.h"
#include "tap.h"
#include <sys/stat.h>
#include <string.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
int main(void)
{
const char *version = MMDB_lib_version();
ok(version != NULL, "MMDB_lib_version exists");
ok(strcmp(version, PACKAGE_VERSION) == 0, "version is " PACKAGE_VERSION);
done_testing();
}
| #include "MMDB.h"
#include "tap.h"
#include <sys/stat.h>
#include <string.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
int main(void)
{
const char *version = MMDB_lib_version();
ok(version != NULL, "MMDB_lib_version exists");
if ( version )
ok(strcmp(version, PACKAGE_VERSION) == 0, "version is " PACKAGE_VERSION);
done_testing();
}
|
Remove "Module Name:" from include file headers. | /** @file
GUID for hardware error record variables.
Copyright (c) 2007 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: HardwareErrorVariable.h
@par Revision Reference:
GUID defined in UEFI 2.1.
**/
#ifndef _HARDWARE_ERROR_VARIABLE_GUID_H_
#define _HARDWARE_ERROR_VARIABLE_GUID_H_
#define EFI_HARDWARE_ERROR_VARIABLE \
{ \
0x414E6BDD, 0xE47B, 0x47cc, {0xB2, 0x44, 0xBB, 0x61, 0x02, 0x0C, 0xF5, 0x16} \
}
extern EFI_GUID gEfiHardwareErrorVariableGuid;
#endif
| /** @file
GUID for hardware error record variables.
Copyright (c) 2007 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
GUID defined in UEFI 2.1.
**/
#ifndef _HARDWARE_ERROR_VARIABLE_GUID_H_
#define _HARDWARE_ERROR_VARIABLE_GUID_H_
#define EFI_HARDWARE_ERROR_VARIABLE \
{ \
0x414E6BDD, 0xE47B, 0x47cc, {0xB2, 0x44, 0xBB, 0x61, 0x02, 0x0C, 0xF5, 0x16} \
}
extern EFI_GUID gEfiHardwareErrorVariableGuid;
#endif
|
Add stub routines for !CONFIG_DCB | /*
* Copyright (c) 2010, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* Author: John Fastabend <john.r.fastabend@intel.com>
*/
#ifndef _DCB_EVENT_H
#define _DCB_EVENT_H
enum dcbevent_notif_type {
DCB_APP_EVENT = 1,
};
extern int register_dcbevent_notifier(struct notifier_block *nb);
extern int unregister_dcbevent_notifier(struct notifier_block *nb);
extern int call_dcbevent_notifiers(unsigned long val, void *v);
#endif
| /*
* Copyright (c) 2010, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* Author: John Fastabend <john.r.fastabend@intel.com>
*/
#ifndef _DCB_EVENT_H
#define _DCB_EVENT_H
enum dcbevent_notif_type {
DCB_APP_EVENT = 1,
};
#ifdef CONFIG_DCB
extern int register_dcbevent_notifier(struct notifier_block *nb);
extern int unregister_dcbevent_notifier(struct notifier_block *nb);
extern int call_dcbevent_notifiers(unsigned long val, void *v);
#else
static inline int
register_dcbevent_notifier(struct notifier_block *nb)
{
return 0;
}
static inline int unregister_dcbevent_notifier(struct notifier_block *nb)
{
return 0;
}
static inline int call_dcbevent_notifiers(unsigned long val, void *v)
{
return 0;
}
#endif /* CONFIG_DCB */
#endif
|
Disable __WINCRYPT_H__ headers for Windows | #ifndef OSSL_CORE_COMMON_H_INCLUDE
#define OSSL_CORE_COMMON_H_INCLUDE
#include <nan.h>
#include "logger.h"
#include "scoped_ssl.h"
#include "excep.h"
#include "key_exp.h"
#include "digest.h"
#include "bn.h"
#include <openssl/bn.h>
#endif // OSSL_CORE_COMMON_H_INCLUDE
| #ifndef OSSL_CORE_COMMON_H_INCLUDE
#define OSSL_CORE_COMMON_H_INCLUDE
#ifdef _WIN32
#define __WINCRYPT_H__
#endif
#include <nan.h>
#include "logger.h"
#include "scoped_ssl.h"
#include "excep.h"
#include "key_exp.h"
#include "digest.h"
#include "bn.h"
#include <openssl/bn.h>
#endif // OSSL_CORE_COMMON_H_INCLUDE
|
Fix a header that had failed to track dome changed locations. | /***************************************************************************
getarg.h - Support routines for the giflib utilities
**************************************************************************/
#ifndef _GETARG_H
#define _GETARG_H
#include <stdbool.h>
#define VERSION_COOKIE " Version %d.%d, "
/***************************************************************************
* Error numbers as returned by GAGetArg routine:
**************************************************************************/
#define CMD_ERR_NotAnOpt 1 /* None Option found. */
#define CMD_ERR_NoSuchOpt 2 /* Undefined Option Found. */
#define CMD_ERR_WildEmpty 3 /* Empty input for !*? seq. */
#define CMD_ERR_NumRead 4 /* Failed on reading number. */
#define CMD_ERR_AllSatis 5 /* Fail to satisfy (must-'!') option. */
bool GAGetArgs(int argc, char **argv, char *CtrlStr, ...);
void GAPrintErrMsg(int Error);
void GAPrintHowTo(char *CtrlStr);
/******************************************************************************
* O.K., here are the routines from QPRINTF.C.
******************************************************************************/
extern bool GifNoisyPrint;
extern void GifQprintf(char *Format, ...);
/******************************************************************************
* O.K., here are the routines from GIF_ERR.C.
******************************************************************************/
extern void PrintGifError(void);
extern int GifLastError(void);
/* These used to live in the library header */
#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
#define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); }
#endif /* _GETARG_H */
/* end */
| /***************************************************************************
getarg.h - Support routines for the giflib utilities
**************************************************************************/
#ifndef _GETARG_H
#define _GETARG_H
#include <stdbool.h>
#define VERSION_COOKIE " Version %d.%d, "
/***************************************************************************
Error numbers as returned by GAGetArg routine:
***************************************************************************/
#define CMD_ERR_NotAnOpt 1 /* None Option found. */
#define CMD_ERR_NoSuchOpt 2 /* Undefined Option Found. */
#define CMD_ERR_WildEmpty 3 /* Empty input for !*? seq. */
#define CMD_ERR_NumRead 4 /* Failed on reading number. */
#define CMD_ERR_AllSatis 5 /* Fail to satisfy (must-'!') option. */
bool GAGetArgs(int argc, char **argv, char *CtrlStr, ...);
void GAPrintErrMsg(int Error);
void GAPrintHowTo(char *CtrlStr);
/******************************************************************************
From qprintf.c
******************************************************************************/
extern bool GifNoisyPrint;
extern void GifQprintf(char *Format, ...);
extern void PrintGifError(void);
/* These used to live in the library header */
#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
#define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); }
#endif /* _GETARG_H */
/* end */
|
Move inclusion of internal headers before system headers | /*
* libaacs by Doom9 ppl 2009, 2010
*/
#ifndef AACS_H_
#define AACS_H_
#include <stdint.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 "../file/configfile.h"
#include <stdint.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_ */
|
Generalize this test to work without instruction names. | // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o %t %s
// RUN: FileCheck < %t %s
// Types with the may_alias attribute should be considered equivalent
// to char for aliasing.
typedef int __attribute__((may_alias)) aliasing_int;
void test0(aliasing_int *ai, int *i)
{
*ai = 0;
*i = 1;
}
// CHECK: store i32 0, i32* %tmp, !tbaa !1
// CHECK: store i32 1, i32* %tmp1, !tbaa !3
// CHECK: !0 = metadata !{metadata !"any pointer", metadata !1}
// CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2}
// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA", null}
// CHECK: !3 = metadata !{metadata !"int", metadata !1}
| // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o %t %s
// RUN: FileCheck < %t %s
// Types with the may_alias attribute should be considered equivalent
// to char for aliasing.
typedef int __attribute__((may_alias)) aliasing_int;
void test0(aliasing_int *ai, int *i)
{
*ai = 0;
*i = 1;
}
// CHECK: store i32 0, i32* %{{.*}}, !tbaa !1
// CHECK: store i32 1, i32* %{{.*}}, !tbaa !3
// CHECK: !0 = metadata !{metadata !"any pointer", metadata !1}
// CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2}
// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA", null}
// CHECK: !3 = metadata !{metadata !"int", metadata !1}
|
Add thread group to manage threads | //
// synchronizer.h
// P2PSP
//
// This code is distributed under the GNU General Public License (see
// THE_GENERAL_GNU_PUBLIC_LICENSE.txt for extending this information).
// Copyright (C) 2016, the P2PSP team.
// http://www.p2psp.org
//
#include <boost/format.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include "../lib/p2psp/src/util/trace.h"
#include <arpa/inet.h>
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp>
#include <ctime>
#include <fstream>
#include <string>
#include <tuple>
#include <vector>
namespace p2psp {
class Synchronizer {
public:
Synchronizer();
~Synchronizer();
const std::vector<std::string>* peer_list;
void Run(int argc, const char* argv[]) throw(boost::system::system_error); //Run the argument parser
void PlayChunk(); //Play the chunk to the player
void Synchronize(); //To get the offset from the first peer and synchronize the lists
void ConnectToPeers(); //Connect the synchronizer with various peers
};
}
| //
// synchronizer.h
// P2PSP
//
// This code is distributed under the GNU General Public License (see
// THE_GENERAL_GNU_PUBLIC_LICENSE.txt for extending this information).
// Copyright (C) 2016, the P2PSP team.
// http://www.p2psp.org
//
#include <boost/format.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include "../lib/p2psp/src/util/trace.h"
#include <arpa/inet.h>
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp>
#include <ctime>
#include <fstream>
#include <string>
#include <tuple>
#include <vector>
namespace p2psp {
class Synchronizer {
public:
Synchronizer();
~Synchronizer();
const std::vector<std::string>* peer_list;
boost::thread_group thread_group_;
void Run(int argc, const char* argv[]) throw(boost::system::system_error); //Run the argument parser
void PlayChunk(); //Play the chunk to the player
void Synchronize(); //To get the offset from the first peer and synchronize the lists
void ConnectToPeers(std::string); //Connect the synchronizer with various peers
};
}
|
Add Doxygen comments for new Singleton methods | /// \file
/// \brief Singleton design pattern
///
/// \author Peter 'png' Hille <peter@das-system-networks.de>
#ifndef SINGLETON_HH
#define SINGLETON_HH 1
#include <dsnutil/compiler_features.h>
namespace dsn {
/// \brief Template for singleton classes
///
/// This template can be used to implement the "singleton" design pattern
/// on any class.
template <class Derived>
class Singleton {
public:
/// \brief Access singleton instance
///
/// Returns a reference to the instance of this singleton.
static dsnutil_cpp_DEPRECATED Derived& getInstance()
{
return instanceRef();
}
static Derived& instanceRef()
{
static Derived instance;
return instance;
}
static Derived* instancePtr()
{
return &instanceRef();
}
protected:
/// \brief Default constructor
///
/// \note This ctor is protected so that derived classes can implement
/// their own logics for object initialization while still maintaining
/// the impossibility of direct ctor calls!
Singleton() {}
private:
/// \brief Copy constructor
///
/// \note This ctor is private to prevent multiple instances of the same
/// singleton from being created through object assignments!
Singleton(const Singleton&) {}
};
}
#endif // !SINGLETON_HH
| /// \file
/// \brief Singleton design pattern
///
/// \author Peter 'png' Hille <peter@das-system-networks.de>
#ifndef SINGLETON_HH
#define SINGLETON_HH 1
#include <dsnutil/compiler_features.h>
namespace dsn {
/// \brief Template for singleton classes
///
/// This template can be used to implement the "singleton" design pattern
/// on any class.
template <class Derived>
class Singleton {
public:
/// \brief Access singleton instance
///
/// \return Reference to the instance of this singleton.
static dsnutil_cpp_DEPRECATED Derived& getInstance()
{
return instanceRef();
}
/// \brief Access singleton instance (by reference)
///
/// \return Reference to the initialized singleton instance
static Derived& instanceRef()
{
static Derived instance;
return instance;
}
/// \brief Access singleton instance (by pointer)
///
/// \return Pointer to the initialized singleton instance
static Derived* instancePtr()
{
return &instanceRef();
}
protected:
/// \brief Default constructor
///
/// \note This ctor is protected so that derived classes can implement
/// their own logics for object initialization while still maintaining
/// the impossibility of direct ctor calls!
Singleton() {}
private:
/// \brief Copy constructor
///
/// \note This ctor is private to prevent multiple instances of the same
/// singleton from being created through object assignments!
Singleton(const Singleton&) {}
};
}
#endif // !SINGLETON_HH
|
Transform from base 10 in whatever base you want | /*
* The decimal number, 585 = 1001001001 (binary), is palindromic in both bases.
* Find the sum of all numbers, less than 5 000 000, which are palindromic in
* base 10 and base 2. (Please note that the palindromic number, in either base,
* may not include leading zeros.)
*/
#include <stdio.h>
#include <string.h>
#define MAXIM 5000000
char * strrev(char number[]){
int length, index=0, tmp;
length = strlen(number)-1;
while(index<length) {
tmp = number[index];
number[index] = number[length];
number[length] = tmp;
index++; length--;
}
return number;
}
int *to_base(int base, char repr[], int number) {
int remainder, length;
static char new_number[] = "";
new_number[0] = '\0';
while(number) {
remainder = number % base;
number /= base;
length = strlen(new_number);
new_number[length] = repr[remainder];
new_number[length+1] = '\0';
}
return atoi(strrev(new_number));
}
int check_palindrom(int number) {
return 1;
}
int generate_palindroms() {
int number, sum=0;
for(number=11; number<=MAXIM; number++){
if (check_palindrom(number) && check_palindrom(to_base(2, "01", number))) {
sum += number;
}
}
return sum;
}
int main() {
generate_palindroms();
return 0;
}
| |
Fix control device IOCTLS access type | /*
* UsbDk filter/redirector driver
*
* Copyright (c) 2013 Red Hat, Inc.
*
* Authors:
* Dmitry Fleytman <dfleytma@redhat.com>
*
*/
#pragma once
#include "UsbDkData.h"
#include "UsbDkNames.h"
#define USBDK_DEVICE_TYPE 50000
// UsbDk Control Device IOCTLs
#define IOCTL_USBDK_COUNT_DEVICES \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x851, METHOD_BUFFERED, FILE_READ_ACCESS ))
#define IOCTL_USBDK_ENUM_DEVICES \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x852, METHOD_BUFFERED, FILE_READ_ACCESS ))
#define IOCTL_USBDK_ADD_REDIRECT \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x854, METHOD_BUFFERED, FILE_READ_ACCESS ))
#define IOCTL_USBDK_REMOVE_REDIRECT \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x855, METHOD_BUFFERED, FILE_READ_ACCESS ))
| /*
* UsbDk filter/redirector driver
*
* Copyright (c) 2013 Red Hat, Inc.
*
* Authors:
* Dmitry Fleytman <dfleytma@redhat.com>
*
*/
#pragma once
#include "UsbDkData.h"
#include "UsbDkNames.h"
#define USBDK_DEVICE_TYPE 50000
// UsbDk Control Device IOCTLs
#define IOCTL_USBDK_COUNT_DEVICES \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x851, METHOD_BUFFERED, FILE_READ_ACCESS ))
#define IOCTL_USBDK_ENUM_DEVICES \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x852, METHOD_BUFFERED, FILE_READ_ACCESS ))
#define IOCTL_USBDK_ADD_REDIRECT \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x854, METHOD_BUFFERED, FILE_WRITE_ACCESS ))
#define IOCTL_USBDK_REMOVE_REDIRECT \
ULONG(CTL_CODE( USBDK_DEVICE_TYPE, 0x855, METHOD_BUFFERED, FILE_WRITE_ACCESS ))
|
Add mock for AppExtension class | /*
* Copyright (c) 2018, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the Ford Motor Company nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_EXTENSION_H_
#define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_EXTENSION_H_
#include "gmock/gmock.h"
#include "application_manager/app_extension.h"
namespace test {
namespace components {
namespace application_manager_test {
namespace {
static unsigned MockAppExtensionUID = 123;
} // namespace
class MockAppExtension : public application_manager::AppExtension {
public:
MockAppExtension() : AppExtension(MockAppExtensionUID) {}
MOCK_METHOD1(
SaveResumptionData,
void(NsSmartDeviceLink::NsSmartObjects::SmartObject& resumption_data));
MOCK_METHOD1(ProcessResumption,
void(const NsSmartDeviceLink::NsSmartObjects::SmartObject&
resumption_data));
};
} // namespace application_manager_test
} // namespace components
} // namespace test
#endif // SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_EXTENSION_H_
| |
Add operators for some types for PUP | #pragma once
#include <glm/glm.hpp>
#include "sv/scivis.h"
inline void operator|(PUP::er &p, sv::VolumeDType &dtype) {
if (p.isUnpacking()) {
int t = 0;
p | t;
dtype = (sv::VolumeDType)t;
} else {
int t = dtype;
p | t;
}
}
inline void operator|(PUP::er &p, glm::uvec3 &v) {
p | v.x;
p | v.y;
p | v.z;
}
| |
Disable a few misc flags | #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_iflag &= ~(ICRNL | IXON);
raw.c_oflag &= ~(OPOST);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enableRawMode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q') {
if (iscntrl(c)) {
printf("%d\r\n", c);
} else {
printf("%d ('%c')\r\n", c, c);
}
}
return 0;
}
| #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag &= ~(OPOST);
raw.c_cflag |= (CS8);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enableRawMode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q') {
if (iscntrl(c)) {
printf("%d\r\n", c);
} else {
printf("%d ('%c')\r\n", c, c);
}
}
return 0;
}
|
Synchronize the mailbox after expunging messages to actually get them expunged. | /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
| /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
else if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
|
Comment out old Command to avoid name collisions | #ifndef TE_COMMANDS_H
#define TE_COMMANDS_H
#include <functional>
#include <map>
#include <SDL_keycode.h>
#include <SDL_events.h>
#include <memory>
namespace te
{
class Rectangle;
enum class Action { UP, DOWN };
typedef std::function<void()> Command;
typedef std::map<Action, Command> CommandMap;
CommandMap createPaddleCommandMap(std::shared_ptr<Rectangle> pPaddle);
typedef std::map<std::pair<SDL_Keycode, Uint32>, Action> KeyMap;
KeyMap createPaddleKeyMap(unsigned int configN = 1);
}
#endif /* TE_COMMANDS_H */
| #ifndef TE_COMMANDS_H
#define TE_COMMANDS_H
#include <functional>
#include <map>
#include <SDL_keycode.h>
#include <SDL_events.h>
#include <memory>
namespace te
{
class Rectangle;
enum class Action { UP, DOWN };
//typedef std::function<void()> Command;
//typedef std::map<Action, Command> CommandMap;
//CommandMap createPaddleCommandMap(std::shared_ptr<Rectangle> pPaddle);
//typedef std::map<std::pair<SDL_Keycode, Uint32>, Action> KeyMap;
//KeyMap createPaddleKeyMap(unsigned int configN = 1);
}
#endif /* TE_COMMANDS_H */
|
Update trapv tests with explicit signal name | // RUN: %ucc -ftrapv -fno-const-fold -o %t %s
// RUN: %t; [ $? -ne 0 ]
main()
{
int x;
// ensure powers of two aren't shift-converted, as overflow can't catch this
x = -3 * 0x4000000000000000;
return 0;
}
| // RUN: %ocheck SIGILL %s -ftrapv -fno-const-fold -DT=int
// RUN: %ocheck SIGILL %s -ftrapv -fno-const-fold -DT=long
// RUN: %ocheck 0 %s -fno-const-fold -DT=int
// RUN: %ocheck 0 %s -fno-const-fold -DT=long
main()
{
// test with T being both int and long, to check how truncations are dealt with
T x;
// ensure powers of two aren't shift-converted, as overflow can't catch this
x = -3 * 0x4000000000000000;
return 0;
}
|
Remove const from ThreadChecker in NullAudioPoller. | /*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef AUDIO_NULL_AUDIO_POLLER_H_
#define AUDIO_NULL_AUDIO_POLLER_H_
#include "modules/audio_device/include/audio_device_defines.h"
#include "rtc_base/messagehandler.h"
#include "rtc_base/thread_checker.h"
namespace webrtc {
namespace internal {
class NullAudioPoller final : public rtc::MessageHandler {
public:
explicit NullAudioPoller(AudioTransport* audio_transport);
~NullAudioPoller();
protected:
void OnMessage(rtc::Message* msg) override;
private:
const rtc::ThreadChecker thread_checker_;
AudioTransport* const audio_transport_;
int64_t reschedule_at_;
};
} // namespace internal
} // namespace webrtc
#endif // AUDIO_NULL_AUDIO_POLLER_H_
| /*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef AUDIO_NULL_AUDIO_POLLER_H_
#define AUDIO_NULL_AUDIO_POLLER_H_
#include "modules/audio_device/include/audio_device_defines.h"
#include "rtc_base/messagehandler.h"
#include "rtc_base/thread_checker.h"
namespace webrtc {
namespace internal {
class NullAudioPoller final : public rtc::MessageHandler {
public:
explicit NullAudioPoller(AudioTransport* audio_transport);
~NullAudioPoller();
protected:
void OnMessage(rtc::Message* msg) override;
private:
rtc::ThreadChecker thread_checker_;
AudioTransport* const audio_transport_;
int64_t reschedule_at_;
};
} // namespace internal
} // namespace webrtc
#endif // AUDIO_NULL_AUDIO_POLLER_H_
|
Add value parameter to fprintf in safe_malloc | #include "safe-c/safe_memory.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void* safe_malloc_function(size_t size, const char* calling_function)
{
if (size == 0)
{
fprintf(stderr, "Error allocating memory: The function %s called "
"'safe_malloc' and requested zero memory. The pointer should "
"be explicitly set to NULL instead.\n",
calling_function);
exit(EXIT_FAILURE);
}
void* memory = malloc(size);
if (!memory)
{
fprintf(stderr, "Error allocating memory: The function %s called "
"'safe_malloc' requesting %u bytes of memory, but an error "
"occurred allocating this amount of memory. Exiting",
calling_function);
exit(EXIT_FAILURE);
}
memset(memory, 0, size);
return memory;
}
void safe_free_function(void** pointer)
{
if (pointer != NULL)
{
free(*pointer);
*pointer = NULL;
}
}
| #include "safe-c/safe_memory.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void* safe_malloc_function(size_t size, const char* calling_function)
{
if (size == 0)
{
fprintf(stderr, "Error allocating memory: The function %s called "
"'safe_malloc' and requested zero memory. The pointer should "
"be explicitly set to NULL instead.\n",
calling_function);
exit(EXIT_FAILURE);
}
void* memory = malloc(size);
if (!memory)
{
fprintf(stderr, "Error allocating memory: The function %s called "
"'safe_malloc' requesting %zu bytes of memory, but an error "
"occurred allocating this amount of memory. Exiting",
calling_function, size);
exit(EXIT_FAILURE);
}
memory = memset(memory, 0, size);
return memory;
}
void safe_free_function(void** pointer)
{
if (pointer != NULL)
{
free(*pointer);
*pointer = NULL;
}
}
|
Add a missing file, even though it doesn't do much right now. | /**
* This program sets up a 50 Hz PWM and a basic UART command structure.
* Users may connect to the UART and send one byte at a time to make up
* more complex commands. The basic layout of the command format is
* like this: [B_1,B_2,0xFE], with the commas, brackets, and quotes all
* being abstract (e.g. not really sent across the wire).
*
* B_1 will generally be the servo of interest (e.g. 'A' or 'B').
* B_2 will generally be a byte between 0 and 180, representing degrees.
* B_1 and B_2 may be sent interchangeably or even many times over, and the
* AVR will just continue to record the data and echo bytes received back
* to the sender until a COMMAND_EXEC_BYTE is reached.
*
* Bytes sent across the wire will be echoed back to the sending device,
* except in the case when COMMAND_EXEC_BYTE (0xFE) is received. In that
* case, ACK_BYTE (0xFF) will be sent back to the sending device.
*
* In the case where the AVR thinks you are trying to set the degrees and
* the degrees are outside the range of [0,180], it will send back a BAD_BYTE.
*/
#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include "servo.h"
#include "uart.h"
#define COMMAND_EXEC_BYTE 0xFD
#define BAD_BYTE 0xFE
#define ACK_BYTE 0xFF
int main (void) {
servo_init(OC1A | OC1B);
uart_enable(UM_Asynchronous);
sei();
volatile uint16_t* pin = 0;
uint8_t degrees = 0;
for (;;) {
volatile unsigned char b = uart_receive();
switch (b) {
case COMMAND_EXEC_BYTE:
*pin = servo(degrees);
b = ACK_BYTE;
break;
case 'A':
pin = &OCR1A;
break;
case 'B':
pin = &OCR1B;
break;
case ACK_BYTE:
break;
default:
if (b > 180) {
b = BAD_BYTE;
} else {
degrees = b;
}
break;
}
uart_transmit(b);
}
return 0;
}
| |
Add __func__, __LINE__ to TRACE if DEBUG, otherwise add progname. | #ifndef _TRACE_H_
#define _TRACE_H_
#include <stdio.h>
#include <errno.h>
#ifdef DEBUG
#define TRACE ERROR
#else
#define TRACE(fmt,arg...) ((void) 0)
#endif
#define ERROR(fmt,arg...) \
fprintf(stderr, "%s:%s:%d: "fmt, program_invocation_short_name, __func__, __LINE__, ##arg)
#define FATAL(fmt,arg...) do { \
ERROR(fmt, ##arg); \
exit(1); \
} while (0)
#endif
| #ifndef _TRACE_H_
#define _TRACE_H_
#include <stdio.h>
#include <errno.h>
#ifdef DEBUG
#define TRACE ERROR
#else
#define TRACE(fmt,arg...) ((void) 0)
#endif
#ifdef DEBUG
#define ERROR(fmt,arg...) \
fprintf(stderr, "%s:%d: "fmt, __func__, __LINE__, ##arg)
#else
#define ERROR(fmt,arg...) \
fprintf(stderr, "%s: "fmt, program_invocation_short_name, ##arg)
#endif
#define FATAL(fmt,arg...) do { \
ERROR(fmt, ##arg); \
exit(1); \
} while (0)
#endif
|
Update version number to 8.02.01-k2. | /*
* QLogic Fibre Channel HBA Driver
* Copyright (c) 2003-2008 QLogic Corporation
*
* See LICENSE.qla2xxx for copyright and licensing details.
*/
/*
* Driver version
*/
#define QLA2XXX_VERSION "8.02.01-k1"
#define QLA_DRIVER_MAJOR_VER 8
#define QLA_DRIVER_MINOR_VER 2
#define QLA_DRIVER_PATCH_VER 1
#define QLA_DRIVER_BETA_VER 0
| /*
* QLogic Fibre Channel HBA Driver
* Copyright (c) 2003-2008 QLogic Corporation
*
* See LICENSE.qla2xxx for copyright and licensing details.
*/
/*
* Driver version
*/
#define QLA2XXX_VERSION "8.02.01-k2"
#define QLA_DRIVER_MAJOR_VER 8
#define QLA_DRIVER_MINOR_VER 2
#define QLA_DRIVER_PATCH_VER 1
#define QLA_DRIVER_BETA_VER 0
|
Update driver version to 5.02.00-k14 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k13"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k14"
|
UPDATE Commented out some test code | #ifndef SSPAPPLICATION_ENTITIES_DOORENTITY_H
#define SSPAPPLICATION_ENTITIES_DOORENTITY_H
#include "Entity.h"
#include <vector>
class DoorEntity :
public Entity
{
private:
struct ElementState {
int entityID;
EVENT desiredState;
bool desiredStateReached;
};
std::vector<ElementState> m_elementStates;
bool m_isOpened;
float m_minRotation;
float m_maxRotation;
float m_rotateTime;
float m_rotatePerSec;
public:
DoorEntity();
virtual ~DoorEntity();
int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp, float rotateTime = 1.0f, float minRotation = 0.0f, float maxRotation = DirectX::XM_PI / 2.0f);
int Update(float dT, InputHandler* inputHandler);
int React(int entityID, EVENT reactEvent);
bool SetIsOpened(bool isOpened);
bool GetIsOpened();
};
#endif | #ifndef SSPAPPLICATION_ENTITIES_DOORENTITY_H
#define SSPAPPLICATION_ENTITIES_DOORENTITY_H
#include "Entity.h"
#include <vector>
class DoorEntity :
public Entity
{
private:
/*struct ElementState {
int entityID;
EVENT desiredState;
bool desiredStateReached;
};
std::vector<ElementState> m_elementStates;*/
bool m_isOpened;
float m_minRotation;
float m_maxRotation;
float m_rotateTime;
float m_rotatePerSec;
public:
DoorEntity();
virtual ~DoorEntity();
int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp, float rotateTime = 1.0f, float minRotation = 0.0f, float maxRotation = DirectX::XM_PI / 2.0f);
int Update(float dT, InputHandler* inputHandler);
int React(int entityID, EVENT reactEvent);
bool SetIsOpened(bool isOpened);
bool GetIsOpened();
};
#endif |
Fix the addr=NULL issue in mmap. | /*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/11/30 Bernard The first version.
*/
#include <stdint.h>
#include <stdio.h>
#include <rtthread.h>
#include <dfs_posix.h>
#include <sys/mman.h>
void *mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset)
{
uint8_t *mem;
if (addr)
{
mem = addr;
}
else mem = (uint8_t *)malloc(length);
if (mem)
{
off_t cur;
size_t read_bytes;
cur = lseek(fd, 0, SEEK_SET);
lseek(fd, offset, SEEK_SET);
read_bytes = read(fd, addr, length);
if (read_bytes != length)
{
if (addr == RT_NULL)
{
/* read failed */
free(mem);
mem = RT_NULL;
}
}
lseek(fd, cur, SEEK_SET);
return mem;
}
errno = ENOMEM;
return MAP_FAILED;
}
int munmap(void *addr, size_t length)
{
if (addr)
{
free(addr);
return 0;
}
return -1;
}
| /*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/11/30 Bernard The first version.
*/
#include <stdint.h>
#include <stdio.h>
#include <rtthread.h>
#include <dfs_posix.h>
#include <sys/mman.h>
void *mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset)
{
uint8_t *mem;
if (addr)
{
mem = addr;
}
else mem = (uint8_t *)malloc(length);
if (mem)
{
off_t cur;
size_t read_bytes;
cur = lseek(fd, 0, SEEK_SET);
lseek(fd, offset, SEEK_SET);
read_bytes = read(fd, mem, length);
if (read_bytes != length)
{
if (addr == RT_NULL)
{
/* read failed */
free(mem);
mem = RT_NULL;
}
}
lseek(fd, cur, SEEK_SET);
return mem;
}
errno = ENOMEM;
return MAP_FAILED;
}
int munmap(void *addr, size_t length)
{
if (addr)
{
free(addr);
return 0;
}
return -1;
}
|
Change key state array constness. | #ifndef INPUTSTATE_H
#define INPUTSTATE_H
#include <SDL2/SDL.h>
#undef main
#include <map>
class InputState
{
public:
enum KeyFunction { KF_EXIT, KF_FORWARDS, KF_BACKWARDS, KF_ROTATE_SUN };
InputState();
void readInputState();
bool getKeyState(KeyFunction f);
int getAbsoluteMouseX() { return mouse_x; };
int getAbsoluteMouseY() { return mouse_y; };
float getMouseX() { return (float)mouse_x / (float)w; };
float getMouseY() { return (float)mouse_y / (float)h; };
int w, h;
int mouse_x, mouse_y;
private:
Uint8 *keys;
Uint8 key_function_to_keycode[4];
};
#endif
| #ifndef INPUTSTATE_H
#define INPUTSTATE_H
#include <SDL2/SDL.h>
#undef main
#include <map>
class InputState
{
public:
enum KeyFunction { KF_EXIT, KF_FORWARDS, KF_BACKWARDS, KF_ROTATE_SUN };
InputState();
void readInputState();
bool getKeyState(KeyFunction f);
int getAbsoluteMouseX() { return mouse_x; };
int getAbsoluteMouseY() { return mouse_y; };
float getMouseX() { return (float)mouse_x / (float)w; };
float getMouseY() { return (float)mouse_y / (float)h; };
int w, h;
int mouse_x, mouse_y;
private:
const Uint8 *keys;
Uint8 key_function_to_keycode[4];
};
#endif
|
Use suggested change from Martin in defining OSCL_UNUSED_ARG. | /* ------------------------------------------------------------------
* Copyright (C) 2009 Martin Storsjo
*
* 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 OSCL_BASE_H
#define OSCL_BASE_H
#include <stdint.h>
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#define OSCL_IMPORT_REF
#define OSCL_EXPORT_REF
#define OSCL_UNUSED_ARG (void)
#endif
| /* ------------------------------------------------------------------
* Copyright (C) 2009 Martin Storsjo
*
* 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 OSCL_BASE_H
#define OSCL_BASE_H
#include <stdint.h>
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#define OSCL_IMPORT_REF
#define OSCL_EXPORT_REF
#define OSCL_UNUSED_ARG(x) (void)(x)
#endif
|
Use GCC "noreturn" function attribute. | #ifndef ERROR_H
#define ERROR_H
/*
* Note that we include "fmt" in the variadic argument list, because C99
* apparently doesn't allow variadic macros to be invoked without any vargs
* parameters.
*/
#define ERROR(...) var_error(__FILE__, __LINE__, __VA_ARGS__)
#define FAIL() simple_error(__FILE__, __LINE__)
#define ASSERT(cond) ((cond) || assert_fail(APR_STRINGIFY(cond), \
__FILE__, __LINE__))
void simple_error(const char *file, int line_num);
void var_error(const char *file, int line_num,
const char *fmt, ...) __attribute__((format(printf, 3, 4)));
int assert_fail(const char *cond, const char *file, int line_num);
#endif /* ERROR_H */
| #ifndef ERROR_H
#define ERROR_H
/*
* Note that we include "fmt" in the variadic argument list, because C99
* apparently doesn't allow variadic macros to be invoked without any vargs
* parameters.
*/
#define ERROR(...) var_error(__FILE__, __LINE__, __VA_ARGS__)
#define FAIL() simple_error(__FILE__, __LINE__)
#define ASSERT(cond) ((cond) || assert_fail(APR_STRINGIFY(cond), \
__FILE__, __LINE__))
void simple_error(const char *file, int line_num) __attribute__((noreturn));
void var_error(const char *file, int line_num,
const char *fmt, ...) __attribute__((format(printf, 3, 4), noreturn));
int assert_fail(const char *cond, const char *file, int line_num);
#endif /* ERROR_H */
|
Enlarge default buffer size limit | // MIT License
// Copyright (c) 2017 Zhuhao Wang
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#ifndef NEKIT_TUNNEL_BUFFER_SIZE
#define NEKIT_TUNNEL_BUFFER_SIZE 8192
#endif
#ifndef NEKIT_TUNNEL_MAX_BUFFER_SIZE
#define NEKIT_TUNNEL_MAX_BUFFER_SIZE NEKIT_TUNNEL_BUFFER_SIZE
#endif
| // MIT License
// Copyright (c) 2017 Zhuhao Wang
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#ifndef NEKIT_TUNNEL_BUFFER_SIZE
#define NEKIT_TUNNEL_BUFFER_SIZE 8192
#endif
#ifndef NEKIT_TUNNEL_MAX_BUFFER_SIZE
#define NEKIT_TUNNEL_MAX_BUFFER_SIZE (NEKIT_TUNNEL_BUFFER_SIZE * 2)
#endif
|
Add assert fail/success comments to 13/32 | #include <pthread.h>
#include <assert.h>
int g = 0;
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t C = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
pthread_mutex_lock(&A);
pthread_mutex_lock(&C);
pthread_mutex_lock(&B);
g = 5;
pthread_mutex_unlock(&B);
pthread_mutex_lock(&B);
g = 0;
pthread_mutex_unlock(&B);
pthread_mutex_unlock(&C);
pthread_mutex_unlock(&A);
return NULL;
}
int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
// This must be before the other to get Mine to fail for the other even with thread ID partitioning.
pthread_mutex_lock(&B);
pthread_mutex_lock(&C);
assert(g == 0);
pthread_mutex_unlock(&C);
pthread_mutex_unlock(&B);
pthread_mutex_lock(&A);
pthread_mutex_lock(&B);
assert(g == 0);
pthread_mutex_unlock(&B);
pthread_mutex_unlock(&A);
pthread_join(id, NULL);
return 0;
}
| #include <pthread.h>
#include <assert.h>
int g = 0;
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t C = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
pthread_mutex_lock(&A);
pthread_mutex_lock(&C);
pthread_mutex_lock(&B);
g = 5;
pthread_mutex_unlock(&B);
pthread_mutex_lock(&B);
g = 0;
pthread_mutex_unlock(&B);
pthread_mutex_unlock(&C);
pthread_mutex_unlock(&A);
return NULL;
}
int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
// This must be before the other to get Mine to fail for the other even with thread ID partitioning.
pthread_mutex_lock(&B);
pthread_mutex_lock(&C);
assert(g == 0); // mine and mutex-oplus fail, mutex-meet succeeds
pthread_mutex_unlock(&C);
pthread_mutex_unlock(&B);
pthread_mutex_lock(&A);
pthread_mutex_lock(&B);
assert(g == 0); // mine fails, mutex-oplus and mutex-meet succeed
pthread_mutex_unlock(&B);
pthread_mutex_unlock(&A);
pthread_join(id, NULL);
return 0;
}
|
Use new `estragon_send` API in CPU plugin | #include <uv.h>
#include <estragon.h>
#ifdef __sun
#include <sys/pset.h>
#include <sys/loadavg.h>
#endif
static uv_timer_t cpu_timer;
void send_cpu_usage(uv_timer_t *timer, int status) {
double loadinfo[3];
#ifdef DEBUG
printf("cpu usage timer fired, status %d\n", status);
#endif
#ifdef __sun
/* On SunOS, if we're not in a global zone, uv_loadavg returns [0, 0, 0] */
/* This, instead, gets the loadavg for our assigned processor set. */
pset_getloadavg(PS_MYID, loadinfo, 3);
#else
uv_loadavg(loadinfo);
#endif
estragon_send("CPU load, last minute", "info", loadinfo[0]);
estragon_send("CPU load, last 5 minutes", "info", loadinfo[1]);
estragon_send("CPU load, last 15 minutes", "info", loadinfo[2]);
}
int cpu_init() {
uv_timer_init(uv_default_loop(), &cpu_timer);
uv_timer_start(&cpu_timer, send_cpu_usage, 0, 1000);
return 0;
}
| #include <uv.h>
#include <estragon.h>
#ifdef __sun
#include <sys/pset.h>
#include <sys/loadavg.h>
#endif
static uv_timer_t cpu_timer;
void send_cpu_usage(uv_timer_t *timer, int status) {
double loadinfo[3];
#ifdef DEBUG
printf("cpu usage timer fired, status %d\n", status);
#endif
#ifdef __sun
/* On SunOS, if we're not in a global zone, uv_loadavg returns [0, 0, 0] */
/* This, instead, gets the loadavg for our assigned processor set. */
pset_getloadavg(PS_MYID, loadinfo, 3);
#else
uv_loadavg(loadinfo);
#endif
estragon_send("cpu", "info", "CPU load, last minute", loadinfo[0]);
estragon_send("cpu", "info", "CPU load, last 5 minutes", loadinfo[1]);
estragon_send("cpu", "info", "CPU load, last 15 minutes", loadinfo[2]);
}
int cpu_init() {
uv_timer_init(uv_default_loop(), &cpu_timer);
uv_timer_start(&cpu_timer, send_cpu_usage, 0, 1000);
return 0;
}
|
Include stdio.h in case bzlib.h needs it. | /* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-internal.h"
#include "istream-zlib.h"
#ifdef HAVE_BZLIB
#include <bzlib.h>
#define BZLIB_INCLUDE
#define gzFile BZFILE
#define gzdopen BZ2_bzdopen
#define gzclose BZ2_bzclose
#define gzread BZ2_bzread
#define gzseek BZ2_bzseek
#define i_stream_create_zlib i_stream_create_bzlib
#include "istream-zlib.c"
#endif
| /* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-internal.h"
#include "istream-zlib.h"
#ifdef HAVE_BZLIB
#include <stdio.h>
#include <bzlib.h>
#define BZLIB_INCLUDE
#define gzFile BZFILE
#define gzdopen BZ2_bzdopen
#define gzclose BZ2_bzclose
#define gzread BZ2_bzread
#define gzseek BZ2_bzseek
#define i_stream_create_zlib i_stream_create_bzlib
#include "istream-zlib.c"
#endif
|
Add serial port console implementation | #include <kernel/kernel.h>
#include <kernel/console.h>
#include <arch/ioport.h>
#define SERIAL_PORT_IO_BASE 0x3f8
#define REG_DATA (SERIAL_PORT_IO_BASE)
#define REG_DLL (SERIAL_PORT_IO_BASE)
#define REG_IER (SERIAL_PORT_IO_BASE + 1)
#define REG_DLH (SERIAL_PORT_IO_BASE + 1)
#define REG_FCR (SERIAL_PORT_IO_BASE + 2)
#define REG_LCR (SERIAL_PORT_IO_BASE + 3)
#define REG_LSR (SERIAL_PORT_IO_BASE + 5)
#define FCR_EFIFO BITU(0)
#define FCR_14BYTES (BITU(6) | BITU(7))
#define LCR_8BIT (BITU(0) | BITU(1))
#define LCR_DLAB BITU(7)
#define LSR_TX_READY BITU(5)
static void putchar(char c)
{
while (!(inb(REG_LSR) & LSR_TX_READY));
outb(REG_DATA, c);
}
static void write(const char *buf, unsigned long size)
{
for (unsigned i = 0; i != size; ++i)
putchar(buf[i]);
}
static struct console serial_console = {
.write = write
};
static void init_polling_mode(void)
{
/* disable all interrupts */
outb(REG_IER, 0);
/* enable access to frequency divisor */
outb(REG_LCR, LCR_DLAB);
/* set 9600 baud rate (timer frequency is 115200, divide it by 12) */
outb(REG_DLL, 0x0C);
outb(REG_DLH, 0x00);
/* set frame format (8 bit, no parity, 1 stop bit) and drop DLAB */
outb(REG_LCR, LCR_8BIT);
/* enable 14 byte length FIFO buffer */
outb(REG_FCR, FCR_EFIFO | FCR_14BYTES);
}
void init_serial_console(void)
{
init_polling_mode();
register_console(&serial_console);
}
| |
Use the correct import syntax | //
// APIAFNetworkingHTTPClient.h
// APIClient
//
// Created by Klaas Pieter Annema on 30-08-13.
// Copyright (c) 2013 Klaas Pieter Annema. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
#import "APIHTTPClient.h"
@interface APIAFNetworkingHTTPClient : NSObject <APIHTTPClient>
@property (nonatomic, readonly, copy) NSURL *baseURL;
@property (nonatomic, readonly, strong) NSURLSessionConfiguration *sessionConfiguration;
- (id)initWithBaseURL:(NSURL *)baseURL;
- (id)initWithBaseURL:(NSURL *)baseURL
sessionConfiguration:(NSURLSessionConfiguration *)sessionConfiguration NS_DESIGNATED_INITIALIZER;
@end
| //
// APIAFNetworkingHTTPClient.h
// APIClient
//
// Created by Klaas Pieter Annema on 30-08-13.
// Copyright (c) 2013 Klaas Pieter Annema. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>
#import "APIHTTPClient.h"
@interface APIAFNetworkingHTTPClient : NSObject <APIHTTPClient>
@property (nonatomic, readonly, copy) NSURL *baseURL;
@property (nonatomic, readonly, strong) NSURLSessionConfiguration *sessionConfiguration;
- (id)initWithBaseURL:(NSURL *)baseURL;
- (id)initWithBaseURL:(NSURL *)baseURL
sessionConfiguration:(NSURLSessionConfiguration *)sessionConfiguration NS_DESIGNATED_INITIALIZER;
@end
|
Make read only functions as const. | // Copyright 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_WAYLAND_INPUT_DEVICE_H_
#define OZONE_WAYLAND_INPUT_DEVICE_H_
#include <wayland-client.h>
#include "base/basictypes.h"
namespace ozonewayland {
class WaylandKeyboard;
class WaylandPointer;
class WaylandDisplay;
class WaylandWindow;
class WaylandInputDevice {
public:
WaylandInputDevice(WaylandDisplay* display, uint32_t id);
~WaylandInputDevice();
wl_seat* GetInputSeat() { return input_seat_; }
WaylandKeyboard* GetKeyBoard() const { return input_keyboard_; }
WaylandPointer* GetPointer() const { return input_pointer_; }
unsigned GetFocusWindowHandle() { return focused_window_handle_; }
void SetFocusWindowHandle(unsigned windowhandle);
private:
static void OnSeatCapabilities(void *data,
wl_seat *seat,
uint32_t caps);
// Keeps track of current focused window.
unsigned focused_window_handle_;
wl_seat* input_seat_;
WaylandKeyboard* input_keyboard_;
WaylandPointer* input_pointer_;
DISALLOW_COPY_AND_ASSIGN(WaylandInputDevice);
};
} // namespace ozonewayland
#endif // OZONE_WAYLAND_INPUT_DEVICE_H_
| // Copyright 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_WAYLAND_INPUT_DEVICE_H_
#define OZONE_WAYLAND_INPUT_DEVICE_H_
#include <wayland-client.h>
#include "base/basictypes.h"
namespace ozonewayland {
class WaylandKeyboard;
class WaylandPointer;
class WaylandDisplay;
class WaylandWindow;
class WaylandInputDevice {
public:
WaylandInputDevice(WaylandDisplay* display, uint32_t id);
~WaylandInputDevice();
wl_seat* GetInputSeat() const { return input_seat_; }
WaylandKeyboard* GetKeyBoard() const { return input_keyboard_; }
WaylandPointer* GetPointer() const { return input_pointer_; }
unsigned GetFocusWindowHandle() const { return focused_window_handle_; }
void SetFocusWindowHandle(unsigned windowhandle);
private:
static void OnSeatCapabilities(void *data,
wl_seat *seat,
uint32_t caps);
// Keeps track of current focused window.
unsigned focused_window_handle_;
wl_seat* input_seat_;
WaylandKeyboard* input_keyboard_;
WaylandPointer* input_pointer_;
DISALLOW_COPY_AND_ASSIGN(WaylandInputDevice);
};
} // namespace ozonewayland
#endif // OZONE_WAYLAND_INPUT_DEVICE_H_
|
Fix for Ubuntu 14.04, CentOS should work too | #include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char *host = "127.0.0.1";
int port = 2000;
int timeout = 2;
int sockfd, n;
char buffer[256];
struct sockaddr_in serv_addr;
struct hostent *server;
struct timeval tv;
tv.tv_sec = timeout;
server = gethostbyname(host);
bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
serv_addr.sin_port = htons(port);
serv_addr.sin_family = AF_INET;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval));
connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
n = read(sockfd, buffer, 255);
if (n < 0) {
perror("error reading from socket");
return 1;
}
printf("%s\n", buffer);
return 0;
}
| #include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char *host = "127.0.0.1";
int port = 2000;
int timeout = 2;
int sockfd, n;
char buffer[256];
struct sockaddr_in serv_addr;
struct hostent *server;
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
server = gethostbyname(host);
bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
serv_addr.sin_port = htons(port);
serv_addr.sin_family = AF_INET;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval));
connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
n = read(sockfd, buffer, 255);
if (n < 0) {
perror("error reading from socket");
return 1;
}
printf("%s\n", buffer);
return 0;
}
|
Add basic test about pointer and structs | /*
name: TEST017
description: Basic test about pointers and structs
output:
F1
G9 F1 main
{
-
S2 s1
(
M3 I y
M4 I z
)
A2 S2 nested
S6 s2
(
M8 P p
)
A3 S6 v
A3 M8 .P A2 'P :P
A3 M8 .P @S2 M3 .I #I1 :I
A3 M8 .P @S2 M4 .I #I2 :I
j L4 A2 M3 .I #I1 =I
yI #I1
L4
j L5 A2 M4 .I #I2 =I
yI #I2
L5
yI #I0
}
*/
#line 1
struct s1 {
int y;
int z;
};
struct s2 {
struct s1 *p;
};
int main()
{
struct s1 nested;
struct s2 v;
v.p = &nested;
v.p->y = 1;
v.p->z = 2;
if (nested.y != 1)
return 1;
if (nested.z != 2)
return 2;
return 0;
}
| |
Fix abort_on_error: Don't forget to exit(-1). | #pragma once
#define pi (3.14159265358979323846)
#define abort_on_error(where, error) ({ \
typeof(where) _where = where; \
typeof(error) _error = error; \
\
if(_error) { \
fprintf( \
stderr, \
__FILE__ ":%d: %s error (%#x).\n", \
__LINE__, \
_where, \
_error \
); \
} \
})
| #pragma once
#include <stdlib.h>
#define pi (3.14159265358979323846)
#define abort_on_error(where, error) ({ \
typeof(where) _where = where; \
typeof(error) _error = error; \
\
if(_error) { \
fprintf( \
stderr, \
__FILE__ ":%d: %s error (%#x).\n", \
__LINE__, \
_where, \
_error \
); \
\
exit(-1); \
} \
})
|
Fix the qualification of `IntrusiveRefCntPtr` to use `llvm::`. | //===--- FSProvider.h - VFS provider for ClangdServer ------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/VirtualFileSystem.h"
namespace clang {
namespace clangd {
// Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
// As FileSystem is not threadsafe, concurrent threads must each obtain one.
class FileSystemProvider {
public:
virtual ~FileSystemProvider() = default;
/// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
/// Context::current() will be the context passed to the clang entrypoint,
/// such as addDocument(), and will also be propagated to result callbacks.
/// Embedders may use this to isolate filesystem accesses.
virtual IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() const = 0;
};
class RealFileSystemProvider : public FileSystemProvider {
public:
// FIXME: returns the single real FS instance, which is not threadsafe.
IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() const override {
return llvm::vfs::getRealFileSystem();
}
};
} // namespace clangd
} // namespace clang
#endif
| //===--- FSProvider.h - VFS provider for ClangdServer ------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/VirtualFileSystem.h"
namespace clang {
namespace clangd {
// Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
// As FileSystem is not threadsafe, concurrent threads must each obtain one.
class FileSystemProvider {
public:
virtual ~FileSystemProvider() = default;
/// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
/// Context::current() will be the context passed to the clang entrypoint,
/// such as addDocument(), and will also be propagated to result callbacks.
/// Embedders may use this to isolate filesystem accesses.
virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
getFileSystem() const = 0;
};
class RealFileSystemProvider : public FileSystemProvider {
public:
// FIXME: returns the single real FS instance, which is not threadsafe.
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
getFileSystem() const override {
return llvm::vfs::getRealFileSystem();
}
};
} // namespace clangd
} // namespace clang
#endif
|
Add typedefs for VertexBuffer, IndexBuffer in GL |
#pragma once
#include <ionGL.h>
typedef ion::GL::Uniform IUniform;
template <typename T>
using CUniformValue = ion::GL::UniformValue<T>;
template <typename T>
using CUniformReference = ion::GL::UniformReference<T>;
|
#pragma once
#include <ionGL.h>
typedef ion::GL::Uniform IUniform;
template <typename T>
using CUniformValue = ion::GL::UniformValue<T>;
template <typename T>
using CUniformReference = ion::GL::UniformReference<T>;
typedef ion::GL::VertexBuffer CVertexBuffer;
typedef ion::GL::IndexBuffer CIndexBuffer;
|
Update ILogListener interface with docs | // Copyright 2016 Airtame
#ifndef MANAGEDEVICE_LOGGING_ILOGLISTENER_H_
#define MANAGEDEVICE_LOGGING_ILOGLISTENER_H_
#include <string>
// Forward declarations.
enum class ELogLevel;
class ILogListener {
public:
virtual ~ILogListener() {}
virtual void Notify(const std::string& iLog, ELogLevel iLevel) = 0;
};
#endif // MANAGEDEVICE_LOGGING_ILOGLISTENER_H_
| // Copyright 2016 Pierre Fourgeaud
#ifndef PF_ILOGLISTENER_H_
#define PF_ILOGLISTENER_H_
#include <string>
// Forward declarations.
enum class ELogLevel;
/**
* @brief The ILogListener class
*
* Define an interface to implement when creating a new LogListener.
* SimpleLogger provide 3 default listeners: Buffer, File, Console.
*
* Implement this class if you want to create your own listener.
*/
class ILogListener {
public:
/**
* Virtual destructor.
*/
virtual ~ILogListener() {}
/**
* Pure virtual method to implement when implementing this interface.
* Method called when getting notified.
*
* @params iLog The string representing the messag to log
* @params iLevel Log level of this message
*/
virtual void Notify(const std::string& iLog, ELogLevel iLevel) = 0;
};
#endif // PF_ILOGLISTENER_H_
|
Revert this, we can now avoid error cascades better. | // Test this without pch.
// RUN: clang-cc -include %S/functions.h -fsyntax-only -verify %s &&
// Test with pch.
// RUN: clang-cc -emit-pch -o %t %S/functions.h &&
// RUN: clang-cc -include-pch %t -fsyntax-only -verify %s
int f0(int x0, int y0, ...) { return x0 + y0; }
float *test_f1(int val, double x, double y) {
if (val > 5)
return f1(x, y);
else
return f1(x); // expected-error{{too few arguments to function call}}
return 0;
}
void test_g0(int *x, float * y) {
g0(y); // expected-warning{{incompatible pointer types passing 'float *', expected 'int *'}}
g0(x);
}
| // Test this without pch.
// RUN: clang-cc -include %S/functions.h -fsyntax-only -verify %s &&
// Test with pch.
// RUN: clang-cc -emit-pch -o %t %S/functions.h &&
// RUN: clang-cc -include-pch %t -fsyntax-only -verify %s
int f0(int x0, int y0, ...) { return x0 + y0; }
float *test_f1(int val, double x, double y) {
if (val > 5)
return f1(x, y);
else
return f1(x); // expected-error{{too few arguments to function call}}
}
void test_g0(int *x, float * y) {
g0(y); // expected-warning{{incompatible pointer types passing 'float *', expected 'int *'}}
g0(x);
}
|
Make KMALLOC_FIRST_HEAP_SIZE depend on KERNEL_MAX_SIZE | /* SPDX-License-Identifier: BSD-2-Clause */
/*
* This is a TEMPLATE. The actual config file is generated by CMake and stored
* in <BUILD_DIR>/tilck_gen_headers/.
*/
#pragma once
#include <tilck_gen_headers/config_global.h>
/* --------- Boolean config variables --------- */
#cmakedefine01 KMALLOC_FREE_MEM_POISONING
#cmakedefine01 KMALLOC_HEAVY_STATS
#cmakedefine01 KMALLOC_SUPPORT_DEBUG_LOG
#cmakedefine01 KMALLOC_SUPPORT_LEAK_DETECTOR
/*
* --------------------------------------------------------------------------
* Hard-coded global & derived constants
* --------------------------------------------------------------------------
*
* Here below there are many dervied constants and convenience constants like
* COMPILER_NAME along with some pseudo-constants like USERMODE_VADDR_END not
* designed to be easily changed because of the code makes assumptions about
* them. Because of that, those constants are hard-coded and not available as
* CMake variables. With time, some of those constants get "promoted" and moved
* in CMake, others remain here. See the comments and think about the potential
* implications before promoting a hard-coded constant to a configurable CMake
* variable.
*/
#if !KERNEL_GCOV
#define KMALLOC_FIRST_HEAP_SIZE ( 128 * KB)
#else
#define KMALLOC_FIRST_HEAP_SIZE ( 512 * KB)
#endif
| /* SPDX-License-Identifier: BSD-2-Clause */
/*
* This is a TEMPLATE. The actual config file is generated by CMake and stored
* in <BUILD_DIR>/tilck_gen_headers/.
*/
#pragma once
#include <tilck_gen_headers/config_global.h>
/* --------- Boolean config variables --------- */
#cmakedefine01 KMALLOC_FREE_MEM_POISONING
#cmakedefine01 KMALLOC_HEAVY_STATS
#cmakedefine01 KMALLOC_SUPPORT_DEBUG_LOG
#cmakedefine01 KMALLOC_SUPPORT_LEAK_DETECTOR
/*
* --------------------------------------------------------------------------
* Hard-coded global & derived constants
* --------------------------------------------------------------------------
*
* Here below there are many dervied constants and convenience constants like
* COMPILER_NAME along with some pseudo-constants like USERMODE_VADDR_END not
* designed to be easily changed because of the code makes assumptions about
* them. Because of that, those constants are hard-coded and not available as
* CMake variables. With time, some of those constants get "promoted" and moved
* in CMake, others remain here. See the comments and think about the potential
* implications before promoting a hard-coded constant to a configurable CMake
* variable.
*/
#if KERNEL_MAX_SIZE <= 1024 * KB
#define KMALLOC_FIRST_HEAP_SIZE ( 128 * KB)
#else
#define KMALLOC_FIRST_HEAP_SIZE ( 512 * KB)
#endif
|
Use const for struct members | // actions:
//
// * read from queue
// * read from array
// * write to queue
// * write to array
// * stop action (with and/or without time?)
// * query xrun stats etc.
// timestamp! start, duration (number of samples? unlimited?)
// return values: actual start, actual duration (number of samples?)
// queue usage: store smallest available write/read size
// xruns during the runtime of the current action
//
// if queue is empty/full, stop playback/recording
enum actiontype
{
PLAY_BUFFER,
PLAY_RINGBUFFER,
RECORD_BUFFER,
RECORD_RINGBUFFER,
};
struct action
{
enum actiontype actiontype;
struct action* next;
union {
float* buffer;
PaUtilRingBuffer* ringbuffer;
};
unsigned long total_frames;
unsigned long done_frames;
// TODO: channel mapping (pointer to list of channels + length)
// TODO: something to store the result of the action?
};
struct state
{
int input_channels;
int output_channels;
PaUtilRingBuffer* action_q; // Queue for incoming commands
PaUtilRingBuffer* result_q; // Queue for results and command disposal
struct action* actions; // Singly linked list of actions
};
int callback(const void* input, void* output, unsigned long frames
, const PaStreamCallbackTimeInfo* time, PaStreamCallbackFlags status
, void* userdata);
| // actions:
//
// * read from queue
// * read from array
// * write to queue
// * write to array
// * stop action (with and/or without time?)
// * query xrun stats etc.
// timestamp! start, duration (number of samples? unlimited?)
// return values: actual start, actual duration (number of samples?)
// queue usage: store smallest available write/read size
// xruns during the runtime of the current action
//
// if queue is empty/full, stop playback/recording
enum actiontype
{
PLAY_BUFFER,
PLAY_RINGBUFFER,
RECORD_BUFFER,
RECORD_RINGBUFFER,
};
struct action
{
const enum actiontype actiontype;
struct action* next;
union {
float* const buffer;
PaUtilRingBuffer* const ringbuffer;
};
const unsigned long total_frames;
unsigned long done_frames;
// TODO: channel mapping (pointer to list of channels + length)
// TODO: something to store the result of the action?
};
struct state
{
const int input_channels;
const int output_channels;
PaUtilRingBuffer* const action_q; // Queue for incoming commands
PaUtilRingBuffer* const result_q; // Queue for results and command disposal
struct action* actions; // Singly linked list of actions
};
int callback(const void* input, void* output, unsigned long frames
, const PaStreamCallbackTimeInfo* time, PaStreamCallbackFlags status
, void* userdata);
|
Fix cut and paste bug for board specific disconnection | /* Copyright (c) 2014 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.
*
* STM32F3 Family specific USB functionality
*/
#include "usb-stm32f3.h"
#include "usb_api.h"
void usb_connect(void)
{
usb_board_connect();
}
void usb_disconnect(void)
{
usb_board_connect();
}
| /* Copyright (c) 2014 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.
*
* STM32F3 Family specific USB functionality
*/
#include "usb-stm32f3.h"
#include "usb_api.h"
void usb_connect(void)
{
usb_board_connect();
}
void usb_disconnect(void)
{
usb_board_disconnect();
}
|
Remove some hacks from libcurl sample | #include <stdio.h>
// Those types are needed but not defined or used in libcurl headers.
typedef size_t header_callback(char *buffer, size_t size, size_t nitems, void *userdata);
typedef size_t write_data_callback(void *buffer, size_t size, size_t nmemb, void *userp);
extern void something_using_callback1(header_callback*);
extern void something_using_callback2(write_data_callback*);
| #include <stddef.h>
// Those types are needed but not defined or used in libcurl headers.
typedef size_t header_callback(char *buffer, size_t size, size_t nitems, void *userdata);
typedef size_t write_data_callback(void *buffer, size_t size, size_t nmemb, void *userp);
|
Add boost::optional wrapper for python bindings | /*ckwg +5
* Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef VISTK_PYTHON_HELPERS_PYTHON_CONVERT_OPTIONAL_H
#define VISTK_PYTHON_HELPERS_PYTHON_CONVERT_OPTIONAL_H
#include <boost/optional.hpp>
#include <boost/python/converter/registry.hpp>
#include <Python.h>
/**
* \file python_convert_any.h
*
* \brief Helpers for working with boost::any in Python.
*/
template <typename T>
class boost_optional_converter
{
public:
typedef T type_t;
typedef boost::optional<T> optional_t;
boost_optional_converter()
{
boost::python::converter::registry::push_back(
&convertible,
&construct,
boost::python::type_id<optional_t>());
}
~boost_optional_converter()
{
}
static void* convertible(PyObject* obj)
{
if (obj == Py_None)
{
return obj;
}
using namespace boost::python::converter;
registration const& converters(registered<type_t>::converters);
if (implicit_rvalue_convertible_from_python(obj, converters))
{
rvalue_from_python_stage1_data data = rvalue_from_python_stage1(obj, converters);
return rvalue_from_python_stage2(obj, data, converters);
}
return NULL;
}
static PyObject* convert(optional_t const& opt)
{
if (opt)
{
return boost::python::to_python_value<T>()(*opt);
}
else
{
return boost::python::detail::none();
}
}
static void construct(PyObject* obj, boost::python::converter::rvalue_from_python_stage1_data* data)
{
void* storage = reinterpret_cast<boost::python::converter::rvalue_from_python_storage<optional_t>*>(data)->storage.bytes;
#define CONSTRUCT(args) \
do \
{ \
new (storage) optional_t args; \
data->convertible = storage; \
return; \
} while (false)
if (obj == Py_None)
{
CONSTRUCT(());
}
else
{
type_t* t = reinterpret_cast<type_t*>(data->convertible);
CONSTRUCT((*t));
}
#undef CONSTRUCT
}
};
#define REGISTER_OPTIONAL_CONVERTER(T) \
do \
{ \
typedef boost_optional_converter<T> converter; \
typedef typename converter::optional_t opt_t; \
to_python_converter<opt_t, converter>(); \
converter(); \
} while (false)
#endif // VISTK_PYTHON_PIPELINE_PYTHON_CONVERT_OPTIONAL_H
| |
Fix doxygen comments for new header. | #ifndef _ECORE_STR_H
# define _ECORE_STR_H
#ifdef EAPI
#undef EAPI
#endif
#ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
/**
* @file Ecore_Data.h
* @brief Contains threading, list, hash, debugging and tree functions.
*/
# ifdef __cplusplus
extern "C" {
# endif
# ifdef __sgi
# define __FUNCTION__ "unknown"
# ifndef __cplusplus
# define inline
# endif
# endif
/* strlcpy implementation for libc's lacking it */
EAPI size_t ecore_strlcpy(char *dst, const char *src, size_t siz);
#ifdef __cplusplus
}
#endif
#endif /* _ECORE_STR_H */
| #ifndef _ECORE_STR_H
# define _ECORE_STR_H
#ifdef EAPI
#undef EAPI
#endif
#ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
/**
* @file Ecore_Str.h
* @brief Contains useful C string functions.
*/
# ifdef __cplusplus
extern "C" {
# endif
# ifdef __sgi
# define __FUNCTION__ "unknown"
# ifndef __cplusplus
# define inline
# endif
# endif
/* strlcpy implementation for libc's lacking it */
EAPI size_t ecore_strlcpy(char *dst, const char *src, size_t siz);
#ifdef __cplusplus
}
#endif
#endif /* _ECORE_STR_H */
|
Add Quaternion to variant types, makes Q_PROPERTY support it | /*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
///TODO: Make this something entirely different... QVariant wrapped Eigen types, wooh! ;)
#ifndef GLUON_VARIANTTYPES
#define GLUON_VARIANTTYPES
#include <QtCore/QVariant>
#include <QtCore/QMetaType>
#include <Eigen/Geometry>
Q_DECLARE_METATYPE(Eigen::Vector3d)
Q_DECLARE_METATYPE(Eigen::Vector3f)
namespace
{
struct GluonVariantTypes
{
public:
GluonVariantTypes()
{
qRegisterMetaType<Eigen::Vector3d>("Eigen::Vector3d");
qRegisterMetaType<Eigen::Vector3f>("Eigen::Vector3f");
}
};
GluonVariantTypes gluonVariantTypes;
}
#endif
| /*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
///TODO: Make this something entirely different... QVariant wrapped Eigen types, wooh! ;)
#ifndef GLUON_VARIANTTYPES
#define GLUON_VARIANTTYPES
#include <QtCore/QVariant>
#include <QtCore/QMetaType>
#include <Eigen/Geometry>
Q_DECLARE_METATYPE(Eigen::Vector3d);
Q_DECLARE_METATYPE(Eigen::Vector3f);
Q_DECLARE_METATYPE(Eigen::Quaternionf);
namespace
{
struct GluonVariantTypes
{
public:
GluonVariantTypes()
{
qRegisterMetaType<Eigen::Vector3d>("Eigen::Vector3d");
qRegisterMetaType<Eigen::Vector3f>("Eigen::Vector3f");
qRegisterMetaType<Eigen::Quaternionf>("Eigen::Quaternionf");
}
};
GluonVariantTypes gluonVariantTypes;
}
#endif
|
Make Serpent's key_schedule and actual round keys private. Add protected accessor functions for get and set. Set is needed by the x86 version since it implements the key schedule directly. | /*
* Serpent
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_SERPENT_H__
#define BOTAN_SERPENT_H__
#include <botan/block_cipher.h>
namespace Botan {
/**
* Serpent, an AES finalist
*/
class BOTAN_DLL Serpent : public BlockCipher
{
public:
void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
void clear() { round_key.clear(); }
std::string name() const { return "Serpent"; }
BlockCipher* clone() const { return new Serpent; }
Serpent() : BlockCipher(16, 16, 32, 8) {}
protected:
void key_schedule(const byte key[], u32bit length);
SecureVector<u32bit, 132> round_key;
};
}
#endif
| /*
* Serpent
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_SERPENT_H__
#define BOTAN_SERPENT_H__
#include <botan/block_cipher.h>
namespace Botan {
/**
* Serpent, an AES finalist
*/
class BOTAN_DLL Serpent : public BlockCipher
{
public:
void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
void clear() { round_key.clear(); }
std::string name() const { return "Serpent"; }
BlockCipher* clone() const { return new Serpent; }
Serpent() : BlockCipher(16, 16, 32, 8) {}
protected:
/**
* For use by subclasses using SIMD, asm, etc
* @return const reference to the key schedule
*/
const SecureVector<u32bit, 132>& get_round_keys() const
{ return round_key; }
/**
* For use by subclasses that implement the key schedule
* @param ks is the new key schedule value to set
*/
void set_round_keys(const u32bit ks[132])
{ round_key.set(ks, 132); }
private:
void key_schedule(const byte key[], u32bit length);
SecureVector<u32bit, 132> round_key;
};
}
#endif
|
Add testcase for recent checkin. | // RUN: clang-cc -verify -fsyntax-only %s
static void (*fp0)(void) __attribute__((noreturn));
static void __attribute__((noreturn)) f0(void) {
fatal();
} // expected-warning {{function declared 'noreturn' should not return}}
// On K&R
int f1() __attribute__((noreturn));
int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' attribute only applies to function types}}
int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute requires 0 argument(s)}}
void f3() __attribute__((noreturn));
void f3() {
return; // expected-warning {{function 'f3' declared 'noreturn' should not return}}
}
#pragma clang diagnostic error "-Winvalid-noreturn"
void f4() __attribute__((noreturn));
void f4() {
return; // expected-error {{function 'f4' declared 'noreturn' should not return}}
}
// PR4685
extern void f5 (unsigned long) __attribute__ ((__noreturn__));
void
f5 (unsigned long size)
{
}
| // RUN: clang -cc1 -verify -fsyntax-only %s
static void (*fp0)(void) __attribute__((noreturn));
static void __attribute__((noreturn)) f0(void) {
fatal();
} // expected-warning {{function declared 'noreturn' should not return}}
// On K&R
int f1() __attribute__((noreturn));
int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' attribute only applies to function types}}
int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute requires 0 argument(s)}}
void f3() __attribute__((noreturn));
void f3() {
return; // expected-warning {{function 'f3' declared 'noreturn' should not return}}
}
#pragma clang diagnostic error "-Winvalid-noreturn"
void f4() __attribute__((noreturn));
void f4() {
return; // expected-error {{function 'f4' declared 'noreturn' should not return}}
}
// PR4685
extern void f5 (unsigned long) __attribute__ ((__noreturn__));
void
f5 (unsigned long size)
{
}
// PR2461
__attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
x();
}
|
Move kmer functionality from kmei to dlib. | #ifndef KMER_UTIL_H
#define KMER_UTIL_H
#include <assert.h>
#include "logging_util.h"
// Largest odd kmer that can be held in a uint64_t
#define MAX_KMER 31
#define DEFAULT_KMER 21
#ifndef num2nuc
# ifndef NUM2NUC_STR
# define NUM2NUC_STR "ACGTN"
# endif
# define num2nuc(x) NUM2NUC_STR[(uint8_t)x]
#endif
#ifdef __cplusplus
namespace dlib {
#endif
inline void kmer2cstr(uint64_t kmer, int k, char *buf)
{
buf[k] = '\0';
while(k) *buf++ = num2nuc((kmer >> (2 * --k)) & 0x3u);
//LOG_DEBUG("kmer %lu has now become string '%s'.\n", kmer, start);
}
#ifdef __cplusplus
}
#endif
#endif
| #ifndef KMER_UTIL_H
#define KMER_UTIL_H
#include <assert.h>
#include "logging_util.h"
// Largest odd kmer that can be held in a uint64_t
#define MAX_KMER 31
#define DEFAULT_KMER 21
#ifndef num2nuc
# ifndef NUM2NUC_STR
# define NUM2NUC_STR "ACGTN"
# endif
# define num2nuc(x) NUM2NUC_STR[(uint8_t)x]
#endif
#ifdef __cplusplus
namespace dlib {
#endif
inline void kmer2cstr(uint64_t kmer, int k, char *buf)
{
buf[k] = '\0';
while(k) *buf++ = num2nuc((kmer >> (2 * --k)) & 0x3u);
//LOG_DEBUG("kmer %lu has now become string '%s'.\n", kmer, start);
}
// Used to determine the direction in which to encode a kmer
inline int cstr_rc_lt(char *seq, int k, int cpos) {
char *_seq1 = cpos + seq, *_seq2 = _seq1 + k - 1;
for(;k;--k) {
if(*_seq1 != nuc_cmpl(*_seq2)) return *_seq1 < nuc_cmpl(*_seq2);
++_seq1, --_seq2;
}
return 0; // This is reverse-complementarily palindromic. Doesn't matter: it's the same string.
}
#ifdef __cplusplus
}
#endif
#endif
|
Add a generic driver model. | // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All right reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Radu Serban
// =============================================================================
//
//
// =============================================================================
#ifndef GENERIC_FUNCDRIVER_H
#define GENERIC_FUNCDRIVER_H
#include "subsys/ChDriver.h"
class Generic_FuncDriver : public chrono::ChDriver
{
public:
Generic_FuncDriver() {}
~Generic_FuncDriver() {}
virtual void Update(double time)
{
if (time < 0.5)
m_throttle = 0;
else if (time < 1.5)
m_throttle = 0.4 * (time - 0.5);
else
m_throttle = 0.4;
if (time < 4)
m_steering = 0;
else if (time < 6)
m_steering = 0.25 * (time - 4);
else if (time < 10)
m_steering = -0.25 * (time - 6) + 0.5;
else
m_steering = -0.5;
}
};
#endif
| |
Add new common block to compute some diagnostics when needed | C $Header$
C $Name$
C The physics state uses the dynamics dimensions in the horizontal
C and the land dimensions in the horizontal for turbulence variables
c
c Secret Hiding Place - Use to compute gridalt correction term diagnostics
c ------------------------------------------------------------------------
common /fizhi_SHP/ ubef,vbef,thbef,sbef,
. udynbef,vdynbef,thdynbef,sdynbef
_RL ubef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nrphys,Nsx,Nsy)
_RL vbef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nrphys,Nsx,Nsy)
_RL thbef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nrphys,Nsx,Nsy)
_RL sbef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nrphys,Nsx,Nsy)
_RL udynbef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,Nsx,Nsy)
_RL vdynbef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,Nsx,Nsy)
_RL thdynbef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,Nsx,Nsy)
_RL sdynbef(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,Nsx,Nsy)
| |
Reimplement no-op version of DLOG to avoid C++ compiler warning | #pragma once
#include <iostream>
// The same as assert, but expression is always evaluated and result returned
#define CHECK(expr) (assert(expr), expr)
#if !defined(NDEBUG) // Debug
namespace dev
{
namespace evmjit
{
std::ostream& getLogStream(char const* _channel);
}
}
#define DLOG(CHANNEL) ::dev::evmjit::getLogStream(#CHANNEL)
#else // Release
#define DLOG(CHANNEL) true ? std::cerr : std::cerr
#endif
| #pragma once
#include <iostream>
// The same as assert, but expression is always evaluated and result returned
#define CHECK(expr) (assert(expr), expr)
#if !defined(NDEBUG) // Debug
namespace dev
{
namespace evmjit
{
std::ostream& getLogStream(char const* _channel);
}
}
#define DLOG(CHANNEL) ::dev::evmjit::getLogStream(#CHANNEL)
#else // Release
namespace dev
{
namespace evmjit
{
struct Voider
{
void operator=(std::ostream const&) {}
};
}
}
#define DLOG(CHANNEL) true ? (void)0 : ::dev::evmjit::Voider{} = std::cerr
#endif
|
Use SafelyCloseFileDescriptor instead of close. | //===- lib/ReaderWriter/PECOFF/PDBPass.h ----------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_READER_WRITER_PE_COFF_PDB_PASS_H
#define LLD_READER_WRITER_PE_COFF_PDB_PASS_H
#include "lld/Core/Pass.h"
#include "llvm/ADT/StringRef.h"
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#else
#include <io.h>
#endif
namespace lld {
namespace pecoff {
class PDBPass : public lld::Pass {
public:
PDBPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
void perform(std::unique_ptr<MutableFile> &file) override {
if (_ctx.getDebug())
touch(_ctx.getPDBFilePath());
}
private:
void touch(StringRef path) {
int fd;
if (llvm::sys::fs::openFileForWrite(path, fd, llvm::sys::fs::F_Append))
llvm::report_fatal_error("failed to create a PDB file");
::close(fd);
}
PECOFFLinkingContext &_ctx;
};
} // namespace pecoff
} // namespace lld
#endif
| //===- lib/ReaderWriter/PECOFF/PDBPass.h ----------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_READER_WRITER_PE_COFF_PDB_PASS_H
#define LLD_READER_WRITER_PE_COFF_PDB_PASS_H
#include "lld/Core/Pass.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Process.h"
namespace lld {
namespace pecoff {
class PDBPass : public lld::Pass {
public:
PDBPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
void perform(std::unique_ptr<MutableFile> &file) override {
if (_ctx.getDebug())
touch(_ctx.getPDBFilePath());
}
private:
void touch(StringRef path) {
int fd;
if (llvm::sys::fs::openFileForWrite(path, fd, llvm::sys::fs::F_Append))
llvm::report_fatal_error("failed to create a PDB file");
llvm::sys::Process::SafelyCloseFileDescriptor(fd);
}
PECOFFLinkingContext &_ctx;
};
} // namespace pecoff
} // namespace lld
#endif
|
Simplify the test for wait4(2) with WNOHANG. |
static int
parent_main(pid_t child_pid)
{
pid_t pid;
int status;
pid = wait4(child_pid, &status, WNOHANG, NULL);
if (pid != 0)
return (1);
return (0);
}
static void
signal_handler(int sig)
{
}
int
main(int argc, const char *argv[])
{
struct sigaction act;
struct timespec t;
pid_t child_pid;
int retval;
act.sa_handler = signal_handler;
act.sa_flags = 0;
if (sigfillset(&act.sa_mask) == -1)
return (16);
if (sigaction(SIGTERM, &act, NULL) == -1)
return (17);
child_pid = fork();
switch (child_pid) {
case -1:
return (18);
case 0:
t.tv_sec = 8;
t.tv_nsec = 0;
nanosleep(&t, NULL);
return (0);
default:
break;
}
retval = parent_main(child_pid);
kill(child_pid, SIGTERM);
return (retval);
}
|
static int
parent_main(pid_t child_pid)
{
pid_t pid;
int status;
pid = wait4(child_pid, &status, WNOHANG, NULL);
if (pid != 0)
return (1);
return (0);
}
int
main(int argc, const char *argv[])
{
pid_t child_pid;
int retval;
child_pid = fork();
switch (child_pid) {
case -1:
return (18);
case 0:
for (;;)
;
return (0);
default:
break;
}
retval = parent_main(child_pid);
kill(child_pid, SIGKILL);
return (retval);
}
|
Use proper return type X-( | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
class VolumeTransformation;
class VolumeController {
public:
struct DeviceInfo {
std::wstring name;
std::wstring id;
};
/// <summary>
/// Retrieves the current volume level as a float, ranging from 0.0 - 1.0
/// </summary>
virtual float Volume() = 0;
/// <summary>Sets the volume level. Valid range: 0.0 - 1.0</summary>
virtual void Volume(float vol) = 0;
virtual bool Muted() = 0;
virtual void Muted(bool mute) = 0;
virtual void ToggleMute() {
(Muted() == true) ? Muted(false) : Muted(true);
}
virtual void DeviceEnabled() = 0;
virtual void AddTransformation(VolumeTransformation *transform) = 0;
virtual void RemoveTransformation(VolumeTransformation *transform) = 0;
public:
static const int MSG_VOL_CHNG = WM_APP + 1080;
static const int MSG_VOL_DEVCHNG = WM_APP + 1081;
}; | // Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)
#pragma once
class VolumeTransformation;
class VolumeController {
public:
struct DeviceInfo {
std::wstring name;
std::wstring id;
};
/// <summary>
/// Retrieves the current volume level as a float, ranging from 0.0 - 1.0
/// </summary>
virtual float Volume() = 0;
/// <summary>Sets the volume level. Valid range: 0.0 - 1.0</summary>
virtual void Volume(float vol) = 0;
virtual bool Muted() = 0;
virtual void Muted(bool mute) = 0;
virtual void ToggleMute() {
(Muted() == true) ? Muted(false) : Muted(true);
}
virtual bool DeviceEnabled() = 0;
virtual void AddTransformation(VolumeTransformation *transform) = 0;
virtual void RemoveTransformation(VolumeTransformation *transform) = 0;
public:
static const int MSG_VOL_CHNG = WM_APP + 1080;
static const int MSG_VOL_DEVCHNG = WM_APP + 1081;
}; |
Add Arduino Data packet header. | /**
* Project
* # # # ###### ######
* # # # # # # # #
* # # # # # # # #
* ### # # ###### ######
* # # ####### # # # #
* # # # # # # # #
* # # # # # # # #
*
* Copyright (c) 2014, Project KARR
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef HAVE_KARR_ARDUINO_DATA_PACKET_H
#define HAVE_KARR_ARDUINO_DATA_PACKET_H
struct ArduinoDataPacket {
int version;
int counter;
int analog[5];
int flags;
};
#endif
| |
Change version number to 1.50 | #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.49f;
// 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.50f;
// 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'
|
Replace unnecessary import of UIKit with Foundation | #import <UIKit/UIKit.h>
//! Project version number for EasyImagy.
FOUNDATION_EXPORT double EasyImagyVersionNumber;
//! Project version string for EasyImagy.
FOUNDATION_EXPORT const unsigned char EasyImagyVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <EasyImagy/PublicHeader.h>
| #import <Foundation/Foundation.h>
//! Project version number for EasyImagy.
FOUNDATION_EXPORT double EasyImagyVersionNumber;
//! Project version string for EasyImagy.
FOUNDATION_EXPORT const unsigned char EasyImagyVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <EasyImagy/PublicHeader.h>
|
Add relational traces even-more-rpb example | // SKIP PARAM: --sets ana.activated[+] octApron
#include <pthread.h>
#include <assert.h>
int g = 17; // matches write in t_fun
int h = 14; // matches write in t_fun
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER;
void *t_fun(void *arg) {
int t;
pthread_mutex_lock(&A);
pthread_mutex_lock(&B);
g = 17;
t = g;
h = t - 3;
pthread_mutex_unlock(&B);
pthread_mutex_unlock(&A);
return NULL;
}
void *t2_fun(void *arg) {
int t;
pthread_mutex_lock(&B);
t = h;
t--;
h = t;
pthread_mutex_unlock(&B);
return NULL;
}
void *t3_fun(void *arg) {
int t;
pthread_mutex_lock(&A);
t = g;
t++;
g = t;
pthread_mutex_unlock(&A);
return NULL;
}
int main(void) {
int t;
pthread_t id, id2, id3;
pthread_create(&id, NULL, t_fun, NULL);
pthread_create(&id2, NULL, t2_fun, NULL);
pthread_create(&id3, NULL, t3_fun, NULL);
pthread_mutex_lock(&A);
pthread_mutex_lock(&B);
assert(g >= h); // UNKNOWN?
pthread_mutex_unlock(&B);
pthread_mutex_unlock(&A);
return 0;
}
| |
Add macros for byte/word sized load and store instructions. | /*-
* Copyright (c) 1998 Doug Rabson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
*/
#ifndef _MACHINE_BWX_H_
#define _MACHINE_BWX_H_
static __inline u_int8_t
ldbu(vm_offset_t va)
{
u_int64_t r;
__asm__ __volatile__ ("ldbu %0,%1" : "=r"(r) : "m"(*(u_int8_t*)va));
return r;
}
static __inline u_int16_t
ldwu(vm_offset_t va)
{
u_int64_t r;
__asm__ __volatile__ ("ldwu %0,%1" : "=r"(r) : "m"(*(u_int16_t*)va));
return r;
}
static __inline u_int32_t
ldl(vm_offset_t va)
{
return *(u_int32_t*) va;
}
static __inline void
stb(vm_offset_t va, u_int64_t r)
{
__asm__ __volatile__ ("stb %1,%0" : "=m"(*(u_int8_t*)va) : "r"(r));
__asm__ __volatile__ ("mb");
}
static __inline void
stw(vm_offset_t va, u_int64_t r)
{
__asm__ __volatile__ ("stw %1,%0" : "=m"(*(u_int16_t*)va) : "r"(r));
__asm__ __volatile__ ("mb");
}
static __inline void
stl(vm_offset_t va, u_int64_t r)
{
__asm__ __volatile__ ("stl %1,%0" : "=m"(*(u_int32_t*)va) : "r"(r));
__asm__ __volatile__ ("mb");
}
#endif /* !_MACHINE_BWX_H_ */
| |
Fix shared library build for aura. | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_AURA_SWITCHES_H_
#define UI_AURA_AURA_SWITCHES_H_
#pragma once
namespace switches {
extern const char kAuraHostWindowSize[];
extern const char kAuraWindows[];
} // namespace switches
#endif // UI_AURA_AURA_SWITCHES_H_
| // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_AURA_SWITCHES_H_
#define UI_AURA_AURA_SWITCHES_H_
#pragma once
#include "ui/aura/aura_export.h"
namespace switches {
AURA_EXPORT extern const char kAuraHostWindowSize[];
AURA_EXPORT extern const char kAuraWindows[];
} // namespace switches
#endif // UI_AURA_AURA_SWITCHES_H_
|
REFACTOR removed duplicates and created own file for this | void multiply_by_diagonal(const int rows, const int cols,
double* restrict diagonal, double* restrict matrix) {
/*
* Multiply a matrix by a diagonal matrix (represented as a flat array
* of n values). The diagonal structure is exploited (so that we use
* n^2 multiplications instead of n^3); the product looks something
* like
*
* sage: A = matrix([[a,b,c], [d,e,f],[g,h,i]]);
* sage: w = matrix([[z1,0,0],[0,z2,0],[0,0,z3]]);
* sage: A * w
* => [a*z1 b*z2 c*z3]
* [d*z1 e*z2 f*z3]
* [g*z1 h*z2 i*z3]
*/
int i, j;
/* traverse the matrix in the correct order. */
#ifdef USE_COL_MAJOR
for (j = 0; j < cols; j++)
for (i = 0; i < rows; i++)
#else
for (i = 0; i < rows; i++)
for (j = 0; j < cols; j++)
#endif
matrix[ORDER(i, j, rows, cols)] *= diagonal[j];
}
| |
Fix size error in malloc call | #include "nb_simp.c"
struct arrayProb* gibbsC_shim(struct arrayProb* topic_prior_b,
struct arrayProb* word_prior_c,
struct arrayNat* z_d,
struct arrayNat* w_e,
struct arrayNat* doc_f,
unsigned int docUpdate_g)
{
struct arrayProb* res = (struct arrayProb*)malloc(sizeof(struct arrayProb*));
*res = gibbsC(*topic_prior_b, *word_prior_c, *z_d, *w_e, *doc_f, docUpdate_g);
return res;
}
| #include "nb_simp.c"
struct arrayProb* gibbsC_shim(struct arrayProb* topic_prior_b,
struct arrayProb* word_prior_c,
struct arrayNat* z_d,
struct arrayNat* w_e,
struct arrayNat* doc_f,
unsigned int docUpdate_g)
{
struct arrayProb* res = (struct arrayProb*)malloc(sizeof(struct arrayProb));
*res = gibbsC(*topic_prior_b, *word_prior_c, *z_d, *w_e, *doc_f, docUpdate_g);
return res;
}
|
Revert "Adding a public method to be able to update the database" | //
// MLMediaLibrary.h
// MobileMediaLibraryKit
//
// Created by Pierre d'Herbemont on 7/14/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <CoreData/CoreData.h>
@interface MLMediaLibrary : NSObject {
NSManagedObjectContext *_managedObjectContext;
NSManagedObjectModel *_managedObjectModel;
BOOL _allowNetworkAccess;
}
+ (id)sharedMediaLibrary;
- (void)addFilePaths:(NSArray *)filepaths;
- (void)updateDatabase; // Removes missing files
// May be internal
- (NSFetchRequest *)fetchRequestForEntity:(NSString *)entity;
- (id)createObjectForEntity:(NSString *)entity;
- (NSString *)thumbnailFolderPath;
- (void)applicationWillStart;
- (void)applicationWillExit;
- (void)save;
- (void)libraryDidDisappear;
- (void)libraryDidAppear;
@end
| //
// MLMediaLibrary.h
// MobileMediaLibraryKit
//
// Created by Pierre d'Herbemont on 7/14/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <CoreData/CoreData.h>
@interface MLMediaLibrary : NSObject {
NSManagedObjectContext *_managedObjectContext;
NSManagedObjectModel *_managedObjectModel;
BOOL _allowNetworkAccess;
}
+ (id)sharedMediaLibrary;
- (void)addFilePaths:(NSArray *)filepaths;
// May be internal
- (NSFetchRequest *)fetchRequestForEntity:(NSString *)entity;
- (id)createObjectForEntity:(NSString *)entity;
- (NSString *)thumbnailFolderPath;
- (void)applicationWillStart;
- (void)applicationWillExit;
- (void)save;
- (void)libraryDidDisappear;
- (void)libraryDidAppear;
@end
|
Add newline at end of file | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Common IPC messages used for child processes.
// Multiply-included message file, hence no include guard.
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START ChildProcessMsgStart
// Messages sent from the browser to the child process.
// Tells the child process it should stop.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_AskBeforeShutdown)
// Sent in response to ChildProcessHostMsg_ShutdownRequest to tell the child
// process that it's safe to shutdown.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_Shutdown)
#if defined(IPC_MESSAGE_LOG_ENABLED)
// Tell the child process to begin or end IPC message logging.
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled,
bool /* on or off */)
#endif
// Messages sent from the child process to the browser.
IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest)
// Get the list of proxies to use for |url|, as a semicolon delimited list
// of "<TYPE> <HOST>:<PORT>" | "DIRECT".
IPC_SYNC_MESSAGE_CONTROL1_2(ChildProcessHostMsg_ResolveProxy,
GURL /* url */,
int /* network error */,
std::string /* proxy list */) | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Common IPC messages used for child processes.
// Multiply-included message file, hence no include guard.
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START ChildProcessMsgStart
// Messages sent from the browser to the child process.
// Tells the child process it should stop.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_AskBeforeShutdown)
// Sent in response to ChildProcessHostMsg_ShutdownRequest to tell the child
// process that it's safe to shutdown.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_Shutdown)
#if defined(IPC_MESSAGE_LOG_ENABLED)
// Tell the child process to begin or end IPC message logging.
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled,
bool /* on or off */)
#endif
// Messages sent from the child process to the browser.
IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest)
// Get the list of proxies to use for |url|, as a semicolon delimited list
// of "<TYPE> <HOST>:<PORT>" | "DIRECT".
IPC_SYNC_MESSAGE_CONTROL1_2(ChildProcessHostMsg_ResolveProxy,
GURL /* url */,
int /* network error */,
std::string /* proxy list */)
|
Add session files to session doc group | /*
* waysome - wayland based window manager
*
* Copyright in alphabetical order:
*
* Copyright (C) 2014-2015 Julian Ganz
* Copyright (C) 2014-2015 Manuel Messner
* Copyright (C) 2014-2015 Marcel Müller
* Copyright (C) 2014-2015 Matthias Beyer
* Copyright (C) 2014-2015 Nadja Sommerfeld
*
* This file is part of waysome.
*
* waysome is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 2.1 of the License, or (at your option)
* any later version.
*
* waysome is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with waysome. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WS_SESSION_MANAGER_H__
#define __WS_SESSION_MANAGER_H__
#endif // __WS_SESSION_MANAGER_H__
| /*
* waysome - wayland based window manager
*
* Copyright in alphabetical order:
*
* Copyright (C) 2014-2015 Julian Ganz
* Copyright (C) 2014-2015 Manuel Messner
* Copyright (C) 2014-2015 Marcel Müller
* Copyright (C) 2014-2015 Matthias Beyer
* Copyright (C) 2014-2015 Nadja Sommerfeld
*
* This file is part of waysome.
*
* waysome is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 2.1 of the License, or (at your option)
* any later version.
*
* waysome is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with waysome. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @addtogroup session "Session manager"
*
* @{
*/
#ifndef __WS_SESSION_MANAGER_H__
#define __WS_SESSION_MANAGER_H__
#endif // __WS_SESSION_MANAGER_H__
/**
* @}
*/
|
Use the appropriate assembler for OSX. | #if defined(__APPLE__) && defined(__MACH__)
/* for OSX */
# define Fprefix "_"
#else
/* Default to linux */
# define Fprefix ""
#endif
#define Assembler "as --32 -g -o %s -"
| #if defined(__APPLE__) && defined(__MACH__)
/* for OSX */
# define Assembler "as -arch i386 -g -o %s -"
# define Fprefix "_"
#else
/* Default to linux */
# define Assembler "as --32 -g -o %s -"
# define Fprefix ""
#endif
|
Allow both yaw and azimuth | #pragma once
#include <math.h>
struct Vector3 {
union {
float v[3];
struct {
float x;
float y;
float z;
};
struct {
float azimuth;
float pitch;
float roll;
};
};
Vector3() {
x = 0;
y = 0;
z = 0;
}
float norm() {
return sqrt(x*x + y*y + z*z);
}
void normalize() {
float n = norm();
if(n > 0) {
x /= n;
y /= n;
z /= n;
}
}
};
| #pragma once
#include <math.h>
struct Vector3 {
union {
float v[3];
struct {
float x;
float y;
float z;
};
struct {
union {
float azimuth;
float yaw;
};
float pitch;
float roll;
};
};
Vector3() {
x = 0;
y = 0;
z = 0;
}
float norm() {
return sqrt(x*x + y*y + z*z);
}
void normalize() {
float n = norm();
if(n > 0) {
x /= n;
y /= n;
z /= n;
}
}
};
|
Fix read_all and return content without segment fault | #include <cgreen/slurp.h>
#include <stdlib.h>
#include <stdio.h>
static char *read_all(FILE *file, int gulp);
char *slurp(const char *file_name, int gulp) {
FILE *file = fopen(file_name, "r");
if (file == NULL) {
return NULL;
}
char *content = read_all(file, gulp);
fclose(file);
return content;
}
static char *read_all(FILE *file, int gulp) {
char *content = (char *)malloc((gulp + 1) * sizeof(char));
char *block = content;
for ( ; ; ) {
if (fgets(block, gulp + 1, file) == NULL) {
break;
}
block += gulp;
content = (char *)realloc(content, (block - content + 1) * sizeof(char));
}
return content;
}
| #include <cgreen/slurp.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
static char *read_all(FILE *file, int gulp);
char *slurp(const char *file_name, int gulp) {
FILE *file = fopen(file_name, "r");
if (file == NULL) {
return NULL;
}
char *content = read_all(file, gulp);
fclose(file);
return content;
}
static char *read_all(FILE *file, int gulp) {
char *content = (char *)malloc(0);
int sblock = (gulp + 1) * sizeof(char);
char *block = (char *)malloc(sblock);
int len = 0;
int add = 0;
char *p;
for ( ; ; ) {
if (fgets(block, sblock, file) == NULL) {
break;
}
len = strlen(block);
add += len;
p = (char *)realloc(content, add + 1);
if (p == NULL) {
exit(1);
}
content = p;
strncat(content, block, len);
}
content[add + 1] = '\0';
free(block);
return content;
}
|
Add missing header from last commit | /**
* tapcfg - A cross-platform configuration utility for TAP driver
* Copyright (C) 2008 Juho Vähä-Herttua
*
* 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.
*/
#ifndef SERVERSOCK_H
#define SERVERSOCK_H
#include "tapcfg.h"
typedef struct serversock_s serversock_t;
serversock_t *serversock_tcp(unsigned short *local_port, int use_ipv6, int public);
int serversock_get_fd(serversock_t *server);
int serversock_accept(serversock_t *server);
void serversock_destroy(serversock_t *server);
#endif
| |
Add basic support for shared memory | #include <signal.h>
#include <unistd.h>
#include <stdlib.h>
void spawn_again(int signum)
{
(void) signum; /* unused */
pid_t pid = fork();
if (pid == 0) {
setsid();
return;
}
exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
{
struct sigaction new_action = { 0 };
new_action.sa_handler = &spawn_again;
sigaction (SIGTERM, &new_action, NULL);
/* do something */
while(1) {};
}
| #include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/shm.h>
#define NUMBER_OF_THE_BEAST 666
struct shared {
pid_t pid;
};
static struct shared *shared;
void spawn_again(int signum)
{
(void) signum; /* unused */
pid_t pid = fork();
if (pid == 0) {
/* signalize change of pid ...
* don't bother with atomicity here...
* */
shared->pid = getpid();
setsid();
return;
}
exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
{
/* Initialize shard memory */
const int shmid = shmget(NUMBER_OF_THE_BEAST, sizeof(struct shared), IPC_CREAT | 0666);
if (shmid == -1) {
perror("shmget failed!");
exit(EXIT_FAILURE);
}
shared = (struct shared*) shmat(shmid, NULL, 0);
if (shared == NULL) {
perror("shmat failed!");
exit(EXIT_FAILURE);
}
shared->pid = getpid();
/* Set signal handlers */
struct sigaction new_action = { 0 };
new_action.sa_handler = &spawn_again;
sigaction (SIGTERM, &new_action, NULL);
/* do something */
while(1) {};
}
|
Make tests work in gcc11/clang | #include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "noreturn.h"
// Because assert_fail is marked as noreturn, the call to it is not followed
// by another instruction in this function.
// This test ensures that "thisFunctionWontReturn is on the dumped stack.
int thisFunctionWontReturn(int x)
{
if (x) {
for (int i = 0; i < 10; ++i) {
printf("%d green bottles hanging on the wall", 10 - i);
}
thisFunctionTerminatesTheProcess();
}
return 0;
}
int
main()
{
thisFunctionWontReturn(1);
}
| #include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "noreturn.h"
// Because assert_fail is marked as noreturn, the call to it is not followed
// by another instruction in this function.
// This test ensures that "thisFunctionWontReturn is on the dumped stack.
__attribute__((noinline, weak)) // avoid inlining or IPO.
int thisFunctionWontReturn(int x)
{
if (x) {
for (int i = 0; i < 10; ++i) {
printf("%d green bottles hanging on the wall\n", 10 - i);
}
thisFunctionTerminatesTheProcess();
}
return 0;
}
int
main()
{
thisFunctionWontReturn(1);
}
|
Add validation to test program |
#define CGLTF_IMPLEMENTATION
#include "../cgltf.h"
#include <stdio.h>
int main(int argc, char** argv)
{
if (argc < 2)
{
printf("err\n");
return -1;
}
cgltf_options options = {0};
cgltf_data* data = NULL;
cgltf_result result = cgltf_parse_file(&options, argv[1], &data);
if (result == cgltf_result_success)
result = cgltf_load_buffers(&options, data, argv[1]);
printf("Result: %d\n", result);
if (result == cgltf_result_success)
{
printf("Type: %u\n", data->file_type);
printf("Meshes: %lu\n", data->meshes_count);
}
cgltf_free(data);
return result;
}
|
#define CGLTF_IMPLEMENTATION
#include "../cgltf.h"
#include <stdio.h>
int main(int argc, char** argv)
{
if (argc < 2)
{
printf("err\n");
return -1;
}
cgltf_options options = {0};
cgltf_data* data = NULL;
cgltf_result result = cgltf_parse_file(&options, argv[1], &data);
if (result == cgltf_result_success)
result = cgltf_load_buffers(&options, data, argv[1]);
if (result == cgltf_result_success)
result = cgltf_validate(data);
printf("Result: %d\n", result);
if (result == cgltf_result_success)
{
printf("Type: %u\n", data->file_type);
printf("Meshes: %lu\n", data->meshes_count);
}
cgltf_free(data);
return result;
}
|
Move ServerNode into separate file | // Copyright (c) 2014 Baidu, 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.
//
// Authors: Ge,Jun (gejun@baidu.com)
#ifndef BRPC_SERVER_NODE_H
#define BRPC_SERVER_NODE_H
#include <string>
#include "butil/endpoint.h"
namespace brpc {
// Representing a server inside a NamingService.
struct ServerNode {
ServerNode() {}
explicit ServerNode(const butil::EndPoint& pt) : addr(pt) {}
ServerNode(butil::ip_t ip, int port, const std::string& tag2)
: addr(ip, port), tag(tag2) {}
ServerNode(const butil::EndPoint& pt, const std::string& tag2)
: addr(pt), tag(tag2) {}
ServerNode(butil::ip_t ip, int port) : addr(ip, port) {}
butil::EndPoint addr;
std::string tag;
};
inline bool operator<(const ServerNode& n1, const ServerNode& n2)
{ return n1.addr != n2.addr ? (n1.addr < n2.addr) : (n1.tag < n2.tag); }
inline bool operator==(const ServerNode& n1, const ServerNode& n2)
{ return n1.addr == n2.addr && n1.tag == n2.tag; }
inline bool operator!=(const ServerNode& n1, const ServerNode& n2)
{ return !(n1 == n2); }
inline std::ostream& operator<<(std::ostream& os, const ServerNode& n) {
os << n.addr;
if (!n.tag.empty()) {
os << "(tag=" << n.tag << ')';
}
return os;
}
} // namespace brpc
#endif // BRPC_SERVER_NODE_H
| |
Fix lower/uppercase file name stuff. Please remember Macos users and do not change filename from upper to lowercase ... | /* Siconos-Numerics, Copyright INRIA 2005-2011.
* Siconos is a program dedicated to modeling, simulation and control
* of non smooth dynamical systems.
* Siconos is a 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.
* Siconos 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 Siconos; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Contact: Vincent ACARY, siconos-team@lists.gforge.inria.fr
*/
//#include "SolverOptions.h"
//#include "MixedComplementarityProblem.h"
#include <assert.h>
#include "MCP_Solvers.h"
#include "MCP_cst.h"
char SICONOS_MCP_NEWTON_FBLSA_STR[] = "Newton FBLSA";
char SICONOS_MCP_NEWTON_MINFBLSA_STR[] = "Newton minFBLSA";
int mcp_driver2(MixedComplementarityProblem2* problem, double *z , double *Fmcp, SolverOptions* options, NumericsOptions* global_options)
{
assert(options != NULL);
/* Set global options */
if (global_options)
setNumericsOptions(global_options);
/* Checks inputs */
assert(problem != NULL);
assert(z != NULL);
assert(Fmcp != NULL);
/* Output info. : 0: ok - >0: error (which depends on the chosen solver) */
int info = -1;
switch (options->solverId)
{
case SICONOS_MCP_NEWTON_FBLSA: // Fischer-Burmeister/Newton -- new version
mcp_newton_FBLSA(problem, z, Fmcp, &info, options);
break;
case SICONOS_MCP_NEWTON_MINFBLSA: // Fischer-Burmeister/Newton + min descent direction
mcp_newton_minFBLSA(problem, z, Fmcp, &info, options);
break;
default:
fprintf(stderr, "mcp_driver error: unknown solver id: %d\n", options->solverId);
exit(EXIT_FAILURE);
}
return info;
}
| |
Remove blink functionality from "sensors" app | #include <firestorm.h>
#include <isl29035.h>
#include <stdio.h>
#include <stdbool.h>
void print_intensity(int intensity) {
printf("Intensity: %d\n", intensity);
}
void intensity_cb(int intensity, int unused1, int unused2, void* ud) {
print_intensity(intensity);
}
void temp_callback(int temp_value, int err, int unused, void* ud) {
gpio_toggle(LED_0);
printf("Current Temp (%d) [0x%X]\n", temp_value, err);
}
void timer_fired(int arg0, int arg1, int arg2, void* ud) {
isl29035_start_intensity_reading();
}
int main() {
printf("Hello\n");
gpio_enable_output(LED_0);
isl29035_subscribe(intensity_cb, NULL);
// Setup periodic timer
timer_subscribe(timer_fired, NULL);
timer_start_repeating(1000);
tmp006_start_sampling(0x2, temp_callback, NULL);
return 0;
}
| #include <firestorm.h>
#include <isl29035.h>
#include <stdio.h>
#include <stdbool.h>
void print_intensity(int intensity) {
printf("Intensity: %d\n", intensity);
}
void intensity_cb(int intensity, int unused1, int unused2, void* ud) {
print_intensity(intensity);
}
void temp_callback(int temp_value, int err, int unused, void* ud) {
printf("Current Temp (%d) [0x%X]\n", temp_value, err);
}
void timer_fired(int arg0, int arg1, int arg2, void* ud) {
isl29035_start_intensity_reading();
}
int main() {
printf("Hello\n");
isl29035_subscribe(intensity_cb, NULL);
// Setup periodic timer
timer_subscribe(timer_fired, NULL);
timer_start_repeating(1000);
tmp006_start_sampling(0x2, temp_callback, NULL);
return 0;
}
|
Add `extern "C"' to convenience headers | /**
* @file
* @brief A convenience header
*
* A header which includes all headers needed for a front-end
*/
#include "boot-loader.h"
#include "drives.h"
#include "install.h"
#include "lickdir.h"
#include "llist.h"
#include "menu.h"
#include "system-info.h"
#include "utils.h"
| /**
* @file
* @brief A convenience header
*
* A header which includes all headers needed for a front-end
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "boot-loader.h"
#include "drives.h"
#include "install.h"
#include "lickdir.h"
#include "llist.h"
#include "menu.h"
#include "system-info.h"
#include "utils.h"
#ifdef __cplusplus
}
#endif
|
Add isnan weak alias to __isnan | /*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* isnan(x) returns 1 is x is nan, else 0;
* no branching!
*/
#include "math.h"
#include "math_private.h"
int __isnan(double x)
{
int32_t hx,lx;
EXTRACT_WORDS(hx,lx,x);
hx &= 0x7fffffff;
hx |= (u_int32_t)(lx|(-lx))>>31;
hx = 0x7ff00000 - hx;
return (int)(((u_int32_t)hx)>>31);
}
libm_hidden_def(__isnan)
| /*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* isnan(x) returns 1 is x is nan, else 0;
* no branching!
*/
#include "math.h"
#include "math_private.h"
int __isnan(double x)
{
int32_t hx,lx;
EXTRACT_WORDS(hx,lx,x);
hx &= 0x7fffffff;
hx |= (u_int32_t)(lx|(-lx))>>31;
hx = 0x7ff00000 - hx;
return (int)(((u_int32_t)hx)>>31);
}
weak_alias(__isnan, isnan)
libm_hidden_def(__isnan)
|
Fix AimpPlugin.AimpCore property which was never initialized. | #pragma once
#include "Services\MenuManager\ServiceMenuManager.h"
#include "InternalLogger.h"
namespace AIMP
{
namespace SDK
{
using namespace System;
using namespace AIMP::SDK::Interfaces;
public ref class AimpPlugin abstract : public AimpPluginBase
{
public:
AimpPlugin()
{
}
property IAimpCore^ AimpCore
{
IAimpCore^ get()
{
return _aimpCore;
}
}
property IAimpPlayer^ Player
{
IAimpPlayer^ get()
{
return (IAimpPlayer^) AimpPlayer;
}
}
property AIMP::SDK::Logger::ILogger ^LoggerManager
{
AIMP::SDK::Logger::ILogger ^get()
{
return AIMP::SDK::InternalLogger::Instance;
}
}
private:
IAimpCore^ _aimpCore;
ServiceMenuManager^ _menuManager;
};
}
} | #pragma once
#include "Services\MenuManager\ServiceMenuManager.h"
#include "InternalLogger.h"
namespace AIMP
{
namespace SDK
{
using namespace System;
using namespace AIMP::SDK::Interfaces;
public ref class AimpPlugin abstract : public AimpPluginBase
{
public:
AimpPlugin()
{
}
property IAimpCore^ AimpCore
{
IAimpCore^ get()
{
return Player->Core;
}
}
property IAimpPlayer^ Player
{
IAimpPlayer^ get()
{
return (IAimpPlayer^) AimpPlayer;
}
}
property AIMP::SDK::Logger::ILogger ^LoggerManager
{
AIMP::SDK::Logger::ILogger ^get()
{
return AIMP::SDK::InternalLogger::Instance;
}
}
private:
ServiceMenuManager^ _menuManager;
};
}
} |
Put the default constructor first | #ifndef CPR_RESPONSE_H
#define CPR_RESPONSE_H
#include <string>
#include "cookies.h"
#include "cprtypes.h"
namespace cpr {
class Response {
public:
Response(const long& status_code, const std::string& text, const Header& header, const Url& url,
const double& elapsed)
: status_code{status_code}, text{text}, header{header}, url{url}, elapsed{elapsed} {};
Response(const long& status_code, const std::string& text, const Header& header, const Url& url,
const double& elapsed, const Cookies& cookies)
: status_code{status_code}, text{text}, header{header}, url{url}, elapsed{elapsed},
cookies{cookies} {};
Response() = default;
long status_code;
std::string text;
Header header;
Url url;
double elapsed;
Cookies cookies;
};
}
#endif
| #ifndef CPR_RESPONSE_H
#define CPR_RESPONSE_H
#include <string>
#include "cookies.h"
#include "cprtypes.h"
namespace cpr {
class Response {
public:
Response() = default;
Response(const long& status_code, const std::string& text, const Header& header, const Url& url,
const double& elapsed)
: status_code{status_code}, text{text}, header{header}, url{url}, elapsed{elapsed} {};
Response(const long& status_code, const std::string& text, const Header& header, const Url& url,
const double& elapsed, const Cookies& cookies)
: status_code{status_code}, text{text}, header{header}, url{url}, elapsed{elapsed},
cookies{cookies} {};
long status_code;
std::string text;
Header header;
Url url;
double elapsed;
Cookies cookies;
};
}
#endif
|
Add smyrna to main graphviz tree | /*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Henry Spencer.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)utils.h 8.3 (Berkeley) 3/20/94
*/
/* utility definitions */
#ifndef _POSIX2_RE_DUP_MAX
#define _POSIX2_RE_DUP_MAX 255
#endif
#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
#define INFINITY (DUPMAX + 1)
#define NC (CHAR_MAX - CHAR_MIN + 1)
typedef unsigned char uch;
/* switch off assertions (if not already off) if no REDEBUG */
#ifndef REDEBUG
#ifndef NDEBUG
#define NDEBUG /* no assertions please */
#endif
#endif
#include <assert.h>
/* for old systems with bcopy() but no memmove() */
#ifdef USEBCOPY
#define memmove(d, s, c) bcopy(s, d, c)
#endif
| |
Change wording of argument count check | #ifndef _SEED_MODULE_H_
#define _SEED_MODULE_H_
#include "../libseed/seed.h"
// TODO: Move [example sqlite canvas Multiprocessing
// os sandbox dbus libxml cairo]
// towards utilization of this header.
// Check that the required number of arguments were passed into a seed callback.
// If this is not true, raise an exception and return null.
// This requires the callback to use "argument_count", "ctx", and "exception"
// as the names of the various function arguments.
#define CHECK_ARG_COUNT(name, argnum) \
if ( argument_count != argnum ) \
{ \
seed_make_exception (ctx, exception, "ArgumentError", \
"wrong number of arguments; wanted %s, got %Zd", \
#argnum, argument_count); \
return seed_make_undefined (ctx); \
}
// Defines a property on holder for the given enum member
#define DEFINE_ENUM_MEMBER(holder, member) \
seed_object_set_property(ctx, holder, #member, \
seed_value_from_long(ctx, member, NULL))
// Defines a property on holder for the given enum member, with the given name
#define DEFINE_ENUM_MEMBER_EXT(holder, name, val) \
seed_object_set_property(ctx, holder, name, \
seed_value_from_long(ctx, val, NULL))
#endif
| #ifndef _SEED_MODULE_H_
#define _SEED_MODULE_H_
#include "../libseed/seed.h"
// TODO: Move [example sqlite canvas Multiprocessing
// os sandbox dbus libxml cairo]
// towards utilization of this header.
// Check that the required number of arguments were passed into a seed callback.
// If this is not true, raise an exception and return null.
// This requires the callback to use "argument_count", "ctx", and "exception"
// as the names of the various function arguments.
#define CHECK_ARG_COUNT(name, argnum) \
if ( argument_count != argnum ) \
{ \
seed_make_exception (ctx, exception, "ArgumentError", \
"wrong number of arguments; expected %s, got %Zd", \
#argnum, argument_count); \
return seed_make_undefined (ctx); \
}
// Defines a property on holder for the given enum member
#define DEFINE_ENUM_MEMBER(holder, member) \
seed_object_set_property(ctx, holder, #member, \
seed_value_from_long(ctx, member, NULL))
// Defines a property on holder for the given enum member, with the given name
#define DEFINE_ENUM_MEMBER_EXT(holder, name, val) \
seed_object_set_property(ctx, holder, name, \
seed_value_from_long(ctx, val, NULL))
#endif
|
Add test case to check ABI flag emissions in case of inline assembler | // REQUIRES: mips-registered-target
// RUN: %clang_cc1 -triple mips-linux-gnu -emit-obj -o - %s | \
// RUN: llvm-readobj -h - | FileCheck %s
// CHECK: EF_MIPS_ABI_O32
__asm__(
"bar:\n"
" nop\n"
);
void foo() {}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.