pike.git / src / pike_macros.h

version» Context lines:

pike.git/src/pike_macros.h:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: pike_macros.h,v 1.37 2003/06/30 17:06:09 mast Exp $ + || $Id: pike_macros.h,v 1.38 2006/05/30 12:04:44 nilsson Exp $   */      #ifndef MACROS_H   #define MACROS_H      #include <global.h>      #ifdef HAVE_SYS_PARAM_H   #include <sys/param.h>   #endif      #include "pike_memory.h"      #define PTR_TO_INT(PTR) ((size_t) ((char *) (PTR) - (char *) NULL))      #define OFFSETOF(str_type, field) \    PTR_TO_INT(& (((struct str_type *)NULL)->field))   #define BASEOF(ptr, str_type, field) \    ((struct str_type *)((char*)ptr - OFFSETOF(str_type, field))) - #define ALIGNOF(X) OFFSETOF({ char ignored_; X fooo_;}, fooo_) - /* #define ALIGNOF(X) PTR_TO_INT(&(((struct { char ignored_ ; X fooo_; } *)NULL)->fooo_)) */ +     -  + #ifdef __cplusplus + extern "C++" { +  template<typename T> static inline int low_alignof_(T *ignored) +  { +  struct { char x; T y;} *bar = NULL; +  return PTR_TO_INT(&bar->y); +  } + }; + # define ALIGNOF(X) low_alignof_((X*)NULL) + #else + # define ALIGNOF(X) OFFSETOF({ char ignored_; X fooo_;}, fooo_) + #endif +    #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" \    "0000000000000000" \    "0000000000000000" \