2 * This file is part of cparser.
3 * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 * File name: ir/adt/align.h
24 * Purpose: macros for alignment.
25 * Author: Markus Armbruster
27 * Created: 1999 by getting from fiasco
29 * Copyright: (c) 1995, 1996 Markus Armbruster
30 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
41 /** A size handled efficiently by malloc(), at least 1K. */
42 #define PREF_MALLOC_SIZE 2048
45 /** A wrapper around GNU C's __attribute__ */
47 /* According to the documentation, the attributes we are interested in
48 work with 2.5, but we encountered trouble before 2.7. */
49 #if defined (__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
50 # define HAVE_ATTRIBUTE 1
51 # define ATTRIBUTE(attrs) __attribute__ (attrs)
53 # define ATTRIBUTE(attrs)
59 /** A type that has most constrained alignment. */
64 } aligned_type ATTRIBUTE ((aligned));
66 /** Inquiring about the alignment of a type. */
68 # define ALIGNOF(type) __alignof__ (type)
70 # define ALIGNOF(type) offsetof (struct { char c; type d; }, d)
73 /** Maximal alignment required for any type. */
74 #define MAX_ALIGN ALIGNOF (aligned_type)