host.h 1.32 KB
Newer Older
Götz Lindenmaier's avatar
Götz Lindenmaier committed
1
2
3
4
5
6
7
8
9
10
11
/*
 * Project:     libFIRM
 * File name:   ir/adt/host.h
 * Purpose:     Declarations describing the host machine and C compiler.
 * Author:      Markus Armbruster
 * Modified by:
 * Created:     1999 by getting from fiasco
 * CVS-ID:      $Id$
 * Copyright:   (c) 1995, 1996 Markus Armbruster
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */
Boris Boesler's avatar
Boris Boesler committed
12

Christian Schäfer's avatar
Christian Schäfer committed
13
14
15
16
17
#ifndef _HOST_H
#define _HOST_H

#include <stddef.h>

Michael Beck's avatar
Michael Beck committed
18
19
20
/**
 * @file host.h
 */
Christian Schäfer's avatar
Christian Schäfer committed
21

Michael Beck's avatar
Michael Beck committed
22
/** A size handled efficiently by malloc(), at least 1K.  */
Christian Schäfer's avatar
Christian Schäfer committed
23
24
25
#define PREF_MALLOC_SIZE 2048


Michael Beck's avatar
Michael Beck committed
26
/** A wrapper around GNU C's __attribute__ */
Christian Schäfer's avatar
Christian Schäfer committed
27
28
29
30
31
32
33
34
35
36
37
38
39

/* 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 */

Michael Beck's avatar
Michael Beck committed
40
/** A type that has most constrained alignment.  */
Christian Schäfer's avatar
Christian Schäfer committed
41
42
43
44
45
46
typedef union {
  long double d;
  void *p;
  long l;
} aligned_type ATTRIBUTE ((aligned));

Michael Beck's avatar
Michael Beck committed
47
/** Inquiring about the alignment of a type.  */
Christian Schäfer's avatar
Christian Schäfer committed
48
49
50
51
52
53
#ifdef __GNUC__
# define ALIGNOF(type) __alignof__ (type)
#else
# define ALIGNOF(type) offsetof (struct { char c; type d; }, d)
#endif

Michael Beck's avatar
Michael Beck committed
54
/** Maximal alignment required for any type.  */
Christian Schäfer's avatar
Christian Schäfer committed
55
56
57
#define MAX_ALIGN ALIGNOF (aligned_type)

#endif