# HG changeset patch # User lost # Date 1265695196 0 # Node ID be63116281b0bd0325497b862cfb0a17dc6814ec # Parent 473ed9b353eba2e09e34bc1f814dbcea2f3810df Created lwlib folder and added first bits to it diff -r 473ed9b353eb -r be63116281b0 Makefile.am --- a/Makefile.am Tue Feb 09 05:33:35 2010 +0000 +++ b/Makefile.am Tue Feb 09 05:59:56 2010 +0000 @@ -1,4 +1,4 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = lib lwasm -DIST_SUBDIRS = lib lwasm +SUBDIRS = lib lwlib lwasm +DIST_SUBDIRS = lib lwlib lwasm EXTRA_DIST = m4/gnulib-cache.m4 diff -r 473ed9b353eb -r be63116281b0 configure.ac --- a/configure.ac Tue Feb 09 05:33:35 2010 +0000 +++ b/configure.ac Tue Feb 09 05:59:56 2010 +0000 @@ -8,6 +8,7 @@ AC_CONFIG_FILES([ Makefile lib/Makefile + lwlib/Makefile lwasm/Makefile ]) AC_OUTPUT diff -r 473ed9b353eb -r be63116281b0 lwasm/Makefile.am --- a/lwasm/Makefile.am Tue Feb 09 05:33:35 2010 +0000 +++ b/lwasm/Makefile.am Tue Feb 09 05:59:56 2010 +0000 @@ -1,5 +1,5 @@ -AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib +AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_builddir)/lwlib -I$(top_srcdir)/lwlib bin_PROGRAMS = lwasm lwasm_SOURCES = main.c -lwasm_LDADD = -L$(top_builddir)/lib -L$(top_srcdir)/lib -lgnu +lwasm_LDADD = -L$(top_builddir)/lib -L$(top_srcdir)/lib -L$(top_builddir)/lwlib -L$(top_srcdir)/lwlib -lgnu -llw EXTRA_DIST = lwasm.h diff -r 473ed9b353eb -r be63116281b0 lwasm/lwasm.h --- a/lwasm/lwasm.h Tue Feb 09 05:33:35 2010 +0000 +++ b/lwasm/lwasm.h Tue Feb 09 05:59:56 2010 +0000 @@ -22,6 +22,8 @@ #ifndef ___lwasm_h_seen___ #define ___lwasm_h_seen___ +#include + enum lwasm_output_e { OUTPUT_DECB = 0, // DECB multirecord format @@ -39,9 +41,11 @@ typedef struct { - int output_format; // output format - int target; // assembly target - int debug_level; // level of debugging requested + int output_format; // output format + int target; // assembly target + int debug_level; // level of debugging requested + + lw_stringlist_t input_files; // files to assemble } asmstate_t; -#endif /* ___lwasm_h_seen___ */ \ No newline at end of file +#endif /* ___lwasm_h_seen___ */ diff -r 473ed9b353eb -r be63116281b0 lwlib/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/Makefile.am Tue Feb 09 05:59:56 2010 +0000 @@ -0,0 +1,3 @@ +noinst_LIBRARIES = liblw.a +liblw_a_SOURCES = lw_alloc.c lw_stringlist.c +EXTRA_DIST = lw_alloc.h lw_stringlist.h diff -r 473ed9b353eb -r be63116281b0 lwlib/lw_alloc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/lw_alloc.c Tue Feb 09 05:59:56 2010 +0000 @@ -0,0 +1,68 @@ +/* +lw_alloc.c + +Copyright © 2010 William Astle + +This file is part of LWTOOLS. + +LWTOOLS 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 3 of the License, or (at your option) any later +version. + +This program 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, see . +*/ + +#include + +#include + +#define ___lw_alloc_c_seen___ +#include "lw_alloc.h" + +void lw_free(void *P) +{ + if (P) + free(P); +} + +void *lw_alloc(int size) +{ + void *r; + + r = malloc(size); + if (!r) + { + abort(); + } + return r; +} + +void *lw_realloc(void *P, int S) +{ + void *r; + + if (!P) + { + return lw_alloc(S); + } + + if (!S) + { + lw_free(P); + return NULL; + } + + r = realloc(P, S); + if (!r) + { + abort(); + } + return r; +} diff -r 473ed9b353eb -r be63116281b0 lwlib/lw_alloc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/lw_alloc.h Tue Feb 09 05:59:56 2010 +0000 @@ -0,0 +1,36 @@ +/* +lw_alloc.h + +Copyright © 2010 William Astle + +This file is part of LWTOOLS. + +LWTOOLS 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 3 of the License, or (at your option) any later +version. + +This program 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, see . +*/ + +#ifndef ___lw_alloc_h_seen___ +#define ___lw_alloc_h_seen___ + + +#ifdef ___lw_alloc_c_seen___ + +#else /* def ___lw_alloc_c_seen___ */ + +extern void lw_free(void *P); +extern void *lw_alloc(int S); +extern void *lw_realloc(void *P, int S); + +#endif /* def ___lw_alloc_c_seen___ */ + +#endif /* ___lw_alloc_h_seen___ */ \ No newline at end of file diff -r 473ed9b353eb -r be63116281b0 lwlib/lw_stringlist.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/lw_stringlist.c Tue Feb 09 05:59:56 2010 +0000 @@ -0,0 +1,45 @@ +/* +lw_stringlist.c + +Copyright © 2010 William Astle + +This file is part of LWTOOLS. + +LWTOOLS 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 3 of the License, or (at your option) any later +version. + +This program 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, see . +*/ + +#include + +#define ___lw_stringlist_c_seen___ +#include "lw_stringlist.h" + +#include "lw_alloc.h" + +lw_stringlist_t lw_stringlist_create(void) +{ + return lw_alloc(sizeof(struct lw_stringlist_priv)); +} + +void lw_stringlist_destroy(lw_stringlist_t S) +{ + if (S) + { + int i; + for (i = 0; i < S -> nstrings; i++) + { + lw_free(S -> strings[i]); + } + lw_free(S); + } +} diff -r 473ed9b353eb -r be63116281b0 lwlib/lw_stringlist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/lw_stringlist.h Tue Feb 09 05:59:56 2010 +0000 @@ -0,0 +1,42 @@ +/* +lw_stringlist.h + +Copyright © 2010 William Astle + +This file is part of LWTOOLS. + +LWTOOLS 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 3 of the License, or (at your option) any later +version. + +This program 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, see . +*/ + +#ifndef ___lw_stringlist_h_seen___ +#define ___lw_stringlist_h_seen___ + + +#ifdef ___lw_stringlist_c_seen___ + +struct lw_stringlist_priv +{ + char **strings; + int nstrings; +}; +typedef struct lw_stringlist_priv * lw_stringlist_t; + +#else /* def ___lw_stringlist_c_seen___ */ + +typedef void * lw_stringlist_t; + + +#endif /* def ___lw_stringlist_c_seen___ */ + +#endif /* ___lw_stringlist_h_seen___ */ \ No newline at end of file