move __memalign declaration to malloc_impl.h
[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 tls_module {
15         struct tls_module *next;
16         void *image;
17         size_t len, size, align, offset;
18 };
19
20 struct __libc {
21         int can_do_threads;
22         int threaded;
23         int secure;
24         volatile int threads_minus_1;
25         size_t *auxv;
26         struct tls_module *tls_head;
27         size_t tls_size, tls_align, tls_cnt;
28         size_t page_size;
29         struct __locale_struct global_locale;
30 };
31
32 #ifndef PAGE_SIZE
33 #define PAGE_SIZE libc.page_size
34 #endif
35
36 #define weak __attribute__((__weak__))
37 #define hidden __attribute__((__visibility__("hidden")))
38
39 extern hidden struct __libc __libc;
40 #define libc __libc
41
42 extern hidden size_t __hwcap;
43 extern hidden size_t __sysinfo;
44 extern char *__progname, *__progname_full;
45
46 extern hidden const char __libc_version[];
47
48 /* Designed to avoid any overhead in non-threaded processes */
49 hidden void __lock(volatile int *);
50 hidden void __unlock(volatile int *);
51 hidden int __lockfile(FILE *);
52 hidden void __unlockfile(FILE *);
53 #define LOCK(x) __lock(x)
54 #define UNLOCK(x) __unlock(x)
55
56 void __synccall(void (*)(void *), void *);
57 int __setxid(int, int, int, int);
58
59 extern char **__environ;
60
61 #undef weak_alias
62 #define weak_alias(old, new) \
63         extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
64
65 #undef LFS64_2
66 #define LFS64_2(x, y) weak_alias(x, y)
67
68 #undef LFS64
69 #define LFS64(x) LFS64_2(x, x##64)
70
71 #endif