summaryrefslogtreecommitdiff
path: root/src/nonstd/__libc.c
blob: 2d2462032d8119d43dd7a1cc75c8099cba35f7c0 (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
36
37
38
39
40
41
42
43
44
#include <nonstd/internal.h>
#include "locale.h"
#include "nonstd/locale.h"

#include "_printf.h"
#include "_syscall.h"

void *__libc(LIBC_INTERNAL variable)
{
	extern void *__libc_per_thread(LIBC_INTERNAL __variable);

	void *r = (void*)0;

	static struct __locale_t locale;

	switch (variable) {
	case ERRNO:
		return __libc_per_thread(ERRNO);

	case THREAD_LOCALE:
		r = __libc_per_thread(THREAD_LOCALE);
		if (r) {
			break;
		}
		/* fallthru */

	case GLOBAL_LOCALE:
		r = &locale;
		break;

	case SYSCALL_LOOKUP:
		r = (void*)__syscall_lookup;
		break;

	case PRINTF:
		r = (void*)(__printf);
		break;

	default:
		break;
	}

	return r;
}