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.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-11-04 10:14:22 +01:00 committed by Janneke Nieuwenhuizen
parent 2a759f904d
commit 4d4e6959e9
7 changed files with 63 additions and 33 deletions

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.
* *
@ -23,6 +23,9 @@
#include <mes/lib-mini.h> #include <mes/lib-mini.h>
#define __FILEDES_MAX 512
extern char *__brk;
char *cast_intp_to_charp (int const *i); char *cast_intp_to_charp (int const *i);
char *cast_long_to_charp (long i); char *cast_long_to_charp (long i);
long cast_charp_to_long (char const *); long cast_charp_to_long (char const *);
@ -34,14 +37,11 @@ void __ungetc_init ();
void __ungetc_clear (int filedes); void __ungetc_clear (int filedes);
void __ungetc_set (int filedes, int c); void __ungetc_set (int filedes, int c);
int __ungetc_p (int filedes); int __ungetc_p (int filedes);
double abtod (char const **p, int base);
long abtol (char const **p, int base); long abtol (char const **p, int base);
char *dtoab (double number, int base, int signed_p);
char *itoa (int number); char *itoa (int number);
char *ltoa (long number); char *ltoa (long number);
char *ltoab (long x, int base); char *ltoab (long x, int base);
char *ntoab (long number, unsigned base, int signed_p); char *ntoab (long number, unsigned base, int signed_p);
char *ultoa (unsigned long number);
char *utoa (unsigned number); char *utoa (unsigned number);
int eputc (int c); int eputc (int c);
int fdgetc (int fd); int fdgetc (int fd);
@ -61,10 +61,12 @@ char *search_path (char const *file_name);
ssize_t _read (int fd, void *buffer, size_t size); ssize_t _read (int fd, void *buffer, size_t size);
void assert_msg (int check, char *msg); void assert_msg (int check, char *msg);
extern char *__brk; long __mesabi_imod (long a, long b);
extern void (*__call_at_exit) (void); long __mesabi_idiv (long a, long b);
void *__memcpy (void *dest, void const *src, size_t n);
#define __FILEDES_MAX 512 void *__memmove (void *dest, void const *src, 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,16 +77,15 @@ void _exit (int code);
long brk (void *addr); long brk (void *addr);
#endif // !SYSTEM_LIBC #endif // !SYSTEM_LIBC
long __mesabi_imod (long a, long b); #if !__M2__
long __mesabi_idiv (long a, long b); extern void (*__call_at_exit) (void);
double abtod (char const **p, int base);
char *dtoab (double number, int base, int signed_p);
char *ultoa (unsigned long number);
unsigned long __mesabi_umod (unsigned long a, unsigned long b); unsigned long __mesabi_umod (unsigned long a, unsigned long b);
unsigned long __mesabi_udiv (unsigned long a, unsigned long b); unsigned long __mesabi_udiv (unsigned long a, unsigned long b);
unsigned long __mesabi_uldiv (unsigned long a, unsigned long b, unsigned long __mesabi_uldiv (unsigned long a, unsigned long b,
unsigned long *remainder); unsigned long *remainder);
#endif
void *__memcpy (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);
int __raise (int signal);
#endif //__MES_LIB_H #endif //__MES_LIB_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 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -65,30 +65,33 @@ int ferror (FILE * stream);
int fflush (FILE * stream); int fflush (FILE * stream);
int fgetc (FILE * stream); int fgetc (FILE * stream);
char *fgets (char *s, int size, FILE * stream); char *fgets (char *s, int size, FILE * stream);
int fprintf (FILE * stream, char const *format, ...);
int fpurge (FILE * stream); int fpurge (FILE * stream);
int fputc (int c, FILE * stream); int fputc (int c, FILE * stream);
int fputs (char const *s, FILE * stream); int fputs (char const *s, FILE * stream);
int fscanf (FILE * stream, char const *template, ...);
int fseek (FILE * stream, long offset, int whence); int fseek (FILE * stream, long offset, int whence);
int getc (FILE * stream); int getc (FILE * stream);
int getchar (void); int getchar (void);
char *getlogin (void); char *getlogin (void);
int printf (char const *format, ...);
int putc (int c, FILE * stream); int putc (int c, FILE * stream);
int putchar (int c); int putchar (int c);
int puts (char const *s); int puts (char const *s);
int remove (char const *file_name); int remove (char const *file_name);
int setvbuf (FILE * stream, char *buf, int mode, size_t size); int setvbuf (FILE * stream, char *buf, int mode, size_t size);
int snprintf (char *str, size_t size, char const *format, ...);
int sprintf (char *str, char const *format, ...);
int sscanf (char const *str, char const *format, ...);
int ungetc (int c, FILE * stream); int ungetc (int c, FILE * stream);
long ftell (FILE * stream); long ftell (FILE * stream);
size_t fread (void *ptr, size_t size, size_t count, FILE * stream); size_t fread (void *ptr, size_t size, size_t count, FILE * stream);
size_t freadahead (FILE * fp); size_t freadahead (FILE * fp);
size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream); size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream);
#if !__M2__
int fprintf (FILE * stream, char const *format, ...);
int fscanf (FILE * stream, char const *template, ...);
int printf (char const *format, ...);
int snprintf (char *str, size_t size, char const *format, ...);
int sprintf (char *str, char const *format, ...);
int sscanf (char const *str, char const *format, ...);
#endif // !__M2__
#endif // ! SYSTEM_LIBC #endif // ! SYSTEM_LIBC
#endif // __MES_STDIO_H #endif // __MES_STDIO_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 © 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.
* *
@ -66,15 +66,23 @@ typedef unsigned gid_t;
#ifndef __MES_INO_T #ifndef __MES_INO_T
#define __MES_INO_T #define __MES_INO_T
#undef ino_t #undef ino_t
#if __M2__
typedef unsigned ino_t;
#else
typedef unsigned long ino_t; typedef unsigned long ino_t;
#endif #endif
#endif
#if __SIZEOF_LONG_LONG__ == 8 #if __SIZEOF_LONG_LONG__ == 8
#ifndef __MES_INO64_T #ifndef __MES_INO64_T
#define __MES_INO64_T #define __MES_INO64_T
#undef ino64_t #undef ino64_t
#if __M2__
typedef unsigned ino64_t;
#else
typedef unsigned long long ino64_t; typedef unsigned long long ino64_t;
#endif #endif
#endif
#endif // __SIZEOF_LONG_LONG__ == 8 #endif // __SIZEOF_LONG_LONG__ == 8
#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined) #if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined)
@ -83,8 +91,12 @@ typedef unsigned long long ino64_t;
#undef intptr_t #undef intptr_t
typedef long intptr_t; typedef long intptr_t;
#undef uintptr_t #undef uintptr_t
#if __M2__
typedef unsigned uintptr_t;
#else
typedef unsigned long uintptr_t; typedef unsigned long uintptr_t;
#endif #endif
#endif
#ifndef __MES_OFF_T #ifndef __MES_OFF_T
#define __MES_OFF_T #define __MES_OFF_T
@ -96,8 +108,12 @@ typedef long off_t;
#ifndef __MES_OFF64_T #ifndef __MES_OFF64_T
#define __MES_OFF64_T #define __MES_OFF64_T
#undef off64_t #undef off64_t
#if __M2__
typedef unsigned off64_t;
#else
typedef unsigned long long off64_t; typedef unsigned long long off64_t;
#endif #endif
#endif
#endif // __SIZEOF_LONG_LONG__ == 8 #endif // __SIZEOF_LONG_LONG__ == 8
#ifndef __MES_PID_T #ifndef __MES_PID_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,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 Danny Milosavljevic <dannym@scratchpost.org> * Copyright © 2021 Danny Milosavljevic <dannym@scratchpost.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
@ -31,9 +31,11 @@ malloc (size_t size)
{ {
if (!__brk) if (!__brk)
__brk = cast_long_to_charp (brk (0)); __brk = cast_long_to_charp (brk (0));
#if !__M2__
/* align what we give back. */ /* align what we give back. */
__brk = (char*) (((uintptr_t) __brk __brk = (char*) (((uintptr_t) __brk
+ sizeof (max_align_t) - 1) & -sizeof (max_align_t)); + sizeof (max_align_t) - 1) & -sizeof (max_align_t));
#endif
if (brk (__brk + size) == -1) if (brk (__brk + size) == -1)
return 0; return 0;
char *p = __brk; char *p = __brk;

View File

@ -27,7 +27,9 @@ ssize_t
read (int filedes, void *buffer, size_t size) read (int filedes, void *buffer, size_t size)
{ {
long long_filedes = filedes; long long_filedes = filedes;
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, (long) buffer, (long) size); long long_buffer = cast_voidp_to_long (buffer);
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, long_buffer, size);
#if !__M2__
if (__mes_debug () > 4) if (__mes_debug () > 4)
{ {
if (bytes == 1) if (bytes == 1)
@ -48,5 +50,6 @@ read (int filedes, void *buffer, size_t size)
eputs ("\n"); eputs ("\n");
} }
} }
#endif
return bytes; return bytes;
} }

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 © 2016,2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -20,12 +20,16 @@
#include <mes/lib.h> #include <mes/lib.h>
#if !__M2__
void (*__call_at_exit) (void); void (*__call_at_exit) (void);
#endif
void void
exit (int code) exit (int code)
{ {
#if !__M2__
if (__call_at_exit) if (__call_at_exit)
(*__call_at_exit) (); (*__call_at_exit) ();
#endif
_exit (code); _exit (code);
} }

View File

@ -24,28 +24,29 @@ mes_cpu=${mes_cpu:-x86}
stage0_cpu=${stage0_cpu:-x86} stage0_cpu=${stage0_cpu:-x86}
M2-Planet \ M2-Planet \
--bootstrap-mode \
--debug \ --debug \
--architecture ${stage0_cpu} \ --architecture ${stage0_cpu} \
-f include/m2/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 include/mes/lib-mini.h \
-f lib/linux/${mes_cpu}-mes-m2/_write.c \ -f lib/linux/${mes_cpu}-mes-m2/_write.c \
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \ -f lib/linux/${mes_cpu}-mes-m2/_exit.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/m2/cast.c \ -f lib/m2/cast.c \
-f include/mes/lib.h \
-f lib/string/strlen.c \ -f lib/string/strlen.c \
-f lib/mes/write.c \ -f lib/mes/write.c \
-f lib/mes/eputs.c \ -f lib/mes/eputs.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/m2/open.c \
-f lib/m2/mes_open.c \ -f include/sys/types.h \
-f include/stdio.h \
-f scaffold/read.c \ -f scaffold/read.c \
-o scaffold/read.M1 -o scaffold/read.M1