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.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-11-14 05:25:55 +01:00 committed by Janneke Nieuwenhuizen
parent e354d912ef
commit dad460189f
40 changed files with 182 additions and 463 deletions

View file

@ -48,7 +48,6 @@ sed -ri \
include/mes/mes.h \ include/mes/mes.h \
include/mes/symbols.h \ include/mes/symbols.h \
include/mes/builtins.h \ include/mes/builtins.h \
include/m2/lib.h \
src/builtins.c \ src/builtins.c \
src/cc.c \ src/cc.c \
src/core.c \ src/core.c \

View file

@ -69,8 +69,11 @@
#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode) #define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode)
int dup (int old); int dup (int old);
int dup2 (int old, int new); int dup2 (int old, int new);
#if !__M2__
int fcntl (int filedes, int command, ...); int fcntl (int filedes, int command, ...);
int open (char const *s, int flags, ...); int open (char const *s, int flags, ...);
#endif
#endif // ! SYSTEM_LIBC #endif // ! SYSTEM_LIBC

View file

@ -25,47 +25,29 @@
/* libc-mini */ /* libc-mini */
#ifndef SYS_exit #ifndef SYS_exit
// CONSTANT SYS_exit 0x01
#define SYS_exit 0x01 #define SYS_exit 0x01
#endif #endif
#ifndef SYS_write #ifndef SYS_write
// CONSTANT SYS_write 0x04
#define SYS_write 0x04 #define SYS_write 0x04
#endif #endif
/* libc */ /* libc */
// CONSTANT SYS_fork 0x02
#define SYS_fork 0x02 #define SYS_fork 0x02
// CONSTANT SYS_read 0x03
#define SYS_read 0x03 #define SYS_read 0x03
// CONSTANT SYS_open 0x05
#define SYS_open 0x05 #define SYS_open 0x05
//#define SYS_waitpid //#define SYS_waitpid
// CONSTANT SYS_wait4 0x72
#define SYS_wait4 0x72 #define SYS_wait4 0x72
// CONSTANT SYS_execve 0x0b
#define SYS_execve 0x0b #define SYS_execve 0x0b
// CONSTANT SYS_chmod 0x0f
#define SYS_chmod 0x0f #define SYS_chmod 0x0f
// CONSTANT SYS_access 0x21
#define SYS_access 0x21 #define SYS_access 0x21
// CONSTANT SYS_brk 0x2d
#define SYS_brk 0x2d #define SYS_brk 0x2d
// CONSTANT SYS_ioctl 0x36
#define SYS_ioctl 0x36 #define SYS_ioctl 0x36
// CONSTANT SYS_fsync 0x76
#define SYS_fsync 0x76 #define SYS_fsync 0x76
// CONSTANT SYS_getcwd 0xb7
#define SYS_getcwd 0xb7 #define SYS_getcwd 0xb7
// CONSTANT SYS_dup 0x29
#define SYS_dup 0x29 #define SYS_dup 0x29
// CONSTANT SYS_dup2 0x3f
#define SYS_dup2 0x3f #define SYS_dup2 0x3f
// CONSTANT SYS_unlink 0x0a
#define SYS_unlink 0x0a #define SYS_unlink 0x0a
// CONSTANT SYS_gettimeofday 0x4e
#define SYS_gettimeofday 0x4e #define SYS_gettimeofday 0x4e
// CONSTANT SYS_clock_gettime 0x107
#define SYS_clock_gettime 0x107 #define SYS_clock_gettime 0x107
/* libc+tcc */ /* libc+tcc */

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -22,50 +22,30 @@
/* libc-mini */ /* libc-mini */
#ifndef SYS_exit #ifndef SYS_exit
// CONSTANT SYS_exit 0x01
#define SYS_exit 0x01 #define SYS_exit 0x01
#endif #endif
#ifndef SYS_write #ifndef SYS_write
// CONSTANT SYS_write 0x04
#define SYS_write 0x04 #define SYS_write 0x04
#endif #endif
/* libc */ /* libc */
// CONSTANT SYS_fork 0x02
#define SYS_fork 0x02 #define SYS_fork 0x02
// CONSTANT SYS_read 0x03
#define SYS_read 0x03 #define SYS_read 0x03
// CONSTANT SYS_open 0x05
#define SYS_open 0x05 #define SYS_open 0x05
// CONSTANT SYS_waitpid 0x07
#define SYS_waitpid 0x07 #define SYS_waitpid 0x07
// CONSTANT SYS_wait4 0x72
#define SYS_wait4 0x72 #define SYS_wait4 0x72
// CONSTANT SYS_execve 0x0b
#define SYS_execve 0x0b #define SYS_execve 0x0b
// CONSTANT SYS_chmod 0x0f
#define SYS_chmod 0x0f #define SYS_chmod 0x0f
// CONSTANT SYS_access 0x21
#define SYS_access 0x21 #define SYS_access 0x21
// CONSTANT SYS_brk 0x2d
#define SYS_brk 0x2d #define SYS_brk 0x2d
// CONSTANT SYS_ioctl 0x36
#define SYS_ioctl 0x36 #define SYS_ioctl 0x36
// CONSTANT SYS_fsync 0x76
#define SYS_fsync 0x76 #define SYS_fsync 0x76
// CONSTANT SYS_getcwd 0xb7
#define SYS_getcwd 0xb7 #define SYS_getcwd 0xb7
// CONSTANT SYS_dup 0x29
#define SYS_dup 0x29 #define SYS_dup 0x29
// CONSTANT SYS_dup2 0x3f
#define SYS_dup2 0x3f #define SYS_dup2 0x3f
// CONSTANT SYS_unlink 0x0a
#define SYS_unlink 0x0a #define SYS_unlink 0x0a
// CONSTANT SYS_gettimeofday 0x4e
#define SYS_gettimeofday 0x4e #define SYS_gettimeofday 0x4e
// CONSTANT SYS_clock_gettime 0x109
#define SYS_clock_gettime 0x109 #define SYS_clock_gettime 0x109
// CONSTANT SYS_time 0x0d
#define SYS_time 0x0d #define SYS_time 0x0d
/* libc+tcc */ /* libc+tcc */

