implemented Confirm node
[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 #include "host.h"
18
19 /* Declare alloca() */
20
21 #ifdef __GNUC__
22   /* @@@ on a true GNU system, this is defined by stdlib.h */
23 # undef alloca
24 # define alloca(size) __builtin_alloca (size)
25 #else
26 # if HAVE_ALLOCA_H
27 #   include <alloca.h>
28 # else
29 #   if defined(_AIX) && !defined(C_ALLOCA)
30       /* if your version of AIX chokes on this, use gcc @@@ or alloca.o */
31     #pragma alloca
32 #   else
33 #     ifndef alloca /* predefined by HP cc +Olibcalls */
34 void *alloca ();
35 #     endif
36 #   endif
37 # endif
38 #endif
39
40 /* xmalloc() & friends.
41
42    The macros set tmalloc_tag to __FILE__, the functions leave it
43    alone.  Use the latter if you set it yourself.  See tmalloc.c for
44    details.  */
45
46 extern void *xmalloc (size_t);
47 extern void *xrealloc (void *, size_t);
48 extern char *xstrdup (const char *);
49 extern void  xnomem (void);
50 extern void  free (void *);
51
52 # define xmalloc(size)       (XMALLOC_TRACE (xmalloc) ((size)))
53 # define xrealloc(ptr, size) (XMALLOC_TRACE (xrealloc) ((ptr), (size)))
54 # define xstrdup(str)        (XMALLOC_TRACE (xstrdup) ((str)))
55 # define xfree(ptr)          (XMALLOC_TRACE free ((ptr)))
56
57 #if defined(HAVE_GNU_MALLOC) && defined(DEBUG)
58 extern const char *tmalloc_tag;
59 # define XMALLOC_TRACE tmalloc_tag = __FILE__,
60 #else
61 # define XMALLOC_TRACE
62 #endif
63
64 #endif /* _XMALLOC_H_ */