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