View file

@ -1,70 +0,0 @@
/*
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __M2_LIB_H
#define __M2_LIB_H
char **environ;
int __stdin;
int __stdout;
int __stderr;
int errno;
// CONSTANT EOF 0xffffffff
// CONSTANT __FILEDES_MAX 512
char* cast_intp_to_charp (int *i);
char* cast_long_to_charp (long i);
long cast_charp_to_long (char const *);
long cast_int_to_long (int i);
long cast_voidp_to_long (void const *);
char *itoa (int number);
char *ltoa (long number);
int __ungetc_p (int filedes);
int eputs (char *s);
int oputs (char *s);
int puts (char *s);
size_t strlen (char *s);
ssize_t _write ();
ssize_t write (int filedes, void *buffer, size_t size);
void __ungetc_clear (int filedes);
void __ungetc_init ();
void __ungetc_set (int filedes, int c);
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
struct timespec
{
long tv_sec;
long tv_nsec;
};
struct timeval
{
long tv_sec;
long tv_usec;
};
#endif /* __M2_LIB_H */

View file

@ -20,6 +20,13 @@
#ifndef __M2_TYPES_H #ifndef __M2_TYPES_H
#define __M2_TYPES_H 1 #define __M2_TYPES_H 1
// FIXME M2_Planet chokes on -1, even inside #if ! __M2__
#if __arm__ || __i386__
#define EOF 0xffffffff
#else
#define EOF 0xffffffffffffffff
#endif
/* /*
#ifndef __MES_CLOCK_T #ifndef __MES_CLOCK_T
#define __MES_CLOCK_T #define __MES_CLOCK_T

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -23,76 +23,32 @@
/* Cell types */ /* Cell types */
// CONSTANT TCHAR 0
#define TCHAR 0 #define TCHAR 0
// CONSTANT TBYTES 1
#define TBYTES 1 #define TBYTES 1
// CONSTANT TCLOSURE 2
#define TCLOSURE 2 #define TCLOSURE 2
// CONSTANT TCONTINUATION 3
#define TCONTINUATION 3 #define TCONTINUATION 3
// CONSTANT TKEYWORD 4
#define TKEYWORD 4 #define TKEYWORD 4
// CONSTANT TMACRO 5
#define TMACRO 5 #define TMACRO 5
// CONSTANT TNUMBER 6
#define TNUMBER 6 #define TNUMBER 6
// CONSTANT TPAIR 7
#define TPAIR 7 #define TPAIR 7
// CONSTANT TPORT 8
#define TPORT 8 #define TPORT 8
// CONSTANT TREF 9
#define TREF 9 #define TREF 9
// CONSTANT TSPECIAL 10
#define TSPECIAL 10 #define TSPECIAL 10
// CONSTANT TSTRING 11
#define TSTRING 11 #define TSTRING 11
// CONSTANT TSTRUCT 12
#define TSTRUCT 12 #define TSTRUCT 12
// CONSTANT TSYMBOL 13
#define TSYMBOL 13 #define TSYMBOL 13
// CONSTANT TVALUES 14
#define TVALUES 14 #define TVALUES 14
// CONSTANT TVARIABLE 15
#define TVARIABLE 15 #define TVARIABLE 15
// CONSTANT TVECTOR 16
#define TVECTOR 16 #define TVECTOR 16
// CONSTANT TBROKEN_HEART 17
#define TBROKEN_HEART 17 #define TBROKEN_HEART 17
/* Struct types */ /* Struct types */
// CONSTANT STRUCT_TYPE 0
#define STRUCT_TYPE 0 #define STRUCT_TYPE 0
// CONSTANT STRUCT_PRINTER 1
#define STRUCT_PRINTER 1 #define STRUCT_PRINTER 1
// CONSTANT GC_FRAME_SIZE 5
#define GC_FRAME_SIZE 5 #define GC_FRAME_SIZE 5
// CONSTANT GC_FRAME_PROCEDURE 4
#define GC_FRAME_PROCEDURE 4 #define GC_FRAME_PROCEDURE 4
// CONSTANT STDIN 0
// CONSTANT STDOUT 1
// CONSTANT STDERR 2
/* Unknown type 1
// CONSTANT EOF -1
*/
// CONSTANT O_RDONLY 0
// CONSTANT O_WRONLY 1
// CONSTANT O_CREAT 0x40
// CONSTANT O_TRUNC 0x200
// CONSTANT PATH_MAX 1024
// CONSTANT __FILEDES_MAX 512
// CONSTANT S_IRUSR 00400
// CONSTANT S_IWUSR 00200
// CONSTANT CLOCK_PROCESS_CPUTIME_ID 2
#endif /* __MES_CONSTANTS_H */ #endif /* __MES_CONSTANTS_H */

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -17,13 +17,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __MES_LIB_CC_H
#define __MES_LIB_CC_H
#include <mes/lib.h> #define EOF -1
void _exit (int code); #if __TINYC__ || SYSTEM_LIBC
#define __raise(x) -1
#endif
void #endif //__MES_LIB_CC_H
exit (int code)
{
_exit (code);
}

