diff options
| author | peter <peter@pmikkelsen.com> | 2026-09-22 19:23:46 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-09-22 19:23:46 +0000 |
| commit | ec058e1f6acc1f6f98ebb31a350531f387441781 (patch) | |
| tree | 8b95b4eb67d108dc17312ecdd635e8a7dad29880 /src | |
| parent | 0b6ea0024a5a51db015797e952d55bfac49b4b6d (diff) | |
| parent | 1e88f84ab887be0330585fdb7b8eeb22280cc9d6 (diff) | |
Update branch to get the latest autotools stuff
FossilOrigin-Name: a39b9d0fe118ac1f3202f7b730f504056fdba8f0ab5fe79961e0861367fc60bb
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/bin/Makefile.am | 8 | ||||
| -rw-r--r-- | src/include/Makefile.am | 2 | ||||
| -rw-r--r-- | src/include/aplwc_macros.h | 2 | ||||
| -rw-r--r-- | src/lib/Makefile.am | 13 | ||||
| -rw-r--r-- | src/lib/aplwc_internal.h | 4 | ||||
| -rw-r--r-- | src/lib/memory.c | 46 | ||||
| -rw-r--r-- | src/lib/module.c | 1 | ||||
| -rw-r--r-- | src/lib/syntax.c | 1 | ||||
| -rw-r--r-- | src/tools/Makefile.am | 10 | ||||
| -rw-r--r-- | src/tools/genboot.c | 27 |
11 files changed, 95 insertions, 23 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..1e7e4e2 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,4 @@ +include src/bin/Makefile.am +include src/include/Makefile.am +include src/lib/Makefile.am +include src/tools/Makefile.am diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am new file mode 100644 index 0000000..bc25fbb --- /dev/null +++ b/src/bin/Makefile.am @@ -0,0 +1,8 @@ +bin_PROGRAMS += aplwc + +aplwc_SOURCES = \ + src/bin/aplwc_repl.h \ + src/bin/main.c \ + src/bin/util.c + +aplwc_LDADD = libaplwc.a diff --git a/src/include/Makefile.am b/src/include/Makefile.am new file mode 100644 index 0000000..3f082fb --- /dev/null +++ b/src/include/Makefile.am @@ -0,0 +1,2 @@ +include_HEADERS += src/include/aplwc.h +noinst_HEADERS += src/include/aplwc_macros.h diff --git a/src/include/aplwc_macros.h b/src/include/aplwc_macros.h index 80ada28..3c8aa6b 100644 --- a/src/include/aplwc_macros.h +++ b/src/include/aplwc_macros.h @@ -20,6 +20,8 @@ #ifndef APLWC_MACROS_H #define APLWC_MACROS_H +#include <config.h> + #define UNUSED_PARAMETER(arg) ((void)arg) #define NELEM(x) (sizeof(x)/sizeof(x[0])) diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 0000000..c95fe1c --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,13 @@ +lib_LIBRARIES += libaplwc.a + +libaplwc_a_SOURCES = \ + src/lib/aplwc_internal.h \ + src/lib/eval.c \ + src/lib/main.c \ + src/lib/memory.c \ + src/lib/module.c \ + src/lib/string.c \ + src/lib/symtab.c \ + src/lib/syntax.c + +EXTRA_DIST += src/lib/boot.aplwc diff --git a/src/lib/aplwc_internal.h b/src/lib/aplwc_internal.h index 328b5de..8c13dfe 100644 --- a/src/lib/aplwc_internal.h +++ b/src/lib/aplwc_internal.h @@ -67,7 +67,7 @@ struct aplwc_line { struct string { size_t bytes; size_t chars; - uint8_t utf8[1]; + uint8_t utf8[FLEXIBLE_ARRAY_MEMBER]; }; enum token_tag { @@ -100,7 +100,7 @@ struct token { struct token_list { struct string *text; size_t length; - struct token tokens[1]; + struct token tokens[FLEXIBLE_ARRAY_MEMBER]; }; enum value_tag { diff --git a/src/lib/memory.c b/src/lib/memory.c index 051acba..a8317c7 100644 --- a/src/lib/memory.c +++ b/src/lib/memory.c @@ -41,7 +41,9 @@ struct chunk { unsigned int last:1; }; +#if APLWC_BUILD_TYPE_DEBUG static void debug_check_mem(struct aplwc *); +#endif /* APLWC_BUILD_TYPE_DEBUG */ void memory_init(struct aplwc *aplwc) @@ -436,27 +438,6 @@ compact(struct aplwc *aplwc) } } -static void -debug_check_mem(struct aplwc *aplwc) -{ - uint64_t size; - struct chunk *c, *prev; - - size = 0; - prev = NULL; - for(c = (struct chunk *)aplwc->data; c; prev = c, c = next(c)){ - assert(((uint8_t*)c) < (aplwc->data+aplwc->size)); - assert((c->size % ALIGNMENT) == 0); - assert(c->stack == NULL); - size += c->size; - assert((c->last == 0) != (size == aplwc->size)); - if(c->tag == CHUNK_TAG_FREE) - assert((prev == NULL) || (prev->tag != CHUNK_TAG_FREE)); - } - - assert(size == aplwc->size); -} - static void * alloc(struct aplwc *aplwc, size_t size, enum chunk_tag tag) { @@ -653,3 +634,26 @@ valid_ref(struct aplwc_ref *ref) { return (ref->aplwc != NULL) && (ref->ptr != NULL); } + +#if APLWC_BUILD_TYPE_DEBUG +static void +debug_check_mem(struct aplwc *aplwc) +{ + uint64_t size; + struct chunk *c, *prev; + + size = 0; + prev = NULL; + for(c = (struct chunk *)aplwc->data; c; prev = c, c = next(c)){ + assert(((uint8_t*)c) < (aplwc->data+aplwc->size)); + assert((c->size % ALIGNMENT) == 0); + assert(c->stack == NULL); + size += c->size; + assert((c->last == 0) != (size == aplwc->size)); + if(c->tag == CHUNK_TAG_FREE) + assert((prev == NULL) || (prev->tag != CHUNK_TAG_FREE)); + } + + assert(size == aplwc->size); +} +#endif /* APLWC_BUILD_TYPE_DEBUG */ diff --git a/src/lib/module.c b/src/lib/module.c index 2ef5ba3..aaa9634 100644 --- a/src/lib/module.c +++ b/src/lib/module.c @@ -67,6 +67,7 @@ read_keyword_decl(struct aplwc *aplwc, struct aplwc_module *module, size_t offse max = module->tokens->length - offset - 1; + len = -1; assert(t(0).tag == TOKEN_TAG_KEYWORD); switch(t(0).data.keyword){ case KW_MODULE: diff --git a/src/lib/syntax.c b/src/lib/syntax.c index 4850b1a..1740a4e 100644 --- a/src/lib/syntax.c +++ b/src/lib/syntax.c @@ -425,6 +425,7 @@ scan_string(struct aplwc *aplwc, struct string *text, int oneline) MEMPTR(0, text); tokens = NULL; + n = 0; if((rc = check(aplwc, text, &n)) != APLWC_OK) goto end; diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am new file mode 100644 index 0000000..b1079e7 --- /dev/null +++ b/src/tools/Makefile.am @@ -0,0 +1,10 @@ +noinst_PROGRAMS += genboot + +genboot_SOURCES = src/tools/genboot.c + +BUILT_SOURCES += $(top_builddir)/generated/boot.h +CLEANFILES += $(top_builddir)/generated/boot.h + +$(top_builddir)/generated/boot.h: genboot src/lib/boot.aplwc + $(MKDIR_P) $(top_builddir)/generated + ./genboot $(top_srcdir)/src/lib/boot.aplwc > $@ diff --git a/src/tools/genboot.c b/src/tools/genboot.c new file mode 100644 index 0000000..e89b3aa --- /dev/null +++ b/src/tools/genboot.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <assert.h> + +int +main(int argc, char *argv[]) +{ + FILE *f; + int c, s; + + assert(argc == 2); + f = fopen(argv[1], "r"); + assert(f != NULL); + + printf("unsigned char boot_src[] = { "); + + s = 0; + while((c = fgetc(f)) != EOF){ + if(s++ > 0) + printf(", "); + printf("0x%02x", c); + } + + printf(" };\n"); + printf("unsigned int boot_src_len = %d;\n", s); + + return 0; +} |