Derive the includes from config.h instead of define alloca
[libfirm] / ir / adt / xmalloc.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/adt/xmalloc.h
4  * Purpose:     More comfortable allocations.
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
13
14 #ifndef _XMALLOC_H_
15 #define _XMALLOC_H_
16
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20
21 #ifdef HAVE_ALLOCA_H
22 #include <alloca.h>
23 #endif
24 #ifdef HAVE_MALLOC_H
25 #include <malloc.h>
26 #endif
27
28 #include "host.h"
29
30 /* xmalloc() & friends.
31
32    The macros set tmalloc_tag to __FILE__, the functions leave it
33    alone.  Use the latter if you set it yourself.  See tmalloc.c for
34    details.  */
35
36 extern void *xmalloc (size_t);
37 extern void *xrealloc (void *, size_t);
38 extern char *xstrdup (const char *);
39 extern void  xnomem (void);
40 extern void  free (void *);
41
42 # define xmalloc(size)       (XMALLOC_TRACE (xmalloc) ((size)))
43 # define xrealloc(ptr, size) (XMALLOC_TRACE (xrealloc) ((ptr), (size)))
44 # define xstrdup(str)        (XMALLOC_TRACE (xstrdup) ((str)))
45 # define xfree(ptr)          (XMALLOC_TRACE free ((ptr)))
46
47 #if defined(HAVE_GNU_MALLOC) && defined(DEBUG)
48 extern const char *tmalloc_tag;
49 # define XMALLOC_TRACE tmalloc_tag = __FILE__,
50 #else
51 # define XMALLOC_TRACE
52 #endif
53
54 #endif /* _XMALLOC_H_ */