View file

@ -22,6 +22,7 @@
#define __MES_LIB_H #define __MES_LIB_H
#include <mes/lib-mini.h> #include <mes/lib-mini.h>
#include <mes/lib-cc.h>
#define __FILEDES_MAX 512 #define __FILEDES_MAX 512
extern char *__brk; extern char *__brk;
@ -66,7 +67,6 @@ long __mesabi_idiv (long a, long b);
void *__memcpy (void *dest, void const *src, size_t n); void *__memcpy (void *dest, void const *src, size_t n);
void *__memmove (void *dest, void const *src, size_t n); void *__memmove (void *dest, void const *src, size_t n);
void *__memset (void *s, int c, size_t n); void *__memset (void *s, int c, size_t n);
int __raise (int signal);
#if !SYSTEM_LIBC #if !SYSTEM_LIBC
void __assert_fail (char const *s, char const *file, unsigned line, void __assert_fail (char const *s, char const *file, unsigned line,
@ -75,6 +75,9 @@ ssize_t __buffered_read (int filedes, void *buffer, size_t size);
size_t __buffered_read_clear (int filedes); size_t __buffered_read_clear (int filedes);
void _exit (int code); void _exit (int code);
long brk (void *addr); long brk (void *addr);
#ifndef __raise
int __raise (int signal);
#endif
#endif // !SYSTEM_LIBC #endif // !SYSTEM_LIBC
#if !__M2__ #if !__M2__

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -137,14 +137,8 @@ extern struct scm *cell_type_broken_heart;
extern struct scm *cell_symbol_program; extern struct scm *cell_symbol_program;
extern struct scm *cell_symbol_test; extern struct scm *cell_symbol_test;
// CONSTANT SYMBOL_MAX 114
#define SYMBOL_MAX 114 #define SYMBOL_MAX 114
// CONSTANT CELL_UNSPECIFIED 7
#define CELL_UNSPECIFIED 7 #define CELL_UNSPECIFIED 7
// CONSTANT CELL_SYMBOL_RECORD_TYPE 82
#define CELL_SYMBOL_RECORD_TYPE 82 #define CELL_SYMBOL_RECORD_TYPE 82
#endif /* __MES_SYMBOLS_H */ #endif /* __MES_SYMBOLS_H */

View file

@ -29,9 +29,12 @@
#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long))) #define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long)))
typedef struct { #if !__M2__
typedef struct
{
unsigned long items[_SIGSET_NITEMS]; unsigned long items[_SIGSET_NITEMS];
} sigset_t; } sigset_t;
#endif
typedef long stack_t; typedef long stack_t;
#include <sys/types.h> #include <sys/types.h>
@ -91,6 +94,7 @@ typedef long stack_t;
#define SA_NOMASK SA_NODEFER #define SA_NOMASK SA_NODEFER
#define SA_ONESHOT SA_RESETHAND #define SA_ONESHOT SA_RESETHAND
#if !__M2__ // lacks short, casts
typedef struct siginfo_t typedef struct siginfo_t
{ {
int si_signo; int si_signo;
@ -120,7 +124,7 @@ typedef struct siginfo_t
} siginfo_t; } siginfo_t;
// *INDENT-ON* // *INDENT-ON*
#if __MESC__ #if __M2__ || __MESC__
typedef long sighandler_t; typedef long sighandler_t;
#else #else
typedef void (*sighandler_t) (int); typedef void (*sighandler_t) (int);
@ -255,6 +259,7 @@ int sigemptyset (sigset_t * set);
#endif #endif
int sigprocmask (int how, sigset_t const *set, sigset_t * oldset); int sigprocmask (int how, sigset_t const *set, sigset_t * oldset);
#endif // !__M2__
#endif //! SYSTEM_LIBC #endif //! SYSTEM_LIBC
#endif // __MES_SIGNAL_H #endif // __MES_SIGNAL_H

View file

@ -28,8 +28,13 @@
#define TCGETS 0x5401 #define TCGETS 0x5401
#define TCGETA 0x5405 #define TCGETA 0x5405
#if __M2__
int ioctl (int fd, unsigned request, long data);
int ioctl3 (int fd, unsigned request, long data);
#else
int ioctl (int fd, unsigned long request, ...); int ioctl (int fd, unsigned long request, ...);
int ioctl3 (int fd, unsigned long request, long data); int ioctl3 (int fd, unsigned long request, long data);
#endif
#endif // ! SYSTEM_LIBC #endif // ! SYSTEM_LIBC

View file

@ -20,6 +20,8 @@
#ifndef __MES_SYS_TYPES_H #ifndef __MES_SYS_TYPES_H
#define __MES_SYS_TYPES_H 1 #define __MES_SYS_TYPES_H 1
#include <mes/lib-cc.h>
#if SYSTEM_LIBC #if SYSTEM_LIBC
#undef __MES_SYS_TYPES_H #undef __MES_SYS_TYPES_H
#include_next <sys/types.h> #include_next <sys/types.h>
@ -31,10 +33,6 @@
#define __MESCCLIB__ 15 #define __MESCCLIB__ 15
#endif #endif
#ifndef EOF
#define EOF -1
#endif
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
@ -142,9 +140,13 @@ typedef long sigval_t;
#ifndef __MES_SIZE_T #ifndef __MES_SIZE_T
#define __MES_SIZE_T #define __MES_SIZE_T
#undef size_t #undef size_t
#if __M2__
typedef unsigned size_t;
#else
typedef unsigned long size_t; typedef unsigned long size_t;
#endif #endif
#endif #endif
#endif
#ifndef __MES_SSIZE_T #ifndef __MES_SSIZE_T
#define __MES_SSIZE_T #define __MES_SSIZE_T

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -27,8 +27,8 @@
#ifndef __MES_TIME_T #ifndef __MES_TIME_T
#define __MES_TIME_T 1 #define __MES_TIME_T 1
typedef long int clockid_t; typedef long clockid_t;
typedef long int time_t; typedef long time_t;
#endif #endif
struct tm struct tm

View file

@ -25,35 +25,42 @@ stage0_cpu=${stage0_cpu:-x86}
mkdir -p m2 mkdir -p m2
M2-Planet \ M2-Planet \
--bootstrap-mode \
--debug \ --debug \
--architecture ${stage0_cpu} \ --architecture ${stage0_cpu} \
-f include/m2/lib.h \ -D __linux__=1 \
-f include/mes/config.h \
-f include/mes/lib-mini.h \
-f include/mes/lib.h \
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \ -f lib/linux/${mes_cpu}-mes-m2/crt1.c \
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \ -f lib/linux/${mes_cpu}-mes-m2/_exit.c \
-f lib/linux/${mes_cpu}-mes-m2/_write.c \ -f lib/linux/${mes_cpu}-mes-m2/_write.c \
-f lib/mes/globals.c \ -f lib/mes/globals.c \
-f lib/m2/cast.c \ -f lib/m2/cast.c \
-f lib/m2/exit.c \ -f lib/stdlib/exit.c \
-f lib/mes/write.c \ -f lib/mes/write.c \
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
-f include/linux/${mes_cpu}/syscall.h \ -f include/linux/${mes_cpu}/syscall.h \
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
-f lib/stub/__raise.c \ -f lib/stub/__raise.c \
-f lib/linux/brk.c \ -f lib/linux/brk.c \
-f lib/m2/malloc.c \ -f lib/linux/malloc.c \
-f lib/string/memset.c \ -f lib/string/memset.c \
-f lib/m2/read.c \ -f lib/linux/read.c \
-f lib/mes/fdgetc.c \ -f lib/mes/fdgetc.c \
-f lib/stdio/getchar.c \ -f lib/stdio/getchar.c \
-f lib/stdio/putchar.c \ -f lib/stdio/putchar.c \
-f lib/m2/open.c \ -f lib/stub/__buffered_read.c \
-f lib/m2/mes_open.c \ -f lib/linux/_open3.c \
-f lib/linux/open.c \
-f lib/mes/mes_open.c \
-f lib/string/strlen.c \ -f lib/string/strlen.c \
-f lib/mes/eputs.c \ -f lib/mes/eputs.c \
-f lib/mes/fdputc.c \ -f lib/mes/fdputc.c \
-f lib/mes/eputc.c \ -f lib/mes/eputc.c \
\ \
-f include/time.h \
-f include/sys/time.h \
-f include/m2/types.h \ -f include/m2/types.h \
-f include/sys/types.h \
-f include/mes/mes.h \ -f include/mes/mes.h \
-f include/mes/builtins.h \ -f include/mes/builtins.h \
-f include/mes/constants.h \ -f include/mes/constants.h \
@ -84,17 +91,19 @@ M2-Planet \
-f lib/linux/access.c \ -f lib/linux/access.c \
-f include/linux/m2/kernel-stat.h \ -f include/linux/m2/kernel-stat.h \
-f include/sys/stat.h \ -f include/sys/stat.h \
-f lib/m2/chmod.c \ -f lib/linux/chmod.c \
-f lib/linux/ioctl3.c \ -f lib/linux/ioctl3.c \
-f include/sys/ioctl.h \
-f lib/m2/isatty.c \ -f lib/m2/isatty.c \
-f lib/linux/fork.c \ -f lib/linux/fork.c \
-f lib/m2/execve.c \ -f lib/m2/execve.c \
-f lib/m2/execv.c \ -f lib/m2/execv.c \
-f lib/m2/waitpid.c \ -f lib/linux/waitpid.c \
-f lib/linux/gettimeofday.c \ -f lib/linux/gettimeofday.c \
-f lib/m2/clock_gettime.c \ -f lib/linux/clock_gettime.c \
-f lib/m2/time.c \ -f lib/m2/time.c \
-f lib/linux/_getcwd.c \ -f lib/linux/_getcwd.c \
-f include/limits.h \
-f lib/m2/getcwd.c \ -f lib/m2/getcwd.c \
-f lib/linux/dup.c \ -f lib/linux/dup.c \
-f lib/linux/dup2.c \ -f lib/linux/dup2.c \
@ -105,6 +114,7 @@ M2-Planet \
-f src/core.c \ -f src/core.c \
-f src/display.c \ -f src/display.c \
-f src/eval-apply.c \ -f src/eval-apply.c \
-f include/fcntl.h \
-f src/gc.c \ -f src/gc.c \
-f src/hash.c \ -f src/hash.c \
-f src/lib.c \ -f src/lib.c \
@ -112,6 +122,7 @@ M2-Planet \
-f src/math.c \ -f src/math.c \
-f src/mes.c \ -f src/mes.c \
-f src/module.c \ -f src/module.c \
-f include/signal.h \
-f src/posix.c \ -f src/posix.c \
-f src/reader.c \ -f src/reader.c \
-f src/stack.c \ -f src/stack.c \

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -24,23 +24,23 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
off_t off_t
_lseek (int filedes, off_t offset, int whence) _lseek (int filedes, off_t offset, int whence)
{ {
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence); long long_offset = offset;
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
} }
#endif
off_t off_t
lseek (int filedes, off_t offset, int whence) lseek (int filedes, off_t offset, int whence)
{ {
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */ #if !__MESC__ && !__M2__
if (_lseek (filedes, 0, SEEK_CUR) == -1) if (_lseek (filedes, 0, SEEK_CUR) == -1)
return -1; return -1;
#endif #endif
size_t skip = __buffered_read_clear (filedes); size_t skip = __buffered_read_clear (filedes);
if (whence == SEEK_CUR) if (whence == SEEK_CUR)
offset -= skip; offset -= skip;
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence); long long_offset = offset;
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
} }

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -24,6 +24,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
#if __M2__
int int
open (char *file_name, int flags, int mask) open (char *file_name, int flags, int mask)
{ {
@ -32,3 +33,17 @@ open (char *file_name, int flags, int mask)
__ungetc_clear (r); __ungetc_clear (r);
return r; return r;
} }
#else // !__M2__
int
open (char const *file_name, int flags, ...)
{
va_list ap;
va_start (ap, flags);
int mask = va_arg (ap, int);
int r = _sys_call3 (SYS_open, (long) file_name, flags, mask);
va_end (ap);
if (r > 2)
__ungetc_clear (r);
return r;
}
#endif // !__M2__

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -25,10 +25,13 @@
pid_t pid_t
waitpid (pid_t pid, int *status_ptr, int options) waitpid (pid_t pid, int *status_ptr, int options)
{ {
long long_pid = pid;
long long_status_ptr = cast_voidp_to_long (status_ptr);
long long_options = options;
#if __i386__ #if __i386__
return _sys_call3 (SYS_waitpid, (long) pid, (long) status_ptr, (int) options); return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
#elif __x86_64__ || __arm__ #elif __x86_64__ || __arm__
return _sys_call4 (SYS_wait4, (long) pid, (long) status_ptr, (int) options, 0); return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options, 0);
#else #else
#error arch not supported #error arch not supported
#endif #endif

View file

@ -1,31 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <sys/stat.h>
int
chmod (char const *file_name, int mask)
{
long long_file_name = file_name;
long long_mask = mask;
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
}

View file

@ -1,30 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <time.h>
int
clock_gettime (long clk_id, struct timespec *tp)
{
long long_tp = tp;
return _sys_call2 (SYS_clock_gettime, clk_id, tp);
}

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -24,8 +24,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
// CONSTANT PATH_MAX 1024
char *__getcwd_buf; char *__getcwd_buf;
char * char *

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -24,7 +24,6 @@
#include <string.h> #include <string.h>
#include <termio.h> #include <termio.h>
// CONSTANT TCGETS 0x5401
#define TCGETS 0x5401 #define TCGETS 0x5401
struct ktermios struct ktermios

View file

@ -1,36 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <string.h>
char *__brk = 0;
void *
malloc (size_t size)
{
if (!__brk)
__brk = cast_long_to_charp (brk (0));
if (brk (__brk + size) == -1)
return 0;
char *p = __brk;
__brk = __brk + size;
return p;
}

View file

@ -1,28 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
mes_open (char *file_name, int flags, int mask)
{
int filedes = open (file_name, flags, mask);
if (filedes > 2)
__ungetc_clear (filedes);
return filedes;
}

View file

@ -1,31 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2019,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <mes/lib.h>
#include <fcntl.h>
long
read (int filedes, void *buffer, long size)
{
long bytes = _sys_call3 (SYS_read, filedes, buffer, size);
return bytes;
}

View file

@ -1,39 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <sys/types.h>
int
waitpid (int pid, int *status_ptr, int options)
{
long long_pid = pid;
long long_status_ptr = cast_voidp_to_long (status_ptr);
long long_options = options;
//##if __i386__
//# return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
//##elif __x86_64__ || __arm__
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options, 0);
//##else
//##error arch not supported
//##endif
}

