diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/config.h.in | 12 | ||||
| -rw-r--r-- | src/include/utils/memutils.h | 53 |
2 files changed, 24 insertions, 41 deletions
diff --git a/src/include/config.h.in b/src/include/config.h.in index 5d2070c6b70..d33bcb5f689 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -290,6 +290,18 @@ extern void srandom(unsigned int seed); /* Define this as the appropriate snprintf format for 64-bit ints, if any */ #undef INT64_FORMAT +/* These must be defined as the alignment requirement (NOT the size) of + * each of the basic C data types (except char, which we assume has align 1). + * MAXIMUM_ALIGNOF is the largest alignment requirement for any C data type. + * ALIGNOF_LONG_LONG_INT need only be defined if HAVE_LONG_LONG_INT_64 is. + */ +#undef ALIGNOF_SHORT +#undef ALIGNOF_INT +#undef ALIGNOF_LONG +#undef ALIGNOF_LONG_LONG_INT +#undef ALIGNOF_DOUBLE +#undef MAXIMUM_ALIGNOF + /* Define as the base type of the last arg to accept */ #undef SOCKET_SIZE_TYPE diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index 58db49693ee..009d086311c 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -15,7 +15,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memutils.h,v 1.22 1999/03/25 03:49:34 tgl Exp $ + * $Id: memutils.h,v 1.23 1999/03/25 19:05:19 tgl Exp $ * * NOTES * some of the information in this file will be moved to @@ -30,50 +30,21 @@ /* ---------------- * Alignment macros: align a length or address appropriately for a given type. * - * It'd be best to use offsetof to check how the compiler aligns stuff, - * but not all compilers support that (still true)? So we make the - * conservative assumption that a type must be aligned on a boundary equal - * to its own size, except on a few architectures where we know better. + * There used to be some incredibly crufty platform-dependent hackery here, + * but now we rely on the configure script to get the info for us. Much nicer. * - * CAUTION: for the system tables, the struct declarations found in - * src/include/pg_*.h had better be interpreted by the compiler in a way - * that agrees with the workings of these macros. In practice that means - * being careful to lay out the columns of a system table in a way that avoids - * wasted pad space. - * - * CAUTION: _ALIGN will not work if sizeof(TYPE) is not a power of 2. - * There are machines where sizeof(double) is not, for example. - * But such a size is almost certainly not an alignment boundary anyway. + * NOTE: _ALIGN will not work if ALIGNVAL is not a power of 2. + * That case seems extremely unlikely to occur in practice, however. * ---------------- */ -#define _ALIGN(TYPE,LEN) \ - (((long)(LEN) + (sizeof(TYPE) - 1)) & ~(sizeof(TYPE) - 1)) - -#define SHORTALIGN(LEN) _ALIGN(short, (LEN)) - -#if defined(m68k) -#define INTALIGN(LEN) _ALIGN(short, (LEN)) -#else -#define INTALIGN(LEN) _ALIGN(int, (LEN)) -#endif - -#if (defined(sun) && ! defined(sparc)) || defined(m68k) -#define LONGALIGN(LEN) _ALIGN(short, (LEN)) -#else -#define LONGALIGN(LEN) _ALIGN(long, (LEN)) -#endif - -#if defined(m68k) -#define DOUBLEALIGN(LEN) _ALIGN(short, (LEN)) -#define MAXALIGN(LEN) _ALIGN(short, (LEN)) -#elif defined(sco) -#define DOUBLEALIGN(LEN) _ALIGN(int, (LEN)) -#define MAXALIGN(LEN) _ALIGN(int, (LEN)) -#else -#define DOUBLEALIGN(LEN) _ALIGN(double, (LEN)) -#define MAXALIGN(LEN) _ALIGN(double, (LEN)) -#endif +#define _ALIGN(ALIGNVAL,LEN) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1)) + +#define SHORTALIGN(LEN) _ALIGN(ALIGNOF_SHORT, (LEN)) +#define INTALIGN(LEN) _ALIGN(ALIGNOF_INT, (LEN)) +#define LONGALIGN(LEN) _ALIGN(ALIGNOF_LONG, (LEN)) +#define DOUBLEALIGN(LEN) _ALIGN(ALIGNOF_DOUBLE, (LEN)) +#define MAXALIGN(LEN) _ALIGN(MAXIMUM_ALIGNOF, (LEN)) /***************************************************************************** * oset.h -- Fixed format ordered set definitions. * |
