-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpfff_macros.h
66 lines (52 loc) · 1.9 KB
/
pfff_macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// this is used by codegraph or syncweb/indexer
// from include/386/u.h
#define va_start(list, start) list =\
(sizeof(start) < 4?\
(char*)((int*)&(start)+1):\
(char*)(&(start)+1))
#define va_end(list)\
USED(list)
#define va_arg(list, mode)\
((sizeof(mode) == 1)?\
((list += 4), (mode*)list)[-4]:\
(sizeof(mode) == 2)?\
((list += 4), (mode*)list)[-2]:\
((list += sizeof(mode)), (mode*)list)[-1])
// from include/libc.h
#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
argv[0] && argv[0][0]=='-' && argv[0][1];\
argc--, argv++) {\
char *_args, *_argt;\
Rune _argc;\
_args = &argv[0][1];\
if(_args[0]=='-' && _args[1]==0){\
argc--; argv++; break;\
}\
_argc = 0;\
while(*_args && (_args += chartorune(&_argc, _args)))\
switch(_argc)
#define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
#define offsetof(s, m) (ulong)(&(((s*)0)->m))
// misc adhoc stuff, maybe not needed anymore
#define EXTERN extern
#define Extern extern
// generators/yacc/yacc.c
// (could improve loop heuristic finder in pp_hacks?)
#define TLOOP(i) for(i=1; i<=ntokens; i++)
#define NTLOOP(i) for(i=0; i<=nnonter; i++)
#define PLOOP(s,i) for(i=s; i<nprod; i++)
#define SLOOP(i) for(i=0; i<nstate; i++)
#define WSBUMP(x) x++
#define WSLOOP(s,j) for(j=s; j<cwp; j++)
#define ITMLOOP(i,p,q) for(q=pstate[i+1], p=pstate[i]; p<q; p++)
#define SETLOOP(i) for(i=0; i<tbitset; i++)
// lib_core/libc/port/pool.c
#define antagonism if(!(p->flags & POOL_ANTAGONISM)){}else
#define paranoia if(!(p->flags & POOL_PARANOIA)){}else
#define verbosity if(!(p->flags & POOL_VERBOSITY)){}else
// linkers/libmach/8.c
// otherwise get wrong dependency on the argument that looks like an entity
#define REGOFF(x) (ulong)(&((struct Ureg *) 0)->x)
// shells/rc/exec.c
// otherwise get wrong dependency on the argument that looks like a global
//#define new(type) ((type *)emalloc(sizeof(type)))