disable_libiberty := @disable_libiberty@
-SOURCES = Makefile.in array.c array.h cookies.h debug.c debug.h host.h obst.h \
- pdeq.c pdeq.h pset.h set.c set.h pmap.h pmap.c eset.h eset.c
+SOURCES = Makefile.in \
+ array.c array.h cookies.h debug.c debug.h host.h obst.h \
+ pdeq.c pdeq.h pset.h set.c set.h pmap.h pmap.c eset.h eset.c \
+ misc.h xmalloc.h
ifeq ($(disable_libiberty),no)
SOURCES += xmalloc.c
#endif
#include <stdlib.h>
+
#include "array.h"
+#include "xmalloc.h"
/* Undefine the macros to get the functions instead, cf tmalloc.c. */
#undef xmalloc
#undef xstrdup
#undef xfree
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+#ifndef MIN
+# define MIN(a,b) ((a) > (b) ? (b) : (a))
+#endif
_arr_descr arr_mt_descr
#ifndef NDEBUG
#include <assert.h>
#include <stddef.h>
#include <obstack.h>
+
#include "cookies.h"
-#include "misc.h"
+#include "xmalloc.h"
/* Flexible create / delete */
#include <stdlib.h>
#include <string.h>
#include "debug.h"
-#include "misc.h"
+#include "xmalloc.h"
int
--- /dev/null
+/*
+ * Project: libFIRM
+ * File name: ir/adt/misc.h
+ * Purpose: Misc. declarations.
+ * 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.
+ */
+
+#ifndef _MISC_H_
+#define _MISC_H_
+
+/* Miscellaneous */
+
+typedef int (*cmp_fun) (const void *, const void *);
+
+#endif /* _MISC_H_ */
# include <stdlib.h>
# include <strings.h>
+# include "xmalloc.h"
+
# define obstack_chunk_alloc xmalloc
-# define obstack_chunk_free free
+# define obstack_chunk_free free
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
# ifdef HAVE_STRING_H
# include <string.h>
# endif
#include "cookies.h"
#include "debug.h"
#include "pdeq.h"
+#include "xmalloc.h"
/** Size of pdeq block cache */
#define _PDEQ_H_
#include <string.h>
+
#include "misc.h"
typedef struct pdeq pdeq;
#include <stdio.h>
#include <string.h>
#include "misc.h"
+#include "xmalloc.h"
#ifdef PSET
# include "pset.h"
#else
# include "set.h"
#endif
+
#define TOBSTACK_ID MANGLEP(tag)
#include "obst.h"
#include <stdlib.h>
#include <string.h>
-#include "misc.h"
+
+#include "xmalloc.h"
#include "panic.h"
--- /dev/null
+/*
+ * Project: libFIRM
+ * File name: ir/adt/xmalloc.h
+ * Purpose: More comfortable allocations.
+ * 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.
+ */
+
+
+#ifndef _XMALLOC_H_
+#define _XMALLOC_H_
+
+#include "host.h"
+
+/* Declare alloca() */
+
+#ifdef __GNUC__
+ /* @@@ on a true GNU system, this is defined by stdlib.h */
+# undef alloca
+# define alloca(size) __builtin_alloca (size)
+#else
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# if defined(_AIX) && !defined(C_ALLOCA)
+ /* if your version of AIX chokes on this, use gcc @@@ or alloca.o */
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+void *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+/* xmalloc() & friends.
+
+ The macros set tmalloc_tag to __FILE__, the functions leave it
+ alone. Use the latter if you set it yourself. See tmalloc.c for
+ details. */
+
+extern void *xmalloc (size_t);
+extern void *xrealloc (void *, size_t);
+extern char *xstrdup (const char *);
+extern void xnomem (void);
+extern void free (void *);
+
+# define xmalloc(size) (XMALLOC_TRACE (xmalloc) ((size)))
+# define xrealloc(ptr, size) (XMALLOC_TRACE (xrealloc) ((ptr), (size)))
+# define xstrdup(str) (XMALLOC_TRACE (xstrdup) ((str)))
+# define xfree(ptr) (XMALLOC_TRACE free ((ptr)))
+
+#if defined(HAVE_GNU_MALLOC) && defined(DEBUG)
+extern const char *tmalloc_tag;
+# define XMALLOC_TRACE tmalloc_tag = __FILE__,
+#else
+# define XMALLOC_TRACE
+#endif
+
+#endif /* _XMALLOC_H_ */
SOURCES = $(INSTALL_HEADERS)
-SOURCES += Makefile.in panic.c firm_common.c firm.c firmwalk.c \
- misc.h panic.h firm_common_t.h
+SOURCES += Makefile.in \
+ panic.c firm_common.c firm.c firmwalk.c \
+ panic.h firm_common_t.h
include $(topdir)/MakeRules
#include <string.h>
+#include <stdbool.h>
#include "ircgcons.h"
#include "array.h"
#include "irgmod.h"
#include "irgwalk.h"
#include "irflag.h"
-#include "misc.h"
/* Datenstruktur für jede Methode */
#endif
# include <assert.h>
+# include <stdbool.h>
# include "irprog.h"
# include "irgopt.h"
# include "iropt_t.h"
# include "irgwalk.h"
# include "ircons.h"
-# include "misc.h"
# include "irgmod.h"
# include "array.h"
# include "pset.h"
# include <config.h>
#endif
-# include "irmode_t.h"
-# include "ident.h"
# include <stdlib.h>
# include <stddef.h>
# include <string.h>
+# include <stdbool.h>
+
+# include "irmode_t.h"
+# include "ident.h"
# include "tv.h"
# include "obst.h"
-# include "misc.h"
#if 0
static long long count = 0;
# include "irop_t.h"
# include "irnode_t.h"
-# include "misc.h"
+
+# include "xmalloc.h"
ir_op *op_Block; ir_op *get_op_Block () { return op_Block; }
#include "config.h"
#endif
-# include "st.h"
+# include <stdio.h>
+# include <stdlib.h>
+# include "st.h"
# include "irgwalk.h"
-
-# include <stdio.h>
-# ifdef DEBUG_libfirm
-# endif /* def DEBUG_libfirm */
-# include <stdlib.h>
-# include "misc.h"
+# include "xmalloc.h"
/* init globals: */
/*static*/ dtree_t *trees = 0;
# include "mangle.h"
# include "obst.h"
-# include "misc.h"
/* Make types visible to allow most efficient access */
# include "entity_t.h"
# include <config.h>
#endif
-# include "misc.h"
+# include "xmalloc.h"
# include "tpop_t.h"
# include "type_t.h"