libc-internal.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _LIBC_INTERNAL_H
  16. #define _LIBC_INTERNAL_H 1
  17. /* Some nice features only work properly with ELF */
  18. #if defined __HAVE_ELF__
  19. /* Define ALIASNAME as a weak alias for NAME. */
  20. # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
  21. # define _weak_alias(name, aliasname) \
  22. extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
  23. /* Define ALIASNAME as a strong alias for NAME. */
  24. # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
  25. # define _strong_alias(name, aliasname) \
  26. extern __typeof (name) aliasname __attribute__ ((alias (#name)));
  27. /* This comes between the return type and function name in
  28. * a function definition to make that definition weak. */
  29. # define weak_function __attribute__ ((weak))
  30. # define weak_const_function __attribute__ ((weak, __const__))
  31. /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
  32. * section attributes on what looks like a comment to the assembler. */
  33. # if defined(__cris__)
  34. # define link_warning(symbol, msg)
  35. # else
  36. # define link_warning(symbol, msg) \
  37. asm (".section " ".gnu.warning." #symbol "\n\t.previous"); \
  38. static const char __evoke_link_warning_##symbol[] \
  39. __attribute__ ((unused, section (".gnu.warning." #symbol "\n\t#"))) = msg;
  40. # endif
  41. #else /* !defined __HAVE_ELF__ */
  42. # define strong_alias(name, aliasname) _strong_alias (name, aliasname)
  43. # define weak_alias(name, aliasname) _strong_alias (name, aliasname)
  44. # define _strong_alias(name, aliasname) \
  45. __asm__(".global " __C_SYMBOL_PREFIX__ #aliasname "\n" \
  46. ".set " __C_SYMBOL_PREFIX__ #aliasname "," __C_SYMBOL_PREFIX__ #name);
  47. # define link_warning(symbol, msg) \
  48. asm (".stabs \"" msg "\",30,0,0,0\n\t" \
  49. ".stabs \"" #symbol "\",1,0,0,0\n");
  50. #endif
  51. #ifndef weak_function
  52. /* If we do not have the __attribute__ ((weak)) syntax, there is no way we
  53. can define functions as weak symbols. The compiler will emit a `.globl'
  54. directive for the function symbol, and a `.weak' directive in addition
  55. will produce an error from the assembler. */
  56. # define weak_function /* empty */
  57. # define weak_const_function /* empty */
  58. #endif
  59. /* On some platforms we can make internal function calls (i.e., calls of
  60. functions not exported) a bit faster by using a different calling
  61. convention. */
  62. #ifndef internal_function
  63. # define internal_function /* empty */
  64. #endif
  65. #ifndef NOT_IN_libc
  66. # define IS_IN_libc 1
  67. #endif
  68. /* Prepare for the case that `__builtin_expect' is not available. */
  69. #if __GNUC__ == 2 && __GNUC_MINOR__ < 96
  70. # define __builtin_expect(x, expected_value) (x)
  71. #endif
  72. #ifndef likely
  73. # define likely(x) __builtin_expect((!!(x)),1)
  74. #endif
  75. #ifndef unlikely
  76. # define unlikely(x) __builtin_expect((!!(x)),0)
  77. #endif
  78. #ifndef __LINUX_COMPILER_H
  79. # define __LINUX_COMPILER_H
  80. #endif
  81. #ifndef __cast__
  82. # define __cast__(_to)
  83. #endif
  84. /* Arrange to hide uClibc internals */
  85. #if __GNUC_PREREQ (3, 3)
  86. # define attribute_hidden __attribute__ ((visibility ("hidden")))
  87. #else
  88. # define attribute_hidden
  89. #endif
  90. #define hidden_def(name) extern __typeof (name) name attribute_hidden;
  91. #ifdef __UCLIBC_BUILD_RELRO__
  92. # define attribute_relro __attribute__ ((section (".data.rel.ro")))
  93. #else
  94. # define attribute_relro
  95. #endif
  96. #ifdef __GNUC__
  97. # define attribute_noreturn __attribute__ ((__noreturn__))
  98. #else
  99. # define attribute_noreturn
  100. #endif
  101. /* Pull in things like __attribute_used__ */
  102. #include <sys/cdefs.h>
  103. /* --- this is added to integrate linuxthreads */
  104. #define __USE_UNIX98 1
  105. #ifndef __ASSEMBLER__
  106. # ifdef IS_IN_libc
  107. # include <bits/types.h>
  108. # ifndef __ssize_t_defined
  109. typedef __ssize_t ssize_t;
  110. # define __ssize_t_defined
  111. # endif
  112. # define __need_size_t
  113. # include <stddef.h>
  114. # include <bits/sigset.h>
  115. /* prototypes for internal use, please keep these in sync w/ updated headers */
  116. /* #include <fcntl.h> */
  117. extern int __open(__const char *__file, int __oflag, ...) attribute_hidden;
  118. /* #include <string.h> */
  119. extern int __memcmp (__const void *__s1, __const void *__s2, size_t __n) attribute_hidden;
  120. extern void *__memcpy (void *__restrict __dest,
  121. __const void *__restrict __src, size_t __n) attribute_hidden;
  122. extern void *__memmove (void *__dest, __const void *__src, size_t __n) attribute_hidden;
  123. extern void *__memset (void *__s, int __c, size_t __n) attribute_hidden;
  124. extern char *__strcpy (char *__restrict __dest, __const char *__restrict __src) attribute_hidden;
  125. extern size_t __strlen (__const char *__s) attribute_hidden;
  126. extern int __strcmp (__const char *__s1, __const char *__s2) attribute_hidden;
  127. extern char *__strcat (char *__restrict __dest, __const char *__restrict __src) attribute_hidden;
  128. extern char *__strncpy (char *__restrict __dest,
  129. __const char *__restrict __src, size_t __n) attribute_hidden;
  130. extern char *__strchr (__const char *__s, int __c) attribute_hidden;
  131. extern int __strncmp (__const char *__s1, __const char *__s2, size_t __n) attribute_hidden;
  132. extern char *__strdup (__const char *__s) attribute_hidden;
  133. /* #include <unistd.h> */
  134. extern ssize_t __read(int __fd, void *__buf, size_t __nbytes) attribute_hidden;
  135. extern ssize_t __write(int __fd, __const void *__buf, size_t __n) attribute_hidden;
  136. extern int __close(int __fd) attribute_hidden;
  137. extern __pid_t __getpid (void) attribute_hidden;
  138. /* #include <stdlib.h> */
  139. extern char *__getenv (__const char *__name) attribute_hidden;
  140. /* #include <signal.h> */
  141. extern int __sigprocmask (int __how, __const __sigset_t *__restrict __set,
  142. __sigset_t *__restrict __oset) attribute_hidden;
  143. /* #include <sys/time.h> */
  144. # if 0 /* undoable here */
  145. # define __need_timeval
  146. # include <bits/time.h>
  147. extern int __gettimeofday(struct timeval *__restrict __tv, *__restrict __timezone__ptr_t __tz) attribute_hidden;
  148. # else
  149. # define gettimeofday __gettimeofday
  150. # endif
  151. /* #include <pthread.h> */
  152. # ifndef __UCLIBC_HAS_THREADS__
  153. # define __pthread_mutex_init(mutex, mutexattr) ((void)0)
  154. # define __pthread_mutex_lock(mutex) ((void)0)
  155. # define __pthread_mutex_trylock(mutex) ((void)0)
  156. # define __pthread_mutex_unlock(mutex) ((void)0)
  157. # endif
  158. # endif /* IS_IN_libc */
  159. #endif /* __ASSEMBLER__ */
  160. #endif /* _LIBC_INTERNAL_H */