Janneke Nieuwenhuizen
a0c9c0aedb
DRAFT lib: tests: 17-compare-unsigned-short-le.c: Avoid gcc optimize.
...
* lib/tests/scaffold/17-compare-unsigned-short-le.c (main): Change
comparison with immediate to comparison with variable.
2023-11-05 09:36:11 +01:00
Janneke Nieuwenhuizen
0f0dad6436
DRAFT lib: tests: 17-compare-unsigned-char-le.c: Avoid gcc optimize.
...
* lib/tests/scaffold/17-compare-unsigned-char-le.c (main): Change
comparison with immediate to comparison with variable.
2023-11-05 09:36:11 +01:00
Ekaitz Zarraga
2be2de827f
lib: tests: Add 17-compare-rotated.
...
* lib/tests/scaffold/17-compare-rotated.c: Add file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-11-05 09:36:11 +01:00
Ekaitz Zarraga
4134285e8e
lib: tests: Add 16-cast.
...
* lib/tests/scaffold/16-cast.c: Add file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-11-05 09:36:11 +01:00
Janneke Nieuwenhuizen
96ad09dbfd
lib: tests: 63-struct-cell: Avoid segfault by array overflow with gcc >= 10.
...
* lib/tests/scaffold/63-struct-cell.c (g_functions]: Use size 3.
2023-08-29 22:07:01 +02:00
Janneke Nieuwenhuizen
ab9946d8ef
lib/tests: Initialize local variable.
...
Reuported by Andrius Štikonas <andrius@stikonas.eu> via IRC.
* lib/tests/assert/50-assert.c (main): Initialize local f.
* lib/tests/scaffold/21-char-array.c (main): Likewise.
2023-07-08 15:10:05 +02:00
Andrius Štikonas
762200b65a
m2: Add new style x86 defines to support M2-Planet 1.11.0.
...
* lib/m2/x86/x86_defs.M1: Add new M1 defines.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen
640bdd027b
lib: __assert_fail: Remove M2-Planet workarounds.
...
* lib/mes/__assert_fail.c (__assert_fail): Use *file, *function.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen
6bc6e8354e
lib: linux: Add wait4.
...
* lib/linux/waitpid.c (waitpid): Factor-out wait4 call to...
* lib/linux/wait4.c: ...new file here.
* include/sys/wait.h (wait4): Add prototype. Include sys/resource.h.
* include/sys/resource.h (struct rusage): Remove gratuitous "int" for
M2-Planet.
* build-aux/configure-lib.sh (libc_SOURCES): Add it.
* kaem.run,
simple.make (M2_SOURCES),
simple.sh: Likewise. Also add resource.h.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen
cbea14f843
core: Move M2_PTR_SIZE, M2_CELL_SIZE to include file.
...
* lib/posix/getenv.c (M2_PTR_SIZE),
lib/posix/setenv.c (M2_PTR_SIZE): Move definition...
* include/mes/lib-mini.h (M2_PTR_SIZE): ...here.
* src/gc.c (M2_CELL_SIZE),
src/symbol.c (M2_CELL_SIZE),
src/test/gc.c (M2_CELL_SIZE),
src/vector.c (M2_CELL_SIZE): Move definition...
* include/mes/mes.h (M2_CELL_SIZE): ...here.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen
dad460189f
kaem.run: Remove --bootstrap-mode.
...
* include/linux/arm/syscall.h,
include/linux/x86/syscall.h,
include/mes/constants.h: Remove CONSTANTs.
* lib/m2/open.c: Move to...
* lib/linux/open.c: ...here. Update to make gcc-compatible.
* scaffold/argv.kaem: Update accordingly.
* lib/linux/lseek.c (_leek, lseek): Suport M2-Planet.
* lib/linux/_open3.c (_open3): Fix cast.
* lib/linux/waitpid.c (waitpid): Suport M2-Planet.
* lib/m2/getcwd.c (PATH_MAX): Remove CONSTANT.
* lib/m2/isatty.c (TCGETS): Remove CONSTANT.
* lib/mes/ntoab.c: Support M2-Planet.
* lib/posix/getcwd.c (__getcwd_buf): Remove.
* lib/posix/getenv.c (M2_PTR_SIZE)[__M2__]: Update to #define.
* lib/posix/setenv.c: Likewise.
* lib/stub/__raise.c (SIGABRT): Remove CONSTANT.
* src/core.c (error): Use __M2__ instead of __M2_PLANET__.
* src/gc.c (M2_CELL_SIZE)[__M2__]: Update to #define. Support
non-bootstrap-mode.
* src/symbol.c: Likewise.
* src/vector.c: Likewise.
* src/posix.c: Likewise.
(__raise): Move to...
* include/mes/lib-cc.h (__raise): ...this new file to avoid M2-Planet crash.
* include/sys/types.h: Include it.
* lib/mes/div.c (__raise): Remove prototype.
[__TINYC__ || SYSTEM_LIBC] (__raise): Remove macro.
* include/mes/lib.h (__raise)[SYSTEM_LIBC]: Remove prototype.
* kaem.run: Remove --botstrap-mode. Update source list accordingly.
* simple.make (M2_PLANET_FLAGS): Remove --bootstrap-mode.
* simple.make (M2_SOURCES, M2_PLANET_INCLUDES): Update source list
accordingly.
* include/sys/types.h (EOF): Move to...
* include/mes/lib-cccc.h (EOF): ...here, and...
* include/m2/types.h (EOF): ...here, to avoid M2-Planet crash.
2023-05-03 08:03:48 +02:00
Jan (janneke) Nieuwenhuizen
e354d912ef
lib: posix/open: Support M2-Planet.
...
* lib/posix/open.c (open)[__M2__]: New function.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen
6ec74a34c4
lib: linux/_open3: Support M2-Planet.
...
* lib/linux/_open3.c (_open3): Use function casting. Also call
__ungetc_init.
* lib/stub/__buffered_read.c: New file.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen
4d4e6959e9
kaem: read: Remove --bootstrap-mode.
...
* include/mes/lib.h[__M2__](__call_at_exit,abtod,dtoab,ultoa,
* include/sys/types.h[__M2__]: Fall back to unsigned instead of using
unsigned long.
* include/stdio.h[__M2__](fprintf, fscanf, printf, snprintf, sprintf,
sscanf): Hide prototypes.
* lib/stdlib/exit.c (exit)[__M2__]: Hide call to __call_at_exit.
* lib/linux/read.c (read)[__M2__]: Hide debugging.
* lib/linux/malloc.c (malloc)[__M2__]: Hide alignment.
__mesabi_umod, __mesabi_udiv, __mesabi_uldiv): Hide prototypes.
* scaffold/argv.kaem: Use them together with lib/mes/lib-mini.h instead of
lib/mes/* specializations. Remove --bootstrap-mode from M2-Planet call.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen
402b024982
lib: mes/write: Rename from mes/mini-write.c
...
* lib/mes/mini-write.c: Move to...
* lib/mes/write.c: ...here.
* build-aux/configure-lib.sh,
kaem.run,
scaffold/argv.kaem,
scaffold/global-array.kaem,
scaffold/hello.kaem,
scaffold/local-array.kaem,
scaffold/local-static-array.kaem,
scaffold/read.kaem,
simple.make,
simple.sh: Update accordingly.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen
e428c17cc5
lib/m2: Update syscall includes.
...
This is a follow-up to commit
bc1fa57851
lib: stat: Use SYS_stat64 for 32bit platforms.
* lib/m2/chmod.c: Update to <arch/syscall.sh>.
* lib/m2/clock_gettime.c: Likewise.
* lib/m2/read.c: Likewise.
2023-05-02 10:22:01 +02:00
Jan (janneke) Nieuwenhuizen
43fe67e2f9
lib: Fix compile warnings.
...
* lib/linux/read.c (read): Add casts.
* lib/linux/signal.c (signal): Likewise.
* lib/stdio/vfscanf.c: Include stdlib.h.
(vfscanf): Add cast.
* lib/stdlib/mbstowcs.c (mbstowcs): Add cast.
2023-02-12 23:02:24 +01:00
R. Masters
b28f42de07
lib: Support uppercase hex conversions.
...
Uppercase hex number conversions fail for abtol, strtol, strtoul,
strtoull, atoi, and abtod.
The following patch fixes it. This allows tcc to handle assembly
language, which is necessary to build the Fiwix kernel as part of the
kernel bootstrapping in progress for the live-bootstrap project.
* lib/ctype/isxdigit.c (isxdigit): Also allow A-F.
* lib/mes/abtol.c (abtol): Also cater for A-F.
2023-01-31 08:22:49 -08:00
Jan (janneke) Nieuwenhuizen
1e14c26305
lib/m2: time: Fix segfault by allocating timeval struct.
...
Suggested by Meghan Denny <hello@nektro.net>.
* lib/m2/time.c (__tv): New global variable.
(time): Use it to allocate timeval struct.
2023-01-24 07:59:49 +01:00
Jan (janneke) Nieuwenhuizen
bc1fa57851
lib: stat: Use SYS_stat64 for 32bit platforms.
...
This fixes <https://debbugs.gnu.org/41264 >.
* include/linux/arm/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/linux/x86/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/sys/stat.h (struct stat): Move definition to...
* include/linux/arm/kernel-stat.h,
include/linux/m2/kernel-stat.h,
include/linux/x86/kernel-stat.h,
include/linux/x86_64/kernel-stat.h: These new files.
* include/gnu/x86/kernel-stat.h: New file.
* configure (main): Copy <srcdest>include/<kernel>/<arch>/*.h to
include/.
* configure.sh: Likewise.
* .gitignore: Ignore them. Add copyright header.
* build-aux/GNUmakefile.in (X86_ARCH_HEADERS, ARCH_HEADERS): New
variables.
(build): Use them.
(include/arch/%.h, arch-dir): New targets.
* build-aux/bootstrap.sh.in (AM_CPPFLAGS): Replace
<srcdest>include/<kernel>/<cpu> with built ../include.
* build-aux/build.sh.in (AM_CPPFLAGS): Likewise.
* build-aux/install.sh.in: Also install built include.
* include/m2/types.h: New file.
* kaem.run: Use it.
* simple.sh: Copy kernel-stat.h, syscall.h for kernel/cpu to
include/arch.
2022-10-29 13:17:58 +02:00
Jan (janneke) Nieuwenhuizen
25e0c4d119
lib: __assert_fail: Update to standard.
...
* lib/mes/__assert_fail.c (__assert_fail): Add file, line, function
parameters.
* include/assert.h (assert): Update caller.
(__assert_fail): Update prototype.
* include/mes/lib.h (__assert_fail): Likewise.
* lib/mes/assert_msg.c (assert_msg): Likewise. Include assert.h.
2022-10-26 21:14:05 +02:00
Jan (janneke) Nieuwenhuizen
84fd995f43
time.c: include sys/time for gettimeofday.
...
* lib/linux/time.c: Include <sys/time.h>.
2022-05-05 23:26:46 +02:00
Jan (janneke) Nieuwenhuizen
77602c2cde
lib: linux/time: Remove SYS_time specialization.
...
* lib/linux/time.c (time)[SYS_time]: Remove specialization.
[!SYS_time && !SYS_gettimeofday]: Remove fallback.
2022-05-04 14:14:51 +02:00
Ekaitz Zarraga
761420ac31
mescc: Add X86_64 assembly defines for TinyCC compilation.
...
* lib/x86_64-mes/x86_64.M1 ( mov____%si,(%rdi), mov____%sil,(%rdi),
mov____(%rax),%si, mov____(%rax),%sil): New defines.
2022-09-21 09:43:43 +02:00
Jan (janneke) Nieuwenhuizen
074fa78f5e
lib/test: Cater for gcc-12.2.0.
...
These inexplicably avoid segfaults with gcc-12.2.0.
* lib/tests/posix/50-open-read.c (main)[__GNUC__ > 11]: Use malloc
instead of local allocated string.
* lib/tests/scaffold/7i-struct-struct.c (main)[__GNUC__ > 11]:
Initialize all fields of struct.
* lib/tests/scaffold/t.c (main): Likewise.
2022-09-15 13:56:38 +02:00
Rick Masters
fdac9fd3f2
lib: abtol: Fix number digits in hex number conversion.
...
After a letter based digit, number based digits are off.
* lib/mes/abtol.c (abtol): Reset "m" for number based digit.
* lib/tests/stdlib/70-strtoull.c (main): Test it.
* lib/tests/stdlib/90-strtol.c (main): Likewise.
2022-10-07 11:59:57 +02:00
Jan (janneke) Nieuwenhuizen
eee5398f3b
ARM: Fix unsigned modulo.
...
* lib/arm-mes/arm.M1 (mov____%esp,%r3): New macro.
* module/mescc/armv4/as.scm (armv4:r0%r1): Use it to avoid overwriting
%r0 before caling __mesabi_uldiv.
2022-09-12 09:47:28 +02:00
Jan (janneke) Nieuwenhuizen
dbec0c3845
test: Add 60-math-modulo.c.
...
* lib/tests/scaffold/60-math-modulo.c: New test.
* build-aux/check-mescc.sh (mes_tests): Add it.
2022-09-11 23:34:20 +02:00
Jan (janneke) Nieuwenhuizen
e64d763ccd
ARM: ntoab: Do not include __mesabi_uldiv for bootstrap tcc.
...
* lib/mes/ntoab.c (__mesabi_uldiv): Exclude for tinycc arm bootstrap.
2022-09-13 19:12:31 +02:00
Jan (janneke) Nieuwenhuizen
d1297688a8
ARM: build: Cater for M2-Planet.
...
* include/linux/arm/syscall.h: Add support for M2-Planet.
* lib/linux/arm-mes-m2/_exit.c,
lib/linux/arm-mes-m2/_write.c,
lib/linux/arm-mes-m2/crt1.M1,
lib/linux/arm-mes-m2/crt1.c,
lib/linux/arm-mes-m2/syscall.c,
lib/m2/arm/ELF-arm.hex2,
lib/m2/arm/arm_defs.M1: New files.
* build-aux/build.sh.in: Also allow kaem build for ARM.
2022-04-30 22:51:42 +02:00
Jan (janneke) Nieuwenhuizen
c45bd1bdd6
Mes C Library: memchr: Avoid compile warning.
...
* lib/string/memchr.c (memchr): Cast return to void*.
2022-04-30 16:40:57 +02:00
Jan (janneke) Nieuwenhuizen
9c2ba4829c
Revert "Mes C Library: m2/execve.c: Remove specialization."
...
This fixes
gcc-lib/libc+gnu.c: At top level:
gcc-lib/libc+gnu.c:2694:1: error: conflicting types for ‘execve’
execve (char const *file_name, char **argv, char **env)
^~~~~~
In file included from gcc-lib/libc+gnu.c:492:0:
include/unistd.h:66:5: note: previous declaration of ‘execve’ was here
int execve (char const *file, char *const argv[], char *const env[]);
^~~~~~
This reverts commit 828c27a073896facdc3a3b24265ee69f0033f58f.
2021-01-02 10:00:35 +01:00
Jan (janneke) Nieuwenhuizen
99fbb9b2e5
bootstrap: Update M2-Planet x86 definitions from 1.7.0-31-g358b6cf.
...
* lib/m2/x86/x86_defs.M1: Update.
2021-01-01 19:07:22 +01:00
Jan (janneke) Nieuwenhuizen
c881e18dae
Revert "Mes C Library: m2/getcwd.c: Remove specialization."
...
This reverts commit 37f44ce9453ef5589b1336c981360de16c154999.
2021-01-01 15:54:13 +01:00
Jan (janneke) Nieuwenhuizen
b23c6885a6
core: Move __getcwd_buf to Mes C Library.
...
* include/mes/mes.h (__getcwd_buf): Move to..
* lib/posix/getcwd.c (__getcwd_buf): ...here.
(getcwd): Refactor.
* src/posix.c (getcwd_): Do not use __getcwd_buf.
2021-01-01 15:43:43 +01:00
Jan (janneke) Nieuwenhuizen
0d337be8ff
bootstrap: Support building with M2-Planet 1.4.
...
* lib/m2/x86/x86_defs.M1 (NOP): New define.
2021-01-01 11:40:51 +01:00
Jan (janneke) Nieuwenhuizen
96e6ecaf7d
core: Add abort.
...
* lib/stub/__raise.c: New file.
* kaem.run: Use it.
* src/posix.c (__raise)[SYSTEM_LIBC]: New macro.
(abort_): New function: possibly use it.
* include/mes/builtins.h: Declare it.
* src/builtins.c (mes_builtins): Register it.
2019-11-10 16:04:25 +01:00
Jan (janneke) Nieuwenhuizen
d984618a48
Mes C Library: m2/execve.c: Remove specialization.
...
* lib/linux/execve.c (execve): Cater for M2-Planet.
* lib/m2/execve.c: Remove.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES): Likewise.
2020-12-29 19:13:02 +01:00
Jan (janneke) Nieuwenhuizen
f07856de0f
Mes C Library: m2/getcwd.c: Remove specialization.
...
* lib/posix/getcwd.c (getcwd): Cater for M2-Planet.
* lib/m2/getcwd.c: Remove.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES): Likewise.
2020-12-29 18:52:37 +01:00
Jan (janneke) Nieuwenhuizen
fca14d27ad
Mes C Library: m2/ioctl.c: Remove specialization.
...
* lib/stub/ioctl.c (ioctl3): Move to...
* lib/stub/ioctl3.c: ...new file.
* lib/m2/ioctl3.c: Move to...
* lib/linux/ioctl3.c: ...here.
* include/mes/lib.h (ioctl3): Declare it.
* lib/m2/isatty.c (isatty): Use it.
* build-aux/configure-lib.sh (libc_SOURCES): Include it; move
lib/linux/ioctl.c to ...
(libc_gnu_SOURCES): ... here.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES): Likewise.
* simple.sh (compiler): Likewise.
2020-12-29 18:41:45 +01:00
Jan (janneke) Nieuwenhuizen
a4e56aac56
Mes C Library: m2/ntoab.c: Remove specialization.
...
* lib/mes/ntoab.c (__mesabi_uldiv)[__M2_PLANET__ || !(__MESC__ &&
__arm__)]: New function.
* lib/mes/ntoab.c (ntoab): Use it to cater for M2-Planet.
* lib/m2/ntoab.c: Remove.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES, (M2_TODO): Likewise.
2020-12-29 15:39:33 +01:00
Jan (janneke) Nieuwenhuizen
41c126759e
mescc: Mes C Library: Prepare for M2-Planet 1.7.0.
...
* lib/m2/ntoab.c (ntoab): Declare variables at toplevel.
* lib/mes/abtol.c (abtol): Likewise.
* lib/posix/getenv.c (getenv): Likewise.
* lib/posix/setenv.c (setenv): Likewise.
2020-12-29 13:37:20 +01:00
Jan (janneke) Nieuwenhuizen
74d7d097e4
mescc: Mes C Library: isatty: Use fixed array size for M2-Planet.
...
* lib/m2/isatty.c (struct ktermios)[c_cc]: Hardcode to size 19.
2020-12-29 13:34:24 +01:00
Jan (janneke) Nieuwenhuizen
a87e014ed6
mescc: Mes C Library: Update M2-Planet macros.
...
* lib/m2/x86/x86_defs.M1: Update from M2-Planet 1.7.0.
2020-12-29 13:33:12 +01:00
Jan (janneke) Nieuwenhuizen
d06a13aee4
guix: Update M2-Planet to 1fc2aeab483208bd2ba117b21df3894c182470ec.
...
* guix/git/mes.scm (m2-planet): Update to 1fc2aeab483208bd2ba117b21df3894c182470ec.
(native-inputs): Add gcc-toolchain-7.
* lib/m2/x86/x86_defs.M1: Update from M2-Planet.
2020-10-18 23:29:15 +02:00
Jan (janneke) Nieuwenhuizen
8f2bc16e7a
core: Use casting functions.
...
Silence all casting errors by using casting functions.
* src/cc.c (cast_charp_to_scmp, cast_charp_to_scmpp,
cast_voidp_to_charp, cast_scmp_to_long, cast_scmp_to_charp): New function.
* src/m2.c (cast_charp_to_scmp, cast_charp_to_scmpp,
cast_voidp_to_charp, cast_scmp_to_long, cast_scmp_to_charp): New function.
* include/mes/mes.h: Declare them.
(struct scm): Add car_value, cdr_value, function.
(g_continuations): Change to long.
* src/mes.c: Silence all casting errors by using casting functions.
2020-10-18 15:44:49 +02:00
Jan (janneke) Nieuwenhuizen
ca8e9f0342
mescc: Mes C Library: Use casting functions.
...
Silence all casting errors by using casting functions.
* lib/mes/cast.c: New file.
* build-aux/configure-lib.sh (libmes_SOURCES): Add it.
* lib/m2/cast.c: New file.
* kaem.run: Add it.
* simple.make: Add them both.
* include/mes/lib.h: Add cast prototypes.
* include/m2/lib.h: Likewise.
* lib/linux/_getcwd.c (_getcwd): Use them.
* lib/linux/access.c (access): Likewise.
* lib/linux/brk.c (brk): Likewise.
* lib/linux/chmod.c (chmod): Likewise.
* lib/linux/clock_gettime.c (clock_gettime): Likewise.
* lib/linux/gettimeofday.c (gettimeofday): Likewise.
* lib/linux/unlink.c (unlink): Likewise.
* lib/mes/fdputc.c (fdputc): Likewise.
* lib/stdio/putchar.c (putchar): Likewise.
* lib/linux/malloc.c (malloc): Likewise.
2020-10-18 14:55:24 +02:00
Jan (janneke) Nieuwenhuizen
c58049d48d
mescc: Mes C Library: Add waitpid for M2-Planet.
...
* lib/m2/waitpid.c: New file.
2020-07-25 20:05:29 +02:00
Jan (janneke) Nieuwenhuizen
e103008c2e
mescc: Mes C Library: Add time for M2-Planet.
...
* lib/m2/time.c: New file.
2020-07-25 20:05:19 +02:00
Jan (janneke) Nieuwenhuizen
e25edc22f7
mescc: Mes C Library: Add ntoab for M2-Planet.
...
* lib/m2/ntoab.c: New file.
2020-07-25 20:04:35 +02:00