]> granicus.if.org Git - yasm/commitdiff
Make libyasm a "real" library, including installing header files.
authorPeter Johnson <peter@tortall.net>
Sat, 15 Mar 2003 05:07:49 +0000 (05:07 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 15 Mar 2003 05:07:49 +0000 (05:07 -0000)
Start separating modules and frontends from libyasm internals.

svn path=/trunk/yasm/; revision=849

61 files changed:
.cvsignore
Makefile.am
configure.ac
frontends/yasm/yasm-module.c
frontends/yasm/yasm-options.c
frontends/yasm/yasm.c
libltdl/Makefile.am
libyasm.h [new file with mode: 0644]
libyasm/.cvsignore [new file with mode: 0644]
libyasm/Makefile.inc
libyasm/arch.c
libyasm/arch.h
libyasm/bitvect.c
libyasm/bytecode.c
libyasm/bytecode.h
libyasm/coretype.h
libyasm/errwarn.c
libyasm/errwarn.h
libyasm/expr.c
libyasm/expr.h
libyasm/file.c
libyasm/floatnum.c
libyasm/hamt.c
libyasm/intnum.c
libyasm/linemgr.c
libyasm/mergesort.c
libyasm/section.c
libyasm/section.h
libyasm/strcasecmp.c
libyasm/strsep.c
libyasm/symrec.c
libyasm/tests/Makefile.inc
libyasm/tests/bitvect_test.c
libyasm/tests/floatnum_test.c
libyasm/util.h
libyasm/valparam.c
libyasm/valparam.h
libyasm/xmalloc.c
libyasm/xstrdup.c
mergesort.c [deleted file]
modules/arch/x86/x86arch.c
modules/arch/x86/x86bc.c
modules/arch/x86/x86expr.c
modules/arch/x86/x86id.re
modules/dbgfmts/null/null-dbgfmt.c
modules/objfmts/bin/bin-objfmt.c
modules/objfmts/coff/coff-objfmt.c
modules/objfmts/dbg/dbg-objfmt.c
modules/optimizers/basic/basic-optimizer.c
modules/parsers/nasm/nasm-bison.y
modules/parsers/nasm/nasm-parser.c
modules/parsers/nasm/nasm-token.re
modules/preprocs/nasm/nasm-eval.c
modules/preprocs/nasm/nasm-pp.c
modules/preprocs/nasm/nasm-preproc.c
modules/preprocs/nasm/nasmlib.c
modules/preprocs/raw/raw-preproc.c
modules/preprocs/yapp/yapp-preproc.c
modules/preprocs/yapp/yapp-token.l
strsep.c [deleted file]
util.h

index 0ab2d20c5ee2934ee7407ce6214a00de32fb2336..66c8425640e5a62a9732bcd57cf3dd5a6415ca83 100644 (file)
@@ -2,6 +2,7 @@ autom4te.cache
 nasm-bison.c
 nasm-bison.h
 nasm-token.c
+nasm-macros.c
 yapp-token.c
 x86id.c
 re2c-parser.c
@@ -12,7 +13,6 @@ re2c
 configure
 configure.scan
 config.*
-stamp-h*
 aclocal.m4
 *.tar.gz
 *.la
index 2f56f1fddae0740b5aaccff51db7641a4cdfc3d2..a9381313896e916ae5e4c869d62f34ebe3718b3b 100644 (file)
@@ -5,7 +5,6 @@ SUBDIRS = libltdl m4 po .
 AM_YFLAGS = -d
 AM_CFLAGS = @MORE_CFLAGS@
 AM_CPPFLAGS = \
-       -I$(top_srcdir)/libyasm \
        -I$(top_srcdir)/check \
        @INCLTDL@
 
@@ -13,6 +12,8 @@ bin_PROGRAMS =
 TESTS =
 noinst_PROGRAMS =
 
+include_HEADERS = libyasm.h
+
 lib_LTLIBRARIES =
 
 YASM_MODULES = 
@@ -42,6 +43,9 @@ EXTRA_DIST += \
        Mkfiles/Makefile.dj Mkfiles/dj/config.h \
        Mkfiles/Makefile.vc Mkfiles/vc/config.h
 
+# Until this gets fixed in automake
+DISTCLEANFILES = libyasm/stamp-h libyasm/stamp-h[0-9]*
+
 ACLOCAL_AMFLAGS = -I m4
 
 distclean-local:
index 84890fc8a16bed00c3390940113b093ebb3ccd87..0da96af65a160040ec9bf8f19791fe84c385540c 100644 (file)
@@ -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([config.h])
+AM_CONFIG_HEADER([libyasm/config.h])
 
 AM_INIT_AUTOMAKE(yasm, `date "+%Y%m%d"`)
 AM_MAINTAINER_MODE
@@ -115,11 +115,11 @@ AC_FUNC_FORK
 AC_FUNC_MALLOC
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([abort memcpy memmove strrchr toascii vsnprintf])
+AC_CHECK_FUNCS([strsep mergesort])
 # Look for the case-insensitive comparison functions
 AC_CHECK_FUNCS([strcasecmp strncasecmp stricmp strcmpi])
 # Check for stuff wanted by the test suite.  None of this is required.
 AC_CHECK_FUNCS([msgctl msgget msgrcv msgsnd strerror snprintf wait])
-AC_REPLACE_FUNCS([strsep mergesort])
 AC_LIB_LTDL
 
 #
@@ -242,12 +242,6 @@ AC_SUBST(MORE_CFLAGS)
 AC_SUBST(INCLTDL)
 AC_SUBST(LIBLTDL)
 
-# Create LTLIBOBJS
-Xsed="sed -e s/^X//"
-LTLIBOBJS=`echo X"$LIB@&t@OBJS"|\
-       [$Xsed -e 's,\.[^.]* ,.lo ,g;s,\.[^.]*$,.lo,']`
-AC_SUBST(LTLIBOBJS)
-
 AC_CONFIG_FILES([Makefile
        libltdl/Makefile
        m4/Makefile
index de2c3c5f53f0307403765dfc15b689c5228caaa9..432b23582f29d03a617f2c32ad834a15152c5349 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
 #include "ltdl.h"
 
 #include "yasm-module.h"
-#include "objfmt.h"
-#include "parser.h"
 
 
 typedef struct module {
index b8e18f3315fe50d0a83a0ab059a35f180acfa04e..fd8ba56019324996e12377de1aa9fe6c2d8c3a5c 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
 #include "yasm-options.h"
-#include "errwarn.h"
 
 
 #ifdef __DEBUG__
index 308bea0a404c80efb7a964ee912fa3b3d17b09e3..2f45ac17de3b3a230a07d5b54a5fe9203cd28629 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
 #include "ltdl.h"
 #include "yasm-module.h"
-
-#include "bitvect.h"
-#include "file.h"
-
 #include "yasm-options.h"
-#include "linemgr.h"
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-#include "section.h"
-#include "objfmt.h"
-#include "dbgfmt.h"
-#include "preproc.h"
-#include "parser.h"
-#include "optimizer.h"
-
-#include "arch.h"
 
 
 /* Extra path to search for our modules. */
index 7f014e5a4d0b16058649c7e23501537ad9c0bf46..c471a20eb85a78e2a2d22120a7ad63607c6aeadb 100644 (file)
@@ -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 ../config.h
+ltdl.lo: ltdl.h ../libyasm/config.h
 
 $(OBJECTS): libtool
 libtool: $(LIBTOOL_DEPS)
diff --git a/libyasm.h b/libyasm.h
new file mode 100644 (file)
index 0000000..9206f27
--- /dev/null
+++ b/libyasm.h
@@ -0,0 +1,79 @@
+/* $IdPath$
+ * Libyasm interface primary header file.
+ *
+ *  Copyright (C) 2003  Peter Johnson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * 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_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)!
+ *
+ * Additional parts may be included via YASM_*_INTERNAL inclusion flags:
+ * 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 "libyasm/util.h"
+#include "libyasm/linemgr.h"
+
+#include "libyasm/errwarn.h"
+#include "libyasm/intnum.h"
+#include "libyasm/floatnum.h"
+#include "libyasm/expr.h"
+#include "libyasm/symrec.h"
+
+#include "libyasm/bytecode.h"
+#include "libyasm/section.h"
+
+#include "libyasm/arch.h"
+#include "libyasm/dbgfmt.h"
+#include "libyasm/objfmt.h"
+#include "libyasm/optimizer.h"
+#include "libyasm/parser.h"
+#include "libyasm/preproc.h"
+
+#ifdef YASM_INTERNAL
+#ifdef YASM_BC_INTERNAL
+#include "libyasm/bc-int.h"
+#endif
+#ifdef YASM_EXPR_INTERNAL
+#include "libyasm/expr-int.h"
+#endif
+#include "libyasm/file.h"
+#include "libyasm/hamt.h"
+#include "libyasm/bitvect.h"
+#endif
+
+#endif
diff --git a/libyasm/.cvsignore b/libyasm/.cvsignore
new file mode 100644 (file)
index 0000000..aaf3458
--- /dev/null
@@ -0,0 +1,2 @@
+stamp-h*
+config.*
index ffa7dac715e695228e6b8bd076caa41b57a489d3..30254a2a5ae490cee87004ad595d4716873ffe0f 100644 (file)
@@ -3,50 +3,55 @@
 lib_LTLIBRARIES += libyasm.la
 libyasm_la_SOURCES = \
        libyasm/bytecode.c      \
+       libyasm/expr.c          \
+       libyasm/symrec.c        \
+       libyasm/file.c          \
+       libyasm/section.c       \
+       libyasm/arch.c          \
+       libyasm/intnum.c        \
+       libyasm/floatnum.c      \
+       libyasm/hamt.c          \
+       libyasm/bitvect.c       \
+       libyasm/valparam.c      \
+       libyasm/errwarn.c       \
+       libyasm/linemgr.c       \
+       libyasm/xmalloc.c       \
+       libyasm/xstrdup.c       \
+       libyasm/strcasecmp.c    \
+       libyasm/mergesort.c     \
+       libyasm/strsep.c
+libyasm_la_LDFLAGS = -no-undefined
+
+modincludedir = $(includedir)/libyasm
+modinclude_HEADERS = \
+       libyasm/util.h          \
        libyasm/bytecode.h      \
        libyasm/bc-int.h        \
        libyasm/errwarn.h       \
-       libyasm/expr.c          \
        libyasm/expr.h          \
        libyasm/expr-int.h      \
-       libyasm/symrec.c        \
        libyasm/symrec.h        \
        libyasm/linemgr.h       \
-       libyasm/util.h          \
        libyasm/coretype.h      \
-       libyasm/file.c          \
        libyasm/file.h          \
-       libyasm/section.c       \
        libyasm/section.h       \
-       libyasm/arch.c          \
        libyasm/arch.h          \
        libyasm/dbgfmt.h        \
        libyasm/objfmt.h        \
        libyasm/optimizer.h     \
        libyasm/parser.h        \
        libyasm/preproc.h       \
-       libyasm/intnum.c        \
        libyasm/intnum.h        \
-       libyasm/floatnum.c      \
        libyasm/floatnum.h      \
-       libyasm/hamt.c          \
        libyasm/hamt.h          \
-       libyasm/bitvect.c       \
        libyasm/bitvect.h       \
-       libyasm/valparam.c      \
        libyasm/valparam.h      \
-       libyasm/errwarn.c       \
-       libyasm/linemgr.c       \
-       libyasm/xmalloc.c       \
-       libyasm/xstrdup.c       \
-       libyasm/strcasecmp.c
-libyasm_la_LIBADD = @LTLIBOBJS@
-libyasm_la_LDFLAGS = -no-undefined
+       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
 
 include libyasm/tests/Makefile.inc
-
-EXTRA_libyasm_la_SOURCES = \
-       libyasm/compat-queue.h
index 03b96b85e24ba920ecd8fbc870acd8ee9d7a11b7..b117b400344682762fab50213a808472d44db96a 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
@@ -174,3 +175,27 @@ yasm_ops_print(FILE *f, int indent_level, const yasm_insn_operandhead *headp)
     STAILQ_FOREACH (cur, headp, link)
        yasm_operand_print(f, indent_level, cur);
 }
+
+/* Non-macro yasm_ops_initialize() for non-YASM_INTERNAL users. */
+#undef yasm_ops_initialize
+void
+yasm_ops_initialize(yasm_insn_operandhead *headp)
+{
+    STAILQ_INIT(headp);
+}
+
+/* Non-macro yasm_ops_first() for non-YASM_INTERNAL users. */
+#undef yasm_ops_first
+yasm_insn_operand *
+yasm_ops_first(yasm_insn_operandhead *headp)
+{
+    return STAILQ_FIRST(headp);
+}
+
+/* Non-macro yasm_ops_next() for non-YASM_INTERNAL users. */
+#undef yasm_ops_next
+yasm_insn_operand *
+yasm_ops_next(yasm_insn_operand *cur)
+{
+    return STAILQ_NEXT(cur, link);
+}
index ad99f18864b51604f24bfb3f2a433b90babf0170..eecee1901d853b4278196cf020862ca02b619ebd 100644 (file)
@@ -36,10 +36,11 @@ typedef enum yasm_arch_check_id_retval {
     YASM_ARCH_CHECK_ID_TARGETMOD       /* an target modifier (for jumps) */
 } yasm_arch_check_id_retval;
 
-typedef /*@reldef@*/ STAILQ_HEAD(yasm_insn_operandhead, yasm_insn_operand)
-       yasm_insn_operandhead;
-
 typedef struct yasm_insn_operand yasm_insn_operand;
+typedef struct yasm_insn_operandhead yasm_insn_operandhead;
+#ifdef YASM_INTERNAL
+/*@reldef@*/ STAILQ_HEAD(yasm_insn_operandhead, yasm_insn_operand);
+#endif
 
 /* Different assemblers order instruction operands differently.  Also, some
  * differ on how exactly various registers are specified.  There's no great
@@ -180,6 +181,7 @@ struct yasm_arch {
     void (*ea_data_print) (FILE *f, int indent_level, const yasm_effaddr *ea);
 };
 
+#ifdef YASM_INTERNAL
 struct yasm_insn_operand {
     /*@reldef@*/ STAILQ_ENTRY(yasm_insn_operand) link;
 
@@ -201,6 +203,7 @@ struct yasm_insn_operand {
     /* Specified size of the operand, in bytes.  0 if not user-specified. */
     unsigned int size;
 };
+#endif
 
 void yasm_arch_common_initialize(yasm_arch *a);
 
@@ -215,9 +218,14 @@ yasm_insn_operand *yasm_operand_new_imm(/*@only@*/ yasm_expr *val);
 void yasm_operand_print(FILE *f, int indent_level,
                        const yasm_insn_operand *op);
 
+void yasm_ops_initialize(yasm_insn_operandhead *headp);
+yasm_insn_operand *yasm_ops_first(yasm_insn_operandhead *headp);
+yasm_insn_operand *yasm_ops_next(yasm_insn_operand *cur);
+#ifdef YASM_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)
+#endif
 
 /* Deletes operands linked list.  Deletes content of each operand if content i
  * nonzero.
index bd2a85e762e950892f71aefda9eb8cb1bc9783f9..533e68c5d667a069e706a546eb84ff3e77278ea3 100644 (file)
@@ -1,3 +1,4 @@
+#define YASM_LIB_INTERNAL
 #include "util.h"
 RCSID("$IdPath$");
 
index aa1815a3a2f35583527a99bfbf751c353d32b287..808677e77111b3b4549ad6c9877657b91aee6a5c 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
@@ -983,3 +984,27 @@ yasm_dvs_print(FILE *f, int indent_level, const yasm_datavalhead *head)
        }
     }
 }
+
+/* Non-macro yasm_bcs_initialize() for non-YASM_INTERNAL users. */
+#undef yasm_bcs_initialize
+void
+yasm_bcs_initialize(yasm_bytecodehead *headp)
+{
+    STAILQ_INIT(headp);
+}
+
+/* Non-macro yasm_bcs_first() for non-YASM_INTERNAL users. */
+#undef yasm_bcs_first
+yasm_bytecode *
+yasm_bcs_first(yasm_bytecodehead *headp)
+{
+    return STAILQ_FIRST(headp);
+}
+
+/* Non-macro yasm_dvs_initialize() for non-YASM_INTERNAL users. */
+#undef yasm_dvs_initialize
+void
+yasm_dvs_initialize(yasm_datavalhead *headp)
+{
+    STAILQ_INIT(headp);
+}
index 0e64920edbd304717c68701341e12389f908439c..276633d576561201a9b05f9acc953e02d28efc36 100644 (file)
 
 typedef struct yasm_effaddr yasm_effaddr;
 typedef struct yasm_immval yasm_immval;
-typedef /*@reldef@*/ STAILQ_HEAD(yasm_datavalhead, yasm_dataval)
-    yasm_datavalhead;
 typedef struct yasm_dataval yasm_dataval;
+typedef struct yasm_datavalhead yasm_datavalhead;
+
+#ifdef YASM_INTERNAL
+/*@reldef@*/ STAILQ_HEAD(yasm_bytecodehead, yasm_bytecode);
+/*@reldef@*/ STAILQ_HEAD(yasm_datavalhead, yasm_dataval);
 
 /* Additional types may be architecture-defined starting at
  * YASM_BYTECODE_TYPE_BASE.
@@ -45,6 +48,7 @@ typedef enum {
     YASM_BC__OBJFMT_DATA
 } yasm_bytecode_type;
 #define YASM_BYTECODE_TYPE_BASE                YASM_BC__OBJFMT_DATA+1
+#endif
 
 void yasm_bc_initialize(yasm_arch *a);
 
@@ -142,11 +146,15 @@ yasm_bc_resolve_flags yasm_bc_resolve(yasm_bytecode *bc, int save,
      /*@null@*/ yasm_output_bc_objfmt_data_func output_bc_objfmt_data)
     /*@sets *buf@*/;
 
-/* void yasm_bcs_initialize(yasm_bytecodehead *headp); */
+void yasm_bcs_initialize(yasm_bytecodehead *headp);
+#ifdef YASM_INTERNAL
 #define        yasm_bcs_initialize(headp)      STAILQ_INIT(headp)
+#endif
 
-/* yasm_bytecode *yasm_bcs_first(yasm_bytecodehead *headp); */
+yasm_bytecode *yasm_bcs_first(yasm_bytecodehead *headp);
+#ifdef YASM_INTERNAL
 #define yasm_bcs_first(headp)  STAILQ_FIRST(headp)
+#endif
 
 /*@null@*/ yasm_bytecode *yasm_bcs_last(yasm_bytecodehead *headp);
 void yasm_bcs_delete(yasm_bytecodehead *headp);
@@ -176,8 +184,10 @@ yasm_dataval *yasm_dv_new_expr(/*@keep@*/ yasm_expr *expn);
 yasm_dataval *yasm_dv_new_float(/*@keep@*/ yasm_floatnum *flt);
 yasm_dataval *yasm_dv_new_string(/*@keep@*/ char *str_val);
 
-/* void yasm_dvs_initialize(yasm_datavalhead *headp); */
+void yasm_dvs_initialize(yasm_datavalhead *headp);
+#ifdef YASM_INTERNAL
 #define        yasm_dvs_initialize(headp)      STAILQ_INIT(headp)
+#endif
 
 void yasm_dvs_delete(yasm_datavalhead *headp);
 
index 86ea58b482ff6ec7bf5339eccf7cff6fc6ca055f..75d9f88da55c49e998251d439522991b3a1f5e4d 100644 (file)
@@ -36,12 +36,10 @@ typedef struct yasm_objfmt yasm_objfmt;
 typedef struct yasm_dbgfmt yasm_dbgfmt;
 
 typedef struct yasm_bytecode yasm_bytecode;
-typedef /*@reldef@*/ STAILQ_HEAD(yasm_bytecodehead, yasm_bytecode)
-    yasm_bytecodehead;
+typedef struct yasm_bytecodehead yasm_bytecodehead;
 
 typedef struct yasm_section yasm_section;
-typedef /*@reldef@*/ STAILQ_HEAD(yasm_sectionhead, yasm_section)
-    yasm_sectionhead;
+typedef struct yasm_sectionhead yasm_sectionhead;
 
 typedef struct yasm_symrec yasm_symrec;
 
@@ -51,6 +49,9 @@ typedef struct yasm_floatnum yasm_floatnum;
 
 typedef struct yasm_linemgr yasm_linemgr;
 
+typedef struct yasm_valparam yasm_valparam;
+typedef struct yasm_valparamhead yasm_valparamhead;
+
 typedef enum {
     YASM_EXPR_ADD,
     YASM_EXPR_SUB,
index 9909a40313496d2f14e86b82fdd034267650dad1..ac30639cc97b6e620a0d49ff9b4a7a015fd3d28e 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index 4e312522407008442848e361d06c35ce2e1304f8..dd46adc8934481ef292edf531becb6f558d184da 100644 (file)
@@ -54,6 +54,8 @@ extern /*@exits@*/ void (*yasm_internal_error_)
  */
 extern /*@exits@*/ void (*yasm_fatal) (const char *message);
 
+#ifdef YASM_INTERNAL
+
 /* va_list versions of the below two functions */
 void yasm__error_va(unsigned long lindex, const char *, va_list va);
 void yasm__warning_va(yasm_warn_class, unsigned long lindex, const char *,
@@ -68,6 +70,8 @@ void yasm__warning(yasm_warn_class, unsigned long lindex, const char *, ...)
  */
 void yasm__parser_error(unsigned long lindex, const char *);
 
+#endif
+
 /* Enables/disables a class of warnings. */
 void yasm_warn_enable(yasm_warn_class);
 void yasm_warn_disable(yasm_warn_class);
@@ -85,8 +89,10 @@ void yasm_errwarn_output_all
      void (*print_warning) (const char *fn, unsigned long line,
                            const char *msg));
 
+#ifdef YASM_INTERNAL
 /* Convert a possibly unprintable character into a printable string. */
 char *yasm__conv_unprint(char ch);
+#endif
 
 /* Map to gettext() if gettext is being used. */
 extern const char * (*yasm_gettext_hook) (const char *msgid);
index 7fd8c948d17491a8fd93de00ed0e5322c79ac0eb..fe12010022c334d8e81ab00a0df72233fca3e43f 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index b65cb0432e31332a9f452dd11cd2187f4c0e67c0..674135da66fbf4824e1c8d230be37d3101888fc7 100644 (file)
@@ -62,7 +62,11 @@ void yasm_expr_delete(/*@only@*/ /*@null@*/ yasm_expr *e);
 typedef /*@only@*/ yasm_expr * (*yasm_expr_xform_func)
     (/*@returned@*/ /*@only@*/ yasm_expr *e, /*@null@*/ void *d);
 
-typedef SLIST_HEAD(yasm__exprhead, yasm__exprentry) yasm__exprhead;
+typedef struct yasm__exprhead yasm__exprhead;
+#ifdef YASM_INTERNAL
+SLIST_HEAD(yasm__exprhead, yasm__exprentry);
+#endif
+
 /* Level an entire expn tree.  Call with eh = NULL */
 /*@only@*/ /*@null@*/ yasm_expr *yasm_expr__level_tree
     (/*@returned@*/ /*@only@*/ /*@null@*/ yasm_expr *e, int fold_const,
index 46906b2287bd2858d0ef61ff1ab3598ab395382b..162dcfdc149efa209ca69422c88e324b5f49da32 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index bb744e72d517181beddc8425b51050962c83b492..13f9d9febfe37d67cadc0e751354ef1cc40ceb53 100644 (file)
@@ -26,6 +26,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index 69e142a9761feebf62bb30834cd9559b00b1e6d7..e656af2cf115ea1ee9ec9ad273ec3f456f6bbca8 100644 (file)
@@ -29,6 +29,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index ea97fcb38915f96068b4142c7488c87df0298d94..26312a48f33ddf171493f5ff50257e137e56f277 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index 02507849cb1196044ae723f2b14ab00ffcd0b1a5..df6beac2f167dadf52c4ae9356346bc8cc6c1e17 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index 3ec4b80ed9f2dd7eb0813bafb68afa0eef7c0df0..6014389bffe07831e3b0406dc2a0191384eda3ee 100644 (file)
@@ -31,6 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+#define YASM_LIB_INTERNAL
 #include "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
 static char sccsid[] = "@(#)merge.c    8.2 (Berkeley) 2/14/94";
 #endif /* LIBC_SCCS and not lint */
 
+#ifdef HAVE_MERGESORT
+#undef yasm__mergesort
+#endif
+
+#ifndef HAVE_MERGESORT
 /*
  * Hybrid exponential search/linear search merge sort with hybrid
  * natural/pairwise first pass.  Requires about .3% more comparisons
@@ -91,14 +97,18 @@ static void insertionsort(unsigned char *, size_t, size_t,
 #define EVAL(p) (unsigned char **)                                             \
        ((unsigned char *)0 +                                                   \
            (((unsigned char *)p + PSIZE - 1 - (unsigned char *) 0) & ~(PSIZE - 1)))
+#endif /*HAVE_MERGESORT*/
 
 /*
  * Arguments are as for qsort.
  */
 int
-mergesort(void *base, size_t nmemb, size_t size,
-         int (*cmp)(const void *, const void *))
+yasm__mergesort(void *base, size_t nmemb, size_t size,
+               int (*cmp)(const void *, const void *))
 {
+#ifdef HAVE_MERGESORT
+    return mergesort(base, nmemb, size, cmp);
+#else
        size_t i;
        int sense;
        int big, iflag;
@@ -232,8 +242,11 @@ COPY:                              b = t;
        }
        xfree(list2);
        return (0);
+#endif /*HAVE_MERGESORT*/
 }
 
+#ifndef HAVE_MERGESORT
+
 #define        swap(a, b) {                                    \
                s = b;                                  \
                i = size;                               \
@@ -348,3 +361,4 @@ insertionsort(unsigned char *a, size_t n, size_t size,
                        swap(u, t);
                }
 }
+#endif /*HAVE_MERGESORT*/
index 861eb045503447f755ac63242ef8bc084ea825a5..d260671e094f90497954febf009379b8d16880e0 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
@@ -73,7 +74,7 @@ yasm_sections_initialize(yasm_sectionhead *headp, yasm_objfmt *of)
     STAILQ_INIT(headp);
 
     /* Add an initial "default" section */
-    yasm_vp_new(vp, yasm__xstrdup(of->default_section_name), NULL);
+    vp = yasm_vp_new(yasm__xstrdup(of->default_section_name), NULL);
     yasm_vps_initialize(&vps);
     yasm_vps_append(&vps, vp);
     s = of->sections_switch(headp, &vps, NULL, 0);
index ffef79eea1d47605c7c62c26e6f9161c9ae87dcd..7f351fb6c1925b73727fefb31b81ed3880f0d94a 100644 (file)
 #ifndef YASM_SECTION_H
 #define YASM_SECTION_H
 
+#ifdef YASM_INTERNAL
+/*@reldef@*/ STAILQ_HEAD(yasm_sectionhead, yasm_section);
+#endif
+
 /*@dependent@*/ yasm_section *yasm_sections_initialize(yasm_sectionhead *headp,
                                                       yasm_objfmt *of);
 
index a7b2a927ba058388e59f8b4a7c52bdf261ace788..7ef5df3515227139cf20487e4e6f53aab3434f90 100644 (file)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+#define YASM_LIB_INTERNAL
 #include "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
 
-#ifdef USE_OUR_OWN_STRCASECMP
+#ifndef USE_OUR_OWN_STRCASECMP
+#undef yasm__strcasecmp
+#undef yasm__strncasecmp
+#endif
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)strcasecmp.c       8.1 (Berkeley) 6/4/93";
@@ -44,6 +48,13 @@ static char sccsid[] = "@(#)strcasecmp.c     8.1 (Berkeley) 6/4/93";
 int
 yasm__strcasecmp(const char *s1, const char *s2)
 {
+#ifdef HAVE_STRCASECMP
+    return strcasecmp(s1, s2);
+#elif HAVE_STRICMP
+    return stricmp(s1, s2);
+#elif HAVE_STRCMPI
+    return strcmpi(s1, s2);
+#else
        const unsigned char
                        *us1 = (const unsigned char *)s1,
                        *us2 = (const unsigned char *)s2;
@@ -52,11 +63,19 @@ yasm__strcasecmp(const char *s1, const char *s2)
                if (*us1++ == '\0')
                        return (0);
        return (tolower(*us1) - tolower(*--us2));
+#endif
 }
 
 int
 yasm__strncasecmp(const char *s1, const char *s2, size_t n)
 {
+#ifdef HAVE_STRCASECMP
+    return strncasecmp(s1, s2, n);
+#elif HAVE_STRICMP
+    return strnicmp(s1, s2, n);
+#elif HAVE_STRCMPI
+    return strncmpi(s1, s2, n);
+#else
        const unsigned char
                        *us1 = (const unsigned char *)s1,
                        *us2 = (const unsigned char *)s2;
@@ -70,5 +89,5 @@ yasm__strncasecmp(const char *s1, const char *s2, size_t n)
                } while (--n != 0);
        }
        return (0);
-}
 #endif
