From: Peter Johnson Date: Mon, 5 May 2003 03:42:12 +0000 (-0000) Subject: Clean up and simplify libyasm.h options and symbol visibility: X-Git-Tag: v0.2.2~3^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfc6bf0dedf4aa501937be4406ed50e6e4649a97;p=yasm Clean up and simplify libyasm.h options and symbol visibility: - Move config.h and util.h from libyasm (and installed libyasm) to top level. - Move yasm_* functions from util.h to coretype.h. - Remove a number of autoconf-related YASM_*_INTERNAL options from libyasm.h. - Rename YASM_INTERNAL to YASM_LIB_INTERNAL; it now actually means what the comment describes: enables definitions that violate the yasm_* namespace. While we're at it, no longer define YASM_LIB_INTERNAL from yasm frontend, so it's closer to what a real typical libyasm-using application would look like. svn path=/trunk/yasm/; revision=944 --- diff --git a/.cvsignore b/.cvsignore index 66c84256..2cf096c4 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,4 +1,6 @@ autom4te.cache +stamp-h* +config.* nasm-bison.c nasm-bison.h nasm-token.c diff --git a/Makefile.am b/Makefile.am index ae11a424..1719629b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -# $IdPath$ +# $IdPath: yasm/Makefile.am,v 1.48 2003/05/03 06:26:15 peter Exp $ SUBDIRS = libltdl m4 po . @@ -15,6 +15,8 @@ noinst_PROGRAMS = include_HEADERS = libyasm.h +noinst_HEADERS = util.h + lib_LTLIBRARIES = pkglib_LTLIBRARIES = diff --git a/configure.ac b/configure.ac index 99c2e515..419765df 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -# $IdPath$ +# $IdPath: yasm/configure.ac,v 1.70 2003/03/18 05:00:54 peter Exp $ # Minimum required perl version for development PERL_VERSION=5.004 @@ -11,7 +11,7 @@ AC_PREREQ(2.50) AC_INIT([yasm], `date "+%Y%m%d"`, [bug-yasm@tortall.net]) #AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_AUX_DIR(config) -AM_CONFIG_HEADER([libyasm/config.h]) +AM_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE(yasm, `date "+%Y%m%d"`) AM_MAINTAINER_MODE diff --git a/frontends/yasm/yasm-module.c b/frontends/yasm/yasm-module.c index 352f864b..565100d4 100644 --- a/frontends/yasm/yasm-module.c +++ b/frontends/yasm/yasm-module.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#define YASM_LIB_INTERNAL +#include +/*@unused@*/ RCSID("$IdPath: yasm/frontends/yasm/yasm-module.c,v 1.13 2003/05/03 06:26:15 peter Exp $"); + +#include #include -/*@unused@*/ RCSID("$IdPath$"); #include "ltdl.h" diff --git a/frontends/yasm/yasm-options.c b/frontends/yasm/yasm-options.c index 5df325ad..dc12682b 100644 --- a/frontends/yasm/yasm-options.c +++ b/frontends/yasm/yasm-options.c @@ -27,9 +27,8 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#define YASM_LIB_INTERNAL -#include -/*@unused@*/ RCSID("$IdPath$"); +#include +/*@unused@*/ RCSID("$IdPath: yasm/frontends/yasm/yasm-options.c,v 1.13 2003/04/01 19:53:30 mu Exp $"); #include "yasm-options.h" diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 7ef74963..3aecf6f9 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -24,9 +24,12 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#define YASM_LIB_INTERNAL +#include +/*@unused@*/ RCSID("$IdPath: yasm/frontends/yasm/yasm.c,v 1.96 2003/05/03 06:26:15 peter Exp $"); + +#include +#include #include -/*@unused@*/ RCSID("$IdPath$"); #ifndef WIN32 #include "ltdl.h" diff --git a/libltdl/Makefile.am b/libltdl/Makefile.am index be2a59db..c9584bd7 100644 --- a/libltdl/Makefile.am +++ b/libltdl/Makefile.am @@ -25,7 +25,7 @@ libltdlc_la_SOURCES = ltdl.c libltdlc_la_LIBADD = $(LIBADD_DL) ## Because we do not have automatic dependency tracking: -ltdl.lo: ltdl.h ../libyasm/config.h +ltdl.lo: ltdl.h ../config.h $(libltdl_la_OBJECTS) $(libltdlc_la_OBJECTS): $(top_builddir)/libtool #libtool: $(LIBTOOL_DEPS) diff --git a/libyasm.h b/libyasm.h index 6e70e2cd..ff86421b 100644 --- a/libyasm.h +++ b/libyasm.h @@ -1,4 +1,4 @@ -/* $IdPath$ +/* $IdPath: yasm/libyasm.h,v 1.3 2003/03/30 21:27:25 peter Exp $ * Libyasm interface primary header file. * * Copyright (C) 2003 Peter Johnson @@ -27,25 +27,25 @@ #ifndef YASM_LIB_H #define YASM_LIB_H -/* Define YASM_INTERNAL to include many internal function and variable defs. - * This includes compat-queue.h, bitvect.h, hamt.h, and util.h, which violate - * the yasm_* namespace (see individual files for details)! +/* Define YASM_LIB_INTERNAL to include many internal function and variable + * definitions that violate the yasm_* namespace. This includes + * compat-queue.h, bitvect.h, and hamt.h. * - * Additional parts may be included via YASM_*_INTERNAL inclusion flags: + * Additional parts may be included via: * YASM_BC_INTERNAL: reveal bytecode internal structures via bc-int.h inclusion * YASM_EXPR_INTERNAL: reveal expr internal structures via expr-int.h inclusion - * YASM_AUTOCONF_INTERNAL: include parts of util.h that depend on certain - * autoconfig settings.. see util.h for more details - * YASM_LIB_AC_INTERNAL: include libyasm/config.h if HAVE_CONFIG_H is defined - * YASM_GETTEXT_INTERNAL: define typical gettext _() and N_(). Requires - * YASM_AUTOCONF_INTERNAL define. - * - * YASM_LIB_INTERNAL: defines YASM_INTERNAL, YASM_AUTOCONF_INTERNAL, - * YASM_LIB_AC_INTERNAL, and YASM_GETTEXT_INTERNAL - * (used when compiling the library itself) */ -#include +#include +#include + +#ifdef YASM_LIB_INTERNAL +# include +#endif + +#include +#include + #include #include @@ -66,7 +66,7 @@ #include -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #ifdef YASM_BC_INTERNAL #include #endif diff --git a/libyasm/.cvsignore b/libyasm/.cvsignore deleted file mode 100644 index aaf3458d..00000000 --- a/libyasm/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -stamp-h* -config.* diff --git a/libyasm/Makefile.inc b/libyasm/Makefile.inc index 30254a2a..be366b55 100644 --- a/libyasm/Makefile.inc +++ b/libyasm/Makefile.inc @@ -1,4 +1,4 @@ -# $IdPath$ +# $IdPath: yasm/libyasm/Makefile.inc,v 1.17 2003/03/15 05:07:47 peter Exp $ lib_LTLIBRARIES += libyasm.la libyasm_la_SOURCES = \ @@ -24,7 +24,6 @@ libyasm_la_LDFLAGS = -no-undefined modincludedir = $(includedir)/libyasm modinclude_HEADERS = \ - libyasm/util.h \ libyasm/bytecode.h \ libyasm/bc-int.h \ libyasm/errwarn.h \ @@ -48,9 +47,6 @@ modinclude_HEADERS = \ libyasm/valparam.h \ libyasm/compat-queue.h -# Generated at configure time, so must be DATA instead of HEADERS -modinclude_DATA = libyasm/config.h - EXTRA_DIST += \ libyasm/tests/Makefile.inc diff --git a/libyasm/arch.c b/libyasm/arch.c index b117b400..3c5902b2 100644 --- a/libyasm/arch.c +++ b/libyasm/arch.c @@ -26,7 +26,9 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/arch.c,v 1.11 2003/03/15 05:07:48 peter Exp $"); + +#include "coretype.h" #include "expr.h" @@ -176,7 +178,7 @@ yasm_ops_print(FILE *f, int indent_level, const yasm_insn_operandhead *headp) yasm_operand_print(f, indent_level, cur); } -/* Non-macro yasm_ops_initialize() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_ops_initialize() for non-YASM_LIB_INTERNAL users. */ #undef yasm_ops_initialize void yasm_ops_initialize(yasm_insn_operandhead *headp) @@ -184,7 +186,7 @@ yasm_ops_initialize(yasm_insn_operandhead *headp) STAILQ_INIT(headp); } -/* Non-macro yasm_ops_first() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_ops_first() for non-YASM_LIB_INTERNAL users. */ #undef yasm_ops_first yasm_insn_operand * yasm_ops_first(yasm_insn_operandhead *headp) @@ -192,7 +194,7 @@ yasm_ops_first(yasm_insn_operandhead *headp) return STAILQ_FIRST(headp); } -/* Non-macro yasm_ops_next() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_ops_next() for non-YASM_LIB_INTERNAL users. */ #undef yasm_ops_next yasm_insn_operand * yasm_ops_next(yasm_insn_operand *cur) diff --git a/libyasm/arch.h b/libyasm/arch.h index 81623e78..79cb3eb0 100644 --- a/libyasm/arch.h +++ b/libyasm/arch.h @@ -2,7 +2,7 @@ * \file arch.h * \brief YASM architecture interface. * - * $IdPath$ + * $IdPath: yasm/libyasm/arch.h,v 1.28 2003/03/31 08:22:05 peter Exp $ * * Copyright (C) 2002 Peter Johnson * @@ -46,7 +46,7 @@ typedef struct yasm_insn_operand yasm_insn_operand; * The list goes from left-to-right as parsed. */ typedef struct yasm_insn_operandhead yasm_insn_operandhead; -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL /*@reldef@*/ STAILQ_HEAD(yasm_insn_operandhead, yasm_insn_operand); #endif @@ -280,7 +280,7 @@ struct yasm_arch { void (*ea_data_print) (FILE *f, int indent_level, const yasm_effaddr *ea); }; -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL /** An instruction operand. */ struct yasm_insn_operand { /** Link for building linked list of operands. \internal */ @@ -365,7 +365,7 @@ yasm_insn_operand *yasm_ops_first(yasm_insn_operandhead *headp); */ yasm_insn_operand *yasm_ops_next(yasm_insn_operand *cur); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #define yasm_ops_initialize(headp) STAILQ_INIT(headp) #define yasm_ops_first(headp) STAILQ_FIRST(headp) #define yasm_ops_next(cur) STAILQ_NEXT(cur, link) diff --git a/libyasm/bitvect.c b/libyasm/bitvect.c index d4749479..945f0eb7 100644 --- a/libyasm/bitvect.c +++ b/libyasm/bitvect.c @@ -1,6 +1,8 @@ #define YASM_LIB_INTERNAL #include "util.h" -RCSID("$IdPath$"); +RCSID("$IdPath: yasm/libyasm/bitvect.c,v 1.19 2003/05/03 08:01:09 peter Exp $"); + +#include "coretype.h" /*****************************************************************************/ /* MODULE NAME: BitVector.c MODULE TYPE: (adt) */ diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index 8806030d..05e23ecf 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -26,8 +26,9 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath: yasm/libyasm/bytecode.c,v 1.93 2003/03/31 05:36:29 peter Exp $"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/bytecode.c,v 1.94 2003/05/04 22:15:09 peter Exp $"); +#include "coretype.h" #include "file.h" #include "errwarn.h" @@ -995,7 +996,7 @@ yasm_bcs_new(void) return headp; } -/* Non-macro yasm_bcs_first() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_bcs_first() for non-YASM_LIB_INTERNAL users. */ #undef yasm_bcs_first yasm_bytecode * yasm_bcs_first(yasm_bytecodehead *headp) @@ -1003,7 +1004,7 @@ yasm_bcs_first(yasm_bytecodehead *headp) return STAILQ_FIRST(headp); } -/* Non-macro yasm_dvs_initialize() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_dvs_initialize() for non-YASM_LIB_INTERNAL users. */ #undef yasm_dvs_initialize void yasm_dvs_initialize(yasm_datavalhead *headp) diff --git a/libyasm/bytecode.h b/libyasm/bytecode.h index 396df834..c7f75429 100644 --- a/libyasm/bytecode.h +++ b/libyasm/bytecode.h @@ -2,7 +2,7 @@ * \file bytecode.h * \brief YASM bytecode interface. * - * $IdPath: yasm/libyasm/bytecode.h,v 1.72 2003/05/04 08:40:35 peter Exp $ + * $IdPath: yasm/libyasm/bytecode.h,v 1.73 2003/05/04 22:15:09 peter Exp $ * * Copyright (C) 2001 Peter Johnson * @@ -39,7 +39,7 @@ typedef struct yasm_dataval yasm_dataval; /** A list of data values (opaque type). */ typedef struct yasm_datavalhead yasm_datavalhead; -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL /*@reldef@*/ STAILQ_HEAD(yasm_bytecodehead, yasm_bytecode); /*@reldef@*/ STAILQ_HEAD(yasm_datavalhead, yasm_dataval); @@ -123,7 +123,7 @@ void yasm_ea_print(FILE *f, int indent_level, const yasm_effaddr *ea); */ void yasm_bc_set_multiple(yasm_bytecode *bc, /*@keep@*/ yasm_expr *e); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL /** Create a bytecode of any specified type. * \param type bytecode type * \param datasize size of type-specific data (in bytes) @@ -275,7 +275,7 @@ yasm_bc_resolve_flags yasm_bc_resolve(yasm_bytecode *bc, int save, * \return First bytecode in list (NULL if list is empty). */ /*@null@*/ yasm_bytecode *yasm_bcs_first(yasm_bytecodehead *headp); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #define yasm_bcs_first(headp) STAILQ_FIRST(headp) #endif @@ -342,7 +342,7 @@ yasm_dataval *yasm_dv_new_string(/*@keep@*/ char *str_val); * \param headp list of data values */ void yasm_dvs_initialize(yasm_datavalhead *headp); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #define yasm_dvs_initialize(headp) STAILQ_INIT(headp) #endif diff --git a/libyasm/coretype.h b/libyasm/coretype.h index 212b2ead..d32f78a8 100644 --- a/libyasm/coretype.h +++ b/libyasm/coretype.h @@ -1,8 +1,8 @@ /** * \file coretype.h - * \brief YASM core type definitions. + * \brief YASM core types and utility functions. * - * $IdPath$ + * $IdPath: yasm/libyasm/coretype.h,v 1.23 2003/03/31 08:22:05 peter Exp $ * * Copyright (C) 2001 Peter Johnson * @@ -174,4 +174,90 @@ typedef int (*yasm_output_expr_func) typedef int (*yasm_output_bc_objfmt_data_func) (unsigned int type, /*@observer@*/ void *data, unsigned char **bufp) /*@sets **bufp@*/; + +/** Sort an array using merge sort algorithm. + * \internal + * \param base base of array + * \param nmemb number of elements in array + * \param size size of each array element + * \param compar element comparison function + */ +int yasm__mergesort(void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)); + +/** Separate string by delimiters. + * \internal + * \param stringp string + * \param delim set of 1 or more delimiters + * \return First/next substring. + */ +/*@null@*/ char *yasm__strsep(char **stringp, const char *delim); + +/** Compare two strings, ignoring case differences. + * \internal + * \param s1 string 1 + * \param s2 string 2 + * \return 0 if strings are equal, -1 if s1s2. + */ +int yasm__strcasecmp(const char *s1, const char *s2); + +/** Compare portion of two strings, ignoring case differences. + * \internal + * \param s1 string 1 + * \param s2 string 2 + * \param n maximum number of characters to compare + * \return 0 if strings are equal, -1 if s1s2. + */ +int yasm__strncasecmp(const char *s1, const char *s2, size_t n); + +/** strdup() implementation using yasm_xmalloc(). + * \internal + * \param str string + * \return Newly allocated duplicate string. + */ +/*@only@*/ char *yasm__xstrdup(const char *str); + +/** strndup() implementation using yasm_xmalloc(). + * \internal + * \param str string + * \param len maximum number of characters to copy + * \return Newly allocated duplicate string. + */ +/*@only@*/ char *yasm__xstrndup(const char *str, size_t len); + +/** Error-checking memory allocation. A default implementation is provided + * that calls yasm_fatal() on allocation errors. + * A replacement should \em never return NULL. + * \param size number of bytes to allocate + * \return Allocated memory block. + */ +extern /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size); + +/** Error-checking memory allocation (with clear-to-0). A default + * implementation is provided that calls yasm_fatal() on allocation errors. + * A replacement should \em never return NULL. + * \param size number of elements to allocate + * \param elsize size (in bytes) of each element + * \return Allocated and cleared memory block. + */ +extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize); + +/** Error-checking memory reallocation. A default implementation is provided + * that calls yasm_fatal() on allocation errors. A replacement should + * \em never return NULL. + * \param oldmem memory block to resize + * \param elsize new size, in bytes + * \return Re-allocated memory block. + */ +extern /*@only@*/ void * (*yasm_xrealloc) + (/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size) + /*@modifies oldmem@*/; + +/** Error-checking memory deallocation. A default implementation is provided + * that calls yasm_fatal() on allocation errors. + * \param p memory block to free + */ +extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p) + /*@modifies p@*/; + #endif diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index 8945337b..7b165021 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -26,7 +26,7 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath: yasm/libyasm/errwarn.c,v 1.55 2003/03/16 23:52:54 peter Exp $"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/errwarn.c,v 1.56 2003/05/04 01:39:10 peter Exp $"); #include @@ -34,6 +34,8 @@ # include #endif +#include "coretype.h" + #include "linemgr.h" #include "errwarn.h" diff --git a/libyasm/errwarn.h b/libyasm/errwarn.h index cb11692f..f15700a1 100644 --- a/libyasm/errwarn.h +++ b/libyasm/errwarn.h @@ -2,7 +2,7 @@ * \file errwarn.h * \brief YASM error and warning reporting interface. * - * $IdPath: yasm/libyasm/errwarn.h,v 1.36 2003/05/04 01:39:10 peter Exp $ + * $IdPath: yasm/libyasm/errwarn.h,v 1.37 2003/05/04 08:40:35 peter Exp $ * * Copyright (C) 2001 Peter Johnson * @@ -70,8 +70,6 @@ extern /*@exits@*/ void (*yasm_internal_error_) */ extern /*@exits@*/ void (*yasm_fatal) (const char *message); -#ifdef YASM_INTERNAL - /** Log an error. va_list version of yasm__error(). * \internal * \param lindex line index @@ -108,8 +106,8 @@ void yasm__error(unsigned long lindex, const char *message, ...) * \param message printf-like-format message * \param ... argument list for message */ -void yasm__warning(yasm_warn_class, unsigned long lindex, const char *message, - ...) /*@printflike@*/; +void yasm__warning(yasm_warn_class wclass, unsigned long lindex, + const char *message, ...) /*@printflike@*/; /** Log a parser error. Parser errors can be overwritten by non-parser errors * on the same line. @@ -119,8 +117,6 @@ void yasm__warning(yasm_warn_class, unsigned long lindex, const char *message, */ void yasm__parser_error(unsigned long lindex, const char *message); -#endif - /** Enable a class of warnings. * \param wclass warning class */ @@ -166,14 +162,12 @@ void yasm_errwarn_output_all (yasm_linemgr *lm, int warning_as_error, yasm_print_error_func print_error, yasm_print_warning_func print_warning); -#ifdef YASM_INTERNAL /** Convert a possibly unprintable character into a printable string. * \internal * \param ch possibly unprintable character * \return Printable string representation (static buffer). */ char *yasm__conv_unprint(int ch); -#endif /** Hook for library users to map to gettext() if GNU gettext is being used. * \param msgid message catalog identifier diff --git a/libyasm/expr.c b/libyasm/expr.c index 26b1b06f..8fc2cd7a 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -26,8 +26,9 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/expr.c,v 1.64 2003/03/15 21:59:55 peter Exp $"); +#include "coretype.h" #include "bitvect.h" #include "errwarn.h" diff --git a/libyasm/expr.h b/libyasm/expr.h index e04767c3..b0c639a1 100644 --- a/libyasm/expr.h +++ b/libyasm/expr.h @@ -2,7 +2,7 @@ * \file expr.h * \brief YASM expression interface * - * $IdPath: yasm/libyasm/expr.h,v 1.39 2003/03/15 05:07:48 peter Exp $ + * $IdPath: yasm/libyasm/expr.h,v 1.40 2003/05/04 20:28:28 peter Exp $ * * Copyright (C) 2001 Michael Urman, Peter Johnson * @@ -131,7 +131,7 @@ typedef /*@only@*/ yasm_expr * (*yasm_expr_xform_func) * Used internally by yasm_expr__level_tree(). */ typedef struct yasm__exprhead yasm__exprhead; -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL SLIST_HEAD(yasm__exprhead, yasm__exprentry); #endif diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c index 13f9d9fe..cc11990a 100644 --- a/libyasm/floatnum.c +++ b/libyasm/floatnum.c @@ -28,10 +28,11 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/floatnum.c,v 1.33 2003/03/15 05:07:48 peter Exp $"); #include +#include "coretype.h" #include "bitvect.h" #include "file.h" diff --git a/libyasm/hamt.c b/libyasm/hamt.c index e656af2c..163d27fb 100644 --- a/libyasm/hamt.c +++ b/libyasm/hamt.c @@ -31,8 +31,9 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/hamt.c,v 1.9 2003/03/15 05:07:48 peter Exp $"); +#include "coretype.h" #include "hamt.h" typedef struct HAMTEntry { diff --git a/libyasm/intnum.c b/libyasm/intnum.c index 81b46d59..91462a44 100644 --- a/libyasm/intnum.c +++ b/libyasm/intnum.c @@ -26,10 +26,11 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/intnum.c,v 1.25 2003/03/17 00:03:02 peter Exp $"); #include +#include "coretype.h" #include "bitvect.h" #include "file.h" diff --git a/libyasm/linemgr.c b/libyasm/linemgr.c index 1983ad6d..b867fb76 100644 --- a/libyasm/linemgr.c +++ b/libyasm/linemgr.c @@ -26,8 +26,9 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/linemgr.c,v 1.33 2003/03/16 23:52:23 peter Exp $"); +#include "coretype.h" #include "hamt.h" #include "errwarn.h" diff --git a/libyasm/section.c b/libyasm/section.c index 0e4e4cce..3e0dd4d4 100644 --- a/libyasm/section.c +++ b/libyasm/section.c @@ -26,7 +26,10 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath: yasm/libyasm/section.c,v 1.36 2003/05/04 20:31:57 peter Exp $"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/section.c,v 1.37 2003/05/04 22:15:09 peter Exp $"); + +#include "coretype.h" +#include "valparam.h" #include "errwarn.h" #include "intnum.h" diff --git a/libyasm/symrec.c b/libyasm/symrec.c index dfadef3f..8427ff4e 100644 --- a/libyasm/symrec.c +++ b/libyasm/symrec.c @@ -26,12 +26,13 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/symrec.c,v 1.60 2003/03/15 05:07:48 peter Exp $"); #ifdef STDC_HEADERS # include #endif +#include "coretype.h" #include "hamt.h" #include "errwarn.h" diff --git a/libyasm/util.h b/libyasm/util.h deleted file mode 100644 index 71464ed2..00000000 --- a/libyasm/util.h +++ /dev/null @@ -1,285 +0,0 @@ -/** - * \file util.h - * \brief YASM utility functions. - * - * $IdPath: yasm/libyasm/util.h,v 1.50 2003/05/03 08:02:15 peter Exp $ - * - * Includes standard headers and defines prototypes for replacement functions - * if needed. This is the *only* header file which should include other - * header files! - * - * Copyright (C) 2001 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef YASM_UTIL_H -#define YASM_UTIL_H - -#ifdef YASM_LIB_INTERNAL -# define YASM_INTERNAL -# define YASM_AUTOCONF_INTERNAL -# define YASM_LIB_AC_INTERNAL -# define YASM_GETTEXT_INTERNAL -#endif - -#ifdef YASM_INTERNAL - -#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H) -# include - -/* Work around glibc's non-defining of certain things when using gcc -ansi */ -# if defined(HAVE_GNU_C_LIBRARY) && defined(__STRICT_ANSI__) -# undef __STRICT_ANSI__ -# endif -#endif - -#endif - -#include - -#ifdef YASM_INTERNAL - -#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H) -# include -#endif - -#if !defined(lint) && !defined(NDEBUG) -# define NDEBUG -#endif - -#ifdef YASM_AUTOCONF_INTERNAL - -# ifdef STDC_HEADERS -# include -# include -# include -# include -# endif - -# ifdef YASM_GETTEXT_INTERNAL -# if defined(lint) -# define _(String) String -# else -# ifdef HAVE_LOCALE_H -# include -# endif - -# ifdef ENABLE_NLS -# include -# define _(String) gettext(String) -# else -# define gettext(Msgid) (Msgid) -# define dgettext(Domainname, Msgid) (Msgid) -# define dcgettext(Domainname, Msgid, Category) (Msgid) -# define textdomain(Domainname) while (0) /* nothing */ -# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ -# define _(String) (String) -# endif -# endif - -# ifdef gettext_noop -# define N_(String) gettext_noop(String) -# else -# define N_(String) (String) -# endif - -# endif /*YASM_GETTEXT_INTERNAL*/ - -#endif /*YASM_AUTOCONF_INTERNAL*/ - -/** Sort an array using merge sort algorithm. - * \internal - * \param base base of array - * \param nmemb number of elements in array - * \param size size of each array element - * \param compar element comparison function - */ -int yasm__mergesort(void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *)); - -#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_MERGESORT) -#define yasm__mergesort(a, b, c, d) mergesort(a, b, c, d) -#endif - -/** Separate string by delimiters. - * \internal - * \param stringp string - * \param delim set of 1 or more delimiters - * \return First/next substring. - */ -/*@null@*/ char *yasm__strsep(char **stringp, const char *delim); - -#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_STRSEP) -#define yasm__strsep(a, b) strsep(a, b) -#endif - -/** Compare two strings, ignoring case differences. - * \internal - * \param s1 string 1 - * \param s2 string 2 - * \return 0 if strings are equal, -1 if s1s2. - */ -int yasm__strcasecmp(const char *s1, const char *s2); - -/** Compare portion of two strings, ignoring case differences. - * \internal - * \param s1 string 1 - * \param s2 string 2 - * \param n maximum number of characters to compare - * \return 0 if strings are equal, -1 if s1s2. - */ -int yasm__strncasecmp(const char *s1, const char *s2, size_t n); - -#ifdef YASM_AUTOCONF_INTERNAL - -#ifdef HAVE_STRCASECMP -# define yasm__strcasecmp(x, y) strcasecmp(x, y) -# define yasm__strncasecmp(x, y, n) strncasecmp(x, y, n) -#elif HAVE_STRICMP -# define yasm__strcasecmp(x, y) stricmp(x, y) -# define yasm__strncasecmp(x, y, n) strnicmp(x, y, n) -#elif HAVE_STRCMPI -# define yasm__strcasecmp(x, y) strcmpi(x, y) -# define yasm__strncasecmp(x, y, n) strncmpi(x, y, n) -#else -# define USE_OUR_OWN_STRCASECMP -#endif - -#if !defined(HAVE_TOASCII) || defined(lint) -# define toascii(c) ((c) & 0x7F) -#endif - -#endif /*YASM_AUTOCONF_INTERNAL*/ - -#include - -#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_SYS_CDEFS_H) -# include -#endif - -#ifdef __RCSID -# define RCSID(s) __RCSID(s) -#else -# ifdef __GNUC__ -# ifdef __ELF__ -# define RCSID(s) __asm__(".ident\t\"" s "\"") -# else -# define RCSID(s) static const char rcsid[] = s -# endif -# else -# define RCSID(s) static const char rcsid[] = s -# endif -#endif - -/** strdup() implementation using yasm_xmalloc(). - * \internal - * \param str string - * \return Newly allocated duplicate string. - */ -/*@only@*/ char *yasm__xstrdup(const char *str); - -/** strndup() implementation using yasm_xmalloc(). - * \internal - * \param str string - * \param len maximum number of characters to copy - * \return Newly allocated duplicate string. - */ -/*@only@*/ char *yasm__xstrndup(const char *str, size_t len); - -#endif /*YASM_INTERNAL*/ - -/** Error-checking memory allocation. A default implementation is provided - * that calls yasm_fatal() on allocation errors. - * A replacement should \em never return NULL. - * \param size number of bytes to allocate - * \return Allocated memory block. - */ -extern /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size); - -/** Error-checking memory allocation (with clear-to-0). A default - * implementation is provided that calls yasm_fatal() on allocation errors. - * A replacement should \em never return NULL. - * \param size number of elements to allocate - * \param elsize size (in bytes) of each element - * \return Allocated and cleared memory block. - */ -extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize); - -/** Error-checking memory reallocation. A default implementation is provided - * that calls yasm_fatal() on allocation errors. A replacement should - * \em never return NULL. - * \param oldmem memory block to resize - * \param elsize new size, in bytes - * \return Re-allocated memory block. - */ -extern /*@only@*/ void * (*yasm_xrealloc) - (/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size) - /*@modifies oldmem@*/; - -/** Error-checking memory deallocation. A default implementation is provided - * that calls yasm_fatal() on allocation errors. - * \param p memory block to free - */ -extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p) - /*@modifies p@*/; - -#ifdef YASM_INTERNAL - -#if defined(YASM_AUTOCONF_INTERNAL) && defined(WITH_DMALLOC) -# include - -#define yasm__xstrdup(str) xstrdup(str) -#define yasm_xmalloc(size) xmalloc(size) -#define yasm_xcalloc(count, size) xcalloc(count, size) -#define yasm_xrealloc(ptr, size) xrealloc(ptr, size) -#define yasm_xfree(ptr) xfree(ptr) -#endif - -/* Bit-counting: used primarily by HAMT but also in a few other places. */ -#define SK5 0x55555555 -#define SK3 0x33333333 -#define SKF0 0x0F0F0F0F -#define BitCount(d, s) do { \ - d = s; \ - d -= (d>>1) & SK5; \ - d = (d & SK3) + ((d>>2) & SK3); \ - d = (d & SKF0) + ((d>>4) & SKF0); \ - d += d>>16; \ - d += d>>8; \ - } while (0) - -#ifndef NELEMS -/** Get the number of elements in an array. - * \internal - * \param array array - * \return Number of elements. - */ -#define NELEMS(array) (sizeof(array) / sizeof(array[0])) -#endif - -#endif /*YASM_INTERNAL*/ - -#include - -#include - -#endif diff --git a/libyasm/valparam.c b/libyasm/valparam.c index 59ccfebb..b486a761 100644 --- a/libyasm/valparam.c +++ b/libyasm/valparam.c @@ -26,7 +26,10 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -/*@unused@*/ RCSID("$IdPath$"); +/*@unused@*/ RCSID("$IdPath: yasm/libyasm/valparam.c,v 1.13 2003/03/16 23:53:31 peter Exp $"); + +#include "coretype.h" +#include "valparam.h" #include "expr.h" @@ -83,7 +86,7 @@ yasm_vps_print(FILE *f, const yasm_valparamhead *headp) } } -/* Non-macro yasm_vps_initialize() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_vps_initialize() for non-YASM_LIB_INTERNAL users. */ #undef yasm_vps_initialize void yasm_vps_initialize(/*@out@*/ yasm_valparamhead *headp) @@ -91,7 +94,7 @@ yasm_vps_initialize(/*@out@*/ yasm_valparamhead *headp) STAILQ_INIT(headp); } -/* Non-macro yasm_vps_append() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_vps_append() for non-YASM_LIB_INTERNAL users. */ #undef yasm_vps_append void yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp) @@ -100,7 +103,7 @@ yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp) STAILQ_INSERT_TAIL(headp, vp, link); } -/* Non-macro yasm_vps_first() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_vps_first() for non-YASM_LIB_INTERNAL users. */ #undef yasm_vps_first /*@null@*/ /*@dependent@*/ yasm_valparam * yasm_vps_first(yasm_valparamhead *headp) @@ -108,7 +111,7 @@ yasm_vps_first(yasm_valparamhead *headp) return STAILQ_FIRST(headp); } -/* Non-macro yasm_vps_next() for non-YASM_INTERNAL users. */ +/* Non-macro yasm_vps_next() for non-YASM_LIB_INTERNAL users. */ #undef yasm_vps_next /*@null@*/ /*@dependent@*/ yasm_valparam * yasm_vps_next(yasm_valparam *cur) diff --git a/libyasm/valparam.h b/libyasm/valparam.h index d97c8980..1fc6793d 100644 --- a/libyasm/valparam.h +++ b/libyasm/valparam.h @@ -2,7 +2,7 @@ * \file valparam.h * \brief YASM Value/Parameter type interface. * - * $IdPath: yasm/libyasm/valparam.h,v 1.12 2003/03/16 23:53:31 peter Exp $ + * $IdPath: yasm/libyasm/valparam.h,v 1.13 2003/05/04 20:28:28 peter Exp $ * * Copyright (C) 2001 Peter Johnson * @@ -30,7 +30,7 @@ #ifndef YASM_VALPARAM_H #define YASM_VALPARAM_H -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL /** Value/parameter pair. \internal */ struct yasm_valparam { /*@reldef@*/ STAILQ_ENTRY(yasm_valparam) link; /**< Next pair in list */ @@ -53,7 +53,7 @@ yasm_valparam *yasm_vp_new(/*@keep@*/ char *v, /*@keep@*/ yasm_expr *p); * \param headp linked list */ void yasm_vps_initialize(/*@out@*/ yasm_valparamhead *headp); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #define yasm_vps_initialize(headp) STAILQ_INIT(headp) #endif @@ -67,7 +67,7 @@ void yasm_vps_delete(yasm_valparamhead *headp); * \param vp valparam */ void yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #define yasm_vps_append(headp, vp) do { \ if (vp) \ STAILQ_INSERT_TAIL(headp, vp, link); \ @@ -80,7 +80,7 @@ void yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp); */ /*@null@*/ /*@dependent@*/ yasm_valparam *yasm_vps_first (yasm_valparamhead *headp); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #define yasm_vps_first(headp) STAILQ_FIRST(headp) #endif @@ -89,7 +89,7 @@ void yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp); * \return Next valparam in linked list. */ /*@null@*/ /*@dependent@*/ yasm_valparam *yasm_vps_next(yasm_valparam *cur); -#ifdef YASM_INTERNAL +#ifdef YASM_LIB_INTERNAL #define yasm_vps_next(cur) STAILQ_NEXT(cur, link) /** Iterate through linked list of valparams. diff --git a/libyasm/xmalloc.c b/libyasm/xmalloc.c index 188b5508..24e84777 100644 --- a/libyasm/xmalloc.c +++ b/libyasm/xmalloc.c @@ -26,8 +26,9 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -RCSID("$IdPath$"); +RCSID("$IdPath: yasm/libyasm/xmalloc.c,v 1.13 2003/03/15 05:07:48 peter Exp $"); +#include "coretype.h" #include "errwarn.h" diff --git a/libyasm/xstrdup.c b/libyasm/xstrdup.c index 6395a351..b4159348 100644 --- a/libyasm/xstrdup.c +++ b/libyasm/xstrdup.c @@ -30,8 +30,9 @@ */ #define YASM_LIB_INTERNAL #include "util.h" -RCSID("$IdPath$"); +RCSID("$IdPath: yasm/libyasm/xstrdup.c,v 1.13 2003/03/15 05:07:48 peter Exp $"); +#include "coretype.h" #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; diff --git a/modules/arch/x86/x86arch.c b/modules/arch/x86/x86arch.c index b590bbe1..2dffc56f 100644 --- a/modules/arch/x86/x86arch.c +++ b/modules/arch/x86/x86arch.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/arch/x86/x86arch.c,v 1.23 2003/03/31 05:36:29 peter Exp $"); + #define YASM_LIB_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); #include "x86arch.h" diff --git a/modules/arch/x86/x86bc.c b/modules/arch/x86/x86bc.c index ff78ba0e..a40312ba 100644 --- a/modules/arch/x86/x86bc.c +++ b/modules/arch/x86/x86bc.c @@ -24,10 +24,12 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/arch/x86/x86bc.c,v 1.52 2003/03/26 05:07:55 peter Exp $"); + #define YASM_LIB_INTERNAL #define YASM_BC_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); #include "x86arch.h" diff --git a/modules/arch/x86/x86expr.c b/modules/arch/x86/x86expr.c index 1cd0a275..e5288344 100644 --- a/modules/arch/x86/x86expr.c +++ b/modules/arch/x86/x86expr.c @@ -24,10 +24,12 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/arch/x86/x86expr.c,v 1.54 2003/03/26 05:07:55 peter Exp $"); + #define YASM_LIB_INTERNAL #define YASM_EXPR_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); #include "x86arch.h" diff --git a/modules/arch/x86/x86id.re b/modules/arch/x86/x86id.re index 78c4b21c..cd10684a 100644 --- a/modules/arch/x86/x86id.re +++ b/modules/arch/x86/x86id.re @@ -24,11 +24,13 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +RCSID("$IdPath: yasm/modules/arch/x86/x86id.re,v 1.46 2003/03/31 05:36:29 peter Exp $"); + #define YASM_LIB_INTERNAL #define YASM_BC_INTERNAL #define YASM_EXPR_INTERNAL #include -RCSID("$IdPath$"); #include "modules/arch/x86/x86arch.h" diff --git a/modules/dbgfmts/null/null-dbgfmt.c b/modules/dbgfmts/null/null-dbgfmt.c index a3b6b9b3..9c0d9d6f 100644 --- a/modules/dbgfmts/null/null-dbgfmt.c +++ b/modules/dbgfmts/null/null-dbgfmt.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/dbgfmts/null/null-dbgfmt.c,v 1.8 2003/03/26 05:07:56 peter Exp $"); + #define YASM_LIB_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); /* Define dbgfmt structure -- see dbgfmt.h for details */ diff --git a/modules/objfmts/bin/bin-objfmt.c b/modules/objfmts/bin/bin-objfmt.c index 23d57b7f..cf3e8e91 100644 --- a/modules/objfmts/bin/bin-objfmt.c +++ b/modules/objfmts/bin/bin-objfmt.c @@ -24,11 +24,13 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/objfmts/bin/bin-objfmt.c,v 1.39 2003/03/26 05:07:56 peter Exp $"); + #define YASM_LIB_INTERNAL #define YASM_BC_INTERNAL #define YASM_EXPR_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); #define REGULAR_OUTBUF_SIZE 1024 diff --git a/modules/objfmts/coff/coff-objfmt.c b/modules/objfmts/coff/coff-objfmt.c index 2095a4d6..a6bc68c9 100644 --- a/modules/objfmts/coff/coff-objfmt.c +++ b/modules/objfmts/coff/coff-objfmt.c @@ -24,11 +24,13 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/objfmts/coff/coff-objfmt.c,v 1.19 2003/03/26 05:07:56 peter Exp $"); + #define YASM_LIB_INTERNAL #define YASM_BC_INTERNAL #define YASM_EXPR_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); #define REGULAR_OUTBUF_SIZE 1024 diff --git a/modules/objfmts/dbg/dbg-objfmt.c b/modules/objfmts/dbg/dbg-objfmt.c index dbdf5a32..c9cddec7 100644 --- a/modules/objfmts/dbg/dbg-objfmt.c +++ b/modules/objfmts/dbg/dbg-objfmt.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/objfmts/dbg/dbg-objfmt.c,v 1.34 2003/03/26 05:07:57 peter Exp $"); + #define YASM_LIB_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); yasm_objfmt yasm_dbg_LTX_objfmt; diff --git a/modules/objfmts/elf/elf32.c b/modules/objfmts/elf/elf32.c index 3472d6a7..318be1cd 100644 --- a/modules/objfmts/elf/elf32.c +++ b/modules/objfmts/elf/elf32.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/objfmts/elf/elf32.c,v 1.2 2003/03/28 07:06:46 peter Exp $"); + #define YASM_LIB_INTERNAL -#include "libyasm.h" -/*@unused@*/ RCSID("$IdPath$"); +#include #include "elf32.h" diff --git a/modules/optimizers/basic/basic-optimizer.c b/modules/optimizers/basic/basic-optimizer.c index ff47e175..12f9ded6 100644 --- a/modules/optimizers/basic/basic-optimizer.c +++ b/modules/optimizers/basic/basic-optimizer.c @@ -24,10 +24,12 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/optimizers/basic/basic-optimizer.c,v 1.33 2003/03/26 05:07:57 peter Exp $"); + #define YASM_LIB_INTERNAL #define YASM_BC_INTERNAL #include -/*@unused@*/ RCSID("$IdPath$"); #define SECTFLAG_NONE 0UL diff --git a/modules/parsers/nasm/nasm-bison.y b/modules/parsers/nasm/nasm-bison.y index 1ac2a7af..293f0c3e 100644 --- a/modules/parsers/nasm/nasm-bison.y +++ b/modules/parsers/nasm/nasm-bison.y @@ -25,10 +25,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ %{ +#include +RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-bison.y,v 1.93 2003/05/04 22:15:09 peter Exp $"); + #define YASM_LIB_INTERNAL #define YASM_EXPR_INTERNAL #include -RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-bison.y,v 1.92 2003/03/31 05:36:30 peter Exp $"); #ifdef STDC_HEADERS # include diff --git a/modules/parsers/nasm/nasm-parser.c b/modules/parsers/nasm/nasm-parser.c index 1b5035e3..8343750e 100644 --- a/modules/parsers/nasm/nasm-parser.c +++ b/modules/parsers/nasm/nasm-parser.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-parser.c,v 1.34 2003/05/04 22:15:09 peter Exp $"); + #define YASM_LIB_INTERNAL #include -/*@unused@*/ RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-parser.c,v 1.33 2003/04/01 07:26:33 peter Exp $"); #include "nasm-parser.h" diff --git a/modules/parsers/nasm/nasm-token.re b/modules/parsers/nasm/nasm-token.re index 42b9bdcd..81f1759a 100644 --- a/modules/parsers/nasm/nasm-token.re +++ b/modules/parsers/nasm/nasm-token.re @@ -26,9 +26,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-token.re,v 1.20 2003/03/31 05:36:30 peter Exp $"); + #define YASM_LIB_INTERNAL #include -RCSID("$IdPath$"); #include "modules/parsers/nasm/nasm-parser.h" #include "modules/parsers/nasm/nasm-defs.h" diff --git a/modules/preprocs/nasm/nasm-eval.c b/modules/preprocs/nasm/nasm-eval.c index 0a237dfe..eb1cea83 100644 --- a/modules/preprocs/nasm/nasm-eval.c +++ b/modules/preprocs/nasm/nasm-eval.c @@ -7,8 +7,8 @@ * * initial version 27/iii/95 by Simon Tatham */ -#define YASM_LIB_INTERNAL -#include "libyasm/util.h" +#include +#include #include #include "nasm.h" diff --git a/modules/preprocs/nasm/nasm-pp.c b/modules/preprocs/nasm/nasm-pp.c index 012531d5..7c40bc38 100644 --- a/modules/preprocs/nasm/nasm-pp.c +++ b/modules/preprocs/nasm/nasm-pp.c @@ -33,8 +33,8 @@ * * detoken is used to convert the line back to text */ -#define YASM_LIB_INTERNAL -#include "libyasm/util.h" +#include +#include #include #include #include diff --git a/modules/preprocs/nasm/nasm-preproc.c b/modules/preprocs/nasm/nasm-preproc.c index eda59b21..2ad8e50d 100644 --- a/modules/preprocs/nasm/nasm-preproc.c +++ b/modules/preprocs/nasm/nasm-preproc.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/preprocs/nasm/nasm-preproc.c,v 1.8 2003/04/01 04:06:47 mu Exp $"); + #define YASM_LIB_INTERNAL -#include "libyasm.h" -/*@unused@*/ RCSID("$IdPath$"); +#include #include "nasm.h" #include "nasmlib.h" diff --git a/modules/preprocs/nasm/nasmlib.c b/modules/preprocs/nasm/nasmlib.c index d74d053f..b8d4281e 100644 --- a/modules/preprocs/nasm/nasmlib.c +++ b/modules/preprocs/nasm/nasmlib.c @@ -5,8 +5,8 @@ * redistributable under the licence given in the file "Licence" * distributed in the NASM archive. */ -#define YASM_LIB_INTERNAL -#include "libyasm/util.h" +#include +#include #include #include "nasm.h" diff --git a/modules/preprocs/raw/raw-preproc.c b/modules/preprocs/raw/raw-preproc.c index e971b5f2..4319e7fc 100644 --- a/modules/preprocs/raw/raw-preproc.c +++ b/modules/preprocs/raw/raw-preproc.c @@ -24,9 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/preprocs/raw/raw-preproc.c,v 1.23 2003/04/01 04:06:47 mu Exp $"); + #define YASM_LIB_INTERNAL -#include "libyasm.h" -/*@unused@*/ RCSID("$IdPath$"); +#include static int is_interactive; diff --git a/modules/preprocs/yapp/yapp-preproc.c b/modules/preprocs/yapp/yapp-preproc.c index 68e154e4..e8e647c0 100644 --- a/modules/preprocs/yapp/yapp-preproc.c +++ b/modules/preprocs/yapp/yapp-preproc.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* $IdPath: yasm/modules/preprocs/yapp/yapp-preproc.c,v 1.23 2003/03/17 00:03:02 peter Exp $ * YAPP preprocessor (mimics NASM's preprocessor) * * Copyright (C) 2001 Michael Urman @@ -19,9 +19,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +/*@unused@*/ RCSID("$IdPath: yasm/modules/preprocs/yapp/yapp-preproc.c,v 1.23 2003/03/17 00:03:02 peter Exp $"); + #define YASM_LIB_INTERNAL -#include "libyasm.h" -/*@unused@*/ RCSID("$IdPath$"); +#include #include "yapp-preproc.h" #include "yapp-token.h" diff --git a/util.h b/util.h index 71464ed2..3e6ff1c4 100644 --- a/util.h +++ b/util.h @@ -1,21 +1,17 @@ -/** - * \file util.h - * \brief YASM utility functions. - * - * $IdPath: yasm/libyasm/util.h,v 1.50 2003/05/03 08:02:15 peter Exp $ +/* $IdPath: yasm/util.h,v 1.51 2003/05/04 20:28:28 peter Exp $ + * YASM utility functions. * * Includes standard headers and defines prototypes for replacement functions - * if needed. This is the *only* header file which should include other - * header files! + * if needed. * * Copyright (C) 2001 Peter Johnson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * - Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * @@ -34,123 +30,61 @@ #ifndef YASM_UTIL_H #define YASM_UTIL_H -#ifdef YASM_LIB_INTERNAL -# define YASM_INTERNAL -# define YASM_AUTOCONF_INTERNAL -# define YASM_LIB_AC_INTERNAL -# define YASM_GETTEXT_INTERNAL -#endif - -#ifdef YASM_INTERNAL - -#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H) -# include +#include /* Work around glibc's non-defining of certain things when using gcc -ansi */ -# if defined(HAVE_GNU_C_LIBRARY) && defined(__STRICT_ANSI__) -# undef __STRICT_ANSI__ -# endif +#if defined(HAVE_GNU_C_LIBRARY) && defined(__STRICT_ANSI__) +# undef __STRICT_ANSI__ #endif +#if !defined(lint) && !defined(NDEBUG) +# define NDEBUG #endif #include +#include -#ifdef YASM_INTERNAL - -#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H) -# include +#ifdef STDC_HEADERS +# include +# include +# include +# include #endif -#if !defined(lint) && !defined(NDEBUG) -# define NDEBUG -#endif - -#ifdef YASM_AUTOCONF_INTERNAL - -# ifdef STDC_HEADERS -# include -# include -# include -# include +#ifdef lint +# define _(String) String +#else +# ifdef HAVE_LOCALE_H +# include # endif -# ifdef YASM_GETTEXT_INTERNAL -# if defined(lint) -# define _(String) String -# else -# ifdef HAVE_LOCALE_H -# include -# endif - -# ifdef ENABLE_NLS -# include -# define _(String) gettext(String) -# else -# define gettext(Msgid) (Msgid) -# define dgettext(Domainname, Msgid) (Msgid) -# define dcgettext(Domainname, Msgid, Category) (Msgid) -# define textdomain(Domainname) while (0) /* nothing */ -# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ -# define _(String) (String) -# endif -# endif - -# ifdef gettext_noop -# define N_(String) gettext_noop(String) -# else -# define N_(String) (String) -# endif - -# endif /*YASM_GETTEXT_INTERNAL*/ - -#endif /*YASM_AUTOCONF_INTERNAL*/ +# ifdef ENABLE_NLS +# include +# define _(String) gettext(String) +# else +# define gettext(Msgid) (Msgid) +# define dgettext(Domainname, Msgid) (Msgid) +# define dcgettext(Domainname, Msgid, Category) (Msgid) +# define textdomain(Domainname) while (0) /* nothing */ +# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ +# define _(String) (String) +# endif +#endif -/** Sort an array using merge sort algorithm. - * \internal - * \param base base of array - * \param nmemb number of elements in array - * \param size size of each array element - * \param compar element comparison function - */ -int yasm__mergesort(void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *)); +#ifdef gettext_noop +# define N_(String) gettext_noop(String) +#else +# define N_(String) (String) +#endif -#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_MERGESORT) +#ifdef HAVE_MERGESORT #define yasm__mergesort(a, b, c, d) mergesort(a, b, c, d) #endif -/** Separate string by delimiters. - * \internal - * \param stringp string - * \param delim set of 1 or more delimiters - * \return First/next substring. - */ -/*@null@*/ char *yasm__strsep(char **stringp, const char *delim); - -#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_STRSEP) +#ifdef HAVE_STRSEP #define yasm__strsep(a, b) strsep(a, b) #endif -/** Compare two strings, ignoring case differences. - * \internal - * \param s1 string 1 - * \param s2 string 2 - * \return 0 if strings are equal, -1 if s1s2. - */ -int yasm__strcasecmp(const char *s1, const char *s2); - -/** Compare portion of two strings, ignoring case differences. - * \internal - * \param s1 string 1 - * \param s2 string 2 - * \param n maximum number of characters to compare - * \return 0 if strings are equal, -1 if s1s2. - */ -int yasm__strncasecmp(const char *s1, const char *s2, size_t n); - -#ifdef YASM_AUTOCONF_INTERNAL - #ifdef HAVE_STRCASECMP # define yasm__strcasecmp(x, y) strcasecmp(x, y) # define yasm__strncasecmp(x, y, n) strncasecmp(x, y, n) @@ -168,11 +102,9 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n); # define toascii(c) ((c) & 0x7F) #endif -#endif /*YASM_AUTOCONF_INTERNAL*/ - #include -#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_SYS_CDEFS_H) +#ifdef HAVE_SYS_CDEFS_H # include #endif @@ -190,68 +122,13 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n); # endif #endif -/** strdup() implementation using yasm_xmalloc(). - * \internal - * \param str string - * \return Newly allocated duplicate string. - */ -/*@only@*/ char *yasm__xstrdup(const char *str); - -/** strndup() implementation using yasm_xmalloc(). - * \internal - * \param str string - * \param len maximum number of characters to copy - * \return Newly allocated duplicate string. - */ -/*@only@*/ char *yasm__xstrndup(const char *str, size_t len); - -#endif /*YASM_INTERNAL*/ - -/** Error-checking memory allocation. A default implementation is provided - * that calls yasm_fatal() on allocation errors. - * A replacement should \em never return NULL. - * \param size number of bytes to allocate - * \return Allocated memory block. - */ -extern /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size); - -/** Error-checking memory allocation (with clear-to-0). A default - * implementation is provided that calls yasm_fatal() on allocation errors. - * A replacement should \em never return NULL. - * \param size number of elements to allocate - * \param elsize size (in bytes) of each element - * \return Allocated and cleared memory block. - */ -extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize); - -/** Error-checking memory reallocation. A default implementation is provided - * that calls yasm_fatal() on allocation errors. A replacement should - * \em never return NULL. - * \param oldmem memory block to resize - * \param elsize new size, in bytes - * \return Re-allocated memory block. - */ -extern /*@only@*/ void * (*yasm_xrealloc) - (/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size) - /*@modifies oldmem@*/; - -/** Error-checking memory deallocation. A default implementation is provided - * that calls yasm_fatal() on allocation errors. - * \param p memory block to free - */ -extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p) - /*@modifies p@*/; - -#ifdef YASM_INTERNAL - -#if defined(YASM_AUTOCONF_INTERNAL) && defined(WITH_DMALLOC) +#ifdef WITH_DMALLOC # include - -#define yasm__xstrdup(str) xstrdup(str) -#define yasm_xmalloc(size) xmalloc(size) -#define yasm_xcalloc(count, size) xcalloc(count, size) -#define yasm_xrealloc(ptr, size) xrealloc(ptr, size) -#define yasm_xfree(ptr) xfree(ptr) +# define yasm__xstrdup(str) xstrdup(str) +# define yasm_xmalloc(size) xmalloc(size) +# define yasm_xcalloc(count, size) xcalloc(count, size) +# define yasm_xrealloc(ptr, size) xrealloc(ptr, size) +# define yasm_xfree(ptr) xfree(ptr) #endif /* Bit-counting: used primarily by HAMT but also in a few other places. */ @@ -276,10 +153,4 @@ extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p) #define NELEMS(array) (sizeof(array) / sizeof(array[0])) #endif -#endif /*YASM_INTERNAL*/ - -#include - -#include - #endif