summaryrefslogtreecommitdiffstats
path: root/gl/alignof.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/alignof.h')
-rw-r--r--gl/alignof.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/gl/alignof.h b/gl/alignof.h
new file mode 100644
index 0000000..896382b
--- /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 */