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
  
/*\ 
||| This file a part of Pike, and is copyright by Fredrik Hubinette 
||| Pike is distributed as GPL (General Public License) 
||| See the files COPYING and DISCLAIMER for more information. 
\*/ 
#ifndef MACROS_H 
#define MACROS_H 
 
#include <sys/param.h> 
#include "pike_memory.h" 
 
#define OFFSETOF(str_type, field) ((long)& (((struct str_type *)0)->field)) 
#define BASEOF(ptr, str_type, field)  \ 
((struct str_type *)((char*)ptr - (char*)& (((struct str_type *)0)->field))) 
 
#define NELEM(a) (sizeof (a) / sizeof ((a)[0])) 
#define ALLOC_STRUCT(X) ( (struct X *)xalloc(sizeof(struct X)) ) 
 
#define MINIMUM(X,Y) ((X)<(Y)?(X):(Y)) 
#define MAXIMUM(X,Y) ((X)>(Y)?(X):(Y)) 
 
 
#define is8bitalnum(X)        ("0000000000000000" \ 
                         "0000000000001000" \ 
                         "0000000000000000" \ 
                         "1111111111000000" \ 
                         "0111111111111111" \ 
                         "1111111111100001" \ 
                         "0111111111111111" \ 
                         "1111111111100000" \ 
                         "0000000000000000" \ 
                         "0000000000000000" \ 
                         "1011110101100010" \ 
                         "1011011001101110" \ 
                         "1111111111111111" \ 
                         "1111111011111111" \ 
                         "1111111111111111" \ 
                         "1111111011111111"[((unsigned)(X))&0xff] == '1') 
   
#define isidchar(X) is8bitalnum(X) 
 
#define ALIGN_BOUND sizeof(char *) 
#define DO_ALIGN(X,Y) (((long)(X)+(Y-1)) & -(Y)) 
#define MY_ALIGN(X) DO_ALIGN(X,ALIGN_BOUND) 
 
#endif