mescc: Mes C Library: Split _exit.c, _write.c from mini.c.
* lib/freebsd/x86-mes-gcc/mini.c: Split into... * lib/freebsd/x86-mes-gcc/_exit.c: ...this, and... * lib/freebsd/x86-mes-gcc/_write.c: ...this. * lib/freebsd/x86-mes-mescc/mini.c: Slpit into... * lib/freebsd/x86-mes-mescc/_exit.c: ...this, and... * lib/freebsd/x86-mes-mescc/_write.c: ...this. * lib/gnu/x86-mes-gcc/mini.c: Split into... * lib/gnu/x86-mes-gcc/_exit.c: ...this, and... * lib/gnu/x86-mes-gcc/_write.c: ...this. * lib/linux/arm-mes-gcc/mini.c: Split into... * lib/linux/arm-mes-gcc/_exit.c: ...this, and... * lib/linux/arm-mes-gcc/_write.c: ...this. * lib/linux/arm-mes-mescc/mini.c: Split into... * lib/linux/arm-mes-mescc/_exit.c: ...this, and... * lib/linux/arm-mes-mescc/_write.c: ...this. * build-aux/configure-lib.sh (libc_mini_shared_SOURCES): Replace mini.c with add _exit.c, _write.c. * simple.sh: Update accordingly.
This commit is contained in:
parent
096939b819
commit
905277a73a
|
@ -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
|
||||
"
|
||||
|
|
41
lib/freebsd/x86-mes-gcc/_exit.c
Normal file
41
lib/freebsd/x86-mes-gcc/_exit.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019,2020 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-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);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* 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)
|
29
lib/freebsd/x86-mes-mescc/_exit.c
Normal file
29
lib/freebsd/x86-mes-mescc/_exit.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019,2020 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/>.
|
||||
*/
|
||||
|
||||
void
|
||||
_exit ()
|
||||
{
|
||||
asm ("mov____$i32,%eax SYS_exit");
|
||||
asm ("mov____0x8(%ebp),%ebx !8");
|
||||
asm ("push___%ebx");
|
||||
asm ("push___%ebx");
|
||||
asm ("int____$0x80");
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,20 +18,16 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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");
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -20,4 +20,4 @@
|
|||
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
// your mini mach here
|
||||
// your mach _exit here
|
23
lib/gnu/x86-mes-gcc/_write.c
Normal file
23
lib/gnu/x86-mes-gcc/_write.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019,2020 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-mini.h"
|
||||
|
||||
// your mach _write here
|
58
lib/linux/arm-mes-gcc/_exit.c
Normal file
58
lib/linux/arm-mes-gcc/_exit.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2019,2020 Danny Milosavljevic <dannym@scratchpost.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-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__
|
|
@ -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)
|
28
lib/linux/arm-mes-mescc/_exit.c
Normal file
28
lib/linux/arm-mes-mescc/_exit.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.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/>.
|
||||
*/
|
||||
|
||||
void
|
||||
_exit ()
|
||||
{
|
||||
asm ("SYS_exit mov____$i8,%r7");
|
||||
asm ("!8 ldr____%r0,(%fp,+#$i8)");
|
||||
asm ("swi____$0");
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
|
@ -19,14 +19,6 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
void
|
||||
_exit ()
|
||||
{
|
||||
asm ("SYS_exit mov____$i8,%r7");
|
||||
asm ("!8 ldr____%r0,(%fp,+#$i8)");
|
||||
asm ("swi____$0");
|
||||
}
|
||||
|
||||
void
|
||||
_write ()
|
||||
{
|
39
lib/linux/x86-mes-gcc/_exit.c
Normal file
39
lib/linux/x86-mes-gcc/_exit.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019,2020 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-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
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* 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)
|
27
lib/linux/x86-mes-mescc/_exit.c
Normal file
27
lib/linux/x86-mes-mescc/_exit.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2020 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/>.
|
||||
*/
|
||||
|
||||
void
|
||||
_exit ()
|
||||
{
|
||||
asm ("mov____$i32,%eax SYS_exit");
|
||||
asm ("mov____0x8(%ebp),%ebx !8");
|
||||
asm ("int____$0x80");
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,26 +18,12 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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");
|
||||
}
|
38
lib/linux/x86_64-mes-gcc/_exit.c
Normal file
38
lib/linux/x86_64-mes-gcc/_exit.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 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-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);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* 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)
|
||||
{
|
32
lib/linux/x86_64-mes-mescc/_exit.c
Normal file
32
lib/linux/x86_64-mes-mescc/_exit.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2020 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-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");
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* 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)
|
||||
{
|
|
@ -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\
|
||||
|
|
Loading…
Reference in a new issue