Commit Graph

9 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 82c6d23712
M2: posix 2019-10-30 20:29:08 +01:00
Jan Nieuwenhuizen 6c2700aa59
mescc: Mes C Library: Add M2-Planet support. WIP
* kaem.run: New file.
* simple.make: Update.
* lib/m2/abtol.c: New file.
* lib/m2/access.c: New file.
* lib/m2/atoi.c: New file.
* lib/m2/chmod.c: New file.
* lib/m2/clock_gettime.c: New file.
* lib/m2/dup.c: New file.
* lib/m2/dup2.c: New file.
* lib/m2/eputs.c: New file.
* lib/m2/execv.c: New file.
* lib/m2/execve.c: New file.
* lib/m2/exit.c: New file.
* lib/m2/fdputc.c: New file.
* lib/m2/fork.c: New file.
* lib/m2/getcwd.c: New file.
* lib/m2/getenv.c: New file.
* lib/m2/isatty.c: New file.
* lib/m2/memchr.c: New file.
* lib/m2/memcmp.c: New file.
* lib/m2/memcpy.c: New file.
* lib/m2/memset.c: New file.
* lib/m2/mes_open.c: New file.
* lib/m2/ntoab.c: New file.
* lib/m2/open.c: New file.
* lib/m2/read.c: New file.
* lib/m2/setenv.c: New file.
* lib/m2/strcmp.c: New file.
* lib/m2/strcpy.c: New file.
* lib/m2/strlen.c: New file.
* lib/m2/strncmp.c: New file.
* lib/m2/time.c: New file.
* lib/m2/unlink.c: New file.
* lib/m2/waitpid.c: New file.
* lib/m2/write.c: New file.
2019-10-30 20:29:05 +01:00
Jan Nieuwenhuizen c43a16e168
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-10-30 18:32:09 +01:00
Jan Nieuwenhuizen d851bb15bb
core: Prepare for pointer-based cells.
* include/mes/cc.h: Prepare for pointer-based cells.
* include/mes/macros.h[POINTER_CELLS]: Alternative set of macros.
* include/mes/mes.h (struct scm)[POINTER_CELLS]: Alternative definition.
* src/gc.c (copy_cell, copy_news): New function.
* include/mes/mes.h: Declare them.
2019-10-30 18:32:05 +01:00
Jan Nieuwenhuizen 1ad683b145
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-10-30 18:32:05 +01:00
Jan Nieuwenhuizen f7d00927e3
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-10-30 18:32:05 +01:00
Jan Nieuwenhuizen 283b8f4def
core: Remove macros from cell creation: make_bytes.
* src/gc.c (bytes_cells, make_bytes): Move from string.c.
* include/mes/macros.h (MAKE_BYTES0, NAME_SYMBOL): Remove.
* include/mes/m2.h: Likewise.
2019-10-30 18:32:05 +01:00
Jan Nieuwenhuizen ec7e5cf250
core: Remove core:make-cell.
* src/gc.c (alloc, make_cell, cons): Move from mes.c
* src/mes.c: (make_cell_): Remove.
* src/lib.c (char_to_integer, integer_to_char): New function.
* src/builtins.c (mes_builtins): Add them; remove make_cell_.
* mes/module/mes/type-0.mes (char->integer, integer->char): Remove.
2019-10-30 18:32:04 +01:00
Jan Nieuwenhuizen ea4c39da65
core: Prepare for M2-Planet: mes.c.
Rewrite C-constructs not supported by M2-Planet, such as

    foo ? bar : baz;       -> if (foo) bar; else baz;
    static char foo[1024]  -> __func_buf = malloc (1024); ... char *foo = __func_buf;
    *foo                   -> foo[0]
    foo++                  -> foo = foo + 1   TODO: pointer arithmetic
    foo += 1;              -> foo = foo + 1
    for (int foo = ;       -> int foo; for (foo=
    if (foo)               -> if (foo != 0)
    if (!foo)              -> if (foo == 0)
    ;                      -> 0;
    // ...                 -> /* ... */

* src/mes.c: Rewrite C constructs not supported by M2-Planet.
* include/mes/mes.h (__execl_c_argv, __getcwd_buf, __open_boot_buf,
__open_boot_file_name, __setenv_buf, __reader_read_char_buf): Declare
buffers.
(init): Initialize them.
* include/mes/macros.h(__M2_PLANET__): Temporary M2 macros.
2019-10-26 19:40:58 +02:00