]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/internal/libc.h
threads: implement init of TLS and stack pointer (#342)
[wasi-libc.git] / libc-top-half / musl / src / internal / libc.h
1 #ifndef LIBC_H
2 #define LIBC_H
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <limits.h>
7
8 struct __locale_map;
9
10 struct __locale_struct {
11 const struct __locale_map *cat[6];
12 };
13
14 struct tls_module {
15 struct tls_module *next;
16 void *image;
17 size_t len, size, align, offset;
18 };
19
20 struct __libc {
21 #ifdef __wasilibc_unmodified_upstream
22 char can_do_threads;
23 #endif
24 #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
25 char threaded;
26 #endif
27 #ifdef __wasilibc_unmodified_upstream // WASI doesn't currently use any code that needs "secure" mode
28 char secure;
29 #endif
30 #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
31 volatile signed char need_locks;
32 int threads_minus_1;
33 #endif
34 #ifdef __wasilibc_unmodified_upstream // WASI has no auxv
35 size_t *auxv;
36 #endif
37 #ifdef __wasilibc_unmodified_upstream // WASI use different TLS implement
38 struct tls_module *tls_head;
39 size_t tls_size, tls_align, tls_cnt;
40 #endif
41 #ifdef __wasilibc_unmodified_upstream // WASI doesn't get the page size from auxv
42 size_t page_size;
43 #endif
44 struct __locale_struct global_locale;
45 #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
46 #else
47 struct __locale_struct *current_locale;
48 #endif
49 };
50
51 #ifndef PAGE_SIZE
52 #define PAGE_SIZE libc.page_size
53 #endif
54
55 extern hidden struct __libc __libc;
56 #define libc __libc
57
58 hidden void __init_libc(char **, char *);
59 hidden void __init_tls(size_t *);
60 hidden void __init_ssp(void *);
61 hidden void __libc_start_init(void);
62 hidden void __funcs_on_exit(void);
63 hidden void __funcs_on_quick_exit(void);
64 hidden void __libc_exit_fini(void);
65 hidden void __fork_handler(int);
66
67 extern hidden size_t __hwcap;
68 extern hidden size_t __sysinfo;
69 extern char *__progname, *__progname_full;
70
71 extern hidden const char __libc_version[];
72
73 hidden void __synccall(void (*)(void *), void *);
74 hidden int __setxid(int, int, int, int);
75
76 #endif