diff --git a/build-aux/configure-lib.sh b/build-aux/configure-lib.sh index 36597246..d7c1601d 100644 --- a/build-aux/configure-lib.sh +++ b/build-aux/configure-lib.sh @@ -37,8 +37,9 @@ lib/mes/oputs.c if test $mes_libc = mes; then libc_mini_shared_SOURCES="$libc_mini_shared_SOURCES lib/mes/globals.c -lib/$mes_kernel/$mes_cpu-mes-$compiler/mini.c lib/stdlib/exit.c +lib/$mes_kernel/$mes_cpu-mes-$compiler/_exit.c +lib/$mes_kernel/$mes_cpu-mes-$compiler/_write.c lib/stdlib/puts.c lib/string/strlen.c " diff --git a/lib/freebsd/x86-mes-gcc/_exit.c b/lib/freebsd/x86-mes-gcc/_exit.c new file mode 100644 index 00000000..ac321a61 --- /dev/null +++ b/lib/freebsd/x86-mes-gcc/_exit.c @@ -0,0 +1,41 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * + * 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 . + */ + +#include "mes/lib-mini.h" + +#define SYS_exit "0x01" + +// *INDENT-OFF* +void +_exit (int code) +{ + asm ( + "mov $"SYS_exit",%%eax\n\t" + "mov %0,%%ebx\n\t" + "push %%ebx\n\t" + "push %%ebx\n\t" + "int $0x80\n\t" + : // no outputs "=" (r) + : "rm" (code) + : "eax", "ebx" + ); + // not reached + _exit (0); +} diff --git a/lib/linux/x86-mes-gcc/mini.c b/lib/freebsd/x86-mes-gcc/_write.c similarity index 78% rename from lib/linux/x86-mes-gcc/mini.c rename to lib/freebsd/x86-mes-gcc/_write.c index dac77fda..54cfaf80 100644 --- a/lib/linux/x86-mes-gcc/mini.c +++ b/lib/freebsd/x86-mes-gcc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -21,33 +21,21 @@ #include "mes/lib-mini.h" #define SYS_exit "0x01" -#define SYS_write "0x04" // *INDENT-OFF* -void -_exit (int code) -{ - asm ( - "mov $"SYS_exit",%%eax\n\t" - "mov %0,%%ebx\n\t" - "int $0x80\n\t" - : // no outputs "=" (r) - : "rm" (code) - : "eax", "ebx" - ); - // not reached - _exit (0); -} - ssize_t _write (int filedes, void const *buffer, size_t size) { long r; asm ( "mov $"SYS_write",%%eax\n\t" - "mov %1,%%ebx\n\t" - "mov %2,%%ecx\n\t" "mov %3,%%edx\n\t" + "push %%edx\n\t" + "mov %2,%%ecx\n\t" + "push %%ecx\n\t" + "mov %1,%%ebx\n\t" + "push %%ebx\n\t" + "push %%ebx\n\t" "int $0x80\n\t" "mov %%eax,%0\n\t" : "=r" (r) diff --git a/lib/freebsd/x86-mes-mescc/_exit.c b/lib/freebsd/x86-mes-mescc/_exit.c new file mode 100644 index 00000000..06c858a8 --- /dev/null +++ b/lib/freebsd/x86-mes-mescc/_exit.c @@ -0,0 +1,29 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * + * 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 . + */ + +void +_exit () +{ + asm ("mov____$i32,%eax SYS_exit"); + asm ("mov____0x8(%ebp),%ebx !8"); + asm ("push___%ebx"); + asm ("push___%ebx"); + asm ("int____$0x80"); +} diff --git a/lib/linux/x86-mes-mescc/mini.c b/lib/freebsd/x86-mes-mescc/_write.c similarity index 83% rename from lib/linux/x86-mes-mescc/mini.c rename to lib/freebsd/x86-mes-mescc/_write.c index 79a6867a..9a4544cc 100644 --- a/lib/linux/x86-mes-mescc/mini.c +++ b/lib/freebsd/x86-mes-mescc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -18,20 +18,16 @@ * along with GNU Mes. If not, see . */ -void -_exit () -{ - asm ("mov____$i32,%eax SYS_exit"); - asm ("mov____0x8(%ebp),%ebx !8"); - asm ("int____$0x80"); -} - void _write () { asm ("mov____$i32,%eax SYS_write"); - asm ("mov____0x8(%ebp),%ebx !8"); - asm ("mov____0x8(%ebp),%ecx !12"); asm ("mov____0x8(%ebp),%edx !16"); + asm ("push___%edx"); + asm ("mov____0x8(%ebp),%ecx !12"); + asm ("push___%ecx"); + asm ("mov____0x8(%ebp),%ebx !8"); + asm ("push___%ebx"); + asm ("push___%ebx"); asm ("int____$0x80"); } diff --git a/lib/gnu/x86-mes-gcc/mini.c b/lib/gnu/x86-mes-gcc/_exit.c similarity index 89% rename from lib/gnu/x86-mes-gcc/mini.c rename to lib/gnu/x86-mes-gcc/_exit.c index a0c42d88..805bdc43 100644 --- a/lib/gnu/x86-mes-gcc/mini.c +++ b/lib/gnu/x86-mes-gcc/_exit.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,4 +20,4 @@ #include "mes/lib-mini.h" -// your mini mach here +// your mach _exit here diff --git a/lib/gnu/x86-mes-gcc/_write.c b/lib/gnu/x86-mes-gcc/_write.c new file mode 100644 index 00000000..28ca6033 --- /dev/null +++ b/lib/gnu/x86-mes-gcc/_write.c @@ -0,0 +1,23 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen + * + * 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 . + */ + +#include "mes/lib-mini.h" + +// your mach _write here diff --git a/lib/linux/arm-mes-gcc/_exit.c b/lib/linux/arm-mes-gcc/_exit.c new file mode 100644 index 00000000..51491710 --- /dev/null +++ b/lib/linux/arm-mes-gcc/_exit.c @@ -0,0 +1,58 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2019,2020 Danny Milosavljevic + * + * 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 . + */ + +#include "mes/lib-mini.h" + +#define SYS_exit "0x01" + +// *INDENT-OFF* +#if !__TINYC__ +void +_exit (int code) +{ + asm ( + "mov r7, $"SYS_exit"\n\t" + "mov r0, %0\n\t" + "swi $0\n\t" + : // no outputs "=" (r) + : "r" (code) + : "r0", "r7" + ); + // not reached + _exit (0); +} +#else //__TINYC__ +__asm__ (".global _exit\n"); +__asm__ ("_exit:\n"); +__asm__ (".int 0xe92d4880\n"); //push {r7, fp, lr} +__asm__ (".int 0xe28db008\n"); //add fp, sp, #8 +__asm__ (".int 0xe24dd00c\n"); //sub sp, sp, #12 +__asm__ (".int 0xe50b0010\n"); //str r0, [fp, #-16] +__asm__ (".int 0xe51b3010\n"); //ldr r3, [fp, #-16] +__asm__ (".int 0xe3a07001\n"); //mov r7, #1 +__asm__ (".int 0xe1a00003\n"); //mov r0, r3 +__asm__ (".int 0xef000000\n"); //svc 0x00000000 +__asm__ (".int 0xe3a00000\n"); //mov r0, #0 +__asm__ (".int 0xebfffffe\n"); //bl 0 <_exit> +__asm__ (".int 0xe320f000\n"); //nop {0} +__asm__ (".int 0xe24bd008\n"); //sub sp, fp, #8 +__asm__ (".int 0xe8bd8880\n"); //pop {r7, fp, pc} +#endif //__TINYC__ diff --git a/lib/linux/arm-mes-gcc/mini.c b/lib/linux/arm-mes-gcc/_write.c similarity index 72% rename from lib/linux/arm-mes-gcc/mini.c rename to lib/linux/arm-mes-gcc/_write.c index 67aa2b61..fec381fd 100644 --- a/lib/linux/arm-mes-gcc/mini.c +++ b/lib/linux/arm-mes-gcc/_write.c @@ -21,43 +21,9 @@ #include "mes/lib-mini.h" -#define SYS_exit "0x01" #define SYS_write "0x04" -#if !__TINYC__ // *INDENT-OFF* -void -_exit (int code) -{ - asm ( - "mov r7, $"SYS_exit"\n\t" - "mov r0, %0\n\t" - "swi $0\n\t" - : // no outputs "=" (r) - : "r" (code) - : "r0", "r7" - ); - // not reached - _exit (0); -} -#else //__TINYC__ -__asm__ (".global _exit\n"); -__asm__ ("_exit:\n"); -__asm__ (".int 0xe92d4880\n"); //push {r7, fp, lr} -__asm__ (".int 0xe28db008\n"); //add fp, sp, #8 -__asm__ (".int 0xe24dd00c\n"); //sub sp, sp, #12 -__asm__ (".int 0xe50b0010\n"); //str r0, [fp, #-16] -__asm__ (".int 0xe51b3010\n"); //ldr r3, [fp, #-16] -__asm__ (".int 0xe3a07001\n"); //mov r7, #1 -__asm__ (".int 0xe1a00003\n"); //mov r0, r3 -__asm__ (".int 0xef000000\n"); //svc 0x00000000 -__asm__ (".int 0xe3a00000\n"); //mov r0, #0 -__asm__ (".int 0xebfffffe\n"); //bl 0 <_exit> -__asm__ (".int 0xe320f000\n"); //nop {0} -__asm__ (".int 0xe24bd008\n"); //sub sp, fp, #8 -__asm__ (".int 0xe8bd8880\n"); //pop {r7, fp, pc} -#endif //__TINYC__ - #if !__TINYC__ ssize_t _write (int filedes, void const *buffer, size_t size) diff --git a/lib/linux/arm-mes-mescc/_exit.c b/lib/linux/arm-mes-mescc/_exit.c new file mode 100644 index 00000000..64d38d8c --- /dev/null +++ b/lib/linux/arm-mes-mescc/_exit.c @@ -0,0 +1,28 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2020 Danny Milosavljevic + * + * 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 . + */ + +void +_exit () +{ + asm ("SYS_exit mov____$i8,%r7"); + asm ("!8 ldr____%r0,(%fp,+#$i8)"); + asm ("swi____$0"); +} diff --git a/lib/linux/arm-mes-mescc/mini.c b/lib/linux/arm-mes-mescc/_write.c similarity index 84% rename from lib/linux/arm-mes-mescc/mini.c rename to lib/linux/arm-mes-mescc/_write.c index 6ea2d5a3..18b1c61a 100644 --- a/lib/linux/arm-mes-mescc/mini.c +++ b/lib/linux/arm-mes-mescc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2020 Jan (janneke) Nieuwenhuizen * Copyright © 2020 Danny Milosavljevic * * This file is part of GNU Mes. @@ -19,14 +19,6 @@ * along with GNU Mes. If not, see . */ -void -_exit () -{ - asm ("SYS_exit mov____$i8,%r7"); - asm ("!8 ldr____%r0,(%fp,+#$i8)"); - asm ("swi____$0"); -} - void _write () { diff --git a/lib/linux/x86-mes-gcc/_exit.c b/lib/linux/x86-mes-gcc/_exit.c new file mode 100644 index 00000000..e239130b --- /dev/null +++ b/lib/linux/x86-mes-gcc/_exit.c @@ -0,0 +1,39 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * + * 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 . + */ + +#include "mes/lib-mini.h" + +#define SYS_exit "0x01" + +// *INDENT-OFF* +void +_exit (int code) +{ + asm ( + "mov $"SYS_exit",%%eax\n\t" + "mov %0,%%ebx\n\t" + "int $0x80\n\t" + : // no outputs "=" (r) + : "rm" (code) + : "eax", "ebx" + ); + // not reached + // _exit (0); // tcc has a problem with this +} diff --git a/lib/freebsd/x86-mes-gcc/mini.c b/lib/linux/x86-mes-gcc/_write.c similarity index 71% rename from lib/freebsd/x86-mes-gcc/mini.c rename to lib/linux/x86-mes-gcc/_write.c index 7978ee25..b3ec74f9 100644 --- a/lib/freebsd/x86-mes-gcc/mini.c +++ b/lib/linux/x86-mes-gcc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,40 +20,18 @@ #include "mes/lib-mini.h" -#define SYS_exit "0x01" #define SYS_write "0x04" // *INDENT-OFF* -void -_exit (int code) -{ - asm ( - "mov $"SYS_exit",%%eax\n\t" - "mov %0,%%ebx\n\t" - "push %%ebx\n\t" - "push %%ebx\n\t" - "int $0x80\n\t" - : // no outputs "=" (r) - : "rm" (code) - : "eax", "ebx" - ); - // not reached - _exit (0); -} - ssize_t _write (int filedes, void const *buffer, size_t size) { long r; asm ( "mov $"SYS_write",%%eax\n\t" - "mov %3,%%edx\n\t" - "push %%edx\n\t" - "mov %2,%%ecx\n\t" - "push %%ecx\n\t" "mov %1,%%ebx\n\t" - "push %%ebx\n\t" - "push %%ebx\n\t" + "mov %2,%%ecx\n\t" + "mov %3,%%edx\n\t" "int $0x80\n\t" "mov %%eax,%0\n\t" : "=r" (r) diff --git a/lib/linux/x86-mes-mescc/_exit.c b/lib/linux/x86-mes-mescc/_exit.c new file mode 100644 index 00000000..4c279d83 --- /dev/null +++ b/lib/linux/x86-mes-mescc/_exit.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2020 Jan (janneke) Nieuwenhuizen + * + * 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 . + */ + +void +_exit () +{ + asm ("mov____$i32,%eax SYS_exit"); + asm ("mov____0x8(%ebp),%ebx !8"); + asm ("int____$0x80"); +} diff --git a/lib/freebsd/x86-mes-mescc/mini.c b/lib/linux/x86-mes-mescc/_write.c similarity index 75% rename from lib/freebsd/x86-mes-mescc/mini.c rename to lib/linux/x86-mes-mescc/_write.c index 7756a7ae..0401dfa8 100644 --- a/lib/freebsd/x86-mes-mescc/mini.c +++ b/lib/linux/x86-mes-mescc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -18,26 +18,12 @@ * along with GNU Mes. If not, see . */ -void -_exit () -{ - asm ("mov____$i32,%eax SYS_exit"); - asm ("mov____0x8(%ebp),%ebx !8"); - asm ("push___%ebx"); - asm ("push___%ebx"); - asm ("int____$0x80"); -} - void _write () { asm ("mov____$i32,%eax SYS_write"); - asm ("mov____0x8(%ebp),%edx !16"); - asm ("push___%edx"); - asm ("mov____0x8(%ebp),%ecx !12"); - asm ("push___%ecx"); asm ("mov____0x8(%ebp),%ebx !8"); - asm ("push___%ebx"); - asm ("push___%ebx"); + asm ("mov____0x8(%ebp),%ecx !12"); + asm ("mov____0x8(%ebp),%edx !16"); asm ("int____$0x80"); } diff --git a/lib/linux/x86_64-mes-gcc/_exit.c b/lib/linux/x86_64-mes-gcc/_exit.c new file mode 100644 index 00000000..917bf80d --- /dev/null +++ b/lib/linux/x86_64-mes-gcc/_exit.c @@ -0,0 +1,38 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen + * + * 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 . + */ + +#include "mes/lib-mini.h" + +#define SYS_exit "0x3c" + +// *INDENT-OFF* +void +_exit (int code) +{ + asm ( + "mov $"SYS_exit",%%rax\n\t" + "mov %0,%%rdi\n\t" + "syscall \n\t" + : // no outputs "=" (r) + : "rm" (code) + ); + // not reached + _exit (0); +} diff --git a/lib/linux/x86_64-mes-gcc/mini.c b/lib/linux/x86_64-mes-gcc/_write.c similarity index 79% rename from lib/linux/x86_64-mes-gcc/mini.c rename to lib/linux/x86_64-mes-gcc/_write.c index 8381ebc0..f206c888 100644 --- a/lib/linux/x86_64-mes-gcc/mini.c +++ b/lib/linux/x86_64-mes-gcc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,24 +20,9 @@ #include "mes/lib-mini.h" -#define SYS_exit "0x3c" #define SYS_write "0x01" // *INDENT-OFF* -void -_exit (int code) -{ - asm ( - "mov $"SYS_exit",%%rax\n\t" - "mov %0,%%rdi\n\t" - "syscall \n\t" - : // no outputs "=" (r) - : "rm" (code) - ); - // not reached - _exit (0); -} - ssize_t _write (int filedes, void const *buffer, size_t size) { diff --git a/lib/linux/x86_64-mes-mescc/_exit.c b/lib/linux/x86_64-mes-mescc/_exit.c new file mode 100644 index 00000000..8e6a3df0 --- /dev/null +++ b/lib/linux/x86_64-mes-mescc/_exit.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2020 Jan (janneke) Nieuwenhuizen + * + * 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 . + */ + +#include "mes/lib-mini.h" + +void +_exit (int status) +{ +#if 1 // !MES_CCAMD64 + asm ("mov____0x8(%rbp),%rdi !0x10"); +#endif + + asm ("mov____$i32,%rax SYS_exit"); + asm ("syscall"); +} diff --git a/lib/linux/x86_64-mes-mescc/mini.c b/lib/linux/x86_64-mes-mescc/_write.c similarity index 81% rename from lib/linux/x86_64-mes-mescc/mini.c rename to lib/linux/x86_64-mes-mescc/_write.c index e68c5a3a..112bf94f 100644 --- a/lib/linux/x86_64-mes-mescc/mini.c +++ b/lib/linux/x86_64-mes-mescc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,17 +20,6 @@ #include "mes/lib-mini.h" -void -_exit (int status) -{ -#if 1 // !MES_CCAMD64 - asm ("mov____0x8(%rbp),%rdi !0x10"); -#endif - - asm ("mov____$i32,%rax SYS_exit"); - asm ("syscall"); -} - void _write (int filedes, void const *buffer, size_t size) { diff --git a/simple.sh b/simple.sh index b54398a5..4f3f8db1 100755 --- a/simple.sh +++ b/simple.sh @@ -91,7 +91,8 @@ MES_DEBUG=2 MES=out-system-libc/mes sh -x scripts/mescc -m $mes_bits -nostdlib\ \ lib/mes/eputs.c\ \ - lib/linux/$mes_cpu-mes-mescc/mini.c\ + lib/linux/$mes_cpu-mes-mescc/_exit.c\ + lib/linux/$mes_cpu-mes-mescc/_write.c\ \ lib/mes/write.c\ lib/string/strlen.c\ @@ -142,7 +143,8 @@ $CC -g -D HAVE_CONFIG_H=1 -I include -I include/$mes_kernel/$mes_cpu\ lib/string/strlen.c\ lib/stdlib/puts.c\ lib/stdlib/exit.c\ - lib/$mes_kernel/$mes_cpu-mes-$compiler/mini.c\ + lib/$mes_kernel/$mes_cpu-mes-$compiler/_exit.c\ + lib/$mes_kernel/$mes_cpu-mes-$compiler/_write.c\ \ lib/mes/div.c\ lib/mes/itoa.c\ @@ -252,7 +254,8 @@ MES_DEBUG=2 MES=out-mes/mes sh -x scripts/mescc -m $mes_bits -nostdlib\ \ lib/mes/eputs.c\ \ - lib/linux/$mes_cpu-mes-mescc/mini.c\ + lib/linux/$mes_cpu-mes-mescc/_exit.c\ + lib/linux/$mes_cpu-mes-mescc/_write.c\ \ lib/mes/write.c\ lib/string/strlen.c\