From 8e30da4186271d17a742c45945f4fb0995f13b51 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Fri, 8 May 2009 17:08:01 +0200 Subject: Update gnulib files. --- gl/Makefile.am | 3 +-- gl/alignof.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 gl/alignof.h (limited to 'gl') diff --git a/gl/Makefile.am b/gl/Makefile.am index 4fd6aba83c..ac033757d7 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -50,8 +50,7 @@ EXTRA_libgnu_la_SOURCES += accept.c ## begin gnulib module alignof - -EXTRA_DIST += alignof.h +libgnu_la_SOURCES += alignof.h ## end gnulib module alignof diff --git a/gl/alignof.h b/gl/alignof.h new file mode 100644 index 0000000000..b16ea28874 --- /dev/null +++ b/gl/alignof.h @@ -0,0 +1,41 @@ +/* Determine alignment of types. + Copyright (C) 2003-2004, 2006, 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _ALIGNOF_H +#define _ALIGNOF_H + +#include + +/* Determine the alignment of a type at compile time. */ +#if defined __GNUC__ +# define alignof __alignof__ +#elif defined __cplusplus + template struct alignof_helper { char __slot1; type __slot2; }; +# define alignof(type) offsetof (alignof_helper, __slot2) +#elif defined __hpux + /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof + values. */ +# define alignof(type) (sizeof (type) <= 4 ? 4 : 8) +#elif defined _AIX + /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof + values. */ +# define alignof(type) (sizeof (type) <= 4 ? 4 : 8) +#else +# define alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) +#endif + +#endif /* _ALIGNOF_H */ -- cgit v1.2.1