+}
index 0e84acfc42c42522ff5de32ec59c2455df1db742..f0dbc11fe8006bad0fd7b9279928fdda340bad93 100644 (file)
@@ -28,6 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+#define YASM_LIB_INTERNAL
 #include "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
@@ -36,6 +37,9 @@
 static char sccsid[] = "@(#)strsep.c   8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 
+#ifdef HAVE_STRSEP
+#undef yasm__strsep
+#endif
 
 /*
  * Get next token from string *stringp, where tokens are possibly-empty
@@ -50,8 +54,11 @@ static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
  */
 /*@-nullstate@*/
 char *
-strsep(char **stringp, const char *delim)
+yasm__strsep(char **stringp, const char *delim)
 {
+#ifdef HAVE_STRSEP
+    return strsep(stringp, delim);
+#else
        register char *s;
        register const char *spanp;
        register int c, sc;
@@ -74,5 +81,6 @@ strsep(char **stringp, const char *delim)
                } while (sc != 0);
        }
        /* NOTREACHED */
+#endif
 }
 /*@=nullstate@*/
index b6ceb1b812dd83e8f8601210fab9e625ea36af48..dfadef3f9ef9027eb8b807694b90f307e772602c 100644 (file)
@@ -24,6 +24,7 @@
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
index ac4b61250a2b1c60a85ac2621058b7d0df6dd73a..fe0692e194d1205578604f8bf3e3491eab109a07 100644 (file)
@@ -13,7 +13,7 @@ bitvect_test_SOURCES = \
        libyasm/tests/bitvect_test.c    \
        $(CHECKFILES)
 bitvect_test_LDFLAGS =