View file

@ -31,12 +31,6 @@ struct ldiv_t
long rem; long rem;
}; };
int __raise (int);
#if __TINYC__ || SYSTEM_LIBC
#define __raise(x) -1
#endif
void void
__mesabi_div0 (void) __mesabi_div0 (void)
{ {

View file

@ -23,7 +23,19 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if __M2_PLANET__ || (!(__MESC__ && __arm__) && !(__TINYC__ && __arm__ && BOOTSTRAP)) #if __MESC__ && __arm__
#define __MESC__and__arm__
#endif
#if __TINYC__ && __arm__ && BOOTSTRAP
#define __TINYC__and__arm__and__BOOTSTRAP
#endif
#define __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP !defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP)
// FIXME: M2-Planet 1.10.0 crashes on this...
// #if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP))
#if __M2__ || __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP
size_t size_t
__mesabi_uldiv (size_t a, size_t b, size_t *remainder) __mesabi_uldiv (size_t a, size_t b, size_t *remainder)
{ {

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -23,8 +23,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <mes/lib.h> #include <mes/lib.h>
char *__getcwd_buf;
char * char *
getcwd (char *buffer, size_t size) getcwd (char *buffer, size_t size)
{ {

View file

@ -1,6 +1,6 @@
/* /*
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -22,8 +22,11 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
// CONSTANT M2_PTR_SIZE 4 #if __M2__
#define M2_PTR_SIZE 4
#else
#define M2_PTR_SIZE 1 #define M2_PTR_SIZE 1
#endif
char * char *
getenv (char const *s) getenv (char const *s)

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -22,8 +22,11 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
// CONSTANT M2_PTR_SIZE 4 #if __M2__
#define M2_PTR_SIZE 4
#else
#define M2_PTR_SIZE 1 #define M2_PTR_SIZE 1
#endif
int int
setenv (char const *s, char const *v, int overwrite_p) setenv (char const *s, char const *v, int overwrite_p)

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -18,8 +18,6 @@
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/ */
// CONSTANT SIGABRT 0
int int
__raise (int signum) __raise (int signum)
{ {

View file

@ -44,7 +44,8 @@ M2-Planet \
-f lib/mes/fdgetc.c \ -f lib/mes/fdgetc.c \
-f lib/stdio/getchar.c \ -f lib/stdio/getchar.c \
-f lib/stdio/putchar.c \ -f lib/stdio/putchar.c \
-f lib/m2/open.c \ -f lib/linux/open.c \
-f include/m2/types.h \
-f include/sys/types.h \ -f include/sys/types.h \
-f include/stdio.h \ -f include/stdio.h \
-f scaffold/read.c \ -f scaffold/read.c \

View file

@ -33,7 +33,7 @@ M2_PLANET_FUBAR = i386
#M2_PLANET_ARCH = amd64 #M2_PLANET_ARCH = amd64
#M2_PLANET_FUBAR = amd64 #M2_PLANET_FUBAR = amd64
M2_PLANET_FLAGS = --bootstrap-mode --debug --architecture $(M2_PLANET_ARCH) M2_PLANET_FLAGS = --debug --architecture $(M2_PLANET_ARCH)
CFLAGS:= \ CFLAGS:= \
$(CFLAGS) \ $(CFLAGS) \
@ -78,20 +78,24 @@ M2_SOURCES = \
lib/linux/x86-mes-m2/_write.c \ lib/linux/x86-mes-m2/_write.c \
lib/mes/globals.c \ lib/mes/globals.c \
lib/m2/cast.c \ lib/m2/cast.c \
lib/m2/exit.c \ lib/stdlib/exit.c \
lib/mes/write.c \ lib/stub/__buffered_read.c \
lib/linux/x86-mes-m2/syscall.c \ lib/linux/x86-mes-m2/syscall.c \
lib/stub/__raise.c \ lib/stub/__raise.c \
lib/linux/brk.c \ lib/linux/brk.c \
lib/m2/malloc.c \ lib/linux/malloc.c \
lib/string/memset.c \ lib/string/memset.c \
\ lib/linux/read.c \
lib/m2/read.c \
lib/mes/fdgetc.c \ lib/mes/fdgetc.c \
lib/linux/lseek.c \
lib/posix/write.c \
\
lib/stdio/getchar.c \ lib/stdio/getchar.c \
lib/stdio/putchar.c \ lib/stdio/putchar.c \
lib/m2/open.c \ lib/stub/__buffered_read.c \
lib/m2/mes_open.c \ lib/linux/_open3.c \
lib/linux/open.c \
lib/mes/mes_open.c \
lib/string/strlen.c \ lib/string/strlen.c \
lib/mes/eputs.c \ lib/mes/eputs.c \
lib/mes/fdputc.c \ lib/mes/fdputc.c \
@ -120,15 +124,15 @@ M2_SOURCES = \
lib/mes/fdungetc.c \ lib/mes/fdungetc.c \
lib/posix/setenv.c \ lib/posix/setenv.c \
lib/linux/access.c \ lib/linux/access.c \
lib/m2/chmod.c \ lib/linux/chmod.c \
lib/linux/ioctl3.c \ lib/linux/ioctl3.c \
lib/m2/isatty.c \ lib/m2/isatty.c \
lib/linux/fork.c \ lib/linux/fork.c \
lib/m2/execve.c \ lib/m2/execve.c \
lib/m2/execv.c \ lib/m2/execv.c \
lib/m2/waitpid.c \ lib/linux/waitpid.c \
lib/linux/gettimeofday.c \ lib/linux/gettimeofday.c \
lib/m2/clock_gettime.c \ lib/linux/clock_gettime.c \
lib/m2/time.c \ lib/m2/time.c \
lib/linux/_getcwd.c \ lib/linux/_getcwd.c \
lib/m2/getcwd.c \ lib/m2/getcwd.c \
@ -139,12 +143,6 @@ M2_SOURCES = \
lib/linux/unlink.c \ lib/linux/unlink.c \
src/m2.c src/m2.c
M2_TODO = \
lib/m2/file_print.c \
lib/mes/ntoab.c \
lib/mes/fdgetc.c \
lib/mes/fdungetc.c
INCLUDES = \ INCLUDES = \
include/mes/builtins.h \ include/mes/builtins.h \
include/mes/constants.h \ include/mes/constants.h \
@ -189,8 +187,18 @@ bin/gc-gcc: simple.make $(GCC_SOURCES) $(TEST_GC_SOURCES) $(INCLUDES) | bin
$(CC) $(CFLAGS) -D GC_TEST=1 -o $@ $(GCC_SOURCES) $(TEST_GC_SOURCES) $(CC) $(CFLAGS) -D GC_TEST=1 -o $@ $(GCC_SOURCES) $(TEST_GC_SOURCES)
M2_PLANET_INCLUDES = \ M2_PLANET_INCLUDES = \
include/m2/lib.h \ include/mes/config.h \
include/mes/lib-mini.h \
include/mes/lib.h \
include/linux/x86/syscall.h \ include/linux/x86/syscall.h \
include/time.h \
include/sys/time.h \
include/sys/types.h \
include/stdio.h \
include/limits.h \
include/sys/stat.h \
include/fcntl.h \
include/signal.h \
include/mes/mes.h \ include/mes/mes.h \
include/mes/builtins.h \ include/mes/builtins.h \
include/mes/constants.h \ include/mes/constants.h \

View file

@ -148,7 +148,7 @@ length (struct scm *x)
struct scm * struct scm *
error (struct scm *key, struct scm *x) error (struct scm *key, struct scm *x)
{ {
#if !__MESC_MES__ && !__M2_PLANET__ #if !__MESC_MES__ && !__M2__
struct scm *throw = module_ref (R0, cell_symbol_throw); struct scm *throw = module_ref (R0, cell_symbol_throw);
if (throw != cell_undefined) if (throw != cell_undefined)
return apply (throw, cons (key, cons (x, cell_nil)), R0); return apply (throw, cons (key, cons (x, cell_nil)), R0);

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2022 Gabriel Wicki <gabriel@erlikon.ch> * Copyright © 2022 Gabriel Wicki <gabriel@erlikon.ch>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
@ -31,8 +31,11 @@
int g_dump_filedes; int g_dump_filedes;
#if __M2__
#define M2_CELL_SIZE 12
#else
#define M2_CELL_SIZE 1U #define M2_CELL_SIZE 1U
// CONSTANT M2_CELL_SIZE 12 #endif
char * char *
cell_bytes (struct scm *x) cell_bytes (struct scm *x)
@ -41,16 +44,20 @@ cell_bytes (struct scm *x)
return p + (2 * sizeof (long)); return p + (2 * sizeof (long));
} }
#if __M2__
#define U10 10
#define U100 100
#else
#define U10 10U #define U10 10U
// CONSTANT U10 10
#define U100 100U #define U100 100U
// CONSTANT U100 100 #endif
void void
gc_init () gc_init ()
{ {
#if SYSTEM_LIBC #if SYSTEM_LIBC
ARENA_SIZE = 100000000; /* 2.3GiB */ ARENA_SIZE = 100000000; /* 2.3GiB */
#elif ! __M2_PLANET__ #elif ! __M2__
ARENA_SIZE = 300000; /* 32b: 3MiB, 64b: 6 MiB */ ARENA_SIZE = 300000; /* 32b: 3MiB, 64b: 6 MiB */
#else #else
ARENA_SIZE = 20000000; ARENA_SIZE = 20000000;

View file

@ -34,10 +34,6 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#if SYSTEM_LIBC
#define __raise(x) -1
#endif
struct scm * struct scm *
abort_ () /*:((name . "abort")) */ abort_ () /*:((name . "abort")) */
{ {
@ -377,13 +373,14 @@ waitpid_ (struct scm *pid, struct scm *options)
return cons (make_number (child), make_number (status)); return cons (make_number (child), make_number (status));
} }
#if __x86_64__ #if __M2__
/* Milliseconds for everyone else. */
#define TIME_UNITS_PER_SECOND 1000
#elif __x86_64__
/* Nanoseconds on 64-bit systems with POSIX timers. */ /* Nanoseconds on 64-bit systems with POSIX timers. */
// CONSTANT TIME_UNITS_PER_SECOND 1000000000
#define TIME_UNITS_PER_SECOND 1000000000U #define TIME_UNITS_PER_SECOND 1000000000U
#else #else
/* Milliseconds for everyone else. */ /* Milliseconds for everyone else. */
// CONSTANT TIME_UNITS_PER_SECOND 1000
#define TIME_UNITS_PER_SECOND 1000U #define TIME_UNITS_PER_SECOND 1000U
#endif #endif
@ -408,8 +405,12 @@ gettimeofday_ () /*:((name . "gettimeofday")) */
return cons (make_number (time->tv_sec), make_number (time->tv_usec)); return cons (make_number (time->tv_sec), make_number (time->tv_usec));
} }
#if __M2__
#define UL1000000000 1000000000
#else
#define UL1000000000 1000000000UL #define UL1000000000 1000000000UL
// CONSTANT UL1000000000 1000000000 #endif
long long
seconds_and_nanoseconds_to_long (long s, long ns) seconds_and_nanoseconds_to_long (long s, long ns)
{ {

View file

@ -23,14 +23,10 @@
#include <string.h> #include <string.h>
// char const *MES_VERSION = "0.24.2"; #if __M2__
#if __M2_PLANET__
#define M2_CELL_SIZE 12 #define M2_CELL_SIZE 12
// CONSTANT M2_CELL_SIZE 12
#else #else
#define M2_CELL_SIZE 1 #define M2_CELL_SIZE 1
// CONSTANT M2_CELL_SIZE 12
#endif #endif
struct scm * struct scm *

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -24,8 +24,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if __M2__
#define M2_CELL_SIZE 12
#else
#define M2_CELL_SIZE 1 #define M2_CELL_SIZE 1
// CONSTANT M2_CELL_SIZE 12 #endif
int g_debug; int g_debug;

View file

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -21,12 +21,10 @@
#include "mes/lib.h" #include "mes/lib.h"
#include "mes/mes.h" #include "mes/mes.h"
#if __M2_PLANET__ #if __M2__
#define M2_CELL_SIZE 12 #define M2_CELL_SIZE 12
// CONSTANT M2_CELL_SIZE 12
#else #else
#define M2_CELL_SIZE 1 #define M2_CELL_SIZE 1
// CONSTANT M2_CELL_SIZE 12
#endif #endif
struct scm * struct scm *