2018-08-19 10:17:57 +01:00
|
|
|
/* -*-comment-start: "//";comment-end:""-*-
|
|
|
|
* GNU Mes --- Maxwell Equations of Software
|
2022-05-03 11:44:00 +01:00
|
|
|
* Copyright © 2016,2017,2018,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2018-08-19 10:17:57 +01:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2019-05-07 23:25:41 +01:00
|
|
|
#ifndef __MES_LIB_MINI_H
|
|
|
|
#define __MES_LIB_MINI_H
|
2018-08-19 10:17:57 +01:00
|
|
|
|
2019-06-08 14:36:22 +01:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <mes/config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STDIN
|
|
|
|
#define STDIN 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STDOUT
|
|
|
|
#define STDOUT 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STDERR
|
|
|
|
#define STDERR 2
|
|
|
|
#endif
|
|
|
|
|
2022-05-07 09:50:06 +01:00
|
|
|
/* M2-Planet does not support pointer arithmetic. Explicitly compensate
|
|
|
|
for that by multiplying with M2_PTR_SIZE when using (char)
|
|
|
|
pointers. */
|
|
|
|
#if __M2__
|
DRAFT x86_64: build: Cater for M2-Planet.
XXX scaffold tests run,
* MES_DEBUG=3 bin/mes-m2 segfaults in gc_init.
* kaem.run: Define __<cpu>__.
* kaem.x86_64,
lib/linux/x86_64-mes-m2/_exit.c,
lib/linux/x86_64-mes-m2/_write.c,
lib/linux/x86_64-mes-m2/crt1.M1,
lib/linux/x86_64-mes-m2/crt1.c,
lib/linux/x86_64-mes-m2/syscall.c,
lib/m2/x86_64/ELF-x86_64.hex2,
lib/m2/x86_64/x86_64_defs.M1: New files.
* build-aux/build.sh.in: Also allow kaem build for X86_64.
* include/mes/lib-mini.h[__M2__ && __x86_64__](M2_PTR_SIZE): Define as
8.
* include/mes/mes.h[__M2__ && __x86_64__](M2_CELL_SIZE): Define as 24.
* lib/x86_64-mes/x86_64.M1 (add____$i8,%rbp, mov____%rdi,%rbp): New
defines.
2022-05-07 07:08:28 +01:00
|
|
|
#if __x86_64__
|
|
|
|
#define M2_PTR_SIZE 8
|
|
|
|
#else
|
2022-05-07 09:50:06 +01:00
|
|
|
#define M2_PTR_SIZE 4
|
DRAFT x86_64: build: Cater for M2-Planet.
XXX scaffold tests run,
* MES_DEBUG=3 bin/mes-m2 segfaults in gc_init.
* kaem.run: Define __<cpu>__.
* kaem.x86_64,
lib/linux/x86_64-mes-m2/_exit.c,
lib/linux/x86_64-mes-m2/_write.c,
lib/linux/x86_64-mes-m2/crt1.M1,
lib/linux/x86_64-mes-m2/crt1.c,
lib/linux/x86_64-mes-m2/syscall.c,
lib/m2/x86_64/ELF-x86_64.hex2,
lib/m2/x86_64/x86_64_defs.M1: New files.
* build-aux/build.sh.in: Also allow kaem build for X86_64.
* include/mes/lib-mini.h[__M2__ && __x86_64__](M2_PTR_SIZE): Define as
8.
* include/mes/mes.h[__M2__ && __x86_64__](M2_CELL_SIZE): Define as 24.
* lib/x86_64-mes/x86_64.M1 (add____$i8,%rbp, mov____%rdi,%rbp): New
defines.
2022-05-07 07:08:28 +01:00
|
|
|
#endif
|
2022-05-07 09:50:06 +01:00
|
|
|
#else
|
|
|
|
#define M2_PTR_SIZE 1
|
|
|
|
#endif
|
|
|
|
|
2020-10-06 09:33:55 +01:00
|
|
|
extern char **environ;
|
|
|
|
extern int __stdin;
|
|
|
|
extern int __stdout;
|
|
|
|
extern int __stderr;
|
2019-06-08 14:36:22 +01:00
|
|
|
|
|
|
|
int eputs (char const *s);
|
|
|
|
int puts (char const *s);
|
|
|
|
int oputs (char const *s);
|
|
|
|
|
|
|
|
#if SYSTEM_LIBC
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#else //!SYSTEM_LIBC
|
2018-11-14 12:07:59 +00:00
|
|
|
|
2018-08-19 10:17:57 +01:00
|
|
|
#ifndef _SIZE_T
|
|
|
|
#define _SIZE_T
|
|
|
|
#ifndef __SIZE_T
|
|
|
|
#define __SIZE_T
|
|
|
|
#ifndef __MES_SIZE_T
|
|
|
|
#define __MES_SIZE_T
|
|
|
|
#undef size_t
|
2022-05-03 11:44:00 +01:00
|
|
|
#if __M2__
|
|
|
|
typedef unsigned size_t;
|
|
|
|
#else
|
2018-08-19 10:17:57 +01:00
|
|
|
typedef unsigned long size_t;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
2022-05-03 11:44:00 +01:00
|
|
|
#endif
|
2018-08-19 10:17:57 +01:00
|
|
|
|
|
|
|
#ifndef _SSIZE_T
|
|
|
|
#define _SSIZE_T
|
|
|
|
#ifndef __SSIZE_T
|
|
|
|
#define __SSIZE_T
|
|
|
|
#ifndef __MES_SSIZE_T
|
|
|
|
#define __MES_SSIZE_T
|
|
|
|
#undef ssize_t
|
2018-11-14 12:07:59 +00:00
|
|
|
#if __i386__
|
|
|
|
typedef int ssize_t;
|
|
|
|
#else
|
2018-08-19 10:17:57 +01:00
|
|
|
typedef long ssize_t;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
2018-11-14 12:07:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __MES_ERRNO_T
|
|
|
|
#define __MES_ERRNO_T 1
|
|
|
|
typedef int error_t;
|
2020-10-06 09:33:55 +01:00
|
|
|
extern int errno;
|
2018-11-14 12:07:59 +00:00
|
|
|
#endif // !__MES_ERRNO_T
|
|
|
|
|
2019-05-18 12:27:42 +01:00
|
|
|
size_t strlen (char const *s);
|
2019-05-07 23:25:41 +01:00
|
|
|
ssize_t _write ();
|
2018-11-14 12:07:59 +00:00
|
|
|
ssize_t write (int filedes, void const *buffer, size_t size);
|
2019-05-29 15:15:12 +01:00
|
|
|
#endif // !SYSTEM_LIBC
|
2018-11-14 12:07:59 +00:00
|
|
|
|
2019-05-07 23:25:41 +01:00
|
|
|
#endif //__MES_LIB_MINI_H
|