blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
721
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 5
91
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 321
values | visit_date
timestamp[ns]date 2016-08-12 09:31:09
2023-09-06 10:45:07
| revision_date
timestamp[ns]date 2010-09-28 14:01:40
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 2010-09-28 14:01:40
2023-09-06 06:22:19
| github_id
int64 426
681M
| star_events_count
int64 101
243k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[ns]date 2012-06-28 18:51:49
2023-09-14 21:59:16
⌀ | gha_created_at
timestamp[ns]date 2008-02-11 22:55:26
2023-08-10 11:14:58
⌀ | gha_language
stringclasses 147
values | src_encoding
stringclasses 26
values | language
stringclasses 2
values | is_vendor
bool 2
classes | is_generated
bool 2
classes | length_bytes
int64 6
10.2M
| extension
stringclasses 115
values | filename
stringlengths 3
113
| content
stringlengths 6
10.2M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
41cb753ca1054ea82868a37ff1c3be9c7517b71c
|
7c857119fe1505b1d80d6e62969661c06dc1a2f4
|
/Xcode/ConfigValidator/ConfigValidator/ConfigValidator.c
|
8d53a50d57a5f53fb99aaee6af51db654807dbe2
|
[
"BSD-2-Clause"
] |
permissive
|
CloverHackyColor/CloverBootloader
|
7042ca7dd6b513d22be591a295e49071ae1482ee
|
2711170df4f60b2ae5aa20add3e00f35cf57b7e5
|
refs/heads/master
| 2023-08-30T22:14:34.590134
| 2023-08-27T19:14:02
| 2023-08-27T19:14:02
| 205,810,121
| 4,734
| 770
|
BSD-2-Clause
| 2023-09-03T12:41:33
| 2019-09-02T08:22:14
|
C
|
UTF-8
|
C
| false
| false
| 18,159
|
c
|
ConfigValidator.c
|
#if 0
shc Version 3.8.9b, Generic Script Compiler
Copyright (c) 1994-2015 Francisco Rosales <frosal@fi.upm.es>
./shc -v -r -T -f ./ConfigValidator.sh
#endif
static char data [] =
#define msg1_z 42
#define msg1 ((&data[6]))
"\233\150\044\313\040\005\310\215\377\044\043\272\360\062\203\301"
"\267\327\203\242\173\355\003\065\230\317\341\013\160\222\025\257"
"\174\041\006\331\151\070\053\007\161\263\250\222\134\220\123\167"
"\132"
#define chk1_z 22
#define chk1 ((&data[51]))
"\036\002\301\354\114\036\262\160\323\316\126\322\103\333\125\146"
"\245\002\206\002\302\177\220\025\340\262\075\021"
#define msg2_z 19
#define msg2 ((&data[77]))
"\322\362\137\041\163\034\331\056\026\024\206\006\040\313\175\267"
"\067\213\234\312"
#define xecc_z 15
#define xecc ((&data[99]))
"\152\276\165\352\335\200\050\306\016\010\342\317\342\326\250\255"
"\175"
#define chk2_z 19
#define chk2 ((&data[118]))
"\041\003\140\147\350\325\334\344\324\351\240\333\135\077\321\230"
"\013\116\211\034\222\145\003\375\162\133"
#define text_z 1633
#define text ((&data[468]))
"\332\223\133\117\353\157\261\253\233\243\035\167\326\172\152\035"
"\101\260\305\012\170\154\302\114\065\020\023\076\356\070\072\277"
"\152\331\254\253\373\123\144\076\067\200\154\336\363\223\106\042"
"\141\214\277\011\064\125\324\043\034\240\310\130\375\366\242\112"
"\177\362\352\073\002\312\163\254\025\316\167\210\017\137\306\143"
"\267\003\017\235\073\240\047\334\161\136\257\341\265\327\212\252"
"\332\025\210\104\346\176\362\206\321\365\026\227\050\070\176\033"
"\142\160\050\162\353\141\370\353\364\265\215\351\022\022\035\264"
"\227\212\263\256\215\312\147\114\301\131\025\365\000\267\337\233"
"\365\035\073\016\302\355\032\140\002\246\212\212\166\220\166\143"
"\301\153\074\347\370\320\007\221\031\220\107\206\307\117\322\244"
"\214\171\221\302\113\374\176\363\017\073\037\275\013\243\357\377"
"\312\337\255\361\206\105\235\012\060\044\176\106\243\055\273\044"
"\254\120\100\001\253\117\043\105\324\234\155\153\167\307\001\326"
"\370\115\336\172\005\153\122\056\335\075\110\336\054\101\265\342"
"\057\107\146\320\172\366\156\201\036\360\226\335\343\220\237\377"
"\161\217\342\117\031\060\343\325\204\317\326\311\114\370\210\206"
"\115\236\203\363\065\174\164\160\210\044\021\167\330\004\340\342"
"\016\245\055\264\025\050\070\300\247\154\264\263\032\257\322\125"
"\062\020\331\224\257\040\201\324\021\354\052\217\205\244\045\263"
"\175\165\341\154\246\304\124\070\113\022\327\355\200\173\222\207"
"\201\066\360\011\364\057\376\366\340\301\275\355\236\320\003\036"
"\375\263\160\163\034\043\307\277\177\371\161\166\050\177\334\311"
"\241\012\041\321\317\211\272\330\040\351\214\311\341\000\352\235"
"\353\350\003\074\126\031\377\227\145\064\301\266\335\002\112\011"
"\046\053\005\145\124\301\315\242\021\153\355\314\011\342\221\304"
"\121\336\326\162\376\247\070\147\124\157\211\063\010\301\350\205"
"\130\337\141\073\203\011\345\243\227\166\162\302\201\164\331\064"
"\121\006\006\326\362\300\022\051\317\164\132\046\057\221\040\225"
"\255\376\254\341\066\053\105\211\034\146\206\201\134\272\064\252"
"\264\036\147\274\354\262\277\132\373\303\211\352\266\377\250\324"
"\006\126\167\076\252\067\307\025\025\231\020\132\340\336\360\107"
"\214\155\047\014\315\170\120\235\175\233\372\170\351\173\272\335"
"\006\106\102\303\247\255\070\153\153\302\054\037\221\061\277\076"
"\153\021\033\002\003\232\345\326\160\341\200\343\356\054\260\237"
"\337\234\112\160\374\105\126\071\314\110\036\014\241\025\365\106"
"\072\130\333\135\157\302\127\043\207\000\034\104\240\012\205\054"
"\041\054\271\221\166\210\011\066\052\324\134\141\236\240\007\244"
"\035\143\211\247\001\215\173\363\332\153\235\255\046\045\255\140"
"\351\257\205\147\262\232\077\022\070\010\075\233\017\313\241\155"
"\360\113\143\225\356\356\243\260\015\077\206\256\273\347\260\242"
"\105\114\231\213\366\117\310\326\035\055\146\334\127\312\151\132"
"\042\362\057\153\223\064\311\054\237\331\030\346\267\123\001\227"
"\147\262\136\073\216\042\360\310\253\157\144\214\050\375\012\056"
"\264\253\006\231\052\321\215\273\250\127\151\047\166\005\076\005"
"\122\061\113\017\073\346\276\164\333\221\067\310\321\177\162\216"
"\057\107\064\013\141\217\056\044\304\072\140\077\366\253\125\003"
"\055\165\046\311\226\272\107\011\040\145\241\202\005\174\146\210"
"\044\213\157\350\324\356\215\142\244\244\133\302\024\027\332\075"
"\314\017\153\122\142\261\303\300\136\021\270\314\326\370\235\226"
"\320\167\042\012\171\255\271\234\331\147\327\140\367\123\242\102"
"\260\204\120\165\213\056\064\335\336\075\367\212\216\005\316\223"
"\272\267\212\127\020\034\053\267\102\234\175\177\113\134\112\246"
"\067\212\006\024\323\056\172\370\206\072\205\361\030\150\247\212"
"\345\022\255\306\170\233\016\002\230\273\121\347\032\131\005\166"
"\054\165\210\170\110\046\024\046\000\053\352\077\020\140\062\014"
"\276\172\251\375\134\357\257\206\040\366\226\334\235\212\167\135"
"\062\377\252\067\264\204\126\163\223\243\247\340\031\211\350\154"
"\032\074\275\122\375\035\276\366\177\104\135\254\037\134\374\372"
"\375\001\122\131\342\226\023\147\155\200\231\317\203\067\343\226"
"\310\321\022\277\240\362\242\360\364\017\056\111\110\032\235\234"
"\364\216\115\357\027\215\343\145\152\322\330\140\304\337\042\262"
"\324\147\155\270\110\000\167\372\246\050\205\231\067\161\222\337"
"\220\347\256\343\064\137\150\325\267\375\146\020\053\021\120\171"
"\327\011\363\221\362\266\345\373\200\265\207\200\167\200\245\021"
"\264\311\333\253\022\155\363\231\303\300\066\244\024\111\264\024"
"\101\245\311\043\115\242\031\347\257\241\014\051\100\326\323\135"
"\151\316\024\037\206\023\020\125\036\363\021\214\350\214\357\106"
"\255\277\122\057\162\144\146\047\061\160\337\105\040\121\133\001"
"\323\102\034\164\305\053\113\110\252\176\072\272\220\313\156\321"
"\213\116\022\273\176\212\130\366\113\320\116\010\004\011\023\024"
"\037\222\240\174\375\301\067\364\025\270\015\232\353\037\014\354"
"\263\134\055\001\120\060\131\130\232\204\343\337\055\326\147\131"
"\273\231\154\153\314\376\344\211\263\215\177\310\371\246\225\011"
"\215\001\221\342\112\220\026\027\355\114\205\374\226\211\064\126"
"\041\134\321\353\276\107\170\231\000\145\372\010\146\346\261\310"
"\244\327\352\253\221\363\261\331\341\100\135\204\163\237\300\375"
"\037\000\126\246\035\200\034\040\263\216\213\210\205\065\064\316"
"\035\251\344\013\176\044\322\353\225\266\304\055\104\131\213\162"
"\177\023\112\251\250\077\303\271\156\027\012\145\075\120\005\162"
"\273\325\106\313\354\370\231\262\132\041\302\060\106\211\153\061"
"\036\346\006\250\063\006\174\050\210\050\304\301\242\274\055\121"
"\376\176\055\325\155\365\200\000\146\352\107\135\150\332\330\220"
"\216\127\277\230\310\161\145\030\300\327\107\242\026\267\102\241"
"\302\353\035\252\134\125\261\120\354\132\373\162\063\177\257\361"
"\170\353\214\314\212\272\275\174\110\214\033\372\106\107\172\205"
"\061\351\377\077\144\360\165\200\050\051\254\101\173\354\233\104"
"\361\143\352\030\340\341\006\360\370\206\124\166\215\107\231\346"
"\027\330\137\233\311\301\005\366\021\342\350\235\127\334\116\275"
"\031\220\156\301\244\030\304\217\207\256\036\136\333\362\175\345"
"\047\017\065\256\213\132\101\143\216\376\353\074\372\362\222\217"
"\115\344\226\042\044\177\326\122\144\317\015\300\226\236\261\346"
"\045\132\065\355\250\120\161\031\120\032\001\217\056\237\151\360"
"\177\131\276\114\252\162\201\001\114\003\355\352\303\244\177\151"
"\137\014\021\312\165\003\065\316\351\345\232\167\017\235\170\037"
"\100\122\371\034\205\150\327\217\333\247\001\044\146\305\347\324"
"\100\072\147\065\367\246\007\017\031\337\177\016\215\022\134\005"
"\253\315\124\146\170\236\335\326\041\157\240\204\001\251\115\353"
"\306\046\176\370\044\106\314\127\046\327\033\020\131\300\312\207"
"\076\151\336\226\251\276\341\177\361\224\210\170\124\341\156\022"
"\257\370\242\132\340\212\167\033\312\013\037\224\004\051\156\157"
"\043\035\101\215\361\107\036\362\331\247\037\250\207\127\124\226"
"\253\136\045\331\054\043\226\310\133\312\002\066\116\112\366\151"
"\322\213\226\364\150\312\053\276\230\003\143\150\273\366\225\012"
"\117\354\031\341\347\211\203\050\103\066\262\373\257\165\263\034"
"\256\324\267\252\137\310\365\155\125\177\265\106\037\301\135\344"
"\203\064\235\200\351\204\352\151\041\165\302\046\111\110\305\314"
"\220\325\353\001\203\356\322\146\032\005\143\361\134\061\007\173"
"\055\066\277\053\000\054\077\315\332\076\343\375\003\074\260\253"
"\176\055\331\350\117\240\321\113\303\054\026\240\103\276\055\350"
"\024\040\345\076\074\261\332\221\060\225\312\344\150\032\051\334"
"\066\075\005\330\020\150\304\114\264\062\114\077\061\043\264\254"
"\054\334\226\237\305\326\165\265\016\004\274\037\070\014\377\336"
"\355\242\123\323\226\336\142\077\271\256\044\254\237\273\035\115"
"\257\371\225\233\103\336\371\353\044\030\150\372\343\000\112\266"
"\047\112\334\365\034\275\133\100\225\032\221\101\133\315\106\251"
"\334\231\134\236\327\376\372\271\042\350\263\006\322\305\252\133"
"\352\027\130\236\153\257\057\141\325\215\324\113\347\027\177\103"
"\327\330\036\276\122\265\044\200\025\025\223\275\253\010\276\301"
"\331\264\062\310\062\126\070\154\150\146\210\343\207\204\124\130"
"\343\226\032\123\301\126\366\275\033\306\323\072\051\143\251\024"
"\272\321\032\164\143\242\024\067\126\063\132\340\133\332\076\052"
"\275\170\224\175\152\122\246\266\161\151\013\020\004\170\273\245"
"\151\021\153\306\204\006\311\374\247\035\162\260\076\005\270\122"
"\053\236\304\250\162\025\105\361\027\341\223\155\330\017\377\055"
"\236\361\000\354\017\077\274\105\217\371\251\225\230\113\011\317"
"\065\237\010\176\137\004\133\035\001\223\277\065\010\117\253\334"
"\234\342\340\342\326\020\310\304\102\132\020\144\313\352\022\250"
"\306\241\144\362\167\126\174\361\330\245\111\332\003\030\175\044"
"\023\311\221\201\363\233\166\373\172\253\165\047\003\141\120\304"
"\211\361\207\103\243\367\143\203\156"
#define tst1_z 22
#define tst1 ((&data[2230]))
"\014\205\023\224\235\247\111\054\223\114\047\203\345\017\017\165"
"\056\117\361\057\223\267\263\257"
#define lsto_z 1
#define lsto ((&data[2253]))
"\001"
#define pswd_z 256
#define pswd ((&data[2274]))
"\347\010\271\264\150\206\136\015\366\114\323\264\020\217\331\124"
"\100\253\020\335\153\115\253\134\027\054\010\254\246\146\371\045"
"\030\377\005\205\343\252\376\352\056\335\171\171\025\252\046\026"
"\205\177\074\370\323\213\032\334\135\314\026\022\062\333\245\213"
"\055\145\341\150\216\152\301\004\100\331\001\160\216\043\041\076"
"\362\060\211\036\245\026\152\301\212\054\172\342\006\313\010\107"
"\226\140\112\312\000\063\152\323\014\350\120\202\354\045\135\356"
"\344\054\167\014\054\367\355\306\317\052\233\271\175\314\327\336"
"\213\062\057\124\035\032\241\023\022\172\016\133\014\320\016\064"
"\346\026\323\274\066\122\040\364\047\347\141\147\200\215\052\301"
"\262\104\202\331\374\154\315\166\170\017\114\124\252\340\010\307"
"\034\117\146\363\300\234\232\005\151\143\152\326\023\371\012\247"
"\341\005\334\242\154\137\226\312\202\337\011\017\347\315\134\344"
"\060\314\152\301\161\345\217\164\255\161\334\153\220\123\305\067"
"\244\064\006\152\210\226\320\307\201\060\323\205\146\324\344\163"
"\043\150\135\352\142\170\346\025\110\323\063\221\266\315\032\271"
"\152\365\213\252\265\317\066\266\273\017\232\313\167\207\317\110"
"\135\161\337\036\132\001\221\065\066\326\236\255\061\322\156\101"
"\325\126\266\345\127\233\135\263\146\126\322\026\306\075\116\005"
"\173\367\013\073\076\260\014\315\046\170\371\265\155\167\215\321"
"\202\061\304\224\223\174\236\344\220\057\046\273\140\007\077\353"
"\203\140\355\073"
#define shll_z 8
#define shll ((&data[2595]))
"\353\337\372\041\022\264\303\351\006"
#define date_z 1
#define date ((&data[2603]))
"\332"
#define opts_z 1
#define opts ((&data[2604]))
"\371"
#define rlax_z 1
#define rlax ((&data[2605]))
"\222"
#define inlo_z 3
#define inlo ((&data[2606]))
"\037\174\041"
#define tst2_z 19
#define tst2 ((&data[2609]))
"\030\170\107\235\170\073\371\345\000\376\025\161\056\245\327\250"
"\340\122\041\153\054\353\204"/* End of data[] */;
#define hide_z 4096
#define DEBUGEXEC 0 /* Define as 1 to debug execvp calls */
#define TRACEABLE 1 /* Define as 1 to enable ptrace the executable */
/* rtc.c */
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
/* 'Alleged RC4' */
static unsigned char stte[256], indx, jndx, kndx;
/*
* Reset arc4 stte.
*/
void stte_0(void)
{
indx = jndx = kndx = 0;
do {
stte[indx] = indx;
} while (++indx);
}
/*
* Set key. Can be used more than once.
*/
void key(void * str, int len)
{
unsigned char tmp, * ptr = (unsigned char *)str;
while (len > 0) {
do {
tmp = stte[indx];
kndx += tmp;
kndx += ptr[(int)indx % len];
stte[indx] = stte[kndx];
stte[kndx] = tmp;
} while (++indx);
ptr += 256;
len -= 256;
}
}
/*
* Crypt data.
*/
void arc4(void * str, int len)
{
unsigned char tmp, * ptr = (unsigned char *)str;
while (len > 0) {
indx++;
tmp = stte[indx];
jndx += tmp;
stte[indx] = stte[jndx];
stte[jndx] = tmp;
tmp += stte[indx];
*ptr ^= stte[tmp];
ptr++;
len--;
}
}
/* End of ARC4 */
/*
* Key with file invariants.
*/
int key_with_file(char * file)
{
struct stat statf[1];
struct stat control[1];
if (stat(file, statf) < 0)
return -1;
/* Turn on stable fields */
memset(control, 0, sizeof(control));
control->st_ino = statf->st_ino;
control->st_dev = statf->st_dev;
control->st_rdev = statf->st_rdev;
control->st_uid = statf->st_uid;
control->st_gid = statf->st_gid;
control->st_size = statf->st_size;
control->st_mtime = statf->st_mtime;
control->st_ctime = statf->st_ctime;
key(control, sizeof(control));
return 0;
}
#if DEBUGEXEC
void debugexec(char * sh11, int argc, char ** argv)
{
int i;
fprintf(stderr, "shll=%s\n", sh11 ? sh11 : "<null>");
fprintf(stderr, "argc=%d\n", argc);
if (!argv) {
fprintf(stderr, "argv=<null>\n");
} else {
for (i = 0; i <= argc ; i++)
fprintf(stderr, "argv[%d]=%.60s\n", i, argv[i] ? argv[i] : "<null>");
}
}
#endif /* DEBUGEXEC */
void rmarg(char ** argv, char * arg)
{
for (; argv && *argv && *argv != arg; argv++);
for (; argv && *argv; argv++)
*argv = argv[1];
}
int chkenv(int argc)
{
char buff[512];
unsigned long mask, m;
int l, a, c;
char * string;
extern char ** environ;
mask = (unsigned long)&chkenv;
mask ^= (unsigned long)getpid() * ~mask;
sprintf(buff, "x%lx", mask);
string = getenv(buff);
#if DEBUGEXEC
fprintf(stderr, "getenv(%s)=%s\n", buff, string ? string : "<null>");
#endif
l = strlen(buff);
if (!string) {
/* 1st */
sprintf(&buff[l], "=%lu %d", mask, argc);
putenv(strdup(buff));
return 0;
}
c = sscanf(string, "%lu %d%c", &m, &a, buff);
if (c == 2 && m == mask) {
/* 3rd */
rmarg(environ, &string[-l - 1]);
return 1 + (argc - a);
}
return -1;
}
#if !TRACEABLE
#define _LINUX_SOURCE_COMPAT
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#if !defined(PTRACE_ATTACH) && defined(PT_ATTACH)
# define PTRACE_ATTACH PT_ATTACH
#endif
void untraceable(char * argv0)
{
char proc[80];
int pid, mine;
switch(pid = fork()) {
case 0:
pid = getppid();
/* For problematic SunOS ptrace */
#if defined(__FreeBSD__)
sprintf(proc, "/proc/%d/mem", (int)pid);
#else
sprintf(proc, "/proc/%d/as", (int)pid);
#endif
close(0);
mine = !open(proc, O_RDWR|O_EXCL);
if (!mine && errno != EBUSY)
mine = !ptrace(PTRACE_ATTACH, pid, 0, 0);
if (mine) {
kill(pid, SIGCONT);
} else {
perror(argv0);
kill(pid, SIGKILL);
}
_exit(mine);
case -1:
break;
default:
if (pid == waitpid(pid, 0, 0))
return;
}
perror(argv0);
_exit(1);
}
#endif /* !TRACEABLE */
char * xsh(int argc, char ** argv)
{
char * scrpt;
int ret, i, j;
char ** varg;
char * me = argv[0];
stte_0();
key(pswd, pswd_z);
arc4(msg1, msg1_z);
arc4(date, date_z);
if (date[0] && (atoll(date)<time(NULL)))
return msg1;
arc4(shll, shll_z);
arc4(inlo, inlo_z);
arc4(xecc, xecc_z);
arc4(lsto, lsto_z);
arc4(tst1, tst1_z);
key(tst1, tst1_z);
arc4(chk1, chk1_z);
if ((chk1_z != tst1_z) || memcmp(tst1, chk1, tst1_z))
return tst1;
ret = chkenv(argc);
arc4(msg2, msg2_z);
if (ret < 0)
return msg2;
varg = (char **)calloc(argc + 10, sizeof(char *));
if (!varg)
return 0;
if (ret) {
arc4(rlax, rlax_z);
if (!rlax[0] && key_with_file(shll))
return shll;
arc4(opts, opts_z);
arc4(text, text_z);
arc4(tst2, tst2_z);
key(tst2, tst2_z);
arc4(chk2, chk2_z);
if ((chk2_z != tst2_z) || memcmp(tst2, chk2, tst2_z))
return tst2;
/* Prepend hide_z spaces to script text to hide it. */
scrpt = malloc(hide_z + text_z);
if (!scrpt)
return 0;
memset(scrpt, (int) ' ', hide_z);
memcpy(&scrpt[hide_z], text, text_z);
} else { /* Reexecute */
if (*xecc) {
scrpt = malloc(512);
if (!scrpt)
return 0;
sprintf(scrpt, xecc, me);
} else {
scrpt = me;
}
}
j = 0;
varg[j++] = argv[0]; /* My own name at execution */
if (ret && *opts)
varg[j++] = opts; /* Options on 1st line of code */
if (*inlo)
varg[j++] = inlo; /* Option introducing inline code */
varg[j++] = scrpt; /* The script itself */
if (*lsto)
varg[j++] = lsto; /* Option meaning last option */
i = (ret > 1) ? ret : 0; /* Args numbering correction */
while (i < argc)
varg[j++] = argv[i++]; /* Main run-time arguments */
varg[j] = 0; /* NULL terminated array */
#if DEBUGEXEC
debugexec(shll, j, varg);
#endif
execvp(shll, varg);
return shll;
}
int main(int argc, char ** argv)
{
#if DEBUGEXEC
debugexec("main", argc, argv);
#endif
#if !TRACEABLE
untraceable(argv[0]);
#endif
argv[1] = xsh(argc, argv);
fprintf(stderr, "%s%s%s: %s\n", argv[0],
errno ? ": " : "",
errno ? strerror(errno) : "",
argv[1] ? argv[1] : "<null>"
);
return 1;
}
|
405a70e74a864df6a5a1c5e977d3a736df4a4fb7
|
da94aa288b0b880471e30b8305698d53a86d5279
|
/pglogical_output.c
|
b24897ef6b24ee508429759f91960a70a8015448
|
[
"PostgreSQL"
] |
permissive
|
2ndQuadrant/pglogical
|
b22f683307df474ab38cb6dd0bcef97bc4fc70a2
|
1ac225303ac8526355c7193fb8496c1780c7b324
|
refs/heads/REL2_x_STABLE
| 2023-09-01T09:23:15.589566
| 2023-05-23T00:51:14
| 2023-05-24T12:51:11
| 58,486,879
| 809
| 171
|
NOASSERTION
| 2023-08-22T23:07:49
| 2016-05-10T19:09:08
|
C
|
UTF-8
|
C
| false
| false
| 986
|
c
|
pglogical_output.c
|
/*-------------------------------------------------------------------------
*
* pglogical_output.c
* Logical Replication output plugin which just loads and forwards
* the call to the pglogical.
*
* This exists for backwards compatibility.
*
* Copyright (c) 2012-2015, PostgreSQL Global Development Group
*
* IDENTIFICATION
* pglogical_output.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "replication/logical.h"
PG_MODULE_MAGIC;
extern void _PG_output_plugin_init(OutputPluginCallbacks *cb);
void
_PG_output_plugin_init(OutputPluginCallbacks *cb)
{
LogicalOutputPluginInit plugin_init;
AssertVariableIsOfType(&_PG_output_plugin_init, LogicalOutputPluginInit);
plugin_init = (LogicalOutputPluginInit)
load_external_function("pglogical", "_PG_output_plugin_init", false, NULL);
if (plugin_init == NULL)
elog(ERROR, "could not load pglogical output plugin");
plugin_init(cb);
}
|
ba6ba9ec99c28f7bbc1d0a52b48f7f7775c1d3ce
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/libaom/source/libaom/common/video_reader.c
|
27f69a967217616e64f92cf868de397fb358c7f1
|
[
"BSD-2-Clause",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"BSD-3-Clause"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 4,512
|
c
|
video_reader.c
|
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "aom_ports/mem_ops.h"
#include "common/ivfdec.h"
#include "common/obudec.h"
#include "common/tools_common.h"
#include "common/video_reader.h"
#include "common/webmdec.h"
struct AvxVideoReaderStruct {
AvxVideoInfo info;
struct AvxInputContext input_ctx;
struct ObuDecInputContext obu_ctx;
struct WebmInputContext webm_ctx;
uint8_t *buffer;
size_t buffer_size;
size_t frame_size;
aom_codec_pts_t pts;
};
AvxVideoReader *aom_video_reader_open(const char *filename) {
AvxVideoReader *reader = NULL;
const bool using_file = strcmp(filename, "-") != 0;
FILE *const file =
using_file ? fopen(filename, "rb") : set_binary_mode(stdin);
if (!file) return NULL; // Can't open file
reader = (AvxVideoReader *)calloc(1, sizeof(*reader));
if (!reader) {
fclose(file);
return NULL; // Can't allocate AvxVideoReader
}
reader->input_ctx.filename = filename;
reader->input_ctx.file = file;
reader->obu_ctx.avx_ctx = &reader->input_ctx;
reader->obu_ctx.is_annexb = 1;
// TODO(https://crbug.com/aomedia/1706): webm type does not support reading
// from stdin yet, and file_is_webm is not using the detect buffer when
// determining the type. Therefore it should only be checked when using a file
// and needs to be checked prior to other types.
if (false) {
#if CONFIG_WEBM_IO
} else if (using_file &&
file_is_webm(&reader->webm_ctx, &reader->input_ctx)) {
reader->input_ctx.file_type = FILE_TYPE_WEBM;
reader->info.codec_fourcc = reader->input_ctx.fourcc;
reader->info.frame_width = reader->input_ctx.width;
reader->info.frame_height = reader->input_ctx.height;
#endif
} else if (file_is_ivf(&reader->input_ctx)) {
reader->input_ctx.file_type = FILE_TYPE_IVF;
reader->info.codec_fourcc = reader->input_ctx.fourcc;
reader->info.frame_width = reader->input_ctx.width;
reader->info.frame_height = reader->input_ctx.height;
} else if (file_is_obu(&reader->obu_ctx)) {
reader->input_ctx.file_type = FILE_TYPE_OBU;
// assume AV1
reader->info.codec_fourcc = AV1_FOURCC;
reader->info.is_annexb = reader->obu_ctx.is_annexb;
} else {
fclose(file);
free(reader);
return NULL; // Unknown file type
}
return reader;
}
void aom_video_reader_close(AvxVideoReader *reader) {
if (reader) {
fclose(reader->input_ctx.file);
if (reader->input_ctx.file_type == FILE_TYPE_OBU) {
obudec_free(&reader->obu_ctx);
}
free(reader->buffer);
free(reader);
}
}
int aom_video_reader_read_frame(AvxVideoReader *reader) {
if (reader->input_ctx.file_type == FILE_TYPE_IVF) {
return !ivf_read_frame(&reader->input_ctx, &reader->buffer,
&reader->frame_size, &reader->buffer_size,
&reader->pts);
} else if (reader->input_ctx.file_type == FILE_TYPE_OBU) {
return !obudec_read_temporal_unit(&reader->obu_ctx, &reader->buffer,
&reader->frame_size,
&reader->buffer_size);
#if CONFIG_WEBM_IO
} else if (reader->input_ctx.file_type == FILE_TYPE_WEBM) {
return !webm_read_frame(&reader->webm_ctx, &reader->buffer,
&reader->frame_size, &reader->buffer_size);
#endif
} else {
assert(0);
return 0;
}
}
const uint8_t *aom_video_reader_get_frame(AvxVideoReader *reader,
size_t *size) {
if (size) *size = reader->frame_size;
return reader->buffer;
}
int64_t aom_video_reader_get_frame_pts(AvxVideoReader *reader) {
return (int64_t)reader->pts;
}
FILE *aom_video_reader_get_file(AvxVideoReader *reader) {
return reader->input_ctx.file;
}
const AvxVideoInfo *aom_video_reader_get_info(AvxVideoReader *reader) {
return &reader->info;
}
void aom_video_reader_set_fourcc(AvxVideoReader *reader, uint32_t fourcc) {
reader->info.codec_fourcc = fourcc;
}
|
b4e9902b5e7bd4d4a2d0ba251916a7a8aef1b17f
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/net/atm/common.c
|
7b491006eaf4000424282979b0c4709325102152
|
[
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 22,142
|
c
|
common.c
|
/* net/atm/common.c - ATM sockets (common part for PVC and SVC) */
/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
#include <linux/module.h>
#include <linux/kmod.h>
#include <linux/net.h> /* struct socket, struct proto_ops */
#include <linux/atm.h> /* ATM stuff */
#include <linux/atmdev.h>
#include <linux/socket.h> /* SOL_SOCKET */
#include <linux/errno.h> /* error codes */
#include <linux/capability.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/time.h> /* struct timeval */
#include <linux/skbuff.h>
#include <linux/bitops.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <net/sock.h> /* struct sock */
#include <linux/uaccess.h>
#include <linux/poll.h>
#include <linux/atomic.h>
#include "resources.h" /* atm_find_dev */
#include "common.h" /* prototypes */
#include "protocols.h" /* atm_init_<transport> */
#include "addr.h" /* address registry */
#include "signaling.h" /* for WAITING and sigd_attach */
struct hlist_head vcc_hash[VCC_HTABLE_SIZE];
EXPORT_SYMBOL(vcc_hash);
DEFINE_RWLOCK(vcc_sklist_lock);
EXPORT_SYMBOL(vcc_sklist_lock);
static ATOMIC_NOTIFIER_HEAD(atm_dev_notify_chain);
static void __vcc_insert_socket(struct sock *sk)
{
struct atm_vcc *vcc = atm_sk(sk);
struct hlist_head *head = &vcc_hash[vcc->vci & (VCC_HTABLE_SIZE - 1)];
sk->sk_hash = vcc->vci & (VCC_HTABLE_SIZE - 1);
sk_add_node(sk, head);
}
void vcc_insert_socket(struct sock *sk)
{
write_lock_irq(&vcc_sklist_lock);
__vcc_insert_socket(sk);
write_unlock_irq(&vcc_sklist_lock);
}
EXPORT_SYMBOL(vcc_insert_socket);
static void vcc_remove_socket(struct sock *sk)
{
write_lock_irq(&vcc_sklist_lock);
sk_del_node_init(sk);
write_unlock_irq(&vcc_sklist_lock);
}
static struct sk_buff *alloc_tx(struct atm_vcc *vcc, unsigned int size)
{
struct sk_buff *skb;
struct sock *sk = sk_atm(vcc);
if (sk_wmem_alloc_get(sk) && !atm_may_send(vcc, size)) {
pr_debug("Sorry: wmem_alloc = %d, size = %d, sndbuf = %d\n",
sk_wmem_alloc_get(sk), size, sk->sk_sndbuf);
return NULL;
}
while (!(skb = alloc_skb(size, GFP_KERNEL)))
schedule();
pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize);
atomic_add(skb->truesize, &sk->sk_wmem_alloc);
return skb;
}
static void vcc_sock_destruct(struct sock *sk)
{
if (atomic_read(&sk->sk_rmem_alloc))
printk(KERN_DEBUG "%s: rmem leakage (%d bytes) detected.\n",
__func__, atomic_read(&sk->sk_rmem_alloc));
if (atomic_read(&sk->sk_wmem_alloc))
printk(KERN_DEBUG "%s: wmem leakage (%d bytes) detected.\n",
__func__, atomic_read(&sk->sk_wmem_alloc));
}
static void vcc_def_wakeup(struct sock *sk)
{
struct socket_wq *wq;
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (wq_has_sleeper(wq))
wake_up(&wq->wait);
rcu_read_unlock();
}
static inline int vcc_writable(struct sock *sk)
{
struct atm_vcc *vcc = atm_sk(sk);
return (vcc->qos.txtp.max_sdu +
atomic_read(&sk->sk_wmem_alloc)) <= sk->sk_sndbuf;
}
static void vcc_write_space(struct sock *sk)
{
struct socket_wq *wq;
rcu_read_lock();
if (vcc_writable(sk)) {
wq = rcu_dereference(sk->sk_wq);
if (wq_has_sleeper(wq))
wake_up_interruptible(&wq->wait);
sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
}
rcu_read_unlock();
}
static void vcc_release_cb(struct sock *sk)
{
struct atm_vcc *vcc = atm_sk(sk);
if (vcc->release_cb)
vcc->release_cb(vcc);
}
static struct proto vcc_proto = {
.name = "VCC",
.owner = THIS_MODULE,
.obj_size = sizeof(struct atm_vcc),
.release_cb = vcc_release_cb,
};
int vcc_create(struct net *net, struct socket *sock, int protocol, int family)
{
struct sock *sk;
struct atm_vcc *vcc;
sock->sk = NULL;
if (sock->type == SOCK_STREAM)
return -EINVAL;
sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto);
if (!sk)
return -ENOMEM;
sock_init_data(sock, sk);
sk->sk_state_change = vcc_def_wakeup;
sk->sk_write_space = vcc_write_space;
vcc = atm_sk(sk);
vcc->dev = NULL;
memset(&vcc->local, 0, sizeof(struct sockaddr_atmsvc));
memset(&vcc->remote, 0, sizeof(struct sockaddr_atmsvc));
vcc->qos.txtp.max_sdu = 1 << 16; /* for meta VCs */
atomic_set(&sk->sk_wmem_alloc, 1);
atomic_set(&sk->sk_rmem_alloc, 0);
vcc->push = NULL;
vcc->pop = NULL;
vcc->owner = NULL;
vcc->push_oam = NULL;
vcc->release_cb = NULL;
vcc->vpi = vcc->vci = 0; /* no VCI/VPI yet */
vcc->atm_options = vcc->aal_options = 0;
sk->sk_destruct = vcc_sock_destruct;
return 0;
}
static void vcc_destroy_socket(struct sock *sk)
{
struct atm_vcc *vcc = atm_sk(sk);
struct sk_buff *skb;
set_bit(ATM_VF_CLOSE, &vcc->flags);
clear_bit(ATM_VF_READY, &vcc->flags);
if (vcc->dev) {
if (vcc->dev->ops->close)
vcc->dev->ops->close(vcc);
if (vcc->push)
vcc->push(vcc, NULL); /* atmarpd has no push */
module_put(vcc->owner);
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
atm_return(vcc, skb->truesize);
kfree_skb(skb);
}
module_put(vcc->dev->ops->owner);
atm_dev_put(vcc->dev);
}
vcc_remove_socket(sk);
}
int vcc_release(struct socket *sock)
{
struct sock *sk = sock->sk;
if (sk) {
lock_sock(sk);
vcc_destroy_socket(sock->sk);
release_sock(sk);
sock_put(sk);
}
return 0;
}
void vcc_release_async(struct atm_vcc *vcc, int reply)
{
struct sock *sk = sk_atm(vcc);
set_bit(ATM_VF_CLOSE, &vcc->flags);
sk->sk_shutdown |= RCV_SHUTDOWN;
sk->sk_err = -reply;
clear_bit(ATM_VF_WAITING, &vcc->flags);
sk->sk_state_change(sk);
}
EXPORT_SYMBOL(vcc_release_async);
void vcc_process_recv_queue(struct atm_vcc *vcc)
{
struct sk_buff_head queue, *rq;
struct sk_buff *skb, *tmp;
unsigned long flags;
__skb_queue_head_init(&queue);
rq = &sk_atm(vcc)->sk_receive_queue;
spin_lock_irqsave(&rq->lock, flags);
skb_queue_splice_init(rq, &queue);
spin_unlock_irqrestore(&rq->lock, flags);
skb_queue_walk_safe(&queue, skb, tmp) {
__skb_unlink(skb, &queue);
vcc->push(vcc, skb);
}
}
EXPORT_SYMBOL(vcc_process_recv_queue);
void atm_dev_signal_change(struct atm_dev *dev, char signal)
{
pr_debug("%s signal=%d dev=%p number=%d dev->signal=%d\n",
__func__, signal, dev, dev->number, dev->signal);
/* atm driver sending invalid signal */
WARN_ON(signal < ATM_PHY_SIG_LOST || signal > ATM_PHY_SIG_FOUND);
if (dev->signal == signal)
return; /* no change */
dev->signal = signal;
atomic_notifier_call_chain(&atm_dev_notify_chain, signal, dev);
}
EXPORT_SYMBOL(atm_dev_signal_change);
void atm_dev_release_vccs(struct atm_dev *dev)
{
int i;
write_lock_irq(&vcc_sklist_lock);
for (i = 0; i < VCC_HTABLE_SIZE; i++) {
struct hlist_head *head = &vcc_hash[i];
struct hlist_node *tmp;
struct sock *s;
struct atm_vcc *vcc;
sk_for_each_safe(s, tmp, head) {
vcc = atm_sk(s);
if (vcc->dev == dev) {
vcc_release_async(vcc, -EPIPE);
sk_del_node_init(s);
}
}
}
write_unlock_irq(&vcc_sklist_lock);
}
EXPORT_SYMBOL(atm_dev_release_vccs);
static int adjust_tp(struct atm_trafprm *tp, unsigned char aal)
{
int max_sdu;
if (!tp->traffic_class)
return 0;
switch (aal) {
case ATM_AAL0:
max_sdu = ATM_CELL_SIZE-1;
break;
case ATM_AAL34:
max_sdu = ATM_MAX_AAL34_PDU;
break;
default:
pr_warning("AAL problems ... (%d)\n", aal);
/* fall through */
case ATM_AAL5:
max_sdu = ATM_MAX_AAL5_PDU;
}
if (!tp->max_sdu)
tp->max_sdu = max_sdu;
else if (tp->max_sdu > max_sdu)
return -EINVAL;
if (!tp->max_cdv)
tp->max_cdv = ATM_MAX_CDV;
return 0;
}
static int check_ci(const struct atm_vcc *vcc, short vpi, int vci)
{
struct hlist_head *head = &vcc_hash[vci & (VCC_HTABLE_SIZE - 1)];
struct sock *s;
struct atm_vcc *walk;
sk_for_each(s, head) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if (test_bit(ATM_VF_ADDR, &walk->flags) && walk->vpi == vpi &&
walk->vci == vci && ((walk->qos.txtp.traffic_class !=
ATM_NONE && vcc->qos.txtp.traffic_class != ATM_NONE) ||
(walk->qos.rxtp.traffic_class != ATM_NONE &&
vcc->qos.rxtp.traffic_class != ATM_NONE)))
return -EADDRINUSE;
}
/* allow VCCs with same VPI/VCI iff they don't collide on
TX/RX (but we may refuse such sharing for other reasons,
e.g. if protocol requires to have both channels) */
return 0;
}
static int find_ci(const struct atm_vcc *vcc, short *vpi, int *vci)
{
static short p; /* poor man's per-device cache */
static int c;
short old_p;
int old_c;
int err;
if (*vpi != ATM_VPI_ANY && *vci != ATM_VCI_ANY) {
err = check_ci(vcc, *vpi, *vci);
return err;
}
/* last scan may have left values out of bounds for current device */
if (*vpi != ATM_VPI_ANY)
p = *vpi;
else if (p >= 1 << vcc->dev->ci_range.vpi_bits)
p = 0;
if (*vci != ATM_VCI_ANY)
c = *vci;
else if (c < ATM_NOT_RSV_VCI || c >= 1 << vcc->dev->ci_range.vci_bits)
c = ATM_NOT_RSV_VCI;
old_p = p;
old_c = c;
do {
if (!check_ci(vcc, p, c)) {
*vpi = p;
*vci = c;
return 0;
}
if (*vci == ATM_VCI_ANY) {
c++;
if (c >= 1 << vcc->dev->ci_range.vci_bits)
c = ATM_NOT_RSV_VCI;
}
if ((c == ATM_NOT_RSV_VCI || *vci != ATM_VCI_ANY) &&
*vpi == ATM_VPI_ANY) {
p++;
if (p >= 1 << vcc->dev->ci_range.vpi_bits)
p = 0;
}
} while (old_p != p || old_c != c);
return -EADDRINUSE;
}
static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi,
int vci)
{
struct sock *sk = sk_atm(vcc);
int error;
if ((vpi != ATM_VPI_UNSPEC && vpi != ATM_VPI_ANY &&
vpi >> dev->ci_range.vpi_bits) || (vci != ATM_VCI_UNSPEC &&
vci != ATM_VCI_ANY && vci >> dev->ci_range.vci_bits))
return -EINVAL;
if (vci > 0 && vci < ATM_NOT_RSV_VCI && !capable(CAP_NET_BIND_SERVICE))
return -EPERM;
error = -ENODEV;
if (!try_module_get(dev->ops->owner))
return error;
vcc->dev = dev;
write_lock_irq(&vcc_sklist_lock);
if (test_bit(ATM_DF_REMOVED, &dev->flags) ||
(error = find_ci(vcc, &vpi, &vci))) {
write_unlock_irq(&vcc_sklist_lock);
goto fail_module_put;
}
vcc->vpi = vpi;
vcc->vci = vci;
__vcc_insert_socket(sk);
write_unlock_irq(&vcc_sklist_lock);
switch (vcc->qos.aal) {
case ATM_AAL0:
error = atm_init_aal0(vcc);
vcc->stats = &dev->stats.aal0;
break;
case ATM_AAL34:
error = atm_init_aal34(vcc);
vcc->stats = &dev->stats.aal34;
break;
case ATM_NO_AAL:
/* ATM_AAL5 is also used in the "0 for default" case */
vcc->qos.aal = ATM_AAL5;
/* fall through */
case ATM_AAL5:
error = atm_init_aal5(vcc);
vcc->stats = &dev->stats.aal5;
break;
default:
error = -EPROTOTYPE;
}
if (!error)
error = adjust_tp(&vcc->qos.txtp, vcc->qos.aal);
if (!error)
error = adjust_tp(&vcc->qos.rxtp, vcc->qos.aal);
if (error)
goto fail;
pr_debug("VCC %d.%d, AAL %d\n", vpi, vci, vcc->qos.aal);
pr_debug(" TX: %d, PCR %d..%d, SDU %d\n",
vcc->qos.txtp.traffic_class,
vcc->qos.txtp.min_pcr,
vcc->qos.txtp.max_pcr,
vcc->qos.txtp.max_sdu);
pr_debug(" RX: %d, PCR %d..%d, SDU %d\n",
vcc->qos.rxtp.traffic_class,
vcc->qos.rxtp.min_pcr,
vcc->qos.rxtp.max_pcr,
vcc->qos.rxtp.max_sdu);
if (dev->ops->open) {
error = dev->ops->open(vcc);
if (error)
goto fail;
}
return 0;
fail:
vcc_remove_socket(sk);
fail_module_put:
module_put(dev->ops->owner);
/* ensure we get dev module ref count correct */
vcc->dev = NULL;
return error;
}
int vcc_connect(struct socket *sock, int itf, short vpi, int vci)
{
struct atm_dev *dev;
struct atm_vcc *vcc = ATM_SD(sock);
int error;
pr_debug("(vpi %d, vci %d)\n", vpi, vci);
if (sock->state == SS_CONNECTED)
return -EISCONN;
if (sock->state != SS_UNCONNECTED)
return -EINVAL;
if (!(vpi || vci))
return -EINVAL;
if (vpi != ATM_VPI_UNSPEC && vci != ATM_VCI_UNSPEC)
clear_bit(ATM_VF_PARTIAL, &vcc->flags);
else
if (test_bit(ATM_VF_PARTIAL, &vcc->flags))
return -EINVAL;
pr_debug("(TX: cl %d,bw %d-%d,sdu %d; "
"RX: cl %d,bw %d-%d,sdu %d,AAL %s%d)\n",
vcc->qos.txtp.traffic_class, vcc->qos.txtp.min_pcr,
vcc->qos.txtp.max_pcr, vcc->qos.txtp.max_sdu,
vcc->qos.rxtp.traffic_class, vcc->qos.rxtp.min_pcr,
vcc->qos.rxtp.max_pcr, vcc->qos.rxtp.max_sdu,
vcc->qos.aal == ATM_AAL5 ? "" :
vcc->qos.aal == ATM_AAL0 ? "" : " ??? code ",
vcc->qos.aal == ATM_AAL0 ? 0 : vcc->qos.aal);
if (!test_bit(ATM_VF_HASQOS, &vcc->flags))
return -EBADFD;
if (vcc->qos.txtp.traffic_class == ATM_ANYCLASS ||
vcc->qos.rxtp.traffic_class == ATM_ANYCLASS)
return -EINVAL;
if (likely(itf != ATM_ITF_ANY)) {
dev = try_then_request_module(atm_dev_lookup(itf),
"atm-device-%d", itf);
} else {
dev = NULL;
mutex_lock(&atm_dev_mutex);
if (!list_empty(&atm_devs)) {
dev = list_entry(atm_devs.next,
struct atm_dev, dev_list);
atm_dev_hold(dev);
}
mutex_unlock(&atm_dev_mutex);
}
if (!dev)
return -ENODEV;
error = __vcc_connect(vcc, dev, vpi, vci);
if (error) {
atm_dev_put(dev);
return error;
}
if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC)
set_bit(ATM_VF_PARTIAL, &vcc->flags);
if (test_bit(ATM_VF_READY, &ATM_SD(sock)->flags))
sock->state = SS_CONNECTED;
return 0;
}
int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
size_t size, int flags)
{
struct sock *sk = sock->sk;
struct atm_vcc *vcc;
struct sk_buff *skb;
int copied, error = -EINVAL;
if (sock->state != SS_CONNECTED)
return -ENOTCONN;
/* only handle MSG_DONTWAIT and MSG_PEEK */
if (flags & ~(MSG_DONTWAIT | MSG_PEEK))
return -EOPNOTSUPP;
vcc = ATM_SD(sock);
if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
test_bit(ATM_VF_CLOSE, &vcc->flags) ||
!test_bit(ATM_VF_READY, &vcc->flags))
return 0;
skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &error);
if (!skb)
return error;
copied = skb->len;
if (copied > size) {
copied = size;
msg->msg_flags |= MSG_TRUNC;
}
error = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
if (error)
return error;
sock_recv_ts_and_drops(msg, sk, skb);
if (!(flags & MSG_PEEK)) {
pr_debug("%d -= %d\n", atomic_read(&sk->sk_rmem_alloc),
skb->truesize);
atm_return(vcc, skb->truesize);
}
skb_free_datagram(sk, skb);
return copied;
}
int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
size_t total_len)
{
struct sock *sk = sock->sk;
DEFINE_WAIT(wait);
struct atm_vcc *vcc;
struct sk_buff *skb;
int eff, error;
const void __user *buff;
int size;
lock_sock(sk);
if (sock->state != SS_CONNECTED) {
error = -ENOTCONN;
goto out;
}
if (m->msg_name) {
error = -EISCONN;
goto out;
}
if (m->msg_iovlen != 1) {
error = -ENOSYS; /* fix this later @@@ */
goto out;
}
buff = m->msg_iov->iov_base;
size = m->msg_iov->iov_len;
vcc = ATM_SD(sock);
if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
test_bit(ATM_VF_CLOSE, &vcc->flags) ||
!test_bit(ATM_VF_READY, &vcc->flags)) {
error = -EPIPE;
send_sig(SIGPIPE, current, 0);
goto out;
}
if (!size) {
error = 0;
goto out;
}
if (size < 0 || size > vcc->qos.txtp.max_sdu) {
error = -EMSGSIZE;
goto out;
}
eff = (size+3) & ~3; /* align to word boundary */
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
error = 0;
while (!(skb = alloc_tx(vcc, eff))) {
if (m->msg_flags & MSG_DONTWAIT) {
error = -EAGAIN;
break;
}
schedule();
if (signal_pending(current)) {
error = -ERESTARTSYS;
break;
}
if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
test_bit(ATM_VF_CLOSE, &vcc->flags) ||
!test_bit(ATM_VF_READY, &vcc->flags)) {
error = -EPIPE;
send_sig(SIGPIPE, current, 0);
break;
}
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
}
finish_wait(sk_sleep(sk), &wait);
if (error)
goto out;
skb->dev = NULL; /* for paths shared with net_device interfaces */
ATM_SKB(skb)->atm_options = vcc->atm_options;
if (copy_from_user(skb_put(skb, size), buff, size)) {
kfree_skb(skb);
error = -EFAULT;
goto out;
}
if (eff != size)
memset(skb->data + size, 0, eff-size);
error = vcc->dev->ops->send(vcc, skb);
error = error ? error : size;
out:
release_sock(sk);
return error;
}
unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
{
struct sock *sk = sock->sk;
struct atm_vcc *vcc;
unsigned int mask;
sock_poll_wait(file, sk_sleep(sk), wait);
mask = 0;
vcc = ATM_SD(sock);
/* exceptional events */
if (sk->sk_err)
mask = POLLERR;
if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
test_bit(ATM_VF_CLOSE, &vcc->flags))
mask |= POLLHUP;
/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue))
mask |= POLLIN | POLLRDNORM;
/* writable? */
if (sock->state == SS_CONNECTING &&
test_bit(ATM_VF_WAITING, &vcc->flags))
return mask;
if (vcc->qos.txtp.traffic_class != ATM_NONE &&
vcc_writable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
return mask;
}
static int atm_change_qos(struct atm_vcc *vcc, struct atm_qos *qos)
{
int error;
/*
* Don't let the QoS change the already connected AAL type nor the
* traffic class.
*/
if (qos->aal != vcc->qos.aal ||
qos->rxtp.traffic_class != vcc->qos.rxtp.traffic_class ||
qos->txtp.traffic_class != vcc->qos.txtp.traffic_class)
return -EINVAL;
error = adjust_tp(&qos->txtp, qos->aal);
if (!error)
error = adjust_tp(&qos->rxtp, qos->aal);
if (error)
return error;
if (!vcc->dev->ops->change_qos)
return -EOPNOTSUPP;
if (sk_atm(vcc)->sk_family == AF_ATMPVC)
return vcc->dev->ops->change_qos(vcc, qos, ATM_MF_SET);
return svc_change_qos(vcc, qos);
}
static int check_tp(const struct atm_trafprm *tp)
{
/* @@@ Should be merged with adjust_tp */
if (!tp->traffic_class || tp->traffic_class == ATM_ANYCLASS)
return 0;
if (tp->traffic_class != ATM_UBR && !tp->min_pcr && !tp->pcr &&
!tp->max_pcr)
return -EINVAL;
if (tp->min_pcr == ATM_MAX_PCR)
return -EINVAL;
if (tp->min_pcr && tp->max_pcr && tp->max_pcr != ATM_MAX_PCR &&
tp->min_pcr > tp->max_pcr)
return -EINVAL;
/*
* We allow pcr to be outside [min_pcr,max_pcr], because later
* adjustment may still push it in the valid range.
*/
return 0;
}
static int check_qos(const struct atm_qos *qos)
{
int error;
if (!qos->txtp.traffic_class && !qos->rxtp.traffic_class)
return -EINVAL;
if (qos->txtp.traffic_class != qos->rxtp.traffic_class &&
qos->txtp.traffic_class && qos->rxtp.traffic_class &&
qos->txtp.traffic_class != ATM_ANYCLASS &&
qos->rxtp.traffic_class != ATM_ANYCLASS)
return -EINVAL;
error = check_tp(&qos->txtp);
if (error)
return error;
return check_tp(&qos->rxtp);
}
int vcc_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
{
struct atm_vcc *vcc;
unsigned long value;
int error;
if (__SO_LEVEL_MATCH(optname, level) && optlen != __SO_SIZE(optname))
return -EINVAL;
vcc = ATM_SD(sock);
switch (optname) {
case SO_ATMQOS:
{
struct atm_qos qos;
if (copy_from_user(&qos, optval, sizeof(qos)))
return -EFAULT;
error = check_qos(&qos);
if (error)
return error;
if (sock->state == SS_CONNECTED)
return atm_change_qos(vcc, &qos);
if (sock->state != SS_UNCONNECTED)
return -EBADFD;
vcc->qos = qos;
set_bit(ATM_VF_HASQOS, &vcc->flags);
return 0;
}
case SO_SETCLP:
if (get_user(value, (unsigned long __user *)optval))
return -EFAULT;
if (value)
vcc->atm_options |= ATM_ATMOPT_CLP;
else
vcc->atm_options &= ~ATM_ATMOPT_CLP;
return 0;
default:
if (level == SOL_SOCKET)
return -EINVAL;
break;
}
if (!vcc->dev || !vcc->dev->ops->setsockopt)
return -EINVAL;
return vcc->dev->ops->setsockopt(vcc, level, optname, optval, optlen);
}
int vcc_getsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen)
{
struct atm_vcc *vcc;
int len;
if (get_user(len, optlen))
return -EFAULT;
if (__SO_LEVEL_MATCH(optname, level) && len != __SO_SIZE(optname))
return -EINVAL;
vcc = ATM_SD(sock);
switch (optname) {
case SO_ATMQOS:
if (!test_bit(ATM_VF_HASQOS, &vcc->flags))
return -EINVAL;
return copy_to_user(optval, &vcc->qos, sizeof(vcc->qos))
? -EFAULT : 0;
case SO_SETCLP:
return put_user(vcc->atm_options & ATM_ATMOPT_CLP ? 1 : 0,
(unsigned long __user *)optval) ? -EFAULT : 0;
case SO_ATMPVC:
{
struct sockaddr_atmpvc pvc;
if (!vcc->dev || !test_bit(ATM_VF_ADDR, &vcc->flags))
return -ENOTCONN;
memset(&pvc, 0, sizeof(pvc));
pvc.sap_family = AF_ATMPVC;
pvc.sap_addr.itf = vcc->dev->number;
pvc.sap_addr.vpi = vcc->vpi;
pvc.sap_addr.vci = vcc->vci;
return copy_to_user(optval, &pvc, sizeof(pvc)) ? -EFAULT : 0;
}
default:
if (level == SOL_SOCKET)
return -EINVAL;
break;
}
if (!vcc->dev || !vcc->dev->ops->getsockopt)
return -EINVAL;
return vcc->dev->ops->getsockopt(vcc, level, optname, optval, len);
}
int register_atmdevice_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_register(&atm_dev_notify_chain, nb);
}
EXPORT_SYMBOL_GPL(register_atmdevice_notifier);
void unregister_atmdevice_notifier(struct notifier_block *nb)
{
atomic_notifier_chain_unregister(&atm_dev_notify_chain, nb);
}
EXPORT_SYMBOL_GPL(unregister_atmdevice_notifier);
static int __init atm_init(void)
{
int error;
error = proto_register(&vcc_proto, 0);
if (error < 0)
goto out;
error = atmpvc_init();
if (error < 0) {
pr_err("atmpvc_init() failed with %d\n", error);
goto out_unregister_vcc_proto;
}
error = atmsvc_init();
if (error < 0) {
pr_err("atmsvc_init() failed with %d\n", error);
goto out_atmpvc_exit;
}
error = atm_proc_init();
if (error < 0) {
pr_err("atm_proc_init() failed with %d\n", error);
goto out_atmsvc_exit;
}
error = atm_sysfs_init();
if (error < 0) {
pr_err("atm_sysfs_init() failed with %d\n", error);
goto out_atmproc_exit;
}
out:
return error;
out_atmproc_exit:
atm_proc_exit();
out_atmsvc_exit:
atmsvc_exit();
out_atmpvc_exit:
atmsvc_exit();
out_unregister_vcc_proto:
proto_unregister(&vcc_proto);
goto out;
}
static void __exit atm_exit(void)
{
atm_proc_exit();
atm_sysfs_exit();
atmsvc_exit();
atmpvc_exit();
proto_unregister(&vcc_proto);
}
subsys_initcall(atm_init);
module_exit(atm_exit);
MODULE_LICENSE("GPL");
MODULE_ALIAS_NETPROTO(PF_ATMPVC);
MODULE_ALIAS_NETPROTO(PF_ATMSVC);
|
ea02686f6dfbaacdd8d8eb88b76392c822bf3b87
|
55540f3e86f1d5d86ef6b5d295a63518e274efe3
|
/components/platform/soc/bl602/bl602_std/bl602_std/Common/libc/inc/arm_gcc/compat_param.h
|
cb7ae8fc01d18e03ecb1cec453758db2aa8131ea
|
[
"Apache-2.0",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown",
"BSD-4-Clause-UC",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
bouffalolab/bl_iot_sdk
|
bc5eaf036b70f8c65dd389439062b169f8d09daa
|
b90664de0bd4c1897a9f1f5d9e360a9631d38b34
|
refs/heads/master
| 2023-08-31T03:38:03.369853
| 2023-08-16T08:50:33
| 2023-08-18T09:13:27
| 307,347,250
| 244
| 101
|
Apache-2.0
| 2023-08-28T06:29:02
| 2020-10-26T11:16:30
|
C
|
UTF-8
|
C
| false
| false
| 133
|
h
|
compat_param.h
|
#ifndef _COMPAT_PARAM_H
#define _COMPAT_PARAM_H
#include <sys/param.h> /* need this to define BSD */
#endif /* _COMPAT_PARAM_H */
|
b9f0201fce53efcbe8aa0f60d794a83283ed0cac
|
e4eb547141929d5c61b3335c09904f258a65f5ea
|
/minijvm/c/jvm/class_load.c
|
cda35c5373ece00e0f66810f1b0200dbb7d33cf4
|
[
"MIT"
] |
permissive
|
digitalgust/miniJVM
|
14e11fa518e965ebe6c6b8172b2cacffde7a46d7
|
aa504d6c3c17a365a8f8f2ea91eb580d6ec94711
|
refs/heads/master
| 2023-08-22T12:55:31.981267
| 2023-08-10T07:09:28
| 2023-08-10T07:09:28
| 101,243,754
| 269
| 78
| null | 2023-03-08T06:50:54
| 2017-08-24T02:10:21
|
C
|
UTF-8
|
C
| false
| false
| 62,702
|
c
|
class_load.c
|
//
// Created by gust on 2017/9/25.
//
#include "stdlib.h"
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include "../utils/bytebuf.h"
#include "../utils/miniz_wrapper.h"
#include "jvm.h"
#include "jvm_util.h"
#include "garbage.h"
#include "jit.h"
/* parse UTF-8 String */
void *_parseCPString(JClass *_this, ByteBuf *buf, s32 index) {
ConstantUTF8 *ptr = jvm_calloc(sizeof(ConstantUTF8));
ptr->item.tag = CONSTANT_UTF8;
ptr->item.index = index;
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (c8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (c8) bytebuf_read(buf);//short_tmp[1];
ptr->string_size = s2c.s;
ptr->utfstr = utf8_create();
s32 i = 0;
for (; i < ptr->string_size; i++) {
u8 ch = (u8) bytebuf_read(buf);//0;
//fread(&ch, 1, 1, fp);
utf8_append_part_c(ptr->utfstr, &ch, 0, 1);
}
arraylist_push_back(_this->constantPool.utf8CP, ptr);
return ptr;
}
/* parse Integer */
void *_parseCPInteger(JClass *_this, ByteBuf *buf, s32 index) {
ConstantInteger *ptr = jvm_calloc(sizeof(ConstantInteger));
ptr->item.tag = CONSTANT_INTEGER;
ptr->item.index = index;
//fread(tmp, 4, 1, fp);
Int2Float i2c;
i2c.c3 = (u8) bytebuf_read(buf);//tmp[0];
i2c.c2 = (u8) bytebuf_read(buf);//tmp[1];
i2c.c1 = (u8) bytebuf_read(buf);//tmp[2];
i2c.c0 = (u8) bytebuf_read(buf);//tmp[3];
ptr->value = i2c.i;
return ptr;
}
/* parse Float */
void *_parseCPFloat(JClass *_this, ByteBuf *buf, s32 index) {
ConstantFloat *ptr = jvm_calloc(sizeof(ConstantFloat));
ptr->item.tag = CONSTANT_FLOAT;
ptr->item.index = index;
//fread(tmp, 4, 1, fp);
Int2Float i2c;
i2c.c3 = (u8) bytebuf_read(buf);//tmp[0];
i2c.c2 = (u8) bytebuf_read(buf);//tmp[1];
i2c.c1 = (u8) bytebuf_read(buf);//tmp[2];
i2c.c0 = (u8) bytebuf_read(buf);//tmp[3];
ptr->value = i2c.f;
return ptr;
}
/* parse LONG */
void *_parseCPLong(JClass *_this, ByteBuf *buf, s32 index) {
ConstantLong *ptr = jvm_calloc(sizeof(ConstantLong));
ptr->item.tag = CONSTANT_LONG;
ptr->item.index = index;
//fread(tmp, 8, 1, fp);
Long2Double l2d;
l2d.c7 = (u8) bytebuf_read(buf);//tmp[0];
l2d.c6 = (u8) bytebuf_read(buf);//tmp[1];
l2d.c5 = (u8) bytebuf_read(buf);//tmp[2];
l2d.c4 = (u8) bytebuf_read(buf);//tmp[3];
l2d.c3 = (u8) bytebuf_read(buf);//tmp[4];
l2d.c2 = (u8) bytebuf_read(buf);//tmp[5];
l2d.c1 = (u8) bytebuf_read(buf);//tmp[6];
l2d.c0 = (u8) bytebuf_read(buf);//tmp[7];
ptr->value = l2d.l;
return ptr;
}
/* parse Double */
void *_parseCPDouble(JClass *_this, ByteBuf *buf, s32 index) {
ConstantDouble *ptr = jvm_calloc(sizeof(ConstantDouble));
ptr->item.tag = CONSTANT_DOUBLE;
ptr->item.index = index;
//fread(tmp, 8, 1, fp);
Long2Double l2d;
l2d.c7 = (u8) bytebuf_read(buf);//tmp[0];
l2d.c6 = (u8) bytebuf_read(buf);//tmp[1];
l2d.c5 = (u8) bytebuf_read(buf);//tmp[2];
l2d.c4 = (u8) bytebuf_read(buf);//tmp[3];
l2d.c3 = (u8) bytebuf_read(buf);//tmp[4];
l2d.c2 = (u8) bytebuf_read(buf);//tmp[5];
l2d.c1 = (u8) bytebuf_read(buf);//tmp[6];
l2d.c0 = (u8) bytebuf_read(buf);//tmp[7];
ptr->value = l2d.d;
return ptr;
}
/* parse Constant Pool Class */
void *_parseCPClass(JClass *_this, ByteBuf *buf, s32 index) {
ConstantClassRef *ptr = jvm_calloc(sizeof(ConstantClassRef));
ptr->item.tag = CONSTANT_CLASS;
ptr->item.index = index;
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->stringIndex = s2c.s;
arraylist_push_back(_this->constantPool.classRef, ptr);
return ptr;
}
/* parse Constant Pool String Ref */
void *_parseCPStringRef(JClass *_this, ByteBuf *buf, s32 index) {
ConstantStringRef *ptr = jvm_calloc(sizeof(ConstantStringRef));
ptr->item.tag = CONSTANT_STRING_REF;
ptr->item.index = index;
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->stringIndex = s2c.s;
arraylist_push_back(_this->constantPool.stringRef, ptr);
return ptr;
}
/* parse Constant Pool Field */
void *_parseCPField(JClass *_this, ByteBuf *buf, s32 index) {
ConstantFieldRef *ptr = jvm_calloc(sizeof(ConstantFieldRef));
ptr->item.tag = CONSTANT_FIELD_REF;
ptr->item.index = index;
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->classIndex = s2c.s;
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->nameAndTypeIndex = s2c.s;
arraylist_push_back(_this->constantPool.fieldRef, ptr);
return ptr;
}
/* parse Constant Pool Method */
void *_parseCPMethod(JClass *_this, ByteBuf *buf, s32 index) {
ConstantMethodRef *ptr = jvm_calloc(sizeof(ConstantMethodRef));
ptr->para_slots = -1;
ptr->item.tag = CONSTANT_METHOD_REF;
ptr->item.index = index;
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->classIndex = s2c.s;
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->nameAndTypeIndex = s2c.s;
arraylist_push_back(_this->constantPool.methodRef, ptr);
return ptr;
}
void *_parseCPInterfaceMethod(JClass *_this, ByteBuf *buf, s32 index) {
ConstantInterfaceMethodRef *ptr = jvm_calloc(sizeof(ConstantInterfaceMethodRef));
ptr->item.tag = CONSTANT_INTERFACE_METHOD_REF;
ptr->item.index = index;
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->classIndex = s2c.s;
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->nameAndTypeIndex = s2c.s;
arraylist_push_back(_this->constantPool.interfaceMethodRef, ptr);
return ptr;
}
void *_parseCPNameAndType(JClass *_this, ByteBuf *buf, s32 index) {
ConstantNameAndType *ptr = jvm_calloc(sizeof(ConstantNameAndType));
ptr->item.tag = CONSTANT_NAME_AND_TYPE;
ptr->item.index = index;
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->nameIndex = s2c.s;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->typeIndex = s2c.s;
return ptr;
}
void *_parseCPMethodType(JClass *_this, ByteBuf *buf, s32 index) {
ConstantMethodType *ptr = jvm_calloc(sizeof(ConstantNameAndType));
ptr->item.tag = CONSTANT_METHOD_TYPE;
ptr->item.index = index;
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->descriptor_index = s2c.s;
return ptr;
}
void *_parseCPMethodHandle(JClass *_this, ByteBuf *buf, s32 index) {
ConstantMethodHandle *ptr = jvm_calloc(sizeof(ConstantNameAndType));
ptr->item.tag = CONSTANT_METHOD_HANDLE;
ptr->item.index = index;
ptr->reference_kind = (u8) bytebuf_read(buf);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->reference_index = s2c.s;
return ptr;
}
void *_parseCPInvokeDynamic(JClass *_this, ByteBuf *buf, s32 index) {
ConstantInvokeDynamic *ptr = jvm_calloc(sizeof(ConstantNameAndType));
ptr->item.tag = CONSTANT_INVOKE_DYNAMIC;
ptr->item.index = index;
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->bootstrap_method_attr_index = s2c.s;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->nameAndTypeIndex = s2c.s;
return ptr;
}
s32 _class_constant_pool_destory(JClass *clazz) {
int i;
for (i = 0; i < clazz->constant_item_count; i++) {
ConstantItem *cptr = clazz->constant_item_ptr[i];
if (cptr) {
switch (cptr->tag) {
case CONSTANT_UTF8: {
ConstantUTF8 *ptr = (ConstantUTF8 *) cptr;
if (ptr->utfstr) {
utf8_destory(ptr->utfstr);
ptr->utfstr = NULL;
}
break;
}
case CONSTANT_METHOD_REF: {
ConstantMethodRef *ptr = (ConstantMethodRef *) cptr;
if (ptr->virtual_methods) {
pairlist_destory(ptr->virtual_methods);
ptr->virtual_methods = NULL;
}
break;
}
}
}
jvm_free(cptr);
}
return 0;
}
s32 _parseAttr(FieldInfo *ptr, ByteBuf *buf) {
s32 i;
AttributeInfo *tmp = 0;
#if 0
jvm_printf("fieldRef attributes_count = %d\n", arr_body->attributes_count);
#endif
for (i = 0; i < ptr->attributes_count; i++) {
tmp = &(ptr->attributes[i]);
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
tmp->attribute_name_index = s2c.s;
//fread(integer_tmp, 4, 1, fp);
Int2Float i2c;
i2c.c3 = (u8) bytebuf_read(buf);//integer_tmp[0];
i2c.c2 = (u8) bytebuf_read(buf);//integer_tmp[1];
i2c.c1 = (u8) bytebuf_read(buf);//integer_tmp[2];
i2c.c0 = (u8) bytebuf_read(buf);//integer_tmp[3];
tmp->attribute_length = i2c.i;
if (tmp->attribute_length > 0) {
tmp->info = (u8 *) jvm_calloc(sizeof(u8) * tmp->attribute_length);
//fread(tmp->info, tmp->attribute_length, 1, fp);
bytebuf_read_batch(buf, (c8 *) tmp->info, tmp->attribute_length);
} else {
tmp->info = NULL;
}
}
return 0;
}
/* parse Field Pool */
s32 _parseFP(JClass *_this, ByteBuf *buf) {
FieldInfo *ptr = &(_this->fieldPool.field[_this->fieldPool.field_used]);
/* access flag */
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->access_flags = s2c.s;
/* name index */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->name_index = s2c.s;
/* descriptor index */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->descriptor_index = s2c.s;
/* attributes count */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->attributes_count = s2c.s;
if (ptr->attributes_count > 0) {
ptr->attributes = (AttributeInfo *) jvm_calloc(sizeof(AttributeInfo) * ptr->attributes_count);
} else {
ptr->attributes = NULL;
}
/* parse attributes */
_parseAttr(ptr, buf);
_this->fieldPool.field_used++;
return 0;
}
s32 _parse_field_pool(JClass *_this, ByteBuf *buf, s32 count) {
s32 size = sizeof(FieldInfo) * count;
_this->fieldPool.field = jvm_calloc(size);
s32 i;
for (i = 0; i < count; i++)
_parseFP(_this, buf);
return 0;
}
s32 _class_field_info_destory(JClass *clazz) {
s32 i, j;
for (i = 0; i < clazz->fieldPool.field_used; i++) {
FieldInfo *fi = &clazz->fieldPool.field[i];
for (j = 0; j < fi->attributes_count; j++) {
AttributeInfo *attr = &fi->attributes[j];
jvm_free(attr->info);
attr->info = NULL;
}
if (fi->attributes)jvm_free(fi->attributes);
fi->attributes = NULL;
}
if (clazz->fieldPool.field)jvm_free(clazz->fieldPool.field);
clazz->fieldPool.field = NULL;
return 0;
}
/* parse Interface Pool Class */
s32 _parseIPClass(JClass *_this, ByteBuf *buf, s32 index) {
ConstantClassRef *ptr = &_this->interfacePool.clasz[_this->interfacePool.clasz_used];
ptr->item.tag = CONSTANT_CLASS;
ptr->item.index = index;
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->stringIndex = s2c.s;
_this->interfacePool.clasz_used++;
return 0;
}
s32 _parse_interface_pool(JClass *_this, ByteBuf *buf, s32 count) {
s32 size = sizeof(ConstantClassRef) * count;
_this->interfacePool.clasz = jvm_calloc(size);
s32 i;
for (i = 0; i < count; i++)
_parseIPClass(_this, buf, i);
return 0;
}
s32 _class_interface_pool_destory(JClass *clazz) {
if (clazz->interfacePool.clasz)jvm_free(clazz->interfacePool.clasz);
clazz->interfacePool.clasz = NULL;
return 0;
}
//================================= load ======================================
s32 _parseMethodAttr(MethodInfo *ptr, ByteBuf *buf) {
s32 i;
AttributeInfo *tmp = 0;
for (i = 0; i < ptr->attributes_count; i++) {
tmp = &ptr->attributes[i];
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
tmp->attribute_name_index = s2c.s;
//fread(integer_tmp, 4, 1, fp);
Int2Float i2c;
i2c.c3 = (u8) bytebuf_read(buf);//integer_tmp[0];
i2c.c2 = (u8) bytebuf_read(buf);//integer_tmp[1];
i2c.c1 = (u8) bytebuf_read(buf);//integer_tmp[2];
i2c.c0 = (u8) bytebuf_read(buf);//integer_tmp[3];
tmp->attribute_length = i2c.i;
tmp->info = (u8 *) jvm_calloc(sizeof(u8) * tmp->attribute_length);
//fread(tmp->info, tmp->attribute_length, 1, fp);
bytebuf_read_batch(buf, (c8 *) tmp->info, tmp->attribute_length);
}
return 0;
}
/* parse Method Pool */
s32 _parseMP(JClass *_this, ByteBuf *buf) {
MethodInfo *ptr = &(_this->methodPool.method[_this->methodPool.method_used]);
/* access flag */
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->access_flags = s2c.s;
ptr->is_native = (s2c.s & ACC_NATIVE) != 0;
ptr->is_sync = (s2c.s & ACC_SYNCHRONIZED) != 0;
ptr->is_static = (s2c.s & ACC_STATIC) != 0;
/* name index */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->name_index = s2c.s;
/* descriptor index */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->descriptor_index = s2c.s;
/* attributes count */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->attributes_count = s2c.s;
if (ptr->attributes_count) {
ptr->attributes = (AttributeInfo *) jvm_calloc(sizeof(AttributeInfo) * ptr->attributes_count);
}
/* parse methodRef attributes */
_parseMethodAttr(ptr, buf);
_this->methodPool.method_used++;
return 0;
}
s32 _parse_method_pool(JClass *_this, ByteBuf *buf, s32 count) {
s32 size = sizeof(MethodInfo) * count;
_this->methodPool.method = jvm_calloc(size);
s32 i;
for (i = 0; i < count; i++)
_parseMP(_this, buf);
return 0;
}
s32 _class_method_info_destory(JClass *clazz) {
s32 i, j;
for (i = 0; i < clazz->methodPool.method_used; i++) {
MethodInfo *mi = &clazz->methodPool.method[i];
for (j = 0; j < mi->attributes_count; j++) {
AttributeInfo *attr = &mi->attributes[j];
if (attr->info)jvm_free(attr->info);//某些没有转
attr->info = NULL;
}
if (mi->converted_code) {
CodeAttribute *ca = (CodeAttribute *) mi->converted_code;
jvm_free(ca->code);//info已被转换为converted_attribute
ca->code = NULL;
jvm_free(ca->bytecode_for_jit);//
ca->bytecode_for_jit = NULL;
jvm_free(ca->exception_table);//info已被转换为converted_attribute
ca->exception_table = NULL;
jvm_free(ca->line_number_table);
ca->line_number_table = NULL;
if (ca->local_var_table)jvm_free(ca->local_var_table);
ca->local_var_table = NULL;
jit_destory(&ca->jit);
//
jvm_free(mi->converted_code);
mi->converted_code = NULL;
}
if (mi->attributes)jvm_free(mi->attributes);
mi->attributes = NULL;
if (mi->jump_2_pos)pairlist_destory(mi->jump_2_pos);
mi->jump_2_pos = NULL;
if (mi->pos_2_label)pairlist_destory(mi->pos_2_label);
mi->pos_2_label = NULL;
utf8_destory(mi->paraType);
utf8_destory(mi->returnType);
if (mi->breakpoint)jvm_free(mi->breakpoint);
mi->breakpoint = NULL;
}
if (clazz->methodPool.method)jvm_free(clazz->methodPool.method);
clazz->methodPool.method = NULL;
return 0;
}
s32 _parse_attribute_pool(JClass *_this, ByteBuf *buf, s32 count) {
s32 size = sizeof(AttributeInfo) * count;
_this->attributePool.attribute = jvm_calloc(size);
_this->attributePool.attribute_used = count;
s32 i;
for (i = 0; i < count; i++) {
AttributeInfo *ptr = &(_this->attributePool.attribute[i]);
/* access flag */
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (u8) bytebuf_read(buf);//short_tmp[0];
s2c.c0 = (u8) bytebuf_read(buf);//short_tmp[1];
ptr->attribute_name_index = s2c.s;
//fread(integer_tmp, 4, 1, fp);
Int2Float i2c;
i2c.c3 = (u8) bytebuf_read(buf);//integer_tmp[0];
i2c.c2 = (u8) bytebuf_read(buf);//integer_tmp[1];
i2c.c1 = (u8) bytebuf_read(buf);//integer_tmp[2];
i2c.c0 = (u8) bytebuf_read(buf);//integer_tmp[3];
ptr->attribute_length = i2c.i;
//
ptr->info = jvm_calloc(ptr->attribute_length);
//fread(ptr->info, ptr->attribute_length, 1, fp);
bytebuf_read_batch(buf, (c8 *) ptr->info, ptr->attribute_length);
}
return 0;
}
s32 _class_attribute_info_destory(JClass *clazz) {
s32 i;
for (i = 0; i < clazz->attributePool.attribute_used; i++) {
AttributeInfo *ptr = &(clazz->attributePool.attribute[i]);
if (ptr->info) {
jvm_free(ptr->info);
ptr->info = NULL;
}
}
if (clazz->attributePool.attribute)jvm_free(clazz->attributePool.attribute);
return 0;
}
s32 _parse_constant_pool(JClass *_this, ByteBuf *buf, s32 count) {
u8 tag = 0;
s32 i = 0;
u64 offset_start = 0;
u64 offset_end = 0;
_this->constant_item_ptr = jvm_calloc(count * sizeof(void *));
_this->constant_item_count = count;
for (i = 1; i < count; i++) {
//fread(&tag, 1, 1, fp);
tag = (u8) bytebuf_read(buf);
offset_start = buf->rp;
//jvm_printf("!!!read tag = %02x!!!\n", tag);
__refer ptr = NULL;
s32 idx = i;
switch (tag) {
case CONSTANT_UTF8:
ptr = _parseCPString(_this, buf, i);
break;
case CONSTANT_INTEGER:
ptr = _parseCPInteger(_this, buf, i);
break;
case CONSTANT_FLOAT:
ptr = _parseCPFloat(_this, buf, i);
break;
case CONSTANT_LONG:
ptr = _parseCPLong(_this, buf, i);
i++;
break;
case CONSTANT_DOUBLE:
ptr = _parseCPDouble(_this, buf, i);
i++;
break;
case CONSTANT_STRING_REF:
ptr = _parseCPStringRef(_this, buf, i);
break;
case CONSTANT_CLASS:
ptr = _parseCPClass(_this, buf, i);
break;
case CONSTANT_FIELD_REF:
ptr = _parseCPField(_this, buf, i);
break;
case CONSTANT_METHOD_REF:
ptr = _parseCPMethod(_this, buf, i);
break;
case CONSTANT_INTERFACE_METHOD_REF:
ptr = _parseCPMethod(_this, buf, i);//parseCPInterface(_this, fp, i);
break;
case CONSTANT_NAME_AND_TYPE:
ptr = _parseCPNameAndType(_this, buf, i);
break;
case CONSTANT_METHOD_TYPE:
ptr = _parseCPMethodType(_this, buf, i);
break;
case CONSTANT_METHOD_HANDLE:
ptr = _parseCPMethodHandle(_this, buf, i);
break;
case CONSTANT_INVOKE_DYNAMIC:
ptr = _parseCPInvokeDynamic(_this, buf, i);
break;
default:
jvm_printf("\n!!!unknow constant item tag = %02x!!!\n\n", tag);
//fseek(fp, -1, SEEK_CUR);
break;
};
offset_end = buf->rp;
_this->constant_item_ptr[idx] = ptr;
}
return 0;
}
/**
* change bytes order in method bytecode to cpu bytes order
* @param method
*/
void _changeBytesOrder(MethodInfo *method) {
method->pos_2_label = pairlist_create(4);
method->jump_2_pos = pairlist_create(4);
CodeAttribute *ca = method->converted_code;
spin_init(&ca->compile_lock, 0);
u8 *ip = ca->code;
u8 *end = ca->code_length + ip;
//jvm_printf("adapte method %s.%s()\n", method->_this_class->name->data, method->name->data);
while (ip < end) {
u8 cur_inst = *ip;
s32 code_idx = (s32) (ip - ca->code);
if (cur_inst < op_breakpoint) {
// if (utf8_equals_c(method->name, "test_typecast"))
// jvm_printf("%8d, %s\n", pc, inst_name[cur_inst]);
} else {
int debug = 1;
}
switch (cur_inst) {
case op_nop:
case op_aconst_null:
case op_iconst_m1:
case op_iconst_0:
case op_iconst_1:
case op_iconst_2:
case op_iconst_3:
case op_iconst_4:
case op_iconst_5:
case op_lconst_0:
case op_lconst_1:
case op_fconst_0:
case op_fconst_1:
case op_fconst_2:
case op_dconst_0:
case op_dconst_1: {
ip++;
break;
}
case op_bipush: {
ip += 2;
break;
}
case op_sipush: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_ldc: {
ip += 2;
break;
}
case op_ldc_w: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_ldc2_w: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_iload:
case op_fload:
case op_aload: {
ip += 2;
break;
}
case op_lload:
case op_dload: {
ip += 2;
break;
}
case op_iload_0:
case op_iload_1:
case op_iload_2:
case op_iload_3:
case op_lload_0:
case op_lload_1:
case op_lload_2:
case op_lload_3:
case op_fload_0:
case op_fload_1:
case op_fload_2:
case op_fload_3:
case op_dload_0:
case op_dload_1:
case op_dload_2:
case op_dload_3:
case op_aload_0:
case op_aload_1:
case op_aload_2:
case op_aload_3:
case op_iaload:
case op_faload:
case op_laload:
case op_daload:
case op_aaload:
case op_baload:
case op_caload:
case op_saload: {
ip++;
break;
}
case op_istore:
case op_fstore:
case op_astore:
case op_lstore:
case op_dstore: {
ip += 2;
break;
}
case op_istore_0:
case op_istore_1:
case op_istore_2:
case op_istore_3:
case op_lstore_0:
case op_lstore_1:
case op_lstore_2:
case op_lstore_3:
case op_fstore_0:
case op_fstore_1:
case op_fstore_2:
case op_fstore_3:
case op_dstore_0:
case op_dstore_1:
case op_dstore_2:
case op_dstore_3:
case op_astore_0:
case op_astore_1:
case op_astore_2:
case op_astore_3:
case op_fastore:
case op_iastore:
case op_dastore:
case op_lastore:
case op_aastore:
case op_bastore:
case op_castore:
case op_sastore:
case op_pop:
case op_pop2:
case op_dup:
case op_dup_x1:
case op_dup_x2:
case op_dup2:
case op_dup2_x1:
case op_dup2_x2:
case op_swap:
case op_iadd:
case op_ladd:
case op_fadd:
case op_dadd:
case op_isub:
case op_lsub:
case op_fsub:
case op_dsub:
case op_imul:
case op_lmul:
case op_fmul:
case op_dmul:
case op_idiv:
case op_ldiv:
case op_fdiv:
case op_ddiv:
case op_irem:
case op_lrem:
case op_frem:
case op_drem:
case op_ineg:
case op_lneg:
case op_fneg:
case op_dneg:
case op_ishl:
case op_lshl:
case op_ishr:
case op_lshr:
case op_iushr:
case op_lushr:
case op_iand:
case op_land:
case op_ior:
case op_lor:
case op_ixor:
case op_lxor: {
ip++;
break;
}
case op_iinc: {
ip += 3;
break;
}
case op_i2l:
case op_i2f:
case op_i2d:
case op_l2i:
case op_l2f:
case op_l2d:
case op_f2i:
case op_f2l:
case op_f2d:
case op_d2i:
case op_d2l:
case op_d2f:
case op_i2b:
case op_i2c:
case op_i2s:
case op_lcmp:
case op_fcmpl:
case op_fcmpg:
case op_dcmpl:
case op_dcmpg: {
ip++;
break;
}
case op_ifeq:
case op_ifne:
case op_iflt:
case op_ifge:
case op_ifgt:
case op_ifle:
case op_if_icmpeq:
case op_if_icmpne:
case op_if_icmplt:
case op_if_icmpge:
case op_if_icmpgt:
case op_if_icmple:
case op_if_acmpeq:
case op_if_acmpne:
case op_goto:
case op_jsr: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((s16 *) addr) = s2c.s;
s32 jumpto = code_idx + s2c.s;
pairlist_putl(method->pos_2_label, jumpto, -1);// save label pos in list
pairlist_putl(method->pos_2_label, code_idx + 3, -1);// save label pos in list
ip += 3;
break;
}
case op_ret: {
ip += 2;
break;
}
case op_tableswitch: {
s32 pos = 0;
pos = 4 - ((((u64) (intptr_t) ip) - (u64) (intptr_t) (ca->code)) % 4);//4 byte对齐
u8 *addr = ip + pos;
Int2Float i2c;
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
s32 default_offset = i2c.i;
pairlist_putl(method->pos_2_label, code_idx + i2c.i, -1);
*((s32 *) addr) = i2c.i;
addr += 4;
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
s32 low = i2c.i;
*((s32 *) addr) = i2c.i;
addr += 4;
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
s32 high = i2c.i;
*((s32 *) addr) = i2c.i;
addr += 4;
//
s32 i = low;
for (; i <= high; i++) {
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
*((s32 *) addr) = i2c.i;
pairlist_putl(method->pos_2_label, code_idx + i2c.i, -1);// save label pos in list
addr += 4;
}
ip += pos;
break;
}
case op_lookupswitch: {
s32 pos = 0;
pos = 4 - ((((u64) (intptr_t) ip) - (u64) (intptr_t) (ca->code)) % 4);//4 byte对齐
u8 *addr = ip + pos;
Int2Float i2c;
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
s32 default_offset = i2c.i;
pairlist_putl(method->pos_2_label, code_idx + i2c.i, -1);
*((s32 *) addr) = i2c.i;
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
s32 n = i2c.i;
addr += 4;
*((s32 *) addr) = i2c.i;
s32 i, key;
int offset = default_offset;
for (i = 0; i < n; i++) {
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
key = i2c.i;
addr += 4;
*((s32 *) addr) = i2c.i;
i2c.c3 = ip[pos++];
i2c.c2 = ip[pos++];
i2c.c1 = ip[pos++];
i2c.c0 = ip[pos++];
offset = i2c.i;
pairlist_putl(method->pos_2_label, code_idx + i2c.i, -1);// save label pos in list
addr += 4;
*((s32 *) addr) = i2c.i;
}
ip += pos;
break;
}
case op_lreturn:
case op_dreturn:
case op_ireturn:
case op_freturn:
case op_areturn:
case op_return: {
ip++;
break;
}
case op_getstatic:
case op_putstatic:
case op_getfield:
case op_putfield: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_invokevirtual: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_invokespecial: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_invokestatic: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_invokeinterface: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 5;
break;
}
case op_invokedynamic: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 5;
break;
}
case op_new: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_newarray: {
ip += 2;
break;
}
case op_anewarray: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_arraylength: {
ip++;
break;
}
case op_athrow: {
ip++;
break;
}
case op_checkcast: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_instanceof: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_monitorenter:
case op_monitorexit: {
ip++;
break;
}
case op_wide: {
ip++;
cur_inst = *ip;
switch (cur_inst) {
case op_iload:
case op_fload:
case op_aload:
case op_lload:
case op_dload:
case op_istore:
case op_fstore:
case op_astore:
case op_lstore:
case op_dstore:
case op_ret: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 3;
break;
}
case op_iinc : {
Short2Char s2c1, s2c2;
s2c1.c1 = ip[1];
s2c1.c0 = ip[2];
s2c2.c1 = ip[3];
s2c2.c0 = ip[4];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c1.us;
addr += 2;
*((u16 *) addr) = s2c2.us;
ip += 5;
break;
}
default:
jvm_printf("instruct wide %x not found\n", cur_inst);
}
break;
}
case op_multianewarray: {
//data type index
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
ip += 4;
break;
}
case op_ifnull:
case op_ifnonnull: {
Short2Char s2c;
s2c.c1 = ip[1];
s2c.c0 = ip[2];
u8 *addr = ip + 1;
*((u16 *) addr) = s2c.us;
s32 jumpto = code_idx + s2c.s;
pairlist_putl(method->pos_2_label, jumpto, -1);// save label pos in list
ip += 3;
break;
}
case op_breakpoint: {
ip += 1;
break;
}
case op_goto_w: {
Int2Float i2f;
i2f.c3 = ip[1];
i2f.c2 = ip[2];
i2f.c1 = ip[3];
i2f.c0 = ip[4];
u8 *addr = ip + 1;
*((s32 *) addr) = i2f.i;
s32 jumpto = code_idx + i2f.i;
pairlist_putl(method->pos_2_label, jumpto, -1);// save label pos in list
ip += 5;
break;
}
case op_jsr_w: {
Int2Float i2f;
i2f.c3 = ip[1];
i2f.c2 = ip[2];
i2f.c1 = ip[3];
i2f.c0 = ip[4];
u8 *addr = ip + 1;
*((s32 *) addr) = i2f.i;
s32 jumpto = code_idx + i2f.i;
pairlist_putl(method->pos_2_label, jumpto, -1);// save label pos in list
pairlist_putl(method->pos_2_label, code_idx + 5, -1);// save label pos in list
ip += 5;
break;
}
default:
jvm_printf("adapte instruct %x not found\n", cur_inst);
}
}
memcpy(ca->bytecode_for_jit, ca->code, ca->code_length);
u8 *mc = ca->code;
if (ca->code_length == 5) {//optimize setter eg: void setSize(int size){this.size=size;}
u8 mc4 = mc[4];
if (mc[1] == op_getfield
&& mc[0] == op_aload_0
&& (mc4 >= op_ireturn && mc4 <= op_areturn)) {
method->is_getter = 1;
//jvm_printf(" getter %s.%s %d \n", utf8_cstr(method->_this_class->name), utf8_cstr(method->name), method->_this_class->status);
}
} else if (ca->code_length == 6) {//optimize setter eg: void setSize(int size){this.size=size;}
u8 mc1 = mc[1];
if (mc[5] == op_return
&& mc[0] == op_aload_0
&& mc[2] == op_putfield
&& (mc1 == op_aload_1 || mc1 == op_dload_1 || mc1 == op_lload_1 || mc1 == op_iload_1 || mc1 == op_fload_1)) {
method->is_setter = 1;
//jvm_printf(" setter %s.%s %d \n", utf8_cstr(method->_this_class->name), utf8_cstr(method->name), method->_this_class->status);
}
}
}
s32 _convert_to_code_attribute(CodeAttribute *ca, AttributeInfo *attr, JClass *clazz) {
s32 info_p = 0;
ca->attribute_name_index = attr->attribute_name_index;
ca->attribute_length = attr->attribute_length;
Short2Char s2c;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->max_stack = s2c.s;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->max_locals = s2c.s;
Int2Float i2c;
i2c.c3 = attr->info[info_p++];
i2c.c2 = attr->info[info_p++];
i2c.c1 = attr->info[info_p++];
i2c.c0 = attr->info[info_p++];
ca->code_length = i2c.i;
ca->code = (u8 *) jvm_calloc(sizeof(u8) * ca->code_length);
ca->bytecode_for_jit = (u8 *) jvm_calloc(sizeof(u8) * ca->code_length);
memcpy(ca->code, attr->info + info_p, ca->code_length);
info_p += ca->code_length;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->exception_table_length = s2c.s;
s32 bytelen = sizeof(ExceptionTable) * ca->exception_table_length;
ca->exception_table = jvm_calloc(bytelen);
int i;
for (i = 0; i < 4 * ca->exception_table_length; i++) {
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
((u16 *) ca->exception_table)[i] = s2c.s;
}
//line number
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
s32 attr_count = (u16) s2c.s;
for (i = 0; i < attr_count; i++) {
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
s32 attribute_name_index = (u16) s2c.s;
i2c.c3 = attr->info[info_p++];
i2c.c2 = attr->info[info_p++];
i2c.c1 = attr->info[info_p++];
i2c.c0 = attr->info[info_p++];
s32 attribute_lenth = (u32) i2c.i;
//转行号表
if (utf8_equals_c(class_get_utf8_string(clazz, attribute_name_index), "LineNumberTable")) {
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->line_number_table_length = (u16) s2c.s;
ca->line_number_table = jvm_calloc(sizeof(u32) * ca->line_number_table_length);
s32 j;
for (j = 0; j < ca->line_number_table_length; j++) {
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
//setFieldShort(ca->line_number_table[j].start_pc, s2c.s);
ca->line_number_table[j].start_pc = s2c.s;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
//setFieldShort(ca->line_number_table[j].line_number, s2c.s);
ca->line_number_table[j].line_number = s2c.s;
}
} else if (utf8_equals_c(class_get_utf8_string(clazz, attribute_name_index), "LocalVariableTable")) {
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->local_var_table_length = (u16) s2c.s;
ca->local_var_table = jvm_calloc(sizeof(LocalVarTable) * ca->local_var_table_length);
s32 j;
for (j = 0; j < ca->local_var_table_length; j++) {
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->local_var_table[j].start_pc = s2c.s;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->local_var_table[j].length = s2c.s;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->local_var_table[j].name_index = s2c.s;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->local_var_table[j].descriptor_index = s2c.s;
s2c.c1 = attr->info[info_p++];
s2c.c0 = attr->info[info_p++];
ca->local_var_table[j].index = s2c.s;
}
} else {
info_p += attribute_lenth;
}
}
return 0;
}
void _convert_2_bootstrap_methods(AttributeInfo *attr, JClass *clazz) {
BootstrapMethodsAttr *bms = jvm_calloc(sizeof(BootstrapMethodsAttr));
s32 ptr = 0;
Short2Char s2c;
s2c.c1 = attr->info[ptr++];
s2c.c0 = attr->info[ptr++];
bms->num_bootstrap_methods = s2c.s;
bms->bootstrap_methods = jvm_calloc(sizeof(BootstrapMethod) * bms->num_bootstrap_methods);
s32 i;
for (i = 0; i < bms->num_bootstrap_methods; i++) {
BootstrapMethod *bm = &bms->bootstrap_methods[i];
s2c.c1 = attr->info[ptr++];
s2c.c0 = attr->info[ptr++];
bm->bootstrap_method_ref = s2c.s;
s2c.c1 = attr->info[ptr++];
s2c.c0 = attr->info[ptr++];
bm->num_bootstrap_arguments = s2c.s;
bm->bootstrap_arguments = jvm_calloc(sizeof(u16) * bm->num_bootstrap_arguments);
s32 j;
for (j = 0; j < bm->num_bootstrap_arguments; j++) {
s2c.c1 = attr->info[ptr++];
s2c.c0 = attr->info[ptr++];
bm->bootstrap_arguments[j] = s2c.s;
}
}
jvm_free(attr->info);
attr->info = NULL;
clazz->bootstrapMethodAttr = bms;
}
void _class_bootstrap_methods_destory(JClass *clazz) {
BootstrapMethodsAttr *bms = clazz->bootstrapMethodAttr;
if (!bms)return;
s32 i;
for (i = 0; i < bms->num_bootstrap_methods; i++) {
BootstrapMethod *bm = &bms->bootstrap_methods[i];
if (bm->bootstrap_arguments) {
jvm_free(bm->bootstrap_arguments);
}
}
jvm_free(bms->bootstrap_methods);
jvm_free(bms);
clazz->bootstrapMethodAttr = NULL;
}
s32 parseMethodPara(Utf8String *methodType, Utf8String *out) {
s32 count = 0;
Utf8String *para = utf8_create_copy(methodType);
utf8_substring(para, utf8_indexof_c(para, "(") + 1, utf8_last_indexof_c(para, ")"));
//从后往前拆分方法参数,从栈中弹出放入本地变量
int i = 0;
while (para->length > 0) {
c8 ch = utf8_char_at(para, 0);
switch (ch) {
case 'S':
case 'C':
case 'B':
case 'I':
case 'F':
case 'Z':
utf8_substring(para, 1, para->length);
utf8_append_c(out, "4");
count++;
break;
case 'D':
case 'J': {
utf8_substring(para, 1, para->length);
utf8_append_c(out, "8");
count += 2;
break;
}
case 'L':
utf8_substring(para, utf8_indexof_c(para, ";") + 1, para->length);
utf8_append_c(out, "R");
count += 1;
break;
case '[':
while (utf8_char_at(para, 1) == '[') {
utf8_substring(para, 1, para->length);//去掉多维中的 [[[[LObject; 中的 [符
}
if (utf8_char_at(para, 1) == 'L') {
utf8_substring(para, utf8_indexof_c(para, ";") + 1, para->length);
} else {
utf8_substring(para, 2, para->length);
}
utf8_append_c(out, "R");
count += 1;
break;
}
i++;
}
utf8_destory(para);
return count;
}
/**
* 把各个索引转为直接地址引用,加快处理速度
* @param clazz class
*/
void _class_optimize(JClass *clazz) {
Utf8String *ustr = class_get_utf8_string(clazz,
class_get_constant_classref(clazz, clazz->cff.this_class)->stringIndex);
clazz->name = utf8_create_copy(ustr);
// if (utf8_equals_c(clazz->name, "com/meslewis/simplegltf2/simpleviewer/SimpleViewer$1")) {
// int debug = 1;
// }
s32 i;
for (i = 0; i < clazz->interfacePool.clasz_used; i++) {
ConstantClassRef *ptr = &clazz->interfacePool.clasz[i];
ptr->name = class_get_utf8_string(clazz, class_get_constant_classref(clazz, ptr->stringIndex)->stringIndex);
}
for (i = 0; i < clazz->fieldPool.field_used; i++) {
FieldInfo *fi = &clazz->fieldPool.field[i];
fi->name = class_get_utf8_string(clazz, fi->name_index);
fi->descriptor = class_get_utf8_string(clazz, fi->descriptor_index);
fi->datatype_idx = getDataTypeIndex(utf8_char_at(fi->descriptor, 0));
fi->isrefer = isDataReferByIndex(fi->datatype_idx);
fi->datatype_bytes = DATA_TYPE_BYTES[fi->datatype_idx];
fi->isvolatile = fi->access_flags & ACC_VOLATILE;
//for gc iterator fast
if (isDataReferByIndex(fi->datatype_idx)) {
if (fi->access_flags & ACC_STATIC) {
arraylist_push_back_unsafe(clazz->staticFieldPtrIndex, fi);
} else {
arraylist_push_back_unsafe(clazz->insFieldPtrIndex, fi);
}
}
//for static final
s32 j;
for (j = 0; j < fi->attributes_count; j++) {
AttributeInfo *att = &fi->attributes[j];
Utf8String *attName = class_get_constant_utf8(clazz, att->attribute_name_index)->utfstr;
if (utf8_equals_c(attName, "ConstantValue")) {
Short2Char s2c;
s2c.c1 = att->info[0];
s2c.c0 = att->info[1];
fi->const_value_item = class_get_constant_item(clazz, s2c.us);
} else if (utf8_equals_c(attName, "Signature")) {
Short2Char s2c;
s2c.c1 = att->info[0];
s2c.c0 = att->info[1];
fi->signature = class_get_utf8_string(clazz, s2c.us);
}
}
}
for (i = 0; i < clazz->methodPool.method_used; i++) {
MethodInfo *ptr = &clazz->methodPool.method[i];
ptr->name = class_get_utf8_string(clazz, ptr->name_index);
ptr->descriptor = class_get_utf8_string(clazz, ptr->descriptor_index);
ptr->_this_class = clazz;
if (!ptr->paraType) {//首次执行
// eg: (Ljava/lang/Object;IBLjava/lang/String;[[[ILjava/lang/Object;)Ljava/lang/String;Z
ptr->paraType = utf8_create();
//parse method description return slots
ptr->para_slots = parseMethodPara(ptr->descriptor, ptr->paraType);
ptr->para_count_with_this = ptr->paraType->length;
if (!(ptr->is_static)) {
ptr->para_slots++;//add this pointer
ptr->para_count_with_this++;
}
s32 pos = utf8_indexof_c(ptr->descriptor, ")") + 1;
ptr->returnType = utf8_create_part(ptr->descriptor, pos, ptr->descriptor->length - pos);
c8 ch = utf8_char_at(ptr->returnType, 0);
if (ch == 'J' || ch == 'D') {
ptr->return_slots = 2;
} else if (ch == 'V') {
ptr->return_slots = 0;
} else {
ptr->return_slots = 1;
}
}
s32 j;
//转attribute为CdoeAttribute
for (j = 0; j < ptr->attributes_count; j++) {
Utf8String *attname = class_get_utf8_string(clazz, ptr->attributes[j].attribute_name_index);
if (utf8_equals_c(attname, "Code") == 1) {
// if (utf8_equals_c(clazz->name, "espresso/syntaxtree/ExpressionNode") && utf8_equals_c(ptr->name, "evaluateExp")) {
// int debug = 1;
// }
CodeAttribute *ca = jvm_calloc(sizeof(CodeAttribute));
_convert_to_code_attribute(ca, &ptr->attributes[j], clazz);
jvm_free(ptr->attributes[j].info);//无用删除
ptr->attributes[j].info = NULL;
ptr->converted_code = ca;
_changeBytesOrder(ptr);
jit_init(ca);
} else if (utf8_equals_c(attname, "Signature") == 1) {
Short2Char s2c;
s2c.c1 = ptr->attributes[j].info[0];
s2c.c0 = ptr->attributes[j].info[1];
ptr->signature = class_get_utf8_string(clazz, s2c.us);
} else if (utf8_equals_c(attname, "Exceptions") == 1) {
Short2Char s2c;
s2c.c1 = ptr->attributes[j].info[0];
s2c.c0 = ptr->attributes[j].info[1];
((u16 *) ptr->attributes[j].info)[0] = s2c.us;
s32 cnt = s2c.us;
s32 k;
for (k = 1; k < cnt + 1; k++) {
s2c.c1 = ptr->attributes[j].info[k * 2 + 0];
s2c.c0 = ptr->attributes[j].info[k * 2 + 1];
((u16 *) ptr->attributes[j].info)[k] = s2c.us;
}
ptr->exceptions_index_in_attributes = j;
}
}
}
for (i = 0; i < clazz->attributePool.attribute_used; i++) {
AttributeInfo *ptr = &clazz->attributePool.attribute[i];
Utf8String *name = class_get_utf8_string(clazz, ptr->attribute_name_index);
if (utf8_equals_c(name, "SourceFile")) {
Short2Char s2c;
s2c.c1 = ptr->info[0];
s2c.c0 = ptr->info[1];
clazz->source = class_get_utf8_string(clazz, s2c.us);
} else if (utf8_equals_c(name, "BootstrapMethods")) {
_convert_2_bootstrap_methods(ptr, clazz);
} else if (utf8_equals_c(name, "Signature")) {
Short2Char s2c;
s2c.c1 = ptr->info[0];
s2c.c0 = ptr->info[1];
clazz->signature = class_get_utf8_string(clazz, s2c.us);
}
}
for (i = 0; i < clazz->constantPool.classRef->length; i++) {
ConstantClassRef *ccr = (ConstantClassRef *) arraylist_get_value(clazz->constantPool.classRef, i);
ccr->name = class_get_utf8_string(clazz, ccr->stringIndex);
}
for (i = 0; i < clazz->constantPool.fieldRef->length; i++) {
ConstantFieldRef *cfr = (ConstantFieldRef *) arraylist_get_value(clazz->constantPool.fieldRef, i);
cfr->nameAndType = class_get_constant_name_and_type(clazz, cfr->nameAndTypeIndex);
cfr->name = class_get_utf8_string(clazz, cfr->nameAndType->nameIndex);
cfr->descriptor = class_get_utf8_string(clazz, cfr->nameAndType->typeIndex);
cfr->clsName = class_get_constant_classref(clazz, cfr->classIndex)->name;
}
for (i = 0; i < clazz->constantPool.methodRef->length; i++) {
ConstantMethodRef *cmr = (ConstantMethodRef *) arraylist_get_value(clazz->constantPool.methodRef, i);
cmr->nameAndType = class_get_constant_name_and_type(clazz, cmr->nameAndTypeIndex);
cmr->name = class_get_utf8_string(clazz, cmr->nameAndType->nameIndex);
cmr->descriptor = class_get_utf8_string(clazz, cmr->nameAndType->typeIndex);
cmr->clsName = class_get_constant_classref(clazz, cmr->classIndex)->name;
// if (utf8_equals_c(clazz->name, "java/lang/String")) {
// printf("%s,%s\n", utf8_cstr(cmr->name), utf8_cstr(cmr->clsName));
// int debug = 1;
// }
if (cmr->para_slots == -1) {
Utf8String *tmps = utf8_create();
cmr->para_slots = parseMethodPara(cmr->descriptor, tmps);
utf8_destory(tmps);
}
}
for (i = 0; i < clazz->constantPool.interfaceMethodRef->length; i++) {
ConstantMethodRef *cmr = (ConstantMethodRef *) arraylist_get_value(clazz->constantPool.methodRef, i);
cmr->nameAndType = class_get_constant_name_and_type(clazz, cmr->nameAndTypeIndex);
cmr->name = class_get_utf8_string(clazz, cmr->nameAndType->nameIndex);
cmr->descriptor = class_get_utf8_string(clazz, cmr->nameAndType->typeIndex);
cmr->clsName = class_get_constant_classref(clazz, cmr->classIndex)->name;
if (cmr->para_slots == -1) {
Utf8String *tmps = utf8_create();
cmr->para_slots = parseMethodPara(cmr->descriptor, tmps);
utf8_destory(tmps);
}
}
}
/* Parse Class File */
s32 _LOAD_CLASS_FROM_BYTES(JClass *_this, ByteBuf *buf) {
ClassFileFormat *cff = &(_this->cff);
/* magic number */
bytebuf_read_batch(buf, (c8 *) &cff->magic_number, 4);
// fread(cff->magic_number, 4, 1, fp);
/* minor_version */
//fread(short_tmp, 2, 1, fp);
Short2Char s2c;
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->minor_version = s2c.s;
/* major_version */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->major_version = s2c.s;
/* constant pool */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->constant_pool_count = s2c.s;
/* constant pool table */
_parse_constant_pool(_this, buf, cff->constant_pool_count);
/* access flag */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->access_flags = s2c.s;
/* this class */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->this_class = s2c.s;
/* super class */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->super_class = s2c.s;
/* interfaceRef count */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->interface_count = s2c.s;
/* interfaceRef pool table */
_parse_interface_pool(_this, buf, cff->interface_count);
/* fieldRef count */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->fields_count = s2c.s;
/* fieldRef pool table */
_parse_field_pool(_this, buf, cff->fields_count);
/* methodRef count */
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->methods_count = s2c.s;
/* methodRef pool table */
_parse_method_pool(_this, buf, cff->methods_count);
//attribute
//fread(short_tmp, 2, 1, fp);
s2c.c1 = (c8) bytebuf_read(buf);
s2c.c0 = (c8) bytebuf_read(buf);
cff->attributes_count = s2c.s;
_parse_attribute_pool(_this, buf, cff->attributes_count);
//fclose(fp);
_class_optimize(_this);
_this->status = CLASS_STATUS_LOADED;
return 0;
}
JClass *class_parse(Instance *loader, ByteBuf *bytebuf, Runtime *runtime) {
JClass *tmpclazz = NULL;
if (bytebuf != NULL) {
tmpclazz = class_create(runtime);
tmpclazz->jloader = loader;
s32 iret = tmpclazz->_load_class_from_bytes(tmpclazz, bytebuf);//load file
MiniJVM *jvm = runtime->jvm;
if (iret == 0) {
classes_put(jvm, tmpclazz);
class_prepar(loader, tmpclazz, runtime);
if (jvm->jdwp_enable && jvm->jdwpserver && tmpclazz)event_on_class_prepare(jvm->jdwpserver, runtime, tmpclazz);
#if _JVM_DEBUG_LOG_LEVEL > 2
jvm_printf("load class (%016llx load %016llx): %s \n", (s64) (intptr_t) loader, (s64) (intptr_t) tmpclazz, utf8_cstr(tmpclazz->name));
#endif
} else {
classes_remove(jvm, tmpclazz);
class_destory(tmpclazz);
tmpclazz = NULL;
}
}
return tmpclazz;
}
JClass *load_class(Instance *jloader, Utf8String *pClassName, Runtime *runtime) {
if (!pClassName)return NULL;
MiniJVM *jvm = runtime->jvm;
//
Utf8String *clsName = utf8_create_copy(pClassName);
utf8_replace_c(clsName, ".", "/");
JClass *tmpclazz = classes_get(jvm, jloader, clsName);
if (utf8_indexof_c(clsName, "[") == 0) {
tmpclazz = array_class_create_get(runtime, jloader, clsName);
}
if (!tmpclazz) {
ByteBuf *bytebuf = NULL;
PeerClassLoader *pcl = jloader ? classLoaders_find_by_instance(jvm, jloader) : jvm->boot_classloader;
utf8_append_c(clsName, ".class");
bytebuf = load_file_from_classpath(pcl, clsName);//load class from classloader
if (bytebuf != NULL) {
tmpclazz = class_parse(jloader, bytebuf, runtime);
bytebuf_destory(bytebuf);
} else if (jloader) { //using appclassloader load
if (jvm->shortcut.launcher_loadClass) {
// if (utf8_equals_c(pClassName, "test/AppManagerTest")) {
// int debug = 1;
// }
runtime->thrd_info->no_pause++;
utf8_replace_c(clsName, "/", ".");
Instance *jstr = jstring_create(pClassName, runtime);
push_ref(runtime->stack, jstr);
push_ref(runtime->stack, jloader);
s32 ret = execute_method_impl(jvm->shortcut.launcher_loadClass, runtime);
if (!ret) {
Instance *ins_of_clazz = pop_ref(runtime->stack);
if (ins_of_clazz) {
tmpclazz = insOfJavaLangClass_get_classHandle(runtime, ins_of_clazz);
}
} else {
jvm_printf("class not found:%s\n", utf8_cstr(clsName));
print_exception(runtime);
//Instance *ins = pop_ref(runtime->stack);
//jvm_printf("load class exception:%s\n", utf8_cstr(ins->mb.clazz->name));
}
runtime->thrd_info->no_pause--;
}
}
}
#if _JVM_DEBUG_LOG_LEVEL > 2
if (!tmpclazz) {
//jvm_printf("class not found in bootstrap classpath: %s \n", utf8_cstr(clsName));
}
#endif
utf8_destory(clsName);
return tmpclazz;
}
s32 _DESTORY_CLASS(JClass *clazz) {
#if _JVM_DEBUG_LOG_LEVEL > 2
jvm_printf("destroy class (%016llx load %016llx): %s \n", (s64) (intptr_t) clazz->jloader, (s64) (intptr_t) clazz, utf8_cstr(clazz->name));
#endif
//
_class_method_info_destory(clazz);
_class_bootstrap_methods_destory(clazz);
_class_interface_pool_destory(clazz);
_class_field_info_destory(clazz);
_class_constant_pool_destory(clazz);
_class_attribute_info_destory(clazz);
if (clazz->field_static)jvm_free(clazz->field_static);
clazz->field_static = NULL;
if (clazz->constant_item_ptr)jvm_free(clazz->constant_item_ptr);
clazz->constant_item_ptr = NULL;
jthreadlock_destory(&clazz->mb);
constant_list_destory(clazz);
utf8_destory(clazz->name);
return 0;
}
|
133b069e596d2149ccbaf194cebeb3db9957d217
|
80ab0c4aa95e858c6bd595d7c4491dda9388d557
|
/src/opmath.c
|
f5832ddb60ac659d7f023509958343c778e59cc1
|
[
"MIT"
] |
permissive
|
gbdev/rgbds
|
ab2b654ee0dd99528b092d460d3d51c4e6035329
|
cfe432ea656f28a6ca50cfcdadb7c9d26bbc263c
|
refs/heads/master
| 2023-08-29T05:07:33.182152
| 2023-08-26T21:23:28
| 2023-08-26T21:23:28
| 304,743
| 486
| 83
|
MIT
| 2023-09-14T15:17:55
| 2009-09-12T03:33:35
|
C
|
UTF-8
|
C
| false
| false
| 2,373
|
c
|
opmath.c
|
/*
* This file is part of RGBDS.
*
* Copyright (c) 1997-2021, RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
// Mathematical operators that don't reuse C's behavior
#include <stdint.h>
#include "opmath.h"
int32_t op_divide(int32_t dividend, int32_t divisor)
{
// Adjust division to floor toward negative infinity,
// not truncate toward zero
return dividend / divisor - ((dividend % divisor < 0) != (divisor < 0));
}
int32_t op_modulo(int32_t dividend, int32_t divisor)
{
int32_t remainder = dividend % divisor;
// Adjust modulo to have the sign of the divisor,
// not the sign of the dividend
return remainder + divisor * ((remainder < 0) != (divisor < 0));
}
int32_t op_exponent(int32_t base, uint32_t power)
{
int32_t result = 1;
for (;;) {
if (power % 2)
result *= base;
power /= 2;
if (!power)
break;
base *= base;
}
return result;
}
int32_t op_shift_left(int32_t value, int32_t amount)
{
// Get the easy cases out of the way
if (amount == 0)
return value;
if (value == 0 || amount >= 32)
return 0;
if (amount < -31)
return (value < 0) ? -1 : 0;
if (amount < 0)
return op_shift_right(value, -amount);
// Use unsigned to force a bitwise shift
// Casting back is OK because the types implement two's complement behavior
return (uint32_t)value << amount;
}
int32_t op_shift_right(int32_t value, int32_t amount)
{
// Repeat the easy cases here to avoid INT_MIN funny business
if (amount == 0)
return value;
if (value == 0 || amount <= -32)
return 0;
if (amount > 31)
return (value < 0) ? -1 : 0;
if (amount < 0)
return op_shift_left(value, -amount);
if (value > 0)
return (uint32_t)value >> amount;
// Calculate an OR mask for sign extension
// 1->0x80000000, 2->0xC0000000, ..., 31->0xFFFFFFFE
uint32_t amount_high_bits = -(UINT32_C(1) << (32 - amount));
// The C standard leaves shifting right negative values
// undefined, so use a left shift manually sign-extended
return ((uint32_t)value >> amount) | amount_high_bits;
}
int32_t op_shift_right_unsigned(int32_t value, int32_t amount)
{
// Repeat the easy cases here to avoid INT_MIN funny business
if (amount == 0)
return value;
if (value == 0 || amount <= -32)
return 0;
if (amount > 31)
return (value < 0) ? -1 : 0;
if (amount < 0)
return op_shift_left(value, -amount);
return (uint32_t)value >> amount;
}
|
7676a141e6fcc31cf53860ae7545b6e9324a5e23
|
995310a5ed19946037e928f9a85bae908694c8fe
|
/src/eloquent/modules/vl53l5cx/4x4.h
|
fc44cf95c8f74319ced76f26fffa3c687832931d
|
[] |
no_license
|
eloquentarduino/EloquentArduino
|
bca073e19af3e9cc5c7f135719cd026631277744
|
15983e68cf82c54afadaf2b6c8fdc95cad268489
|
refs/heads/master
| 2022-08-26T07:07:02.235025
| 2022-08-21T12:24:04
| 2022-08-21T12:24:04
| 227,818,265
| 162
| 57
| null | 2021-01-07T18:33:09
| 2019-12-13T10:49:33
|
C++
|
UTF-8
|
C
| false
| false
| 124
|
h
|
4x4.h
|
//
// Created by Simone on 29/05/2022.
//
#pragma once
#include "../vl53l5cx.h"
Eloquent::Modules::Vl53l5cx vllcx(4 * 4);
|
89331eda006a6b51fc993decfa14247858df0899
|
6c88448c71e2b4d259e7ea0e23c01d68ff20e1c8
|
/2.Firmware/PlatformIO/Peak-ESP32-fw/src/App/Resources/Image/img_src_joints.c
|
ece518eebf9dccee5206e94ff2422b22bddbff02
|
[] |
no_license
|
peng-zhihui/Peak
|
ebf5aa1d4fc48a862bfaad951e87517e7a95f499
|
7605edc702c3f4d4328144f9258c52ea8cff6218
|
refs/heads/main
| 2023-03-02T10:08:10.188723
| 2022-08-28T03:43:48
| 2022-08-28T03:43:48
| 415,492,224
| 1,079
| 250
| null | 2022-08-28T03:43:49
| 2021-10-10T05:12:44
|
C
|
UTF-8
|
C
| false
| false
| 22,768
|
c
|
img_src_joints.c
|
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "lvgl.h"
#endif
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
#ifndef LV_ATTRIBUTE_IMG_IMG_SRC_JOINTS
#define LV_ATTRIBUTE_IMG_IMG_SRC_JOINTS
#endif
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_IMG_SRC_JOINTS uint8_t img_src_joints_map[] = {
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0
/*Pixel format: Blue: 5 bit, Green: 6 bit, Red: 5 bit, Alpha 8 bit*/
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x41, 0xFF, 0xFF, 0xCF, 0xFF, 0xFF, 0xE1, 0xFF, 0xFF, 0x7A, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x4A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x98, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x34, 0xFF, 0xFF, 0x21, 0xFF, 0xFF, 0xB8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x61,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x2C, 0xFF, 0xFF, 0x4D, 0xFF, 0xFF, 0x46, 0xFF, 0xFF, 0x16, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x27, 0xFF, 0xFF, 0x2F, 0xFF, 0xFF, 0x29, 0xFF, 0xFF, 0x2D, 0xFF, 0xFF, 0x32, 0xFF, 0xFF, 0x3B, 0xFF, 0xFF, 0x56, 0xFF, 0xFF, 0x82, 0xFF, 0xFF, 0xAF, 0xFF, 0xFF, 0xC7, 0xFF, 0xFF, 0xDA, 0xFF, 0xFF, 0xEE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x73, 0xFF, 0xFF, 0x93, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE2,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x11, 0xFF, 0xFF, 0xB2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0xFF, 0xFF, 0x65, 0xFF, 0xFF, 0x39, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAC, 0xFF, 0xFF, 0x4E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC,
0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xDA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4B, 0xFF, 0xFF, 0x74, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7C, 0xFF, 0xFF, 0x7A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x74,
0xFF, 0xFF, 0x73, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xFF, 0xFF, 0x2D, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xFF, 0xFF, 0xDE, 0xFF, 0xFF, 0xCD, 0xFF, 0xFF, 0xB6, 0xFF, 0xFF, 0x8A, 0xFF, 0xFF, 0x64, 0xFF, 0xFF, 0x41, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x92, 0xFF, 0xFF, 0xEA, 0xFF, 0xFF, 0xC5, 0xFF, 0xFF, 0xAB, 0xFF, 0xFF, 0x15,
0xFF, 0xFF, 0xCB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x64, 0xFF, 0xFF, 0xA2, 0xFF, 0xFF, 0xF4, 0xFF, 0xFF, 0xCA, 0xFF, 0xFF, 0x97, 0xFF, 0xFF, 0x5C, 0xFF, 0xFF, 0x36, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xA1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5F,
0xFF, 0xFF, 0xE3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xFF, 0xFF, 0x19, 0xFF, 0xFF, 0x13, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xA8, 0xFF, 0xFF, 0xCF, 0xFF, 0xFF, 0x2F,
0xFF, 0xFF, 0xB7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x63, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x49, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x8E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x63, 0xFF, 0xFF, 0xD2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x61, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x71, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7A, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xA9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x84, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xDA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x49, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x16, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB3, 0xFF, 0xFF, 0x56, 0xFF, 0xFF, 0x8C, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x8F, 0xFF, 0xFF, 0x49, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x42, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x9C, 0xFF, 0xFF, 0x2A, 0xFF, 0xFF, 0xB6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB7, 0xFF, 0xFF, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x8D, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0x39, 0xFF, 0xFF, 0xE3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x21, 0xFF, 0xFF, 0xAC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4D, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x91, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x21, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x9B, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x74, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0x97, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0xFF, 0xFF, 0x5D, 0xFF, 0xFF, 0x27, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xB3, 0xFF, 0xFF, 0x84, 0xFF, 0xFF, 0x8B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xAD, 0xFF, 0xFF, 0x5F, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xDA, 0xFF, 0xFF, 0xF3, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x61, 0xFF, 0xFF, 0xBB, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0x95, 0xFF, 0xFF, 0x34, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4A, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xDB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7A, 0xFF, 0xFF, 0x5D, 0xFF, 0xFF, 0x6A, 0xFF, 0xFF, 0x64, 0xFF, 0xFF, 0x62, 0xFF, 0xFF, 0xAE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x6B, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x12, 0xFF, 0xFF, 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xFF, 0xFF, 0xED, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x93, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x23, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB5, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCA, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x42, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x64, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE8, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x88, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0x18, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x38, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xC7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5E, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xD6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x90, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x0C, 0xFF, 0xFF, 0x2A, 0xFF, 0xFF, 0x2F, 0xFF, 0xFF, 0x92, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x95, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x95, 0xFF, 0xFF, 0x95, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x96, 0xFF, 0xFF, 0x98, 0xFF, 0xFF, 0x6D, 0xFF, 0xFF, 0x29, 0xFF, 0xFF, 0x28, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDC, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0xEA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE2, 0xFF, 0xFF, 0x2C, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x94, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x6C, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x2E, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD9, 0xFF, 0xFF, 0x1D, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0x59, 0xFF, 0xFF, 0xC8, 0xFF, 0xFF, 0xCA, 0xFF, 0xFF, 0x97, 0xFF, 0xFF, 0x88, 0xFF, 0xFF, 0xC7, 0xFF, 0xFF, 0xC3, 0xFF, 0xFF, 0xC4, 0xFF, 0xFF, 0xCA, 0xFF, 0xFF, 0x97, 0xFF, 0xFF, 0x88, 0xFF, 0xFF, 0xC7, 0xFF, 0xFF, 0xC3, 0xFF, 0xFF, 0xC4, 0xFF, 0xFF, 0xCA, 0xFF, 0xFF, 0x8B, 0xFF, 0xFF, 0x8A, 0xFF, 0xFF, 0xC7, 0xFF, 0xFF, 0xC7, 0xFF, 0xFF, 0x57, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00
#endif
};
const lv_img_dsc_t img_src_joints = {
.header.always_zero = 0,
.header.w = 29,
.header.h = 42,
.data_size = 1218 * LV_IMG_PX_SIZE_ALPHA_BYTE,
.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA,
.data = img_src_joints_map,
};
|
d38b41d43cb6c58fddd7eb0fdbaf03478b4fcaad
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/mips/cavium/dev/octeon_fauvar.h
|
5cbad5c1c44bb994c72c0c7f96c4d2c768a47911
|
[] |
no_license
|
NetBSD/src
|
1a9cbc22ed778be638b37869ed4fb5c8dd616166
|
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
|
refs/heads/trunk
| 2023-08-31T13:24:58.105962
| 2023-08-27T15:50:47
| 2023-08-27T15:50:47
| 88,439,547
| 656
| 348
| null | 2023-07-20T20:07:24
| 2017-04-16T20:03:43
| null |
UTF-8
|
C
| false
| false
| 4,533
|
h
|
octeon_fauvar.h
|
/* $NetBSD: octeon_fauvar.h,v 1.4 2020/06/23 05:14:18 simonb Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _OCTEON_FAUVAR_H_
#define _OCTEON_FAUVAR_H_
#include <mips/cavium/octeonreg.h>
/* ---- API */
struct octfau_desc {
/* offset in scratch buffer */
size_t fd_scroff; /* XXX offset_t */
/* FAU register number */
size_t fd_regno; /* XXX offset_t */
};
void octfau_op_init(struct octfau_desc *, size_t, size_t);
uint64_t octfau_op_save(struct octfau_desc *);
void octfau_op_restore(struct octfau_desc *, uint64_t);
int64_t octfau_op_inc_8(struct octfau_desc *, int64_t);
int32_t octfau_op_inc_4(struct octfau_desc *, int32_t);
int16_t octfau_op_inc_2(struct octfau_desc *, int16_t);
int8_t octfau_op_inc_1(struct octfau_desc *, int8_t);
int64_t octfau_op_incwait_8(struct octfau_desc *, int);
int32_t octfau_op_incwait_4(struct octfau_desc *, int);
int16_t octfau_op_incwait_2(struct octfau_desc *, int);
int8_t octfau_op_incwait_1(struct octfau_desc *, int);
int64_t octfau_op_get_8(struct octfau_desc *);
int32_t octfau_op_get_4(struct octfau_desc *);
int16_t octfau_op_get_2(struct octfau_desc *);
int8_t octfau_op_get_1(struct octfau_desc *);
int64_t octfau_op_getwait_8(struct octfau_desc *);
int32_t octfau_op_getwait_4(struct octfau_desc *);
int16_t octfau_op_getwait_2(struct octfau_desc *);
int8_t octfau_op_getwait_1(struct octfau_desc *);
void octfau_op_add_8(struct octfau_desc *, int64_t);
void octfau_op_add_4(struct octfau_desc *, int32_t);
void octfau_op_add_2(struct octfau_desc *, int16_t);
void octfau_op_add_1(struct octfau_desc *, int8_t);
void octfau_op_set_8(struct octfau_desc *, int64_t);
void octfau_op_set_4(struct octfau_desc *, int32_t);
void octfau_op_set_2(struct octfau_desc *, int16_t);
void octfau_op_set_1(struct octfau_desc *, int8_t);
/* ---- old API */
/* XXX */
#define OCT_FAU_REG_OQ_ADDR_INDEX (0)
#define OCT_FAU_REG_ADDR_END (256)
/* XXX */
/* XXX */
typedef enum {
OCT_FAU_OP_SIZE_8 = 0,
OCT_FAU_OP_SIZE_16 = 1,
OCT_FAU_OP_SIZE_32 = 2,
OCT_FAU_OP_SIZE_64 = 3
} fau_op_size_t;
/* XXX */
/*
* XXX
* `scraddr' parameter of IOBDMA operation is actually `index';
*/
static inline void
octfau_op_iobdma(int index, uint64_t args)
{
uint64_t value = IOBDMA_CREATE(FAU_MAJOR_DID, FAU_SUB_DID,
index, POW_IOBDMA_LEN, args);
octeon_iobdma_write_8(value);
}
/* IOBDMA Operations */
/* IOBDMA Store Data for FAU Operations */
static inline void
octfau_op_iobdma_store_data(int scraddr, int incval, int tagwait,
int size, int reg)
{
uint64_t args =
__SHIFTIN(incval, POW_IOBDMA_INCVAL) |
__SHIFTIN(tagwait, POW_IOBDMA_TAGWAIT) |
__SHIFTIN(size, POW_IOBDMA_SIZE) |
__SHIFTIN(reg, POW_IOBDMA_REG);
/* `scraddr' parameter of IOBDMA operation is actually `index' */
octfau_op_iobdma(scraddr / sizeof(uint64_t), args);
}
static inline void
octfau_op_inc_fetch_8(struct octfau_desc *fd, int64_t v)
{
octfau_op_iobdma_store_data(fd->fd_scroff, v, 0,
OCT_FAU_OP_SIZE_64/* XXX */, fd->fd_regno);
}
static inline int64_t
octfau_op_inc_read_8(struct octfau_desc *fd)
{
OCTEON_SYNCIOBDMA;
return octeon_cvmseg_read_8(fd->fd_scroff);
}
#endif /* _OCTEON_FAUVAR_H_ */
|
df351b6cfc06bab0c60de35d6236e7c3fccb78cd
|
2cf314b8237fc6a77b7f1a096f17a679179b0057
|
/internal/core/src/common/type_c.h
|
1ab6176e0045e4168f02611c06afd83defb3bdef
|
[
"Apache-2.0"
] |
permissive
|
milvus-io/milvus
|
a02d732cf746effec1ea723f9e4d17856843f8a8
|
0530fd80c91dc5b200606c00214c12bf8dd17cb4
|
refs/heads/master
| 2023-09-04T06:28:57.681855
| 2023-09-04T02:01:04
| 2023-09-04T02:01:04
| 208,728,772
| 23,316
| 2,917
|
Apache-2.0
| 2023-09-14T15:06:12
| 2019-09-16T06:43:43
|
Go
|
UTF-8
|
C
| false
| false
| 2,613
|
h
|
type_c.h
|
// Licensed to the LF AI & Data foundation under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
enum SegmentType {
Invalid = 0,
Growing = 1,
Sealed = 2,
Indexing = 3,
};
typedef enum SegmentType SegmentType;
enum ErrorCode {
Success = 0,
UnexpectedError = 1,
IllegalArgument = 5,
};
// pure C don't support that we use schemapb.DataType directly.
// Note: the value of all enumerations must match the corresponding schemapb.DataType.
// TODO: what if there are increments in schemapb.DataType.
enum CDataType {
None = 0,
Bool = 1,
Int8 = 2,
Int16 = 3,
Int32 = 4,
Int64 = 5,
Float = 10,
Double = 11,
String = 20,
VarChar = 21,
BinaryVector = 100,
FloatVector = 101,
};
typedef enum CDataType CDataType;
typedef struct CStatus {
int error_code;
const char* error_msg;
} CStatus;
typedef struct CProto {
const void* proto_blob;
int64_t proto_size;
} CProto;
typedef struct CLoadDeletedRecordInfo {
void* timestamps;
const uint8_t* primary_keys;
const uint64_t primary_keys_size;
int64_t row_count;
} CLoadDeletedRecordInfo;
typedef struct CStorageConfig {
const char* address;
const char* bucket_name;
const char* access_key_id;
const char* access_key_value;
const char* root_path;
const char* storage_type;
const char* iam_endpoint;
const char* log_level;
const char* region;
bool useSSL;
bool useIAM;
bool useVirtualHost;
} CStorageConfig;
typedef struct CTraceConfig {
const char* exporter;
int sampleFraction;
const char* jaegerURL;
const char* otlpEndpoint;
int nodeID;
} CTraceConfig;
typedef struct CTraceContext {
const uint8_t* traceID;
const uint8_t* spanID;
uint8_t flag;
} CTraceContext;
#ifdef __cplusplus
}
#endif
|
30b9d0e36ac1c336ffb2926512141f1b7332b944
|
dc5b5723f2aebc9abaa125e281b59cb88362996f
|
/sample/targets/c_model/vx_interface.c
|
2f31e0c914380bc87de4f24484164c42769e75d8
|
[
"Apache-2.0"
] |
permissive
|
KhronosGroup/OpenVX-sample-impl
|
cd3cc630b398a859ff83ce75ff02ff7f8dd45e64
|
9caba36a541fa6480f9d65d9a78dde208ebe96f9
|
refs/heads/openvx_1.3
| 2023-09-05T23:32:05.073687
| 2023-06-16T19:53:24
| 2023-06-16T19:53:24
| 157,795,699
| 134
| 55
|
Apache-2.0
| 2023-06-16T19:53:25
| 2018-11-16T01:33:06
|
C
|
UTF-8
|
C
| false
| false
| 18,833
|
c
|
vx_interface.c
|
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*!
* \file
* \brief The C-Model Target Interface
* \author Erik Rainey <erik.rainey@gmail.com>
*/
#include <VX/vx.h>
#include <VX/vx_helper.h>
#include "vx_internal.h"
#include <vx_interface.h>
vx_status VX_CALLBACK vxTilingKernel(vx_node node, const vx_reference parameters[], vx_uint32 num);
static const vx_char name[VX_MAX_TARGET_NAME] = "khronos.any";
/*! \brief Declares the list of all supported base kernels.
* \ingroup group_implementation
* \note This is the list of all supported base kernels! It must at least
* match the OpenVX 1.0 Specification.
*/
static vx_kernel_description_t *target_kernels[] =
{
&colorconvert_kernel,
&channelextract_kernel,
&channelcombine_kernel,
&sobel3x3_kernel,
&magnitude_kernel,
&phase_kernel,
&scale_image_kernel,
&lut_kernel,
&histogram_kernel,
&equalize_hist_kernel,
&absdiff_kernel,
&mean_stddev_kernel,
&threshold_kernel,
&integral_image_kernel,
&erode3x3_kernel,
&dilate3x3_kernel,
&median3x3_kernel,
&box3x3_kernel,
&box3x3_kernel_2,
&gaussian3x3_kernel,
&convolution_kernel,
&gaussian_pyramid_kernel,
&accumulate_kernel,
&accumulate_weighted_kernel,
&accumulate_square_kernel,
&minmaxloc_kernel,
&weightedaverage_kernel,
&convertdepth_kernel,
&canny_kernel,
&and_kernel,
&or_kernel,
&xor_kernel,
¬_kernel,
&multiply_kernel,
&add_kernel,
&subtract_kernel,
&warp_affine_kernel,
&warp_perspective_kernel,
&harris_kernel,
&fast9_kernel,
&nonmaxsuppression_kernel,
&optpyrlk_kernel,
&remap_kernel,
&halfscale_gaussian_kernel,
&laplacian_pyramid_kernel,
&laplacian_reconstruct_kernel,
&nonlinearfilter_kernel,
&tensor_add_kernel,
&tensor_multiply_kernel,
&tensor_subtract_kernel,
&tensor_lut_kernel,
&tensor_transpose_kernel,
&tensor_convert_depth_kernel,
&tensor_lut_kernel,
&tensor_matrix_multiply_kernel,
&min_kernel,
&max_kernel,
&lbp_kernel,
&bilateral_filter_kernel,
&match_template_kernel,
&houghlinesp_kernel,
©_kernel,
&scalar_operation_kernel,
&select_kernel,
&hogcells_kernel,
&hogfeatures_kernel,
#ifdef OPENVX_USE_NN
&nn_convolution_kernel,
&nn_deconvolution_kernel,
&nn_pooling_kernel,
&nn_fully_connected_kernel,
&nn_softmax_kernel,
&nn_norm_kernel,
&nn_activation_kernel,
&nn_roipooling_kernel,
#endif
};
/*! \brief Declares the number of base supported kernels.
* \ingroup group_implementation
*/
static vx_uint32 num_target_kernels = dimof(target_kernels);
/******************************************************************************/
/* EXPORTED FUNCTIONS */
/******************************************************************************/
vx_status vxTargetInit(vx_target target)
{
if (target)
{
strncpy(target->name, name, VX_MAX_TARGET_NAME);
target->priority = VX_TARGET_PRIORITY_C_MODEL;
}
return ownInitializeTarget(target, target_kernels, num_target_kernels);
}
vx_status vxTargetDeinit(vx_target target)
{
return ownDeinitializeTarget(target);
}
vx_status vxTargetSupports(vx_target target,
vx_char targetName[VX_MAX_TARGET_NAME],
vx_char kernelName[VX_MAX_KERNEL_NAME],
vx_uint32 *pIndex)
{
vx_status status = VX_ERROR_NOT_SUPPORTED;
if (strncmp(targetName, name, VX_MAX_TARGET_NAME) == 0 ||
strncmp(targetName, "default", VX_MAX_TARGET_NAME) == 0 ||
strncmp(targetName, "power", VX_MAX_TARGET_NAME) == 0 ||
strncmp(targetName, "performance", VX_MAX_TARGET_NAME) == 0)
{
vx_uint32 k = 0u;
for (k = 0u; k < VX_INT_MAX_KERNELS; k++)
{
vx_char targetKernelName[VX_MAX_KERNEL_NAME];
vx_char *kernel;
vx_char def[8] = "default";
strncpy(targetKernelName, target->kernels[k].name, VX_MAX_KERNEL_NAME);
kernel = strtok(targetKernelName, ":");
if (kernel == NULL)
kernel = def;
if (strncmp(kernelName, kernel, VX_MAX_KERNEL_NAME) == 0
)
{
status = VX_SUCCESS;
if (pIndex) *pIndex = k;
break;
}
}
}
return status;
}
vx_action vxTargetProcess(vx_target target, vx_node_t *nodes[], vx_size startIndex, vx_size numNodes)
{
vx_action action = VX_ACTION_CONTINUE;
vx_status status = VX_SUCCESS;
vx_size n = 0;
(void)target;
for (n = startIndex; (n < (startIndex + numNodes)) && (action == VX_ACTION_CONTINUE); n++)
{
vx_context context = vxGetContext((vx_reference)nodes[n]);
VX_PRINT(VX_ZONE_GRAPH, "Executing Kernel %s:%d in Nodes[%u] on target %s\n",
nodes[n]->kernel->name,
nodes[n]->kernel->enumeration,
n,
nodes[n]->base.context->targets[nodes[n]->affinity].name);
if (context->perf_enabled)
ownStartCapture(&nodes[n]->perf);
if (nodes[n]->is_replicated == vx_true_e)
{
vx_size num_replicas = 0;
vx_uint32 param;
vx_uint32 num_parameters = nodes[n]->kernel->signature.num_parameters;
vx_reference parameters[VX_INT_MAX_PARAMS] = { NULL };
for (param = 0; param < num_parameters; ++param)
{
if (nodes[n]->replicated_flags[param] == vx_true_e)
{
vx_size numItems = 0;
if ((nodes[n]->parameters[param])->scope->type == VX_TYPE_PYRAMID)
{
vx_pyramid pyr = (vx_pyramid)(nodes[n]->parameters[param])->scope;
numItems = pyr->numLevels;
}
else if ((nodes[n]->parameters[param])->scope->type == VX_TYPE_OBJECT_ARRAY)
{
vx_object_array arr = (vx_object_array)(nodes[n]->parameters[param])->scope;
numItems = arr->num_items;
}
else
{
status = VX_ERROR_INVALID_PARAMETERS;
break;
}
if (num_replicas == 0)
num_replicas = numItems;
else if (numItems != num_replicas)
{
status = VX_ERROR_INVALID_PARAMETERS;
break;
}
}
else
{
parameters[param] = nodes[n]->parameters[param];
}
}
if (status == VX_SUCCESS)
{
vx_size replica;
for (replica = 0; replica < num_replicas; ++replica)
{
for (param = 0; param < num_parameters; ++param)
{
if (nodes[n]->replicated_flags[param] == vx_true_e)
{
if ((nodes[n]->parameters[param])->scope->type == VX_TYPE_PYRAMID)
{
vx_pyramid pyr = (vx_pyramid)(nodes[n]->parameters[param])->scope;
parameters[param] = (vx_reference)pyr->levels[replica];
}
else if ((nodes[n]->parameters[param])->scope->type == VX_TYPE_OBJECT_ARRAY)
{
vx_object_array arr = (vx_object_array)(nodes[n]->parameters[param])->scope;
parameters[param] = (vx_reference)arr->items[replica];
}
}
}
status = nodes[n]->kernel->function((vx_node)nodes[n],
parameters,
num_parameters);
}
}
}
else
{
status = nodes[n]->kernel->function((vx_node)nodes[n],
(vx_reference *)nodes[n]->parameters,
nodes[n]->kernel->signature.num_parameters);
}
nodes[n]->executed = vx_true_e;
nodes[n]->status = status;
if (context->perf_enabled)
ownStopCapture(&nodes[n]->perf);
VX_PRINT(VX_ZONE_GRAPH, "kernel %s returned %d\n", nodes[n]->kernel->name, status);
if (status == VX_SUCCESS)
{
/* call the callback if it is attached */
if (nodes[n]->callback)
{
action = nodes[n]->callback((vx_node)nodes[n]);
VX_PRINT(VX_ZONE_GRAPH, "callback returned action %d\n", action);
}
}
else
{
action = VX_ACTION_ABANDON;
VX_PRINT(VX_ZONE_ERROR, "Abandoning Graph due to error (%d)!\n", status);
}
}
return action;
}
vx_status vxTargetVerify(vx_target target, vx_node_t *node)
{
vx_status status = VX_SUCCESS;
(void)target;
(void)node;
return status;
}
vx_kernel vxTargetAddKernel(vx_target target,
vx_char name[VX_MAX_KERNEL_NAME],
vx_enum enumeration,
vx_kernel_f func_ptr,
vx_uint32 numParams,
vx_kernel_validate_f validate,
vx_kernel_input_validate_f input,
vx_kernel_output_validate_f output,
vx_kernel_initialize_f initialize,
vx_kernel_deinitialize_f deinitialize)
{
vx_uint32 k = 0u;
vx_kernel_t *kernel = NULL;
// ownSemWait(&target->base.lock);
for (k = 0; k < VX_INT_MAX_KERNELS; k++)
{
kernel = &(target->kernels[k]);
if (kernel->enabled == vx_false_e)
{
ownInitializeKernel(target->base.context,
kernel,
enumeration, func_ptr, name,
NULL, numParams,
validate, input, output, initialize, deinitialize);
VX_PRINT(VX_ZONE_KERNEL, "Reserving %s Kernel[%u] for %s\n", target->name, k, kernel->name);
target->num_kernels++;
break;
}
kernel = NULL;
}
// ownSemPost(&target->base.lock);
return (vx_kernel)kernel;
}
#ifdef OPENVX_KHR_TILING
vx_kernel vxTargetAddTilingKernel(vx_target target,
vx_char name[VX_MAX_KERNEL_NAME],
vx_enum enumeration,
vx_tiling_kernel_f flexible_func_ptr,
vx_tiling_kernel_f fast_func_ptr,
vx_uint32 numParams,
vx_kernel_input_validate_f input,
vx_kernel_output_validate_f output)
{
vx_uint32 k = 0u;
vx_kernel_t *kernel = NULL;
for (k = 0; k < VX_INT_MAX_KERNELS; k++)
{
kernel = &(target->kernels[k]);
if (kernel->enabled == vx_false_e)
{
kernel->tilingfast_function = fast_func_ptr;
ownInitializeKernel(target->base.context,
kernel,
enumeration, vxTilingKernel, name,
NULL, numParams,
NULL, input, output, NULL, NULL);
VX_PRINT(VX_ZONE_KERNEL, "Reserving %s Kernel[%u] for %s\n", target->name, k, kernel->name);
target->num_kernels++;
break;
}
kernel = NULL;
}
return (vx_kernel)kernel;
}
static vx_status vxGetPatchToTile(vx_image image, vx_rectangle_t *rect, vx_tile_t *tile)
{
vx_status status = VX_SUCCESS;
vx_uint32 p = 0;
vx_image_t *img = (vx_image_t *)image;
for (p = 0; p < img->planes; p++)
{
tile->base[p] = NULL;
status = vxAccessImagePatch(image, rect, 0, &tile->addr[p], (void **)&tile->base[p], VX_READ_AND_WRITE);
}
return status;
}
static vx_status vxSetTileToPatch(vx_image image, vx_rectangle_t *rect, vx_tile_t *tile)
{
vx_image_t *img = (vx_image_t *)image;
vx_uint32 p = 0;
vx_status status = VX_SUCCESS;;
for (p = 0; p < img->planes; p++)
{
status = vxCommitImagePatch(image, rect, 0, &tile->addr[p], tile->base[p]);
}
return status;
}
vx_status VX_CALLBACK vxTilingKernel(vx_node node, const vx_reference parameters[], vx_uint32 num)
{
vx_status status = VX_ERROR_INVALID_PARAMETERS;
vx_image images[VX_INT_MAX_PARAMS];
vx_uint32 ty = 0u, tx = 0u, p = 0u;
vx_rectangle_t rect;
vx_tile_t tiles[VX_INT_MAX_PARAMS];
void *params[VX_INT_MAX_PARAMS] = {NULL};
vx_enum dirs[VX_INT_MAX_PARAMS];
vx_enum types[VX_INT_MAX_PARAMS];
size_t scalars[VX_INT_MAX_PARAMS];
vx_uint32 index = UINT32_MAX;
vx_uint32 tile_size_y = 0u, tile_size_x = 0u;
vx_uint32 block_multiple = 64;
vx_uint32 height = 0u, width = 0u;
vx_border_t borders = {VX_BORDER_UNDEFINED, 0};
vx_neighborhood_size_t nbhd;
void *tile_memory = NULL;
vx_size size = 0;
/* Do the following:
* \arg find out each parameters direction
* \arg assign each image from the parameters
* \arg assign the block/neighborhood info
*/
for (p = 0u; p < num; p++)
{
vx_parameter param = vxGetParameterByIndex(node, p);
if (vxGetStatus((vx_reference)param) == VX_SUCCESS)
{
vxQueryParameter(param, VX_PARAMETER_DIRECTION, &dirs[p], sizeof(dirs[p]));
vxQueryParameter(param, VX_PARAMETER_TYPE, &types[p], sizeof(types[p]));
vxReleaseParameter(¶m);
}
//printf("Tiling Kernel Parameter[%u] dir:%d type:0%08x\n", p, dirs[p], types[p]);
if (types[p] == VX_TYPE_IMAGE)
{
vxQueryNode(node, VX_NODE_OUTPUT_TILE_BLOCK_SIZE, &tiles[p].tile_block, sizeof(vx_tile_block_size_t));
vxQueryNode(node, VX_NODE_INPUT_NEIGHBORHOOD, &tiles[p].neighborhood, sizeof(vx_neighborhood_size_t));
ownPrintImage((vx_image_t *)parameters[p]);
images[p] = (vx_image)parameters[p];
vxQueryImage(images[p], VX_IMAGE_WIDTH, &tiles[p].image.width, sizeof(vx_uint32));
vxQueryImage(images[p], VX_IMAGE_HEIGHT, &tiles[p].image.height, sizeof(vx_uint32));
vxQueryImage(images[p], VX_IMAGE_FORMAT, &tiles[p].image.format, sizeof(vx_df_image));
vxQueryImage(images[p], VX_IMAGE_SPACE, &tiles[p].image.space, sizeof(vx_enum));
vxQueryImage(images[p], VX_IMAGE_RANGE, &tiles[p].image.range, sizeof(vx_enum));
params[p] = &tiles[p];
if ((dirs[p] == VX_OUTPUT) && (index == UINT32_MAX))
{
index = p;
//printf("Using index %u as coordinate basis\n", index);
}
}
else if (types[p] == VX_TYPE_SCALAR)
{
vxCopyScalar((vx_scalar)parameters[p], (void *)&scalars[p], VX_READ_ONLY, VX_MEMORY_TYPE_HOST);
params[p] = &scalars[p];
}
#if defined(OPENVX_TILING_1_1)
/*! \todo add addition data types here */
#endif
}
/* choose the index of the first output image to based the tiling on */
status |= vxQueryImage(images[index], VX_IMAGE_WIDTH, &width, sizeof(width));
status |= vxQueryImage(images[index], VX_IMAGE_HEIGHT, &height, sizeof(height));
status |= vxQueryNode(node, VX_NODE_BORDER, &borders, sizeof(borders));
status |= vxQueryNode(node, VX_NODE_INPUT_NEIGHBORHOOD, &nbhd, sizeof(nbhd));
status |= vxQueryNode(node, VX_NODE_TILE_MEMORY_SIZE, &size, sizeof(size));
#if 0
tile_size_y = (height - (nbhd.y[1] + abs(nbhd.y[0]))) / block_multiple;
tile_size_x = (width - (nbhd.x[1] + abs(nbhd.x[0])));
#else
tile_size_y = height / block_multiple;
tile_size_x = width;
#endif
if ((borders.mode != VX_BORDER_UNDEFINED) &&
(borders.mode != VX_BORDER_MODE_SELF))
{
return VX_ERROR_NOT_SUPPORTED;
}
status = VX_SUCCESS;
#if 0
for (ty = abs(nbhd.y[0]); (ty < (height - nbhd.y[1])) && (status == VX_SUCCESS); ty += tile_size_y)
{
for (tx = abs(nbhd.x[0]); tx < (width - nbhd.x[1]); tx += tile_size_x)
{
#else
for (ty = 0u; (ty < height) && (status == VX_SUCCESS); ty += tile_size_y)
{
for (tx = 0u; tx < width; tx += tile_size_x)
{
#endif
rect.start_x = tx;
rect.start_y = ty;
rect.end_x = tx+tile_size_x;
rect.end_y = ty+tile_size_y;
for (p = 0u; p < num; p++)
{
if (types[p] == VX_TYPE_IMAGE)
{
tiles[p].tile_x = tx;
tiles[p].tile_y = ty;
status |= vxGetPatchToTile(images[p], &rect, &tiles[p]);
}
}
if (status == VX_SUCCESS)
{
//printf("Calling Tile{%u,%u} with %s\n", tx, ty, ((vx_node_t *)node)->kernel->name);
tile_memory = ((vx_node_t *)node)->attributes.tileDataPtr;
((vx_node_t *)node)->kernel->tilingfast_function(params, tile_memory, size);
}
else
{
//printf("Failed to get tile {%u, %u} (status = %d)\n", tx, ty, status);
}
for (p = 0u; p < num; p++)
{
if (types[p] == VX_TYPE_IMAGE)
{
if (dirs[p] == VX_INPUT)
{
status |= vxSetTileToPatch(images[p], 0, &tiles[p]);
}
else
{
status |= vxSetTileToPatch(images[p], &rect, &tiles[p]);
}
}
}
if (status != VX_SUCCESS)
{
break;
}
}
}
//printf("Tiling Kernel returning = %d\n", status);
return status;
}
#endif
|
fda2a46c7c2d0114e6f3e65ff3178df1cdc20a47
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/wayland-protocols/gtk/gdk/gdktoplevel.c
|
ac89e61671acfb025e4d2e8619cb4c5d04fefd4f
|
[
"BSD-3-Clause",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"LGPL-2.1-only",
"LGPL-2.0-only"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 23,415
|
c
|
gdktoplevel.c
|
/*
* Copyright © 2020 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include "gdkintl.h"
#include "gdk-private.h"
#include "gdktoplevelprivate.h"
#include <graphene-gobject.h>
#include <math.h>
/**
* GdkToplevel:
*
* A `GdkToplevel` is a freestanding toplevel surface.
*
* The `GdkToplevel` interface provides useful APIs for interacting with
* the windowing system, such as controlling maximization and size of the
* surface, setting icons and transient parents for dialogs.
*/
G_DEFINE_INTERFACE (GdkToplevel, gdk_toplevel, GDK_TYPE_SURFACE)
enum
{
COMPUTE_SIZE,
N_SIGNALS
};
static guint signals[N_SIGNALS] = { 0 };
static void
gdk_toplevel_default_present (GdkToplevel *toplevel,
GdkToplevelLayout *layout)
{
}
static gboolean
gdk_toplevel_default_minimize (GdkToplevel *toplevel)
{
return FALSE;
}
static gboolean
gdk_toplevel_default_lower (GdkToplevel *toplevel)
{
return FALSE;
}
static void
gdk_toplevel_default_focus (GdkToplevel *toplevel,
guint32 timestamp)
{
}
static gboolean
gdk_toplevel_default_show_window_menu (GdkToplevel *toplevel,
GdkEvent *event)
{
return FALSE;
}
static gboolean
gdk_toplevel_default_supports_edge_constraints (GdkToplevel *toplevel)
{
return FALSE;
}
static void
gdk_toplevel_default_inhibit_system_shortcuts (GdkToplevel *toplevel,
GdkEvent *event)
{
}
static void
gdk_toplevel_default_restore_system_shortcuts (GdkToplevel *toplevel)
{
}
void
gdk_toplevel_notify_compute_size (GdkToplevel *toplevel,
GdkToplevelSize *size)
{
g_signal_emit (toplevel, signals[COMPUTE_SIZE], 0, size);
gdk_toplevel_size_validate (size);
}
static void
gdk_toplevel_default_init (GdkToplevelInterface *iface)
{
iface->present = gdk_toplevel_default_present;
iface->minimize = gdk_toplevel_default_minimize;
iface->lower = gdk_toplevel_default_lower;
iface->focus = gdk_toplevel_default_focus;
iface->show_window_menu = gdk_toplevel_default_show_window_menu;
iface->supports_edge_constraints = gdk_toplevel_default_supports_edge_constraints;
iface->inhibit_system_shortcuts = gdk_toplevel_default_inhibit_system_shortcuts;
iface->restore_system_shortcuts = gdk_toplevel_default_restore_system_shortcuts;
/**
* GdkToplevel:state: (attributes org.gtk.Property.get=gdk_toplevel_get_state)
*
* The state of the toplevel.
*/
g_object_interface_install_property (iface,
g_param_spec_flags ("state",
P_("State"),
P_("State"),
GDK_TYPE_TOPLEVEL_STATE, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GdkToplevel:title: (attributes org.gtk.Property.set=gdk_toplevel_set_title)
*
* The title of the surface.
*/
g_object_interface_install_property (iface,
g_param_spec_string ("title",
"Title",
"The title of the surface",
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:startup-id: (attributes org.gtk.Property.set=gdk_toplevel_set_startup_id)
*
* The startup ID of the surface.
*
* See [class@Gdk.AppLaunchContext] for more information about
* startup feedback.
*/
g_object_interface_install_property (iface,
g_param_spec_string ("startup-id",
"Startup ID",
"The startup ID of the surface",
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:transient-for: (attributes org.gtk.Property.set=gdk_toplevel_set_transient_for)
*
* The transient parent of the surface.
*/
g_object_interface_install_property (iface,
g_param_spec_object ("transient-for",
"Transient For",
"The transient parent of the surface",
GDK_TYPE_SURFACE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:modal: (attributes org.gtk.Property.set=gdk_toplevel_set_modal)
*
* Whether the surface is modal.
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("modal",
"Modal",
"Whether the surface is modal",
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:icon-list: (attributes org.gtk.Property.set=gdk_toplevel_set_icon_list)
*
* A list of textures to use as icon.
*/
g_object_interface_install_property (iface,
g_param_spec_pointer ("icon-list",
"Icon List",
"The list of icon textures",
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:decorated: (attributes org.gtk.Property.set=gdk_toplevel_set_decorated)
*
* Whether the window manager should add decorations.
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("decorated",
"Decorated",
"Decorated",
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:deletable: (attributes org.gtk.Property.set=gdk_toplevel_set_deletable)
*
* Whether the window manager should allow to close the surface.
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("deletable",
"Deletable",
"Deletable",
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:fullscreen-mode:
*
* The fullscreen mode of the surface.
*/
g_object_interface_install_property (iface,
g_param_spec_enum ("fullscreen-mode",
"Fullscreen mode",
"Fullscreen mode",
GDK_TYPE_FULLSCREEN_MODE,
GDK_FULLSCREEN_ON_CURRENT_MONITOR,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel:shortcuts-inhibited:
*
* Whether the surface should inhibit keyboard shortcuts.
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("shortcuts-inhibited",
"Shortcuts inhibited",
"Whether keyboard shortcuts are inhibited",
FALSE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
/**
* GdkToplevel::compute-size:
* @toplevel: a `GdkToplevel`
* @size: (type Gdk.ToplevelSize) (out caller-allocates): a `GdkToplevelSize`
*
* Emitted when the size for the surface needs to be computed, when
* it is present.
*
* It will normally be emitted during or after [method@Gdk.Toplevel.present],
* depending on the configuration received by the windowing system.
* It may also be emitted at any other point in time, in response
* to the windowing system spontaneously changing the configuration.
*
* It is the responsibility of the toplevel user to handle this signal
* and compute the desired size of the toplevel, given the information
* passed via the [struct@Gdk.ToplevelSize] object. Failing to do so
* will result in an arbitrary size being used as a result.
*/
signals[COMPUTE_SIZE] =
g_signal_new ("compute-size",
GDK_TYPE_TOPLEVEL,
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
NULL,
G_TYPE_NONE, 1,
GDK_TYPE_TOPLEVEL_SIZE | G_SIGNAL_TYPE_STATIC_SCOPE);
}
guint
gdk_toplevel_install_properties (GObjectClass *object_class,
guint first_prop)
{
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_STATE, "state");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_TITLE, "title");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_STARTUP_ID, "startup-id");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_TRANSIENT_FOR, "transient-for");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_MODAL, "modal");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_ICON_LIST, "icon-list");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_DECORATED, "decorated");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_DELETABLE, "deletable");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_FULLSCREEN_MODE, "fullscreen-mode");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED, "shortcuts-inhibited");
return GDK_TOPLEVEL_NUM_PROPERTIES;
}
/**
* gdk_toplevel_present:
* @toplevel: the `GdkToplevel` to show
* @layout: the `GdkToplevelLayout` object used to layout
*
* Present @toplevel after having processed the `GdkToplevelLayout` rules.
*
* If the toplevel was previously not showing, it will be showed,
* otherwise it will change layout according to @layout.
*
* GDK may emit the [signal@Gdk.Toplevel::compute-size] signal to let
* the user of this toplevel compute the preferred size of the toplevel
* surface.
*
* Presenting is asynchronous and the specified layout parameters are not
* guaranteed to be respected.
*/
void
gdk_toplevel_present (GdkToplevel *toplevel,
GdkToplevelLayout *layout)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_return_if_fail (layout != NULL);
GDK_TOPLEVEL_GET_IFACE (toplevel)->present (toplevel, layout);
}
/**
* gdk_toplevel_minimize:
* @toplevel: a `GdkToplevel`
*
* Asks to minimize the @toplevel.
*
* The windowing system may choose to ignore the request.
*
* Returns: %TRUE if the surface was minimized
*/
gboolean
gdk_toplevel_minimize (GdkToplevel *toplevel)
{
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
return GDK_TOPLEVEL_GET_IFACE (toplevel)->minimize (toplevel);
}
/**
* gdk_toplevel_lower:
* @toplevel: a `GdkToplevel`
*
* Asks to lower the @toplevel below other windows.
*
* The windowing system may choose to ignore the request.
*
* Returns: %TRUE if the surface was lowered
*/
gboolean
gdk_toplevel_lower (GdkToplevel *toplevel)
{
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
return GDK_TOPLEVEL_GET_IFACE (toplevel)->lower (toplevel);
}
/**
* gdk_toplevel_focus:
* @toplevel: a `GdkToplevel`
* @timestamp: timestamp of the event triggering the surface focus
*
* Sets keyboard focus to @surface.
*
* In most cases, [method@Gtk.Window.present_with_time] should be
* used on a [class@Gtk.Window], rather than calling this function.
*/
void
gdk_toplevel_focus (GdkToplevel *toplevel,
guint32 timestamp)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->focus (toplevel, timestamp);
}
/**
* gdk_toplevel_get_state: (attributes org.gtk.Method.get_property=state)
* @toplevel: a `GdkToplevel`
*
* Gets the bitwise or of the currently active surface state flags,
* from the `GdkToplevelState` enumeration.
*
* Returns: surface state bitfield
*/
GdkToplevelState
gdk_toplevel_get_state (GdkToplevel *toplevel)
{
GdkToplevelState state;
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), 0);
g_object_get (toplevel, "state", &state, NULL);
return state;
}
/**
* gdk_toplevel_set_title: (attributes org.gtk.Method.set_property=title)
* @toplevel: a `GdkToplevel`
* @title: title of @surface
*
* Sets the title of a toplevel surface.
*
* The title maybe be displayed in the titlebar,
* in lists of windows, etc.
*/
void
gdk_toplevel_set_title (GdkToplevel *toplevel,
const char *title)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_object_set (toplevel, "title", title, NULL);
}
/**
* gdk_toplevel_set_startup_id: (attributes org.gtk.Method.set_property=startup-id)
* @toplevel: a `GdkToplevel`
* @startup_id: a string with startup-notification identifier
*
* Sets the startup notification ID.
*
* When using GTK, typically you should use
* [method@Gtk.Window.set_startup_id] instead of this
* low-level function.
*/
void
gdk_toplevel_set_startup_id (GdkToplevel *toplevel,
const char *startup_id)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_object_set (toplevel, "startup-id", startup_id, NULL);
}
/**
* gdk_toplevel_set_transient_for: (attributes org.gtk.Method.set_property=transient-for)
* @toplevel: a `GdkToplevel`
* @parent: another toplevel `GdkSurface`
*
* Sets a transient-for parent.
*
* Indicates to the window manager that @surface is a transient
* dialog associated with the application surface @parent. This
* allows the window manager to do things like center @surface
* on @parent and keep @surface above @parent.
*
* See [method@Gtk.Window.set_transient_for] if you’re using
* [class@Gtk.Window] or [class@Gtk.Dialog].
*/
void
gdk_toplevel_set_transient_for (GdkToplevel *toplevel,
GdkSurface *parent)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_object_set (toplevel, "transient-for", parent, NULL);
}
/**
* gdk_toplevel_set_modal: (attributes org.gtk.Method.set_property=modal)
* @toplevel: a `GdkToplevel`
* @modal: %TRUE if the surface is modal, %FALSE otherwise.
*
* Sets the toplevel to be modal.
*
* The application can use this hint to tell the
* window manager that a certain surface has modal
* behaviour. The window manager can use this information
* to handle modal surfaces in a special way.
*
* You should only use this on surfaces for which you have
* previously called [method@Gdk.Toplevel.set_transient_for].
*/
void
gdk_toplevel_set_modal (GdkToplevel *toplevel,
gboolean modal)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_object_set (toplevel, "modal", modal, NULL);
}
/**
* gdk_toplevel_set_icon_list: (attributes org.gtk.Method.set_property=icon-list)
* @toplevel: a `GdkToplevel`
* @surfaces: (transfer none) (element-type GdkTexture):
* A list of textures to use as icon, of different sizes
*
* Sets a list of icons for the surface.
*
* One of these will be used to represent the surface in iconic form.
* The icon may be shown in window lists or task bars. Which icon
* size is shown depends on the window manager. The window manager
* can scale the icon but setting several size icons can give better
* image quality.
*
* Note that some platforms don't support surface icons.
*/
void
gdk_toplevel_set_icon_list (GdkToplevel *toplevel,
GList *surfaces)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_object_set (toplevel, "icon-list", surfaces, NULL);
}
/**
* gdk_toplevel_show_window_menu:
* @toplevel: a `GdkToplevel`
* @event: a `GdkEvent` to show the menu for
*
* Asks the windowing system to show the window menu.
*
* The window menu is the menu shown when right-clicking the titlebar
* on traditional windows managed by the window manager. This is useful
* for windows using client-side decorations, activating it with a
* right-click on the window decorations.
*
* Returns: %TRUE if the window menu was shown and %FALSE otherwise.
*/
gboolean
gdk_toplevel_show_window_menu (GdkToplevel *toplevel,
GdkEvent *event)
{
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
return GDK_TOPLEVEL_GET_IFACE (toplevel)->show_window_menu (toplevel, event);
}
/**
* gdk_toplevel_set_decorated: (attributes org.gtk.Method.set_property=decorated)
* @toplevel: a `GdkToplevel`
* @decorated: %TRUE to request decorations
*
* Sets the toplevel to be decorated.
*
* Setting @decorated to %FALSE hints the desktop environment
* that the surface has its own, client-side decorations and
* does not need to have window decorations added.
*/
void
gdk_toplevel_set_decorated (GdkToplevel *toplevel,
gboolean decorated)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_object_set (toplevel, "decorated", decorated, NULL);
}
/**
* gdk_toplevel_set_deletable: (attributes org.gtk.Method.set_property=deletable)
* @toplevel: a `GdkToplevel`
* @deletable: %TRUE to request a delete button
*
* Sets the toplevel to be deletable.
*
* Setting @deletable to %TRUE hints the desktop environment
* that it should offer the user a way to close the surface.
*/
void
gdk_toplevel_set_deletable (GdkToplevel *toplevel,
gboolean deletable)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
g_object_set (toplevel, "deletable", deletable, NULL);
}
/**
* gdk_toplevel_supports_edge_constraints:
* @toplevel: a `GdkToplevel`
*
* Returns whether the desktop environment supports
* tiled window states.
*
* Returns: %TRUE if the desktop environment supports
* tiled window states
*/
gboolean
gdk_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
{
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
return GDK_TOPLEVEL_GET_IFACE (toplevel)->supports_edge_constraints (toplevel);
}
/**
* gdk_toplevel_inhibit_system_shortcuts:
* @toplevel: a `GdkToplevel`
* @event: (nullable): the `GdkEvent` that is triggering the inhibit
* request, or %NULL if none is available
*
* Requests that the @toplevel inhibit the system shortcuts.
*
* This is asking the desktop environment/windowing system to let all
* keyboard events reach the surface, as long as it is focused, instead
* of triggering system actions.
*
* If granted, the rerouting remains active until the default shortcuts
* processing is restored with [method@Gdk.Toplevel.restore_system_shortcuts],
* or the request is revoked by the desktop environment, windowing system
* or the user.
*
* A typical use case for this API is remote desktop or virtual machine
* viewers which need to inhibit the default system keyboard shortcuts
* so that the remote session or virtual host gets those instead of the
* local environment.
*
* The windowing system or desktop environment may ask the user to grant
* or deny the request or even choose to ignore the request entirely.
*
* The caller can be notified whenever the request is granted or revoked
* by listening to the [property@Gdk.Toplevel:shortcuts-inhibited] property.
*/
void
gdk_toplevel_inhibit_system_shortcuts (GdkToplevel *toplevel,
GdkEvent *event)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->inhibit_system_shortcuts (toplevel,
event);
}
/**
* gdk_toplevel_restore_system_shortcuts:
* @toplevel: a `GdkToplevel`
*
* Restore default system keyboard shortcuts which were previously
* inhibited.
*
* This undoes the effect of [method@Gdk.Toplevel.inhibit_system_shortcuts].
*/
void
gdk_toplevel_restore_system_shortcuts (GdkToplevel *toplevel)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->restore_system_shortcuts (toplevel);
}
/**
* gdk_toplevel_begin_resize:
* @toplevel: a `GdkToplevel`
* @edge: the edge or corner from which the drag is started
* @device: (nullable): the device used for the operation
* @button: the button being used to drag, or 0 for a keyboard-initiated drag
* @x: surface X coordinate of mouse click that began the drag
* @y: surface Y coordinate of mouse click that began the drag
* @timestamp: timestamp of mouse click that began the drag (use
* [method@Gdk.Event.get_time])
*
* Begins an interactive resize operation.
*
* You might use this function to implement a “window resize grip.”
*/
void
gdk_toplevel_begin_resize (GdkToplevel *toplevel,
GdkSurfaceEdge edge,
GdkDevice *device,
int button,
double x,
double y,
guint32 timestamp)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
if (device == NULL)
{
GdkSeat *seat = gdk_display_get_default_seat (GDK_SURFACE (toplevel)->display);
if (button == 0)
device = gdk_seat_get_keyboard (seat);
else
device = gdk_seat_get_pointer (seat);
}
GDK_TOPLEVEL_GET_IFACE (toplevel)->begin_resize (toplevel,
edge,
device,
button,
x, y,
timestamp);
}
/**
* gdk_toplevel_begin_move:
* @toplevel: a #GdkToplevel
* @device: the device used for the operation
* @button: the button being used to drag, or 0 for a keyboard-initiated drag
* @x: surface X coordinate of mouse click that began the drag
* @y: surface Y coordinate of mouse click that began the drag
* @timestamp: timestamp of mouse click that began the drag (use
* [method@Gdk.Event.get_time])
*
* Begins an interactive move operation.
*
* You might use this function to implement draggable titlebars.
*/
void
gdk_toplevel_begin_move (GdkToplevel *toplevel,
GdkDevice *device,
int button,
double x,
double y,
guint32 timestamp)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
if (device == NULL)
{
GdkSeat *seat = gdk_display_get_default_seat (GDK_SURFACE (toplevel)->display);
if (button == 0)
device = gdk_seat_get_keyboard (seat);
else
device = gdk_seat_get_pointer (seat);
}
GDK_TOPLEVEL_GET_IFACE (toplevel)->begin_move (toplevel,
device,
button,
x, y,
timestamp);
}
|
1612ba137039d820936f70ac04e3cac57688263a
|
e656978e5c3cc80ccb55ed8dca9cc3bd69d18921
|
/examples/notepad/src/notepad.c
|
3b6e90d42bda5f1c118fd220518fc4c5caca756f
|
[
"MIT"
] |
permissive
|
goodpaul6/Tiny
|
6d7458eca419b6e8926107787f9d7e02a46b99cc
|
94acd96f454b0a5b3576e08c1fa202746878cf41
|
refs/heads/master
| 2023-05-27T02:42:13.020622
| 2023-05-17T18:53:43
| 2023-05-17T18:53:43
| 27,659,160
| 134
| 11
|
MIT
| 2022-08-29T08:50:16
| 2014-12-07T04:23:34
|
C
|
UTF-8
|
C
| false
| false
| 875
|
c
|
notepad.c
|
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "editor.h"
#include "tigr.h"
static Editor GEditor;
static Tigr* screen;
static bool Done;
void DrawEditor(Tigr* screen, Editor* editor);
int main(int argc, char** argv) {
screen = tigrWindow(640, 480, "Tiny Notepad", TIGR_FIXED | TIGR_2X);
tigrSetPostFX(screen, 0, 0, 0.5f, 1.2f);
InitEditor(&GEditor);
GEditor.screen = screen;
if (argc > 1) {
MyOpenFile(&GEditor.buf, argv[1]);
FileOpened(&GEditor, argv[1]);
}
while (!tigrClosed(screen)) {
tigrClear(screen, tigrRGB(20, 20, 20));
UpdateEditor(&GEditor, screen);
DrawEditor(screen, &GEditor);
tigrUpdate(screen);
}
tigrFree(screen);
DestroyEditor(&GEditor);
return 0;
}
|
337a530fb5f615c559bdc00e3732b8cf0d177247
|
5fda2cad0be39ba90248d633d58ec36e83c08299
|
/lzma/CPP/7zip/IDecl.h
|
5a34b0e441911b3d6eabaf3c9a62ddf3bc7041be
|
[
"MIT"
] |
permissive
|
OlehKulykov/LzmaSDKObjC
|
82843b4dfaad7a4bbad8a1cdc8d36976075405eb
|
f029d5ca8190a605080ac82c2892ea5749d89c48
|
refs/heads/master
| 2023-08-25T16:53:44.851830
| 2022-11-02T07:26:50
| 2022-11-02T07:26:50
| 41,939,300
| 178
| 57
|
MIT
| 2020-08-28T07:58:13
| 2015-09-04T21:50:34
|
C++
|
UTF-8
|
C
| false
| false
| 680
|
h
|
IDecl.h
|
// IDecl.h
#ifndef __IDECL_H
#define __IDECL_H
#include "../Common/MyUnknown.h"
#define k_7zip_GUID_Data1 0x23170F69
#define k_7zip_GUID_Data2 0x40C1
#define k_7zip_GUID_Data3_Common 0x278A
#define k_7zip_GUID_Data3_Decoder 0x2790
#define k_7zip_GUID_Data3_Encoder 0x2791
#define k_7zip_GUID_Data3_Hasher 0x2792
#define DECL_INTERFACE_SUB(i, base, groupId, subId) \
DEFINE_GUID(IID_ ## i, \
k_7zip_GUID_Data1, \
k_7zip_GUID_Data2, \
k_7zip_GUID_Data3_Common, \
0, 0, 0, (groupId), 0, (subId), 0, 0); \
struct i: public base
#define DECL_INTERFACE(i, groupId, subId) DECL_INTERFACE_SUB(i, IUnknown, groupId, subId)
#endif
|
496d9a2fb1d948582be74abcb53bcb517f0477a8
|
25002d056f91df663aee7318d2c098b053ff5b11
|
/programs/fseDist.c
|
b9f5863364f61b6dc33492bf33c9ba51abde2def
|
[
"BSD-3-Clause",
"GPL-2.0-only",
"BSD-2-Clause"
] |
permissive
|
Cyan4973/FiniteStateEntropy
|
d745b146c52f25cf642ba6259da019af2da268cc
|
7149fa45ec69f54a709e5260e6a0eeb27e710ee0
|
refs/heads/dev
| 2023-08-21T22:22:57.228147
| 2022-09-09T17:38:51
| 2022-09-09T17:38:51
| 15,204,489
| 1,066
| 145
|
BSD-2-Clause
| 2022-09-09T17:38:52
| 2013-12-15T14:05:21
|
C
|
UTF-8
|
C
| false
| false
| 19,607
|
c
|
fseDist.c
|
/*
fseDist.c
Universal length FSE coder
Copyright (C) Yann Collet 2012-2014
GPL v2 License
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//**************************************
// Compiler Options
//**************************************
#if defined(_MSC_VER)
# define _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_DEPRECATE // VS2005
# pragma warning(disable : 4127) // disable: C4127: conditional expression is constant
# include <intrin.h>
#endif
//**************************************
// Includes
//**************************************
#include <stdlib.h> // malloc
#include <stdio.h> // fprintf, fopen, ftello64
#include <string.h> // memcpy
#define FSE_STATIC_LINKING_ONLY
#include "fse.h"
//**************************************
// Compiler specifics
//**************************************
#ifdef __GNUC__
# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#endif
//**************************************
// Basic Types
//**************************************
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L // C99
# include <stdint.h>
typedef uint8_t BYTE;
typedef uint16_t U16;
typedef int16_t S16;
typedef uint32_t U32;
typedef int32_t S32;
typedef uint64_t U64;
#else
typedef unsigned char BYTE;
typedef unsigned short U16;
typedef signed short S16;
typedef unsigned int U32;
typedef signed int S32;
typedef unsigned long long U64;
#endif
//**************************************
// Constants
//**************************************
#define KB *(1U<<10)
#define MB *(1U<<20)
#define GB *(1U<<30)
//**************************************
// Macros
//**************************************
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
//*********************************************************
// Common internal functions
//*********************************************************
static int FSED_highbit (register U32 val)
{
# if defined(_MSC_VER) // Visual
unsigned long r;
_BitScanReverse ( &r, val );
return (int) r;
# elif defined(__GNUC__) && (GCC_VERSION >= 304) // GCC Intrinsic
return 31 - __builtin_clz (val);
# else // Software version
static const int DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
U32 v = val;
int r;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
r = DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27];
return r;
# endif
}
//*********************************************************
// U16 Compression functions
//*********************************************************
int FSED_countU16 (unsigned int* count, const U16* source, int sourceSize)
{
const U16* ip = source;
const U16* const iend = source+sourceSize;
int i;
U32 Counting1[16] = {0};
U32 Counting2[16] = {0};
U32 Counting3[16] = {0};
U32 Counting4[16] = {0};
// Init checks
if (!sourceSize) return -1; // Error : no input
while (ip < iend-3)
{
Counting1[FSED_highbit(*ip++)]++;
Counting2[FSED_highbit(*ip++)]++;
Counting3[FSED_highbit(*ip++)]++;
Counting4[FSED_highbit(*ip++)]++;
}
while (ip<iend) Counting1[FSED_highbit(*ip++)]++;
for (i=0; i<16; i++) count[i] = Counting1[i] + Counting2[i] + Counting3[i] + Counting4[i];
{
int max = 15;
while (!count[max]) max--;
return max;
}
}
int FSED_noCompressU16(void* dest, const U16* source, int sourceSize)
{
BYTE* header = (BYTE*)dest;
*header=0;
memcpy(header+1, source, sourceSize*2);
return sourceSize*2 + 1;
}
int FSED_writeSingleU16(void* dest, U16 distance)
{
BYTE* header = (BYTE*) dest;
U16* value = (U16*)(header+1);
*header=1;
*value = distance;
return 3;
}
static void FSED_encodeU16(FSE_CState_t* statePtr, FSE_CStream_t* bitC, U16 value)
{
BYTE nbBits = (BYTE) FSED_highbit(value);
FSE_addBits(bitC, (size_t)value, nbBits);
FSE_encodeByte(bitC, statePtr, nbBits);
}
int FSED_compressU16_usingCTable (void* dest, const U16* source, int sourceSize, const void* CTable)
{
const U16* const istart = source;
const U16* ip;
const U16* const iend = istart + sourceSize;
BYTE* op = (BYTE*) dest;
FSE_CStream_t bitC;
FSE_CState_t state;
// init
FSE_initCStream(&bitC, op);
FSE_initCState(&state, CTable);
ip=iend-1;
while (ip>istart)
{
FSED_encodeU16(&state, &bitC, *ip--);
if (sizeof(size_t)>4) // static test
FSED_encodeU16(&state, &bitC, *ip--);
FSE_flushBits(&bitC);
}
if (ip==istart) { FSED_encodeU16(&state, &bitC, *ip--); FSE_flushBits(&bitC); }
FSE_flushCState(&bitC, &state);
return (int)FSE_closeCStream(&bitC);
}
#define FSED_U16_MAXMEMLOG 10
int FSED_compressU16 (void* dest, const U16* source, unsigned sourceSize, unsigned tableLog)
{
const U16* const istart = (const U16*) source;
const U16* ip = istart;
BYTE* const ostart = (BYTE*) dest;
BYTE* op = ostart;
unsigned maxSymbolValue = 15;
U32 counting[16];
S16 norm[16];
U32 CTable[2 + 16 + (1<<FSED_U16_MAXMEMLOG)];
if (tableLog > FSED_U16_MAXMEMLOG) return -1;
// early out
if (sourceSize <= 1) return FSED_noCompressU16 (ostart, istart, sourceSize);
// Scan for stats
maxSymbolValue = FSED_countU16 (counting, ip, sourceSize);
// Normalize
tableLog = FSE_optimalTableLog(tableLog, sourceSize, maxSymbolValue);
tableLog = (U32)FSE_normalizeCount (norm, tableLog, counting, sourceSize, maxSymbolValue);
if (tableLog==0) return FSED_writeSingleU16 (ostart, *source); // only one distance in the set
op += FSE_writeHeader (op, FSE_headerBound(maxSymbolValue, tableLog), norm, maxSymbolValue, tableLog);
// Compress
FSE_buildCTable (&CTable, norm, maxSymbolValue, tableLog);
op += FSED_compressU16_usingCTable (op, ip, sourceSize, &CTable);
// check compressibility
if ( (size_t)(op-ostart) >= (size_t)(sourceSize*2-1) )
return FSED_noCompressU16 (ostart, istart, sourceSize);
return (int) (op-ostart);
}
//*********************************************************
// U16 Decompression functions
//*********************************************************
int FSED_decompressRawU16 (U16* out, int osize, const BYTE* in)
{
memcpy (out, in+1, osize*2);
return osize*2+1;
}
int FSED_decompressSingleU16 (U16* out, int osize, U16 value)
{
int i;
for (i=0; i<osize; i++) *out++ = value;
return 3;
}
int FSED_decompressU16_usingDTable (U16* dst, size_t maxDstSize,
const void* cSrc, size_t cSrcSize,
const void* DTable)
{
U16* const ostart = dst;
U16* op = ostart;
FSE_DStream_t DStream;
FSE_DState_t DState;
// Init
(void)maxDstSize;
FSE_initDStream(&DStream, cSrc, cSrcSize);
FSE_initDState(&DState, &DStream, DTable);
// Hot loop
while (FSE_reloadDStream(&DStream))
{
int nbBits = FSE_decodeSymbol(&DState, &DStream);
unsigned short value = (U16)FSE_readBits(&DStream, nbBits);
value += 1<<nbBits;
*op++ = value;
}
return (int)(op-ostart);
}
int FSED_decompressU16 (U16* dst, size_t maxDstSize,
const void* cSrc, size_t cSrcSize)
{
const BYTE* const istart = (const BYTE*) cSrc;
const BYTE* ip = istart;
short norm[16];
U32 DTable[FSE_DTABLE_SIZE_U32(FSED_U16_MAXMEMLOG)];
unsigned nbSymbols;
unsigned tableLog;
int errorCode;
size_t headerSize;
// normal FSE decoding mode
headerSize = FSE_readHeader (norm, &nbSymbols, &tableLog, istart, cSrcSize);
ip += headerSize;
cSrcSize -= headerSize;
FSE_buildDTable (DTable, norm, nbSymbols, tableLog);
errorCode = FSED_decompressU16_usingDTable (dst, maxDstSize, ip, cSrcSize, DTable);
return (int) (errorCode);
}
//*********************************************************
// U16Log2 Compression functions
//*********************************************************
// note : values MUST be >= (1<<LN)
#define LN 3
int FSED_Log2(U16 value)
{
int hb = FSED_highbit(value>>LN);
return (hb * (1<<LN)) + (value>>hb) - (1<<LN);
}
int FSED_countU16Log2 (unsigned int* count, const U16* source, int sourceSize)
{
const U16* ip = source;
const U16* const iend = source+sourceSize;
int i;
U32 Counting1[64] = {0};
U32 Counting2[64] = {0};
U32 Counting3[64] = {0};
U32 Counting4[64] = {0};
// Init checks
if (!sourceSize) return -1; // Error : no input
while (ip < iend-3)
{
Counting1[FSED_Log2(*ip++)]++;
Counting2[FSED_Log2(*ip++)]++;
Counting3[FSED_Log2(*ip++)]++;
Counting4[FSED_Log2(*ip++)]++;
}
while (ip<iend) Counting1[FSED_Log2(*ip++)]++;
for (i=0; i<64; i++) count[i] = Counting1[i] + Counting2[i] + Counting3[i] + Counting4[i];
{
int max = 64;
while (!count[max-1]) max--;
return max;
}
}
static void FSED_encodeU16Log2(FSE_CState_t* statePtr, FSE_CStream_t* bitC, U16 value)
{
int nbBits = FSED_highbit(value>>LN);
BYTE symbol = (BYTE)FSED_Log2(value);
FSE_addBits(bitC, nbBits, (size_t)value);
FSE_encodeByte(bitC, statePtr, symbol);
}
int FSED_compressU16Log2_usingCTable (void* dest, const U16* source, int sourceSize, const void* CTable)
{
const U16* const istart = source;
const U16* ip;
const U16* const iend = istart + sourceSize;
BYTE* op = (BYTE*) dest;
const int memLog = ( (U16*) CTable) [0];
FSE_CState_t state;
FSE_CStream_t bitC;
// init
FSE_initCStream(&bitC, op);
FSE_initCState(&state, CTable);
ip=iend-1;
while (ip>istart)
{
FSED_encodeU16Log2(&state, &bitC, *ip--);
if (sizeof(size_t)>4) // static test
FSED_encodeU16Log2(&state, &bitC, *ip--);
FSE_flushBits(&bitC);
}
if (ip==istart) { FSED_encodeU16Log2(&state, &bitC, *ip--); FSE_flushBits(&bitC); }
// Finalize block
FSE_addBits(&bitC, state.value, memLog);
FSE_flushBits(&bitC);
return (int)FSE_closeCStream(&bitC);
}
#define FSED_U16LOG2_MAXMEMLOG 11
int FSED_compressU16Log2 (void* dest, const U16* source, unsigned sourceSize, unsigned memLog)
{
const U16* const istart = (const U16*) source;
const U16* ip = istart;
BYTE* const ostart = (BYTE*) dest;
BYTE* op = ostart;
int nbSymbols = 16;
U32 counting[64];
short norm[64];
U32 CTable[2 + 16 + (1<<FSED_U16LOG2_MAXMEMLOG)];
if (memLog > FSED_U16LOG2_MAXMEMLOG) return -1;
// early out
if (sourceSize <= 1) return FSED_noCompressU16 (ostart, istart, sourceSize);
// Scan for stats
nbSymbols = FSED_countU16Log2 (counting, ip, sourceSize);
// Normalize
memLog = (U32)FSE_normalizeCount (norm, memLog, counting, sourceSize, nbSymbols);
if (memLog==0) return FSED_writeSingleU16 (ostart, *source); // only one distance in the set
op += FSE_writeHeader (op, FSE_headerBound(nbSymbols, memLog), norm, nbSymbols, memLog);
// Compress
FSE_buildCTable (&CTable, norm, nbSymbols, memLog);
op += FSED_compressU16Log2_usingCTable (op, ip, sourceSize, &CTable);
// check compressibility
if ( (size_t)(op-ostart) >= (size_t)(sourceSize*2-1) )
return FSED_noCompressU16 (ostart, istart, sourceSize);
return (int) (op-ostart);
}
//*********************************************************
// U32 Compression functions
//*********************************************************
#define FSED_MAXBITS_U32 26
int FSED_countU32 (unsigned int* count, const U32* source, int sourceSize)
{
const U32* ip = source;
const U32* const iend = source+sourceSize;
int i;
U32 Counting1[FSED_MAXBITS_U32] = {0};
U32 Counting2[FSED_MAXBITS_U32] = {0};
U32 Counting3[FSED_MAXBITS_U32] = {0};
U32 Counting4[FSED_MAXBITS_U32] = {0};
// Init checks
if (!sourceSize) return -1; // Error : no input
while (ip < iend-3)
{
Counting1[FSED_highbit(*ip++)]++;
Counting2[FSED_highbit(*ip++)]++;
Counting3[FSED_highbit(*ip++)]++;
Counting4[FSED_highbit(*ip++)]++;
}
while (ip<iend) Counting1[FSED_highbit(*ip++)]++;
for (i=0; i<FSED_MAXBITS_U32; i++) count[i] = Counting1[i] + Counting2[i] + Counting3[i] + Counting4[i];
{
int max = FSED_MAXBITS_U32-1;
while (!count[max]) max--;
return max;
}
}
int FSED_noCompressU32(void* dest, const U32* source, int sourceSize)
{
BYTE* header = (BYTE*)dest;
*header=0;
memcpy(header+1, source, sourceSize*4);
return (sourceSize*4) + 1;
}
int FSED_writeSingleU32(void* dest, const U32* source, unsigned sourceSize)
{
BYTE* header = (BYTE*) dest;
U32 val = *source;
const unsigned nb_bits = FSED_highbit(val);
size_t container = 1 + (nb_bits<<2); // header 1 (2 bits) : singleU32
unsigned pos=7;
const unsigned mask = (1<<(nb_bits))-1;
const unsigned max = (sizeof(size_t)*8) - nb_bits;
unsigned i=0;
while (i<sourceSize)
{
val = *source++;
container += (size_t)(val & mask) << pos;
pos += nb_bits;
if (pos >= max) // Note : avoid filling container entirely, because container >> 64 == container (!= 0)
{
const unsigned nb_bytes = pos >> 3;
*(size_t*)header = container;
container >>= (nb_bytes*8);
pos -= (nb_bytes*8);
header += nb_bytes;
}
i++;
}
{
const unsigned nb_bytes = (pos+7) >> 3;
*(size_t*)header = container;
header += nb_bytes;
}
return (int)(header-(BYTE*)dest);
}
void FSED_encodeU32(FSE_CStream_t* bitC, FSE_CState_t* statePtr, U32 value)
{
//BYTE nbBits = (BYTE) FSED_highbit((value>>3)+1);
//FSE_addBits(bitC, (size_t)value, nbBits+3);
BYTE nbBits = (BYTE) FSED_highbit(value);
FSE_addBits(bitC, (size_t)value, nbBits);
if (sizeof(size_t)==4) // static test
FSE_flushBits(bitC);
FSE_encodeByte(bitC, statePtr, nbBits);
}
int FSED_compressU32_usingCTable (void* dest, const U32* source, int sourceSize, const void* CTable)
{
const U32* const istart = source;
const U32* ip;
const U32* const iend = istart + sourceSize;
BYTE* op = (BYTE*) dest;
int tableLog = *(U16*)CTable;
FSE_CStream_t bitC;
FSE_CState_t state;
// init
FSE_initCStream(&bitC, op);
FSE_initCState(&state, CTable);
ip=iend;
while (ip>istart)
{
FSED_encodeU32(&bitC, &state, *--ip);
FSE_flushBits(&bitC);
}
FSE_addBits(&bitC, state.value, tableLog); FSE_flushBits(&bitC);
return (int)FSE_closeCStream(&bitC);
}
#define FSED_U32_MAXTABLELOG 11
size_t FSED_compressU32 (void* dst, size_t maxDstSize, const U32* src, size_t srcSize, unsigned tableLog)
{
const U32* const istart = (const U32*) src;
const U32* ip = istart;
BYTE* const ostart = (BYTE*) dst;
BYTE* op = ostart;
int nbSymbols = FSED_MAXBITS_U32;
U32 counting[FSED_MAXBITS_U32];
short norm[FSED_MAXBITS_U32];
U32 CTable[2 + FSED_MAXBITS_U32 + (1<<FSED_U32_MAXTABLELOG)];
/* safety checks */
(void)maxDstSize;
if (tableLog > FSED_U32_MAXTABLELOG) return (size_t)-FSE_ERROR_GENERIC;
/* early out */
if (srcSize <= 1) return FSED_noCompressU32 (ostart, src, srcSize);
/* Scan for stats */
nbSymbols = FSED_countU32 (counting, ip, srcSize);
/* Normalize */
tableLog = (U32)FSE_normalizeCount (norm, tableLog, counting, srcSize, nbSymbols);
if (tableLog==0) return FSED_writeSingleU32 (ostart, src, srcSize);
op += FSE_writeHeader (op, FSE_headerBound(nbSymbols, tableLog), norm, nbSymbols, tableLog);
/* Compress */
FSE_buildCTable (&CTable, norm, nbSymbols, tableLog);
op += FSED_compressU32_usingCTable (op, ip, srcSize, &CTable);
/* check compressibility */
if ( (size_t)(op-ostart) >= (size_t)(srcSize*4-1) )
return FSED_noCompressU32 (ostart, istart, srcSize);
return (int) (op-ostart);
}
/*********************************************************
U32 Decompression functions
*********************************************************/
int FSED_decompressRawU32 (U32* out, int osize, const BYTE* in)
{
memcpy (out, in+1, osize*4);
return osize*4+1;
}
int FSED_decompressSingleU32 (U32* out, unsigned osize, const BYTE* istart)
{
const BYTE* header = istart;
size_t container = (*(size_t*)header) >> 2; // assumption : *istart&3==1;
const unsigned nb_bits = container & 31;
unsigned pos=7;
const unsigned prefix = 1<<nb_bits;
const unsigned mask = prefix-1;
const unsigned max = (sizeof(size_t)*8) - nb_bits;
unsigned i=0;
container >>= 5;
while (i<osize)
{
U32 val = container & mask;
pos += nb_bits;
val += prefix;
container >>= nb_bits;
*out++ = val;
if (pos > max)
{
const unsigned nb_bytes = pos >> 3;
header += nb_bytes;
pos &= 7;
container = *(size_t*)header;
container >>= pos;
}
i++;
}
{
const unsigned nb_bytes = (pos+7) >> 3;
header += nb_bytes;
}
return (int)(header-istart);
}
int FSED_decompressU32_usingDTable (U32* dst, size_t maxDstSize,
const void* cSrc, size_t cSrcSize,
const void* DTable)
{
U32* const ostart = dst;
U32* op = ostart;
FSE_DStream_t DStream;
FSE_DState_t DState;
/* Init */
(void)maxDstSize;
FSE_initDStream(&DStream, cSrc, cSrcSize);
FSE_initDState(&DState, &DStream, DTable);
// Hot loop
while (FSE_reloadDStream(&DStream)<2)
{
int nbBits = FSE_decodeSymbol(&DState, &DStream);
bitD_t value;
FSE_reloadDStream(&DStream);
value = FSE_readBits(&DStream, nbBits);
value += (bitD_t)1<<nbBits;
*op++ = (U32)value;
}
return (int)(op-ostart);
}
int FSED_decompressU32 (U32* dst, size_t maxDstSize,
const void* cSrc, size_t cSrcSize)
{
const BYTE* const istart = (const BYTE*) cSrc;
const BYTE* ip = istart;
short norm[FSED_MAXBITS_U32];
U32 DTable[1<<FSED_U32_MAXTABLELOG];
unsigned nbSymbols;
unsigned tableLog;
size_t headerSize;
headerSize = FSE_readHeader (norm, &nbSymbols, &tableLog, istart, cSrcSize);
ip += headerSize;
cSrcSize -= headerSize;
FSE_buildDTable (DTable, norm, nbSymbols, tableLog);
return FSED_decompressU32_usingDTable (dst, maxDstSize, ip, cSrcSize, DTable);
}
|
cedbb0ef5eae6a3ec71da1ced7dda0db680ad5f2
|
fbe68d84e97262d6d26dd65c704a7b50af2b3943
|
/third_party/virtualbox/src/VBox/Additions/x11/x11include/xorg-server-1.5.3/swaprep.h
|
bebd3a8140e88dce5d4dc61d5da17a82598169d5
|
[
"GPL-2.0-only",
"LicenseRef-scancode-unknown-license-reference",
"CDDL-1.0",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"GPL-2.0-or-later",
"MPL-1.0",
"LicenseRef-scancode-generic-exception",
"Apache-2.0",
"OpenSSL",
"MIT"
] |
permissive
|
thalium/icebox
|
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
|
6f78952d58da52ea4f0e55b2ab297f28e80c1160
|
refs/heads/master
| 2022-08-14T00:19:36.984579
| 2022-02-22T13:10:31
| 2022-02-22T13:10:31
| 190,019,914
| 585
| 109
|
MIT
| 2022-01-13T20:58:15
| 2019-06-03T14:18:12
|
C++
|
UTF-8
|
C
| false
| false
| 7,774
|
h
|
swaprep.h
|
/************************************************************
Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the above listed
copyright holder(s) not be used in advertising or publicity pertaining
to distribution of the software without specific, written prior
permission.
THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
LIABLE FOR ANY SPECIAL, 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.
********************************************************/
#ifndef SWAPREP_H
#define SWAPREP_H 1
extern void Swap32Write(
ClientPtr /* pClient */,
int /* size */,
CARD32 * /* pbuf */);
extern void CopySwap32Write(
ClientPtr /* pClient */,
int /* size */,
CARD32 * /* pbuf */);
extern void CopySwap16Write(
ClientPtr /* pClient */,
int /* size */,
short * /* pbuf */);
extern void SGenericReply(
ClientPtr /* pClient */,
int /* size */,
xGenericReply * /* pRep */);
extern void SGetWindowAttributesReply(
ClientPtr /* pClient */,
int /* size */,
xGetWindowAttributesReply * /* pRep */);
extern void SGetGeometryReply(
ClientPtr /* pClient */,
int /* size */,
xGetGeometryReply * /* pRep */);
extern void SQueryTreeReply(
ClientPtr /* pClient */,
int /* size */,
xQueryTreeReply * /* pRep */);
extern void SInternAtomReply(
ClientPtr /* pClient */,
int /* size */,
xInternAtomReply * /* pRep */);
extern void SGetAtomNameReply(
ClientPtr /* pClient */,
int /* size */,
xGetAtomNameReply * /* pRep */);
extern void SGetPropertyReply(
ClientPtr /* pClient */,
int /* size */,
xGetPropertyReply * /* pRep */);
extern void SListPropertiesReply(
ClientPtr /* pClient */,
int /* size */,
xListPropertiesReply * /* pRep */);
extern void SGetSelectionOwnerReply(
ClientPtr /* pClient */,
int /* size */,
xGetSelectionOwnerReply * /* pRep */);
extern void SQueryPointerReply(
ClientPtr /* pClient */,
int /* size */,
xQueryPointerReply * /* pRep */);
extern void SwapTimeCoordWrite(
ClientPtr /* pClient */,
int /* size */,
xTimecoord * /* pRep */);
extern void SGetMotionEventsReply(
ClientPtr /* pClient */,
int /* size */,
xGetMotionEventsReply * /* pRep */);
extern void STranslateCoordsReply(
ClientPtr /* pClient */,
int /* size */,
xTranslateCoordsReply * /* pRep */);
extern void SGetInputFocusReply(
ClientPtr /* pClient */,
int /* size */,
xGetInputFocusReply * /* pRep */);
extern void SQueryKeymapReply(
ClientPtr /* pClient */,
int /* size */,
xQueryKeymapReply * /* pRep */);
extern void SQueryFontReply(
ClientPtr /* pClient */,
int /* size */,
xQueryFontReply * /* pRep */);
extern void SQueryTextExtentsReply(
ClientPtr /* pClient */,
int /* size */,
xQueryTextExtentsReply * /* pRep */);
extern void SListFontsReply(
ClientPtr /* pClient */,
int /* size */,
xListFontsReply * /* pRep */);
extern void SListFontsWithInfoReply(
ClientPtr /* pClient */,
int /* size */,
xListFontsWithInfoReply * /* pRep */);
extern void SGetFontPathReply(
ClientPtr /* pClient */,
int /* size */,
xGetFontPathReply * /* pRep */);
extern void SGetImageReply(
ClientPtr /* pClient */,
int /* size */,
xGetImageReply * /* pRep */);
extern void SListInstalledColormapsReply(
ClientPtr /* pClient */,
int /* size */,
xListInstalledColormapsReply * /* pRep */);
extern void SAllocColorReply(
ClientPtr /* pClient */,
int /* size */,
xAllocColorReply * /* pRep */);
extern void SAllocNamedColorReply(
ClientPtr /* pClient */,
int /* size */,
xAllocNamedColorReply * /* pRep */);
extern void SAllocColorCellsReply(
ClientPtr /* pClient */,
int /* size */,
xAllocColorCellsReply * /* pRep */);
extern void SAllocColorPlanesReply(
ClientPtr /* pClient */,
int /* size */,
xAllocColorPlanesReply * /* pRep */);
extern void SQColorsExtend(
ClientPtr /* pClient */,
int /* size */,
xrgb * /* prgb */);
extern void SQueryColorsReply(
ClientPtr /* pClient */,
int /* size */,
xQueryColorsReply * /* pRep */);
extern void SLookupColorReply(
ClientPtr /* pClient */,
int /* size */,
xLookupColorReply * /* pRep */);
extern void SQueryBestSizeReply(
ClientPtr /* pClient */,
int /* size */,
xQueryBestSizeReply * /* pRep */);
extern void SListExtensionsReply(
ClientPtr /* pClient */,
int /* size */,
xListExtensionsReply * /* pRep */);
extern void SGetKeyboardMappingReply(
ClientPtr /* pClient */,
int /* size */,
xGetKeyboardMappingReply * /* pRep */);
extern void SGetPointerMappingReply(
ClientPtr /* pClient */,
int /* size */,
xGetPointerMappingReply * /* pRep */);
extern void SGetModifierMappingReply(
ClientPtr /* pClient */,
int /* size */,
xGetModifierMappingReply * /* pRep */);
extern void SGetKeyboardControlReply(
ClientPtr /* pClient */,
int /* size */,
xGetKeyboardControlReply * /* pRep */);
extern void SGetPointerControlReply(
ClientPtr /* pClient */,
int /* size */,
xGetPointerControlReply * /* pRep */);
extern void SGetScreenSaverReply(
ClientPtr /* pClient */,
int /* size */,
xGetScreenSaverReply * /* pRep */);
extern void SLHostsExtend(
ClientPtr /* pClient */,
int /* size */,
char * /* buf */);
extern void SListHostsReply(
ClientPtr /* pClient */,
int /* size */,
xListHostsReply * /* pRep */);
extern void SErrorEvent(
xError * /* from */,
xError * /* to */);
extern void SwapConnSetupInfo(
char * /* pInfo */,
char * /* pInfoTBase */);
extern void WriteSConnectionInfo(
ClientPtr /* pClient */,
unsigned long /* size */,
char * /* pInfo */);
extern void SwapConnSetupPrefix(
xConnSetupPrefix * /* pcspFrom */,
xConnSetupPrefix * /* pcspTo */);
extern void WriteSConnSetupPrefix(
ClientPtr /* pClient */,
xConnSetupPrefix * /* pcsp */);
#undef SWAPREP_PROC
#define SWAPREP_PROC(func) void func(xEvent * /* from */, xEvent * /* to */)
SWAPREP_PROC(SCirculateEvent);
SWAPREP_PROC(SClientMessageEvent);
SWAPREP_PROC(SColormapEvent);
SWAPREP_PROC(SConfigureNotifyEvent);
SWAPREP_PROC(SConfigureRequestEvent);
SWAPREP_PROC(SCreateNotifyEvent);
SWAPREP_PROC(SDestroyNotifyEvent);
SWAPREP_PROC(SEnterLeaveEvent);
SWAPREP_PROC(SExposeEvent);
SWAPREP_PROC(SFocusEvent);
SWAPREP_PROC(SGraphicsExposureEvent);
SWAPREP_PROC(SGravityEvent);
SWAPREP_PROC(SKeyButtonPtrEvent);
SWAPREP_PROC(SKeymapNotifyEvent);
SWAPREP_PROC(SMapNotifyEvent);
SWAPREP_PROC(SMapRequestEvent);
SWAPREP_PROC(SMappingEvent);
SWAPREP_PROC(SNoExposureEvent);
SWAPREP_PROC(SPropertyEvent);
SWAPREP_PROC(SReparentEvent);
SWAPREP_PROC(SResizeRequestEvent);
SWAPREP_PROC(SSelectionClearEvent);
SWAPREP_PROC(SSelectionNotifyEvent);
SWAPREP_PROC(SSelectionRequestEvent);
SWAPREP_PROC(SUnmapNotifyEvent);
SWAPREP_PROC(SVisibilityEvent);
#undef SWAPREP_PROC
#endif /* SWAPREP_H */
|
4135ca7fa23b2744c8e70aef86d22a441d65173c
|
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
|
/PWGHF/correlationHF/macros/DoPlotCompare1GeVpp.C
|
3c28d363a3d94bcb84040998c84ac29d8fd25498
|
[] |
permissive
|
alisw/AliPhysics
|
91bf1bd01ab2af656a25ff10b25e618a63667d3e
|
5df28b2b415e78e81273b0d9bf5c1b99feda3348
|
refs/heads/master
| 2023-08-31T20:41:44.927176
| 2023-08-31T14:51:12
| 2023-08-31T14:51:12
| 61,661,378
| 129
| 1,150
|
BSD-3-Clause
| 2023-09-14T18:48:45
| 2016-06-21T19:31:29
|
C++
|
UTF-8
|
C
| false
| false
| 12,646
|
c
|
DoPlotCompare1GeVpp.C
|
/*
Comparoson macro for D*, D0, D+
SYSTEM: pp at 7.00 TeV
Dmeson pT : High, mid and low pT
Associated pT : > 1.0 GeV/c
by: Jitendra (jitendra.kumar@cern.ch)
*/
TString inputdirectory = "";
Int_t nhistos=6; //pPb !! IMPORTANT to change -->9 for pp
void SetInputDirectory(TString strdir){
inputdirectory=strdir;
}
TString *filenames;
TCanvas **Canvas;
TCanvas *CanvasCorrelation;
void Reset(){
delete [] filenames;
delete filenames;
// for(Int_t k=0;k<nhistos;k++){
// if(Canvas[k])delete Canvas[k];
// }
delete [] Canvas;
delete CanvasCorrelation;
}
void DoPlotCompareAbove1pp(){// THIS IS NOT A GENERAL MACRO YET --> USE IT ONLY FOR pp, 0.3<pt<1 case
DoPlotSingle1Canvas("1.0to99.0","pp");
}
//_______________________________________________________________________
void DoPlotSingle1Canvas(TString TrackpTthr ="dot5",TString system = "pp"){
gStyle->SetOptStat(0);
Reset();
Int_t CanvasSizeX, CanvasSizeY;
if(system=="pp")CanvasSizeX =1300, CanvasSizeY = 400;
else if(system=="pPb")CanvasSizeX =1200, CanvasSizeY = 600;
else cout << "Check System input !! " <<endl;
CanvasCorrelation=new TCanvas("CanvasCorrelation","CanvasCorrelation",CanvasSizeX,CanvasSizeY);
CanvasCorrelation->SetLeftMargin(0.18409396);
//CanvasCorrelation->SetRightMargin(0.05872483);
//CanvasCorrelation->SetTopMargin(0.07678883);
//CanvasCorrelation->SetBottomMargin(0.1239092);
if(system=="pp")CanvasCorrelation->Divide(3,1);
else if(system=="pPb")CanvasCorrelation->Divide(2,1);
else cout << "Check System input !! " <<endl;
TString CanvasName = "";
LoadFileNamesToCompare(TrackpTthr,system);
cout << " " << endl << "Adding file.." << endl;
for(Int_t k = 0; k<nhistos; k++)cout << k+1 <<" ---------> # " << filenames[k].Data()<<endl;
Int_t entries;
TCanvas ** Canvas = new TCanvas *[nhistos];
Int_t kTemp = 0;
for(Int_t k=0; k<nhistos; k++){
gPad->SetLeftMargin(0.15009396);
gPad->SetRightMargin(-0.25409396);
//gPad->SetMargin(0.1,0.1,.90,.90);
kTemp = 0;
if( k < 3) kTemp = 1;
else if(3<= k && k < 6) kTemp = 2;
else if(k >= 6 )kTemp = 3;
//cout << kTemp << endl;
Canvas[k] = GetCanvas(k,"cDraw"); // get p-Pb
Canvas[k]->SetName(Form("canvaInput%d",k));
TList *lc=Canvas[k]->GetListOfPrimitives();
entries=lc->GetEntries();
for(Int_t jl=0;jl<entries;jl++){
TObject *obj=lc->At(jl);
TString strName=obj->ClassName();
if(strName.Contains("TFrame"))continue;
if(strName.Contains("TPad"))continue;
if(strName.Contains("TH1")){
TH1D *hcur=(TH1D*)obj;
if(system=="pp")hcur->SetMarkerSize(0.7);
else if(system=="pPb")hcur->SetMarkerSize(0.9);
else Printf("Check your system name");
//hcur->SetLineWidth(2);
//Double_t val=hcur->GetMaximum();
//hcur->SetMaximum(val);
}
if(strName.Contains("TLatex")){
TLatex *tl=(TLatex*)obj;
TString str=tl->GetTitle();
if(str.Contains("D^{0}")){
hcur->SetMarkerColor(kRed);
hcur->SetMarkerStyle(20);
}else if(str.Contains("D^{+}")){
hcur->SetMarkerColor(kGreen+3);
hcur->SetMarkerStyle(21);
}else if(str.Contains("D^{*+}")){
// hcur->SetMarkerColor(5);
hcur->SetMarkerColor(kAzure-2);
hcur->SetMarkerStyle(22);
}
}
if(strName.Contains("TGraph")){
//Printf("There is a TGraph");
TGraphAsymmErrors *gr=(TGraphAsymmErrors*)obj;
// gr->SetMarkerStyle();
// gr->SetMarkerColor(0);
if(system=="pp")gr->SetMarkerSize(0.7);
else if(system=="pPb")gr->SetMarkerSize(0.9);
gr->SetLineWidth(2);
gr->Draw("E2");
TGraphAsymmErrors *gr2=(TGraphAsymmErrors*)gr->Clone("grHelp");
//gr2->SetMarkerColor(kBlack);
//gr2->SetLineColor(kBlack);
//gr2->SetMarkerSize(0.3);
//gr2->Draw("p");
}
else obj->Draw("same");
}
CanvasCorrelation->cd(kTemp);
if(k==0 || k==3 || k==6){
hcur->GetYaxis()->SetRangeUser(0,10);
hcur->GetYaxis()->SetTitle("#frac{1}{#it{N}_{D^{}}}#frac{d#it{N}^{assoc}}{d#Delta#varphi} (rad^{-1})");
hcur->Draw("ep");
//dot3 to 1 = 0.15, 0.21, 027
TLatex *tlTitleDplus=new TLatex(0.52,0.51,"#bf{D^{+}#cbar{}^{+19%}_{-18%} scale uncertainty}");
tlTitleDplus->SetNDC();
tlTitleDplus->SetTextColor(kGreen+3);
tlTitleDplus->SetTextSize(0.033);
tlTitleDplus->Draw();
TLatex *tlTitleDStar=new TLatex(0.52,0.57,"#bf{D^{*+}#cbar{}^{+14%}_{-13%} scale uncertainty}");
tlTitleDStar->SetNDC();
tlTitleDStar->SetTextColor(kAzure-2);
tlTitleDStar->SetTextSize(0.033);
tlTitleDStar->Draw();
TLatex *tlTitleDZero=new TLatex(0.52,0.63,"#bf{D^{0}#cbar{}^{+14%}_{-13%} scale uncertainty}");
tlTitleDZero->SetNDC();
tlTitleDZero->SetTextColor(kRed);
tlTitleDZero->SetTextSize(0.033);
tlTitleDZero->Draw();
TLatex *tlTitle0=new TLatex(0.18,0.80,"#bf{pp, #sqrt{s} = 7 TeV, L_{int} = 5 nb^{-1}}");
tlTitle0->SetNDC();
//tlTitle0->SetTextColor(kRed);
tlTitle0->SetTextSize(0.033);
tlTitle0->Draw();
if(kTemp==1)TLatex *tlTitle00=new TLatex(0.18,0.75,"#bf{3 < #it{p}_{T}^{D^{}} < 5 GeV/c}, #bf{|#it{y}^{D}| < 0.5}");
if(kTemp==2)TLatex *tlTitle00=new TLatex(0.18,0.75,"#bf{5 < #it{p}_{T}^{D^{}} < 8 GeV/c}, #bf{|#it{y}^{D}| < 0.5}");
if(kTemp==3)TLatex *tlTitle00=new TLatex(0.18,0.75,"#bf{8 < #it{p}_{T}^{D^{}} < 16 GeV/c}, #bf{|#it{y}^{D}| < 0.5}");
tlTitle00->SetNDC();
//tlTitle0->SetTextColor(kRed);
tlTitle00->SetTextSize(0.033);
tlTitle00->Draw();
for(Int_t jl=0;jl<entries;jl++){
TObject *obj=lc->At(jl);
TString strName=obj->ClassName();
TString str=obj->GetTitle();
if(strName.Contains("TLatex")){
TLatex *tl=(TLatex*)obj;
if(str.Contains("-charged")){
TString strTitle=tl->GetTitle();
Printf("\n%s <-- Default txt(1)",strTitle.Data());
strTitle.ReplaceAll("D^{0}","D^{} ");
Printf("%s <-- Replaced with txt(1)",strTitle.Data());
tl->SetTitle(strTitle.Data());
}
if(str.Contains("ALICE")){
TString strTitle2=tl->GetTitle();
Printf("\n%s <-- Default txt(2)",strTitle2.Data());
strTitle2.ReplaceAll("ALICE Preliminary","");
Printf("%s <-- Replaced with txt(2)",strTitle2.Data());
tl->SetTitle(strTitle2.Data());
}
if(str.Contains("pp")){
TString strTitle3=tl->GetTitle();
Printf("\n%s <-- Default txt(3)",strTitle3.Data());
strTitle3.ReplaceAll("pp, #sqrt{#it{s}} = 7 TeV, L_{int} = 5 nb^{-1}","");
Printf("%s <-- Replaced with txt(3)",strTitle3.Data());
tl->SetTitle(strTitle3.Data());
}
if(str.Contains("assoc")){
TString strTitle5=tl->GetTitle();
Printf("\n%s <-- Default txt(4)",strTitle5.Data());
if(kTemp==1)strTitle5.ReplaceAll(strTitle5.Data(),"#bf{#it{p}_{T}^{assoc} > 1 GeV/#it{c}}, #bf{|#Delta#eta| < 1.0}");
if(kTemp==2)strTitle5.ReplaceAll(strTitle5.Data(),"#bf{#it{p}_{T}^{assoc} > 1 GeV/#it{c}}, #bf{|#Delta#eta| < 1.0}");
if(kTemp==3)strTitle5.ReplaceAll(strTitle5.Data(),"#bf{#it{p}_{T}^{assoc} > 1 GeV/#it{c}}, #bf{|#Delta#eta| < 1.0}");
Printf("%s <-- Replaced with txt(4)",strTitle5.Data());
tl->SetTitle(strTitle5.Data());
}
// SCALE Uncertainity
if(str.Contains("scale uncertainty")){
TString strTitle4=tl->GetTitle();
strTitle4.ReplaceAll("{}^{+17%}_{-16%} dummy scale uncertainty","D^{0}, D^{+}, D^{*+} Comparison");
tl->SetTitle(strTitle4.Data());
tl->SetX(tl->GetX()+0.11); // +0.10 for dot3to1
tl->SetY(tl->GetY()+0.07);
tl->SetTextSize(0.023);
TString strTitle41=tl->GetTitle();
cout << "============> "<<tl->GetTextSize() << ", " << tl->GetY()<< endl;
if(system=="pp"){
tl->SetX(tl->GetX()+0.23);
tl->SetTextSize(0.033);
}
else if(system=="pPb"){
tl->SetX(tl->GetX()+0.25);
tl->SetY(tl->GetY()+0.04);
tl->SetTextSize(0.037);
}
cout << "----------> " << strTitle41.Data() << endl;
}
//legend->AddEntry(hcur,"D0","lep");
tl->Draw();
}
if(strName.Contains("TGraph")){
//Printf("There is a TGraph");
TGraphAsymmErrors *gr=(TGraphAsymmErrors*)obj;
// gr->SetMarkerStyle();
// gr->SetMarkerColor(0);
if(system=="pp")gr->SetMarkerSize(0.7);
else if(system=="pPb")gr->SetMarkerSize(0.9);
gr->SetLineWidth(2);
gr->Draw("E2");
TGraphAsymmErrors *gr2=(TGraphAsymmErrors*)gr->Clone("grHelp");
//gr2->SetMarkerColor(kBlack);
//gr2->SetLineColor(kBlack);
//gr2->SetMarkerSize(0.3);
//gr2->Draw("p");
}
}
}
if(k!=0 || k!=3 || k!=6){
hcur->Draw("sameep");
//cout << hcur->GetYaxis()->GetTitle() << "<---------------"<<endl;
for(Int_t jl=0;jl<entries;jl++){
TObject *obj=lc->At(jl);
TString strName=obj->ClassName();
if(strName.Contains("TGraph")){
//Printf("There is a TGraph");
TGraphAsymmErrors *gr=(TGraphAsymmErrors*)obj;
// gr->SetMarkerStyle();
// gr->SetMarkerColor(0);
if(system=="pp")gr->SetMarkerSize(0.7);
else if(system=="pPb")gr->SetMarkerSize(0.9);
gr->SetLineWidth(2);
gr->Draw("E2");
TGraphAsymmErrors *gr2=(TGraphAsymmErrors*)gr->Clone("grHelp");
//gr2->SetMarkerColor(kBlack);
//gr2->SetLineColor(kBlack);
//gr2->SetMarkerSize(0.3);
//gr2->Draw("p");
}
//else obj->Draw("same");
}
}
CanvasCorrelation->Update();
}
// saving the canvases in .root and .png
TString ptoutput="", direcname="";
direcname += "Output_SngCav_Comparison";
ptoutput += "Comparison_DHCorrelations_assopT";
ptoutput += TrackpTthr.Data();
if(system == "pp") ptoutput += "_pp";
if(system == "pPb") ptoutput += "_pPb";
SaveCanvas(CanvasCorrelation, direcname, ptoutput);
Printf("... .. .. Done !");
return;
}
//_______________________________________________________________________
void LoadFileNamesToCompare(TString TrackpT ="0.3to1.0",TString Sys = "pPb"){
Int_t skip3to5pPb=0;
if(Sys.EqualTo("pp")){
nhistos=9;
}
else if(Sys.EqualTo("pPb")){
nhistos=6;
skip3to5pPb=3;
}
filenames=new TString[nhistos];
Printf(" -------------------> Adding %s in %s coll",TrackpT.Data(),Sys.Data());
if(Sys.EqualTo("pp")){
filenames[0] = Form("%s/CanvaAndVariedHisto%sDzeroPt3to5assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
filenames[1] = Form("%s/CanvaAndVariedHisto%sDplusPt3to5assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
filenames[2] = Form("%s/CanvaAndVariedHisto%sDstarPt3to5assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
}
filenames[3-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDzeroPt5to8assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
filenames[4-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDplusPt5to8assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
filenames[5-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDstarPt5to8assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
filenames[6-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDzeroPt8to16assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
filenames[7-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDplusPt8to16assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
filenames[8-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDstarPt8to16assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
}
//_______________________________________________________________________
TCanvas * GetCanvas(Int_t i, TString canvasname = "cDraw"){
//load the histogram with
TString path = filenames[i];
//cout <<"file #" <<i<<": Reading File from path --->> " << path << endl;
TFile * file = TFile::Open(path.Data(),"READ");
TCanvas * c = (TCanvas*)file->Get(canvasname.Data());
return c;
}
//_______________________________________________________________________
void SaveCanvas(TCanvas * c, TString directory, TString name){
TString outputDir = "";//Plots/15_May/";
if(directory != ""){outputDir += directory;
TString exec = "mkdir -p ";
exec += outputDir;
cout << exec << endl;
gSystem->Exec(exec.Data());
}
TString plotsout = "";//"Canvas_pT_05_";
plotsout += name;
c->SaveAs(Form("%s/%s.root",outputDir.Data(),plotsout.Data()));
c->SaveAs(Form("%s/%s.png",outputDir.Data(),plotsout.Data()));
c->SaveAs(Form("%s/%s.eps",outputDir.Data(),plotsout.Data()));
}
|
f0660c1f1cec299cf07ebaa3cf84dc4f48fb4846
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/u-boot_new/arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c
|
717e7badbedc9db5d401a1360f7d1a5df3917bec
|
[
"GPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 11,760
|
c
|
40x_spd_sdram.c
|
/*
* arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c
* This SPD SDRAM detection code supports IBM/AMCC PPC44x cpu with a
* SDRAM controller. Those are all current 405 PPC's.
*
* (C) Copyright 2001
* Bill Hunter, Wave 7 Optics, williamhunter@attbi.com
*
* Based on code by:
*
* Kenneth Johansson ,Ericsson AB.
* kenneth.johansson@etx.ericsson.se
*
* hacked up by bill hunter. fixed so we could run before
* serial_init and console_init. previous version avoided this by
* running out of cache memory during serial/console init, then running
* this code later.
*
* (C) Copyright 2002
* Jun Gu, Artesyn Technology, jung@artesyncp.com
* Support for AMCC 440 based on OpenBIOS draminit.c from IBM.
*
* (C) Copyright 2005
* Stefan Roese, DENX Software Engineering, sr@denx.de.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <asm/processor.h>
#include <i2c.h>
#include <asm/ppc4xx.h>
#if defined(CONFIG_SPD_EEPROM) && !defined(CONFIG_440)
/*
* Set default values
*/
#define ONE_BILLION 1000000000
#define SDRAM0_CFG_DCE 0x80000000
#define SDRAM0_CFG_SRE 0x40000000
#define SDRAM0_CFG_PME 0x20000000
#define SDRAM0_CFG_MEMCHK 0x10000000
#define SDRAM0_CFG_REGEN 0x08000000
#define SDRAM0_CFG_ECCDD 0x00400000
#define SDRAM0_CFG_EMDULR 0x00200000
#define SDRAM0_CFG_DRW_SHIFT (31-6)
#define SDRAM0_CFG_BRPF_SHIFT (31-8)
#define SDRAM0_TR_CASL_SHIFT (31-8)
#define SDRAM0_TR_PTA_SHIFT (31-13)
#define SDRAM0_TR_CTP_SHIFT (31-15)
#define SDRAM0_TR_LDF_SHIFT (31-17)
#define SDRAM0_TR_RFTA_SHIFT (31-29)
#define SDRAM0_TR_RCD_SHIFT (31-31)
#define SDRAM0_RTR_SHIFT (31-15)
#define SDRAM0_ECCCFG_SHIFT (31-11)
/* SDRAM0_CFG enable macro */
#define SDRAM0_CFG_BRPF(x) ( ( x & 0x3)<< SDRAM0_CFG_BRPF_SHIFT )
#define SDRAM0_BXCR_SZ_MASK 0x000e0000
#define SDRAM0_BXCR_AM_MASK 0x0000e000
#define SDRAM0_BXCR_SZ_SHIFT (31-14)
#define SDRAM0_BXCR_AM_SHIFT (31-18)
#define SDRAM0_BXCR_SZ(x) ( (( x << SDRAM0_BXCR_SZ_SHIFT) & SDRAM0_BXCR_SZ_MASK) )
#define SDRAM0_BXCR_AM(x) ( (( x << SDRAM0_BXCR_AM_SHIFT) & SDRAM0_BXCR_AM_MASK) )
#ifdef CONFIG_SPDDRAM_SILENT
# define SPD_ERR(x) do { return 0; } while (0)
#else
# define SPD_ERR(x) do { printf(x); return(0); } while (0)
#endif
#define sdram_HZ_to_ns(hertz) (1000000000/(hertz))
/* function prototypes */
int spd_read(uint addr);
/*
* This function is reading data from the DIMM module EEPROM over the SPD bus
* and uses that to program the sdram controller.
*
* This works on boards that has the same schematics that the AMCC walnut has.
*
* Input: null for default I2C spd functions or a pointer to a custom function
* returning spd_data.
*/
long int spd_sdram(int(read_spd)(uint addr))
{
int tmp,row,col;
int total_size,bank_size,bank_code;
int mode;
int bank_cnt;
int sdram0_pmit=0x07c00000;
int sdram0_b0cr;
int sdram0_b1cr = 0;
#ifndef CONFIG_405EP /* not on PPC405EP */
int sdram0_b2cr = 0;
int sdram0_b3cr = 0;
int sdram0_besr0 = -1;
int sdram0_besr1 = -1;
int sdram0_eccesr = -1;
int sdram0_ecccfg;
int ecc_on;
#endif
int sdram0_rtr=0;
int sdram0_tr=0;
int sdram0_cfg=0;
int t_rp;
int t_rcd;
int t_ras;
int t_rc;
int min_cas;
PPC4xx_SYS_INFO sys_info;
unsigned long bus_period_x_10;
/*
* get the board info
*/
get_sys_info(&sys_info);
bus_period_x_10 = ONE_BILLION / (sys_info.freqPLB / 10);
if (read_spd == 0){
read_spd=spd_read;
/*
* Make sure I2C controller is initialized
* before continuing.
*/
i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
}
/* Make shure we are using SDRAM */
if (read_spd(2) != 0x04) {
SPD_ERR("SDRAM - non SDRAM memory module found\n");
}
/* ------------------------------------------------------------------
* configure memory timing register
*
* data from DIMM:
* 27 IN Row Precharge Time ( t RP)
* 29 MIN RAS to CAS Delay ( t RCD)
* 127 Component and Clock Detail ,clk0-clk3, junction temp, CAS
* -------------------------------------------------------------------*/
/*
* first figure out which cas latency mode to use
* use the min supported mode
*/
tmp = read_spd(127) & 0x6;
if (tmp == 0x02) { /* only cas = 2 supported */
min_cas = 2;
/* t_ck = read_spd(9); */
/* t_ac = read_spd(10); */
} else if (tmp == 0x04) { /* only cas = 3 supported */
min_cas = 3;
/* t_ck = read_spd(9); */
/* t_ac = read_spd(10); */
} else if (tmp == 0x06) { /* 2,3 supported, so use 2 */
min_cas = 2;
/* t_ck = read_spd(23); */
/* t_ac = read_spd(24); */
} else {
SPD_ERR("SDRAM - unsupported CAS latency \n");
}
/* get some timing values, t_rp,t_rcd,t_ras,t_rc
*/
t_rp = read_spd(27);
t_rcd = read_spd(29);
t_ras = read_spd(30);
t_rc = t_ras + t_rp;
/* The following timing calcs subtract 1 before deviding.
* this has effect of using ceiling instead of floor rounding,
* and also subtracting 1 to convert number to reg value
*/
/* set up CASL */
sdram0_tr = (min_cas - 1) << SDRAM0_TR_CASL_SHIFT;
/* set up PTA */
sdram0_tr |= ((((t_rp - 1) * 10)/bus_period_x_10) & 0x3) << SDRAM0_TR_PTA_SHIFT;
/* set up CTP */
tmp = (((t_rc - t_rcd - t_rp -1) * 10) / bus_period_x_10) & 0x3;
if (tmp < 1)
tmp = 1;
sdram0_tr |= tmp << SDRAM0_TR_CTP_SHIFT;
/* set LDF = 2 cycles, reg value = 1 */
sdram0_tr |= 1 << SDRAM0_TR_LDF_SHIFT;
/* set RFTA = t_rfc/bus_period, use t_rfc = t_rc */
tmp = (((t_rc - 1) * 10) / bus_period_x_10) - 3;
if (tmp < 0)
tmp = 0;
if (tmp > 6)
tmp = 6;
sdram0_tr |= tmp << SDRAM0_TR_RFTA_SHIFT;
/* set RCD = t_rcd/bus_period*/
sdram0_tr |= ((((t_rcd - 1) * 10) / bus_period_x_10) &0x3) << SDRAM0_TR_RCD_SHIFT ;
/*------------------------------------------------------------------
* configure RTR register
* -------------------------------------------------------------------*/
row = read_spd(3);
col = read_spd(4);
tmp = read_spd(12) & 0x7f ; /* refresh type less self refresh bit */
switch (tmp) {
case 0x00:
tmp = 15625;
break;
case 0x01:
tmp = 15625 / 4;
break;
case 0x02:
tmp = 15625 / 2;
break;
case 0x03:
tmp = 15625 * 2;
break;
case 0x04:
tmp = 15625 * 4;
break;
case 0x05:
tmp = 15625 * 8;
break;
default:
SPD_ERR("SDRAM - Bad refresh period \n");
}
/* convert from nsec to bus cycles */
tmp = (tmp * 10) / bus_period_x_10;
sdram0_rtr = (tmp & 0x3ff8) << SDRAM0_RTR_SHIFT;
/*------------------------------------------------------------------
* determine the number of banks used
* -------------------------------------------------------------------*/
/* byte 7:6 is module data width */
if (read_spd(7) != 0)
SPD_ERR("SDRAM - unsupported module width\n");
tmp = read_spd(6);
if (tmp < 32)
SPD_ERR("SDRAM - unsupported module width\n");
else if (tmp < 64)
bank_cnt = 1; /* one bank per sdram side */
else if (tmp < 73)
bank_cnt = 2; /* need two banks per side */
else if (tmp < 161)
bank_cnt = 4; /* need four banks per side */
else
SPD_ERR("SDRAM - unsupported module width\n");
/* byte 5 is the module row count (refered to as dimm "sides") */
tmp = read_spd(5);
if (tmp == 1)
;
else if (tmp==2)
bank_cnt *= 2;
else if (tmp==4)
bank_cnt *= 4;
else
bank_cnt = 8; /* 8 is an error code */
if (bank_cnt > 4) /* we only have 4 banks to work with */
SPD_ERR("SDRAM - unsupported module rows for this width\n");
#ifndef CONFIG_405EP /* not on PPC405EP */
/* now check for ECC ability of module. We only support ECC
* on 32 bit wide devices with 8 bit ECC.
*/
if ((read_spd(11)==2) && (read_spd(6)==40) && (read_spd(14)==8)) {
sdram0_ecccfg = 0xf << SDRAM0_ECCCFG_SHIFT;
ecc_on = 1;
} else {
sdram0_ecccfg = 0;
ecc_on = 0;
}
#endif
/*------------------------------------------------------------------
* calculate total size
* -------------------------------------------------------------------*/
/* calculate total size and do sanity check */
tmp = read_spd(31);
total_size = 1 << 22; /* total_size = 4MB */
/* now multiply 4M by the smallest device row density */
/* note that we don't support asymetric rows */
while (((tmp & 0x0001) == 0) && (tmp != 0)) {
total_size = total_size << 1;
tmp = tmp >> 1;
}
total_size *= read_spd(5); /* mult by module rows (dimm sides) */
/*------------------------------------------------------------------
* map rows * cols * banks to a mode
* -------------------------------------------------------------------*/
switch (row) {
case 11:
switch (col) {
case 8:
mode=4; /* mode 5 */
break;
case 9:
case 10:
mode=0; /* mode 1 */
break;
default:
SPD_ERR("SDRAM - unsupported mode\n");
}
break;
case 12:
switch (col) {
case 8:
mode=3; /* mode 4 */
break;
case 9:
case 10:
mode=1; /* mode 2 */
break;
default:
SPD_ERR("SDRAM - unsupported mode\n");
}
break;
case 13:
switch (col) {
case 8:
mode=5; /* mode 6 */
break;
case 9:
case 10:
if (read_spd(17) == 2)
mode = 6; /* mode 7 */
else
mode = 2; /* mode 3 */
break;
case 11:
mode = 2; /* mode 3 */
break;
default:
SPD_ERR("SDRAM - unsupported mode\n");
}
break;
default:
SPD_ERR("SDRAM - unsupported mode\n");
}
/*------------------------------------------------------------------
* using the calculated values, compute the bank
* config register values.
* -------------------------------------------------------------------*/
/* compute the size of each bank */
bank_size = total_size / bank_cnt;
/* convert bank size to bank size code for ppc4xx
by takeing log2(bank_size) - 22 */
tmp = bank_size; /* start with tmp = bank_size */
bank_code = 0; /* and bank_code = 0 */
while (tmp > 1) { /* this takes log2 of tmp */
bank_code++; /* and stores result in bank_code */
tmp = tmp >> 1;
} /* bank_code is now log2(bank_size) */
bank_code -= 22; /* subtract 22 to get the code */
tmp = SDRAM0_BXCR_SZ(bank_code) | SDRAM0_BXCR_AM(mode) | 1;
sdram0_b0cr = (bank_size * 0) | tmp;
#ifndef CONFIG_405EP /* not on PPC405EP */
if (bank_cnt > 1)
sdram0_b2cr = (bank_size * 1) | tmp;
if (bank_cnt > 2)
sdram0_b1cr = (bank_size * 2) | tmp;
if (bank_cnt > 3)
sdram0_b3cr = (bank_size * 3) | tmp;
#else
/* PPC405EP chip only supports two SDRAM banks */
if (bank_cnt > 1)
sdram0_b1cr = (bank_size * 1) | tmp;
if (bank_cnt > 2)
total_size = 2 * bank_size;
#endif
/*
* enable sdram controller DCE=1
* enable burst read prefetch to 32 bytes BRPF=2
* leave other functions off
*/
/*------------------------------------------------------------------
* now that we've done our calculations, we are ready to
* program all the registers.
* -------------------------------------------------------------------*/
/* disable memcontroller so updates work */
mtsdram(SDRAM0_CFG, 0);
#ifndef CONFIG_405EP /* not on PPC405EP */
mtsdram(SDRAM0_BESR0, sdram0_besr0);
mtsdram(SDRAM0_BESR1, sdram0_besr1);
mtsdram(SDRAM0_ECCCFG, sdram0_ecccfg);
mtsdram(SDRAM0_ECCESR, sdram0_eccesr);
#endif
mtsdram(SDRAM0_RTR, sdram0_rtr);
mtsdram(SDRAM0_PMIT, sdram0_pmit);
mtsdram(SDRAM0_B0CR, sdram0_b0cr);
mtsdram(SDRAM0_B1CR, sdram0_b1cr);
#ifndef CONFIG_405EP /* not on PPC405EP */
mtsdram(SDRAM0_B2CR, sdram0_b2cr);
mtsdram(SDRAM0_B3CR, sdram0_b3cr);
#endif
mtsdram(SDRAM0_TR, sdram0_tr);
/* SDRAM have a power on delay, 500 micro should do */
udelay(500);
sdram0_cfg = SDRAM0_CFG_DCE | SDRAM0_CFG_BRPF(1) | SDRAM0_CFG_ECCDD | SDRAM0_CFG_EMDULR;
#ifndef CONFIG_405EP /* not on PPC405EP */
if (ecc_on)
sdram0_cfg |= SDRAM0_CFG_MEMCHK;
#endif
mtsdram(SDRAM0_CFG, sdram0_cfg);
return (total_size);
}
int spd_read(uint addr)
{
uchar data[2];
if (i2c_read(SPD_EEPROM_ADDRESS, addr, 1, data, 1) == 0)
return (int)data[0];
else
return 0;
}
#endif /* CONFIG_SPD_EEPROM */
|
184573ec88a312f37316c6c40454bf83fb0031b5
|
f8cc1dd4b1378490386def2e0571561fab10b275
|
/src/include/skalibs/disize.h
|
eef82f3b3da661d5cf1f7efea61c0319f51ad9a3
|
[
"ISC"
] |
permissive
|
skarnet/skalibs
|
b1eb2a0e38663cbfa918ee0a7916f56227bd7c2d
|
1f2d5f95684e93f8523e369ef1fed7a75c444082
|
refs/heads/master
| 2023-08-23T07:33:20.996016
| 2023-08-08T09:39:15
| 2023-08-08T09:39:15
| 31,461,366
| 104
| 32
|
ISC
| 2021-04-11T10:10:54
| 2015-02-28T12:01:41
|
C
|
UTF-8
|
C
| false
| false
| 248
|
h
|
disize.h
|
/* ISC license. */
#ifndef SKALIBS_DISIZE_H
#define SKALIBS_DISIZE_H
#include <stddef.h>
typedef struct disize_s disize, *disize_ref ;
struct disize_s
{
size_t left ;
size_t right ;
} ;
#define DISIZE_ZERO { .left = 0, .right = 0 }
#endif
|
ae9732851f996471d6059abcdb9e973323c4580c
|
3a2071c34e3c35847b2bcc2a5d3b3a74114daa0f
|
/subversion/mod_dav_svn/util.c
|
00afb517197981ade1ff400028fcdd368ed7d341
|
[
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-other-permissive",
"X11",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"HPND-Markus-Kuhn",
"LicenseRef-scancode-unicode",
"Apache-2.0",
"FSFAP"
] |
permissive
|
apache/subversion
|
18a9142afe63f060ffc0814fe0c758c91ad8bd31
|
dd957c4991e61bde23cc60d13449ea8b65f80c43
|
refs/heads/trunk
| 2023-09-04T15:22:36.755177
| 2023-08-29T19:55:03
| 2023-08-29T19:55:03
| 454,263
| 520
| 207
|
Apache-2.0
| 2023-08-26T14:17:30
| 2009-12-31T09:00:10
|
C
|
UTF-8
|
C
| false
| false
| 30,022
|
c
|
util.c
|
/*
* util.c:
* # ****************************************************************************
* # TRASHY LITTLE SUBROUTINES
* # ****************************************************************************
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
#include <apr_xml.h>
#include <apr_errno.h>
#include <apr_uri.h>
#include <apr_buckets.h>
#include <mod_dav.h>
#include <http_protocol.h>
#include <http_core.h>
#include "svn_error.h"
#include "svn_fs.h"
#include "svn_dav.h"
#include "svn_base64.h"
#include "svn_ctype.h"
#include "dav_svn.h"
#include "private/svn_fspath.h"
#include "private/svn_string_private.h"
dav_error *
dav_svn__new_error(apr_pool_t *pool,
int status,
int error_id,
apr_status_t aprerr,
const char *desc)
{
if (error_id == 0)
error_id = SVN_ERR_RA_DAV_REQUEST_FAILED;
/*
* Note: dav_new_error() in httpd 2.0/2.2 always treated
* the errno field in dav_error as an apr_status_t when
* logging; on some platforms errno and apr_status_t
* aren't directly interchangeable. The code for httpd
* > 2.2 below perpetuates this.
*/
#if AP_MODULE_MAGIC_AT_LEAST(20091119,0)
return dav_new_error(pool, status, error_id, aprerr, desc);
#else
errno = aprerr; /* For the same reason as in dav_svn__new_error_svn */
return dav_new_error(pool, status, error_id, desc);
#endif
}
dav_error *
dav_svn__new_error_svn(apr_pool_t *pool,
int status,
int error_id,
apr_status_t aprerr,
const char *desc)
{
if (error_id == 0)
error_id = SVN_ERR_RA_DAV_REQUEST_FAILED;
#if AP_MODULE_MAGIC_AT_LEAST(20091119,0)
return dav_new_error_tag(pool, status, error_id, aprerr,
desc, SVN_DAV_ERROR_NAMESPACE, SVN_DAV_ERROR_TAG);
#else
/* dav_new_error_tag will record errno so we use it to pass aprerr.
This overrwites any existing errno value but since Subversion
makes no attempt to avoid system calls after a failed system call
there is no guarantee that any existing errno represents a
relevant error. */
errno = aprerr;
return dav_new_error_tag(pool, status, error_id, desc,
SVN_DAV_ERROR_NAMESPACE, SVN_DAV_ERROR_TAG);
#endif
}
/* Build up a chain of DAV errors that correspond to the underlying SVN
errors that caused this problem. */
static dav_error *
build_error_chain(apr_pool_t *pool, svn_error_t *err, int status)
{
char buffer[128];
const char *msg = svn_err_best_message(err, buffer, sizeof(buffer));
dav_error *derr = dav_svn__new_error_svn(pool, status, err->apr_err, 0,
apr_pstrdup(pool, msg));
if (err->child)
derr->prev = build_error_chain(pool, err->child, status);
return derr;
}
dav_error *
dav_svn__convert_err(svn_error_t *serr,
int status,
const char *message,
apr_pool_t *pool)
{
dav_error *derr;
/* Remove the trace-only error chain links. We need predictable
protocol behavior regardless of whether or not we're in a
debugging build. */
svn_error_t *purged_serr = svn_error_purge_tracing(serr);
/* ### someday mod_dav_svn will send back 'rich' error tags, much
finer grained than plain old svn_error_t's. But for now, all
svn_error_t's are marshalled to the client via the single
generic <svn:error/> tag nestled within a <D:error> block. */
/* Examine the Subverion error code, and select the most
appropriate HTTP status code. If no more appropriate HTTP
status code maps to the Subversion error code, use the one
suggested status provided by the caller. */
switch (purged_serr->apr_err)
{
case SVN_ERR_FS_NOT_FOUND:
case SVN_ERR_FS_NO_SUCH_REVISION:
status = HTTP_NOT_FOUND;
break;
case SVN_ERR_UNSUPPORTED_FEATURE:
status = HTTP_NOT_IMPLEMENTED;
break;
case SVN_ERR_FS_LOCK_OWNER_MISMATCH:
case SVN_ERR_FS_PATH_ALREADY_LOCKED:
status = HTTP_LOCKED;
break;
case SVN_ERR_FS_PROP_BASEVALUE_MISMATCH:
status = HTTP_PRECONDITION_FAILED;
break;
/* add other mappings here */
}
derr = build_error_chain(pool, purged_serr, status);
if (message != NULL
&& !svn_error_find_cause(purged_serr, SVN_ERR_REPOS_HOOK_FAILURE))
/* Don't hide hook failures; we might hide the error text */
derr = dav_push_error(pool, status, purged_serr->apr_err,
message, derr);
/* Now, destroy the Subversion error. */
svn_error_clear(serr);
return derr;
}
/* Set *REVISION to the youngest revision in which an interesting
history item (a modification, or a copy) occurred for PATH under
ROOT. Use POOL for scratchwork. */
static svn_error_t *
get_last_history_rev(svn_revnum_t *revision,
svn_fs_root_t *root,
const char *path,
apr_pool_t *pool)
{
svn_fs_history_t *history;
const char *ignored;
/* Get an initial HISTORY baton. */
SVN_ERR(svn_fs_node_history2(&history, root, path, pool, pool));
/* Now get the first *real* point of interesting history. */
SVN_ERR(svn_fs_history_prev2(&history, history, FALSE, pool, pool));
/* Fetch the location information for this history step. */
return svn_fs_history_location(&ignored, revision, history, pool);
}
svn_revnum_t
dav_svn__get_safe_cr(svn_fs_root_t *root, const char *path, apr_pool_t *pool)
{
svn_revnum_t revision = svn_fs_revision_root_revision(root);
svn_revnum_t history_rev;
svn_fs_root_t *other_root;
svn_fs_t *fs = svn_fs_root_fs(root);
svn_fs_node_relation_t node_relation;
svn_error_t *err;
if ((err = get_last_history_rev(&history_rev, root, path, pool)))
{
svn_error_clear(err);
return revision; /* couldn't find last history rev */
}
if ((err = svn_fs_revision_root(&other_root, fs, history_rev, pool)))
{
svn_error_clear(err);
return revision; /* couldn't open the history rev */
}
if ((err = svn_fs_node_relation(&node_relation, root, path,
other_root, path, pool)))
{
svn_error_clear(err);
return revision;
}
if (node_relation == svn_fs_node_unchanged)
return history_rev; /* the history rev is safe! the same node
exists at the same path in both revisions. */
/* default */
return revision;
}
const char *
dav_svn__build_uri(const dav_svn_repos *repos,
enum dav_svn__build_what what,
svn_revnum_t revision,
const char *path,
svn_boolean_t add_href,
apr_pool_t *pool)
{
const char *root_path = repos->root_path;
const char *special_uri = repos->special_uri;
const char *path_uri = path ? svn_path_uri_encode(path, pool) : NULL;
const char *href1 = add_href ? "<D:href>" : "";
const char *href2 = add_href ? "</D:href>" : "";
/* The first character of root_path is guaranteed to be "/". If
there's no component beyond that, then just use "", so that
appending another "/" later does not result in "//". */
if (root_path[1] == '\0')
root_path = "";
switch (what)
{
case DAV_SVN__BUILD_URI_ACT_COLLECTION:
return apr_psprintf(pool, "%s%s/%s/act/%s",
href1, root_path, special_uri, href2);
case DAV_SVN__BUILD_URI_BASELINE:
return apr_psprintf(pool, "%s%s/%s/bln/%ld%s",
href1, root_path, special_uri, revision, href2);
case DAV_SVN__BUILD_URI_BC:
return apr_psprintf(pool, "%s%s/%s/bc/%ld/%s",
href1, root_path, special_uri, revision, href2);
case DAV_SVN__BUILD_URI_PUBLIC:
return apr_psprintf(pool, "%s%s%s%s",
href1, root_path, path_uri, href2);
case DAV_SVN__BUILD_URI_VERSION:
return apr_psprintf(pool, "%s%s/%s/ver/%ld%s%s",
href1, root_path, special_uri,
revision, path_uri, href2);
case DAV_SVN__BUILD_URI_REVROOT:
return apr_psprintf(pool, "%s%s/%s/rvr/%ld%s%s",
href1, root_path, special_uri,
revision, path_uri, href2);
case DAV_SVN__BUILD_URI_VCC:
return apr_psprintf(pool, "%s%s/%s/vcc/" DAV_SVN__DEFAULT_VCC_NAME "%s",
href1, root_path, special_uri, href2);
default:
/* programmer error somewhere */
SVN_ERR_MALFUNCTION_NO_RETURN();
}
/* NOTREACHED */
}
svn_error_t *
dav_svn__simple_parse_uri(dav_svn__uri_info *info,
const dav_resource *relative,
const char *uri,
apr_pool_t *pool)
{
apr_uri_t comp;
const char *path;
apr_size_t len1;
apr_size_t len2;
const char *slash;
const char *created_rev_str;
/* parse the input URI, in case it is more than just a path */
if (apr_uri_parse(pool, uri, &comp) != APR_SUCCESS)
goto malformed_uri;
/* ### ignore all URI parts but the path (for now) */
/* clean up the URI */
if (comp.path == NULL)
path = "/";
else
{
ap_getparents(comp.path);
ap_no2slash(comp.path);
path = comp.path;
}
/*
* Does the URI path specify the same repository? It does not if one of:
*
* 1) input is shorter than the path to our repository
* 2) input is longer, but there is no separator
* [ http://host/repos vs http://host/repository ]
* 3) the two paths do not match
*/
len1 = strlen(path);
len2 = strlen(relative->info->repos->root_path);
if (len2 == 1 && relative->info->repos->root_path[0] == '/')
len2 = 0;
if (len1 < len2
|| (len1 > len2 && path[len2] != '/')
|| memcmp(path, relative->info->repos->root_path, len2) != 0)
{
return svn_error_create(SVN_ERR_APMOD_MALFORMED_URI, NULL,
"Unusable URI: it does not refer to this "
"repository");
}
/* prep the return value */
memset(info, 0, sizeof(*info));
info->rev = SVN_INVALID_REVNUM;
path += len2; /* now points to "/" or "\0" */
len1 -= len2;
if (len1 <= 1)
{
info->repos_path = "/";
return NULL;
}
/* skip over the leading "/" */
++path;
--len1;
/* is this a special URI? */
len2 = strlen(relative->info->repos->special_uri);
if (len1 < len2
|| (len1 > len2 && path[len2] != '/')
|| memcmp(path, relative->info->repos->special_uri, len2) != 0)
{
/* this is an ordinary "public" URI, so back up to include the
leading '/' and just return... no need to parse further. */
info->repos_path = svn_path_uri_decode(path - 1, pool);
return NULL;
}
path += len2; /* now points to "/" or "\0" just past the special URI */
len1 -= len2;
/* ### we don't handle the root of the special area yet */
if (len1 <= 1)
goto unhandled_form;
/* Find the next component, and ensure something is there. */
slash = ap_strchr_c(path + 1, '/');
if (slash == NULL || slash[1] == '\0')
goto unhandled_form;
len2 = slash - path;
/* Figure out what we have here */
if (len2 == 4 && memcmp(path, "/act/", 5) == 0)
{
/* an activity */
info->activity_id = path + 5;
}
else if (len2 == 4 &&
(memcmp(path, "/ver/", 5) == 0 || memcmp(path, "/rvr/", 5) == 0))
{
/* a version resource */
path += 5;
len1 -= 5;
slash = ap_strchr_c(path, '/');
if (slash == NULL)
{
created_rev_str = apr_pstrndup(pool, path, len1);
info->rev = SVN_STR_TO_REV(created_rev_str);
info->repos_path = "/";
}
else
{
created_rev_str = apr_pstrndup(pool, path, slash - path);
info->rev = SVN_STR_TO_REV(created_rev_str);
info->repos_path = svn_path_uri_decode(slash, pool);
}
if (info->rev == SVN_INVALID_REVNUM)
goto malformed_uri;
}
else
goto unhandled_form;
return NULL;
malformed_uri:
return svn_error_create(SVN_ERR_APMOD_MALFORMED_URI, NULL,
"The specified URI could not be parsed");
unhandled_form:
return svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
"Unsupported URI form");
}
svn_boolean_t
dav_svn__is_parentpath_list(request_rec *r)
{
const char *fs_parent_path = dav_svn__get_fs_parent_path(r);
if (fs_parent_path && dav_svn__get_list_parentpath_flag(r))
{
const char *root_path = dav_svn__get_root_dir(r);
char *uri = apr_pstrdup(r->pool, r->uri);
char *parentpath = apr_pstrdup(r->pool, root_path);
apr_size_t uri_len = strlen(uri);
apr_size_t parentpath_len = strlen(parentpath);
if (uri[uri_len-1] == '/')
uri[uri_len-1] = '\0';
if (parentpath[parentpath_len-1] == '/')
parentpath[parentpath_len-1] = '\0';
if (strcmp(parentpath, uri) == 0)
{
return TRUE;
}
}
return FALSE;
}
/* ### move this into apr_xml */
int
dav_svn__find_ns(const apr_array_header_t *namespaces, const char *uri)
{
int i;
for (i = 0; i < namespaces->nelts; ++i)
if (strcmp(APR_XML_GET_URI_ITEM(namespaces, i), uri) == 0)
return i;
return -1;
}
/*** Output helpers ***/
struct dav_svn__output
{
request_rec *r;
};
dav_svn__output *
dav_svn__output_create(request_rec *r,
apr_pool_t *pool)
{
dav_svn__output *output = apr_pcalloc(pool, sizeof(*output));
output->r = r;
return output;
}
apr_bucket_alloc_t *
dav_svn__output_get_bucket_alloc(dav_svn__output *output)
{
return output->r->connection->bucket_alloc;
}
svn_error_t *
dav_svn__output_pass_brigade(dav_svn__output *output,
apr_bucket_brigade *bb)
{
apr_status_t status;
status = ap_pass_brigade(output->r->output_filters, bb);
/* Empty the brigade here, as required by ap_pass_brigade(). */
apr_brigade_cleanup(bb);
if (status)
return svn_error_create(status, NULL, "Could not write data to filter");
/* Check for an aborted connection, since the brigade functions don't
appear to return useful errors when the connection is dropped. */
if (output->r->connection->aborted)
return svn_error_create(SVN_ERR_APMOD_CONNECTION_ABORTED, NULL, NULL);
return SVN_NO_ERROR;
}
/*** Brigade I/O wrappers ***/
svn_error_t *
dav_svn__brigade_write(apr_bucket_brigade *bb,
dav_svn__output *output,
const char *data,
apr_size_t len)
{
apr_status_t apr_err;
apr_err = apr_brigade_write(bb, ap_filter_flush,
output->r->output_filters, data, len);
if (apr_err)
return svn_error_create(apr_err, 0, NULL);
/* Check for an aborted connection, since the brigade functions don't
appear to return useful errors when the connection is dropped. */
if (output->r->connection->aborted)
return svn_error_create(SVN_ERR_APMOD_CONNECTION_ABORTED, 0, NULL);
return SVN_NO_ERROR;
}
svn_error_t *
dav_svn__brigade_puts(apr_bucket_brigade *bb,
dav_svn__output *output,
const char *str)
{
apr_status_t apr_err;
apr_err = apr_brigade_puts(bb, ap_filter_flush,
output->r->output_filters, str);
if (apr_err)
return svn_error_create(apr_err, 0, NULL);
/* Check for an aborted connection, since the brigade functions don't
appear to return useful errors when the connection is dropped. */
if (output->r->connection->aborted)
return svn_error_create(SVN_ERR_APMOD_CONNECTION_ABORTED, 0, NULL);
return SVN_NO_ERROR;
}
svn_error_t *
dav_svn__brigade_printf(apr_bucket_brigade *bb,
dav_svn__output *output,
const char *fmt,
...)
{
apr_status_t apr_err;
va_list ap;
va_start(ap, fmt);
apr_err = apr_brigade_vprintf(bb, ap_filter_flush,
output->r->output_filters, fmt, ap);
va_end(ap);
if (apr_err)
return svn_error_create(apr_err, 0, NULL);
/* Check for an aborted connection, since the brigade functions don't
appear to return useful errors when the connection is dropped. */
if (output->r->connection->aborted)
return svn_error_create(SVN_ERR_APMOD_CONNECTION_ABORTED, 0, NULL);
return SVN_NO_ERROR;
}
svn_error_t *
dav_svn__brigade_putstrs(apr_bucket_brigade *bb,
dav_svn__output *output,
...)
{
apr_status_t apr_err;
va_list ap;
va_start(ap, output);
apr_err = apr_brigade_vputstrs(bb, ap_filter_flush,
output->r->output_filters, ap);
va_end(ap);
if (apr_err)
return svn_error_create(apr_err, NULL, NULL);
/* Check for an aborted connection, since the brigade functions don't
appear to return useful errors when the connection is dropped. */
if (output->r->connection->aborted)
return svn_error_create(SVN_ERR_APMOD_CONNECTION_ABORTED, NULL, NULL);
return SVN_NO_ERROR;
}
dav_error *
dav_svn__test_canonical(const char *path, apr_pool_t *pool)
{
if (path[0] == '\0')
return NULL;
if (svn_path_is_url(path) && svn_uri_is_canonical(path, pool))
return NULL;
if ((path[0] == '/') && svn_fspath__is_canonical(path))
return NULL;
if (svn_relpath_is_canonical(path))
return NULL;
/* Otherwise, generate a generic HTTP_BAD_REQUEST error. */
return dav_svn__new_error_svn(
pool, HTTP_BAD_REQUEST, 0, 0,
apr_psprintf(pool,
"Path '%s' is not canonicalized; "
"there is a problem with the client.", path));
}
dav_error *
dav_svn__sanitize_error(svn_error_t *serr,
const char *new_msg,
int http_status,
request_rec *r)
{
svn_error_t *safe_err = serr;
if (new_msg != NULL)
{
/* Purge error tracing from the error chain. */
svn_error_t *purged_serr = svn_error_purge_tracing(serr);
/* Sanitization is necessary. Create a new, safe error and
log the original error. */
safe_err = svn_error_create(purged_serr->apr_err, NULL, new_msg);
ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r,
"%s", purged_serr->message);
/* Log the entire error chain. */
while (purged_serr->child)
{
purged_serr = purged_serr->child;
ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r,
"%s", purged_serr->message);
}
svn_error_clear(serr);
}
return dav_svn__convert_err(safe_err, http_status,
apr_psprintf(r->pool, "%s", safe_err->message),
r->pool);
}
struct brigade_write_baton
{
apr_bucket_brigade *bb;
dav_svn__output *output;
};
/* This implements 'svn_write_fn_t'. */
static svn_error_t *
brigade_write_fn(void *baton, const char *data, apr_size_t *len)
{
struct brigade_write_baton *wb = baton;
apr_status_t apr_err;
apr_err = apr_brigade_write(wb->bb, ap_filter_flush,
wb->output->r->output_filters, data, *len);
if (apr_err != APR_SUCCESS)
return svn_error_wrap_apr(apr_err, "Error writing base64 data");
return SVN_NO_ERROR;
}
svn_stream_t *
dav_svn__make_base64_output_stream(apr_bucket_brigade *bb,
dav_svn__output *output,
apr_pool_t *pool)
{
struct brigade_write_baton *wb = apr_palloc(pool, sizeof(*wb));
svn_stream_t *stream = svn_stream_create(wb, pool);
wb->bb = bb;
wb->output = output;
svn_stream_set_write(stream, brigade_write_fn);
return svn_base64_encode2(stream, FALSE, pool);
}
void
dav_svn__operational_log(struct dav_resource_private *info, const char *line)
{
apr_table_set(info->r->subprocess_env, "SVN-ACTION", line);
apr_table_set(info->r->subprocess_env, "SVN-REPOS",
svn_path_uri_encode(info->repos->fs_path, info->r->pool));
apr_table_set(info->r->subprocess_env, "SVN-REPOS-NAME",
svn_path_uri_encode(info->repos->repo_basename, info->r->pool));
}
dav_error *
dav_svn__final_flush_or_error(request_rec *r,
apr_bucket_brigade *bb,
dav_svn__output *output,
dav_error *preferred_err,
apr_pool_t *pool)
{
dav_error *derr = preferred_err;
svn_boolean_t do_flush;
do_flush = r->sent_bodyct > 0;
if (! do_flush)
{
/* Ask about the length of the bucket brigade, ignoring errors. */
apr_off_t len = 0;
(void)apr_brigade_length(bb, FALSE, &len);
do_flush = (len != 0);
}
/* If there's something in the bucket brigade to flush, or we've
already started sending data down the wire, flush what we've
got. We only keep any error retrieved from the flush if weren't
provided a more-important DERR, though. */
if (do_flush)
{
apr_status_t apr_err = ap_fflush(output->r->output_filters, bb);
if (apr_err && (! derr))
derr = dav_svn__new_error(pool, HTTP_INTERNAL_SERVER_ERROR, 0, apr_err,
"Error flushing brigade.");
}
return derr;
}
void dav_svn__log_err(request_rec *r,
dav_error *err,
int level)
{
dav_error *errscan;
/* Log the errors */
/* ### should have a directive to log the first or all */
for (errscan = err; errscan != NULL; errscan = errscan->prev) {
apr_status_t status;
if (errscan->desc == NULL)
continue;
#if AP_MODULE_MAGIC_AT_LEAST(20091119,0)
status = errscan->aprerr;
#else
status = errscan->save_errno;
#endif
ap_log_rerror(APLOG_MARK, level, status, r,
"%s [%d, #%d]",
errscan->desc, errscan->status, errscan->error_id);
}
}
int
dav_svn__error_response_tag(request_rec *r,
dav_error *err)
{
r->status = err->status;
/* ### I really don't think this is needed; gotta test */
r->status_line = ap_get_status_line(err->status);
ap_set_content_type(r, DAV_XML_CONTENT_TYPE);
ap_rputs(DAV_XML_HEADER DEBUG_CR "<D:error xmlns:D=\"DAV:\"", r);
if (err->desc != NULL)
ap_rputs(" xmlns:m=\"http://apache.org/dav/xmlns\"", r);
if (err->namespace != NULL)
ap_rprintf(r, " xmlns:C=\"%s\">" DEBUG_CR "<C:%s/>" DEBUG_CR,
err->namespace, err->tagname);
else if (err->tagname != NULL)
ap_rprintf(r, ">" DEBUG_CR "<D:%s/>" DEBUG_CR, err->tagname);
else
ap_rputs(">" DEBUG_CR, r);
/* here's our mod_dav specific tag: */
if (err->desc != NULL)
ap_rprintf(r, "<m:human-readable errcode=\"%d\">" DEBUG_CR "%s" DEBUG_CR
"</m:human-readable>" DEBUG_CR, err->error_id,
apr_xml_quote_string(r->pool, err->desc, 0));
ap_rputs("</D:error>" DEBUG_CR, r);
/* the response has been sent. */
/*
* ### Use of DONE obviates logging..!
*/
return DONE;
}
/* Set *REQUEST_STR to a string containing the contents of the body of
request R, allocated from POOL.
NOTE: This was shamelessly stolen and modified from Apache's
ap_xml_parse_input(). */
static int
request_body_to_string(svn_string_t **request_str,
request_rec *r,
apr_pool_t *pool)
{
apr_bucket_brigade *brigade;
int seen_eos;
apr_status_t status;
apr_off_t total_read = 0;
apr_off_t limit_req_body = ap_get_limit_xml_body(r);
int result = HTTP_BAD_REQUEST;
const char *content_length_str;
char *endp;
apr_off_t content_length;
svn_stringbuf_t *buf;
*request_str = NULL;
content_length_str = apr_table_get(r->headers_in, "Content-Length");
if (content_length_str)
{
if (apr_strtoff(&content_length, content_length_str, &endp, 10)
|| endp == content_length_str || *endp || content_length < 0)
{
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Invalid Content-Length");
return HTTP_REQUEST_ENTITY_TOO_LARGE;
}
}
else
content_length = 0;
if (limit_req_body && (limit_req_body < content_length))
{
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"Requested content-length of %" APR_OFF_T_FMT " is larger "
"than the configured limit of %" APR_OFF_T_FMT,
content_length, limit_req_body);
return HTTP_REQUEST_ENTITY_TOO_LARGE;
}
if (content_length)
{
/* Do not allocate more than 1 MB until we receive request body. */
apr_size_t alloc_len = 1 * 1024 *1024;
if (content_length < alloc_len)
alloc_len = (apr_size_t) content_length;
buf = svn_stringbuf_create_ensure(alloc_len, pool);
}
else
{
buf = svn_stringbuf_create_empty(pool);
}
brigade = apr_brigade_create(r->pool, r->connection->bucket_alloc);
seen_eos = 0;
total_read = 0;
do
{
apr_bucket *bucket;
status = ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES,
APR_BLOCK_READ, 2048);
if (status != APR_SUCCESS)
goto cleanup;
for (bucket = APR_BRIGADE_FIRST(brigade);
bucket != APR_BRIGADE_SENTINEL(brigade);
bucket = APR_BUCKET_NEXT(bucket))
{
const char *data;
apr_size_t len;
if (APR_BUCKET_IS_EOS(bucket))
{
seen_eos = 1;
break;
}
if (APR_BUCKET_IS_METADATA(bucket))
continue;
status = apr_bucket_read(bucket, &data, &len, APR_BLOCK_READ);
if (status != APR_SUCCESS)
goto cleanup;
total_read += len;
if (limit_req_body && total_read > limit_req_body)
{
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"Request body is larger than the configured "
"limit of %" APR_OFF_T_FMT, limit_req_body);
result = HTTP_REQUEST_ENTITY_TOO_LARGE;
goto cleanup;
}
svn_stringbuf_appendbytes(buf, data, len);
}
apr_brigade_cleanup(brigade);
}
while (!seen_eos);
apr_brigade_destroy(brigade);
/* Make an svn_string_t from our svn_stringbuf_t. */
*request_str = svn_stringbuf__morph_into_string(buf);
return OK;
cleanup:
apr_brigade_destroy(brigade);
/* Apache will supply a default error, plus the error log above. */
return result;
}
int
dav_svn__parse_request_skel(svn_skel_t **skel,
request_rec *r,
apr_pool_t *pool)
{
svn_string_t *skel_str;
int status;
*skel = NULL;
status = request_body_to_string(&skel_str, r, pool);
if (status != OK)
return status;
*skel = svn_skel__parse(skel_str->data, skel_str->len, pool);
return OK;
}
svn_error_t *
dav_svn__get_youngest_rev(svn_revnum_t *youngest_p,
dav_svn_repos *repos,
apr_pool_t *scratch_pool)
{
if (repos->youngest_rev == SVN_INVALID_REVNUM)
{
svn_revnum_t revnum;
SVN_ERR(svn_fs_youngest_rev(&revnum, repos->fs, scratch_pool));
repos->youngest_rev = revnum;
}
*youngest_p = repos->youngest_rev;
return SVN_NO_ERROR;
}
const char *
dav_svn__fuzzy_escape_author(const char *author,
svn_boolean_t is_svn_client,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
apr_size_t len = strlen(author);
if (is_svn_client && !svn_xml_is_xml_safe(author, len))
{
/* We are talking to a Subversion client, which will (like any proper
xml parser) error out if we produce control characters in XML.
However Subversion clients process both the generic
<creator-displayname /> as the custom element for svn:author.
Let's skip outputting the invalid characters here to make the XML
valid, so clients can see the custom element.
Subversion Clients will then either use a slightly invalid
author (unlikely) or more likely use the second result, which
will be transferred with full escaping capabilities.
We have tests in place to assert proper behavior over the RA layer.
*/
apr_size_t i;
svn_stringbuf_t *buf;
buf = svn_stringbuf_ncreate(author, len, scratch_pool);
for (i = 0; i < buf->len; i++)
{
char c = buf->data[i];
if (svn_ctype_iscntrl(c))
{
svn_stringbuf_remove(buf, i--, 1);
}
}
author = buf->data;
}
return apr_xml_quote_string(result_pool, author, 1);
}
|
c450a588657f454508542ddf36d77f876b3c9ef4
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/sys/dev/pci/fms.c
|
f3238126d202c0981ac2f528ff94a00b7ea67a4a
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 17,946
|
c
|
fms.c
|
/* $OpenBSD: fms.c,v 1.36 2022/10/26 20:19:08 kn Exp $ */
/* $NetBSD: fms.c,v 1.5.4.1 2000/06/30 16:27:50 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Witold J. Wnuk.
*
* 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Forte Media FM801 Audio Device Driver
*/
#include "radio.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/audioio.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pcivar.h>
#include <dev/audio_if.h>
#include <dev/ic/ac97.h>
#if 0
#include <dev/ic/mpuvar.h>
#endif
#include <dev/pci/fmsreg.h>
#include <dev/pci/fmsvar.h>
struct fms_dma {
struct fms_dma *next;
caddr_t addr;
size_t size;
bus_dmamap_t map;
bus_dma_segment_t seg;
};
int fms_match(struct device *, void *, void *);
void fms_attach(struct device *, struct device *, void *);
int fms_intr(void *);
int fms_open(void *, int);
void fms_close(void *);
int fms_set_params(void *, int, int, struct audio_params *,
struct audio_params *);
int fms_round_blocksize(void *, int);
int fms_halt_output(void *);
int fms_halt_input(void *);
int fms_set_port(void *, mixer_ctrl_t *);
int fms_get_port(void *, mixer_ctrl_t *);
int fms_query_devinfo(void *, mixer_devinfo_t *);
void *fms_malloc(void *, int, size_t, int, int);
void fms_free(void *, void *, int);
int fms_trigger_output(void *, void *, void *, int, void (*)(void *),
void *, struct audio_params *);
int fms_trigger_input(void *, void *, void *, int, void (*)(void *),
void *, struct audio_params *);
struct cfdriver fms_cd = {
NULL, "fms", DV_DULL
};
const struct cfattach fms_ca = {
sizeof (struct fms_softc), fms_match, fms_attach
};
const struct audio_hw_if fms_hw_if = {
.open = fms_open,
.close = fms_close,
.set_params = fms_set_params,
.round_blocksize = fms_round_blocksize,
.halt_output = fms_halt_output,
.halt_input = fms_halt_input,
.set_port = fms_set_port,
.get_port = fms_get_port,
.query_devinfo = fms_query_devinfo,
.allocm = fms_malloc,
.freem = fms_free,
.trigger_output = fms_trigger_output,
.trigger_input = fms_trigger_input,
};
int fms_attach_codec(void *, struct ac97_codec_if *);
int fms_read_codec(void *, u_int8_t, u_int16_t *);
int fms_write_codec(void *, u_int8_t, u_int16_t);
void fms_reset_codec(void *);
int fms_allocmem(struct fms_softc *, size_t, size_t,
struct fms_dma *);
int fms_freemem(struct fms_softc *, struct fms_dma *);
int
fms_match(struct device *parent, void *match, void *aux)
{
struct pci_attach_args *pa = (struct pci_attach_args *) aux;
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_FORTEMEDIA &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FORTEMEDIA_FM801)
return (1);
return (0);
}
void
fms_attach(struct device *parent, struct device *self, void *aux)
{
struct pci_attach_args *pa = aux;
struct fms_softc *sc = (struct fms_softc *) self;
struct audio_attach_args aa;
pci_chipset_tag_t pc = pa->pa_pc;
pcitag_t pt = pa->pa_tag;
pci_intr_handle_t ih;
bus_size_t iosize;
const char *intrstr;
u_int16_t k1;
int i;
if (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_IO, 0, &sc->sc_iot,
&sc->sc_ioh, NULL, &iosize, 0)) {
printf(": can't map i/o space\n");
return;
}
if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, 0x30, 2,
&sc->sc_mpu_ioh)) {
printf(": can't get mpu subregion handle\n");
bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize);
return;
}
if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, 0x68, 4,
&sc->sc_opl_ioh)) {
printf(": can't get opl subregion handle\n");
bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize);
return;
}
if (pci_intr_map(pa, &ih)) {
printf(": couldn't map interrupt\n");
bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize);
return;
}
intrstr = pci_intr_string(pc, ih);
sc->sc_ih = pci_intr_establish(pc, ih, IPL_AUDIO | IPL_MPSAFE,
fms_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(": couldn't establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize);
return;
}
printf(": %s\n", intrstr);
sc->sc_dmat = pa->pa_dmat;
/* Disable legacy audio (SBPro compatibility) */
pci_conf_write(pc, pt, 0x40, 0);
/* Reset codec and AC'97 */
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_CTL, 0x0020);
delay(2); /* > 1us according to AC'97 documentation */
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_CTL, 0x0000);
delay(1); /* > 168.2ns according to AC'97 documentation */
/* Set up volume */
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_PCM_VOLUME, 0x0808);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_FM_VOLUME, 0x0808);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_I2S_VOLUME, 0x0808);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_RECORD_SOURCE, 0x0000);
/* Unmask playback, record and mpu interrupts, mask the rest */
k1 = bus_space_read_2(sc->sc_iot, sc->sc_ioh, FM_INTMASK);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_INTMASK,
(k1 & ~(FM_INTMASK_PLAY | FM_INTMASK_REC | FM_INTMASK_MPU)) |
FM_INTMASK_VOL);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_INTSTATUS,
FM_INTSTATUS_PLAY | FM_INTSTATUS_REC | FM_INTSTATUS_MPU |
FM_INTSTATUS_VOL);
#if NRADIO > 0
fmsradio_attach(sc);
#endif /* NRADIO > 0 */
sc->host_if.arg = sc;
sc->host_if.attach = fms_attach_codec;
sc->host_if.read = fms_read_codec;
sc->host_if.write = fms_write_codec;
sc->host_if.reset = fms_reset_codec;
if (ac97_attach(&sc->host_if) != 0)
return;
/* Turn mute off */
for (i = 0; i < 3; i++) {
static struct {
char *class, *device;
} d[] = {
{ AudioCoutputs, AudioNmaster },
{ AudioCinputs, AudioNdac },
{ AudioCrecord, AudioNvolume }
};
struct mixer_ctrl ctl;
ctl.type = AUDIO_MIXER_ENUM;
ctl.un.ord = 0;
ctl.dev = sc->codec_if->vtbl->get_portnum_by_name(sc->codec_if,
d[i].class, d[i].device, AudioNmute);
fms_set_port(sc, &ctl);
}
audio_attach_mi(&fms_hw_if, sc, NULL, &sc->sc_dev);
aa.type = AUDIODEV_TYPE_OPL;
aa.hwif = NULL;
aa.hdl = NULL;
config_found(&sc->sc_dev, &aa, audioprint);
aa.type = AUDIODEV_TYPE_MPU;
aa.hwif = NULL;
aa.hdl = NULL;
sc->sc_mpu_dev = config_found(&sc->sc_dev, &aa, audioprint);
}
/*
* Each AC-link frame takes 20.8us, data should be ready in next frame,
* we allow more than two.
*/
#define TIMO 50
int
fms_read_codec(void *addr, u_int8_t reg, u_int16_t *val)
{
struct fms_softc *sc = addr;
int i;
/* Poll until codec is ready */
for (i = 0; i < TIMO && bus_space_read_2(sc->sc_iot, sc->sc_ioh,
FM_CODEC_CMD) & FM_CODEC_CMD_BUSY; i++)
delay(1);
if (i >= TIMO) {
printf("fms: codec busy\n");
return 1;
}
/* Write register index, read access */
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_CMD,
reg | FM_CODEC_CMD_READ);
/* Poll until we have valid data */
for (i = 0; i < TIMO && !(bus_space_read_2(sc->sc_iot, sc->sc_ioh,
FM_CODEC_CMD) & FM_CODEC_CMD_VALID); i++)
delay(1);
if (i >= TIMO) {
printf("fms: no data from codec\n");
return 1;
}
/* Read data */
*val = bus_space_read_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_DATA);
return 0;
}
int
fms_write_codec(void *addr, u_int8_t reg, u_int16_t val)
{
struct fms_softc *sc = addr;
int i;
/* Poll until codec is ready */
for (i = 0; i < TIMO && bus_space_read_2(sc->sc_iot, sc->sc_ioh,
FM_CODEC_CMD) & FM_CODEC_CMD_BUSY; i++)
delay(1);
if (i >= TIMO) {
printf("fms: codec busy\n");
return 1;
}
/* Write data */
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_DATA, val);
/* Write index register, write access */
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_CMD, reg);
return 0;
}
#undef TIMO
int
fms_attach_codec(void *addr, struct ac97_codec_if *cif)
{
struct fms_softc *sc = addr;
sc->codec_if = cif;
return 0;
}
/* Cold Reset */
void
fms_reset_codec(void *addr)
{
struct fms_softc *sc = addr;
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_CTL, 0x0020);
delay(2);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_CODEC_CTL, 0x0000);
delay(1);
}
int
fms_intr(void *arg)
{
struct fms_softc *sc = arg;
u_int16_t istat;
mtx_enter(&audio_lock);
istat = bus_space_read_2(sc->sc_iot, sc->sc_ioh, FM_INTSTATUS);
if (istat & FM_INTSTATUS_PLAY) {
if ((sc->sc_play_nextblk += sc->sc_play_blksize) >=
sc->sc_play_end)
sc->sc_play_nextblk = sc->sc_play_start;
bus_space_write_4(sc->sc_iot, sc->sc_ioh,
sc->sc_play_flip++ & 1 ?
FM_PLAY_DMABUF2 : FM_PLAY_DMABUF1, sc->sc_play_nextblk);
if (sc->sc_pintr)
sc->sc_pintr(sc->sc_parg);
else
printf("unexpected play intr\n");
}
if (istat & FM_INTSTATUS_REC) {
if ((sc->sc_rec_nextblk += sc->sc_rec_blksize) >=
sc->sc_rec_end)
sc->sc_rec_nextblk = sc->sc_rec_start;
bus_space_write_4(sc->sc_iot, sc->sc_ioh,
sc->sc_rec_flip++ & 1 ?
FM_REC_DMABUF2 : FM_REC_DMABUF1, sc->sc_rec_nextblk);
if (sc->sc_rintr)
sc->sc_rintr(sc->sc_rarg);
else
printf("unexpected rec intr\n");
}
#if 0
if (istat & FM_INTSTATUS_MPU)
mpu_intr(sc->sc_mpu_dev);
#endif
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_INTSTATUS,
istat & (FM_INTSTATUS_PLAY | FM_INTSTATUS_REC));
mtx_leave(&audio_lock);
return 1;
}
int
fms_open(void *addr, int flags)
{
/* UNUSED struct fms_softc *sc = addr;*/
return 0;
}
void
fms_close(void *addr)
{
/* UNUSED struct fms_softc *sc = addr;*/
}
/*
* Range below -limit- is set to -rate-
* What a pity FM801 does not have 24000
* 24000 -> 22050 sounds rather poor
*/
struct {
int limit;
int rate;
} fms_rates[11] = {
{ 6600, 5500 },
{ 8750, 8000 },
{ 10250, 9600 },
{ 13200, 11025 },
{ 17500, 16000 },
{ 20500, 19200 },
{ 26500, 22050 },
{ 35000, 32000 },
{ 41000, 38400 },
{ 46000, 44100 },
{ 48000, 48000 },
/* anything above -> 48000 */
};
int
fms_set_params(void *addr, int setmode, int usemode, struct audio_params *play,
struct audio_params *rec)
{
struct fms_softc *sc = addr;
int i;
if (setmode & AUMODE_PLAY) {
switch(play->encoding) {
case AUDIO_ENCODING_SLINEAR_LE:
if (play->precision != 16)
return EINVAL;
break;
case AUDIO_ENCODING_ULINEAR_LE:
case AUDIO_ENCODING_ULINEAR_BE:
if (play->precision != 8)
return EINVAL;
break;
default:
return EINVAL;
}
play->bps = AUDIO_BPS(play->precision);
play->msb = 1;
for (i = 0; i < 10 && play->sample_rate > fms_rates[i].limit;
i++)
;
play->sample_rate = fms_rates[i].rate;
sc->sc_play_reg = (play->channels == 2 ? FM_PLAY_STEREO : 0) |
(play->precision == 16 ? FM_PLAY_16BIT : 0) |
(i << 8);
}
if (setmode & AUMODE_RECORD) {
switch(rec->encoding) {
case AUDIO_ENCODING_SLINEAR_LE:
if (rec->precision != 16)
return EINVAL;
break;
case AUDIO_ENCODING_ULINEAR_LE:
case AUDIO_ENCODING_ULINEAR_BE:
if (rec->precision != 8)
return EINVAL;
break;
default:
return EINVAL;
}
rec->bps = AUDIO_BPS(rec->precision);
rec->msb = 1;
for (i = 0; i < 10 && rec->sample_rate > fms_rates[i].limit;
i++)
;
rec->sample_rate = fms_rates[i].rate;
sc->sc_rec_reg =
(rec->channels == 2 ? FM_REC_STEREO : 0) |
(rec->precision == 16 ? FM_REC_16BIT : 0) |
(i << 8);
}
return 0;
}
int
fms_round_blocksize(void *addr, int blk)
{
return (blk + 0xf) & ~0xf;
}
int
fms_halt_output(void *addr)
{
struct fms_softc *sc = addr;
u_int16_t k1;
mtx_enter(&audio_lock);
k1 = bus_space_read_2(sc->sc_iot, sc->sc_ioh, FM_PLAY_CTL);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_PLAY_CTL,
(k1 & ~(FM_PLAY_STOPNOW | FM_PLAY_START)) |
FM_PLAY_BUF1_LAST | FM_PLAY_BUF2_LAST);
mtx_leave(&audio_lock);
return 0;
}
int
fms_halt_input(void *addr)
{
struct fms_softc *sc = addr;
u_int16_t k1;
mtx_enter(&audio_lock);
k1 = bus_space_read_2(sc->sc_iot, sc->sc_ioh, FM_REC_CTL);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_REC_CTL,
(k1 & ~(FM_REC_STOPNOW | FM_REC_START)) |
FM_REC_BUF1_LAST | FM_REC_BUF2_LAST);
mtx_leave(&audio_lock);
return 0;
}
int
fms_set_port(void *addr, mixer_ctrl_t *cp)
{
struct fms_softc *sc = addr;
return (sc->codec_if->vtbl->mixer_set_port(sc->codec_if, cp));
}
int
fms_get_port(void *addr, mixer_ctrl_t *cp)
{
struct fms_softc *sc = addr;
return (sc->codec_if->vtbl->mixer_get_port(sc->codec_if, cp));
}
void *
fms_malloc(void *addr, int direction, size_t size, int pool, int flags)
{
struct fms_softc *sc = addr;
struct fms_dma *p;
int error;
int rseg;
p = malloc(sizeof(*p), pool, flags);
if (!p)
return 0;
p->size = size;
if ((error = bus_dmamem_alloc(sc->sc_dmat, size, NBPG, 0, &p->seg, 1,
&rseg, BUS_DMA_NOWAIT)) != 0) {
printf("%s: unable to allocate dma, error = %d\n",
sc->sc_dev.dv_xname, error);
goto fail_alloc;
}
if ((error = bus_dmamem_map(sc->sc_dmat, &p->seg, rseg, size, &p->addr,
BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
printf("%s: unable to map dma, error = %d\n",
sc->sc_dev.dv_xname, error);
goto fail_map;
}
if ((error = bus_dmamap_create(sc->sc_dmat, size, 1, size, 0,
BUS_DMA_NOWAIT, &p->map)) != 0) {
printf("%s: unable to create dma map, error = %d\n",
sc->sc_dev.dv_xname, error);
goto fail_create;
}
if ((error = bus_dmamap_load(sc->sc_dmat, p->map, p->addr, size, NULL,
BUS_DMA_NOWAIT)) != 0) {
printf("%s: unable to load dma map, error = %d\n",
sc->sc_dev.dv_xname, error);
goto fail_load;
}
p->next = sc->sc_dmas;
sc->sc_dmas = p;
return p->addr;
fail_load:
bus_dmamap_destroy(sc->sc_dmat, p->map);
fail_create:
bus_dmamem_unmap(sc->sc_dmat, p->addr, size);
fail_map:
bus_dmamem_free(sc->sc_dmat, &p->seg, 1);
fail_alloc:
free(p, pool, sizeof(*p));
return 0;
}
void
fms_free(void *addr, void *ptr, int pool)
{
struct fms_softc *sc = addr;
struct fms_dma **pp, *p;
for (pp = &(sc->sc_dmas); (p = *pp) != NULL; pp = &p->next)
if (p->addr == ptr) {
bus_dmamap_unload(sc->sc_dmat, p->map);
bus_dmamap_destroy(sc->sc_dmat, p->map);
bus_dmamem_unmap(sc->sc_dmat, p->addr, p->size);
bus_dmamem_free(sc->sc_dmat, &p->seg, 1);
*pp = p->next;
free(p, pool, sizeof(*p));
return;
}
panic("fms_free: trying to free unallocated memory");
}
int
fms_query_devinfo(void *addr, mixer_devinfo_t *dip)
{
struct fms_softc *sc = addr;
return (sc->codec_if->vtbl->query_devinfo(sc->codec_if, dip));
}
int
fms_trigger_output(void *addr, void *start, void *end, int blksize,
void (*intr)(void *), void *arg, struct audio_params *param)
{
struct fms_softc *sc = addr;
struct fms_dma *p;
sc->sc_pintr = intr;
sc->sc_parg = arg;
for (p = sc->sc_dmas; p && p->addr != start; p = p->next)
;
if (!p)
panic("fms_trigger_output: request with bad start "
"address (%p)", start);
sc->sc_play_start = p->map->dm_segs[0].ds_addr;
sc->sc_play_end = sc->sc_play_start + ((char *)end - (char *)start);
sc->sc_play_blksize = blksize;
sc->sc_play_nextblk = sc->sc_play_start + sc->sc_play_blksize;
sc->sc_play_flip = 0;
mtx_enter(&audio_lock);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_PLAY_DMALEN, blksize - 1);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, FM_PLAY_DMABUF1,
sc->sc_play_start);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, FM_PLAY_DMABUF2,
sc->sc_play_nextblk);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_PLAY_CTL,
FM_PLAY_START | FM_PLAY_STOPNOW | sc->sc_play_reg);
mtx_leave(&audio_lock);
return 0;
}
int
fms_trigger_input(void *addr, void *start, void *end, int blksize,
void (*intr)(void *), void *arg, struct audio_params *param)
{
struct fms_softc *sc = addr;
struct fms_dma *p;
sc->sc_rintr = intr;
sc->sc_rarg = arg;
for (p = sc->sc_dmas; p && p->addr != start; p = p->next)
;
if (!p)
panic("fms_trigger_input: request with bad start "
"address (%p)", start);
sc->sc_rec_start = p->map->dm_segs[0].ds_addr;
sc->sc_rec_end = sc->sc_rec_start + ((char *)end - (char *)start);
sc->sc_rec_blksize = blksize;
sc->sc_rec_nextblk = sc->sc_rec_start + sc->sc_rec_blksize;
sc->sc_rec_flip = 0;
mtx_enter(&audio_lock);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_REC_DMALEN, blksize - 1);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, FM_REC_DMABUF1,
sc->sc_rec_start);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, FM_REC_DMABUF2,
sc->sc_rec_nextblk);
bus_space_write_2(sc->sc_iot, sc->sc_ioh, FM_REC_CTL,
FM_REC_START | FM_REC_STOPNOW | sc->sc_rec_reg);
mtx_leave(&audio_lock);
return 0;
}
|
3647d1d3b4a25dceb821b3ebaeda9e04351c6b72
|
94096248c1de2dcf46e69ca913cedfa290e44224
|
/src-input/duk_prop_get.c
|
1ece95913035b850b023e113d6edd41b98061262
|
[
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
svaarala/duktape
|
612110d1a6db46226c171cfd222974b1b3651ad5
|
5e169deafbbd12823665f5d30fb4c4c04e3dfa26
|
refs/heads/master
| 2023-08-06T16:43:33.014729
| 2022-11-17T21:02:08
| 2022-11-17T21:02:08
| 15,852,088
| 4,796
| 610
|
MIT
| 2023-09-11T17:13:01
| 2014-01-12T22:16:14
|
JavaScript
|
UTF-8
|
C
| false
| false
| 72,818
|
c
|
duk_prop_get.c
|
/*
* [[Get]] and GetValue() for properties
*
* Property reads are performance critical, and there are also many
* sometimes conflicting concerns:
*
* - Pointer stability; arguments from value stack or outside of it.
*
* - Coercion, and keeping possibly primitive base values ('receiver'
* of getter and Proxy), reads on primitive values (GetValue).
*
* - Fast pathing numbers, and in general minimizing coercion and
* string interning.
*
* - Exotic behaviors for [[Get]] and [[GetOwnProperty]] modifying
* the ordinary behavior.
*
* - Several useful argument / value stack behaviors depending on call
* site, need to optimize for executor especially.
*
* Pointer stability is handled as follows:
*
* - The receiver and output are assumed to be value stack slots and are
* referenced only by indices so they are both reachable and stable at
* all times.
*
* - The key is a duk_tval pointer but it gets very quickly coerced
* (stabilizing if necessary) and after that we only deal with either an
* index or a reachable key (stored in value stack or a compiled function
* constants table) throughout.
*
* - While walking the prototype chain the current 'target' object may only
* be reachable via a prototype chain leading to the original receiver.
* This is safe because no side effects are invoked while we walk. If a
* getter is found, calling the getter may have arbitrary side effects.
* For example, a getter may edit the inheritance chain of the original
* receiver, and may cause the 'target' to become unreachable. However,
* once a getter is found, this no longer matters.
*
* - Writing the final output value to 'idx_out' may have arbitrary side
* effects so it must happen last (these may be caused by the old value
* getting finalized). 'idx_out' may also contain the target object or
* the key which gets overwritten with the property value.
*
* - Proxies are the most difficult case. Just checking for a (non-existent)
* proxy trap may have arbitrary side effects because the trap property in
* the handler object may be a getter or the handler itself may be a Proxy.
* The side effects may cause the current object to be freed, so we can
* no longer safely resume the prototype walk even if no trap is found.
*
* - To handle Proxies it becomes necessary to stabilize the current object
* with a strong reference when doing a Proxy trap check -and- at every
* step after that, even for ordinary objects because the initial trap
* check may have edited the inheritance chain arbitrarily, stranding the
* current object.
*
* - Because we don't want to burden normal fast path property reads with the
* stabilization only needed for Proxies, the [[Get]] operation is in
* effect duplicated into a Proxy-supporting side effect resistant variant.
* This duplication is not done for size optimized builds; for them, the
* stabilization is always done to reduce code size.
*
* There are other possible approaches too:
*
* - Always stabilize the current object on the value stack. This has
* a ~10% impact on property get performance (with interpreter overhead
* included), which is not negligible.
*
* - Prevent side effects during [[Get]] (reset the protection if an error is
* thrown). This would be straightforward but it would be unfortunate to
* prevent finalization entirely e.g. inside getters or Proxy trap calls
* which may do significant work.
*
* - For Proxy traps specifically, one could first try to do a side effect
* free lookup (which would work in the vast majority of cases). If a trap
* was not found, and side effects were known not to actually happen, one
* could stay in the faster unsafe path.
*/
#include "duk_internal.h"
/* Outcome for [[GetOwnProperty]] check. */
#define DUK__GETOWN_NOTFOUND 0 /* not found, continue to parent */
#define DUK__GETOWN_FOUND 1 /* found, stop walk */
#define DUK__GETOWN_DONE_NOTFOUND 2 /* not found, stop walk */
#define DUK__GETOWN_CONTINUE_ORDINARY -1 /* not found, check from ordinary property table */
typedef duk_bool_t (
*duk__get_ownprop_idxkey_htype)(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv);
typedef duk_bool_t (
*duk__get_ownprop_strkey_htype)(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv);
DUK_LOCAL_DECL duk_bool_t
duk__prop_getvalue_plainstr_index(duk_hthread *thr, duk_idx_t idx_recv, duk_uarridx_t idx, duk_idx_t idx_out, duk_hstring *h);
DUK_LOCAL_DECL duk_bool_t
duk__prop_get_strkey_unsafe(duk_hthread *thr, duk_hobject *target, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv);
DUK_LOCAL_DECL duk_bool_t
duk__prop_get_strkey_safe(duk_hthread *thr, duk_hobject *target, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv);
DUK_LOCAL_DECL duk_bool_t
duk__prop_get_idxkey_unsafe(duk_hthread *thr, duk_hobject *target, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv);
DUK_LOCAL_DECL duk_bool_t
duk__prop_get_idxkey_safe(duk_hthread *thr, duk_hobject *target, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv);
DUK_NORETURN(DUK_LOCAL_DECL DUK_COLD duk_bool_t duk__prop_get_error_objidx_strkey(duk_hthread *thr,
duk_idx_t idx_obj,
duk_hstring *key));
DUK_NORETURN(DUK_LOCAL_DECL DUK_COLD duk_bool_t duk__prop_get_error_objidx_idxkey(duk_hthread *thr,
duk_idx_t idx_obj,
duk_uarridx_t idx));
DUK_NORETURN(DUK_LOCAL_DECL DUK_COLD duk_bool_t duk__prop_get_error_objidx_tvkey(duk_hthread *thr,
duk_idx_t idx_obj,
duk_tval *tv_key));
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_NORETURN(DUK_LOCAL_DECL void duk__prop_get_error_shared(duk_hthread *thr, duk_idx_t idx_obj));
DUK_LOCAL void duk__prop_get_error_shared(duk_hthread *thr, duk_idx_t idx_obj) {
const char *str1 = duk_get_type_name(thr, idx_obj);
DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "cannot read property of %s", str1);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_strkey(duk_hthread *thr, duk_idx_t idx_obj, duk_hstring *key) {
DUK_UNREF(key);
duk__prop_get_error_shared(thr, idx_obj);
DUK_WO_NORETURN(return 0;);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_idxkey(duk_hthread *thr, duk_idx_t idx_obj, duk_uarridx_t idx) {
DUK_UNREF(idx);
duk__prop_get_error_shared(thr, idx_obj);
DUK_WO_NORETURN(return 0;);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_tvkey(duk_hthread *thr, duk_idx_t idx_obj, duk_tval *tv_key) {
DUK_UNREF(tv_key);
duk__prop_get_error_shared(thr, idx_obj);
DUK_WO_NORETURN(return 0;);
}
#elif defined(DUK_USE_VERBOSE_ERRORS)
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_strkey(duk_hthread *thr, duk_idx_t idx_obj, duk_hstring *key) {
const char *str1 = duk_push_readable_idx(thr, idx_obj);
const char *str2 = duk_push_readable_hstring(thr, key);
DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s", str2, str1);
DUK_WO_NORETURN(return 0;);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_idxkey(duk_hthread *thr, duk_idx_t idx_obj, duk_uarridx_t idx) {
const char *str1 = duk_push_readable_idx(thr, idx_obj);
DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %lu of %s", (unsigned long) idx, str1);
DUK_WO_NORETURN(return 0;);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_tvkey(duk_hthread *thr, duk_idx_t idx_obj, duk_tval *tv_key) {
const char *str1 = duk_push_readable_idx(thr, idx_obj);
const char *str2 = duk_push_readable_tval(thr, tv_key);
DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s", str2, str1);
DUK_WO_NORETURN(return 0;);
}
#else
DUK_NORETURN(DUK_LOCAL_DECL void duk__prop_get_error_shared(duk_hthread *thr));
DUK_LOCAL void duk__prop_get_error_shared(duk_hthread *thr) {
DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_READ_PROPERTY);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_strkey(duk_hthread *thr, duk_idx_t idx_obj, duk_hstring *key) {
DUK_UNREF(idx_obj);
DUK_UNREF(key);
duk__prop_get_error_shared(thr);
DUK_WO_NORETURN(return 0;);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_idxkey(duk_hthread *thr, duk_idx_t idx_obj, duk_uarridx_t idx) {
DUK_UNREF(idx_obj);
DUK_UNREF(idx);
duk__prop_get_error_shared(thr);
DUK_WO_NORETURN(return 0;);
}
DUK_LOCAL DUK_COLD duk_bool_t duk__prop_get_error_objidx_tvkey(duk_hthread *thr, duk_idx_t idx_obj, duk_tval *tv_key) {
DUK_UNREF(idx_obj);
DUK_UNREF(tv_key);
duk__prop_get_error_shared(thr);
DUK_WO_NORETURN(return 0;);
}
#endif /* error model */
DUK_LOCAL DUK_ALWAYS_INLINE duk_bool_t duk__prop_get_write_tval_result(duk_hthread *thr, duk_idx_t idx_out, duk_tval *tv_src) {
duk_tval *tv_out;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(tv_src != NULL);
tv_out = thr->valstack_bottom + idx_out;
DUK_ASSERT(DUK_HTHREAD_TVAL_IN_VSFRAME(thr, tv_out));
DUK_TVAL_SET_TVAL_UPDREF(thr, tv_out, tv_src);
return 1;
}
DUK_LOCAL DUK_ALWAYS_INLINE duk_bool_t duk__prop_get_write_u32_result(duk_hthread *thr, duk_idx_t idx_out, duk_uint32_t val) {
duk_tval *tv_out;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
tv_out = thr->valstack_bottom + idx_out;
DUK_ASSERT(DUK_HTHREAD_TVAL_IN_VSFRAME(thr, tv_out));
DUK_TVAL_SET_U32_UPDREF(thr, tv_out, val);
return 1;
}
DUK_LOCAL DUK_ALWAYS_INLINE duk_bool_t duk__prop_get_write_notfound_result(duk_hthread *thr, duk_idx_t idx_out) {
duk_tval *tv_out;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
tv_out = thr->valstack_bottom + idx_out;
DUK_ASSERT(DUK_HTHREAD_TVAL_IN_VSFRAME(thr, tv_out));
DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv_out);
return 0;
}
DUK_LOCAL duk_bool_t duk__prop_get_write_plainstr_length(duk_hthread *thr, duk_hstring *h, duk_idx_t idx_out) {
duk_tval *tv_out;
duk_uint32_t len;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(h != NULL);
DUK_ASSERT(DUK_HEAPHDR_IS_ANY_STRING((duk_heaphdr *) h));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
tv_out = thr->valstack_bottom + idx_out;
DUK_ASSERT(DUK_HTHREAD_TVAL_IN_VSFRAME(thr, tv_out));
len = (duk_uint32_t) duk_hstring_get_charlen(h);
DUK_TVAL_SET_U32_UPDREF(thr, tv_out, len);
return 1;
}
DUK_LOCAL DUK_ALWAYS_INLINE duk_bool_t duk__get_own_prop_found_getter_helper(duk_hthread *thr,
duk_hobject *obj,
duk_hstring *key,
duk_uarridx_t idx,
duk_idx_t idx_out,
duk_idx_t idx_recv,
duk_propvalue *pv,
duk_uint8_t attrs,
duk_uint_t use_key) {
duk_propaccessor *pa;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
/* key may be NULL */
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(pv != NULL);
DUK_ASSERT_VALSTACK_SPACE(thr, DUK_HOBJECT_PROP_VALSTACK_SPACE);
DUK_ASSERT((attrs & DUK_PROPDESC_FLAG_ACCESSOR) != 0U);
DUK_ASSERT((use_key && key != NULL) || (!use_key && key == NULL));
DUK_UNREF(obj);
DUK_UNREF(attrs);
pa = &pv->a;
if (DUK_LIKELY(pa->get != NULL)) {
duk_push_hobject(thr, pa->get); /* get function */
duk_dup(thr, idx_recv); /* receiver; original uncoerced base */
#if defined(DUK_USE_NONSTD_GETTER_KEY_ARGUMENT)
if (use_key) {
DUK_ASSERT(key != NULL);
duk_push_hstring(thr, key);
} else {
(void) duk_push_u32_tostring(thr, idx);
}
duk_call_method(thr, 1); /* [ getter receiver(= this) key ] -> [ retval ] */
#else
DUK_UNREF(key);
DUK_UNREF(idx);
DUK_UNREF(use_key);
duk_call_method(thr, 0); /* [ getter receiver(= this) ] -> [ retval ] */
#endif
} else {
/* If getter is missing, return undefined. */
duk_push_undefined(thr);
}
duk_replace_posidx_unsafe(thr, idx_out);
return DUK__GETOWN_FOUND;
}
#if defined(DUK_USE_NONSTD_GETTER_KEY_ARGUMENT)
DUK_LOCAL DUK_NOINLINE duk_bool_t duk__get_own_prop_found_getter_withkey(duk_hthread *thr,
duk_hobject *obj,
duk_hstring *key,
duk_idx_t idx_out,
duk_idx_t idx_recv,
duk_propvalue *pv,
duk_uint8_t attrs) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(key != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(pv != NULL);
return duk__get_own_prop_found_getter_helper(thr, obj, key, 0, idx_out, idx_recv, pv, attrs, 1 /*use_key*/);
}
DUK_LOCAL DUK_NOINLINE duk_bool_t duk__get_own_prop_found_getter_withidx(duk_hthread *thr,
duk_hobject *obj,
duk_uarridx_t idx,
duk_idx_t idx_out,
duk_idx_t idx_recv,
duk_propvalue *pv,
duk_uint8_t attrs) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(pv != NULL);
return duk__get_own_prop_found_getter_helper(thr, obj, NULL, idx, idx_out, idx_recv, pv, attrs, 0 /*use_key*/);
}
#else
DUK_LOCAL DUK_NOINLINE duk_bool_t duk__get_own_prop_found_getter_nokey(duk_hthread *thr,
duk_hobject *obj,
duk_idx_t idx_out,
duk_idx_t idx_recv,
duk_propvalue *pv,
duk_uint8_t attrs) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(pv != NULL);
return duk__get_own_prop_found_getter_helper(thr, obj, NULL, 0, idx_out, idx_recv, pv, attrs, 0 /*use_key*/);
}
#endif
DUK_LOCAL duk_bool_t
duk__get_own_prop_strkey_ordinary(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_propvalue *pv;
duk_uint8_t attrs;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(thr->heap != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(key != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT_VALSTACK_SPACE(thr, DUK_HOBJECT_PROP_VALSTACK_SPACE);
if (DUK_LIKELY(duk_hobject_lookup_strprop_val_attrs(thr, obj, key, &pv, &attrs) != 0)) {
if (DUK_LIKELY(attrs & DUK_PROPDESC_FLAG_ACCESSOR) == 0) {
return duk__prop_get_write_tval_result(thr, idx_out, &pv->v);
} else {
#if defined(DUK_USE_NONSTD_GETTER_KEY_ARGUMENT)
return duk__get_own_prop_found_getter_withkey(thr, obj, key, idx_out, idx_recv, pv, attrs);
#else
return duk__get_own_prop_found_getter_nokey(thr, obj, idx_out, idx_recv, pv, attrs);
#endif
}
} else {
return DUK__GETOWN_NOTFOUND;
}
}
DUK_LOCAL duk_bool_t
duk__get_own_prop_idxkey_ordinary(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_propvalue *pv;
duk_uint8_t attrs;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(thr->heap != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT_VALSTACK_SPACE(thr, DUK_HOBJECT_PROP_VALSTACK_SPACE);
if (DUK_LIKELY(duk_hobject_lookup_idxprop_val_attrs(thr, obj, idx, &pv, &attrs) != 0)) {
if (DUK_LIKELY(attrs & DUK_PROPDESC_FLAG_ACCESSOR) == 0) {
return duk__prop_get_write_tval_result(thr, idx_out, &pv->v);
} else {
#if defined(DUK_USE_NONSTD_GETTER_KEY_ARGUMENT)
return duk__get_own_prop_found_getter_withidx(thr, obj, idx, idx_out, idx_recv, pv, attrs);
#else
return duk__get_own_prop_found_getter_nokey(thr, obj, idx_out, idx_recv, pv, attrs);
#endif
}
} else {
return DUK__GETOWN_NOTFOUND;
}
}
#if defined(DUK_USE_PROXY_POLICY)
DUK_LOCAL void duk__prop_get_own_proxy_policy(duk_hthread *thr, duk_hobject *obj) {
duk_hobject *target;
duk_small_int_t attrs;
/* [ ... key result ] */
target = duk_proxy_get_target_autothrow(thr, (duk_hproxy *) obj);
DUK_ASSERT(target != NULL);
attrs = duk_prop_getowndesc_obj_tvkey(thr, target, duk_get_tval(thr, -2 /*trap key*/));
target = NULL; /* Potentially invalidated. */
/* [ ... key result value ] OR [ ... key result get set ] */
if (attrs >= 0) {
duk_small_uint_t uattrs = (duk_small_uint_t) attrs;
if ((uattrs & (DUK_PROPDESC_FLAG_ACCESSOR | DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)) == 0) {
/* Non-configurable, data property, non-writable: trap value must compare SameValue() to target value. */
if (!duk_samevalue(thr, -1 /*target value*/, -2 /*trap result*/)) {
goto reject;
}
} else if ((uattrs & (DUK_PROPDESC_FLAG_ACCESSOR | DUK_PROPDESC_FLAG_CONFIGURABLE)) == DUK_PROPDESC_FLAG_ACCESSOR) {
/* Non-configurable, accessor property; if [[Get]] is null, trap value must be undefined. */
if (duk_is_nullish(thr, -2 /*get*/) && !duk_is_undefined(thr, -3 /*trap result*/)) {
goto reject;
}
}
} else {
/* If target has no 'key', then no restrictions are applied. */
}
duk_prop_pop_propdesc(thr, attrs);
return;
reject:
DUK_ERROR_TYPE_PROXY_REJECTED(thr);
}
#endif
DUK_LOCAL duk_bool_t duk__prop_get_own_proxy_tail(duk_hthread *thr, duk_hobject *obj, duk_idx_t idx_out, duk_idx_t idx_recv) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
/* [ ... trap handler target key ] */
duk_dup_top(thr);
duk_insert(thr, -5); /* Stash key for policy check. */
/* [ ... key trap handler target key ] */
duk_dup(thr, idx_recv);
duk_call_method(thr, 3); /* [ ... key trap handler target key recv ] -> [ ... key result ] */
#if defined(DUK_USE_PROXY_POLICY)
duk__prop_get_own_proxy_policy(thr, obj);
#else
DUK_DD(DUK_DDPRINT("proxy policy check for 'get' trap disabled in configuration"));
#endif
/* [ ... key result ] */
duk_replace_posidx_unsafe(thr, idx_out);
duk_pop_known(thr);
return DUK__GETOWN_FOUND;
}
DUK_LOCAL DUK_NOINLINE duk_bool_t
duk__get_own_prop_strkey_proxy_actual(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(DUK_HOBJECT_GET_HTYPE(obj) == DUK_HTYPE_PROXY);
DUK_ASSERT(key != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
if (duk_proxy_trap_check_strkey(thr, (duk_hproxy *) obj, key, DUK_STRIDX_GET)) {
duk_push_hstring(thr, key);
return duk__prop_get_own_proxy_tail(thr, obj, idx_out, idx_recv);
} else {
return DUK__GETOWN_NOTFOUND;
}
}
DUK_LOCAL DUK_NOINLINE duk_bool_t duk__get_own_prop_idxkey_proxy_actual(duk_hthread *thr,
duk_hobject *obj,
duk_uarridx_t idx,
duk_idx_t idx_out,
duk_idx_t idx_recv) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(DUK_HOBJECT_GET_HTYPE(obj) == DUK_HTYPE_PROXY);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
if (duk_proxy_trap_check_idxkey(thr, (duk_hproxy *) obj, idx, DUK_STRIDX_GET)) {
(void) duk_push_u32_tostring(thr, idx);
return duk__prop_get_own_proxy_tail(thr, obj, idx_out, idx_recv);
} else {
return DUK__GETOWN_NOTFOUND;
}
}
DUK_LOCAL duk_bool_t duk__prop_get_check_arguments_map_for_get(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx) {
duk_hobject *map;
duk_hobject *env;
duk_hstring *varname;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(DUK_HEAPHDR_GET_HTYPE((duk_heaphdr *) obj) == DUK_HTYPE_ARGUMENTS);
DUK_ASSERT_ARRIDX_VALID(idx);
varname = duk_prop_arguments_map_prep_idxkey(thr, obj, idx, &map, &env);
if (varname == NULL) {
return 0;
}
/* Getvar can have arbitrary side effects, as it may be captured
* e.g. by a with(proxy).
*/
(void) duk_js_getvar_envrec(thr, env, varname, 1 /*throw*/); /* -> [ ... value this_binding ] */
duk_pop_known(thr);
/* Leave result on stack top. */
return 1;
}
DUK_LOCAL DUK_NOINLINE duk_bool_t
duk__get_own_prop_idxkey_arguments(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
/* Conceptually: first perform OrdinaryGetOwnProperty() and then
* apply arguments exotic map handling if the property is found.
* This order only matters for getter properties, otherwise the
* order is not observable.
*
* The Arguments map lookup is side effect free so we can do that
* first and only then look at own properties. If an index is found
* in the map we must still perform a normal property lookup and
* ignore the map result (returning 'undefined') if the own property
* no longer exists.
*
* Note in particular that we can't first write an initial result
* to 'idx_out' and then do the map lookup. The initial result
* write may directly overwrite either key or receiver (they may
* have the same slot) and may also invoke arbitrary side effects
* through finalizers, potentially making 'obj' unreachable.
*/
duk_harray *a = (duk_harray *) obj;
duk_bool_t rc;
duk_bool_t rc_map;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(DUK_HEAPHDR_GET_HTYPE((duk_heaphdr *) obj) == DUK_HTYPE_ARGUMENTS);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
/* Stabilize 'obj' against side effects. Note that this does not
* protect the inheritance chain from being modified, it just
* guarantees 'obj' won't go away prematurely if side effects happen.
*/
duk_push_hobject(thr, obj);
/* Arbitrary side effects. */
rc_map = duk__prop_get_check_arguments_map_for_get(thr, obj, idx);
/* [ obj mappedvalue? ] */
if (DUK_LIKELY(DUK_HOBJECT_HAS_ARRAY_ITEMS(obj))) {
if (DUK_LIKELY(idx < DUK_HARRAY_GET_ITEMS_LENGTH(a))) {
duk_tval *tv = DUK_HARRAY_GET_ITEMS(thr->heap, a) + idx;
if (DUK_LIKELY(!DUK_TVAL_IS_UNUSED(tv))) {
duk__prop_get_write_tval_result(thr, idx_out, tv);
goto found_do_map_check;
}
}
} else {
rc = duk__get_own_prop_idxkey_ordinary(thr, obj, idx, idx_out, idx_recv);
if (rc) {
/* If property is found, arbitrary side effects may have
* happened. 'obj' is still safe because it's stabilized
* on the value stack (above).
*/
goto found_do_map_check;
}
}
/* Pop stabilized 'obj' and possible map lookup result.
*
* In this path we didn't find a property (in particular didn't hit a
* getter) so no side effects have occurred and caller is safe to
* continue with 'obj'. (Had side effects happened, 'obj' might now
* be unreachable except for this value stack reference.)
*/
if (rc_map) {
duk_pop_2_known(thr);
} else {
duk_pop_known(thr);
}
return DUK__GETOWN_NOTFOUND;
found_do_map_check:
if (rc_map) {
/* idx_out already contains the result from a normal property
* lookup, replace it with value found from arguments map.
*/
duk_replace(thr, idx_out);
}
duk_pop_known(thr);
/* Side effects have occurred so all bets are off. This is OK in this
* path because caller will terminate property lookup anyway.
*/
return DUK__GETOWN_FOUND;
}
DUK_LOCAL duk_bool_t
duk__get_own_prop_idxkey_arrayitems(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_harray *a;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(DUK_HOBJECT_GET_HTYPE(obj) == DUK_HTYPE_ARRAY);
DUK_ASSERT(DUK_HOBJECT_HAS_ARRAY_ITEMS(obj));
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_UNREF(idx_recv);
a = (duk_harray *) obj;
/* Comprehensiveness assumption: if array items exists, no index
* keys are allowed in index part.
*/
if (DUK_LIKELY(idx < DUK_HARRAY_GET_ITEMS_LENGTH(a))) {
duk_tval *tv = DUK_HARRAY_GET_ITEMS(thr->heap, a) + idx;
if (DUK_LIKELY(!DUK_TVAL_IS_UNUSED(tv))) {
return duk__prop_get_write_tval_result(thr, idx_out, tv);
}
}
return DUK__GETOWN_NOTFOUND;
}
DUK_LOCAL DUK_NOINLINE duk_small_int_t
duk__get_own_prop_idxkey_stringobj(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_hstring *h;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(DUK_HOBJECT_GET_HTYPE(obj) == DUK_HTYPE_STRING_OBJECT);
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
h = duk_hobject_lookup_intvalue_hstring(thr, obj);
if (DUK_LIKELY(h != NULL)) {
if (DUK_LIKELY(!DUK_HSTRING_HAS_SYMBOL(h) && idx < duk_hstring_get_charlen(h))) {
return (duk_small_int_t) duk__prop_getvalue_plainstr_index(thr, idx_recv, idx, idx_out, h);
}
}
return DUK__GETOWN_CONTINUE_ORDINARY; /* Continue to ordinary idxprops. */
}
DUK_LOCAL DUK_NOINLINE duk_bool_t duk__get_own_prop_strkey_stringobj_length(duk_hthread *thr,
duk_hobject *obj,
duk_hstring *key,
duk_idx_t idx_out,
duk_idx_t idx_recv) {
duk_hstring *h;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(DUK_HOBJECT_GET_HTYPE(obj) == DUK_HTYPE_STRING_OBJECT);
DUK_ASSERT(key != NULL);
DUK_ASSERT(key == DUK_HTHREAD_STRING_LENGTH(thr));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_UNREF(key);
DUK_UNREF(idx_recv);
h = duk_hobject_lookup_intvalue_hstring(thr, obj);
if (DUK_LIKELY(h != NULL)) {
return duk__prop_get_write_plainstr_length(thr, h, idx_out);
}
return DUK__GETOWN_NOTFOUND;
}
DUK_LOCAL duk_bool_t
duk__get_own_prop_strkey_switch(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_small_uint_t htype;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(key != NULL);
DUK_ASSERT(!DUK_HSTRING_HAS_ARRIDX(key));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
htype = DUK_HEAPHDR_GET_HTYPE((duk_heaphdr *) obj);
DUK_ASSERT(DUK_HTYPE_IS_ANY_OBJECT(htype));
#if 0
if (DUK_LIKELY(htype == DUK_HTYPE_OBJECT)) {
goto skip_htype_check;
}
#endif
switch (htype) {
case DUK_HTYPE_ARRAY:
if (DUK_HSTRING_HAS_LENGTH(key)) {
duk_harray *a = (duk_harray *) obj;
duk_uint32_t len = (duk_uint32_t) DUK_HARRAY_GET_LENGTH(a);
return duk__prop_get_write_u32_result(thr, idx_out, len);
}
break;
case DUK_HTYPE_ARGUMENTS:
/* In ES2017+ Arguments objects no longer contain a throwing .caller
* property or exotic behavior related to it. The only exotic behavior
* is for index properties, which don't come here.
*/
break;
case DUK_HTYPE_PROXY:
/* Consult 'get' trap if one exists. If not, move on to the
* Proxy target. Note that 'getPrototypeOf' is not checked
* by Proxy [[Get]].
*
* This is a difficult case because of side effects. Just
* checking for the trap may invalidate caller's 'target'.
*
* Handle specially: return "not found" and handle the actual
* trap lookup in the caller (exploiting the fact that a
* Proxy's internal prototype is NULL) so that the caller can
* stabilize the 'target' if necessary.
*/
return DUK__GETOWN_NOTFOUND;
case DUK_HTYPE_COMPFUNC:
case DUK_HTYPE_NATFUNC:
case DUK_HTYPE_BOUNDFUNC:
/* No exotic behaviors in ES2015+. */
break;
case DUK_HTYPE_STRING_OBJECT:
/* String objects have exotic behavior for string indices
* (CanonicalNumericIndexString), but unlike typed arrays
* non-matching indices continue through to the ordinary
* algorithm. In this path CanonicalNumericIndexStrings
* never match actual indices so they are just passed on.
*
* Exotic behavior for String [[GetOwnProperty]] comes after
* OrdinaryGetOwnProperty() but this doesn't seem to matter
* because the index properties are never found as concrete
* properties (attempt to define them fails as they're
* non-writable and non-configurable). So we implement the
* exotic behavior first.
*/
if (DUK_HSTRING_HAS_LENGTH(key)) {
return duk__get_own_prop_strkey_stringobj_length(thr, obj, key, idx_out, idx_recv);
}
break;
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
case DUK_HTYPE_ARRAYBUFFER:
case DUK_HTYPE_DATAVIEW:
/* ArrayBuffer and DataView .byteLength is an accessor, but it's
* not generally used in loops because there are no index keys
* for ArrayBuffer or DataView.
*
* No virtual .byteLength for now.
*/
break;
case DUK_HTYPE_INT8ARRAY:
case DUK_HTYPE_UINT8ARRAY:
case DUK_HTYPE_UINT8CLAMPEDARRAY:
case DUK_HTYPE_INT16ARRAY:
case DUK_HTYPE_UINT16ARRAY:
case DUK_HTYPE_INT32ARRAY:
case DUK_HTYPE_UINT32ARRAY:
case DUK_HTYPE_FLOAT32ARRAY:
case DUK_HTYPE_FLOAT64ARRAY:
/* Technically integer-indexed exotic object [[GetOwnProperty]]
* does not have any special behavior for 'length' property.
* It is inherited from %TypedArray%.prototype as a getter.
*
* But because it's potentially used in tight loops, it's
* provided as a virtual own property here. Another option
* would be special case length reads but track "tainting"
* of the prototype .length getter and the prototype chain
* so the fast path would be fully transparent.
*
* Array index keys don't come here, but the exotic behavior
* applies to all CanonicalNumericIndexString values which
* must be handled here.
*/
if (DUK_HSTRING_HAS_LENGTH(key)) {
duk_hbufobj *h = (duk_hbufobj *) obj;
duk_uint32_t len = (duk_uint32_t) DUK_HBUFOBJ_GET_LOGICAL_LENGTH(h);
return duk__prop_get_write_u32_result(thr, idx_out, len);
}
if (DUK_HSTRING_HAS_CANNUM(key)) {
/* We could actually skip this check if property
* write path rejects any attempts to establish
* concrete CanonicalNumericIndexString properties.
* We would then return "not found" from the concrete
* property check (performance of that is irrelevant
* for these keys). In any case we must not continue
* prototype walk to the parent.
*/
return DUK__GETOWN_DONE_NOTFOUND; /* Short circuit, don't continue walk. */
}
break;
#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
default:
break;
}
#if 0
skip_htype_check:
#endif
return duk__get_own_prop_strkey_ordinary(thr, obj, key, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_own_prop_idxkey_switch(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_small_uint_t htype;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
htype = DUK_HEAPHDR_GET_HTYPE((duk_heaphdr *) obj);
DUK_ASSERT(DUK_HTYPE_IS_ANY_OBJECT(htype));
/* A lookup with an arridx is expected to hit some exotic behavior
* (array or buffers) so there's probably no point in fast pathing
* plain objects or another subset of non-exotic objects. It might
* be useful to fast path arrays and/or buffers.
*/
switch (htype) {
case DUK_HTYPE_ARRAY:
if (DUK_LIKELY(DUK_HOBJECT_HAS_ARRAY_ITEMS(obj))) {
return duk__get_own_prop_idxkey_arrayitems(thr, obj, idx, idx_out, idx_recv);
}
break;
case DUK_HTYPE_ARGUMENTS:
return duk__get_own_prop_idxkey_arguments(thr, obj, idx, idx_out, idx_recv);
case DUK_HTYPE_PROXY:
/* Handled by caller; see comments for Proxy in the strkey path. */
return DUK__GETOWN_NOTFOUND;
case DUK_HTYPE_STRING_OBJECT: {
duk_small_int_t str_rc;
str_rc = duk__get_own_prop_idxkey_stringobj(thr, obj, idx, idx_out, idx_recv);
if (str_rc < 0) {
/* Continue with normal property table lookup. */
break;
}
return (duk_bool_t) str_rc;
}
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
case DUK_HTYPE_ARRAYBUFFER:
case DUK_HTYPE_DATAVIEW:
break;
case DUK_HTYPE_INT8ARRAY:
case DUK_HTYPE_UINT8ARRAY:
case DUK_HTYPE_UINT8CLAMPEDARRAY:
case DUK_HTYPE_INT16ARRAY:
case DUK_HTYPE_UINT16ARRAY:
case DUK_HTYPE_INT32ARRAY:
case DUK_HTYPE_UINT32ARRAY:
case DUK_HTYPE_FLOAT32ARRAY:
case DUK_HTYPE_FLOAT64ARRAY:
/* All arridx are captured and don't reach OrdinaryGetOwnProperty(). */
if (DUK_LIKELY(duk_hbufobj_validate_and_read_push(thr, (duk_hbufobj *) obj, idx))) {
duk_replace_posidx_unsafe(thr, idx_out);
return DUK__GETOWN_FOUND;
}
return DUK__GETOWN_DONE_NOTFOUND; /* Short circuit. */
#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
default:
break;
}
return duk__get_own_prop_idxkey_ordinary(thr, obj, idx, idx_out, idx_recv);
}
/*
* Index key htype handlers.
*/
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_error(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
DUK_UNREF(thr);
DUK_UNREF(obj);
DUK_UNREF(idx);
DUK_UNREF(idx_out);
DUK_UNREF(idx_recv);
return DUK__GETOWN_NOTFOUND;
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_ordinary(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_own_prop_idxkey_ordinary(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
if (DUK_LIKELY(DUK_HOBJECT_HAS_ARRAY_ITEMS(obj))) {
return duk__get_own_prop_idxkey_arrayitems(thr, obj, idx, idx_out, idx_recv);
}
return duk__get_own_prop_idxkey_ordinary(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_arguments(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_own_prop_idxkey_arguments(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_proxy(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
/* Handled by caller; see comments for Proxy in the strkey path. */
DUK_UNREF(thr);
DUK_UNREF(obj);
DUK_UNREF(idx);
DUK_UNREF(idx_out);
DUK_UNREF(idx_recv);
return DUK__GETOWN_NOTFOUND;
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_stringobj(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_small_int_t str_rc;
str_rc = duk__get_own_prop_idxkey_stringobj(thr, obj, idx, idx_out, idx_recv);
if (str_rc < 0) {
/* Continue with normal property table lookup. */
return duk__get_own_prop_idxkey_ordinary(thr, obj, idx, idx_out, idx_recv);
}
return (duk_bool_t) str_rc;
}
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_typedarray(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
/* All arridx are captured and don't reach OrdinaryGetOwnProperty(). */
DUK_UNREF(idx_recv);
if (DUK_LIKELY(duk_hbufobj_validate_and_read_push(thr, (duk_hbufobj *) obj, idx))) {
duk_replace_posidx_unsafe(thr, idx_out);
return DUK__GETOWN_FOUND;
}
return DUK__GETOWN_DONE_NOTFOUND; /* Short circuit. */
}
#else
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_typedarray(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_error(thr, obj, idx, idx_out, idx_recv);
}
#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_int8array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
#else
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_int8array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_error(thr, obj, idx, idx_out, idx_recv);
}
#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_uint8array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_hbufobj *h = (duk_hbufobj *) obj;
duk_uint8_t *data;
DUK_UNREF(idx_recv);
data = duk_hbufobj_uint8array_get_validated_data_ptr(thr, h, idx);
if (DUK_LIKELY(data != NULL)) {
duk_bool_t rc = duk__prop_get_write_u32_result(thr, idx_out, (duk_uint32_t) *data);
DUK_ASSERT(rc == 1);
DUK_ASSERT(DUK__GETOWN_FOUND == 1);
return rc;
} else {
/* Out-of-bounds, detached, uncovered: treat as not found. */
return DUK__GETOWN_DONE_NOTFOUND; /* Short circuit. */
}
}
#else
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_uint8array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_error(thr, obj, idx, idx_out, idx_recv);
}
#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
DUK_LOCAL duk_bool_t duk__get_ownprop_idxkey_uint8clampedarray(duk_hthread *thr,
duk_hobject *obj,
duk_uarridx_t idx,
duk_idx_t idx_out,
duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_int16array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_uint16array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_int32array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_uint32array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_float32array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_idxkey_float64array(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_idxkey_typedarray(thr, obj, idx, idx_out, idx_recv);
}
/* On 32-bit targets this takes 256 bytes. There are only a few handlers so
* this can be footprint optimized to 1*64 (one byte lookup) and 7*4=28 for
* a table of 7 handlers, saving about 150 bytes.
*
* On 64-bit targets this typically takes 512 bytes.
*/
DUK_LOCAL const duk__get_ownprop_idxkey_htype duk__getown_idxkey_handlers[64] = {
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_array, duk__get_ownprop_idxkey_arguments, duk__get_ownprop_idxkey_ordinary,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary,
duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary,
duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary,
duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_stringobj,
duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary,
duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_ordinary,
duk__get_ownprop_idxkey_proxy, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_ordinary, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_ordinary,
duk__get_ownprop_idxkey_int8array, duk__get_ownprop_idxkey_uint8array, duk__get_ownprop_idxkey_uint8clampedarray,
duk__get_ownprop_idxkey_int16array, duk__get_ownprop_idxkey_uint16array,
duk__get_ownprop_idxkey_int32array, duk__get_ownprop_idxkey_uint32array, duk__get_ownprop_idxkey_float32array,
duk__get_ownprop_idxkey_float64array, duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error,
duk__get_ownprop_idxkey_error, duk__get_ownprop_idxkey_error
};
DUK_LOCAL duk_bool_t
duk__get_own_prop_idxkey_htypejump(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_small_uint_t htype;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
htype = DUK_HEAPHDR_GET_HTYPE((duk_heaphdr *) obj);
DUK_ASSERT(DUK_HTYPE_IS_ANY_OBJECT(htype));
return duk__getown_idxkey_handlers[htype](thr, obj, idx, idx_out, idx_recv);
}
/*
* String key htype handlers
*/
DUK_LOCAL duk_bool_t
duk__get_ownprop_strkey_error(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
DUK_UNREF(thr);
DUK_UNREF(obj);
DUK_UNREF(key);
DUK_UNREF(idx_out);
DUK_UNREF(idx_recv);
return DUK__GETOWN_NOTFOUND;
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_strkey_ordinary(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_own_prop_strkey_ordinary(thr, obj, key, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_strkey_array(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
if (DUK_HSTRING_HAS_LENGTH(key)) {
duk_harray *a = (duk_harray *) obj;
duk_uint32_t len = (duk_uint32_t) DUK_HARRAY_GET_LENGTH(a);
return duk__prop_get_write_u32_result(thr, idx_out, len);
}
return duk__get_own_prop_strkey_ordinary(thr, obj, key, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_strkey_stringobj(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
if (DUK_HSTRING_HAS_LENGTH(key)) {
return duk__get_own_prop_strkey_stringobj_length(thr, obj, key, idx_out, idx_recv);
}
return duk__get_own_prop_strkey_ordinary(thr, obj, key, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__get_ownprop_strkey_proxy(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
/* Handled in call site specially. */
DUK_UNREF(thr);
DUK_UNREF(obj);
DUK_UNREF(key);
DUK_UNREF(idx_out);
DUK_UNREF(idx_recv);
return DUK__GETOWN_NOTFOUND;
}
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
DUK_LOCAL duk_bool_t
duk__get_ownprop_strkey_typedarray(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
if (DUK_HSTRING_HAS_LENGTH(key)) {
duk_hbufobj *h = (duk_hbufobj *) obj;
duk_uint32_t len = (duk_uint32_t) DUK_HBUFOBJ_GET_LOGICAL_LENGTH(h);
return duk__prop_get_write_u32_result(thr, idx_out, len);
}
if (DUK_HSTRING_HAS_CANNUM(key)) {
/* We could actually skip this check if property
* write path rejects any attempts to establish
* concrete CanonicalNumericIndexString properties.
* We would then return "not found" from the concrete
* property check (performance of that is irrelevant
* for these keys). In any case we must not continue
* prototype walk to the parent.
*/
return DUK__GETOWN_DONE_NOTFOUND; /* Short circuit, don't continue walk. */
}
return duk__get_own_prop_strkey_ordinary(thr, obj, key, idx_out, idx_recv);
}
#else
DUK_LOCAL duk_bool_t
duk__get_ownprop_strkey_typedarray(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__get_ownprop_strkey_error(thr, obj, key, idx_out, idx_recv);
}
#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
DUK_LOCAL const duk__get_ownprop_strkey_htype duk__getown_strkey_handlers[64] = {
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_array, duk__get_ownprop_strkey_ordinary, /* Arguments: in ES2017+ no more strkey exotics, e.g.
.caller. */
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_ordinary,
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary,
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary,
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_stringobj,
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary,
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_ordinary,
duk__get_ownprop_strkey_proxy, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_ordinary, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_ordinary,
duk__get_ownprop_strkey_typedarray, duk__get_ownprop_strkey_typedarray, duk__get_ownprop_strkey_typedarray,
duk__get_ownprop_strkey_typedarray, duk__get_ownprop_strkey_typedarray,
duk__get_ownprop_strkey_typedarray, duk__get_ownprop_strkey_typedarray, duk__get_ownprop_strkey_typedarray,
duk__get_ownprop_strkey_typedarray, duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error,
duk__get_ownprop_strkey_error, duk__get_ownprop_strkey_error
};
DUK_LOCAL duk_bool_t
duk__get_own_prop_strkey_htypejump(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
duk_small_uint_t htype;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(obj != NULL);
DUK_ASSERT(key != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
htype = DUK_HEAPHDR_GET_HTYPE((duk_heaphdr *) obj);
DUK_ASSERT(DUK_HTYPE_IS_ANY_OBJECT(htype));
return duk__getown_strkey_handlers[htype](thr, obj, key, idx_out, idx_recv);
}
/*
* [[Get]] prototype walk
*/
DUK_LOCAL DUK_ALWAYS_INLINE duk_bool_t duk__prop_get_stroridx_helper(duk_hthread *thr,
duk_hobject *target,
duk_hstring *key,
duk_uarridx_t idx,
duk_idx_t idx_out,
duk_idx_t idx_recv,
duk_bool_t use_key,
duk_bool_t side_effect_safe) {
duk_bool_t rc;
duk_small_uint_t sanity;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(target != NULL);
if (use_key) {
DUK_ASSERT(key != NULL);
DUK_ASSERT(!DUK_HSTRING_HAS_ARRIDX(key));
} else {
DUK_ASSERT_ARRIDX_VALID(idx);
}
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
if (side_effect_safe) {
duk_push_hobject(thr, target);
#if 0
tv_target = thr->valstack_top++;
DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(tv_target));
DUK_TVAL_SET_OBJECT_INCREF(thr, tv_target, target);
#endif
}
/* The current 'target' may only be reachable via the prototype (and
* Proxy ->target) chain from 'obj', and any side effect involving
* finalizers may alter that chain. So we must be careful not to
* trigger such side effects without stabilizing the 'target' reference.
*
* If a Proxy is encountered we switch to a model where the current
* target is on the stack top: a trap check (for a missing trap) may
* have side effects and may break the prototype chain from the
* original receiver to 'target'. So after a trap check with side
* effects we need to keep the current target reachable on our own,
* even after the initial Proxy.
*/
sanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;
do {
duk_hobject *next;
#if defined(DUK_USE_ASSERTIONS)
#if defined(DUK_USE_REFERENCE_COUNTING)
DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) target) > 0);
if (side_effect_safe && DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) target) == 1) {
DUK_DD(DUK_DDPRINT("'target' is only reachable via stabilized value stack slot"));
}
#endif
#endif
DUK_GC_TORTURE(thr->heap);
if (use_key) {
DUK_UNREF(duk__get_own_prop_strkey_switch);
#if 0
rc = duk__get_own_prop_strkey_switch(thr, target, key, idx_out, idx_recv);
#else
rc = duk__get_own_prop_strkey_htypejump(thr, target, key, idx_out, idx_recv);
#endif
} else {
DUK_UNREF(duk__get_own_prop_idxkey_switch);
#if 0
rc = duk__get_own_prop_idxkey_switch(thr, target, idx, idx_out, idx_recv);
#else
rc = duk__get_own_prop_idxkey_htypejump(thr, target, idx, idx_out, idx_recv);
#endif
}
DUK_GC_TORTURE(thr->heap);
DUK_ASSERT(rc == DUK__GETOWN_NOTFOUND || rc == DUK__GETOWN_FOUND || rc == DUK__GETOWN_DONE_NOTFOUND);
if (rc != DUK__GETOWN_NOTFOUND) {
if (DUK_LIKELY(rc == DUK__GETOWN_FOUND)) {
goto found;
} else {
DUK_ASSERT(rc == DUK__GETOWN_DONE_NOTFOUND);
goto not_found;
}
}
/* The ordinary [[Get]] algorithm looks up [[GetPrototypeOf]]
* but only for ordinary objects, so Proxy 'getPrototypeOf' is
* never invoked here; instead we move on to the Proxy target
* after the 'get' trap, without invoking any more traps.
*
* Because of side effect issues Proxies are handled below
* (e.g. duk__get_own_prop_strkey() does nothing and returns 0
* == not found). Take advantage of the fact that a Proxy has
* NULL as the raw internal prototype to avoid the Proxy check
* for inherit fast path.
*
* At present we always switch to the side effect safe path
* when encountering a Proxy. This is unnecessary if the
* Proxy trap lookup doesn't actually trigger side effects
* (e.g. the handler itself is a Proxy); in the majority of
* cases we could actually remain on the unsafe path.
*/
#if defined(DUK_USE_ASSERTIONS)
#if defined(DUK_USE_REFERENCE_COUNTING)
DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) target) > 0);
if (side_effect_safe && DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) target) == 1) {
/* Useful in some test cases where we want to exercise
* the stabilization approach.
*/
DUK_DD(DUK_DDPRINT("'target' is only reachable via stabilized value stack slot"));
}
#endif
#endif
next = duk_hobject_get_proto_raw(thr->heap, target);
if (next == NULL) {
if (DUK_UNLIKELY(DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(target))) {
if (side_effect_safe) {
/* Actual Proxy handling is here. */
if (use_key) {
rc = duk__get_own_prop_strkey_proxy_actual(thr, target, key, idx_out, idx_recv);
} else {
rc = duk__get_own_prop_idxkey_proxy_actual(thr, target, idx, idx_out, idx_recv);
}
DUK_ASSERT(rc == DUK__GETOWN_NOTFOUND || rc == DUK__GETOWN_FOUND);
if (rc != DUK__GETOWN_NOTFOUND) {
goto found;
} else {
DUK_ASSERT(DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(target));
next = duk_proxy_get_target_autothrow(thr, (duk_hproxy *) target);
DUK_ASSERT(next != NULL);
}
} else {
/* Handling for initial Proxy found, switch to side effect free path. */
DUK_DD(DUK_DDPRINT("encountered Proxy, switch to side effect free variant"));
goto switch_to_safe;
}
} else {
goto not_found;
}
} else {
DUK_ASSERT(DUK_HOBJECT_GET_HTYPE(target) != DUK_HTYPE_PROXY);
}
DUK_ASSERT(next != NULL);
if (side_effect_safe) {
target = duk_prop_switch_stabilized_target_top(thr, target, next);
} else {
target = next;
}
} while (--sanity > 0);
DUK_ERROR_RANGE_PROTO_SANITY(thr);
DUK_WO_NORETURN(return 0;);
not_found:
if (side_effect_safe) {
DUK_ASSERT(duk_get_hobject(thr, -1) == target);
duk_pop_known(thr);
}
return duk__prop_get_write_notfound_result(thr, idx_out);
found:
DUK_ASSERT(rc == 1);
if (side_effect_safe) {
duk_pop_known(thr);
return 1;
} else {
return rc;
}
switch_to_safe:
if (use_key) {
return duk__prop_get_strkey_safe(thr, target, key, idx_out, idx_recv);
} else {
return duk__prop_get_idxkey_safe(thr, target, idx, idx_out, idx_recv);
}
}
DUK_LOCAL duk_bool_t
duk__prop_get_strkey_unsafe(duk_hthread *thr, duk_hobject *target, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
#if defined(DUK_USE_PREFER_SIZE)
return duk__prop_get_strkey_safe(thr, target, key, idx_out, idx_recv);
#else
return duk__prop_get_stroridx_helper(thr, target, key, 0, idx_out, idx_recv, 1 /*use_key*/, 0 /*side_effect_safe*/);
#endif
}
DUK_LOCAL DUK_NOINLINE duk_bool_t
duk__prop_get_strkey_safe(duk_hthread *thr, duk_hobject *target, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__prop_get_stroridx_helper(thr, target, key, 0, idx_out, idx_recv, 1 /*use_key*/, 1 /*side_effect_safe*/);
}
/* [[Get]] for any duk_hobject, with string/symbol key, excluding indexes handled by
* duk__prop_get_idx() and variants.
*/
DUK_LOCAL duk_bool_t
duk__prop_get_str(duk_hthread *thr, duk_hobject *target, duk_hstring *key, duk_idx_t idx_out, duk_idx_t idx_recv) {
DUK_STATS_INC(thr->heap, stats_get_strkey_count);
return duk__prop_get_strkey_unsafe(thr, target, key, idx_out, idx_recv);
}
/* [[Get]] for duk_hobjects with ordinary behavior, with index key. */
DUK_LOCAL duk_bool_t
duk__prop_get_idxkey_unsafe(duk_hthread *thr, duk_hobject *target, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
#if defined(DUK_USE_PREFER_SIZE)
return duk__prop_get_idxkey_safe(thr, target, idx, idx_out, idx_recv);
#else
return duk__prop_get_stroridx_helper(thr, target, NULL, idx, idx_out, idx_recv, 0 /*use_key*/, 0 /*side_effect_safe*/);
#endif
}
DUK_LOCAL DUK_NOINLINE duk_bool_t
duk__prop_get_idxkey_safe(duk_hthread *thr, duk_hobject *target, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
return duk__prop_get_stroridx_helper(thr, target, NULL, idx, idx_out, idx_recv, 0 /*use_key*/, 1 /*side_effect_safe*/);
}
/* [[Get]] for any duk_hobject, with index key. */
DUK_LOCAL duk_bool_t
duk__prop_get_idx(duk_hthread *thr, duk_hobject *target, duk_uarridx_t idx, duk_idx_t idx_out, duk_idx_t idx_recv) {
DUK_STATS_INC(thr->heap, stats_get_idxkey_count);
return duk__prop_get_idxkey_unsafe(thr, target, idx, idx_out, idx_recv);
}
DUK_LOCAL duk_bool_t
duk__prop_getvalue_plainstr_index(duk_hthread *thr, duk_idx_t idx_recv, duk_uarridx_t idx, duk_idx_t idx_out, duk_hstring *h) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_ASSERT(h != NULL);
DUK_UNREF(idx_recv);
duk_prop_push_plainstr_idx(thr, h, idx);
duk_replace_posidx_unsafe(thr, idx_out);
return 1;
}
DUK_LOCAL duk_bool_t duk__prop_getvalue_idxkey_outidx(duk_hthread *thr, duk_idx_t idx_recv, duk_uarridx_t idx, duk_idx_t idx_out) {
duk_hobject *next;
duk_small_uint_t next_bidx;
duk_tval *tv_recv;
duk_small_uint_t tag_recv;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_STATS_INC(thr->heap, stats_getvalue_idxkey_count);
tv_recv = thr->valstack_bottom + idx_recv;
DUK_ASSERT(DUK_HTHREAD_TVAL_IN_VSFRAME(thr, tv_recv));
tag_recv = DUK_TVAL_GET_TAG(tv_recv);
#if 0
if (DUK_LIKELY(tag_recv == DUK_TAG_OBJECT)) {
/* Typical case. */
next = DUK_TVAL_GET_OBJECT(tv_recv);
goto go_next;
}
#endif
switch (tag_recv) {
case DUK_TAG_UNUSED:
case DUK_TAG_UNDEFINED:
case DUK_TAG_NULL:
return duk__prop_get_error_objidx_idxkey(thr, idx_recv, idx);
case DUK_TAG_BOOLEAN:
next_bidx = DUK_BIDX_BOOLEAN_PROTOTYPE;
break;
case DUK_TAG_POINTER:
next_bidx = DUK_BIDX_POINTER_PROTOTYPE;
break;
case DUK_TAG_LIGHTFUNC:
next_bidx = DUK_BIDX_NATIVE_FUNCTION_PROTOTYPE;
break;
case DUK_TAG_STRING: {
duk_hstring *h = DUK_TVAL_GET_STRING(tv_recv);
if (DUK_LIKELY(!DUK_HSTRING_HAS_SYMBOL(h))) {
if (DUK_LIKELY(idx < duk_hstring_get_charlen(h))) {
return duk__prop_getvalue_plainstr_index(thr, idx_recv, idx, idx_out, h);
}
next_bidx = DUK_BIDX_STRING_PROTOTYPE;
} else {
next_bidx = DUK_BIDX_SYMBOL_PROTOTYPE;
}
break;
}
case DUK_TAG_OBJECT:
#if 1
/* Typical case. */
next = DUK_TVAL_GET_OBJECT(tv_recv);
goto go_next;
#else
/* Never here. */
goto not_found;
#endif
case DUK_TAG_BUFFER: {
duk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv_recv);
if (DUK_LIKELY(idx < DUK_HBUFFER_GET_SIZE(h))) {
duk_uint8_t *buf = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h);
duk_uint32_t val = (duk_uint32_t) buf[idx];
return duk__prop_get_write_u32_result(thr, idx_out, val);
} else {
/* Out bounds: don't walk prototype, matches Uint8Array. */
goto not_found;
}
break;
}
default:
DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_recv));
next_bidx = DUK_BIDX_NUMBER_PROTOTYPE;
break;
}
next = thr->builtins[next_bidx];
/* fall thru */
go_next:
return duk__prop_get_idx(thr, next, idx, idx_out, idx_recv);
not_found:
return duk__prop_get_write_notfound_result(thr, idx_out);
}
DUK_LOCAL duk_bool_t duk__prop_getvalue_strkey_outidx(duk_hthread *thr, duk_idx_t idx_recv, duk_hstring *key, duk_idx_t idx_out) {
duk_hobject *next;
duk_small_uint_t next_bidx;
duk_tval *tv_recv;
duk_small_uint_t tag_recv;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(key != NULL);
DUK_ASSERT(!DUK_HSTRING_HAS_ARRIDX(key));
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
DUK_STATS_INC(thr->heap, stats_getvalue_strkey_count);
tv_recv = thr->valstack_bottom + idx_recv;
DUK_ASSERT(DUK_HTHREAD_TVAL_IN_VSFRAME(thr, tv_recv));
tag_recv = DUK_TVAL_GET_TAG(tv_recv);
/* Typical property reads occur on objects, not primitive values so
* optimize for object case. Plain buffers are an important non-object
* base property read case (here, for the 'length' property).
*/
#if 0
if (DUK_LIKELY(tag_recv == DUK_TAG_OBJECT)) {
/* Typical case. */
next = DUK_TVAL_GET_OBJECT(tv_recv);
goto go_next;
}
#endif
switch (tag_recv) {
case DUK_TAG_UNUSED:
case DUK_TAG_UNDEFINED:
case DUK_TAG_NULL:
return duk__prop_get_error_objidx_strkey(thr, idx_recv, key);
case DUK_TAG_STRING: {
duk_hstring *h = DUK_TVAL_GET_STRING(tv_recv);
if (DUK_LIKELY(!DUK_HSTRING_HAS_SYMBOL(h))) {
if (DUK_HSTRING_HAS_LENGTH(key)) {
return duk__prop_get_write_plainstr_length(thr, h, idx_out);
}
next_bidx = DUK_BIDX_STRING_PROTOTYPE;
} else {
next_bidx = DUK_BIDX_SYMBOL_PROTOTYPE;
}
break;
}
case DUK_TAG_OBJECT:
#if 1
/* Typical case. */
next = DUK_TVAL_GET_OBJECT(tv_recv);
goto go_next;
#else
/* Never here. */
goto not_found;
#endif
case DUK_TAG_BUFFER:
if (DUK_HSTRING_HAS_LENGTH(key)) {
duk_hbuffer *h = (duk_hbuffer *) DUK_TVAL_GET_BUFFER(tv_recv);
duk_uint32_t len = (duk_uint32_t) DUK_HBUFFER_GET_SIZE(h);
return duk__prop_get_write_u32_result(thr, idx_out, len);
}
next_bidx = DUK_BIDX_UINT8ARRAY_PROTOTYPE;
break;
case DUK_TAG_BOOLEAN:
next_bidx = DUK_BIDX_BOOLEAN_PROTOTYPE;
break;
case DUK_TAG_POINTER:
next_bidx = DUK_BIDX_POINTER_PROTOTYPE;
break;
case DUK_TAG_LIGHTFUNC:
next_bidx = DUK_BIDX_NATIVE_FUNCTION_PROTOTYPE;
break;
default:
DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_recv));
next_bidx = DUK_BIDX_NUMBER_PROTOTYPE;
}
next = thr->builtins[next_bidx];
/* fall thru */
go_next:
return duk__prop_get_str(thr, next, key, idx_out, idx_recv);
}
/*
* Exposed internal APIs.
*/
DUK_INTERNAL duk_bool_t duk_prop_getvalue_strkey_outidx(duk_hthread *thr, duk_idx_t idx_recv, duk_hstring *key, duk_idx_t idx_out) {
#if defined(DUK_USE_ASSERTIONS)
duk_idx_t entry_top;
#endif
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(key != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
#if defined(DUK_USE_ASSERTIONS)
entry_top = duk_get_top(thr);
#endif
if (DUK_UNLIKELY(DUK_HSTRING_HAS_ARRIDX(key))) {
duk_bool_t rc;
rc = duk__prop_getvalue_idxkey_outidx(thr, idx_recv, duk_hstring_get_arridx_fast_known(key), idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
} else {
duk_bool_t rc;
DUK_ASSERT(!DUK_HSTRING_HAS_ARRIDX(key));
rc = duk__prop_getvalue_strkey_outidx(thr, idx_recv, key, idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
}
}
DUK_INTERNAL duk_bool_t duk_prop_getvalue_strkey_push(duk_hthread *thr, duk_idx_t idx_recv, duk_hstring *key) {
#if defined(DUK_USE_ASSERTIONS)
duk_idx_t entry_top;
#endif
duk_idx_t idx_out;
duk_bool_t rc;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(key != NULL);
#if defined(DUK_USE_ASSERTIONS)
entry_top = duk_get_top(thr);
#endif
duk_push_undefined(thr);
idx_out = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom - 1);
rc = duk_prop_getvalue_strkey_outidx(thr, idx_recv, key, idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top + 1);
return rc;
}
DUK_INTERNAL duk_bool_t duk_prop_getvalue_idxkey_outidx(duk_hthread *thr,
duk_idx_t idx_recv,
duk_uarridx_t idx,
duk_idx_t idx_out) {
#if defined(DUK_USE_ASSERTIONS)
duk_idx_t entry_top;
#endif
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT_ARRIDX_VALID(idx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
#if defined(DUK_USE_ASSERTIONS)
entry_top = duk_get_top(thr);
#endif
if (DUK_LIKELY(idx <= DUK_ARRIDX_MAX)) {
duk_bool_t rc = duk__prop_getvalue_idxkey_outidx(thr, idx_recv, idx, idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
} else {
/* This happens for 0xffffffff specifically, which may be
* passed in even from application calls. Another way to
* handle this corner case would be to handle 0xffffffff
* in the arridx path, but then special cases would be
* needed there to avoid arridx special behaviors.
*/
duk_bool_t rc;
duk_hstring *key;
DUK_DD(DUK_DDPRINT("corner case, input idx 0xffffffff is not an arridx, must coerce to string"));
key = duk_push_u32_tohstring(thr, idx);
rc = duk__prop_getvalue_strkey_outidx(thr, idx_recv, key, idx_out);
duk_pop_known(thr);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
}
}
DUK_INTERNAL duk_bool_t duk_prop_getvalue_outidx(duk_hthread *thr, duk_idx_t idx_recv, duk_tval *tv_key, duk_idx_t idx_out) {
#if defined(DUK_USE_ASSERTIONS)
duk_idx_t entry_top;
#endif
duk_bool_t rc;
duk_hstring *key;
duk_uarridx_t idx;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(tv_key != NULL);
/* tv_key may not be in value stack but it must be reachable and
* remain reachable despite arbitrary side effects (e.g. function
* constant table).
*/
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
/* Output index may overlap with receiver or key. */
#if defined(DUK_USE_ASSERTIONS)
entry_top = duk_get_top(thr);
#endif
/* Must check receiver (typically object) and key (typically
* string, symbol, or numeric index) efficiently. Key is coerced
* using ToPropertyKey(), receiver using ToObject(). We want to
* avoid actual receiver coercion if possible.
*
* Specification requires the base is ToObject() coerced before the
* key, but this is inconvenient here. The order doesn't really
* matter unless key coercion has side effects which only happen
* for undefined/null base. So the slow path where key needs actual
* coercion checks undefined/null base which must cause an error
* before key coercion; other ToObject() coercions are side effect
* free.
*
* Expected common key types are: string, Symbol, fastint/number.
* Other keys are rare and not relevant for performance.
*/
#if 0
if (DUK_TVAL_IS_STRING(tv_key)) {
key = DUK_TVAL_GET_STRING(tv_key);
if (DUK_UNLIKELY(DUK_HSTRING_HAS_ARRIDX(key))) {
idx = duk_hstring_get_arridx_fast_known(key);
goto use_idx;
} else {
goto use_str;
}
} else if (DUK_TVAL_IS_FASTINT(tv_key)) {
duk_int64_t fi = DUK_TVAL_GET_FASTINT(tv_key);
if (fi >= 0 && fi <= (duk_int64_t) DUK_ARRIDX_MAX) {
idx = (duk_uarridx_t) fi;
goto use_idx;
}
}
#endif
switch (DUK_TVAL_GET_TAG(tv_key)) {
case DUK_TAG_STRING:
key = DUK_TVAL_GET_STRING(tv_key);
if (DUK_UNLIKELY(DUK_HSTRING_HAS_ARRIDX(key))) {
idx = duk_hstring_get_arridx_fast_known(key);
goto use_idx;
} else {
goto use_str;
}
#if defined(DUK_USE_FASTINT)
case DUK_TAG_FASTINT: {
duk_int64_t fi = DUK_TVAL_GET_FASTINT(tv_key);
if (fi >= 0 && fi <= (duk_int64_t) DUK_ARRIDX_MAX) {
idx = (duk_uarridx_t) fi;
goto use_idx;
}
break;
}
#endif
#if !defined(DUK_USE_PACKED_TVAL)
case DUK_TAG_NUMBER: {
duk_double_t d = DUK_TVAL_GET_DOUBLE(tv_key);
if (duk_prop_double_idx_check(d, &idx)) {
goto use_idx;
}
break;
}
#endif
case DUK_TAG_UNUSED:
case DUK_TAG_UNDEFINED:
case DUK_TAG_NULL:
case DUK_TAG_BOOLEAN:
case DUK_TAG_POINTER:
case DUK_TAG_LIGHTFUNC:
case DUK_TAG_OBJECT:
case DUK_TAG_BUFFER:
break;
default: {
#if defined(DUK_USE_PACKED_TVAL)
duk_double_t d;
DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_key));
#if defined(DUK_USE_FASTINT)
DUK_ASSERT(!DUK_TVAL_IS_FASTINT(tv_key));
#endif
d = DUK_TVAL_GET_DOUBLE(tv_key);
if (duk_prop_double_idx_check(d, &idx)) {
goto use_idx;
}
#endif
break;
}
}
/* We need to coerce the key, and we need temporary value stack
* space to do it. Do it on stack top and pop the coerced key
* afterwards. This is an uncommon case.
*
* We could handle many cases with a fast path, e.g.
* ToPropertyKey(null) is always 'null', but it's probably
* not worth optimizing for in the switch-case above.
*
* Key coercion without storing the original key means that error
* messages can't reference the uncoerced key. This trade-off
* seems acceptable considering the cost of the alternative.
*/
if (DUK_UNLIKELY(duk_is_nullish(thr, idx_recv))) {
/* Must TypeError before key coercion side effects. */
rc = duk__prop_get_error_objidx_tvkey(thr, idx_recv, tv_key);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
}
duk_push_tval(thr, tv_key);
tv_key = NULL;
key = duk_to_property_key_hstring(thr, -1);
DUK_ASSERT(key != NULL);
rc = duk_prop_getvalue_strkey_outidx(thr, idx_recv, key, idx_out);
duk_pop_known(thr);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
use_idx:
DUK_ASSERT_ARRIDX_VALID(idx);
rc = duk__prop_getvalue_idxkey_outidx(thr, idx_recv, idx, idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
use_str:
DUK_ASSERT(!DUK_HSTRING_HAS_ARRIDX(key));
rc = duk__prop_getvalue_strkey_outidx(thr, idx_recv, key, idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
}
DUK_INTERNAL duk_bool_t duk_prop_getvalue_push(duk_hthread *thr, duk_idx_t idx_recv, duk_tval *tv_key) {
#if defined(DUK_USE_ASSERTIONS)
duk_idx_t entry_top;
#endif
duk_bool_t rc;
duk_idx_t idx_out;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT(tv_key != NULL);
#if defined(DUK_USE_ASSERTIONS)
entry_top = duk_get_top(thr);
#endif
duk_push_undefined(thr);
idx_out = duk_get_top_index_known(thr);
rc = duk_prop_getvalue_outidx(thr, idx_recv, tv_key, idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top + 1);
return rc;
}
DUK_INTERNAL duk_bool_t duk_prop_getvalue_stridx_outidx(duk_hthread *thr,
duk_idx_t idx_recv,
duk_small_uint_t stridx,
duk_idx_t idx_out) {
#if defined(DUK_USE_ASSERTIONS)
duk_idx_t entry_top;
#endif
duk_bool_t rc;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT_STRIDX_VALID(stridx);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_out));
#if defined(DUK_USE_ASSERTIONS)
entry_top = duk_get_top(thr);
#endif
rc = duk_prop_getvalue_strkey_outidx(thr, idx_recv, DUK_HTHREAD_GET_STRING(thr, stridx), idx_out);
DUK_ASSERT(duk_get_top(thr) == entry_top);
return rc;
}
DUK_INTERNAL duk_bool_t duk_prop_getvalue_stridx_push(duk_hthread *thr, duk_idx_t idx_recv, duk_small_uint_t stridx) {
#if defined(DUK_USE_ASSERTIONS)
duk_idx_t entry_top;
#endif
duk_bool_t rc;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(duk_is_valid_posidx(thr, idx_recv));
DUK_ASSERT_STRIDX_VALID(stridx);
#if defined(DUK_USE_ASSERTIONS)
entry_top = duk_get_top(thr);
#endif
rc = duk_prop_getvalue_strkey_push(thr, idx_recv, DUK_HTHREAD_GET_STRING(thr, stridx));
DUK_ASSERT(duk_get_top(thr) == entry_top + 1);
return rc;
}
|
31b4fd4987235fcdbce95fd8549bd5379f70fd39
|
a1b303bf34b1938e743738fad9968fb844662c5a
|
/tests/unt_list.h
|
a605f92afe800fe4b5db599ebfe9241cadcf138d
|
[
"MIT"
] |
permissive
|
LeoVen/C-Macro-Collections
|
dd4a2a41b9c01301372e94d565fa18d83244a71d
|
a8735889c76f4c1b65fc306ffd5de92029048197
|
refs/heads/master
| 2023-06-24T23:30:48.323022
| 2023-03-09T15:51:48
| 2023-03-09T15:51:48
| 177,058,533
| 461
| 51
|
MIT
| 2023-06-21T09:17:56
| 2019-03-22T02:33:19
|
C
|
UTF-8
|
C
| false
| false
| 24,292
|
h
|
unt_list.h
|
#ifndef CMC_TESTS_UNT_LIST_H
#define CMC_TESTS_UNT_LIST_H
#include "utl.h"
#define V size_t
#define PFX l
#define SNAME list
#include "cmc/list.h"
struct list_fval *l_fval = &(struct list_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(CMCList, true, {
CMC_CREATE_TEST(new, {
struct list *l = l_new(1000000, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert_not_equals(ptr, NULL, l->buffer);
cmc_assert_equals(size_t, 1000000, l_capacity(l));
cmc_assert_equals(size_t, 0, l_count(l));
l_free(l);
});
CMC_CREATE_TEST(new[capacity = 0], {
struct list *l = l_new(0, l_fval);
cmc_assert_equals(ptr, NULL, l);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct list *l = l_new(UINT64_MAX, l_fval);
cmc_assert_equals(ptr, NULL, l);
});
CMC_CREATE_TEST(clear[count capacity], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 50; i++)
l_push_back(l, i);
cmc_assert_equals(size_t, 50, l_count(l));
l_clear(l);
cmc_assert_equals(size_t, 0, l_count(l));
cmc_assert_equals(size_t, 100, l_capacity(l));
l_free(l);
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct list *l = l_new(1, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 100; i++)
l_push_back(l, i);
cmc_assert_equals(size_t, 100, l_count(l));
for (size_t i = 0; i < 100; i++)
cmc_assert_equals(size_t, i, l_get(l, i));
l_free(l);
});
CMC_CREATE_TEST(push_front[count], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
cmc_assert(l_push_front(l, i));
cmc_assert_equals(size_t, 250, l_count(l));
l_free(l);
});
CMC_CREATE_TEST(push_front[capacity], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
cmc_assert(l_push_front(l, i));
cmc_assert_lesser_equals(size_t, l_capacity(l), l_count(l));
l_free(l);
});
CMC_CREATE_TEST(push_front[item preservation], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
cmc_assert(l_push_front(l, i));
for (size_t i = 0; i < l_count(l); i++)
cmc_assert_equals(size_t, l_get(l, i), l_count(l) - i - 1);
l_free(l);
});
CMC_CREATE_TEST(push_at[count], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 0));
cmc_assert(l_push_back(l, 249));
for (size_t i = 1; i < 249; i++)
cmc_assert(l_push_at(l, i, l_count(l) - 1));
cmc_assert_equals(size_t, 250, l_count(l));
l_free(l);
});
CMC_CREATE_TEST(push_at[capacity], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 0));
cmc_assert(l_push_back(l, 249));
for (size_t i = 1; i < 249; i++)
cmc_assert(l_push_at(l, i, l_count(l) - 1));
cmc_assert_lesser_equals(size_t, l_capacity(l), l_count(l));
l_free(l);
});
CMC_CREATE_TEST(push_at[item preservation], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 0));
cmc_assert(l_push_back(l, 249));
for (size_t i = 1; i < 249; i++)
cmc_assert(l_push_at(l, i, l_count(l) - 1));
for (size_t i = 0; i < l_count(l); i++)
cmc_assert_equals(size_t, l_get(l, i), i);
l_free(l);
});
CMC_CREATE_TEST(push_back[count], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
cmc_assert(l_push_back(l, i));
cmc_assert_equals(size_t, 250, l_count(l));
l_free(l);
});
CMC_CREATE_TEST(push_back[capacity], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
cmc_assert(l_push_back(l, i));
cmc_assert_lesser_equals(size_t, l_capacity(l), l_count(l));
l_free(l);
});
CMC_CREATE_TEST(push_back[item preservation], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
cmc_assert(l_push_back(l, i));
for (size_t i = 0; i < l_count(l); i++)
cmc_assert_equals(size_t, l_get(l, i), i);
l_free(l);
});
CMC_CREATE_TEST(pop_front[count], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
l_push_back(l, i);
cmc_assert(l_pop_front(l));
l_free(l);
});
CMC_CREATE_TEST(pop_front[item preservation], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i < 250; i++)
l_push_back(l, i);
cmc_assert(l_pop_front(l));
for (size_t i = 0; i < l_count(l); i++)
cmc_assert_equals(size_t, l_get(l, i), i + 1);
l_free(l);
});
CMC_CREATE_TEST(pop_front[count = 0], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(!l_pop_front(l));
l_free(l);
});
CMC_CREATE_TEST(pop_front[count = 1], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 10));
cmc_assert(l_pop_front(l));
l_free(l);
});
CMC_CREATE_TEST(pop_front[buffer_clear], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 1));
cmc_assert(l_push_front(l, 2));
cmc_assert(l_pop_front(l));
cmc_assert_equals(size_t, 0, l->buffer[1]);
l_free(l);
});
CMC_CREATE_TEST(pop_at[count = 0], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(!l_pop_at(l, 1));
l_free(l);
});
CMC_CREATE_TEST(pop_at[count = 1], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 1));
cmc_assert(l_pop_at(l, 0));
cmc_assert_equals(size_t, 0, l->buffer[0]);
l_free(l);
});
CMC_CREATE_TEST(pop_at[buffer_clear], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 1));
cmc_assert(l_push_back(l, 2));
cmc_assert(l_push_back(l, 3));
cmc_assert(l_pop_at(l, 1));
l_free(l);
});
CMC_CREATE_TEST(pop_back[count = 0], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(!l_pop_back(l));
l_free(l);
});
CMC_CREATE_TEST(pop_back[count = 1], {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 10));
cmc_assert(l_pop_back(l));
l_free(l);
});
CMC_CREATE_TEST(flags, {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// clear
l->flag = CMC_FLAG_ERROR;
l_clear(l);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// customize
l->flag = CMC_FLAG_ERROR;
l_customize(l, NULL, NULL);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// push_front
l->flag = CMC_FLAG_ERROR;
cmc_assert(l_push_front(l, 10));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// push_at
cmc_assert(!l_push_at(l, 5, 2));
cmc_assert_equals(int32_t, CMC_FLAG_RANGE, l_flag(l));
cmc_assert(l_push_at(l, 5, 1));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// push_back
l->flag = CMC_FLAG_ERROR;
cmc_assert(l_push_back(l, 0));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// pop_front
l->flag = CMC_FLAG_ERROR;
cmc_assert(l_pop_front(l));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
l_clear(l);
cmc_assert(!l_pop_front(l));
cmc_assert_equals(int32_t, CMC_FLAG_EMPTY, l_flag(l));
// pop_back
cmc_assert(l_push_front(l, 10));
l->flag = CMC_FLAG_ERROR;
cmc_assert(l_pop_back(l));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
cmc_assert(!l_pop_front(l));
cmc_assert_equals(int32_t, CMC_FLAG_EMPTY, l_flag(l));
// pop_at
l->flag = CMC_FLAG_ERROR;
cmc_assert(!l_pop_at(l, 0));
cmc_assert_equals(int32_t, CMC_FLAG_EMPTY, l_flag(l));
cmc_assert(l_push_back(l, 10));
cmc_assert(!l_pop_at(l, 1));
cmc_assert_equals(int32_t, CMC_FLAG_RANGE, l_flag(l));
cmc_assert(l_pop_at(l, 0));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// seq_push_front
cmc_assert(!l_seq_push_front(l, NULL, 0));
cmc_assert_equals(int32_t, CMC_FLAG_INVALID, l_flag(l));
cmc_assert(l_seq_push_front(l, (size_t[2]){ 1, 2 }, 2));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// seq_push_at
cmc_assert(!l_seq_push_at(l, NULL, 0, 0));
cmc_assert_equals(int32_t, CMC_FLAG_INVALID, l_flag(l));
cmc_assert(!l_seq_push_at(l, (size_t[2]){ 1, 2 }, 2, 10));
cmc_assert_equals(int32_t, CMC_FLAG_RANGE, l_flag(l));
cmc_assert(l_seq_push_at(l, (size_t[2]){ 1, 2 }, 2, l_count(l) - 1));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// seq_push_back
cmc_assert(!l_seq_push_back(l, NULL, 0));
cmc_assert_equals(int32_t, CMC_FLAG_INVALID, l_flag(l));
cmc_assert(l_seq_push_back(l, (size_t[2]){ 1, 2 }, 2));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// seq_pop_at
cmc_assert(!l_seq_pop_at(l, 10, 1));
cmc_assert_equals(int32_t, CMC_FLAG_INVALID, l_flag(l));
cmc_assert(!l_seq_pop_at(l, 100, 200));
cmc_assert_equals(int32_t, CMC_FLAG_RANGE, l_flag(l));
cmc_assert(l_seq_pop_at(l, 1, l_count(l) - 2));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// seq_sublist
struct list *l2 = l_seq_sublist(l, 10, 1);
cmc_assert_equals(ptr, NULL, l2);
cmc_assert_equals(int32_t, CMC_FLAG_INVALID, l_flag(l));
l2 = l_seq_sublist(l, 100, 200);
cmc_assert_equals(ptr, NULL, l2);
cmc_assert_equals(int32_t, CMC_FLAG_RANGE, l_flag(l));
l2 = l_seq_sublist(l, 0, l_count(l) - 1);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l2));
l_clear(l);
// l_front
l_front(l);
cmc_assert_equals(int32_t, CMC_FLAG_EMPTY, l_flag(l));
cmc_assert(l_push_back(l, 10));
l->flag = CMC_FLAG_ERROR;
l_front(l);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
l_clear(l);
// l_back
l_back(l);
cmc_assert_equals(int32_t, CMC_FLAG_EMPTY, l_flag(l));
cmc_assert(l_push_back(l, 10));
l->flag = CMC_FLAG_ERROR;
l_back(l);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
l_clear(l);
// get, get_ref
l_get(l, 0);
cmc_assert_equals(int32_t, CMC_FLAG_EMPTY, l_flag(l));
l->flag = CMC_FLAG_ERROR;
l_get_ref(l, 0);
cmc_assert_equals(int32_t, CMC_FLAG_EMPTY, l_flag(l));
cmc_assert(l_push_back(l, 10));
l_get(l, 1);
cmc_assert_equals(int32_t, CMC_FLAG_RANGE, l_flag(l));
l->flag = CMC_FLAG_ERROR;
l_get_ref(l, 1);
cmc_assert_equals(int32_t, CMC_FLAG_RANGE, l_flag(l));
l_get(l, 0);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
l->flag = CMC_FLAG_ERROR;
l_get_ref(l, 0);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// index_of
l->flag = CMC_FLAG_ERROR;
l_index_of(l, 10, false);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// contains
l->flag = CMC_FLAG_ERROR;
cmc_assert(l_contains(l, 10));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
// copy_of
l->flag = CMC_FLAG_ERROR;
struct list *l3 = l_copy_of(l);
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l3));
// equals
l->flag = CMC_FLAG_ERROR;
l3->flag = CMC_FLAG_ERROR;
cmc_assert(l_equals(l, l3));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l));
cmc_assert_equals(int32_t, CMC_FLAG_OK, l_flag(l3));
l_free(l);
l_free(l2);
l_free(l3);
});
})
CMC_CREATE_UNIT(CMCListIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_start(l);
cmc_assert_equals(ptr, l, it.target);
cmc_assert_equals(size_t, 0, it.cursor);
cmc_assert_equals(bool, true, it.start);
cmc_assert_equals(bool, true, it.end);
cmc_assert(l_iter_at_start(&it));
cmc_assert(l_iter_at_end(&it));
cmc_assert(l_push_front(l, 1));
cmc_assert(l_push_front(l, 2));
it = l_iter_start(l);
cmc_assert_equals(size_t, 0, it.cursor);
cmc_assert_equals(bool, false, it.end);
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_end(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_end(l);
cmc_assert_equals(ptr, l, it.target);
cmc_assert_equals(size_t, 0, it.cursor);
cmc_assert_equals(bool, true, it.start);
cmc_assert_equals(bool, true, it.end);
cmc_assert(l_iter_at_start(&it));
cmc_assert(l_iter_at_end(&it));
cmc_assert(l_push_back(l, 1));
cmc_assert(l_push_back(l, 2));
cmc_assert(l_push_back(l, 3));
it = l_iter_end(l);
cmc_assert_equals(size_t, l->count - 1, it.cursor);
cmc_assert_equals(bool, false, it.start);
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_at_start(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_start(l);
// Empty checks
cmc_assert(l_iter_at_start(&it));
it = l_iter_end(l);
cmc_assert(l_iter_at_start(&it));
// Non-empty checks
cmc_assert(l_push_back(l, 1));
it = l_iter_end(l);
cmc_assert(!l_iter_at_start(&it));
it = l_iter_start(l);
cmc_assert(l_iter_at_start(&it));
l_clear(l);
cmc_assert(l_push_front(l, 1));
it = l_iter_end(l);
cmc_assert(!l_iter_at_start(&it));
it = l_iter_start(l);
cmc_assert(l_iter_at_start(&it));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_at_end(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_start(l);
// Empty check
cmc_assert(l_iter_at_end(&it));
it = l_iter_end(l);
cmc_assert(l_iter_at_end(&it));
// Non-empty checks
cmc_assert(l_push_back(l, 1));
it = l_iter_end(l);
cmc_assert(l_iter_at_end(&it));
it = l_iter_start(l);
cmc_assert(!l_iter_at_end(&it));
l_clear(l);
cmc_assert(l_push_front(l, 1));
it = l_iter_end(l);
cmc_assert(l_iter_at_end(&it));
it = l_iter_start(l);
cmc_assert(!l_iter_at_end(&it));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_to_start(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_start(l);
cmc_assert(!l_iter_to_start(&it));
for (size_t i = 1; i <= 100; i++)
{
if (i % 2 == 0)
l_push_back(l, i);
else
l_push_front(l, i);
}
cmc_assert_equals(size_t, 100, l->count);
it = l_iter_end(l);
cmc_assert(!l_iter_at_start(&it));
cmc_assert(l_iter_at_end(&it));
cmc_assert_equals(size_t, 100, l_iter_value(&it));
cmc_assert(l_iter_to_start(&it));
cmc_assert(l_iter_at_start(&it));
cmc_assert(!l_iter_at_end(&it));
cmc_assert_equals(size_t, 99, l_iter_value(&it));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_to_end(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_end(l);
cmc_assert(!l_iter_to_end(&it));
for (size_t i = 1; i <= 100; i++)
{
if (i % 2 == 0)
l_push_back(l, i);
else
l_push_front(l, i);
}
it = l_iter_start(l);
cmc_assert(l_iter_at_start(&it));
cmc_assert(!l_iter_at_end(&it));
cmc_assert_equals(size_t, 99, l_iter_value(&it));
cmc_assert(l_iter_to_end(&it));
cmc_assert(!l_iter_at_start(&it));
cmc_assert(l_iter_at_end(&it));
cmc_assert_equals(size_t, 100, l_iter_value(&it));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_next(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_start(l);
cmc_assert(!l_iter_next(&it));
for (size_t i = 1; i <= 1000; i++)
{
if (i % 2 == 0)
l_push_back(l, i);
else
l_push_front(l, i);
}
size_t sum = 0;
for (it = l_iter_start(l); !l_iter_at_end(&it); l_iter_next(&it))
{
sum += l_iter_value(&it);
}
cmc_assert_equals(size_t, 500500, sum);
sum = 0;
l_iter_to_start(&it);
do
{
sum += l_iter_value(&it);
} while (l_iter_next(&it));
cmc_assert_equals(size_t, 500500, sum);
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_prev(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_end(l);
cmc_assert(!l_iter_prev(&it));
for (size_t i = 1; i <= 1000; i++)
{
if (i % 2 == 0)
l_push_back(l, i);
else
l_push_front(l, i);
}
size_t sum = 0;
for (it = l_iter_end(l); !l_iter_at_start(&it); l_iter_prev(&it))
{
sum += l_iter_value(&it);
}
cmc_assert_equals(size_t, 500500, sum);
sum = 0;
l_iter_to_end(&it);
do
{
sum += l_iter_value(&it);
} while (l_iter_prev(&it));
cmc_assert_equals(size_t, 500500, sum);
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_advance(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_start(l);
cmc_assert(!l_iter_advance(&it, 1));
for (size_t i = 0; i <= 1000; i++)
{
if (i % 2 == 0)
l_push_back(l, i); // will sum all even numbers
else
l_push_back(l, 0);
}
it = l_iter_start(l);
cmc_assert(!l_iter_advance(&it, 0));
cmc_assert(!l_iter_advance(&it, l->count));
size_t sum = 0;
for (it = l_iter_start(l);;)
{
sum += l_iter_value(&it);
if (!l_iter_advance(&it, 2))
break;
}
cmc_assert_equals(size_t, 250500, sum);
l_iter_to_start(&it);
cmc_assert(l_iter_advance(&it, l->count - 1));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_rewind(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_end(l);
cmc_assert(!l_iter_rewind(&it, 1));
for (size_t i = 0; i <= 1000; i++)
{
if (i % 2 == 0)
l_push_front(l, i); // will sum all even numbers
else
l_push_front(l, 0);
}
it = l_iter_end(l);
cmc_assert(!l_iter_rewind(&it, 0));
cmc_assert(!l_iter_rewind(&it, l->count));
size_t sum = 0;
for (it = l_iter_end(l);;)
{
sum += l_iter_value(&it);
if (!l_iter_rewind(&it, 2))
break;
}
cmc_assert_equals(size_t, 250500, sum);
l_iter_to_end(&it);
cmc_assert(l_iter_rewind(&it, l->count - 1));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_go_to(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_end(l);
cmc_assert(!l_iter_go_to(&it, 0));
it = l_iter_start(l);
cmc_assert(!l_iter_go_to(&it, 0));
for (size_t i = 0; i <= 1000; i++)
l_push_back(l, i);
it = l_iter_start(l);
size_t sum = 0;
for (size_t i = 0; i < 1001; i++)
{
l_iter_go_to(&it, i);
sum += l_iter_value(&it);
}
cmc_assert_equals(size_t, 500500, sum);
sum = 0;
for (size_t i = 1001; i > 0; i--)
{
cmc_assert(l_iter_go_to(&it, i - 1));
sum += l_iter_value(&it);
}
cmc_assert_equals(size_t, 500500, sum);
sum = 0;
for (size_t i = 0; i < 1001; i += 100)
{
cmc_assert(l_iter_go_to(&it, i));
cmc_assert_equals(size_t, i, l_iter_index(&it));
sum += l_iter_value(&it);
}
cmc_assert_equals(size_t, 5500, sum);
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_value(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_end(l);
cmc_assert_equals(size_t, (size_t){ 0 }, l_iter_value(&it));
cmc_assert(l_push_back(l, 10));
it = l_iter_start(l);
cmc_assert_equals(size_t, 10, l_iter_value(&it));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_rvalue(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
struct list_iter it = l_iter_end(l);
cmc_assert_equals(ptr, NULL, l_iter_rvalue(&it));
cmc_assert(l_push_back(l, 10));
it = l_iter_start(l);
cmc_assert_not_equals(ptr, NULL, l_iter_rvalue(&it));
cmc_assert_equals(size_t, 10, *l_iter_rvalue(&it));
l_free(l);
});
CMC_CREATE_TEST(PFX##_iter_index(), {
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
for (size_t i = 0; i <= 1000; i++)
l_push_back(l, i);
struct list_iter it = l_iter_start(l);
for (size_t i = 0; i < 1001; i++)
{
cmc_assert_equals(size_t, i, l_iter_index(&it));
l_iter_next(&it);
}
it = l_iter_end(l);
for (size_t i = 1001; i > 0; i--)
{
cmc_assert_equals(size_t, i - 1, l_iter_index(&it));
l_iter_prev(&it);
}
l_free(l);
});
});
#endif /* CMC_TESTS_UNT_LIST_H */
|
98f233477cae157410b9b740f158e5f218595ca7
|
1a286fb8ff1379a6aaf384454a1a6e0e9f1cd540
|
/src/pal/src/ocalls/signal.c
|
941e890fd4236bfc4bcc446149b0adaa57b58ef7
|
[
"BSD-3-Clause"
] |
permissive
|
occlum/occlum
|
3122bbb097b6eba5de8cb0e80ac233bc86688d67
|
56f7ab02a56fa2863db4d390116c894f9f127dcb
|
refs/heads/master
| 2023-08-25T12:23:45.041070
| 2023-08-24T03:09:43
| 2023-08-24T11:47:09
| 157,422,219
| 1,265
| 235
|
NOASSERTION
| 2023-09-14T08:01:19
| 2018-11-13T17:49:56
|
Rust
|
UTF-8
|
C
| false
| false
| 151
|
c
|
signal.c
|
#include "ocalls.h"
int occlum_ocall_tkill(int tid, int signum) {
int tgid = getpid();
int ret = TGKILL(tgid, tid, signum);
return ret;
}
|
e6920d5b119294f5e7134996bbc78efefd15bea5
|
70aeae7ed891a5f34b87f5c7157256712ea53f91
|
/!Other Gits/Phire - centurion_isa-main/c_mon/reg.c
|
f2e4183a72108f2bf97cb5782a4e1729116da17d
|
[] |
no_license
|
Nakazoto/CenturionComputer
|
aa8cb9fd4020f5290a26512b9751ed0cedef11eb
|
1326e34e9106e99ca74622e41a367acd7e6794d1
|
refs/heads/main
| 2023-08-13T02:26:01.567219
| 2023-07-27T18:46:53
| 2023-07-27T18:46:53
| 393,861,784
| 115
| 11
| null | 2022-11-28T17:30:29
| 2021-08-08T04:59:13
|
C
|
UTF-8
|
C
| false
| false
| 887
|
c
|
reg.c
|
#include "reg.h"
static char regs[16] = "wxyzrtklmnspghij";
u8 parse_reg(u8 word) {
char *idx = regs;
char c = POP_CHAR;
for (u8 i = 0; ; i++) {
if (c == *idx++) {
break;
}
if (i > 15) {
error("Invalid register");
return 0;
}
}
if (word) {
if (POP_CHAR != *idx) {
error("Invalid 16bit register");
return 0;
}
}
idx--;
return idx - regs;
}
s16 maybe_parse_reg(u8 word) {
char *idx = regs;
char c = POP_CHAR;
for (u8 i = 0; ; i++) {
if (c == *idx++) {
break;
}
if (i > 15) {
RETURN_CHAR(1);
return -1;
}
}
if (word) {
if (POP_CHAR != *idx) {
RETURN_CHAR(2);
return -1;
}
}
idx--;
return idx - regs;
}
|
6f561d2d3132c568fa766b99eeace834cabbd981
|
19a9f2c19bcb81c4a14ba17831d3098de7731fb5
|
/ncarg2d/src/libncarg_gks/cdrivers/crotiff.h
|
0b496da12009fa6dc633777a0d2d778ba857b9ac
|
[
"Apache-2.0"
] |
permissive
|
NCAR/ncl
|
243c30eaefce642d53373aa583b73df72eb59f22
|
8a96101fe14d0cf0f5ed66a5e6b1733084bc69df
|
refs/heads/develop
| 2023-03-17T07:53:18.883458
| 2022-05-11T16:01:03
| 2022-05-11T16:01:03
| 67,087,395
| 254
| 68
|
NOASSERTION
| 2022-10-08T07:20:06
| 2016-09-01T01:34:28
|
C
|
UTF-8
|
C
| false
| false
| 950
|
h
|
crotiff.h
|
/*
* File: crotiff.h
* Author: brownrig
*
* Created on March 4, 2015, 10:27 AM
*/
#ifndef CROTIFF_H
#define CROTIFF_H
#ifdef __cplusplus
extern "C" {
#endif
struct cairo_surface_t;
typedef struct TiffHandle {
FILE* filePtr;
long nextIFDPointer;
} TiffHandle;
typedef struct TiffGeoReference {
int projCode;
float worldX[4];
float worldY[4];
float ndcX[4];
float ndcY[4];
float meridian;
float stdPar1;
float stdPar2;
} TiffGeoReference;
extern TiffHandle* crotiff_openFile(const char* filename);
extern void crotiff_closeFile(TiffHandle* closure);
extern int crotiff_writeImage(TiffHandle* closure, TiffGeoReference* georef, cairo_surface_t* surface);
extern int crotiff_writeImageCompressed(TiffHandle* closure, TiffGeoReference* georef, cairo_surface_t* surface);
#ifdef __cplusplus
}
#endif
#endif /* CROTIFF_H */
|
3b9ce1610930287d11e774f112cec21134f786a2
|
03666e5f961946fc1a0ac67781ac1425562ef0d7
|
/src/operators/DataBinning/DataBinningViewerPluginInfo.C
|
2dc12f02f4e4cd6b6df19bbc0389c1735aee1b4c
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
visit-dav/visit
|
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
|
601ae46e0bef2e18425b482a755d03490ade0493
|
refs/heads/develop
| 2023-09-06T08:19:38.397058
| 2023-09-05T21:29:32
| 2023-09-05T21:29:32
| 165,565,988
| 335
| 120
|
BSD-3-Clause
| 2023-09-14T00:53:37
| 2019-01-13T23:27:26
|
C
|
UTF-8
|
C
| false
| false
| 549
|
c
|
DataBinningViewerPluginInfo.C
|
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers. See the top-level LICENSE file for dates and other
// details. No copyright assignment is required to contribute to VisIt.
// ****************************************************************************
// File: DataBinningViewerPluginInfo.C
// ****************************************************************************
#include <DataBinningPluginInfo.h>
#include <DataBinningAttributes.h>
VISIT_OPERATOR_PLUGIN_ENTRY_EV(DataBinning,Viewer)
|
e36531a6db7edf1d3b563d6b1eadb0626dd5f3a4
|
7b92efd7dfb60d9b0a498871d5ffa699d0cf7d9e
|
/src/ext/card10/l0dables/support.c
|
90e14efae767c0a752639c2c757fd97b880cbded
|
[
"ISC"
] |
permissive
|
shinyblink/sled
|
854499be7c589b2d705050b41b8324ed66948e45
|
9d8e60ccbf6d8a30db83f41a8a4435d4c6b317a1
|
refs/heads/master
| 2023-07-24T08:30:03.348039
| 2023-07-08T14:00:54
| 2023-07-08T22:17:15
| 115,367,599
| 107
| 20
|
ISC
| 2023-07-08T22:17:17
| 2017-12-25T23:06:04
|
C
|
UTF-8
|
C
| false
| false
| 3,359
|
c
|
support.c
|
/*
* FreeRTOS support functions
*/
#include "FreeRTOS.h"
#include "task.h"
#include "api/dispatcher.h"
#include "modules/log.h"
#include "card10.h"
extern TaskHandle_t dispatcher_task_id;
/*
* This hook is called before FreeRTOS enters tickless idle.
*/
void pre_idle_sleep(TickType_t xExpectedIdleTime)
{
if (xExpectedIdleTime > 0) {
/*
* WFE because the other core should be able to notify
* epicardium if it wants to issue an API call.
*/
/*
* TODO: Ensure this is actually correct and does not have any
* race conditions.
*/
if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
__asm volatile("dsb" ::: "memory");
__asm volatile("wfe");
__asm volatile("isb");
}
}
}
/*
* This hook is called after FreeRTOS exits tickless idle.
*/
void post_idle_sleep(TickType_t xExpectedIdleTime)
{
/* Check whether a new API call was issued. */
if (api_dispatcher_poll_once()) {
xTaskNotifyGive(dispatcher_task_id);
}
/*
* Do card10 house keeping. e.g. polling the i2c devices if they
* triggered an interrupt.
*
* TODO: Do this in a more task focused way (high/low ISR)
*/
card10_poll();
}
void vApplicationGetIdleTaskMemory(
StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer,
uint32_t *pulIdleTaskStackSize
) {
/*
* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits.
*/
static StaticTask_t xIdleTaskTCB;
static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];
/*
* Pass out a pointer to the StaticTask_t structure in which the Idle task's
* ktate will be stored.
*/
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
/* Pass out the array that will be used as the Idle task's stack. */
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
/*
* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes.
*/
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
void vApplicationGetTimerTaskMemory(
StaticTask_t **ppxTimerTaskTCBBuffer,
StackType_t **ppxTimerTaskStackBuffer,
uint32_t *pulTimerTaskStackSize
) {
/*
* If the buffers to be provided to the Timer task are declared inside
* this function then they must be declared static - otherwise they will
* be allocated on the stack and so not exists after this function
* exits.
*/
static StaticTask_t xTimerTaskTCB;
static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
/*
* Pass out a pointer to the StaticTask_t structure in which the Timer
* task's state will be stored.
*/
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
/* Pass out the array that will be used as the Timer task's stack. */
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
/*
* Pass out the size of the array pointed to by
* *ppxTimerTaskStackBuffer. Note that, as the array is necessarily of
* type StackType_t, configMINIMAL_STACK_SIZE is specified in words, not
* bytes.
*/
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName)
{
LOG_CRIT("rtos", "Task \"%s\" overflowed stack!", pcTaskName);
}
|
75eb4cacbcddafce493a1f637bdf1ea840aa0d7c
|
662e36112643697e4f40b036a91c37436e3256d0
|
/aslam_cv2/aslam_cv_detector/include/kaze/KAZEConfig.h
|
a1f942372fbd6aed919dda9708044ccaf8d54d7b
|
[
"Apache-2.0"
] |
permissive
|
ethz-asl/maplab
|
ca9e2cacd2fbaf9dac22b455e24a179f8613729a
|
0b4868efeb292851d71f98d31a1e6bb40ebb244b
|
refs/heads/master
| 2023-08-28T16:19:16.241444
| 2023-06-18T21:36:18
| 2023-06-18T21:36:18
| 112,253,403
| 2,488
| 755
|
Apache-2.0
| 2023-06-18T21:36:19
| 2017-11-27T21:58:23
|
C++
|
UTF-8
|
C
| false
| false
| 3,742
|
h
|
KAZEConfig.h
|
/**
* @file KAZEConfig.h
* @brief KAZE configuration file
* @date Dec 11, 2014
* @author Pablo F. Alcantarilla
*/
#pragma once
/* ************************************************************************* */
// OpenCV
#include <opencv2/core/core.hpp>
// OpenMP
#ifdef _OPENMP
#include <omp.h>
#define OMP_MAX_THREADS 16
#endif
/* ************************************************************************* */
/// KAZE Descriptor Type
enum DESCRIPTOR_TYPE {
SURF_UPRIGHT = 0, ///< Not rotation invariant descriptor, SURF grid, length 64
SURF = 1, ///< Rotation invariant descriptor, SURF grid, length 64
SURF_EXTENDED_UPRIGHT = 2, ///< Not rotation invariant descriptor, SURF grid, length 128
SURF_EXTENDED = 3, ///< Rotation invariant descriptor, SURF grid, length 128
MSURF_UPRIGHT = 4, ///< Not rotation invariant descriptor, M-SURF grid, length 64
MSURF = 5, ///< Rotation invariant descriptor, M-SURF grid, length 64
MSURF_EXTENDED_UPRIGHT = 6, ///< Not rotation invariant descriptor, M-SURF grid, length 128
MSURF_EXTENDED = 7, ///< Rotation invariant descriptor, M-SURF grid, length 128
GSURF_UPRIGHT = 8, ///< Not rotation invariant descriptor, G-SURF grid, length 64
GSURF = 9, ///< Rotation invariant descriptor, G-SURF grid, length 64
GSURF_EXTENDED_UPRIGHT = 10, ///< Not rotation invariant descriptor, G-SURF grid, length 128
GSURF_EXTENDED = 11 ///< Rotation invariant descriptor, G-SURF grid, length 128
};
/* ************************************************************************* */
/// KAZE Diffusivities
enum DIFFUSIVITY_TYPE {
PM_G1 = 0,
PM_G2 = 1,
WEICKERT = 2,
CHARBONNIER = 3
};
/* ************************************************************************* */
/// KAZE configuration options struct
struct KAZEOptions {
KAZEOptions() {
soffset = 1.60;
omax = 4;
nsublevels = 4;
dthreshold = 0.001;
min_dthreshold = 0.000001f;
use_fed = true;
descriptor = MSURF;
diffusivity = PM_G2;
sderivatives = 1.0;
kcontrast = 0.001f;
kcontrast_percentile = 0.7f;
kcontrast_nbins = 300;
save_scale_space = false;
save_keypoints = false;
verbosity = false;
}
float soffset;
int omax;
int nsublevels;
int img_width;
int img_height;
DIFFUSIVITY_TYPE diffusivity; ///< Diffusivity type
float kcontrast; ///< The contrast factor parameter
float kcontrast_percentile; ///< Percentile level for the contrast factor
size_t kcontrast_nbins; ///< Number of bins for the contrast factor histogram
float sderivatives;
float dthreshold; ///< Detector response threshold to accept point
float min_dthreshold; ///< Minimum detector threshold to accept a point
bool use_fed;
DESCRIPTOR_TYPE descriptor;
bool save_scale_space;
bool save_keypoints;
bool verbosity;
};
/* ************************************************************************* */
/// KAZE nonlinear diffusion filtering evolution
struct TEvolution {
cv::Mat Lx, Ly; ///< First order spatial derivatives
cv::Mat Lxx, Lxy, Lyy; ///< Second order spatial derivatives
cv::Mat Lt; ///< Evolution image
cv::Mat Lsmooth; ///< Smoothed image
cv::Mat Ldet; ///< Detector response
float etime; ///< Evolution time
float esigma; ///< Evolution sigma. For linear diffusion t = sigma^2 / 2
int octave; ///< Image octave
int sublevel; ///< Image sublevel in each octave
int sigma_size; ///< Integer esigma. For computing the feature detector responses
};
|
437303305395b2622b83b83758b680bf908067df
|
9eedaea06306b20520151321854f989a73c7daf8
|
/test/testautomation_main.c
|
7c350eda1530cdd4ced8a0eb02b93bd7054e23b6
|
[
"OFL-1.1",
"LicenseRef-scancode-public-domain",
"Zlib"
] |
permissive
|
libsdl-org/SDL
|
cf56bdc8a9e198e9735201674118c822d0e3edf3
|
8387fae698745969ce366c4de9bcc1b4a364a7dd
|
refs/heads/main
| 2023-09-04T06:58:34.316952
| 2023-09-03T15:11:13
| 2023-09-03T15:11:13
| 330,008,801
| 6,912
| 1,605
|
Zlib
| 2023-09-13T19:12:26
| 2021-01-15T19:55:54
|
C
|
UTF-8
|
C
| false
| false
| 5,522
|
c
|
testautomation_main.c
|
/**
* Automated SDL subsystems management test.
*
* Written by J�rgen Tjern� "jorgenpt"
*
* Released under Public Domain.
*/
#include <SDL3/SDL.h>
#include <SDL3/SDL_test.h>
#include "testautomation_suites.h"
/**
* \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem()
* \sa SDL_Init
* \sa SDL_Quit
*/
static int main_testInitQuitSubSystem(void *arg)
{
int i;
int subsystems[] = { SDL_INIT_JOYSTICK, SDL_INIT_HAPTIC, SDL_INIT_GAMEPAD };
for (i = 0; i < SDL_arraysize(subsystems); ++i) {
int initialized_system;
int subsystem = subsystems[i];
SDLTest_AssertCheck((SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) before init should be false", subsystem);
SDLTest_AssertCheck(SDL_InitSubSystem(subsystem) == 0, "SDL_InitSubSystem(%x)", subsystem);
initialized_system = SDL_WasInit(subsystem);
SDLTest_AssertCheck((initialized_system & subsystem) != 0, "SDL_WasInit(%x) should be true (%x)", subsystem, initialized_system);
SDL_QuitSubSystem(subsystem);
SDLTest_AssertCheck((SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) after shutdown should be false", subsystem);
}
return TEST_COMPLETED;
}
static const int joy_and_controller = SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD;
static int main_testImpliedJoystickInit(void *arg)
{
int initialized_system;
/* First initialize the controller */
SDLTest_AssertCheck((SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD) == 0, "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
/* Then make sure this implicitly initialized the joystick subsystem */
initialized_system = SDL_WasInit(joy_and_controller);
SDLTest_AssertCheck((initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system);
/* Then quit the controller, and make sure that implicitly also quits the */
/* joystick subsystem */
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
initialized_system = SDL_WasInit(joy_and_controller);
SDLTest_AssertCheck((initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system);
return TEST_COMPLETED;
}
static int main_testImpliedJoystickQuit(void *arg)
{
int initialized_system;
/* First initialize the controller and the joystick (explicitly) */
SDLTest_AssertCheck((SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD) == 0, "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
/* Then make sure they're both initialized properly */
initialized_system = SDL_WasInit(joy_and_controller);
SDLTest_AssertCheck((initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system);
/* Then quit the controller, and make sure that it does NOT quit the */
/* explicitly initialized joystick subsystem. */
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
initialized_system = SDL_WasInit(joy_and_controller);
SDLTest_AssertCheck((initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system);
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return TEST_COMPLETED;
}
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#endif
static int
main_testSetError(void *arg)
{
size_t i;
char error[1024];
error[0] = '\0';
SDL_SetError("");
SDLTest_AssertCheck(SDL_strcmp(error, SDL_GetError()) == 0, "SDL_SetError(\"\")");
for (i = 0; i < (sizeof(error) - 1); ++i) {
error[i] = 'a' + (i % 26);
}
error[i] = '\0';
SDL_SetError("%s", error);
SDLTest_AssertCheck(SDL_strcmp(error, SDL_GetError()) == 0, "SDL_SetError(\"abc...1023\")");
return TEST_COMPLETED;
}
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
static const SDLTest_TestCaseReference mainTest1 = {
(SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED
};
static const SDLTest_TestCaseReference mainTest2 = {
(SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED
};
static const SDLTest_TestCaseReference mainTest3 = {
(SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED
};
static const SDLTest_TestCaseReference mainTest4 = {
(SDLTest_TestCaseFp)main_testSetError, "main_testSetError", "Tests that SDL_SetError() handles arbitrarily large strings", TEST_ENABLED
};
/* Sequence of Main test cases */
static const SDLTest_TestCaseReference *mainTests[] = {
&mainTest1,
&mainTest2,
&mainTest3,
&mainTest4,
NULL
};
/* Main test suite (global) */
SDLTest_TestSuiteReference mainTestSuite = {
"Main",
NULL,
mainTests,
NULL
};
|
6d7b5528ebc40a61074cac57786a1badc303397b
|
baa9fffc817a2a993d4ecc774d3f277783308c20
|
/examples/cmake/test_uct.c
|
7e88d7921998dddca19b976effad06c7c92c2399
|
[
"BSD-3-Clause"
] |
permissive
|
openucx/ucx
|
9a0f2205295afbdf3cff14b5d24af781b123f5ea
|
73a48700badb7cbace64d94b82f408e2a26fca32
|
refs/heads/master
| 2023-09-01T16:51:26.913950
| 2023-09-01T13:02:25
| 2023-09-01T13:02:25
| 25,379,390
| 966
| 420
|
NOASSERTION
| 2023-09-14T12:29:35
| 2014-10-17T22:17:24
|
C
|
UTF-8
|
C
| false
| false
| 646
|
c
|
test_uct.c
|
/**
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2021. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
#include <uct/api/uct.h>
#include <assert.h>
int main(int argc, char **argv)
{
ucs_async_context_t *async;
uct_worker_h worker;
/* Initialize context */
ucs_status_t status = ucs_async_context_create(UCS_ASYNC_MODE_THREAD_SPINLOCK, &async);
assert(UCS_OK == status);
/* Create a worker object */
status = uct_worker_create(async, UCS_THREAD_MODE_SINGLE, &worker);
assert(UCS_OK == status);
/* Cleanup */
uct_worker_destroy(worker);
ucs_async_context_destroy(async);
return 0;
}
|
23453fe992bdb25f187ed0e1f673143d3e387e95
|
03666e5f961946fc1a0ac67781ac1425562ef0d7
|
/src/databases/AMR/AMRconfigure.h
|
fe40ffa12905672cf7d2d6ba7a247c2eaf6768b8
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
visit-dav/visit
|
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
|
601ae46e0bef2e18425b482a755d03490ade0493
|
refs/heads/develop
| 2023-09-06T08:19:38.397058
| 2023-09-05T21:29:32
| 2023-09-05T21:29:32
| 165,565,988
| 335
| 120
|
BSD-3-Clause
| 2023-09-14T00:53:37
| 2019-01-13T23:27:26
|
C
|
UTF-8
|
C
| false
| false
| 67
|
h
|
AMRconfigure.h
|
// if aggregate leaf blocks
#define USING_AGG
#define USING_OCTKEY
|
200444e6b35646df52bdb730dfe72c61ed0d0488
|
131b6d5381fc3bb4403682135b77f9bce91e79f1
|
/nx/source/services/set.c
|
4b3904943b048399fc09f2983f2eff88eea7386c
|
[
"ISC"
] |
permissive
|
switchbrew/libnx
|
53deb695b9ee6f3981c559125e8fce3bce6852b7
|
4fcdb6eb34b20f1f65eb9791fe513a710a001bea
|
refs/heads/master
| 2023-08-28T17:00:22.025929
| 2023-08-11T04:11:38
| 2023-08-12T14:51:58
| 103,794,142
| 1,286
| 299
|
ISC
| 2023-09-09T12:08:36
| 2017-09-17T01:12:38
|
C
|
UTF-8
|
C
| false
| false
| 60,770
|
c
|
set.c
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
#include <string.h>
#include "service_guard.h"
#include "runtime/hosversion.h"
#include "services/set.h"
#include "services/applet.h"
static Service g_setSrv;
static Service g_setsysSrv;
static Service g_setcalSrv;
static bool g_setLanguageCodesInitialized;
static u64 g_setLanguageCodes[0x40];
static s32 g_setLanguageCodesTotal;
static Result _setMakeLanguageCode(s32 Language, u64 *LanguageCode);
NX_GENERATE_SERVICE_GUARD(set);
Result _setInitialize(void) {
g_setLanguageCodesInitialized = 0;
return smGetService(&g_setSrv, "set");
}
void _setCleanup(void) {
serviceClose(&g_setSrv);
}
Service* setGetServiceSession(void) {
return &g_setSrv;
}
NX_GENERATE_SERVICE_GUARD(setsys);
Result _setsysInitialize(void) {
return smGetService(&g_setsysSrv, "set:sys");
}
void _setsysCleanup(void) {
serviceClose(&g_setsysSrv);
}
Service* setsysGetServiceSession(void) {
return &g_setsysSrv;
}
NX_GENERATE_SERVICE_GUARD(setcal);
Result _setcalInitialize(void) {
return smGetService(&g_setcalSrv, "set:cal");
}
void _setcalCleanup(void) {
serviceClose(&g_setcalSrv);
}
Service* setcalGetServiceSession(void) {
return &g_setcalSrv;
}
static Result _setCmdGetHandle(Service* srv, Handle* handle_out, u32 cmd_id) {
return serviceDispatch(srv, cmd_id,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
.out_handles = handle_out,
);
}
static Result _setCmdGetEvent(Service* srv, Event* out_event, bool autoclear, u32 cmd_id) {
Handle tmp_handle = INVALID_HANDLE;
Result rc = 0;
rc = _setCmdGetHandle(srv, &tmp_handle, cmd_id);
if (R_SUCCEEDED(rc)) eventLoadRemote(out_event, tmp_handle, autoclear);
return rc;
}
static Result _setCmdNoInOut64(Service* srv, u64 *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out);
}
static Result _setCmdNoInOutU32(Service* srv, u32 *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out);
}
static Result _setCmdNoInOutU8(Service* srv, u8 *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out);
}
static Result _setCmdNoInOutBool(Service* srv, bool *out, u32 cmd_id) {
u8 tmp=0;
Result rc = _setCmdNoInOutU8(srv, &tmp, cmd_id);
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
return rc;
}
static Result _setCmdNoInOutUuid(Service* srv, Uuid *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out);
}
static Result _setCmdInU8NoOut(Service* srv, u8 inval, u64 cmd_id) {
return serviceDispatchIn(srv, cmd_id, inval);
}
static Result _setCmdInBoolNoOut(Service* srv, bool inval, u32 cmd_id) {
return _setCmdInU8NoOut(srv, inval!=0, cmd_id);
}
static Result _setCmdInU32NoOut(Service* srv, u32 inval, u32 cmd_id) {
return serviceDispatchIn(srv, cmd_id, inval);
}
static Result _setCmdInU64NoOut(Service* srv, u64 inval, u32 cmd_id) {
return serviceDispatchIn(srv, cmd_id, inval);
}
static Result _setCmdInUuidNoOut(Service* srv, const Uuid *inval, u32 cmd_id) {
return serviceDispatchIn(srv, cmd_id, *inval);
}
static Result _setCmdOutBufAliasFixed(Service* srv, void* buffer, size_t size, u32 cmd_id) {
return serviceDispatch(srv, cmd_id,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out | SfBufferAttr_FixedSize },
.buffers = { { buffer, size } },
);
}
static Result setInitializeLanguageCodesCache(void) {
if (g_setLanguageCodesInitialized) return 0;
Result rc = 0;
rc = setGetAvailableLanguageCodes(&g_setLanguageCodesTotal, g_setLanguageCodes, sizeof(g_setLanguageCodes)/sizeof(u64));
if (R_FAILED(rc)) return rc;
if (g_setLanguageCodesTotal < 0) g_setLanguageCodesTotal = 0;
g_setLanguageCodesInitialized = 1;
return rc;
}
Result setMakeLanguage(u64 LanguageCode, SetLanguage *Language) {
Result rc = setInitializeLanguageCodesCache();
if (R_FAILED(rc)) return rc;
s32 i;
rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
for (i=0; i<g_setLanguageCodesTotal; i++) {
if (g_setLanguageCodes[i] == LanguageCode) {
*Language = i;
return 0;
}
}
return rc;
}
Result setMakeLanguageCode(SetLanguage Language, u64 *LanguageCode) {
Result rc = setInitializeLanguageCodesCache();
if (R_FAILED(rc)) return rc;
if (Language < 0)
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
if (Language >= g_setLanguageCodesTotal) {
if (hosversionBefore(4,0,0)) return MAKERESULT(Module_Libnx, LibnxError_BadInput);
return _setMakeLanguageCode(Language, LanguageCode);
}
*LanguageCode = g_setLanguageCodes[Language];
return rc;
}
Result setGetSystemLanguage(u64 *LanguageCode) {
//This is disabled because the returned LanguageCode can differ from the system language, for example ja instead of {English}.
/*Result rc = appletGetDesiredLanguage(LanguageCode);
if (R_SUCCEEDED(rc)) return rc;*/
return setGetLanguageCode(LanguageCode);
}
Result setGetLanguageCode(u64 *LanguageCode) {
return _setCmdNoInOut64(&g_setSrv, LanguageCode, 0);
}
Result setGetAvailableLanguageCodes(s32 *total_entries, u64 *LanguageCodes, size_t max_entries) {
Result rc=0;
bool new_cmd = hosversionAtLeast(4,0,0);
if (!new_cmd) {//On system-version <4.0.0 the sysmodule will close the session if max_entries is too large.
s32 tmptotal = 0;
rc = setGetAvailableLanguageCodeCount(&tmptotal);
if (R_FAILED(rc)) return rc;
if (max_entries > (size_t)tmptotal) max_entries = (size_t)tmptotal;
}
return serviceDispatchOut(&g_setSrv, new_cmd ? 5 : 1, *total_entries,
.buffer_attrs = { (new_cmd ? SfBufferAttr_HipcMapAlias : SfBufferAttr_HipcPointer) | SfBufferAttr_Out },
.buffers = { { LanguageCodes, max_entries*sizeof(u64) } },
);
}
static Result _setMakeLanguageCode(s32 Language, u64 *LanguageCode) {
return serviceDispatchInOut(&g_setSrv, 2, Language, *LanguageCode);
}
Result setGetAvailableLanguageCodeCount(s32 *total) {
Result rc = _setCmdNoInOutU32(&g_setSrv, (u32*)total, hosversionAtLeast(4,0,0) ? 6 : 3);
if (R_SUCCEEDED(rc) && total && *total < 0) *total = 0;
return rc;
}
Result setGetRegionCode(SetRegion *out) {
s32 code=0;
Result rc = _setCmdNoInOutU32(&g_setSrv, (u32*)&code, 4);
if (R_SUCCEEDED(rc) && out) *out = code;
return rc;
}
Result setGetQuestFlag(bool *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setSrv, out, 8);
}
Result setGetDeviceNickname(SetSysDeviceNickName *nickname) {
if (hosversionBefore(10,1,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdOutBufAliasFixed(&g_setSrv, nickname, sizeof(*nickname), 11);
}
Result setsysSetLanguageCode(u64 LanguageCode) {
return _setCmdInU64NoOut(&g_setsysSrv, LanguageCode, 0);
}
Result setsysSetNetworkSettings(const SetSysNetworkSettings *settings, s32 count) {
return serviceDispatch(&g_setsysSrv, 1,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysNetworkSettings) } },
);
}
Result setsysGetNetworkSettings(s32 *total_out, SetSysNetworkSettings *settings, s32 count) {
return serviceDispatchOut(&g_setsysSrv, 2, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysNetworkSettings) } },
);
}
static Result _setsysGetFirmwareVersionImpl(SetSysFirmwareVersion *out, u32 cmd_id) {
return serviceDispatch(&g_setsysSrv, cmd_id,
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_Out },
.buffers = { { out, sizeof(*out) } },
);
}
Result setsysGetFirmwareVersion(SetSysFirmwareVersion *out) {
/* GetFirmwareVersion2 does exactly what GetFirmwareVersion does, except it doesn't zero the revision field. */
if (hosversionAtLeast(3,0,0)) {
return _setsysGetFirmwareVersionImpl(out, 4);
} else {
return _setsysGetFirmwareVersionImpl(out, 3);
}
}
Result setsysGetFirmwareVersionDigest(SetSysFirmwareVersionDigest *out) {
return serviceDispatchOut(&g_setsysSrv, 5, *out);
}
Result setsysGetLockScreenFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 7);
}
Result setsysSetLockScreenFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 8);
}
Result setsysGetBacklightSettings(SetSysBacklightSettings *out) {
return serviceDispatchOut(&g_setsysSrv, 9, *out);
}
Result setsysSetBacklightSettings(const SetSysBacklightSettings *settings) {
return serviceDispatchIn(&g_setsysSrv, 10, *settings);
}
Result setsysSetBluetoothDevicesSettings(const SetSysBluetoothDevicesSettings *settings, s32 count) {
return serviceDispatch(&g_setsysSrv, 11,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysBluetoothDevicesSettings) } },
);
}
Result setsysGetBluetoothDevicesSettings(s32 *total_out, SetSysBluetoothDevicesSettings *settings, s32 count) {
return serviceDispatchOut(&g_setsysSrv, 12, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysBluetoothDevicesSettings) } },
);
}
Result setsysGetExternalSteadyClockSourceId(Uuid *out) {
return _setCmdNoInOutUuid(&g_setsysSrv, out, 13);
}
Result setsysSetExternalSteadyClockSourceId(const Uuid *uuid) {
return _setCmdInUuidNoOut(&g_setsysSrv, uuid, 14);
}
Result setsysGetUserSystemClockContext(TimeSystemClockContext *out) {
return serviceDispatchOut(&g_setsysSrv, 15, *out);
}
Result setsysSetUserSystemClockContext(const TimeSystemClockContext *context) {
return serviceDispatchIn(&g_setsysSrv, 16, *context);
}
Result setsysGetAccountSettings(SetSysAccountSettings *out) {
return serviceDispatchOut(&g_setsysSrv, 17, *out);
}
Result setsysSetAccountSettings(SetSysAccountSettings settings) {
return serviceDispatchIn(&g_setsysSrv, 18, settings);
}
Result setsysGetAudioVolume(SetSysAudioDevice device, SetSysAudioVolume *out) {
return serviceDispatchInOut(&g_setsysSrv, 19, device, *out);
}
Result setsysSetAudioVolume(SetSysAudioDevice device, const SetSysAudioVolume *volume) {
const struct {
SetSysAudioVolume volume;
u32 device;
} in = { *volume, device };
return serviceDispatchIn(&g_setsysSrv, 20, in);
}
Result setsysGetEulaVersions(s32 *total_out, SetSysEulaVersion *versions, s32 count) {
return serviceDispatchOut(&g_setsysSrv, 21, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { versions, count*sizeof(SetSysEulaVersion) } },
);
}
Result setsysSetEulaVersions(const SetSysEulaVersion *versions, s32 count) {
return serviceDispatch(&g_setsysSrv, 22,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { versions, count*sizeof(SetSysEulaVersion) } },
);
}
Result setsysGetColorSetId(ColorSetId *out) {
u32 color_set=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &color_set, 23);
if (R_SUCCEEDED(rc) && out) *out = color_set;
return rc;
}
Result setsysSetColorSetId(ColorSetId id) {
return _setCmdInU32NoOut(&g_setsysSrv, id, 24);
}
Result setsysGetConsoleInformationUploadFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 25);
}
Result setsysSetConsoleInformationUploadFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 26);
}
Result setsysGetAutomaticApplicationDownloadFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 27);
}
Result setsysSetAutomaticApplicationDownloadFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 28);
}
Result setsysGetNotificationSettings(SetSysNotificationSettings *out) {
return serviceDispatchOut(&g_setsysSrv, 29, *out);
}
Result setsysSetNotificationSettings(const SetSysNotificationSettings *settings) {
return serviceDispatchIn(&g_setsysSrv, 30, *settings);
}
Result setsysGetAccountNotificationSettings(s32 *total_out, SetSysAccountNotificationSettings *settings, s32 count) {
return serviceDispatchOut(&g_setsysSrv, 31, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysAccountNotificationSettings) } },
);
}
Result setsysSetAccountNotificationSettings(const SetSysAccountNotificationSettings *settings, s32 count) {
return serviceDispatch(&g_setsysSrv, 32,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysAccountNotificationSettings) } },
);
}
Result setsysGetVibrationMasterVolume(float *out) {
return serviceDispatchOut(&g_setsysSrv, 35, *out);
}
Result setsysSetVibrationMasterVolume(float volume) {
return serviceDispatchIn(&g_setsysSrv, 36, volume);
}
Result setsysGetSettingsItemValueSize(const char *name, const char *item_key, u64 *size_out) {
char send_name[SET_MAX_NAME_SIZE];
char send_item_key[SET_MAX_NAME_SIZE];
memset(send_name, 0, SET_MAX_NAME_SIZE);
memset(send_item_key, 0, SET_MAX_NAME_SIZE);
strncpy(send_name, name, SET_MAX_NAME_SIZE-1);
strncpy(send_item_key, item_key, SET_MAX_NAME_SIZE-1);
return serviceDispatchOut(&g_setsysSrv, 37, *size_out,
.buffer_attrs = {
SfBufferAttr_HipcPointer | SfBufferAttr_In,
SfBufferAttr_HipcPointer | SfBufferAttr_In,
},
.buffers = {
{ send_name, SET_MAX_NAME_SIZE },
{ send_item_key, SET_MAX_NAME_SIZE },
},
);
}
Result setsysGetSettingsItemValue(const char *name, const char *item_key, void *value_out, size_t value_out_size, u64 *size_out) {
char send_name[SET_MAX_NAME_SIZE];
char send_item_key[SET_MAX_NAME_SIZE];
memset(send_name, 0, SET_MAX_NAME_SIZE);
memset(send_item_key, 0, SET_MAX_NAME_SIZE);
strncpy(send_name, name, SET_MAX_NAME_SIZE-1);
strncpy(send_item_key, item_key, SET_MAX_NAME_SIZE-1);
return serviceDispatchOut(&g_setsysSrv, 38, *size_out,
.buffer_attrs = {
SfBufferAttr_HipcPointer | SfBufferAttr_In,
SfBufferAttr_HipcPointer | SfBufferAttr_In,
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
},
.buffers = {
{ send_name, SET_MAX_NAME_SIZE },
{ send_item_key, SET_MAX_NAME_SIZE },
{ value_out, value_out_size },
},
);
}
Result setsysGetTvSettings(SetSysTvSettings *out) {
return serviceDispatchOut(&g_setsysSrv, 39, *out);
}
Result setsysSetTvSettings(const SetSysTvSettings *settings) {
return serviceDispatchIn(&g_setsysSrv, 40, *settings);
}
Result setsysGetEdid(SetSysEdid *out) {
return serviceDispatch(&g_setsysSrv, 41,
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_Out },
.buffers = { { out, sizeof(*out) } },
);
}
Result setsysSetEdid(const SetSysEdid *edid) {
return serviceDispatch(&g_setsysSrv, 42,
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_In },
.buffers = { { edid, sizeof(*edid) } },
);
}
Result setsysGetAudioOutputMode(SetSysAudioOutputModeTarget target, SetSysAudioOutputMode *out) {
u32 tmp=0;
Result rc = serviceDispatchInOut(&g_setsysSrv, 43, target, tmp);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetAudioOutputMode(SetSysAudioOutputModeTarget target, SetSysAudioOutputMode mode) {
const struct {
u32 target;
u32 mode;
} in = { target, mode };
return serviceDispatchIn(&g_setsysSrv, 44, in);
}
Result setsysGetSpeakerAutoMuteFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 45);
}
Result setsysSetSpeakerAutoMuteFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 46);
}
Result setsysGetQuestFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 47);
}
Result setsysSetQuestFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 48);
}
Result setsysGetDataDeletionSettings(SetSysDataDeletionSettings *out) {
return serviceDispatchOut(&g_setsysSrv, 49, *out);
}
Result setsysSetDataDeletionSettings(const SetSysDataDeletionSettings *settings) {
return serviceDispatchIn(&g_setsysSrv, 50, *settings);
}
Result setsysGetInitialSystemAppletProgramId(u64 *out) {
return _setCmdNoInOut64(&g_setsysSrv, out, 51);
}
Result setsysGetOverlayDispProgramId(u64 *out) {
return _setCmdNoInOut64(&g_setsysSrv, out, 52);
}
Result setsysGetDeviceTimeZoneLocationName(TimeLocationName *out) {
return serviceDispatchOut(&g_setsysSrv, 53, *out);
}
Result setsysSetDeviceTimeZoneLocationName(const TimeLocationName *name) {
return serviceDispatchIn(&g_setsysSrv, 54, *name);
}
Result setsysGetWirelessCertificationFileSize(u64 *out_size) {
return _setCmdNoInOut64(&g_setsysSrv, out_size, 55);
}
Result setsysGetWirelessCertificationFile(void* buffer, size_t size, u64 *out_size) {
return serviceDispatchOut(&g_setsysSrv, 56, *out_size,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { buffer, size } },
);
}
Result setsysSetRegionCode(SetRegion region) {
return _setCmdInU32NoOut(&g_setsysSrv, region, 57);
}
Result setsysGetNetworkSystemClockContext(TimeSystemClockContext *out) {
return serviceDispatchOut(&g_setsysSrv, 58, *out);
}
Result setsysSetNetworkSystemClockContext(const TimeSystemClockContext *context) {
return serviceDispatchIn(&g_setsysSrv, 59, *context);
}
Result setsysIsUserSystemClockAutomaticCorrectionEnabled(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 60);
}
Result setsysSetUserSystemClockAutomaticCorrectionEnabled(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 61);
}
Result setsysGetDebugModeFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 62);
}
Result setsysGetPrimaryAlbumStorage(SetSysPrimaryAlbumStorage *out) {
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 63);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetPrimaryAlbumStorage(SetSysPrimaryAlbumStorage storage) {
return _setCmdInU32NoOut(&g_setsysSrv, storage, 64);
}
Result setsysGetUsb30EnableFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 65);
}
Result setsysSetUsb30EnableFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 66);
}
Result setsysGetBatteryLot(SetBatteryLot *out) {
return serviceDispatchOut(&g_setsysSrv, 67, *out);
}
Result setsysGetSerialNumber(SetSysSerialNumber *out) {
return serviceDispatchOut(&g_setsysSrv, 68, *out);
}
Result setsysGetNfcEnableFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 69);
}
Result setsysSetNfcEnableFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 70);
}
Result setsysGetSleepSettings(SetSysSleepSettings *out) {
return serviceDispatchOut(&g_setsysSrv, 71, *out);
}
Result setsysSetSleepSettings(const SetSysSleepSettings *settings) {
return serviceDispatchIn(&g_setsysSrv, 72, *settings);
}
Result setsysGetWirelessLanEnableFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 73);
}
Result setsysSetWirelessLanEnableFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 74);
}
Result setsysGetInitialLaunchSettings(SetSysInitialLaunchSettings *out) {
return serviceDispatchOut(&g_setsysSrv, 75, *out);
}
Result setsysSetInitialLaunchSettings(const SetSysInitialLaunchSettings *settings) {
return serviceDispatchIn(&g_setsysSrv, 76, *settings);
}
Result setsysGetDeviceNickname(SetSysDeviceNickName *nickname) {
return _setCmdOutBufAliasFixed(&g_setsysSrv, nickname, sizeof(*nickname), 77);
}
Result setsysSetDeviceNickname(const SetSysDeviceNickName *nickname) {
return serviceDispatch(&g_setsysSrv, 78,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { nickname, sizeof(*nickname) } },
);
}
Result setsysGetProductModel(SetSysProductModel *model) {
u32 product_model = 0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &product_model, 79);
if (R_SUCCEEDED(rc) && model) *model = product_model;
return rc;
}
Result setsysGetLdnChannel(s32 *out) {
return _setCmdNoInOutU32(&g_setsysSrv, (u32*)out, 80);
}
Result setsysSetLdnChannel(s32 channel) {
return _setCmdInU32NoOut(&g_setsysSrv, (u32)channel, 81);
}
Result setsysAcquireTelemetryDirtyFlagEventHandle(Event *out_event) {
return _setCmdGetEvent(&g_setsysSrv, out_event, false, 82);
}
Result setsysGetTelemetryDirtyFlags(u64 *flags_0, u64 *flags_1) {
struct {
u64 flags_0;
u64 flags_1;
} out;
Result rc = serviceDispatchOut(&g_setsysSrv, 83, out);
if (R_SUCCEEDED(rc) && flags_0) *flags_0 = out.flags_0;
if (R_SUCCEEDED(rc) && flags_1) *flags_1 = out.flags_1;
return rc;
}
Result setsysGetPtmBatteryLot(SetBatteryLot *out) {
return serviceDispatchOut(&g_setsysSrv, 84, *out);
}
Result setsysSetPtmBatteryLot(const SetBatteryLot *lot) {
return serviceDispatchIn(&g_setsysSrv, 85, *lot);
}
Result setsysGetPtmFuelGaugeParameter(SetSysPtmFuelGaugeParameter *out) {
return serviceDispatchOut(&g_setsysSrv, 86, *out);
}
Result setsysSetPtmFuelGaugeParameter(const SetSysPtmFuelGaugeParameter *parameter) {
return serviceDispatchIn(&g_setsysSrv, 87, *parameter);
}
Result setsysGetBluetoothEnableFlag(bool *out) {
return _setCmdNoInOutBool(&g_setsysSrv, out, 88);
}
Result setsysSetBluetoothEnableFlag(bool flag) {
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 89);
}
Result setsysGetMiiAuthorId(Uuid *out) {
return _setCmdNoInOutUuid(&g_setsysSrv, out, 90);
}
Result setsysSetShutdownRtcValue(u64 value) {
return _setCmdInU64NoOut(&g_setsysSrv, value, 91);
}
Result setsysGetShutdownRtcValue(u64 *out) {
return _setCmdNoInOut64(&g_setsysSrv, out, 92);
}
Result setsysAcquireFatalDirtyFlagEventHandle(Event *out_event) {
return _setCmdGetEvent(&g_setsysSrv, out_event, false, 93);
}
Result setsysGetFatalDirtyFlags(u64 *flags_0, u64 *flags_1) {
struct {
u64 flags_0;
u64 flags_1;
} out;
Result rc = serviceDispatchOut(&g_setsysSrv, 94, out);
if (R_SUCCEEDED(rc) && flags_0) *flags_0 = out.flags_0;
if (R_SUCCEEDED(rc) && flags_1) *flags_1 = out.flags_1;
return rc;
}
Result setsysGetAutoUpdateEnableFlag(bool *out) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 95);
}
Result setsysSetAutoUpdateEnableFlag(bool flag) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 96);
}
Result setsysGetNxControllerSettings(s32 *total_out, SetSysNxControllerLegacySettings *settings, s32 count) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 97, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysNxControllerLegacySettings) } },
);
}
Result setsysSetNxControllerSettings(const SetSysNxControllerLegacySettings *settings, s32 count) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 98,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysNxControllerLegacySettings) } },
);
}
Result setsysGetBatteryPercentageFlag(bool *out) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 99);
}
Result setsysSetBatteryPercentageFlag(bool flag) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 100);
}
Result setsysGetExternalRtcResetFlag(bool *out) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 101);
}
Result setsysSetExternalRtcResetFlag(bool flag) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 102);
}
Result setsysGetUsbFullKeyEnableFlag(bool *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 103);
}
Result setsysSetUsbFullKeyEnableFlag(bool flag) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 104);
}
Result setsysSetExternalSteadyClockInternalOffset(u64 offset) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU64NoOut(&g_setsysSrv, offset, 105);
}
Result setsysGetExternalSteadyClockInternalOffset(u64 *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOut64(&g_setsysSrv, out, 106);
}
Result setsysGetBacklightSettingsEx(SetSysBacklightSettingsEx *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 107, *out);
}
Result setsysSetBacklightSettingsEx(const SetSysBacklightSettingsEx *settings) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 108, *settings);
}
Result setsysGetHeadphoneVolumeWarningCount(u32 *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU32(&g_setsysSrv, out, 109);
}
Result setsysSetHeadphoneVolumeWarningCount(u32 count) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, count, 110);
}
Result setsysGetBluetoothAfhEnableFlag(bool *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 111);
}
Result setsysSetBluetoothAfhEnableFlag(bool flag) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 112);
}
Result setsysGetBluetoothBoostEnableFlag(bool *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 113);
}
Result setsysSetBluetoothBoostEnableFlag(bool flag) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 114);
}
Result setsysGetInRepairProcessEnableFlag(bool *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 115);
}
Result setsysSetInRepairProcessEnableFlag(bool flag) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 116);
}
Result setsysGetHeadphoneVolumeUpdateFlag(bool *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 117);
}
Result setsysSetHeadphoneVolumeUpdateFlag(bool flag) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 118);
}
Result setsysNeedsToUpdateHeadphoneVolume(u8 *a0, u8 *a1, u8 *a2, bool flag) {
if (!hosversionBetween(3,15))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
struct {
u8 a0;
u8 a1;
u8 a2;
} out;
Result rc = serviceDispatchInOut(&g_setsysSrv, 119, flag, out);
if (R_SUCCEEDED(rc) && a0) *a0 = out.a0;
if (R_SUCCEEDED(rc) && a1) *a1 = out.a1;
if (R_SUCCEEDED(rc) && a2) *a2 = out.a2;
return rc;
}
Result setsysGetPushNotificationActivityModeOnSleep(u32 *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU32(&g_setsysSrv, out, 120);
}
Result setsysSetPushNotificationActivityModeOnSleep(u32 mode) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, mode, 121);
}
Result setsysGetServiceDiscoveryControlSettings(SetSysServiceDiscoveryControlSettings *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 122);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetServiceDiscoveryControlSettings(SetSysServiceDiscoveryControlSettings settings) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, settings, 123);
}
Result setsysGetErrorReportSharePermission(SetSysErrorReportSharePermission *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 124);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetErrorReportSharePermission(SetSysErrorReportSharePermission permission) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, permission, 125);
}
Result setsysGetAppletLaunchFlags(u32 *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU32(&g_setsysSrv, out, 126);
}
Result setsysSetAppletLaunchFlags(u32 flags) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, flags, 127);
}
Result setsysGetConsoleSixAxisSensorAccelerationBias(SetSysConsoleSixAxisSensorAccelerationBias *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 128, *out);
}
Result setsysSetConsoleSixAxisSensorAccelerationBias(const SetSysConsoleSixAxisSensorAccelerationBias *bias) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 129, *bias);
}
Result setsysGetConsoleSixAxisSensorAngularVelocityBias(SetSysConsoleSixAxisSensorAngularVelocityBias *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 130, *out);
}
Result setsysSetConsoleSixAxisSensorAngularVelocityBias(const SetSysConsoleSixAxisSensorAngularVelocityBias *bias) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 131, *bias);
}
Result setsysGetConsoleSixAxisSensorAccelerationGain(SetSysConsoleSixAxisSensorAccelerationGain *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 132, *out);
}
Result setsysSetConsoleSixAxisSensorAccelerationGain(const SetSysConsoleSixAxisSensorAccelerationGain *gain) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 133, *gain);
}
Result setsysGetConsoleSixAxisSensorAngularVelocityGain(SetSysConsoleSixAxisSensorAngularVelocityGain *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 134, *out);
}
Result setsysSetConsoleSixAxisSensorAngularVelocityGain(const SetSysConsoleSixAxisSensorAngularVelocityGain *gain) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 135, *gain);
}
Result setsysGetKeyboardLayout(SetKeyboardLayout *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 136);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetKeyboardLayout(SetKeyboardLayout layout) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, layout, 137);
}
Result setsysGetWebInspectorFlag(bool *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 138);
}
Result setsysGetAllowedSslHosts(s32 *total_out, SetSysAllowedSslHosts *out, s32 count) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 139, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, count*sizeof(SetSysAllowedSslHosts) } },
);
}
Result setsysGetHostFsMountPoint(SetSysHostFsMountPoint *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdOutBufAliasFixed(&g_setsysSrv, out, sizeof(*out), 140);
}
Result setsysGetRequiresRunRepairTimeReviser(bool *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 141);
}
Result setsysSetRequiresRunRepairTimeReviser(bool flag) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 142);
}
Result setsysSetBlePairingSettings(const SetSysBlePairingSettings *settings, s32 count) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 143,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysBlePairingSettings) } },
);
}
Result setsysGetBlePairingSettings(s32 *total_out, SetSysBlePairingSettings *settings, s32 count) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 144, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysBlePairingSettings) } },
);
}
Result setsysGetConsoleSixAxisSensorAngularVelocityTimeBias(SetSysConsoleSixAxisSensorAngularVelocityTimeBias *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 145, *out);
}
Result setsysSetConsoleSixAxisSensorAngularVelocityTimeBias(const SetSysConsoleSixAxisSensorAngularVelocityTimeBias *bias) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 146, *bias);
}
Result setsysGetConsoleSixAxisSensorAngularAcceleration(SetSysConsoleSixAxisSensorAngularAcceleration *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 147, *out);
}
Result setsysSetConsoleSixAxisSensorAngularAcceleration(const SetSysConsoleSixAxisSensorAngularAcceleration *acceleration) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 148, *acceleration);
}
Result setsysGetRebootlessSystemUpdateVersion(SetSysRebootlessSystemUpdateVersion *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 149, *out);
}
Result setsysGetDeviceTimeZoneLocationUpdatedTime(TimeSteadyClockTimePoint *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 150, *out);
}
Result setsysSetDeviceTimeZoneLocationUpdatedTime(const TimeSteadyClockTimePoint *time_point) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 151, *time_point);
}
Result setsysGetUserSystemClockAutomaticCorrectionUpdatedTime(TimeSteadyClockTimePoint *out) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 152, *out);
}
Result setsysSetUserSystemClockAutomaticCorrectionUpdatedTime(const TimeSteadyClockTimePoint *time_point) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 153, *time_point);
}
Result setsysGetAccountOnlineStorageSettings(s32 *total_out, SetSysAccountOnlineStorageSettings *settings, s32 count) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 154, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysAccountOnlineStorageSettings) } },
);
}
Result setsysSetAccountOnlineStorageSettings(const SetSysAccountOnlineStorageSettings *settings, s32 count) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 155,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysAccountOnlineStorageSettings) } },
);
}
Result setsysGetPctlReadyFlag(bool *out) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 156);
}
Result setsysSetPctlReadyFlag(bool flag) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 157);
}
Result setsysGetAnalogStickUserCalibrationL(SetSysAnalogStickUserCalibration *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 158, *out);
}
Result setsysSetAnalogStickUserCalibrationL(const SetSysAnalogStickUserCalibration *calibration) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 159, *calibration);
}
Result setsysGetAnalogStickUserCalibrationR(SetSysAnalogStickUserCalibration *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 160, *out);
}
Result setsysSetAnalogStickUserCalibrationR(const SetSysAnalogStickUserCalibration *calibration) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 161, *calibration);
}
Result setsysGetPtmBatteryVersion(u8 *out) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setsysSrv, out, 162);
}
Result setsysSetPtmBatteryVersion(u8 version) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU8NoOut(&g_setsysSrv, version, 163);
}
Result setsysGetUsb30HostEnableFlag(bool *out) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 164);
}
Result setsysSetUsb30HostEnableFlag(bool flag) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 165);
}
Result setsysGetUsb30DeviceEnableFlag(bool *out) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 166);
}
Result setsysSetUsb30DeviceEnableFlag(bool flag) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 167);
}
Result setsysGetThemeId(s32 type, SetSysThemeId *out) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchInOut(&g_setsysSrv, 168, type, *out);
}
Result setsysSetThemeId(s32 type, const SetSysThemeId *theme_id) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
const struct {
s32 type;
SetSysThemeId theme_id;
} in = { type, *theme_id };
return serviceDispatchIn(&g_setsysSrv, 169, in);
}
Result setsysGetChineseTraditionalInputMethod(SetChineseTraditionalInputMethod *out) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 170);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetChineseTraditionalInputMethod(SetChineseTraditionalInputMethod method) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, method, 171);
}
Result setsysGetPtmCycleCountReliability(SetSysPtmCycleCountReliability *out) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 172);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetPtmCycleCountReliability(SetSysPtmCycleCountReliability reliability) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, reliability, 173);
}
Result setsysGetHomeMenuScheme(SetSysHomeMenuScheme *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 174, *out);
}
Result setsysGetThemeSettings(SetSysThemeSettings *out) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 175, *out);
}
Result setsysSetThemeSettings(const SetSysThemeSettings *settings) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 176, *settings);
}
Result setsysGetThemeKey(FsArchiveMacKey *out) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 177, *out);
}
Result setsysSetThemeKey(const FsArchiveMacKey *key) {
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_setsysSrv, 178, *key);
}
Result setsysGetZoomFlag(bool *out) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 179);
}
Result setsysSetZoomFlag(bool flag) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 180);
}
Result setsysGetT(bool *out) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 181);
}
Result setsysSetT(bool flag) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 182);
}
Result setsysGetPlatformRegion(SetSysPlatformRegion *out) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 183);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetPlatformRegion(SetSysPlatformRegion region) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, region, 184);
}
Result setsysGetHomeMenuSchemeModel(u32 *out) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU32(&g_setsysSrv, out, 185);
}
Result setsysGetMemoryUsageRateFlag(bool *out) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 186);
}
Result setsysGetTouchScreenMode(SetSysTouchScreenMode *out) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u32 tmp=0;
Result rc = _setCmdNoInOutU32(&g_setsysSrv, &tmp, 187);
if (R_SUCCEEDED(rc) && out) *out = tmp;
return rc;
}
Result setsysSetTouchScreenMode(SetSysTouchScreenMode mode) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInU32NoOut(&g_setsysSrv, mode, 188);
}
Result setsysGetButtonConfigSettingsFull(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 189, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysSetButtonConfigSettingsFull(const SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 190,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysGetButtonConfigSettingsEmbedded(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 191, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysSetButtonConfigSettingsEmbedded(const SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 192,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysGetButtonConfigSettingsLeft(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 193, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysSetButtonConfigSettingsLeft(const SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 194,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysGetButtonConfigSettingsRight(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 195, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysSetButtonConfigSettingsRight(const SetSysButtonConfigSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 196,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysButtonConfigSettings) } },
);
}
Result setsysGetButtonConfigRegisteredSettingsEmbedded(SetSysButtonConfigRegisteredSettings *settings) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdOutBufAliasFixed(&g_setsysSrv, settings, sizeof(*settings), 197);
}
Result setsysSetButtonConfigRegisteredSettingsEmbedded(const SetSysButtonConfigRegisteredSettings *settings) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 198,
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, sizeof(SetSysButtonConfigRegisteredSettings) } },
);
}
Result setsysGetButtonConfigRegisteredSettings(s32 *total_out, SetSysButtonConfigRegisteredSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 199, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysButtonConfigRegisteredSettings) } },
);
}
Result setsysSetButtonConfigRegisteredSettings(const SetSysButtonConfigRegisteredSettings *settings, s32 count) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 200,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysButtonConfigRegisteredSettings) } },
);
}
Result setsysGetFieldTestingFlag(bool *out) {
if (hosversionBefore(10,1,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutBool(&g_setsysSrv, out, 201);
}
Result setsysSetFieldTestingFlag(bool flag) {
if (hosversionBefore(10,1,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdInBoolNoOut(&g_setsysSrv, flag, 202);
}
Result setsysGetNxControllerSettingsEx(s32 *total_out, SetSysNxControllerSettings *settings, s32 count) {
if (hosversionBefore(13,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setsysSrv, 205, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { settings, count*sizeof(SetSysNxControllerSettings) } },
);
}
Result setsysSetNxControllerSettingsEx(const SetSysNxControllerSettings *settings, s32 count) {
if (hosversionBefore(13,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setsysSrv, 206,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { settings, count*sizeof(SetSysNxControllerSettings) } },
);
}
Result setcalGetBdAddress(SetCalBdAddress *out) {
return serviceDispatchOut(&g_setcalSrv, 0, *out);
}
Result setcalGetConfigurationId1(SetCalConfigurationId1 *out) {
return serviceDispatchOut(&g_setcalSrv, 1, *out);
}
Result setcalGetAccelerometerOffset(SetCalAccelerometerOffset *out) {
return serviceDispatchOut(&g_setcalSrv, 2, *out);
}
Result setcalGetAccelerometerScale(SetCalAccelerometerScale *out) {
return serviceDispatchOut(&g_setcalSrv, 3, *out);
}
Result setcalGetGyroscopeOffset(SetCalGyroscopeOffset *out) {
return serviceDispatchOut(&g_setcalSrv, 4, *out);
}
Result setcalGetGyroscopeScale(SetCalGyroscopeScale *out) {
return serviceDispatchOut(&g_setcalSrv, 5, *out);
}
Result setcalGetWirelessLanMacAddress(SetCalMacAddress *out) {
return serviceDispatchOut(&g_setcalSrv, 6, *out);
}
Result setcalGetWirelessLanCountryCodeCount(s32 *out_count) {
return _setCmdNoInOutU32(&g_setcalSrv, (u32*)out_count, 7);
}
Result setcalGetWirelessLanCountryCodes(s32 *total_out, SetCalCountryCode *codes, s32 count) {
return serviceDispatchOut(&g_setcalSrv, 8, *total_out,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out },
.buffers = { { codes, count*sizeof(SetCalCountryCode) } },
);
}
Result setcalGetSerialNumber(SetCalSerialNumber *out) {
return serviceDispatchOut(&g_setcalSrv, 9, *out);
}
Result setcalSetInitialSystemAppletProgramId(u64 program_id) {
return _setCmdInU64NoOut(&g_setcalSrv, program_id, 10);
}
Result setcalSetOverlayDispProgramId(u64 program_id) {
return _setCmdInU64NoOut(&g_setcalSrv, program_id, 11);
}
Result setcalGetBatteryLot(SetBatteryLot *out) {
return serviceDispatchOut(&g_setcalSrv, 12, *out);
}
Result setcalGetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out) {
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 14);
}
Result setcalGetEticketDeviceCertificate(SetCalRsa2048DeviceCertificate *out) {
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 15);
}
Result setcalGetSslKey(SetCalSslKey *out) {
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 16);
}
Result setcalGetSslCertificate(SetCalSslCertificate *out) {
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 17);
}
Result setcalGetGameCardKey(SetCalGameCardKey *out) {
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 18);
}
Result setcalGetGameCardCertificate(SetCalGameCardCertificate *out) {
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 19);
}
Result setcalGetEciDeviceKey(SetCalEccB233DeviceKey *out) {
return serviceDispatchOut(&g_setcalSrv, 20, *out);
}
Result setcalGetEticketDeviceKey(SetCalRsa2048DeviceKey *out) {
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 21);
}
Result setcalGetSpeakerParameter(SetCalSpeakerParameter *out) {
return serviceDispatchOut(&g_setcalSrv, 22, *out);
}
Result setcalGetLcdVendorId(u32 *out_vendor_id) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU32(&g_setcalSrv, out_vendor_id, 23);
}
Result setcalGetEciDeviceCertificate2(SetCalRsa2048DeviceCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 24);
}
Result setcalGetEciDeviceKey2(SetCalRsa2048DeviceKey *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdOutBufAliasFixed(&g_setcalSrv, out, sizeof(*out), 25);
}
Result setcalGetAmiiboKey(SetCalAmiiboKey *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 26, *out);
}
Result setcalGetAmiiboEcqvCertificate(SetCalAmiiboEcqvCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 27, *out);
}
Result setcalGetAmiiboEcdsaCertificate(SetCalAmiiboEcdsaCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 28, *out);
}
Result setcalGetAmiiboEcqvBlsKey(SetCalAmiiboEcqvBlsKey *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 29, *out);
}
Result setcalGetAmiiboEcqvBlsCertificate(SetCalAmiiboEcqvBlsCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 30, *out);
}
Result setcalGetAmiiboEcqvBlsRootCertificate(SetCalAmiiboEcqvBlsRootCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 31, *out);
}
Result setcalGetUsbTypeCPowerSourceCircuitVersion(u8 *out_version) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_version, 32);
}
Result setcalGetAnalogStickModuleTypeL(u8 *out_type) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_type, 33);
}
Result setcalGetAnalogStickModelParameterL(SetCalAnalogStickModelParameter *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 34, *out);
}
Result setcalGetAnalogStickFactoryCalibrationL(SetCalAnalogStickFactoryCalibration *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 35, *out);
}
Result setcalGetAnalogStickModuleTypeR(u8 *out_type) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_type, 36);
}
Result setcalGetAnalogStickModelParameterR(SetCalAnalogStickModelParameter *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 37, *out);
}
Result setcalGetAnalogStickFactoryCalibrationR(SetCalAnalogStickFactoryCalibration *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 38, *out);
}
Result setcalGetConsoleSixAxisSensorModuleType(u8 *out_type) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_type, 39);
}
Result setcalGetConsoleSixAxisSensorHorizontalOffset(SetCalConsoleSixAxisSensorHorizontalOffset *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 40, *out);
}
Result setcalGetBatteryVersion(u8 *out_version) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_version, 41);
}
Result setcalGetDeviceId(u64 *out_device_id) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOut64(&g_setcalSrv, out_device_id, 42);
}
Result setcalGetConsoleSixAxisSensorMountType(u8 *out_type) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_type, 43);
}
|
ed1d17d92ad6ec37f23ffb4360d55c6bf38254a0
|
9b6acaebd72bb1914838fb3091c0d447bf03104a
|
/inactive-volume-sessions/inactive-volume-sessions/volume.h
|
bd684007a34ce3970913dae1c0d3697ba01082fb
|
[] |
no_license
|
mvaneerde/blog
|
31ad3ab0d1c13e49da5d9f04994c706c2dd36e5e
|
55e6f077b034e90dadfa63b51af5e37d0a3cf6ca
|
refs/heads/develop
| 2023-09-03T19:31:53.969123
| 2023-08-25T17:52:56
| 2023-08-25T17:52:56
| 42,925,860
| 223
| 122
| null | 2021-05-11T11:50:34
| 2015-09-22T09:56:16
|
HTML
|
UTF-8
|
C
| false
| false
| 46
|
h
|
volume.h
|
// volume.h
HRESULT ListVolumesForDevices();
|
96f4afad47ac49d5be4e2a35aae74118e625d0a5
|
7df190df28da7e4ff166e55dc8ce780f11236a9f
|
/src/router/lsof/dialects/n+os/dproc.c
|
ef8529cb4b9bf9c93d89892b82f8db2ec15d9f8a
|
[] |
no_license
|
mirror/dd-wrt
|
25416946e6132aa54b35809de61834a1825a9a36
|
8f2934a5a2adfbb59b471375aa3a38de5d036531
|
refs/heads/master
| 2023-08-31T14:54:47.496685
| 2023-08-30T17:40:54
| 2023-08-30T17:40:54
| 7,470,282
| 520
| 281
| null | 2023-05-29T20:56:24
| 2013-01-06T17:21:29
| null |
UTF-8
|
C
| false
| false
| 17,453
|
c
|
dproc.c
|
/*
* dproc.c - NEXTSTEP and OPENSTEP process access functions for lsof
*/
/*
* Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana
* 47907. All rights reserved.
*
* Written by Victor A. Abell
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. Neither the authors nor Purdue University are responsible for any
* consequences of the use of this software.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Credit to the authors and Purdue
* University must appear in documentation and sources.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 4. This notice may not be removed or altered.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
#endif
#include "lsof.h"
/*
* Local static values
*/
static int Mxp = 0; /* maximum number of processes */
static int Np; /* number of entries in P[] */
static int Nv = 0; /* allocated Vp[] entries */
static struct proc *P = (struct proc *)NULL;
/* local proc structure table */
static KA_T *Pa = (KA_T *)NULL; /* kernel address for each P[] entry */
static KA_T Kp; /* kernel process table pointer */
static KA_T *Vp = (KA_T *)NULL; /* vnode address cache */
_PROTOTYPE(static void get_kernel_access,(void));
_PROTOTYPE(static void process_map,(caddr_t map));
_PROTOTYPE(static void read_proc,(void));
/*
* ckkv - check kernel version
*/
void
ckkv(d, er, ev, ea)
char *d; /* dialect */
char *er; /* expected release */
char *ev; /* expected version */
char *ea; /* expected architecture */
{
#if defined(HASKERNIDCK)
char m[128], *t;
kernel_version_t kv;
kern_return_t kr;
char *vt = (char *)NULL;
if (Fwarn)
return;
/*
* Read Mach kernel version.
*/
if ((kr = host_kernel_version(host_self(), kv)) != KERN_SUCCESS) {
(void) snpf(m, sizeof(m), "%s: can't get kernel version:", Pn);
mach_error(m, kr);
Exit(1);
}
/*
* Skip blank-separated tokens until reaching "Mach". The kernel version
* string follows. Eliminate anything but decimal digits and periods from
* the kernel version string.
*/
if ((t = strtok(kv, " "))) {
do {
if (strcmp(t, "Mach") == 0)
break;
} while ((t = strtok((char *)NULL, " ")));
if (t)
vt = strtok((char *)NULL, " ");
}
if (vt) {
for (t = vt; *t; t++) {
if (*t == '.' || (*t >= '0' && *t <= '9'))
continue;
*t = '\0';
break;
}
}
/*
* Warn if the actual and expected versions don't match.
*/
if (!ev || !vt || strcmp(ev, vt))
(void) fprintf(stderr,
"%s: WARNING: compiled for %s version %s; this is %s\n",
Pn, d, ev ? ev : "UNKNOWN", vt ? vt : "UNKNOWN");
#endif /* defined(HASKERNIDCK) */
}
/*
* gather_proc_info() -- gather process information
*/
void
gather_proc_info()
{
int i, nf, px;
MALLOC_S nb;
short pss, sf;
struct task { /* (Should come from <kern/task.h>.) */
caddr_t d1[SIMPLE_LOCK_SIZE + 2];
caddr_t map;
caddr_t d2[SIMPLE_LOCK_SIZE + 9];
struct utask *u_address;
struct proc *proc;
} t;
struct utask *u;
static struct file **uf = (struct file **)NULL;
static MALLOC_S ufb = 0;
struct utask ut;
#if defined(HASFSTRUCT)
static char *pof = (char *)NULL;
static MALLOC_S pofb = 0;
#endif /* defined(HASFSTRUCT) */
/*
* Clear previously loaded tables and read the process table.
*/
#if STEPV>=31
(void) clr_svnc();
#endif /* STEPV>=31 */
(void) read_proc();
/*
* Process proc structures pre-loaded in initialize().
*/
for (px = 0, u = &ut; px < Np; px++) {
if (is_proc_excl(P[px].p_pid, (int)P[px].p_pgrp,
(UID_ARG)P[px].p_uid, &pss, &sf))
continue;
/*
* Read the task associated with the process, and the user
* area assocated with the task.
*/
if (kread((KA_T)P[px].task, (char *)&t, sizeof(t)))
continue;
if ((KA_T)t.proc != Pa[px])
continue;
if (kread((KA_T)t.u_address, (char *)&ut, sizeof(ut)))
continue;
if ((KA_T)ut.uu_procp != Pa[px])
continue;
/*
* Allocate a local process structure and start filling it.
*/
if (is_cmd_excl(u->u_comm, &pss, &sf))
continue;
alloc_lproc(P[px].p_pid, (int)P[px].p_pgrp, (int)P[px].p_ppid,
(UID_ARG)P[px].p_uid, u->u_comm, (int)pss, (int)sf);
Plf = (struct lfile *)NULL;
/*
* Save current working directory information.
*/
if (u->u_cdir) {
alloc_lfile(CWD, -1);
FILEPTR = (struct file *)NULL;
process_node((KA_T)u->u_cdir);
if (Lf->sf)
link_lfile();
}
/*
* Save root directory information.
*/
if (u->u_rdir) {
alloc_lfile(RTD, -1);
FILEPTR = (struct file *)NULL;
process_node((KA_T)u->u_rdir);
if (Lf->sf)
link_lfile();
}
/*
* Print information on the text files of the virtual memory
* address map.
*/
if (t.map)
process_map(t.map);
/*
* Save information on file descriptors.
*
* NEXTSTEP file pointers come from a structure whose pointer is
* in the user task area.
*/
nf = ut.uu_ofile_cnt;
nb = (MALLOC_S)(sizeof(struct file *) * nf);
if (nb > ufb) {
if (!uf)
uf = (struct file **)malloc(nb);
else
uf = (struct file **)realloc((MALLOC_P *)uf, nb);
if (!uf) {
(void) fprintf(stderr, "%s: no uu_ofile space\n", Pn);
Exit(1);
}
ufb = nb;
}
if (kread((KA_T)ut.uu_ofile, (char *)uf, nb))
continue;
#if defined(HASFSTRUCT)
if (Fsv & FSV_FG) {
nb = (MALLOC_S)(sizeof(char) * nf);
if (nb > pofb) {
if (!pof)
pof = (char *)malloc(nb);
else
pof = (char *)realloc((MALLOC_P *)pof, nb);
if (!pof) {
(void) fprintf(stderr, "%s: no uu_pofile space\n", Pn);
Exit(1);
}
pofb = nb;
}
if (kread((KA_T)ut.uu_pofile, (char *)pof, nb))
zeromem(pof, nb);
}
#endif /* defined(HASFSTRUCT) */
for (i = 0; i < nf; i++) {
if (uf[i]) {
alloc_lfile((char *)NULL, i);
process_file((KA_T)uf[i]);
if (Lf->sf) {
#if defined(HASFSTRUCT)
if (Fsv & FSV_FG)
Lf->pof = (long)pof[i];
#endif /* defined(HASFSTRUCT) */
link_lfile();
}
}
}
/*
* Examine results.
*/
if (examine_lproc())
return;
}
}
/*
* get_kernel_access() - access the required information in the kernel
*/
static void
get_kernel_access()
{
int i;
KA_T lv;
#if defined(HAS_AFS)
struct nlist *nl = (struct nlist *)NULL;
unsigned long v[3];
#endif /* defined(HAS_AFS) */
/*
* Check kernel version against compiled version.
*/
ckkv("NEXTSTEP", (char *)NULL, LSOF_VSTR, (char *)NULL);
#if defined(WILLDROPGID)
/*
* If kernel memory isn't coming from KMEM, drop setgid permission
* before attempting to open the (Memory) file.
*/
if (Memory)
(void) dropgid();
#else /* !defined(WILLDROPGID) */
/*
* See if the non-KMEM memory file is readable.
*/
if (Memory && !is_readable(Memory, 1))
Exit(1);
#endif /* defined(WILLDROPGID) */
/*
* Access the kernel memory file.
*/
if ((Kd = open(Memory ? Memory : KMEM, O_RDONLY, 0)) < 0) {
(void) fprintf(stderr, "%s: can't open %s: %s\n", Pn,
Memory ? Memory : KMEM, strerror(errno));
Exit(1);
}
#if defined(WILLDROPGID)
/*
* Drop setgid permission, if necessary.
*/
if (!Memory)
(void) dropgid();
#else /* !defined(WILLDROPGID) */
/*
* See if the name list file is readable. Build Nl.
*/
if (Nmlst && !is_readable(Nmlst, 1))
Exit(1);
#endif /* defined(WILLDROPGID) */
(void) build_Nl(Drive_Nl);
#if defined(HAS_AFS)
if (!Nmlst) {
/*
* If AFS is defined and we're getting kernel symbol values from
* from N_UNIX, make a copy of Nl[] for possible use with the AFS
* module name list file.
*/
if (!(nl = (struct nlist *)malloc(Nll))) {
(void) fprintf(stderr,
"%s: no space (%d) for Nl[] copy\n", Pn, Nll);
Exit(1);
}
(void) bcopy((char *)Nl, (char *)nl, Nll);
}
#endif /* defined(HAS_AFS) */
/*
* Access the name list file.
*/
if (nlist(Nmlst ? Nmlst : VMUNIX, Nl) < 0) {
(void) fprintf(stderr, "%s: can't read namelist from %s\n",
Pn, Nmlst ? Nmlst : VMUNIX);
Exit(1);
}
if (get_Nl_value("aproc", Drive_Nl, &lv) < 0 || !lv) {
(void) fprintf(stderr, "%s: can't get proc table address\n",
Pn);
Exit(1);
}
#if defined(HAS_AFS)
if (nl) {
/*
* If AFS is defined and we're getting kernel symbol values from
* N_UNIX, and if any X_AFS_* symbols isn't there, see if it is in the
* the AFS module name list file. Make sure that other symbols that
* appear in both name list files have the same values.
*/
if (get_Nl_value("arFID", Drive_Nl, &v[0]) >= 0
&& get_Nl_value("avol", Drive_Nl, &v[1]) >= 0
&& get_Nl_value("avol", Drive_Nl, &v[2]) >= 0
&& (!vo[0] || !v[1] || !v[2]))
(void) ckAFSsym(nl);
(void) free((MALLOC_P *)nl);
}
#endif /* defined(HAS_AFS) */
/*
* Establish a maximum process count estimate.
*/
if (get_Nl_value("mxproc", Drive_Nl, &lv) < 0
|| kread((KA_T)lv, (char *)&Mxp, sizeof(Mxp))
|| Mxp < 1)
Mxp = PROCDFLT;
}
/*
* initialize() - perform all initialization
*/
void
initialize()
{
get_kernel_access();
}
/*
* kread() - read from kernel memory
*/
int
kread(addr, buf, len)
KA_T addr; /* kernel memory address */
char *buf; /* buffer to receive data */
READLEN_T len; /* length to read */
{
int br;
if (lseek(Kd, (off_t)addr, L_SET) == (off_t)-1L)
return(-1);
br = read(Kd, buf, len);
return((br == len) ? 0 : 1);
}
/*
* process_map() - process vm map for vnode references
*/
static void
process_map(map)
caddr_t map;
{
int i, j, n, ne;
#if STEPV<40
/*
* Structures for NeXTSTEP and OPENSTEP < 4.0.
*/
struct vm_map_entry { /* (Should come from <vm/vm_map.h>). */
struct vm_map_entry *prev;
struct vm_map_entry *next;
unsigned int start;
unsigned int end;
caddr_t object;
unsigned int offset;
unsigned int
is_a_map:1,
is_sub_map:1,
copy_on_write:1,
needs_copy:1;
int protection;
int max_protection;
int inheritance;
int wired_count;
} vme, *vmep;
#define VME_NEXT(entry) entry.next
struct vm_map { /* (Should come from <vm/vm_map.h>.) */
caddr_t d1[SIMPLE_LOCK_SIZE + 2];
struct vm_map_entry header;
int nentries;
caddr_t pmap;
unsigned int size;
boolean_t is_main_map;
} vmm;
struct vm_object { /* (Should come from <vm/vm_object.h>.) */
caddr_t d1[SIMPLE_LOCK_SIZE + 4];
unsigned int size;
short ref_count, resident_page_count;
caddr_t copy;
caddr_t pager;
int pager_request, pager_name;
unsigned int paging_offset;
caddr_t shadow;
} vmo, vmso;
#else /* STEPV>=40 */
/*
* Structures for OPENSTEP >= 4.0.
*/
struct vm_map_links { /* (Should come from <vm/vm_map.h>). */
struct vm_map_entry *prev;
struct vm_map_entry *next;
unsigned int start;
unsigned int end;
};
struct vm_map_entry { /* (Should come from <vm/vm_map.h>). */
struct vm_map_links links;
caddr_t object;
unsigned int offset;
unsigned int
is_shared:1,
is_sub_map:1,
in_transition:1,
needs_wakeup:1,
behavior:2,
needs_copy:1,
protection:3,
max_protection:3,
inheritance:2,
pad1:1,
alias:8;
unsigned short wired_count;
unsigned short user_wired_count;
} vme, *vmep;
#define VME_NEXT(entry) entry.links.next
struct vm_map_header { /* (Should come from <vm/vm_map.h>.) */
struct vm_map_links links;
int nentries;
int entries_pageable;
};
struct vm_map { /* (Should come from <vm/vm_map.h>.) */
caddr_t d1[SIMPLE_LOCK_SIZE + 2];
struct vm_map_header hdr;
caddr_t pmap;
unsigned int size;
boolean_t is_main_map; /* Darwin header has this as ref_count,
* but we'll take some liberties ... */
} vmm;
struct vm_object { /* (Should come from <vm/vm_object.h>.) */
caddr_t d1[SIMPLE_LOCK_SIZE + 4];
unsigned int size;
short ref_count, resident_page_count;
caddr_t copy;
caddr_t shadow;
unsigned int shadow_offset;
caddr_t pager;
unsigned int paging_offset;
int pager_request;
} vmo, vmso;
#endif /* STEPV<40 */
struct vstruct { /* (Should come from <vm/vnode_pager.h>.) */
boolean_t is_device;
caddr_t vs_pf;
caddr_t pfMapEntry;
unsigned int vs_swapfile:1;
short vs_count;
int vs_size;
caddr_t vs_vp;
} vmp;
/*
* Read the vm map.
*/
if (!map
|| kread((KA_T)map, (char *)&vmm, sizeof(vmm)))
return;
if (!vmm.is_main_map)
return;
/*
* Look for non-map and non-sub-map vm map entries that have an object
* with a shadow whose pager pointer addresses a non-swap-file istruct
* that has a vnode pointer. Process the unique vnodes found.
*/
#if STEPV<40
vme = vmm.header;
ne = vmm.nentries;
#else /* STEPV>=40 */
if (!vmm.hdr.links.next
|| kread((KA_T)vmm.hdr.links.next, (char *)&vme, sizeof(vme)))
return;
ne = vmm.hdr.nentries;
#endif /* STEPV<40 */
if (ne > 1000)
ne = 1000;
for (i = n = 0; i < ne; i++) {
if (i) {
if (!VME_NEXT(vme)
|| kread((KA_T)VME_NEXT(vme), (char *)&vme, sizeof(vme)))
continue;
}
#if STEPV<40
if (vme.is_a_map || vme.is_sub_map)
#else /* STEPV>=40 */
if (vme.is_sub_map)
#endif /* STEPV<40 */
continue;
if (!vme.object
|| kread((KA_T)vme.object, (char *)&vmo, sizeof(vmo)))
continue;
if (!vmo.shadow
|| kread((KA_T)vmo.shadow, (char *)&vmso, sizeof(vmso)))
continue;
if (!vmso.pager
|| kread((KA_T)vmso.pager, (char *)&vmp, sizeof(vmp)))
continue;
if (vmp.is_device || vmp.vs_swapfile || !vmp.vs_vp)
continue;
/*
* See if the vnode has been processed before.
*/
for (j = 0; j < n; j++) {
if ((KA_T)vmp.vs_vp == Vp[j])
break;
}
if (j < n)
continue;
/*
* Process a new vnode.
*/
alloc_lfile("txt", -1);
FILEPTR = (struct file *)NULL;
process_node((KA_T)vmp.vs_vp);
if (Lf->sf)
link_lfile();
/*
* Allocate space for remembering the vnode.
*/
if (!Vp) {
if (!(Vp = (KA_T *)malloc((MALLOC_S)
(sizeof(struct vnode *) * 10))))
{
(void) fprintf(stderr, "%s: no txt ptr space, PID %d\n",
Pn, Lp->pid);
Exit(1);
}
Nv = 10;
} else if (n >= Nv) {
Nv += 10;
if (!(Vp = (KA_T *)realloc((MALLOC_P *)Vp,
(MALLOC_S)(Nv * sizeof(struct vnode *)))))
{
(void) fprintf(stderr,
"%s: no more txt ptr space, PID %d\n", Pn, Lp->pid);
Exit(1);
}
}
Vp[n++] = (KA_T)vmp.vs_vp;
}
}
/*
* read_proc() - read proc structures
*/
static void
read_proc()
{
static KA_T apav = (KA_T)0;
static int apax = -1;
int i, try;
static int sz = 0;
KA_T kp;
struct proc *p;
/*
* Try PROCTRYLM times to read a valid proc table.
*/
for (try = 0; try < PROCTRYLM; try++) {
/*
* Read kernel's process list pointer. This needs to be done each
* time lsof rereads the process list.
*/
if (apax < 0) {
if ((apax = get_Nl_value("aproc", Drive_Nl, &apav)) < 0) {
(void) fprintf(stderr,
"%s: can't get process table address pointer\n", Pn);
Exit(1);
}
}
if (kread((KA_T)apav, (char *)&Kp, sizeof(Kp))) {
if (!Fwarn)
(void) fprintf(stderr,
"%s: WARNING: can't read %s from %#x\n",
Pn, Nl[apax].n_un.n_name, apav);
continue;
}
/*
* Pre-allocate proc structure space.
*/
if (sz == 0) {
sz = Mxp;
if (!(P = (struct proc *)malloc((MALLOC_S)
(sz * sizeof(struct proc)))))
{
(void) fprintf(stderr, "%s: no proc table space\n",
Pn);
Exit(1);
}
if (!(Pa = (KA_T *)malloc((MALLOC_S)(sz * sizeof(KA_T)))))
{
(void) fprintf(stderr, "%s: no proc pointer space\n",
Pn);
Exit(1);
}
}
/*
* Accumulate proc structures.
*/
for (kp = Kp, Np = 0; kp; ) {
if (kread(kp, (char *)&P[Np], sizeof(struct proc))) {
Np = 0;
break;
}
Pa[Np] = kp;
kp = (KA_T)P[Np].p_nxt;
if (P[Np].p_stat == 0 || P[Np].p_stat == SZOMB)
continue;
Np++;
if (Np >= sz) {
/*
* Expand the local proc table.
*/
sz += PROCDFLT/2;
if (!(P = (struct proc *)realloc((MALLOC_P *)P,
(MALLOC_S)(sizeof(struct proc) * sz))))
{
(void) fprintf(stderr,
"%s: no more (%d) proc space\n",
Pn, sz);
Exit(1);
}
if (!(Pa = (KA_T *)realloc((MALLOC_P *)Pa,
(MALLOC_S)(sizeof(KA_T) * sz))))
{
(void) fprintf(stderr,
"%s: no more (%d) proc ptr space\n",
Pn, sz);
Exit(1);
}
}
}
/*
* If not enough processes were saved in the local table, try again.
*/
if (Np >= PROCMIN)
break;
}
/*
* Quit if no proc structures were stored in the local table.
*/
if (try >= PROCTRYLM) {
(void) fprintf(stderr, "%s: can't read proc table\n", Pn);
Exit(1);
}
if (Np < sz && !RptTm) {
/*
* Reduce the local proc structure table size to a minimum if
* not in repeat mode.
*/
if (!(P = (struct proc *)realloc((MALLOC_P *)P,
(MALLOC_S)(sizeof(struct proc) * Np))))
{
(void) fprintf(stderr,
"%s: can't reduce proc table to %d\n",
Pn, Np);
Exit(1);
}
if (!(Pa = (KA_T *)realloc((MALLOC_P *)Pa,
(MALLOC_S)(sizeof(KA_T) * Np))))
{
(void) fprintf(stderr,
"%s: can't reduce proc ptrs to %d\n",
Pn, Np);
Exit(1);
}
}
}
|
47e501f23c373c25f59e2864ff8f54e614e25416
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/usb/serial/aircable.c
|
6e320cec397dc77fc9ec3d8aadb39bb4fcc5a70f
|
[
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 5,792
|
c
|
aircable.c
|
/*
* AIRcable USB Bluetooth Dongle Driver.
*
* Copyright (C) 2010 Johan Hovold <jhovold@gmail.com>
* Copyright (C) 2006 Manuel Francisco Naranjo (naranjo.manuel@gmail.com)
*
* 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.
*
* The device works as an standard CDC device, it has 2 interfaces, the first
* one is for firmware access and the second is the serial one.
* The protocol is very simply, there are two posibilities reading or writing.
* When writing the first urb must have a Header that starts with 0x20 0x29 the
* next two bytes must say how much data will be sended.
* When reading the process is almost equal except that the header starts with
* 0x00 0x20.
*
* The device simply need some stuff to understand data coming from the usb
* buffer: The First and Second byte is used for a Header, the Third and Fourth
* tells the device the amount of information the package holds.
* Packages are 60 bytes long Header Stuff.
* When writing to the device the first two bytes of the header are 0x20 0x29
* When reading the bytes are 0x00 0x20, or 0x00 0x10, there is an strange
* situation, when too much data arrives to the device because it sends the data
* but with out the header. I will use a simply hack to override this situation,
* if there is data coming that does not contain any header, then that is data
* that must go directly to the tty, as there is no documentation about if there
* is any other control code, I will simply check for the first
* one.
*
* The driver registers himself with the USB-serial core and the USB Core. I had
* to implement a probe function against USB-serial, because other way, the
* driver was attaching himself to both interfaces. I have tryed with different
* configurations of usb_serial_driver with out exit, only the probe function
* could handle this correctly.
*
* I have taken some info from a Greg Kroah-Hartman article:
* http://www.linuxjournal.com/article/6573
* And from Linux Device Driver Kit CD, which is a great work, the authors taken
* the work to recompile lots of information an knowladge in drivers development
* and made it all avaible inside a cd.
* URL: http://kernel.org/pub/linux/kernel/people/gregkh/ddk/
*
*/
#include <asm/unaligned.h>
#include <linux/tty.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/tty_flip.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
/* Vendor and Product ID */
#define AIRCABLE_VID 0x16CA
#define AIRCABLE_USB_PID 0x1502
/* Protocol Stuff */
#define HCI_HEADER_LENGTH 0x4
#define TX_HEADER_0 0x20
#define TX_HEADER_1 0x29
#define RX_HEADER_0 0x00
#define RX_HEADER_1 0x20
#define HCI_COMPLETE_FRAME 64
/* rx_flags */
#define THROTTLED 0x01
#define ACTUALLY_THROTTLED 0x02
#define DRIVER_AUTHOR "Naranjo, Manuel Francisco <naranjo.manuel@gmail.com>, Johan Hovold <jhovold@gmail.com>"
#define DRIVER_DESC "AIRcable USB Driver"
/* ID table that will be registered with USB core */
static const struct usb_device_id id_table[] = {
{ USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) },
{ },
};
MODULE_DEVICE_TABLE(usb, id_table);
static int aircable_prepare_write_buffer(struct usb_serial_port *port,
void *dest, size_t size)
{
int count;
unsigned char *buf = dest;
count = kfifo_out_locked(&port->write_fifo, buf + HCI_HEADER_LENGTH,
size - HCI_HEADER_LENGTH, &port->lock);
buf[0] = TX_HEADER_0;
buf[1] = TX_HEADER_1;
put_unaligned_le16(count, &buf[2]);
return count + HCI_HEADER_LENGTH;
}
static int aircable_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{
struct usb_host_interface *iface_desc = serial->interface->
cur_altsetting;
struct usb_endpoint_descriptor *endpoint;
int num_bulk_out = 0;
int i;
for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
endpoint = &iface_desc->endpoint[i].desc;
if (usb_endpoint_is_bulk_out(endpoint)) {
dev_dbg(&serial->dev->dev,
"found bulk out on endpoint %d\n", i);
++num_bulk_out;
}
}
if (num_bulk_out == 0) {
dev_dbg(&serial->dev->dev, "Invalid interface, discarding\n");
return -ENODEV;
}
return 0;
}
static int aircable_process_packet(struct usb_serial_port *port,
int has_headers, char *packet, int len)
{
if (has_headers) {
len -= HCI_HEADER_LENGTH;
packet += HCI_HEADER_LENGTH;
}
if (len <= 0) {
dev_dbg(&port->dev, "%s - malformed packet\n", __func__);
return 0;
}
tty_insert_flip_string(&port->port, packet, len);
return len;
}
static void aircable_process_read_urb(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
char *data = (char *)urb->transfer_buffer;
int has_headers;
int count;
int len;
int i;
has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0);
count = 0;
for (i = 0; i < urb->actual_length; i += HCI_COMPLETE_FRAME) {
len = min_t(int, urb->actual_length - i, HCI_COMPLETE_FRAME);
count += aircable_process_packet(port, has_headers,
&data[i], len);
}
if (count)
tty_flip_buffer_push(&port->port);
}
static struct usb_serial_driver aircable_device = {
.driver = {
.owner = THIS_MODULE,
.name = "aircable",
},
.id_table = id_table,
.num_ports = 1,
.bulk_out_size = HCI_COMPLETE_FRAME,
.probe = aircable_probe,
.process_read_urb = aircable_process_read_urb,
.prepare_write_buffer = aircable_prepare_write_buffer,
.throttle = usb_serial_generic_throttle,
.unthrottle = usb_serial_generic_unthrottle,
};
static struct usb_serial_driver * const serial_drivers[] = {
&aircable_device, NULL
};
module_usb_serial_driver(serial_drivers, id_table);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
|
62ef8792d862570df31c66af3168080a0db5827d
|
83372fce92c9088ee5c1e1c13bc67385a3b02a36
|
/src/cc65/error.c
|
39b0678250d7df8b9ec34f702cdd17d98bf2eda4
|
[
"Zlib",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
cc65/cc65
|
2cd1b20b61ddd0691cd4601b4da37a9200a50afb
|
16e90187e8e80c6e2fcfcc04f068ac865d2290e5
|
refs/heads/master
| 2023-09-03T17:16:46.027934
| 2023-09-02T22:30:44
| 2023-09-02T22:30:44
| 8,932,489
| 2,103
| 526
|
Zlib
| 2023-09-13T06:19:01
| 2013-03-21T15:56:48
|
C
|
UTF-8
|
C
| false
| false
| 13,956
|
c
|
error.c
|
/*****************************************************************************/
/* */
/* error.c */
/* */
/* Error handling for the cc65 C compiler */
/* */
/* */
/* */
/* (C) 1998-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-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. */
/* */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
/* common */
#include "coll.h"
#include "print.h"
#include "strbuf.h"
/* cc65 */
#include "global.h"
#include "input.h"
#include "lineinfo.h"
#include "scanner.h"
#include "stmt.h"
#include "error.h"
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Count of errors/warnings */
unsigned ErrorCount = 0;
unsigned WarningCount = 0;
/* Warning and error options */
IntStack WarnEnable = INTSTACK(1); /* Enable warnings */
IntStack WarningsAreErrors = INTSTACK(0); /* Treat warnings as errors */
/* Warn about: */
IntStack WarnConstComparison= INTSTACK(1); /* - constant comparison results */
IntStack WarnNoEffect = INTSTACK(1); /* - statements without an effect */
IntStack WarnPointerSign = INTSTACK(1); /* - pointer conversion to pointer differing in signedness */
IntStack WarnPointerTypes = INTSTACK(1); /* - pointer conversion to incompatible pointer type */
IntStack WarnRemapZero = INTSTACK(1); /* - remapping character code zero */
IntStack WarnReturnType = INTSTACK(1); /* - control reaches end of non-void function */
IntStack WarnStructParam = INTSTACK(0); /* - structs passed by val */
IntStack WarnUnknownPragma = INTSTACK(1); /* - unknown #pragmas */
IntStack WarnUnreachableCode= INTSTACK(1); /* - unreachable code */
IntStack WarnUnusedLabel = INTSTACK(1); /* - unused labels */
IntStack WarnUnusedParam = INTSTACK(1); /* - unused parameters */
IntStack WarnUnusedVar = INTSTACK(1); /* - unused variables */
IntStack WarnUnusedFunc = INTSTACK(1); /* - unused functions */
IntStack WarnConstOverflow = INTSTACK(0); /* - overflow conversion of numerical constants */
/* Map the name of a warning to the intstack that holds its state */
typedef struct WarnMapEntry WarnMapEntry;
struct WarnMapEntry {
IntStack* Stack;
const char* Name;
};
static WarnMapEntry WarnMap[] = {
/* Keep names sorted, even if it isn't used for now */
{ &WarnConstComparison, "const-comparison" },
{ &WarningsAreErrors, "error" },
{ &WarnNoEffect, "no-effect" },
{ &WarnPointerSign, "pointer-sign" },
{ &WarnPointerTypes, "pointer-types" },
{ &WarnRemapZero, "remap-zero" },
{ &WarnReturnType, "return-type" },
{ &WarnStructParam, "struct-param" },
{ &WarnUnknownPragma, "unknown-pragma" },
{ &WarnUnreachableCode, "unreachable-code" },
{ &WarnUnusedFunc, "unused-func" },
{ &WarnUnusedLabel, "unused-label" },
{ &WarnUnusedParam, "unused-param" },
{ &WarnUnusedVar, "unused-var" },
{ &WarnConstOverflow, "const-overflow" },
};
Collection DiagnosticStrBufs;
/*****************************************************************************/
/* Helpers */
/*****************************************************************************/
static const char* GetDiagnosticFileName (void)
/* Get the source file name where the diagnostic info refers to */
{
if (CurTok.LI) {
return GetInputName (CurTok.LI);
} else {
return GetCurrentFilename ();
}
}
static unsigned GetDiagnosticLineNum (void)
/* Get the source line number where the diagnostic info refers to */
{
if (CurTok.LI) {
return GetInputLine (CurTok.LI);
} else {
return GetCurrentLineNum ();
}
}
/*****************************************************************************/
/* Handling of fatal errors */
/*****************************************************************************/
void Fatal (const char* Format, ...)
/* Print a message about a fatal error and die */
{
va_list ap;
fprintf (stderr, "%s:%u: Fatal: ", GetDiagnosticFileName (), GetDiagnosticLineNum ());
va_start (ap, Format);
vfprintf (stderr, Format, ap);
va_end (ap);
fprintf (stderr, "\n");
if (Line) {
Print (stderr, 1, "Input: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line));
}
exit (EXIT_FAILURE);
}
void Internal (const char* Format, ...)
/* Print a message about an internal compiler error and die */
{
va_list ap;
fprintf (stderr, "%s:%u: Internal compiler error:\n",
GetDiagnosticFileName (), GetDiagnosticLineNum ());
va_start (ap, Format);
vfprintf (stderr, Format, ap);
va_end (ap);
fprintf (stderr, "\n");
if (Line) {
fprintf (stderr, "\nInput: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line));
}
/* Use abort to create a core dump */
abort ();
}
/*****************************************************************************/
/* Handling of errors */
/*****************************************************************************/
static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va_list ap)
/* Print an error message - internal function */
{
fprintf (stderr, "%s:%u: Error: ", Filename, LineNo);
vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n");
if (Line) {
Print (stderr, 1, "Input: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line));
}
++ErrorCount;
if (ErrorCount > 20) {
Fatal ("Too many errors");
}
}
void Error (const char* Format, ...)
/* Print an error message */
{
va_list ap;
va_start (ap, Format);
IntError (GetDiagnosticFileName (), GetDiagnosticLineNum (), Format, ap);
va_end (ap);
}
void LIError (const LineInfo* LI, const char* Format, ...)
/* Print an error message with the line info given explicitly */
{
va_list ap;
va_start (ap, Format);
IntError (GetInputName (LI), GetInputLine (LI), Format, ap);
va_end (ap);
}
void PPError (const char* Format, ...)
/* Print an error message. For use within the preprocessor */
{
va_list ap;
va_start (ap, Format);
IntError (GetCurrentFilename(), GetCurrentLineNum(), Format, ap);
va_end (ap);
}
/*****************************************************************************/
/* Handling of warnings */
/*****************************************************************************/
static void IntWarning (const char* Filename, unsigned LineNo, const char* Msg, va_list ap)
/* Print a warning message - internal function */
{
if (IS_Get (&WarningsAreErrors)) {
/* Treat the warning as an error */
IntError (Filename, LineNo, Msg, ap);
} else if (IS_Get (&WarnEnable)) {
fprintf (stderr, "%s:%u: Warning: ", Filename, LineNo);
vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n");
if (Line) {
Print (stderr, 1, "Input: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line));
}
++WarningCount;
}
}
void Warning (const char* Format, ...)
/* Print a warning message */
{
va_list ap;
va_start (ap, Format);
IntWarning (GetDiagnosticFileName (), GetDiagnosticLineNum (), Format, ap);
va_end (ap);
}
void LIWarning (const LineInfo* LI, const char* Format, ...)
/* Print a warning message with the line info given explicitly */
{
va_list ap;
va_start (ap, Format);
IntWarning (GetInputName (LI), GetInputLine (LI), Format, ap);
va_end (ap);
}
void PPWarning (const char* Format, ...)
/* Print a warning message. For use within the preprocessor */
{
va_list ap;
va_start (ap, Format);
IntWarning (GetCurrentFilename(), GetCurrentLineNum(), Format, ap);
va_end (ap);
}
IntStack* FindWarning (const char* Name)
/* Search for a warning in the WarnMap table and return a pointer to the
** intstack that holds its state. Return NULL if there is no such warning.
*/
{
unsigned I;
/* For now, do a linear search */
for (I = 0; I < sizeof(WarnMap) / sizeof (WarnMap[0]); ++I) {
if (strcmp (WarnMap[I].Name, Name) == 0) {
return WarnMap[I].Stack;
}
}
return 0;
}
void ListWarnings (FILE* F)
/* Print a list of warning types/names to the given file */
{
unsigned I;
for (I = 0; I < sizeof(WarnMap) / sizeof (WarnMap[0]); ++I) {
fprintf (F, "%s\n", WarnMap[I].Name);
}
}
/*****************************************************************************/
/* Handling of other infos */
/*****************************************************************************/
static void IntNote (const char* Filename, unsigned LineNo, const char* Msg, va_list ap)
/* Print a note message - internal function */
{
fprintf (stderr, "%s:%u: Note: ", Filename, LineNo);
vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n");
}
void Note (const char* Format, ...)
/* Print a note message */
{
va_list ap;
va_start (ap, Format);
IntNote (GetDiagnosticFileName (), GetDiagnosticLineNum (), Format, ap);
va_end (ap);
}
void LINote (const LineInfo* LI, const char* Format, ...)
/* Print a note message with the line info given explicitly */
{
va_list ap;
va_start (ap, Format);
IntNote (GetInputName (LI), GetInputLine (LI), Format, ap);
va_end (ap);
}
void PPNote (const char* Format, ...)
/* Print a note message. For use within the preprocessor */
{
va_list ap;
va_start (ap, Format);
IntNote (GetCurrentFilename(), GetCurrentLineNum(), Format, ap);
va_end (ap);
}
/*****************************************************************************/
/* Code */
/*****************************************************************************/
void ErrorReport (void)
/* Report errors (called at end of compile) */
{
unsigned int V = (ErrorCount != 0 ? 0 : 1);
Print (stdout, V, "%u errors and %u warnings generated.\n", ErrorCount, WarningCount);
}
/*****************************************************************************/
/* Tracked StrBufs */
/*****************************************************************************/
void InitDiagnosticStrBufs (void)
/* Init tracking string buffers used for diagnostics */
{
InitCollection (&DiagnosticStrBufs);
}
void DoneDiagnosticStrBufs (void)
/* Done with tracked string buffers used for diagnostics */
{
ClearDiagnosticStrBufs ();
DoneCollection (&DiagnosticStrBufs);
}
void ClearDiagnosticStrBufs (void)
/* Free all tracked string buffers */
{
unsigned I;
for (I = 0; I < CollCount (&DiagnosticStrBufs); ++I) {
SB_Done (CollAtUnchecked (&DiagnosticStrBufs, I));
}
CollDeleteAll (&DiagnosticStrBufs);
}
struct StrBuf* NewDiagnosticStrBuf (void)
/* Get a new tracked string buffer */
{
StrBuf *Buf = NewStrBuf ();
CollAppend (&DiagnosticStrBufs, Buf);
return Buf;
}
|
adddcfcd21d79eeb65f4104fdc0c50f689af73b8
|
e1cddfd754d952134e72dfd03522c5ea4fb6008e
|
/src/plugins/unittest/rbtree_test.c
|
bfab98c3cd750ab1db0dd0325dde07d73a7593a9
|
[
"Apache-2.0"
] |
permissive
|
FDio/vpp
|
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
|
f234b0d4626d7e686422cc9dfd25958584f4931e
|
refs/heads/master
| 2023-08-31T16:09:04.068646
| 2022-03-14T09:49:15
| 2023-08-31T09:50:00
| 96,556,718
| 1,048
| 630
|
Apache-2.0
| 2023-06-21T05:39:17
| 2017-07-07T16:29:40
|
C
|
UTF-8
|
C
| false
| false
| 7,465
|
c
|
rbtree_test.c
|
/*
* Copyright (c) 2019 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vppinfra/rbtree.h>
#include <vlib/vlib.h>
#define RBTREE_TEST_I(_cond, _comment, _args...) \
({ \
int _evald = (_cond); \
if (!(_evald)) { \
fformat(stderr, "FAIL:%d: " _comment "\n", \
__LINE__, ##_args); \
} else { \
fformat(stderr, "PASS:%d: " _comment "\n", \
__LINE__, ##_args); \
} \
_evald; \
})
#define RBTREE_TEST(_cond, _comment, _args...) \
{ \
if (!RBTREE_TEST_I(_cond, _comment, ##_args)) { \
return 1; \
} \
}
static int
rbtree_test_basic (vlib_main_t * vm, unformat_input_t * input)
{
int __clib_unused verbose, n_keys = 1e3, i;
u32 *test_keys = 0, search_key;
rb_tree_t _rt, *rt = &_rt;
rb_node_t *n, *aux;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "verbose"))
verbose = 1;
else if (unformat (input, "nkeys %u", &n_keys))
;
else
{
vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
input);
return -1;
}
}
rb_tree_init (rt);
RBTREE_TEST (rb_tree_n_nodes (rt) == 1, "tnil created");
/*
* Add keys
*/
vec_validate (test_keys, n_keys - 1);
for (i = n_keys - 1; i >= 0; i--)
{
test_keys[i] = i;
rb_tree_add (rt, i);
}
RBTREE_TEST (rb_tree_n_nodes (rt) == n_keys + 1, "all nodes added");
n = rb_tree_max_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (n->key == n_keys - 1, "max should be %u", n_keys - 1);
n = rb_tree_min_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (n->key == 0, "min should be %u", 0);
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), n_keys / 2);
RBTREE_TEST (n->key == n_keys / 2, "search result should be %u",
n_keys / 2);
aux = rb_tree_successor (rt, n);
RBTREE_TEST (aux->key == n_keys / 2 + 1, "successor should be %u is %u",
n_keys / 2 + 1, aux->key);
aux = rb_tree_predecessor (rt, n);
RBTREE_TEST (aux->key == n_keys / 2 - 1, "predecessor should be %u is %u",
n_keys / 2 - 1, aux->key);
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), n_keys);
RBTREE_TEST (rb_node_is_tnil (rt, n), "search result should be tnil");
/*
* Delete even keys
*/
for (i = 0; i < n_keys; i += 2)
rb_tree_del (rt, i);
n = rb_tree_max_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (n->key == n_keys - 1, "max should be %u", n_keys - 1);
n = rb_tree_min_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (n->key == 1, "min should be %u and is %u", 1, n->key);
search_key = 2 * ((n_keys - 1) / 4);
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), search_key);
RBTREE_TEST (rb_node_is_tnil (rt, n), "search result for %u should be tnil",
search_key);
search_key += 1;
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), search_key);
RBTREE_TEST (n->key == search_key, "search result should be %u",
search_key);
aux = rb_tree_successor (rt, n);
RBTREE_TEST (aux->key == search_key + 2, "successor should be %u is %u",
search_key + 2, aux->key);
aux = rb_tree_predecessor (rt, n);
RBTREE_TEST (aux->key == search_key - 2, "predecessor should be %u is %u",
search_key - 2, aux->key);
/*
* Re-add even keys
*/
for (i = 0; i < n_keys; i += 2)
rb_tree_add (rt, i);
RBTREE_TEST (rb_tree_n_nodes (rt) == n_keys + 1, "number nodes %u is %u",
n_keys + 1, rb_tree_n_nodes (rt));
n = rb_tree_max_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (n->key == n_keys - 1, "max should be %u", n_keys - 1);
n = rb_tree_min_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (n->key == 0, "min should be %u", 0);
search_key = 2 * ((n_keys - 1) / 4);
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), search_key);
RBTREE_TEST (n->key == search_key, "search result should be %u",
search_key);
search_key += 1;
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), search_key);
RBTREE_TEST (n->key == search_key, "search result should be %u",
search_key);
aux = rb_tree_successor (rt, n);
RBTREE_TEST (aux->key == search_key + 1, "successor should be %u is %u",
search_key + 1, aux->key);
aux = rb_tree_predecessor (rt, n);
RBTREE_TEST (aux->key == search_key - 1, "predecessor should be %u is %u",
search_key - 1, aux->key);
/*
* Delete all keys
*/
for (i = 0; i < n_keys; i++)
{
rb_tree_del (rt, i);
if (rt->nodes[RBTREE_TNIL_INDEX].color != RBTREE_BLACK)
RBTREE_TEST (0, "tnil should be black");
}
RBTREE_TEST (rb_tree_n_nodes (rt) == 1, "number nodes %u is %u",
1, rb_tree_n_nodes (rt));
n = rb_tree_min_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (rb_node_is_tnil (rt, n), "min should be tnil");
n = rb_tree_max_subtree (rt, rb_node (rt, rt->root));
RBTREE_TEST (rb_node_is_tnil (rt, n), "max should be tnil");
search_key = 2 * ((n_keys - 1) / 4);
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), search_key);
RBTREE_TEST (rb_node_is_tnil (rt, n), "search result should be tnil");
/*
* Test successor/predecessor
*/
u8 test_vals[] = { 2, 3, 4, 6, 7, 9, 13, 15, 17, 18, 20 };
for (i = 0; i < sizeof (test_vals) / sizeof (u8); i++)
rb_tree_add (rt, test_vals[i]);
search_key = 13;
n = rb_tree_search_subtree (rt, rb_node (rt, rt->root), search_key);
RBTREE_TEST (n->key == search_key, "search result should be %u",
search_key);
aux = rb_tree_successor (rt, n);
RBTREE_TEST (aux->key == 15, "successor should be %u is %u", 15, aux->key);
aux = rb_tree_predecessor (rt, n);
RBTREE_TEST (aux->key == 9, "predecessor should be %u is %u", 9, aux->key);
n = aux;
aux = rb_tree_predecessor (rt, n);
RBTREE_TEST (aux->key == 7, "predecessor should be %u is %u", 7, aux->key);
/*
* Cleanup
*/
rb_tree_free_nodes (rt);
RBTREE_TEST (rb_tree_n_nodes (rt) == 0, "number nodes %u is %u",
0, rb_tree_n_nodes (rt));
return 0;
}
static clib_error_t *
rbtree_test (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd_arg)
{
int res = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "basic"))
{
res = rbtree_test_basic (vm, input);
}
else if (unformat (input, "all"))
{
if ((res = rbtree_test_basic (vm, input)))
goto done;
}
else
break;
}
done:
if (res)
return clib_error_return (0, "rbtree unit test failed");
return 0;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (rbtree_test_command, static) =
{
.path = "test rbtree",
.short_help = "internal rbtree unit tests",
.function = rbtree_test,
};
/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|
4760a72d632c03ded96b822292d9d8329601280f
|
4edd539e79d33f7a08a4c928d113771e9dac0740
|
/lib/burger/show3dologo.c
|
b17376e621a16197bee4a02b1a7b5f204bfbf901
|
[
"MIT"
] |
permissive
|
Olde-Skuul/doom3do
|
84ae4f312e919d070dcb838f7765c5c1ad3f5efd
|
8a5cdae476e09f2bedd2cc4dcd105dae4b35d4af
|
refs/heads/master
| 2023-03-07T19:10:13.752129
| 2023-01-11T22:54:07
| 2023-01-11T22:54:07
| 27,351,671
| 658
| 55
|
MIT
| 2022-11-03T04:07:37
| 2014-11-30T22:02:07
|
C
|
UTF-8
|
C
| false
| false
| 573
|
c
|
show3dologo.c
|
#include "Burger.h"
#include <Task.h>
#include <Filefunctions.h>
#define LOGOPROG "Logo"
/**********************************
This routine will load an executable program
that will display the 3DO logo and then fade to black
**********************************/
void Show3DOLogo(void)
{
Item LogoItem;
LogoItem=LoadProgram(LOGOPROG); /* Load and begin execution */
do {
Yield(); /* Yield all CPU time to the other program */
} while (LookupItem(LogoItem)); /* Wait until the program quits */
DeleteItem(LogoItem); /* Dispose of the 3DO logo code */
}
|
cbe0b89cf284736417a49763a236724d5cad0f01
|
d43f250248c55c6db2f4e14a5fceabf45209b88a
|
/spec/integration/monorepo/before/Frameworks/g/Sources/g.h
|
1b4c1f81dc278ae2b20751b8d22d5069524e0666
|
[
"MIT"
] |
permissive
|
square/cocoapods-generate
|
b66ec2649f8b7b7c9ff97e9898bb5c7c93ea280b
|
fc94b68a67728c7a69dd1c102822576854bbec49
|
refs/heads/master
| 2023-08-25T17:27:29.150861
| 2023-02-10T00:58:46
| 2023-02-10T00:58:46
| 134,632,340
| 262
| 42
|
MIT
| 2023-07-01T19:51:07
| 2018-05-23T22:33:32
|
Ruby
|
UTF-8
|
C
| false
| false
| 11
|
h
|
g.h
|
// g Header
|
9b15c01758a59797afe406edc514f8eacd871f8e
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/include/x86-linux-any/asm/stat.h
|
5796f6e6517b969dc403dfa1089e843ca2774f47
|
[
"MIT"
] |
permissive
|
ziglang/zig
|
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
|
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
|
refs/heads/master
| 2023-08-31T13:16:45.980913
| 2023-08-31T05:50:29
| 2023-08-31T05:50:29
| 40,276,274
| 25,560
| 2,399
|
MIT
| 2023-09-14T21:09:50
| 2015-08-06T00:51:28
|
Zig
|
UTF-8
|
C
| false
| false
| 3,130
|
h
|
stat.h
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _ASM_X86_STAT_H
#define _ASM_X86_STAT_H
#include <asm/posix_types.h>
#define STAT_HAVE_NSEC 1
#ifdef __i386__
struct stat {
unsigned long st_dev;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned long st_rdev;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long st_atime_nsec;
unsigned long st_mtime;
unsigned long st_mtime_nsec;
unsigned long st_ctime;
unsigned long st_ctime_nsec;
unsigned long __unused4;
unsigned long __unused5;
};
/* We don't need to memset the whole thing just to initialize the padding */
#define INIT_STRUCT_STAT_PADDING(st) do { \
st.__unused4 = 0; \
st.__unused5 = 0; \
} while (0)
#define STAT64_HAS_BROKEN_ST_INO 1
/* This matches struct stat64 in glibc2.1, hence the absolutely
* insane amounts of padding around dev_t's.
*/
struct stat64 {
unsigned long long st_dev;
unsigned char __pad0[4];
unsigned long __st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
unsigned long long st_rdev;
unsigned char __pad3[4];
long long st_size;
unsigned long st_blksize;
/* Number 512-byte blocks allocated. */
unsigned long long st_blocks;
unsigned long st_atime;
unsigned long st_atime_nsec;
unsigned long st_mtime;
unsigned int st_mtime_nsec;
unsigned long st_ctime;
unsigned long st_ctime_nsec;
unsigned long long st_ino;
};
/* We don't need to memset the whole thing just to initialize the padding */
#define INIT_STRUCT_STAT64_PADDING(st) do { \
memset(&st.__pad0, 0, sizeof(st.__pad0)); \
memset(&st.__pad3, 0, sizeof(st.__pad3)); \
} while (0)
#else /* __i386__ */
struct stat {
__kernel_ulong_t st_dev;
__kernel_ulong_t st_ino;
__kernel_ulong_t st_nlink;
unsigned int st_mode;
unsigned int st_uid;
unsigned int st_gid;
unsigned int __pad0;
__kernel_ulong_t st_rdev;
__kernel_long_t st_size;
__kernel_long_t st_blksize;
__kernel_long_t st_blocks; /* Number 512-byte blocks allocated. */
__kernel_ulong_t st_atime;
__kernel_ulong_t st_atime_nsec;
__kernel_ulong_t st_mtime;
__kernel_ulong_t st_mtime_nsec;
__kernel_ulong_t st_ctime;
__kernel_ulong_t st_ctime_nsec;
__kernel_long_t __unused[3];
};
/* We don't need to memset the whole thing just to initialize the padding */
#define INIT_STRUCT_STAT_PADDING(st) do { \
st.__pad0 = 0; \
st.__unused[0] = 0; \
st.__unused[1] = 0; \
st.__unused[2] = 0; \
} while (0)
#endif
/* for 32bit emulation and 32 bit kernels */
struct __old_kernel_stat {
unsigned short st_dev;
unsigned short st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
#ifdef __i386__
unsigned long st_size;
unsigned long st_atime;
unsigned long st_mtime;
unsigned long st_ctime;
#else
unsigned int st_size;
unsigned int st_atime;
unsigned int st_mtime;
unsigned int st_ctime;
#endif
};
#endif /* _ASM_X86_STAT_H */
|
a08492c4d5a1c79e7e7b300a9d137cc10cbbb37e
|
ec99010e1c3d7960c1723dfe35b76c73cfbbfe22
|
/src/file_utils.h
|
ba9b9511c9231fbf443d41ef97cf23128726c73e
|
[
"CC-BY-4.0",
"MIT"
] |
permissive
|
openvenues/libpostal
|
d8270049f45feccd1b961c65bb435d1b42d22db6
|
1fe1f0af1f328487e7397560e1b45beb6200ed85
|
refs/heads/master
| 2023-08-16T14:44:06.615711
| 2023-07-06T21:16:05
| 2023-07-06T21:16:05
| 31,570,906
| 3,876
| 466
|
MIT
| 2023-08-21T21:23:36
| 2015-03-03T00:21:31
|
C
|
UTF-8
|
C
| false
| false
| 2,238
|
h
|
file_utils.h
|
#ifndef FILE_UTILS_H
#define FILE_UTILS_H
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <sys/types.h>
#include "libpostal_config.h"
#include "string_utils.h"
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#define NAMLEN(dirent) strlen((dirent)->d_name)
#else
#define dirent direct
#define NAMLEN(dirent) ((dirent)->d_namlen)
#ifdef HAVE_SYS_NDIR_H
#include <sys/ndir.h>
#endif
#ifdef HAVE_SYS_DIR_H
#include <sys/dir.h>
#endif
#ifdef HAVE_NDIR_H
#include <ndir.h>
#endif
#endif
#ifndef BUFSIZ
#define BUFSIZ 4096
#endif
#ifdef _WIN32
#define PATH_SEPARATOR "\\"
#else
#define PATH_SEPARATOR "/"
#endif
#define PATH_SEPARATOR_LEN strlen(PATH_SEPARATOR)
#define TAB_SEPARATOR "\t"
#define TAB_SEPARATOR_LEN strlen(TAB_SEPARATOR)
#define COMMA_SEPARATOR ","
#define COMMA_SEPARATOR_LEN strlen(COMMA_SEPARATOR)
char *file_getline(FILE * f);
bool file_exists(char *filename);
bool is_relative_path(struct dirent *ent);
char *path_join(int n, ...);
char *path_vjoin(int n, va_list args);
uint64_t file_deserialize_uint64(unsigned char *buf);
bool file_read_uint64(FILE *file, uint64_t *value);
bool file_write_uint64(FILE *file, uint64_t value);
bool file_read_uint64_array(FILE *file, uint64_t *value, size_t n);
bool file_read_float(FILE *file, float *value);
bool file_write_float(FILE *file, float value);
bool file_read_float_array(FILE *file, float *value, size_t n);
bool file_read_double(FILE *file, double *value);
bool file_write_double(FILE *file, double value);
bool file_read_double_array(FILE *file, double *value, size_t n);
uint32_t file_deserialize_uint32(unsigned char *buf);
bool file_read_uint32(FILE *file, uint32_t *value);
bool file_write_uint32(FILE *file, uint32_t value);
bool file_read_uint32_array(FILE *file, uint32_t *value, size_t n);
uint16_t file_deserialize_uint16(unsigned char *buf);
bool file_read_uint16(FILE *file, uint16_t *value);
bool file_write_uint16(FILE *file, uint16_t value);
bool file_read_uint8(FILE *file, uint8_t *value);
bool file_write_uint8(FILE *file, uint8_t value);
bool file_read_chars(FILE *file, char *buf, size_t len);
bool file_write_chars(FILE *file, const char *buf, size_t len);
#endif
|
dab8f4eced8fdb07b84ecd4bda26d42465071707
|
a9a591fc3964117db3b16583c3bfa5a24cfc0114
|
/src/grains.c
|
47bd9f3102015686c32e8645c7dd8c6b77d44368
|
[
"BSD-2-Clause"
] |
permissive
|
grz0zrg/fas
|
9cd0a55c7e86fcf5cafffd44ebdf633f3ee5fefa
|
07b08a77b78781dd5ed7984117f294fe4fcbe3fd
|
refs/heads/master
| 2022-09-18T05:29:27.983761
| 2022-08-30T19:53:19
| 2022-08-30T19:53:19
| 78,288,048
| 142
| 10
|
BSD-2-Clause
| 2021-05-25T01:43:22
| 2017-01-07T15:53:24
|
C
|
UTF-8
|
C
| false
| false
| 7,367
|
c
|
grains.c
|
#include "grains.h"
// granular synthesis : grains setup
// all possible grains (and sub-grains from max_density parameter) are pre-computed in memory
struct grain *createGrains(struct sample **s, unsigned int samples_count, unsigned int n, FAS_FLOAT base_frequency, unsigned int octaves, unsigned int sample_rate, unsigned int max_instruments, unsigned int max_density) {
if (samples_count == 0) {
return NULL;
}
unsigned int grains_count = n * max_density * samples_count;
unsigned int y = 0;
FAS_FLOAT octave_length = (FAS_FLOAT)n / octaves;
struct sample *samples = *s;
struct grain *g = (struct grain *)calloc(grains_count, sizeof(struct grain));
for (unsigned int i = 0; i < grains_count; i += samples_count) {
for (unsigned int k = 0; k < samples_count; k += 1) {
int gr_index = i + k;
struct sample *smp = &samples[k];
FAS_FLOAT frequency = base_frequency * pow(2, (n-y) / octave_length);
FAS_FLOAT grain_speed = frequency / smp->pitch / ((FAS_FLOAT)sample_rate / (FAS_FLOAT)smp->samplerate);
if (grain_speed <= 0) {
grain_speed = 1;
}
// channels dependent parameters
g[gr_index].frame = calloc(max_instruments, sizeof(FAS_FLOAT));
g[gr_index].frames = calloc(max_instruments, sizeof(unsigned int));
//g[gr_index].index = calloc(max_instruments, sizeof(unsigned int));
g[gr_index].env_index = calloc(max_instruments, sizeof(FAS_FLOAT));
g[gr_index].env_step = calloc(max_instruments, sizeof(FAS_FLOAT));
g[gr_index].smp_index = calloc(max_instruments, sizeof(unsigned int));
g[gr_index].density = calloc(max_instruments, sizeof(unsigned int));
g[gr_index].speed = calloc(max_instruments, sizeof(FAS_FLOAT));
// initialization for each simultaneous channels
for (unsigned int j = 0; j < max_instruments; j += 1) {
g[gr_index].env_index[j] = FAS_ENVS_SIZE;
g[gr_index].smp_index[j] = k;
g[gr_index].density[j] = 1;
g[gr_index].speed[j] = grain_speed;
}
}
y++;
y = y % n;
}
return g;
}
inline void computeGrains(unsigned int channel, struct grain *g, unsigned int grain_index, FAS_FLOAT alpha, unsigned int si, unsigned int density, FAS_FLOAT density_offset, FAS_FLOAT *gr_env, struct sample *samples, unsigned int smp_index, unsigned int sample_rate, FAS_FLOAT min_duration, FAS_FLOAT max_duration, FAS_FLOAT *out_l, FAS_FLOAT *out_r) {
struct grain *gr = &g[grain_index];
struct sample *smp = &samples[smp_index];
//unsigned int density_start = density_offset * si;
for (unsigned int d = /*density_start*/0; d < (/*density_start + */si * gr->density[channel]); d += si) {
gr = &g[grain_index + d];
FAS_FLOAT env_index = gr->env_index[channel];
if (env_index >= FAS_ENVS_SIZE) {
FAS_FLOAT gr_speed = gr->speed[channel];
FAS_FLOAT grain_start = (FAS_FLOAT)smp->frames - 1.0f;
FAS_FLOAT grain_position = fabs(alpha);
grain_start = roundf(grain_start * fmax(fmin(grain_position, 1.0f), 0.0f) + (grain_start * (density_offset * randf(0.0f, 1.0f))));//(1.0f - randf(0.0f, 1.0f) * floor(fmin(grain_position - 0.0001f, 1.0f))));
//gr->index[k] = grain_start;
// old algorithm (percent of sample length, no cycles)
// roundf(grain_start + fmax(randf(GRAIN_MIN_DURATION + min_duration, max_duration), GRAIN_MIN_DURATION) * (smp->frames - grain_start - 1)) + 1;
gr->frames[channel] = fmax(roundf(fmax(randf(GRAIN_MIN_DURATION + min_duration, max_duration), GRAIN_MIN_DURATION) * (FAS_FLOAT)sample_rate), 0.00000001);
gr->env_step[channel] = fmax(((FAS_FLOAT)(FAS_ENVS_SIZE)) / (((FAS_FLOAT)gr->frames[channel]/* - (FAS_FLOAT)grain_start*/) / fabs(gr_speed)), 0.00000001);
gr->env_index[channel] = 0.0f;
gr->density[channel] = density;
env_index = 0.0f;
if (alpha < 0.0f) {
if (gr_speed > 0.0f) {
gr->speed[channel] = -gr_speed;
}
gr->frame[channel] = grain_start + gr->frames[channel];
} else {
gr->speed[channel] = fabs(gr_speed);
gr->frame[channel] = grain_start + gr->frames[channel];
if (gr->frame[channel] > ((FAS_FLOAT)smp->frames - 1.0f)) {
gr->frame[channel] -= ((FAS_FLOAT)smp->frames - 1.0f) + 1;
}
}
}
FAS_FLOAT pos = gr->frame[channel];
unsigned int sample_index = ((unsigned int)pos) % smp->frames;
unsigned int sample_index2 = sample_index + 1;
FAS_FLOAT smp_l = smp->data_l[sample_index];
FAS_FLOAT smp_r = smp->data_r[sample_index];
FAS_FLOAT smp_l2 = smp->data_l[sample_index2];
FAS_FLOAT smp_r2 = smp->data_r[sample_index2];
FAS_FLOAT mu = pos - (FAS_FLOAT)sample_index;
#ifdef FAS_USE_CUBIC_INTERP
unsigned int sample_index3 = sample_index2 + 1;
unsigned int sample_index4 = sample_index3 + 1;
FAS_FLOAT smp_l3 = smp->data_l[sample_index3];
FAS_FLOAT smp_r3 = smp->data_r[sample_index3];
FAS_FLOAT smp_l4 = smp->data_l[sample_index4];
FAS_FLOAT smp_r4 = smp->data_r[sample_index4];
FAS_FLOAT smp_lv = smp_l2 + 0.5 * mu*(smp_l3 - smp_l + mu*(2.0*smp_l - 5.0*smp_l2 + 4.0*smp_l3 - smp_l4 + mu*(3.0*(smp_l2 - smp_l3) + smp_l4 - smp_l)));
FAS_FLOAT smp_rv = smp_r2 + 0.5 * mu*(smp_r3 - smp_r + mu*(2.0*smp_r - 5.0*smp_r2 + 4.0*smp_r3 - smp_r4 + mu*(3.0*(smp_r2 - smp_r3) + smp_r4 - smp_r)));
#else
FAS_FLOAT smp_lv = smp_l + mu * (smp_l2 - smp_l);
FAS_FLOAT smp_rv = smp_r + mu * (smp_r2 - smp_r);
#endif
FAS_FLOAT env = gr_env[(unsigned int)roundf(env_index)];
*out_l += smp_lv * env;
*out_r += smp_rv * env;
gr->frame[channel] += gr->speed[channel];
if (gr->frame[channel] < 0) {
gr->frame[channel] = ((FAS_FLOAT)smp->frames - 1.0f);
}
if (gr->frame[channel] > ((FAS_FLOAT)smp->frames - 1.0f)) {
gr->frame[channel] = 0;
}
gr->env_index[channel] += gr->env_step[channel];
}
}
struct grain *freeGrains(struct grain **g, unsigned int samples_count, unsigned int max_instruments, unsigned int n, unsigned int max_density) {
if (samples_count == 0) {
return NULL;
}
struct grain *grains = *g;
if (grains == NULL) {
return NULL;
}
unsigned int grains_count = n * max_density * samples_count;
unsigned int y = 0;
for (y = 0; y < grains_count; y += samples_count) {
for (unsigned int k = 0; k < samples_count; k += 1) {
int gr_index = y + k;
free(grains[gr_index].frame);
free(grains[gr_index].frames);
//free(grains[gr_index].index);
free(grains[gr_index].env_index);
free(grains[gr_index].env_step);
free(grains[gr_index].smp_index);
free(grains[gr_index].density);
free(grains[gr_index].speed);
}
}
free(grains);
return NULL;
}
|
150dcbf39bf95af690878456f1f33e1ef3fa1572
|
80d97bc5ff8a43da99893a57f03002e68081d780
|
/src/Extension/Lexers.c
|
2f4fff02180598d6746e2423b508e59f4d1c95f6
|
[
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
ProgerXP/Notepad2e
|
38798db10e0fe0a5602a463a5681bd653afe3bb6
|
c703f11bc278457286b3ca1565047a3b09ccdf8d
|
refs/heads/master
| 2023-09-05T23:32:07.576076
| 2023-07-27T11:03:30
| 2023-07-27T11:03:49
| 10,840,481
| 376
| 50
|
NOASSERTION
| 2022-08-22T14:06:36
| 2013-06-21T10:28:18
|
C++
|
UTF-8
|
C
| false
| false
| 121,409
|
c
|
Lexers.c
|
#include "Lexers.h"
KEYWORDLIST KeyWords_NULL = {
"", "", "", "", "", "", "", "", ""
};
EDITLEXER lexDefault = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx; log; asc; doc; diz; nfo", L"", &KeyWords_NULL, NULL_COMMENT_INFO, {
// [2e]: update EDefaultLexerOptions enum in case of changed order
/* 0 */ { STYLE_DEFAULT, 63100, L"Default Style", L"font:Lucida Console; size:10", L"" },
/* 1 */ { STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"size:-1", L"" },
/* 2 */ { STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+1; bold; fore:#FF0000", L"" },
/* 3 */ { STYLE_BRACEBAD, 63103, L"Matching Braces Error", L"size:+1; bold; fore:#000080", L"" },
/* 4 */ { STYLE_CONTROLCHAR, 63104, L"Control Characters (Font)", L"size:-1", L"" },
/* 5 */ { STYLE_INDENTGUIDE, 63105, L"Indentation Guide (Color)", L"fore:#A0A0A0", L"" },
/* 6 */ { SCI_SETSELFORE + SCI_SETSELBACK, 63106, L"Selected Text (Colors)", L"back:#0A246A; eolfilled; alpha:95", L"" },
/* 7 */ { SCI_SETWHITESPACEFORE + SCI_SETWHITESPACEBACK + SCI_SETWHITESPACESIZE, 63107, L"Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" },
/* 8 */ { SCI_SETCARETLINEBACK + SCI_SETCARETLINEBACKALPHA, 63108, L"Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" },
/* 9 */ { SCI_SETCARETLINEBACK + SCI_SETCARETLINEBACKALPHA, 63361, L"Current Line, Inactive View (Color)", L"back:#999999; alpha:50", L"" },
/* 10 */ { SCI_SETCARETFORE + SCI_SETCARETWIDTH, 63109, L"Caret (Color, Size 1-3)", L"", L"" },
/* 11 */ { SCI_SETEDGECOLOUR, 63110, L"Long Line Marker (Colors)", L"fore:#FFC000", L"" },
/* 12 */ { SCI_SETEXTRAASCENT + SCI_SETEXTRADESCENT, 63111, L"Extra Line Spacing (Size)", L"size:2", L"" },
/* 13 */ { 0, 63124, L"Splitter (Color, Size)", L"size:0", L"" },
/* 14 */ { STYLE_DEFAULT, 63112, L"2nd Default Style", L"font:Courier New; size:10", L"" },
/* 15 */ { STYLE_LINENUMBER, 63113, L"2nd Margins and Line Numbers", L"font:Tahoma; size:-2; fore:#FF0000", L"" },
/* 16 */ { STYLE_BRACELIGHT, 63114, L"2nd Matching Braces", L"bold; fore:#FF0000", L"" },
/* 17 */ { STYLE_BRACEBAD, 63115, L"2nd Matching Braces Error", L"bold; fore:#000080", L"" },
/* 18 */ { STYLE_CONTROLCHAR, 63116, L"2nd Control Characters (Font)", L"size:-1", L"" },
/* 19 */ { STYLE_INDENTGUIDE, 63117, L"2nd Indentation Guide (Color)", L"fore:#A0A0A0", L"" },
/* 20 */ { SCI_SETSELFORE + SCI_SETSELBACK, 63118, L"2nd Selected Text (Colors)", L"eolfilled", L"" },
/* 21 */ { SCI_SETWHITESPACEFORE + SCI_SETWHITESPACEBACK + SCI_SETWHITESPACESIZE, 63119, L"2nd Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" },
/* 22 */ { SCI_SETCARETLINEBACK + SCI_SETCARETLINEBACKALPHA, 63120, L"2nd Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" },
/* 23 */ { SCI_SETCARETLINEBACK + SCI_SETCARETLINEBACKALPHA, 63362, L"2nd Current Line, Inactive View (Color)", L"back:#999999; alpha:50", L"" },
/* 24 */ { SCI_SETCARETFORE + SCI_SETCARETWIDTH, 63121, L"2nd Caret (Color, Size 1-3)", L"", L"" },
/* 25 */ { SCI_SETEDGECOLOUR, 63122, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" },
/* 26 */ { SCI_SETEXTRAASCENT + SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_HTML = {
"!doctype ^aria- ^data- a abbr accept accept-charset accesskey acronym action address align alink "
"alt and applet archive area article aside async audio autocomplete autofocus autoplay axis b "
"background base basefont bb bdi bdo bgcolor big blockquote body border bordercolor br button "
"canvas caption cellpadding cellspacing center challenge char charoff charset checkbox checked "
"cite class classid clear code codebase codetype col colgroup color cols colspan command compact "
"content contenteditable contextmenu controls coords data datafld dataformatas datagrid datalist "
"datapagesize datasrc datetime dd declare default defer del details dfn dialog dir dirname "
"disabled div dl draggable dropzone dt em embed enctype event eventsource face fieldset "
"figcaption figure file font footer for form formaction formenctype formmethod formnovalidate "
"formtarget frame frameborder frameset h1 h2 h3 h4 h5 h6 head header headers height hgroup hidden "
"high hr href hreflang hspace html http-equiv i icon id iframe image img input ins isindex ismap "
"kbd keygen keytype kind label lang language leftmargin legend li link list longdesc loop low "
"main manifest map marginheight marginwidth mark max maxlength media menu meta meter method min "
"multiple name nav noframes nohref noresize noscript noshade novalidate nowrap object ol onabort "
"onafterprint onbeforeprint onbeforeunload onblur oncanplay oncanplaythrough onchange onclick "
"oncontextmenu oncuechange ondblclick ondrag ondragend ondragenter ondragleave ondragover "
"ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange onforminput "
"onhashchange oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata "
"onloadstart onmessage onmousedown onmousemove onmouseout onmouseover onmouseup onmousewheel "
"onoffline ononline onpagehide onpageshow onpause onplay onplaying onpopstate onprogress "
"onratechange onreadystatechange onredo onreset onresize onscroll onseeked onseeking onselect "
"onshow onstalled onstorage onsubmit onsuspend ontimeupdate onundo onunload onvolumechange "
"onwaiting open optgroup optimum option output p param password pattern picture ping placeholder poster "
"pre preload profile progress prompt pubdate public q radio radiogroup rb readonly rel required "
"reset rev reversed rows rowspan rp rt rtc ruby rules s samp sandbox scheme scope scoped script "
"scrolling seamless section select selected shape size sizes small source span spellcheck src "
"srcdoc srclang standby start step strike strong style sub submit summary sup tabindex table "
"target tbody td template text textarea tfoot th thead time title topmargin tr track tt type u ul usemap "
"valign value valuetype var version video vlink vspace wbr width wrap xml xmlns",
"abstract boolean break byte case catch char class const continue debugger default delete do "
"double else enum export extends false final finally float for function goto if implements "
"import in instanceof int interface long native new null package private protected public "
"return short static super switch synchronized this throw throws transient true try typeof var "
"void volatile while with",
"alias and as attribute begin boolean byref byte byval call case class compare const continue "
"currency date declare dim do double each else elseif empty end enum eqv erase error event exit "
"explicit false for friend function get global gosub goto if imp implement in integer is let lib "
"load long loop lset me mid mod module new next not nothing null object on option optional or "
"preserve private property public raiseevent redim rem resume return rset select set single "
"static stop string sub then to true type unload until variant wend while with withevents xor",
"",
"__callstatic __class__ __dir__ __file__ __function__ __get __isset __line__ __method__ "
"__namespace__ __set __sleep __unset __wakeup abstract and argc argv array as break case catch "
"cfunction class clone const continue declare default define die do e_all e_error e_fatal "
"e_notice e_parse e_strict e_warning echo else elseif empty enddeclare endfor endforeach endif "
"endswitch endwhile eval exception exit extends false final for foreach function global goto "
"http_cookie_vars http_env_vars http_get_vars http_post_files http_post_vars http_server_vars if "
"implements include include_once instanceof interface isset list namespace new not null "
"old_function or parent php_self print private protected public require require_once return "
"static stdclass switch this throw true try unset use var virtual while xor",
"", "", "", ""
};
EDITLEXER lexHTML = { SCLEX_HTML, 63001, L"Web Source Code", L"html; htm; asp; aspx; shtml; htd; xhtml; php; php3; phtml; htt; cfm; tpl; dtd; hta; htc", L"", &KeyWords_HTML, COMMENT_INFO(C_COMMENT, MULTI_STYLE(SCE_HPHP_COMMENTLINE, SCE_HJ_COMMENTLINE, SCE_HJA_COMMENTLINE, SCE_HBA_COMMENTLINE)), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_H_TAG, SCE_H_TAGEND, 0, 0), 63136, L"HTML Tag", L"fore:#648000", L"" },
{ SCE_H_TAGUNKNOWN, 63137, L"HTML Unknown Tag", L"fore:#C80000; back:#FFFF80", L"" },
{ SCE_H_ATTRIBUTE, 63138, L"HTML Attribute", L"fore:#FF4000", L"" },
{ SCE_H_ATTRIBUTEUNKNOWN, 63139, L"HTML Unknown Attribute", L"fore:#C80000; back:#FFFF80", L"" },
{ SCE_H_VALUE, 63140, L"HTML Value", L"fore:#3A6EA5", L"" },
{ MULTI_STYLE(SCE_H_DOUBLESTRING, SCE_H_SINGLESTRING, 0, 0), 63141, L"HTML String", L"fore:#3A6EA5", L"" },
{ SCE_H_OTHER, 63142, L"HTML Other Inside Tag", L"fore:#3A6EA5", L"" },
{ MULTI_STYLE(SCE_H_COMMENT, SCE_H_XCCOMMENT, 0, 0), 63143, L"HTML Comment", L"fore:#646464", L"" },
{ SCE_H_ENTITY, 63144, L"HTML Entity", L"fore:#B000B0", L"" },
{ SCE_H_DEFAULT, 63256, L"HTML Element Text", L"", L"" },
{ MULTI_STYLE(SCE_H_XMLSTART, SCE_H_XMLEND, 0, 0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" },
{ SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" },
{ SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" },
{ MULTI_STYLE(SCE_H_ASP, SCE_H_ASPAT, 0, 0), 63146, L"ASP Start Tag", L"bold; fore:#000080", L"" },
{ SCE_H_QUESTION, 63148, L"PHP Start Tag", L"bold; fore:#000080", L"" },
{ SCE_HPHP_DEFAULT, 63149, L"PHP Default", L"", L"" },
{ MULTI_STYLE(SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, 0, 0), 63157, L"PHP Comment", L"fore:#FF8000", L"" },
{ SCE_HPHP_WORD, 63152, L"PHP Keyword", L"bold; fore:#A46000", L"" },
{ SCE_HPHP_HSTRING, 63150, L"PHP String", L"fore:#008000", L"" },
{ SCE_HPHP_SIMPLESTRING, 63151, L"PHP Simple String", L"fore:#008000", L"" },
{ SCE_HPHP_NUMBER, 63153, L"PHP Number", L"fore:#FF0000", L"" },
{ SCE_HPHP_OPERATOR, 63158, L"PHP Operator", L"fore:#B000B0", L"" },
{ SCE_HPHP_VARIABLE, 63154, L"PHP Variable", L"italic; fore:#000080", L"" },
{ SCE_HPHP_HSTRING_VARIABLE, 63155, L"PHP String Variable", L"italic; fore:#000080", L"" },
{ SCE_HPHP_COMPLEX_VARIABLE, 63156, L"PHP Complex Variable", L"italic; fore:#000080", L"" },
{ MULTI_STYLE(SCE_HJ_DEFAULT, SCE_HJ_START, 0, 0), 63159, L"JS Default", L"", L"" },
{ MULTI_STYLE(SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, 0), 63160, L"JS Comment", L"fore:#646464", L"" },
{ SCE_HJ_KEYWORD, 63163, L"JS Keyword", L"bold; fore:#A46000", L"" },
{ SCE_HJ_WORD, 63162, L"JS Identifier", L"", L"" },
{ MULTI_STYLE(SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, 0), 63164, L"JS String", L"fore:#008000", L"" },
{ SCE_HJ_REGEX, 63166, L"JS Regex", L"fore:#006633; back:#FFF1A8", L"" },
{ SCE_HJ_NUMBER, 63161, L"JS Number", L"fore:#FF0000", L"" },
{ SCE_HJ_SYMBOLS, 63165, L"JS Symbols", L"fore:#B000B0", L"" },
{ MULTI_STYLE(SCE_HJA_DEFAULT, SCE_HJA_START, 0, 0), 63167, L"ASP JS Default", L"", L"" },
{ MULTI_STYLE(SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, SCE_HJA_COMMENTDOC, 0), 63168, L"ASP JS Comment", L"fore:#646464", L"" },
{ SCE_HJA_KEYWORD, 63171, L"ASP JS Keyword", L"bold; fore:#A46000", L"" },
{ SCE_HJA_WORD, 63170, L"ASP JS Identifier", L"", L"" },
{ MULTI_STYLE(SCE_HJA_DOUBLESTRING, SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, 0), 63172, L"ASP JS String", L"fore:#008000", L"" },
{ SCE_HJA_REGEX, 63174, L"ASP JS Regex", L"fore:#006633; back:#FFF1A8", L"" },
{ SCE_HJA_NUMBER, 63169, L"ASP JS Number", L"fore:#FF0000", L"" },
{ SCE_HJA_SYMBOLS, 63173, L"ASP JS Symbols", L"fore:#B000B0", L"" },
{ MULTI_STYLE(SCE_HB_DEFAULT, SCE_HB_START, 0, 0), 63175, L"VBS Default", L"", L"" },
{ SCE_HB_COMMENTLINE, 63176, L"VBS Comment", L"fore:#646464", L"" },
{ SCE_HB_WORD, 63178, L"VBS Keyword", L"bold; fore:#B000B0", L"" },
{ SCE_HB_IDENTIFIER, 63180, L"VBS Identifier", L"", L"" },
{ MULTI_STYLE(SCE_HB_STRING, SCE_HB_STRINGEOL, 0, 0), 63179, L"VBS String", L"fore:#008000", L"" },
{ SCE_HB_NUMBER, 63177, L"VBS Number", L"fore:#FF0000", L"" },
{ MULTI_STYLE(SCE_HBA_DEFAULT, SCE_HBA_START, 0, 0), 63181, L"ASP VBS Default", L"", L"" },
{ SCE_HBA_COMMENTLINE, 63182, L"ASP VBS Comment", L"fore:#646464", L"" },
{ SCE_HBA_WORD, 63184, L"ASP VBS Keyword", L"bold; fore:#B000B0", L"" },
{ SCE_HBA_IDENTIFIER, 63186, L"ASP VBS Identifier", L"", L"" },
{ MULTI_STYLE(SCE_HBA_STRING, SCE_HBA_STRINGEOL, 0, 0), 63185, L"ASP VBS String", L"fore:#008000", L"" },
{ SCE_HBA_NUMBER, 63183, L"ASP VBS Number", L"fore:#FF0000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_XML = {
"", "", "", "", "", "", "", "", ""
};
EDITLEXER lexXML = { SCLEX_XML, 63002, L"XML", L"xml; xsl; rss; svg; xul; xsd; xslt; axl; rdf; xaml; vcproj", L"", &KeyWords_XML, COMMENT_INFO(C_COMMENT, 0), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_H_TAG, SCE_H_TAGUNKNOWN, SCE_H_TAGEND, 0), 63187, L"XML Tag", L"fore:#881280", L"" },
{ MULTI_STYLE(SCE_H_ATTRIBUTE, SCE_H_ATTRIBUTEUNKNOWN, 0, 0), 63188, L"XML Attribute", L"fore:#994500", L"" },
{ SCE_H_VALUE, 63189, L"XML Value", L"fore:#1A1AA6", L"" },
{ MULTI_STYLE(SCE_H_DOUBLESTRING, SCE_H_SINGLESTRING, 0, 0), 63190, L"XML String", L"fore:#1A1AA6", L"" },
{ SCE_H_OTHER, 63191, L"XML Other Inside Tag", L"fore:#1A1AA6", L"" },
{ MULTI_STYLE(SCE_H_COMMENT, SCE_H_XCCOMMENT, 0, 0), 63192, L"XML Comment", L"fore:#646464", L"" },
{ SCE_H_ENTITY, 63193, L"XML Entity", L"fore:#B000B0", L"" },
{ SCE_H_DEFAULT, 63257, L"XML Element Text", L"", L"" },
{ MULTI_STYLE(SCE_H_XMLSTART, SCE_H_XMLEND, 0, 0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" },
{ SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" },
{ SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_CSS = {
"^-moz- ^-ms- ^-o- ^-webkit-"
" animation animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-play-state"
" background background-attachment background-color background-image background-position background-repeat background-clip background-origin background-size"
" border border-bottom border-bottom-color border-bottom-style border-bottom-width border-color border-left border-left-color border-left-style border-left-width"
" border-right border-right-color border-right-style border-right-width border-style border-top border-top-color border-top-style border-top-width border-width"
" outline outline-color outline-style outline-width border-bottom-left-radius border-bottom-right-radius"
" border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width"
" border-radius border-top-left-radius border-top-right-radius box-decoration-break box-shadow"
" overflow-x overflow-y overflow-style rotation rotation-point overflow-x overflow-y overflow-style"
" rotation rotation-point bookmark-label bookmark-level bookmark-target float-offset hyphenate-after hyphenate-before hyphenate-character hyphenate-lines hyphenate-resource"
" hyphens image-resolution marks string-set height max-height max-width min-height min-width width"
" box-align box-direction box-flex box-flex-group box-lines box-ordinal-group box-orient box-pack font font-family font-size font-style"
" font-variant font-weight font-size-adjust font-stretch content counter-increment counter-reset quotes crop move-to page-policy grid-columns grid-rows"
" target target-name target-new target-position alignment-adjust alignment-baseline baseline-shift dominant-baseline drop-initial-after-adjust"
" drop-initial-after-align drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value inline-box-align line-stacking line-stacking-ruby"
" line-stacking-shift line-stacking-strategy text-height list-style list-style-image list-style-position list-style-type"
" margin margin-bottom margin-left margin-right margin-top marquee-direction marquee-play-count marquee-speed marquee-style"
" column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width"
" columns padding padding-bottom padding-left padding-right padding-top fit fit-position image-orientation"
" page size bottom clear clip cursor display float left overflow position right top visibility"
" z-index orphans page-break-after page-break-before page-break-inside widows ruby-align ruby-overhang ruby-position ruby-span mark mark-after mark-before"
" phonemes rest rest-after rest-before voice-balance voice-duration voice-pitch voice-pitch-range voice-rate voice-stress voice-volume border-collapse border-spacing caption-side"
" empty-cells table-layout color direction letter-spacing line-height text-align text-decoration text-indent text-transform unicode-bidi vertical-align white-space"
" word-spacing hanging-punctuation punctuation-trim text-align-last text-justify text-outline text-overflow text-shadow text-wrap"
" word-break word-wrap transform transform-origin transform-style perspective perspective-origin backface-visibility"
" transition transition-property transition-duration transition-timing-function transition-delay appearance box-sizing icon"
" nav-down nav-index nav-left nav-right nav-up outline-offset resize color-profile opacity rendering-intent"
,
"active after before checked default disabled empty enabled first first-child first-letter"
" first-line first-of-type focus hover indeterminate invalid lang last-child last-of-type left"
" link not nth-child nth-last-child nth-last-of-type nth-of-type only-child only-of-type optional"
" required right root target valid visited"
,
"", "", "", "", "", "", ""
};
EDITLEXER lexCSS = { SCLEX_CSS, 63003, L"CSS Style Sheets", L"css", L"", &KeyWords_CSS, COMMENT_INFO(C_COMMENT, 0), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_CSS_COMMENT, 63127, L"Comment", L"fore:#646464", L"" },
{ SCE_CSS_TAG, 63136, L"HTML Tag", L"bold; fore:#0A246A", L"" },
{ SCE_CSS_CLASS, 63194, L"Tag-Class", L"fore:#648000", L"" },
{ SCE_CSS_ID, 63195, L"Tag-Id", L"fore:#648000", L"" },
{ SCE_CSS_ATTRIBUTE, 63196, L"Tag-Attribute", L"italic; fore:#648000", L"" },
{ MULTI_STYLE(SCE_CSS_PSEUDOCLASS, SCE_CSS_EXTENDED_PSEUDOCLASS, SCE_CSS_PSEUDOELEMENT, SCE_CSS_EXTENDED_PSEUDOELEMENT), 63197, L"Pseudo-class/element", L"fore:#B000B0", L"" },
{ SCE_CSS_UNKNOWN_PSEUDOCLASS, 63198, L"Unknown Pseudo-class", L"fore:#C80000; back:#FFFF80", L"" },
{ MULTI_STYLE(SCE_CSS_IDENTIFIER, SCE_CSS_IDENTIFIER2, SCE_CSS_IDENTIFIER3, SCE_CSS_EXTENDED_IDENTIFIER), 63199, L"CSS Property", L"fore:#FF4000", L"" },
{ SCE_CSS_UNKNOWN_IDENTIFIER, 63200, L"Unknown Property", L"fore:#C80000; back:#FFFF80", L"" },
{ MULTI_STYLE(SCE_CSS_DOUBLESTRING, SCE_CSS_SINGLESTRING, 0, 0), 63131, L"String", L"fore:#008000", L"" },
{ SCE_CSS_VALUE, 63201, L"Value", L"fore:#3A6EA5", L"" },
{ SCE_CSS_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
{ SCE_CSS_IMPORTANT, 63202, L"Important", L"bold; fore:#C80000", L"" },
{ SCE_CSS_DIRECTIVE, 63203, L"Directive", L"bold; fore:#000000; back:#FFF1A8", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_CPP = {
"__abstract __alignof __asm __assume __based __box __cdecl __declspec __delegate __event "
"__except __except__try __fastcall __finally __forceinline __gc __hook __identifier "
"__if_exists __if_not_exists __inline __int16 __int32 __int64 __int8 __interface __leave "
"__m128 __m128d __m128i __m64 __multiple_inheritance __nogc __noop __pin __property __raise "
"__sealed __single_inheritance __stdcall __super __try __try_cast __unhook __uuidof __value "
"__virtual_inheritance __wchar_t auto bool break case catch char class const const_cast "
"continue default defined delete do double dynamic_cast else enum explicit extern false float "
"for friend goto if inline int long mutable naked namespace new operator private protected "
"public register reinterpret_cast return short signed size_t sizeof static static_cast struct "
"switch template this throw true try typedef typeid typename union unsigned using uuid "
"virtual void volatile wchar_t while",
"",
"", "", "", "", "", "", ""
};
EDITLEXER lexCPP = { SCLEX_CPP, 63004, L"C/C++", L"c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl", L"", &KeyWords_CPP, COMMENT_INFO(C_COMMENT, SCE_C_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE2(SCE_C_COMMENT, SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR, 0, 0), 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" },
{ SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_C_STRING, SCE_C_CHARACTER, SCE_C_STRINGEOL, SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
{ SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
{ SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_CS = {
"abstract as base bool break byte case catch char checked class const "
"continue decimal default delegate do double else enum event explicit "
"extern false finally fixed float for foreach goto if implicit in int interface "
"internal is lock long namespace new null object operator out override "
"params private protected public readonly ref return sbyte sealed short "
"sizeof stackalloc static string struct switch this throw true try typeof "
"uint ulong unchecked unsafe ushort using virtual void while",
"",
"", "", "", "", "", "", ""
};
EDITLEXER lexCS = { SCLEX_CPP, 63005, L"C#", L"cs", L"", &KeyWords_CS, COMMENT_INFO(C_COMMENT, SCE_C_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE2(SCE_C_COMMENT, SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR, 0, 0), 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" },
{ SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_C_STRING, SCE_C_CHARACTER, SCE_C_STRINGEOL, 0), 63131, L"String", L"fore:#008000", L"" },
{ SCE_C_VERBATIM, 63134, L"Verbatim String", L"fore:#008000", L"" },
{ SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
{ SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_RC = {
"ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON "
"BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX "
"CLASS COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG "
"DIALOGEX DISCARDABLE EDITTEXT END EXSTYLE FONT GROUPBOX "
"ICON LANGUAGE LISTBOX LTEXT MENU MENUEX MENUITEM "
"MESSAGETABLE POPUP PUSHBUTTON RADIOBUTTON RCDATA RTEXT "
"SCROLLBAR SEPARATOR SHIFT STATE3 STRINGTABLE STYLE "
"TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexRC = { SCLEX_CPP, 63006, L"Resource Script", L"rc; rc2; rct; rh; r; dlg", L"", &KeyWords_RC, COMMENT_INFO(C_COMMENT, SCE_C_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE2(SCE_C_COMMENT, SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR, 0, 0), 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" },
{ SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_C_STRING, SCE_C_CHARACTER, SCE_C_STRINGEOL, SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
{ SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_C_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" },
{ SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_MAK = {
"", "", "", "", "", "", "", "", ""
};
EDITLEXER lexMAK = { SCLEX_MAKEFILE, 63007, L"Makefile", L"mak; make; mk; dsp", L"", &KeyWords_MAK, COMMENT_INFO(BASH_COMMENT, SCE_MAKE_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"fore:#0A246A", L"" },
{ SCE_MAKE_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
{ MULTI_STYLE(SCE_MAKE_IDENTIFIER, SCE_MAKE_IDEOL, 0, 0), 63129, L"Identifier", L"fore:#003CE6", L"" },
{ SCE_MAKE_OPERATOR, 63132, L"Operator", L"", L"" },
{ SCE_MAKE_TARGET, 63204, L"Target", L"fore:#003CE6; back:#FFC000", L"" },
{ SCE_MAKE_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_VBS = {
"alias and as attribute begin boolean byref byte byval call case class compare const continue "
"currency date declare dim do double each else elseif empty end enum eqv erase error event exit "
"explicit false for friend function get global gosub goto if imp implement in integer is let lib "
"load long loop lset me mid mod module new next not nothing null object on option optional or "
"preserve private property public raiseevent redim rem resume return rset select set single "
"static stop string sub then to true type unload until variant wend while with withevents xor",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexVBS = { SCLEX_VBSCRIPT, 63008, L"VBScript", L"vbs; dsm", L"", &KeyWords_VBS, COMMENT_INFO(VB_COMMENT, SCE_B_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_B_COMMENT, SCE_B_COMMENTBLOCK, 0, 0), 63127, L"Comment", L"fore:#808080", L"" },
{ SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" },
{ SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_B_STRING, SCE_B_STRINGEOL, 0, 0), 63131, L"String", L"fore:#008000", L"" },
{ SCE_B_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_B_OPERATOR, 63132, L"Operator", L"", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_VB = {
"addhandler addressof alias and andalso ansi any as assembly auto boolean byref byte byval call "
"case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj compare const cshort csng "
"cstr ctype date decimal declare default delegate dim directcast do double each else elseif end "
"enum erase error event exit explicit externalsource false finally for friend function get "
"gettype gosub goto handles if implements imports in inherits integer interface is let lib like "
"long loop me mid mod module mustinherit mustoverride mybase myclass namespace new next not "
"nothing notinheritable notoverridable object on option optional or orelse overloads overridable "
"overrides paramarray preserve private property protected public raiseevent randomize readonly "
"redim rem removehandler resume return select set shadows shared short single static step stop "
"strict string structure sub synclock then throw to true try typeof unicode until variant when "
"while with withevents writeonly xor",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexVB = { SCLEX_VB, 63009, L"Visual Basic", L"vb; bas; frm; cls; ctl; pag; dsr; dob", L"", &KeyWords_VB, COMMENT_INFO(VB_COMMENT, SCE_B_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_B_COMMENT, SCE_B_COMMENTBLOCK, 0, 0), 63127, L"Comment", L"fore:#808080", L"" },
{ SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" },
{ SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_B_STRING, SCE_B_STRINGEOL, 0, 0), 63131, L"String", L"fore:#008000", L"" },
{ MULTI_STYLE(SCE_B_NUMBER, SCE_B_DATE, 0, 0), 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_B_OPERATOR, 63132, L"Operator", L"", L"" },
{ SCE_B_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF9C00", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_JS = {
"abstract boolean break byte case catch char class const continue debugger default delete do "
"double else enum export extends false final finally float for function goto if implements "
"import in instanceof int interface long native new null package private protected public "
"return short static super switch synchronized this throw throws transient true try typeof var "
"void volatile while with",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexJS = { SCLEX_CPP, 63010, L"JavaScript", L"js; jse; jsm; json; as", L"", &KeyWords_JS, COMMENT_INFO(C_COMMENT, SCE_C_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE2(SCE_C_COMMENT, SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR, 0, 0), 63127, L"Comment", L"fore:#646464", L"" },
{ SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" },
{ SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_C_STRING, SCE_C_CHARACTER, SCE_C_STRINGEOL, SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
{ SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" },
{ SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_JAVA = {
"abstract assert boolean break byte case catch char class const "
"continue default do double else extends final finally float for future "
"generic goto if implements import inner instanceof int interface long "
"native new null outer package private protected public rest return "
"short static super switch synchronized this throw throws transient try "
"var void volatile while",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexJAVA = { SCLEX_CPP, 63011, L"Java", L"java", L"", &KeyWords_JAVA, COMMENT_INFO(C_COMMENT, SCE_C_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE2(SCE_C_COMMENT, SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR, 0, 0), 63127, L"Comment", L"fore:#646464", L"" },
{ SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" },
{ SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_C_STRING, SCE_C_CHARACTER, SCE_C_STRINGEOL, SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
{ SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" },
{ SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_PAS = {
"absolute abstract alias and array as asm assembler begin break case cdecl class const constructor continue cppdecl default "
"destructor dispose div do downto else end end. except exit export exports external false far far16 file finalization finally for "
"forward function goto if implementation in index inherited initialization inline interface is label library local message mod "
"name near new nil nostackframe not object of oldfpccall on operator or out overload override packed pascal private procedure "
"program property protected public published raise read record register reintroduce repeat resourcestring safecall self set shl "
"shr softfloat stdcall stored string then threadvar to true try type unit until uses var virtual while with write xor",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexPAS = { SCLEX_PASCAL, 63012, L"Pascal/Delphi", L"pas; dpr; dpk; dfm; inc; pp", L"", &KeyWords_PAS, COMMENT_INFO(PASCAL_COMMENT, SCE_PAS_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_PAS_COMMENT, SCE_PAS_COMMENT2, SCE_PAS_COMMENTLINE, 0), 63127, L"Comment", L"fore:#646464", L"" },
{ SCE_PAS_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" },
{ SCE_PAS_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_PAS_STRING, SCE_PAS_CHARACTER, SCE_PAS_STRINGEOL, 0), 63131, L"String", L"fore:#008000", L"" },
{ MULTI_STYLE(SCE_PAS_NUMBER, SCE_PAS_HEXNUMBER, 0, 0), 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_PAS_OPERATOR, 63132, L"Operator", L"bold", L"" },
{ SCE_PAS_ASM, 63205, L"Inline Asm", L"fore:#0000FF", L"" },
{ MULTI_STYLE(SCE_PAS_PREPROCESSOR, SCE_PAS_PREPROCESSOR2, 0, 0), 63133, L"Preprocessor", L"fore:#FF00FF", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_ASM = {
"aaa aad aam aas adc add and arpl bound bsf bsr bswap bt btc btr bts call cbw cdq cflush clc cld "
"cli clts cmc cmova cmovae cmovb cmovbe cmovc cmove cmovg cmovge cmovl cmovle cmovna cmovnae "
"cmovnb cmovnbe cmovnc cmovne cmovng cmovnge cmovnl cmovnle cmovno cmovnp cmovns cmovnz cmovo "
"cmovp cmovpe cmovpo cmovs cmovz cmp cmps cmpsb cmpsd cmpsq cmpsw cmpxchg cmpxchg486 cmpxchg8b "
"cpuid cwd cwde daa das dec div emms enter esc femms hlt ibts icebp idiv imul in inc ins insb "
"insd insw int int01 int03 int1 int3 into invd invlpg iret iretd iretdf iretf iretw ja jae jb jbe "
"jc jcxz je jecxz jg jge jl jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz "
"jo jp jpe jpo js jz lahf lar lds lea leave les lfs lgdt lgs lidt lldt lmsw loadall loadall286 "
"lock lods lodsb lodsd lodsq lodsw loop loopd loope looped loopew loopne loopned loopnew loopnz "
"loopnzd loopnzw loopw loopz loopzd loopzw lsl lss ltr mov movs movsb movsd movsq movsw movsx "
"movsxd movzx mul neg nop not or out outs outsb outsd outsw pop popa popad popaw popf popfd popfw "
"push pusha pushad pushaw pushd pushf pushfd pushfw pushw rcl rcr rdmsr rdpmc rdshr rdtsc rep "
"repe repne repnz repz ret retf retn rol ror rsdc rsldt rsm rsts sahf sal salc sar sbb scas scasb "
"scasd scasq scasw seta setae setb setbe setc sete setg setge setl setle setna setnae setnb "
"setnbe setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp setpe setpo sets "
"setz sgdt shl shld shr shrd sidt sldt smi smint smintold smsw stc std sti stos stosb stosd stosq "
"stosw str sub svdc svldt svts syscall sysenter sysexit sysret test ud0 ud1 ud2 umov verr verw "
"wait wbinvd wrmsr wrshr xadd xbts xchg xlat xlatb xor",
"f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcmovb fcmovbe fcmove fcmovnb fcmovnbe fcmovne "
"fcmovnu fcmovu fcom fcomi fcomip fcomp fcompp fcos fdecstp fdisi fdiv fdivp fdivr fdivrp feni "
"ffree ffreep fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisub fisubr "
"fld fld1 fldcw fldenv fldenvd fldenvw fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex "
"fndisi fneni fninit fnop fnsave fnsaved fnsavew fnstcw fnstenv fnstenvd fnstenvw fnstsw fpatan "
"fprem fprem1 fptan frndint frstor frstord frstorw fsave fsaved fsavew fscale fsetpm fsin fsincos "
"fsqrt fst fstcw fstenv fstenvd fstenvw fstp fstsw fsub fsubp fsubr fsubrp ftst fucom fucomp "
"fucompp fwait fxam fxch fxtract fyl2x fyl2xp1",
"ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs cx dh di dl dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp "
"ebx ecx edi edx eip es esi esp fs gs mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 r10 r10b r10d r10w r11 r11b "
"r11d r11w r12 r12b r12d r12w r13 r13b r13d r13w r14 r14b r14d r14w r15 r15b r15d r15w r8 r8b r8d "
"r8w r9 r9b r9d r9w rax rbp rbx rcx rdi rdx rip rsi rsp si sp ss st st0 st1 st2 st3 st4 st5 st6 "
"st7 tr3 tr4 tr5 tr6 tr7 xmm0 xmm1 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 xmm2 xmm3 xmm4 xmm5 xmm6 "
"xmm7 xmm8 xmm9 ymm0 ymm1 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8 "
"ymm9",
"%arg %assign %define %elif %elifctk %elifdef %elifid %elifidn %elifidni %elifmacro %elifnctk "
"%elifndef %elifnid %elifnidn %elifnidni %elifnmacro %elifnnum %elifnstr %elifnum %elifstr %else "
"%endif %endmacro %endrep %error %exitrep %iassign %idefine %if %ifctk %ifdef %ifid %ifidn "
"%ifidni %ifmacro %ifnctk %ifndef %ifnid %ifnidn %ifnidni %ifnmacro %ifnnum %ifnstr %ifnum %ifstr "
"%imacro %include %line %local %macro %out %pop %push %rep %repl %rotate %stacksize %strlen "
"%substr %undef %xdefine %xidefine .186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p "
".8086 .8087 .alpha .break .code .const .continue .cref .data .data? .dosseg .else .elseif .endif "
".endw .err .err1 .err2 .errb .errdef .errdif .errdifi .erre .erridn .erridni .errnb .errndef "
".errnz .exit .fardata .fardata? .if .lall .lfcond .list .listall .listif .listmacro "
".listmacroall .model .msfloat .no87 .nocref .nolist .nolistif .nolistmacro .radix .repeat .sall "
".seq .sfcond .stack .startup .tfcond .type .until .untilcxz .while .xall .xcref .xlist absolute "
"alias align alignb assume at bits catstr comm comment common cpu db dd df dosseg dq dt dup dw "
"echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif elseifdifi elseife elseifidn "
"elseifidni elseifnb elseifndef end endif endm endp ends endstruc eq equ even exitm export extern "
"externdef extrn for forc ge global goto group gt high highword iend if if1 if2 ifb ifdef ifdif "
"ifdifi ife ifidn ifidni ifnb ifndef import incbin include includelib instr invoke irp irpc "
"istruc label le length lengthof local low lowword lroffset lt macro mask mod name ne offset "
"opattr option org page popcontext proc proto ptr public purge pushcontext record repeat rept "
"resb resd resq rest resw section seg segment short size sizeof sizestr struc struct substr "
"subtitle subttl textequ this times title type typedef union use16 use32 while width",
"$ $$ %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 .bss .data .text ? @b @f a16 a32 abs addr all assumes at "
"basic byte c carry? casemap common compact cpu dotname dword emulator epilogue error export "
"expr16 expr32 far far16 far32 farstack flat forceframe fortran fword huge language large listing "
"ljmp loadds m510 medium memory near near16 near32 nearstack nodotname noemulator nokeyword "
"noljmp nom510 none nonunique nooldmacros nooldstructs noreadonly noscoped nosignextend nosplit "
"nothing notpublic o16 o32 oldmacros oldstructs os_dos overflow? para parity? pascal private "
"prologue qword radix readonly real10 real4 real8 req sbyte scoped sdword seq setif2 sign? small "
"smallstack stdcall sword syscall tbyte tiny use16 use32 uses vararg word wrt zero?",
"addpd addps addsd addss andnpd andnps andpd andps blendpd blendps blendvpd blendvps cmpeqpd "
"cmpeqps cmpeqsd cmpeqss cmplepd cmpleps cmplesd cmpless cmpltpd cmpltps cmpltsd cmpltss cmpnepd "
"cmpneps cmpnesd cmpness cmpnlepd cmpnleps cmpnlesd cmpnless cmpnltpd cmpnltps cmpnltsd cmpnltss "
"cmpordpd cmpordps cmpordsd cmpordss cmpunordpd cmpunordps cmpunordsd cmpunordss comisd comiss "
"crc32 cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi "
"cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvtss2sd cvtss2si cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi "
"cvttsd2si cvttss2si divpd divps divsd divss dppd dpps extractps fxrstor fxsave insertps ldmxscr "
"lfence maskmovdq maskmovdqu maxpd maxps maxss mfence minpd minps minsd minss movapd movaps movd "
"movdq2q movdqa movdqu movhlps movhpd movhps movlhps movlpd movlps movmskpd movmskps movntdq "
"movntdqa movnti movntpd movntps movntq movq movq2dq movsd movss movupd movups mpsadbw mulpd "
"mulps mulsd mulss orpd orps packssdw packsswb packusdw packuswb paddb paddd paddq paddsb paddsiw "
"paddsw paddusb paddusw paddw pand pandn pause paveb pavgb pavgusb pavgw paxsd pblendvb pblendw "
"pcmpeqb pcmpeqd pcmpeqq pcmpeqw pcmpestri pcmpestrm pcmpgtb pcmpgtd pcmpgtq pcmpgtw pcmpistri "
"pcmpistrm pdistib pextrb pextrd pextrq pextrw pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt "
"pfmax pfmin pfmul pfnacc pfpnacc pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr "
"phminposuw pi2fd pinsrb pinsrd pinsrq pinsrw pmachriw pmaddwd pmagw pmaxsb pmaxsd pmaxsw pmaxub "
"pmaxud pmaxuw pminsb pminsd pminsw pminub pminud pminuw pmovmskb pmovsxbd pmovsxbq pmovsxbw "
"pmovsxdq pmovsxwd pmovsxwq pmovzxbd pmovzxbq pmovzxbw pmovzxdq pmovzxwd pmovzxwq pmuldq pmulhriw "
"pmulhrwa pmulhrwc pmulhuw pmulhw pmulld pmullw pmuludq pmvgezb pmvlzb pmvnzb pmvzb popcnt por "
"prefetch prefetchnta prefetcht0 prefetcht1 prefetcht2 prefetchw psadbw pshufd pshufhw pshuflw "
"pshufw pslld pslldq psllq psllw psrad psraw psrld psrldq psrlq psrlw psubb psubd psubq psubsb "
"psubsiw psubsw psubusb psubusw psubw pswapd ptest punpckhbw punpckhdq punpckhqdq punpckhwd "
"punpcklbw punpckldq punpcklqdq punpcklwd pxor rcpps rcpss roundpd roundps roundsd roundss "
"rsqrtps rsqrtss sfence shufpd shufps sqrtpd sqrtps sqrtsd sqrtss stmxcsr subpd subps subsd subss "
"ucomisd ucomiss unpckhpd unpckhps unpcklpd unpcklps xorpd xorps",
"", "", ""
};
EDITLEXER lexASM = { SCLEX_ASM, 63013, L"Assembly Script", L"asm", L"", &KeyWords_ASM, COMMENT_INFO(ASM_COMMENT, SCE_ASM_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_ASM_COMMENT, SCE_ASM_COMMENTBLOCK, 0, 0), 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_ASM_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_ASM_STRING, SCE_ASM_CHARACTER, SCE_ASM_STRINGEOL, 0), 63131, L"String", L"fore:#008000", L"" },
{ SCE_ASM_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_ASM_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" },
{ SCE_ASM_CPUINSTRUCTION, 63206, L"CPU Instruction", L"fore:#0A246A", L"" },
{ SCE_ASM_MATHINSTRUCTION, 63207, L"FPU Instruction", L"fore:#0A246A", L"" },
{ SCE_ASM_EXTINSTRUCTION, 63210, L"Extended Instruction", L"fore:#0A246A", L"" },
{ SCE_ASM_DIRECTIVE, 63203, L"Directive", L"fore:#0A246A", L"" },
{ SCE_ASM_DIRECTIVEOPERAND, 63209, L"Directive Operand", L"fore:#0A246A", L"" },
{ SCE_ASM_REGISTER, 63208, L"Register", L"fore:#FF8000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_PL = {
"__DATA__ __END__ __FILE__ __LINE__ __PACKAGE__ abs accept alarm and atan2 AUTOLOAD BEGIN "
"bind binmode bless caller chdir CHECK chmod chomp chop chown chr chroot close closedir cmp "
"connect continue CORE cos crypt dbmclose dbmopen default defined delete DESTROY die do "
"dump each else elsif END endgrent endhostent endnetent endprotoent endpwent endservent eof "
"eq EQ eval exec exists exit exp fcntl fileno flock for foreach fork format formline ge GE "
"getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin "
"getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname "
"getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport "
"getservent getsockname getsockopt given glob gmtime goto grep gt GT hex if index INIT int "
"ioctl join keys kill last lc lcfirst le LE length link listen local localtime lock log "
"lstat lt LT map mkdir msgctl msgget msgrcv msgsnd my ne NE next no not NULL oct open "
"opendir or ord our pack package pipe pop pos print printf prototype push qu quotemeta rand "
"read readdir readline readlink readpipe recv redo ref rename require reset return reverse "
"rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent "
"sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift "
"shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split "
"sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek "
"system syswrite tell telldir tie tied time times truncate uc ucfirst umask undef UNITCHECK "
"unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn "
"when while write xor",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexPL = { SCLEX_PERL, 63014, L"Perl", L"pl; pm; cgi; pod", L"", &KeyWords_PL, COMMENT_INFO(BASH_COMMENT, SCE_PL_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_PL_COMMENTLINE, 63127, L"Comment", L"fore:#646464", L"" },
{ SCE_PL_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" },
{ SCE_PL_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_PL_STRING, 63211, L"String double quoted", L"fore:#008000", L"" },
{ SCE_PL_CHARACTER, 63212, L"String single quoted", L"fore:#008000", L"" },
{ SCE_PL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_PL_OPERATOR, 63132, L"Operator", L"bold", L"" },
{ SCE_PL_SCALAR, 63215, L"Scalar $var", L"fore:#0A246A", L"" },
{ SCE_PL_ARRAY, 63216, L"Array @var", L"fore:#003CE6", L"" },
{ SCE_PL_HASH, 63217, L"Hash %var", L"fore:#B000B0", L"" },
{ SCE_PL_SYMBOLTABLE, 63218, L"Symbol table *var", L"fore:#3A6EA5", L"" },
{ SCE_PL_REGEX, 63219, L"Regex /re/ or m{re}", L"fore:#006633; back:#FFF1A8", L"" },
{ SCE_PL_REGSUBST, 63220, L"Substitution s/re/ore/", L"fore:#006633; back:#FFF1A8", L"" },
{ SCE_PL_BACKTICKS, 63221, L"Back ticks", L"fore:#E24000; back:#FFF1A8", L"" },
{ SCE_PL_HERE_DELIM, 63223, L"Here-doc (delimiter)", L"fore:#648000", L"" },
{ SCE_PL_HERE_Q, 63224, L"Here-doc (single quoted, q)", L"fore:#648000", L"" },
{ SCE_PL_HERE_QQ, 63225, L"Here-doc (double quoted, qq)", L"fore:#648000", L"" },
{ SCE_PL_HERE_QX, 63226, L"Here-doc (back ticks, qx)", L"fore:#E24000; back:#FFF1A8", L"" },
{ SCE_PL_STRING_Q, 63227, L"Single quoted string (generic, q)", L"fore:#008000", L"" },
{ SCE_PL_STRING_QQ, 63228, L"Double quoted string (qq)", L"fore:#008000", L"" },
{ SCE_PL_STRING_QX, 63229, L"Back ticks (qx)", L"fore:#E24000; back:#FFF1A8", L"" },
{ SCE_PL_STRING_QR, 63230, L"Regex (qr)", L"fore:#006633; back:#FFF1A8", L"" },
{ SCE_PL_STRING_QW, 63231, L"Array (qw)", L"fore:#003CE6", L"" },
{ SCE_PL_SUB_PROTOTYPE, 63253, L"Prototype", L"fore:#800080; back:#FFE2FF", L"" },
{ SCE_PL_FORMAT_IDENT, 63254, L"Format identifier", L"bold; fore:#648000; back:#FFF1A8", L"" },
{ SCE_PL_FORMAT, 63255, L"Format body", L"fore:#648000; back:#FFF1A8", L"" },
{ SCE_PL_POD, 63213, L"POD (common)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" },
{ SCE_PL_POD_VERB, 63214, L"POD (verbatim)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" },
{ SCE_PL_DATASECTION, 63222, L"Data section", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" },
{ SCE_PL_ERROR, 63252, L"Parsing error", L"fore:#C80000; back:#FFFF80", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_INI = {
"", "", "", "", "", "", "", "", ""
};
EDITLEXER lexINI = { SCLEX_PROPERTIES, 63015, L"Configuration Files (INI)", L"ini; inf; reg; cfg; properties; oem; sif; url; sed; theme", L"", &KeyWords_INI, COMMENT_INFO(ASM_COMMENT, SCE_PROPS_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_PROPS_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_PROPS_SECTION, 63232, L"Section", L"bold; fore:#000000; back:#FFD24D; eolfilled", L"" },
{ SCE_PROPS_ASSIGNMENT, 63233, L"Assignment", L"fore:#FF0000", L"" },
{ SCE_PROPS_DEFVAL, 63234, L"Default Value", L"fore:#FF0000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_BAT = {
"break call cd chcp chdir choice cls color com con copy country date defined del dir "
"disabledelayedexpansion disableextensions do doskey echo else enabledelayedexpansion "
"enableextensions endlocal equ erase errorlevel exist exit for geq goto gtr if in leq "
"loadfix loadhigh lpt lss md mkdir more move neq not nul off on path pause popd print "
"prompt pushd rd rem ren rename rmdir set setlocal shift time title tree type ver verify",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexBAT = { SCLEX_BATCH, 63016, L"Batch Script", L"bat; cmd", L"", &KeyWords_BAT, COMMENT_INFO(BATCH_COMMENT, SCE_BAT_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_BAT_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_BAT_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" },
{ SCE_BAT_IDENTIFIER, 63129, L"Identifier", L"fore:#003CE6; back:#FFF1A8", L"" },
{ SCE_BAT_OPERATOR, 63132, L"Operator", L"", L"" },
{ MULTI_STYLE(SCE_BAT_COMMAND, SCE_BAT_HIDE, 0, 0), 63236, L"Command", L"bold", L"" },
{ SCE_BAT_LABEL, 63235, L"Label", L"fore:#C80000; back:#F4F4F4; eolfilled", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_DIFF = {
"", "", "", "", "", "", "", "", ""
};
EDITLEXER lexDIFF = { SCLEX_DIFF, 63017, L"Diff Files", L"diff; patch", L"", &KeyWords_DIFF, COMMENT_INFO(DIFF_COMMENT, SCE_DIFF_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_DIFF_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_DIFF_COMMAND, 63236, L"Command", L"bold; fore:#0A246A", L"" },
{ SCE_DIFF_HEADER, 63238, L"Source and Destination", L"fore:#C80000; back:#FFF1A8; eolfilled", L"" },
{ SCE_DIFF_POSITION, 63239, L"Position Setting", L"fore:#0000FF", L"" },
{ SCE_DIFF_ADDED, 63240, L"Line Addition", L"fore:#000000; back:#C0FF60; eolfilled", L"" },
{ SCE_DIFF_DELETED, 63241, L"Line Removal", L"fore:#000000; back:#FF8060; eolfilled", L"" },
{ SCE_DIFF_CHANGED, 63242, L"Line Change", L"fore:#000000; back:#99D7FF; eolfilled", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_SQL = {
"abort accessible action add after all alter analyze and as asc asensitive attach autoincrement "
"before begin between bigint binary bit blob both by call cascade case cast change char character "
"check collate column commit condition conflict constraint continue convert create cross current_date "
"current_time current_timestamp current_user cursor database databases date day_hour day_microsecond "
"day_minute day_second dec decimal declare default deferrable deferred delayed delete desc describe "
"detach deterministic distinct distinctrow div double drop dual each else elseif enclosed end enum "
"escape escaped except exclusive exists exit explain fail false fetch float float4 float8 for force "
"foreign from full fulltext glob grant group having high_priority hour_microsecond hour_minute "
"hour_second if ignore immediate in index infile initially inner inout insensitive insert instead int "
"int1 int2 int3 int4 int8 integer intersect interval into is isnull iterate join key keys kill "
"leading leave left like limit linear lines load localtime localtimestamp lock long longblob longtext "
"loop low_priority master_ssl_verify_server_cert match mediumblob mediumint mediumtext middleint "
"minute_microsecond minute_second mod modifies natural no no_write_to_binlog not notnull null numeric "
"of offset on optimize option optionally or order out outer outfile plan pragma precision primary "
"procedure purge query raise range read read_only read_write reads real references regexp reindex "
"release rename repeat replace require restrict return revoke right rlike rollback row rowid schema "
"schemas second_microsecond select sensitive separator set show smallint spatial specific sql "
"sql_big_result sql_calc_found_rows sql_small_result sqlexception sqlstate sqlwarning ssl starting "
"straight_join table temp temporary terminated text then time timestamp tinyblob tinyint tinytext to "
"trailing transaction trigger true undo union unique unlock unsigned update usage use using utc_date "
"utc_time utc_timestamp vacuum values varbinary varchar varcharacter varying view virtual when where "
"while with write xor year_month zerofill",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexSQL = { SCLEX_SQL, 63018, L"SQL Query", L"sql", L"", &KeyWords_SQL, COMMENT_INFO(SQL_COMMENT, -1), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE2(SCE_SQL_COMMENT, SCE_SQL_COMMENTLINE, SCE_SQL_COMMENTDOC, SCE_SQL_COMMENTLINEDOC, SCE_SQL_COMMENTDOCKEYWORD, SCE_SQL_COMMENTDOCKEYWORDERROR, 0, 0), 63127, L"Comment", L"fore:#505050", L"" },
{ SCE_SQL_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" },
{ MULTI_STYLE(SCE_SQL_STRING, SCE_SQL_CHARACTER, 0, 0), 63131, L"String", L"fore:#008000; back:#FFF1A8", L"" },
{ SCE_SQL_IDENTIFIER, 63129, L"Identifier", L"fore:#800080", L"" },
{ SCE_SQL_QUOTEDIDENTIFIER, 63243, L"Quoted Identifier", L"fore:#800080; back:#FFCCFF", L"" },
{ SCE_SQL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_SQL_OPERATOR, 63132, L"Operator", L"bold; fore:#800080", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_PY = {
"and as assert break class continue def del elif else except "
"exec False finally for from global if import in is lambda None "
"not or pass print raise return True try with while yield",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexPY = { SCLEX_PYTHON, 63019, L"Python", L"py; pyw", L"", &KeyWords_PY, COMMENT_INFO(BASH_COMMENT, SCE_P_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_P_COMMENTLINE, SCE_P_COMMENTBLOCK, 0, 0), 63127, L"Comment", L"fore:#880000", L"" },
{ SCE_P_WORD, 63128, L"Keyword", L"fore:#000088", L"" },
{ SCE_P_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_P_STRING, SCE_P_STRINGEOL, 0, 0), 63211, L"String double quoted", L"fore:#008800", L"" },
{ SCE_P_CHARACTER, 63212, L"String single quoted", L"fore:#008800", L"" },
{ SCE_P_TRIPLEDOUBLE, 63244, L"String triple double quotes", L"fore:#008800", L"" },
{ SCE_P_TRIPLE, 63245, L"String triple single quotes", L"fore:#008800", L"" },
{ SCE_P_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" },
{ SCE_P_OPERATOR, 63132, L"Operator", L"bold; fore:#666600", L"" },
{ SCE_P_DEFNAME, 63247, L"Function name", L"fore:#660066", L"" },
{ SCE_P_CLASSNAME, 63246, L"Class name", L"fore:#660066", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_CONF = {
"acceptmutex acceptpathinfo accessconfig accessfilename action addalt addaltbyencoding addaltbytype addcharset adddefaultcharset "
"adddescription addencoding addhandler addicon addiconbyencoding addiconbytype addinputfilter addlanguage addmodule addmoduleinfo "
"addoutputfilter addoutputfilterbytype addtype agentlog alias aliasmatch all allow allowconnect allowencodedslashes allowoverride "
"anonymous anonymous_authoritative anonymous_logemail anonymous_mustgiveemail anonymous_nouserid anonymous_verifyemail "
"assignuserid authauthoritative authdbauthoritative authdbgroupfile authdbmauthoritative authdbmgroupfile authdbmtype "
"authdbmuserfile authdbuserfile authdigestalgorithm authdigestdomain authdigestfile authdigestgroupfile authdigestnccheck "
"authdigestnonceformat authdigestnoncelifetime authdigestqop authdigestshmemsize authgroupfile authldapauthoritative "
"authldapbinddn authldapbindpassword authldapcharsetconfig authldapcomparednonserver authldapdereferencealiases authldapenabled "
"authldapfrontpagehack authldapgroupattribute authldapgroupattributeisdn authldapremoteuserisdn authldapurl authname authtype "
"authuserfile bindaddress browsermatch browsermatchnocase bs2000account bufferedlogs cachedefaultexpire cachedirlength "
"cachedirlevels cachedisable cacheenable cacheexpirycheck cachefile cacheforcecompletion cachegcclean cachegcdaily "
"cachegcinterval cachegcmemusage cachegcunused cacheignorecachecontrol cacheignoreheaders cacheignorenolastmod "
"cachelastmodifiedfactor cachemaxexpire cachemaxfilesize cacheminfilesize cachenegotiateddocs cacheroot cachesize cachetimemargin "
"cgimapextension charsetdefault charsetoptions charsetsourceenc checkspelling childperuserid clearmodulelist contentdigest "
"cookiedomain cookieexpires cookielog cookiename cookiestyle cookietracking coredumpdirectory customlog dav davdepthinfinity "
"davlockdb davmintimeout defaulticon defaultlanguage defaulttype define deflatebuffersize deflatecompressionlevel "
"deflatefilternote deflatememlevel deflatewindowsize deny directory directoryindex directorymatch directoryslash documentroot "
"dumpioinput dumpiooutput enableexceptionhook enablemmap enablesendfile errordocument errorlog example expiresactive "
"expiresbytype expiresdefault extendedstatus extfilterdefine extfilteroptions fancyindexing fileetag files filesmatch "
"forcelanguagepriority forcetype forensiclog from group header headername hostnamelookups identitycheck ifdefine ifmodule "
"imapbase imapdefault imapmenu include indexignore indexoptions indexorderdefault isapiappendlogtoerrors isapiappendlogtoquery "
"isapicachefile isapifakeasync isapilognotsupported isapireadaheadbuffer keepalive keepalivetimeout languagepriority "
"ldapcacheentries ldapcachettl ldapconnectiontimeout ldapopcacheentries ldapopcachettl ldapsharedcachefile ldapsharedcachesize "
"ldaptrustedca ldaptrustedcatype limit limitexcept limitinternalrecursion limitrequestbody limitrequestfields "
"limitrequestfieldsize limitrequestline limitxmlrequestbody listen listenbacklog loadfile loadmodule location locationmatch "
"lockfile logformat loglevel maxclients maxkeepaliverequests maxmemfree maxrequestsperchild maxrequestsperthread maxspareservers "
"maxsparethreads maxthreads maxthreadsperchild mcachemaxobjectcount mcachemaxobjectsize mcachemaxstreamingbuffer "
"mcacheminobjectsize mcacheremovalalgorithm mcachesize metadir metafiles metasuffix mimemagicfile minspareservers minsparethreads "
"mmapfile modmimeusepathinfo multiviewsmatch namevirtualhost nocache noproxy numservers nwssltrustedcerts nwsslupgradeable "
"options order passenv pidfile port protocolecho proxy proxybadheader proxyblock proxydomain proxyerroroverride proxyiobuffersize "
"proxymatch proxymaxforwards proxypass proxypassreverse proxypreservehost proxyreceivebuffersize proxyremote proxyremotematch "
"proxyrequests proxytimeout proxyvia qsc readmename redirect redirectmatch redirectpermanent redirecttemp refererignore "
"refererlog removecharset removeencoding removehandler removeinputfilter removelanguage removeoutputfilter removetype "
"requestheader require resourceconfig rewritebase rewritecond rewriteengine rewritelock rewritelog rewriteloglevel rewritemap "
"rewriteoptions rewriterule rlimitcpu rlimitmem rlimitnproc satisfy scoreboardfile script scriptalias scriptaliasmatch "
"scriptinterpretersource scriptlog scriptlogbuffer scriptloglength scriptsock securelisten sendbuffersize serveradmin serveralias "
"serverlimit servername serverpath serverroot serversignature servertokens servertype setenv setenvif setenvifnocase sethandler "
"setinputfilter setoutputfilter singlelisten ssiendtag ssierrormsg ssistarttag ssitimeformat ssiundefinedecho "
"sslcacertificatefile sslcacertificatepath sslcarevocationfile sslcarevocationpath sslcertificatechainfile sslcertificatefile "
"sslcertificatekeyfile sslciphersuite sslengine sslmutex ssloptions sslpassphrasedialog sslprotocol sslproxycacertificatefile "
"sslproxycacertificatepath sslproxycarevocationfile sslproxycarevocationpath sslproxyciphersuite sslproxyengine "
"sslproxymachinecertificatefile sslproxymachinecertificatepath sslproxyprotocol sslproxyverify sslproxyverifydepth sslrandomseed "
"sslrequire sslrequiressl sslsessioncache sslsessioncachetimeout sslusername sslverifyclient sslverifydepth startservers "
"startthreads suexecusergroup threadlimit threadsperchild threadstacksize timeout transferlog typesconfig unsetenv "
"usecanonicalname user userdir virtualdocumentroot virtualdocumentrootip virtualhost virtualscriptalias virtualscriptaliasip "
"win32disableacceptex xbithack",
"",
"", "", "", "", "", "", ""
};
EDITLEXER lexCONF = { SCLEX_CONF, 63020, L"Apache Config File", L"conf; htaccess", L"", &KeyWords_CONF, COMMENT_INFO(BASH_COMMENT, SCE_CONF_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_CONF_COMMENT, 63127, L"Comment", L"fore:#648000", L"" },
{ SCE_CONF_STRING, 63131, L"String", L"fore:#B000B0", L"" },
{ SCE_CONF_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" },
{ SCE_CONF_DIRECTIVE, 63203, L"Directive", L"fore:#003CE6", L"" },
{ SCE_CONF_IP, 63248, L"IP Address", L"bold; fore:#FF4000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_PS = {
"begin break catch continue data do dynamicparam else elseif end exit filter finally for foreach "
"from function if in local param private process return switch throw trap try until where while",
"add-computer add-content add-history add-member add-pssnapin add-type checkpoint-computer "
"clear-content clear-eventlog clear-history clear-host clear-item clear-itemproperty "
"clear-variable compare-object complete-transaction connect-wsman convertfrom-csv "
"convertfrom-securestring convertfrom-stringdata convert-path convertto-csv convertto-html "
"convertto-securestring convertto-xml copy-item copy-itemproperty debug-process "
"disable-computerrestore disable-psbreakpoint disable-psremoting disable-pssessionconfiguration "
"disable-wsmancredssp disconnect-wsman enable-computerrestore enable-psbreakpoint "
"enable-psremoting enable-pssessionconfiguration enable-wsmancredssp enter-pssession "
"exit-pssession export-alias export-clixml export-console export-counter export-csv "
"export-formatdata export-modulemember export-pssession foreach-object format-custom format-list "
"format-table format-wide get-acl get-alias get-authenticodesignature get-childitem get-command "
"get-computerrestorepoint get-content get-counter get-credential get-culture get-date get-event "
"get-eventlog get-eventsubscriber get-executionpolicy get-formatdata get-help get-history "
"get-host get-hotfix get-item get-itemproperty get-job get-location get-member get-module "
"get-pfxcertificate get-process get-psbreakpoint get-pscallstack get-psdrive get-psprovider "
"get-pssession get-pssessionconfiguration get-pssnapin get-random get-service get-tracesource "
"get-transaction get-uiculture get-unique get-variable get-verb get-winevent get-wmiobject "
"get-wsmancredssp get-wsmaninstance group-object import-alias import-clixml import-counter "
"import-csv import-localizeddata import-module import-pssession invoke-command invoke-expression "
"invoke-history invoke-item invoke-wmimethod invoke-wsmanaction join-path limit-eventlog "
"measure-command measure-object move-item move-itemproperty new-alias new-event new-eventlog "
"new-item new-itemproperty new-module new-modulemanifest new-object new-psdrive new-pssession "
"new-pssessionoption new-service new-timespan new-variable new-webserviceproxy new-wsmaninstance "
"new-wsmansessionoption out-default out-file out-gridview out-host out-null out-printer "
"out-string pop-location push-location read-host receive-job register-engineevent "
"register-objectevent register-pssessionconfiguration register-wmievent remove-computer "
"remove-event remove-eventlog remove-item remove-itemproperty remove-job remove-module "
"remove-psbreakpoint remove-psdrive remove-pssession remove-pssnapin remove-variable "
"remove-wmiobject remove-wsmaninstance rename-item rename-itemproperty "
"reset-computermachinepassword resolve-path restart-computer restart-service restore-computer "
"resume-service select-object select-string select-xml send-mailmessage set-acl set-alias "
"set-authenticodesignature set-content set-date set-executionpolicy set-item set-itemproperty "
"set-location set-psbreakpoint set-psdebug set-pssessionconfiguration set-service set-strictmode "
"set-tracesource set-variable set-wmiinstance set-wsmaninstance set-wsmanquickconfig "
"show-eventlog sort-object split-path start-job start-process start-service start-sleep "
"start-transaction start-transcript stop-computer stop-job stop-process stop-service "
"stop-transcript suspend-service tee-object test-computersecurechannel test-connection "
"test-modulemanifest test-path test-wsman trace-command undo-transaction unregister-event "
"unregister-pssessionconfiguration update-formatdata update-list update-typedata use-transaction "
"wait-event wait-job wait-process where-object write-debug write-error write-eventlog write-host "
"write-output write-progress write-verbose write-warning",
"ac asnp cat cd chdir clc clear clhy cli clp cls clv compare copy cp cpi cpp cvpa dbp del diff "
"dir ebp echo epal epcsv epsn erase etsn exsn fc fl foreach ft fw gal gbp gc gci gcm gcs gdr ghy "
"gi gjb gl gm gmo gp gps group gsn gsnp gsv gu gv gwmi h help history icm iex ihy ii ipal ipcsv "
"ipmo ipsn ise iwmi kill lp ls man md measure mi mkdir more mount move mp mv nal ndr ni nmo nsn "
"nv ogv oh popd ps pushd pwd r rbp rcjb rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp rv "
"rvpa rwmi sajb sal saps sasv sbp sc select set si sl sleep sort sp spjb spps spsv start sv swmi "
"tee type where wjb write",
"importsystemmodules prompt psedit tabexpansion",
"", "", "", "", ""
};
EDITLEXER lexPS = { SCLEX_POWERSHELL, 63021, L"PowerShell Script", L"ps1; psd1; psm1", L"", &KeyWords_PS, COMMENT_INFO(BASH_COMMENT, SCE_POWERSHELL_COMMENT), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_POWERSHELL_COMMENT, SCE_POWERSHELL_COMMENTSTREAM, SCE_POWERSHELL_COMMENTDOCKEYWORD, 0), 63127, L"Comment", L"fore:#646464", L"" },
{ SCE_POWERSHELL_KEYWORD, 63128, L"Keyword", L"bold; fore:#804000", L"" },
{ SCE_POWERSHELL_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_POWERSHELL_STRING, SCE_POWERSHELL_CHARACTER, 0, 0), 63131, L"String", L"fore:#008000", L"" },
{ SCE_POWERSHELL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
{ SCE_POWERSHELL_OPERATOR, 63132, L"Operator", L"bold", L"" },
{ SCE_POWERSHELL_VARIABLE, 63249, L"Variable", L"fore:#0A246A", L"" },
{ MULTI_STYLE(SCE_POWERSHELL_CMDLET, SCE_POWERSHELL_FUNCTION, 0, 0), 63250, L"Cmdlet", L"fore:#804000; back:#FFF1A8", L"" },
{ SCE_POWERSHELL_ALIAS, 63251, L"Alias", L"bold; fore:#0A246A", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_RUBY = {
"__FILE__ __LINE__ alias and begin break case class def defined? do else elsif end ensure "
"false for in if module next nil not or redo rescue retry return self super then true "
"undef unless until when while yield",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexRUBY = { SCLEX_RUBY, 63022, L"Ruby", L"rb; ruby; rbw; rake; rjs; Rakefile", L"", &KeyWords_RUBY, COMMENT_INFO(BASH_COMMENT, SCE_RB_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_RB_COMMENTLINE, SCE_P_COMMENTBLOCK, 0, 0), 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_RB_WORD, 63128, L"Keyword", L"bold; fore:#00007F", L"" },
{ SCE_RB_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_RB_NUMBER, 63130, L"Number", L"fore:#008080", L"" },
{ SCE_RB_OPERATOR, 63132, L"Operator", L"", L"" },
{ MULTI_STYLE(SCE_RB_STRING, SCE_RB_CHARACTER, SCE_P_STRINGEOL, 0), 63131, L"String", L"fore:#FF8000", L"" },
{ SCE_RB_CLASSNAME, 63246, L"Class name", L"fore:#0000FF", L"" },
{ SCE_RB_DEFNAME, 63247, L"Function name", L"fore:#007F7F", L"" },
{ SCE_RB_POD, 63314, L"POD", L"fore:#004000; back:#C0FFC0; eolfilled", L"" },
{ SCE_RB_REGEX, 63135, L"Regex", L"fore:#000000; back:#A0FFA0", L"" },
{ SCE_RB_SYMBOL, 63316, L"Symbol", L"fore:#C0A030", L"" },
{ SCE_RB_MODULE_NAME, 63317, L"Module name", L"fore:#A000A0", L"" },
{ SCE_RB_INSTANCE_VAR, 63318, L"Instance Var", L"fore:#B00080", L"" },
{ SCE_RB_CLASS_VAR, 63319, L"Class Var", L"fore:#8000B0", L"" },
{ SCE_RB_DATASECTION, 63320, L"Data Section", L"fore:#600000; back:#FFF0D8; eolfilled", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_BASH = {
"alias "
"ar asa awk banner basename bash bc bdiff break "
"bunzip2 bzip2 cal calendar case cat cc cd chmod cksum "
"clear cmp col comm compress continue cp cpio crypt "
"csplit ctags cut date dc dd declare deroff dev df diff diff3 "
"dircmp dirname do done du echo ed egrep elif else env "
"esac eval ex exec exit expand export expr false fc "
"fgrep fi file find fmt fold for function functions "
"getconf getopt getopts grep gres hash head help "
"history iconv id if in integer jobs join kill local lc "
"let line ln logname look ls m4 mail mailx make "
"man mkdir more mt mv newgrp nl nm nohup ntps od "
"pack paste patch pathchk pax pcat perl pg pr print "
"printf ps pwd read readonly red return rev rm rmdir "
"sed select set sh shift size sleep sort spell "
"split start stop strings strip stty sum suspend "
"sync tail tar tee test then time times touch tr "
"trap true tsort tty type typeset ulimit umask unalias "
"uname uncompress unexpand uniq unpack unset until "
"uudecode uuencode vi vim vpax wait wc whence which "
"while who wpaste wstart xargs zcat "
"chgrp chown chroot dir dircolors "
"factor groups hostid install link md5sum mkfifo "
"mknod nice pinky printenv ptx readlink seq "
"sha1sum shred stat su tac unlink users vdir whoami yes",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexBASH = { SCLEX_BASH, 63023, L"Bash Script", L"sh; bash; configure; ksh", L"", &KeyWords_BASH, COMMENT_INFO(BASH_COMMENT, SCE_SH_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_SH_DEFAULT, 63126, L"Default", L"fore:#808080", L"" },
{ SCE_SH_ERROR, 63325, L"Error", L"fore:#FFFF00,back:#FF0000", L"" },
{ SCE_SH_COMMENTLINE, 63127, L"Comment", L"fore:#007F00", L"" },
{ SCE_SH_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" },
{ SCE_SH_WORD, 63128, L"Keyword", L"fore:#00007F,bold", L"" },
{ SCE_SH_STRING, 63131, L"String", L"fore:#7F007F", L"" },
{ SCE_SH_CHARACTER, 63265, L"Char", L"fore:#7F007F", L"" },
{ SCE_SH_OPERATOR, 63132, L"Operator", L"fore:#000000,bold", L"" },
{ SCE_SH_IDENTIFIER, 63129, L"Identifier", L"fore:#000000", L"" },
{ SCE_SH_SCALAR, 63215, L"Scalar $var", L"fore:#000000,back:#FFE0E0", L"" },
{ SCE_SH_PARAM, 63125, L"Parameter", L"fore:#000000,back:#FFFFE0", L"" },
{ SCE_SH_BACKTICKS, 63221, L"Back ticks", L"fore:#FFFF00,back:#A08080", L"" },
{ SCE_SH_HERE_DELIM, 63223, L"Here-doc (delimiter)", L"fore:#000000,back:#DDD0DD", L"" },
{ SCE_SH_HERE_Q, 63224, L"Here-doc (single quoted, q)", L"fore:#7F007F,back:#DDD0DD,eolfilled,notbold", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_ASN1 = {
"ACCESS AGENT AUGMENTS "
"BEGIN BITS "
"CAPABILITIES CHOICE COMPLIANCE CONTACT CONVENTION "
"DEFINITIONS DEFVAL DESCRIPTION DISPLAY "
"END ENTERPRISE EXPORTS "
"FALSE FROM "
"GROUP GROUPS "
"HINT "
"IDENTITY IMPLIED IMPORTS INCLUDES INDEX INFO "
"LAST "
"MANDATORY MAX MIN MODULE "
"NOTATION NOTIFICATION NULL "
"OBJECTS OBJECT-TYPE OF ORGANIZATION "
"PRODUCT "
"RELEASE REFERENCE REQUIRES REVISION "
"SEQUENCE SIZE STATUS SUPPORTS SYNTAX "
"TEXTUAL TRAP TYPE TRAP-TYPE "
"UPDATED "
"VALUE VARIABLES VARIATION "
"WRITE "
"accessible "
"create current "
"deprecated "
"for "
"mandatory "
"not notify not-accessible "
"obsolete only optional "
"read read-only read-write "
"write "
"ABSENT ANY APPLICATION "
"BIT BOOLEAN BY "
"COMPONENT COMPONENTS "
"DEFAULT DEFINED "
"ENUMERATED EXPLICIT EXTERNAL "
"IMPLICIT INIFINITY "
"MAX MIN MINUS "
"OPTIONAL "
"PRESENT PRIVATE "
"REAL "
"SET "
"TAGS TRUE "
"Counter Counter32 Counter64 "
"DisplayString "
"Gauge Gauge32 "
"IDENTIFIER INTEGER Integer32 IpAddress "
"NetworkAddress NsapAddress "
"OBJECT OCTET Opaque "
"PhysAddress "
"STRING "
"TimeTicks "
"UInteger32 UNITS Unsigned32",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexASN1 = { SCLEX_ASN1, 63024, L"ASN1", L"mib", L"", &KeyWords_ASN1, COMMENT_INFO(SQL_COMMENT, SCE_ASN1_COMMENT), {
{ SCE_ASN1_DEFAULT, 63126, L"Default", L"fore:#000000", L"" },
{ SCE_ASN1_COMMENT, 63127, L"Comment", L"fore:#007F00", L"" },
{ SCE_ASN1_IDENTIFIER, 63129, L"Identifier", L"fore:#000000,bold", L"" },
{ SCE_ASN1_STRING, 63131, L"String", L"fore:#7F007F", L"" },
{ SCE_ASN1_OID, 63129, L"Identifier", L"fore:#007F7F,bold", L"" },
{ SCE_ASN1_SCALAR, 63215, L"Scalar $var", L"fore:#7F0000", L"" },
{ SCE_ASN1_KEYWORD, 63128, L"Keyword", L"fore:#00007F", L"" },
{ SCE_ASN1_ATTRIBUTE, 63258, L"Attribute", L"fore:#F07800", L"" },
{ SCE_ASN1_DESCRIPTOR, 63259, L"Descriptor", L"fore:#00007F", L"" },
{ SCE_ASN1_TYPE, 63260, L"Type", L"fore:#00007F", L"" },
{ SCE_ASN1_OPERATOR, 63132, L"Operator", L"fore:#00007F", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_CAML = {
"and as assert asr begin class "
"constraint do done downto else end "
"exception external false for fun function "
"functor if in include inherit initializer "
"land lazy let lor lsl lsr "
"lxor match method mod module mutable "
"new object of open or private "
"rec sig struct then to true "
"try type val virtual when while "
"with ",
"option Some None ignore ref lnot succ pred parser ",
"array bool char float int list string unit",
"", "", "", "", "", ""
};
EDITLEXER lexCAML = { SCLEX_CAML, 63025, L"OCaml", L"ml; mli", L"", &KeyWords_CAML, NULL_COMMENT_INFO, {
{ SCE_CAML_DEFAULT, 63126, L"Default", L"fore:#808080", L"" },
{ SCE_CAML_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_CAML_TAGNAME, 63261, L"Tag Name", L"fore:#000000,back:#ffe0ff", L"" },
{ SCE_CAML_KEYWORD, 63128, L"Keyword", L"fore:#00007F,bold", L"" },
{ SCE_CAML_KEYWORD2, 63262, L"Keyword 2", L"fore:#000000,back:#e0e0ff", L"" },
{ SCE_CAML_KEYWORD3, 63263, L"Keyword 3", L"fore:#a0000,bold", L"" },
{ SCE_CAML_LINENUM, 63264, L"Linenum", L"back:#C0C0C0", L"" },
{ SCE_CAML_OPERATOR, 63132, L"Operator", L"fore:#000000,bold", L"" },
{ SCE_CAML_NUMBER, 63130, L"Number", L"fore:#000000,back:#ffff00", L"" },
{ SCE_CAML_CHAR, 63265, L"Char", L"fore:#000000,back:#ffff00", L"" },
{ SCE_CAML_WHITE, 63266, L"Whitespace", L"fore:#000000,back:#e0e0e0", L"" },
{ SCE_CAML_STRING, 63131, L"String", L"fore:#000000,back:#ffff00", L"" },
{ SCE_CAML_COMMENT, 63127, L"Comment", L"fore:#007F00", L"" },
{ SCE_CAML_COMMENT1, 63267, L"Comment 1", L"back:#E0EEFF", L"" },
{ SCE_CAML_COMMENT2, 63268, L"Comment 2", L"back:#E0EEFF", L"" },
{ SCE_CAML_COMMENT3, 63269, L"Comment 3", L"back:#E0EEFF", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_COFFEESCRIPT = {
"", "", "", "", "", "", "", "", ""
};
EDITLEXER lexCOFFEESCRIPT = { SCLEX_COFFEESCRIPT, 63026, L"CoffeeScript", L"coffee", L"", &KeyWords_COFFEESCRIPT, COMMENT_INFO(BATCH_COMMENT, SCE_COFFEESCRIPT_COMMENTLINE), {
{ SCE_COFFEESCRIPT_DEFAULT, 63126, L"Default", L"fore:#808080", L"" },
{ SCE_COFFEESCRIPT_COMMENT, 63127, L"Comment", L"fore:#007F00", L"" },
{ SCE_COFFEESCRIPT_COMMENTLINE, 63270, L"Comment Line", L"fore:#007F00", L"" },
{ SCE_COFFEESCRIPT_COMMENTDOC, 63271, L"Comment Doc", L"fore:#3F703F", L"" },
{ SCE_COFFEESCRIPT_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" },
{ SCE_COFFEESCRIPT_WORD, 63128, L"Keyword", L"fore:#00007F,bold", L"" },
{ SCE_COFFEESCRIPT_STRING, 63131, L"String", L"fore:#7F007F", L"" },
{ SCE_COFFEESCRIPT_CHARACTER, 63265, L"Char", L"fore:#7F007F", L"" },
{ SCE_COFFEESCRIPT_UUID, 63272, L"UUID", L"fore:#804080", L"" },
{ SCE_COFFEESCRIPT_PREPROCESSOR, 63273, L"Preprocessor", L"fore:#7F7F00", L"" },
{ SCE_COFFEESCRIPT_OPERATOR, 63132, L"Operator", L"fore:#000000,bold", L"" },
{ SCE_COFFEESCRIPT_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_COFFEESCRIPT_STRINGEOL, 63274, L"String EOL", L"fore:#000000,back:#E0C0E0,eolfilled", L"" },
{ SCE_COFFEESCRIPT_VERBATIM, 63275, L"Verbatim", L"fore:#007F00,back:#E0FFE0,eolfilled", L"" },
{ SCE_COFFEESCRIPT_REGEX, 63135, L"Regex", L"fore:#3F7F3F,back:#E0F0FF,eolfilled", L"" },
{ SCE_COFFEESCRIPT_COMMENTLINEDOC, 63276, L"Comment Line Doc", L"fore:#3F703F", L"" },
{ SCE_COFFEESCRIPT_WORD2, 63262, L"Keyword 2", L"fore:#B00040", L"" },
{ SCE_COFFEESCRIPT_COMMENTDOCKEYWORD, 63277, L"Comment Doc Keyword", L"fore:#3060A0", L"" },
{ SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR, 63278, L"Comment Doc Keyword Error", L"fore:#804020", L"" },
{ SCE_COFFEESCRIPT_GLOBALCLASS, 63279, L"Global Class", L"fore:#DD9900", L"" },
{ SCE_COFFEESCRIPT_STRINGRAW, 63280, L"String Raw", L"fore:#7F007F,back:#FFF3FF,eolfilled", L"" },
{ SCE_COFFEESCRIPT_TRIPLEVERBATIM, 63281, L"Trip Lever Batim", L"fore:#007F00,back:#E0FFE0,eolfilled", L"" },
{ SCE_COFFEESCRIPT_COMMENTBLOCK, 63282, L"Comment Block", L"fore:#007F00,back:#E7FFD7,eolfilled", L"" },
{ SCE_COFFEESCRIPT_VERBOSE_REGEX, 63283, L"Verbose Regex", L"fore:#659900", L"" },
{ SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT, 63284, L"Regex Comment", L"fore:#3F703F", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_D = {
"abstract alias align asm assert auto "
"body bool break byte "
"case cast catch cdouble cent cfloat char class const continue creal "
"dchar debug default delegate delete deprecated do double "
"else enum export extern "
"false final finally float for foreach foreach_reverse function "
"goto "
"idouble if ifloat import in inout int interface invariant ireal is "
"lazy long "
"mixin module "
"new null "
"out override "
"package pragma private protected public "
"real return "
"scope short static struct super switch synchronized "
"template this throw true try typedef typeid typeof "
"ubyte ucent uint ulong union unittest ushort "
"version void volatile "
"wchar while with",
"",
"a addindex addtogroup anchor arg attention "
"author b brief bug c class code date def defgroup deprecated dontinclude "
"e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception "
"f$ f[ f] file fn hideinitializer htmlinclude htmlonly "
"if image include ingroup internal invariant interface latexonly li line link "
"mainpage name namespace nosubgrouping note overload "
"p page par param post pre ref relates remarks return retval "
"sa section see showinitializer since skip skipline struct subsection "
"test throw todo typedef union until "
"var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }",
"", "", "", "", "", ""
};
EDITLEXER lexD = { SCLEX_D, 63027, L"D", L"d", L"", &KeyWords_D, COMMENT_INFO(C_COMMENT, SCE_D_COMMENTLINE), {
{ SCE_D_DEFAULT, 63126, L"Default", L"fore:#808080", L"" },
{ SCE_D_COMMENT, 63127, L"Comment", L"fore:#007F00", L"" },
{ SCE_D_COMMENTLINE, 63270, L"Comment Line", L"fore:#007F00", L"" },
{ SCE_D_COMMENTDOC, 63271, L"Comment Doc", L"fore:#3F703F", L"" },
{ SCE_D_COMMENTNESTED, 63286, L"Comment Nested", L"fore:#A0C0A0", L"" },
{ SCE_D_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" },
{ SCE_D_WORD, 63128, L"Keyword", L"fore:#00007F,bold", L"" },
{ SCE_D_WORD2, 63262, L"Keyword 2", L"fore:#00007F,bold", L"" },
{ SCE_D_WORD3, 63263, L"Keyword 3", L"fore:#00007F,bold", L"" },
{ SCE_D_TYPEDEF, 63285, L"Typedef", L"fore:#00007F,bold", L"" },
{ SCE_D_STRING, 63131, L"String", L"fore:#7F007F", L"" },
{ SCE_D_STRINGEOL, 63274, L"String EOL", L"fore:#000000,back:#E0C0E0,eolfilled", L"" },
{ SCE_D_CHARACTER, 63265, L"Char", L"fore:#7F007F", L"" },
{ SCE_D_OPERATOR, 63132, L"Operator", L"fore:#000000,bold", L"" },
{ SCE_D_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_D_COMMENTLINEDOC, 63276, L"Comment Line Doc", L"fore:#3F703F", L"" },
{ SCE_D_COMMENTDOCKEYWORD, 63277, L"Comment Doc Keyword", L"fore:#3060A0", L"" },
{ SCE_D_COMMENTDOCKEYWORDERROR, 63278, L"Comment Doc Keyword Error", L"fore:#804020", L"" },
{ SCE_D_STRINGB, 63287, L"String B", L"fore:#DD9900", L"" },
{ SCE_D_STRINGR, 63288, L"String R", L"fore:#DD9900", L"" },
{ SCE_D_WORD5, 63290, L"Keyword 5", L"fore:#DD9900", L"" },
{ SCE_D_WORD6, 63291, L"Keyword 6", L"fore:#DD9900", L"" },
{ SCE_D_WORD7, 63292, L"Keyword 7", L"fore:#DD9900", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_Lisp = {
"not defun + - * / = < > <= >= princ "
"eval apply funcall quote identity function complement backquote lambda set setq setf "
"defun defmacro gensym make symbol intern symbol name symbol value symbol plist get "
"getf putprop remprop hash make array aref car cdr caar cadr cdar cddr caaar caadr cadar "
"caddr cdaar cdadr cddar cdddr caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr "
"cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr cons list append reverse last nth "
"nthcdr member assoc subst sublis nsubst nsublis remove length list length "
"mapc mapcar mapl maplist mapcan mapcon rplaca rplacd nconc delete atom symbolp numberp "
"boundp null listp consp minusp zerop plusp evenp oddp eq eql equal cond case and or let l if prog "
"prog1 prog2 progn go return do dolist dotimes catch throw error cerror break "
"continue errset baktrace evalhook truncate float rem min max abs sin cos tan expt exp sqrt "
"random logand logior logxor lognot bignums logeqv lognand lognor "
"logorc2 logtest logbitp logcount integer length nil",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexLisp = { SCLEX_LISP, 63028, L"Lisp", L"lsp;lisp", L"", &KeyWords_Lisp, COMMENT_INFO(ASM_COMMENT, SCE_LISP_COMMENT), {
{ SCE_LISP_DEFAULT, 63126, L"Default", L"fore:#808080", L"" },
{ SCE_LISP_COMMENT, 63127, L"Comment", L"fore:#007F00", L"" },
{ SCE_LISP_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" },
{ SCE_LISP_KEYWORD, 63128, L"Keyword", L"fore:#00007F,bold", L"" },
{ SCE_LISP_KEYWORD_KW, 63262, L"Keyword 2", L"fore:#EE00AA", L"" },
{ SCE_LISP_SYMBOL, 63294, L"Symbol", L"fore:#DD9900", L"" },
{ SCE_LISP_STRING, 63131, L"String", L"fore:#7F007F", L"" },
{ SCE_LISP_STRINGEOL, 63274, L"String EOL", L"fore:#000000,back:#fefecc,eolfilled", L"" },
{ SCE_LISP_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_LISP_OPERATOR, 63132, L"Operator", L"fore:#000000,bold", L"" },
{ SCE_LISP_SPECIAL, 63295, L"Special", L"fore:#60AA00", L"" },
{ SCE_LISP_MULTI_COMMENT, 63296, L"Multi-line Comment", L"fore:#007F00", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_Lua = {
"and break do else elseif "
"end for function if in "
"local nil not or repeat "
"return then until while false true goto",
"assert collectgarbage dofile error _G "
"getmetatable ipairs loadfile next pairs "
"pcall print rawequal rawget rawset "
"setmetatable tonumber tostring type _VERSION "
"xpcall string table math coroutine io os debug "
"getfenv gcinfo load loadlib loadstring "
"require select setfenv unpack "
"_LOADED LUA_PATH _REQUIREDNAME "
"package rawlen package bit32 utf8 _ENV",
"string.byte string.char string.dump string.find string.format "
"string.gsub string.len string.lower string.rep string.sub string.upper "
"table.concat table.insert table.remove table.sort "
"math.abs math.acos math.asin math.atan math.atan2 "
"math.ceil math.cos math.deg math.exp math.floor "
"math.frexp math.ldexp math.log math.max math.min "
"math.pi math.pow math.rad math.random math.randomseed "
"math.sin math.sqrt math.tan "
"string.gfind string.gmatch string.match string.reverse "
"string.pack string.packsize string.unpack "
"table.foreach table.foreachi table.getn table.setn "
"table.maxn table.pack table.unpack table.move "
"math.cosh math.fmod math.huge math.log10 math.modf "
"math.mod math.sinh math.tanh math.maxinteger math.mininteger "
"math.tointeger math.type math.ult "
"bit32.arshift bit32.band bit32.bnot bit32.bor bit32.btest "
"bit32.bxor bit32.extract bit32.replace bit32.lrotate bit32.lshift "
"bit32.rrotate bit32.rshift "
"utf8.char utf8.charpattern utf8.codes "
"utf8.codepoint utf8.len utf8.offset",
"coroutine.create coroutine.resume coroutine.status coroutine.wrap coroutine.yield "
"io.close io.flush io.input io.lines io.open "
"io.output io.read io.tmpfile io.type io.write "
"io.stdin io.stdout io.stderr "
"os.clock os.date os.difftime os.execute os.exit "
"os.getenv os.remove os.rename os.setlocale os.time "
"os.tmpname "
"coroutine.isyieldable coroutine.running io.popen "
"module package.loaders package.seeall "
"package.config package.searchers package.searchpath "
"require package.cpath package.loaded "
"package.loadlib package.path package.preload",
"", "", "", "", ""
};
EDITLEXER lexLua = { SCLEX_LUA, 63029, L"Lua", L"lua", L"", &KeyWords_Lua, COMMENT_INFO(LUA_COMMENT, SCE_LUA_COMMENTLINE), {
{ SCE_LUA_DEFAULT, 63126, L"Default", L"fore:#FF0000", L"" },
{ SCE_LUA_COMMENT, 63127, L"Comment", L"fore:#007F00,back:#D0F0F0,eolfilled", L"" },
{ SCE_LUA_COMMENTLINE, 63270, L"Comment Line", L"fore:#007F00", L"" },
{ SCE_LUA_COMMENTDOC, 63271, L"Comment Doc", L"back:#FF0000", L"" },
{ SCE_LUA_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" },
{ SCE_LUA_WORD, 63128, L"Keyword", L"fore:#00007F", L"" },
{ SCE_LUA_STRING, 63131, L"String", L"fore:#7F007F", L"" },
{ SCE_LUA_CHARACTER, 63265, L"Char", L"fore:#7F007F", L"" },
{ SCE_LUA_LITERALSTRING, 63295, L"Literal String", L"fore:#7F007F,back:#E0FFFF", L"" },
{ SCE_LUA_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#7F7F00", L"" },
{ SCE_LUA_OPERATOR, 63132, L"Operator", L"fore:#000000", L"" },
{ SCE_LUA_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_LUA_STRINGEOL, 63274, L"String EOL", L"back:#E0C0E0,eolfilled", L"" },
{ SCE_LUA_WORD2, 63262, L"Keyword 2", L"fore:#00007F,back:#F5FFF5", L"" },
{ SCE_LUA_WORD3, 63263, L"Keyword 3", L"fore:#00007F,back:#F5F5FF", L"" },
{ SCE_LUA_WORD4, 63289, L"Keyword 4", L"fore:#00007F,back:#FFF5F5", L"" },
{ SCE_LUA_WORD5, 63290, L"Keyword 5", L"fore:#00007F,back:#FFF5FF", L"" },
{ SCE_LUA_WORD6, 63291, L"Keyword 6", L"fore:#00007F,back:#FFFFF5", L"" },
{ SCE_LUA_WORD7, 63292, L"Keyword 7", L"fore:#00007F,back:#FFA0A0", L"" },
{ SCE_LUA_WORD8, 63293, L"Keyword 8", L"fore:#00007F,back:#FFF5F5", L"" },
{ SCE_LUA_LABEL, 63235, L"Label", L"fore:#7F7F00", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_NSIS = {
"!addincludedir !addplugindir MakeNSIS Portions "
"Contributors: Abort AddBrandingImage AddSize AutoCloseWindow BGFont "
"BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI "
"ClearErrors ComponentText GetDLLVersion GetDLLVersionLocal GetFileTime "
"GetFileTimeLocal CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut "
"SetDatablockOptimize DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue "
"Delete DetailPrint DirText DirShow DirVar DirVerify GetInstDirError AllowRootDirInstall "
"CheckBitmap EnableWindow EnumRegKey EnumRegValue Exch Exec ExecWait "
"ExecShell ExpandEnvStrings FindWindow FindClose FindFirst FindNext File FileBufSize "
"FlushINI ReserveFile FileClose FileErrorText FileOpen FileRead FileWrite FileReadByte "
"FileWriteByte FileSeek Function FunctionEnd GetDlgItem GetFullPathName "
"GetTempFileName HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfSilent "
"InstallDirRegKey InstallColors InstallDir InstProgressFlags InstType IntOp IntCmp "
"IntCmpU IntFmt IsWindow Goto LangString LangStringUP LicenseData "
"LicenseForceSelection LicenseLangString LicenseText LicenseBkColor "
"LoadLanguageFile LogSet LogText MessageBox Nop Name OutFile Page "
"PageCallbacks PageEx PageExEnd Pop Push Quit ReadINIStr ReadRegDWORD "
"ReadRegStr ReadEnvStr Reboot RegDLL Rename Return RMDir Section SectionEnd "
"SectionIn SubSection SectionGroup SubSectionEnd SectionGroupEnd SearchPath "
"SectionSetFlags SectionGetFlags SectionSetInstTypes SectionGetInstTypes "
"SectionGetText SectionSetText SectionGetSize SectionSetSize GetCurInstType "
"SetCurInstType InstTypeSetText InstTypeGetText SendMessage SetAutoClose "
"SetCtlColors SetBrandingImage SetCompress SetCompressor SetCompressorDictSize "
"SetCompressionLevel SetDateSave SetDetailsView SetDetailsPrint SetErrors "
"SetErrorLevel GetErrorLevel SetFileAttributes SetFont SetOutPath SetOverwrite "
"SetPluginUnload SetRebootFlag SetShellVarContext SetSilent ShowInstDetails "
"ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep StrCmp StrCpy "
"StrLen SubCaption UninstallExeName UninstallCaption UninstallIcon UninstPage "
"UninstallText UninstallSubCaption UnRegDLL WindowIcon WriteINIStr WriteRegBin "
"WriteRegDWORD WriteRegStr WriteRegExpandStr WriteUninstaller XPStyle !packhdr "
"!system !execute !AddIncludeDir !include !cd !ifdef !ifndef !endif !define !undef !else !echo !warning "
"!error !verbose !macro !macroend !insertmacro !ifmacrodef !ifmacrondef MiscButtonText "
"DetailsButtonText UninstallButtonText InstallButtonText SpaceTexts "
"CompletedText GetFunctionAddress GetLabelAddress GetCurrentAddress "
"!AddPluginDir InitPluginsDir AllowSkipFiles Var VIAddVersionKey VIProductVersion LockWindow",
"$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 "
"$R0 $R1 $R2 $R3 $R4 $R5 $R6 $R7 $R8 $R9 $\\t $\\\" $\\' $\\` "
"$VARNAME $0, $INSTDIR $OUTDIR $CMDLINE $LANGUAGE $PROGRAMFILES "
"$COMMONFILES $DESKTOP $EXEDIR ${NSISDIR} $WINDIR $SYSDIR $TEMP "
"$STARTMENU $SMPROGRAMS $SMSTARTUP $QUICKLAUNCH $DOCUMENTS "
"$SENDTO $RECENT $FAVORITES $MUSIC $PICTURES $VIDEOS $NETHOOD "
"$FONTS $TEMPLATES $APPDATA $PRINTHOOD $INTERNET_CACHE $COOKIES "
"$HISTORY $PROFILE $ADMINTOOLS $RESOURCES $RESOURCES_LOCALIZED "
"$CDBURN_AREA $HWNDPARENT $PLUGINSDIR $$ $\\r $\\n",
"ARCHIVE FILE_ATTRIBUTE_ARCHIVE FILE_ATTRIBUTE_HIDDEN "
"FILE_ATTRIBUTE_NORMAL FILE_ATTRIBUTE_OFFLINE FILE_ATTRIBUTE_READONLY "
"FILE_ATTRIBUTE_SYSTEM FILE_ATTRIBUTE_TEMPORARY HIDDEN HKCC HKCR HKCU "
"HKDD HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER HKEY_DYN_DATA "
"HKEY_LOCAL_MACHINE HKEY_PERFORMANCE_DATA HKEY_USERS HKLM HKPD HKU IDABORT "
"IDCANCEL IDIGNORE IDNO IDOK IDRETRY IDYES MB_ABORTRETRYIGNORE MB_DEFBUTTON1 "
"MB_DEFBUTTON2 MB_DEFBUTTON3 MB_DEFBUTTON4 MB_ICONEXCLAMATION "
"MB_ICONINFORMATION MB_ICONQUESTION MB_ICONSTOP MB_OK MB_OKCANCEL "
"MB_RETRYCANCEL MB_RIGHT MB_SETFOREGROUND MB_TOPMOST MB_YESNO "
"MB_YESNOCANCEL NORMAL OFFLINE READONLY SW_SHOWMAXIMIZED SW_SHOWMINIMIZED "
"SW_SHOWNORMAL SYSTEM TEMPORARY auto colored false force hide ifnewer nevershow "
"normal off on show silent silentlog smooth true try lzma zlib bzip2 none listonly textonly "
"both top left bottom right license components directory instfiles uninstConfirm custom "
"all leave current ifdiff lastused LEFT RIGHT CENTER dlg_id ALT CONTROL EXT SHIFT "
"open print manual alwaysoff",
"", "", "", "", "", ""
};
EDITLEXER lexNSIS = { SCLEX_NSIS, 63030, L"NSIS Script", L"nsi;nsh", L"", &KeyWords_NSIS, COMMENT_INFO(BASH_COMMENT, SCE_NSIS_COMMENT), {
{ SCE_NSIS_DEFAULT, 63126, L"Default", L"fore:#000000", L"" },
{ SCE_NSIS_COMMENT, 63127, L"Comment", L"fore:#007F00", L"" },
{ SCE_NSIS_STRINGDQ, 63211, L"String double quoted", L"fore:#999999,back:#EEEEEE", L"" },
{ SCE_NSIS_STRINGLQ, 63298, L"String left quote", L"fore:#999999,back:#EEEEEE", L"" },
{ SCE_NSIS_STRINGRQ, 63299, L"String right quote", L"fore:#999999,back:#EEEEEE", L"" },
{ SCE_NSIS_FUNCTION, 63247, L"Function name", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_VARIABLE, 63249, L"Variable", L"fore:#CC3300", L"" },
{ SCE_NSIS_LABEL, 63235, L"Label", L"fore:#FF9900", L"" },
{ SCE_NSIS_USERDEFINED, 63300, L"User defined", L"fore:#000000", L"" },
{ SCE_NSIS_SECTIONDEF, 63232, L"Section", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_SUBSECTIONDEF, 63301, L"Subsection", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_IFDEFINEDEF, 63302, L"If def", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_MACRODEF, 63303, L"Macro def", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_STRINGVAR, 63304, L"Variable within string", L"fore:#CC3300,back:#EEEEEE", L"" },
{ SCE_NSIS_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" },
{ SCE_NSIS_SECTIONGROUP, 63305, L"Section Group", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_PAGEEX, 63306, L"Page Ex", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_FUNCTIONDEF, 63307, L"Function Definition", L"fore:#00007F,bold", L"" },
{ SCE_NSIS_COMMENTBOX, 63308, L"Comment Box", L"fore:#007F00,bold", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_TeX = {
"above abovedisplayshortskip abovedisplayskip "
"abovewithdelims accent adjdemerits advance afterassignment "
"aftergroup atop atopwithdelims "
"badness baselineskip batchmode begingroup "
"belowdisplayshortskip belowdisplayskip binoppenalty botmark "
"box boxmaxdepth brokenpenalty "
"catcode char chardef cleaders closein closeout clubpenalty "
"copy count countdef cr crcr csname "
"day deadcycles def defaulthyphenchar defaultskewchar "
"delcode delimiter delimiterfactor delimeters "
"delimitershortfall delimeters dimen dimendef discretionary "
"displayindent displaylimits displaystyle "
"displaywidowpenalty displaywidth divide "
"doublehyphendemerits dp dump "
"edef else emergencystretch end endcsname endgroup endinput "
"endlinechar eqno errhelp errmessage errorcontextlines "
"errorstopmode escapechar everycr everydisplay everyhbox "
"everyjob everymath everypar everyvbox exhyphenpenalty "
"expandafter "
"fam fi finalhyphendemerits firstmark floatingpenalty font "
"fontdimen fontname futurelet "
"gdef global group globaldefs "
"halign hangafter hangindent hbadness hbox hfil horizontal "
"hfill horizontal hfilneg hfuzz hoffset holdinginserts hrule "
"hsize hskip hss horizontal ht hyphenation hyphenchar "
"hyphenpenalty hyphen "
"if ifcase ifcat ifdim ifeof iffalse ifhbox ifhmode ifinner "
"ifmmode ifnum ifodd iftrue ifvbox ifvmode ifvoid ifx "
"ignorespaces immediate indent input inputlineno "
"insert insertpenalties interlinepenalty "
"jobname "
"kern "
"language lastbox lastkern lastpenalty lastskip lccode "
"leaders left lefthyphenmin leftskip leqno let limits "
"linepenalty line lineskip lineskiplimit long looseness "
"lower lowercase "
"mag mark mathaccent mathbin mathchar mathchardef mathchoice "
"mathclose mathcode mathinner mathop mathopen mathord "
"mathpunct mathrel mathsurround maxdeadcycles maxdepth "
"meaning medmuskip message mkern month moveleft moveright "
"mskip multiply muskip muskipdef "
"newlinechar noalign noboundary noexpand noindent nolimits "
"nonscript scriptscript nonstopmode nulldelimiterspace "
"nullfont number "
"omit openin openout or outer output outputpenalty over "
"overfullrule overline overwithdelims "
"pagedepth pagefilllstretch pagefillstretch pagefilstretch "
"pagegoal pageshrink pagestretch pagetotal par parfillskip "
"parindent parshape parskip patterns pausing penalty "
"postdisplaypenalty predisplaypenalty predisplaysize "
"pretolerance prevdepth prevgraf "
"radical raise read relax relpenalty right righthyphenmin "
"rightskip romannumeral "
"scriptfont scriptscriptfont scriptscriptstyle scriptspace "
"scriptstyle scrollmode setbox setlanguage sfcode shipout "
"show showbox showboxbreadth showboxdepth showlists showthe "
"skewchar skip skipdef spacefactor spaceskip span special "
"splitbotmark splitfirstmark splitmaxdepth splittopskip "
"string "
"tabskip textfont textstyle the thickmuskip thinmuskip time "
"toks toksdef tolerance topmark topskip tracingcommands "
"tracinglostchars tracingmacros tracingonline tracingoutput "
"tracingpages tracingparagraphs tracingrestores tracingstats "
"uccode uchyph underline unhbox unhcopy unkern unpenalty "
"unskip unvbox unvcopy uppercase "
"vadjust valign vbadness vbox vcenter vfil vfill vfilneg "
"vfuzz voffset vrule vsize vskip vsplit vss vtop "
"wd widowpenalty write "
"xdef xleaders xspaceskip "
"year "
"TeX "
"bgroup egroup endgraf space empty null "
"newcount newdimen newskip newmuskip newbox newtoks newhelp newread newwrite newfam newlanguage newinsert newif "
"maxdimen magstephalf magstep "
"frenchspacing nonfrenchspacing normalbaselines obeylines obeyspaces raggedright ttraggedright "
"thinspace negthinspace enspace enskip quad qquad "
"smallskip medskip bigskip removelastskip topglue vglue hglue "
"break nobreak allowbreak filbreak goodbreak smallbreak medbreak bigbreak "
"line leftline rightline centerline rlap llap underbar strutbox strut "
"cases matrix pmatrix bordermatrix eqalign displaylines eqalignno leqalignno "
"pageno folio tracingall showhyphens fmtname fmtversion "
"hphantom vphantom phantom smash",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexTeX = { SCLEX_TEX, 63031, L"TeX", L"tex;sty", L"", &KeyWords_TeX, NULL_COMMENT_INFO, {
{ SCE_TEX_DEFAULT, 63126, L"Default", L"fore:#3F3F3F", L"" },
{ SCE_TEX_SPECIAL, 63295, L"Special", L"fore:#007F7F", L"" },
{ SCE_TEX_GROUP, 63321, L"Group", L"fore:#7F0000", L"" },
{ SCE_TEX_SYMBOL, 63316, L"Symbol", L"fore:#7F7F00", L"" },
{ SCE_TEX_COMMAND, 63236, L"Command", L"fore:#007F00", L"" },
{ SCE_TEX_TEXT, 63322, L"Text", L"", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_Yaml = {
"true false yes no",
"", "", "", "", "", "", "", ""
};
EDITLEXER lexYaml = { SCLEX_YAML, 63032, L"YAML", L"yaml;yml", L"", &KeyWords_Yaml, COMMENT_INFO(BASH_COMMENT, SCE_YAML_COMMENT), {
{ SCE_YAML_DEFAULT, 63126, L"Default", L"fore:#000000", L"" },
{ SCE_YAML_COMMENT, 63127, L"Comment", L"fore:#008800", L"" },
{ SCE_YAML_IDENTIFIER, 63129, L"Identifier", L"fore:#000088,bold", L"" },
{ SCE_YAML_KEYWORD, 63128, L"Keyword", L"fore:#880088", L"" },
{ SCE_YAML_NUMBER, 63130, L"Number", L"fore:#880000", L"" },
{ SCE_YAML_REFERENCE, 63323, L"Reference", L"fore:#008888", L"" },
{ SCE_YAML_DOCUMENT, 63324, L"Document", L"fore:#FFFFFF,bold,back:#000088,eolfilled", L"" },
{ SCE_YAML_TEXT, 63322, L"Text", L"fore:#333366", L"" },
{ SCE_YAML_ERROR, 63325, L"Error", L"fore:#FFFFFF,italics,bold,back:#FF0000,eolfilled", L"" },
{ SCE_YAML_OPERATOR, 63132, L"Operator", L"fore:#000000", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_Rust = {
"alignof as be box break const continue crate do else enum extern false fn "
"for if impl in let loop match mod mut offsetof once priv proc pub pure ref "
"return self sizeof static struct super trait true type typeof unsafe unsized use virtual while yield",
"bool char f32 f64 i16 i32 i64 i8 int str u16 u32 u64 u8 uint",
"Self",
"", "", "", "", "", ""
};
EDITLEXER lexRust = { SCLEX_RUST, 63033, L"Rust", L"rs", L"", &KeyWords_Rust, COMMENT_INFO(C_COMMENT, SCE_RUST_COMMENTLINE), {
{ SCE_RUST_DEFAULT, 63126, L"Default", L"fore:#808080", L"" },
{ SCE_RUST_COMMENTBLOCK, 63282, L"Comment Block", L"fore:#007F00", L"" },
{ SCE_RUST_COMMENTLINE, 63270, L"Comment Line", L"fore:#007F00", L"" },
{ SCE_RUST_COMMENTBLOCKDOC, 63326, L"Comment Block Dock", L"fore:#3F703F", L"" },
{ SCE_RUST_COMMENTLINEDOC, 63276, L"Comment Line Doc", L"fore:#3F703F", L"" },
{ SCE_RUST_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" },
{ SCE_RUST_WORD, 63128, L"Keyword", L"fore:#00007F,bold", L"" },
{ SCE_RUST_WORD2, 63262, L"Keyword 2", L"fore:#00007F,bold", L"" },
{ SCE_RUST_WORD3, 63263, L"Keyword 3", L"fore:#00007F", L"" },
{ SCE_RUST_WORD4, 63289, L"Keyword 4", L"fore:#00007F,bold", L"" },
{ SCE_RUST_WORD5, 63290, L"Keyword 5", L"fore:#00007F,bold", L"" },
{ SCE_RUST_WORD6, 63291, L"Keyword 6", L"fore:#00007F,bold", L"" },
{ SCE_RUST_WORD7, 63292, L"Keyword 7", L"fore:#00007F,bold", L"" },
{ SCE_RUST_STRING, 63131, L"String", L"fore:#7F007F", L"" },
{ SCE_RUST_STRINGR, 63288, L"String R", L"fore:#B090B0", L"" },
{ SCE_RUST_CHARACTER, 63265, L"Char", L"fore:#7F007F", L"" },
{ SCE_RUST_OPERATOR, 63132, L"Operator", L"fore:#000000,bold", L"" },
{ SCE_RUST_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ SCE_RUST_LIFETIME, 63327, L"Lifetime", L"fore:#007F7F", L"" },
{ SCE_RUST_MACRO, 63303, L"Macro def", L"fore:#7F7F00", L"" },
{ SCE_RUST_LEXERROR, 63325, L"Error", L"fore:#000000,back:#E0C0E0", L"" },
{ SCE_RUST_BYTESTRING, 63328, L"Byte String", L"fore:#7F007F", L"" },
{ SCE_RUST_BYTESTRINGR, 63329, L"Byte String R", L"fore:#B090B0", L"" },
{ SCE_RUST_BYTECHARACTER, 63330, L"Byte Char", L"fore:#7F007F", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
KEYWORDLIST KeyWords_Markdown = {
"", "", "", "", "", "", "", "", ""
};
EDITLEXER lexMarkdown = { SCLEX_MARKDOWN, 63034, L"Markdown", L"markdown;mdown;mkdn;md;mkd;mdwn;mdtxt;mdtext", L"", &KeyWords_Markdown, NULL_COMMENT_INFO, {
{ SCE_MARKDOWN_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_MARKDOWN_LINE_BEGIN, 63331, L"Line Begin", L"fore:#CC00FF", L"" },
{ SCE_MARKDOWN_STRONG1, 63332, L"Strong", L"fore:#DDBB99,bold", L"" },
{ SCE_MARKDOWN_STRONG2, 63333, L"Strong 2", L"fore:#CC00FF", L"" },
{ SCE_MARKDOWN_EM1, 63334, L"EM1", L"fore:#CC00FF,italics", L"" },
{ SCE_MARKDOWN_EM2, 63335, L"EM2", L"fore:#9999FF,italics", L"" },
{ SCE_MARKDOWN_HEADER1, 63336, L"Header 1", L"fore:#0088FF,bold", L"" },
{ SCE_MARKDOWN_HEADER2, 63337, L"Header 2", L"fore:#2299FF,bold", L"" },
{ SCE_MARKDOWN_HEADER3, 63338, L"Header 3", L"fore:#44AAFF,bold", L"" },
{ SCE_MARKDOWN_HEADER4, 63339, L"Header 4", L"fore:#CC00FF,bold", L"" },
{ SCE_MARKDOWN_HEADER5, 63340, L"Header 5", L"fore:#CC00FF,bold", L"" },
{ SCE_MARKDOWN_HEADER6, 63341, L"Header 6", L"fore:#CC00FF,bold", L"" },
{ SCE_MARKDOWN_PRECHAR, 63342, L"Prechar", L"fore:#000000", L"" },
{ SCE_MARKDOWN_ULIST_ITEM, 63343, L"UList Item", L"fore:#CC33FF", L"" },
{ SCE_MARKDOWN_OLIST_ITEM, 63344, L"OList Item", L"fore:#CC00FF", L"" },
{ SCE_MARKDOWN_BLOCKQUOTE, 63345, L"Block Quote", L"fore:#CC00FF", L"" },
{ SCE_MARKDOWN_STRIKEOUT, 63346, L"Strike Out", L"", L"" },
{ SCE_MARKDOWN_HRULE, 63347, L"HRule", L"fore:#CC00FF", L"" },
{ SCE_MARKDOWN_LINK, 63348, L"Link", L"fore:#FF5555", L"" },
{ SCE_MARKDOWN_CODE, 63349, L"Code", L"fore:#80FF80,back:#100010", L"" },
{ SCE_MARKDOWN_CODE2, 63350, L"Code 2", L"fore:#CC00FF", L"" },
{ SCE_MARKDOWN_CODEBK, 63351, L"Code Block", L"fore:#CC00FF", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
// [2e]: Awk syntax highlighting #216
// Original lexer implementation: https://github.com/rizonesoft/Notepad3/blob/master/src/StyleLexers/styleLexAwk.c
KEYWORDLIST KeyWords_Awk = {
"break case continue default do else exit function for if in next return switch while "
"@include delete nextfile print printf BEGIN BEGINFILE END "
"atan2 cos exp int log rand sin sqrt srand asort asorti gensub gsub index "
"length match patsplit split sprintf strtonum sub substr tolower toupper close "
"fflush system mktime strftime systime and compl lshift rshift xor "
"isarray bindtextdomain dcgettext dcngettext",
"ARGC ARGIND ARGV FILENAME FNR FS NF NR OFMT OFS ORS RLENGTH RS RSTART SUBSEP TEXTDOMAIN "
"BINMODE CONVFMT FIELDWIDTHS FPAT IGNORECASE LINT TEXTDOMAiN ENVIRON ERRNO PROCINFO RT",
"", "", "", "", "", ""
};
EDITLEXER lexAWK = { SCLEX_PYTHON, 63035, L"Awk Script", L"awk", L"", &KeyWords_Awk, COMMENT_INFO(BASH_COMMENT, SCE_P_COMMENTLINE), {
{ STYLE_DEFAULT, 63126, L"Default", L"", L"" },
{ SCE_P_WORD, 63128, L"Keyword", L"bold; fore:#0000A0", L"" },
{ SCE_P_WORD, 63262, L"Keyword 2", L"bold; italic; fore:#6666FF", L"" },
{ SCE_P_IDENTIFIER, 63129, L"Identifier", L"", L"" },
{ MULTI_STYLE(SCE_P_COMMENTLINE,SCE_P_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#808080", L"" },
{ MULTI_STYLE(SCE_P_STRING,SCE_P_STRINGEOL,SCE_P_CHARACTER,0), 63131, L"String", L"fore:#008000", L"" },
{ SCE_P_NUMBER, 63130, L"Number", L"fore:#C04000", L"" },
{ SCE_P_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
// [/2e]
// [2e]: AHK syntax highlighting #214
// Original lexer implementation: https://github.com/XhmikosR/notepad2-mod/blob/master/scintilla/lexers/LexAHK.cxx
KEYWORDLIST KeyWords_AHK = {
"break continue else exit exitapp gosub goto if ifequal ifexist ifgreater ifgreaterorequal "
"ifinstring ifless iflessorequal ifmsgbox ifnotequal ifnotexist ifnotinstring ifwinactive "
"ifwinexist ifwinnotactive ifwinnotexist loop onexit pause repeat return settimer sleep "
"suspend static global local var byref while until for class try catch throw",
"autotrim blockinput clipwait control controlclick controlfocus controlget controlgetfocus "
"controlgetpos controlgettext controlmove controlsend controlsendraw controlsettext coordmode "
"critical detecthiddentext detecthiddenwindows drive driveget drivespacefree edit endrepeat "
"envadd envdiv envget envmult envset envsub envupdate fileappend filecopy filecopydir filecreatedir "
"filecreateshortcut filedelete filegetattrib filegetshortcut filegetsize filegettime filegetversion "
"fileinstall filemove filemovedir fileread filereadline filerecycle filerecycleempty fileremovedir "
"fileselectfile fileselectfolder filesetattrib filesettime formattime getkeystate groupactivate "
"groupadd groupclose groupdeactivategui guicontrol guicontrolget hideautoitwin hotkey imagesearch "
"inidelete iniread iniwrite input inputbox keyhistory keywait listhotkeys listlines listvars menu "
"mouseclick mouseclickdrag mousegetpos mousemove msgbox outputdebug pixelgetcolor pixelsearch "
"postmessage process progress random regdelete regread regwrite reload run runas runwait send "
"sendevent sendinput sendmessage sendmode sendplay sendraw setbatchlines setcapslockstate "
"setcontroldelay setdefaultmousespeed setenv setformat setkeydelay setmousedelay setnumlockstate "
"setscrolllockstate setstorecapslockmode settitlematchmode setwindelay setworkingdir shutdown sort "
"soundbeep soundget soundgetwavevolume soundplay soundset soundsetwavevolume splashimage splashtextoff "
"splashtexton splitpath statusbargettext statusbarwait stringcasesense stringgetpos stringleft stringlen "
"stringlower stringmid stringreplace stringright stringsplit stringtrimleft stringtrimright stringupper "
"sysget thread tooltip transform traytip urldownloadtofile winactivate winactivatebottom winclose winget "
"wingetactivestats wingetactivetitle wingetclass wingetpos wingettext wingettitle winhide winkill "
"winmaximize winmenuselectitem winminimize winminimizeall winminimizeallundo winmove winrestore winset "
"winsettitle winshow winwait winwaitactive winwaitclose winwaitnotactive fileencoding",
"abs acos asc asin atan ceil chr cos dllcall exp fileexist floor getkeystate numget numput "
"registercallback il_add il_create il_destroy instr islabel isfunc ln log lv_add lv_delete "
"lv_deletecol lv_getcount lv_getnext lv_gettext lv_insert lv_insertcol lv_modify lv_modifycol "
"lv_setimagelist mod onmessage round regexmatch regexreplace sb_seticon sb_setparts sb_settext "
"sin sqrt strlen substr tan tv_add tv_delete tv_getchild tv_getcount tv_getnext tv_get tv_getparent "
"tv_getprev tv_getselection tv_gettext tv_modify tv_setimagelist varsetcapacity winactive winexist "
"trim ltrim rtrim fileopen strget strput object array isobject objinsert objremove objminindex "
"objmaxindex objsetcapacity objgetcapacity objgetaddress objnewenum objaddref objrelease objhaskey "
"objclone _insert _remove _minindex _maxindex _setcapacity _getcapacity _getaddress _newenum _addref "
"_release _haskey _clone comobjcreate comobjget comobjconnect comobjerror comobjactive comobjenwrap "
"comobjunwrap comobjparameter comobjmissing comobjtype comobjvalue comobjarray comobjquery comobjflags "
"func getkeyname getkeyvk getkeysc isbyref exception",
"allowsamelinecomments clipboardtimeout commentflag errorstdout escapechar hotkeyinterval "
"hotkeymodifiertimeout hotstring if iftimeout ifwinactive ifwinexist include includeagain "
"installkeybdhook installmousehook keyhistory ltrim maxhotkeysperinterval maxmem maxthreads "
"maxthreadsbuffer maxthreadsperhotkey menumaskkey noenv notrayicon persistent singleinstance "
"usehook warn winactivateforce",
"shift lshift rshift alt lalt ralt control lcontrol rcontrol ctrl lctrl rctrl lwin rwin appskey "
"altdown altup shiftdown shiftup ctrldown ctrlup lwindown lwinup rwindown rwinup lbutton rbutton "
"mbutton wheelup wheeldown xbutton1 xbutton2 joy1 joy2 joy3 joy4 joy5 joy6 joy7 joy8 joy9 joy10 "
"joy11 joy12 joy13 joy14 joy15 joy16 joy17 joy18 joy19 joy20 joy21 joy22 joy23 joy24 joy25 joy26 "
"joy27 joy28 joy29 joy30 joy31 joy32 joyx joyy joyz joyr joyu joyv joypov joyname joybuttons "
"joyaxes joyinfo space tab enter escape esc backspace bs delete del insert ins pgup pgdn home end "
"up down left right printscreen ctrlbreak pause scrolllock capslock numlock numpad0 numpad1 numpad2 "
"numpad3 numpad4 numpad5 numpad6 numpad7 numpad8 numpad9 numpadmult numpadadd numpadsub numpaddiv "
"numpaddot numpaddel numpadins numpadclear numpadup numpaddown numpadleft numpadright numpadhome "
"numpadend numpadpgup numpadpgdn numpadenter f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 "
"f16 f17 f18 f19 f20 f21 f22 f23 f24 browser_back browser_forward browser_refresh browser_stop "
"browser_search browser_favorites browser_home volume_mute volume_down volume_up media_next "
"media_prev media_stop media_play_pause launch_mail launch_media launch_app1 launch_app2 blind "
"click raw wheelleft wheelright",
"a_ahkpath a_ahkversion a_appdata a_appdatacommon a_autotrim a_batchlines a_caretx a_carety "
"a_computername a_controldelay a_cursor a_dd a_ddd a_dddd a_defaultmousespeed a_desktop "
"a_desktopcommon a_detecthiddentext a_detecthiddenwindows a_endchar a_eventinfo a_exitreason "
"a_formatfloat a_formatinteger a_gui a_guievent a_guicontrol a_guicontrolevent a_guiheight "
"a_guiwidth a_guix a_guiy a_hour a_iconfile a_iconhidden a_iconnumber a_icontip a_index "
"a_ipaddress1 a_ipaddress2 a_ipaddress3 a_ipaddress4 a_isadmin a_iscompiled a_issuspended "
"a_keydelay a_language a_lasterror a_linefile a_linenumber a_loopfield a_loopfileattrib "
"a_loopfiledir a_loopfileext a_loopfilefullpath a_loopfilelongpath a_loopfilename "
"a_loopfileshortname a_loopfileshortpath a_loopfilesize a_loopfilesizekb a_loopfilesizemb "
"a_loopfiletimeaccessed a_loopfiletimecreated a_loopfiletimemodified a_loopreadline a_loopregkey "
"a_loopregname a_loopregsubkey a_loopregtimemodified a_loopregtype a_mday a_min a_mm a_mmm "
"a_mmmm a_mon a_mousedelay a_msec a_mydocuments a_now a_nowutc a_numbatchlines a_ostype "
"a_osversion a_priorhotkey a_programfiles a_programs a_programscommon a_screenheight "
"a_screenwidth a_scriptdir a_scriptfullpath a_scriptname a_sec a_space a_startmenu "
"a_startmenucommon a_startup a_startupcommon a_stringcasesense a_tab a_temp a_thishotkey "
"a_thismenu a_thismenuitem a_thismenuitempos a_tickcount a_timeidle a_timeidlephysical "
"a_timesincepriorhotkey a_timesincethishotkey a_titlematchmode a_titlematchmodespeed "
"a_username a_wday a_windelay a_windir a_workingdir a_yday a_year a_yweek a_yyyy "
"clipboard clipboardall comspec errorlevel programfiles true false a_thisfunc a_thislabel "
"a_ispaused a_iscritical a_isunicode a_ptrsize a_scripthwnd a_priorkey",
"ltrim rtrim join ahk_id ahk_pid ahk_class ahk_group ahk_exe processname processpath minmax "
"controllist statuscd filesystem setlabel alwaysontop mainwindow nomainwindow useerrorlevel "
"altsubmit hscroll vscroll imagelist wantctrla wantf2 vis visfirst wantreturn backgroundtrans "
"minimizebox maximizebox sysmenu toolwindow exstyle check3 checkedgray readonly notab lastfound "
"lastfoundexist alttab shiftalttab alttabmenu alttabandmenu alttabmenudismiss controllisthwnd "
"hwnd deref pow bitnot bitand bitor bitxor bitshiftleft bitshiftright sendandmouse mousemove "
"mousemoveoff hkey_local_machine hkey_users hkey_current_user hkey_classes_root hkey_current_config "
"hklm hku hkcu hkcr hkcc reg_sz reg_expand_sz reg_multi_sz reg_dword reg_qword reg_binary reg_link "
"reg_resource_list reg_full_resource_descriptor reg_resource_requirements_list reg_dword_big_endian "
"regex pixel mouse screen relative rgb low belownormal normal abovenormal high realtime between "
"contains in is integer float number digit xdigit integerfast floatfast alpha upper lower alnum "
"time date not or and topmost top bottom transparent transcolor redraw region id idlast count "
"list capacity eject lock unlock label serial type status seconds minutes hours days read parse "
"logoff close error single shutdown menu exit reload tray add rename check uncheck togglecheck "
"enable disable toggleenable default nodefault standard nostandard color delete deleteall icon "
"noicon tip click show edit progress hotkey text picture pic groupbox button checkbox radio "
"dropdownlist ddl combobox statusbar treeview listbox listview datetime monthcal updown slider "
"tab tab2 activex iconsmall tile report sortdesc nosort nosorthdr grid hdr autosize range xm ym "
"ys xs xp yp font resize owner submit nohide minimize maximize restore noactivate na cancel "
"destroy center margin owndialogs guiescape guiclose guisize guicontextmenu guidropfiles tabstop "
"section wrap border top bottom buttons expand first lines number uppercase lowercase limit "
"password multi group background bold italic strike underline norm theme caption delimiter flash "
"style checked password hidden left right center section move focus hide choose choosestring text "
"pos enabled disabled visible notimers interrupt priority waitclose unicode tocodepage fromcodepage "
"yes no ok cancel abort retry ignore force on off all send wanttab monitorcount monitorprimary "
"monitorname monitorworkarea pid this base extends __get __set __call __delete __new new "
"useunsetlocal useunsetglobal useenv localsameasglobal",
"", ""
};
EDITLEXER lexAHK = { SCLEX_AHK, 63036, L"AutoHotkey Script", L"ahk; ia; scriptlet", L"", &KeyWords_AHK, COMMENT_INFO(ASM_COMMENT, SCE_AHK_COMMENTLINE), {
{ SCE_AHK_DEFAULT, 63126, L"Default", L"", L"" },
{ MULTI_STYLE(SCE_AHK_COMMENTLINE,SCE_AHK_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" },
{ SCE_AHK_ESCAPE, 63352, L"Escape", L"fore:#FF8000", L"" },
{ SCE_AHK_SYNOPERATOR, 63353, L"Syntax operator", L"fore:#7F200F", L"" },
{ SCE_AHK_EXPOPERATOR, 63354, L"Expression operator", L"fore:#FF4F00", L"" },
{ SCE_AHK_STRING, 63131, L"String", L"fore:#404040", L"" },
{ SCE_AHK_NUMBER, 63130, L"Number", L"fore:#2F4F7F", L"" },
{ SCE_AHK_IDENTIFIER, 63129, L"Identifier", L"fore:#CF2F0F", L"" },
{ SCE_AHK_VARREF, 63355, L"Variable dereferencing", L"fore:#CF2F0F; back:#E4FFE4", L"" },
{ SCE_AHK_LABEL, 63235, L"Label", L"fore:#000000; back:#FFFFA1", L"" },
{ SCE_AHK_WORD_CF, 63356, L"Flow of control", L"fore:#480048; bold", L"" },
{ SCE_AHK_WORD_CMD, 63236, L"Command", L"fore:#004080", L"" },
{ SCE_AHK_WORD_FN, 63247, L"Function name", L"fore:#0F707F; italics", L"" },
{ SCE_AHK_WORD_DIR, 63357, L"Directive", L"fore:#F04020; italics", L"" },
{ SCE_AHK_WORD_KB, 63358, L"Keys & buttons", L"fore:#FF00FF; bold", L"" },
{ SCE_AHK_WORD_VAR, 63359, L"Built-in variables", L"fore:#CF00CF; italics", L"" },
{ SCE_AHK_WORD_SP, 63295, L"Special", L"fore:#0000FF; italics", L"" },
{ SCE_AHK_WORD_UD, 63300, L"User defined", L"fore:#800020", L"" },
{ SCE_AHK_VARREFKW, 63360, L"Variable keyword", L"fore:#CF00CF; italics; back:#F9F9FF", L"" },
{ SCE_AHK_ERROR, 63325, L"Error", L"back:#FFC0C0", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
// [2e]: Lua LPeg Lexers #251
#ifdef LPEG_LEXER
EDITLEXER lexLPEG = { SCLEX_LPEG, 63037, L"LPEG", L"", L"", &KeyWords_NULL, NULL_COMMENT_INFO, {
{ 0, 63126, L"Default", L"", L"" },
{ -1, 00000, L"", L"", L"" }
}
};
#endif
// [/2e]
PEDITLEXER pLexArray[NUMLEXERS] = {
&lexDefault,
&lexCONF,
&lexASN1,
&lexASM,
&lexAHK,
&lexAWK,
&lexBASH,
&lexBAT,
&lexCS,
&lexCPP,
&lexCOFFEESCRIPT,
&lexINI,
&lexCSS,
&lexD,
&lexDIFF,
&lexJAVA,
&lexJS,
&lexLisp,
&lexLua,
&lexMAK,
&lexMarkdown,
&lexNSIS,
&lexCAML,
&lexPAS,
&lexPL,
&lexPS,
&lexPY,
&lexRC,
&lexRUBY,
&lexRust,
&lexSQL,
&lexTeX,
&lexVBS,
&lexVB,
&lexHTML,
&lexXML,
&lexYaml
#ifdef LPEG_LEXER
, &lexLPEG
#endif
};
PEDITLEXER pLexCurrent = &lexDefault;
|
7d97a11bbf7c26dffa733788bbfad43f56d5adfa
|
d5fa3a8417ef72029ebe1a714204b4d80afa07b0
|
/apue/10-14.c
|
dde35cd1938669fb5081f5bcd2e3c3b50791fe59
|
[] |
no_license
|
wuzhouhui/misc
|
e9eeaa16ce21341db0e075a369edc45af4a89aae
|
465c679b10b9766985a510df26d3e6a549cfa421
|
refs/heads/master
| 2023-01-07T00:45:02.721093
| 2022-12-30T07:27:37
| 2022-12-30T07:27:37
| 48,721,582
| 1,287
| 494
| null | null | null | null |
UTF-8
|
C
| false
| false
| 512
|
c
|
10-14.c
|
#include <errno.h>
#include <stdio.h>
#include <signal.h>
void pr_mask(const char *str)
{
sigset_t sigset;
int errno_save;
errno_save = errno;
if (sigprocmask(0, NULL, &sigset) < 0) {
printf("sigprocmask() error\n");
} else {
printf("%s", str);
if (sigismember(&sigset, SIGQUIT))
printf(" SIGQUIT\n");
if (sigismember(&sigset, SIGINT))
printf(" SIGINT\n");
if (sigismember(&sigset, SIGUSR1))
printf(" SIGUSR1\n");
if (sigismember(&sigset, SIGUSR2))
printf(" SIGUSR2\n");
}
}
|
1df64998d52615c1ddf77267b83ec80643a3df99
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/Infineon/libraries/IFX_PSOC6_HAL/mtb_shared/usbdev/cy_usb_dev_hid_descr.h
|
2b46132a05b4805cf9022c0321cae8f870edd6c9
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 1,693
|
h
|
cy_usb_dev_hid_descr.h
|
/***************************************************************************//**
* \file cy_usb_dev_hid_descr.h
* \version 2.10
*
* Provides HID class-specific descriptor defines.
*
********************************************************************************
* \copyright
* (c) 2018-2021, Cypress Semiconductor Corporation (an Infineon company) or
* an affiliate of Cypress Semiconductor Corporation. All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
*******************************************************************************/
#if !defined(CY_USB_DEV_HID_DESCR_H)
#define CY_USB_DEV_HID_DESCR_H
#if (defined(CY_IP_MXUSBFS) || defined(CY_IP_M0S8USBDSS))
#if defined(__cplusplus)
extern "C" {
#endif
/*******************************************************************************
* API Constants
*******************************************************************************/
/** \cond INTERNAL */
/* Supported HID version */
#define CY_USB_DEV_HID_VERSION_1_11 (0x0111U)
/* HID Class */
#define CY_USB_DEV_HID_CLASS (3U)
#define CY_USB_DEV_HID_SUBCLASS_NONE (0U)
#define CY_USB_DEV_HID_PROTOCOL_NONE (0U)
/* Descriptors */
#define CY_USB_DEV_HID_DESCRIPTOR (33U)
#define CY_USB_DEV_HID_DESCRIPTOR_LENGTH (9U)
#define CY_USB_DEV_HID_REPORT_DESCRIPTOR (34U)
/** \endcond */
#if defined(__cplusplus)
}
#endif
#endif /* (defined(CY_IP_MXUSBFS) || defined(CY_IP_M0S8USBDSS)) */
#endif /* (CY_USB_DEV_HID_DESCR_H) */
/* [] END OF FILE */
|
4a7e254a950eca95140752b694af9a17212712e1
|
39568e19301a7a112398be542154950af25591de
|
/sw/device/silicon_creator/lib/drivers/otbn.c
|
e169a0636fe759ac6836cc5bc8af5b64a8583e67
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
lowRISC/opentitan
|
493995bc7cf7cb3aee486a5203af3fd62bba3bfc
|
51f6017b8425b14d5a4aa9abace8fe5a25ef08c8
|
refs/heads/master
| 2023-08-31T22:05:09.425796
| 2023-08-14T14:52:15
| 2023-08-31T20:31:13
| 204,516,692
| 2,077
| 634
|
Apache-2.0
| 2023-09-14T21:16:21
| 2019-08-26T16:30:16
|
SystemVerilog
|
UTF-8
|
C
| false
| false
| 8,284
|
c
|
otbn.c
|
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include "sw/device/silicon_creator/lib/drivers/otbn.h"
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include "sw/device/lib/base/abs_mmio.h"
#include "sw/device/lib/base/bitfield.h"
#include "sw/device/silicon_creator/lib/base/sec_mmio.h"
#include "sw/device/silicon_creator/lib/drivers/rnd.h"
#include "sw/device/silicon_creator/lib/error.h"
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
#include "otbn_regs.h" // Generated.
enum {
/**
* Base address for OTBN.
*/
kBase = TOP_EARLGREY_OTBN_BASE_ADDR,
/**
* Highest index of OTBN error bits.
*/
kOtbnErrBitsLast = OTBN_ERR_BITS_FATAL_SOFTWARE_BIT,
};
/**
* Ensures that `offset_bytes` and `len` are valid for a given `mem_size`.
*/
OT_WARN_UNUSED_RESULT
static rom_error_t check_offset_len(uint32_t offset_bytes, size_t num_words,
size_t mem_size) {
if (num_words > UINT32_MAX / sizeof(uint32_t)) {
return kErrorOtbnBadOffsetLen;
}
uint32_t num_bytes = num_words * sizeof(uint32_t);
if (offset_bytes > UINT32_MAX - num_bytes) {
return kErrorOtbnBadOffsetLen;
}
uint32_t adjusted_offset_bytes = offset_bytes + num_bytes;
if (adjusted_offset_bytes > mem_size) {
return kErrorOtbnBadOffsetLen;
}
return kErrorOk;
}
rom_error_t otbn_busy_wait_for_done(void) {
uint32_t status = launder32(UINT32_MAX);
rom_error_t res = launder32(kErrorOk ^ status);
do {
status = abs_mmio_read32(kBase + OTBN_STATUS_REG_OFFSET);
} while (launder32(status) != kOtbnStatusIdle &&
launder32(status) != kOtbnStatusLocked);
res ^= ~status;
if (launder32(res) == kErrorOk) {
HARDENED_CHECK_EQ(res, kErrorOk);
HARDENED_CHECK_EQ(abs_mmio_read32(kBase + OTBN_STATUS_REG_OFFSET),
kOtbnStatusIdle);
return res;
}
return kErrorOtbnUnavailable;
}
/**
* Helper function for writing to OTBN's DMEM or IMEM.
*
* @param dest_addr Destination address.
* @param src Source buffer.
* @param num_words Number of words to copy.
*/
static void otbn_write(uint32_t dest_addr, const uint32_t *src,
size_t num_words) {
// Start from a random index less than `num_words`.
size_t i = ((uint64_t)rnd_uint32() * (uint64_t)num_words) >> 32;
enum { kStep = 1 };
size_t iter_cnt = 0, r_iter_cnt = num_words - 1;
for (; launder32(iter_cnt) < num_words && launder32(r_iter_cnt) < num_words;
++iter_cnt, --r_iter_cnt) {
abs_mmio_write32(dest_addr + i * sizeof(uint32_t), src[i]);
i += kStep;
if (launder32(i) >= num_words) {
i -= num_words;
}
HARDENED_CHECK_LT(i, num_words);
}
HARDENED_CHECK_EQ(iter_cnt, num_words);
HARDENED_CHECK_EQ((uint32_t)r_iter_cnt, UINT32_MAX);
}
OT_WARN_UNUSED_RESULT
static rom_error_t otbn_imem_write(size_t num_words, const uint32_t *src,
otbn_addr_t dest) {
HARDENED_RETURN_IF_ERROR(
check_offset_len(dest, num_words, OTBN_IMEM_SIZE_BYTES));
otbn_write(kBase + OTBN_IMEM_REG_OFFSET + dest, src, num_words);
return kErrorOk;
}
rom_error_t otbn_dmem_write(size_t num_words, const uint32_t *src,
otbn_addr_t dest) {
HARDENED_RETURN_IF_ERROR(
check_offset_len(dest, num_words, OTBN_DMEM_SIZE_BYTES));
otbn_write(kBase + OTBN_DMEM_REG_OFFSET + dest, src, num_words);
return kErrorOk;
}
rom_error_t otbn_dmem_read(size_t num_words, otbn_addr_t src, uint32_t *dest) {
HARDENED_RETURN_IF_ERROR(
check_offset_len(src, num_words, OTBN_DMEM_SIZE_BYTES));
size_t i = 0, r = num_words - 1;
for (; launder32(i) < num_words && launder32(r) < num_words; ++i, --r) {
dest[i] = abs_mmio_read32(kBase + OTBN_DMEM_REG_OFFSET + src +
i * sizeof(uint32_t));
}
HARDENED_CHECK_EQ(i, num_words);
HARDENED_CHECK_EQ((uint32_t)r, UINT32_MAX);
return kErrorOk;
}
/**
* Helper function for running an OTBN command.
*
* This function blocks until OTBN is idle.
*
* @param cmd OTBN command.
* @param error Error to return if operation fails.
* @return Result of the operation.
*/
OT_WARN_UNUSED_RESULT
static rom_error_t otbn_cmd_run(otbn_cmd_t cmd, rom_error_t error) {
enum {
kIntrStateDone = (1 << OTBN_INTR_COMMON_DONE_BIT),
// Use a bit index that doesn't overlap with error bits.
kResDoneBit = 31,
};
static_assert((UINT32_C(1) << kResDoneBit) > kOtbnErrBitsLast,
"kResDoneBit must not overlap with OTBN error bits");
abs_mmio_write32(kBase + OTBN_INTR_STATE_REG_OFFSET, kIntrStateDone);
abs_mmio_write32(kBase + OTBN_CMD_REG_OFFSET, cmd);
rom_error_t res = kErrorOk ^ (UINT32_C(1) << kResDoneBit);
uint32_t reg = 0;
do {
reg = abs_mmio_read32(kBase + OTBN_INTR_STATE_REG_OFFSET);
res ^= (uint32_t)bitfield_bit32_read(reg, OTBN_INTR_COMMON_DONE_BIT)
<< kResDoneBit;
} while (launder32(reg) != kIntrStateDone);
HARDENED_CHECK_EQ(reg, kIntrStateDone);
abs_mmio_write32(kBase + OTBN_INTR_STATE_REG_OFFSET, kIntrStateDone);
// Error bits register should be 0 (no errors).
uint32_t err_bits = abs_mmio_read32(kBase + OTBN_ERR_BITS_REG_OFFSET);
res ^= err_bits;
// Status should be kOtbnStatusIdle; OTBN can also issue a done interrupt
// when transitioning to the "locked" state, so it is important to check
// the status here.
uint32_t status = abs_mmio_read32(kBase + OTBN_STATUS_REG_OFFSET);
if (launder32(res) == kErrorOk && launder32(err_bits) == 0 &&
launder32(status) == kOtbnStatusIdle) {
HARDENED_CHECK_EQ(res, kErrorOk);
HARDENED_CHECK_EQ(err_bits, 0);
HARDENED_CHECK_EQ(abs_mmio_read32(kBase + OTBN_STATUS_REG_OFFSET),
kOtbnStatusIdle);
return res;
}
return error;
}
rom_error_t otbn_execute(void) {
// If OTBN is busy, wait for it to be done.
HARDENED_RETURN_IF_ERROR(otbn_busy_wait_for_done());
// Set software errors to fatal before running the program. Note: the CTRL
// register has only this one setting, so we have no need to read the
// previous value.
sec_mmio_write32(kBase + OTBN_CTRL_REG_OFFSET,
1 << OTBN_CTRL_SOFTWARE_ERRS_FATAL_BIT);
return otbn_cmd_run(kOtbnCmdExecute, kErrorOtbnExecutionFailed);
}
uint32_t otbn_instruction_count_get(void) {
return abs_mmio_read32(kBase + OTBN_INSN_CNT_REG_OFFSET);
}
rom_error_t otbn_imem_sec_wipe(void) {
return otbn_cmd_run(kOtbnCmdSecWipeImem, kErrorOtbnSecWipeImemFailed);
}
rom_error_t otbn_dmem_sec_wipe(void) {
return otbn_cmd_run(kOtbnCmdSecWipeDmem, kErrorOtbnSecWipeDmemFailed);
}
/**
* Checks if the OTBN application's IMEM and DMEM address parameters are valid.
*
* IMEM and DMEM ranges must not be "backwards" in memory, with the end address
* coming before the start address, and the IMEM range must additionally be
* non-empty.
*
* @param app the OTBN application to check
* @return OK if the addresses are valid, otherwise `kErrorOtbnInvalidArgument`.
*/
OT_WARN_UNUSED_RESULT
static rom_error_t check_app_address_ranges(const otbn_app_t app) {
if (app.imem_end > app.imem_start &&
app.dmem_data_end >= app.dmem_data_start) {
HARDENED_CHECK_GT(app.imem_end, app.imem_start);
HARDENED_CHECK_GE(app.dmem_data_end, app.dmem_data_start);
return kErrorOk;
}
return kErrorOtbnInvalidArgument;
}
rom_error_t otbn_load_app(const otbn_app_t app) {
HARDENED_RETURN_IF_ERROR(check_app_address_ranges(app));
// If OTBN is busy, wait for it to be done.
HARDENED_RETURN_IF_ERROR(otbn_busy_wait_for_done());
// Wipe memories.
HARDENED_RETURN_IF_ERROR(otbn_dmem_sec_wipe());
HARDENED_RETURN_IF_ERROR(otbn_imem_sec_wipe());
const size_t imem_num_words = (size_t)(app.imem_end - app.imem_start);
const size_t data_num_words =
(size_t)(app.dmem_data_end - app.dmem_data_start);
// IMEM always starts at 0.
otbn_addr_t imem_start_addr = 0;
HARDENED_RETURN_IF_ERROR(
otbn_imem_write(imem_num_words, app.imem_start, imem_start_addr));
if (data_num_words > 0) {
HARDENED_RETURN_IF_ERROR(otbn_dmem_write(
data_num_words, app.dmem_data_start, app.dmem_data_start_addr));
}
return kErrorOk;
}
|
83cd50a55c5528e887cba4cbabaaf4a3857ec38f
|
f7dc806f341ef5dbb0e11252a4693003a66853d5
|
/thirdparty/libtheora/rate.c
|
bf2b1396a17ea3c7d7ac87e8b78771f7874a4a8a
|
[
"LicenseRef-scancode-on2-patent",
"BSD-3-Clause",
"MIT",
"OFL-1.1",
"JSON",
"LicenseRef-scancode-nvidia-2002",
"Zlib",
"MPL-2.0",
"CC0-1.0",
"BSL-1.0",
"Libpng",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"Unlicense",
"LicenseRef-scancode-free-unknown",
"CC-BY-4.0",
"Bison-exception-2.2",
"LicenseRef-scancode-other-permissive",
"GPL-3.0-only",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-unicode",
"BSD-2-Clause",
"FTL",
"GPL-3.0-or-later",
"Bitstream-Vera",
"MIT-Modern-Variant"
] |
permissive
|
godotengine/godot
|
8a2419750f4851d1426a8f3bcb52cac5c86f23c2
|
970be7afdc111ccc7459d7ef3560de70e6d08c80
|
refs/heads/master
| 2023-08-21T14:37:00.262883
| 2023-08-21T06:26:15
| 2023-08-21T06:26:15
| 15,634,981
| 68,852
| 18,388
|
MIT
| 2023-09-14T21:42:16
| 2014-01-04T16:05:36
|
C++
|
UTF-8
|
C
| false
| false
| 46,459
|
c
|
rate.c
|
/********************************************************************
* *
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function:
last mod: $Id$
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include "encint.h"
/*A rough lookup table for tan(x), 0<=x<pi/2.
The values are Q12 fixed-point and spaced at 5 degree intervals.
These decisions are somewhat arbitrary, but sufficient for the 2nd order
Bessel follower below.
Values of x larger than 85 degrees are extrapolated from the last inteval,
which is way off, but "good enough".*/
static unsigned short OC_ROUGH_TAN_LOOKUP[18]={
0, 358, 722, 1098, 1491, 1910,
2365, 2868, 3437, 4096, 4881, 5850,
7094, 8784,11254,15286,23230,46817
};
/*_alpha is Q24 in the range [0,0.5).
The return values is 5.12.*/
static int oc_warp_alpha(int _alpha){
int i;
int d;
int t0;
int t1;
i=_alpha*36>>24;
if(i>=17)i=16;
t0=OC_ROUGH_TAN_LOOKUP[i];
t1=OC_ROUGH_TAN_LOOKUP[i+1];
d=_alpha*36-(i<<24);
return (int)(((ogg_int64_t)t0<<32)+(t1-t0<<8)*(ogg_int64_t)d>>32);
}
/*Re-initialize the Bessel filter coefficients with the specified delay.
This does not alter the x/y state, but changes the reaction time of the
filter.
Altering the time constant of a reactive filter without alterning internal
state is something that has to be done carefuly, but our design operates at
high enough delays and with small enough time constant changes to make it
safe.*/
static void oc_iir_filter_reinit(oc_iir_filter *_f,int _delay){
int alpha;
ogg_int64_t one48;
ogg_int64_t warp;
ogg_int64_t k1;
ogg_int64_t k2;
ogg_int64_t d;
ogg_int64_t a;
ogg_int64_t ik2;
ogg_int64_t b1;
ogg_int64_t b2;
/*This borrows some code from an unreleased version of Postfish.
See the recipe at http://unicorn.us.com/alex/2polefilters.html for details
on deriving the filter coefficients.*/
/*alpha is Q24*/
alpha=(1<<24)/_delay;
one48=(ogg_int64_t)1<<48;
/*warp is 7.12*/
warp=OC_MAXI(oc_warp_alpha(alpha),1);
/*k1 is 9.12*/
k1=3*warp;
/*k2 is 16.24.*/
k2=k1*warp;
/*d is 16.15.*/
d=((1<<12)+k1<<12)+k2+256>>9;
/*a is 0.32, since d is larger than both 1.0 and k2.*/
a=(k2<<23)/d;
/*ik2 is 25.24.*/
ik2=one48/k2;
/*b1 is Q56; in practice, the integer ranges between -2 and 2.*/
b1=2*a*(ik2-(1<<24));
/*b2 is Q56; in practice, the integer ranges between -2 and 2.*/
b2=(one48<<8)-(4*a<<24)-b1;
/*All of the filter parameters are Q24.*/
_f->c[0]=(ogg_int32_t)(b1+((ogg_int64_t)1<<31)>>32);
_f->c[1]=(ogg_int32_t)(b2+((ogg_int64_t)1<<31)>>32);
_f->g=(ogg_int32_t)(a+128>>8);
}
/*Initialize a 2nd order low-pass Bessel filter with the corresponding delay
and initial value.
_value is Q24.*/
static void oc_iir_filter_init(oc_iir_filter *_f,int _delay,ogg_int32_t _value){
oc_iir_filter_reinit(_f,_delay);
_f->y[1]=_f->y[0]=_f->x[1]=_f->x[0]=_value;
}
static ogg_int64_t oc_iir_filter_update(oc_iir_filter *_f,ogg_int32_t _x){
ogg_int64_t c0;
ogg_int64_t c1;
ogg_int64_t g;
ogg_int64_t x0;
ogg_int64_t x1;
ogg_int64_t y0;
ogg_int64_t y1;
ogg_int64_t ya;
c0=_f->c[0];
c1=_f->c[1];
g=_f->g;
x0=_f->x[0];
x1=_f->x[1];
y0=_f->y[0];
y1=_f->y[1];
ya=(_x+x0*2+x1)*g+y0*c0+y1*c1+(1<<23)>>24;
_f->x[1]=(ogg_int32_t)x0;
_f->x[0]=_x;
_f->y[1]=(ogg_int32_t)y0;
_f->y[0]=(ogg_int32_t)ya;
return ya;
}
/*Search for the quantizer that matches the target most closely.
We don't assume a linear ordering, but when there are ties we pick the
quantizer closest to the old one.*/
static int oc_enc_find_qi_for_target(oc_enc_ctx *_enc,int _qti,int _qi_old,
int _qi_min,ogg_int64_t _log_qtarget){
ogg_int64_t best_qdiff;
int best_qi;
int qi;
best_qi=_qi_min;
best_qdiff=_enc->log_qavg[_qti][best_qi]-_log_qtarget;
best_qdiff=best_qdiff+OC_SIGNMASK(best_qdiff)^OC_SIGNMASK(best_qdiff);
for(qi=_qi_min+1;qi<64;qi++){
ogg_int64_t qdiff;
qdiff=_enc->log_qavg[_qti][qi]-_log_qtarget;
qdiff=qdiff+OC_SIGNMASK(qdiff)^OC_SIGNMASK(qdiff);
if(qdiff<best_qdiff||
qdiff==best_qdiff&&abs(qi-_qi_old)<abs(best_qi-_qi_old)){
best_qi=qi;
best_qdiff=qdiff;
}
}
return best_qi;
}
void oc_enc_calc_lambda(oc_enc_ctx *_enc,int _qti){
ogg_int64_t lq;
int qi;
int qi1;
int nqis;
/*For now, lambda is fixed depending on the qi value and frame type:
lambda=qscale*(qavg[qti][qi]**2),
where qscale=0.2125.
This was derived by exhaustively searching for the optimal quantizer for
the AC coefficients in each block from a number of test sequences for a
number of fixed lambda values and fitting the peaks of the resulting
histograms (on the log(qavg) scale).
The same model applies to both inter and intra frames.
A more adaptive scheme might perform better.*/
qi=_enc->state.qis[0];
/*If rate control is active, use the lambda for the _target_ quantizer.
This allows us to scale to rates slightly lower than we'd normally be able
to reach, and give the rate control a semblance of "fractional qi"
precision.
TODO: Add API for changing QI, and allow extra precision.*/
if(_enc->state.info.target_bitrate>0)lq=_enc->rc.log_qtarget;
else lq=_enc->log_qavg[_qti][qi];
/*The resulting lambda value is less than 0x500000.*/
_enc->lambda=(int)oc_bexp64(2*lq-0x4780BD468D6B62BLL);
/*Select additional quantizers.
The R-D optimal block AC quantizer statistics suggest that the distribution
is roughly Gaussian-like with a slight positive skew.
K-means clustering on log_qavg to select 3 quantizers produces cluster
centers of {log_qavg-0.6,log_qavg,log_qavg+0.7}.
Experiments confirm these are relatively good choices.
Although we do greedy R-D optimization of the qii flags to avoid switching
too frequently, this becomes ineffective at low rates, either because we
do a poor job of predicting the actual R-D cost, or the greedy
optimization is not sufficient.
Therefore adaptive quantization is disabled above an (experimentally
suggested) threshold of log_qavg=7.00 (e.g., below INTRA qi=12 or
INTER qi=20 with current matrices).
This may need to be revised if the R-D cost estimation or qii flag
optimization strategies change.*/
nqis=1;
if(lq<(OC_Q57(56)>>3)&&!_enc->vp3_compatible&&
_enc->sp_level<OC_SP_LEVEL_FAST_ANALYSIS){
qi1=oc_enc_find_qi_for_target(_enc,_qti,OC_MAXI(qi-1,0),0,
lq+(OC_Q57(7)+5)/10);
if(qi1!=qi)_enc->state.qis[nqis++]=qi1;
qi1=oc_enc_find_qi_for_target(_enc,_qti,OC_MINI(qi+1,63),0,
lq-(OC_Q57(6)+5)/10);
if(qi1!=qi&&qi1!=_enc->state.qis[nqis-1])_enc->state.qis[nqis++]=qi1;
}
_enc->state.nqis=nqis;
}
/*Binary exponential of _log_scale with 24-bit fractional precision and
saturation.
_log_scale: A binary logarithm in Q24 format.
Return: The binary exponential in Q24 format, saturated to 2**47-1 if
_log_scale was too large.*/
static ogg_int64_t oc_bexp_q24(ogg_int32_t _log_scale){
if(_log_scale<(ogg_int32_t)23<<24){
ogg_int64_t ret;
ret=oc_bexp64(((ogg_int64_t)_log_scale<<33)+OC_Q57(24));
return ret<0x7FFFFFFFFFFFLL?ret:0x7FFFFFFFFFFFLL;
}
return 0x7FFFFFFFFFFFLL;
}
/*Convenience function converts Q57 value to a clamped 32-bit Q24 value
_in: input in Q57 format.
Return: same number in Q24 */
static ogg_int32_t oc_q57_to_q24(ogg_int64_t _in){
ogg_int64_t ret;
ret=_in+((ogg_int64_t)1<<32)>>33;
/*0x80000000 is automatically converted to unsigned on 32-bit systems.
-0x7FFFFFFF-1 is needed to avoid "promoting" the whole expression to
unsigned.*/
return (ogg_int32_t)OC_CLAMPI(-0x7FFFFFFF-1,ret,0x7FFFFFFF);
}
/*Binary exponential of _log_scale with 24-bit fractional precision and
saturation.
_log_scale: A binary logarithm in Q57 format.
Return: The binary exponential in Q24 format, saturated to 2**31-1 if
_log_scale was too large.*/
static ogg_int32_t oc_bexp64_q24(ogg_int64_t _log_scale){
if(_log_scale<OC_Q57(8)){
ogg_int64_t ret;
ret=oc_bexp64(_log_scale+OC_Q57(24));
return ret<0x7FFFFFFF?(ogg_int32_t)ret:0x7FFFFFFF;
}
return 0x7FFFFFFF;
}
static void oc_enc_rc_reset(oc_enc_ctx *_enc){
ogg_int64_t npixels;
ogg_int64_t ibpp;
int inter_delay;
/*TODO: These parameters should be exposed in a th_encode_ctl() API.*/
_enc->rc.bits_per_frame=(_enc->state.info.target_bitrate*
(ogg_int64_t)_enc->state.info.fps_denominator)/
_enc->state.info.fps_numerator;
/*Insane framerates or frame sizes mean insane bitrates.
Let's not get carried away.*/
if(_enc->rc.bits_per_frame>0x400000000000LL){
_enc->rc.bits_per_frame=(ogg_int64_t)0x400000000000LL;
}
else if(_enc->rc.bits_per_frame<32)_enc->rc.bits_per_frame=32;
_enc->rc.buf_delay=OC_MAXI(_enc->rc.buf_delay,12);
_enc->rc.max=_enc->rc.bits_per_frame*_enc->rc.buf_delay;
/*Start with a buffer fullness of 50% plus 25% of the amount we plan to spend
on a single keyframe interval.
We can require fully half the bits in an interval for a keyframe, so this
initial level gives us maximum flexibility for over/under-shooting in
subsequent frames.*/
_enc->rc.target=(_enc->rc.max+1>>1)+(_enc->rc.bits_per_frame+2>>2)*
OC_MINI(_enc->keyframe_frequency_force,_enc->rc.buf_delay);
_enc->rc.fullness=_enc->rc.target;
/*Pick exponents and initial scales for quantizer selection.*/
npixels=_enc->state.info.frame_width*
(ogg_int64_t)_enc->state.info.frame_height;
_enc->rc.log_npixels=oc_blog64(npixels);
ibpp=npixels/_enc->rc.bits_per_frame;
if(ibpp<1){
_enc->rc.exp[0]=59;
_enc->rc.log_scale[0]=oc_blog64(1997)-OC_Q57(8);
}
else if(ibpp<2){
_enc->rc.exp[0]=55;
_enc->rc.log_scale[0]=oc_blog64(1604)-OC_Q57(8);
}
else{
_enc->rc.exp[0]=48;
_enc->rc.log_scale[0]=oc_blog64(834)-OC_Q57(8);
}
if(ibpp<4){
_enc->rc.exp[1]=100;
_enc->rc.log_scale[1]=oc_blog64(2249)-OC_Q57(8);
}
else if(ibpp<8){
_enc->rc.exp[1]=95;
_enc->rc.log_scale[1]=oc_blog64(1751)-OC_Q57(8);
}
else{
_enc->rc.exp[1]=73;
_enc->rc.log_scale[1]=oc_blog64(1260)-OC_Q57(8);
}
_enc->rc.prev_drop_count=0;
_enc->rc.log_drop_scale=OC_Q57(0);
/*Set up second order followers, initialized according to corresponding
time constants.*/
oc_iir_filter_init(&_enc->rc.scalefilter[0],4,
oc_q57_to_q24(_enc->rc.log_scale[0]));
inter_delay=(_enc->rc.twopass?
OC_MAXI(_enc->keyframe_frequency_force,12):_enc->rc.buf_delay)>>1;
_enc->rc.inter_count=0;
/*We clamp the actual inter_delay to a minimum of 10 to work within the range
of values where later incrementing the delay works as designed.
10 is not an exact choice, but rather a good working trade-off.*/
_enc->rc.inter_delay=10;
_enc->rc.inter_delay_target=inter_delay;
oc_iir_filter_init(&_enc->rc.scalefilter[1],_enc->rc.inter_delay,
oc_q57_to_q24(_enc->rc.log_scale[1]));
oc_iir_filter_init(&_enc->rc.vfrfilter,4,
oc_bexp64_q24(_enc->rc.log_drop_scale));
}
void oc_rc_state_init(oc_rc_state *_rc,oc_enc_ctx *_enc){
_rc->twopass=0;
_rc->twopass_buffer_bytes=0;
_rc->twopass_force_kf=0;
_rc->frame_metrics=NULL;
_rc->rate_bias=0;
if(_enc->state.info.target_bitrate>0){
/*The buffer size is set equal to the keyframe interval, clamped to the
range [12,256] frames.
The 12 frame minimum gives us some chance to distribute bit estimation
errors.
The 256 frame maximum means we'll require 8-10 seconds of pre-buffering
at 24-30 fps, which is not unreasonable.*/
_rc->buf_delay=_enc->keyframe_frequency_force>256?
256:_enc->keyframe_frequency_force;
/*By default, enforce all buffer constraints.*/
_rc->drop_frames=1;
_rc->cap_overflow=1;
_rc->cap_underflow=0;
oc_enc_rc_reset(_enc);
}
}
void oc_rc_state_clear(oc_rc_state *_rc){
_ogg_free(_rc->frame_metrics);
}
void oc_enc_rc_resize(oc_enc_ctx *_enc){
/*If encoding has not yet begun, reset the buffer state.*/
if(_enc->state.curframe_num<0)oc_enc_rc_reset(_enc);
else{
int idt;
/*Otherwise, update the bounds on the buffer, but not the current
fullness.*/
_enc->rc.bits_per_frame=(_enc->state.info.target_bitrate*
(ogg_int64_t)_enc->state.info.fps_denominator)/
_enc->state.info.fps_numerator;
/*Insane framerates or frame sizes mean insane bitrates.
Let's not get carried away.*/
if(_enc->rc.bits_per_frame>0x400000000000LL){
_enc->rc.bits_per_frame=(ogg_int64_t)0x400000000000LL;
}
else if(_enc->rc.bits_per_frame<32)_enc->rc.bits_per_frame=32;
_enc->rc.buf_delay=OC_MAXI(_enc->rc.buf_delay,12);
_enc->rc.max=_enc->rc.bits_per_frame*_enc->rc.buf_delay;
_enc->rc.target=(_enc->rc.max+1>>1)+(_enc->rc.bits_per_frame+2>>2)*
OC_MINI(_enc->keyframe_frequency_force,_enc->rc.buf_delay);
/*Update the INTER-frame scale filter delay.
We jump to it immediately if we've already seen enough frames; otherwise
it is simply set as the new target.*/
_enc->rc.inter_delay_target=idt=OC_MAXI(_enc->rc.buf_delay>>1,10);
if(idt<OC_MINI(_enc->rc.inter_delay,_enc->rc.inter_count)){
oc_iir_filter_init(&_enc->rc.scalefilter[1],idt,
_enc->rc.scalefilter[1].y[0]);
_enc->rc.inter_delay=idt;
}
}
/*If we're in pass-2 mode, make sure the frame metrics array is big enough
to hold frame statistics for the full buffer.*/
if(_enc->rc.twopass==2){
int cfm;
int buf_delay;
int reset_window;
buf_delay=_enc->rc.buf_delay;
reset_window=_enc->rc.frame_metrics==NULL&&(_enc->rc.frames_total[0]==0||
buf_delay<_enc->rc.frames_total[0]+_enc->rc.frames_total[1]
+_enc->rc.frames_total[2]);
cfm=_enc->rc.cframe_metrics;
/*Only try to resize the frame metrics buffer if a) it's too small and
b) we were using a finite buffer, or are about to start.*/
if(cfm<buf_delay&&(_enc->rc.frame_metrics!=NULL||reset_window)){
oc_frame_metrics *fm;
int nfm;
int fmh;
fm=(oc_frame_metrics *)_ogg_realloc(_enc->rc.frame_metrics,
buf_delay*sizeof(*_enc->rc.frame_metrics));
if(fm==NULL){
/*We failed to allocate a finite buffer.*/
/*If we don't have a valid 2-pass header yet, just return; we'll reset
the buffer size when we read the header.*/
if(_enc->rc.frames_total[0]==0)return;
/*Otherwise revert to the largest finite buffer previously set, or to
whole-file buffering if we were still using that.*/
_enc->rc.buf_delay=_enc->rc.frame_metrics!=NULL?
cfm:_enc->rc.frames_total[0]+_enc->rc.frames_total[1]
+_enc->rc.frames_total[2];
oc_enc_rc_resize(_enc);
return;
}
_enc->rc.frame_metrics=fm;
_enc->rc.cframe_metrics=buf_delay;
/*Re-organize the circular buffer.*/
fmh=_enc->rc.frame_metrics_head;
nfm=_enc->rc.nframe_metrics;
if(fmh+nfm>cfm){
int shift;
shift=OC_MINI(fmh+nfm-cfm,buf_delay-cfm);
memcpy(fm+cfm,fm,OC_MINI(fmh+nfm-cfm,buf_delay-cfm)*sizeof(*fm));
if(fmh+nfm>buf_delay)memmove(fm,fm+shift,fmh+nfm-buf_delay);
}
}
/*We were using whole-file buffering; now we're not.*/
if(reset_window){
_enc->rc.nframes[0]=_enc->rc.nframes[1]=_enc->rc.nframes[2]=0;
_enc->rc.scale_sum[0]=_enc->rc.scale_sum[1]=0;
_enc->rc.scale_window_end=_enc->rc.scale_window0=
_enc->state.curframe_num+_enc->prev_dup_count+1;
if(_enc->rc.twopass_buffer_bytes){
int qti;
/*We already read the metrics for the first frame in the window.*/
*(_enc->rc.frame_metrics)=*&_enc->rc.cur_metrics;
_enc->rc.nframe_metrics++;
qti=_enc->rc.cur_metrics.frame_type;
_enc->rc.nframes[qti]++;
_enc->rc.nframes[2]+=_enc->rc.cur_metrics.dup_count;
_enc->rc.scale_sum[qti]+=oc_bexp_q24(_enc->rc.cur_metrics.log_scale);
_enc->rc.scale_window_end+=_enc->rc.cur_metrics.dup_count+1;
if(_enc->rc.scale_window_end-_enc->rc.scale_window0<buf_delay){
/*We need more frame data.*/
_enc->rc.twopass_buffer_bytes=0;
}
}
}
/*Otherwise, we could shrink the size of the current window, if necessary,
but leaving it like it is lets us adapt to the new buffer size more
gracefully.*/
}
}
/*Scale the number of frames by the number of expected drops/duplicates.*/
static int oc_rc_scale_drop(oc_rc_state *_rc,int _nframes){
if(_rc->prev_drop_count>0||_rc->log_drop_scale>OC_Q57(0)){
ogg_int64_t dup_scale;
dup_scale=oc_bexp64((_rc->log_drop_scale
+oc_blog64(_rc->prev_drop_count+1)>>1)+OC_Q57(8));
if(dup_scale<_nframes<<8){
int dup_scalei;
dup_scalei=(int)dup_scale;
if(dup_scalei>0)_nframes=((_nframes<<8)+dup_scalei-1)/dup_scalei;
}
else _nframes=!!_nframes;
}
return _nframes;
}
int oc_enc_select_qi(oc_enc_ctx *_enc,int _qti,int _clamp){
ogg_int64_t rate_total;
ogg_int64_t rate_bias;
int nframes[2];
int buf_delay;
int buf_pad;
ogg_int64_t log_qtarget;
ogg_int64_t log_scale0;
ogg_int64_t log_cur_scale;
ogg_int64_t log_qexp;
int exp0;
int old_qi;
int qi;
/*Figure out how to re-distribute bits so that we hit our fullness target
before the last keyframe in our current buffer window (after the current
frame), or the end of the buffer window, whichever comes first.*/
log_cur_scale=(ogg_int64_t)_enc->rc.scalefilter[_qti].y[0]<<33;
buf_pad=0;
switch(_enc->rc.twopass){
default:{
ogg_uint32_t next_key_frame;
/*Single pass mode: assume only forced keyframes and attempt to estimate
the drop count for VFR content.*/
next_key_frame=_qti?_enc->keyframe_frequency_force
-(_enc->state.curframe_num-_enc->state.keyframe_num):0;
nframes[0]=(_enc->rc.buf_delay-OC_MINI(next_key_frame,_enc->rc.buf_delay)
+_enc->keyframe_frequency_force-1)/_enc->keyframe_frequency_force;
if(nframes[0]+_qti>1){
nframes[0]--;
buf_delay=next_key_frame+nframes[0]*_enc->keyframe_frequency_force;
}
else buf_delay=_enc->rc.buf_delay;
nframes[1]=buf_delay-nframes[0];
/*Downgrade the delta frame rate to correspond to the recent drop count
history.*/
nframes[1]=oc_rc_scale_drop(&_enc->rc,nframes[1]);
}break;
case 1:{
/*Pass 1 mode: use a fixed qi value.*/
qi=_enc->state.qis[0];
_enc->rc.log_qtarget=_enc->log_qavg[_qti][qi];
return qi;
}break;
case 2:{
ogg_int64_t scale_sum[2];
int qti;
/*Pass 2 mode: we know exactly how much of each frame type there is in
the current buffer window, and have estimates for the scales.*/
nframes[0]=_enc->rc.nframes[0];
nframes[1]=_enc->rc.nframes[1];
scale_sum[0]=_enc->rc.scale_sum[0];
scale_sum[1]=_enc->rc.scale_sum[1];
/*The window size can be slightly larger than the buffer window for VFR
content; clamp it down, if appropriate (the excess will all be dup
frames).*/
buf_delay=OC_MINI(_enc->rc.scale_window_end-_enc->rc.scale_window0,
_enc->rc.buf_delay);
/*If we're approaching the end of the file, add some slack to keep us
from slamming into a rail.
Our rate accuracy goes down, but it keeps the result sensible.
We position the target where the first forced keyframe beyond the end
of the file would be (for consistency with 1-pass mode).*/
buf_pad=OC_MINI(_enc->rc.buf_delay,_enc->state.keyframe_num
+_enc->keyframe_frequency_force-_enc->rc.scale_window0);
if(buf_delay<buf_pad)buf_pad-=buf_delay;
else{
/*Otherwise, search for the last keyframe in the buffer window and
target that.*/
buf_pad=0;
/*TODO: Currently we only do this when using a finite buffer; we could
save the position of the last keyframe in the summary data and do it
with a whole-file buffer as well, but it isn't likely to make a
difference.*/
if(_enc->rc.frame_metrics!=NULL){
int fmi;
int fm_tail;
fm_tail=_enc->rc.frame_metrics_head+_enc->rc.nframe_metrics;
if(fm_tail>=_enc->rc.cframe_metrics)fm_tail-=_enc->rc.cframe_metrics;
for(fmi=fm_tail;;){
oc_frame_metrics *m;
fmi--;
if(fmi<0)fmi+=_enc->rc.cframe_metrics;
/*Stop before we remove the first frame.*/
if(fmi==_enc->rc.frame_metrics_head)break;
m=_enc->rc.frame_metrics+fmi;
/*If we find a keyframe, remove it and everything past it.*/
if(m->frame_type==OC_INTRA_FRAME){
do{
qti=m->frame_type;
nframes[qti]--;
scale_sum[qti]-=oc_bexp_q24(m->log_scale);
buf_delay-=m->dup_count+1;
fmi++;
if(fmi>=_enc->rc.cframe_metrics)fmi=0;
m=_enc->rc.frame_metrics+fmi;
}
while(fmi!=fm_tail);
/*And stop scanning backwards.*/
break;
}
}
}
}
/*If we're not using the same frame type as in pass 1 (because someone
changed the keyframe interval), remove that scale estimate.
We'll add in a replacement for the correct frame type below.*/
qti=_enc->rc.cur_metrics.frame_type;
if(qti!=_qti){
nframes[qti]--;
scale_sum[qti]-=oc_bexp_q24(_enc->rc.cur_metrics.log_scale);
}
/*Compute log_scale estimates for each frame type from the pass-1 scales
we measured in the current window.*/
for(qti=0;qti<2;qti++){
_enc->rc.log_scale[qti]=nframes[qti]>0?
oc_blog64(scale_sum[qti])-oc_blog64(nframes[qti])-OC_Q57(24):
-_enc->rc.log_npixels;
}
/*If we're not using the same frame type as in pass 1, add a scale
estimate for the corresponding frame using the current low-pass
filter value.
This is mostly to ensure we have a valid estimate even when pass 1 had
no frames of this type in the buffer window.
TODO: We could also plan ahead and figure out how many keyframes we'll
be forced to add in the current buffer window.*/
qti=_enc->rc.cur_metrics.frame_type;
if(qti!=_qti){
ogg_int64_t scale;
scale=_enc->rc.log_scale[_qti]<OC_Q57(23)?
oc_bexp64(_enc->rc.log_scale[_qti]+OC_Q57(24)):0x7FFFFFFFFFFFLL;
scale*=nframes[_qti];
nframes[_qti]++;
scale+=oc_bexp_q24(log_cur_scale>>33);
_enc->rc.log_scale[_qti]=oc_blog64(scale)
-oc_blog64(nframes[qti])-OC_Q57(24);
}
else log_cur_scale=(ogg_int64_t)_enc->rc.cur_metrics.log_scale<<33;
/*Add the padding from above.
This basically reverts to 1-pass estimations in the last keyframe
interval.*/
if(buf_pad>0){
ogg_int64_t scale;
int nextra_frames;
/*Extend the buffer.*/
buf_delay+=buf_pad;
/*Add virtual delta frames according to the estimated drop count.*/
nextra_frames=oc_rc_scale_drop(&_enc->rc,buf_pad);
/*And blend in the low-pass filtered scale according to how many frames
we added.*/
scale=
oc_bexp64(_enc->rc.log_scale[1]+OC_Q57(24))*(ogg_int64_t)nframes[1]
+oc_bexp_q24(_enc->rc.scalefilter[1].y[0])*(ogg_int64_t)nextra_frames;
nframes[1]+=nextra_frames;
_enc->rc.log_scale[1]=oc_blog64(scale)-oc_blog64(nframes[1])-OC_Q57(24);
}
}break;
}
/*If we've been missing our target, add a penalty term.*/
rate_bias=(_enc->rc.rate_bias/(_enc->state.curframe_num+1000))*
(buf_delay-buf_pad);
/*rate_total is the total bits available over the next buf_delay frames.*/
rate_total=_enc->rc.fullness-_enc->rc.target+rate_bias
+buf_delay*_enc->rc.bits_per_frame;
log_scale0=_enc->rc.log_scale[_qti]+_enc->rc.log_npixels;
/*If there aren't enough bits to achieve our desired fullness level, use the
minimum quality permitted.*/
if(rate_total<=buf_delay)log_qtarget=OC_QUANT_MAX_LOG;
else{
static const ogg_int64_t LOG_KEY_RATIO=0x0137222BB70747BALL;
ogg_int64_t log_scale1;
ogg_int64_t rlo;
ogg_int64_t rhi;
log_scale1=_enc->rc.log_scale[1-_qti]+_enc->rc.log_npixels;
rlo=0;
rhi=(rate_total+nframes[_qti]-1)/nframes[_qti];
while(rlo<rhi){
ogg_int64_t curr;
ogg_int64_t rdiff;
ogg_int64_t log_rpow;
ogg_int64_t rscale;
curr=rlo+rhi>>1;
log_rpow=oc_blog64(curr)-log_scale0;
log_rpow=(log_rpow+(_enc->rc.exp[_qti]>>1))/_enc->rc.exp[_qti];
if(_qti)log_rpow+=LOG_KEY_RATIO>>6;
else log_rpow-=LOG_KEY_RATIO>>6;
log_rpow*=_enc->rc.exp[1-_qti];
rscale=nframes[1-_qti]*oc_bexp64(log_scale1+log_rpow);
rdiff=nframes[_qti]*curr+rscale-rate_total;
if(rdiff<0)rlo=curr+1;
else if(rdiff>0)rhi=curr-1;
else break;
}
log_qtarget=OC_Q57(2)-((oc_blog64(rlo)-log_scale0+(_enc->rc.exp[_qti]>>1))/
_enc->rc.exp[_qti]<<6);
log_qtarget=OC_MINI(log_qtarget,OC_QUANT_MAX_LOG);
}
/*The above allocation looks only at the total rate we'll accumulate in the
next buf_delay frames.
However, we could overflow the buffer on the very next frame, so check for
that here, if we're not using a soft target.*/
exp0=_enc->rc.exp[_qti];
if(_enc->rc.cap_overflow){
ogg_int64_t margin;
ogg_int64_t soft_limit;
ogg_int64_t log_soft_limit;
/*Allow 3% of the buffer for prediction error.
This should be plenty, and we don't mind if we go a bit over; we only
want to keep these bits from being completely wasted.*/
margin=_enc->rc.max+31>>5;
/*We want to use at least this many bits next frame.*/
soft_limit=_enc->rc.fullness+_enc->rc.bits_per_frame-(_enc->rc.max-margin);
log_soft_limit=oc_blog64(soft_limit);
/*If we're predicting we won't use that many...*/
log_qexp=(log_qtarget-OC_Q57(2)>>6)*exp0;
if(log_scale0-log_qexp<log_soft_limit){
/*Scale the adjustment based on how far into the margin we are.*/
log_qexp+=(log_scale0-log_soft_limit-log_qexp>>32)*
((OC_MINI(margin,soft_limit)<<32)/margin);
log_qtarget=((log_qexp+(exp0>>1))/exp0<<6)+OC_Q57(2);
}
}
/*If this was not one of the initial frames, limit the change in quality.*/
old_qi=_enc->state.qis[0];
if(_clamp){
ogg_int64_t log_qmin;
ogg_int64_t log_qmax;
/*Clamp the target quantizer to within [0.8*Q,1.2*Q], where Q is the
current quantizer.
TODO: With user-specified quant matrices, we need to enlarge these limits
if they don't actually let us change qi values.*/
log_qmin=_enc->log_qavg[_qti][old_qi]-0x00A4D3C25E68DC58LL;
log_qmax=_enc->log_qavg[_qti][old_qi]+0x00A4D3C25E68DC58LL;
log_qtarget=OC_CLAMPI(log_qmin,log_qtarget,log_qmax);
}
/*The above allocation looks only at the total rate we'll accumulate in the
next buf_delay frames.
However, we could bust the budget on the very next frame, so check for that
here, if we're not using a soft target.*/
/* Disabled when our minimum qi > 0; if we saturate log_qtarget to
to the maximum possible size when we have a minimum qi, the
resulting lambda will interact very strangely with SKIP. The
resulting artifacts look like waterfalls. */
if(_enc->state.info.quality==0){
ogg_int64_t log_hard_limit;
/*Compute the maximum number of bits we can use in the next frame.
Allow 50% of the rate for a single frame for prediction error.
This may not be enough for keyframes or sudden changes in complexity.*/
log_hard_limit=oc_blog64(_enc->rc.fullness+(_enc->rc.bits_per_frame>>1));
/*If we're predicting we'll use more than this...*/
log_qexp=(log_qtarget-OC_Q57(2)>>6)*exp0;
if(log_scale0-log_qexp>log_hard_limit){
/*Force the target to hit our limit exactly.*/
log_qexp=log_scale0-log_hard_limit;
log_qtarget=((log_qexp+(exp0>>1))/exp0<<6)+OC_Q57(2);
/*If that target is unreasonable, oh well; we'll have to drop.*/
log_qtarget=OC_MINI(log_qtarget,OC_QUANT_MAX_LOG);
}
}
/*Compute a final estimate of the number of bits we plan to use.*/
log_qexp=(log_qtarget-OC_Q57(2)>>6)*_enc->rc.exp[_qti];
_enc->rc.rate_bias+=oc_bexp64(log_cur_scale+_enc->rc.log_npixels-log_qexp);
qi=oc_enc_find_qi_for_target(_enc,_qti,old_qi,
_enc->state.info.quality,log_qtarget);
/*Save the quantizer target for lambda calculations.*/
_enc->rc.log_qtarget=log_qtarget;
return qi;
}
int oc_enc_update_rc_state(oc_enc_ctx *_enc,
long _bits,int _qti,int _qi,int _trial,int _droppable){
ogg_int64_t buf_delta;
ogg_int64_t log_scale;
int dropped;
dropped=0;
/* Drop frames also disabled for now in the case of infinite-buffer
two-pass mode */
if(!_enc->rc.drop_frames||_enc->rc.twopass&&_enc->rc.frame_metrics==NULL){
_droppable=0;
}
buf_delta=_enc->rc.bits_per_frame*(1+_enc->dup_count);
if(_bits<=0){
/*We didn't code any blocks in this frame.*/
log_scale=OC_Q57(-64);
_bits=0;
}
else{
ogg_int64_t log_bits;
ogg_int64_t log_qexp;
/*Compute the estimated scale factor for this frame type.*/
log_bits=oc_blog64(_bits);
log_qexp=_enc->rc.log_qtarget-OC_Q57(2);
log_qexp=(log_qexp>>6)*(_enc->rc.exp[_qti]);
log_scale=OC_MINI(log_bits-_enc->rc.log_npixels+log_qexp,OC_Q57(16));
}
/*Special two-pass processing.*/
switch(_enc->rc.twopass){
case 1:{
/*Pass 1 mode: save the metrics for this frame.*/
_enc->rc.cur_metrics.log_scale=oc_q57_to_q24(log_scale);
_enc->rc.cur_metrics.dup_count=_enc->dup_count;
_enc->rc.cur_metrics.frame_type=_enc->state.frame_type;
_enc->rc.cur_metrics.activity_avg=_enc->activity_avg;
_enc->rc.twopass_buffer_bytes=0;
}break;
case 2:{
/*Pass 2 mode:*/
if(!_trial){
ogg_int64_t next_frame_num;
int qti;
/*Move the current metrics back one frame.*/
*&_enc->rc.prev_metrics=*&_enc->rc.cur_metrics;
next_frame_num=_enc->state.curframe_num+_enc->dup_count+1;
/*Back out the last frame's statistics from the sliding window.*/
qti=_enc->rc.prev_metrics.frame_type;
_enc->rc.frames_left[qti]--;
_enc->rc.frames_left[2]-=_enc->rc.prev_metrics.dup_count;
_enc->rc.nframes[qti]--;
_enc->rc.nframes[2]-=_enc->rc.prev_metrics.dup_count;
_enc->rc.scale_sum[qti]-=oc_bexp_q24(_enc->rc.prev_metrics.log_scale);
_enc->rc.scale_window0=(int)next_frame_num;
/*Free the corresponding entry in the circular buffer.*/
if(_enc->rc.frame_metrics!=NULL){
_enc->rc.nframe_metrics--;
_enc->rc.frame_metrics_head++;
if(_enc->rc.frame_metrics_head>=_enc->rc.cframe_metrics){
_enc->rc.frame_metrics_head=0;
}
}
/*Mark us ready for the next 2-pass packet.*/
_enc->rc.twopass_buffer_bytes=0;
/*Update state, so the user doesn't have to keep calling 2pass_in after
they've fed in all the data when we're using a finite buffer.*/
_enc->prev_dup_count=_enc->dup_count;
oc_enc_rc_2pass_in(_enc,NULL,0);
}
}break;
}
/*Common to all passes:*/
if(_bits>0){
if(_trial){
oc_iir_filter *f;
/*Use the estimated scale factor directly if this was a trial.*/
f=_enc->rc.scalefilter+_qti;
f->y[1]=f->y[0]=f->x[1]=f->x[0]=oc_q57_to_q24(log_scale);
_enc->rc.log_scale[_qti]=log_scale;
}
else{
/*Lengthen the time constant for the INTER filter as we collect more
frame statistics, until we reach our target.*/
if(_enc->rc.inter_delay<_enc->rc.inter_delay_target&&
_enc->rc.inter_count>=_enc->rc.inter_delay&&_qti==OC_INTER_FRAME){
oc_iir_filter_reinit(&_enc->rc.scalefilter[1],++_enc->rc.inter_delay);
}
/*Otherwise update the low-pass scale filter for this frame type,
regardless of whether or not we dropped this frame.*/
_enc->rc.log_scale[_qti]=oc_iir_filter_update(
_enc->rc.scalefilter+_qti,oc_q57_to_q24(log_scale))<<33;
/*If this frame busts our budget, it must be dropped.*/
if(_droppable&&_enc->rc.fullness+buf_delta<_bits){
_enc->rc.prev_drop_count+=1+_enc->dup_count;
_bits=0;
dropped=1;
}
else{
ogg_uint32_t drop_count;
/*Update a low-pass filter to estimate the "real" frame rate taking
drops and duplicates into account.
This is only done if the frame is coded, as it needs the final
count of dropped frames.*/
drop_count=_enc->rc.prev_drop_count+1;
if(drop_count>0x7F)drop_count=0x7FFFFFFF;
else drop_count<<=24;
_enc->rc.log_drop_scale=oc_blog64(oc_iir_filter_update(
&_enc->rc.vfrfilter,drop_count))-OC_Q57(24);
/*Initialize the drop count for this frame to the user-requested dup
count.
It will be increased if we drop more frames.*/
_enc->rc.prev_drop_count=_enc->dup_count;
}
}
/*Increment the INTER frame count, for filter adaptation purposes.*/
if(_enc->rc.inter_count<INT_MAX)_enc->rc.inter_count+=_qti;
}
/*Increase the drop count.*/
else _enc->rc.prev_drop_count+=1+_enc->dup_count;
/*And update the buffer fullness level.*/
if(!_trial){
_enc->rc.fullness+=buf_delta-_bits;
/*If we're too quick filling the buffer and overflow is capped,
that rate is lost forever.*/
if(_enc->rc.cap_overflow&&_enc->rc.fullness>_enc->rc.max){
_enc->rc.fullness=_enc->rc.max;
}
/*If we're too quick draining the buffer and underflow is capped,
don't try to make up that rate later.*/
if(_enc->rc.cap_underflow&&_enc->rc.fullness<0){
_enc->rc.fullness=0;
}
/*Adjust the bias for the real bits we've used.*/
_enc->rc.rate_bias-=_bits;
}
return dropped;
}
#define OC_RC_2PASS_VERSION (2)
#define OC_RC_2PASS_HDR_SZ (38)
#define OC_RC_2PASS_PACKET_SZ (12)
static void oc_rc_buffer_val(oc_rc_state *_rc,ogg_int64_t _val,int _bytes){
while(_bytes-->0){
_rc->twopass_buffer[_rc->twopass_buffer_bytes++]=(unsigned char)(_val&0xFF);
_val>>=8;
}
}
int oc_enc_rc_2pass_out(oc_enc_ctx *_enc,unsigned char **_buf){
if(_enc->rc.twopass_buffer_bytes==0){
if(_enc->rc.twopass==0){
int qi;
/*Pick first-pass qi for scale calculations.*/
qi=oc_enc_select_qi(_enc,0,0);
_enc->state.nqis=1;
_enc->state.qis[0]=qi;
_enc->rc.twopass=1;
_enc->rc.frames_total[0]=_enc->rc.frames_total[1]=
_enc->rc.frames_total[2]=0;
_enc->rc.scale_sum[0]=_enc->rc.scale_sum[1]=0;
/*Fill in dummy summary values.*/
oc_rc_buffer_val(&_enc->rc,0x5032544F,4);
oc_rc_buffer_val(&_enc->rc,OC_RC_2PASS_VERSION,4);
oc_rc_buffer_val(&_enc->rc,0,OC_RC_2PASS_HDR_SZ-8);
}
else{
int qti;
qti=_enc->rc.cur_metrics.frame_type;
_enc->rc.scale_sum[qti]+=oc_bexp_q24(_enc->rc.cur_metrics.log_scale);
_enc->rc.frames_total[qti]++;
_enc->rc.frames_total[2]+=_enc->rc.cur_metrics.dup_count;
oc_rc_buffer_val(&_enc->rc,
_enc->rc.cur_metrics.dup_count|_enc->rc.cur_metrics.frame_type<<31,4);
oc_rc_buffer_val(&_enc->rc,_enc->rc.cur_metrics.log_scale,4);
oc_rc_buffer_val(&_enc->rc,_enc->rc.cur_metrics.activity_avg,4);
}
}
else if(_enc->packet_state==OC_PACKET_DONE&&
_enc->rc.twopass_buffer_bytes!=OC_RC_2PASS_HDR_SZ){
_enc->rc.twopass_buffer_bytes=0;
oc_rc_buffer_val(&_enc->rc,0x5032544F,4);
oc_rc_buffer_val(&_enc->rc,OC_RC_2PASS_VERSION,4);
oc_rc_buffer_val(&_enc->rc,_enc->rc.frames_total[0],4);
oc_rc_buffer_val(&_enc->rc,_enc->rc.frames_total[1],4);
oc_rc_buffer_val(&_enc->rc,_enc->rc.frames_total[2],4);
oc_rc_buffer_val(&_enc->rc,_enc->rc.exp[0],1);
oc_rc_buffer_val(&_enc->rc,_enc->rc.exp[1],1);
oc_rc_buffer_val(&_enc->rc,_enc->rc.scale_sum[0],8);
oc_rc_buffer_val(&_enc->rc,_enc->rc.scale_sum[1],8);
}
else{
/*The data for this frame has already been retrieved.*/
*_buf=NULL;
return 0;
}
*_buf=_enc->rc.twopass_buffer;
return _enc->rc.twopass_buffer_bytes;
}
static size_t oc_rc_buffer_fill(oc_rc_state *_rc,
unsigned char *_buf,size_t _bytes,size_t _consumed,size_t _goal){
while(_rc->twopass_buffer_fill<_goal&&_consumed<_bytes){
_rc->twopass_buffer[_rc->twopass_buffer_fill++]=_buf[_consumed++];
}
return _consumed;
}
static ogg_int64_t oc_rc_unbuffer_val(oc_rc_state *_rc,int _bytes){
ogg_int64_t ret;
int shift;
ret=0;
shift=0;
while(_bytes-->0){
ret|=((ogg_int64_t)_rc->twopass_buffer[_rc->twopass_buffer_bytes++])<<shift;
shift+=8;
}
return ret;
}
int oc_enc_rc_2pass_in(oc_enc_ctx *_enc,unsigned char *_buf,size_t _bytes){
size_t consumed;
consumed=0;
/*Enable pass 2 mode if this is the first call.*/
if(_enc->rc.twopass==0){
_enc->rc.twopass=2;
_enc->rc.twopass_buffer_fill=0;
_enc->rc.frames_total[0]=0;
_enc->rc.nframe_metrics=0;
_enc->rc.cframe_metrics=0;
_enc->rc.frame_metrics_head=0;
_enc->rc.scale_window0=0;
_enc->rc.scale_window_end=0;
}
/*If we haven't got a valid summary header yet, try to parse one.*/
if(_enc->rc.frames_total[0]==0){
if(!_buf){
int frames_needed;
/*If we're using a whole-file buffer, we just need the first frame.
Otherwise, we may need as many as one per buffer slot.*/
frames_needed=_enc->rc.frame_metrics==NULL?1:_enc->rc.buf_delay;
return OC_RC_2PASS_HDR_SZ+frames_needed*OC_RC_2PASS_PACKET_SZ
-_enc->rc.twopass_buffer_fill;
}
consumed=oc_rc_buffer_fill(&_enc->rc,
_buf,_bytes,consumed,OC_RC_2PASS_HDR_SZ);
if(_enc->rc.twopass_buffer_fill>=OC_RC_2PASS_HDR_SZ){
ogg_int64_t scale_sum[2];
int exp[2];
int buf_delay;
/*Read the summary header data.*/
/*Check the magic value and version number.*/
if(oc_rc_unbuffer_val(&_enc->rc,4)!=0x5032544F||
oc_rc_unbuffer_val(&_enc->rc,4)!=OC_RC_2PASS_VERSION){
_enc->rc.twopass_buffer_bytes=0;
return TH_ENOTFORMAT;
}
_enc->rc.frames_total[0]=(ogg_uint32_t)oc_rc_unbuffer_val(&_enc->rc,4);
_enc->rc.frames_total[1]=(ogg_uint32_t)oc_rc_unbuffer_val(&_enc->rc,4);
_enc->rc.frames_total[2]=(ogg_uint32_t)oc_rc_unbuffer_val(&_enc->rc,4);
exp[0]=(int)oc_rc_unbuffer_val(&_enc->rc,1);
exp[1]=(int)oc_rc_unbuffer_val(&_enc->rc,1);
scale_sum[0]=oc_rc_unbuffer_val(&_enc->rc,8);
scale_sum[1]=oc_rc_unbuffer_val(&_enc->rc,8);
/*Make sure the file claims to have at least one frame.
Otherwise we probably got the placeholder data from an aborted pass 1.
Also make sure the total frame count doesn't overflow an integer.*/
buf_delay=_enc->rc.frames_total[0]+_enc->rc.frames_total[1]
+_enc->rc.frames_total[2];
if(_enc->rc.frames_total[0]==0||buf_delay<0||
(ogg_uint32_t)buf_delay<_enc->rc.frames_total[0]||
(ogg_uint32_t)buf_delay<_enc->rc.frames_total[1]){
_enc->rc.frames_total[0]=0;
_enc->rc.twopass_buffer_bytes=0;
return TH_EBADHEADER;
}
/*Got a valid header; set up pass 2.*/
_enc->rc.frames_left[0]=_enc->rc.frames_total[0];
_enc->rc.frames_left[1]=_enc->rc.frames_total[1];
_enc->rc.frames_left[2]=_enc->rc.frames_total[2];
/*If the user hasn't specified a buffer size, use the whole file.*/
if(_enc->rc.frame_metrics==NULL){
_enc->rc.buf_delay=buf_delay;
_enc->rc.nframes[0]=_enc->rc.frames_total[0];
_enc->rc.nframes[1]=_enc->rc.frames_total[1];
_enc->rc.nframes[2]=_enc->rc.frames_total[2];
_enc->rc.scale_sum[0]=scale_sum[0];
_enc->rc.scale_sum[1]=scale_sum[1];
_enc->rc.scale_window_end=buf_delay;
oc_enc_rc_reset(_enc);
}
_enc->rc.exp[0]=exp[0];
_enc->rc.exp[1]=exp[1];
/*Clear the header data from the buffer to make room for packet data.*/
_enc->rc.twopass_buffer_fill=0;
_enc->rc.twopass_buffer_bytes=0;
}
}
if(_enc->rc.frames_total[0]!=0){
ogg_int64_t curframe_num;
int nframes_total;
curframe_num=_enc->state.curframe_num;
if(curframe_num>=0){
/*We just encoded a frame; make sure things matched.*/
if(_enc->rc.prev_metrics.dup_count!=_enc->prev_dup_count){
_enc->rc.twopass_buffer_bytes=0;
return TH_EINVAL;
}
}
curframe_num+=_enc->prev_dup_count+1;
nframes_total=_enc->rc.frames_total[0]+_enc->rc.frames_total[1]
+_enc->rc.frames_total[2];
if(curframe_num>=nframes_total){
/*We don't want any more data after the last frame, and we don't want to
allow any more frames to be encoded.*/
_enc->rc.twopass_buffer_bytes=0;
}
else if(_enc->rc.twopass_buffer_bytes==0){
if(_enc->rc.frame_metrics==NULL){
/*We're using a whole-file buffer:*/
if(!_buf)return OC_RC_2PASS_PACKET_SZ-_enc->rc.twopass_buffer_fill;
consumed=oc_rc_buffer_fill(&_enc->rc,
_buf,_bytes,consumed,OC_RC_2PASS_PACKET_SZ);
if(_enc->rc.twopass_buffer_fill>=OC_RC_2PASS_PACKET_SZ){
ogg_uint32_t dup_count;
ogg_int32_t log_scale;
unsigned activity;
int qti;
int arg;
/*Read the metrics for the next frame.*/
dup_count=oc_rc_unbuffer_val(&_enc->rc,4);
log_scale=oc_rc_unbuffer_val(&_enc->rc,4);
activity=oc_rc_unbuffer_val(&_enc->rc,4);
_enc->rc.cur_metrics.log_scale=log_scale;
qti=(dup_count&0x80000000)>>31;
_enc->rc.cur_metrics.dup_count=dup_count&0x7FFFFFFF;
_enc->rc.cur_metrics.frame_type=qti;
_enc->rc.twopass_force_kf=qti==OC_INTRA_FRAME;
_enc->activity_avg=_enc->rc.cur_metrics.activity_avg=activity;
/*"Helpfully" set the dup count back to what it was in pass 1.*/
arg=_enc->rc.cur_metrics.dup_count;
th_encode_ctl(_enc,TH_ENCCTL_SET_DUP_COUNT,&arg,sizeof(arg));
/*Clear the buffer for the next frame.*/
_enc->rc.twopass_buffer_fill=0;
}
}
else{
int frames_needed;
/*We're using a finite buffer:*/
frames_needed=OC_MINI(_enc->rc.buf_delay-OC_MINI(_enc->rc.buf_delay,
_enc->rc.scale_window_end-_enc->rc.scale_window0),
_enc->rc.frames_left[0]+_enc->rc.frames_left[1]
-_enc->rc.nframes[0]-_enc->rc.nframes[1]);
while(frames_needed>0){
if(!_buf){
return OC_RC_2PASS_PACKET_SZ*frames_needed
-_enc->rc.twopass_buffer_fill;
}
consumed=oc_rc_buffer_fill(&_enc->rc,
_buf,_bytes,consumed,OC_RC_2PASS_PACKET_SZ);
if(_enc->rc.twopass_buffer_fill>=OC_RC_2PASS_PACKET_SZ){
oc_frame_metrics *m;
int fmi;
ogg_uint32_t dup_count;
ogg_int32_t log_scale;
int qti;
unsigned activity;
/*Read the metrics for the next frame.*/
dup_count=oc_rc_unbuffer_val(&_enc->rc,4);
log_scale=oc_rc_unbuffer_val(&_enc->rc,4);
activity=oc_rc_unbuffer_val(&_enc->rc,4);
/*Add the to the circular buffer.*/
fmi=_enc->rc.frame_metrics_head+_enc->rc.nframe_metrics++;
if(fmi>=_enc->rc.cframe_metrics)fmi-=_enc->rc.cframe_metrics;
m=_enc->rc.frame_metrics+fmi;
m->log_scale=log_scale;
qti=(dup_count&0x80000000)>>31;
m->dup_count=dup_count&0x7FFFFFFF;
m->frame_type=qti;
m->activity_avg=activity;
/*And accumulate the statistics over the window.*/
_enc->rc.nframes[qti]++;
_enc->rc.nframes[2]+=m->dup_count;
_enc->rc.scale_sum[qti]+=oc_bexp_q24(m->log_scale);
_enc->rc.scale_window_end+=m->dup_count+1;
/*Compute an upper bound on the number of remaining packets needed
for the current window.*/
frames_needed=OC_MINI(_enc->rc.buf_delay-OC_MINI(_enc->rc.buf_delay,
_enc->rc.scale_window_end-_enc->rc.scale_window0),
_enc->rc.frames_left[0]+_enc->rc.frames_left[1]
-_enc->rc.nframes[0]-_enc->rc.nframes[1]);
/*Clear the buffer for the next frame.*/
_enc->rc.twopass_buffer_fill=0;
_enc->rc.twopass_buffer_bytes=0;
}
/*Go back for more data.*/
else break;
}
/*If we've got all the frames we need, fill in the current metrics.
We're ready to go.*/
if(frames_needed<=0){
int arg;
*&_enc->rc.cur_metrics=
*(_enc->rc.frame_metrics+_enc->rc.frame_metrics_head);
_enc->rc.twopass_force_kf=
_enc->rc.cur_metrics.frame_type==OC_INTRA_FRAME;
_enc->activity_avg=_enc->rc.cur_metrics.activity_avg;
/*"Helpfully" set the dup count back to what it was in pass 1.*/
arg=_enc->rc.cur_metrics.dup_count;
th_encode_ctl(_enc,TH_ENCCTL_SET_DUP_COUNT,&arg,sizeof(arg));
/*Mark us ready for the next frame.*/
_enc->rc.twopass_buffer_bytes=1;
}
}
}
}
return (int)consumed;
}
|
9b71da0610c543598857ac3b0bfc9a363ad74d0d
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/xtensa/mm/fault.c
|
38278337d85e82690ae143fe038a9f5884eaee21
|
[
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 6,480
|
c
|
fault.c
|
// TODO VM_EXEC flag work-around, cache aliasing
/*
* arch/xtensa/mm/fault.c
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2001 - 2010 Tensilica Inc.
*
* Chris Zankel <chris@zankel.net>
* Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
*/
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/hardirq.h>
#include <asm/mmu_context.h>
#include <asm/cacheflush.h>
#include <asm/hardirq.h>
#include <asm/uaccess.h>
#include <asm/pgalloc.h>
unsigned long asid_cache = ASID_USER_FIRST;
void bad_page_fault(struct pt_regs*, unsigned long, int);
#undef DEBUG_PAGE_FAULT
/*
* This routine handles page faults. It determines the address,
* and the problem, and then passes it off to one of the appropriate
* routines.
*
* Note: does not handle Miss and MultiHit.
*/
void do_page_fault(struct pt_regs *regs)
{
struct vm_area_struct * vma;
struct mm_struct *mm = current->mm;
unsigned int exccause = regs->exccause;
unsigned int address = regs->excvaddr;
siginfo_t info;
int is_write, is_exec;
int fault;
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
info.si_code = SEGV_MAPERR;
/* We fault-in kernel-space virtual memory on-demand. The
* 'reference' page table is init_mm.pgd.
*/
if (address >= TASK_SIZE && !user_mode(regs))
goto vmalloc_fault;
/* If we're in an interrupt or have no user
* context, we must not take the fault..
*/
if (in_atomic() || !mm) {
bad_page_fault(regs, address, SIGSEGV);
return;
}
is_write = (exccause == EXCCAUSE_STORE_CACHE_ATTRIBUTE) ? 1 : 0;
is_exec = (exccause == EXCCAUSE_ITLB_PRIVILEGE ||
exccause == EXCCAUSE_ITLB_MISS ||
exccause == EXCCAUSE_FETCH_CACHE_ATTRIBUTE) ? 1 : 0;
#ifdef DEBUG_PAGE_FAULT
printk("[%s:%d:%08x:%d:%08x:%s%s]\n", current->comm, current->pid,
address, exccause, regs->pc, is_write? "w":"", is_exec? "x":"");
#endif
if (user_mode(regs))
flags |= FAULT_FLAG_USER;
retry:
down_read(&mm->mmap_sem);
vma = find_vma(mm, address);
if (!vma)
goto bad_area;
if (vma->vm_start <= address)
goto good_area;
if (!(vma->vm_flags & VM_GROWSDOWN))
goto bad_area;
if (expand_stack(vma, address))
goto bad_area;
/* Ok, we have a good vm_area for this memory access, so
* we can handle it..
*/
good_area:
info.si_code = SEGV_ACCERR;
if (is_write) {
if (!(vma->vm_flags & VM_WRITE))
goto bad_area;
flags |= FAULT_FLAG_WRITE;
} else if (is_exec) {
if (!(vma->vm_flags & VM_EXEC))
goto bad_area;
} else /* Allow read even from write-only pages. */
if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
goto bad_area;
/* If for any reason at all we couldn't handle the fault,
* make sure we exit gracefully rather than endlessly redo
* the fault.
*/
fault = handle_mm_fault(mm, vma, address, flags);
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
return;
if (unlikely(fault & VM_FAULT_ERROR)) {
if (fault & VM_FAULT_OOM)
goto out_of_memory;
else if (fault & VM_FAULT_SIGSEGV)
goto bad_area;
else if (fault & VM_FAULT_SIGBUS)
goto do_sigbus;
BUG();
}
if (flags & FAULT_FLAG_ALLOW_RETRY) {
if (fault & VM_FAULT_MAJOR)
current->maj_flt++;
else
current->min_flt++;
if (fault & VM_FAULT_RETRY) {
flags &= ~FAULT_FLAG_ALLOW_RETRY;
flags |= FAULT_FLAG_TRIED;
/* No need to up_read(&mm->mmap_sem) as we would
* have already released it in __lock_page_or_retry
* in mm/filemap.c.
*/
goto retry;
}
}
up_read(&mm->mmap_sem);
return;
/* Something tried to access memory that isn't in our memory map..
* Fix it, but check if it's kernel or user first..
*/
bad_area:
up_read(&mm->mmap_sem);
if (user_mode(regs)) {
current->thread.bad_vaddr = address;
current->thread.error_code = is_write;
info.si_signo = SIGSEGV;
info.si_errno = 0;
/* info.si_code has been set above */
info.si_addr = (void *) address;
force_sig_info(SIGSEGV, &info, current);
return;
}
bad_page_fault(regs, address, SIGSEGV);
return;
/* We ran out of memory, or some other thing happened to us that made
* us unable to handle the page fault gracefully.
*/
out_of_memory:
up_read(&mm->mmap_sem);
if (!user_mode(regs))
bad_page_fault(regs, address, SIGKILL);
else
pagefault_out_of_memory();
return;
do_sigbus:
up_read(&mm->mmap_sem);
/* Send a sigbus, regardless of whether we were in kernel
* or user mode.
*/
current->thread.bad_vaddr = address;
info.si_code = SIGBUS;
info.si_errno = 0;
info.si_code = BUS_ADRERR;
info.si_addr = (void *) address;
force_sig_info(SIGBUS, &info, current);
/* Kernel mode? Handle exceptions or die */
if (!user_mode(regs))
bad_page_fault(regs, address, SIGBUS);
return;
vmalloc_fault:
{
/* Synchronize this task's top level page-table
* with the 'reference' page table.
*/
struct mm_struct *act_mm = current->active_mm;
int index = pgd_index(address);
pgd_t *pgd, *pgd_k;
pmd_t *pmd, *pmd_k;
pte_t *pte_k;
if (act_mm == NULL)
goto bad_page_fault;
pgd = act_mm->pgd + index;
pgd_k = init_mm.pgd + index;
if (!pgd_present(*pgd_k))
goto bad_page_fault;
pgd_val(*pgd) = pgd_val(*pgd_k);
pmd = pmd_offset(pgd, address);
pmd_k = pmd_offset(pgd_k, address);
if (!pmd_present(*pmd) || !pmd_present(*pmd_k))
goto bad_page_fault;
pmd_val(*pmd) = pmd_val(*pmd_k);
pte_k = pte_offset_kernel(pmd_k, address);
if (!pte_present(*pte_k))
goto bad_page_fault;
return;
}
bad_page_fault:
bad_page_fault(regs, address, SIGKILL);
return;
}
void
bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
{
extern void die(const char*, struct pt_regs*, long);
const struct exception_table_entry *entry;
/* Are we prepared to handle this kernel fault? */
if ((entry = search_exception_tables(regs->pc)) != NULL) {
#ifdef DEBUG_PAGE_FAULT
printk(KERN_DEBUG "%s: Exception at pc=%#010lx (%lx)\n",
current->comm, regs->pc, entry->fixup);
#endif
current->thread.bad_uaddr = address;
regs->pc = entry->fixup;
return;
}
/* Oops. The kernel tried to access some bad page. We'll have to
* terminate things with extreme prejudice.
*/
printk(KERN_ALERT "Unable to handle kernel paging request at virtual "
"address %08lx\n pc = %08lx, ra = %08lx\n",
address, regs->pc, regs->areg[0]);
die("Oops", regs, sig);
do_exit(sig);
}
|
2b8e92ccfdab6796d4a5891fd8a0d0e83b58be5b
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/usr.bin/make/varmodifiers.c
|
1cbcfe8e7d1360fc1cabcf976043fd08931844a4
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 40,149
|
c
|
varmodifiers.c
|
/* $OpenBSD: varmodifiers.c,v 1.48 2020/08/30 12:16:04 tb Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
* Copyright (c) 1999-2010 Marc Espie.
*
* Extensive code changes for the OpenBSD project.
*
* 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 OPENBSD PROJECT 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 OPENBSD
* PROJECT 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.
*/
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
*
* 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 University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* VarModifiers_Apply is mostly a constituent function of Var_Parse, it
* is also called directly by Var_SubstVar. */
#include <ctype.h>
#include <sys/types.h>
#include <regex.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "defines.h"
#include "buf.h"
#include "var.h"
#include "varmodifiers.h"
#include "varname.h"
#include "targ.h"
#include "error.h"
#include "str.h"
#include "cmd_exec.h"
#include "memory.h"
#include "gnode.h"
/* Var*Pattern flags */
#define VAR_SUB_GLOBAL 0x01 /* Apply substitution globally */
#define VAR_SUB_ONE 0x02 /* Apply substitution to one word */
#define VAR_SUB_MATCHED 0x04 /* There was a match */
#define VAR_MATCH_START 0x08 /* Match at start of word */
#define VAR_MATCH_END 0x10 /* Match at end of word */
/* Modifiers flags */
#define VAR_EQUAL 0x20
#define VAR_MAY_EQUAL 0x40
#define VAR_ADD_EQUAL 0x80
#define VAR_BANG_EQUAL 0x100
typedef struct {
char *lbuffer; /* left string to free */
char *lhs; /* String to match */
size_t leftLen; /* Length of string */
char *rhs; /* Replacement string (w/ &'s removed) */
size_t rightLen; /* Length of replacement */
int flags;
} VarPattern;
struct LoopStuff {
struct LoopVar *var;
char *expand;
bool err;
};
static bool VarHead(struct Name *, bool, Buffer, void *);
static bool VarTail(struct Name *, bool, Buffer, void *);
static bool VarSuffix(struct Name *, bool, Buffer, void *);
static bool VarRoot(struct Name *, bool, Buffer, void *);
static bool VarMatch(struct Name *, bool, Buffer, void *);
static bool VarSYSVMatch(struct Name *, bool, Buffer, void *);
static bool VarNoMatch(struct Name *, bool, Buffer, void *);
static bool VarUniq(struct Name *, bool, Buffer, void *);
static bool VarLoop(struct Name *, bool, Buffer, void *);
static void VarREError(int, regex_t *, const char *);
static bool VarRESubstitute(struct Name *, bool, Buffer, void *);
static char *do_regex(const char *, const struct Name *, void *);
typedef struct {
regex_t re;
int nsub;
regmatch_t *matches;
char *replace;
int flags;
} VarREPattern;
static bool VarSubstitute(struct Name *, bool, Buffer, void *);
static char *VarGetPattern(SymTable *, int, const char **, int, int,
size_t *, VarPattern *);
static char *VarQuote(const char *, const struct Name *, void *);
static char *VarModify(char *, bool (*)(struct Name *, bool, Buffer, void *), void *);
static void *check_empty(const char **, SymTable *, bool, int);
static void *check_quote(const char **, SymTable *, bool, int);
static char *do_upper(const char *, const struct Name *, void *);
static char *do_lower(const char *, const struct Name *, void *);
static void *check_shcmd(const char **, SymTable *, bool, int);
static char *do_shcmd(const char *, const struct Name *, void *);
static char *do_sort(const char *, const struct Name *, void *);
static char *finish_loop(const char *, const struct Name *, void *);
static int NameCompare(const void *, const void *);
static char *do_label(const char *, const struct Name *, void *);
static char *do_path(const char *, const struct Name *, void *);
static char *do_def(const char *, const struct Name *, void *);
static char *do_undef(const char *, const struct Name *, void *);
static char *do_assign(const char *, const struct Name *, void *);
static char *do_exec(const char *, const struct Name *, void *);
static void *assign_get_value(const char **, SymTable *, bool, int);
static void *get_cmd(const char **, SymTable *, bool, int);
static void *get_value(const char **, SymTable *, bool, int);
static void *get_stringarg(const char **, SymTable *, bool, int);
static void free_stringarg(void *);
static void *get_patternarg(const char **, SymTable *, bool, int);
static void *get_spatternarg(const char **, SymTable *, bool, int);
static void *common_get_patternarg(const char **, SymTable *, bool, int, bool);
static void free_patternarg(void *);
static void free_looparg(void *);
static void *get_sysvpattern(const char **, SymTable *, bool, int);
static void *get_loop(const char **, SymTable *, bool, int);
static char *LoopGrab(const char **);
static struct Name dummy;
static struct Name *dummy_arg = &dummy;
static struct modifier {
bool atstart;
void * (*getarg)(const char **, SymTable *, bool, int);
char * (*apply)(const char *, const struct Name *, void *);
bool (*word_apply)(struct Name *, bool, Buffer, void *);
void (*freearg)(void *);
} *choose_mod[256],
match_mod = {false, get_stringarg, NULL, VarMatch, free_stringarg},
nomatch_mod = {false, get_stringarg, NULL, VarNoMatch, free_stringarg},
subst_mod = {false, get_spatternarg, NULL, VarSubstitute, free_patternarg},
resubst_mod = {false, get_patternarg, do_regex, NULL, free_patternarg},
quote_mod = {false, check_quote, VarQuote, NULL , free},
tail_mod = {false, check_empty, NULL, VarTail, NULL},
head_mod = {false, check_empty, NULL, VarHead, NULL},
suffix_mod = {false, check_empty, NULL, VarSuffix, NULL},
root_mod = {false, check_empty, NULL, VarRoot, NULL},
upper_mod = {false, check_empty, do_upper, NULL, NULL},
lower_mod = {false, check_empty, do_lower, NULL, NULL},
shcmd_mod = {false, check_shcmd, do_shcmd, NULL, NULL},
sysv_mod = {false, get_sysvpattern, NULL, VarSYSVMatch, free_patternarg},
uniq_mod = {false, check_empty, NULL, VarUniq, NULL},
sort_mod = {false, check_empty, do_sort, NULL, NULL},
loop_mod = {false, get_loop, finish_loop, VarLoop, free_looparg},
undef_mod = {true, get_value, do_undef, NULL, NULL},
def_mod = {true, get_value, do_def, NULL, NULL},
label_mod = {true, check_empty, do_label, NULL, NULL},
path_mod = {true, check_empty, do_path, NULL, NULL},
assign_mod = {true, assign_get_value, do_assign, NULL, free_patternarg},
exec_mod = {true, get_cmd, do_exec, NULL, free_patternarg}
;
void
VarModifiers_Init()
{
choose_mod['M'] = &match_mod;
choose_mod['N'] = &nomatch_mod;
choose_mod['S'] = &subst_mod;
choose_mod['C'] = &resubst_mod;
choose_mod['Q'] = "e_mod;
choose_mod['T'] = &tail_mod;
choose_mod['H'] = &head_mod;
choose_mod['E'] = &suffix_mod;
choose_mod['R'] = &root_mod;
if (FEATURES(FEATURE_UPPERLOWER)) {
choose_mod['U'] = &upper_mod;
choose_mod['L'] = &lower_mod;
}
if (FEATURES(FEATURE_SUNSHCMD))
choose_mod['s'] = &shcmd_mod;
if (FEATURES(FEATURE_UNIQ))
choose_mod['u'] = &uniq_mod;
if (FEATURES(FEATURE_SORT))
choose_mod['O'] = &sort_mod;
if (FEATURES(FEATURE_ODE)) {
choose_mod['@'] = &loop_mod;
choose_mod['D'] = &def_mod;
choose_mod['U'] = &undef_mod;
choose_mod['L'] = &label_mod;
choose_mod['P'] = &path_mod;
}
if (FEATURES(FEATURE_ASSIGN))
choose_mod[':'] = &assign_mod;
if (FEATURES(FEATURE_EXECMOD))
choose_mod['!'] = &exec_mod;
}
/* All modifiers handle addSpace (need to add a space before placing the
* next word into the buffer) and propagate it when necessary.
*/
/*-
*-----------------------------------------------------------------------
* VarHead --
* Remove the tail of the given word and add the result to the given
* buffer.
*-----------------------------------------------------------------------
*/
static bool
VarHead(struct Name *word, bool addSpace, Buffer buf, void *dummy UNUSED)
{
const char *slash;
slash = Str_rchri(word->s, word->e, '/');
if (slash != NULL) {
if (addSpace)
Buf_AddSpace(buf);
Buf_Addi(buf, word->s, slash);
} else {
/* If no directory part, give . (q.v. the POSIX standard). */
if (addSpace)
Buf_AddString(buf, " .");
else
Buf_AddChar(buf, '.');
}
return true;
}
/*-
*-----------------------------------------------------------------------
* VarTail --
* Remove the head of the given word add the result to the given
* buffer.
*-----------------------------------------------------------------------
*/
static bool
VarTail(struct Name *word, bool addSpace, Buffer buf, void *dummy UNUSED)
{
const char *slash;
if (addSpace)
Buf_AddSpace(buf);
slash = Str_rchri(word->s, word->e, '/');
if (slash != NULL)
Buf_Addi(buf, slash+1, word->e);
else
Buf_Addi(buf, word->s, word->e);
return true;
}
/*-
*-----------------------------------------------------------------------
* VarSuffix --
* Add the suffix of the given word to the given buffer.
*-----------------------------------------------------------------------
*/
static bool
VarSuffix(struct Name *word, bool addSpace, Buffer buf, void *dummy UNUSED)
{
const char *dot;
dot = Str_rchri(word->s, word->e, '.');
if (dot != NULL) {
if (addSpace)
Buf_AddSpace(buf);
Buf_Addi(buf, dot+1, word->e);
addSpace = true;
}
return addSpace;
}
/*-
*-----------------------------------------------------------------------
* VarRoot --
* Remove the suffix of the given word and add the result to the
* buffer.
*-----------------------------------------------------------------------
*/
static bool
VarRoot(struct Name *word, bool addSpace, Buffer buf, void *dummy UNUSED)
{
const char *dot;
if (addSpace)
Buf_AddSpace(buf);
dot = Str_rchri(word->s, word->e, '.');
if (dot != NULL)
Buf_Addi(buf, word->s, dot);
else
Buf_Addi(buf, word->s, word->e);
return true;
}
/*-
*-----------------------------------------------------------------------
* VarMatch --
* Add the word to the buffer if it matches the given pattern.
*-----------------------------------------------------------------------
*/
static bool
VarMatch(struct Name *word, bool addSpace, Buffer buf,
void *pattern) /* Pattern the word must match */
{
const char *pat = pattern;
if (Str_Matchi(word->s, word->e, pat, strchr(pat, '\0'))) {
if (addSpace)
Buf_AddSpace(buf);
Buf_Addi(buf, word->s, word->e);
return true;
} else
return addSpace;
}
/*-
*-----------------------------------------------------------------------
* VarNoMatch --
* Add the word to the buffer if it doesn't match the given pattern.
*-----------------------------------------------------------------------
*/
static bool
VarNoMatch(struct Name *word, bool addSpace, Buffer buf,
void *pattern) /* Pattern the word must not match */
{
const char *pat = pattern;
if (!Str_Matchi(word->s, word->e, pat, strchr(pat, '\0'))) {
if (addSpace)
Buf_AddSpace(buf);
Buf_Addi(buf, word->s, word->e);
return true;
} else
return addSpace;
}
static bool
VarUniq(struct Name *word, bool addSpace, Buffer buf, void *lastp)
{
struct Name *last = lastp;
/* does not match */
if (last->s == NULL || last->e - last->s != word->e - word->s ||
strncmp(word->s, last->s, word->e - word->s) != 0) {
if (addSpace)
Buf_AddSpace(buf);
Buf_Addi(buf, word->s, word->e);
addSpace = true;
}
last->s = word->s;
last->e = word->e;
return addSpace;
}
static bool
VarLoop(struct Name *word, bool addSpace, Buffer buf, void *vp)
{
struct LoopStuff *v = vp;
if (addSpace)
Buf_AddSpace(buf);
Var_SubstVar(buf, v->expand, v->var, word->s);
return true;
}
static char *
finish_loop(const char *s, const struct Name *n UNUSED , void *p)
{
struct LoopStuff *l = p;
return Var_Subst(s, NULL, l->err);
}
static int
NameCompare(const void *ap, const void *bp)
{
const struct Name *a, *b;
size_t n, m;
int c;
a = ap;
b = bp;
n = a->e - a->s;
m = b->e - b->s;
if (n < m) {
c = strncmp(a->s, b->s, n);
if (c != 0)
return c;
else
return -1;
} else if (m < n) {
c = strncmp(a->s, b->s, m);
if (c != 0)
return c;
else
return 1;
} else
return strncmp(a->s, b->s, n);
}
static char *
do_sort(const char *s, const struct Name *dummy UNUSED, void *arg UNUSED)
{
struct Name *t;
unsigned long n, i, j;
const char *start, *end;
n = 1024; /* start at 1024 words */
t = ereallocarray(NULL, n, sizeof(struct Name));
start = s;
end = start;
for (i = 0;; i++) {
if (i == n) {
n *= 2;
t = ereallocarray(t, n, sizeof(struct Name));
}
start = iterate_words(&end);
if (start == NULL)
break;
t[i].s = start;
t[i].e = end;
}
if (i > 0) {
BUFFER buf;
Buf_Init(&buf, end - s);
qsort(t, i, sizeof(struct Name), NameCompare);
Buf_Addi(&buf, t[0].s, t[0].e);
for (j = 1; j < i; j++) {
Buf_AddSpace(&buf);
Buf_Addi(&buf, t[j].s, t[j].e);
}
free(t);
return Buf_Retrieve(&buf);
} else {
free(t);
return "";
}
}
static char *
do_label(const char *s UNUSED, const struct Name *n, void *arg UNUSED)
{
return Str_dupi(n->s, n->e);
}
static char *
do_path(const char *s UNUSED, const struct Name *n, void *arg UNUSED)
{
GNode *gn;
gn = Targ_FindNodei(n->s, n->e, TARG_NOCREATE);
if (gn == NULL)
return Str_dupi(n->s, n->e);
else
return strdup(gn->path);
}
static char *
do_def(const char *s, const struct Name *n UNUSED, void *arg)
{
VarPattern *v = arg;
if (s == NULL) {
free_patternarg(v);
return NULL;
} else
return v->lbuffer;
}
static char *
do_undef(const char *s, const struct Name *n UNUSED, void *arg)
{
VarPattern *v = arg;
if (s != NULL) {
free_patternarg(v);
return NULL;
} else
return v->lbuffer;
}
static char *
do_assign(const char *s, const struct Name *n, void *arg)
{
VarPattern *v = arg;
char *msg;
char *result;
switch (v->flags) {
case VAR_EQUAL:
Var_Seti(n->s, n->e, v->lbuffer);
break;
case VAR_MAY_EQUAL:
if (s == NULL)
Var_Seti(n->s, n->e, v->lbuffer);
break;
case VAR_ADD_EQUAL:
if (s == NULL)
Var_Seti(n->s, n->e, v->lbuffer);
else
Var_Appendi(n->s, n->e, v->lbuffer);
break;
case VAR_BANG_EQUAL:
result = Cmd_Exec(v->lbuffer, &msg);
if (result != NULL) {
Var_Seti(n->s, n->e, result);
free(result);
} else
Error(msg, v->lbuffer);
break;
}
return NULL;
}
static char *
do_exec(const char *s UNUSED, const struct Name *n UNUSED, void *arg)
{
VarPattern *v = arg;
char *msg;
char *result;
result = Cmd_Exec(v->lbuffer, &msg);
if (result == NULL)
Error(msg, v->lbuffer);
return result;
}
/*-
*-----------------------------------------------------------------------
* VarSYSVMatch --
* Add the word to the buffer if it matches the given pattern.
* Used to implement the System V % modifiers.
*-----------------------------------------------------------------------
*/
static bool
VarSYSVMatch(struct Name *word, bool addSpace, Buffer buf, void *patp)
{
size_t len;
const char *ptr;
VarPattern *pat = patp;
if (*word->s != '\0') {
if (addSpace)
Buf_AddSpace(buf);
if ((ptr = Str_SYSVMatch(word->s, pat->lhs, &len)) != NULL)
Str_SYSVSubst(buf, pat->rhs, ptr, len);
else
Buf_Addi(buf, word->s, word->e);
return true;
} else
return addSpace;
}
void *
get_sysvpattern(const char **p, SymTable *ctxt UNUSED, bool err, int endc)
{
VarPattern *pattern;
const char *cp, *cp2;
BUFFER buf, buf2;
int cnt = 0;
char startc = endc == ')' ? '(' : '{';
Buf_Init(&buf, 0);
for (cp = *p;; cp++) {
if (*cp == '=' && cnt == 0)
break;
if (*cp == '\0') {
Buf_Destroy(&buf);
return NULL;
}
if (*cp == startc)
cnt++;
else if (*cp == endc) {
cnt--;
if (cnt < 0) {
Buf_Destroy(&buf);
return NULL;
}
} else if (*cp == '$') {
if (cp[1] == '$')
cp++;
else {
size_t len;
(void)Var_ParseBuffer(&buf, cp, ctxt, err,
&len);
cp += len - 1;
continue;
}
}
Buf_AddChar(&buf, *cp);
}
Buf_Init(&buf2, 0);
for (cp2 = cp+1;; cp2++) {
if (((*cp2 == ':' && cp2[1] != endc) || *cp2 == endc) &&
cnt == 0)
break;
if (*cp2 == '\0') {
Buf_Destroy(&buf);
Buf_Destroy(&buf2);
return NULL;
}
if (*cp2 == startc)
cnt++;
else if (*cp2 == endc) {
cnt--;
if (cnt < 0) {
Buf_Destroy(&buf);
Buf_Destroy(&buf2);
return NULL;
}
} else if (*cp2 == '$') {
if (cp2[1] == '$')
cp2++;
else {
size_t len;
(void)Var_ParseBuffer(&buf2, cp2, ctxt, err,
&len);
cp2 += len - 1;
continue;
}
}
Buf_AddChar(&buf2, *cp2);
}
pattern = emalloc(sizeof(VarPattern));
pattern->lbuffer = pattern->lhs = Buf_Retrieve(&buf);
pattern->leftLen = Buf_Size(&buf);
pattern->rhs = Buf_Retrieve(&buf2);
pattern->rightLen = Buf_Size(&buf2);
pattern->flags = 0;
*p = cp2;
return pattern;
}
/*-
*-----------------------------------------------------------------------
* VarSubstitute --
* Perform a string-substitution on the given word, Adding the
* result to the given buffer.
*-----------------------------------------------------------------------
*/
static bool
VarSubstitute(struct Name *word, bool addSpace, Buffer buf,
void *patternp) /* Pattern for substitution */
{
size_t wordLen; /* Length of word */
const char *cp; /* General pointer */
VarPattern *pattern = patternp;
wordLen = word->e - word->s;
if ((pattern->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) !=
(VAR_SUB_ONE|VAR_SUB_MATCHED)) {
/* Still substituting -- break it down into simple anchored cases
* and if none of them fits, perform the general substitution case. */
if ((pattern->flags & VAR_MATCH_START) &&
(strncmp(word->s, pattern->lhs, pattern->leftLen) == 0)) {
/* Anchored at start and beginning of word matches pattern. */
if ((pattern->flags & VAR_MATCH_END) &&
(wordLen == pattern->leftLen)) {
/* Also anchored at end and matches to the end (word
* is same length as pattern) add space and rhs only
* if rhs is non-null. */
if (pattern->rightLen != 0) {
if (addSpace)
Buf_AddSpace(buf);
addSpace = true;
Buf_AddChars(buf, pattern->rightLen,
pattern->rhs);
}
pattern->flags |= VAR_SUB_MATCHED;
} else if (pattern->flags & VAR_MATCH_END) {
/* Doesn't match to end -- copy word wholesale. */
goto nosub;
} else {
/* Matches at start but need to copy in
* trailing characters. */
if ((pattern->rightLen + wordLen - pattern->leftLen) != 0){
if (addSpace)
Buf_AddSpace(buf);
addSpace = true;
}
Buf_AddChars(buf, pattern->rightLen, pattern->rhs);
Buf_AddChars(buf, wordLen - pattern->leftLen,
word->s + pattern->leftLen);
pattern->flags |= VAR_SUB_MATCHED;
}
} else if (pattern->flags & VAR_MATCH_START) {
/* Had to match at start of word and didn't -- copy whole word. */
goto nosub;
} else if (pattern->flags & VAR_MATCH_END) {
/* Anchored at end, Find only place match could occur (leftLen
* characters from the end of the word) and see if it does. Note
* that because the $ will be left at the end of the lhs, we have
* to use strncmp. */
cp = word->s + (wordLen - pattern->leftLen);
if (cp >= word->s &&
strncmp(cp, pattern->lhs, pattern->leftLen) == 0) {
/* Match found. If we will place characters in the buffer,
* add a space before hand as indicated by addSpace, then
* stuff in the initial, unmatched part of the word followed
* by the right-hand-side. */
if (((cp - word->s) + pattern->rightLen) != 0) {
if (addSpace)
Buf_AddSpace(buf);
addSpace = true;
}
Buf_Addi(buf, word->s, cp);
Buf_AddChars(buf, pattern->rightLen, pattern->rhs);
pattern->flags |= VAR_SUB_MATCHED;
} else {
/* Had to match at end and didn't. Copy entire word. */
goto nosub;
}
} else {
/* Pattern is unanchored: search for the pattern in the word using
* strstr, copying unmatched portions and the
* right-hand-side for each match found, handling non-global
* substitutions correctly, etc. When the loop is done, any
* remaining part of the word (word and wordLen are adjusted
* accordingly through the loop) is copied straight into the
* buffer.
* addSpace is set to false as soon as a space is added to the
* buffer. */
bool done;
size_t origSize;
done = false;
origSize = Buf_Size(buf);
while (!done) {
cp = strstr(word->s, pattern->lhs);
if (cp != NULL) {
if (addSpace && (cp - word->s) + pattern->rightLen != 0){
Buf_AddSpace(buf);
addSpace = false;
}
Buf_Addi(buf, word->s, cp);
Buf_AddChars(buf, pattern->rightLen, pattern->rhs);
wordLen -= (cp - word->s) + pattern->leftLen;
word->s = cp + pattern->leftLen;
if (wordLen == 0 || (pattern->flags & VAR_SUB_GLOBAL) == 0)
done = true;
pattern->flags |= VAR_SUB_MATCHED;
} else
done = true;
}
if (wordLen != 0) {
if (addSpace)
Buf_AddSpace(buf);
Buf_AddChars(buf, wordLen, word->s);
}
/* If added characters to the buffer, need to add a space
* before we add any more. If we didn't add any, just return
* the previous value of addSpace. */
return Buf_Size(buf) != origSize || addSpace;
}
return addSpace;
}
nosub:
if (addSpace)
Buf_AddSpace(buf);
Buf_AddChars(buf, wordLen, word->s);
return true;
}
/*-
*-----------------------------------------------------------------------
* VarREError --
* Print the error caused by a regcomp or regexec call.
*-----------------------------------------------------------------------
*/
static void
VarREError(int err, regex_t *pat, const char *str)
{
char *errbuf;
int errlen;
errlen = regerror(err, pat, 0, 0);
errbuf = emalloc(errlen);
regerror(err, pat, errbuf, errlen);
Error("%s: %s", str, errbuf);
free(errbuf);
}
/*-
*-----------------------------------------------------------------------
* VarRESubstitute --
* Perform a regex substitution on the given word, placing the
* result in the passed buffer.
*-----------------------------------------------------------------------
*/
static bool
VarRESubstitute(struct Name *word, bool addSpace, Buffer buf, void *patternp)
{
VarREPattern *pat;
int xrv;
const char *wp;
char *rp;
int added;
#define MAYBE_ADD_SPACE() \
if (addSpace && !added) \
Buf_AddSpace(buf); \
added = 1
added = 0;
wp = word->s;
pat = patternp;
if ((pat->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) ==
(VAR_SUB_ONE|VAR_SUB_MATCHED))
xrv = REG_NOMATCH;
else {
tryagain:
xrv = regexec(&pat->re, wp, pat->nsub, pat->matches, 0);
}
switch (xrv) {
case 0:
pat->flags |= VAR_SUB_MATCHED;
if (pat->matches[0].rm_so > 0) {
MAYBE_ADD_SPACE();
Buf_AddChars(buf, pat->matches[0].rm_so, wp);
}
for (rp = pat->replace; *rp; rp++) {
if (*rp == '\\' && (rp[1] == '&' || rp[1] == '\\')) {
MAYBE_ADD_SPACE();
Buf_AddChar(buf,rp[1]);
rp++;
}
else if (*rp == '&' ||
(*rp == '\\' && ISDIGIT(rp[1]))) {
int n;
const char *subbuf;
int sublen;
char errstr[3];
if (*rp == '&') {
n = 0;
errstr[0] = '&';
errstr[1] = '\0';
} else {
n = rp[1] - '0';
errstr[0] = '\\';
errstr[1] = rp[1];
errstr[2] = '\0';
rp++;
}
if (n >= pat->nsub) {
Error("No subexpression %s",
&errstr[0]);
subbuf = "";
sublen = 0;
} else if (pat->matches[n].rm_so == -1 &&
pat->matches[n].rm_eo == -1) {
Error("No match for subexpression %s",
&errstr[0]);
subbuf = "";
sublen = 0;
} else {
subbuf = wp + pat->matches[n].rm_so;
sublen = pat->matches[n].rm_eo -
pat->matches[n].rm_so;
}
if (sublen > 0) {
MAYBE_ADD_SPACE();
Buf_AddChars(buf, sublen, subbuf);
}
} else {
MAYBE_ADD_SPACE();
Buf_AddChar(buf, *rp);
}
}
wp += pat->matches[0].rm_eo;
if (pat->flags & VAR_SUB_GLOBAL) {
/* like most modern tools, empty string matches
* should advance one char at a time...
*/
if (pat->matches[0].rm_eo == 0) {
if (*wp) {
MAYBE_ADD_SPACE();
Buf_AddChar(buf, *wp++);
} else
break;
}
goto tryagain;
}
if (*wp) {
MAYBE_ADD_SPACE();
Buf_AddString(buf, wp);
}
break;
default:
VarREError(xrv, &pat->re, "Unexpected regex error");
/* FALLTHROUGH */
case REG_NOMATCH:
if (*wp) {
MAYBE_ADD_SPACE();
Buf_AddString(buf, wp);
}
break;
}
return addSpace||added;
}
/*-
*-----------------------------------------------------------------------
* VarModify --
* Modify each of the words of the passed string using the given
* function. Used to implement all modifiers.
*
* Results:
* A string of all the words modified appropriately.
*-----------------------------------------------------------------------
*/
static char *
VarModify(char *str, /* String whose words should be trimmed */
/* Function to use to modify them */
bool (*modProc)(struct Name *, bool, Buffer, void *),
void *datum) /* Datum to pass it */
{
BUFFER buf; /* Buffer for the new string */
bool addSpace; /* true if need to add a space to the
* buffer before adding the trimmed
* word */
struct Name word;
Buf_Init(&buf, 0);
addSpace = false;
word.e = str;
while ((word.s = iterate_words(&word.e)) != NULL) {
char termc;
termc = *word.e;
*((char *)(word.e)) = '\0';
addSpace = (*modProc)(&word, addSpace, &buf, datum);
*((char *)(word.e)) = termc;
}
return Buf_Retrieve(&buf);
}
/*-
*-----------------------------------------------------------------------
* VarGetPattern --
* Pass through the tstr looking for 1) escaped delimiters,
* '$'s and backslashes (place the escaped character in
* uninterpreted) and 2) unescaped $'s that aren't before
* the delimiter (expand the variable substitution).
* Return the expanded string or NULL if the delimiter was missing
* If pattern is specified, handle escaped ampersands, and replace
* unescaped ampersands with the lhs of the pattern.
*
* Results:
* A string of all the words modified appropriately.
* If length is specified, return the string length of the buffer
*-----------------------------------------------------------------------
*/
static char *
VarGetPattern(SymTable *ctxt, int err, const char **tstr, int delim1,
int delim2, size_t *length, VarPattern *pattern)
{
const char *cp;
char *result;
BUFFER buf;
size_t junk;
Buf_Init(&buf, 0);
if (length == NULL)
length = &junk;
#define IS_A_MATCH(cp, delim1, delim2) \
(cp[0] == '\\' && (cp[1] == delim1 || cp[1] == delim2 || \
cp[1] == '\\' || cp[1] == '$' || (pattern && cp[1] == '&')))
/*
* Skim through until the matching delimiter is found;
* pick up variable substitutions on the way. Also allow
* backslashes to quote the delimiter, $, and \, but don't
* touch other backslashes.
*/
for (cp = *tstr; *cp != '\0' && *cp != delim1 && *cp != delim2; cp++) {
if (IS_A_MATCH(cp, delim1, delim2)) {
Buf_AddChar(&buf, cp[1]);
cp++;
} else if (*cp == '$') {
/* Allowed at end of pattern */
if (cp[1] == delim1 || cp[1] == delim2)
Buf_AddChar(&buf, *cp);
else {
size_t len;
/* If unescaped dollar sign not before the
* delimiter, assume it's a variable
* substitution and recurse. */
(void)Var_ParseBuffer(&buf, cp, ctxt, err,
&len);
cp += len - 1;
}
} else if (pattern && *cp == '&')
Buf_AddChars(&buf, pattern->leftLen, pattern->lhs);
else
Buf_AddChar(&buf, *cp);
}
*length = Buf_Size(&buf);
result = Buf_Retrieve(&buf);
if (*cp != delim1 && *cp != delim2) {
*tstr = cp;
*length = 0;
free(result);
return NULL;
}
else {
*tstr = ++cp;
return result;
}
}
/*-
*-----------------------------------------------------------------------
* VarQuote --
* Quote shell meta-characters in the string
*
* Results:
* The quoted string
*-----------------------------------------------------------------------
*/
static char *
VarQuote(const char *str, const struct Name *n UNUSED, void *islistp)
{
int *p = islistp;
int islist = *p;
BUFFER buf;
/* This should cover most shells :-( */
static char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";
char *rep = meta;
if (islist)
rep += 3;
Buf_Init(&buf, MAKE_BSIZE);
for (; *str; str++) {
if (strchr(rep, *str) != NULL)
Buf_AddChar(&buf, '\\');
Buf_AddChar(&buf, *str);
}
return Buf_Retrieve(&buf);
}
static void *
check_empty(const char **p, SymTable *ctxt UNUSED, bool b UNUSED, int endc)
{
dummy_arg->s = NULL;
if ((*p)[1] == endc || (*p)[1] == ':') {
(*p)++;
return dummy_arg;
} else
return NULL;
}
static void *
check_quote(const char **p, SymTable *ctxt UNUSED, bool b UNUSED, int endc)
{
int *qargs = emalloc(sizeof(int));
*qargs = 0;
if ((*p)[1] == 'L') {
*qargs = 1;
(*p)++;
}
if ((*p)[1] == endc || (*p)[1] == ':') {
(*p)++;
return qargs;
} else {
free(qargs);
return NULL;
}
}
static void *
check_shcmd(const char **p, SymTable *ctxt UNUSED, bool b UNUSED, int endc)
{
if ((*p)[1] == 'h' && ((*p)[2] == endc || (*p)[2] == ':')) {
(*p)+=2;
return dummy_arg;
} else
return NULL;
}
static char *
do_shcmd(const char *s, const struct Name *n UNUSED, void *arg UNUSED)
{
char *err;
char *t;
t = Cmd_Exec(s, &err);
if (err)
Error(err, s);
return t;
}
static void *
get_stringarg(const char **p, SymTable *ctxt UNUSED, bool b UNUSED, int endc)
{
const char *cp;
char *s;
for (cp = *p + 1; *cp != ':' && *cp != endc; cp++) {
if (*cp == '\\') {
if (cp[1] == ':' || cp[1] == endc || cp[1] == '\\')
cp++;
} else if (*cp == '\0')
return NULL;
}
s = escape_dupi(*p+1, cp, ":)}");
*p = cp;
return s;
}
static void
free_stringarg(void *arg)
{
free(arg);
}
static char *
do_upper(const char *s, const struct Name *n UNUSED, void *arg UNUSED)
{
size_t len, i;
char *t;
len = strlen(s);
t = emalloc(len+1);
for (i = 0; i < len; i++)
t[i] = TOUPPER(s[i]);
t[len] = '\0';
return t;
}
static char *
do_lower(const char *s, const struct Name *n UNUSED, void *arg UNUSED)
{
size_t len, i;
char *t;
len = strlen(s);
t = emalloc(len+1);
for (i = 0; i < len; i++)
t[i] = TOLOWER(s[i]);
t[len] = '\0';
return t;
}
static void *
get_patternarg(const char **p, SymTable *ctxt, bool err, int endc)
{
return common_get_patternarg(p, ctxt, err, endc, false);
}
/* Extract anchors */
static void *
get_spatternarg(const char **p, SymTable *ctxt, bool err, int endc)
{
return common_get_patternarg(p, ctxt, err, endc, true);
}
static void
free_looparg(void *arg)
{
struct LoopStuff *l = arg;
Var_DeleteLoopVar(l->var);
free(l->expand);
}
static char *
LoopGrab(const char **s)
{
const char *p, *start;
start = *s;
for (p = start; *p != '@'; p++) {
if (*p == '\\')
p++;
if (*p == 0)
return NULL;
}
*s = p+1;
return escape_dupi(start, p, "@\\");
}
static void *
get_loop(const char **p, SymTable *ctxt UNUSED, bool err, int endc)
{
static struct LoopStuff loop;
const char *s;
const char *var;
s = *p +1;
loop.var = NULL;
loop.expand = NULL;
loop.err = err;
var = LoopGrab(&s);
if (var != NULL) {
loop.expand = LoopGrab(&s);
if (*s == endc || *s == ':') {
*p = s;
loop.var = Var_NewLoopVar(var, NULL);
return &loop;
}
}
free_looparg(&loop);
return NULL;
}
static void *
common_get_patternarg(const char **p, SymTable *ctxt, bool err, int endc,
bool dosubst)
{
VarPattern *pattern;
char delim;
const char *s;
pattern = emalloc(sizeof(VarPattern));
pattern->flags = 0;
s = *p;
delim = s[1];
if (delim == '\0')
return NULL;
s += 2;
pattern->rhs = NULL;
pattern->lhs = VarGetPattern(ctxt, err, &s, delim, delim,
&pattern->leftLen, NULL);
pattern->lbuffer = pattern->lhs;
if (pattern->lhs != NULL) {
if (dosubst && pattern->leftLen > 0) {
if (pattern->lhs[pattern->leftLen-1] == '$') {
pattern->leftLen--;
pattern->flags |= VAR_MATCH_END;
}
if (pattern->lhs[0] == '^') {
pattern->lhs++;
pattern->leftLen--;
pattern->flags |= VAR_MATCH_START;
}
}
pattern->rhs = VarGetPattern(ctxt, err, &s, delim, delim,
&pattern->rightLen, dosubst ? pattern: NULL);
if (pattern->rhs != NULL) {
/* Check for global substitution. If 'g' after the
* final delimiter, substitution is global and is
* marked that way. */
for (;; s++) {
switch (*s) {
case 'g':
pattern->flags |= VAR_SUB_GLOBAL;
continue;
case '1':
pattern->flags |= VAR_SUB_ONE;
continue;
}
break;
}
if (*s == endc || *s == ':') {
*p = s;
return pattern;
}
}
}
free_patternarg(pattern);
return NULL;
}
static void *
assign_get_value(const char **p, SymTable *ctxt, bool err, int endc)
{
const char *s;
int flags;
VarPattern *arg;
s = *p + 1;
if (s[0] == '=')
flags = VAR_EQUAL;
else if (s[0] == '?' && s[1] == '=')
flags = VAR_MAY_EQUAL;
else if (s[0] == '+' && s[1] == '=')
flags = VAR_ADD_EQUAL;
else if (s[0] == '!' && s[1] == '=')
flags = VAR_BANG_EQUAL;
else
return NULL;
arg = get_value(&s, ctxt, err, endc);
if (arg != NULL) {
*p = s;
arg->flags = flags;
}
return arg;
}
static void *
get_value(const char **p, SymTable *ctxt, bool err, int endc)
{
VarPattern *pattern;
const char *s;
pattern = emalloc(sizeof(VarPattern));
s = *p + 1;
pattern->rhs = NULL;
pattern->lbuffer = VarGetPattern(ctxt, err, &s, ':', endc,
&pattern->leftLen, NULL);
if (s[-1] == endc || s[-1] == ':') {
*p = s-1;
return pattern;
}
free_patternarg(pattern);
return NULL;
}
static void *
get_cmd(const char **p, SymTable *ctxt, bool err, int endc UNUSED)
{
VarPattern *pattern;
const char *s;
pattern = emalloc(sizeof(VarPattern));
s = *p + 1;
pattern->rhs = NULL;
pattern->lbuffer = VarGetPattern(ctxt, err, &s, '!', '!',
&pattern->leftLen, NULL);
if (s[-1] == '!') {
*p = s-1;
return pattern;
}
free_patternarg(pattern);
return NULL;
}
static void
free_patternarg(void *p)
{
VarPattern *vp = p;
free(vp->lbuffer);
free(vp->rhs);
free(vp);
}
static char *
do_regex(const char *s, const struct Name *n UNUSED, void *arg)
{
VarREPattern p2;
VarPattern *p = arg;
int error;
char *result;
error = regcomp(&p2.re, p->lhs, REG_EXTENDED);
if (error) {
VarREError(error, &p2.re, "RE substitution error");
return var_Error;
}
p2.nsub = p2.re.re_nsub + 1;
p2.replace = p->rhs;
p2.flags = p->flags;
if (p2.nsub < 1)
p2.nsub = 1;
if (p2.nsub > 10)
p2.nsub = 10;
p2.matches = ereallocarray(NULL, p2.nsub, sizeof(regmatch_t));
result = VarModify((char *)s, VarRESubstitute, &p2);
regfree(&p2.re);
free(p2.matches);
return result;
}
char *
VarModifiers_Apply(char *str, const struct Name *name, SymTable *ctxt,
bool err, bool *freePtr, const char **pscan, int paren)
{
const char *tstr;
bool atstart; /* Some ODE modifiers only make sense at start */
char endc = paren == '(' ? ')' : '}';
const char *start = *pscan;
tstr = start;
/*
* Now we need to apply any modifiers the user wants applied.
* These are:
* :M<pattern> words which match the given <pattern>.
* <pattern> is of the standard file
* wildcarding form.
* :S<d><pat1><d><pat2><d>[g]
* Substitute <pat2> for <pat1> in the
* value
* :C<d><pat1><d><pat2><d>[g]
* Substitute <pat2> for regex <pat1> in
* the value
* :H Substitute the head of each word
* :T Substitute the tail of each word
* :E Substitute the extension (minus '.') of
* each word
* :R Substitute the root of each word
* (pathname minus the suffix).
* :lhs=rhs Like :S, but the rhs goes to the end of
* the invocation.
*/
atstart = true;
while (*tstr != endc && *tstr != '\0') {
struct modifier *mod;
void *arg;
char *newStr;
tstr++;
if (DEBUG(VAR)) {
if (str != NULL)
printf("Applying :%c to \"%s\"\n", *tstr, str);
else
printf("Applying :%c\n", *tstr);
}
mod = choose_mod[(unsigned char)*tstr];
arg = NULL;
if (mod != NULL && (!mod->atstart || atstart))
arg = mod->getarg(&tstr, ctxt, err, endc);
if (FEATURES(FEATURE_SYSVVARSUB) && arg == NULL) {
mod = &sysv_mod;
arg = mod->getarg(&tstr, ctxt, err, endc);
}
atstart = false;
if (arg != NULL) {
if (str != NULL || (mod->atstart && name != NULL)) {
if (mod->word_apply != NULL) {
newStr = VarModify(str,
mod->word_apply, arg);
if (mod->apply != NULL) {
char *newStr2;
newStr2 = mod->apply(newStr,
name, arg);
free(newStr);
newStr = newStr2;
}
} else
newStr = mod->apply(str, name, arg);
if (*freePtr)
free(str);
str = newStr;
if (str != var_Error)
*freePtr = true;
else
*freePtr = false;
}
if (mod->freearg != NULL)
mod->freearg(arg);
} else {
Error("Bad modifier: %s", tstr);
/* Try skipping to end of var... */
while (*tstr != endc && *tstr != '\0')
tstr++;
if (str != NULL && *freePtr)
free(str);
str = var_Error;
*freePtr = false;
break;
}
if (DEBUG(VAR) && str != NULL)
printf("Result is \"%s\"\n", str);
}
if (*tstr == '\0')
Parse_Error(PARSE_FATAL, "Unclosed variable specification");
else
tstr++;
*pscan = tstr;
return str;
}
char *
Var_GetHead(char *s)
{
return VarModify(s, VarHead, NULL);
}
char *
Var_GetTail(char *s)
{
return VarModify(s, VarTail, NULL);
}
|
5905d8619df3c2e3298f050d67547c6fee511083
|
e1ea5f615a2ee3130926cdb506d4804742bc9fee
|
/iocore/cache/P_CacheHttp.h
|
55234ec06eddce7baf400f2e06b8f8c2d9a82dda
|
[
"TCL",
"LicenseRef-scancode-proprietary-license",
"BSD-3-Clause",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"ISC",
"OpenSSL",
"MIT",
"HPND",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown"
] |
permissive
|
apache/trafficserver
|
1507804151ab2c2ac50012fdecee6200f2c52c1f
|
c5d7b19d60646de902fc847f80f57030779a4bfc
|
refs/heads/master
| 2023-08-31T20:10:00.381763
| 2023-08-31T19:15:34
| 2023-08-31T19:15:34
| 356,066
| 1,570
| 981
|
Apache-2.0
| 2023-09-14T21:04:36
| 2009-10-31T08:00:10
|
C++
|
UTF-8
|
C
| false
| false
| 2,075
|
h
|
P_CacheHttp.h
|
/** @file
A brief file description
@section license License
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once
#include "P_CacheArray.h"
#include "HTTP.h"
#include "URL.h"
using CacheURL = URL;
using CacheHTTPHdr = HTTPHdr;
using CacheHTTPInfo = HTTPInfo;
#define OFFSET_BITS 24
enum {
OWNER_NONE = 0,
OWNER_CACHE = 1,
OWNER_HTTP = 2,
};
struct vec_info {
CacheHTTPInfo alternate;
};
struct CacheHTTPInfoVector {
void *magic = nullptr;
CacheHTTPInfoVector();
~CacheHTTPInfoVector();
int
count()
{
return xcount;
}
int insert(CacheHTTPInfo *info, int id = -1);
CacheHTTPInfo *get(int idx);
void detach(int idx, CacheHTTPInfo *r);
void remove(int idx, bool destroy);
void clear(bool destroy = true);
void
reset()
{
xcount = 0;
data.clear();
}
void print(char *buffer, size_t buf_size, bool temps = true);
int marshal_length();
int marshal(char *buf, int length);
uint32_t get_handles(const char *buf, int length, RefCountObj *block_ptr = nullptr);
int unmarshal(const char *buf, int length, RefCountObj *block_ptr);
CacheArray<vec_info> data;
int xcount = 0;
Ptr<RefCountObj> vector_buf;
};
inline CacheHTTPInfo *
CacheHTTPInfoVector::get(int idx)
{
ink_assert(idx >= 0);
ink_assert(idx < xcount);
return &data[idx].alternate;
}
|
b8d2021299e01edea55c746494805286be657128
|
fa1ad2e2ac7e376fc7cb3b3a6e1bb88eed3e80be
|
/govern/data-security/krb-1.2.1/src/kadmin/server/auth_acl.c
|
a1ed032d43f91b9ffbbd25248834e916eb88d3fe
|
[
"Apache-2.0",
"BSD-3-Clause",
"MIT",
"BSD-4-Clause",
"LicenseRef-scancode-generic-export-compliance",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-mit-old-style",
"BSD-4-Clause-UC",
"LicenseRef-scancode-rsa-1990",
"MIT-CMU",
"LicenseRef-scancode-mit-no-advert-export-control",
"CC-BY-SA-3.0",
"LicenseRef-scancode-mit-modification-obligations",
"LicenseRef-scancode-proprietary-license",
"GPL-2.0-or-later",
"LicenseRef-scancode-michigan-disclaimer",
"ISC",
"LicenseRef-scancode-nrl-permission",
"FreeBSD-DOC",
"LicenseRef-scancode-rsa-md4",
"RSA-MD",
"OLDAP-2.8",
"FSFULLRWD",
"BSD-2-Clause",
"LicenseRef-scancode-brian-gladman"
] |
permissive
|
alldatacenter/alldata
|
7bc7713c9f1d56ad6b8e59ea03206d1073b7e047
|
8d5f9a2d49ab8f9e85ccf058cb02c2fda287afc6
|
refs/heads/master
| 2023-08-05T07:32:25.442740
| 2023-08-03T13:17:24
| 2023-08-03T13:17:24
| 213,321,771
| 774
| 250
|
Apache-2.0
| 2023-09-06T17:35:32
| 2019-10-07T07:36:18
| null |
UTF-8
|
C
| false
| false
| 23,693
|
c
|
auth_acl.c
|
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* kadmin/server/auth_acl.c - ACL kadm5_auth module */
/*
* Copyright 1995-2004, 2007, 2008, 2017 by the Massachusetts Institute of
* Technology. All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#include "k5-int.h"
#include <syslog.h>
#include <kadm5/admin.h>
#include <krb5/kadm5_auth_plugin.h>
#include "adm_proto.h"
#include <ctype.h>
#include "auth.h"
/*
* Access control bits.
*/
#define ACL_ADD 1
#define ACL_DELETE 2
#define ACL_MODIFY 4
#define ACL_CHANGEPW 8
/* #define ACL_CHANGE_OWN_PW 16 */
#define ACL_INQUIRE 32
#define ACL_EXTRACT 64
#define ACL_LIST 128
#define ACL_SETKEY 256
#define ACL_IPROP 512
#define ACL_ALL_MASK (ACL_ADD | \
ACL_DELETE | \
ACL_MODIFY | \
ACL_CHANGEPW | \
ACL_INQUIRE | \
ACL_LIST | \
ACL_IPROP | \
ACL_SETKEY)
struct acl_op_table {
char op;
uint32_t mask;
};
struct acl_entry {
struct acl_entry *next;
krb5_principal client;
uint32_t op_allowed;
krb5_principal target;
struct kadm5_auth_restrictions *rs;
};
static const struct acl_op_table acl_op_table[] = {
{ 'a', ACL_ADD },
{ 'd', ACL_DELETE },
{ 'm', ACL_MODIFY },
{ 'c', ACL_CHANGEPW },
{ 'i', ACL_INQUIRE },
{ 'l', ACL_LIST },
{ 'p', ACL_IPROP },
{ 's', ACL_SETKEY },
{ 'x', ACL_ALL_MASK },
{ '*', ACL_ALL_MASK },
{ 'e', ACL_EXTRACT },
{ '\0', 0 }
};
struct wildstate {
int nwild;
const krb5_data *backref[9];
};
struct acl_state {
struct acl_entry *list;
};
/*
* Get a line from the ACL file. Lines ending with \ are continued on the next
* line. The caller should set *lineno to 1 and *incr to 0 before the first
* call. On successful return, *lineno will be the line number of the line
* read. Return a pointer to the line on success, or NULL on end of file or
* read failure.
*/
static char *
get_line(FILE *fp, const char *fname, int *lineno, int *incr)
{
const int chunksize = 128;
struct k5buf buf;
size_t old_len;
char *p;
/* Increment *lineno by the number of newlines from the last line. */
*lineno += *incr;
*incr = 0;
k5_buf_init_dynamic(&buf);
for (;;) {
/* Read at least part of a line into the buffer. */
old_len = buf.len;
p = k5_buf_get_space(&buf, chunksize);
if (p == NULL)
return NULL;
if (fgets(p, chunksize, fp) == NULL) {
/* We reached the end. Return a final unterminated line, if there
* is one and it's not a comment. */
k5_buf_truncate(&buf, old_len);
if (buf.len > 0 && *(char *)buf.data != '#')
return buf.data;
k5_buf_free(&buf);
return NULL;
}
/* Set the buffer length based on the actual amount read. */
k5_buf_truncate(&buf, old_len + strlen(p));
p = buf.data;
if (buf.len > 0 && p[buf.len - 1] == '\n') {
/* We have a complete raw line in the buffer. */
(*incr)++;
k5_buf_truncate(&buf, buf.len - 1);
if (buf.len > 0 && p[buf.len - 1] == '\\') {
/* This line has a continuation marker; keep reading. */
k5_buf_truncate(&buf, buf.len - 1);
} else if (buf.len == 0 || *p == '#') {
/* This line is empty or a comment. Start over. */
*lineno += *incr;
*incr = 0;
k5_buf_truncate(&buf, 0);
} else {
return buf.data;
}
}
}
}
/*
* Parse a restrictions field. Return NULL on failure.
*
* Allowed restrictions are:
* [+-]flagname (recognized by krb5_flagspec_to_mask)
* flag is forced to indicated value
* -clearpolicy policy is forced clear
* -policy pol policy is forced to be "pol"
* -{expire,pwexpire,maxlife,maxrenewlife} deltat
* associated value will be forced to
* MIN(deltat, requested value)
*/
static struct kadm5_auth_restrictions *
parse_restrictions(const char *str, const char *fname)
{
char *copy = NULL, *token, *arg, *save;
const char *delims = "\t\n\f\v\r ,";
krb5_deltat delta;
struct kadm5_auth_restrictions *rs;
copy = strdup(str);
if (copy == NULL)
return NULL;
rs = calloc(1, sizeof(*rs));
if (rs == NULL) {
free(copy);
return NULL;
}
rs->forbid_attrs = ~(krb5_flags)0;
for (token = strtok_r(copy, delims, &save); token != NULL;
token = strtok_r(NULL, delims, &save)) {
if (krb5_flagspec_to_mask(token, &rs->require_attrs,
&rs->forbid_attrs) == 0) {
rs->mask |= KADM5_ATTRIBUTES;
continue;
}
if (strcmp(token, "-clearpolicy") == 0) {
rs->mask |= KADM5_POLICY_CLR;
continue;
}
/* Everything else needs an argument. */
arg = strtok_r(NULL, delims, &save);
if (arg == NULL)
goto error;
if (strcmp(token, "-policy") == 0) {
if (rs->policy != NULL)
goto error;
rs->policy = strdup(arg);
if (rs->policy == NULL)
goto error;
rs->mask |= KADM5_POLICY;
continue;
}
/* All other arguments must be a deltat. */
if (krb5_string_to_deltat(arg, &delta) != 0)
goto error;
if (strcmp(token, "-expire") == 0) {
rs->princ_lifetime = delta;
rs->mask |= KADM5_PRINC_EXPIRE_TIME;
} else if (strcmp(token, "-pwexpire") == 0) {
rs->pw_lifetime = delta;
rs->mask |= KADM5_PW_EXPIRATION;
} else if (strcmp(token, "-maxlife") == 0) {
rs->max_life = delta;
rs->mask |= KADM5_MAX_LIFE;
} else if (strcmp(token, "-maxrenewlife") == 0) {
rs->max_renewable_life = delta;
rs->mask |= KADM5_MAX_RLIFE;
} else {
goto error;
}
}
free(copy);
return rs;
error:
krb5_klog_syslog(LOG_ERR, _("%s: invalid restrictions: %s"), fname, str);
free(copy);
free(rs->policy);
free(rs);
return NULL;
}
static void
free_acl_entry(struct acl_entry *entry)
{
krb5_free_principal(NULL, entry->client);
krb5_free_principal(NULL, entry->target);
if (entry->rs != NULL) {
free(entry->rs->policy);
free(entry->rs);
}
free(entry);
}
/* Parse the four fields of an ACL entry and return a structure representing
* it. Log a message and return NULL on error. */
static struct acl_entry *
parse_entry(krb5_context context, const char *client, const char *ops,
const char *target, const char *rs, const char *line,
const char *fname)
{
struct acl_entry *entry;
const char *op;
char rop;
int t;
entry = calloc(1, sizeof(*entry));
if (entry == NULL)
return NULL;
for (op = ops; *op; op++) {
rop = isupper((unsigned char)*op) ? tolower((unsigned char)*op) : *op;
for (t = 0; acl_op_table[t].op; t++) {
if (rop == acl_op_table[t].op) {
if (rop == *op)
entry->op_allowed |= acl_op_table[t].mask;
else
entry->op_allowed &= ~acl_op_table[t].mask;
break;
}
}
if (!acl_op_table[t].op) {
krb5_klog_syslog(LOG_ERR,
_("Unrecognized ACL operation '%c' in %s"),
*op, line);
goto error;
}
}
if (strcmp(client, "*") != 0) {
if (krb5_parse_name(context, client, &entry->client) != 0) {
krb5_klog_syslog(LOG_ERR, _("Cannot parse client principal '%s'"),
client);
goto error;
}
}
if (target != NULL && strcmp(target, "*") != 0) {
if (krb5_parse_name(context, target, &entry->target) != 0) {
krb5_klog_syslog(LOG_ERR, _("Cannot parse target principal '%s'"),
target);
goto error;
}
}
if (rs != NULL) {
entry->rs = parse_restrictions(rs, fname);
if (entry->rs == NULL)
goto error;
}
return entry;
error:
free_acl_entry(entry);
return NULL;
}
/* Parse the contents of an ACL line. */
static struct acl_entry *
parse_line(krb5_context context, const char *line, const char *fname)
{
struct acl_entry *entry = NULL;
char *copy;
char *client, *client_end, *ops, *ops_end, *target, *target_end, *rs, *end;
const char *ws = "\t\n\f\v\r ,";
/*
* Format:
* entry ::= [<whitespace>] <principal> <whitespace> <opstring>
* [<whitespace> <target> [<whitespace> <restrictions>
* [<whitespace>]]]
*/
/* Make a copy and remove any trailing whitespace. */
copy = strdup(line);
if (copy == NULL)
return NULL;
end = copy + strlen(copy);
while (end > copy && isspace(end[-1]))
*--end = '\0';
/* Find the beginning and end of each field. The end of restrictions is
* the end of copy. */
client = copy + strspn(copy, ws);
client_end = client + strcspn(client, ws);
ops = client_end + strspn(client_end, ws);
ops_end = ops + strcspn(ops, ws);
target = ops_end + strspn(ops_end, ws);
target_end = target + strcspn(target, ws);
rs = target_end + strspn(target_end, ws);
/* Terminate the first three fields. */
*client_end = *ops_end = *target_end = '\0';
/* The last two fields are optional; represent them as NULL if not present.
* The first two fields are required. */
if (*target == '\0')
target = NULL;
if (*rs == '\0')
rs = NULL;
if (*client != '\0' && *ops != '\0')
entry = parse_entry(context, client, ops, target, rs, line, fname);
free(copy);
return entry;
}
/* Free all ACL entries. */
static void
free_acl_entries(struct acl_state *state)
{
struct acl_entry *entry, *next;
for (entry = state->list; entry != NULL; entry = next) {
next = entry->next;
free_acl_entry(entry);
}
state->list = NULL;
}
/* Open and parse the ACL file. */
static krb5_error_code
load_acl_file(krb5_context context, const char *fname, struct acl_state *state)
{
krb5_error_code ret;
FILE *fp;
char *line;
struct acl_entry **entry_slot;
int lineno, incr;
state->list = NULL;
/* Open the ACL file for reading. */
fp = fopen(fname, "r");
if (fp == NULL) {
krb5_klog_syslog(LOG_ERR, _("%s while opening ACL file %s"),
error_message(errno), fname);
ret = errno;
k5_setmsg(context, errno, _("Cannot open %s: %s"), fname,
error_message(ret));
return ret;
}
set_cloexec_file(fp);
lineno = 1;
incr = 0;
entry_slot = &state->list;
/* Get a non-comment line. */
while ((line = get_line(fp, fname, &lineno, &incr)) != NULL) {
/* Parse it. Fail out on syntax error. */
*entry_slot = parse_line(context, line, fname);
if (*entry_slot == NULL) {
krb5_klog_syslog(LOG_ERR,
_("%s: syntax error at line %d <%.10s...>"),
fname, lineno, line);
k5_setmsg(context, EINVAL,
_("%s: syntax error at line %d <%.10s...>"),
fname, lineno, line);
free_acl_entries(state);
free(line);
fclose(fp);
return EINVAL;
}
entry_slot = &(*entry_slot)->next;
free(line);
}
fclose(fp);
return 0;
}
/*
* See if two data entries match. If e1 is a wildcard (matching a whole
* component only) and targetflag is false, save an alias to e2 into
* ws->backref. If e1 is a back-reference and targetflag is true, compare the
* appropriate entry in ws->backref to e2. If ws is NULL, do not store or
* match back-references.
*/
static krb5_boolean
match_data(const krb5_data *e1, const krb5_data *e2, krb5_boolean targetflag,
struct wildstate *ws)
{
int n;
if (data_eq_string(*e1, "*")) {
if (ws != NULL && !targetflag) {
if (ws->nwild < 9)
ws->backref[ws->nwild++] = e2;
}
return TRUE;
}
if (ws != NULL && targetflag && e1->length == 2 && e1->data[0] == '*' &&
e1->data[1] >= '1' && e1->data[1] <= '9') {
n = e1->data[1] - '1';
if (n >= ws->nwild)
return FALSE;
return data_eq(*e2, *ws->backref[n]);
} else {
return data_eq(*e2, *e1);
}
}
/* Return true if p1 matches p2. p1 may contain wildcards if targetflag is
* false, or backreferences if it is true. */
static krb5_boolean
match_princ(krb5_const_principal p1, krb5_const_principal p2,
krb5_boolean targetflag, struct wildstate *ws)
{
int i;
/* The principals must be of the same length. */
if (p1->length != p2->length)
return FALSE;
/* The realm must match, and does not interact with wildcard state. */
if (!match_data(&p1->realm, &p2->realm, targetflag, NULL))
return FALSE;
/* All components of the principals must match. */
for (i = 0; i < p1->length; i++) {
if (!match_data(&p1->data[i], &p2->data[i], targetflag, ws))
return FALSE;
}
return TRUE;
}
/* Find an ACL entry matching principal and target_principal. Return NULL if
* none is found. */
static struct acl_entry *
find_entry(struct acl_state *state, krb5_const_principal client,
krb5_const_principal target)
{
struct acl_entry *entry;
struct wildstate ws;
for (entry = state->list; entry != NULL; entry = entry->next) {
memset(&ws, 0, sizeof(ws));
if (entry->client != NULL) {
if (!match_princ(entry->client, client, FALSE, &ws))
continue;
}
if (entry->target != NULL) {
if (target == NULL)
continue;
if (!match_princ(entry->target, target, TRUE, &ws))
continue;
}
return entry;
}
return NULL;
}
/* Return true if op is permitted for this principal. Set *rs_out (if not
* NULL) according to any restrictions in the ACL entry. */
static krb5_error_code
acl_check(kadm5_auth_moddata data, uint32_t op, krb5_const_principal client,
krb5_const_principal target, struct kadm5_auth_restrictions **rs_out)
{
struct acl_entry *entry;
if (rs_out != NULL)
*rs_out = NULL;
entry = find_entry((struct acl_state *)data, client, target);
if (entry == NULL)
return KRB5_PLUGIN_NO_HANDLE;
if (!(entry->op_allowed & op))
return KRB5_PLUGIN_NO_HANDLE;
if (rs_out != NULL && entry->rs != NULL && entry->rs->mask)
*rs_out = entry->rs;
return 0;
}
static krb5_error_code
acl_init(krb5_context context, const char *acl_file,
kadm5_auth_moddata *data_out)
{
krb5_error_code ret;
struct acl_state *state;
*data_out = NULL;
if (acl_file == NULL)
return KRB5_PLUGIN_NO_HANDLE;
state = malloc(sizeof(*state));
state->list = NULL;
ret = load_acl_file(context, acl_file, state);
if (ret) {
free(state);
return ret;
}
*data_out = (kadm5_auth_moddata)state;
return 0;
}
static void
acl_fini(krb5_context context, kadm5_auth_moddata data)
{
if (data == NULL)
return;
free_acl_entries((struct acl_state *)data);
free(data);
}
static krb5_error_code
acl_addprinc(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target,
const struct _kadm5_principal_ent_t *ent, long mask,
struct kadm5_auth_restrictions **rs_out)
{
return acl_check(data, ACL_ADD, client, target, rs_out);
}
static krb5_error_code
acl_modprinc(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target,
const struct _kadm5_principal_ent_t *ent, long mask,
struct kadm5_auth_restrictions **rs_out)
{
return acl_check(data, ACL_MODIFY, client, target, rs_out);
}
static krb5_error_code
acl_setstr(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target,
const char *key, const char *value)
{
return acl_check(data, ACL_MODIFY, client, target, NULL);
}
static krb5_error_code
acl_cpw(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_CHANGEPW, client, target, NULL);
}
static krb5_error_code
acl_chrand(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_CHANGEPW, client, target, NULL);
}
static krb5_error_code
acl_setkey(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_SETKEY, client, target, NULL);
}
static krb5_error_code
acl_purgekeys(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_MODIFY, client, target, NULL);
}
static krb5_error_code
acl_delprinc(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_DELETE, client, target, NULL);
}
static krb5_error_code
acl_renprinc(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal src,
krb5_const_principal dest)
{
struct kadm5_auth_restrictions *rs;
if (acl_check(data, ACL_DELETE, client, src, NULL) == 0 &&
acl_check(data, ACL_ADD, client, dest, &rs) == 0 && rs == NULL)
return 0;
return KRB5_PLUGIN_NO_HANDLE;
}
static krb5_error_code
acl_getprinc(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_INQUIRE, client, target, NULL);
}
static krb5_error_code
acl_getstrs(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_INQUIRE, client, target, NULL);
}
static krb5_error_code
acl_extract(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, krb5_const_principal target)
{
return acl_check(data, ACL_EXTRACT, client, target, NULL);
}
static krb5_error_code
acl_listprincs(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client)
{
return acl_check(data, ACL_LIST, client, NULL, NULL);
}
static krb5_error_code
acl_addpol(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, const char *policy,
const struct _kadm5_policy_ent_t *ent, long mask)
{
return acl_check(data, ACL_ADD, client, NULL, NULL);
}
static krb5_error_code
acl_modpol(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, const char *policy,
const struct _kadm5_policy_ent_t *ent, long mask)
{
return acl_check(data, ACL_MODIFY, client, NULL, NULL);
}
static krb5_error_code
acl_delpol(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, const char *policy)
{
return acl_check(data, ACL_DELETE, client, NULL, NULL);
}
static krb5_error_code
acl_getpol(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client, const char *policy,
const char *client_policy)
{
return acl_check(data, ACL_INQUIRE, client, NULL, NULL);
}
static krb5_error_code
acl_listpols(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client)
{
return acl_check(data, ACL_LIST, client, NULL, NULL);
}
static krb5_error_code
acl_iprop(krb5_context context, kadm5_auth_moddata data,
krb5_const_principal client)
{
return acl_check(data, ACL_IPROP, client, NULL, NULL);
}
krb5_error_code
kadm5_auth_acl_initvt(krb5_context context, int maj_ver, int min_ver,
krb5_plugin_vtable vtable)
{
kadm5_auth_vtable vt;
if (maj_ver != 1)
return KRB5_PLUGIN_VER_NOTSUPP;
vt = (kadm5_auth_vtable)vtable;
vt->name = "acl";
vt->init = acl_init;
vt->fini = acl_fini;
vt->addprinc = acl_addprinc;
vt->modprinc = acl_modprinc;
vt->setstr = acl_setstr;
vt->cpw = acl_cpw;
vt->chrand = acl_chrand;
vt->setkey = acl_setkey;
vt->purgekeys = acl_purgekeys;
vt->delprinc = acl_delprinc;
vt->renprinc = acl_renprinc;
vt->getprinc = acl_getprinc;
vt->getstrs = acl_getstrs;
vt->extract = acl_extract;
vt->listprincs = acl_listprincs;
vt->addpol = acl_addpol;
vt->modpol = acl_modpol;
vt->delpol = acl_delpol;
vt->getpol = acl_getpol;
vt->listpols = acl_listpols;
vt->iprop = acl_iprop;
return 0;
}
|
b8c13d3d78bd021176d5eb9c2234f1dbfad1736c
|
17227ad12bc0826771ac6ac2b95dddd9517d0117
|
/PVSupport/Sources/retro/libretro-common/hash/rhash.c
|
a36c27d69858c0646cb0d6bebd5a8b59b7ab4115
|
[
"BSD-2-Clause"
] |
permissive
|
Provenance-Emu/Provenance
|
e38f7c81e784455d4876f8a2ff999baca0135199
|
c6f49d7921ee27eb8c0c34ca95ec9dc7baf584c1
|
refs/heads/develop
| 2023-08-17T05:04:01.554294
| 2023-07-01T07:58:33
| 2023-07-01T07:58:33
| 12,416,862
| 2,367
| 364
|
NOASSERTION
| 2023-08-01T07:42:35
| 2013-08-27T20:34:36
|
C
|
UTF-8
|
C
| false
| false
| 17,888
|
c
|
rhash.c
|
/* Copyright (C) 2010-2015 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (rhash.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <stdio.h>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include <rhash.h>
#include <retro_miscellaneous.h>
#include <retro_endianness.h>
#include <streams/file_stream.h>
#define LSL32(x, n) ((uint32_t)(x) << (n))
#define LSR32(x, n) ((uint32_t)(x) >> (n))
#define ROR32(x, n) (LSR32(x, n) | LSL32(x, 32 - (n)))
/* First 32 bits of the fractional parts of the square roots of the first 8 primes 2..19 */
static const uint32_t T_H[8] = {
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
};
/* First 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311 */
static const uint32_t T_K[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
};
/* SHA256 implementation from bSNES. Written by valditx. */
struct sha256_ctx
{
union
{
uint8_t u8[64];
uint32_t u32[16];
} in;
unsigned inlen;
uint32_t w[64];
uint32_t h[8];
uint64_t len;
};
static void sha256_init(struct sha256_ctx *p)
{
memset(p, 0, sizeof(struct sha256_ctx));
memcpy(p->h, T_H, sizeof(T_H));
}
static void sha256_block(struct sha256_ctx *p)
{
unsigned i;
uint32_t s0, s1;
uint32_t a, b, c, d, e, f, g, h;
for (i = 0; i < 16; i++)
p->w[i] = load32be(p->in.u32 + i);
for (i = 16; i < 64; i++)
{
s0 = ROR32(p->w[i - 15], 7) ^ ROR32(p->w[i - 15], 18) ^ LSR32(p->w[i - 15], 3);
s1 = ROR32(p->w[i - 2], 17) ^ ROR32(p->w[i - 2], 19) ^ LSR32(p->w[i - 2], 10);
p->w[i] = p->w[i - 16] + s0 + p->w[i - 7] + s1;
}
a = p->h[0]; b = p->h[1]; c = p->h[2]; d = p->h[3];
e = p->h[4]; f = p->h[5]; g = p->h[6]; h = p->h[7];
for (i = 0; i < 64; i++)
{
uint32_t t1, t2, maj, ch;
s0 = ROR32(a, 2) ^ ROR32(a, 13) ^ ROR32(a, 22);
maj = (a & b) ^ (a & c) ^ (b & c);
t2 = s0 + maj;
s1 = ROR32(e, 6) ^ ROR32(e, 11) ^ ROR32(e, 25);
ch = (e & f) ^ (~e & g);
t1 = h + s1 + ch + T_K[i] + p->w[i];
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
p->h[0] += a; p->h[1] += b; p->h[2] += c; p->h[3] += d;
p->h[4] += e; p->h[5] += f; p->h[6] += g; p->h[7] += h;
/* Next block */
p->inlen = 0;
}
static void sha256_chunk(struct sha256_ctx *p,
const uint8_t *s, unsigned len)
{
p->len += len;
while (len)
{
unsigned l = 64 - p->inlen;
if (len < l)
l = len;
memcpy(p->in.u8 + p->inlen, s, l);
s += l;
p->inlen += l;
len -= l;
if (p->inlen == 64)
sha256_block(p);
}
}
static void sha256_final(struct sha256_ctx *p)
{
uint64_t len;
p->in.u8[p->inlen++] = 0x80;
if (p->inlen > 56)
{
memset(p->in.u8 + p->inlen, 0, 64 - p->inlen);
sha256_block(p);
}
memset(p->in.u8 + p->inlen, 0, 56 - p->inlen);
len = p->len << 3;
store32be(p->in.u32 + 14, (uint32_t)(len >> 32));
store32be(p->in.u32 + 15, (uint32_t)len);
sha256_block(p);
}
static void sha256_subhash(struct sha256_ctx *p, uint32_t *t)
{
unsigned i;
for (i = 0; i < 8; i++)
store32be(t++, p->h[i]);
}
/**
* sha256_hash:
* @s : Output.
* @in : Input.
* @size : Size of @s.
*
* Hashes SHA256 and outputs a human readable string.
**/
void sha256_hash(char *s, const uint8_t *in, size_t size)
{
unsigned i;
struct sha256_ctx sha;
union
{
uint32_t u32[8];
uint8_t u8[32];
} shahash;
sha256_init(&sha);
sha256_chunk(&sha, in, size);
sha256_final(&sha);
sha256_subhash(&sha, shahash.u32);
for (i = 0; i < 32; i++)
snprintf(s + 2 * i, 3, "%02x", (unsigned)shahash.u8[i]);
}
#ifndef HAVE_ZLIB
/* Zlib CRC32. */
static const uint32_t crc32_table[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
uint32_t crc32_adjust(uint32_t checksum, uint8_t input)
{
return ((checksum >> 8) & 0x00ffffff) ^ crc32_table[(checksum ^ input) & 0xff];
}
uint32_t crc32_calculate(const uint8_t *data, size_t length)
{
size_t i;
uint32_t checksum = ~0;
for (i = 0; i < length; i++)
checksum = crc32_adjust(checksum, data[i]);
return ~checksum;
}
#endif
/* SHA-1 implementation. */
/*
* sha1.c
*
* Copyright (C) 1998, 2009
* Paul E. Jones <paulej@packetizer.com>
* All Rights Reserved
*
*****************************************************************************
* $Id: sha1.c 12 2009-06-22 19:34:25Z paulej $
*****************************************************************************
*
* Description:
* This file implements the Secure Hashing Standard as defined
* in FIPS PUB 180-1 published April 17, 1995.
*
* The Secure Hashing Standard, which uses the Secure Hashing
* Algorithm (SHA), produces a 160-bit message digest for a
* given data stream. In theory, it is highly improbable that
* two messages will produce the same message digest. Therefore,
* this algorithm can serve as a means of providing a "fingerprint"
* for a message.
*
* Portability Issues:
* SHA-1 is defined in terms of 32-bit "words". This code was
* written with the expectation that the processor has at least
* a 32-bit machine word size. If the machine word size is larger,
* the code should still function properly. One caveat to that
* is that the input functions taking characters and character
* arrays assume that only 8 bits of information are stored in each
* character.
*
* Caveats:
* SHA-1 is designed to work with messages less than 2^64 bits
* long. Although SHA-1 allows a message digest to be generated for
* messages of any number of bits less than 2^64, this
* implementation only works with messages with a length that is a
* multiple of the size of an 8-bit character.
*
*/
/* Define the circular shift macro */
#define SHA1CircularShift(bits,word) ((((word) << (bits)) & 0xFFFFFFFF) | ((word) >> (32-(bits))))
static void SHA1Reset(SHA1Context *context)
{
if (!context)
return;
context->Length_Low = 0;
context->Length_High = 0;
context->Message_Block_Index = 0;
context->Message_Digest[0] = 0x67452301;
context->Message_Digest[1] = 0xEFCDAB89;
context->Message_Digest[2] = 0x98BADCFE;
context->Message_Digest[3] = 0x10325476;
context->Message_Digest[4] = 0xC3D2E1F0;
context->Computed = 0;
context->Corrupted = 0;
}
static void SHA1ProcessMessageBlock(SHA1Context *context)
{
const unsigned K[] = /* Constants defined in SHA-1 */
{
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xCA62C1D6
};
int t; /* Loop counter */
unsigned temp; /* Temporary word value */
unsigned W[80]; /* Word sequence */
unsigned A, B, C, D, E; /* Word buffers */
/* Initialize the first 16 words in the array W */
for(t = 0; t < 16; t++)
{
W[t] = ((unsigned) context->Message_Block[t * 4]) << 24;
W[t] |= ((unsigned) context->Message_Block[t * 4 + 1]) << 16;
W[t] |= ((unsigned) context->Message_Block[t * 4 + 2]) << 8;
W[t] |= ((unsigned) context->Message_Block[t * 4 + 3]);
}
for(t = 16; t < 80; t++)
W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
A = context->Message_Digest[0];
B = context->Message_Digest[1];
C = context->Message_Digest[2];
D = context->Message_Digest[3];
E = context->Message_Digest[4];
for(t = 0; t < 20; t++)
{
temp = SHA1CircularShift(5,A) +
((B & C) | ((~B) & D)) + E + W[t] + K[0];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = SHA1CircularShift(30,B);
B = A;
A = temp;
}
for(t = 20; t < 40; t++)
{
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = SHA1CircularShift(30,B);
B = A;
A = temp;
}
for(t = 40; t < 60; t++)
{
temp = SHA1CircularShift(5,A) +
((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = SHA1CircularShift(30,B);
B = A;
A = temp;
}
for(t = 60; t < 80; t++)
{
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = SHA1CircularShift(30,B);
B = A;
A = temp;
}
context->Message_Digest[0] =
(context->Message_Digest[0] + A) & 0xFFFFFFFF;
context->Message_Digest[1] =
(context->Message_Digest[1] + B) & 0xFFFFFFFF;
context->Message_Digest[2] =
(context->Message_Digest[2] + C) & 0xFFFFFFFF;
context->Message_Digest[3] =
(context->Message_Digest[3] + D) & 0xFFFFFFFF;
context->Message_Digest[4] =
(context->Message_Digest[4] + E) & 0xFFFFFFFF;
context->Message_Block_Index = 0;
}
static void SHA1PadMessage(SHA1Context *context)
{
if (!context)
return;
/*
* Check to see if the current message block is too small to hold
* the initial padding bits and length. If so, we will pad the
* block, process it, and then continue padding into a second
* block.
*/
context->Message_Block[context->Message_Block_Index++] = 0x80;
if (context->Message_Block_Index > 55)
{
while(context->Message_Block_Index < 64)
context->Message_Block[context->Message_Block_Index++] = 0;
SHA1ProcessMessageBlock(context);
}
while(context->Message_Block_Index < 56)
context->Message_Block[context->Message_Block_Index++] = 0;
/* Store the message length as the last 8 octets */
context->Message_Block[56] = (context->Length_High >> 24) & 0xFF;
context->Message_Block[57] = (context->Length_High >> 16) & 0xFF;
context->Message_Block[58] = (context->Length_High >> 8) & 0xFF;
context->Message_Block[59] = (context->Length_High) & 0xFF;
context->Message_Block[60] = (context->Length_Low >> 24) & 0xFF;
context->Message_Block[61] = (context->Length_Low >> 16) & 0xFF;
context->Message_Block[62] = (context->Length_Low >> 8) & 0xFF;
context->Message_Block[63] = (context->Length_Low) & 0xFF;
SHA1ProcessMessageBlock(context);
}
static int SHA1Result(SHA1Context *context)
{
if (context->Corrupted)
return 0;
if (!context->Computed)
{
SHA1PadMessage(context);
context->Computed = 1;
}
return 1;
}
static void SHA1Input(SHA1Context *context,
const unsigned char *message_array,
unsigned length)
{
if (!length)
return;
if (context->Computed || context->Corrupted)
{
context->Corrupted = 1;
return;
}
while(length-- && !context->Corrupted)
{
context->Message_Block[context->Message_Block_Index++] =
(*message_array & 0xFF);
context->Length_Low += 8;
/* Force it to 32 bits */
context->Length_Low &= 0xFFFFFFFF;
if (context->Length_Low == 0)
{
context->Length_High++;
/* Force it to 32 bits */
context->Length_High &= 0xFFFFFFFF;
if (context->Length_High == 0)
context->Corrupted = 1; /* Message is too long */
}
if (context->Message_Block_Index == 64)
SHA1ProcessMessageBlock(context);
message_array++;
}
}
int sha1_calculate(const char *path, char *result)
{
unsigned char buff[4096] = {0};
SHA1Context sha;
int rv = 1;
RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1);
if (!fd)
goto error;
SHA1Reset(&sha);
do
{
rv = filestream_read(fd, buff, 4096);
if (rv < 0)
goto error;
SHA1Input(&sha, buff, rv);
}while(rv);
if (!SHA1Result(&sha))
goto error;
sprintf(result, "%08X%08X%08X%08X%08X",
sha.Message_Digest[0],
sha.Message_Digest[1],
sha.Message_Digest[2],
sha.Message_Digest[3], sha.Message_Digest[4]);
filestream_close(fd);
return 0;
error:
if (fd)
filestream_close(fd);
return -1;
}
uint32_t djb2_calculate(const char *str)
{
const unsigned char *aux = (const unsigned char*)str;
uint32_t hash = 5381;
while ( *aux )
hash = ( hash << 5 ) + hash + *aux++;
return hash;
}
|
70a4026c9f9900ceb2052b1c5670804c22ee2829
|
4475534475854c584c04ca926a576f27c1bcf63d
|
/SyslogkRootkit/Research Tools/unhide_rootkit.c
|
d1ad6db3527a37a3968f5d71b0c6c214bff1c48c
|
[] |
no_license
|
avast/ioc
|
24bddbba3f344009a58f80184d11e484564b221d
|
9451de7c5daec18e3b88052d3684a7a13828e03f
|
refs/heads/master
| 2023-09-05T14:37:43.279410
| 2023-01-10T18:04:21
| 2023-01-10T18:04:21
| 199,451,430
| 311
| 79
| null | 2022-11-21T21:25:37
| 2019-07-29T12:46:46
|
Python
|
UTF-8
|
C
| false
| false
| 293
|
c
|
unhide_rootkit.c
|
// It unhides the Syslog Rootkit
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
void main(void)
{
int fd = open("/proc/syslogk", O_WRONLY);
lseek(fd, 0 , SEEK_SET);
write(fd, "1", 1); // Command for unhiding the module
close(fd);
}
|
d3f39db5c507863b53e009612d938ad584ad2537
|
ea910d9946ff96f44bf8895508d053f3075f7c3a
|
/third_party/apout/cpu.c
|
67887d6da78a6454a829b1401e4dce8f6382ca8b
|
[
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"GPL-1.0-or-later",
"MIT",
"GPL-3.0-only",
"GPL-2.0-only",
"LicenseRef-scancode-public-domain"
] |
permissive
|
davidgiven/cowgol
|
290e4ba4e6e87b4619a5f69c0c156145f31cee88
|
ec33ae1293df3937c6397575a0f7defb5e3b4a4d
|
refs/heads/master
| 2023-07-13T20:31:01.261973
| 2023-03-06T19:06:34
| 2023-03-06T19:06:34
| 93,265,830
| 180
| 29
|
BSD-2-Clause
| 2023-03-05T19:29:03
| 2017-06-03T18:12:02
|
C
|
UTF-8
|
C
| false
| false
| 8,191
|
c
|
cpu.c
|
/* cpu.c - this holds the main loop for the emulator, plus generic
* functions to deal with exceptional instructions and events
*
* $Revision: 1.26 $
* $Date: 2008/05/15 07:52:45 $
*/
#include "defines.h"
#include <unistd.h>
u_int8_t *ispace, *dspace; /* Instruction and Data spaces */
u_int16_t dwrite_base = 2; /* Lowest addr where dspace writes can occur */
u_int16_t regs[8]; /* general registers */
u_int16_t ir; /* current instruction register */
u_int16_t *adptr; /* used in memory access macros */
u_int16_t ea_addr; /* stored address for dest modifying insts */
int CC_N = 0; /* The processor status word is represented */
int CC_Z = 0; /* by these four values. On some */
int CC_V = 0; /* architectures, you may get a performance */
int CC_C = 0; /* increase by using shorts or bytes */
u_int16_t dstword; /* These globals are used in the effective */
u_int16_t srcword; /* address calculations, mainly to save */
u_int16_t tmpword; /* parameter passing overheads in */
u_int8_t dstbyte; /* function calls */
u_int8_t srcbyte;
u_int8_t tmpbyte;
struct our_siglist *Sighead = NULL; /* List of pending signals */
struct our_siglist *Sigtail = NULL; /* List of pending signals */
void (*sigrunner) (void) = NULL; /* F'n that will run the signal */
#ifdef DEBUG
extern char *iname[1024];
extern char *iname0[64]; /* Name of each instruction */
extern char *iname1[64];
char *name;
#endif
/* Run until told to stop. */
void run()
{
#ifdef DEBUG
int i;
if (trap_debug) {
TrapDebug((dbg_file, "Just starting to run pid %d\n",
(int) getpid()));
TrapDebug((dbg_file, "Regs are "));
for (i = 0; i <= PC; i++)
TrapDebug((dbg_file, "%06o ", regs[i]));
TrapDebug((dbg_file, "\n"));
}
#endif
while (1) {
/* Fetch and execute the instruction. */
#ifdef DEBUG
lli_word(regs[PC], ir);
if (inst_debug) {
i = ir >> 6;
switch (i) {
case 0:
name = iname0[ir & 077];
break;
case 2:
name = iname1[ir & 077];
break;
default:
name = iname[i];
}
#if defined HEX
TrapDebug((dbg_file, "%04x %04x %4s ", regs[7], ir, name));
TrapDebug((dbg_file, "%04x %04x %04x %04x %04x %04x %04x ",
#else
TrapDebug((dbg_file, "%06o %06o %4s ", regs[7], ir, name));
TrapDebug((dbg_file, "%06o %06o %06o %06o %06o %06o %06o ",
#endif
regs[0], regs[1], regs[2], regs[3],
regs[4], regs[5], regs[6]));
TrapDebug((dbg_file, "NZVC1 %d%d%d%d\n", CC_N, CC_Z, CC_V,
CC_C));
fflush(dbg_file);
}
regs[PC] += 2;
itab[ir >> 6] ();
if ((Sighead != NULL) && (sigrunner != NULL))
(void) (*sigrunner) ();
#else
/* When not debugging, we can manually unroll this inner loop */
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
lli_word(regs[PC], ir);
regs[PC] += 2;
itab[ir >> 6] ();
if ((Sighead != NULL) && (sigrunner != NULL))
(void) (*sigrunner) ();
#endif
}
}
/* sim_init() - Initialize the cpu registers. */
void sim_init()
{
int x;
for (x = 0; x < 8; ++x) {
regs[x] = 0;
}
ir = 0;
CLR_CC_ALL();
}
void bus_error(int signo)
{
TrapDebug((dbg_file, "Apout - pid %d bus error at PC 0%06o\n",
(int) getpid(), regs[PC]));
TrapDebug((dbg_file, "%06o ", ir));
TrapDebug((dbg_file, "%o %o %o %o %o %o %o %o ",
regs[0], regs[1], regs[2], regs[3],
regs[4], regs[5], regs[6], regs[7]));
TrapDebug((dbg_file, "NZVC2 are %d%d%d%d\n", CC_N, CC_Z, CC_V, CC_C));
exit(EXIT_FAILURE);
}
void seg_fault()
{
TrapDebug((dbg_file, "Apout - pid %d segmentation fault at PC 0%06o\n",
(int) getpid(), regs[PC]));
TrapDebug((dbg_file, "%06o ", ir));
TrapDebug((dbg_file, "%o %o %o %o %o %o %o %o ",
regs[0], regs[1], regs[2], regs[3],
regs[4], regs[5], regs[6], regs[7]));
TrapDebug((dbg_file, "NZVC3 are %d%d%d%d\n", CC_N, CC_Z, CC_V, CC_C));
exit(EXIT_FAILURE);
}
void waiti()
{
TrapDebug((stderr, "Apout - pid %d waiti instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void halt()
{
TrapDebug((stderr, "Apout - pid %d halt instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void iot()
{
TrapDebug((stderr, "Apout - pid %d iot instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void emt()
{
TrapDebug((stderr, "Apout - pid %d emt instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void bpt()
{
TrapDebug((stderr, "Apout - pid %d bpt instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void illegal()
{
TrapDebug((stderr, "Apout - pid %d illegal instruction %o at PC 0%o\n",
(int) getpid(), ir, regs[PC]));
exit(EXIT_FAILURE);
}
void not_impl()
{
TrapDebug((stderr,
"Apout - pid %d unimplemented instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void mark()
{
TrapDebug((stderr, "Apout - pid %d mark instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void mfpd()
{
TrapDebug((stderr, "Apout - pid %d mfpd instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void mtpd()
{
TrapDebug((stderr, "Apout - pid %d mtpd instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void trap()
{
TrapDebug((stderr, "Apout - pid %d trap instruction at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
void bad_FP_reg()
{
TrapDebug((stderr, "Apout - pid %d bad FP register used at PC 0%o\n",
(int) getpid(), regs[PC]));
exit(EXIT_FAILURE);
}
/* This is the generic function which catches
* a signal, and appends it to the queue.
*/
void sigcatcher(int sig)
{
struct our_siglist *this;
this = (struct our_siglist *) malloc(sizeof(struct our_siglist));
if (this == NULL)
return;
TrapDebug((dbg_file, "Caught signal %d\n", sig));
this->sig = sig;
this->next = NULL;
if (Sighead == NULL) {
Sighead = Sigtail = this;
} else {
Sigtail->next = this;
Sigtail = this;
}
}
|
f78adf7d7e160ceec6f4be449bcde2514dc1858f
|
aa5c1a530f95d629e686ac9124caf1a49a9f23e9
|
/runtime/src/iree/base/internal/wait_handle_emscripten.c
|
7a7c1ece0f45bb19ba36b7b1cd3503cb7cef4b7b
|
[
"Apache-2.0",
"LLVM-exception",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
openxla/iree
|
eacf5b239559e1d3b40c38039ac4c26315b523f7
|
13ef677e556d0a1d154e45b052fe016256057f65
|
refs/heads/main
| 2023-09-06T01:19:49.598662
| 2023-09-04T07:01:30
| 2023-09-04T07:01:30
| 208,145,128
| 387
| 110
|
Apache-2.0
| 2023-09-14T20:48:00
| 2019-09-12T20:57:39
|
C++
|
UTF-8
|
C
| false
| false
| 5,174
|
c
|
wait_handle_emscripten.c
|
// Copyright 2023 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// clang-format off: must be included before all other headers.
#include "iree/base/internal/wait_handle_impl.h"
// clang-format on
#include "iree/base/api.h"
#include "iree/base/internal/wait_handle.h"
// This implementation for the web platform via Emscripten uses JavaScript
// Promise objects for asynchronous waiting:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
//
// Synchronous wait APIs (e.g. iree_wait_one) are not supported, as using
// Promises requires interacting with the asynchronous browser event loop.
// * Note: JSPI (https://v8.dev/blog/jspi) and Asyncify
// (https://emscripten.org/docs/porting/asyncify.html)
// could probably be used to interop with this, but the real goal of this
// implementation is browser-native asynchronous behavior.
//
// Wait handles may be asynchronously waited on via the JavaScript API:
// ```
// // C
// int handle = iree_wait_primitive_promise_create(false);
//
// // JS
// const promiseWrapper = IreeWaitHandlePromise.getPromiseWrapper(handle);
// promiseWrapper.promise.then(() => { ... });
//
// // C
// iree_wait_primitive_promise_set(handle);
// ```
#if IREE_WAIT_API == IREE_WAIT_API_PROMISE && defined(IREE_PLATFORM_EMSCRIPTEN)
#include <emscripten.h>
//===----------------------------------------------------------------------===//
// externs from wait_handle_emscripten.js
//===----------------------------------------------------------------------===//
extern int iree_wait_primitive_promise_create(bool initial_state);
extern void iree_wait_primitive_promise_delete(int promise_handle);
extern void iree_wait_primitive_promise_set(int promise_handle);
extern void iree_wait_primitive_promise_reset(int promise_handle);
//===----------------------------------------------------------------------===//
// iree_wait_primitive_* raw calls
//===----------------------------------------------------------------------===//
void iree_wait_handle_close(iree_wait_handle_t* handle) {
switch (handle->type) {
#if defined(IREE_HAVE_WAIT_TYPE_JAVASCRIPT_PROMISE)
case IREE_WAIT_PRIMITIVE_TYPE_JAVASCRIPT_PROMISE: {
iree_wait_primitive_promise_delete(handle->value.promise.handle);
break;
}
#endif // IREE_HAVE_WAIT_TYPE_JAVASCRIPT_PROMISE
default:
break;
}
iree_wait_handle_deinitialize(handle);
}
//===----------------------------------------------------------------------===//
// iree_wait_set_t
//===----------------------------------------------------------------------===//
struct iree_wait_set_t {
int reserved;
};
iree_status_t iree_wait_set_allocate(iree_host_size_t capacity,
iree_allocator_t allocator,
iree_wait_set_t** out_set) {
*out_set = NULL;
return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "wait_set unimplemented");
}
void iree_wait_set_free(iree_wait_set_t* set) {}
bool iree_wait_set_is_empty(const iree_wait_set_t* set) { return true; }
iree_status_t iree_wait_set_insert(iree_wait_set_t* set,
iree_wait_handle_t handle) {
return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "wait_set unimplemented");
}
void iree_wait_set_erase(iree_wait_set_t* set, iree_wait_handle_t handle) {}
void iree_wait_set_clear(iree_wait_set_t* set) {}
iree_status_t iree_wait_all(iree_wait_set_t* set, iree_time_t deadline_ns) {
return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "wait_set unimplemented");
}
iree_status_t iree_wait_any(iree_wait_set_t* set, iree_time_t deadline_ns,
iree_wait_handle_t* out_wake_handle) {
return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "wait_set unimplemented");
}
iree_status_t iree_wait_one(iree_wait_handle_t* handle,
iree_time_t deadline_ns) {
return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "wait_set unimplemented");
}
//===----------------------------------------------------------------------===//
// iree_event_t
//===----------------------------------------------------------------------===//
iree_status_t iree_event_initialize(bool initial_state,
iree_event_t* out_event) {
memset(out_event, 0, sizeof(*out_event));
out_event->type = IREE_WAIT_PRIMITIVE_TYPE_JAVASCRIPT_PROMISE;
int promise_handle = iree_wait_primitive_promise_create(initial_state);
out_event->value.promise.handle = promise_handle;
return iree_ok_status();
}
void iree_event_deinitialize(iree_event_t* event) {
iree_wait_handle_close(event);
}
void iree_event_set(iree_event_t* event) {
if (!event) return;
iree_wait_primitive_promise_set(event->value.promise.handle);
}
void iree_event_reset(iree_event_t* event) {
if (!event) return;
iree_wait_primitive_promise_reset(event->value.promise.handle);
}
#endif // IREE_WAIT_API == IREE_WAIT_API_INPROC &&
// defined(IREE_PLATFORM_EMSCRIPTEN)
|
30508a78d5bbe0822b9dafdd45bd63be57e3c50f
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/lib/mesa/src/gallium/drivers/panfrost/pan_resource.h
|
c5c14f5c88b756b2836565b657d37aecab5d8af0
|
[] |
no_license
|
openbsd/xenocara
|
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
|
a012b5de33ea0b977095d77316a521195b26cc6b
|
refs/heads/master
| 2023-08-25T12:16:58.862008
| 2023-08-12T16:16:25
| 2023-08-12T16:16:25
| 66,967,384
| 177
| 66
| null | 2023-07-22T18:12:37
| 2016-08-30T18:36:01
|
C
|
UTF-8
|
C
| false
| false
| 5,617
|
h
|
pan_resource.h
|
/*
* © Copyright2018-2019 Alyssa Rosenzweig
*
* 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 (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef PAN_RESOURCE_H
#define PAN_RESOURCE_H
#include "pan_screen.h"
#include "pan_minmax_cache.h"
#include "pan_texture.h"
#include "drm-uapi/drm.h"
#include "util/u_range.h"
#define LAYOUT_CONVERT_THRESHOLD 8
#define PAN_MAX_BATCHES 32
#define PAN_BIND_SHARED_MASK (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | \
PIPE_BIND_SHARED)
struct panfrost_resource {
struct pipe_resource base;
struct {
struct pipe_scissor_state extent;
struct {
bool enable;
unsigned stride;
unsigned size;
BITSET_WORD *data;
} tile_map;
} damage;
struct {
/** Number of batches accessing this resource. Used to check if
* a resource is in use. */
_Atomic unsigned nr_users;
/** Number of batches writing this resource. Note that only one
* batch per context may write a resource, so this is the
* number of contexts that have an active writer. */
_Atomic unsigned nr_writers;
} track;
struct renderonly_scanout *scanout;
struct panfrost_resource *separate_stencil;
struct util_range valid_buffer_range;
/* Description of the resource layout */
struct pan_image image;
struct {
/* Is the checksum for this image valid? Implicitly refers to
* the first slice; we only checksum non-mipmapped 2D images */
bool crc;
/* Has anything been written to this slice? */
BITSET_DECLARE(data, MAX_MIP_LEVELS);
} valid;
/* Whether the modifier can be changed */
bool modifier_constant;
/* Used to decide when to convert to another modifier */
uint16_t modifier_updates;
/* Do all pixels have the same stencil value? */
bool constant_stencil;
/* The stencil value if constant_stencil is set */
uint8_t stencil_value;
/* Cached min/max values for index buffers */
struct panfrost_minmax_cache *index_cache;
};
static inline struct panfrost_resource *
pan_resource(struct pipe_resource *p)
{
return (struct panfrost_resource *)p;
}
struct panfrost_transfer {
struct pipe_transfer base;
void *map;
struct {
struct pipe_resource *rsrc;
struct pipe_box box;
} staging;
};
static inline struct panfrost_transfer *
pan_transfer(struct pipe_transfer *p)
{
return (struct panfrost_transfer *)p;
}
void panfrost_resource_screen_init(struct pipe_screen *screen);
void panfrost_resource_screen_destroy(struct pipe_screen *screen);
void panfrost_resource_context_init(struct pipe_context *pctx);
/* Blitting */
void
panfrost_blitter_save(struct panfrost_context *ctx, bool render_cond);
void
panfrost_blit(struct pipe_context *pipe,
const struct pipe_blit_info *info);
void
panfrost_resource_set_damage_region(struct pipe_screen *screen,
struct pipe_resource *res,
unsigned int nrects,
const struct pipe_box *rects);
static inline enum mali_texture_dimension
panfrost_translate_texture_dimension(enum pipe_texture_target t) {
switch (t)
{
case PIPE_BUFFER:
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_1D_ARRAY:
return MALI_TEXTURE_DIMENSION_1D;
case PIPE_TEXTURE_2D:
case PIPE_TEXTURE_2D_ARRAY:
case PIPE_TEXTURE_RECT:
return MALI_TEXTURE_DIMENSION_2D;
case PIPE_TEXTURE_3D:
return MALI_TEXTURE_DIMENSION_3D;
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
return MALI_TEXTURE_DIMENSION_CUBE;
default:
unreachable("Unknown target");
}
}
void
pan_resource_modifier_convert(struct panfrost_context *ctx,
struct panfrost_resource *rsrc,
uint64_t modifier, const char *reason);
void
pan_legalize_afbc_format(struct panfrost_context *ctx,
struct panfrost_resource *rsrc,
enum pipe_format format);
#endif /* PAN_RESOURCE_H */
|
aa4d2bc78aa9d79b0b91cf751d235180afd1ec8c
|
1661c43eaf9e44dfe7cce269cfaae62e336036f1
|
/blink/vfs.h
|
7e0b9ae44a036efdf079860bbb972ea08a15283c
|
[] |
permissive
|
jart/blink
|
3354eaf084e3e85a50372f1a93fc75ff2b9488b1
|
312a027d0908c1b1f9d1e9ebba837da569606b82
|
refs/heads/master
| 2023-08-31T21:30:40.551686
| 2023-08-22T15:42:44
| 2023-08-22T15:42:44
| 561,183,031
| 6,089
| 192
|
ISC
| 2023-08-22T15:42:46
| 2022-11-03T06:07:09
|
C
|
UTF-8
|
C
| false
| false
| 15,608
|
h
|
vfs.h
|
#ifndef BLINK_VFS_H_
#define BLINK_VFS_H_
#include <dirent.h>
#include <poll.h>
#include <stdarg.h>
#include <stdbool.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <termios.h>
#include <unistd.h>
#include "blink/dll.h"
#include "blink/macros.h"
#include "blink/overlays.h"
#include "blink/preadv.h"
#include "blink/thread.h"
#include "blink/tsan.h"
#include "blink/types.h"
#define VFS_SYSTEM_ROOT_MOUNT "/SystemRoot"
#define VFS_PATH_MAX MAX(PATH_MAX, 4096)
#define VFS_NAME_MAX 256
struct VfsDevice;
struct VfsMount;
struct VfsInfo;
struct VfsSystem;
struct VfsFd;
struct VfsMap;
struct Vfs {
struct Dll *devices GUARDED_BY(lock);
struct Dll *systems GUARDED_BY(lock);
struct Dll *fds GUARDED_BY(lock);
struct Dll *maps GUARDED_BY(mapslock);
pthread_mutex_t_ lock;
pthread_mutex_t_ mapslock;
};
struct VfsOps {
int (*Init)(const char *, u64, const void *, struct VfsDevice **,
struct VfsMount **);
int (*Freeinfo)(void *);
int (*Freedevice)(void *);
int (*Readmountentry)(struct VfsDevice *, char **, char **, char **);
int (*Finddir)(struct VfsInfo *, const char *, struct VfsInfo **);
int (*Traverse)(struct VfsInfo **, const char **, struct VfsInfo *);
ssize_t (*Readlink)(struct VfsInfo *, char **);
int (*Mkdir)(struct VfsInfo *, const char *, mode_t);
int (*Mkfifo)(struct VfsInfo *, const char *, mode_t);
int (*Open)(struct VfsInfo *, const char *, int, int, struct VfsInfo **);
int (*Access)(struct VfsInfo *, const char *, mode_t, int);
int (*Stat)(struct VfsInfo *, const char *, struct stat *, int);
int (*Fstat)(struct VfsInfo *, struct stat *);
int (*Chmod)(struct VfsInfo *, const char *, mode_t, int);
int (*Fchmod)(struct VfsInfo *, mode_t);
int (*Chown)(struct VfsInfo *, const char *, uid_t, gid_t, int);
int (*Fchown)(struct VfsInfo *, uid_t, gid_t);
int (*Ftruncate)(struct VfsInfo *, off_t);
int (*Close)(struct VfsInfo *);
int (*Link)(struct VfsInfo *, const char *, struct VfsInfo *, const char *,
int);
int (*Unlink)(struct VfsInfo *, const char *, int);
ssize_t (*Read)(struct VfsInfo *, void *, size_t);
ssize_t (*Write)(struct VfsInfo *, const void *, size_t);
ssize_t (*Pread)(struct VfsInfo *, void *, size_t, off_t);
ssize_t (*Pwrite)(struct VfsInfo *, const void *, size_t, off_t);
ssize_t (*Readv)(struct VfsInfo *, const struct iovec *, int);
ssize_t (*Writev)(struct VfsInfo *, const struct iovec *, int);
ssize_t (*Preadv)(struct VfsInfo *, const struct iovec *, int, off_t);
ssize_t (*Pwritev)(struct VfsInfo *, const struct iovec *, int, off_t);
off_t (*Seek)(struct VfsInfo *, off_t, int);
int (*Fsync)(struct VfsInfo *);
int (*Fdatasync)(struct VfsInfo *);
int (*Flock)(struct VfsInfo *, int);
int (*Fcntl)(struct VfsInfo *, int, va_list);
int (*Ioctl)(struct VfsInfo *, unsigned long, const void *);
int (*Dup)(struct VfsInfo *, struct VfsInfo **);
#ifdef HAVE_DUP3
int (*Dup3)(struct VfsInfo *, struct VfsInfo **, int);
#endif
int (*Poll)(struct VfsInfo **, struct pollfd *, nfds_t, int);
int (*Opendir)(struct VfsInfo *, struct VfsInfo **);
#ifdef HAVE_SEEKDIR
void (*Seekdir)(struct VfsInfo *, long);
long (*Telldir)(struct VfsInfo *);
#endif
struct dirent *(*Readdir)(struct VfsInfo *);
void (*Rewinddir)(struct VfsInfo *);
int (*Closedir)(struct VfsInfo *);
int (*Bind)(struct VfsInfo *, const struct sockaddr *, socklen_t);
int (*Connect)(struct VfsInfo *, const struct sockaddr *, socklen_t);
int (*Connectunix)(struct VfsInfo *, struct VfsInfo *,
const struct sockaddr_un *, socklen_t);
int (*Accept)(struct VfsInfo *, struct sockaddr *, socklen_t *,
struct VfsInfo **);
int (*Listen)(struct VfsInfo *, int);
int (*Shutdown)(struct VfsInfo *, int);
ssize_t (*Recvmsg)(struct VfsInfo *, struct msghdr *, int);
ssize_t (*Sendmsg)(struct VfsInfo *, const struct msghdr *, int);
ssize_t (*Recvmsgunix)(struct VfsInfo *, struct VfsInfo *, struct msghdr *,
int);
ssize_t (*Sendmsgunix)(struct VfsInfo *, struct VfsInfo *,
const struct msghdr *, int);
int (*Getsockopt)(struct VfsInfo *, int, int, void *, socklen_t *);
int (*Setsockopt)(struct VfsInfo *, int, int, const void *, socklen_t);
int (*Getsockname)(struct VfsInfo *, struct sockaddr *, socklen_t *);
int (*Getpeername)(struct VfsInfo *, struct sockaddr *, socklen_t *);
int (*Rename)(struct VfsInfo *, const char *, struct VfsInfo *, const char *);
int (*Utime)(struct VfsInfo *, const char *, const struct timespec[2], int);
int (*Futime)(struct VfsInfo *, const struct timespec[2]);
int (*Symlink)(const char *, struct VfsInfo *, const char *);
void *(*Mmap)(struct VfsInfo *, void *, size_t, int, int, off_t);
int (*Munmap)(struct VfsInfo *, void *, size_t);
int (*Mprotect)(struct VfsInfo *, void *, size_t, int);
int (*Msync)(struct VfsInfo *, void *, size_t, int);
int (*Pipe)(struct VfsInfo *[2]);
#ifdef HAVE_PIPE2
int (*Pipe2)(struct VfsInfo *[2], int);
#endif
int (*Socket)(int, int, int, struct VfsInfo **);
int (*Socketpair)(int, int, int, struct VfsInfo *[2]);
int (*Tcgetattr)(struct VfsInfo *, struct termios *);
int (*Tcsetattr)(struct VfsInfo *, int, const struct termios *);
int (*Tcflush)(struct VfsInfo *, int);
int (*Tcdrain)(struct VfsInfo *);
int (*Tcsendbreak)(struct VfsInfo *, int);
int (*Tcflow)(struct VfsInfo *, int);
pid_t (*Tcgetsid)(struct VfsInfo *);
pid_t (*Tcgetpgrp)(struct VfsInfo *);
int (*Tcsetpgrp)(struct VfsInfo *, pid_t);
#ifdef HAVE_SOCKATMARK
int (*Sockatmark)(struct VfsInfo *);
#endif
int (*Fexecve)(struct VfsInfo *, char *const *, char *const *);
};
#define VFS_SYSTEM_NAME_MAX 8
struct VfsSystem {
struct Dll elem;
struct VfsOps ops;
char name[VFS_SYSTEM_NAME_MAX];
bool nodev;
};
struct VfsMount {
u64 baseino;
struct VfsInfo *root;
struct Dll elem;
};
struct VfsDevice {
pthread_mutex_t_ lock;
struct Dll *mounts;
struct VfsOps *ops;
struct VfsInfo *root;
void *data;
struct Dll elem;
u64 flags;
u32 dev;
_Atomic(u32) refcount;
};
struct VfsInfo {
struct VfsDevice *device;
struct VfsInfo *parent;
const char *name;
size_t namelen;
void *data;
u64 ino;
u32 dev;
u32 mode;
_Atomic(u32) refcount;
};
extern struct Vfs g_vfs;
extern struct VfsInfo *g_cwdinfo;
extern struct VfsInfo *g_rootinfo;
extern struct VfsInfo *g_actualrootinfo;
#define VFS_SYSTEM_CONTAINER(e) DLL_CONTAINER(struct VfsSystem, elem, (e))
#define VFS_MOUNT_CONTAINER(e) DLL_CONTAINER(struct VfsMount, elem, (e))
#define VFS_DEVICE_CONTAINER(e) DLL_CONTAINER(struct VfsDevice, elem, (e))
#if !defined(DISABLE_VFS)
int VfsChdir(const char *);
char *VfsGetcwd(char *, size_t);
int VfsChroot(const char *);
int VfsMount(const char *, const char *, const char *, u64, const void *);
int VfsUnlink(int, const char *, int);
int VfsMkdir(int, const char *, mode_t);
int VfsMkfifo(int, const char *, mode_t);
int VfsOpen(int, const char *, int, int);
int VfsChmod(int, const char *, mode_t, int);
int VfsAccess(int, const char *, mode_t, int);
int VfsSymlink(const char *, int, const char *);
int VfsStat(int, const char *, struct stat *, int);
int VfsChown(int, const char *, uid_t, gid_t, int);
int VfsRename(int, const char *, int, const char *);
ssize_t VfsReadlink(int, const char *, char *, size_t);
int VfsLink(int, const char *, int, const char *, int);
int VfsUtime(int, const char *, const struct timespec[2], int);
int VfsFutime(int, const struct timespec[2]);
int VfsFchown(int, uid_t, gid_t);
int VfsFstat(int, struct stat *);
int VfsFtruncate(int, off_t);
int VfsClose(int);
ssize_t VfsRead(int, void *, size_t);
ssize_t VfsWrite(int, const void *, size_t);
ssize_t VfsPread(int, void *, size_t, off_t);
ssize_t VfsPwrite(int, const void *, size_t, off_t);
ssize_t VfsReadv(int, const struct iovec *, int);
ssize_t VfsWritev(int, const struct iovec *, int);
ssize_t VfsPreadv(int, const struct iovec *, int, off_t);
ssize_t VfsPwritev(int, const struct iovec *, int, off_t);
off_t VfsSeek(int, off_t, int);
int VfsFchmod(int, mode_t);
int VfsFchdir(int);
int VfsFsync(int);
int VfsFdatasync(int);
int VfsFlock(int, int);
int VfsFcntl(int, int, ...);
int VfsIoctl(int, unsigned long, void *);
int VfsDup(int);
int VfsDup2(int, int);
#ifdef HAVE_DUP3
int VfsDup3(int, int, int);
#endif
int VfsPoll(struct pollfd *, nfds_t, int);
int VfsSelect(int, fd_set *, fd_set *, fd_set *, struct timespec *, sigset_t *);
DIR *VfsOpendir(int);
#ifdef HAVE_SEEKDIR
void VfsSeekdir(DIR *, long);
long VfsTelldir(DIR *);
#endif
struct dirent *VfsReaddir(DIR *);
void VfsRewinddir(DIR *);
int VfsClosedir(DIR *);
int VfsBind(int, const struct sockaddr *, socklen_t);
int VfsConnect(int, const struct sockaddr *, socklen_t);
int VfsAccept(int, struct sockaddr *, socklen_t *);
int VfsListen(int, int);
int VfsShutdown(int, int);
ssize_t VfsRecvmsg(int, struct msghdr *, int);
ssize_t VfsSendmsg(int, const struct msghdr *, int);
int VfsGetsockopt(int, int, int, void *, socklen_t *);
int VfsSetsockopt(int, int, int, const void *, socklen_t);
int VfsGetsockname(int, struct sockaddr *, socklen_t *);
int VfsGetpeername(int, struct sockaddr *, socklen_t *);
int VfsPipe(int[2]);
#ifdef HAVE_PIPE2
int VfsPipe2(int[2], int);
#endif
int VfsSocket(int, int, int);
int VfsSocketpair(int, int, int, int[2]);
int VfsTcgetattr(int, struct termios *);
int VfsTcsetattr(int, int, const struct termios *);
pid_t VfsTcgetpgrp(int);
int VfsTcsetpgrp(int, pid_t);
int VfsTcdrain(int);
int VfsTcsendbreak(int, int);
int VfsTcflow(int, int);
pid_t VfsTcgetsid(int);
int VfsTcflush(int, int);
int VfsSockatmark(int);
int VfsExecve(const char *, char *const *, char *const *);
void *VfsMmap(void *, size_t, int, int, int, off_t);
int VfsMunmap(void *, size_t);
int VfsMprotect(void *, size_t, int);
int VfsMsync(void *, size_t, int);
int VfsInit(const char *);
int VfsRegister(struct VfsSystem *);
int VfsTraverse(const char *, struct VfsInfo **, bool);
int VfsCreateInfo(struct VfsInfo **);
int VfsAcquireInfo(struct VfsInfo *, struct VfsInfo **);
int VfsCreateDevice(struct VfsDevice **output);
int VfsAcquireDevice(struct VfsDevice *, struct VfsDevice **);
int VfsFreeDevice(struct VfsDevice *);
int VfsFreeInfo(struct VfsInfo *);
int VfsAddFd(struct VfsInfo *);
int VfsFreeFd(int, struct VfsInfo **);
int VfsSetFd(int, struct VfsInfo *);
ssize_t VfsPathBuildFull(struct VfsInfo *, struct VfsInfo *, char **);
ssize_t VfsPathBuild(struct VfsInfo *, struct VfsInfo *, bool,
char[VFS_PATH_MAX]);
#elif !defined(DISABLE_OVERLAYS)
#define VfsChown OverlaysChown
#define VfsAccess OverlaysAccess
#define VfsStat OverlaysStat
#define VfsChdir OverlaysChdir
#define VfsGetcwd OverlaysGetcwd
#define VfsMkdir OverlaysMkdir
#define VfsChmod OverlaysChmod
#define VfsReadlink OverlaysReadlink
#define VfsOpen OverlaysOpen
#define VfsSymlink OverlaysSymlink
#define VfsMkfifo OverlaysMkfifo
#define VfsUnlink OverlaysUnlink
#define VfsRename OverlaysRename
#define VfsLink OverlaysLink
#define VfsUtime OverlaysUtime
#define VfsFchown fchown
#define VfsFchdir fchdir
#define VfsFchmod fchmod
#define VfsFutime futimens
#define VfsFstat fstat
#define VfsFtruncate ftruncate
#define VfsClose close
#define VfsRead read
#define VfsWrite write
#define VfsPread pread
#define VfsPwrite pwrite
#define VfsReadv readv
#define VfsWritev writev
#define VfsPreadv preadv
#define VfsPwritev pwritev
#define VfsSeek lseek
#define VfsFsync fsync
#define VfsFdatasync fdatasync
#define VfsFlock flock
#define VfsFcntl fcntl
#define VfsDup dup
#define VfsDup2 dup2
#define VfsDup3 dup3
#define VfsPoll poll
#define VfsSelect pselect
#define VfsOpendir fdopendir
#define VfsSeekdir seekdir
#define VfsTelldir telldir
#define VfsReaddir readdir
#define VfsRewinddir rewinddir
#define VfsClosedir closedir
#define VfsPipe pipe
#define VfsPipe2 pipe2
#define VfsSocket socket
#define VfsSocketpair socketpair
#define VfsBind bind
#define VfsConnect connect
#define VfsAccept accept
#define VfsListen listen
#define VfsShutdown shutdown
#define VfsRecvmsg recvmsg
#define VfsSendmsg sendmsg
#define VfsGetsockopt getsockopt
#define VfsSetsockopt setsockopt
#define VfsGetsockname getsockname
#define VfsGetpeername getpeername
#define VfsIoctl ioctl
#define VfsTcgetattr tcgetattr
#define VfsTcsetattr tcsetattr
#define VfsTcgetpgrp tcgetpgrp
#define VfsTcsetpgrp tcsetpgrp
#define VfsTcgetsid tcgetsid
#define VfsTcsendbreak tcsendbreak
#define VfsTcflow tcflow
#define VfsTcflush tcflush
#define VfsTcdrain tcdrain
#define VfsSockatmark sockatmark
#define VfsExecve execve
#define VfsMmap mmap
#define VfsMunmap munmap
#define VfsMprotect mprotect
#define VfsMsync msync
#else
#define VfsChown fchownat
#define VfsAccess faccessat
#define VfsStat fstatat
#define VfsChdir chdir
#define VfsGetcwd getcwd
#define VfsMkdir mkdirat
#define VfsChmod fchmodat
#define VfsReadlink readlinkat
#define VfsOpen openat
#define VfsSymlink symlinkat
#define VfsMkfifo mkfifoat
#define VfsUnlink unlinkat
#define VfsRename renameat
#define VfsLink linkat
#define VfsUtime utimensat
#define VfsFchown fchown
#define VfsFchdir fchdir
#define VfsFchmod fchmod
#define VfsFutime futimens
#define VfsFstat fstat
#define VfsFtruncate ftruncate
#define VfsClose close
#define VfsRead read
#define VfsWrite write
#define VfsPread pread
#define VfsPwrite pwrite
#define VfsReadv readv
#define VfsWritev writev
#define VfsPreadv preadv
#define VfsPwritev pwritev
#define VfsSeek lseek
#define VfsFsync fsync
#define VfsFdatasync fdatasync
#define VfsFlock flock
#define VfsFcntl fcntl
#define VfsDup dup
#define VfsDup2 dup2
#define VfsDup3 dup3
#define VfsPoll poll
#define VfsSelect pselect
#define VfsOpendir fdopendir
#define VfsSeekdir seekdir
#define VfsTelldir telldir
#define VfsReaddir readdir
#define VfsRewinddir rewinddir
#define VfsClosedir closedir
#define VfsPipe pipe
#define VfsPipe2 pipe2
#define VfsSocket socket
#define VfsSocketpair socketpair
#define VfsBind bind
#define VfsConnect connect
#define VfsAccept accept
#define VfsListen listen
#define VfsShutdown shutdown
#define VfsRecvmsg recvmsg
#define VfsSendmsg sendmsg
#define VfsGetsockopt getsockopt
#define VfsSetsockopt setsockopt
#define VfsGetsockname getsockname
#define VfsGetpeername getpeername
#define VfsIoctl ioctl
#define VfsTcgetattr tcgetattr
#define VfsTcsetattr tcsetattr
#define VfsTcgetpgrp tcgetpgrp
#define VfsTcsetpgrp tcsetpgrp
#define VfsTcgetsid tcgetsid
#define VfsTcsendbreak tcsendbreak
#define VfsTcflow tcflow
#define VfsTcflush tcflush
#define VfsTcdrain tcdrain
#define VfsSockatmark sockatmark
#define VfsExecve execve
#define VfsMmap mmap
#define VfsMunmap munmap
#define VfsMprotect mprotect
#define VfsMsync msync
#endif
#endif /* BLINK_VFS_H_ */
|
fab1a7877714273aa6ef70d70b63e60f2237f188
|
2fe54e153cabb14d4dca1589a42e5ce20e0797e3
|
/src/programs/sphinx3_align/ms_mllr.c
|
61b617947578c83720072dcf38979fd19084eb52
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] |
permissive
|
cmusphinx/sphinxtrain
|
721be72a756d3435ab4c70683453af6a03046fbe
|
532034bc547770516c39f78c4f90cb1b74b9e871
|
refs/heads/master
| 2023-08-28T22:46:01.618946
| 2022-10-13T21:04:31
| 2022-10-13T21:04:31
| 18,513,555
| 171
| 124
|
NOASSERTION
| 2023-01-13T21:36:12
| 2014-04-07T10:32:58
|
Roff
|
UTF-8
|
C
| false
| false
| 6,970
|
c
|
ms_mllr.c
|
/* ====================================================================
* Copyright (c) 1999-2004 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* This work was supported in part by funding from the Defense Advanced
* Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED 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 CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES 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.
*
* ====================================================================
*
*/
/*
* ms_mllr.c -- Application of MLLR regression matrices to codebook means
*
* **********************************************
* CMU ARPA Speech Project
*
* Copyright (c) 1996 Carnegie Mellon University.
* ALL RIGHTS RESERVED.
* **********************************************
*
* HISTORY
* $Log$
* Revision 1.5 2006/02/22 17:21:35 arthchan2003
* Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Added ms_mllr.[ch]
*
* Revision 1.4.4.1 2005/07/20 19:39:01 arthchan2003
* Added licences in ms_* series of code.
*
* Revision 1.4 2005/06/21 18:56:13 arthchan2003
* 1, Fixed doxygen documentation. 2, Added $ keyword.
*
* Revision 1.4 2005/06/19 04:50:02 archan
* Sphinx3 to s3.generic: allow multiple classes for MLLR
*
* Revision 1.3 2005/03/30 01:22:47 archan
* Fixed mistakes in last updates. Add
*
*
* 02-Dec-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
* Added reading of MLLR classes in transformation file. Currently must
* be 1.
*
* 26-Sep-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
* Started (copied from Vipul Parikh's implementation).
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
/* #include <s3.h>*/
#include "ms_mllr.h"
int32
ms_mllr_read_regmat(const char *regmatfile,
float32 ***** A,
float32 **** B,
float32 **** H,
int32 * streamlen, int32 n_stream, int32 * nclass)
{
int32 i, j, k, m, n, lnclass;
FILE *fp;
float32 ****lA, ***lB, ***lH;
if ((fp = fopen(regmatfile, "r")) == NULL) {
E_ERROR("fopen(%s,r) failed\n", regmatfile);
return -1;
}
else
E_INFO("Reading MLLR transformation file %s\n", regmatfile);
if ((fscanf(fp, "%d", &n) != 1) || (n < 1))
return -1;
lnclass = n;
if ((fscanf(fp, "%d", &n) != 1) || (n != n_stream))
return -1;
lA = (float32 ****) ckd_calloc(n_stream, sizeof(float32 **));
lB = (float32 ***) ckd_calloc(n_stream, sizeof(float32 *));
lH = (float32 ***) ckd_calloc(n_stream, sizeof(float32 *));
for (i = 0; i < n_stream; ++i) {
lA[i] =
(float32 ***) ckd_calloc_3d(lnclass, streamlen[i],
streamlen[i], sizeof(float32));
lB[i] =
(float32 **) ckd_calloc_2d(lnclass, streamlen[i],
sizeof(float32));
lH[i] =
(float32 **) ckd_calloc_2d(lnclass, streamlen[i],
sizeof(float32));
}
for (i = 0; i < n_stream; ++i) {
if ((fscanf(fp, "%d", &n) != 1) || (streamlen[i] != n))
goto readerror;
for (m = 0; m < lnclass; ++m) {
for (j = 0; j < streamlen[i]; ++j) {
for (k = 0; k < streamlen[i]; ++k) {
if (fscanf(fp, "%f ", &lA[i][m][j][k]) != 1)
goto readerror;
}
}
for (j = 0; j < streamlen[i]; ++j) {
if (fscanf(fp, "%f ", &lB[i][m][j]) != 1)
goto readerror;
}
for (j = 0; j < streamlen[i]; ++j) {
if (fscanf(fp, "%f ", &lH[i][m][j]) != 1)
goto readerror;
}
}
}
*A = lA;
*B = lB;
*H = lH;
*nclass = lnclass;
fclose(fp);
return 0;
readerror:
E_ERROR("Error reading MLLR file %s\n", regmatfile);
for (i = 0; i < n_stream; ++i) {
ckd_free_3d((void ***) lA[i]);
ckd_free_2d((void **) lB[i]);
ckd_free_2d((void **) lH[i]);
}
ckd_free(lA);
ckd_free(lB);
ckd_free(lH);
fclose(fp);
*A = NULL;
*B = NULL;
*H = NULL;
return -1;
}
int32
ms_mllr_free_regmat(float32 **** A, float32 *** B, float32 *** H, int32 n_stream)
{
int32 i;
for (i = 0; i < n_stream; i++) {
ckd_free_3d((void ***) A[i]);
ckd_free_2d((void **) B[i]);
ckd_free_2d((void **) H[i]);
}
ckd_free(A);
ckd_free(B);
ckd_free(H);
return 0;
}
int32
ms_mllr_norm_mgau(float32 *** mean,
float32 *** var,
int32 n_density,
float32 **** A,
float32 *** B,
float32 *** H,
int32 * streamlen, int32 n_stream, int32 class)
{
int32 s, d, l, m;
float64 *temp;
/* Transform codebook for each stream s */
for (s = 0; s < n_stream; s++) {
temp = (float64 *) ckd_calloc(streamlen[s], sizeof(float64));
/* Transform each density d in selected codebook */
for (d = 0; d < n_density; d++) {
for (l = 0; l < streamlen[s]; l++) {
temp[l] = 0.0;
for (m = 0; m < streamlen[s]; m++) {
temp[l] += A[s][class][l][m] * mean[s][d][m];
}
temp[l] += B[s][class][l];
}
for (l = 0; l < streamlen[s]; l++) {
mean[s][d][l] = (float32) temp[l];
if (H)
var[s][d][l] *= H[s][class][l];
}
}
ckd_free(temp);
}
return 0;
}
|
0112d31f5290e9244a7a8f832deddbcb4d060161
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/dav1d/libdav1d/src/thread_task.c
|
49a8c123fd458e480ea20c22adaeba379053682a
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 40,197
|
c
|
thread_task.c
|
/*
* Copyright © 2018, VideoLAN and dav1d authors
* Copyright © 2018, Two Orioles, LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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 "config.h"
#include "common/frame.h"
#include "src/thread_task.h"
#include "src/fg_apply.h"
// This function resets the cur pointer to the first frame theoretically
// executable after a task completed (ie. each time we update some progress or
// insert some tasks in the queue).
// When frame_idx is set, it can be either from a completed task, or from tasks
// inserted in the queue, in which case we have to make sure the cur pointer
// isn't past this insert.
// The special case where frame_idx is UINT_MAX is to handle the reset after
// completing a task and locklessly signaling progress. In this case we don't
// enter a critical section, which is needed for this function, so we set an
// atomic for a delayed handling, happening here. Meaning we can call this
// function without any actual update other than what's in the atomic, hence
// this special case.
static inline int reset_task_cur(const Dav1dContext *const c,
struct TaskThreadData *const ttd,
unsigned frame_idx)
{
const unsigned first = atomic_load(&ttd->first);
unsigned reset_frame_idx = atomic_exchange(&ttd->reset_task_cur, UINT_MAX);
if (reset_frame_idx < first) {
if (frame_idx == UINT_MAX) return 0;
reset_frame_idx = UINT_MAX;
}
if (!ttd->cur && c->fc[first].task_thread.task_cur_prev == NULL)
return 0;
if (reset_frame_idx != UINT_MAX) {
if (frame_idx == UINT_MAX) {
if (reset_frame_idx > first + ttd->cur)
return 0;
ttd->cur = reset_frame_idx - first;
goto cur_found;
}
} else if (frame_idx == UINT_MAX)
return 0;
if (frame_idx < first) frame_idx += c->n_fc;
const unsigned min_frame_idx = umin(reset_frame_idx, frame_idx);
const unsigned cur_frame_idx = first + ttd->cur;
if (ttd->cur < c->n_fc && cur_frame_idx < min_frame_idx)
return 0;
for (ttd->cur = min_frame_idx - first; ttd->cur < c->n_fc; ttd->cur++)
if (c->fc[(first + ttd->cur) % c->n_fc].task_thread.task_head)
break;
cur_found:
for (unsigned i = ttd->cur; i < c->n_fc; i++)
c->fc[(first + i) % c->n_fc].task_thread.task_cur_prev = NULL;
return 1;
}
static inline void reset_task_cur_async(struct TaskThreadData *const ttd,
unsigned frame_idx, unsigned n_frames)
{
const unsigned first = atomic_load(&ttd->first);
if (frame_idx < first) frame_idx += n_frames;
unsigned last_idx = frame_idx;
do {
frame_idx = last_idx;
last_idx = atomic_exchange(&ttd->reset_task_cur, frame_idx);
} while (last_idx < frame_idx);
if (frame_idx == first && atomic_load(&ttd->first) != first) {
unsigned expected = frame_idx;
atomic_compare_exchange_strong(&ttd->reset_task_cur, &expected, UINT_MAX);
}
}
static void insert_tasks_between(Dav1dFrameContext *const f,
Dav1dTask *const first, Dav1dTask *const last,
Dav1dTask *const a, Dav1dTask *const b,
const int cond_signal)
{
struct TaskThreadData *const ttd = f->task_thread.ttd;
if (atomic_load(f->c->flush)) return;
assert(!a || a->next == b);
if (!a) f->task_thread.task_head = first;
else a->next = first;
if (!b) f->task_thread.task_tail = last;
last->next = b;
reset_task_cur(f->c, ttd, first->frame_idx);
if (cond_signal && !atomic_fetch_or(&ttd->cond_signaled, 1))
pthread_cond_signal(&ttd->cond);
}
static void insert_tasks(Dav1dFrameContext *const f,
Dav1dTask *const first, Dav1dTask *const last,
const int cond_signal)
{
// insert task back into task queue
Dav1dTask *t_ptr, *prev_t = NULL;
for (t_ptr = f->task_thread.task_head;
t_ptr; prev_t = t_ptr, t_ptr = t_ptr->next)
{
// entropy coding precedes other steps
if (t_ptr->type == DAV1D_TASK_TYPE_TILE_ENTROPY) {
if (first->type > DAV1D_TASK_TYPE_TILE_ENTROPY) continue;
// both are entropy
if (first->sby > t_ptr->sby) continue;
if (first->sby < t_ptr->sby) {
insert_tasks_between(f, first, last, prev_t, t_ptr, cond_signal);
return;
}
// same sby
} else {
if (first->type == DAV1D_TASK_TYPE_TILE_ENTROPY) {
insert_tasks_between(f, first, last, prev_t, t_ptr, cond_signal);
return;
}
if (first->sby > t_ptr->sby) continue;
if (first->sby < t_ptr->sby) {
insert_tasks_between(f, first, last, prev_t, t_ptr, cond_signal);
return;
}
// same sby
if (first->type > t_ptr->type) continue;
if (first->type < t_ptr->type) {
insert_tasks_between(f, first, last, prev_t, t_ptr, cond_signal);
return;
}
// same task type
}
// sort by tile-id
assert(first->type == DAV1D_TASK_TYPE_TILE_RECONSTRUCTION ||
first->type == DAV1D_TASK_TYPE_TILE_ENTROPY);
assert(first->type == t_ptr->type);
assert(t_ptr->sby == first->sby);
const int p = first->type == DAV1D_TASK_TYPE_TILE_ENTROPY;
const int t_tile_idx = (int) (first - f->task_thread.tile_tasks[p]);
const int p_tile_idx = (int) (t_ptr - f->task_thread.tile_tasks[p]);
assert(t_tile_idx != p_tile_idx);
if (t_tile_idx > p_tile_idx) continue;
insert_tasks_between(f, first, last, prev_t, t_ptr, cond_signal);
return;
}
// append at the end
insert_tasks_between(f, first, last, prev_t, NULL, cond_signal);
}
static inline void insert_task(Dav1dFrameContext *const f,
Dav1dTask *const t, const int cond_signal)
{
insert_tasks(f, t, t, cond_signal);
}
static inline void add_pending(Dav1dFrameContext *const f, Dav1dTask *const t) {
pthread_mutex_lock(&f->task_thread.pending_tasks.lock);
t->next = NULL;
if (!f->task_thread.pending_tasks.head)
f->task_thread.pending_tasks.head = t;
else
f->task_thread.pending_tasks.tail->next = t;
f->task_thread.pending_tasks.tail = t;
atomic_store(&f->task_thread.pending_tasks.merge, 1);
pthread_mutex_unlock(&f->task_thread.pending_tasks.lock);
}
static inline int merge_pending_frame(Dav1dFrameContext *const f) {
int const merge = atomic_load(&f->task_thread.pending_tasks.merge);
if (merge) {
pthread_mutex_lock(&f->task_thread.pending_tasks.lock);
Dav1dTask *t = f->task_thread.pending_tasks.head;
f->task_thread.pending_tasks.head = NULL;
f->task_thread.pending_tasks.tail = NULL;
atomic_store(&f->task_thread.pending_tasks.merge, 0);
pthread_mutex_unlock(&f->task_thread.pending_tasks.lock);
while (t) {
Dav1dTask *const tmp = t->next;
insert_task(f, t, 0);
t = tmp;
}
}
return merge;
}
static inline int merge_pending(const Dav1dContext *const c) {
int res = 0;
for (unsigned i = 0; i < c->n_fc; i++)
res |= merge_pending_frame(&c->fc[i]);
return res;
}
static int create_filter_sbrow(Dav1dFrameContext *const f,
const int pass, Dav1dTask **res_t)
{
const int has_deblock = f->frame_hdr->loopfilter.level_y[0] ||
f->frame_hdr->loopfilter.level_y[1];
const int has_cdef = f->seq_hdr->cdef;
const int has_resize = f->frame_hdr->width[0] != f->frame_hdr->width[1];
const int has_lr = f->lf.restore_planes;
Dav1dTask *tasks = f->task_thread.tasks;
const int uses_2pass = f->c->n_fc > 1;
int num_tasks = f->sbh * (1 + uses_2pass);
if (num_tasks > f->task_thread.num_tasks) {
const size_t size = sizeof(Dav1dTask) * num_tasks;
tasks = realloc(f->task_thread.tasks, size);
if (!tasks) return -1;
memset(tasks, 0, size);
f->task_thread.tasks = tasks;
f->task_thread.num_tasks = num_tasks;
}
tasks += f->sbh * (pass & 1);
if (pass & 1) {
f->frame_thread.entropy_progress = 0;
} else {
const int prog_sz = ((f->sbh + 31) & ~31) >> 5;
if (prog_sz > f->frame_thread.prog_sz) {
atomic_uint *const prog = realloc(f->frame_thread.frame_progress,
2 * prog_sz * sizeof(*prog));
if (!prog) return -1;
f->frame_thread.frame_progress = prog;
f->frame_thread.copy_lpf_progress = prog + prog_sz;
}
f->frame_thread.prog_sz = prog_sz;
memset(f->frame_thread.frame_progress, 0, prog_sz * sizeof(atomic_uint));
memset(f->frame_thread.copy_lpf_progress, 0, prog_sz * sizeof(atomic_uint));
atomic_store(&f->frame_thread.deblock_progress, 0);
}
f->frame_thread.next_tile_row[pass & 1] = 0;
Dav1dTask *t = &tasks[0];
t->sby = 0;
t->recon_progress = 1;
t->deblock_progress = 0;
t->type = pass == 1 ? DAV1D_TASK_TYPE_ENTROPY_PROGRESS :
has_deblock ? DAV1D_TASK_TYPE_DEBLOCK_COLS :
has_cdef || has_lr /* i.e. LR backup */ ? DAV1D_TASK_TYPE_DEBLOCK_ROWS :
has_resize ? DAV1D_TASK_TYPE_SUPER_RESOLUTION :
DAV1D_TASK_TYPE_RECONSTRUCTION_PROGRESS;
t->frame_idx = (int)(f - f->c->fc);
*res_t = t;
return 0;
}
int dav1d_task_create_tile_sbrow(Dav1dFrameContext *const f, const int pass,
const int cond_signal)
{
Dav1dTask *tasks = f->task_thread.tile_tasks[0];
const int uses_2pass = f->c->n_fc > 1;
const int num_tasks = f->frame_hdr->tiling.cols * f->frame_hdr->tiling.rows;
if (pass < 2) {
int alloc_num_tasks = num_tasks * (1 + uses_2pass);
if (alloc_num_tasks > f->task_thread.num_tile_tasks) {
const size_t size = sizeof(Dav1dTask) * alloc_num_tasks;
tasks = realloc(f->task_thread.tile_tasks[0], size);
if (!tasks) return -1;
memset(tasks, 0, size);
f->task_thread.tile_tasks[0] = tasks;
f->task_thread.num_tile_tasks = alloc_num_tasks;
}
f->task_thread.tile_tasks[1] = tasks + num_tasks;
}
tasks += num_tasks * (pass & 1);
Dav1dTask *pf_t;
if (create_filter_sbrow(f, pass, &pf_t))
return -1;
Dav1dTask *prev_t = NULL;
for (int tile_idx = 0; tile_idx < num_tasks; tile_idx++) {
Dav1dTileState *const ts = &f->ts[tile_idx];
Dav1dTask *t = &tasks[tile_idx];
t->sby = ts->tiling.row_start >> f->sb_shift;
if (pf_t && t->sby) {
prev_t->next = pf_t;
prev_t = pf_t;
pf_t = NULL;
}
t->recon_progress = 0;
t->deblock_progress = 0;
t->deps_skip = 0;
t->type = pass != 1 ? DAV1D_TASK_TYPE_TILE_RECONSTRUCTION :
DAV1D_TASK_TYPE_TILE_ENTROPY;
t->frame_idx = (int)(f - f->c->fc);
if (prev_t) prev_t->next = t;
prev_t = t;
}
if (pf_t) {
prev_t->next = pf_t;
prev_t = pf_t;
}
prev_t->next = NULL;
atomic_store(&f->task_thread.done[pass & 1], 0);
// XXX in theory this could be done locklessly, at this point they are no
// tasks in the frameQ, so no other runner should be using this lock, but
// we must add both passes at once
pthread_mutex_lock(&f->task_thread.pending_tasks.lock);
assert(f->task_thread.pending_tasks.head == NULL || pass == 2);
if (!f->task_thread.pending_tasks.head)
f->task_thread.pending_tasks.head = &tasks[0];
else
f->task_thread.pending_tasks.tail->next = &tasks[0];
f->task_thread.pending_tasks.tail = prev_t;
atomic_store(&f->task_thread.pending_tasks.merge, 1);
atomic_store(&f->task_thread.init_done, 1);
pthread_mutex_unlock(&f->task_thread.pending_tasks.lock);
return 0;
}
void dav1d_task_frame_init(Dav1dFrameContext *const f) {
const Dav1dContext *const c = f->c;
atomic_store(&f->task_thread.init_done, 0);
// schedule init task, which will schedule the remaining tasks
Dav1dTask *const t = &f->task_thread.init_task;
t->type = DAV1D_TASK_TYPE_INIT;
t->frame_idx = (int)(f - c->fc);
t->sby = 0;
t->recon_progress = t->deblock_progress = 0;
insert_task(f, t, 1);
}
void dav1d_task_delayed_fg(Dav1dContext *const c, Dav1dPicture *const out,
const Dav1dPicture *const in)
{
struct TaskThreadData *const ttd = &c->task_thread;
ttd->delayed_fg.in = in;
ttd->delayed_fg.out = out;
ttd->delayed_fg.type = DAV1D_TASK_TYPE_FG_PREP;
atomic_init(&ttd->delayed_fg.progress[0], 0);
atomic_init(&ttd->delayed_fg.progress[1], 0);
pthread_mutex_lock(&ttd->lock);
ttd->delayed_fg.exec = 1;
pthread_cond_signal(&ttd->cond);
pthread_cond_wait(&ttd->delayed_fg.cond, &ttd->lock);
pthread_mutex_unlock(&ttd->lock);
}
static inline int ensure_progress(struct TaskThreadData *const ttd,
Dav1dFrameContext *const f,
Dav1dTask *const t, const enum TaskType type,
atomic_int *const state, int *const target)
{
// deblock_rows (non-LR portion) depends on deblock of previous sbrow,
// so ensure that completed. if not, re-add to task-queue; else, fall-through
int p1 = atomic_load(state);
if (p1 < t->sby) {
t->type = type;
t->recon_progress = t->deblock_progress = 0;
*target = t->sby;
add_pending(f, t);
pthread_mutex_lock(&ttd->lock);
return 1;
}
return 0;
}
static inline int check_tile(Dav1dTask *const t, Dav1dFrameContext *const f,
const int frame_mt)
{
const int tp = t->type == DAV1D_TASK_TYPE_TILE_ENTROPY;
const int tile_idx = (int)(t - f->task_thread.tile_tasks[tp]);
Dav1dTileState *const ts = &f->ts[tile_idx];
const int p1 = atomic_load(&ts->progress[tp]);
if (p1 < t->sby) return 1;
int error = p1 == TILE_ERROR;
error |= atomic_fetch_or(&f->task_thread.error, error);
if (!error && frame_mt && !tp) {
const int p2 = atomic_load(&ts->progress[1]);
if (p2 <= t->sby) return 1;
error = p2 == TILE_ERROR;
error |= atomic_fetch_or(&f->task_thread.error, error);
}
if (!error && frame_mt && !IS_KEY_OR_INTRA(f->frame_hdr)) {
// check reference state
const Dav1dThreadPicture *p = &f->sr_cur;
const int ss_ver = p->p.p.layout == DAV1D_PIXEL_LAYOUT_I420;
const unsigned p_b = (t->sby + 1) << (f->sb_shift + 2);
const int tile_sby = t->sby - (ts->tiling.row_start >> f->sb_shift);
const int (*const lowest_px)[2] = ts->lowest_pixel[tile_sby];
for (int n = t->deps_skip; n < 7; n++, t->deps_skip++) {
unsigned lowest;
if (tp) {
// if temporal mv refs are disabled, we only need this
// for the primary ref; if segmentation is disabled, we
// don't even need that
lowest = p_b;
} else {
// +8 is postfilter-induced delay
const int y = lowest_px[n][0] == INT_MIN ? INT_MIN :
lowest_px[n][0] + 8;
const int uv = lowest_px[n][1] == INT_MIN ? INT_MIN :
lowest_px[n][1] * (1 << ss_ver) + 8;
const int max = imax(y, uv);
if (max == INT_MIN) continue;
lowest = iclip(max, 1, f->refp[n].p.p.h);
}
const unsigned p3 = atomic_load(&f->refp[n].progress[!tp]);
if (p3 < lowest) return 1;
atomic_fetch_or(&f->task_thread.error, p3 == FRAME_ERROR);
}
}
return 0;
}
static inline int get_frame_progress(const Dav1dContext *const c,
const Dav1dFrameContext *const f)
{
unsigned frame_prog = c->n_fc > 1 ? atomic_load(&f->sr_cur.progress[1]) : 0;
if (frame_prog >= FRAME_ERROR)
return f->sbh - 1;
int idx = frame_prog >> (f->sb_shift + 7);
int prog;
do {
atomic_uint *state = &f->frame_thread.frame_progress[idx];
const unsigned val = ~atomic_load(state);
prog = val ? ctz(val) : 32;
if (prog != 32) break;
prog = 0;
} while (++idx < f->frame_thread.prog_sz);
return ((idx << 5) | prog) - 1;
}
static inline void abort_frame(Dav1dFrameContext *const f, const int error) {
atomic_store(&f->task_thread.error, error == DAV1D_ERR(EINVAL) ? 1 : -1);
atomic_store(&f->task_thread.task_counter, 0);
atomic_store(&f->task_thread.done[0], 1);
atomic_store(&f->task_thread.done[1], 1);
atomic_store(&f->sr_cur.progress[0], FRAME_ERROR);
atomic_store(&f->sr_cur.progress[1], FRAME_ERROR);
dav1d_decode_frame_exit(f, error);
f->n_tile_data = 0;
pthread_cond_signal(&f->task_thread.cond);
}
static inline void delayed_fg_task(const Dav1dContext *const c,
struct TaskThreadData *const ttd)
{
const Dav1dPicture *const in = ttd->delayed_fg.in;
Dav1dPicture *const out = ttd->delayed_fg.out;
#if CONFIG_16BPC
int off;
if (out->p.bpc != 8)
off = (out->p.bpc >> 1) - 4;
#endif
switch (ttd->delayed_fg.type) {
case DAV1D_TASK_TYPE_FG_PREP:
ttd->delayed_fg.exec = 0;
if (atomic_load(&ttd->cond_signaled))
pthread_cond_signal(&ttd->cond);
pthread_mutex_unlock(&ttd->lock);
switch (out->p.bpc) {
#if CONFIG_8BPC
case 8:
dav1d_prep_grain_8bpc(&c->dsp[0].fg, out, in,
ttd->delayed_fg.scaling_8bpc,
ttd->delayed_fg.grain_lut_8bpc);
break;
#endif
#if CONFIG_16BPC
case 10:
case 12:
dav1d_prep_grain_16bpc(&c->dsp[off].fg, out, in,
ttd->delayed_fg.scaling_16bpc,
ttd->delayed_fg.grain_lut_16bpc);
break;
#endif
default: abort();
}
ttd->delayed_fg.type = DAV1D_TASK_TYPE_FG_APPLY;
pthread_mutex_lock(&ttd->lock);
ttd->delayed_fg.exec = 1;
// fall-through
case DAV1D_TASK_TYPE_FG_APPLY:;
int row = atomic_fetch_add(&ttd->delayed_fg.progress[0], 1);
pthread_mutex_unlock(&ttd->lock);
int progmax = (out->p.h + 31) >> 5;
fg_apply_loop:
if (row + 1 < progmax)
pthread_cond_signal(&ttd->cond);
else if (row + 1 >= progmax) {
pthread_mutex_lock(&ttd->lock);
ttd->delayed_fg.exec = 0;
if (row >= progmax) goto end_add;
pthread_mutex_unlock(&ttd->lock);
}
switch (out->p.bpc) {
#if CONFIG_8BPC
case 8:
dav1d_apply_grain_row_8bpc(&c->dsp[0].fg, out, in,
ttd->delayed_fg.scaling_8bpc,
ttd->delayed_fg.grain_lut_8bpc, row);
break;
#endif
#if CONFIG_16BPC
case 10:
case 12:
dav1d_apply_grain_row_16bpc(&c->dsp[off].fg, out, in,
ttd->delayed_fg.scaling_16bpc,
ttd->delayed_fg.grain_lut_16bpc, row);
break;
#endif
default: abort();
}
row = atomic_fetch_add(&ttd->delayed_fg.progress[0], 1);
int done = atomic_fetch_add(&ttd->delayed_fg.progress[1], 1) + 1;
if (row < progmax) goto fg_apply_loop;
pthread_mutex_lock(&ttd->lock);
ttd->delayed_fg.exec = 0;
end_add:
done = atomic_fetch_add(&ttd->delayed_fg.progress[1], 1) + 1;
progmax = atomic_load(&ttd->delayed_fg.progress[0]);
// signal for completion only once the last runner reaches this
if (done < progmax)
break;
pthread_cond_signal(&ttd->delayed_fg.cond);
break;
default: abort();
}
}
void *dav1d_worker_task(void *data) {
Dav1dTaskContext *const tc = data;
const Dav1dContext *const c = tc->c;
struct TaskThreadData *const ttd = tc->task_thread.ttd;
dav1d_set_thread_name("dav1d-worker");
pthread_mutex_lock(&ttd->lock);
for (;;) {
if (tc->task_thread.die) break;
if (atomic_load(c->flush)) goto park;
merge_pending(c);
if (ttd->delayed_fg.exec) { // run delayed film grain first
delayed_fg_task(c, ttd);
continue;
}
Dav1dFrameContext *f;
Dav1dTask *t, *prev_t = NULL;
if (c->n_fc > 1) { // run init tasks second
for (unsigned i = 0; i < c->n_fc; i++) {
const unsigned first = atomic_load(&ttd->first);
f = &c->fc[(first + i) % c->n_fc];
if (atomic_load(&f->task_thread.init_done)) continue;
t = f->task_thread.task_head;
if (!t) continue;
if (t->type == DAV1D_TASK_TYPE_INIT) goto found;
if (t->type == DAV1D_TASK_TYPE_INIT_CDF) {
// XXX This can be a simple else, if adding tasks of both
// passes at once (in dav1d_task_create_tile_sbrow).
// Adding the tasks to the pending Q can result in a
// thread merging them before setting init_done.
// We will need to set init_done before adding to the
// pending Q, so maybe return the tasks, set init_done,
// and add to pending Q only then.
const int p1 = f->in_cdf.progress ?
atomic_load(f->in_cdf.progress) : 1;
if (p1) {
atomic_fetch_or(&f->task_thread.error, p1 == TILE_ERROR);
goto found;
}
}
}
}
while (ttd->cur < c->n_fc) { // run decoding tasks last
const unsigned first = atomic_load(&ttd->first);
f = &c->fc[(first + ttd->cur) % c->n_fc];
merge_pending_frame(f);
prev_t = f->task_thread.task_cur_prev;
t = prev_t ? prev_t->next : f->task_thread.task_head;
while (t) {
if (t->type == DAV1D_TASK_TYPE_INIT_CDF) goto next;
else if (t->type == DAV1D_TASK_TYPE_TILE_ENTROPY ||
t->type == DAV1D_TASK_TYPE_TILE_RECONSTRUCTION)
{
// if not bottom sbrow of tile, this task will be re-added
// after it's finished
if (!check_tile(t, f, c->n_fc > 1))
goto found;
} else if (t->recon_progress) {
const int p = t->type == DAV1D_TASK_TYPE_ENTROPY_PROGRESS;
int error = atomic_load(&f->task_thread.error);
assert(!atomic_load(&f->task_thread.done[p]) || error);
const int tile_row_base = f->frame_hdr->tiling.cols *
f->frame_thread.next_tile_row[p];
if (p) {
atomic_int *const prog = &f->frame_thread.entropy_progress;
const int p1 = atomic_load(prog);
if (p1 < t->sby) goto next;
atomic_fetch_or(&f->task_thread.error, p1 == TILE_ERROR);
}
for (int tc = 0; tc < f->frame_hdr->tiling.cols; tc++) {
Dav1dTileState *const ts = &f->ts[tile_row_base + tc];
const int p2 = atomic_load(&ts->progress[p]);
if (p2 < t->recon_progress) goto next;
atomic_fetch_or(&f->task_thread.error, p2 == TILE_ERROR);
}
if (t->sby + 1 < f->sbh) {
// add sby+1 to list to replace this one
Dav1dTask *next_t = &t[1];
*next_t = *t;
next_t->sby++;
const int ntr = f->frame_thread.next_tile_row[p] + 1;
const int start = f->frame_hdr->tiling.row_start_sb[ntr];
if (next_t->sby == start)
f->frame_thread.next_tile_row[p] = ntr;
next_t->recon_progress = next_t->sby + 1;
insert_task(f, next_t, 0);
}
goto found;
} else if (t->type == DAV1D_TASK_TYPE_CDEF) {
atomic_uint *prog = f->frame_thread.copy_lpf_progress;
const int p1 = atomic_load(&prog[(t->sby - 1) >> 5]);
if (p1 & (1U << ((t->sby - 1) & 31)))
goto found;
} else {
assert(t->deblock_progress);
const int p1 = atomic_load(&f->frame_thread.deblock_progress);
if (p1 >= t->deblock_progress) {
atomic_fetch_or(&f->task_thread.error, p1 == TILE_ERROR);
goto found;
}
}
next:
prev_t = t;
t = t->next;
f->task_thread.task_cur_prev = prev_t;
}
ttd->cur++;
}
if (reset_task_cur(c, ttd, UINT_MAX)) continue;
if (merge_pending(c)) continue;
park:
tc->task_thread.flushed = 1;
pthread_cond_signal(&tc->task_thread.td.cond);
// we want to be woken up next time progress is signaled
atomic_store(&ttd->cond_signaled, 0);
pthread_cond_wait(&ttd->cond, &ttd->lock);
tc->task_thread.flushed = 0;
reset_task_cur(c, ttd, UINT_MAX);
continue;
found:
// remove t from list
if (prev_t) prev_t->next = t->next;
else f->task_thread.task_head = t->next;
if (!t->next) f->task_thread.task_tail = prev_t;
if (t->type > DAV1D_TASK_TYPE_INIT_CDF && !f->task_thread.task_head)
ttd->cur++;
t->next = NULL;
// we don't need to check cond_signaled here, since we found a task
// after the last signal so we want to re-signal the next waiting thread
// and again won't need to signal after that
atomic_store(&ttd->cond_signaled, 1);
pthread_cond_signal(&ttd->cond);
pthread_mutex_unlock(&ttd->lock);
found_unlocked:;
const int flush = atomic_load(c->flush);
int error = atomic_fetch_or(&f->task_thread.error, flush) | flush;
// run it
tc->f = f;
int sby = t->sby;
switch (t->type) {
case DAV1D_TASK_TYPE_INIT: {
assert(c->n_fc > 1);
int res = dav1d_decode_frame_init(f);
int p1 = f->in_cdf.progress ? atomic_load(f->in_cdf.progress) : 1;
if (res || p1 == TILE_ERROR) {
pthread_mutex_lock(&ttd->lock);
abort_frame(f, res ? res : DAV1D_ERR(EINVAL));
reset_task_cur(c, ttd, t->frame_idx);
} else {
t->type = DAV1D_TASK_TYPE_INIT_CDF;
if (p1) goto found_unlocked;
add_pending(f, t);
pthread_mutex_lock(&ttd->lock);
}
continue;
}
case DAV1D_TASK_TYPE_INIT_CDF: {
assert(c->n_fc > 1);
int res = DAV1D_ERR(EINVAL);
if (!atomic_load(&f->task_thread.error))
res = dav1d_decode_frame_init_cdf(f);
if (f->frame_hdr->refresh_context && !f->task_thread.update_set) {
atomic_store(f->out_cdf.progress, res < 0 ? TILE_ERROR : 1);
}
if (!res) {
assert(c->n_fc > 1);
for (int p = 1; p <= 2; p++) {
const int res = dav1d_task_create_tile_sbrow(f, p, 0);
if (res) {
pthread_mutex_lock(&ttd->lock);
// memory allocation failed
atomic_store(&f->task_thread.done[2 - p], 1);
atomic_store(&f->task_thread.error, -1);
atomic_fetch_sub(&f->task_thread.task_counter,
f->frame_hdr->tiling.cols *
f->frame_hdr->tiling.rows + f->sbh);
atomic_store(&f->sr_cur.progress[p - 1], FRAME_ERROR);
if (p == 2 && atomic_load(&f->task_thread.done[1])) {
assert(!atomic_load(&f->task_thread.task_counter));
dav1d_decode_frame_exit(f, DAV1D_ERR(ENOMEM));
f->n_tile_data = 0;
pthread_cond_signal(&f->task_thread.cond);
} else {
pthread_mutex_unlock(&ttd->lock);
}
}
}
pthread_mutex_lock(&ttd->lock);
} else {
pthread_mutex_lock(&ttd->lock);
abort_frame(f, res);
reset_task_cur(c, ttd, t->frame_idx);
atomic_store(&f->task_thread.init_done, 1);
}
continue;
}
case DAV1D_TASK_TYPE_TILE_ENTROPY:
case DAV1D_TASK_TYPE_TILE_RECONSTRUCTION: {
const int p = t->type == DAV1D_TASK_TYPE_TILE_ENTROPY;
const int tile_idx = (int)(t - f->task_thread.tile_tasks[p]);
Dav1dTileState *const ts = &f->ts[tile_idx];
tc->ts = ts;
tc->by = sby << f->sb_shift;
const int uses_2pass = c->n_fc > 1;
tc->frame_thread.pass = !uses_2pass ? 0 :
1 + (t->type == DAV1D_TASK_TYPE_TILE_RECONSTRUCTION);
if (!error) error = dav1d_decode_tile_sbrow(tc);
const int progress = error ? TILE_ERROR : 1 + sby;
// signal progress
atomic_fetch_or(&f->task_thread.error, error);
if (((sby + 1) << f->sb_shift) < ts->tiling.row_end) {
t->sby++;
t->deps_skip = 0;
if (!check_tile(t, f, uses_2pass)) {
atomic_store(&ts->progress[p], progress);
reset_task_cur_async(ttd, t->frame_idx, c->n_fc);
if (!atomic_fetch_or(&ttd->cond_signaled, 1))
pthread_cond_signal(&ttd->cond);
goto found_unlocked;
}
atomic_store(&ts->progress[p], progress);
add_pending(f, t);
pthread_mutex_lock(&ttd->lock);
} else {
pthread_mutex_lock(&ttd->lock);
atomic_store(&ts->progress[p], progress);
reset_task_cur(c, ttd, t->frame_idx);
error = atomic_load(&f->task_thread.error);
if (f->frame_hdr->refresh_context &&
tc->frame_thread.pass <= 1 && f->task_thread.update_set &&
f->frame_hdr->tiling.update == tile_idx)
{
if (!error)
dav1d_cdf_thread_update(f->frame_hdr, f->out_cdf.data.cdf,
&f->ts[f->frame_hdr->tiling.update].cdf);
if (c->n_fc > 1)
atomic_store(f->out_cdf.progress, error ? TILE_ERROR : 1);
}
if (atomic_fetch_sub(&f->task_thread.task_counter, 1) - 1 == 0 &&
atomic_load(&f->task_thread.done[0]) &&
(!uses_2pass || atomic_load(&f->task_thread.done[1])))
{
error = atomic_load(&f->task_thread.error);
dav1d_decode_frame_exit(f, error == 1 ? DAV1D_ERR(EINVAL) :
error ? DAV1D_ERR(ENOMEM) : 0);
f->n_tile_data = 0;
pthread_cond_signal(&f->task_thread.cond);
}
assert(atomic_load(&f->task_thread.task_counter) >= 0);
if (!atomic_fetch_or(&ttd->cond_signaled, 1))
pthread_cond_signal(&ttd->cond);
}
continue;
}
case DAV1D_TASK_TYPE_DEBLOCK_COLS:
if (!atomic_load(&f->task_thread.error))
f->bd_fn.filter_sbrow_deblock_cols(f, sby);
if (ensure_progress(ttd, f, t, DAV1D_TASK_TYPE_DEBLOCK_ROWS,
&f->frame_thread.deblock_progress,
&t->deblock_progress)) continue;
// fall-through
case DAV1D_TASK_TYPE_DEBLOCK_ROWS:
if (!atomic_load(&f->task_thread.error))
f->bd_fn.filter_sbrow_deblock_rows(f, sby);
// signal deblock progress
if (f->frame_hdr->loopfilter.level_y[0] ||
f->frame_hdr->loopfilter.level_y[1])
{
error = atomic_load(&f->task_thread.error);
atomic_store(&f->frame_thread.deblock_progress,
error ? TILE_ERROR : sby + 1);
reset_task_cur_async(ttd, t->frame_idx, c->n_fc);
if (!atomic_fetch_or(&ttd->cond_signaled, 1))
pthread_cond_signal(&ttd->cond);
} else if (f->seq_hdr->cdef || f->lf.restore_planes) {
atomic_fetch_or(&f->frame_thread.copy_lpf_progress[sby >> 5],
1U << (sby & 31));
// CDEF needs the top buffer to be saved by lr_copy_lpf of the
// previous sbrow
if (sby) {
int prog = atomic_load(&f->frame_thread.copy_lpf_progress[(sby - 1) >> 5]);
if (~prog & (1U << ((sby - 1) & 31))) {
t->type = DAV1D_TASK_TYPE_CDEF;
t->recon_progress = t->deblock_progress = 0;
add_pending(f, t);
pthread_mutex_lock(&ttd->lock);
continue;
}
}
}
// fall-through
case DAV1D_TASK_TYPE_CDEF:
if (f->seq_hdr->cdef) {
if (!atomic_load(&f->task_thread.error))
f->bd_fn.filter_sbrow_cdef(tc, sby);
reset_task_cur_async(ttd, t->frame_idx, c->n_fc);
if (!atomic_fetch_or(&ttd->cond_signaled, 1))
pthread_cond_signal(&ttd->cond);
}
// fall-through
case DAV1D_TASK_TYPE_SUPER_RESOLUTION:
if (f->frame_hdr->width[0] != f->frame_hdr->width[1])
if (!atomic_load(&f->task_thread.error))
f->bd_fn.filter_sbrow_resize(f, sby);
// fall-through
case DAV1D_TASK_TYPE_LOOP_RESTORATION:
if (!atomic_load(&f->task_thread.error) && f->lf.restore_planes)
f->bd_fn.filter_sbrow_lr(f, sby);
// fall-through
case DAV1D_TASK_TYPE_RECONSTRUCTION_PROGRESS:
// dummy to cover for no post-filters
case DAV1D_TASK_TYPE_ENTROPY_PROGRESS:
// dummy to convert tile progress to frame
break;
default: abort();
}
// if task completed [typically LR], signal picture progress as per below
const int uses_2pass = c->n_fc > 1;
const int sbh = f->sbh;
const int sbsz = f->sb_step * 4;
if (t->type == DAV1D_TASK_TYPE_ENTROPY_PROGRESS) {
error = atomic_load(&f->task_thread.error);
const unsigned y = sby + 1 == sbh ? UINT_MAX : (unsigned)(sby + 1) * sbsz;
assert(c->n_fc > 1);
if (f->sr_cur.p.data[0] /* upon flush, this can be free'ed already */)
atomic_store(&f->sr_cur.progress[0], error ? FRAME_ERROR : y);
atomic_store(&f->frame_thread.entropy_progress,
error ? TILE_ERROR : sby + 1);
if (sby + 1 == sbh)
atomic_store(&f->task_thread.done[1], 1);
pthread_mutex_lock(&ttd->lock);
const int num_tasks = atomic_fetch_sub(&f->task_thread.task_counter, 1) - 1;
if (sby + 1 < sbh && num_tasks) {
reset_task_cur(c, ttd, t->frame_idx);
continue;
}
if (!num_tasks && atomic_load(&f->task_thread.done[0]) &&
atomic_load(&f->task_thread.done[1]))
{
error = atomic_load(&f->task_thread.error);
dav1d_decode_frame_exit(f, error == 1 ? DAV1D_ERR(EINVAL) :
error ? DAV1D_ERR(ENOMEM) : 0);
f->n_tile_data = 0;
pthread_cond_signal(&f->task_thread.cond);
}
reset_task_cur(c, ttd, t->frame_idx);
continue;
}
// t->type != DAV1D_TASK_TYPE_ENTROPY_PROGRESS
atomic_fetch_or(&f->frame_thread.frame_progress[sby >> 5],
1U << (sby & 31));
pthread_mutex_lock(&f->task_thread.lock);
sby = get_frame_progress(c, f);
error = atomic_load(&f->task_thread.error);
const unsigned y = sby + 1 == sbh ? UINT_MAX : (unsigned)(sby + 1) * sbsz;
if (c->n_fc > 1 && f->sr_cur.p.data[0] /* upon flush, this can be free'ed already */)
atomic_store(&f->sr_cur.progress[1], error ? FRAME_ERROR : y);
pthread_mutex_unlock(&f->task_thread.lock);
if (sby + 1 == sbh)
atomic_store(&f->task_thread.done[0], 1);
pthread_mutex_lock(&ttd->lock);
const int num_tasks = atomic_fetch_sub(&f->task_thread.task_counter, 1) - 1;
if (sby + 1 < sbh && num_tasks) {
reset_task_cur(c, ttd, t->frame_idx);
continue;
}
if (!num_tasks && atomic_load(&f->task_thread.done[0]) &&
(!uses_2pass || atomic_load(&f->task_thread.done[1])))
{
error = atomic_load(&f->task_thread.error);
dav1d_decode_frame_exit(f, error == 1 ? DAV1D_ERR(EINVAL) :
error ? DAV1D_ERR(ENOMEM) : 0);
f->n_tile_data = 0;
pthread_cond_signal(&f->task_thread.cond);
}
reset_task_cur(c, ttd, t->frame_idx);
}
pthread_mutex_unlock(&ttd->lock);
return NULL;
}
|
82e957566114c29058250bf6342433ddc20bd141
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/net/netatalk3/patches/patch-libatalk_util_getiface.c
|
15810b44de0abd3af76cfeeed74ffd748f3c3b6d
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283
| 2023-09-01T05:25:19
| 2023-09-01T05:25:19
| 88,439,572
| 321
| 138
| null | 2023-07-12T22:34:14
| 2017-04-16T20:04:15
| null |
UTF-8
|
C
| false
| false
| 1,108
|
c
|
patch-libatalk_util_getiface.c
|
$NetBSD: patch-libatalk_util_getiface.c,v 1.2 2016/11/07 12:46:52 christos Exp $
Provide support for getifaddrs
--- libatalk/util/getiface.c.orig 2013-04-09 12:56:18.000000000 +0000
+++ libatalk/util/getiface.c
@@ -12,6 +12,11 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+
+#ifdef HAVE_GETIFADDRS
+#include <ifaddrs.h>
+#endif
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
@@ -70,6 +75,28 @@ static int getifaces(const int sockfd, c
*list = new;
return i;
+#elif defined(HAVE_GETIFADDRS)
+ struct ifaddrs *ifa, *a;
+ int i;
+ char **new;
+
+ if (!list)
+ return 0;
+ if (getifaddrs(&ifa) == -1)
+ return 0;
+ for (i = 0, a = ifa; a != NULL; a = a->ifa_next, i++)
+ continue;
+ new = malloc((i + 1) * sizeof(char *));
+ if (new == NULL) {
+ freeifaddrs(ifa);
+ return 0;
+ }
+ for (i = 0, a = ifa; a != NULL; a = a->ifa_next)
+ if (addname(new, &i, a->ifa_name) < 0)
+ break;
+ freeifaddrs(ifa);
+ *list = new;
+ return i;
#else
struct ifconf ifc;
struct ifreq ifrs[ 64 ], *ifr, *nextifr;
|
8c24065ea9999e546d761eae908f60246f983a70
|
88aca3340574f733b9ecd6f76708ecd2d57cb07e
|
/vendor/bundle/ruby/2.6.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/ruby_http_parser.c
|
e30f349bd333204410ba98713d2d59c3dc48094f
|
[
"Apache-2.0",
"MIT"
] |
permissive
|
collabnix/dockerlabs
|
65c63a8424d34120bddc0fc8d6fd54a688953491
|
0f2a6b906a8ca0ebc28561236d4d6516f93b184c
|
refs/heads/master
| 2023-09-05T07:30:30.601797
| 2023-09-05T07:25:53
| 2023-09-05T07:25:53
| 153,069,455
| 5,239
| 1,854
|
Apache-2.0
| 2023-09-03T05:51:41
| 2018-10-15T07:19:18
|
PHP
|
UTF-8
|
C
| false
| false
| 15,934
|
c
|
ruby_http_parser.c
|
#include "ruby.h"
#include "ext_help.h"
#include "ryah_http_parser.h"
#define GET_WRAPPER(N, from) ParserWrapper *N = (ParserWrapper *)(from)->data;
#define HASH_CAT(h, k, ptr, len) \
do { \
VALUE __v = rb_hash_aref(h, k); \
if (__v != Qnil) { \
rb_str_cat(__v, ptr, len); \
} else { \
rb_hash_aset(h, k, rb_str_new(ptr, len)); \
} \
} while(0)
typedef struct ParserWrapper {
ryah_http_parser parser;
VALUE status;
VALUE request_url;
VALUE headers;
VALUE upgrade_data;
VALUE on_message_begin;
VALUE on_headers_complete;
VALUE on_body;
VALUE on_message_complete;
VALUE callback_object;
VALUE stopped;
VALUE completed;
VALUE header_value_type;
VALUE last_field_name;
VALUE curr_field_name;
enum ryah_http_parser_type type;
} ParserWrapper;
void ParserWrapper_init(ParserWrapper *wrapper) {
ryah_http_parser_init(&wrapper->parser, wrapper->type);
wrapper->parser.status_code = 0;
wrapper->parser.http_major = 0;
wrapper->parser.http_minor = 0;
wrapper->status = Qnil;
wrapper->request_url = Qnil;
wrapper->upgrade_data = Qnil;
wrapper->headers = Qnil;
wrapper->completed = Qfalse;
wrapper->last_field_name = Qnil;
wrapper->curr_field_name = Qnil;
}
void ParserWrapper_mark(void *data) {
if(data) {
ParserWrapper *wrapper = (ParserWrapper *) data;
rb_gc_mark_maybe(wrapper->status);
rb_gc_mark_maybe(wrapper->request_url);
rb_gc_mark_maybe(wrapper->upgrade_data);
rb_gc_mark_maybe(wrapper->headers);
rb_gc_mark_maybe(wrapper->on_message_begin);
rb_gc_mark_maybe(wrapper->on_headers_complete);
rb_gc_mark_maybe(wrapper->on_body);
rb_gc_mark_maybe(wrapper->on_message_complete);
rb_gc_mark_maybe(wrapper->callback_object);
rb_gc_mark_maybe(wrapper->last_field_name);
rb_gc_mark_maybe(wrapper->curr_field_name);
}
}
void ParserWrapper_free(void *data) {
if(data) {
free(data);
}
}
static VALUE cParser;
static VALUE cRequestParser;
static VALUE cResponseParser;
static VALUE eParserError;
static ID Icall;
static ID Ion_message_begin;
static ID Ion_headers_complete;
static ID Ion_body;
static ID Ion_message_complete;
static VALUE Sstop;
static VALUE Sreset;
static VALUE Sarrays;
static VALUE Sstrings;
static VALUE Smixed;
/** Callbacks **/
int on_message_begin(ryah_http_parser *parser) {
GET_WRAPPER(wrapper, parser);
wrapper->status = rb_str_new2("");
wrapper->request_url = rb_str_new2("");
wrapper->headers = rb_hash_new();
wrapper->upgrade_data = rb_str_new2("");
VALUE ret = Qnil;
if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_message_begin)) {
ret = rb_funcall(wrapper->callback_object, Ion_message_begin, 0);
} else if (wrapper->on_message_begin != Qnil) {
ret = rb_funcall(wrapper->on_message_begin, Icall, 0);
}
if (ret == Sstop) {
wrapper->stopped = Qtrue;
return -1;
} else {
return 0;
}
}
int on_status(ryah_http_parser *parser, const char *at, size_t length) {
GET_WRAPPER(wrapper, parser);
if (at && length) {
if (wrapper->status == Qnil) {
wrapper->status = rb_str_new(at, length);
} else {
rb_str_cat(wrapper->status, at, length);
}
}
return 0;
}
int on_url(ryah_http_parser *parser, const char *at, size_t length) {
GET_WRAPPER(wrapper, parser);
if (at && length) {
if (wrapper->request_url == Qnil) {
wrapper->request_url = rb_str_new(at, length);
} else {
rb_str_cat(wrapper->request_url, at, length);
}
}
return 0;
}
int on_header_field(ryah_http_parser *parser, const char *at, size_t length) {
GET_WRAPPER(wrapper, parser);
if (wrapper->curr_field_name == Qnil) {
wrapper->last_field_name = Qnil;
wrapper->curr_field_name = rb_str_new(at, length);
} else {
rb_str_cat(wrapper->curr_field_name, at, length);
}
return 0;
}
int on_header_value(ryah_http_parser *parser, const char *at, size_t length) {
GET_WRAPPER(wrapper, parser);
int new_field = 0;
VALUE current_value;
if (wrapper->last_field_name == Qnil) {
new_field = 1;
wrapper->last_field_name = wrapper->curr_field_name;
wrapper->curr_field_name = Qnil;
}
current_value = rb_hash_aref(wrapper->headers, wrapper->last_field_name);
if (new_field == 1) {
if (current_value == Qnil) {
if (wrapper->header_value_type == Sarrays) {
rb_hash_aset(wrapper->headers, wrapper->last_field_name, rb_ary_new3(1, rb_str_new2("")));
} else {
rb_hash_aset(wrapper->headers, wrapper->last_field_name, rb_str_new2(""));
}
} else {
if (wrapper->header_value_type == Smixed) {
if (TYPE(current_value) == T_STRING) {
rb_hash_aset(wrapper->headers, wrapper->last_field_name, rb_ary_new3(2, current_value, rb_str_new2("")));
} else {
rb_ary_push(current_value, rb_str_new2(""));
}
} else if (wrapper->header_value_type == Sarrays) {
rb_ary_push(current_value, rb_str_new2(""));
} else {
rb_str_cat(current_value, ", ", 2);
}
}
current_value = rb_hash_aref(wrapper->headers, wrapper->last_field_name);
}
if (TYPE(current_value) == T_ARRAY) {
current_value = rb_ary_entry(current_value, -1);
}
rb_str_cat(current_value, at, length);
return 0;
}
int on_headers_complete(ryah_http_parser *parser) {
GET_WRAPPER(wrapper, parser);
VALUE ret = Qnil;
if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_headers_complete)) {
ret = rb_funcall(wrapper->callback_object, Ion_headers_complete, 1, wrapper->headers);
} else if (wrapper->on_headers_complete != Qnil) {
ret = rb_funcall(wrapper->on_headers_complete, Icall, 1, wrapper->headers);
}
if (ret == Sstop) {
wrapper->stopped = Qtrue;
return -1;
} else if (ret == Sreset){
return 1;
} else {
return 0;
}
}
int on_body(ryah_http_parser *parser, const char *at, size_t length) {
GET_WRAPPER(wrapper, parser);
VALUE ret = Qnil;
if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_body)) {
ret = rb_funcall(wrapper->callback_object, Ion_body, 1, rb_str_new(at, length));
} else if (wrapper->on_body != Qnil) {
ret = rb_funcall(wrapper->on_body, Icall, 1, rb_str_new(at, length));
}
if (ret == Sstop) {
wrapper->stopped = Qtrue;
return -1;
} else {
return 0;
}
}
int on_message_complete(ryah_http_parser *parser) {
GET_WRAPPER(wrapper, parser);
VALUE ret = Qnil;
wrapper->completed = Qtrue;
if (wrapper->callback_object != Qnil && rb_respond_to(wrapper->callback_object, Ion_message_complete)) {
ret = rb_funcall(wrapper->callback_object, Ion_message_complete, 0);
} else if (wrapper->on_message_complete != Qnil) {
ret = rb_funcall(wrapper->on_message_complete, Icall, 0);
}
if (ret == Sstop) {
wrapper->stopped = Qtrue;
return -1;
} else {
return 0;
}
}
static ryah_http_parser_settings settings = {
.on_message_begin = on_message_begin,
.on_status = on_status,
.on_url = on_url,
.on_header_field = on_header_field,
.on_header_value = on_header_value,
.on_headers_complete = on_headers_complete,
.on_body = on_body,
.on_message_complete = on_message_complete
};
VALUE Parser_alloc_by_type(VALUE klass, enum ryah_http_parser_type type) {
ParserWrapper *wrapper = ALLOC_N(ParserWrapper, 1);
wrapper->type = type;
wrapper->parser.data = wrapper;
wrapper->on_message_begin = Qnil;
wrapper->on_headers_complete = Qnil;
wrapper->on_body = Qnil;
wrapper->on_message_complete = Qnil;
wrapper->callback_object = Qnil;
ParserWrapper_init(wrapper);
return Data_Wrap_Struct(klass, ParserWrapper_mark, ParserWrapper_free, wrapper);
}
VALUE Parser_alloc(VALUE klass) {
return Parser_alloc_by_type(klass, HTTP_BOTH);
}
VALUE RequestParser_alloc(VALUE klass) {
return Parser_alloc_by_type(klass, HTTP_REQUEST);
}
VALUE ResponseParser_alloc(VALUE klass) {
return Parser_alloc_by_type(klass, HTTP_RESPONSE);
}
VALUE Parser_strict_p(VALUE klass) {
return HTTP_PARSER_STRICT == 1 ? Qtrue : Qfalse;
}
VALUE Parser_initialize(int argc, VALUE *argv, VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
VALUE default_header_value_type = Qnil;
if (argc > 0 && RB_TYPE_P(argv[argc-1], T_HASH)) {
ID keyword_ids[1];
keyword_ids[0] = rb_intern("default_header_value_type");
rb_get_kwargs(argv[argc-1], keyword_ids, 0, 1, &default_header_value_type);
if (default_header_value_type == Qundef) {
default_header_value_type = Qnil;
}
--argc;
}
if (argc == 1) {
wrapper->callback_object = argv[0];
}
if (argc == 2) {
wrapper->callback_object = argv[0];
default_header_value_type = argv[1];
}
if (default_header_value_type == Qnil) {
wrapper->header_value_type = rb_iv_get(CLASS_OF(self), "@default_header_value_type");
} else {
wrapper->header_value_type = default_header_value_type;
}
return self;
}
VALUE Parser_execute(VALUE self, VALUE data) {
ParserWrapper *wrapper = NULL;
Check_Type(data, T_STRING);
char *ptr = RSTRING_PTR(data);
long len = RSTRING_LEN(data);
DATA_GET(self, ParserWrapper, wrapper);
wrapper->stopped = Qfalse;
size_t nparsed = ryah_http_parser_execute(&wrapper->parser, &settings, ptr, len);
if (wrapper->parser.upgrade) {
if (RTEST(wrapper->stopped) && !RTEST(wrapper->completed))
nparsed += 1;
if (nparsed < len)
rb_str_cat(wrapper->upgrade_data, ptr + nparsed, len - nparsed);
} else if (nparsed != (size_t)len) {
if (!RTEST(wrapper->stopped) && !RTEST(wrapper->completed))
rb_raise(eParserError, "Could not parse data entirely (%zu != %zu)", nparsed, len);
else
nparsed += 1; // error states fail on the current character
}
return INT2FIX(nparsed);
}
VALUE Parser_set_on_message_begin(VALUE self, VALUE callback) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
wrapper->on_message_begin = callback;
return callback;
}
VALUE Parser_set_on_headers_complete(VALUE self, VALUE callback) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
wrapper->on_headers_complete = callback;
return callback;
}
VALUE Parser_set_on_body(VALUE self, VALUE callback) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
wrapper->on_body = callback;
return callback;
}
VALUE Parser_set_on_message_complete(VALUE self, VALUE callback) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
wrapper->on_message_complete = callback;
return callback;
}
VALUE Parser_keep_alive_p(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
return http_should_keep_alive(&wrapper->parser) == 1 ? Qtrue : Qfalse;
}
VALUE Parser_upgrade_p(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
return wrapper->parser.upgrade ? Qtrue : Qfalse;
}
VALUE Parser_http_version(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
if (wrapper->parser.http_major == 0 && wrapper->parser.http_minor == 0)
return Qnil;
else
return rb_ary_new3(2, INT2FIX(wrapper->parser.http_major), INT2FIX(wrapper->parser.http_minor));
}
VALUE Parser_http_major(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
if (wrapper->parser.http_major == 0 && wrapper->parser.http_minor == 0)
return Qnil;
else
return INT2FIX(wrapper->parser.http_major);
}
VALUE Parser_http_minor(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
if (wrapper->parser.http_major == 0 && wrapper->parser.http_minor == 0)
return Qnil;
else
return INT2FIX(wrapper->parser.http_minor);
}
VALUE Parser_http_method(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
if (wrapper->parser.type == HTTP_REQUEST)
return rb_str_new2(http_method_str(wrapper->parser.method));
else
return Qnil;
}
VALUE Parser_status_code(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
if (wrapper->parser.status_code)
return INT2FIX(wrapper->parser.status_code);
else
return Qnil;
}
#define DEFINE_GETTER(name) \
VALUE Parser_##name(VALUE self) { \
ParserWrapper *wrapper = NULL; \
DATA_GET(self, ParserWrapper, wrapper); \
return wrapper->name; \
}
DEFINE_GETTER(status);
DEFINE_GETTER(request_url);
DEFINE_GETTER(headers);
DEFINE_GETTER(upgrade_data);
DEFINE_GETTER(header_value_type);
VALUE Parser_set_header_value_type(VALUE self, VALUE val) {
if (val != Sarrays && val != Sstrings && val != Smixed) {
rb_raise(rb_eArgError, "Invalid header value type");
}
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
wrapper->header_value_type = val;
return wrapper->header_value_type;
}
VALUE Parser_reset(VALUE self) {
ParserWrapper *wrapper = NULL;
DATA_GET(self, ParserWrapper, wrapper);
ParserWrapper_init(wrapper);
return Qtrue;
}
void Init_ruby_http_parser() {
#ifdef HAVE_RB_EXT_RACTOR_SAFE
rb_ext_ractor_safe(true);
#endif
VALUE mHTTP = rb_define_module("HTTP");
cParser = rb_define_class_under(mHTTP, "Parser", rb_cObject);
cRequestParser = rb_define_class_under(mHTTP, "RequestParser", cParser);
cResponseParser = rb_define_class_under(mHTTP, "ResponseParser", cParser);
eParserError = rb_define_class_under(cParser, "Error", rb_eIOError);
Icall = rb_intern("call");
Ion_message_begin = rb_intern("on_message_begin");
Ion_headers_complete = rb_intern("on_headers_complete");
Ion_body = rb_intern("on_body");
Ion_message_complete = rb_intern("on_message_complete");
Sstop = ID2SYM(rb_intern("stop"));
Sreset = ID2SYM(rb_intern("reset"));
Sarrays = ID2SYM(rb_intern("arrays"));
Sstrings = ID2SYM(rb_intern("strings"));
Smixed = ID2SYM(rb_intern("mixed"));
rb_define_alloc_func(cParser, Parser_alloc);
rb_define_alloc_func(cRequestParser, RequestParser_alloc);
rb_define_alloc_func(cResponseParser, ResponseParser_alloc);
rb_define_singleton_method(cParser, "strict?", Parser_strict_p, 0);
rb_define_method(cParser, "initialize", Parser_initialize, -1);
rb_define_method(cParser, "on_message_begin=", Parser_set_on_message_begin, 1);
rb_define_method(cParser, "on_headers_complete=", Parser_set_on_headers_complete, 1);
rb_define_method(cParser, "on_body=", Parser_set_on_body, 1);
rb_define_method(cParser, "on_message_complete=", Parser_set_on_message_complete, 1);
rb_define_method(cParser, "<<", Parser_execute, 1);
rb_define_method(cParser, "keep_alive?", Parser_keep_alive_p, 0);
rb_define_method(cParser, "upgrade?", Parser_upgrade_p, 0);
rb_define_method(cParser, "http_version", Parser_http_version, 0);
rb_define_method(cParser, "http_major", Parser_http_major, 0);
rb_define_method(cParser, "http_minor", Parser_http_minor, 0);
rb_define_method(cParser, "http_method", Parser_http_method, 0);
rb_define_method(cParser, "status_code", Parser_status_code, 0);
rb_define_method(cParser, "status", Parser_status, 0);
rb_define_method(cParser, "request_url", Parser_request_url, 0);
rb_define_method(cParser, "headers", Parser_headers, 0);
rb_define_method(cParser, "upgrade_data", Parser_upgrade_data, 0);
rb_define_method(cParser, "header_value_type", Parser_header_value_type, 0);
rb_define_method(cParser, "header_value_type=", Parser_set_header_value_type, 1);
rb_define_method(cParser, "reset!", Parser_reset, 0);
}
|
ce65ce412417c82e5765e7f833dd566a98ac1845
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/inputmethod/skkfep/patches/patch-skklib.c
|
07790ae8b8838f9fb16ff8bc7b3f9dcee5d128f9
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283
| 2023-09-01T05:25:19
| 2023-09-01T05:25:19
| 88,439,572
| 321
| 138
| null | 2023-07-12T22:34:14
| 2017-04-16T20:04:15
| null |
UTF-8
|
C
| false
| false
| 733
|
c
|
patch-skklib.c
|
$NetBSD: patch-skklib.c,v 1.1 2012/12/20 21:50:47 joerg Exp $
--- skklib.c.orig 2012-12-20 14:41:31.000000000 +0000
+++ skklib.c
@@ -15,6 +15,8 @@ static char *allocStr();
/* char *malloc(); */
int hashVal();
+static void mergeDictionary(Dictionary dic, char *dicname);
+
/*
* Open SKK
*/
@@ -235,9 +237,7 @@ int okuri;
return citem0;
}
-closeSKK(dic,dicname)
-Dictionary dic;
-char *dicname;
+void closeSKK(Dictionary dic, char *dicname)
{
char *buf;
FILE *f;
@@ -301,9 +301,7 @@ char *dicname;
/* #define DEBUG_MERGE /* debug dictionary merge */
-mergeDictionary(dic,dicname)
-Dictionary dic;
-char *dicname;
+static void mergeDictionary(Dictionary dic, char *dicname)
{
FILE *f;
CandList cand,dcand;
|
7feb0bf8e0247beaa81340e05069263d9e7b6490
|
276b41398db43c33314e822667592dc37cd11795
|
/cpp/test/kev/kev_eval.c
|
fd4afd922cb466c3884fc1cac1d3201e818a44ff
|
[
"Apache-2.0"
] |
permissive
|
HenryRLee/PokerHandEvaluator
|
f7dcaab12453a88f8e19dec66e7c15e4113e6a36
|
4715359b497a62ab00071a4754557da6dd49f241
|
refs/heads/master
| 2023-07-06T18:09:44.216288
| 2023-07-05T11:44:42
| 2023-07-05T11:44:42
| 53,184,524
| 269
| 90
|
Apache-2.0
| 2023-09-03T12:27:15
| 2016-03-05T05:05:24
|
C
|
UTF-8
|
C
| false
| false
| 1,847
|
c
|
kev_eval.c
|
extern short eval_5cards_fast(int c1, int c2, int c3, int c4, int c5);
extern short eval_6cards_fast(int c1, int c2, int c3, int c4, int c5, int c6);
extern short eval_7cards_fast(int c1, int c2, int c3, int c4, int c5, int c6, int c7);
extern short eval_8cards_fast(int c1, int c2, int c3, int c4, int c5, int c6, int c7, int c8);
extern short eval_9cards_fast(int c1, int c2, int c3, int c4, int c5, int c6, int c7, int c8, int c9);
int deck[52] =
{
98306, 81922, 73730, 69634, 164099, 147715, 139523, 135427, 295429, 279045, 270853, 266757, 557831, 541447, 533255, 529159, 1082379, 1065995, 1057803, 1053707, 2131213, 2114829, 2106637, 2102541, 4228625, 4212241, 4204049, 4199953, 8423187, 8406803, 8398611, 8394515, 16812055, 16795671, 16787479, 16783383, 33589533, 33573149, 33564957, 33560861, 67144223, 67127839, 67119647, 67115551, 134253349, 134236965, 134228773, 134224677, 268471337, 268454953, 268446761, 268442665,
};
short kev_eval_5cards(int c1, int c2, int c3, int c4, int c5)
{
return eval_5cards_fast(deck[c1], deck[c2], deck[c3], deck[c4], deck[c5]);
}
short kev_eval_6cards(int c1, int c2, int c3, int c4, int c5, int c6)
{
return eval_6cards_fast(deck[c1], deck[c2], deck[c3], deck[c4], deck[c5], deck[c6]);
}
short kev_eval_7cards(int c1, int c2, int c3, int c4, int c5, int c6, int c7)
{
return eval_7cards_fast(deck[c1], deck[c2], deck[c3], deck[c4], deck[c5], deck[c6], deck[c7]);
}
short kev_eval_8cards(int c1, int c2, int c3, int c4, int c5, int c6, int c7, int c8)
{
return eval_8cards_fast(deck[c1], deck[c2], deck[c3], deck[c4], deck[c5], deck[c6], deck[c7], deck[c8]);
}
short kev_eval_9cards(int c1, int c2, int c3, int c4, int c5, int c6, int c7, int c8, int c9)
{
return eval_9cards_fast(deck[c1], deck[c2], deck[c3], deck[c4], deck[c5], deck[c6], deck[c7], deck[c8], deck[c9]);
}
|
fc2e5dcb40c58c049bdebccc63c7064cee0a6e87
|
ff2180134ad76ce50d9b9a162edf035c3914ab4a
|
/port/esp32/hawkbit/test/main/hawkbit_util_test.c
|
3c87ae6c7886a3e62347ac24db301b2fe4367d62
|
[
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
iotivity/iotivity-lite
|
4ddddfc7d76766d1c5e94d81dd26e28f8cb4a940
|
1597367d65bad60a26511775ee47e5496186ddca
|
refs/heads/master
| 2023-08-16T18:09:54.615426
| 2023-08-09T19:05:42
| 2023-08-09T19:05:42
| 171,529,940
| 143
| 80
|
Apache-2.0
| 2023-09-14T07:31:04
| 2019-02-19T18:47:09
|
C
|
UTF-8
|
C
| false
| false
| 3,028
|
c
|
hawkbit_util_test.c
|
/****************************************************************************
*
* Copyright (c) 2022 Jozef Kralik, All Rights Reserved.
* Copyright (c) 2022 Daniel Adam, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"),
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************/
#include "../../hawkbit_util.h"
#include "unity.h"
#include <string.h>
TEST_CASE("sha256 hash to hex string", "[hawkbit][util]")
{
hawkbit_sha256_hash_t hash = {
.data = "0bf474896363505e5ea5e5d6ace8ebfb13a760a409b1fb467d428fc716f9f284",
};
hawkbit_sha256_digest_t digest = hawkbit_sha256_hash_to_digest(hash);
char data[HAWKBIT_SHA256_DIGEST_SIZE + 1];
memcpy(data, digest.data, sizeof(digest.data));
data[HAWKBIT_SHA256_DIGEST_SIZE] = 0;
// printf("digest: %s\n", data);
hawkbit_sha256_hash_t hash2 = hawkbit_sha256_digest_to_hash(digest);
// printf("hash: %s\n", hash.data);
// printf("hash2: %s\n", hash2.data);
TEST_ASSERT_EQUAL_MEMORY(hash.data, hash2.data, sizeof(hash.data));
}
TEST_CASE("parse hawkbit url", "[hawkbit][util]")
{
TEST_ASSERT_FALSE(hawkbit_parse_package_url("test", NULL));
hawkbit_url_t url;
TEST_ASSERT_TRUE(
hawkbit_parse_package_url("https://hawkbit.try.plgd.cloud", &url));
TEST_ASSERT_EQUAL_STRING("https://hawkbit.try.plgd.cloud", url.server_url);
TEST_ASSERT_NULL(url.controller_id);
TEST_ASSERT_NULL(url.tenant);
#define BASE_URL "https://hawkbit.try.plgd.cloud"
#define TENANT_ID "TENANT_ID"
#define CONTROLLER_ID "CONTROLLER_ID"
TEST_ASSERT_TRUE(hawkbit_parse_package_url(BASE_URL "/" TENANT_ID, &url));
TEST_ASSERT_EQUAL(url.server_url_length, sizeof(BASE_URL) - 1);
TEST_ASSERT_EQUAL_MEMORY(BASE_URL, url.server_url, url.server_url_length);
TEST_ASSERT_EQUAL(url.tenant_length, sizeof(TENANT_ID) - 1);
TEST_ASSERT_EQUAL_MEMORY(TENANT_ID, url.tenant, url.tenant_length);
TEST_ASSERT_NULL(url.controller_id);
TEST_ASSERT_TRUE(hawkbit_parse_package_url(
BASE_URL "/" TENANT_ID "/controller/v1/" CONTROLLER_ID, &url));
TEST_ASSERT_EQUAL(url.server_url_length, sizeof(BASE_URL) - 1);
TEST_ASSERT_EQUAL_MEMORY(BASE_URL, url.server_url, url.server_url_length);
TEST_ASSERT_EQUAL(url.tenant_length, sizeof(TENANT_ID) - 1);
TEST_ASSERT_EQUAL_MEMORY(TENANT_ID, url.tenant, url.tenant_length);
TEST_ASSERT_EQUAL(url.controller_id_length, sizeof(CONTROLLER_ID) - 1);
TEST_ASSERT_EQUAL_MEMORY(CONTROLLER_ID, url.controller_id,
url.controller_id_length);
}
|
bb9718e8fc0fb7d538448e7c2f4c698c657d490a
|
eecd5e4c50d8b78a769bcc2675250576bed34066
|
/src/mat/tests/ex46.c
|
0fdfeabda946f64e179e4beebb4b2454770fd009
|
[
"BSD-2-Clause"
] |
permissive
|
petsc/petsc
|
3b1a04fea71858e0292f9fd4d04ea11618c50969
|
9c5460f9064ca60dd71a234a1f6faf93e7a6b0c9
|
refs/heads/main
| 2023-08-17T20:51:16.507070
| 2023-08-17T16:08:06
| 2023-08-17T16:08:06
| 8,691,401
| 341
| 169
|
NOASSERTION
| 2023-03-29T11:02:58
| 2013-03-10T20:55:21
|
C
|
UTF-8
|
C
| false
| false
| 2,321
|
c
|
ex46.c
|
static char help[] = "Tests late MatSetBlockSizes.\n\n";
#include <petscmat.h>
int main(int argc, char **args)
{
Mat A;
Vec x[4];
IS is;
ISLocalToGlobalMapping rmap, cmap;
PetscInt bs[4], l2gbs[4], rbs, cbs, l2grbs, l2gcbs, i;
PetscFunctionBeginUser;
PetscCall(PetscInitialize(&argc, &args, (char *)0, help));
PetscCall(MatCreate(PETSC_COMM_WORLD, &A));
PetscCall(MatSetSizes(A, 12, 12, PETSC_DECIDE, PETSC_DECIDE));
PetscCall(MatSetType(A, MATAIJ));
PetscCall(ISCreateStride(PETSC_COMM_WORLD, 12, 0, 1, &is));
PetscCall(ISLocalToGlobalMappingCreateIS(is, &rmap));
PetscCall(ISLocalToGlobalMappingSetBlockSize(rmap, 2));
PetscCall(ISLocalToGlobalMappingCreateIS(is, &cmap));
PetscCall(ISLocalToGlobalMappingSetBlockSize(cmap, 2));
PetscCall(MatSetLocalToGlobalMapping(A, rmap, cmap));
PetscCall(ISLocalToGlobalMappingDestroy(&rmap));
PetscCall(ISLocalToGlobalMappingDestroy(&cmap));
PetscCall(ISDestroy(&is));
PetscCall(MatSetUp(A));
PetscCall(MatCreateVecs(A, &x[1], &x[0]));
PetscCall(MatSetBlockSizes(A, 6, 3));
PetscCall(MatCreateVecs(A, &x[3], &x[2]));
for (i = 0; i < 4; i++) {
ISLocalToGlobalMapping l2g;
PetscCall(VecGetBlockSize(x[i], &bs[i]));
PetscCall(VecGetLocalToGlobalMapping(x[i], &l2g));
PetscCall(ISLocalToGlobalMappingGetBlockSize(l2g, &l2gbs[i]));
PetscCall(VecDestroy(&x[i]));
}
PetscCall(MatGetBlockSizes(A, &rbs, &cbs));
PetscCall(MatGetLocalToGlobalMapping(A, &rmap, &cmap));
PetscCall(ISLocalToGlobalMappingGetBlockSize(rmap, &l2grbs));
PetscCall(ISLocalToGlobalMappingGetBlockSize(cmap, &l2gcbs));
PetscCall(MatDestroy(&A));
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Mat Block sizes: %" PetscInt_FMT " %" PetscInt_FMT " (l2g %" PetscInt_FMT " %" PetscInt_FMT ")\n", rbs, cbs, l2grbs, l2gcbs));
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Vec Block sizes: %" PetscInt_FMT " %" PetscInt_FMT " (l2g %" PetscInt_FMT " %" PetscInt_FMT ")\n", bs[0], bs[1], l2gbs[0], l2gbs[1]));
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Vec Block sizes: %" PetscInt_FMT " %" PetscInt_FMT " (l2g %" PetscInt_FMT " %" PetscInt_FMT ")\n", bs[2], bs[3], l2gbs[2], l2gbs[3]));
PetscCall(PetscFinalize());
return 0;
}
/*TEST
test:
nsize: 2
TEST*/
|
d2049e9ed09caffdeebb09a1a4e411dbb1cd1825
|
73fbb7c1c93f53c9499e83f13c5ed8e4d4ce9d4a
|
/tests/kvasir-tests/perl/globals.c
|
994ca8da957dc72bbdf4a44d495f13e0c509c1fd
|
[
"MIT"
] |
permissive
|
codespecs/daikon
|
8cccbaa7cce77d88160ae368054d9ef74043d465
|
62109d49852676657ce3205283cebbb46456425c
|
refs/heads/master
| 2023-09-01T19:45:13.280344
| 2023-08-22T03:21:40
| 2023-08-22T03:21:40
| 37,424,689
| 183
| 56
|
NOASSERTION
| 2023-08-22T03:21:41
| 2015-06-14T18:40:55
|
C
|
UTF-8
|
C
| false
| false
| 1,643
|
c
|
globals.c
|
/* globals.c
*
* Copyright (C) 1995, 1999, 2000, 2001, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
/*
* "For the rest, they shall represent the other Free Peoples of the World:
* Elves, Dwarves, and Men." --Elrond
*/
/* This file exists to #include "perl.h" _ONCE_ with
* PERL_IN_GLOBALS_C defined. That causes various global varaiables
* in perl.h and other files it includes to be _defined_ (and initialized)
* rather than just declared.
*
* There is a #include "perlapi.h" which makes use of the fact
* that the object file created from this file will be included by linker
* (to resolve global variables). perlapi.h mention various other "API"
* functions not used by perl itself, but the functions get
* pulled into the perl executable via the refrerence here.
*
* Two printf() like functions have also found their way here.
* Most likely by analogy to the API scheme above (as perl doesn't
* use them) but they probably belong elsewhere the obvious place
* being in perlio.c
*
*/
#include "INTERN.h"
#define PERL_IN_GLOBALS_C
#include "perl.h"
int
Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
{
dTHXs;
va_list(arglist);
va_start(arglist, format);
return PerlIO_vprintf(stream, format, arglist);
}
int
Perl_printf_nocontext(const char *format, ...)
{
dTHX;
va_list(arglist);
va_start(arglist, format);
return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
}
#include "perlapi.h" /* bring in PL_force_link_funcs */
|
0f578497265efa1a9a0b50a9133a34ad9c905555
|
f1ee65fbe1ffc43c2aac45e41515f1987eb534a4
|
/src/third_party/boringssl/src/crypto/obj/obj.c
|
67c73d4f3533729bbf2e105dd5b9b3d97340b54e
|
[
"BSD-3-Clause",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"ISC",
"OpenSSL",
"MIT"
] |
permissive
|
klzgrad/naiveproxy
|
6e0d206b6f065b9311d1e12b363109f2d35cc058
|
8ef1cecadfd4e2b5d57e7ea2fa42d05717e51c2e
|
refs/heads/master
| 2023-08-20T22:42:12.511091
| 2023-06-04T03:54:34
| 2023-08-16T23:30:19
| 119,178,893
| 5,710
| 976
|
BSD-3-Clause
| 2023-08-05T10:59:59
| 2018-01-27T16:02:33
|
C++
|
UTF-8
|
C
| false
| false
| 16,124
|
c
|
obj.c
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.] */
#include <openssl/obj.h>
#include <inttypes.h>
#include <limits.h>
#include <string.h>
#include <openssl/asn1.h>
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/lhash.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include "../asn1/internal.h"
#include "../internal.h"
#include "../lhash/internal.h"
// obj_data.h must be included after the definition of |ASN1_OBJECT|.
#include "obj_dat.h"
DEFINE_LHASH_OF(ASN1_OBJECT)
static CRYPTO_MUTEX global_added_lock = CRYPTO_MUTEX_INIT;
// These globals are protected by |global_added_lock|.
static LHASH_OF(ASN1_OBJECT) *global_added_by_data = NULL;
static LHASH_OF(ASN1_OBJECT) *global_added_by_nid = NULL;
static LHASH_OF(ASN1_OBJECT) *global_added_by_short_name = NULL;
static LHASH_OF(ASN1_OBJECT) *global_added_by_long_name = NULL;
static CRYPTO_MUTEX global_next_nid_lock = CRYPTO_MUTEX_INIT;
static unsigned global_next_nid = NUM_NID;
static int obj_next_nid(void) {
CRYPTO_MUTEX_lock_write(&global_next_nid_lock);
int ret = global_next_nid++;
CRYPTO_MUTEX_unlock_write(&global_next_nid_lock);
return ret;
}
ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o) {
ASN1_OBJECT *r;
unsigned char *data = NULL;
char *sn = NULL, *ln = NULL;
if (o == NULL) {
return NULL;
}
if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC)) {
// TODO(fork): this is a little dangerous.
return (ASN1_OBJECT *)o;
}
r = ASN1_OBJECT_new();
if (r == NULL) {
OPENSSL_PUT_ERROR(OBJ, ERR_R_ASN1_LIB);
return NULL;
}
r->ln = r->sn = NULL;
data = OPENSSL_malloc(o->length);
if (data == NULL) {
goto err;
}
if (o->data != NULL) {
OPENSSL_memcpy(data, o->data, o->length);
}
// once data is attached to an object, it remains const
r->data = data;
r->length = o->length;
r->nid = o->nid;
if (o->ln != NULL) {
ln = OPENSSL_strdup(o->ln);
if (ln == NULL) {
goto err;
}
}
if (o->sn != NULL) {
sn = OPENSSL_strdup(o->sn);
if (sn == NULL) {
goto err;
}
}
r->sn = sn;
r->ln = ln;
r->flags =
o->flags | (ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
ASN1_OBJECT_FLAG_DYNAMIC_DATA);
return r;
err:
OPENSSL_free(ln);
OPENSSL_free(sn);
OPENSSL_free(data);
OPENSSL_free(r);
return NULL;
}
int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b) {
int ret;
ret = a->length - b->length;
if (ret) {
return ret;
}
return OPENSSL_memcmp(a->data, b->data, a->length);
}
const uint8_t *OBJ_get0_data(const ASN1_OBJECT *obj) {
if (obj == NULL) {
return NULL;
}
return obj->data;
}
size_t OBJ_length(const ASN1_OBJECT *obj) {
if (obj == NULL || obj->length < 0) {
return 0;
}
return (size_t)obj->length;
}
// obj_cmp is called to search the kNIDsInOIDOrder array. The |key| argument is
// an |ASN1_OBJECT|* that we're looking for and |element| is a pointer to an
// unsigned int in the array.
static int obj_cmp(const void *key, const void *element) {
uint16_t nid = *((const uint16_t *)element);
const ASN1_OBJECT *a = key;
const ASN1_OBJECT *b = &kObjects[nid];
if (a->length < b->length) {
return -1;
} else if (a->length > b->length) {
return 1;
}
return OPENSSL_memcmp(a->data, b->data, a->length);
}
int OBJ_obj2nid(const ASN1_OBJECT *obj) {
if (obj == NULL) {
return NID_undef;
}
if (obj->nid != 0) {
return obj->nid;
}
CRYPTO_MUTEX_lock_read(&global_added_lock);
if (global_added_by_data != NULL) {
ASN1_OBJECT *match;
match = lh_ASN1_OBJECT_retrieve(global_added_by_data, obj);
if (match != NULL) {
CRYPTO_MUTEX_unlock_read(&global_added_lock);
return match->nid;
}
}
CRYPTO_MUTEX_unlock_read(&global_added_lock);
const uint16_t *nid_ptr =
bsearch(obj, kNIDsInOIDOrder, OPENSSL_ARRAY_SIZE(kNIDsInOIDOrder),
sizeof(kNIDsInOIDOrder[0]), obj_cmp);
if (nid_ptr == NULL) {
return NID_undef;
}
return kObjects[*nid_ptr].nid;
}
int OBJ_cbs2nid(const CBS *cbs) {
if (CBS_len(cbs) > INT_MAX) {
return NID_undef;
}
ASN1_OBJECT obj;
OPENSSL_memset(&obj, 0, sizeof(obj));
obj.data = CBS_data(cbs);
obj.length = (int)CBS_len(cbs);
return OBJ_obj2nid(&obj);
}
// short_name_cmp is called to search the kNIDsInShortNameOrder array. The
// |key| argument is name that we're looking for and |element| is a pointer to
// an unsigned int in the array.
static int short_name_cmp(const void *key, const void *element) {
const char *name = (const char *)key;
uint16_t nid = *((const uint16_t *)element);
return strcmp(name, kObjects[nid].sn);
}
int OBJ_sn2nid(const char *short_name) {
CRYPTO_MUTEX_lock_read(&global_added_lock);
if (global_added_by_short_name != NULL) {
ASN1_OBJECT *match, template;
template.sn = short_name;
match = lh_ASN1_OBJECT_retrieve(global_added_by_short_name, &template);
if (match != NULL) {
CRYPTO_MUTEX_unlock_read(&global_added_lock);
return match->nid;
}
}
CRYPTO_MUTEX_unlock_read(&global_added_lock);
const uint16_t *nid_ptr =
bsearch(short_name, kNIDsInShortNameOrder,
OPENSSL_ARRAY_SIZE(kNIDsInShortNameOrder),
sizeof(kNIDsInShortNameOrder[0]), short_name_cmp);
if (nid_ptr == NULL) {
return NID_undef;
}
return kObjects[*nid_ptr].nid;
}
// long_name_cmp is called to search the kNIDsInLongNameOrder array. The
// |key| argument is name that we're looking for and |element| is a pointer to
// an unsigned int in the array.
static int long_name_cmp(const void *key, const void *element) {
const char *name = (const char *)key;
uint16_t nid = *((const uint16_t *)element);
return strcmp(name, kObjects[nid].ln);
}
int OBJ_ln2nid(const char *long_name) {
CRYPTO_MUTEX_lock_read(&global_added_lock);
if (global_added_by_long_name != NULL) {
ASN1_OBJECT *match, template;
template.ln = long_name;
match = lh_ASN1_OBJECT_retrieve(global_added_by_long_name, &template);
if (match != NULL) {
CRYPTO_MUTEX_unlock_read(&global_added_lock);
return match->nid;
}
}
CRYPTO_MUTEX_unlock_read(&global_added_lock);
const uint16_t *nid_ptr = bsearch(
long_name, kNIDsInLongNameOrder, OPENSSL_ARRAY_SIZE(kNIDsInLongNameOrder),
sizeof(kNIDsInLongNameOrder[0]), long_name_cmp);
if (nid_ptr == NULL) {
return NID_undef;
}
return kObjects[*nid_ptr].nid;
}
int OBJ_txt2nid(const char *s) {
ASN1_OBJECT *obj;
int nid;
obj = OBJ_txt2obj(s, 0 /* search names */);
nid = OBJ_obj2nid(obj);
ASN1_OBJECT_free(obj);
return nid;
}
OPENSSL_EXPORT int OBJ_nid2cbb(CBB *out, int nid) {
const ASN1_OBJECT *obj = OBJ_nid2obj(nid);
CBB oid;
if (obj == NULL ||
!CBB_add_asn1(out, &oid, CBS_ASN1_OBJECT) ||
!CBB_add_bytes(&oid, obj->data, obj->length) ||
!CBB_flush(out)) {
return 0;
}
return 1;
}
ASN1_OBJECT *OBJ_nid2obj(int nid) {
if (nid >= 0 && nid < NUM_NID) {
if (nid != NID_undef && kObjects[nid].nid == NID_undef) {
goto err;
}
return (ASN1_OBJECT *)&kObjects[nid];
}
CRYPTO_MUTEX_lock_read(&global_added_lock);
if (global_added_by_nid != NULL) {
ASN1_OBJECT *match, template;
template.nid = nid;
match = lh_ASN1_OBJECT_retrieve(global_added_by_nid, &template);
if (match != NULL) {
CRYPTO_MUTEX_unlock_read(&global_added_lock);
return match;
}
}
CRYPTO_MUTEX_unlock_read(&global_added_lock);
err:
OPENSSL_PUT_ERROR(OBJ, OBJ_R_UNKNOWN_NID);
return NULL;
}
const char *OBJ_nid2sn(int nid) {
const ASN1_OBJECT *obj = OBJ_nid2obj(nid);
if (obj == NULL) {
return NULL;
}
return obj->sn;
}
const char *OBJ_nid2ln(int nid) {
const ASN1_OBJECT *obj = OBJ_nid2obj(nid);
if (obj == NULL) {
return NULL;
}
return obj->ln;
}
static ASN1_OBJECT *create_object_with_text_oid(int (*get_nid)(void),
const char *oid,
const char *short_name,
const char *long_name) {
uint8_t *buf;
size_t len;
CBB cbb;
if (!CBB_init(&cbb, 32) ||
!CBB_add_asn1_oid_from_text(&cbb, oid, strlen(oid)) ||
!CBB_finish(&cbb, &buf, &len)) {
OPENSSL_PUT_ERROR(OBJ, OBJ_R_INVALID_OID_STRING);
CBB_cleanup(&cbb);
return NULL;
}
ASN1_OBJECT *ret = ASN1_OBJECT_create(get_nid ? get_nid() : NID_undef, buf,
len, short_name, long_name);
OPENSSL_free(buf);
return ret;
}
ASN1_OBJECT *OBJ_txt2obj(const char *s, int dont_search_names) {
if (!dont_search_names) {
int nid = OBJ_sn2nid(s);
if (nid == NID_undef) {
nid = OBJ_ln2nid(s);
}
if (nid != NID_undef) {
return OBJ_nid2obj(nid);
}
}
return create_object_with_text_oid(NULL, s, NULL, NULL);
}
static int strlcpy_int(char *dst, const char *src, int dst_size) {
size_t ret = OPENSSL_strlcpy(dst, src, dst_size < 0 ? 0 : (size_t)dst_size);
if (ret > INT_MAX) {
OPENSSL_PUT_ERROR(OBJ, ERR_R_OVERFLOW);
return -1;
}
return (int)ret;
}
int OBJ_obj2txt(char *out, int out_len, const ASN1_OBJECT *obj,
int always_return_oid) {
// Python depends on the empty OID successfully encoding as the empty
// string.
if (obj == NULL || obj->length == 0) {
return strlcpy_int(out, "", out_len);
}
if (!always_return_oid) {
int nid = OBJ_obj2nid(obj);
if (nid != NID_undef) {
const char *name = OBJ_nid2ln(nid);
if (name == NULL) {
name = OBJ_nid2sn(nid);
}
if (name != NULL) {
return strlcpy_int(out, name, out_len);
}
}
}
CBS cbs;
CBS_init(&cbs, obj->data, obj->length);
char *txt = CBS_asn1_oid_to_text(&cbs);
if (txt == NULL) {
if (out_len > 0) {
out[0] = '\0';
}
return -1;
}
int ret = strlcpy_int(out, txt, out_len);
OPENSSL_free(txt);
return ret;
}
static uint32_t hash_nid(const ASN1_OBJECT *obj) {
return obj->nid;
}
static int cmp_nid(const ASN1_OBJECT *a, const ASN1_OBJECT *b) {
return a->nid - b->nid;
}
static uint32_t hash_data(const ASN1_OBJECT *obj) {
return OPENSSL_hash32(obj->data, obj->length);
}
static int cmp_data(const ASN1_OBJECT *a, const ASN1_OBJECT *b) {
int i = a->length - b->length;
if (i) {
return i;
}
return OPENSSL_memcmp(a->data, b->data, a->length);
}
static uint32_t hash_short_name(const ASN1_OBJECT *obj) {
return OPENSSL_strhash(obj->sn);
}
static int cmp_short_name(const ASN1_OBJECT *a, const ASN1_OBJECT *b) {
return strcmp(a->sn, b->sn);
}
static uint32_t hash_long_name(const ASN1_OBJECT *obj) {
return OPENSSL_strhash(obj->ln);
}
static int cmp_long_name(const ASN1_OBJECT *a, const ASN1_OBJECT *b) {
return strcmp(a->ln, b->ln);
}
// obj_add_object inserts |obj| into the various global hashes for run-time
// added objects. It returns one on success or zero otherwise.
static int obj_add_object(ASN1_OBJECT *obj) {
obj->flags &= ~(ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
ASN1_OBJECT_FLAG_DYNAMIC_DATA);
CRYPTO_MUTEX_lock_write(&global_added_lock);
if (global_added_by_nid == NULL) {
global_added_by_nid = lh_ASN1_OBJECT_new(hash_nid, cmp_nid);
}
if (global_added_by_data == NULL) {
global_added_by_data = lh_ASN1_OBJECT_new(hash_data, cmp_data);
}
if (global_added_by_short_name == NULL) {
global_added_by_short_name =
lh_ASN1_OBJECT_new(hash_short_name, cmp_short_name);
}
if (global_added_by_long_name == NULL) {
global_added_by_long_name = lh_ASN1_OBJECT_new(hash_long_name, cmp_long_name);
}
int ok = 0;
if (global_added_by_nid == NULL ||
global_added_by_data == NULL ||
global_added_by_short_name == NULL ||
global_added_by_long_name == NULL) {
goto err;
}
// We don't pay attention to |old_object| (which contains any previous object
// that was evicted from the hashes) because we don't have a reference count
// on ASN1_OBJECT values. Also, we should never have duplicates nids and so
// should always have objects in |global_added_by_nid|.
ASN1_OBJECT *old_object;
ok = lh_ASN1_OBJECT_insert(global_added_by_nid, &old_object, obj);
if (obj->length != 0 && obj->data != NULL) {
ok &= lh_ASN1_OBJECT_insert(global_added_by_data, &old_object, obj);
}
if (obj->sn != NULL) {
ok &= lh_ASN1_OBJECT_insert(global_added_by_short_name, &old_object, obj);
}
if (obj->ln != NULL) {
ok &= lh_ASN1_OBJECT_insert(global_added_by_long_name, &old_object, obj);
}
err:
CRYPTO_MUTEX_unlock_write(&global_added_lock);
return ok;
}
int OBJ_create(const char *oid, const char *short_name, const char *long_name) {
ASN1_OBJECT *op =
create_object_with_text_oid(obj_next_nid, oid, short_name, long_name);
if (op == NULL ||
!obj_add_object(op)) {
return NID_undef;
}
return op->nid;
}
void OBJ_cleanup(void) {}
|
8c511c6e64578ed2152d4f4acbcbd2fc3e22fdbd
|
83372fce92c9088ee5c1e1c13bc67385a3b02a36
|
/test/val/bug1675.c
|
ee24425dfee54a0e2575e665e4a3076aab827db8
|
[
"Zlib",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
cc65/cc65
|
2cd1b20b61ddd0691cd4601b4da37a9200a50afb
|
16e90187e8e80c6e2fcfcc04f068ac865d2290e5
|
refs/heads/master
| 2023-09-03T17:16:46.027934
| 2023-09-02T22:30:44
| 2023-09-02T22:30:44
| 8,932,489
| 2,103
| 526
|
Zlib
| 2023-09-13T06:19:01
| 2013-03-21T15:56:48
|
C
|
UTF-8
|
C
| false
| false
| 2,905
|
c
|
bug1675.c
|
/* #1675 - Some corner cases of bit-shifts */
#include <stdio.h>
int failures = 0;
void Test_Defined(void)
{
{
/* Well-defined per standard, lhs expected in cc65: (int)-256 */
if (!(((signed char)0x80 << 1) < 0)) {
++failures;
printf("Expected: ((signed char)0x80 << 1) < 0, got lhs: %ld\n", (long)((signed char)0x80 << 1));
}
}
{
/* Implementation-defined per standard, lhs expected in cc65: (int)-128 */
if (!(((signed char)0x80 >> 1 << 1) < 0)) {
++failures;
printf("Expected: ((signed char)0x80 >> 1 << 1) < 0, got lhs: %ld\n", (long)((signed char)0x80 >> 1 << 1));
}
}
{
int x = 0;
/* Well-defined per standard, lhs expected in cc65: (int)1 */
if (!((1 << (x++, 0)) == 1)) {
++failures;
x = 0;
printf("Expected: (1 << (x++, 0)) == 1, got lhs: %ld\n", (long)(1 << (x++, 0)));
}
/* Well-defined per standard, lhs expected in cc65: (int)1 */
if (!(x == 1)) {
++failures;
printf("Expected: (1 << (x++, 0)) == 1 && x == 1, got x: %d\n", x);
}
}
{
int x = 0, y = 0x100;
/* Well-defined per standard, lhs expected in cc65: (int)128 */
if (!((y >> (x++, 0) >> 1) == 0x80)) {
++failures;
x = 0;
printf("Expected: (y >> (x++, 0) >> 1) == 0x80, got lhs: %ld\n", (long)(y >> (x++, 0) >> 1));
}
/* Well-defined per standard, lhs expected in cc65: (int)1 */
if (!(x == 1)) {
++failures;
printf("Expected: (y >> (x++, 0) >> 1) == 0x80 && x == 1, got x: %d\n", x);
}
}
{
int x = 0, y = 0x100;
/* Well-defined per standard, lhs expected in cc65: (int)1 */
if (!((y >> (x++, 8)) == 1)) {
++failures;
x = 0;
printf("Expected: (y >> (x++, 8)) == 1, got lhs: %ld\n", (long)(y >> (x++, 8)));
}
/* Well-defined per standard, lhs expected in cc65: (int)1 */
if (!(x == 1)) {
++failures;
printf("Expected: (y >> (x++, 8)) == 1 && x == 1, got x: %d\n", x);
}
}
{
const signed char x = 0x80;
/* Well-defined per standard, lhs expected in cc65: (int)-256 */
if (!((x << 1) < 0)) {
++failures;
printf("Expected: (x << 1) < 0, got lhs: %ld\n", (long)(x << 1));
}
}
{
const signed char x = 0x40;
/* Well-defined per standard, lhs expected in cc65: (int)128 */
if (!((x << 1) >= 0)) {
++failures;
printf("Expected: (x << 1) >= 0, got lhs: %ld\n", (long)(x << 1));
}
}
}
int main(void)
{
Test_Defined();
if (failures != 0) {
printf("Failures: %d\n", failures);
}
return failures;
}
|
9f89f88f7cdb47652e164d57cc7279b47d1e2c6a
|
7f6c235b0598353549959c18f69eefd20b766907
|
/include/_DEVELOPMENT/sdcc/z80.h
|
73dc1aa4413037e23eef5d254099f487861e1b7d
|
[
"ClArtistic"
] |
permissive
|
z88dk/z88dk
|
46dfd4905f36d99333173cadd0a660839befc9f0
|
8b07f37cc43c5d9ffe69b563c80763491d8faff7
|
refs/heads/master
| 2023-09-04T19:29:49.254958
| 2023-09-03T20:51:24
| 2023-09-03T20:51:24
| 54,035,569
| 820
| 263
|
NOASSERTION
| 2023-09-05T11:09:04
| 2016-03-16T13:48:16
|
Assembly
|
UTF-8
|
C
| false
| false
| 2,763
|
h
|
z80.h
|
// automatically generated by m4 from headers in proto subdir
#if __Z80 || __Z80N
#ifndef __Z80_H__
#define __Z80_H__
#include <stdint.h>
#include <im2.h>
extern void z80_delay_ms(uint16_t ms);
extern void z80_delay_ms_fastcall(uint16_t ms) __z88dk_fastcall;
#define z80_delay_ms(a) z80_delay_ms_fastcall(a)
extern void z80_delay_tstate(uint16_t tstates) __preserves_regs(d,e);
extern void z80_delay_tstate_fastcall(uint16_t tstates) __preserves_regs(d,e) __z88dk_fastcall;
#define z80_delay_tstate(a) z80_delay_tstate_fastcall(a)
extern uint8_t z80_get_int_state(void) __preserves_regs(b,c,d,e);
extern void z80_set_int_state(uint8_t state) __preserves_regs(b,c,d,e);
extern void z80_set_int_state_fastcall(uint8_t state) __preserves_regs(a,b,c,d,e,h,l) __z88dk_fastcall;
#define z80_set_int_state(a) z80_set_int_state_fastcall(a)
extern uint8_t z80_inp(uint16_t port) __preserves_regs(d,e);
extern uint8_t z80_inp_fastcall(uint16_t port) __preserves_regs(d,e) __z88dk_fastcall;
#define z80_inp(a) z80_inp_fastcall(a)
extern void *z80_inir(void *dst,uint8_t port,uint8_t num) __preserves_regs(d,e);
extern void *z80_inir_callee(void *dst,uint8_t port,uint8_t num) __preserves_regs(d,e) __z88dk_callee;
#define z80_inir(a,b,c) z80_inir_callee(a,b,c)
extern void *z80_indr(void *dst,uint8_t port,uint8_t num) __preserves_regs(d,e);
extern void *z80_indr_callee(void *dst,uint8_t port,uint8_t num) __preserves_regs(d,e) __z88dk_callee;
#define z80_indr(a,b,c) z80_indr_callee(a,b,c)
extern void z80_outp(uint16_t port,uint8_t data) __preserves_regs(d,e);
extern void z80_outp_callee(uint16_t port,uint8_t data) __preserves_regs(d,e) __z88dk_callee;
#define z80_outp(a,b) z80_outp_callee(a,b)
extern void *z80_otir(void *src,uint8_t port,uint8_t num) __preserves_regs(d,e);
extern void *z80_otir_callee(void *src,uint8_t port,uint8_t num) __preserves_regs(d,e) __z88dk_callee;
#define z80_otir(a,b,c) z80_otir_callee(a,b,c)
extern void *z80_otdr(void *src,uint8_t port,uint8_t num) __preserves_regs(d,e);
extern void *z80_otdr_callee(void *src,uint8_t port,uint8_t num) __preserves_regs(d,e) __z88dk_callee;
#define z80_otdr(a,b,c) z80_otdr_callee(a,b,c)
#define z80_bpoke(a,b) (*(unsigned char *)(a) = b)
#define z80_wpoke(a,b) (*(unsigned int *)(a) = b)
#define z80_lpoke(a,b) (*(unsigned long *)(a) = b)
#define z80_bpeek(a) (*(unsigned char *)(a))
#define z80_wpeek(a) (*(unsigned int *)(a))
#define z80_lpeek(a) (*(unsigned long *)(a))
#ifdef __CLANG
#define z80_llpoke(a,b) (*(unsigned long long *)(a) = b)
#define z80_llpeek(a) (*(unsigned long long *)(a))
#endif
#ifdef __SDCC
#define z80_llpoke(a,b) (*(unsigned long long *)(a) = b)
#define z80_llpeek(a) (*(unsigned long long *)(a))
#endif
#endif
#endif
|
fc3cdad1c854d2bccd76d14b1593bb6dcfbdd384
|
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
|
/src/mono/mono/component/debugger-engine.h
|
b0f6c5ca729b385f8a09742851c473ed8e814b9f
|
[
"MIT"
] |
permissive
|
dotnet/runtime
|
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
|
47bb554d298e1e34c4e3895d7731e18ad1c47d02
|
refs/heads/main
| 2023-09-03T15:35:46.493337
| 2023-09-03T08:13:23
| 2023-09-03T08:13:23
| 210,716,005
| 13,765
| 5,179
|
MIT
| 2023-09-14T21:58:52
| 2019-09-24T23:36:39
|
C#
|
UTF-8
|
C
| false
| false
| 18,971
|
h
|
debugger-engine.h
|
/**
* \file
*/
#ifndef __MONO_DEBUGGER_ENGINE_COMPONENT_H__
#define __MONO_DEBUGGER_ENGINE_COMPONENT_H__
#include <mono/mini/mini.h>
#include <mono/metadata/seq-points-data.h>
#include "debugger-state-machine.h"
#include <mono/metadata/mono-debug.h>
#include <mono/mini/interp/interp-internals.h>
#include "debugger-protocol.h"
#define ModifierKind MdbgProtModifierKind
#define StepDepth MdbgProtStepDepth
#define StepSize MdbgProtStepSize
#define StepFilter MdbgProtStepFilter
#define EventKind MdbgProtEventKind
#define CommandSet MdbgProtCommandSet
#define EVENT_KIND_BREAKPOINT MDBGPROT_EVENT_KIND_BREAKPOINT
#define EVENT_KIND_STEP MDBGPROT_EVENT_KIND_STEP
#define EVENT_KIND_KEEPALIVE MDBGPROT_EVENT_KIND_KEEPALIVE
#define EVENT_KIND_METHOD_ENTRY MDBGPROT_EVENT_KIND_METHOD_ENTRY
#define EVENT_KIND_METHOD_EXIT MDBGPROT_EVENT_KIND_METHOD_EXIT
#define EVENT_KIND_APPDOMAIN_CREATE MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE
#define EVENT_KIND_APPDOMAIN_UNLOAD MDBGPROT_EVENT_KIND_APPDOMAIN_UNLOAD
#define EVENT_KIND_THREAD_START MDBGPROT_EVENT_KIND_THREAD_START
#define EVENT_KIND_THREAD_DEATH MDBGPROT_EVENT_KIND_THREAD_DEATH
#define EVENT_KIND_ASSEMBLY_LOAD MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD
#define EVENT_KIND_ASSEMBLY_UNLOAD MDBGPROT_EVENT_KIND_ASSEMBLY_UNLOAD
#define EVENT_KIND_TYPE_LOAD MDBGPROT_EVENT_KIND_TYPE_LOAD
#define EVENT_KIND_VM_START MDBGPROT_EVENT_KIND_VM_START
#define EVENT_KIND_VM_DEATH MDBGPROT_EVENT_KIND_VM_DEATH
#define EVENT_KIND_CRASH MDBGPROT_EVENT_KIND_CRASH
#define EVENT_KIND_EXCEPTION MDBGPROT_EVENT_KIND_EXCEPTION
#define EVENT_KIND_USER_BREAK MDBGPROT_EVENT_KIND_USER_BREAK
#define EVENT_KIND_USER_LOG MDBGPROT_EVENT_KIND_USER_LOG
#define CMD_EVENT_REQUEST_SET MDBGPROT_CMD_EVENT_REQUEST_SET
#define CMD_EVENT_REQUEST_CLEAR MDBGPROT_CMD_EVENT_REQUEST_CLEAR
#define CMD_EVENT_REQUEST_CLEAR_ALL_BREAKPOINTS MDBGPROT_CMD_EVENT_REQUEST_CLEAR_ALL_BREAKPOINTS
#define CMD_VM_VERSION MDBGPROT_CMD_VM_VERSION
#define CMD_VM_SET_PROTOCOL_VERSION MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION
#define CMD_VM_ALL_THREADS MDBGPROT_CMD_VM_ALL_THREADS
#define CMD_VM_SUSPEND MDBGPROT_CMD_VM_SUSPEND
#define CMD_VM_RESUME MDBGPROT_CMD_VM_RESUME
#define CMD_VM_DISPOSE MDBGPROT_CMD_VM_DISPOSE
#define CMD_VM_EXIT MDBGPROT_CMD_VM_EXIT
#define CMD_VM_INVOKE_METHOD MDBGPROT_CMD_VM_INVOKE_METHOD
#define CMD_VM_INVOKE_METHODS MDBGPROT_CMD_VM_INVOKE_METHODS
#define CMD_VM_ABORT_INVOKE MDBGPROT_CMD_VM_ABORT_INVOKE
#define CMD_VM_SET_KEEPALIVE MDBGPROT_CMD_VM_SET_KEEPALIVE
#define CMD_VM_GET_TYPES_FOR_SOURCE_FILE MDBGPROT_CMD_VM_GET_TYPES_FOR_SOURCE_FILE
#define CMD_VM_GET_TYPES MDBGPROT_CMD_VM_GET_TYPES
#define CMD_VM_START_BUFFERING MDBGPROT_CMD_VM_START_BUFFERING
#define CMD_VM_STOP_BUFFERING MDBGPROT_CMD_VM_STOP_BUFFERING
#define CMD_APPDOMAIN_GET_ROOT_DOMAIN MDBGPROT_CMD_APPDOMAIN_GET_ROOT_DOMAIN
#define CMD_APPDOMAIN_GET_FRIENDLY_NAME MDBGPROT_CMD_APPDOMAIN_GET_FRIENDLY_NAME
#define CMD_APPDOMAIN_GET_ASSEMBLIES MDBGPROT_CMD_APPDOMAIN_GET_ASSEMBLIES
#define CMD_APPDOMAIN_GET_ENTRY_ASSEMBLY MDBGPROT_CMD_APPDOMAIN_GET_ENTRY_ASSEMBLY
#define CMD_APPDOMAIN_GET_CORLIB MDBGPROT_CMD_APPDOMAIN_GET_CORLIB
#define CMD_APPDOMAIN_CREATE_STRING MDBGPROT_CMD_APPDOMAIN_CREATE_STRING
#define CMD_APPDOMAIN_CREATE_BYTE_ARRAY MDBGPROT_CMD_APPDOMAIN_CREATE_BYTE_ARRAY
#define CMD_APPDOMAIN_CREATE_BOXED_VALUE MDBGPROT_CMD_APPDOMAIN_CREATE_BOXED_VALUE
#define CMD_ASSEMBLY_GET_LOCATION MDBGPROT_CMD_ASSEMBLY_GET_LOCATION
#define CMD_ASSEMBLY_GET_ENTRY_POINT MDBGPROT_CMD_ASSEMBLY_GET_ENTRY_POINT
#define CMD_ASSEMBLY_GET_MANIFEST_MODULE MDBGPROT_CMD_ASSEMBLY_GET_MANIFEST_MODULE
#define CMD_ASSEMBLY_GET_OBJECT MDBGPROT_CMD_ASSEMBLY_GET_OBJECT
#define CMD_ASSEMBLY_GET_DOMAIN MDBGPROT_CMD_ASSEMBLY_GET_DOMAIN
#define CMD_ASSEMBLY_GET_TYPE MDBGPROT_CMD_ASSEMBLY_GET_TYPE
#define CMD_ASSEMBLY_GET_NAME MDBGPROT_CMD_ASSEMBLY_GET_NAME
#define CMD_ASSEMBLY_GET_METADATA_BLOB MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB
#define CMD_ASSEMBLY_GET_IS_DYNAMIC MDBGPROT_CMD_ASSEMBLY_GET_IS_DYNAMIC
#define CMD_ASSEMBLY_GET_PDB_BLOB MDBGPROT_CMD_ASSEMBLY_GET_PDB_BLOB
#define CMD_ASSEMBLY_GET_TYPE_FROM_TOKEN MDBGPROT_CMD_ASSEMBLY_GET_TYPE_FROM_TOKEN
#define CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN
#define CMD_ASSEMBLY_HAS_DEBUG_INFO MDBGPROT_CMD_ASSEMBLY_HAS_DEBUG_INFO
#define CMD_ASSEMBLY_GET_CATTRS MDBGPROT_CMD_ASSEMBLY_GET_CATTRS
#define CMD_MODULE_GET_INFO MDBGPROT_CMD_MODULE_GET_INFO
#define CMD_FIELD_GET_INFO MDBGPROT_CMD_FIELD_GET_INFO
#define CMD_TYPE_GET_INFO MDBGPROT_CMD_TYPE_GET_INFO
#define CMD_TYPE_GET_METHODS MDBGPROT_CMD_TYPE_GET_METHODS
#define CMD_TYPE_GET_FIELDS MDBGPROT_CMD_TYPE_GET_FIELDS
#define CMD_TYPE_GET_PROPERTIES MDBGPROT_CMD_TYPE_GET_PROPERTIES
#define CMD_TYPE_GET_CATTRS MDBGPROT_CMD_TYPE_GET_CATTRS
#define CMD_TYPE_GET_FIELD_CATTRS MDBGPROT_CMD_TYPE_GET_FIELD_CATTRS
#define CMD_TYPE_GET_PROPERTY_CATTRS MDBGPROT_CMD_TYPE_GET_PROPERTY_CATTRS
#define CMD_TYPE_GET_VALUES MDBGPROT_CMD_TYPE_GET_VALUES
#define CMD_TYPE_GET_VALUES_2 MDBGPROT_CMD_TYPE_GET_VALUES_2
#define CMD_TYPE_SET_VALUES MDBGPROT_CMD_TYPE_SET_VALUES
#define CMD_TYPE_GET_OBJECT MDBGPROT_CMD_TYPE_GET_OBJECT
#define CMD_TYPE_GET_SOURCE_FILES MDBGPROT_CMD_TYPE_GET_SOURCE_FILES
#define CMD_TYPE_GET_SOURCE_FILES_2 MDBGPROT_CMD_TYPE_GET_SOURCE_FILES_2
#define CMD_TYPE_IS_ASSIGNABLE_FROM MDBGPROT_CMD_TYPE_IS_ASSIGNABLE_FROM
#define CMD_TYPE_GET_METHODS_BY_NAME_FLAGS MDBGPROT_CMD_TYPE_GET_METHODS_BY_NAME_FLAGS
#define CMD_TYPE_GET_INTERFACES MDBGPROT_CMD_TYPE_GET_INTERFACES
#define CMD_TYPE_GET_INTERFACE_MAP MDBGPROT_CMD_TYPE_GET_INTERFACE_MAP
#define CMD_TYPE_IS_INITIALIZED MDBGPROT_CMD_TYPE_IS_INITIALIZED
#define CMD_TYPE_CREATE_INSTANCE MDBGPROT_CMD_TYPE_CREATE_INSTANCE
#define CMD_TYPE_GET_VALUE_SIZE MDBGPROT_CMD_TYPE_GET_VALUE_SIZE
#define CMD_METHOD_GET_NAME MDBGPROT_CMD_METHOD_GET_NAME
#define CMD_METHOD_GET_DECLARING_TYPE MDBGPROT_CMD_METHOD_GET_DECLARING_TYPE
#define CMD_METHOD_GET_DEBUG_INFO MDBGPROT_CMD_METHOD_GET_DEBUG_INFO
#define CMD_METHOD_GET_PARAM_INFO MDBGPROT_CMD_METHOD_GET_PARAM_INFO
#define CMD_METHOD_GET_LOCALS_INFO MDBGPROT_CMD_METHOD_GET_LOCALS_INFO
#define CMD_METHOD_GET_INFO MDBGPROT_CMD_METHOD_GET_INFO
#define CMD_METHOD_GET_BODY MDBGPROT_CMD_METHOD_GET_BODY
#define CMD_METHOD_RESOLVE_TOKEN MDBGPROT_CMD_METHOD_RESOLVE_TOKEN
#define CMD_METHOD_GET_CATTRS MDBGPROT_CMD_METHOD_GET_CATTRS
#define CMD_METHOD_MAKE_GENERIC_METHOD MDBGPROT_CMD_METHOD_MAKE_GENERIC_METHOD
#define CMD_METHOD_TOKEN MDBGPROT_CMD_METHOD_TOKEN
#define CMD_METHOD_ASSEMBLY MDBGPROT_CMD_METHOD_ASSEMBLY
#define CMD_THREAD_GET_NAME MDBGPROT_CMD_THREAD_GET_NAME
#define CMD_THREAD_GET_FRAME_INFO MDBGPROT_CMD_THREAD_GET_FRAME_INFO
#define CMD_THREAD_GET_STATE MDBGPROT_CMD_THREAD_GET_STATE
#define CMD_THREAD_GET_INFO MDBGPROT_CMD_THREAD_GET_INFO
#define CMD_THREAD_GET_ID MDBGPROT_CMD_THREAD_GET_ID
#define CMD_THREAD_GET_TID MDBGPROT_CMD_THREAD_GET_TID
#define CMD_THREAD_SET_IP MDBGPROT_CMD_THREAD_SET_IP
#define CMD_THREAD_ELAPSED_TIME MDBGPROT_CMD_THREAD_ELAPSED_TIME
#define CMD_STACK_FRAME_GET_DOMAIN MDBGPROT_CMD_STACK_FRAME_GET_DOMAIN
#define CMD_STACK_FRAME_GET_ARGUMENT MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT
#define CMD_STACK_FRAME_GET_VALUES MDBGPROT_CMD_STACK_FRAME_GET_VALUES
#define CMD_STACK_FRAME_GET_THIS MDBGPROT_CMD_STACK_FRAME_GET_THIS
#define CMD_STACK_FRAME_SET_VALUES MDBGPROT_CMD_STACK_FRAME_SET_VALUES
#define CMD_STACK_FRAME_GET_DOMAIN MDBGPROT_CMD_STACK_FRAME_GET_DOMAIN
#define CMD_STACK_FRAME_SET_THIS MDBGPROT_CMD_STACK_FRAME_SET_THIS
#define CMD_ARRAY_REF_GET_TYPE MDBGPROT_CMD_ARRAY_REF_GET_TYPE
#define CMD_ARRAY_REF_GET_LENGTH MDBGPROT_CMD_ARRAY_REF_GET_LENGTH
#define CMD_ARRAY_REF_GET_VALUES MDBGPROT_CMD_ARRAY_REF_GET_VALUES
#define CMD_ARRAY_REF_SET_VALUES MDBGPROT_CMD_ARRAY_REF_SET_VALUES
#define CMD_STRING_REF_GET_VALUE MDBGPROT_CMD_STRING_REF_GET_VALUE
#define CMD_STRING_REF_GET_LENGTH MDBGPROT_CMD_STRING_REF_GET_LENGTH
#define CMD_STRING_REF_GET_CHARS MDBGPROT_CMD_STRING_REF_GET_CHARS
#define CMD_POINTER_GET_VALUE MDBGPROT_CMD_POINTER_GET_VALUE
#define CMD_OBJECT_REF_IS_COLLECTED MDBGPROT_CMD_OBJECT_REF_IS_COLLECTED
#define CMD_OBJECT_REF_GET_TYPE MDBGPROT_CMD_OBJECT_REF_GET_TYPE
#define CMD_OBJECT_REF_GET_VALUES_BY_FIELD_TOKEN MDBGPROT_CMD_OBJECT_REF_GET_VALUES_BY_FIELD_TOKEN
#define CMD_OBJECT_REF_GET_VALUES MDBGPROT_CMD_OBJECT_REF_GET_VALUES
#define CMD_OBJECT_REF_SET_VALUES MDBGPROT_CMD_OBJECT_REF_SET_VALUES
#define CMD_OBJECT_REF_GET_ADDRESS MDBGPROT_CMD_OBJECT_REF_GET_ADDRESS
#define CMD_OBJECT_REF_GET_DOMAIN MDBGPROT_CMD_OBJECT_REF_GET_DOMAIN
#define CMD_OBJECT_REF_GET_INFO MDBGPROT_CMD_OBJECT_REF_GET_INFO
#define TOKEN_TYPE_METHOD MDBGPROT_TOKEN_TYPE_METHOD
#define TOKEN_TYPE_UNKNOWN MDBGPROT_TOKEN_TYPE_UNKNOWN
#define TOKEN_TYPE_FIELD MDBGPROT_TOKEN_TYPE_FIELD
#define TOKEN_TYPE_METHOD MDBGPROT_TOKEN_TYPE_METHOD
#define TOKEN_TYPE_STRING MDBGPROT_TOKEN_TYPE_STRING
#define TOKEN_TYPE_TYPE MDBGPROT_TOKEN_TYPE_TYPE
#define STEP_FILTER_STATIC_CTOR MDBGPROT_STEP_FILTER_STATIC_CTOR
#define STEP_DEPTH_OVER MDBGPROT_STEP_DEPTH_OVER
#define STEP_DEPTH_OUT MDBGPROT_STEP_DEPTH_OUT
#define STEP_DEPTH_INTO MDBGPROT_STEP_DEPTH_INTO
#define STEP_SIZE_MIN MDBGPROT_STEP_SIZE_MIN
#define STEP_SIZE_LINE_COLUMN MDBGPROT_STEP_SIZE_LINE_COLUMN
#define SUSPEND_POLICY_NONE MDBGPROT_SUSPEND_POLICY_NONE
#define SUSPEND_POLICY_ALL MDBGPROT_SUSPEND_POLICY_ALL
#define SUSPEND_POLICY_EVENT_THREAD MDBGPROT_SUSPEND_POLICY_EVENT_THREAD
#define CMD_COMPOSITE MDBGPROT_CMD_COMPOSITE
#define INVOKE_FLAG_SINGLE_THREADED MDBGPROT_INVOKE_FLAG_SINGLE_THREADED
#define INVOKE_FLAG_VIRTUAL MDBGPROT_INVOKE_FLAG_VIRTUAL
#define INVOKE_FLAG_DISABLE_BREAKPOINTS_AND_STEPPING MDBGPROT_INVOKE_FLAG_DISABLE_BREAKPOINTS_AND_STEPPING
#define INVOKE_FLAG_RETURN_OUT_THIS MDBGPROT_INVOKE_FLAG_RETURN_OUT_THIS
#define INVOKE_FLAG_RETURN_OUT_ARGS MDBGPROT_INVOKE_FLAG_RETURN_OUT_ARGS
#define MOD_KIND_ASSEMBLY_ONLY MDBGPROT_MOD_KIND_ASSEMBLY_ONLY
#define MOD_KIND_EXCEPTION_ONLY MDBGPROT_MOD_KIND_EXCEPTION_ONLY
#define MOD_KIND_NONE MDBGPROT_MOD_KIND_NONE
#define MOD_KIND_COUNT MDBGPROT_MOD_KIND_COUNT
#define MOD_KIND_THREAD_ONLY MDBGPROT_MOD_KIND_THREAD_ONLY
#define MOD_KIND_SOURCE_FILE_ONLY MDBGPROT_MOD_KIND_SOURCE_FILE_ONLY
#define MOD_KIND_TYPE_NAME_ONLY MDBGPROT_MOD_KIND_TYPE_NAME_ONLY
#define MOD_KIND_STEP MDBGPROT_MOD_KIND_STEP
#define MOD_KIND_LOCATION_ONLY MDBGPROT_MOD_KIND_LOCATION_ONLY
#define STEP_FILTER_DEBUGGER_HIDDEN MDBGPROT_STEP_FILTER_DEBUGGER_HIDDEN
#define STEP_FILTER_DEBUGGER_NON_USER_CODE MDBGPROT_STEP_FILTER_DEBUGGER_NON_USER_CODE
#define STEP_FILTER_DEBUGGER_STEP_THROUGH MDBGPROT_STEP_FILTER_DEBUGGER_STEP_THROUGH
#define STEP_FILTER_NONE MDBGPROT_STEP_FILTER_NONE
#define ERR_NONE MDBGPROT_ERR_NONE
#define ERR_INVOKE_ABORTED MDBGPROT_ERR_INVOKE_ABORTED
#define ERR_NOT_SUSPENDED MDBGPROT_ERR_NOT_SUSPENDED
#define ERR_INVALID_ARGUMENT MDBGPROT_ERR_INVALID_ARGUMENT
#define ERR_INVALID_OBJECT MDBGPROT_ERR_INVALID_OBJECT
#define ERR_UNLOADED MDBGPROT_ERR_UNLOADED
#define ERR_NOT_IMPLEMENTED MDBGPROT_ERR_NOT_IMPLEMENTED
#define ERR_LOADER_ERROR MDBGPROT_ERR_LOADER_ERROR
#define ERR_NO_INVOCATION MDBGPROT_ERR_NO_INVOCATION
#define ERR_NO_SEQ_POINT_AT_IL_OFFSET MDBGPROT_ERR_NO_SEQ_POINT_AT_IL_OFFSET
#define ERR_INVALID_FIELDID MDBGPROT_ERR_INVALID_FIELDID
#define ERR_INVALID_FRAMEID MDBGPROT_ERR_INVALID_FRAMEID
#define ERR_ABSENT_INFORMATION MDBGPROT_ERR_ABSENT_INFORMATION
#define VALUE_TYPE_ID_FIXED_ARRAY MDBGPROT_VALUE_TYPE_ID_FIXED_ARRAY
#define VALUE_TYPE_ID_NULL MDBGPROT_VALUE_TYPE_ID_NULL
#define VALUE_TYPE_ID_PARENT_VTYPE MDBGPROT_VALUE_TYPE_ID_PARENT_VTYPE
#define VALUE_TYPE_ID_TYPE MDBGPROT_VALUE_TYPE_ID_TYPE
#define CMD_SET_VM MDBGPROT_CMD_SET_VM
#define CMD_SET_OBJECT_REF MDBGPROT_CMD_SET_OBJECT_REF
#define CMD_SET_STRING_REF MDBGPROT_CMD_SET_STRING_REF
#define CMD_SET_THREAD MDBGPROT_CMD_SET_THREAD
#define CMD_SET_ARRAY_REF MDBGPROT_CMD_SET_ARRAY_REF
#define CMD_SET_EVENT_REQUEST MDBGPROT_CMD_SET_EVENT_REQUEST
#define CMD_SET_STACK_FRAME MDBGPROT_CMD_SET_STACK_FRAME
#define CMD_SET_APPDOMAIN MDBGPROT_CMD_SET_APPDOMAIN
#define CMD_SET_ASSEMBLY MDBGPROT_CMD_SET_ASSEMBLY
#define CMD_SET_METHOD MDBGPROT_CMD_SET_METHOD
#define CMD_SET_TYPE MDBGPROT_CMD_SET_TYPE
#define CMD_SET_MODULE MDBGPROT_CMD_SET_MODULE
#define CMD_SET_FIELD MDBGPROT_CMD_SET_FIELD
#define CMD_SET_POINTER MDBGPROT_CMD_SET_POINTER
#define CMD_SET_EVENT MDBGPROT_CMD_SET_EVENT
#define Buffer MdbgProtBuffer
#define ReplyPacket MdbgProtReplyPacket
#define buffer_init m_dbgprot_buffer_init
#define buffer_free m_dbgprot_buffer_free
#define buffer_add_int m_dbgprot_buffer_add_int
#define buffer_add_long m_dbgprot_buffer_add_long
#define buffer_add_string m_dbgprot_buffer_add_string
#define buffer_add_id m_dbgprot_buffer_add_id
#define buffer_add_byte m_dbgprot_buffer_add_byte
#define buffer_len m_dbgprot_buffer_len
#define buffer_add_buffer m_dbgprot_buffer_add_buffer
#define buffer_add_data m_dbgprot_buffer_add_data
#define buffer_add_utf16 m_dbgprot_buffer_add_utf16
#define buffer_add_byte_array m_dbgprot_buffer_add_byte_array
#define buffer_add_short m_dbgprot_buffer_add_short
#define decode_id m_dbgprot_decode_id
#define decode_int m_dbgprot_decode_int
#define decode_byte m_dbgprot_decode_byte
#define decode_long m_dbgprot_decode_long
#define decode_string m_dbgprot_decode_string
#define event_to_string m_dbgprot_event_to_string
#define ErrorCode MdbgProtErrorCode
#define FRAME_FLAG_DEBUGGER_INVOKE MDBGPROT_FRAME_FLAG_DEBUGGER_INVOKE
#define FRAME_FLAG_NATIVE_TRANSITION MDBGPROT_FRAME_FLAG_NATIVE_TRANSITION
/*
* Contains information about an inserted breakpoint.
*/
typedef struct {
long il_offset, native_offset;
guint8 *ip;
MonoJitInfo *ji;
MonoDomain *domain;
} BreakpointInstance;
/*
* OBJECT IDS
*/
/*
* Represents an object accessible by the debugger client.
*/
typedef struct {
/* Unique id used in the wire protocol to refer to objects */
int id;
/*
* A weakref gc handle pointing to the object. The gc handle is used to
* detect if the object was garbage collected.
*/
MonoGCHandle handle;
} ObjRef;
typedef struct
{
//Must be the first field to ensure pointer equivalence
DbgEngineStackFrame de;
int id;
guint32 il_offset;
/*
* If method is gshared, this is the actual instance, otherwise this is equal to
* method.
*/
MonoMethod *actual_method;
/*
* This is the method which is visible to debugger clients. Same as method,
* except for native-to-managed wrappers.
*/
MonoMethod *api_method;
MonoContext ctx;
MonoDebugMethodJitInfo *jit;
MonoInterpFrameHandle interp_frame;
gpointer frame_addr;
int flags;
host_mgreg_t *reg_locations [MONO_MAX_IREGS];
/*
* Whenever ctx is set. This is FALSE for the last frame of running threads, since
* the frame can become invalid.
*/
gboolean has_ctx;
} StackFrame;
#define DE_ERR_NONE 0
// WARNING WARNING WARNING
// Error codes MUST match those of sdb for now
#define DE_ERR_NOT_IMPLEMENTED 100
MonoGHashTable *
mono_debugger_get_thread_states (void);
gboolean
mono_debugger_is_disconnected (void);
void
mono_debugger_agent_init (void);
gsize
mono_debugger_tls_thread_id (DebuggerTlsData *debuggerTlsData);
void
mono_debugger_set_thread_state (DebuggerTlsData *ref, MonoDebuggerThreadState expected, MonoDebuggerThreadState set);
MonoDebuggerThreadState
mono_debugger_get_thread_state (DebuggerTlsData *ref);
void mono_de_cleanup (void);
void mono_de_set_log_level (int level, FILE *file);
//locking - we expose the lock object from the debugging engine to ensure we keep the same locking semantics of sdb.
void mono_de_lock (void);
void mono_de_unlock (void);
// domain handling
void mono_de_foreach_domain (GHFunc func, gpointer user_data);
void mono_de_domain_add (MonoDomain *domain);
//breakpoints
void mono_de_clear_breakpoint (MonoBreakpoint *bp);
MonoBreakpoint* mono_de_set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError *error);
void mono_de_collect_breakpoints_by_sp (SeqPoint *sp, MonoJitInfo *ji, GPtrArray *ss_reqs, GPtrArray *bp_reqs);
void mono_de_clear_breakpoints_for_domain (MonoDomain *domain);
void mono_de_add_pending_breakpoints(MonoMethod* method, MonoJitInfo* ji);
//single stepping
void mono_de_start_single_stepping (void);
void mono_de_stop_single_stepping (void);
void mono_de_process_breakpoint (void *tls, gboolean from_signal);
void mono_de_process_single_step (void *tls, gboolean from_signal);
DbgEngineErrorCode mono_de_ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilter filter, EventRequest *req);
void mono_de_cancel_ss (SingleStepReq *req);
void mono_de_cancel_all_ss (void);
DbgEngineErrorCode mono_de_set_interp_var (MonoType *t, gpointer addr, guint8 *val_buf);
gboolean set_set_notification_for_wait_completion_flag (DbgEngineStackFrame *frame);
MonoClass * get_class_to_get_builder_field(DbgEngineStackFrame *frame);
gpointer get_async_method_builder (DbgEngineStackFrame *frame);
MonoMethod* get_notify_debugger_of_wait_completion_method (void);
MonoMethod* get_object_id_for_debugger_method (MonoClass* async_builder_class);
void mono_debugger_free_objref(gpointer value);
#ifdef HOST_ANDROID
#define PRINT_DEBUG_MSG(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { g_print (__VA_ARGS__); } } while (0)
#define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; } } while (0)
#elif HOST_WASI
#define PRINT_DEBUG_MSG(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { g_print (__VA_ARGS__); } } while (0)
#define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; } } while (0)
#elif HOST_WASM
void wasm_debugger_log(int level, const gchar *format, ...);
#define PRINT_DEBUG_MSG(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { wasm_debugger_log (level, __VA_ARGS__); } } while (0)
#define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; } } while (0)
#elif defined(HOST_WIN32) && !HAVE_API_SUPPORT_WIN32_CONSOLE
void win32_debugger_log(FILE *stream, const gchar *format, ...);
#define PRINT_DEBUG_MSG(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { win32_debugger_log (log_file, __VA_ARGS__); } } while (0)
#define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; } } while (0)
#else
#define PRINT_DEBUG_MSG(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { fprintf (log_file, __VA_ARGS__); fflush (log_file); } } while (0)
#define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; fflush (log_file); } } while (0)
#endif
#endif
#if defined(HOST_WIN32) && !HAVE_API_SUPPORT_WIN32_CONSOLE
void win32_debugger_log(FILE *stream, const gchar *format, ...);
#define PRINT_ERROR_MSG(...) win32_debugger_log (log_file, __VA_ARGS__)
#define PRINT_MSG(...) win32_debugger_log (log_file, __VA_ARGS__)
#else
#define PRINT_ERROR_MSG(...) g_printerr (__VA_ARGS__)
#define PRINT_MSG(...) g_print (__VA_ARGS__)
#endif
void
mono_de_init(DebuggerEngineCallbacks* cbs);
|
27b4cdcf662adc1d2269c7254f3ed40259fa53e4
|
ce99bd11ca505967277f4689c621479c1987698e
|
/src/game/math_asinacos.c
|
689097bb6889854144bce1568a3c9bee594e8b11
|
[] |
no_license
|
n64decomp/007
|
5951258890f15431f273e1503674c5e0402c66e0
|
c46751089ddc18b12ef7a45b6a3e03de2054c422
|
refs/heads/master
| 2022-11-08T23:34:54.021033
| 2022-10-29T14:41:01
| 2022-10-29T14:41:01
| 241,212,109
| 359
| 48
| null | 2020-11-21T23:30:31
| 2020-02-17T21:31:00
|
C
|
UTF-8
|
C
| false
| false
| 2,386
|
c
|
math_asinacos.c
|
#include <ultra64.h>
//data
//D:80032320
u16 table_1[] = {
0x8000,0x7EBA,0x7D74,0x7C2D,0x7AE7,0x79A0,0x7859,0x7711,0x75C9,0x7480,
0x7337,0x71EC,0x70A1,0x6F55,0x6E07,0x6CB8,0x6B68,0x6A17,0x68C4,0x6770,
0x661A,0x64C1,0x6367,0x620B,0x60AD,0x5F4C,0x5DE9,0x5C83,0x5B1A,0x59AE,
0x583E,0x56CB,0x5555,0x53DB,0x525C,0x50D9,0x4F51,0x4DC5,0x4C32,0x4A9A,
0x48FC,0x4757,0x45AB,0x43F7,0x423A,0x4075,0x3EA5,0x3CCB,0x3AE5,0x38F1,
0x36EF,0x34DC,0x32B7,0x307D,0x2E2B,0x2BBD,0x292E,0x2678,0x2391,0x206C,
0x1CF6, 0
};
//D:8003239C
u16 table_2[] = {
0x1CF6,0x1CBB,0x1C80,0x1C45,0x1C08,0x1BCC,0x1B8F,0x1B51,0x1B13,0x1AD4,
0x1A95,0x1A55,0x1A14,0x19D3,0x1992,0x194F,0x190C,0x18C9,0x1884,0x183F,
0x17F9,0x17B3,0x176B,0x1723,0x16DA,0x1690,0x1645,0x15F9,0x15AC,0x155E,
0x150F,0x14BE,0x146D,0x141A,0x13C6,0x1370,0x1319,0x12C1,0x1267,0x120B,
0x11AD,0x114E,0x10EC,0x1088,0x1022, 0xFB9, 0xF4D, 0xEDE, 0xE6C, 0xDF7,
0xD7D, 0xD00, 0xC7D, 0xBF4, 0xB66, 0xAD0, 0xA31, 0x989, 0x8D3, 0x80E,
0x734, 0x63D, 0x518, 0x39A
};
//D:8003241C
u16 table_3[] = {
0x39A, 0x31E, 0x28C, 0x1CD, 0, 0
};
static s32 sub_GAME_7F05AB70(s32 arg0)
{
s32 mask;
u16 *table;
s32 shift;
s32 first;
s32 second;
s32 dd;
if (arg0 >= 0x7FE0)
{
mask = 7;
shift = 3;
table = &table_3;
arg0 = arg0 - 0x7FE0;
}
else if (arg0 >= 0x7800)
{
mask = 0x1F;
shift = 5;
table = &table_2;
arg0 = arg0 - 0x7800;
}
else
{
mask = 0x1FF;
shift = 9;
table = &table_1;
}
first = table[arg0 >> shift];
second = table[(arg0 >> shift) + 1];
dd = ((first - second) * (arg0 & mask)) >> shift;
return first - dd;
}
u16 acos(s16 arg0)
{
s32 phi_a0;
if (arg0 >= 0)
{
phi_a0 = arg0;
}
else
{
phi_a0 = -arg0;
}
phi_a0 = sub_GAME_7F05AB70(phi_a0);
if (arg0 < 0)
{
phi_a0 = 0xFFFF - phi_a0;
}
return (u16)phi_a0;
}
s16 asin(s16 arg0)
{
s32 temp_v0;
s32 phi_a0;
if (arg0 >= 0)
{
phi_a0 = arg0;
}
else
{
phi_a0 = -arg0;
}
temp_v0 = sub_GAME_7F05AB70(phi_a0);
if (arg0 >= 0)
{
phi_a0 = 0x7FFF - temp_v0;
}
else
{
phi_a0 = temp_v0 - 0x8000;
}
return (s16)phi_a0;
}
|
14d68527466e48bedf081b3df77eecfd614fd37e
|
e7508ea0a1c1fca5979908742b7ad3033f7686e9
|
/Test/hash_table_delete.c
|
ad7af89658a1876ccc9369e22cf92c05dc8540d3
|
[
"GPL-1.0-or-later",
"MIT"
] |
permissive
|
gnustep/libobjc2
|
c89e3bd185cb431e891f4c29e1e9530482ff8a1d
|
71e38a048fc06fea0c2015662540d46a33b5c45d
|
refs/heads/master
| 2023-08-03T08:23:45.566080
| 2023-01-29T17:40:34
| 2023-02-19T16:03:04
| 22,781,599
| 429
| 125
|
MIT
| 2023-02-19T16:03:06
| 2014-08-09T07:37:34
|
C
|
UTF-8
|
C
| false
| false
| 1,495
|
c
|
hash_table_delete.c
|
#include <stdbool.h>
#include <stdint.h>
struct test_struct {
uintptr_t key;
};
struct test_struct null_placeholder = {0};
static int test_compare(const void *key, const struct test_struct test) {
return (uintptr_t)key == test.key;
}
// force hash collisions
static uint32_t test_key_hash(const void *ptr) {
return ((uint32_t)(uintptr_t)ptr)>>2;
}
static uint32_t test_value_hash(const struct test_struct test) {
return test.key>>2;
}
static int test_is_null(const struct test_struct test) {
return test.key == 0;
}
#define MAP_TABLE_NAME test
#define MAP_TABLE_COMPARE_FUNCTION test_compare
#define MAP_TABLE_VALUE_TYPE struct test_struct
#define MAP_TABLE_VALUE_NULL test_is_null
#define MAP_TABLE_HASH_KEY test_key_hash
#define MAP_TABLE_HASH_VALUE test_value_hash
#define MAP_TABLE_VALUE_PLACEHOLDER null_placeholder
#define MAP_TABLE_ACCESS_BY_REFERENCE 1
#define MAP_TABLE_SINGLE_THREAD 1
#define MAP_TABLE_NO_LOCK 1
#include "../hash_table.h"
int main(int argc, char *argv[])
{
test_table *testTable;
test_initialize(&testTable, 128);
struct test_struct one, two, three;
one.key = 1;
two.key = 2;
three.key = 3;
test_insert(testTable, one);
test_insert(testTable, two);
test_insert(testTable, three);
test_remove(testTable, (void*)2);
test_remove(testTable, (void*)1);
struct test_struct *pthree = test_table_get(testTable, (void*)3);
if (!pthree) {
fprintf(stderr, "failed to find value (key=3) inserted into hash table\n");
return 1;
}
return 0;
}
|
41699a6ef76baf960653b86c50a5e63a61b54f5e
|
eecd5e4c50d8b78a769bcc2675250576bed34066
|
/include/petsc/private/pcgamgimpl.h
|
fdd10718ce615aa683f61397307a94afc5a2d7a8
|
[
"BSD-2-Clause"
] |
permissive
|
petsc/petsc
|
3b1a04fea71858e0292f9fd4d04ea11618c50969
|
9c5460f9064ca60dd71a234a1f6faf93e7a6b0c9
|
refs/heads/main
| 2023-08-17T20:51:16.507070
| 2023-08-17T16:08:06
| 2023-08-17T16:08:06
| 8,691,401
| 341
| 169
|
NOASSERTION
| 2023-03-29T11:02:58
| 2013-03-10T20:55:21
|
C
|
UTF-8
|
C
| false
| false
| 4,018
|
h
|
pcgamgimpl.h
|
#ifndef PETSC_PCGAMGIMPL_H
#define PETSC_PCGAMGIMPL_H
#include <petscksp.h>
#include <petsc/private/pcimpl.h>
#include <petsc/private/pcmgimpl.h> /*I "petscksp.h" I*/
#include <petscmatcoarsen.h> /*I "petscmatcoarsen.h" I*/
struct _PCGAMGOps {
PetscErrorCode (*creategraph)(PC, Mat, Mat *);
PetscErrorCode (*coarsen)(PC, Mat *, PetscCoarsenData **);
PetscErrorCode (*prolongator)(PC, Mat, Mat, PetscCoarsenData *, Mat *);
PetscErrorCode (*optprolongator)(PC, Mat, Mat *);
PetscErrorCode (*createlevel)(PC, Mat, PetscInt, Mat *, Mat *, PetscMPIInt *, IS *, PetscBool);
PetscErrorCode (*createdefaultdata)(PC, Mat); /* for data methods that have a default (SA) */
PetscErrorCode (*setfromoptions)(PC, PetscOptionItems *);
PetscErrorCode (*destroy)(PC);
PetscErrorCode (*view)(PC, PetscViewer);
};
/* Private context for the GAMG preconditioner */
typedef struct gamg_TAG {
PCGAMGType type;
PetscInt Nlevels;
PetscBool repart;
PetscBool reuse_prol;
PetscBool use_aggs_in_asm;
PetscBool use_parallel_coarse_grid_solver;
PCGAMGLayoutType layout_type;
PetscBool cpu_pin_coarse_grids;
PetscInt min_eq_proc;
PetscInt coarse_eq_limit;
PetscReal threshold_scale;
PetscReal threshold[PETSC_MG_MAXLEVELS]; /* common quatity to many AMG methods so keep it up here */
PetscInt level_reduction_factors[PETSC_MG_MAXLEVELS];
PetscInt current_level; /* stash construction state */
/* these 4 are all related to the method data and should be in the subctx */
PetscInt data_sz; /* nloc*data_rows*data_cols */
PetscInt data_cell_rows;
PetscInt data_cell_cols;
PetscInt orig_data_cell_rows;
PetscInt orig_data_cell_cols;
PetscReal *data; /* [data_sz] blocked vector of vertex data on fine grid (coordinates/nullspace) */
PetscReal *orig_data; /* cache data */
struct _PCGAMGOps *ops;
char *gamg_type_name;
void *subctx;
PetscBool use_sa_esteig;
PetscReal emin, emax;
} PC_GAMG;
PetscErrorCode PCReset_MG(PC);
/* hooks create derivied classes */
PetscErrorCode PCCreateGAMG_GEO(PC);
PetscErrorCode PCCreateGAMG_AGG(PC);
PetscErrorCode PCCreateGAMG_Classical(PC);
PetscErrorCode PCDestroy_GAMG(PC);
/* helper methods */
PetscErrorCode PCGAMGGetDataWithGhosts(Mat, PetscInt, PetscReal[], PetscInt *, PetscReal **);
enum tag {
GAMG_SETUP = 0,
GAMG_MESH,
GAMG_MATRIX,
GAMG_GRAPH,
GAMG_COARSEN,
GAMG_SQUARE,
GAMG_MIS,
GAMG_PROL,
GAMG_PROLA,
GAMG_PROLB,
GAMG_OPT,
GAMG_OPTSM,
GAMG_LEVEL,
GAMG_PTAP,
GAMG_REDUCE,
GAMG_REPART,
SET13,
SET14,
SET15,
GAMG_NUM_SET
};
PETSC_EXTERN PetscLogEvent petsc_gamg_setup_events[GAMG_NUM_SET];
PETSC_EXTERN PetscLogEvent petsc_gamg_setup_matmat_events[PETSC_MG_MAXLEVELS][3];
typedef struct _PCGAMGHashTable {
PetscInt *table;
PetscInt *data;
PetscInt size;
} PCGAMGHashTable;
PETSC_INTERN PetscErrorCode PCGAMGHashTableCreate(PetscInt, PCGAMGHashTable *);
PETSC_INTERN PetscErrorCode PCGAMGHashTableDestroy(PCGAMGHashTable *);
PETSC_INTERN PetscErrorCode PCGAMGHashTableAdd(PCGAMGHashTable *, PetscInt, PetscInt);
#define GAMG_HASH(key) (PetscInt)((((PetscInt64)7) * (PetscInt64)key) % (PetscInt64)a_tab->size)
static inline PetscErrorCode PCGAMGHashTableFind(PCGAMGHashTable *a_tab, PetscInt a_key, PetscInt *a_data)
{
PetscInt kk, idx;
PetscFunctionBegin;
PetscCheck(a_key >= 0, PETSC_COMM_SELF, PETSC_ERR_USER, "Negative key %" PetscInt_FMT, a_key);
for (kk = 0, idx = GAMG_HASH(a_key); kk < a_tab->size; kk++, idx = (idx == (a_tab->size - 1)) ? 0 : idx + 1) {
if (a_tab->table[idx] == a_key) {
*a_data = a_tab->data[idx];
break;
} else if (a_tab->table[idx] == -1) {
/* not here */
*a_data = -1;
break;
}
}
PetscCheck(kk != a_tab->size, PETSC_COMM_SELF, PETSC_ERR_USER, "key %" PetscInt_FMT " not found in table", a_key);
PetscFunctionReturn(PETSC_SUCCESS);
}
#endif // PETSC_PCGAMGIMPL_H
|
987cd91d141cd4e9f50465fbcf2a4793466c21b4
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/net/ethernet/atheros/atl1c/atl1c_hw.h
|
21d8c4dbdbe12b6bd90676b49a08823de35a30f7
|
[
"GPL-1.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 36,929
|
h
|
atl1c_hw.h
|
/*
* Copyright(c) 2008 - 2009 Atheros Corporation. All rights reserved.
*
* Derived from Intel e1000 driver
* Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; 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.
*/
#ifndef _ATL1C_HW_H_
#define _ATL1C_HW_H_
#include <linux/types.h>
#include <linux/mii.h>
#define FIELD_GETX(_x, _name) ((_x) >> (_name##_SHIFT) & (_name##_MASK))
#define FIELD_SETX(_x, _name, _v) \
(((_x) & ~((_name##_MASK) << (_name##_SHIFT))) |\
(((_v) & (_name##_MASK)) << (_name##_SHIFT)))
#define FIELDX(_name, _v) (((_v) & (_name##_MASK)) << (_name##_SHIFT))
struct atl1c_adapter;
struct atl1c_hw;
/* function prototype */
void atl1c_phy_disable(struct atl1c_hw *hw);
void atl1c_hw_set_mac_addr(struct atl1c_hw *hw, u8 *mac_addr);
int atl1c_phy_reset(struct atl1c_hw *hw);
int atl1c_read_mac_addr(struct atl1c_hw *hw);
int atl1c_get_speed_and_duplex(struct atl1c_hw *hw, u16 *speed, u16 *duplex);
u32 atl1c_hash_mc_addr(struct atl1c_hw *hw, u8 *mc_addr);
void atl1c_hash_set(struct atl1c_hw *hw, u32 hash_value);
int atl1c_read_phy_reg(struct atl1c_hw *hw, u16 reg_addr, u16 *phy_data);
int atl1c_write_phy_reg(struct atl1c_hw *hw, u32 reg_addr, u16 phy_data);
bool atl1c_read_eeprom(struct atl1c_hw *hw, u32 offset, u32 *p_value);
int atl1c_phy_init(struct atl1c_hw *hw);
int atl1c_check_eeprom_exist(struct atl1c_hw *hw);
int atl1c_restart_autoneg(struct atl1c_hw *hw);
int atl1c_phy_to_ps_link(struct atl1c_hw *hw);
int atl1c_power_saving(struct atl1c_hw *hw, u32 wufc);
bool atl1c_wait_mdio_idle(struct atl1c_hw *hw);
void atl1c_stop_phy_polling(struct atl1c_hw *hw);
void atl1c_start_phy_polling(struct atl1c_hw *hw, u16 clk_sel);
int atl1c_read_phy_core(struct atl1c_hw *hw, bool ext, u8 dev,
u16 reg, u16 *phy_data);
int atl1c_write_phy_core(struct atl1c_hw *hw, bool ext, u8 dev,
u16 reg, u16 phy_data);
int atl1c_read_phy_ext(struct atl1c_hw *hw, u8 dev_addr,
u16 reg_addr, u16 *phy_data);
int atl1c_write_phy_ext(struct atl1c_hw *hw, u8 dev_addr,
u16 reg_addr, u16 phy_data);
int atl1c_read_phy_dbg(struct atl1c_hw *hw, u16 reg_addr, u16 *phy_data);
int atl1c_write_phy_dbg(struct atl1c_hw *hw, u16 reg_addr, u16 phy_data);
void atl1c_post_phy_linkchg(struct atl1c_hw *hw, u16 link_speed);
/* hw-ids */
#define PCI_DEVICE_ID_ATTANSIC_L2C 0x1062
#define PCI_DEVICE_ID_ATTANSIC_L1C 0x1063
#define PCI_DEVICE_ID_ATHEROS_L2C_B 0x2060 /* AR8152 v1.1 Fast 10/100 */
#define PCI_DEVICE_ID_ATHEROS_L2C_B2 0x2062 /* AR8152 v2.0 Fast 10/100 */
#define PCI_DEVICE_ID_ATHEROS_L1D 0x1073 /* AR8151 v1.0 Gigabit 1000 */
#define PCI_DEVICE_ID_ATHEROS_L1D_2_0 0x1083 /* AR8151 v2.0 Gigabit 1000 */
#define L2CB_V10 0xc0
#define L2CB_V11 0xc1
#define L2CB_V20 0xc0
#define L2CB_V21 0xc1
/* register definition */
#define REG_DEVICE_CAP 0x5C
#define DEVICE_CAP_MAX_PAYLOAD_MASK 0x7
#define DEVICE_CAP_MAX_PAYLOAD_SHIFT 0
#define DEVICE_CTRL_MAXRRS_MIN 2
#define REG_LINK_CTRL 0x68
#define LINK_CTRL_L0S_EN 0x01
#define LINK_CTRL_L1_EN 0x02
#define LINK_CTRL_EXT_SYNC 0x80
#define REG_PCIE_IND_ACC_ADDR 0x80
#define REG_PCIE_IND_ACC_DATA 0x84
#define REG_DEV_SERIALNUM_CTRL 0x200
#define REG_DEV_MAC_SEL_MASK 0x0 /* 0:EUI; 1:MAC */
#define REG_DEV_MAC_SEL_SHIFT 0
#define REG_DEV_SERIAL_NUM_EN_MASK 0x1
#define REG_DEV_SERIAL_NUM_EN_SHIFT 1
#define REG_TWSI_CTRL 0x218
#define TWSI_CTLR_FREQ_MASK 0x3UL
#define TWSI_CTRL_FREQ_SHIFT 24
#define TWSI_CTRL_FREQ_100K 0
#define TWSI_CTRL_FREQ_200K 1
#define TWSI_CTRL_FREQ_300K 2
#define TWSI_CTRL_FREQ_400K 3
#define TWSI_CTRL_LD_EXIST BIT(23)
#define TWSI_CTRL_HW_LDSTAT BIT(12) /* 0:finish,1:in progress */
#define TWSI_CTRL_SW_LDSTART BIT(11)
#define TWSI_CTRL_LD_OFFSET_MASK 0xFF
#define TWSI_CTRL_LD_OFFSET_SHIFT 0
#define REG_PCIE_DEV_MISC_CTRL 0x21C
#define PCIE_DEV_MISC_EXT_PIPE 0x2
#define PCIE_DEV_MISC_RETRY_BUFDIS 0x1
#define PCIE_DEV_MISC_SPIROM_EXIST 0x4
#define PCIE_DEV_MISC_SERDES_ENDIAN 0x8
#define PCIE_DEV_MISC_SERDES_SEL_DIN 0x10
#define REG_PCIE_PHYMISC 0x1000
#define PCIE_PHYMISC_FORCE_RCV_DET BIT(2)
#define PCIE_PHYMISC_NFTS_MASK 0xFFUL
#define PCIE_PHYMISC_NFTS_SHIFT 16
#define REG_PCIE_PHYMISC2 0x1004
#define PCIE_PHYMISC2_L0S_TH_MASK 0x3UL
#define PCIE_PHYMISC2_L0S_TH_SHIFT 18
#define L2CB1_PCIE_PHYMISC2_L0S_TH 3
#define PCIE_PHYMISC2_CDR_BW_MASK 0x3UL
#define PCIE_PHYMISC2_CDR_BW_SHIFT 16
#define L2CB1_PCIE_PHYMISC2_CDR_BW 3
#define REG_TWSI_DEBUG 0x1108
#define TWSI_DEBUG_DEV_EXIST BIT(29)
#define REG_DMA_DBG 0x1114
#define DMA_DBG_VENDOR_MSG BIT(0)
#define REG_EEPROM_CTRL 0x12C0
#define EEPROM_CTRL_DATA_HI_MASK 0xFFFF
#define EEPROM_CTRL_DATA_HI_SHIFT 0
#define EEPROM_CTRL_ADDR_MASK 0x3FF
#define EEPROM_CTRL_ADDR_SHIFT 16
#define EEPROM_CTRL_ACK 0x40000000
#define EEPROM_CTRL_RW 0x80000000
#define REG_EEPROM_DATA_LO 0x12C4
#define REG_OTP_CTRL 0x12F0
#define OTP_CTRL_CLK_EN BIT(1)
#define REG_PM_CTRL 0x12F8
#define PM_CTRL_HOTRST BIT(31)
#define PM_CTRL_MAC_ASPM_CHK BIT(30) /* L0s/L1 dis by MAC based on
* thrghput(setting in 15A0) */
#define PM_CTRL_SA_DLY_EN BIT(29)
#define PM_CTRL_L0S_BUFSRX_EN BIT(28)
#define PM_CTRL_LCKDET_TIMER_MASK 0xFUL
#define PM_CTRL_LCKDET_TIMER_SHIFT 24
#define PM_CTRL_LCKDET_TIMER_DEF 0xC
#define PM_CTRL_PM_REQ_TIMER_MASK 0xFUL
#define PM_CTRL_PM_REQ_TIMER_SHIFT 20 /* pm_request_l1 time > @
* ->L0s not L1 */
#define PM_CTRL_PM_REQ_TO_DEF 0xF
#define PMCTRL_TXL1_AFTER_L0S BIT(19) /* l1dv2.0+ */
#define L1D_PMCTRL_L1_ENTRY_TM_MASK 7UL /* l1dv2.0+, 3bits */
#define L1D_PMCTRL_L1_ENTRY_TM_SHIFT 16
#define L1D_PMCTRL_L1_ENTRY_TM_DIS 0
#define L1D_PMCTRL_L1_ENTRY_TM_2US 1
#define L1D_PMCTRL_L1_ENTRY_TM_4US 2
#define L1D_PMCTRL_L1_ENTRY_TM_8US 3
#define L1D_PMCTRL_L1_ENTRY_TM_16US 4
#define L1D_PMCTRL_L1_ENTRY_TM_24US 5
#define L1D_PMCTRL_L1_ENTRY_TM_32US 6
#define L1D_PMCTRL_L1_ENTRY_TM_63US 7
#define PM_CTRL_L1_ENTRY_TIMER_MASK 0xFUL /* l1C 4bits */
#define PM_CTRL_L1_ENTRY_TIMER_SHIFT 16
#define L2CB1_PM_CTRL_L1_ENTRY_TM 7
#define L1C_PM_CTRL_L1_ENTRY_TM 0xF
#define PM_CTRL_RCVR_WT_TIMER BIT(15) /* 1:1us, 0:2ms */
#define PM_CTRL_CLK_PWM_VER1_1 BIT(14) /* 0:1.0a,1:1.1 */
#define PM_CTRL_CLK_SWH_L1 BIT(13) /* en pcie clk sw in L1 */
#define PM_CTRL_ASPM_L0S_EN BIT(12)
#define PM_CTRL_RXL1_AFTER_L0S BIT(11) /* l1dv2.0+ */
#define L1D_PMCTRL_L0S_TIMER_MASK 7UL /* l1d2.0+, 3bits*/
#define L1D_PMCTRL_L0S_TIMER_SHIFT 8
#define PM_CTRL_L0S_ENTRY_TIMER_MASK 0xFUL /* l1c, 4bits */
#define PM_CTRL_L0S_ENTRY_TIMER_SHIFT 8
#define PM_CTRL_SERDES_BUFS_RX_L1_EN BIT(7)
#define PM_CTRL_SERDES_PD_EX_L1 BIT(6) /* power down serdes rx */
#define PM_CTRL_SERDES_PLL_L1_EN BIT(5)
#define PM_CTRL_SERDES_L1_EN BIT(4)
#define PM_CTRL_ASPM_L1_EN BIT(3)
#define PM_CTRL_CLK_REQ_EN BIT(2)
#define PM_CTRL_RBER_EN BIT(1)
#define PM_CTRL_SPRSDWER_EN BIT(0)
#define REG_LTSSM_ID_CTRL 0x12FC
#define LTSSM_ID_EN_WRO 0x1000
/* Selene Master Control Register */
#define REG_MASTER_CTRL 0x1400
#define MASTER_CTRL_OTP_SEL BIT(31)
#define MASTER_DEV_NUM_MASK 0x7FUL
#define MASTER_DEV_NUM_SHIFT 24
#define MASTER_REV_NUM_MASK 0xFFUL
#define MASTER_REV_NUM_SHIFT 16
#define MASTER_CTRL_INT_RDCLR BIT(14)
#define MASTER_CTRL_CLK_SEL_DIS BIT(12) /* 1:alwys sel pclk from
* serdes, not sw to 25M */
#define MASTER_CTRL_RX_ITIMER_EN BIT(11) /* IRQ MODURATION FOR RX */
#define MASTER_CTRL_TX_ITIMER_EN BIT(10) /* MODURATION FOR TX/RX */
#define MASTER_CTRL_MANU_INT BIT(9) /* SOFT MANUAL INT */
#define MASTER_CTRL_MANUTIMER_EN BIT(8)
#define MASTER_CTRL_SA_TIMER_EN BIT(7) /* SYS ALIVE TIMER EN */
#define MASTER_CTRL_OOB_DIS BIT(6) /* OUT OF BOX DIS */
#define MASTER_CTRL_WAKEN_25M BIT(5) /* WAKE WO. PCIE CLK */
#define MASTER_CTRL_BERT_START BIT(4)
#define MASTER_PCIE_TSTMOD_MASK 3UL
#define MASTER_PCIE_TSTMOD_SHIFT 2
#define MASTER_PCIE_RST BIT(1)
#define MASTER_CTRL_SOFT_RST BIT(0) /* RST MAC & DMA */
#define DMA_MAC_RST_TO 50
/* Timer Initial Value Register */
#define REG_MANUAL_TIMER_INIT 0x1404
/* IRQ ModeratorTimer Initial Value Register */
#define REG_IRQ_MODRT_TIMER_INIT 0x1408
#define IRQ_MODRT_TIMER_MASK 0xffff
#define IRQ_MODRT_TX_TIMER_SHIFT 0
#define IRQ_MODRT_RX_TIMER_SHIFT 16
#define REG_GPHY_CTRL 0x140C
#define GPHY_CTRL_ADDR_MASK 0x1FUL
#define GPHY_CTRL_ADDR_SHIFT 19
#define GPHY_CTRL_BP_VLTGSW BIT(18)
#define GPHY_CTRL_100AB_EN BIT(17)
#define GPHY_CTRL_10AB_EN BIT(16)
#define GPHY_CTRL_PHY_PLL_BYPASS BIT(15)
#define GPHY_CTRL_PWDOWN_HW BIT(14) /* affect MAC&PHY, to low pw */
#define GPHY_CTRL_PHY_PLL_ON BIT(13) /* 1:pll always on, 0:can sw */
#define GPHY_CTRL_SEL_ANA_RST BIT(12)
#define GPHY_CTRL_HIB_PULSE BIT(11)
#define GPHY_CTRL_HIB_EN BIT(10)
#define GPHY_CTRL_GIGA_DIS BIT(9)
#define GPHY_CTRL_PHY_IDDQ_DIS BIT(8) /* pw on RST */
#define GPHY_CTRL_PHY_IDDQ BIT(7) /* bit8 affect bit7 while rb */
#define GPHY_CTRL_LPW_EXIT BIT(6)
#define GPHY_CTRL_GATE_25M_EN BIT(5)
#define GPHY_CTRL_REV_ANEG BIT(4)
#define GPHY_CTRL_ANEG_NOW BIT(3)
#define GPHY_CTRL_LED_MODE BIT(2)
#define GPHY_CTRL_RTL_MODE BIT(1)
#define GPHY_CTRL_EXT_RESET BIT(0) /* 1:out of DSP RST status */
#define GPHY_CTRL_EXT_RST_TO 80 /* 800us atmost */
#define GPHY_CTRL_CLS (\
GPHY_CTRL_LED_MODE |\
GPHY_CTRL_100AB_EN |\
GPHY_CTRL_PHY_PLL_ON)
/* Block IDLE Status Register */
#define REG_IDLE_STATUS 0x1410
#define IDLE_STATUS_SFORCE_MASK 0xFUL
#define IDLE_STATUS_SFORCE_SHIFT 14
#define IDLE_STATUS_CALIB_DONE BIT(13)
#define IDLE_STATUS_CALIB_RES_MASK 0x1FUL
#define IDLE_STATUS_CALIB_RES_SHIFT 8
#define IDLE_STATUS_CALIBERR_MASK 0xFUL
#define IDLE_STATUS_CALIBERR_SHIFT 4
#define IDLE_STATUS_TXQ_BUSY BIT(3)
#define IDLE_STATUS_RXQ_BUSY BIT(2)
#define IDLE_STATUS_TXMAC_BUSY BIT(1)
#define IDLE_STATUS_RXMAC_BUSY BIT(0)
#define IDLE_STATUS_MASK (\
IDLE_STATUS_TXQ_BUSY |\
IDLE_STATUS_RXQ_BUSY |\
IDLE_STATUS_TXMAC_BUSY |\
IDLE_STATUS_RXMAC_BUSY)
/* MDIO Control Register */
#define REG_MDIO_CTRL 0x1414
#define MDIO_CTRL_MODE_EXT BIT(30)
#define MDIO_CTRL_POST_READ BIT(29)
#define MDIO_CTRL_AP_EN BIT(28)
#define MDIO_CTRL_BUSY BIT(27)
#define MDIO_CTRL_CLK_SEL_MASK 0x7UL
#define MDIO_CTRL_CLK_SEL_SHIFT 24
#define MDIO_CTRL_CLK_25_4 0 /* 25MHz divide 4 */
#define MDIO_CTRL_CLK_25_6 2
#define MDIO_CTRL_CLK_25_8 3
#define MDIO_CTRL_CLK_25_10 4
#define MDIO_CTRL_CLK_25_32 5
#define MDIO_CTRL_CLK_25_64 6
#define MDIO_CTRL_CLK_25_128 7
#define MDIO_CTRL_START BIT(23)
#define MDIO_CTRL_SPRES_PRMBL BIT(22)
#define MDIO_CTRL_OP_READ BIT(21) /* 1:read, 0:write */
#define MDIO_CTRL_REG_MASK 0x1FUL
#define MDIO_CTRL_REG_SHIFT 16
#define MDIO_CTRL_DATA_MASK 0xFFFFUL
#define MDIO_CTRL_DATA_SHIFT 0
#define MDIO_MAX_AC_TO 120 /* 1.2ms timeout for slow clk */
/* for extension reg access */
#define REG_MDIO_EXTN 0x1448
#define MDIO_EXTN_PORTAD_MASK 0x1FUL
#define MDIO_EXTN_PORTAD_SHIFT 21
#define MDIO_EXTN_DEVAD_MASK 0x1FUL
#define MDIO_EXTN_DEVAD_SHIFT 16
#define MDIO_EXTN_REG_MASK 0xFFFFUL
#define MDIO_EXTN_REG_SHIFT 0
/* BIST Control and Status Register0 (for the Packet Memory) */
#define REG_BIST0_CTRL 0x141c
#define BIST0_NOW 0x1
#define BIST0_SRAM_FAIL 0x2 /* 1: The SRAM failure is
* un-repairable because
* it has address decoder
* failure or more than 1 cell
* stuck-to-x failure */
#define BIST0_FUSE_FLAG 0x4
/* BIST Control and Status Register1(for the retry buffer of PCI Express) */
#define REG_BIST1_CTRL 0x1420
#define BIST1_NOW 0x1
#define BIST1_SRAM_FAIL 0x2
#define BIST1_FUSE_FLAG 0x4
/* SerDes Lock Detect Control and Status Register */
#define REG_SERDES 0x1424
#define SERDES_PHY_CLK_SLOWDOWN BIT(18)
#define SERDES_MAC_CLK_SLOWDOWN BIT(17)
#define SERDES_SELFB_PLL_MASK 0x3UL
#define SERDES_SELFB_PLL_SHIFT 14
#define SERDES_PHYCLK_SEL_GTX BIT(13) /* 1:gtx_clk, 0:25M */
#define SERDES_PCIECLK_SEL_SRDS BIT(12) /* 1:serdes,0:25M */
#define SERDES_BUFS_RX_EN BIT(11)
#define SERDES_PD_RX BIT(10)
#define SERDES_PLL_EN BIT(9)
#define SERDES_EN BIT(8)
#define SERDES_SELFB_PLL_SEL_CSR BIT(6) /* 0:state-machine,1:csr */
#define SERDES_SELFB_PLL_CSR_MASK 0x3UL
#define SERDES_SELFB_PLL_CSR_SHIFT 4
#define SERDES_SELFB_PLL_CSR_4 3 /* 4-12% OV-CLK */
#define SERDES_SELFB_PLL_CSR_0 2 /* 0-4% OV-CLK */
#define SERDES_SELFB_PLL_CSR_12 1 /* 12-18% OV-CLK */
#define SERDES_SELFB_PLL_CSR_18 0 /* 18-25% OV-CLK */
#define SERDES_VCO_SLOW BIT(3)
#define SERDES_VCO_FAST BIT(2)
#define SERDES_LOCK_DETECT_EN BIT(1)
#define SERDES_LOCK_DETECT BIT(0)
#define REG_LPI_DECISN_TIMER 0x143C
#define L2CB_LPI_DESISN_TIMER 0x7D00
#define REG_LPI_CTRL 0x1440
#define LPI_CTRL_CHK_DA BIT(31)
#define LPI_CTRL_ENH_TO_MASK 0x1FFFUL
#define LPI_CTRL_ENH_TO_SHIFT 12
#define LPI_CTRL_ENH_TH_MASK 0x1FUL
#define LPI_CTRL_ENH_TH_SHIFT 6
#define LPI_CTRL_ENH_EN BIT(5)
#define LPI_CTRL_CHK_RX BIT(4)
#define LPI_CTRL_CHK_STATE BIT(3)
#define LPI_CTRL_GMII BIT(2)
#define LPI_CTRL_TO_PHY BIT(1)
#define LPI_CTRL_EN BIT(0)
#define REG_LPI_WAIT 0x1444
#define LPI_WAIT_TIMER_MASK 0xFFFFUL
#define LPI_WAIT_TIMER_SHIFT 0
/* MAC Control Register */
#define REG_MAC_CTRL 0x1480
#define MAC_CTRL_SPEED_MODE_SW BIT(30) /* 0:phy,1:sw */
#define MAC_CTRL_HASH_ALG_CRC32 BIT(29) /* 1:legacy,0:lw_5b */
#define MAC_CTRL_SINGLE_PAUSE_EN BIT(28)
#define MAC_CTRL_DBG BIT(27)
#define MAC_CTRL_BC_EN BIT(26)
#define MAC_CTRL_MC_ALL_EN BIT(25)
#define MAC_CTRL_RX_CHKSUM_EN BIT(24)
#define MAC_CTRL_TX_HUGE BIT(23)
#define MAC_CTRL_DBG_TX_BKPRESURE BIT(22)
#define MAC_CTRL_SPEED_MASK 3UL
#define MAC_CTRL_SPEED_SHIFT 20
#define MAC_CTRL_SPEED_10_100 1
#define MAC_CTRL_SPEED_1000 2
#define MAC_CTRL_TX_SIMURST BIT(19)
#define MAC_CTRL_SCNT BIT(17)
#define MAC_CTRL_TX_PAUSE BIT(16)
#define MAC_CTRL_PROMIS_EN BIT(15)
#define MAC_CTRL_RMV_VLAN BIT(14)
#define MAC_CTRL_PRMLEN_MASK 0xFUL
#define MAC_CTRL_PRMLEN_SHIFT 10
#define MAC_CTRL_HUGE_EN BIT(9)
#define MAC_CTRL_LENCHK BIT(8)
#define MAC_CTRL_PAD BIT(7)
#define MAC_CTRL_ADD_CRC BIT(6)
#define MAC_CTRL_DUPLX BIT(5)
#define MAC_CTRL_LOOPBACK BIT(4)
#define MAC_CTRL_RX_FLOW BIT(3)
#define MAC_CTRL_TX_FLOW BIT(2)
#define MAC_CTRL_RX_EN BIT(1)
#define MAC_CTRL_TX_EN BIT(0)
/* MAC IPG/IFG Control Register */
#define REG_MAC_IPG_IFG 0x1484
#define MAC_IPG_IFG_IPGT_SHIFT 0 /* Desired back to back
* inter-packet gap. The
* default is 96-bit time */
#define MAC_IPG_IFG_IPGT_MASK 0x7f
#define MAC_IPG_IFG_MIFG_SHIFT 8 /* Minimum number of IFG to
* enforce in between RX frames */
#define MAC_IPG_IFG_MIFG_MASK 0xff /* Frame gap below such IFP is dropped */
#define MAC_IPG_IFG_IPGR1_SHIFT 16 /* 64bit Carrier-Sense window */
#define MAC_IPG_IFG_IPGR1_MASK 0x7f
#define MAC_IPG_IFG_IPGR2_SHIFT 24 /* 96-bit IPG window */
#define MAC_IPG_IFG_IPGR2_MASK 0x7f
/* MAC STATION ADDRESS */
#define REG_MAC_STA_ADDR 0x1488
/* Hash table for multicast address */
#define REG_RX_HASH_TABLE 0x1490
/* MAC Half-Duplex Control Register */
#define REG_MAC_HALF_DUPLX_CTRL 0x1498
#define MAC_HALF_DUPLX_CTRL_LCOL_SHIFT 0 /* Collision Window */
#define MAC_HALF_DUPLX_CTRL_LCOL_MASK 0x3ff
#define MAC_HALF_DUPLX_CTRL_RETRY_SHIFT 12
#define MAC_HALF_DUPLX_CTRL_RETRY_MASK 0xf
#define MAC_HALF_DUPLX_CTRL_EXC_DEF_EN 0x10000
#define MAC_HALF_DUPLX_CTRL_NO_BACK_C 0x20000
#define MAC_HALF_DUPLX_CTRL_NO_BACK_P 0x40000 /* No back-off on backpressure,
* immediately start the
* transmission after back pressure */
#define MAC_HALF_DUPLX_CTRL_ABEBE 0x80000 /* 1: Alternative Binary Exponential Back-off Enabled */
#define MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT 20 /* Maximum binary exponential number */
#define MAC_HALF_DUPLX_CTRL_ABEBT_MASK 0xf
#define MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT 24 /* IPG to start JAM for collision based flow control in half-duplex */
#define MAC_HALF_DUPLX_CTRL_JAMIPG_MASK 0xf /* mode. In unit of 8-bit time */
/* Maximum Frame Length Control Register */
#define REG_MTU 0x149c
/* Wake-On-Lan control register */
#define REG_WOL_CTRL 0x14a0
#define WOL_PT7_MATCH BIT(31)
#define WOL_PT6_MATCH BIT(30)
#define WOL_PT5_MATCH BIT(29)
#define WOL_PT4_MATCH BIT(28)
#define WOL_PT3_MATCH BIT(27)
#define WOL_PT2_MATCH BIT(26)
#define WOL_PT1_MATCH BIT(25)
#define WOL_PT0_MATCH BIT(24)
#define WOL_PT7_EN BIT(23)
#define WOL_PT6_EN BIT(22)
#define WOL_PT5_EN BIT(21)
#define WOL_PT4_EN BIT(20)
#define WOL_PT3_EN BIT(19)
#define WOL_PT2_EN BIT(18)
#define WOL_PT1_EN BIT(17)
#define WOL_PT0_EN BIT(16)
#define WOL_LNKCHG_ST BIT(10)
#define WOL_MAGIC_ST BIT(9)
#define WOL_PATTERN_ST BIT(8)
#define WOL_OOB_EN BIT(6)
#define WOL_LINK_CHG_PME_EN BIT(5)
#define WOL_LINK_CHG_EN BIT(4)
#define WOL_MAGIC_PME_EN BIT(3)
#define WOL_MAGIC_EN BIT(2)
#define WOL_PATTERN_PME_EN BIT(1)
#define WOL_PATTERN_EN BIT(0)
/* WOL Length ( 2 DWORD ) */
#define REG_WOL_PTLEN1 0x14A4
#define WOL_PTLEN1_3_MASK 0xFFUL
#define WOL_PTLEN1_3_SHIFT 24
#define WOL_PTLEN1_2_MASK 0xFFUL
#define WOL_PTLEN1_2_SHIFT 16
#define WOL_PTLEN1_1_MASK 0xFFUL
#define WOL_PTLEN1_1_SHIFT 8
#define WOL_PTLEN1_0_MASK 0xFFUL
#define WOL_PTLEN1_0_SHIFT 0
#define REG_WOL_PTLEN2 0x14A8
#define WOL_PTLEN2_7_MASK 0xFFUL
#define WOL_PTLEN2_7_SHIFT 24
#define WOL_PTLEN2_6_MASK 0xFFUL
#define WOL_PTLEN2_6_SHIFT 16
#define WOL_PTLEN2_5_MASK 0xFFUL
#define WOL_PTLEN2_5_SHIFT 8
#define WOL_PTLEN2_4_MASK 0xFFUL
#define WOL_PTLEN2_4_SHIFT 0
/* Internal SRAM Partition Register */
#define RFDX_HEAD_ADDR_MASK 0x03FF
#define RFDX_HARD_ADDR_SHIFT 0
#define RFDX_TAIL_ADDR_MASK 0x03FF
#define RFDX_TAIL_ADDR_SHIFT 16
#define REG_SRAM_RFD0_INFO 0x1500
#define REG_SRAM_RFD1_INFO 0x1504
#define REG_SRAM_RFD2_INFO 0x1508
#define REG_SRAM_RFD3_INFO 0x150C
#define REG_RFD_NIC_LEN 0x1510 /* In 8-bytes */
#define RFD_NIC_LEN_MASK 0x03FF
#define REG_SRAM_TRD_ADDR 0x1518
#define TPD_HEAD_ADDR_MASK 0x03FF
#define TPD_HEAD_ADDR_SHIFT 0
#define TPD_TAIL_ADDR_MASK 0x03FF
#define TPD_TAIL_ADDR_SHIFT 16
#define REG_SRAM_TRD_LEN 0x151C /* In 8-bytes */
#define TPD_NIC_LEN_MASK 0x03FF
#define REG_SRAM_RXF_ADDR 0x1520
#define REG_SRAM_RXF_LEN 0x1524
#define REG_SRAM_TXF_ADDR 0x1528
#define REG_SRAM_TXF_LEN 0x152C
#define REG_SRAM_TCPH_ADDR 0x1530
#define REG_SRAM_PKTH_ADDR 0x1532
/*
* Load Ptr Register
* Software sets this bit after the initialization of the head and tail */
#define REG_LOAD_PTR 0x1534
/*
* addresses of all descriptors, as well as the following descriptor
* control register, which triggers each function block to load the head
* pointer to prepare for the operation. This bit is then self-cleared
* after one cycle.
*/
#define REG_RX_BASE_ADDR_HI 0x1540
#define REG_TX_BASE_ADDR_HI 0x1544
#define REG_RFD0_HEAD_ADDR_LO 0x1550
#define REG_RFD_RING_SIZE 0x1560
#define RFD_RING_SIZE_MASK 0x0FFF
#define REG_RX_BUF_SIZE 0x1564
#define RX_BUF_SIZE_MASK 0xFFFF
#define REG_RRD0_HEAD_ADDR_LO 0x1568
#define REG_RRD_RING_SIZE 0x1578
#define RRD_RING_SIZE_MASK 0x0FFF
#define REG_TPD_PRI1_ADDR_LO 0x157C
#define REG_TPD_PRI0_ADDR_LO 0x1580
#define REG_TPD_RING_SIZE 0x1584
#define TPD_RING_SIZE_MASK 0xFFFF
/* TXQ Control Register */
#define REG_TXQ_CTRL 0x1590
#define TXQ_TXF_BURST_NUM_MASK 0xFFFFUL
#define TXQ_TXF_BURST_NUM_SHIFT 16
#define L1C_TXQ_TXF_BURST_PREF 0x200
#define L2CB_TXQ_TXF_BURST_PREF 0x40
#define TXQ_CTRL_PEDING_CLR BIT(8)
#define TXQ_CTRL_LS_8023_EN BIT(7)
#define TXQ_CTRL_ENH_MODE BIT(6)
#define TXQ_CTRL_EN BIT(5)
#define TXQ_CTRL_IP_OPTION_EN BIT(4)
#define TXQ_NUM_TPD_BURST_MASK 0xFUL
#define TXQ_NUM_TPD_BURST_SHIFT 0
#define TXQ_NUM_TPD_BURST_DEF 5
#define TXQ_CFGV (\
FIELDX(TXQ_NUM_TPD_BURST, TXQ_NUM_TPD_BURST_DEF) |\
TXQ_CTRL_ENH_MODE |\
TXQ_CTRL_LS_8023_EN |\
TXQ_CTRL_IP_OPTION_EN)
#define L1C_TXQ_CFGV (\
TXQ_CFGV |\
FIELDX(TXQ_TXF_BURST_NUM, L1C_TXQ_TXF_BURST_PREF))
#define L2CB_TXQ_CFGV (\
TXQ_CFGV |\
FIELDX(TXQ_TXF_BURST_NUM, L2CB_TXQ_TXF_BURST_PREF))
/* Jumbo packet Threshold for task offload */
#define REG_TX_TSO_OFFLOAD_THRESH 0x1594 /* In 8-bytes */
#define TX_TSO_OFFLOAD_THRESH_MASK 0x07FF
#define MAX_TSO_FRAME_SIZE (7*1024)
#define REG_TXF_WATER_MARK 0x1598 /* In 8-bytes */
#define TXF_WATER_MARK_MASK 0x0FFF
#define TXF_LOW_WATER_MARK_SHIFT 0
#define TXF_HIGH_WATER_MARK_SHIFT 16
#define TXQ_CTRL_BURST_MODE_EN 0x80000000
#define REG_THRUPUT_MON_CTRL 0x159C
#define THRUPUT_MON_RATE_MASK 0x3
#define THRUPUT_MON_RATE_SHIFT 0
#define THRUPUT_MON_EN 0x80
/* RXQ Control Register */
#define REG_RXQ_CTRL 0x15A0
#define ASPM_THRUPUT_LIMIT_MASK 0x3
#define ASPM_THRUPUT_LIMIT_SHIFT 0
#define ASPM_THRUPUT_LIMIT_NO 0x00
#define ASPM_THRUPUT_LIMIT_1M 0x01
#define ASPM_THRUPUT_LIMIT_10M 0x02
#define ASPM_THRUPUT_LIMIT_100M 0x03
#define IPV6_CHKSUM_CTRL_EN BIT(7)
#define RXQ_RFD_BURST_NUM_MASK 0x003F
#define RXQ_RFD_BURST_NUM_SHIFT 20
#define RXQ_NUM_RFD_PREF_DEF 8
#define RSS_MODE_MASK 3UL
#define RSS_MODE_SHIFT 26
#define RSS_MODE_DIS 0
#define RSS_MODE_SQSI 1
#define RSS_MODE_MQSI 2
#define RSS_MODE_MQMI 3
#define RSS_NIP_QUEUE_SEL BIT(28) /* 0:q0, 1:table */
#define RRS_HASH_CTRL_EN BIT(29)
#define RX_CUT_THRU_EN BIT(30)
#define RXQ_CTRL_EN BIT(31)
#define REG_RFD_FREE_THRESH 0x15A4
#define RFD_FREE_THRESH_MASK 0x003F
#define RFD_FREE_HI_THRESH_SHIFT 0
#define RFD_FREE_LO_THRESH_SHIFT 6
/* RXF flow control register */
#define REG_RXQ_RXF_PAUSE_THRESH 0x15A8
#define RXQ_RXF_PAUSE_TH_HI_SHIFT 0
#define RXQ_RXF_PAUSE_TH_HI_MASK 0x0FFF
#define RXQ_RXF_PAUSE_TH_LO_SHIFT 16
#define RXQ_RXF_PAUSE_TH_LO_MASK 0x0FFF
#define REG_RXD_DMA_CTRL 0x15AC
#define RXD_DMA_THRESH_MASK 0x0FFF /* In 8-bytes */
#define RXD_DMA_THRESH_SHIFT 0
#define RXD_DMA_DOWN_TIMER_MASK 0xFFFF
#define RXD_DMA_DOWN_TIMER_SHIFT 16
/* DMA Engine Control Register */
#define REG_DMA_CTRL 0x15C0
#define DMA_CTRL_SMB_NOW BIT(31)
#define DMA_CTRL_WPEND_CLR BIT(30)
#define DMA_CTRL_RPEND_CLR BIT(29)
#define DMA_CTRL_WDLY_CNT_MASK 0xFUL
#define DMA_CTRL_WDLY_CNT_SHIFT 16
#define DMA_CTRL_WDLY_CNT_DEF 4
#define DMA_CTRL_RDLY_CNT_MASK 0x1FUL
#define DMA_CTRL_RDLY_CNT_SHIFT 11
#define DMA_CTRL_RDLY_CNT_DEF 15
#define DMA_CTRL_RREQ_PRI_DATA BIT(10) /* 0:tpd, 1:data */
#define DMA_CTRL_WREQ_BLEN_MASK 7UL
#define DMA_CTRL_WREQ_BLEN_SHIFT 7
#define DMA_CTRL_RREQ_BLEN_MASK 7UL
#define DMA_CTRL_RREQ_BLEN_SHIFT 4
#define L1C_CTRL_DMA_RCB_LEN128 BIT(3) /* 0:64bytes,1:128bytes */
#define DMA_CTRL_RORDER_MODE_MASK 7UL
#define DMA_CTRL_RORDER_MODE_SHIFT 0
#define DMA_CTRL_RORDER_MODE_OUT 4
#define DMA_CTRL_RORDER_MODE_ENHANCE 2
#define DMA_CTRL_RORDER_MODE_IN 1
/* INT-triggle/SMB Control Register */
#define REG_SMB_STAT_TIMER 0x15C4 /* 2us resolution */
#define SMB_STAT_TIMER_MASK 0xFFFFFF
#define REG_TINT_TPD_THRESH 0x15C8 /* tpd th to trig intrrupt */
/* Mail box */
#define MB_RFDX_PROD_IDX_MASK 0xFFFF
#define REG_MB_RFD0_PROD_IDX 0x15E0
#define REG_TPD_PRI1_PIDX 0x15F0 /* 16bit,hi-tpd producer idx */
#define REG_TPD_PRI0_PIDX 0x15F2 /* 16bit,lo-tpd producer idx */
#define REG_TPD_PRI1_CIDX 0x15F4 /* 16bit,hi-tpd consumer idx */
#define REG_TPD_PRI0_CIDX 0x15F6 /* 16bit,lo-tpd consumer idx */
#define REG_MB_RFD01_CONS_IDX 0x15F8
#define MB_RFD0_CONS_IDX_MASK 0x0000FFFF
#define MB_RFD1_CONS_IDX_MASK 0xFFFF0000
/* Interrupt Status Register */
#define REG_ISR 0x1600
#define ISR_SMB 0x00000001
#define ISR_TIMER 0x00000002
/*
* Software manual interrupt, for debug. Set when SW_MAN_INT_EN is set
* in Table 51 Selene Master Control Register (Offset 0x1400).
*/
#define ISR_MANUAL 0x00000004
#define ISR_HW_RXF_OV 0x00000008 /* RXF overflow interrupt */
#define ISR_RFD0_UR 0x00000010 /* RFD0 under run */
#define ISR_RFD1_UR 0x00000020
#define ISR_RFD2_UR 0x00000040
#define ISR_RFD3_UR 0x00000080
#define ISR_TXF_UR 0x00000100
#define ISR_DMAR_TO_RST 0x00000200
#define ISR_DMAW_TO_RST 0x00000400
#define ISR_TX_CREDIT 0x00000800
#define ISR_GPHY 0x00001000
/* GPHY low power state interrupt */
#define ISR_GPHY_LPW 0x00002000
#define ISR_TXQ_TO_RST 0x00004000
#define ISR_TX_PKT 0x00008000
#define ISR_RX_PKT_0 0x00010000
#define ISR_RX_PKT_1 0x00020000
#define ISR_RX_PKT_2 0x00040000
#define ISR_RX_PKT_3 0x00080000
#define ISR_MAC_RX 0x00100000
#define ISR_MAC_TX 0x00200000
#define ISR_UR_DETECTED 0x00400000
#define ISR_FERR_DETECTED 0x00800000
#define ISR_NFERR_DETECTED 0x01000000
#define ISR_CERR_DETECTED 0x02000000
#define ISR_PHY_LINKDOWN 0x04000000
#define ISR_DIS_INT 0x80000000
/* Interrupt Mask Register */
#define REG_IMR 0x1604
#define IMR_NORMAL_MASK (\
ISR_MANUAL |\
ISR_HW_RXF_OV |\
ISR_RFD0_UR |\
ISR_TXF_UR |\
ISR_DMAR_TO_RST |\
ISR_TXQ_TO_RST |\
ISR_DMAW_TO_RST |\
ISR_GPHY |\
ISR_TX_PKT |\
ISR_RX_PKT_0 |\
ISR_GPHY_LPW |\
ISR_PHY_LINKDOWN)
#define ISR_RX_PKT (\
ISR_RX_PKT_0 |\
ISR_RX_PKT_1 |\
ISR_RX_PKT_2 |\
ISR_RX_PKT_3)
#define ISR_OVER (\
ISR_RFD0_UR |\
ISR_RFD1_UR |\
ISR_RFD2_UR |\
ISR_RFD3_UR |\
ISR_HW_RXF_OV |\
ISR_TXF_UR)
#define ISR_ERROR (\
ISR_DMAR_TO_RST |\
ISR_TXQ_TO_RST |\
ISR_DMAW_TO_RST |\
ISR_PHY_LINKDOWN)
#define REG_INT_RETRIG_TIMER 0x1608
#define INT_RETRIG_TIMER_MASK 0xFFFF
#define REG_MAC_RX_STATUS_BIN 0x1700
#define REG_MAC_RX_STATUS_END 0x175c
#define REG_MAC_TX_STATUS_BIN 0x1760
#define REG_MAC_TX_STATUS_END 0x17c0
#define REG_CLK_GATING_CTRL 0x1814
#define CLK_GATING_DMAW_EN 0x0001
#define CLK_GATING_DMAR_EN 0x0002
#define CLK_GATING_TXQ_EN 0x0004
#define CLK_GATING_RXQ_EN 0x0008
#define CLK_GATING_TXMAC_EN 0x0010
#define CLK_GATING_RXMAC_EN 0x0020
#define CLK_GATING_EN_ALL (CLK_GATING_DMAW_EN |\
CLK_GATING_DMAR_EN |\
CLK_GATING_TXQ_EN |\
CLK_GATING_RXQ_EN |\
CLK_GATING_TXMAC_EN|\
CLK_GATING_RXMAC_EN)
/* DEBUG ADDR */
#define REG_DEBUG_DATA0 0x1900
#define REG_DEBUG_DATA1 0x1904
#define L1D_MPW_PHYID1 0xD01C /* V7 */
#define L1D_MPW_PHYID2 0xD01D /* V1-V6 */
#define L1D_MPW_PHYID3 0xD01E /* V8 */
/* Autoneg Advertisement Register */
#define ADVERTISE_DEFAULT_CAP \
(ADVERTISE_ALL | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM)
/* 1000BASE-T Control Register */
#define GIGA_CR_1000T_REPEATER_DTE 0x0400 /* 1=Repeater/switch device port 0=DTE device */
#define GIGA_CR_1000T_MS_VALUE 0x0800 /* 1=Configure PHY as Master 0=Configure PHY as Slave */
#define GIGA_CR_1000T_MS_ENABLE 0x1000 /* 1=Master/Slave manual config value 0=Automatic Master/Slave config */
#define GIGA_CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
#define GIGA_CR_1000T_TEST_MODE_1 0x2000 /* Transmit Waveform test */
#define GIGA_CR_1000T_TEST_MODE_2 0x4000 /* Master Transmit Jitter test */
#define GIGA_CR_1000T_TEST_MODE_3 0x6000 /* Slave Transmit Jitter test */
#define GIGA_CR_1000T_TEST_MODE_4 0x8000 /* Transmitter Distortion test */
#define GIGA_CR_1000T_SPEED_MASK 0x0300
#define GIGA_CR_1000T_DEFAULT_CAP 0x0300
/* PHY Specific Status Register */
#define MII_GIGA_PSSR 0x11
#define GIGA_PSSR_SPD_DPLX_RESOLVED 0x0800 /* 1=Speed & Duplex resolved */
#define GIGA_PSSR_DPLX 0x2000 /* 1=Duplex 0=Half Duplex */
#define GIGA_PSSR_SPEED 0xC000 /* Speed, bits 14:15 */
#define GIGA_PSSR_10MBS 0x0000 /* 00=10Mbs */
#define GIGA_PSSR_100MBS 0x4000 /* 01=100Mbs */
#define GIGA_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
/* PHY Interrupt Enable Register */
#define MII_IER 0x12
#define IER_LINK_UP 0x0400
#define IER_LINK_DOWN 0x0800
/* PHY Interrupt Status Register */
#define MII_ISR 0x13
#define ISR_LINK_UP 0x0400
#define ISR_LINK_DOWN 0x0800
/* Cable-Detect-Test Control Register */
#define MII_CDTC 0x16
#define CDTC_EN_OFF 0 /* sc */
#define CDTC_EN_BITS 1
#define CDTC_PAIR_OFF 8
#define CDTC_PAIR_BIT 2
/* Cable-Detect-Test Status Register */
#define MII_CDTS 0x1C
#define CDTS_STATUS_OFF 8
#define CDTS_STATUS_BITS 2
#define CDTS_STATUS_NORMAL 0
#define CDTS_STATUS_SHORT 1
#define CDTS_STATUS_OPEN 2
#define CDTS_STATUS_INVALID 3
#define MII_DBG_ADDR 0x1D
#define MII_DBG_DATA 0x1E
/***************************** debug port *************************************/
#define MIIDBG_ANACTRL 0x00
#define ANACTRL_CLK125M_DELAY_EN 0x8000
#define ANACTRL_VCO_FAST 0x4000
#define ANACTRL_VCO_SLOW 0x2000
#define ANACTRL_AFE_MODE_EN 0x1000
#define ANACTRL_LCKDET_PHY 0x800
#define ANACTRL_LCKDET_EN 0x400
#define ANACTRL_OEN_125M 0x200
#define ANACTRL_HBIAS_EN 0x100
#define ANACTRL_HB_EN 0x80
#define ANACTRL_SEL_HSP 0x40
#define ANACTRL_CLASSA_EN 0x20
#define ANACTRL_MANUSWON_SWR_MASK 3U
#define ANACTRL_MANUSWON_SWR_SHIFT 2
#define ANACTRL_MANUSWON_SWR_2V 0
#define ANACTRL_MANUSWON_SWR_1P9V 1
#define ANACTRL_MANUSWON_SWR_1P8V 2
#define ANACTRL_MANUSWON_SWR_1P7V 3
#define ANACTRL_MANUSWON_BW3_4M 0x2
#define ANACTRL_RESTART_CAL 0x1
#define ANACTRL_DEF 0x02EF
#define MIIDBG_SYSMODCTRL 0x04
#define SYSMODCTRL_IECHOADJ_PFMH_PHY 0x8000
#define SYSMODCTRL_IECHOADJ_BIASGEN 0x4000
#define SYSMODCTRL_IECHOADJ_PFML_PHY 0x2000
#define SYSMODCTRL_IECHOADJ_PS_MASK 3U
#define SYSMODCTRL_IECHOADJ_PS_SHIFT 10
#define SYSMODCTRL_IECHOADJ_PS_40 3
#define SYSMODCTRL_IECHOADJ_PS_20 2
#define SYSMODCTRL_IECHOADJ_PS_0 1
#define SYSMODCTRL_IECHOADJ_10BT_100MV 0x40 /* 1:100mv, 0:200mv */
#define SYSMODCTRL_IECHOADJ_HLFAP_MASK 3U
#define SYSMODCTRL_IECHOADJ_HLFAP_SHIFT 4
#define SYSMODCTRL_IECHOADJ_VDFULBW 0x8
#define SYSMODCTRL_IECHOADJ_VDBIASHLF 0x4
#define SYSMODCTRL_IECHOADJ_VDAMPHLF 0x2
#define SYSMODCTRL_IECHOADJ_VDLANSW 0x1
#define SYSMODCTRL_IECHOADJ_DEF 0x88BB /* ???? */
/* for l1d & l2cb */
#define SYSMODCTRL_IECHOADJ_CUR_ADD 0x8000
#define SYSMODCTRL_IECHOADJ_CUR_MASK 7U
#define SYSMODCTRL_IECHOADJ_CUR_SHIFT 12
#define SYSMODCTRL_IECHOADJ_VOL_MASK 0xFU
#define SYSMODCTRL_IECHOADJ_VOL_SHIFT 8
#define SYSMODCTRL_IECHOADJ_VOL_17ALL 3
#define SYSMODCTRL_IECHOADJ_VOL_100M15 1
#define SYSMODCTRL_IECHOADJ_VOL_10M17 0
#define SYSMODCTRL_IECHOADJ_BIAS1_MASK 0xFU
#define SYSMODCTRL_IECHOADJ_BIAS1_SHIFT 4
#define SYSMODCTRL_IECHOADJ_BIAS2_MASK 0xFU
#define SYSMODCTRL_IECHOADJ_BIAS2_SHIFT 0
#define L1D_SYSMODCTRL_IECHOADJ_DEF 0x4FBB
#define MIIDBG_SRDSYSMOD 0x05
#define SRDSYSMOD_LCKDET_EN 0x2000
#define SRDSYSMOD_PLL_EN 0x800
#define SRDSYSMOD_SEL_HSP 0x400
#define SRDSYSMOD_HLFTXDR 0x200
#define SRDSYSMOD_TXCLK_DELAY_EN 0x100
#define SRDSYSMOD_TXELECIDLE 0x80
#define SRDSYSMOD_DEEMP_EN 0x40
#define SRDSYSMOD_MS_PAD 0x4
#define SRDSYSMOD_CDR_ADC_VLTG 0x2
#define SRDSYSMOD_CDR_DAC_1MA 0x1
#define SRDSYSMOD_DEF 0x2C46
#define MIIDBG_CFGLPSPD 0x0A
#define CFGLPSPD_RSTCNT_MASK 3U
#define CFGLPSPD_RSTCNT_SHIFT 14
#define CFGLPSPD_RSTCNT_CLK125SW 0x2000
#define MIIDBG_HIBNEG 0x0B
#define HIBNEG_PSHIB_EN 0x8000
#define HIBNEG_WAKE_BOTH 0x4000
#define HIBNEG_ONOFF_ANACHG_SUDEN 0x2000
#define HIBNEG_HIB_PULSE 0x1000
#define HIBNEG_GATE_25M_EN 0x800
#define HIBNEG_RST_80U 0x400
#define HIBNEG_RST_TIMER_MASK 3U
#define HIBNEG_RST_TIMER_SHIFT 8
#define HIBNEG_GTX_CLK_DELAY_MASK 3U
#define HIBNEG_GTX_CLK_DELAY_SHIFT 5
#define HIBNEG_BYPSS_BRKTIMER 0x10
#define HIBNEG_DEF 0xBC40
#define MIIDBG_TST10BTCFG 0x12
#define TST10BTCFG_INTV_TIMER_MASK 3U
#define TST10BTCFG_INTV_TIMER_SHIFT 14
#define TST10BTCFG_TRIGER_TIMER_MASK 3U
#define TST10BTCFG_TRIGER_TIMER_SHIFT 12
#define TST10BTCFG_DIV_MAN_MLT3_EN 0x800
#define TST10BTCFG_OFF_DAC_IDLE 0x400
#define TST10BTCFG_LPBK_DEEP 0x4 /* 1:deep,0:shallow */
#define TST10BTCFG_DEF 0x4C04
#define MIIDBG_AZ_ANADECT 0x15
#define AZ_ANADECT_10BTRX_TH 0x8000
#define AZ_ANADECT_BOTH_01CHNL 0x4000
#define AZ_ANADECT_INTV_MASK 0x3FU
#define AZ_ANADECT_INTV_SHIFT 8
#define AZ_ANADECT_THRESH_MASK 0xFU
#define AZ_ANADECT_THRESH_SHIFT 4
#define AZ_ANADECT_CHNL_MASK 0xFU
#define AZ_ANADECT_CHNL_SHIFT 0
#define AZ_ANADECT_DEF 0x3220
#define AZ_ANADECT_LONG 0xb210
#define MIIDBG_MSE16DB 0x18 /* l1d */
#define L1D_MSE16DB_UP 0x05EA
#define L1D_MSE16DB_DOWN 0x02EA
#define MIIDBG_LEGCYPS 0x29
#define LEGCYPS_EN 0x8000
#define LEGCYPS_DAC_AMP1000_MASK 7U
#define LEGCYPS_DAC_AMP1000_SHIFT 12
#define LEGCYPS_DAC_AMP100_MASK 7U
#define LEGCYPS_DAC_AMP100_SHIFT 9
#define LEGCYPS_DAC_AMP10_MASK 7U
#define LEGCYPS_DAC_AMP10_SHIFT 6
#define LEGCYPS_UNPLUG_TIMER_MASK 7U
#define LEGCYPS_UNPLUG_TIMER_SHIFT 3
#define LEGCYPS_UNPLUG_DECT_EN 0x4
#define LEGCYPS_ECNC_PS_EN 0x1
#define L1D_LEGCYPS_DEF 0x129D
#define L1C_LEGCYPS_DEF 0x36DD
#define MIIDBG_TST100BTCFG 0x36
#define TST100BTCFG_NORMAL_BW_EN 0x8000
#define TST100BTCFG_BADLNK_BYPASS 0x4000
#define TST100BTCFG_SHORTCABL_TH_MASK 0x3FU
#define TST100BTCFG_SHORTCABL_TH_SHIFT 8
#define TST100BTCFG_LITCH_EN 0x80
#define TST100BTCFG_VLT_SW 0x40
#define TST100BTCFG_LONGCABL_TH_MASK 0x3FU
#define TST100BTCFG_LONGCABL_TH_SHIFT 0
#define TST100BTCFG_DEF 0xE12C
#define MIIDBG_VOLT_CTRL 0x3B /* only for l2cb 1 & 2 */
#define VOLT_CTRL_CABLE1TH_MASK 0x1FFU
#define VOLT_CTRL_CABLE1TH_SHIFT 7
#define VOLT_CTRL_AMPCTRL_MASK 3U
#define VOLT_CTRL_AMPCTRL_SHIFT 5
#define VOLT_CTRL_SW_BYPASS 0x10
#define VOLT_CTRL_SWLOWEST 0x8
#define VOLT_CTRL_DACAMP10_MASK 7U
#define VOLT_CTRL_DACAMP10_SHIFT 0
#define MIIDBG_CABLE1TH_DET 0x3E
#define CABLE1TH_DET_EN 0x8000
/******* dev 3 *********/
#define MIIEXT_PCS 3
#define MIIEXT_CLDCTRL3 0x8003
#define CLDCTRL3_BP_CABLE1TH_DET_GT 0x8000
#define CLDCTRL3_AZ_DISAMP 0x1000
#define L2CB_CLDCTRL3 0x4D19
#define L1D_CLDCTRL3 0xDD19
#define MIIEXT_CLDCTRL6 0x8006
#define CLDCTRL6_CAB_LEN_MASK 0x1FFU
#define CLDCTRL6_CAB_LEN_SHIFT 0
#define CLDCTRL6_CAB_LEN_SHORT 0x50
/********* dev 7 **********/
#define MIIEXT_ANEG 7
#define MIIEXT_LOCAL_EEEADV 0x3C
#define LOCAL_EEEADV_1000BT 0x4
#define LOCAL_EEEADV_100BT 0x2
#define MIIEXT_REMOTE_EEEADV 0x3D
#define REMOTE_EEEADV_1000BT 0x4
#define REMOTE_EEEADV_100BT 0x2
#define MIIEXT_EEE_ANEG 0x8000
#define EEE_ANEG_1000M 0x4
#define EEE_ANEG_100M 0x2
#endif /*_ATL1C_HW_H_*/
|
3bb5113e38cbdf12e86036db8372d8146188c22a
|
6a9c13837bcf73fa64d1974eb3ae383aace3cf37
|
/tests/smoke/blt_hip_runtime_c_smoke.c
|
16519e34119e16fe6a6a3fdaa6ba5d6d1cbb5d56
|
[
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
LLNL/blt
|
93fb69ddf7fe86bbc1a3c975d4b36f70dbf0fec9
|
d57f7995ff8299e4612e74ec94e35eacde93cf40
|
refs/heads/develop
| 2023-09-06T07:51:57.666876
| 2023-08-23T22:23:17
| 2023-08-23T22:23:17
| 83,483,519
| 228
| 66
|
BSD-3-Clause
| 2023-08-23T22:23:19
| 2017-02-28T21:59:28
|
C++
|
UTF-8
|
C
| false
| false
| 1,003
|
c
|
blt_hip_runtime_c_smoke.c
|
// Copyright (c) 2017-2023, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level LICENSE file for details
//
// SPDX-License-Identifier: (BSD-3-Clause)
//-----------------------------------------------------------------------------
//
// file: blt_hip_runtime_c_smoke.c
//
//-----------------------------------------------------------------------------
#include <stdio.h>
#include "hip/hip_runtime_api.h"
int main()
{
int nDevices;
hipGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++)
{
hipDeviceProp_t prop;
hipGetDeviceProperties(&prop, i);
printf("Device Number: %d\n", i);
printf(" Device name: %s\n", prop.name);
printf(" Memory Clock Rate (KHz): %d\n",
prop.memoryClockRate);
printf(" Memory Bus Width (bits): %d\n",
prop.memoryBusWidth);
printf(" Peak Memory Bandwidth (GB/s): %f\n\n",
2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
}
return 0;
}
|
765e221feaa3f13a77716b3210142206e2888b55
|
03b2c80dbc41e904b167d504666e27d798da5447
|
/test/test_bit.c
|
da0defb0e5e4d4781863f94b68f88c3ff20e9873
|
[
"Unlicense"
] |
permissive
|
nptcl/npt
|
7c1570b497cdce0b8971cb445fbc04cb500232d3
|
aa714a2370ac9fa5348c2fc96159b40b9de3de07
|
refs/heads/master
| 2023-03-20T09:13:54.669118
| 2022-07-02T11:17:44
| 2022-07-02T11:17:44
| 171,985,905
| 160
| 12
|
Unlicense
| 2023-03-11T01:36:37
| 2019-02-22T03:11:34
|
C
|
UTF-8
|
C
| false
| false
| 21,855
|
c
|
test_bit.c
|
#include "bit.c"
#include "character.h"
#include "clos.h"
#include "common.h"
#include "cons.h"
#include "constant.h"
#include "degrade.h"
#include "object.h"
#include "package.h"
#include "reader.h"
#include "stream.h"
#include "symbol.h"
#include "syscall.h"
#include "type.h"
#include "type_table.h"
static int test_bitp(void)
{
test(bitp(fixnumh(0)), "bitp1");
test(bitp(fixnumh(1)), "bitp2");
test(! bitp(fixnumh(2)), "bitp3");
test(! bitp(fixnumh(-1)), "bitp4");
test(! bitp(fixnumh(10)), "bitp5");
test(! bitp(T), "bitp6");
RETURN;
}
static int test_bit_getint(void)
{
int value;
value = 999;
test(! bit_getint(fixnumh(0), &value), "bit_getint1");
test(value == 0, "bit_getint2");
test(! bit_getint(fixnumh(1), &value), "bit_getint3");
test(value == 1, "bit_getint4");
value = 999;
test(bit_getint(fixnumh(2), &value), "bit_getint5");
test(value == 999, "bit_getint6");
test(bit_getint(fixnumh(-1), &value), "bit_getint7");
test(bit_getint(fixnumh(10), &value), "bit_getint8");
test(bit_getint(T, &value), "bit_getint9");
RETURN;
}
/*
* bitcons
*/
static int test_bitbuffer_local(void)
{
addr pos;
LocalRoot local;
LocalStack stack;
struct bitbuffer_struct *str;
size_t size, check;
local = Local_Thread;
push_local(local, &stack);
bitbuffer_local(local, &pos, 10);
test(GetType(pos) == LISPSYSTEM_BITBUFFER, "bitbuffer_local1");
str = BitBufferStruct(pos);
test(str->index == 0, "bitbuffer_local2");
test(str->array == 0, "bitbuffer_local3");
test(str->data[0] == 0, "bitbuffer_local4");
test(str->data[9] == 0, "bitbuffer_local5");
size = lenbodyr(pos);
check = sizeoft(struct bitbuffer_struct) + sizeoft(fixed) * 10UL;
test(size == check, "bitbuffer_local6");
GetBitBuffer(pos, &pos);
test(pos == Nil, "bitbuffer_local7");
rollback_local(local, stack);
RETURN;
}
static int test_getfixedsize(void)
{
test(getfixedsize(0) == 0, "getfixedsize1");
test(getfixedsize(1) == 1, "getfixedsize2");
test(getfixedsize(2) == 1, "getfixedsize3");
test(getfixedsize(8*sizeoft(fixed) - 1) == 1, "getfixedsize4");
test(getfixedsize(8*sizeoft(fixed) + 0) == 1, "getfixedsize5");
test(getfixedsize(8*sizeoft(fixed) + 1) == 2, "getfixedsize6");
test(getfixedsize(8*sizeoft(fixed) + 2) == 2, "getfixedsize7");
test(getfixedsize(2*8*sizeoft(fixed) - 1) == 2, "getfixedsize8");
test(getfixedsize(2*8*sizeoft(fixed) + 0) == 2, "getfixedsize9");
test(getfixedsize(2*8*sizeoft(fixed) + 1) == 3, "getfixedsize10");
test(getfixedsize(2*8*sizeoft(fixed) + 2) == 3, "getfixedsize11");
RETURN;
}
static int test_bitcons_local(void)
{
addr pos, check;
LocalRoot local;
LocalStack stack;
struct bitcons_struct *str;
local = Local_Thread;
push_local(local, &stack);
bitcons_local(local, &pos, 3);
test(GetType(pos) == LISPSYSTEM_BITCONS, "bitcons_local1");
str = BitConsStruct(pos);
test(str->bitsize == sizeoft(fixed) * 8UL, "bitcons_local2");
test(str->fixedsize == 1, "bitcons_local3");
test(str->index == 0, "bitcons_local4");
GetBitConsRoot(pos, &check);
test(GetType(check) == LISPSYSTEM_BITBUFFER, "bitcons_local5");
GetBitConsTail(pos, &pos);
test(pos == check, "bitcons_local6");
rollback_local(local, stack);
RETURN;
}
static int test_pushnext_bitcons(void)
{
addr pos, check, next;
LocalRoot local;
LocalStack stack;
struct bitbuffer_struct *str;
local = Local_Thread;
push_local(local, &stack);
bitcons_local(local, &pos, 5);
pushnext_bitcons(local, pos, &next);
GetBitConsRoot(pos, &check);
test(check == next, "pushnext_bitcons1");
str = BitBufferStruct(next);
str->index = 8UL * sizeoft(fixed) - 1UL;
pushnext_bitcons(local, pos, &next);
GetBitConsRoot(pos, &check);
test(check == next, "pushnext_bitcons2");
str = BitBufferStruct(next);
str->index = 8UL * sizeoft(fixed);
pushnext_bitcons(local, pos, &next);
GetBitConsRoot(pos, &check);
test(check != next, "pushnext_bitcons3");
GetBitConsTail(pos, &check);
test(check == next, "pushnext_bitcons4");
rollback_local(local, stack);
RETURN;
}
static int test_push_bitcons(void)
{
addr pos, next;
LocalRoot local;
LocalStack stack;
struct bitbuffer_struct *str;
local = Local_Thread;
push_local(local, &stack);
bitcons_local(local, &pos, 1);
push_bitcons(local, pos, 1);
GetBitConsTail(pos, &next);
str = BitBufferStruct(next);
test(str->data[0], "push_bitcons1");
rollback_local(local, stack);
RETURN;
}
/*
* bitmemory
*/
static int test_bitmemory_unsafe(void)
{
addr pos;
LocalRoot local;
LocalStack stack;
struct bitmemory_struct *str;
local = Local_Thread;
push_local(local, &stack);
bitmemory_unsafe(local, &pos, 9999);
test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_unsafe1");
test(GetStatusDynamic(pos), "bitmemory_unsafe2");
str = BitMemoryStruct(pos);
test(str->bitsize == 9999, "bitmemory_unsafe3");
test(str->fixedsize == getfixedsize(9999), "bitmemory_unsafe4");
rollback_local(local, stack);
RETURN;
}
static int test_bitmemory_alloc(void)
{
addr pos;
struct bitmemory_struct *str;
bitmemory_alloc(NULL, &pos, 9999);
test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_alloc1");
test(! GetStatusDynamic(pos), "bitmemory_alloc2");
str = BitMemoryStruct(pos);
test(str->bitsize == 9999, "bitmemory_alloc3");
test(str->fixedsize == getfixedsize(9999), "bitmemory_alloc4");
test(str->data[0] == 0, "bitmemory_alloc5");
test(str->data[1] == 0, "bitmemory_alloc6");
RETURN;
}
static int test_bitmemory_local(void)
{
addr pos;
LocalRoot local;
LocalStack stack;
local = Local_Thread;
push_local(local, &stack);
bitmemory_local(local, &pos, 9999);
test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_local1");
test(GetStatusDynamic(pos), "bitmemory_local2");
rollback_local(local, stack);
RETURN;
}
static int test_bitmemory_heap(void)
{
addr pos;
bitmemory_heap(&pos, 9999);
test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_heap1");
test(! GetStatusDynamic(pos), "bitmemory_heap2");
RETURN;
}
static int test_bitcheck(struct bitmemory_struct *str, unsigned index, unsigned bit)
{
return (str->data[index] >> bit) & 1;
}
static int test_bitmemory_cons_alloc(void)
{
int i;
addr cons, pos;
LocalRoot local;
LocalStack stack;
struct bitmemory_struct *str;
local = Local_Thread;
push_local(local, &stack);
bitcons_local(local, &cons, 0);
for (i = 0; i < 99; i++) {
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 0);
push_bitcons(local, cons, 0);
push_bitcons(local, cons, 0);
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 1);
}
bitmemory_cons_alloc(local, &pos, cons);
test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_cons_alloc1");
test(GetStatusDynamic(pos), "bitmemory_cons_alloc2");
str = BitMemoryStruct(pos);
test(str->bitsize == 8*99, "bitmemory_cons_alloc3");
test(str->fixedsize == getfixedsize(8*99), "bitmemory_cons_alloc4");
test( test_bitcheck(str, 0, 0), "bitmemory_cons_alloc5");
test( test_bitcheck(str, 0, 1), "bitmemory_cons_alloc6");
test( test_bitcheck(str, 0, 2), "bitmemory_cons_alloc7");
test(! test_bitcheck(str, 0, 3), "bitmemory_cons_alloc8");
test(! test_bitcheck(str, 0, 4), "bitmemory_cons_alloc9");
test(! test_bitcheck(str, 0, 5), "bitmemory_cons_alloc10");
test( test_bitcheck(str, 0, 6), "bitmemory_cons_alloc11");
test( test_bitcheck(str, 1, 0), "bitmemory_cons_alloc12");
test( test_bitcheck(str, 1, 1), "bitmemory_cons_alloc13");
test( test_bitcheck(str, 1, 2), "bitmemory_cons_alloc14");
test(! test_bitcheck(str, 1, 3), "bitmemory_cons_alloc15");
test(! test_bitcheck(str, 1, 4), "bitmemory_cons_alloc16");
test(! test_bitcheck(str, 1, 5), "bitmemory_cons_alloc17");
test( test_bitcheck(str, 1, 6), "bitmemory_cons_alloc18");
rollback_local(local, stack);
RETURN;
}
static int test_bitmemory_cons_local(void)
{
addr cons, pos;
LocalRoot local;
LocalStack stack;
struct bitmemory_struct *str;
local = Local_Thread;
push_local(local, &stack);
bitcons_local(local, &cons, 0);
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 0);
bitmemory_cons_local(local, &pos, cons);
test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_cons_local1");
test(GetStatusDynamic(pos), "bitmemory_cons_local2");
str = BitMemoryStruct(pos);
test( test_bitcheck(str, 0, 0), "bitmemory_cons_local3");
test( test_bitcheck(str, 0, 1), "bitmemory_cons_local4");
test(! test_bitcheck(str, 0, 2), "bitmemory_cons_local5");
rollback_local(local, stack);
RETURN;
}
static int test_bitmemory_cons_heap(void)
{
addr cons, pos;
LocalRoot local;
LocalStack stack;
struct bitmemory_struct *str;
local = Local_Thread;
push_local(local, &stack);
bitcons_local(local, &cons, 0);
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 1);
push_bitcons(local, cons, 0);
bitmemory_cons_heap(&pos, cons);
test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_cons_heap1");
test(! GetStatusDynamic(pos), "bitmemory_cons_heap2");
str = BitMemoryStruct(pos);
test( test_bitcheck(str, 0, 0), "bitmemory_cons_heap3");
test( test_bitcheck(str, 0, 1), "bitmemory_cons_heap4");
test(! test_bitcheck(str, 0, 2), "bitmemory_cons_heap5");
rollback_local(local, stack);
RETURN;
}
static int test_bitmemoryp(void)
{
addr pos;
bitmemory_heap(&pos, 10);
test(bitmemoryp(pos), "bitmemoryp1");
test(! bitmemoryp(Nil), "bitmemoryp2");
RETURN;
}
static int test_bitmemory_memset_byte(void)
{
addr pos;
bitmemory_heap(&pos, 256);
bitmemory_memset_byte(pos, 0xA0);
test(! bitmemory_refint_debug(pos, 0), "bitmemory_memset_byte1");
test(! bitmemory_refint_debug(pos, 1), "bitmemory_memset_byte2");
test(! bitmemory_refint_debug(pos, 2), "bitmemory_memset_byte3");
test(! bitmemory_refint_debug(pos, 3), "bitmemory_memset_byte4");
test(! bitmemory_refint_debug(pos, 4), "bitmemory_memset_byte5");
test( bitmemory_refint_debug(pos, 5), "bitmemory_memset_byte6");
test(! bitmemory_refint_debug(pos, 6), "bitmemory_memset_byte7");
test( bitmemory_refint_debug(pos, 7), "bitmemory_memset_byte8");
test(! bitmemory_refint_debug(pos, 64+0), "bitmemory_memset_byte9");
test(! bitmemory_refint_debug(pos, 64+1), "bitmemory_memset_byte10");
test(! bitmemory_refint_debug(pos, 64+2), "bitmemory_memset_byte11");
test(! bitmemory_refint_debug(pos, 64+3), "bitmemory_memset_byte12");
test(! bitmemory_refint_debug(pos, 64+4), "bitmemory_memset_byte13");
test( bitmemory_refint_debug(pos, 64+5), "bitmemory_memset_byte14");
test(! bitmemory_refint_debug(pos, 64+6), "bitmemory_memset_byte15");
test( bitmemory_refint_debug(pos, 64+7), "bitmemory_memset_byte16");
RETURN;
}
static int test_bitmemory_memset(void)
{
addr pos;
bitmemory_heap(&pos, 256);
bitmemory_memset(pos, 0);
test(! bitmemory_refint_debug(pos, 0), "bitmemory_memset1");
test(! bitmemory_refint_debug(pos, 66), "bitmemory_memset2");
bitmemory_memset(pos, 0);
test(! bitmemory_refint_debug(pos, 1), "bitmemory_memset3");
test(! bitmemory_refint_debug(pos, 67), "bitmemory_memset4");
RETURN;
}
static int test_bitmemory_copy_unsafe(void)
{
int i, n;
addr a, b;
bitmemory_heap(&a, 100);
for (i = n = 0; i < 10; i++) {
bitmemory_setint_(a, n++, 1);
bitmemory_setint_(a, n++, 1);
bitmemory_setint_(a, n++, 0);
bitmemory_setint_(a, n++, 0);
bitmemory_setint_(a, n++, 1);
}
bitmemory_heap(&b, 100);
bitmemory_copy_unsafe(b, a, 100);
test(bitmemory_equal(a, b), "bitmemory_copy_unsafe1");
RETURN;
}
static int test_bitmemory_length(void)
{
addr pos;
size_t size;
bitmemory_heap(&pos, 55);
bitmemory_length(pos, &size);
test(size == 55, "bitmemory_length1");
RETURN;
}
static int test_bitmemory_equal(void)
{
addr pos1, pos2;
bitmemory_char_heap(&pos1, "1011");
bitmemory_char_heap(&pos2, "1011");
test(bitmemory_equal(pos1, pos2), "bitmemory_equal1");
bitmemory_char_heap(&pos1, "1101");
bitmemory_char_heap(&pos2, "1011");
test(! bitmemory_equal(pos1, pos2), "bitmemory_equal2");
bitmemory_char_heap(&pos1, "10110");
bitmemory_char_heap(&pos2, "1011");
test(! bitmemory_equal(pos1, pos2), "bitmemory_equal3");
bitmemory_char_heap(&pos1, "1011");
bitmemory_char_heap(&pos2, "10110");
test(! bitmemory_equal(pos1, pos2), "bitmemory_equal4");
bitmemory_char_heap(&pos1,
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111");
bitmemory_char_heap(&pos2,
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111");
test(bitmemory_equal(pos1, pos2), "bitmemory_equal5");
bitmemory_char_heap(&pos1,
"10010111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111");
bitmemory_char_heap(&pos2,
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111");
test(! bitmemory_equal(pos1, pos2), "bitmemory_equal6");
bitmemory_char_heap(&pos1,
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111");
bitmemory_char_heap(&pos2,
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110101");
test(! bitmemory_equal(pos1, pos2), "bitmemory_equal7");
RETURN;
}
static int test_bitmemory_getint(void)
{
int check;
addr pos;
bitmemory_char_heap(&pos,
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110101");
bitmemory_getint_(pos, 0, &check);
test(check, "bitmemory_getint1");
bitmemory_getint_(pos, 1, &check);
test(! check, "bitmemory_getint2");
bitmemory_getint_(pos, 2, &check);
test(check, "bitmemory_getint3");
bitmemory_getint_(pos, 3, &check);
test(check, "bitmemory_getint4");
bitmemory_getint_(pos, 65-1, &check);
test(check, "bitmemory_getint5");
bitmemory_getint_(pos, 65+0, &check);
test(check, "bitmemory_getint6");
bitmemory_getint_(pos, 65+1, &check);
test(! check, "bitmemory_getint7");
bitmemory_getint_(pos, 65+2, &check);
test(check, "bitmemory_getint8");
bitmemory_getint_(pos, 65+3, &check);
test(check, "bitmemory_getint9");
RETURN;
}
static int test_bitmemory_setint(void)
{
addr pos1, pos2;
bitmemory_char_heap(&pos1,
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110101");
bitmemory_char_heap(&pos2,
"10110111111000000111111000001101010101010111100100100111001110110"
"01010111111000000111111000001101010101010111100100100111001110111"
"10110111111000000111111000001101010101010111100100100111001110101");
bitmemory_setint_(pos1, 65-1, 0);
bitmemory_setint_(pos1, 65+0, 0);
bitmemory_setint_(pos1, 65+1, 1);
bitmemory_setint_(pos1, 65+2, 0);
bitmemory_setint_(pos1, 65+3, 1);
test(bitmemory_equal(pos1, pos2), "bitmemory_setint1");
RETURN;
}
static int test_bitmemory_get(void)
{
addr pos, value;
bitmemory_char_heap(&pos, "110010");
bitmemory_get_(NULL, pos, 0, &value);
test(RefFixnum(value) == 1, "bitmemory_get1");
bitmemory_get_(NULL, pos, 1, &value);
test(RefFixnum(value) == 1, "bitmemory_get2");
bitmemory_get_(NULL, pos, 2, &value);
test(RefFixnum(value) == 0, "bitmemory_get3");
bitmemory_get_(NULL, pos, 4, &value);
test(RefFixnum(value) == 1, "bitmemory_get4");
bitmemory_get_(NULL, pos, 5, &value);
test(RefFixnum(value) == 0, "bitmemory_get5");
RETURN;
}
static int test_bitmemory_aref(void)
{
addr pos, value;
bitmemory_char_heap(&pos, "110010");
list_heap(&value, fixnumh(0), NULL);
bitmemory_aref_(NULL, pos, value, &value);
test(RefFixnum(value) == 1, "bitmemory_aref1");
list_heap(&value, fixnumh(2), NULL);
bitmemory_aref_(NULL, pos, value, &value);
test(RefFixnum(value) == 0, "bitmemory_aref2");
list_heap(&value, fixnumh(5), NULL);
bitmemory_aref_(NULL, pos, value, &value);
test(RefFixnum(value) == 0, "bitmemory_aref3");
RETURN;
}
static int test_bitmemory_set(void)
{
addr pos, check;
bitmemory_char_heap(&pos, "110010");
bitmemory_char_heap(&check, "100011");
bitmemory_set_(pos, 1, fixnumh(0));
bitmemory_set_(pos, 5, fixnumh(1));
test(bitmemory_equal(pos, check), "bitmemory_set1");
RETURN;
}
static int test_bitmemory_setf_aref(void)
{
addr pos, check, args;
bitmemory_char_heap(&pos, "110010");
bitmemory_char_heap(&check, "100011");
list_heap(&args, fixnumh(1), NULL);
bitmemory_setf_aref_(pos, args, fixnumh(0));
list_heap(&args, fixnumh(5), NULL);
bitmemory_setf_aref_(pos, args, fixnumh(1));
test(bitmemory_equal(pos, check), "bitmemory_setf_aref1");
RETURN;
}
/*
* bvarray
*/
static int test_array_bvarrayp(void)
{
addr pos, list;
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(array_bvarrayp(pos), "array_bvarrayp1");
GetTypeTable(&pos, Bit);
list_heap(&list, fixnumh(10), fixnumh(20), NULL);
array_make_array_(&pos, list, pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(! array_bvarrayp(pos), "array_bvarrayp2");
GetTypeTable(&pos, T);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(! array_bvarrayp(pos), "array_bvarrayp3");
RETURN;
}
static int test_bvarrayp(void)
{
addr pos;
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, T, Nil, Nil, Nil);
test(bvarrayp(pos), "bvarrayp1");
test(! bvarrayp(T), "bvarrayp2");
RETURN;
}
static int test_bitvectorp(void)
{
addr pos;
bitmemory_heap(&pos, 10);
test(bitvectorp(pos), "bitvectorp1");
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(bitvectorp(pos), "bitvectorp2");
test(! bitvectorp(T), "bitvectorp3");
RETURN;
}
static int test_simple_array_bvarrayp(void)
{
addr pos, list;
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(simple_array_bvarrayp(pos), "simple_array_bvarrayp1");
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, T, Nil, Nil, Nil);
test(! simple_array_bvarrayp(pos), "simple_array_bvarrayp2");
GetTypeTable(&pos, Bit);
list_heap(&list, fixnumh(10), fixnumh(20), NULL);
array_make_array_(&pos, list, pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(! simple_array_bvarrayp(pos), "simple_array_bvarrayp3");
GetTypeTable(&pos, T);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(! simple_array_bvarrayp(pos), "simple_array_bvarrayp4");
RETURN;
}
static int test_simple_bvarrayp(void)
{
addr pos;
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(simple_bvarrayp(pos), "simple_bvarrayp1");
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, T, Nil, Nil, Nil);
test(! simple_bvarrayp(pos), "simple_bvarrayp2");
test(! simple_bvarrayp(T), "simple_bvarrayp3");
RETURN;
}
static int test_simple_bitvectorp(void)
{
addr pos;
bitmemory_heap(&pos, 10);
test(simple_bitvectorp(pos), "simple_bitvectorp1");
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, Nil, Nil, Nil, Nil);
test(simple_bitvectorp(pos), "simple_bitvectorp2");
GetTypeTable(&pos, Bit);
array_make_array_(&pos, fixnumh(10), pos,
Unbound, Unbound, T, Nil, Nil, Nil);
test(! simple_bitvectorp(pos), "simple_bitvectorp3");
test(! simple_bitvectorp(T), "simple_bitvectorp4");
RETURN;
}
/*
* main
*/
static int testcase_bit(void)
{
/* bit */
TestBreak(test_bitp);
TestBreak(test_bit_getint);
/* bitcons */
TestBreak(test_bitbuffer_local);
TestBreak(test_getfixedsize);
TestBreak(test_bitcons_local);
TestBreak(test_pushnext_bitcons);
TestBreak(test_push_bitcons);
/* bitmemory */
TestBreak(test_bitmemory_unsafe);
TestBreak(test_bitmemory_alloc);
TestBreak(test_bitmemory_local);
TestBreak(test_bitmemory_heap);
TestBreak(test_bitmemory_cons_alloc);
TestBreak(test_bitmemory_cons_local);
TestBreak(test_bitmemory_cons_heap);
TestBreak(test_bitmemoryp);
TestBreak(test_bitmemory_memset_byte);
TestBreak(test_bitmemory_memset);
TestBreak(test_bitmemory_copy_unsafe);
TestBreak(test_bitmemory_length);
TestBreak(test_bitmemory_equal);
TestBreak(test_bitmemory_getint);
TestBreak(test_bitmemory_setint);
TestBreak(test_bitmemory_get);
TestBreak(test_bitmemory_aref);
TestBreak(test_bitmemory_set);
TestBreak(test_bitmemory_setf_aref);
/* bvarray */
TestBreak(test_array_bvarrayp);
TestBreak(test_bvarrayp);
TestBreak(test_bitvectorp);
TestBreak(test_simple_array_bvarrayp);
TestBreak(test_simple_bvarrayp);
TestBreak(test_simple_bitvectorp);
return 0;
}
static void testinit_bit(Execute ptr)
{
build_lisproot(ptr);
build_constant();
build_object();
build_character();
build_package();
build_stream();
build_symbol();
build_clos(ptr);
build_condition(ptr);
build_type();
build_syscall();
build_common();
build_reader();
}
int test_bit(void)
{
DegradeTitle;
return DegradeCode(bit);
}
|
7e516922667e4368e5a8a2371ccdb7366da34c13
|
f64218de515453d960cf5d9922b6b691d7d1f581
|
/slot.h
|
689fce5b0180f2859915185f320839870428d42d
|
[
"MIT"
] |
permissive
|
six-ddc/hss
|
8ae89c3653b164656c6645b438a3e94da79096c3
|
92c02e82808a9a30bfbaaca8f44060c3077e53ae
|
refs/heads/master
| 2023-03-08T16:08:10.412663
| 2022-02-08T03:29:12
| 2022-02-08T03:29:12
| 105,174,855
| 351
| 26
|
MIT
| 2021-03-14T06:33:43
| 2017-09-28T16:51:33
|
C
|
UTF-8
|
C
| false
| false
| 1,210
|
h
|
slot.h
|
#ifndef _HSS_SLOT_H_
#define _HSS_SLOT_H_
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include "sstring.h"
#define PIPE_READ_END 0
#define PIPE_WRITE_END 1
struct
stdio_pipe {
int out[2];
int err[2];
};
struct
slot {
char host[1024];
int ssh_argc;
char **ssh_argv;
int pid;
int exit_code;
bool alive;
int poll_index;
FILE *output;
sstring out_buff;
sstring err_buff;
struct stdio_pipe io;
struct slot *next;
};
typedef
void (*fn_getline)(struct slot *pslot, int io_type, sstring str, void *data);
void
slot_read_line(struct slot *pslot, int io_type, fn_getline cb, void *cb_data);
void
slot_read_remains(struct slot *pslot, fn_getline cb, void *cb_data);
struct slot *
new_slot(const char *args);
void
slot_reinit(struct slot *pslot);
void
slot_append(struct slot *pslot_list, struct slot *next);
void
slot_close(struct slot *pslot, int exit_code);
void
slot_free(struct slot *pslot);
void
print_slot_args(struct slot *pslot);
struct slot *
slot_find_by_pid(struct slot *pslot_list, int pid);
void
slot_del_by_host(struct slot *pslot_list, const char *host);
#endif //_HSS_SLOT_H_
|
e3e44d2c1fd49485e2d1f406e28196680e71afd7
|
7d232f51e2330a4f537c50ede9c6bc023d656fd4
|
/src/ruby/ext/grpc/rb_call.c
|
dde2901e6b2108302eb2cb029ea3245706ca7160
|
[
"BSD-3-Clause",
"MPL-2.0",
"Apache-2.0"
] |
permissive
|
grpc/grpc
|
6975af3ba6f07a6fe965b875a0c09abf18999a52
|
e4d598ab64aa54f1da78c6ed6133b741742d11d4
|
refs/heads/master
| 2023-08-31T01:10:22.666618
| 2023-08-30T22:35:17
| 2023-08-30T22:35:17
| 27,729,880
| 42,330
| 13,022
|
Apache-2.0
| 2023-09-14T21:54:19
| 2014-12-08T18:58:53
|
C++
|
UTF-8
|
C
| false
| false
| 38,320
|
c
|
rb_call.c
|
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <ruby/ruby.h>
#include "rb_call.h"
#include "rb_byte_buffer.h"
#include "rb_call_credentials.h"
#include "rb_completion_queue.h"
#include "rb_grpc.h"
#include "rb_grpc_imports.generated.h"
#include <grpc/grpc.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
/* grpc_rb_cCall is the Call class whose instances proxy grpc_call. */
static VALUE grpc_rb_cCall;
/* grpc_rb_eCallError is the ruby class of the exception thrown during call
operations; */
VALUE grpc_rb_eCallError = Qnil;
/* grpc_rb_eOutOfTime is the ruby class of the exception thrown to indicate
a timeout. */
static VALUE grpc_rb_eOutOfTime = Qnil;
/* grpc_rb_sBatchResult is struct class used to hold the results of a batch
* call. */
static VALUE grpc_rb_sBatchResult;
/* grpc_rb_cMdAry is the MetadataArray class whose instances proxy
* grpc_metadata_array. */
VALUE grpc_rb_cMdAry;
/* id_credentials is the name of the hidden ivar that preserves the value
* of the credentials added to the call */
static ID id_credentials;
/* id_metadata is name of the attribute used to access the metadata hash
* received by the call and subsequently saved on it. */
static ID id_metadata;
/* id_trailing_metadata is the name of the attribute used to access the trailing
* metadata hash received by the call and subsequently saved on it. */
static ID id_trailing_metadata;
/* id_status is name of the attribute used to access the status object
* received by the call and subsequently saved on it. */
static ID id_status;
/* id_write_flag is name of the attribute used to access the write_flag
* saved on the call. */
static ID id_write_flag;
/* sym_* are the symbol for attributes of grpc_rb_sBatchResult. */
static VALUE sym_send_message;
static VALUE sym_send_metadata;
static VALUE sym_send_close;
static VALUE sym_send_status;
static VALUE sym_message;
static VALUE sym_status;
static VALUE sym_cancelled;
typedef struct grpc_rb_call {
grpc_call* wrapped;
grpc_completion_queue* queue;
} grpc_rb_call;
static void destroy_call(grpc_rb_call* call) {
/* Ensure that we only try to destroy the call once */
if (call->wrapped != NULL) {
grpc_call_unref(call->wrapped);
call->wrapped = NULL;
grpc_rb_completion_queue_destroy(call->queue);
call->queue = NULL;
}
}
/* Destroys a Call. */
static void grpc_rb_call_destroy(void* p) {
if (p == NULL) {
return;
}
destroy_call((grpc_rb_call*)p);
xfree(p);
}
const rb_data_type_t grpc_rb_md_ary_data_type = {
"grpc_metadata_array",
{GRPC_RB_GC_NOT_MARKED,
GRPC_RB_GC_DONT_FREE,
GRPC_RB_MEMSIZE_UNAVAILABLE,
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
/* it is unsafe to specify RUBY_TYPED_FREE_IMMEDIATELY because
* grpc_rb_call_destroy
* touches a hash object.
* TODO(yugui) Directly use st_table and call the free function earlier?
*/
0,
#endif
};
/* Describes grpc_call struct for RTypedData */
static const rb_data_type_t grpc_call_data_type = {"grpc_call",
{GRPC_RB_GC_NOT_MARKED,
grpc_rb_call_destroy,
GRPC_RB_MEMSIZE_UNAVAILABLE,
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
};
/* Error code details is a hash containing text strings describing errors */
VALUE rb_error_code_details;
/* Obtains the error detail string for given error code */
const char* grpc_call_error_detail_of(grpc_call_error err) {
VALUE detail_ref = rb_hash_aref(rb_error_code_details, UINT2NUM(err));
const char* detail = "unknown error code!";
if (detail_ref != Qnil) {
detail = StringValueCStr(detail_ref);
}
return detail;
}
/* Called by clients to cancel an RPC on the server.
Can be called multiple times, from any thread. */
static VALUE grpc_rb_call_cancel(VALUE self) {
grpc_rb_call* call = NULL;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
// This call has been closed
return Qnil;
}
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
err = grpc_call_cancel(call->wrapped, NULL);
if (err != GRPC_CALL_OK) {
rb_raise(grpc_rb_eCallError, "cancel failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
return Qnil;
}
/* TODO: expose this as part of the surface API if needed.
* This is meant for internal usage by the "write thread" of grpc-ruby
* client-side bidi calls. It provides a way for the background write-thread
* to propagate failures to the main read-thread and give the user an error
* message. */
static VALUE grpc_rb_call_cancel_with_status(VALUE self, VALUE status_code,
VALUE details) {
grpc_rb_call* call = NULL;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
// This call has been closed
return Qnil;
}
if (TYPE(details) != T_STRING || TYPE(status_code) != T_FIXNUM) {
rb_raise(rb_eTypeError,
"Bad parameter type error for cancel with status. Want Fixnum, "
"String.");
return Qnil;
}
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
err = grpc_call_cancel_with_status(call->wrapped, NUM2LONG(status_code),
StringValueCStr(details), NULL);
if (err != GRPC_CALL_OK) {
rb_raise(grpc_rb_eCallError, "cancel with status failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
return Qnil;
}
/* Releases the c-level resources associated with a call
Once a call has been closed, no further requests can be
processed.
*/
static VALUE grpc_rb_call_close(VALUE self) {
grpc_rb_call* call = NULL;
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
if (call != NULL) {
destroy_call(call);
xfree(RTYPEDDATA_DATA(self));
RTYPEDDATA_DATA(self) = NULL;
}
return Qnil;
}
/* Called to obtain the peer that this call is connected to. */
static VALUE grpc_rb_call_get_peer(VALUE self) {
VALUE res = Qnil;
grpc_rb_call* call = NULL;
char* peer = NULL;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot get peer value on closed call");
return Qnil;
}
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
peer = grpc_call_get_peer(call->wrapped);
res = rb_str_new2(peer);
gpr_free(peer);
return res;
}
/* Called to obtain the x509 cert of an authenticated peer. */
static VALUE grpc_rb_call_get_peer_cert(VALUE self) {
grpc_rb_call* call = NULL;
VALUE res = Qnil;
grpc_auth_context* ctx = NULL;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot get peer cert on closed call");
return Qnil;
}
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
ctx = grpc_call_auth_context(call->wrapped);
if (!ctx || !grpc_auth_context_peer_is_authenticated(ctx)) {
return Qnil;
}
{
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME);
const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
if (prop == NULL) {
return Qnil;
}
res = rb_str_new2(prop->value);
}
grpc_auth_context_release(ctx);
return res;
}
/*
call-seq:
status = call.status
Gets the status object saved the call. */
static VALUE grpc_rb_call_get_status(VALUE self) {
return rb_ivar_get(self, id_status);
}
/*
call-seq:
call.status = status
Saves a status object on the call. */
static VALUE grpc_rb_call_set_status(VALUE self, VALUE status) {
if (!NIL_P(status) && rb_obj_class(status) != grpc_rb_sStatus) {
rb_raise(rb_eTypeError, "bad status: got:<%s> want: <Struct::Status>",
rb_obj_classname(status));
return Qnil;
}
return rb_ivar_set(self, id_status, status);
}
/*
call-seq:
metadata = call.metadata
Gets the metadata object saved the call. */
static VALUE grpc_rb_call_get_metadata(VALUE self) {
return rb_ivar_get(self, id_metadata);
}
/*
call-seq:
call.metadata = metadata
Saves the metadata hash on the call. */
static VALUE grpc_rb_call_set_metadata(VALUE self, VALUE metadata) {
if (!NIL_P(metadata) && TYPE(metadata) != T_HASH) {
rb_raise(rb_eTypeError, "bad metadata: got:<%s> want: <Hash>",
rb_obj_classname(metadata));
return Qnil;
}
return rb_ivar_set(self, id_metadata, metadata);
}
/*
call-seq:
trailing_metadata = call.trailing_metadata
Gets the trailing metadata object saved on the call */
static VALUE grpc_rb_call_get_trailing_metadata(VALUE self) {
return rb_ivar_get(self, id_trailing_metadata);
}
/*
call-seq:
call.trailing_metadata = trailing_metadata
Saves the trailing metadata hash on the call. */
static VALUE grpc_rb_call_set_trailing_metadata(VALUE self, VALUE metadata) {
if (!NIL_P(metadata) && TYPE(metadata) != T_HASH) {
rb_raise(rb_eTypeError, "bad metadata: got:<%s> want: <Hash>",
rb_obj_classname(metadata));
return Qnil;
}
return rb_ivar_set(self, id_trailing_metadata, metadata);
}
/*
call-seq:
write_flag = call.write_flag
Gets the write_flag value saved the call. */
static VALUE grpc_rb_call_get_write_flag(VALUE self) {
return rb_ivar_get(self, id_write_flag);
}
/*
call-seq:
call.write_flag = write_flag
Saves the write_flag on the call. */
static VALUE grpc_rb_call_set_write_flag(VALUE self, VALUE write_flag) {
if (!NIL_P(write_flag) && TYPE(write_flag) != T_FIXNUM) {
rb_raise(rb_eTypeError, "bad write_flag: got:<%s> want: <Fixnum>",
rb_obj_classname(write_flag));
return Qnil;
}
return rb_ivar_set(self, id_write_flag, write_flag);
}
/*
call-seq:
call.set_credentials call_credentials
Sets credentials on a call */
static VALUE grpc_rb_call_set_credentials(VALUE self, VALUE credentials) {
grpc_rb_call* call = NULL;
grpc_call_credentials* creds;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot set credentials of closed call");
return Qnil;
}
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
creds = grpc_rb_get_wrapped_call_credentials(credentials);
err = grpc_call_set_credentials(call->wrapped, creds);
if (err != GRPC_CALL_OK) {
rb_raise(grpc_rb_eCallError,
"grpc_call_set_credentials failed with %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
/* We need the credentials to be alive for as long as the call is alive,
but we don't care about destruction order. */
rb_ivar_set(self, id_credentials, credentials);
return Qnil;
}
/* grpc_rb_md_ary_fill_hash_cb is the hash iteration callback used
to fill grpc_metadata_array.
it's capacity should have been computed via a prior call to
grpc_rb_md_ary_capacity_hash_cb
*/
static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
grpc_metadata_array* md_ary = NULL;
long array_length;
long i;
grpc_slice key_slice;
grpc_slice value_slice;
char* tmp_str = NULL;
if (TYPE(key) == T_SYMBOL) {
key_slice = grpc_slice_from_static_string(rb_id2name(SYM2ID(key)));
} else if (TYPE(key) == T_STRING) {
key_slice =
grpc_slice_from_copied_buffer(RSTRING_PTR(key), RSTRING_LEN(key));
} else {
rb_raise(rb_eTypeError,
"grpc_rb_md_ary_fill_hash_cb: bad type for key parameter");
return ST_STOP;
}
if (!grpc_header_key_is_legal(key_slice)) {
tmp_str = grpc_slice_to_c_string(key_slice);
rb_raise(rb_eArgError,
"'%s' is an invalid header key, must match [a-z0-9-_.]+", tmp_str);
return ST_STOP;
}
/* Construct a metadata object from key and value and add it */
TypedData_Get_Struct(md_ary_obj, grpc_metadata_array,
&grpc_rb_md_ary_data_type, md_ary);
if (TYPE(val) == T_ARRAY) {
array_length = RARRAY_LEN(val);
/* If the value is an array, add capacity for each value in the array */
for (i = 0; i < array_length; i++) {
value_slice = grpc_slice_from_copied_buffer(
RSTRING_PTR(rb_ary_entry(val, i)), RSTRING_LEN(rb_ary_entry(val, i)));
if (!grpc_is_binary_header(key_slice) &&
!grpc_header_nonbin_value_is_legal(value_slice)) {
// The value has invalid characters
tmp_str = grpc_slice_to_c_string(value_slice);
rb_raise(rb_eArgError, "Header value '%s' has invalid characters",
tmp_str);
return ST_STOP;
}
GPR_ASSERT(md_ary->count < md_ary->capacity);
md_ary->metadata[md_ary->count].key = key_slice;
md_ary->metadata[md_ary->count].value = value_slice;
md_ary->count += 1;
}
} else if (TYPE(val) == T_STRING) {
value_slice =
grpc_slice_from_copied_buffer(RSTRING_PTR(val), RSTRING_LEN(val));
if (!grpc_is_binary_header(key_slice) &&
!grpc_header_nonbin_value_is_legal(value_slice)) {
// The value has invalid characters
tmp_str = grpc_slice_to_c_string(value_slice);
rb_raise(rb_eArgError, "Header value '%s' has invalid characters",
tmp_str);
return ST_STOP;
}
GPR_ASSERT(md_ary->count < md_ary->capacity);
md_ary->metadata[md_ary->count].key = key_slice;
md_ary->metadata[md_ary->count].value = value_slice;
md_ary->count += 1;
} else {
rb_raise(rb_eArgError, "Header values must be of type string or array");
return ST_STOP;
}
return ST_CONTINUE;
}
/* grpc_rb_md_ary_capacity_hash_cb is the hash iteration callback used
to pre-compute the capacity a grpc_metadata_array.
*/
static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val,
VALUE md_ary_obj) {
grpc_metadata_array* md_ary = NULL;
(void)key;
/* Construct a metadata object from key and value and add it */
TypedData_Get_Struct(md_ary_obj, grpc_metadata_array,
&grpc_rb_md_ary_data_type, md_ary);
if (TYPE(val) == T_ARRAY) {
/* If the value is an array, add capacity for each value in the array */
md_ary->capacity += RARRAY_LEN(val);
} else {
md_ary->capacity += 1;
}
return ST_CONTINUE;
}
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
a grpc_metadata_array.
Note that this function may throw exceptions.
*/
void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array* md_ary) {
VALUE md_ary_obj = Qnil;
if (md_ary_hash == Qnil) {
return; /* Do nothing if the expected has value is nil */
}
if (TYPE(md_ary_hash) != T_HASH) {
rb_raise(rb_eTypeError, "md_ary_convert: got <%s>, want <Hash>",
rb_obj_classname(md_ary_hash));
return;
}
/* Initialize the array, compute it's capacity, then fill it. */
grpc_metadata_array_init(md_ary);
md_ary_obj =
TypedData_Wrap_Struct(grpc_rb_cMdAry, &grpc_rb_md_ary_data_type, md_ary);
rb_hash_foreach(md_ary_hash, grpc_rb_md_ary_capacity_hash_cb, md_ary_obj);
md_ary->metadata = gpr_zalloc(md_ary->capacity * sizeof(grpc_metadata));
rb_hash_foreach(md_ary_hash, grpc_rb_md_ary_fill_hash_cb, md_ary_obj);
}
/* Converts a metadata array to a hash. */
VALUE grpc_rb_md_ary_to_h(grpc_metadata_array* md_ary) {
VALUE key = Qnil;
VALUE new_ary = Qnil;
VALUE value = Qnil;
VALUE result = rb_hash_new();
size_t i;
for (i = 0; i < md_ary->count; i++) {
key = grpc_rb_slice_to_ruby_string(md_ary->metadata[i].key);
value = rb_hash_aref(result, key);
if (value == Qnil) {
value = grpc_rb_slice_to_ruby_string(md_ary->metadata[i].value);
rb_hash_aset(result, key, value);
} else if (TYPE(value) == T_ARRAY) {
/* Add the string to the returned array */
rb_ary_push(value,
grpc_rb_slice_to_ruby_string(md_ary->metadata[i].value));
} else {
/* Add the current value with this key and the new one to an array */
new_ary = rb_ary_new();
rb_ary_push(new_ary, value);
rb_ary_push(new_ary,
grpc_rb_slice_to_ruby_string(md_ary->metadata[i].value));
rb_hash_aset(result, key, new_ary);
}
}
return result;
}
/* grpc_rb_call_check_op_keys_hash_cb is a hash iteration func that checks
each key of an ops hash is valid.
*/
static int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val,
VALUE ops_ary) {
(void)val;
/* Update the capacity; the value is an array, add capacity for each value in
* the array */
if (TYPE(key) != T_FIXNUM) {
rb_raise(rb_eTypeError, "invalid operation : got <%s>, want <Fixnum>",
rb_obj_classname(key));
return ST_STOP;
}
switch (NUM2INT(key)) {
case GRPC_OP_SEND_INITIAL_METADATA:
case GRPC_OP_SEND_MESSAGE:
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
case GRPC_OP_SEND_STATUS_FROM_SERVER:
case GRPC_OP_RECV_INITIAL_METADATA:
case GRPC_OP_RECV_MESSAGE:
case GRPC_OP_RECV_STATUS_ON_CLIENT:
case GRPC_OP_RECV_CLOSE_ON_SERVER:
rb_ary_push(ops_ary, key);
return ST_CONTINUE;
default:
rb_raise(rb_eTypeError, "invalid operation : bad value %d", NUM2INT(key));
};
return ST_STOP;
}
/* grpc_rb_op_update_status_from_server adds the values in a ruby status
struct to the 'send_status_from_server' portion of an op.
*/
static void grpc_rb_op_update_status_from_server(
grpc_op* op, grpc_metadata_array* md_ary, grpc_slice* send_status_details,
VALUE status) {
VALUE code = rb_struct_aref(status, sym_code);
VALUE details = rb_struct_aref(status, sym_details);
VALUE metadata_hash = rb_struct_aref(status, sym_metadata);
/* TODO: add check to ensure status is the correct struct type */
if (TYPE(code) != T_FIXNUM) {
rb_raise(rb_eTypeError, "invalid code : got <%s>, want <Fixnum>",
rb_obj_classname(code));
return;
}
if (TYPE(details) != T_STRING) {
rb_raise(rb_eTypeError, "invalid details : got <%s>, want <String>",
rb_obj_classname(code));
return;
}
*send_status_details =
grpc_slice_from_copied_buffer(RSTRING_PTR(details), RSTRING_LEN(details));
op->data.send_status_from_server.status = NUM2INT(code);
op->data.send_status_from_server.status_details = send_status_details;
grpc_rb_md_ary_convert(metadata_hash, md_ary);
op->data.send_status_from_server.trailing_metadata_count = md_ary->count;
op->data.send_status_from_server.trailing_metadata = md_ary->metadata;
}
/* run_batch_stack holds various values used by the
* grpc_rb_call_run_batch function */
typedef struct run_batch_stack {
/* The batch ops */
grpc_op ops[8]; /* 8 is the maximum number of operations */
size_t op_num; /* tracks the last added operation */
/* Data being sent */
grpc_metadata_array send_metadata;
grpc_metadata_array send_trailing_metadata;
/* Data being received */
grpc_byte_buffer* recv_message;
grpc_metadata_array recv_metadata;
grpc_metadata_array recv_trailing_metadata;
int recv_cancelled;
grpc_status_code recv_status;
grpc_slice recv_status_details;
const char* recv_status_debug_error_string;
unsigned write_flag;
grpc_slice send_status_details;
} run_batch_stack;
/* grpc_run_batch_stack_init ensures the run_batch_stack is properly
* initialized */
static void grpc_run_batch_stack_init(run_batch_stack* st,
unsigned write_flag) {
MEMZERO(st, run_batch_stack, 1);
grpc_metadata_array_init(&st->send_metadata);
grpc_metadata_array_init(&st->send_trailing_metadata);
grpc_metadata_array_init(&st->recv_metadata);
grpc_metadata_array_init(&st->recv_trailing_metadata);
st->op_num = 0;
st->write_flag = write_flag;
}
void grpc_rb_metadata_array_destroy_including_entries(
grpc_metadata_array* array) {
size_t i;
if (array->metadata) {
for (i = 0; i < array->count; i++) {
grpc_slice_unref(array->metadata[i].key);
grpc_slice_unref(array->metadata[i].value);
}
}
grpc_metadata_array_destroy(array);
}
/* grpc_run_batch_stack_cleanup ensures the run_batch_stack is properly
* cleaned up */
static void grpc_run_batch_stack_cleanup(run_batch_stack* st) {
size_t i = 0;
grpc_rb_metadata_array_destroy_including_entries(&st->send_metadata);
grpc_rb_metadata_array_destroy_including_entries(&st->send_trailing_metadata);
grpc_metadata_array_destroy(&st->recv_metadata);
grpc_metadata_array_destroy(&st->recv_trailing_metadata);
if (GRPC_SLICE_START_PTR(st->send_status_details) != NULL) {
grpc_slice_unref(st->send_status_details);
}
if (GRPC_SLICE_START_PTR(st->recv_status_details) != NULL) {
grpc_slice_unref(st->recv_status_details);
}
if (st->recv_message != NULL) {
grpc_byte_buffer_destroy(st->recv_message);
}
for (i = 0; i < st->op_num; i++) {
if (st->ops[i].op == GRPC_OP_SEND_MESSAGE) {
grpc_byte_buffer_destroy(st->ops[i].data.send_message.send_message);
}
}
}
/* grpc_run_batch_stack_fill_ops fills the run_batch_stack ops array from
* ops_hash */
static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) {
VALUE this_op = Qnil;
VALUE this_value = Qnil;
VALUE ops_ary = rb_ary_new();
size_t i = 0;
/* Create a ruby array with just the operation keys */
rb_hash_foreach(ops_hash, grpc_rb_call_check_op_keys_hash_cb, ops_ary);
/* Fill the ops array */
for (i = 0; i < (size_t)RARRAY_LEN(ops_ary); i++) {
this_op = rb_ary_entry(ops_ary, i);
this_value = rb_hash_aref(ops_hash, this_op);
st->ops[st->op_num].flags = 0;
switch (NUM2INT(this_op)) {
case GRPC_OP_SEND_INITIAL_METADATA:
grpc_rb_md_ary_convert(this_value, &st->send_metadata);
st->ops[st->op_num].data.send_initial_metadata.count =
st->send_metadata.count;
st->ops[st->op_num].data.send_initial_metadata.metadata =
st->send_metadata.metadata;
break;
case GRPC_OP_SEND_MESSAGE:
st->ops[st->op_num].data.send_message.send_message =
grpc_rb_s_to_byte_buffer(RSTRING_PTR(this_value),
RSTRING_LEN(this_value));
st->ops[st->op_num].flags = st->write_flag;
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
break;
case GRPC_OP_SEND_STATUS_FROM_SERVER:
grpc_rb_op_update_status_from_server(
&st->ops[st->op_num], &st->send_trailing_metadata,
&st->send_status_details, this_value);
break;
case GRPC_OP_RECV_INITIAL_METADATA:
st->ops[st->op_num].data.recv_initial_metadata.recv_initial_metadata =
&st->recv_metadata;
break;
case GRPC_OP_RECV_MESSAGE:
st->ops[st->op_num].data.recv_message.recv_message = &st->recv_message;
break;
case GRPC_OP_RECV_STATUS_ON_CLIENT:
st->ops[st->op_num].data.recv_status_on_client.trailing_metadata =
&st->recv_trailing_metadata;
st->ops[st->op_num].data.recv_status_on_client.status =
&st->recv_status;
st->ops[st->op_num].data.recv_status_on_client.status_details =
&st->recv_status_details;
st->ops[st->op_num].data.recv_status_on_client.error_string =
&st->recv_status_debug_error_string;
break;
case GRPC_OP_RECV_CLOSE_ON_SERVER:
st->ops[st->op_num].data.recv_close_on_server.cancelled =
&st->recv_cancelled;
break;
default:
grpc_run_batch_stack_cleanup(st);
rb_raise(rb_eTypeError, "invalid operation : bad value %d",
NUM2INT(this_op));
};
st->ops[st->op_num].op = (grpc_op_type)NUM2INT(this_op);
st->ops[st->op_num].reserved = NULL;
st->op_num++;
}
}
/* grpc_run_batch_stack_build_result fills constructs a ruby BatchResult struct
after the results have run */
static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
size_t i = 0;
VALUE result = rb_struct_new(grpc_rb_sBatchResult, Qnil, Qnil, Qnil, Qnil,
Qnil, Qnil, Qnil, Qnil, NULL);
for (i = 0; i < st->op_num; i++) {
switch (st->ops[i].op) {
case GRPC_OP_SEND_INITIAL_METADATA:
rb_struct_aset(result, sym_send_metadata, Qtrue);
break;
case GRPC_OP_SEND_MESSAGE:
rb_struct_aset(result, sym_send_message, Qtrue);
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
rb_struct_aset(result, sym_send_close, Qtrue);
break;
case GRPC_OP_SEND_STATUS_FROM_SERVER:
rb_struct_aset(result, sym_send_status, Qtrue);
break;
case GRPC_OP_RECV_INITIAL_METADATA:
rb_struct_aset(result, sym_metadata,
grpc_rb_md_ary_to_h(&st->recv_metadata));
case GRPC_OP_RECV_MESSAGE:
rb_struct_aset(result, sym_message,
grpc_rb_byte_buffer_to_s(st->recv_message));
break;
case GRPC_OP_RECV_STATUS_ON_CLIENT:
rb_struct_aset(
result, sym_status,
rb_struct_new(
grpc_rb_sStatus, UINT2NUM(st->recv_status),
(GRPC_SLICE_START_PTR(st->recv_status_details) == NULL
? Qnil
: grpc_rb_slice_to_ruby_string(st->recv_status_details)),
grpc_rb_md_ary_to_h(&st->recv_trailing_metadata),
st->recv_status_debug_error_string == NULL
? Qnil
: rb_str_new_cstr(st->recv_status_debug_error_string),
NULL));
gpr_free((void*)st->recv_status_debug_error_string);
break;
case GRPC_OP_RECV_CLOSE_ON_SERVER:
rb_struct_aset(result, sym_send_close, Qtrue);
break;
default:
break;
}
}
return result;
}
struct call_run_batch_args {
grpc_rb_call* call;
unsigned write_flag;
VALUE ops_hash;
run_batch_stack* st;
};
static VALUE grpc_rb_call_run_batch_try(VALUE value_args) {
grpc_rb_fork_unsafe_begin();
struct call_run_batch_args* args = (struct call_run_batch_args*)value_args;
void* tag = (void*)&args->st;
grpc_event ev;
grpc_call_error err;
args->st = gpr_malloc(sizeof(run_batch_stack));
grpc_run_batch_stack_init(args->st, args->write_flag);
grpc_run_batch_stack_fill_ops(args->st, args->ops_hash);
/* call grpc_call_start_batch, then wait for it to complete using
* pluck_event */
err = grpc_call_start_batch(args->call->wrapped, args->st->ops,
args->st->op_num, tag, NULL);
if (err != GRPC_CALL_OK) {
rb_raise(grpc_rb_eCallError,
"grpc_call_start_batch failed with %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
ev = rb_completion_queue_pluck(args->call->queue, tag,
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
if (!ev.success) {
rb_raise(grpc_rb_eCallError, "call#run_batch failed somehow");
}
/* Build and return the BatchResult struct result,
if there is an error, it's reflected in the status */
return grpc_run_batch_stack_build_result(args->st);
}
static VALUE grpc_rb_call_run_batch_ensure(VALUE value_args) {
grpc_rb_fork_unsafe_end();
struct call_run_batch_args* args = (struct call_run_batch_args*)value_args;
if (args->st) {
grpc_run_batch_stack_cleanup(args->st);
gpr_free(args->st);
}
return Qnil;
}
/* call-seq:
ops = {
GRPC::Core::CallOps::SEND_INITIAL_METADATA => <op_value>,
GRPC::Core::CallOps::SEND_MESSAGE => <op_value>,
...
}
tag = Object.new
timeout = 10
call.start_batch(tag, timeout, ops)
Start a batch of operations defined in the array ops; when complete, post a
completion of type 'tag' to the completion queue bound to the call.
Also waits for the batch to complete, until timeout is reached.
The order of ops specified in the batch has no significance.
Only one operation of each type can be active at once in any given
batch */
static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
grpc_ruby_fork_guard();
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
}
grpc_rb_call* call = NULL;
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
/* Validate the ops args, adding them to a ruby array */
if (TYPE(ops_hash) != T_HASH) {
rb_raise(rb_eTypeError, "call#run_batch: ops hash should be a hash");
}
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
struct call_run_batch_args args = {
.call = call,
.write_flag = rb_write_flag == Qnil ? 0 : NUM2UINT(rb_write_flag),
.ops_hash = ops_hash,
.st = NULL};
return rb_ensure(grpc_rb_call_run_batch_try, (VALUE)&args,
grpc_rb_call_run_batch_ensure, (VALUE)&args);
}
static void Init_grpc_write_flags() {
/* Constants representing the write flags in grpc.h */
VALUE grpc_rb_mWriteFlags =
rb_define_module_under(grpc_rb_mGrpcCore, "WriteFlags");
rb_define_const(grpc_rb_mWriteFlags, "BUFFER_HINT",
UINT2NUM(GRPC_WRITE_BUFFER_HINT));
rb_define_const(grpc_rb_mWriteFlags, "NO_COMPRESS",
UINT2NUM(GRPC_WRITE_NO_COMPRESS));
}
static void Init_grpc_error_codes() {
/* Constants representing the error codes of grpc_call_error in grpc.h */
VALUE grpc_rb_mRpcErrors =
rb_define_module_under(grpc_rb_mGrpcCore, "RpcErrors");
rb_define_const(grpc_rb_mRpcErrors, "OK", UINT2NUM(GRPC_CALL_OK));
rb_define_const(grpc_rb_mRpcErrors, "ERROR", UINT2NUM(GRPC_CALL_ERROR));
rb_define_const(grpc_rb_mRpcErrors, "NOT_ON_SERVER",
UINT2NUM(GRPC_CALL_ERROR_NOT_ON_SERVER));
rb_define_const(grpc_rb_mRpcErrors, "NOT_ON_CLIENT",
UINT2NUM(GRPC_CALL_ERROR_NOT_ON_CLIENT));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_ACCEPTED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_ACCEPTED));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_INVOKED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_INVOKED));
rb_define_const(grpc_rb_mRpcErrors, "NOT_INVOKED",
UINT2NUM(GRPC_CALL_ERROR_NOT_INVOKED));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_FINISHED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_FINISHED));
rb_define_const(grpc_rb_mRpcErrors, "TOO_MANY_OPERATIONS",
UINT2NUM(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS));
rb_define_const(grpc_rb_mRpcErrors, "INVALID_FLAGS",
UINT2NUM(GRPC_CALL_ERROR_INVALID_FLAGS));
/* Hint the GC that this is a global and shouldn't be sweeped. */
rb_global_variable(&rb_error_code_details);
/* Add the detail strings to a Hash */
rb_error_code_details = rb_hash_new();
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_OK),
rb_str_new2("ok"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR),
rb_str_new2("unknown error"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_ON_SERVER),
rb_str_new2("not available on a server"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_ON_CLIENT),
rb_str_new2("not available on a client"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_ALREADY_ACCEPTED),
rb_str_new2("call is already accepted"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_ALREADY_INVOKED),
rb_str_new2("call is already invoked"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_INVOKED),
rb_str_new2("call is not yet invoked"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_ALREADY_FINISHED),
rb_str_new2("call is already finished"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS),
rb_str_new2("outstanding read or write present"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_INVALID_FLAGS),
rb_str_new2("a bad flag was given"));
rb_define_const(grpc_rb_mRpcErrors, "ErrorMessages", rb_error_code_details);
rb_obj_freeze(rb_error_code_details);
}
static void Init_grpc_op_codes() {
/* Constants representing operation type codes in grpc.h */
VALUE grpc_rb_mCallOps = rb_define_module_under(grpc_rb_mGrpcCore, "CallOps");
rb_define_const(grpc_rb_mCallOps, "SEND_INITIAL_METADATA",
UINT2NUM(GRPC_OP_SEND_INITIAL_METADATA));
rb_define_const(grpc_rb_mCallOps, "SEND_MESSAGE",
UINT2NUM(GRPC_OP_SEND_MESSAGE));
rb_define_const(grpc_rb_mCallOps, "SEND_CLOSE_FROM_CLIENT",
UINT2NUM(GRPC_OP_SEND_CLOSE_FROM_CLIENT));
rb_define_const(grpc_rb_mCallOps, "SEND_STATUS_FROM_SERVER",
UINT2NUM(GRPC_OP_SEND_STATUS_FROM_SERVER));
rb_define_const(grpc_rb_mCallOps, "RECV_INITIAL_METADATA",
UINT2NUM(GRPC_OP_RECV_INITIAL_METADATA));
rb_define_const(grpc_rb_mCallOps, "RECV_MESSAGE",
UINT2NUM(GRPC_OP_RECV_MESSAGE));
rb_define_const(grpc_rb_mCallOps, "RECV_STATUS_ON_CLIENT",
UINT2NUM(GRPC_OP_RECV_STATUS_ON_CLIENT));
rb_define_const(grpc_rb_mCallOps, "RECV_CLOSE_ON_SERVER",
UINT2NUM(GRPC_OP_RECV_CLOSE_ON_SERVER));
}
static void Init_grpc_metadata_keys() {
VALUE grpc_rb_mMetadataKeys =
rb_define_module_under(grpc_rb_mGrpcCore, "MetadataKeys");
rb_define_const(grpc_rb_mMetadataKeys, "COMPRESSION_REQUEST_ALGORITHM",
rb_str_new2(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY));
}
void Init_grpc_call() {
/* CallError inherits from Exception to signal that it is non-recoverable */
grpc_rb_eCallError =
rb_define_class_under(grpc_rb_mGrpcCore, "CallError", rb_eException);
grpc_rb_eOutOfTime =
rb_define_class_under(grpc_rb_mGrpcCore, "OutOfTime", rb_eException);
grpc_rb_cCall = rb_define_class_under(grpc_rb_mGrpcCore, "Call", rb_cObject);
grpc_rb_cMdAry =
rb_define_class_under(grpc_rb_mGrpcCore, "MetadataArray", rb_cObject);
rb_undef_alloc_func(grpc_rb_cMdAry);
/* Prevent allocation or inialization of the Call class */
rb_define_alloc_func(grpc_rb_cCall, grpc_rb_cannot_alloc);
rb_define_method(grpc_rb_cCall, "initialize", grpc_rb_cannot_init, 0);
rb_define_method(grpc_rb_cCall, "initialize_copy", grpc_rb_cannot_init_copy,
1);
/* Add ruby analogues of the Call methods. */
rb_define_method(grpc_rb_cCall, "run_batch", grpc_rb_call_run_batch, 1);
rb_define_method(grpc_rb_cCall, "cancel", grpc_rb_call_cancel, 0);
rb_define_method(grpc_rb_cCall, "cancel_with_status",
grpc_rb_call_cancel_with_status, 2);
rb_define_method(grpc_rb_cCall, "close", grpc_rb_call_close, 0);
rb_define_method(grpc_rb_cCall, "peer", grpc_rb_call_get_peer, 0);
rb_define_method(grpc_rb_cCall, "peer_cert", grpc_rb_call_get_peer_cert, 0);
rb_define_method(grpc_rb_cCall, "status", grpc_rb_call_get_status, 0);
rb_define_method(grpc_rb_cCall, "status=", grpc_rb_call_set_status, 1);
rb_define_method(grpc_rb_cCall, "metadata", grpc_rb_call_get_metadata, 0);
rb_define_method(grpc_rb_cCall, "metadata=", grpc_rb_call_set_metadata, 1);
rb_define_method(grpc_rb_cCall, "trailing_metadata",
grpc_rb_call_get_trailing_metadata, 0);
rb_define_method(grpc_rb_cCall,
"trailing_metadata=", grpc_rb_call_set_trailing_metadata, 1);
rb_define_method(grpc_rb_cCall, "write_flag", grpc_rb_call_get_write_flag, 0);
rb_define_method(grpc_rb_cCall, "write_flag=", grpc_rb_call_set_write_flag,
1);
rb_define_method(grpc_rb_cCall, "set_credentials!",
grpc_rb_call_set_credentials, 1);
/* Ids used to support call attributes */
id_metadata = rb_intern("metadata");
id_trailing_metadata = rb_intern("trailing_metadata");
id_status = rb_intern("status");
id_write_flag = rb_intern("write_flag");
/* Ids used by the c wrapping internals. */
id_credentials = rb_intern("__credentials");
/* Ids used in constructing the batch result. */
sym_send_message = ID2SYM(rb_intern("send_message"));
sym_send_metadata = ID2SYM(rb_intern("send_metadata"));
sym_send_close = ID2SYM(rb_intern("send_close"));
sym_send_status = ID2SYM(rb_intern("send_status"));
sym_message = ID2SYM(rb_intern("message"));
sym_status = ID2SYM(rb_intern("status"));
sym_cancelled = ID2SYM(rb_intern("cancelled"));
/* The Struct used to return the run_batch result. */
grpc_rb_sBatchResult = rb_struct_define(
"BatchResult", "send_message", "send_metadata", "send_close",
"send_status", "message", "metadata", "status", "cancelled", NULL);
Init_grpc_error_codes();
Init_grpc_op_codes();
Init_grpc_write_flags();
Init_grpc_metadata_keys();
}
/* Gets the call from the ruby object */
grpc_call* grpc_rb_get_wrapped_call(VALUE v) {
grpc_rb_call* call = NULL;
TypedData_Get_Struct(v, grpc_rb_call, &grpc_call_data_type, call);
return call->wrapped;
}
/* Obtains the wrapped object for a given call */
VALUE grpc_rb_wrap_call(grpc_call* c, grpc_completion_queue* q) {
grpc_rb_call* wrapper;
if (c == NULL || q == NULL) {
return Qnil;
}
wrapper = ALLOC(grpc_rb_call);
wrapper->wrapped = c;
wrapper->queue = q;
return TypedData_Wrap_Struct(grpc_rb_cCall, &grpc_call_data_type, wrapper);
}
|
603a64e85ad7e502da3c8b27c6434df547f95996
|
c95c521825127ead6602f9bad0b6de89fe270c02
|
/src/RegHelper.h
|
90f0a1c666ae85484feabd3323412a52f9c7e9e3
|
[
"MIT"
] |
permissive
|
strobejb/winspy
|
7d88e60eaf06aa751b5774df18f5b2abb49cca5c
|
365839b8af7278101ee427f431687271ecf4a58a
|
refs/heads/master
| 2023-05-28T00:06:30.231033
| 2023-05-13T19:22:23
| 2023-05-13T19:22:23
| 4,961,649
| 234
| 80
|
MIT
| 2023-05-13T19:33:29
| 2012-07-09T17:14:14
|
C
|
UTF-8
|
C
| false
| false
| 755
|
h
|
RegHelper.h
|
#ifndef _REGHELPER_INCLUDED
#define _REGHELPER_INCLUDED
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
LONG GetSettingInt(HKEY hkey, TCHAR szKeyName[], LONG nDefault);
BOOL GetSettingBool(HKEY hkey, TCHAR szKeyName[], BOOL nDefault);
LONG GetSettingStr(HKEY hkey, TCHAR szKeyName[], TCHAR szDefault[], TCHAR szReturnStr[], DWORD nSize);
LONG GetSettingBinary(HKEY hkey, TCHAR szKeyName[], void *buf, ULONG nNumBytes);
LONG WriteSettingInt(HKEY hkey, TCHAR szKeyName[], LONG nValue);
LONG WriteSettingBool(HKEY hkey, TCHAR szKeyName[], BOOL nValue);
LONG WriteSettingStr(HKEY hkey, TCHAR szKeyName[], TCHAR szString[]);
LONG WriteSettingBinary(HKEY hkey, TCHAR szKeyName[], void *buf, UINT nNumBytes);
#ifdef __cplusplus
}
#endif
#endif
|
97d418b1e84b2897dcd3d8ae34071c61659fdb78
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/boards/mips/pic32mx/pic32mx7mmb/src/pic32_usbdev.c
|
5c0af99c10022baf259cb14b3a5e7a5edca62712
|
[
"MIT-open-group",
"BSD-3-Clause",
"HPND-sell-variant",
"BSD-4-Clause-UC",
"LicenseRef-scancode-warranty-disclaimer",
"MIT-0",
"LicenseRef-scancode-bsd-atmel",
"LicenseRef-scancode-gary-s-brown",
"LicenseRef-scancode-proprietary-license",
"SunPro",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"LicenseRef-scancode-other-permissive",
"HPND",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"GPL-1.0-or-later",
"CC-BY-2.0",
"CC-BY-4.0"
] |
permissive
|
apache/nuttx
|
14519a7bff4a87935d94fb8fb2b19edb501c7cec
|
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
|
refs/heads/master
| 2023-08-25T06:55:45.822534
| 2023-08-23T16:03:31
| 2023-08-24T21:25:47
| 228,103,273
| 407
| 241
|
Apache-2.0
| 2023-09-14T18:26:05
| 2019-12-14T23:27:55
|
C
|
UTF-8
|
C
| false
| false
| 6,246
|
c
|
pic32_usbdev.c
|
/****************************************************************************
* boards/mips/pic32mx/pic32mx7mmb/src/pic32_usbdev.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
#include "pic32mx.h"
#include "pic32mx7mmb.h"
#if defined(CONFIG_PIC32MX_USBDEV)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* PIN NAME SIGNAL NOTES
* ---- ----------------------------- ------------ ----------------------
* 20 VBUSON/C1IN+/AN5/CN7/RB5 VBUSON To USB VBUS circuitry
* 43 C2IN+/AN3/CN5/RB3 USB_PGOOD Power good (low if bad)
*/
#define GPIO_USB_VBUSON (GPIO_INPUT|GPIO_PORTB|GPIO_PIN5)
#define GPIO_USB_PGOOD (GPIO_INPUT|GPIO_PORTB|GPIO_PIN3)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: pic32mx_usbdevinitialize
*
* Description:
* Called to configure the mini-A/B J5 on the Mikroelektronika PIC32MX7 MMB
* for the USB device
*
****************************************************************************/
void weak_function pic32mx_usbdevinitialize(void)
{
/* Connect the PHY to the USB mini-B port. Order and timing matter! */
pic32mx_configgpio(GPIO_USB_PGOOD);
/* Notes from the Sure Electronics sample code:
*
* "The USB specifications require that USB peripheral devices must never
* source current onto the Vbus pin. Additionally, USB peripherals should
* not source current on D+ or D- when the host/hub is not actively
* powering the Vbus line.
* When designing a self powered (as opposed to bus powered) USB
* peripheral device, the firmware should make sure not to turn on the
* USB module and D+ or D- pull up resistor unless Vbus is actively
* powered. Therefore, the firmware needs some means to detect when
* Vbus is being powered by the host.
* A 5V tolerant I/O pin can be connected to Vbus (through a resistor),
* and can be used to detect when Vbus is high (host actively powering),
* or low (host is shut down or otherwise not supplying power). The USB
* firmware can then periodically poll this I/O pin to know when it is
* okay to turn on the USB module/D+/D- pull up resistor. When designing
* a purely bus powered peripheral device, it is not possible to source
* current on D+ or D- when the host is not actively providing power on
* Vbus. Therefore, implementing this bus sense feature is optional. ..."
*/
#ifdef CONFIG_USBHOST
/* pic32mx_configgpio(GPIO_USB_VBUSON); */
#endif
/* "If the host PC sends a GetStatus (device) request, the firmware must
* respond and let the host know if the USB peripheral device is currently
* bus powered or self powered.
* See chapter 9 in the official USB specifications for details regarding
* this request. If the peripheral device is capable of being both self
* and bus powered, it should not return a hard coded value for this
* request.
* Instead, firmware should check if it is currently self or bus powered,
* and respond accordingly.
* If the hardware has been configured like demonstrated on the PICDEM FS
* USB Demo Board, an I/O pin can be polled to determine the
* currently selected power source. ..."
*/
#ifdef CONFIG_USB_PWRSENSE
/* pic32mx_configgpio(GPIO_USB_PWRSENSE); */
#endif
}
/****************************************************************************
* Name: pic32mx_usbpullup
*
* Description:
* If USB is supported and the board supports a pullup via GPIO (for USB
* software connect and disconnect), then the board software must provide
* pic32mx_usbpullup. See include/nuttx/usb/usbdev.h for additional
* description of this method. Alternatively, if no pull-up GPIO the
* following EXTERN can be redefined to be NULL.
*
****************************************************************************/
int pic32mx_usbpullup(struct usbdev_s *dev, bool enable)
{
/* The Mikroelektronika PIC32MX7 MMB does not have a USB pull-up */
return OK;
}
/****************************************************************************
* Name: pic32mx_usbsuspend
*
* Description:
* Board logic must provide the pic32mx_usbsuspend logic if the USBDEV
* driver is used.
* This function is called whenever the USB enters or leaves
* suspend mode. This is an opportunity for the board logic to shutdown
* clocks, power, etc. while the USB is suspended.
*
****************************************************************************/
void pic32mx_usbsuspend(struct usbdev_s *dev, bool resume)
{
/* Do nothing */
}
#endif /* CONFIG_PIC32MX_USBDEV */
|
db7fa47974050dbc8fdbfe3470bff57c7491fb48
|
cb174161b8855fed9780aae7a59ae75a81abe585
|
/contrib/pgspider_core_fdw/deparse.c
|
8b4113eebf9d14b52630655597c1fa8d850b7041
|
[
"PostgreSQL"
] |
permissive
|
pgspider/pgspider
|
1a58de2c85955d47ed12e4b101534f37fb23e513
|
4f59708ea58d6825c731325db38c2532fbbb82d9
|
refs/heads/master
| 2023-07-25T19:16:12.543972
| 2023-07-11T02:31:14
| 2023-07-11T02:31:14
| 236,634,576
| 160
| 15
|
NOASSERTION
| 2023-07-11T02:31:15
| 2020-01-28T01:31:36
|
C
|
UTF-8
|
C
| false
| false
| 23,687
|
c
|
deparse.c
|
/*-------------------------------------------------------------------------
*
* deparse.c
* FDW deparsing module for pgspider_core_fdw
*
* Portions Copyright (c) 2018, TOSHIBA CORPORATION
*
* IDENTIFICATION
* contrib/pgspider_core_fdw/deparse.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "postgres_fdw/postgres_fdw.h"
#include "stdbool.h"
#include "access/htup_details.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include "parser/parsetree.h"
#include "catalog/pg_namespace.h"
#include "utils/lsyscache.h"
#include "pgspider_core_fdw_defs.h"
#include "catalog/pg_type.h"
#include "nodes/nodeFuncs.h"
#include "utils/builtins.h"
#include "pgspider_core_fdw.h"
/* List of stable function with star argument of InfluxDB */
static const char *InfluxDBStableStarFunction[] = {
"influx_count_all",
"influx_mode_all",
"influx_max_all",
"influx_min_all",
"influx_sum_all",
"integral_all",
"mean_all",
"median_all",
"spread_all",
"stddev_all",
"first_all",
"last_all",
"percentile_all",
"sample_all",
"abs_all",
"acos_all",
"asin_all",
"atan_all",
"atan2_all",
"ceil_all",
"cos_all",
"cumulative_sum_all",
"derivative_all",
"difference_all",
"elapsed_all",
"exp_all",
"floor_all",
"ln_all",
"log_all",
"log2_all",
"log10_all",
"moving_average_all",
"non_negative_derivative_all",
"non_negative_difference_all",
"pow_all",
"round_all",
"sin_all",
"sqrt_all",
"tan_all",
"chande_momentum_oscillator_all",
"exponential_moving_average_all",
"double_exponential_moving_average_all",
"kaufmans_efficiency_ratio_all",
"kaufmans_adaptive_moving_average_all",
"triple_exponential_moving_average_all",
"triple_exponential_derivative_all",
"relative_strength_index_all",
NULL
};
/* List of stable function with regular expression argument of InfluxDB */
static const char *InfluxDBStableRegexFunction[] = {
"percentile",
"sample",
"top",
"cumulative_sum",
"derivative",
"difference",
"elapsed",
"moving_average",
"non_negative_derivative",
"non_negative_difference",
"chande_momentum_oscillator",
"exponential_moving_average",
"double_exponential_moving_average",
"kaufmans_efficiency_ratio",
"kaufmans_adaptive_moving_average",
"triple_exponential_moving_average",
"triple_exponential_derivative",
"relative_strength_index",
NULL
};
/* List of stable agg function with regular expression argument of InfluxDB */
static const char *InfluxDBStableRegexAgg[] = {
"influx_count",
"influx_max",
"influx_min",
"influx_mode",
"influx_sum",
"integral",
"mean",
"median",
"spread",
"stddev",
"first",
"last",
NULL
};
/* List of stable function with constant argument of GridDB */
static const char *GridDBStableConstArgFunction[] = {
"time_next",
"time_next_only",
"time_prev",
"time_prev_only",
NULL
};
/* List of functions return record of griddb */
static const char *GridDBReturnRecordFunctions[] = {
"time_next",
"time_next_only",
"time_prev",
"time_prev_only",
"time_interpolated",
"max_rows",
"min_rows",
"time_sampling",
NULL
};
/* List mysql aggregation stub function */
static const char *MysqlAggregateStubFunction[] = {
"bit_xor",
"group_concat",
"std",
NULL
};
/*
* Global context for foreign_expr_walker's search of an expression tree.
*/
typedef struct foreign_glob_cxt
{
PlannerInfo *root; /* global planner state */
RelOptInfo *foreignrel; /* the foreign relation we are planning for */
bool hasAggref; /* this flag is used to detect if __spd_url is
* inside Aggref function */
int node_num; /* number of child node */
} foreign_glob_cxt;
/*
* Local (per-tree-level) context for foreign_expr_walker's search.
* This is concerned with identifying collations used in the expression.
*/
typedef enum
{
FDW_COLLATE_NONE, /* expression is of a noncollatable type, or
* it has default collation that is not
* traceable to a foreign Var */
FDW_COLLATE_SAFE, /* collation derives from a foreign Var */
FDW_COLLATE_UNSAFE /* collation is non-default and derives from
* something other than a foreign Var */
} FDWCollateState;
typedef struct foreign_loc_cxt
{
Oid collation; /* OID of current collation, if any */
FDWCollateState state; /* state of current collation choice */
} foreign_loc_cxt;
/* Local function forward declarations */
static bool having_clause_tree_walker(Node *node, void *param);
/*
* Prevent push down of T_Param(Subquery Expressions) which PGSpider cannot bind
*/
static bool
is_valid_type(Oid type)
{
switch (type)
{
case BOOLOID:
return false;
case INT2OID:
case INT4OID:
case INT8OID:
case OIDOID:
case FLOAT4OID:
case FLOAT8OID:
case NUMERICOID:
case VARCHAROID:
case TEXTOID:
case TIMEOID:
case TIMESTAMPOID:
case TIMESTAMPTZOID:
return true;
default:
elog(WARNING, "Found an unexpected case when check Param type. In default pushdown this case to PGSpider");
return true;
}
}
/*
* spd_is_regex_argument
*
* Return true if argument of function is regular expression for InfluxDB
*/
static bool
spd_is_regex_argument(Const *node)
{
Oid typoutput;
bool typIsVarlena;
const char *extval;
const char *first;
const char *last;
getTypeOutputInfo(node->consttype, &typoutput, &typIsVarlena);
extval = OidOutputFunctionCall(typoutput, node->constvalue);
first = extval;
last = extval + strlen(extval) - 1;
/* Check regex */
if (*first == '/' && *last == '/')
return true;
else
return false;
}
/*
* Check if expression is safe to push down to remote fdw, and return true if so.
*
* This function was created based on deparse.c of other fdw.
* TODO: This function is maybe missing some type of expression.
* It should be added more later.
*
*/
static bool
foreign_expr_walker(Node *node,
foreign_glob_cxt *glob_cxt,
foreign_loc_cxt *outer_cxt)
{
foreign_loc_cxt inner_cxt;
/* Need do nothing for empty subexpressions */
if (node == NULL)
return true;
/* Set up inner_cxt for possible recursion to child nodes */
inner_cxt.collation = InvalidOid;
inner_cxt.state = FDW_COLLATE_NONE;
switch (nodeTag(node))
{
case T_Var:
{
Var *var = (Var *) node;
char *colname;
RangeTblEntry *rte;
/* The case of whole row. */
if (var->varattno == 0)
return false;
rte = planner_rt_fetch(var->varno, glob_cxt->root);
colname = get_attname(rte->relid, var->varattno, false);
/* Don't pushed down __spd_url if it is inside Aggref */
if (glob_cxt->hasAggref && strcmp(colname, SPDURL) == 0)
return false;
break;
}
case T_Aggref:
{
Aggref *aggref = (Aggref *) node;
char *funcname = NULL;
ListCell *lc;
/* Get function name */
funcname = get_func_name(aggref->aggfnoid);
/*
* Pushdown DISTINCT inside aggregate in single node model for
* mysql stub aggregate function
*/
if (aggref->aggdistinct != NIL)
{
if (IS_SPD_MULTI_NODES(glob_cxt->node_num))
{
return false;
}
else if (strcmp(funcname, "count") && !exist_in_string_list(funcname, MysqlAggregateStubFunction))
{
return false;
}
}
/* Set the flag if detected Aggref function */
glob_cxt->hasAggref = true;
/*
* Recurse to input args. Don't pushed down __spd_url.
*/
foreach(lc, aggref->args)
{
Node *n = (Node *) lfirst(lc);
/* If TargetEntry, extract the expression from it */
if (IsA(n, TargetEntry))
{
TargetEntry *tle = (TargetEntry *) n;
n = (Node *) tle->expr;
}
if (!foreign_expr_walker(n, glob_cxt, &inner_cxt))
{
/* Reset the flag for next recursive check */
glob_cxt->hasAggref = false;
return false;
}
}
/* Reset the flag for next recursive check */
glob_cxt->hasAggref = false;
/*
* The aggregate functions array_agg, json_agg, jsonb_agg,
* json_object_agg, jsonb_object_agg, as well as similar
* user-defined aggregate functions, produce meaningfully
* different result values depending on the order of the input
* values. It is hard to control the order of input value in
* PGSpider temp table. So, we change there aggregate
* functions to not pushdown to FDW
*/
if (strcmp(funcname, "array_agg") == 0 ||
strcmp(funcname, "json_agg") == 0 ||
strcmp(funcname, "jsonb_agg") == 0 ||
strcmp(funcname, "json_object_agg") == 0 ||
strcmp(funcname, "jsonb_object_agg") == 0)
{
if (IS_SPD_MULTI_NODES(glob_cxt->node_num))
return false;
}
if (strcmp(funcname, "string_agg") == 0 ||
strcmp(funcname, "xmlagg") == 0)
{
/*
* The aggregate functions string_agg, and xmlagg, are not
* pushdown to FDW when has ORDER BY
*/
if (aggref->aggorder != NIL)
return false;
/*
* The aggregate functions string_agg is not pushdown to
* FDW when the delimiter is not a constant.
*/
if (strcmp(funcname, "string_agg") == 0)
{
TargetEntry *tle = (TargetEntry *) lsecond(aggref->args);
Node *node = (Node *) tle->expr;
if (!IsA(node, Const))
return false;
}
}
if (IS_SPD_MULTI_NODES(glob_cxt->node_num))
{
/*
* Do not push down specific stub aggregate function for
* mysql remote
*/
if (exist_in_string_list(funcname, MysqlAggregateStubFunction))
return false;
/*
* Do not push down star regex function of InfluxDB when
* there are multiple nodes
*/
if (spd_is_stub_star_regex_function((Expr *) node))
return false;
}
break;
}
case T_List:
{
List *l = (List *) node;
ListCell *lc;
/*
* Recurse to component subexpressions.
*/
foreach(lc, l)
{
if (!foreign_expr_walker((Node *) lfirst(lc), glob_cxt, &inner_cxt))
return false;
}
break;
}
case T_FuncExpr:
{
FuncExpr *func = (FuncExpr *) node;
/*
* If having a single node, pushdown function expression. If
* it is regular expression function or star function of
* InfluxDB, pushdown function expression. Otherwise not
* pushdown.
*/
if ((func->funcformat == COERCE_EXPLICIT_CALL) && IS_SPD_MULTI_NODES(glob_cxt->node_num))
{
if (!spd_is_stub_star_regex_function((Expr *) node))
return false;
}
if (!foreign_expr_walker((Node *) func->args, glob_cxt, &inner_cxt))
return false;
break;
}
case T_OpExpr:
{
OpExpr *oe = (OpExpr *) node;
/*
* Recurse to input subexpressions.
*/
if (!foreign_expr_walker((Node *) oe->args, glob_cxt, &inner_cxt))
return false;
break;
}
case T_Param:
{
Param *p = (Param *) node;
/* Check type of T_Param(Subquery Expressions) */
if (!is_valid_type(p->paramtype))
return false;
break;
}
case T_BoolExpr:
{
BoolExpr *b = (BoolExpr *) node;
/*
* Recurse to input subexpressions.
*/
if (!foreign_expr_walker((Node *) b->args, glob_cxt, &inner_cxt))
return false;
break;
}
case T_FieldSelect:
{
/*
* Do not allow to push down when there are multiple nodes
*/
if (IS_SPD_MULTI_NODES(glob_cxt->node_num))
return false;
break;
}
case T_RowExpr:
{
/*
* Enable to support push down on Mysql
*/
break;
}
default:
break;
}
/* It looks OK */
return true;
}
bool
spd_is_foreign_expr(PlannerInfo *root, RelOptInfo *baserel, Expr *expr)
{
foreign_glob_cxt glob_cxt;
foreign_loc_cxt loc_cxt;
/*
* Check that the expression consists of nodes that are safe to execute
* remotely.
*/
glob_cxt.root = root;
glob_cxt.foreignrel = baserel;
glob_cxt.hasAggref = false;
glob_cxt.node_num = spd_get_node_num(baserel);
loc_cxt.collation = InvalidOid;
loc_cxt.state = FDW_COLLATE_NONE;
if (!foreign_expr_walker((Node *) expr, &glob_cxt, &loc_cxt))
return false;
return true;
}
/*
* Append a SQL string literal representing "val" to buf.
*/
void
spd_deparse_string_literal(StringInfo buf, const char *val)
{
const char *valptr;
/*
* Rather than making assumptions about the remote server's value of
* standard_conforming_strings, always use E'foo' syntax if there are any
* backslashes. This will fail on remote servers before 8.1, but those
* are long out of support.
*/
if (strchr(val, '\\') != NULL)
appendStringInfoChar(buf, ESCAPE_STRING_SYNTAX);
appendStringInfoChar(buf, '\'');
for (valptr = val; *valptr; valptr++)
{
char ch = *valptr;
if (SQL_STR_DOUBLE(ch, true))
appendStringInfoChar(buf, ch);
appendStringInfoChar(buf, ch);
}
appendStringInfoChar(buf, '\'');
}
/*
* having_clause_tree_walker
*
* Check if HAVING expression is safe to pass to child fdws.
*/
static bool
having_clause_tree_walker(Node *node, void *param)
{
/* Need do nothing for empty subexpression. */
if (node == NULL)
return false;
switch (nodeTag(node))
{
case T_Aggref:
{
/*
* Do not pass to child fdw when HAVING clause contains
* aggregate functions
*/
return true;
}
case T_FuncExpr:
case T_OpExpr:
{
List *args = NIL;
ListCell *lc;
if (IsA(node, FuncExpr))
args = ((FuncExpr *) node)->args;
else
args = ((OpExpr *) node)->args;
foreach(lc, args)
{
Expr *arg = (Expr *) lfirst(lc);
if (!(IsA(arg, BoolExpr) || IsA(arg, FuncExpr) || IsA(arg, List)))
{
if (!(IsA(arg, Aggref) || IsA(arg, Var) || IsA(arg, Const)))
return true;
}
}
break;
}
default:
break;
}
return expression_tree_walker(node, having_clause_tree_walker, (void *) param);
}
/*
* spd_is_having_safe
*
* Check every conditions whether expression
* is safe to pass to child FDW or not.
*/
bool
spd_is_having_safe(Node *node)
{
return (!having_clause_tree_walker(node, NULL));
}
/*
* order_by_walker
*
* Check if HAVING expression is safe to pass to child fdws.
*/
static bool
order_by_walker(Node *node, void *param)
{
/* Need do nothing for empty subexpression. */
if (node == NULL)
return false;
switch (nodeTag(node))
{
case T_Aggref:
{
Aggref *agg = (Aggref *) node;
if (agg->aggorder)
return true;
break;
}
default:
break;
}
return expression_tree_walker(node, order_by_walker, (void *) param);
}
/*
* spd_is_sorted
*
* Check if expression contains aggregation with ORDER BY
*/
bool
spd_is_sorted(Node *node)
{
return (order_by_walker(node, NULL));
}
/*
* Convert type OID + typmod info into a type name
*/
char *
spd_deparse_type_name(Oid type_oid, int32 typemod)
{
bits16 flags = FORMAT_TYPE_TYPEMOD_GIVEN;
return format_type_extended(type_oid, typemod, flags);
}
/*
* Deparse given constant value into buf.
*
* This function has to be kept in sync with ruleutils.c's get_const_expr.
* As for that function, showtype can be -1 to never show "::typename" decoration,
* or +1 to always show it, or 0 to show it only if the constant wouldn't be assumed
* to be the right type by default.
*/
void
spd_deparse_const(Const *node, StringInfo buf, int showtype)
{
Oid typoutput;
bool typIsVarlena;
char *extval;
bool isfloat = false;
bool needlabel;
if (node->constisnull)
{
appendStringInfoString(buf, "NULL");
if (showtype >= 0)
appendStringInfo(buf, "::%s",
spd_deparse_type_name(node->consttype,
node->consttypmod));
return;
}
getTypeOutputInfo(node->consttype,
&typoutput, &typIsVarlena);
extval = OidOutputFunctionCall(typoutput, node->constvalue);
switch (node->consttype)
{
case INT2OID:
case INT4OID:
case INT8OID:
case OIDOID:
case FLOAT4OID:
case FLOAT8OID:
case NUMERICOID:
{
/*
* No need to quote unless it's a special value such as 'NaN'.
* See comments in get_const_expr().
*/
if (strspn(extval, "0123456789+-eE.") == strlen(extval))
{
if (extval[0] == '+' || extval[0] == '-')
appendStringInfo(buf, "(%s)", extval);
else
appendStringInfoString(buf, extval);
if (strcspn(extval, "eE.") != strlen(extval))
isfloat = true; /* it looks like a float */
}
else
appendStringInfo(buf, "'%s'", extval);
}
break;
case BITOID:
case VARBITOID:
appendStringInfo(buf, "B'%s'", extval);
break;
case BOOLOID:
if (strcmp(extval, "t") == 0)
appendStringInfoString(buf, "true");
else
appendStringInfoString(buf, "false");
break;
default:
spd_deparse_string_literal(buf, extval);
break;
}
pfree(extval);
if (showtype < 0)
return;
/*
* For showtype == 0, append ::typename unless the constant will be
* implicitly typed as the right type when it is read in.
*
* XXX this code has to be kept in sync with the behavior of the parser,
* especially make_const.
*/
switch (node->consttype)
{
case BOOLOID:
case INT4OID:
case UNKNOWNOID:
needlabel = false;
break;
case NUMERICOID:
needlabel = !isfloat || (node->consttypmod >= 0);
break;
default:
needlabel = true;
break;
}
if (needlabel || showtype > 0)
appendStringInfo(buf, "::%s",
spd_deparse_type_name(node->consttype,
node->consttypmod));
}
/*
* Print the name of an operator.
*/
void
spd_deparse_operator_name(StringInfo buf, Form_pg_operator opform)
{
char *opname;
/* opname is not a SQL identifier, so we should not quote it. */
opname = NameStr(opform->oprname);
/* Print schema name only if it's not pg_catalog */
if (opform->oprnamespace != PG_CATALOG_NAMESPACE)
{
const char *opnspname;
opnspname = get_namespace_name(opform->oprnamespace);
/* Print fully qualified operator name. */
appendStringInfo(buf, "OPERATOR(%s.%s)",
quote_identifier(opnspname), opname);
}
else
{
/* Just print operator name. */
appendStringInfoString(buf, opname);
}
}
/*
* Return true if string existed in list of string
*/
bool
exist_in_string_list(char *str, const char **strlist)
{
int i;
for (i = 0; strlist[i]; i++)
{
if (strcmp(str, strlist[i]) == 0)
return true;
}
return false;
}
/*
* spd_is_stub_star_regex_function
*
* Return true if function is regular expression function or star function
*/
bool
spd_is_stub_star_regex_function(Expr *expr)
{
char *opername = NULL;
ListCell *lc;
/* Need do nothing for empty subexpressions */
if (expr == NULL)
return false;
switch (nodeTag(expr))
{
case T_Aggref:
{
Aggref *agg = (Aggref *) expr;
/* Get function name */
opername = get_func_name(agg->aggfnoid);
if ((strlen(opername) > 4) &&
(strcmp(opername + strlen(opername) - 4, "_all") == 0))
{
/* Check stable function with star argument of InfluxDB */
if (exist_in_string_list(opername, InfluxDBStableStarFunction))
return true;
}
foreach(lc, agg->args)
{
Node *n = (Node *) lfirst(lc);
/* If TargetEntry, extract the expression from it */
if (IsA(n, TargetEntry))
{
TargetEntry *tle = (TargetEntry *) n;
n = (Node *) tle->expr;
if (IsA(n, Const))
{
Const *arg = (Const *) n;
if (arg->consttype == TEXTOID && spd_is_regex_argument(arg))
return exist_in_string_list(opername, InfluxDBStableRegexAgg);
}
}
}
break;
}
case T_FuncExpr:
{
FuncExpr *fe = (FuncExpr *) expr;
/* Get function name */
opername = get_func_name(fe->funcid);
if ((strlen(opername) > 4) &&
(strcmp(opername + strlen(opername) - 4, "_all") == 0))
{
/* Check stable function with star argument of InfluxDB */
if (exist_in_string_list(opername, InfluxDBStableStarFunction))
return true;
}
/* Check stable function with constant argument of GridDB */
if (exist_in_string_list(opername, GridDBStableConstArgFunction))
return true;
if (list_length(fe->args) > 0)
{
ListCell *funclc;
Node *firstArg;
funclc = list_head(fe->args);
firstArg = (Node *) lfirst(funclc);
if (IsA(firstArg, Const))
{
Const *arg = (Const *) firstArg;
if (arg->consttype == TEXTOID && spd_is_regex_argument(arg))
return exist_in_string_list(opername, InfluxDBStableRegexFunction);
}
}
break;
}
default:
break;
}
return false;
}
/*
* Return true if tlist has star or regex function
*/
bool
spd_is_record_func(List *tlist)
{
ListCell *lc;
foreach(lc, tlist)
{
TargetEntry *tle = lfirst_node(TargetEntry, lc);
Oid funcid;
Oid returntype;
List *args;
char *opername;
if (IsA((Node *) tle->expr, FuncExpr))
{
funcid = ((FuncExpr *) tle->expr)->funcid;
returntype = ((FuncExpr *) tle->expr)->funcresulttype;
args = ((FuncExpr *) tle->expr)->args;
}
else if (IsA((Node *) tle->expr, Aggref))
{
funcid = ((Aggref *) tle->expr)->aggfnoid;
returntype = ((Aggref *) tle->expr)->aggtype;
args = ((Aggref *) tle->expr)->args;
}
else
return false;
if ((funcid >= FirstGenbkiObjectId && returntype == TEXTOID))
{
ListCell *funclc;
Node *firstArg;
opername = get_func_name(funcid);
/* Check stable function return record of GridDB */
if (exist_in_string_list(opername, GridDBReturnRecordFunctions))
return true;
/* check stable agg with regex argument of InfluxDB */
if (exist_in_string_list(opername, InfluxDBStableRegexAgg))
return true;
if (list_length(args) > 0)
{
funclc = list_head(args);
firstArg = (Node *) lfirst(funclc);
/* Check stable function with regex argument of InfluxDB */
if (IsA(firstArg, Const))
{
Const *arg = (Const *) firstArg;
if (spd_is_regex_argument(arg))
return exist_in_string_list(opername, InfluxDBStableRegexFunction);
}
}
if ((strlen(opername) > 4) &&
(strcmp(opername + strlen(opername) - 4, "_all") == 0))
{
/* Check stable function with star argument of InfluxDB */
if (exist_in_string_list(opername, InfluxDBStableStarFunction))
return true;
}
}
}
return false;
}
/* Examine each qual clause in input_conds, and classify them into two groups,
* which are returned as two lists:
* - remote_conds contains expressions that can be evaluated remotely
* - local_conds contains expressions that can't be evaluated remotely
*/
void
spd_classifyConditions(PlannerInfo *root,
RelOptInfo *baserel,
List *input_conds,
List **remote_conds,
List **local_conds)
{
ListCell *lc;
*remote_conds = NIL;
*local_conds = NIL;
foreach(lc, input_conds)
{
RestrictInfo *clause = (RestrictInfo *) lfirst(lc);
Expr *expr = (Expr *) clause->clause;
if (spd_expr_has_spdurl(root, (Node *) expr, NULL))
{
/*
* If it contains SPDURL, we append it to local_conds list.
* upper relation uses local_conds will be used to check whether it is safe or not.
*/
*local_conds = lappend(*local_conds, clause);
}
else
{
/* If it does not contain SPDURL, we append it to remote_conds list. */
*remote_conds = lappend(*remote_conds, clause);
}
}
}
/* Output join name for given join type */
const char *
spd_get_jointype_name(JoinType jointype)
{
switch (jointype)
{
case JOIN_INNER:
return "INNER";
case JOIN_LEFT:
return "LEFT";
case JOIN_RIGHT:
return "RIGHT";
case JOIN_FULL:
return "FULL";
default:
/* Shouldn't come here, but protect from buggy code. */
elog(ERROR, "unsupported join type %d", jointype);
}
/* Keep compiler happy */
return NULL;
}
|
0ceb69bff80f5c1e7df0b8134dd3efcce186fa91
|
e814383d36a10839104efaa4df277996ab220fa3
|
/3rd-party/romio341/mpi-io/set_size.c
|
c57256460c6fd5b9c46170db1f20c448100aad86
|
[
"mpich2",
"BSD-3-Clause-Open-MPI"
] |
permissive
|
open-mpi/ompi
|
a1d7483ae1d83dd8fd8ae3ee95e832e0a0ee04e3
|
1edfdb025c4450f694600083ad871cf06c8d45cd
|
refs/heads/main
| 2023-09-01T01:30:02.040705
| 2023-08-29T17:32:18
| 2023-08-29T17:32:18
| 24,107,001
| 2,008
| 973
|
NOASSERTION
| 2023-09-14T20:59:26
| 2014-09-16T16:08:30
|
C
|
UTF-8
|
C
| false
| false
| 2,987
|
c
|
set_size.c
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include "mpioimpl.h"
#ifdef HAVE_WEAK_SYMBOLS
#if defined(HAVE_PRAGMA_WEAK)
#pragma weak MPI_File_set_size = PMPI_File_set_size
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#pragma _HP_SECONDARY_DEF PMPI_File_set_size MPI_File_set_size
#elif defined(HAVE_PRAGMA_CRI_DUP)
#pragma _CRI duplicate MPI_File_set_size as PMPI_File_set_size
/* end of weak pragmas */
#elif defined(HAVE_WEAK_ATTRIBUTE)
int MPI_File_set_size(MPI_File fh, MPI_Offset size)
__attribute__ ((weak, alias("PMPI_File_set_size")));
#endif
/* Include mapping from MPI->PMPI */
#define MPIO_BUILD_PROFILING
#include "mpioprof.h"
#endif
/*@
MPI_File_set_size - Sets the file size
Input Parameters:
. fh - file handle (handle)
. size - size to truncate or expand file (nonnegative integer)
.N fortran
@*/
int MPI_File_set_size(MPI_File fh, MPI_Offset size)
{
int error_code;
ADIO_File adio_fh;
static char myname[] = "MPI_FILE_SET_SIZE";
MPI_Offset tmp_sz, max_sz, min_sz;
#ifdef MPI_hpux
int fl_xmpi;
HPMP_IO_START(fl_xmpi, BLKMPIFILESETSIZE, TRDTBLOCK, adio_fh, MPI_DATATYPE_NULL, -1);
#endif /* MPI_hpux */
ROMIO_THREAD_CS_ENTER();
adio_fh = MPIO_File_resolve(fh);
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
MPIO_CHECK_NOT_SEQUENTIAL_MODE(adio_fh, myname, error_code);
if (size < 0) {
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_ARG, "**iobadsize", 0);
error_code = MPIO_Err_return_file(adio_fh, error_code);
goto fn_exit;
}
MPIO_CHECK_WRITABLE(fh, myname, error_code);
/* --END ERROR HANDLING-- */
tmp_sz = size;
MPI_Allreduce(&tmp_sz, &max_sz, 1, ADIO_OFFSET, MPI_MAX, adio_fh->comm);
MPI_Allreduce(&tmp_sz, &min_sz, 1, ADIO_OFFSET, MPI_MIN, adio_fh->comm);
/* --BEGIN ERROR HANDLING-- */
if (max_sz != min_sz) {
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_ARG, "**notsame", 0);
error_code = MPIO_Err_return_file(adio_fh, error_code);
goto fn_exit;
}
/* --END ERROR HANDLING-- */
if (!ADIO_Feature(adio_fh, ADIO_SCALABLE_RESIZE)) {
/* rare stupid file systems (like NFS) need to carry out resize on all
* processes */
ADIOI_TEST_DEFERRED(adio_fh, "MPI_File_set_size", &error_code);
}
ADIO_Resize(adio_fh, size, &error_code);
/* TODO: what to do with error code? */
/* --BEGIN ERROR HANDLING-- */
if (error_code != MPI_SUCCESS)
error_code = MPIO_Err_return_file(adio_fh, error_code);
/* --END ERROR HANDLING-- */
#ifdef MPI_hpux
HPMP_IO_END(fl_xmpi, adio_fh, MPI_DATATYPE_NULL, -1);
#endif /* MPI_hpux */
fn_exit:
ROMIO_THREAD_CS_EXIT();
return error_code;
}
|
2c1c6584b2bdfdd623fda525573a83b65a59854e
|
d61b532db0d3e08818338cfaac530a1ced1ffe3b
|
/util/ceg/defaults/pseudo/C_ina_dnam.c
|
1d41b6bed5ce180b25b29bc19a29f38448a24bd6
|
[
"LicenseRef-scancode-other-permissive"
] |
permissive
|
davidgiven/ack
|
61049c7a8e95ff61a77b1edd3c22bb290720e276
|
db5a32c68c4a60ca26a3927a799ea662b5b2b0e5
|
refs/heads/default
| 2023-08-29T07:33:12.771205
| 2023-07-08T20:17:27
| 2023-07-08T20:17:27
| 37,686,316
| 376
| 74
|
NOASSERTION
| 2023-07-08T20:17:28
| 2015-06-18T21:33:42
|
C
|
UTF-8
|
C
| false
| false
| 127
|
c
|
C_ina_dnam.c
|
#define CODE_EXPANDER
#include <em.h>
#include "back.h"
void
C_ina_dnam( s)
char *s;
{
set_local_visible( extnd_name( s));
}
|
1b21014bdd7649cc0d379e7c70136669e20e641d
|
4c4deee160ee4a3056b2973f6202e5cbaafb5925
|
/tools/event-benchmark/event_worker.h
|
5f3a643bc8a7c667c0db00fe37bb8ef1f3e42a2a
|
[
"AGPL-3.0-or-later",
"AGPL-3.0-only",
"LGPL-3.0-only"
] |
permissive
|
open-io/oio-sds
|
b9bc7cec283838a59b83b5279cb181cded69034f
|
08abd65aac86e47cf324826487ab9b475e014938
|
refs/heads/master
| 2023-09-05T05:09:29.653325
| 2023-08-01T16:37:37
| 2023-08-31T16:05:19
| 32,169,193
| 663
| 121
|
MIT
| 2022-03-04T13:08:03
| 2015-03-13T17:06:25
|
Python
|
UTF-8
|
C
| false
| false
| 1,541
|
h
|
event_worker.h
|
/*
OpenIO SDS oio-event-benchmark
Copyright (C) 2017 OpenIO SAS, as part of OpenIO SDS
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OIO_SDS__tools__benchmark_event__event_worker_h
# define OIO_SDS__tools__benchmark_event__event_worker_h
/**
* Initialize event mechanism
*
* @addr event agent address or NULL if events disabled.
*
* @return 0 if KO, !=0 if OK
*/
GError* event_worker_init(const char *addr);
/**
* Destroy event mechanism
*/
void event_worker_destroy(void);
/**
* Send event to event agent. This function adds "when" token automatically.
*
* @event_type name of the event
* @url url event in json (this function will free it)
* @data_json data event in json (this function will free it)
*
* @return NULL if OK, or a GError describing the problem
*/
GError* event_worker_send(const char *event_type, struct oio_url_s *url,
GString *data_json);
#endif /* OIO_SDS__tools__benchmark_event__event_worker_h */
|
d8250011554b90520d20f992c8940a8514c46f23
|
7c857119fe1505b1d80d6e62969661c06dc1a2f4
|
/NetworkPkg/Ip6Dxe/Ip6NvData.h
|
eb36d7ed4cd58c2b77194c09a27291ad8dfe96a6
|
[
"BSD-2-Clause"
] |
permissive
|
CloverHackyColor/CloverBootloader
|
7042ca7dd6b513d22be591a295e49071ae1482ee
|
2711170df4f60b2ae5aa20add3e00f35cf57b7e5
|
refs/heads/master
| 2023-08-30T22:14:34.590134
| 2023-08-27T19:14:02
| 2023-08-27T19:14:02
| 205,810,121
| 4,734
| 770
|
BSD-2-Clause
| 2023-09-03T12:41:33
| 2019-09-02T08:22:14
|
C
|
UTF-8
|
C
| false
| false
| 2,081
|
h
|
Ip6NvData.h
|
/** @file
NVData structure used by the IP6 configuration component.
Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef _IP6_NV_DATA_H_
#define _IP6_NV_DATA_H_
#include <Guid/Ip6ConfigHii.h>
#define FORMID_MAIN_FORM 1
#define FORMID_MANUAL_CONFIG_FORM 2
#define FORMID_HEAD_FORM 3
#define IP6_POLICY_AUTO 0
#define IP6_POLICY_MANUAL 1
#define DAD_MAX_TRANSMIT_COUNT 10
#define KEY_INTERFACE_ID 0x101
#define KEY_MANUAL_ADDRESS 0x102
#define KEY_GATEWAY_ADDRESS 0x103
#define KEY_DNS_ADDRESS 0x104
#define KEY_SAVE_CHANGES 0x105
#define KEY_SAVE_CONFIG_CHANGES 0x106
#define KEY_IGNORE_CONFIG_CHANGES 0x107
#define KEY_GET_CURRENT_SETTING 0x108
#define HOST_ADDRESS_LABEL 0x9000
#define ROUTE_TABLE_LABEL 0xa000
#define GATEWAY_ADDRESS_LABEL 0xb000
#define DNS_ADDRESS_LABEL 0xc000
#define LABEL_END 0xffff
#define INTERFACE_ID_STR_MIN_SIZE 1
#define INTERFACE_ID_STR_MAX_SIZE 23
#define INTERFACE_ID_STR_STORAGE 25
#define IP6_STR_MAX_SIZE 40
#define ADDRESS_STR_MIN_SIZE 2
#define ADDRESS_STR_MAX_SIZE 255
///
/// IP6_CONFIG_IFR_NVDATA contains the IP6 configure
/// parameters for that NIC.
///
#pragma pack(1)
typedef struct {
UINT8 IfType; ///< interface type
UINT8 Padding[3];
UINT32 Policy; ///< manual or automatic
UINT32 DadTransmitCount; ///< dad transmits count
CHAR16 InterfaceId[INTERFACE_ID_STR_STORAGE]; ///< alternative interface id
CHAR16 ManualAddress[ADDRESS_STR_MAX_SIZE]; ///< IP addresses
CHAR16 GatewayAddress[ADDRESS_STR_MAX_SIZE]; ///< Gateway address
CHAR16 DnsAddress[ADDRESS_STR_MAX_SIZE]; ///< DNS server address
} IP6_CONFIG_IFR_NVDATA;
#pragma pack()
#endif
|
2101fdcf078af2cf5c2d21a7276e196b39a788a0
|
3195f36520cf39e7bb2f3f4455f354ce327302c2
|
/c/popcount.h
|
134b6b36819c6381f232fe4ccc0e2424e7ebab04
|
[
"Apache-2.0"
] |
permissive
|
racket/ChezScheme
|
d882355f22f91adbf2decfc0a39c9ce6fd2ac6c6
|
73b4ec3c21207a72d1e9cafee9cfb8e6c2e7d3e3
|
refs/heads/master
| 2023-09-04T21:08:27.269433
| 2023-09-01T23:33:53
| 2023-09-03T19:28:38
| 171,331,531
| 109
| 17
|
Apache-2.0
| 2023-08-22T22:35:31
| 2019-02-18T18:03:38
|
Scheme
|
UTF-8
|
C
| false
| false
| 743
|
h
|
popcount.h
|
#if __GNUC__ >= 5
static int Spopcount_32(U32 x)
{
return __builtin_popcount(x);
}
#else
static int Spopcount_32(U32 x)
{
/* http://bits.stephan-brumme.com/countBits.html */
/* count bits of each 2-bit chunk */
x = x - ((x >> 1) & 0x55555555);
/* count bits of each 4-bit chunk */
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
/* count bits of each 8-bit chunk */
x = x + (x >> 4);
/* mask out junk */
x &= 0xF0F0F0F;
/* add all four 8-bit chunks */
return (x * 0x01010101) >> 24;
}
#endif
#if ptr_bits == 32
static int Spopcount(uptr x)
{
return Spopcount_32((U32)x);
}
#elif ptr_bits == 64
static int Spopcount(uptr x)
{
return Spopcount_32((U32)(x & 0xFFFFFFFF)) + Spopcount_32((U32)(x >> 32));
}
#endif
|
41845bd39fee380b48bc3a61906f90e2dfbad6b5
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/sysutils/busybox/files/patch-editors_awk.c
|
487e6a5e1ff67b49abb8895cad251c806687c6d9
|
[
"BSD-2-Clause"
] |
permissive
|
freebsd/freebsd-ports
|
86f2e89d43913412c4f6b2be3e255bc0945eac12
|
605a2983f245ac63f5420e023e7dce56898ad801
|
refs/heads/main
| 2023-08-30T21:46:28.720924
| 2023-08-30T19:33:44
| 2023-08-30T19:33:44
| 1,803,961
| 916
| 918
|
NOASSERTION
| 2023-09-08T04:06:26
| 2011-05-26T11:15:35
| null |
UTF-8
|
C
| false
| false
| 411
|
c
|
patch-editors_awk.c
|
--- editors/awk.c.orig 2021-11-28 21:53:43 UTC
+++ editors/awk.c
@@ -3238,7 +3238,7 @@ static var *evaluate(node *op, var *res)
if (op1)
syntax_error("Too many arguments");
{
-#if RAND_MAX >= 0x7fffffff
+#if RAND_MAX >= 0x7ffffffd
uint32_t u = ((uint32_t)rand() << 16) ^ rand();
uint64_t v = ((uint64_t)rand() << 32) | u;
/* the above shift+or is optimized out on 32-bit arches */
|
37cc35aa2289514934bf4dd4dfb8a4f512198d21
|
75196819c910f3fd523f1a4d28e5d0fe12570ab1
|
/src/bdb53/util/db_sql_codegen/generate.c
|
6d2f7a5fadd0dd3b839661247a7dc666f3057ad8
|
[
"MIT",
"BSD-3-Clause",
"Sleepycat"
] |
permissive
|
gridcoin-community/Gridcoin-Research
|
889967579b5b05bcc3ae836697a0f173b5ae91ea
|
21414dd0f63c9a34060f7f762f08d1a52aeb9e87
|
refs/heads/development
| 2023-09-04T09:21:55.006935
| 2023-09-03T17:45:20
| 2023-09-03T17:45:20
| 23,332,350
| 292
| 117
|
MIT
| 2023-09-11T10:22:10
| 2014-08-25T23:41:04
|
HTML
|
UTF-8
|
C
| false
| false
| 53,548
|
c
|
generate.c
|
/*
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 2013 Oracle and/or its affiliates. All rights reserved.
*
*/
/*
* This compilation unit contains functions related to generating the
* storage layer implementation in "C".
*/
#include "generation.h"
static int header_indent_level = 0;
static int code_indent_level = 0;
static FILE *header_file; /* stream for generated include file */
static FILE *code_file; /* stream for generated bdb code */
#define SEPARATE_HEADER (header_file != code_file)
void generate_test(FILE *tfile, char *hfilename);
void generate_verification(FILE *vfile, char *hfilename);
static void check_constraints();
static void generate_config_defines();
static void generate_schema_structs();
static void generate_iteration_callback_typedefs();
static void generate_environment();
static void generate_db_creation_functions();
static void generate_db_removal_functions();
static void generate_insertion_functions();
static void generate_fetch_functions();
static void generate_deletion_functions();
static void generate_full_iterations();
static void generate_index_functions();
static void generate_initialization();
static void pr_header(char *, ...);
static void pr_header_comment(char *, ...);
static void pr_code(char *, ...);
static void pr_code_comment(char *, ...);
/*
* Emit a printf-formatted string into the main code file
*/
static void
pr_code(char *fmt, ...)
{
va_list ap;
char *s;
static int enable_indent = 1;
s = prepare_string(fmt,
enable_indent ? code_indent_level : 0,
0);
va_start(ap, fmt);
vfprintf(code_file, s, ap);
va_end(ap);
/*
* If the last char emitted was a newline, enable indentation
* for the next time.
*/
if (s[strlen(s) - 1] == '\n')
enable_indent = 1;
else
enable_indent = 0;
}
/*
* Emit a formatted comment into the main code file.
*/
static void
pr_code_comment(char *fmt, ...)
{
va_list ap;
char *s;
s = prepare_string(fmt, code_indent_level, 1);
va_start(ap, fmt);
vfprintf(code_file, s, ap);
va_end(ap);
}
/*
* Emit a printf-formatted string into the header file.
*/
static void
pr_header(char *fmt, ...)
{
va_list ap;
char *s;
static int enable_indent = 1;
s = prepare_string(fmt,
enable_indent ? header_indent_level : 0,
0);
va_start(ap, fmt);
vfprintf(header_file, s, ap);
va_end(ap);
/*
* if the last char emitted was a newline, enable indentation
* for the next time
*/
if (s[strlen(s) - 1] == '\n')
enable_indent = 1;
else
enable_indent = 0;
}
/*
* Emit a formatted comment into the header file.
*/
static void
pr_header_comment(char *fmt, ...)
{
va_list ap;
char *s;
s = prepare_string(fmt, header_indent_level, 1);
va_start(ap, fmt);
vfprintf(header_file, s, ap);
va_end(ap);
}
static void
generate_config_defines()
{
static char *cache_size_comment =
"Cache size constants, specified in a \n\
hint comment in the original DDL";
if (the_schema.environment.cache_size > 0) {
pr_header_comment(cache_size_comment);
pr_header("#define %s_CACHE_SIZE_GIGA %lu\n",
upcase_env_name(&the_schema.environment),
the_schema.environment.cache_size / GIGA);
pr_header("#define %s_CACHE_SIZE_BYTES %lu\n\n",
upcase_env_name(&the_schema.environment),
the_schema.environment.cache_size % GIGA);
}
}
static void
generate_environment()
{
static char *create_env_function_template_part1 =
" \n\
int create_%s_env(DB_ENV **envpp) \n\
{ \n\
int ret, flags; \n\
char *env_name = \"./%s\"; \n\
\n\
if ((ret = db_env_create(envpp, 0)) != 0) { \n\
fprintf(stderr, \"db_env_create: %%s\", db_strerror(ret)); \n\
return 1; \n\
} \n\
\n\
(*envpp)->set_errfile(*envpp, stderr); \n\
flags = DB_CREATE | DB_INIT_MPOOL %s; \n\
\n\
";
static char *create_env_function_template_part2 =
" \n\
if ((ret = (*envpp)->open(*envpp, env_name, flags, 0)) != 0) { \n\
(*envpp)->err(*envpp, ret, \"DB_ENV->open: %%s\", env_name); \n\
return 1; \n\
} \n\
return 0; \n\
} \n\
\n\
";
static char *set_cachesize_template =
" (*envpp)->set_cachesize(*envpp, \n\
%s_CACHE_SIZE_GIGA, \n\
%s_CACHE_SIZE_BYTES, 1); \n\
\n\
";
pr_code(create_env_function_template_part1,
the_schema.environment.name,
the_schema.environment.name,
the_schema.environment.transactional ?
" | DB_INIT_LOG | DB_INIT_TXN" :"");
if (the_schema.environment.cache_size > 0) {
pr_code(set_cachesize_template,
upcase_env_name(&the_schema.environment),
upcase_env_name(&the_schema.environment));
}
pr_code(create_env_function_template_part2);
if (SEPARATE_HEADER) {
pr_header_comment(
"The environment creation/initialization function");
pr_header("int create_%s_env(DB_ENV **envpp);\n\n",
the_schema.environment.name);
}
}
/*
* This entity operation functions is called by the entity iterator
* when generating the db creation functions.
*/
static void
db_create_enter_entop(ENTITY *e)
{
static char *create_db_template =
"int create_%s_database(DB_ENV *envp,%s DB **dbpp) \n\
{ \n\
return create_database(envp, %s, \"%s.db\", dbpp, \n\
DB_CREATE, %s, 0, %s); \n\
} \n\
\n\
";
pr_code(create_db_template, e->name,
e->transactional ? " DB_TXN *txn," : "",
e->transactional ? "txn" : "NULL",
e->name, e->dbtype,
(strcmp(e->dbtype, "DB_BTREE") == 0 ?
custom_comparator_for_type(e->primary_key->type) : "NULL"));
if (SEPARATE_HEADER)
pr_header(
"int create_%s_database(DB_ENV *envp,%s DB **dbpp);\n\n",
e->name,
e->transactional ? " DB_TXN *txn," : "");
}
static void
generate_db_creation_functions()
{
static char *comparator_function_comment =
"These are custom comparator functions for integer keys. They are \n\
needed to make integers sort well on little-endian architectures, \n\
such as x86. cf. discussion of btree comparators in 'Getting Started \n\
with Data Storage' manual.";
static char *comparator_functions =
"static int \n\
compare_int(DB *dbp, const DBT *a, const DBT *b) \n\
{ \n\
int ai, bi; \n\
\n\
memcpy(&ai, a->data, sizeof(int)); \n\
memcpy(&bi, b->data, sizeof(int)); \n\
return (ai - bi); \n\
} \n\
\n\
int \n\
compare_long(DB *dbp, const DBT *a, const DBT *b) \n\
{ \n\
long ai, bi; \n\
\n\
memcpy(&ai, a->data, sizeof(long)); \n\
memcpy(&bi, b->data, sizeof(long)); \n\
return (ai - bi); \n\
} \n\
\n\
";
static char *create_db_function_comment =
"A generic function for creating and opening a database";
static char *generic_create_db_function =
"int \n\
create_database(DB_ENV *envp, \n\
DB_TXN *txn, \n\
char *db_name, \n\
DB **dbpp, \n\
int flags, \n\
DBTYPE type, \n\
int moreflags, \n\
int (*comparator)(DB *, const DBT *, const DBT *)) \n\
{ \n\
int ret; \n\
FILE *errfilep; \n\
\n\
if ((ret = db_create(dbpp, envp, 0)) != 0) { \n\
envp->err(envp, ret, \"db_create\"); \n\
return ret; \n\
} \n\
\n\
if (moreflags != 0) \n\
(*dbpp)->set_flags(*dbpp, moreflags); \n\
\n\
if (comparator != NULL) \n\
(*dbpp)->set_bt_compare(*dbpp, comparator); \n\
\n\
envp->get_errfile(envp, &errfilep); \n\
(*dbpp)->set_errfile(*dbpp, errfilep); \n\
\n\
if ((ret = (*dbpp)->open(*dbpp, txn, db_name, \n\
NULL, type, flags, 0644)) != 0) \n\
(*dbpp)->err(*dbpp, ret, \"DB->open: %%s\", db_name); \n\
\n\
return ret; \n\
} \n\
\n\
";
pr_code_comment(comparator_function_comment);
pr_code(comparator_functions);
pr_code_comment(create_db_function_comment);
pr_code(generic_create_db_function);
pr_header_comment("Database creation/initialization functions");
iterate_over_entities(&db_create_enter_entop,
NULL,
NULL);
}
/*
* This entity operation function is called by the entity iterator
* when generating the db removal functions.
*/
static void
db_remove_enter_entop(ENTITY *e)
{
static char *remove_db_template =
" \n\
int remove_%s_database(DB_ENV *envp%s) \n\
{ \n\
return envp->dbremove(envp,%s, \"%s.db\", NULL, 0); \n\
} \n\
";
pr_code(remove_db_template, e->name,
e->transactional ? ", DB_TXN *txn" : "",
e->transactional ? " txn" : "NULL",
e->name);
if (SEPARATE_HEADER)
pr_header(
"int remove_%s_database(DB_ENV *envp%s);\n\n",
e->name,
e->transactional ? ", DB_TXN *txn" : "");
}
static void
generate_db_removal_functions() {
pr_header_comment("Database removal functions");
iterate_over_entities(&db_remove_enter_entop,
NULL,
NULL);
}
/*
* This group of entity and attribute operation functions are
* called by the attribute iterator when defining constants for any
* array type attributes.
*/
static void
array_dim_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
COMPQUIET(first, 0);
COMPQUIET(last, 0);
if (is_array(a->type))
pr_header("#define %s %d\n", array_dim_name(e, a),
a->type->array_dim);
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining structs
* corresponding to the entities.
*/
static void
structs_enter_entop(ENTITY *e)
{
pr_header("typedef struct _%s_data {\n", e->name);
header_indent_level++;
}
static void
structs_exit_entop(ENTITY *e)
{
header_indent_level--;
pr_header("} %s_data;\n\n", e->name);
pr_header("%s_data %s_data_specimen;\n\n", e->name, e->name);
}
static void
structs_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
COMPQUIET(first, 0);
COMPQUIET(last, 0);
pr_header("%s\t%s;\n", a->type->c_type, decl_name(e, a));
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining constants for
* serialized lengths of records.
*/
static void
serialized_length_enter_entop(ENTITY *e)
{
pr_header("#define %s (", serialized_length_name(e));
}
static void
serialized_length_exit_entop(ENTITY *e)
{
COMPQUIET(e, NULL);
pr_header(")\n\n");
}
static void
serialized_length_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
static char *sizeof_template = "%ssizeof(%s_data_specimen.%s)";
COMPQUIET(last, 0);
if (strcmp(e->primary_key->name, a->name) == 0)
pr_header("%s0", first ? "" : " + \\\n\t");
else
pr_header(sizeof_template, first ? "" : " + \\\n\t",
e->name, a->name);
}
/*
* Call the iterator twice, once for generating the array dimension
* #defines, and once for the structs.
*/
static void
generate_schema_structs()
{
pr_header_comment("Array size constants.");
/* Emit the array dimension definitions. */
iterate_over_entities(NULL,
NULL,
&array_dim_attrop);
pr_header_comment("Data structures representing the record layouts");
/* Emit the structs that represent the schema. */
iterate_over_entities(&structs_enter_entop,
&structs_exit_entop,
&structs_attrop);
pr_header_comment(
"Macros for the maximum length of the \n\
records after serialization. This is \n\
the maximum size of the data that is stored");
/* Emit the serialized length #defines. */
iterate_over_entities(&serialized_length_enter_entop,
&serialized_length_exit_entop,
&serialized_length_attrop);
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining the entity
* serialization functions.
*/
static void
serialize_function_enter_entop(ENTITY *e)
{
static char *header_template =
" \n\
int serialize_%s_data(%s_data *%sp, \n\
DBT *key_dbt";
static char *function_template=
" key_dbt->data = %s%sp->%s; \n\
key_dbt->size = ";
pr_code(header_template, e->name, e->name, e->name);
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head))
pr_code(
", \n\
char *buffer, \n\
DBT *data_dbt) \n\
{ \n\
size_t len; \n\
char *p; \n\
\n\
");
else
pr_code(")\n{\n");
pr_code(function_template,
is_array(e->primary_key->type) ? "" : "&",
e->name, e->primary_key->name);
if (is_array(e->primary_key->type) &&
!is_string(e->primary_key->type))
pr_code(array_dim_name(e, e->primary_key));
else
pr_code("%s(%sp->%s)%s",
is_string(e->primary_key->type) ? "strlen" : "sizeof",
e->name, e->primary_key->name,
is_string(e->primary_key->type) ? " + 1" : "");
pr_code(";\n");
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head))
pr_code(
" \n\
memset(buffer, 0, %s); \n\
p = buffer; \n\
",
serialized_length_name(e));
code_indent_level++;
}
static void
serialize_function_exit_entop(ENTITY *e)
{
code_indent_level--;
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head))
pr_code(
" \n\
data_dbt->data = buffer; \n\
data_dbt->size = p - buffer; \n\
");
pr_code("}\n");
}
static void
serialize_function_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
static char *copy_strlen_template =
" \n\
len = strlen(%sp->%s) + 1; \n\
assert(len <= %s); \n\
memcpy(p, %sp->%s, len); \n\
p += len; \n\
";
COMPQUIET(first, 0);
COMPQUIET(last, 0);
/* Primary key is not stored in data. */
if (strcmp(e->primary_key->name, a->name) != 0) {
/*
* For strings, we store only the length calculated by
* strlen.
*/
if (is_string(a->type)) {
pr_code(copy_strlen_template,
e->name, a->name,
array_dim_name(e, a),
e->name, a->name);
} else {
pr_code("memcpy(p, %s%sp->%s, sizeof(%sp->%s));\n",
is_array(a->type) ? "" : "&",
e->name, a->name, e->name, a->name);
pr_code("p += sizeof(%sp->%s);\n", e->name, a->name);
}
}
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining the entity
* deserialization functions.
*/
static void
deserialize_function_enter_entop(ENTITY *e)
{
static char *header_template =
" \n\
void deserialize_%s_data(char *buffer, %s_data *%sp) \n\
{ \n\
size_t len; \n\
";
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head)) {
pr_code(header_template, e->name, e->name, e->name,
e->name, e->name);
code_indent_level++;
}
}
static void
deserialize_function_exit_entop(ENTITY *e)
{
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head)) {
code_indent_level--;
pr_code("}\n");
}
}
static void
deserialize_function_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
/* strings are stored with null termination in the buffer */
static char *copy_strlen_template =
"\nlen = strlen(buffer) + 1; \n\
assert(len <= %s); \n\
memcpy(%sp->%s, buffer, len); \n\
buffer += len; \n\
";
COMPQUIET(first, 0);
COMPQUIET(last, 0);
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head)) {
if (strcmp(e->primary_key->name, a->name) != 0) {
if (is_string(a->type)) {
pr_code (copy_strlen_template,
array_dim_name(e, a),
e->name, a->name);
} else {
pr_code(
"\nmemcpy(%s%sp->%s, buffer, sizeof(%sp->%s));\n",
is_array(a->type)? "" : "&",
e->name, a->name, e->name, a->name);
pr_code("buffer += sizeof(%sp->%s);\n",
e->name, a->name);
}
}
}
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining the struct insertion
* functions.
*/
static void
insert_struct_function_enter_entop(ENTITY *e)
{
static char *header_template =
" \n\
int %s_insert_struct( DB *dbp, %s%s_data *%sp) \n\
{ \n\
DBT key_dbt, data_dbt; \n\
";
static char *initialization_template =
" int ret; \n\
%s %s%s_key = %sp->%s; \n\
\n\
memset(&key_dbt, 0, sizeof(key_dbt)); \n\
memset(&data_dbt, 0, sizeof(data_dbt)); \n\
\n\
serialize_%s_data(%sp, &key_dbt";
static char *function_template =
" \n\
if ((ret = dbp->put(dbp, %s, &key_dbt, &data_dbt, 0)) != 0) { \n\
dbp->err(dbp, ret, \"Inserting key %s\", %s_key); \n\
return -1; \n\
} \n\
return 0; \n\
} \n\
\n\
";
pr_code(header_template, e->name,
e->transactional ? "DB_TXN *txn, " : "",
e->name, e->name);
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head))
pr_code(" char serialized_data[%s];\n",
serialized_length_name(e));
pr_code(initialization_template,
e->primary_key->type->c_type,
is_array(e->primary_key->type)? "*" : "",
e->name, e->name,
e->primary_key->name,
e->name, e->name);
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head))
pr_code(", serialized_data, &data_dbt");
pr_code(");\n");
pr_code(function_template,
e->transactional ? "txn" : "NULL",
is_array(e->primary_key->type) ? "%s" : "%d",
e->name);
if (SEPARATE_HEADER)
pr_header(
"int %s_insert_struct(DB *dbp, %s%s_data *%sp);\n\n",
e->name,
e->transactional ? "DB_TXN *txn, " : "",
e->name, e->name);
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining the field insertion
* functions.
*/
static void
insert_fields_list_args_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
/*
* This is an extra attribute operation called by
* insert_fields_enter_entop to produce the arguments to the
* function it defines.
*/
COMPQUIET(e, NULL);
COMPQUIET(first, 0);
if (SEPARATE_HEADER) {
pr_header("%s %s%s", a->type->c_type,
is_array(a->type)? "*" : "",
a->name);
if (!last) pr_header(",\n");
}
}
/*
* This is an extra attribute operation called by
* insert_fields_enter_entop to produce the arguments to the
* function it defines.
*/
static void
insert_fields_declare_args_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
COMPQUIET(e, NULL);
COMPQUIET(first, 0);
pr_code("%s %s%s", a->type->c_type,
is_array(a->type)? "*" : "",
a->name);
if (!last)
pr_code(",\n");
else
pr_code(")\n");
}
static void
insert_fields_function_enter_entop(ENTITY *e)
{
if (SEPARATE_HEADER)
pr_header(
"int %s_insert_fields(DB * dbp%s,\n",
e->name,
e->transactional ? ", DB_TXN *txn" : "");
pr_code("int %s_insert_fields(DB *dbp%s,\n",
e->name,
e->transactional ? ", DB_TXN *txn" : "");
code_indent_level+=3; /* push them way over */
header_indent_level+=3;
iterate_over_attributes(e, &insert_fields_list_args_attrop);
if (SEPARATE_HEADER)
pr_header(");\n\n");
code_indent_level-=2; /* drop back to +1 */
header_indent_level -= 3;
iterate_over_attributes(e, &insert_fields_declare_args_attrop);
code_indent_level--;
pr_code("{\n");
code_indent_level++;
pr_code("%s_data data;\n", e->name);
}
static void
insert_fields_function_exit_entop(ENTITY *e)
{
pr_code("return %s_insert_struct(dbp, %s&data);\n",
e->name,
e->transactional ? "txn, " : "");
code_indent_level--;
pr_code("}\n\n");
}
static void
insert_fields_function_attrop(ENTITY *e, ATTRIBUTE *a, int first, int last)
{
COMPQUIET(first, 0);
COMPQUIET(last, 0);
if (is_string(a->type)) {
pr_code("assert(strlen(%s) < %s);\n", a->name,
array_dim_name(e, a));
pr_code("strncpy(data.%s, %s, %s);\n",
a->name, a->name, array_dim_name(e, a));
} else if (is_array(a->type)) {
pr_code("memcpy(data.%s, %s, %s);\n",
a->name, a->name, array_dim_name(e, a));
} else
pr_code("data.%s = %s;\n", a->name, a->name);
}
static void
generate_insertion_functions()
{
/* Generate the serializer functions for each entity. */
iterate_over_entities(&serialize_function_enter_entop,
&serialize_function_exit_entop,
&serialize_function_attrop);
/* Generate the de-serializer functions for each entity. */
iterate_over_entities(&deserialize_function_enter_entop,
&deserialize_function_exit_entop,
&deserialize_function_attrop);
/* Generate the struct insertion functions for each entity. */
if (SEPARATE_HEADER)
pr_header_comment(
"Functions for inserting records by providing \n\
the full corresponding data structure"
);
iterate_over_entities(&insert_struct_function_enter_entop,
NULL,
NULL);
/* Generate the field insertion functions for each entity. */
if (SEPARATE_HEADER)
pr_header_comment(
"Functions for inserting records by providing \n\
each field value as a separate argument"
);
iterate_over_entities(&insert_fields_function_enter_entop,
&insert_fields_function_exit_entop,
&insert_fields_function_attrop);
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining the simple fetch
* by key functions.
*/
static void
fetch_function_enter_entop(ENTITY *e)
{
static char *header_template =
" \n\
int get_%s_data(DB *dbp, %s \n\
%s %s%s_key, \n\
%s_data *data) \n\
{ \n\
DBT key_dbt, data_dbt; \n\
int ret; \n\
%s %scanonical_key = %s_key; \n\
\n\
memset(&key_dbt, 0, sizeof(key_dbt)); \n\
memset(&data_dbt, 0, sizeof(data_dbt)); \n\
memset(data, 0, sizeof(%s_data)); \n\
\n\
key_dbt.data = %scanonical_key; \n\
key_dbt.size = ";
static char *function_template =
" \n\
if ((ret = dbp->get(dbp, %s, &key_dbt, &data_dbt, 0)) != 0) { \n\
dbp->err(dbp, ret, \"Retrieving key %s\", %s_key); \n\
return ret; \n\
} \n\
\n\
assert(data_dbt.size <= %s); \n\
memcpy(&data->%s, key_dbt.data, sizeof(data->%s)); \n\
";
pr_code(header_template, e->name,
e->transactional ? "DB_TXN *txn," : "",
e->primary_key->type->c_type,
is_array(e->primary_key->type) ? "*" : "",
e->name, e->name, e->primary_key->type->c_type,
is_array(e->primary_key->type) ? "*" : "",
e->name, e->name,
is_array(e->primary_key->type) ? "" : "&");
if (is_array(e->primary_key->type) && !is_string(e->primary_key->type))
pr_code(array_dim_name(e, e->primary_key));
else
pr_code("%s(canonical_key)%s",
is_string(e->primary_key->type) ? "strlen" : "sizeof",
is_string(e->primary_key->type) ? " + 1" : "");
pr_code(";\n");
pr_code(function_template,
e->transactional ? "txn" : "NULL",
is_array(e->primary_key->type) ? "%s" : "%d",
e->name,
serialized_length_name(e),
e->primary_key->name,
e->primary_key->name);
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head))
pr_code(" deserialize_%s_data(data_dbt.data, data);\n",
e->name);
else
pr_code(" assert(data_dbt.size == 0);\n");
pr_code(
" \n\
return 0; \n\
} \n\
");
if (SEPARATE_HEADER)
pr_header(
"int get_%s_data(DB *dbp, %s%s %s%s_key, %s_data *data);\n\n",
e->name,
e->transactional ? "DB_TXN *txn, " : "",
e->primary_key->type->c_type,
is_array(e->primary_key->type) ? "*" : "",
e->name, e->name);
}
static void
generate_fetch_functions()
{
if (SEPARATE_HEADER)
pr_header_comment("Functions for retrieving records by key");
iterate_over_entities(&fetch_function_enter_entop,
NULL,
NULL);
}
/*
* This next group of entity and attribute operation functions are
* called by the attribute iterator when defining the simple deletion
* by primary key functions.
*/
static void
deletion_function_enter_entop(ENTITY *e)
{
static char *header_template =
" \n\
int delete_%s_key(DB *dbp, %s%s %s%s_key) \n\
{ \n\
DBT key_dbt; \n\
int ret; \n\
%s %scanonical_key = %s_key; \n\
\n\
memset(&key_dbt, 0, sizeof(key_dbt)); \n\
\n\
key_dbt.data = %scanonical_key; \n\
key_dbt.size = ";
static char *method_template =
" \n\
if ((ret = dbp->del(dbp, %s, &key_dbt, 0)) != 0) { \n\
dbp->err(dbp, ret, \"deleting key %s\", %s_key); \n\
return ret; \n\
} \n\
\n\
return 0; \n\
} \n\
\n\
";
pr_code(header_template, e->name,
e->transactional ? "DB_TXN *txn, " : "",
e->primary_key->type->c_type,
is_array(e->primary_key->type) ? "*" : "",
e->name, e->primary_key->type->c_type,
is_array(e->primary_key->type) ? "*" : "",
e->name,
is_array(e->primary_key->type) ? "" : "&");
if (is_array(e->primary_key->type) && !is_string(e->primary_key->type))
pr_code(array_dim_name(e, e->primary_key));
else
pr_code("%s(canonical_key)%s",
is_string(e->primary_key->type) ? "strlen" : "sizeof",
is_string(e->primary_key->type) ? " + 1" : "");
pr_code(";\n");
pr_code(method_template,
e->transactional ? "txn" : "NULL",
is_array(e->primary_key->type) ? "%s" : "%d", e->name);
if (SEPARATE_HEADER)
pr_header(
"int delete_%s_key(DB *dbp, %s%s %s%s_key);\n\n",
e->name,
e->transactional ? "DB_TXN *txn, " : "",
e->primary_key->type->c_type,
is_array(e->primary_key->type) ? "*" : "",
e->name);
}
static void
generate_deletion_functions()
{
if (SEPARATE_HEADER)
pr_header_comment("Functions for deleting records by key");
iterate_over_entities(&deletion_function_enter_entop,
NULL,
NULL);
}
/*
* This entity operation function is called by the attribute iterator when
* producing header code that declares the global primary database pointers.
*/
static void
declare_extern_database_pointers_enter_entop(ENTITY *e)
{
pr_header("extern DB *%s_dbp;\n", e->name);
}
/*
* This entity operation function is called by the attribute iterator
* when producing code that defines the global primary database
* pointers.
*/
static void
declare_database_pointers_enter_entop(ENTITY *e)
{
pr_code("DB *%s_dbp = NULL;\n", e->name);
}
/*
* This index operation function is called by the attribute iterator when
* producing header code that declares the global secondary database pointers.
*/
static void
declare_extern_secondary_pointers_idxop(DB_INDEX *idx)
{
pr_header("extern DB *%s_dbp;\n", idx->name);
}
/*
* This index operation function is called by the attribute iterator when
* producing code that defines the global secondary database pointers.
*/
static void
declare_secondary_pointers_idxop(DB_INDEX *idx)
{
pr_code("DB *%s_dbp = NULL;\n", idx->name);
}
/*
* This entity operation function is called by the attribute iterator
* when producing initialization code that creates the primary databases.
*/
static void
create_database_enter_entop(ENTITY *e)
{
pr_code(
" \n\
if (create_%s_database(%s_envp, %s%s&%s_dbp) != 0) \n\
goto exit_error; \n\
",
e->name, the_schema.environment.name,
e->transactional ? the_schema.environment.name : "",
e->transactional ? "_txnp, " : "",
e->name);
}
/*
* This index operation function is called by the attribute iterator when
* producing initialization code that creates the secondary databases.
*/
static void
create_secondary_idxop(DB_INDEX *idx)
{
pr_code(
" \n\
if (create_%s_secondary(%s_envp, %s%s%s_dbp, &%s_dbp) != 0) \n\
goto exit_error; \n\
",
idx->name, the_schema.environment.name,
idx->primary->transactional ? the_schema.environment.name : "",
idx->primary->transactional ? "_txnp, " : "",
idx->primary->name, idx->name);
}
static void
generate_secondary_key_callback_function(DB_INDEX *idx)
{
static char *secondary_key_callback_template =
" \n\
int %s_callback(DB *dbp, \n\
const DBT *key_dbt, \n\
const DBT *data_dbt, \n\
DBT *secondary_key_dbt) \n\
{ \n\
int ret; \n\
%s_data deserialized_data; \n\
\n\
memcpy(&deserialized_data.%s, key_dbt->data, key_dbt->size); \n\
deserialize_%s_data(data_dbt->data, &deserialized_data); \n\
\n\
memset(secondary_key_dbt, 0, sizeof(DBT)); \n\
secondary_key_dbt->size = %s(deserialized_data.%s)%s; \n\
secondary_key_dbt->data = malloc(secondary_key_dbt->size); \n\
memcpy(secondary_key_dbt->data, %sdeserialized_data.%s, \n\
secondary_key_dbt->size); \n\
\n\
/* tell the caller to free memory referenced by secondary_key_dbt */ \n\
secondary_key_dbt->flags = DB_DBT_APPMALLOC; \n\
\n\
return 0; \n\
} \n\
";
pr_code(secondary_key_callback_template,
idx->name, idx->primary->name,
idx->primary->primary_key->name,
idx->primary->name,
is_string(idx->attribute->type) ? "strlen" : "sizeof",
idx->attribute->name,
is_string(idx->attribute->type) ? " + 1" : "",
is_array(idx->attribute->type) ? "" : "&",
idx->attribute->name);
}
static void
generate_index_creation_function(DB_INDEX *idx)
{
static char *index_creation_function_template =
" \n\
int create_%s_secondary(DB_ENV *envp, %s \n\
DB *primary_dbp, \n\
DB **secondary_dbpp) \n\
{ \n\
int ret; \n\
char * secondary_name = \"%s.db\"; \n\
\n\
if ((ret = create_database(envp, %s, secondary_name, secondary_dbpp, \n\
DB_CREATE, %s, DB_DUPSORT, %s)) != 0) \n\
return ret; \n\
\n\
if ((ret = primary_dbp->associate(primary_dbp, %s, *secondary_dbpp, \n\
&%s_callback, DB_CREATE)) != 0) { \n\
(*secondary_dbpp)->err(*secondary_dbpp, ret, \n\
\"DB->associate: %%s.db\", secondary_name); \n\
return ret; \n\
} \n\
return 0; \n\
} \n\
";
pr_code(index_creation_function_template,
idx->name,
idx->primary->transactional ? "DB_TXN *txn," : "",
idx->name,
idx->primary->transactional ? "txn" : "NULL",
idx->dbtype,
custom_comparator_for_type(idx->attribute->type),
idx->primary->transactional ? "txn" : "NULL",
idx->name);
if (SEPARATE_HEADER)
pr_header(
"int create_%s_secondary(DB_ENV *envp, %sDB *dbpp, \
DB **secondary_dbpp);\n\n",
idx->name,
idx->primary->transactional ? "DB_TXN *txn, " : "");
}
static void
generate_index_removal_function(DB_INDEX *idx)
{
pr_code(
" \n\
int remove_%s_index(DB_ENV *envp%s) \n\
{ \n\
return envp->dbremove(envp, %s, \"%s.db\", NULL, 0); \n\
} \n\
",
idx->name,
idx->primary->transactional ? ", DB_TXN *txn" : "",
idx->primary->transactional ? "txn" : "NULL",
idx->name);
if (SEPARATE_HEADER)
pr_header(
"int remove_%s_index(DB_ENV * envp%s);\n\n",
idx->name,
idx->primary->transactional ? ", DB_TXN *txn" : "");
}
static void
generate_index_query_iteration(DB_INDEX *idx)
{
static char *query_iteration_template =
" \n\
int %s_query_iteration(DB *secondary_dbp, %s \n\
%s %s%s_key, \n\
%s_iteration_callback user_func, \n\
void *user_data) \n\
{ \n\
DBT key_dbt, pkey_dbt, data_dbt; \n\
DBC *cursorp; \n\
%s_data deserialized_data; \n\
int flag = DB_SET; \n\
int ret; \n\
\n\
memset(&key_dbt, 0, sizeof(key_dbt)); \n\
memset(&pkey_dbt, 0, sizeof(pkey_dbt)); \n\
memset(&data_dbt, 0, sizeof(data_dbt)); \n\
\n\
if ((ret = secondary_dbp->cursor(secondary_dbp, %s, &cursorp, 0)) != 0) { \n\
secondary_dbp->err(secondary_dbp, ret, \"creating cursor\"); \n\
return ret; \n\
} \n\
\n\
key_dbt.data = %s%s_key; \n\
key_dbt.size = %s(%s_key)%s; \n\
\n\
while ((ret = cursorp->pget(cursorp, &key_dbt, &pkey_dbt, &data_dbt, flag)) \n\
== 0) { \n\
memcpy(&deserialized_data.%s, pkey_dbt.data, \n\
sizeof(deserialized_data.%s)); \n\
deserialize_%s_data(data_dbt.data, &deserialized_data); \n\
(*user_func)(user_data, &deserialized_data); \n\
if (flag == DB_SET) \n\
flag = DB_NEXT_DUP; \n\
} \n\
\n\
if (ret != DB_NOTFOUND) { \n\
secondary_dbp->err(secondary_dbp, ret, \"Querying secondary\"); \n\
return ret; \n\
} \n\
\n\
cursorp->close(cursorp); \n\
\n\
return 0; \n\
} \n\
";
pr_code(query_iteration_template,
idx->name,
idx->primary->transactional ? "DB_TXN *txn," : "",
idx->attribute->type->c_type,
is_array(idx->attribute->type) ? "*" : "",
idx->name,
idx->primary->name, idx->primary->name,
idx->primary->transactional ? "txn" : "NULL",
is_array(idx->attribute->type) ? "" : "&",
idx->name,
is_string(idx->attribute->type) ? "strlen" : "sizeof",
idx->name,
is_string(idx->attribute->type) ? " + 1" : "",
idx->primary->primary_key->name,
idx->primary->primary_key->name,
idx->primary->name);
if (SEPARATE_HEADER)
pr_header(
"int %s_query_iteration(DB *secondary_dbp, %s \n\
%s %s%s_key, \n\
%s_iteration_callback user_func, \n\
void *user_data);\n\n",
idx->name,
idx->primary->transactional ? "DB_TXN *txn, " : "",
idx->attribute->type->c_type,
is_array(idx->attribute->type) ? "*" : "",
idx->name, idx->primary->name);
}
static void
index_function_idxop(DB_INDEX *idx)
{
generate_secondary_key_callback_function(idx);
generate_index_creation_function(idx);
generate_index_removal_function(idx);
generate_index_query_iteration(idx);
}
static void
generate_index_functions() {
if (SEPARATE_HEADER)
pr_header_comment("Index creation and removal functions");
iterate_over_indexes(&index_function_idxop);
}
/*
* Emit the prototype of the user's callback into the header file.
*/
static void
generate_iteration_callback_typedef_enter_entop(ENTITY *e)
{
pr_header(
"typedef void (*%s_iteration_callback)(void *, %s_data *);\n\n",
e->name, e->name);
}
static void
generate_iteration_callback_typedefs()
{
pr_header_comment(
"These typedefs are prototypes for the user-written \n\
iteration callback functions, which are invoked during \n\
full iteration and secondary index queries"
);
iterate_over_entities(&generate_iteration_callback_typedef_enter_entop,
NULL,
NULL);
}
static void
generate_full_iteration_enter_entop(ENTITY *e)
{
static char *full_iteration_template =
" \n\
int %s_full_iteration(DB *dbp, %s \n\
%s_iteration_callback user_func, \n\
void *user_data) \n\
{ \n\
DBT key_dbt, data_dbt; \n\
DBC *cursorp; \n\
%s_data deserialized_data; \n\
int ret; \n\
\n\
memset(&key_dbt, 0, sizeof(key_dbt)); \n\
memset(&data_dbt, 0, sizeof(data_dbt)); \n\
\n\
if ((ret = dbp->cursor(dbp, %s, &cursorp, 0)) != 0) { \n\
dbp->err(dbp, ret, \"creating cursor\"); \n\
return ret; \n\
} \n\
\n\
while ((ret = cursorp->get(cursorp, &key_dbt, &data_dbt, DB_NEXT)) == 0) { \n\
memcpy(&deserialized_data.%s, key_dbt.data, sizeof(deserialized_data.%s));\n\
";
static char *dispose_template =
" (*user_func)(user_data, &deserialized_data); \n\
} \n\
\n\
if (ret != DB_NOTFOUND) { \n\
dbp->err(dbp, ret, \"Full iteration\"); \n\
cursorp->close(cursorp); \n\
return ret; \n\
} \n\
\n\
cursorp->close(cursorp); \n\
\n\
return 0; \n\
} \n\
";
pr_code(full_iteration_template,
e->name,
e->transactional ? "DB_TXN *txn," : "",
e->name, e->name,
e->transactional ? "txn" : "NULL",
e->primary_key->name,
e->primary_key->name);
if ((e->attributes_head != e->attributes_tail) ||
(e->primary_key != e->attributes_head))
pr_code(
" deserialize_%s_data(data_dbt.data, &deserialized_data);\n",
e->name);
else
pr_code(" assert(data_dbt.size == 0);\n");
pr_code(dispose_template);
if (SEPARATE_HEADER)
pr_header(
"int %s_full_iteration(DB *dbp, %s \n\
%s_iteration_callback user_func, \n\
void *user_data);\n\n",
e->name,
e->transactional ? "DB_TXN *txn," : "",
e->name);
}
static void
generate_full_iterations()
{
if (SEPARATE_HEADER)
pr_header_comment(
"Functions for doing iterations over \n\
an entire primary database");
iterate_over_entities(&generate_full_iteration_enter_entop,
NULL,
NULL);
}
static void
generate_initialization()
{
if (SEPARATE_HEADER) {
pr_header_comment(
"This convenience method invokes all of the \n\
environment and database creation methods necessary \n\
to initialize the complete BDB environment. It uses \n\
the global environment and database pointers declared \n\
below. You may bypass this function and use your own \n\
environment and database pointers, if you wish.");
pr_header("int initialize_%s_environment();\n",
the_schema.environment.name);
}
pr_header("\nextern DB_ENV * %s_envp;\n", the_schema.environment.name);
if (the_schema.environment.transactional)
pr_header("\nextern DB_TXN * %s_txnp;\n",
the_schema.environment.name);
iterate_over_entities(&declare_extern_database_pointers_enter_entop,
NULL,
NULL);
pr_code("\nDB_ENV * %s_envp = NULL;\n", the_schema.environment.name);
if (the_schema.environment.transactional)
pr_code("DB_TXN * %s_txnp = NULL;\n",
the_schema.environment.name);
iterate_over_entities(&declare_database_pointers_enter_entop,
NULL,
NULL);
iterate_over_indexes(&declare_extern_secondary_pointers_idxop);
iterate_over_indexes(&declare_secondary_pointers_idxop);
pr_code(
" \n\
int initialize_%s_environment() \n\
{ \n\
if (create_%s_env(&%s_envp) != 0) \n\
goto exit_error; \n\
",
the_schema.environment.name,
the_schema.environment.name,
the_schema.environment.name);
code_indent_level++;
if (the_schema.environment.transactional) {
pr_code("\n%s_envp->txn_begin(%s_envp, NULL, &%s_txnp, 0);\n",
the_schema.environment.name,
the_schema.environment.name,
the_schema.environment.name);
}
iterate_over_entities(&create_database_enter_entop,
NULL,
NULL);
iterate_over_indexes(&create_secondary_idxop);
pr_code ("\nreturn 0;\n\n");
code_indent_level--;
pr_code("exit_error:\n");
code_indent_level++;
pr_code(
" \n\
fprintf(stderr, \"Stopping initialization because of error\\n\"); \n\
return -1; \n\
");
code_indent_level--;
pr_code("}\n");
}
static void
check_pk_constraint_enter_entop(ENTITY *e)
{
if (e->primary_key == NULL) {
fprintf(stderr,
"The table \"%s\" (defined near line %d) lacks a \
primary key, which is not allowed. All tables must have a designated \
primary key.\n",
e->name, e->line_number);
exit(1);
}
}
static void
check_constraints()
{
iterate_over_entities(&check_pk_constraint_enter_entop,
NULL, NULL);
}
/*
* Generate is the sole entry point to this module. It orchestrates
* the generation of the C code for the storage layer and for the
* smoke test.
*/
void generate(hfile, cfile, tfile, vfile, hfilename)
FILE *hfile, *cfile, *tfile, *vfile;
char *hfilename;
{
static char *header_intro_comment =
"Header file for a Berkeley DB implementation \n\
generated from SQL DDL by db_sql";
static char *include_stmts =
"#include <sys/types.h> \n\
#include <sys/stat.h> \n\
#include <assert.h> \n\
#include <errno.h> \n\
#include <stdlib.h> \n\
#include <string.h> \n\
#include \"db.h\" \n\
\n";
header_file = hfile;
code_file = cfile;
check_constraints();
if (SEPARATE_HEADER)
pr_header_comment(header_intro_comment);
pr_header(include_stmts);
if (SEPARATE_HEADER)
pr_code("#include \"%s\"\n\n", hfilename);
generate_config_defines();
generate_schema_structs();
generate_iteration_callback_typedefs();
generate_environment();
generate_db_creation_functions();
generate_db_removal_functions();
generate_insertion_functions();
generate_fetch_functions();
generate_deletion_functions();
generate_full_iterations();
generate_index_functions();
generate_initialization();
if (tfile != NULL)
generate_test(tfile, hfilename);
if (vfile != NULL)
generate_verification(vfile, hfilename);
}
|
0dafd93e5b58d41e84038e428fd17d01b46da49d
|
060bc5ba9a8f707bdac927f30842febf9a4676a1
|
/sys/tahoe/math/Kfp.h
|
b78a4067dc078341e6d7bc53bb97b9c3720ccf20
|
[
"BSD-4-Clause-UC",
"LicenseRef-scancode-other-permissive"
] |
permissive
|
sergev/LiteBSD
|
14ae93caa709d4707c3b122c243641c8214583c3
|
6f89c18880065a83d3d18661c80f72fb3397a888
|
refs/heads/master
| 2023-01-10T02:20:05.357875
| 2022-07-19T16:41:32
| 2022-07-19T16:41:32
| 19,167,171
| 318
| 58
|
NOASSERTION
| 2022-12-28T16:23:01
| 2014-04-26T02:55:34
|
C
|
UTF-8
|
C
| false
| false
| 3,098
|
h
|
Kfp.h
|
/*-
* Copyright (c) 1985 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Computer Consoles Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)Kfp.h 7.1 (Berkeley) 12/6/90
*/
/*
* Opcodes to be emulated by kernel software.
*/
#define CVLF 0x76
#define CVLD 0x77
#define CVFL 0x86
#define CVDL 0x87
#define LDFD 0x97
#define CVDF 0xa6
#define ADDF 0xc6
#define ADDD 0xc7
#define SUBF 0xd6
#define SUBD 0xd7
#define MULF 0xe6
#define MULD 0xe7
#define DIVF 0xf6
#define DIVD 0xf7
#define SINF 0x05
#define COSF 0x15
#define ATANF 0x25
#define LOGF 0x35
#define SQRTF 0x45
#define EXPF 0x55
/* HFS bits: */
#define HFS_UNDF 0x008 /* float underflow */
#define HFS_OVF 0x004 /* float overflow */
#define HFS_RANGE 0x8000 /* set u_error to ERANGE */
#define HFS_DOM 0x4000 /* set u_error to EDOM */
#define HFS_DIVZ 0x2000 /* divide by zero flag */
/* destination types for the f.p. opcodes: */
#define LONG 01
#define FLOAT 02
#define DOUBLE 03
/* exceptions: */
#define OVF_EXC 0x003 /* floating overflow */
#define UNDF_EXC 0x004 /* floating underflow */
#define DIV0_EXC 0x005 /* floating divide by 0 */
|
009aeb2721515a35e707697a15aac09269fc525b
|
060c02561085a494df306deb2f3a8fddb984c73a
|
/inc/xrdoptdefs.h
|
9bf5f69fb11dbc0e6af88b7d2ab4112784f19477
|
[
"MIT"
] |
permissive
|
Interlisp/maiko
|
48631ae6abc9d98d5c3eeb5f5eb736adf400ea8f
|
7fce08f92c221bcb98e5f6d560aa50cb942e95b3
|
refs/heads/master
| 2023-09-03T12:23:43.081470
| 2023-08-09T21:04:51
| 2023-08-09T21:04:51
| 279,184,900
| 110
| 33
|
MIT
| 2023-09-13T14:49:28
| 2020-07-13T02:00:09
|
C
|
UTF-8
|
C
| false
| false
| 132
|
h
|
xrdoptdefs.h
|
#ifndef XRDOPTDEFS_H
#define XRDOPTDEFS_H 1
void print_Xusage(const char *prog);
void read_Xoption(int *argc, char *argv[]);
#endif
|
a898c6279c129dda703a57e7e50ffef036a4156a
|
cb9ab2e6b33f0befa99543c9501108641501500e
|
/IsoLib/libisomediafile/src/TrackFragmentRunAtom.c
|
5cda94cfbc688be5517b1d4a58bba7c93e7a8f5a
|
[] |
no_license
|
MPEGGroup/isobmff
|
3401d5022d9bf0bfe3fc860c8fe53e83b66021d2
|
2a0e1a3690efb4553defca31caf347013f1eb9e1
|
refs/heads/master
| 2023-08-10T19:09:28.069852
| 2022-11-08T15:18:52
| 2022-11-08T15:18:52
| 118,715,054
| 101
| 37
| null | 2023-08-30T18:48:42
| 2018-01-24T05:07:44
|
C
|
UTF-8
|
C
| false
| false
| 7,557
|
c
|
TrackFragmentRunAtom.c
|
/*
This software module was originally developed by Apple Computer, Inc.
in the course of development of MPEG-4.
This software module is an implementation of a part of one or
more MPEG-4 tools as specified by MPEG-4.
ISO/IEC gives users of MPEG-4 free license to this
software module or modifications thereof for use in hardware
or software products claiming conformance to MPEG-4.
Those intending to use this software module in hardware or software
products are advised that its use may infringe existing patents.
The original developer of this software module and his/her company,
the subsequent editors and their companies, and ISO/IEC have no
liability for use of this software module or modifications thereof
in an implementation.
Copyright is not released for non MPEG-4 conforming
products. Apple Computer, Inc. retains full right to use the code for its own
purpose, assign or donate the code to a third party and to
inhibit third parties from using the code for non
MPEG-4 conforming products.
This copyright notice must be included in all copies or
derivative works. Copyright (c) 1999.
*/
/*
$Id: TrackFragmentRunAtom.c,v 1.1.1.1 2002/09/20 08:53:35 julien Exp $
*/
#include "MP4Atoms.h"
#include <stdlib.h>
static void destroy(MP4AtomPtr s)
{
MP4TrackRunAtomPtr self = (MP4TrackRunAtomPtr)s;
if(self == NULL) return;
if(self->entries)
{
free(self->entries);
self->entries = NULL;
}
if(self->super) self->super->destroy(s);
}
static void calculateDefaults(struct MP4TrackRunAtom *self, MP4TrackFragmentHeaderAtomPtr tfhd,
u32 flags_index)
{
MP4TrackRunEntryPtr entry;
if(self->samplecount == 0) return;
entry = self->entries;
if(tfhd->default_sample_duration == 0) tfhd->default_sample_duration = entry->sample_duration;
if(tfhd->default_sample_size == 0) tfhd->default_sample_size = entry->sample_size;
if((tfhd->default_sample_flags == 0) && (self->samplecount >= flags_index))
tfhd->default_sample_flags = entry[flags_index - 1].sample_flags;
}
static void setFlags(struct MP4TrackRunAtom *self, MP4TrackFragmentHeaderAtomPtr tfhd)
{
u32 flags;
u32 i;
MP4TrackRunEntryPtr entry;
flags = 0;
if(self->data_offset != 0) flags |= trun_data_offset_present;
entry = self->entries;
self->first_sample_flags = entry->sample_flags;
if(entry->sample_flags != tfhd->default_sample_flags) flags |= trun_first_sample_flags_present;
for(i = 0, entry = self->entries; i < self->samplecount; i++, entry++)
{
if(entry->sample_duration != tfhd->default_sample_duration)
flags |= trun_sample_duration_present;
if(entry->sample_size != tfhd->default_sample_size) flags |= trun_sample_size_present;
if((i > 0) && (entry->sample_flags != tfhd->default_sample_flags))
flags = (flags & ~trun_first_sample_flags_present) | trun_sample_flags_present;
if(entry->sample_composition_time_offset != 0) flags |= trun_sample_composition_times_present;
if((flags & trun_all_sample_flags) == trun_all_sample_flags) break;
}
self->flags = flags;
}
static MP4Err serialize(struct MP4Atom *s, char *buffer)
{
MP4Err err;
u32 flags;
u32 i;
MP4TrackRunEntryPtr entry;
MP4TrackRunAtomPtr self = (MP4TrackRunAtomPtr)s;
err = MP4NoErr;
flags = self->flags;
err = MP4SerializeCommonFullAtomFields((MP4FullAtomPtr)s, buffer);
if(err) goto bail;
buffer += self->bytesWritten;
PUT32(samplecount);
if(flags & trun_data_offset_present)
{
PUT32(data_offset);
};
if(flags & trun_first_sample_flags_present)
{
PUT32(first_sample_flags);
};
for(i = 0, entry = self->entries; i < self->samplecount; i++, entry++)
{
if(flags & trun_sample_duration_present)
{
PUT32_V(entry->sample_duration);
};
if(flags & trun_sample_size_present)
{
PUT32_V(entry->sample_size);
};
if(flags & trun_sample_flags_present)
{
PUT32_V(entry->sample_flags);
};
if(flags & trun_sample_composition_times_present)
{
PUT32_V(entry->sample_composition_time_offset);
};
}
assert(self->bytesWritten == self->size);
bail:
TEST_RETURN(err);
return err;
}
static MP4Err calculateSize(struct MP4Atom *s)
{
MP4Err err;
u32 flags;
u32 entry_size;
MP4TrackRunAtomPtr self = (MP4TrackRunAtomPtr)s;
err = MP4NoErr;
flags = self->flags;
entry_size = 0;
err = MP4CalculateFullAtomFieldSize((MP4FullAtomPtr)s);
if(err) goto bail;
self->size += 4;
if(flags & trun_data_offset_present) self->size += 4;
if(flags & trun_first_sample_flags_present) self->size += 4;
if(flags & trun_sample_duration_present) entry_size += 4;
if(flags & trun_sample_size_present) entry_size += 4;
if(flags & trun_sample_flags_present) entry_size += 4;
if(flags & trun_sample_composition_times_present) entry_size += 4;
self->size += entry_size * self->samplecount;
bail:
TEST_RETURN(err);
return err;
}
static int bitcount(int v)
{
unsigned int c; /* c accumulates the total bits set in v */
for(c = 0; v; c++)
{
v &= v - 1; /* clear the least significant bit set */
}
return c;
}
static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStreamPtr inputStream)
{
MP4Err err;
u32 flags;
u32 i;
MP4TrackRunEntryPtr entry;
MP4TrackRunAtomPtr self = (MP4TrackRunAtomPtr)s;
u32 field_count, record_count, r, junk;
err = MP4NoErr;
if(self == NULL) BAILWITHERROR(MP4BadParamErr)
err = self->super->createFromInputStream(s, proto, (char *)inputStream);
if(err) goto bail;
flags = self->flags;
GET32(samplecount);
self->entries = (MP4TrackRunEntry *)calloc(self->samplecount, sizeof(MP4TrackRunEntry));
field_count = bitcount(flags & 0xFF);
record_count = bitcount(flags & 0xFF00);
if(flags & trun_data_offset_present)
{
GET32(data_offset);
field_count--;
};
if(flags & trun_first_sample_flags_present)
{
GET32(first_sample_flags);
field_count--;
};
while(field_count > 0)
{
GET32_V(junk);
field_count--;
}
for(i = 0, entry = self->entries; i < self->samplecount; i++, entry++)
{
r = record_count;
if(flags & trun_sample_duration_present)
{
GET32_V_MSG((entry->sample_duration), "duration");
r--;
};
if(flags & trun_sample_size_present)
{
GET32_V_MSG((entry->sample_size), "size");
r--;
};
if(flags & trun_sample_flags_present)
{
GET32_V_MSG((entry->sample_flags), "flags");
r--;
};
if(flags & trun_sample_composition_times_present)
{
GET32_V_MSG((entry->sample_composition_time_offset), "comp offset");
r--;
};
while(r > 0)
{
GET32_V(junk);
r--;
}
}
bail:
TEST_RETURN(err);
return err;
}
MP4Err MP4CreateTrackRunAtom(MP4TrackRunAtomPtr *outAtom)
{
MP4Err err;
MP4TrackRunAtomPtr self;
self = (MP4TrackRunAtomPtr)calloc(1, sizeof(MP4TrackRunAtom));
TESTMALLOC(self)
err = MP4CreateFullAtom((MP4AtomPtr)self);
if(err) goto bail;
self->type = MP4TrackRunAtomType;
self->name = "track fragment run";
self->flags = 0;
self->createFromInputStream = (cisfunc)createFromInputStream;
self->destroy = destroy;
self->calculateSize = calculateSize;
self->serialize = serialize;
self->setFlags = setFlags;
self->calculateDefaults = calculateDefaults;
*outAtom = self;
bail:
TEST_RETURN(err);
return err;
}
|
a4642ee2b253269ce1fa0b074f73ca519268cdbf
|
65089dbc386e1184983c15fe3a2282763ae65960
|
/gear-lib/librbtree/librbtree.c
|
336348715e90ea1204acb87bd9f551e760cd08bd
|
[
"MIT"
] |
permissive
|
gozfree/gear-lib
|
9f4db1bce799ded1cf1f3411cb51bdfbcbe7c7bc
|
bffbfd25af4ff7b04ebfafdab391b55270b0273e
|
refs/heads/master
| 2023-08-14T16:01:29.449910
| 2023-07-24T16:08:47
| 2023-07-24T16:09:41
| 40,359,871
| 1,771
| 488
|
MIT
| 2023-05-27T11:08:46
| 2015-08-07T12:41:05
|
C
|
UTF-8
|
C
| false
| false
| 23,009
|
c
|
librbtree.c
|
/******************************************************************************
* Copyright (C) 2014-2020 Zhifeng Gong <gozfree@163.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
/*
* red-black trees properties: http://en.wikipedia.org/wiki/Rbtree
*
* 1) A node is either red or black
* 2) The root is black
* 3) All leaves (NULL) are black
* 4) Both children of every red node are black
* 5) Every simple path from root to leaves contains the same number
* of black nodes.
*
* 4 and 5 give the O(log n) guarantee, since 4 implies you cannot have two
* consecutive red nodes in a path and every red node is therefore followed by
* a black. So if B is the number of black nodes on every simple path (as per
* 5), then the longest possible path due to 4 is 2B.
*
* We shall indicate color with case, where black nodes are uppercase and red
* nodes will be lowercase. Unknown color nodes shall be drawn as red within
* parentheses and have some accompanying text comment.
*/
#include <stdio.h>
#include <stdlib.h>
#include "librbtree.h"
#define RB_RED 0
#define RB_BLACK 1
#define __rb_parent(pc) ((struct rb_node *)(pc & ~3))
#define __rb_color(pc) ((pc) & 1)
#define __rb_is_black(pc) __rb_color(pc)
#define __rb_is_red(pc) (!__rb_color(pc))
#define rb_color(rb) __rb_color((rb)->__rb_parent_color)
#define rb_is_red(rb) __rb_is_red((rb)->__rb_parent_color)
#define rb_is_black(rb) __rb_is_black((rb)->__rb_parent_color)
static inline void rb_set_black(struct rb_node *rb)
{
rb->__rb_parent_color |= RB_BLACK;
}
static inline struct rb_node *rb_red_parent(struct rb_node *red)
{
return (struct rb_node *)red->__rb_parent_color;
}
static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
{
rb->__rb_parent_color = rb_color(rb) | (unsigned long)p;
}
static inline void rb_set_parent_color(struct rb_node *rb,
struct rb_node *p, int color)
{
rb->__rb_parent_color = (unsigned long)p | color;
}
static inline void
__rb_change_child(struct rb_node *old, struct rb_node *_new,
struct rb_node *parent, struct rb_root *root)
{
if (parent) {
if (parent->rb_left == old)
parent->rb_left = _new;
else
parent->rb_right = _new;
} else
root->rb_node = _new;
}
/*
* Helper function for rotations:
* - old's parent and color get assigned to new
* - old gets assigned new as a parent and 'color' as a color.
*/
static inline void
__rb_rotate_set_parents(struct rb_node *old, struct rb_node *_new,
struct rb_root *root, int color)
{
struct rb_node *parent = rb_parent(old);
_new->__rb_parent_color = old->__rb_parent_color;
rb_set_parent_color(old, _new, color);
__rb_change_child(old, _new, parent, root);
}
#ifdef __ANDROID__
static void
#else
static __always_inline void
#endif
__rb_insert(struct rb_node *node, struct rb_root *root,
void (*augment_rotate)(struct rb_node *old, struct rb_node *_new))
{
struct rb_node *parent = rb_red_parent(node), *gparent, *tmp;
while (1) {
/*
* Loop invariant: node is red
*
* If there is a black parent, we are done.
* Otherwise, take some corrective action as we don't
* want a red root or two consecutive red nodes.
*/
if (!parent) {
rb_set_parent_color(node, NULL, RB_BLACK);
break;
} else if (rb_is_black(parent))
break;
gparent = rb_red_parent(parent);
tmp = gparent->rb_right;
if (parent != tmp) { /* parent == gparent->rb_left */
if (tmp && rb_is_red(tmp)) {
/*
* Case 1 - color flips
*
* G g
* / \ / \
* p u --> P U
* / /
* n N
*
* However, since g's parent might be red, and
* 4) does not allow this, we need to recurse
* at g.
*/
rb_set_parent_color(tmp, gparent, RB_BLACK);
rb_set_parent_color(parent, gparent, RB_BLACK);
node = gparent;
parent = rb_parent(node);
rb_set_parent_color(node, parent, RB_RED);
continue;
}
tmp = parent->rb_right;
if (node == tmp) {
/*
* Case 2 - left rotate at parent
*
* G G
* / \ / \
* p U --> n U
* \ /
* n p
*
* This still leaves us in violation of 4), the
* continuation into Case 3 will fix that.
*/
parent->rb_right = tmp = node->rb_left;
node->rb_left = parent;
if (tmp)
rb_set_parent_color(tmp, parent,
RB_BLACK);
rb_set_parent_color(parent, node, RB_RED);
augment_rotate(parent, node);
parent = node;
tmp = node->rb_right;
}
/*
* Case 3 - right rotate at gparent
*
* G P
* / \ / \
* p U --> n g
* / \
* n U
*/
gparent->rb_left = tmp; /* == parent->rb_right */
parent->rb_right = gparent;
if (tmp)
rb_set_parent_color(tmp, gparent, RB_BLACK);
__rb_rotate_set_parents(gparent, parent, root, RB_RED);
augment_rotate(gparent, parent);
break;
} else {
tmp = gparent->rb_left;
if (tmp && rb_is_red(tmp)) {
/* Case 1 - color flips */
rb_set_parent_color(tmp, gparent, RB_BLACK);
rb_set_parent_color(parent, gparent, RB_BLACK);
node = gparent;
parent = rb_parent(node);
rb_set_parent_color(node, parent, RB_RED);
continue;
}
tmp = parent->rb_left;
if (node == tmp) {
/* Case 2 - right rotate at parent */
parent->rb_left = tmp = node->rb_right;
node->rb_right = parent;
if (tmp)
rb_set_parent_color(tmp, parent,
RB_BLACK);
rb_set_parent_color(parent, node, RB_RED);
augment_rotate(parent, node);
parent = node;
tmp = node->rb_left;
}
/* Case 3 - left rotate at gparent */
gparent->rb_right = tmp; /* == parent->rb_left */
parent->rb_left = gparent;
if (tmp)
rb_set_parent_color(tmp, gparent, RB_BLACK);
__rb_rotate_set_parents(gparent, parent, root, RB_RED);
augment_rotate(gparent, parent);
break;
}
}
}
/*
* Inline version for rb_erase() use - we want to be able to inline
* and eliminate the dummy_rotate callback there
*/
#ifdef __ANDROID__
static void
#else
static __always_inline void
#endif
____rb_erase_color(struct rb_node *parent, struct rb_root *root,
void (*augment_rotate)(struct rb_node *old, struct rb_node *_new))
{
struct rb_node *node = NULL, *sibling, *tmp1, *tmp2;
while (1) {
/*
* Loop invariants:
* - node is black (or NULL on first iteration)
* - node is not the root (parent is not NULL)
* - All leaf paths going through parent and node have a
* black node count that is 1 lower than other leaf paths.
*/
sibling = parent->rb_right;
if (node != sibling) { /* node == parent->rb_left */
if (rb_is_red(sibling)) {
/*
* Case 1 - left rotate at parent
*
* P S
* / \ / \
* N s --> p Sr
* / \ / \
* Sl Sr N Sl
*/
parent->rb_right = tmp1 = sibling->rb_left;
sibling->rb_left = parent;
rb_set_parent_color(tmp1, parent, RB_BLACK);
__rb_rotate_set_parents(parent, sibling, root,
RB_RED);
augment_rotate(parent, sibling);
sibling = tmp1;
}
tmp1 = sibling->rb_right;
if (!tmp1 || rb_is_black(tmp1)) {
tmp2 = sibling->rb_left;
if (!tmp2 || rb_is_black(tmp2)) {
/*
* Case 2 - sibling color flip
* (p could be either color here)
*
* (p) (p)
* / \ / \
* N S --> N s
* / \ / \
* Sl Sr Sl Sr
*
* This leaves us violating 5) which
* can be fixed by flipping p to black
* if it was red, or by recursing at p.
* p is red when coming from Case 1.
*/
rb_set_parent_color(sibling, parent,
RB_RED);
if (rb_is_red(parent))
rb_set_black(parent);
else {
node = parent;
parent = rb_parent(node);
if (parent)
continue;
}
break;
}
/*
* Case 3 - right rotate at sibling
* (p could be either color here)
*
* (p) (p)
* / \ / \
* N S --> N Sl
* / \ \
* sl Sr s
* \
* Sr
*/
sibling->rb_left = tmp1 = tmp2->rb_right;
tmp2->rb_right = sibling;
parent->rb_right = tmp2;
if (tmp1)
rb_set_parent_color(tmp1, sibling,
RB_BLACK);
augment_rotate(sibling, tmp2);
tmp1 = sibling;
sibling = tmp2;
}
/*
* Case 4 - left rotate at parent + color flips
* (p and sl could be either color here.
* After rotation, p becomes black, s acquires
* p's color, and sl keeps its color)
*
* (p) (s)
* / \ / \
* N S --> P Sr
* / \ / \
* (sl) sr N (sl)
*/
parent->rb_right = tmp2 = sibling->rb_left;
sibling->rb_left = parent;
rb_set_parent_color(tmp1, sibling, RB_BLACK);
if (tmp2)
rb_set_parent(tmp2, parent);
__rb_rotate_set_parents(parent, sibling, root,
RB_BLACK);
augment_rotate(parent, sibling);
break;
} else {
sibling = parent->rb_left;
if (rb_is_red(sibling)) {
/* Case 1 - right rotate at parent */
parent->rb_left = tmp1 = sibling->rb_right;
sibling->rb_right = parent;
rb_set_parent_color(tmp1, parent, RB_BLACK);
__rb_rotate_set_parents(parent, sibling, root,
RB_RED);
augment_rotate(parent, sibling);
sibling = tmp1;
}
tmp1 = sibling->rb_left;
if (!tmp1 || rb_is_black(tmp1)) {
tmp2 = sibling->rb_right;
if (!tmp2 || rb_is_black(tmp2)) {
/* Case 2 - sibling color flip */
rb_set_parent_color(sibling, parent,
RB_RED);
if (rb_is_red(parent))
rb_set_black(parent);
else {
node = parent;
parent = rb_parent(node);
if (parent)
continue;
}
break;
}
/* Case 3 - right rotate at sibling */
sibling->rb_right = tmp1 = tmp2->rb_left;
tmp2->rb_left = sibling;
parent->rb_left = tmp2;
if (tmp1)
rb_set_parent_color(tmp1, sibling,
RB_BLACK);
augment_rotate(sibling, tmp2);
tmp1 = sibling;
sibling = tmp2;
}
/* Case 4 - left rotate at parent + color flips */
parent->rb_left = tmp2 = sibling->rb_right;
sibling->rb_right = parent;
rb_set_parent_color(tmp1, sibling, RB_BLACK);
if (tmp2)
rb_set_parent(tmp2, parent);
__rb_rotate_set_parents(parent, sibling, root,
RB_BLACK);
augment_rotate(parent, sibling);
break;
}
}
}
/*
* Non-augmented rbtree manipulation functions.
*
* We use dummy augmented callbacks here, and have the compiler optimize them
* out of the rb_insert_color() and rb_erase() function definitions.
*/
static inline void dummy_propagate(struct rb_node *node, struct rb_node *stop) {}
static inline void dummy_copy(struct rb_node *old, struct rb_node *_new) {}
static inline void dummy_rotate(struct rb_node *old, struct rb_node *_new) {}
struct rb_augment_callbacks {
void (*propagate)(struct rb_node *node, struct rb_node *stop);
void (*copy)(struct rb_node *old, struct rb_node *_new);
void (*rotate)(struct rb_node *old, struct rb_node *_new);
};
static const struct rb_augment_callbacks dummy_callbacks = {
dummy_propagate, dummy_copy, dummy_rotate
};
void rb_insert_color(struct rb_node *node, struct rb_root *root)
{
__rb_insert(node, root, dummy_rotate);
}
#ifdef __ANDROID__
static struct rb_node *
#else
static __always_inline struct rb_node *
#endif
__rb_erase_augmented(struct rb_node *node, struct rb_root *root,
const struct rb_augment_callbacks *augment)
{
struct rb_node *child = node->rb_right, *tmp = node->rb_left;
struct rb_node *parent, *rebalance;
unsigned long pc;
if (!tmp) {
/*
* Case 1: node to erase has no more than 1 child (easy!)
*
* Note that if there is one child it must be red due to 5)
* and node must be black due to 4). We adjust colors locally
* so as to bypass __rb_erase_color() later on.
*/
pc = node->__rb_parent_color;
parent = __rb_parent(pc);
__rb_change_child(node, child, parent, root);
if (child) {
child->__rb_parent_color = pc;
rebalance = NULL;
} else
rebalance = __rb_is_black(pc) ? parent : NULL;
tmp = parent;
} else if (!child) {
/* Still case 1, but this time the child is node->rb_left */
tmp->__rb_parent_color = pc = node->__rb_parent_color;
parent = __rb_parent(pc);
__rb_change_child(node, tmp, parent, root);
rebalance = NULL;
tmp = parent;
} else {
struct rb_node *successor = child, *child2;
tmp = child->rb_left;
if (!tmp) {
/*
* Case 2: node's successor is its right child
*
* (n) (s)
* / \ / \
* (x) (s) -> (x) (c)
* \
* (c)
*/
parent = successor;
child2 = successor->rb_right;
augment->copy(node, successor);
} else {
/*
* Case 3: node's successor is leftmost under
* node's right child subtree
*
* (n) (s)
* / \ / \
* (x) (y) -> (x) (y)
* / /
* (p) (p)
* / /
* (s) (c)
* \
* (c)
*/
do {
parent = successor;
successor = tmp;
tmp = tmp->rb_left;
} while (tmp);
parent->rb_left = child2 = successor->rb_right;
successor->rb_right = child;
rb_set_parent(child, successor);
augment->copy(node, successor);
augment->propagate(parent, successor);
}
successor->rb_left = tmp = node->rb_left;
rb_set_parent(tmp, successor);
pc = node->__rb_parent_color;
tmp = __rb_parent(pc);
__rb_change_child(node, successor, tmp, root);
if (child2) {
successor->__rb_parent_color = pc;
rb_set_parent_color(child2, parent, RB_BLACK);
rebalance = NULL;
} else {
unsigned long pc2 = successor->__rb_parent_color;
successor->__rb_parent_color = pc;
rebalance = __rb_is_black(pc2) ? parent : NULL;
}
tmp = successor;
}
augment->propagate(tmp, NULL);
return rebalance;
}
void rb_erase(struct rb_node *node, struct rb_root *root)
{
struct rb_node *rebalance;
rebalance = __rb_erase_augmented(node, root, &dummy_callbacks);
if (rebalance)
____rb_erase_color(rebalance, root, dummy_rotate);
}
/*
* This function returns the first node (in sort order) of the tree.
*/
struct rb_node *rb_first(const struct rb_root *root)
{
struct rb_node *n;
n = root->rb_node;
if (!n)
return NULL;
while (n->rb_left)
n = n->rb_left;
return n;
}
struct rb_node *rb_last(const struct rb_root *root)
{
struct rb_node *n;
n = root->rb_node;
if (!n)
return NULL;
while (n->rb_right)
n = n->rb_right;
return n;
}
struct rb_node *rb_next(const struct rb_node *node)
{
struct rb_node *parent;
if (RB_EMPTY_NODE(node))
return NULL;
/*
* If we have a right-hand child, go down and then left as far
* as we can.
*/
if (node->rb_right) {
node = node->rb_right;
while (node->rb_left)
node=node->rb_left;
return (struct rb_node *)node;
}
/*
* No right-hand children. Everything down and left is smaller than us,
* so any 'next' node must be in the general direction of our parent.
* Go up the tree; any time the ancestor is a right-hand child of its
* parent, keep going up. First time it's a left-hand child of its
* parent, said parent is our 'next' node.
*/
while ((parent = rb_parent(node)) && node == parent->rb_right)
node = parent;
return parent;
}
struct rb_node *rb_prev(const struct rb_node *node)
{
struct rb_node *parent;
if (RB_EMPTY_NODE(node))
return NULL;
/*
* If we have a left-hand child, go down and then right as far
* as we can.
*/
if (node->rb_left) {
node = node->rb_left;
while (node->rb_right)
node=node->rb_right;
return (struct rb_node *)node;
}
/*
* No left-hand children. Go up till we find an ancestor which
* is a right-hand child of its parent.
*/
while ((parent = rb_parent(node)) && node == parent->rb_left)
node = parent;
return parent;
}
void rb_replace_node(struct rb_node *victim, struct rb_node *_new,
struct rb_root *root)
{
struct rb_node *parent = rb_parent(victim);
/* Set the surrounding nodes to point to the replacement */
__rb_change_child(victim, _new, parent, root);
if (victim->rb_left)
rb_set_parent(victim->rb_left, _new);
if (victim->rb_right)
rb_set_parent(victim->rb_right, _new);
/* Copy the pointers/colour from the victim to the replacement */
*_new = *victim;
}
static struct rb_node *rb_left_deepest_node(const struct rb_node *node)
{
for (;;) {
if (node->rb_left)
node = node->rb_left;
else if (node->rb_right)
node = node->rb_right;
else
return (struct rb_node *)node;
}
}
struct rb_node *rb_next_postorder(const struct rb_node *node)
{
const struct rb_node *parent;
if (!node)
return NULL;
parent = rb_parent(node);
/* If we're sitting on node, we've already seen our children */
if (parent && node == parent->rb_left && parent->rb_right) {
/* If we are the parent's left node, go to the parent's right
* node then all the way down to the left */
return rb_left_deepest_node(parent->rb_right);
} else
/* Otherwise we are the parent's right node, and the parent
* should be next */
return (struct rb_node *)parent;
}
struct rb_node *rb_first_postorder(const struct rb_root *root)
{
if (!root->rb_node)
return NULL;
return rb_left_deepest_node(root->rb_node);
}
|
7555daec1153e4003c8bd8a873323a9f0556030d
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/arch/arm/src/stm32f0l0g0/hardware/stm32_comp.h
|
04d6af81400ebb614c71f6e4222813d3b6cc992a
|
[
"MIT-open-group",
"BSD-3-Clause",
"HPND-sell-variant",
"BSD-4-Clause-UC",
"LicenseRef-scancode-warranty-disclaimer",
"MIT-0",
"LicenseRef-scancode-bsd-atmel",
"LicenseRef-scancode-gary-s-brown",
"LicenseRef-scancode-proprietary-license",
"SunPro",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"LicenseRef-scancode-other-permissive",
"HPND",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"GPL-1.0-or-later",
"CC-BY-2.0",
"CC-BY-4.0"
] |
permissive
|
apache/nuttx
|
14519a7bff4a87935d94fb8fb2b19edb501c7cec
|
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
|
refs/heads/master
| 2023-08-25T06:55:45.822534
| 2023-08-23T16:03:31
| 2023-08-24T21:25:47
| 228,103,273
| 407
| 241
|
Apache-2.0
| 2023-09-14T18:26:05
| 2019-12-14T23:27:55
|
C
|
UTF-8
|
C
| false
| false
| 9,434
|
h
|
stm32_comp.h
|
/****************************************************************************
* arch/arm/src/stm32f0l0g0/hardware/stm32_comp.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_STM32F0L0G0_HARDWARE_STM32_COMP_H
#define __ARCH_ARM_SRC_STM32F0L0G0_HARDWARE_STM32_COMP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "chip.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Register Offsets *********************************************************/
#define STM32_COMP_CSR_OFFSET 0x001c /* COMP1/COMP2 Control register */
/* Register Addresses *******************************************************/
#define STM32_COMP_CSR (STM32_COMP_BASE + STM32_COMP_CSR_OFFSET)
/* Register Bitfield Definitions ********************************************/
/* COMP control and status register */
#define COMP_CSR_COMP1EN (1 << 0) /* Bit 0: Comparator 1 enable */
#define COMP_CSR_COMP1SW1 (1 << 1) /* Bit 1: Comparator 1 non inverting input DAC switch */
#define COMP_CSR_COMP1MODE_SHIFT (2) /* Bits 2-3: Compator 1 mode */
#define COMP_CSR_COMP1MODE_MASK (3 << COMP_CSR_COMP1MODE_SHIFT)
# define COMP_CSR_COMP1MODE_HIGH (0 << COMP_CSR_COMP1MODE_SHIFT) /* 00: High Speed / full power */
# define COMP_CSR_COMP1MODE_MEDIUM (1 << COMP_CSR_COMP1MODE_SHIFT) /* 01: Medium Speed / medium power */
# define COMP_CSR_COMP1MODE_LOW (2 << COMP_CSR_COMP1MODE_SHIFT) /* 10: Low Speed / low-power */
# define COMP_CSR_COMP1MODE_VLOW (3 << COMP_CSR_COMP1MODE_SHIFT) /* 11: Very-low Speed / ultra-low power */
#define COMP_CSR_COMP1INSEL_SHIFT (4) /* Bits 4-6: Comparator 1 inverting input selection */
#define COMP_CSR_COMP1INSEL_MASK (7 << COMP_CSR_COMP1INSEL_SHIFT)
# define COMP_CSR_COMP1INSEL_1P4VREF (0 << COMP_CSR_COMP1INSEL_SHIFT) /* 000: 1/4 of Vrefint */
# define COMP_CSR_COMP1INSEL_1P2VREF (1 << COMP_CSR_COMP1INSEL_SHIFT) /* 001: 1/2 of Vrefint */
# define COMP_CSR_COMP1INSEL_3P4VREF (2 << COMP_CSR_COMP1INSEL_SHIFT) /* 010: 3/4 of Vrefint */
# define COMP_CSR_COMP1INSEL_VREF (3 << COMP_CSR_COMP1INSEL_SHIFT) /* 011: Vrefint */
# define COMP_CSR_COMP1INSEL_INM4 (4 << COMP_CSR_COMP1INSEL_SHIFT) /* 100: COMP1_INM4 (PA4 DAC_OUT1 if enabled) */
# define COMP_CSR_COMP1INSEL_INM5 (5 << COMP_CSR_COMP1INSEL_SHIFT) /* 101: COMP1_INM5 (PA5 DAC_OUT2 if present and enabled) */
# define COMP_CSR_COMP1INSEL_INM6 (6 << COMP_CSR_COMP1INSEL_SHIFT) /* 110: COMP1_INM6 (PA0) */
#define COMP_CSR_COMP1OUTSEL_SHIFT (8) /* Bits 8-10: Comparator 1 output selection*/
#define COMP_CSR_COMP1OUTSEL_MASK (7 << COMP_CSR_COMP1OUTSEL_MASK)
# define COMP_CSR_COMP1OUTSEL_NOSEL (0 << COMP_CSR_COMP1OUTSEL_MASK) /* 000: no selection */
# define COMP_CSR_COMP1OUTSEL_T1BRK (1 << COMP_CSR_COMP1OUTSEL_MASK) /* 001: Timer 1 break input */
# define COMP_CSR_COMP1OUTSEL_T1ICAP (2 << COMP_CSR_COMP1OUTSEL_MASK) /* 010: Timer 1 Input capture 1 */
# define COMP_CSR_COMP1OUTSEL_T1OCRC (3 << COMP_CSR_COMP1OUTSEL_MASK) /* 011: Timer 1 OCrefclear input */
# define COMP_CSR_COMP1OUTSEL_T2ICAP (4 << COMP_CSR_COMP1OUTSEL_MASK) /* 100: Timer 2 input capture 4 */
# define COMP_CSR_COMP1OUTSEL_T2OCRC (5 << COMP_CSR_COMP1OUTSEL_MASK) /* 101: Timer 2 OCrefclear input */
# define COMP_CSR_COMP1OUTSEL_T3ICAP (6 << COMP_CSR_COMP1OUTSEL_MASK) /* 110: Timer 3 input capture 1 */
# define COMP_CSR_COMP1OUTSEL_T3OCRC (7 << COMP_CSR_COMP1OUTSEL_MASK) /* 111: Timer 3 OCrefclear input */
#define COMP_CSR_COMP1POL (1 << 11) /* Bit 11: Comparator 1 output polarity */
#define COMP_CSR_COMP1HYST_SHIFT (12) /* Bits 12-13: Comparator 1 hysteresis */
#define COMP_CSR_COMP1HYST_MASK (3 << COMP_CSR_COMP1HYST_SHIFT)
# define COMP_CSR_COMP1HYST_NOHYST (0 << COMP_CSR_COMP1HYST_MASK) /* 00: No hysteresis */
# define COMP_CSR_COMP1HYST_LOWHYST (1 << COMP_CSR_COMP1HYST_MASK) /* 01: Low hysteresis */
# define COMP_CSR_COMP1HYST_MDHYST (2 << COMP_CSR_COMP1HYST_MASK) /* 10: Medium hysteresis */
# define COMP_CSR_COMP1HYST_HIHYST (3 << COMP_CSR_COMP1HYST_MASK) /* 11: Low hysteresis */
#define COMP_CSR_COMP1OUT (1 << 14) /* Bit 14: Comparator 1 output */
#define COMP_CSR_COMP1LOCK (1 << 15) /* Bit 15: Comparator 1 lock */
#define COMP_CSR_COMP2EN (1 << 16) /* Bit 16: Comparator 2 enable */
#define COMP_CSR_COMP2MODE_SHIFT (18) /* Bits 18-19: Compator 2 mode */
#define COMP_CSR_COMP2MODE_MASK (3 << COMP_CSR_COMP2MODE_SHIFT)
# define COMP_CSR_COMP2MODE_HIGH (0 << COMP_CSR_COMP2MODE_SHIFT) /* 00: High Speed / full power */
# define COMP_CSR_COMP2MODE_MEDIUM (1 << COMP_CSR_COMP2MODE_SHIFT) /* 01: Medium Speed / medium power */
# define COMP_CSR_COMP2MODE_LOW (2 << COMP_CSR_COMP2MODE_SHIFT) /* 10: Low Speed / low-power */
# define COMP_CSR_COMP2MODE_VLOW (3 << COMP_CSR_COMP2MODE_SHIFT) /* 11: Very-low Speed / ultra-low power */
#define COMP_CSR_COMP2INSEL_SHIFT (20) /* Bits 20-22: Comparator 2 inverting input selection */
#define COMP_CSR_COMP2INSEL_MASK (7 << COMP_CSR_COMP2INSEL_SHIFT)
# define COMP_CSR_COMP2INSEL_1P4VREF (0 << COMP_CSR_COMP2INSEL_SHIFT) /* 000: 1/4 of Vrefint */
# define COMP_CSR_COMP2INSEL_1P2VREF (1 << COMP_CSR_COMP2INSEL_SHIFT) /* 001: 1/2 of Vrefint */
# define COMP_CSR_COMP2INSEL_3P4VREF (2 << COMP_CSR_COMP2INSEL_SHIFT) /* 010: 3/4 of Vrefint */
# define COMP_CSR_COMP2INSEL_VREF (3 << COMP_CSR_COMP2INSEL_SHIFT) /* 011: Vrefint */
# define COMP_CSR_COMP2INSEL_INM4 (4 << COMP_CSR_COMP2INSEL_SHIFT) /* 100: COMP1_INM4 (PA4 DAC_OUT1 if enabled) */
# define COMP_CSR_COMP2INSEL_INM5 (5 << COMP_CSR_COMP2INSEL_SHIFT) /* 101: COMP1_INM5 (PA5 DAC_OUT2 if present and enabled) */
# define COMP_CSR_COMP2INSEL_INM6 (6 << COMP_CSR_COMP2INSEL_SHIFT) /* 110: COMP1_INM6 (PA2) */
#define COMP_CSR_WNDWEN (1 << 23) /* Bit 23: Window mode enable */
#define COMP_CSR_COMP2OUTSEL_SHIFT (24) /* Bits 24-26: Comparator 1 output selection*/
#define COMP_CSR_COMP2OUTSEL_MASK (7 << COMP_CSR_COMP2OUTSEL_MASK)
# define COMP_CSR_COMP2OUTSEL_NOSEL (0 << COMP_CSR_COMP2OUTSEL_MASK) /* 000: no selection */
# define COMP_CSR_COMP2OUTSEL_T1BRK (1 << COMP_CSR_COMP2OUTSEL_MASK) /* 001: Timer 1 break input */
# define COMP_CSR_COMP2OUTSEL_T1ICAP (2 << COMP_CSR_COMP2OUTSEL_MASK) /* 010: Timer 1 Input capture 1 */
# define COMP_CSR_COMP2OUTSEL_T1OCRC (3 << COMP_CSR_COMP2OUTSEL_MASK) /* 011: Timer 1 OCrefclear input */
# define COMP_CSR_COMP2OUTSEL_T2ICAP (4 << COMP_CSR_COMP2OUTSEL_MASK) /* 100: Timer 2 input capture 4 */
# define COMP_CSR_COMP2OUTSEL_T2OCRC (5 << COMP_CSR_COMP2OUTSEL_MASK) /* 101: Timer 2 OCrefclear input */
# define COMP_CSR_COMP2OUTSEL_T3ICAP (6 << COMP_CSR_COMP2OUTSEL_MASK) /* 110: Timer 3 input capture 1 */
# define COMP_CSR_COMP2OUTSEL_T3OCRC (7 << COMP_CSR_COMP2OUTSEL_MASK) /* 111: Timer 3 OCrefclear input */
#define COMP_CSR_COMP2POL (1 << 27) /* Bit 27: Comparator 2 output polarity */
#define COMP_CSR_COMP2HYST_SHIFT (12) /* Bits 12-13: Comparator 1 hysteresis */
#define COMP_CSR_COMP2HYST_MASK (3 << COMP_CSR_COMP2HYST_SHIFT)
# define COMP_CSR_COMP2HYST_NOHYST (0 << COMP_CSR_COMP2HYST_MASK) /* 00: No hysteresis */
# define COMP_CSR_COMP2HYST_LOWHYST (1 << COMP_CSR_COMP2HYST_MASK) /* 01: Low hysteresis */
# define COMP_CSR_COMP2HYST_MDHYST (2 << COMP_CSR_COMP2HYST_MASK) /* 10: Medium hysteresis */
# define COMP_CSR_COMP2HYST_HIHYST (3 << COMP_CSR_COMP2HYST_MASK) /* 11: Low hysteresis */
#define COMP_CSR_COMP2OUT (1 << 14) /* Bit 14: Comparator 1 output */
#define COMP_CSR_COMP2LOCK (1 << 15) /* Bit 15: Comparator 1 lock */
#endif /* __ARCH_ARM_SRC_STM32F0L0G0_HARDWARE_STM32_COMP_H */
|
bb036389410b3db86e2baa8aa3835cc85cff320d
|
33bbf5ec9c25a08cdc2ea9b404fef066f48b91e6
|
/i18n/ro/dictionary.h
|
1485ca78078d344e4a3b4f21c132bcb16353fae1
|
[
"BSD-2-Clause"
] |
permissive
|
gabordemooij/citrine
|
2cf1102851461b273158e6731a68e35fe7123c88
|
135beb4c417e006028b3affb264c1bd554ae28f1
|
refs/heads/master
| 2023-08-28T01:10:20.952764
| 2023-07-08T10:02:04
| 2023-07-08T10:02:04
| 23,259,816
| 110
| 23
|
BSD-2-Clause
| 2023-07-08T10:02:08
| 2014-08-23T15:55:48
|
C
|
UTF-8
|
C
| false
| false
| 9,088
|
h
|
dictionary.h
|
#define CTR_DICT_CODEGEN_MAP_NEW "(Hartă crea) "
#define CTR_DICT_CODEGEN_MAP_PUT "pune:"
#define CTR_DICT_CODEGEN_MAP_PUT_AT " la:"
#define CTR_DICT_CODEGEN_ARRAY_NEW "Listă crea "
#define CTR_DICT_CODEGEN_ARRAY_NEW_PUSH "Listă ← "
#define CTR_DICT_END_OF_LINE "."
#define CTR_DICT_NIL "Nul"
#define CTR_DICT_BOOLEAN "Boolean"
#define CTR_DICT_TRUE "Adevărat"
#define CTR_DICT_FALSE "Fals"
#define CTR_DICT_NUMBER "Număr"
#define CTR_DICT_STRING "String"
#define CTR_DICT_TASK "Cod"
#define CTR_DICT_OBJECT "Obiect"
#define CTR_DICT_ARRAY_OBJECT "Listă"
#define CTR_DICT_MAP_OBJECT "Hartă"
#define CTR_DICT_PROGRAM "Program"
#define CTR_DICT_FILE "Fişier"
#define CTR_DICT_MOMENT "Moment"
#define CTR_DICT_VAR_ICON "☞"
#define CTR_DICT_ME_ICON "⛏"
#define CTR_DICT_MY_ICON "⚿"
#define CTR_DICT_BULLET "•"
#define CTR_DICT_SYMBOL_EQUALS "="
#define CTR_DICT_PLUS "+"
#define CTR_DICT_MINUS "-"
#define CTR_DICT_MULTIPLIER "×"
#define CTR_DICT_DIVISION "÷"
#define CTR_DICT_GREATER ">"
#define CTR_DICT_LESS "<"
#define CTR_DICT_AT_SYMBOL "?"
#define CTR_DICT_PEN_ICON "✎"
#define CTR_DICT_NEW_ARRAY_AND_PUSH_SYMBOL "←"
#define CTR_DICT_GREATER_OR_EQUAL_SYMBOL "≥"
#define CTR_DICT_LESS_OR_EQUAL_SYMBOL "≤"
#define CTR_DICT_UNEQUALS_SYMBOL "≠"
#define CTR_DICT_NEW "crea"
#define CTR_DICT_EQUALS "egal:"
#define CTR_DICT_AND "şi:"
#define CTR_DICT_OR "sau:"
#define CTR_DICT_MODULO "modul:"
#define CTR_DICT_NOR "nici:"
#define CTR_DICT_ONDO "la:execută:"
#define CTR_DICT_TYPE "tip"
#define CTR_DICT_ISNIL "Nul?"
#define CTR_DICT_MYSELF "sine"
#define CTR_DICT_DO "fă"
#define CTR_DICT_DONE "gata"
#define CTR_DICT_IFFALSE "fals:"
#define CTR_DICT_IFTRUE "adevărat:"
#define CTR_DICT_WHILE "cât timp:"
#define CTR_DICT_MESSAGEARGS "mesaj:argumente:"
#define CTR_DICT_MESSAGE "mesaj:"
#define CTR_DICT_LEARN "învaţă:înseamnă:"
#define CTR_DICT_BREAK "opreşte"
#define CTR_DICT_CONTINUE "continuă"
#define CTR_DICT_ELSE "altfel:"
#define CTR_DICT_NOT "nu"
#define CTR_DICT_TONUMBER "număr"
#define CTR_DICT_ITONUMBER "număr internațional"
#define CTR_DICT_TOSTRING "string"
#define CTR_DICT_CHAR_AT_SET "caracter:"
#define CTR_DICT_EITHEROR "sau:sau:"
#define CTR_DICT_BY_SET "cu:"
#define CTR_DICT_FLOOR "floor"
#define CTR_DICT_CEIL "ceil"
#define CTR_DICT_ROUND "rounjeşte"
#define CTR_DICT_ABS "absolut"
#define CTR_DICT_SQRT "radical"
#define CTR_DICT_POWER "putere:"
#define CTR_DICT_MIN "minimum"
#define CTR_DICT_MAX "maximum"
#define CTR_DICT_ODD "impar?"
#define CTR_DICT_EVEN "par?"
#define CTR_DICT_POS "pozitiv?"
#define CTR_DICT_NEG "negativ?"
#define CTR_DICT_TOBOOL "boolean"
#define CTR_DICT_RANDOM_NUM_BETWEEN "între:şi:"
#define CTR_DICT_LENGTH "lungime"
#define CTR_DICT_FROM_LENGTH "de la:lungime:"
#define CTR_DICT_TRIM "şterge spaţiile din jur"
#define CTR_DICT_AT "la:"
#define CTR_DICT_POSITION_SET "poziţie:"
#define CTR_DICT_INDEX_OF "caută:"
#define CTR_DICT_LAST_INDEX_OF "ultimul:"
#define CTR_DICT_REPLACE_WITH "înlocuieşte:cu:"
#define CTR_DICT_SPLIT "împarte:"
#define CTR_DICT_SKIP "ofset:"
#define CTR_DICT_RUN "execută"
#define CTR_DICT_APPLY_TO "aplică:"
#define CTR_DICT_APPLY_TO_AND "aplică:şi:"
#define CTR_DICT_VALUE_SET "set:valoare:"
#define CTR_DICT_ERROR "eroare:"
#define CTR_DICT_CATCH "prinde:"
#define CTR_DICT_PUSH_SYMBOL ";"
#define CTR_DICT_SHIFT "mută"
#define CTR_DICT_COUNT "numără"
#define CTR_DICT_JOIN "alătură:"
#define CTR_DICT_POP "scoate"
#define CTR_DICT_SORT "sortează:"
#define CTR_DICT_PUT_AT "pune:la:"
#define CTR_DICT_MAP "map:"
#define CTR_DICT_EACH "fiecare:"
#define CTR_DICT_WRITE "scrie:"
#define CTR_DICT_PATH "cale"
#define CTR_DICT_READ "citeşte"
#define CTR_DICT_APPEND "adaugă la sfârşit:"
#define CTR_DICT_PREPEND "adaugă la început:"
#define CTR_DICT_EXISTS "există"
#define CTR_DICT_SIZE "dimensiune"
#define CTR_DICT_DELETE "şterge"
#define CTR_DICT_USE_SET "utilizare:"
#define CTR_DICT_ARRAY "listă:"
#define CTR_DICT_END "final"
#define CTR_DICT_ARGUMENT "argument:"
#define CTR_DICT_ARGUMENT_COUNT "argumente"
#define CTR_DICT_WAIT_FOR_PASSW "cere o parolă"
#define CTR_DICT_WAIT_FOR_INPUT "întreabă"
#define CTR_DICT_INPUT "intrare"
#define CTR_DICT_FLUSH "curăţă"
#define CTR_DICT_WAIT "aşteaptă:"
#define CTR_DICT_TIME "timp"
#define CTR_DICT_RESPOND_TO "răspunde:"
#define CTR_DICT_RESPOND_TO_AND "răspunde:şi:"
#define CTR_DICT_SHELL "linie de comandă:"
#define CTR_DICT_SWEEP "curăţă memoria"
#define CTR_DICT_MEMORY_LIMIT "memorie:"
#define CTR_DICT_MEMORY "memorie"
#define CTR_DICT_GC_MODE "ordine:"
#define CTR_DICT_HASH_WITH_KEY "hash:"
#define CTR_DICT_CHARACTERS "caractere"
#define CTR_DICT_QUALIFIER_SET "califică:"
#define CTR_DICT_QUALIFIER "calificare"
#define CTR_DICT_NEW_SET "crea:"
#define CTR_DICT_HOUR "oră"
#define CTR_DICT_HOUR_SET "oră:"
#define CTR_DICT_MINUTE_SET "minut:"
#define CTR_DICT_MINUTE "minut"
#define CTR_DICT_SECOND_SET "secundă:"
#define CTR_DICT_SECOND "secundă"
#define CTR_DICT_DAY "zi"
#define CTR_DICT_DAY_SET "zi:"
#define CTR_DICT_WEEK "săptămână"
#define CTR_DICT_WEEK_SET "săptămână:"
#define CTR_DICT_MONTH "lună"
#define CTR_DICT_MONTH_SET "lună:"
#define CTR_DICT_YEAR "an"
#define CTR_DICT_RAW "dur"
#define CTR_DICT_YEAR_SET "an:"
#define CTR_DICT_WEEK_DAY "zi a săptămânii"
#define CTR_DICT_YEAR_DAY "zi din an"
#define CTR_DICT_ZONE "zonă"
#define CTR_DICT_ZONE_SET "zonă:"
#define CTR_DICT_ADD_SET "adaugă:"
#define CTR_DICT_SUBTRACT_SET "scade:"
#define CTR_DICT_MULTIPLIER_SET "multiplică cu:"
#define CTR_DICT_DIVIDER_SET "împarte la:"
#define CTR_DICT_LAST "ultim"
#define CTR_DICT_FIRST "prim"
#define CTR_DICT_SECOND_LAST "penultim"
#define CTR_DICT_FILL_WITH "umple:cu:"
#define CTR_DICT_SPLICE "înlocuieşte:lungime:cu:"
#define CTR_DICT_VALUES "valori"
#define CTR_DICT_ENTRIES "intrări"
#define CTR_DICT_COMPARE_SET "compară:"
#define CTR_DICT_HAS "are:"
#define CTR_DICT_COPY "copiază"
#define CTR_DICT_CASE_DO "în caz că:fă:"
#define CTR_DICT_STOP "stop"
#define CTR_DICT_ASCII_UPPER_CASE "majuscule"
#define CTR_DICT_ASCII_LOWER_CASE "litere mici"
#define CTR_DICT_CONTAINS "conţine:"
#define CTR_DICT_APPLY_TO_AND_AND "aplică:şi:şi:"
#define CTR_DICT_ENVIRONMENT_VARIABLE "setare:"
#define CTR_DICT_SET_ENVIRONMENT_VARIABLE "setare:valoare:"
#define CTR_DICT_RESPOND_TO_AND_AND "răspunde:şi:şi:"
#define CTR_DICT_RESPOND_TO_AND_AND_AND "răspunde:şi:şi:şi:"
#define CTR_DICT_CURRENT_TASK "acest bloc de cod"
#define CTR_DICT_NUM_DEC_SEP ","
#define CTR_DICT_NUM_THO_SEP "."
#define CTR_DICT_QUOT_OPEN "‘"
#define CTR_DICT_QUOT_CLOSE "’"
#define CTR_DICT_MESSAGE_CHAIN ","
#define CTR_DICT_ASSIGN "≔"
#define CTR_DICT_PAREN_OPEN "("
#define CTR_DICT_PAREN_CLOSE ")"
#define CTR_DICT_BLOCK_START "{"
#define CTR_DICT_BLOCK_END "}"
#define CTR_DICT_PARAMETER_PREFIX ":"
#define CTR_DICT_RETURN "↲"
#define CTR_DICT_CODE "code"
#define CTR_DICT_PROCEDURE "procedură"
#define CTR_DICT_TOOBJECT "obiect"
#define CTR_DICT_PATH_OBJECT "Locația fișierului"
#define CTR_DICT_CMD_OBJECT "Instrucțiuni"
#define CTR_DICT_RECURSIVE "recursiv"
|
3f899dafbd4c005ec35964265dbe5a12587f7646
|
e72db16e9747386afd01edd1dd36d9589a3f71ef
|
/src/libpmem2/x86_64/memcpy/memcpy_avx.h
|
2a01739bf41fa424264f3e01316d319b45d09eea
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
pmem/pmdk
|
5e49feee8017574340db2a0f9b4e2eab99f8581c
|
ccadb16227bddea1bdcc518bd8f298d551b2baad
|
refs/heads/master
| 2023-08-31T02:28:06.884934
| 2023-08-30T14:52:25
| 2023-08-30T14:52:25
| 23,637,153
| 1,017
| 402
|
NOASSERTION
| 2023-09-07T11:52:42
| 2014-09-03T20:55:23
|
C
|
UTF-8
|
C
| false
| false
| 2,182
|
h
|
memcpy_avx.h
|
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2017-2022, Intel Corporation */
#ifndef PMEM2_MEMCPY_AVX_H
#define PMEM2_MEMCPY_AVX_H
#include <immintrin.h>
#include <stddef.h>
#include <stdint.h>
#include "out.h"
static force_inline void
memmove_small_avx_noflush(char *dest, const char *src, size_t len)
{
ASSERT(len <= 64);
if (len <= 8)
goto le8;
if (len <= 32)
goto le32;
/* 33..64 */
__m256i ymm0 = _mm256_loadu_si256((__m256i *)src);
__m256i ymm1 = _mm256_loadu_si256((__m256i *)(src + len - 32));
_mm256_storeu_si256((__m256i *)dest, ymm0);
_mm256_storeu_si256((__m256i *)(dest + len - 32), ymm1);
return;
le32:
if (len > 16) {
/* 17..32 */
__m128i xmm0 = _mm_loadu_si128((__m128i *)src);
__m128i xmm1 = _mm_loadu_si128((__m128i *)(src + len - 16));
_mm_storeu_si128((__m128i *)dest, xmm0);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm1);
return;
}
/* 9..16 */
ua_uint64_t d80 = *(ua_uint64_t *)src;
ua_uint64_t d81 = *(ua_uint64_t *)(src + len - 8);
*(ua_uint64_t *)dest = d80;
*(ua_uint64_t *)(dest + len - 8) = d81;
return;
le8:
if (len <= 2)
goto le2;
if (len > 4) {
/* 5..8 */
ua_uint32_t d40 = *(ua_uint32_t *)src;
ua_uint32_t d41 = *(ua_uint32_t *)(src + len - 4);
*(ua_uint32_t *)dest = d40;
*(ua_uint32_t *)(dest + len - 4) = d41;
return;
}
/* 3..4 */
ua_uint16_t d20 = *(ua_uint16_t *)src;
ua_uint16_t d21 = *(ua_uint16_t *)(src + len - 2);
*(ua_uint16_t *)dest = d20;
*(ua_uint16_t *)(dest + len - 2) = d21;
return;
le2:
if (len == 2) {
*(ua_uint16_t *)dest = *(ua_uint16_t *)src;
return;
}
*(uint8_t *)dest = *(uint8_t *)src;
}
static force_inline void
memmove_small_avx(char *dest, const char *src, size_t len, flush_fn flush)
{
/*
* pmemcheck complains about "overwritten stores before they were made
* persistent" for overlapping stores (last instruction in each code
* path) in the optimized version.
* libc's memcpy also does that, so we can't use it here.
*/
if (On_pmemcheck) {
memmove_nodrain_generic(dest, src, len, PMEM2_F_MEM_NOFLUSH,
NULL, NULL);
} else {
memmove_small_avx_noflush(dest, src, len);
}
flush(dest, len);
}
#endif
|
eb012d8d9431119cc7be1463d8acf26dea976c46
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/nuvoton/libraries/m2354/Device/Nuvoton/M2354/Include/eadc_reg.h
|
bedb6a60c01aa77d884e8d56ed2805029a35a355
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 147,607
|
h
|
eadc_reg.h
|
/**************************************************************************//**
* @file eadc_reg.h
* @version V1.00
* @brief EADC register definition header file
*
* @copyright SPDX-License-Identifier: Apache-2.0
* @copyright Copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#ifndef __EADC_REG_H__
#define __EADC_REG_H__
/** @addtogroup REGISTER Control Register
@{
*/
/*---------------------- Enhanced Analog to Digital Converter -------------------------*/
/**
@addtogroup EADC Enhanced Analog to Digital Converter(EADC)
Memory Mapped Structure for EADC Controller
@{
*/
typedef struct
{
/**
* @var EADC_T::DAT[19]
* Offset: 0x00 ADC Data Register 0~18 for Sample Module 0~18
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[15:0] |RESULT |ADC Conversion Result
* | | |This field contains 12 bits conversion result.
* | | |When DMOF (EADC_CTL[9]) is set to 0, 12-bit ADC conversion result with unsigned format will be filled in RESULT[11:0] and zero will be filled in RESULT[15:12].
* | | |When DMOF (EADC_CTL[9]) set to 1, 12-bit ADC conversion result with 2'complement format will be filled in RESULT[11:0] and signed bits to will be filled in RESULT[15:12].
* |[16] |OV |Overrun Flag
* | | |If converted data in RESULT[11:0] has not been read before new conversion result is loaded to this register, OV is set to 1.
* | | |0 = Data in RESULT[11:0] is recent conversion result.
* | | |1 = Data in RESULT[11:0] is overwrite.
* | | |Note: It is cleared by hardware after EADC_DAT register is read.
* |[17] |VALID |Valid Flag
* | | |This bit is set to 1 when corresponding sample module channel analog input conversion is completed and cleared by hardware after EADC_DAT register is read.
* | | |0 = Data in RESULT[11:0] bits is not valid.
* | | |1 = Data in RESULT[11:0] bits is valid.
* @var EADC_T::CURDAT
* Offset: 0x4C ADC PDMA Current Transfer Data Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[17:0] |CURDAT |ADC PDMA Current Transfer Data Register
* | | |This register is a shadow register of EADC_DATn (n=0~18) for PDMA support.
* | | |This is a read only register.
* @var EADC_T::CTL
* Offset: 0x50 ADC Control Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[0] |ADCEN |ADC Converter Enable Bit
* | | |0 = Disabled EADC.
* | | |1 = Enabled EADC.
* | | |Note: Before starting ADC conversion function, this bit should be set to 1
* | | |Clear it to 0 to disable ADC converter analog circuit power consumption.
* |[1] |ADCRST |ADC Converter Control Circuits Reset
* | | |0 = No effect.
* | | |1 = Cause ADC control circuits reset to initial state, but not change the ADC registers value.
* | | |Note: ADCRST bit remains 1 during ADC reset, when ADC reset end, the ADCRST bit is automatically cleared to 0.
* |[2] |ADCIEN0 |Specific Sample Module ADC ADINT0 Interrupt Enable Bit
* | | |The ADC converter generates a conversion end ADIF0 (EADC_STATUS2[0]) upon the end of specific sample module ADC conversion
* | | |If ADCIEN0 bit is set then conversion end interrupt request ADINT0 is generated.
* | | |0 = Specific sample module ADC ADINT0 interrupt function Disabled.
* | | |1 = Specific sample module ADC ADINT0 interrupt function Enabled.
* |[3] |ADCIEN1 |Specific Sample Module ADC ADINT1 Interrupt Enable Bit
* | | |The ADC converter generates a conversion end ADIF1 (EADC_STATUS2[1]) upon the end of specific sample module ADC conversion
* | | |If ADCIEN1 bit is set then conversion end interrupt request ADINT1 is generated.
* | | |0 = Specific sample module ADC ADINT1 interrupt function Disabled.
* | | |1 = Specific sample module ADC ADINT1 interrupt function Enabled.
* |[4] |ADCIEN2 |Specific Sample Module ADC ADINT2 Interrupt Enable Bit
* | | |The ADC converter generates a conversion end ADIF2 (EADC_STATUS2[2]) upon the end of specific sample module ADC conversion
* | | |If ADCIEN2 bit is set then conversion end interrupt request ADINT2 is generated.
* | | |0 = Specific sample module ADC ADINT2 interrupt function Disabled.
* | | |1 = Specific sample module ADC ADINT2 interrupt function Enabled.
* |[5] |ADCIEN3 |Specific Sample Module ADC ADINT3 Interrupt Enable Bit
* | | |The ADC converter generates a conversion end ADIF3 (EADC_STATUS2[3]) upon the end of specific sample module ADC conversion
* | | |If ADCIEN3 bit is set then conversion end interrupt request ADINT3 is generated.
* | | |0 = Specific sample module ADC ADINT3 interrupt function Disabled.
* | | |1 = Specific sample module ADC ADINT3 interrupt function Enabled.
* |[7:6] |RESSEL |Resolution Selection
* | | |00 = 6-bit ADC result will be put at RESULT (EADC_DATn[5:0]).
* | | |01 = 8-bit ADC result will be put at RESULT (EADC_DATn[7:0]).
* | | |10 = 10-bit ADC result will be put at RESULT (EADC_DATn[9:0]).
* | | |11 = 12-bit ADC result will be put at RESULT (EADC_DATn[11:0]).
* |[8] |DIFFEN |Differential Analog Input Mode Enable Bit
* | | |0 = Single-end analog input mode.
* | | |1 = Differential analog input mode.
* |[9] |DMOF |ADC Differential Input Mode Output Format
* | | |0 = ADC conversion result will be filled in RESULT (EADC_DATn[15:0] , n= 0 ~18) with unsigned format.
* | | |1 = ADC conversion result will be filled in RESULT (EADC_DATn[15:0] , n= 0 ~18) with 2'complement format.
* @var EADC_T::SWTRG
* Offset: 0x54 ADC Sample Module Software Start Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[18:0] |SWTRG |ADC Sample Module 0~18 Software Force to Start ADC Conversion
* | | |0 = No effect.
* | | |1 = Cause an ADC conversion when the priority is given to sample module.
* | | |Note: After write this register to start ADC conversion, the EADC_PENDSTS register will show which sample module will conversion
* | | |If user want to disable the conversion of the sample module, user can write EADC_PENDSTS register to clear it.
* @var EADC_T::PENDSTS
* Offset: 0x58 ADC Start of Conversion Pending Flag Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[18:0] |STPF |ADC Sample Module 0~18 Start of Conversion Pending Flag
* | | |Read:
* | | |0 = There is no pending conversion for sample module.
* | | |1 = Sample module ADC start of conversion is pending.
* | | |Write:
* | | |1 = clear pending flag and cancel the conversion for sample module.
* | | |Note: This bit remains 1 during pending state, when the respective ADC conversion is end, the STPFn (n=0~18) bit is automatically cleared to 0
* @var EADC_T::OVSTS
* Offset: 0x5C ADC Sample Module Start of Conversion Overrun Flag Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[18:0] |SPOVF |ADC SAMPLE0~18 Overrun Flag
* | | |0 = No sample module event overrun.
* | | |1 = Indicates a new sample module event is generated while an old one event is pending.
* | | |Note: This bit is cleared by writing 1 to it.
* @var EADC_T::SCTL[19]
* Offset: 0x80 ADC Sample Module 0~18 Control Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[3:0] |CHSEL |ADC Sample Module Channel Selection
* | | |00H = EADC_CH0 (slow channel).
* | | |01H = EADC_CH1 (slow channel).
* | | |02H = EADC_CH2 (slow channel).
* | | |03H = EADC_CH3 (slow channel).
* | | |04H = EADC_CH4 (slow channel).
* | | |05H = EADC_CH5 (slow channel).
* | | |06H = EADC_CH6 (slow channel).
* | | |07H = EADC_CH7 (slow channel).
* | | |08H = EADC_CH8 (slow channel).
* | | |09H = EADC_CH9 (slow channel).
* | | |0AH = EADC_CH10 (fast channel).
* | | |0BH = EADC_CH11 (fast channel).
* | | |0CH = EADC_CH12 (fast channel).
* | | |0DH = EADC_CH13 (fast channel).
* | | |0EH = EADC_CH14 (fast channel).
* | | |0FH = EADC_CH15 (fast channel).
* |[4] |EXTREN |ADC External Trigger Rising Edge Enable Bit
* | | |0 = Rising edge Disabled when ADC selects EADC0_ST as trigger source.
* | | |1 = Rising edge Enabled when ADC selects EADC0_ST as trigger source.
* |[5] |EXTFEN |ADC External Trigger Falling Edge Enable Bit
* | | |0 = Falling edge Disabled when ADC selects EADC0_ST as trigger source.
* | | |1 = Falling edge Enabled when ADC selects EADC0_ST as trigger source.
* |[7:6] |TRGDLYDIV |ADC Sample Module Start of Conversion Trigger Delay Clock Divider Selection
* | | |Trigger delay clock frequency:
* | | |00 = ADC_CLK/1.
* | | |01 = ADC_CLK/2.
* | | |10 = ADC_CLK/4.
* | | |11 = ADC_CLK/16.
* |[15:8] |TRGDLYCNT |ADC Sample Module Start of Conversion Trigger Delay Time
* | | |Trigger delay time = TRGDLYCNT x ADC_CLK x n (n=1,2,4,16 from TRGDLYDIV setting).
* |[20:16] |TRGSEL |ADC Sample Module Start of Conversion Trigger Source Selection
* | | |0H = Disable trigger.
* | | |1H = External trigger from EADC0_ST pin input.
* | | |2H = ADC ADINT0 interrupt EOC (End of conversion) pulse trigger.
* | | |3H = ADC ADINT1 interrupt EOC (End of conversion) pulse trigger.
* | | |4H = Timer0 overflow pulse trigger.
* | | |5H = Timer1 overflow pulse trigger.
* | | |6H = Timer2 overflow pulse trigger.
* | | |7H = Timer3 overflow pulse trigger.
* | | |8H = Timer4 overflow pulse trigger.
* | | |9H = Timer5 overflow pulse trigger.
* | | |AH = EPWM0TG0.
* | | |BH = EPWM0TG1.
* | | |CH = EPWM0TG2.
* | | |DH = EPWM0TG3.
* | | |EH = EPWM0TG4.
* | | |FH = EPWM0TG5.
* | | |10H = EPWM1TG0.
* | | |11H = EPWM1TG1.
* | | |12H = EPWM1TG2.
* | | |13H = EPWM1TG3.
* | | |14H = EPWM1TG4.
* | | |15H = EPWM1TG5.
* | | |16H = BPWM0TG.
* | | |17H = BPWM1TG.
* | | |other = Reserved.
* |[22] |INTPOS |Interrupt Flag Position Select
* | | |0 = Set ADIFn (EADC_STATUS2[n], n=0~3) at ADC end of conversion.
* | | |1 = Set ADIFn (EADC_STATUS2[n], n=0~3) at ADC start of conversion.
* |[23] |DBMEN |Double Buffer Mode Enable Bit
* | | |0 = Sample has one sample result register. (default).
* | | |1 = Sample has two sample result registers.
* |[31:24] |EXTSMPT |ADC Sampling Time Extend
* | | |When ADC converting at high conversion rate, the sampling time of analog input voltage may not enough if input channel loading is heavy, user can extend ADC sampling time after trigger source is coming to get enough sampling time.
* | | |The range of start delay time is from 0~255 ADC clock.
* @var EADC_T::INTSRC[4]
* Offset: 0xD0 ADC interrupt 0~3 Source Enable Control Register.
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[0] |SPLIE0 |Sample Module 0 Interrupt Enable Bit
* | | |0 = Sample Module 0 interrupt Disabled.
* | | |1 = Sample Module 0 interrupt Enabled.
* |[1] |SPLIE1 |Sample Module 1 Interrupt Enable Bit
* | | |0 = Sample Module 1 interrupt Disabled.
* | | |1 = Sample Module 1 interrupt Enabled.
* |[2] |SPLIE2 |Sample Module 2 Interrupt Enable Bit
* | | |0 = Sample Module 2 interrupt Disabled.
* | | |1 = Sample Module 2 interrupt Enabled.
* |[3] |SPLIE3 |Sample Module 3 Interrupt Enable Bit
* | | |0 = Sample Module 3 interrupt Disabled.
* | | |1 = Sample Module 3 interrupt Enabled.
* |[4] |SPLIE4 |Sample Module 4 Interrupt Enable Bit
* | | |0 = Sample Module 4 interrupt Disabled.
* | | |1 = Sample Module 4 interrupt Enabled.
* |[5] |SPLIE5 |Sample Module 5 Interrupt Enable Bit
* | | |0 = Sample Module 5 interrupt Disabled.
* | | |1 = Sample Module 5 interrupt Enabled.
* |[6] |SPLIE6 |Sample Module 6 Interrupt Enable Bit
* | | |0 = Sample Module 6 interrupt Disabled.
* | | |1 = Sample Module 6 interrupt Enabled.
* |[7] |SPLIE7 |Sample Module 7 Interrupt Enable Bit
* | | |0 = Sample Module 7 interrupt Disabled.
* | | |1 = Sample Module 7 interrupt Enabled.
* |[8] |SPLIE8 |Sample Module 8 Interrupt Enable Bit
* | | |0 = Sample Module 8 interrupt Disabled.
* | | |1 = Sample Module 8 interrupt Enabled.
* |[9] |SPLIE9 |Sample Module 9 Interrupt Enable Bit
* | | |0 = Sample Module 9 interrupt Disabled.
* | | |1 = Sample Module 9 interrupt Enabled.
* |[10] |SPLIE10 |Sample Module 10 Interrupt Enable Bit
* | | |0 = Sample Module 10 interrupt Disabled.
* | | |1 = Sample Module 10 interrupt Enabled.
* |[11] |SPLIE11 |Sample Module 11 Interrupt Enable Bit
* | | |0 = Sample Module 11 interrupt Disabled.
* | | |1 = Sample Module 11 interrupt Enabled.
* |[12] |SPLIE12 |Sample Module 12 Interrupt Enable Bit
* | | |0 = Sample Module 12 interrupt Disabled.
* | | |1 = Sample Module 12 interrupt Enabled.
* |[13] |SPLIE13 |Sample Module 13 Interrupt Enable Bit
* | | |0 = Sample Module 13 interrupt Disabled.
* | | |1 = Sample Module 13 interrupt Enabled.
* |[14] |SPLIE14 |Sample Module 14 Interrupt Enable Bit
* | | |0 = Sample Module 14 interrupt Disabled.
* | | |1 = Sample Module 14 interrupt Enabled.
* |[15] |SPLIE15 |Sample Module 15 Interrupt Enable Bit
* | | |0 = Sample Module 15 interrupt Disabled.
* | | |1 = Sample Module 15 interrupt Enabled.
* |[16] |SPLIE16 |Sample Module 16 Interrupt Enable Bit
* | | |0 = Sample Module 16 interrupt Disabled.
* | | |1 = Sample Module 16 interrupt Enabled.
* |[17] |SPLIE17 |Sample Module 17 Interrupt Enable Bit
* | | |0 = Sample Module 17 interrupt Disabled.
* | | |1 = Sample Module 17 interrupt Enabled.
* |[18] |SPLIE18 |Sample Module 18 Interrupt Enable Bit
* | | |0 = Sample Module 18 interrupt Disabled.
* | | |1 = Sample Module 18 interrupt Enabled.
* @var EADC_T::CMP[4]
* Offset: 0xE0 ADC Result Compare Register 0~3
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[0] |ADCMPEN |ADC Result Compare Enable Bit
* | | |0 = Compare Disabled.
* | | |1 = Compare Enabled.
* | | |Set this bit to 1 to enable compare CMPDAT (EADC_CMPn[27:16], n=0~3) with specified sample module conversion result when converted data is loaded into EADC_DAT register.
* |[1] |ADCMPIE |ADC Result Compare Interrupt Enable Bit
* | | |0 = Compare function interrupt Disabled.
* | | |1 = Compare function interrupt Enabled.
* | | |If the compare function is enabled and the compare condition matches the setting of CMPCOND (EADC_CMPn[2], n=0~3) and CMPMCNT (EADC_CMPn[11:8], n=0~3), ADCMPFn (EADC_STATUS2[7:4], n=0~3) will be asserted, in the meanwhile, if ADCMPIE is set to 1, a compare interrupt request is generated.
* |[2] |CMPCOND |Compare Condition
* | | |0= Set the compare condition as that when a 12-bit ADC conversion result is less than the 12-bit CMPDAT (EADC_CMPn [27:16]), the internal match counter will increase one.
* | | |1= Set the compare condition as that when a 12-bit ADC conversion result is greater or equal to the 12-bit CMPDAT (EADC_CMPn [27:16]), the internal match counter will increase one.
* | | |Note: When the internal counter reaches the value to (CMPMCNT (EADC_CMPn[11:8], n=0~3) +1), the CMPF bit will be set.
* |[7:3] |CMPSPL |Compare Sample Module Selection
* | | |00000 = Sample Module 0 conversion result EADC_DAT0 is selected to be compared.
* | | |00001 = Sample Module 1 conversion result EADC_DAT1 is selected to be compared.
* | | |00010 = Sample Module 2 conversion result EADC_DAT2 is selected to be compared.
* | | |00011 = Sample Module 3 conversion result EADC_DAT3 is selected to be compared.
* | | |00100 = Sample Module 4 conversion result EADC_DAT4 is selected to be compared.
* | | |00101 = Sample Module 5 conversion result EADC_DAT5 is selected to be compared.
* | | |00110 = Sample Module 6 conversion result EADC_DAT6 is selected to be compared.
* | | |00111 = Sample Module 7 conversion result EADC_DAT7 is selected to be compared.
* | | |01000 = Sample Module 8 conversion result EADC_DAT8 is selected to be compared.
* | | |01001 = Sample Module 9 conversion result EADC_DAT9 is selected to be compared.
* | | |01010 = Sample Module 10 conversion result EADC_DAT10 is selected to be compared.
* | | |01011 = Sample Module 11 conversion result EADC_DAT11 is selected to be compared.
* | | |01100 = Sample Module 12 conversion result EADC_DAT12 is selected to be compared.
* | | |01101 = Sample Module 13 conversion result EADC_DAT13 is selected to be compared.
* | | |01110 = Sample Module 14 conversion result EADC_DAT14 is selected to be compared.
* | | |01111 = Sample Module 15 conversion result EADC_DAT15 is selected to be compared.
* | | |10000 = Sample Module 16 conversion result EADC_DAT16 is selected to be compared.
* | | |10001 = Sample Module 17 conversion result EADC_DAT17 is selected to be compared.
* | | |10010 = Sample Module 18 conversion result EADC_DAT18 is selected to be compared.
* |[11:8] |CMPMCNT |Compare Match Count
* | | |When the specified ADC sample module analog conversion result matches the compare condition defined by CMPCOND (EADC_CMPn[2], n=0~3), the internal match counter will increase 1
* | | |If the compare result does not meet the compare condition, the internal compare match counter will reset to 0
* | | |When the internal counter reaches the value to (CMPMCNT +1), the ADCMPFn (EADC_STATUS2[7:4], n=0~3) will be set.
* |[15] |CMPWEN |Compare Window Mode Enable Bit
* | | |0 = ADCMPF0 (EADC_STATUS2[4]) will be set when EADC_CMP0 compared condition matched
* | | |ADCMPF2 (EADC_STATUS2[6]) will be set when EADC_CMP2 compared condition matched
* | | |1 = ADCMPF0 (EADC_STATUS2[4]) will be set when both EADC_CMP0 and EADC_CMP1 compared condition matched
* | | |ADCMPF2 (EADC_STATUS2[6]) will be set when both EADC_CMP2 and EADC_CMP3 compared condition matched.
* | | |Note: This bit is only present in EADC_CMP0 and EADC_CMP2 register.
* |[27:16] |CMPDAT |Comparison Data
* | | |The 12 bits data is used to compare with conversion result of specified sample module
* | | |User can use it to monitor the external analog input pin voltage transition without imposing a load on software.
* @var EADC_T::STATUS0
* Offset: 0xF0 ADC Status Register 0
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[15:0] |VALID |EADC_DAT0~15 Data Valid Flag
* | | |It is a mirror of VALID bit in sample module ADC result data register EADC_DATn. (n=0~18).
* |[31:16] |OV |EADC_DAT0~15 Overrun Flag
* | | |It is a mirror to OV bit in sample module ADC result data register EADC_DATn. (n=0~18).
* @var EADC_T::STATUS1
* Offset: 0xF4 ADC Status Register 1
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[2:0] |VALID |EADC_DAT16~18 Data Valid Flag
* | | |It is a mirror of VALID bit in sample module ADC result data register EADC_DATn. (n=0~18).
* |[18:16] |OV |EADC_DAT16~18 Overrun Flag
* | | |It is a mirror to OV bit in sample module ADC result data register EADC_DATn. (n=0~18).
* @var EADC_T::STATUS2
* Offset: 0xF8 ADC Status Register 2
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[0] |ADIF0 |ADC ADINT0 Interrupt Flag
* | | |0 = No ADINT0 interrupt pulse received.
* | | |1 = ADINT0 interrupt pulse has been received.
* | | |Note1: This bit is cleared by writing 1 to it.
* | | |Note2:This bit indicates whether an ADC conversion of specific sample module has been completed
* |[1] |ADIF1 |ADC ADINT1 Interrupt Flag
* | | |0 = No ADINT1 interrupt pulse received.
* | | |1 = ADINT1 interrupt pulse has been received.
* | | |Note1: This bit is cleared by writing 1 to it.
* | | |Note2:This bit indicates whether an ADC conversion of specific sample module has been completed
* |[2] |ADIF2 |ADC ADINT2 Interrupt Flag
* | | |0 = No ADINT2 interrupt pulse received.
* | | |1 = ADINT2 interrupt pulse has been received.
* | | |Note1: This bit is cleared by writing 1 to it.
* | | |Note2:This bit indicates whether an ADC conversion of specific sample module has been completed
* |[3] |ADIF3 |ADC ADINT3 Interrupt Flag
* | | |0 = No ADINT3 interrupt pulse received.
* | | |1 = ADINT3 interrupt pulse has been received.
* | | |Note1: This bit is cleared by writing 1 to it.
* | | |Note2:This bit indicates whether an ADC conversion of specific sample module has been completed
* |[4] |ADCMPF0 |ADC Compare 0 Flag
* | | |When the specific sample module ADC conversion result meets setting condition in EADC_CMP0 then this bit is set to 1.
* | | |0 = Conversion result in EADC_DAT does not meet EADC_CMP0 register setting.
* | | |1 = Conversion result in EADC_DAT meets EADC_CMP0 register setting.
* | | |Note: This bit is cleared by writing 1 to it.
* |[5] |ADCMPF1 |ADC Compare 1 Flag
* | | |When the specific sample module ADC conversion result meets setting condition in EADC_CMP1 then this bit is set to 1.
* | | |0 = Conversion result in EADC_DAT does not meet EADC_CMP1 register setting.
* | | |1 = Conversion result in EADC_DAT meets EADC_CMP1 register setting.
* | | |Note: This bit is cleared by writing 1 to it.
* |[6] |ADCMPF2 |ADC Compare 2 Flag
* | | |When the specific sample module ADC conversion result meets setting condition in EADC_CMP2 then this bit is set to 1.
* | | |0 = Conversion result in EADC_DAT does not meet EADC_CMP2 register setting.
* | | |1 = Conversion result in EADC_DAT meets EADC_CMP2 register setting.
* | | |Note: This bit is cleared by writing 1 to it.
* |[7] |ADCMPF3 |ADC Compare 3 Flag
* | | |When the specific sample module ADC conversion result meets setting condition in EADC_CMP3 then this bit is set to 1.
* | | |0 = Conversion result in EADC_DAT does not meet EADC_CMP3 register setting.
* | | |1 = Conversion result in EADC_DAT meets EADC_CMP3 register setting.
* | | |Note: This bit is cleared by writing 1 to it.
* |[8] |ADOVIF0 |ADC ADINT0 Interrupt Flag Overrun
* | | |0 = ADINT0 interrupt flag is not overwritten to 1.
* | | |1 = ADINT0 interrupt flag is overwritten to 1.
* | | |Note: This bit is cleared by writing 1 to it.
* |[9] |ADOVIF1 |ADC ADINT1 Interrupt Flag Overrun
* | | |0 = ADINT1 interrupt flag is not overwritten to 1.
* | | |1 = ADINT1 interrupt flag is overwritten to 1.
* | | |Note: This bit is cleared by writing 1 to it.
* |[10] |ADOVIF2 |ADC ADINT2 Interrupt Flag Overrun
* | | |0 = ADINT2 interrupt flag is not overwritten to 1.
* | | |1 = ADINT2 interrupt flag is s overwritten to 1.
* | | |Note: This bit is cleared by writing 1 to it.
* |[11] |ADOVIF3 |ADC ADINT3 Interrupt Flag Overrun
* | | |0 = ADINT3 interrupt flag is not overwritten to 1.
* | | |1 = ADINT3 interrupt flag is overwritten to 1.
* | | |Note: This bit is cleared by writing 1 to it.
* |[12] |ADCMPO0 |ADC Compare 0 Output Status (Read Only)
* | | |The 12 bits compare0 data CMPDAT0 (EADC_CMP0[27:16]) is used to compare with conversion result of specified sample module.
* | | |User can use it to monitor the external analog input pin voltage status.
* | | |0 = Conversion result in EADC_DAT less than CMPDAT0 setting.
* | | |1 = Conversion result in EADC_DAT great than or equal CMPDAT0 setting.
* |[13] |ADCMPO1 |ADC Compare 1 Output Status (Read Only)
* | | |The 12 bits compare1 data CMPDAT1 (EADC_CMP1[27:16]) is used to compare with conversion result of specified sample module.
* | | |User can use it to monitor the external analog input pin voltage status.
* | | |0 = Conversion result in EADC_DAT less than CMPDAT1 setting.
* | | |1 = Conversion result in EADC_DAT great than or equal CMPDAT1 setting.
* |[14] |ADCMPO2 |ADC Compare 2 Output Status (Read Only)
* | | |The 12 bits compare2 data CMPDAT2 (EADC_CMP2[27:16]) is used to compare with conversion result of specified sample module.
* | | |User can use it to monitor the external analog input pin voltage status.
* | | |0 = Conversion result in EADC_DAT less than CMPDAT2 setting.
* | | |1 = Conversion result in EADC_DAT great than or equal CMPDAT2 setting.
* |[15] |ADCMPO3 |ADC Compare 3 Output Status (Read Only)
* | | |The 12 bits compare3 data CMPDAT3 (EADC_CMP3[27:16]) is used to compare with conversion result of specified sample module.
* | | |User can use it to monitor the external analog input pin voltage status.
* | | |0 = Conversion result in EADC_DAT less than CMPDAT3 setting.
* | | |1 = Conversion result in EADC_DAT great than or equal CMPDAT3 setting.
* |[20:16] |CHANNEL |Current Conversion Channel (Read Only)
* | | |This filed reflects ADC current conversion channel when BUSY=1.
* | | |It is read only.
* | | |00H = EADC_CH0.
* | | |01H = EADC_CH1.
* | | |02H = EADC_CH2.
* | | |03H = EADC_CH3.
* | | |04H = EADC_CH4.
* | | |05H = EADC_CH5.
* | | |06H = EADC_CH6.
* | | |07H = EADC_CH7.
* | | |08H = EADC_CH8.
* | | |09H = EADC_CH9.
* | | |0AH = EADC_CH10.
* | | |0BH = EADC_CH11.
* | | |0CH = EADC_CH12.
* | | |0DH = EADC_CH13.
* | | |0EH = EADC_CH14.
* | | |0FH = EADC_CH15.
* | | |10H = VBG.
* | | |11H = VTEMP.
* | | |12H = VBAT/4.
* |[23] |BUSY |Busy/Idle (Read Only)
* | | |0 = EADC is in idle state.
* | | |1 = EADC is busy at conversion.
* |[24] |ADOVIF |All ADC Interrupt Flag Overrun Bits Check (Read Only)
* | | |n=0~3.
* | | |0 = None of ADINT interrupt flag ADOVIFn (EADC_STATUS2[11:8]) is overwritten to 1.
* | | |1 = Any one of ADINT interrupt flag ADOVIFn (EADC_STATUS2[11:8]) is overwritten to 1.
* | | |Note: This bit will keep 1 when any ADOVIFn Flag is equal to 1.
* |[25] |STOVF |for All ADC Sample Module Start of Conversion Overrun Flags Check (Read Only)
* | | |n=0~18.
* | | |0 = None of sample module event overrun flag SPOVFn (EADC_OVSTS[n]) is set to 1.
* | | |1 = Any one of sample module event overrun flag SPOVFn (EADC_OVSTS[n]) is set to 1.
* | | |Note: This bit will keep 1 when any SPOVFn Flag is equal to 1.
* |[26] |AVALID |for All Sample Module ADC Result Data Register EADC_DAT Data Valid Flag Check (Read Only)
* | | |n=0~18.
* | | |0 = None of sample module data register valid flag VALIDn (EADC_DATn[17]) is set to 1.
* | | |1 = Any one of sample module data register valid flag VALIDn (EADC_DATn[17]) is set to 1.
* | | |Note: This bit will keep 1 when any VALIDn Flag is equal to 1.
* |[27] |AOV |for All Sample Module ADC Result Data Register Overrun Flags Check (Read Only)
* | | |n=0~18.
* | | |0 = None of sample module data register overrun flag OVn (EADC_DATn[16]) is set to 1.
* | | |1 = Any one of sample module data register overrun flag OVn (EADC_DATn[16]) is set to 1.
* | | |Note: This bit will keep 1 when any OVn Flag is equal to 1.
* @var EADC_T::STATUS3
* Offset: 0xFC ADC Status Register 3
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[4:0] |CURSPL |ADC Current Sample Module
* | | |This register show the current ADC is controlled by which sample module control logic modules.
* | | |If the ADC is Idle, this bit filed will set to 0x1F.
* | | |This is a read only register.
* @var EADC_T::DDAT
* Offset: 0x100-0x10C ADC Double Data Register n for Sample Module n, n=0~3
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[15:0] |RESULT |ADC Conversion Results
* | | |This field contains 12 bits conversion results.
* | | |When the DMOF (EADC_CTL[9]) is set to 0, 12-bit ADC conversion result with unsigned format will be filled in RESULT [11:0] and zero will be filled in RESULT [15:12].
* | | |When DMOF (EADC_CTL[9]) set to 1, 12-bit ADC conversion result with 2'complement format will be filled in RESULT [11:0] and signed bits to will be filled in RESULT [15:12].
* |[16] |OV |Overrun Flag
* | | |0 = Data in RESULT (EADC_DATn[15:0], n=0~3) is recent conversion result.
* | | |1 = Data in RESULT (EADC_DATn[15:0], n=0~3) is overwrite.
* | | |If converted data in RESULT[15:0] has not been read before new conversion result is loaded to this register, OV is set to 1.
* | | |It is cleared by hardware after EADC_DDAT register is read.
* |[17] |VALID |Valid Flag
* | | |0 = Double data in RESULT (EADC_DDATn[15:0]) is not valid.
* | | |1 = Double data in RESULT (EADC_DDATn[15:0]) is valid.
* | | |This bit is set to 1 when corresponding sample module channel analog input conversion is completed and cleared by hardware after EADC_DDATn register is read.
* | | |(n=0~3).
* @var EADC_T::PWRM
* Offset: 0x110 ADC Power Management Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[0] |PWUPRDY |ADC Power-up Sequence Completed and Ready for Conversion (Read Only)
* | | |0 = ADC is not ready for conversion may be in power down state or in the progress of power up.
* | | |1 = ADC is ready for conversion.
* |[1] |PWUCALEN |Power Up Calibration Function Enable Control
* | | |0 = Disable the function of calibration at power up.
* | | |1 = Enable the function of calibration at power up.
* | | |Note: This bit work together with CALSEL (EADC_CALCTL [3]), see the following
* | | |{PWUCALEN, CALSEL } Description:
* | | |PWUCALEN is 0 and CALSEL is 0: No need to calibrate.
* | | |PWUCALEN is 0 and CALSEL is 1: No need to calibrate.
* | | |PWUCALEN is 1 and CALSEL is 0: Load calibration word when power up.
* | | |PWUCALEN is 1 and CALSEL is 1: Calibrate when power up.
* |[3:2] |PWDMOD |ADC Power-down Mode
* | | |Set this bit fields to select ADC power down mode when system power-down.
* | | |00 = ADC Deep power down mode.
* | | |01 = ADC Power down.
* | | |10 = ADC Standby mode.
* | | |11 = ADC Deep power down mode.
* | | |Note: Different PWDMOD has different power down/up sequence, in order to avoid ADC powering up with wrong sequence; user must keep PWMOD consistent each time in power down and start up
* |[19:8] |LDOSUT |ADC Internal LDO Start-up Time
* | | |Set this bit fields to control LDO start-up time
* | | |The minimum required LDO start-up time is 20us
* | | |LDO start-up time = (1/ADC_CLK) x LDOSUT.
* @var EADC_T::CALCTL
* Offset: 0x114 ADC Calibration Control Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[1] |CALSTART |Calibration Functional Block Start
* | | |0 = Stops calibration functional block.
* | | |1 = Starts calibration functional block.
* | | |Note: This bit is set by SW and clear by HW after re-calibration finish
* |[2] |CALDONE |Calibration Functional Block Complete (Read Only)
* | | |0 = During a calibration.
* | | |1 = Calibration is completed.
* |[3] |CALSEL |Select Calibration Functional Block
* | | |0 = Load calibration word when calibration functional block is active.
* | | |1 = Execute calibration when calibration functional block is active.
* @var EADC_T::CALDWRD
* Offset: 0x118 ADC Calibration Load Word Register
* ---------------------------------------------------------------------------------------------------
* |Bits |Field |Descriptions
* | :----: | :----: | :---- |
* |[6:0] |CALWORD |Calibration Word Bits
* | | |Write to this register with the previous calibration word before load calibration action.
* | | |Read this register after calibration done.
* | | |Note: The calibration block contains two parts CALIBRATION and LOAD CALIBRATION; if the calibration block configure as CALIBRATION; then this register represent the result of calibration when calibration is completed; if configure as LOAD CALIBRATION ; configure this register before loading calibration action, after loading calibration complete, the laoded calibration word will apply to the ADC; while in loading calibration function the loaded value will not be equal to the original CALWORD until calibration is done.
*/
__I uint32_t DAT[19]; /*!< [0x0000~0x0048] ADC Data Register n for Sample Module n, n=0~18 */
__I uint32_t CURDAT; /*!< [0x004c] ADC PDMA Current Transfer Data Register */
__IO uint32_t CTL; /*!< [0x0050] ADC Control Register */
__O uint32_t SWTRG; /*!< [0x0054] ADC Sample Module Software Start Register */
__IO uint32_t PENDSTS; /*!< [0x0058] ADC Start of Conversion Pending Flag Register */
__IO uint32_t OVSTS; /*!< [0x005c] ADC Sample Module Start of Conversion Overrun Flag Register */
__I uint32_t RESERVE0[8];
__IO uint32_t SCTL[19]; /*!< [0x0080~0x00c8] ADC Sample Module n Control Register, n=0~18 */
__I uint32_t RESERVE1[1];
__IO uint32_t INTSRC[4]; /*!< [0x00d0~0x00dc] ADC interrupt n Source Enable Control Register, n=0~3 */
__IO uint32_t CMP[4]; /*!< [0x00e0~0x00ec] ADC Result Compare Register n, n=0~3 */
__I uint32_t STATUS0; /*!< [0x00f0] ADC Status Register 0 */
__I uint32_t STATUS1; /*!< [0x00f4] ADC Status Register 1 */
__IO uint32_t STATUS2; /*!< [0x00f8] ADC Status Register 2 */
__I uint32_t STATUS3; /*!< [0x00fc] ADC Status Register 3 */
__I uint32_t DDAT[4]; /*!< [0x0100~0x010c] ADC Double Data Register n for Sample Module n, n=0~3 */
__IO uint32_t PWRM; /*!< [0x0110] ADC Power Management Register */
__IO uint32_t CALCTL; /*!< [0x0114] ADC Calibration Control Register */
__IO uint32_t CALDWRD; /*!< [0x0118] ADC Calibration Load Word Register */
__I uint32_t RESERVE2[5];
__IO uint32_t PDMACTL; /*!< [0x0130] ADC PDMA Control Register */
} EADC_T;
/**
@addtogroup EADC_CONST EADC Bit Field Definition
Constant Definitions for EADC Controller
@{
*/
#define EADC_DAT_RESULT_Pos (0) /*!< EADC_T::DAT: RESULT Position */
#define EADC_DAT_RESULT_Msk (0xfffful << EADC_DAT_RESULT_Pos) /*!< EADC_T::DAT: RESULT Mask */
#define EADC_DAT_OV_Pos (16) /*!< EADC_T::DAT: OV Position */
#define EADC_DAT_OV_Msk (0x1ul << EADC_DAT_OV_Pos) /*!< EADC_T::DAT: OV Mask */
#define EADC_DAT_VALID_Pos (17) /*!< EADC_T::DAT: VALID Position */
#define EADC_DAT_VALID_Msk (0x1ul << EADC_DAT_VALID_Pos) /*!< EADC_T::DAT: VALID Mask */
#define EADC_DAT0_RESULT_Pos (0) /*!< EADC_T::DAT0: RESULT Position */
#define EADC_DAT0_RESULT_Msk (0xfffful << EADC_DAT0_RESULT_Pos) /*!< EADC_T::DAT0: RESULT Mask */
#define EADC_DAT0_OV_Pos (16) /*!< EADC_T::DAT0: OV Position */
#define EADC_DAT0_OV_Msk (0x1ul << EADC_DAT0_OV_Pos) /*!< EADC_T::DAT0: OV Mask */
#define EADC_DAT0_VALID_Pos (17) /*!< EADC_T::DAT0: VALID Position */
#define EADC_DAT0_VALID_Msk (0x1ul << EADC_DAT0_VALID_Pos) /*!< EADC_T::DAT0: VALID Mask */
#define EADC_DAT1_RESULT_Pos (0) /*!< EADC_T::DAT1: RESULT Position */
#define EADC_DAT1_RESULT_Msk (0xfffful << EADC_DAT1_RESULT_Pos) /*!< EADC_T::DAT1: RESULT Mask */
#define EADC_DAT1_OV_Pos (16) /*!< EADC_T::DAT1: OV Position */
#define EADC_DAT1_OV_Msk (0x1ul << EADC_DAT1_OV_Pos) /*!< EADC_T::DAT1: OV Mask */
#define EADC_DAT1_VALID_Pos (17) /*!< EADC_T::DAT1: VALID Position */
#define EADC_DAT1_VALID_Msk (0x1ul << EADC_DAT1_VALID_Pos) /*!< EADC_T::DAT1: VALID Mask */
#define EADC_DAT2_RESULT_Pos (0) /*!< EADC_T::DAT2: RESULT Position */
#define EADC_DAT2_RESULT_Msk (0xfffful << EADC_DAT2_RESULT_Pos) /*!< EADC_T::DAT2: RESULT Mask */
#define EADC_DAT2_OV_Pos (16) /*!< EADC_T::DAT2: OV Position */
#define EADC_DAT2_OV_Msk (0x1ul << EADC_DAT2_OV_Pos) /*!< EADC_T::DAT2: OV Mask */
#define EADC_DAT2_VALID_Pos (17) /*!< EADC_T::DAT2: VALID Position */
#define EADC_DAT2_VALID_Msk (0x1ul << EADC_DAT2_VALID_Pos) /*!< EADC_T::DAT2: VALID Mask */
#define EADC_DAT3_RESULT_Pos (0) /*!< EADC_T::DAT3: RESULT Position */
#define EADC_DAT3_RESULT_Msk (0xfffful << EADC_DAT3_RESULT_Pos) /*!< EADC_T::DAT3: RESULT Mask */
#define EADC_DAT3_OV_Pos (16) /*!< EADC_T::DAT3: OV Position */
#define EADC_DAT3_OV_Msk (0x1ul << EADC_DAT3_OV_Pos) /*!< EADC_T::DAT3: OV Mask */
#define EADC_DAT3_VALID_Pos (17) /*!< EADC_T::DAT3: VALID Position */
#define EADC_DAT3_VALID_Msk (0x1ul << EADC_DAT3_VALID_Pos) /*!< EADC_T::DAT3: VALID Mask */
#define EADC_DAT4_RESULT_Pos (0) /*!< EADC_T::DAT4: RESULT Position */
#define EADC_DAT4_RESULT_Msk (0xfffful << EADC_DAT4_RESULT_Pos) /*!< EADC_T::DAT4: RESULT Mask */
#define EADC_DAT4_OV_Pos (16) /*!< EADC_T::DAT4: OV Position */
#define EADC_DAT4_OV_Msk (0x1ul << EADC_DAT4_OV_Pos) /*!< EADC_T::DAT4: OV Mask */
#define EADC_DAT4_VALID_Pos (17) /*!< EADC_T::DAT4: VALID Position */
#define EADC_DAT4_VALID_Msk (0x1ul << EADC_DAT4_VALID_Pos) /*!< EADC_T::DAT4: VALID Mask */
#define EADC_DAT5_RESULT_Pos (0) /*!< EADC_T::DAT5: RESULT Position */
#define EADC_DAT5_RESULT_Msk (0xfffful << EADC_DAT5_RESULT_Pos) /*!< EADC_T::DAT5: RESULT Mask */
#define EADC_DAT5_OV_Pos (16) /*!< EADC_T::DAT5: OV Position */
#define EADC_DAT5_OV_Msk (0x1ul << EADC_DAT5_OV_Pos) /*!< EADC_T::DAT5: OV Mask */
#define EADC_DAT5_VALID_Pos (17) /*!< EADC_T::DAT5: VALID Position */
#define EADC_DAT5_VALID_Msk (0x1ul << EADC_DAT5_VALID_Pos) /*!< EADC_T::DAT5: VALID Mask */
#define EADC_DAT6_RESULT_Pos (0) /*!< EADC_T::DAT6: RESULT Position */
#define EADC_DAT6_RESULT_Msk (0xfffful << EADC_DAT6_RESULT_Pos) /*!< EADC_T::DAT6: RESULT Mask */
#define EADC_DAT6_OV_Pos (16) /*!< EADC_T::DAT6: OV Position */
#define EADC_DAT6_OV_Msk (0x1ul << EADC_DAT6_OV_Pos) /*!< EADC_T::DAT6: OV Mask */
#define EADC_DAT6_VALID_Pos (17) /*!< EADC_T::DAT6: VALID Position */
#define EADC_DAT6_VALID_Msk (0x1ul << EADC_DAT6_VALID_Pos) /*!< EADC_T::DAT6: VALID Mask */
#define EADC_DAT7_RESULT_Pos (0) /*!< EADC_T::DAT7: RESULT Position */
#define EADC_DAT7_RESULT_Msk (0xfffful << EADC_DAT7_RESULT_Pos) /*!< EADC_T::DAT7: RESULT Mask */
#define EADC_DAT7_OV_Pos (16) /*!< EADC_T::DAT7: OV Position */
#define EADC_DAT7_OV_Msk (0x1ul << EADC_DAT7_OV_Pos) /*!< EADC_T::DAT7: OV Mask */
#define EADC_DAT7_VALID_Pos (17) /*!< EADC_T::DAT7: VALID Position */
#define EADC_DAT7_VALID_Msk (0x1ul << EADC_DAT7_VALID_Pos) /*!< EADC_T::DAT7: VALID Mask */
#define EADC_DAT8_RESULT_Pos (0) /*!< EADC_T::DAT8: RESULT Position */
#define EADC_DAT8_RESULT_Msk (0xfffful << EADC_DAT8_RESULT_Pos) /*!< EADC_T::DAT8: RESULT Mask */
#define EADC_DAT8_OV_Pos (16) /*!< EADC_T::DAT8: OV Position */
#define EADC_DAT8_OV_Msk (0x1ul << EADC_DAT8_OV_Pos) /*!< EADC_T::DAT8: OV Mask */
#define EADC_DAT8_VALID_Pos (17) /*!< EADC_T::DAT8: VALID Position */
#define EADC_DAT8_VALID_Msk (0x1ul << EADC_DAT8_VALID_Pos) /*!< EADC_T::DAT8: VALID Mask */
#define EADC_DAT9_RESULT_Pos (0) /*!< EADC_T::DAT9: RESULT Position */
#define EADC_DAT9_RESULT_Msk (0xfffful << EADC_DAT9_RESULT_Pos) /*!< EADC_T::DAT9: RESULT Mask */
#define EADC_DAT9_OV_Pos (16) /*!< EADC_T::DAT9: OV Position */
#define EADC_DAT9_OV_Msk (0x1ul << EADC_DAT9_OV_Pos) /*!< EADC_T::DAT9: OV Mask */
#define EADC_DAT9_VALID_Pos (17) /*!< EADC_T::DAT9: VALID Position */
#define EADC_DAT9_VALID_Msk (0x1ul << EADC_DAT9_VALID_Pos) /*!< EADC_T::DAT9: VALID Mask */
#define EADC_DAT10_RESULT_Pos (0) /*!< EADC_T::DAT10: RESULT Position */
#define EADC_DAT10_RESULT_Msk (0xfffful << EADC_DAT10_RESULT_Pos) /*!< EADC_T::DAT10: RESULT Mask */
#define EADC_DAT10_OV_Pos (16) /*!< EADC_T::DAT10: OV Position */
#define EADC_DAT10_OV_Msk (0x1ul << EADC_DAT10_OV_Pos) /*!< EADC_T::DAT10: OV Mask */
#define EADC_DAT10_VALID_Pos (17) /*!< EADC_T::DAT10: VALID Position */
#define EADC_DAT10_VALID_Msk (0x1ul << EADC_DAT10_VALID_Pos) /*!< EADC_T::DAT10: VALID Mask */
#define EADC_DAT11_RESULT_Pos (0) /*!< EADC_T::DAT11: RESULT Position */
#define EADC_DAT11_RESULT_Msk (0xfffful << EADC_DAT11_RESULT_Pos) /*!< EADC_T::DAT11: RESULT Mask */
#define EADC_DAT11_OV_Pos (16) /*!< EADC_T::DAT11: OV Position */
#define EADC_DAT11_OV_Msk (0x1ul << EADC_DAT11_OV_Pos) /*!< EADC_T::DAT11: OV Mask */
#define EADC_DAT11_VALID_Pos (17) /*!< EADC_T::DAT11: VALID Position */
#define EADC_DAT11_VALID_Msk (0x1ul << EADC_DAT11_VALID_Pos) /*!< EADC_T::DAT11: VALID Mask */
#define EADC_DAT12_RESULT_Pos (0) /*!< EADC_T::DAT12: RESULT Position */
#define EADC_DAT12_RESULT_Msk (0xfffful << EADC_DAT12_RESULT_Pos) /*!< EADC_T::DAT12: RESULT Mask */
#define EADC_DAT12_OV_Pos (16) /*!< EADC_T::DAT12: OV Position */
#define EADC_DAT12_OV_Msk (0x1ul << EADC_DAT12_OV_Pos) /*!< EADC_T::DAT12: OV Mask */
#define EADC_DAT12_VALID_Pos (17) /*!< EADC_T::DAT12: VALID Position */
#define EADC_DAT12_VALID_Msk (0x1ul << EADC_DAT12_VALID_Pos) /*!< EADC_T::DAT12: VALID Mask */
#define EADC_DAT13_RESULT_Pos (0) /*!< EADC_T::DAT13: RESULT Position */
#define EADC_DAT13_RESULT_Msk (0xfffful << EADC_DAT13_RESULT_Pos) /*!< EADC_T::DAT13: RESULT Mask */
#define EADC_DAT13_OV_Pos (16) /*!< EADC_T::DAT13: OV Position */
#define EADC_DAT13_OV_Msk (0x1ul << EADC_DAT13_OV_Pos) /*!< EADC_T::DAT13: OV Mask */
#define EADC_DAT13_VALID_Pos (17) /*!< EADC_T::DAT13: VALID Position */
#define EADC_DAT13_VALID_Msk (0x1ul << EADC_DAT13_VALID_Pos) /*!< EADC_T::DAT13: VALID Mask */
#define EADC_DAT14_RESULT_Pos (0) /*!< EADC_T::DAT14: RESULT Position */
#define EADC_DAT14_RESULT_Msk (0xfffful << EADC_DAT14_RESULT_Pos) /*!< EADC_T::DAT14: RESULT Mask */
#define EADC_DAT14_OV_Pos (16) /*!< EADC_T::DAT14: OV Position */
#define EADC_DAT14_OV_Msk (0x1ul << EADC_DAT14_OV_Pos) /*!< EADC_T::DAT14: OV Mask */
#define EADC_DAT14_VALID_Pos (17) /*!< EADC_T::DAT14: VALID Position */
#define EADC_DAT14_VALID_Msk (0x1ul << EADC_DAT14_VALID_Pos) /*!< EADC_T::DAT14: VALID Mask */
#define EADC_DAT15_RESULT_Pos (0) /*!< EADC_T::DAT15: RESULT Position */
#define EADC_DAT15_RESULT_Msk (0xfffful << EADC_DAT15_RESULT_Pos) /*!< EADC_T::DAT15: RESULT Mask */
#define EADC_DAT15_OV_Pos (16) /*!< EADC_T::DAT15: OV Position */
#define EADC_DAT15_OV_Msk (0x1ul << EADC_DAT15_OV_Pos) /*!< EADC_T::DAT15: OV Mask */
#define EADC_DAT15_VALID_Pos (17) /*!< EADC_T::DAT15: VALID Position */
#define EADC_DAT15_VALID_Msk (0x1ul << EADC_DAT15_VALID_Pos) /*!< EADC_T::DAT15: VALID Mask */
#define EADC_DAT16_RESULT_Pos (0) /*!< EADC_T::DAT16: RESULT Position */
#define EADC_DAT16_RESULT_Msk (0xfffful << EADC_DAT16_RESULT_Pos) /*!< EADC_T::DAT16: RESULT Mask */
#define EADC_DAT16_OV_Pos (16) /*!< EADC_T::DAT16: OV Position */
#define EADC_DAT16_OV_Msk (0x1ul << EADC_DAT16_OV_Pos) /*!< EADC_T::DAT16: OV Mask */
#define EADC_DAT16_VALID_Pos (17) /*!< EADC_T::DAT16: VALID Position */
#define EADC_DAT16_VALID_Msk (0x1ul << EADC_DAT16_VALID_Pos) /*!< EADC_T::DAT16: VALID Mask */
#define EADC_DAT17_RESULT_Pos (0) /*!< EADC_T::DAT17: RESULT Position */
#define EADC_DAT17_RESULT_Msk (0xfffful << EADC_DAT17_RESULT_Pos) /*!< EADC_T::DAT17: RESULT Mask */
#define EADC_DAT17_OV_Pos (16) /*!< EADC_T::DAT17: OV Position */
#define EADC_DAT17_OV_Msk (0x1ul << EADC_DAT17_OV_Pos) /*!< EADC_T::DAT17: OV Mask */
#define EADC_DAT17_VALID_Pos (17) /*!< EADC_T::DAT17: VALID Position */
#define EADC_DAT17_VALID_Msk (0x1ul << EADC_DAT17_VALID_Pos) /*!< EADC_T::DAT17: VALID Mask */
#define EADC_DAT18_RESULT_Pos (0) /*!< EADC_T::DAT18: RESULT Position */
#define EADC_DAT18_RESULT_Msk (0xfffful << EADC_DAT18_RESULT_Pos) /*!< EADC_T::DAT18: RESULT Mask */
#define EADC_DAT18_OV_Pos (16) /*!< EADC_T::DAT18: OV Position */
#define EADC_DAT18_OV_Msk (0x1ul << EADC_DAT18_OV_Pos) /*!< EADC_T::DAT18: OV Mask */
#define EADC_DAT18_VALID_Pos (17) /*!< EADC_T::DAT18: VALID Position */
#define EADC_DAT18_VALID_Msk (0x1ul << EADC_DAT18_VALID_Pos) /*!< EADC_T::DAT18: VALID Mask */
#define EADC_CURDAT_CURDAT_Pos (0) /*!< EADC_T::CURDAT: CURDAT Position */
#define EADC_CURDAT_CURDAT_Msk (0x3fffful << EADC_CURDAT_CURDAT_Pos) /*!< EADC_T::CURDAT: CURDAT Mask */
#define EADC_CTL_ADCEN_Pos (0) /*!< EADC_T::CTL: ADCEN Position */
#define EADC_CTL_ADCEN_Msk (0x1ul << EADC_CTL_ADCEN_Pos) /*!< EADC_T::CTL: ADCEN Mask */
#define EADC_CTL_ADCRST_Pos (1) /*!< EADC_T::CTL: ADCRST Position */
#define EADC_CTL_ADCRST_Msk (0x1ul << EADC_CTL_ADCRST_Pos) /*!< EADC_T::CTL: ADCRST Mask */
#define EADC_CTL_ADCIEN0_Pos (2) /*!< EADC_T::CTL: ADCIEN0 Position */
#define EADC_CTL_ADCIEN0_Msk (0x1ul << EADC_CTL_ADCIEN0_Pos) /*!< EADC_T::CTL: ADCIEN0 Mask */
#define EADC_CTL_ADCIEN1_Pos (3) /*!< EADC_T::CTL: ADCIEN1 Position */
#define EADC_CTL_ADCIEN1_Msk (0x1ul << EADC_CTL_ADCIEN1_Pos) /*!< EADC_T::CTL: ADCIEN1 Mask */
#define EADC_CTL_ADCIEN2_Pos (4) /*!< EADC_T::CTL: ADCIEN2 Position */
#define EADC_CTL_ADCIEN2_Msk (0x1ul << EADC_CTL_ADCIEN2_Pos) /*!< EADC_T::CTL: ADCIEN2 Mask */
#define EADC_CTL_ADCIEN3_Pos (5) /*!< EADC_T::CTL: ADCIEN3 Position */
#define EADC_CTL_ADCIEN3_Msk (0x1ul << EADC_CTL_ADCIEN3_Pos) /*!< EADC_T::CTL: ADCIEN3 Mask */
#define EADC_CTL_RESSEL_Pos (6) /*!< EADC_T::CTL: RESSEL Position */
#define EADC_CTL_RESSEL_Msk (0x3ul << EADC_CTL_RESSEL_Pos) /*!< EADC_T::CTL: RESSEL Mask */
#define EADC_CTL_DIFFEN_Pos (8) /*!< EADC_T::CTL: DIFFEN Position */
#define EADC_CTL_DIFFEN_Msk (0x1ul << EADC_CTL_DIFFEN_Pos) /*!< EADC_T::CTL: DIFFEN Mask */
#define EADC_CTL_DMOF_Pos (9) /*!< EADC_T::CTL: DMOF Position */
#define EADC_CTL_DMOF_Msk (0x1ul << EADC_CTL_DMOF_Pos) /*!< EADC_T::CTL: DMOF Mask */
#define EADC_SWTRG_SWTRG_Pos (0) /*!< EADC_T::SWTRG: SWTRG Position */
#define EADC_SWTRG_SWTRG_Msk (0x7fffful << EADC_SWTRG_SWTRG_Pos) /*!< EADC_T::SWTRG: SWTRG Mask */
#define EADC_PENDSTS_STPF_Pos (0) /*!< EADC_T::PENDSTS: STPF Position */
#define EADC_PENDSTS_STPF_Msk (0x7fffful << EADC_PENDSTS_STPF_Pos) /*!< EADC_T::PENDSTS: STPF Mask */
#define EADC_OVSTS_SPOVF_Pos (0) /*!< EADC_T::OVSTS: SPOVF Position */
#define EADC_OVSTS_SPOVF_Msk (0x7fffful << EADC_OVSTS_SPOVF_Pos) /*!< EADC_T::OVSTS: SPOVF Mask */
#define EADC_SCTL_CHSEL_Pos (0) /*!< EADC_T::SCTL: CHSEL Position */
#define EADC_SCTL_CHSEL_Msk (0xful << EADC_SCTL_CHSEL_Pos) /*!< EADC_T::SCTL: CHSEL Mask */
#define EADC_SCTL_EXTREN_Pos (4) /*!< EADC_T::SCTL: EXTREN Position */
#define EADC_SCTL_EXTREN_Msk (0x1ul << EADC_SCTL_EXTREN_Pos) /*!< EADC_T::SCTL: EXTREN Mask */
#define EADC_SCTL_EXTFEN_Pos (5) /*!< EADC_T::SCTL: EXTFEN Position */
#define EADC_SCTL_EXTFEN_Msk (0x1ul << EADC_SCTL_EXTFEN_Pos) /*!< EADC_T::SCTL: EXTFEN Mask */
#define EADC_SCTL_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL: TRGDLYDIV Position */
#define EADC_SCTL_TRGDLYDIV_Msk (0x3ul << EADC_SCTL_TRGDLYDIV_Pos) /*!< EADC_T::SCTL: TRGDLYDIV Mask */
#define EADC_SCTL_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL: TRGDLYCNT Position */
#define EADC_SCTL_TRGDLYCNT_Msk (0xfful << EADC_SCTL_TRGDLYCNT_Pos) /*!< EADC_T::SCTL: TRGDLYCNT Mask */
#define EADC_SCTL_TRGSEL_Pos (16) /*!< EADC_T::SCTL: TRGSEL Position */
#define EADC_SCTL_TRGSEL_Msk (0x1ful << EADC_SCTL_TRGSEL_Pos) /*!< EADC_T::SCTL: TRGSEL Mask */
#define EADC_SCTL_INTPOS_Pos (22) /*!< EADC_T::SCTL: INTPOS Position */
#define EADC_SCTL_INTPOS_Msk (0x1ul << EADC_SCTL_INTPOS_Pos) /*!< EADC_T::SCTL: INTPOS Mask */
#define EADC_SCTL_DBMEN_Pos (23) /*!< EADC_T::SCTL: DBMEN Position */
#define EADC_SCTL_DBMEN_Msk (0x1ul << EADC_SCTL_DBMEN_Pos) /*!< EADC_T::SCTL: DBMEN Mask */
#define EADC_SCTL_EXTSMPT_Pos (24) /*!< EADC_T::SCTL: EXTSMPT Position */
#define EADC_SCTL_EXTSMPT_Msk (0xfful << EADC_SCTL_EXTSMPT_Pos) /*!< EADC_T::SCTL: EXTSMPT Mask */
#define EADC_SCTL0_CHSEL_Pos (0) /*!< EADC_T::SCTL0: CHSEL Position */
#define EADC_SCTL0_CHSEL_Msk (0xful << EADC_SCTL0_CHSEL_Pos) /*!< EADC_T::SCTL0: CHSEL Mask */
#define EADC_SCTL0_EXTREN_Pos (4) /*!< EADC_T::SCTL0: EXTREN Position */
#define EADC_SCTL0_EXTREN_Msk (0x1ul << EADC_SCTL0_EXTREN_Pos) /*!< EADC_T::SCTL0: EXTREN Mask */
#define EADC_SCTL0_EXTFEN_Pos (5) /*!< EADC_T::SCTL0: EXTFEN Position */
#define EADC_SCTL0_EXTFEN_Msk (0x1ul << EADC_SCTL0_EXTFEN_Pos) /*!< EADC_T::SCTL0: EXTFEN Mask */
#define EADC_SCTL0_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL0: TRGDLYDIV Position */
#define EADC_SCTL0_TRGDLYDIV_Msk (0x3ul << EADC_SCTL0_TRGDLYDIV_Pos) /*!< EADC_T::SCTL0: TRGDLYDIV Mask */
#define EADC_SCTL0_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL0: TRGDLYCNT Position */
#define EADC_SCTL0_TRGDLYCNT_Msk (0xfful << EADC_SCTL0_TRGDLYCNT_Pos) /*!< EADC_T::SCTL0: TRGDLYCNT Mask */
#define EADC_SCTL0_TRGSEL_Pos (16) /*!< EADC_T::SCTL0: TRGSEL Position */
#define EADC_SCTL0_TRGSEL_Msk (0x1ful << EADC_SCTL0_TRGSEL_Pos) /*!< EADC_T::SCTL0: TRGSEL Mask */
#define EADC_SCTL0_INTPOS_Pos (22) /*!< EADC_T::SCTL0: INTPOS Position */
#define EADC_SCTL0_INTPOS_Msk (0x1ul << EADC_SCTL0_INTPOS_Pos) /*!< EADC_T::SCTL0: INTPOS Mask */
#define EADC_SCTL0_DBMEN_Pos (23) /*!< EADC_T::SCTL0: DBMEN Position */
#define EADC_SCTL0_DBMEN_Msk (0x1ul << EADC_SCTL0_DBMEN_Pos) /*!< EADC_T::SCTL0: DBMEN Mask */
#define EADC_SCTL0_EXTSMPT_Pos (24) /*!< EADC_T::SCTL0: EXTSMPT Position */
#define EADC_SCTL0_EXTSMPT_Msk (0xfful << EADC_SCTL0_EXTSMPT_Pos) /*!< EADC_T::SCTL0: EXTSMPT Mask */
#define EADC_SCTL1_CHSEL_Pos (0) /*!< EADC_T::SCTL1: CHSEL Position */
#define EADC_SCTL1_CHSEL_Msk (0xful << EADC_SCTL1_CHSEL_Pos) /*!< EADC_T::SCTL1: CHSEL Mask */
#define EADC_SCTL1_EXTREN_Pos (4) /*!< EADC_T::SCTL1: EXTREN Position */
#define EADC_SCTL1_EXTREN_Msk (0x1ul << EADC_SCTL1_EXTREN_Pos) /*!< EADC_T::SCTL1: EXTREN Mask */
#define EADC_SCTL1_EXTFEN_Pos (5) /*!< EADC_T::SCTL1: EXTFEN Position */
#define EADC_SCTL1_EXTFEN_Msk (0x1ul << EADC_SCTL1_EXTFEN_Pos) /*!< EADC_T::SCTL1: EXTFEN Mask */
#define EADC_SCTL1_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL1: TRGDLYDIV Position */
#define EADC_SCTL1_TRGDLYDIV_Msk (0x3ul << EADC_SCTL1_TRGDLYDIV_Pos) /*!< EADC_T::SCTL1: TRGDLYDIV Mask */
#define EADC_SCTL1_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL1: TRGDLYCNT Position */
#define EADC_SCTL1_TRGDLYCNT_Msk (0xfful << EADC_SCTL1_TRGDLYCNT_Pos) /*!< EADC_T::SCTL1: TRGDLYCNT Mask */
#define EADC_SCTL1_TRGSEL_Pos (16) /*!< EADC_T::SCTL1: TRGSEL Position */
#define EADC_SCTL1_TRGSEL_Msk (0x1ful << EADC_SCTL1_TRGSEL_Pos) /*!< EADC_T::SCTL1: TRGSEL Mask */
#define EADC_SCTL1_INTPOS_Pos (22) /*!< EADC_T::SCTL1: INTPOS Position */
#define EADC_SCTL1_INTPOS_Msk (0x1ul << EADC_SCTL1_INTPOS_Pos) /*!< EADC_T::SCTL1: INTPOS Mask */
#define EADC_SCTL1_DBMEN_Pos (23) /*!< EADC_T::SCTL1: DBMEN Position */
#define EADC_SCTL1_DBMEN_Msk (0x1ul << EADC_SCTL1_DBMEN_Pos) /*!< EADC_T::SCTL1: DBMEN Mask */
#define EADC_SCTL1_EXTSMPT_Pos (24) /*!< EADC_T::SCTL1: EXTSMPT Position */
#define EADC_SCTL1_EXTSMPT_Msk (0xfful << EADC_SCTL1_EXTSMPT_Pos) /*!< EADC_T::SCTL1: EXTSMPT Mask */
#define EADC_SCTL2_CHSEL_Pos (0) /*!< EADC_T::SCTL2: CHSEL Position */
#define EADC_SCTL2_CHSEL_Msk (0xful << EADC_SCTL2_CHSEL_Pos) /*!< EADC_T::SCTL2: CHSEL Mask */
#define EADC_SCTL2_EXTREN_Pos (4) /*!< EADC_T::SCTL2: EXTREN Position */
#define EADC_SCTL2_EXTREN_Msk (0x1ul << EADC_SCTL2_EXTREN_Pos) /*!< EADC_T::SCTL2: EXTREN Mask */
#define EADC_SCTL2_EXTFEN_Pos (5) /*!< EADC_T::SCTL2: EXTFEN Position */
#define EADC_SCTL2_EXTFEN_Msk (0x1ul << EADC_SCTL2_EXTFEN_Pos) /*!< EADC_T::SCTL2: EXTFEN Mask */
#define EADC_SCTL2_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL2: TRGDLYDIV Position */
#define EADC_SCTL2_TRGDLYDIV_Msk (0x3ul << EADC_SCTL2_TRGDLYDIV_Pos) /*!< EADC_T::SCTL2: TRGDLYDIV Mask */
#define EADC_SCTL2_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL2: TRGDLYCNT Position */
#define EADC_SCTL2_TRGDLYCNT_Msk (0xfful << EADC_SCTL2_TRGDLYCNT_Pos) /*!< EADC_T::SCTL2: TRGDLYCNT Mask */
#define EADC_SCTL2_TRGSEL_Pos (16) /*!< EADC_T::SCTL2: TRGSEL Position */
#define EADC_SCTL2_TRGSEL_Msk (0x1ful << EADC_SCTL2_TRGSEL_Pos) /*!< EADC_T::SCTL2: TRGSEL Mask */
#define EADC_SCTL2_INTPOS_Pos (22) /*!< EADC_T::SCTL2: INTPOS Position */
#define EADC_SCTL2_INTPOS_Msk (0x1ul << EADC_SCTL2_INTPOS_Pos) /*!< EADC_T::SCTL2: INTPOS Mask */
#define EADC_SCTL2_DBMEN_Pos (23) /*!< EADC_T::SCTL2: DBMEN Position */
#define EADC_SCTL2_DBMEN_Msk (0x1ul << EADC_SCTL2_DBMEN_Pos) /*!< EADC_T::SCTL2: DBMEN Mask */
#define EADC_SCTL2_EXTSMPT_Pos (24) /*!< EADC_T::SCTL2: EXTSMPT Position */
#define EADC_SCTL2_EXTSMPT_Msk (0xfful << EADC_SCTL2_EXTSMPT_Pos) /*!< EADC_T::SCTL2: EXTSMPT Mask */
#define EADC_SCTL3_CHSEL_Pos (0) /*!< EADC_T::SCTL3: CHSEL Position */
#define EADC_SCTL3_CHSEL_Msk (0xful << EADC_SCTL3_CHSEL_Pos) /*!< EADC_T::SCTL3: CHSEL Mask */
#define EADC_SCTL3_EXTREN_Pos (4) /*!< EADC_T::SCTL3: EXTREN Position */
#define EADC_SCTL3_EXTREN_Msk (0x1ul << EADC_SCTL3_EXTREN_Pos) /*!< EADC_T::SCTL3: EXTREN Mask */
#define EADC_SCTL3_EXTFEN_Pos (5) /*!< EADC_T::SCTL3: EXTFEN Position */
#define EADC_SCTL3_EXTFEN_Msk (0x1ul << EADC_SCTL3_EXTFEN_Pos) /*!< EADC_T::SCTL3: EXTFEN Mask */
#define EADC_SCTL3_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL3: TRGDLYDIV Position */
#define EADC_SCTL3_TRGDLYDIV_Msk (0x3ul << EADC_SCTL3_TRGDLYDIV_Pos) /*!< EADC_T::SCTL3: TRGDLYDIV Mask */
#define EADC_SCTL3_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL3: TRGDLYCNT Position */
#define EADC_SCTL3_TRGDLYCNT_Msk (0xfful << EADC_SCTL3_TRGDLYCNT_Pos) /*!< EADC_T::SCTL3: TRGDLYCNT Mask */
#define EADC_SCTL3_TRGSEL_Pos (16) /*!< EADC_T::SCTL3: TRGSEL Position */
#define EADC_SCTL3_TRGSEL_Msk (0x1ful << EADC_SCTL3_TRGSEL_Pos) /*!< EADC_T::SCTL3: TRGSEL Mask */
#define EADC_SCTL3_INTPOS_Pos (22) /*!< EADC_T::SCTL3: INTPOS Position */
#define EADC_SCTL3_INTPOS_Msk (0x1ul << EADC_SCTL3_INTPOS_Pos) /*!< EADC_T::SCTL3: INTPOS Mask */
#define EADC_SCTL3_DBMEN_Pos (23) /*!< EADC_T::SCTL3: DBMEN Position */
#define EADC_SCTL3_DBMEN_Msk (0x1ul << EADC_SCTL3_DBMEN_Pos) /*!< EADC_T::SCTL3: DBMEN Mask */
#define EADC_SCTL3_EXTSMPT_Pos (24) /*!< EADC_T::SCTL3: EXTSMPT Position */
#define EADC_SCTL3_EXTSMPT_Msk (0xfful << EADC_SCTL3_EXTSMPT_Pos) /*!< EADC_T::SCTL3: EXTSMPT Mask */
#define EADC_SCTL4_CHSEL_Pos (0) /*!< EADC_T::SCTL4: CHSEL Position */
#define EADC_SCTL4_CHSEL_Msk (0xful << EADC_SCTL4_CHSEL_Pos) /*!< EADC_T::SCTL4: CHSEL Mask */
#define EADC_SCTL4_EXTREN_Pos (4) /*!< EADC_T::SCTL4: EXTREN Position */
#define EADC_SCTL4_EXTREN_Msk (0x1ul << EADC_SCTL4_EXTREN_Pos) /*!< EADC_T::SCTL4: EXTREN Mask */
#define EADC_SCTL4_EXTFEN_Pos (5) /*!< EADC_T::SCTL4: EXTFEN Position */
#define EADC_SCTL4_EXTFEN_Msk (0x1ul << EADC_SCTL4_EXTFEN_Pos) /*!< EADC_T::SCTL4: EXTFEN Mask */
#define EADC_SCTL4_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL4: TRGDLYDIV Position */
#define EADC_SCTL4_TRGDLYDIV_Msk (0x3ul << EADC_SCTL4_TRGDLYDIV_Pos) /*!< EADC_T::SCTL4: TRGDLYDIV Mask */
#define EADC_SCTL4_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL4: TRGDLYCNT Position */
#define EADC_SCTL4_TRGDLYCNT_Msk (0xfful << EADC_SCTL4_TRGDLYCNT_Pos) /*!< EADC_T::SCTL4: TRGDLYCNT Mask */
#define EADC_SCTL4_TRGSEL_Pos (16) /*!< EADC_T::SCTL4: TRGSEL Position */
#define EADC_SCTL4_TRGSEL_Msk (0x1ful << EADC_SCTL4_TRGSEL_Pos) /*!< EADC_T::SCTL4: TRGSEL Mask */
#define EADC_SCTL4_INTPOS_Pos (22) /*!< EADC_T::SCTL4: INTPOS Position */
#define EADC_SCTL4_INTPOS_Msk (0x1ul << EADC_SCTL4_INTPOS_Pos) /*!< EADC_T::SCTL4: INTPOS Mask */
#define EADC_SCTL4_EXTSMPT_Pos (24) /*!< EADC_T::SCTL4: EXTSMPT Position */
#define EADC_SCTL4_EXTSMPT_Msk (0xfful << EADC_SCTL4_EXTSMPT_Pos) /*!< EADC_T::SCTL4: EXTSMPT Mask */
#define EADC_SCTL5_CHSEL_Pos (0) /*!< EADC_T::SCTL5: CHSEL Position */
#define EADC_SCTL5_CHSEL_Msk (0xful << EADC_SCTL5_CHSEL_Pos) /*!< EADC_T::SCTL5: CHSEL Mask */
#define EADC_SCTL5_EXTREN_Pos (4) /*!< EADC_T::SCTL5: EXTREN Position */
#define EADC_SCTL5_EXTREN_Msk (0x1ul << EADC_SCTL5_EXTREN_Pos) /*!< EADC_T::SCTL5: EXTREN Mask */
#define EADC_SCTL5_EXTFEN_Pos (5) /*!< EADC_T::SCTL5: EXTFEN Position */
#define EADC_SCTL5_EXTFEN_Msk (0x1ul << EADC_SCTL5_EXTFEN_Pos) /*!< EADC_T::SCTL5: EXTFEN Mask */
#define EADC_SCTL5_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL5: TRGDLYDIV Position */
#define EADC_SCTL5_TRGDLYDIV_Msk (0x3ul << EADC_SCTL5_TRGDLYDIV_Pos) /*!< EADC_T::SCTL5: TRGDLYDIV Mask */
#define EADC_SCTL5_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL5: TRGDLYCNT Position */
#define EADC_SCTL5_TRGDLYCNT_Msk (0xfful << EADC_SCTL5_TRGDLYCNT_Pos) /*!< EADC_T::SCTL5: TRGDLYCNT Mask */
#define EADC_SCTL5_TRGSEL_Pos (16) /*!< EADC_T::SCTL5: TRGSEL Position */
#define EADC_SCTL5_TRGSEL_Msk (0x1ful << EADC_SCTL5_TRGSEL_Pos) /*!< EADC_T::SCTL5: TRGSEL Mask */
#define EADC_SCTL5_INTPOS_Pos (22) /*!< EADC_T::SCTL5: INTPOS Position */
#define EADC_SCTL5_INTPOS_Msk (0x1ul << EADC_SCTL5_INTPOS_Pos) /*!< EADC_T::SCTL5: INTPOS Mask */
#define EADC_SCTL5_EXTSMPT_Pos (24) /*!< EADC_T::SCTL5: EXTSMPT Position */
#define EADC_SCTL5_EXTSMPT_Msk (0xfful << EADC_SCTL5_EXTSMPT_Pos) /*!< EADC_T::SCTL5: EXTSMPT Mask */
#define EADC_SCTL6_CHSEL_Pos (0) /*!< EADC_T::SCTL6: CHSEL Position */
#define EADC_SCTL6_CHSEL_Msk (0xful << EADC_SCTL6_CHSEL_Pos) /*!< EADC_T::SCTL6: CHSEL Mask */
#define EADC_SCTL6_EXTREN_Pos (4) /*!< EADC_T::SCTL6: EXTREN Position */
#define EADC_SCTL6_EXTREN_Msk (0x1ul << EADC_SCTL6_EXTREN_Pos) /*!< EADC_T::SCTL6: EXTREN Mask */
#define EADC_SCTL6_EXTFEN_Pos (5) /*!< EADC_T::SCTL6: EXTFEN Position */
#define EADC_SCTL6_EXTFEN_Msk (0x1ul << EADC_SCTL6_EXTFEN_Pos) /*!< EADC_T::SCTL6: EXTFEN Mask */
#define EADC_SCTL6_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL6: TRGDLYDIV Position */
#define EADC_SCTL6_TRGDLYDIV_Msk (0x3ul << EADC_SCTL6_TRGDLYDIV_Pos) /*!< EADC_T::SCTL6: TRGDLYDIV Mask */
#define EADC_SCTL6_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL6: TRGDLYCNT Position */
#define EADC_SCTL6_TRGDLYCNT_Msk (0xfful << EADC_SCTL6_TRGDLYCNT_Pos) /*!< EADC_T::SCTL6: TRGDLYCNT Mask */
#define EADC_SCTL6_TRGSEL_Pos (16) /*!< EADC_T::SCTL6: TRGSEL Position */
#define EADC_SCTL6_TRGSEL_Msk (0x1ful << EADC_SCTL6_TRGSEL_Pos) /*!< EADC_T::SCTL6: TRGSEL Mask */
#define EADC_SCTL6_INTPOS_Pos (22) /*!< EADC_T::SCTL6: INTPOS Position */
#define EADC_SCTL6_INTPOS_Msk (0x1ul << EADC_SCTL6_INTPOS_Pos) /*!< EADC_T::SCTL6: INTPOS Mask */
#define EADC_SCTL6_EXTSMPT_Pos (24) /*!< EADC_T::SCTL6: EXTSMPT Position */
#define EADC_SCTL6_EXTSMPT_Msk (0xfful << EADC_SCTL6_EXTSMPT_Pos) /*!< EADC_T::SCTL6: EXTSMPT Mask */
#define EADC_SCTL7_CHSEL_Pos (0) /*!< EADC_T::SCTL7: CHSEL Position */
#define EADC_SCTL7_CHSEL_Msk (0xful << EADC_SCTL7_CHSEL_Pos) /*!< EADC_T::SCTL7: CHSEL Mask */
#define EADC_SCTL7_EXTREN_Pos (4) /*!< EADC_T::SCTL7: EXTREN Position */
#define EADC_SCTL7_EXTREN_Msk (0x1ul << EADC_SCTL7_EXTREN_Pos) /*!< EADC_T::SCTL7: EXTREN Mask */
#define EADC_SCTL7_EXTFEN_Pos (5) /*!< EADC_T::SCTL7: EXTFEN Position */
#define EADC_SCTL7_EXTFEN_Msk (0x1ul << EADC_SCTL7_EXTFEN_Pos) /*!< EADC_T::SCTL7: EXTFEN Mask */
#define EADC_SCTL7_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL7: TRGDLYDIV Position */
#define EADC_SCTL7_TRGDLYDIV_Msk (0x3ul << EADC_SCTL7_TRGDLYDIV_Pos) /*!< EADC_T::SCTL7: TRGDLYDIV Mask */
#define EADC_SCTL7_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL7: TRGDLYCNT Position */
#define EADC_SCTL7_TRGDLYCNT_Msk (0xfful << EADC_SCTL7_TRGDLYCNT_Pos) /*!< EADC_T::SCTL7: TRGDLYCNT Mask */
#define EADC_SCTL7_TRGSEL_Pos (16) /*!< EADC_T::SCTL7: TRGSEL Position */
#define EADC_SCTL7_TRGSEL_Msk (0x1ful << EADC_SCTL7_TRGSEL_Pos) /*!< EADC_T::SCTL7: TRGSEL Mask */
#define EADC_SCTL7_INTPOS_Pos (22) /*!< EADC_T::SCTL7: INTPOS Position */
#define EADC_SCTL7_INTPOS_Msk (0x1ul << EADC_SCTL7_INTPOS_Pos) /*!< EADC_T::SCTL7: INTPOS Mask */
#define EADC_SCTL7_EXTSMPT_Pos (24) /*!< EADC_T::SCTL7: EXTSMPT Position */
#define EADC_SCTL7_EXTSMPT_Msk (0xfful << EADC_SCTL7_EXTSMPT_Pos) /*!< EADC_T::SCTL7: EXTSMPT Mask */
#define EADC_SCTL8_CHSEL_Pos (0) /*!< EADC_T::SCTL8: CHSEL Position */
#define EADC_SCTL8_CHSEL_Msk (0xful << EADC_SCTL8_CHSEL_Pos) /*!< EADC_T::SCTL8: CHSEL Mask */
#define EADC_SCTL8_EXTREN_Pos (4) /*!< EADC_T::SCTL8: EXTREN Position */
#define EADC_SCTL8_EXTREN_Msk (0x1ul << EADC_SCTL8_EXTREN_Pos) /*!< EADC_T::SCTL8: EXTREN Mask */
#define EADC_SCTL8_EXTFEN_Pos (5) /*!< EADC_T::SCTL8: EXTFEN Position */
#define EADC_SCTL8_EXTFEN_Msk (0x1ul << EADC_SCTL8_EXTFEN_Pos) /*!< EADC_T::SCTL8: EXTFEN Mask */
#define EADC_SCTL8_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL8: TRGDLYDIV Position */
#define EADC_SCTL8_TRGDLYDIV_Msk (0x3ul << EADC_SCTL8_TRGDLYDIV_Pos) /*!< EADC_T::SCTL8: TRGDLYDIV Mask */
#define EADC_SCTL8_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL8: TRGDLYCNT Position */
#define EADC_SCTL8_TRGDLYCNT_Msk (0xfful << EADC_SCTL8_TRGDLYCNT_Pos) /*!< EADC_T::SCTL8: TRGDLYCNT Mask */
#define EADC_SCTL8_TRGSEL_Pos (16) /*!< EADC_T::SCTL8: TRGSEL Position */
#define EADC_SCTL8_TRGSEL_Msk (0x1ful << EADC_SCTL8_TRGSEL_Pos) /*!< EADC_T::SCTL8: TRGSEL Mask */
#define EADC_SCTL8_INTPOS_Pos (22) /*!< EADC_T::SCTL8: INTPOS Position */
#define EADC_SCTL8_INTPOS_Msk (0x1ul << EADC_SCTL8_INTPOS_Pos) /*!< EADC_T::SCTL8: INTPOS Mask */
#define EADC_SCTL8_EXTSMPT_Pos (24) /*!< EADC_T::SCTL8: EXTSMPT Position */
#define EADC_SCTL8_EXTSMPT_Msk (0xfful << EADC_SCTL8_EXTSMPT_Pos) /*!< EADC_T::SCTL8: EXTSMPT Mask */
#define EADC_SCTL9_CHSEL_Pos (0) /*!< EADC_T::SCTL9: CHSEL Position */
#define EADC_SCTL9_CHSEL_Msk (0xful << EADC_SCTL9_CHSEL_Pos) /*!< EADC_T::SCTL9: CHSEL Mask */
#define EADC_SCTL9_EXTREN_Pos (4) /*!< EADC_T::SCTL9: EXTREN Position */
#define EADC_SCTL9_EXTREN_Msk (0x1ul << EADC_SCTL9_EXTREN_Pos) /*!< EADC_T::SCTL9: EXTREN Mask */
#define EADC_SCTL9_EXTFEN_Pos (5) /*!< EADC_T::SCTL9: EXTFEN Position */
#define EADC_SCTL9_EXTFEN_Msk (0x1ul << EADC_SCTL9_EXTFEN_Pos) /*!< EADC_T::SCTL9: EXTFEN Mask */
#define EADC_SCTL9_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL9: TRGDLYDIV Position */
#define EADC_SCTL9_TRGDLYDIV_Msk (0x3ul << EADC_SCTL9_TRGDLYDIV_Pos) /*!< EADC_T::SCTL9: TRGDLYDIV Mask */
#define EADC_SCTL9_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL9: TRGDLYCNT Position */
#define EADC_SCTL9_TRGDLYCNT_Msk (0xfful << EADC_SCTL9_TRGDLYCNT_Pos) /*!< EADC_T::SCTL9: TRGDLYCNT Mask */
#define EADC_SCTL9_TRGSEL_Pos (16) /*!< EADC_T::SCTL9: TRGSEL Position */
#define EADC_SCTL9_TRGSEL_Msk (0x1ful << EADC_SCTL9_TRGSEL_Pos) /*!< EADC_T::SCTL9: TRGSEL Mask */
#define EADC_SCTL9_INTPOS_Pos (22) /*!< EADC_T::SCTL9: INTPOS Position */
#define EADC_SCTL9_INTPOS_Msk (0x1ul << EADC_SCTL9_INTPOS_Pos) /*!< EADC_T::SCTL9: INTPOS Mask */
#define EADC_SCTL9_EXTSMPT_Pos (24) /*!< EADC_T::SCTL9: EXTSMPT Position */
#define EADC_SCTL9_EXTSMPT_Msk (0xfful << EADC_SCTL9_EXTSMPT_Pos) /*!< EADC_T::SCTL9: EXTSMPT Mask */
#define EADC_SCTL10_CHSEL_Pos (0) /*!< EADC_T::SCTL10: CHSEL Position */
#define EADC_SCTL10_CHSEL_Msk (0xful << EADC_SCTL10_CHSEL_Pos) /*!< EADC_T::SCTL10: CHSEL Mask */
#define EADC_SCTL10_EXTREN_Pos (4) /*!< EADC_T::SCTL10: EXTREN Position */
#define EADC_SCTL10_EXTREN_Msk (0x1ul << EADC_SCTL10_EXTREN_Pos) /*!< EADC_T::SCTL10: EXTREN Mask */
#define EADC_SCTL10_EXTFEN_Pos (5) /*!< EADC_T::SCTL10: EXTFEN Position */
#define EADC_SCTL10_EXTFEN_Msk (0x1ul << EADC_SCTL10_EXTFEN_Pos) /*!< EADC_T::SCTL10: EXTFEN Mask */
#define EADC_SCTL10_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL10: TRGDLYDIV Position */
#define EADC_SCTL10_TRGDLYDIV_Msk (0x3ul << EADC_SCTL10_TRGDLYDIV_Pos) /*!< EADC_T::SCTL10: TRGDLYDIV Mask */
#define EADC_SCTL10_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL10: TRGDLYCNT Position */
#define EADC_SCTL10_TRGDLYCNT_Msk (0xfful << EADC_SCTL10_TRGDLYCNT_Pos) /*!< EADC_T::SCTL10: TRGDLYCNT Mask */
#define EADC_SCTL10_TRGSEL_Pos (16) /*!< EADC_T::SCTL10: TRGSEL Position */
#define EADC_SCTL10_TRGSEL_Msk (0x1ful << EADC_SCTL10_TRGSEL_Pos) /*!< EADC_T::SCTL10: TRGSEL Mask */
#define EADC_SCTL10_INTPOS_Pos (22) /*!< EADC_T::SCTL10: INTPOS Position */
#define EADC_SCTL10_INTPOS_Msk (0x1ul << EADC_SCTL10_INTPOS_Pos) /*!< EADC_T::SCTL10: INTPOS Mask */
#define EADC_SCTL10_EXTSMPT_Pos (24) /*!< EADC_T::SCTL10: EXTSMPT Position */
#define EADC_SCTL10_EXTSMPT_Msk (0xfful << EADC_SCTL10_EXTSMPT_Pos) /*!< EADC_T::SCTL10: EXTSMPT Mask */
#define EADC_SCTL11_CHSEL_Pos (0) /*!< EADC_T::SCTL11: CHSEL Position */
#define EADC_SCTL11_CHSEL_Msk (0xful << EADC_SCTL11_CHSEL_Pos) /*!< EADC_T::SCTL11: CHSEL Mask */
#define EADC_SCTL11_EXTREN_Pos (4) /*!< EADC_T::SCTL11: EXTREN Position */
#define EADC_SCTL11_EXTREN_Msk (0x1ul << EADC_SCTL11_EXTREN_Pos) /*!< EADC_T::SCTL11: EXTREN Mask */
#define EADC_SCTL11_EXTFEN_Pos (5) /*!< EADC_T::SCTL11: EXTFEN Position */
#define EADC_SCTL11_EXTFEN_Msk (0x1ul << EADC_SCTL11_EXTFEN_Pos) /*!< EADC_T::SCTL11: EXTFEN Mask */
#define EADC_SCTL11_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL11: TRGDLYDIV Position */
#define EADC_SCTL11_TRGDLYDIV_Msk (0x3ul << EADC_SCTL11_TRGDLYDIV_Pos) /*!< EADC_T::SCTL11: TRGDLYDIV Mask */
#define EADC_SCTL11_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL11: TRGDLYCNT Position */
#define EADC_SCTL11_TRGDLYCNT_Msk (0xfful << EADC_SCTL11_TRGDLYCNT_Pos) /*!< EADC_T::SCTL11: TRGDLYCNT Mask */
#define EADC_SCTL11_TRGSEL_Pos (16) /*!< EADC_T::SCTL11: TRGSEL Position */
#define EADC_SCTL11_TRGSEL_Msk (0x1ful << EADC_SCTL11_TRGSEL_Pos) /*!< EADC_T::SCTL11: TRGSEL Mask */
#define EADC_SCTL11_INTPOS_Pos (22) /*!< EADC_T::SCTL11: INTPOS Position */
#define EADC_SCTL11_INTPOS_Msk (0x1ul << EADC_SCTL11_INTPOS_Pos) /*!< EADC_T::SCTL11: INTPOS Mask */
#define EADC_SCTL11_EXTSMPT_Pos (24) /*!< EADC_T::SCTL11: EXTSMPT Position */
#define EADC_SCTL11_EXTSMPT_Msk (0xfful << EADC_SCTL11_EXTSMPT_Pos) /*!< EADC_T::SCTL11: EXTSMPT Mask */
#define EADC_SCTL12_CHSEL_Pos (0) /*!< EADC_T::SCTL12: CHSEL Position */
#define EADC_SCTL12_CHSEL_Msk (0xful << EADC_SCTL12_CHSEL_Pos) /*!< EADC_T::SCTL12: CHSEL Mask */
#define EADC_SCTL12_EXTREN_Pos (4) /*!< EADC_T::SCTL12: EXTREN Position */
#define EADC_SCTL12_EXTREN_Msk (0x1ul << EADC_SCTL12_EXTREN_Pos) /*!< EADC_T::SCTL12: EXTREN Mask */
#define EADC_SCTL12_EXTFEN_Pos (5) /*!< EADC_T::SCTL12: EXTFEN Position */
#define EADC_SCTL12_EXTFEN_Msk (0x1ul << EADC_SCTL12_EXTFEN_Pos) /*!< EADC_T::SCTL12: EXTFEN Mask */
#define EADC_SCTL12_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL12: TRGDLYDIV Position */
#define EADC_SCTL12_TRGDLYDIV_Msk (0x3ul << EADC_SCTL12_TRGDLYDIV_Pos) /*!< EADC_T::SCTL12: TRGDLYDIV Mask */
#define EADC_SCTL12_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL12: TRGDLYCNT Position */
#define EADC_SCTL12_TRGDLYCNT_Msk (0xfful << EADC_SCTL12_TRGDLYCNT_Pos) /*!< EADC_T::SCTL12: TRGDLYCNT Mask */
#define EADC_SCTL12_TRGSEL_Pos (16) /*!< EADC_T::SCTL12: TRGSEL Position */
#define EADC_SCTL12_TRGSEL_Msk (0x1ful << EADC_SCTL12_TRGSEL_Pos) /*!< EADC_T::SCTL12: TRGSEL Mask */
#define EADC_SCTL12_INTPOS_Pos (22) /*!< EADC_T::SCTL12: INTPOS Position */
#define EADC_SCTL12_INTPOS_Msk (0x1ul << EADC_SCTL12_INTPOS_Pos) /*!< EADC_T::SCTL12: INTPOS Mask */
#define EADC_SCTL12_EXTSMPT_Pos (24) /*!< EADC_T::SCTL12: EXTSMPT Position */
#define EADC_SCTL12_EXTSMPT_Msk (0xfful << EADC_SCTL12_EXTSMPT_Pos) /*!< EADC_T::SCTL12: EXTSMPT Mask */
#define EADC_SCTL13_CHSEL_Pos (0) /*!< EADC_T::SCTL13: CHSEL Position */
#define EADC_SCTL13_CHSEL_Msk (0xful << EADC_SCTL13_CHSEL_Pos) /*!< EADC_T::SCTL13: CHSEL Mask */
#define EADC_SCTL13_EXTREN_Pos (4) /*!< EADC_T::SCTL13: EXTREN Position */
#define EADC_SCTL13_EXTREN_Msk (0x1ul << EADC_SCTL13_EXTREN_Pos) /*!< EADC_T::SCTL13: EXTREN Mask */
#define EADC_SCTL13_EXTFEN_Pos (5) /*!< EADC_T::SCTL13: EXTFEN Position */
#define EADC_SCTL13_EXTFEN_Msk (0x1ul << EADC_SCTL13_EXTFEN_Pos) /*!< EADC_T::SCTL13: EXTFEN Mask */
#define EADC_SCTL13_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL13: TRGDLYDIV Position */
#define EADC_SCTL13_TRGDLYDIV_Msk (0x3ul << EADC_SCTL13_TRGDLYDIV_Pos) /*!< EADC_T::SCTL13: TRGDLYDIV Mask */
#define EADC_SCTL13_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL13: TRGDLYCNT Position */
#define EADC_SCTL13_TRGDLYCNT_Msk (0xfful << EADC_SCTL13_TRGDLYCNT_Pos) /*!< EADC_T::SCTL13: TRGDLYCNT Mask */
#define EADC_SCTL13_TRGSEL_Pos (16) /*!< EADC_T::SCTL13: TRGSEL Position */
#define EADC_SCTL13_TRGSEL_Msk (0x1ful << EADC_SCTL13_TRGSEL_Pos) /*!< EADC_T::SCTL13: TRGSEL Mask */
#define EADC_SCTL13_INTPOS_Pos (22) /*!< EADC_T::SCTL13: INTPOS Position */
#define EADC_SCTL13_INTPOS_Msk (0x1ul << EADC_SCTL13_INTPOS_Pos) /*!< EADC_T::SCTL13: INTPOS Mask */
#define EADC_SCTL13_EXTSMPT_Pos (24) /*!< EADC_T::SCTL13: EXTSMPT Position */
#define EADC_SCTL13_EXTSMPT_Msk (0xfful << EADC_SCTL13_EXTSMPT_Pos) /*!< EADC_T::SCTL13: EXTSMPT Mask */
#define EADC_SCTL14_CHSEL_Pos (0) /*!< EADC_T::SCTL14: CHSEL Position */
#define EADC_SCTL14_CHSEL_Msk (0xful << EADC_SCTL14_CHSEL_Pos) /*!< EADC_T::SCTL14: CHSEL Mask */
#define EADC_SCTL14_EXTREN_Pos (4) /*!< EADC_T::SCTL14: EXTREN Position */
#define EADC_SCTL14_EXTREN_Msk (0x1ul << EADC_SCTL14_EXTREN_Pos) /*!< EADC_T::SCTL14: EXTREN Mask */
#define EADC_SCTL14_EXTFEN_Pos (5) /*!< EADC_T::SCTL14: EXTFEN Position */
#define EADC_SCTL14_EXTFEN_Msk (0x1ul << EADC_SCTL14_EXTFEN_Pos) /*!< EADC_T::SCTL14: EXTFEN Mask */
#define EADC_SCTL14_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL14: TRGDLYDIV Position */
#define EADC_SCTL14_TRGDLYDIV_Msk (0x3ul << EADC_SCTL14_TRGDLYDIV_Pos) /*!< EADC_T::SCTL14: TRGDLYDIV Mask */
#define EADC_SCTL14_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL14: TRGDLYCNT Position */
#define EADC_SCTL14_TRGDLYCNT_Msk (0xfful << EADC_SCTL14_TRGDLYCNT_Pos) /*!< EADC_T::SCTL14: TRGDLYCNT Mask */
#define EADC_SCTL14_TRGSEL_Pos (16) /*!< EADC_T::SCTL14: TRGSEL Position */
#define EADC_SCTL14_TRGSEL_Msk (0x1ful << EADC_SCTL14_TRGSEL_Pos) /*!< EADC_T::SCTL14: TRGSEL Mask */
#define EADC_SCTL14_INTPOS_Pos (22) /*!< EADC_T::SCTL14: INTPOS Position */
#define EADC_SCTL14_INTPOS_Msk (0x1ul << EADC_SCTL14_INTPOS_Pos) /*!< EADC_T::SCTL14: INTPOS Mask */
#define EADC_SCTL14_EXTSMPT_Pos (24) /*!< EADC_T::SCTL14: EXTSMPT Position */
#define EADC_SCTL14_EXTSMPT_Msk (0xfful << EADC_SCTL14_EXTSMPT_Pos) /*!< EADC_T::SCTL14: EXTSMPT Mask */
#define EADC_SCTL15_CHSEL_Pos (0) /*!< EADC_T::SCTL15: CHSEL Position */
#define EADC_SCTL15_CHSEL_Msk (0xful << EADC_SCTL15_CHSEL_Pos) /*!< EADC_T::SCTL15: CHSEL Mask */
#define EADC_SCTL15_EXTREN_Pos (4) /*!< EADC_T::SCTL15: EXTREN Position */
#define EADC_SCTL15_EXTREN_Msk (0x1ul << EADC_SCTL15_EXTREN_Pos) /*!< EADC_T::SCTL15: EXTREN Mask */
#define EADC_SCTL15_EXTFEN_Pos (5) /*!< EADC_T::SCTL15: EXTFEN Position */
#define EADC_SCTL15_EXTFEN_Msk (0x1ul << EADC_SCTL15_EXTFEN_Pos) /*!< EADC_T::SCTL15: EXTFEN Mask */
#define EADC_SCTL15_TRGDLYDIV_Pos (6) /*!< EADC_T::SCTL15: TRGDLYDIV Position */
#define EADC_SCTL15_TRGDLYDIV_Msk (0x3ul << EADC_SCTL15_TRGDLYDIV_Pos) /*!< EADC_T::SCTL15: TRGDLYDIV Mask */
#define EADC_SCTL15_TRGDLYCNT_Pos (8) /*!< EADC_T::SCTL15: TRGDLYCNT Position */
#define EADC_SCTL15_TRGDLYCNT_Msk (0xfful << EADC_SCTL15_TRGDLYCNT_Pos) /*!< EADC_T::SCTL15: TRGDLYCNT Mask */
#define EADC_SCTL15_TRGSEL_Pos (16) /*!< EADC_T::SCTL15: TRGSEL Position */
#define EADC_SCTL15_TRGSEL_Msk (0x1ful << EADC_SCTL15_TRGSEL_Pos) /*!< EADC_T::SCTL15: TRGSEL Mask */
#define EADC_SCTL15_INTPOS_Pos (22) /*!< EADC_T::SCTL15: INTPOS Position */
#define EADC_SCTL15_INTPOS_Msk (0x1ul << EADC_SCTL15_INTPOS_Pos) /*!< EADC_T::SCTL15: INTPOS Mask */
#define EADC_SCTL15_EXTSMPT_Pos (24) /*!< EADC_T::SCTL15: EXTSMPT Position */
#define EADC_SCTL15_EXTSMPT_Msk (0xfful << EADC_SCTL15_EXTSMPT_Pos) /*!< EADC_T::SCTL15: EXTSMPT Mask */
#define EADC_SCTL16_EXTSMPT_Pos (24) /*!< EADC_T::SCTL16: EXTSMPT Position */
#define EADC_SCTL16_EXTSMPT_Msk (0xfful << EADC_SCTL16_EXTSMPT_Pos) /*!< EADC_T::SCTL16: EXTSMPT Mask */
#define EADC_SCTL17_EXTSMPT_Pos (24) /*!< EADC_T::SCTL17: EXTSMPT Position */
#define EADC_SCTL17_EXTSMPT_Msk (0xfful << EADC_SCTL17_EXTSMPT_Pos) /*!< EADC_T::SCTL17: EXTSMPT Mask */
#define EADC_SCTL18_EXTSMPT_Pos (24) /*!< EADC_T::SCTL18: EXTSMPT Position */
#define EADC_SCTL18_EXTSMPT_Msk (0xfful << EADC_SCTL18_EXTSMPT_Pos) /*!< EADC_T::SCTL18: EXTSMPT Mask */
#define EADC_INTSRC0_SPLIE0_Pos (0) /*!< EADC_T::INTSRC0: SPLIE0 Position */
#define EADC_INTSRC0_SPLIE0_Msk (0x1ul << EADC_INTSRC0_SPLIE0_Pos) /*!< EADC_T::INTSRC0: SPLIE0 Mask */
#define EADC_INTSRC0_SPLIE1_Pos (1) /*!< EADC_T::INTSRC0: SPLIE1 Position */
#define EADC_INTSRC0_SPLIE1_Msk (0x1ul << EADC_INTSRC0_SPLIE1_Pos) /*!< EADC_T::INTSRC0: SPLIE1 Mask */
#define EADC_INTSRC0_SPLIE2_Pos (2) /*!< EADC_T::INTSRC0: SPLIE2 Position */
#define EADC_INTSRC0_SPLIE2_Msk (0x1ul << EADC_INTSRC0_SPLIE2_Pos) /*!< EADC_T::INTSRC0: SPLIE2 Mask */
#define EADC_INTSRC0_SPLIE3_Pos (3) /*!< EADC_T::INTSRC0: SPLIE3 Position */
#define EADC_INTSRC0_SPLIE3_Msk (0x1ul << EADC_INTSRC0_SPLIE3_Pos) /*!< EADC_T::INTSRC0: SPLIE3 Mask */
#define EADC_INTSRC0_SPLIE4_Pos (4) /*!< EADC_T::INTSRC0: SPLIE4 Position */
#define EADC_INTSRC0_SPLIE4_Msk (0x1ul << EADC_INTSRC0_SPLIE4_Pos) /*!< EADC_T::INTSRC0: SPLIE4 Mask */
#define EADC_INTSRC0_SPLIE5_Pos (5) /*!< EADC_T::INTSRC0: SPLIE5 Position */
#define EADC_INTSRC0_SPLIE5_Msk (0x1ul << EADC_INTSRC0_SPLIE5_Pos) /*!< EADC_T::INTSRC0: SPLIE5 Mask */
#define EADC_INTSRC0_SPLIE6_Pos (6) /*!< EADC_T::INTSRC0: SPLIE6 Position */
#define EADC_INTSRC0_SPLIE6_Msk (0x1ul << EADC_INTSRC0_SPLIE6_Pos) /*!< EADC_T::INTSRC0: SPLIE6 Mask */
#define EADC_INTSRC0_SPLIE7_Pos (7) /*!< EADC_T::INTSRC0: SPLIE7 Position */
#define EADC_INTSRC0_SPLIE7_Msk (0x1ul << EADC_INTSRC0_SPLIE7_Pos) /*!< EADC_T::INTSRC0: SPLIE7 Mask */
#define EADC_INTSRC0_SPLIE8_Pos (8) /*!< EADC_T::INTSRC0: SPLIE8 Position */
#define EADC_INTSRC0_SPLIE8_Msk (0x1ul << EADC_INTSRC0_SPLIE8_Pos) /*!< EADC_T::INTSRC0: SPLIE8 Mask */
#define EADC_INTSRC0_SPLIE9_Pos (9) /*!< EADC_T::INTSRC0: SPLIE9 Position */
#define EADC_INTSRC0_SPLIE9_Msk (0x1ul << EADC_INTSRC0_SPLIE9_Pos) /*!< EADC_T::INTSRC0: SPLIE9 Mask */
#define EADC_INTSRC0_SPLIE10_Pos (10) /*!< EADC_T::INTSRC0: SPLIE10 Position */
#define EADC_INTSRC0_SPLIE10_Msk (0x1ul << EADC_INTSRC0_SPLIE10_Pos) /*!< EADC_T::INTSRC0: SPLIE10 Mask */
#define EADC_INTSRC0_SPLIE11_Pos (11) /*!< EADC_T::INTSRC0: SPLIE11 Position */
#define EADC_INTSRC0_SPLIE11_Msk (0x1ul << EADC_INTSRC0_SPLIE11_Pos) /*!< EADC_T::INTSRC0: SPLIE11 Mask */
#define EADC_INTSRC0_SPLIE12_Pos (12) /*!< EADC_T::INTSRC0: SPLIE12 Position */
#define EADC_INTSRC0_SPLIE12_Msk (0x1ul << EADC_INTSRC0_SPLIE12_Pos) /*!< EADC_T::INTSRC0: SPLIE12 Mask */
#define EADC_INTSRC0_SPLIE13_Pos (13) /*!< EADC_T::INTSRC0: SPLIE13 Position */
#define EADC_INTSRC0_SPLIE13_Msk (0x1ul << EADC_INTSRC0_SPLIE13_Pos) /*!< EADC_T::INTSRC0: SPLIE13 Mask */
#define EADC_INTSRC0_SPLIE14_Pos (14) /*!< EADC_T::INTSRC0: SPLIE14 Position */
#define EADC_INTSRC0_SPLIE14_Msk (0x1ul << EADC_INTSRC0_SPLIE14_Pos) /*!< EADC_T::INTSRC0: SPLIE14 Mask */
#define EADC_INTSRC0_SPLIE15_Pos (15) /*!< EADC_T::INTSRC0: SPLIE15 Position */
#define EADC_INTSRC0_SPLIE15_Msk (0x1ul << EADC_INTSRC0_SPLIE15_Pos) /*!< EADC_T::INTSRC0: SPLIE15 Mask */
#define EADC_INTSRC0_SPLIE16_Pos (16) /*!< EADC_T::INTSRC0: SPLIE16 Position */
#define EADC_INTSRC0_SPLIE16_Msk (0x1ul << EADC_INTSRC0_SPLIE16_Pos) /*!< EADC_T::INTSRC0: SPLIE16 Mask */
#define EADC_INTSRC0_SPLIE17_Pos (17) /*!< EADC_T::INTSRC0: SPLIE17 Position */
#define EADC_INTSRC0_SPLIE17_Msk (0x1ul << EADC_INTSRC0_SPLIE17_Pos) /*!< EADC_T::INTSRC0: SPLIE17 Mask */
#define EADC_INTSRC0_SPLIE18_Pos (18) /*!< EADC_T::INTSRC0: SPLIE18 Position */
#define EADC_INTSRC0_SPLIE18_Msk (0x1ul << EADC_INTSRC0_SPLIE18_Pos) /*!< EADC_T::INTSRC0: SPLIE18 Mask */
#define EADC_INTSRC1_SPLIE0_Pos (0) /*!< EADC_T::INTSRC1: SPLIE0 Position */
#define EADC_INTSRC1_SPLIE0_Msk (0x1ul << EADC_INTSRC1_SPLIE0_Pos) /*!< EADC_T::INTSRC1: SPLIE0 Mask */
#define EADC_INTSRC1_SPLIE1_Pos (1) /*!< EADC_T::INTSRC1: SPLIE1 Position */
#define EADC_INTSRC1_SPLIE1_Msk (0x1ul << EADC_INTSRC1_SPLIE1_Pos) /*!< EADC_T::INTSRC1: SPLIE1 Mask */
#define EADC_INTSRC1_SPLIE2_Pos (2) /*!< EADC_T::INTSRC1: SPLIE2 Position */
#define EADC_INTSRC1_SPLIE2_Msk (0x1ul << EADC_INTSRC1_SPLIE2_Pos) /*!< EADC_T::INTSRC1: SPLIE2 Mask */
#define EADC_INTSRC1_SPLIE3_Pos (3) /*!< EADC_T::INTSRC1: SPLIE3 Position */
#define EADC_INTSRC1_SPLIE3_Msk (0x1ul << EADC_INTSRC1_SPLIE3_Pos) /*!< EADC_T::INTSRC1: SPLIE3 Mask */
#define EADC_INTSRC1_SPLIE4_Pos (4) /*!< EADC_T::INTSRC1: SPLIE4 Position */
#define EADC_INTSRC1_SPLIE4_Msk (0x1ul << EADC_INTSRC1_SPLIE4_Pos) /*!< EADC_T::INTSRC1: SPLIE4 Mask */
#define EADC_INTSRC1_SPLIE5_Pos (5) /*!< EADC_T::INTSRC1: SPLIE5 Position */
#define EADC_INTSRC1_SPLIE5_Msk (0x1ul << EADC_INTSRC1_SPLIE5_Pos) /*!< EADC_T::INTSRC1: SPLIE5 Mask */
#define EADC_INTSRC1_SPLIE6_Pos (6) /*!< EADC_T::INTSRC1: SPLIE6 Position */
#define EADC_INTSRC1_SPLIE6_Msk (0x1ul << EADC_INTSRC1_SPLIE6_Pos) /*!< EADC_T::INTSRC1: SPLIE6 Mask */
#define EADC_INTSRC1_SPLIE7_Pos (7) /*!< EADC_T::INTSRC1: SPLIE7 Position */
#define EADC_INTSRC1_SPLIE7_Msk (0x1ul << EADC_INTSRC1_SPLIE7_Pos) /*!< EADC_T::INTSRC1: SPLIE7 Mask */
#define EADC_INTSRC1_SPLIE8_Pos (8) /*!< EADC_T::INTSRC1: SPLIE8 Position */
#define EADC_INTSRC1_SPLIE8_Msk (0x1ul << EADC_INTSRC1_SPLIE8_Pos) /*!< EADC_T::INTSRC1: SPLIE8 Mask */
#define EADC_INTSRC1_SPLIE9_Pos (9) /*!< EADC_T::INTSRC1: SPLIE9 Position */
#define EADC_INTSRC1_SPLIE9_Msk (0x1ul << EADC_INTSRC1_SPLIE9_Pos) /*!< EADC_T::INTSRC1: SPLIE9 Mask */
#define EADC_INTSRC1_SPLIE10_Pos (10) /*!< EADC_T::INTSRC1: SPLIE10 Position */
#define EADC_INTSRC1_SPLIE10_Msk (0x1ul << EADC_INTSRC1_SPLIE10_Pos) /*!< EADC_T::INTSRC1: SPLIE10 Mask */
#define EADC_INTSRC1_SPLIE11_Pos (11) /*!< EADC_T::INTSRC1: SPLIE11 Position */
#define EADC_INTSRC1_SPLIE11_Msk (0x1ul << EADC_INTSRC1_SPLIE11_Pos) /*!< EADC_T::INTSRC1: SPLIE11 Mask */
#define EADC_INTSRC1_SPLIE12_Pos (12) /*!< EADC_T::INTSRC1: SPLIE12 Position */
#define EADC_INTSRC1_SPLIE12_Msk (0x1ul << EADC_INTSRC1_SPLIE12_Pos) /*!< EADC_T::INTSRC1: SPLIE12 Mask */
#define EADC_INTSRC1_SPLIE13_Pos (13) /*!< EADC_T::INTSRC1: SPLIE13 Position */
#define EADC_INTSRC1_SPLIE13_Msk (0x1ul << EADC_INTSRC1_SPLIE13_Pos) /*!< EADC_T::INTSRC1: SPLIE13 Mask */
#define EADC_INTSRC1_SPLIE14_Pos (14) /*!< EADC_T::INTSRC1: SPLIE14 Position */
#define EADC_INTSRC1_SPLIE14_Msk (0x1ul << EADC_INTSRC1_SPLIE14_Pos) /*!< EADC_T::INTSRC1: SPLIE14 Mask */
#define EADC_INTSRC1_SPLIE15_Pos (15) /*!< EADC_T::INTSRC1: SPLIE15 Position */
#define EADC_INTSRC1_SPLIE15_Msk (0x1ul << EADC_INTSRC1_SPLIE15_Pos) /*!< EADC_T::INTSRC1: SPLIE15 Mask */
#define EADC_INTSRC1_SPLIE16_Pos (16) /*!< EADC_T::INTSRC1: SPLIE16 Position */
#define EADC_INTSRC1_SPLIE16_Msk (0x1ul << EADC_INTSRC1_SPLIE16_Pos) /*!< EADC_T::INTSRC1: SPLIE16 Mask */
#define EADC_INTSRC1_SPLIE17_Pos (17) /*!< EADC_T::INTSRC1: SPLIE17 Position */
#define EADC_INTSRC1_SPLIE17_Msk (0x1ul << EADC_INTSRC1_SPLIE17_Pos) /*!< EADC_T::INTSRC1: SPLIE17 Mask */
#define EADC_INTSRC1_SPLIE18_Pos (18) /*!< EADC_T::INTSRC1: SPLIE18 Position */
#define EADC_INTSRC1_SPLIE18_Msk (0x1ul << EADC_INTSRC1_SPLIE18_Pos) /*!< EADC_T::INTSRC1: SPLIE18 Mask */
#define EADC_INTSRC2_SPLIE0_Pos (0) /*!< EADC_T::INTSRC2: SPLIE0 Position */
#define EADC_INTSRC2_SPLIE0_Msk (0x1ul << EADC_INTSRC2_SPLIE0_Pos) /*!< EADC_T::INTSRC2: SPLIE0 Mask */
#define EADC_INTSRC2_SPLIE1_Pos (1) /*!< EADC_T::INTSRC2: SPLIE1 Position */
#define EADC_INTSRC2_SPLIE1_Msk (0x1ul << EADC_INTSRC2_SPLIE1_Pos) /*!< EADC_T::INTSRC2: SPLIE1 Mask */
#define EADC_INTSRC2_SPLIE2_Pos (2) /*!< EADC_T::INTSRC2: SPLIE2 Position */
#define EADC_INTSRC2_SPLIE2_Msk (0x1ul << EADC_INTSRC2_SPLIE2_Pos) /*!< EADC_T::INTSRC2: SPLIE2 Mask */
#define EADC_INTSRC2_SPLIE3_Pos (3) /*!< EADC_T::INTSRC2: SPLIE3 Position */
#define EADC_INTSRC2_SPLIE3_Msk (0x1ul << EADC_INTSRC2_SPLIE3_Pos) /*!< EADC_T::INTSRC2: SPLIE3 Mask */
#define EADC_INTSRC2_SPLIE4_Pos (4) /*!< EADC_T::INTSRC2: SPLIE4 Position */
#define EADC_INTSRC2_SPLIE4_Msk (0x1ul << EADC_INTSRC2_SPLIE4_Pos) /*!< EADC_T::INTSRC2: SPLIE4 Mask */
#define EADC_INTSRC2_SPLIE5_Pos (5) /*!< EADC_T::INTSRC2: SPLIE5 Position */
#define EADC_INTSRC2_SPLIE5_Msk (0x1ul << EADC_INTSRC2_SPLIE5_Pos) /*!< EADC_T::INTSRC2: SPLIE5 Mask */
#define EADC_INTSRC2_SPLIE6_Pos (6) /*!< EADC_T::INTSRC2: SPLIE6 Position */
#define EADC_INTSRC2_SPLIE6_Msk (0x1ul << EADC_INTSRC2_SPLIE6_Pos) /*!< EADC_T::INTSRC2: SPLIE6 Mask */
#define EADC_INTSRC2_SPLIE7_Pos (7) /*!< EADC_T::INTSRC2: SPLIE7 Position */
#define EADC_INTSRC2_SPLIE7_Msk (0x1ul << EADC_INTSRC2_SPLIE7_Pos) /*!< EADC_T::INTSRC2: SPLIE7 Mask */
#define EADC_INTSRC2_SPLIE8_Pos (8) /*!< EADC_T::INTSRC2: SPLIE8 Position */
#define EADC_INTSRC2_SPLIE8_Msk (0x1ul << EADC_INTSRC2_SPLIE8_Pos) /*!< EADC_T::INTSRC2: SPLIE8 Mask */
#define EADC_INTSRC2_SPLIE9_Pos (9) /*!< EADC_T::INTSRC2: SPLIE9 Position */
#define EADC_INTSRC2_SPLIE9_Msk (0x1ul << EADC_INTSRC2_SPLIE9_Pos) /*!< EADC_T::INTSRC2: SPLIE9 Mask */
#define EADC_INTSRC2_SPLIE10_Pos (10) /*!< EADC_T::INTSRC2: SPLIE10 Position */
#define EADC_INTSRC2_SPLIE10_Msk (0x1ul << EADC_INTSRC2_SPLIE10_Pos) /*!< EADC_T::INTSRC2: SPLIE10 Mask */
#define EADC_INTSRC2_SPLIE11_Pos (11) /*!< EADC_T::INTSRC2: SPLIE11 Position */
#define EADC_INTSRC2_SPLIE11_Msk (0x1ul << EADC_INTSRC2_SPLIE11_Pos) /*!< EADC_T::INTSRC2: SPLIE11 Mask */
#define EADC_INTSRC2_SPLIE12_Pos (12) /*!< EADC_T::INTSRC2: SPLIE12 Position */
#define EADC_INTSRC2_SPLIE12_Msk (0x1ul << EADC_INTSRC2_SPLIE12_Pos) /*!< EADC_T::INTSRC2: SPLIE12 Mask */
#define EADC_INTSRC2_SPLIE13_Pos (13) /*!< EADC_T::INTSRC2: SPLIE13 Position */
#define EADC_INTSRC2_SPLIE13_Msk (0x1ul << EADC_INTSRC2_SPLIE13_Pos) /*!< EADC_T::INTSRC2: SPLIE13 Mask */
#define EADC_INTSRC2_SPLIE14_Pos (14) /*!< EADC_T::INTSRC2: SPLIE14 Position */
#define EADC_INTSRC2_SPLIE14_Msk (0x1ul << EADC_INTSRC2_SPLIE14_Pos) /*!< EADC_T::INTSRC2: SPLIE14 Mask */
#define EADC_INTSRC2_SPLIE15_Pos (15) /*!< EADC_T::INTSRC2: SPLIE15 Position */
#define EADC_INTSRC2_SPLIE15_Msk (0x1ul << EADC_INTSRC2_SPLIE15_Pos) /*!< EADC_T::INTSRC2: SPLIE15 Mask */
#define EADC_INTSRC2_SPLIE16_Pos (16) /*!< EADC_T::INTSRC2: SPLIE16 Position */
#define EADC_INTSRC2_SPLIE16_Msk (0x1ul << EADC_INTSRC2_SPLIE16_Pos) /*!< EADC_T::INTSRC2: SPLIE16 Mask */
#define EADC_INTSRC2_SPLIE17_Pos (17) /*!< EADC_T::INTSRC2: SPLIE17 Position */
#define EADC_INTSRC2_SPLIE17_Msk (0x1ul << EADC_INTSRC2_SPLIE17_Pos) /*!< EADC_T::INTSRC2: SPLIE17 Mask */
#define EADC_INTSRC2_SPLIE18_Pos (18) /*!< EADC_T::INTSRC2: SPLIE18 Position */
#define EADC_INTSRC2_SPLIE18_Msk (0x1ul << EADC_INTSRC2_SPLIE18_Pos) /*!< EADC_T::INTSRC2: SPLIE18 Mask */
#define EADC_INTSRC3_SPLIE0_Pos (0) /*!< EADC_T::INTSRC3: SPLIE0 Position */
#define EADC_INTSRC3_SPLIE0_Msk (0x1ul << EADC_INTSRC3_SPLIE0_Pos) /*!< EADC_T::INTSRC3: SPLIE0 Mask */
#define EADC_INTSRC3_SPLIE1_Pos (1) /*!< EADC_T::INTSRC3: SPLIE1 Position */
#define EADC_INTSRC3_SPLIE1_Msk (0x1ul << EADC_INTSRC3_SPLIE1_Pos) /*!< EADC_T::INTSRC3: SPLIE1 Mask */
#define EADC_INTSRC3_SPLIE2_Pos (2) /*!< EADC_T::INTSRC3: SPLIE2 Position */
#define EADC_INTSRC3_SPLIE2_Msk (0x1ul << EADC_INTSRC3_SPLIE2_Pos) /*!< EADC_T::INTSRC3: SPLIE2 Mask */
#define EADC_INTSRC3_SPLIE3_Pos (3) /*!< EADC_T::INTSRC3: SPLIE3 Position */
#define EADC_INTSRC3_SPLIE3_Msk (0x1ul << EADC_INTSRC3_SPLIE3_Pos) /*!< EADC_T::INTSRC3: SPLIE3 Mask */
#define EADC_INTSRC3_SPLIE4_Pos (4) /*!< EADC_T::INTSRC3: SPLIE4 Position */
#define EADC_INTSRC3_SPLIE4_Msk (0x1ul << EADC_INTSRC3_SPLIE4_Pos) /*!< EADC_T::INTSRC3: SPLIE4 Mask */
#define EADC_INTSRC3_SPLIE5_Pos (5) /*!< EADC_T::INTSRC3: SPLIE5 Position */
#define EADC_INTSRC3_SPLIE5_Msk (0x1ul << EADC_INTSRC3_SPLIE5_Pos) /*!< EADC_T::INTSRC3: SPLIE5 Mask */
#define EADC_INTSRC3_SPLIE6_Pos (6) /*!< EADC_T::INTSRC3: SPLIE6 Position */
#define EADC_INTSRC3_SPLIE6_Msk (0x1ul << EADC_INTSRC3_SPLIE6_Pos) /*!< EADC_T::INTSRC3: SPLIE6 Mask */
#define EADC_INTSRC3_SPLIE7_Pos (7) /*!< EADC_T::INTSRC3: SPLIE7 Position */
#define EADC_INTSRC3_SPLIE7_Msk (0x1ul << EADC_INTSRC3_SPLIE7_Pos) /*!< EADC_T::INTSRC3: SPLIE7 Mask */
#define EADC_INTSRC3_SPLIE8_Pos (8) /*!< EADC_T::INTSRC3: SPLIE8 Position */
#define EADC_INTSRC3_SPLIE8_Msk (0x1ul << EADC_INTSRC3_SPLIE8_Pos) /*!< EADC_T::INTSRC3: SPLIE8 Mask */
#define EADC_INTSRC3_SPLIE9_Pos (9) /*!< EADC_T::INTSRC3: SPLIE9 Position */
#define EADC_INTSRC3_SPLIE9_Msk (0x1ul << EADC_INTSRC3_SPLIE9_Pos) /*!< EADC_T::INTSRC3: SPLIE9 Mask */
#define EADC_INTSRC3_SPLIE10_Pos (10) /*!< EADC_T::INTSRC3: SPLIE10 Position */
#define EADC_INTSRC3_SPLIE10_Msk (0x1ul << EADC_INTSRC3_SPLIE10_Pos) /*!< EADC_T::INTSRC3: SPLIE10 Mask */
#define EADC_INTSRC3_SPLIE11_Pos (11) /*!< EADC_T::INTSRC3: SPLIE11 Position */
#define EADC_INTSRC3_SPLIE11_Msk (0x1ul << EADC_INTSRC3_SPLIE11_Pos) /*!< EADC_T::INTSRC3: SPLIE11 Mask */
#define EADC_INTSRC3_SPLIE12_Pos (12) /*!< EADC_T::INTSRC3: SPLIE12 Position */
#define EADC_INTSRC3_SPLIE12_Msk (0x1ul << EADC_INTSRC3_SPLIE12_Pos) /*!< EADC_T::INTSRC3: SPLIE12 Mask */
#define EADC_INTSRC3_SPLIE13_Pos (13) /*!< EADC_T::INTSRC3: SPLIE13 Position */
#define EADC_INTSRC3_SPLIE13_Msk (0x1ul << EADC_INTSRC3_SPLIE13_Pos) /*!< EADC_T::INTSRC3: SPLIE13 Mask */
#define EADC_INTSRC3_SPLIE14_Pos (14) /*!< EADC_T::INTSRC3: SPLIE14 Position */
#define EADC_INTSRC3_SPLIE14_Msk (0x1ul << EADC_INTSRC3_SPLIE14_Pos) /*!< EADC_T::INTSRC3: SPLIE14 Mask */
#define EADC_INTSRC3_SPLIE15_Pos (15) /*!< EADC_T::INTSRC3: SPLIE15 Position */
#define EADC_INTSRC3_SPLIE15_Msk (0x1ul << EADC_INTSRC3_SPLIE15_Pos) /*!< EADC_T::INTSRC3: SPLIE15 Mask */
#define EADC_INTSRC3_SPLIE16_Pos (16) /*!< EADC_T::INTSRC3: SPLIE16 Position */
#define EADC_INTSRC3_SPLIE16_Msk (0x1ul << EADC_INTSRC3_SPLIE16_Pos) /*!< EADC_T::INTSRC3: SPLIE16 Mask */
#define EADC_INTSRC3_SPLIE17_Pos (17) /*!< EADC_T::INTSRC3: SPLIE17 Position */
#define EADC_INTSRC3_SPLIE17_Msk (0x1ul << EADC_INTSRC3_SPLIE17_Pos) /*!< EADC_T::INTSRC3: SPLIE17 Mask */
#define EADC_INTSRC3_SPLIE18_Pos (18) /*!< EADC_T::INTSRC3: SPLIE18 Position */
#define EADC_INTSRC3_SPLIE18_Msk (0x1ul << EADC_INTSRC3_SPLIE18_Pos) /*!< EADC_T::INTSRC3: SPLIE18 Mask */
#define EADC_CMP_ADCMPEN_Pos (0) /*!< EADC_T::CMP: ADCMPEN Position */
#define EADC_CMP_ADCMPEN_Msk (0x1ul << EADC_CMP_ADCMPEN_Pos) /*!< EADC_T::CMP: ADCMPEN Mask */
#define EADC_CMP_ADCMPIE_Pos (1) /*!< EADC_T::CMP: ADCMPIE Position */
#define EADC_CMP_ADCMPIE_Msk (0x1ul << EADC_CMP_ADCMPIE_Pos) /*!< EADC_T::CMP: ADCMPIE Mask */
#define EADC_CMP_CMPCOND_Pos (2) /*!< EADC_T::CMP: CMPCOND Position */
#define EADC_CMP_CMPCOND_Msk (0x1ul << EADC_CMP_CMPCOND_Pos) /*!< EADC_T::CMP: CMPCOND Mask */
#define EADC_CMP_CMPSPL_Pos (3) /*!< EADC_T::CMP: CMPSPL Position */
#define EADC_CMP_CMPSPL_Msk (0x1ful << EADC_CMP_CMPSPL_Pos) /*!< EADC_T::CMP: CMPSPL Mask */
#define EADC_CMP_CMPMCNT_Pos (8) /*!< EADC_T::CMP: CMPMCNT Position */
#define EADC_CMP_CMPMCNT_Msk (0xful << EADC_CMP_CMPMCNT_Pos) /*!< EADC_T::CMP: CMPMCNT Mask */
#define EADC_CMP_CMPWEN_Pos (15) /*!< EADC_T::CMP: CMPWEN Position */
#define EADC_CMP_CMPWEN_Msk (0x1ul << EADC_CMP_CMPWEN_Pos) /*!< EADC_T::CMP: CMPWEN Mask */
#define EADC_CMP_CMPDAT_Pos (16) /*!< EADC_T::CMP: CMPDAT Position */
#define EADC_CMP_CMPDAT_Msk (0xffful << EADC_CMP_CMPDAT_Pos) /*!< EADC_T::CMP: CMPDAT Mask */
#define EADC_CMP0_ADCMPEN_Pos (0) /*!< EADC_T::CMP0: ADCMPEN Position */
#define EADC_CMP0_ADCMPEN_Msk (0x1ul << EADC_CMP0_ADCMPEN_Pos) /*!< EADC_T::CMP0: ADCMPEN Mask */
#define EADC_CMP0_ADCMPIE_Pos (1) /*!< EADC_T::CMP0: ADCMPIE Position */
#define EADC_CMP0_ADCMPIE_Msk (0x1ul << EADC_CMP0_ADCMPIE_Pos) /*!< EADC_T::CMP0: ADCMPIE Mask */
#define EADC_CMP0_CMPCOND_Pos (2) /*!< EADC_T::CMP0: CMPCOND Position */
#define EADC_CMP0_CMPCOND_Msk (0x1ul << EADC_CMP0_CMPCOND_Pos) /*!< EADC_T::CMP0: CMPCOND Mask */
#define EADC_CMP0_CMPSPL_Pos (3) /*!< EADC_T::CMP0: CMPSPL Position */
#define EADC_CMP0_CMPSPL_Msk (0x1ful << EADC_CMP0_CMPSPL_Pos) /*!< EADC_T::CMP0: CMPSPL Mask */
#define EADC_CMP0_CMPMCNT_Pos (8) /*!< EADC_T::CMP0: CMPMCNT Position */
#define EADC_CMP0_CMPMCNT_Msk (0xful << EADC_CMP0_CMPMCNT_Pos) /*!< EADC_T::CMP0: CMPMCNT Mask */
#define EADC_CMP0_CMPWEN_Pos (15) /*!< EADC_T::CMP0: CMPWEN Position */
#define EADC_CMP0_CMPWEN_Msk (0x1ul << EADC_CMP0_CMPWEN_Pos) /*!< EADC_T::CMP0: CMPWEN Mask */
#define EADC_CMP0_CMPDAT_Pos (16) /*!< EADC_T::CMP0: CMPDAT Position */
#define EADC_CMP0_CMPDAT_Msk (0xffful << EADC_CMP0_CMPDAT_Pos) /*!< EADC_T::CMP0: CMPDAT Mask */
#define EADC_CMP1_ADCMPEN_Pos (0) /*!< EADC_T::CMP1: ADCMPEN Position */
#define EADC_CMP1_ADCMPEN_Msk (0x1ul << EADC_CMP1_ADCMPEN_Pos) /*!< EADC_T::CMP1: ADCMPEN Mask */
#define EADC_CMP1_ADCMPIE_Pos (1) /*!< EADC_T::CMP1: ADCMPIE Position */
#define EADC_CMP1_ADCMPIE_Msk (0x1ul << EADC_CMP1_ADCMPIE_Pos) /*!< EADC_T::CMP1: ADCMPIE Mask */
#define EADC_CMP1_CMPCOND_Pos (2) /*!< EADC_T::CMP1: CMPCOND Position */
#define EADC_CMP1_CMPCOND_Msk (0x1ul << EADC_CMP1_CMPCOND_Pos) /*!< EADC_T::CMP1: CMPCOND Mask */
#define EADC_CMP1_CMPSPL_Pos (3) /*!< EADC_T::CMP1: CMPSPL Position */
#define EADC_CMP1_CMPSPL_Msk (0x1ful << EADC_CMP1_CMPSPL_Pos) /*!< EADC_T::CMP1: CMPSPL Mask */
#define EADC_CMP1_CMPMCNT_Pos (8) /*!< EADC_T::CMP1: CMPMCNT Position */
#define EADC_CMP1_CMPMCNT_Msk (0xful << EADC_CMP1_CMPMCNT_Pos) /*!< EADC_T::CMP1: CMPMCNT Mask */
#define EADC_CMP1_CMPWEN_Pos (15) /*!< EADC_T::CMP1: CMPWEN Position */
#define EADC_CMP1_CMPWEN_Msk (0x1ul << EADC_CMP1_CMPWEN_Pos) /*!< EADC_T::CMP1: CMPWEN Mask */
#define EADC_CMP1_CMPDAT_Pos (16) /*!< EADC_T::CMP1: CMPDAT Position */
#define EADC_CMP1_CMPDAT_Msk (0xffful << EADC_CMP1_CMPDAT_Pos) /*!< EADC_T::CMP1: CMPDAT Mask */
#define EADC_CMP2_ADCMPEN_Pos (0) /*!< EADC_T::CMP2: ADCMPEN Position */
#define EADC_CMP2_ADCMPEN_Msk (0x1ul << EADC_CMP2_ADCMPEN_Pos) /*!< EADC_T::CMP2: ADCMPEN Mask */
#define EADC_CMP2_ADCMPIE_Pos (1) /*!< EADC_T::CMP2: ADCMPIE Position */
#define EADC_CMP2_ADCMPIE_Msk (0x1ul << EADC_CMP2_ADCMPIE_Pos) /*!< EADC_T::CMP2: ADCMPIE Mask */
#define EADC_CMP2_CMPCOND_Pos (2) /*!< EADC_T::CMP2: CMPCOND Position */
#define EADC_CMP2_CMPCOND_Msk (0x1ul << EADC_CMP2_CMPCOND_Pos) /*!< EADC_T::CMP2: CMPCOND Mask */
#define EADC_CMP2_CMPSPL_Pos (3) /*!< EADC_T::CMP2: CMPSPL Position */
#define EADC_CMP2_CMPSPL_Msk (0x1ful << EADC_CMP2_CMPSPL_Pos) /*!< EADC_T::CMP2: CMPSPL Mask */
#define EADC_CMP2_CMPMCNT_Pos (8) /*!< EADC_T::CMP2: CMPMCNT Position */
#define EADC_CMP2_CMPMCNT_Msk (0xful << EADC_CMP2_CMPMCNT_Pos) /*!< EADC_T::CMP2: CMPMCNT Mask */
#define EADC_CMP2_CMPWEN_Pos (15) /*!< EADC_T::CMP2: CMPWEN Position */
#define EADC_CMP2_CMPWEN_Msk (0x1ul << EADC_CMP2_CMPWEN_Pos) /*!< EADC_T::CMP2: CMPWEN Mask */
#define EADC_CMP2_CMPDAT_Pos (16) /*!< EADC_T::CMP2: CMPDAT Position */
#define EADC_CMP2_CMPDAT_Msk (0xffful << EADC_CMP2_CMPDAT_Pos) /*!< EADC_T::CMP2: CMPDAT Mask */
#define EADC_CMP3_ADCMPEN_Pos (0) /*!< EADC_T::CMP3: ADCMPEN Position */
#define EADC_CMP3_ADCMPEN_Msk (0x1ul << EADC_CMP3_ADCMPEN_Pos) /*!< EADC_T::CMP3: ADCMPEN Mask */
#define EADC_CMP3_ADCMPIE_Pos (1) /*!< EADC_T::CMP3: ADCMPIE Position */
#define EADC_CMP3_ADCMPIE_Msk (0x1ul << EADC_CMP3_ADCMPIE_Pos) /*!< EADC_T::CMP3: ADCMPIE Mask */
#define EADC_CMP3_CMPCOND_Pos (2) /*!< EADC_T::CMP3: CMPCOND Position */
#define EADC_CMP3_CMPCOND_Msk (0x1ul << EADC_CMP3_CMPCOND_Pos) /*!< EADC_T::CMP3: CMPCOND Mask */
#define EADC_CMP3_CMPSPL_Pos (3) /*!< EADC_T::CMP3: CMPSPL Position */
#define EADC_CMP3_CMPSPL_Msk (0x1ful << EADC_CMP3_CMPSPL_Pos) /*!< EADC_T::CMP3: CMPSPL Mask */
#define EADC_CMP3_CMPMCNT_Pos (8) /*!< EADC_T::CMP3: CMPMCNT Position */
#define EADC_CMP3_CMPMCNT_Msk (0xful << EADC_CMP3_CMPMCNT_Pos) /*!< EADC_T::CMP3: CMPMCNT Mask */
#define EADC_CMP3_CMPWEN_Pos (15) /*!< EADC_T::CMP3: CMPWEN Position */
#define EADC_CMP3_CMPWEN_Msk (0x1ul << EADC_CMP3_CMPWEN_Pos) /*!< EADC_T::CMP3: CMPWEN Mask */
#define EADC_CMP3_CMPDAT_Pos (16) /*!< EADC_T::CMP3: CMPDAT Position */
#define EADC_CMP3_CMPDAT_Msk (0xffful << EADC_CMP3_CMPDAT_Pos) /*!< EADC_T::CMP3: CMPDAT Mask */
#define EADC_STATUS0_VALID_Pos (0) /*!< EADC_T::STATUS0: VALID Position */
#define EADC_STATUS0_VALID_Msk (0xfffful << EADC_STATUS0_VALID_Pos) /*!< EADC_T::STATUS0: VALID Mask */
#define EADC_STATUS0_OV_Pos (16) /*!< EADC_T::STATUS0: OV Position */
#define EADC_STATUS0_OV_Msk (0xfffful << EADC_STATUS0_OV_Pos) /*!< EADC_T::STATUS0: OV Mask */
#define EADC_STATUS1_VALID_Pos (0) /*!< EADC_T::STATUS1: VALID Position */
#define EADC_STATUS1_VALID_Msk (0x7ul << EADC_STATUS1_VALID_Pos) /*!< EADC_T::STATUS1: VALID Mask */
#define EADC_STATUS1_OV_Pos (16) /*!< EADC_T::STATUS1: OV Position */
#define EADC_STATUS1_OV_Msk (0x7ul << EADC_STATUS1_OV_Pos) /*!< EADC_T::STATUS1: OV Mask */
#define EADC_STATUS2_ADIF0_Pos (0) /*!< EADC_T::STATUS2: ADIF0 Position */
#define EADC_STATUS2_ADIF0_Msk (0x1ul << EADC_STATUS2_ADIF0_Pos) /*!< EADC_T::STATUS2: ADIF0 Mask */
#define EADC_STATUS2_ADIF1_Pos (1) /*!< EADC_T::STATUS2: ADIF1 Position */
#define EADC_STATUS2_ADIF1_Msk (0x1ul << EADC_STATUS2_ADIF1_Pos) /*!< EADC_T::STATUS2: ADIF1 Mask */
#define EADC_STATUS2_ADIF2_Pos (2) /*!< EADC_T::STATUS2: ADIF2 Position */
#define EADC_STATUS2_ADIF2_Msk (0x1ul << EADC_STATUS2_ADIF2_Pos) /*!< EADC_T::STATUS2: ADIF2 Mask */
#define EADC_STATUS2_ADIF3_Pos (3) /*!< EADC_T::STATUS2: ADIF3 Position */
#define EADC_STATUS2_ADIF3_Msk (0x1ul << EADC_STATUS2_ADIF3_Pos) /*!< EADC_T::STATUS2: ADIF3 Mask */
#define EADC_STATUS2_ADCMPF0_Pos (4) /*!< EADC_T::STATUS2: ADCMPF0 Position */
#define EADC_STATUS2_ADCMPF0_Msk (0x1ul << EADC_STATUS2_ADCMPF0_Pos) /*!< EADC_T::STATUS2: ADCMPF0 Mask */
#define EADC_STATUS2_ADCMPF1_Pos (5) /*!< EADC_T::STATUS2: ADCMPF1 Position */
#define EADC_STATUS2_ADCMPF1_Msk (0x1ul << EADC_STATUS2_ADCMPF1_Pos) /*!< EADC_T::STATUS2: ADCMPF1 Mask */
#define EADC_STATUS2_ADCMPF2_Pos (6) /*!< EADC_T::STATUS2: ADCMPF2 Position */
#define EADC_STATUS2_ADCMPF2_Msk (0x1ul << EADC_STATUS2_ADCMPF2_Pos) /*!< EADC_T::STATUS2: ADCMPF2 Mask */
#define EADC_STATUS2_ADCMPF3_Pos (7) /*!< EADC_T::STATUS2: ADCMPF3 Position */
#define EADC_STATUS2_ADCMPF3_Msk (0x1ul << EADC_STATUS2_ADCMPF3_Pos) /*!< EADC_T::STATUS2: ADCMPF3 Mask */
#define EADC_STATUS2_ADOVIF0_Pos (8) /*!< EADC_T::STATUS2: ADOVIF0 Position */
#define EADC_STATUS2_ADOVIF0_Msk (0x1ul << EADC_STATUS2_ADOVIF0_Pos) /*!< EADC_T::STATUS2: ADOVIF0 Mask */
#define EADC_STATUS2_ADOVIF1_Pos (9) /*!< EADC_T::STATUS2: ADOVIF1 Position */
#define EADC_STATUS2_ADOVIF1_Msk (0x1ul << EADC_STATUS2_ADOVIF1_Pos) /*!< EADC_T::STATUS2: ADOVIF1 Mask */
#define EADC_STATUS2_ADOVIF2_Pos (10) /*!< EADC_T::STATUS2: ADOVIF2 Position */
#define EADC_STATUS2_ADOVIF2_Msk (0x1ul << EADC_STATUS2_ADOVIF2_Pos) /*!< EADC_T::STATUS2: ADOVIF2 Mask */
#define EADC_STATUS2_ADOVIF3_Pos (11) /*!< EADC_T::STATUS2: ADOVIF3 Position */
#define EADC_STATUS2_ADOVIF3_Msk (0x1ul << EADC_STATUS2_ADOVIF3_Pos) /*!< EADC_T::STATUS2: ADOVIF3 Mask */
#define EADC_STATUS2_ADCMPO0_Pos (12) /*!< EADC_T::STATUS2: ADCMPO0 Position */
#define EADC_STATUS2_ADCMPO0_Msk (0x1ul << EADC_STATUS2_ADCMPO0_Pos) /*!< EADC_T::STATUS2: ADCMPO0 Mask */
#define EADC_STATUS2_ADCMPO1_Pos (13) /*!< EADC_T::STATUS2: ADCMPO1 Position */
#define EADC_STATUS2_ADCMPO1_Msk (0x1ul << EADC_STATUS2_ADCMPO1_Pos) /*!< EADC_T::STATUS2: ADCMPO1 Mask */
#define EADC_STATUS2_ADCMPO2_Pos (14) /*!< EADC_T::STATUS2: ADCMPO2 Position */
#define EADC_STATUS2_ADCMPO2_Msk (0x1ul << EADC_STATUS2_ADCMPO2_Pos) /*!< EADC_T::STATUS2: ADCMPO2 Mask */
#define EADC_STATUS2_ADCMPO3_Pos (15) /*!< EADC_T::STATUS2: ADCMPO3 Position */
#define EADC_STATUS2_ADCMPO3_Msk (0x1ul << EADC_STATUS2_ADCMPO3_Pos) /*!< EADC_T::STATUS2: ADCMPO3 Mask */
#define EADC_STATUS2_CHANNEL_Pos (16) /*!< EADC_T::STATUS2: CHANNEL Position */
#define EADC_STATUS2_CHANNEL_Msk (0x1ful << EADC_STATUS2_CHANNEL_Pos) /*!< EADC_T::STATUS2: CHANNEL Mask */
#define EADC_STATUS2_BUSY_Pos (23) /*!< EADC_T::STATUS2: BUSY Position */
#define EADC_STATUS2_BUSY_Msk (0x1ul << EADC_STATUS2_BUSY_Pos) /*!< EADC_T::STATUS2: BUSY Mask */
#define EADC_STATUS2_ADOVIF_Pos (24) /*!< EADC_T::STATUS2: ADOVIF Position */
#define EADC_STATUS2_ADOVIF_Msk (0x1ul << EADC_STATUS2_ADOVIF_Pos) /*!< EADC_T::STATUS2: ADOVIF Mask */
#define EADC_STATUS2_STOVF_Pos (25) /*!< EADC_T::STATUS2: STOVF Position */
#define EADC_STATUS2_STOVF_Msk (0x1ul << EADC_STATUS2_STOVF_Pos) /*!< EADC_T::STATUS2: STOVF Mask */
#define EADC_STATUS2_AVALID_Pos (26) /*!< EADC_T::STATUS2: AVALID Position */
#define EADC_STATUS2_AVALID_Msk (0x1ul << EADC_STATUS2_AVALID_Pos) /*!< EADC_T::STATUS2: AVALID Mask */
#define EADC_STATUS2_AOV_Pos (27) /*!< EADC_T::STATUS2: AOV Position */
#define EADC_STATUS2_AOV_Msk (0x1ul << EADC_STATUS2_AOV_Pos) /*!< EADC_T::STATUS2: AOV Mask */
#define EADC_STATUS3_CURSPL_Pos (0) /*!< EADC_T::STATUS3: CURSPL Position */
#define EADC_STATUS3_CURSPL_Msk (0x1ful << EADC_STATUS3_CURSPL_Pos) /*!< EADC_T::STATUS3: CURSPL Mask */
#define EADC_DDAT0_RESULT_Pos (0) /*!< EADC_T::DDAT0: RESULT Position */
#define EADC_DDAT0_RESULT_Msk (0xfffful << EADC_DDAT0_RESULT_Pos) /*!< EADC_T::DDAT0: RESULT Mask */
#define EADC_DDAT0_OV_Pos (16) /*!< EADC_T::DDAT0: OV Position */
#define EADC_DDAT0_OV_Msk (0x1ul << EADC_DDAT0_OV_Pos) /*!< EADC_T::DDAT0: OV Mask */
#define EADC_DDAT0_VALID_Pos (17) /*!< EADC_T::DDAT0: VALID Position */
#define EADC_DDAT0_VALID_Msk (0x1ul << EADC_DDAT0_VALID_Pos) /*!< EADC_T::DDAT0: VALID Mask */
#define EADC_DDAT1_RESULT_Pos (0) /*!< EADC_T::DDAT1: RESULT Position */
#define EADC_DDAT1_RESULT_Msk (0xfffful << EADC_DDAT1_RESULT_Pos) /*!< EADC_T::DDAT1: RESULT Mask */
#define EADC_DDAT1_OV_Pos (16) /*!< EADC_T::DDAT1: OV Position */
#define EADC_DDAT1_OV_Msk (0x1ul << EADC_DDAT1_OV_Pos) /*!< EADC_T::DDAT1: OV Mask */
#define EADC_DDAT1_VALID_Pos (17) /*!< EADC_T::DDAT1: VALID Position */
#define EADC_DDAT1_VALID_Msk (0x1ul << EADC_DDAT1_VALID_Pos) /*!< EADC_T::DDAT1: VALID Mask */
#define EADC_DDAT2_RESULT_Pos (0) /*!< EADC_T::DDAT2: RESULT Position */
#define EADC_DDAT2_RESULT_Msk (0xfffful << EADC_DDAT2_RESULT_Pos) /*!< EADC_T::DDAT2: RESULT Mask */
#define EADC_DDAT2_OV_Pos (16) /*!< EADC_T::DDAT2: OV Position */
#define EADC_DDAT2_OV_Msk (0x1ul << EADC_DDAT2_OV_Pos) /*!< EADC_T::DDAT2: OV Mask */
#define EADC_DDAT2_VALID_Pos (17) /*!< EADC_T::DDAT2: VALID Position */
#define EADC_DDAT2_VALID_Msk (0x1ul << EADC_DDAT2_VALID_Pos) /*!< EADC_T::DDAT2: VALID Mask */
#define EADC_DDAT3_RESULT_Pos (0) /*!< EADC_T::DDAT3: RESULT Position */
#define EADC_DDAT3_RESULT_Msk (0xfffful << EADC_DDAT3_RESULT_Pos) /*!< EADC_T::DDAT3: RESULT Mask */
#define EADC_DDAT3_OV_Pos (16) /*!< EADC_T::DDAT3: OV Position */
#define EADC_DDAT3_OV_Msk (0x1ul << EADC_DDAT3_OV_Pos) /*!< EADC_T::DDAT3: OV Mask */
#define EADC_DDAT3_VALID_Pos (17) /*!< EADC_T::DDAT3: VALID Position */
#define EADC_DDAT3_VALID_Msk (0x1ul << EADC_DDAT3_VALID_Pos) /*!< EADC_T::DDAT3: VALID Mask */
#define EADC_PWRM_PWUPRDY_Pos (0) /*!< EADC_T::PWRM: PWUPRDY Position */
#define EADC_PWRM_PWUPRDY_Msk (0x1ul << EADC_PWRM_PWUPRDY_Pos) /*!< EADC_T::PWRM: PWUPRDY Mask */
#define EADC_PWRM_PWUCALEN_Pos (1) /*!< EADC_T::PWRM: PWUCALEN Position */
#define EADC_PWRM_PWUCALEN_Msk (0x1ul << EADC_PWRM_PWUCALEN_Pos) /*!< EADC_T::PWRM: PWUCALEN Mask */
#define EADC_PWRM_PWDMOD_Pos (2) /*!< EADC_T::PWRM: PWDMOD Position */
#define EADC_PWRM_PWDMOD_Msk (0x3ul << EADC_PWRM_PWDMOD_Pos) /*!< EADC_T::PWRM: PWDMOD Mask */
#define EADC_PWRM_LDOSUT_Pos (8) /*!< EADC_T::PWRM: LDOSUT Position */
#define EADC_PWRM_LDOSUT_Msk (0xffful << EADC_PWRM_LDOSUT_Pos) /*!< EADC_T::PWRM: LDOSUT Mask */
#define EADC_CALCTL_CALSTART_Pos (1) /*!< EADC_T::CALCTL: CALSTART Position */
#define EADC_CALCTL_CALSTART_Msk (0x1ul << EADC_CALCTL_CALSTART_Pos) /*!< EADC_T::CALCTL: CALSTART Mask */
#define EADC_CALCTL_CALDONE_Pos (2) /*!< EADC_T::CALCTL: CALDONE Position */
#define EADC_CALCTL_CALDONE_Msk (0x1ul << EADC_CALCTL_CALDONE_Pos) /*!< EADC_T::CALCTL: CALDONE Mask */
#define EADC_CALCTL_CALSEL_Pos (3) /*!< EADC_T::CALCTL: CALSEL Position */
#define EADC_CALCTL_CALSEL_Msk (0x1ul << EADC_CALCTL_CALSEL_Pos) /*!< EADC_T::CALCTL: CALSEL Mask */
#define EADC_CALDWRD_CALWORD_Pos (0) /*!< EADC_T::CALDWRD: CALWORD Position */
#define EADC_CALDWRD_CALWORD_Msk (0x7ful << EADC_CALDWRD_CALWORD_Pos) /*!< EADC_T::CALDWRD: CALWORD Mask */
#define EADC_PDMACTL_PDMATEN_Pos (0) /*!< EADC_T::PDMACTL: PDMATEN Position */
#define EADC_PDMACTL_PDMATEN_Msk (0x7fffful << EADC_PDMACTL_PDMATEN_Pos) /*!< EADC_T::PDMACTL: PDMATEN Mask */
/**@}*/ /* EADC_CONST */
/**@}*/ /* end of EADC register group */
/**@}*/ /* end of REGISTER group */
#endif /* __EADC_REG_H__ */
|
44a06852604142ec554215a896eb7b0b59f2caa0
|
21c92afbd7fd022a206fb31294c523aebb770104
|
/SuiteSparse/UMFPACK/Source/umf_dump.h
|
e04ed6ff69b28d812df32b31458b73622896f435
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown",
"GPL-2.0-or-later",
"GPL-3.0-only",
"LGPL-2.1-or-later",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] |
permissive
|
jlblancoc/suitesparse-metis-for-windows
|
70e6bcab2b525afb41758d61f823efa0618f67cf
|
5ee2eb4bc7bfd6d27af2f7fb027b1545cfc0fa3f
|
refs/heads/master
| 2023-08-30T21:15:39.624300
| 2023-03-09T10:16:48
| 2023-03-09T10:16:48
| 16,236,582
| 423
| 251
|
BSD-3-Clause
| 2023-03-09T10:18:08
| 2014-01-25T18:06:21
|
C
|
UTF-8
|
C
| false
| false
| 3,902
|
h
|
umf_dump.h
|
/* -------------------------------------------------------------------------- */
/* Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com. */
/* All Rights Reserved. See ../Doc/License.txt for License. */
/* -------------------------------------------------------------------------- */
/* umf_dump.h: debugging definitions. */
#ifndef NDEBUG
GLOBAL void UMF_dump_dense
(
Entry *C,
Int dim,
Int m,
Int n
) ;
GLOBAL void UMF_dump_element
(
NumericType *Numeric,
WorkType *Work,
Int e,
Int clean
) ;
GLOBAL void UMF_dump_rowcol
(
Int dump_which,
NumericType *Numeric,
WorkType *Work,
Int dump_index,
Int check_degree
) ;
GLOBAL void UMF_dump_matrix
(
NumericType *Numeric,
WorkType *Work,
Int check_degree
) ;
GLOBAL void UMF_dump_current_front
(
NumericType *Numeric,
WorkType *Work,
Int check
) ;
GLOBAL void UMF_dump_lu
(
NumericType *Numeric
) ;
GLOBAL void UMF_dump_memory
(
NumericType *Numeric
) ;
GLOBAL void UMF_dump_packed_memory
(
NumericType *Numeric,
WorkType *Work
) ;
GLOBAL void UMF_dump_col_matrix
(
const double Ax [ ],
#ifdef COMPLEX
const double Az [ ],
#endif
const Int Ai [ ],
const Int Ap [ ],
Int n_row,
Int n_col,
Int nz
) ;
GLOBAL void UMF_dump_chain
(
Int frontid,
Int Front_parent [ ],
Int Front_npivcol [ ],
Int Front_nrows [ ],
Int Front_ncols [ ],
Int nfr
) ;
GLOBAL void UMF_dump_rowmerge
(
NumericType *Numeric,
SymbolicType *Symbolic,
WorkType *Work
) ;
GLOBAL void UMF_dump_start
(
void
) ;
GLOBAL void UMF_dump_diagonal_map
(
Int Diagonal_map [ ],
Int Diagonal_imap [ ],
Int nn
) ;
#define UMF_DBMAX 50000
#ifndef EXTERN
#define EXTERN extern
#endif
GLOBAL EXTERN Int UMF_debug ;
GLOBAL EXTERN Int UMF_allocfail ;
GLOBAL EXTERN double UMF_gprob ;
#define DEBUGk(k,params) { if (UMF_debug >= (k)) { PRINTF (params) ; } }
#define DEBUGm4(params) DEBUGk (-4, params)
#define DEBUGm3(params) DEBUGk (-3, params)
#define DEBUGm2(params) DEBUGk (-2, params)
#define DEBUGm1(params) DEBUGk (-1, params)
#define DEBUG0(params) DEBUGk (0, params)
#define DEBUG1(params) DEBUGk (1, params)
#define DEBUG2(params) DEBUGk (2, params)
#define DEBUG3(params) DEBUGk (3, params)
#define DEBUG4(params) DEBUGk (4, params)
#define DEBUG5(params) DEBUGk (5, params)
#define DEBUG6(params) DEBUGk (6, params)
#define DEBUG7(params) DEBUGk (7, params)
#define DEBUG8(params) DEBUGk (8, params)
#define DEBUG9(params) DEBUGk (9, params)
#define EDEBUGk(k,a) { if (UMF_debug >= (k)) { PRINT_ENTRY (a) ; } }
#define EDEBUG0(a) EDEBUGk (0, a)
#define EDEBUG1(a) EDEBUGk (1, a)
#define EDEBUG2(a) EDEBUGk (2, a)
#define EDEBUG3(a) EDEBUGk (3, a)
#define EDEBUG4(a) EDEBUGk (4, a)
#define EDEBUG5(a) EDEBUGk (5, a)
#define EDEBUG6(a) EDEBUGk (6, a)
#define EDEBUG7(a) EDEBUGk (7, a)
#define EDEBUG8(a) EDEBUGk (8, a)
#define EDEBUG9(a) EDEBUGk (9, a)
/* ASSERT defined in amd_dump.h */
#else
/* ========================================================================== */
/* === No debugging ========================================================= */
/* ========================================================================== */
/* turn off all debugging macros */
#define DEBUGk(k,params)
#define DEBUGm4(params)
#define DEBUGm3(params)
#define DEBUGm2(params)
#define DEBUGm1(params)
#define DEBUG0(params)
#define DEBUG1(params)
#define DEBUG2(params)
#define DEBUG3(params)
#define DEBUG4(params)
#define DEBUG5(params)
#define DEBUG6(params)
#define DEBUG7(params)
#define DEBUG8(params)
#define DEBUG9(params)
#define EDEBUGk(k,a)
#define EDEBUG0(a)
#define EDEBUG1(a)
#define EDEBUG2(a)
#define EDEBUG3(a)
#define EDEBUG4(a)
#define EDEBUG5(a)
#define EDEBUG6(a)
#define EDEBUG7(a)
#define EDEBUG8(a)
#define EDEBUG9(a)
#endif /* NDEBUG */
|
3c74f9390ead8be9fa82b03f88f9d442f444a8f3
|
170b2943b2ad515acc4d751a2293f1fbf67c40d6
|
/test/test_syscalls.c
|
67b4f54ab8ea4f909530869770a8af88ac8404d2
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
pmem/vltrace
|
6b144ee14473a367ea0222296fc3e8ef5704f748
|
1e3bef9e0bfcc8cb8459a704f58457615a3bf50a
|
refs/heads/master
| 2023-09-04T10:00:09.957920
| 2023-03-22T19:58:41
| 2023-03-22T19:58:41
| 89,579,002
| 103
| 21
|
NOASSERTION
| 2023-03-22T19:58:43
| 2017-04-27T09:13:40
|
C
|
UTF-8
|
C
| false
| false
| 15,680
|
c
|
test_syscalls.c
|
/*
* Copyright 2016, Intel Corporation
*
* 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 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
* 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.
*/
/*
* test_syscalls.c -- functional tests for vltrace
*/
#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <signal.h>
#include <utime.h>
#include <assert.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/utsname.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/epoll.h>
#include <sys/xattr.h>
#include <sys/file.h>
#include <sys/socket.h>
#include <sys/inotify.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/select.h>
#include <sys/swap.h>
#include <sys/sendfile.h>
#include <linux/futex.h>
#include <linux/fs.h>
#include <linux/falloc.h>
#include "../src/syscalls_numbers.h"
#define N_WORKERS 10
#define F_ADD_SEALS 1033
#define F_GET_SEALS 1034
#define ANY_STR "any string"
#define PATTERN_START ((int)0x12345678)
#define PATTERN_END ((int)0x87654321)
#define BUF_SIZE 0x100
#define MARK_START() (void) close(PATTERN_START)
#define MARK_END() (void) close(PATTERN_END)
#define FILE_EXIST "/etc/fstab"
#define FILE_CREATE "/tmp/tmp vltrace"
#define NON_EXIST_PATH_1 "111 non exist"
#define NON_EXIST_PATH_2 "222 non exist"
/* used to test all flags set */
#define FLAGS_SET 0x0FFFFFFFFFFFFFFF
#define STRING_10 "1234567890"
#define STRING_30 STRING_10 STRING_10 STRING_10
#define STRING_60 STRING_30 STRING_30
#define STRING_120 STRING_60 STRING_60
#define STRING_420 STRING_120 STRING_120 STRING_120 STRING_60
#define STRING_840 STRING_420 STRING_420
#define STRING_1260 STRING_420 STRING_420 STRING_420
#define STRING_126_1 "START 111 "STRING_10" 111 END"
#define STRING_126_2 "START 222 "STRING_10" 222 END"
#define STRING_126_3 "START 333 "STRING_10" 333 END"
#define STRING_382_1 "START 111 "STRING_120" 111 END"
#define STRING_382_2 "START 222 "STRING_120" 222 END"
#define STRING_382_3 "START 333 "STRING_120" 333 END"
#define STRING_765_1 "START 111 "STRING_420" 111 END"
#define STRING_765_2 "START 222 "STRING_420" 222 END"
#define STRING_765_3 "START 333 "STRING_420" 333 END"
#define STRING_1148_1 "START 111 "STRING_840" 111 END"
#define STRING_1148_2 "START 222 "STRING_840" 222 END"
#define STRING_1148_3 "START 333 "STRING_840" 333 END"
#define STRING_1531_1 "START 111 "STRING_1260" 111 END"
#define STRING_1531_2 "START 222 "STRING_1260" 222 END"
#define STRING_1531_3 "START 333 "STRING_1260" 333 END"
static char *strings[5][3] = {
{
STRING_126_1,
STRING_126_2,
STRING_126_3,
},
{
STRING_382_1,
STRING_382_2,
STRING_382_3,
},
{
STRING_765_1,
STRING_765_2,
STRING_765_3,
},
{
STRING_1148_1,
STRING_1148_2,
STRING_1148_3,
},
{
STRING_1531_1,
STRING_1531_2,
STRING_1531_3,
},
};
#define N_ITERATIONS 4000000
volatile unsigned counter;
static int do_wait;
/*
* s -- busy wait for a while
*/
static inline void
s()
{
if (!do_wait)
return;
for (int i = 0; i < N_ITERATIONS; i++)
counter++;
}
/*
* test_basic_syscalls -- test basic syscalls
*/
static void
test_basic_syscalls(void)
{
char buffer[BUF_SIZE];
struct utsname name;
struct stat buf;
int fd;
memset(buffer, 0xFF, BUF_SIZE);
/* PART #1 - real arguments */
s();
fd = open(FILE_EXIST, O_RDONLY);
if (fd == -1) {
perror("open");
exit(-1);
}
s();
(void) close(fd);
s();
fd = open(FILE_CREATE, O_RDWR | O_CREAT, 0666);
if (fd == -1) {
perror("open");
exit(-1);
}
s();
(void) write(fd, buffer, BUF_SIZE);
s();
(void) lseek(fd, 0, SEEK_SET);
s();
(void) read(fd, buffer, BUF_SIZE);
s();
(void) fstat(fd, &buf);
s();
(void) close(fd);
s();
(void) unlink(FILE_CREATE);
s();
(void) execve(FILE_CREATE, (char * const *)0x123456,
(char * const *)0x654321);
s();
(void) stat(FILE_EXIST, &buf);
s();
(void) lstat(FILE_EXIST, &buf);
s();
(void) uname(&name);
s();
(void) syscall(SYS_getpid); /* getpid */
s();
(void) syscall(SYS_gettid); /* gettid */
/* PART #2 - test arguments */
s();
(void) write(0x101, buffer, 1);
s();
(void) read(0x102, buffer, 2);
s();
(void) lseek(0x103, 3, SEEK_END);
s();
(void) fstat(0x104, &buf);
s();
(void) syscall(SYS_futex, 1, FUTEX_WAKE_OP, 3, 4, 5, FLAGS_SET);
s();
}
/*
* test_unsupported_syscalls -- test unsupported syscalls
*/
static void
test_unsupported_syscalls(void)
{
char buf[BUF_SIZE];
s();
(void) chroot(NON_EXIST_PATH_1);
/* fcntl - unsupported flags */
s();
(void) syscall(SYS_fcntl, 0x104, FLAGS_SET, FLAGS_SET, 0x105, 0x106,
0x107);
s();
(void) flock(0x108, 0x109);
s();
(void) setsockopt(0x101, 0x102, 0x103, (void *)0x104, (socklen_t)0x105);
s();
(void) getsockopt(0x106, 0x107, 0x108, (void *)0x109,
(socklen_t *)0x110);
s();
struct sockaddr addr;
socklen_t addrlen = sizeof(addr);
(void) getsockname(0x101, &addr, &addrlen);
s();
(void) inotify_add_watch(0x104, NON_EXIST_PATH_1, 0x105);
s();
(void) inotify_rm_watch(0x106, 0x107);
s();
(void) syscall(SYS_io_cancel, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106);
s();
(void) syscall(SYS_io_destroy, 0x102, 0x103, 0x104, 0x105, 0x106,
0x107);
s();
(void) syscall(SYS_io_getevents, 0x103, 0x104, 0x105, 0x106, 0x107,
0x108);
s();
(void) syscall(SYS_io_setup, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109);
s();
(void) syscall(SYS_io_submit, 0x105, 0x106, 0x107, 0x108, 0x109, 0x110);
s();
(void) syscall(SYS_ioctl, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106);
s();
(void) mknod(FILE_EXIST, 0x101, 0x102);
s();
(void) mknodat(0x103, FILE_EXIST, 0x104, 0x105);
s();
(void) mmap((void *)0x101, 0x102, 0x103, 0xFFFF, 0x105, 0x106);
s();
(void) munmap((void *)0x102, 0x103);
struct timeval time1;
struct timespec time2;
memset(&time1, 0, sizeof(time1));
memset(&time2, 0, sizeof(time2));
s();
(void) select(0, (fd_set *)0x104, (fd_set *)0x105, (fd_set *)0x106,
&time1);
s();
(void) pselect(0, (fd_set *)0x105, (fd_set *)0x106, (fd_set *)0x107,
&time2, (const sigset_t *)0x108);
s();
(void) swapon(NON_EXIST_PATH_1, 0x101);
s();
(void) swapoff(NON_EXIST_PATH_2);
s();
(void) syscall(SYS_poll, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107);
s();
(void) mount(NON_EXIST_PATH_1, NON_EXIST_PATH_2, "ext3", 0x101,
(void *)0x102);
s();
(void) umount(NON_EXIST_PATH_1);
s();
(void) umount2(NON_EXIST_PATH_2, 0x123);
s();
(void) setxattr(NON_EXIST_PATH_1, ANY_STR, buf, BUF_SIZE, XATTR_CREATE);
s();
(void) lsetxattr(NON_EXIST_PATH_2, ANY_STR, buf, BUF_SIZE,
XATTR_CREATE);
s();
(void) fsetxattr(0x107, ANY_STR, buf, BUF_SIZE, XATTR_CREATE);
s();
(void) getxattr(NON_EXIST_PATH_1, ANY_STR, buf, BUF_SIZE);
s();
(void) lgetxattr(NON_EXIST_PATH_2, ANY_STR, buf, BUF_SIZE);
s();
(void) fgetxattr(0x105, ANY_STR, buf, BUF_SIZE);
s();
(void) listxattr(NON_EXIST_PATH_1, ANY_STR, 0x101);
s();
(void) llistxattr(NON_EXIST_PATH_2, ANY_STR, 0x102);
s();
(void) flistxattr(0x103, ANY_STR, 0x104);
s();
(void) removexattr(NON_EXIST_PATH_1, ANY_STR);
s();
(void) lremovexattr(NON_EXIST_PATH_2, ANY_STR);
s();
(void) fremovexattr(0x101, ANY_STR);
s();
(void) syscall(SYS_ppoll, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106);
s();
(void) epoll_ctl(0x101, 0x102, 0x103, (struct epoll_event *)0x104);
s();
(void) epoll_wait(0x102, (struct epoll_event *)0x103, 0x104, 0x105);
s();
(void) epoll_pwait(0x103, (struct epoll_event *)0x104, 0x105, 0x106,
(const sigset_t *)0x107);
/* open - unsupported flags */
s();
(void) syscall(SYS_open, NON_EXIST_PATH_2, FLAGS_SET, FLAGS_SET,
FLAGS_SET, FLAGS_SET, FLAGS_SET);
/* clone - unsupported flags */
s();
(void) syscall(SYS_clone, FLAGS_SET, FLAGS_SET, FLAGS_SET, FLAGS_SET,
FLAGS_SET, FLAGS_SET);
/* vfork - moved to test_4 */
}
/*
* test_strings -- test syscalls with string arguments
*/
static void
test_strings(char *string[3])
{
/* string args: 1 (open) */
s();
(void) syscall(SYS_open, string[0], 0x102, 0x103, 0x104, 0x105, 0x106);
/* string args: 2 (openat) */
s();
(void) syscall(SYS_openat, 0x101, string[1], 0x103, 0x104, 0x105,
0x106);
/* string args: 1 2 (rename) */
s();
(void) rename(string[0], string[1]);
/* string args: 1 2 (llistxattr) */
s();
(void) llistxattr(string[1], string[0], 0x103);
/* string args: 1 3 (symlinkat) */
s();
(void) syscall(SYS_symlinkat, string[0], 0x102, string[1]);
/* string args: 2 4 (renameat) */
s();
(void) syscall(SYS_renameat, 0x101, string[0], 0x103, string[1]);
/* string args: 1 2 3 (mount) */
s();
(void) mount(string[0], string[1], string[2], 0x101, (void *)0x102);
/* string args: 1 2 3 (request_key) */
s();
(void) syscall(SYS_request_key, string[0], string[1], string[2], 0x104);
/* string args: 3 (init_module) */
s();
(void) syscall(SYS_init_module, 0x101, 0x102, string[0]);
/* string args: 4 (kexec_file_load) */
s();
(void) syscall(SYS_kexec_file_load, 0x101, 0x102, 0x103, string[1],
0x105);
/* string args: 5 (fanotify_mark) */
s();
(void) syscall(SYS_fanotify_mark, 0x101, 0x102, 0x103, 0x104,
string[0]);
s();
}
/* testing signals */
static int Signalled;
/*
* sig_user_handler -- SIGALARM signal handler.
*/
static void
sig_user_handler(int sig, siginfo_t *si, void *unused)
{
(void) sig;
(void) si;
(void) unused;
Signalled = 1;
}
/*
* test_signal -- test the syscall 'sigaction'
*/
static void
test_signal(void)
{
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_sigaction = sig_user_handler;
sa.sa_flags = SA_RESTART | SA_RESETHAND;
(void) sigaction(SIGUSR1, &sa, NULL);
Signalled = 0;
(void) raise(SIGUSR1);
while (Signalled == 0)
sleep(1);
}
/*
* test_0 -- test basic syscalls
*/
static void
test_0(void)
{
MARK_START();
test_basic_syscalls();
MARK_END();
}
/*
* test_1 -- test basic syscalls with fork()
*/
static void
test_1(void)
{
if (syscall(SYS_fork) == -1) {
perror("fork");
exit(-1);
}
test_0();
}
/*
* test_2 -- test unsupported syscalls
*/
static void
test_2(void)
{
MARK_START();
test_unsupported_syscalls();
MARK_END();
}
/*
* test_3 -- test unsupported syscalls with fork()
*/
static void
test_3(void)
{
if (syscall(SYS_fork) == -1) {
perror("fork");
exit(-1);
}
test_2();
}
/*
* test_4 -- test vfork()
*/
static void
test_4(void)
{
MARK_START();
/*
* test if other syscalls are correctly detected,
* when vfork is present
*/
s();
(void) syscall(SYS_open, NON_EXIST_PATH_1, 0x101, 0x102, 0x103, 0x104,
0x105);
s();
(void) syscall(SYS_close, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106);
s();
switch (vfork()) {
case 0: /* handle child */
(void) execve(NON_EXIST_PATH_1, (char * const *)0x123456,
(char * const *)0x654321);
_exit(1);
case -1:
perror("vfork");
exit(-1);
}
/*
* test if other syscalls are correctly detected,
* when vfork is present
*/
s();
(void) syscall(SYS_open, NON_EXIST_PATH_2, 0x102, 0x103, 0x104, 0x105,
0x106);
s();
(void) syscall(SYS_close, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107);
s();
MARK_END();
}
/*
* test_5 -- test basic syscalls after double fork()
*/
static void
test_5(void)
{
if (syscall(SYS_fork) == -1) {
perror("fork");
exit(-1);
}
test_1();
}
/*
* test_6 -- test unsupported syscalls after double fork()
*/
static void
test_6(void)
{
if (syscall(SYS_fork) == -1) {
perror("fork");
exit(-1);
}
test_3();
}
/*
* test_7 -- test the syscall 'signal'
*/
static void
test_7(void)
{
MARK_START();
test_signal();
MARK_END();
}
/*
* test_8 -- test syscalls with string arguments of length < 126
*/
static void
test_8(void)
{
MARK_START();
test_strings(strings[0]);
MARK_END();
}
/*
* test_9 -- test syscalls with string arguments of length < 382
*/
static void
test_9(void)
{
MARK_START();
test_strings(strings[1]);
MARK_END();
}
/*
* test_10 -- test syscalls with string arguments of length < 765
*/
static void
test_10(void)
{
MARK_START();
test_strings(strings[2]);
MARK_END();
}
/*
* test_11 -- test syscalls with string arguments of length < 1148
*/
static void
test_11(void)
{
MARK_START();
test_strings(strings[3]);
MARK_END();
}
/*
* test_12 -- test syscalls with string arguments of length < 1531
*/
static void
test_12(void)
{
MARK_START();
test_strings(strings[4]);
MARK_END();
}
/*
* test_13 -- test syscalls with string arguments of length < 1531
* with single fork
*/
static void
test_13(void)
{
if (syscall(SYS_fork) == -1) {
perror("fork");
exit(-1);
}
test_12();
}
/*
* test_14 -- test syscalls with string arguments of length < 1531
* with double fork
*/
static void
test_14(void)
{
if (syscall(SYS_fork) == -1) {
perror("fork");
exit(-1);
}
test_13();
}
/*
* worker_15 -- worker for test_15
*/
static void *
worker_15(void *arg)
{
MARK_START();
test_strings(strings[0]);
MARK_END();
return NULL;
}
/*
* test_15 -- multithreaded test
*/
static void
test_15()
{
pthread_t workers[N_WORKERS];
int i;
MARK_START();
for (i = 0; i < N_WORKERS; ++i) {
if (pthread_create(&workers[i], NULL, worker_15, NULL)) {
perror("pthread_create");
exit(-1);
}
}
MARK_END();
for (i = i - 1; i >= 0; --i) {
pthread_join(workers[i], NULL);
}
}
/*
* run_test -- array of tests
*/
static void (*run_test[])(void) = {
test_0,
test_1,
test_2,
test_3,
test_4,
test_5,
test_6,
test_7,
test_8,
test_9,
test_10,
test_11,
test_12,
test_13,
test_14,
test_15
};
int
main(int argc, char *argv[])
{
int max = sizeof(run_test) / sizeof(run_test[0]) - 1;
if (argc < 3) {
fprintf(stderr,
"usage: %s <wait|do-not-wait> <test-number>\n"
" wait - busy wait between syscalls ('wait' or 'do-not-wait')\n"
" test-number - test number from the range: [0...%i]\n",
argv[0], max);
return -1;
}
do_wait = (strncmp(argv[1], "wait", 5) == 0);
printf("Notice: busy wait between syscall is %s\n",
do_wait ? "ON" : "OFF");
int n = atoi(argv[2]);
if (n < 0 || n > max) {
fprintf(stderr,
"Error: test number can take only following values: 0..%i (%i is not allowed)\n",
max, n);
return -1;
}
printf("Starting: test_%i ...\n", n);
run_test[n]();
printf("Done (test_%i)\n", n);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.