cb22561995-10-11Fredrik Hübinette (Hubbe) /*\
06983f1996-09-22Fredrik Hübinette (Hubbe) ||| This file a part of Pike, and is copyright by Fredrik Hubinette ||| Pike is distributed as GPL (General Public License)
cb22561995-10-11Fredrik Hübinette (Hubbe) ||| See the files COPYING and DISCLAIMER for more information. \*/
5267b71995-08-09Fredrik Hübinette (Hubbe) #ifndef MACROS_H #define MACROS_H #include <sys/param.h>
9aa6fa1997-05-19Fredrik Hübinette (Hubbe) #include "pike_memory.h"
5267b71995-08-09Fredrik Hübinette (Hubbe) 
d4828c1997-07-17Fredrik Hübinette (Hubbe) #define OFFSETOF(str_type, field) ((long)& (((struct str_type *)0)->field))
5267b71995-08-09Fredrik Hübinette (Hubbe) #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))
b432bb1996-10-29Per Hedbor 
ff7d821997-01-16Per Hedbor #define is8bitalnum(X) ("0000000000000000000000000000100000000000000000001111111111000000011111111111111111111111111000010111111111111111111111111110000000000000000000000000000000000000101111010110001011110110011011100000000001111111111111101111111111111111111111111111111011111111"[((unsigned)(X))&0xff] == '1')
b432bb1996-10-29Per Hedbor  #define isidchar(X) is8bitalnum(X)
5c8e891995-10-29Fredrik Hübinette (Hubbe) 
f90e541995-08-17Fredrik Hübinette (Hubbe) #define ALIGN_BOUND sizeof(char *)
06983f1996-09-22Fredrik Hübinette (Hubbe) #define DO_ALIGN(X,Y) (((long)(X)+(Y-1)) & -(Y)) #define MY_ALIGN(X) DO_ALIGN(X,ALIGN_BOUND)
5267b71995-08-09Fredrik Hübinette (Hubbe)  #endif