summaryrefslogtreecommitdiff
path: root/src/nonstd/__libc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nonstd/__libc.c')
-rw-r--r--src/nonstd/__libc.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/nonstd/__libc.c b/src/nonstd/__libc.c
new file mode 100644
index 00000000..2d246203
--- /dev/null
+++ b/src/nonstd/__libc.c
@@ -0,0 +1,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;
+}