Branch: Tag:

2003-06-30

2003-06-30 16:43:02 by Martin Stjernholm <mast@lysator.liu.se>

Added PTR_TO_INT macro.

Rev: src/pike_macros.h:1.36

2:   || 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.35 2003/01/02 18:22:37 grubba Exp $ + || $Id: pike_macros.h,v 1.36 2003/06/30 16:43:02 mast Exp $   */      #ifndef MACROS_H
16:      #include "pike_memory.h"    + #define PTR_TO_INT(PTR) ((size_t) ((char *) (PTR) - (char *) 0)) +    #define OFFSETOF(str_type, field) \ -  ((size_t)(((char *)& (((struct str_type *)0)->field))-((char *)0))) +  PTR_TO_INT(& (((struct str_type *)0)->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) ((size_t)(((char *)&(((struct { char ignored_ ; X fooo_; } *)0)->fooo_))-((char *)0))) */ + /* #define ALIGNOF(X) PTR_TO_INT(&(((struct { char ignored_ ; X fooo_; } *)0)->fooo_)) */      #define NELEM(a) (sizeof (a) / sizeof ((a)[0]))   #define ALLOC_STRUCT(X) ( (struct X *)xalloc(sizeof(struct X)) )