hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588 values | lang stringclasses 305 values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ca30142bad58cc55a017268ae53683a53580808d | 2,253 | h | C | src/compiler/descriptor.h | CoinXu/reviser-compiler | 1296cf5f8c01bbc4963a2b29bd6d62a25f0e54af | [
"MIT"
] | 1 | 2020-04-24T02:59:51.000Z | 2020-04-24T02:59:51.000Z | src/compiler/descriptor.h | CoinXu/reviser-compiler | 1296cf5f8c01bbc4963a2b29bd6d62a25f0e54af | [
"MIT"
] | null | null | null | src/compiler/descriptor.h | CoinXu/reviser-compiler | 1296cf5f8c01bbc4963a2b29bd6d62a25f0e54af | [
"MIT"
] | null | null | null | //
// @date 2020-06-23
// @author duanxian0605@163.com
// @description 定义.reviser文件内容标记,词法定义参考syntax.md
//
#ifndef REVISER_COMPILER_DESCRIPTOR
#define REVISER_COMPILER_DESCRIPTOR
#include <string>
#include <stack>
#include <tokenizer.h>
#include <ast/stmt_enum.h>
#include <ast/stmt_struct.h>
using namespace reviser::ast;
using namespace std;
namespace reviser {
namespace compiler {
enum DeclareType {
DECLARE_ENUM,
DECLARE_STRUCT,
DECLARE_UNDEFINED
};
class Descriptor {
public:
struct VariableDeclare {
string id;
DeclareType type;
};
union VariableAst {
Enum* e;
Struct* s;
};
struct ContextVariable {
string id;
DeclareType type;
VariableAst node;
};
private:
vector<string> decorators_;
vector<VariableDeclare> global_variables_;
vector<DataType> data_types_;
public:
// 使用一个二维数组来存储作用域与作用域已声明的变量
// 其中,一维元素代表一个作用域
// 二维元素存储该作用域声明的变量
vector<vector<ContextVariable>> context;
bool include_type_array = false;
bool include_struct_array = false;
bool include_enum_array = false;
// 压入一个新的上下文,添加一个新的数组到context中
void PushNewContext();
// 退出当前上下文,删除context最后一个数组
void PopBackContext();
// 在当前上下文中添Enum声明
void PushContextVariable(Enum*);
// 在当前上下文中添Struct声明
void PushContextVariable(Struct*);
// 作用域内通过id找已定义的声明,从当前开始一直找到最顶层
ContextVariable* FindContextVariableById(string);
// 当前作用域内通过id找已定义的声明,只找一层
ContextVariable* FindCurrentContextVariableById(string);
// 查找在当前作用域有效的声明的类型,从低往上找,以第一个找到的声明为准
DeclareType FindContextVariableTypeById(string);
// 通过id在作用域内找Enum声明
Enum* FindEnumContextVariableById(string);
// Enum是否已声明string标记的属性
bool EnumInlcudeProperty(Enum*, string);
// 同enum
Struct* FindStructContextVariableById(string);
bool StructIncludeProperty(Struct*, string);
vector<string> Decorators();
vector<VariableDeclare> GlobalVariables();
vector<DataType> DataTypes();
void AddDataTypesOnce(DataType type);
void AddDecoratorOnce(string decorator);
void AddGlobalVariableOnce(string variable, DeclareType type);
Descriptor();
~Descriptor();
};
}; // reviser
}; // compiler
#endif
| 22.757576 | 66 | 0.709277 |
ca39a5e35a4fb7d22a75c7958be0e86fdfcb6ee9 | 30,940 | c | C | linux/d4ebc877b1223f20d5a0.c | zsm-oss/syzkaller-repros | b18de420311083a419293a07e07e121fe8150ceb | [
"Apache-2.0"
] | 32 | 2019-10-08T11:22:21.000Z | 2022-03-31T14:11:28.000Z | linux/d4ebc877b1223f20d5a0.c | zsm-oss/syzkaller-repros | b18de420311083a419293a07e07e121fe8150ceb | [
"Apache-2.0"
] | 3 | 2020-02-07T12:06:43.000Z | 2020-11-30T07:42:32.000Z | linux/d4ebc877b1223f20d5a0.c | zsm-oss/syzkaller-repros | b18de420311083a419293a07e07e121fe8150ceb | [
"Apache-2.0"
] | 10 | 2019-10-12T13:05:54.000Z | 2021-10-24T01:05:41.000Z | // WARNING in go7007_usb_onboard_write_interrupt/usb_submit_urb
// https://syzkaller.appspot.com/bug?id=d4ebc877b1223f20d5a0
// status:0
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
static uint64_t current_time_ms(void)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
exit(1);
return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
#define MAX_FDS 30
#define USB_MAX_IFACE_NUM 4
#define USB_MAX_EP_NUM 32
#define USB_MAX_FDS 6
struct usb_endpoint_index {
struct usb_endpoint_descriptor desc;
int handle;
};
struct usb_iface_index {
struct usb_interface_descriptor* iface;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bInterfaceClass;
struct usb_endpoint_index eps[USB_MAX_EP_NUM];
int eps_num;
};
struct usb_device_index {
struct usb_device_descriptor* dev;
struct usb_config_descriptor* config;
uint8_t bDeviceClass;
uint8_t bMaxPower;
int config_length;
struct usb_iface_index ifaces[USB_MAX_IFACE_NUM];
int ifaces_num;
int iface_cur;
};
struct usb_info {
int fd;
struct usb_device_index index;
};
static struct usb_info usb_devices[USB_MAX_FDS];
static int usb_devices_num;
static bool parse_usb_descriptor(const char* buffer, size_t length,
struct usb_device_index* index)
{
if (length < sizeof(*index->dev) + sizeof(*index->config))
return false;
memset(index, 0, sizeof(*index));
index->dev = (struct usb_device_descriptor*)buffer;
index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev));
index->bDeviceClass = index->dev->bDeviceClass;
index->bMaxPower = index->config->bMaxPower;
index->config_length = length - sizeof(*index->dev);
index->iface_cur = -1;
size_t offset = 0;
while (true) {
if (offset + 1 >= length)
break;
uint8_t desc_length = buffer[offset];
uint8_t desc_type = buffer[offset + 1];
if (desc_length <= 2)
break;
if (offset + desc_length > length)
break;
if (desc_type == USB_DT_INTERFACE &&
index->ifaces_num < USB_MAX_IFACE_NUM) {
struct usb_interface_descriptor* iface =
(struct usb_interface_descriptor*)(buffer + offset);
index->ifaces[index->ifaces_num].iface = iface;
index->ifaces[index->ifaces_num].bInterfaceNumber =
iface->bInterfaceNumber;
index->ifaces[index->ifaces_num].bAlternateSetting =
iface->bAlternateSetting;
index->ifaces[index->ifaces_num].bInterfaceClass = iface->bInterfaceClass;
index->ifaces_num++;
}
if (desc_type == USB_DT_ENDPOINT && index->ifaces_num > 0) {
struct usb_iface_index* iface = &index->ifaces[index->ifaces_num - 1];
if (iface->eps_num < USB_MAX_EP_NUM) {
memcpy(&iface->eps[iface->eps_num].desc, buffer + offset,
sizeof(iface->eps[iface->eps_num].desc));
iface->eps_num++;
}
}
offset += desc_length;
}
return true;
}
static struct usb_device_index* add_usb_index(int fd, const char* dev,
size_t dev_len)
{
int i = __atomic_fetch_add(&usb_devices_num, 1, __ATOMIC_RELAXED);
if (i >= USB_MAX_FDS)
return NULL;
if (!parse_usb_descriptor(dev, dev_len, &usb_devices[i].index))
return NULL;
__atomic_store_n(&usb_devices[i].fd, fd, __ATOMIC_RELEASE);
return &usb_devices[i].index;
}
static struct usb_device_index* lookup_usb_index(int fd)
{
for (int i = 0; i < USB_MAX_FDS; i++) {
if (__atomic_load_n(&usb_devices[i].fd, __ATOMIC_ACQUIRE) == fd) {
return &usb_devices[i].index;
}
}
return NULL;
}
struct vusb_connect_string_descriptor {
uint32_t len;
char* str;
} __attribute__((packed));
struct vusb_connect_descriptors {
uint32_t qual_len;
char* qual;
uint32_t bos_len;
char* bos;
uint32_t strs_len;
struct vusb_connect_string_descriptor strs[0];
} __attribute__((packed));
static const char default_string[] = {8, USB_DT_STRING, 's', 0, 'y', 0, 'z', 0};
static const char default_lang_id[] = {4, USB_DT_STRING, 0x09, 0x04};
static bool
lookup_connect_response_in(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl,
char** response_data, uint32_t* response_length)
{
struct usb_device_index* index = lookup_usb_index(fd);
uint8_t str_idx;
if (!index)
return false;
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_GET_DESCRIPTOR:
switch (ctrl->wValue >> 8) {
case USB_DT_DEVICE:
*response_data = (char*)index->dev;
*response_length = sizeof(*index->dev);
return true;
case USB_DT_CONFIG:
*response_data = (char*)index->config;
*response_length = index->config_length;
return true;
case USB_DT_STRING:
str_idx = (uint8_t)ctrl->wValue;
if (descs && str_idx < descs->strs_len) {
*response_data = descs->strs[str_idx].str;
*response_length = descs->strs[str_idx].len;
return true;
}
if (str_idx == 0) {
*response_data = (char*)&default_lang_id[0];
*response_length = default_lang_id[0];
return true;
}
*response_data = (char*)&default_string[0];
*response_length = default_string[0];
return true;
case USB_DT_BOS:
*response_data = descs->bos;
*response_length = descs->bos_len;
return true;
case USB_DT_DEVICE_QUALIFIER:
if (!descs->qual) {
struct usb_qualifier_descriptor* qual =
(struct usb_qualifier_descriptor*)response_data;
qual->bLength = sizeof(*qual);
qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER;
qual->bcdUSB = index->dev->bcdUSB;
qual->bDeviceClass = index->dev->bDeviceClass;
qual->bDeviceSubClass = index->dev->bDeviceSubClass;
qual->bDeviceProtocol = index->dev->bDeviceProtocol;
qual->bMaxPacketSize0 = index->dev->bMaxPacketSize0;
qual->bNumConfigurations = index->dev->bNumConfigurations;
qual->bRESERVED = 0;
*response_length = sizeof(*qual);
return true;
}
*response_data = descs->qual;
*response_length = descs->qual_len;
return true;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return false;
}
typedef bool (*lookup_connect_out_response_t)(
int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done);
static bool lookup_connect_response_out_generic(
int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done)
{
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_SET_CONFIGURATION:
*done = true;
return true;
default:
break;
}
break;
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver,
const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
static void set_interface(int fd, int n)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return;
if (index->iface_cur >= 0 && index->iface_cur < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++) {
int rv = usb_raw_ep_disable(
fd, index->ifaces[index->iface_cur].eps[ep].handle);
if (rv < 0) {
} else {
}
}
}
if (n >= 0 && n < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[n].eps_num; ep++) {
int rv = usb_raw_ep_enable(fd, &index->ifaces[n].eps[ep].desc);
if (rv < 0) {
} else {
index->ifaces[n].eps[ep].handle = rv;
}
}
index->iface_cur = n;
}
}
static int configure_device(int fd)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
int rv = usb_raw_vbus_draw(fd, index->bMaxPower);
if (rv < 0) {
return rv;
}
rv = usb_raw_configure(fd);
if (rv < 0) {
return rv;
}
set_interface(fd, 0);
return 0;
}
#define USB_MAX_PACKET_SIZE 4096
struct usb_raw_control_event {
struct usb_raw_event inner;
struct usb_ctrlrequest ctrl;
char data[USB_MAX_PACKET_SIZE];
};
struct usb_raw_ep_io_data {
struct usb_raw_ep_io inner;
char data[USB_MAX_PACKET_SIZE];
};
static volatile long
syz_usb_connect_impl(uint64_t speed, uint64_t dev_len, const char* dev,
const struct vusb_connect_descriptors* descs,
lookup_connect_out_response_t lookup_connect_response_out)
{
if (!dev) {
return -1;
}
int fd = usb_raw_open();
if (fd < 0) {
return fd;
}
if (fd >= MAX_FDS) {
close(fd);
return -1;
}
struct usb_device_index* index = add_usb_index(fd, dev, dev_len);
if (!index) {
return -1;
}
char device[32];
sprintf(&device[0], "dummy_udc.%llu", procid);
int rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
if (rv < 0) {
return rv;
}
rv = usb_raw_run(fd);
if (rv < 0) {
return rv;
}
bool done = false;
while (!done) {
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = sizeof(event.ctrl);
rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL)
continue;
char* response_data = NULL;
uint32_t response_length = 0;
if (event.ctrl.bRequestType & USB_DIR_IN) {
if (!lookup_connect_response_in(fd, descs, &event.ctrl, &response_data,
&response_length)) {
usb_raw_ep0_stall(fd);
continue;
}
} else {
if (!lookup_connect_response_out(fd, descs, &event.ctrl, &done)) {
usb_raw_ep0_stall(fd);
continue;
}
response_data = NULL;
response_length = event.ctrl.wLength;
}
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD &&
event.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) {
rv = configure_device(fd);
if (rv < 0) {
return rv;
}
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if (event.ctrl.bRequestType & USB_DIR_IN) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
}
sleep_ms(200);
return fd;
}
static volatile long syz_usb_connect(volatile long a0, volatile long a1,
volatile long a2, volatile long a3)
{
uint64_t speed = a0;
uint64_t dev_len = a1;
const char* dev = (const char*)a2;
const struct vusb_connect_descriptors* descs =
(const struct vusb_connect_descriptors*)a3;
return syz_usb_connect_impl(speed, dev_len, dev, descs,
&lookup_connect_response_out_generic);
}
static void kill_and_wait(int pid, int* status)
{
kill(-pid, SIGKILL);
kill(pid, SIGKILL);
for (int i = 0; i < 100; i++) {
if (waitpid(-1, status, WNOHANG | __WALL) == pid)
return;
usleep(1000);
}
DIR* dir = opendir("/sys/fs/fuse/connections");
if (dir) {
for (;;) {
struct dirent* ent = readdir(dir);
if (!ent)
break;
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
continue;
char abort[300];
snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
ent->d_name);
int fd = open(abort, O_WRONLY);
if (fd == -1) {
continue;
}
if (write(fd, abort, 1) < 0) {
}
close(fd);
}
closedir(dir);
} else {
}
while (waitpid(-1, status, __WALL) != pid) {
}
}
static void setup_test()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
write_file("/proc/self/oom_score_adj", "1000");
}
static void execute_one(void);
#define WAIT_FLAGS __WALL
static void loop(void)
{
int iter = 0;
for (;; iter++) {
int pid = fork();
if (pid < 0)
exit(1);
if (pid == 0) {
setup_test();
execute_one();
exit(0);
}
int status = 0;
uint64_t start = current_time_ms();
for (;;) {
if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
break;
sleep_ms(1);
if (current_time_ms() - start < 5000) {
continue;
}
kill_and_wait(pid, &status);
break;
}
}
}
void execute_one(void)
{
*(uint8_t*)0x20000200 = 0x12;
*(uint8_t*)0x20000201 = 1;
*(uint16_t*)0x20000202 = 0x310;
*(uint8_t*)0x20000204 = 0xb2;
*(uint8_t*)0x20000205 = 0xfd;
*(uint8_t*)0x20000206 = 0xa1;
*(uint8_t*)0x20000207 = 0x20;
*(uint16_t*)0x20000208 = 0xeb1;
*(uint16_t*)0x2000020a = 0x7007;
*(uint16_t*)0x2000020c = 0x205;
*(uint8_t*)0x2000020e = 1;
*(uint8_t*)0x2000020f = 2;
*(uint8_t*)0x20000210 = 3;
*(uint8_t*)0x20000211 = 1;
*(uint8_t*)0x20000212 = 9;
*(uint8_t*)0x20000213 = 2;
*(uint16_t*)0x20000214 = 0x1d9;
*(uint8_t*)0x20000216 = 3;
*(uint8_t*)0x20000217 = 0;
*(uint8_t*)0x20000218 = 0;
*(uint8_t*)0x20000219 = 0;
*(uint8_t*)0x2000021a = 0;
*(uint8_t*)0x2000021b = 9;
*(uint8_t*)0x2000021c = 4;
*(uint8_t*)0x2000021d = 0xc9;
*(uint8_t*)0x2000021e = 8;
*(uint8_t*)0x2000021f = 9;
*(uint8_t*)0x20000220 = -1;
*(uint8_t*)0x20000221 = 0;
*(uint8_t*)0x20000222 = -1;
*(uint8_t*)0x20000223 = -1;
*(uint8_t*)0x20000224 = 9;
*(uint8_t*)0x20000225 = 5;
*(uint8_t*)0x20000226 = 0xd;
*(uint8_t*)0x20000227 = 0;
*(uint16_t*)0x20000228 = 0x40;
*(uint8_t*)0x2000022a = 0;
*(uint8_t*)0x2000022b = 7;
*(uint8_t*)0x2000022c = 0x40;
*(uint8_t*)0x2000022d = 7;
*(uint8_t*)0x2000022e = 0x25;
*(uint8_t*)0x2000022f = 1;
*(uint8_t*)0x20000230 = 0x81;
*(uint8_t*)0x20000231 = 8;
*(uint16_t*)0x20000232 = 8;
*(uint8_t*)0x20000234 = 9;
*(uint8_t*)0x20000235 = 5;
*(uint8_t*)0x20000236 = 0;
*(uint8_t*)0x20000237 = 0;
*(uint16_t*)0x20000238 = 0x3ff;
*(uint8_t*)0x2000023a = 0x3f;
*(uint8_t*)0x2000023b = 0xbc;
*(uint8_t*)0x2000023c = 7;
*(uint8_t*)0x2000023d = 9;
*(uint8_t*)0x2000023e = 5;
*(uint8_t*)0x2000023f = 8;
*(uint8_t*)0x20000240 = 0x10;
*(uint16_t*)0x20000241 = 8;
*(uint8_t*)0x20000243 = 0x40;
*(uint8_t*)0x20000244 = 0xf8;
*(uint8_t*)0x20000245 = 4;
*(uint8_t*)0x20000246 = 7;
*(uint8_t*)0x20000247 = 0x25;
*(uint8_t*)0x20000248 = 1;
*(uint8_t*)0x20000249 = 0x80;
*(uint8_t*)0x2000024a = 0;
*(uint16_t*)0x2000024b = 3;
*(uint8_t*)0x2000024d = 7;
*(uint8_t*)0x2000024e = 0x25;
*(uint8_t*)0x2000024f = 1;
*(uint8_t*)0x20000250 = 2;
*(uint8_t*)0x20000251 = 8;
*(uint16_t*)0x20000252 = 0x9e00;
*(uint8_t*)0x20000254 = 9;
*(uint8_t*)0x20000255 = 5;
*(uint8_t*)0x20000256 = 2;
*(uint8_t*)0x20000257 = 6;
*(uint16_t*)0x20000258 = 0x20;
*(uint8_t*)0x2000025a = 0x40;
*(uint8_t*)0x2000025b = 5;
*(uint8_t*)0x2000025c = 0x80;
*(uint8_t*)0x2000025d = 9;
*(uint8_t*)0x2000025e = 5;
*(uint8_t*)0x2000025f = 8;
*(uint8_t*)0x20000260 = 1;
*(uint16_t*)0x20000261 = 0x40;
*(uint8_t*)0x20000263 = 2;
*(uint8_t*)0x20000264 = -1;
*(uint8_t*)0x20000265 = 0x3f;
*(uint8_t*)0x20000266 = 2;
*(uint8_t*)0x20000267 = 0xf;
*(uint8_t*)0x20000268 = 9;
*(uint8_t*)0x20000269 = 5;
*(uint8_t*)0x2000026a = 0x80;
*(uint8_t*)0x2000026b = 0x10;
*(uint16_t*)0x2000026c = 0x200;
*(uint8_t*)0x2000026e = -1;
*(uint8_t*)0x2000026f = 0x9b;
*(uint8_t*)0x20000270 = -1;
*(uint8_t*)0x20000271 = 9;
*(uint8_t*)0x20000272 = 5;
*(uint8_t*)0x20000273 = 0xf;
*(uint8_t*)0x20000274 = 0;
*(uint16_t*)0x20000275 = 0x40;
*(uint8_t*)0x20000277 = 5;
*(uint8_t*)0x20000278 = 6;
*(uint8_t*)0x20000279 = 0x7f;
*(uint8_t*)0x2000027a = 7;
*(uint8_t*)0x2000027b = 0x25;
*(uint8_t*)0x2000027c = 1;
*(uint8_t*)0x2000027d = 0x80;
*(uint8_t*)0x2000027e = 0;
*(uint16_t*)0x2000027f = 4;
*(uint8_t*)0x20000281 = 9;
*(uint8_t*)0x20000282 = 5;
*(uint8_t*)0x20000283 = 0xa;
*(uint8_t*)0x20000284 = 3;
*(uint16_t*)0x20000285 = 8;
*(uint8_t*)0x20000287 = 0x3f;
*(uint8_t*)0x20000288 = 1;
*(uint8_t*)0x20000289 = 6;
*(uint8_t*)0x2000028a = 7;
*(uint8_t*)0x2000028b = 0x25;
*(uint8_t*)0x2000028c = 1;
*(uint8_t*)0x2000028d = 0;
*(uint8_t*)0x2000028e = 8;
*(uint16_t*)0x2000028f = 0;
*(uint8_t*)0x20000291 = 9;
*(uint8_t*)0x20000292 = 5;
*(uint8_t*)0x20000293 = 0x8b;
*(uint8_t*)0x20000294 = 0;
*(uint16_t*)0x20000295 = 0x10;
*(uint8_t*)0x20000297 = 0x97;
*(uint8_t*)0x20000298 = 2;
*(uint8_t*)0x20000299 = 6;
*(uint8_t*)0x2000029a = 9;
*(uint8_t*)0x2000029b = 4;
*(uint8_t*)0x2000029c = 0xde;
*(uint8_t*)0x2000029d = 9;
*(uint8_t*)0x2000029e = 0xf;
*(uint8_t*)0x2000029f = 0xd0;
*(uint8_t*)0x200002a0 = 0xec;
*(uint8_t*)0x200002a1 = 0x82;
*(uint8_t*)0x200002a2 = 9;
*(uint8_t*)0x200002a3 = 2;
*(uint8_t*)0x200002a4 = 0x22;
*(uint8_t*)0x200002a5 = 9;
*(uint8_t*)0x200002a6 = 5;
*(uint8_t*)0x200002a7 = 0x80;
*(uint8_t*)0x200002a8 = 0;
*(uint16_t*)0x200002a9 = 8;
*(uint8_t*)0x200002ab = 7;
*(uint8_t*)0x200002ac = 8;
*(uint8_t*)0x200002ad = 0xc0;
*(uint8_t*)0x200002ae = 7;
*(uint8_t*)0x200002af = 0x25;
*(uint8_t*)0x200002b0 = 1;
*(uint8_t*)0x200002b1 = 0x80;
*(uint8_t*)0x200002b2 = 3;
*(uint16_t*)0x200002b3 = 0x401;
*(uint8_t*)0x200002b5 = 9;
*(uint8_t*)0x200002b6 = 5;
*(uint8_t*)0x200002b7 = 0xd;
*(uint8_t*)0x200002b8 = 0x10;
*(uint16_t*)0x200002b9 = 0x200;
*(uint8_t*)0x200002bb = 0xc1;
*(uint8_t*)0x200002bc = 2;
*(uint8_t*)0x200002bd = 0xfe;
*(uint8_t*)0x200002be = 9;
*(uint8_t*)0x200002bf = 5;
*(uint8_t*)0x200002c0 = 6;
*(uint8_t*)0x200002c1 = 0;
*(uint16_t*)0x200002c2 = 8;
*(uint8_t*)0x200002c4 = 7;
*(uint8_t*)0x200002c5 = 0;
*(uint8_t*)0x200002c6 = 9;
*(uint8_t*)0x200002c7 = 2;
*(uint8_t*)0x200002c8 = 0x22;
*(uint8_t*)0x200002c9 = 9;
*(uint8_t*)0x200002ca = 5;
*(uint8_t*)0x200002cb = 0xd;
*(uint8_t*)0x200002cc = 0x10;
*(uint16_t*)0x200002cd = 0x20;
*(uint8_t*)0x200002cf = 0x3f;
*(uint8_t*)0x200002d0 = 9;
*(uint8_t*)0x200002d1 = 0xfa;
*(uint8_t*)0x200002d2 = 2;
*(uint8_t*)0x200002d3 = 0x22;
*(uint8_t*)0x200002d4 = 9;
*(uint8_t*)0x200002d5 = 5;
*(uint8_t*)0x200002d6 = 0;
*(uint8_t*)0x200002d7 = 2;
*(uint16_t*)0x200002d8 = 0x20;
*(uint8_t*)0x200002da = 3;
*(uint8_t*)0x200002db = 0xec;
*(uint8_t*)0x200002dc = 0x92;
*(uint8_t*)0x200002dd = 7;
*(uint8_t*)0x200002de = 0x25;
*(uint8_t*)0x200002df = 1;
*(uint8_t*)0x200002e0 = 1;
*(uint8_t*)0x200002e1 = 0xf8;
*(uint16_t*)0x200002e2 = 1;
*(uint8_t*)0x200002e4 = 7;
*(uint8_t*)0x200002e5 = 0x25;
*(uint8_t*)0x200002e6 = 1;
*(uint8_t*)0x200002e7 = 2;
*(uint8_t*)0x200002e8 = 0x81;
*(uint16_t*)0x200002e9 = 9;
*(uint8_t*)0x200002eb = 9;
*(uint8_t*)0x200002ec = 5;
*(uint8_t*)0x200002ed = 4;
*(uint8_t*)0x200002ee = 0xc;
*(uint16_t*)0x200002ef = 0x50;
*(uint8_t*)0x200002f1 = 2;
*(uint8_t*)0x200002f2 = -1;
*(uint8_t*)0x200002f3 = 0x1f;
*(uint8_t*)0x200002f4 = 2;
*(uint8_t*)0x200002f5 = 0xd;
*(uint8_t*)0x200002f6 = 9;
*(uint8_t*)0x200002f7 = 5;
*(uint8_t*)0x200002f8 = 0xd;
*(uint8_t*)0x200002f9 = 0;
*(uint16_t*)0x200002fa = 0x3ff;
*(uint8_t*)0x200002fc = 7;
*(uint8_t*)0x200002fd = 2;
*(uint8_t*)0x200002fe = 0x4e;
*(uint8_t*)0x200002ff = 9;
*(uint8_t*)0x20000300 = 5;
*(uint8_t*)0x20000301 = 0xc;
*(uint8_t*)0x20000302 = 0x10;
*(uint16_t*)0x20000303 = 0x200;
*(uint8_t*)0x20000305 = 0x41;
*(uint8_t*)0x20000306 = 1;
*(uint8_t*)0x20000307 = 0xeb;
*(uint8_t*)0x20000308 = 2;
*(uint8_t*)0x20000309 = 5;
*(uint8_t*)0x2000030a = 9;
*(uint8_t*)0x2000030b = 5;
*(uint8_t*)0x2000030c = 5;
*(uint8_t*)0x2000030d = 0;
*(uint16_t*)0x2000030e = 0x400;
*(uint8_t*)0x20000310 = 0x7f;
*(uint8_t*)0x20000311 = 0x93;
*(uint8_t*)0x20000312 = 7;
*(uint8_t*)0x20000313 = 9;
*(uint8_t*)0x20000314 = 5;
*(uint8_t*)0x20000315 = 4;
*(uint8_t*)0x20000316 = 4;
*(uint16_t*)0x20000317 = 0x20;
*(uint8_t*)0x20000319 = 8;
*(uint8_t*)0x2000031a = 0xfa;
*(uint8_t*)0x2000031b = 1;
*(uint8_t*)0x2000031c = 9;
*(uint8_t*)0x2000031d = 5;
*(uint8_t*)0x2000031e = 3;
*(uint8_t*)0x2000031f = 0;
*(uint16_t*)0x20000320 = 8;
*(uint8_t*)0x20000322 = 0xc0;
*(uint8_t*)0x20000323 = 7;
*(uint8_t*)0x20000324 = 6;
*(uint8_t*)0x20000325 = 2;
*(uint8_t*)0x20000326 = 2;
*(uint8_t*)0x20000327 = 9;
*(uint8_t*)0x20000328 = 5;
*(uint8_t*)0x20000329 = 0xe;
*(uint8_t*)0x2000032a = 0xc;
*(uint16_t*)0x2000032b = 0x40;
*(uint8_t*)0x2000032d = 0;
*(uint8_t*)0x2000032e = 0x7f;
*(uint8_t*)0x2000032f = 9;
*(uint8_t*)0x20000330 = 9;
*(uint8_t*)0x20000331 = 5;
*(uint8_t*)0x20000332 = 5;
*(uint8_t*)0x20000333 = 0x10;
*(uint16_t*)0x20000334 = 0x10;
*(uint8_t*)0x20000336 = 1;
*(uint8_t*)0x20000337 = 2;
*(uint8_t*)0x20000338 = 9;
*(uint8_t*)0x20000339 = 7;
*(uint8_t*)0x2000033a = 0x25;
*(uint8_t*)0x2000033b = 1;
*(uint8_t*)0x2000033c = 2;
*(uint8_t*)0x2000033d = 0;
*(uint16_t*)0x2000033e = 0x31e0;
*(uint8_t*)0x20000340 = 7;
*(uint8_t*)0x20000341 = 0x25;
*(uint8_t*)0x20000342 = 1;
*(uint8_t*)0x20000343 = 2;
*(uint8_t*)0x20000344 = 0x40;
*(uint16_t*)0x20000345 = 2;
*(uint8_t*)0x20000347 = 9;
*(uint8_t*)0x20000348 = 5;
*(uint8_t*)0x20000349 = 1;
*(uint8_t*)0x2000034a = 4;
*(uint16_t*)0x2000034b = 0x108;
*(uint8_t*)0x2000034d = 0x40;
*(uint8_t*)0x2000034e = 1;
*(uint8_t*)0x2000034f = 0;
*(uint8_t*)0x20000350 = 9;
*(uint8_t*)0x20000351 = 5;
*(uint8_t*)0x20000352 = 5;
*(uint8_t*)0x20000353 = 0xc;
*(uint16_t*)0x20000354 = 0x200;
*(uint8_t*)0x20000356 = 0x44;
*(uint8_t*)0x20000357 = 0xd0;
*(uint8_t*)0x20000358 = 0xe7;
*(uint8_t*)0x20000359 = 7;
*(uint8_t*)0x2000035a = 0x25;
*(uint8_t*)0x2000035b = 1;
*(uint8_t*)0x2000035c = 1;
*(uint8_t*)0x2000035d = 0x4a;
*(uint16_t*)0x2000035e = 0x101;
*(uint8_t*)0x20000360 = 2;
*(uint8_t*)0x20000361 = 4;
*(uint8_t*)0x20000362 = 9;
*(uint8_t*)0x20000363 = 4;
*(uint8_t*)0x20000364 = 0xfb;
*(uint8_t*)0x20000365 = 0x7d;
*(uint8_t*)0x20000366 = 5;
*(uint8_t*)0x20000367 = 8;
*(uint8_t*)0x20000368 = 4;
*(uint8_t*)0x20000369 = 0x50;
*(uint8_t*)0x2000036a = 0;
*(uint8_t*)0x2000036b = 5;
*(uint8_t*)0x2000036c = 0x24;
*(uint8_t*)0x2000036d = 6;
*(uint8_t*)0x2000036e = 0;
*(uint8_t*)0x2000036f = 1;
*(uint8_t*)0x20000370 = 5;
*(uint8_t*)0x20000371 = 0x24;
*(uint8_t*)0x20000372 = 0;
*(uint16_t*)0x20000373 = 0;
*(uint8_t*)0x20000375 = 0xd;
*(uint8_t*)0x20000376 = 0x24;
*(uint8_t*)0x20000377 = 0xf;
*(uint8_t*)0x20000378 = 1;
*(uint32_t*)0x20000379 = 0;
*(uint16_t*)0x2000037d = 5;
*(uint16_t*)0x2000037f = 4;
*(uint8_t*)0x20000381 = 8;
*(uint8_t*)0x20000382 = 6;
*(uint8_t*)0x20000383 = 0x24;
*(uint8_t*)0x20000384 = 0x1a;
*(uint16_t*)0x20000385 = 6;
*(uint8_t*)0x20000387 = 0;
*(uint8_t*)0x20000388 = 5;
*(uint8_t*)0x20000389 = 0x24;
*(uint8_t*)0x2000038a = 6;
*(uint8_t*)0x2000038b = 0;
*(uint8_t*)0x2000038c = 0;
*(uint8_t*)0x2000038d = 5;
*(uint8_t*)0x2000038e = 0x24;
*(uint8_t*)0x2000038f = 0;
*(uint16_t*)0x20000390 = 0x8000;
*(uint8_t*)0x20000392 = 0xd;
*(uint8_t*)0x20000393 = 0x24;
*(uint8_t*)0x20000394 = 0xf;
*(uint8_t*)0x20000395 = 1;
*(uint32_t*)0x20000396 = 1;
*(uint16_t*)0x2000039a = 7;
*(uint16_t*)0x2000039c = 8;
*(uint8_t*)0x2000039e = 5;
*(uint8_t*)0x2000039f = 4;
*(uint8_t*)0x200003a0 = 0x24;
*(uint8_t*)0x200003a1 = 0x13;
*(uint8_t*)0x200003a2 = 9;
*(uint8_t*)0x200003a3 = 8;
*(uint8_t*)0x200003a4 = 0x24;
*(uint8_t*)0x200003a5 = 0x1c;
*(uint16_t*)0x200003a6 = 0x5dd0;
*(uint8_t*)0x200003a8 = 0x3f;
*(uint16_t*)0x200003a9 = 0xfff;
*(uint8_t*)0x200003ab = 4;
*(uint8_t*)0x200003ac = 0x24;
*(uint8_t*)0x200003ad = 2;
*(uint8_t*)0x200003ae = 2;
*(uint8_t*)0x200003af = 9;
*(uint8_t*)0x200003b0 = 5;
*(uint8_t*)0x200003b1 = 4;
*(uint8_t*)0x200003b2 = 3;
*(uint16_t*)0x200003b3 = 0x3ff;
*(uint8_t*)0x200003b5 = 6;
*(uint8_t*)0x200003b6 = 1;
*(uint8_t*)0x200003b7 = 0x81;
*(uint8_t*)0x200003b8 = 2;
*(uint8_t*)0x200003b9 = 0x23;
*(uint8_t*)0x200003ba = 9;
*(uint8_t*)0x200003bb = 5;
*(uint8_t*)0x200003bc = 0;
*(uint8_t*)0x200003bd = 0x10;
*(uint16_t*)0x200003be = 0x40;
*(uint8_t*)0x200003c0 = 4;
*(uint8_t*)0x200003c1 = 3;
*(uint8_t*)0x200003c2 = 7;
*(uint8_t*)0x200003c3 = 9;
*(uint8_t*)0x200003c4 = 5;
*(uint8_t*)0x200003c5 = 1;
*(uint8_t*)0x200003c6 = 0x10;
*(uint16_t*)0x200003c7 = 8;
*(uint8_t*)0x200003c9 = 0x5d;
*(uint8_t*)0x200003ca = 0xc0;
*(uint8_t*)0x200003cb = 7;
*(uint8_t*)0x200003cc = 7;
*(uint8_t*)0x200003cd = 0x25;
*(uint8_t*)0x200003ce = 1;
*(uint8_t*)0x200003cf = 1;
*(uint8_t*)0x200003d0 = 1;
*(uint16_t*)0x200003d1 = 0x81;
*(uint8_t*)0x200003d3 = 9;
*(uint8_t*)0x200003d4 = 5;
*(uint8_t*)0x200003d5 = 9;
*(uint8_t*)0x200003d6 = 0;
*(uint16_t*)0x200003d7 = 0x3ff;
*(uint8_t*)0x200003d9 = 0;
*(uint8_t*)0x200003da = 1;
*(uint8_t*)0x200003db = 0x20;
*(uint8_t*)0x200003dc = 2;
*(uint8_t*)0x200003dd = 9;
*(uint8_t*)0x200003de = 9;
*(uint8_t*)0x200003df = 5;
*(uint8_t*)0x200003e0 = 8;
*(uint8_t*)0x200003e1 = 0;
*(uint16_t*)0x200003e2 = 0x10;
*(uint8_t*)0x200003e4 = 4;
*(uint8_t*)0x200003e5 = 1;
*(uint8_t*)0x200003e6 = 0x80;
*(uint8_t*)0x200003e7 = 2;
*(uint8_t*)0x200003e8 = 1;
*(uint8_t*)0x200003e9 = 2;
*(uint8_t*)0x200003ea = 0x21;
*(uint32_t*)0x20000c80 = 0;
*(uint64_t*)0x20000c84 = 0;
*(uint32_t*)0x20000c8c = 0;
*(uint64_t*)0x20000c90 = 0;
*(uint32_t*)0x20000c98 = 3;
*(uint32_t*)0x20000c9c = 0xa3;
*(uint64_t*)0x20000ca0 = 0;
*(uint32_t*)0x20000ca8 = 0;
*(uint64_t*)0x20000cac = 0;
*(uint32_t*)0x20000cb4 = 0;
*(uint64_t*)0x20000cb8 = 0;
syz_usb_connect(0, 0x1eb, 0x20000200, 0x20000c80);
}
int main(void)
{
syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
loop();
return 0;
}
| 27.949413 | 80 | 0.648093 |
341dbac46531dd8d606f0041e749f28cf6728bb0 | 5,287 | h | C | AK/Buffered.h | AristodamusAdairs/SegueBaseOS | 36e8546009cfea6acd25f111b1cd0ce766271a77 | [
"BSD-2-Clause",
"MIT"
] | 1 | 2021-07-05T13:51:23.000Z | 2021-07-05T13:51:23.000Z | AK/Buffered.h | AristodamusAdairs/SegueBaseOS | 36e8546009cfea6acd25f111b1cd0ce766271a77 | [
"BSD-2-Clause",
"MIT"
] | 1 | 2021-08-02T21:33:29.000Z | 2021-08-06T21:22:19.000Z | AK/Buffered.h | AristodamusAdairs/SegueBaseOS | 36e8546009cfea6acd25f111b1cd0ce766271a77 | [
"BSD-2-Clause",
"MIT"
] | null | null | null | /*
* Copyright (c) 2020, the SegueBaseOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Noncopyable.h>
#include <AK/Span.h>
#include <AK/StdLibExtras.h>
#include <AK/Stream.h>
#include <AK/Types.h>
#include <AK/kmalloc.h>
namespace AK {
// FIXME: Implement Buffered<T> for DuplexStream.
template<typename StreamType, size_t Size = 4096, typename = void>
class Buffered;
template<typename StreamType, size_t Size>
class Buffered<StreamType, Size, typename EnableIf<IsBaseOf<InputStream, StreamType>>::Type> final : public InputStream {
AK_MAKE_NONCOPYABLE(Buffered);
public:
template<typename... Parameters>
explicit Buffered(Parameters&&... parameters)
: m_stream(forward<Parameters>(parameters)...)
{
}
Buffered(Buffered&& other)
: m_stream(move(other.m_stream))
{
other.buffer().copy_to(buffer());
m_buffered = exchange(other.m_buffered, 0);
}
bool has_recoverable_error() const override { return m_stream.has_recoverable_error(); }
bool has_fatal_error() const override { return m_stream.has_fatal_error(); }
bool has_any_error() const override { return m_stream.has_any_error(); }
bool handle_recoverable_error() override { return m_stream.handle_recoverable_error(); }
bool handle_fatal_error() override { return m_stream.handle_fatal_error(); }
bool handle_any_error() override { return m_stream.handle_any_error(); }
void set_recoverable_error() const override { return m_stream.set_recoverable_error(); }
void set_fatal_error() const override { return m_stream.set_fatal_error(); }
size_t read(Bytes bytes) override
{
if (has_any_error())
return 0;
auto nread = buffer().trim(m_buffered).copy_trimmed_to(bytes);
m_buffered -= nread;
buffer().slice(nread, m_buffered).copy_to(buffer());
if (nread < bytes.size()) {
m_buffered = m_stream.read(buffer());
if (m_buffered == 0)
return nread;
nread += read(bytes.slice(nread));
}
return nread;
}
bool read_or_error(Bytes bytes) override
{
if (read(bytes) < bytes.size()) {
set_fatal_error();
return false;
}
return true;
}
bool unreliable_eof() const override { return m_buffered == 0 && m_stream.unreliable_eof(); }
bool eof() const
{
if (m_buffered > 0)
return false;
m_buffered = m_stream.read(buffer());
return m_buffered == 0;
}
bool discard_or_error(size_t count) override
{
size_t ndiscarded = 0;
while (ndiscarded < count) {
u8 dummy[Size];
if (!read_or_error({ dummy, min(Size, count - ndiscarded) }))
return false;
ndiscarded += min(Size, count - ndiscarded);
}
return true;
}
private:
Bytes buffer() const { return { m_buffer, Size }; }
mutable StreamType m_stream;
mutable u8 m_buffer[Size];
mutable size_t m_buffered { 0 };
};
template<typename StreamType, size_t Size>
class Buffered<StreamType, Size, typename EnableIf<IsBaseOf<OutputStream, StreamType>>::Type> final : public OutputStream {
AK_MAKE_NONCOPYABLE(Buffered);
public:
template<typename... Parameters>
explicit Buffered(Parameters&&... parameters)
: m_stream(forward<Parameters>(parameters)...)
{
}
Buffered(Buffered&& other)
: m_stream(move(other.m_stream))
{
other.buffer().copy_to(buffer());
m_buffered = exchange(other.m_buffered, 0);
}
~Buffered()
{
if (m_buffered > 0)
flush();
}
bool has_recoverable_error() const override { return m_stream.has_recoverable_error(); }
bool has_fatal_error() const override { return m_stream.has_fatal_error(); }
bool has_any_error() const override { return m_stream.has_any_error(); }
bool handle_recoverable_error() override { return m_stream.handle_recoverable_error(); }
bool handle_fatal_error() override { return m_stream.handle_fatal_error(); }
bool handle_any_error() override { return m_stream.handle_any_error(); }
void set_recoverable_error() const override { return m_stream.set_recoverable_error(); }
void set_fatal_error() const override { return m_stream.set_fatal_error(); }
size_t write(ReadonlyBytes bytes) override
{
if (has_any_error())
return 0;
auto nwritten = bytes.copy_trimmed_to(buffer().slice(m_buffered));
m_buffered += nwritten;
if (m_buffered == Size) {
flush();
if (bytes.size() - nwritten >= Size)
nwritten += m_stream.write(bytes.slice(nwritten));
nwritten += write(bytes.slice(nwritten));
}
return nwritten;
}
bool write_or_error(ReadonlyBytes bytes) override
{
write(bytes);
return true;
}
void flush()
{
m_stream.write_or_error({ m_buffer, m_buffered });
m_buffered = 0;
}
private:
Bytes buffer() { return { m_buffer, Size }; }
StreamType m_stream;
u8 m_buffer[Size];
size_t m_buffered { 0 };
};
}
using AK::Buffered;
| 26.837563 | 123 | 0.63798 |
2ee6715df7c66051b6a70f5359ab01a82a2f6d50 | 4,163 | h | C | tensorflow/core/kernels/adjust_contrast_op.h | rickyHong/tensorflow_tx1 | c1303e974501ae81c67b70243f4d31b68416cdcd | [
"Apache-2.0"
] | 1 | 2016-01-25T16:24:24.000Z | 2016-01-25T16:24:24.000Z | tensorflow/core/kernels/adjust_contrast_op.h | rickyHong/tensorflow_tx1 | c1303e974501ae81c67b70243f4d31b68416cdcd | [
"Apache-2.0"
] | null | null | null | tensorflow/core/kernels/adjust_contrast_op.h | rickyHong/tensorflow_tx1 | c1303e974501ae81c67b70243f4d31b68416cdcd | [
"Apache-2.0"
] | null | null | null | /* Copyright 2015 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_KERNELS_ADJUST_CONTRAST_OP_H_
#define TENSORFLOW_KERNELS_ADJUST_CONTRAST_OP_H_
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/tensor_types.h"
namespace tensorflow {
namespace functor {
// Functor used by AdjustContrastOp to do the computations.
template <typename Device, typename T>
struct AdjustContrast {
void operator()(const Device& d, typename TTypes<T, 4>::ConstTensor input,
typename TTypes<float>::ConstScalar contrast_factor,
typename TTypes<float>::ConstScalar min_value,
typename TTypes<float>::ConstScalar max_value,
typename TTypes<float, 4>::Tensor mean_values,
typename TTypes<float, 4>::Tensor output) {
const int batch = input.dimension(0);
const int height = input.dimension(1);
const int width = input.dimension(2);
const int channels = input.dimension(3);
//MF Eigen::array scalar_broadcast{{batch, height, width, channels}};
Eigen::array<int, 4> scalar_broadcast;
scalar_broadcast[0] = batch;
scalar_broadcast[1] = height;
scalar_broadcast[2] = width;
scalar_broadcast[3] = channels;
#if !defined(EIGEN_HAS_INDEX_LIST)
//MF Eigen::array reduction_axis{{1, 2}};
//MF Eigen::array scalar{{1, 1, 1, 1}};
//MF Eigen::array broadcast_dims{{1, height, width, 1}};
//MF Eigen::Tensor::Dimensions reshape_dims{{batch, 1, 1, channels}};
Eigen::array<Eigen::DenseIndex, 2> reduction_axis;
reduction_axis[0]=1;
reduction_axis[1]=2;
Eigen::array<Eigen::DenseIndex,4> scalar;
scalar[0]=1;
scalar[1]=1;
scalar[2]=1;
scalar[3]=1;
Eigen::array<Eigen::DenseIndex, 4> broadcast_dims;
broadcast_dims[0]=1;
broadcast_dims[1]=height;
broadcast_dims[2]=width;
broadcast_dims[3]=1;
Eigen::DSizes<Eigen::DenseIndex, 4> reshape_dims;
reshape_dims[0]=batch;
reshape_dims[1]=1;
reshape_dims[2]=1;
reshape_dims[3]=channels;
#else
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<2> >
reduction_axis;
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<1>,
Eigen::type2index<1>, Eigen::type2index<1> > scalar;
Eigen::IndexList<Eigen::type2index<1>, int, int, Eigen::type2index<1> >
broadcast_dims;
broadcast_dims.set(1, height);
broadcast_dims.set(2, width);
Eigen::IndexList<int, Eigen::type2index<1>, Eigen::type2index<1>, int>
reshape_dims;
reshape_dims.set(0, batch);
reshape_dims.set(3, channels);
#endif
mean_values.device(d) = input.template cast<float>()
.mean(reduction_axis)
.eval()
.reshape(reshape_dims)
.broadcast(broadcast_dims);
auto contrast_factor_tensor =
contrast_factor.reshape(scalar).broadcast(scalar_broadcast);
auto adjusted =
(input.template cast<float>() - mean_values) * contrast_factor_tensor +
mean_values;
auto min_bcast = min_value.reshape(scalar).broadcast(scalar_broadcast);
auto max_bcast = max_value.reshape(scalar).broadcast(scalar_broadcast);
// TODO(wicke): This is rather slow and should be re-written as pure cuda.
output.device(d) = adjusted.cwiseMin(max_bcast).cwiseMax(min_bcast);
}
};
} // namespace functor
} // namespace tensorflow
#endif // TENSORFLOW_KERNELS_ADJUST_CONTRAST_OP_H_
| 40.028846 | 80 | 0.668268 |
0c13b591e37847c4b3f804f07dd10149158a8bf4 | 843 | c | C | scrcpy-core/src-fix/scrcpy-fix.c | eritpchy/scrcpy-ios | 2f296b9ed626ec57abffa08944b6997e92be5cd9 | [
"Apache-2.0"
] | 141 | 2021-07-24T10:46:48.000Z | 2022-03-26T05:50:08.000Z | scrcpy-core/src-fix/scrcpy-fix.c | eritpchy/scrcpy-ios | 2f296b9ed626ec57abffa08944b6997e92be5cd9 | [
"Apache-2.0"
] | 15 | 2021-07-24T19:51:52.000Z | 2022-03-24T02:01:14.000Z | scrcpy-core/src-fix/scrcpy-fix.c | eritpchy/scrcpy-ios | 2f296b9ed626ec57abffa08944b6997e92be5cd9 | [
"Apache-2.0"
] | 17 | 2021-07-24T16:08:19.000Z | 2022-03-26T05:50:09.000Z | //
// scrcpy-fix.c
// scrcpy-core
// > this file is created to fix/tuning srouce code of scrcpy core
//
// Created by Ethan on 2021/12/7.
//
#include <stdbool.h>
#include "input_manager.h"
bool
input_manager_handle_event_fix(struct input_manager *im, SDL_Event *event);
#define input_manager_handle_event(...) input_manager_handle_event_fix(__VA_ARGS__)
#include "scrcpy.c"
#undef input_manager_handle_event
/**
* Handle input_manager to allow null when send a Restart codec event
*/
bool
input_manager_handle_event_fix(struct input_manager *im, SDL_Event *event) {
static struct input_manager *global_im = NULL;
global_im = im ? : global_im;
// sometimes maybe control connect haven't ready
if (global_im == NULL) {
return false;
}
return input_manager_handle_event(global_im, event);
}
| 23.416667 | 84 | 0.723606 |
08dd5aeae964e06ba009dc9ed4959f63dbd23748 | 7,873 | h | C | Firmware/TI-TMS320F28335/Data_aquisition/include/DSP2833x_Sci.h | zhutoutoutousan/NVH | 78cf6d46b89a650dc7510c850441b23f620c5297 | [
"MIT"
] | null | null | null | Firmware/TI-TMS320F28335/Data_aquisition/include/DSP2833x_Sci.h | zhutoutoutousan/NVH | 78cf6d46b89a650dc7510c850441b23f620c5297 | [
"MIT"
] | null | null | null | Firmware/TI-TMS320F28335/Data_aquisition/include/DSP2833x_Sci.h | zhutoutoutousan/NVH | 78cf6d46b89a650dc7510c850441b23f620c5297 | [
"MIT"
] | null | null | null | //###########################################################################
//
// FILE: DSP2833x_Sci.h
//
// TITLE: DSP2833x Device SCI Register Definitions.
//
//###########################################################################
// $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
// $Release Date: June 8, 2012 $
//###########################################################################
#ifndef DSP2833x_SCI_H
#define DSP2833x_SCI_H
#ifdef __cplusplus
extern "C" {
#endif
//---------------------------------------------------------------------------
// SCI Individual Register Bit Definitions
//----------------------------------------------------------
// SCICCR communication control register bit definitions:
//
struct SCICCR_BITS { // bit description
Uint16 SCICHAR:3; // 2:0 Character length control
Uint16 ADDRIDLE_MODE:1; // 3 ADDR/IDLE Mode control
Uint16 LOOPBKENA:1; // 4 Loop Back enable
Uint16 PARITYENA:1; // 5 Parity enable
Uint16 PARITY:1; // 6 Even or Odd Parity
Uint16 STOPBITS:1; // 7 Number of Stop Bits
Uint16 rsvd1:8; // 15:8 reserved
};
union SCICCR_REG {
Uint16 all;
struct SCICCR_BITS bit;
};
//-------------------------------------------
// SCICTL1 control register 1 bit definitions:
//
struct SCICTL1_BITS { // bit description
Uint16 RXENA:1; // 0 SCI receiver enable
Uint16 TXENA:1; // 1 SCI transmitter enable
Uint16 SLEEP:1; // 2 SCI sleep
Uint16 TXWAKE:1; // 3 Transmitter wakeup method
Uint16 rsvd:1; // 4 reserved
Uint16 SWRESET:1; // 5 Software reset
Uint16 RXERRINTENA:1; // 6 Recieve interrupt enable
Uint16 rsvd1:9; // 15:7 reserved
};
union SCICTL1_REG {
Uint16 all;
struct SCICTL1_BITS bit;
};
//---------------------------------------------
// SCICTL2 control register 2 bit definitions:
//
struct SCICTL2_BITS { // bit description
Uint16 TXINTENA:1; // 0 Transmit interrupt enable
Uint16 RXBKINTENA:1; // 1 Receiver-buffer break enable
Uint16 rsvd:4; // 5:2 reserved
Uint16 TXEMPTY:1; // 6 Transmitter empty flag
Uint16 TXRDY:1; // 7 Transmitter ready flag
Uint16 rsvd1:8; // 15:8 reserved
};
union SCICTL2_REG {
Uint16 all;
struct SCICTL2_BITS bit;
};
//---------------------------------------------------
// SCIRXST Receiver status register bit definitions:
//
struct SCIRXST_BITS { // bit description
Uint16 rsvd:1; // 0 reserved
Uint16 RXWAKE:1; // 1 Receiver wakeup detect flag
Uint16 PE:1; // 2 Parity error flag
Uint16 OE:1; // 3 Overrun error flag
Uint16 FE:1; // 4 Framing error flag
Uint16 BRKDT:1; // 5 Break-detect flag
Uint16 RXRDY:1; // 6 Receiver ready flag
Uint16 RXERROR:1; // 7 Receiver error flag
};
union SCIRXST_REG {
Uint16 all;
struct SCIRXST_BITS bit;
};
//----------------------------------------------------
// SCIRXBUF Receiver Data Buffer with FIFO bit definitions:
//
struct SCIRXBUF_BITS { // bits description
Uint16 RXDT:8; // 7:0 Receive word
Uint16 rsvd:6; // 13:8 reserved
Uint16 SCIFFPE:1; // 14 SCI PE error in FIFO mode
Uint16 SCIFFFE:1; // 15 SCI FE error in FIFO mode
};
union SCIRXBUF_REG {
Uint16 all;
struct SCIRXBUF_BITS bit;
};
//--------------------------------------------------
// SCIPRI Priority control register bit definitions:
//
//
struct SCIPRI_BITS { // bit description
Uint16 rsvd:3; // 2:0 reserved
Uint16 FREE:1; // 3 Free emulation suspend mode
Uint16 SOFT:1; // 4 Soft emulation suspend mode
Uint16 rsvd1:3; // 7:5 reserved
};
union SCIPRI_REG {
Uint16 all;
struct SCIPRI_BITS bit;
};
//-------------------------------------------------
// SCI FIFO Transmit register bit definitions:
//
//
struct SCIFFTX_BITS { // bit description
Uint16 TXFFIL:5; // 4:0 Interrupt level
Uint16 TXFFIENA:1; // 5 Interrupt enable
Uint16 TXFFINTCLR:1; // 6 Clear INT flag
Uint16 TXFFINT:1; // 7 INT flag
Uint16 TXFFST:5; // 12:8 FIFO status
Uint16 TXFIFOXRESET:1; // 13 FIFO reset
Uint16 SCIFFENA:1; // 14 Enhancement enable
Uint16 SCIRST:1; // 15 SCI reset rx/tx channels
};
union SCIFFTX_REG {
Uint16 all;
struct SCIFFTX_BITS bit;
};
//------------------------------------------------
// SCI FIFO recieve register bit definitions:
//
//
struct SCIFFRX_BITS { // bits description
Uint16 RXFFIL:5; // 4:0 Interrupt level
Uint16 RXFFIENA:1; // 5 Interrupt enable
Uint16 RXFFINTCLR:1; // 6 Clear INT flag
Uint16 RXFFINT:1; // 7 INT flag
Uint16 RXFFST:5; // 12:8 FIFO status
Uint16 RXFIFORESET:1; // 13 FIFO reset
Uint16 RXFFOVRCLR:1; // 14 Clear overflow
Uint16 RXFFOVF:1; // 15 FIFO overflow
};
union SCIFFRX_REG {
Uint16 all;
struct SCIFFRX_BITS bit;
};
// SCI FIFO control register bit definitions:
struct SCIFFCT_BITS { // bits description
Uint16 FFTXDLY:8; // 7:0 FIFO transmit delay
Uint16 rsvd:5; // 12:8 reserved
Uint16 CDC:1; // 13 Auto baud mode enable
Uint16 ABDCLR:1; // 14 Auto baud clear
Uint16 ABD:1; // 15 Auto baud detect
};
union SCIFFCT_REG {
Uint16 all;
struct SCIFFCT_BITS bit;
};
//---------------------------------------------------------------------------
// SCI Register File:
//
struct SCI_REGS {
union SCICCR_REG SCICCR; // Communications control register
union SCICTL1_REG SCICTL1; // Control register 1
Uint16 SCIHBAUD; // Baud rate (high) register
Uint16 SCILBAUD; // Baud rate (low) register
union SCICTL2_REG SCICTL2; // Control register 2
union SCIRXST_REG SCIRXST; // Recieve status register
Uint16 SCIRXEMU; // Recieve emulation buffer register
union SCIRXBUF_REG SCIRXBUF; // Recieve data buffer
Uint16 rsvd1; // reserved
Uint16 SCITXBUF; // Transmit data buffer
union SCIFFTX_REG SCIFFTX; // FIFO transmit register
union SCIFFRX_REG SCIFFRX; // FIFO recieve register
union SCIFFCT_REG SCIFFCT; // FIFO control register
Uint16 rsvd2; // reserved
Uint16 rsvd3; // reserved
union SCIPRI_REG SCIPRI; // FIFO Priority control
};
//---------------------------------------------------------------------------
// SCI External References & Function Declarations:
//
extern volatile struct SCI_REGS SciaRegs;
extern volatile struct SCI_REGS ScibRegs;
extern volatile struct SCI_REGS ScicRegs;
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // end of DSP2833x_SCI_H definition
//===========================================================================
// End of file.
//===========================================================================
| 33.645299 | 77 | 0.488124 |
08e66766be0c68a19f4979bffa76cc7e834de05a | 4,024 | h | C | lib/libyasa/raliparser.h | anoidgit/yasa | 2b67b3610a68287a29999499dee0ca8f8b8b0f62 | [
"Apache-2.0"
] | 2 | 2019-04-12T03:49:10.000Z | 2020-07-29T08:58:30.000Z | lib/libyasa/raliparser.h | hfxunlp/yasa | 2b67b3610a68287a29999499dee0ca8f8b8b0f62 | [
"Apache-2.0"
] | null | null | null | lib/libyasa/raliparser.h | hfxunlp/yasa | 2b67b3610a68287a29999499dee0ca8f8b8b0f62 | [
"Apache-2.0"
] | 1 | 2021-06-13T19:08:53.000Z | 2021-06-13T19:08:53.000Z | /*
Copyright 2013 RALI
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 JAPA_RALI_PARSER_H
#define JAPA_RALI_PARSER_H
#include <string>
#include "textparser.h"
namespace japa
{
/**
* \french
* Compile un texte suivant une norme s'inspirant de celle du RALI ( GLM ).
*
* Le texte est compos�s des jetons suivants :
* <table>
* <tr><th>Nom</th> <th>Description</th></tr>
* <tr><td>{sect}</td> <td>D�but d'une section.</td></tr>
* <tr><td>{para}</td> <td>D�but d'un paragraphe.</td></tr>
* <tr><td>{sent}</td> <td>D�but d'une phrase.</td></tr>
* <tr><td>{EOF}</td> <td>Fin du fichier ( optionnel ).</td></tr>
* <tr><td>autre</td> <td>Un mot.</td></tr>
*
* Chaque jeton doit tenir sur sa propre ligne. Toutes les lignes avant le
* premier jeton <code>{sent}</code> et apr�s le jeton <code>{EOF}</code> sont
* ignor�s et peuvent donc servir � commenter le fichier.
* </table>
*
* \endfrench
*
* \english
* Parse a text in a format similar to the RALI ( GLM ) format.
*
* The text must be composed of the following tokens :
*
* <table>
* <tr><th>Name</th> <th>Description</th></tr>
* <tr><td>{sect}</td> <td>Beginning of a section.</td></tr>
* <tr><td>{para}</td> <td>Beginning of a paragraphe.</td></tr>
* <tr><td>{sent}</td> <td>Beginning of a sentence.</td></tr>
* <tr><td>{EOF}</td> <td>End of the file ( optional ).</td></tr>
* <tr><td>other</td> <td>A word.</td></tr>
*
* Each token must stands on its own line. All the lines before the first
* <code>{sent}</code> and after <code>{EOF}</code> token are ignored. So
* theses lines can comment the file.
*
* \endenglish
*
*
* @version 1.1
*/
class RaliParser : public TextParser
{
public :
/**
* \french
* Constructeur.
* \endfrench
*
* \english
* Constructor.
* \endenglish
*/
RaliParser();
bool operator() ( std::wistream& in, Text& text );
/**
* \french
* Lex�me marquant le d�but d'une division.
* \endfrench
*
* \english
* Lexeme indicating the beginning of a new division.
* \endenglish
*/
static const std::wstring LEX_BEGIN_DIVISION;
/**
* \french
* Lex�me marquant le d�but d'un paragraphe.
* \endfrench
*
* \english
* Lexeme indicating the beginning of a new paragraph.
* \endenglish
*/
static const std::wstring LEX_BEGIN_PARAGRAPH;
/**
* \french
* Lex�me marquant le d�but d'une phrase.
* \endfrench
*
* \english
* Lexeme indicating the beginning of a new sentence.
* \endenglish
*/
static const std::wstring LEX_BEGIN_SENTENCE;
/**
* \french
* Lex�me marquant la fin du texte.
* \endfrench
*
* \english
* Lexeme indicating the end of the text.
* \endenglish
*/
static const std::wstring LEX_END_TEXT;
/**
* \french
* Le s�parateur de lex�mes.
* \endfrench
*
* \english
* Lexems separator.
* \endenglish
*/
static const wchar_t LEX_SEPARATOR;
private :
/**
* \french
* @return Un identificateur de phrase unique.
* \endfrench
*
* \english
* @return A unique sentence identifier.
* \endenglish
*/
std::wstring nextSID();
/**
* \french
* L'identificateur de la prochaine phrase.
* \endfrench
*
* \english
* The next sentence's identifier.
* \endenglish
*/
unsigned long m_sID;
};
}// namespace japa
#endif
| 23.810651 | 78 | 0.608101 |
39faa37d4edfd4c760eeab5789a792bbe84f8be3 | 973 | h | C | CS2710 Lab Work/LAB 7/P1/listADTArr.h | vikram-kv/CS2710-LabWork | 412e9746f746a131811df47c49fd141dc9e8fc70 | [
"Apache-2.0"
] | null | null | null | CS2710 Lab Work/LAB 7/P1/listADTArr.h | vikram-kv/CS2710-LabWork | 412e9746f746a131811df47c49fd141dc9e8fc70 | [
"Apache-2.0"
] | null | null | null | CS2710 Lab Work/LAB 7/P1/listADTArr.h | vikram-kv/CS2710-LabWork | 412e9746f746a131811df47c49fd141dc9e8fc70 | [
"Apache-2.0"
] | null | null | null | #ifndef LIST_ADT_ARR_H
#define LIST_ADT_ARR_H
typedef int elementType;//Alias for int used as an element type
typedef int Position;//Alias for int used for indexing
/*
Defines ADT List.
Data members: Pointer to the first node of an array of type elementType - *list
Position of the last node - lastNode
Operations: All the common list operations along with
Swap the elements at two positions
Sort the list by Quick Sort technique
*/
/* begin {Definition of class List} */
class List {
public:
void insert(elementType x, Position p);
void delItem(Position p);
void makeNull();
void printList();
Position end();
Position first();
Position next(Position p);
elementType retrieve(Position p);
void swap(Position i,Position j);
void quickSortList(Position,Position);
private:
Position partition(Position,Position);
Position lastNode;
elementType* list;
};
/* end{Definition of class List} */
#endif
| 27.8 | 81 | 0.713258 |
d82077f0b2275f028e2091190e0df965fb5d416d | 18,067 | h | C | hdf5-1.8.20/src/H5B2pkg.h | GWU-CFD/flash-distro | 740f45047bde057365823036158893c19c6d7c72 | [
"MIT"
] | 20 | 2016-06-22T04:14:55.000Z | 2022-03-21T15:06:48.000Z | hdf5-1.8.20/src/H5B2pkg.h | GWU-CFD/flash-distro | 740f45047bde057365823036158893c19c6d7c72 | [
"MIT"
] | 5 | 2019-06-06T18:47:10.000Z | 2022-03-31T14:05:18.000Z | hdf5-1.8.20/src/H5B2pkg.h | GWU-CFD/flash-distro | 740f45047bde057365823036158893c19c6d7c72 | [
"MIT"
] | 5 | 2017-07-11T22:28:45.000Z | 2021-12-03T22:21:08.000Z | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
* Monday, January 31, 2005
*
* Purpose: This file contains declarations which are visible only within
* the H5B2 package. Source files outside the H5B2 package should
* include H5B2private.h instead.
*/
#ifndef H5B2_PACKAGE
#error "Do not include this file outside the H5B2 package!"
#endif
#ifndef _H5B2pkg_H
#define _H5B2pkg_H
/* Get package's private header */
#include "H5B2private.h"
/* Other private headers needed by this file */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5FLprivate.h" /* Free Lists */
/**************************/
/* Package Private Macros */
/**************************/
/* Size of storage for number of records per node (on disk) */
#define H5B2_SIZEOF_RECORDS_PER_NODE (unsigned)2
/* Size of a "tree pointer" (on disk) */
/* (essentially, the largest internal pointer allowed) */
#define H5B2_TREE_POINTER_SIZE(h) ( \
(h)->sizeof_addr + \
H5B2_SIZEOF_RECORDS_PER_NODE + \
(h)->sizeof_size \
)
/* Size of a internal node pointer (on disk) */
#define H5B2_INT_POINTER_SIZE(h, d) ( \
(unsigned)(h)->sizeof_addr /* Address of child node */ \
+ (h)->max_nrec_size /* # of records in child node */ \
+ (h)->node_info[(d) - 1].cum_max_nrec_size /* Total # of records in child & below */ \
)
/* Size of checksum information (on disk) */
#define H5B2_SIZEOF_CHKSUM 4
/* Format overhead for all v2 B-tree metadata in the file */
#define H5B2_METADATA_PREFIX_SIZE ( \
(unsigned)H5_SIZEOF_MAGIC /* Signature */ \
+ (unsigned)1 /* Version */ \
+ (unsigned)1 /* Tree type */ \
+ (unsigned)H5B2_SIZEOF_CHKSUM /* Metadata checksum */ \
)
/* Size of the v2 B-tree header on disk */
#define H5B2_HEADER_SIZE(h) ( \
/* General metadata fields */ \
H5B2_METADATA_PREFIX_SIZE \
\
/* Header specific fields */ \
+ (unsigned)4 /* Node size, in bytes */ \
+ (unsigned)2 /* Record size, in bytes */ \
+ (unsigned)2 /* Depth of tree */ \
+ (unsigned)1 /* Split % of full (as integer, ie. "98" means 98%) */ \
+ (unsigned)1 /* Merge % of full (as integer, ie. "98" means 98%) */ \
+ H5B2_TREE_POINTER_SIZE(h) /* Node pointer to root node in tree */ \
)
/* Size of the v2 B-tree internal node prefix */
#define H5B2_INT_PREFIX_SIZE ( \
/* General metadata fields */ \
H5B2_METADATA_PREFIX_SIZE \
\
/* Header specific fields */ \
/* <none> */ \
)
/* Size of the v2 B-tree leaf node prefix */
#define H5B2_LEAF_PREFIX_SIZE ( \
/* General metadata fields */ \
H5B2_METADATA_PREFIX_SIZE \
\
/* Header specific fields */ \
/* <none> */ \
)
/* Macro to retrieve pointer to i'th native record for native record buffer */
#define H5B2_NAT_NREC(b, hdr, idx) ((b) + (hdr)->nat_off[(idx)])
/* Macro to retrieve pointer to i'th native record for internal node */
#define H5B2_INT_NREC(i, hdr, idx) H5B2_NAT_NREC((i)->int_native, (hdr), (idx))
/* Macro to retrieve pointer to i'th native record for leaf node */
#define H5B2_LEAF_NREC(l, hdr, idx) H5B2_NAT_NREC((l)->leaf_native, (hdr), (idx))
/* Number of records that fit into internal node */
/* (accounts for extra node pointer by counting it in with the prefix bytes) */
#define H5B2_NUM_INT_REC(h, d) \
(((h)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(h, d))) / ((h)->rrec_size + H5B2_INT_POINTER_SIZE(h, d)))
/****************************/
/* Package Private Typedefs */
/****************************/
/* A "node pointer" to another B-tree node */
typedef struct {
haddr_t addr; /* Address of other node */
uint16_t node_nrec; /* Number of records used in node pointed to */
hsize_t all_nrec; /* Number of records in node pointed to and all it's children */
} H5B2_node_ptr_t;
/* Information about a node at a given depth */
typedef struct {
unsigned max_nrec; /* Max. number of records in node */
unsigned split_nrec; /* Number of records to split node at */
unsigned merge_nrec; /* Number of records to merge node at */
hsize_t cum_max_nrec; /* Cumulative max. # of records below this node's depth */
uint8_t cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */
H5FL_fac_head_t *nat_rec_fac; /* Factory for native record blocks */
H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */
} H5B2_node_info_t;
/* The B-tree header information */
typedef struct H5B2_hdr_t {
/* Information for H5AC cache functions, _must_ be first field in structure */
H5AC_info_t cache_info;
/* Internal B-tree information (stored) */
H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */
/* Information set by user (stored) */
uint8_t split_percent; /* Percent full at which to split the node, when inserting */
uint8_t merge_percent; /* Percent full at which to merge the node, when deleting */
uint32_t node_size; /* Size of B-tree nodes, in bytes */
uint32_t rrec_size; /* Size of "raw" (on disk) record, in bytes */
/* Dynamic information (stored) */
uint16_t depth; /* B-tree's overall depth */
/* Derived information from user's information (not stored) */
uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */
/* Shared internal data structures (not stored) */
H5F_t *f; /* Pointer to the file that the B-tree is in */
haddr_t addr; /* Address of B-tree header in the file */
size_t hdr_size; /* Size of the B-tree header on disk */
size_t rc; /* Reference count of nodes using this header */
size_t file_rc; /* Reference count of files using this header */
hbool_t pending_delete; /* B-tree is pending deletion */
uint8_t sizeof_size; /* Size of file sizes */
uint8_t sizeof_addr; /* Size of file addresses */
H5B2_remove_t remove_op; /* Callback operator for deleting B-tree */
void *remove_op_data;/* B-tree deletion callback's context */
uint8_t *page; /* Common disk page for I/O */
size_t *nat_off; /* Array of offsets of native records */
H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */
uint8_t *min_native_rec; /* Pointer to minimum native record */
uint8_t *max_native_rec; /* Pointer to maximum native record */
/* Client information (not stored) */
const H5B2_class_t *cls; /* Class of B-tree client */
void *cb_ctx; /* Client callback context */
} H5B2_hdr_t;
/* B-tree leaf node information */
typedef struct H5B2_leaf_t {
/* Information for H5AC cache functions, _must_ be first field in structure */
H5AC_info_t cache_info;
/* Internal B-tree information */
H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */
uint8_t *leaf_native; /* Pointer to native records */
uint16_t nrec; /* Number of records in node */
} H5B2_leaf_t;
/* B-tree internal node information */
typedef struct H5B2_internal_t {
/* Information for H5AC cache functions, _must_ be first field in structure */
H5AC_info_t cache_info;
/* Internal B-tree information */
H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */
uint8_t *int_native; /* Pointer to native records */
H5B2_node_ptr_t *node_ptrs; /* Pointer to node pointers */
uint16_t nrec; /* Number of records in node */
uint16_t depth; /* Depth of this node in the B-tree */
} H5B2_internal_t;
/* v2 B-tree */
struct H5B2_t {
H5B2_hdr_t *hdr; /* Pointer to internal v2 B-tree header info */
H5F_t *f; /* Pointer to file for v2 B-tree */
};
/* Node position, for min/max determination */
typedef enum H5B2_nodepos_t {
H5B2_POS_ROOT, /* Node is root (i.e. both right & left-most in tree) */
H5B2_POS_RIGHT, /* Node is right-most in tree, at a given depth */
H5B2_POS_LEFT, /* Node is left-most in tree, at a given depth */
H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */
} H5B2_nodepos_t;
/* Callback info for loading a free space header into the cache */
typedef struct H5B2_hdr_cache_ud_t {
H5F_t *f; /* File that v2 b-tree header is within */
void *ctx_udata; /* User-data for protecting */
} H5B2_hdr_cache_ud_t;
/* Callback info for loading a free space internal node into the cache */
typedef struct H5B2_internal_cache_ud_t {
H5F_t *f; /* File that v2 b-tree header is within */
H5B2_hdr_t *hdr; /* v2 B-tree header */
unsigned nrec; /* Number of records in node to load */
unsigned depth; /* Depth of node to load */
} H5B2_internal_cache_ud_t;
/* Callback info for loading a free space leaf node into the cache */
typedef struct H5B2_leaf_cache_ud_t {
H5F_t *f; /* File that v2 b-tree header is within */
H5B2_hdr_t *hdr; /* v2 B-tree header */
unsigned nrec; /* Number of records in node to load */
} H5B2_leaf_cache_ud_t;
#ifdef H5B2_TESTING
/* Node information for testing */
typedef struct {
unsigned depth; /* Depth of node */
unsigned nrec; /* Number of records in node */
} H5B2_node_info_test_t;
#endif /* H5B2_TESTING */
/*****************************/
/* Package Private Variables */
/*****************************/
/* H5B2 header inherits cache-like properties from H5AC */
H5_DLLVAR const H5AC_class_t H5AC_BT2_HDR[1];
/* H5B2 internal node inherits cache-like properties from H5AC */
H5_DLLVAR const H5AC_class_t H5AC_BT2_INT[1];
/* H5B2 leaf node inherits cache-like properties from H5AC */
H5_DLLVAR const H5AC_class_t H5AC_BT2_LEAF[1];
/* Declare a free list to manage the H5B2_internal_t struct */
H5FL_EXTERN(H5B2_internal_t);
/* Declare a free list to manage the H5B2_leaf_t struct */
H5FL_EXTERN(H5B2_leaf_t);
/* Internal v2 B-tree testing class */
#ifdef H5B2_TESTING
H5_DLLVAR const H5B2_class_t H5B2_TEST[1];
#endif /* H5B2_TESTING */
/* Array of v2 B-tree client ID -> client class mappings */
extern const H5B2_class_t *const H5B2_client_class_g[H5B2_NUM_BTREE_ID];
/******************************/
/* Package Private Prototypes */
/******************************/
/* Routines for managing B-tree header info */
H5_DLL H5B2_hdr_t *H5B2_hdr_alloc(H5F_t *f);
H5_DLL haddr_t H5B2_hdr_create(H5F_t *f, hid_t dxpl_id,
const H5B2_create_t *cparam, void *ctx_udata);
H5_DLL herr_t H5B2_hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam,
void *ctx_udata, uint16_t depth);
H5_DLL herr_t H5B2_hdr_incr(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_hdr_decr(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_hdr_fuse_incr(H5B2_hdr_t *hdr);
H5_DLL size_t H5B2_hdr_fuse_decr(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_hdr_dirty(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id);
/* Routines for operating on leaf nodes */
H5B2_leaf_t *H5B2_protect_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, haddr_t addr,
unsigned nrec, H5AC_protect_t rw);
/* Routines for operating on internal nodes */
H5_DLL H5B2_internal_t *H5B2_protect_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
haddr_t addr, unsigned nrec, unsigned depth, H5AC_protect_t rw);
/* Routines for allocating nodes */
H5_DLL herr_t H5B2_split_root(H5B2_hdr_t *hdr, hid_t dxpl_id);
H5_DLL herr_t H5B2_create_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *node_ptr);
/* Routines for releasing structures */
H5_DLL herr_t H5B2_hdr_free(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_leaf_free(H5B2_leaf_t *l);
H5_DLL herr_t H5B2_internal_free(H5B2_internal_t *i);
/* Routines for inserting records */
H5_DLL herr_t H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
unsigned depth, unsigned *parent_cache_info_flags_ptr,
H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata);
H5_DLL herr_t H5B2_insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata);
/* Routines for iterating over nodes/records */
H5_DLL herr_t H5B2_iterate_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data);
H5_DLL herr_t H5B2_node_size(H5B2_hdr_t *hdr, hid_t dxpl_id,
unsigned depth, const H5B2_node_ptr_t *curr_node, hsize_t *op_data);
/* Routines for locating records */
H5_DLL int H5B2_locate_record(const H5B2_class_t *type, unsigned nrec,
size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx, int *result);
H5_DLL herr_t H5B2_neighbor_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
unsigned depth, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data);
H5_DLL herr_t H5B2_neighbor_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data);
/* Routines for removing records */
H5_DLL herr_t H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
hbool_t *depth_decreased, void *swap_loc, unsigned depth,
H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
H5B2_nodepos_t curr_pos, H5B2_node_ptr_t *curr_node_ptr, void *udata,
H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos,
void *udata, H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
hbool_t *depth_decreased, void *swap_loc, unsigned depth,
H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n,
H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos,
unsigned idx, H5B2_remove_t op, void *op_data);
/* Routines for deleting nodes */
H5_DLL herr_t H5B2_delete_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data);
/* Debugging routines for dumping file structures */
H5_DLL herr_t H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
FILE *stream, int indent, int fwidth, const H5B2_class_t *type, haddr_t obj_addr);
H5_DLL herr_t H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
FILE *stream, int indent, int fwidth, const H5B2_class_t *type,
haddr_t hdr_addr, unsigned nrec, unsigned depth, haddr_t obj_addr);
H5_DLL herr_t H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
FILE *stream, int indent, int fwidth, const H5B2_class_t *type,
haddr_t hdr_addr, unsigned nrec, haddr_t obj_addr);
/* Testing routines */
#ifdef H5B2_TESTING
H5_DLL herr_t H5B2_get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr);
H5_DLL int H5B2_get_node_depth_test(H5B2_t *bt2, hid_t dxpl_id, void *udata);
H5_DLL herr_t H5B2_get_node_info_test(H5B2_t *bt2, hid_t dxpl_id,
void *udata, H5B2_node_info_test_t *ninfo);
#endif /* H5B2_TESTING */
#endif /* _H5B2pkg_H */
| 47.923077 | 126 | 0.60569 |
142f1e25001ddf858f8e81794b2612342664aeaa | 1,852 | h | C | base_engine/src/components/indexer/global_descriptor/index_builder.h | AiPratice/VideoAnalysisEngine | e6aa67e5b0d08d6b3ae1b63988982ef31e60bf7a | [
"Apache-2.0"
] | 23 | 2018-09-12T10:04:32.000Z | 2022-02-13T12:07:53.000Z | base_engine/src/components/indexer/global_descriptor/index_builder.h | AiPratice/VideoAnalysisTool | e6aa67e5b0d08d6b3ae1b63988982ef31e60bf7a | [
"Apache-2.0"
] | 1 | 2021-03-24T03:37:28.000Z | 2021-03-24T03:37:28.000Z | base_engine/src/components/indexer/global_descriptor/index_builder.h | AiPratice/VideoAnalysisTool | e6aa67e5b0d08d6b3ae1b63988982ef31e60bf7a | [
"Apache-2.0"
] | 12 | 2018-09-12T10:04:33.000Z | 2021-12-20T12:47:07.000Z | #pragma once
#include "definition.h"
#include "gdindex.h"
#include <string>
#include <vector>
namespace vrs
{
namespace components
{
class index_builder
{
public:
/*
* 建立以镜头为基础的全局索引
* vector<string> &feature_file_paths 特征文件路径数组
* const char *out_file_path 索引文件输出路径
* uint num_gaussians
* uint ld_mode 局部描述算子的模式(SIFT OR SIFT_GEO)
* int shot_mode
* int verbose_level
* const char *gdindex_parameters_path
* bool gd_intra_normalization
* bool gd_unbinarized
*/
static bool build_shot_based(std::vector<std::string> &feature_file_paths,
const char *out_file_path, uint num_gaussians = 512, uint ld_mode =
SIFT_LOCAL_DESCRIPTOR, int shot_mode = SHOT_MODE_INDEP_KEYF,
int shot_keyf = -1, int verbose_level = 1,
const char *gdindex_parameters_path = "./trained_parameters",
bool single_shot = false, bool gd_intra_normalization = false,
bool gd_unbinarized = false);
/*
* 建立以帧为基础的全局索引
* vector<string> &feature_file_paths 特征文件路径数组
* const char *out_file_path 索引文件输出路径
* uint num_gaussians
* uint ld_mode 局部描述算子的模式(SIFT OR SIFT_GEO)
* int verbose_level
* const char *gdindex_parameters_path
* bool gd_intra_normalization
* bool gd_unbinarized
*/
static bool build_frame_based(const std::vector<std::string> &feature_file_paths,
const char *out_file_path, uint num_gaussians = 512, uint ld_mode =
SIFT_LOCAL_DESCRIPTOR, int verbose_level = 3,
const char *gdindex_parameters_path = "./trained_parameters",
bool gd_intra_normalization = false, bool gd_unbinarized = false);
};
}
} /* namespace vrs */
| 33.672727 | 98 | 0.637149 |
969a9e23729c9f049b1a8563be3fe3f95076100b | 7,332 | h | C | src/aarch64/gic.h | am11/nanos | ae93340b38d41d200e587090bab02e91c9bc333b | [
"Apache-2.0"
] | null | null | null | src/aarch64/gic.h | am11/nanos | ae93340b38d41d200e587090bab02e91c9bc333b | [
"Apache-2.0"
] | null | null | null | src/aarch64/gic.h | am11/nanos | ae93340b38d41d200e587090bab02e91c9bc333b | [
"Apache-2.0"
] | null | null | null | #define GIC_SGI_INTS_START 0
#define GIC_SGI_INTS_END 16
#define GIC_PPI_INTS_START 16
#define GIC_PPI_INTS_END 32
#define GIC_SPI_INTS_START 32
#define GIC_SPI_INTS_END 64
#define GIC_MAX_INT GIC_SPI_INTS_END
#define GIC_MAX_PRIO 16
#define GIC_TIMER_IRQ 27
#define ICC_PMR_EL1 "S3_0_C4_C6_0"
#define ICC_IAR0_EL1 "S3_0_C12_C8_0"
#define ICC_EOIR0_EL1 "S3_0_C12_C8_1"
#define ICC_HPPIR0_EL1 "S3_0_C12_C8_2"
#define ICC_BPR0_EL1 "S3_0_C12_C8_3"
//#define ICC_AP0R<n>_EL1
//#define ICC_AP1R<n>_EL1
#define ICC_DIR_EL1 "S3_0_C12_C11_1"
#define ICC_RPR_EL1 "S3_0_C12_C11_3"
#define ICC_SGI1R_EL1 "S3_0_C12_C11_5"
#define ICC_ASGI1R_EL1 "S3_0_C12_C11_6"
#define ICC_SGI0R_EL1 "S3_0_C12_C11_7"
#define ICC_IAR1_EL1 "S3_0_C12_C12_0"
#define ICC_EOIR1_EL1 "S3_0_C12_C12_1"
#define ICC_HPPIR1_EL1 "S3_0_C12_C12_2"
#define ICC_BPR1_EL1 "S3_0_C12_C12_3"
#define ICC_CTLR_EL1 "S3_0_C12_C12_4"
#define ICC_SRE_EL1 "S3_0_C12_C12_5"
#define ICC_IGRPEN0_EL1 "S3_0_C12_C12_6"
#define ICC_IGRPEN1_EL1 "S3_0_C12_C12_7"
#define ICC_SRE_EL2 "S3_4_C12_C9_5"
#define ICC_CTLR_EL3 "S3_6_C12_C12_4"
#define ICC_SRE_EL3 "S3_6_C12_C12_5"
#define ICC_IGRPEN1_EL3 "S3_6_C12_C12_7"
#define ICC_CTLR_EL1_ExtRange U64_FROM_BIT(19)
#define ICC_CTLR_EL1_RSS U64_FROM_BIT(18)
#define ICC_CTLR_EL1_A3V U64_FROM_BIT(15)
#define ICC_CTLR_EL1_SEIS U64_FROM_BIT(14)
#define ICC_CTLR_EL1_IDbits_BITS 3
#define ICC_CTLR_EL1_IDbits_SHIFT 11
#define ICC_CTLR_EL1_IDbits_16 0
#define ICC_CTLR_EL1_IDbits_24 1
#define ICC_CTLR_EL1_PRIbits_BITS 3
#define ICC_CTLR_EL1_PRIbits_SHIFT 8
#define ICC_CTLR_EL1_EOImode U64_FROM_BIT(1)
#define ICC_CTLR_EL1_CBPR U64_FROM_BIT(0)
#define ICC_IGRPENx_ENABLE 1
#define INTID_NO_PENDING 1023
/* GIC Distributor */
#define GICD_CTLR (*(volatile u32 *)(dev_base_pointer(GIC_DIST)))
#define GICD_CTLR_DISABLE 0
#define GICD_CTLR_ENABLEGRP0 1
#define GICD_CTLR_ENABLEGRP1 2
#define GICD_TYPER (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0004))
#define GICD_ITLinesNumber_BITS 5
#define GICD_ITLinesNumber_SHIFT 0
#define GICD_IIDR (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0008))
#define GICD_TYPER2 (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x000c))
#define GICD_STATUSR (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0010))
#define GICD_SETSPI_NSR (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0040))
#define GICD_CLRSPI_NSR (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0048))
#define GICD_SETSPI_SR (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0050))
#define GICD_CLRSPI_SR (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0058))
#define GICD_IGROUPR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0080 + 4 * (n)))
#define GICD_INTS_PER_IGROUP_REG 32
#define GICD_ISENABLER(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0100 + 4 * (n)))
#define GICD_ICENABLER(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0180 + 4 * (n)))
#define GICD_INTS_PER_IENABLE_REG 32
#define GICD_ISPENDR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0200 + 4 * (n)))
#define GICD_ICPENDR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0280 + 4 * (n)))
#define GICD_INTS_PER_IPEND_REG 32
#define GICD_ISACTIVER(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0300 + 4 * (n)))
#define GICD_ICACTIVER(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0380 + 4 * (n)))
#define GICD_IPRIORITYR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0400 + 4 * (n)))
#define GICD_INTS_PER_IPRIORITY_REG 4
#define GICD_ITARGETSR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0800 + 4 * (n)))
#define GICD_INTS_PER_ITARGETS_REG 4
#define GICD_ICFGR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0c00 + 4 * (n)))
#define GICD_INTS_PER_ICFG_REG 16
#define GICD_ICFGR_LEVEL 0
#define GICD_ICFGR_EDGE 2
#define GICD_IGRPMODR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0d00))
#define GICD_NSACR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0e00))
#define GICD_SGIR (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0f00))
#define GICD_CPENDSGIR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0f10))
#define GICD_SPENDSGIR(n) (*(volatile u32 *)(dev_base_pointer(GIC_DIST) + 0x0f20))
#define _GICR_OFFSET (dev_base_pointer(GIC_REDIST) + 0x10000)
#define GICR_IGROUPR (*(volatile u32 *)(_GICR_OFFSET + 0x0080))
#define GICR_INTS_PER_IGROUP_REG 32
#define GICR_ISENABLER (*(volatile u32 *)(_GICR_OFFSET + 0x0100))
#define GICR_ICENABLER (*(volatile u32 *)(_GICR_OFFSET + 0x0180))
#define GICR_INTS_PER_IENABLE_REG 32
#define GICR_ISPENDR (*(volatile u32 *)(_GICR_OFFSET + 0x0200))
#define GICR_ICPENDR (*(volatile u32 *)(_GICR_OFFSET + 0x0280))
#define GICR_INTS_PER_IPEND_REG 32
#define GICR_ISACTIVER (*(volatile u32 *)(_GICR_OFFSET + 0x0300))
#define GICR_ICACTIVER (*(volatile u32 *)(_GICR_OFFSET + 0x0380))
#define GICR_IPRIORITYR (*(volatile u32 *)(_GICR_OFFSET + 0x0400))
#define GICR_INTS_PER_IPRIORITY_REG 4
#define GICR_ITARGETSR (*(volatile u32 *)(_GICR_OFFSET + 0x0800))
#define GICR_INTS_PER_ITARGETS_REG 4
#define GICR_ICFGR (*(volatile u32 *)(_GICR_OFFSET + 0x0c00))
#define GICR_INTS_PER_ICFG_REG 16
#define GICR_ICFGR_LEVEL 0
#define GICR_ICFGR_EDGE 2
/* Legacy (<v3) GICC interface */
#define GIC_CPU_REG(offset) (*(volatile u32 *)(dev_base_pointer(GIC_CPU + (offset))))
#define GICC_CTLR GIC_CPU_REG(0x0000)
#define GICC_CTLR_EOImode 0x100
#define GICC_CTLR_AckCtl 0x004
#define GICC_CTLR_EnableGrp1 0x002
#define GICC_CTLR_EnableGrp0 0x001
#define GICC_PMR GIC_CPU_REG(0x0004)
#define GICC_BPR GIC_CPU_REG(0x0008)
#define GICC_IAR GIC_CPU_REG(0x000c)
#define GICC_EOIR GIC_CPU_REG(0x0010)
#define GICC_RPR GIC_CPU_REG(0x0014)
#define GICC_HPPIR GIC_CPU_REG(0x0018)
#define GICC_ABPR GIC_CPU_REG(0x001c)
#define GICC_AIAR GIC_CPU_REG(0x0020)
#define GICC_AEOIR GIC_CPU_REG(0x0024)
#define GICC_AHPPIR GIC_CPU_REG(0x0028)
#define GICC_APR(n) GIC_CPU_REG(0x00d0 + 4 * (n))
#define GICC_NSAPR(n) GIC_CPU_REG(0x00e0 + 4 * (n))
#define GICC_IIDR GIC_CPU_REG(0x00fc)
#define GICC_IIDR_ProductID_BITS 12
#define GICC_IIDR_ProductID_SHIFT 20
#define GICC_IIDR_Architecture_version_BITS 4
#define GICC_IIDR_Architecture_version_SHIFT 16
#define GICC_IIDR_Revision_BITS 4
#define GICC_IIDR_Revision_SHIFT 12
#define GICC_IIDR_Implementer_BITS 12
#define GICC_IIDR_Implementer_SHIFT 0
#define GICC_DIR GIC_CPU_REG(0x1000)
void gic_disable_int(int irq);
void gic_enable_int(int irq);
void gic_clear_pending_int(int irq);
void gic_set_int_priority(int irq, u32 pri);
void gic_set_int_config(int irq, u32 cfg);
boolean gic_int_is_pending(int irq);
u64 gic_dispatch_int(void);
void gic_eoi(int irq);
void init_gic(void);
#define _GIC_SET_INTFIELD(name, type) void gic_set_int_##name(int irq, u32 v);
_GIC_SET_INTFIELD(priority, IPRIORITY)
_GIC_SET_INTFIELD(config, ICFG)
_GIC_SET_INTFIELD(target, ITARGETS)
#undef _GIC_SET_INTFIELD
| 46.113208 | 93 | 0.740589 |
cae0b139c16902197e4472378cabaa7d3e06f627 | 1,810 | h | C | source/nmt/translate/Translator.h | TestNLPClass/NiuTrans.NMT | 2439764705582e34624e1d76573f193aa22c9457 | [
"Apache-2.0"
] | 1 | 2020-12-07T13:23:22.000Z | 2020-12-07T13:23:22.000Z | source/nmt/translate/Translator.h | TestNLPClass/NiuTrans.NMT | 2439764705582e34624e1d76573f193aa22c9457 | [
"Apache-2.0"
] | null | null | null | source/nmt/translate/Translator.h | TestNLPClass/NiuTrans.NMT | 2439764705582e34624e1d76573f193aa22c9457 | [
"Apache-2.0"
] | 1 | 2020-12-07T13:23:25.000Z | 2020-12-07T13:23:25.000Z | /* NiuTrans.NMT - an open-source neural machine translation system.
* Copyright (C) 2020 NiuTrans Research. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Created by: XIAO Tong (xiaotong@mail.neu.edu.cn) 2019-03-27
* A week with no trips :)
* $Modified by: HU Chi (huchinlp@gmail.com) 2020-06
*/
#ifndef __TESTER_H__
#define __TESTER_H__
#include "Search.h"
#include "DataSet.h"
namespace nmt
{
/* This class translates test sentences with a trained model. */
class Translator
{
public:
/* vocabulary size of the source side */
int vSize;
/* vocabulary size of the target side */
int vSizeTgt;
/* batch size for sentences */
int sentBatch;
/* batch size for words */
int wordBatch;
/* beam size */
int beamSize;
/* for batching */
DataSet batchLoader;
/* decoder for inference */
void* seacher;
public:
/* constructor */
Translator();
/* de-constructor */
~Translator();
/* initialize the model */
void Init(Config& config);
/* test the model */
void Translate(const char* ifn, const char* vfn, const char* ofn,
const char* tfn, Model* model);
/* dump the result into the file */
void Dump(FILE* file, XTensor* output);
};
}
#endif | 23.506494 | 75 | 0.666851 |
9f01075bde3baf629d86917e3134df4a4010a149 | 3,292 | h | C | System/Library/PrivateFrameworks/CarPlaySupport.framework/CarPlaySupport.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 12 | 2019-06-02T02:42:41.000Z | 2021-04-13T07:22:20.000Z | System/Library/PrivateFrameworks/CarPlaySupport.framework/CarPlaySupport.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/CarPlaySupport.framework/CarPlaySupport.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 3 | 2019-06-11T02:46:10.000Z | 2019-12-21T14:58:16.000Z | #import <CarPlaySupport/CPSGridButton.h>
#import <CarPlaySupport/CPSTableCell.h>
#import <CarPlaySupport/CPSButton.h>
#import <CarPlaySupport/CPSVoiceTemplateViewController.h>
#import <CarPlaySupport/CPSVoiceView.h>
#import <CarPlaySupport/CPSPausedCardView.h>
#import <CarPlaySupport/CPSPanButton.h>
#import <CarPlaySupport/CPSPanView.h>
#import <CarPlaySupport/_CPSOverlayTouchBlockingView.h>
#import <CarPlaySupport/CPSOverlayViewController.h>
#import <CarPlaySupport/CPSAnalytics.h>
#import <CarPlaySupport/CPSBannerSource.h>
#import <CarPlaySupport/CPSAbridgableLabel.h>
#import <CarPlaySupport/CPSTemplateInstance.h>
#import <CarPlaySupport/_CPSNudgeTapGestureRecognizer.h>
#import <CarPlaySupport/_CPSNudgeLongPressGestureRecognizer.h>
#import <CarPlaySupport/CPSPanViewController.h>
#import <CarPlaySupport/CPSApplicationStateMonitor.h>
#import <CarPlaySupport/CPSMapButton.h>
#import <CarPlaySupport/CPSInvisibleButton.h>
#import <CarPlaySupport/CPSRouteRowView.h>
#import <CarPlaySupport/CPSAlternateRoutesView.h>
#import <CarPlaySupport/CPSBaseTemplateViewController.h>
#import <CarPlaySupport/CPSNavigator.h>
#import <CarPlaySupport/CPSCardPlatterView.h>
#import <CarPlaySupport/CPSBannerItem.h>
#import <CarPlaySupport/CPSBannerView.h>
#import <CarPlaySupport/CPSLabeledValueView.h>
#import <CarPlaySupport/CPSRouteEstimatesView.h>
#import <CarPlaySupport/CPSGridTemplateView.h>
#import <CarPlaySupport/CPSGridTemplateViewController.h>
#import <CarPlaySupport/CPSSearchTemplateViewController.h>
#import <CarPlaySupport/CPSNavigationAlertQueue.h>
#import <CarPlaySupport/CPSListTemplateViewController.h>
#import <CarPlaySupport/CPSGuidanceBannerView.h>
#import <CarPlaySupport/CPSNavigationAlertView.h>
#import <CarPlaySupport/CPSNavigationAlertProgressView.h>
#import <CarPlaySupport/CPSNavigationAlertFocusButton.h>
#import <CarPlaySupport/CPSNavigationAlertButtonView.h>
#import <CarPlaySupport/CPSNavigationETAView.h>
#import <CarPlaySupport/CPSUtilities.h>
#import <CarPlaySupport/CPSInheritedBackgroundColorView.h>
#import <CarPlaySupport/CPSTableView.h>
#import <CarPlaySupport/CPSPagingControlButton.h>
#import <CarPlaySupport/CPSPagingControlView.h>
#import <CarPlaySupport/CPSSectionedDataSource.h>
#import <CarPlaySupport/CPSHidingLabel.h>
#import <CarPlaySupport/CPSRouteOverviewView.h>
#import <CarPlaySupport/CPSHairlineBorderedView.h>
#import <CarPlaySupport/CPSTripPreviewsCardView.h>
#import <CarPlaySupport/CPSPagingTripPreviewsCardView.h>
#import <CarPlaySupport/CPSRoutePreviewsCardView.h>
#import <CarPlaySupport/CPSTemplateConnectionManager.h>
#import <CarPlaySupport/CPSHairlineView.h>
#import <CarPlaySupport/CPSFullScreenAlertViewController.h>
#import <CarPlaySupport/_CPSFocusHoldingButton.h>
#import <CarPlaySupport/CPSMapTemplateViewController.h>
#import <CarPlaySupport/CPSManeuverView.h>
#import <CarPlaySupport/CPSPrimaryManeuverView.h>
#import <CarPlaySupport/CPSSecondaryManeuverView.h>
#import <CarPlaySupport/CPSUpcomingManeuversCardView.h>
#import <CarPlaySupport/CPSBarButtonItem.h>
#import <CarPlaySupport/CPSBarButton.h>
#import <CarPlaySupport/CPSNavigationCardView.h>
#import <CarPlaySupport/CPSNavigationBar.h>
#import <CarPlaySupport/CPSEventObserver.h>
#import <CarPlaySupport/CPSDataSource.h>
#import <CarPlaySupport/CPSAlertButton.h>
| 47.710145 | 62 | 0.855407 |
9f16405d773f885fc89d110c8a3a82dbf9959d37 | 3,668 | c | C | lib/drivers/display/lws-display.c | tlsa/libwebsockets | bd59a9963ca6d935b9e101d63caa89842c243ccb | [
"Apache-2.0"
] | null | null | null | lib/drivers/display/lws-display.c | tlsa/libwebsockets | bd59a9963ca6d935b9e101d63caa89842c243ccb | [
"Apache-2.0"
] | null | null | null | lib/drivers/display/lws-display.c | tlsa/libwebsockets | bd59a9963ca6d935b9e101d63caa89842c243ccb | [
"Apache-2.0"
] | null | null | null | /*
* lws abstract display
*
* Copyright (C) 2019 - 2022 Andy Green <andy@warmcat.com>
*
* 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.
*/
#include <private-lib-core.h>
static void
sul_autodim_cb(lws_sorted_usec_list_t *sul)
{
lws_display_state_t *lds = lws_container_of(sul, lws_display_state_t,
sul_autodim);
int next_ms = -1;
/* we fire both to dim and to blank... if already in dim state, blank */
switch (lds->state) {
case LWSDISPS_BECOMING_ACTIVE:
lws_display_state_set_brightness(lds, lds->disp->bl_active);
lds->state = LWSDISPS_ACTIVE;
next_ms = lds->autodim_ms;
break;
case LWSDISPS_ACTIVE:
/* active -> autodimmed */
lds->state = LWSDISPS_AUTODIMMED;
next_ms = lds->off_ms;
lws_display_state_set_brightness(lds, lds->disp->bl_dim);
break;
case LWSDISPS_AUTODIMMED:
/* dimmed -> OFF */
lws_display_state_set_brightness(lds, &lws_pwmseq_static_off);
lds->state = LWSDISPS_GOING_OFF;
next_ms = 600;
break;
case LWSDISPS_GOING_OFF:
/* off dimming completed, actual display OFF */
lws_display_state_off(lds);
return;
default:
return;
}
if (next_ms >= 0)
lws_sul_schedule(lds->ctx, 0, &lds->sul_autodim, sul_autodim_cb,
next_ms * LWS_US_PER_MS);
}
void
lws_display_state_init(lws_display_state_t *lds, struct lws_context *ctx,
int dim_ms, int off_ms, struct lws_led_state *bl_lcs,
const lws_display_t *disp)
{
memset(lds, 0, sizeof(*lds));
lds->disp = disp;
lds->ctx = ctx;
lds->autodim_ms = dim_ms;
lds->off_ms = off_ms;
lds->bl_lcs = bl_lcs;
lds->state = LWSDISPS_OFF;
lws_led_transition(lds->bl_lcs, "backlight", &lws_pwmseq_static_off,
&lws_pwmseq_static_on);
disp->init(lds);
}
void
lws_display_state_set_brightness(lws_display_state_t *lds,
const lws_led_sequence_def_t *pwmseq)
{
lws_led_transition(lds->bl_lcs, "backlight", pwmseq,
lds->disp->bl_transition);
}
void
lws_display_state_active(lws_display_state_t *lds)
{
int waiting_ms;
if (lds->state == LWSDISPS_OFF) {
/* power us up */
lds->disp->power(lds, 1);
lds->state = LWSDISPS_BECOMING_ACTIVE;
waiting_ms = lds->disp->latency_wake_ms;
} else {
if (lds->state != LWSDISPS_ACTIVE)
lws_display_state_set_brightness(lds,
lds->disp->bl_active);
lds->state = LWSDISPS_ACTIVE;
waiting_ms = lds->autodim_ms;
}
/* reset the autodim timer */
if (waiting_ms >= 0)
lws_sul_schedule(lds->ctx, 0, &lds->sul_autodim, sul_autodim_cb,
waiting_ms * LWS_US_PER_MS);
}
void
lws_display_state_off(lws_display_state_t *lds)
{
lds->disp->power(lds, 0);
lws_sul_cancel(&lds->sul_autodim);
lds->state = LWSDISPS_OFF;
}
| 27.787879 | 79 | 0.727644 |
88c06fd78f3883cdceae8e9ddb814e7027da6c22 | 3,754 | h | C | LibGraphics/Shaders/Wm5VisualEffect.h | bazhenovc/WildMagic | b1a7cc2140dde23d8d9a4ece52a07bd5ff938239 | [
"BSL-1.0"
] | 48 | 2015-10-07T07:26:14.000Z | 2022-03-18T14:30:07.000Z | LibGraphics/Shaders/Wm5VisualEffect.h | zouxiaohang/WildMagic | b1a7cc2140dde23d8d9a4ece52a07bd5ff938239 | [
"BSL-1.0"
] | null | null | null | LibGraphics/Shaders/Wm5VisualEffect.h | zouxiaohang/WildMagic | b1a7cc2140dde23d8d9a4ece52a07bd5ff938239 | [
"BSL-1.0"
] | 21 | 2015-09-01T03:14:47.000Z | 2022-01-04T04:07:46.000Z | // Geometric Tools, LLC
// Copyright (c) 1998-2012
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.2 (2012/07/01)
#ifndef WM5VISUALEFFECT_H
#define WM5VISUALEFFECT_H
#include "Wm5GraphicsLIB.h"
#include "Wm5FileIO.h"
#include "Wm5VisualTechnique.h"
namespace Wm5
{
class WM5_GRAPHICS_ITEM VisualEffect : public Object
{
WM5_DECLARE_RTTI;
WM5_DECLARE_NAMES;
WM5_DECLARE_STREAM(VisualEffect);
public:
// Construction and destruction.
VisualEffect ();
virtual ~VisualEffect ();
// Support for deferred construction. The function appends the new
// technique to the end of the array.
void InsertTechnique (VisualTechnique* technique);
// Member access.
inline int GetNumTechniques () const;
VisualTechnique* GetTechnique (int techniqueIndex) const;
// Access to components of the effect.
int GetNumPasses (int techniqueIndex) const;
VisualPass* GetPass (int techniqueIndex, int passIndex) const;
VertexShader* GetVertexShader (int techniqueIndex, int passIndex) const;
PixelShader* GetPixelShader (int techniqueIndex, int passIndex) const;
AlphaState* GetAlphaState (int techniqueIndex, int passIndex) const;
CullState* GetCullState (int techniqueIndex, int passIndex) const;
DepthState* GetDepthState (int techniqueIndex, int passIndex) const;
OffsetState* GetOffsetState (int techniqueIndex, int passIndex) const;
StencilState* GetStencilState (int techniqueIndex, int passIndex) const;
WireState* GetWireState (int techniqueIndex, int passIndex) const;
protected:
std::vector<VisualTechniquePtr> mTechniques;
// Support for the raw load/save of VisualEffect.
public:
// Load/save a visual effect from/to a *.wmfx file outside the
// streaming system.
static VisualEffect* LoadWMFX (const std::string& name,
int mode = FileIO::FM_DEFAULT_READ);
void SaveWMFX (const std::string& name,
int mode = FileIO::FM_DEFAULT_WRITE);
protected:
// For derived classes to load the effect from a *.wmfx file.
VisualEffect (const std::string& name,
int mode = FileIO::FM_DEFAULT_READ);
private:
static VisualTechnique* LoadVisualTechnique (FileIO& inFile);
static VisualPass* LoadVisualPass (FileIO& inFile);
static Shader* LoadShader (FileIO& inFile, bool isVertexShader);
static AlphaState* LoadAlphaState (FileIO& inFile);
static CullState* LoadCullState (FileIO& inFile);
static DepthState* LoadDepthState (FileIO& inFile);
static OffsetState* LoadOffsetState (FileIO& inFile);
static StencilState* LoadStencilState (FileIO& inFile);
static WireState* LoadWireState (FileIO& inFile);
static std::string LoadStdString (FileIO& inFile);
static void SaveVisualTechnique (FileIO& outFile,
VisualTechnique* technique);
static void SaveVisualPass (FileIO& outFile, VisualPass* pass);
static void SaveShader (FileIO& outFile, Shader* shader);
static void SaveAlphaState (FileIO& outFile, AlphaState* astate);
static void SaveCullState (FileIO& outFile, CullState* cstate);
static void SaveDepthState (FileIO& outFile, DepthState* dstate);
static void SaveOffsetState (FileIO& outFile, OffsetState* ostate);
static void SaveStencilState (FileIO& outFile, StencilState* sstate);
static void SaveWireState (FileIO& outFile, WireState* wstate);
static void SaveStdString (FileIO& outFile, std::string& name);
// End support for raw load/save.
};
WM5_REGISTER_STREAM(VisualEffect);
typedef Pointer0<VisualEffect> VisualEffectPtr;
#include "Wm5VisualEffect.inl"
}
#endif
| 36.803922 | 74 | 0.739212 |
7af88e28f9c74728ea2f28c5843ccb50a351da93 | 886 | h | C | ios/RNMonthPicker+Toolbar.h | vuduc4793/react-native-month-year-picker | b485a9ef4277ded274873fc68cc87b7cc2c720e9 | [
"MIT"
] | 68 | 2020-05-22T08:59:43.000Z | 2022-03-29T14:05:16.000Z | ios/RNMonthPicker+Toolbar.h | vuduc4793/react-native-month-year-picker | b485a9ef4277ded274873fc68cc87b7cc2c720e9 | [
"MIT"
] | 102 | 2020-05-22T12:56:58.000Z | 2022-03-22T11:48:39.000Z | ios/RNMonthPicker+Toolbar.h | vuduc4793/react-native-month-year-picker | b485a9ef4277ded274873fc68cc87b7cc2c720e9 | [
"MIT"
] | 35 | 2020-06-12T14:05:01.000Z | 2022-03-28T20:17:36.000Z | //
// RNMonthPicker+Toolbar.h
// Pods
//
// Created by Gustavo Paris on 22/09/2020.
//
#import <UIKit/UIKit.h>
#import <React/UIView+React.h>
@interface RNMonthPickerToolbar : UIView
@property (nonatomic, copy) RCTBubblingEventBlock onCancel;
@property (nonatomic, copy) RCTBubblingEventBlock onDone;
@property (nonatomic, copy) RCTBubblingEventBlock onNeutral;
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
@property (nonatomic, assign) NSDate* value;
@property (nonatomic, assign) NSDate* minimumDate;
@property (nonatomic, assign) NSDate* maximumDate;
@property (nonatomic, assign) NSString* mode;
@property (nonatomic, assign) NSString* okButtonLabel;
@property (nonatomic, assign) NSString* cancelButtonLabel;
@property (nonatomic, assign) NSString* neutralButtonLabel;
@property (nonatomic, assign) BOOL autoTheme;
- (void)setLocale:(NSLocale *)locale;
@end
| 30.551724 | 60 | 0.774266 |
9b8ddaf1390f69c8504ec4a3c31d6bc511716ce2 | 1,791 | h | C | include/Renderer/renderWindow.h | ThomasMontanoGames/Rune | fc23eac324e2381f4c5fddce5a1b3a805bed34bd | [
"Apache-2.0"
] | 3 | 2020-10-05T00:09:43.000Z | 2021-06-01T23:11:54.000Z | include/Renderer/renderWindow.h | ThomasMontanoGames/Rune | fc23eac324e2381f4c5fddce5a1b3a805bed34bd | [
"Apache-2.0"
] | null | null | null | include/Renderer/renderWindow.h | ThomasMontanoGames/Rune | fc23eac324e2381f4c5fddce5a1b3a805bed34bd | [
"Apache-2.0"
] | null | null | null | /**
* @class rune::RenderWindow
* @brief A window that the game can be drawn to.
*
* @author Thomas Montano
* @date April 20 2020
*/
#ifndef RENDER_WINDOW_H
#define RENDER_WINDOW_H
#include "core.h"
#include "color.h"
#include <vector>
#include "Math\vec2.h"
#include <Renderer\camera.h>
#include <string>
struct GLFWwindow;
namespace rune{
class Drawable;
class RUNE_ENGINE RenderWindow
{
private:
bool windowOpen;
int width, height;
GLFWwindow* GLwindow;
Camera* windowCamera;
///Resize the drawing area if the window is resized
static void onWindowResize(GLFWwindow* window, int width, int height);
public:
///Get the camera currently being used by the scene.
Camera getCamera(void);
///Set a camera to be used by the scene.
void setCamera(Camera&);
///Default constructor to give an openGL context and window.
RenderWindow(int newWidth, int newHeight, std::string const& title);
///Destructor to handle window clean up.
~RenderWindow(void);
///Renders a drawable to the screen.
void draw(Drawable&);
///Set the window title.
void setWindowTitle(std::string const&);
///Display on screen what has been rendered to the window so far.
void display(void);
///Clear the entire screen with a single color.
void clear(rune::Color);
///Tell whether or not the window is open.
bool isOpen(void);
///Gets the current size of the RenderWindow.
rune::Vec2 getSize(void);
///Enables or disables Vsync.
void enableVsync(bool enable);
///Close the window
void close(void);
///Return a pointer to the OpenGL window.
GLFWwindow* GetGLWindow();
///Returns the size of the current monitor in pixels
static rune::Vec2 getDesktopSize(void);
///Maximize the currently open window
void maximizeWindow(void);
};
}
#endif | 24.875 | 72 | 0.718035 |
c61696f02de82992ec54f927e9754e41a764fed5 | 4,565 | c | C | thingml_xpath.c | SINTEF-9012/thingml-xpath.c-value | 981fefed418be187f49965dc9bd4d14514ef101f | [
"MIT"
] | 1 | 2015-09-02T16:18:45.000Z | 2015-09-02T16:18:45.000Z | thingml_xpath.c | SINTEF-9012/thingml-xpath.c-value | 981fefed418be187f49965dc9bd4d14514ef101f | [
"MIT"
] | null | null | null | thingml_xpath.c | SINTEF-9012/thingml-xpath.c-value | 981fefed418be187f49965dc9bd4d14514ef101f | [
"MIT"
] | null | null | null | /*
* thingml_xpath.c
*
* Created on: Sep 2, 2015
* Author: vassik
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxml/xmlstring.h>
#include "thingml_xpath.h"
xmlXPathObjectPtr evaluate_expression(xmlChar** xpathExpr,
xmlXPathContextPtr* xpathCtx, xmlXPathObjectPtr* xpathObj,
const char* xml_content, const char* xpath, void* parser_context);
void parse_integer(const char* xml_content, const char* xpath, void* parser_context) {
xmlChar* xpathExpr = BAD_CAST xpath;
xmlXPathContextPtr xpathCtx = NULL;
xmlXPathObjectPtr xpathObj = NULL;
xpathObj = evaluate_expression(&xpathExpr, &xpathCtx, &xpathObj, xml_content, xpath, parser_context);
if(xpathObj) {
ThingMLXPATHParserCnxt * context = (ThingMLXPATHParserCnxt*) parser_context;
int value = (int)floor(xpathObj->floatval);
context->fn_parse_integer_callback(context->thing_instance, value);
/* Cleanup */
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
}
}
void parse_double(const char* xml_content, const char* xpath, void* parser_context) {
xmlChar* xpathExpr = BAD_CAST xpath;
xmlXPathContextPtr xpathCtx = NULL;
xmlXPathObjectPtr xpathObj = NULL;
xpathObj = evaluate_expression(&xpathExpr, &xpathCtx, &xpathObj, xml_content, xpath, parser_context);
if(xpathObj) {
ThingMLXPATHParserCnxt * context = (ThingMLXPATHParserCnxt*) parser_context;
context->fn_parse_double_callback(context->thing_instance, xpathObj->floatval);
/* Cleanup */
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
}
}
void parse_string(const char* xml_content, const char* xpath, void* parser_context) {
xmlChar* xpathExpr = BAD_CAST xpath;
xmlXPathContextPtr xpathCtx = NULL;
xmlXPathObjectPtr xpathObj = NULL;
xpathObj = evaluate_expression(&xpathExpr, &xpathCtx, &xpathObj, xml_content, xpath, parser_context);
if(xpathObj) {
ThingMLXPATHParserCnxt * context = (ThingMLXPATHParserCnxt*) parser_context;
context->fn_parse_string_callback(context->thing_instance, (char *) xpathObj->stringval);
/* Cleanup */
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
}
}
void parse_boolean(const char* xml_content, const char* xpath, void* parser_context) {
xmlChar* xpathExpr = BAD_CAST xpath;
xmlXPathContextPtr xpathCtx = NULL;
xmlXPathObjectPtr xpathObj = NULL;
xpathObj = evaluate_expression(&xpathExpr, &xpathCtx, &xpathObj, xml_content, xpath, parser_context);
if(xpathObj) {
ThingMLXPATHParserCnxt * context = (ThingMLXPATHParserCnxt*) parser_context;
if(strcmp((char *) xpathObj->stringval, "true") == 0 || strcmp((char *) xpathObj->stringval, "false") == 0) {
int value = (strcmp((char *) xpathObj->stringval, "true") == 0) ? 1 : 0;
context->fn_parse_boolean_callback(context->thing_instance, value);
} else {
fprintf(stderr,"Error: value is neither false nor true '%s'\n", (char *) xpathObj->stringval);
context->fn_onerror_callback(context->thing_instance);
}
/* Cleanup */
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
}
}
xmlXPathObjectPtr evaluate_expression(xmlChar** xpathExpr,
xmlXPathContextPtr* xpathCtx, xmlXPathObjectPtr* xpathObj,
const char* xml_content, const char* xpath, void* parser_context) {
xmlDocPtr doc = xmlParseMemory(xml_content, strlen(xml_content));
ThingMLXPATHParserCnxt * context = (ThingMLXPATHParserCnxt*) parser_context;
if (doc == NULL) {
fprintf(stderr, "Error: unable to parse string \"%s\"\n", xml_content);
context->fn_onerror_callback(context->thing_instance);
return NULL;
}
/* Create xpath evaluation context */
*xpathCtx = xmlXPathNewContext(doc);
if(*xpathCtx == NULL) {
fprintf(stderr,"Error: unable to create new XPath context\n");
xmlFreeDoc(doc);
context->fn_onerror_callback(context->thing_instance);
return NULL;
}
/* Evaluate xpath expression */
*xpathObj = xmlXPathEvalExpression(*xpathExpr, *xpathCtx);
if(*xpathObj == NULL) {
fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", *xpathExpr);
xmlXPathFreeContext(*xpathCtx);
xmlFreeDoc(doc);
context->fn_onerror_callback(context->thing_instance);
return NULL;
}
xmlFreeDoc(doc);
return *xpathObj;
}
| 32.607143 | 114 | 0.709091 |
18c2a5c5f403f07e7c43b599b7c2a73f9de3fe3f | 10,927 | c | C | 2_usb_device/lib_mem/cf/cf.c | rw-hsma-fpga/grub-switch | 299df9b84a125ef2a5820660502dedcec34092ee | [
"MIT"
] | 20 | 2020-07-22T19:25:22.000Z | 2022-03-28T18:10:39.000Z | 2_usb_device/lib_mem/cf/cf.c | rw-hsma-fpga/grub-switch | 299df9b84a125ef2a5820660502dedcec34092ee | [
"MIT"
] | null | null | null | 2_usb_device/lib_mem/cf/cf.c | rw-hsma-fpga/grub-switch | 299df9b84a125ef2a5820660502dedcec34092ee | [
"MIT"
] | null | null | null | /*This file is prepared for Doxygen automatic documentation generation.*/
//! \file *********************************************************************
//!
//! \brief This file contains the low-level dataflash routines
//!
//! - Compiler: IAR EWAVR and GNU GCC for AVR
//! - Supported devices: AT90USB1287, AT90USB1286, AT90USB647, AT90USB646
//!
//! \author Atmel Corporation: http://www.atmel.com \n
//! Support and FAQ: http://support.atmel.no/
//!
//! ***************************************************************************
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an Atmel
* AVR product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
* SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
*/
//_____ I N C L U D E S ____________________________________________________
#include "config.h" // system configuration
#include "lib_mcu/usb/usb_drv.h" // usb driver definition
#include "cf.h" // dataflash definition
#include "fat12_data.h"
#include "boot_choice.h"
void cf_init (void)
{
boot_choice_init();
U16 file_size = eeprom_read_word((const uint16_t*)1022);
// limit file size to maximum if stored too big
if (file_size > 960)
file_size = 960;
set_entryfile_size(file_size);
parse_entry_file();
build_bootfile_parameters(get_boot_choice());
}
//! This function performs a memory check on all DF.
//!
//!
//! @return bit
//! The memory is ready -> OK
//! The memory check failed -> KO
//!
Bool cf_mem_check (void)
{
// CF memory check.
return OK;
}
//! This function is optimized and writes nb-sector * 512 Bytes from DataFlash memory to USB controller
//!
//! NOTE:
//! - First call must be preceded by a call to the cf_read_open() function,
//! - The USB EPIN must have been previously selected,
//! - USB ping-pong buffers are free,
//! - As 512 is always a sub-multiple of page size, there is no need to check
//! page end for each Bytes,
//! - Interrupts are disabled during transfer to avoid timer interrupt,
//! - nb_sector always >= 1, cannot be zero.
//!
//! @param nb_sector number of contiguous sectors to read [IN]
//!
//! @return The read succeeded -> OK
//!
Bool cf_read_sector (U32 pos, Uint16 nb_sector)
{
U8 i, j;
// Set the global memory ptr at a Byte address.
U16 sector_address = (pos << CF_LOG2_FAT12_SECTOR_SIZE);
build_bootfile_parameters(get_boot_choice());
Led_on();
do
{
// make copy of sector start
U16 curr_read_addr = sector_address;
for (i = 8; i != 0; i--)
{
Disable_interrupt(); // Global disable.
for(j=0;j<64;j++)
{
// bootsector
if (curr_read_addr <= 0x00bf)
Usb_write_byte(pgm_read_byte(sector0 + curr_read_addr));
// partition table marker and cluster map
else if ((curr_read_addr >= 0x01fe) && (curr_read_addr <= 0x0208))
Usb_write_byte(pgm_read_byte(pt_cluster + curr_read_addr - 0x01fe));
// file size of 'SWITCH.GRB' in root directory
else if (curr_read_addr == SWITCH_GRB_SIZE_ADDR)
{
U16 file_size = get_bootfile_size();
Usb_write_byte(LSB(file_size));
j++; curr_read_addr++; // double-byte write, skip one loop iteration
Usb_write_byte(MSB(file_size));
}
// file size of '.entries.txt' in root directory
else if (curr_read_addr == ENTRIES_TXT_SIZE_ADDR)
{
U16 file_size = get_entryfile_size();
Usb_write_byte(LSB(file_size));
j++; curr_read_addr++; // double-byte write, skip one loop iteration
Usb_write_byte(MSB(file_size));
}
// root directory except file sizes of 'SWITCH.GRB', '.entries.txt'
else if ((curr_read_addr >= 0x0400) && (curr_read_addr <= 0x04bf))
{
U8 dir_table_buf = pgm_read_byte(dir_table + curr_read_addr - 0x0400);
if (curr_read_addr == 0x046b) // if .entries.txt attributes
if (0 == read_wrprot_pin()) // if write protect switched on (pin low)
dir_table_buf |= 0x1; // set read-only attribute
Usb_write_byte(dir_table_buf);
}
// 'SWITCH.GRB' boot file: Parameters from EEPROM file, template from PROGMEM
else if ( (curr_read_addr >= SWITCH_GRB_ADDR) && (curr_read_addr < (SWITCH_GRB_ADDR + get_bootfile_size() )) )
Usb_write_byte(read_file_SWITCH_GRB(curr_read_addr - SWITCH_GRB_ADDR));
// file '.entries.txt'; maximum size is 960 bytes, 64 bytes in EEPROM reserved
else if ((curr_read_addr >= ENTRIES_TXT_ADDR) && (curr_read_addr < (ENTRIES_TXT_ADDR + 960)))
Usb_write_byte(read_entry_file(curr_read_addr - ENTRIES_TXT_ADDR));
// file '.bootpins.txt' - data is changed based on switch bits
else if ((curr_read_addr >= BOOTPINS_TXT_ADDR) && (curr_read_addr < (BOOTPINS_TXT_ADDR + 0x12)))
Usb_write_byte(read_file_BOOTPINS_TXT(curr_read_addr - BOOTPINS_TXT_ADDR));
else
Usb_write_byte(0x00);
curr_read_addr++;
}
Usb_send_in(); // Send the FIFO IN content to the USB Host.
Enable_interrupt(); // Global interrupt re-enable.
// Wait until the tx is done so that we may write to the FIFO IN again.
while(Is_usb_write_enabled()==FALSE)
{
if(!Is_usb_endpoint_enabled())
return KO; // USB Reset
}
}
sector_address += CF_FAT12_SECTOR_SIZE; // increment global address pointer
nb_sector--; // 1 more sector read
}
while (nb_sector != 0);
Led_off();
return OK;
}
//! This function is optimized and writes nb-sector * 512 Bytes from USB controller to DataFlash memory
//!
//! NOTE:
//! - First call must be preceded by a call to the cf_write_open() function,
//! - As 512 is always a sub-multiple of page size, there is no need to check
//! page end for each Bytes,
//! - The USB EPOUT must have been previously selected,
//! - Interrupts are disabled during transfer to avoid timer interrupt,
//! - nb_sector always >= 1, cannot be zero.
//!
//! @param nb_sector number of contiguous sectors to write [IN]
//!
//! @return The write succeeded -> OK
//!
Bool cf_write_sector (U32 pos, Uint16 nb_sector)
{
U8 i, j;
// Set the global memory ptr at a Byte address.
U16 sector_address = (pos << CF_LOG2_FAT12_SECTOR_SIZE);
Bool write_protected = (0 == read_wrprot_pin());
Led_on();
do
{
// make copy of sector start
U16 curr_write_addr = sector_address;
//# Write 8x64b = 512b from the USB FIFO OUT.
for (i = 8; i != 0; i--)
{
// Wait end of rx in USB EPOUT.
while(!Is_usb_read_enabled())
{
if(!Is_usb_endpoint_enabled())
return KO; // USB Reset
}
Disable_interrupt(); // Global disable.
U8 usb_rx_buffer[64];
if (write_protected)
{
// empty buffer, don't use data though
for(j=0;j<64;j++)
usb_rx_buffer[j] = Usb_read_byte();
}
else
{
for(j=0;j<64;j++)
{
usb_rx_buffer[j] = Usb_read_byte();
// file size of '.entries.txt' in root directory
if (curr_write_addr == ENTRIES_TXT_SIZE_ADDR)
{
U16 file_size;
LSB(file_size) = usb_rx_buffer[j];
j++; curr_write_addr++; // double-byte access, skip one loop iteration
usb_rx_buffer[j] = Usb_read_byte();
MSB(file_size) = usb_rx_buffer[j];
// limit file size to maximum if stored too big
if (file_size > 960)
file_size = 960;
set_entryfile_size(file_size);
eeprom_write_word((uint16_t*)1022, file_size);
parse_entry_file();
build_bootfile_parameters(get_boot_choice());
}
curr_write_addr++;
}
// copy 64 bytes to EEPROM if it was file .entries.txt
U16 last_block_address = curr_write_addr - 64;
if ( (last_block_address >= ENTRIES_TXT_ADDR) && (last_block_address < (ENTRIES_TXT_ADDR + 960) ))
eeprom_write_block((U8*)usb_rx_buffer, (U8*)(last_block_address-ENTRIES_TXT_ADDR), 64);
}
Usb_ack_receive_out(); // USB EPOUT read acknowledgement.
Enable_interrupt(); // Global re-enable.
} // for (i = 8; i != 0; i--)
sector_address += 512; // Update the memory pointer.
nb_sector--; // 1 more sector written
}
while (nb_sector != 0);
Led_off();
return OK; // Write done
}
| 35.82623 | 123 | 0.584241 |
b72686a72ae38d6367cb0005a02300240a5a8120 | 6,208 | c | C | module/ngx_http_webshell_module.c | maverickplusplus/shellwithwsshd | f32f4c06c160e9bad49b0d8a0ad96e5e697761f5 | [
"MIT"
] | 25 | 2018-12-17T03:50:38.000Z | 2022-03-08T08:31:02.000Z | module/ngx_http_webshell_module.c | maverickplusplus/shellwithwsshd | f32f4c06c160e9bad49b0d8a0ad96e5e697761f5 | [
"MIT"
] | null | null | null | module/ngx_http_webshell_module.c | maverickplusplus/shellwithwsshd | f32f4c06c160e9bad49b0d8a0ad96e5e697761f5 | [
"MIT"
] | 8 | 2019-05-31T09:37:21.000Z | 2021-11-06T12:30:28.000Z | /**
* Nginx HTTP Application Module
* Embed Application into Nginx (GET/POST/WebSocket)
*
* Author: CUI Wei <ghostplant@qq.com>
* Copyright (C) 2016.12 - ..
*
* The MIT License (MIT)
*/
#include <pty.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
#include "ngx_http_webshell_module.h"
typedef struct {
ngx_connection_t conn;
ngx_event_t in, out;
pid_t pid;
u_short width, height;
u_char inbuf[1 << 18];
FILE *upload;
} shell_ctx_t;
typedef struct pid_entry_s {
pid_t pid;
ngx_http_request_t *r;
struct pid_entry_s *next;
} pid_entry_t;
static pid_entry_t pids;
void ngx_pty_recv(ngx_event_t *ev) {
ngx_http_request_t *r = ev->data;
shell_ctx_t *ctx = ngx_get_session(r);
if (!ctx->in.available)
return;
ssize_t n = read(ctx->conn.fd, ctx->inbuf + 1, sizeof(ctx->inbuf) - 1);
if (n < 0)
return;
if (n == 0) {
ngx_websocket_do_close(r);
return;
}
*ctx->inbuf = 'y';
if (ngx_websocket_do_send(r, ctx->inbuf, n + 1) != NGX_OK) {
ngx_websocket_do_close(r);
return;
}
ctx->in.available = 0;
}
void ngx_signal_handler(ngx_event_t *ev) {
int status;
volatile pid_t pid;
pid_entry_t *p, *q;
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
for (p = &pids; p->next != NULL; p = p->next)
if (p->next->pid == pid) {
q = p->next;
ngx_websocket_do_close(q->r);
p->next = q->next;
ngx_free(q);
--pids.pid;
break;
}
}
}
void signal_hander() {
ngx_notify(ngx_signal_handler);
}
const char *get_home() {
static char home[256] = "/home/";
if (!home[6]) {
FILE *fp = popen("whoami", "r");
if (!fp || !fread(home + 6, 1, sizeof(home) - 6, fp)) {
if (fp)
pclose(fp);
return NULL;
}
home[sizeof(home) - 1] = 0;
size_t i;
for (i = 0; i < sizeof(home); ++i)
if (home[i] == '\n') {
home[i] = 0;
break;
}
pclose(fp);
fflush(stdout);
if (!strcmp(home + 6, "root"))
home[1] = 'r', home[2] = 'o', home[3] = 'o', home[4] = 't', home[5] = 0;
}
return home;
}
void ngx_websocket_on_open(ngx_http_request_t *r) {
shell_ctx_t *ctx = ngx_pcalloc(r->pool, sizeof(shell_ctx_t));
if (ctx == NULL) {
ngx_websocket_do_close(r);
return;
}
if (!ngx_strncmp(r->uri.data, (u_char*)"/upload", sizeof("/upload") - 1)) {
ngx_set_session(r, ctx);
return;
}
pid_entry_t *p = ngx_alloc(sizeof(pid_entry_t), ngx_cycle->log);
if (p == NULL) {
ngx_websocket_do_close(r);
return;
}
signal(SIGCHLD, signal_hander);
ctx->conn.read = &ctx->in;
ctx->conn.write = &ctx->out;
ctx->conn.log = r->pool->log;
ctx->in.handler = ngx_pty_recv;
ctx->out.handler = ngx_empty_event_handler;
ctx->in.data = ctx->out.data = r;
ctx->in.log = ctx->out.log = r->pool->log;
ctx->in.available = ctx->out.available = 1;
ctx->pid = forkpty(&ctx->conn.fd, NULL, NULL, NULL);
if (ctx->pid < 0) {
ngx_websocket_do_close(r);
return;
}
const char *home = get_home();
if (!ctx->pid) {
setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 0);
setenv("HOME", home, 0);
setenv("TERM", "xterm", 0);
setenv("LANG", "en_US.UTF-8", 0);
char *sh[] = {"/bin/sh", "-c", "cd ~; umask 022; [ -e /etc/default/locale ] && . /etc/default/locale && export LANG; [ -e /bin/bash ] && exec bash; exec /bin/sh;", NULL};
execvp(*sh, sh);
exit(1);
}
if (ctx->conn.fd <= 0) {
ngx_websocket_do_close(r);
return;
}
p->pid = ctx->pid;
p->r = r;
p->next = pids.next;
pids.next = p;
++pids.pid;
struct termios tios;
tcgetattr(ctx->conn.fd, &tios);
// tios.c_lflag &= ~(ECHO | ECHONL);
tcsetattr(ctx->conn.fd, TCSAFLUSH, &tios);
fcntl(ctx->conn.fd, F_SETFL, fcntl(ctx->conn.fd, F_GETFL, 0) | O_NONBLOCK);
//ngx_add_event(&ctx->conn, NGX_READ_EVENT, 0);
ngx_add_conn(&ctx->conn);
ngx_set_session(r, ctx);
}
void ngx_websocket_on_close(ngx_http_request_t *r) {
shell_ctx_t *ctx = ngx_get_session(r);
if (ctx->upload != NULL) {
fclose(ctx->upload);
ctx->upload = NULL;
return;
}
ngx_del_conn(&ctx->conn, 0);
if (ctx->pid > 0) {
kill(ctx->pid, SIGKILL);
ctx->pid = 0;
}
if (ctx->conn.fd > 0) {
close(ctx->conn.fd);
ctx->conn.fd = 0;
}
}
ngx_int_t ngx_websocket_on_message(ngx_http_request_t *r, u_char *message, size_t len) {
shell_ctx_t *ctx = ngx_get_session(r);
if (ctx->upload != NULL) {
fwrite(message, 1, len, ctx->upload);
if (ngx_websocket_do_send(r, message, 1) != NGX_OK)
return NGX_ERROR;
} else if (*message == 'd') {
if (ctx->conn.fd == 0)
return NGX_ERROR;
size_t ulen = (len - 1) / 2, i;
u_char *umsg = message + 1;
for (i = 0; i < ulen; ++i) {
char a = (umsg[i + i] <= '9') ? (umsg[i + i] - '0') : (umsg[i + i] - 'A' + 10);
char b = (umsg[i + i + 1] <= '9') ? (umsg[i + i + 1] - '0') : (umsg[i + i + 1] - 'A' + 10);
umsg[i] = (a << 4) | b;
}
ssize_t n = write(ctx->conn.fd, umsg, ulen);
if (len > 1 && n <= 0)
return NGX_ERROR;
if (!ctx->in.available) {
ctx->in.available = 1;
ngx_pty_recv(&ctx->in);
}
// FIXME: buffering again message
} else if (*message == 's') {
if (ctx->conn.fd == 0)
return NGX_ERROR;
if (!ctx->in.available) {
ctx->in.available = 1;
ngx_pty_recv(&ctx->in);
}
if (len == 1)
return NGX_OK;
char *p = strchr((char*)message, ',');
if (!p)
return NGX_ERROR;
*p = 0;
u_short layout[4] = {atoi((char*)message + 1), atoi(p + 1), 0, 0};
if (layout[0] != ctx->height || layout[1] != ctx->width) {
ctx->height = layout[0], ctx->width = layout[1];
ioctl(ctx->conn.fd, TIOCSWINSZ, layout);
}
} else if (*message == 'o') {
if (ctx->upload != NULL)
return NGX_ERROR;
if (message[1] == '~' && message[2] == '/') {
const char *home = get_home();
size_t l = strlen(home);
char *buf = (char*)malloc(l + len);
if (!buf)
return NGX_ERROR;
memcpy(buf, home, l);
memcpy(buf + l, message + 2, len - 2);
buf[l + len - 2] = 0;
ctx->upload = fopen(buf, "wb");
free(buf);
} else if (message[1] != '/')
return NGX_ERROR;
else
ctx->upload = fopen((char*)(message + 1), "wb");
if (!ctx->upload)
ngx_websocket_do_close(r);
else if (ngx_websocket_do_send(r, message, 1) != NGX_OK)
return NGX_ERROR;
} else if (*message != 'p')
return NGX_ERROR;
return NGX_OK;
}
| 24.733068 | 172 | 0.595522 |
763c6df35720fc080bc23b04fcee64c04c0ca2c8 | 199 | h | C | screenposition.h | Catishere/TheGame | 9519ea2f2c1b152039b4aa30022f6f7ab94d83ac | [
"MIT"
] | null | null | null | screenposition.h | Catishere/TheGame | 9519ea2f2c1b152039b4aa30022f6f7ab94d83ac | [
"MIT"
] | null | null | null | screenposition.h | Catishere/TheGame | 9519ea2f2c1b152039b4aa30022f6f7ab94d83ac | [
"MIT"
] | null | null | null | #ifndef SCREENPOSITION_H
#define SCREENPOSITION_H
struct ScreenPosition {
float xOffset;
float yOffset;
float scale;
};
typedef struct ScreenPosition scrPos;
#endif // SCREENPOSITION_H
| 16.583333 | 37 | 0.763819 |
49aa6736d6f28725237049a2468377467aedc070 | 2,592 | h | C | DQM/SiStripMonitorClient/interface/SiStripDcsInfo.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | DQM/SiStripMonitorClient/interface/SiStripDcsInfo.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | DQM/SiStripMonitorClient/interface/SiStripDcsInfo.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | #ifndef SiStripMonitorClient_SiStripDcsInfo_h
#define SiStripMonitorClient_SiStripDcsInfo_h
// -*- C++ -*-
//
// Package: SiStripMonitorClient
// Class : SiStripDcsInfo
//
/**\class SiStripDcsInfo SiStripDcsInfo.h DQM/SiStripMonitorCluster/interface/SiStripDcsInfo.h
Description:
Checks the # of SiStrip FEDs from DAQ
Usage:
<usage>
*/
//
// Author: Suchandra Dutta
// Created: Mon Feb 16 19:00:00 CET 2009
//
#include <string>
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
class DQMStore;
class MonitorElement;
class SiStripDetVOff;
class SiStripDetCabling;
class SiStripDcsInfo: public edm::EDAnalyzer {
public:
/// Constructor
SiStripDcsInfo(const edm::ParameterSet& ps);
/// Destructor
virtual ~SiStripDcsInfo();
private:
/// BeginJob
void beginJob();
/// Begin Run
void beginRun(edm::Run const& run, edm::EventSetup const& eSetup);
/// Begin Luminosity Block
void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup) ;
/// End Of Luminosity
void endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup);
/// EndRun
void endRun(edm::Run const& run, edm::EventSetup const& eSetup);
/// Analyze
void analyze(edm::Event const&, edm::EventSetup const&);
private:
void bookStatus();
void readStatus(edm::EventSetup const&);
void readCabling(edm::EventSetup const&);
void addBadModules();
void fillStatus();
void fillDummyStatus();
DQMStore* dqmStore_;
MonitorElement * DcsFraction_;
struct SubDetMEs{
std::string folder_name;
MonitorElement* DcsFractionME;
int TotalDetectors;
std::vector<uint32_t> FaultyDetectors;
std::unordered_map<uint32_t,uint16_t> NLumiDetectorIsFaulty;
};
std::map <std::string, SubDetMEs> SubDetMEsMap;
unsigned long long m_cacheIDCabling_;
unsigned long long m_cacheIDDcs_;
bool bookedStatus_;
edm::ESHandle<SiStripDetVOff> siStripDetVOff_;
int nFEDConnected_;
int nLumiAnalysed_;
bool IsLumiGoodDcs_;
int nGoodDcsLumi_;
float MinAcceptableDcsDetFrac_ = 0.90;
float MaxAcceptableBadDcsLumi_ = 2;
edm::ESHandle< SiStripDetCabling > detCabling_;
};
#endif
| 23.351351 | 97 | 0.736111 |
6f6d486faa305321e6c14e46507fb6011eb61191 | 536 | h | C | MVCTest/PDDetailInfo.h | YiQieSuiYuan/TVLis | eadbe5b57f27fa4c72aaad834bca5dd17d6cc6e6 | [
"Apache-2.0"
] | 7 | 2016-04-05T02:56:41.000Z | 2016-08-23T04:04:42.000Z | MVCTest/PDDetailInfo.h | dev-zlcode/TVList | eadbe5b57f27fa4c72aaad834bca5dd17d6cc6e6 | [
"Apache-2.0"
] | 1 | 2016-05-27T04:07:55.000Z | 2016-05-27T04:07:55.000Z | MVCTest/PDDetailInfo.h | dev-zlcode/TVList | eadbe5b57f27fa4c72aaad834bca5dd17d6cc6e6 | [
"Apache-2.0"
] | 3 | 2016-07-18T00:38:46.000Z | 2021-02-08T02:52:26.000Z | //
// PDDetailInfo.h
// MVCTest
//
// Created by 张雷 on 16/1/9.
// Copyright © 2016年 zhanlgei. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface PDDetailInfo : NSObject
// 节目名
@property (nonatomic,strong) NSString *t;
// 播放时间
@property (nonatomic,strong) NSString *showTime;
// 开始时间
@property (nonatomic,assign) NSInteger st;
// 结束时间
@property (nonatomic,assign) NSInteger et;
// 节目时长
@property (nonatomic,assign) NSInteger duration;
// -1 暂未播放 0 直播 1 回播
@property (nonatomic,assign) NSInteger isLiving;
@end
| 19.142857 | 52 | 0.716418 |
6f877ddb6b4fc513327f06aa90ff7275dc9ea283 | 1,535 | h | C | flare/times/internal/time_zone_fixed.h | flare-rpc/flare-cpp | c1630c7eb8bae0a0b0cee6ec3f13f1babeaef950 | [
"Apache-2.0"
] | 3 | 2022-01-23T17:55:24.000Z | 2022-03-23T12:55:18.000Z | flare/times/internal/time_zone_fixed.h | flare-rpc/flare-cpp | c1630c7eb8bae0a0b0cee6ec3f13f1babeaef950 | [
"Apache-2.0"
] | null | null | null | flare/times/internal/time_zone_fixed.h | flare-rpc/flare-cpp | c1630c7eb8bae0a0b0cee6ec3f13f1babeaef950 | [
"Apache-2.0"
] | null | null | null | // Copyright (c) 2021, gottingen group.
// All rights reserved.
// Created by liyinbin lijippy@163.com
#ifndef FLARE_TIMES_INTERNAL_TIME_ZONE_FIXED_H_
#define FLARE_TIMES_INTERNAL_TIME_ZONE_FIXED_H_
#include <string>
#include "flare/base/profile.h"
#include "flare/times/internal/time_zone.h"
namespace flare::times_internal {
// Helper functions for dealing with the names and abbreviations
// of time zones that are a fixed offset (seconds east) from UTC.
// FixedOffsetFromName() extracts the offset from a valid fixed-offset
// name, while FixedOffsetToName() and FixedOffsetToAbbr() generate
// the canonical zone name and abbreviation respectively for the given
// offset.
//
// A fixed-offset name looks like "Fixed/UTC<+-><hours>:<mins>:<secs>".
// Its abbreviation is of the form "UTC(<+->H?H(MM(SS)?)?)?" where the
// optional pieces are omitted when their values are zero. (Note that
// the sign is the opposite of that used in a POSIX TZ specification.)
//
// Note: FixedOffsetFromName() fails on syntax errors or when the parsed
// offset exceeds 24 hours. FixedOffsetToName() and FixedOffsetToAbbr()
// both produce "UTC" when the argument offset exceeds 24 hours.
bool fixed_offset_from_name(const std::string &name, seconds *offset);
std::string fixed_offset_to_name(const seconds &offset);
std::string fixed_offset_to_abbr(const seconds &offset);
} // namespace flare::times_internal
#endif // FLARE_TIMES_INTERNAL_TIME_ZONE_FIXED_H_
| 40.394737 | 76 | 0.731596 |
e4acd1c1d1ffa33b59b309183f622c6d08e91f21 | 6,129 | c | C | usr/boot_perfmon/connections.c | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 111 | 2015-02-03T02:57:27.000Z | 2022-03-01T23:57:09.000Z | usr/boot_perfmon/connections.c | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 12 | 2016-03-22T14:44:32.000Z | 2020-03-18T13:30:29.000Z | usr/boot_perfmon/connections.c | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 55 | 2015-02-03T05:28:12.000Z | 2022-03-31T05:00:03.000Z | /**
* \file
* \brief
*/
/*
* Copyright (c) 2010, ETH Zurich and Mircosoft Corporation.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
* ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
*/
#include <ctype.h>
#include "internal.h"
#include <barrelfish/nameservice_client.h>
struct bind_state {
coreid_t id;
};
struct coreset *set;
struct relations *rel;
static callback retcb;
static void done_reply(struct boot_perfmon_binding *b)
{
retcb();
}
static errval_t done_msging(void *st, coreid_t id,
struct boot_perfmon_binding *b)
{
return b->tx_vtbl.done_reply(b, NOP_CONT);
}
static void done_request(struct boot_perfmon_binding *b)
{
errval_t err;
static coreid_t count = 0;
count++;
if (count == (coreset_count(set) - 1)) {
err = relations_iterate(rel, NULL, done_msging);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "relations_iterate failed");
}
retcb();
}
}
static void init(struct boot_perfmon_binding *b, coreid_t id)
{
errval_t err;
err = relations_add(rel, id, b);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "relations_add failed");
}
// Check if done connecting
if (relations_count(rel) == (coreset_count(set) - 1)) {
if (!check_leader()) { // Message leader that connect is done
struct boot_perfmon_binding *lb;
err = relations_get(rel, get_leader_id(), &lb);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "relations_get failed");
}
err = lb->tx_vtbl.done_request(lb, NOP_CONT);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "sending done failed");
}
}
}
}
static struct boot_perfmon_rx_vtbl vtbl = {
.init = init,
.done_reply = done_reply,
.done_request = done_request,
.ping = ping,
.pong = pong,
.exit = exit_msg,
};
static void bind_cb(void *st, errval_t err, struct boot_perfmon_binding *b)
{
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "failure in bind_cb");
}
b->rx_vtbl = vtbl;
struct bind_state *bs = st;
err = relations_add(rel, bs->id, b);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "relations_add failed");
}
free(bs);
err = b->tx_vtbl.init(b, NOP_CONT, my_core_id);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "sending init failed");
}
// Check if done connecting
if (relations_count(rel) == (coreset_count(set) - 1)) {
if (!check_leader()) { // Message leader that connect is done
struct boot_perfmon_binding *lb;
err = relations_get(rel, get_leader_id(), &lb);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "relations_get failed");
}
err = lb->tx_vtbl.done_request(lb, NOP_CONT);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "sending done failed");
}
}
}
}
/**
* \brief Connect to every core with id bigger than mine
*/
static errval_t iter_connect(void *st, coreid_t id)
{
errval_t err;
if (my_core_id > id) {
iref_t iref;
char name[128];
snprintf(name, 128, "boot_perfmon:%d", id);
err = nameservice_blocking_lookup(name, &iref);
if (err_is_fail(err)) {
DEBUG_ERR(err, "nameservice_blocking_lookup failed");
abort();
}
struct bind_state *bs = malloc(sizeof(struct bind_state));
if (!bs) {
USER_PANIC("malloc failed");
}
bs->id = id;
err = boot_perfmon_bind(iref, bind_cb, bs, get_default_waitset(),
IDC_BIND_FLAGS_DEFAULT);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "boot_perfmon_bind failed");
}
}
return SYS_ERR_OK;
}
static void export_cb(void *st, errval_t err, iref_t iref)
{
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "export failed");
}
char name[128];
snprintf(name, 128, "boot_perfmon:%d", my_core_id);
err = nameservice_register(name, iref);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "nameservice_register failed");
}
}
static errval_t connect_cb(void *st, struct boot_perfmon_binding *b)
{
b->rx_vtbl = vtbl;
return SYS_ERR_OK;
}
/**
* \brief Find and add all coreids to coreset
*/
static void set_skb_present(char *str)
{
errval_t err;
while (*str != '\0') {
if (!isdigit((int)*str)) {
str++;
continue;
}
coreid_t id = strtol(str, &str, 10);
err = coreset_add(set, id);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "coreset_add failed");
}
}
}
errval_t connect(callback cb)
{
errval_t err;
retcb = cb;
/* Initialize the coreset */
err = coreset_new(&set);
if (err_is_fail(err)) {
return err_push(err, LIB_ERR_CORESET_NEW);
}
/* Initialize the relations */
err = relations_new(&rel);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "export failed");
}
/* Get the list of coreids in the system and add them to the coreset */
char *result, *str_err;
int32_t int_err;
err = skb_evaluate("get_core_id_list(L),write(L).",
&result, &str_err, &int_err);
if (err_is_fail(err)) {
return err_push(err, SKB_ERR_EVALUATE);
}
set_skb_present(result);
free(result);
free(str_err);
/* Export service */
err = boot_perfmon_export(NULL, export_cb, connect_cb,
get_default_waitset(),
IDC_EXPORT_FLAGS_DEFAULT);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "export failed");
}
/* Connect */
err = coreset_iterate(set, NULL, iter_connect);
if (err_is_fail(err)) {
USER_PANIC_ERR(err, "coreset_add failed");
}
return SYS_ERR_OK;
}
| 25.222222 | 81 | 0.590798 |
a516633f25848f6dbfb74e94b5db20535ea6b3ca | 2,125 | h | C | Code/Editor/Include/IErrorReport.h | cypherdotXd/o3de | bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676 | [
"Apache-2.0",
"MIT"
] | 1 | 2022-03-12T14:13:45.000Z | 2022-03-12T14:13:45.000Z | Code/Editor/Include/IErrorReport.h | cypherdotXd/o3de | bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676 | [
"Apache-2.0",
"MIT"
] | 2 | 2022-01-13T04:29:38.000Z | 2022-03-12T01:05:31.000Z | Code/Editor/Include/IErrorReport.h | cypherdotXd/o3de | bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676 | [
"Apache-2.0",
"MIT"
] | null | null | null | /*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Class that collects error reports to present them later.
#ifndef CRYINCLUDE_EDITOR_INTERFACE_ERRORREPORT_H
#define CRYINCLUDE_EDITOR_INTERFACE_ERRORREPORT_H
#pragma once
#include <IValidator.h>
// forward declarations.
class CParticleItem;
class CBaseObject;
class CBaseLibraryItem;
class CErrorRecord;
/*! Error report manages collection of errors occurred during map analyzes or level load.
*/
struct IErrorReport
: public IValidator
{
virtual ~IErrorReport(){}
//! If enabled errors are reported immediately and not stored.
virtual void SetImmediateMode(bool bEnable) = 0;
virtual bool IsImmediateMode() const = 0;
virtual void SetShowErrors(bool bShowErrors = true) = 0;
//! Adds new error to report.
virtual void ReportError(CErrorRecord& err) = 0;
//! Check if error report have any errors.
virtual bool IsEmpty() const = 0;
//! Get number of contained error records.
virtual int GetErrorCount() const = 0;
//! Get access to indexed error record.
virtual CErrorRecord& GetError(int i) = 0;
//! Clear all error records.
virtual void Clear() = 0;
//! Display dialog with all errors.
virtual void Display() = 0;
//! Assign current Object to which new reported warnings are assigned.
virtual void SetCurrentValidatorObject(CBaseObject* pObject) = 0;
//! Assign current Item to which new reported warnings are assigned.
virtual void SetCurrentValidatorItem(CBaseLibraryItem* pItem) = 0;
//! Assign current filename.
virtual void SetCurrentFile(const QString& file) = 0;
//////////////////////////////////////////////////////////////////////////
// Implement IValidator interface.
//////////////////////////////////////////////////////////////////////////
virtual void Report(SValidatorRecord& record) = 0;
};
#endif // CRYINCLUDE_EDITOR_ERRORREPORT_H
| 28.716216 | 100 | 0.671059 |
a5d847f6fafa480522c3e29ccd53c62f59ac526e | 1,152 | h | C | include/snake/engine.h | CS126SP20/snake-pyanda2 | cde0003962ae17c2164ff59149b239f220415dda | [
"MIT"
] | null | null | null | include/snake/engine.h | CS126SP20/snake-pyanda2 | cde0003962ae17c2164ff59149b239f220415dda | [
"MIT"
] | null | null | null | include/snake/engine.h | CS126SP20/snake-pyanda2 | cde0003962ae17c2164ff59149b239f220415dda | [
"MIT"
] | null | null | null | // Copyright (c) 2020 CS126SP20. All rights reserved.
#ifndef SNAKE_ENGINE_H_
#define SNAKE_ENGINE_H_
#include <random>
#include <set>
#include "direction.h"
#include "food.h"
#include "snake.h"
namespace snake {
// This is the game engine which is primary way to interact with the game.
class Engine {
public:
// Creates a new snake game of the given size.
Engine(size_t width, size_t height);
// Creates a new snake game of the given size, seeded.
Engine(size_t width, size_t height, unsigned seed);
// Executes a time step: moves the snake, etc.
void Step();
// Start the game over.
void Reset();
// Changes the direction of the snake for the next time step.
void SetDirection(Direction);
size_t GetScore() const;
Snake GetSnake() const;
Food GetFood() const;
private:
Location GetRandomLocation();
std::set<Location> GetOccupiedTiles();
private:
const size_t width_;
const size_t height_;
Snake snake_;
Food food_;
Direction direction_;
Direction last_direction_;
std::mt19937 rng_;
std::uniform_real_distribution<double> uniform_;
};
} // namespace snake
#endif // SNAKE_ENGINE_H_
| 20.571429 | 74 | 0.717882 |
9d1b6b7c394cfb5eb5ef2968065f97b5f2b875a7 | 9,168 | c | C | linux-4.14.90-dev/linux-4.14.90/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | linux-4.14.90-dev/linux-4.14.90/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 5 | 2020-04-04T09:24:09.000Z | 2020-04-19T12:33:55.000Z | linux-4.14.90-dev/linux-4.14.90/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 30 | 2018-05-02T08:43:27.000Z | 2022-01-23T03:25:54.000Z | /*
* Intel IXP4xx Queue Manager driver for Linux
*
* Copyright (C) 2007 Krzysztof Halasa <khc@pm.waw.pl>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
*/
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <mach/qmgr.h>
static struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
static struct resource *mem_res;
static spinlock_t qmgr_lock;
static u32 used_sram_bitmap[4]; /* 128 16-dword pages */
static void (*irq_handlers[QUEUES])(void *pdev);
static void *irq_pdevs[QUEUES];
#if DEBUG_QMGR
char qmgr_queue_descs[QUEUES][32];
#endif
void qmgr_set_irq(unsigned int queue, int src,
void (*handler)(void *pdev), void *pdev)
{
unsigned long flags;
spin_lock_irqsave(&qmgr_lock, flags);
if (queue < HALF_QUEUES) {
u32 __iomem *reg;
int bit;
BUG_ON(src > QUEUE_IRQ_SRC_NOT_FULL);
reg = &qmgr_regs->irqsrc[queue >> 3]; /* 8 queues per u32 */
bit = (queue % 8) * 4; /* 3 bits + 1 reserved bit per queue */
__raw_writel((__raw_readl(reg) & ~(7 << bit)) | (src << bit),
reg);
} else
/* IRQ source for queues 32-63 is fixed */
BUG_ON(src != QUEUE_IRQ_SRC_NOT_NEARLY_EMPTY);
irq_handlers[queue] = handler;
irq_pdevs[queue] = pdev;
spin_unlock_irqrestore(&qmgr_lock, flags);
}
static irqreturn_t qmgr_irq1_a0(int irq, void *pdev)
{
int i, ret = 0;
u32 en_bitmap, src, stat;
/* ACK - it may clear any bits so don't rely on it */
__raw_writel(0xFFFFFFFF, &qmgr_regs->irqstat[0]);
en_bitmap = qmgr_regs->irqen[0];
while (en_bitmap) {
i = __fls(en_bitmap); /* number of the last "low" queue */
en_bitmap &= ~BIT(i);
src = qmgr_regs->irqsrc[i >> 3];
stat = qmgr_regs->stat1[i >> 3];
if (src & 4) /* the IRQ condition is inverted */
stat = ~stat;
if (stat & BIT(src & 3)) {
irq_handlers[i](irq_pdevs[i]);
ret = IRQ_HANDLED;
}
}
return ret;
}
static irqreturn_t qmgr_irq2_a0(int irq, void *pdev)
{
int i, ret = 0;
u32 req_bitmap;
/* ACK - it may clear any bits so don't rely on it */
__raw_writel(0xFFFFFFFF, &qmgr_regs->irqstat[1]);
req_bitmap = qmgr_regs->irqen[1] & qmgr_regs->statne_h;
while (req_bitmap) {
i = __fls(req_bitmap); /* number of the last "high" queue */
req_bitmap &= ~BIT(i);
irq_handlers[HALF_QUEUES + i](irq_pdevs[HALF_QUEUES + i]);
ret = IRQ_HANDLED;
}
return ret;
}
static irqreturn_t qmgr_irq(int irq, void *pdev)
{
int i, half = (irq == IRQ_IXP4XX_QM1 ? 0 : 1);
u32 req_bitmap = __raw_readl(&qmgr_regs->irqstat[half]);
if (!req_bitmap)
return 0;
__raw_writel(req_bitmap, &qmgr_regs->irqstat[half]); /* ACK */
while (req_bitmap) {
i = __fls(req_bitmap); /* number of the last queue */
req_bitmap &= ~BIT(i);
i += half * HALF_QUEUES;
irq_handlers[i](irq_pdevs[i]);
}
return IRQ_HANDLED;
}
void qmgr_enable_irq(unsigned int queue)
{
unsigned long flags;
int half = queue / 32;
u32 mask = 1 << (queue & (HALF_QUEUES - 1));
spin_lock_irqsave(&qmgr_lock, flags);
__raw_writel(__raw_readl(&qmgr_regs->irqen[half]) | mask,
&qmgr_regs->irqen[half]);
spin_unlock_irqrestore(&qmgr_lock, flags);
}
void qmgr_disable_irq(unsigned int queue)
{
unsigned long flags;
int half = queue / 32;
u32 mask = 1 << (queue & (HALF_QUEUES - 1));
spin_lock_irqsave(&qmgr_lock, flags);
__raw_writel(__raw_readl(&qmgr_regs->irqen[half]) & ~mask,
&qmgr_regs->irqen[half]);
__raw_writel(mask, &qmgr_regs->irqstat[half]); /* clear */
spin_unlock_irqrestore(&qmgr_lock, flags);
}
static inline void shift_mask(u32 *mask)
{
mask[3] = mask[3] << 1 | mask[2] >> 31;
mask[2] = mask[2] << 1 | mask[1] >> 31;
mask[1] = mask[1] << 1 | mask[0] >> 31;
mask[0] <<= 1;
}
#if DEBUG_QMGR
int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
unsigned int nearly_empty_watermark,
unsigned int nearly_full_watermark,
const char *desc_format, const char* name)
#else
int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
unsigned int nearly_empty_watermark,
unsigned int nearly_full_watermark)
#endif
{
u32 cfg, addr = 0, mask[4]; /* in 16-dwords */
int err;
BUG_ON(queue >= QUEUES);
if ((nearly_empty_watermark | nearly_full_watermark) & ~7)
return -EINVAL;
switch (len) {
case 16:
cfg = 0 << 24;
mask[0] = 0x1;
break;
case 32:
cfg = 1 << 24;
mask[0] = 0x3;
break;
case 64:
cfg = 2 << 24;
mask[0] = 0xF;
break;
case 128:
cfg = 3 << 24;
mask[0] = 0xFF;
break;
default:
return -EINVAL;
}
cfg |= nearly_empty_watermark << 26;
cfg |= nearly_full_watermark << 29;
len /= 16; /* in 16-dwords: 1, 2, 4 or 8 */
mask[1] = mask[2] = mask[3] = 0;
if (!try_module_get(THIS_MODULE))
return -ENODEV;
spin_lock_irq(&qmgr_lock);
if (__raw_readl(&qmgr_regs->sram[queue])) {
err = -EBUSY;
goto err;
}
while (1) {
if (!(used_sram_bitmap[0] & mask[0]) &&
!(used_sram_bitmap[1] & mask[1]) &&
!(used_sram_bitmap[2] & mask[2]) &&
!(used_sram_bitmap[3] & mask[3]))
break; /* found free space */
addr++;
shift_mask(mask);
if (addr + len > ARRAY_SIZE(qmgr_regs->sram)) {
printk(KERN_ERR "qmgr: no free SRAM space for"
" queue %i\n", queue);
err = -ENOMEM;
goto err;
}
}
used_sram_bitmap[0] |= mask[0];
used_sram_bitmap[1] |= mask[1];
used_sram_bitmap[2] |= mask[2];
used_sram_bitmap[3] |= mask[3];
__raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]);
#if DEBUG_QMGR
snprintf(qmgr_queue_descs[queue], sizeof(qmgr_queue_descs[0]),
desc_format, name);
printk(KERN_DEBUG "qmgr: requested queue %s(%i) addr = 0x%02X\n",
qmgr_queue_descs[queue], queue, addr);
#endif
spin_unlock_irq(&qmgr_lock);
return 0;
err:
spin_unlock_irq(&qmgr_lock);
module_put(THIS_MODULE);
return err;
}
void qmgr_release_queue(unsigned int queue)
{
u32 cfg, addr, mask[4];
BUG_ON(queue >= QUEUES); /* not in valid range */
spin_lock_irq(&qmgr_lock);
cfg = __raw_readl(&qmgr_regs->sram[queue]);
addr = (cfg >> 14) & 0xFF;
BUG_ON(!addr); /* not requested */
switch ((cfg >> 24) & 3) {
case 0: mask[0] = 0x1; break;
case 1: mask[0] = 0x3; break;
case 2: mask[0] = 0xF; break;
case 3: mask[0] = 0xFF; break;
}
mask[1] = mask[2] = mask[3] = 0;
while (addr--)
shift_mask(mask);
#if DEBUG_QMGR
printk(KERN_DEBUG "qmgr: releasing queue %s(%i)\n",
qmgr_queue_descs[queue], queue);
qmgr_queue_descs[queue][0] = '\x0';
#endif
while ((addr = qmgr_get_entry(queue)))
printk(KERN_ERR "qmgr: released queue %i not empty: 0x%08X\n",
queue, addr);
__raw_writel(0, &qmgr_regs->sram[queue]);
used_sram_bitmap[0] &= ~mask[0];
used_sram_bitmap[1] &= ~mask[1];
used_sram_bitmap[2] &= ~mask[2];
used_sram_bitmap[3] &= ~mask[3];
irq_handlers[queue] = NULL; /* catch IRQ bugs */
spin_unlock_irq(&qmgr_lock);
module_put(THIS_MODULE);
}
static int qmgr_init(void)
{
int i, err;
irq_handler_t handler1, handler2;
mem_res = request_mem_region(IXP4XX_QMGR_BASE_PHYS,
IXP4XX_QMGR_REGION_SIZE,
"IXP4xx Queue Manager");
if (mem_res == NULL)
return -EBUSY;
/* reset qmgr registers */
for (i = 0; i < 4; i++) {
__raw_writel(0x33333333, &qmgr_regs->stat1[i]);
__raw_writel(0, &qmgr_regs->irqsrc[i]);
}
for (i = 0; i < 2; i++) {
__raw_writel(0, &qmgr_regs->stat2[i]);
__raw_writel(0xFFFFFFFF, &qmgr_regs->irqstat[i]); /* clear */
__raw_writel(0, &qmgr_regs->irqen[i]);
}
__raw_writel(0xFFFFFFFF, &qmgr_regs->statne_h);
__raw_writel(0, &qmgr_regs->statf_h);
for (i = 0; i < QUEUES; i++)
__raw_writel(0, &qmgr_regs->sram[i]);
if (cpu_is_ixp42x_rev_a0()) {
handler1 = qmgr_irq1_a0;
handler2 = qmgr_irq2_a0;
} else
handler1 = handler2 = qmgr_irq;
err = request_irq(IRQ_IXP4XX_QM1, handler1, 0, "IXP4xx Queue Manager",
NULL);
if (err) {
printk(KERN_ERR "qmgr: failed to request IRQ%i (%i)\n",
IRQ_IXP4XX_QM1, err);
goto error_irq;
}
err = request_irq(IRQ_IXP4XX_QM2, handler2, 0, "IXP4xx Queue Manager",
NULL);
if (err) {
printk(KERN_ERR "qmgr: failed to request IRQ%i (%i)\n",
IRQ_IXP4XX_QM2, err);
goto error_irq2;
}
used_sram_bitmap[0] = 0xF; /* 4 first pages reserved for config */
spin_lock_init(&qmgr_lock);
printk(KERN_INFO "IXP4xx Queue Manager initialized.\n");
return 0;
error_irq2:
free_irq(IRQ_IXP4XX_QM1, NULL);
error_irq:
release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE);
return err;
}
static void qmgr_remove(void)
{
free_irq(IRQ_IXP4XX_QM1, NULL);
free_irq(IRQ_IXP4XX_QM2, NULL);
synchronize_irq(IRQ_IXP4XX_QM1);
synchronize_irq(IRQ_IXP4XX_QM2);
release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE);
}
module_init(qmgr_init);
module_exit(qmgr_remove);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Krzysztof Halasa");
EXPORT_SYMBOL(qmgr_set_irq);
EXPORT_SYMBOL(qmgr_enable_irq);
EXPORT_SYMBOL(qmgr_disable_irq);
#if DEBUG_QMGR
EXPORT_SYMBOL(qmgr_queue_descs);
EXPORT_SYMBOL(qmgr_request_queue);
#else
EXPORT_SYMBOL(__qmgr_request_queue);
#endif
EXPORT_SYMBOL(qmgr_release_queue);
| 24.579088 | 75 | 0.674193 |
c444c5dbff608b567384ceb81cd10c938100dee2 | 1,503 | c | C | C Programs/interlace-odd-even-from-a-to-b.c | muhammad-masood-ur-rehman/Skillrack | 71a25417c89d0efab40ee6229ccd758b26ae4312 | [
"CC0-1.0"
] | 2 | 2021-06-26T21:50:59.000Z | 2021-09-18T04:55:51.000Z | C Programs/interlace-odd-even-from-a-to-b.c | muhammad-masood-ur-rehman/Skillrack | 71a25417c89d0efab40ee6229ccd758b26ae4312 | [
"CC0-1.0"
] | null | null | null | C Programs/interlace-odd-even-from-a-to-b.c | muhammad-masood-ur-rehman/Skillrack | 71a25417c89d0efab40ee6229ccd758b26ae4312 | [
"CC0-1.0"
] | null | null | null | Interlace odd / even from A to B
Two numbers A and B are passed as input. The program must print the odd numbers from A to B (inclusive of A and B) interlaced with the even numbers from B to A.
Input Format: The first line denotes the value of A. The second line denotes the value of B.
Output Format: The odd and even numbers interlaced, each separated by a space.
Boundary Conditions: 1 <= A <= 9999999 A < B <= 9999999
Example Input/Output 1:
Input:
5
11
Output:
5 10 7 8 9 6 11
Explanation: The odd numbers from 5 to 11 are 5 7 9 11 The even numbers from 11 to 5 (that is in reverse direction) are 10 8 6 So these numbers are interlaced to produce 5 10 7 8 9 6 11
Example Input/Output 2:
Input:
4
14
Output:
14 5 12 7 10 9 8 11 6 13 4
Explanation: The odd numbers from 4 to 14 are 5 7 9 11 13 The even numbers from 14 to 4 (that is in reverse direction) are 14 12 10 8 6 4 So these numbers are interlaced to produce 14 5 12 7 10 9 8 11 6 13 4 (Here as the even numbers count are more than the odd numbers count we start with the even number in the output)
Example Input/Output 3:
Input:
3
12
Output:
3 12 5 10 7 8 9 6 11 4
Explanation: The odd numbers from 3 to 12 are 3 5 7 9 11 The even numbers from 12 to 3 (that is in the reverse direction) are 12 10 8 6 4 So these numbers are interlaced to produce 3 12 5 10 7 8 9 6 11 4
#include<stdio.h>
int main()
{
int i,n,m,j;
scanf("%d%d",&n,&m);
for(i=n,j=m;i<=m;i++,j--)
{
if(i%2==1)
printf("%d\t",i);
if(j%2==0)
printf("%d\t",j);
}
}
| 37.575 | 320 | 0.707917 |
87ff4f56dbe165ae307d41b9eafa595bfd8292b1 | 229 | h | C | WUO/WUO/Util/Refresh/XYRefreshGifFooter.h | Ossey/WUO | bd4b9dd45cc5bd2be4aa7e47166ca5ec0645dfc6 | [
"Apache-2.0"
] | null | null | null | WUO/WUO/Util/Refresh/XYRefreshGifFooter.h | Ossey/WUO | bd4b9dd45cc5bd2be4aa7e47166ca5ec0645dfc6 | [
"Apache-2.0"
] | null | null | null | WUO/WUO/Util/Refresh/XYRefreshGifFooter.h | Ossey/WUO | bd4b9dd45cc5bd2be4aa7e47166ca5ec0645dfc6 | [
"Apache-2.0"
] | null | null | null | //
// XYRefreshGifFooter.h
// WUO
//
// Created by mofeini on 17/1/3.
// Copyright © 2017年 com.test.demo. All rights reserved.
//
#import <MJRefresh/MJRefresh.h>
@interface XYRefreshGifFooter : MJRefreshBackGifFooter
@end
| 16.357143 | 57 | 0.71179 |
27852cfb3503e8d4de92d0bf26ab0f51c946837c | 5,841 | c | C | io/m_io_osevent_pipe.c | Monetra/mstdlib | aecbaa0c14a3a618923331250427e175db7ebef9 | [
"BSD-2-Clause"
] | 22 | 2017-09-28T16:12:10.000Z | 2022-03-11T03:21:11.000Z | io/m_io_osevent_pipe.c | Monetra/mstdlib | aecbaa0c14a3a618923331250427e175db7ebef9 | [
"BSD-2-Clause"
] | 13 | 2018-03-06T16:24:12.000Z | 2020-03-02T13:25:19.000Z | io/m_io_osevent_pipe.c | Monetra/mstdlib | aecbaa0c14a3a618923331250427e175db7ebef9 | [
"BSD-2-Clause"
] | 5 | 2018-03-06T15:54:42.000Z | 2020-03-10T16:02:06.000Z | /* The MIT License (MIT)
*
* Copyright (c) 2017 Monetra Technologies, LLC.
*
* 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.
*/
#include "m_config.h"
#include <mstdlib/mstdlib_io.h>
#include <mstdlib/io/m_io_layer.h>
#include "m_event_int.h"
#include "base/m_defs_int.h"
#include <unistd.h>
#include <fcntl.h>
/* XXX: currently needed for M_io_setnonblock() which should be moved */
#include "m_io_int.h"
#include "m_io_posix_common.h"
#define M_IO_OSEVENT_NAME "PIPEEVENT"
struct M_io_handle {
M_EVENT_HANDLE *handles;
size_t handles_cnt;
};
static M_bool M_io_osevent_init_cb(M_io_layer_t *layer)
{
M_io_handle_t *handle = M_io_layer_get_handle(layer);
M_io_t *io = M_io_layer_get_io(layer);
return M_event_handle_modify(M_io_get_event(io), M_EVENT_MODTYPE_ADD_HANDLE, io, handle->handles[0], M_EVENT_INVALID_SOCKET, M_EVENT_WAIT_READ, M_EVENT_CAPS_READ);
}
static M_bool M_io_osevent_process_cb(M_io_layer_t *layer, M_event_type_t *type)
{
unsigned char tmp[32];
ssize_t bytes;
size_t total_read = 0;
M_io_handle_t *handle = M_io_layer_get_handle(layer);
switch (*type) {
case M_EVENT_TYPE_READ:
/* Read until either error, EWOULDBLOCK/EAGAIN, or partial read occurs. If any
* bytes were read, success */
while ((bytes = read(handle->handles[0], tmp, sizeof(tmp))) > 0) {
total_read += (size_t)bytes;
}
/* If error condition and no bytes were read, consume the event and wait
* on a new one */
if (bytes <= 0 && total_read == 0)
return M_TRUE;
/* Do not consume the event, pass it on, but rewrite it as M_EVENT_TYPE_OTHER */
*type = M_EVENT_TYPE_OTHER;
return M_FALSE;
default:
/* Hmm, what other legitimate event could there be for this? I'd think none */
break;
}
/* Consume this unknown event, I can't see what purpose passing it on could have */
return M_TRUE;
}
static void M_io_osevent_unregister_cb(M_io_layer_t *layer)
{
M_io_handle_t *handle = M_io_layer_get_handle(layer);
M_io_t *io = M_io_layer_get_io(layer);
M_event_handle_modify(M_io_get_event(io), M_EVENT_MODTYPE_DEL_HANDLE, io, handle->handles[0], M_EVENT_INVALID_SOCKET, 0, 0);
}
static void M_io_osevent_destroy_cb(M_io_layer_t *layer)
{
M_io_handle_t *handle = M_io_layer_get_handle(layer);
if (handle == NULL)
return;
if (handle->handles_cnt == 2) {
if (handle->handles[0] != -1) {
close(handle->handles[0]);
}
if (handle->handles[1] != -1)
close(handle->handles[1]);
}
M_free(handle->handles);
M_free(handle);
}
static M_io_state_t M_io_osevent_state_cb(M_io_layer_t *layer)
{
(void)layer;
return M_IO_STATE_CONNECTED;
}
M_io_t *M_io_osevent_create(M_event_t *event)
{
M_io_t *io;
M_io_handle_t *handle;
M_io_callbacks_t *callbacks;
handle = M_malloc_zero(sizeof(*handle));
handle->handles_cnt = 2;
handle->handles = M_malloc_zero(sizeof(*handle->handles) * handle->handles_cnt);
#if defined(HAVE_PIPE2) && defined(O_CLOEXEC)
if (pipe2(handle->handles, O_CLOEXEC) == 0) {
#else
if (pipe(handle->handles) == 0) {
M_io_posix_fd_set_closeonexec(handle->handles[0], M_TRUE);
M_io_posix_fd_set_closeonexec(handle->handles[1], M_TRUE);
#endif
} else {
M_free(handle->handles);
M_free(handle);
return NULL;
}
if (!M_io_setnonblock(handle->handles[0]) || !M_io_setnonblock(handle->handles[1])) {
close(handle->handles[0]);
close(handle->handles[1]);
M_free(handle->handles);
M_free(handle);
return NULL;
}
io = M_io_init(M_IO_TYPE_EVENT);
callbacks = M_io_callbacks_create();
M_io_callbacks_reg_init(callbacks, M_io_osevent_init_cb);
M_io_callbacks_reg_processevent(callbacks, M_io_osevent_process_cb);
M_io_callbacks_reg_unregister(callbacks, M_io_osevent_unregister_cb);
M_io_callbacks_reg_destroy(callbacks, M_io_osevent_destroy_cb);
M_io_callbacks_reg_state(callbacks, M_io_osevent_state_cb);
M_io_layer_add(io, M_IO_OSEVENT_NAME, handle, callbacks);
M_io_callbacks_destroy(callbacks);
M_event_add(event, io, NULL, NULL);
return io;
}
void M_io_osevent_trigger(M_io_t *io)
{
M_io_layer_t *layer;
M_io_handle_t *handle;
unsigned char data[] = { 0x01 };
ssize_t retval;
if (io == NULL || M_io_get_type(io) != M_IO_TYPE_EVENT)
return;
layer = M_io_layer_acquire(io, 0, M_IO_OSEVENT_NAME);
if (layer == NULL)
return;
handle = M_io_layer_get_handle(layer);
/* Ignore errors, if it can't write, that means the pipe is already full of
* events and we really only actually deliver one anyhow */
retval = (ssize_t)write(handle->handles[1], data, sizeof(data));
M_io_layer_release(layer);
/* We have to do this to avoid some compiler warnings about unused results, even
* though this actually _is_ valid in this circumstance */
(void)retval;
}
| 30.421875 | 164 | 0.7283 |
1e75d67a8fd3e2f1d8f333184b0694322f663690 | 4,032 | c | C | asm68k/src/symbol.c | tenk-a/misc | f66b265c0feea2d06d1aea95df101315d940d99d | [
"BSD-2-Clause"
] | null | null | null | asm68k/src/symbol.c | tenk-a/misc | f66b265c0feea2d06d1aea95df101315d940d99d | [
"BSD-2-Clause"
] | null | null | null | asm68k/src/symbol.c | tenk-a/misc | f66b265c0feea2d06d1aea95df101315d940d99d | [
"BSD-2-Clause"
] | null | null | null | /***********************************************************************
*
* SYMBOL.C
* Symbol Handling Routines for 68000 Assembler
*
* Function: lookup()
* Searches the symbol table for a previously defined
* symbol or creates a new symbol. The routine functions
* as follows:
*
* Symbol
* Found Returned
* In Create Action Error
* Table? Flag Taken Code
* ------ ------ -------------- -----------
* N FALSE None UNDEFINED
* N TRUE Symbol created OK
* Y FALSE None OK
* Y TRUE None MULTIPLE_DEFS
*
* In addition, the routine always returns a pointer to
* the structure (type symbolDef) that which contains the
* symbol that was found or created. The routine uses a
* hash function to index into an array of pointers to
* ordered linked lists of symbol definitions.
*
* define()
* Defines the symbol whose name is specified to have the
* value specified. If check is TRUE, then the symbol is
* is assumed to already exist and its value is checked
* against the passed value; a PHASE_ERROR results if the
* values are not the same. When check is TRUE the routine
* also sets the backRef bit for the symbol. If check is
* FALSE, then the symbol is defined and its value is set
* equal to the supplied number. The function returns a
* pointer to the symbol definition structure.
*
* Usage: symbolDef *lookup(sym, create, errorPtr)
* char *sym;
* int create, *errorPtr;
*
* symbolDef *define(sym, value, check, errorPtr)
* char *sym;
* int value, check, *errorPtr;
*
* Author: Paul McKee
* ECE492 North Carolina State University
*
* Date: 11/28/86
*
************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "asm.h"
/* MAXHASH is the range of the hash function. hash()
returns values from 0 to MAXHASH inclusive. */
#define MAXHASH 26
static symbolDef *htable[MAXHASH + 1];
void *mallocE(int size)
{
void *p;
p = calloc(1, size);
if (p == NULL) {
puts("not enough memory");
exit(1);
}
return p;
}
symbolDef *lookup(char *sym, int create, int *errorPtr)
{
int h, cmp;
symbolDef *s, *last, *t;
static char initialized = FALSE;
if (!initialized) {
for (h = 0; h <= MAXHASH; h++)
htable[h] = 0;
initialized = TRUE;
}
h = hash(sym);
if ((s = htable[h]) != NULL) {
/* Search the linked list for a matching symbol */
last = NULL;
while (s && (cmp = strcmp(s->name, sym)) < 0) {
last = s;
s = s->next;
}
if (s && !cmp) { /* If a match was found, return pointer to the structure */
if (create)
NEWERROR(*errorPtr, MULTIPLE_DEFS);
t = s;
} else if (create) { /* Otherwise insert the symbol in the list */
if (last) {
/* The symbol goes after an existing symbol */
t = (symbolDef *) mallocE(sizeof(symbolDef));
last->next = t;
t->next = s;
strcpy(t->name, sym);
} else {
/* The symbol goes at the head of a list */
t = (symbolDef *) mallocE(sizeof(symbolDef));
t->next = htable[h];
htable[h] = t;
strcpy(t->name, sym);
}
} else {
NEWERROR(*errorPtr, UNDEFINED);
}
} else if (create) {
t = (symbolDef *) mallocE(sizeof(symbolDef));
htable[h] = t;
t->next = NULL;
strcpy(t->name, sym);
} else {
NEWERROR(*errorPtr, UNDEFINED);
}
return t;
}
int hash(char *symbol)
{
int sum;
sum = 0;
while (*symbol) {
sum += (isupper(*symbol)) ? (*symbol - 'A') : 26;
symbol++;
}
return (sum % 27);
}
symbolDef *define(char *sym,long value,int check,int *errorPtr)
{
symbolDef *symbol;
symbol = lookup(sym, !check, errorPtr);
if (*errorPtr < ERROR) {
if (check) {
if (symbol->value != value)
NEWERROR(*errorPtr, PHASE_ERROR);
symbol->flags |= BACKREF;
/* printf("Marking symbol \"%s\"\n", sym); */
} else {
/* printf("Defining the symbol \"%s\" as %08lX.\n", sym, value); */
symbol->value = value;
symbol->flags = 0;
}
}
return symbol;
}
| 25.2 | 78 | 0.589286 |
1492aa83e26c7d0998b9feee6327fce7bcfef694 | 301 | h | C | Tests/Mocks/SRMockTransportRequest.h | niketaabnave/SignalR-Obj-Updated | 2f8eca8c5488153e0d5afa6a1008161da58ff1bd | [
"MIT"
] | null | null | null | Tests/Mocks/SRMockTransportRequest.h | niketaabnave/SignalR-Obj-Updated | 2f8eca8c5488153e0d5afa6a1008161da58ff1bd | [
"MIT"
] | null | null | null | Tests/Mocks/SRMockTransportRequest.h | niketaabnave/SignalR-Obj-Updated | 2f8eca8c5488153e0d5afa6a1008161da58ff1bd | [
"MIT"
] | null | null | null | //
// SRMockTransportRequest.h
// SignalR.Client.ObjC
//
// Created by Alex Billingsley on 7/20/16.
// Copyright © 2016 DyKnow LLC. All rights reserved.
//
#import <URLMock/UMKMockHTTPRequest.h>
#import <URLMock/UMKMockURLProtocol.h>
@interface SRMockTransportRequest : UMKMockHTTPRequest
@end
| 20.066667 | 54 | 0.750831 |
e7db3e5023cb2178d2f1267c291d8baae949e7ff | 4,276 | h | C | RTIMULib/RTFusion.h | AchmadFathoni/RTIMULib2 | c1239e438503357c35ffdd7bd3782388b1d02798 | [
"MIT"
] | 16 | 2017-06-18T15:29:09.000Z | 2022-01-10T06:27:02.000Z | RTIMULib/RTFusion.h | bsirang/RTIMULib2 | 19018e1dd5007155f38aecca4e7439121ce6f235 | [
"MIT"
] | null | null | null | RTIMULib/RTFusion.h | bsirang/RTIMULib2 | 19018e1dd5007155f38aecca4e7439121ce6f235 | [
"MIT"
] | 29 | 2017-06-19T17:07:57.000Z | 2021-11-25T15:26:23.000Z | ////////////////////////////////////////////////////////////////////////////
//
// This file is part of RTIMULib
//
// Copyright (c) 2014-2015, richards-tech, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
// Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _RTFUSION_H
#define _RTFUSION_H
#include "RTIMULibDefs.h"
class RTIMUSettings;
class RTFusion
{
public:
RTFusion();
virtual ~RTFusion();
// fusionType returns the type code of the fusion algorithm
virtual int fusionType() { return RTFUSION_TYPE_NULL; }
// the following function can be called to set the SLERP power
void setSlerpPower(RTFLOAT power) { m_slerpPower = power; }
// reset() resets the fusion state but keeps any setting changes (such as enables)
virtual void reset() {}
// newIMUData() should be called for subsequent updates
// the fusion fields are updated with the results
virtual void newIMUData(RTIMU_DATA& /* data */, const RTIMUSettings * /* settings */) {}
virtual void gyroBiasInit(float) {}
virtual void handleGyroBias(RTIMU_DATA&, RTIMUSettings *) {}
// This static function returns performs the type to name mapping
static const char *fusionName(int fusionType) { return m_fusionNameMap[fusionType]; }
// the following three functions control the influence of the gyro, accel and compass sensors
void setGyroEnable(bool enable) { m_enableGyro = enable;}
void setAccelEnable(bool enable) { m_enableAccel = enable; }
void setCompassEnable(bool enable) { m_enableCompass = enable;}
inline const RTVector3& getMeasuredPose() {return m_measuredPose;}
inline const RTQuaternion& getMeasuredQPose() {return m_measuredQPose;}
inline const RTVector3& getFusionPose() {return m_fusionPose;}
inline const RTQuaternion& getFusionQPose() {return m_fusionQPose;}
// getAccelResiduals() gets the residual after subtracting gravity
RTVector3 getAccelResiduals(RTVector3 accel);
void setDebugEnable(bool enable) { m_debug = enable; }
void calculatePose(const RTVector3& accel, const RTVector3& mag, float magDeclination); // generates pose from accels and mag
protected:
RTFLOAT m_slerpPower; // a value 0 to 1 that controls measured
RTQuaternion m_measuredQPose; // quaternion form of pose from measurement
RTVector3 m_measuredPose; // vector for
RTQuaternion m_fusionQPose; // quaternion form of pose from fusion
RTVector3 m_fusionPose; // vector form of pose from fusion
bool m_debug;
bool m_enableGyro; // enables gyro as input
bool m_enableAccel; // enables accel as input
bool m_enableCompass; // enables compass a input
bool m_compassValid; // true if compass data valid
bool m_firstTime; // if first time after reset
uint64_t m_lastFusionTime; // for delta time calculation
static const char *m_fusionNameMap[]; // the fusion name array
};
#endif // _RTFUSION_H
| 42.336634 | 129 | 0.665108 |
af3e04e41c644bf704a45000ff774b2849bebf48 | 675 | c | C | lab1/hello3.c | DonovanYe/CS11 | e0f0a10821e8d6cc7c6c77d1030d0d0fead729d1 | [
"MIT"
] | null | null | null | lab1/hello3.c | DonovanYe/CS11 | e0f0a10821e8d6cc7c6c77d1030d0d0fead729d1 | [
"MIT"
] | null | null | null | lab1/hello3.c | DonovanYe/CS11 | e0f0a10821e8d6cc7c6c77d1030d0d0fead729d1 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
char s[100];
int randN;
int i;
/* Seed rand */
srand(time(0));
/* Scan for name input */
printf("Enter your name: ");
scanf("%99s", s);
/* Random int between 1 and 10 */
randN = (int)(((float)rand() / RAND_MAX) * 10) + 1;
/* Print hello, <name>! (even) or hi there, <name>! (odd), randN times */
for (i = 0; i < randN; i++) {
if (randN % 2 == 0) {
printf("%d: hello, %s!\n", randN, s);
}
else {
printf("%d: hi there, %s!\n", randN, s);
}
}
return 0;
} | 22.5 | 78 | 0.444444 |
6331ca740ebc65377bd5b89674ccab788b9f3a9e | 2,624 | h | C | vector.h | daleksla/SGL | 3ee2e264920e440190d4aa7535570ad5300fe417 | [
"BSL-1.0"
] | null | null | null | vector.h | daleksla/SGL | 3ee2e264920e440190d4aa7535570ad5300fe417 | [
"BSL-1.0"
] | null | null | null | vector.h | daleksla/SGL | 3ee2e264920e440190d4aa7535570ad5300fe417 | [
"BSL-1.0"
] | null | null | null | #ifndef VECTOR_H
#define VECTOR_H
#pragma once
#include <stdlib.h> // malloc, free
#include <string.h> // memcpy, memset
/** @brief Vector structure & functionality to support dynamically allocated arrays
@author Salih Mahmoud Sayed Ahmed
@email ahmed233@uni.coventry.ac.uk
@date Jun 2021
**/
#ifdef __cplusplus
extern "C++" {
#endif // __cplusplus
typedef struct {
/** vector struct, contains properties pertaining to vector **/
void* data ; // stores vector data
unsigned long bytes ; // stores bytes allocated
unsigned long size ; // stores actual items of data
} vector ;
/** vector_init function, initialises empty vector
* @return initialised vector struct **/
vector vector_init(void) ;
/** vector_copy function, copies contents of a given vector.
* @param const pointer to vector
* @return copy of given vector **/
vector vector_copy(const vector*) ;
/** vector_append function, adds item of data to end of a vector data and resizes accordingly
* @param pointer to vector to append data to
* @param l-value (ie pre-initialised) item of data to add **/
#define vector_append(qwerty_x_vec_l_abcd, qwerty_x_data_l_abcd) ({\
unsigned long bytes = sizeof(qwerty_x_data_l_abcd) ;\
/* then, allocate more memory accordingly, copy the data over, add new data, delete old location */\
void* newVecData = malloc(qwerty_x_vec_l_abcd->bytes+bytes) ;\
memset(newVecData, 0, qwerty_x_vec_l_abcd->bytes+bytes) ; /* there has to be a better alternative to avoid valgrinds message */\
memcpy(newVecData, qwerty_x_vec_l_abcd->data, qwerty_x_vec_l_abcd->bytes) ;\
free(qwerty_x_vec_l_abcd->data) ; /* delete the old bit of data */\
qwerty_x_vec_l_abcd->data = newVecData ; /* assign vector new memory location */\
((char*)qwerty_x_vec_l_abcd->data)[qwerty_x_vec_l_abcd->bytes] = qwerty_x_data_l_abcd ;\
qwerty_x_vec_l_abcd->bytes += bytes ;\
++qwerty_x_vec_l_abcd->size ;\
})
/** vector_fini function, frees data held by provided vector
* @param pointer to vector **/
void vector_fini(vector*) ;
vector vector_init(void)
{
vector vec ;
vec.data = NULL ;
vec.bytes = 0 ;
vec.size = 0 ;
return vec ;
}
vector vector_copy(const vector* cpVec)
{
vector vec ;
vec.bytes = cpVec->bytes ;
vec.size = cpVec->size ;
if(vec.bytes)
{
vec.data = malloc(vec.bytes) ;
memcpy(vec.data, cpVec->data, vec.bytes) ;
}
else {
vec.data = NULL ;
}
return vec ;
}
void vector_fini(vector* vec)
{
if(vec->data != NULL)
{
free(vec->data) ;
vec->data = NULL ;
vec->size = 0 ;
vec->bytes = 0 ;
}
}
#ifdef __cplusplus
} // "C++"
#endif // __cplusplus
#endif // VECTOR_H
| 26.505051 | 129 | 0.705793 |
6351665ffaf49a11f87fb438de717f6ea09d5b0b | 298 | h | C | src/src/base/AppInfo.h | zhangkn/MachOExplorer | 7f510277b2d10612cab739c4456aadc292cda3a5 | [
"MIT"
] | 586 | 2017-02-18T02:30:50.000Z | 2022-03-24T02:54:22.000Z | src/src/base/AppInfo.h | fenglh/MachOExplorer | 173122e2a0dae9633f792bd4399a6ce832596458 | [
"MIT"
] | 20 | 2017-12-01T02:41:08.000Z | 2021-01-05T20:48:28.000Z | src/src/base/AppInfo.h | fenglh/MachOExplorer | 173122e2a0dae9633f792bd4399a6ce832596458 | [
"MIT"
] | 56 | 2017-10-02T07:54:03.000Z | 2021-12-16T09:15:58.000Z | //
// Created by everettjf
// Copyright © 2017 everettjf. All rights reserved.
//
#ifndef APPINFO_H
#define APPINFO_H
#include <QString>
class AppInfo
{
public:
AppInfo();
static AppInfo & Instance();
QString GetAppVersion();
QString GetAppEdition();
};
#endif // APPINFO_H
| 12.956522 | 52 | 0.674497 |
635f8e62a063571ff7f023b488250d662583d442 | 2,165 | h | C | Engine/lib/collada/include/dae/daeUtils.h | vbillet/Torque3D | ece8823599424ea675e5f79d9bcb44e42cba8cae | [
"MIT"
] | 2,113 | 2015-01-01T11:23:01.000Z | 2022-03-28T04:51:46.000Z | Engine/lib/collada/include/dae/daeUtils.h | vbillet/Torque3D | ece8823599424ea675e5f79d9bcb44e42cba8cae | [
"MIT"
] | 948 | 2015-01-02T01:50:00.000Z | 2022-02-27T05:56:40.000Z | Engine/lib/collada/include/dae/daeUtils.h | vbillet/Torque3D | ece8823599424ea675e5f79d9bcb44e42cba8cae | [
"MIT"
] | 944 | 2015-01-01T09:33:53.000Z | 2022-03-15T22:23:03.000Z | // A home for commonly used utility functions. These are mostly for internal DOM
// use, but the automated tests use some of these functions, so we'll export
// them.
#ifndef daeUtils_h
#define daeUtils_h
#include <string>
#include <sstream>
#include <list>
#include <vector>
#include <dae/daePlatform.h>
namespace cdom {
// System type info. We only need to distinguish between Posix and Winodws for now.
enum systemType {
Posix,
Windows
};
// Get the system type at runtime.
DLLSPEC systemType getSystemType();
// String replace function. Usage: replace("abcdef", "cd", "12") --> "ab12ef".
DLLSPEC std::string replace(const std::string& s,
const std::string& replace,
const std::string& replaceWith);
// Usage:
// tokenize("this/is some#text", "/#", true) --> ("this" "/" "is some" "#" "text")
// tokenize("this is some text", " ", false) --> ("this" "is" "some" "text")
DLLSPEC std::list<std::string> tokenize(const std::string& s,
const std::string& separators,
bool separatorsInResult = false);
// Same as the previous function, but returns the result via a parameter to avoid an object copy.
DLLSPEC void tokenize(const std::string& s,
const std::string& separators,
/* out */ std::list<std::string>& tokens,
bool separatorsInResult = false);
typedef std::list<std::string>::iterator tokenIter;
DLLSPEC std::vector<std::string> makeStringArray(const char* s, ...);
DLLSPEC std::list<std::string> makeStringList(const char* s, ...);
DLLSPEC std::string getCurrentDir();
DLLSPEC std::string getCurrentDirAsUri();
DLLSPEC int strcasecmp(const char* str1, const char* str2);
DLLSPEC std::string tolower(const std::string& s);
// Disable VS warning
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4267)
#endif
template<typename T>
std::string toString(const T& val) {
std::ostringstream stream;
stream << val;
return stream.str();
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
}
#endif
| 31.838235 | 98 | 0.636952 |
c0a6163546404e024d03746b26930b0c96be8b88 | 4,014 | h | C | netbsd/sys/arch/hpcarm/sa11x0/sa11x0_gpioreg.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 91 | 2015-01-05T15:18:31.000Z | 2022-03-11T16:43:28.000Z | netbsd/sys/arch/hpcarm/sa11x0/sa11x0_gpioreg.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 1 | 2016-02-25T15:57:55.000Z | 2016-02-25T16:01:02.000Z | netbsd/sys/arch/hpcarm/sa11x0/sa11x0_gpioreg.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 21 | 2015-02-07T08:23:07.000Z | 2021-12-14T06:01:49.000Z | /* $NetBSD: sa11x0_gpioreg.h,v 1.11 2001/07/13 03:33:38 ichiro Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Ichiro FUKUHARA (ichiro@ichiro.org).
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* SA-11x0 GPIO Register
*/
#define SAGPIO_NPORTS 8
/* GPIO pin-level register */
#define SAGPIO_PLR 0x00
/* GPIO pin direction register */
#define SAGPIO_PDR 0x04
/* GPIO pin output set register */
#define SAGPIO_PSR 0x08
/* GPIO pin output clear register */
#define SAGPIO_PCR 0x0C
/* GPIO rising-edge detect register */
#define SAGPIO_RER 0x10
/* GPIO falling-edge detect register */
#define SAGPIO_FER 0x14
/* GPIO edge-detect status register */
#define SAGPIO_EDR 0x18
/* GPIO alternate function register */
#define SAGPIO_AFR 0x1C
/* XXX */
#define GPIO(x) (0x00000001 << (x))
/*
* SA-11x0 GPIOs parameter
* Alternate Functions
*/
#define GPIO_ALT_LDD8 GPIO(2) /* LCD DATA(8) */
#define GPIO_ALT_LDD9 GPIO(3) /* LCD DATA(9) */
#define GPIO_ALT_LDD10 GPIO(4) /* LCD DATA(10) */
#define GPIO_ALT_LDD11 GPIO(5) /* LCD DATA(11) */
#define GPIO_ALT_LDD12 GPIO(6) /* LCD DATA(12) */
#define GPIO_ALT_LDD13 GPIO(7) /* LCD DATA(13) */
#define GPIO_ALT_LDD14 GPIO(8) /* LCD DATA(14) */
#define GPIO_ALT_LDD15 GPIO(9) /* LCD DATA(15) */
#define GPIO_ALT_SSP_TXD GPIO(10) /* SSP transmit */
#define GPIO_ALT_SSP_RXD GPIO(11) /* SSP receive */
#define GPIO_ALT_SSP_SCLK GPIO(12) /* SSP serial clock */
#define GPIO_ALT_SSP_SFRM GPIO(13) /* SSP frameclock */
#define GPIO_ALT_UART_TXD GPIO(14) /* UART transmit */
#define GPIO_ALT_UART_RXD GPIO(15) /* UART receive */
#define GPIO_ALT_GPCLK_OUT GPIO(16) /* General-purpose clock out */
#define GPIO_ALT_UART_SCLK GPIO(18) /* Sample clock input */
#define GPIO_ALT_SSP_CLK GPIO(19) /* Sample clock input */
#define GPIO_ALT_UART_SCLK3 GPIO(20) /* Sample clock input */
#define GPIO_ALT_MCP_CLK GPIO(21) /* MCP dock in */
#define GPIO_ALT_TREQA GPIO(22) /* Either TIC request A */
#define GPIO_ALT_TREQB GPIO(23) /* Either TIC request B */
#define GPIO_ALT_RTC GPIO(25) /* Real Time Clock */
#define GPIO_ALT_RCLK_OUT GPIO(26) /* internal clock /2 */
#define GPIO_ALT_32KHZ_OUT GPIO(27) /* Raw 32.768kHz osc output */
| 40.545455 | 78 | 0.737668 |
0239c4ed05bd12bb95aa9cf6016e3c34faa33df2 | 231 | h | C | MediaManagerDemo/MediaManagerViewController.h | kajornsakp/DroneHackathon-iOS | 50a9171de8b29e7f99c2cfc5d4e8b11060da8425 | [
"MIT"
] | 4 | 2018-10-01T19:35:11.000Z | 2021-02-26T04:34:11.000Z | MediaManagerDemo/MediaManagerViewController.h | kajornsakp/DroneHackathon-iOS | 50a9171de8b29e7f99c2cfc5d4e8b11060da8425 | [
"MIT"
] | 4 | 2017-08-15T02:41:34.000Z | 2018-03-09T11:01:13.000Z | MediaManagerDemo/MediaManagerViewController.h | kajornsakp/DroneHackathon-iOS | 50a9171de8b29e7f99c2cfc5d4e8b11060da8425 | [
"MIT"
] | 2 | 2019-03-08T08:59:53.000Z | 2020-07-14T16:43:25.000Z | //
// MediaManagerViewController.h
// MediaManagerDemo
//
// Created by DJI on 1/8/2017.
// Copyright © 2017 DJI. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MediaManagerViewController : UIViewController
@end
| 16.5 | 56 | 0.722944 |
cbe3258bf9d8335c8810b8d5f6044a91429a7b19 | 16,574 | c | C | src/nlreset_info.c | nestlabs/nlplatform | ddcc36e911c16401d46b053ca918ac8087fe4679 | [
"Apache-2.0"
] | 2 | 2020-08-27T04:57:24.000Z | 2022-01-17T11:56:47.000Z | src/nlreset_info.c | nestlabs/nlplatform | ddcc36e911c16401d46b053ca918ac8087fe4679 | [
"Apache-2.0"
] | null | null | null | src/nlreset_info.c | nestlabs/nlplatform | ddcc36e911c16401d46b053ca918ac8087fe4679 | [
"Apache-2.0"
] | 1 | 2022-01-10T14:15:16.000Z | 2022-01-10T14:15:16.000Z | /*
*
* Copyright (c) 2016-2018 Nest Labs, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Description:
* This file...
*
*/
#include <nlplatform.h>
#include <nlenv.h>
#include <FreeRTOS.h>
#include <task.h>
#ifdef BUILD_FEATURE_RESET_INFO
// g_reset_info needs to be in retained/persistent RAM that
// maintains it's values across a reboot.
//
// Currently, two implementations are supported. Either
// g_reset_info is in dedicated retained RAM, or it is
// in temporary/overlaid retained RAM that is only valid
// between a fault and early in the next boot. The latter
// implementation saves RAM, but requires an external FLASH
// partition in order to save the reset/fault information
// so that it is available for later use by the application,
// Once reset info is written to, the system *MUST* continue
// with a reset soon after and task switching should be disabled.
void nlplatform_reset_info_init_done(void) LINKER_REPLACEABLE_FUNCTION(nlplatform_reset_info_init_done_default);
#ifdef BUILD_FEATURE_RESET_INFO_IN_TEMP_RAM
// NL_RESETINFO_SYMBOL is defined when special section
// is used for RESETINFO. It is assumed this is the case
// when the section is overlaid with another RAM section
// to reduce RAM usage, instead of just using a dedicated
// area in RETAIN section.
nl_reset_info_t g_reset_info NL_RESETINFO_SYMBOL __attribute__((used));
#ifdef DEBUG
// cache of reset reason for querying after boot since the
// overlaid RAM will be used by something else once boot is done.
static nl_reset_reason_t s_cached_reset_reason;
#endif // DEBUG
static int save_fault_to_flash(void)
{
int retval;
char fault_dirty_flag;
size_t retlen = sizeof(fault_dirty_flag);
retval = nl_env_get(kFaultDiagsDirtyKey, &fault_dirty_flag, &retlen);
if (retval >= 0)
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Fault info already dirty, not overwriting\n"));
}
else
{
g_reset_info.fault_info.reason = g_reset_info.reset_reason;
fault_dirty_flag = '1';
retval = nlflash_erase(NLFLASH_EXTERNAL, NL_FAULT_DIAGS_FLASH_LOCATION,
NL_FAULT_DIAGS_FLASH_SIZE, &retlen, NULL);
if (retval < 0)
{
goto flash_ops_failed;
}
retval = nlflash_write(NLFLASH_EXTERNAL, NL_FAULT_DIAGS_FLASH_LOCATION,
sizeof(g_reset_info.fault_info),
&retlen, (uint8_t*)&g_reset_info.fault_info, NULL);
if (retval < 0)
{
goto flash_ops_failed;
}
retval = nl_env_set(kFaultDiagsDirtyKey, (void*)&fault_dirty_flag, sizeof(fault_dirty_flag));
if (retval < 0)
{
goto flash_ops_failed;
}
printf(UNIQUE_PRINTF_FORMAT_STRING("Saved reset+fault info to external flash\n"));
}
flash_ops_failed:
if (retval < 0)
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Saving reset+fault info to external flash failed\n"));
}
return retval;
}
void nl_reset_info_init(void)
{
if (g_reset_info.magic != NL_RESET_INFO_MAGIC)
{
// make sure g_reset_info.reset_reason and
// g_reset_info.fault_info.reason are initialized
g_reset_info.reset_reason = NL_RESET_REASON_UNKNOWN;
g_reset_info.fault_info.reason = NL_RESET_REASON_UNKNOWN;
}
// check the status of the reset_reason to see
// if the we have reset from a previous app run due to a fault.
// if so, save a copy of the fault info flash so we can
// later send it to the service. g_reset_info should be
// preserved at this early point in boot.
// Only write fault info out if it is a fault and not another
// type of reset, and only if the flash block isn't already dirty
// (dirty is indicated by existence of dirty env)
if ((g_reset_info.magic == NL_RESET_INFO_MAGIC) &&
IS_VALID_FAULT_REASON(g_reset_info.reset_reason))
{
save_fault_to_flash();
}
#ifdef DEBUG
// save last reset reason so we can print it later if desired
if ((g_reset_info.magic == NL_RESET_INFO_MAGIC) &&
(IS_VALID_RESET_REASON(g_reset_info.reset_reason) ||
IS_VALID_FAULT_REASON(g_reset_info.reset_reason)))
{
s_cached_reset_reason = g_reset_info.reset_reason;
}
else
{
s_cached_reset_reason = NL_RESET_REASON_UNKNOWN;
}
nl_reset_info_print();
nl_reset_info_print_saved_fault();
#endif // DEBUG
// clear magic to indicate we've processed previous reset reason
// and are ready for a new reset
g_reset_info.magic = 0;
// allow platforms to do things after we're done with
// the g_reset_info, in case it is overlaid with some
// other section
nlplatform_reset_info_init_done();
}
static void nl_reset_info_set(nl_reset_reason_t reset_reason, const char *fault_description)
{
g_reset_info.magic = NL_RESET_INFO_MAGIC;
g_reset_info.reset_reason = reset_reason;
if (IS_VALID_FAULT_REASON(reset_reason))
{
// g_reset_info.fault_info is just a cache, the persistent
// information is in external FLASH so we always reset the
// RAM copy here
g_reset_info.fault_info.reason = NL_RESET_REASON_UNKNOWN;
if (fault_description != NULL)
{
strncpy((void*)&g_reset_info.fault_info.description, fault_description,
sizeof(nl_fault_description_t));
}
}
}
void nl_reset_info_prepare_reset(nl_reset_reason_t reset_reason, const char *fault_description)
{
// disable scheduler since we don't want anyone modifying
// .resetinfo if it's in an overlaid section
vTaskSuspendAll();
// sometimes there are nested faults. if we've already been set, do
// nothing since we want to retain the first reason.
if (g_reset_info.magic != NL_RESET_INFO_MAGIC)
{
nl_reset_info_set(reset_reason, fault_description);
}
}
void nl_reset_info_prepare_reset_bootloader(nl_reset_reason_t reset_reason, const char *fault_description)
{
// If the reset_reason is a fault, we always want to record this
// in the bootloader case (unlike nl_reset_info_prepare_reset(),
// which doesn't want to overwrite faults until it's been able
// to save it off to flash). Otherwise, a preexisting reset reason
// like normal SW reset would prevent the bootloader from recording
// a fault.
if ((g_reset_info.magic != NL_RESET_INFO_MAGIC) ||
IS_VALID_FAULT_REASON(reset_reason))
{
nl_reset_info_set(reset_reason, fault_description);
}
}
int nl_reset_info_get_saved_fault(nl_fault_info_t *saved_fault_info)
{
int retval = -1;
char fault_dirty_flag;
size_t retlen = sizeof(fault_dirty_flag);
if (nl_env_get(kFaultDiagsDirtyKey, &fault_dirty_flag, &retlen) >= 0)
{
// read into the provided buffer
retval = nlflash_read(NLFLASH_EXTERNAL, NL_FAULT_DIAGS_FLASH_LOCATION,
sizeof(*saved_fault_info), &retlen,
(uint8_t*)saved_fault_info, NULL);
}
// sanity check the previous fault info. especially if there was a
// change in reset_reason codes, we could get weird info.
if (retval == 0)
{
if (!IS_VALID_FAULT_REASON(saved_fault_info->reason))
{
// not valid previous fault, clear it
nl_reset_info_clear_saved_fault();
retval = -1;
}
}
return retval;
}
void nl_reset_info_clear_saved_fault(void)
{
nl_env_set(kFaultDiagsDirtyKey, NULL, 0);
}
#else // BUILD_FEATURE_RESET_INFO_IN_TEMP_RAM
nl_reset_info_t g_reset_info NL_RETAIN_SYMBOL __attribute__((used));
void nl_reset_info_init(void)
{
if (g_reset_info.magic != NL_RESET_INFO_MAGIC)
{
// make sure g_reset_info.reset_reason and
// g_reset_info.fault_info.reason are initialized
g_reset_info.reset_reason = NL_RESET_REASON_UNKNOWN;
nl_reset_info_clear_saved_fault();
}
#ifdef DEBUG
nl_reset_info_print();
nl_reset_info_print_saved_fault();
#endif // DEBUG
// clear magic to indicate we've processed previous reset reason
// and are ready for a new reset
g_reset_info.magic = 0;
// allow platforms to do things after we're done with
// the g_reset_info, in case it is overlaid with some
// other section
nlplatform_reset_info_init_done();
}
static void nl_reset_info_set(nl_reset_reason_t reset_reason, const char *fault_description,
bool override_fault_reason)
{
g_reset_info.magic = NL_RESET_INFO_MAGIC;
g_reset_info.reset_reason = reset_reason;
if (IS_VALID_FAULT_REASON(reset_reason))
{
// don't overwrite last fault info if it's not been cleared by app,
// to preserve that info for eventual app processing
if ((g_reset_info.fault_info.reason == NL_RESET_REASON_UNKNOWN) ||
(override_fault_reason == true))
{
g_reset_info.fault_info.reason = reset_reason;
if (fault_description != NULL)
{
strncpy((void*)&g_reset_info.fault_info.description, fault_description,
sizeof(nl_fault_description_t));
}
}
}
}
void nl_reset_info_prepare_reset(nl_reset_reason_t reset_reason, const char *fault_description)
{
// sometimes there are nested faults. if we've already been set, do
// nothing since we want to retain the first reason.
if (g_reset_info.magic != NL_RESET_INFO_MAGIC)
{
nl_reset_info_set(reset_reason, fault_description, false);
}
}
void nl_reset_info_prepare_reset_bootloader(nl_reset_reason_t reset_reason, const char *fault_description)
{
// If the reset_reason is a fault, we always want to record this
// in the bootloader case (unlike nl_reset_info_prepare_reset(),
// which doesn't want to overwrite faults until it's been able
// to save it off to flash). Otherwise, a preexisting reset reason
// like normal SW reset would prevent the bootloader from recording
// a fault.
if ((g_reset_info.magic != NL_RESET_INFO_MAGIC) ||
IS_VALID_FAULT_REASON(reset_reason))
{
nl_reset_info_set(reset_reason, fault_description, true);
}
}
int nl_reset_info_get_saved_fault(nl_fault_info_t *saved_fault_info)
{
int retval = -1;
// our RAM is not shared so our fault info (if any) is valid
if (IS_VALID_FAULT_REASON(g_reset_info.fault_info.reason))
{
memcpy(saved_fault_info, &g_reset_info.fault_info, sizeof(g_reset_info.fault_info));
retval = 0;
}
// sanity check the previous fault info. especially if there was a
// change in reset_reason codes, we could get weird info.
if (retval == 0)
{
if (!IS_VALID_FAULT_REASON(saved_fault_info->reason))
{
// not valid previous fault, clear it
nl_reset_info_clear_saved_fault();
retval = -1;
}
}
return retval;
}
void nl_reset_info_clear_saved_fault(void)
{
memset(&g_reset_info.fault_info, 0, sizeof(g_reset_info.fault_info));
g_reset_info.fault_info.reason = NL_RESET_REASON_UNKNOWN;
}
#endif // BUILD_FEATURE_RESET_INFO_IN_TEMP_RAM
nl_reset_reason_t nl_reset_info_get_reset_reason(void)
{
nl_reset_reason_t reset_reason = NL_RESET_REASON_UNKNOWN;
if ((g_reset_info.magic == NL_RESET_INFO_MAGIC) &&
(IS_VALID_RESET_REASON(g_reset_info.reset_reason) ||
IS_VALID_FAULT_REASON(g_reset_info.reset_reason)))
{
reset_reason = g_reset_info.reset_reason;
}
return reset_reason;
}
#ifdef DEBUG
/* The entries in s_reset_reason_strings and
* s_fault_reset_reason_strings should match those in
* nl_reset_reason_t enum under nlreset_info.h
*/
const char *s_reset_reason_strings[NL_RESET_REASON_COUNT] =
{
[NL_RESET_REASON_UNSPECIFIED] = "unspecified",
[NL_RESET_REASON_UNKNOWN] = "unknown",
[NL_RESET_REASON_SW_REQUESTED] = "sw requested",
[NL_RESET_REASON_SW_UPDATE] = "sw update",
[NL_RESET_REASON_FACTORY_RESET] = "factory reset"
};
const char *s_fault_reset_reason_strings[NL_RESET_REASON_FAULT_COUNT] =
{
[NL_RESET_REASON_HARD_FAULT - NL_RESET_REASON_FIRST_FAULT] = "hard fault",
[NL_RESET_REASON_ASSERT - NL_RESET_REASON_FIRST_FAULT] = "assert",
[NL_RESET_REASON_WATCHDOG - NL_RESET_REASON_FIRST_FAULT] = "watchdog",
[NL_RESET_REASON_STACK_OVERFLOW - NL_RESET_REASON_FIRST_FAULT] = "stack overflow"
};
void nl_reset_info_print(void)
{
nl_reset_reason_t reset_reason;
#ifdef BUILD_FEATURE_RESET_INFO_IN_TEMP_RAM
reset_reason = s_cached_reset_reason;
#else
reset_reason = g_reset_info.reset_reason;
#endif
if (IS_VALID_RESET_REASON(reset_reason))
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Last reset reason: %s\n"), s_reset_reason_strings[reset_reason]);
}
else if (IS_VALID_FAULT_REASON(reset_reason))
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Last fault reset reason: %s\n"), s_fault_reset_reason_strings[reset_reason - NL_RESET_REASON_FIRST_FAULT]);
}
else
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Invalid last reset reason %u\n"), (unsigned)reset_reason);
}
}
static const char * const reg_names[] = { " sp", " lr", " pc", "psr" };
void nl_reset_info_print_saved_fault(void)
{
nl_fault_info_t fault_info;
nl_fault_task_info_t *task_info;
unsigned i,j;
if (nl_reset_info_get_saved_fault(&fault_info) == 0)
{
// Found a previous fault_info. Print out all associated data
printf(UNIQUE_PRINTF_FORMAT_STRING("Previous fault info found! Printing post-mortem info:\n"));
printf(UNIQUE_PRINTF_FORMAT_STRING("Fault reason: %s\n"), s_fault_reset_reason_strings[fault_info.reason - NL_RESET_REASON_FIRST_FAULT]);
printf(UNIQUE_PRINTF_FORMAT_STRING("Fault Registers:\n"));
for (i = 0; i < 13; i++)
{
printf(UNIQUE_PRINTF_FORMAT_STRING("r%d\t0x%08lx\n"), i, (long unsigned int)fault_info.registers[i]);
}
for (i = 0; i < ARRAY_SIZE(reg_names); i++)
{
printf(UNIQUE_PRINTF_FORMAT_STRING("%s\t0x%08lx\n"), reg_names[i], (long unsigned int)fault_info.registers[i+13]);
}
if (fault_info.active_task_name[0])
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Task at time of fault: %s\n"), fault_info.active_task_name);
printf(UNIQUE_PRINTF_FORMAT_STRING("Task Info:\n"));
for (i = 0; i < ARRAY_SIZE(fault_info.task_info); i++)
{
task_info = &fault_info.task_info[i];
if (task_info->backtrace[0])
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Task: %s%s\n"), task_info->task_name, task_info->task_state);
for (j = 0; j < ARRAY_SIZE(task_info->backtrace) && task_info->backtrace[j] != 0; j++)
{
printf(UNIQUE_PRINTF_FORMAT_STRING("\t0x%08lx\n"), (long unsigned int)task_info->backtrace[j]);
}
}
}
}
if (fault_info.machine_backtrace[0])
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Machine Backtrace:\n"));
for (j = 0; j < ARRAY_SIZE(fault_info.machine_backtrace) && fault_info.machine_backtrace[j] != 0; j++)
{
printf(UNIQUE_PRINTF_FORMAT_STRING("\t0x%08lx\n"), (long unsigned int)fault_info.machine_backtrace[j]);
}
}
if (fault_info.description[0])
{
printf(UNIQUE_PRINTF_FORMAT_STRING("Fault description: [%*s]\n"), (int)sizeof(fault_info.description),
fault_info.description);
}
}
else
{
printf(UNIQUE_PRINTF_FORMAT_STRING("No previous fault info\n"));
}
}
#endif // DEBUG
void nlplatform_reset_info_init_done_default(void);
void nlplatform_reset_info_init_done_default(void)
{
}
#endif // BUILD_FEATURE_RESET_INFO
| 35.719828 | 151 | 0.684989 |
4ffae00c5d0d8aa945659cea393d2a93b649f5a5 | 870 | h | C | guest/lib.h | fork-for-contribution/ZeldaOS.x86_64 | e3f9ed83ecb8c101328ec6653a036677d2b37aa9 | [
"BSD-3-Clause"
] | 49 | 2019-03-25T15:11:31.000Z | 2022-03-26T08:37:49.000Z | guest/lib.h | fork-for-contribution/ZeldaOS.x86_64 | e3f9ed83ecb8c101328ec6653a036677d2b37aa9 | [
"BSD-3-Clause"
] | 8 | 2019-05-22T16:56:24.000Z | 2020-09-10T04:43:28.000Z | guest/lib.h | fork-for-contribution/ZeldaOS.x86_64 | e3f9ed83ecb8c101328ec6653a036677d2b37aa9 | [
"BSD-3-Clause"
] | 14 | 2019-06-18T10:46:52.000Z | 2022-03-31T03:37:52.000Z | /*
* Copyright (c) 2019 Jie Zheng
*/
#ifndef _LIB_H
#define _LIB_H
#include <stdint.h>
#include <printk.h>
void
memset(void *dst, const void *src, int nr_bytes);
void
print_string(const char * content);
static inline uint64_t
rdtsc(void)
{
uint32_t eax = 0;
uint32_t edx = 0;
__asm__ volatile("rdtsc;"
:"=a"(eax), "=d"(edx)
:
:"cc");
return (((uint64_t)edx) << 32)| (uint64_t)eax;
}
static inline int
rand(int range)
{
return rdtsc() % range;
}
static inline uint64_t
get_cpu_frequency(void)
{
uint64_t rcx;
// It's a little tricky here, I put the cpu frequency into RCX after
// rdtsc is issued. see vm_monitor/vmx_rdtsc.c
__asm__ volatile("rdtsc;"
:"=c"(rcx)
:
:"memory");
return rcx;
}
#endif
| 18.510638 | 72 | 0.557471 |
8b43b11e98cec70323bf03131f66138f6e52100a | 9,085 | h | C | google/cloud/securitycenter/security_center_connection.h | GoogleCloudPlatform/google-cloud-cpp | c4fc35de9e15f95b1dbf585f1c96de5dba609e2b | [
"Apache-2.0"
] | 80 | 2017-11-24T00:19:45.000Z | 2019-01-25T10:24:33.000Z | google/cloud/securitycenter/security_center_connection.h | GoogleCloudPlatform/google-cloud-cpp | c4fc35de9e15f95b1dbf585f1c96de5dba609e2b | [
"Apache-2.0"
] | 1,579 | 2017-11-24T01:01:21.000Z | 2019-01-28T23:41:21.000Z | google/cloud/securitycenter/security_center_connection.h | GoogleCloudPlatform/google-cloud-cpp | c4fc35de9e15f95b1dbf585f1c96de5dba609e2b | [
"Apache-2.0"
] | 51 | 2017-11-24T00:56:11.000Z | 2019-01-18T20:35:02.000Z | // Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://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.
// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/cloud/securitycenter/v1/securitycenter_service.proto
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SECURITYCENTER_SECURITY_CENTER_CONNECTION_H
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SECURITYCENTER_SECURITY_CENTER_CONNECTION_H
#include "google/cloud/securitycenter/internal/security_center_retry_traits.h"
#include "google/cloud/securitycenter/internal/security_center_stub.h"
#include "google/cloud/securitycenter/security_center_connection_idempotency_policy.h"
#include "google/cloud/backoff_policy.h"
#include "google/cloud/future.h"
#include "google/cloud/options.h"
#include "google/cloud/polling_policy.h"
#include "google/cloud/status_or.h"
#include "google/cloud/stream_range.h"
#include "google/cloud/version.h"
#include <google/longrunning/operations.grpc.pb.h>
#include <memory>
namespace google {
namespace cloud {
namespace securitycenter {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
using SecurityCenterRetryPolicy =
::google::cloud::internal::TraitBasedRetryPolicy<
securitycenter_internal::SecurityCenterRetryTraits>;
using SecurityCenterLimitedTimeRetryPolicy =
::google::cloud::internal::LimitedTimeRetryPolicy<
securitycenter_internal::SecurityCenterRetryTraits>;
using SecurityCenterLimitedErrorCountRetryPolicy =
::google::cloud::internal::LimitedErrorCountRetryPolicy<
securitycenter_internal::SecurityCenterRetryTraits>;
class SecurityCenterConnection {
public:
virtual ~SecurityCenterConnection() = 0;
virtual Options options() { return Options{}; }
virtual future<
StatusOr<google::cloud::securitycenter::v1::BulkMuteFindingsResponse>>
BulkMuteFindings(
google::cloud::securitycenter::v1::BulkMuteFindingsRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::Source> CreateSource(
google::cloud::securitycenter::v1::CreateSourceRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::Finding> CreateFinding(
google::cloud::securitycenter::v1::CreateFindingRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::MuteConfig>
CreateMuteConfig(
google::cloud::securitycenter::v1::CreateMuteConfigRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::NotificationConfig>
CreateNotificationConfig(
google::cloud::securitycenter::v1::CreateNotificationConfigRequest const&
request);
virtual Status DeleteMuteConfig(
google::cloud::securitycenter::v1::DeleteMuteConfigRequest const&
request);
virtual Status DeleteNotificationConfig(
google::cloud::securitycenter::v1::DeleteNotificationConfigRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::BigQueryExport>
GetBigQueryExport(
google::cloud::securitycenter::v1::GetBigQueryExportRequest const&
request);
virtual StatusOr<google::iam::v1::Policy> GetIamPolicy(
google::iam::v1::GetIamPolicyRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::MuteConfig> GetMuteConfig(
google::cloud::securitycenter::v1::GetMuteConfigRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::NotificationConfig>
GetNotificationConfig(
google::cloud::securitycenter::v1::GetNotificationConfigRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::OrganizationSettings>
GetOrganizationSettings(
google::cloud::securitycenter::v1::GetOrganizationSettingsRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::Source> GetSource(
google::cloud::securitycenter::v1::GetSourceRequest const& request);
virtual StreamRange<google::cloud::securitycenter::v1::GroupResult>
GroupAssets(google::cloud::securitycenter::v1::GroupAssetsRequest request);
virtual StreamRange<google::cloud::securitycenter::v1::GroupResult>
GroupFindings(
google::cloud::securitycenter::v1::GroupFindingsRequest request);
virtual StreamRange<
google::cloud::securitycenter::v1::ListAssetsResponse::ListAssetsResult>
ListAssets(google::cloud::securitycenter::v1::ListAssetsRequest request);
virtual StreamRange<google::cloud::securitycenter::v1::ListFindingsResponse::
ListFindingsResult>
ListFindings(google::cloud::securitycenter::v1::ListFindingsRequest request);
virtual StreamRange<google::cloud::securitycenter::v1::MuteConfig>
ListMuteConfigs(
google::cloud::securitycenter::v1::ListMuteConfigsRequest request);
virtual StreamRange<google::cloud::securitycenter::v1::NotificationConfig>
ListNotificationConfigs(
google::cloud::securitycenter::v1::ListNotificationConfigsRequest
request);
virtual StreamRange<google::cloud::securitycenter::v1::Source> ListSources(
google::cloud::securitycenter::v1::ListSourcesRequest request);
virtual future<
StatusOr<google::cloud::securitycenter::v1::RunAssetDiscoveryResponse>>
RunAssetDiscovery(
google::cloud::securitycenter::v1::RunAssetDiscoveryRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::Finding> SetFindingState(
google::cloud::securitycenter::v1::SetFindingStateRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::Finding> SetMute(
google::cloud::securitycenter::v1::SetMuteRequest const& request);
virtual StatusOr<google::iam::v1::Policy> SetIamPolicy(
google::iam::v1::SetIamPolicyRequest const& request);
virtual StatusOr<google::iam::v1::TestIamPermissionsResponse>
TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::ExternalSystem>
UpdateExternalSystem(
google::cloud::securitycenter::v1::UpdateExternalSystemRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::Finding> UpdateFinding(
google::cloud::securitycenter::v1::UpdateFindingRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::MuteConfig>
UpdateMuteConfig(
google::cloud::securitycenter::v1::UpdateMuteConfigRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::NotificationConfig>
UpdateNotificationConfig(
google::cloud::securitycenter::v1::UpdateNotificationConfigRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::OrganizationSettings>
UpdateOrganizationSettings(
google::cloud::securitycenter::v1::
UpdateOrganizationSettingsRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::Source> UpdateSource(
google::cloud::securitycenter::v1::UpdateSourceRequest const& request);
virtual StatusOr<google::cloud::securitycenter::v1::SecurityMarks>
UpdateSecurityMarks(
google::cloud::securitycenter::v1::UpdateSecurityMarksRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::BigQueryExport>
CreateBigQueryExport(
google::cloud::securitycenter::v1::CreateBigQueryExportRequest const&
request);
virtual Status DeleteBigQueryExport(
google::cloud::securitycenter::v1::DeleteBigQueryExportRequest const&
request);
virtual StatusOr<google::cloud::securitycenter::v1::BigQueryExport>
UpdateBigQueryExport(
google::cloud::securitycenter::v1::UpdateBigQueryExportRequest const&
request);
virtual StreamRange<google::cloud::securitycenter::v1::BigQueryExport>
ListBigQueryExports(
google::cloud::securitycenter::v1::ListBigQueryExportsRequest request);
};
std::shared_ptr<SecurityCenterConnection> MakeSecurityCenterConnection(
Options options = {});
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace securitycenter
} // namespace cloud
} // namespace google
namespace google {
namespace cloud {
namespace securitycenter_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
std::shared_ptr<securitycenter::SecurityCenterConnection>
MakeSecurityCenterConnection(std::shared_ptr<SecurityCenterStub> stub,
Options options);
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace securitycenter_internal
} // namespace cloud
} // namespace google
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SECURITYCENTER_SECURITY_CENTER_CONNECTION_H
| 39.5 | 86 | 0.766979 |
8b4725452409cce450b6da7546b483b9cde98642 | 2,617 | h | C | examples/mikeos/kernel/DebugDisplay.h | cashlisa/mos | 75165d1a63a6aa172001bbd9a1df441ff9c15038 | [
"MIT"
] | 302 | 2019-05-20T12:45:37.000Z | 2022-03-29T07:27:43.000Z | examples/mikeos/kernel/DebugDisplay.h | huytd/mos | a9d8f925b87fcc56b94ff5933403f46a3146e1bf | [
"MIT"
] | 12 | 2020-03-27T13:04:53.000Z | 2021-12-07T12:26:29.000Z | examples/mikeos/kernel/DebugDisplay.h | huytd/mos | a9d8f925b87fcc56b94ff5933403f46a3146e1bf | [
"MIT"
] | 33 | 2020-04-08T15:40:44.000Z | 2022-03-12T03:26:07.000Z | #ifndef _DEBUGDISPLAY_H
#define _DEBUGDISPLAY_H
//****************************************************************************
//**
//** DebugDisplay.h
//** - Provides display capabilities for debugging. Because it is
//** specifically for debugging and not final release, we don't
//** care for portability here
//**
//****************************************************************************
//============================================================================
// INTERFACE REQUIRED HEADERS
//============================================================================
#include <stdarg.h>
#include <stdint.h>
//============================================================================
// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
//============================================================================
//============================================================================
// INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
//============================================================================
//============================================================================
// INTERFACE STRUCTURES / UTILITY CLASSES
//============================================================================
//============================================================================
// INTERFACE DATA DECLARATIONS
//============================================================================
//============================================================================
// INTERFACE FUNCTION PROTOTYPES
//============================================================================
void DebugPutc(unsigned char c);
void DebugClrScr(const uint8_t c);
void DebugPuts(char *str);
int DebugPrintf(const char *str, ...);
unsigned DebugSetColor(const unsigned c);
void DebugGotoXY(unsigned x, unsigned y);
void DebugGetXY(unsigned *x, unsigned *y);
int DebugGetHorz();
int DebugGetVert();
//============================================================================
// INTERFACE OBJECT CLASS DEFINITIONS
//============================================================================
//============================================================================
// INTERFACE TRAILING HEADERS
//============================================================================
//****************************************************************************
//**
//** END [FILE NAME]
//**
//****************************************************************************
#endif
| 45.912281 | 79 | 0.269775 |
ae2a42315dce78477bd4cb4a3881f3ca21f5e5ab | 323 | h | C | generic/tcltermbox.h | ray2501/tcl-termbox | 6cd708dfa022ad88050f7f1c1f033e91039b758c | [
"MIT"
] | null | null | null | generic/tcltermbox.h | ray2501/tcl-termbox | 6cd708dfa022ad88050f7f1c1f033e91039b758c | [
"MIT"
] | null | null | null | generic/tcltermbox.h | ray2501/tcl-termbox | 6cd708dfa022ad88050f7f1c1f033e91039b758c | [
"MIT"
] | null | null | null | #ifndef _TERMBOX
#define _TERMBOX
/*
* For C++ compilers, use extern "C"
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <tcl.h>
/*
* Only the _Init function is exported.
*/
extern DLLEXPORT int Termbox_Init(Tcl_Interp * interp);
/*
* end block for C++
*/
#ifdef __cplusplus
}
#endif
#endif /* _TERMBOX */
| 11.137931 | 55 | 0.656347 |
539aed5f1f7bfaa900e8c881284c4c81aa6fcc6c | 95 | h | C | ios/Classes/WatchConnectivityPlugin.h | Rexios80/watch_connectivity | 863e07a3d971a7ca9cfd2dea2e6453b639d7c783 | [
"BSD-3-Clause"
] | null | null | null | ios/Classes/WatchConnectivityPlugin.h | Rexios80/watch_connectivity | 863e07a3d971a7ca9cfd2dea2e6453b639d7c783 | [
"BSD-3-Clause"
] | null | null | null | ios/Classes/WatchConnectivityPlugin.h | Rexios80/watch_connectivity | 863e07a3d971a7ca9cfd2dea2e6453b639d7c783 | [
"BSD-3-Clause"
] | null | null | null | #import <Flutter/Flutter.h>
@interface WatchConnectivityPlugin : NSObject<FlutterPlugin>
@end
| 19 | 60 | 0.810526 |
85ad273654748ff427eb0639e6c9f0dd99a624af | 50,881 | c | C | code/libcdio/lib/iso9660/iso9660_fs.c | timkingh/FFmpeg_VS | 993b14dc146731d782cf4b5fffc6a0f4b9aeea0c | [
"MIT"
] | null | null | null | code/libcdio/lib/iso9660/iso9660_fs.c | timkingh/FFmpeg_VS | 993b14dc146731d782cf4b5fffc6a0f4b9aeea0c | [
"MIT"
] | null | null | null | code/libcdio/lib/iso9660/iso9660_fs.c | timkingh/FFmpeg_VS | 993b14dc146731d782cf4b5fffc6a0f4b9aeea0c | [
"MIT"
] | null | null | null | /*
Copyright (C) 2003-2008, 2011-2015, 2017 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 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/>.
*/
/* iso9660 filesystem-based routines */
/* FIXME: _cdio_list_free for iso9660 statbuf is insufficient because it doesn't
free bits that are allocated inside the data. */
#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__)
#include "config.h"
#define __CDIO_CONFIG_H__ 1
#endif
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_LANGINFO_CODESET
#include <langinfo.h>
#endif
#include <cdio/cdio.h>
#include <cdio/bytesex.h>
#include <cdio/iso9660.h>
#include <cdio/util.h>
#include <cdio/utf8.h>
/* Private headers */
#include "cdio_assert.h"
#include "_cdio_stdio.h"
#include "cdio_private.h"
/** Implementation of iso9660_t type */
struct _iso9660_s {
CdioDataSource_t *stream; /**< Stream pointer */
bool_3way_t b_xa; /**< true if has XA attributes. */
bool_3way_t b_mode2; /**< true if has mode 2, false for mode 1. */
uint8_t u_joliet_level; /**< 0 = no Joliet extensions.
1-3: Joliet level. */
iso9660_pvd_t pvd;
iso9660_svd_t svd;
iso_extension_mask_t iso_extension_mask; /**< What extensions we
tolerate. */
uint32_t i_datastart; /**< Usually 0 when i_framesize is ISO_BLOCKSIZE.
This is the normal condition. But in a fuzzy
read we may be reading a CD-image
and not a true ISO 9660 image this might be
CDIO_CD_SYNC_SIZE
*/
uint32_t i_framesize; /**< Usually ISO_BLOCKSIZE (2048), but in a
fuzzy read, we may be reading a CD-image
and not a true ISO 9660 image this might
be CDIO_CD_FRAMESIZE_RAW (2352) or
M2RAW_SECTOR_SIZE (2336).
*/
int i_fuzzy_offset; /**< Adjustment in bytes to make ISO_STANDARD_ID
("CD001") come out as ISO_PVD_SECTOR
(frame 16). Normally this should be 0
for an ISO 9660 image, but if one is
say reading a BIN/CUE or cdrdao BIN/TOC
without having the CUE or TOC and
trying to extract an ISO-9660
filesystem inside that it may be
different.
*/
bool b_have_superblock; /**< Superblock has been read in? */
};
static long int iso9660_seek_read_framesize (const iso9660_t *p_iso,
void *ptr, lsn_t start,
long int size,
uint16_t i_framesize);
/* Adjust the p_iso's i_datastart, i_byte_offset and i_framesize
based on whether we find a frame header or not.
*/
static void
adjust_fuzzy_pvd( iso9660_t *p_iso )
{
long int i_byte_offset;
if (!p_iso) return;
i_byte_offset = (ISO_PVD_SECTOR * p_iso->i_framesize)
+ p_iso->i_fuzzy_offset + p_iso->i_datastart;
/* If we have a raw 2352-byte frame then we should expect to see a sync
frame and a header.
*/
if (CDIO_CD_FRAMESIZE_RAW == p_iso->i_framesize) {
char buf[CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE + CDIO_CD_SUBHEADER_SIZE];
i_byte_offset -= CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE + CDIO_CD_SUBHEADER_SIZE;
if ( DRIVER_OP_SUCCESS != cdio_stream_seek (p_iso->stream, i_byte_offset,
SEEK_SET) )
return;
if (sizeof(buf) == cdio_stream_read (p_iso->stream, buf, sizeof(buf), 1)) {
/* Does the sector frame header suggest Mode 1 format? */
if (!memcmp(CDIO_SECTOR_SYNC_HEADER, buf+CDIO_CD_SUBHEADER_SIZE,
CDIO_CD_SYNC_SIZE)) {
if (buf[14+CDIO_CD_SUBHEADER_SIZE] != 0x16) {
cdio_warn ("Expecting the PVD sector header MSF to be 0x16, is: %x",
buf[14]);
}
if (buf[15+CDIO_CD_SUBHEADER_SIZE] != 0x1) {
cdio_warn ("Expecting the PVD sector mode to be Mode 1 is: %x",
buf[15]);
}
p_iso->b_mode2 = nope;
p_iso->b_xa = nope;
} else if (!memcmp(CDIO_SECTOR_SYNC_HEADER, buf, CDIO_CD_SYNC_SIZE)) {
/* Frame header indicates Mode 2 Form 1*/
if (buf[14] != 0x16) {
cdio_warn ("Expecting the PVD sector header MSF to be 0x16, is: %x",
buf[14]);
}
if (buf[15] != 0x2) {
cdio_warn ("Expecting the PVD sector mode to be Mode 2 is: %x",
buf[15]);
}
p_iso->b_mode2 = yep;
/* Do do: check Mode 2 Form 2? */
} else {
/* Has no frame header */
p_iso->i_framesize = M2RAW_SECTOR_SIZE;
p_iso->i_fuzzy_offset = (CDIO_CD_FRAMESIZE_RAW - M2RAW_SECTOR_SIZE)
* ISO_PVD_SECTOR + p_iso->i_fuzzy_offset + p_iso->i_datastart;
p_iso->i_datastart = 0;
}
}
}
}
/*!
Open an ISO 9660 image for reading in either fuzzy mode or not.
*/
static iso9660_t *
iso9660_open_ext_private (const char *psz_path,
iso_extension_mask_t iso_extension_mask,
uint16_t i_fuzz, bool b_fuzzy)
{
iso9660_t *p_iso = (iso9660_t *) calloc(1, sizeof(iso9660_t)) ;
if (!p_iso) return NULL;
p_iso->stream = cdio_stdio_new( psz_path );
if (NULL == p_iso->stream)
goto error;
p_iso->i_framesize = ISO_BLOCKSIZE;
p_iso->b_have_superblock = (b_fuzzy)
? iso9660_ifs_fuzzy_read_superblock(p_iso, iso_extension_mask, i_fuzz)
: iso9660_ifs_read_superblock(p_iso, iso_extension_mask) ;
if ( ! p_iso->b_have_superblock ) goto error;
/* Determine if image has XA attributes. */
p_iso->b_xa = strncmp ((char *) &(p_iso->pvd) + ISO_XA_MARKER_OFFSET,
ISO_XA_MARKER_STRING,
sizeof (ISO_XA_MARKER_STRING))
? nope : yep;
p_iso->iso_extension_mask = iso_extension_mask;
return p_iso;
error:
if (p_iso && p_iso->stream) cdio_stdio_destroy(p_iso->stream);
free(p_iso);
return NULL;
}
/*!
Open an ISO 9660 image for reading. Maybe in the future we will have
a mode. NULL is returned on error.
@param psz_path full path of ISO9660 file.
@return a IS9660 structure is unconditionally returned. The caller
should call iso9660_close() when done.
*/
iso9660_t *
iso9660_open (const char *psz_path /*, mode*/)
{
return iso9660_open_ext(psz_path, ISO_EXTENSION_NONE);
}
/*!
Open an ISO 9660 image for reading allowing various ISO 9660
extensions. Maybe in the future we will have a mode. NULL is
returned on error.
@see iso9660_open_fuzzy
*/
iso9660_t *
iso9660_open_ext (const char *psz_path,
iso_extension_mask_t iso_extension_mask)
{
return iso9660_open_ext_private(psz_path, iso_extension_mask, 0, false);
}
/*! Open an ISO 9660 image for "fuzzy" reading. This means that we
will try to guess various internal offset based on internal
checks. This may be useful when trying to read an ISO 9660 image
contained in a file format that libiso9660 doesn't know natively
(or knows imperfectly.)
Some tolerence allowed for positioning the ISO 9660 image. We scan
for STANDARD_ID and use that to set the eventual offset to adjust
by (as long as that is <= i_fuzz).
Maybe in the future we will have a mode. NULL is returned on error.
@see iso9660_open, @see iso9660_fuzzy_ext
*/
iso9660_t *
iso9660_open_fuzzy (const char *psz_path, uint16_t i_fuzz /*, mode*/)
{
return iso9660_open_fuzzy_ext(psz_path, ISO_EXTENSION_NONE, i_fuzz);
}
/*!
Open an ISO 9660 image for reading with some tolerence for positioning
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
the eventual offset to adjust by (as long as that is <= i_fuzz).
Maybe in the future we will have a mode. NULL is returned on error.
@see iso9660_open_ext @see iso9660_open_fuzzy
*/
iso9660_t *
iso9660_open_fuzzy_ext (const char *psz_path,
iso_extension_mask_t iso_extension_mask,
uint16_t i_fuzz)
{
return iso9660_open_ext_private(psz_path, iso_extension_mask, i_fuzz,
true);
}
/*! Close previously opened ISO 9660 image and free resources
associated with the image. Call this when done using using an ISO
9660 image.
@return true is unconditionally returned. If there was an error
false would be returned.
*/
bool
iso9660_close (iso9660_t *p_iso)
{
if (NULL != p_iso) {
cdio_stdio_destroy(p_iso->stream);
p_iso->stream = NULL;
free(p_iso);
}
return true;
}
static bool
check_pvd (const iso9660_pvd_t *p_pvd, cdio_log_level_t log_level)
{
if ( ISO_VD_PRIMARY != from_711(p_pvd->type) ) {
cdio_log (log_level, "unexpected PVD type %d", p_pvd->type);
return false;
}
if (strncmp (p_pvd->id, ISO_STANDARD_ID, strlen (ISO_STANDARD_ID)))
{
cdio_log (log_level, "unexpected ID encountered (expected `"
ISO_STANDARD_ID "', got `%.5s')", p_pvd->id);
return false;
}
return true;
}
/*!
Core procedure for the iso9660_ifs_get_###_id() calls.
pvd_member/svd_member is a pointer to an achar_t or dchar_t
ID string which we can superset as char.
If the Joliet converted string is the same as the achar_t/dchar_t
one, we fall back to using the latter, as it may be longer.
*/
static inline bool
get_member_id(iso9660_t *p_iso, cdio_utf8_t **p_psz_member_id,
char* pvd_member, char* svd_member, size_t max_size)
{
int j;
bool strip;
if (!p_iso) {
*p_psz_member_id = NULL;
return false;
}
#ifdef HAVE_JOLIET
if (p_iso->u_joliet_level) {
/* Translate USC-2 string from Secondary Volume Descriptor */
if (cdio_charset_to_utf8(svd_member, max_size,
p_psz_member_id, "UCS-2BE")) {
/* NB: *p_psz_member_id is never NULL on success. */
if (strncmp(*p_psz_member_id, pvd_member,
strlen(*p_psz_member_id)) != 0) {
/* Strip trailing spaces */
for (j = strlen(*p_psz_member_id)-1; j >= 0; j--) {
if ((*p_psz_member_id)[j] != ' ')
break;
(*p_psz_member_id)[j] = '\0';
}
if ((*p_psz_member_id)[0] != 0) {
/* Joliet string is not empty and differs from
non Joliet one => use it */
return true;
}
}
/* Joliet string was either empty or same */
free(*p_psz_member_id);
}
}
#endif /*HAVE_JOLIET*/
*p_psz_member_id = calloc(max_size+1, sizeof(cdio_utf8_t));
if (!*p_psz_member_id) {
cdio_warn("Memory allocation error");
return false;
}
/* Copy string while removing trailing spaces */
(*p_psz_member_id)[max_size] = 0;
for (strip=true, j=max_size-1; j>=0; j--) {
if (strip && (pvd_member[j] == ' '))
continue;
strip = false;
(*p_psz_member_id)[j] = pvd_member[j];
}
if (strlen(*p_psz_member_id) == 0) {
free(*p_psz_member_id);
*p_psz_member_id = NULL;
return false;
}
return true;
}
/*!
Return the application ID. NULL is returned in psz_app_id if there
is some problem in getting this.
*/
bool
iso9660_ifs_get_application_id(iso9660_t *p_iso,
/*out*/ cdio_utf8_t **p_psz_app_id)
{
return get_member_id(p_iso, p_psz_app_id,
(char*)p_iso->pvd.application_id,
(char*)p_iso->svd.application_id,
ISO_MAX_APPLICATION_ID);
}
/*!
Return the Joliet level recognized for p_iso.
*/
uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso)
{
if (!p_iso) return 0;
return p_iso->u_joliet_level;
}
/*!
Return a string containing the preparer id with trailing
blanks removed.
*/
bool
iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
/*out*/ cdio_utf8_t **p_psz_preparer_id)
{
return get_member_id(p_iso, p_psz_preparer_id,
(char*)p_iso->pvd.preparer_id,
(char*)p_iso->svd.preparer_id,
ISO_MAX_PREPARER_ID);
}
/*!
Return a string containing the PVD's publisher id with trailing
blanks removed.
*/
bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
/*out*/ cdio_utf8_t **p_psz_publisher_id)
{
return get_member_id(p_iso, p_psz_publisher_id,
(char*)p_iso->pvd.publisher_id,
(char*)p_iso->svd.publisher_id,
ISO_MAX_PUBLISHER_ID);
}
/*!
Return a string containing the PVD's publisher id with trailing
blanks removed.
*/
bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
/*out*/ cdio_utf8_t **p_psz_system_id)
{
return get_member_id(p_iso, p_psz_system_id,
(char*)p_iso->pvd.system_id,
(char*)p_iso->svd.system_id,
ISO_MAX_SYSTEM_ID);
}
/*!
Return a string containing the PVD's publisher id with trailing
blanks removed.
*/
bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
/*out*/ cdio_utf8_t **p_psz_volume_id)
{
return get_member_id(p_iso, p_psz_volume_id,
(char*)p_iso->pvd.volume_id,
(char*)p_iso->svd.volume_id,
ISO_MAX_VOLUME_ID);
}
/*!
Return a string containing the PVD's publisher id with trailing
blanks removed.
*/
bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
/*out*/ cdio_utf8_t **p_psz_volumeset_id)
{
return get_member_id(p_iso, p_psz_volumeset_id,
(char*)p_iso->pvd.volume_set_id,
(char*)p_iso->svd.volume_set_id,
ISO_MAX_VOLUMESET_ID);
}
/*!
Read the Primary Volume Descriptor for an ISO 9660 image.
True is returned if read, and false if there was an error.
*/
static bool
iso9660_ifs_read_pvd_loglevel (const iso9660_t *p_iso,
/*out*/ iso9660_pvd_t *p_pvd,
cdio_log_level_t log_level)
{
if (0 == iso9660_iso_seek_read (p_iso, p_pvd, ISO_PVD_SECTOR, 1)) {
cdio_log ( log_level, "error reading PVD sector (%d)", ISO_PVD_SECTOR );
return false;
}
return check_pvd(p_pvd, log_level);
}
/*!
Read the Primary Volume Descriptor for an ISO 9660 image.
True is returned if read, and false if there was an error.
*/
bool
iso9660_ifs_read_pvd (const iso9660_t *p_iso, /*out*/ iso9660_pvd_t *p_pvd)
{
return iso9660_ifs_read_pvd_loglevel(p_iso, p_pvd, CDIO_LOG_WARN);
}
/*!
Read the Super block of an ISO 9660 image. This is the
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
Descriptor if (Joliet) extensions are acceptable.
*/
bool
iso9660_ifs_read_superblock (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask)
{
iso9660_svd_t p_svd; /* Secondary volume descriptor. */
int i;
if (!p_iso || !iso9660_ifs_read_pvd(p_iso, &(p_iso->pvd)))
return false;
p_iso->u_joliet_level = 0;
/* There may be multiple Secondary Volume Descriptors (eg. El Torito + Joliet) */
for (i=1; (0 != iso9660_iso_seek_read (p_iso, &p_svd, ISO_PVD_SECTOR+i, 1)); i++) {
if (ISO_VD_END == from_711(p_svd.type) ) /* Last SVD */
break;
if ( ISO_VD_SUPPLEMENTARY == from_711(p_svd.type) ) {
/* We're only interested in Joliet => make sure the SVD isn't overwritten */
if (p_iso->u_joliet_level == 0)
memcpy(&(p_iso->svd), &p_svd, sizeof(iso9660_svd_t));
if (p_svd.escape_sequences[0] == 0x25
&& p_svd.escape_sequences[1] == 0x2f) {
switch (p_svd.escape_sequences[2]) {
case 0x40:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL1)
p_iso->u_joliet_level = 1;
break;
case 0x43:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL2)
p_iso->u_joliet_level = 2;
break;
case 0x45:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL3)
p_iso->u_joliet_level = 3;
break;
default:
cdio_info("Supplementary Volume Descriptor found, but not Joliet");
}
if (p_iso->u_joliet_level > 0) {
cdio_info("Found Extension: Joliet Level %d", p_iso->u_joliet_level);
}
}
}
}
return true;
}
/*!
Read the Super block of an ISO 9660 image but determine framesize
and datastart and a possible additional offset. Generally here we are
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
filesystem.
*/
bool
iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask,
uint16_t i_fuzz)
{
/* Got some work to do to find ISO_STANDARD_ID ("CD001") */
unsigned int i;
for (i=0; i<i_fuzz; i++) {
unsigned int j;
char *pvd = NULL;
for (j = 0; j <= 1; j++ ) {
lsn_t lsn;
uint16_t k;
const uint16_t framesizes[] = { ISO_BLOCKSIZE, CDIO_CD_FRAMESIZE_RAW,
M2RAW_SECTOR_SIZE } ;
/* We don't need to loop over a zero offset twice*/
if (0==i && j)
continue;
lsn = (j) ? ISO_PVD_SECTOR - i : ISO_PVD_SECTOR + i;
for (k=0; k < 3; k++) {
char *p, *q;
char frame[CDIO_CD_FRAMESIZE_RAW] = {'\0',};
p_iso->i_framesize = framesizes[k];
p_iso->i_datastart = (ISO_BLOCKSIZE == framesizes[k]) ?
0 : CDIO_CD_SYNC_SIZE;
p_iso->i_fuzzy_offset = 0;
if (0 == iso9660_seek_read_framesize (p_iso, frame, lsn, 1,
p_iso->i_framesize)) {
return false;
}
q = memchr(frame, 'C', p_iso->i_framesize);
for ( p=q; p && p < frame + p_iso->i_framesize ; p=q+1 ) {
q = memchr(p, 'C', p_iso->i_framesize - (p - frame));
if ( !q || (pvd = strstr(q, ISO_STANDARD_ID)) )
break;
}
if (pvd) {
/* Yay! Found something */
p_iso->i_fuzzy_offset = (pvd - frame - 1) -
((ISO_PVD_SECTOR-lsn)*p_iso->i_framesize) ;
/* But is it *really* a PVD? */
if ( iso9660_ifs_read_pvd_loglevel(p_iso, &(p_iso->pvd),
CDIO_LOG_DEBUG) ) {
adjust_fuzzy_pvd(p_iso);
return true;
}
}
}
}
}
return false;
}
/*!
Read the Primary Volume Descriptor for of CD.
*/
bool
iso9660_fs_read_pvd(const CdIo_t *p_cdio, /*out*/ iso9660_pvd_t *p_pvd)
{
/* A bit of a hack, we'll assume track 1 contains ISO_PVD_SECTOR.*/
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
driver_return_code_t driver_return =
cdio_read_data_sectors (p_cdio, buf, ISO_PVD_SECTOR, ISO_BLOCKSIZE, 1);
if (DRIVER_OP_SUCCESS != driver_return) {
cdio_warn ("error reading PVD sector (%d) error %d", ISO_PVD_SECTOR,
driver_return);
return false;
}
/* The size of a PVD or SVD is smaller than a sector. So we
allocated a bigger block above (buf) and now we'll copy just
the part we need to save.
*/
cdio_assert (sizeof(buf) >= sizeof (iso9660_pvd_t));
memcpy(p_pvd, buf, sizeof(iso9660_pvd_t));
return check_pvd(p_pvd, CDIO_LOG_WARN);
}
/*!
Read the Super block of an ISO 9660 image. This is the
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
Descriptor if (Joliet) extensions are acceptable.
*/
bool
iso9660_fs_read_superblock (CdIo_t *p_cdio,
iso_extension_mask_t iso_extension_mask)
{
if (!p_cdio) return false;
{
generic_img_private_t *p_env = (generic_img_private_t *) p_cdio->env;
iso9660_pvd_t *p_pvd = &(p_env->pvd);
iso9660_svd_t *p_svd = &(p_env->svd);
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
driver_return_code_t driver_return;
if ( !iso9660_fs_read_pvd(p_cdio, p_pvd) )
return false;
p_env->u_joliet_level = 0;
driver_return =
cdio_read_data_sectors ( p_cdio, buf, ISO_PVD_SECTOR+1, ISO_BLOCKSIZE,
1 );
if (DRIVER_OP_SUCCESS == driver_return) {
/* The size of a PVD or SVD is smaller than a sector. So we
allocated a bigger block above (buf) and now we'll copy just
the part we need to save.
*/
cdio_assert (sizeof(buf) >= sizeof (iso9660_svd_t));
memcpy(p_svd, buf, sizeof(iso9660_svd_t));
if ( ISO_VD_SUPPLEMENTARY == from_711(p_svd->type) ) {
if (p_svd->escape_sequences[0] == 0x25
&& p_svd->escape_sequences[1] == 0x2f) {
switch (p_svd->escape_sequences[2]) {
case 0x40:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL1)
p_env->u_joliet_level = 1;
break;
case 0x43:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL2)
p_env->u_joliet_level = 2;
break;
case 0x45:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL3)
p_env->u_joliet_level = 3;
break;
default:
cdio_info("Supplementary Volume Descriptor found, but not Joliet");
}
if (p_env->u_joliet_level > 0) {
cdio_info("Found Extension: Joliet Level %d",
p_env->u_joliet_level);
}
}
}
}
}
return true;
}
/*!
Seek to a position and then read n blocks. Size read is returned.
*/
static long int
iso9660_seek_read_framesize (const iso9660_t *p_iso, void *ptr,
lsn_t start, long int size,
uint16_t i_framesize)
{
long int ret;
int64_t i_byte_offset;
if (!p_iso) return 0;
i_byte_offset = (start * (int64_t)(p_iso->i_framesize))
+ p_iso->i_fuzzy_offset + p_iso->i_datastart;
ret = cdio_stream_seek (p_iso->stream, i_byte_offset, SEEK_SET);
if (ret!=0) return 0;
return cdio_stream_read (p_iso->stream, ptr, i_framesize, size);
}
/*!
Seek to a position and then read n blocks. Size read is returned.
*/
long int
iso9660_iso_seek_read (const iso9660_t *p_iso, void *ptr, lsn_t start,
long int size)
{
return iso9660_seek_read_framesize(p_iso, ptr, start, size, ISO_BLOCKSIZE);
}
/*!
Check for the end of a directory record list in a single directory
block. If at the end, set the offset to start of the next block and
return "true". The caller often skips actions only when at the end
of a record list.
*/
static bool
iso9660_check_dir_block_end(iso9660_dir_t *p_iso9660_dir, unsigned *offset)
{
if (!iso9660_get_dir_len(p_iso9660_dir))
{
/*
Length 0 indicates that no more directory records are in this
block. This matches how Linux and libburn's libisofs work.
Note that assignment below does not exactly round up.
If (offset % ISO_BLOCKSIZE) == 0 then offset is incremented
by ISO_BLOCKSIZE, i.e. the block is skipped.
*/
*offset += ISO_BLOCKSIZE - (*offset % ISO_BLOCKSIZE);
return true;
}
if ((*offset + iso9660_get_dir_len(p_iso9660_dir) - 1) / ISO_BLOCKSIZE
!= *offset / ISO_BLOCKSIZE)
{
/*
Directory record spans over block limit.
Hop to next block where a new record is supposed to begin,
if it is not after the end of the directory data.
*/
*offset += ISO_BLOCKSIZE - (*offset % ISO_BLOCKSIZE);
return true;
}
return false;
}
static iso9660_stat_t *
_iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
uint8_t u_joliet_level)
{
uint8_t dir_len= iso9660_get_dir_len(p_iso9660_dir);
iso711_t i_fname;
unsigned int stat_len;
iso9660_stat_t *p_stat = NULL;
bool err;
if (!dir_len) return NULL;
i_fname = from_711(p_iso9660_dir->filename.len);
/* .. string in statbuf is one longer than in p_iso9660_dir's listing '\1' */
stat_len = sizeof(iso9660_stat_t)+i_fname+2;
p_stat = calloc(1, stat_len);
if (!p_stat)
{
cdio_warn("Couldn't calloc(1, %d)", stat_len);
return NULL;
}
p_stat->type = (p_iso9660_dir->file_flags & ISO_DIRECTORY)
? _STAT_DIR : _STAT_FILE;
p_stat->lsn = from_733_with_err (p_iso9660_dir->extent, &err);
if (err) {
free(p_stat);
return NULL;
}
p_stat->size = from_733_with_err (p_iso9660_dir->size, &err);
if (err) {
free(p_stat);
return NULL;
}
p_stat->secsize = _cdio_len2blocks (p_stat->size, ISO_BLOCKSIZE);
p_stat->rr.b3_rock = dunno; /*FIXME should do based on mask */
p_stat->b_xa = false;
{
char rr_fname[256] = "";
int i_rr_fname =
#ifdef HAVE_ROCK
get_rock_ridge_filename(p_iso9660_dir, rr_fname, p_stat);
#else
0;
#endif
if (i_rr_fname > 0) {
if (i_rr_fname > i_fname) {
/* realloc gives valgrind errors */
iso9660_stat_t *p_stat_new =
calloc(1, sizeof(iso9660_stat_t)+i_rr_fname+2);
if (!p_stat_new)
{
cdio_warn("Couldn't calloc(1, %d)", (int)(sizeof(iso9660_stat_t)+i_rr_fname+2));
free(p_stat);
return NULL;
}
memcpy(p_stat_new, p_stat, stat_len);
free(p_stat);
p_stat = p_stat_new;
}
strncpy(p_stat->filename, rr_fname, i_rr_fname+1);
} else {
if ('\0' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
strncpy (p_stat->filename, ".", sizeof("."));
else if ('\1' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
strncpy (p_stat->filename, "..", sizeof(".."));
#ifdef HAVE_JOLIET
else if (u_joliet_level) {
int i_inlen = i_fname;
cdio_utf8_t *p_psz_out = NULL;
if (cdio_charset_to_utf8(&p_iso9660_dir->filename.str[1], i_inlen,
&p_psz_out, "UCS-2BE")) {
strncpy(p_stat->filename, p_psz_out, i_fname);
free(p_psz_out);
}
else {
free(p_stat);
return NULL;
}
}
#endif /*HAVE_JOLIET*/
else {
strncpy (p_stat->filename, &p_iso9660_dir->filename.str[1], i_fname);
}
}
}
iso9660_get_dtime(&(p_iso9660_dir->recording_time), true, &(p_stat->tm));
if (dir_len < sizeof (iso9660_dir_t)) {
iso9660_stat_free(p_stat);
return NULL;
}
{
int su_length = iso9660_get_dir_len(p_iso9660_dir)
- sizeof (iso9660_dir_t);
su_length -= i_fname;
if (su_length % 2)
su_length--;
if (su_length < 0 || su_length < sizeof (iso9660_xa_t))
return p_stat;
if (nope == b_xa) {
return p_stat;
} else {
iso9660_xa_t *xa_data =
(void *) (((char *) p_iso9660_dir)
+ (iso9660_get_dir_len(p_iso9660_dir) - su_length));
cdio_log_level_t loglevel = (yep == b_xa)
? CDIO_LOG_WARN : CDIO_LOG_INFO;
if (xa_data->signature[0] != 'X'
|| xa_data->signature[1] != 'A')
{
cdio_log (loglevel,
"XA signature not found in ISO9660's system use area;"
" ignoring XA attributes for this file entry.");
cdio_debug ("%d %d %d, '%c%c' (%d, %d)",
iso9660_get_dir_len(p_iso9660_dir),
i_fname,
su_length,
xa_data->signature[0], xa_data->signature[1],
xa_data->signature[0], xa_data->signature[1]);
return p_stat;
}
p_stat->b_xa = true;
p_stat->xa = *xa_data;
}
}
return p_stat;
}
/*!
Return the directory name stored in the iso9660_dir_t
A string is allocated: the caller must deallocate. This routine
can return NULL if memory allocation fails.
*/
char *
iso9660_dir_to_name (const iso9660_dir_t *iso9660_dir)
{
uint8_t len=iso9660_get_dir_len(iso9660_dir);
if (!len) return NULL;
cdio_assert (len >= sizeof (iso9660_dir_t));
/* (iso9660_dir->file_flags & ISO_DIRECTORY) */
if (iso9660_dir->filename.str[1] == '\0')
return strdup(".");
else if (iso9660_dir->filename.str[1] == '\1')
return strdup("..");
else {
return strdup(&iso9660_dir->filename.str[1]);
}
}
/*
Return a pointer to a ISO 9660 stat buffer or NULL if there's an error
*/
static iso9660_stat_t *
_fs_stat_root (CdIo_t *p_cdio)
{
if (!p_cdio) return NULL;
{
iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
generic_img_private_t *p_env = (generic_img_private_t *) p_cdio->env;
iso9660_dir_t *p_iso9660_dir;
iso9660_stat_t *p_stat;
bool_3way_t b_xa;
if (!p_env->u_joliet_level)
iso_extension_mask &= ~ISO_EXTENSION_JOLIET;
/* FIXME try also with Joliet.*/
if ( !iso9660_fs_read_superblock (p_cdio, iso_extension_mask) ) {
cdio_warn("Could not read ISO-9660 Superblock.");
return NULL;
}
switch(cdio_get_discmode(p_cdio)) {
case CDIO_DISC_MODE_CD_XA:
b_xa = yep;
break;
case CDIO_DISC_MODE_CD_DATA:
b_xa = nope;
break;
default:
b_xa = dunno;
}
#ifdef HAVE_JOLIET
p_iso9660_dir = p_env->u_joliet_level
? &(p_env->svd.root_directory_record)
: &(p_env->pvd.root_directory_record) ;
#else
p_iso9660_dir = &(p_env->pvd.root_directory_record) ;
#endif
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, b_xa,
p_env->u_joliet_level);
return p_stat;
}
}
static iso9660_stat_t *
_ifs_stat_root (iso9660_t *p_iso)
{
iso9660_stat_t *p_stat;
iso9660_dir_t *p_iso9660_dir;
#ifdef HAVE_JOLIET
p_iso9660_dir = p_iso->u_joliet_level
? &(p_iso->svd.root_directory_record)
: &(p_iso->pvd.root_directory_record) ;
#else
p_iso9660_dir = &(p_iso->pvd.root_directory_record) ;
#endif
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_xa,
p_iso->u_joliet_level);
return p_stat;
}
static iso9660_stat_t *
_fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
char **splitpath)
{
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
iso9660_stat_t *p_stat;
generic_img_private_t *p_env = (generic_img_private_t *) p_cdio->env;
if (!splitpath[0])
{
unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1;
p_stat = calloc(1, len);
cdio_assert (p_stat != NULL);
memcpy(p_stat, _root, len);
p_stat->rr.psz_symlink = calloc(1, p_stat->rr.i_symlink_max);
cdio_assert (p_stat->rr.psz_symlink != NULL);
memcpy(p_stat->rr.psz_symlink, _root->rr.psz_symlink,
p_stat->rr.i_symlink_max);
return p_stat;
}
if (_root->type == _STAT_FILE)
return NULL;
cdio_assert (_root->type == _STAT_DIR);
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
cdio_warn("Couldn't calloc(1, %d)", _root->secsize * ISO_BLOCKSIZE);
return NULL;
}
if (cdio_read_data_sectors (p_cdio, _dirbuf, _root->lsn, ISO_BLOCKSIZE,
_root->secsize))
return NULL;
while (offset < (_root->secsize * ISO_BLOCKSIZE))
{
iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset];
iso9660_stat_t *p_iso9660_stat;
int cmp;
if (iso9660_check_dir_block_end(p_iso9660_dir, &offset))
continue;
p_iso9660_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, dunno,
p_env->u_joliet_level);
cmp = strcmp(splitpath[0], p_iso9660_stat->filename);
if ( 0 != cmp && 0 == p_env->u_joliet_level
&& yep != p_iso9660_stat->rr.b3_rock ) {
char *trans_fname = NULL;
unsigned int i_trans_fname=strlen(p_iso9660_stat->filename);
if (i_trans_fname) {
trans_fname = calloc(1, i_trans_fname+1);
if (!trans_fname) {
cdio_warn("can't allocate %lu bytes",
(long unsigned int) strlen(p_iso9660_stat->filename));
free(p_iso9660_stat);
return NULL;
}
iso9660_name_translate_ext(p_iso9660_stat->filename, trans_fname,
p_env->u_joliet_level);
cmp = strcmp(splitpath[0], trans_fname);
free(trans_fname);
}
}
if (!cmp) {
iso9660_stat_t *ret_stat
= _fs_stat_traverse (p_cdio, p_iso9660_stat, &splitpath[1]);
iso9660_stat_free(p_iso9660_stat);
free (_dirbuf);
return ret_stat;
}
iso9660_stat_free(p_iso9660_stat);
offset += iso9660_get_dir_len(p_iso9660_dir);
}
cdio_assert (offset == (_root->secsize * ISO_BLOCKSIZE));
/* not found */
free (_dirbuf);
return NULL;
}
static iso9660_stat_t *
_fs_iso_stat_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
char **splitpath)
{
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
int ret;
if (!splitpath[0])
{
iso9660_stat_t *p_stat;
unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1;
p_stat = calloc(1, len);
cdio_assert (p_stat != NULL);
memcpy(p_stat, _root, len);
p_stat->rr.psz_symlink = calloc(1, p_stat->rr.i_symlink_max);
cdio_assert (p_stat->rr.psz_symlink != NULL);
memcpy(p_stat->rr.psz_symlink, _root->rr.psz_symlink,
p_stat->rr.i_symlink_max);
return p_stat;
}
if (_root->type == _STAT_FILE)
return NULL;
cdio_assert (_root->type == _STAT_DIR);
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
cdio_warn("Couldn't calloc(1, %d)", _root->secsize * ISO_BLOCKSIZE);
return NULL;
}
ret = iso9660_iso_seek_read (p_iso, _dirbuf, _root->lsn, _root->secsize);
if (ret!=ISO_BLOCKSIZE*_root->secsize) {
free(_dirbuf);
return NULL;
}
while (offset < (_root->secsize * ISO_BLOCKSIZE))
{
iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset];
iso9660_stat_t *p_stat;
int cmp;
if (iso9660_check_dir_block_end(p_iso9660_dir, &offset))
continue;
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_xa,
p_iso->u_joliet_level);
if (!p_stat) {
cdio_warn("Bad directory information for %s", splitpath[0]);
free(_dirbuf);
return NULL;
}
cmp = strcmp(splitpath[0], p_stat->filename);
if ( 0 != cmp && 0 == p_iso->u_joliet_level
&& yep != p_stat->rr.b3_rock ) {
char *trans_fname = NULL;
unsigned int i_trans_fname=strlen(p_stat->filename);
if (i_trans_fname) {
trans_fname = calloc(1, i_trans_fname+1);
if (!trans_fname) {
cdio_warn("can't allocate %lu bytes",
(long unsigned int) strlen(p_stat->filename));
free(p_stat);
return NULL;
}
iso9660_name_translate_ext(p_stat->filename, trans_fname,
p_iso->u_joliet_level);
cmp = strcmp(splitpath[0], trans_fname);
free(trans_fname);
}
}
if (!cmp) {
iso9660_stat_t *ret_stat
= _fs_iso_stat_traverse (p_iso, p_stat, &splitpath[1]);
iso9660_stat_free(p_stat);
free (_dirbuf);
return ret_stat;
}
iso9660_stat_free(p_stat);
offset += iso9660_get_dir_len(p_iso9660_dir);
}
cdio_assert (offset == (_root->secsize * ISO_BLOCKSIZE));
/* not found */
free (_dirbuf);
return NULL;
}
/*!
Return file status for psz_path. NULL is returned on error.
@param p_cdio the CD object to read from
@param psz_path filename path to look up and get information about
@return ISO 9660 file information
Important note:
You make get different results looking up "/" versus "/." and the
latter may give more complete information. "/" will take information
from the PVD only, whereas "/." will force a directory read of "/" and
find "." and in that Rock-Ridge information might be found which fills
in more stat information. Ideally iso9660_fs_stat should be fixed.
Patches anyone?
*/
iso9660_stat_t *
iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[])
{
iso9660_stat_t *p_root;
char **p_psz_splitpath;
iso9660_stat_t *p_stat;
if (!p_cdio) return NULL;
if (!psz_path) return NULL;
p_root = _fs_stat_root (p_cdio);
if (!p_root) return NULL;
p_psz_splitpath = _cdio_strsplit (psz_path, '/');
p_stat = _fs_stat_traverse (p_cdio, p_root, p_psz_splitpath);
free(p_root);
_cdio_strfreev (p_psz_splitpath);
return p_stat;
}
typedef iso9660_stat_t * (stat_root_t) (void *p_image);
typedef iso9660_stat_t * (stat_traverse_t)
(const void *p_image, const iso9660_stat_t *_root, char **splitpath);
/*!
Get file status for psz_path into stat. NULL is returned on error.
pathname version numbers in the ISO 9660
name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names
are lowercased.
*/
static iso9660_stat_t *
fs_stat_translate (void *p_image, stat_root_t stat_root,
stat_traverse_t stat_traverse,
const char psz_path[])
{
iso9660_stat_t *p_root;
char **p_psz_splitpath;
iso9660_stat_t *p_stat;
if (!p_image) return NULL;
if (!psz_path) return NULL;
p_root = stat_root (p_image);
if (!p_root) return NULL;
p_psz_splitpath = _cdio_strsplit (psz_path, '/');
p_stat = stat_traverse (p_image, p_root, p_psz_splitpath);
free(p_root);
_cdio_strfreev (p_psz_splitpath);
return p_stat;
}
/*!
Return file status for path name psz_path. NULL is returned on error.
pathname version numbers in the ISO 9660 name are dropped, i.e. ;1
is removed and if level 1 ISO-9660 names are lowercased.
@param p_cdio the CD object to read from
@param psz_path filename path to look up and get information about
@return ISO 9660 file information. The caller must free the
returned result using iso9660_stat_free().
*/
iso9660_stat_t *
iso9660_fs_stat_translate (CdIo_t *p_cdio, const char psz_path[])
{
return fs_stat_translate(p_cdio, (stat_root_t *) _fs_stat_root,
(stat_traverse_t *) _fs_stat_traverse,
psz_path);
}
/*!
@param p_iso the ISO-9660 file image to get data from
@param psz_path filename path translate
@return file status for path name psz_path. NULL is returned on
error. pathname version numbers in the ISO 9660 name are dropped,
i.e. ;1 is removed and if level 1 ISO-9660 names are lowercased.
The caller must free the returned result using iso9660_stat_free().
*/
iso9660_stat_t *
iso9660_ifs_stat_translate (iso9660_t *p_iso, const char psz_path[])
{
return fs_stat_translate(p_iso, (stat_root_t *) _ifs_stat_root,
(stat_traverse_t *) _fs_iso_stat_traverse,
psz_path);
}
/*!
@param p_cdio the CD object to read from
@param pzs_path path the look up
@return file status for pathname. NULL is returned on error.
The caller must free the returned result using iso9660_stat_free().
*/
iso9660_stat_t *
iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[])
{
iso9660_stat_t *p_root;
char **splitpath;
iso9660_stat_t *stat;
if (!p_iso) return NULL;
if (!psz_path) return NULL;
p_root = _ifs_stat_root (p_iso);
if (!p_root) return NULL;
splitpath = _cdio_strsplit (psz_path, '/');
stat = _fs_iso_stat_traverse (p_iso, p_root, splitpath);
free(p_root);
_cdio_strfreev (splitpath);
return stat;
}
/*!
Read psz_path (a directory) and return a list of iso9660_stat_t
pointers for the files inside that directory.
@param p_cdio the CD object to read from
@param pzs_path path the read the directory from.
@return file status for psz_path. The caller must free the
The caller must free the returned result using iso9660_stat_free().
*/
CdioISO9660FileList_t *
iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[])
{
generic_img_private_t *p_env;
iso9660_stat_t *p_stat;
if (!p_cdio) return NULL;
if (!psz_path) return NULL;
p_env = (generic_img_private_t *) p_cdio->env;
p_stat = iso9660_fs_stat (p_cdio, psz_path);
if (!p_stat) return NULL;
if (p_stat->type != _STAT_DIR) {
iso9660_stat_free(p_stat);
return NULL;
}
{
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
CdioISO9660DirList_t *retval = _cdio_list_new ();
_dirbuf = calloc(1, p_stat->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
cdio_warn("Couldn't calloc(1, %d)", p_stat->secsize * ISO_BLOCKSIZE);
iso9660_stat_free(p_stat);
iso9660_dirlist_free(retval);
return NULL;
}
if (cdio_read_data_sectors (p_cdio, _dirbuf, p_stat->lsn,
ISO_BLOCKSIZE, p_stat->secsize)) {
iso9660_stat_free(p_stat);
iso9660_dirlist_free(retval);
return NULL;
}
while (offset < (p_stat->secsize * ISO_BLOCKSIZE))
{
iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset];
iso9660_stat_t *p_iso9660_stat;
if (iso9660_check_dir_block_end(p_iso9660_dir, &offset))
continue;
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir, dunno,
p_env->u_joliet_level);
_cdio_list_append (retval, p_iso9660_stat);
offset += iso9660_get_dir_len(p_iso9660_dir);
}
cdio_assert (offset == (p_stat->secsize * ISO_BLOCKSIZE));
free(_dirbuf);
iso9660_stat_free(p_stat);
return retval;
}
}
/*!
Read psz_path (a directory) and return a list of iso9660_stat_t
of the files inside that. The caller must free the returned result.
*/
CdioISO9660FileList_t *
iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[])
{
iso9660_stat_t *p_stat;
if (!p_iso) return NULL;
if (!psz_path) return NULL;
p_stat = iso9660_ifs_stat (p_iso, psz_path);
if (!p_stat) return NULL;
if (p_stat->type != _STAT_DIR) {
iso9660_stat_free(p_stat);
return NULL;
}
{
long int ret;
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
CdioList_t *retval = _cdio_list_new ();
const size_t dirbuf_len = p_stat->secsize * ISO_BLOCKSIZE;
if (!dirbuf_len)
{
cdio_warn("Invalid directory buffer sector size %u", p_stat->secsize);
iso9660_stat_free(p_stat);
_cdio_list_free (retval, true, NULL);
return NULL;
}
_dirbuf = calloc(1, dirbuf_len);
if (!_dirbuf)
{
cdio_warn("Couldn't calloc(1, %lu)", (unsigned long)dirbuf_len);
iso9660_stat_free(p_stat);
_cdio_list_free (retval, true, NULL);
return NULL;
}
ret = iso9660_iso_seek_read (p_iso, _dirbuf, p_stat->lsn, p_stat->secsize);
if (ret != dirbuf_len) {
_cdio_list_free (retval, true, NULL);
iso9660_stat_free(p_stat);
free (_dirbuf);
return NULL;
}
while (offset < (dirbuf_len))
{
iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset];
iso9660_stat_t *p_iso9660_stat;
if (iso9660_check_dir_block_end(p_iso9660_dir, &offset))
continue;
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir, p_iso->b_xa,
p_iso->u_joliet_level);
if (p_iso9660_stat)
_cdio_list_append (retval, p_iso9660_stat);
else {
cdio_warn("Invalid directory stat at offset %lu", (unsigned long)offset);
break;
}
offset += iso9660_get_dir_len(p_iso9660_dir);
}
free (_dirbuf);
iso9660_stat_free(p_stat);
if (offset != dirbuf_len) {
_cdio_list_free (retval, true, (CdioDataFree_t) iso9660_stat_free);
return NULL;
}
return retval;
}
}
typedef CdioISO9660FileList_t * (iso9660_readdir_t)
(void *p_image, const char * psz_path);
CdioISO9660FileList_t *
iso9660_filelist_new(void) {
return (CdioISO9660FileList_t *) _cdio_list_new ();
}
CdioISO9660DirList_t *
iso9660_dirlist_new(void) {
return (CdioISO9660FileList_t *) _cdio_list_new ();
}
static iso9660_stat_t *
find_lsn_recurse (void *p_image, iso9660_readdir_t iso9660_readdir,
const char psz_path[], lsn_t lsn,
/*out*/ char **ppsz_full_filename)
{
CdioISO9660FileList_t *entlist = iso9660_readdir (p_image, psz_path);
CdioISO9660DirList_t *dirlist = iso9660_filelist_new();
CdioListNode_t *entnode;
cdio_assert (entlist != NULL);
/* iterate over each entry in the directory */
_CDIO_LIST_FOREACH (entnode, entlist)
{
iso9660_stat_t *statbuf = _cdio_list_node_data (entnode);
const char *psz_filename = (char *) statbuf->filename;
unsigned int len = strlen(psz_path) + strlen(psz_filename)+2;
if (*ppsz_full_filename != NULL) free(*ppsz_full_filename);
*ppsz_full_filename = calloc(1, len);
snprintf (*ppsz_full_filename, len, "%s%s/", psz_path, psz_filename);
if (statbuf->type == _STAT_DIR
&& strcmp ((char *) statbuf->filename, ".")
&& strcmp ((char *) statbuf->filename, "..")) {
snprintf (*ppsz_full_filename, len, "%s%s/", psz_path, psz_filename);
_cdio_list_append (dirlist, strdup(*ppsz_full_filename));
}
if (statbuf->lsn == lsn) {
const unsigned int len2 = sizeof(iso9660_stat_t)+strlen(statbuf->filename)+1;
iso9660_stat_t *ret_stat = calloc(1, len2);
if (!ret_stat)
{
iso9660_dirlist_free(dirlist);
cdio_warn("Couldn't calloc(1, %d)", len2);
free(*ppsz_full_filename);
*ppsz_full_filename = NULL;
return NULL;
}
memcpy(ret_stat, statbuf, len2);
iso9660_filelist_free (entlist);
iso9660_dirlist_free(dirlist);
return ret_stat;
}
}
iso9660_filelist_free (entlist);
/* now recurse/descend over directories encountered */
_CDIO_LIST_FOREACH (entnode, dirlist)
{
char *psz_path_prefix = _cdio_list_node_data (entnode);
iso9660_stat_t *ret_stat;
free(*ppsz_full_filename);
*ppsz_full_filename = NULL;
ret_stat = find_lsn_recurse (p_image, iso9660_readdir,
psz_path_prefix, lsn,
ppsz_full_filename);
if (NULL != ret_stat) {
iso9660_dirlist_free(dirlist);
return ret_stat;
}
}
if (*ppsz_full_filename != NULL) {
free(*ppsz_full_filename);
*ppsz_full_filename = NULL;
}
iso9660_dirlist_free(dirlist);
return NULL;
}
/*!
Given a directory pointer, find the filesystem entry that contains
lsn and return information about it.
Returns stat_t of entry if we found lsn, or NULL otherwise.
*/
iso9660_stat_t *
iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn)
{
char *psz_full_filename = NULL;
iso9660_stat_t * p_statbuf;
p_statbuf = find_lsn_recurse (p_cdio, (iso9660_readdir_t *) iso9660_fs_readdir,
"/", i_lsn, &psz_full_filename);
if (psz_full_filename != NULL)
free(psz_full_filename);
return p_statbuf;
}
/*!
Given a directory pointer, find the filesystem entry that contains
LSN and return information about it.
@param p_iso the ISO-9660 file image to get data from.
@param i_lsn the LSN to find
@param ppsz_full_filename the place to store the name of the path that has LSN.
On entry this should point to NULL. If not, the value will be freed.
On exit a value is malloc'd and the caller is responsible for
freeing the result.
@return stat_t of entry if we found lsn, or NULL otherwise.
Caller must free return value using iso9660_stat_free().
*/
iso9660_stat_t *
iso9660_fs_find_lsn_with_path(CdIo_t *p_cdio, lsn_t i_lsn,
/*out*/ char **ppsz_full_filename)
{
return find_lsn_recurse (p_cdio, (iso9660_readdir_t *) iso9660_fs_readdir,
"/", i_lsn, ppsz_full_filename);
}
/*!
Given a directory pointer, find the filesystem entry that contains
lsn and return information about it.
@param p_iso the ISO-9660 file image to get data from.
@param i_lsn the LSN to find
@return stat_t of entry if we found lsn, or NULL otherwise.
Caller must free return value using iso9660_stat_free().
*/
iso9660_stat_t *
iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn)
{
char *psz_full_filename = NULL;
iso9660_stat_t *ret =
find_lsn_recurse (p_iso, (iso9660_readdir_t *) iso9660_ifs_readdir,
"/", i_lsn, &psz_full_filename);
if (psz_full_filename != NULL)
free(psz_full_filename);
return ret;
}
/*!
Given a directory pointer, find the filesystem entry that contains
lsn and return information about it.
@param p_iso pointer to iso_t
@param i_lsn LSN to find
@param ppsz_path full path of lsn filename. On entry *ppsz_path should be
NULL. On return it will be allocated an point to the full path of the
file at lsn or NULL if the lsn is not found. You should deallocate
*ppsz_path when you are done using it.
@return stat_t of entry if we found lsn, or NULL otherwise.
Caller must free return value using iso9660_stat_free().
*/
iso9660_stat_t *
iso9660_ifs_find_lsn_with_path(iso9660_t *p_iso, lsn_t i_lsn,
/*out*/ char **ppsz_full_filename)
{
return find_lsn_recurse (p_iso, (iso9660_readdir_t *) iso9660_ifs_readdir,
"/", i_lsn, ppsz_full_filename);
}
/*!
Free the passed iso9660_stat_t structure.
@param p_stat iso9660 stat buffer to free.
*/
void
iso9660_stat_free(iso9660_stat_t *p_stat)
{
if (p_stat != NULL) {
if (p_stat->rr.psz_symlink) {
CDIO_FREE_IF_NOT_NULL(p_stat->rr.psz_symlink);
}
free(p_stat);
}
}
/*!
Free the passed CdioISOC9660FileList_t structure.
*/
void
iso9660_filelist_free(CdioISO9660FileList_t *p_filelist) {
_cdio_list_free(p_filelist, true, (CdioDataFree_t) iso9660_stat_free);
}
/*!
Free the passed CdioISOC9660DirList_t structure.
*/
void
iso9660_dirlist_free(CdioISO9660DirList_t *p_filelist) {
_cdio_list_free(p_filelist, true, free);
}
/*!
Return true if ISO 9660 image has extended attrributes (XA).
*/
bool
iso9660_ifs_is_xa (const iso9660_t * p_iso)
{
if (!p_iso) return false;
return yep == p_iso->b_xa;
}
static bool_3way_t
iso_have_rr_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
char **splitpath, uint64_t *pu_file_limit)
{
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
int ret;
bool_3way_t have_rr = nope;
if (!splitpath[0]) return false;
if (_root->type == _STAT_FILE) return nope;
if (*pu_file_limit == 0) return dunno;
cdio_assert (_root->type == _STAT_DIR);
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
cdio_warn("Couldn't calloc(1, %d)", _root->secsize * ISO_BLOCKSIZE);
return dunno;
}
ret = iso9660_iso_seek_read (p_iso, _dirbuf, _root->lsn, _root->secsize);
if (ret!=ISO_BLOCKSIZE*_root->secsize) {
free(_dirbuf);
return false;
}
while (offset < (_root->secsize * ISO_BLOCKSIZE))
{
iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset];
iso9660_stat_t *p_stat;
unsigned int i_last_component = 1;
if (iso9660_check_dir_block_end(p_iso9660_dir, &offset))
continue;
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_xa,
p_iso->u_joliet_level);
have_rr = p_stat->rr.b3_rock;
if ( have_rr != yep) {
if (strlen(splitpath[0]) == 0)
have_rr = false;
else
have_rr = iso_have_rr_traverse (p_iso, p_stat, &splitpath[i_last_component],
pu_file_limit);
}
free(p_stat);
if (have_rr != nope) {
free (_dirbuf);
return have_rr;
}
offset += iso9660_get_dir_len(p_iso9660_dir);
*pu_file_limit = (*pu_file_limit)-1;
if ((*pu_file_limit) == 0) {
free (_dirbuf);
return dunno;
}
}
cdio_assert (offset == (_root->secsize * ISO_BLOCKSIZE));
/* not found */
free (_dirbuf);
return nope;
}
/*!
Return "yup" if any file has Rock-Ridge extensions. Warning: this can
be time consuming. On an ISO 9600 image with lots of files but no Rock-Ridge
extensions, the entire directory structure will be scanned up to u_file_limit.
@param p_iso the ISO-9660 file image to get data from
@param u_file_limit the maximimum number of (non-rock-ridge) files
to consider before giving up and returning "dunno".
"dunno" can also be returned if there was some error encountered
such as not being able to allocate memory in processing.
*/
extern bool_3way_t
iso9660_have_rr(iso9660_t *p_iso, uint64_t u_file_limit)
{
iso9660_stat_t *p_root;
char *p_psz_splitpath[2] = {strdup("/"), strdup("")};
bool_3way_t is_rr = nope;
if (!p_iso) return false;
p_root = _ifs_stat_root (p_iso);
if (!p_root) return dunno;
if (u_file_limit == 0) u_file_limit = UINT64_MAX;
is_rr = iso_have_rr_traverse (p_iso, p_root, p_psz_splitpath, &u_file_limit);
free(p_root);
free(p_psz_splitpath[0]);
free(p_psz_splitpath[1]);
return is_rr;
}
| 27.712963 | 90 | 0.676952 |
85d2cbcdd1a890667bf867b96f9c173b0a44d7ab | 5,829 | c | C | CoX/CoX_Peripheral/CoX_Peripheral_NUC122/pwm/test/suite1/src/xpwmtest3.c | coocox/cox | c94e4a65417301b76a02108be5a9eeea3663ef70 | [
"BSD-3-Clause"
] | 58 | 2015-01-23T11:12:14.000Z | 2022-03-23T01:52:14.000Z | CoX/CoX_Peripheral/CoX_Peripheral_NUC122/pwm/test/suite1/src/xpwmtest3.c | eventus17/cox | c94e4a65417301b76a02108be5a9eeea3663ef70 | [
"BSD-3-Clause"
] | 1 | 2017-12-30T05:40:50.000Z | 2017-12-30T05:40:50.000Z | CoX/CoX_Peripheral/CoX_Peripheral_NUC122/pwm/test/suite1/src/xpwmtest3.c | eventus17/cox | c94e4a65417301b76a02108be5a9eeea3663ef70 | [
"BSD-3-Clause"
] | 68 | 2015-01-22T11:03:59.000Z | 2022-01-29T14:18:40.000Z | //*****************************************************************************
//
//! @page xpwm_testcase xpwm CaptureMode test
//!
//! File: @ref xpwmtest3.c
//!
//! <h2>Description</h2>
//! This module implements the test sequence for the xpwm sub component.<br><br>
//! - \p Board: NUC122 <br><br>
//! - \p Last-Time(about): 0.5s <br><br>
//! - \p Phenomenon: Success or failure information will be printed on the UART. <br><br>
//! .
//!
//! <h2>Preconditions</h2>
//! The module requires the following options:<br><br>
//! - \p Option-define:
//! <br>(1)None.<br><br>
//! - \p Option-hardware:
//! <br>(1)Connect an USB cable to the development board.<br><br>
//! - \p Option-OtherModule:
//! <br>Connect an COM cable to the development board.<br>
//! .
//! In case some of the required options are not enabled then some or all tests
//! may be skipped or result FAILED.<br>
//!
//! <h2>Test Cases</h2>
//! The module contain those sub tests:<br><br>
//! - \subpage test_xpwm_CaptureMode
//! .
//! \file xpwmtest3.c
//! \brief xpwm test source file
//! \brief xpwm test header file <br>
//
//*****************************************************************************
#include "test.h"
#include "xpwm.h"
#include "xhw_pwm.h"
//*****************************************************************************
//
//!\page test_xpwm_CaptureMode test_xpwm_CaptureMode
//!
//!<h2>Description</h2>
//!Test xpwm CaptureMode. <br>
//!
//
//*****************************************************************************
//*****************************************************************************
//! \breif PWM interrupt handler.
//!
//! \return None
//
//*****************************************************************************
static unsigned long user_Callback( void *pvCBData, unsigned long ulEvent, \
unsigned long ulMsgParam, void *pvMsgData )
{
TestEmitToken('a');
return 0;
}
//
// pwm base value
//
static unsigned long PWNBase[] = {xPWMA_BASE};
//
// pwm channel value
//
static unsigned long PWMChannel[2][4] = {
{xPWM_CHANNEL0, xPWM_CHANNEL1,
xPWM_CHANNEL2,xPWM_CHANNEL3},
};
//
// pwm Inttertupt ID
//
static unsigned long IntID[] = {xINT_PWMA};
//*****************************************************************************
//
//! \brief xpwm003 test execute main body.
//!
//! \return None.
//
//*****************************************************************************
static void xpwm003Execute(void)
{
unsigned long ulBase;
int i, j;
for(i = 0; i < 1; i++)
{
for(j = 0; j < 4; j++)
{
ulBase = PWNBase[i];
//
// Set invert, dead zone and mode
//
xPWMInitConfigure(ulBase, PWMChannel[i][j], xPWM_TOGGLE_MODE |
xPWM_OUTPUT_INVERTER_DIS | xPWM_DEAD_ZONE_DIS);
// Set CNR, Prescale and Divider
xPWMFrequencyConfig(ulBase, PWMChannel[i][j], 0x3FF0100);
//
// Set output disable
//
xPWMOutputDisable(ulBase, PWMChannel[i][j]);
//
// Enable capture in
//
PWMCAPInputEnable(ulBase, PWMChannel[i][j]);
//
// Set interrupt call back
//
xPWMIntCallbackInit(ulBase, user_Callback);
//
// PWM output interrupt enable
//
xPWMIntEnable(ulBase, PWMChannel[i][j], PWM_INT_CAP_BOTH);
//
// NVIC interrupt enable
//
xIntEnable(IntID[i]);
//
// start pwm
//
PWMCAPEnable(ulBase, PWMChannel[i][j]);
TestAssertQBreak("a", " pwm intterupt test error!", 0xffffffff);
}
}
}
//*****************************************************************************
//
//! \brief Get the Test description of xpwm003 CaptureMode test.
//!
//! \return the desccription of the xpwm003 test.
//
//*****************************************************************************
static char* xpwm003GetTest(void)
{
return "xpwm, 003, xpwm CaptureMode test";
}
//*****************************************************************************
//
//! \brief something should do before the test execute of xpwm003 test.
//!
//! \return None.
//
//*****************************************************************************
static void xpwm003Setup(void)
{
SysCtlKeyAddrUnlock();
xSysCtlClockSet(12000000, xSYSCTL_XTAL_12MHZ | xSYSCTL_OSC_MAIN);
xSysCtlPeripheralEnable(xSYSCTL_PERIPH_PWMA);
//
// GPIO pin function set as pwm output
//
xSPinTypePWM(PWM0, PA12);
xSPinTypePWM(PWM1, PA13);
xSPinTypePWM(PWM2, PA14);
xSPinTypePWM(PWM3, PA15);
}
//*****************************************************************************
//
//! \brief something should do after the test execute of xpwm003 test.
//!
//! \return None.
//
//*****************************************************************************
static void xpwm003TearDown(void)
{
xSysCtlPeripheralDisable(xSYSCTL_PERIPH_PWMA);
}
//
// xpwm003 CaptureMode test case struct.
//
const tTestCase sTestxpwm003CaptureMode = {
xpwm003GetTest,
xpwm003Setup,
xpwm003TearDown,
xpwm003Execute
};
//
// Xpwm test suits.
//
const tTestCase * const psPatternxpwm3[] =
{
&sTestxpwm003CaptureMode,
0
};
| 27.757143 | 120 | 0.441757 |
c490515962b6a9488f8daf991302d1933f0794f0 | 3,929 | c | C | src/lib/thread/thread.c | State-of-War-PostBar/Blue-Alert | 637f4738e09433de9dbc7adae4cdd047ea306730 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | src/lib/thread/thread.c | State-of-War-PostBar/Blue-Alert | 637f4738e09433de9dbc7adae4cdd047ea306730 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | src/lib/thread/thread.c | State-of-War-PostBar/Blue-Alert | 637f4738e09433de9dbc7adae4cdd047ea306730 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | /*************************************************************************************************
* *
* [ Blue Alert ] *
* *
**************************************************************************************************
* *
* A free, open-source indie RTS game. *
* (ɔ) 2017 - 2022 State of War Baidu Postbar, some rights reserved. *
* *
* Blue Alert is a free software. You can freely do whatever you want with it *
* under the JUST DON'T BOTHER ME PUBLIC LICENSE (hereinafter referred to as the license) *
* published by mhtvsSFrpHdE <https://github.com/mhtvsSFrpHdE>. *
* *
* Blue Alert is created, intended to be useful, but without any warranty. *
* For more information, please forward to the license. *
* *
* You should have received a copy of the license along with the *
* source code of this program. If not, please see *
* <https://github.com/State-of-War-PostBar/Blue-Alert/blob/master/LICENSE>. *
* *
* For more information about the project and us, please visit our Github repository at *
* <https://github.com/State-of-War-PostBar/Blue-Alert>. *
* *
**************************************************************************************************
* *
* Mission is successfully completed. *
* *
**************************************************************************************************/
#include "thread.h"
int
blrt_Thread_Create( blrt_Thread *thr, blrt_ThreadFunc func, void *arg )
{
#ifdef BLRT_TARGET_WINDOWS
blrt_Thread thrd = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) func, arg, 0, NULL);
if (!thrd)
{
*thr = NULL;
return -1;
}
*thr = thrd;
return 0;
#else
return pthread_create(thr, NULL, func, arg);
#endif
}
blrt_Thread
blrt_Thread_Current( void )
{
#ifdef BLRT_TARGET_WINDOWS
return GetCurrentThread();
#else
return pthread_self();
#endif
}
void
blrt_Thread_Sleep( const struct timespec *duration )
{
#ifdef BLRT_TARGET_WINDOWS
Sleep(duration->tv_sec * 1000.0 + duration->tv_nsec / 0.000001);
#else
nanosleep(duration, NULL);
#endif
}
void
blrt_Thread_Exit( void )
{
#ifdef BLRT_TARGET_WINDOWS
ExitThread(0);
#else
pthread_exit(NULL);
#endif
}
void
blrt_Thread_Detach( blrt_Thread thr )
{
#ifdef BLRT_TARGET_WINDOWS
CloseHandle(thr);
#else
pthread_detach(thr);
#endif
}
void
blrt_Thread_Join( blrt_Thread thr )
{
#ifdef BLRT_TARGET_WINDOWS
WaitForSingleObject(thr, INFINITE);
CloseHandle(thr);
#else
pthread_join(thr, NULL);
#endif
}
| 39.686869 | 99 | 0.371087 |
e30919f1c7630199ca0b232f3e1eecff72b6b570 | 3,646 | c | C | asn1c_defs/X2N_ServedNRCellsToModify-Item.c | o-ran-sc/ric-app-admin | 0a168f272a81ac4c3afe42e014f8032f2a159d97 | [
"Apache-2.0"
] | null | null | null | asn1c_defs/X2N_ServedNRCellsToModify-Item.c | o-ran-sc/ric-app-admin | 0a168f272a81ac4c3afe42e014f8032f2a159d97 | [
"Apache-2.0"
] | null | null | null | asn1c_defs/X2N_ServedNRCellsToModify-Item.c | o-ran-sc/ric-app-admin | 0a168f272a81ac4c3afe42e014f8032f2a159d97 | [
"Apache-2.0"
] | null | null | null | /*
* Generated by asn1c-0.9.29 n1 (http://lionet.info/asn1c)
* From ASN.1 module "X2AP-PDU-Contents"
* found in "../../asn_defs/asn1/x2ap-15-04.asn"
* `asn1c -fcompound-names -fno-include-deps -findirect-choice -gen-PER -no-gen-OER`
*/
#include "X2N_ServedNRCellsToModify-Item.h"
#include "X2N_NRNeighbour-Information.h"
#include "X2N_ProtocolExtensionContainer.h"
asn_TYPE_member_t asn_MBR_X2N_ServedNRCellsToModify_Item_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct X2N_ServedNRCellsToModify_Item, old_nrcgi),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_X2N_NRCGI,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"old-nrcgi"
},
{ ATF_NOFLAGS, 0, offsetof(struct X2N_ServedNRCellsToModify_Item, servedNRCellInformation),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_X2N_ServedNRCell_Information,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"servedNRCellInformation"
},
{ ATF_POINTER, 3, offsetof(struct X2N_ServedNRCellsToModify_Item, nrNeighbourInformation),
(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_X2N_NRNeighbour_Information,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"nrNeighbourInformation"
},
{ ATF_POINTER, 2, offsetof(struct X2N_ServedNRCellsToModify_Item, nrDeactivationIndication),
(ASN_TAG_CLASS_CONTEXT | (3 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_X2N_DeactivationIndication,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"nrDeactivationIndication"
},
{ ATF_POINTER, 1, offsetof(struct X2N_ServedNRCellsToModify_Item, iE_Extensions),
(ASN_TAG_CLASS_CONTEXT | (4 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_X2N_ProtocolExtensionContainer_8231P100,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"iE-Extensions"
},
};
static const int asn_MAP_X2N_ServedNRCellsToModify_Item_oms_1[] = { 2, 3, 4 };
static const ber_tlv_tag_t asn_DEF_X2N_ServedNRCellsToModify_Item_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_X2N_ServedNRCellsToModify_Item_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* old-nrcgi */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* servedNRCellInformation */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* nrNeighbourInformation */
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* nrDeactivationIndication */
{ (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 } /* iE-Extensions */
};
asn_SEQUENCE_specifics_t asn_SPC_X2N_ServedNRCellsToModify_Item_specs_1 = {
sizeof(struct X2N_ServedNRCellsToModify_Item),
offsetof(struct X2N_ServedNRCellsToModify_Item, _asn_ctx),
asn_MAP_X2N_ServedNRCellsToModify_Item_tag2el_1,
5, /* Count of tags in the map */
asn_MAP_X2N_ServedNRCellsToModify_Item_oms_1, /* Optional members */
3, 0, /* Root/Additions */
5, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_X2N_ServedNRCellsToModify_Item = {
"ServedNRCellsToModify-Item",
"ServedNRCellsToModify-Item",
&asn_OP_SEQUENCE,
asn_DEF_X2N_ServedNRCellsToModify_Item_tags_1,
sizeof(asn_DEF_X2N_ServedNRCellsToModify_Item_tags_1)
/sizeof(asn_DEF_X2N_ServedNRCellsToModify_Item_tags_1[0]), /* 1 */
asn_DEF_X2N_ServedNRCellsToModify_Item_tags_1, /* Same as above */
sizeof(asn_DEF_X2N_ServedNRCellsToModify_Item_tags_1)
/sizeof(asn_DEF_X2N_ServedNRCellsToModify_Item_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_X2N_ServedNRCellsToModify_Item_1,
5, /* Elements count */
&asn_SPC_X2N_ServedNRCellsToModify_Item_specs_1 /* Additional specs */
};
| 38.378947 | 93 | 0.727647 |
8b784dc556e0e15a2f1d6b3de7a4a13306e3d1d8 | 3,429 | h | C | include/x/eklt/types.h | jpl-x/x_events | e9d0b6e578f045eb7b57acadf75b77d8a323f51d | [
"Apache-2.0"
] | null | null | null | include/x/eklt/types.h | jpl-x/x_events | e9d0b6e578f045eb7b57acadf75b77d8a323f51d | [
"Apache-2.0"
] | null | null | null | include/x/eklt/types.h | jpl-x/x_events | e9d0b6e578f045eb7b57acadf75b77d8a323f51d | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <deque>
#include <opencv2/core.hpp>
#include <ceres/ceres.h>
#include <ceres/cubic_interpolation.h>
#include <x/common/event_types.h>
#include <x/vision/tiled_image.h>
#include <x/common/csv_writer.h>
#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#else
error "Missing the <filesystem> header."
#endif
#include <easy/profiler.h>
namespace x {
enum class EkltTrackUpdateType : char {
Init,
Bootstrap,
Update,
Lost
};
std::ostream& operator << (std::ostream& os, const x::EkltTrackUpdateType& obj);
}
namespace x {
using EventsCsv = CsvWriter<profiler::timestamp_t, profiler::timestamp_t>;
using OptimizationsCsv = CsvWriter<profiler::timestamp_t, profiler::timestamp_t, int, double>;
using EventTracksInterpolation = CsvWriter<int, double, double, double>;
using EventTracksCSV = CsvWriter<int, double, double, double>;
using EKLTTracksCSV = CsvWriter<profiler::timestamp_t, int, EkltTrackUpdateType, double, double, double, double>;
struct EventsPerformanceLogger {
explicit EventsPerformanceLogger(const fs::path & path)
: events_csv(path / "events.csv", {"ts_start", "ts_stop"})
, event_tracks_csv(path / "event_tracks.csv", {"id", "t", "center_x", "center_y"})
, event_tracks_interpolation_csv(path / "event_tracks_interpolation.csv", {"id", "interpolated_t", "interpolated_x_dist", "interpolated_y_dist"}) {}
EventsCsv events_csv;
EventTracksCSV event_tracks_csv;
EventTracksInterpolation event_tracks_interpolation_csv;
};
typedef std::shared_ptr<EventsPerformanceLogger> EventsPerformanceLoggerPtr;
struct EkltPerformanceLogger {
explicit EkltPerformanceLogger(const fs::path & path)
: optimizations_csv(path / "optimizations.csv", {"ts_start", "ts_stop", "num_iterations", "final_cost"})
, eklt_tracks_csv(path / "eklt_tracks.csv", {"ts", "id", "update_type", "patch_t_current", "center_x", "center_y", "flow_angle"}) {}
OptimizationsCsv optimizations_csv;
EKLTTracksCSV eklt_tracks_csv;
};
typedef std::shared_ptr<EkltPerformanceLogger> EkltPerformanceLoggerPtr;
struct EkltPatch; //forward decl
using EkltPatches = std::vector<EkltPatch>; //forward decl
struct HastePatch; //forward decl
using HastePatches = std::vector<HastePatch>; //forward decl
using ImageBuffer = std::map<double, TiledImage>;
struct FeatureTrackData {
EkltPatches patches;
double t, t_init;
cv::Mat image;
};
using Grid = ceres::Grid2D<double, 2>;
using GridPtr = std::unique_ptr<Grid>;
using Interpolator = ceres::BiCubicInterpolator<Grid>;
using InterpolatorPtr = std::unique_ptr<ceres::BiCubicInterpolator<Grid>>;
struct OptimizerDatum {
OptimizerDatum() {}
OptimizerDatum(const std::vector<double> &grad, const cv::Mat &img, int num_patches) {
grad_ = grad;
grad_grid_ = new Grid(grad_.data(), 0, img.rows, 0, img.cols);
grad_interp_ = new Interpolator(*grad_grid_);
ref_counter_ = num_patches;
}
void clear() {
delete grad_interp_;
delete grad_grid_;
}
std::vector<double> grad_;
Grid *grad_grid_;
Interpolator *grad_interp_;
int ref_counter_;
};
using OptimizerData = std::map<double, OptimizerDatum>;
}
| 30.616071 | 154 | 0.719452 |
e95b56a2193eac6158d48b70231c928a4bd5bfd6 | 449 | h | C | Engine/Classes/UserInterface/ImGuiLayer.h | minimpoun/MARS | b989e173bc401ce382a4f1a5bbcc36389e3d5969 | [
"Apache-2.0"
] | null | null | null | Engine/Classes/UserInterface/ImGuiLayer.h | minimpoun/MARS | b989e173bc401ce382a4f1a5bbcc36389e3d5969 | [
"Apache-2.0"
] | null | null | null | Engine/Classes/UserInterface/ImGuiLayer.h | minimpoun/MARS | b989e173bc401ce382a4f1a5bbcc36389e3d5969 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "Core/Layers/Layer.h"
namespace MARS
{
class EXPORT_TYPE ImGuiLayer : private Layer
{
public:
virtual void OnAttach() override;
virtual void OnDetach() override;
virtual void RenderLayerUI() override;
virtual void OnBegin() override;
virtual void OnEnd() override;
friend class Application;
protected:
float m_Time = 0.f;
static bool bShowDebugMenu;
private:
ImGuiLayer();
~ImGuiLayer();
};
} | 14.966667 | 45 | 0.714922 |
f5dba868e412e3e2c9802559ccdfe75be5638473 | 2,133 | h | C | Engine/Logic/gkNodeManager.h | gamekit-developers/gamekit | 74c896af5826ebe8fb72f2911015738f38ab7bb2 | [
"Zlib",
"MIT"
] | 241 | 2015-01-04T00:36:58.000Z | 2022-01-06T19:19:23.000Z | Engine/Logic/gkNodeManager.h | slagusev/gamekit | a6e97fcf2a9c3b9b9799bc12c3643818503ffc7d | [
"MIT"
] | 10 | 2015-07-10T18:27:17.000Z | 2019-06-26T20:59:59.000Z | Engine/Logic/gkNodeManager.h | slagusev/gamekit | a6e97fcf2a9c3b9b9799bc12c3643818503ffc7d | [
"MIT"
] | 82 | 2015-01-25T18:02:35.000Z | 2022-03-05T12:28:17.000Z | /*
-------------------------------------------------------------------------------
This file is part of OgreKit.
http://gamekit.googlecode.com/
Copyright (c) 2006-2013 Charlie C.
Contributor(s): none yet.
-------------------------------------------------------------------------------
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-------------------------------------------------------------------------------
*/
#ifndef _gkNodeManager_h_
#define _gkNodeManager_h_
#include "gkLogicCommon.h"
#include "gkResourceManager.h"
#include "gkMathUtils.h"
#include "utSingleton.h"
class gkGameObject;
class gkNodeManager : public gkResourceManager, public utSingleton<gkNodeManager>
{
public:
public:
gkNodeManager();
~gkNodeManager();
gkResource* createImpl(const gkResourceName& name, const gkResourceHandle& handle);
gkLogicTree* createLogicTree(const gkString& groupName=""); //create normal tree
void update(gkScalar tick);
protected:
virtual void notifyDestroyAllImpl(void);
virtual void notifyDestroyGroupImpl (const gkResourceNameString &group);
virtual void notifyResourceCreatedImpl(gkResource* res);
virtual void notifyResourceDestroyedImpl(gkResource* res);
typedef utList<gkLogicTree*> TreeList;
TreeList m_locals;
UT_DECLARE_SINGLETON(gkNodeManager);
};
#endif//_gkNodeManager_h_
| 32.318182 | 84 | 0.687295 |
3a6f67457ebde2311a97aa7d3a33546f6eb2bf4b | 2,804 | h | C | toolboxes/python/python_numpy_wrappers.h | roopchansinghv/gadgetron | fb6c56b643911152c27834a754a7b6ee2dd912da | [
"MIT"
] | 1 | 2022-02-22T21:06:36.000Z | 2022-02-22T21:06:36.000Z | toolboxes/python/python_numpy_wrappers.h | apd47/gadgetron | 073e84dabe77d2dae3b3dd9aa4bf9edbf1f890f2 | [
"MIT"
] | null | null | null | toolboxes/python/python_numpy_wrappers.h | apd47/gadgetron | 073e84dabe77d2dae3b3dd9aa4bf9edbf1f890f2 | [
"MIT"
] | null | null | null | #ifndef GADGETRON_PYTHON_NUMPY_WRAPPERS_H
#define GADGETRON_PYTHON_NUMPY_WRAPPERS_H
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <ismrmrd/waveform.h>
#include "numpy/ndarraytypes.h"
namespace Gadgetron {
/// Wrappers for NumPy C-API functions. These functions must be used
/// in the same C++ source file as the call to `import_array()`. In this
/// case, that is Python.cpp. The simplest solution is to lightly wrap the API.
EXPORTPYTHON int NumPyArray_NDIM(PyObject* obj);
EXPORTPYTHON npy_intp NumPyArray_DIM(PyObject* obj, int i);
EXPORTPYTHON void *NumPyArray_DATA(PyObject* obj);
EXPORTPYTHON npy_intp *NumPyArray_STRIDES(PyObject* obj);
EXPORTPYTHON int NumPyArray_ITEMSIZE(PyObject* obj);
EXPORTPYTHON npy_intp NumPyArray_SIZE(PyObject* obj);
EXPORTPYTHON PyObject *NumPyArray_SimpleNew(int nd, npy_intp* dims, int typenum);
EXPORTPYTHON PyObject *NumPyArray_EMPTY(int nd, npy_intp* dims, int typenum, int fortran);
EXPORTPYTHON PyObject* NumPyArray_FromAny(PyObject* op, PyArray_Descr* dtype, int min_depth, int max_depth, int requirements, PyObject* context);
/// return the enumerated numpy type for a given C++ type
template <typename T> int get_numpy_type() { return NPY_VOID; }
template <> inline int get_numpy_type< bool >() { return NPY_BOOL; }
template <> inline int get_numpy_type< char >() { return NPY_INT8; }
template <> inline int get_numpy_type< unsigned char >() { return NPY_UINT8; }
template <> inline int get_numpy_type< short >() { return NPY_INT16; }
template <> inline int get_numpy_type< unsigned short >() { return NPY_UINT16; }
template <> inline int get_numpy_type< int >() { return NPY_INT32; }
template <> inline int get_numpy_type< unsigned int >() { return NPY_UINT32; }
template <> inline int get_numpy_type< long >() { return NPY_INT64; }
template <> inline int get_numpy_type< unsigned long >() { return NPY_UINT64; }
template <> inline int get_numpy_type< float >() { return NPY_FLOAT32; }
template <> inline int get_numpy_type< double >() { return NPY_FLOAT64; }
template <> inline int get_numpy_type< std::complex<float> >() { return NPY_COMPLEX64; }
template <> inline int get_numpy_type< std::complex<double> >() { return NPY_COMPLEX128; }
template <> inline int get_numpy_type< ISMRMRD::AcquisitionHeader>() { return NPY_OBJECT;}
template <> inline int get_numpy_type< ISMRMRD::ImageHeader>() { return NPY_OBJECT; }
template <> inline int get_numpy_type< ISMRMRD::ISMRMRD_WaveformHeader>() { return NPY_OBJECT; }
template <> inline int get_numpy_type< ISMRMRD::Waveform>() { return NPY_OBJECT; }
/* Don't define these for now */
/* template <> inline int get_numpy_type< char* >() { return NPY_STRING; } */
/* template <> inline int get_numpy_type< std::string >() { return NPY_STRING; } */
}
#endif // GADGETRON_PYTHON_NUMPY_WRAPPERS_H
| 57.22449 | 145 | 0.761412 |
5c5242b35527f11a172bd686408d6bcea00ca5c1 | 991 | h | C | Applications/HeadBoard/HBSiriRemoteAnalyticsEventLogger.h | lechium/tvOS144Headers | e22dcf52662ae03002e3a6d57273f54e74013cb0 | [
"MIT"
] | 2 | 2021-04-15T10:50:21.000Z | 2021-08-19T19:00:09.000Z | Applications/HeadBoard/HBSiriRemoteAnalyticsEventLogger.h | lechium/tvOS144Headers | e22dcf52662ae03002e3a6d57273f54e74013cb0 | [
"MIT"
] | null | null | null | Applications/HeadBoard/HBSiriRemoteAnalyticsEventLogger.h | lechium/tvOS144Headers | e22dcf52662ae03002e3a6d57273f54e74013cb0 | [
"MIT"
] | null | null | null | //
// Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <objc/NSObject.h>
@class NSMutableArray;
@interface HBSiriRemoteAnalyticsEventLogger : NSObject
{
long long _trackingTouchesCount; // 8 = 0x8
NSMutableArray *_events; // 16 = 0x10
}
+ (id)sharedInstance; // IMP=0x00000001000222d0
- (void).cxx_destruct; // IMP=0x0000000100022cb4
@property(readonly, nonatomic) NSMutableArray *events; // @synthesize events=_events;
@property(readonly, nonatomic) long long trackingTouchesCount; // @synthesize trackingTouchesCount=_trackingTouchesCount;
- (void)_logSelectEventWithVendorInfo:(CDStruct_912cb5d2)arg1; // IMP=0x0000000100022838
- (void)_logEvent:(CDStruct_7f320dbc)arg1; // IMP=0x0000000100022704
- (void)_focusDidUpdate; // IMP=0x0000000100022644
- (void)receiveEvent:(id)arg1; // IMP=0x0000000100022348
- (id)_init; // IMP=0x0000000100022238
@end
| 34.172414 | 121 | 0.759839 |
582bbdd65b9e36ecf229f9c89cf062d4d59a3bea | 205 | h | C | sw/polynomialRootSolver/I_PolynomialRootSolver.h | galpHub/PolynomialRootSolverForOpenCV | 28683fe03d77efc77f277e9a93eeb474ba582298 | [
"MIT"
] | null | null | null | sw/polynomialRootSolver/I_PolynomialRootSolver.h | galpHub/PolynomialRootSolverForOpenCV | 28683fe03d77efc77f277e9a93eeb474ba582298 | [
"MIT"
] | null | null | null | sw/polynomialRootSolver/I_PolynomialRootSolver.h | galpHub/PolynomialRootSolverForOpenCV | 28683fe03d77efc77f277e9a93eeb474ba582298 | [
"MIT"
] | null | null | null | #include <opencv2/core/core.hpp>
class I_PolynomialRootSolver
{
public:
virtual ~I_PolynomialRootSolver(){};
virtual cv::Mat computeRoots(const cv::Mat& rowOfCoefficientsInAscendingDegreeOrder) = 0;
};
| 22.777778 | 90 | 0.785366 |
d9c66e14241c9cf7565554c1e6b8c686bb2d1da1 | 1,304 | h | C | DDMobileProject/DDMobileProject/BaseSource/controller/DDBaseViewController.h | DevQC/DDMobileProject | 81812726ae5b11b8eb5610811f0592a8a248ebb4 | [
"MIT"
] | null | null | null | DDMobileProject/DDMobileProject/BaseSource/controller/DDBaseViewController.h | DevQC/DDMobileProject | 81812726ae5b11b8eb5610811f0592a8a248ebb4 | [
"MIT"
] | null | null | null | DDMobileProject/DDMobileProject/BaseSource/controller/DDBaseViewController.h | DevQC/DDMobileProject | 81812726ae5b11b8eb5610811f0592a8a248ebb4 | [
"MIT"
] | null | null | null | //
// DDBaseViewController.h
// DDMobileProject
//
// Created by QJ_001 on 16/8/3.
// Copyright © 2016年 Deven. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DDTableView.h"
#import "UINavigationController+FDFullscreenPopGesture.h"
@protocol DDBaseViewControllerDataSource<NSObject>
@optional
-(NSInteger)numberOfLeft_buttons;
-(NSMutableAttributedString*)setTitle;
-(UIButton*)set_leftButton;
-(UIButton*)set_rightButton;
-(UIColor*)set_colorBackground;
-(CGFloat)set_navigationHeight;
-(UIView*)set_bottomView;
-(UIImage*)backgroundImage;
-(CGFloat)set_leftBarButtonItemVerticalPosition;
-(CGFloat)set_rightBarButtonItemVerticalPosition;
-(UIImage*)set_leftBarButtonItemWithImage;
-(UIImage*)set_rightBarButtonItemWithImage;
-(BOOL)showNavSeparateLine;
@end
@protocol DDBaseViewControllerDelegate <NSObject>
@optional
-(void)left_button_event;
-(void)right_button_event;
-(void)right_button_event:(UIButton*)sender;
-(void)title_click_event:(UIView*)sender;
@end
@interface DDBaseViewController : UIViewController<DDBaseViewControllerDataSource,DDBaseViewControllerDelegate>
@property(nonatomic, strong, readonly) UIPercentDrivenInteractiveTransition *interactivePopTransition;
@property(nonatomic, strong) UIView *snapshot;
-(void)set_Title:(NSMutableAttributedString *)title;
@end
| 29.636364 | 111 | 0.819785 |
d9dd070709f7ba44529cedb020e02bc5d9a28792 | 1,320 | c | C | tests/test1.c | trailofbits/screen | 311e5e4e1a8ee12844b404c5a4d39e27072cbb6f | [
"Apache-2.0"
] | 19 | 2016-10-24T22:12:24.000Z | 2022-03-16T03:36:21.000Z | tests/test1.c | trailofbits/screen | 311e5e4e1a8ee12844b404c5a4d39e27072cbb6f | [
"Apache-2.0"
] | 8 | 2016-10-05T19:35:21.000Z | 2016-11-10T02:15:57.000Z | tests/test1.c | trailofbits/screen | 311e5e4e1a8ee12844b404c5a4d39e27072cbb6f | [
"Apache-2.0"
] | 4 | 2016-12-22T04:53:00.000Z | 2022-03-16T03:36:24.000Z | // had it working to get a simple flattening list, but clearly not branch specific
//main() -> fun1() -> llvm.var.annotation() -> printf() -> llvm.var.annotation() -> printf() -> foo() -> printf() -> printf()
#include <stdio.h>
#include <stdlib.h>
__attribute__((annotate("screen_function_paths")))
void foo(int a) {
printf("%d", a);
return;
}
int fun1();
int fun2();
int fun3();
int fun4();
int fun1(){
//__attribute__((annotate("screen_paths_start"))) char a = 'a';
//printf("starting character: %c", a);
//__attribute__((annotate("screen_paths_end"))) char b = 'b';
//printf("Ending character: %c", b);
int a = 2;
int b = 3;
char c = a + b;
fun2();
return (int) c;
}
int fun2(){
printf("starting character:");
fun3();
return 0;
}
int fun3() {
fun4();
return 0;
}
int fun4() {
__attribute__((annotate("screen_paths2_end"))) char b = 'b';
(void) b;
return 0;
}
int fun0(){
fun2();
return 0;
}
__attribute__((annotate("screen_function_paths")))
int main(int argc, char **argv)
{
__attribute__((annotate("screen_paths2_start"))) char aa = 'a';
(void) aa;
(void)argc;
(void)argv;
int a = 0x41414141;
int *b = &a;
printf("BranchInst approaching...\n");
if ( argc != 1)
a = fun1();
else
fun0(a);
printf("a = %u *b = %u\n", a, *b);
}
| 18.333333 | 125 | 0.593939 |
8db9079161f73f99c03528a0679b0c93b1819d74 | 10,404 | c | C | examples/ixpsrv.c | mmirko/libixp | 76dc2105fc8767e4732a6d31e146d91b479cbf8c | [
"MIT"
] | 25 | 2016-11-23T07:45:18.000Z | 2020-11-28T02:29:03.000Z | examples/ixpsrv.c | mmirko/libixp | 76dc2105fc8767e4732a6d31e146d91b479cbf8c | [
"MIT"
] | null | null | null | examples/ixpsrv.c | mmirko/libixp | 76dc2105fc8767e4732a6d31e146d91b479cbf8c | [
"MIT"
] | 8 | 2018-01-15T16:07:48.000Z | 2022-01-02T20:49:09.000Z | /* Copyright ©2007 Ron Minnich <rminnich at gmail dot com>
/* Copyright ©2007-2010 Kris Maglione <maglione.k@gmail.com>
* See LICENSE file for license details.
*/
/* This is a simple 9P file server which serves a normal filesystem
* hierarchy. While some of the code is from wmii, the server is by
* Ron.
*
* Note: I added an ifdef for Linux vs. BSD for the mount call, so
* this compiles on BSD, but it won't actually run. It should,
* ideally, have the option of not mounting the FS.
* --Kris
*/
#include <assert.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <ixp_local.h>
/* Temporary */
#define fatal(...) ixp_eprint("ixpsrv: fatal: " __VA_ARGS__)
#define debug(...) if(debuglevel) fprintf(stderr, "ixpsrv: " __VA_ARGS__)
/* Datatypes: */
typedef struct FidAux FidAux;
struct FidAux {
DIR *dir;
int fd;
char name[]; /* c99 */
};
/* Error messages */
static char
Enoperm[] = "permission denied",
Enofile[] = "file not found",
Ebadvalue[] = "bad value";
/* Macros */
#define QID(t, i) ((vlong)(t))
/* Global Vars */
static IxpServer server;
static char *user;
static int debuglevel = 0;
static void fs_open(Ixp9Req *r);
static void fs_walk(Ixp9Req *r);
static void fs_read(Ixp9Req *r);
static void fs_stat(Ixp9Req *r);
static void fs_write(Ixp9Req *r);
static void fs_clunk(Ixp9Req *r);
static void fs_flush(Ixp9Req *r);
static void fs_attach(Ixp9Req *r);
static void fs_create(Ixp9Req *r);
static void fs_remove(Ixp9Req *r);
static void fs_freefid(IxpFid *f);
Ixp9Srv p9srv = {
.open= fs_open,
.walk= fs_walk,
.read= fs_read,
.stat= fs_stat,
.write= fs_write,
.clunk= fs_clunk,
.flush= fs_flush,
.attach=fs_attach,
.create=fs_create,
.remove=fs_remove,
.freefid=fs_freefid
};
static void
usage() {
fprintf(stderr,
"usage: %1$s [-a <address>] {create | read | ls [-ld] | remove | write} <file>\n"
" %1$s [-a <address>] xwrite <file> <data>\n"
" %1$s -v\n", argv0);
exit(1);
}
/* Utility Functions */
static FidAux*
newfidaux(char *name) {
FidAux *f;
f = ixp_emallocz(sizeof(*f) + strlen(name) + 1);
f->fd = -1;
strcpy(f->name, name);
return f;
}
/* is this a dir? */
/* -1 means it ain't anything .. */
static int
isdir(char *path) {
struct stat buf;
if (stat(path, &buf) < 0)
return -1;
return S_ISDIR(buf.st_mode);
}
/* This should be moved to libixp */
static void
write_buf(Ixp9Req *r, char *buf, uint len) {
if(r->ifcall.tread.offset >= len)
return;
len -= r->ifcall.tread.offset;
if(len > r->ifcall.tread.count)
len = r->ifcall.tread.count;
r->ofcall.rread.data = ixp_emalloc(len);
memcpy(r->ofcall.rread.data, buf + r->ifcall.tread.offset, len);
r->ofcall.rread.count = len;
}
/* This should be moved to libixp */
static void
write_to_buf(Ixp9Req *r, void *buf, uint *len, uint max) {
uint offset, count;
// offset = (r->fid->omode&OAPPEND) ? *len : r->ifcall.tread.offset;
offset = r->ifcall.tread.offset;
if(offset > *len || r->ifcall.tread.count == 0) {
r->ofcall.rread.count = 0;
return;
}
count = r->ifcall.tread.count;
if(max && (count > max - offset))
count = max - offset;
*len = offset + count;
if(max == 0) {
*(void **)buf = ixp_erealloc(*(void **)buf, *len + 1);
buf = *(void **)buf;
}
memcpy((uchar*)buf + offset, r->ifcall.tread.data, count);
r->ofcall.rread.count = count;
((char *)buf)[offset+count] = '\0';
}
static void
dostat(Stat *s, char *name, struct stat *buf) {
s->type = 0;
s->dev = 0;
s->qid.type = buf->st_mode&S_IFMT;
s->qid.path = buf->st_ino;
s->qid.version = 0;
s->mode = buf->st_mode & 0777;
if (S_ISDIR(buf->st_mode)) {
s->mode |= P9_DMDIR;
s->qid.type |= QTDIR;
}
s->atime = buf->st_atime;
s->mtime = buf->st_mtime;
s->length = buf->st_size;
s->name =name;
s->uid = user;
s->gid = user;
s->muid = user;
}
/* the gnu/linux guys have made a real mess of errno ... don't ask --ron */
/* I agree. --Kris */
void
rerrno(Ixp9Req *r, char *m) {
/*
char errbuf[128];
respond(r, strerror_r(errno, errbuf, sizeof(errbuf)));
*/
respond(r, m);
}
void
fs_attach(Ixp9Req *r) {
debug("fs_attach(%p)\n", r);
r->fid->qid.type = QTDIR;
r->fid->qid.path = (uintptr_t)r->fid;
r->fid->aux = newfidaux("/");
r->ofcall.rattach.qid = r->fid->qid;
respond(r, nil);
}
void
fs_walk(Ixp9Req *r) {
struct stat buf;
char *name;
FidAux *f;
int i;
debug("fs_walk(%p)\n", r);
f = r->fid->aux;
name = malloc(PATH_MAX);
strcpy(name, f->name);
if (stat(name, &buf) < 0){
respond(r, Enofile);
return;
}
/* build full path. Stat full path. Done */
for(i=0; i < r->ifcall.twalk.nwname; i++) {
strcat(name, "/");
strcat(name, r->ifcall.twalk.wname[i]);
if (stat(name, &buf) < 0){
respond(r, Enofile);
free(name);
return;
}
r->ofcall.rwalk.wqid[i].type = buf.st_mode&S_IFMT;
r->ofcall.rwalk.wqid[i].path = buf.st_ino;
}
r->newfid->aux = newfidaux(name);
r->ofcall.rwalk.nwqid = i;
free(name);
respond(r, nil);
}
void
fs_stat(Ixp9Req *r) {
struct stat st;
Stat s;
IxpMsg m;
char *name;
uchar *buf;
FidAux *f;
int size;
f = r->fid->aux;
debug("fs_stat(%p)\n", r);
debug("fs_stat %s\n", f->name);
name = f->name;
if (stat(name, &st) < 0){
respond(r, Enofile);
return;
}
dostat(&s, name, &st);
r->fid->qid = s.qid;
r->ofcall.rstat.nstat = size = ixp_sizeof_stat(&s);
buf = ixp_emallocz(size);
m = ixp_message(buf, size, MsgPack);
ixp_pstat(&m, &s);
r->ofcall.rstat.stat = m.data;
respond(r, nil);
}
void
fs_read(Ixp9Req *r) {
FidAux *f;
char *buf;
int n, offset;
int size;
debug("fs_read(%p)\n", r);
f = r->fid->aux;
if (f->dir) {
Stat s;
IxpMsg m;
offset = 0;
size = r->ifcall.tread.count;
buf = ixp_emallocz(size);
m = ixp_message((uchar*)buf, size, MsgPack);
/* note: we don't really handle lots of things well, so do one thing
* at a time
*/
/*for(f=f->next; f; f=f->next) */{
struct dirent *d;
struct stat st;
d = readdir(f->dir);
if (d) {
stat(d->d_name, &st);
dostat(&s, d->d_name, &st);
n = ixp_sizeof_stat(&s);
ixp_pstat(&m, &s);
offset += n;
} else n = 0;
}
r->ofcall.rread.count = n;
r->ofcall.rread.data = (char*)m.data;
respond(r, nil);
return;
} else {
r->ofcall.rread.data = ixp_emallocz(r->ifcall.tread.count);
if (! r->ofcall.rread.data) {
respond(r, nil);
return;
}
r->ofcall.rread.count = pread(f->fd, r->ofcall.rread.data, r->ifcall.tread.count, r->ifcall.tread.offset);
if (r->ofcall.rread.count < 0)
rerrno(r, Enoperm);
else
respond(r, nil);
return;
}
/*
* This is an assert because this should this should not be called if
* the file is not open for reading.
*/
assert(!"Read called on an unreadable file");
}
void
fs_write(Ixp9Req *r) {
FidAux *f;
debug("fs_write(%p)\n", r);
if(r->ifcall.twrite.count == 0) {
respond(r, nil);
return;
}
f = r->fid->aux;
/*
* This is an assert because this function should not be called if
* the file is not open for writing.
*/
assert(!"Write called on an unwritable file");
}
void
fs_open(Ixp9Req *r) {
int dir;
FidAux *f;
debug("fs_open(%p)\n", r);
f = r->fid->aux;
dir = isdir(f->name);
/* fucking stupid linux -- open dir is a DIR */
if (dir) {
f->dir = opendir(f->name);
if (! f->dir){
rerrno(r, Enoperm);
return;
}
} else {
f->fd = open(f->name, O_RDONLY);
if (f->fd < 0){
rerrno(r, Enoperm);
return;
}
}
respond(r, nil);
}
void
fs_create(Ixp9Req *r) {
debug("fs_create(%p)\n", r);
respond(r, Enoperm);
}
void
fs_remove(Ixp9Req *r) {
debug("fs_remove(%p)\n", r);
respond(r, Enoperm);
}
void
fs_clunk(Ixp9Req *r) {
int dir;
FidAux *f;
debug("fs_clunk(%p)\n", f);
f = r->fid->aux;
dir = isdir(f->name);
if (dir) {
(void) closedir(f->dir);
f->dir = NULL;
} else {
(void) close(f->fd);
f->fd = -1;
}
respond(r, nil);
}
void
fs_flush(Ixp9Req *r) {
debug("fs_flush(%p)\n", r);
respond(r, nil);
}
void
fs_freefid(Fid *f) {
debug("fs_freefid(%p)\n", f);
free(f->aux);
}
// mount -t 9p 127.1 /tmp/cache -o port=20006,noextend
/* Yuck. */
#if defined(__linux__)
# define MF(n) MS_##n
# define mymount(src, dest, flags, opts) mount(src, dest, "9p", flags, opts)
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
# define MF(n) MNT_##n
# define mymount(src, dest, flags, opts) mount("9p", dest, flags, src)
#endif
static ulong mountflags =
MF(NOATIME)
| MF(NODEV)
/* | MF(NODIRATIME) */
| MF(NOEXEC)
| MF(NOSUID)
| MF(RDONLY);
int
getaddr(char *mountaddr, char **ip, char **port) {
char *cp;
if (!mountaddr)
mountaddr = getenv("XCPU_PARENT");
if (!mountaddr)
return -1;
cp = mountaddr;
if (strcmp(cp, "tcp!"))
cp += 4;
*ip = cp;
cp = strstr(cp, "!");
if (cp)
*port = cp + 1;
return strtoul(*port, 0, 0);
}
int
main(int argc, char *argv[]) {
int fd;
int ret;
int domount, mountonly;
char *mountaddr;
char *address;
char *msg;
IxpConn *acceptor;
domount = 0;
mountonly = 0;
address = getenv("IXP_ADDRESS");
mountaddr = nil;
ARGBEGIN{
case 'v':
printf("%s-" VERSION ", ©2007 Ron Minnich\n", argv0);
exit(0);
case 'a':
address = EARGF(usage());
break;
case 'd':
debuglevel++;
break;
case 'm':
domount++;
break;
case 'M':
mountonly++;
break;
default:
usage();
}ARGEND;
if(!address)
fatal("$IXP_ADDRESS not set\n");
if(!(user = getenv("USER")))
fatal("$USER not set\n");
fd = ixp_announce(address);
if(fd < 0)
fatal("%s\n", errstr);
/* set up a fake client so we can grap connects. */
acceptor = ixp_listen(&server, fd, &p9srv, serve_9pcon, NULL);
/* we might need to mount ourselves. The bit of complexity is the need to fork so
* we can serve ourselves. We've done the listen so that's ok.
*/
if (domount){
int f = fork();
if (f < 0)
errx(1, "fork!");
if (!f){
char *addr, *aport;
int port;
char options[128];
port = getaddr(mountaddr, &addr, &aport);
sprintf(options, "port=%d,noextend", port);
if (mymount(addr, "/tmp/cache", mountflags, options) < 0)
errx(1, "Mount failed");
}
}
if (mountonly)
exit(0);
ixp_serverloop(&server);
printf("msg %s\n", ixp_errbuf());
return ret;
}
| 19.195572 | 108 | 0.616782 |
381df5b3398a64b9410b41ff7a0ca5e24d123968 | 393 | h | C | CodeLib/MyLib/DownloadImage/NetFileManager.h | SevenandTen/CodeLib | 52ec917c0f3bcb0acdd5d5609e87e2d88971ec9c | [
"MIT"
] | null | null | null | CodeLib/MyLib/DownloadImage/NetFileManager.h | SevenandTen/CodeLib | 52ec917c0f3bcb0acdd5d5609e87e2d88971ec9c | [
"MIT"
] | null | null | null | CodeLib/MyLib/DownloadImage/NetFileManager.h | SevenandTen/CodeLib | 52ec917c0f3bcb0acdd5d5609e87e2d88971ec9c | [
"MIT"
] | 1 | 2019-11-25T11:44:28.000Z | 2019-11-25T11:44:28.000Z | //
// NetFileManager.h
// BaseCode
//
// Created by zw on 2018/8/27.
// Copyright © 2018年 zw. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface NetFileManager : NSObject
+ (instancetype)shareInstance;
- (void)startLoadFileWithUrl:(NSString *)url withView:(UIView *)view;
- (void)removeImageView:(UIView *)view forUrl:(NSString *)url;
@end
| 17.863636 | 69 | 0.707379 |
c093a76a07b1a9063e198bac56c23864557c0570 | 1,024 | h | C | src/include/catalog/mgr_updateparm.h | cumthqb/AntDB | ac2aa27563a378cd6af86181aa36fbbf216b50bc | [
"PostgreSQL",
"Apache-2.0"
] | 1 | 2019-03-01T02:44:33.000Z | 2019-03-01T02:44:33.000Z | src/include/catalog/mgr_updateparm.h | cumthqb/AntDB | ac2aa27563a378cd6af86181aa36fbbf216b50bc | [
"PostgreSQL",
"Apache-2.0"
] | null | null | null | src/include/catalog/mgr_updateparm.h | cumthqb/AntDB | ac2aa27563a378cd6af86181aa36fbbf216b50bc | [
"PostgreSQL",
"Apache-2.0"
] | null | null | null |
#ifndef MGR_UPDATEPARM_H
#define MGR_UPDATEPARM_H
#ifdef BUILD_BKI
#include "catalog/buildbki.h"
#else /* BUILD_BKI */
#include "catalog/genbki.h"
#endif /* BUILD_BKI */
#define UpdateparmRelationId 4801
CATALOG(mgr_updateparm,4801) BKI_WITHOUT_OIDS
{
NameData updateparmnodename; /* updateparm nodename */
char updateparmnodetype;
NameData updateparmkey;
#ifdef CATALOG_VARLEN
text updateparmvalue;
#endif
/* CATALOG_VARLEN */
} FormData_mgr_updateparm;
/* ----------------
* Form_mgr_updateparm corresponds to a pointer to a tuple with
* the format of mgr_updateparm relation.
* ----------------
*/
typedef FormData_mgr_updateparm *Form_mgr_updateparm;
/* ----------------
* compiler constants for mgr_updateparm
* ----------------
*/
#define Natts_mgr_updateparm 4
#define Anum_mgr_updateparm_nodename 1
#define Anum_mgr_updateparm_nodetype 2
#define Anum_mgr_updateparm_key 3
#define Anum_mgr_updateparm_value 4
#define MACRO_STAND_FOR_ALL_NODENAME "*"
#endif /* MGR_UPDATEPARM_H */
| 22.755556 | 64 | 0.731445 |
0e139bc8717cab2892ca2aefe4935f90bb5eb28b | 288 | h | C | ios/versioned-react-native/ABI36_0_0/Expo/EXGoogleSignIn/ABI36_0_0EXGoogleSignIn/ABI36_0_0EXGoogleSignIn.h | rudylee/expo | b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc | [
"Apache-2.0",
"MIT"
] | 3 | 2020-09-06T17:32:53.000Z | 2021-05-20T19:04:48.000Z | ios/versioned-react-native/ABI36_0_0/Expo/EXGoogleSignIn/ABI36_0_0EXGoogleSignIn/ABI36_0_0EXGoogleSignIn.h | rudylee/expo | b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc | [
"Apache-2.0",
"MIT"
] | 16 | 2021-03-01T21:18:59.000Z | 2022-02-27T08:18:52.000Z | ios/versioned-react-native/ABI36_0_0/Expo/EXGoogleSignIn/ABI36_0_0EXGoogleSignIn/ABI36_0_0EXGoogleSignIn.h | rudylee/expo | b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc | [
"Apache-2.0",
"MIT"
] | 2 | 2020-04-25T16:31:11.000Z | 2020-04-25T16:31:13.000Z | // Copyright 2018-present 650 Industries. All rights reserved.
#import <ABI36_0_0UMCore/ABI36_0_0UMModuleRegistryConsumer.h>
#import <GoogleSignIn/GoogleSignIn.h>
@interface ABI36_0_0EXGoogleSignIn : ABI36_0_0UMExportedModule <ABI36_0_0UMModuleRegistryConsumer, GIDSignInDelegate>
@end
| 36 | 117 | 0.854167 |
354e2d1a43c16fe0fbbb06c5d9c68dc22b8439c6 | 1,007 | c | C | src/strings/ft_isalnum.c | kubekhrm/libft | 348b181d98eb533a5784ffb9406e6bd2fe1bede3 | [
"Unlicense"
] | 8 | 2015-07-24T15:17:51.000Z | 2020-10-29T08:18:26.000Z | src/strings/ft_isalnum.c | kubekhrm/libft | 348b181d98eb533a5784ffb9406e6bd2fe1bede3 | [
"Unlicense"
] | null | null | null | src/strings/ft_isalnum.c | kubekhrm/libft | 348b181d98eb533a5784ffb9406e6bd2fe1bede3 | [
"Unlicense"
] | 2 | 2016-02-02T18:23:17.000Z | 2017-02-13T08:32:36.000Z | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cfeijoo <cfeijoo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/11/23 00:04:52 by cfeijoo #+# #+# */
/* Updated: 2014/02/22 23:18:01 by cfeijoo ### ########.fr */
/* */
/* ************************************************************************** */
#include <ft_strings.h>
int ft_isalnum(int c)
{
if (ft_isalpha(c) || ft_isdigit(c))
return (1);
return (0);
}
| 47.952381 | 80 | 0.171797 |
77469df3a95507da0a6b88e1b0eec4e3cc0390b2 | 4,413 | h | C | src/formal_parameter_list.h | sarang2dan/git-coan2 | 0ae84adac82cb7b739ec1bad1fb9dab6ce38e3c3 | [
"BSD-3-Clause"
] | 1 | 2020-04-14T09:39:13.000Z | 2020-04-14T09:39:13.000Z | src/formal_parameter_list.h | sarang2dan/git-coan2 | 0ae84adac82cb7b739ec1bad1fb9dab6ce38e3c3 | [
"BSD-3-Clause"
] | null | null | null | src/formal_parameter_list.h | sarang2dan/git-coan2 | 0ae84adac82cb7b739ec1bad1fb9dab6ce38e3c3 | [
"BSD-3-Clause"
] | null | null | null | #ifndef FORMAL_PARAMETER_LIST_H
#define FORMAL_PARAMETER_LIST_H
#pragma once
/***************************************************************************
* Copyright (C) 2007-2014 Mike Kinghan, imk@burroingroingjoing.com *
* 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 Mike Kinghan nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**************************************************************************/
#include "parameter_list_base.h"
/** \file formal_parameter_list.h
* This file defines `struct formal_parameter_list`.
*/
/** \brief `struct formal_parameter_list` encapsulates a list of
* formal macro parameters.
*/
struct formal_parameter_list : innards::parameter_list_base {
/// Base class
using base = innards::parameter_list_base;
/// Explicitly construct from a `parameter_list_base`
explicit formal_parameter_list(parameter_list_base const & parms)
: base(parms){}
/** \brief Construct for `n` arguments
*
* \param n The number of arguments.
*
* If `n` > 0, the list of placeholder arguments `$1,...,$n` is
*constructed.
*/
explicit formal_parameter_list(size_t n = 0)
: base(n){}
/** \brief Explicitly construct given a `chewer<CharSeq>`
* \param chew On entry, a `chewer<CharSeq>` positioned at the offset
* in the associated `CharSeq` from which to scan. On return`chew` is
* positioned to the first offset not consumed.
*
* \tparam A character-sequence type
*/
template<class CharSeq>
explicit formal_parameter_list(chewer<CharSeq> & chew) {
read(chew);
}
/** \brief Read the `formal_parameter_list` from a `chewer<CharSeq>`
*
* \tparam CharSeq A character-sequence type
* \param chew On entry, a `chewer<CharSeq>` positioned at the offset
* in the associated `CharSeq` from which to scan. On return`chew` is
* positioned to the first offset not consumed.
*
* The `formal_parameter_list` is emptied and replaced by parsing the text
* from `chew`
*/
template<class CharSeq>
void read(chewer<CharSeq> & chew);
private:
using parameter_list_base::none;
using parameter_list_base::empty_param;
using parameter_list_base::unclosed;
};
#endif //EOF
| 44.575758 | 79 | 0.576932 |
a6b426aa74d4c2d1c9690799a2a03f0ef1d4e1df | 1,681 | h | C | NPCStatusWidget_classes.h | NotDiscordOfficial/Fortnite_SDK | 58f8da148256f99cb35518003306fffee33c4a21 | [
"MIT"
] | null | null | null | NPCStatusWidget_classes.h | NotDiscordOfficial/Fortnite_SDK | 58f8da148256f99cb35518003306fffee33c4a21 | [
"MIT"
] | null | null | null | NPCStatusWidget_classes.h | NotDiscordOfficial/Fortnite_SDK | 58f8da148256f99cb35518003306fffee33c4a21 | [
"MIT"
] | 1 | 2021-07-22T00:31:44.000Z | 2021-07-22T00:31:44.000Z | // WidgetBlueprintGeneratedClass NPCStatusWidget.NPCStatusWidget_C
// Size: 0x29c (Inherited: 0x260)
struct UNPCStatusWidget_C : UUserWidget {
struct FPointerToUberGraphFrame UberGraphFrame; // 0x260(0x08)
struct UNPCStatusWidgetBar_C* Bar_Health; // 0x268(0x08)
struct UNPCStatusWidgetBar_C* Bar_Shield; // 0x270(0x08)
struct FTimerHandle VisibiltyTimer; // 0x278(0x08)
struct FMulticastInlineDelegate VisibilityChanged; // 0x280(0x10)
float StatusWidgetVisibleDuration; // 0x290(0x04)
float CurrentHealthPercent; // 0x294(0x04)
float CurrentShieldPercent; // 0x298(0x04)
void Construct(); // Function NPCStatusWidget.NPCStatusWidget_C.Construct // (BlueprintCosmetic|Event|Public|BlueprintEvent) // @ game+0xda7c34
void EventUpdateStatus(float Health, float Shield, bool ShowShield); // Function NPCStatusWidget.NPCStatusWidget_C.EventUpdateStatus // (BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void EventHideStatus(); // Function NPCStatusWidget.NPCStatusWidget_C.EventHideStatus // (BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void ChangeWidgetVisibleDuration(float StatusWidgetVisibleDuration); // Function NPCStatusWidget.NPCStatusWidget_C.ChangeWidgetVisibleDuration // (BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void ExecuteUbergraph_NPCStatusWidget(int32_t EntryPoint); // Function NPCStatusWidget.NPCStatusWidget_C.ExecuteUbergraph_NPCStatusWidget // (Final|UbergraphFunction|HasDefaults) // @ game+0xda7c34
void VisibilityChanged__DelegateSignature(bool bVisible); // Function NPCStatusWidget.NPCStatusWidget_C.VisibilityChanged__DelegateSignature // (Public|Delegate|BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
};
| 80.047619 | 214 | 0.825699 |
60d739b85eb7e78b49c96b9f2e62fa8283111f8d | 1,673 | c | C | release/src-ra-4300/linux/linux-2.6.36.x/drivers/staging/rtl8192su/r8192U_pm.c | zhoutao0712/rtn11pb1 | 09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05 | [
"Apache-2.0"
] | 55 | 2015-01-20T00:09:45.000Z | 2021-08-19T05:40:27.000Z | release/src-ra-4300/linux/linux-2.6.36.x/drivers/staging/rtl8192su/r8192U_pm.c | zhoutao0712/rtn11pb1 | 09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05 | [
"Apache-2.0"
] | 1 | 2021-08-07T07:14:45.000Z | 2021-08-07T08:24:23.000Z | release/src-ra-4300/linux/linux-2.6.36.x/drivers/staging/rtl8192su/r8192U_pm.c | zhoutao0712/rtn11pb1 | 09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05 | [
"Apache-2.0"
] | 36 | 2015-02-13T00:58:22.000Z | 2021-08-19T08:08:07.000Z | /*
Power management interface routines.
Written by Mariusz Matuszek.
This code is currently just a placeholder for later work and
does not do anything useful.
This is part of rtl8180 OpenSource driver.
Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
Released under the terms of GPL (General Public Licence)
*/
#include "r8192U.h"
#include "r8192U_pm.h"
/*****************************************************************************/
int rtl8192U_save_state (struct pci_dev *dev, u32 state)
{
printk(KERN_NOTICE "r8192U save state call (state %u).\n", state);
return(-EAGAIN);
}
int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state)
{
struct net_device *dev = usb_get_intfdata(intf);
RT_TRACE(COMP_POWER, "============> r8192U suspend call.\n");
if(dev) {
if (!netif_running(dev)) {
printk(KERN_WARNING "netif not running, go out suspend function\n");
return 0;
}
if (dev->netdev_ops->ndo_stop)
dev->netdev_ops->ndo_stop(dev);
mdelay(10);
netif_device_detach(dev);
}
return 0;
}
int rtl8192U_resume (struct usb_interface *intf)
{
struct net_device *dev = usb_get_intfdata(intf);
RT_TRACE(COMP_POWER, "================>r8192U resume call.");
if(dev) {
if (!netif_running(dev)){
printk(KERN_WARNING "netif not running, go out resume function\n");
return 0;
}
netif_device_attach(dev);
if (dev->netdev_ops->ndo_open)
dev->netdev_ops->ndo_open(dev);
}
return 0;
}
int rtl8192U_enable_wake (struct pci_dev *dev, u32 state, int enable)
{
printk(KERN_NOTICE "r8192U enable wake call (state %u, enable %d).\n",
state, enable);
return(-EAGAIN);
}
| 22.917808 | 79 | 0.655708 |
e6b32ac2d2d029b7aab47c3a6f1c3f4c735ec1b9 | 1,847 | h | C | pytorch_blade/src/ltc/disc_compiler/disc_compiler.h | JamesTheZ/BladeDISC | e6c76ee557ebfccd560d44f6b6276bbc4e0a8a34 | [
"Apache-2.0"
] | 328 | 2021-12-20T03:29:35.000Z | 2022-03-31T14:27:23.000Z | pytorch_blade/src/ltc/disc_compiler/disc_compiler.h | JamesTheZ/BladeDISC | e6c76ee557ebfccd560d44f6b6276bbc4e0a8a34 | [
"Apache-2.0"
] | 82 | 2021-12-20T09:15:16.000Z | 2022-03-31T09:33:48.000Z | pytorch_blade/src/ltc/disc_compiler/disc_compiler.h | JamesTheZ/BladeDISC | e6c76ee557ebfccd560d44f6b6276bbc4e0a8a34 | [
"Apache-2.0"
] | 66 | 2021-12-21T17:28:27.000Z | 2022-03-29T12:08:34.000Z | // Copyright 2022 The BladeDISC Authors. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <ATen/core/ivalue.h>
#include <sys/stat.h>
#include <unistd.h>
namespace torch {
namespace jit {
class Graph;
class GraphExecutor;
} // namespace jit
namespace lazy {
class BackendData;
class BackendDevice;
} // namespace lazy
} // namespace torch
namespace torch_disc {
namespace compiler {
// Executable represents an executable program
class Executable {
public:
Executable(
const std::shared_ptr<torch::jit::Graph>& graph,
const std::vector<c10::IValue>& disc_inputs);
std::vector<std::shared_ptr<torch::lazy::BackendData>> Run(
c10::ArrayRef<std::shared_ptr<torch::lazy::BackendData>> arguments,
const torch::lazy::BackendDevice& device,
bool default_device_is_cuda);
std::shared_ptr<torch::jit::Graph> graph() {
return graph_;
}
private:
std::shared_ptr<torch::jit::Graph> graph_;
std::shared_ptr<torch::jit::GraphExecutor> graph_executor_;
std::vector<c10::IValue> disc_inputs_;
};
using ExecutablePtr = std::shared_ptr<Executable>;
ExecutablePtr CompileToDiscExecutable(
const std::shared_ptr<torch::jit::Graph>& graph,
c10::ArrayRef<std::shared_ptr<torch::lazy::BackendData>> arguments);
} // namespace compiler
} // namespace torch_disc
| 29.790323 | 75 | 0.737412 |
fcb2f95cb73bb826edbc966ecb7bf8a19cdf0d2b | 3,983 | h | C | src/http.h | ZyperPL/esp8266-websocket-server | a1e9e3621246da0e7ca32e6eef955a440bef8d64 | [
"MIT",
"Unlicense"
] | 1 | 2018-10-15T14:58:00.000Z | 2018-10-15T14:58:00.000Z | src/http.h | ZyperPL/esp8266-websocket-server | a1e9e3621246da0e7ca32e6eef955a440bef8d64 | [
"MIT",
"Unlicense"
] | null | null | null | src/http.h | ZyperPL/esp8266-websocket-server | a1e9e3621246da0e7ca32e6eef955a440bef8d64 | [
"MIT",
"Unlicense"
] | null | null | null | #pragma once
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "uart.h"
#include "mem.h"
#include "user_interface.h"
#include "espconn.h"
#include "sha1.h"
#include "b64.h"
#include "network.h"
// parameters from WebSocket specification RFC 6455
#define WEBSOCKET_MAGIC "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
#define WEBSOCKET_CONT 0x00
#define WEBSOCKET_TEXT 0x01
#define WEBSOCKET_BIN 0x02
#define WEBSOCKET_EXIT 0x08
#define WEBSOCKET_PING 0x9
#define WEBSOCKET_PONG 0xA
// ping magic
#define WEBSOCKET_PING_MAGIC "zPNGz"__DATE__"_"__TIME__"zPNGz"
// maximum number of connections remebered
#define WEBSOCKET_CONNECTIONS_POOL_SIZE 16
// name of custom websocket protocol
#define WEBSOCKET_PROTOCOL_NAME "ZPROTO2"
#define HTTP_FILE_MAX_LENGTH 32
#define HTTP_PAYLOAD_SIZE 256
#define HTTP_PAYLOAD_INTERVAL 1000
#define HTTP_BUFFER_SIZE 8192
/*
* Type of WebSocket callback function that is called on every decoded websocket packet.
*/
typedef void (*ws_receive_callback_t)(struct espconn *con, char *data, uint64_t length);
// WebSocket related functions
/*
* Generates websocket accept key based on client key.
*/
char ICACHE_FLASH_ATTR *websocket_get_accept(char *key);
/*
* Sets connection parameters and registers its callbacks. Adds connection to pool.
*/
void ICACHE_FLASH_ATTR websocket_add_connection(struct espconn *con);
/*
* Get all websocket connections in pool
*/
struct espconn ICACHE_FLASH_ATTR **websocket_get_connections();
/*
* Decodes websocket packet.
*/
char ICACHE_FLASH_ATTR *websocket_decode(char *pdata, unsigned short len);
/*
* Invokes when websocket data is received.
*/
void ICACHE_FLASH_ATTR websocket_receive(void *arg, char *pdata, unsigned short len);
/*
* Sets user-defined websocket receive callback.
*/
void ICACHE_FLASH_ATTR websocket_set_receive_callback(ws_receive_callback_t callback);
/*
* Sends websocket data to specified client.
*/
void ICACHE_FLASH_ATTR websocket_write(struct espconn *con, const void *data, uint64_t len, uint8_t mode);
/*
* Sends websocket data to all clients in the pool
*/
void ICACHE_FLASH_ATTR websocket_write_all(const void *data, uint64_t len, uint8_t mode);
/*
* Closes connection with client
*/
void ICACHE_FLASH_ATTR websocket_close(struct espconn *con);
// Simple HTTP server functions
/*
* Initialize HTTP server listening on port
*/
void ICACHE_FLASH_ATTR http_start(int16_t port);
/*
* Invokes when new connecting to the server is made.
*/
void ICACHE_FLASH_ATTR http_connect(void *arg);
/*
* Invokes when connected client disconnects from the server.
*/
void ICACHE_FLASH_ATTR http_disconnect(void *arg);
/*
* Sends data to the server.
*/
void ICACHE_FLASH_ATTR http_send(struct espconn *con, char *data);
void ICACHE_FLASH_ATTR http_send_file(struct espconn *con, const char *str, const char *type);
void ICACHE_FLASH_ATTR http_send_string(struct espconn *con, const char *str, const char *type);
/*
* Invokes when data is received.
*/
void ICACHE_FLASH_ATTR http_receive(void *arg, char *pdata, unsigned short len);
/*
* Extracts file name from HTTP request string.
*/
char ICACHE_FLASH_ATTR *http_get_file_name(char *pdata, unsigned short len);
/*
* Extracts parameter param from HTTP request.
*/
char ICACHE_FLASH_ATTR *http_get_param(char *req, char *param);
// example files
#define HTML_INDEX_PAGE "<!DOCTYPE HTML><html><head>OK</head><body><div style='width: 400px; height: 800px; overflow:auto;' id='wdata'></div><script src='websocket_test.js'></script></body></html>"
#define WEBSOCKET_TEST_JS "window.onload = function() { "\
"socket = new WebSocket('ws://' + window.location.host + '/socket', '"WEBSOCKET_PROTOCOL_NAME"');"\
"socket.onmessage = function(e) { console.info(e); wd = document.getElementById('wdata'); wd.innerHTML += e.data + '<br>'; wd.scrollTop = wd.scrollHeight; }"\
"}"
| 28.654676 | 197 | 0.743158 |
690903648a05f0ec4892a9929b6b40d7bff6c43c | 2,006 | h | C | include/plat/marvell/octeontx/csr/cavm-csrs-apbr.h | Gateworks/atf-newport | 67f418ebe7ee6630f77c3ef7a10b7bf6c15c5ce3 | [
"BSD-3-Clause"
] | null | null | null | include/plat/marvell/octeontx/csr/cavm-csrs-apbr.h | Gateworks/atf-newport | 67f418ebe7ee6630f77c3ef7a10b7bf6c15c5ce3 | [
"BSD-3-Clause"
] | null | null | null | include/plat/marvell/octeontx/csr/cavm-csrs-apbr.h | Gateworks/atf-newport | 67f418ebe7ee6630f77c3ef7a10b7bf6c15c5ce3 | [
"BSD-3-Clause"
] | 1 | 2021-06-12T11:06:26.000Z | 2021-06-12T11:06:26.000Z | #ifndef __CAVM_CSRS_APBR_H__
#define __CAVM_CSRS_APBR_H__
/* This file is auto-generated. Do not edit */
/***********************license start***********************************
* Copyright (C) 2019 Marvell International Ltd.
* SPDX-License-Identifier: BSD-3-Clause
* https://spdx.org/licenses
***********************license end**************************************/
/**
* @file
*
* Configuration and status register (CSR) address and type definitions for
* OcteonTX APBR.
*
* This file is auto generated. Do not edit.
*
*/
/**
* Enumeration apbr_bar_e
*
* APBR Base Address Register Enumeration
* Enumerates the base address registers.
*/
#define CAVM_APBR_BAR_E_APBRX_PF_BAR0(a) (0x8fb000000000ll + 0x100000ll * (a))
#define CAVM_APBR_BAR_E_APBRX_PF_BAR0_SIZE 0x100000ull
/**
* Register (NCB) apbr#_const
*
* INTERNAL: APBR Fake Register
*
* This register is only to satisfy the tools, it has no physical manifestation.
*/
union cavm_apbrx_const
{
uint64_t u;
struct cavm_apbrx_const_s
{
#if __BYTE_ORDER == __BIG_ENDIAN /* Word 0 - Big Endian */
uint64_t reserved_0_63 : 64;
#else /* Word 0 - Little Endian */
uint64_t reserved_0_63 : 64;
#endif /* Word 0 - End */
} s;
/* struct cavm_apbrx_const_s cn; */
};
typedef union cavm_apbrx_const cavm_apbrx_const_t;
static inline uint64_t CAVM_APBRX_CONST(unsigned long a) __attribute__ ((pure, always_inline));
static inline uint64_t CAVM_APBRX_CONST(unsigned long a)
{
if (cavm_is_model(OCTEONTX_CN9XXX) && (a<=53))
return 0x8fb000000000ll + 0x100000ll * ((a) & 0x3f);
__cavm_csr_fatal("APBRX_CONST", 1, a, 0, 0, 0, 0, 0);
}
#define typedef_CAVM_APBRX_CONST(a) cavm_apbrx_const_t
#define bustype_CAVM_APBRX_CONST(a) CSR_TYPE_NCB
#define basename_CAVM_APBRX_CONST(a) "APBRX_CONST"
#define device_bar_CAVM_APBRX_CONST(a) 0x0 /* PF_BAR0 */
#define busnum_CAVM_APBRX_CONST(a) (a)
#define arguments_CAVM_APBRX_CONST(a) (a),-1,-1,-1
#endif /* __CAVM_CSRS_APBR_H__ */
| 29.072464 | 95 | 0.67996 |
1122484040e99e696e273c02cf742312b2344e38 | 3,378 | c | C | libairfloat/libairfloat/alac_format.c | f000/airfloattest | fd8ed9eb111a710eb84ca737cbb4458bad37dd40 | [
"Unlicense"
] | 405 | 2015-01-03T15:29:31.000Z | 2022-02-03T21:42:55.000Z | libairfloat/libairfloat/alac_format.c | f000/airfloattest | fd8ed9eb111a710eb84ca737cbb4458bad37dd40 | [
"Unlicense"
] | 31 | 2015-01-09T14:06:15.000Z | 2021-04-29T02:04:05.000Z | libairfloat/libairfloat/alac_format.c | f000/airfloattest | fd8ed9eb111a710eb84ca737cbb4458bad37dd40 | [
"Unlicense"
] | 121 | 2015-01-16T23:40:35.000Z | 2022-02-20T13:58:49.000Z | //
// alac_format.c
// AirFloat
//
// Copyright (c) 2013, Kristian Trenskow 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. 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.
//
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "endian.h"
#include "alac_format.h"
struct alac_magic_cookie_t alac_format_parse(const char* rtp_fmtp) {
size_t fmtp_len = strlen(rtp_fmtp);
char fmtp_s[fmtp_len + 1];
strcpy(fmtp_s, rtp_fmtp);
uint32_t fmtp[11];
uint32_t fmtp_c = 0;
bzero(fmtp, sizeof(uint32_t) * 11);
char* read_pos = fmtp_s;
for (uint32_t i = 0 ; true ; i++) {
if (fmtp_s[i] == ' ') {
fmtp_s[i] = '\0';
fmtp[fmtp_c++] = atoi(read_pos);
read_pos = &fmtp_s[i + 1];
} else if (fmtp_s[i] == '\0') {
fmtp[fmtp_c++] = atoi(read_pos);
break;
}
}
struct alac_magic_cookie_t cookie;
bzero(&cookie, sizeof(struct alac_magic_cookie_t));
cookie.format_atom.atom_size = mtbl(12);
cookie.format_atom.channel_layout_info_id = mtbl('frma');
cookie.format_atom.type = mtbl('alac');
cookie.alac_specific_info.info_size = mtbl(36);
cookie.alac_specific_info.id = mtbl('alac');
cookie.alac_specific_info.version_flag = 0;
cookie.alac_specific_info.config.frame_length = mtbl(fmtp[0]);
cookie.alac_specific_info.config.compatible_version = fmtp[1];
cookie.alac_specific_info.config.bit_depth = fmtp[2];
cookie.alac_specific_info.config.pb = fmtp[3];
cookie.alac_specific_info.config.mb = fmtp[4];
cookie.alac_specific_info.config.kb = fmtp[5];
cookie.alac_specific_info.config.num_channels = fmtp[6];
cookie.alac_specific_info.config.max_run = mtbs((uint16_t)fmtp[7]);
cookie.alac_specific_info.config.max_frame_bytes = mtbl(fmtp[8]);
cookie.alac_specific_info.config.avg_bit_rate = mtbl(fmtp[9]);
cookie.alac_specific_info.config.sample_rate = mtbl(fmtp[10]);
cookie.terminator_atom.channel_layout_info_size = mtbl(8);
cookie.terminator_atom.channel_layout_info_id = 0;
return cookie;
}
| 38.827586 | 71 | 0.703967 |
1126da5c61100d7ead500e1ae5f1fbe02c610c2e | 2,186 | c | C | device/frames/frame.c | CodeOmar/ekeyd | f9b7ecae512e8d8b93a144222b695a1a4b249ff3 | [
"MIT"
] | 3 | 2015-03-06T09:42:31.000Z | 2015-12-30T16:43:12.000Z | device/frames/frame.c | CodeOmar/ekeyd | f9b7ecae512e8d8b93a144222b695a1a4b249ff3 | [
"MIT"
] | null | null | null | device/frames/frame.c | CodeOmar/ekeyd | f9b7ecae512e8d8b93a144222b695a1a4b249ff3 | [
"MIT"
] | null | null | null | /* frames/frame.c
*
* Framing information for eKey protocol
*
* Copyright 2009 Simtec Electronics
*
* For licence terms refer to the COPYING file.
*/
#include "frame.h"
#include "../skeinwrap.h"
#include "pem.h"
static EKeySkein framer_mac_base;
static EKeySkein framer_mac;
extern unsigned char *_serial_no;
extern void *memcpy(void*,const void*,size_t);
void
framer_prepare_mac(const unsigned char *sharedkey)
{
PrepareSkein(&framer_mac_base, _serial_no, sharedkey, EKEY_SKEIN_PERSONALISATION_PMS);
}
void
framer_compute_mac(const char *frame, char *mactarget)
{
unsigned char macbuf[32];
memcpy(&framer_mac, &framer_mac_base, sizeof(framer_mac));
Skein_256_Update(&framer_mac, frame, 52);
Skein_256_Final_Pad(&framer_mac, macbuf);
pem64_encode_bytes(macbuf, 3, mactarget);
pem64_encode_bytes(macbuf + 29, 3, mactarget + 4);
}
void
framer_fill_frame(char *frame, char ft1, char ft2, char *payload)
{
char *fr = frame + 2;
int payload_left = 50;
*fr++ = ft1;
*fr++ = ft2;
while ((payload_left > 0) && (*payload != 0)) {
*fr++ = *payload++;
payload_left--;
}
while (payload_left-- > 0)
*fr++ = ' ';
framer_compute_mac(frame + 2, fr);
}
#ifdef FRAMER_TEST
unsigned char *_serial_no = "\x00\x01\x02\x03\x10\x11\x12\x13\xab\xac\xad\xae";
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
static unsigned char nullkey[32];
int
main(int argc, char **argv)
{
char message[64];
char frame[64];
int counter = 0;
int max = 50;
frame[0] = '*';
frame[1] = ' ';
frame[62] = '\r';
frame[63] = '\n';
memset(&(nullkey[0]), 0, 32);
framer_prepare_mac(&(nullkey[0]));
message[0] = message[1] = ' ';
message[2 + pem64_encode_bytes(_serial_no, 12, &(message[2]))] = '\0';
framer_fill_frame(frame, 'S', '!', message);
write(1, frame, 64);
if (argc > 1) {
if (atoi(argv[1]) > 0)
max = atoi(argv[1]);
}
for (counter = 0; counter < max; ++counter) {
snprintf(message, 64, "Frame number %d from pid %d (parent %d)", counter, getpid(), getppid());
framer_fill_frame(frame, 'I', '>', message);
write(1, frame, 64);
}
return 0;
}
#endif
| 21.223301 | 99 | 0.646844 |
741e646f5b6e82a581c487ea3dea553f3141db91 | 52,965 | c | C | testsuite/EXP_4/test1580.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 34 | 2017-07-04T14:16:12.000Z | 2021-04-22T21:04:43.000Z | testsuite/EXP_4/test1580.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 1 | 2017-07-06T03:43:44.000Z | 2017-07-06T03:43:44.000Z | testsuite/EXP_4/test1580.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 6 | 2017-07-04T16:30:42.000Z | 2019-10-16T05:37:29.000Z |
/*
CF3
Copyright (c) 2015 ishiura-lab.
Released under the MIT license.
https://github.com/ishiura-compiler/CF3/MIT-LICENSE.md
*/
#include<stdio.h>
#include<stdint.h>
#include<stdlib.h>
#include"test1.h"
int32_t x1 = INT32_MAX;
static uint64_t x5 = 3259LLU;
uint32_t x8 = 6U;
int32_t x10 = -636;
int16_t x12 = INT16_MAX;
int64_t t3 = -1LL;
int16_t x17 = -35;
static uint16_t x26 = UINT16_MAX;
volatile int32_t x42 = -70;
int8_t x45 = -1;
static int64_t x48 = INT64_MIN;
volatile int64_t t11 = -546451479993LL;
volatile uint32_t x50 = UINT32_MAX;
volatile int64_t x59 = INT64_MAX;
int8_t x63 = INT8_MIN;
static int32_t t14 = -14;
static volatile int8_t x66 = -31;
int16_t x74 = INT16_MAX;
static volatile int16_t x86 = INT16_MIN;
int32_t x89 = INT32_MIN;
int16_t x101 = INT16_MIN;
uint32_t x104 = UINT32_MAX;
int32_t t22 = -6809;
volatile int32_t t25 = -67427611;
volatile int16_t x117 = INT16_MIN;
uint32_t x120 = 36U;
int16_t x123 = INT16_MIN;
int64_t t29 = INT64_MIN;
int8_t x139 = -3;
volatile int64_t t31 = 135373734972937713LL;
int64_t x155 = -1964879LL;
uint16_t x159 = 778U;
static int64_t x160 = INT64_MIN;
uint64_t t36 = 7443LLU;
int32_t x164 = -1;
volatile int32_t t37 = INT32_MIN;
volatile int16_t x166 = INT16_MIN;
static uint8_t x168 = 35U;
int64_t x180 = INT64_MIN;
int8_t x182 = INT8_MIN;
int32_t x185 = -781875455;
static int32_t x189 = INT32_MIN;
volatile int32_t t44 = -7109;
static int8_t x197 = 3;
int32_t t46 = -1733;
int8_t x203 = INT8_MIN;
static int16_t x209 = -3499;
int8_t x212 = INT8_MAX;
volatile uint64_t t51 = 142894141LLU;
static uint32_t x221 = 1054U;
int64_t x227 = 218647440826098210LL;
static int32_t x229 = INT32_MAX;
int64_t x230 = INT64_MIN;
volatile int32_t x232 = -1;
int8_t x233 = -16;
volatile int16_t x238 = INT16_MIN;
static int8_t x240 = INT8_MIN;
int32_t x241 = INT32_MIN;
static volatile uint32_t x242 = UINT32_MAX;
volatile uint16_t x246 = 3225U;
int32_t t59 = 298393;
uint64_t x254 = UINT64_MAX;
uint16_t x259 = 209U;
uint64_t x262 = UINT64_MAX;
int32_t x263 = INT32_MAX;
uint16_t x265 = 6166U;
volatile int32_t t63 = 197881619;
static uint32_t x270 = UINT32_MAX;
int16_t x274 = -1;
uint16_t x280 = 59U;
static volatile uint16_t x281 = 13450U;
int64_t x284 = 4093100LL;
int64_t t68 = -24LL;
uint32_t t69 = 299U;
static uint8_t x303 = UINT8_MAX;
int64_t x305 = INT64_MAX;
int8_t x307 = INT8_MAX;
int64_t t73 = 1794834518650LL;
static int64_t x312 = INT64_MAX;
static int64_t x314 = -1LL;
int16_t x315 = INT16_MIN;
int16_t x319 = -1;
volatile int16_t x321 = INT16_MAX;
uint8_t x326 = UINT8_MAX;
int64_t x342 = INT64_MIN;
int8_t x354 = INT8_MIN;
int64_t x360 = -1LL;
volatile int32_t t85 = -42;
static volatile uint64_t t89 = 14LLU;
volatile uint32_t t90 = 136778U;
static uint8_t x383 = 9U;
int32_t x385 = -338761441;
int64_t x387 = INT64_MIN;
int16_t x390 = -1;
static volatile uint32_t x392 = 207546541U;
volatile int32_t x397 = -1;
volatile int32_t t95 = -207487;
int64_t x406 = INT64_MIN;
volatile uint16_t x408 = UINT16_MAX;
static uint16_t x413 = 96U;
int32_t t100 = 4474;
int32_t x435 = -1;
int64_t t102 = -81685926LL;
volatile int8_t x440 = INT8_MAX;
int16_t x441 = INT16_MAX;
static volatile int64_t t104 = 29375140LL;
static uint64_t x470 = UINT64_MAX;
volatile uint32_t x482 = UINT32_MAX;
int8_t x484 = 45;
int16_t x491 = INT16_MAX;
static int64_t x492 = 7LL;
volatile int16_t x495 = INT16_MIN;
volatile int8_t x499 = -2;
volatile int32_t t117 = 3918792;
int32_t x522 = 1141072;
uint32_t t122 = 4188360U;
int32_t x528 = INT32_MIN;
static int8_t x532 = 1;
volatile int64_t t126 = 31468634086305LL;
uint32_t x542 = 13U;
int16_t x554 = INT16_MIN;
int8_t x555 = -1;
uint16_t x559 = 0U;
uint32_t x563 = UINT32_MAX;
static int8_t x567 = INT8_MIN;
static int16_t x582 = INT16_MIN;
int64_t t136 = 5LL;
uint64_t x585 = 35476182925579013LLU;
volatile int64_t x594 = -269895166177148310LL;
uint8_t x599 = 4U;
int8_t x604 = INT8_MIN;
volatile int64_t t142 = -5409167552LL;
volatile int8_t x609 = -7;
static uint64_t x612 = UINT64_MAX;
uint64_t x613 = 943597116533LLU;
volatile int64_t x618 = INT64_MIN;
int32_t x619 = INT32_MAX;
uint32_t x631 = UINT32_MAX;
int16_t x633 = INT16_MIN;
int16_t x634 = INT16_MIN;
volatile int16_t x635 = INT16_MIN;
uint32_t x638 = UINT32_MAX;
volatile uint32_t t150 = UINT32_MAX;
static int64_t x644 = INT64_MIN;
uint32_t x648 = UINT32_MAX;
int32_t t154 = 1;
int16_t x659 = -1;
static uint16_t x665 = 72U;
int32_t t157 = -236282;
int64_t x670 = INT64_MAX;
int8_t x673 = INT8_MIN;
uint8_t x674 = 2U;
int32_t t160 = 12684;
static uint8_t x682 = 7U;
uint32_t x685 = 172254U;
int32_t x687 = INT32_MAX;
uint64_t x691 = 362060079LLU;
int16_t x694 = INT16_MIN;
int8_t x698 = 2;
volatile uint16_t x702 = 2604U;
static volatile uint8_t x716 = 13U;
static volatile int32_t t170 = 15216827;
int64_t x725 = INT64_MIN;
volatile int32_t x736 = INT32_MAX;
uint16_t x737 = UINT16_MAX;
int64_t x740 = INT64_MAX;
uint8_t x744 = UINT8_MAX;
volatile uint64_t x749 = UINT64_MAX;
int64_t x750 = -563582741673658446LL;
int16_t x760 = INT16_MIN;
int8_t x762 = INT8_MIN;
int8_t x764 = INT8_MIN;
int16_t x765 = INT16_MIN;
volatile int32_t t180 = 334355;
int16_t x774 = INT16_MIN;
int64_t t182 = INT64_MIN;
int32_t x780 = 762318394;
volatile int32_t t183 = -5;
int64_t x783 = 12887LL;
uint64_t x787 = 858835LLU;
static int64_t x794 = INT64_MAX;
static int64_t t189 = INT64_MIN;
int64_t x805 = INT64_MIN;
int32_t x807 = INT32_MIN;
volatile int8_t x809 = INT8_MIN;
int64_t x816 = INT64_MIN;
static int16_t x818 = INT16_MIN;
volatile uint64_t t193 = 1718930LLU;
int32_t x822 = INT32_MIN;
static int16_t x830 = -6;
static uint16_t x835 = 2306U;
int64_t x836 = INT64_MAX;
static int16_t x839 = -1;
void f0(void) {
uint64_t x2 = 634809289694361138LLU;
uint64_t x3 = UINT64_MAX;
int8_t x4 = INT8_MAX;
static uint64_t t0 = 119LLU;
t0 = (x1&(x2+(x3>x4)));
if (t0 != 72988211LLU) { NG(); } else { ; }
}
void f1(void) {
int64_t x6 = -148855LL;
int64_t x7 = -1LL;
volatile uint64_t t1 = 40477141LLU;
t1 = (x5&(x6+(x7>x8)));
if (t1 != 2185LLU) { NG(); } else { ; }
}
void f2(void) {
int64_t x9 = -166974576913614LL;
static uint32_t x11 = 438382U;
static int64_t t2 = 76526652438144LL;
t2 = (x9&(x10+(x11>x12)));
if (t2 != -166974576914176LL) { NG(); } else { ; }
}
void f3(void) {
int64_t x13 = -1LL;
volatile int32_t x14 = -27243;
int64_t x15 = INT64_MIN;
volatile int32_t x16 = INT32_MIN;
t3 = (x13&(x14+(x15>x16)));
if (t3 != -27243LL) { NG(); } else { ; }
}
void f4(void) {
static int32_t x18 = -1344;
static int64_t x19 = INT64_MAX;
static int8_t x20 = INT8_MAX;
int32_t t4 = -6;
t4 = (x17&(x18+(x19>x20)));
if (t4 != -1343) { NG(); } else { ; }
}
void f5(void) {
uint8_t x21 = 4U;
static uint64_t x22 = 60384322152299548LLU;
uint64_t x23 = 10170274568318LLU;
static int8_t x24 = INT8_MAX;
volatile uint64_t t5 = 74LLU;
t5 = (x21&(x22+(x23>x24)));
if (t5 != 4LLU) { NG(); } else { ; }
}
void f6(void) {
uint32_t x25 = 6080U;
int64_t x27 = -1LL;
int8_t x28 = INT8_MIN;
uint32_t t6 = 208828379U;
t6 = (x25&(x26+(x27>x28)));
if (t6 != 0U) { NG(); } else { ; }
}
void f7(void) {
int32_t x29 = -1;
volatile int16_t x30 = -226;
int16_t x31 = -1;
int32_t x32 = INT32_MAX;
static int32_t t7 = -38;
t7 = (x29&(x30+(x31>x32)));
if (t7 != -226) { NG(); } else { ; }
}
void f8(void) {
volatile int16_t x33 = INT16_MIN;
int16_t x34 = INT16_MIN;
volatile int32_t x35 = INT32_MAX;
int64_t x36 = INT64_MIN;
int32_t t8 = -31;
t8 = (x33&(x34+(x35>x36)));
if (t8 != -32768) { NG(); } else { ; }
}
void f9(void) {
volatile uint32_t x37 = 1293699957U;
static uint8_t x38 = 6U;
int64_t x39 = INT64_MIN;
int16_t x40 = -673;
uint32_t t9 = 832800U;
t9 = (x37&(x38+(x39>x40)));
if (t9 != 4U) { NG(); } else { ; }
}
void f10(void) {
static int16_t x41 = INT16_MAX;
uint32_t x43 = UINT32_MAX;
uint64_t x44 = UINT64_MAX;
int32_t t10 = -253;
t10 = (x41&(x42+(x43>x44)));
if (t10 != 32698) { NG(); } else { ; }
}
void f11(void) {
static int64_t x46 = 661907955197LL;
uint8_t x47 = UINT8_MAX;
t11 = (x45&(x46+(x47>x48)));
if (t11 != 661907955198LL) { NG(); } else { ; }
}
void f12(void) {
int8_t x49 = INT8_MAX;
uint16_t x51 = 123U;
volatile int8_t x52 = INT8_MIN;
uint32_t t12 = 2716314U;
t12 = (x49&(x50+(x51>x52)));
if (t12 != 0U) { NG(); } else { ; }
}
void f13(void) {
int64_t x57 = INT64_MAX;
int32_t x58 = INT32_MAX;
int64_t x60 = INT64_MAX;
static volatile int64_t t13 = 101581981523139LL;
t13 = (x57&(x58+(x59>x60)));
if (t13 != 2147483647LL) { NG(); } else { ; }
}
void f14(void) {
static volatile int8_t x61 = -1;
static int8_t x62 = -16;
int16_t x64 = INT16_MAX;
t14 = (x61&(x62+(x63>x64)));
if (t14 != -16) { NG(); } else { ; }
}
void f15(void) {
int16_t x65 = INT16_MIN;
static int16_t x67 = INT16_MIN;
int8_t x68 = -1;
volatile int32_t t15 = -302288988;
t15 = (x65&(x66+(x67>x68)));
if (t15 != -32768) { NG(); } else { ; }
}
void f16(void) {
volatile int8_t x73 = INT8_MAX;
uint16_t x75 = 58U;
int16_t x76 = INT16_MIN;
volatile int32_t t16 = 95;
t16 = (x73&(x74+(x75>x76)));
if (t16 != 0) { NG(); } else { ; }
}
void f17(void) {
volatile int8_t x77 = -3;
volatile int8_t x78 = INT8_MAX;
volatile uint64_t x79 = 6075967872176LLU;
uint8_t x80 = 0U;
static int32_t t17 = -6748146;
t17 = (x77&(x78+(x79>x80)));
if (t17 != 128) { NG(); } else { ; }
}
void f18(void) {
int32_t x85 = -1;
int32_t x87 = -111358;
uint8_t x88 = 2U;
int32_t t18 = 3;
t18 = (x85&(x86+(x87>x88)));
if (t18 != -32768) { NG(); } else { ; }
}
void f19(void) {
int32_t x90 = INT32_MIN;
int32_t x91 = INT32_MIN;
volatile uint8_t x92 = UINT8_MAX;
int32_t t19 = INT32_MIN;
t19 = (x89&(x90+(x91>x92)));
if (t19 != INT32_MIN) { NG(); } else { ; }
}
void f20(void) {
static int64_t x93 = INT64_MIN;
uint16_t x94 = 4199U;
uint64_t x95 = 1LLU;
int64_t x96 = INT64_MIN;
volatile int64_t t20 = 482106LL;
t20 = (x93&(x94+(x95>x96)));
if (t20 != 0LL) { NG(); } else { ; }
}
void f21(void) {
int8_t x97 = -29;
uint32_t x98 = 54777U;
int32_t x99 = INT32_MAX;
int32_t x100 = INT32_MIN;
uint32_t t21 = 57332217U;
t21 = (x97&(x98+(x99>x100)));
if (t21 != 54754U) { NG(); } else { ; }
}
void f22(void) {
int16_t x102 = 12;
int32_t x103 = -1;
t22 = (x101&(x102+(x103>x104)));
if (t22 != 0) { NG(); } else { ; }
}
void f23(void) {
static int64_t x105 = 2781087LL;
int8_t x106 = 1;
int32_t x107 = 766;
volatile uint8_t x108 = 11U;
int64_t t23 = 2215173073LL;
t23 = (x105&(x106+(x107>x108)));
if (t23 != 2LL) { NG(); } else { ; }
}
void f24(void) {
uint64_t x109 = 2307128652163411979LLU;
static int8_t x110 = INT8_MIN;
volatile int8_t x111 = INT8_MIN;
uint16_t x112 = 4U;
uint64_t t24 = 10154LLU;
t24 = (x109&(x110+(x111>x112)));
if (t24 != 2307128652163411968LLU) { NG(); } else { ; }
}
void f25(void) {
int8_t x113 = 3;
uint8_t x114 = 0U;
int64_t x115 = -1LL;
static int64_t x116 = 113810LL;
t25 = (x113&(x114+(x115>x116)));
if (t25 != 0) { NG(); } else { ; }
}
void f26(void) {
int64_t x118 = -1LL;
int64_t x119 = INT64_MAX;
volatile int64_t t26 = 1851506041717035LL;
t26 = (x117&(x118+(x119>x120)));
if (t26 != 0LL) { NG(); } else { ; }
}
void f27(void) {
int8_t x121 = 1;
static int64_t x122 = -161571LL;
volatile uint16_t x124 = 0U;
static volatile int64_t t27 = -255192LL;
t27 = (x121&(x122+(x123>x124)));
if (t27 != 1LL) { NG(); } else { ; }
}
void f28(void) {
static int32_t x125 = INT32_MAX;
int16_t x126 = INT16_MIN;
int8_t x127 = INT8_MAX;
static int32_t x128 = INT32_MAX;
volatile int32_t t28 = 1999392;
t28 = (x125&(x126+(x127>x128)));
if (t28 != 2147450880) { NG(); } else { ; }
}
void f29(void) {
int64_t x129 = INT64_MIN;
int16_t x130 = INT16_MIN;
static volatile uint64_t x131 = 191562377084LLU;
uint64_t x132 = 176706446LLU;
t29 = (x129&(x130+(x131>x132)));
if (t29 != INT64_MIN) { NG(); } else { ; }
}
void f30(void) {
volatile int32_t x133 = INT32_MIN;
volatile int64_t x134 = 3636887151171LL;
volatile int32_t x135 = INT32_MIN;
int64_t x136 = INT64_MAX;
int64_t t30 = 847809044581LL;
t30 = (x133&(x134+(x135>x136)));
if (t30 != 3635689816064LL) { NG(); } else { ; }
}
void f31(void) {
int8_t x137 = 1;
volatile int64_t x138 = INT64_MIN;
int8_t x140 = INT8_MAX;
t31 = (x137&(x138+(x139>x140)));
if (t31 != 0LL) { NG(); } else { ; }
}
void f32(void) {
volatile uint8_t x141 = 0U;
int8_t x142 = INT8_MIN;
static volatile int16_t x143 = -1;
static int64_t x144 = -1LL;
volatile int32_t t32 = -1208;
t32 = (x141&(x142+(x143>x144)));
if (t32 != 0) { NG(); } else { ; }
}
void f33(void) {
int8_t x145 = -1;
uint64_t x146 = 110LLU;
int32_t x147 = -30362;
int64_t x148 = INT64_MAX;
volatile uint64_t t33 = 732731847401991024LLU;
t33 = (x145&(x146+(x147>x148)));
if (t33 != 110LLU) { NG(); } else { ; }
}
void f34(void) {
int16_t x149 = -34;
int16_t x150 = -73;
int16_t x151 = 43;
static int64_t x152 = 42188491409092424LL;
volatile int32_t t34 = 16203;
t34 = (x149&(x150+(x151>x152)));
if (t34 != -106) { NG(); } else { ; }
}
void f35(void) {
uint64_t x153 = 294LLU;
uint64_t x154 = UINT64_MAX;
int64_t x156 = -1LL;
uint64_t t35 = 845158167LLU;
t35 = (x153&(x154+(x155>x156)));
if (t35 != 294LLU) { NG(); } else { ; }
}
void f36(void) {
uint32_t x157 = UINT32_MAX;
static uint64_t x158 = UINT64_MAX;
t36 = (x157&(x158+(x159>x160)));
if (t36 != 0LLU) { NG(); } else { ; }
}
void f37(void) {
int8_t x161 = INT8_MIN;
int32_t x162 = INT32_MIN;
static int32_t x163 = INT32_MIN;
t37 = (x161&(x162+(x163>x164)));
if (t37 != INT32_MIN) { NG(); } else { ; }
}
void f38(void) {
int32_t x165 = -1;
int32_t x167 = -4034;
volatile int32_t t38 = 876231454;
t38 = (x165&(x166+(x167>x168)));
if (t38 != -32768) { NG(); } else { ; }
}
void f39(void) {
int32_t x169 = INT32_MAX;
int64_t x170 = 4790568957LL;
int16_t x171 = 838;
static int32_t x172 = -1;
int64_t t39 = 904963629549LL;
t39 = (x169&(x170+(x171>x172)));
if (t39 != 495601662LL) { NG(); } else { ; }
}
void f40(void) {
uint64_t x173 = UINT64_MAX;
int32_t x174 = INT32_MIN;
volatile int8_t x175 = -7;
uint32_t x176 = 403U;
volatile uint64_t t40 = 323LLU;
t40 = (x173&(x174+(x175>x176)));
if (t40 != 18446744071562067969LLU) { NG(); } else { ; }
}
void f41(void) {
int64_t x177 = INT64_MIN;
int32_t x178 = -1;
volatile int32_t x179 = -1;
volatile int64_t t41 = 2760425686801839193LL;
t41 = (x177&(x178+(x179>x180)));
if (t41 != 0LL) { NG(); } else { ; }
}
void f42(void) {
static int16_t x181 = INT16_MIN;
int32_t x183 = -1;
static uint8_t x184 = 100U;
static int32_t t42 = 2124064;
t42 = (x181&(x182+(x183>x184)));
if (t42 != -32768) { NG(); } else { ; }
}
void f43(void) {
uint32_t x186 = 12931U;
int64_t x187 = INT64_MAX;
volatile uint32_t x188 = UINT32_MAX;
uint32_t t43 = 2U;
t43 = (x185&(x186+(x187>x188)));
if (t43 != 512U) { NG(); } else { ; }
}
void f44(void) {
int16_t x190 = -1;
volatile int64_t x191 = INT64_MAX;
int32_t x192 = -1;
t44 = (x189&(x190+(x191>x192)));
if (t44 != 0) { NG(); } else { ; }
}
void f45(void) {
volatile uint8_t x193 = 6U;
volatile int64_t x194 = 7582787599LL;
volatile int64_t x195 = 4506180946LL;
int16_t x196 = INT16_MIN;
volatile int64_t t45 = -10156126LL;
t45 = (x193&(x194+(x195>x196)));
if (t45 != 0LL) { NG(); } else { ; }
}
void f46(void) {
int32_t x198 = 66989;
static int16_t x199 = 6285;
static int32_t x200 = 0;
t46 = (x197&(x198+(x199>x200)));
if (t46 != 2) { NG(); } else { ; }
}
void f47(void) {
int32_t x201 = INT32_MIN;
int8_t x202 = -1;
int16_t x204 = -7707;
volatile int32_t t47 = 6504845;
t47 = (x201&(x202+(x203>x204)));
if (t47 != 0) { NG(); } else { ; }
}
void f48(void) {
static uint16_t x205 = 802U;
uint8_t x206 = UINT8_MAX;
int32_t x207 = -72288;
int16_t x208 = INT16_MAX;
int32_t t48 = -343;
t48 = (x205&(x206+(x207>x208)));
if (t48 != 34) { NG(); } else { ; }
}
void f49(void) {
static volatile int16_t x210 = -1;
int32_t x211 = -1;
static int32_t t49 = -4;
t49 = (x209&(x210+(x211>x212)));
if (t49 != -3499) { NG(); } else { ; }
}
void f50(void) {
uint8_t x213 = 28U;
static uint16_t x214 = UINT16_MAX;
int64_t x215 = INT64_MIN;
static uint64_t x216 = 7701039LLU;
static int32_t t50 = -77;
t50 = (x213&(x214+(x215>x216)));
if (t50 != 0) { NG(); } else { ; }
}
void f51(void) {
int8_t x217 = INT8_MAX;
static uint64_t x218 = 141777330603323LLU;
static uint64_t x219 = 84182319605LLU;
int16_t x220 = -1;
t51 = (x217&(x218+(x219>x220)));
if (t51 != 59LLU) { NG(); } else { ; }
}
void f52(void) {
int16_t x222 = INT16_MIN;
static uint64_t x223 = UINT64_MAX;
int64_t x224 = 34693675298060LL;
uint32_t t52 = 9353U;
t52 = (x221&(x222+(x223>x224)));
if (t52 != 0U) { NG(); } else { ; }
}
void f53(void) {
static int16_t x225 = 155;
uint32_t x226 = UINT32_MAX;
int16_t x228 = INT16_MIN;
uint32_t t53 = 0U;
t53 = (x225&(x226+(x227>x228)));
if (t53 != 0U) { NG(); } else { ; }
}
void f54(void) {
int16_t x231 = -1;
volatile int64_t t54 = -17909895LL;
t54 = (x229&(x230+(x231>x232)));
if (t54 != 0LL) { NG(); } else { ; }
}
void f55(void) {
uint8_t x234 = UINT8_MAX;
volatile uint32_t x235 = 1625U;
int32_t x236 = INT32_MAX;
volatile int32_t t55 = 56323;
t55 = (x233&(x234+(x235>x236)));
if (t55 != 240) { NG(); } else { ; }
}
void f56(void) {
volatile uint64_t x237 = UINT64_MAX;
volatile int64_t x239 = -1LL;
uint64_t t56 = 8751317361593143002LLU;
t56 = (x237&(x238+(x239>x240)));
if (t56 != 18446744073709518849LLU) { NG(); } else { ; }
}
void f57(void) {
volatile int64_t x243 = -2071488782038545128LL;
static int16_t x244 = INT16_MAX;
volatile uint32_t t57 = 5805U;
t57 = (x241&(x242+(x243>x244)));
if (t57 != 2147483648U) { NG(); } else { ; }
}
void f58(void) {
volatile uint64_t x245 = 61997LLU;
static int8_t x247 = INT8_MIN;
int64_t x248 = -1LL;
uint64_t t58 = 1742166451894892682LLU;
t58 = (x245&(x246+(x247>x248)));
if (t58 != 9LLU) { NG(); } else { ; }
}
void f59(void) {
uint16_t x249 = 2790U;
int8_t x250 = INT8_MAX;
static int32_t x251 = INT32_MIN;
int64_t x252 = -1LL;
t59 = (x249&(x250+(x251>x252)));
if (t59 != 102) { NG(); } else { ; }
}
void f60(void) {
uint16_t x253 = UINT16_MAX;
volatile int16_t x255 = INT16_MIN;
volatile int8_t x256 = -1;
static volatile uint64_t t60 = 11791544641531738LLU;
t60 = (x253&(x254+(x255>x256)));
if (t60 != 65535LLU) { NG(); } else { ; }
}
void f61(void) {
static int8_t x257 = -1;
int8_t x258 = INT8_MIN;
volatile uint8_t x260 = UINT8_MAX;
static volatile int32_t t61 = 1;
t61 = (x257&(x258+(x259>x260)));
if (t61 != -128) { NG(); } else { ; }
}
void f62(void) {
int64_t x261 = -4055155145981LL;
int32_t x264 = -1;
volatile uint64_t t62 = 3781881298364LLU;
t62 = (x261&(x262+(x263>x264)));
if (t62 != 0LLU) { NG(); } else { ; }
}
void f63(void) {
uint16_t x266 = UINT16_MAX;
int32_t x267 = -1;
uint32_t x268 = UINT32_MAX;
t63 = (x265&(x266+(x267>x268)));
if (t63 != 6166) { NG(); } else { ; }
}
void f64(void) {
uint64_t x269 = 1LLU;
static volatile int8_t x271 = INT8_MAX;
int16_t x272 = INT16_MAX;
uint64_t t64 = 130020283930LLU;
t64 = (x269&(x270+(x271>x272)));
if (t64 != 1LLU) { NG(); } else { ; }
}
void f65(void) {
int16_t x273 = -1;
volatile uint16_t x275 = 86U;
int32_t x276 = -1;
static volatile int32_t t65 = -30335402;
t65 = (x273&(x274+(x275>x276)));
if (t65 != 0) { NG(); } else { ; }
}
void f66(void) {
uint8_t x277 = 6U;
volatile uint32_t x278 = UINT32_MAX;
volatile int8_t x279 = INT8_MAX;
volatile uint32_t t66 = 10U;
t66 = (x277&(x278+(x279>x280)));
if (t66 != 0U) { NG(); } else { ; }
}
void f67(void) {
uint8_t x282 = 46U;
uint32_t x283 = 8178U;
int32_t t67 = 144361;
t67 = (x281&(x282+(x283>x284)));
if (t67 != 10) { NG(); } else { ; }
}
void f68(void) {
int64_t x285 = INT64_MIN;
static int16_t x286 = 131;
static uint64_t x287 = 6809478LLU;
uint8_t x288 = 11U;
t68 = (x285&(x286+(x287>x288)));
if (t68 != 0LL) { NG(); } else { ; }
}
void f69(void) {
static int8_t x289 = -22;
volatile uint32_t x290 = 29U;
static int64_t x291 = INT64_MIN;
int64_t x292 = INT64_MIN;
t69 = (x289&(x290+(x291>x292)));
if (t69 != 8U) { NG(); } else { ; }
}
void f70(void) {
uint32_t x293 = 21U;
int8_t x294 = INT8_MIN;
int16_t x295 = INT16_MIN;
int64_t x296 = -389669LL;
static volatile uint32_t t70 = 28U;
t70 = (x293&(x294+(x295>x296)));
if (t70 != 1U) { NG(); } else { ; }
}
void f71(void) {
volatile int8_t x297 = 7;
static int8_t x298 = INT8_MAX;
int8_t x299 = INT8_MIN;
static uint32_t x300 = 498U;
int32_t t71 = -13626;
t71 = (x297&(x298+(x299>x300)));
if (t71 != 0) { NG(); } else { ; }
}
void f72(void) {
int16_t x301 = INT16_MIN;
static uint8_t x302 = UINT8_MAX;
int16_t x304 = 16;
volatile int32_t t72 = 7170;
t72 = (x301&(x302+(x303>x304)));
if (t72 != 0) { NG(); } else { ; }
}
void f73(void) {
uint32_t x306 = UINT32_MAX;
volatile uint32_t x308 = 958028U;
t73 = (x305&(x306+(x307>x308)));
if (t73 != 4294967295LL) { NG(); } else { ; }
}
void f74(void) {
int8_t x309 = 1;
uint16_t x310 = 14012U;
uint32_t x311 = 1105U;
volatile int32_t t74 = 576130;
t74 = (x309&(x310+(x311>x312)));
if (t74 != 0) { NG(); } else { ; }
}
void f75(void) {
volatile uint8_t x313 = 87U;
int8_t x316 = INT8_MAX;
volatile int64_t t75 = -392132LL;
t75 = (x313&(x314+(x315>x316)));
if (t75 != 87LL) { NG(); } else { ; }
}
void f76(void) {
int32_t x317 = INT32_MIN;
static uint8_t x318 = UINT8_MAX;
volatile int32_t x320 = 1606;
int32_t t76 = -397949;
t76 = (x317&(x318+(x319>x320)));
if (t76 != 0) { NG(); } else { ; }
}
void f77(void) {
static volatile int64_t x322 = INT64_MAX;
uint16_t x323 = 22U;
uint8_t x324 = 87U;
int64_t t77 = -3328753LL;
t77 = (x321&(x322+(x323>x324)));
if (t77 != 32767LL) { NG(); } else { ; }
}
void f78(void) {
int16_t x325 = INT16_MIN;
volatile int32_t x327 = INT32_MAX;
int8_t x328 = INT8_MAX;
int32_t t78 = 6;
t78 = (x325&(x326+(x327>x328)));
if (t78 != 0) { NG(); } else { ; }
}
void f79(void) {
int16_t x329 = INT16_MIN;
int16_t x330 = -2993;
int8_t x331 = INT8_MIN;
int32_t x332 = -1;
int32_t t79 = 1307;
t79 = (x329&(x330+(x331>x332)));
if (t79 != -32768) { NG(); } else { ; }
}
void f80(void) {
static int8_t x333 = INT8_MIN;
int64_t x334 = -1LL;
uint64_t x335 = 0LLU;
static int8_t x336 = INT8_MIN;
static volatile int64_t t80 = 213137319272LL;
t80 = (x333&(x334+(x335>x336)));
if (t80 != -128LL) { NG(); } else { ; }
}
void f81(void) {
uint64_t x341 = 119865416735886LLU;
int32_t x343 = 527;
static volatile int32_t x344 = INT32_MIN;
volatile uint64_t t81 = 84033625193LLU;
t81 = (x341&(x342+(x343>x344)));
if (t81 != 0LLU) { NG(); } else { ; }
}
void f82(void) {
static uint16_t x345 = UINT16_MAX;
volatile uint32_t x346 = UINT32_MAX;
int16_t x347 = -13280;
int16_t x348 = INT16_MIN;
uint32_t t82 = 149U;
t82 = (x345&(x346+(x347>x348)));
if (t82 != 0U) { NG(); } else { ; }
}
void f83(void) {
static int8_t x349 = INT8_MAX;
int8_t x350 = -1;
int64_t x351 = INT64_MIN;
static volatile uint64_t x352 = UINT64_MAX;
int32_t t83 = -21;
t83 = (x349&(x350+(x351>x352)));
if (t83 != 127) { NG(); } else { ; }
}
void f84(void) {
int32_t x353 = INT32_MAX;
int32_t x355 = INT32_MAX;
uint64_t x356 = 421LLU;
int32_t t84 = -5;
t84 = (x353&(x354+(x355>x356)));
if (t84 != 2147483521) { NG(); } else { ; }
}
void f85(void) {
int8_t x357 = 0;
int32_t x358 = -1;
int32_t x359 = INT32_MIN;
t85 = (x357&(x358+(x359>x360)));
if (t85 != 0) { NG(); } else { ; }
}
void f86(void) {
volatile int64_t x361 = INT64_MIN;
uint8_t x362 = UINT8_MAX;
static uint64_t x363 = 132556284LLU;
uint32_t x364 = 3U;
int64_t t86 = 63621751LL;
t86 = (x361&(x362+(x363>x364)));
if (t86 != 0LL) { NG(); } else { ; }
}
void f87(void) {
int8_t x365 = 3;
volatile int64_t x366 = INT64_MIN;
volatile int32_t x367 = INT32_MIN;
int32_t x368 = 718;
static volatile int64_t t87 = -4243709838125102712LL;
t87 = (x365&(x366+(x367>x368)));
if (t87 != 0LL) { NG(); } else { ; }
}
void f88(void) {
int16_t x369 = INT16_MIN;
uint16_t x370 = UINT16_MAX;
static int32_t x371 = 2;
int64_t x372 = INT64_MAX;
static volatile int32_t t88 = 13830;
t88 = (x369&(x370+(x371>x372)));
if (t88 != 32768) { NG(); } else { ; }
}
void f89(void) {
uint16_t x373 = 431U;
uint64_t x374 = 4165LLU;
uint32_t x375 = 25602U;
int8_t x376 = INT8_MIN;
t89 = (x373&(x374+(x375>x376)));
if (t89 != 5LLU) { NG(); } else { ; }
}
void f90(void) {
uint32_t x377 = 79801904U;
int16_t x378 = -18;
int32_t x379 = INT32_MAX;
volatile int32_t x380 = -13;
t90 = (x377&(x378+(x379>x380)));
if (t90 != 79801888U) { NG(); } else { ; }
}
void f91(void) {
int32_t x381 = -1;
int32_t x382 = INT32_MIN;
uint64_t x384 = UINT64_MAX;
int32_t t91 = INT32_MIN;
t91 = (x381&(x382+(x383>x384)));
if (t91 != INT32_MIN) { NG(); } else { ; }
}
void f92(void) {
int16_t x386 = INT16_MIN;
int8_t x388 = INT8_MAX;
static int32_t t92 = 941;
t92 = (x385&(x386+(x387>x388)));
if (t92 != -338788352) { NG(); } else { ; }
}
void f93(void) {
uint64_t x389 = 123287723252884LLU;
int16_t x391 = -1;
uint64_t t93 = 2189076639LLU;
t93 = (x389&(x390+(x391>x392)));
if (t93 != 0LLU) { NG(); } else { ; }
}
void f94(void) {
static int32_t x393 = INT32_MAX;
int8_t x394 = INT8_MIN;
volatile uint16_t x395 = 1U;
volatile int64_t x396 = INT64_MIN;
volatile int32_t t94 = -263;
t94 = (x393&(x394+(x395>x396)));
if (t94 != 2147483521) { NG(); } else { ; }
}
void f95(void) {
int8_t x398 = INT8_MAX;
int64_t x399 = -1LL;
uint16_t x400 = 58U;
t95 = (x397&(x398+(x399>x400)));
if (t95 != 127) { NG(); } else { ; }
}
void f96(void) {
int16_t x401 = INT16_MAX;
uint8_t x402 = 49U;
volatile int8_t x403 = 1;
uint32_t x404 = 8365917U;
volatile int32_t t96 = 709824;
t96 = (x401&(x402+(x403>x404)));
if (t96 != 49) { NG(); } else { ; }
}
void f97(void) {
int8_t x405 = INT8_MIN;
int16_t x407 = 56;
int64_t t97 = INT64_MIN;
t97 = (x405&(x406+(x407>x408)));
if (t97 != INT64_MIN) { NG(); } else { ; }
}
void f98(void) {
uint16_t x409 = 2211U;
static int8_t x410 = -1;
static int32_t x411 = -99140;
int32_t x412 = INT32_MIN;
int32_t t98 = -2520;
t98 = (x409&(x410+(x411>x412)));
if (t98 != 0) { NG(); } else { ; }
}
void f99(void) {
uint16_t x414 = 21U;
volatile int8_t x415 = INT8_MIN;
volatile uint64_t x416 = UINT64_MAX;
volatile int32_t t99 = 1;
t99 = (x413&(x414+(x415>x416)));
if (t99 != 0) { NG(); } else { ; }
}
void f100(void) {
int16_t x417 = -1;
static uint8_t x418 = UINT8_MAX;
int32_t x419 = INT32_MIN;
int16_t x420 = -1;
t100 = (x417&(x418+(x419>x420)));
if (t100 != 255) { NG(); } else { ; }
}
void f101(void) {
int64_t x429 = INT64_MIN;
uint8_t x430 = 0U;
int8_t x431 = -1;
volatile uint64_t x432 = 188933454164865LLU;
static volatile int64_t t101 = -122705675LL;
t101 = (x429&(x430+(x431>x432)));
if (t101 != 0LL) { NG(); } else { ; }
}
void f102(void) {
int64_t x433 = -59103120LL;
int8_t x434 = INT8_MIN;
static int8_t x436 = INT8_MIN;
t102 = (x433&(x434+(x435>x436)));
if (t102 != -59103232LL) { NG(); } else { ; }
}
void f103(void) {
int64_t x437 = -1LL;
volatile int64_t x438 = -117069LL;
volatile uint64_t x439 = 49358781885252LLU;
static int64_t t103 = -494163LL;
t103 = (x437&(x438+(x439>x440)));
if (t103 != -117068LL) { NG(); } else { ; }
}
void f104(void) {
volatile int64_t x442 = 206LL;
int64_t x443 = 420303922077634905LL;
uint32_t x444 = UINT32_MAX;
t104 = (x441&(x442+(x443>x444)));
if (t104 != 207LL) { NG(); } else { ; }
}
void f105(void) {
uint16_t x445 = 137U;
uint8_t x446 = UINT8_MAX;
int64_t x447 = INT64_MIN;
int32_t x448 = -1;
int32_t t105 = 126322042;
t105 = (x445&(x446+(x447>x448)));
if (t105 != 137) { NG(); } else { ; }
}
void f106(void) {
static int64_t x449 = 57078857223LL;
uint32_t x450 = 76934U;
int64_t x451 = INT64_MAX;
uint16_t x452 = UINT16_MAX;
int64_t t106 = 1639085936LL;
t106 = (x449&(x450+(x451>x452)));
if (t106 != 11271LL) { NG(); } else { ; }
}
void f107(void) {
volatile int64_t x453 = INT64_MAX;
static uint8_t x454 = UINT8_MAX;
uint32_t x455 = 182U;
static int64_t x456 = 8LL;
static volatile int64_t t107 = 141LL;
t107 = (x453&(x454+(x455>x456)));
if (t107 != 256LL) { NG(); } else { ; }
}
void f108(void) {
static int8_t x457 = -1;
volatile int16_t x458 = -1;
uint16_t x459 = 12U;
static int8_t x460 = INT8_MAX;
int32_t t108 = 377040;
t108 = (x457&(x458+(x459>x460)));
if (t108 != -1) { NG(); } else { ; }
}
void f109(void) {
uint32_t x465 = 3152U;
int16_t x466 = -1;
uint8_t x467 = 5U;
uint8_t x468 = UINT8_MAX;
uint32_t t109 = 14840U;
t109 = (x465&(x466+(x467>x468)));
if (t109 != 3152U) { NG(); } else { ; }
}
void f110(void) {
uint64_t x469 = UINT64_MAX;
int8_t x471 = 8;
volatile uint16_t x472 = 61U;
volatile uint64_t t110 = UINT64_MAX;
t110 = (x469&(x470+(x471>x472)));
if (t110 != UINT64_MAX) { NG(); } else { ; }
}
void f111(void) {
int64_t x473 = INT64_MIN;
volatile uint8_t x474 = UINT8_MAX;
uint16_t x475 = 460U;
int16_t x476 = INT16_MIN;
volatile int64_t t111 = 134292LL;
t111 = (x473&(x474+(x475>x476)));
if (t111 != 0LL) { NG(); } else { ; }
}
void f112(void) {
int32_t x477 = INT32_MIN;
int16_t x478 = 94;
int16_t x479 = 11530;
uint16_t x480 = 16U;
int32_t t112 = 0;
t112 = (x477&(x478+(x479>x480)));
if (t112 != 0) { NG(); } else { ; }
}
void f113(void) {
static uint32_t x481 = UINT32_MAX;
static int8_t x483 = INT8_MIN;
static volatile uint32_t t113 = UINT32_MAX;
t113 = (x481&(x482+(x483>x484)));
if (t113 != UINT32_MAX) { NG(); } else { ; }
}
void f114(void) {
int32_t x489 = INT32_MAX;
static uint32_t x490 = UINT32_MAX;
volatile uint32_t t114 = 199U;
t114 = (x489&(x490+(x491>x492)));
if (t114 != 0U) { NG(); } else { ; }
}
void f115(void) {
int16_t x493 = INT16_MAX;
int64_t x494 = -152329885521LL;
int8_t x496 = INT8_MIN;
static volatile int64_t t115 = 33016786991114829LL;
t115 = (x493&(x494+(x495>x496)));
if (t115 != 26799LL) { NG(); } else { ; }
}
void f116(void) {
static volatile int64_t x497 = INT64_MIN;
int32_t x498 = 41919;
uint16_t x500 = 7182U;
int64_t t116 = -10LL;
t116 = (x497&(x498+(x499>x500)));
if (t116 != 0LL) { NG(); } else { ; }
}
void f117(void) {
static int8_t x501 = -1;
volatile uint8_t x502 = 0U;
volatile int64_t x503 = INT64_MAX;
int64_t x504 = INT64_MIN;
t117 = (x501&(x502+(x503>x504)));
if (t117 != 1) { NG(); } else { ; }
}
void f118(void) {
static volatile uint64_t x505 = 0LLU;
int8_t x506 = 1;
int16_t x507 = 5302;
static uint64_t x508 = UINT64_MAX;
static volatile uint64_t t118 = 5578102353684423320LLU;
t118 = (x505&(x506+(x507>x508)));
if (t118 != 0LLU) { NG(); } else { ; }
}
void f119(void) {
uint8_t x509 = UINT8_MAX;
uint32_t x510 = 428U;
static int8_t x511 = INT8_MIN;
int8_t x512 = 48;
volatile uint32_t t119 = 632382275U;
t119 = (x509&(x510+(x511>x512)));
if (t119 != 172U) { NG(); } else { ; }
}
void f120(void) {
static uint32_t x513 = UINT32_MAX;
int32_t x514 = INT32_MIN;
uint8_t x515 = 0U;
int32_t x516 = INT32_MAX;
volatile uint32_t t120 = 573214U;
t120 = (x513&(x514+(x515>x516)));
if (t120 != 2147483648U) { NG(); } else { ; }
}
void f121(void) {
static int16_t x517 = INT16_MIN;
int16_t x518 = 7425;
uint8_t x519 = 2U;
uint64_t x520 = 125352801273LLU;
static volatile int32_t t121 = -1929458;
t121 = (x517&(x518+(x519>x520)));
if (t121 != 0) { NG(); } else { ; }
}
void f122(void) {
volatile uint32_t x521 = UINT32_MAX;
static int16_t x523 = 0;
int32_t x524 = -215495020;
t122 = (x521&(x522+(x523>x524)));
if (t122 != 1141073U) { NG(); } else { ; }
}
void f123(void) {
int32_t x525 = INT32_MIN;
static int64_t x526 = INT64_MAX;
static volatile int64_t x527 = INT64_MIN;
volatile int64_t t123 = -675581122910105LL;
t123 = (x525&(x526+(x527>x528)));
if (t123 != 9223372034707292160LL) { NG(); } else { ; }
}
void f124(void) {
static int16_t x529 = -1;
volatile int8_t x530 = INT8_MIN;
int16_t x531 = INT16_MIN;
volatile int32_t t124 = -4187;
t124 = (x529&(x530+(x531>x532)));
if (t124 != -128) { NG(); } else { ; }
}
void f125(void) {
int32_t x533 = INT32_MAX;
int64_t x534 = INT64_MAX;
uint32_t x535 = 3277U;
static uint64_t x536 = UINT64_MAX;
static int64_t t125 = 1926306LL;
t125 = (x533&(x534+(x535>x536)));
if (t125 != 2147483647LL) { NG(); } else { ; }
}
void f126(void) {
int64_t x537 = INT64_MIN;
static volatile uint8_t x538 = UINT8_MAX;
volatile int64_t x539 = INT64_MIN;
int64_t x540 = INT64_MIN;
t126 = (x537&(x538+(x539>x540)));
if (t126 != 0LL) { NG(); } else { ; }
}
void f127(void) {
int8_t x541 = -1;
int64_t x543 = 0LL;
int32_t x544 = 12;
uint32_t t127 = 516983U;
t127 = (x541&(x542+(x543>x544)));
if (t127 != 13U) { NG(); } else { ; }
}
void f128(void) {
int8_t x545 = INT8_MIN;
uint16_t x546 = UINT16_MAX;
uint64_t x547 = 2269581712260LLU;
uint64_t x548 = UINT64_MAX;
volatile int32_t t128 = -206521;
t128 = (x545&(x546+(x547>x548)));
if (t128 != 65408) { NG(); } else { ; }
}
void f129(void) {
volatile int16_t x549 = -1;
volatile int8_t x550 = 8;
volatile uint32_t x551 = UINT32_MAX;
static volatile int64_t x552 = -1316916027594001LL;
volatile int32_t t129 = 50778;
t129 = (x549&(x550+(x551>x552)));
if (t129 != 9) { NG(); } else { ; }
}
void f130(void) {
uint32_t x553 = 3013U;
int16_t x556 = 143;
volatile uint32_t t130 = 640U;
t130 = (x553&(x554+(x555>x556)));
if (t130 != 0U) { NG(); } else { ; }
}
void f131(void) {
int32_t x557 = INT32_MAX;
uint32_t x558 = 1109U;
static int32_t x560 = INT32_MAX;
volatile uint32_t t131 = 48154U;
t131 = (x557&(x558+(x559>x560)));
if (t131 != 1109U) { NG(); } else { ; }
}
void f132(void) {
int16_t x561 = -2162;
static int8_t x562 = INT8_MIN;
int8_t x564 = -1;
volatile int32_t t132 = 27135;
t132 = (x561&(x562+(x563>x564)));
if (t132 != -2176) { NG(); } else { ; }
}
void f133(void) {
int64_t x565 = INT64_MIN;
uint64_t x566 = 3LLU;
int8_t x568 = INT8_MIN;
uint64_t t133 = 17010926308927LLU;
t133 = (x565&(x566+(x567>x568)));
if (t133 != 0LLU) { NG(); } else { ; }
}
void f134(void) {
int8_t x573 = -36;
int64_t x574 = INT64_MIN;
int64_t x575 = INT64_MAX;
static uint16_t x576 = 1686U;
volatile int64_t t134 = INT64_MIN;
t134 = (x573&(x574+(x575>x576)));
if (t134 != INT64_MIN) { NG(); } else { ; }
}
void f135(void) {
int8_t x577 = INT8_MIN;
int64_t x578 = INT64_MIN;
uint8_t x579 = UINT8_MAX;
volatile int64_t x580 = -1LL;
int64_t t135 = INT64_MIN;
t135 = (x577&(x578+(x579>x580)));
if (t135 != INT64_MIN) { NG(); } else { ; }
}
void f136(void) {
static int64_t x581 = -1LL;
int32_t x583 = -1;
uint8_t x584 = 1U;
t136 = (x581&(x582+(x583>x584)));
if (t136 != -32768LL) { NG(); } else { ; }
}
void f137(void) {
int8_t x586 = 53;
static int16_t x587 = INT16_MIN;
int64_t x588 = INT64_MAX;
uint64_t t137 = 1093169344LLU;
t137 = (x585&(x586+(x587>x588)));
if (t137 != 5LLU) { NG(); } else { ; }
}
void f138(void) {
volatile int32_t x589 = INT32_MIN;
uint32_t x590 = UINT32_MAX;
static uint8_t x591 = UINT8_MAX;
int8_t x592 = INT8_MIN;
uint32_t t138 = 141846294U;
t138 = (x589&(x590+(x591>x592)));
if (t138 != 0U) { NG(); } else { ; }
}
void f139(void) {
uint32_t x593 = 20U;
int32_t x595 = INT32_MIN;
static uint8_t x596 = 0U;
static int64_t t139 = 4991773267168LL;
t139 = (x593&(x594+(x595>x596)));
if (t139 != 0LL) { NG(); } else { ; }
}
void f140(void) {
int8_t x597 = INT8_MIN;
int16_t x598 = INT16_MIN;
volatile int64_t x600 = -132442439343829991LL;
int32_t t140 = 0;
t140 = (x597&(x598+(x599>x600)));
if (t140 != -32768) { NG(); } else { ; }
}
void f141(void) {
int32_t x601 = 23146919;
int32_t x602 = INT32_MAX;
volatile int32_t x603 = -3189;
static volatile int32_t t141 = 34;
t141 = (x601&(x602+(x603>x604)));
if (t141 != 23146919) { NG(); } else { ; }
}
void f142(void) {
int8_t x605 = INT8_MAX;
int64_t x606 = -3602LL;
int16_t x607 = -11;
int16_t x608 = INT16_MIN;
t142 = (x605&(x606+(x607>x608)));
if (t142 != 111LL) { NG(); } else { ; }
}
void f143(void) {
volatile int16_t x610 = INT16_MIN;
uint8_t x611 = 5U;
static int32_t t143 = 1716379;
t143 = (x609&(x610+(x611>x612)));
if (t143 != -32768) { NG(); } else { ; }
}
void f144(void) {
volatile uint32_t x614 = 285569U;
int64_t x615 = INT64_MAX;
int64_t x616 = INT64_MAX;
uint64_t t144 = 592281207152LLU;
t144 = (x613&(x614+(x615>x616)));
if (t144 != 284673LLU) { NG(); } else { ; }
}
void f145(void) {
uint64_t x617 = 489386660058973LLU;
volatile int32_t x620 = INT32_MAX;
volatile uint64_t t145 = 15109LLU;
t145 = (x617&(x618+(x619>x620)));
if (t145 != 0LLU) { NG(); } else { ; }
}
void f146(void) {
int32_t x621 = INT32_MIN;
uint64_t x622 = 205LLU;
uint64_t x623 = 958795583LLU;
uint8_t x624 = 10U;
uint64_t t146 = 32223455LLU;
t146 = (x621&(x622+(x623>x624)));
if (t146 != 0LLU) { NG(); } else { ; }
}
void f147(void) {
int16_t x625 = -4;
int8_t x626 = INT8_MAX;
uint16_t x627 = 1433U;
static int8_t x628 = -1;
int32_t t147 = 24;
t147 = (x625&(x626+(x627>x628)));
if (t147 != 128) { NG(); } else { ; }
}
void f148(void) {
volatile int16_t x629 = INT16_MIN;
static uint8_t x630 = 16U;
volatile int16_t x632 = INT16_MIN;
int32_t t148 = 341;
t148 = (x629&(x630+(x631>x632)));
if (t148 != 0) { NG(); } else { ; }
}
void f149(void) {
int16_t x636 = -1;
volatile int32_t t149 = 725346039;
t149 = (x633&(x634+(x635>x636)));
if (t149 != -32768) { NG(); } else { ; }
}
void f150(void) {
volatile uint32_t x637 = UINT32_MAX;
int64_t x639 = INT64_MIN;
uint16_t x640 = 86U;
t150 = (x637&(x638+(x639>x640)));
if (t150 != UINT32_MAX) { NG(); } else { ; }
}
void f151(void) {
static int64_t x641 = INT64_MIN;
uint16_t x642 = 2144U;
uint8_t x643 = 15U;
int64_t t151 = 11581793LL;
t151 = (x641&(x642+(x643>x644)));
if (t151 != 0LL) { NG(); } else { ; }
}
void f152(void) {
static uint64_t x645 = 1697788009927LLU;
uint64_t x646 = 2LLU;
int64_t x647 = INT64_MIN;
uint64_t t152 = 144LLU;
t152 = (x645&(x646+(x647>x648)));
if (t152 != 2LLU) { NG(); } else { ; }
}
void f153(void) {
int64_t x649 = INT64_MAX;
int64_t x650 = INT64_MIN;
int32_t x651 = INT32_MAX;
uint32_t x652 = 115559U;
volatile int64_t t153 = 45572373LL;
t153 = (x649&(x650+(x651>x652)));
if (t153 != 1LL) { NG(); } else { ; }
}
void f154(void) {
int16_t x653 = -1295;
static int32_t x654 = -1;
static int16_t x655 = -1921;
uint64_t x656 = 116119562724583LLU;
t154 = (x653&(x654+(x655>x656)));
if (t154 != 0) { NG(); } else { ; }
}
void f155(void) {
static int16_t x657 = INT16_MIN;
static int64_t x658 = -1LL;
int32_t x660 = 654926;
volatile int64_t t155 = 5402926331342539LL;
t155 = (x657&(x658+(x659>x660)));
if (t155 != -32768LL) { NG(); } else { ; }
}
void f156(void) {
volatile int8_t x661 = -1;
uint16_t x662 = 271U;
int32_t x663 = INT32_MAX;
int16_t x664 = INT16_MIN;
volatile int32_t t156 = 291210;
t156 = (x661&(x662+(x663>x664)));
if (t156 != 272) { NG(); } else { ; }
}
void f157(void) {
int32_t x666 = 472919;
int8_t x667 = 0;
int32_t x668 = INT32_MIN;
t157 = (x665&(x666+(x667>x668)));
if (t157 != 72) { NG(); } else { ; }
}
void f158(void) {
int16_t x669 = INT16_MAX;
volatile uint8_t x671 = 0U;
volatile int8_t x672 = INT8_MAX;
int64_t t158 = 250092879208106667LL;
t158 = (x669&(x670+(x671>x672)));
if (t158 != 32767LL) { NG(); } else { ; }
}
void f159(void) {
uint32_t x675 = 706334541U;
volatile int8_t x676 = INT8_MAX;
int32_t t159 = 1;
t159 = (x673&(x674+(x675>x676)));
if (t159 != 0) { NG(); } else { ; }
}
void f160(void) {
static int8_t x677 = -1;
int16_t x678 = INT16_MAX;
int64_t x679 = INT64_MAX;
uint64_t x680 = UINT64_MAX;
t160 = (x677&(x678+(x679>x680)));
if (t160 != 32767) { NG(); } else { ; }
}
void f161(void) {
int16_t x681 = 27;
int64_t x683 = 2735235121447539841LL;
int8_t x684 = INT8_MIN;
volatile int32_t t161 = -4085517;
t161 = (x681&(x682+(x683>x684)));
if (t161 != 8) { NG(); } else { ; }
}
void f162(void) {
int8_t x686 = -2;
int32_t x688 = -4051;
volatile uint32_t t162 = 5600U;
t162 = (x685&(x686+(x687>x688)));
if (t162 != 172254U) { NG(); } else { ; }
}
void f163(void) {
int32_t x689 = -29;
static uint8_t x690 = 1U;
int64_t x692 = -1LL;
int32_t t163 = -1;
t163 = (x689&(x690+(x691>x692)));
if (t163 != 1) { NG(); } else { ; }
}
void f164(void) {
uint64_t x693 = 233255288LLU;
volatile int64_t x695 = INT64_MAX;
volatile int8_t x696 = -1;
volatile uint64_t t164 = 123487LLU;
t164 = (x693&(x694+(x695>x696)));
if (t164 != 233242624LLU) { NG(); } else { ; }
}
void f165(void) {
int64_t x697 = -3106904104LL;
static uint32_t x699 = UINT32_MAX;
volatile int8_t x700 = INT8_MIN;
int64_t t165 = -2260490666495LL;
t165 = (x697&(x698+(x699>x700)));
if (t165 != 0LL) { NG(); } else { ; }
}
void f166(void) {
volatile int8_t x701 = INT8_MAX;
uint16_t x703 = UINT16_MAX;
int8_t x704 = -1;
int32_t t166 = 53585;
t166 = (x701&(x702+(x703>x704)));
if (t166 != 45) { NG(); } else { ; }
}
void f167(void) {
static int8_t x705 = INT8_MAX;
uint8_t x706 = UINT8_MAX;
int16_t x707 = INT16_MAX;
static uint8_t x708 = 63U;
volatile int32_t t167 = -37785;
t167 = (x705&(x706+(x707>x708)));
if (t167 != 0) { NG(); } else { ; }
}
void f168(void) {
uint8_t x709 = UINT8_MAX;
uint32_t x710 = UINT32_MAX;
static int16_t x711 = INT16_MIN;
uint16_t x712 = UINT16_MAX;
volatile uint32_t t168 = 644U;
t168 = (x709&(x710+(x711>x712)));
if (t168 != 255U) { NG(); } else { ; }
}
void f169(void) {
uint8_t x713 = 74U;
int8_t x714 = -1;
static int64_t x715 = -54748LL;
volatile int32_t t169 = -80;
t169 = (x713&(x714+(x715>x716)));
if (t169 != 74) { NG(); } else { ; }
}
void f170(void) {
volatile int32_t x717 = 53;
int16_t x718 = INT16_MAX;
int32_t x719 = 292;
static int16_t x720 = 11462;
t170 = (x717&(x718+(x719>x720)));
if (t170 != 53) { NG(); } else { ; }
}
void f171(void) {
uint32_t x726 = 49394U;
static int16_t x727 = INT16_MIN;
volatile int16_t x728 = INT16_MAX;
volatile int64_t t171 = 242426156743LL;
t171 = (x725&(x726+(x727>x728)));
if (t171 != 0LL) { NG(); } else { ; }
}
void f172(void) {
uint32_t x729 = 11U;
int16_t x730 = 6;
uint16_t x731 = 110U;
int16_t x732 = INT16_MIN;
uint32_t t172 = 1U;
t172 = (x729&(x730+(x731>x732)));
if (t172 != 3U) { NG(); } else { ; }
}
void f173(void) {
int16_t x733 = INT16_MIN;
static volatile int8_t x734 = INT8_MAX;
int64_t x735 = 7LL;
int32_t t173 = 97117;
t173 = (x733&(x734+(x735>x736)));
if (t173 != 0) { NG(); } else { ; }
}
void f174(void) {
int8_t x738 = INT8_MAX;
int8_t x739 = INT8_MAX;
static volatile int32_t t174 = -1851;
t174 = (x737&(x738+(x739>x740)));
if (t174 != 127) { NG(); } else { ; }
}
void f175(void) {
static int8_t x741 = INT8_MAX;
volatile uint32_t x742 = 8547U;
uint16_t x743 = 2795U;
static uint32_t t175 = 142819U;
t175 = (x741&(x742+(x743>x744)));
if (t175 != 100U) { NG(); } else { ; }
}
void f176(void) {
int32_t x745 = -159;
int64_t x746 = INT64_MIN;
volatile int64_t x747 = -2836073829057164LL;
uint16_t x748 = UINT16_MAX;
int64_t t176 = INT64_MIN;
t176 = (x745&(x746+(x747>x748)));
if (t176 != INT64_MIN) { NG(); } else { ; }
}
void f177(void) {
static int32_t x751 = INT32_MIN;
volatile uint8_t x752 = 1U;
volatile uint64_t t177 = 38257554LLU;
t177 = (x749&(x750+(x751>x752)));
if (t177 != 17883161332035893170LLU) { NG(); } else { ; }
}
void f178(void) {
int64_t x757 = 20890482LL;
uint32_t x758 = UINT32_MAX;
volatile uint64_t x759 = 14994530810044451LLU;
int64_t t178 = -519663LL;
t178 = (x757&(x758+(x759>x760)));
if (t178 != 20890482LL) { NG(); } else { ; }
}
void f179(void) {
uint32_t x761 = 1U;
uint64_t x763 = 43438396585600LLU;
uint32_t t179 = 453151U;
t179 = (x761&(x762+(x763>x764)));
if (t179 != 0U) { NG(); } else { ; }
}
void f180(void) {
int16_t x766 = 1875;
int16_t x767 = INT16_MIN;
volatile int64_t x768 = INT64_MIN;
t180 = (x765&(x766+(x767>x768)));
if (t180 != 0) { NG(); } else { ; }
}
void f181(void) {
static int16_t x769 = 22;
static int16_t x770 = 5198;
static uint32_t x771 = 316U;
int64_t x772 = -433331LL;
static volatile int32_t t181 = 12861361;
t181 = (x769&(x770+(x771>x772)));
if (t181 != 6) { NG(); } else { ; }
}
void f182(void) {
int64_t x773 = INT64_MIN;
uint32_t x775 = 1920087U;
uint32_t x776 = UINT32_MAX;
t182 = (x773&(x774+(x775>x776)));
if (t182 != INT64_MIN) { NG(); } else { ; }
}
void f183(void) {
int16_t x777 = -83;
static volatile int32_t x778 = -1;
int64_t x779 = INT64_MIN;
t183 = (x777&(x778+(x779>x780)));
if (t183 != -83) { NG(); } else { ; }
}
void f184(void) {
static int32_t x781 = INT32_MIN;
volatile int8_t x782 = -1;
int16_t x784 = -1;
int32_t t184 = -158;
t184 = (x781&(x782+(x783>x784)));
if (t184 != 0) { NG(); } else { ; }
}
void f185(void) {
int16_t x785 = -1;
int32_t x786 = INT32_MIN;
int32_t x788 = 3629440;
static int32_t t185 = INT32_MIN;
t185 = (x785&(x786+(x787>x788)));
if (t185 != INT32_MIN) { NG(); } else { ; }
}
void f186(void) {
static int8_t x789 = -58;
uint64_t x790 = UINT64_MAX;
static int8_t x791 = 53;
uint16_t x792 = UINT16_MAX;
volatile uint64_t t186 = 3937387222670751LLU;
t186 = (x789&(x790+(x791>x792)));
if (t186 != 18446744073709551558LLU) { NG(); } else { ; }
}
void f187(void) {
int8_t x793 = INT8_MAX;
int8_t x795 = -1;
volatile int16_t x796 = INT16_MAX;
volatile int64_t t187 = 222692693LL;
t187 = (x793&(x794+(x795>x796)));
if (t187 != 127LL) { NG(); } else { ; }
}
void f188(void) {
int8_t x797 = -59;
static uint8_t x798 = 11U;
uint32_t x799 = 35759389U;
int64_t x800 = -17961756578LL;
volatile int32_t t188 = -20;
t188 = (x797&(x798+(x799>x800)));
if (t188 != 4) { NG(); } else { ; }
}
void f189(void) {
int64_t x801 = INT64_MIN;
int64_t x802 = -2401088601LL;
int32_t x803 = INT32_MIN;
uint32_t x804 = 10408002U;
t189 = (x801&(x802+(x803>x804)));
if (t189 != INT64_MIN) { NG(); } else { ; }
}
void f190(void) {
int64_t x806 = -132533111670823LL;
uint64_t x808 = UINT64_MAX;
int64_t t190 = INT64_MIN;
t190 = (x805&(x806+(x807>x808)));
if (t190 != INT64_MIN) { NG(); } else { ; }
}
void f191(void) {
uint16_t x810 = UINT16_MAX;
uint16_t x811 = 5251U;
int8_t x812 = INT8_MIN;
volatile int32_t t191 = -107;
t191 = (x809&(x810+(x811>x812)));
if (t191 != 65536) { NG(); } else { ; }
}
void f192(void) {
volatile int16_t x813 = 83;
int8_t x814 = INT8_MIN;
int8_t x815 = 2;
int32_t t192 = 2339;
t192 = (x813&(x814+(x815>x816)));
if (t192 != 1) { NG(); } else { ; }
}
void f193(void) {
uint64_t x817 = 4163LLU;
static int8_t x819 = INT8_MAX;
volatile int64_t x820 = -1LL;
t193 = (x817&(x818+(x819>x820)));
if (t193 != 1LLU) { NG(); } else { ; }
}
void f194(void) {
uint16_t x821 = UINT16_MAX;
volatile uint8_t x823 = UINT8_MAX;
int16_t x824 = -1;
volatile int32_t t194 = -8180;
t194 = (x821&(x822+(x823>x824)));
if (t194 != 1) { NG(); } else { ; }
}
void f195(void) {
static uint16_t x825 = 1015U;
int64_t x826 = INT64_MIN;
int8_t x827 = -1;
volatile int16_t x828 = 201;
int64_t t195 = -42538574007348236LL;
t195 = (x825&(x826+(x827>x828)));
if (t195 != 0LL) { NG(); } else { ; }
}
void f196(void) {
uint16_t x829 = UINT16_MAX;
uint16_t x831 = 18U;
int8_t x832 = INT8_MAX;
volatile int32_t t196 = -4946601;
t196 = (x829&(x830+(x831>x832)));
if (t196 != 65530) { NG(); } else { ; }
}
void f197(void) {
uint32_t x833 = 1U;
int32_t x834 = INT32_MAX;
volatile uint32_t t197 = 451337369U;
t197 = (x833&(x834+(x835>x836)));
if (t197 != 1U) { NG(); } else { ; }
}
void f198(void) {
static int8_t x837 = 5;
int16_t x838 = INT16_MAX;
uint32_t x840 = 1U;
volatile int32_t t198 = 25;
t198 = (x837&(x838+(x839>x840)));
if (t198 != 0) { NG(); } else { ; }
}
void f199(void) {
int8_t x841 = INT8_MIN;
int64_t x842 = INT64_MIN;
uint64_t x843 = 950076991702LLU;
int64_t x844 = 8306LL;
volatile int64_t t199 = INT64_MIN;
t199 = (x841&(x842+(x843>x844)));
if (t199 != INT64_MIN) { NG(); } else { ; }
}
int main(void) {
f0();
f1();
f2();
f3();
f4();
f5();
f6();
f7();
f8();
f9();
f10();
f11();
f12();
f13();
f14();
f15();
f16();
f17();
f18();
f19();
f20();
f21();
f22();
f23();
f24();
f25();
f26();
f27();
f28();
f29();
f30();
f31();
f32();
f33();
f34();
f35();
f36();
f37();
f38();
f39();
f40();
f41();
f42();
f43();
f44();
f45();
f46();
f47();
f48();
f49();
f50();
f51();
f52();
f53();
f54();
f55();
f56();
f57();
f58();
f59();
f60();
f61();
f62();
f63();
f64();
f65();
f66();
f67();
f68();
f69();
f70();
f71();
f72();
f73();
f74();
f75();
f76();
f77();
f78();
f79();
f80();
f81();
f82();
f83();
f84();
f85();
f86();
f87();
f88();
f89();
f90();
f91();
f92();
f93();
f94();
f95();
f96();
f97();
f98();
f99();
f100();
f101();
f102();
f103();
f104();
f105();
f106();
f107();
f108();
f109();
f110();
f111();
f112();
f113();
f114();
f115();
f116();
f117();
f118();
f119();
f120();
f121();
f122();
f123();
f124();
f125();
f126();
f127();
f128();
f129();
f130();
f131();
f132();
f133();
f134();
f135();
f136();
f137();
f138();
f139();
f140();
f141();
f142();
f143();
f144();
f145();
f146();
f147();
f148();
f149();
f150();
f151();
f152();
f153();
f154();
f155();
f156();
f157();
f158();
f159();
f160();
f161();
f162();
f163();
f164();
f165();
f166();
f167();
f168();
f169();
f170();
f171();
f172();
f173();
f174();
f175();
f176();
f177();
f178();
f179();
f180();
f181();
f182();
f183();
f184();
f185();
f186();
f187();
f188();
f189();
f190();
f191();
f192();
f193();
f194();
f195();
f196();
f197();
f198();
f199();
return 0;
}
| 18.755312 | 61 | 0.59258 |
7495f9bbedfefa47c3b6f2c51d813ff7febdce73 | 1,809 | c | C | ARIS/application/src/wifi_internal_thread.c | arrow-acs/acn-embedded | b31d4cf2055f8809fa7b80ec80703402fc09001e | [
"Apache-2.0"
] | 7 | 2017-03-27T01:08:22.000Z | 2019-08-20T18:29:03.000Z | ARIS/application/src/wifi_internal_thread.c | konexios/moonstone-acn-embedded | b31d4cf2055f8809fa7b80ec80703402fc09001e | [
"Apache-2.0"
] | 5 | 2017-11-10T23:09:50.000Z | 2018-04-04T13:58:31.000Z | ARIS/application/src/wifi_internal_thread.c | konexios/moonstone-acn-embedded | b31d4cf2055f8809fa7b80ec80703402fc09001e | [
"Apache-2.0"
] | 5 | 2017-03-29T02:15:10.000Z | 2019-02-22T13:09:42.000Z | /* Copyright (c) 2017 Arrow Electronics, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License 2.0
* which accompanies this distribution, and is available at
* http://apache.org/licenses/LICENSE-2.0
* Contributors: Arrow Electronics, Inc.
*/
#include "reloc_macro.h"
#include "wifi_thread.h"
#include "wifi_internal_thread.h"
#include "driver/include/m2m_wifi.h"
#include "ledcmd.h"
#define INT_STACK_LEN 0x1000
extern uint32_t ledmask;
static TX_THREAD net_wifi_thread;
static int thread_start = 0;
static VOID net_wifi_internal_thread (ULONG initial_input);
static uint8_t wifi_internal_thread_stack[INT_STACK_LEN];
VOID net_wifi_internal_thread (ULONG initial_input) {
SSP_PARAMETER_NOT_USED( initial_input );
int i = 0;
ioport_level_t lvl;
while(1) {
tx_thread_sleep ( CONV_MS_TO_TICK(10) );
while (m2m_wifi_handle_events(NULL) != M2M_SUCCESS) { }
if ( ( i++ % 100 ) == 0 && !is_blue_led_hold() ) {
g_ioport.p_api->pinRead(IOPORT_PORT_06_PIN_00, &lvl);
if (lvl==IOPORT_LEVEL_LOW) g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00 ,IOPORT_LEVEL_HIGH);
else g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00 ,IOPORT_LEVEL_LOW);
}
}
}
UINT wifi_internal_run() {
if ( ! thread_start ) {
thread_start = 1;
return tx_thread_create(&net_wifi_thread,
(CHAR*)"wifi_internal_thread",
net_wifi_internal_thread,
(ULONG) NULL,
wifi_internal_thread_stack, INT_STACK_LEN,
3, 3, 1,
TX_AUTO_START);
}
return TX_SUCCESS;
}
void wifi_internal_stop() {
tx_thread_terminate(&net_wifi_thread);
}
| 31.736842 | 106 | 0.6733 |
a1c4421bab4c39aa27d12c454905b7b551b40e49 | 3,289 | h | C | Source/WebCore/css/CSSToStyleMap.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | 6 | 2021-07-05T16:09:39.000Z | 2022-03-06T22:44:42.000Z | Source/WebCore/css/CSSToStyleMap.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | 7 | 2022-03-15T13:25:39.000Z | 2022-03-15T13:25:44.000Z | Source/WebCore/css/CSSToStyleMap.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include "CSSPropertyNames.h"
#include <wtf/FastMalloc.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
class Animation;
class CSSValue;
class FillLayer;
class LengthBox;
class NinePieceImage;
class RenderStyle;
class StyleImage;
namespace Style {
class BuilderState;
}
class CSSToStyleMap {
WTF_MAKE_NONCOPYABLE(CSSToStyleMap);
WTF_MAKE_FAST_ALLOCATED;
public:
CSSToStyleMap(Style::BuilderState&);
void mapFillAttachment(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillClip(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillComposite(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillBlendMode(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillOrigin(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillImage(CSSPropertyID, FillLayer&, CSSValue&);
void mapFillRepeatX(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillRepeatY(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillSize(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillXPosition(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillYPosition(CSSPropertyID, FillLayer&, const CSSValue&);
void mapFillMaskSourceType(CSSPropertyID, FillLayer&, const CSSValue&);
void mapAnimationDelay(Animation&, const CSSValue&);
void mapAnimationDirection(Animation&, const CSSValue&);
void mapAnimationDuration(Animation&, const CSSValue&);
void mapAnimationFillMode(Animation&, const CSSValue&);
void mapAnimationIterationCount(Animation&, const CSSValue&);
void mapAnimationName(Animation&, const CSSValue&);
void mapAnimationPlayState(Animation&, const CSSValue&);
void mapAnimationProperty(Animation&, const CSSValue&);
void mapAnimationTimingFunction(Animation&, const CSSValue&);
void mapNinePieceImage(CSSPropertyID, CSSValue*, NinePieceImage&);
void mapNinePieceImageSlice(CSSValue&, NinePieceImage&);
LengthBox mapNinePieceImageQuad(CSSValue&);
void mapNinePieceImageRepeat(CSSValue&, NinePieceImage&);
private:
RenderStyle* style() const;
bool useSVGZoomRules() const;
RefPtr<StyleImage> styleImage(CSSValue&);
// FIXME: This type can merge into BuilderState.
Style::BuilderState& m_builderState;
};
} // namespace WebCore
| 37.804598 | 101 | 0.757069 |
1f4d8dedd0b959ff7cf3cb11f3e8652b9d17db30 | 923 | h | C | Source/Drivers/Depth3D/DirectShow/ext/DCamDrv.h | BEIWG/OpenNI2 | 3d144e98884dd78703a3e145856dded166f87e60 | [
"Apache-2.0"
] | null | null | null | Source/Drivers/Depth3D/DirectShow/ext/DCamDrv.h | BEIWG/OpenNI2 | 3d144e98884dd78703a3e145856dded166f87e60 | [
"Apache-2.0"
] | 2 | 2018-04-16T10:51:56.000Z | 2018-04-24T06:35:09.000Z | Source/Drivers/Depth3D/uvc/DCamDrv.h | BEIWG/OpenNI2 | 3d144e98884dd78703a3e145856dded166f87e60 | [
"Apache-2.0"
] | null | null | null | #ifndef DCAM_DRV_H /* prevent circular inclusions */
#define DCAM_DRV_H /* by using protection macros */
#include <stdint.h>
void DCAM_DRV_Init(void *devh);
uint8_t SME_CMD_Config(uint16_t cmd,uint32_t value);
uint8_t SME_Video_En(uint32_t value);
uint8_t SME_IIC2SPI_En(uint32_t value);
uint8_t SME_Projection_Set(uint32_t value);
uint8_t SME_DispDepth_En(uint32_t value);
uint8_t SME_Depth_Sel(uint32_t value);
uint8_t SME_InPhase_Set(uint32_t value);
uint8_t FlashWPSet(uint8_t WP);
uint8_t FlashRead(uint32_t flashaddr, uint8_t *buf, uint16_t len);
uint8_t FlashWrite(uint32_t flashaddr, uint8_t *buf, uint16_t len);
uint8_t FlashErase(uint8_t mode, uint32_t flashaddr);
void WriteREFBin(uint32_t ref_baseaddr, const char * reffilename);
void depth_lut2flash(double reg_list[][3], double depth_ref, int mindis, uint32_t flashaddr);
double calc_n(double minidis, double depth_ref, double reg_list[][3]);
#endif | 36.92 | 93 | 0.8039 |
944256daec2ed17f593045666f2fae7e3da6b1f3 | 6,473 | c | C | src/compute/common/cl/assert_cl.c | pospx/external_skia | 7a135275c9fc2a4b3cbdcf9a96e7102724752234 | [
"BSD-3-Clause"
] | 6 | 2018-10-20T10:53:55.000Z | 2021-12-25T07:58:57.000Z | src/compute/common/cl/assert_cl.c | pospx/external_skia | 7a135275c9fc2a4b3cbdcf9a96e7102724752234 | [
"BSD-3-Clause"
] | 3 | 2020-04-26T17:03:31.000Z | 2020-04-28T14:55:33.000Z | src/compute/common/cl/assert_cl.c | pospx/external_skia | 7a135275c9fc2a4b3cbdcf9a96e7102724752234 | [
"BSD-3-Clause"
] | 57 | 2016-12-29T02:00:25.000Z | 2021-11-16T01:22:50.000Z | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
*/
//
//
//
#include <stdlib.h>
#include <stdio.h>
//
//
//
#include "assert_cl.h"
//
//
//
#define CL_VAL_TO_STRING(err) case err: return #err
//
//
//
#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000
//
//
//
char const *
cl_get_error_string(cl_int const err)
{
switch (err)
{
CL_VAL_TO_STRING(CL_SUCCESS);
CL_VAL_TO_STRING(CL_DEVICE_NOT_FOUND);
CL_VAL_TO_STRING(CL_DEVICE_NOT_AVAILABLE);
CL_VAL_TO_STRING(CL_COMPILER_NOT_AVAILABLE);
CL_VAL_TO_STRING(CL_MEM_OBJECT_ALLOCATION_FAILURE);
CL_VAL_TO_STRING(CL_OUT_OF_RESOURCES);
CL_VAL_TO_STRING(CL_OUT_OF_HOST_MEMORY);
CL_VAL_TO_STRING(CL_PROFILING_INFO_NOT_AVAILABLE);
CL_VAL_TO_STRING(CL_MEM_COPY_OVERLAP);
CL_VAL_TO_STRING(CL_IMAGE_FORMAT_MISMATCH);
CL_VAL_TO_STRING(CL_IMAGE_FORMAT_NOT_SUPPORTED);
CL_VAL_TO_STRING(CL_BUILD_PROGRAM_FAILURE);
CL_VAL_TO_STRING(CL_MAP_FAILURE);
CL_VAL_TO_STRING(CL_MISALIGNED_SUB_BUFFER_OFFSET);
CL_VAL_TO_STRING(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST);
CL_VAL_TO_STRING(CL_COMPILE_PROGRAM_FAILURE);
CL_VAL_TO_STRING(CL_LINKER_NOT_AVAILABLE);
CL_VAL_TO_STRING(CL_LINK_PROGRAM_FAILURE);
CL_VAL_TO_STRING(CL_DEVICE_PARTITION_FAILED);
CL_VAL_TO_STRING(CL_KERNEL_ARG_INFO_NOT_AVAILABLE);
CL_VAL_TO_STRING(CL_INVALID_VALUE);
CL_VAL_TO_STRING(CL_INVALID_DEVICE_TYPE);
CL_VAL_TO_STRING(CL_INVALID_PLATFORM);
CL_VAL_TO_STRING(CL_INVALID_DEVICE);
CL_VAL_TO_STRING(CL_INVALID_CONTEXT);
CL_VAL_TO_STRING(CL_INVALID_QUEUE_PROPERTIES);
CL_VAL_TO_STRING(CL_INVALID_COMMAND_QUEUE);
CL_VAL_TO_STRING(CL_INVALID_HOST_PTR);
CL_VAL_TO_STRING(CL_INVALID_MEM_OBJECT);
CL_VAL_TO_STRING(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
CL_VAL_TO_STRING(CL_INVALID_IMAGE_SIZE);
CL_VAL_TO_STRING(CL_INVALID_SAMPLER);
CL_VAL_TO_STRING(CL_INVALID_BINARY);
CL_VAL_TO_STRING(CL_INVALID_BUILD_OPTIONS);
CL_VAL_TO_STRING(CL_INVALID_PROGRAM);
CL_VAL_TO_STRING(CL_INVALID_PROGRAM_EXECUTABLE);
CL_VAL_TO_STRING(CL_INVALID_KERNEL_NAME);
CL_VAL_TO_STRING(CL_INVALID_KERNEL_DEFINITION);
CL_VAL_TO_STRING(CL_INVALID_KERNEL);
CL_VAL_TO_STRING(CL_INVALID_ARG_INDEX);
CL_VAL_TO_STRING(CL_INVALID_ARG_VALUE);
CL_VAL_TO_STRING(CL_INVALID_ARG_SIZE);
CL_VAL_TO_STRING(CL_INVALID_KERNEL_ARGS);
CL_VAL_TO_STRING(CL_INVALID_WORK_DIMENSION);
CL_VAL_TO_STRING(CL_INVALID_WORK_GROUP_SIZE);
CL_VAL_TO_STRING(CL_INVALID_WORK_ITEM_SIZE);
CL_VAL_TO_STRING(CL_INVALID_GLOBAL_OFFSET);
CL_VAL_TO_STRING(CL_INVALID_EVENT_WAIT_LIST);
CL_VAL_TO_STRING(CL_INVALID_EVENT);
CL_VAL_TO_STRING(CL_INVALID_OPERATION);
CL_VAL_TO_STRING(CL_INVALID_GL_OBJECT);
CL_VAL_TO_STRING(CL_INVALID_BUFFER_SIZE);
CL_VAL_TO_STRING(CL_INVALID_MIP_LEVEL);
CL_VAL_TO_STRING(CL_INVALID_GLOBAL_WORK_SIZE);
CL_VAL_TO_STRING(CL_INVALID_PROPERTY);
CL_VAL_TO_STRING(CL_INVALID_IMAGE_DESCRIPTOR);
CL_VAL_TO_STRING(CL_INVALID_COMPILER_OPTIONS);
CL_VAL_TO_STRING(CL_INVALID_LINKER_OPTIONS);
CL_VAL_TO_STRING(CL_INVALID_DEVICE_PARTITION_COUNT);
// CL_VAL_TO_STRING(CL_INVALID_PIPE_SIZE);
// CL_VAL_TO_STRING(CL_INVALID_DEVICE_QUEUE);
//
// Extensions:
//
// cl_khr_gl_sharing
//
CL_VAL_TO_STRING(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR);
//
//
//
default:
return "UNKNOWN ERROR CODE";
}
}
//
//
//
cl_int
assert_cl(cl_int const code, char const * const file, int const line, bool const abort)
{
if (code != CL_SUCCESS)
{
char const * const cl_err_str = cl_get_error_string(code);
fprintf(stderr,
"\"%s\", line %d: assert_cl( %d ) = \"%s\"",
file,line,code,cl_err_str);
if (abort)
{
// stop profiling and reset device here if necessary
exit(code);
}
}
return code;
}
//
//
//
void
cl_get_event_info(cl_event event,
cl_int * const status,
cl_command_type * const type)
{
if (status != NULL) {
cl(GetEventInfo(event,
CL_EVENT_COMMAND_EXECUTION_STATUS,
sizeof(*status),
status,
NULL));
}
if (type != NULL) {
cl(GetEventInfo(event,
CL_EVENT_COMMAND_TYPE,
sizeof(*type),
type,
NULL));
}
}
char const *
cl_get_event_command_status_string(cl_int const status)
{
switch (status)
{
CL_VAL_TO_STRING(CL_QUEUED);
CL_VAL_TO_STRING(CL_SUBMITTED);
CL_VAL_TO_STRING(CL_RUNNING);
CL_VAL_TO_STRING(CL_COMPLETE);
default:
return "UNKNOWN COMMAND STATUS";
}
}
char const *
cl_get_event_command_type_string(cl_command_type const type)
{
switch (type)
{
CL_VAL_TO_STRING(CL_COMMAND_NDRANGE_KERNEL);
CL_VAL_TO_STRING(CL_COMMAND_TASK);
CL_VAL_TO_STRING(CL_COMMAND_NATIVE_KERNEL);
CL_VAL_TO_STRING(CL_COMMAND_READ_BUFFER);
CL_VAL_TO_STRING(CL_COMMAND_WRITE_BUFFER);
CL_VAL_TO_STRING(CL_COMMAND_COPY_BUFFER);
CL_VAL_TO_STRING(CL_COMMAND_READ_IMAGE);
CL_VAL_TO_STRING(CL_COMMAND_WRITE_IMAGE);
CL_VAL_TO_STRING(CL_COMMAND_COPY_IMAGE);
CL_VAL_TO_STRING(CL_COMMAND_COPY_BUFFER_TO_IMAGE);
CL_VAL_TO_STRING(CL_COMMAND_COPY_IMAGE_TO_BUFFER);
CL_VAL_TO_STRING(CL_COMMAND_MAP_BUFFER);
CL_VAL_TO_STRING(CL_COMMAND_MAP_IMAGE);
CL_VAL_TO_STRING(CL_COMMAND_UNMAP_MEM_OBJECT);
CL_VAL_TO_STRING(CL_COMMAND_MARKER);
CL_VAL_TO_STRING(CL_COMMAND_ACQUIRE_GL_OBJECTS);
CL_VAL_TO_STRING(CL_COMMAND_RELEASE_GL_OBJECTS);
CL_VAL_TO_STRING(CL_COMMAND_READ_BUFFER_RECT);
CL_VAL_TO_STRING(CL_COMMAND_WRITE_BUFFER_RECT);
CL_VAL_TO_STRING(CL_COMMAND_COPY_BUFFER_RECT);
CL_VAL_TO_STRING(CL_COMMAND_USER);
CL_VAL_TO_STRING(CL_COMMAND_BARRIER);
CL_VAL_TO_STRING(CL_COMMAND_MIGRATE_MEM_OBJECTS);
CL_VAL_TO_STRING(CL_COMMAND_FILL_BUFFER);
CL_VAL_TO_STRING(CL_COMMAND_FILL_IMAGE);
CL_VAL_TO_STRING(CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR);
default:
return "UNKNOWN EVENT COMMAND TYPE";
}
}
| 29.026906 | 87 | 0.714815 |
2045059f37766f1a0ded7f9e74ddef983573498f | 2,265 | c | C | src/gba_irq.c | bkacjios/libgba-english | cb563acd70309e7ecd3ae34cbf0eb0cbeaaf8fd3 | [
"BSD-3-Clause"
] | null | null | null | src/gba_irq.c | bkacjios/libgba-english | cb563acd70309e7ecd3ae34cbf0eb0cbeaaf8fd3 | [
"BSD-3-Clause"
] | null | null | null | src/gba_irq.c | bkacjios/libgba-english | cb563acd70309e7ecd3ae34cbf0eb0cbeaaf8fd3 | [
"BSD-3-Clause"
] | null | null | null | /*
libgba interrupt support routines
Copyright 2003-2004 by Dave Murphy.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
Please report all bugs and problems through the bug tracker at
"http://sourceforge.net/tracker/?group_id=114505&atid=668551".
*/
#include "gba_irq.h"
#include "gba_video.h"
struct gba_irq_handler_table gba_irq_table[IRQ_MAX];
void gba_irq_dummy(void) {};
void gba_irq_init() {
int i;
// Set all interrupts to dummy functions.
for(i = 0; i < IRQ_MAX; i ++)
{
gba_irq_table[i].handler = gba_irq_dummy;
gba_irq_table[i].mask = 0;
}
IRQ_HANDLER = gba_irq_main;
}
gba_irq_handler* gba_irq_set(short mask, gba_irq_handler function) {
int i;
for (i=0;;i++) {
if (!gba_irq_table[i].mask || gba_irq_table[i].mask == mask) break;
}
if ( i >= IRQ_MAX) return NULL;
gba_irq_table[i].handler = function;
gba_irq_table[i].mask = mask;
return &gba_irq_table[i].handler;
}
void gba_irq_enable(short mask) {
gba_irq_regs.IME = IRQ_DISABLE;
if (mask & IRQ_VBLANK) gba_video_regs.DISPSTAT |= VIDEO_VBLANK_INT;
if (mask & IRQ_HBLANK) gba_video_regs.DISPSTAT |= VIDEO_HBLANK_INT;
if (mask & IRQ_VCOUNT) gba_video_regs.DISPSTAT |= VIDEO_VCOUNTER_INT;
gba_irq_regs.IE |= mask;
gba_irq_regs.IME = IRQ_ENABLE;
}
void gba_irq_disable(short mask) {
gba_irq_regs.IME = IRQ_DISABLE;
if (mask & IRQ_VBLANK) gba_video_regs.DISPSTAT &= ~VIDEO_VBLANK_INT;
if (mask & IRQ_HBLANK) gba_video_regs.DISPSTAT &= ~VIDEO_HBLANK_INT;
if (mask & IRQ_VCOUNT) gba_video_regs.DISPSTAT &= ~VIDEO_VCOUNTER_INT;
gba_irq_regs.IE &= ~mask;
gba_irq_regs.IME = IRQ_ENABLE;
} | 27.289157 | 71 | 0.748344 |
541ae45440a258322a3d98cfecb76e99b0bc4cb5 | 7,308 | c | C | thread.c | VicerExciser/Xv6Chat | 9cc577d17e7582128f17f135f2dd225e13f3a448 | [
"MIT-0"
] | null | null | null | thread.c | VicerExciser/Xv6Chat | 9cc577d17e7582128f17f135f2dd225e13f3a448 | [
"MIT-0"
] | null | null | null | thread.c | VicerExciser/Xv6Chat | 9cc577d17e7582128f17f135f2dd225e13f3a448 | [
"MIT-0"
] | null | null | null | #include "lwip/xv6/arch/sys_arch.h"
// #include "types.h"
#include "defs.h"
// #include "thread.h"
#include "param.h"
#include "mmu.h"
#include "proc.h"
#include "defs.h"
#ifndef MAXTHREADS
#define MAXTHREADS 16
#endif
extern struct proc* allocproc_wrapper(void);
extern struct proc* ptable_find_proc(char *tofind);
extern void procdump(void);
extern struct proc *initproc;
extern struct ptable_t ptable;
void thread_wrap(void (* thread)(void *arg), void *arg);
static int kptable_insert(kproc_t thread);
static kproc_t kptable_remove(int kpti);
static kproc_t kptable_find_thr(char *tofind);
static bool kptableinit = false; //0;
static struct {
struct spinlock lock;
kproc_t threads[MAXTHREADS];
int size;
} kptable;
void
kptable_dump(void)
{
acquire(&kptable.lock);
static char *states[] = {
[UNUSED] "unused",
[EMBRYO] "embryo",
[SLEEPING] "sleep ",
[RUNNABLE] "runble",
[RUNNING] "run ",
[ZOMBIE] "zombie",
[MSLEEPING] "msleep"
};
int i;
cprintf("\n____________________ KPROC TABLE (size: %d) ____________________\n\n", kptable.size);
for (i = 0; i < MAXTHREADS; i++) {
if (kptable.threads[i]) {
kproc_t t = kptable.threads[i];
cprintf("[%d] '%s': proc=%p\n\tpid=%d state=%s sz=%u killed=%d parent='%s' \n\tthr=%p timeouts=%p tsem=%p chan=%p\n",
t->kptidx,
t->p->name,
t->p,
t->p->pid,
states[t->p->state],
t->p->sz,
t->p->killed,
(t->p->parent ? t->p->parent->name : "0"),
t->p->thr,
t->timeouts,
t->tsem,
t->p->chan
);
}
}
cprintf("_______________________________________________________________\n\n");
release(&kptable.lock);
}
// #define USE_FORK // for creating a child process for a new thread
kproc_t
kproc_start(void (* runfunc)(void *arg), void *arg, int prio, void *data, char *name)
{
// #ifdef KPROC_SEM_EXPERIMENTAL
if (!kptableinit) {
memset(&kptable, 0, sizeof(kptable));
initlock(&kptable.lock, "kptable");
kptableinit = true; //1;
// cprintf("THREAD::kptable INITIALIZED\n");
}
// #endif
kproc_t thr;
struct proc *np;
// int thr_exists = 0;
// if (name) {
// thr = kptable_find_thr(name);
// if (thr) {
// while(thr->p->state == SLEEPING || thr->p->state == MSLEEPING ) {
// // cprintf("kproc_start waking up sleeping thread '%s'\n", name);
// wakeup(thr->p->chan);
// // wakeup(initproc);
// sys_sem_signal(thr->tsem);
// }
// // procdump();
// // kptable_dump();
// // assert(thr->p->state != SLEEPING);
// // assert(thr->p->state != MSLEEPING);
// // return thr;
// thr_exists = 1;
// np = thr->p;
// }
// }
// if (!thr_exists)
// {
thr = (kproc_t)kalloc();
if (!thr)
return NULL;
thr->p = allocproc_wrapper();
np = thr->p;
if (!np)
return NULL;
// np->pgdir = setupkvm();
np->pgdir = setupuserkvm();
// }
np->thr = thr;
np->parent = initproc;
// np->parent = ptable_find_proc("sh");
np->sz = 0;
np->chan = 0;
np->killed = 0;
// memset(np->context, 0, sizeof(np->context));
memset(np->context, 0, sizeof(*np->context));
thr->data = data;
thr->timeouts.next = 0;
thr->tsem = 0;
if (name == 0)
safestrcpy(np->name, "kernel thread", sizeof(np->name));
else
safestrcpy(np->name, name, sizeof(np->name));
// }
char *sp;
sp = np->kstack + KSTACKSIZE - 1;
sp -= sizeof np->tf;
np->tf = (struct trapframe*) sp;
sp -= 4;
*(uint*)sp = (uint) exit;
sp -= 4;
*(uint*)sp = (uint) runfunc;
sp -= 4;
*(uint*)sp = (uint) arg;
sp -= sizeof *np->context;
np->context = (struct context*) sp;
(np->context)->eip = (uint)thread_wrap;
np->cwd = namei("/");
np->state = RUNNABLE;
if (!kptable_find_thr(np->name)){
acquire(&kptable.lock);
thr->kptidx = kptable_insert(thr);
release(&kptable.lock);
}
return thr;
}
/* Insert new thread at the first available index and return that index */
static int
kptable_insert(kproc_t thread)
{
if (kptable.size == MAXTHREADS) {
cprintf("[kptable_insert] ERROR: kproc table is full, could not insert new thread!\n");
return -1;
}
int i;
for (i = 0; i < MAXTHREADS; i++) {
if (!kptable.threads[i]) {
kptable.threads[i] = thread;
kptable.size++;
return i;
}
}
return -1;
}
/* Remove thread from the specified index and return that thread to kill */
static kproc_t
kptable_remove(int kpti)
{
assert(kpti < MAXTHREADS);
assert(kpti >= 0);
if (kptable.size == 0) {
cprintf("[kptable_remove] ERROR: kproc table is empty, could not remove thread!\n");
return NULL; // (kproc_t)0;
}
kproc_t deadthread = kptable.threads[kpti];
if (!deadthread) {
cprintf("[kptable_remove] ERROR: kproc table has no thread to remove at index %d!\n", kpti);
} else {
assert(deadthread->kptidx == kpti);
kptable.threads[kpti] = NULL;
kptable.size--;
deadthread->kptidx = -1;
}
return deadthread;
}
void
kproc_free(kproc_t thread)
{
// cprintf("kproc_free called\n");
struct proc *p = thread->p;
#ifdef KPROC_SEM_EXPERIMENTAL
kproc_signal(p->name);
sys_sem_free(thread->tsem);
p->state = ZOMBIE;
#endif
acquire(&kptable.lock);
assert(kptable_remove(thread->kptidx) == thread);
release(&kptable.lock);
memset(thread, 0, sizeof(struct thread));
kfree((char*)thread);
p->thr = 0;
p->state = UNUSED;
}
void
thread_wrap(void (* runfunc)(void *arg), void *arg)
{
// cprintf("thread beginning to serve its purpose:\n");
release(&ptable.lock);
runfunc(arg);
exit();
}
static kproc_t
kptable_find_thr(char *tofind)
{
int i, n = strlen(tofind);
acquire(&kptable.lock);
for (i = 0; i < MAXTHREADS; i++) {
if (kptable.threads[i]) {
int ni = strlen(kptable.threads[i]->p->name);
if (ni == n && !strncmp(kptable.threads[i]->p->name, tofind, n)) {
release(&kptable.lock);
return kptable.threads[i];
}
}
}
release(&kptable.lock);
// cprintf("[kptable_find_thr] ERROR: thread '%s' not found in kptable!\n");
return NULL;
}
void
kproc_signal(char *thrname)
{
kproc_t thread;// = kptable_find_thr(thrname);
// assert(thread != NULL);
while ((thread = kptable_find_thr(thrname))) {
if (thread->tsem && thread->tsem->waiters) {
// cprintf("[kproc_signal] posting sem wakeup signal for '%s'\n", thrname);
// sem_post(thread->tsem);
sys_sem_signal(thread->tsem);
}
}
}
| 26.1 | 139 | 0.539819 |
91939e3e5193d070fa81ad81a8f3dc9cb5c9841d | 4,801 | c | C | main.c | rjuppa/pattern_search | 3267232fc4283479566d13d5b1c3b872ec02456c | [
"MIT"
] | null | null | null | main.c | rjuppa/pattern_search | 3267232fc4283479566d13d5b1c3b872ec02456c | [
"MIT"
] | null | null | null | main.c | rjuppa/pattern_search | 3267232fc4283479566d13d5b1c3b872ec02456c | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <limits.h>
#include <time.h>
char *text;
long text_len = 0;
int file_exists(const char *filename) {
struct stat buffer;
int exist = stat(filename, &buffer);
if (exist == 0)
return 1;
else
return 0;
}
char *read_file(const char *filename) {
char *buffer = NULL;
long read_size;
FILE *handler = fopen(filename, "r");
if (handler) {
fseek(handler, 0, SEEK_END);
text_len = ftell(handler);
rewind(handler);
// allocate a string
buffer = (char *) malloc(sizeof(char) * (text_len + 1));
if (buffer == NULL) {
printf("Out of memory");
return NULL;
}
// read it all in one
read_size = fread(buffer, sizeof(char), (size_t) text_len, handler);
buffer[text_len] = '\0';
if (text_len != read_size) {
// Something went wrong
free(buffer);
buffer = NULL;
}
fclose(handler);
}
return buffer;
}
int bf_search(char *pattern, int i) {
// Brute-Force
int j;
int index = -1;
size_t pattern_len = strlen(pattern);
clock_t startTime = clock();
long end = text_len - pattern_len;
while (i < end) {
j = 0;
while ((j < pattern_len) && (text[i + j] == pattern[j])) {
j++;
}
if (j == pattern_len) {
index = i;
break;
}
i++;
}
if (index < 0) {
printf("Pattern not found.");
}
clock_t endTime = clock();
double duration = (endTime - startTime);
printf("BF Search found '%s' at position: %d elapsed time: %f [ms]\n", pattern, index, duration);
return index;
}
void get_fail_table(char *pattern, int *fail) {
size_t pattern_len = strlen(pattern);
int i = 1;
int j = 0;
fail[0] = 0;
while (i < pattern_len) {
if (pattern[i] == pattern[j]) {
fail[i] = j + 1;
i++;
j++;
} else if (j > 0) {
j = fail[j - 1];
} else {
fail[i] = 0;
i++;
}
}
}
int kmp_search(char *pattern, int i) {
// Knuth–Morris–Pratt
int j = 0;
int index = -1;
size_t pattern_len = strlen(pattern);
int *fail;
fail = (int *) malloc(sizeof(int) * pattern_len);
get_fail_table(pattern, fail);
clock_t startTime = clock();
while (i < text_len) {
while (j < pattern_len && text[i] == pattern[j]) {
j++;
i++;
}
if (j == pattern_len) {
index = i - (int) pattern_len;
break;
}
if (j > 0) {
j = fail[j - 1];
} else {
i++;
}
}
if (index < 0) {
printf("Pattern not found.");
}
clock_t endTime = clock();
double duration = (endTime - startTime);
printf("KMP Search found '%s' at position: %d elapsed time: %f [ms]\n", pattern, index, duration);
free(fail);
return index;
}
int max(int a, int b) { return (a > b) ? a : b; }
void get_last(char *str, int size, int badchar[256]) {
int i;
for (i = 0; i < 256; i++)
badchar[i] = -1;
for (i = 0; i < size; i++)
badchar[(int) str[i]] = i;
}
int bm_search(char *pattern, int i) {
int index = -1;
int j = 0;
int pattern_len = (int) strlen(pattern);
long end = text_len - pattern_len;
int badchar[256];
get_last(pattern, pattern_len, badchar);
clock_t startTime = clock();
int s = 0;
while (s <= end) {
j = pattern_len - 1;
while (j >= 0 && pattern[j] == text[s + j]) {
j--;
}
if (j < 0) {
index = s;
break;
} else {
s += max(1, j - badchar[text[s + j]]);
}
}
if (index < 0) {
printf("Pattern not found.");
}
clock_t endTime = clock();
double duration = (endTime - startTime);
printf("BM Search found '%s' at position: %d elapsed time: %f [ms]\n", pattern, index, duration);
return index;
}
int main() {
char resolved_path[PATH_MAX];
char *filename = "../big.txt";
realpath(filename, resolved_path);
int exist = file_exists(resolved_path);
if (exist) {
printf("File %s exist", resolved_path);
text = read_file(resolved_path);
printf("'\n");
kmp_search("tradeMark1", 0);
bf_search("tradeMark1", 0);
kmp_search("tradeMark1", 0);
bm_search("tradeMark1", 0);
bf_search("tradeMark1", 0);
bm_search("tradeMark1", 0);
free(text);
} else {
printf("File %s does not exist", resolved_path);
}
return 0;
} | 22.753555 | 103 | 0.50302 |
8cd6fc3176a2094c5352bb805bc0dcdc626a6976 | 2,095 | c | C | src/make/bibutils_6.10/lib/bibutils.c | Proximify/bibutils | b5a99706cc5903e4bdf949c47772b34fad6cf940 | [
"MIT"
] | null | null | null | src/make/bibutils_6.10/lib/bibutils.c | Proximify/bibutils | b5a99706cc5903e4bdf949c47772b34fad6cf940 | [
"MIT"
] | null | null | null | src/make/bibutils_6.10/lib/bibutils.c | Proximify/bibutils | b5a99706cc5903e4bdf949c47772b34fad6cf940 | [
"MIT"
] | null | null | null | /*
* bibutils.c
*
* Copyright (c) Chris Putnam 2005-2020
*
* Source code released under the GPL version 2
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "bibutils.h"
#include "bibformats.h"
int
bibl_initparams( param *p, int readmode, int writemode, char *progname )
{
int status;
switch ( readmode ) {
case BIBL_BIBTEXIN: status = bibtexin_initparams ( p, progname ); break;
case BIBL_BIBLATEXIN: status = biblatexin_initparams( p, progname ); break;
case BIBL_COPACIN: status = copacin_initparams ( p, progname ); break;
case BIBL_EBIIN: status = ebiin_initparams ( p, progname ); break;
case BIBL_ENDNOTEIN: status = endin_initparams ( p, progname ); break;
case BIBL_ENDNOTEXMLIN: status = endxmlin_initparams ( p, progname ); break;
case BIBL_MEDLINEIN: status = medin_initparams ( p, progname ); break;
case BIBL_MODSIN: status = modsin_initparams ( p, progname ); break;
case BIBL_NBIBIN: status = nbibin_initparams ( p, progname ); break;
case BIBL_RISIN: status = risin_initparams ( p, progname ); break;
case BIBL_WORDIN: status = wordin_initparams ( p, progname ); break;
default: status = BIBL_ERR_BADINPUT;
}
if ( status!=BIBL_OK ) return status;
switch ( writemode ) {
case BIBL_ADSABSOUT: status = adsout_initparams ( p, progname ); break;
case BIBL_BIBTEXOUT: status = bibtexout_initparams ( p, progname ); break;
case BIBL_BIBLATEXOUT: status = biblatexout_initparams( p, progname ); break;
case BIBL_ENDNOTEOUT: status = endout_initparams ( p, progname ); break;
case BIBL_ISIOUT: status = isiout_initparams ( p, progname ); break;
case BIBL_MODSOUT: status = modsout_initparams ( p, progname ); break;
case BIBL_NBIBOUT: status = nbibout_initparams ( p, progname ); break;
case BIBL_RISOUT: status = risout_initparams ( p, progname ); break;
case BIBL_WORD2007OUT: status = wordout_initparams ( p, progname ); break;
default: status = BIBL_ERR_BADINPUT;
}
return status;
}
| 41.078431 | 78 | 0.681146 |
7b3870e3d566dcbeb634f3d5fe886e035595290f | 4,733 | h | C | emu-ex-plus-alpha/imagine/src/base/common/funcs.h | damoonvisuals/GBA4iOS | 95bfce0aca270b68484535ecaf0d3b2366739c77 | [
"MIT"
] | 1 | 2018-11-14T23:40:35.000Z | 2018-11-14T23:40:35.000Z | emu-ex-plus-alpha/imagine/src/base/common/funcs.h | damoonvisuals/GBA4iOS | 95bfce0aca270b68484535ecaf0d3b2366739c77 | [
"MIT"
] | null | null | null | emu-ex-plus-alpha/imagine/src/base/common/funcs.h | damoonvisuals/GBA4iOS | 95bfce0aca270b68484535ecaf0d3b2366739c77 | [
"MIT"
] | null | null | null | #pragma once
#include <mem/interface.h>
#ifdef CONFIG_FS
#include <fs/Fs.hh>
#endif
#ifdef CONFIG_INPUT
#include <input/Input.hh>
#endif
#ifdef CONFIG_GFX
#include <gfx/Gfx.hh>
#endif
#ifdef CONFIG_AUDIO
#include <audio/Audio.hh>
#endif
#if defined CONFIG_BLUETOOTH
#include <bluetooth/sys.hh>
#endif
#if defined(__unix__) || defined(__APPLE__)
#include <unistd.h>
#include <sys/resource.h>
#endif
extern bool isGBAROM;
namespace Base
{
static bool triggerGfxResize = 0;
static Window mainWin, currWin;
bool gfxUpdate = 0;
static void generic_displayNeedsUpdate()
{
//logMsg("posting display update");
gfxUpdate = 1;
}
const Window &window()
{
return mainWin;
}
#ifdef CONFIG_GFX
static int generic_resizeEvent(const Window &win, bool force = 0)
{
// do gfx_resizeDisplay only if the window-size changed
if(force || currWin != win)
{
logMsg("resizing display area %d:%d:%d:%d -> %d:%d:%d:%d",
currWin.rect.x, currWin.rect.y, currWin.rect.x2, currWin.rect.y2,
win.rect.x, win.rect.y, win.rect.x2, win.rect.y2);
currWin = win;
triggerGfxResize = 1;
gfxUpdate = 1;
return 1;
}
return 0;
}
#endif
const char copyright[] = "Imagine is Copyright 2010-2013 Robert Broglia";
static void engineInit() ATTRS(cold);
static void engineInit()
{
#if defined __unix__ || defined CONFIG_BASE_MACOSX
struct rlimit stack;
getrlimit(RLIMIT_STACK, &stack);
stack.rlim_cur = 16 * 1024 * 1024;
assert(stack.rlim_cur <= stack.rlim_max);
setrlimit(RLIMIT_STACK, &stack);
#ifndef NDEBUG
getrlimit(RLIMIT_STACK, &stack);
logMsg("stack limit %u:%u", (uint)stack.rlim_cur, (uint)stack.rlim_max);
#endif
#endif
logDMsg("%s", copyright);
logDMsg("compiled on %s %s", __DATE__, __TIME__);
mem_init();
#ifdef CONFIG_GFX
currWin = mainWin;
doOrExit(Gfx::setOutputVideoMode(mainWin));
#endif
#ifdef CONFIG_AUDIO
doOrExit(Audio::init());
#endif
if (isGBAROM)
{
doOrExit(onWindowInit_GBA());
}
else
{
doOrExit(onWindowInit_GBC());
}
}
static uint runEngine(Gfx::FrameTimeBase frameTime)
{
#ifdef CONFIG_GFX
if(unlikely(triggerGfxResize))
{
Gfx::resizeDisplay(currWin);
triggerGfxResize = 0;
}
#endif
int frameRendered = 0;
#ifdef CONFIG_GFX
if(likely(gfxUpdate))
{
gfxUpdate = 0;
Gfx::renderFrame(frameTime);
frameRendered = 1;
//logMsg("rendered frame");
}
else
{
//logDMsg("skipped render");
}
#endif
return frameRendered;
}
// needed by GCC when not compiling with libstdc++/libsupc++, or to override it
CLINK void __cxa_pure_virtual() { bug_exit("called pure virtual"); }
#if defined(__unix__) || defined(__APPLE__)
void sleepUs(int us)
{
usleep(us);
}
void sleepMs(int ms)
{
sleepUs(ms*1000);
}
#endif
static void processAppMsg(int type, int shortArg, int intArg, int intArg2)
{
switch(type)
{
#if defined CONFIG_BLUETOOTH_BLUEZ || defined CONFIG_BLUETOOTH_ANDROID
bcase MSG_BT_SCAN_STATUS_DELEGATE:
{
logMsg("got bluetooth adapter status delegate message");
auto bta = BluetoothAdapter::defaultAdapter();
bta->onScanStatus()(*bta, intArg, intArg2);
}
#endif
bdefault:
{
if(type >= MSG_USER)
{
logMsg("got app message %d", type);
if (isGBAROM)
{
Base::onAppMessage_GBA(type, shortArg, intArg, intArg2);
}
else
{
Base::onAppMessage_GBC(type, shortArg, intArg, intArg2);
}
}
}
}
}
}
static int getPollTimeout()
{
// When waiting for events:
// 1. If rendering, don't block
// 2. Else block until next event
int pollTimeout = Base::gfxUpdate ? 0 :
-1;
/*if(pollTimeout == -1)
logMsg("will poll for next event");*/
return pollTimeout;
}
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
#define CONFIG_BASE_NO_CUSTOM_NEW_DELETE
#endif
#endif
#ifndef CONFIG_BASE_NO_CUSTOM_NEW_DELETE
void* operator new (std::size_t size)
#ifdef __EXCEPTIONS
throw (std::bad_alloc)
#endif
{ return mem_alloc(size); }
void* operator new[] (std::size_t size)
#ifdef __EXCEPTIONS
throw (std::bad_alloc)
#endif
{ return mem_alloc(size); }
#ifdef CONFIG_BASE_PS3
void *operator new(_CSTD size_t size, _CSTD size_t align)
_THROW1(_XSTD bad_alloc)
{
//logMsg("called aligned new, size %d @ %d byte boundary", (int)size, (int)align);
return memalign(size, align);
}
#endif
void operator delete (void *o) noexcept { mem_free(o); }
void operator delete[] (void *o) noexcept { mem_free(o); }
#endif
#ifdef __EXCEPTIONS
namespace __gnu_cxx
{
EVISIBLE void __verbose_terminate_handler()
{
logErr("terminated by uncaught exception");
abort();
}
}
#endif
| 19.239837 | 83 | 0.674836 |
4cc5efbdff515dbd59ec671b207fbb4f263e4898 | 867 | h | C | src/status.h | EvanKuhn/webserver | 79ee063ac1f50cc9665ac6d46b8dfe0bcdd5d72d | [
"MIT"
] | 5 | 2015-04-10T11:02:58.000Z | 2018-03-18T05:13:37.000Z | src/status.h | EvanKuhn/webserver | 79ee063ac1f50cc9665ac6d46b8dfe0bcdd5d72d | [
"MIT"
] | null | null | null | src/status.h | EvanKuhn/webserver | 79ee063ac1f50cc9665ac6d46b8dfe0bcdd5d72d | [
"MIT"
] | 2 | 2015-08-18T14:10:26.000Z | 2016-08-08T04:04:01.000Z | //==============================================================================
// Simple status struct that contains a status flag and associated error number.
// The error number is meant to store 'errno' values, but can be used for any
// error values.
//
// Evan Kuhn, 2012-09-09
//==============================================================================
#ifndef STATUS_H
#define STATUS_H
#include <stdbool.h>
typedef struct Status {
bool ok; // Bool indicating success or failure
int errnum; // Error number indicating type of failure. Often set to errno.
} Status;
// Create a new Status object with 'ok' and 'errnum' values as specified
Status make_status(bool ok, int errnum);
// Create a new Status object
// - If 'ok' is true, set 'errnum' to 0
// - If 'ok' is false, set 'errnum' to errno
Status get_status(bool ok);
#endif // STATUS_H | 33.346154 | 80 | 0.580161 |
0b0b9c10b397e44407d8ea6193583e184ded6184 | 5,750 | h | C | sys/vax/include/vmparam.h | weiss/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 114 | 2015-01-18T22:55:52.000Z | 2022-02-17T10:45:02.000Z | sys/vax/include/vmparam.h | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | null | null | null | sys/vax/include/vmparam.h | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 29 | 2015-11-03T22:05:22.000Z | 2022-02-08T15:36:37.000Z | /*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
*
* %sccs.include.proprietary.c%
*
* @(#)vmparam.h 7.4 (Berkeley) 05/08/91
*/
/*
* Machine dependent constants for VAX
*/
/*
* USRTEXT is the start of the user text/data space, while USRSTACK
* is the top (end) of the user stack. LOWPAGES and HIGHPAGES are
* the number of pages from the beginning of the P0 region to the
* beginning of the text and from the beginning of the P1 region to the
* beginning of the stack respectively.
*/
#define USRTEXT 0
#define USRSTACK (0x80000000-UPAGES*NBPG) /* Start of user stack */
#define BTOPUSRSTACK (0x400000 - UPAGES) /* btop(USRSTACK) */
/* number of ptes per page */
#define P1PAGES 0x200000 /* number of pages in P1 region */
#define LOWPAGES 0
#define HIGHPAGES UPAGES
/*
* Virtual memory related constants, all in bytes
*/
#ifndef MAXTSIZ
#define MAXTSIZ (6*1024*1024) /* max text size */
#endif
#ifndef DFLDSIZ
#define DFLDSIZ (6*1024*1024) /* initial data size limit */
#endif
#ifndef MAXDSIZ
#define MAXDSIZ (16*1024*1024) /* max data size */
#endif
#ifndef DFLSSIZ
#define DFLSSIZ (512*1024) /* initial stack size limit */
#endif
#ifndef MAXSSIZ
#define MAXSSIZ MAXDSIZ /* max stack size */
#endif
/*
* Default sizes of swap allocation chunks (see dmap.h).
* The actual values may be changed in vminit() based on MAXDSIZ.
* With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
* DMMIN should be at least ctod(1) so that vtod() works.
* vminit() ensures this.
*/
#define DMMIN 32 /* smallest swap allocation */
#define DMMAX 4096 /* largest potential swap allocation */
#define DMTEXT 1024 /* swap allocation for text */
/*
* Sizes of the system and user portions of the system page table.
*/
/* SYSPTSIZE IS SILLY; IT SHOULD BE COMPUTED AT BOOT TIME */
#define SYSPTSIZE ((20+MAXUSERS)*NPTEPG)
#define USRPTSIZE (32*NPTEPG)
/*
* PTEs for system V compatible shared memory.
* This is basically slop for kmempt which we actually allocate (malloc) from.
*/
#define SHMMAXPGS 1024
/*
* Boundary at which to place first MAPMEM segment if not explicitly
* specified. Should be a power of two. This allows some slop for
* the data segment to grow underneath the first mapped segment.
*/
#define MMSEG 0x200000
/*
* The size of the clock loop.
*/
#define LOOPPAGES (maxfree - firstfree)
/*
* The time for a process to be blocked before being very swappable.
* This is a number of seconds which the system takes as being a non-trivial
* amount of real time. You probably shouldn't change this;
* it is used in subtle ways (fractions and multiples of it are, that is, like
* half of a ``long time'', almost a long time, etc.)
* It is related to human patience and other factors which don't really
* change over time.
*/
#define MAXSLP 20
/*
* A swapped in process is given a small amount of core without being bothered
* by the page replacement algorithm. Basically this says that if you are
* swapped in you deserve some resources. We protect the last SAFERSS
* pages against paging and will just swap you out rather than paging you.
* Note that each process has at least UPAGES+CLSIZE pages which are not
* paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
* number just means a swapped in process is given around 25k bytes.
* Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
* so we loan each swapped in process memory worth 100$, or just admit
* that we don't consider it worthwhile and swap it out to disk which costs
* $30/mb or about $0.75.
*/
#define SAFERSS 32 /* nominal ``small'' resident set size
protected against replacement */
/*
* DISKRPM is used to estimate the number of paging i/o operations
* which one can expect from a single disk controller.
*/
#define DISKRPM 60
/*
* Klustering constants. Klustering is the gathering
* of pages together for pagein/pageout, while clustering
* is the treatment of hardware page size as though it were
* larger than it really is.
*
* KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
* units. Note that ctod(KLMAX*CLSIZE) must be <= DMMIN in dmap.h.
* ctob(KLMAX) should also be less than MAXPHYS (in vm_swp.c) to
* avoid "big push" panics.
*/
#define KLMAX (32/CLSIZE)
#define KLSEQL (16/CLSIZE) /* in klust if vadvise(VA_SEQL) */
#define KLIN (8/CLSIZE) /* default data/stack in klust */
#define KLTXT (4/CLSIZE) /* default text in klust */
#define KLOUT (32/CLSIZE)
/*
* KLSDIST is the advance or retard of the fifo reclaim for sequential
* processes data space.
*/
#define KLSDIST 3 /* klusters advance/retard for seq. fifo */
/*
* Paging thresholds (see vm_sched.c).
* Strategy of 1/19/85:
* lotsfree is 512k bytes, but at most 1/4 of memory
* desfree is 200k bytes, but at most 1/8 of memory
* minfree is 64k bytes, but at most 1/2 of desfree
*/
#define LOTSFREE (512 * 1024)
#define LOTSFREEFRACT 4
#define DESFREE (200 * 1024)
#define DESFREEFRACT 8
#define MINFREE (64 * 1024)
#define MINFREEFRACT 2
/*
* There are two clock hands, initially separated by HANDSPREAD bytes
* (but at most all of user memory). The amount of time to reclaim
* a page once the pageout process examines it increases with this
* distance and decreases as the scan rate rises.
*/
#define HANDSPREAD (2 * 1024 * 1024)
/*
* The number of times per second to recompute the desired paging rate
* and poke the pagedaemon.
*/
#define RATETOSCHEDPAGING 4
/*
* Believed threshold (in megabytes) for which interleaved
* swapping area is desirable.
*/
#define LOTSOFMEM 2
#define mapin(pte, v, pfnum, prot) \
(*(int *)(pte) = (pfnum) | (prot), mtpr(TBIS, v))
| 32.670455 | 78 | 0.714435 |
219d2b9153138d217dbf1b2428d911896cf907c6 | 1,397 | h | C | def_lang/include/def_lang/ep/Value_Template_EP.h | jeanleflambeur/silkopter | cdbc67ee2c85f5c95eb4f52e2e0ba24514962dd8 | [
"BSD-3-Clause"
] | 36 | 2015-03-09T16:47:14.000Z | 2021-02-04T08:32:04.000Z | def_lang/include/def_lang/ep/Value_Template_EP.h | jeanlemotan/silkopter | cdbc67ee2c85f5c95eb4f52e2e0ba24514962dd8 | [
"BSD-3-Clause"
] | 42 | 2017-02-11T11:15:51.000Z | 2019-12-28T16:00:44.000Z | def_lang/include/def_lang/ep/Value_Template_EP.h | jeanleflambeur/silkopter | cdbc67ee2c85f5c95eb4f52e2e0ba24514962dd8 | [
"BSD-3-Clause"
] | 5 | 2015-10-15T05:46:48.000Z | 2020-05-11T17:40:36.000Z | #pragma once
#include <memory>
#include "def_lang/IValue.h"
#include "def_lang/IInitializer.h"
namespace ts
{
template<typename Traits>
class Value_Template_EP : public virtual Traits::value_interface
{
public:
typedef typename Traits::value_interface value_interface;
typedef typename Traits::type_interface type_interface;
typedef typename Traits::fundamental_type fundamental_type;
Value_Template_EP(std::shared_ptr<type_interface const> type);
Result<bool> is_equal(IValue const& other) const override;
Result<void> copy_construct(IValue const& other) override;
Result<void> copy_assign(IValue const& other) override;
//std::shared_ptr<IValue> clone() const override;
std::shared_ptr<IType const> get_type() const override;
std::shared_ptr<const IValue> select(Value_Selector&& selector) const override;
std::shared_ptr<IValue> select(Value_Selector&& selector) override;
std::shared_ptr<type_interface const> get_specialized_type() const override;
Result<void> set_value(fundamental_type value) override;
fundamental_type get_value() const override;
protected:
bool is_constructed() const override;
void set_constructed(bool constructed);
private:
bool m_is_constructed = false;
std::shared_ptr<type_interface const> m_type;
fundamental_type m_value;
};
}
#include "def_lang/ep/Value_Template_EP.inl"
| 27.94 | 83 | 0.765927 |
56b5667308952d0f33d620371045235db4a605b1 | 297 | h | C | Utils.h | livyang/TwitterDemo | 8c62d756e3feeb5bea7237fad4c845c9a014c84c | [
"Apache-2.0"
] | null | null | null | Utils.h | livyang/TwitterDemo | 8c62d756e3feeb5bea7237fad4c845c9a014c84c | [
"Apache-2.0"
] | null | null | null | Utils.h | livyang/TwitterDemo | 8c62d756e3feeb5bea7237fad4c845c9a014c84c | [
"Apache-2.0"
] | null | null | null | //
// Utils.h
// TwitterDemo
//
// Created by Li Yang on 2/2/17.
// Copyright © 2017 Li Yang. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "User.h"
@interface Utils : NSObject
+ (void)cacheCurrentUser:(NSDictionary *) userDict;
+ (User *) getCachedCurrentUser;
@end
| 15.631579 | 51 | 0.676768 |
56f05a975de8446a1015c6d1938cae48e46594eb | 4,973 | c | C | elauncherApp/src/elauncher.c | huyong1979/elauncher | 21dede81246bab11b7ab430d408e6d24f4e82830 | [
"BSD-3-Clause"
] | 1 | 2021-12-07T19:13:56.000Z | 2021-12-07T19:13:56.000Z | elauncherApp/src/elauncher.c | huyong1979/elauncher | 21dede81246bab11b7ab430d408e6d24f4e82830 | [
"BSD-3-Clause"
] | null | null | null | elauncherApp/src/elauncher.c | huyong1979/elauncher | 21dede81246bab11b7ab430d408e6d24f4e82830 | [
"BSD-3-Clause"
] | 1 | 2021-10-15T14:52:33.000Z | 2021-10-15T14:52:33.000Z |
#include <stdlib.h>
#include <string.h>
#include <epicsString.h>
#include <epicsAssert.h>
#include <cantProceed.h>
#include <epicsThread.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <callback.h>
#include <epicsExit.h>
#include <errlog.h>
#include <dbStaticLib.h>
#include <alarm.h>
#include <dbEvent.h>
#include <dbAccess.h>
#include <recSup.h>
#include <devSup.h>
#include <alarm.h>
#include <boRecord.h>
#include <recGbl.h>
int launcherVerbose = 0;
typedef struct {
epicsMutexId lock;
epicsThreadId thread;
epicsEventId start;
boRecord *prec;
unsigned int running:1;
unsigned int done:1;
char *cmd;
int ret;
} work;
static void worker(void*);
static void cleanup(void*);
static long init_record(boRecord* prec)
{
return 2;
}
static long add_record(dbCommon* pcom)
{
DBENTRY entry;
boRecord *prec=(boRecord*)pcom;
work *priv=prec->dpvt;
if(!priv) {
priv=mallocMustSucceed(sizeof(*priv), "elauncher malloc");
prec->dpvt = priv;
priv->lock = epicsMutexMustCreate();
priv->start = epicsEventMustCreate(epicsEventEmpty);
priv->prec = prec;
priv->cmd = NULL;
priv->ret = -1;
priv->running = 0;
priv->done = 0;
priv->thread = epicsThreadMustCreate("launcher",
epicsThreadPriorityMedium,
epicsThreadGetStackSize(epicsThreadStackSmall),
&worker, priv);
epicsAtExit(&cleanup, priv);
}
assert(prec->out.type == INST_IO);
dbInitEntry(pdbbase, &entry);
dbFindRecord(&entry, prec->name); /* can't fail */
if(dbFindInfo(&entry, "cmd")==0) {
priv->cmd = epicsStrDup(dbGetInfoString(&entry));
} else {
priv->cmd = epicsStrDup(prec->out.value.instio.string);
}
if(launcherVerbose || !priv->cmd || strlen(priv->cmd)==0)
errlogPrintf("%s: cmd '%s'\n", prec->name, priv->cmd);
assert(priv->cmd);
dbFinishEntry(&entry);
return 0;
}
static long del_record(dbCommon* pcom)
{
boRecord *prec=(boRecord*)pcom;
work *priv=prec->dpvt;
if(!priv)
return -1;
assert(prec->out.type == INST_IO);
if(priv->running)
return -1;
free(priv->cmd);
priv->cmd = NULL;
return 0;
}
static long write(boRecord* prec)
{
work *priv=prec->dpvt;
if(!priv || !priv->cmd)
return -1;
prec->udf = 0;
if(!prec->pact) {
/* ensure 1-> 0 transition on completion */
prec->mlst = prec->val;
prec->val = 1;
db_post_events(prec, &prec->val, DBE_VALUE|DBE_LOG);
priv->running = 1;
epicsEventSignal(priv->start);
prec->pact = TRUE;
if(launcherVerbose)
errlogPrintf("%s: start\n", prec->name);
return 0;
} else {
prec->pact = FALSE;
if(WIFSIGNALED(priv->ret)) {
recGblSetSevr(prec, WRITE_ALARM, INVALID_ALARM);
} else if(WEXITSTATUS(priv->ret)) {
recGblSetSevr(prec, WRITE_ALARM, MAJOR_ALARM);
}
prec->mlst = prec->val;
prec->val = 0;
if(launcherVerbose)
errlogPrintf("%s: done\n", prec->name);
}
return 0;
}
static void worker(void *raw)
{
work *priv=raw;
while(1) {
char *cmd;
int ret;
epicsEventMustWait(priv->start);
if(priv->done) {
priv->done = 0;
return;
}
dbScanLock((dbCommon*)priv->prec);
if(launcherVerbose)
errlogPrintf("%s: run\n", priv->prec->name);
cmd = epicsStrDup(priv->cmd);
dbScanUnlock((dbCommon*)priv->prec);
ret = system(cmd);
dbScanLock((dbCommon*)priv->prec);
if(launcherVerbose)
errlogPrintf("%s: complete\n", priv->prec->name);
if(WIFSIGNALED(priv->ret)) {
unsigned int d=WTERMSIG(ret);
errlogPrintf("%s: command terminated with signal %u\n '%s'\n",
priv->prec->name, d, cmd);
}
free(cmd);
priv->ret = ret;
priv->running = 0;
(*priv->prec->rset->process)(priv->prec);
dbScanUnlock((dbCommon*)priv->prec);
}
}
static void cleanup(void *raw)
{
work *priv=raw;
priv->done = 1;
while(priv->done)
epicsEventSignal(priv->start);
if(launcherVerbose)
errlogPrintf("%s: worker stopped\n", priv->prec->name);
}
static
dsxt extLauncher =
{
&add_record, &del_record
};
static long init(int pass)
{
if(pass==0)
devExtend(&extLauncher);
return 0;
}
static
struct {
dset com;
DEVSUPFUN write;
} devLauncher =
{
{5, NULL,
(DEVSUPFUN) &init,
(DEVSUPFUN) &init_record,
NULL
},
(DEVSUPFUN) &write
};
#include <epicsExport.h>
epicsExportAddress(dset, devLauncher);
epicsExportAddress(int, launcherVerbose);
| 20.052419 | 92 | 0.56847 |
1fba1ff8fd3f95394845d3eeabdcf98f81497e1b | 317 | c | C | moon_code/sync/test/md5.c | xdc427/moon_in_water | cf8404868306fa311c00f6885654601af0e21761 | [
"MIT"
] | null | null | null | moon_code/sync/test/md5.c | xdc427/moon_in_water | cf8404868306fa311c00f6885654601af0e21761 | [
"MIT"
] | null | null | null | moon_code/sync/test/md5.c | xdc427/moon_in_water | cf8404868306fa311c00f6885654601af0e21761 | [
"MIT"
] | null | null | null | #include<openssl/md5.h>
#include<stdio.h>
#include<string.h>
void main( int argc, char * argv[] )
{
unsigned char md5_sun[ 16 ];
int i;
if( argc < 2 ){
return;
}
MD5( argv[ 1 ], strlen( argv[ 1 ] ), md5_sun );
for( i = 0; i < sizeof( md5_sun ); i++ ){
printf( "%02x", md5_sun[ i ]);
}
printf( "\n" );
}
| 16.684211 | 48 | 0.555205 |
4e6a70d65f553d80f4a58f56d0958da19f98ee15 | 425 | c | C | 001_EXAMPLES/007_Enum/Enum/Enum.c | JooHyeon-Roh/C | 705dfe312446780dbd7f6e6c65670497f665ee9c | [
"MIT"
] | null | null | null | 001_EXAMPLES/007_Enum/Enum/Enum.c | JooHyeon-Roh/C | 705dfe312446780dbd7f6e6c65670497f665ee9c | [
"MIT"
] | null | null | null | 001_EXAMPLES/007_Enum/Enum/Enum.c | JooHyeon-Roh/C | 705dfe312446780dbd7f6e6c65670497f665ee9c | [
"MIT"
] | null | null | null | #include <stdio.h>
enum WEEK
{
MON,
TUE,
WED,
THUR,
FRI,
SAT,
SUN
};
enum WEEK2
{
MON2 = 1,
TUE2,
WED2,
THUR2,
FRI2,
SAT2,
SUN2
};
enum _WEEK3
{
MON3 = 10,
TUE3,
WED3,
THUR3,
FRI3,
SAT3,
SUN3
}WEEK3;
int main(void)
{
enum WEEK today;
today = FRI;
printf("%d\n\n", today);
enum WEEK2 today2;
today2 = FRI2;
printf("%d\n\n", today2);
WEEK3 = FRI3;
printf("%d\n\n", WEEK3);
return 0;
} | 7.727273 | 26 | 0.574118 |
4ec35e14c5f0eddf0467e3da08f56c39c3e99ae4 | 1,266 | c | C | cmds/avatar/_buffmob.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 9 | 2021-07-05T15:24:54.000Z | 2022-02-25T19:44:15.000Z | cmds/avatar/_buffmob.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | cmds/avatar/_buffmob.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 10 | 2021-03-13T00:18:03.000Z | 2022-03-29T15:02:42.000Z | #include <std.h>
inherit DAEMON;
int help(){
write(
"
%^CYAN%^NAME%^RESET%^
buffmob - converts a mob to a champion version with increased stats and damage
%^CYAN%^SYNTAX%^RESET%^
buffmob %^ORANGE%^%^ULINE%^MOB%^RESET%^
%^CYAN%^DESCRIPTION%^RESET%^
Convert %^ORANGE%^%^ULINE%^MOB%^RESET%^ to be a champion version of itself with increased stats and damage.
%^CYAN%^SEE ALSO%^RESET%^
"
);
return 1;
}
int cmd_buffmob(string str){
string who;
object mob;
string posxxx;
if(!objectp(TP)) return 0;
posxxx = lower_case((string)TP->query_position());
if(posxxx == "builder" || posxxx == "apprentice") {
tell_object(TP,"You cannot use this command as a builder or apprentice.");
return 1;
}
if (!str) return help();
if (sscanf(str, "%s", who) != 1) return help();
mob = present(who,ETP);
if(!objectp(mob)) return notify_fail("That isn't here.\n");
if(interactive(mob)) return notify_fail("This command does not work on players or personas.\n");
write("%^BOLD%^You apply a serious buff to "+capitalize(who)+"\n");
tell_room(ETP,"%^BOLD%^%^RED%^" + mob->QCN + " flexes and strikes a serious pose!%^RESET%^");
"/daemon/champion_d"->create_champion(mob,1);
return 1;
}
| 23.018182 | 107 | 0.633491 |
8e3507308f5b1fceaa84dde323f511ea11e1cab0 | 878 | h | C | libs/libkrt/include/sys/cdefs.h | zhiayang/nx | 0d9da881f67ec351244abd72e1f3884816b48f5b | [
"Apache-2.0"
] | 16 | 2019-03-14T19:45:02.000Z | 2022-02-06T19:18:08.000Z | libs/libkrt/include/sys/cdefs.h | zhiayang/nx | 0d9da881f67ec351244abd72e1f3884816b48f5b | [
"Apache-2.0"
] | 1 | 2020-05-08T08:40:02.000Z | 2020-05-08T13:27:59.000Z | libs/libkrt/include/sys/cdefs.h | zhiayang/nx | 0d9da881f67ec351244abd72e1f3884816b48f5b | [
"Apache-2.0"
] | 2 | 2021-01-16T20:42:05.000Z | 2021-12-01T23:37:18.000Z | // cdefs.h
// Copyright (c) 2014 - 2016, zhiayang
// Licensed under the Apache License Version 2.0.
/* Preprocessor trick to turn anything into a string. */
#define __STRINGIFY(x) #x
/* Issue warning when this is used, except in defines, where the warning is
inserted whenever the macro is expanded. This can be used to deprecated
macros - and it happens on preprocessor level - so it shouldn't change any
semantics of any code that uses such a macro. The argument msg should be a
string that contains the warning. */
#define __PRAGMA_WARNING(msg) _Pragma(__STRINGIFY(GCC warning msg))
/* C++ needs to know that types and declarations are C, not C++. */
#ifdef __cplusplus
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif
#define restrict __restrict
#define __pure2 __attribute__((__const__))
| 32.518519 | 77 | 0.747153 |
e2ebbe808fb53ef35bc05c2b739b191fa1a5279e | 5,297 | c | C | src/device.c | binp-cnc/rpi-cnc | f4f302b7c439948bc93b8b0c10cbef1880ecfb4d | [
"MIT"
] | null | null | null | src/device.c | binp-cnc/rpi-cnc | f4f302b7c439948bc93b8b0c10cbef1880ecfb4d | [
"MIT"
] | null | null | null | src/device.c | binp-cnc/rpi-cnc | f4f302b7c439948bc93b8b0c10cbef1880ecfb4d | [
"MIT"
] | null | null | null | #include <device.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <signal.h>
#include <pigpio.h>
#include <generator.h>
#include <command.h>
#include <axis.h>
ringbuffer_define(RBC, rbc, Cmd)
int dev_init(Device *dev, int axis_count) {
dev->axis_count = axis_count;
return 0;
}
int dev_free(Device *dev) {
return 0;
}
typedef struct {
uint32_t in;
uint32_t out;
uint32_t count;
} _SyncMapEntry;
typedef struct {
Device *dev;
Generator *gen;
Cmd (*get_cmd)(int, void*);
void *userdata;
gpioPulse_t *pulses;
int pulse_count;
int reuse_pulses;
int reuse_count;
_SyncMapEntry sync_map[SYNC_MAP_SIZE];
} _DevRunCookie;
static void _dev_run_alert(int gpio, int level, uint32_t tick, void *userdata) {
_DevRunCookie *cookie = (_DevRunCookie*) userdata;
Device *dev = cookie->dev;
Generator *gen = cookie->gen;
int i;
for (i = 0; i < dev->axis_count; ++i) {
if(dev->axes[i].pin_left == gpio && level) {
printf("axis %d left\n", i);
gen_stop(gen);
} else if(dev->axes[i].pin_right == gpio && level) {
printf("axis %d right\n", i);
gen_stop(gen);
}
}
}
typedef struct {
int axis;
Cmd (*get_cmd)(int, void*);
void *userdata;
} _AxisGetCmdCookie;
static Cmd _dev_axis_get_cmd(void *userdata) {
_AxisGetCmdCookie *cookie = (_AxisGetCmdCookie*) userdata;
Cmd cmd = cookie->get_cmd(cookie->axis, cookie->userdata);
//printf("axis %d cmd %d\n", cookie->axis, cmd.type);
return cmd;
}
static int _dev_run_get_wave(void *userdata) {
_DevRunCookie *cookie = (_DevRunCookie*) userdata;
Device *dev = cookie->dev;
gpioPulse_t *pulses = cookie->pulses;
int pulse_count = cookie->pulse_count;
_AxisGetCmdCookie axis_cookie;
axis_cookie.get_cmd = cookie->get_cmd;
axis_cookie.userdata = cookie->userdata;
int i, ax;
if (!cookie->reuse_pulses) {
int total = 0;
for (i = 0; i < pulse_count - 2; ++i) {
int nax = -1, remain = 0;
for (ax = 0; ax < dev->axis_count; ++ax) {
_AxisState *axst = &dev->axes[ax].state;
if (axst->idle) {
if (axst->cmd.type == CMD_SYNC) {
_SyncMapEntry *sme = &cookie->sync_map[axst->cmd.sync.id % SYNC_MAP_SIZE];
//printf("[sme] in: %d, out: %d, count %d\n", sme->in, sme->out, sme->count);
//printf("[sync] id: %d, count %d\n", axst->cmd.sync.id, axst->cmd.sync.count);
if (!axst->done) {
if (sme->count == 0) {
sme->count = axst->cmd.sync.count;
}
sme->in += 1;
axst->done = 1;
}
if (sme->in >= sme->count) {
sme->out += 1;
if (sme->out >= sme->count) {
sme->count = 0;
sme->in = 0;
sme->out = 0;
}
nax = ax;
remain = 0;
}
}
} else {
if (nax < 0 || axst->remain < remain) {
nax = ax;
remain = axst->remain;
}
}
}
if (nax < 0) {
break;
}
// printf("nax: %d, remain: %d, steps: %d\n", nax, remain, dev->axes[nax].state.steps);
if (remain > 0) {
total += remain;
for (ax = 0; ax < dev->axis_count; ++ax) {
dev->axes[ax].state.remain -= remain;
}
pulses[i].usDelay = remain;
pulses[i].gpioOn = 0;
pulses[i].gpioOff = 0;
} else {
axis_cookie.axis = nax;
PinAction pa = axis_step(&dev->axes[nax], _dev_axis_get_cmd, (void*) &axis_cookie);
pulses[i].gpioOn = pa.on;
pulses[i].gpioOff = pa.off;
pulses[i].usDelay = 0;
}
// printf("pulse: on: %d, off: %d, delay: %d\n", pulses[i].gpioOn, pulses[i].gpioOff, pulses[i].usDelay);
}
pulse_count = i + 2;
//printf("total: %d\n", total);
//printf("pulses: %d\n", pulse_count);
// dummy last pulses (never executed)
for (i = pulse_count - 2; i < pulse_count; ++i) {
pulses[i].usDelay = 1;
pulses[i].gpioOn = 0;
pulses[i].gpioOff = 0;
}
} else {
pulse_count = cookie->reuse_count;
}
if (pulse_count <= 2) {
return -1;
}
gpioWaveAddNew();
gpioWaveAddGeneric(pulse_count, pulses);
int wave = gpioWaveCreate();
if (wave < 0) {
cookie->reuse_pulses = 1;
cookie->reuse_count = pulse_count;
} else {
cookie->reuse_pulses = 0;
}
//printf("wid: %d\n", wave);
return wave;
}
int dev_run(Device *dev, Generator *gen, Cmd (*get_cmd)(int axis, void *userdata), void *userdata) {
int i;
_DevRunCookie cookie;
cookie.dev = dev;
cookie.gen = gen;
cookie.get_cmd = get_cmd;
cookie.userdata = userdata;
cookie.pulse_count = 0x100;
cookie.pulses = (gpioPulse_t*) malloc(sizeof(gpioPulse_t)*cookie.pulse_count);
cookie.reuse_pulses = 0;
cookie.reuse_count = 0;
for (i = 0; i < SYNC_MAP_SIZE; ++i) {
cookie.sync_map[i].in = 0;
cookie.sync_map[i].out = 0;
cookie.sync_map[i].count = 0;
}
for (i = 0; i < dev->axis_count; ++i) {
if (dev->axes[i].sense) {
gpioSetAlertFuncEx(dev->axes[i].pin_left, _dev_run_alert, (void*) &cookie);
gpioSetAlertFuncEx(dev->axes[i].pin_right, _dev_run_alert, (void*) &cookie);
}
}
gen_run(gen, _dev_run_get_wave, (void*) &cookie);
for (i = 0; i < dev->axis_count; ++i) {
if (dev->axes[i].sense) {
gpioSetAlertFuncEx(dev->axes[i].pin_left, NULL, NULL);
gpioSetAlertFuncEx(dev->axes[i].pin_right, NULL, NULL);
}
}
free(cookie.pulses);
return 0;
}
int dev_clear(Device *dev) {
int i;
for (i = 0; i < dev->axis_count; ++i) {
_axis_state_init(&dev->axes[i].state);
}
return 0;
}
| 23.334802 | 108 | 0.614121 |
2257cae8829142117b0f193f526b5ed07e093260 | 4,737 | h | C | src/tools/tools/0027.Stat/CSVTopNPrinter.h | OpenCMISS-Dependencies/cube | bb425e6f75ee5dbdf665fa94b241b48deee11505 | [
"Cube"
] | null | null | null | src/tools/tools/0027.Stat/CSVTopNPrinter.h | OpenCMISS-Dependencies/cube | bb425e6f75ee5dbdf665fa94b241b48deee11505 | [
"Cube"
] | null | null | null | src/tools/tools/0027.Stat/CSVTopNPrinter.h | OpenCMISS-Dependencies/cube | bb425e6f75ee5dbdf665fa94b241b48deee11505 | [
"Cube"
] | 2 | 2016-09-19T00:16:05.000Z | 2021-03-29T22:06:45.000Z | /****************************************************************************
** CUBE http://www.scalasca.org/ **
*****************************************************************************
** Copyright (c) 1998-2016 **
** Forschungszentrum Juelich GmbH, Juelich Supercomputing Centre **
** **
** Copyright (c) 2009-2015 **
** German Research School for Simulation Sciences GmbH, **
** Laboratory for Parallel Programming **
** **
** This software may be modified and distributed under the terms of **
** a BSD-style license. See the COPYING file in the package base **
** directory for details. **
****************************************************************************/
#ifndef __CUBE_STAT_CSV_TOPN_PRINTER_H
#define __CUBE_STAT_CSV_TOPN_PRINTER_H
#include <vector>
#include "AggrCube.h"
#include "CubeMetric.h"
#include "CubeCnode.h"
#include "TopNPrinter.h"
/*-------------------------------------------------------------------------*/
/**
* @class CSVTopNPrinter
* @brief Class for printing topN flat profile data as a comma seperated
* value file
*/
/*-------------------------------------------------------------------------*/
class CSVTopNPrinter : public TopNPrinter
{
public:
// / @name Constructor & destructor
// / @{
CSVTopNPrinter( cube::AggrCube* cubeObj,
std::vector<std::string> const& metNames );
virtual
~CSVTopNPrinter()
{
}
// / @}
// / @name Print methods used by clients
// / @{
virtual void
PrintLegend() const;
virtual void
Print( int n ) const;
// / @}
private:
cube::AggrCube* cubeObject;
};
/**
* Creates a new CSVTopNPrinter instance from the given CUBE object and
* the names of the requested metrics and cnodes.
*
* @param cubeObj The CUBE object used to parse the CUBE file to be analyzed.
* @param metNames A std::vector containing all metric names for which data is
* to be gathered and printed.
*/
CSVTopNPrinter::CSVTopNPrinter( cube::AggrCube* cubeObj,
std::vector<std::string> const& metNames )
: TopNPrinter( cubeObj, metNames ), cubeObject( cubeObj )
{
}
/**
* Prints the legend for topN flat profile as a line of a comma seperated
* value file
*/
void
CSVTopNPrinter::PrintLegend() const
{
std::vector<cube::Metric*> const& _requestedMetricVec = GetRequestedMetrics();
int num_metrics = _requestedMetricVec.size();
const int inclTimeMetricID = 2;
std::cout << "cube::Region,Number of Calls,Exclusive Time,Inclusive Time";
for ( int m = inclTimeMetricID + 1; m < num_metrics; ++m )
{
std::cout << ',' << _requestedMetricVec[ m ]->get_uniq_name();
}
std::cout << std::endl;
}
/**
* Prints the values for the @p n top regions as a topN flat profile
* as a line of a comma seperated value file
*
* @param n Number of regions to print
*/
void
CSVTopNPrinter::Print( int n ) const
{
std::vector<cube::Metric*> const& _requestedMetricVec = GetRequestedMetrics();
std::vector<cube::Region*> const& regionsVec = cubeObject->get_regv();
int num_metrics = values.size();
int num_regions = regionsVec.size();
const int visitsMetricID = 0;
for ( int r = 0; r < num_regions && r < n; ++r )
{
int rr = indexVec[ r ];
if ( values[ visitsMetricID ][ rr ] == 0 )
{
// abort loop when functions got never called
break;
}
std::cout << "\"" << regionsVec[ rr ]->get_name() << "\"";
for ( int m = 0; m < num_metrics; ++m )
{
std::vector<double> const& curr_met_values = values[ m ];
std::cout << ',';
if ( _requestedMetricVec[ m ]->get_dtype() == "INTEGER" )
{
std::cout << std::fixed << std::noshowpoint << std::setprecision( 0 );
}
std::cout << curr_met_values[ rr ];
std::cout.setf( std::ios_base::fmtflags( 0 ), std::ios_base::floatfield );
std::cout << std::showpoint << std::setprecision( 6 );
}
std::cout << std::endl;
}
}
#endif
| 34.326087 | 87 | 0.483428 |
61be83d3f7a12d756a55a2851093a858b43e0a2f | 804 | h | C | src/dynf32.h | tedajax/runner | 0b6d23627922228cc7d5f82747b99aa5deff2ca3 | [
"MIT"
] | 1 | 2016-04-17T22:08:19.000Z | 2016-04-17T22:08:19.000Z | src/dynf32.h | tedajax/runner | 0b6d23627922228cc7d5f82747b99aa5deff2ca3 | [
"MIT"
] | null | null | null | src/dynf32.h | tedajax/runner | 0b6d23627922228cc7d5f82747b99aa5deff2ca3 | [
"MIT"
] | null | null | null | #ifndef RUNNER_DYNF32_H
#define RUNNER_DYNF32_H
#include "types.h"
#include "inline.h"
#include "ini.h"
// forward declarations
typedef struct tween_t Tween;
typedef struct tween_config_t TweenConfig;
typedef struct tween_manager_t TweenManager;
typedef enum dynamic_f32_type_e {
DYN_F32_VALUE,
DYN_F32_TWEEN,
} DynamicFloatType;
typedef struct dynamic_f32_t {
f32 value;
DynamicFloatType type;
Tween* tween;
TweenConfig* tweenConfig;
} dynf32;
void dynf32_zero(dynf32* self);
void dynf32_release(dynf32* self);
void dynf32_start_tween(dynf32* self, TweenManager* tweenManager);
void dynf32_restart(dynf32* self, TweenManager* tweenManager);
void dynf32_copy(const dynf32* source, dynf32* dest);
f32 dynf32_get(dynf32* self);
bool dynf32_set(dynf32* self, f32 value);
#endif | 24.363636 | 66 | 0.781095 |
254ac585910d4ca10e88cb8e7b82d8e48f95ac29 | 7,779 | c | C | apps/fota/ota/json_utils.c | cryingheart/t2_dlna | ce30bea1664d32e56a82e9e1ac74cf561d652992 | [
"Apache-2.0"
] | null | null | null | apps/fota/ota/json_utils.c | cryingheart/t2_dlna | ce30bea1664d32e56a82e9e1ac74cf561d652992 | [
"Apache-2.0"
] | null | null | null | apps/fota/ota/json_utils.c | cryingheart/t2_dlna | ce30bea1664d32e56a82e9e1ac74cf561d652992 | [
"Apache-2.0"
] | null | null | null | /**
******************************************************************************
* @file json_utils.c
*
* @brief json utility functions
*
******************************************************************************
* @attention
*
*
* Copyright (c) 2021, InnoPhase, Inc.
*
* 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.
*
******************************************************************************
*/
#include <assert.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <kernel/os.h>
#include <kernel/bitops.h>
#include "json_utils.h"
/* flags returned by tokenizer functions */
#define AGAIN 0
#define CONSUMED BIT(31)
static inline bool isjsonspace(int ch)
{
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
}
static inline void addc(struct big_json_parser *parser, int ch)
{
if(parser->endp < &parser->token[sizeof(parser->token)-1])
*parser->endp++ = ch;
}
/* string state flags */
#define STRING_ESCAPE BIT(0)
static unsigned int
big_json_token_string(struct big_json_parser *parser, int ch)
{
if(ch == EOF) {
*parser->endp = '\0';
return JSON_STRING;
}
if(parser->state & STRING_ESCAPE) {
parser->state &= ~STRING_ESCAPE;
if(ch == '\\') {
addc(parser, ch);
return JSON_NONE|CONSUMED;
}
if(ch == 'b') {
addc(parser, '\b');
return JSON_NONE|CONSUMED;
}
if(ch == 'f') {
addc(parser, '\f');
return JSON_NONE|CONSUMED;
}
if(ch == 'n') {
addc(parser, '\n');
return JSON_NONE|CONSUMED;
}
if(ch == 'r') {
addc(parser, '\r');
return JSON_NONE|CONSUMED;
}
if(ch == 't') {
addc(parser, '\t');
return JSON_NONE|CONSUMED;
}
if(ch == 'u')
/* preserve unicode quoting as-is */
addc(parser, '\\');
/* as-is */
addc(parser, ch);
return JSON_NONE|CONSUMED;
}
if(ch == '\\') {
parser->state |= STRING_ESCAPE;
return JSON_NONE|CONSUMED;
}
if(ch == '"') {
*parser->endp = '\0';
return JSON_STRING|CONSUMED;
}
addc(parser, ch);
return JSON_NONE|CONSUMED;
}
/* This basically accepts integer constants, instead what it should
* accept is as follows:
*
* RFC7159 specifies the following number format:
*
* -?(0|[1-9][0-0]*)(\.[0-9]+)?(e[-+][0-9]+)?
*
* It seems more reasonable to accept the following (basically what
* strtod would accept):
*
* decimal floats:
* [-+]?[0-9]+(\.[0-9]*)?(e[-+]?[0-9]+)?
* [-+]?\.[0-9]+(e[-+]?[0-9]+)?
*
* perhaps also:
*
* hex floats:
* [-+]?0x[0-9a-f]+(\.[0-9a-f]*)?(p[-+]?[0-9]+)?
* [-+]?0x\.[0-9a-f]+(p[-+]?[0-9]+)?
*
* specials:
* [-+]inf(inity)?
* [-+]nan(\([0-9a-z_]*\))?
*/
static unsigned int
big_json_token_number(struct big_json_parser *parser, int ch)
{
const int states[] = {
[0] = 4|2|1,
[1] = 4|2,
[2] = 8|4,
[3] = 4,
[4] = 16,
};
int m = states[parser->state];
if((m & 1) && ch == '-') {
parser->state = 1;
} else if((m & 2) && ch == '0') {
parser->state = 2;
} else if((m & 4) && isdigit(ch)) {
parser->state = 3;
} else if((m & 8) && tolower(ch) == 'x') {
parser->state = 4;
} else if((m & 16) && isxdigit(ch)) {
parser->state = 4;
} else {
*parser->endp = '\0';
return JSON_NUMBER|AGAIN;
}
addc(parser, ch);
return JSON_NONE|CONSUMED;
}
/* unquoted string */
static unsigned int
big_json_token_literal(struct big_json_parser *parser, int ch)
{
bool good = false;
good = isalpha(ch);
if(!good && parser->endp > parser->token)
good = isdigit(ch) || ch == '_';
if(good) {
addc(parser, ch);
return JSON_NONE|CONSUMED;
}
*parser->endp = '\0';
if(strcmp(parser->token, "false") == 0)
return JSON_FALSE|AGAIN;
if(strcmp(parser->token, "true") == 0)
return JSON_TRUE|AGAIN;
if(strcmp(parser->token, "null") == 0)
return JSON_NULL|AGAIN;
return JSON_LITERAL|AGAIN;
}
static unsigned int
big_json_token_start(struct big_json_parser *parser, int ch)
{
if(ch == EOF)
return JSON_END|CONSUMED;
if(isjsonspace(ch))
return JSON_NONE|CONSUMED;
parser->endp = parser->token;
if(strchr("[]{},:", ch) != NULL) {
addc(parser, ch);
*parser->endp = '\0';
return ch|CONSUMED;
}
if(ch == '"') {
parser->tokenizer = big_json_token_string;
parser->state = 0;
return JSON_NONE|CONSUMED;
}
if(isdigit(ch) || ch == '-') {
parser->tokenizer = big_json_token_number;
parser->state = 0;
return JSON_NONE|AGAIN;
}
if(isalpha(ch)) {
parser->tokenizer = big_json_token_literal;
parser->state = 0;
return JSON_NONE|AGAIN;
}
addc(parser, ch);
*parser->endp = '\0';
return JSON_UNKNOWN|CONSUMED;
}
void
big_json_init(struct big_json_parser *parser)
{
parser->tokenizer = big_json_token_start;
parser->endp = parser->token;
parser->state = 0;
parser->ungetc = EOF;
}
void
big_json_finish(struct big_json_parser *parser)
{
}
/* This accepts one character at a time, and returns a JSON token
* descriptor, or JSON_NONE for unfinished tokens, the string
* comprising the token is available in parser->token (this has a
* restricted size).
*
* Strings are returned with no particular coding. Unicode escapes
* (\uXXXX) are passed through as-is, this causes ambiguity with
* strings like "\\u1234" vs "\u1234".
*
* Numbers are limited to simple integers with optional sign, and
* hex-prefix. The number itself is not parsed, use strtol or similar.
*
* true/false/null are handled properly, other unquoted symbols are
* returned as JSON_LITERAL.
*
* JSON_UNKNOWN is returned for anything not matching a known lexical
* token.
*
* JSON_END is returned at end of file.
*
* Since this parses JSON files on a lexical level only, there
* is no requirement, or validation, that a parsed file is well formed.
*/
enum big_json_token
big_json_tokenizer(struct big_json_parser *parser, int ch)
{
unsigned int result;
if(parser->ungetc != EOF)
swap(parser->ungetc, ch);
do {
result = (*parser->tokenizer)(parser, ch);
bool consumed = result&CONSUMED;
result &= ~CONSUMED;
if(result == JSON_NONE) {
if(consumed) {
ch = EOF;
swap(parser->ungetc, ch);
}
} else {
if(!consumed) {
assert(parser->ungetc == EOF);
parser->ungetc = ch;
}
parser->tokenizer = big_json_token_start;
return result;
}
} while(ch != EOF);
return JSON_NONE;
}
| 26.191919 | 80 | 0.556113 |
5eb9e119633b0d0be9d68674ab651be1adbcf520 | 3,723 | h | C | Mem.h | privacore/open-source-search-engine | dac28de673068039381ca3f66521ea4c1eaf6a1e | [
"Apache-2.0"
] | 134 | 2016-05-30T13:29:37.000Z | 2021-06-18T02:13:51.000Z | Mem.h | mehmet-biter/open-source-search-engine | dac28de673068039381ca3f66521ea4c1eaf6a1e | [
"Apache-2.0"
] | 65 | 2016-10-31T16:02:28.000Z | 2020-04-30T14:18:57.000Z | Mem.h | mehmet-biter/open-source-search-engine | dac28de673068039381ca3f66521ea4c1eaf6a1e | [
"Apache-2.0"
] | 22 | 2016-05-30T13:29:39.000Z | 2020-06-30T08:43:38.000Z | // Matt Wells, copyright Sep 2001
// . mostly just wrappers for most memory functions
// . allows us to constrain memory
// . also calls mlockall() on construction to avoid swapping out any mem
// . TODO: primealloc(int slotSize,int numSlots) :
// pre-allocs a table of these slots for faster mmalloc'ing
#ifndef GB_MEM_H
#define GB_MEM_H
#include <new>
#include <stddef.h> //for NULL
#include <inttypes.h>
class SafeBuf;
class Mem {
public:
Mem();
~Mem();
bool init ( );
void *gbmalloc ( size_t size , const char *note );
void *gbcalloc ( size_t size , const char *note);
void *gbrealloc ( void *oldPtr, size_t oldSize, size_t newSize, const char *note);
void gbfree(void *ptr, const char *note, size_t size, bool checksize);
void *dup ( const void *data , size_t dataSize , const char *note);
// this one does not include new/delete mem, only *alloc()/free() mem
size_t getUsedMem() const;
// the max mem ever allocated
size_t getMaxAllocated() const { return m_maxAllocated; }
size_t getMaxAlloc () const { return m_maxAlloc; }
const char *getMaxAllocBy() const { return m_maxAllocBy; }
// the max mem we can use!
size_t getMaxMem() const;
int32_t getNumAllocated() const { return m_numAllocated; }
int64_t getNumTotalAllocated() const { return m_numTotalAllocated; }
float getUsedMemPercentage() const;
int32_t getOOMCount() const { return m_outOfMems; }
uint32_t getMemTableSize() const { return m_memtablesize; }
int64_t getFreeMem() const;
void setMemTableSize(uint32_t sz) { m_memtablesize = sz; }
void incrementOOMCount() { m_outOfMems++; }
// who underan/overran their buffers?
int printBreeches () ;
// print mem usage stats
int printMem ( ) ;
void addMem(void *mem, size_t size, const char *note, char isnew);
bool rmMem(void *mem, size_t size, const char *note, bool checksize);
bool lblMem(void *mem, size_t size, const char *note);
void addnew(void *ptr, size_t size, const char *note);
void delnew(void *ptr, size_t size, const char *note);
bool printMemBreakdownTable(SafeBuf *sb);
private:
size_t m_maxAllocated; // at any one time
size_t m_maxAlloc; // the biggest single alloc ever done
const char *m_maxAllocBy; // the biggest single alloc ever done
int32_t validate();
int32_t getMemSlot(void *mem);
// currently used mem (estimate)
size_t m_used;
// count how many allocs/news failed
int32_t m_outOfMems;
int32_t m_numAllocated;
int64_t m_numTotalAllocated;
uint32_t m_memtablesize;
int printBreeches_unlocked();
int printBreech(int32_t i);
};
extern class Mem g_mem;
static inline void *mmalloc(size_t size, const char *note) {
return g_mem.gbmalloc(size, note);
}
static inline void *mcalloc(size_t size, const char *note) {
return g_mem.gbcalloc(size, note);
}
static inline void *mrealloc(void *oldPtr, size_t oldSize, size_t newSize, const char *note) {
return g_mem.gbrealloc(oldPtr, oldSize, newSize, note);
}
static inline void mfree(void *ptr, size_t size, const char *note) {
return g_mem.gbfree(ptr, note, size, true);
}
static inline void *mdup(const void *data, size_t dataSize, const char *note) {
return g_mem.dup(data, dataSize, note);
}
static inline void mnew(void *ptr, size_t size, const char *note) {
return g_mem.addnew(ptr, size, note);
}
static inline void mdelete(void *ptr, size_t size, const char *note) {
return g_mem.delnew(ptr, size, note);
}
static inline bool relabel(void *ptr, size_t size, const char *note) {
return g_mem.lblMem(ptr, size, note);
}
class ScopedMemoryLimitBypass {
int64_t oldMaxMem;
public:
ScopedMemoryLimitBypass();
~ScopedMemoryLimitBypass() {
release();
}
void release();
};
#endif // GB_MEM_H
| 26.978261 | 94 | 0.718775 |
e87f8f2b1d527c61aa3c1ebb2ca176956d552292 | 109 | h | C | Source/WebCore/ForwardingHeaders/runtime/WeakGCPtr.h | VincentWei/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | 6 | 2017-05-31T01:46:45.000Z | 2018-06-12T10:53:30.000Z | Source/WebCore/ForwardingHeaders/runtime/WeakGCPtr.h | FMSoftCN/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | null | null | null | Source/WebCore/ForwardingHeaders/runtime/WeakGCPtr.h | FMSoftCN/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | 2 | 2017-07-17T06:02:42.000Z | 2018-09-19T10:08:38.000Z | #ifndef WebCore_FWD_WeakGCPtr_h
#define WebCore_FWD_WeakGCPtr_h
#include <JavaScriptCore/WeakGCPtr.h>
#endif
| 21.8 | 37 | 0.862385 |
9562eb42964de8a44e2faaec124a70e3c8e320bb | 3,653 | h | C | PrivateFrameworks/TelephonyUtilities/NSURL-QueryParameters.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/TelephonyUtilities/NSURL-QueryParameters.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/TelephonyUtilities/NSURL-QueryParameters.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSURL.h"
@class NSString;
@interface NSURL (QueryParameters)
+ (id)faceTimeShowInCallUIURL;
+ (id)faceTimeLaunchForOutgoingConversationURL;
+ (id)faceTimeLaunchForIncomingCallURL;
+ (id)faceTimePromptURLWithURL:(id)arg1;
+ (id)faceTimeURLWithURL:(id)arg1;
+ (id)_applyFaceTimeScheme:(id)arg1 toFaceTimeURL:(id)arg2;
+ (id)faceTimeTelephonyURLWithPhoneNumber:(id)arg1 showPrompt:(BOOL)arg2;
+ (id)faceTimeTelephonyURLWithPhoneNumber:(id)arg1;
+ (id)faceTimeURLWithDestinationID:(id)arg1 addressBookUID:(id)arg2 audioOnly:(BOOL)arg3;
+ (id)faceTimeURLWithDestinationID:(id)arg1 addressBookUID:(id)arg2;
+ (id)faceTimeURLWithDestinationID:(id)arg1;
+ (id)_faceTimeURLWithHandle:(id)arg1 addressBookUID:(id)arg2 audioOnly:(BOOL)arg3;
+ (id)_faceTimeURLWithDestinationID:(id)arg1 addressBookUID:(id)arg2 audioOnly:(BOOL)arg3;
+ (id)faceTimePinExchangeURLWithAction:(int)arg1 serviceType:(int)arg2;
+ (id)faceTimePinExchangeURLWithCode:(id)arg1 alias:(id)arg2 serviceType:(int)arg3;
+ (id)_faceTimePinExchangeURLWithParameters:(id)arg1;
+ (id)URLWithTelephoneNumber:(id)arg1 addressBookUID:(int)arg2 forceAssist:(BOOL)arg3 suppressAssist:(BOOL)arg4 wasAssisted:(BOOL)arg5;
+ (id)URLWithTelephoneNumber:(id)arg1 addressBookUID:(int)arg2;
+ (id)URLWithTelephoneNumber:(id)arg1 promptUser:(BOOL)arg2;
+ (id)URLWithTelephoneNumber:(id)arg1;
+ (id)telephonyURLForTelEmergencyCall;
+ (id)telephonyURLForVoicemail;
+ (id)telephonyURLWithDestinationID:(id)arg1 addressBookUID:(int)arg2 forceAssist:(BOOL)arg3 suppressAssist:(BOOL)arg4 wasAssisted:(BOOL)arg5;
+ (id)telephonyURLWithDestinationID:(id)arg1 addressBookUID:(int)arg2;
+ (id)telephonyURLWithDestinationID:(id)arg1 promptUser:(BOOL)arg2;
+ (id)telephonyURLWithDestinationID:(id)arg1;
- (id)URLByDeletingQueryParameterWithKey:(id)arg1;
- (id)URLBySettingQueryParameterValue:(id)arg1 forKey:(id)arg2;
- (id)tuQueryParameters;
- (id)queryParameters;
- (BOOL)isShowInCallUIURL;
- (BOOL)isLaunchForOutgoingConversationURL;
- (BOOL)isLaunchForIncomingCallURL;
- (BOOL)isDialCallURL;
@property(readonly, nonatomic) int addressBookUID;
- (BOOL)isTelephonyURL;
- (BOOL)hasNoPromptOption;
- (BOOL)isFaceTimeMultiwayURL;
- (BOOL)isFaceTimeAudioPromptURL;
- (BOOL)isFaceTimeAudioURL;
- (BOOL)isFaceTimePromptURL;
- (BOOL)isFaceTimeURL;
- (BOOL)_isPhoneNumberID:(id)arg1;
- (id)faceTimeDestinationAccount;
- (int)pinExchangeServiceType;
- (int)pinExchangeAction;
- (id)pinExchangeAlias;
- (id)pinExchangeCode;
- (BOOL)isPinExchangeURL;
- (id)_mobilePhoneQueryParameters;
- (id)_mobilePhonePathParameters;
- (id)telephonyParameterDictionary;
@property(readonly) BOOL isVoicemailURL;
@property(readonly) BOOL isEmergencyCallURL;
@property(readonly) BOOL isEmergencyURL;
- (id)webSafeTelephoneURL;
- (BOOL)isWebSafeTelephoneURL;
- (BOOL)_hasScheme:(id)arg1;
- (BOOL)hasTelephonyScheme;
- (BOOL)isTelephonyPromptURL;
- (BOOL)isTelephonyURL;
- (BOOL)_dialAssistBooleanQueryParameterValueForKey:(id)arg1;
@property(readonly) BOOL wasAlreadyAssisted;
@property(readonly) BOOL suppressAssist;
@property(readonly) BOOL forceAssist;
@property(readonly) NSString *originatingUIIdentifier;
@property(readonly) int callService;
@property(readonly) NSString *phoneNumber;
- (id)_destinationIDConvertingNumbersToLatin:(BOOL)arg1;
// Remaining properties
@property(readonly, nonatomic, getter=isBasebandLogURL) BOOL basebandLogURL;
@property(readonly, copy, nonatomic) NSString *formattedPhoneNumber;
@property(readonly, copy, nonatomic) NSString *numberQualifiedForAddressBook;
@end
| 41.511364 | 142 | 0.801259 |
957013165a02b5c8e32e4206848063f37b2d158b | 481 | c | C | testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53495.c | mewbak/cc-1 | d673e9b70d4d716fd96e81a4d7dc9d532c6c0391 | [
"BSD-3-Clause"
] | 178 | 2016-03-03T12:31:18.000Z | 2021-11-05T22:36:55.000Z | testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53495.c | mewbak/cc-1 | d673e9b70d4d716fd96e81a4d7dc9d532c6c0391 | [
"BSD-3-Clause"
] | 106 | 2016-03-03T13:11:42.000Z | 2018-09-27T13:01:51.000Z | testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53495.c | mewbak/cc-1 | d673e9b70d4d716fd96e81a4d7dc9d532c6c0391 | [
"BSD-3-Clause"
] | 21 | 2016-03-03T14:21:36.000Z | 2020-04-09T01:19:17.000Z | /* PR rtl-optimization/53495 */
int a, b, c, d, e, g;
static char
fn1 (char p1, int p2)
{
return p1 || p2 < 0 || p2 >= 1 || 1 >> p2 ? p1 : 0;
}
static long long fn2 (int *, int);
static int fn3 ();
void
fn4 ()
{
fn3 ();
fn2 (&a, d);
}
long long
fn2 (int *p1, int p2)
{
int f = -1L;
for (; c <= 1; c++)
{
*p1 = 0;
*p1 = fn1 (c, p2 ^ f);
}
a = 0;
e = p2;
return 0;
}
int
fn3 ()
{
b = 3;
for (; b; b--)
c++;
g = 0 >= c;
return 0;
}
| 11.452381 | 53 | 0.428274 |
66ab6e71b4257f3caab7ac7e5cffb18822fb16ff | 724 | h | C | Editor/Graphics/Manipulators/Rotater/AGRotater.h | alexshpunt/art_gear | 64a2d001570812690fc8845f694f2bfe1d96c3a2 | [
"MIT"
] | null | null | null | Editor/Graphics/Manipulators/Rotater/AGRotater.h | alexshpunt/art_gear | 64a2d001570812690fc8845f694f2bfe1d96c3a2 | [
"MIT"
] | null | null | null | Editor/Graphics/Manipulators/Rotater/AGRotater.h | alexshpunt/art_gear | 64a2d001570812690fc8845f694f2bfe1d96c3a2 | [
"MIT"
] | null | null | null | #ifndef AG_ROTATEMANIP_H
#define AG_ROTATEMANIP_H
#include "Engine/Graphics/Objects/AGManipulator.h"
class AGGameObject;
class AGDrawable;
class AGCircle;
class AGSurface;
class AGGizmo;
class AGLine;
using namespace std;
class AGRotater : public AGManipulator
{
public:
AGRotater();
~AGRotater();
bool mouseClickEvent( AGMouseButton btn, AGSurface* surface );
bool mouseMoveEvent( AGSurface* surface );
void mouseReleaseEvent( AGMouseButton btn );
void draw( AGSurface* surface );
private:
AGCircle* m_xCircle;
AGCircle* m_yCircle;
AGCircle* m_zCircle;
AGGizmo* m_selectedObject;
AGVec3 m_v1;
AGVec3 m_v2;
AGVec3 m_v3;
AGVec3 m_tangent;
AGVec3 m_angles;
};
#endif | 16.454545 | 64 | 0.736188 |
95e4698d8e281e1415dd83e685e3a56416034da4 | 3,991 | h | C | chrome/browser/sync/engine/authenticator.h | rwatson/chromium-capsicum | b03da8e897f897c6ad2cda03ceda217b760fd528 | [
"BSD-3-Clause"
] | 11 | 2015-03-20T04:08:08.000Z | 2021-11-15T15:51:36.000Z | chrome/browser/sync/engine/authenticator.h | rwatson/chromium-capsicum | b03da8e897f897c6ad2cda03ceda217b760fd528 | [
"BSD-3-Clause"
] | null | null | null | chrome/browser/sync/engine/authenticator.h | rwatson/chromium-capsicum | b03da8e897f897c6ad2cda03ceda217b760fd528 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// The authenticator is a cross-platform class that handles authentication for
// the sync client.
//
// Current State:
// The authenticator is currently only used to authenticate tokens using the
// newer protocol buffer request.
#ifndef CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_
#define CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_
#include <string>
#include "base/basictypes.h"
#include "base/port.h"
namespace sync_pb {
class UserIdentification;
}
namespace browser_sync {
class ServerConnectionManager;
class UserSettings;
class Authenticator {
public:
// Single return enum.
enum AuthenticationResult {
SUCCESS = 0,
// We couldn't log on because we don't have saved credentials.
NO_SAVED_CREDENTIALS,
// We can't reach auth server (i.e. we're offline or server's down).
NOT_CONNECTED,
// Server's up, but we're down.
SERVICE_DOWN,
// We contacted the server, but the response didn't make sense.
CORRUPT_SERVER_RESPONSE,
// Bad username/password.
BAD_CREDENTIALS,
// Credentials are fine, but the user hasn't signed up.
USER_NOT_ACTIVATED,
// Return values for internal use.
// We will never return this to the user unless they call AuthenticateToken
// directly. Other auth functions retry and then return
// CORRUPT_SERVER_RESPONSE.
// TODO(sync): Implement retries.
BAD_AUTH_TOKEN,
// We should never return this, it's a placeholder during development.
// TODO(sync): Remove this
UNSPECIFIC_ERROR_RETURN,
};
// Constructor. This class will keep the connection authenticated.
// TODO(sync): Make it work as described.
// TODO(sync): Require a UI callback mechanism.
Authenticator(ServerConnectionManager* manager, UserSettings* settings);
// Constructor for a simple authenticator used for programmatic login from
// test programs.
explicit Authenticator(ServerConnectionManager* manager);
// This version of Authenticate tries to use saved credentials, if we have
// any.
AuthenticationResult Authenticate();
// If save_credentials is set we save the long-lived auth token to local disk.
// In all cases we save the username and password in memory (if given) so we
// can refresh the long-lived auth token if it expires.
// Also we save a 10-bit hash of the password to allow offline login.
// TODO(sync): Make it work as described.
// TODO(sync): Arguments for desired domain.
AuthenticationResult Authenticate(std::string username, std::string password,
bool save_credentials);
// A version of the auth token to authenticate cookie portion of
// authentication. It uses the new proto buffer based call instead of the HTTP
// GET based one we currently use.
// Can return one of SUCCESS, SERVICE_DOWN, CORRUPT_SERVER_RESPONSE,
// USER_NOT_ACTIVATED or BAD_AUTH_TOKEN. See above for the meaning of these
// values.
// TODO(sync): Make this function private when we're done.
AuthenticationResult AuthenticateToken(std::string auth_token);
const char* display_email() const { return display_email_.c_str(); }
const char* display_name() const { return display_name_.c_str(); }
private:
// Stores the information in the UserIdentification returned from the server.
AuthenticationResult HandleSuccessfulTokenRequest(
const sync_pb::UserIdentification* user);
// The server connection manager that we're looking after.
ServerConnectionManager* server_connection_manager_;
// Returns SUCCESS or the value that should be returned to the user.
std::string display_email_;
std::string display_name_;
std::string obfuscated_id_;
UserSettings* const settings_;
DISALLOW_COPY_AND_ASSIGN(Authenticator);
};
} // namespace browser_sync
#endif // CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_
| 36.953704 | 80 | 0.744174 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.