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
70c2c2993a7ee0cdeb63a663714f94378f92de1d
15,657
c
C
src/ucode_gen.c
nocferno/intel_ucode_gen
9e2ccfcb1bc1f813628d0b27c02674ecceab46ff
[ "Apache-2.0" ]
null
null
null
src/ucode_gen.c
nocferno/intel_ucode_gen
9e2ccfcb1bc1f813628d0b27c02674ecceab46ff
[ "Apache-2.0" ]
null
null
null
src/ucode_gen.c
nocferno/intel_ucode_gen
9e2ccfcb1bc1f813628d0b27c02674ecceab46ff
[ "Apache-2.0" ]
1
2022-01-29T17:29:42.000Z
2022-01-29T17:29:42.000Z
/* Attempts to generate an Intel microcode blob */ /* author - nocferno */ #include "../include/ucode_gen.h" #include "../include/rand_32.h" #include <sys/random.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/time.h> #include <unistd.h> #include <fcntl.h> #include <cpuid.h> #include <time.h> #include <errno.h> #include <string.h> #include <stdio.h> static struct __microcode_path { char * _ucode_file_path; uint16_t _ucode_path_len; char _ucode_name[0x8]; const char * _ucode_path; bool _init; } __ucode_path; typedef struct __microcode_path ucode_path; typedef struct __microcode_path * ucode_path_ptr; /* forward declarations */ static void _set_header_version(intel_microcode_ptr); static void _set_loader_revision(intel_microcode_ptr); static void _set_total_size(intel_microcode_ptr); static bool _sanitize_dev_path_(dev_path_ptr); static bool _get_proc_sig(intel_microcode_ptr); static bool _build_microcode_data(intel_microcode_ptr); static int _gen_microcode_data(intel_microcode_ptr); static int _gen_update_revision(intel_microcode_ptr); static int _gen_update_time(intel_microcode_ptr); static int _gen_proc_flags(intel_microcode_ptr, const char *); static int _gen_checksum(intel_microcode_ptr); static int _gen_data_size(intel_microcode_ptr); static int _gen_microcode_file_path(intel_microcode_ptr, ucode_path_ptr); static bool _build_ucode_name(uint8_t, uint8_t, uint8_t, ucode_path_ptr); static char _hex2ascii(uint8_t); int ucode_gen_main(dev_path_ptr args) { int ret = 0x1; if(!args) return ret; if(_sanitize_dev_path_(args)) ret ^= ret; if(!ret) { intel_microcode _data = { 0x0 }; ucode_path _path = { 0x0 }; if(!(_gen_proc_flags(&_data, args->_msr_dev_path)) && _get_proc_sig(&_data)) { _path._ucode_path = args->_fw_path; ret = _gen_microcode_file_path(&_data, &_path); } if(!ret) { int _flags = (O_CREAT | O_RDWR); mode_t _access_mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); unlink(_path._ucode_file_path); _data._map_fd = open(_path._ucode_file_path, _flags, _access_mode); if(_data._map_fd <= 0x0) ret = 0x2; if(!_gen_data_size(&_data)) { _set_total_size(&_data); _data._map_len = _data.total_size; } if(!_data._map_len) { if(!ret) close(_data._map_fd); ret = 0x3; } if(!ret) { int _map_prot = (PROT_WRITE | PROT_READ), _map_flags = (MAP_PRIVATE | MAP_ANONYMOUS); _data._map_ptr = mmap(NULL, _data._map_len, _map_prot, _map_flags, -1, 0x0); if(_data._map_ptr != MAP_FAILED) { if(!_build_microcode_data(&_data)) { ret = 0x5; } else { if(write(_data._map_fd, _data._map_ptr, _data._map_len) != _data._map_len) ret = 0x6; } } else { fprintf(stdout, "%s\n", strerror(errno)); ret = 0x4; } if(!ret) munmap(_data._map_ptr, _data._map_len); close(_data._map_fd); } } if(_path._init) munmap(_path._ucode_file_path, _path._ucode_path_len); } else { ret = 0x5; } return ret; } static bool _sanitize_dev_path_(dev_path_ptr args) { bool ret = false; if(!args) return ret; if(args->_fw_path && args->_ucode_load_path && args->_msr_dev_path) if(args->_init) ret = args->_init; return ret; } static void _set_header_version(intel_microcode_ptr primary) { if(primary) primary->header_ver = 0x1; return; } static void _set_loader_revision(intel_microcode_ptr primary) { if(primary) primary->loader_rev = 0x1; return; } static void _set_total_size(intel_microcode_ptr primary) { if(primary) if(primary->data_size > 0x0) primary->total_size = (primary->data_size + 0x30); return; } static bool _get_proc_sig(intel_microcode_ptr primary) { if(primary) { uint32_t eax, ebx, ecx, edx; if(__get_cpuid(0x1, &eax, &ebx, &ecx, &edx)) primary->proc_sig = eax; } return (primary->proc_sig) > 0x0 ? true : false; } static int _gen_update_revision(intel_microcode_ptr primary) { int ret = 0x1; if(primary) { primary->update_rev = get_rand_32(0x1000000, 0xF0000000); ret ^= ret; } return ret; } static int _gen_update_time(intel_microcode_ptr primary) { int ret = 0x1; if(primary) { time_t _current = time(0x0); struct tm *_time_data = localtime(&_current); if(_time_data) { uint8_t _date_hex[0x8] = {0x0}, i = 0x0; _time_data->tm_year += 0x76C; _time_data->tm_mon++; /* year */ _date_hex[0x3] = ((_time_data->tm_year) / 0x3E8), _date_hex[0x2] = ((_time_data->tm_year) / 0x64) - (_date_hex[0x3] * 0xA), _date_hex[0x1] = ((_time_data->tm_year) / 0xA) - (_date_hex[0x3] * 0x64), _date_hex[0x0] = ((_time_data->tm_year) - (_date_hex[0x3] * 0x3E8)); if(_date_hex[0x0] > 0xA) _date_hex[0x0] -= 0xA; /* day */ _date_hex[0x5] = 0x0; if(_time_data->tm_mday >= 0xA) { _date_hex[0x5] = ((_time_data->tm_mday) / 0xA), _date_hex[0x4] = ((_time_data->tm_mday) - (_date_hex[0x5] * 0xA)); } else { _date_hex[0x4] = _time_data->tm_mday; } /* month */ _date_hex[0x7] = 0x0; if(_time_data->tm_mon >= 0xA) { _date_hex[0x7] = ((_time_data->tm_mon) / 0xA), _date_hex[0x6] = ((_time_data->tm_mon) - (_date_hex[0x7] * 0xA)); } else { _date_hex[0x6] = _time_data->tm_mon; } primary->update_date ^= primary->update_date; /* assemble date */ for(i ^= i; i < 0x8; i++) primary->update_date |= _date_hex[i] << (i * 0x4); if(primary->update_date > 0x0) ret ^= ret; } } return ret; } static int _gen_proc_flags(intel_microcode_ptr primary, const char *msr_device) { char _msr_data[0x8] = {0x0}; int msr_fd = 0x0, ret = 0x1; if(!primary || !msr_device) return ret; msr_fd = open(msr_device, O_RDONLY); if(msr_fd > 0x0) { size_t bytes_read = pread(msr_fd, _msr_data, 0x8, 0x17); if(bytes_read == 0x8) { primary->proc_flags = (_msr_data[0x6] & 0x8) | /* bit 51 */ (_msr_data[0x6] & 0x10) | /* bit 52 */ (_msr_data[0x6] & 0x20); /* bit 53 */ ret ^= ret; } close(msr_fd); } return ret; } static int _gen_checksum(intel_microcode_ptr primary) { int ret = 0x1; if(primary) { uint32_t *microcode_ptr = primary->_map_ptr; uint32_t i = 0x0, _sum = 0x0; for(i ^= i; i < primary->total_size / 0x4; i++) _sum += microcode_ptr[i]; primary->checksum = (0xFFFFFFFF - _sum) + 0x1; ret ^= ret; } return ret; } static int _gen_data_size(intel_microcode_ptr primary) { int ret = 0x1; if(primary) { do { primary->data_size = get_rand_32(0x7D0, 0x5000); } while((primary->data_size % 0x4) != 0x0); ret = (primary->data_size) ? 0x0 : 0x2; } return ret; } static int _gen_microcode_file_path(intel_microcode_ptr primary, ucode_path_ptr path) { uint32_t stepping_id = 0x0, model_id = 0x0, family_id = 0x0, ex_model_id = 0x0, ex_family_id = 0x0; int ret = 0x1; if(!primary || !path) return ret; stepping_id = (primary->proc_sig & 0xF), model_id = (primary->proc_sig & 0xF0) >> 0x4, family_id = (primary->proc_sig & 0xF00) >> 0x8, ex_model_id = (primary->proc_sig & 0xF0000) >> 0x10, ex_family_id = (primary->proc_sig & 0xFF00000) >> 0x14; if(primary->proc_sig > 0x0) { if(family_id == 0x6 || family_id == 0xF) model_id += (ex_model_id << 0x4); if(family_id == 0xF) family_id += ex_family_id; /* family_id, model_id, stepping_id -- (8-byte file name) */ ret ^= ret; } else { ret++; } if(!ret) { if(_build_ucode_name((family_id & 0xFF), (model_id & 0xFF), (stepping_id & 0xFF), path)) { int map_prot = (PROT_READ | PROT_WRITE), map_flag = (MAP_ANONYMOUS | MAP_PRIVATE), i = 0x0, n = 0x0; path->_ucode_path_len ^= path->_ucode_path_len; for(i ^= i; path->_ucode_path[i] != '\0'; i++); path->_ucode_path_len = i + 0x8; /* path + name */ path->_ucode_file_path = mmap(NULL, path->_ucode_path_len, map_prot, map_flag, -1, 0x0); if(path->_ucode_file_path != MAP_FAILED) { char *_ptr = (char *)(path->_ucode_path); for(i ^= i, n = i; i < path->_ucode_path_len; i++, n++) { if((path->_ucode_path_len - i) == 0x8) { _ptr = path->_ucode_name; n ^= n; } path->_ucode_file_path[i] = _ptr[n]; } path->_init = true; } } } return ret; } static bool _build_ucode_name(uint8_t family_id, uint8_t model_id, uint8_t stepping_id, ucode_path_ptr path) { bool ret = false; if(path) { path->_ucode_name[0x0] = _hex2ascii((family_id & 0xF0) >> 0x4), path->_ucode_name[0x1] = _hex2ascii(family_id & 0xF), path->_ucode_name[0x2] = 0x2D, path->_ucode_name[0x3] = _hex2ascii((model_id & 0xF0) >> 0x4), path->_ucode_name[0x4] = _hex2ascii(model_id & 0xF), path->_ucode_name[0x5] = 0x2D, path->_ucode_name[0x6] = _hex2ascii((stepping_id & 0xF0) >> 0x4), path->_ucode_name[0x7] = _hex2ascii(stepping_id & 0xF); ret = true; } return ret; } static char _hex2ascii(uint8_t num) { return (num >= 0xA && num <= 0xF) ? (char)(num + 0x31) : (char)(num + 0x30); } static int _gen_microcode_data(intel_microcode_ptr primary) { int ret = 0x1; if(!primary) return ret; if(primary->data_size > 0x0) { int _prot = (PROT_WRITE | PROT_READ), _flag = (MAP_PRIVATE | MAP_ANONYMOUS); primary->fw_data = mmap(NULL, primary->data_size, _prot, _flag, -1, 0x0); /* NOTE: A microcode encrypted data header spans the first 48-bytes relative to offset of the encrypted data itself. from primary->fw_data + 0x30 --> primary->fw_data + 0x60 lays a slab of bytes, that account for data that will ultimately be used by the CPU/BIOS to continue with the update process. let us assume that: [[ uint32_t *encrypted_data_hdr = (primary->fw_data + 0x30): ]] then: (microcode encrypted data header -- 8-bytes ) encrypted_data_hdr[0x0] = 0x0, 4-bytes encrypted_data_hdr[0x1] = 0xA1000000, 4-bytes encrypted_data_hdr[0x2] = 0x1, 2-bytes encrypted_data_hdr[0x3] = 0x2, 2-bytes (end of microcode encrypted data header) encrypted_data_hdr[0x4] = primary->update_rev, 4-bytes encrypted_data_hdr[0x5] = 0x0, 4-bytes encrypted_data_hdr[0x6] = 0x0, 4-bytes encrypted_data_hdr[0x7] = primary->update_date 4-bytes (possible checksum of all data relative to (primary->fw_data + 0x60) ?..) encrypted_data_hdr[0x8] = ?? 4-bytes (loader revision/update header?) encrypted_data_hdr[0x9] = 0x1 4-bytes encrypted_data_hdr[0xA] = primary->proc_sig 4-bytes encrypted_data_hdr[0xB] = */ if(primary->fw_data != MAP_FAILED) { uint32_t size_ctr = 0x0; uint8_t rand_len = 0x40; for(size_ctr ^= size_ctr; size_ctr < primary->data_size; size_ctr += rand_len) if(getrandom(primary->fw_data, rand_len, GRND_NONBLOCK) == rand_len) primary->fw_data += rand_len; primary->fw_data -= primary->data_size; ret ^= ret; } } return ret; } static bool _build_microcode_data(intel_microcode_ptr primary) { bool ret = false; if(!primary) return ret; _set_header_version(primary); _set_loader_revision(primary); if(!_gen_update_revision(primary) && !_gen_update_time(primary)) { uint32_t *file_map = primary->_map_ptr; /* write all members of intel_microcode_ptr to primary->_map_ptr */ if(file_map) { unsigned char *file_map_char = primary->_map_ptr; uint32_t i = 0x0, n = 0x0; file_map[0x0] = primary->header_ver, file_map[0x1] = primary->update_rev, file_map[0x2] = primary->update_date, file_map[0x3] = primary->proc_sig, file_map[0x5] = primary->loader_rev, file_map[0x6] = primary->proc_flags, file_map[0x7] = primary->data_size, file_map[0x8] = primary->total_size; if(!_gen_microcode_data(primary)) { for(i ^= i, n = 0x30; i < primary->data_size; i++, n++) file_map_char[n] = primary->fw_data[i]; if(!_gen_checksum(primary)) { file_map[0x4] = primary->checksum; if(!munmap(primary->fw_data, primary->data_size)) primary->fw_data = NULL; ret = true; } } } } return ret; }
28.6234
82
0.512359
cb5f1bc2f9bc0f4fcade633dc1d3dc8c09c6143d
202
h
C
firmware/orocaboy_fw/src/sketch/arduboy/glove/exit.h
oroca/orocaboy
95914d2927479e89918c4b26ee3e611b7c180a36
[ "Apache-2.0" ]
2
2018-01-09T18:18:55.000Z
2020-01-12T03:18:11.000Z
firmware/orocaboy_fw/src/sketch/arduboy/glove/exit.h
oroca/orocaboy
95914d2927479e89918c4b26ee3e611b7c180a36
[ "Apache-2.0" ]
null
null
null
firmware/orocaboy_fw/src/sketch/arduboy/glove/exit.h
oroca/orocaboy
95914d2927479e89918c4b26ee3e611b7c180a36
[ "Apache-2.0" ]
3
2017-04-25T06:22:26.000Z
2020-04-14T09:43:36.000Z
#ifndef _EXIT_H #define _EXIT_H struct Exit{ char x; char y; char dest; bool active; }; void add_exit(char x, char y, char dest); void draw_exit(Exit &obj); void activate_exit(Exit& obj); #endif
12.625
41
0.707921
b44bb1378b28f0f0d314e70f8a83eb6ea453ccc6
458
h
C
src/usb/ao/AoUsb1608g.h
d4ddi0/uldaq
cf0445561d9b511e42c10bb04a61289887b51aee
[ "MIT" ]
73
2018-05-11T02:36:01.000Z
2022-03-24T22:41:51.000Z
src/usb/ao/AoUsb1608g.h
d4ddi0/uldaq
cf0445561d9b511e42c10bb04a61289887b51aee
[ "MIT" ]
35
2018-06-05T13:04:11.000Z
2022-03-31T17:38:56.000Z
src/usb/ao/AoUsb1608g.h
d4ddi0/uldaq
cf0445561d9b511e42c10bb04a61289887b51aee
[ "MIT" ]
30
2018-06-21T21:07:04.000Z
2022-03-30T21:13:37.000Z
/* * AoUsb1608g.h * * Author: Measurement Computing Corporation */ #ifndef USB_AO_AOUSB1608G_H_ #define USB_AO_AOUSB1608G_H_ #include "AoUsb1208hs.h" namespace ul { class UL_LOCAL AoUsb1608g: public AoUsb1208hs { public: AoUsb1608g(const UsbDaqDevice& daqDevice, int numChans); virtual ~AoUsb1608g(); protected: virtual void readCalDate(); private: enum { FIFO_SIZE = 4 * 1024 }; }; } /* namespace ul */ #endif /* USB_AO_AOUSB1608G_H_ */
14.774194
57
0.724891
cc54f4b43cec2feb6b08781eaba4eef23deb0445
335
h
C
FeedReader/FeedReader/DetailViewController.h
fjnavarro/FeedReader
92176131aee6a1e54c851eb834841e05046a1c09
[ "MIT" ]
null
null
null
FeedReader/FeedReader/DetailViewController.h
fjnavarro/FeedReader
92176131aee6a1e54c851eb834841e05046a1c09
[ "MIT" ]
null
null
null
FeedReader/FeedReader/DetailViewController.h
fjnavarro/FeedReader
92176131aee6a1e54c851eb834841e05046a1c09
[ "MIT" ]
null
null
null
// // DetailViewController.h // FeedReader // // Created by Francisco José Navarro García on 18/7/17. // Copyright © 2017 fjnavarro.com. All rights reserved. // #import <UIKit/UIKit.h> @class ItemModel; @interface DetailViewController : UIViewController <UIWebViewDelegate> @property (nonatomic, strong) ItemModel *feed; @end
18.611111
70
0.737313
4a5079d8668c76870a51b919351595ba6c838f81
11,835
c
C
xboot/src/kernel/graphic/maps/software/sw_rotate.c
LoongPenguin/Linux_210
d941ed620798fb9c96b5d06764fb1dcb68057513
[ "Apache-2.0" ]
null
null
null
xboot/src/kernel/graphic/maps/software/sw_rotate.c
LoongPenguin/Linux_210
d941ed620798fb9c96b5d06764fb1dcb68057513
[ "Apache-2.0" ]
null
null
null
xboot/src/kernel/graphic/maps/software/sw_rotate.c
LoongPenguin/Linux_210
d941ed620798fb9c96b5d06764fb1dcb68057513
[ "Apache-2.0" ]
null
null
null
/* * kernel/graphic/maps/software/sw_rotate.c * * Copyright(c) 2007-2013 jianjun jiang <jerryjianjun@gmail.com> * official site: http://xboot.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 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <graphic/maps/software.h> static void software_rotate_1byte(struct surface_t * dst, struct surface_t * src, struct rect_t * rect, enum rotate_type type) { u8_t * dp, * sp; s32_t dx, dy, dw, dh; u32_t dpitch, spitch; u8_t bytes_per_pixel; u32_t len; u8_t * p, * q; dw = dst->w; dh = dst->h; dpitch = dst->pitch; spitch = src->pitch; bytes_per_pixel = src->info.bytes_per_pixel; len = bytes_per_pixel * dw; switch(type) { case ROTATE_DEGREE_0: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp += spitch; } break; } case ROTATE_DEGREE_90: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dh - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q; q = (u8_t *)((u8_t *)q + spitch); } dp += dpitch; sp -= bytes_per_pixel; } break; } case ROTATE_DEGREE_180: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q--; } dp += dpitch; sp -= spitch; } break; } case ROTATE_DEGREE_270: { dp = dst->pixels; sp = src->pixels + (rect->y + dw - 1) * spitch + rect->x * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q; q = (u8_t *)((u8_t *)q - spitch); } dp += dpitch; sp += bytes_per_pixel; } break; } case ROTATE_MIRROR_H: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q--; } dp += dpitch; sp += spitch; } break; } case ROTATE_MIRROR_V: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp -= spitch; } break; } default: return; } } static void software_rotate_2byte(struct surface_t * dst, struct surface_t * src, struct rect_t * rect, enum rotate_type type) { u8_t * dp, * sp; s32_t dx, dy, dw, dh; u32_t dpitch, spitch; u8_t bytes_per_pixel; u32_t len; u16_t * p, * q; dw = dst->w; dh = dst->h; dpitch = dst->pitch; spitch = src->pitch; bytes_per_pixel = src->info.bytes_per_pixel; len = bytes_per_pixel * dw; switch(type) { case ROTATE_DEGREE_0: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp += spitch; } break; } case ROTATE_DEGREE_90: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dh - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u16_t *)dp; q = (u16_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q; q = (u16_t *)((u8_t *)q + spitch); } dp += dpitch; sp -= bytes_per_pixel; } break; } case ROTATE_DEGREE_180: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u16_t *)dp; q = (u16_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q--; } dp += dpitch; sp -= spitch; } break; } case ROTATE_DEGREE_270: { dp = dst->pixels; sp = src->pixels + (rect->y + dw - 1) * spitch + rect->x * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u16_t *)dp; q = (u16_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q; q = (u16_t *)((u8_t *)q - spitch); } dp += dpitch; sp += bytes_per_pixel; } break; } case ROTATE_MIRROR_H: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u16_t *)dp; q = (u16_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q--; } dp += dpitch; sp += spitch; } break; } case ROTATE_MIRROR_V: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp -= spitch; } break; } default: return; } } static void software_rotate_3byte(struct surface_t * dst, struct surface_t * src, struct rect_t * rect, enum rotate_type type) { u8_t * dp, * sp; s32_t dx, dy, dw, dh; u32_t dpitch, spitch; u8_t bytes_per_pixel; u32_t len; u8_t * p, * q; dw = dst->w; dh = dst->h; dpitch = dst->pitch; spitch = src->pitch; bytes_per_pixel = src->info.bytes_per_pixel; len = bytes_per_pixel * dw; switch(type) { case ROTATE_DEGREE_0: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp += spitch; } break; } case ROTATE_DEGREE_90: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dh - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = q[0]; *p++ = q[1]; *p++ = q[2]; q += spitch; } dp += dpitch; sp -= bytes_per_pixel; } break; } case ROTATE_DEGREE_180: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = q[0]; *p++ = q[1]; *p++ = q[2]; q -= 3; } dp += dpitch; sp -= spitch; } break; } case ROTATE_DEGREE_270: { dp = dst->pixels; sp = src->pixels + (rect->y + dw - 1) * spitch + rect->x * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = q[0]; *p++ = q[1]; *p++ = q[2]; q -= spitch; } dp += dpitch; sp += bytes_per_pixel; } break; } case ROTATE_MIRROR_H: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u8_t *)dp; q = (u8_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = q[0]; *p++ = q[1]; *p++ = q[2]; q -= 3; } dp += dpitch; sp += spitch; } break; } case ROTATE_MIRROR_V: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp -= spitch; } break; } default: return; } } static void software_rotate_4byte(struct surface_t * dst, struct surface_t * src, struct rect_t * rect, enum rotate_type type) { u8_t * dp, * sp; s32_t dx, dy, dw, dh; u32_t dpitch, spitch; u8_t bytes_per_pixel; u32_t len; u32_t * p, * q; dw = dst->w; dh = dst->h; dpitch = dst->pitch; spitch = src->pitch; bytes_per_pixel = src->info.bytes_per_pixel; len = bytes_per_pixel * dw; switch(type) { case ROTATE_DEGREE_0: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp += spitch; } break; } case ROTATE_DEGREE_90: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dh - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u32_t *)dp; q = (u32_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q; q = (u32_t *)((u8_t *)q + spitch); } dp += dpitch; sp -= bytes_per_pixel; } break; } case ROTATE_DEGREE_180: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u32_t *)dp; q = (u32_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q--; } dp += dpitch; sp -= spitch; } break; } case ROTATE_DEGREE_270: { dp = dst->pixels; sp = src->pixels + (rect->y + dw - 1) * spitch + rect->x * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u32_t *)dp; q = (u32_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q; q = (u32_t *)((u8_t *)q - spitch); } dp += dpitch; sp += bytes_per_pixel; } break; } case ROTATE_MIRROR_H: { dp = dst->pixels; sp = src->pixels + rect->y * spitch + (rect->x + dw - 1) * bytes_per_pixel; for(dy = 0; dy < dh; dy++) { p = (u32_t *)dp; q = (u32_t *)sp; for(dx = 0; dx < dw; dx++) { *p++ = *q--; } dp += dpitch; sp += spitch; } break; } case ROTATE_MIRROR_V: { dp = dst->pixels; sp = src->pixels + (rect->y + dh - 1) * spitch + rect->x * bytes_per_pixel; for (dy = 0; dy < dh; dy++) { memcpy(dp, sp, len); dp += dpitch; sp -= spitch; } break; } default: return; } } struct surface_t * map_software_rotate(struct surface_t * surface, struct rect_t * rect, enum rotate_type type) { struct surface_t * rotate; struct rect_t clipped; u32_t w, h; if(!surface) return NULL; if (!surface->pixels) return NULL; if (surface->info.bits_per_pixel < 8) return NULL; clipped.x = 0; clipped.y = 0; clipped.w = surface->w; clipped.h = surface->h; if(rect) { if (!rect_intersect(rect, &clipped, &clipped)) return NULL; } rect = &clipped; switch(type) { case ROTATE_DEGREE_0: case ROTATE_DEGREE_180: case ROTATE_MIRROR_H: case ROTATE_MIRROR_V: w = rect->w; h = rect->h; break; case ROTATE_DEGREE_90: case ROTATE_DEGREE_270: w = rect->h; h = rect->w; break; default: return NULL; } rotate = surface_alloc(NULL, w, h, surface->info.fmt); if(!rotate) return NULL; switch (surface->info.bytes_per_pixel) { case 1: software_rotate_1byte(rotate, surface, rect, type); break; case 2: software_rotate_2byte(rotate, surface, rect, type); break; case 3: software_rotate_3byte(rotate, surface, rect, type); break; case 4: software_rotate_4byte(rotate, surface, rect, type); break; default: surface_free(rotate); return NULL; } return rotate; }
18.179724
127
0.515505
0bfb75345f7a0d7bf103b52adb61ffe892c85ed7
1,513
h
C
include/config.h
cyrusbuilt/CyGate4
7c31dcc78b614ad5b134e713e4b562032facf44b
[ "MIT" ]
null
null
null
include/config.h
cyrusbuilt/CyGate4
7c31dcc78b614ad5b134e713e4b562032facf44b
[ "MIT" ]
null
null
null
include/config.h
cyrusbuilt/CyGate4
7c31dcc78b614ad5b134e713e4b562032facf44b
[ "MIT" ]
null
null
null
#ifndef _CONFIG_H #define _CONFIG_H #include <IPAddress.h> #define DEBUG #define SUPPORT_OTA #define SUPPORT_MDNS #define DEFAULT_SSID "your_ssid_here" #define DEFAULT_PASSWORD "your_password_here" #define DEFAULT_TIMEZONE -4 #define SERIAL_BAUD 115200 #define CONFIG_FILE_PATH "/config.json" #define DOOR_FILE_PATH "/doors.json" #define CHECK_WIFI_INTERVAL 30000 // How often to check WiFi status (milliseconds). #define CHECK_MQTT_INTERVAL 35000 // How often to check connectivity to the MQTT broker. #define CLOCK_SYNC_INTERVAL 3600000 // How often to sync the local clock with NTP (milliseconds). #define MQTT_TOPIC_STATUS "cygate4/status" #define MQTT_TOPIC_CONTROL "cygate4/control" #define MQTT_BROKER "your_mqtt_host_here" #define MQTT_PORT 1883 #define DEFAULT_HOST_NAME "CYGATE4" #define NTP_POOL "pool.ntp.org" #ifdef SUPPORT_OTA #include <ArduinoOTA.h> #define DEFAULT_OTA_HOST_PORT 8266 #define DEFAULT_OTA_PASSWORD "your_ota_password_here" #endif typedef struct { // Network stuff String hostname; String ssid; String password; IPAddress ip; IPAddress gw; IPAddress sm; IPAddress dns; bool useDhcp; bool mdnsEnable; uint8_t clockTimezone; // MQTT stuff String mqttTopicStatus; String mqttTopicControl; String mqttBroker; String mqttUsername; String mqttPassword; uint16_t mqttPort; // OTA stuff bool otaEnable; uint16_t otaPort; String otaPassword; } config_t; #endif
26.086207
109
0.7462
04294afbd7d879b49e57a9f4b3d101118cd28d46
5,778
c
C
finciones.c
EduardoLlamasRad/C-Utilities
5a23f2604f2ae43c9eda2d5eb4c8dc5a09428932
[ "MIT" ]
2
2019-06-06T19:31:04.000Z
2019-07-30T23:34:20.000Z
finciones.c
EduardoLlamasRad/C-Utilities
5a23f2604f2ae43c9eda2d5eb4c8dc5a09428932
[ "MIT" ]
null
null
null
finciones.c
EduardoLlamasRad/C-Utilities
5a23f2604f2ae43c9eda2d5eb4c8dc5a09428932
[ "MIT" ]
null
null
null
#include <stdio.h> void leer(char s[100][100], int n){ int i; for(i = 0; i < n; i++){ scanf("%s", &s[i]); } return; } void voltea(char s[]){ int c, i, j; for (j = 0; s[j]; j++); for (i = 0, j--; i < j; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } } int revisa(char s[], char t[]){ int i, j, k; for (i = 0; t[i]; i++) { for (j = 0, k = i; t[k] && (t[k] == s[j]); j++, k++); if (!s[j]){ return 1; } } return 0; } void imprime_vector(int a[], int n){ int i; for(i = 0; i < n; i++){ printf("%d\n", a[i]); } return; } void intercambio(int *a, int *b){ int t; t = *a; *a = *b; *b = t; printf("%d %d %d %d\n", a, *a, &a, &(*a)); return; } void imprime_matriz(int m[1000][2000], int filas, int columnas){ int i, j; for(i = 0; i < filas; i++){ for(j = 0; j < columnas; j++){ printf("%d ", m[i][j]); } printf("\n"); } return; } void imprime_intercalada(int m[1000][2000], int filas, int columnas){ int i, j; for(i = 0; i < filas; i++){ if(i%2 != 0){ for(j = columnas-1; j >= 0; j--){ printf("%d ", m[i][j]); } } else{ for(j = 0; j < columnas; j++){ printf("%d ", m[i][j]); } } printf("\n"); } return; } void matriz_volteada(int m[1000][2000], int *fil, int *col){ int i, j, t, volt[1000][2000]; for(i = 0; i < *fil; i++){ for(j = 0; j < *col; j++){ volt[i][j] = m[i][j]; } } for(i = 0; i < *fil; i++){ for(j = 0; j < *col; j++){ m[j][i] = volt[i][j]; } } t = *fil; *fil = *col; *col = t; return; } void imprime_cadenas(const char *s){ while(*s != '\0'){ putchar(*s); s++; } return; } void leer_matriz(int *n, char s[1000][100]){ int i; scanf("%d", &(*n)); for(i = 0; i < *n; i++){ scanf("%s", s[i]); printf("%s\n", s[i]); } return; } void lectura(int mat[100][100], int filas, int columnas){ int i, j; for(i = 0; i < filas; i++){ for(j = 0; j < columnas; j++){ scanf("%d", &mat[i][j]); } } return; } int longitud(char *s){ int cont = 0; while(*s != '\0'){ cont++; s++; } return cont; } int longitud_hard(char *s){ char *t = s; while(*(t++) != '\0'); return t-s-1; } int compara_hard(char *s, char *t){ while(*s != '\0' && *t != '\0' && *(s++) == *(t++)); return *(--s) == *(--t); } int compara_relax(char *s, char *t){ int i; for(i = 0; s[i] != '\0' && t[i] != '\0'; i++){ if(s[i] != t[i]){ return 0; } } return s[i] == '\0' && t[i] == '\0'; } int i, n1 = longitud(s), n2 = longitud(t); if(n1 != n2) return 0; for(i = 0; i < n1; i++){ if(s[i] != t[i]){ return 0; } } return 1; } void buscar(int n, char s[1000][100], char *t){ int i; for(i = 0; i < n; i++){ if(compara_hard(s[i], t)){ printf("Si esta!\n"); return; } } printf("No esta!\n"); return; } void imprimir_lista(int n, char s[1000][100]){ int i; for(i = 0; i < n; i++){ printf("%d) %s %d\n", i, s[i], longitud(s[i])); } return; } void suma2(int A[100][100], int B[100][100], int C[100][100], int filas, int columnas){ int i, j; for(i = 0; i < filas; i++){ for(j = 0; j < columnas; j++){ C[i][j] = A[i][j]+B[i][j]; } } return; } void unir(int a[], int n, int b[], int m, int res[]){ int i; for( i = 0; i < n; i++){ res[i] = a[i]; } for( i = 0; i < m; i++){ res[i + n] = b[i]; } return; } int ordena(int a[], int n){ int j, i, temp; for (i=0;i<n;i++){ for (j=i+1;j<n;j++){ if (a[j] < a[i]){ temp = a[j]; a[j] = a[i]; a[i] = temp; } } printf(" %d", a[i]); } } void insertionSort(int *a, int n){ int i, aux, j; for (i = 1; i < n; i++) { aux = a[i]; j = i-1; while (j >= 0 && a[j] > aux) { a[j+1] = a[j]; j = j-1; } a[j+1] = aux; } } int binary_Search(int vec[], int n, int x){ int inicio, fin, centro; inicio = 0; fin = n-1; while(inicio <= fin){ centro = (inicio + fin)/2; if(x < vec[centro]) fin = centro-1; else if(x > vec[centro]) inicio = centro + 1; else{ return centro; } } return (-1); } int binarySearchS(int *vec, int x,int n){ int inicio, fin, centro; inicio = 0; fin = n-1; while(inicio <= fin){ centro = (inicio + fin)/2; if(x < vec[centro]) fin = centro-1; else if(x > vec[centro]) inicio = centro + 1; else{ printf("Existe una instancia de este numero en la posicion: "); return centro; } } return (-1); //No lo encontro } return; } int diferencias_arreglos(int a1[],int n){ int i; for(i=0;i<n-1;i++){ d[i]=abs(a1[i]-a1[i+1]); } return d[i]; } int palindromo(char s[]){ int i, n = longitud_hard(s); for(i = 0, n = n-1; i < n; i++, n--){ if(s[i] != s[n]) return 0; } return 1; } int suma_vectores( int a[], int n) { int i; int suma; i = 0; suma = 0; while( i < n ) { suma+=a[i]; i++; } printf("%d\n", suma); return suma; } int descarta_repeticion(int o[],int n) { int aux[1000]; int cont,num,i,j=0,k,l=0 ; for (i=0;i<n;i++) { cont=0; num=o[i]; aux[j]=num; j++; for (k=0;k<n;k++) if ( aux[k] == num ) cont++; if(cont == 1 ){ fin[l]=num; l++; } } return fin[i]; } int sumas_arreglo_sin_repe( int a[], int n){ int i=0,j, suma=0; for(j=1;j<=n;j++){ b[j]=j; } while( i < n ) { if(a[i]!=a[i+1]){ suma+=a[i]; } i++; } return suma; }
17.509091
87
0.42783
a44e6f43c0018fc713a69f023c3414d06bad569c
838
h
C
util/stats/hour_counter.h
romange/beeri
60718d0f3133fffdf1500f8844852a79c91d8351
[ "BSD-2-Clause" ]
2
2015-01-07T06:34:25.000Z
2019-01-25T10:11:24.000Z
util/stats/hour_counter.h
romange/beeri
60718d0f3133fffdf1500f8844852a79c91d8351
[ "BSD-2-Clause" ]
null
null
null
util/stats/hour_counter.h
romange/beeri
60718d0f3133fffdf1500f8844852a79c91d8351
[ "BSD-2-Clause" ]
1
2019-01-25T10:11:28.000Z
2019-01-25T10:11:28.000Z
// Copyright 2014, Beeri 15. All rights reserved. // Author: Roman Gershman (romange@gmail.com) // #ifndef _UTIL_HOUR_COUNTER_H #define _UTIL_HOUR_COUNTER_H #include <time.h> #include "base/integral_types.h" namespace util { class HourCounter { uint32 is_set_ : 1; uint32 hour_ : 7; uint32 count_ : 24; public: HourCounter() : is_set_(0), hour_(0), count_(0) {} void Inc() { IncAtTime(time(NULL)); } uint32 value() const { uint8 cur_hour = (time(NULL)/3600) & 127; return is_set_ && (cur_hour == hour_) ? count_ : 0; } void IncAtTime(long secs_epoch) { uint8 cur_hour = (secs_epoch/3600) & 127; if (!is_set_ || hour_ != cur_hour) { is_set_ = 1; hour_ = cur_hour; count_ = 1; } else { ++count_; } } }; } // namespace util #endif // _UTIL_HOUR_COUNTER_H
19.488372
55
0.625298
a8702dd3f98df3742cd632f413afc3a75ecb0770
656
h
C
app/bytereceivetimesdialog.h
pgeorgiev98/5Com
b24e28fc92fa692d5292c29ff22dc312d3fe5cf6
[ "MIT" ]
2
2019-02-21T18:24:08.000Z
2019-03-23T06:29:59.000Z
app/bytereceivetimesdialog.h
pgeorgiev98/5Com
b24e28fc92fa692d5292c29ff22dc312d3fe5cf6
[ "MIT" ]
null
null
null
app/bytereceivetimesdialog.h
pgeorgiev98/5Com
b24e28fc92fa692d5292c29ff22dc312d3fe5cf6
[ "MIT" ]
null
null
null
#ifndef BYTERECEIVETIMESDIALOG_H #define BYTERECEIVETIMESDIALOG_H #include <QDialog> #include <QTime> class QTableWidget; class ByteReceiveTimesDialog : public QDialog { Q_OBJECT public: struct Byte { int ms; unsigned char value; }; explicit ByteReceiveTimesDialog(int height, QWidget *parent = nullptr); int bytesCount() const; const QVector<Byte> &bytes() const; void setFont(QFont font); public slots: void removeFromBegining(int bytesCount); void insertData(const QByteArray &data); void clear(); private: QTime m_startTime; QTableWidget *m_table; int m_rowHeight; QVector<Byte> m_bytes; }; #endif // BYTERECEIVETIMESDIALOG_H
17.72973
72
0.766768
a8c438114323034b75a26ab92fadd4982939373a
2,032
h
C
ssbToolClass/Classes/UtilityClass/HelperManage.h
shishibiao/ssbToolClass
b14ad8b88125fc3474e24731e764d1274574cdb9
[ "MIT" ]
null
null
null
ssbToolClass/Classes/UtilityClass/HelperManage.h
shishibiao/ssbToolClass
b14ad8b88125fc3474e24731e764d1274574cdb9
[ "MIT" ]
null
null
null
ssbToolClass/Classes/UtilityClass/HelperManage.h
shishibiao/ssbToolClass
b14ad8b88125fc3474e24731e764d1274574cdb9
[ "MIT" ]
null
null
null
// // HelperManage.h // demo11 // // Created by apple on 2020/6/22. // Copyright © 2020 ssb. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface HelperManage : NSObject +(HelperManage *)shareHelperManage; #pragma mark - 获取宽、高 /** * * 输入字符串、字体、高度,返回宽度 * retrun 宽度 * @param str 字符串 * @param wordFont 字体 * @param height 高度 * */ + (CGFloat)widthForString:(NSString*)str andFont:(UIFont*)wordFont height:(CGFloat)height; /** * * 输入字符串、字体、宽度,返回高度 * retrun 高度 * @param str 字符串 * @param wordFont 字体 * @param width 高度 * */ + (CGFloat)hightForString:(NSString *)str andFont:(UIFont*)wordFont width:(CGFloat)width; #pragma mark - 时间操作 /** * 两个时间相隔 * @param begintime 开始时间 * @param endtime 结束时间 * retrun CGFloat */ +(CGFloat)begintime:(NSString *)begintime endtime:(NSString *)endtime; #pragma mark - 各种转换类型 /** * * 字符串转字典 * @param jsonString 字符串 * return NSDictionary * */ +(NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString; /** * * 字典转化字符串 * @param dic 字典类型 * return 字符串 */ +(NSString*)dictionaryToJson:(NSDictionary *)dic; /** * * 字符串转数组 * @param symbolStr 分隔符 * return 数组 */ +(NSArray *)turnString:(NSString *)string andsymbol:(NSString *)symbolStr; /** * * 数组转字符串 * @param symbolStr 分隔符 * return 字符串 */ +(NSString *)turnArr:(NSArray *)array andsymbol:(NSString *)symbolStr; #pragma mark - 判断传入的值 /** * * 判断字符串是否为空 YES空 NO不空 * @param aStr 字符串 */ +(BOOL)isBlankString:(NSString *)aStr; /** * * 判断数组为空 YES空 NO不空 * @param arr 数组 * */ +(BOOL)isBlankArr:(NSArray *)arr; /** * * 判断字典为空 YES空 NO不空 * @param dic 字典 */ +(BOOL)isBlankDictionary:(NSDictionary *)dic; #pragma mark - 图片操作 /** * * 获取本地视频第一帧 * @param videoURL url * retrun 图片 * */ +(UIImage *)getImage:(NSString *)videoURL; #pragma mark - 改变行间距和字间距 /** * 改变行间距和字间距 */ -(void)changeSpaceForLabel:(UILabel *)label withLineSpace:(float)lineSpace WordSpace:(float)wordSpace; @end NS_ASSUME_NONNULL_END
15.51145
102
0.662402
a8fa30385a229bfa4ca87f3a39cac71b435e17ae
1,497
c
C
block2/3-MCLennardJones/Source/mc_move.c
Amin-Debabeche/advanced_comput
17175765c5c3d6079e48dc88d8e0a11435e7ec8a
[ "MIT" ]
null
null
null
block2/3-MCLennardJones/Source/mc_move.c
Amin-Debabeche/advanced_comput
17175765c5c3d6079e48dc88d8e0a11435e7ec8a
[ "MIT" ]
null
null
null
block2/3-MCLennardJones/Source/mc_move.c
Amin-Debabeche/advanced_comput
17175765c5c3d6079e48dc88d8e0a11435e7ec8a
[ "MIT" ]
null
null
null
#include <stdlib.h> #include <stdio.h> #include <math.h> #include "system.h" #include "ran_uniform.h" // attempts to displace a randomly selected particle void Mcmove(void) { double EnergyNew,VirialNew,EnergyOld,VirialOld; VECTOR NewPosition; int i; NumberOfAttempts++; // choose a random particle i=NumberOfParticles*RandomNumber(); // calculate old energy EnergyParticle(Positions[i],i,0,&EnergyOld,&VirialOld); // give a random displacement NewPosition.x=Positions[i].x+(RandomNumber()-0.5)*MaximumDisplacement; NewPosition.y=Positions[i].y+(RandomNumber()-0.5)*MaximumDisplacement; NewPosition.z=Positions[i].z+(RandomNumber()-0.5)*MaximumDisplacement; // calculate new energy EnergyParticle(NewPosition,i,0,&EnergyNew,&VirialNew); if(RandomNumber()<exp(-Beta*(EnergyNew-EnergyOld))) { // accept NumberOfAcceptedMoves++; RunningEnergy+=(EnergyNew-EnergyOld); RunningVirial+=(VirialNew-VirialOld); // put particle in simulation box /* if(NewPosition.x<0.0) NewPosition.x+=Box; else if(NewPosition.x>=Box) NewPosition.x-=Box; if(NewPosition.y<0.0) NewPosition.y+=Box; else if(NewPosition.y>=Box) NewPosition.y-=Box; if(NewPosition.z<0.0) NewPosition.z+=Box; else if(NewPosition.z>=Box) NewPosition.z-=Box; */ // update new position Positions[i].x=NewPosition.x; Positions[i].y=NewPosition.y; Positions[i].z=NewPosition.z; } }
24.540984
72
0.678691
601a7368a006c1f9e71418cbb7a41e3d9a0d2967
2,431
h
C
lsp_shiloh/oem/shiloh/common/scan/apps/rollereraseMain.h
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/oem/shiloh/common/scan/apps/rollereraseMain.h
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/oem/shiloh/common/scan/apps/rollereraseMain.h
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
#ifndef ROLLERERASE_MAIN_H_ #define ROLLERERASE_MAIN_H_ int SDH_eraseRoller_init(void); int SDH_eraseRoller_isUse(void); typedef struct erase_roller_MainParam_s { unsigned int scan_job_type; unsigned int pixels_per_row_padded; unsigned int pixels_per_row; unsigned int total_rows; unsigned int BitsPerPixel; unsigned int bytes_per_row; unsigned int scanvar_dpi; unsigned int scanvar_cmode; //regarding roller position unsigned int roller_check_current_mode; unsigned int roller_check_current_row_index; unsigned int roller_1st_buffer_save_point; unsigned int roller_2nd_buffer_save_point; unsigned int roller_1st_check_start_row_index; unsigned int roller_2nd_check_start_row_index; unsigned int roller_1st_check_end_row_index; unsigned int roller_2nd_check_end_row_index; unsigned int roller_1st_check_line_nums; unsigned int roller_2nd_check_line_nums; unsigned int roller_1st_check_line_gaps; unsigned int roller_2nd_check_line_gaps; unsigned int roller_start_col_index; }erase_roller_MainParam_t; typedef struct scan_flatbed_roller_position_s { unsigned int dpi; unsigned int roller_position_1st_start; //REF1_Y unsigned int roller_position_1st_width; //roller_width unsigned int roller_position_1st_height; //roller_height unsigned int roller_position_2nd_start; //REF2_Y unsigned int roller_position_2nd_width; //roller_width unsigned int roller_position_2nd_height; //roller_height int roller_height; int roller_width; int pwl; int pwr; int checklength; int inside; int edgebound; int blackpart; int REF1_X; int REF2_X; int REF1_Y; int REF2_Y; int bgrbound; int paperbound; int roller_inside; }scan_flatbed_roller_position_t; typedef enum { ROLLER_ERASE_CURRENT_MODE_NORMAL = 0, ROLLER_ERASE_CURRENT_MODE_WAIT_1ST_ROLLER = 1, ROLLER_ERASE_CURRENT_MODE_START_1ST_ROLLER = 2, ROLLER_ERASE_CURRENT_MODE_END_1ST_ROLLER = 3, ROLLER_ERASE_CURRENT_MODE_WAIT_2ND_ROLLER = 4, ROLLER_ERASE_CURRENT_MODE_START_2ND_ROLLER = 5, ROLLER_ERASE_CURRENT_MODE_END_2ND_ROLLER = 6, }ROLLER_ERASE_MODE; typedef enum { DATA_RECEIVER_NONE_AFTER_ERASE = 0, DATA_RECEIVER_SCANMAN_AFTER_ERASE = 1, DATA_RECEIVER_MERGEAPP_AFTER_ERASE = 2, }DATA_RECEIVER; typedef enum { ERASE_JOB_TYPE_NONE=0, ERASE_JOB_TYPE_NORMAL=1, ERASE_JOB_TYPE_MERGE=2, } erase_roller_job_type_t; typedef enum { e_HOST_SCAN=0, e_HOST_COPY=1, e_HOST_FAX=2, } erase_roller_host_type_t; #endif
27.942529
57
0.835047
448aec2eb2cdb6fd7614604847f3f783f9b8141f
287
h
C
include/object/git_error_method.h
punkymaniac/phpgit2
780e21d999990bd4cfec96629b719eb4983125b8
[ "MIT" ]
null
null
null
include/object/git_error_method.h
punkymaniac/phpgit2
780e21d999990bd4cfec96629b719eb4983125b8
[ "MIT" ]
null
null
null
include/object/git_error_method.h
punkymaniac/phpgit2
780e21d999990bd4cfec96629b719eb4983125b8
[ "MIT" ]
null
null
null
#ifndef PHPGIT_OBJECT_GIT_ERROR_METHOD_H #define PHPGIT_OBJECT_GIT_ERROR_METHOD_H /** * Magic method __toString * * @access public * * @return string */ PHP_METHOD(GitError, __toString); ZEND_BEGIN_ARG_INFO_EX(arginfo_error_method___toString, 0, 0, 0) ZEND_END_ARG_INFO() #endif
17.9375
64
0.790941
448be523d4422527e539884eed55c62850235e5b
1,068
h
C
apps/ci_lab/fsw/platform_inc/ci_lab_msgids.h
junitas/coreflightexec
fdeb437e3052f4c89632dfcfe540140ddb8c70b3
[ "NASA-1.3" ]
1
2016-05-09T13:07:16.000Z
2016-05-09T13:07:16.000Z
cfe/tools/ci_lab/fsw/platform_inc/ci_lab_msgids.h
SpaceySciences/spacey-cfs
dd4b318843328a7b298f80c68692923c74725ee9
[ "NASA-1.3" ]
null
null
null
cfe/tools/ci_lab/fsw/platform_inc/ci_lab_msgids.h
SpaceySciences/spacey-cfs
dd4b318843328a7b298f80c68692923c74725ee9
[ "NASA-1.3" ]
null
null
null
/************************************************************************ ** File: ** $Id: ci_lab_msgids.h 1.2 2010/09/20 12:27:18GMT-05:00 wmoleski Exp $ ** ** Purpose: ** Define CI Lab Message IDs ** ** Notes: ** ** $Log: ci_lab_msgids.h $ ** Revision 1.2 2010/09/20 12:27:18GMT-05:00 wmoleski ** Modified the CI_LAB, SCH_LAB and TO_LAB applications to use unique message IDs and Pipe Names. The "_LAB" ** was added to all definitions so that a mission can use these "Lab" apps as well as their own mission apps together. ** Revision 1.1 2008/04/30 13:07:18EDT rjmcgraw ** Initial revision ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/ci_lab/fsw/platform_inc/project.pj ** *************************************************************************/ #ifndef _ci_lab_msgids_h_ #define _ci_lab_msgids_h_ #define CI_LAB_CMD_MID 0x1884 #define CI_LAB_SEND_HK_MID 0x1885 #define CI_LAB_HK_TLM_MID 0x0884 #endif /* _ci_lab_msgids_h_ */ /************************/ /* End of File Comment */ /************************/
32.363636
118
0.582397
923c3f4aef5108c6f3979435839c989750c6614e
2,617
c
C
bin/pulse-monitor.c
redoste/dotfiles
01fe3736018ed1e33ba3c436fcde7875efc81229
[ "Unlicense" ]
null
null
null
bin/pulse-monitor.c
redoste/dotfiles
01fe3736018ed1e33ba3c436fcde7875efc81229
[ "Unlicense" ]
null
null
null
bin/pulse-monitor.c
redoste/dotfiles
01fe3736018ed1e33ba3c436fcde7875efc81229
[ "Unlicense" ]
null
null
null
#include <pulse/pulseaudio.h> #include <stdio.h> #include <string.h> #include <unistd.h> static void sink_callback(pa_context* context, const pa_sink_info* info, int eol, void* userdata) { (void)context; (void)userdata; if (eol > 0) return; double volume = ((double)pa_cvolume_avg(&info->volume) / PA_VOLUME_NORM) * 100; if (info->mute) { printf("bV:M% 3.f%%\n", volume); } else { printf("gV:% 3.f%%\n", volume); } fflush(stdout); } static void server_info_callback(pa_context* context, const pa_server_info* info, void* userdata) { (void)userdata; // The default_sink_name is temporarily "@DEFAULT_SINK@" when we change profiles // This breaks stuff if (strcmp(info->default_sink_name, "@DEFAULT_SINK@") != 0) { pa_operation* o = pa_context_get_sink_info_by_name(context, info->default_sink_name, sink_callback, NULL); pa_operation_unref(o); } } inline static void update_status(pa_context* context) { pa_operation* o = pa_context_get_server_info(context, server_info_callback, NULL); pa_operation_unref(o); } static void subscribe_callback(pa_context* context, pa_subscription_event_type_t type, uint32_t idx, void* userdata) { (void)idx; (void)userdata; unsigned int event_facility = type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK; if (event_facility != PA_SUBSCRIPTION_EVENT_SINK && event_facility != PA_SUBSCRIPTION_EVENT_SERVER) { return; } update_status(context); } static void context_callback(pa_context* context, void* userdata) { (void)userdata; pa_context_state_t state = pa_context_get_state(context); if (state != PA_CONTEXT_READY) return; update_status(context); pa_context_set_subscribe_callback(context, subscribe_callback, NULL); pa_operation* o = pa_context_subscribe(context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SERVER, NULL, NULL); pa_operation_unref(o); } static pa_mainloop* try_connecting(void) { pa_mainloop* loop = pa_mainloop_new(); pa_mainloop_api* loop_api = pa_mainloop_get_api(loop); pa_context* context = pa_context_new(loop_api, "Volume Monitor"); if (pa_context_connect(context, NULL, PA_CONTEXT_NOFAIL, NULL) < 0) { printf("bWaiting for pulse...\n"); fflush(stdout); pa_context_unref(context); pa_mainloop_free(loop); sleep(10); return NULL; } pa_context_set_state_callback(context, context_callback, NULL); return loop; } int main(void) { // For some reason i can't get the auto reconnect to work // We'll juste wait for pipewire-pulse to start sleep(5); pa_mainloop* loop = NULL; while (loop == NULL) loop = try_connecting(); int ret; pa_mainloop_run(loop, &ret); return ret; }
26.979381
118
0.748185
f3ab99bcc695caf27aaac21447d62f0dbf443c03
19,752
c
C
mpich-3.3/src/mpi/coll/reduce/reduce.c
ucd-plse/mpi-error-prop
4367df88bcdc4d82c9a65b181d0e639d04962503
[ "BSD-3-Clause" ]
3
2020-05-22T04:17:23.000Z
2020-07-17T04:14:25.000Z
mpich-3.3/src/mpi/coll/reduce/reduce.c
ucd-plse/mpi-error-prop
4367df88bcdc4d82c9a65b181d0e639d04962503
[ "BSD-3-Clause" ]
null
null
null
mpich-3.3/src/mpi/coll/reduce/reduce.c
ucd-plse/mpi-error-prop
4367df88bcdc4d82c9a65b181d0e639d04962503
[ "BSD-3-Clause" ]
null
null
null
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* * * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ #include "mpiimpl.h" /* === BEGIN_MPI_T_CVAR_INFO_BLOCK === cvars: - name : MPIR_CVAR_REDUCE_SHORT_MSG_SIZE category : COLLECTIVE type : int default : 2048 class : device verbosity : MPI_T_VERBOSITY_USER_BASIC scope : MPI_T_SCOPE_ALL_EQ description : >- the short message algorithm will be used if the send buffer size is <= this value (in bytes) - name : MPIR_CVAR_ENABLE_SMP_REDUCE category : COLLECTIVE type : boolean default : true class : device verbosity : MPI_T_VERBOSITY_USER_BASIC scope : MPI_T_SCOPE_ALL_EQ description : >- Enable SMP aware reduce. - name : MPIR_CVAR_MAX_SMP_REDUCE_MSG_SIZE category : COLLECTIVE type : int default : 0 class : device verbosity : MPI_T_VERBOSITY_USER_BASIC scope : MPI_T_SCOPE_ALL_EQ description : >- Maximum message size for which SMP-aware reduce is used. A value of '0' uses SMP-aware reduce for all message sizes. - name : MPIR_CVAR_REDUCE_INTRA_ALGORITHM category : COLLECTIVE type : string default : auto class : device verbosity : MPI_T_VERBOSITY_USER_BASIC scope : MPI_T_SCOPE_ALL_EQ description : |- Variable to select reduce algorithm auto - Internal algorithm selection binomial - Force binomial algorithm nb - Force nonblocking algorithm reduce_scatter_gather - Force reduce scatter gather algorithm - name : MPIR_CVAR_REDUCE_INTER_ALGORITHM category : COLLECTIVE type : string default : auto class : device verbosity : MPI_T_VERBOSITY_USER_BASIC scope : MPI_T_SCOPE_ALL_EQ description : |- Variable to select reduce algorithm auto - Internal algorithm selection local_reduce_remote_send - Force local-reduce-remote-send algorithm nb - Force nonblocking algorithm - name : MPIR_CVAR_REDUCE_DEVICE_COLLECTIVE category : COLLECTIVE type : boolean default : true class : device verbosity : MPI_T_VERBOSITY_USER_BASIC scope : MPI_T_SCOPE_ALL_EQ description : >- If set to true, MPI_Reduce will allow the device to override the MPIR-level collective algorithms. The device still has the option to call the MPIR-level algorithms manually. If set to false, the device-level reduce function will not be called. === END_MPI_T_CVAR_INFO_BLOCK === */ /* -- Begin Profiling Symbol Block for routine MPI_Reduce */ #if defined(HAVE_PRAGMA_WEAK) #pragma weak MPI_Reduce = PMPI_Reduce #elif defined(HAVE_PRAGMA_HP_SEC_DEF) #pragma _HP_SECONDARY_DEF PMPI_Reduce MPI_Reduce #elif defined(HAVE_PRAGMA_CRI_DUP) #pragma _CRI duplicate MPI_Reduce as PMPI_Reduce #elif defined(HAVE_WEAK_ATTRIBUTE) int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) __attribute__ ((weak, alias("PMPI_Reduce"))); #endif /* -- End Profiling Symbol Block */ /* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build the MPI routines */ #ifndef MPICH_MPI_FROM_PMPI #undef MPI_Reduce #define MPI_Reduce PMPI_Reduce /* This is the machine-independent implementation of reduce. The algorithm is: Algorithm: MPI_Reduce For long messages and for builtin ops and if count >= pof2 (where pof2 is the nearest power-of-two less than or equal to the number of processes), we use Rabenseifner's algorithm (see http://www.hlrs.de/organization/par/services/models/mpi/myreduce.html). This algorithm implements the reduce in two steps: first a reduce-scatter, followed by a gather to the root. A recursive-halving algorithm (beginning with processes that are distance 1 apart) is used for the reduce-scatter, and a binomial tree algorithm is used for the gather. The non-power-of-two case is handled by dropping to the nearest lower power-of-two: the first few odd-numbered processes send their data to their left neighbors (rank-1), and the reduce-scatter happens among the remaining power-of-two processes. If the root is one of the excluded processes, then after the reduce-scatter, rank 0 sends its result to the root and exits; the root now acts as rank 0 in the binomial tree algorithm for gather. For the power-of-two case, the cost for the reduce-scatter is lgp.alpha + n.((p-1)/p).beta + n.((p-1)/p).gamma. The cost for the gather to root is lgp.alpha + n.((p-1)/p).beta. Therefore, the total cost is: Cost = 2.lgp.alpha + 2.n.((p-1)/p).beta + n.((p-1)/p).gamma For the non-power-of-two case, assuming the root is not one of the odd-numbered processes that get excluded in the reduce-scatter, Cost = (2.floor(lgp)+1).alpha + (2.((p-1)/p) + 1).n.beta + n.(1+(p-1)/p).gamma For short messages, user-defined ops, and count < pof2, we use a binomial tree algorithm for both short and long messages. Cost = lgp.alpha + n.lgp.beta + n.lgp.gamma We use the binomial tree algorithm in the case of user-defined ops because in this case derived datatypes are allowed, and the user could pass basic datatypes on one process and derived on another as long as the type maps are the same. Breaking up derived datatypes to do the reduce-scatter is tricky. FIXME: Per the MPI-2.1 standard this case is not possible. We should be able to use the reduce-scatter/gather approach as long as count >= pof2. [goodell@ 2009-01-21] Possible improvements: End Algorithm: MPI_Reduce */ #undef FUNCNAME #define FUNCNAME MPIR_Reduce_intra_auto #undef FCNAME #define FCNAME MPL_QUOTE(FUNCNAME) int MPIR_Reduce_intra_auto(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPIR_Comm * comm_ptr, MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; int mpi_errno_ret = MPI_SUCCESS; int is_commutative, type_size, pof2; int nbytes = 0; if (count == 0) return MPI_SUCCESS; /* is the op commutative? We do SMP optimizations only if it is. */ is_commutative = MPIR_Op_is_commutative(op); MPIR_Datatype_get_size_macro(datatype, type_size); nbytes = MPIR_CVAR_MAX_SMP_REDUCE_MSG_SIZE ? type_size * count : 0; if (MPIR_CVAR_ENABLE_SMP_COLLECTIVES && MPIR_CVAR_ENABLE_SMP_REDUCE && MPIR_Comm_is_node_aware(comm_ptr) && is_commutative && nbytes <= MPIR_CVAR_MAX_SMP_REDUCE_MSG_SIZE) { mpi_errno = MPIR_Reduce_intra_smp(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); if (mpi_errno) { /* for communication errors, just record the error but continue */ *errflag = MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(mpi_errno) ? MPIR_ERR_PROC_FAILED : MPIR_ERR_OTHER; MPIR_ERR_SET(mpi_errno, *errflag, "**fail"); MPIR_ERR_ADD(mpi_errno_ret, mpi_errno); } goto fn_exit; } MPIR_Datatype_get_size_macro(datatype, type_size); /* get nearest power-of-two less than or equal to number of ranks in the communicator */ pof2 = comm_ptr->pof2; if ((count * type_size > MPIR_CVAR_REDUCE_SHORT_MSG_SIZE) && (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) && (count >= pof2)) { /* do a reduce-scatter followed by gather to root. */ mpi_errno = MPIR_Reduce_intra_reduce_scatter_gather(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); } else { /* use a binomial tree algorithm */ mpi_errno = MPIR_Reduce_intra_binomial(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); } if (mpi_errno) { /* for communication errors, just record the error but continue */ *errflag = MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(mpi_errno) ? MPIR_ERR_PROC_FAILED : MPIR_ERR_OTHER; MPIR_ERR_SET(mpi_errno, *errflag, "**fail"); MPIR_ERR_ADD(mpi_errno_ret, mpi_errno); } fn_exit: if (mpi_errno_ret) mpi_errno = mpi_errno_ret; else if (*errflag != MPIR_ERR_NONE) MPIR_ERR_SET(mpi_errno, *errflag, "**coll_fail"); return mpi_errno; } #undef FUNCNAME #define FUNCNAME MPIR_Reduce_inter_auto #undef FCNAME #define FCNAME MPL_QUOTE(FUNCNAME) int MPIR_Reduce_inter_auto(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPIR_Comm * comm_ptr, MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; mpi_errno = MPIR_Reduce_inter_local_reduce_remote_send(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); return mpi_errno; } #undef FUNCNAME #define FUNCNAME MPIR_Reduce_impl #undef FCNAME #define FCNAME MPL_QUOTE(FUNCNAME) int MPIR_Reduce_impl(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPIR_Comm * comm_ptr, MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; if (comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM) { /* intracommunicator */ switch (MPIR_Reduce_intra_algo_choice) { case MPIR_REDUCE_INTRA_ALGO_BINOMIAL: mpi_errno = MPIR_Reduce_intra_binomial(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); break; case MPIR_REDUCE_INTRA_ALGO_REDUCE_SCATTER_GATHER: mpi_errno = MPIR_Reduce_intra_reduce_scatter_gather(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); break; case MPIR_REDUCE_INTRA_ALGO_NB: mpi_errno = MPIR_Reduce_allcomm_nb(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); break; case MPIR_REDUCE_INTRA_ALGO_AUTO: MPL_FALLTHROUGH; default: mpi_errno = MPIR_Reduce_intra_auto(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); break; } } else { /* intercommunicator */ switch (MPIR_Reduce_inter_algo_choice) { case MPIR_REDUCE_INTER_ALGO_LOCAL_REDUCE_REMOTE_SEND: mpi_errno = MPIR_Reduce_inter_local_reduce_remote_send(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); break; case MPIR_REDUCE_INTER_ALGO_NB: mpi_errno = MPIR_Reduce_allcomm_nb(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); break; case MPIR_REDUCE_INTER_ALGO_AUTO: MPL_FALLTHROUGH; default: mpi_errno = MPIR_Reduce_inter_auto(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); break; } } if (mpi_errno) MPIR_ERR_POP(mpi_errno); fn_exit: return mpi_errno; fn_fail: goto fn_exit; } #undef FUNCNAME #define FUNCNAME MPIR_Reduce #undef FCNAME #define FCNAME MPL_QUOTE(FUNCNAME) int MPIR_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPIR_Comm * comm_ptr, MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; if (MPIR_CVAR_REDUCE_DEVICE_COLLECTIVE && MPIR_CVAR_DEVICE_COLLECTIVES) { mpi_errno = MPID_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); } else { mpi_errno = MPIR_Reduce_impl(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, errflag); } return mpi_errno; } #endif #undef FUNCNAME #define FUNCNAME MPI_Reduce #undef FCNAME #define FCNAME MPL_QUOTE(FUNCNAME) /*@ MPI_Reduce - Reduces values on all processes to a single value Input Parameters: + sendbuf - address of send buffer (choice) . count - number of elements in send buffer (integer) . datatype - data type of elements of send buffer (handle) . op - reduce operation (handle) . root - rank of root process (integer) - comm - communicator (handle) Output Parameters: . recvbuf - address of receive buffer (choice, significant only at 'root') .N ThreadSafe .N Fortran .N collops .N Errors .N MPI_SUCCESS .N MPI_ERR_COMM .N MPI_ERR_COUNT .N MPI_ERR_TYPE .N MPI_ERR_BUFFER .N MPI_ERR_BUFFER_ALIAS @*/ int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) { int mpi_errno = MPI_SUCCESS; MPIR_Comm *comm_ptr = NULL; MPIR_Errflag_t errflag = MPIR_ERR_NONE; MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_REDUCE); MPIR_ERRTEST_INITIALIZED_ORDIE(); MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX); MPIR_FUNC_TERSE_COLL_ENTER(MPID_STATE_MPI_REDUCE); /* Validate parameters, especially handles needing to be converted */ #ifdef HAVE_ERROR_CHECKING { MPID_BEGIN_ERROR_CHECKS; { MPIR_ERRTEST_COMM(comm, mpi_errno); } MPID_END_ERROR_CHECKS; } #endif /* HAVE_ERROR_CHECKING */ /* Convert MPI object handles to object pointers */ MPIR_Comm_get_ptr(comm, comm_ptr); /* Validate parameters and objects (post conversion) */ #ifdef HAVE_ERROR_CHECKING { MPID_BEGIN_ERROR_CHECKS; { MPIR_Datatype *datatype_ptr = NULL; MPIR_Op *op_ptr = NULL; int rank; MPIR_Comm_valid_ptr(comm_ptr, mpi_errno, FALSE); if (mpi_errno != MPI_SUCCESS) goto fn_fail; if (comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM) { MPIR_ERRTEST_INTRA_ROOT(comm_ptr, root, mpi_errno); MPIR_ERRTEST_COUNT(count, mpi_errno); MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno); if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) { MPIR_Datatype_get_ptr(datatype, datatype_ptr); MPIR_Datatype_valid_ptr(datatype_ptr, mpi_errno); if (mpi_errno != MPI_SUCCESS) goto fn_fail; MPIR_Datatype_committed_ptr(datatype_ptr, mpi_errno); if (mpi_errno != MPI_SUCCESS) goto fn_fail; } if (sendbuf != MPI_IN_PLACE) MPIR_ERRTEST_USERBUFFER(sendbuf, count, datatype, mpi_errno); rank = comm_ptr->rank; if (rank == root) { MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, count, mpi_errno); MPIR_ERRTEST_USERBUFFER(recvbuf, count, datatype, mpi_errno); if (count != 0 && sendbuf != MPI_IN_PLACE) { MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno); } } else MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, count, mpi_errno); } if (comm_ptr->comm_kind == MPIR_COMM_KIND__INTERCOMM) { MPIR_ERRTEST_INTER_ROOT(comm_ptr, root, mpi_errno); if (root == MPI_ROOT) { MPIR_ERRTEST_COUNT(count, mpi_errno); MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno); if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) { MPIR_Datatype_get_ptr(datatype, datatype_ptr); MPIR_Datatype_valid_ptr(datatype_ptr, mpi_errno); if (mpi_errno != MPI_SUCCESS) goto fn_fail; MPIR_Datatype_committed_ptr(datatype_ptr, mpi_errno); if (mpi_errno != MPI_SUCCESS) goto fn_fail; } MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, count, mpi_errno); MPIR_ERRTEST_USERBUFFER(recvbuf, count, datatype, mpi_errno); } else if (root != MPI_PROC_NULL) { MPIR_ERRTEST_COUNT(count, mpi_errno); MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno); if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) { MPIR_Datatype_get_ptr(datatype, datatype_ptr); MPIR_Datatype_valid_ptr(datatype_ptr, mpi_errno); if (mpi_errno != MPI_SUCCESS) goto fn_fail; MPIR_Datatype_committed_ptr(datatype_ptr, mpi_errno); if (mpi_errno != MPI_SUCCESS) goto fn_fail; } MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, count, mpi_errno); MPIR_ERRTEST_USERBUFFER(sendbuf, count, datatype, mpi_errno); } } MPIR_ERRTEST_OP(op, mpi_errno); if (mpi_errno != MPI_SUCCESS) goto fn_fail; if (HANDLE_GET_KIND(op) != HANDLE_KIND_BUILTIN) { MPIR_Op_get_ptr(op, op_ptr); MPIR_Op_valid_ptr(op_ptr, mpi_errno); } if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) { mpi_errno = (*MPIR_OP_HDL_TO_DTYPE_FN(op)) (datatype); } if (mpi_errno != MPI_SUCCESS) goto fn_fail; } MPID_END_ERROR_CHECKS; } #endif /* HAVE_ERROR_CHECKING */ /* ... body of routine ... */ mpi_errno = MPIR_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm_ptr, &errflag); if (mpi_errno) MPIR_ERR_POP(mpi_errno); /* ... end of body of routine ... */ fn_exit: MPIR_FUNC_TERSE_COLL_EXIT(MPID_STATE_MPI_REDUCE); MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX); return mpi_errno; fn_fail: /* --BEGIN ERROR HANDLING-- */ #ifdef HAVE_ERROR_CHECKING { mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_reduce", "**mpi_reduce %p %p %d %D %O %d %C", sendbuf, recvbuf, count, datatype, op, root, comm); } #endif mpi_errno = MPIR_Err_return_comm(comm_ptr, FCNAME, mpi_errno); goto fn_exit; /* --END ERROR HANDLING-- */ }
37.12782
97
0.604344
43572e3750ffff068ea7e7ebb0815ab8bccea849
490
h
C
C++/Data_Structures/DS_Assignments/lab8_james_williams/Lab8_James_Williams/BinaryTree.h
JRW2252/OldProjects
58fb6788b7b08e45e1c29a62987f7af0dd2b8e13
[ "Unlicense" ]
null
null
null
C++/Data_Structures/DS_Assignments/lab8_james_williams/Lab8_James_Williams/BinaryTree.h
JRW2252/OldProjects
58fb6788b7b08e45e1c29a62987f7af0dd2b8e13
[ "Unlicense" ]
null
null
null
C++/Data_Structures/DS_Assignments/lab8_james_williams/Lab8_James_Williams/BinaryTree.h
JRW2252/OldProjects
58fb6788b7b08e45e1c29a62987f7af0dd2b8e13
[ "Unlicense" ]
null
null
null
#include<iostream> #include<fstream> #include<string> #include<stdexcept> #include"BTNode.h" using namespace std; #ifndef BINARY_TREE_H_ #define BINARY_TREE_H_ class BinaryTree{ private: Node* root; void trahsBTNode(Node* r); public: BTNode(); ~BTNode(); bool empty(); int nodeHeight(string s); void insert(char c, string s); void insertNW(char c, string s, Node* r, Node* current, string sub); void printTree(BTNode* root); }; #endif BINARY_TREE_H_
18.846154
70
0.691837
d8e4c81143ae003d000ec3a024befababeb5d750
369
h
C
project2D/MenuState.h
MrGuppy/VersionControlExample2
a13a421a04038f699e669520ff0238f47bbfe24d
[ "MIT" ]
null
null
null
project2D/MenuState.h
MrGuppy/VersionControlExample2
a13a421a04038f699e669520ff0238f47bbfe24d
[ "MIT" ]
null
null
null
project2D/MenuState.h
MrGuppy/VersionControlExample2
a13a421a04038f699e669520ff0238f47bbfe24d
[ "MIT" ]
null
null
null
#pragma once #include "Entity.h" #include "State.h" class MenuState : public State { public: MenuState(); ~MenuState(); void OnEnter(StateMachine* pMachine); void OnUpdate(float deltaTime, StateMachine* pMachine); void OnExit(StateMachine* pMachine); void OnDraw(Renderer2D* m_2dRenderer); private: aie::Font* m_pFont; float m_fTimer; float m_fAlpha; };
16.043478
56
0.737127
94810d328dac1973d086982a0405675fa57d5a35
3,194
h
C
CaptureTheFlag/Public/CaptureTheFlagGameMode.h
DennisSSDev/NetworkedCaptureTheFlagBase
ea4d5cfcac500d109c510af20d426f42a2649111
[ "MIT" ]
1
2019-04-18T12:13:26.000Z
2019-04-18T12:13:26.000Z
CaptureTheFlag/Public/CaptureTheFlagGameMode.h
DennisSSDev/NetworkedCaptureTheFlagBase
ea4d5cfcac500d109c510af20d426f42a2649111
[ "MIT" ]
null
null
null
CaptureTheFlag/Public/CaptureTheFlagGameMode.h
DennisSSDev/NetworkedCaptureTheFlagBase
ea4d5cfcac500d109c510af20d426f42a2649111
[ "MIT" ]
null
null
null
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GameFramework/GameModeBase.h" #include "CaptureTheFlagGameState.h" #include "FlagSpawnPoint.h" #include "TimerManager.h" #include "Flag.h" #include "CaptureTheFlagGameMode.generated.h" class ACaptureTheFlagController; /* Delegates */ DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGameModeEvent); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSpawnEvent, FVector, SpawnPosition); // TODO: In the future, implement a team based mode UENUM(BlueprintType) enum class EGameType : uint8 { FFA UMETA(DisplayName = "Free for All"), Team UMETA(DisplayName = "Team") }; UCLASS(minimalapi) class ACaptureTheFlagGameMode : public AGameModeBase { GENERATED_BODY() /* Initiates the game's restart timer (seamless travel) */ UFUNCTION() void BeginGameRestart(); UFUNCTION() void TickGameRestart(); UFUNCTION() void RestartGame(); UFUNCTION() void SendFrontEndTimer(); /* Increment */ UFUNCTION() void IncrementFlagCapture(); public: ACaptureTheFlagGameMode(); /* How many flags a player needs to win */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay Defaults") int32 WinFlagCount = 2; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay Defaults") float SecondsTillFlagScore = 10.f; /* Free for all or Team based */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay Defaults") EGameType GameModeType = EGameType::FFA; /* Flag that will be spawned */ UPROPERTY(EditDefaultsOnly, Category = "Flag") TSubclassOf<AFlag> FlagBP; UPROPERTY(BlueprintAssignable) FGameModeEvent OnGameWin; UPROPERTY(BlueprintAssignable) FSpawnEvent OnFlagSpawn; /* The player that currently carries the flag */ UPROPERTY() FPlayerData CurrentOwningPlayer; /* The player that won the game */ UPROPERTY() FPlayerData WonPlayer; /* The server side counter till player scores a flag */ UPROPERTY() float FlagCaptureProgress = 0.f; protected: virtual void BeginPlay() override; /* Call this upon player join in game */ virtual void PostLogin(APlayerController* NewPlayer) override; private: UPROPERTY() FTimerHandle GameResetTimer; UPROPERTY() FTimerHandle FlagCaptureTimer; UPROPERTY() float TimeTillGameRestart = -1.f; //All the player scores in the game. Persistent UPROPERTY() TMap<FString, int32> PlayerScores; //Bases UPROPERTY() TArray<AFlagSpawnPoint*> FlagSpawnPoints; //Flag currently being captured UPROPERTY() AFlag* StoredFlag; public: UFUNCTION() const float& GetTimeTillGameRestart() const; UFUNCTION() void SpawnFlag(FVector Location); UFUNCTION() void RespawnPlayer(APawn* Pawn); // When player exits the vehicle, move him right next to the vehicle UFUNCTION() void RespawnPlayerFromVehicle(APawn* Pawn); // Add a point to the specified player name UFUNCTION() bool AddPlayerScore(FString Name); // Start a server side flag capture timer UFUNCTION() void BeginCaptureTimer(FString PlayerName, AFlag* Flag); UFUNCTION() void StopCaptureTimer(); FORCEINLINE UFUNCTION() int32 GetPlayerScore(FString PlayerName) const { return PlayerScores[PlayerName]; }; };
22.814286
85
0.761741
7fc484a05e02a8ac88c8dfad68dc6db77a8bc444
5,562
c
C
mkkeypad.c
ayoul3/wc3270_hacked
255502e451599aeabdb12e560b65861ab8516f4a
[ "BSD-3-Clause" ]
4
2017-04-13T13:34:59.000Z
2019-11-27T08:04:28.000Z
mkkeypad.c
hharte/c3270
3f132b769b205c540d78adb26f36dd0803462c70
[ "BSD-3-Clause" ]
null
null
null
mkkeypad.c
hharte/c3270
3f132b769b205c540d78adb26f36dd0803462c70
[ "BSD-3-Clause" ]
1
2021-04-21T02:11:59.000Z
2021-04-21T02:11:59.000Z
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> /* * Construct keypad data structures from a set of descriptor files. * * The files are: * keypad.labels * literal text to be drawn for the keypad * keypad.outline * outlines for the keys, ACS encoded ('l' for upper left, etc.) * keypad.map * sensitivity map for the keypad (aaaa is field 'a', etc.) * keypad.full * not used by this program, but gives the overall plan * * The result is an array of structures: * unsigned char literal; text from keypad.labels * unsigned char outline; ACS-encoded outline text * sens_t *sens; sensitivity, or NULL * * A sens_t is a structure: * unsigned char ul_x, ul_y; upper left corner * unsigned char lr_x, lr_y; lower right corner * unsigned char callback_name; 'a', 'b', etc. */ typedef struct sensmap { struct sensmap *next; unsigned char name; unsigned ul_x, ul_y, lr_x, lr_y; int index; char *callback; } sensmap_t; sensmap_t *sensmaps = NULL; sensmap_t *last_sensmap = NULL; int sensmap_count = 0; int main(int argc, char *argv[]) { FILE *callbacks; FILE *labels; FILE *outline; FILE *map; int c, d; unsigned x; unsigned y; sensmap_t *s; char buf[128]; int cbl = 0; /* Open the files. */ labels = fopen("keypad.labels", "r"); if (labels == NULL) { perror("keypad.labels"); exit(1); } outline = fopen("keypad.outline", "r"); if (outline == NULL) { perror("keypad.outline"); exit(1); } map = fopen("keypad.map", "r"); if (map == NULL) { perror("keypad.map"); exit(1); } callbacks = fopen("keypad.callbacks", "r"); if (callbacks == NULL) { perror("keypad.callbacks"); exit(1); } /* Read in the map file first. */ x = 0; y = 0; while ((c = fgetc(map)) != EOF) { if (c == '\n') { y++; x = 0; continue; } if (c == ' ') { x++; continue; } for (s = sensmaps; s != NULL; s = s->next) { if (s->name == c) break; } if (s != NULL) { /* Seen it before. */ s->lr_x = x; s->lr_y = y; } else { s = (sensmap_t *)malloc(sizeof(sensmap_t)); if (s == NULL) { fprintf(stderr, "Out of memory.\n"); exit(1); } memset(s, '\0', sizeof(sensmap_t)); s->name = c; s->ul_x = s->lr_x = x; s->ul_y = s->lr_y = y; s->index = sensmap_count++; s->callback = NULL; s->next = NULL; if (last_sensmap) last_sensmap->next = s; else sensmaps = s; last_sensmap = s; last_sensmap = s; } x++; } fclose(map); /* Read in the callbacks. */ while (fgets(buf, sizeof(buf), callbacks) != NULL) { char *t; char c; size_t sl; cbl++; sl = strlen(buf); if (sl > 0 && buf[sl - 1] == '\n') buf[sl - 1] = '\0'; c = buf[0]; if (!isalnum(c)) { fprintf(stderr, "keypad.callbacks:%d Invalid callback character.\n", cbl); exit(1); } t = &buf[1]; while (*t && isspace(*t)) { t++; } if (!*t || !isalnum(*t)) { fprintf(stderr, "keypad.callbacks:%d Invalid callback string.\n", cbl); exit(1); } #if defined(MKK_DEBUG) /*[*/ fprintf(stderr, "line %d: name '%c', callback '%s'\n", cbl, c, t); #endif /*]*/ for (s = sensmaps; s != NULL; s = s->next) { if (s->name == c) { if (s->callback != NULL) { fprintf(stderr, "keypad.callbacks:%d Duplicate callback " "for '%c' (%s, %s).\n", cbl, c, s->callback, t); exit(1); } s->callback = malloc(strlen(t) + 1); if (s->callback == NULL) { fprintf(stderr, "Out of memory.\n"); exit(1); } strcpy(s->callback, t); break; } } if (s == NULL) { fprintf(stderr, "keypad.callbacks:%d: Callback '%c' for " "nonexistent map.\n", cbl, c); exit(1); } } fclose(callbacks); for (s = sensmaps; s != NULL; s = s->next) { if (s->callback == NULL) { fprintf(stderr, "Map '%c' has no callback.\n", s->name); exit(1); } } /* Dump out the sensmaps. */ printf("sens_t sens[%u] = {\n", sensmap_count); for (s = sensmaps; s != NULL; s = s->next) { printf(" { %2u, %2u, %2u, %2u, \"%s\" },\n", s->ul_x, s->ul_y, s->lr_x, s->lr_y, s->callback); } printf("};\n"); /* * Read in the label and outline files, and use them to dump out the * keypad_desc[]. */ labels = fopen("keypad.labels", "r"); if (labels == NULL) { perror("keypad.labels"); exit(1); } outline = fopen("keypad.outline", "r"); if (outline == NULL) { perror("keypad.outline"); exit(1); } printf("keypad_desc_t keypad_desc[%u][80] = {\n", y); printf("{ /* row 0 */\n"); x = 0; y = 0; while ((c = fgetc(labels)) != EOF) { d = fgetc(outline); if (c == '\n') { if (d != '\n') { fprintf(stderr, "labels and outline out of sync at line %d\n", y + 1); exit(1); } y++; x = 0; continue; } if (x == 0 && y != 0) printf("},\n{ /* row %u */\n", y); for (s = sensmaps; s != NULL; s = s->next) { if (x >= s->ul_x && y >= s->ul_y && x <= s->lr_x && y <= s->lr_y) { printf(" { '%c', '%c', &sens[%u] },\n", c, d, s->index); break; } } if (s == NULL) { if (c == ' ' && d == ' ') printf(" { 0, 0, NULL },\n"); else printf(" { '%c', '%c', NULL },\n", c, d); } x++; } if ((d = fgetc(outline)) != EOF) { fprintf(stderr, "labels and outline out of sync at EOF\n"); exit(1); } printf("} };\n"); fclose(labels); fclose(outline); return 0; }
22.248
73
0.522294
964433a5fbba57e00ab18802a3d620f48d2f0bb8
787
h
C
LLProgramFramework/LLProgramFramework/Service/XNetworking/Components/Assistants/XAFRequestGenerator.h
liuniuliuniu/LLProgramFramework
6434efa94ba3f87f1e0b8ce118ccd9a87647b23e
[ "MIT" ]
4
2017-06-27T06:36:39.000Z
2018-11-05T10:52:42.000Z
LLProgramFramework/LLProgramFramework/Service/XNetworking/Components/Assistants/XAFRequestGenerator.h
liuniuliuniu/LLProgramFramework
6434efa94ba3f87f1e0b8ce118ccd9a87647b23e
[ "MIT" ]
null
null
null
LLProgramFramework/LLProgramFramework/Service/XNetworking/Components/Assistants/XAFRequestGenerator.h
liuniuliuniu/LLProgramFramework
6434efa94ba3f87f1e0b8ce118ccd9a87647b23e
[ "MIT" ]
null
null
null
// // XAFRequestGenerator.h // XNetworking // 助手类-生成NSURLRequest // Created by wangxi on 15/6/17. // Copyright (c) 2015年 x. All rights reserved. // #import <Foundation/Foundation.h> @interface XAFRequestGenerator : NSObject + (instancetype)sharedInstance; - (NSURLRequest *)generateGETRequestWithServiceIdentifier:(NSString *)serviceIdentifier requestParams:(NSDictionary *)requestParams methodName:(NSString *)methodName; - (NSURLRequest *)generatePOSTRequestWithServiceIdentifier:(NSString *)serviceIdentifier requestParams:(NSDictionary *)requestParams methodName:(NSString *)methodName; @end
39.35
88
0.609911
d0ff07d77d51f2939c669c46411a5627fd44aefb
1,666
h
C
Source/Source/Tools/SceneEditor/KDlg_TextureStageState.h
uvbs/FullSource
07601c5f18d243fb478735b7bdcb8955598b9a90
[ "MIT" ]
2
2018-07-26T07:58:14.000Z
2019-05-31T14:32:18.000Z
Jx3Full/Source/Source/Tools/SceneEditor/KDlg_TextureStageState.h
RivenZoo/FullSource
cfd7fd7ad422fd2dae5d657a18839c91ff9521fd
[ "MIT" ]
null
null
null
Jx3Full/Source/Source/Tools/SceneEditor/KDlg_TextureStageState.h
RivenZoo/FullSource
cfd7fd7ad422fd2dae5d657a18839c91ff9521fd
[ "MIT" ]
5
2021-02-03T10:25:39.000Z
2022-02-23T07:08:37.000Z
#pragma once #include "afxwin.h" // KDlg_TextureStageState dialog class KDlg_TextureStageState : public CDialog { public: struct TextureStageStateRestore { DWORD ColorOp; DWORD ColorArg1; DWORD ColorArg2; DWORD AlphaOp; DWORD AlphaArg1; DWORD AlphaArg2; }; struct Operation { D3DTEXTUREOP opOperation; TCHAR strDesc[256]; }; struct Arg { DWORD dwArg; TCHAR strDesc[256]; }; DECLARE_DYNAMIC(KDlg_TextureStageState) public: KDlg_TextureStageState(CWnd* pParent = NULL); // standard constructor virtual ~KDlg_TextureStageState(); // Dialog Data enum { IDD = IDD_DIALOG_TEXTURESTAGE }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedButtonRestore(); void Init(DWORD *pdwTextureIDs, CWnd* pParent); TextureStageStateRestore m_RestoreData[8]; //KG3DMaterial::KG3DMaterialSubset* m_pMaterial; DWORD *m_pdwTextureIDs; int m_nNumTexture; public: virtual BOOL OnInitDialog(); CComboBox m_ctlColorOp; CComboBox m_ctlColorArg1; CComboBox m_ctlColorArg2; CComboBox m_ctlAlphaOp; CComboBox m_ctlAlphaArg1; CComboBox m_ctlAlphaArg2; CComboBox m_ctlStage; void FillLists(); }; static KDlg_TextureStageState::Operation Ops[] = { {D3DTOP_DISABLE, "D3DTOP_DISABLE"}, {D3DTOP_SELECTARG1, "D3DTOP_SELECTARG1"}, {D3DTOP_SELECTARG2, "D3DTOP_SELECTARG2"}, }; static KDlg_TextureStageState::Arg Args[] = { {D3DTA_CURRENT, "D3DTA_CURRENT"}, }; KDlg_TextureStageState& g_GetTextureStageStateDlg();
20.072289
73
0.706483
303dab76f414831c25409c17f94923bdf994285c
12,963
h
C
services/service_manager/public/cpp/connector.h
Yannic/chromium
ab32e8aacb08c9fce0dc4bf09eec456ba46e3710
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
76
2020-09-02T03:05:41.000Z
2022-03-30T04:40:55.000Z
services/service_manager/public/cpp/connector.h
blueboxd/chromium-legacy
07223bc94bd97499909c9ed3c3f5769d718fe2e0
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
45
2020-09-02T03:21:37.000Z
2022-03-31T22:19:45.000Z
services/service_manager/public/cpp/connector.h
Yannic/chromium
ab32e8aacb08c9fce0dc4bf09eec456ba46e3710
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
8
2020-07-22T18:49:18.000Z
2022-02-08T10:27:16.000Z
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ #include <map> #include <memory> #include <utility> #include "base/callback.h" #include "base/sequence_checker.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/service_manager/public/cpp/export.h" #include "services/service_manager/public/cpp/identity.h" #include "services/service_manager/public/mojom/connector.mojom.h" #include "services/service_manager/public/mojom/service.mojom-forward.h" #include "services/service_manager/public/mojom/service_manager.mojom-forward.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace service_manager { // An interface that encapsulates the Service Manager's brokering interface, by // which connections between services are established. Once any public methods // are called on an instance of this class, that instance is bound to the // calling thread. // // To use the same interface on another thread, call Clone() and pass the new // instance to the desired thread before calling any public methods on it. class SERVICE_MANAGER_PUBLIC_CPP_EXPORT Connector { public: // DEPRECATED: Do not introduce new uses of this API. Just call the public // *ForTesting methods directly on the Connector. Also see the note on those // methods about preferring TestConnectorFactory where feasible. class TestApi { public: using Binder = base::RepeatingCallback<void(mojo::ScopedMessagePipeHandle)>; explicit TestApi(Connector* connector) : connector_(connector) {} ~TestApi() = default; // Allows caller to specify a callback to bind requests for |interface_name| // from |service_name| locally, rather than passing the request through the // Service Manager. void OverrideBinderForTesting(const service_manager::ServiceFilter& filter, const std::string& interface_name, const Binder& binder) { connector_->OverrideBinderForTesting(filter, interface_name, binder); } bool HasBinderOverride(const service_manager::ServiceFilter& filter, const std::string& interface_name) { return connector_->HasBinderOverrideForTesting(filter, interface_name); } void ClearBinderOverride(const service_manager::ServiceFilter& filter, const std::string& interface_name) { connector_->ClearBinderOverrideForTesting(filter, interface_name); } void ClearBinderOverrides() { connector_->ClearBinderOverridesForTesting(); } private: Connector* connector_; }; explicit Connector(mojo::PendingRemote<mojom::Connector> unbound_state); explicit Connector(mojo::Remote<mojom::Connector> connector); ~Connector(); // Creates a new Connector instance and fills in |*receiver| with a request // for the other end the Connector's interface. static std::unique_ptr<Connector> Create( mojo::PendingReceiver<mojom::Connector>* receiver); // Asks the Service Manager to ensure that there's a running service instance // which would match |filter| from the caller's perspective. Useful when // future |BindInterface()| calls will be made with the same |filter| and // reducing their latency is a high priority. // // Note that there is no value in calling this *immediately* before // |BindInterface()|, so only use it if there is some delay between when you // know you will want to talk to a service and when you actually need to for // the first time. For example, Chrome warms the Network Service ASAP on // startup so that it can be brought up in parallel while the browser is // initializing other subsystems. // // |callback| conveys information about the result of the request. See // documentation on the mojom ConnectResult definition for the meaning of // |result|. If |result| is |SUCCEEDED|, then |identity| will contain the full // identity of the matching service instance, which was either already running // or was started as a result of this request. using WarmServiceCallback = base::OnceCallback<void(mojom::ConnectResult result, const absl::optional<Identity>& identity)>; void WarmService(const ServiceFilter& filter, WarmServiceCallback callback = {}); // Creates an instance of a service for |identity| in a process started by the // client (or someone else). Must be called before any |BindInterface()| // reaches the Service Manager expecting the instance to exist, otherwise the // Service Manager may attempt to start a new instance on its own, which will // invariably fail (if the Service Manager knew how to start the instance, the // caller wouldn't need to use this API). // // NOTE: |identity| must be a complete service Identity (including a random // globally unique ID), and this call will only succeed if the calling service // has set |can_create_other_service_instances| option to |true| in its // manifest. This is considered privileged behavior. using RegisterServiceInstanceCallback = base::OnceCallback<void(mojom::ConnectResult result)>; void RegisterServiceInstance( const Identity& identity, mojo::PendingRemote<mojom::Service> service, mojo::PendingReceiver<mojom::ProcessMetadata> metadata_receiver, RegisterServiceInstanceCallback callback = {}); // Determines if the service for |service_name| is known, and returns // information about it from the catalog. void QueryService(const std::string& service_name, mojom::Connector::QueryServiceCallback callback); // All variants of |Connect()| ask the Service Manager to route a // |mojo::Receiver<T>| for any interface type T to a service instance // identified by a ServiceFilter. If no running service instance matches the // provided ServiceFilter, the Service Manager may start a new instance which // does, before routing the Receiver to it. template <typename Interface> void Connect(const ServiceFilter& filter, mojo::PendingReceiver<Interface> receiver, mojom::BindInterfacePriority priority = mojom::BindInterfacePriority::kImportant) { BindInterface(filter, std::move(receiver), priority); } // A variant of the above which constructs a simple ServiceFilter by service // name only. This will route the Receiver to any available instance of the // named service. template <typename Interface> void Connect(const std::string& service_name, mojo::PendingReceiver<Interface> receiver) { Connect(ServiceFilter::ByName(service_name), std::move(receiver)); } // A variant of the above which take a callback, |callback| conveys // information about the result of the request. See documentation on the mojom // ConnectResult definition for the meaning of |result|. If |result| is // |SUCCEEDED|, then |identity| will contain the full identity of the matching // service instance to which the pending receiver was routed. This service // instance was either already running, or was started as a result of this // request. using BindInterfaceCallback = base::OnceCallback<void(mojom::ConnectResult result, const absl::optional<Identity>& identity)>; template <typename Interface> void Connect(const ServiceFilter& filter, mojo::PendingReceiver<Interface> receiver, BindInterfaceCallback callback) { BindInterface(filter, std::move(receiver), std::move(callback)); } // DEPRECATED: Prefer |Connect()| above. |BindInterface()| uses deprecated // InterfaceRequest and InterfacePtr types. // // All variants of |BindInterface()| ask the Service Manager to route an // interface request to a service instance matching |filter|. If no running // service instance matches |filter|, the Service Manager may start a new // service instance which does, and then route the request to it. See the // comments in connector.mojom regarding restrictions on when the Service // Manager will *not* create a new instance or when |filter| may otherwise be // rejected. // // For variants which take a callback, |callback| conveys information about // the result of the request. See documentation on the mojom ConnectResult // definition for the meaning of |result|. If |result| is |SUCCEEDED|, then // |identity| will contain the full identity of the matching service instance // to which the interface request was routed. This service instance was either // already running, or was started as a result of this request. // // TODO: We should consider removing some of these overloads as they're quite // redundant. It would be cleaner to just have callers explicitly construct a // ServiceFilter and InterfaceRequest rather than having a bunch of template // helpers to do the same in various combinations. The first and last variants // of |BindInterface()| here are sufficient for all use cases. template <typename Interface> void BindInterface(const ServiceFilter& filter, mojo::PendingReceiver<Interface> receiver, BindInterfaceCallback callback = {}) { BindInterface(filter, Interface::Name_, receiver.PassPipe(), mojom::BindInterfacePriority::kImportant, std::move(callback)); } template <typename Interface> void BindInterface(const std::string& service_name, mojo::PendingReceiver<Interface> receiver) { return BindInterface(ServiceFilter::ByName(service_name), std::move(receiver)); } template <typename Interface> void BindInterface(const ServiceFilter& filter, mojo::PendingReceiver<Interface> receiver, mojom::BindInterfacePriority priority) { return BindInterface(filter, Interface::Name_, receiver.PassPipe(), priority, {}); } void BindInterface(const ServiceFilter& filter, const std::string& interface_name, mojo::ScopedMessagePipeHandle interface_pipe, BindInterfaceCallback callback = {}) { BindInterface(filter, interface_name, std::move(interface_pipe), mojom::BindInterfacePriority::kImportant, std::move(callback)); } void BindInterface(const ServiceFilter& filter, const std::string& interface_name, mojo::ScopedMessagePipeHandle interface_pipe, mojom::BindInterfacePriority priority, BindInterfaceCallback callback); // Creates a new instance of this class which may be passed to another thread. // The returned object may be passed across sequences until any of its public // methods are called, at which point it becomes bound to the calling // sequence. std::unique_ptr<Connector> Clone(); // Returns |true| if this Connector instance is already bound to a thread. bool IsBound() const; // Binds a Connector receiver to the other end of this Connector. void BindConnectorReceiver(mojo::PendingReceiver<mojom::Connector> receiver); base::WeakPtr<Connector> GetWeakPtr(); // Test-only methods for interception of requests on Connectors. Consider // using TestConnectorFactory to create and inject fake Connectors into // production code instead of using these methods to monkey-patch existing // Connector objects. void OverrideBinderForTesting(const service_manager::ServiceFilter& filter, const std::string& interface_name, const TestApi::Binder& binder); bool HasBinderOverrideForTesting(const service_manager::ServiceFilter& filter, const std::string& interface_name); void ClearBinderOverrideForTesting( const service_manager::ServiceFilter& filter, const std::string& interface_name); void ClearBinderOverridesForTesting(); private: using BinderOverrideMap = std::map<std::string, TestApi::Binder>; void OnConnectionError(); bool BindConnectorIfNecessary(); mojo::PendingRemote<mojom::Connector> unbound_state_; mojo::Remote<mojom::Connector> connector_; SEQUENCE_CHECKER(sequence_checker_); std::map<service_manager::ServiceFilter, BinderOverrideMap> local_binder_overrides_; base::WeakPtrFactory<Connector> weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(Connector); }; } // namespace service_manager #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_
47.310219
80
0.716809
cf141b20f8219c4da84b844924055987cc7a57be
10,562
h
C
runtime/bin/process.h
johnmcconnell/dartlang-sdk
b3a688a9c692fa769f48472e850a258e6cec152d
[ "BSD-Source-Code" ]
2
2021-06-29T14:03:23.000Z
2021-10-02T12:44:13.000Z
runtime/bin/process.h
johnmcconnell/dartlang-sdk
b3a688a9c692fa769f48472e850a258e6cec152d
[ "BSD-Source-Code" ]
null
null
null
runtime/bin/process.h
johnmcconnell/dartlang-sdk
b3a688a9c692fa769f48472e850a258e6cec152d
[ "BSD-Source-Code" ]
null
null
null
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. #ifndef RUNTIME_BIN_PROCESS_H_ #define RUNTIME_BIN_PROCESS_H_ #include <errno.h> #include "bin/builtin.h" #include "bin/io_buffer.h" #include "bin/lockers.h" #include "bin/namespace.h" #include "bin/thread.h" #include "platform/globals.h" #if !defined(HOST_OS_WINDOWS) #include "platform/signal_blocker.h" #endif #include "platform/utils.h" namespace dart { namespace bin { class ProcessResult { public: ProcessResult() : exit_code_(0) {} void set_stdout_data(Dart_Handle stdout_data) { stdout_data_ = stdout_data; } void set_stderr_data(Dart_Handle stderr_data) { stderr_data_ = stderr_data; } void set_exit_code(intptr_t exit_code) { exit_code_ = exit_code; } Dart_Handle stdout_data() { return stdout_data_; } Dart_Handle stderr_data() { return stderr_data_; } intptr_t exit_code() { return exit_code_; } private: Dart_Handle stdout_data_; Dart_Handle stderr_data_; intptr_t exit_code_; DISALLOW_ALLOCATION(); }; // To be kept in sync with ProcessSignal consts in sdk/lib/io/process.dart // Note that this map is as on Linux. enum ProcessSignals { kSighup = 1, kSigint = 2, kSigquit = 3, kSigill = 4, kSigtrap = 5, kSigabrt = 6, kSigbus = 7, kSigfpe = 8, kSigkill = 9, kSigusr1 = 10, kSigsegv = 11, kSigusr2 = 12, kSigpipe = 13, kSigalrm = 14, kSigterm = 15, kSigchld = 17, kSigcont = 18, kSigstop = 19, kSigtstp = 20, kSigttin = 21, kSigttou = 22, kSigurg = 23, kSigxcpu = 24, kSigxfsz = 25, kSigvtalrm = 26, kSigprof = 27, kSigwinch = 28, kSigpoll = 29, kSigsys = 31, kLastSignal = kSigsys, }; // To be kept in sync with ProcessStartMode consts in sdk/lib/io/process.dart. enum ProcessStartMode { kNormal = 0, kInheritStdio = 1, kDetached = 2, kDetachedWithStdio = 3, }; class Process { public: static void Init(); static void Cleanup(); // Start a new process providing access to stdin, stdout, stderr and // process exit streams. static int Start(Namespace* namespc, const char* path, char* arguments[], intptr_t arguments_length, const char* working_directory, char* environment[], intptr_t environment_length, ProcessStartMode mode, intptr_t* in, intptr_t* out, intptr_t* err, intptr_t* id, intptr_t* exit_handler, char** os_error_message); static bool Wait(intptr_t id, intptr_t in, intptr_t out, intptr_t err, intptr_t exit_handler, ProcessResult* result); // Kill a process with a given pid. static bool Kill(intptr_t id, int signal); // Terminate the exit code handler thread. Does not return before // the thread has terminated. static void TerminateExitCodeHandler(); static int GlobalExitCode() { MutexLocker ml(global_exit_code_mutex_); return global_exit_code_; } static void SetGlobalExitCode(int exit_code) { MutexLocker ml(global_exit_code_mutex_); global_exit_code_ = exit_code; } typedef void (*ExitHook)(int64_t exit_code); static void SetExitHook(ExitHook hook) { exit_hook_ = hook; } static void RunExitHook(int64_t exit_code) { if (exit_hook_ != NULL) { exit_hook_(exit_code); } } static intptr_t CurrentProcessId(); static intptr_t SetSignalHandler(intptr_t signal); // When there is a current Isolate and the 'port' argument is // Dart_GetMainPortId(), this clears the signal handler for the current // isolate. When 'port' is ILLEGAL_PORT, this clears all signal handlers for // 'signal' for all Isolates. static void ClearSignalHandler(intptr_t signal, Dart_Port port); static void ClearSignalHandlerByFd(intptr_t fd, Dart_Port port); static void ClearAllSignalHandlers(); static Dart_Handle GetProcessIdNativeField(Dart_Handle process, intptr_t* pid); static Dart_Handle SetProcessIdNativeField(Dart_Handle process, intptr_t pid); static int64_t CurrentRSS(); static int64_t MaxRSS(); static void GetRSSInformation(int64_t* max_rss, int64_t* current_rss); static bool ModeIsAttached(ProcessStartMode mode); static bool ModeHasStdio(ProcessStartMode mode); private: static int global_exit_code_; static Mutex* global_exit_code_mutex_; static ExitHook exit_hook_; DISALLOW_ALLOCATION(); DISALLOW_IMPLICIT_CONSTRUCTORS(Process); }; typedef void (*sa_handler_t)(int); class SignalInfo { public: SignalInfo(intptr_t fd, intptr_t signal, sa_handler_t oldact, SignalInfo* next) : fd_(fd), signal_(signal), oldact_(oldact), // SignalInfo is expected to be created when in a isolate. port_(Dart_GetMainPortId()), next_(next), prev_(NULL) { if (next_ != NULL) { next_->prev_ = this; } } ~SignalInfo(); void Unlink() { if (prev_ != NULL) { prev_->next_ = next_; } if (next_ != NULL) { next_->prev_ = prev_; } } intptr_t fd() const { return fd_; } intptr_t signal() const { return signal_; } sa_handler_t oldact() const { return oldact_; } Dart_Port port() const { return port_; } SignalInfo* next() const { return next_; } private: intptr_t fd_; intptr_t signal_; sa_handler_t oldact_; // The port_ is used to identify what isolate the signal-info belongs to. Dart_Port port_; SignalInfo* next_; SignalInfo* prev_; DISALLOW_COPY_AND_ASSIGN(SignalInfo); }; // Utility class for collecting the output when running a process // synchronously by using Process::Wait. This class is sub-classed in // the platform specific files to implement reading into the buffers // allocated. class BufferListBase { protected: static const intptr_t kBufferSize = 16 * 1024; class BufferListNode { public: explicit BufferListNode(intptr_t size) { data_ = new uint8_t[size]; // We check for a failed allocation below in Allocate() next_ = NULL; } ~BufferListNode() { delete[] data_; } bool Valid() const { return data_ != NULL; } uint8_t* data() const { return data_; } BufferListNode* next() const { return next_; } void set_next(BufferListNode* n) { next_ = n; } private: uint8_t* data_; BufferListNode* next_; DISALLOW_IMPLICIT_CONSTRUCTORS(BufferListNode); }; public: BufferListBase() : head_(NULL), tail_(NULL), data_size_(0), free_size_(0) {} ~BufferListBase() { Free(); DEBUG_ASSERT(IsEmpty()); } // Returns the collected data as a Uint8List. If an error occours an // error handle is returned. Dart_Handle GetData() { uint8_t* buffer; intptr_t buffer_position = 0; Dart_Handle result = IOBuffer::Allocate(data_size_, &buffer); if (Dart_IsNull(result)) { return DartUtils::NewDartOSError(); } if (Dart_IsError(result)) { Free(); return result; } for (BufferListNode* current = head_; current != NULL; current = current->next()) { intptr_t to_copy = dart::Utils::Minimum(data_size_, kBufferSize); memmove(buffer + buffer_position, current->data(), to_copy); buffer_position += to_copy; data_size_ -= to_copy; } ASSERT(data_size_ == 0); Free(); return result; } #if defined(DEBUG) bool IsEmpty() const { return (head_ == NULL) && (tail_ == NULL); } #endif protected: bool Allocate() { ASSERT(free_size_ == 0); BufferListNode* node = new BufferListNode(kBufferSize); if ((node == NULL) || !node->Valid()) { // Failed to allocate a buffer for the node. delete node; return false; } if (head_ == NULL) { head_ = node; tail_ = node; } else { ASSERT(tail_->next() == NULL); tail_->set_next(node); tail_ = node; } free_size_ = kBufferSize; return true; } void Free() { BufferListNode* current = head_; while (current != NULL) { BufferListNode* tmp = current; current = current->next(); delete tmp; } head_ = NULL; tail_ = NULL; data_size_ = 0; free_size_ = 0; } // Returns the address of the first byte in the free space. uint8_t* FreeSpaceAddress() { return tail_->data() + (kBufferSize - free_size_); } intptr_t data_size() const { return data_size_; } void set_data_size(intptr_t size) { data_size_ = size; } intptr_t free_size() const { return free_size_; } void set_free_size(intptr_t size) { free_size_ = size; } BufferListNode* head() const { return head_; } BufferListNode* tail() const { return tail_; } private: // Linked list for data collected. BufferListNode* head_; BufferListNode* tail_; // Number of bytes of data collected in the linked list. intptr_t data_size_; // Number of free bytes in the last node in the list. intptr_t free_size_; DISALLOW_COPY_AND_ASSIGN(BufferListBase); }; #if defined(HOST_OS_ANDROID) || defined(HOST_OS_FUCHSIA) || \ defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) class BufferList : public BufferListBase { public: BufferList() {} bool Read(int fd, intptr_t available) { // Read all available bytes. while (available > 0) { if (free_size() == 0) { if (!Allocate()) { errno = ENOMEM; return false; } } ASSERT(free_size() > 0); ASSERT(free_size() <= kBufferSize); intptr_t block_size = dart::Utils::Minimum(free_size(), available); #if defined(HOST_OS_FUCHSIA) intptr_t bytes = NO_RETRY_EXPECTED( read(fd, reinterpret_cast<void*>(FreeSpaceAddress()), block_size)); #else intptr_t bytes = TEMP_FAILURE_RETRY( read(fd, reinterpret_cast<void*>(FreeSpaceAddress()), block_size)); #endif // defined(HOST_OS_FUCHSIA) if (bytes < 0) { return false; } set_data_size(data_size() + bytes); set_free_size(free_size() - bytes); available -= bytes; } return true; } private: DISALLOW_COPY_AND_ASSIGN(BufferList); }; #endif // defined(HOST_OS_ANDROID) ... } // namespace bin } // namespace dart #endif // RUNTIME_BIN_PROCESS_H_
26.739241
80
0.653475
65f28b00306004f11c3ccadf3cd99da41c8809e8
794
h
C
IMGPickerManagerDemo/IMGPickerManager/UIImage+IMGMultiFormat.h
TongFangyuan/FYImageManager
171ea64a78cbe7a947705c75227f27deeaf363eb
[ "MIT" ]
null
null
null
IMGPickerManagerDemo/IMGPickerManager/UIImage+IMGMultiFormat.h
TongFangyuan/FYImageManager
171ea64a78cbe7a947705c75227f27deeaf363eb
[ "MIT" ]
null
null
null
IMGPickerManagerDemo/IMGPickerManager/UIImage+IMGMultiFormat.h
TongFangyuan/FYImageManager
171ea64a78cbe7a947705c75227f27deeaf363eb
[ "MIT" ]
null
null
null
// // UIImage+IMGMultiFormat.h // IMGPickerManagerDemo // // Created by admin on 2018/5/16. // Copyright © 2018年 tongfangyuan. All rights reserved. // #import <UIKit/UIKit.h> @interface UIImage (IMGMultiFormat) /** * UIKit: * For static image format, this value is always 0. * For animated image format, 0 means infinite looping. * Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. * AppKit: * NSImage currently only support animated via GIF imageRep unlike UIImage. * The getter of this property will get the loop count from GIF imageRep * The setter of this property will set the loop count from GIF imageRep */ @property (nonatomic, assign) NSUInteger img_imageLoopCount; @end
30.538462
149
0.753149
d08852bb7bcf7b18c3dd19fd9a7a2e6b60db8b90
15,880
h
C
src/CoviMAC/Zones/Zone_CoviMAC.h
pledac/trust-code
46ab5c5da3f674185f53423090f526a38ecdbad1
[ "BSD-3-Clause" ]
1
2021-10-04T09:20:19.000Z
2021-10-04T09:20:19.000Z
src/CoviMAC/Zones/Zone_CoviMAC.h
pledac/trust-code
46ab5c5da3f674185f53423090f526a38ecdbad1
[ "BSD-3-Clause" ]
null
null
null
src/CoviMAC/Zones/Zone_CoviMAC.h
pledac/trust-code
46ab5c5da3f674185f53423090f526a38ecdbad1
[ "BSD-3-Clause" ]
null
null
null
/**************************************************************************** * Copyright (c) 2015, CEA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ ////////////////////////////////////////////////////////////////////////////// // // File: Zone_CoviMAC.h // Directory: $TRUST_ROOT/src/CoviMAC/Zones // Version: 1 // ////////////////////////////////////////////////////////////////////////////// #ifndef Zone_CoviMAC_included #define Zone_CoviMAC_included #include <math.h> #include <Zone_VF.h> #include <Elem_CoviMAC.h> #include <Domaine.h> #include <Static_Int_Lists.h> #include <IntLists.h> #include <Conds_lim.h> #include <Matrice_Morse_Sym.h> #include <SolveurSys.h> #include <DoubleTrav.h> #include <IntTrav.h> #include <Lapack.h> #include <array> #include <Periodique.h> #include <Neumann_sortie_libre.h> #include <Neumann_homogene.h> #include <Dirichlet.h> #include <Symetrie.h> #include <Echange_global_impose.h> #include <Champ_front_var_instationnaire.h> #include <vector> #include <map> #include <string> #ifndef __clang__ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif class Geometrie; // // .DESCRIPTION class Zone_CoviMAC // // Classe instanciable qui derive de Zone_VF. // Cette classe contient les informations geometriques que demande // la methode des Volumes Elements Finis (element de Crouzeix-Raviart) // La classe porte un certain nombre d'informations concernant les faces // Dans cet ensemble de faces on fait figurer aussi les faces du bord et // des joints. Pour manipuler les faces on distingue 2 categories: // - les faces non standard qui sont sur un joint, un bord ou qui sont // internes tout en appartenant a un element du bord // - les faces standard qui sont les faces internes n'appartenant pas // a un element du bord // Cette distinction correspond au traitement des conditions aux limites:les // faces standard ne "voient pas" les conditions aux limites. // L'ensemble des faces est numerote comme suit: // - les faces qui sont sur une Zone_joint apparaissent en premier // (dans l'ordre du vecteur les_joints) // - les faces qui sont sur une Zone_bord apparaissent ensuite // (dans l'ordre du vecteur les_bords) // - les faces internes non standard apparaissent ensuite // - les faces internes standard en dernier // Finalement on trouve regroupees en premier toutes les faces non standard // qui vont necessiter un traitement particulier // On distingue deux types d'elements // - les elements non standard : ils ont au moins une face de bord // - les elements standard : ils n'ont pas de face de bord // Les elements standard (resp. les elements non standard) ne sont pas ranges // de maniere consecutive dans l'objet Zone. On utilise le tableau // rang_elem_non_std pour acceder de maniere selective a l'un ou // l'autre des types d'elements // // class Zone_CoviMAC : public Zone_VF { Declare_instanciable(Zone_CoviMAC); public : void typer_elem(Zone& zone_geom); void discretiser(); virtual void reordonner(Faces&); void modifier_pour_Cl(const Conds_lim& ) { }; inline const Elem_CoviMAC& type_elem() const; inline int nb_elem_Cl() const; inline int nb_faces_joint() const; inline int nb_faces_std() const; inline int nb_elem_std() const; inline double carre_pas_du_maillage() const; inline double carre_pas_maille(int i) const { return h_carre_(i); }; inline double face_normales(int,int ) const; inline DoubleTab& face_normales(); inline const DoubleTab& face_normales() const; inline IntVect& rang_elem_non_std(); inline const IntVect& rang_elem_non_std() const; inline int oriente_normale(int face_opp, int elem2)const; inline const ArrOfInt& ind_faces_virt_non_std() const; void calculer_h_carre(); inline DoubleTab& volumes_entrelaces_dir(); inline const DoubleTab& volumes_entrelaces_dir() const; inline double dot (const double *a, const double *b, const double *ma = NULL, const double *mb = NULL) const; inline std::array<double, 3> cross(int dima, int dimb, const double *a, const double *b, const double *ma = NULL, const double *mb = NULL) const; inline double dist_norm(int num_face) const; inline double dist_norm_bord(int num_face) const; DoubleVect& dist_norm_bord(DoubleVect& , const Nom& nom_bord) const; inline double dist_face_elem0(int num_face,int n0) const; inline double dist_face_elem1(int num_face,int n1) const; inline double dist_face_elem0_period(int num_face,int n0,double l) const; inline double dist_face_elem1_period(int num_face,int n1,double l) const; void detecter_faces_non_planes() const; //quelles structures optionelles on a initialise mutable std::map<std::string, int> is_init; //faces "equivalentes" : equiv(f, 0/1, i) = face equivalente a e_f(f_e(f, 0/1), i) de l'autre cote, -1 si il n'y en a pas void init_equiv() const; mutable IntTab equiv; //interpolations d'ordre 1 du vecteur vitesse aux elements void init_ve() const; mutable IntTab ved, vej; //reconstruction de ve par (vej, vec)[ved(e), ved(e + 1)[ (faces) mutable DoubleTab vec; //elements et faces de bord connectes a chaque face en dehors de l'amont/aval : //fef_j([fef_d(f), fef_d(f + 1)[) (offset de nb_elem_tot() pour les faces de bord) void init_feb() const; mutable IntTab febf_d, febf_j, febs_d, febs_j, feb_d, feb_j; //equivalent de dot(), mais pour le produit (a - ma).nu.(b - mb) inline double nu_dot(const DoubleTab* nu, int e, int n, int N, const double *a, const double *b, const double *ma = NULL, const double *mb = NULL) const; //pour un champ T aux elements, interpole |f| nu.grad T aux faces [0, f_max[; indices donnes par fef_e, fef_f //optionellement, remplit les coordonnes des points aux bords correspondant au flux a deux points void fgrad(int f_max, const DoubleTab* nu, IntTab& phif_d, IntTab& phif_j, DoubleTab& phif_c, DoubleTab *pxfb = NULL) const; //pour un champ T aux elements, interpole |e| grad T aux elements (combine fgrad + ve) //fcl / tcl renseignent les CLs : tcl[fcl(f, 0)] = 1 (Neumann) / 2 (Dirichlet) //dependance en les Te / Tb / dTb dans egrad_(j/c)([egrad_d(e), egrad_d(e + 1)[) void egrad(const IntTab& fcl, const std::vector<int>& is_flux, const DoubleTab *nu, int N, IntTab& egrad_d, IntTab& egrad_j, DoubleTab& egrad_c, DoubleTab *pxfb = NULL) const; //MD_Vectors pour Champ_Face_CoviMAC (faces + d x elems) MD_Vector mdv_ch_face; private: double h_carre; // carre du pas du maillage DoubleVect h_carre_; // carre du pas d'une maille Elem_CoviMAC type_elem_; // type de l'element de discretisation DoubleTab face_normales_; // normales aux faces int nb_faces_std_; // nombre de faces standard int nb_elem_std_; // nombre d'elements standard IntVect rang_elem_non_std_; // rang_elem_non_std_= -1 si l'element est standard // rang_elem_non_std_= rang de l'element dans les tableaux // relatifs aux elements non standards ArrOfInt ind_faces_virt_non_std_; // contient les indices des faces virtuelles non standard void remplir_elem_faces() {}; Sortie& ecrit(Sortie& os) const; void creer_faces_virtuelles_non_std(); }; // Fonctions inline // Decription: // renvoie le type d'element utilise. inline const Elem_CoviMAC& Zone_CoviMAC::type_elem() const { return type_elem_; } // Decription: // renvoie la composante comp de la surface normale a la face. inline double Zone_CoviMAC::face_normales(int face,int comp) const { return face_normales_(face,comp); } // Decription: // renvoie le tableau des surfaces normales. inline DoubleTab& Zone_CoviMAC::face_normales() { return face_normales_; } // Decription: // renvoie le tableau des surfaces normales. inline const DoubleTab& Zone_CoviMAC::face_normales() const { return face_normales_; } // Decription: // renvoie le tableau des volumes entrelaces par cote. inline DoubleTab& Zone_CoviMAC::volumes_entrelaces_dir() { return volumes_entrelaces_dir_; } // Decription: // renvoie le tableau des surfaces normales. inline const DoubleTab& Zone_CoviMAC::volumes_entrelaces_dir() const { return volumes_entrelaces_dir_; } // Decription: inline IntVect& Zone_CoviMAC::rang_elem_non_std() { return rang_elem_non_std_; } // Decription: inline const IntVect& Zone_CoviMAC::rang_elem_non_std() const { return rang_elem_non_std_; } // Decription: inline int Zone_CoviMAC::nb_faces_joint() const { return 0; // return nb_faces_joint_; A FAIRE } // Decription: inline int Zone_CoviMAC::nb_faces_std() const { return nb_faces_std_; } // Decription: inline int Zone_CoviMAC::nb_elem_std() const { return nb_elem_std_; } // Decription: inline int Zone_CoviMAC::nb_elem_Cl() const { return nb_elem() - nb_elem_std_; } // Decription: inline double Zone_CoviMAC::carre_pas_du_maillage() const { return h_carre; } // Decription: inline int Zone_CoviMAC::oriente_normale(int face_opp, int elem2) const { if(face_voisins(face_opp,0)==elem2) return 1; else return -1; } // Decription: // Renvoie le tableau des indices des faces virtuelles non standard //inline const VECT(ArrOfInt)& Zone_CoviMAC::faces_virt_non_std() const //{ // return faces_virt_non_std_; //} // Decription: // Renvoie le tableau des indices des faces distantes non standard inline const ArrOfInt& Zone_CoviMAC::ind_faces_virt_non_std() const { return ind_faces_virt_non_std_; } /* produit scalaire de deux vecteurs */ inline double Zone_CoviMAC::dot(const double *a, const double *b, const double *ma, const double *mb) const { double res = 0; for (int i = 0; i < dimension; i++) res += (a[i] - (ma ? ma[i] : 0)) * (b[i] - (mb ? mb[i] : 0)); return res; } /* produit vectoriel de deux vecteurs (toujours 3D, meme en 2D) */ inline std::array<double, 3> Zone_CoviMAC::cross(int dima, int dimb, const double *a, const double *b, const double *ma, const double *mb) const { std::array<double, 3> va = {{ 0, 0, 0 }}, vb = {{ 0, 0, 0 }}, res; for (int i = 0; i < dima; i++) va[i] = a[i] - (ma ? ma[i] : 0); for (int i = 0; i < dimb; i++) vb[i] = b[i] - (mb ? mb[i] : 0); for (int i = 0; i < 3; i++) res[i] = va[(i + 1) % 3] * vb[(i + 2) % 3] - va[(i + 2) % 3] * vb[(i + 1) % 3]; return res; } /* produit matricel et transposee de DoubleTab */ static inline DoubleTab prod(DoubleTab a, DoubleTab b) { int i, j, k, m = a.dimension(0), n = a.dimension(1), p = b.dimension(1); assert(n == b.dimension(0)); DoubleTab r(m, p); for (i = 0; i < m; i++) for (j = 0; j < n; j++) for (k = 0; k < p; k++) r(i, k) += a(i, j) * b(j, k); return r; } static inline DoubleTab transp(DoubleTab a) { int i, j, m = a.dimension(0), n = a.dimension(1); DoubleTab r(n, m); for (i = 0; i < m; i++) for (j = 0; j < n; j++) r(j, i) = a(i, j); return r; } /* minimise ||M.x - b||_2, met le noyau de M dans P et retourne le residu */ static inline double kersol(const DoubleTab& M, DoubleTab& b, double eps, DoubleTab *P, DoubleTab& x, DoubleTab& S) { int i, nk, m = M.dimension(0), n = M.dimension(1), k = min(m, n), l = max(m, n), w = 5 * l, info, iP, jP; double res2 = 0; char a = 'A'; //lapack en mode Fortran -> on decompose en fait Mt!! DoubleTab A = M, U(m, m), Vt(n, n), W(w), iS(n, m); S.resize(k); F77NAME(dgesvd)(&a, &a, &n, &m, A.addr(), &n, S.addr(), Vt.addr(), &n, U.addr(), &m, W.addr(), &w, &info); for (i = 0, nk = n; i < k && S(i) > eps * S(0); i++) nk--; if (P) P->resize(n, nk); for (i = 0, jP = -1; i < n; i++) if (i < k && S(i) > eps * S(0)) iS(i, i) = 1 / S(i); //terme diagonal de iS else if (P) for (iP = 0, jP++; iP < n; iP++) (*P)(iP, jP) = Vt(i, iP); //colonne de V -> colonne de P x = prod(transp(Vt), prod(iS, prod(transp(U), b))); DoubleTab res = prod(M, x); for (i = 0; i < m; i++) res2 += std::pow(res(i, 0) - b(i, 0), 2); return sqrt(res2); } /* equivalent du dist_norm_bord du VDF */ inline double Zone_CoviMAC::dist_norm_bord(int f) const { assert(face_voisins(f, 1) == -1); return dabs(dot(&xp_(face_voisins(f, 0), 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f); } inline double Zone_CoviMAC::dist_norm(int f) const { return dabs(dot(&xp_(face_voisins(f, 0), 0), &face_normales_(f, 0), &xp_(face_voisins(f, 1), 0))) / face_surfaces(f); } inline double Zone_CoviMAC::dist_face_elem0(int f,int e) const { return dabs(dot(&xp_(e, 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f); } inline double Zone_CoviMAC::dist_face_elem1(int f,int e) const { return dabs(dot(&xp_(e, 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f); } inline double Zone_CoviMAC::dist_face_elem0_period(int num_face,int n0,double l) const { abort(); return 0; } inline double Zone_CoviMAC::dist_face_elem1_period(int num_face,int n1,double l) const { abort(); return 0; } //remplit dans le DoubleTab(N, dimension) resu les produits nu.v quelle que soit la forme de nu inline double Zone_CoviMAC::nu_dot(const DoubleTab* nu, int e, int n, int N, const double *a, const double *b, const double *ma, const double *mb) const { if (!nu) return dot(a, b, ma, mb); int i, j, N_nu = nu->line_size(); double resu = 0; if (N_nu <= N) resu = nu->addr()[N_nu < N ? e : N * e + n] * dot(a, b, ma, mb); //isotrope else if (N_nu == N * dimension) for (i = 0; i < dimension; i++) //anisotrope diagonal resu += nu->addr()[dimension * (N * e + n) + i] * (a[i] - (ma ? ma[i] : 0)) * (b[i] - (mb ? mb[i] : 0)); else if (N_nu == N * dimension * dimension) for (i = 0; i < dimension; i++) //anisotrope complet for (j = 0; j < dimension; j++) resu += nu->addr()[dimension * (dimension * (N * e + n) + i) + j] * (a[i] - (ma ? ma[i] : 0)) * (b[j] - (mb ? mb[j] : 0)); return resu; } /* compaction d'un tableau qui avait set_smart_resize = 1 */ #define CRIMP(a) a.nb_dim() > 2 ? a.resize(a.dimension(0) + 1, a.dimension(1), a.dimension(2)) : a.nb_dim() > 1 ? a.resize(a.dimension(0) + 1, a.dimension(1)) : a.resize(a.dimension(0) + 1), \ a.set_smart_resize(0), \ a.nb_dim() > 2 ? a.resize(a.dimension(0) - 1, a.dimension(1), a.dimension(2)) : a.nb_dim() > 1 ? a.resize(a.dimension(0) - 1, a.dimension(1)) : a.resize(a.dimension(0) - 1) #endif
38.731707
260
0.675126
04db120dcbd8898827a0071e02184f49cad1b603
52,208
c
C
dlls/ntdll/unix/socket.c
ofey404/wine
fd7954974b9d94b4abe5b2ee8918f8ca063b51db
[ "MIT" ]
2
2021-09-23T18:50:37.000Z
2022-03-29T09:45:56.000Z
dlls/ntdll/unix/socket.c
PWN-Term/wine
1de583a4dac7d704b2d4291ada4a1885cd8cd1c9
[ "MIT" ]
null
null
null
dlls/ntdll/unix/socket.c
PWN-Term/wine
1de583a4dac7d704b2d4291ada4a1885cd8cd1c9
[ "MIT" ]
null
null
null
/* * Windows sockets * * Copyright 2021 Zebediah Figura for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #if 0 #pragma makedep unix #endif #include "config.h" #include <errno.h> #include <sys/types.h> #include <unistd.h> #ifdef HAVE_IFADDRS_H # include <ifaddrs.h> #endif #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif #ifdef HAVE_NETINET_TCP_H # include <netinet/tcp.h> #endif #ifdef HAVE_NETIPX_IPX_H # include <netipx/ipx.h> #elif defined(HAVE_LINUX_IPX_H) # ifdef HAVE_ASM_TYPES_H # include <asm/types.h> # endif # ifdef HAVE_LINUX_TYPES_H # include <linux/types.h> # endif # include <linux/ipx.h> #endif #if defined(SOL_IPX) || defined(SO_DEFAULT_HEADERS) # define HAS_IPX #endif #ifdef HAVE_LINUX_IRDA_H # ifdef HAVE_LINUX_TYPES_H # include <linux/types.h> # endif # include <linux/irda.h> # define HAS_IRDA #endif #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" #include "winioctl.h" #define USE_WS_PREFIX #include "winsock2.h" #include "mswsock.h" #include "mstcpip.h" #include "ws2tcpip.h" #include "wsipx.h" #include "af_irda.h" #include "wine/afd.h" #include "unix_private.h" #if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE) /* TCP_KEEPALIVE is the Mac OS name for TCP_KEEPIDLE */ #define TCP_KEEPIDLE TCP_KEEPALIVE #endif WINE_DEFAULT_DEBUG_CHANNEL(winsock); #define FILE_USE_FILE_POINTER_POSITION ((LONGLONG)-2) static async_data_t server_async( HANDLE handle, struct async_fileio *user, HANDLE event, PIO_APC_ROUTINE apc, void *apc_context, IO_STATUS_BLOCK *io ) { async_data_t async; async.handle = wine_server_obj_handle( handle ); async.user = wine_server_client_ptr( user ); async.iosb = wine_server_client_ptr( io ); async.event = wine_server_obj_handle( event ); async.apc = wine_server_client_ptr( apc ); async.apc_context = wine_server_client_ptr( apc_context ); return async; } static NTSTATUS wait_async( HANDLE handle, BOOL alertable ) { return NtWaitForSingleObject( handle, alertable, NULL ); } union unix_sockaddr { struct sockaddr addr; struct sockaddr_in in; struct sockaddr_in6 in6; #ifdef HAS_IPX struct sockaddr_ipx ipx; #endif #ifdef HAS_IRDA struct sockaddr_irda irda; #endif }; struct async_recv_ioctl { struct async_fileio io; WSABUF *control; struct WS_sockaddr *addr; int *addr_len; DWORD *ret_flags; int unix_flags; unsigned int count; struct iovec iov[1]; }; struct async_send_ioctl { struct async_fileio io; const struct WS_sockaddr *addr; int addr_len; int unix_flags; unsigned int sent_len; unsigned int count; unsigned int iov_cursor; struct iovec iov[1]; }; struct async_transmit_ioctl { struct async_fileio io; HANDLE file; char *buffer; unsigned int buffer_size; /* allocated size of buffer */ unsigned int read_len; /* amount of valid data currently in the buffer */ unsigned int head_cursor; /* amount of header data already sent */ unsigned int file_cursor; /* amount of file data already sent */ unsigned int buffer_cursor; /* amount of data currently in the buffer already sent */ unsigned int tail_cursor; /* amount of tail data already sent */ unsigned int file_len; /* total file length to send */ DWORD flags; TRANSMIT_FILE_BUFFERS buffers; LARGE_INTEGER offset; }; static NTSTATUS sock_errno_to_status( int err ) { switch (err) { case EBADF: return STATUS_INVALID_HANDLE; case EBUSY: return STATUS_DEVICE_BUSY; case EPERM: case EACCES: return STATUS_ACCESS_DENIED; case EFAULT: return STATUS_ACCESS_VIOLATION; case EINVAL: return STATUS_INVALID_PARAMETER; case ENFILE: case EMFILE: return STATUS_TOO_MANY_OPENED_FILES; case EINPROGRESS: case EWOULDBLOCK: return STATUS_DEVICE_NOT_READY; case EALREADY: return STATUS_NETWORK_BUSY; case ENOTSOCK: return STATUS_OBJECT_TYPE_MISMATCH; case EDESTADDRREQ: return STATUS_INVALID_PARAMETER; case EMSGSIZE: return STATUS_BUFFER_OVERFLOW; case EPROTONOSUPPORT: case ESOCKTNOSUPPORT: case EPFNOSUPPORT: case EAFNOSUPPORT: case EPROTOTYPE: return STATUS_NOT_SUPPORTED; case ENOPROTOOPT: return STATUS_INVALID_PARAMETER; case EOPNOTSUPP: return STATUS_NOT_SUPPORTED; case EADDRINUSE: return STATUS_SHARING_VIOLATION; case EADDRNOTAVAIL: return STATUS_INVALID_PARAMETER; case ECONNREFUSED: return STATUS_CONNECTION_REFUSED; case ESHUTDOWN: return STATUS_PIPE_DISCONNECTED; case ENOTCONN: return STATUS_INVALID_CONNECTION; case ETIMEDOUT: return STATUS_IO_TIMEOUT; case ENETUNREACH: return STATUS_NETWORK_UNREACHABLE; case EHOSTUNREACH: return STATUS_HOST_UNREACHABLE; case ENETDOWN: return STATUS_NETWORK_BUSY; case EPIPE: case ECONNRESET: return STATUS_CONNECTION_RESET; case ECONNABORTED: return STATUS_CONNECTION_ABORTED; case EISCONN: return STATUS_CONNECTION_ACTIVE; case 0: return STATUS_SUCCESS; default: FIXME( "unknown errno %d\n", err ); return STATUS_UNSUCCESSFUL; } } static socklen_t sockaddr_to_unix( const struct WS_sockaddr *wsaddr, int wsaddrlen, union unix_sockaddr *uaddr ) { memset( uaddr, 0, sizeof(*uaddr) ); switch (wsaddr->sa_family) { case WS_AF_INET: { struct WS_sockaddr_in win = {0}; if (wsaddrlen < sizeof(win)) return 0; memcpy( &win, wsaddr, sizeof(win) ); uaddr->in.sin_family = AF_INET; uaddr->in.sin_port = win.sin_port; memcpy( &uaddr->in.sin_addr, &win.sin_addr, sizeof(win.sin_addr) ); return sizeof(uaddr->in); } case WS_AF_INET6: { struct WS_sockaddr_in6 win = {0}; if (wsaddrlen < sizeof(struct WS_sockaddr_in6_old)) return 0; if (wsaddrlen < sizeof(struct WS_sockaddr_in6)) memcpy( &win, wsaddr, sizeof(struct WS_sockaddr_in6_old) ); else memcpy( &win, wsaddr, sizeof(struct WS_sockaddr_in6) ); uaddr->in6.sin6_family = AF_INET6; uaddr->in6.sin6_port = win.sin6_port; uaddr->in6.sin6_flowinfo = win.sin6_flowinfo; memcpy( &uaddr->in6.sin6_addr, &win.sin6_addr, sizeof(win.sin6_addr) ); #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID if (wsaddrlen >= sizeof(struct WS_sockaddr_in6)) uaddr->in6.sin6_scope_id = win.sin6_scope_id; #endif return sizeof(uaddr->in6); } #ifdef HAS_IPX case WS_AF_IPX: { struct WS_sockaddr_ipx win = {0}; if (wsaddrlen < sizeof(win)) return 0; memcpy( &win, wsaddr, sizeof(win) ); uaddr->ipx.sipx_family = AF_IPX; memcpy( &uaddr->ipx.sipx_network, win.sa_netnum, sizeof(win.sa_netnum) ); memcpy( &uaddr->ipx.sipx_node, win.sa_nodenum, sizeof(win.sa_nodenum) ); uaddr->ipx.sipx_port = win.sa_socket; return sizeof(uaddr->ipx); } #endif #ifdef HAS_IRDA case WS_AF_IRDA: { SOCKADDR_IRDA win = {0}; unsigned int lsap_sel; if (wsaddrlen < sizeof(win)) return 0; memcpy( &win, wsaddr, sizeof(win) ); uaddr->irda.sir_family = AF_IRDA; if (sscanf( win.irdaServiceName, "LSAP-SEL%u", &lsap_sel ) == 1) uaddr->irda.sir_lsap_sel = lsap_sel; else { uaddr->irda.sir_lsap_sel = LSAP_ANY; memcpy( uaddr->irda.sir_name, win.irdaServiceName, sizeof(win.irdaServiceName) ); } memcpy( &uaddr->irda.sir_addr, win.irdaDeviceID, sizeof(win.irdaDeviceID) ); return sizeof(uaddr->irda); } #endif case WS_AF_UNSPEC: switch (wsaddrlen) { default: /* likely an ipv4 address */ case sizeof(struct WS_sockaddr_in): return sizeof(uaddr->in); #ifdef HAS_IPX case sizeof(struct WS_sockaddr_ipx): return sizeof(uaddr->ipx); #endif #ifdef HAS_IRDA case sizeof(SOCKADDR_IRDA): return sizeof(uaddr->irda); #endif case sizeof(struct WS_sockaddr_in6): case sizeof(struct WS_sockaddr_in6_old): return sizeof(uaddr->in6); } default: FIXME( "unknown address family %u\n", wsaddr->sa_family ); return 0; } } static int sockaddr_from_unix( const union unix_sockaddr *uaddr, struct WS_sockaddr *wsaddr, socklen_t wsaddrlen ) { memset( wsaddr, 0, wsaddrlen ); switch (uaddr->addr.sa_family) { case AF_INET: { struct WS_sockaddr_in win = {0}; if (wsaddrlen < sizeof(win)) return -1; win.sin_family = WS_AF_INET; win.sin_port = uaddr->in.sin_port; memcpy( &win.sin_addr, &uaddr->in.sin_addr, sizeof(win.sin_addr) ); memcpy( wsaddr, &win, sizeof(win) ); return sizeof(win); } case AF_INET6: { struct WS_sockaddr_in6 win = {0}; if (wsaddrlen < sizeof(struct WS_sockaddr_in6_old)) return -1; win.sin6_family = WS_AF_INET6; win.sin6_port = uaddr->in6.sin6_port; win.sin6_flowinfo = uaddr->in6.sin6_flowinfo; memcpy( &win.sin6_addr, &uaddr->in6.sin6_addr, sizeof(win.sin6_addr) ); #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID win.sin6_scope_id = uaddr->in6.sin6_scope_id; #endif if (wsaddrlen >= sizeof(struct WS_sockaddr_in6)) { memcpy( wsaddr, &win, sizeof(struct WS_sockaddr_in6) ); return sizeof(struct WS_sockaddr_in6); } memcpy( wsaddr, &win, sizeof(struct WS_sockaddr_in6_old) ); return sizeof(struct WS_sockaddr_in6_old); } #ifdef HAS_IPX case AF_IPX: { struct WS_sockaddr_ipx win = {0}; if (wsaddrlen < sizeof(win)) return -1; win.sa_family = WS_AF_IPX; memcpy( win.sa_netnum, &uaddr->ipx.sipx_network, sizeof(win.sa_netnum) ); memcpy( win.sa_nodenum, &uaddr->ipx.sipx_node, sizeof(win.sa_nodenum) ); win.sa_socket = uaddr->ipx.sipx_port; memcpy( wsaddr, &win, sizeof(win) ); return sizeof(win); } #endif #ifdef HAS_IRDA case AF_IRDA: { SOCKADDR_IRDA win; if (wsaddrlen < sizeof(win)) return -1; win.irdaAddressFamily = WS_AF_IRDA; memcpy( win.irdaDeviceID, &uaddr->irda.sir_addr, sizeof(win.irdaDeviceID) ); if (uaddr->irda.sir_lsap_sel != LSAP_ANY) snprintf( win.irdaServiceName, sizeof(win.irdaServiceName), "LSAP-SEL%u", uaddr->irda.sir_lsap_sel ); else memcpy( win.irdaServiceName, uaddr->irda.sir_name, sizeof(win.irdaServiceName) ); memcpy( wsaddr, &win, sizeof(win) ); return sizeof(win); } #endif case AF_UNSPEC: return 0; default: FIXME( "unknown address family %d\n", uaddr->addr.sa_family ); return -1; } } #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS #if defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) static WSACMSGHDR *fill_control_message( int level, int type, WSACMSGHDR *current, ULONG *maxsize, void *data, int len ) { ULONG msgsize = sizeof(WSACMSGHDR) + WSA_CMSG_ALIGN(len); char *ptr = (char *) current + sizeof(WSACMSGHDR); if (msgsize > *maxsize) return NULL; *maxsize -= msgsize; current->cmsg_len = sizeof(WSACMSGHDR) + len; current->cmsg_level = level; current->cmsg_type = type; memcpy(ptr, data, len); return (WSACMSGHDR *)(ptr + WSA_CMSG_ALIGN(len)); } #endif /* defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) */ static int convert_control_headers(struct msghdr *hdr, WSABUF *control) { #if defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) WSACMSGHDR *cmsg_win = (WSACMSGHDR *)control->buf, *ptr; ULONG ctlsize = control->len; struct cmsghdr *cmsg_unix; ptr = cmsg_win; for (cmsg_unix = CMSG_FIRSTHDR(hdr); cmsg_unix != NULL; cmsg_unix = CMSG_NXTHDR(hdr, cmsg_unix)) { switch (cmsg_unix->cmsg_level) { case IPPROTO_IP: switch (cmsg_unix->cmsg_type) { #if defined(IP_PKTINFO) case IP_PKTINFO: { const struct in_pktinfo *data_unix = (struct in_pktinfo *)CMSG_DATA(cmsg_unix); struct WS_in_pktinfo data_win; memcpy( &data_win.ipi_addr, &data_unix->ipi_addr.s_addr, 4 ); /* 4 bytes = 32 address bits */ data_win.ipi_ifindex = data_unix->ipi_ifindex; ptr = fill_control_message( WS_IPPROTO_IP, WS_IP_PKTINFO, ptr, &ctlsize, (void *)&data_win, sizeof(data_win) ); if (!ptr) goto error; break; } #elif defined(IP_RECVDSTADDR) case IP_RECVDSTADDR: { const struct in_addr *addr_unix = (struct in_addr *)CMSG_DATA(cmsg_unix); struct WS_in_pktinfo data_win; memcpy( &data_win.ipi_addr, &addr_unix->s_addr, 4 ); /* 4 bytes = 32 address bits */ data_win.ipi_ifindex = 0; /* FIXME */ ptr = fill_control_message( WS_IPPROTO_IP, WS_IP_PKTINFO, ptr, &ctlsize, (void *)&data_win, sizeof(data_win) ); if (!ptr) goto error; break; } #endif /* IP_PKTINFO */ default: FIXME("Unhandled IPPROTO_IP message header type %d\n", cmsg_unix->cmsg_type); break; } break; default: FIXME("Unhandled message header level %d\n", cmsg_unix->cmsg_level); break; } } control->len = (char *)ptr - (char *)cmsg_win; return 1; error: control->len = 0; return 0; #else /* defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) */ control->len = 0; return 1; #endif /* defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) */ } #endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */ static NTSTATUS try_recv( int fd, struct async_recv_ioctl *async, ULONG_PTR *size ) { #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS char control_buffer[512]; #endif union unix_sockaddr unix_addr; struct msghdr hdr; NTSTATUS status; ssize_t ret; memset( &hdr, 0, sizeof(hdr) ); if (async->addr) { hdr.msg_name = &unix_addr.addr; hdr.msg_namelen = sizeof(unix_addr); } hdr.msg_iov = async->iov; hdr.msg_iovlen = async->count; #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS hdr.msg_control = control_buffer; hdr.msg_controllen = sizeof(control_buffer); #endif while ((ret = virtual_locked_recvmsg( fd, &hdr, async->unix_flags )) < 0 && errno == EINTR); if (ret < 0) { /* Unix-like systems return EINVAL when attempting to read OOB data from * an empty socket buffer; Windows returns WSAEWOULDBLOCK. */ if ((async->unix_flags & MSG_OOB) && errno == EINVAL) errno = EWOULDBLOCK; if (errno != EWOULDBLOCK) WARN( "recvmsg: %s\n", strerror( errno ) ); return sock_errno_to_status( errno ); } status = (hdr.msg_flags & MSG_TRUNC) ? STATUS_BUFFER_OVERFLOW : STATUS_SUCCESS; #ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS if (async->control) { ERR( "Message control headers cannot be properly supported on this system.\n" ); async->control->len = 0; } #else if (async->control && !convert_control_headers( &hdr, async->control )) { WARN( "Application passed insufficient room for control headers.\n" ); *async->ret_flags |= WS_MSG_CTRUNC; status = STATUS_BUFFER_OVERFLOW; } #endif /* If this socket is connected, Linux doesn't give us msg_name and * msg_namelen from recvmsg, but it does set msg_namelen to zero. * * MSDN says that the address is ignored for connection-oriented sockets, so * don't try to translate it. */ if (async->addr && hdr.msg_namelen) *async->addr_len = sockaddr_from_unix( &unix_addr, async->addr, *async->addr_len ); *size = ret; return status; } static NTSTATUS async_recv_proc( void *user, IO_STATUS_BLOCK *io, NTSTATUS status ) { struct async_recv_ioctl *async = user; ULONG_PTR information = 0; int fd, needs_close; TRACE( "%#x\n", status ); if (status == STATUS_ALERTED) { if ((status = server_get_unix_fd( async->io.handle, 0, &fd, &needs_close, NULL, NULL ))) return status; status = try_recv( fd, async, &information ); TRACE( "got status %#x, %#lx bytes read\n", status, information ); if (status == STATUS_DEVICE_NOT_READY) status = STATUS_PENDING; if (needs_close) close( fd ); } if (status != STATUS_PENDING) { io->Status = status; io->Information = information; release_fileio( &async->io ); } return status; } static NTSTATUS sock_recv( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, int fd, const WSABUF *buffers, unsigned int count, WSABUF *control, struct WS_sockaddr *addr, int *addr_len, DWORD *ret_flags, int unix_flags, int force_async ) { struct async_recv_ioctl *async; ULONG_PTR information; HANDLE wait_handle; DWORD async_size; NTSTATUS status; unsigned int i; ULONG options; if (unix_flags & MSG_OOB) { int oobinline; socklen_t len = sizeof(oobinline); if (!getsockopt( fd, SOL_SOCKET, SO_OOBINLINE, (char *)&oobinline, &len ) && oobinline) return STATUS_INVALID_PARAMETER; } for (i = 0; i < count; ++i) { if (!virtual_check_buffer_for_write( buffers[i].buf, buffers[i].len )) return STATUS_ACCESS_VIOLATION; } async_size = offsetof( struct async_recv_ioctl, iov[count] ); if (!(async = (struct async_recv_ioctl *)alloc_fileio( async_size, async_recv_proc, handle ))) return STATUS_NO_MEMORY; async->count = count; for (i = 0; i < count; ++i) { async->iov[i].iov_base = buffers[i].buf; async->iov[i].iov_len = buffers[i].len; } async->unix_flags = unix_flags; async->control = control; async->addr = addr; async->addr_len = addr_len; async->ret_flags = ret_flags; status = try_recv( fd, async, &information ); if (status != STATUS_SUCCESS && status != STATUS_BUFFER_OVERFLOW && status != STATUS_DEVICE_NOT_READY) { release_fileio( &async->io ); return status; } if (status == STATUS_DEVICE_NOT_READY && force_async) status = STATUS_PENDING; if (!NT_ERROR(status)) { io->Status = status; io->Information = information; } SERVER_START_REQ( recv_socket ) { req->status = status; req->total = information; req->async = server_async( handle, &async->io, event, apc, apc_user, io ); req->oob = !!(unix_flags & MSG_OOB); status = wine_server_call( req ); wait_handle = wine_server_ptr_handle( reply->wait ); options = reply->options; } SERVER_END_REQ; if (status != STATUS_PENDING) release_fileio( &async->io ); if (wait_handle) status = wait_async( wait_handle, options & FILE_SYNCHRONOUS_IO_ALERT ); return status; } struct async_poll_ioctl { struct async_fileio io; unsigned int count; struct afd_poll_params *input, *output; struct poll_socket_output sockets[1]; }; static ULONG_PTR fill_poll_output( struct async_poll_ioctl *async, NTSTATUS status ) { struct afd_poll_params *input = async->input, *output = async->output; unsigned int i, count = 0; memcpy( output, input, offsetof( struct afd_poll_params, sockets[0] ) ); if (!status) { for (i = 0; i < async->count; ++i) { if (async->sockets[i].flags) { output->sockets[count].socket = input->sockets[i].socket; output->sockets[count].flags = async->sockets[i].flags; output->sockets[count].status = async->sockets[i].status; ++count; } } } output->count = count; return offsetof( struct afd_poll_params, sockets[count] ); } static NTSTATUS async_poll_proc( void *user, IO_STATUS_BLOCK *io, NTSTATUS status ) { struct async_poll_ioctl *async = user; ULONG_PTR information = 0; if (status == STATUS_ALERTED) { SERVER_START_REQ( get_async_result ) { req->user_arg = wine_server_client_ptr( async ); wine_server_set_reply( req, async->sockets, async->count * sizeof(async->sockets[0]) ); status = wine_server_call( req ); } SERVER_END_REQ; information = fill_poll_output( async, status ); } if (status != STATUS_PENDING) { io->Status = status; io->Information = information; free( async->input ); release_fileio( &async->io ); } return status; } /* we could handle this ioctl entirely on the server side, but the differing * structure size makes it painful */ static NTSTATUS sock_poll( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, void *in_buffer, ULONG in_size, void *out_buffer, ULONG out_size ) { const struct afd_poll_params *params = in_buffer; struct poll_socket_input *input; struct async_poll_ioctl *async; HANDLE wait_handle; DWORD async_size; NTSTATUS status; unsigned int i; ULONG options; if (in_size < sizeof(*params) || out_size < in_size || !params->count || in_size < offsetof( struct afd_poll_params, sockets[params->count] )) return STATUS_INVALID_PARAMETER; TRACE( "timeout %s, count %u, unknown %#x, padding (%#x, %#x, %#x), sockets[0] {%04lx, %#x}\n", wine_dbgstr_longlong(params->timeout), params->count, params->unknown, params->padding[0], params->padding[1], params->padding[2], params->sockets[0].socket, params->sockets[0].flags ); if (params->unknown) FIXME( "unknown boolean is %#x\n", params->unknown ); if (params->padding[0]) FIXME( "padding[0] is %#x\n", params->padding[0] ); if (params->padding[1]) FIXME( "padding[1] is %#x\n", params->padding[1] ); if (params->padding[2]) FIXME( "padding[2] is %#x\n", params->padding[2] ); for (i = 0; i < params->count; ++i) { if (params->sockets[i].flags & ~0x1ff) FIXME( "unknown socket flags %#x\n", params->sockets[i].flags ); } if (!(input = malloc( params->count * sizeof(*input) ))) return STATUS_NO_MEMORY; async_size = offsetof( struct async_poll_ioctl, sockets[params->count] ); if (!(async = (struct async_poll_ioctl *)alloc_fileio( async_size, async_poll_proc, handle ))) { free( input ); return STATUS_NO_MEMORY; } if (!(async->input = malloc( in_size ))) { release_fileio( &async->io ); free( input ); return STATUS_NO_MEMORY; } memcpy( async->input, in_buffer, in_size ); async->count = params->count; async->output = out_buffer; for (i = 0; i < params->count; ++i) { input[i].socket = params->sockets[i].socket; input[i].flags = params->sockets[i].flags; } SERVER_START_REQ( poll_socket ) { req->async = server_async( handle, &async->io, event, apc, apc_user, io ); req->timeout = params->timeout; wine_server_add_data( req, input, params->count * sizeof(*input) ); wine_server_set_reply( req, async->sockets, params->count * sizeof(async->sockets[0]) ); status = wine_server_call( req ); wait_handle = wine_server_ptr_handle( reply->wait ); options = reply->options; if (wait_handle && status != STATUS_PENDING) { io->Status = status; io->Information = fill_poll_output( async, status ); } } SERVER_END_REQ; free( input ); if (status != STATUS_PENDING) { free( async->input ); release_fileio( &async->io ); } if (wait_handle) status = wait_async( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT) ); return status; } static NTSTATUS try_send( int fd, struct async_send_ioctl *async ) { union unix_sockaddr unix_addr; struct msghdr hdr; ssize_t ret; memset( &hdr, 0, sizeof(hdr) ); if (async->addr) { hdr.msg_name = &unix_addr; hdr.msg_namelen = sockaddr_to_unix( async->addr, async->addr_len, &unix_addr ); if (!hdr.msg_namelen) { ERR( "failed to convert address\n" ); return STATUS_ACCESS_VIOLATION; } #if defined(HAS_IPX) && defined(SOL_IPX) if (async->addr->sa_family == WS_AF_IPX) { int type; socklen_t len = sizeof(type); /* The packet type is stored at the IPX socket level. At least the * linux kernel seems to do something with it in case hdr.msg_name * is NULL. Nonetheless we can use it to store the packet type, and * then we can retrieve it using getsockopt. After that we can set * the IPX type in the sockaddr_ipx structure with the stored value. */ if (getsockopt(fd, SOL_IPX, IPX_TYPE, &type, &len) >= 0) unix_addr.ipx.sipx_type = type; } #endif } hdr.msg_iov = async->iov + async->iov_cursor; hdr.msg_iovlen = async->count - async->iov_cursor; while ((ret = sendmsg( fd, &hdr, async->unix_flags )) == -1) { if (errno == EISCONN) { hdr.msg_name = NULL; hdr.msg_namelen = 0; } else if (errno != EINTR) { if (errno != EWOULDBLOCK) WARN( "sendmsg: %s\n", strerror( errno ) ); return sock_errno_to_status( errno ); } } async->sent_len += ret; while (async->iov_cursor < async->count && ret >= async->iov[async->iov_cursor].iov_len) ret -= async->iov[async->iov_cursor++].iov_len; if (async->iov_cursor < async->count) { async->iov[async->iov_cursor].iov_base = (char *)async->iov[async->iov_cursor].iov_base + ret; async->iov[async->iov_cursor].iov_len -= ret; return STATUS_DEVICE_NOT_READY; } return STATUS_SUCCESS; } static NTSTATUS async_send_proc( void *user, IO_STATUS_BLOCK *io, NTSTATUS status ) { struct async_send_ioctl *async = user; int fd, needs_close; TRACE( "%#x\n", status ); if (status == STATUS_ALERTED) { if ((status = server_get_unix_fd( async->io.handle, 0, &fd, &needs_close, NULL, NULL ))) return status; status = try_send( fd, async ); TRACE( "got status %#x\n", status ); if (status == STATUS_DEVICE_NOT_READY) status = STATUS_PENDING; if (needs_close) close( fd ); } if (status != STATUS_PENDING) { io->Status = status; io->Information = async->sent_len; release_fileio( &async->io ); } return status; } static NTSTATUS sock_send( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, int fd, const WSABUF *buffers, unsigned int count, const struct WS_sockaddr *addr, unsigned int addr_len, int unix_flags, int force_async ) { struct async_send_ioctl *async; HANDLE wait_handle; DWORD async_size; NTSTATUS status; unsigned int i; ULONG options; async_size = offsetof( struct async_send_ioctl, iov[count] ); if (!(async = (struct async_send_ioctl *)alloc_fileio( async_size, async_send_proc, handle ))) return STATUS_NO_MEMORY; async->count = count; for (i = 0; i < count; ++i) { async->iov[i].iov_base = buffers[i].buf; async->iov[i].iov_len = buffers[i].len; } async->unix_flags = unix_flags; async->addr = addr; async->addr_len = addr_len; async->iov_cursor = 0; async->sent_len = 0; status = try_send( fd, async ); if (status != STATUS_SUCCESS && status != STATUS_DEVICE_NOT_READY) { release_fileio( &async->io ); return status; } if (status == STATUS_DEVICE_NOT_READY && force_async) status = STATUS_PENDING; if (!NT_ERROR(status)) { io->Status = status; io->Information = async->sent_len; } SERVER_START_REQ( send_socket ) { req->status = status; req->total = async->sent_len; req->async = server_async( handle, &async->io, event, apc, apc_user, io ); status = wine_server_call( req ); wait_handle = wine_server_ptr_handle( reply->wait ); options = reply->options; } SERVER_END_REQ; if (status != STATUS_PENDING) release_fileio( &async->io ); if (wait_handle) status = wait_async( wait_handle, options & FILE_SYNCHRONOUS_IO_ALERT ); return status; } static ssize_t do_send( int fd, const void *buffer, size_t len, int flags ) { ssize_t ret; while ((ret = send( fd, buffer, len, flags )) < 0 && errno == EINTR); if (ret < 0 && errno != EWOULDBLOCK) WARN( "send: %s\n", strerror( errno ) ); return ret; } static NTSTATUS try_transmit( int sock_fd, int file_fd, struct async_transmit_ioctl *async ) { ssize_t ret; while (async->head_cursor < async->buffers.HeadLength) { TRACE( "sending %u bytes of header data\n", async->buffers.HeadLength - async->head_cursor ); ret = do_send( sock_fd, (char *)async->buffers.Head + async->head_cursor, async->buffers.HeadLength - async->head_cursor, 0 ); if (ret < 0) return sock_errno_to_status( errno ); TRACE( "send returned %zd\n", ret ); async->head_cursor += ret; } while (async->buffer_cursor < async->read_len) { TRACE( "sending %u bytes of file data\n", async->read_len - async->buffer_cursor ); ret = do_send( sock_fd, async->buffer + async->buffer_cursor, async->read_len - async->buffer_cursor, 0 ); if (ret < 0) return sock_errno_to_status( errno ); TRACE( "send returned %zd\n", ret ); async->buffer_cursor += ret; async->file_cursor += ret; } if (async->file && async->buffer_cursor == async->read_len) { unsigned int read_size = async->buffer_size; if (async->file_len) read_size = min( read_size, async->file_len - async->file_cursor ); TRACE( "reading %u bytes of file data\n", read_size ); do { if (async->offset.QuadPart == FILE_USE_FILE_POINTER_POSITION) ret = read( file_fd, async->buffer, read_size ); else ret = pread( file_fd, async->buffer, read_size, async->offset.QuadPart ); } while (ret < 0 && errno == EINTR); if (ret < 0) return errno_to_status( errno ); TRACE( "read returned %zd\n", ret ); async->read_len = ret; async->buffer_cursor = 0; if (async->offset.QuadPart != FILE_USE_FILE_POINTER_POSITION) async->offset.QuadPart += ret; if (ret < read_size || (async->file_len && async->file_cursor == async->file_len)) async->file = NULL; return STATUS_PENDING; /* still more data to send */ } while (async->tail_cursor < async->buffers.TailLength) { TRACE( "sending %u bytes of tail data\n", async->buffers.TailLength - async->tail_cursor ); ret = do_send( sock_fd, (char *)async->buffers.Tail + async->tail_cursor, async->buffers.TailLength - async->tail_cursor, 0 ); if (ret < 0) return sock_errno_to_status( errno ); TRACE( "send returned %zd\n", ret ); async->tail_cursor += ret; } return STATUS_SUCCESS; } static NTSTATUS async_transmit_proc( void *user, IO_STATUS_BLOCK *io, NTSTATUS status ) { int sock_fd, file_fd = -1, sock_needs_close = FALSE, file_needs_close = FALSE; struct async_transmit_ioctl *async = user; TRACE( "%#x\n", status ); if (status == STATUS_ALERTED) { if ((status = server_get_unix_fd( async->io.handle, 0, &sock_fd, &sock_needs_close, NULL, NULL ))) return status; if (async->file && (status = server_get_unix_fd( async->file, 0, &file_fd, &file_needs_close, NULL, NULL ))) { if (sock_needs_close) close( sock_fd ); return status; } status = try_transmit( sock_fd, file_fd, async ); TRACE( "got status %#x\n", status ); if (status == STATUS_DEVICE_NOT_READY) status = STATUS_PENDING; if (sock_needs_close) close( sock_fd ); if (file_needs_close) close( file_fd ); } if (status != STATUS_PENDING) { io->Status = status; io->Information = async->head_cursor + async->file_cursor + async->tail_cursor; release_fileio( &async->io ); } return status; } static NTSTATUS sock_transmit( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, int fd, const struct afd_transmit_params *params ) { int file_fd, file_needs_close = FALSE; struct async_transmit_ioctl *async; enum server_fd_type file_type; union unix_sockaddr addr; socklen_t addr_len; HANDLE wait_handle; NTSTATUS status; ULONG options; addr_len = sizeof(addr); if (getpeername( fd, &addr.addr, &addr_len ) != 0) return STATUS_INVALID_CONNECTION; if (params->file) { if ((status = server_get_unix_fd( params->file, 0, &file_fd, &file_needs_close, &file_type, NULL ))) return status; if (file_needs_close) close( file_fd ); if (file_type != FD_TYPE_FILE) { FIXME( "unsupported file type %#x\n", file_type ); return STATUS_NOT_IMPLEMENTED; } } if (!(async = (struct async_transmit_ioctl *)alloc_fileio( sizeof(*async), async_transmit_proc, handle ))) return STATUS_NO_MEMORY; async->file = params->file; async->buffer_size = params->buffer_size ? params->buffer_size : 65536; if (!(async->buffer = malloc( async->buffer_size ))) { release_fileio( &async->io ); return STATUS_NO_MEMORY; } async->read_len = 0; async->head_cursor = 0; async->file_cursor = 0; async->buffer_cursor = 0; async->tail_cursor = 0; async->file_len = params->file_len; async->flags = params->flags; async->buffers = params->buffers; async->offset = params->offset; SERVER_START_REQ( send_socket ) { req->status = STATUS_PENDING; req->total = 0; req->async = server_async( handle, &async->io, event, apc, apc_user, io ); status = wine_server_call( req ); wait_handle = wine_server_ptr_handle( reply->wait ); options = reply->options; } SERVER_END_REQ; if (status != STATUS_PENDING) release_fileio( &async->io ); if (wait_handle) status = wait_async( wait_handle, options & FILE_SYNCHRONOUS_IO_ALERT ); return status; } static void complete_async( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, NTSTATUS status, ULONG_PTR information ) { io->Status = status; io->Information = information; if (event) NtSetEvent( event, NULL ); if (apc) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc, (ULONG_PTR)apc_user, (ULONG_PTR)io, 0 ); if (apc_user) add_completion( handle, (ULONG_PTR)apc_user, status, information, FALSE ); } NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, ULONG code, void *in_buffer, ULONG in_size, void *out_buffer, ULONG out_size ) { int fd, needs_close = FALSE; NTSTATUS status; TRACE( "handle %p, code %#x, in_buffer %p, in_size %u, out_buffer %p, out_size %u\n", handle, code, in_buffer, in_size, out_buffer, out_size ); switch (code) { case IOCTL_AFD_BIND: { const struct afd_bind_params *params = in_buffer; if (params->unknown) FIXME( "bind: got unknown %#x\n", params->unknown ); status = STATUS_BAD_DEVICE_TYPE; break; } case IOCTL_AFD_GETSOCKNAME: if (in_size) FIXME( "unexpected input size %u\n", in_size ); status = STATUS_BAD_DEVICE_TYPE; break; case IOCTL_AFD_LISTEN: { const struct afd_listen_params *params = in_buffer; TRACE( "backlog %u\n", params->backlog ); if (out_size) FIXME( "unexpected output size %u\n", out_size ); if (params->unknown1) FIXME( "listen: got unknown1 %#x\n", params->unknown1 ); if (params->unknown2) FIXME( "listen: got unknown2 %#x\n", params->unknown2 ); status = STATUS_BAD_DEVICE_TYPE; break; } case IOCTL_AFD_EVENT_SELECT: { const struct afd_event_select_params *params = in_buffer; TRACE( "event %p, mask %#x\n", params->event, params->mask ); if (out_size) FIXME( "unexpected output size %u\n", out_size ); status = STATUS_BAD_DEVICE_TYPE; break; } case IOCTL_AFD_GET_EVENTS: if (in_size) FIXME( "unexpected input size %u\n", in_size ); status = STATUS_BAD_DEVICE_TYPE; break; case IOCTL_AFD_RECV: { const struct afd_recv_params *params = in_buffer; int unix_flags = 0; if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (out_size) FIXME( "unexpected output size %u\n", out_size ); if (in_size < sizeof(struct afd_recv_params)) { status = STATUS_INVALID_PARAMETER; break; } if ((params->msg_flags & (AFD_MSG_NOT_OOB | AFD_MSG_OOB)) == 0 || (params->msg_flags & (AFD_MSG_NOT_OOB | AFD_MSG_OOB)) == (AFD_MSG_NOT_OOB | AFD_MSG_OOB)) { status = STATUS_INVALID_PARAMETER; break; } if (params->msg_flags & ~(AFD_MSG_NOT_OOB | AFD_MSG_OOB | AFD_MSG_PEEK | AFD_MSG_WAITALL)) FIXME( "unknown msg_flags %#x\n", params->msg_flags ); if (params->recv_flags & ~AFD_RECV_FORCE_ASYNC) FIXME( "unknown recv_flags %#x\n", params->recv_flags ); if (params->msg_flags & AFD_MSG_OOB) unix_flags |= MSG_OOB; if (params->msg_flags & AFD_MSG_PEEK) unix_flags |= MSG_PEEK; if (params->msg_flags & AFD_MSG_WAITALL) FIXME( "MSG_WAITALL is not supported\n" ); status = sock_recv( handle, event, apc, apc_user, io, fd, params->buffers, params->count, NULL, NULL, NULL, NULL, unix_flags, !!(params->recv_flags & AFD_RECV_FORCE_ASYNC) ); break; } case IOCTL_AFD_WINE_RECVMSG: { struct afd_recvmsg_params *params = in_buffer; int unix_flags = 0; if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (in_size < sizeof(*params)) { status = STATUS_BUFFER_TOO_SMALL; break; } if (*params->ws_flags & WS_MSG_OOB) unix_flags |= MSG_OOB; if (*params->ws_flags & WS_MSG_PEEK) unix_flags |= MSG_PEEK; if (*params->ws_flags & WS_MSG_WAITALL) FIXME( "MSG_WAITALL is not supported\n" ); status = sock_recv( handle, event, apc, apc_user, io, fd, params->buffers, params->count, params->control, params->addr, params->addr_len, params->ws_flags, unix_flags, params->force_async ); break; } case IOCTL_AFD_WINE_SENDMSG: { const struct afd_sendmsg_params *params = in_buffer; int unix_flags = 0; if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (in_size < sizeof(*params)) { status = STATUS_BUFFER_TOO_SMALL; break; } if (params->ws_flags & WS_MSG_OOB) unix_flags |= MSG_OOB; if (params->ws_flags & WS_MSG_PARTIAL) WARN( "ignoring MSG_PARTIAL\n" ); if (params->ws_flags & ~(WS_MSG_OOB | WS_MSG_PARTIAL)) FIXME( "unknown flags %#x\n", params->ws_flags ); status = sock_send( handle, event, apc, apc_user, io, fd, params->buffers, params->count, params->addr, params->addr_len, unix_flags, params->force_async ); break; } case IOCTL_AFD_WINE_TRANSMIT: { const struct afd_transmit_params *params = in_buffer; if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (in_size < sizeof(*params)) { status = STATUS_BUFFER_TOO_SMALL; break; } status = sock_transmit( handle, event, apc, apc_user, io, fd, params ); break; } case IOCTL_AFD_WINE_COMPLETE_ASYNC: { if (in_size != sizeof(NTSTATUS)) return STATUS_BUFFER_TOO_SMALL; status = *(NTSTATUS *)in_buffer; complete_async( handle, event, apc, apc_user, io, status, 0 ); break; } case IOCTL_AFD_POLL: status = sock_poll( handle, event, apc, apc_user, io, in_buffer, in_size, out_buffer, out_size ); break; case IOCTL_AFD_WINE_FIONREAD: { int value, ret; if (out_size < sizeof(int)) { status = STATUS_BUFFER_TOO_SMALL; break; } if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; #ifdef linux { socklen_t len = sizeof(value); /* FIONREAD on a listening socket always fails (see tcp(7)). */ if (!getsockopt( fd, SOL_SOCKET, SO_ACCEPTCONN, &value, &len ) && value) { *(int *)out_buffer = 0; status = STATUS_SUCCESS; complete_async( handle, event, apc, apc_user, io, status, 0 ); break; } } #endif if ((ret = ioctl( fd, FIONREAD, &value )) < 0) { status = sock_errno_to_status( errno ); break; } *(int *)out_buffer = value; status = STATUS_SUCCESS; complete_async( handle, event, apc, apc_user, io, status, 0 ); break; } case IOCTL_AFD_WINE_SIOCATMARK: { int value, ret; socklen_t len = sizeof(value); if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (out_size < sizeof(int)) { status = STATUS_BUFFER_TOO_SMALL; break; } if (getsockopt( fd, SOL_SOCKET, SO_OOBINLINE, &value, &len ) < 0) { status = sock_errno_to_status( errno ); break; } if (value) { *(int *)out_buffer = TRUE; } else { if ((ret = ioctl( fd, SIOCATMARK, &value )) < 0) { status = sock_errno_to_status( errno ); break; } /* windows is reversed with respect to unix */ *(int *)out_buffer = !value; } status = STATUS_SUCCESS; complete_async( handle, event, apc, apc_user, io, status, 0 ); break; } case IOCTL_AFD_WINE_GET_INTERFACE_LIST: { #ifdef HAVE_GETIFADDRS INTERFACE_INFO *info = out_buffer; struct ifaddrs *ifaddrs, *ifaddr; unsigned int count = 0; ULONG ret_size; if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (getifaddrs( &ifaddrs ) < 0) { status = sock_errno_to_status( errno ); break; } for (ifaddr = ifaddrs; ifaddr != NULL; ifaddr = ifaddr->ifa_next) { if (ifaddr->ifa_addr && ifaddr->ifa_addr->sa_family == AF_INET) ++count; } ret_size = count * sizeof(*info); if (out_size < ret_size) { status = STATUS_PENDING; complete_async( handle, event, apc, apc_user, io, STATUS_BUFFER_TOO_SMALL, 0 ); freeifaddrs( ifaddrs ); break; } memset( out_buffer, 0, ret_size ); count = 0; for (ifaddr = ifaddrs; ifaddr != NULL; ifaddr = ifaddr->ifa_next) { in_addr_t addr, mask; if (!ifaddr->ifa_addr || ifaddr->ifa_addr->sa_family != AF_INET) continue; addr = ((const struct sockaddr_in *)ifaddr->ifa_addr)->sin_addr.s_addr; mask = ((const struct sockaddr_in *)ifaddr->ifa_netmask)->sin_addr.s_addr; info[count].iiFlags = 0; if (ifaddr->ifa_flags & IFF_BROADCAST) info[count].iiFlags |= WS_IFF_BROADCAST; if (ifaddr->ifa_flags & IFF_LOOPBACK) info[count].iiFlags |= WS_IFF_LOOPBACK; if (ifaddr->ifa_flags & IFF_MULTICAST) info[count].iiFlags |= WS_IFF_MULTICAST; #ifdef IFF_POINTTOPOINT if (ifaddr->ifa_flags & IFF_POINTTOPOINT) info[count].iiFlags |= WS_IFF_POINTTOPOINT; #endif if (ifaddr->ifa_flags & IFF_UP) info[count].iiFlags |= WS_IFF_UP; info[count].iiAddress.AddressIn.sin_family = WS_AF_INET; info[count].iiAddress.AddressIn.sin_port = 0; info[count].iiAddress.AddressIn.sin_addr.WS_s_addr = addr; info[count].iiNetmask.AddressIn.sin_family = WS_AF_INET; info[count].iiNetmask.AddressIn.sin_port = 0; info[count].iiNetmask.AddressIn.sin_addr.WS_s_addr = mask; if (ifaddr->ifa_flags & IFF_BROADCAST) { info[count].iiBroadcastAddress.AddressIn.sin_family = WS_AF_INET; info[count].iiBroadcastAddress.AddressIn.sin_port = 0; info[count].iiBroadcastAddress.AddressIn.sin_addr.WS_s_addr = addr | ~mask; } ++count; } freeifaddrs( ifaddrs ); status = STATUS_PENDING; complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, ret_size ); #else FIXME( "Interface list queries are currently not supported on this platform.\n" ); status = STATUS_NOT_SUPPORTED; #endif break; } case IOCTL_AFD_WINE_KEEPALIVE_VALS: { struct tcp_keepalive *k = in_buffer; int keepalive; if (!in_buffer || in_size < sizeof(struct tcp_keepalive)) return STATUS_BUFFER_TOO_SMALL; keepalive = !!k->onoff; if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (setsockopt( fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(int) ) < 0) { status = STATUS_INVALID_PARAMETER; break; } if (keepalive) { #ifdef TCP_KEEPIDLE int idle = max( 1, (k->keepalivetime + 500) / 1000 ); if (setsockopt( fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(int) ) < 0) { status = STATUS_INVALID_PARAMETER; break; } #else FIXME("ignoring keepalive timeout\n"); #endif } if (keepalive) { #ifdef TCP_KEEPINTVL int interval = max( 1, (k->keepaliveinterval + 500) / 1000 ); if (setsockopt( fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(int) ) < 0) status = STATUS_INVALID_PARAMETER; #else FIXME("ignoring keepalive interval\n"); #endif } status = STATUS_SUCCESS; complete_async( handle, event, apc, apc_user, io, status, 0 ); break; } case IOCTL_AFD_WINE_GETPEERNAME: { union unix_sockaddr unix_addr; socklen_t unix_len = sizeof(unix_addr); int len; if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return status; if (getpeername( fd, &unix_addr.addr, &unix_len ) < 0) { status = sock_errno_to_status( errno ); break; } len = sockaddr_from_unix( &unix_addr, out_buffer, out_size ); if (out_size < len) { status = STATUS_BUFFER_TOO_SMALL; break; } io->Information = len; status = STATUS_SUCCESS; break; } default: { if ((code >> 16) == FILE_DEVICE_NETWORK) { /* Wine-internal ioctl */ status = STATUS_BAD_DEVICE_TYPE; } else { FIXME( "Unknown ioctl %#x (device %#x, access %#x, function %#x, method %#x)\n", code, code >> 16, (code >> 14) & 3, (code >> 2) & 0xfff, code & 3 ); status = STATUS_INVALID_DEVICE_REQUEST; } break; } } if (needs_close) close( fd ); return status; }
32.855884
120
0.588799
10cbbe57a6cb86ad9bd893e3eb258446b2fa459f
6,128
h
C
third_party/mesa/MesaLib/src/mesa/program/prog_parameter.h
Scopetta197/chromium
b7bf8e39baadfd9089de2ebdc0c5d982de4a9820
[ "BSD-3-Clause" ]
212
2015-01-31T11:55:58.000Z
2022-02-22T06:35:11.000Z
third_party/mesa/MesaLib/src/mesa/program/prog_parameter.h
1065672644894730302/Chromium
239dd49e906be4909e293d8991e998c9816eaa35
[ "BSD-3-Clause" ]
5
2015-03-27T14:29:23.000Z
2019-09-25T13:23:12.000Z
third_party/mesa/MesaLib/src/mesa/program/prog_parameter.h
1065672644894730302/Chromium
239dd49e906be4909e293d8991e998c9816eaa35
[ "BSD-3-Clause" ]
221
2015-01-07T06:21:24.000Z
2022-02-11T02:51:12.000Z
/* * Mesa 3-D graphics library * Version: 7.3 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * 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 * BRIAN PAUL 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. */ /** * \file prog_parameter.c * Program parameter lists and functions. * \author Brian Paul */ #ifndef PROG_PARAMETER_H #define PROG_PARAMETER_H #include "main/mtypes.h" #include "prog_statevars.h" /** * Program parameter flags */ /*@{*/ #define PROG_PARAM_BIT_CENTROID 0x1 /**< for varying vars (GLSL 1.20) */ #define PROG_PARAM_BIT_INVARIANT 0x2 /**< for varying vars (GLSL 1.20) */ #define PROG_PARAM_BIT_FLAT 0x4 /**< for varying vars (GLSL 1.30) */ #define PROG_PARAM_BIT_LINEAR 0x8 /**< for varying vars (GLSL 1.30) */ #define PROG_PARAM_BIT_CYL_WRAP 0x10 /**< XXX gallium debug */ /*@}*/ /** * Program parameter. * Used by shaders/programs for uniforms, constants, varying vars, etc. */ struct gl_program_parameter { const char *Name; /**< Null-terminated string */ gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ /** * Number of components (1..4), or more. * If the number of components is greater than 4, * this parameter is part of a larger uniform like a GLSL matrix or array. * The next program parameter's Size will be Size-4 of this parameter. */ GLuint Size; GLboolean Initialized; /**< debug: Has the ParameterValue[] been set? */ GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ /** * A sequence of STATE_* tokens and integers to identify GL state. */ gl_state_index StateIndexes[STATE_LENGTH]; }; /** * List of gl_program_parameter instances. */ struct gl_program_parameter_list { GLuint Size; /**< allocated size of Parameters, ParameterValues */ GLuint NumParameters; /**< number of parameters in arrays */ struct gl_program_parameter *Parameters; /**< Array [Size] */ GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */ GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes might invalidate ParameterValues[] */ }; extern struct gl_program_parameter_list * _mesa_new_parameter_list(void); extern struct gl_program_parameter_list * _mesa_new_parameter_list_sized(unsigned size); extern void _mesa_free_parameter_list(struct gl_program_parameter_list *paramList); extern struct gl_program_parameter_list * _mesa_clone_parameter_list(const struct gl_program_parameter_list *list); extern struct gl_program_parameter_list * _mesa_combine_parameter_lists(const struct gl_program_parameter_list *a, const struct gl_program_parameter_list *b); static INLINE GLuint _mesa_num_parameters(const struct gl_program_parameter_list *list) { return list ? list->NumParameters : 0; } extern GLint _mesa_add_parameter(struct gl_program_parameter_list *paramList, gl_register_file type, const char *name, GLuint size, GLenum datatype, const GLfloat *values, const gl_state_index state[STATE_LENGTH], GLbitfield flags); extern GLint _mesa_add_named_parameter(struct gl_program_parameter_list *paramList, const char *name, const GLfloat values[4]); extern GLint _mesa_add_named_constant(struct gl_program_parameter_list *paramList, const char *name, const GLfloat values[4], GLuint size); extern GLint _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, const GLfloat values[4], GLuint size, GLuint *swizzleOut); extern GLint _mesa_add_varying(struct gl_program_parameter_list *paramList, const char *name, GLuint size, GLenum datatype, GLbitfield flags); extern GLint _mesa_add_attribute(struct gl_program_parameter_list *paramList, const char *name, GLint size, GLenum datatype, GLint attrib); extern GLint _mesa_add_state_reference(struct gl_program_parameter_list *paramList, const gl_state_index stateTokens[STATE_LENGTH]); extern GLfloat * _mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList, GLsizei nameLen, const char *name); extern GLint _mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList, GLsizei nameLen, const char *name); extern GLboolean _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, const GLfloat v[], GLuint vSize, GLint *posOut, GLuint *swizzleOut); extern GLuint _mesa_longest_parameter_name(const struct gl_program_parameter_list *list, gl_register_file type); extern GLuint _mesa_num_parameters_of_type(const struct gl_program_parameter_list *list, gl_register_file type); #endif /* PROG_PARAMETER_H */
36.260355
81
0.698597
803402aefaeb65d1bd9c81affd8d9bc853be65a8
5,938
c
C
drivers/acpi/acpica/hwesleep.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
5
2020-07-08T01:35:16.000Z
2021-04-12T16:35:29.000Z
drivers/acpi/acpica/hwesleep.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
null
null
null
drivers/acpi/acpica/hwesleep.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
null
null
null
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /****************************************************************************** * * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the * extended FADT-V5 sleep registers. * * Copyright (C) 2000 - 2021, Intel Corp. * *****************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME("hwesleep") /******************************************************************************* * * FUNCTION: acpi_hw_execute_sleep_method * * PARAMETERS: method_pathname - Pathname of method to execute * integer_argument - Argument to pass to the method * * RETURN: None * * DESCRIPTION: Execute a sleep/wake related method with one integer argument * and no return value. * ******************************************************************************/ void acpi_hw_execute_sleep_method(char *method_pathname, u32 integer_argument) { struct acpi_object_list arg_list; union acpi_object arg; acpi_status status; ACPI_FUNCTION_TRACE(hw_execute_sleep_method); /* One argument, integer_argument; No return value expected */ arg_list.count = 1; arg_list.pointer = &arg; arg.type = ACPI_TYPE_INTEGER; arg.integer.value = (u64)integer_argument; status = acpi_evaluate_object(NULL, method_pathname, &arg_list, NULL); if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { ACPI_EXCEPTION((AE_INFO, status, "While executing method %s", method_pathname)); } return_VOID; } /******************************************************************************* * * FUNCTION: acpi_hw_extended_sleep * * PARAMETERS: sleep_state - Which sleep state to enter * * RETURN: Status * * DESCRIPTION: Enter a system sleep state via the extended FADT sleep * registers (V5 FADT). * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ acpi_status acpi_hw_extended_sleep(u8 sleep_state) { acpi_status status; u8 sleep_control; u64 sleep_status; ACPI_FUNCTION_TRACE(hw_extended_sleep); /* Extended sleep registers must be valid */ if (!acpi_gbl_FADT.sleep_control.address || !acpi_gbl_FADT.sleep_status.address) { return_ACPI_STATUS(AE_NOT_EXIST); } /* Clear wake status (WAK_STS) */ status = acpi_write((u64)ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } acpi_gbl_system_awake_and_running = FALSE; /* * Set the SLP_TYP and SLP_EN bits. * * Note: We only use the first value returned by the \_Sx method * (acpi_gbl_sleep_type_a) - As per ACPI specification. */ ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Entering sleep state [S%u]\n", sleep_state)); sleep_control = ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & ACPI_X_SLEEP_TYPE_MASK) | ACPI_X_SLEEP_ENABLE; /* Flush caches, as per ACPI specification */ ACPI_FLUSH_CPU_CACHE(); status = acpi_os_enter_sleep(sleep_state, sleep_control, 0); if (status == AE_CTRL_TERMINATE) { return_ACPI_STATUS(AE_OK); } if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } status = acpi_write((u64)sleep_control, &acpi_gbl_FADT.sleep_control); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Wait for transition back to Working State */ do { status = acpi_read(&sleep_status, &acpi_gbl_FADT.sleep_status); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } while (!(((u8)sleep_status) & ACPI_X_WAKE_STATUS)); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * * FUNCTION: acpi_hw_extended_wake_prep * * PARAMETERS: sleep_state - Which sleep state we just exited * * RETURN: Status * * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after * a sleep. Called with interrupts ENABLED. * ******************************************************************************/ acpi_status acpi_hw_extended_wake_prep(u8 sleep_state) { acpi_status status; u8 sleep_type_value; ACPI_FUNCTION_TRACE(hw_extended_wake_prep); status = acpi_get_sleep_type_data(ACPI_STATE_S0, &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); if (ACPI_SUCCESS(status)) { sleep_type_value = ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & ACPI_X_SLEEP_TYPE_MASK); (void)acpi_write((u64)(sleep_type_value | ACPI_X_SLEEP_ENABLE), &acpi_gbl_FADT.sleep_control); } return_ACPI_STATUS(AE_OK); } /******************************************************************************* * * FUNCTION: acpi_hw_extended_wake * * PARAMETERS: sleep_state - Which sleep state we just exited * * RETURN: Status * * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep * Called with interrupts ENABLED. * ******************************************************************************/ acpi_status acpi_hw_extended_wake(u8 sleep_state) { ACPI_FUNCTION_TRACE(hw_extended_wake); /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; /* Execute the wake methods */ acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING); acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state); /* * Some BIOS code assumes that WAK_STS will be cleared on resume * and use it to determine whether the system is rebooting or * resuming. Clear WAK_STS for compatibility. */ (void)acpi_write((u64)ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status); acpi_gbl_system_awake_and_running = TRUE; acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING); return_ACPI_STATUS(AE_OK); }
28.68599
80
0.629673
4e19ef5ab072306d4c80eca8689614e309bce481
968
h
C
DearPyGui/src/core/AppItems/values/mvColorValue.h
htnminh/DearPyGui
bfbcb297f287295fae9766b21a53a99fbb0fe756
[ "MIT" ]
null
null
null
DearPyGui/src/core/AppItems/values/mvColorValue.h
htnminh/DearPyGui
bfbcb297f287295fae9766b21a53a99fbb0fe756
[ "MIT" ]
1
2021-08-16T02:39:32.000Z
2021-08-16T02:39:32.000Z
DearPyGui/src/core/AppItems/values/mvColorValue.h
Jah-On/DearPyGui
0e4f5d05555f950670e01bb2a647fb8b0b9a106f
[ "MIT" ]
null
null
null
#pragma once #include <array> #include "mvItemRegistry.h" namespace Marvel { MV_REGISTER_WIDGET(mvColorValue, MV_ITEM_DESC_DEFAULT, StorageValueTypes::Color, 1); class mvColorValue : public mvAppItem { public: static void InsertParser(std::map<std::string, mvPythonParser>* parsers); MV_APPLY_WIDGET_REGISTRATION(mvAppItemType::mvColorValue, add_color_value) MV_NO_COMMANDS MV_DEFAULT_CHILDREN MV_NO_CONSTANTS MV_START_PARENTS MV_ADD_PARENT(mvAppItemType::mvValueRegistry) MV_END_PARENTS public: mvColorValue(mvUUID uuid); void draw(ImDrawList* drawlist, float x, float y) override {} void setDataSource(mvUUID dataSource) override; void* getValue() override { return &_value; } PyObject* getPyValue() override; void setPyValue(PyObject* value) override; private: mvRef<std::array<float, 4>> _value = CreateRef<std::array<float, 4>>(std::array<float, 4>{0.0f, 0.0f, 0.0f, 1.0f}); float _disabled_value[4]{}; }; }
22.511628
117
0.748967
a2f5f72b590bfdfa2ca628d2e413740340fd9a7b
1,191
h
C
src/prod/src/PyHost/PyUtils.h
leikong/service-fabric
6b81daab914c8cf02801073fe6b6e5bf97270e9b
[ "MIT" ]
null
null
null
src/prod/src/PyHost/PyUtils.h
leikong/service-fabric
6b81daab914c8cf02801073fe6b6e5bf97270e9b
[ "MIT" ]
null
null
null
src/prod/src/PyHost/PyUtils.h
leikong/service-fabric
6b81daab914c8cf02801073fe6b6e5bf97270e9b
[ "MIT" ]
null
null
null
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #pragma once namespace PyHost { class PyUtils { public: static void ThrowOnFailure( std::string const & moduleName, std::string const & funcName, std::string const & operation); private: static void CheckPyErrAndThrow(std::string && debugTag); }; #define TRY_PARSE_PY_STRING( Input ) \ string parsed_##Input; \ { \ auto parseError = StringUtility::LpcwstrToWstring2( Input, false, parsed_##Input ); \ if (!parseError.IsSuccess()) \ { \ auto msg = formatString("Function '{0}': Parse({1}, __out {2}) failed: {3}", __FUNCTION__, #Input, parsed_##Input, parseError); \ Trace.WriteWarning("PyUtils", "{0}", msg); \ PyErr_SetString(PyExc_RuntimeError, msg.c_str()); \ return NULL; \ } \ } \ }
33.083333
145
0.513014
bd2e172022c96174da5510d3cc08ba1e934e77ea
4,386
c
C
bin/varnishd/cache_vrt_vmod.c
schongo/varnish
d02178ace8ad6bcb59d19aa14b776637d6c4fcd5
[ "BSD-2-Clause" ]
1
2015-11-05T15:21:41.000Z
2015-11-05T15:21:41.000Z
bin/varnishd/cache_vrt_vmod.c
wikimedia/operations-debs-varnish
2a9b4e476e1b51f52e31c58636bf661b7bd2f8fa
[ "BSD-2-Clause" ]
null
null
null
bin/varnishd/cache_vrt_vmod.c
wikimedia/operations-debs-varnish
2a9b4e476e1b51f52e31c58636bf661b7bd2f8fa
[ "BSD-2-Clause" ]
null
null
null
/*- * Copyright (c) 2006 Verdens Gang AS * Copyright (c) 2006-2011 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp <phk@phk.freebsd.dk> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Runtime support for compiled VCL programs */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <dlfcn.h> #include "cli_priv.h" #include "vrt.h" #include "cache.h" /*-------------------------------------------------------------------- * Modules stuff */ struct vmod { unsigned magic; #define VMOD_MAGIC 0xb750219c VTAILQ_ENTRY(vmod) list; int ref; char *nm; char *path; void *hdl; const void *funcs; int funclen; const void *idptr; }; static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods); int VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, const char *path, struct cli *cli) { struct vmod *v; void *x, *y, *z, *w; ASSERT_CLI(); VTAILQ_FOREACH(v, &vmods, list) if (!strcmp(v->nm, nm)) // Also path, len ? break; if (v == NULL) { ALLOC_OBJ(v, VMOD_MAGIC); AN(v); v->hdl = dlopen(path, RTLD_NOW | RTLD_LOCAL); if (v->hdl == NULL) { VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); VCLI_Out(cli, "dlopen() failed: %s\n", dlerror()); VCLI_Out(cli, "Check child process permissions.\n"); FREE_OBJ(v); return (1); } x = dlsym(v->hdl, "Vmod_Name"); y = dlsym(v->hdl, "Vmod_Len"); z = dlsym(v->hdl, "Vmod_Func"); w = dlsym(v->hdl, "Vmod_Id"); if (x == NULL || y == NULL || z == NULL || w == NULL) { VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); VCLI_Out(cli, "VMOD symbols not found\n"); VCLI_Out(cli, "Check relative pathnames.\n"); (void)dlclose(v->hdl); FREE_OBJ(v); return (1); } AN(x); AN(y); AN(z); AN(w); if (strcmp(x, nm)) { VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); VCLI_Out(cli, "File contain wrong VMOD (\"%s\")\n", x); VCLI_Out(cli, "Check relative pathnames ?.\n"); (void)dlclose(v->hdl); FREE_OBJ(v); return (1); } v->funclen = *(const int *)y; v->funcs = z; REPLACE(v->nm, nm); REPLACE(v->path, path); VSC_C_main->vmods++; VTAILQ_INSERT_TAIL(&vmods, v, list); v->idptr = w; } assert(len == v->funclen); memcpy(ptr, v->funcs, v->funclen); v->ref++; *hdl = v; return (0); } void VRT_Vmod_Fini(void **hdl) { struct vmod *v; ASSERT_CLI(); AN(*hdl); CAST_OBJ_NOTNULL(v, *hdl, VMOD_MAGIC); *hdl = NULL; if (--v->ref != 0) return; #ifndef DONT_DLCLOSE_VMODS AZ(dlclose(v->hdl)); #endif free(v->nm); free(v->path); VTAILQ_REMOVE(&vmods, v, list); VSC_C_main->vmods--; FREE_OBJ(v); } /*---------------------------------------------------------------------*/ static void ccf_debug_vmod(struct cli *cli, const char * const *av, void *priv) { struct vmod *v; (void)av; (void)priv; ASSERT_CLI(); VTAILQ_FOREACH(v, &vmods, list) VCLI_Out(cli, "%5d %s (%s)\n", v->ref, v->nm, v->path); } static struct cli_proto vcl_cmds[] = { { "debug.vmod", "debug.vmod", "show loaded vmods", 0, 0, "d", ccf_debug_vmod }, { NULL } }; void VMOD_Init(void) { CLI_AddFuncs(vcl_cmds); }
24.232044
77
0.637483
ea87698a056743f211b81a9116e70b61e723dc7a
790
h
C
ns-3-dev/build/include/ns3/lr-wpan-module.h
Marquez607/Wireless-Perf-Sim
1086759b6dbe7da192225780d5fe6a3da0c5eb07
[ "MIT" ]
1
2022-03-22T08:08:35.000Z
2022-03-22T08:08:35.000Z
ns-3-dev/build/include/ns3/lr-wpan-module.h
Marquez607/Wireless-Perf-Sim
1086759b6dbe7da192225780d5fe6a3da0c5eb07
[ "MIT" ]
null
null
null
ns-3-dev/build/include/ns3/lr-wpan-module.h
Marquez607/Wireless-Perf-Sim
1086759b6dbe7da192225780d5fe6a3da0c5eb07
[ "MIT" ]
null
null
null
#ifdef NS3_MODULE_COMPILATION error "Do not include ns3 module aggregator headers from other modules these are meant only for end user scripts." #endif #ifndef NS3_MODULE_LR_WPAN // Module headers: #include <ns3/lr-wpan-helper.h> #include <ns3/lr-wpan-csmaca.h> #include <ns3/lr-wpan-error-model.h> #include <ns3/lr-wpan-fields.h> #include <ns3/lr-wpan-interference-helper.h> #include <ns3/lr-wpan-lqi-tag.h> #include <ns3/lr-wpan-mac-header.h> #include <ns3/lr-wpan-mac-pl-headers.h> #include <ns3/lr-wpan-mac-trailer.h> #include <ns3/lr-wpan-mac.h> #include <ns3/lr-wpan-net-device.h> #include <ns3/lr-wpan-phy.h> #include <ns3/lr-wpan-spectrum-signal-parameters.h> #include <ns3/lr-wpan-spectrum-value-helper.h> #endif
39.5
119
0.691139
d8606f62367327d79180b6d189764847472fc67d
3,576
h
C
src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.h
jtschuster/runtime
edd359716c2096274e656d26ed8945d99afc2da5
[ "MIT" ]
1
2021-11-21T18:25:08.000Z
2021-11-21T18:25:08.000Z
src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.h
jtschuster/runtime
edd359716c2096274e656d26ed8945d99afc2da5
[ "MIT" ]
1
2021-11-19T10:42:54.000Z
2021-11-19T10:42:54.000Z
src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.h
jtschuster/runtime
edd359716c2096274e656d26ed8945d99afc2da5
[ "MIT" ]
null
null
null
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #pragma once #if defined(TARGET_AMD64) || defined(TARGET_X86) struct T_RUNTIME_FUNCTION { uint32_t BeginAddress; uint32_t EndAddress; uint32_t UnwindInfoAddress; }; #elif defined(TARGET_ARM) struct T_RUNTIME_FUNCTION { uint32_t BeginAddress; uint32_t UnwindData; }; #elif defined(TARGET_ARM64) struct T_RUNTIME_FUNCTION { uint32_t BeginAddress; union { uint32_t UnwindData; struct { uint32_t Flag : 2; uint32_t FunctionLength : 11; uint32_t RegF : 3; uint32_t RegI : 4; uint32_t H : 1; uint32_t CR : 2; uint32_t FrameSize : 9; } PackedUnwindData; }; }; #else #error unexpected target architecture #endif typedef DPTR(T_RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION; class CoffNativeCodeManager : public ICodeManager { TADDR m_moduleBase; PTR_VOID m_pvManagedCodeStartRange; uint32_t m_cbManagedCodeRange; PTR_RUNTIME_FUNCTION m_pRuntimeFunctionTable; uint32_t m_nRuntimeFunctionTable; PTR_PTR_VOID m_pClasslibFunctions; uint32_t m_nClasslibFunctions; public: CoffNativeCodeManager(TADDR moduleBase, PTR_VOID pvManagedCodeStartRange, uint32_t cbManagedCodeRange, PTR_RUNTIME_FUNCTION pRuntimeFunctionTable, uint32_t nRuntimeFunctionTable, PTR_PTR_VOID pClasslibFunctions, uint32_t nClasslibFunctions); ~CoffNativeCodeManager(); // // Code manager methods // bool FindMethodInfo(PTR_VOID ControlPC, MethodInfo * pMethodInfoOut); bool IsFunclet(MethodInfo * pMethodInfo); bool IsFilter(MethodInfo * pMethodInfo); PTR_VOID GetFramePointer(MethodInfo * pMethodInfo, REGDISPLAY * pRegisterSet); uint32_t GetCodeOffset(MethodInfo * pMethodInfo, PTR_VOID address, /*out*/ PTR_UInt8* gcInfo); bool IsSafePoint(PTR_VOID pvAddress); void EnumGcRefs(MethodInfo * pMethodInfo, PTR_VOID safePointAddress, REGDISPLAY * pRegisterSet, GCEnumContext * hCallback, bool isActiveStackFrame); bool UnwindStackFrame(MethodInfo * pMethodInfo, REGDISPLAY * pRegisterSet, // in/out PInvokeTransitionFrame** ppPreviousTransitionFrame); // out uintptr_t GetConservativeUpperBoundForOutgoingArgs(MethodInfo * pMethodInfo, REGDISPLAY * pRegisterSet); bool GetReturnAddressHijackInfo(MethodInfo * pMethodInfo, REGDISPLAY * pRegisterSet, // in PTR_PTR_VOID * ppvRetAddrLocation, // out GCRefKind * pRetValueKind); // out PTR_VOID RemapHardwareFaultToGCSafePoint(MethodInfo * pMethodInfo, PTR_VOID controlPC); bool EHEnumInit(MethodInfo * pMethodInfo, PTR_VOID * pMethodStartAddress, EHEnumState * pEHEnumState); bool EHEnumNext(EHEnumState * pEHEnumState, EHClause * pEHClause); PTR_VOID GetMethodStartAddress(MethodInfo * pMethodInfo); void * GetClasslibFunction(ClasslibFunctionId functionId); PTR_VOID GetAssociatedData(PTR_VOID ControlPC); PTR_VOID GetOsModuleHandle(); };
32.807339
106
0.642897
e7f42b208510288f31e81a8d0a2463ac1cd1bbf4
3,146
h
C
Qt/Python/pqPythonSyntaxHighlighter.h
danlipsa/ParaView-vtk-optimizations
b2c0380ad833c4459cd877d623d382888903d670
[ "Apache-2.0" ]
1
2020-05-21T20:20:59.000Z
2020-05-21T20:20:59.000Z
Qt/Python/pqPythonSyntaxHighlighter.h
danlipsa/ParaView-vtk-optimizations
b2c0380ad833c4459cd877d623d382888903d670
[ "Apache-2.0" ]
null
null
null
Qt/Python/pqPythonSyntaxHighlighter.h
danlipsa/ParaView-vtk-optimizations
b2c0380ad833c4459cd877d623d382888903d670
[ "Apache-2.0" ]
5
2016-04-14T13:42:37.000Z
2021-05-22T04:59:42.000Z
/*========================================================================= Program: ParaView Module: pqPythonSyntaxHighlighter.h Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc. All rights reserved. ParaView is a free software; you can redistribute it and/or modify it under the terms of the ParaView license version 1.2. See License_v1.2.txt for the full ParaView license. A copy of this license can be obtained by contacting Kitware Inc. 28 Corporate Drive Clifton Park, NY 12065 USA 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 AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef _pqPythonSyntaxHighlighter_h #define _pqPythonSyntaxHighlighter_h #include "pqPythonModule.h" #include <QObject> #include <QScopedPointer> class QTextEdit; /// This class is a helper object to attach to a QTextEdit to add Python /// syntax highlighting to the text that is displayed. The pygments python /// module is used to generate syntax highlighting. Since mixing tabs and /// spaces is an error for python's indentation, tabs are highlighted in red. /// /// The QTextEdit is set up so that it uses a fixed-width font and tabs are /// the width of 4 spaces by the constructor. /// /// This will also optionally /// capture presses of the tab key that would go to the QTextEdit and /// insert 4 spaces instead of the tab. This option is enabled by default. class PQPYTHON_EXPORT pqPythonSyntaxHighlighter : public QObject { Q_OBJECT public: typedef QObject Superclass; /// Creates a pqPythonSyntaxHighlighter on the given QTextEdit /// NOTE: the optional tab key capture is enabled by the constructor explicit pqPythonSyntaxHighlighter(QTextEdit* textEdit, QObject* p = 0); virtual ~pqPythonSyntaxHighlighter(); /// Returns true if the tab key is being intercepted to insert spaces in /// the text edit bool isReplacingTabs() const; /// Used to enable/disable tab key capture /// Passing true will cause the tab key to insert 4 spaces in the QTextEdit void setReplaceTabs(bool replaceTabs); protected: /// This event filter is applied to the TextEdit to translate presses of the /// Tab key into 4 spaces being inserted bool eventFilter(QObject*, QEvent*); private slots: void rehighlightSyntax(); private: class pqInternal; const QScopedPointer< pqInternal > Internals; Q_DISABLE_COPY(pqPythonSyntaxHighlighter) }; #endif
39.325
78
0.732676
37e712d71d12b13a1e57c4e93658d5d35d40c93c
15,078
c
C
release/src-rt-6.x.4708/router/samba-3.5.8/source3/libsmb/cliquota.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
4
2017-05-17T11:27:04.000Z
2020-05-24T07:23:26.000Z
release/src-rt-6.x.4708/router/samba-3.5.8/source3/libsmb/cliquota.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
1
2018-08-21T03:42:06.000Z
2018-08-21T03:42:06.000Z
release/src-rt-6.x.4708/router/samba-3.5.8/source3/libsmb/cliquota.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
5
2017-10-11T08:09:11.000Z
2020-10-14T04:10:13.000Z
/* Unix SMB/CIFS implementation. client quota functions Copyright (C) Stefan (metze) Metzmacher 2003 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/>. */ #include "includes.h" NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum) { return cli_ntcreate(cli, FAKE_FILE_NAME_QUOTA_WIN32, 0x00000016, DESIRED_ACCESS_PIPE, 0x00000000, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x00000000, 0x03, quota_fnum); } void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list) { if (!qt_list) return; if ((*qt_list)->mem_ctx) talloc_destroy((*qt_list)->mem_ctx); (*qt_list) = NULL; return; } static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, unsigned int *offset, SMB_NTQUOTA_STRUCT *pqt) { int sid_len; SMB_NTQUOTA_STRUCT qt; ZERO_STRUCT(qt); if (!rdata||!offset||!pqt) { smb_panic("parse_quota_record: called with NULL POINTER!"); } if (rdata_count < 40) { return False; } /* offset to next quota record. * 4 bytes IVAL(rdata,0) * unused here... */ *offset = IVAL(rdata,0); /* sid len */ sid_len = IVAL(rdata,4); if (rdata_count < 40+sid_len) { return False; } /* unknown 8 bytes in pdata * maybe its the change time in NTTIME */ /* the used space 8 bytes (uint64_t)*/ qt.usedspace = (uint64_t)IVAL(rdata,16); #ifdef LARGE_SMB_OFF_T qt.usedspace |= (((uint64_t)IVAL(rdata,20)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,20) != 0)&& ((qt.usedspace != 0xFFFFFFFF)|| (IVAL(rdata,20)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } #endif /* LARGE_SMB_OFF_T */ /* the soft quotas 8 bytes (uint64_t)*/ qt.softlim = (uint64_t)IVAL(rdata,24); #ifdef LARGE_SMB_OFF_T qt.softlim |= (((uint64_t)IVAL(rdata,28)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| (IVAL(rdata,28)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } #endif /* LARGE_SMB_OFF_T */ /* the hard quotas 8 bytes (uint64_t)*/ qt.hardlim = (uint64_t)IVAL(rdata,32); #ifdef LARGE_SMB_OFF_T qt.hardlim |= (((uint64_t)IVAL(rdata,36)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| (IVAL(rdata,36)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } #endif /* LARGE_SMB_OFF_T */ if (!sid_parse(rdata+40,sid_len,&qt.sid)) { return false; } qt.qtype = SMB_USER_QUOTA_TYPE; *pqt = qt; return True; } bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { bool ret = False; uint16 setup; char params[16]; unsigned int data_len; char data[SID_MAX_SIZE+8]; char *rparam=NULL, *rdata=NULL; unsigned int rparam_count=0, rdata_count=0; unsigned int sid_len; unsigned int offset; if (!cli||!pqt) { smb_panic("cli_get_user_quota() called with NULL Pointer!"); } setup = NT_TRANSACT_GET_USER_QUOTA; SSVAL(params, 0,quota_fnum); SSVAL(params, 2,TRANSACT_GET_USER_QUOTA_FOR_SID); SIVAL(params, 4,0x00000024); SIVAL(params, 8,0x00000000); SIVAL(params,12,0x00000024); sid_len = ndr_size_dom_sid(&pqt->sid, NULL, 0); data_len = sid_len+8; SIVAL(data, 0, 0x00000000); SIVAL(data, 4, sid_len); sid_linearize(data+8, sid_len, &pqt->sid); if (!cli_send_nt_trans(cli, NT_TRANSACT_GET_USER_QUOTA, 0, &setup, 1, 0, params, 16, 4, data, data_len, 112)) { DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); goto cleanup; } if (!cli_receive_nt_trans(cli, &rparam, &rparam_count, &rdata, &rdata_count)) { DEBUG(1,("Failed to recv NT_TRANSACT_GET_USER_QUOTA\n")); goto cleanup; } if (cli_is_error(cli)) { ret = False; goto cleanup; } else { ret = True; } if ((rparam&&rdata)&&(rparam_count>=4&&rdata_count>=8)) { ret = parse_user_quota_record(rdata, rdata_count, &offset, pqt); } else { DEBUG(0,("Got INVALID NT_TRANSACT_GET_USER_QUOTA reply.\n")); ret = False; } cleanup: SAFE_FREE(rparam); SAFE_FREE(rdata); return ret; } bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { bool ret = False; uint16 setup; char params[2]; char data[112]; char *rparam=NULL, *rdata=NULL; unsigned int rparam_count=0, rdata_count=0; unsigned int sid_len; memset(data,'\0',112); if (!cli||!pqt) { smb_panic("cli_set_user_quota() called with NULL Pointer!"); } setup = NT_TRANSACT_SET_USER_QUOTA; SSVAL(params,0,quota_fnum); sid_len = ndr_size_dom_sid(&pqt->sid, NULL, 0); SIVAL(data,0,0); SIVAL(data,4,sid_len); SBIG_UINT(data, 8,(uint64_t)0); SBIG_UINT(data,16,pqt->usedspace); SBIG_UINT(data,24,pqt->softlim); SBIG_UINT(data,32,pqt->hardlim); sid_linearize(data+40, sid_len, &pqt->sid); if (!cli_send_nt_trans(cli, NT_TRANSACT_SET_USER_QUOTA, 0, &setup, 1, 0, params, 2, 0, data, 112, 0)) { DEBUG(1,("Failed to send NT_TRANSACT_SET_USER_QUOTA\n")); goto cleanup; } if (!cli_receive_nt_trans(cli, &rparam, &rparam_count, &rdata, &rdata_count)) { DEBUG(1,("NT_TRANSACT_SET_USER_QUOTA failed\n")); goto cleanup; } if (cli_is_error(cli)) { ret = False; goto cleanup; } else { ret = True; } cleanup: SAFE_FREE(rparam); SAFE_FREE(rdata); return ret; } bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list) { bool ret = False; uint16 setup; char params[16]; char *rparam=NULL, *rdata=NULL; unsigned int rparam_count=0, rdata_count=0; unsigned int offset; const char *curdata = NULL; unsigned int curdata_count = 0; TALLOC_CTX *mem_ctx = NULL; SMB_NTQUOTA_STRUCT qt; SMB_NTQUOTA_LIST *tmp_list_ent; if (!cli||!pqt_list) { smb_panic("cli_list_user_quota() called with NULL Pointer!"); } setup = NT_TRANSACT_GET_USER_QUOTA; SSVAL(params, 0,quota_fnum); SSVAL(params, 2,TRANSACT_GET_USER_QUOTA_LIST_START); SIVAL(params, 4,0x00000000); SIVAL(params, 8,0x00000000); SIVAL(params,12,0x00000000); if (!cli_send_nt_trans(cli, NT_TRANSACT_GET_USER_QUOTA, 0, &setup, 1, 0, params, 16, 4, NULL, 0, 2048)) { DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); goto cleanup; } if (!cli_receive_nt_trans(cli, &rparam, &rparam_count, &rdata, &rdata_count)) { DEBUG(1,("Failed to recv NT_TRANSACT_GET_USER_QUOTA\n")); goto cleanup; } if (cli_is_error(cli)) { ret = False; goto cleanup; } else { ret = True; } if (rdata_count == 0) { *pqt_list = NULL; return True; } if ((mem_ctx=talloc_init("SMB_USER_QUOTA_LIST"))==NULL) { DEBUG(0,("talloc_init() failed\n")); return (-1); } offset = 1; for (curdata=rdata,curdata_count=rdata_count; ((curdata)&&(curdata_count>=8)&&(offset>0)); curdata +=offset,curdata_count -= offset) { ZERO_STRUCT(qt); if (!parse_user_quota_record(curdata, curdata_count, &offset, &qt)) { DEBUG(1,("Failed to parse the quota record\n")); goto cleanup; } if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); return (-1); } if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); return (-1); } memcpy(tmp_list_ent->quotas,&qt,sizeof(qt)); tmp_list_ent->mem_ctx = mem_ctx; DLIST_ADD((*pqt_list),tmp_list_ent); } SSVAL(params, 2,TRANSACT_GET_USER_QUOTA_LIST_CONTINUE); while(1) { if (!cli_send_nt_trans(cli, NT_TRANSACT_GET_USER_QUOTA, 0, &setup, 1, 0, params, 16, 4, NULL, 0, 2048)) { DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); goto cleanup; } SAFE_FREE(rparam); SAFE_FREE(rdata); if (!cli_receive_nt_trans(cli, &rparam, &rparam_count, &rdata, &rdata_count)) { DEBUG(1,("Failed to recv NT_TRANSACT_GET_USER_QUOTA\n")); goto cleanup; } if (cli_is_error(cli)) { ret = False; goto cleanup; } else { ret = True; } if (rdata_count == 0) { break; } offset = 1; for (curdata=rdata,curdata_count=rdata_count; ((curdata)&&(curdata_count>=8)&&(offset>0)); curdata +=offset,curdata_count -= offset) { ZERO_STRUCT(qt); if (!parse_user_quota_record(curdata, curdata_count, &offset, &qt)) { DEBUG(1,("Failed to parse the quota record\n")); goto cleanup; } if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); goto cleanup; } if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); goto cleanup; } memcpy(tmp_list_ent->quotas,&qt,sizeof(qt)); tmp_list_ent->mem_ctx = mem_ctx; DLIST_ADD((*pqt_list),tmp_list_ent); } } ret = True; cleanup: SAFE_FREE(rparam); SAFE_FREE(rdata); return ret; } bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { bool ret = False; uint16 setup; char param[2]; char *rparam=NULL, *rdata=NULL; unsigned int rparam_count=0, rdata_count=0; SMB_NTQUOTA_STRUCT qt; ZERO_STRUCT(qt); if (!cli||!pqt) { smb_panic("cli_get_fs_quota_info() called with NULL Pointer!"); } setup = TRANSACT2_QFSINFO; SSVAL(param,0,SMB_FS_QUOTA_INFORMATION); if (!cli_send_trans(cli, SMBtrans2, NULL, 0, 0, &setup, 1, 0, param, 2, 0, NULL, 0, 560)) { goto cleanup; } if (!cli_receive_trans(cli, SMBtrans2, &rparam, &rparam_count, &rdata, &rdata_count)) { goto cleanup; } if (cli_is_error(cli)) { ret = False; goto cleanup; } else { ret = True; } if (rdata_count < 48) { goto cleanup; } /* unknown_1 24 NULL bytes in pdata*/ /* the soft quotas 8 bytes (uint64_t)*/ qt.softlim = (uint64_t)IVAL(rdata,24); #ifdef LARGE_SMB_OFF_T qt.softlim |= (((uint64_t)IVAL(rdata,28)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| (IVAL(rdata,28)!=0xFFFFFFFF))) { /* more than 32 bits? */ goto cleanup; } #endif /* LARGE_SMB_OFF_T */ /* the hard quotas 8 bytes (uint64_t)*/ qt.hardlim = (uint64_t)IVAL(rdata,32); #ifdef LARGE_SMB_OFF_T qt.hardlim |= (((uint64_t)IVAL(rdata,36)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| (IVAL(rdata,36)!=0xFFFFFFFF))) { /* more than 32 bits? */ goto cleanup; } #endif /* LARGE_SMB_OFF_T */ /* quota_flags 2 bytes **/ qt.qflags = SVAL(rdata,40); qt.qtype = SMB_USER_FS_QUOTA_TYPE; *pqt = qt; ret = True; cleanup: SAFE_FREE(rparam); SAFE_FREE(rdata); return ret; } bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { bool ret = False; uint16 setup; char param[4]; char data[48]; char *rparam=NULL, *rdata=NULL; unsigned int rparam_count=0, rdata_count=0; SMB_NTQUOTA_STRUCT qt; ZERO_STRUCT(qt); memset(data,'\0',48); if (!cli||!pqt) { smb_panic("cli_set_fs_quota_info() called with NULL Pointer!"); } setup = TRANSACT2_SETFSINFO; SSVAL(param,0,quota_fnum); SSVAL(param,2,SMB_FS_QUOTA_INFORMATION); /* Unknown1 24 NULL bytes*/ /* Default Soft Quota 8 bytes */ SBIG_UINT(data,24,pqt->softlim); /* Default Hard Quota 8 bytes */ SBIG_UINT(data,32,pqt->hardlim); /* Quota flag 2 bytes */ SSVAL(data,40,pqt->qflags); /* Unknown3 6 NULL bytes */ if (!cli_send_trans(cli, SMBtrans2, NULL, 0, 0, &setup, 1, 0, param, 4, 0, data, 48, 0)) { goto cleanup; } if (!cli_receive_trans(cli, SMBtrans2, &rparam, &rparam_count, &rdata, &rdata_count)) { goto cleanup; } if (cli_is_error(cli)) { ret = False; goto cleanup; } else { ret = True; } cleanup: SAFE_FREE(rparam); SAFE_FREE(rdata); return ret; } static const char *quota_str_static(uint64_t val, bool special, bool _numeric) { const char *result; if (!_numeric&&special&&(val == SMB_NTQUOTAS_NO_LIMIT)) { return "NO LIMIT"; } result = talloc_asprintf(talloc_tos(), "%"PRIu64, val); SMB_ASSERT(result != NULL); return result; } void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric)) { TALLOC_CTX *frame = talloc_stackframe(); if (!qt) { smb_panic("dump_ntquota() called with NULL pointer"); } switch (qt->qtype) { case SMB_USER_FS_QUOTA_TYPE: { d_printf("File System QUOTAS:\n"); d_printf("Limits:\n"); d_printf(" Default Soft Limit: %15s\n",quota_str_static(qt->softlim,True,_numeric)); d_printf(" Default Hard Limit: %15s\n",quota_str_static(qt->hardlim,True,_numeric)); d_printf("Quota Flags:\n"); d_printf(" Quotas Enabled: %s\n", ((qt->qflags&QUOTAS_ENABLED)||(qt->qflags&QUOTAS_DENY_DISK))?"On":"Off"); d_printf(" Deny Disk: %s\n",(qt->qflags&QUOTAS_DENY_DISK)?"On":"Off"); d_printf(" Log Soft Limit: %s\n",(qt->qflags&QUOTAS_LOG_THRESHOLD)?"On":"Off"); d_printf(" Log Hard Limit: %s\n",(qt->qflags&QUOTAS_LOG_LIMIT)?"On":"Off"); } break; case SMB_USER_QUOTA_TYPE: { fstring username_str = {0}; if (_sidtostring) { _sidtostring(username_str,&qt->sid,_numeric); } else { sid_to_fstring(username_str, &qt->sid); } if (_verbose) { d_printf("Quotas for User: %s\n",username_str); d_printf("Used Space: %15s\n",quota_str_static(qt->usedspace,False,_numeric)); d_printf("Soft Limit: %15s\n",quota_str_static(qt->softlim,True,_numeric)); d_printf("Hard Limit: %15s\n",quota_str_static(qt->hardlim,True,_numeric)); } else { d_printf("%-30s: ",username_str); d_printf("%15s/",quota_str_static(qt->usedspace,False,_numeric)); d_printf("%15s/",quota_str_static(qt->softlim,True,_numeric)); d_printf("%15s\n",quota_str_static(qt->hardlim,True,_numeric)); } } break; default: d_printf("dump_ntquota() invalid qtype(%d)\n",qt->qtype); } TALLOC_FREE(frame); return; } void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric)) { SMB_NTQUOTA_LIST *cur; for (cur = *qtl;cur;cur = cur->next) { if (cur->quotas) dump_ntquota(cur->quotas,_verbose,_numeric,_sidtostring); } }
23.744882
140
0.662886
88ae6da039fcc548d41efb8cc5b58607a2932716
461
h
C
src/anchors.h
zm66260/maskDetection
8df15655477923a5e621b9831c72e58cd51a52c7
[ "MIT" ]
1
2020-07-27T05:59:48.000Z
2020-07-27T05:59:48.000Z
src/anchors.h
zm66260/maskDetection
8df15655477923a5e621b9831c72e58cd51a52c7
[ "MIT" ]
null
null
null
src/anchors.h
zm66260/maskDetection
8df15655477923a5e621b9831c72e58cd51a52c7
[ "MIT" ]
null
null
null
#include "xtensor/xarray.hpp" class anchors{ public: xt::xarray<float> generate_anchors(xt::xarray<float>& feature_map_sizes, xt::xarray<float>& anchor_sizes, xt::xarray<float>& anchor_ratios); xt::xarray<float> decode_bbox(xt::xarray<float>& anchors, xt::xarray<float>& raw_outputs, xt::xarray<float> variances = {0.1, 0.1, 0.2, 0.2}); private: // template<typename T> std::vector<float> linspace(T start_in, T end_in, int num_in); };
32.928571
146
0.694143
5368d1fcb2034e7267451feceeee51ef67996d68
1,428
c
C
test/clob_06.c
hroptatyr/clob
b41de8799f1b7da8d9d7243a488a2841c932fbf5
[ "BSD-3-Clause" ]
19
2017-06-27T15:22:52.000Z
2022-03-23T03:48:47.000Z
test/clob_06.c
hroptatyr/clob
b41de8799f1b7da8d9d7243a488a2841c932fbf5
[ "BSD-3-Clause" ]
20
2021-02-01T07:51:09.000Z
2021-10-01T12:23:22.000Z
test/clob_06.c
hroptatyr/clob
b41de8799f1b7da8d9d7243a488a2841c932fbf5
[ "BSD-3-Clause" ]
10
2017-10-25T08:44:55.000Z
2021-12-01T04:11:29.000Z
#include <stdio.h> #include "dfp754_d64.h" #include "clob.h" #include "nifty.h" int main(void) { clob_t c; clob_aggiter_t i; size_t j = 0U; c = make_clob(); clob_add(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_ASK, {100.dd, 0.0dd}, .lmt = 200.0dd}); clob_add(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_ASK, {100.dd, 0.0dd}, .lmt = 200.0dd}); clob_add(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_BID, {10.dd, 50.0dd}, .lmt = 198.0dd}); clob_add(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_BID, {10.dd, 50.0dd}, .lmt = 197.0dd}); clob_add(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_BID, {10.dd, 50.0dd}, .lmt = 198.0dd}); clob_add(c, (clob_ord_t){CLOB_TYPE_MKT, CLOB_SIDE_SHORT, {80.dd, 0.0dd}}); puts("LMT+BID"); i = clob_aggiter(c, CLOB_TYPE_LMT, CLOB_SIDE_BID); for (; clob_aggiter_next(&i); j++) { printf("%f %f\n", (double)i.p, (double)(i.q.dis + i.q.hid)); } puts("LMT+ASK"); i = clob_aggiter(c, CLOB_TYPE_LMT, CLOB_SIDE_ASK); for (; clob_aggiter_next(&i); j++) { printf("%f %f\n", (double)i.p, (double)(i.q.dis + i.q.hid)); } puts("MKT+BID"); i = clob_aggiter(c, CLOB_TYPE_MKT, CLOB_SIDE_BID); for (; clob_aggiter_next(&i); j++) { printf("%f %f\n", (double)i.p, (double)(i.q.dis + i.q.hid)); } puts("MKT+ASK"); i = clob_aggiter(c, CLOB_TYPE_MKT, CLOB_SIDE_ASK); for (; clob_aggiter_next(&i); j++) { printf("%f %f\n", (double)i.p, (double)(i.q.dis + i.q.hid)); } free_clob(c); return j != 4; }
30.382979
90
0.641457
7af07705eb80d83ee49265a746b3221fc50e1de7
8,070
h
C
FDK/Tools/Programs/makeotf/makeotf_lib/source/typecomp/eurosans.h
czchen/afdko
86602643ce35bffe0573646f87cde6a0c219b7d5
[ "Apache-2.0" ]
null
null
null
FDK/Tools/Programs/makeotf/makeotf_lib/source/typecomp/eurosans.h
czchen/afdko
86602643ce35bffe0573646f87cde6a0c219b7d5
[ "Apache-2.0" ]
null
null
null
FDK/Tools/Programs/makeotf/makeotf_lib/source/typecomp/eurosans.h
czchen/afdko
86602643ce35bffe0573646f87cde6a0c219b7d5
[ "Apache-2.0" ]
null
null
null
/* DO NOT EDIT; this file generated with: mkhex eurosans.cff */ 0x01, 0x00, 0x04, 0x02, 0x00, 0x01, 0x01, 0x01, 0x0c, 0x45, 0x75, 0x72, 0x6f, 0x4d, 0x4d, 0x2d, 0x53, 0x61, 0x6e, 0x73, 0x00, 0x01, 0x01, 0x01, 0x51, 0x91, 0xcf, 0xf9, 0x82, 0xab, 0xf8, 0x1c, 0xf8, 0x1d, 0x0c, 0x18, 0xf8, 0x0f, 0x00, 0xf8, 0x1e, 0x01, 0xf8, 0x1f, 0x02, 0xf8, 0x20, 0x03, 0xf8, 0x21, 0x04, 0x1f, 0x9d, 0x7f, 0xf7, 0x83, 0xf9, 0x40, 0xae, 0x85, 0x93, 0x7d, 0x85, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0xf8, 0xc0, 0x8f, 0xf8, 0xc1, 0xc3, 0xf8, 0xa5, 0x8b, 0x8b, 0x8c, 0x8b, 0x8b, 0x8f, 0x10, 0x0e, 0x05, 0xf8, 0x22, 0xf8, 0x23, 0x0c, 0x1a, 0xf8, 0xa1, 0x10, 0xf8, 0xa5, 0x0f, 0xf8, 0xaa, 0x11, 0xd4, 0x1c, 0x04, 0xd5, 0x12, 0x00, 0x09, 0x02, 0x00, 0x01, 0x00, 0x05, 0x00, 0x9f, 0x01, 0x27, 0x01, 0x6b, 0x01, 0x77, 0x01, 0x7e, 0x01, 0x81, 0x01, 0x87, 0x01, 0x8c, 0x45, 0x75, 0x72, 0x6f, 0x8d, 0x8b, 0x8d, 0x0c, 0x0d, 0x8c, 0xff, 0x00, 0x00, 0x55, 0x55, 0x0c, 0x1b, 0x0c, 0x1b, 0x8d, 0x0c, 0x14, 0xff, 0x00, 0x00, 0x65, 0x1c, 0x0c, 0x1b, 0x8e, 0x0c, 0x14, 0x0c, 0x18, 0x8f, 0x0c, 0x14, 0x0c, 0x0b, 0x90, 0x0c, 0x14, 0x8b, 0x8b, 0x0c, 0x15, 0x9f, 0x0c, 0x0b, 0xf7, 0x84, 0x0c, 0x0c, 0x8b, 0x0c, 0x15, 0x9f, 0x0c, 0x16, 0x8c, 0x8b, 0x0c, 0x15, 0xf7, 0x98, 0x0c, 0x16, 0x8b, 0x0c, 0x14, 0x8b, 0x8c, 0x0c, 0x15, 0xf7, 0x9d, 0x0c, 0x0b, 0xf8, 0xe7, 0x0c, 0x0c, 0x8c, 0x0c, 0x15, 0xf7, 0x9d, 0x0c, 0x16, 0x8c, 0x8c, 0x0c, 0x15, 0xf9, 0xf0, 0x0c, 0x16, 0x8c, 0x0c, 0x14, 0x90, 0x0c, 0x15, 0x8c, 0x0c, 0x15, 0x0c, 0x18, 0x8f, 0x0c, 0x15, 0x0c, 0x0a, 0x8e, 0x0c, 0x15, 0x0c, 0x0c, 0x8b, 0x0c, 0x15, 0x0c, 0x1b, 0x8e, 0x0c, 0x15, 0x0c, 0x0e, 0x0c, 0x18, 0x90, 0x0c, 0x15, 0x8c, 0x0c, 0x15, 0x0c, 0x18, 0x0c, 0x0a, 0x8f, 0x0c, 0x15, 0x0c, 0x0a, 0x8b, 0x0c, 0x16, 0x8b, 0x0c, 0x14, 0x8c, 0x8b, 0x8b, 0x8d, 0x0c, 0x08, 0x0e, 0x8c, 0x8b, 0x8d, 0x0c, 0x0d, 0xff, 0x00, 0x00, 0x68, 0x89, 0x8d, 0x0c, 0x14, 0x8c, 0x8b, 0x0c, 0x15, 0x8d, 0x0c, 0x15, 0x0c, 0x0c, 0x8b, 0x0c, 0x15, 0x8d, 0x0c, 0x15, 0x0c, 0x0b, 0x8c, 0x8d, 0x0c, 0x15, 0x0c, 0x0b, 0x0c, 0x0c, 0x8b, 0x0c, 0x15, 0x8d, 0x0c, 0x15, 0x0c, 0x16, 0x0c, 0x1b, 0x8f, 0x0c, 0x14, 0x0c, 0x0b, 0x8e, 0x0c, 0x14, 0x8b, 0x90, 0x0c, 0x14, 0x8b, 0x91, 0x0c, 0x14, 0x8e, 0x0c, 0x15, 0x0c, 0x1b, 0x8c, 0x8c, 0x0c, 0x15, 0x0c, 0x0b, 0x0c, 0x18, 0x92, 0x0c, 0x14, 0x8c, 0x0c, 0x15, 0x0c, 0x18, 0x93, 0x0c, 0x14, 0x8f, 0x0c, 0x15, 0x0c, 0x1b, 0x8c, 0x8c, 0x0c, 0x15, 0x0c, 0x0b, 0x0c, 0x18, 0x94, 0x0c, 0x14, 0x8c, 0x0c, 0x15, 0x0c, 0x18, 0x95, 0x0c, 0x14, 0x8b, 0x96, 0x0c, 0x14, 0x8b, 0x97, 0x0c, 0x14, 0x8b, 0x8b, 0x92, 0x90, 0x8b, 0x0c, 0x15, 0x8d, 0x0c, 0x15, 0x0c, 0x16, 0x91, 0x0c, 0x08, 0x0e, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x31, 0x39, 0x39, 0x38, 0x20, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x20, 0x49, 0x6e, 0x63, 0x6f, 0x72, 0x70, 0x6f, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2e, 0x20, 0x20, 0x41, 0x6c, 0x6c, 0x20, 0x52, 0x69, 0x67, 0x68, 0x74, 0x73, 0x20, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x2e, 0x45, 0x75, 0x72, 0x6f, 0x20, 0x4d, 0x4d, 0x20, 0x53, 0x61, 0x6e, 0x73, 0x45, 0x75, 0x72, 0x6f, 0x20, 0x4d, 0x4d, 0x41, 0x6c, 0x6c, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x57, 0x69, 0x64, 0x74, 0x68, 0x00, 0x00, 0x00, 0x02, 0x20, 0x80, 0x00, 0x00, 0x01, 0x01, 0x87, 0x00, 0x03, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x07, 0x02, 0xb5, 0xf8, 0x88, 0x0e, 0xf8, 0x88, 0x0e, 0xf7, 0x9d, 0xf8, 0xe7, 0x8b, 0xf8, 0xe7, 0x8b, 0xf8, 0xe7, 0x8c, 0x10, 0x7f, 0x9f, 0xf7, 0x9b, 0x9f, 0xe7, 0x9f, 0xf7, 0x99, 0x8b, 0xe2, 0xe3, 0xf7, 0x2e, 0xf7, 0x34, 0x8b, 0xfb, 0x1e, 0xfb, 0x1f, 0xfb, 0x64, 0xfb, 0x6a, 0x8b, 0xd1, 0xd1, 0xc6, 0xc6, 0x8b, 0x68, 0x68, 0x5b, 0x5b, 0x8b, 0xd1, 0xd1, 0xc6, 0xc6, 0x8b, 0xfb, 0x21, 0xfb, 0x21, 0xfb, 0x3d, 0xfb, 0x44, 0x91, 0x10, 0x9f, 0x8b, 0xe2, 0xe3, 0xf7, 0x2d, 0xf7, 0x34, 0x8c, 0x10, 0x01, 0xc4, 0x9f, 0xd8, 0x86, 0xd1, 0x75, 0xc3, 0x8b, 0xed, 0xed, 0xf7, 0x84, 0xf7, 0x84, 0x8d, 0x10, 0x03, 0xf7, 0x83, 0xf9, 0x30, 0xf8, 0xc0, 0x8f, 0xf8, 0xc1, 0x8e, 0xf8, 0xa5, 0x33, 0x8e, 0x62, 0x81, 0x6f, 0x8d, 0x10, 0x15, 0x93, 0x82, 0x78, 0x93, 0x63, 0xba, 0x89, 0x9b, 0x8e, 0x96, 0x5b, 0x8e, 0x6b, 0x8c, 0x7d, 0x3d, 0x8a, 0x3b, 0x89, 0x5a, 0xb4, 0x8a, 0xa5, 0x92, 0x9c, 0x3e, 0x94, 0x3b, 0x8a, 0x43, 0x90, 0x10, 0x1b, 0x31, 0x76, 0xfb, 0x00, 0xfb, 0x41, 0x88, 0xfb, 0x29, 0xa6, 0xfb, 0x34, 0x90, 0xfb, 0x6a, 0x2a, 0x6a, 0x37, 0x74, 0x40, 0x60, 0xc0, 0x77, 0x94, 0x85, 0xb6, 0x8c, 0xd4, 0x92, 0xa1, 0x73, 0x84, 0x65, 0x86, 0x63, 0x90, 0x10, 0x1f, 0x68, 0x62, 0x91, 0x6b, 0x9c, 0x6c, 0x8c, 0x10, 0x06, 0x87, 0x77, 0x84, 0x7d, 0x60, 0x82, 0x63, 0x8b, 0x45, 0x45, 0x50, 0x50, 0x8d, 0x10, 0x05, 0xb2, 0xb7, 0x8d, 0xcb, 0x83, 0xca, 0x8c, 0x10, 0x06, 0x8b, 0x7b, 0x8b, 0x74, 0x7e, 0x8a, 0x8a, 0x8a, 0x8b, 0x8a, 0x92, 0x90, 0x97, 0x93, 0x90, 0x8a, 0x8b, 0x8a, 0x8b, 0x8b, 0x94, 0x99, 0x9a, 0x9e, 0x9c, 0x86, 0x91, 0x8a, 0x91, 0x92, 0x90, 0x10, 0x1a, 0x80, 0x8b, 0x78, 0x8b, 0x81, 0x89, 0x8c, 0x86, 0x8d, 0x90, 0x8c, 0x8b, 0x8c, 0x8b, 0x8b, 0x83, 0x92, 0x96, 0x96, 0x98, 0x8d, 0x8c, 0x8c, 0x8b, 0x8c, 0x8a, 0x8d, 0x8e, 0x8d, 0x8c, 0x90, 0x10, 0x1e, 0x68, 0x65, 0x97, 0x76, 0x9c, 0x74, 0x8c, 0x10, 0x06, 0x87, 0x77, 0x84, 0x7d, 0x60, 0x82, 0x63, 0x8b, 0x45, 0x45, 0x50, 0x50, 0x8d, 0x10, 0x05, 0xb2, 0xbc, 0x96, 0xd5, 0x83, 0xd6, 0x8c, 0x10, 0x06, 0xfb, 0x68, 0x8b, 0xb5, 0x44, 0xd0, 0xbb, 0xb7, 0xc7, 0xcd, 0xd4, 0xb4, 0x97, 0xb5, 0x8f, 0xb4, 0xe2, 0x8a, 0xf6, 0x8c, 0xc7, 0x5b, 0x92, 0x82, 0x7f, 0x78, 0xf7, 0x26, 0x8d, 0xf7, 0x1d, 0x9f, 0xf7, 0x78, 0x90, 0x10, 0x1b, 0xba, 0x9c, 0x94, 0x92, 0x92, 0xc7, 0x7c, 0xe5, 0x82, 0xca, 0xe3, 0x8b, 0xd7, 0x8c, 0xb6, 0xb4, 0x85, 0xa8, 0x8c, 0x98, 0xba, 0x8b, 0x98, 0x94, 0x94, 0xbd, 0x8c, 0xa2, 0x93, 0xa4, 0x90, 0x10, 0x1f, 0xa4, 0x8f, 0xdd, 0xf2, 0xf7, 0x1e, 0xf7, 0x30, 0x8c, 0x10, 0x07, 0x7e, 0x7f, 0x7d, 0x83, 0x5e, 0x56, 0x90, 0x73, 0x8f, 0x82, 0x4d, 0x91, 0x69, 0x9a, 0x78, 0x3e, 0x91, 0x46, 0xa2, 0x39, 0x64, 0x91, 0x6a, 0x8d, 0x82, 0x51, 0xa7, 0x3c, 0xc6, 0x74, 0x90, 0x10, 0x1b, 0x53, 0x68, 0xda, 0xf7, 0x4c, 0x8b, 0xfb, 0x27, 0xac, 0x28, 0xd0, 0x53, 0x30, 0x9f, 0x54, 0xb8, 0x81, 0xb2, 0x58, 0x77, 0x48, 0x4c, 0x64, 0x34, 0xfb, 0x0b, 0xfb, 0x21, 0xfb, 0x2b, 0x67, 0x8a, 0x6f, 0x8d, 0x77, 0x90, 0x10, 0x1f, 0xf6, 0xf8, 0x05, 0x28, 0xf7, 0x87, 0xfb, 0x53, 0xe1, 0x8c, 0x10, 0x06, 0x8f, 0x9f, 0x92, 0x99, 0xb6, 0x94, 0xb3, 0x8b, 0xd1, 0xd1, 0xc6, 0xc6, 0x8d, 0x10, 0x05, 0xfb, 0x03, 0xfc, 0x11, 0xdd, 0xfb, 0xc9, 0xf7, 0x4c, 0xfb, 0x26, 0x8c, 0x10, 0x06, 0x8b, 0x97, 0x8b, 0x9b, 0x97, 0x8a, 0x8b, 0x8a, 0x8b, 0x89, 0x8a, 0x89, 0x84, 0x87, 0x86, 0x89, 0x8b, 0x8a, 0x8b, 0x8a, 0x8b, 0x86, 0x89, 0x82, 0x85, 0x96, 0x88, 0x8c, 0x86, 0x88, 0x90, 0x10, 0x1a, 0x97, 0x8b, 0xa4, 0x8b, 0x9a, 0x8e, 0x86, 0x8d, 0x87, 0x7f, 0x8c, 0x8b, 0x8c, 0x8b, 0x8b, 0x83, 0x7c, 0x79, 0x7b, 0x7e, 0x8d, 0x8b, 0x8c, 0x8b, 0x8c, 0x86, 0x86, 0x80, 0x81, 0x82, 0x90, 0x10, 0x1e, 0xf7, 0x13, 0xf8, 0x34, 0x36, 0xf7, 0xd7, 0xfb, 0x55, 0xf7, 0x30, 0x8c, 0x10, 0x06, 0x8f, 0x9f, 0x92, 0x99, 0xb6, 0x94, 0xb3, 0x8b, 0xd1, 0xd1, 0xc6, 0xc6, 0x8d, 0x10, 0x05, 0xfb, 0x17, 0xfc, 0x37, 0xd5, 0xfb, 0xeb, 0xf7, 0x4a, 0xfb, 0x52, 0x8c, 0x10, 0x06, 0xf7, 0x2e, 0x8b, 0xa0, 0xf6, 0xd4, 0x62, 0x50, 0x2d, 0x33, 0xfb, 0x05, 0xa2, 0x8d, 0xa6, 0x8a, 0x9e, 0xeb, 0x84, 0xcc, 0x70, 0x9e, 0xb4, 0x39, 0x5c, 0x3a, 0x4c, 0xf7, 0x29, 0x59, 0xe0, 0x30, 0xc9, 0x90, 0x10, 0x1b, 0xb2, 0x9d, 0x83, 0x7e, 0x96, 0xd1, 0x76, 0xe2, 0x54, 0xcd, 0xda, 0x80, 0xd0, 0x6f, 0xb8, 0x63, 0x90, 0x69, 0x87, 0x83, 0x58, 0x91, 0x74, 0x77, 0x8a, 0xc2, 0x86, 0xaa, 0x80, 0x9a, 0x90, 0x10, 0x1f, 0x0e, 0x1f, 0x72, 0xa4, 0xf9, 0x35, 0x97, 0x8b, 0x98, 0x98, 0x98, 0x98, 0x8b, 0x7e, 0x7e, 0x7e, 0x7e, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8f, 0x10, 0x0e, 0x06, 0x1f, 0x9f, 0x8b, 0xda, 0xda, 0xc6, 0xc6, 0x8c, 0x10, 0x0e, 0x0a, 0x1f, 0x9f, 0x8b, 0xed, 0xed, 0xf7, 0x84, 0xf7, 0x84, 0x8c, 0x10, 0x0e, 0x0b, 0x1f, 0x8b, 0x8b, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x10, 0x0e, 0x0c, 0x0e, 0x1e, 0xa3, 0x95, 0x82, 0x8f, 0x0c, 0x0f,
54.527027
63
0.655019
bb11e5cd10c6247fbf2f6f842ee6454611241457
7,927
h
C
thirdparty/GeometricTools/WildMagic5/LibMathematics/Containment/Wm5ContPointInPolyhedron3.h
SoMa-Project/vision
ea8199d98edc363b2be79baa7c691da3a5a6cc86
[ "BSD-2-Clause-FreeBSD" ]
1
2020-07-24T23:40:01.000Z
2020-07-24T23:40:01.000Z
thirdparty/GeometricTools/WildMagic5/LibMathematics/Containment/Wm5ContPointInPolyhedron3.h
SoMa-Project/vision
ea8199d98edc363b2be79baa7c691da3a5a6cc86
[ "BSD-2-Clause-FreeBSD" ]
4
2020-05-19T18:14:33.000Z
2021-03-19T15:53:43.000Z
thirdparty/GeometricTools/WildMagic5/LibMathematics/Containment/Wm5ContPointInPolyhedron3.h
SoMa-Project/vision
ea8199d98edc363b2be79baa7c691da3a5a6cc86
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
// Geometric Tools, LLC // Copyright (c) 1998-2014 // 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.1 (2010/10/01) #ifndef WM5CONTPOINTINPOLYHEDRON3_H #define WM5CONTPOINTINPOLYHEDRON3_H #include "Wm5MathematicsLIB.h" #include "Wm5Plane3.h" #include "Wm5Ray3.h" #include "Wm5Vector2.h" // This class contains various implementations for point-in-polyhedron // queries. The planes stored with the faces are used in all cases to // reject ray-face intersection tests, a quick culling operation. // // The algorithm is to cast a ray from the input point P and test for // intersection against each face of the polyhedron. If the ray only // intersects faces at interior points (not vertices, not edge points), // then the point is inside when the number of intersections is odd and // the point is outside when the number of intersections is even. If the // ray intersects an edge or a vertex, then the counting must be handled // differently. The details are tedious. As an alternative, the approach // here is to allow you to specify 2*N+1 rays, where N >= 0. You should // choose these rays randomly. Each ray reports "inside" or "outside". // Whichever result occurs N+1 or more times is the "winner". The input // rayQuantity is 2*N+1. The input array Direction must have rayQuantity // elements. If you are feeling lucky, choose rayQuantity to be 1. // // TO DO. Add a Contains function that uses exact arithmetic and that // casts one ray, keeping track of the parity correctly when the ray // intersects a vertex or an edge. If the faces are always triangles, // the use of barycentric coordinates gives us a "normalized" measurement // of how close to a vertex or an edge the intersection point is. This, // in turn, might make it easy to use filtered predicates, which will be // faster than always using exact arithmetic. If the faces are not // triangles, any triangulation introduces edges that are not face // boundary edges. These should be ignored by the special-case handling // of boundary edges. In the most general case of simple polygon faces // without triangulation, it is not immediately clear how to compute a // "normalized" measurement that will allow us to use filtered predicates // in an easy manner. namespace Wm5 { template <typename Real> class WM5_MATHEMATICS_ITEM PointInPolyhedron3 { public: // For simple polyhedra with triangle faces. class WM5_MATHEMATICS_ITEM TriangleFace { public: // When you view the face from outside, the vertices are // counterclockwise ordered. The Indices array stores the indices // into the vertex array. int Indices[3]; // The normal vector is unit length and points to the outside of the // polyhedron. Plane3<Real> Plane; }; // The Contains query will use ray-triangle intersection queries. PointInPolyhedron3 (int numPoints, const Vector3<Real>* points, int numFaces, const TriangleFace* faces, int numRays, const Vector3<Real>* directions); // For simple polyhedra with convex polygon faces. class WM5_MATHEMATICS_ITEM ConvexFace { public: // When you view the face from outside, the vertices are // counterclockwise ordered. The Indices array stores the indices // into the vertex array. std::vector<int> Indices; // The normal vector is unit length and points to the outside of the // polyhedron. Plane3<Real> Plane; }; // The Contains query will use ray-convexpolygon intersection queries. A // ray-convexpolygon intersection query can be implemented in many ways. // In this context, uiMethod is one of three value: // 0 : Use a triangle fan and perform a ray-triangle intersection query // for each triangle. // 1 : Find the point of intersection of ray and plane of polygon. Test // whether that point is inside the convex polygon using an O(N) // test. // 2 : Find the point of intersection of ray and plane of polygon. Test // whether that point is inside the convex polygon using an O(log N) // test. PointInPolyhedron3 (int numPoints, const Vector3<Real>* points, int numFaces, const ConvexFace* faces, int numRays, const Vector3<Real>* directions, unsigned int method); // For simple polyhedra with simple polygon faces that are generally // not all convex. class WM5_MATHEMATICS_ITEM SimpleFace { public: // When you view the face from outside, the vertices are // counterclockwise ordered. The Indices array stores the indices // into the vertex array. std::vector<int> Indices; // The normal vector is unit length and points to the outside of the // polyhedron. Plane3<Real> Plane; // Each simple face may be triangulated. The indices are relative to // the vertex array. Each triple of indices represents a triangle in // the triangulation. std::vector<int> Triangles; }; // The Contains query will use ray-simplepolygon intersection queries. A // ray-simplepolygon intersection query can be implemented in a couple of // ways. In this context, uiMethod is one of two value: // 0 : Iterate over the triangles of each face and perform a // ray-triangle intersection query for each triangle. This requires // that the SimpleFace::Triangles array be initialized for each // face. // 1 : Find the point of intersection of ray and plane of polygon. Test // whether that point is inside the polygon using an O(N) test. The // SimpleFace::Triangles array is not used for this method, so it // does not have to be initialized for each face. PointInPolyhedron3 (int numPoints, const Vector3<Real>* points, int numFaces, const SimpleFace* faces, int numRays, const Vector3<Real>* directions, unsigned intmethod); // This function will select the actual algorithm based on which // constructor you used for this class. bool Contains (const Vector3<Real>& p) const; private: // For all types of faces. The ray origin is the test point. The ray // direction is one of those passed to the constructors. The plane origin // is a point on the plane of the face. The plane normal is a unit-length // normal to the face and that points outside the polyhedron. static bool FastNoIntersect (const Ray3<Real>& ray, const Plane3<Real>& plane); // For triangle faces. bool ContainsT0 (const Vector3<Real>& p) const; // For convex faces. bool ContainsC0 (const Vector3<Real>& p) const; bool ContainsC1C2 (const Vector3<Real>& p, unsigned int method) const; // For simple faces. bool ContainsS0 (const Vector3<Real>& p) const; bool ContainsS1 (const Vector3<Real>& p) const; int mNumPoints; const Vector3<Real>* mPoints; int mNumFaces; const TriangleFace* mTFaces; const ConvexFace* mCFaces; const SimpleFace* mSFaces; unsigned int mMethod; int mNumRays; const Vector3<Real>* mDirections; // Temporary storage for those methods that reduce the problem to 2D // point-in-polygon queries. The array stores the projections of // face vertices onto the plane of the face. It is resized as needed. mutable std::vector<Vector2<Real> > mProjVertices; }; typedef PointInPolyhedron3<float> PointInPolyhedron3f; typedef PointInPolyhedron3<double> PointInPolyhedron3d; } #endif
42.848649
79
0.685379
c61658a2556caeb926d68be86581142c554cc36d
6,733
c
C
src/common/alignment.c
C-Chads/cc65
52e43879298c2fb30c7bc6fd95fae3b3f1458793
[ "Zlib" ]
1,673
2015-01-01T23:03:31.000Z
2022-03-30T21:49:03.000Z
src/common/alignment.c
Fabrizio-Caruso/cc65
84dba7f6ae43e8e93ed1601e1d565e97503cd0b2
[ "Zlib" ]
1,307
2015-01-06T09:32:26.000Z
2022-03-31T19:57:16.000Z
src/common/alignment.c
Fabrizio-Caruso/cc65
84dba7f6ae43e8e93ed1601e1d565e97503cd0b2
[ "Zlib" ]
423
2015-01-01T19:11:31.000Z
2022-03-30T14:36:00.000Z
/*****************************************************************************/ /* */ /* alignment.c */ /* */ /* Address aligment */ /* */ /* */ /* */ /* (C) 2011, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* 70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ /* common */ #include "alignment.h" #include "check.h" /*****************************************************************************/ /* Data */ /*****************************************************************************/ /* To factorize an alignment, we will use the following prime table. It lists ** all primes up to 256, which means we're able to factorize alignments up to ** 0x10000. This is checked in the code. */ static const unsigned char Primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251 }; #define PRIME_COUNT (sizeof (Primes) / sizeof (Primes[0])) #define LAST_PRIME ((unsigned long)Primes[PRIME_COUNT-1]) /* A number together with its prime factors */ typedef struct FactorizedNumber FactorizedNumber; struct FactorizedNumber { unsigned long Value; /* The actual number */ unsigned long Remainder; /* Remaining prime */ unsigned char Powers[PRIME_COUNT]; /* Powers of the factors */ }; /*****************************************************************************/ /* Code */ /*****************************************************************************/ static void Initialize (FactorizedNumber* F, unsigned long Value) /* Initialize a FactorizedNumber structure */ { unsigned I; F->Value = Value; F->Remainder = 1; for (I = 0; I < PRIME_COUNT; ++I) { F->Powers[I] = 0; } } static void Factorize (unsigned long Value, FactorizedNumber* F) /* Factorize a value between 1 and 0x10000 that is in F */ { unsigned I; /* Initialize F */ Initialize (F, Value); /* If the value is 1 we're already done */ if (Value == 1) { return; } /* Be sure we can factorize */ CHECK (Value <= MAX_ALIGNMENT && Value != 0); /* Handle factor 2 separately for speed */ while ((Value & 0x01UL) == 0UL) { ++F->Powers[0]; Value >>= 1; } /* Factorize. */ I = 1; /* Skip 2 because it was handled above */ while (Value > 1) { unsigned long Tmp = Value / Primes[I]; if (Tmp * Primes[I] == Value) { /* This is a factor */ ++F->Powers[I]; Value = Tmp; } else { /* This is not a factor, try next one */ if (++I >= PRIME_COUNT) { break; } } } /* If something is left, it must be a remaining prime */ F->Remainder = Value; } unsigned long LeastCommonMultiple (unsigned long Left, unsigned long Right) /* Calculate the least common multiple of two numbers and return ** the result. */ { unsigned I; FactorizedNumber L, R; unsigned long Res; /* Factorize the two numbers */ Factorize (Left, &L); Factorize (Right, &R); /* Generate the result from the factors. ** Some thoughts on range problems: Since the largest numbers we can ** factorize are 2^16 (0x10000), the only numbers that could produce an ** overflow when using 32 bits are exactly these. But the LCM for 2^16 ** and 2^16 is 2^16 so this will never happen and we're safe. */ Res = L.Remainder * R.Remainder; for (I = 0; I < PRIME_COUNT; ++I) { unsigned P = (L.Powers[I] > R.Powers[I])? L.Powers[I] : R.Powers[I]; while (P--) { Res *= Primes[I]; } } /* Return the calculated lcm */ return Res; } unsigned long AlignAddr (unsigned long Addr, unsigned long Alignment) /* Align an address to the given alignment */ { return ((Addr + Alignment - 1) / Alignment) * Alignment; } unsigned long AlignCount (unsigned long Addr, unsigned long Alignment) /* Calculate how many bytes must be inserted to align Addr to Alignment */ { return AlignAddr (Addr, Alignment) - Addr; }
36.394595
79
0.434576
7646e9796ede2f36ec6ebc8eacceff50812b7004
3,563
c
C
user-contributed/weizmann/sources/controlfb.c
mikelandy/HIPS
fb5440573848cd22d55771484e3c036b6007f780
[ "MIT" ]
null
null
null
user-contributed/weizmann/sources/controlfb.c
mikelandy/HIPS
fb5440573848cd22d55771484e3c036b6007f780
[ "MIT" ]
null
null
null
user-contributed/weizmann/sources/controlfb.c
mikelandy/HIPS
fb5440573848cd22d55771484e3c036b6007f780
[ "MIT" ]
null
null
null
/* * Copyright (c) 1987 Leah Mory * * Disclaimer: No guarantees of performance accompany this software, * nor is any responsibility assumed on the part of the authors. All * the software has been tested extensively and every effort has been * made to insure its reliability. */ /* * controlfb.c - display a specific frame buffer as it is, or clear * it beforehand. * * Usage: controlfb [-g greylevel] [-p pan] [-s scroll] [-z] [-d dev] * [-b fbnum] [-h] * * Defaults: device=/dev/ipfb0a, not zoomed, pan=0,scroll=0, * fbnum=MASTER_FB (=0), low byte (no h option), no change (no g * option) * * Load: cc -O -I/horef/image/sys -o controlfb controlfb.c -lhipl * * controlfb displays on the monitor the contents of the frame buffer * fbnum. If the -g option is used, the frame buffer is cleared to * the value greylevel beforehand, and then displayed. pan and scroll * are only for the display : the contents of the frame buffer stays * intact. z sets the zoom. h is relevant only if fbnum is a 16-bits * buffer. The monitor will display the low byte, unless h is on. In * this case the high byte will be displayed. * * Leah Mory , April 1987. */ #include <stdio.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sundev/ipfbreg.h> #include <hipl_format.h> #define FBCSR IPFB_CSRLI | IPFB_CSRLSC | IPFB_CSRLHR char *device = "/dev/ipfb0a"; /* ipfb0a is an alu configuration. */ main(argc, argv) int argc; char **argv; { int error; extern errno; extern int optind; extern char *optarg; int mask = 0xff00, fbcsr, fbopt, op, ipfb; int zoom = 0; int pan = 0; int scroll = 0; int clear = 0, greylevel; int fbnum = MASTER_FB; int high = 0; Progname = strsave(*argv); while ((op = getopt(argc, argv, "g:p:s:zd:b:h")) != EOF) switch (op) { case 'g': clear = 1; greylevel = atoi(optarg); break; case 'p': pan = atoi(optarg); break; case 's': scroll = atoi(optarg); break; case 'z': zoom++; break; case 'd': device = optarg; break; case 'b': fbnum = atoi(optarg); break; case 'h': high = 1; break; default: fprintf(stderr, "Usage:\ncontrolfb [-g greylevel] [-p pan] [-s scroll] [-z]\ [-d device] [-b fbnum ] [-h]\n"); exit(2); break; } if ((ipfb = open(device, O_WRONLY)) < 0) { fprintf(stderr, "Couldn't open %s\n", device); exit(1); } if ((error = ioctl(ipfb, IPFB_SFBUNIT, &fbnum)) == -1) { perror("wrong frame buffer number"); close(ipfb); exit(1); } if (high) { ioctl(ipfb, IPFB_GETOPT, &fbopt); fbopt |= IPFB_DATAHI; if ((error = ioctl(ipfb, IPFB_SETOPT, &fbopt)) == -1) { perror("no HIGH on frame buffer"); close(ipfb); exit(1); } greylevel <<= 8; mask = 0xff; /* do not clear low */ } ioctl(ipfb, IPFB_SPAN, &pan); ioctl(ipfb, IPFB_SSCROLL, &scroll); if (zoom) { ioctl(ipfb, IPFB_GFBCSR, &fbcsr); /* get the fb csr */ fbcsr |= FBCSR; ioctl(ipfb, IPFB_SFBCSR, &fbcsr); /* set the fb csr to zoom */ } if (clear) { ioctl(ipfb, IPFB_SMASK, &mask); ioctl(ipfb, IPFB_SDATA, &greylevel); ioctl(ipfb, IPFB_GFBCSR, &fbcsr); fbcsr = (fbcsr & ~IPFB_CSRHCS) | IPFB_CSRHCCLR; /* clear */ ioctl(ipfb, IPFB_SFBCSR, &fbcsr); } close(ipfb); }
26.392593
76
0.575919
6333f823a0d57958b1c2afe70a52f58af0f610c6
153
h
C
patientv1.0/patientv1.0/classes/vender/vdfac/af/AskRequestInfo.h
coper/piqq
bc72e8d8c81cd30f4651f7e54e035de54ee84860
[ "Apache-2.0" ]
null
null
null
patientv1.0/patientv1.0/classes/vender/vdfac/af/AskRequestInfo.h
coper/piqq
bc72e8d8c81cd30f4651f7e54e035de54ee84860
[ "Apache-2.0" ]
null
null
null
patientv1.0/patientv1.0/classes/vender/vdfac/af/AskRequestInfo.h
coper/piqq
bc72e8d8c81cd30f4651f7e54e035de54ee84860
[ "Apache-2.0" ]
null
null
null
// // AskRequestInfo.h // patient // // Created by liyongli on 15/8/10. // // #import "RequestInfo.h" @interface AskRequestInfo : RequestInfo @end
10.928571
39
0.660131
0ab83eb9133c060ac613db92eb33bf3dcc946298
551
h
C
src/Cedar/SW.h
Piroro-hs/SoftEtherVPN
9997785812755b38ec7adb23be9a4fabc98a9bb8
[ "Apache-2.0" ]
2
2020-12-06T10:58:34.000Z
2021-05-12T03:41:46.000Z
src/Cedar/SW.h
Piroro-hs/SoftEtherVPN
9997785812755b38ec7adb23be9a4fabc98a9bb8
[ "Apache-2.0" ]
1
2020-12-06T11:03:57.000Z
2020-12-06T11:03:57.000Z
src/Cedar/SW.h
Piroro-hs/SoftEtherVPN
9997785812755b38ec7adb23be9a4fabc98a9bb8
[ "Apache-2.0" ]
2
2021-01-05T14:46:52.000Z
2021-05-12T03:41:50.000Z
// SoftEther VPN Source Code - Developer Edition Master Branch // Cedar Communication Module // SW.h // Header of SW.c #ifndef SW_H #define SW_H #define SW_REG_KEY "Software\\" GC_REG_COMPANY_NAME "\\Setup Wizard Settings" UINT SWExec(); UINT SWExecMain(); LIST *SwNewSfxFileList(); void SwFreeSfxFileList(LIST *o); bool SwAddBasicFilesToList(LIST *o, char *component_name); bool SwCompileSfx(LIST *o, wchar_t *dst_filename); bool SwGenSfxModeMain(char *mode, wchar_t *dst); bool SwWaitForVpnClientPortReady(UINT timeout); #endif // SW_H
21.192308
81
0.756806
e43d5554b50628b823db9f026f98e2191bc6090e
4,258
c
C
security/tomoyo/securityfs_if.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
4
2016-07-01T04:50:02.000Z
2021-11-14T21:29:42.000Z
security/tomoyo/securityfs_if.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
1
2018-08-21T03:43:09.000Z
2018-08-21T03:43:09.000Z
security/tomoyo/securityfs_if.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
5
2017-10-11T08:09:11.000Z
2020-10-14T04:10:13.000Z
/* * security/tomoyo/common.c * * Securityfs interface for TOMOYO. * * Copyright (C) 2005-2010 NTT DATA CORPORATION */ #include <linux/security.h> #include "common.h" /** * tomoyo_open - open() for /sys/kernel/security/tomoyo/ interface. * * @inode: Pointer to "struct inode". * @file: Pointer to "struct file". * * Returns 0 on success, negative value otherwise. */ static int tomoyo_open(struct inode *inode, struct file *file) { const int key = ((u8 *) file->f_path.dentry->d_inode->i_private) - ((u8 *) NULL); return tomoyo_open_control(key, file); } /** * tomoyo_release - close() for /sys/kernel/security/tomoyo/ interface. * * @inode: Pointer to "struct inode". * @file: Pointer to "struct file". * * Returns 0 on success, negative value otherwise. */ static int tomoyo_release(struct inode *inode, struct file *file) { return tomoyo_close_control(file); } /** * tomoyo_poll - poll() for /proc/ccs/ interface. * * @file: Pointer to "struct file". * @wait: Pointer to "poll_table". * * Returns 0 on success, negative value otherwise. */ static unsigned int tomoyo_poll(struct file *file, poll_table *wait) { return tomoyo_poll_control(file, wait); } /** * tomoyo_read - read() for /sys/kernel/security/tomoyo/ interface. * * @file: Pointer to "struct file". * @buf: Pointer to buffer. * @count: Size of @buf. * @ppos: Unused. * * Returns bytes read on success, negative value otherwise. */ static ssize_t tomoyo_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { return tomoyo_read_control(file, buf, count); } /** * tomoyo_write - write() for /sys/kernel/security/tomoyo/ interface. * * @file: Pointer to "struct file". * @buf: Pointer to buffer. * @count: Size of @buf. * @ppos: Unused. * * Returns @count on success, negative value otherwise. */ static ssize_t tomoyo_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { return tomoyo_write_control(file, buf, count); } /* * tomoyo_operations is a "struct file_operations" which is used for handling * /sys/kernel/security/tomoyo/ interface. * * Some files under /sys/kernel/security/tomoyo/ directory accept open(O_RDWR). * See tomoyo_io_buffer for internals. */ static const struct file_operations tomoyo_operations = { .open = tomoyo_open, .release = tomoyo_release, .poll = tomoyo_poll, .read = tomoyo_read, .write = tomoyo_write, .llseek = noop_llseek, }; /** * tomoyo_create_entry - Create interface files under /sys/kernel/security/tomoyo/ directory. * * @name: The name of the interface file. * @mode: The permission of the interface file. * @parent: The parent directory. * @key: Type of interface. * * Returns nothing. */ static void __init tomoyo_create_entry(const char *name, const mode_t mode, struct dentry *parent, const u8 key) { securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key, &tomoyo_operations); } /** * tomoyo_initerface_init - Initialize /sys/kernel/security/tomoyo/ interface. * * Returns 0. */ static int __init tomoyo_initerface_init(void) { struct dentry *tomoyo_dir; /* Don't create securityfs entries unless registered. */ if (current_cred()->security != &tomoyo_kernel_domain) return 0; tomoyo_dir = securityfs_create_dir("tomoyo", NULL); tomoyo_create_entry("query", 0600, tomoyo_dir, TOMOYO_QUERY); tomoyo_create_entry("domain_policy", 0600, tomoyo_dir, TOMOYO_DOMAINPOLICY); tomoyo_create_entry("exception_policy", 0600, tomoyo_dir, TOMOYO_EXCEPTIONPOLICY); tomoyo_create_entry("self_domain", 0400, tomoyo_dir, TOMOYO_SELFDOMAIN); tomoyo_create_entry(".domain_status", 0600, tomoyo_dir, TOMOYO_DOMAIN_STATUS); tomoyo_create_entry(".process_status", 0600, tomoyo_dir, TOMOYO_PROCESS_STATUS); tomoyo_create_entry("meminfo", 0600, tomoyo_dir, TOMOYO_MEMINFO); tomoyo_create_entry("profile", 0600, tomoyo_dir, TOMOYO_PROFILE); tomoyo_create_entry("manager", 0600, tomoyo_dir, TOMOYO_MANAGER); tomoyo_create_entry("version", 0400, tomoyo_dir, TOMOYO_VERSION); return 0; } fs_initcall(tomoyo_initerface_init);
27.294872
93
0.695162
1722aa55c246385cb8632a20d2ff8b651ed4f5c9
511
h
C
EPPromiseM/MultiPromise/MultiPromise.h
own2pwn/EPPromise
8f360f9d78498fcfcbd472a76da7d63c9567be5a
[ "MIT" ]
null
null
null
EPPromiseM/MultiPromise/MultiPromise.h
own2pwn/EPPromise
8f360f9d78498fcfcbd472a76da7d63c9567be5a
[ "MIT" ]
null
null
null
EPPromiseM/MultiPromise/MultiPromise.h
own2pwn/EPPromise
8f360f9d78498fcfcbd472a76da7d63c9567be5a
[ "MIT" ]
null
null
null
// // MultiPromise.h // MultiPromise // // Created by Evgeniy on 24/11/2018. // Copyright © 2018 Evgeniy. All rights reserved. // #import <Cocoa/Cocoa.h> //! Project version number for MultiPromise. FOUNDATION_EXPORT double MultiPromiseVersionNumber; //! Project version string for MultiPromise. FOUNDATION_EXPORT const unsigned char MultiPromiseVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <MultiPromise/PublicHeader.h>
25.55
137
0.76908
77fbc4137c3d3a17cf93a79ee7d5818d861a0675
129
h
C
AADC/src/aadcDemo/jury/JuryCommunication/TcpSink.h
AlexanderVenetidis/aadc2018
53227597d47254e191ac836298c00f3226477f3d
[ "MIT" ]
null
null
null
AADC/src/aadcDemo/jury/JuryCommunication/TcpSink.h
AlexanderVenetidis/aadc2018
53227597d47254e191ac836298c00f3226477f3d
[ "MIT" ]
null
null
null
AADC/src/aadcDemo/jury/JuryCommunication/TcpSink.h
AlexanderVenetidis/aadc2018
53227597d47254e191ac836298c00f3226477f3d
[ "MIT" ]
null
null
null
version https://git-lfs.github.com/spec/v1 oid sha256:ec879cb1e2b4c90234b67742f356d7c2c0864e68363ff5bf9adfbab56fb58961 size 3188
32.25
75
0.883721
48e9038a96822585773e26a1a543f0ff421a5eb5
437
h
C
dependencies/MyGui/Tools/SkinEditor/VerticalSelectorControl.h
amvb/GUCEF
08fd423bbb5cdebbe4b70df24c0ae51716b65825
[ "Apache-2.0" ]
5
2016-04-18T23:12:51.000Z
2022-03-06T05:12:07.000Z
dependencies/MyGui/Tools/SkinEditor/VerticalSelectorControl.h
amvb/GUCEF
08fd423bbb5cdebbe4b70df24c0ae51716b65825
[ "Apache-2.0" ]
2
2015-10-09T19:13:25.000Z
2018-12-25T17:16:54.000Z
dependencies/MyGui/Tools/SkinEditor/VerticalSelectorControl.h
amvb/GUCEF
08fd423bbb5cdebbe4b70df24c0ae51716b65825
[ "Apache-2.0" ]
15
2015-02-23T16:35:28.000Z
2022-03-25T13:40:33.000Z
/*! @file @author Albert Semenov @date 08/2010 */ #ifndef __VERTICAL_SELECTOR_CONTROL_H__ #define __VERTICAL_SELECTOR_CONTROL_H__ #include "SelectorControl.h" namespace tools { class VerticalSelectorControl : public SelectorControl { public: VerticalSelectorControl(MyGUI::Widget* _parent); virtual ~VerticalSelectorControl(); }; } // namespace tools #endif // __VERTICAL_SELECTOR_CONTROL_H__
17.48
51
0.732265
e271442654dd9767141c213b21ea7c2ee58b188d
1,385
c
C
tests/test.c
fiatlux23/motmot-lang
6f0fba2df5a811092fcc4968ac30233dd1927502
[ "MIT" ]
null
null
null
tests/test.c
fiatlux23/motmot-lang
6f0fba2df5a811092fcc4968ac30233dd1927502
[ "MIT" ]
null
null
null
tests/test.c
fiatlux23/motmot-lang
6f0fba2df5a811092fcc4968ac30233dd1927502
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "test.h" #include "test_table.h" #include "test_component.h" /* writing tests: * * tests should be defined in headers and included in test.c * * test functions should take no arguments and return an int, e.g. * int test_hash_table() * * a test function should begin with INIT_TEST() and end with END_TEST() * * within a test function, test cases can be created by enclosing them * within BEGIN_TEST_CASE(description) and END_TEST_CASE(). a test case * can be signaled to fail with the TEST_FAIL() macro, otherwise when * it reaches END_TEST_CASE() the test will be reported as successful * e.g. * BEGIN_TEST_CASE("x is 1") * if (x != 1) TEST_FAIL(); * END_TEST_CASE(); * * when calling a test function from main, use TEST(testfn, description) * to call the test and supply a description of what the test does overall */ int main() { #line 1 /* set line number to 1 to report tests in order */ TEST(test_ht_add_entry, "Adding 3 entries to a hash table and then retrieving them"); TEST(test_ht_resize, "Adding 8 entries to a hash table to force a resize and then retrieving them"); TEST(test_ht_stress, "Add 2000 entries, delete 2000 entries, add 2000 new entries"); TEST(test_motmot_arithmetic, "Source strings compile to expected bytecode and evaluate to expected result"); }
34.625
112
0.727798
28f27b34e4f8bd12799566c2f23ddf79385f52cf
2,166
h
C
interfaces/native_cpp/osal/include/bundle_manager.h
dawmlight/communication_nfc
84a10d69eb9cb3128e864230c53d5a5e6660dfb9
[ "Apache-2.0" ]
null
null
null
interfaces/native_cpp/osal/include/bundle_manager.h
dawmlight/communication_nfc
84a10d69eb9cb3128e864230c53d5a5e6660dfb9
[ "Apache-2.0" ]
null
null
null
interfaces/native_cpp/osal/include/bundle_manager.h
dawmlight/communication_nfc
84a10d69eb9cb3128e864230c53d5a5e6660dfb9
[ "Apache-2.0" ]
null
null
null
#ifndef OSAL_BUNDLE_MANAGER_H #define OSAL_BUNDLE_MANAGER_H #include <map> #include <memory> #include <mutex> #include <string> #include <vector> namespace OHOS::NativePreferences { class Element; } namespace osal { class BundleInfo; class BundleManager { public: BundleManager(/* args */); ~BundleManager(); // For SE std::string GetCallingBundleName(int64_t uid); int CheckPermission(const std::string& permission, const std::string& bundleName); void AddPermission(const std::string& permission, const std::string& bundleName); std::vector<std::string> GetBundlesForUid(int64_t uid); void SetBundlesForUid(int64_t uid, const std::vector<std::string>& bundleNames); void RemoveBundlesForUid(int64_t uid); std::shared_ptr<BundleInfo> GetBundleInfo(std::string bundleName, int flags); void SetBundleInfo(const std::string& bundleName, std::shared_ptr<BundleInfo> bundleInfo); bool Marshalling(const std::string& configFile); bool Unmarshalling(const std::string& configFile); public: static const int PERMISSION_GRANTED{0}; static const int PERMISSION_DENIED{-1}; static const int GET_SIGNATURES{64}; static constexpr const auto SE_TEST_CONFIG{"/data/nfc/param/se_test_config.cfg"}; private: // set up bool SetUpBundleNames(OHOS::NativePreferences::Element& bundleNames); bool SetUpBundleInfos(OHOS::NativePreferences::Element& bundleInfos); // read bool ParseBundleNames(const std::vector<OHOS::NativePreferences::Element>& elements); bool ParseBundleInfos(const std::vector<OHOS::NativePreferences::Element>& element); std::shared_ptr<BundleInfo> LoadBundleInfo(const std::vector<OHOS::NativePreferences::Element>& elements); std::vector<std::string> LoadStringVector(const std::vector<OHOS::NativePreferences::Element>& elements); private: std::mutex mtx_; // uid(high 32bit)+pid(low 32bit, default 0x0000) --- bundle name std::map<int64_t, std::vector<std::string>> bundleNames_{}; // Bundle name - BundleInfo std::map<std::string, std::shared_ptr<BundleInfo>> bundleInfos_; }; } // namespace osal #endif // OSAL_BUNDLE_MANAGER_H
35.508197
110
0.739151
acc29dab898fd1fdb7d70ed22e3392bd61ffe4cb
20,570
h
C
src/components/store/nvmestore/src/persist_session_pmem.h
ghsecuritylab/comanche
a8862eaed59045377874b95b120832a0cba42193
[ "Apache-2.0" ]
19
2017-10-03T16:01:49.000Z
2021-06-07T10:21:46.000Z
src/components/store/nvmestore/src/persist_session_pmem.h
dnbaker/comanche
121cd0fa16e55d461b366e83511d3810ea2b11c9
[ "Apache-2.0" ]
25
2018-02-21T23:43:03.000Z
2020-09-02T08:47:32.000Z
src/components/store/nvmestore/src/persist_session_pmem.h
dnbaker/comanche
121cd0fa16e55d461b366e83511d3810ea2b11c9
[ "Apache-2.0" ]
19
2017-10-24T17:41:40.000Z
2022-02-22T02:17:18.000Z
/* * Description: * * Author: Feng Li * e-mail: fengggli@yahoo.com */ #ifndef PERSIST_SESSION_PMEM_H_ #define PERSIST_SESSION_PMEM_H_ /* * This is deprecated, now nvmestore use ikvstore as backend. */ #ifdef USE_PMEM struct store_root_t { TOID(struct hashmap_tx) map; /** hashkey-> obj_info*/ size_t pool_size; }; // TOID_DECLARE_ROOT(struct store_root_t); class Nvmestore_session { public: static constexpr bool option_DEBUG = false; using lock_type_t = IKVStore::lock_type_t; using key_t = uint64_t; // virt_addr is used to identify each obj Nvmestore_session(TOID(struct store_root_t) root, PMEMobjpool* pop, size_t pool_size, std::string path, size_t io_mem_size, nvmestore::Block_manager* blk_manager, State_map* ptr_state_map) : _root(root), _pop(pop), _path(path), _io_mem_size(io_mem_size), _blk_manager(blk_manager), p_state_map(ptr_state_map), _num_objs(0) { _io_mem = _blk_manager->allocate_io_buffer(_io_mem_size, 4096, Component::NUMA_NODE_ANY); } ~Nvmestore_session() { if (option_DEBUG) PLOG("CLOSING session"); if (_io_mem) _blk_manager->free_io_buffer(_io_mem); pmemobj_close(_pop); } std::unordered_map<uint64_t, io_buffer_t>& get_locked_regions() { return _locked_regions; } std::string get_path() & { return _path; } /** Get persist pointer of this pool*/ PMEMobjpool* get_pop() { return _pop; } /* [>* Get <]*/ /*TOID(struct store_root_t) get_root() { return _root; }*/ size_t get_count() { return _num_objs; } void alloc_new_object(const std::string& key, size_t value_len, TOID(struct obj_info) & out_blkmeta); /** Erase Objects*/ status_t erase(const std::string& key); /** Put and object*/ status_t put(const std::string& key, const void* valude, size_t value_len, unsigned int flags); /** Get an object*/ status_t get(const std::string& key, void*& out_value, size_t& out_value_len); status_t get_direct(const std ::string& key, void* out_value, size_t& out_value_len, buffer_t* memory_handle); key_t lock(const std::string& key, lock_type_t type, void*& out_value, size_t& out_value_len); status_t unlock(key_t obj_key); status_t map(std::function<int(const std::string& key, const void* value, const size_t value_len)> f); status_t map_keys(std::function<int(const std::string& key)> f); private: // for meta_pmem only TOID(struct store_root_t) _root; PMEMobjpool* _pop; // the pool for mapping size_t _pool_size; std::string _path; uint64_t _io_mem; /** dynamic iomem for put/get */ size_t _io_mem_size; /** io memory size */ nvmestore::Block_manager* _blk_manager; State_map* p_state_map; /** Session locked, io_buffer_t(virt_addr) -> pool hashkey of obj*/ std::unordered_map<io_buffer_t, uint64_t> _locked_regions; size_t _num_objs; status_t may_ajust_io_mem(size_t value_len); }; /** * Create a entry in the pool and allocate space * * @param session * @param value_len * @param out_blkmeta [out] block mapping info of this obj * * TODO This allocate memory using regions */ void Nvmestore_session::alloc_new_object(const std::string& key, size_t value_len, TOID(struct obj_info) & out_blkmeta) { auto& root = this->_root; auto& pop = this->_pop; auto& blk_manager = this->_blk_manager; uint64_t hashkey = CityHash64(key.c_str(), key.length()); size_t blk_size = blk_manager->blk_sz(); size_t nr_io_blocks = (value_len + blk_size - 1) / blk_size; void* handle; // transaction also happens in here uint64_t lba = _blk_manager->alloc_blk_region(nr_io_blocks, &handle); PDBG("write to lba %lu with length %lu, key %lx", lba, value_len, hashkey); auto& objinfo = out_blkmeta; TX_BEGIN(pop) { /* allocate memory for entry - range added to tx implicitly? */ // get the available range from allocator objinfo = TX_ALLOC(struct obj_info, sizeof(struct obj_info)); D_RW(objinfo)->lba_start = lba; D_RW(objinfo)->size = value_len; D_RW(objinfo)->handle = handle; D_RW(objinfo)->key_len = key.length(); TOID(char) key_data = TX_ALLOC(char, key.length() + 1); // \0 included if (D_RO(key_data) == nullptr) throw General_exception("Failed to allocate space for key"); std::copy(key.c_str(), key.c_str() + key.length() + 1, D_RW(key_data)); D_RW(objinfo)->key_data = key_data; /* insert into HT */ int rc; if ((rc = hm_tx_insert(pop, D_RW(root)->map, hashkey, objinfo.oid))) { if (rc == 1) throw General_exception("inserting same key"); else throw General_exception("hm_tx_insert failed unexpectedly (rc=%d)", rc); } _num_objs += 1; } TX_ONABORT { // TODO: free objinfo throw General_exception("TX abort (%s) during nvmeput", pmemobj_errormsg()); } TX_END PDBG("Allocated obj with obj %p, ,handle %p", D_RO(objinfo), D_RO(objinfo)->handle); } status_t Nvmestore_session::erase(const std::string& key) { uint64_t hashkey = CityHash64(key.c_str(), key.length()); auto& root = this->_root; auto& pop = this->_pop; uint64_t pool = reinterpret_cast<uint64_t>(this); TOID(struct obj_info) objinfo; try { objinfo = hm_tx_get(pop, D_RW(root)->map, hashkey); if (OID_IS_NULL(objinfo.oid)) return NVME_store::E_KEY_NOT_FOUND; /* get hold of write lock to remove */ if (!p_state_map->state_get_write_lock(pool, D_RO(objinfo)->handle)) throw API_exception("unable to remove, value locked"); PDBG("Tring to Remove obj with obj %p,handle %p", D_RO(objinfo), D_RO(objinfo)->handle); // Free objinfo objinfo = hm_tx_remove(pop, D_RW(root)->map, hashkey); /* could be optimized to not re-lookup */ TX_BEGIN(_pop) { TX_FREE(objinfo); } TX_ONABORT { throw General_exception("TX abort (%s) when free objinfo record", pmemobj_errormsg()); } TX_END if (OID_IS_NULL(objinfo.oid)) throw API_exception("hm_tx_remove with key(%lu) failed unexpectedly %s", hashkey, pmemobj_errormsg()); // Free block range in the blk_alloc _blk_manager->free_blk_region(D_RO(objinfo)->lba_start, D_RO(objinfo)->handle); p_state_map->state_remove(pool, D_RO(objinfo)->handle); _num_objs -= 1; } catch (...) { throw General_exception("hm_tx_remove failed unexpectedly"); } return S_OK; } status_t Nvmestore_session::may_ajust_io_mem(size_t value_len) { /* increase IO buffer sizes when value size is large*/ // TODO: need lock if (value_len > _io_mem_size) { size_t new_io_mem_size = _io_mem_size; while (new_io_mem_size < value_len) { new_io_mem_size *= 2; } _io_mem_size = new_io_mem_size; _blk_manager->free_io_buffer(_io_mem); _io_mem = _blk_manager->allocate_io_buffer(_io_mem_size, 4096, Component::NUMA_NODE_ANY); if (option_DEBUG) PINF("[Nvmestore_session]: incresing IO mem size %lu at %lx", new_io_mem_size, _io_mem); } return S_OK; } status_t Nvmestore_session::put(const std::string& key, const void* value, size_t value_len, unsigned int flags) { uint64_t hashkey = CityHash64(key.c_str(), key.length()); size_t blk_sz = _blk_manager->blk_sz(); auto root = _root; auto pop = _pop; TOID(struct obj_info) blkmeta; // block mapping of this obj if (hm_tx_lookup(pop, D_RO(root)->map, hashkey)) { PLOG("overriting exsiting obj"); erase(key); return put(key, value, value_len, flags); } may_ajust_io_mem(value_len); alloc_new_object(key, value_len, blkmeta); memcpy(_blk_manager->virt_addr(_io_mem), value, value_len); /* for the moment we have to memcpy */ #ifdef USE_ASYNC #error("use_sync is deprecated") // TODO: can the free be triggered by callback? uint64_t tag = blk_dev->async_write(session->io_mem, 0, lba, nr_io_blocks); D_RW(objinfo)->last_tag = tag; #else auto nr_io_blocks = (value_len + blk_sz - 1) / blk_sz; _blk_manager->do_block_io(nvmestore::BLOCK_IO_WRITE, _io_mem, D_RO(blkmeta)->lba_start, nr_io_blocks); #endif return S_OK; } status_t Nvmestore_session::get(const std::string& key, void*& out_value, size_t& out_value_len) { uint64_t hashkey = CityHash64(key.c_str(), key.length()); size_t blk_sz = _blk_manager->blk_sz(); auto root = _root; auto& pop = _pop; TOID(struct obj_info) objinfo; // TODO: can write to a shadowed copy try { objinfo = hm_tx_get(pop, D_RW(root)->map, hashkey); if (OID_IS_NULL(objinfo.oid)) return IKVStore::E_KEY_NOT_FOUND; auto val_len = D_RO(objinfo)->size; auto lba = D_RO(objinfo)->lba_start; #ifdef USE_ASYNC uint64_t tag = D_RO(objinfo)->last_tag; while (!blk_dev->check_completion(tag)) cpu_relax(); /* check the last completion, TODO: check each time makes the get slightly slow () */ #endif PDBG("prepare to read lba %d with length %d, key %lx", lba, val_len, hashkey); may_ajust_io_mem(val_len); size_t nr_io_blocks = (val_len + blk_sz - 1) / blk_sz; _blk_manager->do_block_io(nvmestore::BLOCK_IO_READ, _io_mem, lba, nr_io_blocks); out_value = malloc(val_len); assert(out_value); memcpy(out_value, _blk_manager->virt_addr(_io_mem), val_len); out_value_len = val_len; } catch (...) { throw General_exception("hm_tx_get failed unexpectedly"); } return S_OK; } status_t Nvmestore_session::get_direct(const std::string& key, void* out_value, size_t& out_value_len, buffer_t* memory_handle) { uint64_t hashkey = CityHash64(key.c_str(), key.length()); size_t blk_sz = _blk_manager->blk_sz(); auto root = _root; auto pop = _pop; TOID(struct obj_info) objinfo; try { cpu_time_t start = rdtsc(); objinfo = hm_tx_get(pop, D_RW(root)->map, hashkey); if (OID_IS_NULL(objinfo.oid)) return IKVStore::E_KEY_NOT_FOUND; auto val_len = static_cast<size_t>(D_RO(objinfo)->size); auto lba = static_cast<lba_t>(D_RO(objinfo)->lba_start); cpu_time_t cycles_for_hm = rdtsc() - start; PLOG("checked hxmap read latency took %ld cycles (%f usec) per hm access", cycles_for_hm, cycles_for_hm / 2400.0f); #ifdef USE_ASYNC uint64_t tag = D_RO(objinfo)->last_tag; while (!blk_dev->check_completion(tag)) cpu_relax(); /* check the last completion, TODO: check each time makes the get slightly slow () */ #endif PDBG("prepare to read lba %lu with length %lu", lba, val_len); assert(out_value); io_buffer_t mem; if (memory_handle) { // external memory /* TODO: they are not nessarily equal, it memory is registered from * outside */ if (out_value < memory_handle->start_vaddr()) { throw General_exception("out_value is not registered"); } size_t offset = (size_t) out_value - (size_t)(memory_handle->start_vaddr()); if ((val_len + offset) > memory_handle->length()) { throw General_exception("registered memory is not big enough"); } mem = memory_handle->io_mem() + offset; } else { mem = reinterpret_cast<io_buffer_t>(out_value); } assert(mem); size_t nr_io_blocks = (val_len + blk_sz - 1) / blk_sz; start = rdtsc(); _blk_manager->do_block_io(nvmestore::BLOCK_IO_READ, mem, lba, nr_io_blocks); cpu_time_t cycles_for_iop = rdtsc() - start; PDBG("prepare to read lba %lu with nr_blocks %lu", lba, nr_io_blocks); PDBG("checked read latency took %ld cycles (%f usec) per IOP", cycles_for_iop, cycles_for_iop / 2400.0f); out_value_len = val_len; } catch (...) { throw General_exception("hm_tx_get failed unexpectedly"); } return S_OK; } Nvmestore_session::key_t Nvmestore_session::lock(const std::string& key, lock_type_t type, void*& out_value, size_t& out_value_len) { uint64_t hashkey = CityHash64(key.c_str(), key.length()); auto& root = _root; auto& pop = _pop; int operation_type = nvmestore::BLOCK_IO_NOP; size_t blk_sz = _blk_manager->blk_sz(); auto pool = reinterpret_cast<uint64_t>(this); TOID(struct obj_info) objinfo; try { objinfo = hm_tx_get(pop, D_RW(root)->map, hashkey); if (!OID_IS_NULL(objinfo.oid)) { #ifdef USE_ASYNC /* there might be pending async write for this object */ uint64_t tag = D_RO(objinfo)->last_tag; while (!blk_dev->check_completion(tag)) cpu_relax(); /* check the last completion */ #endif operation_type = nvmestore::BLOCK_IO_READ; } else { if (!out_value_len) { throw General_exception( "%s: Need value length to lock a unexsiting object", __func__); } alloc_new_object(key, out_value_len, objinfo); } if (type == IKVStore::STORE_LOCK_READ) { if (!p_state_map->state_get_read_lock(pool, D_RO(objinfo)->handle)) throw General_exception("%s: unable to get read lock", __func__); } else { if (!p_state_map->state_get_write_lock(pool, D_RO(objinfo)->handle)) throw General_exception("%s: unable to get write lock", __func__); } auto handle = D_RO(objinfo)->handle; auto value_len = D_RO(objinfo)->size; // the length allocated before auto lba = D_RO(objinfo)->lba_start; /* fetch the data to block io mem */ size_t nr_io_blocks = (value_len + blk_sz - 1) / blk_sz; io_buffer_t mem = _blk_manager->allocate_io_buffer( nr_io_blocks * blk_sz, 4096, Component::NUMA_NODE_ANY); _blk_manager->do_block_io(operation_type, mem, lba, nr_io_blocks); get_locked_regions().emplace(mem, hashkey); PDBG("[nvmestore_session]: allocating io mem at %p, virt addr %p", (void*) mem, _blk_manager->virt_addr(mem)); /* set output values */ out_value = _blk_manager->virt_addr(mem); out_value_len = value_len; } catch (...) { PERR("NVME_store: lock failed"); } PDBG("NVME_store: obtained the lock"); return reinterpret_cast<Nvmestore_session::key_t>(out_value); } status_t Nvmestore_session::unlock(Nvmestore_session::key_t key_handle) { auto root = _root; auto pop = _pop; auto pool = reinterpret_cast<uint64_t>(this); io_buffer_t mem = reinterpret_cast<io_buffer_t>(key_handle); uint64_t hashkey = get_locked_regions().at(mem); size_t blk_sz = _blk_manager->blk_sz(); TOID(struct obj_info) objinfo; try { objinfo = hm_tx_get(pop, D_RW(root)->map, (uint64_t) hashkey); if (OID_IS_NULL(objinfo.oid)) return IKVStore::E_KEY_NOT_FOUND; auto val_len = D_RO(objinfo)->size; auto lba = D_RO(objinfo)->lba_start; size_t nr_io_blocks = (val_len + blk_sz - 1) / blk_sz; /*flush and release iomem*/ #ifdef USE_ASYNC uint64_t tag = blk_dev->async_write(mem, 0, lba, nr_io_blocks); D_RW(objinfo)->last_tag = tag; #else _blk_manager->do_block_io(nvmestore::BLOCK_IO_WRITE, mem, lba, nr_io_blocks); #endif PDBG("[nvmestore_session]: freeing io mem at %p", (void*) mem); _blk_manager->free_io_buffer(mem); /*release the lock*/ p_state_map->state_unlock(pool, D_RO(objinfo)->handle); PDBG("NVME_store: released the lock"); } catch (...) { throw General_exception("hm_tx_get failed unexpectedly or iomem not found"); } return S_OK; } status_t Nvmestore_session::map(std::function<int(const std::string& key, const void* value, const size_t value_len)> f) { size_t blk_sz = _blk_manager->blk_sz(); auto& root = _root; auto& pop = _pop; TOID(struct obj_info) objinfo; // functor auto f_map = [f, pop, root](uint64_t hashkey, void* arg) -> int { Nvmestore_session* session = reinterpret_cast<Nvmestore_session*>(arg); void* value = nullptr; size_t value_len = 0; TOID(struct obj_info) objinfo; objinfo = hm_tx_get(pop, D_RW(root)->map, (uint64_t) hashkey); const char* key_str = D_RO(D_RO(objinfo)->key_data); std::string key(key_str); IKVStore::lock_type_t wlock = IKVStore::STORE_LOCK_WRITE; // lock try { session->lock(key, wlock, value, value_len); } catch (...) { throw General_exception("lock failed"); } if (S_OK != f(key, value, value_len)) { throw General_exception("apply functor failed"); } // unlock if (S_OK != session->unlock((key_t) value)) { throw General_exception("unlock failed"); } return 0; }; TX_BEGIN(pop) { // lock/apply/ and unlock hm_tx_foreachkey(pop, D_RW(root)->map, f_map, this); } TX_ONABORT { throw General_exception("Map for each failed"); } TX_END return S_OK; } status_t Nvmestore_session::map_keys( std::function<int(const std::string& key)> f) { auto& root = _root; auto& pop = _pop; TOID(struct obj_info) objinfo; // functor auto f_map = [f, pop, root](uint64_t hashkey, void* arg) -> int { TOID(struct obj_info) objinfo; objinfo = hm_tx_get(pop, D_RW(root)->map, (uint64_t) hashkey); const char* key_str = D_RO(D_RO(objinfo)->key_data); std::string key(key_str); if (S_OK != f(key)) { throw General_exception("apply functor failed"); } return 0; }; TX_BEGIN(pop) { hm_tx_foreachkey(pop, D_RW(root)->map, f_map, this); } TX_ONABORT { throw General_exception("MapKeys for each failed"); } TX_END return S_OK; } static int check_pool(const char* path) { PLOG("check_pool: %s", path); PMEMpoolcheck* ppc; struct pmempool_check_status* status; struct pmempool_check_args args; args.path = path; args.backup_path = NULL; args.pool_type = PMEMPOOL_POOL_TYPE_DETECT; args.flags = PMEMPOOL_CHECK_FORMAT_STR | PMEMPOOL_CHECK_REPAIR | PMEMPOOL_CHECK_VERBOSE; if ((ppc = pmempool_check_init(&args, sizeof(args))) == NULL) { perror("pmempool_check_init"); return -1; } /* perform check and repair, answer 'yes' for each question */ while ((status = pmempool_check(ppc)) != NULL) { switch (status->type) { case PMEMPOOL_CHECK_MSG_TYPE_ERROR: printf("%s\n", status->str.msg); break; case PMEMPOOL_CHECK_MSG_TYPE_INFO: printf("%s\n", status->str.msg); break; case PMEMPOOL_CHECK_MSG_TYPE_QUESTION: printf("%s\n", status->str.msg); status->str.answer = "yes"; break; default: pmempool_check_end(ppc); throw General_exception("pmempool_check failed"); } } /* finalize the check and get the result */ int ret = pmempool_check_end(ppc); switch (ret) { case PMEMPOOL_CHECK_RESULT_CONSISTENT: case PMEMPOOL_CHECK_RESULT_REPAIRED: PLOG("pool (%s) checked OK!", path); return 0; } return 1; } #endif #endif
31.261398
80
0.611133
6b29f25d16f48b3c12012fd11ff4c7334a9edf13
278
h
C
CJUIKitDemo/CJUIKitDemo/Modules/DemosView/TextFieldDemo/TSTextFieldAccessoryViewController.h
dvlproad/CJUIK
3dc93619ad545f613e9a7f7e1a4b0a93c4cb47ba
[ "MIT" ]
59
2018-08-16T10:09:52.000Z
2022-02-16T05:43:45.000Z
CJUIKitDemo/CJUIKitDemo/Modules/DemosView/TextFieldDemo/TSTextFieldAccessoryViewController.h
dvlproad/CJUIK
3dc93619ad545f613e9a7f7e1a4b0a93c4cb47ba
[ "MIT" ]
null
null
null
CJUIKitDemo/CJUIKitDemo/Modules/DemosView/TextFieldDemo/TSTextFieldAccessoryViewController.h
dvlproad/CJUIK
3dc93619ad545f613e9a7f7e1a4b0a93c4cb47ba
[ "MIT" ]
15
2018-11-09T01:49:32.000Z
2022-02-14T14:56:12.000Z
// // TSTextFieldAccessoryViewController.h // CJUIKitDemo // // Created by ciyouzen on 2015/12/23. // Copyright © 2015年 dvlproad. All rights reserved. // #import "CJUIKitBaseViewController.h" @interface TSTextFieldAccessoryViewController : CJUIKitBaseViewController @end
19.857143
73
0.773381
6b36813c50b0f3578c450d8d96bef56ed0fe3dac
3,153
h
C
include/o3d/core/processor.h
dream-overflow/o3d
087ab870cc0fd9091974bb826e25c23903a1dde0
[ "FSFAP" ]
2
2019-06-22T23:29:44.000Z
2019-07-07T18:34:04.000Z
include/o3d/core/processor.h
dream-overflow/o3d
087ab870cc0fd9091974bb826e25c23903a1dde0
[ "FSFAP" ]
null
null
null
include/o3d/core/processor.h
dream-overflow/o3d
087ab870cc0fd9091974bb826e25c23903a1dde0
[ "FSFAP" ]
null
null
null
/** * @file processor.h * @brief Processor informations. * @author Frederic SCHERMA (frederic.scherma@dreamoverflow.org) * @date 2007-12-01 * @copyright Copyright (c) 2001-2017 Dream Overflow. All rights reserved. * @details */ #ifndef _O3D_PROCESSOR_H #define _O3D_PROCESSOR_H #include "string.h" namespace o3d { /** * @brief Give informations about processor type and its available features * like MMX, SSE... * @todo Get count of CPUs * @todo Support for ARM */ class O3D_API Processor { public: //! Default constructor Processor(); //! Report informations on log file void reportLog(); //! Has SSE1 support Bool hasSSE() const { return m_has_sse; } //! Has SSE2 support Bool hasSSE2() const { return m_has_sse2; } //! Has SSE3 support Bool hasSSE3() const { return m_has_sse3; } //! Has SSSE3 support Bool hasSSSE3() const { return m_has_ssse3; } //! Has SSE4_1 support Bool hasSSE4_1() const { return m_has_sse4_1; } //! Has SSE4_2 support Bool hasSSE4_2() const { return m_has_sse4_2; } //! Has MMX support Bool hasMMX() const { return m_has_mmx; } //! Has MMX ext support Bool hasMMXExt() const { return m_has_mmx_ext; } //! Has 3DNOW support Bool has3DNow() const { return m_has_3dnow; } //! Has 3DNOW ext support Bool has3DNowExt() const { return m_has_3dnow_ext; } //! Has Hyper HyperTransport Technology Bool isHTT() const { return m_is_htt; } //! Get the CPU name const String& getName() const { return m_cpu_name; } //! Get the CPU Vendor ID const String& getVendorID() const { return m_cpu_vendor; } //! Get the CPU vendor name String getVendorName() const; //! Get the CPU frequency in Mhz Float getSpeed() const { return m_cpu_speed; } //! Get the CPU model stepping Int32 getStepping() const { return m_stepping; } //! Get the CPU model Int32 getModel() const { return m_model; } //! Get the CPU family Int32 getFamily() const { return m_family; } //! Get the CPU type Int32 getType() const { return m_type; } //! Get ext informations about the CPU model Int32 getExtModel() const { return m_ext_model; } //! Get ext informations about the CPU family Int32 getExtFamily() const { return m_ext_family; } //! Get number of CPUs Int32 getNumCPU() const { return m_num_cpu; } //! Get the cache line size Int32 getCacheLineSize() const { return m_cache_line_size; } //! Get the system RAM size in Mo Int32 getSystemRAMSize() const { return m_system_ram_size; } private: Bool m_has_mmx; Bool m_has_mmx_ext; Bool m_has_3dnow; Bool m_has_3dnow_ext; Bool m_has_sse; Bool m_has_sse2; Bool m_has_sse3; Bool m_has_ssse3; Bool m_has_sse4_1; Bool m_has_sse4_2; Bool m_is_htt; Int32 m_stepping; Int32 m_model; Int32 m_family; Int32 m_type; Int32 m_ext_model; Int32 m_ext_family; String m_cpu_name; String m_cpu_vendor; Float m_cpu_speed; Int32 m_num_cpu; Int32 m_cache_line_size; Int32 m_system_ram_size; void doCPUID(); }; } // namespace o3d #endif // _O3D_PROCESSOR_H
22.361702
75
0.679987
7512efcaebf5f834a836f70cf8fb0873c87582e4
2,369
c
C
src/c/samplef.c
adomasbaliuka/fast-loaded-dice-roller
19d30abe421edecf25173ca4146f02109194be5f
[ "Apache-2.0" ]
36
2020-04-02T17:03:11.000Z
2022-03-27T20:57:24.000Z
src/c/samplef.c
adomasbaliuka/fast-loaded-dice-roller
19d30abe421edecf25173ca4146f02109194be5f
[ "Apache-2.0" ]
7
2020-03-26T15:45:15.000Z
2020-09-18T00:26:34.000Z
src/c/samplef.c
adomasbaliuka/fast-loaded-dice-roller
19d30abe421edecf25173ca4146f02109194be5f
[ "Apache-2.0" ]
10
2020-06-02T12:18:43.000Z
2022-01-28T18:08:06.000Z
/* Name: sample.c Purpose: Command line interface for FLDR (floating-point weights). Author: F. A. Saad Copyright (C) 2020 Feras A. Saad, All Rights Reserved. Released under Apache 2.0; refer to LICENSE.txt */ #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "fldrf.h" #include "flip.h" double * load_array(FILE *fp, int length) { double *a = calloc(length, sizeof(*a)); for (int i = 0; i < length; i++) { assert(fscanf(fp, "%lf", &a[i]) == 1); } return a; } void * write_array(FILE *fp, int *x, int n) { for (int j = 0; j < n; j++) { if (j < n - 1) { fprintf(fp, "%d ", x[j]); } else { fprintf(fp, "%d", x[j]); } } fprintf(fp, "\n"); } void write_fldrf_s(char *fname, fldrf_preprocess_t *x) { char *fname_s = strcat(fname, ".fldrf"); FILE *fp = fopen(fname_s, "w"); fprintf(fp, "%d %d", x->n, x->k); fprintf(fp, "\n"); write_array(fp, x->m.items, x->m.length); write_array(fp, x->r.items, x->r.length); write_array(fp, x->h, x->k); for (int row = 0; row < x->n + 1; row++){ for (int col = 0; col < x->k; col++) { if (col < x->k - 1) { fprintf(fp, "%d ", x->H[row*x->k + col]); } else { fprintf(fp, "%d", x->H[row*x->k + col]); } } if (row < x->n) { fprintf(fp, "\n"); } } fprintf(fp, "\n"); fclose(fp); } int main(int argc, char **argv) { if (argc < 3) { printf("usage: %s N path\n", argv[0]); exit(0); } int N = atoi(argv[1]); char *path = argv[2]; // Load the target distribution. FILE *fp = fopen(path, "r"); int n; assert(fscanf(fp, "%d", &n) == 1); double *a = load_array(fp, n); fclose(fp); // Obtain the samples. int *samples = calloc(N, sizeof(*samples)); fldrf_preprocess_t *x = fldrf_preprocess(a, n); for (int i = 0; i < N; i++) { samples[i] = fldrf_sample(x); } // Print the samples. for (int i = 0; i < N; i ++) { printf("%d ", samples[i]); } printf("\n"); // Write the structure. if (argc == 4) { write_fldrf_s(path, x); } // Free the heap. free(a); free(samples); fldrf_free(x); return 0; }
22.349057
69
0.487125
759ca9fb46c6ba7b49a700eaad0fef3f77eaa35a
718
h
C
aws-cpp-sdk-ec2/include/aws/ec2/model/LocalGatewayRouteState.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2022-02-10T08:06:54.000Z
2022-02-10T08:06:54.000Z
aws-cpp-sdk-ec2/include/aws/ec2/model/LocalGatewayRouteState.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-ec2/include/aws/ec2/model/LocalGatewayRouteState.h
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2022-03-23T15:17:18.000Z
2022-03-23T15:17:18.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/ec2/EC2_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> namespace Aws { namespace EC2 { namespace Model { enum class LocalGatewayRouteState { NOT_SET, pending, active, blackhole, deleting, deleted }; namespace LocalGatewayRouteStateMapper { AWS_EC2_API LocalGatewayRouteState GetLocalGatewayRouteStateForName(const Aws::String& name); AWS_EC2_API Aws::String GetNameForLocalGatewayRouteState(LocalGatewayRouteState value); } // namespace LocalGatewayRouteStateMapper } // namespace Model } // namespace EC2 } // namespace Aws
20.514286
93
0.754875
55a9eb841e4fde2f9f700d79385bf9d6a356550f
2,653
c
C
sw/snRuntime/src/barrier.c
sccc-8/snitch
989a0bc3987d83ef077b51e5b9a1adfc42f3cde7
[ "Apache-2.0" ]
null
null
null
sw/snRuntime/src/barrier.c
sccc-8/snitch
989a0bc3987d83ef077b51e5b9a1adfc42f3cde7
[ "Apache-2.0" ]
null
null
null
sw/snRuntime/src/barrier.c
sccc-8/snitch
989a0bc3987d83ef077b51e5b9a1adfc42f3cde7
[ "Apache-2.0" ]
null
null
null
// Copyright 2020 ETH Zurich and University of Bologna. // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 #include "snrt.h" #include "team.h" /// Synchronize cores in a cluster with a hardware barrier void snrt_cluster_hw_barrier() { _snrt_cluster_barrier(); } /// Synchronize cores in a cluster with a software barrier void snrt_cluster_sw_barrier() { // Remember previous iteration volatile struct snrt_barrier *barrier_ptr = &_snrt_team_current->root->cluster_barrier; uint32_t prev_barrier_iteration = barrier_ptr->barrier_iteration; uint32_t barrier = __atomic_add_fetch(&barrier_ptr->barrier, 1, __ATOMIC_RELAXED); // Increment the barrier counter if (barrier == snrt_cluster_core_num()) { barrier_ptr->barrier = 0; __atomic_add_fetch(&barrier_ptr->barrier_iteration, 1, __ATOMIC_RELAXED); } else { // Some threads have not reached the barrier --> Let's wait while (prev_barrier_iteration == barrier_ptr->barrier_iteration) ; } } static volatile struct snrt_barrier global_barrier __attribute__((section(".dram"))); /// Synchronize clusters globally with a global software barrier void snrt_global_barrier() { // Remember previous iteration volatile struct snrt_barrier *barrier_ptr = &global_barrier; uint32_t prev_barrier_iteration = barrier_ptr->barrier_iteration; uint32_t barrier = __atomic_add_fetch(&barrier_ptr->barrier, 1, __ATOMIC_RELAXED); // Increment the barrier counter if (barrier == snrt_global_core_num()) { barrier_ptr->barrier = 0; __atomic_add_fetch(&barrier_ptr->barrier_iteration, 1, __ATOMIC_RELAXED); } else { // Some threads have not reached the barrier --> Let's wait while (prev_barrier_iteration == barrier_ptr->barrier_iteration) ; } } /** * @brief Generic barrier * * @param barr pointer to a barrier * @param n number of harts that have to enter before released */ void snrt_barrier(struct snrt_barrier *barr, uint32_t n) { // Remember previous iteration uint32_t prev_it = barr->barrier_iteration; uint32_t barrier = __atomic_add_fetch(&barr->barrier, 1, __ATOMIC_RELAXED); // Increment the barrier counter if (barrier == n) { barr->barrier = 0; __atomic_add_fetch(&barr->barrier_iteration, 1, __ATOMIC_RELAXED); } else { // Some threads have not reached the barrier --> Let's wait while (prev_it == barr->barrier_iteration) ; } }
35.373333
79
0.686016
1d8a2da3e55b70e261ad44d4274c9196352ec6d5
323
h
C
release/src/linux/linux/include/asm-arm/arch-mx1ads/keyboard.h
enfoTek/tomato.linksys.e2000.nvram-mod
2ce3a5217def49d6df7348522e2bfda702b56029
[ "FSFAP" ]
278
2015-11-03T03:01:20.000Z
2022-01-20T18:21:05.000Z
release/src/linux/linux/include/asm-arm/arch-mx1ads/keyboard.h
unforgiven512/tomato
96f09fab4929c6ddde5c9113f1b2476ad37133c4
[ "FSFAP" ]
374
2015-11-03T12:37:22.000Z
2021-12-17T14:18:08.000Z
release/src/linux/linux/include/asm-arm/arch-mx1ads/keyboard.h
unforgiven512/tomato
96f09fab4929c6ddde5c9113f1b2476ad37133c4
[ "FSFAP" ]
96
2015-11-22T07:47:26.000Z
2022-01-20T19:52:19.000Z
/* * linux/include/asm-arm/arch-mx1ads/keyboard.h * * Copyright (C) 2002 Shane Nay (shane@minirl.com) * * Well..., what did you expect?, it's not really there :) * */ #define kbd_init_hw() do { } while (0) #define kbd_enable_irq() do { } while (0) #define kbd_disable_irq() do { } while (0)
26.916667
58
0.594427
0e809a1918f3a9df8d40242a5c266db51a4ecd08
505
c
C
chapter_05/fmemopen.c
PacktPublishing/Mastering-Unix-Programming
9483bcbef8856f7d63dd304abffbdbac7c9634d6
[ "MIT" ]
2
2020-12-27T16:56:01.000Z
2021-11-14T14:16:33.000Z
chapter_05/fmemopen.c
PacktPublishing/Mastering-Unix-Programming
9483bcbef8856f7d63dd304abffbdbac7c9634d6
[ "MIT" ]
null
null
null
chapter_05/fmemopen.c
PacktPublishing/Mastering-Unix-Programming
9483bcbef8856f7d63dd304abffbdbac7c9634d6
[ "MIT" ]
2
2020-09-21T02:00:24.000Z
2021-08-24T10:45:49.000Z
#include <stdio.h> #define BUF_SIZE 256 char buf[BUF_SIZE]; void dump(FILE *fp) { int c; while ((c = fgetc(fp)) != EOF) printf("%c", c); printf("\n"); } int main(void) { FILE *fp; fp = fmemopen(buf, BUF_SIZE, "r+"); if (!fp) { perror("fmemopen"); return -1; } /* Write something in the stream */ fprintf(fp, "the buffer is %d bytes long\n", BUF_SIZE); /* Rewind the "current position" pointer */ rewind(fp); printf("Data in the stream:\n"); dump(fp); fclose(fp); return 0; }
13.648649
56
0.60198
1d8b96847db2ec2c20e0d3bf4e4f4e8098047d7e
3,636
h
C
Source/Core/StaticString.h
aiekick/VulkanRTSEngine
b02c0d0fa1530dc920fde2a9928bd540cfdd31e6
[ "Apache-2.0" ]
1
2021-05-11T07:52:05.000Z
2021-05-11T07:52:05.000Z
Source/Core/StaticString.h
aiekick/VulkanRTSEngine
b02c0d0fa1530dc920fde2a9928bd540cfdd31e6
[ "Apache-2.0" ]
null
null
null
Source/Core/StaticString.h
aiekick/VulkanRTSEngine
b02c0d0fa1530dc920fde2a9928bd540cfdd31e6
[ "Apache-2.0" ]
null
null
null
#pragma once #include <type_traits> // TODO: add static-runtime asserts for safety // TODO: add raw c-string initializer // A String with on-stack allocated buffer. Constexpr context usable. template<int N> class StaticString { // utility constructors to enable efficient concatenation template<int M, int K> constexpr StaticString(const char(&aBuffer)[M], const StaticString<K>& aString) : myBuffer{0} , myLength(M+K-1) { for (int i = 0; i < M - 1; i++) // skip \0 { myBuffer[i] = aBuffer[i]; } for (int i = 0; i < K; i++) { myBuffer[M - 1 + i] = aString[i]; } } template<int M, int K> constexpr StaticString(const StaticString<M>& aString, const char(&aBuffer)[K]) : myBuffer{ 0 } , myLength(M + K - 1) { for (int i = 0; i < M - 1; i++) // skip \0 { myBuffer[i] = aString[i]; } for (int i = 0; i < K; i++) { myBuffer[M - 1 + i] = aBuffer[i]; } } template<int M, int K> constexpr StaticString(const StaticString<M>& aString1, const StaticString<K>& aString2) : myBuffer{ 0 } , myLength(M + K - 1) { for (int i = 0; i < M - 1; i++) // skip \0 { myBuffer[i] = aString1[i]; } for (int i = 0; i < K; i++) { myBuffer[M - 1 + i] = aString2[i]; } } // friend declarations template<int N, int M> friend constexpr StaticString<N + M - 1> operator+(const char(&aBuffer)[N], const StaticString<M>& aString); template<int N, int M> friend constexpr StaticString<N + M - 1> operator+(const StaticString<N>& aString, const char(&aBuffer)[M]); template<int N, int M> friend constexpr StaticString<N + M - 1> operator+(const StaticString<N>& aString1, const StaticString<M>& aString2); public: constexpr StaticString(const char(&aBuffer)[N]) : myBuffer{0} // constexpr requires members to be initialized , myLength(N) { for (int i = 0; i < N; i++) { myBuffer[i] = aBuffer[i]; } } template<int M, class = std::enable_if_t<M <= N>> constexpr StaticString(const char(&aBuffer)[M]) : myBuffer{0} // constexpr requires members to be initialized , myLength(M) { for (int i = 0; i < M; i++) { myBuffer[i] = aBuffer[i]; } } template<int M, class = std::enable_if_t<M <= N>> constexpr StaticString(const StaticString<M>& aOther) : myBuffer{0} , myLength(M) { for (int i = 0; i < M; i++) { myBuffer[i] = aOther[i]; } } constexpr char& operator[](int index) { // TODO: add check to enforce last element to be \0 return myBuffer[index]; } constexpr const char& operator[](int index) const { return myBuffer[index]; } constexpr int GetLength() const { return myLength; } constexpr int GetMaxLength() const { return N; } template<int M> constexpr bool operator==(const StaticString<M>& aOther) { if (myLength != aOther.GetLength()) { return false; } for (int i = 0; i < myLength; i++) { if (myBuffer[i] != aOther[i]) { return false; } } return true; } constexpr const char* CStr() const { return myBuffer; } private: char myBuffer[N]; int myLength; }; template<int N, int M> constexpr StaticString<N + M - 1> operator+(const char(&aBuffer)[N], const StaticString<M>& aString) { return StaticString<N + M - 1>(aBuffer, aString); } template<int N, int M> constexpr StaticString<N + M - 1> operator+(const StaticString<N>& aString, const char(&aBuffer)[M]) { return StaticString<N + M - 1>(aString, aBuffer); } template<int N, int M> constexpr StaticString<N + M - 1> operator+(const StaticString<N>& aString1, const StaticString<M>& aString2) { return StaticString<N + M - 1>(aString1, aString2); }
20.896552
89
0.626513
5c1a7f59bbf3e55694bef6fa93006480a7b3345d
640
h
C
HaoYuClient_rac/HaoYuClient/Component/ChooseDiscountViewController/HYChooseDiscountViewController.h
1365102044/lwHooray
3ed66a8adea99220bb748d603bf4c432cbe70fec
[ "MIT" ]
null
null
null
HaoYuClient_rac/HaoYuClient/Component/ChooseDiscountViewController/HYChooseDiscountViewController.h
1365102044/lwHooray
3ed66a8adea99220bb748d603bf4c432cbe70fec
[ "MIT" ]
null
null
null
HaoYuClient_rac/HaoYuClient/Component/ChooseDiscountViewController/HYChooseDiscountViewController.h
1365102044/lwHooray
3ed66a8adea99220bb748d603bf4c432cbe70fec
[ "MIT" ]
null
null
null
// // HYChooseDiscountViewController.h // HaoYuClient // // Created by 刘文强 on 2018/9/25. // Copyright © 2018年 LWQ. All rights reserved. // #import "HYBaseTableViewController.h" @protocol chooseDiscountDelegate <NSObject> - (void)alearySelectDicount:(NSArray *)discounts indexPath:(NSIndexPath *)indexPath; @end @interface HYChooseDiscountViewController : HYBaseTableViewController @property (nonatomic, strong) NSIndexPath * indexpath; @property (nonatomic, weak) id<chooseDiscountDelegate> delegate; + (instancetype)creatChooseDiscountVCWithDatas:(NSArray *)datas sourceVC:(HYBaseViewController *)sourceVC extend:(id)extend; @end
29.090909
124
0.789063
ce7352c70b5dc4fcc6455041aa6d5daa40adb75c
218
h
C
Source/Core/Shape.h
thavlik/iridium
8051e7ed6aefd42552e5737aff3d20fd0b844eda
[ "MIT" ]
1
2017-09-08T04:26:19.000Z
2017-09-08T04:26:19.000Z
Source/Core/Shape.h
thavlik/iridium
8051e7ed6aefd42552e5737aff3d20fd0b844eda
[ "MIT" ]
null
null
null
Source/Core/Shape.h
thavlik/iridium
8051e7ed6aefd42552e5737aff3d20fd0b844eda
[ "MIT" ]
null
null
null
#pragma once #include "Control.h" namespace Ir { class Shape : public Control { public: Shape(Object* parent); public: GeometryProperty RendererdGeometry; public: virtual void Draw(Renderer*) const; }; }
13.625
37
0.711009
a81e52bd3e27ec3de25a2f510652648c0b6d146f
6,154
h
C
src_code/Datastruct_C++(thrid)/Treap.h
yanrong/book_demo
20cd13f3c3507a11e826ebbf22bd1c7bcb36e06f
[ "Apache-2.0" ]
5
2017-03-30T23:23:08.000Z
2020-11-08T00:34:46.000Z
src_code/Datastruct_C++(thrid)/Treap.h
yanrong/book_demo
20cd13f3c3507a11e826ebbf22bd1c7bcb36e06f
[ "Apache-2.0" ]
null
null
null
src_code/Datastruct_C++(thrid)/Treap.h
yanrong/book_demo
20cd13f3c3507a11e826ebbf22bd1c7bcb36e06f
[ "Apache-2.0" ]
1
2019-04-12T13:17:31.000Z
2019-04-12T13:17:31.000Z
#ifndef TREAP_H #define TREAP_H #include <climits> #include "Random.h" #include "dsexceptions.h" #include <iostream> // For NULL using namespace std; // Treap class // // ******************PUBLIC OPERATIONS********************* // void insert( x ) --> Insert x // void remove( x ) --> Remove x (unimplemented) // bool contains( x ) --> Return true if x is present // Comparable findMin( ) --> Return smallest item // Comparable findMax( ) --> Return largest item // bool isEmpty( ) --> Return true if empty; else false // void makeEmpty( ) --> Remove all items // void printTree( ) --> Print tree in sorted order // ******************ERRORS******************************** // Throws UnderflowException as warranted template <typename Comparable> class Treap { public: Treap( ) { nullNode = new TreapNode; nullNode->left = nullNode->right = nullNode; nullNode->priority = INT_MAX; root = nullNode; } Treap( const Treap & rhs ) { nullNode = new TreapNode; nullNode->left = nullNode->right = nullNode; nullNode->priority = INT_MAX; root = nullNode; *this = rhs; } ~Treap( ) { makeEmpty( ); delete nullNode; } const Comparable & findMin( ) const { if( isEmpty( ) ) throw UnderflowException( ); TreapNode *ptr = root; while( ptr->left != nullNode ) ptr = ptr->left; return ptr->element; } const Comparable & findMax( ) const { if( isEmpty( ) ) throw UnderflowException( ); TreapNode *ptr = root; while( ptr->right != nullNode ) ptr = ptr->right; return ptr->element; } bool contains( const Comparable & x ) const { TreapNode *current = root; nullNode->element = x; for( ; ; ) { if( x < current->element ) current = current->left; else if( current->element < x ) current = current->right; else return current != nullNode; } } bool isEmpty( ) const { return root == nullNode; } void printTree( ) const { if( isEmpty( ) ) cout << "Empty tree" << endl; else printTree( root ); } void makeEmpty( ) { makeEmpty( root ); } void insert( const Comparable & x ) { insert( x, root ); } void remove( const Comparable & x ) { remove( x, root ); } const Treap & operator=( const Treap & rhs ) { if( this != &rhs ) { makeEmpty( ); root = clone( rhs.root ); } return *this; } private: struct TreapNode { Comparable element; TreapNode *left; TreapNode *right; int priority; TreapNode( ) : left( NULL ), right( NULL ), priority( INT_MAX ) { } TreapNode( const Comparable & theElement, TreapNode *lt, TreapNode *rt, int pr ) : element( theElement ), left( lt ), right( rt ), priority( pr ) { } }; TreapNode *root; TreapNode *nullNode; Random randomNums; // Recursive routines /** * Internal method to insert into a subtree. * x is the item to insert. * t is the node that roots the tree. * Set the new root of the subtree. * (randomNums is a Random object that is a data member of Treap.) */ void insert( const Comparable & x, TreapNode* & t ) { if( t == nullNode ) t = new TreapNode( x, nullNode, nullNode, randomNums.randomInt( ) ); else if( x < t->element ) { insert( x, t->left ); if( t->left->priority < t->priority ) rotateWithLeftChild( t ); } else if( t->element < x ) { insert( x, t->right ); if( t->right->priority < t->priority ) rotateWithRightChild( t ); } // else duplicate; do nothing } /** * Internal method to remove from a subtree. * x is the item to remove. * t is the node that roots the tree. * Set the new root of the subtree. */ void remove( const Comparable & x, TreapNode * & t ) { if( t != nullNode ) { if( x < t->element ) remove( x, t->left ); else if( t->element < x ) remove( x, t->right ); else { // Match found if( t->left->priority < t->right->priority ) rotateWithLeftChild( t ); else rotateWithRightChild( t ); if( t != nullNode ) // Continue on down remove( x, t ); else { delete t->left; t->left = nullNode; // At a leaf } } } } void makeEmpty( TreapNode * & t ) { if( t != nullNode ) { makeEmpty( t->left ); makeEmpty( t->right ); delete t; } t = nullNode; } void printTree( TreapNode *t ) const { if( t != nullNode ) { printTree( t->left ); cout << t->element << endl; printTree( t->right ); } } // Rotations void rotateWithLeftChild( TreapNode * & k2 ) { TreapNode *k1 = k2->left; k2->left = k1->right; k1->right = k2; k2 = k1; } void rotateWithRightChild( TreapNode * & k1 ) { TreapNode *k2 = k1->right; k1->right = k2->left; k2->left = k1; k1 = k2; } TreapNode * clone( TreapNode * t ) const { if( t == t->left ) // Cannot test against nullNode!!! return nullNode; else return new TreapNode( t->element, clone( t->left ), clone( t->right ), t->priority ); } }; #endif
23.945525
97
0.473838
6de770841e3a94a5d604db7b63f3e174c3a98234
19,010
c
C
kernel/lge/msm8226/arch/arm/mach-msm/board-8064-camera.c
Uswer/LineageOS-14.1_jag3gds
6fe76987fad4fca7b3c08743b067d5e79892e77f
[ "Apache-2.0" ]
1
2020-06-01T10:53:47.000Z
2020-06-01T10:53:47.000Z
kernel/lge/msm8226/arch/arm/mach-msm/board-8064-camera.c
Uswer/LineageOS-14.1_jag3gds
6fe76987fad4fca7b3c08743b067d5e79892e77f
[ "Apache-2.0" ]
1
2020-05-28T13:06:06.000Z
2020-05-28T13:13:15.000Z
kernel/lge/msm8226/arch/arm/mach-msm/board-8064-camera.c
Uswer/LineageOS-14.1_jag3gds
6fe76987fad4fca7b3c08743b067d5e79892e77f
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2012, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include <linux/i2c.h> #include <linux/gpio.h> #include <asm/mach-types.h> #include <mach/camera.h> #include <mach/msm_bus_board.h> #include <mach/gpiomux.h> #include "devices.h" #include "board-8064.h" #ifdef CONFIG_MSM_CAMERA static struct gpiomux_setting cam_settings[] = { { .func = GPIOMUX_FUNC_GPIO, /*suspend*/ .drv = GPIOMUX_DRV_2MA, .pull = GPIOMUX_PULL_DOWN, }, { .func = GPIOMUX_FUNC_1, /*active 1*/ .drv = GPIOMUX_DRV_2MA, .pull = GPIOMUX_PULL_NONE, }, { .func = GPIOMUX_FUNC_GPIO, /*active 2*/ .drv = GPIOMUX_DRV_2MA, .pull = GPIOMUX_PULL_NONE, }, { .func = GPIOMUX_FUNC_2, /*active 3*/ .drv = GPIOMUX_DRV_2MA, .pull = GPIOMUX_PULL_NONE, }, { .func = GPIOMUX_FUNC_5, /*active 4*/ .drv = GPIOMUX_DRV_8MA, .pull = GPIOMUX_PULL_UP, }, { .func = GPIOMUX_FUNC_6, /*active 5*/ .drv = GPIOMUX_DRV_8MA, .pull = GPIOMUX_PULL_UP, }, { .func = GPIOMUX_FUNC_2, /*active 6*/ .drv = GPIOMUX_DRV_2MA, .pull = GPIOMUX_PULL_UP, }, { .func = GPIOMUX_FUNC_3, /*active 7*/ .drv = GPIOMUX_DRV_8MA, .pull = GPIOMUX_PULL_UP, }, { .func = GPIOMUX_FUNC_GPIO, /*i2c suspend*/ .drv = GPIOMUX_DRV_2MA, .pull = GPIOMUX_PULL_KEEPER, }, { .func = GPIOMUX_FUNC_9, /*active 9*/ .drv = GPIOMUX_DRV_8MA, .pull = GPIOMUX_PULL_NONE, }, { .func = GPIOMUX_FUNC_A, /*active 10*/ .drv = GPIOMUX_DRV_8MA, .pull = GPIOMUX_PULL_NONE, }, { .func = GPIOMUX_FUNC_6, /*active 11*/ .drv = GPIOMUX_DRV_8MA, .pull = GPIOMUX_PULL_NONE, }, { .func = GPIOMUX_FUNC_4, /*active 12*/ .drv = GPIOMUX_DRV_2MA, .pull = GPIOMUX_PULL_NONE, }, }; static struct msm_gpiomux_config apq8064_cam_common_configs[] = { { .gpio = 1, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[2], [GPIOMUX_SUSPENDED] = &cam_settings[0], }, }, { .gpio = 2, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[12], [GPIOMUX_SUSPENDED] = &cam_settings[0], }, }, { .gpio = 3, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[2], [GPIOMUX_SUSPENDED] = &cam_settings[0], }, }, { .gpio = 4, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[3], [GPIOMUX_SUSPENDED] = &cam_settings[0], }, }, { .gpio = 5, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[1], [GPIOMUX_SUSPENDED] = &cam_settings[0], }, }, { .gpio = 34, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[2], [GPIOMUX_SUSPENDED] = &cam_settings[0], }, }, { .gpio = 107, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[2], [GPIOMUX_SUSPENDED] = &cam_settings[0], }, }, { .gpio = 10, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[9], [GPIOMUX_SUSPENDED] = &cam_settings[8], }, }, { .gpio = 11, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[10], [GPIOMUX_SUSPENDED] = &cam_settings[8], }, }, { .gpio = 12, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[11], [GPIOMUX_SUSPENDED] = &cam_settings[8], }, }, { .gpio = 13, .settings = { [GPIOMUX_ACTIVE] = &cam_settings[11], [GPIOMUX_SUSPENDED] = &cam_settings[8], }, }, }; #define VFE_CAMIF_TIMER1_GPIO 3 #define VFE_CAMIF_TIMER2_GPIO 1 static struct gpio flash_init_gpio[] = { {VFE_CAMIF_TIMER1_GPIO, GPIOF_OUT_INIT_LOW, "CAMIF_TIMER1"}, {VFE_CAMIF_TIMER2_GPIO, GPIOF_OUT_INIT_LOW, "CAMIF_TIMER2"}, }; static struct msm_gpio_set_tbl flash_set_gpio[] = { {VFE_CAMIF_TIMER1_GPIO, GPIOF_OUT_INIT_HIGH, 2000}, {VFE_CAMIF_TIMER2_GPIO, GPIOF_OUT_INIT_HIGH, 2000}, }; static struct msm_camera_sensor_flash_src msm_flash_src = { .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT, .init_gpio_tbl = flash_init_gpio, .init_gpio_tbl_size = ARRAY_SIZE(flash_init_gpio), .set_gpio_tbl = flash_set_gpio, .set_gpio_tbl_size = ARRAY_SIZE(flash_set_gpio), ._fsrc.ext_driver_src.led_en = VFE_CAMIF_TIMER1_GPIO, ._fsrc.ext_driver_src.led_flash_en = VFE_CAMIF_TIMER2_GPIO, ._fsrc.ext_driver_src.flash_id = MAM_CAMERA_EXT_LED_FLASH_SC628A, }; static struct msm_gpiomux_config apq8064_cam_2d_configs[] = { }; static struct msm_bus_vectors cam_init_vectors[] = { { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, { .src = MSM_BUS_MASTER_VPE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, }; static struct msm_bus_vectors cam_preview_vectors[] = { { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 27648000, .ib = 110592000, }, { .src = MSM_BUS_MASTER_VPE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, }; static struct msm_bus_vectors cam_video_vectors[] = { { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 274406400, .ib = 561807360, }, { .src = MSM_BUS_MASTER_VPE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 206807040, .ib = 488816640, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, }; static struct msm_bus_vectors cam_snapshot_vectors[] = { { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 274423680, .ib = 1097694720, }, { .src = MSM_BUS_MASTER_VPE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 540000000, .ib = 1350000000, }, }; static struct msm_bus_vectors cam_zsl_vectors[] = { { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 302071680, .ib = 1208286720, }, { .src = MSM_BUS_MASTER_VPE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 540000000, .ib = 1350000000, }, }; static struct msm_bus_vectors cam_video_ls_vectors[] = { { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 348192000, .ib = 617103360, }, { .src = MSM_BUS_MASTER_VPE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 206807040, .ib = 488816640, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 540000000, .ib = 1350000000, }, }; static struct msm_bus_vectors cam_dual_vectors[] = { { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 348192000, .ib = 1208286720, }, { .src = MSM_BUS_MASTER_VPE, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 206807040, .ib = 488816640, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 540000000, .ib = 1350000000, }, { .src = MSM_BUS_MASTER_JPEG_ENC, .dst = MSM_BUS_SLAVE_MM_IMEM, .ab = 43200000, .ib = 69120000, }, { .src = MSM_BUS_MASTER_VFE, .dst = MSM_BUS_SLAVE_MM_IMEM, .ab = 43200000, .ib = 69120000, }, }; static struct msm_bus_paths cam_bus_client_config[] = { { ARRAY_SIZE(cam_init_vectors), cam_init_vectors, }, { ARRAY_SIZE(cam_preview_vectors), cam_preview_vectors, }, { ARRAY_SIZE(cam_video_vectors), cam_video_vectors, }, { ARRAY_SIZE(cam_snapshot_vectors), cam_snapshot_vectors, }, { ARRAY_SIZE(cam_zsl_vectors), cam_zsl_vectors, }, { ARRAY_SIZE(cam_video_ls_vectors), cam_video_ls_vectors, }, { ARRAY_SIZE(cam_dual_vectors), cam_dual_vectors, }, }; static struct msm_bus_scale_pdata cam_bus_client_pdata = { cam_bus_client_config, ARRAY_SIZE(cam_bus_client_config), .name = "msm_camera", }; static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = { { .csiphy_core = 0, .csid_core = 0, .is_vpe = 1, .cam_bus_scale_table = &cam_bus_client_pdata, }, { .csiphy_core = 1, .csid_core = 1, .is_vpe = 1, .cam_bus_scale_table = &cam_bus_client_pdata, }, }; static struct camera_vreg_t apq_8064_cam_vreg[] = { {"cam_vdig", REG_LDO, 1200000, 1200000, 105000}, {"cam_vio", REG_VS, 0, 0, 0}, {"cam_vana", REG_LDO, 2800000, 2850000, 85600}, {"cam_vaf", REG_LDO, 2800000, 2850000, 300000}, }; #define CAML_RSTN PM8921_GPIO_PM_TO_SYS(28) #define CAMR_RSTN 34 static struct gpio apq8064_common_cam_gpio[] = { }; static struct gpio apq8064_back_cam_gpio[] = { {5, GPIOF_DIR_IN, "CAMIF_MCLK"}, {CAML_RSTN, GPIOF_DIR_OUT, "CAM_RESET"}, }; static struct msm_gpio_set_tbl apq8064_back_cam_gpio_set_tbl[] = { {CAML_RSTN, GPIOF_OUT_INIT_LOW, 10000}, {CAML_RSTN, GPIOF_OUT_INIT_HIGH, 10000}, }; static struct msm_camera_gpio_conf apq8064_back_cam_gpio_conf = { .cam_gpiomux_conf_tbl = apq8064_cam_2d_configs, .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(apq8064_cam_2d_configs), .cam_gpio_common_tbl = apq8064_common_cam_gpio, .cam_gpio_common_tbl_size = ARRAY_SIZE(apq8064_common_cam_gpio), .cam_gpio_req_tbl = apq8064_back_cam_gpio, .cam_gpio_req_tbl_size = ARRAY_SIZE(apq8064_back_cam_gpio), .cam_gpio_set_tbl = apq8064_back_cam_gpio_set_tbl, .cam_gpio_set_tbl_size = ARRAY_SIZE(apq8064_back_cam_gpio_set_tbl), }; static struct gpio apq8064_front_cam_gpio[] = { {4, GPIOF_DIR_IN, "CAMIF_MCLK"}, {12, GPIOF_DIR_IN, "CAMIF_I2C_DATA"}, {13, GPIOF_DIR_IN, "CAMIF_I2C_CLK"}, {CAMR_RSTN, GPIOF_DIR_OUT, "CAM_RESET"}, }; static struct msm_gpio_set_tbl apq8064_front_cam_gpio_set_tbl[] = { {CAMR_RSTN, GPIOF_OUT_INIT_LOW, 10000}, {CAMR_RSTN, GPIOF_OUT_INIT_HIGH, 10000}, }; static struct msm_camera_gpio_conf apq8064_front_cam_gpio_conf = { .cam_gpiomux_conf_tbl = apq8064_cam_2d_configs, .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(apq8064_cam_2d_configs), .cam_gpio_common_tbl = apq8064_common_cam_gpio, .cam_gpio_common_tbl_size = ARRAY_SIZE(apq8064_common_cam_gpio), .cam_gpio_req_tbl = apq8064_front_cam_gpio, .cam_gpio_req_tbl_size = ARRAY_SIZE(apq8064_front_cam_gpio), .cam_gpio_set_tbl = apq8064_front_cam_gpio_set_tbl, .cam_gpio_set_tbl_size = ARRAY_SIZE(apq8064_front_cam_gpio_set_tbl), }; static struct msm_camera_i2c_conf apq8064_back_cam_i2c_conf = { .use_i2c_mux = 1, .mux_dev = &msm8960_device_i2c_mux_gsbi4, .i2c_mux_mode = MODE_L, }; static struct i2c_board_info msm_act_main_cam_i2c_info = { I2C_BOARD_INFO("msm_actuator", 0x11), }; static struct msm_actuator_info msm_act_main_cam_0_info = { .board_info = &msm_act_main_cam_i2c_info, .cam_name = MSM_ACTUATOR_MAIN_CAM_0, .bus_id = APQ_8064_GSBI4_QUP_I2C_BUS_ID, .vcm_pwd = 0, .vcm_enable = 0, }; static struct i2c_board_info msm_act_main_cam1_i2c_info = { I2C_BOARD_INFO("msm_actuator", 0x18), }; static struct msm_actuator_info msm_act_main_cam_1_info = { .board_info = &msm_act_main_cam1_i2c_info, .cam_name = MSM_ACTUATOR_MAIN_CAM_1, .bus_id = APQ_8064_GSBI4_QUP_I2C_BUS_ID, .vcm_pwd = 0, .vcm_enable = 0, }; static struct msm_camera_i2c_conf apq8064_front_cam_i2c_conf = { .use_i2c_mux = 1, .mux_dev = &msm8960_device_i2c_mux_gsbi4, .i2c_mux_mode = MODE_L, }; static struct msm_camera_sensor_flash_data flash_imx135 = { .flash_type = MSM_CAMERA_FLASH_NONE, }; static struct msm_camera_csi_lane_params imx135_csi_lane_params = { .csi_lane_assign = 0xE4, .csi_lane_mask = 0xF, }; static struct msm_camera_sensor_platform_info sensor_board_info_imx135 = { .mount_angle = 90, .cam_vreg = apq_8064_cam_vreg, .num_vreg = ARRAY_SIZE(apq_8064_cam_vreg), .gpio_conf = &apq8064_back_cam_gpio_conf, .i2c_conf = &apq8064_back_cam_i2c_conf, .csi_lane_params = &imx135_csi_lane_params, }; static struct msm_camera_sensor_info msm_camera_sensor_imx135_data = { .sensor_name = "imx135", .pdata = &msm_camera_csi_device_data[0], .flash_data = &flash_imx135, .sensor_platform_info = &sensor_board_info_imx135, .csi_if = 1, .camera_type = BACK_CAMERA_2D, .sensor_type = BAYER_SENSOR, .actuator_info = &msm_act_main_cam_1_info, }; static struct i2c_board_info sc628a_flash_i2c_info = { I2C_BOARD_INFO("sc628a", 0x6E), }; static struct msm_camera_sensor_flash_data flash_imx074 = { .flash_type = MSM_CAMERA_FLASH_LED, .flash_src = &msm_flash_src, .board_info = &sc628a_flash_i2c_info, .bus_id = APQ_8064_GSBI4_QUP_I2C_BUS_ID, }; static struct msm_camera_csi_lane_params imx074_csi_lane_params = { .csi_lane_assign = 0xE4, .csi_lane_mask = 0xF, }; static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = { .mount_angle = 90, .cam_vreg = apq_8064_cam_vreg, .num_vreg = ARRAY_SIZE(apq_8064_cam_vreg), .gpio_conf = &apq8064_back_cam_gpio_conf, .i2c_conf = &apq8064_back_cam_i2c_conf, .csi_lane_params = &imx074_csi_lane_params, }; static struct i2c_board_info imx074_eeprom_i2c_info = { I2C_BOARD_INFO("imx074_eeprom", 0x34 << 1), }; static struct msm_eeprom_info imx074_eeprom_info = { .board_info = &imx074_eeprom_i2c_info, .bus_id = APQ_8064_GSBI4_QUP_I2C_BUS_ID, }; static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = { .sensor_name = "imx074", .pdata = &msm_camera_csi_device_data[0], .flash_data = &flash_imx074, .sensor_platform_info = &sensor_board_info_imx074, .csi_if = 1, .camera_type = BACK_CAMERA_2D, .sensor_type = BAYER_SENSOR, .actuator_info = &msm_act_main_cam_0_info, .eeprom_info = &imx074_eeprom_info, }; static struct msm_camera_csi_lane_params imx091_csi_lane_params = { .csi_lane_assign = 0xE4, .csi_lane_mask = 0xF, }; static struct msm_camera_sensor_flash_data flash_imx091 = { .flash_type = MSM_CAMERA_FLASH_NONE, }; static struct msm_camera_sensor_platform_info sensor_board_info_imx091 = { .mount_angle = 0, .cam_vreg = apq_8064_cam_vreg, .num_vreg = ARRAY_SIZE(apq_8064_cam_vreg), .gpio_conf = &apq8064_back_cam_gpio_conf, .i2c_conf = &apq8064_back_cam_i2c_conf, .csi_lane_params = &imx091_csi_lane_params, }; static struct i2c_board_info imx091_eeprom_i2c_info = { I2C_BOARD_INFO("imx091_eeprom", 0x21), }; static struct msm_eeprom_info imx091_eeprom_info = { .board_info = &imx091_eeprom_i2c_info, .bus_id = APQ_8064_GSBI4_QUP_I2C_BUS_ID, }; static struct msm_camera_sensor_info msm_camera_sensor_imx091_data = { .sensor_name = "imx091", .pdata = &msm_camera_csi_device_data[0], .flash_data = &flash_imx091, .sensor_platform_info = &sensor_board_info_imx091, .csi_if = 1, .camera_type = BACK_CAMERA_2D, .sensor_type = BAYER_SENSOR, .actuator_info = &msm_act_main_cam_1_info, .eeprom_info = &imx091_eeprom_info, }; static struct msm_camera_sensor_flash_data flash_s5k3l1yx = { .flash_type = MSM_CAMERA_FLASH_NONE, }; static struct msm_camera_csi_lane_params s5k3l1yx_csi_lane_params = { .csi_lane_assign = 0xE4, .csi_lane_mask = 0xF, }; static struct msm_camera_sensor_platform_info sensor_board_info_s5k3l1yx = { .mount_angle = 90, .cam_vreg = apq_8064_cam_vreg, .num_vreg = ARRAY_SIZE(apq_8064_cam_vreg), .gpio_conf = &apq8064_back_cam_gpio_conf, .i2c_conf = &apq8064_back_cam_i2c_conf, .csi_lane_params = &s5k3l1yx_csi_lane_params, }; static struct msm_camera_sensor_info msm_camera_sensor_s5k3l1yx_data = { .sensor_name = "s5k3l1yx", .pdata = &msm_camera_csi_device_data[0], .flash_data = &flash_s5k3l1yx, .sensor_platform_info = &sensor_board_info_s5k3l1yx, .csi_if = 1, .camera_type = BACK_CAMERA_2D, .sensor_type = BAYER_SENSOR, }; static struct msm_camera_sensor_flash_data flash_mt9m114 = { .flash_type = MSM_CAMERA_FLASH_NONE }; static struct msm_camera_csi_lane_params mt9m114_csi_lane_params = { .csi_lane_assign = 0xE4, .csi_lane_mask = 0x1, }; static struct msm_camera_sensor_platform_info sensor_board_info_mt9m114 = { .mount_angle = 90, .cam_vreg = apq_8064_cam_vreg, .num_vreg = ARRAY_SIZE(apq_8064_cam_vreg), .gpio_conf = &apq8064_front_cam_gpio_conf, .i2c_conf = &apq8064_front_cam_i2c_conf, .csi_lane_params = &mt9m114_csi_lane_params, }; static struct msm_camera_sensor_info msm_camera_sensor_mt9m114_data = { .sensor_name = "mt9m114", .pdata = &msm_camera_csi_device_data[1], .flash_data = &flash_mt9m114, .sensor_platform_info = &sensor_board_info_mt9m114, .csi_if = 1, .camera_type = FRONT_CAMERA_2D, .sensor_type = YUV_SENSOR, }; static struct msm_camera_sensor_flash_data flash_ov2720 = { .flash_type = MSM_CAMERA_FLASH_NONE, }; static struct msm_camera_csi_lane_params ov2720_csi_lane_params = { .csi_lane_assign = 0xE4, .csi_lane_mask = 0x3, }; static struct msm_camera_sensor_platform_info sensor_board_info_ov2720 = { .mount_angle = 0, .cam_vreg = apq_8064_cam_vreg, .num_vreg = ARRAY_SIZE(apq_8064_cam_vreg), .gpio_conf = &apq8064_front_cam_gpio_conf, .i2c_conf = &apq8064_front_cam_i2c_conf, .csi_lane_params = &ov2720_csi_lane_params, }; static struct msm_camera_sensor_info msm_camera_sensor_ov2720_data = { .sensor_name = "ov2720", .pdata = &msm_camera_csi_device_data[1], .flash_data = &flash_ov2720, .sensor_platform_info = &sensor_board_info_ov2720, .csi_if = 1, .camera_type = FRONT_CAMERA_2D, .sensor_type = BAYER_SENSOR, }; static struct platform_device msm_camera_server = { .name = "msm_cam_server", .id = 0, }; void __init apq8064_init_cam(void) { msm_gpiomux_install(apq8064_cam_common_configs, ARRAY_SIZE(apq8064_cam_common_configs)); if (machine_is_apq8064_cdp()) { sensor_board_info_imx074.mount_angle = 0; sensor_board_info_mt9m114.mount_angle = 0; } else if (machine_is_apq8064_liquid()) sensor_board_info_imx074.mount_angle = 180; platform_device_register(&msm_camera_server); platform_device_register(&msm8960_device_i2c_mux_gsbi4); platform_device_register(&msm8960_device_csiphy0); platform_device_register(&msm8960_device_csiphy1); platform_device_register(&msm8960_device_csid0); platform_device_register(&msm8960_device_csid1); platform_device_register(&msm8960_device_ispif); platform_device_register(&msm8960_device_vfe); platform_device_register(&msm8960_device_vpe); } #ifdef CONFIG_I2C static struct i2c_board_info apq8064_camera_i2c_boardinfo[] = { { I2C_BOARD_INFO("imx074", 0x1A), .platform_data = &msm_camera_sensor_imx074_data, }, { I2C_BOARD_INFO("imx135", 0x10), .platform_data = &msm_camera_sensor_imx135_data, }, { I2C_BOARD_INFO("mt9m114", 0x48), .platform_data = &msm_camera_sensor_mt9m114_data, }, { I2C_BOARD_INFO("ov2720", 0x6C), .platform_data = &msm_camera_sensor_ov2720_data, }, { I2C_BOARD_INFO("imx091", 0x34), .platform_data = &msm_camera_sensor_imx091_data, }, { I2C_BOARD_INFO("s5k3l1yx", 0x20), .platform_data = &msm_camera_sensor_s5k3l1yx_data, }, }; struct msm_camera_board_info apq8064_camera_board_info = { .board_info = apq8064_camera_i2c_boardinfo, .num_i2c_board_info = ARRAY_SIZE(apq8064_camera_i2c_boardinfo), }; #endif #endif
24.403081
78
0.732457
b8fbe6ba42bbd8fff2dce02037d01e29359e7416
1,845
c
C
3rdparty/suitesparse-metis-for-windows-1.2.1/SuiteSparse/UMFPACK/Source/umfpack_free_numeric.c
luoyongheng/dtslam
d3c2230d45db14c811eff6fd43e119ac39af1352
[ "BSD-3-Clause" ]
144
2015-01-15T03:38:44.000Z
2022-02-17T09:07:52.000Z
3rdparty/suitesparse-metis-for-windows-1.2.1/SuiteSparse/UMFPACK/Source/umfpack_free_numeric.c
luoyongheng/dtslam
d3c2230d45db14c811eff6fd43e119ac39af1352
[ "BSD-3-Clause" ]
9
2015-09-09T06:51:46.000Z
2020-06-17T14:10:10.000Z
3rdparty/suitesparse-metis-for-windows-1.2.1/SuiteSparse/UMFPACK/Source/umfpack_free_numeric.c
luoyongheng/dtslam
d3c2230d45db14c811eff6fd43e119ac39af1352
[ "BSD-3-Clause" ]
58
2015-01-14T23:43:49.000Z
2021-11-15T05:19:08.000Z
/* ========================================================================== */ /* === UMFPACK_free_numeric ================================================= */ /* ========================================================================== */ /* -------------------------------------------------------------------------- */ /* Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com. */ /* All Rights Reserved. See ../Doc/License for License. */ /* -------------------------------------------------------------------------- */ /* User-callable. Free the entire Numeric object (consists of 11 to 13 * malloc'd objects. See UMFPACK_free_numeric.h for details. */ #include "umf_internal.h" #include "umf_free.h" GLOBAL void UMFPACK_free_numeric ( void **NumericHandle ) { NumericType *Numeric ; if (!NumericHandle) { return ; } Numeric = *((NumericType **) NumericHandle) ; if (!Numeric) { return ; } /* these 9 objects always exist */ (void) UMF_free ((void *) Numeric->D) ; (void) UMF_free ((void *) Numeric->Rperm) ; (void) UMF_free ((void *) Numeric->Cperm) ; (void) UMF_free ((void *) Numeric->Lpos) ; (void) UMF_free ((void *) Numeric->Lilen) ; (void) UMF_free ((void *) Numeric->Lip) ; (void) UMF_free ((void *) Numeric->Upos) ; (void) UMF_free ((void *) Numeric->Uilen) ; (void) UMF_free ((void *) Numeric->Uip) ; /* Rs does not exist if scaling was not performed */ (void) UMF_free ((void *) Numeric->Rs) ; /* Upattern can only exist for singular or rectangular matrices */ (void) UMF_free ((void *) Numeric->Upattern) ; /* these 2 objects always exist */ (void) UMF_free ((void *) Numeric->Memory) ; (void) UMF_free ((void *) Numeric) ; *NumericHandle = (void *) NULL ; }
32.368421
80
0.484011
ef9fc058f22ed67d983fff48b77519240984ea7a
5,658
c
C
addons/audio/sdl_audio.c
arganoid/allegro5
9de18401d51144071ee2943afdf7640e5d8e0287
[ "BSD-3-Clause" ]
null
null
null
addons/audio/sdl_audio.c
arganoid/allegro5
9de18401d51144071ee2943afdf7640e5d8e0287
[ "BSD-3-Clause" ]
1
2018-12-09T06:08:53.000Z
2018-12-09T06:08:53.000Z
addons/audio/sdl_audio.c
arganoid/allegro5
9de18401d51144071ee2943afdf7640e5d8e0287
[ "BSD-3-Clause" ]
2
2020-03-16T00:15:55.000Z
2021-12-23T17:50:41.000Z
#include "allegro5/allegro.h" #include "allegro5/internal/aintern_audio.h" #include "allegro5/platform/allegro_internal_sdl.h" ALLEGRO_DEBUG_CHANNEL("SDL") typedef struct SDL_VOICE { SDL_AudioDeviceID device; SDL_AudioSpec spec; ALLEGRO_VOICE *voice; bool is_playing; } SDL_VOICE; typedef struct SDL_RECORDER { SDL_AudioDeviceID device; SDL_AudioSpec spec; unsigned int fragment; } SDL_RECORDER; static void audio_callback(void *userdata, Uint8 *stream, int len) { // TODO: Allegro has those mysterious "non-streaming" samples, but I // can't figure out what their purpose is and how would I play them... SDL_VOICE *sv = userdata; ALLEGRO_SAMPLE_INSTANCE *instance = sv->voice->attached_stream; ALLEGRO_SAMPLE *sample = &instance->spl_data; unsigned int frames = sv->spec.samples; const void *data = _al_voice_update(sv->voice, sv->voice->mutex, &frames); if (data) { // FIXME: What is frames for? memcpy(stream, sample->buffer.ptr, len); } } static int sdl_open(void) { return 0; } static void sdl_close(void) { } static SDL_AudioFormat allegro_format_to_sdl(ALLEGRO_AUDIO_DEPTH d) { if (d == ALLEGRO_AUDIO_DEPTH_INT8) return AUDIO_S8; if (d == ALLEGRO_AUDIO_DEPTH_UINT8) return AUDIO_U8; if (d == ALLEGRO_AUDIO_DEPTH_INT16) return AUDIO_S16; if (d == ALLEGRO_AUDIO_DEPTH_UINT16) return AUDIO_U16; return AUDIO_F32; } static ALLEGRO_AUDIO_DEPTH sdl_format_to_allegro(SDL_AudioFormat d) { if (d == AUDIO_S8) return ALLEGRO_AUDIO_DEPTH_INT8; if (d == AUDIO_U8) return ALLEGRO_AUDIO_DEPTH_UINT8; if (d == AUDIO_S16) return ALLEGRO_AUDIO_DEPTH_INT16; if (d == AUDIO_U16) return ALLEGRO_AUDIO_DEPTH_UINT16; return ALLEGRO_AUDIO_DEPTH_FLOAT32; } static int sdl_allocate_voice(ALLEGRO_VOICE *voice) { SDL_VOICE *sv = al_malloc(sizeof *sv); SDL_AudioSpec want; memset(&want, 0, sizeof want); want.freq = voice->frequency; want.format = allegro_format_to_sdl(voice->depth); want.channels = al_get_channel_count(voice->chan_conf); // TODO: Should make this configurable somehow want.samples = 4096; want.callback = audio_callback; want.userdata = sv; sv->device = SDL_OpenAudioDevice(NULL, 0, &want, &sv->spec, SDL_AUDIO_ALLOW_FORMAT_CHANGE); voice->extra = sv; sv->voice = voice; // we allow format change above so need to update here voice->depth = sdl_format_to_allegro(sv->spec.format); return 0; } static void sdl_deallocate_voice(ALLEGRO_VOICE *voice) { SDL_VOICE *sv = voice->extra; SDL_CloseAudioDevice(sv->device); al_free(sv); } static int sdl_load_voice(ALLEGRO_VOICE *voice, const void *data) { (void)data; voice->attached_stream->pos = 0; return 0; } static void sdl_unload_voice(ALLEGRO_VOICE *voice) { (void) voice; } static int sdl_start_voice(ALLEGRO_VOICE *voice) { SDL_VOICE *sv = voice->extra; sv->is_playing = true; SDL_PauseAudioDevice(sv->device, 0); return 0; } static int sdl_stop_voice(ALLEGRO_VOICE *voice) { SDL_VOICE *sv = voice->extra; sv->is_playing = false; SDL_PauseAudioDevice(sv->device, 1); return 0; } static bool sdl_voice_is_playing(const ALLEGRO_VOICE *voice) { SDL_VOICE *sv = voice->extra; return sv->is_playing; } static unsigned int sdl_get_voice_position(const ALLEGRO_VOICE *voice) { return voice->attached_stream->pos; } static int sdl_set_voice_position(ALLEGRO_VOICE *voice, unsigned int pos) { voice->attached_stream->pos = pos; return 0; } static void recorder_callback(void *userdata, Uint8 *stream, int len) { ALLEGRO_AUDIO_RECORDER *r = (ALLEGRO_AUDIO_RECORDER *) userdata; SDL_RECORDER *sdl = (SDL_RECORDER *) r->extra; al_lock_mutex(r->mutex); if (!r->is_recording) { al_unlock_mutex(r->mutex); return; } while (len > 0) { int count = SDL_min(len, r->samples * r->sample_size); memcpy(r->fragments[sdl->fragment], stream, count); ALLEGRO_EVENT user_event; ALLEGRO_AUDIO_RECORDER_EVENT *e; user_event.user.type = ALLEGRO_EVENT_AUDIO_RECORDER_FRAGMENT; e = al_get_audio_recorder_event(&user_event); e->buffer = r->fragments[sdl->fragment]; e->samples = count / r->sample_size; al_emit_user_event(&r->source, &user_event, NULL); sdl->fragment++; if (sdl->fragment == r->fragment_count) { sdl->fragment = 0; } len -= count; } al_unlock_mutex(r->mutex); } static int sdl_allocate_recorder(ALLEGRO_AUDIO_RECORDER *r) { SDL_RECORDER *sdl; sdl = al_calloc(1, sizeof(*sdl)); if (!sdl) { ALLEGRO_ERROR("Unable to allocate memory for SDL_RECORDER.\n"); return 1; } SDL_AudioSpec want; memset(&want, 0, sizeof want); want.freq = r->frequency; want.format = allegro_format_to_sdl(r->depth); want.channels = al_get_channel_count(r->chan_conf); want.samples = r->samples; want.callback = recorder_callback; want.userdata = r; sdl->device = SDL_OpenAudioDevice(NULL, 1, &want, &sdl->spec, 0); sdl->fragment = 0; r->extra = sdl; SDL_PauseAudioDevice(sdl->device, 0); return 0; } static void sdl_deallocate_recorder(ALLEGRO_AUDIO_RECORDER *r) { SDL_RECORDER *sdl = (SDL_RECORDER *) r->extra; SDL_CloseAudioDevice(sdl->device); al_free(r->extra); } ALLEGRO_AUDIO_DRIVER _al_kcm_sdl_driver = { "SDL", sdl_open, sdl_close, sdl_allocate_voice, sdl_deallocate_voice, sdl_load_voice, sdl_unload_voice, sdl_start_voice, sdl_stop_voice, sdl_voice_is_playing, sdl_get_voice_position, sdl_set_voice_position, sdl_allocate_recorder, sdl_deallocate_recorder };
24.707424
77
0.707847
b49a420bcdcbbe71b509a983652d802705c03aad
344
h
C
NewTestDemo/Pods/Target Support Files/LeadFramework/LeadFramework-umbrella.h
shitaldalavi/LeadFramework
db8cfa9ec5793c6f3c53dbc302ad79e814db6e51
[ "MIT" ]
null
null
null
NewTestDemo/Pods/Target Support Files/LeadFramework/LeadFramework-umbrella.h
shitaldalavi/LeadFramework
db8cfa9ec5793c6f3c53dbc302ad79e814db6e51
[ "MIT" ]
null
null
null
NewTestDemo/Pods/Target Support Files/LeadFramework/LeadFramework-umbrella.h
shitaldalavi/LeadFramework
db8cfa9ec5793c6f3c53dbc302ad79e814db6e51
[ "MIT" ]
null
null
null
#ifdef __OBJC__ #import <UIKit/UIKit.h> #else #ifndef FOUNDATION_EXPORT #if defined(__cplusplus) #define FOUNDATION_EXPORT extern "C" #else #define FOUNDATION_EXPORT extern #endif #endif #endif #import "LeadFramework.h" FOUNDATION_EXPORT double LeadFrameworkVersionNumber; FOUNDATION_EXPORT const unsigned char LeadFrameworkVersionString[];
19.111111
67
0.825581
35a35c9c6e6b0760677cdeb129be0ea3c4ed3886
1,244
h
C
src/fwsc.h
jukkas/FeebleESPWSClient
9cac97561b6e7eebcdbde1c569553d9c0137ead4
[ "0BSD" ]
null
null
null
src/fwsc.h
jukkas/FeebleESPWSClient
9cac97561b6e7eebcdbde1c569553d9c0137ead4
[ "0BSD" ]
null
null
null
src/fwsc.h
jukkas/FeebleESPWSClient
9cac97561b6e7eebcdbde1c569553d9c0137ead4
[ "0BSD" ]
1
2021-07-27T23:39:59.000Z
2021-07-27T23:39:59.000Z
#pragma once #include <cstdint> #include <functional> #ifdef ESP8266 #include <ESP8266WiFi.h> #endif #include <WiFiClientSecure.h> #define FWSCBUFLEN 2048 enum class WSEvent { error, disconnected, connected, text, unsupported }; const unsigned long initialWsReconnectInterval = 60000; class Fwsc { private: uint8_t _buffer[FWSCBUFLEN] = {0}; // TODO: use buffer reserved by caller WiFiClientSecure _client; std::function<void(WSEvent type, uint8_t * payload)> callback = nullptr; void callCallback(WSEvent type, uint8_t * payload); int parse_ws_message(const uint8_t * data, int len); unsigned long wsLastDisconnect = 0; const char * _host; const char * _url; const char * _extraHeader = nullptr; uint16_t _port; public: void setCallback(std::function<void(WSEvent type, uint8_t * payload)> cb) { callback = cb; }; void setExtraHeader(const char * extraHeader) { _extraHeader = extraHeader; }; int connect(const char * host, uint16_t port = 443, const char * url = "/"); void disconnect(); void loop(void); bool sendtxt(const char * payload); bool isConnected = false; bool tryReconnect = true; unsigned long wsReconnectInterval = initialWsReconnectInterval; };
30.341463
97
0.713023
c303aa6e1d81c0b74b4f0d00b2e5f3eb59eabe54
2,612
h
C
src/MetaData/Value.h
ess-dmsc/kafka-to-nexus
4b34a67b329583fab3634c9c56d3afcd30aee65c
[ "BSD-2-Clause" ]
1
2020-08-13T06:50:04.000Z
2020-08-13T06:50:04.000Z
src/MetaData/Value.h
ess-dmsc/kafka-to-nexus
4b34a67b329583fab3634c9c56d3afcd30aee65c
[ "BSD-2-Clause" ]
507
2017-06-05T09:53:34.000Z
2022-03-28T16:52:33.000Z
src/MetaData/Value.h
ess-dmsc/kafka-to-nexus
4b34a67b329583fab3634c9c56d3afcd30aee65c
[ "BSD-2-Clause" ]
5
2019-03-15T13:32:54.000Z
2020-12-07T02:54:13.000Z
// SPDX-License-Identifier: BSD-2-Clause // // This code has been produced by the European Spallation Source // and its partner institutes under the BSD 2 Clause License. // // See LICENSE.md at the top level for license information. // // Screaming Udder! https://esss.se #pragma once #include "ValueInternal.h" #include <functional> #include <h5cpp/hdf5.hpp> #include <memory> #include <nlohmann/json.hpp> #include <string> namespace MetaData { class Tracker; class ValueBase { public: explicit ValueBase( std::shared_ptr<MetaDataInternal::ValueBaseInternal> ValuePtr) : ValueObj(ValuePtr) {} nlohmann::json getAsJSON() const { throwIfInvalid(); return ValueObj->getAsJSON(); } std::string getKey() const { throwIfInvalid(); return ValueObj->getName(); } bool isValid() const { return ValueObj != nullptr; } void throwIfInvalid() const { if (not isValid()) { throw std::runtime_error("Unable to set or get meta data value as it has " "not been initialised."); } } protected: auto getValuePtr() const { throwIfInvalid(); return ValueObj; } private: std::shared_ptr<MetaDataInternal::ValueBaseInternal> ValueObj{nullptr}; friend Tracker; }; template <class DataType> class Value : public ValueBase { public: Value() = default; Value(std::string const &Path, std::string const &Name, std::function<void(hdf5::node::Node, std::string, DataType)> HDF5Writer = {}) : ValueBase(std::make_shared<MetaDataInternal::ValueInternal<DataType>>( Path, Name, HDF5Writer)) {} Value(char const *const Path, std::string const &Name, std::function<void(hdf5::node::Node, std::string, DataType)> HDF5Writer = {}) : ValueBase(std::make_shared<MetaDataInternal::ValueInternal<DataType>>( Path, Name, HDF5Writer)) {} template <class NodeType> Value(NodeType const &Node, std::string const &Name, std::function<void(hdf5::node::Node, std::string, DataType)> HDF5Writer = {}) : ValueBase(std::make_shared<MetaDataInternal::ValueInternal<DataType>>( std::string(Node.link().path()), Name, HDF5Writer)) {} void setValue(DataType NewValue) { std::dynamic_pointer_cast<MetaDataInternal::ValueInternal<DataType>>( getValuePtr()) ->setValue(NewValue); } DataType getValue() const { return std::dynamic_pointer_cast<MetaDataInternal::ValueInternal<DataType>>( getValuePtr()) ->getValue(); } }; } // namespace MetaData
29.348315
80
0.656202
debc7f639cbb42a1f686a91e8128c99c40d5a533
1,399
h
C
lib/signalAnalysis/bioSignalGenerator.h
EngineeringLibrary/embeddedControlSystem
c6fb457139651e7694e93c143860451b1404f340
[ "MIT" ]
null
null
null
lib/signalAnalysis/bioSignalGenerator.h
EngineeringLibrary/embeddedControlSystem
c6fb457139651e7694e93c143860451b1404f340
[ "MIT" ]
2
2019-07-18T15:01:22.000Z
2019-07-18T15:06:28.000Z
lib/signalAnalysis/bioSignalGenerator.h
EngineeringLibrary/embeddedControlSystem
c6fb457139651e7694e93c143860451b1404f340
[ "MIT" ]
null
null
null
#ifndef BIOSIGNALGENERATOR_H #define BIOSIGNALGENERATOR_H #include <iostream> #include <time.h> #include "esp_system.h" #include "rom/ets_sys.h" #include "driver/ledc.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "map" namespace ElectroStimulation{ class bioSignalController { public: bioSignalController(){} void powerControllerInit(const gpio_num_t &pin, const uint32_t &freq, const ledc_channel_t &channel); void setPowerLevel(const double &powerLevel); void setOutputHandlerPin(const gpio_num_t &outputHandlerPin); gpio_num_t getOutputHandlerPin () const {return outputHandlerPin;} void addSignalBehavior(const std::string &signalBehaviorName, const double &signalBehavior); void removeSignalBehavior(const std::string &signalBehaviorName); double getSignalBehavior(const std::string &signalBehavior) const; private: ledc_channel_config_t ledc_channel; ledc_timer_config_t ledc_timer; gpio_num_t outputHandlerPin; std::map<std::string, double> signalBehaviorHandler; }; static void burstController(void*); static void normalController(void*); static void modulationController(void*); static void sd1Controller(void*); static void sd2Controller(void*); } #include "bioSignalGenerator.hpp" #endif // BIOSIGNALGENERATOR_H
31.088889
109
0.730522
721e25e373e1d165817dc05d7999d56599a10cb6
1,624
h
C
PodPractise/MGVideo.framework/Headers/MGAudioRecorder.h
jiajiguang/PodPractise
619f782ad81c73f8ccc944ee479ac3ed23362faa
[ "MIT" ]
null
null
null
PodPractise/MGVideo.framework/Headers/MGAudioRecorder.h
jiajiguang/PodPractise
619f782ad81c73f8ccc944ee479ac3ed23362faa
[ "MIT" ]
null
null
null
PodPractise/MGVideo.framework/Headers/MGAudioRecorder.h
jiajiguang/PodPractise
619f782ad81c73f8ccc944ee479ac3ed23362faa
[ "MIT" ]
null
null
null
/*! @header MGAudioRecorder.h @abstract MGVideo */ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "MGRecordDataModel.h" /** * 音频录制状态 */ typedef NS_ENUM(NSInteger, AudioRecorderState) { /** * 完成 */ AudioRecorderStateFinish = 0, /** * 正在录制 */ AudioRecorderStateRecording = 1 }; /*! @protocol @abstract 这个MGAudioRecorder类的一个protocol */ @protocol MGAudioRecorderDelegate <NSObject> @optional /*! @method @abstract 录制完成 @param audioPath 音频路径 */ - (void)audioRecorderFinish:(NSString *)audioPath; /*! @method @abstract 录制出错 */ - (void)audioRecorderError; /*! @method @abstract 录制状态 */ - (void)audioRecorderState:(AudioRecorderState )state; /*! @method @abstract 录制时长 @param duration 时长,毫秒 */ - (void)audioRecorderDuration:(int )duration; @end /*! @class @abstract 咪咕短视频音频录制类 */ @interface MGAudioRecorder : NSObject /*! @property @abstract 代理 */ @property (nonatomic, weak) id<MGAudioRecorderDelegate> delegate; /*! @method @abstract 开始录制 */ - (void)startRecorder; /*! @method @abstract 结束录制 */ - (void)stopRecorder; /*! @method @abstract 是否正在录制 */ - (BOOL)isRecording; /*! @method @abstract 设置配音数据 */ - (void)setDubbingData:(NSMutableArray <MGDubbingInfoModel *>*)audioArray; /*! @method @abstract 获得配音数据 */ - (NSMutableArray <MGDubbingInfoModel *>*)listDubbingData; /*! @method @abstract 设置配音操作数据 */ - (void)setOperateDubbingData:(NSMutableArray <MGDubbingInfoModel *>*)audioOperateArray; /*! @method @abstract 获得配音操作数据 */ - (NSMutableArray <MGDubbingInfoModel *>*)listOperateDubbingData; @end
14
88
0.682882
896b4b94c1d0d1af719a56f0bfaa7818404966d2
1,226
c
C
CreateTCPServerSocket.c
YuyaFuna/TinyShell
0c7afc16212bc4f4027f9894931003b46408e992
[ "MIT" ]
null
null
null
CreateTCPServerSocket.c
YuyaFuna/TinyShell
0c7afc16212bc4f4027f9894931003b46408e992
[ "MIT" ]
null
null
null
CreateTCPServerSocket.c
YuyaFuna/TinyShell
0c7afc16212bc4f4027f9894931003b46408e992
[ "MIT" ]
null
null
null
#include "Main.h" int CreateTCPServerSocket(unsigned short port) { int sock; /* socket to create */ struct sockaddr_in ServAddr; /* Local address */ /* Create socket for incoming connections */ if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) DieWithError("socket() failed"); #ifdef DEBUG printf("create server socket\n"); #endif /* Construct local address structure */ memset(&ServAddr, 0, sizeof(ServAddr)); /* Zero out structure */ ServAddr.sin_family = AF_INET; /* Internet address family */ ServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */ ServAddr.sin_port = htons(port); /* Local port */ /* Bind to the local address */ if (bind(sock, (struct sockaddr *)&ServAddr, sizeof(ServAddr)) < 0) DieWithError("bind() failed"); #ifdef DEBUG printf("bind server socket to addr\n"); printf("server IP %s\n", inet_ntoa(ServAddr.sin_addr)); #endif /* Mark the socket so it will listen for incoming connections */ if (listen(sock, MAXPENDING) < 0) DieWithError("listen() failed"); #ifdef DEBUG printf("listen...\n"); #endif return sock; }
30.65
79
0.62969
817978ade3a47855faa9f2e3e7814cd94661afc2
37,771
h
C
drivers/hal/fm/FM33LG0xx_HAL/FM33LG0xx_FL_Driver/Inc/fm33lg0xx_fl_pmu.h
flyghost/OneOS-V2.1.0
6fedab0558c07fe679d63ba1eb8ee9992c044d86
[ "Apache-2.0" ]
null
null
null
drivers/hal/fm/FM33LG0xx_HAL/FM33LG0xx_FL_Driver/Inc/fm33lg0xx_fl_pmu.h
flyghost/OneOS-V2.1.0
6fedab0558c07fe679d63ba1eb8ee9992c044d86
[ "Apache-2.0" ]
null
null
null
drivers/hal/fm/FM33LG0xx_HAL/FM33LG0xx_FL_Driver/Inc/fm33lg0xx_fl_pmu.h
flyghost/OneOS-V2.1.0
6fedab0558c07fe679d63ba1eb8ee9992c044d86
[ "Apache-2.0" ]
null
null
null
/** ******************************************************************************************************* * @file fm33lg0xx_fl_pmu.h * @author FMSH Application Team * @brief Head file of PMU FL Module ******************************************************************************************************* * @attention * * Copyright (c) [2019] [Fudan Microelectronics] * THIS SOFTWARE is licensed under the Mulan PSL v1. * can use this software according to the terms and conditions of the Mulan PSL v1. * You may obtain a copy of Mulan PSL v1 at: * http://license.coscl.org.cn/MulanPSL * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v1 for more details. * ******************************************************************************************************* */ /* Define to prevent recursive inclusion---------------------------------------------------------------*/ #ifndef __FM33LG0XX_FL_PMU_H #define __FM33LG0XX_FL_PMU_H #ifdef __cplusplus extern "C" { #endif /* Includes -------------------------------------------------------------------------------------------*/ #include "fm33lg0xx_fl.h" /** @addtogroup FM33LG0XX_FL_Driver * @{ */ /* Exported types -------------------------------------------------------------------------------------*/ /** @defgroup PMU_FL_ES_INIT PMU Exported Init structures * @{ */ /** * @brief FL PMU Init Sturcture definition */ typedef struct { /*! 低功耗模式配置 */ uint32_t powerMode; /*! 低功耗模式下内核电压降低与否 */ FL_FunState coreVoltageScaling; /*! 睡眠模式配置 */ uint32_t deepSleep; /*! 唤醒后的系统频率,仅对RCHF */ uint32_t wakeupFrequency; /*! 芯片LDO是否进入低功耗 */ uint32_t LDOLowPowerMode; /*! 额外唤醒延迟 */ uint32_t wakeupDelay; } FL_PMU_SleepInitTypeDef; /** * @} */ /* Exported constants ---------------------------------------------------------------------------------*/ /** @defgroup PMU_FL_Exported_Constants PMU Exported Constants * @{ */ #define PMU_CR_LDO_LPM_Pos (18U) #define PMU_CR_LDO_LPM_Msk (0x3U << PMU_CR_LDO_LPM_Pos) #define PMU_CR_LDO_LPM PMU_CR_LDO_LPM_Msk #define PMU_CR_LDO15EN_Pos (17U) #define PMU_CR_LDO15EN_Msk (0x1U << PMU_CR_LDO15EN_Pos) #define PMU_CR_LDO15EN PMU_CR_LDO15EN_Msk #define PMU_CR_LDO15EN_B_Pos (16U) #define PMU_CR_LDO15EN_B_Msk (0x1U << PMU_CR_LDO15EN_B_Pos) #define PMU_CR_LDO15EN_B PMU_CR_LDO15EN_B_Msk #define PMU_CR_WKFSEL_Pos (10U) #define PMU_CR_WKFSEL_Msk (0x3U << PMU_CR_WKFSEL_Pos) #define PMU_CR_WKFSEL PMU_CR_WKFSEL_Msk #define PMU_CR_SLPDP_Pos (9U) #define PMU_CR_SLPDP_Msk (0x1U << PMU_CR_SLPDP_Pos) #define PMU_CR_SLPDP PMU_CR_SLPDP_Msk #define PMU_CR_CVS_Pos (8U) #define PMU_CR_CVS_Msk (0x1U << PMU_CR_CVS_Pos) #define PMU_CR_CVS PMU_CR_CVS_Msk #define PMU_CR_PMOD_Pos (0U) #define PMU_CR_PMOD_Msk (0x3U << PMU_CR_PMOD_Pos) #define PMU_CR_PMOD PMU_CR_PMOD_Msk #define PMU_WKTR_VREFDLY_Pos (3U) #define PMU_WKTR_VREFDLY_Msk (0x1U << PMU_WKTR_VREFDLY_Pos) #define PMU_WKTR_VREFDLY PMU_WKTR_VREFDLY_Msk #define PMU_WKTR_STPCLR_Pos (2U) #define PMU_WKTR_STPCLR_Msk (0x1U << PMU_WKTR_STPCLR_Pos) #define PMU_WKTR_STPCLR PMU_WKTR_STPCLR_Msk #define PMU_WKTR_T1A_Pos (0U) #define PMU_WKTR_T1A_Msk (0x3U << PMU_WKTR_T1A_Pos) #define PMU_WKTR_T1A PMU_WKTR_T1A_Msk #define PMU_WKFR_ADCWKF_Pos (31U) #define PMU_WKFR_ADCWKF_Msk (0x1U << PMU_WKFR_ADCWKF_Pos) #define PMU_WKFR_ADCWKF PMU_WKFR_ADCWKF_Msk #define PMU_WKFR_UART1WKF_Pos (30U) #define PMU_WKFR_UART1WKF_Msk (0x1U << PMU_WKFR_UART1WKF_Pos) #define PMU_WKFR_UART1WKF PMU_WKFR_UART1WKF_Msk #define PMU_WKFR_UART0WKF_Pos (29U) #define PMU_WKFR_UART0WKF_Msk (0x1U << PMU_WKFR_UART0WKF_Pos) #define PMU_WKFR_UART0WKF PMU_WKFR_UART0WKF_Msk #define PMU_WKFR_RTCWKF_Pos (28U) #define PMU_WKFR_RTCWKF_Msk (0x1U << PMU_WKFR_RTCWKF_Pos) #define PMU_WKFR_RTCWKF PMU_WKFR_RTCWKF_Msk #define PMU_WKFR_SVDWKF_Pos (27U) #define PMU_WKFR_SVDWKF_Msk (0x1U << PMU_WKFR_SVDWKF_Pos) #define PMU_WKFR_SVDWKF PMU_WKFR_SVDWKF_Msk #define PMU_WKFR_LFDETWKF_Pos (26U) #define PMU_WKFR_LFDETWKF_Msk (0x1U << PMU_WKFR_LFDETWKF_Pos) #define PMU_WKFR_LFDETWKF PMU_WKFR_LFDETWKF_Msk #define PMU_WKFR_VREFWKF_Pos (25U) #define PMU_WKFR_VREFWKF_Msk (0x1U << PMU_WKFR_VREFWKF_Pos) #define PMU_WKFR_VREFWKF PMU_WKFR_VREFWKF_Msk #define PMU_WKFR_IOWKF_Pos (24U) #define PMU_WKFR_IOWKF_Msk (0x1U << PMU_WKFR_IOWKF_Pos) #define PMU_WKFR_IOWKF PMU_WKFR_IOWKF_Msk #define PMU_WKFR_IICWKF_Pos (23U) #define PMU_WKFR_IICWKF_Msk (0x1U << PMU_WKFR_IICWKF_Pos) #define PMU_WKFR_IICWKF PMU_WKFR_IICWKF_Msk #define PMU_WKFR_LPU2WKF_Pos (22U) #define PMU_WKFR_LPU2WKF_Msk (0x1U << PMU_WKFR_LPU2WKF_Pos) #define PMU_WKFR_LPU2WKF PMU_WKFR_LPU2WKF_Msk #define PMU_WKFR_LPU1WKF_Pos (21U) #define PMU_WKFR_LPU1WKF_Msk (0x1U << PMU_WKFR_LPU1WKF_Pos) #define PMU_WKFR_LPU1WKF PMU_WKFR_LPU1WKF_Msk #define PMU_WKFR_LPU0WKF_Pos (20U) #define PMU_WKFR_LPU0WKF_Msk (0x1U << PMU_WKFR_LPU0WKF_Pos) #define PMU_WKFR_LPU0WKF PMU_WKFR_LPU0WKF_Msk #define PMU_WKFR_COMP3WKF_Pos (18U) #define PMU_WKFR_COMP3WKF_Msk (0x1U << PMU_WKFR_COMP3WKF_Pos) #define PMU_WKFR_COMP3WKF PMU_WKFR_COMP3WKF_Msk #define PMU_WKFR_COMP2WKF_Pos (17U) #define PMU_WKFR_COMP2WKF_Msk (0x1U << PMU_WKFR_COMP2WKF_Pos) #define PMU_WKFR_COMP2WKF PMU_WKFR_COMP2WKF_Msk #define PMU_WKFR_COMP1WKF_Pos (16U) #define PMU_WKFR_COMP1WKF_Msk (0x1U << PMU_WKFR_COMP1WKF_Pos) #define PMU_WKFR_COMP1WKF PMU_WKFR_COMP1WKF_Msk #define PMU_WKFR_LPT32WKF_Pos (14U) #define PMU_WKFR_LPT32WKF_Msk (0x1U << PMU_WKFR_LPT32WKF_Pos) #define PMU_WKFR_LPT32WKF PMU_WKFR_LPT32WKF_Msk #define PMU_WKFR_LPT16WKF_Pos (13U) #define PMU_WKFR_LPT16WKF_Msk (0x1U << PMU_WKFR_LPT16WKF_Pos) #define PMU_WKFR_LPT16WKF PMU_WKFR_LPT16WKF_Msk #define PMU_WKFR_BST32WKF_Pos (12U) #define PMU_WKFR_BST32WKF_Msk (0x1U << PMU_WKFR_BST32WKF_Pos) #define PMU_WKFR_BST32WKF PMU_WKFR_BST32WKF_Msk #define PMU_WKFR_BST16WKF_Pos (11U) #define PMU_WKFR_BST16WKF_Msk (0x1U << PMU_WKFR_BST16WKF_Pos) #define PMU_WKFR_BST16WKF PMU_WKFR_BST16WKF_Msk #define PMU_WKFR_DBGWKF_Pos (10U) #define PMU_WKFR_DBGWKF_Msk (0x1U << PMU_WKFR_DBGWKF_Pos) #define PMU_WKFR_DBGWKF PMU_WKFR_DBGWKF_Msk #define PMU_WKFR_WKPXF_Pos (0U) #define PMU_WKFR_WKPXF_Msk (0x3ffU << PMU_WKFR_WKPXF_Pos) #define PMU_WKFR_WKPXF PMU_WKFR_WKPXF_Msk #define PMU_IER_LPACTIE_Pos (2U) #define PMU_IER_LPACTIE_Msk (0x1U << PMU_IER_LPACTIE_Pos) #define PMU_IER_LPACTIE PMU_IER_LPACTIE_Msk #define PMU_IER_SLPEIE_Pos (1U) #define PMU_IER_SLPEIE_Msk (0x1U << PMU_IER_SLPEIE_Pos) #define PMU_IER_SLPEIE PMU_IER_SLPEIE_Msk #define PMU_IER_LPREIE_Pos (0U) #define PMU_IER_LPREIE_Msk (0x1U << PMU_IER_LPREIE_Pos) #define PMU_IER_LPREIE PMU_IER_LPREIE_Msk #define PMU_ISR_LPACTIF_Pos (2U) #define PMU_ISR_LPACTIF_Msk (0x1U << PMU_ISR_LPACTIF_Pos) #define PMU_ISR_LPACTIF PMU_ISR_LPACTIF_Msk #define PMU_ISR_SLPEIF_Pos (1U) #define PMU_ISR_SLPEIF_Msk (0x1U << PMU_ISR_SLPEIF_Pos) #define PMU_ISR_SLPEIF PMU_ISR_SLPEIF_Msk #define PMU_ISR_LPREIF_Pos (0U) #define PMU_ISR_LPREIF_Msk (0x1U << PMU_ISR_LPREIF_Pos) #define PMU_ISR_LPREIF PMU_ISR_LPREIF_Msk #define FL_PMU_WAKEUP0_PIN (0x1U << 0U) #define FL_PMU_WAKEUP1_PIN (0x1U << 1U) #define FL_PMU_WAKEUP2_PIN (0x1U << 2U) #define FL_PMU_WAKEUP3_PIN (0x1U << 3U) #define FL_PMU_WAKEUP4_PIN (0x1U << 4U) #define FL_PMU_WAKEUP5_PIN (0x1U << 5U) #define FL_PMU_WAKEUP6_PIN (0x1U << 6U) #define FL_PMU_WAKEUP7_PIN (0x1U << 7U) #define FL_PMU_WAKEUP8_PIN (0x1U << 8U) #define FL_PMU_WAKEUP9_PIN (0x1U << 9U) #define FL_PMU_LDO_LPM_DISABLE (0x0U << PMU_CR_LDO_LPM_Pos) #define FL_PMU_LDO_LPM_ENABLE (0x2U << PMU_CR_LDO_LPM_Pos) #define FL_PMU_RCHF_WAKEUP_FREQ_8MHZ (0x0U << PMU_CR_WKFSEL_Pos) #define FL_PMU_RCHF_WAKEUP_FREQ_16MHZ (0x1U << PMU_CR_WKFSEL_Pos) #define FL_PMU_RCHF_WAKEUP_FREQ_24MHZ (0x2U << PMU_CR_WKFSEL_Pos) #define FL_PMU_SLEEP_MODE_DEEP (0x1U << PMU_CR_SLPDP_Pos) #define FL_PMU_SLEEP_MODE_NORMAL (0x0U << PMU_CR_SLPDP_Pos) #define FL_PMU_POWER_MODE_ACTIVE_OR_LPACTIVE (0x0U << PMU_CR_PMOD_Pos) #define FL_PMU_POWER_MODE_LPRUN_ONLY (0x1U << PMU_CR_PMOD_Pos) #define FL_PMU_POWER_MODE_SLEEP_OR_DEEPSLEEP (0x2U << PMU_CR_PMOD_Pos) #define FL_PMU_WAKEUP_DELAY_MODE_IMMEDIATE (0x0U << PMU_WKTR_VREFDLY_Pos) #define FL_PMU_WAKEUP_DELAY_MODE_WAIT_VREF1P2 (0x1U << PMU_WKTR_VREFDLY_Pos) #define FL_PMU_FLASH_STOP_CLEAR_MODE_ASYNCHRONOUS (0x0U << PMU_WKTR_STPCLR_Pos) #define FL_PMU_FLASH_STOP_CLEAR_MODE_SYNCHRONOUS (0x1U << PMU_WKTR_STPCLR_Pos) #define FL_PMU_WAKEUP_DELAY_0US (0x0U << PMU_WKTR_T1A_Pos) #define FL_PMU_WAKEUP_DELAY_2US (0x1U << PMU_WKTR_T1A_Pos) #define FL_PMU_WAKEUP_DELAY_4US (0x2U << PMU_WKTR_T1A_Pos) #define FL_PMU_WAKEUP_DELAY_8US (0x3U << PMU_WKTR_T1A_Pos) /** * @} */ /* Exported functions ---------------------------------------------------------------------------------*/ /** @defgroup PMU_FL_Exported_Functions PMU Exported Functions * @{ */ /** * @brief Set LDO Low Power Mode * @rmtoll CR LDO_LPM FL_PMU_SetLDOLowPowerMode * @param PMUx PMU instance * @param mode This parameter can be one of the following values: * @arg @ref FL_PMU_LDO_LPM_DISABLE * @arg @ref FL_PMU_LDO_LPM_ENABLE * @retval None */ __STATIC_INLINE void FL_PMU_SetLDOLowPowerMode(PMU_Type *PMUx, uint32_t mode) { MODIFY_REG(PMUx->CR, PMU_CR_LDO_LPM_Msk, mode); } /** * @brief Get LDO Low Power Mode Setting * @rmtoll CR LDO_LPM FL_PMU_GetLDOLowPowerMode * @param PMUx PMU instance * @retval Returned value can be one of the following values: * @arg @ref FL_PMU_LDO_LPM_DISABLE * @arg @ref FL_PMU_LDO_LPM_ENABLE */ __STATIC_INLINE uint32_t FL_PMU_GetLDOLowPowerMode(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->CR, PMU_CR_LDO_LPM_Msk)); } /** * @brief Get LDO15 Enable Status * @rmtoll CR LDO15EN FL_PMU_GetLDO15Status * @param PMUx PMU instance * @retval Returned value can be one of the following values: */ __STATIC_INLINE uint32_t FL_PMU_GetLDO15Status(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->CR, PMU_CR_LDO15EN_Msk)); } /** * @brief Get LDO15 Inverse check bit * @rmtoll CR LDO15EN_B FL_PMU_GetLDO15StatusInvert * @param PMUx PMU instance * @retval Returned value can be one of the following values: */ __STATIC_INLINE uint32_t FL_PMU_GetLDO15StatusInvert(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->CR, PMU_CR_LDO15EN_B_Msk)); } /** * @brief Set RCHF Frequency After Wakeup * @rmtoll CR WKFSEL FL_PMU_SetRCHFWakeupFrequency * @param PMUx PMU instance * @param Freq This parameter can be one of the following values: * @arg @ref FL_PMU_RCHF_WAKEUP_FREQ_8MHZ * @arg @ref FL_PMU_RCHF_WAKEUP_FREQ_16MHZ * @arg @ref FL_PMU_RCHF_WAKEUP_FREQ_24MHZ * @retval None */ __STATIC_INLINE void FL_PMU_SetRCHFWakeupFrequency(PMU_Type *PMUx, uint32_t Freq) { MODIFY_REG(PMUx->CR, PMU_CR_WKFSEL_Msk, Freq); } /** * @brief Get RCHF Frequency After Wakeup Setting * @rmtoll CR WKFSEL FL_PMU_GetRCHFWakeupFrequency * @param PMUx PMU instance * @retval Returned value can be one of the following values: * @arg @ref FL_PMU_RCHF_WAKEUP_FREQ_8MHZ * @arg @ref FL_PMU_RCHF_WAKEUP_FREQ_16MHZ * @arg @ref FL_PMU_RCHF_WAKEUP_FREQ_24MHZ */ __STATIC_INLINE uint32_t FL_PMU_GetRCHFWakeupFrequency(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->CR, PMU_CR_WKFSEL_Msk)); } /** * @brief Set Sleep Mode * @rmtoll CR SLPDP FL_PMU_SetSleepMode * @param PMUx PMU instance * @param mode This parameter can be one of the following values: * @arg @ref FL_PMU_SLEEP_MODE_DEEP * @arg @ref FL_PMU_SLEEP_MODE_NORMAL * @retval None */ __STATIC_INLINE void FL_PMU_SetSleepMode(PMU_Type *PMUx, uint32_t mode) { MODIFY_REG(PMUx->CR, PMU_CR_SLPDP_Msk, mode); } /** * @brief Get Sleep Mode Setting * @rmtoll CR SLPDP FL_PMU_GetSleepMode * @param PMUx PMU instance * @retval Returned value can be one of the following values: * @arg @ref FL_PMU_SLEEP_MODE_DEEP * @arg @ref FL_PMU_SLEEP_MODE_NORMAL */ __STATIC_INLINE uint32_t FL_PMU_GetSleepMode(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->CR, PMU_CR_SLPDP_Msk)); } /** * @brief Enable Core Voltage Scaling Under Low Power Mode * @rmtoll CR CVS FL_PMU_EnableCoreVoltageScaling * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_EnableCoreVoltageScaling(PMU_Type *PMUx) { SET_BIT(PMUx->CR, PMU_CR_CVS_Msk); } /** * @brief Get Core Voltage Scaling Under Low Power Mode Enable Status * @rmtoll CR CVS FL_PMU_IsEnabledCoreVoltageScaling * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsEnabledCoreVoltageScaling(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->CR, PMU_CR_CVS_Msk) == PMU_CR_CVS_Msk); } /** * @brief Disable Core Voltage Scaling Under Low Power Mode * @rmtoll CR CVS FL_PMU_DisableCoreVoltageScaling * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_DisableCoreVoltageScaling(PMU_Type *PMUx) { CLEAR_BIT(PMUx->CR, PMU_CR_CVS_Msk); } /** * @brief Set Low Power Mode * @rmtoll CR PMOD FL_PMU_SetLowPowerMode * @param PMUx PMU instance * @param mode This parameter can be one of the following values: * @arg @ref FL_PMU_POWER_MODE_ACTIVE_OR_LPACTIVE * @arg @ref FL_PMU_POWER_MODE_LPRUN_ONLY * @arg @ref FL_PMU_POWER_MODE_SLEEP_OR_DEEPSLEEP * @retval None */ __STATIC_INLINE void FL_PMU_SetLowPowerMode(PMU_Type *PMUx, uint32_t mode) { MODIFY_REG(PMUx->CR, PMU_CR_PMOD_Msk, mode); } /** * @brief Get Low Power Mode Setting * @rmtoll CR PMOD FL_PMU_GetLowPowerMode * @param PMUx PMU instance * @retval Returned value can be one of the following values: */ __STATIC_INLINE uint32_t FL_PMU_GetLowPowerMode(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->CR, PMU_CR_PMOD_Msk)); } /** * @brief Set VREF delay wakeup mode * @rmtoll WKTR VREFDLY FL_PMU_SetVREFWakeupDelayMode * @param PMUx PMU instance * @param VREFDelay This parameter can be one of the following values: * @arg @ref FL_PMU_WAKEUP_DELAY_MODE_IMMEDIATE * @arg @ref FL_PMU_WAKEUP_DELAY_MODE_WAIT_VREF1P2 * @retval None */ __STATIC_INLINE void FL_PMU_SetVREFWakeupDelayMode(PMU_Type *PMUx, uint32_t VREFDelay) { MODIFY_REG(PMUx->WKTR, PMU_WKTR_VREFDLY_Msk, VREFDelay); } /** * @brief Get VREF delay wakeup status * @rmtoll WKTR VREFDLY FL_PMU_GetVREFWakeupDelayMode * @param PMUx PMU instance * @retval Returned value can be one of the following values: * @arg @ref FL_PMU_WAKEUP_DELAY_MODE_IMMEDIATE * @arg @ref FL_PMU_WAKEUP_DELAY_MODE_WAIT_VREF1P2 */ __STATIC_INLINE uint32_t FL_PMU_GetVREFWakeupDelayMode(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKTR, PMU_WKTR_VREFDLY_Msk)); } /** * @brief Set Flash Stop Signal Clear Way * @rmtoll WKTR STPCLR FL_PMU_SetFlashStopSignalClearMode * @param PMUx PMU instance * @param config This parameter can be one of the following values: * @arg @ref FL_PMU_FLASH_STOP_CLEAR_MODE_ASYNCHRONOUS * @arg @ref FL_PMU_FLASH_STOP_CLEAR_MODE_SYNCHRONOUS * @retval None */ __STATIC_INLINE void FL_PMU_SetFlashStopSignalClearMode(PMU_Type *PMUx, uint32_t config) { MODIFY_REG(PMUx->WKTR, PMU_WKTR_STPCLR_Msk, config); } /** * @brief Get Flash Stop Signal Clear Way Setting * @rmtoll WKTR STPCLR FL_PMU_GetFlashStopSignalClearMode * @param PMUx PMU instance * @retval Returned value can be one of the following values: * @arg @ref FL_PMU_FLASH_STOP_CLEAR_MODE_ASYNCHRONOUS * @arg @ref FL_PMU_FLASH_STOP_CLEAR_MODE_SYNCHRONOUS */ __STATIC_INLINE uint32_t FL_PMU_GetFlashStopSignalClearMode(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKTR, PMU_WKTR_STPCLR_Msk)); } /** * @brief Set Extra Wakeup Delay Under Sleep/DeepSleep Mode * @rmtoll WKTR T1A FL_PMU_SetWakeupDelay * @param PMUx PMU instance * @param time This parameter can be one of the following values: * @arg @ref FL_PMU_WAKEUP_DELAY_0US * @arg @ref FL_PMU_WAKEUP_DELAY_2US * @arg @ref FL_PMU_WAKEUP_DELAY_4US * @arg @ref FL_PMU_WAKEUP_DELAY_8US * @retval None */ __STATIC_INLINE void FL_PMU_SetWakeupDelay(PMU_Type *PMUx, uint32_t time) { MODIFY_REG(PMUx->WKTR, PMU_WKTR_T1A_Msk, time); } /** * @brief Get Extra Wakeup Delay Under Sleep/DeepSleep Mode Setting * @rmtoll WKTR T1A FL_PMU_GetWakeupDelay * @param PMUx PMU instance * @retval Returned value can be one of the following values: * @arg @ref FL_PMU_WAKEUP_DELAY_0US * @arg @ref FL_PMU_WAKEUP_DELAY_2US * @arg @ref FL_PMU_WAKEUP_DELAY_4US * @arg @ref FL_PMU_WAKEUP_DELAY_8US */ __STATIC_INLINE uint32_t FL_PMU_GetWakeupDelay(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKTR, PMU_WKTR_T1A_Msk)); } /** * @brief Get ADC interrupt wakeup flag * @rmtoll WKFR ADCWKF FL_PMU_IsActiveFlag_WakeupADC * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupADC(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_ADCWKF_Msk) == (PMU_WKFR_ADCWKF_Msk)); } /** * @brief Get UART1 interrupt wakeup flag * @rmtoll WKFR UART1WKF FL_PMU_IsActiveFlag_WakeupUART1 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupUART1(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_UART1WKF_Msk) == (PMU_WKFR_UART1WKF_Msk)); } /** * @brief Get UART0 interrupt wakeup flag * @rmtoll WKFR UART0WKF FL_PMU_IsActiveFlag_WakeupUART0 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupUART0(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_UART0WKF_Msk) == (PMU_WKFR_UART0WKF_Msk)); } /** * @brief Get RTC interrupt wakeup flag * @rmtoll WKFR RTCWKF FL_PMU_IsActiveFlag_WakeupRTC * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupRTC(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_RTCWKF_Msk) == (PMU_WKFR_RTCWKF_Msk)); } /** * @brief Get SVD interrupt wakeup flag * @rmtoll WKFR SVDWKF FL_PMU_IsActiveFlag_WakeupSVD * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupSVD(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_SVDWKF_Msk) == (PMU_WKFR_SVDWKF_Msk)); } /** * @brief Get LFDET interrupt wakeup flag * @rmtoll WKFR LFDETWKF FL_PMU_IsActiveFlag_WakeupLFDET * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupLFDET(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_LFDETWKF_Msk) == (PMU_WKFR_LFDETWKF_Msk)); } /** * @brief Get VREF interrupt wakeup flag * @rmtoll WKFR VREFWKF FL_PMU_IsActiveFlag_WakeupVREF * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupVREF(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_VREFWKF_Msk) == (PMU_WKFR_VREFWKF_Msk)); } /** * @brief Get IO interrupt wakeup flag * @rmtoll WKFR IOWKF FL_PMU_IsActiveFlag_WakeupEXTI * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupEXTI(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_IOWKF_Msk) == (PMU_WKFR_IOWKF_Msk)); } /** * @brief Get I2C interrupt wakeup flag * @rmtoll WKFR IICWKF FL_PMU_IsActiveFlag_WakeupI2C * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupI2C(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_IICWKF_Msk) == (PMU_WKFR_IICWKF_Msk)); } /** * @brief Get LPUART2 interrupt wakeup flag * @rmtoll WKFR LPU2WKF FL_PMU_IsActiveFlag_WakeupLPUART2 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupLPUART2(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_LPU2WKF_Msk) == (PMU_WKFR_LPU2WKF_Msk)); } /** * @brief Get LPUART1 interrupt wakeup flag * @rmtoll WKFR LPU1WKF FL_PMU_IsActiveFlag_WakeupLPUART1 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupLPUART1(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_LPU1WKF_Msk) == (PMU_WKFR_LPU1WKF_Msk)); } /** * @brief Get LPUART0 interrupt wakeup flag * @rmtoll WKFR LPU0WKF FL_PMU_IsActiveFlag_WakeupLPUART0 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupLPUART0(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_LPU0WKF_Msk) == (PMU_WKFR_LPU0WKF_Msk)); } /** * @brief Get COMP3 interrrupt wakeup flag * @rmtoll WKFR COMP3WKF FL_PMU_IsActiveFlag_WakeupCOMP3 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupCOMP3(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_COMP3WKF_Msk) == (PMU_WKFR_COMP3WKF_Msk)); } /** * @brief Get COMP2 interrrupt wakeup flag * @rmtoll WKFR COMP2WKF FL_PMU_IsActiveFlag_WakeupCOMP2 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupCOMP2(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_COMP2WKF_Msk) == (PMU_WKFR_COMP2WKF_Msk)); } /** * @brief Get COMP1 interrrupt wakeup flag * @rmtoll WKFR COMP1WKF FL_PMU_IsActiveFlag_WakeupCOMP1 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupCOMP1(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_COMP1WKF_Msk) == (PMU_WKFR_COMP1WKF_Msk)); } /** * @brief Get LPTIM32 interrupt wakeup flag * @rmtoll WKFR LPT32WKF FL_PMU_IsActiveFlag_WakeupLPTIM32 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupLPTIM32(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_LPT32WKF_Msk) == (PMU_WKFR_LPT32WKF_Msk)); } /** * @brief Get LPTIM16 interrupt wakeup flag * @rmtoll WKFR LPT16WKF FL_PMU_IsActiveFlag_WakeupLPTIM16 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupLPTIM16(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_LPT16WKF_Msk) == (PMU_WKFR_LPT16WKF_Msk)); } /** * @brief Get BSTIM32 interrupt wakeup flag * @rmtoll WKFR BST32WKF FL_PMU_IsActiveFlag_WakeupBSTIM32 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupBSTIM32(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_BST32WKF_Msk) == (PMU_WKFR_BST32WKF_Msk)); } /** * @brief Get BSTIM16 interrupt wakeup flag * @rmtoll WKFR BST16WKF FL_PMU_IsActiveFlag_WakeupBSTIM16 * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupBSTIM16(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_BST16WKF_Msk) == (PMU_WKFR_BST16WKF_Msk)); } /** * @brief Get CPU Debugger wakeup flag * @rmtoll WKFR DBGWKF FL_PMU_IsActiveFlag_WakeupDBG * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupDBG(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->WKFR, PMU_WKFR_DBGWKF_Msk) == (PMU_WKFR_DBGWKF_Msk)); } /** * @brief Clear CPU Debugger wakeup flag * @rmtoll WKFR DBGWKF FL_PMU_ClearFlag_WakeupDBG * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_ClearFlag_WakeupDBG(PMU_Type *PMUx) { WRITE_REG(PMUx->WKFR, PMU_WKFR_DBGWKF_Msk); } /** * @brief Get pinx wakeup flag * @rmtoll WKFR WKPXF FL_PMU_IsActiveFlag_WakeupPIN * @param PMUx PMU instance * @param Pin This parameter can be one of the following values: * @arg @ref FL_PMU_WAKEUP0_PIN * @arg @ref FL_PMU_WAKEUP1_PIN * @arg @ref FL_PMU_WAKEUP2_PIN * @arg @ref FL_PMU_WAKEUP3_PIN * @arg @ref FL_PMU_WAKEUP4_PIN * @arg @ref FL_PMU_WAKEUP5_PIN * @arg @ref FL_PMU_WAKEUP6_PIN * @arg @ref FL_PMU_WAKEUP7_PIN * @arg @ref FL_PMU_WAKEUP8_PIN * @arg @ref FL_PMU_WAKEUP9_PIN * @retval Returned value can be one of the following values: */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_WakeupPIN(PMU_Type *PMUx, uint32_t Pin) { return (uint32_t)(READ_BIT(PMUx->WKFR, ((Pin & 0x3ff) << 0x0U)) == ((Pin & 0x3ff) << 0x0U)); } /** * @brief Clear pinx wakeup flag * @rmtoll WKFR WKPXF FL_PMU_ClearFlag_WakeupPIN * @param PMUx PMU instance * @param Pin This parameter can be one of the following values: * @arg @ref FL_PMU_WAKEUP0_PIN * @arg @ref FL_PMU_WAKEUP1_PIN * @arg @ref FL_PMU_WAKEUP2_PIN * @arg @ref FL_PMU_WAKEUP3_PIN * @arg @ref FL_PMU_WAKEUP4_PIN * @arg @ref FL_PMU_WAKEUP5_PIN * @arg @ref FL_PMU_WAKEUP6_PIN * @arg @ref FL_PMU_WAKEUP7_PIN * @arg @ref FL_PMU_WAKEUP8_PIN * @arg @ref FL_PMU_WAKEUP9_PIN * @retval None */ __STATIC_INLINE void FL_PMU_ClearFlag_WakeupPIN(PMU_Type *PMUx, uint32_t Pin) { WRITE_REG(PMUx->WKFR, ((Pin & 0x3ff) << 0x0U)); } /** * @brief LPActive error interrupt enable * @rmtoll IER LPACTIE FL_PMU_EnableIT_LPActiveError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_EnableIT_LPActiveError(PMU_Type *PMUx) { SET_BIT(PMUx->IER, PMU_IER_LPACTIE_Msk); } /** * @brief Get LPActive error interrupt enable status * @rmtoll IER LPACTIE FL_PMU_IsEnabledIT_LPActiveError * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsEnabledIT_LPActiveError(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->IER, PMU_IER_LPACTIE_Msk) == PMU_IER_LPACTIE_Msk); } /** * @brief LPActive error interrupt disable * @rmtoll IER LPACTIE FL_PMU_DisableIT_LPActiveError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_DisableIT_LPActiveError(PMU_Type *PMUx) { CLEAR_BIT(PMUx->IER, PMU_IER_LPACTIE_Msk); } /** * @brief Sleep error interrupt enable * @rmtoll IER SLPEIE FL_PMU_EnableIT_SleepError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_EnableIT_SleepError(PMU_Type *PMUx) { SET_BIT(PMUx->IER, PMU_IER_SLPEIE_Msk); } /** * @brief Get sleep error interrupt enable status * @rmtoll IER SLPEIE FL_PMU_IsEnabledIT_SleepError * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsEnabledIT_SleepError(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->IER, PMU_IER_SLPEIE_Msk) == PMU_IER_SLPEIE_Msk); } /** * @brief Sleep error interrupt disable * @rmtoll IER SLPEIE FL_PMU_DisableIT_SleepError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_DisableIT_SleepError(PMU_Type *PMUx) { CLEAR_BIT(PMUx->IER, PMU_IER_SLPEIE_Msk); } /** * @brief LPREIE error interrupt enable * @rmtoll IER LPREIE FL_PMU_EnableIT_LPRunError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_EnableIT_LPRunError(PMU_Type *PMUx) { SET_BIT(PMUx->IER, PMU_IER_LPREIE_Msk); } /** * @brief Get LPREIE error interrupt enable status * @rmtoll IER LPREIE FL_PMU_IsEnabledIT_LPRunError * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsEnabledIT_LPRunError(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->IER, PMU_IER_LPREIE_Msk) == PMU_IER_LPREIE_Msk); } /** * @brief LPREIE error interrupt disable * @rmtoll IER LPREIE FL_PMU_DisableIT_LPRunError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_DisableIT_LPRunError(PMU_Type *PMUx) { CLEAR_BIT(PMUx->IER, PMU_IER_LPREIE_Msk); } /** * @brief Get LPACTIF error interrupt flag * @rmtoll ISR LPACTIF FL_PMU_IsActiveFlag_LPActiveError * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_LPActiveError(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->ISR, PMU_ISR_LPACTIF_Msk) == (PMU_ISR_LPACTIF_Msk)); } /** * @brief Clear LPACTIF error interrupt flag * @rmtoll ISR LPACTIF FL_PMU_ClearFlag_LPActiveError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_ClearFlag_LPActiveError(PMU_Type *PMUx) { WRITE_REG(PMUx->ISR, PMU_ISR_LPACTIF_Msk); } /** * @brief Get SLEEP error interrupt flag * @rmtoll ISR SLPEIF FL_PMU_IsActiveFlag_SleepError * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_SleepError(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->ISR, PMU_ISR_SLPEIF_Msk) == (PMU_ISR_SLPEIF_Msk)); } /** * @brief Clear SLEEP error interrupt flag * @rmtoll ISR SLPEIF FL_PMU_ClearFlag_SleepError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_ClearFlag_SleepError(PMU_Type *PMUx) { WRITE_REG(PMUx->ISR, PMU_ISR_SLPEIF_Msk); } /** * @brief Get LPRUN error interrupt flag * @rmtoll ISR LPREIF FL_PMU_IsActiveFlag_LPRunError * @param PMUx PMU instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t FL_PMU_IsActiveFlag_LPRunError(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->ISR, PMU_ISR_LPREIF_Msk) == (PMU_ISR_LPREIF_Msk)); } /** * @brief Clear LPRUN error interrupt flag * @rmtoll ISR LPREIF FL_PMU_ClearFlag_LPRunError * @param PMUx PMU instance * @retval None */ __STATIC_INLINE void FL_PMU_ClearFlag_LPRunError(PMU_Type *PMUx) { WRITE_REG(PMUx->ISR, PMU_ISR_LPREIF_Msk); } /** * @brief Set ULPBG output VREF * @rmtoll ULPB_TR FL_PMU_WriteULPBGOutputTrim * @param PMUx PMU instance * @param trim * @retval None */ __STATIC_INLINE void FL_PMU_WriteULPBGOutputTrim(PMU_Type *PMUx, uint32_t trim) { MODIFY_REG(PMUx->ULPB_TR, (0x1fU << 0U), (trim << 0U)); } /** * @brief Get ULPBG output VREF * @rmtoll ULPB_TR FL_PMU_ReadULPBGOutputTrim * @param PMUx PMU instance * @retval */ __STATIC_INLINE uint32_t FL_PMU_ReadULPBGOutputTrim(PMU_Type *PMUx) { return (uint32_t)(READ_BIT(PMUx->ULPB_TR, (0x1fU << 0U)) >> 0U); } /** * @} */ /** @defgroup PMU_FL_EF_Init Initialization and de-initialization functions * @{ */ FL_ErrorStatus FL_PMU_Sleep_DeInit(PMU_Type *PMUx); FL_ErrorStatus FL_PMU_Sleep_Init(PMU_Type *PMUx, FL_PMU_SleepInitTypeDef *LPM_InitStruct); void FL_PMU_StructInit(FL_PMU_SleepInitTypeDef *LPM_InitStruct); /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __FM33LG0XX_FL_PMU_H*/ /*************************Py_Code_Generator Version: 0.1-0.14-0.1 @ 2020-10-20*************************/ /*************************(C) COPYRIGHT Fudan Microelectronics **** END OF FILE*************************/
37.434093
105
0.607874
edb73a534e33f395c2381865360ac6fea74d924e
153
h
C
src/vendor/mariadb-10.6.7/storage/columnstore/columnstore/dbcon/mysql/versionnumber.h
zettadb/zettalib
3d5f96dc9e3e4aa255f4e6105489758944d37cc4
[ "Apache-2.0" ]
null
null
null
src/vendor/mariadb-10.6.7/storage/columnstore/columnstore/dbcon/mysql/versionnumber.h
zettadb/zettalib
3d5f96dc9e3e4aa255f4e6105489758944d37cc4
[ "Apache-2.0" ]
null
null
null
src/vendor/mariadb-10.6.7/storage/columnstore/columnstore/dbcon/mysql/versionnumber.h
zettadb/zettalib
3d5f96dc9e3e4aa255f4e6105489758944d37cc4
[ "Apache-2.0" ]
2
2022-02-27T14:00:01.000Z
2022-03-31T06:24:22.000Z
#ifndef VERSIONNUMBER_H_ #define VERSIONNUMBER_H_ #include <string> const std::string idb_version("1.0.2"); const std::string idb_release("1"); #endif
17
39
0.75817
8e3b05c02e052c2b57ad016fb2ba6536e8509f56
3,628
h
C
libs/bluevk/include/vk_video/vulkan_video_codec_h264std_decode.h
andykit/filament
f4f9f331c0882db6b58d1ec5ea2bb42ae9baf1d4
[ "Apache-2.0" ]
13
2022-02-04T16:37:32.000Z
2022-03-23T04:23:55.000Z
libs/bluevk/include/vk_video/vulkan_video_codec_h264std_decode.h
andykit/filament
f4f9f331c0882db6b58d1ec5ea2bb42ae9baf1d4
[ "Apache-2.0" ]
3
2022-02-06T12:13:05.000Z
2022-03-05T01:15:16.000Z
libs/bluevk/include/vk_video/vulkan_video_codec_h264std_decode.h
andykit/filament
f4f9f331c0882db6b58d1ec5ea2bb42ae9baf1d4
[ "Apache-2.0" ]
6
2022-02-04T20:12:56.000Z
2022-03-31T17:35:08.000Z
#ifndef VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ #define VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 1 /* ** Copyright 2015-2022 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ /* ** This header is generated from the Khronos Vulkan XML API Registry. ** */ #ifdef __cplusplus extern "C" { #endif #define vulkan_video_codec_h264std_decode 1 #define STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE 2 #define STD_VIDEO_DECODE_H264_MVC_REF_LIST_SIZE 15 typedef enum StdVideoDecodeH264FieldOrderCount { STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_TOP = 0, STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_BOTTOM = 1, STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_INVALID = 0x7FFFFFFF, STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_MAX_ENUM = 0x7FFFFFFF } StdVideoDecodeH264FieldOrderCount; typedef struct StdVideoDecodeH264PictureInfoFlags { uint32_t field_pic_flag : 1; uint32_t is_intra : 1; uint32_t IdrPicFlag : 1; uint32_t bottom_field_flag : 1; uint32_t is_reference : 1; uint32_t complementary_field_pair : 1; } StdVideoDecodeH264PictureInfoFlags; typedef struct StdVideoDecodeH264PictureInfo { uint8_t seq_parameter_set_id; uint8_t pic_parameter_set_id; uint16_t reserved; uint16_t frame_num; uint16_t idr_pic_id; int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; StdVideoDecodeH264PictureInfoFlags flags; } StdVideoDecodeH264PictureInfo; typedef struct StdVideoDecodeH264ReferenceInfoFlags { uint32_t top_field_flag : 1; uint32_t bottom_field_flag : 1; uint32_t is_long_term : 1; uint32_t is_non_existing : 1; } StdVideoDecodeH264ReferenceInfoFlags; typedef struct StdVideoDecodeH264ReferenceInfo { uint16_t FrameNum; uint16_t reserved; int32_t PicOrderCnt[2]; StdVideoDecodeH264ReferenceInfoFlags flags; } StdVideoDecodeH264ReferenceInfo; typedef struct StdVideoDecodeH264MvcElementFlags { uint32_t non_idr : 1; uint32_t anchor_pic : 1; uint32_t inter_view : 1; } StdVideoDecodeH264MvcElementFlags; typedef struct StdVideoDecodeH264MvcElement { StdVideoDecodeH264MvcElementFlags flags; uint16_t viewOrderIndex; uint16_t viewId; uint16_t temporalId; uint16_t priorityId; uint16_t numOfAnchorRefsInL0; uint16_t viewIdOfAnchorRefsInL0[STD_VIDEO_DECODE_H264_MVC_REF_LIST_SIZE]; uint16_t numOfAnchorRefsInL1; uint16_t viewIdOfAnchorRefsInL1[STD_VIDEO_DECODE_H264_MVC_REF_LIST_SIZE]; uint16_t numOfNonAnchorRefsInL0; uint16_t viewIdOfNonAnchorRefsInL0[STD_VIDEO_DECODE_H264_MVC_REF_LIST_SIZE]; uint16_t numOfNonAnchorRefsInL1; uint16_t viewIdOfNonAnchorRefsInL1[STD_VIDEO_DECODE_H264_MVC_REF_LIST_SIZE]; } StdVideoDecodeH264MvcElement; typedef struct StdVideoDecodeH264Mvc { uint32_t viewId0; uint32_t mvcElementCount; StdVideoDecodeH264MvcElement* pMvcElements; } StdVideoDecodeH264Mvc; #ifdef __cplusplus } #endif #endif
36.646465
108
0.654079
b81080965b28cb2eed3868e899e56ea67cc8f4e3
1,167
c
C
lib/libc/stdio/funopen.c
weiss/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
114
2015-01-18T22:55:52.000Z
2022-02-17T10:45:02.000Z
lib/libc/stdio/funopen.c
JamesLinus/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
null
null
null
lib/libc/stdio/funopen.c
JamesLinus/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
29
2015-11-03T22:05:22.000Z
2022-02-08T15:36:37.000Z
/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * %sccs.include.redist.c% */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)funopen.c 8.1 (Berkeley) 06/04/93"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> #include <errno.h> #include "local.h" FILE * funopen(cookie, readfn, writefn, seekfn, closefn) const void *cookie; int (*readfn)(), (*writefn)(); #if __STDC__ fpos_t (*seekfn)(void *cookie, fpos_t off, int whence); #else fpos_t (*seekfn)(); #endif int (*closefn)(); { register FILE *fp; int flags; if (readfn == NULL) { if (writefn == NULL) { /* illegal */ errno = EINVAL; return (NULL); } else flags = __SWR; /* write only */ } else { if (writefn == NULL) flags = __SRD; /* read only */ else flags = __SRW; /* read-write */ } if ((fp = __sfp()) == NULL) return (NULL); fp->_flags = flags; fp->_file = -1; fp->_cookie = (void *)cookie; fp->_read = readfn; fp->_write = writefn; fp->_seek = seekfn; fp->_close = closefn; return (fp); }
20.839286
69
0.61868
1182bc772bbf6bed10ee0c3e6cdc91da4d6afe2a
8,799
h
C
linux_packages/source/hypre-2.9.0b/src/babel/bHYPREClient-P/bHYPRE_StructMatrix_Module.h
pangkeji/warp3d
8b273b337e557f734298940a63291697cd561d02
[ "NCSA" ]
75
2015-07-06T18:14:20.000Z
2022-01-24T02:54:32.000Z
linux_packages/source/hypre-2.9.0b/src/babel/bHYPREClient-P/bHYPRE_StructMatrix_Module.h
pangkeji/warp3d
8b273b337e557f734298940a63291697cd561d02
[ "NCSA" ]
15
2017-04-07T18:09:58.000Z
2022-02-28T01:48:33.000Z
linux_packages/source/hypre-2.9.0b/src/babel/bHYPREClient-P/bHYPRE_StructMatrix_Module.h
pangkeji/warp3d
8b273b337e557f734298940a63291697cd561d02
[ "NCSA" ]
41
2015-05-24T23:24:54.000Z
2021-12-13T22:07:45.000Z
/* * File: bHYPRE_StructMatrix_Module.h * Symbol: bHYPRE.StructMatrix-v1.0.0 * Symbol Type: class * Babel Version: 1.0.4 * Description: expose a constructor for the Python wrapper * * WARNING: Automatically generated; only changes within splicers preserved * */ /* * THIS CODE IS AUTOMATICALLY GENERATED BY THE BABEL * COMPILER. DO NOT EDIT THIS! * * External clients need an entry point to wrap a pointer * to an instance of bHYPRE.StructMatrix. * This header files defines two methods that such clients * will need. * bHYPRE_StructMatrix__import * This should be called in the client's init * module method. * bHYPRE_StructMatrix__wrap * This will wrap an IOR in a Python object. */ #ifndef included_bHYPRE_StructMatrix_MODULE #define included_bHYPRE_StructMatrix_MODULE #include <Python.h> #include "sidlType.h" #ifdef HAVE_PTHREAD #include <pthread.h> #endif /* HAVE_PTHREAD */ #ifdef __cplusplus extern "C" { #endif struct sidl__array; /* Forward declaration of IOR structure */ struct bHYPRE_StructMatrix__object; struct bHYPRE_StructMatrix__array; struct sidl_BaseInterface__object; #define bHYPRE_StructMatrix__wrap_NUM 0 #define bHYPRE_StructMatrix__wrap_RETURN PyObject * #define bHYPRE_StructMatrix__wrap_PROTO (struct bHYPRE_StructMatrix__object *sidlobj) #define bHYPRE_StructMatrix__convert_NUM 1 #define bHYPRE_StructMatrix__convert_RETURN int #define bHYPRE_StructMatrix__convert_PROTO (PyObject *obj, struct bHYPRE_StructMatrix__object **sidlobj) #define bHYPRE_StructMatrix__convert_python_array_NUM 2 #define bHYPRE_StructMatrix__convert_python_array_RETURN int #define bHYPRE_StructMatrix__convert_python_array_PROTO (PyObject *obj, struct bHYPRE_StructMatrix__array **sidlarray) #define bHYPRE_StructMatrix__convert_sidl_array_NUM 3 #define bHYPRE_StructMatrix__convert_sidl_array_RETURN PyObject * #define bHYPRE_StructMatrix__convert_sidl_array_PROTO (struct sidl__array *sidlarray) #define bHYPRE_StructMatrix__weakRef_NUM 4 #define bHYPRE_StructMatrix__weakRef_RETURN PyObject * #define bHYPRE_StructMatrix__weakRef_PROTO (struct bHYPRE_StructMatrix__object *sidlobj) #define bHYPRE_StructMatrix_deref_NUM 5 #define bHYPRE_StructMatrix_deref_RETURN void #define bHYPRE_StructMatrix_deref_PROTO (struct bHYPRE_StructMatrix__object *sidlobj) #define bHYPRE_StructMatrix__newRef_NUM 6 #define bHYPRE_StructMatrix__newRef_RETURN PyObject * #define bHYPRE_StructMatrix__newRef_PROTO (struct bHYPRE_StructMatrix__object *sidlobj) #define bHYPRE_StructMatrix__addRef_NUM 7 #define bHYPRE_StructMatrix__addRef_RETURN void #define bHYPRE_StructMatrix__addRef_PROTO (struct bHYPRE_StructMatrix__object *sidlobj) #define bHYPRE_StructMatrix_PyType_NUM 8 #define bHYPRE_StructMatrix_PyType_RETURN PyTypeObject * #define bHYPRE_StructMatrix_PyType_PROTO (void) #define bHYPRE_StructMatrix__connectI_NUM 9 #define bHYPRE_StructMatrix__connectI_RETURN struct bHYPRE_StructMatrix__object* #define bHYPRE_StructMatrix__connectI_PROTO (const char* url, sidl_bool ar, struct sidl_BaseInterface__object ** _ex) #define bHYPRE_StructMatrix__rmicast_NUM 10 #define bHYPRE_StructMatrix__rmicast_RETURN struct bHYPRE_StructMatrix__object* #define bHYPRE_StructMatrix__rmicast_PROTO (void* bi, struct sidl_BaseInterface__object ** _ex) #define bHYPRE_StructMatrix__API_NUM 11 #ifdef bHYPRE_StructMatrix_INTERNAL #define bHYPRE_StructMatrix__import() ; /* * This declaration is not for clients. */ static bHYPRE_StructMatrix__wrap_RETURN bHYPRE_StructMatrix__wrap bHYPRE_StructMatrix__wrap_PROTO; static bHYPRE_StructMatrix__convert_RETURN bHYPRE_StructMatrix__convert bHYPRE_StructMatrix__convert_PROTO; static bHYPRE_StructMatrix__convert_python_array_RETURN bHYPRE_StructMatrix__convert_python_array bHYPRE_StructMatrix__convert_python_array_PROTO; static bHYPRE_StructMatrix__convert_sidl_array_RETURN bHYPRE_StructMatrix__convert_sidl_array bHYPRE_StructMatrix__convert_sidl_array_PROTO; static bHYPRE_StructMatrix__weakRef_RETURN bHYPRE_StructMatrix__weakRef bHYPRE_StructMatrix__weakRef_PROTO; static bHYPRE_StructMatrix_deref_RETURN bHYPRE_StructMatrix_deref bHYPRE_StructMatrix_deref_PROTO; static bHYPRE_StructMatrix__newRef_RETURN bHYPRE_StructMatrix__newRef bHYPRE_StructMatrix__newRef_PROTO; static bHYPRE_StructMatrix__addRef_RETURN bHYPRE_StructMatrix__addRef bHYPRE_StructMatrix__addRef_PROTO; static bHYPRE_StructMatrix_PyType_RETURN bHYPRE_StructMatrix_PyType bHYPRE_StructMatrix_PyType_PROTO; #else static void **bHYPRE_StructMatrix__API = NULL; #define bHYPRE_StructMatrix__wrap \ (*((bHYPRE_StructMatrix__wrap_RETURN (*) \ bHYPRE_StructMatrix__wrap_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__wrap_NUM]))) #define bHYPRE_StructMatrix__convert \ (*((bHYPRE_StructMatrix__convert_RETURN (*) \ bHYPRE_StructMatrix__convert_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__convert_NUM]))) #define bHYPRE_StructMatrix__convert_python_array \ (*((bHYPRE_StructMatrix__convert_python_array_RETURN (*) \ bHYPRE_StructMatrix__convert_python_array_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__convert_python_array_NUM]))) #define bHYPRE_StructMatrix__convert_sidl_array \ (*((bHYPRE_StructMatrix__convert_sidl_array_RETURN (*) \ bHYPRE_StructMatrix__convert_sidl_array_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__convert_sidl_array_NUM]))) #define bHYPRE_StructMatrix__weakRef \ (*((bHYPRE_StructMatrix__weakRef_RETURN (*) \ bHYPRE_StructMatrix__weakRef_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__weakRef_NUM]))) #define bHYPRE_StructMatrix_deref \ (*((bHYPRE_StructMatrix_deref_RETURN (*) \ bHYPRE_StructMatrix_deref_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix_deref_NUM]))) #define bHYPRE_StructMatrix__newRef \ (*((bHYPRE_StructMatrix__newRef_RETURN (*) \ bHYPRE_StructMatrix__newRef_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__newRef_NUM]))) #define bHYPRE_StructMatrix__addRef \ (*((bHYPRE_StructMatrix__addRef_RETURN (*) \ bHYPRE_StructMatrix__addRef_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__addRef_NUM]))) #define bHYPRE_StructMatrix_PyType \ (*((bHYPRE_StructMatrix_PyType_RETURN (*) \ bHYPRE_StructMatrix_PyType_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix_PyType_NUM]))) #define bHYPRE_StructMatrix__connectI \ (*((bHYPRE_StructMatrix__connectI_RETURN (*) \ bHYPRE_StructMatrix__connectI_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__connectI_NUM]))) #define bHYPRE_StructMatrix__rmicast \ (*((bHYPRE_StructMatrix__rmicast_RETURN (*) \ bHYPRE_StructMatrix__rmicast_PROTO) \ (bHYPRE_StructMatrix__API \ [bHYPRE_StructMatrix__rmicast_NUM]))) #ifdef HAVE_PTHREAD #define bHYPRE_StructMatrix__import() \ { \ pthread_mutex_t __sidl_pyapi_mutex = PTHREAD_MUTEX_INITIALIZER; \ pthread_mutex_lock(&__sidl_pyapi_mutex); \ if (!bHYPRE_StructMatrix__API) { \ PyObject *module = PyImport_ImportModule("bHYPRE.StructMatrix"); \ if (module != NULL) { \ PyObject *module_dict = PyModule_GetDict(module); \ PyObject *c_api_object = \ PyDict_GetItemString(module_dict, "_C_API"); \ if (c_api_object && PyCObject_Check(c_api_object)) { \ bHYPRE_StructMatrix__API = \ (void **)PyCObject_AsVoidPtr(c_api_object); \ } \ else { fprintf(stderr, "babel: bHYPRE_StructMatrix__import failed to lookup _C_API (%p %p %s).\n", c_api_object, c_api_object ? c_api_object->ob_type : NULL, c_api_object ? c_api_object->ob_type->tp_name : ""); }\ Py_DECREF(module); \ } else { fprintf(stderr, "babel: bHYPRE_StructMatrix__import failed to import its module.\n"); }\ }\ pthread_mutex_unlock(&__sidl_pyapi_mutex); \ pthread_mutex_destroy(&__sidl_pyapi_mutex); \ } #else /* !HAVE_PTHREAD */ #define bHYPRE_StructMatrix__import() \ if (!bHYPRE_StructMatrix__API) { \ PyObject *module = PyImport_ImportModule("bHYPRE.StructMatrix"); \ if (module != NULL) { \ PyObject *module_dict = PyModule_GetDict(module); \ PyObject *c_api_object = \ PyDict_GetItemString(module_dict, "_C_API"); \ if (c_api_object && PyCObject_Check(c_api_object)) { \ bHYPRE_StructMatrix__API = \ (void **)PyCObject_AsVoidPtr(c_api_object); \ } \ else { fprintf(stderr, "babel: bHYPRE_StructMatrix__import failed to lookup _C_API (%p %p %s).\n", c_api_object, c_api_object ? c_api_object->ob_type : NULL, c_api_object ? c_api_object->ob_type->tp_name : ""); }\ Py_DECREF(module); \ } else { fprintf(stderr, "babel: bHYPRE_StructMatrix__import failed to import its module.\n"); }\ } #endif /* HAVE_PTHREAD */ #endif #ifdef __cplusplus } #endif #endif
34.505882
219
0.80941
e649aac95f02f84392488f408f2d91bf7b10ceee
4,214
c
C
src/libxpeccy/z80/z80.c
Pulfer/Xpeccy
3b9826813a2371a00dd83380b773fc82a6be1c0f
[ "MIT" ]
null
null
null
src/libxpeccy/z80/z80.c
Pulfer/Xpeccy
3b9826813a2371a00dd83380b773fc82a6be1c0f
[ "MIT" ]
null
null
null
src/libxpeccy/z80/z80.c
Pulfer/Xpeccy
3b9826813a2371a00dd83380b773fc82a6be1c0f
[ "MIT" ]
null
null
null
#include <stdlib.h> #include "z80.h" #include "z80macros.h" #include "z80tables.c" extern opCode npTab[256]; extern opCode ddTab[256]; extern opCode fdTab[256]; extern opCode cbTab[256]; extern opCode edTab[256]; #include "z80nop.c" #include "z80ed.c" #include "z80ddcb.c" #include "z80fdcb.c" #include "z80dd.c" #include "z80fd.c" #include "z80cb.c" Z80CPU* cpuCreate(cbmr fmr, cbmw fmw, cbir fir, cbiw fiw, cbirq frq, void* dt) { Z80CPU* cpu = (Z80CPU*)malloc(sizeof(Z80CPU)); cpu->data = dt; cpu->mrd = fmr; cpu->mwr = fmw; cpu->ird = fir; cpu->iwr = fiw; cpu->irq = frq; cpu->halt = 0; cpu->resPV = 0; cpu->noint = 0; cpu->imode = 0; return cpu; } void cpuDestroy(Z80CPU* cpu) { free(cpu); } void cpuReset(Z80CPU* cpu) { cpu->pc = 0; cpu->iff1 = 0; cpu->iff2 = 0; cpu->imode = 0; cpu->af = cpu->bc = cpu->de = cpu->hl = 0xffff; cpu->af_ = cpu->bc_ = cpu->de_ = cpu->hl_ = 0xffff; cpu->ix = cpu->iy = 0xffff; cpu->sp = 0xffff; cpu->i = cpu->r = cpu->r7 = 0; } int cpuExec(Z80CPU* cpu) { cpu->t = 0; cpu->noint = 0; cpu->opTab = npTab; do { cpu->op = &cpu->opTab[cpu->mrd(cpu->pc++,1,cpu->data)]; cpu->r++; cpu->t += cpu->op->t; cpu->op->exec(cpu); } while (cpu->op->flag & 1); return cpu->t; } int cpuINT(Z80CPU* cpu) { if (!cpu->iff1 || cpu->noint) return 0; cpu->iff1 = 0; cpu->iff2 = 0; if (cpu->halt) { cpu->pc++; cpu->halt = 0; } if (cpu->resPV) { cpu->f &= ~FP; cpu->resPV = 0; } cpu->opTab = npTab; switch(cpu->imode) { case 0: cpu->t = 2; cpu->op = &cpu->opTab[cpu->irq(cpu->data)]; cpu->r++; cpu->t += cpu->op->t; // +5 (RST38 fetch) cpu->op->exec(cpu); // +3 +3 execution. 13 total while (cpu->op->flag & 1) { cpu->op = &cpu->opTab[cpu->mrd(cpu->pc++,1,cpu->data)]; cpu->r++; cpu->t += cpu->op->t; cpu->op->exec(cpu); } break; case 1: cpu->r++; cpu->t = 2 + 5; // 2 extra + 5 on RST38 fetch nprFF(cpu); // +3 +3 execution. 13 total break; case 2: cpu->r++; cpu->t = 7; PUSH(cpu->hpc,cpu->lpc); // +3 (10) +3 (13) cpu->lptr = cpu->irq(cpu->data); // int vector (FF) cpu->hptr = cpu->i; cpu->lpc = MEMRD(cpu->mptr++,3); // +3 (16) cpu->hpc = MEMRD(cpu->mptr,3); // +3 (19) cpu->mptr = cpu->pc; break; } return cpu->t; } int cpuNMI(Z80CPU* cpu) { if (cpu->noint) return 0; cpu->r++; cpu->iff1 = 0; cpu->t = 5; PUSH(cpu->hpc,cpu->lpc); cpu->pc = 0x0066; cpu->mptr = cpu->pc; return cpu->t; // always 11 } // disasm const char halfByte[] = "0123456789ABCDEF"; int cpuDisasm(unsigned short adr,char* buf, cbdmr mrd, void* data) { unsigned char op; unsigned char tmp = 0; unsigned char dtl; unsigned char dth; unsigned short dtw; int res = 0; opCode* opc; opCode* opt = npTab; do { op = mrd(adr++,data); res++; opc = &opt[op]; if (opc->flag & 1) { opt = opc->tab; if ((opt == ddcbTab) || (opt == fdcbTab)) { tmp = mrd(adr++,data); res++; } } } while (opc->flag & 1); const char* src = opc->mnem; while (*src != 0) { if (*src == ':') { src++; op = *(src++); switch(op) { case '1': // byte = (adr) dtl = mrd(adr++,data); res++; *(buf++) = halfByte[dtl >> 4]; *(buf++) = halfByte[dtl & 0x0f]; break; case '2': // word = (adr,adr+1) dtl = mrd(adr++,data); dth = mrd(adr++,data); res += 2; *(buf++) = halfByte[dth >> 4]; *(buf++) = halfByte[dth & 0x0f]; *(buf++) = halfByte[dtl >> 4]; *(buf++) = halfByte[dtl & 0x0f]; break; case '3': // word = adr + [e = (adr)] dtl = mrd(adr++,data); res++; dtw = adr + (signed char)dtl; *(buf++) = halfByte[(dtw >> 12) & 0x0f]; *(buf++) = halfByte[(dtw >> 8) & 0x0f]; *(buf++) = halfByte[(dtw >> 4) & 0x0f]; *(buf++) = halfByte[dtw & 0x0f]; break; case '4': // signed byte e = (adr) tmp = mrd(adr++,data); res++; case '5': // signed byte e = tmp if (tmp < 0x80) { *(buf++) = '+'; } else { *(buf++) = '-'; tmp = (0xff - tmp) + 1; } *(buf++) = halfByte[tmp >> 4]; *(buf++) = halfByte[tmp & 0x0f]; break; } } else { *(buf++) = *(src++); } } *buf = 0; return res; }
21.282828
80
0.516611
e649b0b273b11d6826f531ecc7d4a373f80c6512
3,524
h
C
main/main.h
d51x/esp-iot-rgb
a88abaa434e4f3f9a780b4ed7d8741f41f31e1ae
[ "MIT" ]
null
null
null
main/main.h
d51x/esp-iot-rgb
a88abaa434e4f3f9a780b4ed7d8741f41f31e1ae
[ "MIT" ]
null
null
null
main/main.h
d51x/esp-iot-rgb
a88abaa434e4f3f9a780b4ed7d8741f41f31e1ae
[ "MIT" ]
null
null
null
#pragma once #ifndef __MAIN_H__ #define __MAIN_H__ #include <stdio.h> #include <string.h> #include <stdlib.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/portmacro.h" #include "esp_system.h" #include "esp_spi_flash.h" #include "nvs.h" #include "nvs_flash.h" #ifdef CONFIG_COMPONENT_DEBUG #include "iot_debug.h" #endif #include "wifi.h" #include "wifi_http.h" #include "mqtt_cl.h" #include "mqtt_cl_http.h" #include "ota_http.h" #include "sntp.h" #include "httpd.h" #include "http_page.h" #include "esp_log.h" #include "utils.h" #include "user.h" #ifdef CONFIG_COMPONENT_I2C #include "i2c_http.h" #endif #ifdef CONFIG_COMPONENT_RELAY #include "relay.h" #include "relay_mqtt.h" #ifdef CONFIG_RELAY_HTTP #include "relay_http.h" #endif #endif #ifdef CONFIG_COMPONENT_IR_RECV #include "irrcv.h" #ifdef CONFIG_IR_RECV_HTTP #include "irrcv_http.h" #endif #endif #ifdef CONFIG_SENSOR_SHT21 #include "sht21.h" #include "sht21_http.h" #include "sht21_mqtt.h" #endif #ifdef CONFIG_COMPONENT_PCF8574 #include "pcf8574.h" #endif #ifdef CONFIG_COMPONENT_LCD2004 #include "lcd2004.h" #ifdef CONFIG_COMPONENT_LCD2004_HTTP #include "lcd2004_http.h" #endif #endif #ifdef CONFIG_COMPONENT_MCP23017 #include "mcp23017.h" #include "mcp23017_mqtt.h" #ifdef CONFIG_MCP23017_HTTP #include "mcp23017_http.h" #endif #endif #ifdef CONFIG_LED_CONTROLLER #include "ledcontrol.h" #include "ledcontrol_mqtt.h" #ifdef CONFIG_LED_CONTROL_HTTP #include "ledcontrol_http.h" #endif #endif #ifdef CONFIG_RGB_CONTROLLER #include "rgbcontrol.h" #include "rgbcontrol_mqtt.h" #ifdef CONFIG_RGB_CONTROLLER_HTTP #include "rgbcontrol_http.h" #endif #ifdef CONFIG_RGB_EFFECTS #include "effects.h" #ifdef RGB_EFFECTS_HTTP #endif #endif #endif #ifdef CONFIG_SENSOR_PZEM004_T #include "pzem004t.h" #include "pzem004t_mqtt.h" #ifdef CONFIG_SENSOR_PZEM004_T_WEB #include "pzem004t_http.h" #endif #endif #ifdef CONFIG_SENSORS_GET #include "sensors.h" #include "sensors_http.h" #endif #ifdef CONFIG_SENSOR_MQTT #include "mqtt_sub.h" #endif //======================== variable definitions =================================== extern httpd_handle_t http_server; extern void sntp_start(); #ifdef CONFIG_COMPONENT_IR_RECV irrcv_handle_t ir_rx; #endif #ifdef CONFIG_COMPONENT_RELAY relay_handle_t relay_h; //relay_handle_t relay_red_h; //relay_handle_t relay_blue_h; //relay_handle_t relay_green_h; #endif #ifdef CONFIG_COMPONENT_MCP23017 mcp23017_handle_t mcp23017_h; #endif #ifdef CONFIG_COMPONENT_PCF8574 pcf8574_handle_t pcf8574_h; #endif #ifdef CONFIG_LED_CONTROLLER #define LED_CHANNELS_COUNT CONFIG_LED_CHANNELS_COUNT #if LED_CHANNELS_COUNT > 0 ledcontrol_channel_t *ch[LED_CHANNELS_COUNT]; #endif ledcontrol_t *ledc_h; ledcontrol_t *ledc; #ifdef CONFIG_RGB_CONTROLLER rgbcontrol_t *rgb_ledc; #ifdef CONFIG_RGB_EFFECTS effects_t* effects; #endif #endif #endif extern void sntp_start(); void initialize_modules(); void initialize_modules_mqtt(); void initialize_modules_http(httpd_handle_t _server); #endif
19.797753
84
0.672815
508608776ecb54e9d9f330bbc56990bafddc2746
12,054
h
C
src/audio_analyzer/multiband_histogram.h
nankasuisui/phaselimiter
dd155676a3750d4977b8248d52fc77f5c28d1906
[ "MIT" ]
12
2021-07-07T14:37:20.000Z
2022-03-07T16:43:47.000Z
src/audio_analyzer/multiband_histogram.h
nankasuisui/phaselimiter
dd155676a3750d4977b8248d52fc77f5c28d1906
[ "MIT" ]
null
null
null
src/audio_analyzer/multiband_histogram.h
nankasuisui/phaselimiter
dd155676a3750d4977b8248d52fc77f5c28d1906
[ "MIT" ]
3
2021-04-03T13:36:02.000Z
2021-12-28T20:21:10.000Z
#ifndef BAKUAGE_AUDIO_ANALYZER_MULTIBAND_HISTOGRAM_H_ #define BAKUAGE_AUDIO_ANALYZER_MULTIBAND_HISTOGRAM_H_ #include <algorithm> #include <vector> #include <functional> #include "bakuage/dft.h" #include "bakuage/memory.h" #include "bakuage/loudness_filter.h" #include "bakuage/ms_compressor_filter.h" #include "bakuage/utils.h" namespace audio_analyzer { template <typename Float> class Band { public: Float low_freq; Float high_freq; // ver 1 Float loudness; Float loudness_range; Float mid_to_side_loudness; Float mid_to_side_loudness_range; //std::vector<int> histogram; //std::vector<int> mid_to_side_histogram; // ver 2 Float mid_mean; Float side_mean; }; template <typename Float> std::vector<Band<Float>> CreateBandsByErb(int sample_rate, Float erb_scale) { std::vector<Band<Float>> bands; Float prev_freq = 0; while (1) { Float next_freq = prev_freq + erb_scale * bakuage::GlasbergErb(prev_freq); // 最後が短いときはスキップ if (next_freq >= sample_rate / 2) { if ((sample_rate / 2 - prev_freq) / (next_freq - prev_freq) < 0.5) { break; } } Band<Float> band = { 0 }; band.low_freq = prev_freq; band.high_freq = next_freq; bands.push_back(band); if (next_freq >= sample_rate / 2) { break; } prev_freq = next_freq; } return bands; } template <typename Float> Float Mean(const std::vector<Float> &v) { double sum = 0; for (int i = 0; i < v.size(); i++) { sum += v[i]; } return sum / (1e-37 + v.size()); } // ラウドネス規格: BS.1770 // Loudness Range http://www.abma-bvam.be/PDF/EBU_PLOUD/EBU_tech3342.pdf // http://jp.music-group.com/TCE/Tech/LRA.pdf // block_sec = 3, shift_sec = 2, relative_threshold_db = -20 // CompressorFilterのAnalyzeでやる方法は正確だけど遅い // 遅いとユーザー体験が悪くなるし、実験のイテレーションも悪くなる // だから、STFTを使った解析をする。 // BS.1770を少し拡張した感じ(bandが一つのときにBS.1770と等価になるようにする <- 窓関数かけないとダメだ) template <typename Float> void CalculateMultibandLoudness(const Float *input, const int channels, const int samples, const int sample_freq, const Float block_sec, const Float shift_sec, const Float relative_threshold_db, Band<Float> *bands, const int band_count, int *block_samples) { using namespace bakuage; // 400ms block int width = (int)(sample_freq * block_sec); // nearest samples int shift = (int)(sample_freq * shift_sec); std::vector<Float> filtered(channels * samples); std::vector<LoudnessFilter<double>> filters; for (int i = 0; i < channels; i++) { LoudnessFilter<double> filter(sample_freq); for (int j = 0; j < samples; j++) { int k = channels * j + i; filtered[k] = filter.Clock(input[k]); } } std::vector<std::vector<Float>> blocks(band_count); std::vector<std::vector<Float>> mid_to_side_blocks(band_count); const int spec_len = width / 2 + 1; float *fft_input = (float *)bakuage::AlignedMalloc(sizeof(float) * width); std::vector<std::complex<float> *> fft_outputs(channels); for (int ch = 0; ch < channels; ch++) { fft_outputs[ch] = (std::complex<float> *)bakuage::AlignedMalloc(sizeof(std::complex<float>) * spec_len); } bakuage::RealDft<float> dft(width); // FFTの正規化も行う (sqrt(hanning)窓) std::vector<float> window(width); for (int i = 0; i < width; i++) { window[i] = std::sqrt(0.5 - 0.5 * std::cos(2.0 * M_PI * i / width)) / std::sqrt(width); } int pos = 0; // 規格では最後のブロックは使わないけど、 // 使ったほうが実用的なので使う while (pos < samples) { int end = std::min<int>(pos + width, samples); // FFT for (int ch = 0; ch < channels; ch++) { for (int i = 0; i < width; i++) { fft_input[i] = pos + i < end ? filtered[channels * (pos + i) + ch] * window[i] : 0; } dft.Forward(fft_input, (float *)fft_outputs[ch]); } // binをbandに振り分けていく for (int band_index = 0; band_index < band_count; band_index++) { int low_bin_index = std::floor(width * bands[band_index].low_freq / sample_freq); int high_bin_index = std::min<int>(std::floor(width * bands[band_index].high_freq / sample_freq), spec_len); // total double sum = 0; for (int ch = 0; ch < channels; ch++) { for (int i = low_bin_index; i < high_bin_index; i++) { sum += std::norm(fft_outputs[ch][i]); } } double z = -0.691 + 10 * std::log10(1e-37 + sum / (0.5 * width)); // 0.5は窓関数の分 blocks[band_index].push_back(z); // -70 <-> [-70, -69) /*int index = std::floor(z) + 70; if (0 <= index && index < histo.size()) { histo[index]++; }*/ // mid to side if (channels == 2) { double mid_sum = 0; double side_sum = 0; for (int i = low_bin_index; i < high_bin_index; i++) { mid_sum += std::norm(fft_outputs[0][i] + fft_outputs[1][i]); side_sum += std::norm(fft_outputs[0][i] - fft_outputs[1][i]); } z = 10 * std::log10(1e-37 + side_sum / (1e-37 + mid_sum)); mid_to_side_blocks[band_index].push_back(z); } } // 75% overlap pos += shift; } for (int band_index = 0; band_index < band_count; band_index++) { for (int calc_index = 0; calc_index < 2; calc_index++) { const auto &band_blocks = calc_index == 0 ? blocks[band_index] : mid_to_side_blocks[band_index]; double threshold = -70; for (int k = 0; k < 2; k++) { double count = 0; double sum = 0; for (double z : band_blocks) { if (z < threshold) continue; count++; sum += z; } double mean = sum / (1e-37 + count); if (k == 0) { threshold = mean + relative_threshold_db; } else if (k == 1) { if (calc_index == 0) { bands[band_index].loudness = mean; } else { bands[band_index].mid_to_side_loudness = mean; } } } // loudness range std::vector<Float> sorted_blocks; for (double z : band_blocks) { if (z < threshold) continue; sorted_blocks.push_back(z); } std::sort(sorted_blocks.begin(), sorted_blocks.end()); double q10 = 0; for (int i = 0; i < sorted_blocks.size(); i++) { if (10 * sorted_blocks.size() <= 100 * i) { q10 = sorted_blocks[i]; break; } } double q95 = 0; for (int i = 0; i < sorted_blocks.size(); i++) { if (95 * sorted_blocks.size() <= 100 * i) { q95 = sorted_blocks[i]; break; } } if (calc_index == 0) { bands[band_index].loudness_range = q95 - q10; } else { bands[band_index].mid_to_side_loudness_range = q95 - q10; } } } if (block_samples) { *block_samples = width; } bakuage::AlignedFree(fft_input); for (int ch = 0; ch < channels; ch++) { bakuage::AlignedFree(fft_outputs[ch]); } } // stereo only template <typename Float> void CalculateMultibandLoudness2(const Float *input, const int channels, const int samples, const int sample_freq, const Float block_sec, const Float shift_sec, const Float relative_threshold_db, Band<Float> *bands, const int band_count, std::vector<std::vector<Float>> *covariance, int *block_samples) { using namespace bakuage; assert(channels == 2); // 400ms block int width = (int)(sample_freq * block_sec); // nearest samples int shift = (int)(sample_freq * shift_sec); std::vector<Float> filtered(channels * samples); std::vector<LoudnessFilter<double>> filters; for (int i = 0; i < channels; i++) { LoudnessFilter<double> filter(sample_freq); for (int j = 0; j < samples; j++) { int k = channels * j + i; filtered[k] = filter.Clock(input[k]); } } const int spec_len = width / 2 + 1; float *fft_input = (float *)bakuage::AlignedMalloc(sizeof(float) * width); std::vector<std::complex<float> *> fft_outputs(channels); for (int ch = 0; ch < channels; ch++) { fft_outputs[ch] = (std::complex<float> *)bakuage::AlignedMalloc(sizeof(std::complex<float>) * spec_len); } bakuage::RealDft<float> dft(width); // FFTの正規化も行う (sqrt(hanning)窓) std::vector<float> window(width); for (int i = 0; i < width; i++) { window[i] = std::sqrt(0.5 - 0.5 * std::cos(2.0 * M_PI * i / width)) / std::sqrt(width); } int pos = 0; std::vector<std::vector<Float>> mid_blocks(band_count); std::vector<std::vector<Float>> side_blocks(band_count); // 規格では最後のブロックは使わないけど、 // 使ったほうが実用的なので使う while (pos < samples) { int end = std::min<int>(pos + width, samples); // FFT for (int ch = 0; ch < channels; ch++) { for (int i = 0; i < width; i++) { fft_input[i] = pos + i < end ? filtered[channels * (pos + i) + ch] * window[i] : 0; } dft.Forward(fft_input, (float *)fft_outputs[ch]); } // binをbandに振り分けていく for (int band_index = 0; band_index < band_count; band_index++) { int low_bin_index = std::floor(width * bands[band_index].low_freq / sample_freq); int high_bin_index = std::min<int>(std::floor(width * bands[band_index].high_freq / sample_freq), spec_len); // mid double sum = 0; for (int i = low_bin_index; i < high_bin_index; i++) { sum += std::norm(fft_outputs[0][i] + fft_outputs[1][i]) ; } mid_blocks[band_index].push_back(10 * std::log10(1e-7//1e-37 + sum / (0.5 * width))); // side sum = 0; for (int i = low_bin_index; i < high_bin_index; i++) { sum += std::norm(fft_outputs[0][i] - fft_outputs[1][i]); } side_blocks[band_index].push_back(10 * std::log10(1e-7//1e-37 + sum / (0.5 * width))); } // 75% overlap pos += shift; } // calculate mean std::vector<Float> mid_threshold(band_count); std::vector<Float> side_threshold(band_count); for (int band_index = 0; band_index < band_count; band_index++) { for (int calc_index = 0; calc_index < 2; calc_index++) { const auto &band_blocks = calc_index == 0 ? mid_blocks[band_index] : side_blocks[band_index]; double threshold = -1e10;//-70; for (int k = 0; k < 2; k++) { double count = 0; double sum = 0; for (double z : band_blocks) { const bool valid = z >= threshold; count += valid; sum += valid * z; } double mean = sum / (1e-37 + count); if (k == 0) { threshold = mean + relative_threshold_db; if (calc_index == 0) { mid_threshold[band_index] = threshold; } else { side_threshold[band_index] = threshold; } } else if (k == 1) { if (calc_index == 0) { bands[band_index].mid_mean = mean; } else { bands[band_index].side_mean = mean; } } } } } // calculate covariance covariance->clear(); for (int i = 0; i < 2 * band_count; i++) { covariance->emplace_back(std::vector<Float>(2 * band_count)); } for (int band_index1 = 0; band_index1 < band_count; band_index1++) { for (int is_side1 = 0; is_side1 < 2; is_side1++) { for (int band_index2 = 0; band_index2 < band_count; band_index2++) { for (int is_side2 = 0; is_side2 < 2; is_side2++) { int row = 2 * band_index1 + is_side1; int col = 2 * band_index2 + is_side2; const double mean1 = is_side1 ? bands[band_index1].side_mean : bands[band_index1].mid_mean; const double mean2 = is_side2 ? bands[band_index2].side_mean : bands[band_index2].mid_mean; const double threshold1 = is_side1 ? side_threshold[band_index1] : mid_threshold[band_index1]; const double threshold2 = is_side2 ? side_threshold[band_index2] : mid_threshold[band_index2]; const auto &band_blocks1 = is_side1 ? side_blocks[band_index1] : mid_blocks[band_index1]; const auto &band_blocks2 = is_side2 ? side_blocks[band_index2] : mid_blocks[band_index2]; double v = 0; double c = 0; for (int i = 0; i < band_blocks1.size(); i++) { const double x1 = band_blocks1[i]; const double x2 = band_blocks2[i]; const bool valid = (x1 >= threshold1) & (x2 >= threshold2); // not && instead & for performance v += valid * (x1 - mean1) * (x2 - mean2); c += valid; } (*covariance)[row][col] += v / (1e-37 + c); } } } } if (block_samples) { *block_samples = width; } bakuage::AlignedFree(fft_input); for (int ch = 0; ch < channels; ch++) { bakuage::AlignedFree(fft_outputs[ch]); } } } #endif
29.762963
119
0.623942
da35d5472791a95f9ef7f795997b309e5af87e1d
485
c
C
test/programs/simple/switch-tests/brokenSwitch.c
GnKonkort/cpachecker
d79a358c2d89ca4b5d58b36859efcf8c320a737b
[ "Apache-2.0" ]
16
2015-01-19T15:52:14.000Z
2015-11-30T14:12:31.000Z
test/programs/simple/switch-tests/brokenSwitch.c
teodorov/cpachecker
16e37b76c5b9e3d203992c6c7bf96b64da6fbae1
[ "Apache-2.0" ]
5
2022-02-15T03:55:13.000Z
2022-02-28T03:59:20.000Z
test/programs/simple/switch-tests/brokenSwitch.c
teodorov/cpachecker
16e37b76c5b9e3d203992c6c7bf96b64da6fbae1
[ "Apache-2.0" ]
18
2015-02-17T19:22:41.000Z
2015-11-24T09:12:39.000Z
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 void main() { int N = 5; int a[N]; int i; switch(2) { case 0: for(i=0; i < N; ++i) { a[i] = i;} break; case 1: for(i=(N-1); i >= 0; --i) a[i] = N-1-i; break; case 2: for(i=0; i < N; ++i) a[i] = i; break; } }
15.645161
74
0.558763
fbc80a7d30cb80ff811b5ec90df4d11f1b017e65
11,503
h
C
lib/dotconf.h
johntconklin/monitor-core
f8aff2b11c6e2ffb3654dad58d786612669bc836
[ "BSD-3-Clause" ]
346
2015-01-06T14:19:48.000Z
2022-03-27T07:15:09.000Z
lib/dotconf.h
johntconklin/monitor-core
f8aff2b11c6e2ffb3654dad58d786612669bc836
[ "BSD-3-Clause" ]
98
2015-01-14T18:17:53.000Z
2022-03-20T00:22:46.000Z
lib/dotconf.h
johntconklin/monitor-core
f8aff2b11c6e2ffb3654dad58d786612669bc836
[ "BSD-3-Clause" ]
157
2015-01-20T16:26:30.000Z
2022-03-10T06:02:09.000Z
#ifndef DOTCONF_H #define DOTCONF_H #ifdef __cplusplus extern "C" { #endif /* stdio.h should be included by the application - as the manual page says */ #ifndef _STDIO_H #include <stdio.h> /* needed for FILE* */ #endif #ifdef WIN32 # ifndef R_OK #define R_OK 0 # endif #endif /* some buffersize definitions */ #define CFG_BUFSIZE 4096 /* max length of one line */ #define CFG_MAX_OPTION 32 /* max length of any option name */ #define CFG_MAX_VALUE 4064 /* max length of any options value */ #define CFG_MAX_FILENAME 256 /* max length of a filename */ #define CFG_VALUES 16 /* max # of arguments an option takes */ #define CFG_INCLUDEPATH_ENV "DC_INCLUDEPATH" #define WILDCARDS "*?" /* list of supported wild-card characters */ /* constants for type of option */ #define ARG_TOGGLE 0 /* TOGGLE on,off; yes,no; 1, 0; */ #define ARG_INT 1 /* callback wants an integer */ #define ARG_STR 2 /* callback expects a \0 terminated str */ #define ARG_LIST 3 /* wants list of strings */ #define ARG_NAME 4 /* wants option name plus ARG_LIST stuff */ #define ARG_RAW 5 /* wants raw argument data */ #define ARG_NONE 6 /* does not expect ANY args */ #define CTX_ALL 0 /* context: option can be used anywhere */ /* for convenience of terminating the dotconf_options list */ #define LAST_OPTION { "", 0, NULL, NULL } #define LAST_CONTEXT_OPTION { "", 0, NULL, NULL, 0 } #define DOTCONF_CB(__name) const char *__name(command_t *cmd, \ context_t *ctx) #define FUNC_ERRORHANDLER(_name) int _name(configfile_t * configfile, \ int type, long dc_errno, const char *msg) /* some flags that change the runtime behaviour of dotconf */ #define NONE 0 #define CASE_INSENSITIVE 1<<0 /* match option names case insensitive */ #define DONT_SUBSTITUTE 1<<1 /* do not call substitute_env after read_arg */ #define NO_INLINE_COMMENTS 1<<2 /* do not allow inline comments */ #define DUPLICATE_OPTION_NAMES 1<<3 /* allow for duplicate option names */ /* syslog style errors as suggested by Sander Steffann <sander@steffann.nl> */ #ifdef HAVE_SYSLOG #include <syslog.h> #define DCLOG_EMERG LOG_EMERG /* system is unusable */ #define DCLOG_ALERT LOG_ALERT /* action must be taken immediately */ #define DCLOG_CRIT LOG_CRIT /* critical conditions */ #define DCLOG_ERR LOG_ERR /* error conditions */ #define DCLOG_WARNING LOG_WARNING /* warning conditions */ #define DCLOG_NOTICE LOG_NOTICE /* normal but significant condition */ #define DCLOG_INFO LOG_INFO /* informational */ #define DCLOG_DEBUG LOG_DEBUG /* debug-level messages */ #define DCLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */ #else /* HAVE_SYSLOG */ #define DCLOG_EMERG 0 /* system is unusable */ #define DCLOG_ALERT 1 /* action must be taken immediately */ #define DCLOG_CRIT 2 /* critical conditions */ #define DCLOG_ERR 3 /* error conditions */ #define DCLOG_WARNING 4 /* warning conditions */ #define DCLOG_NOTICE 5 /* normal but significant condition */ #define DCLOG_INFO 6 /* informational */ #define DCLOG_DEBUG 7 /* debug-level messages */ #define DCLOG_LEVELMASK 7 /* mask off the level value */ #endif /* HAVE_SYSLOG */ /* callback types for dotconf_callback */ /* error constants */ #define ERR_NOERROR 0x0000 #define ERR_PARSE_ERROR 0x0001 #define ERR_UNKNOWN_OPTION 0x0002 #define ERR_WRONG_ARG_COUNT 0x0003 #define ERR_INCLUDE_ERROR 0x0004 #define ERR_NOACCESS 0x0005 #define ERR_USER 0x1000 /* base for userdefined errno's */ /* i needed this to check an ARG_LIST entry if it's toggled in one of my apps; maybe you do too */ #define CFG_TOGGLED(_val) ( (_val[0] == 'Y' \ || _val[0] == 'y') \ || (_val[0] == '1') \ || ((_val[0] == 'o' \ || _val[0] == 'O') \ && (_val[1] == 'n' \ || _val[1] == 'N'))) enum callback_types { ERROR_HANDLER = 1, CONTEXT_CHECKER }; typedef enum callback_types callback_types; typedef struct configfile_t configfile_t; typedef struct configoption_t configoption_t; typedef struct configoption_t ConfigOption; typedef struct command_t command_t; typedef void context_t; typedef void info_t; typedef const char *(*dotconf_callback_t)(command_t *, context_t *); typedef int (*dotconf_errorhandler_t)(configfile_t *, int, unsigned long, const char *); typedef const char *(*dotconf_contextchecker_t)(command_t *, unsigned long); struct configfile_t { /* ------ the fields in configfile_t are provided to the app via command_t's ; READ ONLY! --- */ FILE *stream; char eof; /* end of file reached ? */ size_t size; /* file size; cached on-demand for here-documents */ context_t *context; configoption_t const **config_options; int config_option_count; /* ------ misc read-only fields ------------------------------------------------------------- */ char *filename; /* name of file this option was found in */ unsigned long line; /* line number we're currently at */ unsigned long flags; /* runtime flags given to dotconf_open */ char *includepath; /* ------ some callbacks for interactivity -------------------------------------------------- */ dotconf_errorhandler_t errorhandler; dotconf_contextchecker_t contextchecker; int (*cmp_func)(const char *, const char *, size_t); }; struct configoption_t { const char *name; /* name of configuration option */ int type; /* for possible values, see above */ dotconf_callback_t callback; /* callback function */ info_t *info; /* additional info for multi-option callbacks */ unsigned long context; /* context sensitivity flags */ }; struct command_t { const char *name; /* name of the command */ configoption_t *option; /* the option as given in the app; READ ONLY */ /* ------ argument data filled in for each line / command ----------------------------------- */ struct { long value; /* ARG_INT, ARG_TOGGLE */ char *str; /* ARG_STR */ char **list; /* ARG_LIST */ } data; int arg_count; /* number of arguments (in data.list) */ /* ------ misc context information ---------------------------------------------------------- */ configfile_t *configfile; context_t *context; }; /* ------ dotconf_create() - create the configfile_t needed for further dot.conf fun ------------ */ configfile_t *dotconf_create(char *, const configoption_t *, context_t *, unsigned long); /* ------ dotconf_cleanup() - tidy up behind dotconf_create and the parser dust ----------------- */ void dotconf_cleanup(configfile_t *configfile); /* ------ dotconf_command_loop() - iterate through each line of file and handle the commands ---- */ int dotconf_command_loop(configfile_t *configfile); /* ------ dotconf_command_loop_until_error() - like continue_line but return on the first error - */ const char *dotconf_command_loop_until_error(configfile_t *configfile); /* ------ dotconf_continue_line() - check if line continuation is to be handled ----------------- */ int dotconf_continue_line(char *buffer, size_t length); /* ------ dotconf_get_next_line() - read in the next line of the configfile_t ------------------- */ int dotconf_get_next_line(char *buffer, size_t bufsize, configfile_t *configfile); /* ------ dotconf_get_here_document() - read the here document until delimit is found ----------- */ char *dotconf_get_here_document(configfile_t *configfile, const char *delimit); /* ------ dotconf_invoke_command() - call the callback for command_t ---------------------------- */ const char *dotconf_invoke_command(configfile_t *configfile, command_t *cmd); /* ------ dotconf_find_command() - iterate through all registered options trying to match ------- */ configoption_t *dotconf_find_command(configfile_t *configfile, const char *command); /* ------ dotconf_read_arg() - read one argument from the line handling quoting and escaping ---- */ /* side effects: the char* returned by dotconf_read_arg is malloc() before, hence that pointer will have to be free()ed later. */ char *dotconf_read_arg(configfile_t *configfile, char **line); /* ------ dotconf_handle_command() - parse, substitute, find, invoke the command found in buffer */ const char *dotconf_handle_command(configfile_t *configfile, char *buffer); /* ------ dotconf_register_option() - add a new option table to the list of commands ------------ */ void dotconf_register_options(configfile_t *configfile, const configoption_t *options); /* ------ dotconf_warning() - handle the dispatch of error messages of various levels ----------- */ int dotconf_warning(configfile_t *configfile, int level, unsigned long errnum, const char *, ...); /* ------ dotconf_callback() - register a special callback -------------------------------------- */ void dotconf_callback(configfile_t *configfile, callback_types type, dotconf_callback_t); /* ------ dotconf_substitute_env() - handle the substitution on environment variables ----------- */ char *dotconf_substitute_env(configfile_t *, char *); /* ------ internal utility function that verifies if a character is in the WILDCARDS list -- */ int dotconf_is_wild_card(char value); /* ------ internal utility function that calls the appropriate routine for the wildcard passed in -- */ int dotconf_handle_wild_card(command_t* cmd, char wild_card, char* path, char* pre, char* ext); /* ------ internal utility function that frees allocated memory from dotcont_find_wild_card -- */ void dotconf_wild_card_cleanup(char* path, char* pre); /* ------ internal utility function to check for wild cards in file path -- */ /* ------ path and pre must be freed by the developer ( dotconf_wild_card_cleanup) -- */ int dotconf_find_wild_card(char* filename, char* wildcard, char** path, char** pre, char** ext); /* ------ internal utility function that compares two stings from back to front -- */ int dotconf_strcmp_from_back(const char* s1, const char* s2); /* ------ internal utility function that determins if a string matches the '?' criteria -- */ int dotconf_question_mark_match(char* dir_name, char* pre, char* ext); /* ------ internal utility function that determins if a string matches the '*' criteria -- */ int dotconf_star_match(char* dir_name, char* pre, char* ext); /* ------ internal utility function that determins matches for filenames with -- */ /* ------ a '?' in name and calls the Internal Include function on that filename -- */ int dotconf_handle_question_mark(command_t* cmd, char* path, char* pre, char* ext); /* ------ internal utility function that determins matches for filenames with -- */ /* ------ a '*' in name and calls the Internal Include function on that filename -- */ int dotconf_handle_star(command_t* cmd, char* path, char* pre, char* ext); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* DOTCONF_H */
43.407547
103
0.641919
3e105e7c55b9ee1bf76ccf353073ef307416db51
10,695
h
C
inc/common_macro.h
wind0ws/libcutils
f67c8c2ee195efccee4016dce76211eb70f5d6a1
[ "Apache-2.0" ]
null
null
null
inc/common_macro.h
wind0ws/libcutils
f67c8c2ee195efccee4016dce76211eb70f5d6a1
[ "Apache-2.0" ]
null
null
null
inc/common_macro.h
wind0ws/libcutils
f67c8c2ee195efccee4016dce76211eb70f5d6a1
[ "Apache-2.0" ]
null
null
null
#pragma once #ifndef LCU_COMMON_MACRO_H #define LCU_COMMON_MACRO_H #include <stdbool.h> /* for true/false */ #include <stddef.h> /* for size_t */ #include <stdint.h> /* for int32_t */ #include <stdlib.h> /* for abort */ #include <stdio.h> /* for FILE */ #include <assert.h> /* for assert */ #include <sys/types.h> /* for ssize_t */ #if(defined(__linux__) || defined(__ANDROID__)) #include <sys/cdefs.h> /* for __BEGIN_DECLS */ #endif // __linux__ || __ANDROID__ #ifdef __ANDROID__ #include <android/log.h> /* for log msg on logcat */ #endif // __ANDROID__ #ifdef _WIN32 #include <crtdbg.h> /* for _ASSERT_AND_INVOKE_WATSON */ #include <sal.h> /* for annotation: mark parameters */ #ifndef __func__ #define __func__ __FUNCTION__ #endif // !__func__ #ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif // !__PRETTY_FUNCTION__ #else typedef void* HANDLE; typedef void* PVOID; typedef unsigned long DWORD; typedef int BOOL; typedef unsigned char BYTE; typedef unsigned short WORD; typedef float FLOAT; #endif // _WIN32 #ifndef UNUSED #define UNUSED(x) (void)(x) #endif // !UNUSED #ifndef UNUSED_ATTR #ifdef _WIN32 #define UNUSED_ATTR #else #define UNUSED_ATTR __attribute__((unused)) #endif // _WIN32 #endif // !UNUSED_ATTR // annotation: for mark parameters #ifndef __in #define __in #endif // !__in #ifndef __out #define __out #endif // !__out #ifndef __inout #define __inout #endif // !__inout #ifndef __in_opt #define __in_opt #endif // !__in_opt #ifndef __out_opt #define __out_opt #endif // !__out_opt #ifndef __inout_opt #define __inout_opt #endif // !__inout_opt // for API_EXPORT/IMPORT #if defined(_MSC_VER) // Microsoft #define API_EXPORT __declspec(dllexport) #define API_IMPORT __declspec(dllimport) #define API_HIDDEN #elif defined(__GNUC__) // GCC #define API_EXPORT __attribute__((visibility("default"))) #define API_IMPORT #define API_HIDDEN __attribute__((visibility("hidden"))) #else // do nothing and hope for the best? #define API_EXPORT #define API_IMPORT #define API_HIDDEN #pragma warning Unknown dynamic link import/export/hidden semantics. #endif // _MSC_VER #ifndef EXTERN_C #ifdef __cplusplus #define EXTERN_C extern "C" #else #define EXTERN_C extern #endif // __cplusplus #endif // !EXTERN_C #ifndef EXTERN_C_START #ifdef __cplusplus #define EXTERN_C_START extern "C" { #define EXTERN_C_END } #else #define EXTERN_C_START #define EXTERN_C_END #endif // __cplusplus #endif // !EXTERN_C_START #ifndef __BEGIN_DECLS #define __BEGIN_DECLS EXTERN_C_START #define __END_DECLS EXTERN_C_END #endif // !__BEGIN_DECLS //for size_t ssize_t. Note: in _WIN64 build system, _WIN32 is also defined. //sigh: windows ONLY defined size_t on vcruntime.h. so we need define ssize_t #ifdef _WIN32 #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) typedef intptr_t ssize_t; #define SSIZE_MAX INTPTR_MAX #define _SSIZE_T_ #define _SSIZE_T_DEFINED #endif // !_SSIZE_T_ && !_SSIZE_T_DEFINED #if(defined(_MSC_VER) && _MSC_VER < 1800) /* __LP64__ is defined by compiler. If set to 1 means this is 64bit build system */ #ifdef __LP64__ #define SIZE_T_FORMAT "%lu" #define SSIZE_T_FORMAT "%ld" #else #define SIZE_T_FORMAT "%u" #define SSIZE_T_FORMAT "%d" #endif #else #define SIZE_T_FORMAT "%zu" #define SSIZE_T_FORMAT "%zd" #endif // _MSC_VER #endif // _WIN32 // widely useful macros. pay attention to the influence of double computation! #ifndef __max #define __max(a,b) (((a) > (b)) ? (a) : (b)) #endif // !__max #ifndef __min #define __min(a,b) (((a) < (b)) ? (a) : (b)) #endif // !__min #ifndef __abs #define __abs(x) ((x) >= 0 ? (x) : -(x)) #endif // !__abs #ifndef FREE #define FREE(ptr) do{ if(ptr) { free(ptr); (ptr) = NULL; } }while(0) #endif // !FREE #ifndef ARRAY_LEN #define ARRAY_LEN(x) (sizeof(x) / sizeof((x)[0])) #endif // !ARRAY_LEN #ifndef INVALID_FD #define INVALID_FD (-1) #endif // !INVALID_FD #ifndef CONCAT #define CONCAT(a, b) a##b #endif // !CONCAT #ifndef STRINGIFY #define STRINGIFY(a) #a #endif // !STRINGIFY #ifndef NULLABLE_STRING #define NULLABLE_STRING(a) ((a) ? (a) : "(null)") #endif // !NULLABLE_STRING // Use during compile time to check conditional values // NOTE: The the failures will present as a generic error // "error: initialization makes pointer from integer without a cast" // but the file and line number will present the condition that failed #define DUMMY_COUNTER(c) CONCAT(__lcu_dummy_, c) #define DUMMY_PTR DUMMY_COUNTER(__COUNTER__) #ifndef STATIC_ASSERT #define STATIC_ASSERT_WITH_MSG(expr, msg) typedef char __static_assert_t_##msg[(expr) != 0] #define _TEMP_FOR_EXPAND_STATIC_ASSERT_WITH_MSG(expr, msg) STATIC_ASSERT_WITH_MSG(expr, msg) #define STATIC_ASSERT(expr) _TEMP_FOR_EXPAND_STATIC_ASSERT_WITH_MSG(expr, __LINE__) #endif // !STATIC_ASSERT #ifdef __ANDROID__ #define _EMERGENCY_LOG_FOR_PLATFORM(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, "DEBUG", fmt, ##__VA_ARGS__) #else #define _EMERGENCY_LOG_FOR_PLATFORM(fmt, ...) #endif //__ANDROID__ //for log emergency error message. #define EMERGENCY_LOG(fmt, ...) \ do { \ _EMERGENCY_LOG_FOR_PLATFORM(fmt, ##__VA_ARGS__); \ printf("[DEBUG] " fmt "\n", ##__VA_ARGS__); \ fflush(stdout); \ } while(0) #ifndef ASSERT #if(defined(NDEBUG) || !defined(_DEBUG)) #define ASSERT(expr) (void)(expr) #define _TEMP_FOR_ASSERT_ABORT(expr, line) \ do { \ if (expr) break; \ EMERGENCY_LOG("API check '%s' failed at '%s' (%s:%d)", \ #expr, __PRETTY_FUNCTION__, __FILE__, line); \ abort(); \ } while(0) #else #ifdef _WIN32 //why we not use _ASSERT_AND_INVOKE_WATSON directly? Because we don't want to be affected by double computation! #define _TEMP_FOR_ASSERT_AND_INVOKE_WATSON(expr, line) \ do { \ bool expr_##line = !!(expr); \ if(expr_##line) break; \ _ASSERT_EXPR(expr_##line, _CRT_WIDE(#expr)); \ } while(0) #define _TEMP_FOR_EXPAND_ASSERT_AND_INVOKE_WATSON(expr, line) _TEMP_FOR_ASSERT_AND_INVOKE_WATSON(expr, line) #define ASSERT(expr) _TEMP_FOR_EXPAND_ASSERT_AND_INVOKE_WATSON(expr, __LINE__) #define _TEMP_FOR_ASSERT_ABORT(expr, line) _TEMP_FOR_EXPAND_ASSERT_AND_INVOKE_WATSON(expr, line) #else #define ASSERT(expr) assert(expr) #define _TEMP_FOR_ASSERT_ABORT(expr, line) assert(expr) #endif // _WIN32 #endif // NDEBUG || !_DEBUG #endif // !ASSERT #define _TEMP_FOR_EXPAND_ASSERT_ABORT(expr, line) _TEMP_FOR_ASSERT_ABORT(expr, line) /** * In debug mode, expression check failure will catch by ASSERT. * In release mode, it will log error to stdout/logcat and abort program. */ #define ASSERT_ABORT(expr) _TEMP_FOR_EXPAND_ASSERT_ABORT(expr, __LINE__) #ifndef __cplusplus // Macros for safe integer to pointer conversion. In the C language, data is // commonly cast to opaque pointer containers and back for generic parameter // passing in callbacks. These macros should be used sparingly in new code // (never in C++ code). Whenever integers need to be passed as a pointer, use // these macros. #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) #define UINT_TO_PTR(u) ((void *) ((uintptr_t) (u))) #define PTR_TO_INT(p) ((int) ((intptr_t) (p))) #define INT_TO_PTR(i) ((void *) ((intptr_t) (i))) #endif // !__cplusplus #ifdef _WIN32 #include <direct.h> #include <io.h> #define F_OK 0 #define X_OK 1 #define W_OK 2 #define R_OK 4 //just to make MSC happy #define access(path_name, mode) _access(path_name, mode) #define mkdir(path, mode) _mkdir(path) #define read(fd, buf, count) _read(fd, buf, count) #define write(fd, buf, count) _write(fd, buf, count) static inline FILE* _fopen_safe(char const* _FileName, char const* _Mode) { FILE* _ftemp = NULL; fopen_s(&_ftemp, _FileName, _Mode); return _ftemp; } //to make MSC happy #define fopen(file_name, mode) _fopen_safe(file_name, mode) #else #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #endif // _WIN32 #define fclose(fp) do{if(fp){ fclose(fp); (fp) = NULL; }}while(0) #ifndef RANDOM #define RANDOM_INIT(seed) srand((seed)) #define RANDOM(a, b) (rand() % ((b) - (a)) + (a)) #endif // !RANDOM //================================DECLARE ENUM AND STRINGS================================ /** how to use: // def enum and declare enum strings on header #define FOREACH_STATES_ITEM(GENERATOR) \ GENERATOR(STATE_START) \ GENERATOR(STATE_STOP) DEF_ENUM(STATES, FOREACH_STATES_ITEM); DECLARE_ENUM_STRS(STATES); // def enum string on source file DEF_ENUM_STRS(STATES, FOREACH_STATES_ITEM); //now you can print enum str printf("STATES[0]=%s", STATES_STR[STATE_START]); */ #define _GENERATOR_ENUM_ITEM(item) item, #define _GENERATOR_ENUM_STR(item) #item, #define _TEMP_FOR_DEF_ENUM(name, foreach_enum, generator_enum_item) \ typedef enum name##_ { \ foreach_enum(generator_enum_item) \ } name; #define DEF_ENUM(name, foreach_enum) _TEMP_FOR_DEF_ENUM(name, foreach_enum, _GENERATOR_ENUM_ITEM) #define DECLARE_ENUM_STRS(name) extern const char *name##_STRS[] #define _TEMP_FOR_DEF_ENUM_STRS(name, foreach_enum, generator_enum_str) \ const char *name##_STRS[] = { foreach_enum(generator_enum_str) }; #define DEF_ENUM_STRS(name, foreach_enum) \ _TEMP_FOR_DEF_ENUM_STRS(name, foreach_enum, _GENERATOR_ENUM_STR) //================================DECLARE ENUM AND STRINGS================================ #endif // LCU_COMMON_MACRO_H
35.180921
113
0.630108
2d0a4b790adadc6d20060fdf88472899822f7c12
297
c
C
TestSuites/ADFamily/src/RpcStubs/MS-DRSR/drsr.c
Grom-Li/WindowsProtocolTestSuites
fe1a56afeef952c9eac7d8129b9d16bcd197dcb1
[ "MIT" ]
332
2019-05-14T09:46:46.000Z
2022-03-23T19:45:34.000Z
TestSuites/ADFamily/src/RpcStubs/MS-DRSR/drsr.c
Grom-Li/WindowsProtocolTestSuites
fe1a56afeef952c9eac7d8129b9d16bcd197dcb1
[ "MIT" ]
107
2015-11-27T05:44:26.000Z
2019-02-28T08:37:53.000Z
TestSuites/ADFamily/src/RpcStubs/MS-DRSR/drsr.c
Grom-Li/WindowsProtocolTestSuites
fe1a56afeef952c9eac7d8129b9d16bcd197dcb1
[ "MIT" ]
106
2019-05-15T02:05:55.000Z
2022-03-25T00:52:11.000Z
#include "ms-drsr.h" /* Allocate the Memory pointed by */ void *__RPC_USER MIDL_user_allocate(size_t memSize) { return malloc(memSize); } /* De-allocate the Memory pointed by */ void __RPC_USER MIDL_user_free(void *p) { free(p); } void __RPC_USER DRS_HANDLE_rundown( DRS_HANDLE p ) { }
17.470588
51
0.717172
7c88ac68957f904315e3d3f7fa3054acccb6861b
4,064
h
C
IVT/src/Image/IplImageAdaptor.h
Tobi2001/asr_ivt
146abe4324a14d7b8acccec7b1bfbdb74590fb5f
[ "BSD-3-Clause" ]
null
null
null
IVT/src/Image/IplImageAdaptor.h
Tobi2001/asr_ivt
146abe4324a14d7b8acccec7b1bfbdb74590fb5f
[ "BSD-3-Clause" ]
null
null
null
IVT/src/Image/IplImageAdaptor.h
Tobi2001/asr_ivt
146abe4324a14d7b8acccec7b1bfbdb74590fb5f
[ "BSD-3-Clause" ]
1
2019-11-24T17:09:19.000Z
2019-11-24T17:09:19.000Z
// **************************************************************************** // This file is part of the Integrating Vision Toolkit (IVT). // // The IVT is maintained by the Karlsruhe Institute of Technology (KIT) // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de). // // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT). // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the KIT 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 KIT 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 KIT OR CONTRIBUTORS BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // **************************************************************************** #ifndef _IPL_IMAGE_ADAPTOR_H_ #define _IPL_IMAGE_ADAPTOR_H_ // **************************************************************************** // Necessary includes // **************************************************************************** #include "opencv/cv.h" // **************************************************************************** // Forward declarations // **************************************************************************** class CByteImage; // **************************************************************************** // IplImageAdaptor // **************************************************************************** /*! \ingroup ImageRepresentations \brief Conversion between CByteImage (IVT) and IplImage (OpenCV). */ namespace IplImageAdaptor { /*! \brief Converts a CByteImage to an IplImage. @param pImage The input image. @param bAllocateMemory If set to false (default value) the pointer pImage->pixels is assigned to the returned instance of IplImage. In this case, cvReleaseImageHeader must be called for deletion. If set to true the returned instance of IplImage allocates its own memory and the image contents are copied. In this case, cvReleaseImage must be called for deletion. @return the created instance of IplImage. Do not forget to delete the instance after use (see documentation of the parameter bAllocateMemory for details). */ IplImage* Adapt(const CByteImage *pImage, bool bAllocateMemory = false); /*! \brief Converts an IplImage to a CByteImage. @param pIplImage The input image. @param bAllocateMemory If set to false (default value) the pointer pIplImage->pixels is assigned to the returned instance of CByteImage. If set to true the returned instance of CByteImage allocates its own memory and the image contents are copied. @return the created instance of CByteImage. Do not forget to delete the instance after use (deletion of CByteImage::pixels is done automatically in the destructor if necessary). */ CByteImage* Adapt(const IplImage *pIplImage, bool bAllocateMemory = false); } #endif /* _IPL_IMAGE_ADAPTOR_H_ */
45.155556
179
0.64813
f5aa23120f4ae75124ed145ce85d1ebf05fc4fbc
263
h
C
include/math.h
A3st76/ionmath
1a8f7732b3fea96d7add1110178686ba56a6fdb9
[ "MIT" ]
null
null
null
include/math.h
A3st76/ionmath
1a8f7732b3fea96d7add1110178686ba56a6fdb9
[ "MIT" ]
null
null
null
include/math.h
A3st76/ionmath
1a8f7732b3fea96d7add1110178686ba56a6fdb9
[ "MIT" ]
null
null
null
// Copyright © 2020-2021 Dmitriy Lukovenko. All rights reserved. #pragma once #include "math/functions.h" #include "math/vector2.h" #include "math/vector3.h" #include "math/vector4.h" #include "math/color.h" #include "math/matrix.h" #include "math/quaternion.h"
23.909091
64
0.741445
7b359744c28db47e0f14b75c75c435a3c50055b0
916
h
C
NewLLDebugTool/algorithms/MonkeyScriptHelper.h
didiaodanding/TestPods
f894a1633933f4ccf0ead56e78a296117037c82e
[ "MIT" ]
1
2020-05-28T03:28:06.000Z
2020-05-28T03:28:06.000Z
NewLLDebugTool/algorithms/MonkeyScriptHelper.h
didiaodanding/TestPods
f894a1633933f4ccf0ead56e78a296117037c82e
[ "MIT" ]
null
null
null
NewLLDebugTool/algorithms/MonkeyScriptHelper.h
didiaodanding/TestPods
f894a1633933f4ccf0ead56e78a296117037c82e
[ "MIT" ]
null
null
null
// // MonkeyScriptHelper.h // LLDebugToolDemo // // Created by apple on 2019/10/18. // Copyright © 2019 li. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface LLTestCase:NSObject @property (strong, nonatomic) id target; @property (assign, nonatomic) SEL selector; - (instancetype)initWithTarget:(id)target selector:(SEL)selector ; @end @interface MonkeyScriptHelper : NSObject /** Singleton to control monkey script. @return Singleton */ + (instancetype)sharedHelper ; /** obtain sel from target **/ - (LLTestCase *)loadTestFromTarget:(id)target ; /** obtain all monkey script **/ - (NSArray *)loadAllTestCases ; /** run monkey script **/ - (BOOL)runTestWithTarget:(id)target selector:(SEL)selector exception:(NSException **)exception interval:(NSTimeInterval *)interval reraiseExceptions:(BOOL)reraiseExceptions ; @end NS_ASSUME_NONNULL_END
20.355556
131
0.7369
4c22f476f1a2ee7373775131f4df1a07a7821b9d
5,434
c
C
client/submit.c
kjcolley7/PEGASUS
a1dceb52f51192f028672055958666a1ac65a15a
[ "MIT" ]
1
2020-11-13T02:29:05.000Z
2020-11-13T02:29:05.000Z
client/submit.c
kjcolley7/PEGASUS
a1dceb52f51192f028672055958666a1ac65a15a
[ "MIT" ]
null
null
null
client/submit.c
kjcolley7/PEGASUS
a1dceb52f51192f028672055958666a1ac65a15a
[ "MIT" ]
null
null
null
// // submit.c // PegasusEar // // Created by Kevin Colley on 11/3/2020. // #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <stdint.h> #include <stdbool.h> #include <string.h> #include <netdb.h> #include <errno.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #include "kjc_argparse/kjc_argparse.h" /*! * Maximum allowed size of a PEG file is 70 KiB. * It doesn't make sense to allow PEG files much larger than the EAR address space size (64 KiB). */ #define PEG_SIZE_MAX (0x1000 * 70) static bool send_peg_file(int sock, const void* peg_data, uint32_t peg_size) { char buf[256] = {0}; const char* banner = "PEG SIZE?\n"; size_t banner_len = strlen(banner); errno = 0; ssize_t xfer = recv(sock, buf, banner_len, MSG_WAITALL); if(xfer < 0) { fprintf(stderr, "Failed to receive data from the server: %s\n", strerror(errno)); return false; } else if(xfer != (ssize_t)banner_len) { fprintf(stderr, "Premature EOF in server response: %s\n", buf); return false; } if(memcmp(buf, banner, banner_len) != 0) { fprintf(stderr, "Received unexpected data from server: %s\n", banner); return false; } uint32_t net_size = htonl(peg_size); errno = 0; xfer = send(sock, &net_size, sizeof(net_size), 0); if(xfer != sizeof(net_size)) { fprintf(stderr, "Failed to send PEGASUS size: %s\n", strerror(errno)); return false; } banner = "PEG DATA?\n"; banner_len = strlen(banner); errno = 0; xfer = recv(sock, buf, banner_len, MSG_WAITALL); if(xfer < 0) { fprintf(stderr, "Failed to receive data from the server: %s\n", strerror(errno)); return false; } else if(xfer != (ssize_t)banner_len) { fprintf(stderr, "Premature EOF in server response: %s\n", buf); return false; } if(memcmp(buf, banner, banner_len) != 0) { fprintf(stderr, "Received unexpected data from server: %s\n", banner); return false; } errno = 0; xfer = send(sock, peg_data, peg_size, 0); if(xfer != peg_size) { fprintf(stderr, "Failed to send PEGASUS data: %s\n", strerror(errno)); return false; } fprintf(stderr, "PEGASUS file submitted!\n"); fprintf(stderr, "Challenge server says:\n"); while(1) { errno = 0; xfer = recv(sock, buf, sizeof(buf) - 1, MSG_WAITALL); if(xfer == 0) { break; } if(xfer < 0) { fprintf(stderr, "Error receiving data from server: %s\n", strerror(errno)); return false; } if(write(STDOUT_FILENO, buf, xfer) != xfer) { fprintf(stderr, "Failed to write to stdout\n"); return false; } } return true; } int main(int argc, char** argv) { int ret = EXIT_FAILURE; bool parseSuccess = false; const char* pegFile = NULL; const char* server = NULL; uint16_t port = 0; ARGPARSE(argc, argv) { ARGPARSE_SET_OUTPUT(stderr); ARG('h', "help", "Displays this help message") { ARGPARSE_HELP(); break; } ARG_STRING('s', "server", "Server address for the challenge server", str) { if(server != NULL) { fprintf(stderr, "--server cannot be used more than once!\n"); ARGPARSE_HELP(); break; } server = str; } ARG_INT('p', "port", "Port number for the challenge server", num) { if(port != 0) { fprintf(stderr, "--port cannot be used more than once!\n"); ARGPARSE_HELP(); break; } if(num <= 0 || UINT16_MAX < num) { fprintf(stderr, "Port number is out of range!\n"); ARGPARSE_HELP(); break; } port = num; } ARG_POSITIONAL("<solution>.peg", arg) { if(pegFile != NULL) { fprintf(stderr, "Only one input file may be provided!\n"); ARGPARSE_HELP(); break; } pegFile = arg; } ARG_END() { if(pegFile == NULL) { fprintf(stderr, "No input files\n"); } else if(server == NULL) { fprintf(stderr, "Missing required argument --server\n"); } else if(port == 0) { fprintf(stderr, "Missing required argument --port\n"); } else { parseSuccess = true; break; } ARGPARSE_HELP(); } } if(!parseSuccess) { return EXIT_FAILURE; } int peg_fd = open(pegFile, O_RDONLY); if(peg_fd == -1) { perror(pegFile); return EXIT_FAILURE; } off_t seek_pos = lseek(peg_fd, 0, SEEK_END); if(seek_pos > UINT32_MAX) { fprintf(stderr, "PEGASUS file is too large\n"); close(peg_fd); return EXIT_FAILURE; } uint32_t peg_size = (uint32_t)seek_pos; void* peg_data = mmap(NULL, peg_size, PROT_READ, MAP_FILE | MAP_PRIVATE, peg_fd, 0); close(peg_fd); if(peg_data == MAP_FAILED) { perror("mmap"); return EXIT_FAILURE; } char port_str[6]; snprintf(port_str, sizeof(port_str), "%hu", port); struct addrinfo* ai = NULL; int gai_err = getaddrinfo(server, port_str, NULL, &ai); if(gai_err != 0) { fprintf(stderr, "Failed to resolve server address %s: %s\n", server, gai_strerror(gai_err)); return EXIT_FAILURE; } struct addrinfo* cur; for(cur = ai; cur != NULL; cur = cur->ai_next) { errno = 0; int sock = socket(AF_INET, SOCK_STREAM, 0); if(sock < 0) { fprintf(stderr, "Error creating socket: %s\n", strerror(errno)); continue; } errno = 0; if(connect(sock, cur->ai_addr, cur->ai_addrlen) != 0) { fprintf(stderr, "Connecting to %s:%hu failed: %s\n", server, port, strerror(errno)); close(sock); continue; } ret = send_peg_file(sock, peg_data, peg_size) ? EXIT_SUCCESS : EXIT_FAILURE; close(sock); break; } munmap(peg_data, peg_size); if(ai != NULL) { freeaddrinfo(ai); } return ret; }
23.123404
97
0.641148
21de410a2107bae7e1867869ce61d1740015439f
1,085
h
C
Frameworks/YHOcrSDK.framework/Versions/A/Headers/YHOcrCutImageView.h
XmYlzYhkj/YHOcrSDK
0ee4a58480823860ec3faf1d564af80b751d2954
[ "MIT" ]
null
null
null
Frameworks/YHOcrSDK.framework/Versions/A/Headers/YHOcrCutImageView.h
XmYlzYhkj/YHOcrSDK
0ee4a58480823860ec3faf1d564af80b751d2954
[ "MIT" ]
null
null
null
Frameworks/YHOcrSDK.framework/Versions/A/Headers/YHOcrCutImageView.h
XmYlzYhkj/YHOcrSDK
0ee4a58480823860ec3faf1d564af80b751d2954
[ "MIT" ]
null
null
null
// // YHOcrCutImageView.h // YHOcr // // Created by Jagtu on 2020/8/9. // Copyright © 2020年 易惠. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> #import "YHOcrImageView.h" @protocol YHOcrImageDelegate <NSObject> @optional - (void)YHCutImageBeginPaint; - (void)YHCutImageScale; - (void)YHCutImageMove; - (void)YHCutImageEndPaint; @end @interface YHOcrCutImageView : UIView <UITextViewDelegate,YHOcrImageViewDelegate> @property (nonatomic, assign) id<YHOcrImageDelegate> imgDelegate; @property (nonatomic, retain) NSString *strSelectContent; @property (nonatomic, strong) UIImageView *bgImageView; @property (nonatomic, assign) BOOL isImageFromLib; //截图的分辨率系数 开发者可自行配置 @property (nonatomic, assign) CGFloat scale; //设置页面图片 - (void)setBGImage:(UIImage *)aImage fromPhotoLib:(BOOL)isFromLib useGestureRecognizer:(BOOL)isUse; - (UIImage *)cutImageFromView:(UIImageView *)theView withSize:(CGSize)ori atFrame:(CGRect)rect; @end
27.820513
99
0.712442
2965ce406b8421f343bbf98498e09eb48fc50789
616
h
C
wxMasterPanelDlgCanvas.h
dl200010/Home_Security_Project
025d4d9d9b0baa579236bce8ef53292e1df317d6
[ "Apache-2.0" ]
null
null
null
wxMasterPanelDlgCanvas.h
dl200010/Home_Security_Project
025d4d9d9b0baa579236bce8ef53292e1df317d6
[ "Apache-2.0" ]
null
null
null
wxMasterPanelDlgCanvas.h
dl200010/Home_Security_Project
025d4d9d9b0baa579236bce8ef53292e1df317d6
[ "Apache-2.0" ]
null
null
null
#ifndef WXMASTERPANELDLGCANVAS #define WXMASTERPANELDLGCANVAS #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/image.h" #include "wx/file.h" #include "wx/filename.h" #include "wx/mstream.h" #include "wx/wfstream.h" #include "wx/quantize.h" class wxMasterPanelDlgCanvas: public wxScrolledWindow { public: wxMasterPanelDlgCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size ); ~wxMasterPanelDlgCanvas(); void OnPaint( wxPaintEvent &event ); wxBitmap housepicture_bmp; DECLARE_EVENT_TABLE() }; #endif
18.666667
99
0.73539
29ae4b6714c599e9a14160808ed726d86988ae13
919
h
C
PrivateFrameworks/CloudDocsDaemon.framework/BRCFSEventsPersistedState.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/CloudDocsDaemon.framework/BRCFSEventsPersistedState.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/CloudDocsDaemon.framework/BRCFSEventsPersistedState.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/CloudDocsDaemon.framework/CloudDocsDaemon */ @interface BRCFSEventsPersistedState : NSObject <NSSecureCoding> { bool _isCancelled; unsigned long long _latestEventID; unsigned long long _rootID; BRCAccountSession * _session; NSUUID * _streamUUID; } @property (nonatomic) unsigned long long latestEventID; @property (nonatomic) unsigned long long rootID; @property (nonatomic, retain) NSUUID *streamUUID; + (id)loadFromClientStateInSession:(id)arg1 name:(id)arg2; + (bool)supportsSecureCoding; - (void).cxx_destruct; - (id)description; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; - (unsigned long long)latestEventID; - (unsigned long long)rootID; - (void)setLatestEventID:(unsigned long long)arg1; - (void)setRootID:(unsigned long long)arg1; - (void)setStreamUUID:(id)arg1; - (id)streamUUID; @end
28.71875
85
0.758433
ada377f0c2060a770a622f921887538307ddfb97
776
c
C
linsched-linsched-alpha/arch/arm/mach-s5pc100/setup-keypad.c
usenixatc2021/SoftRefresh_Scheduling
589ba06c8ae59538973c22edf28f74a59d63aa14
[ "MIT" ]
55
2019-12-20T03:25:14.000Z
2022-01-16T07:19:47.000Z
linsched-linsched-alpha/arch/arm/mach-s5pc100/setup-keypad.c
usenixatc2021/SoftRefresh_Scheduling
589ba06c8ae59538973c22edf28f74a59d63aa14
[ "MIT" ]
2
2020-11-02T08:01:00.000Z
2022-03-27T02:59:18.000Z
linsched-linsched-alpha/arch/arm/mach-s5pc100/setup-keypad.c
usenixatc2021/SoftRefresh_Scheduling
589ba06c8ae59538973c22edf28f74a59d63aa14
[ "MIT" ]
19
2015-02-25T19:50:05.000Z
2021-10-05T14:35:54.000Z
/* linux/arch/arm/mach-s5pc100/setup-keypad.c * * Copyright (c) 2010 Samsung Electronics Co., Ltd. * http://www.samsung.com/ * * GPIO configuration for S5PC100 KeyPad device * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/gpio.h> #include <plat/gpio-cfg.h> void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols) { /* Set all the necessary GPH3 pins to special-function 3: KP_ROW[x] */ s3c_gpio_cfgrange_nopull(S5PC100_GPH3(0), rows, S3C_GPIO_SFN(3)); /* Set all the necessary GPH2 pins to special-function 3: KP_COL[x] */ s3c_gpio_cfgrange_nopull(S5PC100_GPH2(0), cols, S3C_GPIO_SFN(3)); }
32.333333
71
0.742268
bc1f6d86ce2a39a6dac6bc368900ecb9f88b6793
5,007
h
C
chrome/browser/sync_file_system/drive_backend_v1/remote_sync_delegate.h
kurli/chromium-crosswalk
f4c5d15d49d02b74eb834325e4dff50b16b53243
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/sync_file_system/drive_backend_v1/remote_sync_delegate.h
kurli/chromium-crosswalk
f4c5d15d49d02b74eb834325e4dff50b16b53243
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/sync_file_system/drive_backend_v1/remote_sync_delegate.h
kurli/chromium-crosswalk
f4c5d15d49d02b74eb834325e4dff50b16b53243
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE_H_ #include <string> #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/drive_backend_v1/api_util.h" #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service.h" #include "chrome/browser/sync_file_system/drive_backend_v1/drive_metadata_store.h" #include "chrome/browser/sync_file_system/file_change.h" #include "chrome/browser/sync_file_system/sync_action.h" #include "chrome/browser/sync_file_system/sync_callbacks.h" #include "chrome/browser/sync_file_system/sync_file_metadata.h" #include "chrome/browser/sync_file_system/sync_file_system.pb.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/common/blob/scoped_file.h" namespace sync_file_system { class DriveMetadataStore; class RemoteChangeProcessor; namespace drive_backend { class APIUtil; // This class handles RemoteFileSyncService::ProcessRemoteChange for drive // backend, and its instance represents single ProcessRemoteChange operation. // The caller is responsible to own the instance, and can cancel operation by // deleting the instance. class RemoteSyncDelegate : public base::SupportsWeakPtr<RemoteSyncDelegate> { public: typedef RemoteChangeHandler::RemoteChange RemoteChange; RemoteSyncDelegate( DriveFileSyncService* sync_service, const RemoteChange& remote_change); virtual ~RemoteSyncDelegate(); void Run(const SyncStatusCallback& callback); const fileapi::FileSystemURL& url() const { return remote_change_.url; } private: void DidPrepareForProcessRemoteChange(const SyncStatusCallback& callback, SyncStatusCode status, const SyncFileMetadata& metadata, const FileChangeList& local_changes); void ApplyRemoteChange(const SyncStatusCallback& callback); void DidApplyRemoteChange(const SyncStatusCallback& callback, SyncStatusCode status); void DeleteMetadata(const SyncStatusCallback& callback); void DownloadFile(const SyncStatusCallback& callback); void DidDownloadFile(const SyncStatusCallback& callback, google_apis::GDataErrorCode error, const std::string& md5_checksum, int64 file_size, const base::Time& updated_time, scoped_ptr<webkit_blob::ScopedFile> downloaded_file); void HandleConflict(const SyncStatusCallback& callback, SyncFileType remote_file_type); void HandleLocalWin(const SyncStatusCallback& callback); void HandleRemoteWin(const SyncStatusCallback& callback, SyncFileType remote_file_type); void HandleManualResolutionCase(const SyncStatusCallback& callback); void DidGetEntryForConflictResolution( const SyncStatusCallback& callback, google_apis::GDataErrorCode error, scoped_ptr<google_apis::ResourceEntry> entry); void ResolveToLocal(const SyncStatusCallback& callback); void DidResolveToLocal(const SyncStatusCallback& callback, SyncStatusCode status); void ResolveToRemote(const SyncStatusCallback& callback); void DidResolveToRemote(const SyncStatusCallback& callback, SyncStatusCode status); void StartOver(const SyncStatusCallback& callback, SyncStatusCode status); void CompleteSync(const SyncStatusCallback& callback, SyncStatusCode status); void AbortSync(const SyncStatusCallback& callback, SyncStatusCode status); void DidFinish(const SyncStatusCallback& callback, SyncStatusCode status); SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper( google_apis::GDataErrorCode error); DriveMetadataStore* metadata_store(); APIUtilInterface* api_util(); RemoteChangeHandler* remote_change_handler(); RemoteChangeProcessor* remote_change_processor(); ConflictResolutionResolver* conflict_resolution_resolver(); const FileChange& remote_file_change() const { return remote_change_.change; } DriveFileSyncService* sync_service_; // Not owned. RemoteChange remote_change_; DriveMetadata drive_metadata_; SyncFileMetadata local_metadata_; webkit_blob::ScopedFile temporary_file_; std::string md5_checksum_; SyncAction sync_action_; bool metadata_updated_; bool clear_local_changes_; std::string origin_resource_id_; DISALLOW_COPY_AND_ASSIGN(RemoteSyncDelegate); }; } // namespace drive_backend } // namespace sync_file_system #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE_H_
40.707317
85
0.754943
f63cef6beb99b9b9e6275b71299a5b336c6f7cce
1,285
c
C
src/lua_utils.c
e0328eric/aedif
5e37f09f0d28edb6c43b6f7e87d9a08c14b2b755
[ "MIT" ]
null
null
null
src/lua_utils.c
e0328eric/aedif
5e37f09f0d28edb6c43b6f7e87d9a08c14b2b755
[ "MIT" ]
2
2021-12-19T12:54:12.000Z
2021-12-19T12:54:13.000Z
src/lua_utils.c
e0328eric/aedif
5e37f09f0d28edb6c43b6f7e87d9a08c14b2b755
[ "MIT" ]
null
null
null
#include <stdint.h> #include <stdio.h> #include <string.h> #include "lua_utils.h" int getLineNumber(lua_State* L) { lua_Debug ar; if (lua_getstack(L, 1, &ar)) { lua_getinfo(L, "l", &ar); return ar.currentline; } return -1; } void dumpStack(lua_State* L) { int top = lua_gettop(L); printf("==================================================\n"); for (int i = 1; i <= top; ++i) { printf("%d\t%s\t", i, luaL_typename(L, i)); switch (lua_type(L, i)) { case LUA_TNUMBER: printf("%f\n", lua_tonumber(L, i)); break; case LUA_TSTRING: printf("%s\n", lua_tostring(L, i)); break; case LUA_TBOOLEAN: printf("%s\n", lua_toboolean(L, i) ? "true" : "false"); break; case LUA_TNIL: printf("nil\n"); break; default: printf("%p\n", lua_topointer(L, i)); break; } } printf("==================================================\n"); } bool is_ok(lua_State* L, int result) { if (result != LUA_OK) { const char* err_msg = lua_tostring(L, -1); fprintf(stderr, "%s\n", err_msg); return false; } return true; }
20.078125
67
0.449027
5e25bdfd8b2817f3ecee78e399cf32c1761196e3
23
h
C
openssl-1.0.1g/vsbuild/drop-ins/include/openssl/e_os.h
ValeriyKopylov/OpenSSL-WP8
abe7cb0128a070bc2d5932c96a3b83364c61196c
[ "OpenSSL" ]
1
2015-01-28T01:59:16.000Z
2015-01-28T01:59:16.000Z
openssl-1.0.1g/vsbuild/drop-ins/include/openssl/e_os.h
ValeriyKopylov/OpenSSL-WP8
abe7cb0128a070bc2d5932c96a3b83364c61196c
[ "OpenSSL" ]
null
null
null
openssl-1.0.1g/vsbuild/drop-ins/include/openssl/e_os.h
ValeriyKopylov/OpenSSL-WP8
abe7cb0128a070bc2d5932c96a3b83364c61196c
[ "OpenSSL" ]
null
null
null
#include "../../e_os.h"
23
23
0.521739
823fd35445aaf360176bb99cfa5521fdd8dda054
1,094
h
C
ContextKit.framework/CKContextCompleter.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
4
2021-10-06T12:15:26.000Z
2022-02-21T02:26:00.000Z
ContextKit.framework/CKContextCompleter.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
null
null
null
ContextKit.framework/CKContextCompleter.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
1
2021-10-08T07:40:53.000Z
2021-10-08T07:40:53.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/ContextKit.framework/ContextKit */ @interface CKContextCompleter : NSObject { unsigned long long _couldHaveShown; bool _discarded; bool _hideCompletions; NSDate * _hideCompletionsAfterDate; NSString * _ignorePrefix; NSString * _input; unsigned long long _mustPrefixMatchLength; CKContextResponse * _response; NSLocale * _searchLocale; NSMutableArray * _zkwResults; } - (void).cxx_destruct; - (id)_resultsMatching:(id)arg1; - (void)dealloc; - (void)discard; - (id)initWithResponse:(id)arg1; - (void)logEngagement:(id)arg1 forInput:(id)arg2; - (void)logEngagement:(id)arg1 forInput:(id)arg2 completion:(id)arg3; - (void)logResultsShown:(unsigned long long)arg1 serverOverride:(bool)arg2; - (void)logResultsShown:(unsigned long long)arg1 serverOverride:(bool)arg2 forInput:(id)arg3; - (void)logTransactionSuccessfulForInput:(id)arg1; - (void)logTransactionSuccessfulForInput:(id)arg1 completion:(id)arg2; - (id)queriesMatching:(id)arg1; - (id)resultsMatching:(id)arg1; @end
33.151515
93
0.755027
e8a39b257d0dd67f63c38d6d8cf6615d89bd202a
4,313
h
C
AssortedWidgets/KeyEvent.h
Bot-Labs/AssortedWidgets
298567b8f069580205e309979bc35ec063d09f51
[ "MIT" ]
107
2016-03-13T23:45:48.000Z
2022-02-13T21:17:44.000Z
AssortedWidgets/KeyEvent.h
Bot-Labs/AssortedWidgets
298567b8f069580205e309979bc35ec063d09f51
[ "MIT" ]
2
2019-10-12T12:19:21.000Z
2022-01-04T10:42:18.000Z
AssortedWidgets/KeyEvent.h
Bot-Labs/AssortedWidgets
298567b8f069580205e309979bc35ec063d09f51
[ "MIT" ]
29
2017-06-04T15:04:30.000Z
2021-11-25T14:36:48.000Z
#pragma once #include "Event.h" namespace AssortedWidgets { namespace Event { class KeyEvent : public Event { public: KeyEvent(Widgets::Component* _source, int _type, int _keyCode, int _modifiers) :Event(_source,_type), m_keyCode(_keyCode), m_modifiers(_modifiers) {} enum KeyEventTypes { KEY_PRESSED, KEY_RELEASED, KEY_TYPED }; enum VirtualKeys { VKUI_UNKNOWN = 0, VKUI_FIRST = 0, VKUI_BACKSPACE = 8, VKUI_TAB = 9, VKUI_ENTER = 10, VKUI_CLEAR = 12, VKUI_RETURN = 13, VKUI_CTRL = 17, VKUI_ALT = 18, VKUI_PAUSE = 19, VKUI_CAPSLOCK = 20, VKUI_ESCAPE = 27, VKUI_SPACE = 32, VKUI_EXCLAIM = 33, VKUI_QUOTEDBL = 34, VKUI_HASH = 35, VKUI_DOLLAR = 36, VKUI_AMPERSAND = 38, VKUI_QUOTE = 39, VKUI_LEFTPAREN = 40, VKUI_RIGHTPAREN = 41, VKUI_ASTERISK = 42, VKUI_PLUS = 43, VKUI_COMMA = 44, VKUI_MINUS = 45, VKUI_PERIOD = 46, VKUI_SLASH = 47, VKUI_0 = 48, VKUI_1 = 49, VKUI_2 = 50, VKUI_3 = 51, VKUI_4 = 52, VKUI_5 = 53, VKUI_6 = 54, VKUI_7 = 55, VKUI_8 = 56, VKUI_9 = 57, VKUI_COLON = 58, VKUI_SEMICOLON = 59, VKUI_LESS = 60, VKUI_EQUALS = 61, VKUI_GREATER = 62, VKUI_QUESTION = 63, VKUI_AT = 64, VKUI_LEFTBRACKET = 91, VKUI_BACKSLASH = 92, VKUI_RIGHTBRACKET = 93, VKUI_CARET = 94, VKUI_UNDERSCORE = 95, VKUI_BACKQUOTE = 96, VKUI_A = 97, VKUI_B = 98, VKUI_C = 99, VKUI_D = 100, VKUI_E = 101, VKUI_F = 102, VKUI_G = 103, VKUI_H = 104, VKUI_I = 105, VKUI_J = 106, VKUI_K = 107, VKUI_L = 108, VKUI_M = 109, VKUI_N = 110, VKUI_O = 111, VKUI_P = 112, VKUI_Q = 113, VKUI_R = 114, VKUI_S = 115, VKUI_T = 116, VKUI_U = 117, VKUI_V = 118, VKUI_W = 119, VKUI_X = 120, VKUI_Y = 121, VKUI_Z = 122, VKUI_DELETE = 127, // numeric pad VKUI_KP0 = 256, VKUI_KP1 = 257, VKUI_KP2 = 258, VKUI_KP3 = 259, VKUI_KP4 = 260, VKUI_KP5 = 261, VKUI_KP6 = 262, VKUI_KP7 = 263, VKUI_KP8 = 264, VKUI_KP9 = 265, VKUI_KP_PERIOD = 266, VKUI_KP_DIVIDE = 267, VKUI_KP_MULTIPLY = 268, VKUI_KP_MINUS = 269, VKUI_KP_PLUS = 270, VKUI_KP_ENTER = 271, VKUI_KP_EQUALS = 272, VKUI_UP = 273, VKUI_DOWN = 274, VKUI_RIGHT = 275, VKUI_LEFT = 276, VKUI_INSERT = 277, VKUI_HOME = 278, VKUI_END = 279, VKUI_PAGEUP = 280, VKUI_PAGEDOWN = 281, VKUI_F1 = 282, VKUI_F2 = 283, VKUI_F3 = 284, VKUI_F4 = 285, VKUI_F5 = 286, VKUI_F6 = 287, VKUI_F7 = 288, VKUI_F8 = 289, VKUI_F9 = 290, VKUI_F10 = 291, VKUI_F11 = 292, VKUI_F12 = 293, VKUI_F13 = 294, VKUI_F14 = 295, VKUI_F15 = 296, VKUI_NUMLOCK = 300, //VKUI_CAPSLOCK = 301, VKUI_SCROLLOCK = 302, VKUI_RSHIFT = 303, VKUI_LSHIFT = 304, VKUI_RCTRL = 305, VKUI_LCTRL = 306, VKUI_RALT = 307, VKUI_LALT = 308, VKUI_RMETA = 309, VKUI_LMETA = 310, VKUI_LSUPER = 311, VKUI_RSUPER = 312, VKUI_MODE = 313, VKUI_COMPOSE = 314, VKUI_HELP = 315, VKUI_PRINT = 316, VKUI_SYSREQ = 317, VKUI_BREAK = 318, VKUI_MENU = 319, VKUI_EURO = 321 }; enum Modifiers { MOD_NONE = 0x0000, MOD_LSHIFT= 0x0001, MOD_RSHIFT= 0x0002, MOD_LCTRL = 0x0040, MOD_RCTRL = 0x0080, MOD_LALT = 0x0100, MOD_RALT = 0x0200, MOD_LMETA = 0x0400, MOD_RMETA = 0x0800, MOD_NUM = 0x1000, MOD_CAPS = 0x2000, MOD_MODE = 0x4000, MOD_RESERVED = 0x8000 }; int getKeyCode() const { return m_keyCode; } int getModifier() const { return m_modifiers; } private: int m_keyCode; int m_modifiers; }; } }
20.538095
90
0.517273
798952a586ff05557224b3a227fbf2839b57b9eb
39,997
c
C
lean/pkgs/c32sat/src/aig_vector.c
uw-unsat/exoverifier
da64f040db04614be81d9d465179fa3e0e2cd0c4
[ "Apache-2.0" ]
5
2021-09-23T16:06:19.000Z
2022-02-17T18:08:25.000Z
lean/pkgs/c32sat/src/aig_vector.c
uw-unsat/exoverifier
da64f040db04614be81d9d465179fa3e0e2cd0c4
[ "Apache-2.0" ]
null
null
null
lean/pkgs/c32sat/src/aig_vector.c
uw-unsat/exoverifier
da64f040db04614be81d9d465179fa3e0e2cd0c4
[ "Apache-2.0" ]
1
2021-11-05T23:35:03.000Z
2021-11-05T23:35:03.000Z
/* Institute for Formal Models and Verification (FMV), Johannes Kepler University Linz, Austria Copyright (c) 2006, Robert Daniel Brummayer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the FMV 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 <assert.h> #include <stdlib.h> #include <stdio.h> #include "aig.h" #include "aig_vector.h" #include "c32sat_math.h" #include "memory_management.h" #include "config.h" AIGVector * create_aig_vector () { int i = 0; AIGVector *result = (AIGVector *) malloc_c32sat (sizeof (AIGVector)); result->aig = (AIG **) malloc_c32sat (sizeof (AIG *) * ext_number_of_bits); for (i = 0; i < ext_number_of_bits; i++) { result->aig[i] = AIG_FALSE; } result->undefined = AIG_FALSE; return result; } void delete_aig_vector (AIGVector * aig_vector) { assert (aig_vector != NULL); free_c32sat (aig_vector->aig, sizeof (AIG *) * ext_number_of_bits); free_c32sat (aig_vector, sizeof (AIGVector)); } AIGVector * copy_aig_vector (AIGUniqueTable ** table, AIGVector * aig_vector) { int i = 0; AIGVector *result = NULL; assert (table != NULL && *table != NULL && aig_vector != NULL); result = create_aig_vector (); for (i = 0; i < ext_number_of_bits; i++) { result->aig[i] = copy_aig (table, aig_vector->aig[i]); } result->undefined = copy_aig (table, aig_vector->undefined); return result; } void release_aig_vector (AIGUniqueTable ** table, AIGVector * aig_vector) { int i = 0; assert (table != NULL && *table != NULL && aig_vector != NULL); for (i = 0; i < ext_number_of_bits; i++) { release_aig (table, aig_vector->aig[i]); } release_aig (table, aig_vector->undefined); } long long int aig_vector_2_long_long (AIGVector * aig_vector) { int bin[ext_number_of_bits]; int i = 0; assert (aig_vector != NULL); for (i = 0; i < ext_number_of_bits; i++) { assert (is_aig_constant (aig_vector->aig[i])); bin[i] = aig_vector->aig[i] == AIG_TRUE ? 1 : 0; } return bin_2_long_long_c32sat_math (bin, ext_number_of_bits); } void long_long_2_aig_vector (long long int x, AIGVector * result) { int bin[ext_number_of_bits]; int i = 0; assert (result != NULL); long_long_2_bin_c32sat_math (x, bin, ext_number_of_bits); for (i = 0; i < ext_number_of_bits; i++) { result->aig[i] = bin[i] ? AIG_TRUE : AIG_FALSE; } } AIG * conjunction_aig_vector (AIGUniqueTable ** table, AIGVector * aig_vector) { AIG *temp[ext_number_of_bits]; int i = 0; assert (table != NULL && aig_vector != NULL); for (i = 0; i < ext_number_of_bits; i++) { temp[i] = aig_vector->aig[i]; } return and_aig_array (table, temp, ext_number_of_bits); } AIG * disjunction_aig_vector (AIGUniqueTable ** table, AIGVector * aig_vector) { AIG *temp[ext_number_of_bits]; int i = 0; assert (table != NULL && aig_vector != NULL); for (i = 0; i < ext_number_of_bits; i++) { temp[i] = aig_vector->aig[i]; } return or_aig_array (table, temp, ext_number_of_bits); } AIGVector * not_aig_vector (AIGUniqueTable ** table, AIGVector * x) { AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL); result = create_aig_vector (); result->aig[0] = invert_aig (disjunction_aig_vector (table, x)); result->undefined = copy_aig (table, x->undefined); return result; } AIGVector * and_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *temp3 = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); temp1 = disjunction_aig_vector (table, x); temp2 = disjunction_aig_vector (table, y); result->aig[0] = and_aig (table, temp1, temp2); temp3 = and_aig (table, temp1, y->undefined); result->undefined = or_aig(table, x->undefined, temp3); release_aig (table, temp1); release_aig (table, temp2); release_aig (table, temp3); return result; } AIGVector * or_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *temp3 = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); temp1 = disjunction_aig_vector (table, x); temp2 = disjunction_aig_vector (table, y); result->aig[0] = or_aig (table, temp1, temp2); temp3 = and_aig (table, invert_aig (temp1), y->undefined); result->undefined = or_aig (table, x->undefined, temp3); release_aig (table, temp1); release_aig (table, temp2); release_aig (table, temp3); return result; } AIGVector * imp_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIGVector *not_x = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); not_x = not_aig_vector (table, x); result = or_aig_vector (table, not_x, y); release_aig_vector (table, not_x); delete_aig_vector (not_x); return result; } AIGVector * dimp_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *temp3 = NULL; AIG *temp4 = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); temp1 = disjunction_aig_vector (table, x); temp2 = disjunction_aig_vector (table, y); temp3 = or_aig (table, invert_aig (temp1), temp2); temp4 = or_aig (table, temp1, invert_aig (temp2)); result->aig[0] = and_aig (table, temp3, temp4); release_aig (table, temp1); release_aig (table, temp2); release_aig (table, temp3); release_aig (table, temp4); result->undefined = or_aig (table, x->undefined, y->undefined); return result; } void invert_aig_vector (AIGVector * aig_vector) { int i = 0; assert (aig_vector != NULL); for (i = 0; i < ext_number_of_bits; i++) { aig_vector->aig[i] = invert_aig (aig_vector->aig[i]); } } AIGVector * band_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { int i = 0; AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); for (i = 0; i < ext_number_of_bits; i++) { result->aig[i] = and_aig (table, x->aig[i], y->aig[i]); } result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * bor_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { int i = 0; AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); for (i = 0; i < ext_number_of_bits; i++) { result->aig[i] = or_aig (table, x->aig[i], y->aig[i]); } result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * bxor_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { int i = 0; AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); for (i = 0; i < ext_number_of_bits; i++) { result->aig[i] = xor_aig (table, x->aig[i], y->aig[i]); } result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * add_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { int i = 0; AIG *carry = AIG_FALSE; AIG *temp = AIG_FALSE; AIG *temp2 = NULL; AIG *overflow = NULL; AIGVector *result = create_aig_vector (); assert (table != NULL && x != NULL && y != NULL); for (i = 0; i < ext_number_of_bits - 1; i++) { result->aig[i] = full_add_aig (table, x->aig[i], y->aig[i], carry, &temp); release_aig (table, carry); carry = temp; } result->aig[ext_number_of_bits - 1] = xor_aig_va_list (table, 3, x->aig[ext_number_of_bits - 1], y->aig[ext_number_of_bits - 1], carry); temp = dimp_aig (table, x->aig[ext_number_of_bits - 1], y->aig[ext_number_of_bits - 1]); temp2 = dimp_aig (table, x->aig[ext_number_of_bits - 1], result->aig[ext_number_of_bits - 1]); overflow = and_aig (table, temp, invert_aig (temp2)); if (ext_allow_overflow) { result->undefined = or_aig (table, x->undefined, y->undefined); } else { result->undefined = or_aig_va_list (table, 3, x->undefined, y->undefined, overflow); } release_aig (table, carry); release_aig (table, temp); release_aig (table, temp2); release_aig (table, overflow); return result; } AIGVector * unary_minus_aig_vector (AIGUniqueTable ** table, AIGVector * x) { int i = 0; AIGVector *temp_vector = NULL; AIGVector *one = NULL; AIGVector *result = NULL; AIG *temp = NULL; assert (table != NULL && x != NULL); temp_vector = create_aig_vector (); one = create_aig_vector (); one->aig[0] = AIG_TRUE; for (i = 0; i < ext_number_of_bits; i++) { temp_vector->aig[i] = invert_aig (x->aig[i]); } result = add_aig_vector (table, temp_vector, one); temp = result->undefined; result->undefined = or_aig (table, x->undefined, temp); release_aig (table, temp); delete_aig_vector (one); delete_aig_vector (temp_vector); return result; } static AIGVector * twos_complement_aig_vector (AIGUniqueTable ** table, AIGVector * x) { AIGVector *result = NULL; assert (table != NULL && x != NULL); result = unary_minus_aig_vector (table, x); release_aig (table, result->undefined); result->undefined = copy_aig (table, x->undefined); return result; } AIGVector * subtract_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIGVector *temp_vector = NULL; AIGVector *zero = NULL; AIGVector *int_min = NULL; AIGVector *greater_equal_zero = NULL; AIGVector *is_int_min = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); zero = create_aig_vector (); int_min = create_aig_vector (); int_min->aig[ext_number_of_bits - 1] = AIG_TRUE; temp_vector = twos_complement_aig_vector (table, y); result = add_aig_vector (table, x, temp_vector); greater_equal_zero = greater_than_or_equal_aig_vector (table, x, zero); is_int_min = eq_aig_vector (table, y, int_min); temp1 = and_aig (table, result->undefined, invert_aig (is_int_min->aig[0])); temp2 = and_aig (table, greater_equal_zero->aig[0], is_int_min->aig[0]); release_aig (table, result->undefined); if (ext_allow_overflow) { result->undefined = or_aig (table, x->undefined, y->undefined); } else { result->undefined = or_aig_va_list (table, 4, temp1, temp2, x->undefined, y->undefined); } release_aig (table, temp1); release_aig (table, temp2); release_aig_vector (table, temp_vector); release_aig_vector (table, greater_equal_zero); release_aig_vector (table, is_int_min); delete_aig_vector (temp_vector); delete_aig_vector (greater_equal_zero); delete_aig_vector (is_int_min); delete_aig_vector (zero); delete_aig_vector (int_min); return result; } AIGVector * eq_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { int i = 0; AIGVector *result = NULL; AIGVector *temp = NULL; assert (table != NULL && x != NULL && y != NULL); result = create_aig_vector (); temp = create_aig_vector (); for (i = 0; i < ext_number_of_bits; i++) { temp->aig[i] = dimp_aig (table, x->aig[i], y->aig[i]); } result->aig[0] = conjunction_aig_vector (table, temp); release_aig_vector (table, temp); delete_aig_vector (temp); result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * neq_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; assert (table != NULL && x != NULL && y != NULL); result = eq_aig_vector (table, x, y); result->aig[0] = invert_aig (result->aig[0]); return result; } void ripple_compare_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y, AIG ** lt, AIG ** eq, AIG ** gt) { int i = 0; AIG *lt_in = NULL; AIG *eq_in = NULL; AIG *gt_in = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL && lt != NULL && eq != NULL && gt != NULL); lt_in = and_aig (table, x->aig[ext_number_of_bits - 1], invert_aig (y->aig[ext_number_of_bits - 1])); eq_in = dimp_aig (table, x->aig[ext_number_of_bits - 1], y->aig[ext_number_of_bits - 1]); gt_in = and_aig (table, invert_aig (x->aig[ext_number_of_bits - 1]), y->aig[ext_number_of_bits - 1]); for (i = ext_number_of_bits - 2; i >= 0; i--) { ripple_compare_aig (table, x->aig[i], y->aig[i], lt_in, eq_in, gt_in, lt, eq, gt); release_aig (table, lt_in); release_aig (table, eq_in); release_aig (table, gt_in); lt_in = *lt; eq_in = *eq; gt_in = *gt; } } AIGVector * less_than_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIG *lt = NULL; AIG *eq = NULL; AIG *gt = NULL; AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); ripple_compare_aig_vector (table, x, y, &lt, &eq, &gt); result->aig[0] = lt; release_aig (table, eq); release_aig (table, gt); result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * less_than_or_equal_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIG *lt = NULL; AIG *eq = NULL; AIG *gt = NULL; AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); ripple_compare_aig_vector (table, x, y, &lt, &eq, &gt); result->aig[0] = xor_aig (table, lt, eq); release_aig (table, lt); release_aig (table, eq); release_aig (table, gt); result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * greater_than_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIG *lt = NULL; AIG *eq = NULL; AIG *gt = NULL; AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); ripple_compare_aig_vector (table, x, y, &lt, &eq, &gt); result->aig[0] = gt; release_aig (table, lt); release_aig (table, eq); result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * greater_than_or_equal_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIG *lt = NULL; AIG *eq = NULL; AIG *gt = NULL; AIGVector *result = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = create_aig_vector (); ripple_compare_aig_vector (table, x, y, &lt, &eq, &gt); result->aig[0] = xor_aig (table, gt, eq); release_aig (table, lt); release_aig (table, eq); release_aig (table, gt); result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * shift_n_bits_left_aig_vector (AIGUniqueTable ** table, AIGVector * x, int bits, AIG * shift) { AIGVector *result = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *temp3 = NULL; int i = 0; assert (table != NULL && *table != NULL && x != NULL && bits >= 0 && bits < ext_number_of_bits); if (bits == 0) { return copy_aig_vector (table, x); } result = create_aig_vector (); for (i = 0; i < bits; i++) { temp1 = and_aig (table, x->aig[i], invert_aig (shift)); temp2 = and_aig (table, AIG_FALSE, shift); result->aig[i] = or_aig (table, temp1, temp2); release_aig (table, temp1); release_aig (table, temp2); } for (i = bits; i < ext_number_of_bits; i++) { temp1 = and_aig (table, x->aig[i], invert_aig (shift)); temp2 = and_aig (table, x->aig[i - bits], shift); result->aig[i] = or_aig (table, temp1, temp2); release_aig (table, temp1); release_aig (table, temp2); } /* is the result of shifting x left by n bits defined ? */ temp2 = dimp_aig (table, x->aig[ext_number_of_bits - 1], x->aig[ext_number_of_bits - 2]); for (i = 2; i <= bits; i++) { temp1 = dimp_aig (table, x->aig[ext_number_of_bits - 1], x->aig[ext_number_of_bits - 1 - i]); temp3 = and_aig (table, temp2, temp1); release_aig (table, temp1); release_aig (table, temp2); temp2 = temp3; } temp3 = and_aig (table, invert_aig (temp2), shift); result->undefined = or_aig (table, x->undefined, temp3); release_aig (table, temp2); release_aig (table, temp3); return result; } AIGVector * shift_n_bits_right_aig_vector (AIGUniqueTable ** table, AIGVector * x, int bits, AIG * shift) { AIGVector *result = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *temp3 = NULL; int i = 0; assert (table != NULL && *table != NULL && x != NULL && bits >= 0 && bits < ext_number_of_bits); if (bits == 0) { return copy_aig_vector (table, x); } result = create_aig_vector (); for (i = 0; i < ext_number_of_bits - bits; i++) { temp1 = and_aig (table, x->aig[i], invert_aig (shift)); temp2 = and_aig (table, x->aig[i + bits], shift); result->aig[i] = or_aig (table, temp1, temp2); release_aig (table, temp1); release_aig (table, temp2); } for (i = ext_number_of_bits - bits; i < ext_number_of_bits; i++) { temp1 = and_aig (table, x->aig[i], invert_aig (shift)); temp2 = or_aig (table, x->aig[ext_number_of_bits - 1], AIG_FALSE); temp3 = and_aig (table, temp2, shift); result->aig[i] = or_aig (table, temp1, temp3); release_aig (table, temp1); release_aig (table, temp2); release_aig (table, temp3); } result->undefined = copy_aig (table, x->undefined); return result; } AIGVector * shift_left_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIGVector *temp32 = NULL; AIGVector *greater_equal_bit_width = NULL; AIGVector *bit_width = NULL; AIG *overflow = NULL; int i = 0; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = shift_n_bits_left_aig_vector (table, x, 1, y->aig[0]); for (i = 1; i < log2_c32sat_math (ext_number_of_bits); i++) { temp32 = result; result = shift_n_bits_left_aig_vector (table, temp32, (int) pow2_c32sat_math (i), y->aig[i]); release_aig_vector (table, temp32); delete_aig_vector (temp32); } bit_width = create_aig_vector (); long_long_2_aig_vector (ext_number_of_bits, bit_width); greater_equal_bit_width = greater_than_or_equal_aig_vector (table, y, bit_width); overflow = result->undefined; if (ext_allow_overflow) { result->undefined = or_aig_va_list (table, 4, x->undefined, y->undefined, y->aig[ext_number_of_bits - 1], greater_equal_bit_width->aig[0]); } else { result->undefined = or_aig_va_list (table, 5, x->undefined, y->undefined, y->aig[ext_number_of_bits - 1], overflow, greater_equal_bit_width->aig[0]); } release_aig (table, overflow); release_aig_vector (table, greater_equal_bit_width); delete_aig_vector (bit_width); delete_aig_vector (greater_equal_bit_width); return result; } AIGVector * shift_right_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIGVector *temp32 = NULL; AIGVector *greater_equal_bit_width = NULL; AIGVector *bit_width = NULL; int i = 0; assert (table != NULL && *table != NULL && x != NULL && y != NULL); result = shift_n_bits_right_aig_vector (table, x, 1, y->aig[0]); for (i = 1; i < log2_c32sat_math (ext_number_of_bits); i++) { temp32 = result; result = shift_n_bits_right_aig_vector (table, temp32, (int) pow2_c32sat_math (i), y->aig[i]); release_aig_vector (table, temp32); delete_aig_vector (temp32); } release_aig (table, result->undefined); /* right operand may not be >= bit width. left shift operand and right shift operand may not be negative */ bit_width = create_aig_vector (); long_long_2_aig_vector (ext_number_of_bits, bit_width); greater_equal_bit_width = greater_than_or_equal_aig_vector (table, y, bit_width); result->undefined = or_aig_va_list (table, 5, x->undefined, y->undefined, x->aig[ext_number_of_bits - 1], y->aig[ext_number_of_bits - 1], greater_equal_bit_width->aig[0]); release_aig_vector (table, greater_equal_bit_width); delete_aig_vector (bit_width); delete_aig_vector (greater_equal_bit_width); return result; } AIGVector * shift_and_add_multiplication (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *result = NULL; AIGVector *temp32_1 = NULL; AIGVector *temp32_2 = NULL; AIGVector *temp32_3 = NULL; int i = 0; int j = 0; assert (table != NULL && *table != NULL && x != NULL && y != NULL); temp32_1 = create_aig_vector (); result = create_aig_vector (); for (i = 0; i < ext_number_of_bits; i++) { for (j = 0; j < ext_number_of_bits; j++) { temp32_1->aig[j] = and_aig (table, x->aig[j], y->aig[i]); } temp32_2 = shift_n_bits_left_aig_vector (table, temp32_1, i, AIG_TRUE); temp32_3 = add_aig_vector (table, result, temp32_2); release_aig_vector (table, result); delete_aig_vector (result); result = temp32_3; release_aig_vector (table, temp32_2); delete_aig_vector (temp32_2); release_aig_vector (table, temp32_1); } delete_aig_vector (temp32_1); release_aig (table, result->undefined); result->undefined = or_aig (table, x->undefined, y->undefined); return result; } AIGVector * add_aig_vector_carry_out (AIGUniqueTable ** table, AIGVector * x, AIGVector * y, AIG ** carry_out) { int i = 0; AIG *carry = AIG_FALSE; AIG *temp = NULL; AIGVector *result = create_aig_vector (); assert (table != NULL && x != NULL && y != NULL && carry_out != NULL); for (i = 0; i < ext_number_of_bits - 1; i++) { result->aig[i] = full_add_aig (table, x->aig[i], y->aig[i], carry, &temp); release_aig (table, carry); carry = temp; } result->aig[ext_number_of_bits - 1] = xor_aig_va_list (table, 3, x->aig[ext_number_of_bits - 1], y->aig[ext_number_of_bits - 1], carry); *carry_out = carry; assert (result->undefined == AIG_FALSE); result->undefined = or_aig_va_list (table, 3, carry, x->undefined, y->undefined); return result; } AIGVector * shift_and_add_multiplication_no_overflow (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *x_comp = NULL; AIGVector *y_comp = NULL; AIGVector *is_x_neg = NULL; AIGVector *is_x_zero = NULL; AIGVector *is_x_one = NULL; AIGVector *is_x_int_min = NULL; AIGVector *is_y_neg = NULL; AIGVector *is_y_zero = NULL; AIGVector *is_y_one = NULL; AIGVector *is_y_int_min = NULL; AIGVector *is_result_int_min = NULL; AIGVector *need_neg_result = NULL; AIGVector *normalised_x = NULL; AIGVector *normalised_y = NULL; AIGVector *normalised_result = NULL; AIGVector *zero = NULL; AIGVector *one = NULL; AIGVector *int_min = NULL; AIGVector *result = NULL; AIGVector *result_comp = NULL; AIGVector *and_result = NULL; AIGVector *shift_result = NULL; AIGVector *add_result = NULL; AIGVector *num_carries = NULL; AIGVector *no_carry_overflow_occurred = NULL; AIGVector *temp_carry = NULL; AIGVector *temp_carry_sum_result = NULL; AIG *is_x_zero_or_one = NULL; AIG *is_y_zero_or_one = NULL; AIG *special_overflow_case = NULL; AIG *overflow_occurred = NULL; AIG *overflow_correction = NULL; AIG *overflow = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *carry_out = NULL; int i = 0; int j = 0; assert (table != NULL && *table != NULL && x != NULL && y != NULL); and_result = create_aig_vector (); result = create_aig_vector (); num_carries = create_aig_vector (); x_comp = twos_complement_aig_vector (table, x); y_comp = twos_complement_aig_vector (table, y); zero = create_aig_vector (); one = create_aig_vector (); one->aig[0] = AIG_TRUE; int_min = create_aig_vector (); int_min->aig[ext_number_of_bits - 1] = AIG_TRUE; is_x_neg = less_than_aig_vector (table, x, zero); is_x_zero = eq_aig_vector (table, x, zero); is_x_one = eq_aig_vector (table, x, one); is_x_int_min = eq_aig_vector (table, x, int_min); is_y_neg = less_than_aig_vector (table, y, zero); is_y_zero = eq_aig_vector (table, y, zero); is_y_one = eq_aig_vector (table, y, one); is_y_int_min = eq_aig_vector (table, y, int_min); need_neg_result = create_aig_vector (); normalised_x = if_then_else_aig_vector (table, is_x_neg, x_comp, x); normalised_y = if_then_else_aig_vector (table, is_y_neg, y_comp, y); for (i = 0; i < ext_number_of_bits; i++) { for (j = 0; j < ext_number_of_bits; j++) { and_result->aig[j] = and_aig (table, normalised_x->aig[j], normalised_y->aig[i]); } shift_result = shift_n_bits_left_aig_vector (table, and_result, i, AIG_TRUE); add_result = add_aig_vector_carry_out (table, result, shift_result, &carry_out); release_aig_vector (table, result); delete_aig_vector (result); result = add_result; temp_carry = create_aig_vector (); temp_carry->aig[0] = carry_out; temp_carry_sum_result = add_aig_vector (table, num_carries, temp_carry); release_aig_vector (table, num_carries); delete_aig_vector (num_carries); num_carries = temp_carry_sum_result; release_aig_vector (table, shift_result); delete_aig_vector (shift_result); release_aig_vector (table, and_result); release_aig (table, carry_out); delete_aig_vector (temp_carry); } no_carry_overflow_occurred = eq_aig_vector (table, num_carries, zero); is_result_int_min = eq_aig_vector (table, result, int_min); result_comp = twos_complement_aig_vector (table, result); temp1 = and_aig (table, is_x_neg->aig[0], invert_aig (is_y_neg->aig[0])); temp2 = and_aig (table, invert_aig (is_x_neg->aig[0]), is_y_neg->aig[0]); need_neg_result->aig[0] = or_aig (table, temp1, temp2); normalised_result = if_then_else_aig_vector (table, need_neg_result, result_comp, result); release_aig (table, temp1); release_aig (table, temp2); release_aig_vector (table, x_comp); release_aig_vector (table, y_comp); release_aig_vector (table, result_comp); release_aig_vector (table, normalised_x); release_aig_vector (table, normalised_y); delete_aig_vector (and_result); delete_aig_vector (x_comp); delete_aig_vector (y_comp); delete_aig_vector (result_comp); delete_aig_vector (normalised_x); delete_aig_vector (normalised_y); delete_aig_vector (zero); delete_aig_vector (one); delete_aig_vector (int_min); /* is the result undefined ? */ is_x_zero_or_one = or_aig (table, is_x_zero->aig[0], is_x_one->aig[0]); is_y_zero_or_one = or_aig (table, is_y_zero->aig[0], is_y_one->aig[0]); temp1 = and_aig (table, invert_aig (is_x_zero_or_one), is_y_int_min->aig[0]); temp2 = and_aig (table, invert_aig (is_y_zero_or_one), is_x_int_min->aig[0]); special_overflow_case = or_aig (table, temp1, temp2); release_aig (table, temp1); release_aig (table, temp2); overflow_occurred = normalised_result->undefined; overflow_correction = and_aig_va_list (table, 3, need_neg_result->aig[0], is_result_int_min->aig[0], no_carry_overflow_occurred->aig[0]); overflow = and_aig (table, overflow_occurred, invert_aig (overflow_correction)); normalised_result->undefined = or_aig_va_list (table, 4, x->undefined, y->undefined, overflow, special_overflow_case); release_aig (table, overflow); release_aig (table, overflow_correction); release_aig (table, special_overflow_case); release_aig (table, is_x_zero_or_one); release_aig (table, is_y_zero_or_one); release_aig (table, overflow_occurred); release_aig_vector (table, num_carries); release_aig_vector (table, no_carry_overflow_occurred); release_aig_vector (table, is_x_neg); release_aig_vector (table, is_x_zero); release_aig_vector (table, is_x_one); release_aig_vector (table, is_x_int_min); release_aig_vector (table, is_y_neg); release_aig_vector (table, is_y_zero); release_aig_vector (table, is_y_one); release_aig_vector (table, is_y_int_min); release_aig_vector (table, is_result_int_min); release_aig_vector (table, result); release_aig_vector (table, need_neg_result); delete_aig_vector (is_x_neg); delete_aig_vector (is_x_zero); delete_aig_vector (is_x_one); delete_aig_vector (is_x_int_min); delete_aig_vector (is_y_neg); delete_aig_vector (is_y_zero); delete_aig_vector (is_y_one); delete_aig_vector (is_y_int_min); delete_aig_vector (num_carries); delete_aig_vector (no_carry_overflow_occurred); delete_aig_vector (is_result_int_min); delete_aig_vector (need_neg_result); delete_aig_vector (result); return normalised_result; } AIGVector * multiply_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { assert (table != NULL && *table != NULL && x != NULL && y != NULL); if (ext_allow_overflow) { return shift_and_add_multiplication (table, x, y); } else { return shift_and_add_multiplication_no_overflow (table, x, y); } } AIGVector * if_then_else_aig_vector (AIGUniqueTable ** table, AIGVector * condition, AIGVector * if_case, AIGVector * else_case) { int i = 0; AIGVector *result = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *condition_aig = NULL; assert (table != NULL && *table != NULL && condition != NULL && if_case != NULL && else_case != NULL); result = create_aig_vector (); condition_aig = disjunction_aig_vector (table, condition); for (i = 0; i < ext_number_of_bits; i++) { temp1 = and_aig (table, if_case->aig[i], condition_aig); temp2 = and_aig (table, else_case->aig[i], invert_aig (condition_aig)); result->aig[i] = or_aig (table, temp1, temp2); release_aig (table, temp1); release_aig (table, temp2); } assert (result->undefined == AIG_FALSE); temp1 = and_aig (table, condition_aig, if_case->undefined); temp2 = and_aig (table, invert_aig (condition_aig), else_case->undefined); result->undefined = or_aig_va_list (table, 3, condition->undefined, temp1, temp2); release_aig (table, condition_aig); release_aig (table, temp1); release_aig (table, temp2); return result; } void divide_and_remainder_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y, AIGVector ** quotient, AIGVector ** remainder) { AIGVector *x_neg_cond = NULL; AIGVector *y_neg_cond = NULL; AIGVector *x_neg = NULL; AIGVector *y_neg = NULL; AIGVector *zero = NULL; AIGVector *divisor_neg = NULL; AIGVector *temp = NULL; AIGVector *quotient_temp = NULL; AIGVector *subtraction_result = NULL; AIGVector *subtraction_result_neg_cond = NULL; AIGVector *quotient_neg = NULL; AIGVector *remainder_neg = NULL; AIGVector *quotient_neg_cond = NULL; AIG *eq = NULL; AIG *gt = NULL; AIG *lt = NULL; int i = 0; assert (table != NULL && *table != NULL && x != NULL && y != NULL && quotient != NULL && remainder != NULL); zero = create_aig_vector (); x_neg_cond = create_aig_vector (); y_neg_cond = create_aig_vector (); /* normalisation */ ripple_compare_aig_vector (table, x, zero, &lt, &eq, &gt); x_neg_cond->aig[0] = lt; release_aig (table, eq); release_aig (table, gt); ripple_compare_aig_vector (table, y, zero, &lt, &eq, &gt); y_neg_cond->aig[0] = lt; release_aig (table, eq); release_aig (table, gt); x_neg = twos_complement_aig_vector (table, x); y_neg = twos_complement_aig_vector (table, y); *quotient = if_then_else_aig_vector (table, x_neg_cond, x_neg, x); *remainder = create_aig_vector (); divisor_neg = if_then_else_aig_vector (table, y_neg_cond, y, y_neg); for (i = 0; i < ext_number_of_bits; i++) { /* shift register pair */ temp = shift_n_bits_left_aig_vector (table, *remainder, 1, AIG_TRUE); release_aig_vector (table, *remainder); delete_aig_vector (*remainder); *remainder = temp; assert ((*remainder)->aig[0] == AIG_FALSE); (*remainder)->aig[0] = copy_aig (table, (*quotient)->aig[ext_number_of_bits - 1]); temp = shift_n_bits_left_aig_vector (table, *quotient, 1, AIG_TRUE); release_aig_vector (table, *quotient); delete_aig_vector (*quotient); *quotient = temp; /* subtract */ subtraction_result = add_aig_vector (table, *remainder, divisor_neg); ripple_compare_aig_vector (table, subtraction_result, zero, &lt, &eq, &gt); subtraction_result_neg_cond = create_aig_vector (); subtraction_result_neg_cond->aig[0] = lt; release_aig (table, eq); release_aig (table, gt); /* compute quotient */ assert ((*quotient)->aig[0] == AIG_FALSE); quotient_temp = copy_aig_vector (table, *quotient); quotient_temp->aig[0] = AIG_TRUE; temp = if_then_else_aig_vector (table, subtraction_result_neg_cond, *quotient, quotient_temp); release_aig_vector (table, *quotient); delete_aig_vector (*quotient); *quotient = temp; /* restore ? */ temp = if_then_else_aig_vector (table, subtraction_result_neg_cond, *remainder, subtraction_result); release_aig_vector (table, *remainder); delete_aig_vector (*remainder); *remainder = temp; /* clean up */ release_aig_vector (table, subtraction_result); release_aig_vector (table, subtraction_result_neg_cond); release_aig_vector (table, quotient_temp); delete_aig_vector (subtraction_result); delete_aig_vector (subtraction_result_neg_cond); delete_aig_vector (quotient_temp); } /* sign quotient and remainder if necessary */ quotient_neg = twos_complement_aig_vector (table, *quotient); quotient_neg_cond = create_aig_vector (); quotient_neg_cond->aig[0] = xor_aig (table, x_neg_cond->aig[0], y_neg_cond->aig[0]); temp = if_then_else_aig_vector (table, quotient_neg_cond, quotient_neg, *quotient); release_aig_vector (table, *quotient); delete_aig_vector (*quotient); *quotient = temp; remainder_neg = twos_complement_aig_vector (table, *remainder); temp = if_then_else_aig_vector (table, x_neg_cond, remainder_neg, *remainder); release_aig_vector (table, *remainder); delete_aig_vector (*remainder); *remainder = temp; /* cleanup */ release_aig_vector (table, x_neg_cond); release_aig_vector (table, y_neg_cond); release_aig_vector (table, x_neg); release_aig_vector (table, y_neg); release_aig_vector (table, divisor_neg); release_aig_vector (table, quotient_neg); release_aig_vector (table, remainder_neg); release_aig_vector (table, quotient_neg_cond); delete_aig_vector (x_neg_cond); delete_aig_vector (y_neg_cond); delete_aig_vector (x_neg); delete_aig_vector (y_neg); delete_aig_vector (divisor_neg); delete_aig_vector (quotient_neg); delete_aig_vector (remainder_neg); delete_aig_vector (quotient_neg_cond); delete_aig_vector (zero); } AIGVector * divide_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *quotient = NULL; AIGVector *remainder = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; AIG *temp3 = NULL; AIG *int_min = NULL; AIG *minus_one = NULL; AIG *temp4 = NULL; AIGVector *int_min_zeros = NULL; int i = 0; assert (table != NULL && *table != NULL && x != NULL && y != NULL); divide_and_remainder_aig_vector (table, x, y, &quotient, &remainder); release_aig_vector (table, remainder); delete_aig_vector (remainder); int_min_zeros = create_aig_vector (); temp1 = or_aig (table, x->undefined, y->undefined); /* x / 0 is undefined */ temp2 = invert_aig (disjunction_aig_vector (table, y)); /* INT_MIN / -1 is undefined ----> overflow */ for (i = 0; i < ext_number_of_bits - 1; i++) { int_min_zeros->aig[i] = x->aig[i]; } assert (int_min_zeros->aig[ext_number_of_bits - 1] == AIG_FALSE); temp3 = invert_aig (disjunction_aig_vector (table, int_min_zeros)); int_min = and_aig (table, x->aig[ext_number_of_bits - 1], temp3); minus_one = conjunction_aig_vector (table, y); temp4 = and_aig (table, int_min, minus_one); release_aig (table, quotient->undefined); if (ext_allow_overflow) { quotient->undefined = or_aig (table, temp1, temp2); } else { quotient->undefined = or_aig_va_list (table, 3, temp1, temp2, temp4); } release_aig (table, temp1); release_aig (table, temp2); release_aig (table, temp3); release_aig (table, int_min); release_aig (table, minus_one); release_aig (table, temp4); delete_aig_vector (int_min_zeros); return quotient; } AIGVector * modulo_aig_vector (AIGUniqueTable ** table, AIGVector * x, AIGVector * y) { AIGVector *quotient = NULL; AIGVector *remainder = NULL; AIG *temp1 = NULL; AIG *temp2 = NULL; assert (table != NULL && *table != NULL && x != NULL && y != NULL); divide_and_remainder_aig_vector (table, x, y, &quotient, &remainder); release_aig_vector (table, quotient); delete_aig_vector (quotient); temp1 = or_aig (table, x->undefined, y->undefined); /* x % 0 is undefined */ temp2 = invert_aig (disjunction_aig_vector (table, y)); release_aig (table, remainder->undefined); remainder->undefined = or_aig (table, temp1, temp2); release_aig (table, temp1); release_aig (table, temp2); return remainder; }
33.695872
84
0.658124
257bf88995147995d721e004ad509c9fd5616e11
20,482
c
C
nimbus_source/001_util-linux-2.20/disk-utils/mkfs.minix.c
isabella232/wireless-media-drive
ab09fbd1194c8148131cf0a37425419253a137b0
[ "Apache-2.0" ]
10
2015-02-28T21:05:37.000Z
2021-09-16T04:57:27.000Z
nimbus_source/001_util-linux-2.20/disk-utils/mkfs.minix.c
SanDisk-Open-Source/wireless-media-drive
ab09fbd1194c8148131cf0a37425419253a137b0
[ "Apache-2.0" ]
1
2021-02-24T05:16:58.000Z
2021-02-24T05:16:58.000Z
nimbus_source/001_util-linux-2.20/disk-utils/mkfs.minix.c
isabella232/wireless-media-drive
ab09fbd1194c8148131cf0a37425419253a137b0
[ "Apache-2.0" ]
5
2018-11-19T16:42:53.000Z
2021-12-07T12:39:23.000Z
/* * mkfs.minix.c - make a linux (minix) file-system. * * (C) 1991 Linus Torvalds. This file may be redistributed as per * the Linux copyright. */ /* * DD.MM.YY * * 24.11.91 - Time began. Used the fsck sources to get started. * * 25.11.91 - Corrected some bugs. Added support for ".badblocks" * The algorithm for ".badblocks" is a bit weird, but * it should work. Oh, well. * * 25.01.92 - Added the -l option for getting the list of bad blocks * out of a named file. (Dave Rivers, rivers@ponds.uucp) * * 28.02.92 - Added %-information when using -c. * * 28.02.93 - Added support for other namelengths than the original * 14 characters so that I can test the new kernel routines.. * * 09.10.93 - Make exit status conform to that required by fsutil * (Rik Faith, faith@cs.unc.edu) * * 31.10.93 - Added inode request feature, for backup floppies: use * 32 inodes, for a news partition use more. * (Scott Heavner, sdh@po.cwru.edu) * * 03.01.94 - Added support for file system valid flag. * (Dr. Wettstein, greg%wind.uucp@plains.nodak.edu) * * 30.10.94 - Added support for v2 filesystem * (Andreas Schwab, schwab@issan.informatik.uni-dortmund.de) * * 09.11.94 - Added test to prevent overwrite of mounted fs adapted * from Theodore Ts'o's (tytso@athena.mit.edu) mke2fs * program. (Daniel Quinlan, quinlan@yggdrasil.com) * * 03.20.95 - Clear first 512 bytes of filesystem to make certain that * the filesystem is not misidentified as a MS-DOS FAT filesystem. * (Daniel Quinlan, quinlan@yggdrasil.com) * * 02.07.96 - Added small patch from Russell King to make the program a * good deal more portable (janl@math.uio.no) * * 06.29.11 - Overall cleanups for util-linux and v3 support * Davidlohr Bueso <dave@gnu.org> * * Usage: mkfs [-c | -l filename ] [-12v3] [-nXX] [-iXX] device [size-in-blocks] * * -c for readablility checking (SLOW!) * -l for getting a list of bad blocks from a file. * -n for namelength (currently the kernel only uses 14 or 30) * -i for number of inodes * -1 for v1 filesystem * -2,-v for v2 filesystem * -3 for v3 filesystem * * The device may be a block device or a image of one, but this isn't * enforced (but it's not much fun on a character device :-). */ #include <stdio.h> #include <time.h> #include <unistd.h> #include <string.h> #include <signal.h> #include <fcntl.h> #include <ctype.h> #include <stdlib.h> #include <termios.h> #include <sys/stat.h> #include <mntent.h> #include <getopt.h> #include <err.h> #include "blkdev.h" #include "minix_programs.h" #include "nls.h" #include "pathnames.h" #include "bitops.h" #include "exitcodes.h" #include "strutils.h" #include "writeall.h" #define MINIX_ROOT_INO 1 #define MINIX_BAD_INO 2 #define TEST_BUFFER_BLOCKS 16 #define MAX_GOOD_BLOCKS 512 #define MINIX_MAX_INODES 65535 /* * Global variables used in minix_programs.h inline fuctions */ int fs_version = 1; char *super_block_buffer; static char *inode_buffer = NULL; #define Inode (((struct minix_inode *) inode_buffer) - 1) #define Inode2 (((struct minix2_inode *) inode_buffer) - 1) static char *program_name = "mkfs"; static char *device_name; static int DEV = -1; static unsigned long long BLOCKS; static int check; static int badblocks; /* * default (changed to 30, per Linus's * suggestion, Sun Nov 21 08:05:07 1993) * This should be changed in the future to 60, * since v3 needs to be the default nowadays (2011) */ static size_t namelen = 30; static size_t dirsize = 32; static int magic = MINIX_SUPER_MAGIC2; static int version2; static char root_block[MINIX_BLOCK_SIZE]; static char boot_block_buffer[512]; static unsigned short good_blocks_table[MAX_GOOD_BLOCKS]; static int used_good_blocks; static unsigned long req_nr_inodes; static char *inode_map; static char *zone_map; #define zone_in_use(x) (isset(zone_map,(x)-get_first_zone()+1) != 0) #define mark_inode(x) (setbit(inode_map,(x))) #define unmark_inode(x) (clrbit(inode_map,(x))) #define mark_zone(x) (setbit(zone_map,(x)-get_first_zone()+1)) #define unmark_zone(x) (clrbit(zone_map,(x)-get_first_zone()+1)) static void __attribute__((__noreturn__)) usage(void) { errx(MKFS_USAGE, _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]"), program_name); } /* * Check to make certain that our new filesystem won't be created on * an already mounted partition. Code adapted from mke2fs, Copyright * (C) 1994 Theodore Ts'o. Also licensed under GPL. */ static void check_mount(void) { FILE * f; struct mntent * mnt; if ((f = setmntent (_PATH_MOUNTED, "r")) == NULL) return; while ((mnt = getmntent (f)) != NULL) if (strcmp (device_name, mnt->mnt_fsname) == 0) break; endmntent (f); if (!mnt) return; errx(MKFS_ERROR, _("%s is mounted; will not make a filesystem here!"), device_name); } static void super_set_state(void) { switch (fs_version) { case 1: case 2: Super.s_state |= MINIX_VALID_FS; Super.s_state &= ~MINIX_ERROR_FS; break; } } static void write_tables(void) { unsigned long imaps = get_nimaps(); unsigned long zmaps = get_nzmaps(); unsigned long buffsz = get_inode_buffer_size(); /* Mark the super block valid. */ super_set_state(); if (lseek(DEV, 0, SEEK_SET)) err(MKFS_ERROR, _("%s: seek to boot block failed " " in write_tables"), device_name); if (write_all(DEV, boot_block_buffer, 512)) err(MKFS_ERROR, _("%s: unable to clear boot sector"), device_name); if (MINIX_BLOCK_SIZE != lseek(DEV, MINIX_BLOCK_SIZE, SEEK_SET)) err(MKFS_ERROR, _("%s: seek failed in write_tables"), device_name); if (write_all(DEV, super_block_buffer, MINIX_BLOCK_SIZE)) err(MKFS_ERROR, _("%s: unable to write super-block"), device_name); if (write_all(DEV, inode_map, imaps * MINIX_BLOCK_SIZE)) err(MKFS_ERROR, _("%s: unable to write inode map"), device_name); if (write_all(DEV, zone_map, zmaps * MINIX_BLOCK_SIZE)) err(MKFS_ERROR, _("%s: unable to write zone map"), device_name); if (write_all(DEV, inode_buffer, buffsz)) err(MKFS_ERROR, _("%s: unable to write inodes"), device_name); } static void write_block(int blk, char * buffer) { if (blk*MINIX_BLOCK_SIZE != lseek(DEV, blk*MINIX_BLOCK_SIZE, SEEK_SET)) errx(MKFS_ERROR, _("%s: seek failed in write_block"), device_name); if (write_all(DEV, buffer, MINIX_BLOCK_SIZE)) errx(MKFS_ERROR, _("%s: write failed in write_block"), device_name); } static int get_free_block(void) { unsigned int blk; unsigned int zones = get_nzones(); unsigned int first_zone = get_first_zone(); if (used_good_blocks+1 >= MAX_GOOD_BLOCKS) errx(MKFS_ERROR, _("%s: too many bad blocks"), device_name); if (used_good_blocks) blk = good_blocks_table[used_good_blocks-1]+1; else blk = first_zone; while (blk < zones && zone_in_use(blk)) blk++; if (blk >= zones) errx(MKFS_ERROR, _("%s: not enough good blocks"), device_name); good_blocks_table[used_good_blocks] = blk; used_good_blocks++; return blk; } static void mark_good_blocks(void) { int blk; for (blk=0 ; blk < used_good_blocks ; blk++) mark_zone(good_blocks_table[blk]); } static inline int next(unsigned long zone) { unsigned long zones = get_nzones(); unsigned long first_zone = get_first_zone(); if (!zone) zone = first_zone-1; while (++zone < zones) if (zone_in_use(zone)) return zone; return 0; } static void make_bad_inode_v1(void) { struct minix_inode * inode = &Inode[MINIX_BAD_INO]; int i,j,zone; int ind=0,dind=0; unsigned short ind_block[MINIX_BLOCK_SIZE>>1]; unsigned short dind_block[MINIX_BLOCK_SIZE>>1]; #define NEXT_BAD (zone = next(zone)) if (!badblocks) return; mark_inode(MINIX_BAD_INO); inode->i_nlinks = 1; inode->i_time = time(NULL); inode->i_mode = S_IFREG + 0000; inode->i_size = badblocks*MINIX_BLOCK_SIZE; zone = next(0); for (i=0 ; i<7 ; i++) { inode->i_zone[i] = zone; if (!NEXT_BAD) goto end_bad; } inode->i_zone[7] = ind = get_free_block(); memset(ind_block,0,MINIX_BLOCK_SIZE); for (i=0 ; i<512 ; i++) { ind_block[i] = zone; if (!NEXT_BAD) goto end_bad; } inode->i_zone[8] = dind = get_free_block(); memset(dind_block,0,MINIX_BLOCK_SIZE); for (i=0 ; i<512 ; i++) { write_block(ind,(char *) ind_block); dind_block[i] = ind = get_free_block(); memset(ind_block,0,MINIX_BLOCK_SIZE); for (j=0 ; j<512 ; j++) { ind_block[j] = zone; if (!NEXT_BAD) goto end_bad; } } errx(MKFS_ERROR, _("%s: too many bad blocks"), device_name); end_bad: if (ind) write_block(ind, (char *) ind_block); if (dind) write_block(dind, (char *) dind_block); } static void make_bad_inode_v2_v3 (void) { struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; int i, j, zone; int ind = 0, dind = 0; unsigned long ind_block[MINIX_BLOCK_SIZE >> 2]; unsigned long dind_block[MINIX_BLOCK_SIZE >> 2]; if (!badblocks) return; mark_inode (MINIX_BAD_INO); inode->i_nlinks = 1; inode->i_atime = inode->i_mtime = inode->i_ctime = time (NULL); inode->i_mode = S_IFREG + 0000; inode->i_size = badblocks * MINIX_BLOCK_SIZE; zone = next (0); for (i = 0; i < 7; i++) { inode->i_zone[i] = zone; if (!NEXT_BAD) goto end_bad; } inode->i_zone[7] = ind = get_free_block (); memset (ind_block, 0, MINIX_BLOCK_SIZE); for (i = 0; i < 256; i++) { ind_block[i] = zone; if (!NEXT_BAD) goto end_bad; } inode->i_zone[8] = dind = get_free_block (); memset (dind_block, 0, MINIX_BLOCK_SIZE); for (i = 0; i < 256; i++) { write_block (ind, (char *) ind_block); dind_block[i] = ind = get_free_block (); memset (ind_block, 0, MINIX_BLOCK_SIZE); for (j = 0; j < 256; j++) { ind_block[j] = zone; if (!NEXT_BAD) goto end_bad; } } /* Could make triple indirect block here */ errx(MKFS_ERROR, _("%s: too many bad blocks"), device_name); end_bad: if (ind) write_block (ind, (char *) ind_block); if (dind) write_block (dind, (char *) dind_block); } static void make_bad_inode(void) { if (fs_version < 2) return make_bad_inode_v1(); return make_bad_inode_v2_v3(); } static void make_root_inode_v1(void) { struct minix_inode * inode = &Inode[MINIX_ROOT_INO]; mark_inode(MINIX_ROOT_INO); inode->i_zone[0] = get_free_block(); inode->i_nlinks = 2; inode->i_time = time(NULL); if (badblocks) inode->i_size = 3*dirsize; else { root_block[2*dirsize] = '\0'; root_block[2*dirsize+1] = '\0'; inode->i_size = 2*dirsize; } inode->i_mode = S_IFDIR + 0755; inode->i_uid = getuid(); if (inode->i_uid) inode->i_gid = getgid(); write_block(inode->i_zone[0],root_block); } static void make_root_inode_v2_v3 (void) { struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; mark_inode (MINIX_ROOT_INO); inode->i_zone[0] = get_free_block (); inode->i_nlinks = 2; inode->i_atime = inode->i_mtime = inode->i_ctime = time (NULL); if (badblocks) inode->i_size = 3 * dirsize; else { root_block[2 * dirsize] = '\0'; if (fs_version == 2) inode->i_size = 2 * dirsize; } inode->i_mode = S_IFDIR + 0755; inode->i_uid = getuid(); if (inode->i_uid) inode->i_gid = getgid(); write_block (inode->i_zone[0], root_block); } static void make_root_inode(void) { if (fs_version < 2) return make_root_inode_v1(); return make_root_inode_v2_v3(); } static void super_set_nzones(void) { switch (fs_version) { case 3: case 2: Super.s_zones = BLOCKS; break; default: /* v1 */ Super.s_nzones = BLOCKS; break; } } static void super_init_maxsize(void) { switch (fs_version) { case 3: Super3.s_max_size = 2147483647L; break; case 2: Super.s_max_size = 0x7fffffff; break; default: /* v1 */ Super.s_max_size = (7+512+512*512)*1024; break; } } static void super_set_map_blocks(unsigned long inodes) { switch (fs_version) { case 3: Super3.s_imap_blocks = UPPER(inodes + 1, BITS_PER_BLOCK); Super3.s_zmap_blocks = UPPER(BLOCKS - (1+get_nimaps()+inode_blocks()), BITS_PER_BLOCK+1); Super3.s_firstdatazone = first_zone_data(); break; default: Super.s_imap_blocks = UPPER(inodes + 1, BITS_PER_BLOCK); Super.s_zmap_blocks = UPPER(BLOCKS - (1+get_nimaps()+inode_blocks()), BITS_PER_BLOCK+1); Super.s_firstdatazone = first_zone_data(); break; } } static void super_set_magic(void) { switch (fs_version) { case 3: Super3.s_magic = magic; break; default: Super.s_magic = magic; break; } } static void setup_tables(void) { unsigned long inodes, zmaps, imaps, zones, i; super_block_buffer = calloc(1, MINIX_BLOCK_SIZE); if (!super_block_buffer) err(MKFS_ERROR, _("%s: unable to alloc buffer for superblock"), device_name); memset(boot_block_buffer,0,512); super_set_magic(); if (fs_version == 3) { Super3.s_log_zone_size = 0; Super3.s_blocksize = BLOCKS; } else { Super.s_log_zone_size = 0; } super_init_maxsize(); super_set_nzones(); zones = get_nzones(); /* some magic nrs: 1 inode / 3 blocks */ if ( req_nr_inodes == 0 ) inodes = BLOCKS/3; else inodes = req_nr_inodes; /* Round up inode count to fill block size */ if (fs_version == 2 || fs_version == 3) inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & ~(MINIX2_INODES_PER_BLOCK - 1)); else inodes = ((inodes + MINIX_INODES_PER_BLOCK - 1) & ~(MINIX_INODES_PER_BLOCK - 1)); if (inodes > MINIX_MAX_INODES) inodes = MINIX_MAX_INODES; if (fs_version == 3) Super3.s_ninodes = inodes; else Super.s_ninodes = inodes; super_set_map_blocks(inodes); imaps = get_nimaps(); zmaps = get_nzmaps(); inode_map = malloc(imaps * MINIX_BLOCK_SIZE); zone_map = malloc(zmaps * MINIX_BLOCK_SIZE); if (!inode_map || !zone_map) err(MKFS_ERROR, _("%s: unable to allocate buffers for maps"), device_name); memset(inode_map,0xff,imaps * MINIX_BLOCK_SIZE); memset(zone_map,0xff,zmaps * MINIX_BLOCK_SIZE); for (i = get_first_zone() ; i<zones ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<=inodes; i++) unmark_inode(i); inode_buffer = malloc(get_inode_buffer_size()); if (!inode_buffer) err(MKFS_ERROR, _("%s: unable to allocate buffer for inodes"), device_name); memset(inode_buffer,0, get_inode_buffer_size()); printf(_("%lu inodes\n"), inodes); printf(_("%lu blocks\n"), zones); printf(_("Firstdatazone=%ld (%ld)\n"), get_first_zone(), first_zone_data()); printf(_("Zonesize=%d\n"),MINIX_BLOCK_SIZE<<get_zone_size()); printf(_("Maxsize=%ld\n\n"),get_max_size()); } /* * Perform a test of a block; return the number of * blocks readable/writeable. */ static long do_check(char * buffer, int try, unsigned int current_block) { long got; /* Seek to the correct loc. */ if (lseek(DEV, current_block * MINIX_BLOCK_SIZE, SEEK_SET) != current_block * MINIX_BLOCK_SIZE ) err(MKFS_ERROR, _("%s: seek failed during testing of blocks"), device_name); /* Try the read */ got = read(DEV, buffer, try * MINIX_BLOCK_SIZE); if (got < 0) got = 0; if (got & (MINIX_BLOCK_SIZE - 1 )) { printf(_("Weird values in do_check: probably bugs\n")); } got /= MINIX_BLOCK_SIZE; return got; } static unsigned int currently_testing = 0; static void alarm_intr(int alnum __attribute__ ((__unused__))) { unsigned long zones = get_nzones(); if (currently_testing >= zones) return; signal(SIGALRM,alarm_intr); alarm(5); if (!currently_testing) return; printf("%d ...", currently_testing); fflush(stdout); } static void check_blocks(void) { int try,got; static char buffer[MINIX_BLOCK_SIZE * TEST_BUFFER_BLOCKS]; unsigned long zones = get_nzones(); unsigned long first_zone = get_first_zone(); currently_testing=0; signal(SIGALRM,alarm_intr); alarm(5); while (currently_testing < zones) { if (lseek(DEV,currently_testing*MINIX_BLOCK_SIZE,SEEK_SET) != currently_testing*MINIX_BLOCK_SIZE) errx(MKFS_ERROR, _("%s: seek failed in check_blocks"), device_name); try = TEST_BUFFER_BLOCKS; if (currently_testing + try > zones) try = zones-currently_testing; got = do_check(buffer, try, currently_testing); currently_testing += got; if (got == try) continue; if (currently_testing < first_zone) errx(MKFS_ERROR, _("%s: bad blocks before data-area: " "cannot make fs"), device_name); mark_zone(currently_testing); badblocks++; currently_testing++; } if (badblocks > 1) printf(_("%d bad blocks\n"), badblocks); else if (badblocks == 1) printf(_("one bad block\n")); } static void get_list_blocks(char *filename) { FILE *listfile; unsigned long blockno; listfile = fopen(filename,"r"); if (listfile == NULL) err(MKFS_ERROR, _("%s: can't open file of bad blocks"), device_name); while (!feof(listfile)) { if (fscanf(listfile,"%ld\n", &blockno) != 1) { printf(_("badblock number input error on line %d\n"), badblocks + 1); errx(MKFS_ERROR, _("%s: cannot read badblocks file"), device_name); } mark_zone(blockno); badblocks++; } fclose(listfile); if(badblocks > 1) printf(_("%d bad blocks\n"), badblocks); else if (badblocks == 1) printf(_("one bad block\n")); } int main(int argc, char ** argv) { int i; char * tmp; struct stat statbuf; char * listfile = NULL; char * p; if (argc && *argv) program_name = *argv; if ((p = strrchr(program_name, '/')) != NULL) program_name = p+1; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); if (argc == 2 && (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) { printf(_("%s (%s)\n"), program_name, PACKAGE_STRING); exit(0); } if (INODE_SIZE * MINIX_INODES_PER_BLOCK != MINIX_BLOCK_SIZE) errx(MKFS_ERROR, _("%s: bad inode size"), device_name); if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != MINIX_BLOCK_SIZE) errx(MKFS_ERROR, _("%s: bad inode size"), device_name); opterr = 0; while ((i = getopt(argc, argv, "ci:l:n:v123")) != -1) switch (i) { case 'c': check=1; break; case 'i': req_nr_inodes = (unsigned long) atol(optarg); break; case 'l': listfile = optarg; break; case 'n': i = strtoul(optarg,&tmp,0); if (*tmp) usage(); if (i == 14) magic = MINIX_SUPER_MAGIC; else if (i == 30) magic = MINIX_SUPER_MAGIC2; else usage(); namelen = i; dirsize = i+2; break; case '1': fs_version = 1; break; case '2': case 'v': /* kept for backwards compatiblitly */ fs_version = 2; version2 = 1; break; case '3': fs_version = 3; break; default: usage(); } argc -= optind; argv += optind; if (argc > 0 && !device_name) { device_name = argv[0]; argc--; argv++; } if (argc > 0) { BLOCKS = strtol(argv[0],&tmp,0); if (*tmp) { printf(_("strtol error: number of blocks not specified")); usage(); } } if (!device_name) { usage(); } check_mount(); /* is it already mounted? */ tmp = root_block; *(short *)tmp = 1; strcpy(tmp+2,"."); tmp += dirsize; *(short *)tmp = 1; strcpy(tmp+2,".."); tmp += dirsize; *(short *)tmp = 2; strcpy(tmp+2,".badblocks"); if (stat(device_name, &statbuf) < 0) err(MKFS_ERROR, _("%s: stat failed"), device_name); if (S_ISBLK(statbuf.st_mode)) DEV = open(device_name,O_RDWR | O_EXCL); else DEV = open(device_name,O_RDWR); if (DEV<0) err(MKFS_ERROR, _("%s: open failed"), device_name); if (S_ISBLK(statbuf.st_mode)) { int sectorsize; if (blkdev_get_sector_size(DEV, &sectorsize) == -1) sectorsize = DEFAULT_SECTOR_SIZE; /* kernel < 2.3.3 */ if (blkdev_is_misaligned(DEV)) warnx(_("%s: device is misaligned"), device_name); if (MINIX_BLOCK_SIZE < sectorsize) errx(MKFS_ERROR, _("block size smaller than physical " "sector size of %s"), device_name); if (!BLOCKS) { if (blkdev_get_size(DEV, &BLOCKS) == -1) errx(MKFS_ERROR, _("cannot determine size of %s"), device_name); BLOCKS /= MINIX_BLOCK_SIZE; } } else if (!S_ISBLK(statbuf.st_mode)) { if (!BLOCKS) BLOCKS = statbuf.st_size / MINIX_BLOCK_SIZE; check=0; } else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) errx(MKFS_ERROR, _("will not try to make filesystem on '%s'"), device_name); if (BLOCKS < 10) errx(MKFS_ERROR, _("%s: number of blocks too small"), device_name); if (fs_version == 3) magic = MINIX3_SUPER_MAGIC; if (fs_version == 2) { if (namelen == 14) magic = MINIX2_SUPER_MAGIC; else magic = MINIX2_SUPER_MAGIC2; } else if (BLOCKS > MINIX_MAX_INODES) BLOCKS = MINIX_MAX_INODES; setup_tables(); if (check) check_blocks(); else if (listfile) get_list_blocks(listfile); make_root_inode(); make_bad_inode(); mark_good_blocks(); write_tables(); close(DEV); return 0; }
25.634543
85
0.677082
c949da10300f50e793ab22b1a035453be27d43b0
3,219
h
C
src/input.h
richfitz/boxr
77d5c9489d0224a980ff712525a96fdcc2d5f7d1
[ "MIT" ]
null
null
null
src/input.h
richfitz/boxr
77d5c9489d0224a980ff712525a96fdcc2d5f7d1
[ "MIT" ]
null
null
null
src/input.h
richfitz/boxr
77d5c9489d0224a980ff712525a96fdcc2d5f7d1
[ "MIT" ]
null
null
null
// if s1 starts with s2 returns true, else false // len is the length of s1 // s2 should be null-terminated static bool starts_with(const char *s1, int len, const char *s2) { int n = 0; while (*s2 && n < len) { if (*s1++ != *s2++) return false; n++; } return *s2 == 0; } // convert escape sequence to event, and return consumed bytes on success (failure == 0) static int parse_escape_seq(struct tb_event *event, const char *buf, int len) { if (len >= 6 && starts_with(buf, len, "\033[M")) { switch (buf[3] & 3) { case 0: if (buf[3] == 0x60) event->key = TB_KEY_MOUSE_WHEEL_UP; else event->key = TB_KEY_MOUSE_LEFT; break; case 1: if (buf[3] == 0x61) event->key = TB_KEY_MOUSE_WHEEL_DOWN; else event->key = TB_KEY_MOUSE_MIDDLE; break; case 2: event->key = TB_KEY_MOUSE_RIGHT; break; case 3: event->key = TB_KEY_MOUSE_RELEASE; break; default: return -6; } event->type = TB_EVENT_MOUSE; // TB_EVENT_KEY by default // the coord is 1,1 for upper left event->x = (uint8_t)buf[4] - 1 - 32; event->y = (uint8_t)buf[5] - 1 - 32; return 6; } // it's pretty simple here, find 'starts_with' match and return // success, else return failure int i; for (i = 0; keys[i]; i++) { if (starts_with(buf, len, keys[i])) { event->ch = 0; event->key = 0xFFFF-i; return strlen(keys[i]); } } return 0; } static bool extract_event(struct tb_event *event, struct bytebuffer *inbuf, int inputmode) { const char *buf = inbuf->buf; const int len = inbuf->len; if (len == 0) return false; if (buf[0] == '\033') { int n = parse_escape_seq(event, buf, len); if (n != 0) { bool success = true; if (n < 0) { success = false; n = -n; } bytebuffer_truncate(inbuf, n); return success; } else { // it's not escape sequence, then it's ALT or ESC, // check inputmode if (inputmode&TB_INPUT_ESC) { // if we're in escape mode, fill ESC event, pop // buffer, return success event->ch = 0; event->key = TB_KEY_ESC; event->mod = 0; bytebuffer_truncate(inbuf, 1); return true; } else if (inputmode&TB_INPUT_ALT) { // if we're in alt mode, set ALT modifier to // event and redo parsing event->mod = TB_MOD_ALT; bytebuffer_truncate(inbuf, 1); return extract_event(event, inbuf, inputmode); } assert(!"never got here"); } } // if we're here, this is not an escape sequence and not an alt sequence // so, it's a FUNCTIONAL KEY or a UNICODE character // first of all check if it's a functional key if ((unsigned char)buf[0] <= TB_KEY_SPACE || (unsigned char)buf[0] == TB_KEY_BACKSPACE2) { // fill event, pop buffer, return success */ event->ch = 0; event->key = (uint16_t)buf[0]; bytebuffer_truncate(inbuf, 1); return true; } // feh... we got utf8 here // check if there is all bytes if (len >= tb_utf8_char_length(buf[0])) { /* everything ok, fill event, pop buffer, return success */ tb_utf8_char_to_unicode(&event->ch, buf); event->key = 0; bytebuffer_truncate(inbuf, tb_utf8_char_length(buf[0])); return true; } // event isn't recognized, perhaps there is not enough bytes in utf8 // sequence return false; }
24.386364
90
0.634048
d710211454363e623d4626b1d30e3a796b0df100
13,640
h
C
feeds/ipq807x/qca-nss-drv/src/nss_ppe.h
ArthurSu0211/wlan-ap
5bf882b0e0225d49860b88d25c9b9ff9bc354516
[ "BSD-3-Clause" ]
2
2021-05-17T02:47:24.000Z
2021-05-17T02:48:01.000Z
feeds/ipq807x/qca-nss-drv/src/nss_ppe.h
ArthurSu0211/wlan-ap
5bf882b0e0225d49860b88d25c9b9ff9bc354516
[ "BSD-3-Clause" ]
1
2021-01-14T18:40:50.000Z
2021-01-14T18:40:50.000Z
feeds/ipq807x/qca-nss-drv/src/nss_ppe.h
ArthurSu0211/wlan-ap
5bf882b0e0225d49860b88d25c9b9ff9bc354516
[ "BSD-3-Clause" ]
3
2021-02-22T04:54:20.000Z
2021-04-13T01:54:40.000Z
/* ************************************************************************** * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all copies. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ************************************************************************** */ /* * nss_ppe.h * NSS PPE header file */ #include <net/sock.h> #include "nss_tx_rx_common.h" #define PPE_BASE_ADDR 0x3a000000 #define PPE_REG_SIZE 0x1000000 #define PPE_L3_DBG_WR_OFFSET 0x200c04 #define PPE_L3_DBG_RD_OFFSET 0x200c0c #define PPE_L3_DBG0_OFFSET 0x10001 #define PPE_L3_DBG1_OFFSET 0x10002 #define PPE_L3_DBG2_OFFSET 0x10003 #define PPE_L3_DBG3_OFFSET 0x10004 #define PPE_L3_DBG4_OFFSET 0x10005 #define PPE_L3_DBG_PORT_OFFSET 0x11e80 #define PPE_PKT_CODE_WR_OFFSET 0x100080 #define PPE_PKT_CODE_RD_OFFSET 0x100084 #define PPE_PKT_CODE_DROP0_OFFSET 0xf000000 #define PPE_PKT_CODE_DROP1_OFFSET 0x10000000 #define PPE_PKT_CODE_CPU_OFFSET 0x40000000 #define PPE_PKT_CODE_DROP0_GET(x) (((x) & 0xe0000000) >> 29) #define PPE_PKT_CODE_DROP1_GET(x) (((x) & 0x7) << 3) #define PPE_PKT_CODE_DROP_GET(d0, d1) (PPE_PKT_CODE_DROP0_GET(d0) | PPE_PKT_CODE_DROP1_GET(d1)) #define PPE_PKT_CODE_CPU_GET(x) (((x) >> 3) & 0xff) #define PPE_IPE_PC_REG 0x100000 /* * NSS_SYS_REG_DROP_CPU_CNT_TBL * Address map and access APIs for DROP_CPU_CNT table. */ #define PPE_DROP_CPU_CNT_TBL_OFFSET 0x60000 #define PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE 0x10 #define PPE_DROP_CPU_CNT_TBL_BASE_OFFSET (PPE_IPE_PC_REG + PPE_DROP_CPU_CNT_TBL_OFFSET) #define PPE_CPU_CODE_MAX_NUM 256 /* * CPU code offset */ #define PPE_CPU_CODE_OFFSET(n) (PPE_DROP_CPU_CNT_TBL_BASE_OFFSET + ((n) * PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE)) /* * DROP code offset */ #define PPE_DROP_CODE_IDX(code, src_port) (PPE_CPU_CODE_MAX_NUM + (8 * (code)) + (src_port)) #define PPE_DROP_CODE_OFFSET(code, src_port) (PPE_DROP_CPU_CNT_TBL_BASE_OFFSET + ((PPE_DROP_CODE_IDX(code, src_port)) * PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE)) #define NSS_PPE_TX_TIMEOUT 1000 /* 1 Second */ /* * Maximum number of VSI */ #define NSS_PPE_VSI_NUM_MAX 32 /* * ppe nss debug stats lock */ extern spinlock_t nss_ppe_stats_lock; /* * Private data structure */ struct nss_ppe_pvt { void * __iomem ppe_base; struct semaphore sem; struct completion complete; int response; void *cb; void *app_data; }; /* * Data structure to store to PPE private context */ extern struct nss_ppe_pvt ppe_pvt; /** * nss_ppe_message_types * Message types for Packet Processing Engine (PPE) requests and responses. * * Note: PPE messages are added as short term approach, expect all * messages below to be deprecated for more integrated approach. */ enum nss_ppe_message_types { NSS_PPE_MSG_SYNC_STATS, NSS_PPE_MSG_IPSEC_PORT_CONFIG, NSS_PPE_MSG_IPSEC_PORT_MTU_CHANGE, NSS_PPE_MSG_IPSEC_ADD_INTF, NSS_PPE_MSG_IPSEC_DEL_INTF, NSS_PPE_MSG_MAX, }; /** * nss_ppe_msg_error_type * PPE error types. */ enum nss_ppe_msg_error_type { PPE_MSG_ERROR_OK, PPE_MSG_ERROR_UNKNOWN_TYPE, PPE_MSG_ERROR_PORT_CREATION_FAIL, PPE_MSG_ERROR_INVALID_PORT_VSI, PPE_MSG_ERROR_INVALID_L3_IF, PPE_MSG_ERROR_IPSEC_PORT_CONFIG, PPE_MSG_ERROR_IPSEC_INTF_TABLE_FULL, PPE_MSG_ERROR_IPSEC_INTF_ATTACHED, PPE_MSG_ERROR_IPSEC_INTF_UNATTACHED, PPE_ERROR_MAX }; /** * nss_ppe_stats_sc * Message structure for per service code stats. */ struct nss_ppe_stats_sc { uint32_t nss_ppe_sc_cb_unregister; /* Per service-code counter for callback not registered */ uint32_t nss_ppe_sc_cb_success; /* Per service-code coutner for successful callback */ uint32_t nss_ppe_sc_cb_failure; /* Per service-code counter for failure callback */ }; /** * nss_ppe_stats * Message structure for ppe general stats */ struct nss_ppe_stats { uint32_t nss_ppe_v4_l3_flows; /**< Number of IPv4 routed flows. */ uint32_t nss_ppe_v4_l2_flows; /**< Number of IPv4 bridge flows. */ uint32_t nss_ppe_v4_create_req; /**< Number of IPv4 create requests. */ uint32_t nss_ppe_v4_create_fail; /**< Number of IPv4 create failures. */ uint32_t nss_ppe_v4_destroy_req; /**< Number of IPv4 delete requests. */ uint32_t nss_ppe_v4_destroy_fail; /**< Number of IPv4 delete failures. */ uint32_t nss_ppe_v4_mc_create_req; /**< Number of IPv4 MC create requests. */ uint32_t nss_ppe_v4_mc_create_fail; /**< Number of IPv4 MC create failure. */ uint32_t nss_ppe_v4_mc_update_req; /**< Number of IPv4 MC update requests. */ uint32_t nss_ppe_v4_mc_update_fail; /**< Number of IPv4 MC update failure. */ uint32_t nss_ppe_v4_mc_destroy_req; /**< Number of IPv4 MC delete requests. */ uint32_t nss_ppe_v4_mc_destroy_fail; /**< Number of IPv4 MC delete failure. */ uint32_t nss_ppe_v4_unknown_interface; /**< Number of IPv4 create failures */ uint32_t nss_ppe_v6_l3_flows; /**< Number of IPv6 routed flows. */ uint32_t nss_ppe_v6_l2_flows; /**< Number of IPv6 bridge flows. */ uint32_t nss_ppe_v6_create_req; /**< Number of IPv6 create requests. */ uint32_t nss_ppe_v6_create_fail; /**< Number of IPv6 create failures. */ uint32_t nss_ppe_v6_destroy_req; /**< Number of IPv6 delete requests. */ uint32_t nss_ppe_v6_destroy_fail; /**< Number of IPv6 delete failures. */ uint32_t nss_ppe_v6_mc_create_req; /**< Number of IPv6 MC create requests. */ uint32_t nss_ppe_v6_mc_create_fail; /**< Number of IPv6 MC create failure. */ uint32_t nss_ppe_v6_mc_update_req; /**< Number of IPv6 MC update requests. */ uint32_t nss_ppe_v6_mc_update_fail; /**< Number of IPv6 MC update failure. */ uint32_t nss_ppe_v6_mc_destroy_req; /**< Number of IPv6 MC delete requests. */ uint32_t nss_ppe_v6_mc_destroy_fail; /**< Number of IPv6 MC delete failure. */ uint32_t nss_ppe_v6_unknown_interface; /**< Number of IPv6 create failures */ uint32_t nss_ppe_fail_vp_full; /**< Request failed because the virtual port table is full */ uint32_t nss_ppe_fail_nh_full; /**< Request failed because the next hop table is full. */ uint32_t nss_ppe_fail_flow_full; /**< Request failed because the flow table is full. */ uint32_t nss_ppe_fail_host_full; /**< Request failed because the host table is full. */ uint32_t nss_ppe_fail_pubip_full; /**< Request failed because the public IP table is full. */ uint32_t nss_ppe_fail_port_setup; /**< Request failed because the PPE port is not setup. */ uint32_t nss_ppe_fail_rw_fifo_full; /**< Request failed because the read/write FIFO is full. */ uint32_t nss_ppe_fail_flow_command; /**< Request failed because the PPE flow command failed. */ uint32_t nss_ppe_fail_unknown_proto; /**< Request failed because of an unknown protocol. */ uint32_t nss_ppe_fail_ppe_unresponsive; /**< Request failed because the PPE is not responding. */ uint32_t nss_ppe_ce_opaque_invalid; /**< Request failed because of invalid opaque in connection entry. */ uint32_t nss_ppe_fail_fqg_full; /**< Request failed because the flow QoS group is full. */ }; /** * nss_ppe_sync_stats_msg * Message information for PPE synchronization statistics. */ struct nss_ppe_sync_stats_msg { struct nss_ppe_stats stats; /**< General stats */ struct nss_ppe_stats_sc sc_stats[NSS_PPE_SC_MAX]; /**< Per service-code stats */ }; /** * nss_ppe_ipsec_port_config_msg * Message structure for inline IPsec port configuration. */ struct nss_ppe_ipsec_port_config_msg { uint32_t nss_ifnum; /**< NSS interface number corresponding to inline IPsec port. */ uint16_t mtu; /**< MTU value for inline IPsec port. */ uint8_t vsi_num; /**< Default port VSI for inline IPsec port. */ }; /** * nss_ppe_ipsec_port_mtu_msg * Message structure for inline IPsec port MTU change. */ struct nss_ppe_ipsec_port_mtu_msg { uint32_t nss_ifnum; /**< NSS interface number corresponding to inline IPsec port. */ uint16_t mtu; /**< MTU value for inline IPsec port. */ }; /** * nss_ppe_ipsec_add_intf_msg * Message structure for adding dynamic IPsec/DTLS interface to inline IPsec port. */ struct nss_ppe_ipsec_add_intf_msg { uint32_t nss_ifnum; /**< Dynamic IPsec/DTLS interface number. */ }; /** * nss_ppe_ipsec_del_intf_msg * Message structure for deleting dynamic IPsec/DTLS interface to inline IPsec port. */ struct nss_ppe_ipsec_del_intf_msg { uint32_t nss_ifnum; /**< Dynamic IPsec/DTLS interface number. */ }; /** * nss_ppe_msg * Data for sending and receiving PPE host-to-NSS messages. */ struct nss_ppe_msg { struct nss_cmn_msg cm; /**< Common message header. */ /** * Payload of a PPE host-to-NSS message. */ union { struct nss_ppe_sync_stats_msg stats; /**< Synchronization statistics. */ struct nss_ppe_ipsec_port_config_msg ipsec_config; /**< PPE inline IPsec port configuration message. */ struct nss_ppe_ipsec_port_mtu_msg ipsec_mtu; /**< Inline IPsec port MTU change message. */ struct nss_ppe_ipsec_add_intf_msg ipsec_addif; /**< Inline IPsec NSS interface attach message. */ struct nss_ppe_ipsec_del_intf_msg ipsec_delif; /**< Inline IPsec NSS interface detach message. */ } msg; /**< Message payload. */ }; /** * Callback function for receiving PPE messages. * * @datatypes * nss_ppe_msg * * @param[in] app_data Pointer to the application context of the message. * @param[in] msg Pointer to the message data. */ typedef void (*nss_ppe_msg_callback_t)(void *app_data, struct nss_ppe_msg *msg); /** * nss_ppe_tx_msg * Sends PPE messages to the NSS. * * @datatypes * nss_ctx_instance \n * nss_ppe_msg * * @param[in] nss_ctx Pointer to the NSS context. * @param[in] msg Pointer to the message data. * * @return * Status of the Tx operation. */ nss_tx_status_t nss_ppe_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ppe_msg *msg); /** * nss_ppe_tx_msg_sync * Sends PPE messages synchronously to the NSS. * * @datatypes * nss_ctx_instance \n * nss_ppe_msg * * @param[in] nss_ctx Pointer to the NSS context. * @param[in,out] msg Pointer to the message data. * * @return * Status of the Tx operation. */ nss_tx_status_t nss_ppe_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_msg *msg); /** * nss_ppe_msg_init * Initializes a PPE message. * * @datatypes * nss_ppe_msg * * @param[in,out] ncm Pointer to the message. * @param[in] if_num Interface number * @param[in] type Type of message. * @param[in] len Size of the payload. * @param[in] cb Callback function for the message. * @param[in] app_data Pointer to the application context of the message. * * @return * None. */ void nss_ppe_msg_init(struct nss_ppe_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); /** * nss_ppe_get_context * Gets the PPE context used in nss_ppe_tx. * * @return * Pointer to the NSS core context. */ struct nss_ctx_instance *nss_ppe_get_context(void); /** * nss_ppe_tx_ipsec_config_msg * Sends the PPE a message to configure inline IPsec port. * * @param[in] if_num Static IPsec interface number. * @param[in] vsi_num Default VSI number associated with inline IPsec port. * @param[in] mtu Default MTU of static inline IPsec port. * @param[in] mru Default MRU of static inline IPsec port. * * @return * Status of the Tx operation. */ nss_tx_status_t nss_ppe_tx_ipsec_config_msg(uint32_t nss_ifnum, uint32_t vsi_num, uint16_t mtu, uint16_t mru); /** * nss_ppe_tx_ipsec_mtu_msg * Sends the PPE a message to configure MTU value on IPsec port. * * @param[in] nss_ifnum Static IPsec interface number. * @param[in] mtu MTU of static IPsec interface. * @param[in] mru MRU of static IPsec interface. * * @return * Status of the Tx operation. */ nss_tx_status_t nss_ppe_tx_ipsec_mtu_msg(uint32_t nss_ifnum, uint16_t mtu, uint16_t mru); /** * nss_ppe_tx_ipsec_add_intf_msg * Sends the PPE a message to attach a dynamic interface number to IPsec port. * * @param[in] if_num Dynamic IPsec/DTLS interface number. * * @return * Status of the Tx operation. */ nss_tx_status_t nss_ppe_tx_ipsec_add_intf_msg(uint32_t nss_ifnum); /** * nss_ppe_tx_ipsec_del_intf_msg * Sends the PPE a message to detach a dynamic interface number to IPsec port. * * @param[in] if_num Dynamic IPsec/DTLS interface number. * * @return * Status of the Tx operation. */ nss_tx_status_t nss_ppe_tx_ipsec_del_intf_msg(uint32_t nss_ifnum); /* * nss_ppe_reg_read() */ static inline void nss_ppe_reg_read(u32 reg, u32 *val) { *val = readl((ppe_pvt.ppe_base + reg)); } /* * nss_ppe_reg_write() */ static inline void nss_ppe_reg_write(u32 reg, u32 val) { writel(val, (ppe_pvt.ppe_base + reg)); } /* * nss_ppe_log.h * NSS PPE Log Header File */ /* * nss_ppe_log_tx_msg * Logs a ppe message that is sent to the NSS firmware. */ void nss_ppe_log_tx_msg(struct nss_ppe_msg *npm); /* * nss_ppe_log_rx_msg * Logs a ppe message that is received from the NSS firmware. */ void nss_ppe_log_rx_msg(struct nss_ppe_msg *npm);
32.169811
153
0.73717