Commit Graph

1561 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 938f425c71
mescc: dup, dup2: Move to libc.
* lib/linux/libc.c (dup, dup2): New function.
* lib/linux/gnu.c (dup, dup2): Remove.
2018-11-15 18:08:49 +01:00
Jan Nieuwenhuizen 5a3f28a069
mescc: getcwd: Move to libc.
* lib/linux/libc.c (getcwd): New function.
* lib/linux/tcc.c (getcwd): Remove.
2018-11-15 18:08:48 +01:00
Jan Nieuwenhuizen 5f987d12c2
mescc: Support GNU make with POSIX.
* include/linux/x86/syscall.h (SYS_sigprocmask): New macro.
* include/linux/x86_64/syscall.h (SYS_rt_sigprocmask): New macro.
* include/signal.h (SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK): New macro.
(sigprocmask): Declare.
* lib/linux/gnu.c (sigprocmask): New function.
2018-11-15 18:08:48 +01:00
Jan Nieuwenhuizen cd30bee788
mescc: Support GNU Bash.
* include/errno.h (EACCES, ENOSPC, ESPIPE): New macro.
* include/linux/x86/syscall.h (SYS_setuid, SYS_geteuid, SYS_getegid,
SYS_setgid): New macro.
* include/linux/x86_64/syscall.h: Likewise.
* include/stdint.h (LLONG_MIN, LLONG_MAX, SIZE_MAX): New macro.
* include/sys/stat.h (S_ISUID, S_ISGID, S_IXGRP, S_IXOTH, S_IRGRP,
S_IROTH, S_IWGRP, S_IWOTH, S_IRWXG, S_IRWXO): New macro.
* include/termio.h: New file.
* include/unistd.h (_POSIX_VERSION): New macro.
* lib/linux/gnu.c (geteuid, getegid, setuid, setgid): New function.
* lib/string/memchr.c: New file.
* lib/stub/getpwuid.c: New file.
* lib/stub/rand.c: New file.
* lib/stub/ttyname.c: New file.
* include/string.h (memchr): Declare.
* include/unistd.h (geteuid, getegid, setuid, setgid): Declare.
2018-11-15 18:08:48 +01:00
Jan Nieuwenhuizen 23d4019d13
build: Simplify: cater for one compiler at a time.
* build-aux/build-cc.sh: Remove.
* build-aux/build-cc32.sh: Remove.
* build-aux/build-cc64.sh: Remove.
* build-aux/build-x86_64-mes.sh: Remove.
* build-aux/cc-mes.sh: Remove.
* build-aux/cc-x86_64-mes.sh: Remove.
* build-aux/cc32-mes.sh: Remove.
* build-aux/cc64-mes.sh: Remove.
* build-aux/test64.sh: Remove.
* build-aux/bootstrap-mes.sh: New file.
* build-aux/config.make.in: New file.
* build-aux/config.status.in: New file.
* build-aux/test-cc.sh: New file.
* .gitignore: Update.
* build-aux/GNUmakefile.in: Update.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-boot.sh: Update.
* build-aux/check-mes.sh: Update.
* build-aux/check-mescc.sh: Update.
* build-aux/check-tcc.sh: Update.
* build-aux/check.sh.in: Update.
* build-aux/config.sh: Update.
* build-aux/export.make: Update.
* build-aux/install.sh.in: Update.
* build-aux/pre-inst-env.in: Update.
* build-aux/test.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* module/mescc/i386/as.scm: Update.
* module/mescc/preprocess.scm: Update.
* module/mescc/x86_64/as.scm: Update.
* scripts/mescc.in: Update.
* tests/psyntax.test: Update.
2018-11-15 18:08:48 +01:00
Jan Nieuwenhuizen 28190c53df
mescc: Add missing define.
* lib/x86-mes/x86.M1: Add missing define.
2018-11-15 18:08:28 +01:00
Jan Nieuwenhuizen fc1db23dc8
mescc: Exit if library cannot be found.
* module/mescc/mescc.scm (arch-find): Exit upon failure.
2018-11-15 18:08:28 +01:00
Jan Nieuwenhuizen 213c89072f
mescc: Accept -O, --std, -x.
* scripts/mescc.in (parse-opts): Accept -O, --std, -x.
2018-11-11 12:10:42 +01:00
Jan Nieuwenhuizen 414a94f5f6
mescc: Support -dumpmachine.
* scripts/mescc.in (parse-opts): Support -dumpmachine.
2018-11-11 12:10:42 +01:00
Jan Nieuwenhuizen 1e3e1f33bf
mescc: vsnprintf: Compliant implementation.
* lib/stdio/vsnprintf.c (vsnprintf): New, complient implementation,
replacing vsnprint.
* lib/stdio/vsprintf.c (vsnprint): Forward to vsnprint.
* lib/stdio/snprintf.c (snprintf): Likewise.
* scaffold/tests/9a-snprintf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-11-11 12:10:42 +01:00
Jan Nieuwenhuizen 72665f5bba
test: Add performance test.
* module/mes/test.scm (pass-if-timeout): New macro.
* tests/perform.test: New test.
* build-aux/check-mes.sh (tests): Run it.
2018-11-11 12:10:42 +01:00
Jan Nieuwenhuizen 38d014decd
mes: Add ceil, floor, round, inexact->exact.
* mes/module/mes/scm.mes (ceil, floor, round, inexact->exact,
exact->inexact): New function.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen bb6cdb6b54
mes: read-string: Take optional port argument.
* src/posix.c (read_string): Take optional port argument.
* mes/module/mes/guile.mes (read-string): Remove.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen 4a31bcb06a
core: eval_apply: Order gotos according to frequency.
* src/mes.c (eval_apply): Order gotos according to frequency.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen 47600095c3
Revert "core: eval_apply profile."
This reverts commit d61e6be0b18459a8e3c262eab448b428dc81937a.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen 3d4dbdef60
core: eval_apply profile.
* src/mes.c: Poor man's eval_apply profile.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen cee0972566
core: Fix displaying of closure.
* src/lib.c (display_helper): Fix displaying of closure.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen 24748f575a
mes: Print backtrace upon exception.
* mes/module/mes/catch.mes (display-backtrace,
frame-function): New function.
(%eh): Use them.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen b93fd30819
core: Set procedure in stack frame.
* src/mes.c (eval_apply): Set procedure in stack frame.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 10a0ec8808
core: Implement stack and frame.
* src/lib.c (frame_printer make_frame_type, make_frame,
make_stack_type, make_stack, stack_length, stack_ref): New function.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 37cba9c93b
core: Support time functions.
* lib/linux/clock_gettime.c: New file, move from gnu.c.
* lib/linux/gettimeofday.c: New file, move from tcc.c.
* lib/linux/time.c: New file, move from tcc.c.
* lib/linux/libc.c: Include them.
* lib/linux/gnu.c (clock_gettime): Remove.
* lib/linux/tcc.c (time, gettimeofday): Remove.
* include/time.h (CLOCK_PROCESS_CPUTIME_ID): New define.
* src/posix.c (init_time, current_time, gettimeofday_,
seconds_and_nanoseconds_to_long, get_internal_run_time): New function.
* src/mes.c (scm_symbol_internal_time_units_per_second): New symbol.
(main): Call init_time.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 9b32098573
core: Use hash table for symbols.
* src/mes.c (mes_symbols): Use hash table for symbols.  Update users.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 554d1beeb2
core: Use assert before failure exit.
* src/mes.c (error): Use assert before failure exit.  Helps debugging.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 42e6f43149
core: Add hashq_get_handle, hash, hash_ref, hash_set_x.
* src/mes.c (scm_symbol_hashq_table, scm_symbol_record_type,
scm_symbol_module, scm_symbol_buckets, scm_symbol_size): New symbols.
Update users.
* src/hash.c (hash_list_of_char): Rename from hashq_.  Respect size,
update callers.
(hashq_, hash_ hash, hashq_get_handle, hash_ref, hash_set_x_,
hash_set_x): New function.
(hashq_ref): Do not return handle.  Update callers.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen d9199b3536
mes: Move pair? to core.
* src/lib.c (pair_p): New function.  Gains 8% performance on MesCC.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 4e1f494d19
mes: Move assoc to core.
* mes/mes.c (assoc_string, assoc): New function.
* mes/module/mes/scm.mes (assoc): Remove.  Gains 12% performance for
MesCC.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 5c685ebd22
Revert "core: Add gc-debug for stack array."
This reverts commit f35084d1dbea889d107824e7596da1701c6b90ad.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 30c67ca3e0
core: Add gc-debug for stack array.
* src/gc.c (gc_debug): New function.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen df2c9bf03f
scaffold: Resurrect mini-mes.
* src/mini-mes.c: Resurrect.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 79cffa7d79
core: Use array-based stack.
* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
(g_stack_array): New variable.
(g_stack): Change type to SCM*.
(gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
(gc_peek_frame): Likewise.
(gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
(gc): Likewise.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 010901ca89
mes: Resurrect Guile-1.8 support.
* module/mes/mes-0.scm: Resurrect Guile-1.8 support.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen d3fa0b4a1a
core: expand_variable: Remove weird exceptions: begin, if.
* src/mes.c (expand_variable_): Remove weird exceptions: begin, if.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 8044674d00
mes: Switch to srfi-9 based on structs.
* mes/module/srfi/srfi-9.mes: Swap symlink to srfi-9-struct.mes.
* mes/module/srfi/srfi-9/gnu.mes: Swap symlink to gnu-struct.mes.
* src/module.c (make_module_type): Update to match srfi-9-struct
records.  Update users.
* src/hash.c (make_hashq_type): Likewise.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 08ef31c86b
mes: srfi-9: Add implementation based on struct.
* mes/module/srfi/srfi-9-struct.mes: New file.
* mes/module/srfi/srfi-9-vector.mes: Rename from srfi-9.mes
* mes/module/srfi/srfi-9.mes: Symlink to srfi-9-vector.mes.
* mes/module/srfi/srfi-9/gnu-struct.mes: Add srfi-9-struct
implementation.
* mes/module/srfi/srfi-9/gnu-vector.mes: Rename from gnu.mes.
* mes/module/srfi/srfi-9/gnu.mes: Symlink to gnu-vector.mes.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 3dcc9879ab
core: hashq-table: Refactor to be a record-like struct.
* src/hash.c (hash_table_printer): New function.
(make_hashq_type): New function.
* src/module.c (module_printer): Use it.
(make_module_type): New function.
(make_initial_module): Use them.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 312099e5f3
mescc: Mes C Library: oputs: New function.
* lib/mes/oputc.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare it.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 99d890e340
core: Use hashq-table for macros.
* src/mes.c (lookup_macro_): Remove.
(macro_ref, get_macro, macro_set_x): New function.  Update callers.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen d9fb66a258
core: Add hashq-table type.
src/hash.c: New file.
src/module.c (char_hash, module_hash): Remove.
* src/module.c (make_initial_module): Use hash primitives.
(module_define_x): Likewise.
(module_variable): Likewise.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 08452c7b26
core: Add boot-module.
* src/mes.c (scm_symbol_boot_module): New symbol.
(eval_apply): Handle it.
(mes_symbols): Initialize it.
2018-11-07 22:48:07 +01:00
Jan Nieuwenhuizen 049066edc7
core: Add module-define!
* src/module.c (module_define_x, module_printer): New function.
(make_initial_module): Use them.
* tests/srfi-0.test: Test it.
* src/mes.c (display_m0): Remove.  Update callers.
* mes/module/mes/fluids.mes (make-fluid): Rewrite.
* tests/macro.test: Test it.
* mes/module/mes/boot-0.scm.in (module-define!): Remove.
* mes/module/mes/boot-02.scm: Likewise.
* module/mes/misc.scm (pk, warn): New function.
* build-aux/check-mes.sh (tests): Run tests.
2018-11-07 22:48:07 +01:00
Jan Nieuwenhuizen f8b70ff62e
core: Add module indirection for variable lookup.
* src/module.c (module_ref, module_variable): New function.
* src/mes.c: Thoughout: Use them.
(assq_ref_env): Remove.
* mes/module/mes/boot-0.scm.in (defined?): Use module-variable.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm: Likewise.
2018-10-14 08:30:18 +02:00
Jan Nieuwenhuizen b243af5499
core: Add module type.
* src/module.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-10-14 08:15:22 +02:00
Jan Nieuwenhuizen 47604479e2
core: Add cstring_to_symbol.
* src/mes.c (make_symbol): Rename from lookup_symbol_.  Update
callers.
(cstring_to_symbol): New function.
* src/reader.c (reader_read_identifier_or_number): Use it.
2018-10-14 07:38:51 +02:00
Jan Nieuwenhuizen c3a1435714
core: Add struct type.
* src/struct.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-10-13 17:34:27 +02:00
Jan Nieuwenhuizen f0216ab20d
build: factor-out snarfing.
* build-aux/snarf.sh: New file.
* build-aux/build-cc.sh: Use it.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-cc64.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/snarf.sh: Likewise.
2018-10-15 13:48:50 +02:00
Jan Nieuwenhuizen 18a9e37567
core: core:cdr: Support port type.
* src/mes.c (cdr_): Support port type.
* mes/module/mes/display.mes (display): Add space between fields.
2018-10-15 12:28:02 +02:00
Jan Nieuwenhuizen 05d7b2cb16
mes: with-fluids: Fix reset.
* mes/module/mes/fluids.mes (with-fluids): Fix reset.
* tests/fluids.test (report): Remove Mes failure expectation.
2018-10-15 10:39:02 +02:00
Jan Nieuwenhuizen 06f7fb29ee
mescc: Recognize U integer suffix.
* module/mescc/compile.scm (cstring->int): Recognize U integer
suffix.  Thanks, Peter de Wachter!
2018-10-19 23:31:30 +02:00
Peter De Wachter 607b02c12c
mescc: Add INTn_MIN/MAX defines to stdint.h.
* include/stdint.h: Add INTn_MIN/MAX defines.  Move integere size
defines from limits.h
* include/limits.h: Include it.
2018-10-16 20:40:41 +02:00
Peter De Wachter 58d184fc46
mescc: Allow superfluous parentheses in function declarations.
E.g.:  int (f)();
This is obscure but valid C.  It occurs in the csmith headers (thanks
to macro shenanigans).

* module/mescc/compile.scm (fctn-defn:get-name,
fctn-defn:get-statement): Allow superfluous parentheses in function declarations.
2018-10-16 20:40:40 +02:00