-bitvect_test_LDADD = libyasm.la @LIBLTDL@ @LIBOBJS@ $(INTLLIBS) @LIBADD_DL@
+bitvect_test_LDADD = libyasm.la @LIBLTDL@ $(INTLLIBS) @LIBADD_DL@
 
 #bytecode_test_CFLAGS =
 #bytecode_test_SOURCES = \
@@ -25,14 +25,14 @@ bitvect_test_LDADD = libyasm.la @LIBLTDL@ @LIBOBJS@ $(INTLLIBS) @LIBADD_DL@
 #      $(YASMARCHFILES)                \
 #      $(CHECKFILES)
 #bytecode_test_LDFLAGS =
-#bytecode_test_LDADD = libyasm.la @LIBLTDL@ @LIBOBJS@ $(INTLLIBS) @LIBADD_DL@
+#bytecode_test_LDADD = libyasm.la @LIBLTDL@ $(INTLLIBS) @LIBADD_DL@
 
 floatnum_test_CFLAGS =
 floatnum_test_SOURCES = \
        libyasm/tests/floatnum_test.c   \
        $(CHECKFILES)
 floatnum_test_LDFLAGS =
-floatnum_test_LDADD = libyasm.la @LIBLTDL@ @LIBOBJS@ $(INTLLIBS) @LIBADD_DL@
+floatnum_test_LDADD = libyasm.la @LIBLTDL@ $(INTLLIBS) @LIBADD_DL@
 
 #memexpr_test_CFLAGS =
 #memexpr_test_SOURCES = \
