mescc: Mes C Library: Initialize streams in crt1.
* lib/linux/x86-mes-gcc/crt1.c: Initialize streams. * lib/linux/x86-mes/crt1.c: Likewise. * lib/linux/x86_64-mes-gcc/crt1.c: Likewise. * lib/linux/x86_64-mes/crt1.c: Likewise. * src/mes.c (main): Remove initialization of streams.
This commit is contained in:
parent
3480813038
commit
5232cfe669
|
@ -21,11 +21,6 @@
|
||||||
#ifndef __MES_LIBMES_MINI_H
|
#ifndef __MES_LIBMES_MINI_H
|
||||||
#define __MES_LIBMES_MINI_H
|
#define __MES_LIBMES_MINI_H
|
||||||
|
|
||||||
char **environ;
|
|
||||||
int g_stdin;
|
|
||||||
int g_stdout;
|
|
||||||
int g_stderr;
|
|
||||||
|
|
||||||
#if !WITH_GLIBC
|
#if !WITH_GLIBC
|
||||||
|
|
||||||
#ifndef _SIZE_T
|
#ifndef _SIZE_T
|
||||||
|
@ -64,18 +59,25 @@ int errno;
|
||||||
|
|
||||||
#endif //!WITH_LIBC
|
#endif //!WITH_LIBC
|
||||||
|
|
||||||
|
// CONSTANT STDIN 0
|
||||||
#ifndef STDIN
|
#ifndef STDIN
|
||||||
#define STDIN 0
|
#define STDIN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// CONSTANT STDOUT 1
|
||||||
#ifndef STDOUT
|
#ifndef STDOUT
|
||||||
#define STDOUT 1
|
#define STDOUT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// CONSTANT STDERR 2
|
||||||
#ifndef STDERR
|
#ifndef STDERR
|
||||||
#define STDERR 2
|
#define STDERR 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char **environ;
|
||||||
|
int g_stdin;
|
||||||
|
int g_stdout;
|
||||||
|
int g_stderr;
|
||||||
|
|
||||||
int eputs (char const* s);
|
int eputs (char const* s);
|
||||||
int puts (char const* s);
|
int puts (char const* s);
|
||||||
|
|
|
@ -40,8 +40,6 @@
|
||||||
#error both __GNU__ and _linux__ are undefined, choose one
|
#error both __GNU__ and _linux__ are undefined, choose one
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int g_stdin = 0;
|
|
||||||
|
|
||||||
void _env ();
|
void _env ();
|
||||||
|
|
||||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
// instead of calling main, it seems to call either _main or ___main,
|
// instead of calling main, it seems to call either _main or ___main,
|
||||||
// let's try _main first
|
// let's try _main first
|
||||||
|
|
||||||
char **environ = 0;
|
#include <libmes-mini.h>
|
||||||
int _main (int argc, char *argv[]);
|
int _main (int argc, char *argv[]);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -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,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,12 +18,32 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char **environ = 0;
|
#include <libmes-mini.h>
|
||||||
//int main (int argc, char *argv[], char *envp[]);
|
//int main (int argc, char *argv[], char *envp[]);
|
||||||
|
|
||||||
void
|
void
|
||||||
_start ()
|
_start ()
|
||||||
{
|
{
|
||||||
|
asm (
|
||||||
|
"mov $0,%%eax\n\t"
|
||||||
|
"mov %%eax,%0\n"
|
||||||
|
: "=r" (g_stdin)
|
||||||
|
: //no inputs ""
|
||||||
|
);
|
||||||
|
|
||||||
|
asm (
|
||||||
|
"mov $1,%%eax\n\t"
|
||||||
|
"mov %%eax,%0\n"
|
||||||
|
: "=r" (g_stdout)
|
||||||
|
: //no inputs ""
|
||||||
|
);
|
||||||
|
|
||||||
|
asm (
|
||||||
|
"mov $2,%%eax\n\t"
|
||||||
|
"mov %%eax,%0\n"
|
||||||
|
: "=r" (g_stderr)
|
||||||
|
: //no inputs ""
|
||||||
|
);
|
||||||
asm (
|
asm (
|
||||||
"mov %%ebp,%%eax\n\t"
|
"mov %%ebp,%%eax\n\t"
|
||||||
"add $4,%%eax\n\t"
|
"add $4,%%eax\n\t"
|
||||||
|
|
|
@ -18,12 +18,22 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char **environ = 0;
|
#include "libmes-mini.h"
|
||||||
|
|
||||||
int main (int argc, char *argv[], char *envp[]);
|
int main (int argc, char *argv[], char *envp[]);
|
||||||
|
|
||||||
int
|
int
|
||||||
_start ()
|
_start ()
|
||||||
{
|
{
|
||||||
|
asm ("mov____$i8,%eax !0");
|
||||||
|
asm ("mov____%eax,0x32 &g_stdin");
|
||||||
|
|
||||||
|
asm ("mov____$i8,%eax !1");
|
||||||
|
asm ("mov____%eax,0x32 &g_stdout");
|
||||||
|
|
||||||
|
asm ("mov____$i8,%eax !2");
|
||||||
|
asm ("mov____%eax,0x32 &g_stderr");
|
||||||
|
|
||||||
asm ("mov____%ebp,%eax");
|
asm ("mov____%ebp,%eax");
|
||||||
asm ("add____$i8,%eax !4");
|
asm ("add____$i8,%eax !4");
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
// instead of calling main, it seems to call either _main or ___main,
|
// instead of calling main, it seems to call either _main or ___main,
|
||||||
// let's try _main first
|
// let's try _main first
|
||||||
|
|
||||||
char **environ = 0;
|
#include <libmes-mini.h>
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
|
|
||||||
// gcc x86_64 calling convention:
|
// gcc x86_64 calling convention:
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char **environ = 0;
|
#include <libmes-mini.h>
|
||||||
// int main (int argc, char *argv[]);
|
// int main (int argc, char *argv[]);
|
||||||
|
|
||||||
// gcc x86_64 calling convention:
|
// gcc x86_64 calling convention:
|
||||||
|
@ -27,6 +27,26 @@ char **environ = 0;
|
||||||
void
|
void
|
||||||
_start ()
|
_start ()
|
||||||
{
|
{
|
||||||
|
asm (
|
||||||
|
"mov $0,%%rax\n\t"
|
||||||
|
"mov %%rax,%0\n"
|
||||||
|
: "=r" (g_stdin)
|
||||||
|
: //no inputs ""
|
||||||
|
);
|
||||||
|
|
||||||
|
asm (
|
||||||
|
"mov $1,%%rax\n\t"
|
||||||
|
"mov %%rax,%0\n"
|
||||||
|
: "=r" (g_stdout)
|
||||||
|
: //no inputs ""
|
||||||
|
);
|
||||||
|
|
||||||
|
asm (
|
||||||
|
"mov $2,%%rax\n\t"
|
||||||
|
"mov %%rax,%0\n"
|
||||||
|
: "=r" (g_stderr)
|
||||||
|
: //no inputs ""
|
||||||
|
);
|
||||||
asm (
|
asm (
|
||||||
"mov %%rbp,%%rax\n\t"
|
"mov %%rbp,%%rax\n\t"
|
||||||
"add $8,%%rax\n\t"
|
"add $8,%%rax\n\t"
|
||||||
|
|
|
@ -18,12 +18,21 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char **environ = 0;
|
#include "libmes-mini.h"
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[], char *envp[]);
|
||||||
|
|
||||||
int
|
int
|
||||||
_start ()
|
_start ()
|
||||||
{
|
{
|
||||||
|
asm ("mov____$i8,%rax !0");
|
||||||
|
asm ("mov____%rax,0x32 &g_stdin");
|
||||||
|
|
||||||
|
asm ("mov____$i8,%rax !1");
|
||||||
|
asm ("mov____%rax,0x32 &g_stdout");
|
||||||
|
|
||||||
|
asm ("mov____$i8,%rax !2");
|
||||||
|
asm ("mov____%rax,0x32 &g_stderr");
|
||||||
|
|
||||||
#if 0 //MES_CCAMD64
|
#if 0 //MES_CCAMD64
|
||||||
asm ("add____$i32,%rbp %0x80"); // FIXME: corresponds to x86_64/as.scm function-preamble-fu
|
asm ("add____$i32,%rbp %0x80"); // FIXME: corresponds to x86_64/as.scm function-preamble-fu
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -82,6 +82,8 @@ DEFINE mov____$i32,(%eax) c700
|
||||||
DEFINE mov____$i32,0x32 c705
|
DEFINE mov____$i32,0x32 c705
|
||||||
DEFINE mov____$i32,0x8(%eax) c740
|
DEFINE mov____$i32,0x8(%eax) c740
|
||||||
DEFINE mov____$i32,0x8(%ebp) c745
|
DEFINE mov____$i32,0x8(%ebp) c745
|
||||||
|
DEFINE mov____$i8,%al b0
|
||||||
|
DEFINE mov____$i8,%eax b0
|
||||||
DEFINE mov____%al,(%ebx) 8803
|
DEFINE mov____%al,(%ebx) 8803
|
||||||
DEFINE mov____%al,0x8(%ebp) 8845
|
DEFINE mov____%al,0x8(%ebp) 8845
|
||||||
DEFINE mov____%ax,(%ebx) 668903
|
DEFINE mov____%ax,(%ebx) 668903
|
||||||
|
|
|
@ -82,6 +82,8 @@ DEFINE mov____$i32,0x8(%rbp) c745
|
||||||
DEFINE mov____$i64,%r15 49bf
|
DEFINE mov____$i64,%r15 49bf
|
||||||
DEFINE mov____$i64,%rax 48b8
|
DEFINE mov____$i64,%rax 48b8
|
||||||
DEFINE mov____$i64,%rdi 48bf
|
DEFINE mov____$i64,%rdi 48bf
|
||||||
|
DEFINE mov____$i8,%al b0
|
||||||
|
DEFINE mov____$i8,%rax b0
|
||||||
DEFINE mov____%al,(%rdi) 8807
|
DEFINE mov____%al,(%rdi) 8807
|
||||||
DEFINE mov____%al,0x32(%rbp) 8885
|
DEFINE mov____%al,0x32(%rbp) 8885
|
||||||
DEFINE mov____%al,0x8(%rbp) 8845
|
DEFINE mov____%al,0x8(%rbp) 8845
|
||||||
|
|
|
@ -2286,9 +2286,6 @@ main (int argc, char *argv[])
|
||||||
STACK_SIZE = atoi (p);
|
STACK_SIZE = atoi (p);
|
||||||
if (p = getenv ("MES_MAX_STRING"))
|
if (p = getenv ("MES_MAX_STRING"))
|
||||||
MAX_STRING = atoi (p);
|
MAX_STRING = atoi (p);
|
||||||
g_stdin = STDIN;
|
|
||||||
g_stdout = STDOUT;
|
|
||||||
g_stderr = STDERR;
|
|
||||||
|
|
||||||
SCM a = mes_environment (argc, argv);
|
SCM a = mes_environment (argc, argv);
|
||||||
a = mes_builtins (a);
|
a = mes_builtins (a);
|
||||||
|
|
Loading…
Reference in a new issue