libc.h 1.5 KB

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