-/* $IdPath$
+/*
* Generic Options Support Header File
*
* Copyright (c) 2001 Stanislav Karchebny <berk@madfire.net>
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "options.h"
#include "errwarn.h"
-/* $IdPath$
+/*
* Program entry point, command line parsing
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#include "preproc.h"
#include "parser.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#ifndef countof
#define countof(x,y) (sizeof(x)/sizeof(y))
-/* $IdPath$ */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
/*****************************************************************************/
/* MODULE NAME: BitVector.c MODULE TYPE: (adt) */
/*****************************************************************************/
/* MODULE IMPORTS: */
/*****************************************************************************/
+#include <ctype.h> /* MODULE TYPE: (sys) */
#ifdef STDC_HEADERS
#include <limits.h> /* MODULE TYPE: (sys) */
#include <string.h> /* MODULE TYPE: (sys) */
-#include <ctype.h> /* MODULE TYPE: (sys) */
#endif
/*****************************************************************************/
/* MODULE INTERFACE: */
/*****************************************************************************/
#include "bitvect.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* ToolBox.h */
#define and && /* logical (boolean) operators: lower case */
-/* $IdPath$
+/*
* Bytecode utility functions
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "globals.h"
#include "errwarn.h"
#include "intnum.h"
-#include "floatnum.h"
#include "expr.h"
#include "bytecode.h"
-#include "section.h"
-
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-RCSID("$IdPath$");
struct effaddr {
expr *disp; /* address displacement */
#ifndef YASM_BYTECODE_H
#define YASM_BYTECODE_H
-#ifndef YASM_SECTION
-#define YASM_SECTION
-typedef struct section section;
-#endif
-
-#ifndef YASM_EXPR
-#define YASM_EXPR
-typedef struct expr expr;
-#endif
-
-#ifndef YASM_FLOATNUM
-#define YASM_FLOATNUM
-typedef struct floatnum floatnum;
-#endif
-
typedef struct effaddr effaddr;
typedef struct immval immval;
typedef STAILQ_HEAD(datavalhead, dataval) datavalhead;
typedef struct dataval dataval;
-typedef STAILQ_HEAD(bytecodehead, bytecode) bytecodehead;
-
-#ifndef YASM_BYTECODE
-#define YASM_BYTECODE
-typedef struct bytecode bytecode;
-#endif
typedef enum {
JR_NONE,
JR_NEAR_FORCED
} jmprel_opcode_sel;
-typedef struct targetval_s {
+typedef struct targetval {
expr *val;
jmprel_opcode_sel op_sel;
--- /dev/null
+/* $IdPath$
+ * Core (used by many modules/header files) type definitions.
+ *
+ * Copyright (C) 2001 Peter Johnson
+ *
+ * This file is part of YASM.
+ *
+ * YASM is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * YASM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef YASM_CORETYPE_H
+#define YASM_CORETYPE_H
+
+typedef struct preproc preproc;
+typedef struct parser parser;
+typedef struct optimizer optimizer;
+typedef struct objfmt objfmt;
+
+typedef struct bytecode bytecode;
+typedef STAILQ_HEAD(bytecodehead, bytecode) bytecodehead;
+
+typedef struct section section;
+typedef STAILQ_HEAD(sectionhead, section) sectionhead;
+
+typedef struct symrec symrec;
+
+typedef struct expr expr;
+typedef struct intnum intnum;
+typedef struct floatnum floatnum;
+
+typedef enum {
+ EXPR_ADD,
+ EXPR_SUB,
+ EXPR_MUL,
+ EXPR_DIV,
+ EXPR_SIGNDIV,
+ EXPR_MOD,
+ EXPR_SIGNMOD,
+ EXPR_NEG,
+ EXPR_NOT,
+ EXPR_OR,
+ EXPR_AND,
+ EXPR_XOR,
+ EXPR_SHL,
+ EXPR_SHR,
+ EXPR_LOR,
+ EXPR_LAND,
+ EXPR_LNOT,
+ EXPR_LT,
+ EXPR_GT,
+ EXPR_EQ,
+ EXPR_LE,
+ EXPR_GE,
+ EXPR_NE,
+ EXPR_IDENT /* no operation, just a value */
+} ExprOp;
+
+#endif
-/* $IdPath$
+/*
* Error and warning reporting and related functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
#include <ctype.h>
#ifdef STDC_HEADERS
-# include <stdlib.h>
# include <stdarg.h>
-# include <string.h>
#endif
-#include <libintl.h>
-#define _(String) gettext(String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#include "globals.h"
#include "errwarn.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Total error count for entire assembler run.
* Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */
-/* $IdPath$
+/*
* Expression handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "bitvect.h"
#include "expr.h"
#include "symrec.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Types listed in canonical sorting order. See expr_order_terms(). */
typedef enum {
#ifndef YASM_EXPR_H
#define YASM_EXPR_H
-#ifndef YASM_SYMREC
-#define YASM_SYMREC
-typedef struct symrec symrec;
-#endif
-
-#ifndef YASM_FLOATNUM
-#define YASM_FLOATNUM
-typedef struct floatnum floatnum;
-#endif
-
-#ifndef YASM_INTNUM
-#define YASM_INTNUM
-typedef struct intnum intnum;
-#endif
-
-#ifndef YASM_EXPROP
-#define YASM_EXPROP
-typedef enum {
- EXPR_ADD,
- EXPR_SUB,
- EXPR_MUL,
- EXPR_DIV,
- EXPR_SIGNDIV,
- EXPR_MOD,
- EXPR_SIGNMOD,
- EXPR_NEG,
- EXPR_NOT,
- EXPR_OR,
- EXPR_AND,
- EXPR_XOR,
- EXPR_SHL,
- EXPR_SHR,
- EXPR_LOR,
- EXPR_LAND,
- EXPR_LNOT,
- EXPR_LT,
- EXPR_GT,
- EXPR_EQ,
- EXPR_LE,
- EXPR_GE,
- EXPR_NE,
- EXPR_IDENT /* no operation, just a value */
-} ExprOp;
-#endif
-
typedef struct ExprItem ExprItem;
-#ifndef YASM_EXPR
-#define YASM_EXPR
-typedef struct expr expr;
-#endif
-
expr *expr_new(ExprOp, ExprItem *, ExprItem *);
ExprItem *ExprSym(symrec *);
-/* $IdPath$
+/*
* Little-endian file functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "file.h"
-RCSID("$IdPath$");
size_t
fwrite_short(unsigned short val, FILE *f)
-/* $IdPath$
+/*
* Floating point number functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
#include <ctype.h>
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
-
#include "bitvect.h"
#include "file.h"
#include "errwarn.h"
#include "floatnum.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* 97-bit internal floating point format:
* 0000000s eeeeeeee eeeeeeee m.....................................m
#ifndef YASM_FLOATNUM_H
#define YASM_FLOATNUM_H
-#ifndef YASM_EXPROP
-#define YASM_EXPROP
-typedef enum {
- EXPR_ADD,
- EXPR_SUB,
- EXPR_MUL,
- EXPR_DIV,
- EXPR_SIGNDIV,
- EXPR_MOD,
- EXPR_SIGNMOD,
- EXPR_NEG,
- EXPR_NOT,
- EXPR_OR,
- EXPR_AND,
- EXPR_XOR,
- EXPR_SHL,
- EXPR_SHR,
- EXPR_LOR,
- EXPR_LAND,
- EXPR_LNOT,
- EXPR_LT,
- EXPR_GT,
- EXPR_EQ,
- EXPR_LE,
- EXPR_GE,
- EXPR_NE,
- EXPR_IDENT /* if right is IDENT, then the entire expr is just a num */
-} ExprOp;
-#endif
-
-#ifndef YASM_FLOATNUM
-#define YASM_FLOATNUM
-typedef struct floatnum floatnum;
-#endif
-
floatnum *floatnum_new(const char *str);
floatnum *floatnum_copy(const floatnum *flt);
void floatnum_delete(floatnum *flt);
-/* $IdPath$
+/*
* Integer number functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
#include <ctype.h>
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-
#include "bitvect.h"
#include "file.h"
#include "errwarn.h"
#include "intnum.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define BITVECT_ALLOC_SIZE 80
#ifndef YASM_INTNUM_H
#define YASM_INTNUM_H
-#ifndef YASM_EXPROP
-#define YASM_EXPROP
-typedef enum {
- EXPR_ADD,
- EXPR_SUB,
- EXPR_MUL,
- EXPR_DIV,
- EXPR_SIGNDIV,
- EXPR_MOD,
- EXPR_SIGNMOD,
- EXPR_NEG,
- EXPR_NOT,
- EXPR_OR,
- EXPR_AND,
- EXPR_XOR,
- EXPR_SHL,
- EXPR_SHR,
- EXPR_LOR,
- EXPR_LAND,
- EXPR_LNOT,
- EXPR_LT,
- EXPR_GT,
- EXPR_EQ,
- EXPR_LE,
- EXPR_GE,
- EXPR_NE,
- EXPR_IDENT /* if right is IDENT, then the entire expr is just a num */
-} ExprOp;
-#endif
-
-#ifndef YASM_INTNUM
-#define YASM_INTNUM
-typedef struct intnum intnum;
-#endif
-
intnum *intnum_new_dec(char *str);
intnum *intnum_new_bin(char *str);
intnum *intnum_new_oct(char *str);
-/* $IdPath$
+/*
* Global variables
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
+#include "ternary.h"
#include "globals.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
const char *in_filename = (const char *)NULL;
unsigned int line_number = 1;
-/* $IdPath$
+/*
* mergesort() implementation for systems that don't have it.
*
* Copyright (c) 1992, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
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 */
#define YASM_OBJFMT_H
/* Interface to the object format module(s) */
-typedef struct objfmt_s {
+struct objfmt {
/* one-line description of the format */
const char *name;
/* NULL-terminated list of debugging formats that are valid to use with
* this object format.
*/
-/* struct debugfmt_s **debugfmts;*/
+/* debugfmt **debugfmts;*/
/* Default debugging format (set even if there's only one available to
* use)
*/
-/* struct debugfmt_s *default_df;*/
+/* debugfmt *default_df;*/
/* Is the specified section name valid?
* Return is a boolean value.
*/
int (*is_valid_section) (const char *name);
-} objfmt;
+};
/* Available object formats */
extern objfmt dbg_objfmt;
#define YASM_OPTIMIZER_H
/* Interface to the optimizer module(s) */
-typedef struct optimizer_s {
+struct optimizer {
/* one-line description of the optimizer */
const char *name;
* This function takes the unoptimized linked list of sections and returns
* an optimized linked list of sections ready for output to an object file.
*/
-} optimizer;
+};
/* Available optimizers */
extern optimizer dbg_optimizer;
#define YASM_PARSER_H
/* Interface to the parser module(s) -- the "front end" of the assembler */
-typedef struct parser_s {
+struct parser {
/* one-line description of the parser */
const char *name;
* This function returns the starting section of a linked list of sections
* (whatever was in the file).
*/
- sectionhead *(*do_parse) (struct parser_s *p, objfmt *of, FILE *f);
-} parser;
+ sectionhead *(*do_parse) (parser *p, objfmt *of, FILE *f);
+};
/* Generic functions for all parsers - implemented in src/parser.c */
#define YASM_PREPROC_H
/* Interface to the preprocesor module(s) */
-typedef struct preproc_s {
+struct preproc {
/* one-line description of the preprocessor */
const char *name;
/* Gets more preprocessed source code (up to max_size bytes) into buf.
* Note that more than a single line may be returned in buf. */
int (*input) (char *buf, int max_size);
-} preproc;
+};
/* Available preprocessors */
extern preproc raw_preproc;
-/* $IdPath$
+/*
* Section utility functions
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "globals.h"
#include "errwarn.h"
#include "section.h"
#include "objfmt.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
struct section {
STAILQ_ENTRY(section) link;
#ifndef YASM_SECTION_H
#define YASM_SECTION_H
-struct objfmt_s;
+struct objfmt;
-typedef STAILQ_HEAD(sectionhead, section) sectionhead;
+section *sections_initialize(sectionhead *headp, struct objfmt *of);
-#ifndef YASM_SECTION
-#define YASM_SECTION
-typedef struct section section;
-#endif
-
-section *sections_initialize(sectionhead *headp, struct objfmt_s *of);
-
-section *sections_switch(sectionhead *headp, struct objfmt_s *of,
+section *sections_switch(sectionhead *headp, struct objfmt *of,
const char *name);
void sections_delete(sectionhead *headp);
-/* $IdPath$
+/*
* strcasecmp() implementation for systems that don't have it or stricmp()
* or strcmpi().
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
RCSID("$IdPath$");
+
#ifdef USE_OUR_OWN_STRCASECMP
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#ifdef STDC_HEADERS
-# include <string.h>
-# include <ctype.h>
-#endif
+#include <ctype.h>
int
strcasecmp(const char *s1, const char *s2)
-/* $IdPath$
+/*
* strsep() implementation for systems that don't have it.
*
* Copyright (c) 1990, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include "util.h"
+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 */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-#include <string.h>
-#endif
-
-RCSID("$IdPath$");
/*
* Get next token from string *stringp, where tokens are possibly-empty
-/* $IdPath$
+/*
* Symbol table handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+#include "ternary.h"
#include "globals.h"
#include "errwarn.h"
#include "bytecode.h"
#include "section.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* DEFINED is set with EXTERN and COMMON below */
typedef enum {
#ifndef YASM_SYMREC_H
#define YASM_SYMREC_H
-#ifndef YASM_EXPR
-#define YASM_EXPR
-typedef struct expr expr;
-#endif
-
-#ifndef YASM_SECTION
-#define YASM_SECTION
-typedef struct section section;
-#endif
-
-#ifndef YASM_BYTECODE
-#define YASM_BYTECODE
-typedef struct bytecode bytecode;
-#endif
-
/* EXTERN and COMMON are mutually exclusive */
typedef enum {
SYM_LOCAL = 0, /* default, local only */
SYM_EXTERN = 1 << 2 /* if it's declared EXTERN */
} SymVisibility;
-#ifndef YASM_SYMREC
-#define YASM_SYMREC
-typedef struct symrec symrec;
-#endif
-
symrec *symrec_use(const char *name);
symrec *symrec_define_equ(const char *name, expr *e);
/* in_table specifies if the label should be inserted into the symbol table. */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <stdio.h>
+#include "util.h"
#include "check.h"
/* $IdPath$
- * Defines prototypes for replacement functions if needed.
+ * 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
*
#ifndef YASM_UTIL_H
#define YASM_UTIL_H
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+
#ifdef STDC_HEADERS
# include <stddef.h>
+# include <stdlib.h>
+# include <string.h>
#endif
+#include <libintl.h>
+#define _(String) gettext(String)
+
#if !defined(HAVE_MERGESORT)
int mergesort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
# include "compat-queue.h"
#endif
-#include "ternary.h"
-
-#ifndef DMALLOC
-/* strdup() implementation with error checking (using xmalloc). */
-char *xstrdup(const char *str);
-
-/* Error-checking memory allocation routines in xmalloc.c. */
-void *xmalloc(size_t size);
-void *xcalloc(size_t nelem, size_t elsize);
-void *xrealloc(void *oldmem, size_t size);
-void xfree(void *p);
-#endif
-
#ifdef HAVE_SYS_CDEFS_H
# include <sys/cdefs.h>
#endif
# endif
#endif
+#ifdef DMALLOC
+# include <dmalloc.h>
+#else
+/* strdup() implementation with error checking (using xmalloc). */
+char *xstrdup(const char *str);
+
+/* Error-checking memory allocation routines in xmalloc.c. */
+void *xmalloc(size_t size);
+void *xcalloc(size_t nelem, size_t elsize);
+void *xrealloc(void *oldmem, size_t size);
+void xfree(void *p);
+#endif
+
+#include "coretype.h"
+
#endif
-/* $IdPath$
+/*
* Memory allocation routines with error checking. Idea from GNU libiberty.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "errwarn.h"
-#ifndef DMALLOC
-RCSID("$IdPath$");
+#ifndef DMALLOC
void *
xmalloc(size_t size)
-/* $IdPath$
+/*
* strdup() implementation with error checking (using xmalloc).
*
* Copyright (c) 1988, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include "util.h"
+RCSID("$IdPath$");
+
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "util.h"
-#ifdef STDC_HEADERS
-# include <stddef.h>
-# include <string.h>
-#else
+#ifndef STDC_HEADERS
size_t strlen(const char *);
# ifndef HAVE_MEMCPY
void bcopy(const void *, void *, size_t);
#ifndef DMALLOC
-RCSID("$IdPath$");
-
char *
xstrdup(const char *str)
{
-/* $IdPath$
+/*
* mergesort() implementation for systems that don't have it.
*
* Copyright (c) 1992, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
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 */
-/* $IdPath$
+/*
* Expression handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "bitvect.h"
#include "expr.h"
#include "symrec.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Types listed in canonical sorting order. See expr_order_terms(). */
typedef enum {
-/* $IdPath$
+/*
* Expression handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "bitvect.h"
#include "expr.h"
#include "symrec.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Types listed in canonical sorting order. See expr_order_terms(). */
typedef enum {
-/* $IdPath$
+/*
* Debugging object format (used to debug object format module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "objfmt.h"
-RCSID("$IdPath$");
static int
dbg_objfmt_is_valid_section(const char *name)
-/* $IdPath$
+/*
* Debugging object format (used to debug object format module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "objfmt.h"
-RCSID("$IdPath$");
static int
dbg_objfmt_is_valid_section(const char *name)
-/* $IdPath$
+/*
* Debugging optimizer (used to debug optimizer module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#include "optimizer.h"
-RCSID("$IdPath$");
/* Define optimizer structure -- see optimizer.h for details */
optimizer dbg_optimizer = {
-/* $IdPath$
+/*
* Debugging optimizer (used to debug optimizer module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#include "optimizer.h"
-RCSID("$IdPath$");
/* Define optimizer structure -- see optimizer.h for details */
optimizer dbg_optimizer = {
-/* $IdPath$
+/*
* Debugging optimizer (used to debug optimizer module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#include "optimizer.h"
-RCSID("$IdPath$");
/* Define optimizer structure -- see optimizer.h for details */
optimizer dbg_optimizer = {
-/* $IdPath$
+/*
* NASM-compatible bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%{
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
# include <math.h>
#endif
-#include <libintl.h>
-#define _(String) gettext(String)
-
#include "bitvect.h"
#include "globals.h"
#include "section.h"
#include "objfmt.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define YYDEBUG 1
-/* $IdPath$
+/*
* NASM-compatible bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%{
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
# include <math.h>
#endif
-#include <libintl.h>
-#define _(String) gettext(String)
-
#include "bitvect.h"
#include "globals.h"
#include "section.h"
#include "objfmt.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define YYDEBUG 1
-/* $IdPath$
+/*
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
-/* $IdPath$
+/*
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
-/* $IdPath$
+/*
* NASM-compatible lex lexer
*
* Copyright (C) 2001 Peter Johnson
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%{
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "bitvect.h"
#include "bison.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define YY_NEVER_INTERACTIVE 1
-/* $IdPath$
+/*
* Raw preprocessor (preforms NO preprocessing)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "objfmt.h"
#include "preproc.h"
-RCSID("$IdPath$");
static int is_interactive;
static FILE *in;
-/* $IdPath$
+/*
* Raw preprocessor (preforms NO preprocessing)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "objfmt.h"
#include "preproc.h"
-RCSID("$IdPath$");
static int is_interactive;
static FILE *in;
-/* $IdPath$
+/*
* Expression handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "bitvect.h"
#include "expr.h"
#include "symrec.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Types listed in canonical sorting order. See expr_order_terms(). */
typedef enum {
-/* $IdPath$
+/*
* Expression handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "bitvect.h"
#include "expr.h"
#include "symrec.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Types listed in canonical sorting order. See expr_order_terms(). */
typedef enum {
-/* $IdPath$ */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
/*****************************************************************************/
/* MODULE NAME: BitVector.c MODULE TYPE: (adt) */
/*****************************************************************************/
/* MODULE IMPORTS: */
/*****************************************************************************/
+#include <ctype.h> /* MODULE TYPE: (sys) */
#ifdef STDC_HEADERS
#include <limits.h> /* MODULE TYPE: (sys) */
#include <string.h> /* MODULE TYPE: (sys) */
-#include <ctype.h> /* MODULE TYPE: (sys) */
#endif
/*****************************************************************************/
/* MODULE INTERFACE: */
/*****************************************************************************/
#include "bitvect.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* ToolBox.h */
#define and && /* logical (boolean) operators: lower case */
-/* $IdPath$
+/*
* Bytecode utility functions
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "globals.h"
#include "errwarn.h"
#include "intnum.h"
-#include "floatnum.h"
#include "expr.h"
#include "bytecode.h"
-#include "section.h"
-
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-RCSID("$IdPath$");
struct effaddr {
expr *disp; /* address displacement */
#ifndef YASM_BYTECODE_H
#define YASM_BYTECODE_H
-#ifndef YASM_SECTION
-#define YASM_SECTION
-typedef struct section section;
-#endif
-
-#ifndef YASM_EXPR
-#define YASM_EXPR
-typedef struct expr expr;
-#endif
-
-#ifndef YASM_FLOATNUM
-#define YASM_FLOATNUM
-typedef struct floatnum floatnum;
-#endif
-
typedef struct effaddr effaddr;
typedef struct immval immval;
typedef STAILQ_HEAD(datavalhead, dataval) datavalhead;
typedef struct dataval dataval;
-typedef STAILQ_HEAD(bytecodehead, bytecode) bytecodehead;
-
-#ifndef YASM_BYTECODE
-#define YASM_BYTECODE
-typedef struct bytecode bytecode;
-#endif
typedef enum {
JR_NONE,
JR_NEAR_FORCED
} jmprel_opcode_sel;
-typedef struct targetval_s {
+typedef struct targetval {
expr *val;
jmprel_opcode_sel op_sel;
--- /dev/null
+/* $IdPath$
+ * Core (used by many modules/header files) type definitions.
+ *
+ * Copyright (C) 2001 Peter Johnson
+ *
+ * This file is part of YASM.
+ *
+ * YASM is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * YASM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef YASM_CORETYPE_H
+#define YASM_CORETYPE_H
+
+typedef struct preproc preproc;
+typedef struct parser parser;
+typedef struct optimizer optimizer;
+typedef struct objfmt objfmt;
+
+typedef struct bytecode bytecode;
+typedef STAILQ_HEAD(bytecodehead, bytecode) bytecodehead;
+
+typedef struct section section;
+typedef STAILQ_HEAD(sectionhead, section) sectionhead;
+
+typedef struct symrec symrec;
+
+typedef struct expr expr;
+typedef struct intnum intnum;
+typedef struct floatnum floatnum;
+
+typedef enum {
+ EXPR_ADD,
+ EXPR_SUB,
+ EXPR_MUL,
+ EXPR_DIV,
+ EXPR_SIGNDIV,
+ EXPR_MOD,
+ EXPR_SIGNMOD,
+ EXPR_NEG,
+ EXPR_NOT,
+ EXPR_OR,
+ EXPR_AND,
+ EXPR_XOR,
+ EXPR_SHL,
+ EXPR_SHR,
+ EXPR_LOR,
+ EXPR_LAND,
+ EXPR_LNOT,
+ EXPR_LT,
+ EXPR_GT,
+ EXPR_EQ,
+ EXPR_LE,
+ EXPR_GE,
+ EXPR_NE,
+ EXPR_IDENT /* no operation, just a value */
+} ExprOp;
+
+#endif
-/* $IdPath$
+/*
* Error and warning reporting and related functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
#include <ctype.h>
#ifdef STDC_HEADERS
-# include <stdlib.h>
# include <stdarg.h>
-# include <string.h>
#endif
-#include <libintl.h>
-#define _(String) gettext(String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#include "globals.h"
#include "errwarn.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Total error count for entire assembler run.
* Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */
-/* $IdPath$
+/*
* Expression handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "bitvect.h"
#include "expr.h"
#include "symrec.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Types listed in canonical sorting order. See expr_order_terms(). */
typedef enum {
#ifndef YASM_EXPR_H
#define YASM_EXPR_H
-#ifndef YASM_SYMREC
-#define YASM_SYMREC
-typedef struct symrec symrec;
-#endif
-
-#ifndef YASM_FLOATNUM
-#define YASM_FLOATNUM
-typedef struct floatnum floatnum;
-#endif
-
-#ifndef YASM_INTNUM
-#define YASM_INTNUM
-typedef struct intnum intnum;
-#endif
-
-#ifndef YASM_EXPROP
-#define YASM_EXPROP
-typedef enum {
- EXPR_ADD,
- EXPR_SUB,
- EXPR_MUL,
- EXPR_DIV,
- EXPR_SIGNDIV,
- EXPR_MOD,
- EXPR_SIGNMOD,
- EXPR_NEG,
- EXPR_NOT,
- EXPR_OR,
- EXPR_AND,
- EXPR_XOR,
- EXPR_SHL,
- EXPR_SHR,
- EXPR_LOR,
- EXPR_LAND,
- EXPR_LNOT,
- EXPR_LT,
- EXPR_GT,
- EXPR_EQ,
- EXPR_LE,
- EXPR_GE,
- EXPR_NE,
- EXPR_IDENT /* no operation, just a value */
-} ExprOp;
-#endif
-
typedef struct ExprItem ExprItem;
-#ifndef YASM_EXPR
-#define YASM_EXPR
-typedef struct expr expr;
-#endif
-
expr *expr_new(ExprOp, ExprItem *, ExprItem *);
ExprItem *ExprSym(symrec *);
-/* $IdPath$
+/*
* Little-endian file functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "file.h"
-RCSID("$IdPath$");
size_t
fwrite_short(unsigned short val, FILE *f)
-/* $IdPath$
+/*
* Floating point number functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
#include <ctype.h>
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
-
#include "bitvect.h"
#include "file.h"
#include "errwarn.h"
#include "floatnum.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* 97-bit internal floating point format:
* 0000000s eeeeeeee eeeeeeee m.....................................m
#ifndef YASM_FLOATNUM_H
#define YASM_FLOATNUM_H
-#ifndef YASM_EXPROP
-#define YASM_EXPROP
-typedef enum {
- EXPR_ADD,
- EXPR_SUB,
- EXPR_MUL,
- EXPR_DIV,
- EXPR_SIGNDIV,
- EXPR_MOD,
- EXPR_SIGNMOD,
- EXPR_NEG,
- EXPR_NOT,
- EXPR_OR,
- EXPR_AND,
- EXPR_XOR,
- EXPR_SHL,
- EXPR_SHR,
- EXPR_LOR,
- EXPR_LAND,
- EXPR_LNOT,
- EXPR_LT,
- EXPR_GT,
- EXPR_EQ,
- EXPR_LE,
- EXPR_GE,
- EXPR_NE,
- EXPR_IDENT /* if right is IDENT, then the entire expr is just a num */
-} ExprOp;
-#endif
-
-#ifndef YASM_FLOATNUM
-#define YASM_FLOATNUM
-typedef struct floatnum floatnum;
-#endif
-
floatnum *floatnum_new(const char *str);
floatnum *floatnum_copy(const floatnum *flt);
void floatnum_delete(floatnum *flt);
-/* $IdPath$
+/*
* Global variables
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
+#include "ternary.h"
#include "globals.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
const char *in_filename = (const char *)NULL;
unsigned int line_number = 1;
-/* $IdPath$
+/*
* Integer number functions.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
#include <ctype.h>
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-
#include "bitvect.h"
#include "file.h"
#include "errwarn.h"
#include "intnum.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define BITVECT_ALLOC_SIZE 80
#ifndef YASM_INTNUM_H
#define YASM_INTNUM_H
-#ifndef YASM_EXPROP
-#define YASM_EXPROP
-typedef enum {
- EXPR_ADD,
- EXPR_SUB,
- EXPR_MUL,
- EXPR_DIV,
- EXPR_SIGNDIV,
- EXPR_MOD,
- EXPR_SIGNMOD,
- EXPR_NEG,
- EXPR_NOT,
- EXPR_OR,
- EXPR_AND,
- EXPR_XOR,
- EXPR_SHL,
- EXPR_SHR,
- EXPR_LOR,
- EXPR_LAND,
- EXPR_LNOT,
- EXPR_LT,
- EXPR_GT,
- EXPR_EQ,
- EXPR_LE,
- EXPR_GE,
- EXPR_NE,
- EXPR_IDENT /* if right is IDENT, then the entire expr is just a num */
-} ExprOp;
-#endif
-
-#ifndef YASM_INTNUM
-#define YASM_INTNUM
-typedef struct intnum intnum;
-#endif
-
intnum *intnum_new_dec(char *str);
intnum *intnum_new_bin(char *str);
intnum *intnum_new_oct(char *str);
-/* $IdPath$
+/*
* Global variables
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
+#include "ternary.h"
#include "globals.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
const char *in_filename = (const char *)NULL;
unsigned int line_number = 1;
-/* $IdPath$
+/*
* Program entry point, command line parsing
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#include "preproc.h"
#include "parser.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#ifndef countof
#define countof(x,y) (sizeof(x)/sizeof(y))
-/* $IdPath$
+/*
* mergesort() implementation for systems that don't have it.
*
* Copyright (c) 1992, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
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 */
#define YASM_OBJFMT_H
/* Interface to the object format module(s) */
-typedef struct objfmt_s {
+struct objfmt {
/* one-line description of the format */
const char *name;
/* NULL-terminated list of debugging formats that are valid to use with
* this object format.
*/
-/* struct debugfmt_s **debugfmts;*/
+/* debugfmt **debugfmts;*/
/* Default debugging format (set even if there's only one available to
* use)
*/
-/* struct debugfmt_s *default_df;*/
+/* debugfmt *default_df;*/
/* Is the specified section name valid?
* Return is a boolean value.
*/
int (*is_valid_section) (const char *name);
-} objfmt;
+};
/* Available object formats */
extern objfmt dbg_objfmt;
-/* $IdPath$
+/*
* Debugging object format (used to debug object format module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "objfmt.h"
-RCSID("$IdPath$");
static int
dbg_objfmt_is_valid_section(const char *name)
-/* $IdPath$
+/*
* Debugging object format (used to debug object format module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "objfmt.h"
-RCSID("$IdPath$");
static int
dbg_objfmt_is_valid_section(const char *name)
#define YASM_OPTIMIZER_H
/* Interface to the optimizer module(s) */
-typedef struct optimizer_s {
+struct optimizer {
/* one-line description of the optimizer */
const char *name;
* This function takes the unoptimized linked list of sections and returns
* an optimized linked list of sections ready for output to an object file.
*/
-} optimizer;
+};
/* Available optimizers */
extern optimizer dbg_optimizer;
-/* $IdPath$
+/*
* Debugging optimizer (used to debug optimizer module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#include "optimizer.h"
-RCSID("$IdPath$");
/* Define optimizer structure -- see optimizer.h for details */
optimizer dbg_optimizer = {
-/* $IdPath$
+/*
* Debugging optimizer (used to debug optimizer module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#include "optimizer.h"
-RCSID("$IdPath$");
/* Define optimizer structure -- see optimizer.h for details */
optimizer dbg_optimizer = {
-/* $IdPath$
+/*
* Debugging optimizer (used to debug optimizer module interface)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#include "optimizer.h"
-RCSID("$IdPath$");
/* Define optimizer structure -- see optimizer.h for details */
optimizer dbg_optimizer = {
-/* $IdPath$
+/*
* Generic Options Support Header File
*
* Copyright (c) 2001 Stanislav Karchebny <berk@madfire.net>
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "options.h"
#include "errwarn.h"
-/* $IdPath$
+/*
* Generic functions for all parsers
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
+RCSID("$IdPath$");
#include "globals.h"
-#include "errwarn.h"
-#include "expr.h"
-#include "bytecode.h"
-#include "section.h"
-#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* NULL-terminated list of all available parsers.
* Someday change this if we dynamically load parsers at runtime.
#define YASM_PARSER_H
/* Interface to the parser module(s) -- the "front end" of the assembler */
-typedef struct parser_s {
+struct parser {
/* one-line description of the parser */
const char *name;
* This function returns the starting section of a linked list of sections
* (whatever was in the file).
*/
- sectionhead *(*do_parse) (struct parser_s *p, objfmt *of, FILE *f);
-} parser;
+ sectionhead *(*do_parse) (parser *p, objfmt *of, FILE *f);
+};
/* Generic functions for all parsers - implemented in src/parser.c */
-/* $IdPath$
+/*
* NASM-compatible bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%{
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
# include <math.h>
#endif
-#include <libintl.h>
-#define _(String) gettext(String)
-
#include "bitvect.h"
#include "globals.h"
#include "section.h"
#include "objfmt.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define YYDEBUG 1
-/* $IdPath$
+/*
* NASM-compatible bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%{
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
# include <math.h>
#endif
-#include <libintl.h>
-#define _(String) gettext(String)
-
#include "bitvect.h"
#include "globals.h"
#include "section.h"
#include "objfmt.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define YYDEBUG 1
-/* $IdPath$
+/*
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
-/* $IdPath$
+/*
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
-/* $IdPath$
+/*
* NASM-compatible lex lexer
*
* Copyright (C) 2001 Peter Johnson
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%{
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "bitvect.h"
#include "bison.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
#define YY_NEVER_INTERACTIVE 1
#define YASM_PREPROC_H
/* Interface to the preprocesor module(s) */
-typedef struct preproc_s {
+struct preproc {
/* one-line description of the preprocessor */
const char *name;
/* Gets more preprocessed source code (up to max_size bytes) into buf.
* Note that more than a single line may be returned in buf. */
int (*input) (char *buf, int max_size);
-} preproc;
+};
/* Available preprocessors */
extern preproc raw_preproc;
-/* $IdPath$
+/*
* Raw preprocessor (preforms NO preprocessing)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "objfmt.h"
#include "preproc.h"
-RCSID("$IdPath$");
static int is_interactive;
static FILE *in;
-/* $IdPath$
+/*
* Raw preprocessor (preforms NO preprocessing)
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "errwarn.h"
-#include "objfmt.h"
#include "preproc.h"
-RCSID("$IdPath$");
static int is_interactive;
static FILE *in;
-/* $IdPath$
+/*
* Section utility functions
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+RCSID("$IdPath$");
#include "globals.h"
#include "errwarn.h"
#include "section.h"
#include "objfmt.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
struct section {
STAILQ_ENTRY(section) link;
#ifndef YASM_SECTION_H
#define YASM_SECTION_H
-struct objfmt_s;
+struct objfmt;
-typedef STAILQ_HEAD(sectionhead, section) sectionhead;
+section *sections_initialize(sectionhead *headp, struct objfmt *of);
-#ifndef YASM_SECTION
-#define YASM_SECTION
-typedef struct section section;
-#endif
-
-section *sections_initialize(sectionhead *headp, struct objfmt_s *of);
-
-section *sections_switch(sectionhead *headp, struct objfmt_s *of,
+section *sections_switch(sectionhead *headp, struct objfmt *of,
const char *name);
void sections_delete(sectionhead *headp);
-/* $IdPath$
+/*
* strcasecmp() implementation for systems that don't have it or stricmp()
* or strcmpi().
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
RCSID("$IdPath$");
+
#ifdef USE_OUR_OWN_STRCASECMP
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#ifdef STDC_HEADERS
-# include <string.h>
-# include <ctype.h>
-#endif
+#include <ctype.h>
int
strcasecmp(const char *s1, const char *s2)
-/* $IdPath$
+/*
* strsep() implementation for systems that don't have it.
*
* Copyright (c) 1990, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include "util.h"
+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 */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-#include <string.h>
-#endif
-
-RCSID("$IdPath$");
/*
* Get next token from string *stringp, where tokens are possibly-empty
-/* $IdPath$
+/*
* Symbol table handling
*
* Copyright (C) 2001 Michael Urman, Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
+RCSID("$IdPath$");
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-# include <string.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+#include "ternary.h"
#include "globals.h"
#include "errwarn.h"
#include "bytecode.h"
#include "section.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* DEFINED is set with EXTERN and COMMON below */
typedef enum {
#ifndef YASM_SYMREC_H
#define YASM_SYMREC_H
-#ifndef YASM_EXPR
-#define YASM_EXPR
-typedef struct expr expr;
-#endif
-
-#ifndef YASM_SECTION
-#define YASM_SECTION
-typedef struct section section;
-#endif
-
-#ifndef YASM_BYTECODE
-#define YASM_BYTECODE
-typedef struct bytecode bytecode;
-#endif
-
/* EXTERN and COMMON are mutually exclusive */
typedef enum {
SYM_LOCAL = 0, /* default, local only */
SYM_EXTERN = 1 << 2 /* if it's declared EXTERN */
} SymVisibility;
-#ifndef YASM_SYMREC
-#define YASM_SYMREC
-typedef struct symrec symrec;
-#endif
-
symrec *symrec_use(const char *name);
symrec *symrec_define_equ(const char *name, expr *e);
/* in_table specifies if the label should be inserted into the symbol table. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "util.h"
-
-#include <stdio.h>
+RCSID("$IdPath$");
#include "errwarn.h"
#include "ternary.h"
-#ifdef DMALLOC
-# include <dmalloc.h>
-#endif
-
-RCSID("$IdPath$");
/* Non-recursive so we don't waste stack space/time on large
insertions. */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#include <stdio.h>
+#include "util.h"
#include "check.h"
/* $IdPath$
- * Defines prototypes for replacement functions if needed.
+ * 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
*
#ifndef YASM_UTIL_H
#define YASM_UTIL_H
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+
#ifdef STDC_HEADERS
# include <stddef.h>
+# include <stdlib.h>
+# include <string.h>
#endif
+#include <libintl.h>
+#define _(String) gettext(String)
+
#if !defined(HAVE_MERGESORT)
int mergesort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
# include "compat-queue.h"
#endif
-#include "ternary.h"
-
-#ifndef DMALLOC
-/* strdup() implementation with error checking (using xmalloc). */
-char *xstrdup(const char *str);
-
-/* Error-checking memory allocation routines in xmalloc.c. */
-void *xmalloc(size_t size);
-void *xcalloc(size_t nelem, size_t elsize);
-void *xrealloc(void *oldmem, size_t size);
-void xfree(void *p);
-#endif
-
#ifdef HAVE_SYS_CDEFS_H
# include <sys/cdefs.h>
#endif
# endif
#endif
+#ifdef DMALLOC
+# include <dmalloc.h>
+#else
+/* strdup() implementation with error checking (using xmalloc). */
+char *xstrdup(const char *str);
+
+/* Error-checking memory allocation routines in xmalloc.c. */
+void *xmalloc(size_t size);
+void *xcalloc(size_t nelem, size_t elsize);
+void *xrealloc(void *oldmem, size_t size);
+void xfree(void *p);
+#endif
+
+#include "coretype.h"
+
#endif
-/* $IdPath$
+/*
* Memory allocation routines with error checking. Idea from GNU libiberty.
*
* Copyright (C) 2001 Peter Johnson
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "util.h"
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-#endif
-
-#include <libintl.h>
-#define _(String) gettext(String)
+RCSID("$IdPath$");
#include "errwarn.h"
-#ifndef DMALLOC
-RCSID("$IdPath$");
+#ifndef DMALLOC
void *
xmalloc(size_t size)
-/* $IdPath$
+/*
* strdup() implementation with error checking (using xmalloc).
*
* Copyright (c) 1988, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include "util.h"
+RCSID("$IdPath$");
+
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "util.h"
-#ifdef STDC_HEADERS
-# include <stddef.h>
-# include <string.h>
-#else
+#ifndef STDC_HEADERS
size_t strlen(const char *);
# ifndef HAVE_MEMCPY
void bcopy(const void *, void *, size_t);
#ifndef DMALLOC
-RCSID("$IdPath$");
-
char *
xstrdup(const char *str)
{
-/* $IdPath$
+/*
* strsep() implementation for systems that don't have it.
*
* Copyright (c) 1990, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include "util.h"
+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 */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "util.h"
-
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-#include <string.h>
-#endif
-
-RCSID("$IdPath$");
/*
* Get next token from string *stringp, where tokens are possibly-empty
/* $IdPath$
- * Defines prototypes for replacement functions if needed.
+ * 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
*
#ifndef YASM_UTIL_H
#define YASM_UTIL_H
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+
#ifdef STDC_HEADERS
# include <stddef.h>
+# include <stdlib.h>
+# include <string.h>
#endif
+#include <libintl.h>
+#define _(String) gettext(String)
+
#if !defined(HAVE_MERGESORT)
int mergesort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
# include "compat-queue.h"
#endif
-#include "ternary.h"
-
-#ifndef DMALLOC
-/* strdup() implementation with error checking (using xmalloc). */
-char *xstrdup(const char *str);
-
-/* Error-checking memory allocation routines in xmalloc.c. */
-void *xmalloc(size_t size);
-void *xcalloc(size_t nelem, size_t elsize);
-void *xrealloc(void *oldmem, size_t size);
-void xfree(void *p);
-#endif
-
#ifdef HAVE_SYS_CDEFS_H
# include <sys/cdefs.h>
#endif
# endif
#endif
+#ifdef DMALLOC
+# include <dmalloc.h>
+#else
+/* strdup() implementation with error checking (using xmalloc). */
+char *xstrdup(const char *str);
+
+/* Error-checking memory allocation routines in xmalloc.c. */
+void *xmalloc(size_t size);
+void *xcalloc(size_t nelem, size_t elsize);
+void *xrealloc(void *oldmem, size_t size);
+void xfree(void *p);
+#endif
+
+#include "coretype.h"
+
#endif