diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2009-05-20 00:32:10 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2009-05-20 00:32:10 +0200 |
commit | 50b3ff7b91e78a61aca93247bee586d6d7eb27c8 (patch) | |
tree | db4c7eee24479ac7ee6888ce1562facf60159b71 /gl/alignof.h | |
parent | 2701ccd500e60537a8c2977a81549ff33eeaef3f (diff) | |
download | monitoring-plugins-50b3ff7b91e78a61aca93247bee586d6d7eb27c8.tar.gz |
Sync with the latest Gnulib code (cb75dc5)
Signed-off-by: Holger Weiss <holger@zedat.fu-berlin.de>
Diffstat (limited to 'gl/alignof.h')
-rw-r--r-- | gl/alignof.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gl/alignof.h b/gl/alignof.h new file mode 100644 index 00000000..896382b0 --- /dev/null +++ b/gl/alignof.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* Determine alignment of types. | ||
2 | Copyright (C) 2003-2004, 2006, 2009 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
17 | |||
18 | #ifndef _ALIGNOF_H | ||
19 | #define _ALIGNOF_H | ||
20 | |||
21 | #include <stddef.h> | ||
22 | |||
23 | /* Determine the alignment of a type at compile time. */ | ||
24 | #if defined __GNUC__ | ||
25 | # define alignof __alignof__ | ||
26 | #elif defined __cplusplus | ||
27 | template <class type> struct alignof_helper { char __slot1; type __slot2; }; | ||
28 | # define alignof(type) offsetof (alignof_helper<type>, __slot2) | ||
29 | #else | ||
30 | # define alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) | ||
31 | #endif | ||
32 | |||
33 | #endif /* _ALIGNOF_H */ | ||