more work on local variable support
[cparser] / adt / align.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/adt/align.h
4  * Purpose:     macros for alignment.
5  * Author:      Markus Armbruster
6  * Modified by:
7  * Created:     1999 by getting from fiasco
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1995, 1996 Markus Armbruster
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12 #ifndef _ALIGN_H
13 #define _ALIGN_H
14
15 #include <stddef.h>
16
17 /**
18  * @file align.h
19  */
20
21 /** A size handled efficiently by malloc(), at least 1K.  */
22 #define PREF_MALLOC_SIZE 2048
23
24
25 /** A wrapper around GNU C's __attribute__ */
26
27 /* According to the documentation, the attributes we are interested in
28    work with 2.5, but we encountered trouble before 2.7.  */
29 #if defined (__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
30 # define HAVE_ATTRIBUTE 1
31 # define ATTRIBUTE(attrs) __attribute__ (attrs)
32 #else
33 # define ATTRIBUTE(attrs)
34 #endif
35
36
37 /* Alignment */
38
39 /** A type that has most constrained alignment.  */
40 typedef union {
41   long double d;
42   void *p;
43   long l;
44 } aligned_type ATTRIBUTE ((aligned));
45
46 /** Inquiring about the alignment of a type.  */
47 #ifdef __GNUC__
48 # define ALIGNOF(type) __alignof__ (type)
49 #else
50 # define ALIGNOF(type) offsetof (struct { char c; type d; }, d)
51 #endif
52
53 /** Maximal alignment required for any type.  */
54 #define MAX_ALIGN ALIGNOF (aligned_type)
55
56 #endif /* _ALIGN_H */