remove everything related to forkall
[musl] / src / internal / libc.h
1 #ifndef LIBC_H
2 #define LIBC_H
3
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 struct __libc {
8         void *main_thread;
9         int threaded;
10         int secure;
11         size_t *auxv;
12         int (*atexit)(void (*)(void));
13         void (*fini)(void);
14         void (*ldso_fini)(void);
15         volatile int threads_minus_1;
16         int canceldisable;
17         FILE *ofl_head;
18         int ofl_lock[2];
19 };
20
21
22 #if !defined(__PIC__) || 100*__GNUC__+__GNUC_MINOR__ >= 303 || defined(__PCC__) || defined(__TINYC__)
23
24 #ifdef __PIC__
25 #if __GNUC__ < 4
26 #define BROKEN_VISIBILITY 1
27 #endif
28 #define ATTR_LIBC_VISIBILITY __attribute__((visibility("hidden"))) 
29 #else
30 #define ATTR_LIBC_VISIBILITY
31 #endif
32
33 extern struct __libc __libc ATTR_LIBC_VISIBILITY;
34 #define libc __libc
35
36 #else
37
38 #define USE_LIBC_ACCESSOR
39 #define ATTR_LIBC_VISIBILITY
40 extern struct __libc *__libc_loc(void) __attribute__((const));
41 #define libc (*__libc_loc())
42
43 #endif
44
45
46 /* Designed to avoid any overhead in non-threaded processes */
47 void __lock(volatile int *);
48 void __unlock(volatile int *);
49 int __lockfile(FILE *);
50 void __unlockfile(FILE *);
51 #define LOCK(x) (libc.threads_minus_1 ? (__lock(x),1) : ((void)(x),1))
52 #define UNLOCK(x) (libc.threads_minus_1 ? (__unlock(x),1) : ((void)(x),1))
53
54 void __synccall(void (*)(void *), void *);
55 int __setxid(int, int, int, int);
56
57 extern char **__environ;
58 #define environ __environ
59
60 #undef weak_alias
61 #define weak_alias(old, new) \
62         extern __typeof(old) new __attribute__((weak, alias(#old)))
63
64 #undef LFS64_2
65 //#define LFS64_2(x, y) weak_alias(x, y)
66 #define LFS64_2(x, y) extern __typeof(x) y
67
68 #undef LFS64
69 #define LFS64(x) LFS64_2(x, x##64)
70
71 #endif