@@ -44,4 +44,4 @@ floatnum_test_LDADD = libyasm.la @LIBLTDL@ @LIBOBJS@ $(INTLLIBS) @LIBADD_DL@
 #      $(YASMARCHFILES)                \
 #      $(CHECKFILES)
 #memexpr_test_LDFLAGS =
-#memexpr_test_LDADD = libyasm.la @LIBLTDL@ @LIBOBJS@ $(INTLLIBS) @LIBADD_DL@
+#memexpr_test_LDADD = libyasm.la @LIBLTDL@ $(INTLLIBS) @LIBADD_DL@
index 6ad5b430abf223bdf66d594d3479390436c6b6f0..afc1506347533f7d657a8ecfb8fcf97272fdd025 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "check.h"
 
-#include "bitvect.h"
+#include "libyasm/bitvect.h"
 
 START_TEST(test_boot)
 {
index bf18f93a06c0e7495af7b43268d4738f40d4b62d..41875b14bbc65b5a554301f430417ab22055dde2 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "check.h"
 
-#include "floatnum.c"
+#include "libyasm/floatnum.c"
 
 /* constants describing parameters of internal floating point format.
  *  (these should match those in src/floatnum.c !)
index fc0113c7d2c0034e78c68721b9bc695a8edc12ac..ccdbfe3207dd9e78b3832f2adf695273f7b047a3 100644 (file)
 #ifndef YASM_UTIL_H
 #define YASM_UTIL_H
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <stdio.h>
+
+#ifdef YASM_LIB_INTERNAL
+# define YASM_INTERNAL
+# define YASM_AUTOCONF_INTERNAL
+# define YASM_LIB_AC_INTERNAL
+# define YASM_GETTEXT_INTERNAL
 #endif
 
-#include <stdio.h>
+#ifdef YASM_INTERNAL
+# include <stdarg.h>
+
+#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H)
+# include "libyasm/config.h"
+#endif
 
 #if !defined(lint)
 # define NDEBUG
 #endif
 
-#ifdef STDC_HEADERS
-# include <stddef.h>
-# include <stdlib.h>
-# include <string.h>
-# include <assert.h>
-# include <stdarg.h>
-#endif
+#ifdef YASM_AUTOCONF_INTERNAL
 
-#if defined(lint)
-#define _(String)      String
-#else
-# ifdef HAVE_LOCALE_H
-#  include <locale.h>
+# ifdef STDC_HEADERS
+#  include <stddef.h>
+#  include <stdlib.h>
+#  include <string.h>
+#  include <assert.h>
 # endif
 
-# ifdef ENABLE_NLS
-#  include <libintl.h>
-#  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 YASM_GETTEXT_INTERNAL
+#  if defined(lint)
+#   define _(String)   String
+#  else
+#   ifdef HAVE_LOCALE_H
+#    include <locale.h>
+#   endif
+
+#   ifdef ENABLE_NLS
+#    include <libintl.h>
+#    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
+#  ifdef gettext_noop
+#   define N_(String)  gettext_noop(String)
+#  else
+#   define N_(String)  (String)
+#  endif
 
-#if !defined(HAVE_MERGESORT) || defined(lint)
-int mergesort(void *base, size_t nmemb, size_t size,
-             int (*compar)(const void *, const void *));
-#endif
+# endif        /*YASM_GETTEXT_INTERNAL*/
+
+#endif /*YASM_AUTOCONF_INTERNAL*/
+
+int yasm__mergesort(void *base, size_t nmemb, size_t size,
+                   int (*compar)(const void *, const void *));
 
-#if !defined(HAVE_STRSEP) || defined(lint)
-/*@null@*/ char *strsep(char **stringp, const char *delim);
+#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_MERGESORT)
+#define yasm__mergesort(a, b, c, d)    mergesort(a, b, c, d)
 #endif
 
-#ifdef HAVE_STRCASECMP
-# define yasm__strcasecmp(x, y)                strcasecmp(x, y)
-# define yasm__strncasecmp(x, y)       strncasecmp(x, y)
-#else
-# ifdef HAVE_STRICMP
-#  define yasm__strcasecmp(x, y)       stricmp(x, y)
-#  define yasm__strncasecmp(x, y)      strnicmp(x, y)
-# elif HAVE_STRCMPI
-#  define yasm__strcasecmp(x, y)       strcmpi(x, y)
-#  define yasm__strncasecmp(x, y)      strncmpi(x, y)
-# else
-#  define USE_OUR_OWN_STRCASECMP
-# endif
+/*@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
 
-#if defined(USE_OUR_OWN_STRCASECMP) || defined(lint)
 int yasm__strcasecmp(const char *s1, const char *s2);
 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
 
-#include "compat-queue.h"
+#endif /*YASM_AUTOCONF_INTERNAL*/
 
-#ifdef HAVE_SYS_CDEFS_H
+#include "libyasm/compat-queue.h"
+
+#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_SYS_CDEFS_H)
 # include <sys/cdefs.h>
 #endif
 
@@ -126,18 +146,11 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
 # endif
 #endif
 
-#ifdef WITH_DMALLOC
-# include <dmalloc.h>
-
-#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)
-
-#else
 /* strdup() implementation with error checking (using xmalloc). */
 /*@only@*/ char *yasm__xstrdup(const char *str);
+/*@only@*/ char *yasm__xstrndup(const char *str, size_t len);
+
+#endif /*YASM_INTERNAL*/
 
 /* Error-checking memory allocation routines.  Default implementations in
  * xmalloc.c.
@@ -150,9 +163,17 @@ extern /*@only@*/ void * (*yasm_xrealloc)
 extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
     /*@modifies p@*/;
 
-#endif
+#ifdef YASM_INTERNAL
 
-/*@only@*/ char *yasm__xstrndup(const char *str, size_t len);
+#if defined(YASM_AUTOCONF_INTERNAL) && defined(WITH_DMALLOC)
+# include <dmalloc.h>
+
+#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
@@ -172,8 +193,10 @@ extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
 #define NELEMS(array)  (sizeof(array) / sizeof(array[0]))
 #endif
 
-#include "coretype.h"
+#endif /*YASM_INTERNAL*/
+
+#include "libyasm/coretype.h"
 
-#include "valparam.h"
+#include "libyasm/valparam.h"
 
 #endif
index 8126712b73688b3c1d77e6197447f21e1b9f3cf6..4c27382b38a367e860dc488905f8c79456ceaf1c 100644 (file)
  * 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 "util.h"
 /*@unused@*/ RCSID("$IdPath$");
 
 #include "expr.h"
 
 
+yasm_valparam *
+yasm_vp_new(/*@keep@*/ const char *v, /*@keep@*/ yasm_expr *p)
+{
+    yasm_valparam *r = yasm_xmalloc(sizeof(yasm_valparam));
+    r->val = v;
+    r->param = p;
+}
+
 void
 yasm_vps_delete(yasm_valparamhead *headp)
 {
@@ -72,3 +81,36 @@ yasm_vps_print(FILE *f, const yasm_valparamhead *headp)
            fprintf(f, ",");
     }
 }
+
+/* Non-macro yasm_vps_initialize() for non-YASM_INTERNAL users. */
+#undef yasm_vps_initialize
+void
+yasm_vps_initialize(/*@out@*/ yasm_valparamhead *headp)
+{
+    STAILQ_INIT(headp);
+}
+
+/* Non-macro yasm_vps_append() for non-YASM_INTERNAL users. */
+#undef yasm_vps_append
+void
+yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp)
+{
+    if (vp)
+       STAILQ_INSERT_TAIL(headp, vp, link);
+}
+
+/* Non-macro yasm_vps_first() for non-YASM_INTERNAL users. */
+#undef yasm_vps_first
+/*@null@*/ /*@dependent@*/ yasm_valparam *
+yasm_vps_first(yasm_valparamhead *headp)
+{
+    return STAILQ_FIRST(headp);
+}
+
+/* Non-macro yasm_vps_next() for non-YASM_INTERNAL users. */
+#undef yasm_vps_next
+/*@null@*/ /*@dependent@*/ yasm_valparam *
+yasm_vps_next(yasm_valparam *cur)
+{
+    return STAILQ_NEXT(cur, link);
+}
index af7af9c14ed8d3281c650abbab56f72a8931a382..0d5a26204be82b5988d02774922857d61bff0d35 100644 (file)
 #ifndef YASM_VALPARAM_H
 #define YASM_VALPARAM_H
 
-typedef struct yasm_valparam {
+#ifdef YASM_INTERNAL
+struct yasm_valparam {
     /*@reldef@*/ STAILQ_ENTRY(yasm_valparam) link;
     /*@owned@*/ /*@null@*/ char *val;
     /*@owned@*/ /*@null@*/ yasm_expr *param;
-} yasm_valparam;
-typedef /*@reldef@*/ STAILQ_HEAD(yasm_valparamhead, yasm_valparam)
-    yasm_valparamhead;
+};
+/*@reldef@*/ STAILQ_HEAD(yasm_valparamhead, yasm_valparam);
+#endif
 
-void yasm_vp_new(/*@out@*/ yasm_valparam *r, /*@keep@*/ const char *v,
-                /*@keep@*/ yasm_expr *p);
-#define yasm_vp_new(r, v, p)       do {                \
-       r = yasm_xmalloc(sizeof(yasm_valparam));        \
-       r->val = v;                                     \
-       r->param = p;                                   \
-    } while(0)
+yasm_valparam *yasm_vp_new(/*@keep@*/ const char *v, /*@keep@*/ yasm_expr *p);
 
-/* void yasm_vps_initialize(//@out@// yasm_valparamhead *headp); */
+void yasm_vps_initialize(/*@out@*/ yasm_valparamhead *headp);
+#ifdef YASM_INTERNAL
 #define yasm_vps_initialize(headp)     STAILQ_INIT(headp)
+#endif
 void yasm_vps_delete(yasm_valparamhead *headp);
 void yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp);
+#ifdef YASM_INTERNAL
 #define yasm_vps_append(headp, vp)     do {        \
        if (vp)                                     \
            STAILQ_INSERT_TAIL(headp, vp, link);    \
     } while(0)
+#endif
 
-/* //@null@// //@dependent@// yasm_valparam *yasm_vps_first
-    (yasm_valparamhead *headp); */
+/*@null@*/ /*@dependent@*/ yasm_valparam *yasm_vps_first
+    (yasm_valparamhead *headp);
+#ifdef YASM_INTERNAL
 #define yasm_vps_first(headp)      STAILQ_FIRST(headp)
+#endif
 
-/* //@null@// //@dependent@// yasm_valparam *yasm_vps_next
-    (yasm_valparam *cur); */
+/*@null@*/ /*@dependent@*/ yasm_valparam *yasm_vps_next(yasm_valparam *cur);
+#ifdef YASM_INTERNAL
 #define yasm_vps_next(cur)         STAILQ_NEXT(cur, link)
 
 #define yasm_vps_foreach(iter, headp)  STAILQ_FOREACH(iter, headp, link)
+#endif
 
 void yasm_vps_print(FILE *f, /*@null@*/ const yasm_valparamhead *headp);
 
index b8fbe0132bf42b7bd8107c7f559caca30f533aba..188b55087f60b080a230b491fb5e7f8fcdcfbf36 100644 (file)
  * 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 "util.h"
 RCSID("$IdPath$");
 
 #include "errwarn.h"
 
 
-#ifndef WITH_DMALLOC
+#ifdef WITH_DMALLOC
+#undef yasm_xmalloc
+#undef yasm_xcalloc
+#undef yasm_xrealloc
+#undef yasm_xfree
+#endif
 
 static /*@only@*/ /*@out@*/ void *def_xmalloc(size_t size);
 static /*@only@*/ void *def_xcalloc(size_t nelem, size_t elsize);
@@ -103,5 +109,3 @@ def_xfree(void *p)
        return;
     free(p);
 }
-
-#endif
index 473554fcc063baf00a038edb5dc0cefb46bff8bb..6395a35162ea60de5af05148daa5fa9aa9dfee75 100644 (file)
@@ -28,6 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+#define YASM_LIB_INTERNAL
 #include "util.h"
 RCSID("$IdPath$");
 
@@ -47,7 +48,9 @@ void memcpy(void *, const void *, size_t);
 # endif
 #endif
 
-#ifndef WITH_DMALLOC
+#ifdef WITH_DMALLOC
+#undef yasm__xstrdup
+#endif
 
 char *
 yasm__xstrdup(const char *str)
@@ -60,7 +63,6 @@ yasm__xstrdup(const char *str)
        memcpy(copy, str, len);
        return (copy);
 }
-#endif
 
 char *
 yasm__xstrndup(const char *str, size_t len)
diff --git a/mergesort.c b/mergesort.c
deleted file mode 100644 (file)
index 3ec4b80..0000000
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * mergesort() implementation for systems that don't have it.
- *
- * Copyright (c) 1992, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Peter McIlroy.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND 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 REGENTS OR 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.
- */
-#include "util.h"
-/*@unused@*/ RCSID("$IdPath$");
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)merge.c    8.2 (Berkeley) 2/14/94";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Hybrid exponential search/linear search merge sort with hybrid
- * natural/pairwise first pass.  Requires about .3% more comparisons
- * for random data than LSMS with pairwise first pass alone.
- * It works for objects as small as two bytes.
- */
-
-#define NATURAL
-#define THRESHOLD 16   /* Best choice for natural merge cut-off. */
-
-/* #define NATURAL to get hybrid natural merge.
- * (The default is pairwise merging.)
- */
-
-#ifdef STDC_HEADERS
-# include <errno.h>
-# include <string.h>
-#endif
-
-static void setup(unsigned char *, unsigned char *, size_t, size_t,
-                 int (*)(const void *, const void *));
-static void insertionsort(unsigned char *, size_t, size_t,
-                         int (*)(const void *, const void *));
-
-#define ISIZE sizeof(int)
-#define PSIZE sizeof(unsigned char *)
-#define ICOPY_LIST(src, dst, last)                             \
-       do                                                      \
-       *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE;    \
-       while(src < last)
-#define ICOPY_ELT(src, dst, i)                                 \
-       do                                                      \
-       *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE;  \
-       while (i -= ISIZE)
-
-#define CCOPY_LIST(src, dst, last)             \
-       do                                      \
-               *dst++ = *src++;                \
-       while (src < last)
-#define CCOPY_ELT(src, dst, i)                 \
-       do                                      \
-               *dst++ = *src++;                \
-       while (i -= 1)
-
-/*
- * Find the next possible pointer head.  (Trickery for forcing an array
- * to do double duty as a linked list when objects do not align with word
- * boundaries.
- */
-/* Assumption: PSIZE is a power of 2. */
-#define EVAL(p) (unsigned char **)                                             \
-       ((unsigned char *)0 +                                                   \
-           (((unsigned char *)p + PSIZE - 1 - (unsigned char *) 0) & ~(PSIZE - 1)))
-
-/*
- * Arguments are as for qsort.
- */
-int
-mergesort(void *base, size_t nmemb, size_t size,
-         int (*cmp)(const void *, const void *))
-{
-       size_t i;
-       int sense;
-       int big, iflag;
-       unsigned char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
-       unsigned char *list2, *list1, *p2, *p, *last, **p1;
-
-       if (size < PSIZE / 2) {         /* Pointers must fit into 2 * size. */
-#ifdef EINVAL
-               errno = EINVAL;
-#endif
-               return (-1);
-       }
-
-       if (nmemb == 0)
-               return (0);
-
-       /*
-        * XXX
-        * Stupid subtraction for the Cray.
-        */
-       iflag = 0;
-       if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
-               iflag = 1;
-
-       if ((list2 = xmalloc(nmemb * size + PSIZE)) == NULL)
-               return (-1);
-
-       list1 = base;
-       setup(list1, list2, nmemb, size, cmp);
-       last = list2 + nmemb * size;
-       i = 0;
-       big = 0;
-       while (*EVAL(list2) != last) {
-           l2 = list1;
-           p1 = EVAL(list1);
-           for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
-               p2 = *EVAL(p2);
-               f1 = l2;
-               f2 = l1 = list1 + (p2 - list2);
-               if (p2 != last)
-                       p2 = *EVAL(p2);
-               l2 = list1 + (p2 - list2);
-               while (f1 < l1 && f2 < l2) {
-                       if ((*cmp)(f1, f2) <= 0) {
-                               q = f2;
-                               b = f1, t = l1;
-                               sense = -1;
-                       } else {
-                               q = f1;
-                               b = f2, t = l2;
-                               sense = 0;
-                       }
-                       if (!big) {     /* here i = 0 */
-                               while ((b += size) < t && cmp(q, b) >sense)
-                                       if (++i == 6) {
-                                               big = 1;
-                                               goto EXPONENTIAL;
-                                       }
-                       } else {
-EXPONENTIAL:                   for (i = size; ; i <<= 1)
-                                       if ((p = (b + i)) >= t) {
-                                               if ((p = t - size) > b &&
-                                                   (*cmp)(q, p) <= sense)
-                                                       t = p;
-                                               else
-                                                       b = p;
-                                               break;
-                                       } else if ((*cmp)(q, p) <= sense) {
-                                               t = p;
-                                               if (i == size)
-                                                       big = 0;
-                                               goto FASTCASE;
-                                       } else
-                                               b = p;
-                               while (t > b+size) {
-                                       i = (((t - b) / size) >> 1) * size;
-                                       if ((*cmp)(q, p = b + i) <= sense)
-                                               t = p;
-                                       else
-                                               b = p;
-                               }
-                               goto COPY;
-FASTCASE:                      while (i > size)
-                                       if ((*cmp)(q,
-                                               p = b + (i >>= 1)) <= sense)
-                                               t = p;
-                                       else
-                                               b = p;
-COPY:                          b = t;
-                       }
-                       i = size;
-                       if (q == f1) {
-                               if (iflag) {
-                                       ICOPY_LIST(f2, tp2, b);
-                                       ICOPY_ELT(f1, tp2, i);
-                               } else {
-                                       CCOPY_LIST(f2, tp2, b);
-                                       CCOPY_ELT(f1, tp2, i);
-                               }
-                       } else {
-                               if (iflag) {
-                                       ICOPY_LIST(f1, tp2, b);
-                                       ICOPY_ELT(f2, tp2, i);
-                               } else {
-                                       CCOPY_LIST(f1, tp2, b);
-                                       CCOPY_ELT(f2, tp2, i);
-                               }
-                       }
-               }
-               if (f2 < l2) {
-                       if (iflag)
-                               ICOPY_LIST(f2, tp2, l2);
-                       else
-                               CCOPY_LIST(f2, tp2, l2);
-               } else if (f1 < l1) {
-                       if (iflag)
-                               ICOPY_LIST(f1, tp2, l1);
-                       else
-                               CCOPY_LIST(f1, tp2, l1);
-               }
-               *p1 = l2;
-           }
-           tp2 = list1;        /* swap list1, list2 */
-           list1 = list2;
-           list2 = tp2;
-           last = list2 + nmemb*size;
-       }
-       if (base == list2) {
-               memmove(list2, list1, nmemb*size);
-               list2 = list1;
-       }
-       xfree(list2);
-       return (0);
-}
-
-#define        swap(a, b) {                                    \
-               s = b;                                  \
-               i = size;                               \
-               do {                                    \
-                       tmp = *a; *a++ = *s; *s++ = tmp; \
-               } while (--i);                          \
-               a -= size;                              \
-       }
-#define reverse(bot, top) {                            \
-       s = top;                                        \
-       do {                                            \
-               i = size;                               \
-               do {                                    \
-                       tmp = *bot; *bot++ = *s; *s++ = tmp; \
-               } while (--i);                          \
-               s -= size2;                             \
-       } while(bot < s);                               \
-}
-
-/*
- * Optional hybrid natural/pairwise first pass.  Eats up list1 in runs of
- * increasing order, list2 in a corresponding linked list.  Checks for runs
- * when THRESHOLD/2 pairs compare with same sense.  (Only used when NATURAL
- * is defined.  Otherwise simple pairwise merging is used.)
- */
-void
-setup(unsigned char *list1, unsigned char *list2, size_t n, size_t size,
-      int (*cmp)(const void *, const void *))
-{
-       size_t i;
-       unsigned int tmp;
-       int length, size2, sense;
-       unsigned char *f1, *f2, *s, *l2, *last, *p2;
-
-       size2 = size*2;
-       if (n <= 5) {
-               insertionsort(list1, n, size, cmp);
-               *EVAL(list2) = (unsigned char*) list2 + n*size;
-               return;
-       }
-       /*
-        * Avoid running pointers out of bounds; limit n to evens
-        * for simplicity.
-        */
-       i = 4 + (n & 1);
-       insertionsort(list1 + (n - i) * size, i, size, cmp);
-       last = list1 + size * (n - i);
-       *EVAL(list2 + (last - list1)) = list2 + n * size;
-
-#ifdef NATURAL
-       p2 = list2;
-       f1 = list1;
-       sense = (cmp(f1, f1 + size) > 0);
-       for (; f1 < last; sense = !sense) {
-               length = 2;
-                                       /* Find pairs with same sense. */
-               for (f2 = f1 + size2; f2 < last; f2 += size2) {
-                       if ((cmp(f2, f2+ size) > 0) != sense)
-                               break;
-                       length += 2;
-               }
-               if (length < THRESHOLD) {               /* Pairwise merge */
-                       do {
-                               p2 = *EVAL(p2) = f1 + size2 - list1 + list2;
-                               if (sense > 0)
-                                       swap (f1, f1 + size);
-                       } while ((f1 += size2) < f2);
-               } else {                                /* Natural merge */
-                       l2 = f2;
-                       for (f2 = f1 + size2; f2 < l2; f2 += size2) {
-                               if ((cmp(f2-size, f2) > 0) != sense) {
-                                       p2 = *EVAL(p2) = f2 - list1 + list2;
-                                       if (sense > 0)
-                                               reverse(f1, f2-size);
-                                       f1 = f2;
-                               }
-                       }
-                       if (sense > 0)
-                               reverse (f1, f2-size);
-                       f1 = f2;
-                       if (f2 < last || cmp(f2 - size, f2) > 0)
-                               p2 = *EVAL(p2) = f2 - list1 + list2;
-                       else
-                               p2 = *EVAL(p2) = list2 + n*size;
-               }
-       }
-#else          /* pairwise merge only. */
-       for (f1 = list1, p2 = list2; f1 < last; f1 += size2) {
-               p2 = *EVAL(p2) = p2 + size2;
-               if (cmp (f1, f1 + size) > 0)
-                       swap(f1, f1 + size);
-       }
-#endif /* NATURAL */
-}
-
-/*
- * This is to avoid out-of-bounds addresses in sorting the
- * last 4 elements.
- */
-static void
-insertionsort(unsigned char *a, size_t n, size_t size,
-             int (*cmp)(const void *, const void *))
-{
-       unsigned char *ai, *s, *t, *u, tmp;
-       size_t i;
-
-       for (ai = a+size; --n >= 1; ai += size)
-               for (t = ai; t > a; t -= size) {
-                       u = t - size;
-                       if (cmp(u, t) <= 0)
-                               break;
-                       swap(u, t);
-               }
-}
index 8c600edb76d013ae5a241ea2a6a460ee9c6351a4..5441b279923dcb8cf08810dbba966b34cd5b5e46 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "file.h"
-
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-
-#include "bytecode.h"
-
-#include "arch.h"
-
 #include "x86arch.h"
 
 
index 27fcc75c769979c939bd4f06dbb83c234c9027c3..fd4cf461213b90df203561ddaf3fd67799d104f4 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#define YASM_BC_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "file.h"
-
-#include "errwarn.h"
-#include "intnum.h"
-#include "expr.h"
-
-#include "bytecode.h"
-#include "arch.h"
-
 #include "x86arch.h"
 
-#include "bc-int.h"
-
 
 typedef struct x86_effaddr {
     yasm_effaddr ea;           /* base structure */
index 06ff7bf030184c55abe606a835ee86fa3eb88e52..972ff9536f468172900725fd0be5261c208ab4fd 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#define YASM_EXPR_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "bitvect.h"
-
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-
-#include "bytecode.h"
-#include "arch.h"
-
 #include "x86arch.h"
 
-#include "expr-int.h"
-
 
 typedef struct x86_checkea_reg3264_data {
     int *regs;         /* total multiplier for each reg */
index becb9ddc4c0044bd4d3553e89a430d29f324eb8a..37d55564dbac6d53ab6e8a9b895980e31b82ba58 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#define YASM_BC_INTERNAL
+#define YASM_EXPR_INTERNAL
+#include "libyasm.h"
 RCSID("$IdPath$");
 
-#include "bitvect.h"
-
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-
-#include "arch.h"
 #include "modules/arch/x86/x86arch.h"
 
-#include "expr-int.h"
-#include "bc-int.h"
-
 
 /* Available CPU feature flags */
 #define CPU_Any            (0UL)       /* Any old cpu will do */
index 74aa6e20e614653a56a697d2ec5182b1cc0c3cc1..8cc9617fbf21d8ea061563bb2ea124bc25de4c99 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "dbgfmt.h"
-
 
 /* Define preproc structure -- see preproc.h for details */
 yasm_dbgfmt yasm_null_LTX_dbgfmt = {
index 1549131b1db220e882b3a7e4b575f1a5ace6867b..adb9e30710efdd615558d27394b00d06f4524e7e 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#define YASM_BC_INTERNAL
+#define YASM_EXPR_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "file.h"
-
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-#include "section.h"
-
-#include "expr-int.h"
-#include "bc-int.h"
-
-#include "arch.h"
-#include "objfmt.h"
-
 
 #define REGULAR_OUTBUF_SIZE    1024
 
index 4ccf66a6703222089f36f8eb3b3333370fbefc3d..cc26ca43313ab54cc323978c21ccae1fbcb369f5 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#define YASM_BC_INTERNAL
+#define YASM_EXPR_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "file.h"
-
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-#include "section.h"
-
-#include "expr-int.h"
-#include "bc-int.h"
-
-#include "arch.h"
-#include "objfmt.h"
-
 
 #define REGULAR_OUTBUF_SIZE    1024
 
index f1134123db598eaffd5cc74e119fc653e59d7e7f..2cc1c13aa5956fa2d3f3fdb5ac7102ae70bd47db 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "errwarn.h"
-#include "expr.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-#include "arch.h"
-#include "section.h"
-#include "objfmt.h"
-#include "dbgfmt.h"
-
 
 yasm_objfmt yasm_dbg_LTX_objfmt;
 
index b7013f35b9dc8efaa117e28a1ea7b1541da65ea5..fea7f8fcf26076ddee37cf058e83a79f1d746599 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#define YASM_BC_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "errwarn.h"
-#include "intnum.h"
-#include "expr.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-#include "section.h"
-
-#include "bc-int.h"
-
-#include "optimizer.h"
-
 
 #define SECTFLAG_NONE          0UL
 #define SECTFLAG_INPROGRESS    (1UL<<0)
index 7446e546c5b3a6377ac7e453eaeea4e479128ec7..3032d501b1d570b373349c7cbeb960c09ff525f7 100644 (file)
  * POSSIBILITY OF SUCH DAMAGE.
  */
 %{
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#define YASM_EXPR_INTERNAL
+#include "libyasm.h"
 RCSID("$IdPath$");
 
 #ifdef STDC_HEADERS
 # include <math.h>
 #endif
 
-#include "bitvect.h"
-
-#include "linemgr.h"
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-#include "expr-int.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-#include "section.h"
-#include "objfmt.h"
-
-#include "arch.h"
-
 #include "modules/parsers/nasm/nasm-parser.h"
 #include "modules/parsers/nasm/nasm-defs.h"
 
@@ -304,18 +290,18 @@ directive_valparam: direxpr       {
         */
        const /*@null@*/ yasm_symrec *vp_symrec;
        if ((vp_symrec = yasm_expr_get_symrec(&$1, 0))) {
-           yasm_vp_new($$, yasm__xstrdup(yasm_symrec_get_name(vp_symrec)),
-                       NULL);
+           $$ = yasm_vp_new(yasm__xstrdup(yasm_symrec_get_name(vp_symrec)),
+                            NULL);
            yasm_expr_delete($1);
        } else {
            yasm_expr__traverse_leaves_in($1, NULL, fix_directive_symrec);
-           yasm_vp_new($$, NULL, $1);
+           $$ = yasm_vp_new(NULL, $1);
        }
     }
-    | STRING                   { yasm_vp_new($$, $1, NULL); }
+    | STRING                   { $$ = yasm_vp_new($1, NULL); }
     | ID '=' direxpr           {
        yasm_expr__traverse_leaves_in($3, NULL, fix_directive_symrec);
-       yasm_vp_new($$, $1, $3);
+       $$ = yasm_vp_new($1, $3);
     }
 ;
 
index 865e56a9c7592c490778fd707cd81529e4596b67..5f8edece98b5a0ab97b0a3e7009ca3b7f359609e 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "errwarn.h"
-
-#include "section.h"
-#include "objfmt.h"
-#include "preproc.h"
-#include "parser.h"
-
 #include "nasm-parser.h"
 
 
index 6cd9725d2da0c3f5a1f12508fb1f2da05a0a4d4b..854ecc06adca3f33c0da9e940cca148dbf02e943 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 RCSID("$IdPath$");
 
-#include "bitvect.h"
-
-#include "linemgr.h"
-#include "errwarn.h"
-#include "intnum.h"
-#include "floatnum.h"
-#include "expr.h"
-#include "symrec.h"
-
-#include "bytecode.h"
-
-#include "arch.h"
-
 #include "modules/parsers/nasm/nasm-parser.h"
 #include "modules/parsers/nasm/nasm-defs.h"
 #include "nasm-bison.h"
index 545f42564a3176dcaefe397adcd322e16e8ba991..1991a4d19028ce3bbe5a9b43d763c556f8ba75c6 100644 (file)
@@ -7,7 +7,8 @@
  *
  * initial version 27/iii/95 by Simon Tatham
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm/util.h"
 #include <ctype.h>
 
 #include "nasm.h"
index d5095df09c714b9690a7012874a836ac03b0a5b2..9d8c30eb39bd32b54fa393c703a5dbcfd5f3a4e7 100644 (file)
@@ -33,7 +33,8 @@
  *
  * detoken is used to convert the line back to text
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm/util.h"
 #include <stdarg.h>
 #include <ctype.h>
 #include <limits.h>
index e7a2b7e9511410a0dc2a0d3e4918f17395730771..81f7fe887d2b337669f0183a7573cd5887f6623f 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "errwarn.h"
-#include "linemgr.h"
-
-#include "preproc.h"
 #include "nasm.h"
 #include "nasmlib.h"
 #include "nasm-pp.h"
index 5eb2be1a7500c62d6c4a0f1c3376372dad7f5f94..6b025dfd4bd11deb709deaa034b00183c2e5f567 100644 (file)
@@ -5,7 +5,8 @@
  * redistributable under the licence given in the file "Licence"
  * distributed in the NASM archive.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm/util.h"
 #include <ctype.h>
 
 #include "nasm.h"
index 49f6e8cf8c08ee3cfaf49a9ff3ea44ae264ca0ff..ecf363192bca5b104c0da301f11ac765cb3b87d2 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "errwarn.h"
-#include "linemgr.h"
-
-#include "preproc.h"
-
 
 static int is_interactive;
 static FILE *in;
index edd9bf308ca9824a1d740a25eb64805686497880..593437295d9044693faa3ba4f53e4f63b2927cdb 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
-#include "linemgr.h"
-#include "errwarn.h"
-#include "preproc.h"
-#include "hamt.h"
-
 #include "yapp-preproc.h"
 #include "yapp-token.h"
 
index 6055a9a283c6a68d5b9c9cacab0d57135633118b..8423430ec33a61339f8dbab9119795e4114f6650 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 %{
-#include "util.h"
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
 /*@unused@*/ RCSID("$IdPath$");
 
 #include <errno.h>
 
-#include "linemgr.h"
-#include "errwarn.h"
-
 #include "modules/preprocs/yapp/yapp-preproc.h"
 #include "modules/preprocs/yapp/yapp-token.h"
 
diff --git a/strsep.c b/strsep.c
deleted file mode 100644 (file)
index 0e84acf..0000000
--- a/strsep.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * strsep() implementation for systems that don't have it.
- *
- * Copyright (c) 1990, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND 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 REGENTS OR 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.
- */
-#include "util.h"
-/*@unused@*/ RCSID("$IdPath$");
-
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strsep.c   8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-
-/*
- * Get next token from string *stringp, where tokens are possibly-empty
- * strings separated by characters from delim.
- *
- * Writes NULs into the string at *stringp to end tokens.
- * delim need not remain constant from call to call.
- * On return, *stringp points past the last NUL written (if there might
- * be further tokens), or is NULL (if there are definitely no more tokens).
- *
- * If *stringp is NULL, strsep returns NULL.
- */
-/*@-nullstate@*/
-char *
-strsep(char **stringp, const char *delim)
-{
-       register char *s;
-       register const char *spanp;
-       register int c, sc;
-       char *tok;
-
-       if ((s = *stringp) == NULL)
-               return (NULL);
-       for (tok = s;;) {
-               c = *s++;
-               spanp = delim;
-               do {
-                       if ((sc = *spanp++) == c) {
-                               if (c == 0)
-                                       s = NULL;
-                               else
-                                       s[-1] = 0;
-                               *stringp = s;
-                               return (tok);
-                       }
-               } while (sc != 0);
-       }
-       /* NOTREACHED */
-}
-/*@=nullstate@*/
diff --git a/util.h b/util.h
index fc0113c7d2c0034e78c68721b9bc695a8edc12ac..ccdbfe3207dd9e78b3832f2adf695273f7b047a3 100644 (file)
--- a/util.h
+++ b/util.h
 #ifndef YASM_UTIL_H
 #define YASM_UTIL_H
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <stdio.h>
+
+#ifdef YASM_LIB_INTERNAL
+# define YASM_INTERNAL
+# define YASM_AUTOCONF_INTERNAL
+# define YASM_LIB_AC_INTERNAL
+# define YASM_GETTEXT_INTERNAL
 #endif
 
-#include <stdio.h>
+#ifdef YASM_INTERNAL
+# include <stdarg.h>
+
+#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H)
+# include "libyasm/config.h"
+#endif
 
 #if !defined(lint)
 # define NDEBUG
 #endif
 
-#ifdef STDC_HEADERS
-# include <stddef.h>
-# include <stdlib.h>
-# include <string.h>
-# include <assert.h>
-# include <stdarg.h>
-#endif
+#ifdef YASM_AUTOCONF_INTERNAL
 
-#if defined(lint)
-#define _(String)      String
-#else
-# ifdef HAVE_LOCALE_H
-#  include <locale.h>
+# ifdef STDC_HEADERS
+#  include <stddef.h>
+#  include <stdlib.h>
+#  include <string.h>
+#  include <assert.h>
 # endif
 
-# ifdef ENABLE_NLS
-#  include <libintl.h>
-#  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 YASM_GETTEXT_INTERNAL
+#  if defined(lint)
+#   define _(String)   String
+#  else
+#   ifdef HAVE_LOCALE_H
+#    include <locale.h>
+#   endif
+
+#   ifdef ENABLE_NLS
+#    include <libintl.h>
+#    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
+#  ifdef gettext_noop
+#   define N_(String)  gettext_noop(String)
+#  else
+#   define N_(String)  (String)
+#  endif
 
-#if !defined(HAVE_MERGESORT) || defined(lint)
-int mergesort(void *base, size_t nmemb, size_t size,
-             int (*compar)(const void *, const void *));
-#endif
+# endif        /*YASM_GETTEXT_INTERNAL*/
+
+#endif /*YASM_AUTOCONF_INTERNAL*/
+
+int yasm__mergesort(void *base, size_t nmemb, size_t size,
+                   int (*compar)(const void *, const void *));
 
-#if !defined(HAVE_STRSEP) || defined(lint)
-/*@null@*/ char *strsep(char **stringp, const char *delim);
+#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_MERGESORT)
+#define yasm__mergesort(a, b, c, d)    mergesort(a, b, c, d)
 #endif
 
-#ifdef HAVE_STRCASECMP
-# define yasm__strcasecmp(x, y)                strcasecmp(x, y)
-# define yasm__strncasecmp(x, y)       strncasecmp(x, y)
-#else
-# ifdef HAVE_STRICMP
-#  define yasm__strcasecmp(x, y)       stricmp(x, y)
-#  define yasm__strncasecmp(x, y)      strnicmp(x, y)
-# elif HAVE_STRCMPI
-#  define yasm__strcasecmp(x, y)       strcmpi(x, y)
-#  define yasm__strncasecmp(x, y)      strncmpi(x, y)
-# else
-#  define USE_OUR_OWN_STRCASECMP
-# endif
+/*@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
 
-#if defined(USE_OUR_OWN_STRCASECMP) || defined(lint)
 int yasm__strcasecmp(const char *s1, const char *s2);
 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
 
-#include "compat-queue.h"
+#endif /*YASM_AUTOCONF_INTERNAL*/
 
-#ifdef HAVE_SYS_CDEFS_H
+#include "libyasm/compat-queue.h"
+
+#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_SYS_CDEFS_H)
 # include <sys/cdefs.h>
 #endif
 
@@ -126,18 +146,11 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
 # endif
 #endif
 
-#ifdef WITH_DMALLOC
-# include <dmalloc.h>
-
-#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)
-
-#else
 /* strdup() implementation with error checking (using xmalloc). */
 /*@only@*/ char *yasm__xstrdup(const char *str);
+/*@only@*/ char *yasm__xstrndup(const char *str, size_t len);
+
+#endif /*YASM_INTERNAL*/
 
 /* Error-checking memory allocation routines.  Default implementations in
  * xmalloc.c.
@@ -150,9 +163,17 @@ extern /*@only@*/ void * (*yasm_xrealloc)
 extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
     /*@modifies p@*/;
 
-#endif
+#ifdef YASM_INTERNAL
 
-/*@only@*/ char *yasm__xstrndup(const char *str, size_t len);
+#if defined(YASM_AUTOCONF_INTERNAL) && defined(WITH_DMALLOC)
+# include <dmalloc.h>
+
+#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
@@ -172,8 +193,10 @@ extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
 #define NELEMS(array)  (sizeof(array) / sizeof(array[0]))
 #endif
 
-#include "coretype.h"
+#endif /*YASM_INTERNAL*/
+
+#include "libyasm/coretype.h"
 
-#include "valparam.h"
+#include "libyasm/valparam.h"
 
 #endif