From fbcb96cc20a7b5d06136e4c70870e86173e658eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Wed, 20 Aug 2003 09:56:28 +0000 Subject: [PATCH] moved misc.h to adt, splitted into misc and xmalloc, updated dependencies, removed unused stuff and stdbool header [r1727] --- ir/adt/Makefile.in | 6 ++-- ir/adt/array.c | 8 ++++++ ir/adt/array.h | 3 +- ir/adt/debug.c | 2 +- ir/adt/misc.h | 20 ++++++++++++++ ir/adt/obst.h | 4 ++- ir/adt/pdeq.c | 2 ++ ir/adt/pdeq.h | 1 + ir/adt/set.c | 2 ++ ir/adt/xmalloc.c | 3 +- ir/adt/xmalloc.h | 64 +++++++++++++++++++++++++++++++++++++++++++ ir/common/Makefile.in | 5 ++-- ir/ir/ircgcons.c | 2 +- ir/ir/irgopt.c | 2 +- ir/ir/irmode.c | 7 +++-- ir/ir/irop.c | 3 +- ir/st/st.c | 11 +++----- ir/tr/mangle.c | 1 - ir/tr/tpop.c | 2 +- 19 files changed, 125 insertions(+), 23 deletions(-) create mode 100644 ir/adt/misc.h create mode 100644 ir/adt/xmalloc.h diff --git a/ir/adt/Makefile.in b/ir/adt/Makefile.in index 58ee1676e..6d14ac7b0 100644 --- a/ir/adt/Makefile.in +++ b/ir/adt/Makefile.in @@ -17,8 +17,10 @@ subdir := ir/adt 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 diff --git a/ir/adt/array.c b/ir/adt/array.c index 1c4ab0ac9..b73eac2ca 100644 --- a/ir/adt/array.c +++ b/ir/adt/array.c @@ -15,7 +15,9 @@ #endif #include + #include "array.h" +#include "xmalloc.h" /* Undefine the macros to get the functions instead, cf tmalloc.c. */ #undef xmalloc @@ -23,6 +25,12 @@ #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 diff --git a/ir/adt/array.h b/ir/adt/array.h index d4b41738b..43dd9eb07 100644 --- a/ir/adt/array.h +++ b/ir/adt/array.h @@ -18,8 +18,9 @@ #include #include #include + #include "cookies.h" -#include "misc.h" +#include "xmalloc.h" /* Flexible create / delete */ diff --git a/ir/adt/debug.c b/ir/adt/debug.c index edb6876d3..e8616d340 100644 --- a/ir/adt/debug.c +++ b/ir/adt/debug.c @@ -17,7 +17,7 @@ #include #include #include "debug.h" -#include "misc.h" +#include "xmalloc.h" int diff --git a/ir/adt/misc.h b/ir/adt/misc.h new file mode 100644 index 000000000..7de7315b7 --- /dev/null +++ b/ir/adt/misc.h @@ -0,0 +1,20 @@ +/* + * 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_ */ diff --git a/ir/adt/obst.h b/ir/adt/obst.h index a25482aaf..865c96aa7 100644 --- a/ir/adt/obst.h +++ b/ir/adt/obst.h @@ -15,5 +15,7 @@ # include # include +# include "xmalloc.h" + # define obstack_chunk_alloc xmalloc -# define obstack_chunk_free free +# define obstack_chunk_free free diff --git a/ir/adt/pdeq.c b/ir/adt/pdeq.c index 51211c233..284da0508 100644 --- a/ir/adt/pdeq.c +++ b/ir/adt/pdeq.c @@ -18,6 +18,7 @@ #include #include #include +#include # ifdef HAVE_STRING_H # include # endif @@ -25,6 +26,7 @@ #include "cookies.h" #include "debug.h" #include "pdeq.h" +#include "xmalloc.h" /** Size of pdeq block cache */ diff --git a/ir/adt/pdeq.h b/ir/adt/pdeq.h index a8043dcd6..f9c5239bf 100644 --- a/ir/adt/pdeq.h +++ b/ir/adt/pdeq.h @@ -15,6 +15,7 @@ #define _PDEQ_H_ #include + #include "misc.h" typedef struct pdeq pdeq; diff --git a/ir/adt/set.c b/ir/adt/set.c index 9a30bd5ba..f43a0a34f 100644 --- a/ir/adt/set.c +++ b/ir/adt/set.c @@ -66,12 +66,14 @@ #include #include #include "misc.h" +#include "xmalloc.h" #ifdef PSET # include "pset.h" #else # include "set.h" #endif + #define TOBSTACK_ID MANGLEP(tag) #include "obst.h" diff --git a/ir/adt/xmalloc.c b/ir/adt/xmalloc.c index 087a0db7a..89ab63a4c 100644 --- a/ir/adt/xmalloc.c +++ b/ir/adt/xmalloc.c @@ -19,7 +19,8 @@ #include #include -#include "misc.h" + +#include "xmalloc.h" #include "panic.h" diff --git a/ir/adt/xmalloc.h b/ir/adt/xmalloc.h new file mode 100644 index 000000000..942c3fff1 --- /dev/null +++ b/ir/adt/xmalloc.h @@ -0,0 +1,64 @@ +/* + * 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 +# 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_ */ diff --git a/ir/common/Makefile.in b/ir/common/Makefile.in index e3e068c3b..bdb6699eb 100644 --- a/ir/common/Makefile.in +++ b/ir/common/Makefile.in @@ -19,8 +19,9 @@ INSTALL_HEADERS := firm_common.h firm.h firmwalk.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 diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index 5c72a40b9..be6d0f892 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -13,6 +13,7 @@ #include +#include #include "ircgcons.h" #include "array.h" @@ -21,7 +22,6 @@ #include "irgmod.h" #include "irgwalk.h" #include "irflag.h" -#include "misc.h" /* Datenstruktur für jede Methode */ diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index c5e7b04fb..c63a524fc 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -16,6 +16,7 @@ #endif # include +# include # include "irprog.h" # include "irgopt.h" @@ -24,7 +25,6 @@ # include "iropt_t.h" # include "irgwalk.h" # include "ircons.h" -# include "misc.h" # include "irgmod.h" # include "array.h" # include "pset.h" diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index e0bb6ee86..f3b62e71f 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -15,14 +15,15 @@ # include #endif -# include "irmode_t.h" -# include "ident.h" # include # include # include +# include + +# include "irmode_t.h" +# include "ident.h" # include "tv.h" # include "obst.h" -# include "misc.h" #if 0 static long long count = 0; diff --git a/ir/ir/irop.c b/ir/ir/irop.c index 79a07302d..26b46a314 100644 --- a/ir/ir/irop.c +++ b/ir/ir/irop.c @@ -18,7 +18,8 @@ # 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; } diff --git a/ir/st/st.c b/ir/st/st.c index ed7d5011e..26f083d8b 100644 --- a/ir/st/st.c +++ b/ir/st/st.c @@ -23,15 +23,12 @@ #include "config.h" #endif -# include "st.h" +# include +# include +# include "st.h" # include "irgwalk.h" - -# include -# ifdef DEBUG_libfirm -# endif /* def DEBUG_libfirm */ -# include -# include "misc.h" +# include "xmalloc.h" /* init globals: */ /*static*/ dtree_t *trees = 0; diff --git a/ir/tr/mangle.c b/ir/tr/mangle.c index 9bca8227b..5adb6661a 100644 --- a/ir/tr/mangle.c +++ b/ir/tr/mangle.c @@ -18,7 +18,6 @@ # include "mangle.h" # include "obst.h" -# include "misc.h" /* Make types visible to allow most efficient access */ # include "entity_t.h" diff --git a/ir/tr/tpop.c b/ir/tr/tpop.c index 71885e0f6..13454a52f 100644 --- a/ir/tr/tpop.c +++ b/ir/tr/tpop.c @@ -15,7 +15,7 @@ # include #endif -# include "misc.h" +# include "xmalloc.h" # include "tpop_t.h" # include "type_t.h" -- 2.20.1