diff --git a/frontends/yasm/yasm-options.c b/frontends/yasm/yasm-options.c index efe7882e..5eef8b24 100644 --- a/frontends/yasm/yasm-options.c +++ b/frontends/yasm/yasm-options.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Generic Options Support Header File * * Copyright (c) 2001 Stanislav Karchebny @@ -27,25 +27,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#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" diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 45e76049..0b4d711f 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Program entry point, command line parsing * * Copyright (C) 2001 Peter Johnson @@ -19,21 +19,9 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) #ifdef gettext_noop #define N_(String) gettext_noop(String) #else @@ -53,11 +41,6 @@ #include "preproc.h" #include "parser.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #ifndef countof #define countof(x,y) (sizeof(x)/sizeof(y)) diff --git a/libyasm/bitvect.c b/libyasm/bitvect.c index cedec924..6ed5d189 100644 --- a/libyasm/bitvect.c +++ b/libyasm/bitvect.c @@ -1,30 +1,21 @@ -/* $IdPath$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" +RCSID("$IdPath$"); /*****************************************************************************/ /* MODULE NAME: BitVector.c MODULE TYPE: (adt) */ /*****************************************************************************/ /* MODULE IMPORTS: */ /*****************************************************************************/ +#include /* MODULE TYPE: (sys) */ #ifdef STDC_HEADERS #include /* MODULE TYPE: (sys) */ #include /* MODULE TYPE: (sys) */ -#include /* MODULE TYPE: (sys) */ #endif /*****************************************************************************/ /* MODULE INTERFACE: */ /*****************************************************************************/ #include "bitvect.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* ToolBox.h */ #define and && /* logical (boolean) operators: lower case */ diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index 6db2d777..407f01ec 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Bytecode utility functions * * Copyright (C) 2001 Peter Johnson @@ -19,35 +19,16 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#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 -#endif -RCSID("$IdPath$"); struct effaddr { expr *disp; /* address displacement */ diff --git a/libyasm/bytecode.h b/libyasm/bytecode.h index d2cd383c..3683bae9 100644 --- a/libyasm/bytecode.h +++ b/libyasm/bytecode.h @@ -22,31 +22,10 @@ #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, @@ -56,7 +35,7 @@ typedef enum { JR_NEAR_FORCED } jmprel_opcode_sel; -typedef struct targetval_s { +typedef struct targetval { expr *val; jmprel_opcode_sel op_sel; diff --git a/libyasm/coretype.h b/libyasm/coretype.h new file mode 100644 index 00000000..ada1ffb1 --- /dev/null +++ b/libyasm/coretype.h @@ -0,0 +1,69 @@ +/* $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 diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index 4f008386..4f66a1c0 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Error and warning reporting and related functions. * * Copyright (C) 2001 Peter Johnson @@ -19,23 +19,15 @@ * 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 #include #ifdef STDC_HEADERS -# include # include -# include #endif -#include -#define _(String) gettext(String) #ifdef gettext_noop #define N_(String) gettext_noop(String) #else @@ -45,11 +37,6 @@ #include "globals.h" #include "errwarn.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Total error count for entire assembler run. * Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */ diff --git a/libyasm/expr.c b/libyasm/expr.c index 17a73738..c49d1846 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Expression handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,26 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif +RCSID("$IdPath$"); #include "bitvect.h" @@ -49,11 +31,6 @@ #include "expr.h" #include "symrec.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Types listed in canonical sorting order. See expr_order_terms(). */ typedef enum { diff --git a/libyasm/expr.h b/libyasm/expr.h index 25266d59..3f526e90 100644 --- a/libyasm/expr.h +++ b/libyasm/expr.h @@ -22,58 +22,8 @@ #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 *); diff --git a/libyasm/file.c b/libyasm/file.c index acd1a74f..93347df0 100644 --- a/libyasm/file.c +++ b/libyasm/file.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Little-endian file functions. * * Copyright (C) 2001 Peter Johnson @@ -19,17 +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 */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" - -#include +RCSID("$IdPath$"); #include "file.h" -RCSID("$IdPath$"); size_t fwrite_short(unsigned short val, FILE *f) diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c index 1f173d14..54a9759f 100644 --- a/libyasm/floatnum.c +++ b/libyasm/floatnum.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Floating point number functions. * * Copyright (C) 2001 Peter Johnson @@ -21,38 +21,17 @@ * 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 #include -#ifdef STDC_HEADERS -# include -#endif - -#include -#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 -#endif - -RCSID("$IdPath$"); /* 97-bit internal floating point format: * 0000000s eeeeeeee eeeeeeee m.....................................m diff --git a/libyasm/floatnum.h b/libyasm/floatnum.h index cf265b2a..5ac4b51a 100644 --- a/libyasm/floatnum.h +++ b/libyasm/floatnum.h @@ -24,41 +24,6 @@ #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); diff --git a/libyasm/intnum.c b/libyasm/intnum.c index 9b09d9b2..bcd1c485 100644 --- a/libyasm/intnum.c +++ b/libyasm/intnum.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Integer number functions. * * Copyright (C) 2001 Peter Johnson @@ -19,33 +19,17 @@ * 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 #include -#ifdef STDC_HEADERS -# include -#endif - -#include -#define _(String) gettext(String) - #include "bitvect.h" #include "file.h" #include "errwarn.h" #include "intnum.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define BITVECT_ALLOC_SIZE 80 diff --git a/libyasm/intnum.h b/libyasm/intnum.h index 5aec7389..cd104f28 100644 --- a/libyasm/intnum.h +++ b/libyasm/intnum.h @@ -22,41 +22,6 @@ #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); diff --git a/libyasm/linemgr.c b/libyasm/linemgr.c index 03ef07e0..c21436a7 100644 --- a/libyasm/linemgr.c +++ b/libyasm/linemgr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Global variables * * Copyright (C) 2001 Peter Johnson @@ -19,21 +19,13 @@ * 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 +#include "ternary.h" #include "globals.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); const char *in_filename = (const char *)NULL; unsigned int line_number = 1; diff --git a/libyasm/mergesort.c b/libyasm/mergesort.c index 6091983b..3f8a428b 100644 --- a/libyasm/mergesort.c +++ b/libyasm/mergesort.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * mergesort() implementation for systems that don't have it. * * Copyright (c) 1992, 1993 @@ -31,19 +31,10 @@ * 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 -#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 */ diff --git a/libyasm/objfmt.h b/libyasm/objfmt.h index cd584de3..ea820306 100644 --- a/libyasm/objfmt.h +++ b/libyasm/objfmt.h @@ -23,7 +23,7 @@ #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; @@ -39,18 +39,18 @@ typedef struct objfmt_s { /* 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; diff --git a/libyasm/optimizer.h b/libyasm/optimizer.h index 4b7e9d0f..0f52e087 100644 --- a/libyasm/optimizer.h +++ b/libyasm/optimizer.h @@ -23,7 +23,7 @@ #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; @@ -35,7 +35,7 @@ typedef struct optimizer_s { * 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; diff --git a/libyasm/parser.h b/libyasm/parser.h index b66d317b..232bf393 100644 --- a/libyasm/parser.h +++ b/libyasm/parser.h @@ -23,7 +23,7 @@ #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; @@ -52,8 +52,8 @@ typedef struct parser_s { * 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 */ diff --git a/libyasm/preproc.h b/libyasm/preproc.h index 760afc94..fa64ecd1 100644 --- a/libyasm/preproc.h +++ b/libyasm/preproc.h @@ -23,7 +23,7 @@ #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; @@ -44,7 +44,7 @@ typedef struct preproc_s { /* 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; diff --git a/libyasm/section.c b/libyasm/section.c index 90608419..0ebccb7e 100644 --- a/libyasm/section.c +++ b/libyasm/section.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Section utility functions * * Copyright (C) 2001 Peter Johnson @@ -19,25 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#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" @@ -47,11 +30,6 @@ #include "section.h" #include "objfmt.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); struct section { STAILQ_ENTRY(section) link; diff --git a/libyasm/section.h b/libyasm/section.h index ff99fb9d..43e47bd1 100644 --- a/libyasm/section.h +++ b/libyasm/section.h @@ -22,18 +22,11 @@ #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); diff --git a/libyasm/strcasecmp.c b/libyasm/strcasecmp.c index b0aa443c..15971ec4 100644 --- a/libyasm/strcasecmp.c +++ b/libyasm/strcasecmp.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * strcasecmp() implementation for systems that don't have it or stricmp() * or strcmpi(). * @@ -29,25 +29,17 @@ * 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 -# include -#endif +#include int strcasecmp(const char *s1, const char *s2) diff --git a/libyasm/strsep.c b/libyasm/strsep.c index 64a71889..4e35c407 100644 --- a/libyasm/strsep.c +++ b/libyasm/strsep.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * strsep() implementation for systems that don't have it. * * Copyright (c) 1990, 1993 @@ -28,24 +28,14 @@ * 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 - -#ifdef STDC_HEADERS -#include -#endif - -RCSID("$IdPath$"); /* * Get next token from string *stringp, where tokens are possibly-empty diff --git a/libyasm/symrec.c b/libyasm/symrec.c index aad043af..eccb034f 100644 --- a/libyasm/symrec.c +++ b/libyasm/symrec.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Symbol table handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,20 +19,10 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#define _(String) gettext(String) +#include "ternary.h" #include "globals.h" #include "errwarn.h" @@ -43,11 +33,6 @@ #include "bytecode.h" #include "section.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* DEFINED is set with EXTERN and COMMON below */ typedef enum { diff --git a/libyasm/symrec.h b/libyasm/symrec.h index c4a94f14..11ff4a09 100644 --- a/libyasm/symrec.h +++ b/libyasm/symrec.h @@ -22,21 +22,6 @@ #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 */ @@ -45,11 +30,6 @@ typedef enum { 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. */ diff --git a/libyasm/tests/memexpr_test.c b/libyasm/tests/memexpr_test.c index 6e0ae89d..09e017fa 100644 --- a/libyasm/tests/memexpr_test.c +++ b/libyasm/tests/memexpr_test.c @@ -18,16 +18,7 @@ * 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 -# include -#endif - -#include +#include "util.h" #include "check.h" diff --git a/libyasm/util.h b/libyasm/util.h index a56c3e9c..5d0bf8d7 100644 --- a/libyasm/util.h +++ b/libyasm/util.h @@ -1,5 +1,7 @@ /* $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 * @@ -22,10 +24,21 @@ #ifndef YASM_UTIL_H #define YASM_UTIL_H +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + #ifdef STDC_HEADERS # include +# include +# include #endif +#include +#define _(String) gettext(String) + #if !defined(HAVE_MERGESORT) int mergesort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); @@ -62,19 +75,6 @@ int strncasecmp(const char *s1, const char *s2, size_t n); # 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 #endif @@ -93,4 +93,19 @@ void xfree(void *p); # endif #endif +#ifdef DMALLOC +# include +#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 diff --git a/libyasm/xmalloc.c b/libyasm/xmalloc.c index 77353c19..da38bd92 100644 --- a/libyasm/xmalloc.c +++ b/libyasm/xmalloc.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Memory allocation routines with error checking. Idea from GNU libiberty. * * Copyright (C) 2001 Peter Johnson @@ -19,24 +19,13 @@ * 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 -#endif - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "errwarn.h" -#ifndef DMALLOC -RCSID("$IdPath$"); +#ifndef DMALLOC void * xmalloc(size_t size) diff --git a/libyasm/xstrdup.c b/libyasm/xstrdup.c index c0b30272..77cccba0 100644 --- a/libyasm/xstrdup.c +++ b/libyasm/xstrdup.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * strdup() implementation with error checking (using xmalloc). * * Copyright (c) 1988, 1993 @@ -28,21 +28,16 @@ * 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 -# include -#else +#ifndef STDC_HEADERS size_t strlen(const char *); # ifndef HAVE_MEMCPY void bcopy(const void *, void *, size_t); @@ -54,8 +49,6 @@ void memcpy(void *, const void *, size_t); #ifndef DMALLOC -RCSID("$IdPath$"); - char * xstrdup(const char *str) { diff --git a/mergesort.c b/mergesort.c index 6091983b..3f8a428b 100644 --- a/mergesort.c +++ b/mergesort.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * mergesort() implementation for systems that don't have it. * * Copyright (c) 1992, 1993 @@ -31,19 +31,10 @@ * 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 -#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 */ diff --git a/modules/arch/x86/expr.c b/modules/arch/x86/expr.c index 17a73738..c49d1846 100644 --- a/modules/arch/x86/expr.c +++ b/modules/arch/x86/expr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Expression handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,26 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif +RCSID("$IdPath$"); #include "bitvect.h" @@ -49,11 +31,6 @@ #include "expr.h" #include "symrec.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Types listed in canonical sorting order. See expr_order_terms(). */ typedef enum { diff --git a/modules/arch/x86/x86expr.c b/modules/arch/x86/x86expr.c index 17a73738..c49d1846 100644 --- a/modules/arch/x86/x86expr.c +++ b/modules/arch/x86/x86expr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Expression handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,26 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif +RCSID("$IdPath$"); #include "bitvect.h" @@ -49,11 +31,6 @@ #include "expr.h" #include "symrec.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Types listed in canonical sorting order. See expr_order_terms(). */ typedef enum { diff --git a/modules/objfmts/dbg/dbg-objfmt.c b/modules/objfmts/dbg/dbg-objfmt.c index 9c9b983b..f5ce6b69 100644 --- a/modules/objfmts/dbg/dbg-objfmt.c +++ b/modules/objfmts/dbg/dbg-objfmt.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging object format (used to debug object format module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,17 +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 */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" - -#include +RCSID("$IdPath$"); #include "objfmt.h" -RCSID("$IdPath$"); static int dbg_objfmt_is_valid_section(const char *name) diff --git a/modules/objfmts/dbg/objfmt.c b/modules/objfmts/dbg/objfmt.c index 9c9b983b..f5ce6b69 100644 --- a/modules/objfmts/dbg/objfmt.c +++ b/modules/objfmts/dbg/objfmt.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging object format (used to debug object format module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,17 +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 */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" - -#include +RCSID("$IdPath$"); #include "objfmt.h" -RCSID("$IdPath$"); static int dbg_objfmt_is_valid_section(const char *name) diff --git a/modules/optimizers/basic/basic-optimizer.c b/modules/optimizers/basic/basic-optimizer.c index d6535d94..763f3864 100644 --- a/modules/optimizers/basic/basic-optimizer.c +++ b/modules/optimizers/basic/basic-optimizer.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging optimizer (used to debug optimizer module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,15 +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 */ -#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 = { diff --git a/modules/optimizers/basic/optimizer.c b/modules/optimizers/basic/optimizer.c index d6535d94..763f3864 100644 --- a/modules/optimizers/basic/optimizer.c +++ b/modules/optimizers/basic/optimizer.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging optimizer (used to debug optimizer module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,15 +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 */ -#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 = { diff --git a/modules/optimizers/dbg/optimizer.c b/modules/optimizers/dbg/optimizer.c index d6535d94..763f3864 100644 --- a/modules/optimizers/dbg/optimizer.c +++ b/modules/optimizers/dbg/optimizer.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging optimizer (used to debug optimizer module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,15 +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 */ -#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 = { diff --git a/modules/parsers/nasm/bison.y.in b/modules/parsers/nasm/bison.y.in index 4b3754e4..54893a76 100644 --- a/modules/parsers/nasm/bison.y.in +++ b/modules/parsers/nasm/bison.y.in @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,21 +20,13 @@ * 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 -# include # include #endif -#include -#define _(String) gettext(String) - #include "bitvect.h" #include "globals.h" @@ -48,11 +40,6 @@ #include "section.h" #include "objfmt.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define YYDEBUG 1 diff --git a/modules/parsers/nasm/nasm-bison.y b/modules/parsers/nasm/nasm-bison.y index 4b3754e4..54893a76 100644 --- a/modules/parsers/nasm/nasm-bison.y +++ b/modules/parsers/nasm/nasm-bison.y @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,21 +20,13 @@ * 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 -# include # include #endif -#include -#define _(String) gettext(String) - #include "bitvect.h" #include "globals.h" @@ -48,11 +40,6 @@ #include "section.h" #include "objfmt.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define YYDEBUG 1 diff --git a/modules/parsers/nasm/nasm-parser.c b/modules/parsers/nasm/nasm-parser.c index fffa8bdb..c1bab7ed 100644 --- a/modules/parsers/nasm/nasm-parser.c +++ b/modules/parsers/nasm/nasm-parser.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,27 +19,16 @@ * 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 +RCSID("$IdPath$"); #include "errwarn.h" -#include "bytecode.h" #include "section.h" #include "objfmt.h" #include "preproc.h" #include "parser.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); extern FILE *nasm_parser_in; extern int nasm_parser_debug; diff --git a/modules/parsers/nasm/parser.c b/modules/parsers/nasm/parser.c index fffa8bdb..c1bab7ed 100644 --- a/modules/parsers/nasm/parser.c +++ b/modules/parsers/nasm/parser.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,27 +19,16 @@ * 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 +RCSID("$IdPath$"); #include "errwarn.h" -#include "bytecode.h" #include "section.h" #include "objfmt.h" #include "preproc.h" #include "parser.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); extern FILE *nasm_parser_in; extern int nasm_parser_debug; diff --git a/modules/parsers/nasm/token.l.in b/modules/parsers/nasm/token.l.in index 6973afbe..8c1d6834 100644 --- a/modules/parsers/nasm/token.l.in +++ b/modules/parsers/nasm/token.l.in @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible lex lexer * * Copyright (C) 2001 Peter Johnson @@ -20,19 +20,8 @@ * 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 -# include -#endif - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "bitvect.h" @@ -46,11 +35,6 @@ #include "bison.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define YY_NEVER_INTERACTIVE 1 diff --git a/modules/preprocs/raw/preproc.c b/modules/preprocs/raw/preproc.c index c655e4df..8c692c24 100644 --- a/modules/preprocs/raw/preproc.c +++ b/modules/preprocs/raw/preproc.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Raw preprocessor (preforms NO preprocessing) * * Copyright (C) 2001 Peter Johnson @@ -19,23 +19,13 @@ * 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 - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "errwarn.h" -#include "objfmt.h" #include "preproc.h" -RCSID("$IdPath$"); static int is_interactive; static FILE *in; diff --git a/modules/preprocs/raw/raw-preproc.c b/modules/preprocs/raw/raw-preproc.c index c655e4df..8c692c24 100644 --- a/modules/preprocs/raw/raw-preproc.c +++ b/modules/preprocs/raw/raw-preproc.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Raw preprocessor (preforms NO preprocessing) * * Copyright (C) 2001 Peter Johnson @@ -19,23 +19,13 @@ * 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 - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "errwarn.h" -#include "objfmt.h" #include "preproc.h" -RCSID("$IdPath$"); static int is_interactive; static FILE *in; diff --git a/src/arch/x86/expr.c b/src/arch/x86/expr.c index 17a73738..c49d1846 100644 --- a/src/arch/x86/expr.c +++ b/src/arch/x86/expr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Expression handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,26 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif +RCSID("$IdPath$"); #include "bitvect.h" @@ -49,11 +31,6 @@ #include "expr.h" #include "symrec.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Types listed in canonical sorting order. See expr_order_terms(). */ typedef enum { diff --git a/src/arch/x86/x86expr.c b/src/arch/x86/x86expr.c index 17a73738..c49d1846 100644 --- a/src/arch/x86/x86expr.c +++ b/src/arch/x86/x86expr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Expression handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,26 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif +RCSID("$IdPath$"); #include "bitvect.h" @@ -49,11 +31,6 @@ #include "expr.h" #include "symrec.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Types listed in canonical sorting order. See expr_order_terms(). */ typedef enum { diff --git a/src/bitvect.c b/src/bitvect.c index cedec924..6ed5d189 100644 --- a/src/bitvect.c +++ b/src/bitvect.c @@ -1,30 +1,21 @@ -/* $IdPath$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" +RCSID("$IdPath$"); /*****************************************************************************/ /* MODULE NAME: BitVector.c MODULE TYPE: (adt) */ /*****************************************************************************/ /* MODULE IMPORTS: */ /*****************************************************************************/ +#include /* MODULE TYPE: (sys) */ #ifdef STDC_HEADERS #include /* MODULE TYPE: (sys) */ #include /* MODULE TYPE: (sys) */ -#include /* MODULE TYPE: (sys) */ #endif /*****************************************************************************/ /* MODULE INTERFACE: */ /*****************************************************************************/ #include "bitvect.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* ToolBox.h */ #define and && /* logical (boolean) operators: lower case */ diff --git a/src/bytecode.c b/src/bytecode.c index 6db2d777..407f01ec 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Bytecode utility functions * * Copyright (C) 2001 Peter Johnson @@ -19,35 +19,16 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#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 -#endif -RCSID("$IdPath$"); struct effaddr { expr *disp; /* address displacement */ diff --git a/src/bytecode.h b/src/bytecode.h index d2cd383c..3683bae9 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -22,31 +22,10 @@ #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, @@ -56,7 +35,7 @@ typedef enum { JR_NEAR_FORCED } jmprel_opcode_sel; -typedef struct targetval_s { +typedef struct targetval { expr *val; jmprel_opcode_sel op_sel; diff --git a/src/coretype.h b/src/coretype.h new file mode 100644 index 00000000..ada1ffb1 --- /dev/null +++ b/src/coretype.h @@ -0,0 +1,69 @@ +/* $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 diff --git a/src/errwarn.c b/src/errwarn.c index 4f008386..4f66a1c0 100644 --- a/src/errwarn.c +++ b/src/errwarn.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Error and warning reporting and related functions. * * Copyright (C) 2001 Peter Johnson @@ -19,23 +19,15 @@ * 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 #include #ifdef STDC_HEADERS -# include # include -# include #endif -#include -#define _(String) gettext(String) #ifdef gettext_noop #define N_(String) gettext_noop(String) #else @@ -45,11 +37,6 @@ #include "globals.h" #include "errwarn.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Total error count for entire assembler run. * Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */ diff --git a/src/expr.c b/src/expr.c index 17a73738..c49d1846 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Expression handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,26 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif +RCSID("$IdPath$"); #include "bitvect.h" @@ -49,11 +31,6 @@ #include "expr.h" #include "symrec.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Types listed in canonical sorting order. See expr_order_terms(). */ typedef enum { diff --git a/src/expr.h b/src/expr.h index 25266d59..3f526e90 100644 --- a/src/expr.h +++ b/src/expr.h @@ -22,58 +22,8 @@ #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 *); diff --git a/src/file.c b/src/file.c index acd1a74f..93347df0 100644 --- a/src/file.c +++ b/src/file.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Little-endian file functions. * * Copyright (C) 2001 Peter Johnson @@ -19,17 +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 */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" - -#include +RCSID("$IdPath$"); #include "file.h" -RCSID("$IdPath$"); size_t fwrite_short(unsigned short val, FILE *f) diff --git a/src/floatnum.c b/src/floatnum.c index 1f173d14..54a9759f 100644 --- a/src/floatnum.c +++ b/src/floatnum.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Floating point number functions. * * Copyright (C) 2001 Peter Johnson @@ -21,38 +21,17 @@ * 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 #include -#ifdef STDC_HEADERS -# include -#endif - -#include -#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 -#endif - -RCSID("$IdPath$"); /* 97-bit internal floating point format: * 0000000s eeeeeeee eeeeeeee m.....................................m diff --git a/src/floatnum.h b/src/floatnum.h index cf265b2a..5ac4b51a 100644 --- a/src/floatnum.h +++ b/src/floatnum.h @@ -24,41 +24,6 @@ #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); diff --git a/src/globals.c b/src/globals.c index 03ef07e0..c21436a7 100644 --- a/src/globals.c +++ b/src/globals.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Global variables * * Copyright (C) 2001 Peter Johnson @@ -19,21 +19,13 @@ * 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 +#include "ternary.h" #include "globals.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); const char *in_filename = (const char *)NULL; unsigned int line_number = 1; diff --git a/src/intnum.c b/src/intnum.c index 9b09d9b2..bcd1c485 100644 --- a/src/intnum.c +++ b/src/intnum.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Integer number functions. * * Copyright (C) 2001 Peter Johnson @@ -19,33 +19,17 @@ * 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 #include -#ifdef STDC_HEADERS -# include -#endif - -#include -#define _(String) gettext(String) - #include "bitvect.h" #include "file.h" #include "errwarn.h" #include "intnum.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define BITVECT_ALLOC_SIZE 80 diff --git a/src/intnum.h b/src/intnum.h index 5aec7389..cd104f28 100644 --- a/src/intnum.h +++ b/src/intnum.h @@ -22,41 +22,6 @@ #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); diff --git a/src/linemgr.c b/src/linemgr.c index 03ef07e0..c21436a7 100644 --- a/src/linemgr.c +++ b/src/linemgr.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Global variables * * Copyright (C) 2001 Peter Johnson @@ -19,21 +19,13 @@ * 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 +#include "ternary.h" #include "globals.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); const char *in_filename = (const char *)NULL; unsigned int line_number = 1; diff --git a/src/main.c b/src/main.c index 45e76049..0b4d711f 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Program entry point, command line parsing * * Copyright (C) 2001 Peter Johnson @@ -19,21 +19,9 @@ * 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 - -#ifdef STDC_HEADERS -# include -# include -#endif - -#include -#define _(String) gettext(String) #ifdef gettext_noop #define N_(String) gettext_noop(String) #else @@ -53,11 +41,6 @@ #include "preproc.h" #include "parser.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #ifndef countof #define countof(x,y) (sizeof(x)/sizeof(y)) diff --git a/src/mergesort.c b/src/mergesort.c index 6091983b..3f8a428b 100644 --- a/src/mergesort.c +++ b/src/mergesort.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * mergesort() implementation for systems that don't have it. * * Copyright (c) 1992, 1993 @@ -31,19 +31,10 @@ * 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 -#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 */ diff --git a/src/objfmt.h b/src/objfmt.h index cd584de3..ea820306 100644 --- a/src/objfmt.h +++ b/src/objfmt.h @@ -23,7 +23,7 @@ #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; @@ -39,18 +39,18 @@ typedef struct objfmt_s { /* 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; diff --git a/src/objfmts/dbg/dbg-objfmt.c b/src/objfmts/dbg/dbg-objfmt.c index 9c9b983b..f5ce6b69 100644 --- a/src/objfmts/dbg/dbg-objfmt.c +++ b/src/objfmts/dbg/dbg-objfmt.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging object format (used to debug object format module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,17 +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 */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" - -#include +RCSID("$IdPath$"); #include "objfmt.h" -RCSID("$IdPath$"); static int dbg_objfmt_is_valid_section(const char *name) diff --git a/src/objfmts/dbg/objfmt.c b/src/objfmts/dbg/objfmt.c index 9c9b983b..f5ce6b69 100644 --- a/src/objfmts/dbg/objfmt.c +++ b/src/objfmts/dbg/objfmt.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging object format (used to debug object format module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,17 +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 */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "util.h" - -#include +RCSID("$IdPath$"); #include "objfmt.h" -RCSID("$IdPath$"); static int dbg_objfmt_is_valid_section(const char *name) diff --git a/src/optimizer.h b/src/optimizer.h index 4b7e9d0f..0f52e087 100644 --- a/src/optimizer.h +++ b/src/optimizer.h @@ -23,7 +23,7 @@ #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; @@ -35,7 +35,7 @@ typedef struct optimizer_s { * 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; diff --git a/src/optimizers/basic/basic-optimizer.c b/src/optimizers/basic/basic-optimizer.c index d6535d94..763f3864 100644 --- a/src/optimizers/basic/basic-optimizer.c +++ b/src/optimizers/basic/basic-optimizer.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging optimizer (used to debug optimizer module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,15 +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 */ -#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 = { diff --git a/src/optimizers/basic/optimizer.c b/src/optimizers/basic/optimizer.c index d6535d94..763f3864 100644 --- a/src/optimizers/basic/optimizer.c +++ b/src/optimizers/basic/optimizer.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging optimizer (used to debug optimizer module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,15 +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 */ -#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 = { diff --git a/src/optimizers/dbg/optimizer.c b/src/optimizers/dbg/optimizer.c index d6535d94..763f3864 100644 --- a/src/optimizers/dbg/optimizer.c +++ b/src/optimizers/dbg/optimizer.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Debugging optimizer (used to debug optimizer module interface) * * Copyright (C) 2001 Peter Johnson @@ -19,15 +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 */ -#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 = { diff --git a/src/options.c b/src/options.c index efe7882e..5eef8b24 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Generic Options Support Header File * * Copyright (c) 2001 Stanislav Karchebny @@ -27,25 +27,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#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" diff --git a/src/parser.c b/src/parser.c index 3b7d360e..4a654a56 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Generic functions for all parsers * * Copyright (C) 2001 Peter Johnson @@ -19,33 +19,14 @@ * 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 - -#ifdef STDC_HEADERS -# include -#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 -#endif - -RCSID("$IdPath$"); /* NULL-terminated list of all available parsers. * Someday change this if we dynamically load parsers at runtime. diff --git a/src/parser.h b/src/parser.h index b66d317b..232bf393 100644 --- a/src/parser.h +++ b/src/parser.h @@ -23,7 +23,7 @@ #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; @@ -52,8 +52,8 @@ typedef struct parser_s { * 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 */ diff --git a/src/parsers/nasm/bison.y.in b/src/parsers/nasm/bison.y.in index 4b3754e4..54893a76 100644 --- a/src/parsers/nasm/bison.y.in +++ b/src/parsers/nasm/bison.y.in @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,21 +20,13 @@ * 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 -# include # include #endif -#include -#define _(String) gettext(String) - #include "bitvect.h" #include "globals.h" @@ -48,11 +40,6 @@ #include "section.h" #include "objfmt.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define YYDEBUG 1 diff --git a/src/parsers/nasm/nasm-bison.y b/src/parsers/nasm/nasm-bison.y index 4b3754e4..54893a76 100644 --- a/src/parsers/nasm/nasm-bison.y +++ b/src/parsers/nasm/nasm-bison.y @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,21 +20,13 @@ * 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 -# include # include #endif -#include -#define _(String) gettext(String) - #include "bitvect.h" #include "globals.h" @@ -48,11 +40,6 @@ #include "section.h" #include "objfmt.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define YYDEBUG 1 diff --git a/src/parsers/nasm/nasm-parser.c b/src/parsers/nasm/nasm-parser.c index fffa8bdb..c1bab7ed 100644 --- a/src/parsers/nasm/nasm-parser.c +++ b/src/parsers/nasm/nasm-parser.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,27 +19,16 @@ * 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 +RCSID("$IdPath$"); #include "errwarn.h" -#include "bytecode.h" #include "section.h" #include "objfmt.h" #include "preproc.h" #include "parser.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); extern FILE *nasm_parser_in; extern int nasm_parser_debug; diff --git a/src/parsers/nasm/parser.c b/src/parsers/nasm/parser.c index fffa8bdb..c1bab7ed 100644 --- a/src/parsers/nasm/parser.c +++ b/src/parsers/nasm/parser.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,27 +19,16 @@ * 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 +RCSID("$IdPath$"); #include "errwarn.h" -#include "bytecode.h" #include "section.h" #include "objfmt.h" #include "preproc.h" #include "parser.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); extern FILE *nasm_parser_in; extern int nasm_parser_debug; diff --git a/src/parsers/nasm/token.l.in b/src/parsers/nasm/token.l.in index 6973afbe..8c1d6834 100644 --- a/src/parsers/nasm/token.l.in +++ b/src/parsers/nasm/token.l.in @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * NASM-compatible lex lexer * * Copyright (C) 2001 Peter Johnson @@ -20,19 +20,8 @@ * 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 -# include -#endif - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "bitvect.h" @@ -46,11 +35,6 @@ #include "bison.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); #define YY_NEVER_INTERACTIVE 1 diff --git a/src/preproc.h b/src/preproc.h index 760afc94..fa64ecd1 100644 --- a/src/preproc.h +++ b/src/preproc.h @@ -23,7 +23,7 @@ #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; @@ -44,7 +44,7 @@ typedef struct preproc_s { /* 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; diff --git a/src/preprocs/raw/preproc.c b/src/preprocs/raw/preproc.c index c655e4df..8c692c24 100644 --- a/src/preprocs/raw/preproc.c +++ b/src/preprocs/raw/preproc.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Raw preprocessor (preforms NO preprocessing) * * Copyright (C) 2001 Peter Johnson @@ -19,23 +19,13 @@ * 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 - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "errwarn.h" -#include "objfmt.h" #include "preproc.h" -RCSID("$IdPath$"); static int is_interactive; static FILE *in; diff --git a/src/preprocs/raw/raw-preproc.c b/src/preprocs/raw/raw-preproc.c index c655e4df..8c692c24 100644 --- a/src/preprocs/raw/raw-preproc.c +++ b/src/preprocs/raw/raw-preproc.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Raw preprocessor (preforms NO preprocessing) * * Copyright (C) 2001 Peter Johnson @@ -19,23 +19,13 @@ * 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 - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "errwarn.h" -#include "objfmt.h" #include "preproc.h" -RCSID("$IdPath$"); static int is_interactive; static FILE *in; diff --git a/src/section.c b/src/section.c index 90608419..0ebccb7e 100644 --- a/src/section.c +++ b/src/section.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Section utility functions * * Copyright (C) 2001 Peter Johnson @@ -19,25 +19,8 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#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" @@ -47,11 +30,6 @@ #include "section.h" #include "objfmt.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); struct section { STAILQ_ENTRY(section) link; diff --git a/src/section.h b/src/section.h index ff99fb9d..43e47bd1 100644 --- a/src/section.h +++ b/src/section.h @@ -22,18 +22,11 @@ #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); diff --git a/src/strcasecmp.c b/src/strcasecmp.c index b0aa443c..15971ec4 100644 --- a/src/strcasecmp.c +++ b/src/strcasecmp.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * strcasecmp() implementation for systems that don't have it or stricmp() * or strcmpi(). * @@ -29,25 +29,17 @@ * 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 -# include -#endif +#include int strcasecmp(const char *s1, const char *s2) diff --git a/src/strsep.c b/src/strsep.c index 64a71889..4e35c407 100644 --- a/src/strsep.c +++ b/src/strsep.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * strsep() implementation for systems that don't have it. * * Copyright (c) 1990, 1993 @@ -28,24 +28,14 @@ * 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 - -#ifdef STDC_HEADERS -#include -#endif - -RCSID("$IdPath$"); /* * Get next token from string *stringp, where tokens are possibly-empty diff --git a/src/symrec.c b/src/symrec.c index aad043af..eccb034f 100644 --- a/src/symrec.c +++ b/src/symrec.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Symbol table handling * * Copyright (C) 2001 Michael Urman, Peter Johnson @@ -19,20 +19,10 @@ * 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 - -#ifdef STDC_HEADERS -# include -#endif - -#include -#define _(String) gettext(String) +#include "ternary.h" #include "globals.h" #include "errwarn.h" @@ -43,11 +33,6 @@ #include "bytecode.h" #include "section.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* DEFINED is set with EXTERN and COMMON below */ typedef enum { diff --git a/src/symrec.h b/src/symrec.h index c4a94f14..11ff4a09 100644 --- a/src/symrec.h +++ b/src/symrec.h @@ -22,21 +22,6 @@ #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 */ @@ -45,11 +30,6 @@ typedef enum { 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. */ diff --git a/src/ternary.c b/src/ternary.c index 9447bab9..7d5af590 100644 --- a/src/ternary.c +++ b/src/ternary.c @@ -20,23 +20,13 @@ 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 +RCSID("$IdPath$"); #include "errwarn.h" #include "ternary.h" -#ifdef DMALLOC -# include -#endif - -RCSID("$IdPath$"); /* Non-recursive so we don't waste stack space/time on large insertions. */ diff --git a/src/tests/memexpr_test.c b/src/tests/memexpr_test.c index 6e0ae89d..09e017fa 100644 --- a/src/tests/memexpr_test.c +++ b/src/tests/memexpr_test.c @@ -18,16 +18,7 @@ * 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 -# include -#endif - -#include +#include "util.h" #include "check.h" diff --git a/src/util.h b/src/util.h index a56c3e9c..5d0bf8d7 100644 --- a/src/util.h +++ b/src/util.h @@ -1,5 +1,7 @@ /* $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 * @@ -22,10 +24,21 @@ #ifndef YASM_UTIL_H #define YASM_UTIL_H +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + #ifdef STDC_HEADERS # include +# include +# include #endif +#include +#define _(String) gettext(String) + #if !defined(HAVE_MERGESORT) int mergesort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); @@ -62,19 +75,6 @@ int strncasecmp(const char *s1, const char *s2, size_t n); # 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 #endif @@ -93,4 +93,19 @@ void xfree(void *p); # endif #endif +#ifdef DMALLOC +# include +#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 diff --git a/src/xmalloc.c b/src/xmalloc.c index 77353c19..da38bd92 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * Memory allocation routines with error checking. Idea from GNU libiberty. * * Copyright (C) 2001 Peter Johnson @@ -19,24 +19,13 @@ * 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 -#endif - -#include -#define _(String) gettext(String) +RCSID("$IdPath$"); #include "errwarn.h" -#ifndef DMALLOC -RCSID("$IdPath$"); +#ifndef DMALLOC void * xmalloc(size_t size) diff --git a/src/xstrdup.c b/src/xstrdup.c index c0b30272..77cccba0 100644 --- a/src/xstrdup.c +++ b/src/xstrdup.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * strdup() implementation with error checking (using xmalloc). * * Copyright (c) 1988, 1993 @@ -28,21 +28,16 @@ * 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 -# include -#else +#ifndef STDC_HEADERS size_t strlen(const char *); # ifndef HAVE_MEMCPY void bcopy(const void *, void *, size_t); @@ -54,8 +49,6 @@ void memcpy(void *, const void *, size_t); #ifndef DMALLOC -RCSID("$IdPath$"); - char * xstrdup(const char *str) { diff --git a/strsep.c b/strsep.c index 64a71889..4e35c407 100644 --- a/strsep.c +++ b/strsep.c @@ -1,4 +1,4 @@ -/* $IdPath$ +/* * strsep() implementation for systems that don't have it. * * Copyright (c) 1990, 1993 @@ -28,24 +28,14 @@ * 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 - -#ifdef STDC_HEADERS -#include -#endif - -RCSID("$IdPath$"); /* * Get next token from string *stringp, where tokens are possibly-empty diff --git a/util.h b/util.h index a56c3e9c..5d0bf8d7 100644 --- a/util.h +++ b/util.h @@ -1,5 +1,7 @@ /* $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 * @@ -22,10 +24,21 @@ #ifndef YASM_UTIL_H #define YASM_UTIL_H +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + #ifdef STDC_HEADERS # include +# include +# include #endif +#include +#define _(String) gettext(String) + #if !defined(HAVE_MERGESORT) int mergesort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); @@ -62,19 +75,6 @@ int strncasecmp(const char *s1, const char *s2, size_t n); # 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 #endif @@ -93,4 +93,19 @@ void xfree(void *p); # endif #endif +#ifdef DMALLOC +# include +#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