Commit Graph

1683 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen c13941261e
mes: Run indent.
for i in $(find . -name '*.h' -o -name '*.c'); do indent $i --no-tabs --no-space-after-casts; done
2019-02-11 07:55:17 +01:00
Jan Nieuwenhuizen dac4283f7d
mes: Grand indent: prepare. 2019-02-11 07:53:39 +01:00
Jan Nieuwenhuizen 615a4a1d22
doc: Update WIP 2019-02-11 07:40:23 +01:00
Jan Nieuwenhuizen a5474558c4
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-02-11 07:19:44 +01:00
Jan Nieuwenhuizen 60e7c8491f
mescc: Mes C Library: Remove dead code.
* lib/glibc.c: Remove.
* lib/abtol.c: Remove.
2019-02-11 07:19:44 +01:00
Jan Nieuwenhuizen c971e02614
mescc: Mes C Library: Explode linux/tcc.c. WIP 2019-02-11 07:19:43 +01:00
Jan Nieuwenhuizen 3d615ee790
mescc: Mes C Library: Explode linux/libc.c. WIP 2019-02-11 07:19:43 +01:00
Jan Nieuwenhuizen b2afb3b3f3
mescc: Mes C Library: Explode linux/gnu.c. WIP 2019-02-11 07:19:43 +01:00
Jan Nieuwenhuizen 544d601aea
mescc: Mes C Library: Explode libc-mini.c. WIP 2019-02-11 07:19:43 +01:00
Jan Nieuwenhuizen 8b149e7f4f
mescc: Mes C Library: Cleanup includes.
* include/mes/lib-mini.h: Move from include/libmes-mini.h.  Update users.
* include/mes/lib.h: Move from include/libmes.h.  Update users.
2019-02-11 07:19:31 +01:00
Jan Nieuwenhuizen 4fc1f5444a
mescc: Support -nodefaultlibs, -nostartfiles, -nostdlib.
* module/mescc.scm (parse-opts): Parse -nodefaultlibs, -nostartfiles, -nostdlib.
* module/mescc/mescc.scm (mescc:link): Handle -nodefaultlibs, -nostdlib.
(hex2->elf): Handle -nostartfiles, -nostdlib.
2019-02-10 19:30:01 +01:00
Jan Nieuwenhuizen d0e6228fa1
build: Do not install test binaries.
* build-aux/install.sh.in: Do not install test binaries.
2019-02-10 19:30:01 +01:00
Jan Nieuwenhuizen 29950ae645
mes: m2: Move force-output to Scheme.
* mes/module/mes/guile.mes (force-output): New function.
* src/posix.c (force_output): Remove.
* src/mes.c (mes_builtins): Remove adding of force-output.
2019-02-10 19:30:01 +01:00
Jan Nieuwenhuizen 39693eca63
mescc: Mes C Library: Support gcc-4.6.4: vsscanf: Support *, [, s.
* lib/stdio/vsscanf.c (vsscanf): Support  *, [, s.
* lib/stdio/vfscanf.c (vfscanf): Likewise.
* lib/tests/stdio/90-sscanf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
* lib/x86-mes/x86.M1 (mov____%al,0x32(%ebp): New macro.
2019-02-10 19:30:01 +01:00
Jan Nieuwenhuizen 44add95226
mescc: Mes C Library: Support gcc-4.6.4: Allow larger qsort entries.
* lib/stdlib/qsort.c (qswap): Increase buffer to 128 bytes (gmp needs
36) and add assert.
2019-02-10 19:30:01 +01:00
Jan Nieuwenhuizen 544540d332
mescc: Mes C Library: Support gcc-4.6.4: Avoid type/size_t conflicts.
* include/alloca.h: Remove typedefs, include sys/types.h.
* include/stdint.h: Likewise.
* include/string.h: Likewise.
2019-02-10 19:30:01 +01:00
Jan Nieuwenhuizen 0f7af7ac61
mescc: Mes C Library: Support gcc-4.6.4: Add mmap, munmap.
* include/linux/x86/syscall.h (SYS_mmap, SYS_munmap): New macro.
* include/linux/x86_64/syscall.h (SYS_mmap, SYS_munmap): New macro.
* include/sys/mman.h (MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS,
MAP_POPULATE, MAP_ANON, MAP_FAILED): New macro.
(mmap, munmap): Declare.
* lib/linux/gnu.c (mmap, munmap): New function.
* lib/linux/x86-mes-gcc/mes.c (_sys_call6): New function.
* lib/linux/x86-mes/mes.c (__sys_call6): New function.
(_sys_call6): New function.
* lib/linux/x86_64-mes-gcc/mes.c (_sys_call6): New function.
* lib/linux/x86_64-mes/mes.c (__sys_call): Cater for 6 syscall parameters.
(_sys_call6): New function.
* lib/x86-mes/x86.M1 (pop____%ebp): New macro.
* lib/x86_64-mes/x86_64.M1 (mov____0x8(%rbp),%r9): New macro.
2019-02-10 19:29:52 +01:00
Jan Nieuwenhuizen 96b585aba4
mescc: Mes C Library: Support gcc-4.6.4: Add strtok.
* include/string.h (strtok): Declare.
* lib/string/strtok.c (strtok): New file.
* lib/libc+gnu.c: Include it.
2019-02-09 23:25:45 +01:00
Jan Nieuwenhuizen ace1056fab
mescc: Mes C Library: Support gcc-4.6.4: Add labs.
* lib/math/labs.c: New file.
* lib/libc+gnu.c: Include it.
* include/math.h (labs): Declare.
2019-02-09 23:25:45 +01:00
Jan Nieuwenhuizen 834a722029
mescc: Mes C Library: Support gcc-4.6.4: Implement rewind.
* lib/stdio/rewind.c: Move from ../stub.  Implement.
* include/stdio.h (rewind): Declare.
* lib/libc+gnu.c: Update include.
* lib/libg.c: Update include.
* lib/stub/rewind.c: Remove.
2019-02-09 23:25:45 +01:00
Jan Nieuwenhuizen 7f26f85e75
mescc: Mes C Library: Support gcc-4.6.4: Add asctime stub.
* lib/stub/asctime.c: New file.
* lib/libc+gnu.c: Include it.
* include/time.h (asctime): Declare.
2019-02-09 23:25:45 +01:00
Jan Nieuwenhuizen 61033960aa
mescc: Mes C Library: Support gcc-4.6.4: vfprintf, vsnprintf: #-type.
* lib/stdio/vfprintf.c (vfprintf): Support #-type prefix.  Show whole
format upon error.
* lib/stdio/vsnprintf.c (vsnprintf): Likewise.
* lib/stdio/vfscanf.c (vfscanf): Show whole template upon error.
* lib/stdio/vsscanf.c (vsscanf): Likewise.
2019-02-09 23:25:45 +01:00
Jan Nieuwenhuizen b7b8470247
mescc: Mes C Library: Support gcc-4.6.4: vfprintf, vsnprintf: pad with space.
* lib/stdio/vfprintf.c (vfprintf): pad with space.
* lib/stdio/vsnprintf.c (vsnprintf): pad with space.
2019-02-09 23:25:44 +01:00
Jan Nieuwenhuizen a6072afb98
mescc: Mes C Library: Support gcc-4.6.4: atexit: return 0.
* lib/stdlib/atexit.c (atexit): return 0.
2019-02-08 19:34:50 +01:00
Jan Nieuwenhuizen 82332f0c0b
mescc: Mes C Library: Support gcc-4.6.4: Add SSIZE_MAX macro.
* include/stdint.h (SSIZE_MAX): New macro.
2019-02-08 19:34:49 +01:00
Jan Nieuwenhuizen 31e03d1cd7
mescc: Mes C Library: Support gcc-4.6.4: Add math stubs.
* lib/math/ceil.c: New file.
* lib/math/floor.c: New file.
* lib/stub/atan2.c: New file.
* lib/stub/cos.c: New file.
* lib/stub/exp.c: New file.
* lib/stub/log.c: New file.
* lib/stub/modf.c: New file.
* lib/stub/pow.c: New file.
* lib/stub/sin.c: New file.
* lib/stub/sqrt.c: New file.
* lib/libc+gnu.c: Include them.
* include/math.h (atan2, ceil, cos, exp, fabs, floor, log, modf, pow,
sin, sqrt): Declare.
* lib/math/fabs.c: Update.
* lib/stub/ldexp.c: Update.
2019-02-08 19:34:49 +01:00
Jan Nieuwenhuizen b6bbbf66e9
mescc: Mes C Library: Support gcc-4.6.4: Add fscanf, vfscanf.
* lib/stdio/vfscanf.c: New file.
* lib/stdio/fscanf.c: New file.
* include/stdio.h (fscanf): Declare.
* include/stdarg.h (vfscanf): Declare.
* lib/libc+gnu.c: Include them.
* lib/libg.c: Likewise.
* lib/stub/fscanf.c: Remove.
2019-02-08 19:34:49 +01:00
Jan Nieuwenhuizen 76729c9971
mescc: Mes C Library: vfprintf, vsnprintf: Pad floats with space.
* lib/stdio/vfprintf.c (vfprintf): Pad floats with space.
* lib/stdio/vsnprintf.c (vsnprintf): Pad floats with space.
* lib/tests/stdio/90-sprintf.c: Test it.
2019-02-08 19:34:49 +01:00
Jan Nieuwenhuizen e930a00a35
mescc: Mes C Library: Support gcc-4.6.4: Add float macros.
* include/float.h (DBL_EPSILON, DBL_MANT_DIG, DBL_MAX, DBL_MIN,
FLT_RADIX, LDBL_EPSILON, LDBL_MANT_DIG, LDBL_MAX, LDBL_MIN): New
macro.
2019-02-08 19:34:49 +01:00
Jan Nieuwenhuizen 2121b98bda
mescc: Mes C Library: Support gcc-4.6.4: Add stdint [U]SHRT macros.
* include/stdint.h (SHRT_MAX, SHRT_MIN, USHRT_MAX, USHRT_MIN): New
macro.
2019-02-08 19:34:49 +01:00
Jan Nieuwenhuizen a3fb84e6a6
mescc: Mes C Library: Support gcc-4.6.4: Add abort prototype.
* include/stdlib.h (abort): Add prototype.
2019-02-08 19:34:49 +01:00
Jan Nieuwenhuizen 087a0767a0
mescc: Mes C Library: Support gcc-4.6.4: Fix ctime stub.
* lib/stub/ctime.c (ctime): Fix stub to avoid segfault upon use.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 6c1b4cf1d7
mescc: Mes C Library: Support gcc-4.6.4: Fix uintptr_t, add [u]intmax_t.
* include/stdint.h: Fix uintptr_t, add [u]intmax_t.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 510f82a575
.dir-locals.el: Assert default GNU settings.
* .dir-locals.el: Assert default GNU settings.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 17a46c5c64
Fix typo in stage0 copyright headers.
* lib/x86-mes/elf-0footer.hex2: Fix typo.
* lib/x86-mes/elf32-0header.hex2: Fix typo.
* lib/x86-mes/elf32-body-exit-42.hex2: Fix typo.
* lib/x86-mes/elf32-footer-single-main.hex2: Fix typo.
* lib/x86-mes/elf32-header.hex2: Fix typo.
* lib/x86_64-mes/elf-0footer.hex2: Fix typo.
* lib/x86_64-mes/elf64-0header.hex2: Fix typo.
* lib/x86_64-mes/elf64-body-exit-42.hex2: Fix typo.
* lib/x86_64-mes/elf64-footer-single-main.hex2: Fix typo.
* lib/x86_64-mes/elf64-header.hex2: Fix typo.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 6a11d4c9b7
build: M2-Planet first-aid, simplest build script possible.
* simple.sh: New file.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 9eaccf70eb
build: Replace POSIX, posix_p by WITH_GLIBC, wip_glibc_p.
* build-aux/build-mes.sh: Replace POSIX, posix_p by WITH_GLIBC, wip_glibc_p.
* build-aux/build.sh.in: Likewise.
* build-aux/cc.sh (link): Likewise.
* build-aux/config.make.in (with_glibc_p): Likewise.
* build-aux/config.sh (libc): Likewise.
(CPPFLAGS): Likewise.
* build-aux/config.status.in (with_glibc_p): Likewise.
* build-aux/test.sh: Likewise.
* configure (main): Likewise.
* configure.sh (subst): Likewise.
(mes_arch): Likewise.
* include/libmes.h: Likewise.
* include/linux/x86_64/syscall.h: Likewise.
* lib/libmes.c: Likewise.
* lib/tests/stdio/70-printf-hello.c (main): Likewise.
* lib/tests/stdio/70-printf-simple.c (main): Likewise.
* lib/tests/stdio/80-sscanf.c (main): Likewise.
* lib/tests/stdlib/50-malloc.c: Likewise.
* module/mescc/preprocess.scm (c99-input->full-ast): Likewise.
* scaffold/cons-mes.c: Likewise.
* scaffold/lib/stdlib/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/tests/61-array.c (getenv): Likewise.
* scaffold/tiny-mes.c: Likewise.
* src/mes.c: Likewise.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 15c8c9857a
mescc: Mes C Library: Fix compile warnings.
* include/libmes.h (dtoab, itoa, ltoa, ntoab, ultoa, utoa): Return
char* (WAS: char const*).
* lib/*/*c: Update, add missing includes.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 2183f4bb2a
mescc: Mes C Library: vsscanf: Increase count for scanned float.
* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.
2019-02-08 19:34:48 +01:00
Jan Nieuwenhuizen 6ffeec94a7
mescc: Mes C Library: Fix isatty.
* lib/posix/isatty.c (isatty): Test ioctl == 0.
* mes/module/mes/boot-0.scm.in: Update: no tty?: read from stdin.
2019-02-08 19:34:47 +01:00
Jan Nieuwenhuizen d23b72589d
test: 50-getenv: Test PATH, allow to fail.
* lib/tests/posix/50-getenv.c (main): Test PATH.
* build-aux/check-mescc.sh (broken): Add 50-getenv.
2019-02-08 19:34:47 +01:00
Jan Nieuwenhuizen 9a0daee989
mes: Support map and for-each with lists of unequal length.
* mes/module/mes/base.mes (map): Support lists of unequal length.
* mes/module/mes/scm.mes (for-each): Likewise.
* module/mescc/compile.scm (expr->register): Fix compile warning.
* tests/scm.test ("map 1,2", "map 2,1", "for-each 1,2", "for-each
2,1": Test it.
2019-02-08 19:34:47 +01:00
Jan Nieuwenhuizen 5f0e6200dc
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-02-08 19:34:47 +01:00
Jan Nieuwenhuizen 013cb1f33d
mescc: Mes C Library: Support GNU Sed: Fix ungetc.
* include/sys/resource.h (OPEN_MAX, RLIMIT_NOFILE): New macro.
* lib/libc.c: Add memset.c include.
* lib/libc+tcc.c: Remove memset.c include.
* lib/linux/tcc.c (close):
* lib/mes/fdgetc.c (__ungetc_buf): New global.
(_ungetc_pos, _ungetc_fd, _ungetc_buf): Remove.  Update users.
* scaffold/tests/65-read.c: Update.
2019-02-08 19:34:47 +01:00
Jan Nieuwenhuizen 4d6084b20b
mescc: Mes C Library: Support GNU Tar: Fix getpwnam, getpwuid stubs.
* lib/stub/getpwnam.c (getpwnam): Return pointer to static struct
passwd.
* lib/stub/getpwuid.c (getpwuid): Likewise.
2019-02-08 19:34:47 +01:00
Jan Nieuwenhuizen e81e48c701
mescc: Mes C Library: Support GNU Tar: Add getgrgid, getgrnam, setgrent stub.
* include/grp.h: New file.
* lib/stub/getgrgid.c: New file.
* lib/stub/getgrnam.c: New file.
* lib/stub/setgrent.c: New file.
* lib/libc+gnu.c: Include them.
2019-02-08 19:34:47 +01:00
Jan Nieuwenhuizen 27045d21dc
mescc: Mes C Library: Support GNU Awk: Add wchar_t.
* include/sys/types.h (wchar_t): New typedef.
2019-02-08 19:34:46 +01:00
Jan Nieuwenhuizen a652026c08
mescc: Mes C Library: Support GNU Awk: Add getpgid, getpgrp stubs.
* include/unistd.h (getpgid, getpgrp): Declare.
* lib/stub/getpgid.c: New file.
* lib/stub/getpgrp.c: New file.
* lib/libc+gnu.c: Include them.
2019-02-08 19:34:46 +01:00
Jan Nieuwenhuizen 6f08fee316
mescc: Mes C Library: Support GNU Tar: Add mktime stub, fix localtime stub.
* include/time.h (mktime): Declare.
* lib/stub/mktime.c: New stub.
* lib/libc+gnu.c: Include it.
* lib/stub/localtime.c (localtime): Return pointer to static struct
tm.  Avoids segfaults.
2019-02-08 19:34:46 +01:00
Jan Nieuwenhuizen 29272e3d96
mescc: Mes C Library: Support GNU Tar: Add creat, mknod.
* include/linux/x86_64/syscall.h (SYS_mknod): New macro.
* include/linux/x86/syscall.h (SYS_mknod): New macro.
* lib/linux/gnu.c (mknod): New function, use it.
* include/sys/stat.h: Declare it.
* include/fcntl.h (creat): New macro.
2019-02-08 19:34:46 +01:00