Commit Graph

55 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen b9f40e2653
core: Switch to pointer cells.
Run

   build-aux/pointer.sh

* src/*.c: Update.
* include/mes/*.h: Update.
2019-11-03 10:34:32 +01:00
Jan Nieuwenhuizen 74f95a3b67
core: posix: Prepare for M2-Planet.
* src/posix.c (access_p): Prepare for M2-Planet.
2019-11-02 21:32:46 +01:00
Jan Nieuwenhuizen f9d2fc1252
mescc: Mes C Library: Add M2-Planet support.
Mes can now be built with M2-Planet by running

    kaem --verbose --strict

* include/linux/x86/syscall.h (SYS_getcwd, SYS_dup, SYS_dup2,
SYS_unlilnk, SYS_gettimeofday, SYS_clock_gettime, SYS_time): Move to
libc section.  Add M2-Planet constants.
* include/m2/lib.h (struct timezone, struct timespec): struct timeval):
Define.  Add M2-Planet flavor prototypes for mes libc.
* include/mes/m2.h: Remove macros.
* include/mes/mes.h (g_start_time, __gettimeofday_time,
__get_internal_run_time_ts): Declare.
* src/mes.c (init): Initialize them.
* src/posix.c: Use them.
* simple.make: Use them.  Remove macro preprocessing for M2-Planet.
* kaem.run: New file.
2019-11-02 21:32:44 +01:00
Jan Nieuwenhuizen 91277b44c9
core: Split-out stack.c
* src/lib.c (exit_, frame_printer, make_frame_type, make_frame,
make_stack_type, make_stack, stack_length, stack_ref_): Move to ..
* src/posix.c (exit_): Here and to ..
* src/core.c: New file.
* build-aux/build-mes.sh (mes_sources): Add it.
* simple.make (LIBMES_SOURCES): Likewise.
2019-11-02 21:27:35 +01:00
Jan Nieuwenhuizen 403c173c36
core: Prepare for M2-Planet: if (foo).
Rewrite C-constructs not supported by M2-Planet

    if (foo)              -> if (foo != 0)

* src/posix.c: Rewrite C-constructs not supported by M2-Planet.
(current_input_port): Likewise.
* src/display.c (display_helper): : Likewise.
* src/eval-apply.c (expand_variable_): : Likewise.
(eval_apply): : Likewise.
* src/mes.c (open_boot): : Likewise.
* src/reader.c (reader_read_identifier_or_number): : Likewise.
* src/symbols.c (init_symbol): : Likewise.
2019-11-02 19:13:15 +01:00
Jan Nieuwenhuizen 5e445ce773
core: Prepare for M2-Planet: VALUE/TYPE indirections.
Rewrite C-constructs not supported by M2-Planet

    VALUE (CAR (foo))           -> SCM a = CAR (foo); VALUE (a)
    TYPE (CAR (foo))            -> SCM t = CAR (foo); TYPE (a)

* src/builtins.c (builtin_function): Use VALUE indirections.
(builtin_printer): Likewise.
* src/eval-apply.c (apply_builtin): Likewise.
(get_macro): Likewise.
(expand_variable_): Likewise.
(eval_apply): Likewise.
* src/hash.c (hashq_get_handle): Likewise.
(hashq_ref): Likewise.
(hash_ref): Likewise.
(hash_set_x): Likewise.
(hash_table_printer): Likewise.
* src/math.c (greater_p): Likewise.
(less_p): Likewise.
(is_p): Likewise.
(minus): Likewise.
(plus): Likewise.
(divide): Likewise.
(multiply): Likewise.
(logand): Likewise.
(logior): Likewise.
(logxor): Likewise.
* src/posix.c (current_input_port): Likewise.
(set_current_output_port): Likewise.
* src/reader.c (reader_read_list): Likewise.
(reader_read_character): Likewise.
(reader_read_string): Likewise.
* src/string.c (list_to_cstring): Likewise.
(read_string): Likewise.
2019-11-02 19:13:15 +01:00
Jan Nieuwenhuizen 1fedea5db6
core: open_output_file: Prepare for M2-Planet.
* src/posix.c (open_output_file): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen a48c4eabbd
core: current_input_port: Prepare for M2-Planet.
* src/posix.c (current_input_port): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen abe12e1929
core: write_byte: Prepare for M2-Planet.
* src/posix.c (write_byte): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen 57b2686a91
core: read_char: Prepare for M2-Planet.
* src/posix.c (read_char): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen 28d7152cad
core: Remove CBYTES, CSTRING, NCBYTES macros.
* src/gc.c (cell_bytes, news_bytes): New function.
* include/mes/macros.h (CBYTES, CSTRING, NCBYTES): Remove.  Update
users.
* include/mes/m2.h: Likewise.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen 1baa53f089
core: Prepare for conversion to pointer cells.
* src/posix.c (execl_): Prepare for conversion to pointer cells.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen 95902000fc
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen ec66f33631
core: Use assert_msg.
* src/mes.c: Use assert_msg instead of assert.
* src/gc.c: Likewise.
* src/hash.c: Likewise.
* src/lib.c: Likewise.
* src/math.c: Likewise.
* src/module.c: Likewise.
* src/posix.c: Likewise.
* src/reader.c: Likewise.
* src/string.c: Likewise.
* src/struct.c: Likewise.
* src/vector.c: Likewise.
* simple.make (LIB_SOURCES): Add lib/mes/assert_msg.c.
2019-11-02 13:54:02 +01:00
Jan Nieuwenhuizen 9a453ec38a
core: Prepare for M2-Planet: posix.c.
* src/posix.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:01 +01:00
Jan Nieuwenhuizen 5dc245e739
build: Simplify.
core: Make mes src/ c files separate compilation units.

* include/mes/constants.h: New file.
* include/mes/macros.h: New file.
* include/mes/mes.h: New file.
* src/gc.c: Update.
* src/hash.c: Update.
* src/lib.c: Update.
* src/math.c: Update.
* src/mes.c: Update.
* src/module.c: Update.
* src/posix.c: Update.
* src/reader.c: Update.
* src/string.c: Update.
* src/struct.c: Update.
* src/vector.c: Update.

    mes: Update datadir.

* src/mes.c (g_datadir): New global.
(open_boot): Rename from read_boot.
(read_boot): New function.
* mes/module/mes/boot-0.scm: Move from boot-0.scm.in
* configure: Update.
* configure.sh: Update.

    mescc: Create libraries from separate files.

* .gitignore: Update.
* build-aux/bootstrap-mes.sh: Remove.
* build-aux/bootstrap.sh.in: Remove.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build-scaffold.sh: New file.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-tcc.sh: Remove.
* build-aux/config.sh.in: New file.
* build-aux/config.sh: Remove.
* build-aux/install.sh.in: Update.
* build-aux/test-boot.sh: New file.
* build-aux/test-c.sh: New file.
* build-aux/test-driver: New file.
* build-aux/test-suite.sh: New file.
* build-aux/trace.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* lib/linux/x86-mes-mescc/crt1.c: Move from lib/linux/x86-mes.
* lib/linux/x86-mes-mescc/mini.c: Likewise.
* lib/linux/x86_64-mes-mescc/crt1.c: Move from lib/linux/x86_64-mes.
* lib/linux/x86_64-mes-mescc/mini.c: Likewise.
* lib/linux/x86-mes-gcc/syscall.c: Rename from mes.c.
* lib/linux/x86-mes-mescc/syscall.c: Likewise.
* lib/linux/x86_64-mes-gcc/syscall.c: Likewise.
* lib/linux/x86_64-mes-mescc/syscall.c: Likewise.
* lib/mes/mes_open.c: Include config.h.
* lib/tests/stdio/70-printf-hello.c: Likewise.
* lib/tests/stdio/70-printf-simple.c: Likewise.
* scaffold/gc-test.sh: New file.
* simple.sh: Update.
2019-06-08 15:36:22 +02:00
Jan Nieuwenhuizen c33d6d00bc
mes: Run build-aux/indent.sh.
* src/mes.c: Re-indent.
* src: Likewise.
* include: Likewise.
* lib: Likewise.
* scaffold: Likewise.
2019-05-18 13:27:42 +02:00
Jan Nieuwenhuizen 8bda737ee4
mescc: Mes C Library: Use mes_open to avoid open trickery.
* include/mes/lib.h (mes_open): Declare.
* lib/libmes.c[WITH_GLIBC]: Remove open undefine.
(mes_open)[!WITH_GLIBC]: New function.
* src/mes.c (open_boot): Use mes_open.
* src/posix.c (open_input_file): Likewise.
(open_output_file): Likewise.
2019-05-13 00:40:33 +02:00
Jan Nieuwenhuizen 829cc9cca5
mes: m2: Move force-output to Scheme.
* mes/module/mes/posix.mes (force-output): New function.
* src/posix.c (force_output): Remove.
* src/mes.c (mes_builtins): Remove adding of force-output.
2019-05-05 13:11:33 +02:00
Jan Nieuwenhuizen 757d603e4c
mescc: Mes C Library: Use __ as global internal prefix.
* include/libmes-mini.h (g_stdin, g_stdout, g_stderr): Rename to
__stdin, __stdout, __stderr.  Update users.
2019-03-02 12:35:18 +01:00
Jan Nieuwenhuizen 8e8e2fd6d3
core: Remove string debugging.
* src/strings.c (make_bytes, make_string, string_equal_p,
symbol_to_string, symbol_to_keyword, make_symbol): Remove string
debugging.
2018-12-27 16:48:45 +01:00
Jan Nieuwenhuizen 149f2a3e51
core: String as array of bytes.
* src/strings.c: New file.
* src/mes.c: Use it.  Update users.
2018-11-11 16:25:36 +01:00
Jan Nieuwenhuizen d2cba60eb4
core: read_string: Allow for gc.
* src/posix.c (read_char): Add optional port parameter.
(read_string): Allow for gc.
2018-11-11 10:17:50 +01:00
Jan Nieuwenhuizen af328a444a
core: Add delete_file.
* src/posix.c (delete_file): New function.
2018-11-11 11:03:03 +01:00
Jan Nieuwenhuizen 35c8408df4
core: Add dup, dup2.
* src/posix.c (dup_, dup2_): New function.
2018-11-11 10:18:50 +01:00
Jan Nieuwenhuizen 7c63d3df47
core: Add getcwd.
* src/posix.c (getcwd_): New function.
2018-11-11 10:16:19 +01:00
Jan Nieuwenhuizen 7d2e0f1215
core: Support redirection of stderr.
* include/libmes-mini.h (g_stderr): New global.
* lib/mes/eputc.c (eputc): Use it.
* lib/mes/eputs.c (eputs): Likewise.
* lib/mes/oputc.c (oputc): Likewise.
* lib/mes/oputs.c (oputs): Likewise.
* src/lib.c (display_error_, write_error_): Likewise.
* src/posix.c (write_byte): Likewise.
* src/mes.c (mes_builtins): Likewise.
(main): Iniitalize g_stderr.
* src/posix.c (current_error_port, set_current_error_port): New
function.
* mes/module/mes/boot-0.scm.in (current-output-port,
current-error-port): Remove.
2018-11-11 10:04:03 +01:00
Jan Nieuwenhuizen 0e1d98963c
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-10-21 12:00:00 +02:00
Jan Nieuwenhuizen 094bdac0bd
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-10-20 14:18:04 +02:00
Jan Nieuwenhuizen 72cb975213
GNU Mes.
Throughout, make these changes

   Copyright headers: GNU Mes
   First mention of name: GNU Mes
   Website: https://www.gnu.org/software/mes
   Git:     git://git.savannah.gnu.org/mes.git
2018-07-22 14:24:36 +02:00
Jan Nieuwenhuizen f6d5578174
core: Fix segfault on Debian/strectch. Thanks, pdewacht!
* src/posix.c (execl_): Typo in initialization.  Fixes segfault on
  Debian/strectch.  Thanks, pdewacht!
2018-07-12 22:30:00 +02:00
Jan Nieuwenhuizen 16f4adfbc2
core: Fix compile warnings.
* lib/libmes.c: Fix warning.
* src/posix.c (execl_): Fix warning, add debug printing.
2018-06-26 06:19:51 +02:00
Jan Nieuwenhuizen 7be16f51b3
core: execl_: Allow 1000 arguments.
* src/posix.c (execl_): Allow 1000 arguments.
2018-06-26 06:05:20 +02:00
Jan Nieuwenhuizen de964f3e1f
mescc: Support gcc-2.6.3.
* TODO
2018-06-02 11:41:06 +02:00
Jan Nieuwenhuizen f1efaa0e93
mescc: Support binutils-2.5.1.
* include/stdint.h: #undef types before typedef'ing them.
* include/sys/types.h: Likewise.
* include/string.h (NULL): New define.
* include/stdio.h (BUFSIZ): New define.
2018-05-30 21:55:39 +02:00
Jan Nieuwenhuizen 2cda87257a
mlibc: Cleanup. 2018-05-29 18:15:22 +02:00
Jan Nieuwenhuizen 4ee1c9595e
Revert "fork/exec: debug."
This reverts commit f0315ac0d9acd66a30dbb192334f443459b7ed16.
2018-05-25 11:21:26 +02:00
Jan Nieuwenhuizen 342195bbbd
fork/exec: debug. 2018-05-25 11:21:06 +02:00
Jan Nieuwenhuizen e4d0298d1b
core: Support fork, waitpid, execve.
* stage0/x86.M1 (SYS_fork, SYS_waitpid, SYS_execve): New define.
* lib/linux-gcc.c (fork, waitpid, execve): New function.
* lib/linux-mes.c (fork, waitpid, execve): New function.
* lib/libc.c (wait): New function.
* include/unistd.h (fork, execve): Declare.
* include/sys/wait.h (waitpid, wait): Declare.
* module/mes/posix.mes (search-path, execlp, system*, waitpid): New function.
* src/posix.c (primitive_fork, execl): New function.
2018-05-24 19:54:42 +02:00
Jan Nieuwenhuizen dc24a7f76f
core: Add string ports.
* src/mes.c (type_t): Add TPORT.
  (scm_type_port): New symbol.
  (PORT): New macro.
  (MAKE_STRING_PORT): New macro.
  (eval_apply): Handle string ports in primitive-load.
  (mes_symbols): Add scm_type_port.
* src/posix.c (peekchar): Handle string ports.
  (readchar): New function.  Replace all getchar callers.
  (unreadchar): Likewise.
* module/mes/type-0 (port?): New function.
* module/mes/guile.mes (with-input-from-file): Rewrite.
  (open-input-string): Remove.
* module/mes/guile.scm (guile): Update cell types.
* src/gc.c (gc_loop): Support TPORT.
* src/lib.c (display_helper): Support TPORT.
* module/mes/display.mes (display): Support TPORT.
2018-04-29 17:48:38 +02:00
Jan Nieuwenhuizen 865e72ae8a
core: Fix compile warnings.
* src/posix.c: Include sys/stat.h.
  (chmod): Return cell_unspecified.
* include/stdlib.h: Typo.
2018-04-29 12:02:23 +02:00
Jan Nieuwenhuizen 2cc6f166db
core: Add chmod.
* src/posix.c (chmod_): New function.
2018-04-27 23:31:45 +02:00
Jan Nieuwenhuizen bb45012c39
mes: Add isatty?.
* src/posix.c (isatty_p): New function.
2018-04-22 11:48:38 +02:00
Jan Nieuwenhuizen ad135d3752 doc: Release udpate.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.12: New file.
* throughout: (janneke) coming out.
2017-11-21 19:22:26 +01:00
Jan Nieuwenhuizen 6932d83d82 mes: Add setenv.
* src/posix.c (setenv_): New function.
* tests/base.test ("setenv, getenv"): Test it.
2018-04-07 09:34:02 +02:00
Jan Nieuwenhuizen 35bb5869f9 mes: Cleanup formatting. 2018-04-05 21:35:31 +02:00
Jan Nieuwenhuizen 4c9690996c mes: Iterative recursive macro expand.
* src/mes.c (eval_apply): Iterative recursive macro expand.
* src/posix.c (set_current_input_port): Return previous port.
* module/mes/catch.mes (%eh): Use core:display.
* module/mes/display.mes (display-cut, display-cut2): Move macro
  definitions to toplevel.
2018-03-04 10:05:55 +01:00
Jan Nieuwenhuizen f077364bce mes: reader: reader_ prefix; read/write char/string in core.
* src/posix.c (peek_char, read_char, read_string, unread_char, write_char): New function.
* src/reader.c: Use reader_ prefix.

r#	bootstrappable.org
2018-01-06 07:58:23 +01:00
Jan Nieuwenhuizen 6af7556d51 mescc: C99 header files and declaraions.
* libc/include/assert.h (assert_fail):
* libc/include/stdio.h:
+int eputs (char const* s);
+int fputs (char const* s);
+int puts (char const* s);
+int putchar (int c);
+int fputc (int c, int fd);
+int getchar ();
* libc/include/stdlib.h:
+char* getenv (char const* s)
+int atoi (char const *s);
+int *malloc (size_t);
+int *realloc (int *p, int size);
* libc/include/unistd.h (access):
* src/lib.c (display_helper):
* src/mes.c (read_input_file_env):
* src/posix.c: Include unistd.h.
2017-05-23 07:16:08 +02:00
Jan Nieuwenhuizen 45ce77df85 core: Add current-output-port, open-output-file, set-current-output-port.
* libc/include/fcntl.h: Declare it.  Add some fcntl defines.
* libc/include/stdio.h: Remove fcntl defines, Declare g_stdout.
* module/language/c99/compiler.mes (c99-input->ast): Define O_WRONLY, O_RDWR.
* module/mes/guile.mes (with-output-to-file, with-output-to-port): New functions.
* src/posix.c (current_output_port, open_output_file,
  set_current_output_port): New functions.
* libc/mlibc.c (open): Add optional mode parameter.
* module/mes/libc-i386.mes (i386:open): Forward third parameter.
* scaffold/mini-mes.c (main): Init g_stdout.
* src/mes.c (main): Likewise.
2017-05-19 06:56:47 +02:00