overhaul locale internals to treat categories roughly uniformly
[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 *volatile cat[6];
12 };
13
14 struct __libc {
15         int can_do_threads;
16         int threaded;
17         int secure;
18         volatile int threads_minus_1;
19         size_t *auxv;
20         FILE *ofl_head;
21         volatile int ofl_lock[2];
22         size_t tls_size;
23         size_t page_size;
24         struct __locale_struct global_locale;
25 };
26
27 #ifndef PAGE_SIZE
28 #define PAGE_SIZE libc.page_size
29 #endif
30
31 #ifdef __PIC__
32 #define ATTR_LIBC_VISIBILITY __attribute__((visibility("hidden")))
33 #else
34 #define ATTR_LIBC_VISIBILITY
35 #endif
36
37 extern struct __libc __libc ATTR_LIBC_VISIBILITY;
38 #define libc __libc
39
40 extern size_t __hwcap ATTR_LIBC_VISIBILITY;
41 extern size_t __sysinfo ATTR_LIBC_VISIBILITY;
42 extern char *__progname, *__progname_full;
43
44 /* Designed to avoid any overhead in non-threaded processes */
45 void __lock(volatile int *) ATTR_LIBC_VISIBILITY;
46 void __unlock(volatile int *) ATTR_LIBC_VISIBILITY;
47 int __lockfile(FILE *) ATTR_LIBC_VISIBILITY;
48 void __unlockfile(FILE *) ATTR_LIBC_VISIBILITY;
49 #define LOCK(x) __lock(x)
50 #define UNLOCK(x) __unlock(x)
51
52 void __synccall(void (*)(void *), void *);
53 int __setxid(int, int, int, int);
54
55 extern char **__environ;
56
57 #undef weak_alias
58 #define weak_alias(old, new) \
59         extern __typeof(old) new __attribute__((weak, alias(#old)))
60
61 #undef LFS64_2
62 #define LFS64_2(x, y) weak_alias(x, y)
63
64 #undef LFS64
65 #define LFS64(x) LFS64_2(x, x##64)
66
67 #endif