summaryrefslogtreecommitdiff
path: root/src/nonstd/__libc_start.c
blob: f9fadfd524471fc366b8b95063b54e0e1e066cfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "stdio.h"
#include "locale.h"

#include "nonstd/io.h"

void __libc_start(int argc, char **argv)
{
	struct __FILE *files = __libc(FILE_STREAMS);

	stdin = files + 0;
	stdin->fd = 0;

	stdout = files + 1;
	stdout->fd = 1;

	stderr = files + 2;
	stderr->fd = 2;

	stdin->next = stdout;
	stdout->next = stderr;

	stdout->prev = stdin;
	stderr->prev = stdout;

        #if defined _POSIX_SOURCE
        setlocale(LC_ALL, "POSIX");
        #else
        setlocale(LC_ALL, "C");
        #endif

	extern void exit(int);
	extern int main(int, char*[]);

        exit(main(argc, argv));
}