libc.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef LIBC_H
  2. #define LIBC_H
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. struct __libc {
  6. int *(*errno_location)(void);
  7. void (*testcancel)(void);
  8. int threaded;
  9. int canceldisable;
  10. void (*fork_handler)(int);
  11. int (*atexit)(void (*)(void));
  12. void (*fini)(void);
  13. void (*ldso_fini)(void);
  14. volatile int threads_minus_1;
  15. int ofl_lock;
  16. FILE *ofl_head;
  17. };
  18. #if 100*__GNUC__+__GNUC_MINOR__ >= 303 || defined(__PCC__) || defined(__TINYC__)
  19. extern struct __libc __libc __attribute__((visibility("hidden")));
  20. #define libc __libc
  21. #elif !defined(__PIC__)
  22. extern struct __libc __libc;
  23. #define libc __libc
  24. #else
  25. #define USE_LIBC_ACCESSOR
  26. extern struct __libc *__libc_loc(void) __attribute__((const));
  27. #define libc (*__libc_loc())
  28. #endif
  29. /* Designed to avoid any overhead in non-threaded processes */
  30. void __lock(volatile int *);
  31. void __lockfile(FILE *);
  32. #define LOCK(x) (libc.threads_minus_1 ? (__lock(x),1) : ((void)(x),1))
  33. #define UNLOCK(x) (*(volatile int *)(x)=0)
  34. int __rsyscall(int, long, long, long, long, long, long);
  35. extern char **__environ;
  36. #define environ __environ
  37. #undef weak_alias
  38. #define weak_alias(old, new) \
  39. extern __typeof(old) new __attribute__((weak, alias(#old)))
  40. #undef LFS64_2
  41. //#define LFS64_2(x, y) weak_alias(x, y)
  42. #define LFS64_2(x, y) extern __typeof(x) y
  43. #undef LFS64
  44. #define LFS64(x) LFS64_2(x, x##64)
  45. #endif