Commit 3da5ed25 authored by Matthias Braun's avatar Matthias Braun
Browse files

we can do without the odd align.h

[r27545]
parent fd2f1785
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* Licensees holding valid libFirm Professional Edition licenses may use
* this file in accordance with the libFirm Commercial License.
* Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
/**
* @file
* @brief macros for alignment.
* @author Markus Armbruster
* @version $Id$
*/
#ifndef FIRM_ADT_ALIGN_H
#define FIRM_ADT_ALIGN_H
#include <stddef.h>
/** A size handled efficiently by malloc(), at least 1K. */
#define PREF_MALLOC_SIZE 2048
/** A wrapper around GNU C's __attribute__ */
/* According to the documentation, the attributes we are interested in
work with 2.5, but we encountered trouble before 2.7. */
#if defined (__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
# define HAVE_ATTRIBUTE 1
# define ATTRIBUTE(attrs) __attribute__ (attrs)
#else
# define ATTRIBUTE(attrs)
#endif
/* Alignment */
/** A type that has most constrained alignment. */
typedef union {
long double d;
void *p;
long l;
} aligned_type ATTRIBUTE ((aligned));
/** Inquiring about the alignment of a type. */
#ifdef __GNUC__
# define ALIGNOF(type) __alignof__ (type)
#else
# define ALIGNOF(type) offsetof (struct { char c; type d; }, d)
#endif
/** Maximal alignment required for any type. */
#define MAX_ALIGN ALIGNOF (aligned_type)
#endif
......@@ -31,7 +31,6 @@
#include "obst.h"
#include "fourcc.h"
#include "align.h"
#include "xmalloc.h"
/**
......@@ -220,6 +219,12 @@
assert((0 <= (idx)) && ((idx) < ARR_LEN((arr))))
#endif
/** A type that has most constrained alignment. */
typedef union {
long double d;
void *p;
long l;
} aligned_type;
/**
* Construct an array header.
......
......@@ -43,6 +43,9 @@
/** Size of pdeq block cache. */
#define TUNE_NSAVED_PDEQS 16
/** A size handled efficiently by malloc(), at least 1K. */
#define PREF_MALLOC_SIZE 2048
/**
* Maximal number of data items in a pdeq chunk.
*/
......
......@@ -36,15 +36,4 @@
#define LC_FOURCC(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
#define LC_FOURCC_STR(str) LC_FOURCC(str[0], str[1], str[2], str[3])
#define LC_OFFSETOF(type,memb) ((char *) &((type *) 0)->memb - (char *) 0)
#ifdef __GNUC__
#define LC_ALIGNOF(type) __alignof__(type)
#else
#define LC_ALIGNOF(type) LC_OFFSETOF(struct { char c; type d; }, d)
#endif
#define LC_PTR2INT(x) (((char *)(x)) - (char *)0)
#define LC_INT2PTR(x) (((char *)(x)) + (char *)0)
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment