Start separating modules and frontends from libyasm internals.
svn path=/trunk/yasm/; revision=849
nasm-bison.c
nasm-bison.h
nasm-token.c
+nasm-macros.c
yapp-token.c
x86id.c
re2c-parser.c
configure
configure.scan
config.*
-stamp-h*
aclocal.m4
*.tar.gz
*.la
AM_YFLAGS = -d
AM_CFLAGS = @MORE_CFLAGS@
AM_CPPFLAGS = \
- -I$(top_srcdir)/libyasm \
-I$(top_srcdir)/check \
@INCLTDL@
TESTS =
noinst_PROGRAMS =
+include_HEADERS = libyasm.h
+
lib_LTLIBRARIES =
YASM_MODULES =
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:
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
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
#
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
* 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 {
* 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__
* 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. */
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)
--- /dev/null
+/* $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
--- /dev/null
+stamp-h*
+config.*
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
* 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$");
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);
+}
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
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;
/* Specified size of the operand, in bytes. 0 if not user-specified. */
unsigned int size;
};
+#endif
void yasm_arch_common_initialize(yasm_arch *a);
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.
+#define YASM_LIB_INTERNAL
#include "util.h"
RCSID("$IdPath$");
* 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$");
}
}
}
+
+/* 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);
+}
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.
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);
/*@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);
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);
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;
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,
* 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$");
*/
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 *,
*/
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);
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);
* 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$");
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,
* 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$");
* 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$");
* 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$");
* 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$");
* 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$");
* 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
#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;
}
xfree(list2);
return (0);
+#endif /*HAVE_MERGESORT*/
}
+#ifndef HAVE_MERGESORT
+
#define swap(a, b) { \
s = b; \
i = size; \
swap(u, t);
}
}
+#endif /*HAVE_MERGESORT*/
* 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$");
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);
#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);
* 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";
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;
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;
} while (--n != 0);
}
return (0);
-}
#endif
+}
* 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[] = "@(#)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
*/
/*@-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;
} while (sc != 0);
}
/* NOTREACHED */
+#endif
}
/*@=nullstate@*/
* 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$");
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 = \
# $(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 = \
# $(YASMARCHFILES) \
# $(CHECKFILES)
#memexpr_test_LDFLAGS =
-#memexpr_test_LDADD = libyasm.la @LIBLTDL@ @LIBOBJS@ $(INTLLIBS) @LIBADD_DL@
+#memexpr_test_LDADD = libyasm.la @LIBLTDL@ $(INTLLIBS) @LIBADD_DL@
#include "check.h"
-#include "bitvect.h"
+#include "libyasm/bitvect.h"
START_TEST(test_boot)
{
#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 !)
#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
# 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.
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
#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
* 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)
{
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);
+}
#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);
* 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);
return;
free(p);
}
-
-#endif
* 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$");
# endif
#endif
-#ifndef WITH_DMALLOC
+#ifdef WITH_DMALLOC
+#undef yasm__xstrdup
+#endif
char *
yasm__xstrdup(const char *str)
memcpy(copy, str, len);
return (copy);
}
-#endif
char *
yasm__xstrndup(const char *str, size_t len)
+++ /dev/null
-/*
- * 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);
- }
-}
* 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"
* 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 */
* 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 */
* 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 */
* 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 = {
* 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
* 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
* 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;
* 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)
* 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"
*/
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);
}
;
* 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"
* 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"
*
* 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"
*
* 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>
* 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"
* 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"
* 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;
* 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"
* 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"
+++ /dev/null
-/*
- * 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@*/
#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
# 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.
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
#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