2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief macros for alignment.
23 * @author Markus Armbruster
26 #ifndef FIRM_ADT_ALIGN_H
27 #define FIRM_ADT_ALIGN_H
31 /** A size handled efficiently by malloc(), at least 1K. */
32 #define PREF_MALLOC_SIZE 2048
35 /** A wrapper around GNU C's __attribute__ */
37 /* According to the documentation, the attributes we are interested in
38 work with 2.5, but we encountered trouble before 2.7. */
39 #if defined (__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
40 # define HAVE_ATTRIBUTE 1
41 # define ATTRIBUTE(attrs) __attribute__ (attrs)
43 # define ATTRIBUTE(attrs)
49 /** A type that has most constrained alignment. */
54 } aligned_type ATTRIBUTE ((aligned));
56 /** Inquiring about the alignment of a type. */
58 # define ALIGNOF(type) __alignof__ (type)
60 # define ALIGNOF(type) offsetof (struct { char c; type d; }, d)
63 /** Maximal alignment required for any type. */
64 #define MAX_ALIGN ALIGNOF (aligned_type)