apply feature test protection to memccpy
[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 (*lock)(volatile int *);
9         void (*cancelpt)(int);
10         int (*atexit)(void (*)(void));
11         void (*fini)(void);
12         void (*ldso_fini)(void);
13         int *(*errno_location)(void);
14         volatile int threads_minus_1;
15         int (*rsyscall)(int, long, long, long, long, long, long);
16         void (**tsd_keys)(void *);
17         void (*fork_handler)(int);
18 };
19
20 #ifdef __PIC__
21 extern struct __libc *__libc_loc(void) __attribute__((const));
22 #define libc (*__libc_loc())
23 #else
24 extern struct __libc __libc;
25 #define libc __libc
26 #endif
27
28
29 /* Designed to avoid any overhead in non-threaded processes */
30 void __lock(volatile int *);
31 #define LOCK(x) (libc.threads_minus_1 ? (__lock(x),1) : ((void)(x),1))
32 #define UNLOCK(x) (*(x)=0)
33 #define CANCELPT(x) (libc.cancelpt ? libc.cancelpt((x)),0 : (void)(x),0)
34 #define CANCELPT_BEGIN CANCELPT(1)
35 #define CANCELPT_END CANCELPT(0)
36
37 extern char **__environ;
38 #define environ __environ
39
40 #undef weak_alias
41 #define weak_alias(old, new) \
42         extern __typeof(old) new __attribute__((weak, alias(#old)))
43
44 #undef LFS64_2
45 //#define LFS64_2(x, y) weak_alias(x, y)
46 #define LFS64_2(x, y) extern __typeof(x) y
47
48 #undef LFS64
49 #define LFS64(x) LFS64_2(x, x##64)
50
51 #endif