libc-internal.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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. #include <features.h>
  18. #ifndef __ASSEMBLER__
  19. /* GCC understands weak symbols and aliases; use its interface where
  20. possible, instead of embedded assembly language. */
  21. /* Define ALIASNAME as a strong alias for NAME. */
  22. # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
  23. # define _strong_alias(name, aliasname) \
  24. extern __typeof (name) aliasname __attribute__ ((alias (#name)));
  25. /* This comes between the return type and function name in
  26. a function definition to make that definition weak. */
  27. # define weak_function __attribute__ ((weak))
  28. # define weak_const_function __attribute__ ((weak, __const__))
  29. /* Define ALIASNAME as a weak alias for NAME.
  30. If weak aliases are not available, this defines a strong alias. */
  31. # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
  32. # define _weak_alias(name, aliasname) \
  33. extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
  34. /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
  35. # define weak_extern(symbol) _weak_extern (weak symbol)
  36. # define _weak_extern(expr) _Pragma (#expr)
  37. #else /* __ASSEMBLER__ */
  38. #ifdef __SYMBOL_PREFIX
  39. # define C_SYMBOL_NAME(name) _##name
  40. #else
  41. # define C_SYMBOL_NAME(name) name
  42. #endif
  43. # define strong_alias(name, aliasname) \
  44. .global C_SYMBOL_NAME (aliasname) ; \
  45. .set C_SYMBOL_NAME(aliasname),C_SYMBOL_NAME(name)
  46. # define weak_alias(name, aliasname) \
  47. .weak C_SYMBOL_NAME(aliasname) ; \
  48. C_SYMBOL_NAME(aliasname) = C_SYMBOL_NAME(name)
  49. # define weak_extern(symbol) \
  50. .weak C_SYMBOL_NAME(symbol)
  51. #endif /* __ASSEMBLER__ */
  52. /* When a reference to SYMBOL is encountered, the linker will emit a
  53. warning message MSG. */
  54. #ifdef __HAVE_ELF__
  55. /* We want the .gnu.warning.SYMBOL section to be unallocated. */
  56. # define __make_section_unallocated(section_string) \
  57. asm (".section " section_string "\n\t.previous");
  58. /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
  59. section attributes on what looks like a comment to the assembler. */
  60. # ifdef __sparc__ //HAVE_SECTION_QUOTES
  61. # define __sec_comment "\"\n\t#\""
  62. # else
  63. # define __sec_comment "\n\t#"
  64. # endif
  65. # ifdef __cris__
  66. # define link_warning(symbol, msg)
  67. # else
  68. # define link_warning(symbol, msg) \
  69. __make_section_unallocated (".gnu.warning." #symbol) \
  70. static const char __evoke_link_warning_##symbol[] \
  71. __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
  72. = msg;
  73. # endif
  74. #else /* __HAVE_ELF__ */
  75. # define link_warning(symbol, msg) \
  76. asm (".stabs \"" msg "\",30,0,0,0\n\t" \
  77. ".stabs \"" __C_SYMBOL_PREFIX__ #symbol "\",1,0,0,0\n");
  78. #endif /* __HAVE_ELF__ */
  79. #ifndef weak_function
  80. /* If we do not have the __attribute__ ((weak)) syntax, there is no way we
  81. can define functions as weak symbols. The compiler will emit a `.globl'
  82. directive for the function symbol, and a `.weak' directive in addition
  83. will produce an error from the assembler. */
  84. # define weak_function /* empty */
  85. # define weak_const_function /* empty */
  86. #endif
  87. /* On some platforms we can make internal function calls (i.e., calls of
  88. functions not exported) a bit faster by using a different calling
  89. convention. */
  90. #if 0 /*def __i386__*/
  91. # define internal_function __attribute__ ((regparm (3), stdcall))
  92. #endif
  93. #ifndef internal_function
  94. # define internal_function /* empty */
  95. #endif
  96. #ifndef NOT_IN_libc
  97. # define IS_IN_libc 1
  98. #endif
  99. /* need this to unset defaults in libpthread for files that get added to libc */
  100. #ifdef IS_IN_libc
  101. # undef NOT_IN_libc
  102. #endif
  103. /* Prepare for the case that `__builtin_expect' is not available. */
  104. #if __GNUC__ == 2 && __GNUC_MINOR__ < 96
  105. # define __builtin_expect(x, expected_value) (x)
  106. #endif
  107. #ifndef likely
  108. # define likely(x) __builtin_expect((!!(x)),1)
  109. #endif
  110. #ifndef unlikely
  111. # define unlikely(x) __builtin_expect((!!(x)),0)
  112. #endif
  113. #ifndef __LINUX_COMPILER_H
  114. # define __LINUX_COMPILER_H
  115. #endif
  116. #ifndef __cast__
  117. # define __cast__(_to)
  118. #endif
  119. #define attribute_unused __attribute__ ((unused))
  120. /* The following macros are used for PLT bypassing within libc.so
  121. (and if needed other libraries similarly).
  122. First of all, you need to have the function prototyped somewhere,
  123. say in foo/foo.h:
  124. int foo (int __bar);
  125. If calls to foo within libc.so should always go to foo defined in libc.so,
  126. then in include/foo.h you add:
  127. libc_hidden_proto (foo)
  128. line and after the foo function definition:
  129. int foo (int __bar)
  130. {
  131. return __bar;
  132. }
  133. libc_hidden_def (foo)
  134. or
  135. int foo (int __bar)
  136. {
  137. return __bar;
  138. }
  139. libc_hidden_weak (foo)
  140. Simularly for global data. If references to foo within libc.so should
  141. always go to foo defined in libc.so, then in include/foo.h you add:
  142. libc_hidden_proto (foo)
  143. line and after foo's definition:
  144. int foo = INITIAL_FOO_VALUE;
  145. libc_hidden_data_def (foo)
  146. or
  147. int foo = INITIAL_FOO_VALUE;
  148. libc_hidden_data_weak (foo)
  149. If foo is normally just an alias (strong or weak) of some other function,
  150. you should use the normal strong_alias first, then add libc_hidden_def
  151. or libc_hidden_weak:
  152. int baz (int __bar)
  153. {
  154. return __bar;
  155. }
  156. strong_alias (baz, foo)
  157. libc_hidden_weak (foo)
  158. If the function should be internal to multiple objects, say ld.so and
  159. libc.so, the best way is to use:
  160. #if !defined NOT_IN_libc || defined IS_IN_rtld
  161. hidden_proto (foo)
  162. #endif
  163. in include/foo.h and the normal macros at all function definitions
  164. depending on what DSO they belong to.
  165. If versioned_symbol macro is used to define foo,
  166. libc_hidden_ver macro should be used, as in:
  167. int __real_foo (int __bar)
  168. {
  169. return __bar;
  170. }
  171. versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
  172. libc_hidden_ver (__real_foo, foo) */
  173. /* uClibc specific (the above comment was copied from glibc):
  174. * a. when ppc64 will be supported, we need changes to support:
  175. * strong_data_alias (used by asm hidden_data_def) / HAVE_ASM_GLOBAL_DOT_NAME
  176. * b. libc_hidden_proto(foo) should be added after the header having foo's prototype
  177. * or after extern foo... to all source files that should use the internal version
  178. * of foo within libc, even to the file defining foo itself, libc_hidden_def does
  179. * not hide __GI_foo itself, although the name suggests it (hiding is done exclusively
  180. * by libc_hidden_proto). The reasoning to have it after the header w/ foo's prototype is
  181. * to get first the __REDIRECT from original header and then create the __GI_foo alias
  182. * c. no versioning support, hidden[_data]_ver are noop */
  183. /* Arrange to hide uClibc internals */
  184. #if __GNUC_PREREQ (3, 3)
  185. # define attribute_hidden __attribute__ ((visibility ("hidden")))
  186. # define __hidden_proto_hiddenattr(attrs...) __attribute__ ((visibility ("hidden"), ##attrs))
  187. #else
  188. # define attribute_hidden
  189. # define __hidden_proto_hiddenattr(attrs...)
  190. #endif
  191. /* if ppc64 will be supported, this section needs adapting due to HAVE_ASM_GLOBAL_DOT_NAME */
  192. #if 1 /* SHARED */
  193. # ifndef __ASSEMBLER__
  194. # define hidden_strong_alias(name, aliasname) _hidden_strong_alias(name, aliasname)
  195. # define _hidden_strong_alias(name, aliasname) \
  196. extern __typeof (name) aliasname __attribute__ ((alias (#name))) attribute_hidden;
  197. # define hidden_weak_alias(name, aliasname) _hidden_weak_alias (name, aliasname)
  198. # define _hidden_weak_alias(name, aliasname) \
  199. extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) attribute_hidden;
  200. # define hidden_proto(name, attrs...) __hidden_proto (name, __GI_##name, ##attrs)
  201. # define __hidden_proto(name, internal, attrs...) \
  202. extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
  203. __hidden_proto_hiddenattr (attrs);
  204. # define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
  205. # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
  206. # define __hidden_asmname2(prefix, name) #prefix name
  207. # define __hidden_ver1(local, internal, name) \
  208. extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
  209. extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname (#local))))
  210. # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
  211. # define hidden_data_def(name) hidden_def(name)
  212. # define hidden_weak(name) __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
  213. # define hidden_data_weak(name) hidden_weak(name)
  214. # else /* __ASSEMBLER__ */
  215. # define hidden_strong_alias(name, aliasname) \
  216. .global C_SYMBOL_NAME (aliasname) ; \
  217. .hidden C_SYMBOL_NAME (aliasname) ; \
  218. .set C_SYMBOL_NAME(aliasname),C_SYMBOL_NAME(name)
  219. # define hidden_weak_alias(name, aliasname) \
  220. .weak C_SYMBOL_NAME(aliasname) ; \
  221. .hidden C_SYMBOL_NAME(aliasname) ; \
  222. C_SYMBOL_NAME(aliasname) = C_SYMBOL_NAME(name)
  223. /* For assembly, we need to do the opposite of what we do in C:
  224. in assembly gcc __REDIRECT stuff is not in place, so functions
  225. are defined by its normal name and we need to create the
  226. __GI_* alias to it, in C __REDIRECT causes the function definition
  227. to use __GI_* name and we need to add alias to the real name.
  228. There is no reason to use hidden_weak over hidden_def in assembly,
  229. but we provide it for consistency with the C usage.
  230. hidden_proto doesn't make sense for assembly but the equivalent
  231. is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
  232. # define hidden_def(name) hidden_strong_alias (name, __GI_##name)
  233. # define hidden_data_def(name) hidden_strong_alias (name, __GI_##name)
  234. # define hidden_weak(name) hidden_def (name)
  235. # define hidden_data_weak(name) hidden_data_def (name)
  236. # define HIDDEN_JUMPTARGET(name) __GI_##name
  237. # endif /* __ASSEMBLER__ */
  238. #else /* SHARED */
  239. # define hidden_strong_alias(name, aliasname)
  240. # define hidden_weak_alias(name, aliasname)
  241. # ifndef __ASSEMBLER__
  242. # define hidden_proto(name, attrs...)
  243. # else
  244. # define HIDDEN_JUMPTARGET(name) name
  245. # endif
  246. # define hidden_def(name)
  247. # define hidden_data_def(name)
  248. # define hidden_weak(name)
  249. # define hidden_data_weak(name)
  250. #endif /* SHARED */
  251. /* uClibc does not support versioning yet. */
  252. #define versioned_symbol(lib, local, symbol, version) /* weak_alias(local, symbol) */
  253. #define hidden_ver(local, name) /* strong_alias(local, __GI_##name) */
  254. #define hidden_data_ver(local, name) /* strong_alias(local,__GI_##name) */
  255. #if !defined NOT_IN_libc
  256. # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  257. # define libc_hidden_def(name) hidden_def (name)
  258. # define libc_hidden_weak(name) hidden_weak (name)
  259. # define libc_hidden_ver(local, name) hidden_ver (local, name)
  260. # define libc_hidden_data_def(name) hidden_data_def (name)
  261. # define libc_hidden_data_weak(name) hidden_data_weak (name)
  262. # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
  263. #else
  264. # define libc_hidden_proto(name, attrs...)
  265. # define libc_hidden_def(name)
  266. # define libc_hidden_weak(name)
  267. # define libc_hidden_ver(local, name)
  268. # define libc_hidden_data_def(name)
  269. # define libc_hidden_data_weak(name)
  270. # define libc_hidden_data_ver(local, name)
  271. #endif
  272. #if defined NOT_IN_libc && defined IS_IN_rtld
  273. # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  274. # define rtld_hidden_def(name) hidden_def (name)
  275. # define rtld_hidden_weak(name) hidden_weak (name)
  276. # define rtld_hidden_ver(local, name) hidden_ver (local, name)
  277. # define rtld_hidden_data_def(name) hidden_data_def (name)
  278. # define rtld_hidden_data_weak(name) hidden_data_weak (name)
  279. # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
  280. #else
  281. # define rtld_hidden_proto(name, attrs...)
  282. # define rtld_hidden_def(name)
  283. # define rtld_hidden_weak(name)
  284. # define rtld_hidden_ver(local, name)
  285. # define rtld_hidden_data_def(name)
  286. # define rtld_hidden_data_weak(name)
  287. # define rtld_hidden_data_ver(local, name)
  288. #endif
  289. #if defined NOT_IN_libc && defined IS_IN_libm
  290. # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  291. # define libm_hidden_def(name) hidden_def (name)
  292. # define libm_hidden_weak(name) hidden_weak (name)
  293. # define libm_hidden_ver(local, name) hidden_ver (local, name)
  294. # define libm_hidden_data_def(name) hidden_data_def (name)
  295. # define libm_hidden_data_weak(name) hidden_data_weak (name)
  296. # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
  297. #else
  298. # define libm_hidden_proto(name, attrs...)
  299. # define libm_hidden_def(name)
  300. # define libm_hidden_weak(name)
  301. # define libm_hidden_ver(local, name)
  302. # define libm_hidden_data_def(name)
  303. # define libm_hidden_data_weak(name)
  304. # define libm_hidden_data_ver(local, name)
  305. #endif
  306. #if defined NOT_IN_libc && defined IS_IN_libresolv
  307. # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  308. # define libresolv_hidden_def(name) hidden_def (name)
  309. # define libresolv_hidden_weak(name) hidden_weak (name)
  310. # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
  311. # define libresolv_hidden_data_def(name) hidden_data_def (name)
  312. # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
  313. # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
  314. #else
  315. # define libresolv_hidden_proto(name, attrs...)
  316. # define libresolv_hidden_def(name)
  317. # define libresolv_hidden_weak(name)
  318. # define libresolv_hidden_ver(local, name)
  319. # define libresolv_hidden_data_def(name)
  320. # define libresolv_hidden_data_weak(name)
  321. # define libresolv_hidden_data_ver(local, name)
  322. #endif
  323. #if defined NOT_IN_libc && defined IS_IN_librt
  324. # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  325. # define librt_hidden_def(name) hidden_def (name)
  326. # define librt_hidden_weak(name) hidden_weak (name)
  327. # define librt_hidden_ver(local, name) hidden_ver (local, name)
  328. # define librt_hidden_data_def(name) hidden_data_def (name)
  329. # define librt_hidden_data_weak(name) hidden_data_weak (name)
  330. # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
  331. #else
  332. # define librt_hidden_proto(name, attrs...)
  333. # define librt_hidden_def(name)
  334. # define librt_hidden_weak(name)
  335. # define librt_hidden_ver(local, name)
  336. # define librt_hidden_data_def(name)
  337. # define librt_hidden_data_weak(name)
  338. # define librt_hidden_data_ver(local, name)
  339. #endif
  340. #if defined NOT_IN_libc && defined IS_IN_libdl
  341. # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  342. # define libdl_hidden_def(name) hidden_def (name)
  343. # define libdl_hidden_weak(name) hidden_weak (name)
  344. # define libdl_hidden_ver(local, name) hidden_ver (local, name)
  345. # define libdl_hidden_data_def(name) hidden_data_def (name)
  346. # define libdl_hidden_data_weak(name) hidden_data_weak (name)
  347. # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
  348. #else
  349. # define libdl_hidden_proto(name, attrs...)
  350. # define libdl_hidden_def(name)
  351. # define libdl_hidden_weak(name)
  352. # define libdl_hidden_ver(local, name)
  353. # define libdl_hidden_data_def(name)
  354. # define libdl_hidden_data_weak(name)
  355. # define libdl_hidden_data_ver(local, name)
  356. #endif
  357. #if defined NOT_IN_libc && defined IS_IN_libintl
  358. # define libintl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  359. # define libintl_hidden_def(name) hidden_def (name)
  360. # define libintl_hidden_weak(name) hidden_weak (name)
  361. # define libintl_hidden_ver(local, name) hidden_ver (local, name)
  362. # define libintl_hidden_data_def(name) hidden_data_def (name)
  363. # define libintl_hidden_data_weak(name) hidden_data_weak (name)
  364. # define libintl_hidden_data_ver(local, name) hidden_data_ver(local, name)
  365. #else
  366. # define libintl_hidden_proto(name, attrs...)
  367. # define libintl_hidden_def(name)
  368. # define libintl_hidden_weak(name)
  369. # define libintl_hidden_ver(local, name)
  370. # define libintl_hidden_data_def(name)
  371. # define libintl_hidden_data_weak(name)
  372. # define libintl_hidden_data_ver(local, name)
  373. #endif
  374. #if defined NOT_IN_libc && defined IS_IN_libnsl
  375. # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  376. # define libnsl_hidden_def(name) hidden_def (name)
  377. # define libnsl_hidden_weak(name) hidden_weak (name)
  378. # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
  379. # define libnsl_hidden_data_def(name) hidden_data_def (name)
  380. # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
  381. # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
  382. #else
  383. # define libnsl_hidden_proto(name, attrs...)
  384. # define libnsl_hidden_def(name)
  385. # define libnsl_hidden_weak(name)
  386. # define libnsl_hidden_ver(local, name)
  387. # define libnsl_hidden_data_def(name)
  388. # define libnsl_hidden_data_weak(name)
  389. # define libnsl_hidden_data_ver(local, name)
  390. #endif
  391. #if defined NOT_IN_libc && defined IS_IN_libutil
  392. # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  393. # define libutil_hidden_def(name) hidden_def (name)
  394. # define libutil_hidden_weak(name) hidden_weak (name)
  395. # define libutil_hidden_ver(local, name) hidden_ver (local, name)
  396. # define libutil_hidden_data_def(name) hidden_data_def (name)
  397. # define libutil_hidden_data_weak(name) hidden_data_weak (name)
  398. # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
  399. #else
  400. # define libutil_hidden_proto(name, attrs...)
  401. # define libutil_hidden_def(name)
  402. # define libutil_hidden_weak(name)
  403. # define libutil_hidden_ver(local, name)
  404. # define libutil_hidden_data_def(name)
  405. # define libutil_hidden_data_weak(name)
  406. # define libutil_hidden_data_ver(local, name)
  407. #endif
  408. #if defined NOT_IN_libc && defined IS_IN_libcrypt
  409. # define libcrypt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  410. # define libcrypt_hidden_def(name) hidden_def (name)
  411. # define libcrypt_hidden_weak(name) hidden_weak (name)
  412. # define libcrypt_hidden_ver(local, name) hidden_ver (local, name)
  413. # define libcrypt_hidden_data_def(name) hidden_data_def (name)
  414. # define libcrypt_hidden_data_weak(name) hidden_data_weak (name)
  415. # define libcrypt_hidden_data_ver(local, name) hidden_data_ver (local, name)
  416. #else
  417. # define libcrypt_hidden_proto(name, attrs...)
  418. # define libcrypt_hidden_def(name)
  419. # define libcrypt_hidden_weak(name)
  420. # define libcrypt_hidden_ver(local, name)
  421. # define libcrypt_hidden_data_def(name)
  422. # define libcrypt_hidden_data_weak(name)
  423. # define libcrypt_hidden_data_ver(local, name)
  424. #endif
  425. #if defined NOT_IN_libc && defined IS_IN_libpthread
  426. # define libpthread_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  427. # define libpthread_hidden_def(name) hidden_def (name)
  428. # define libpthread_hidden_weak(name) hidden_weak (name)
  429. # define libpthread_hidden_ver(local, name) hidden_ver (local, name)
  430. # define libpthread_hidden_data_def(name) hidden_data_def (name)
  431. # define libpthread_hidden_data_weak(name) hidden_data_weak (name)
  432. # define libpthread_hidden_data_ver(local, name) hidden_data_ver (local, name)
  433. #else
  434. # define libpthread_hidden_proto(name, attrs...)
  435. # define libpthread_hidden_def(name)
  436. # define libpthread_hidden_weak(name)
  437. # define libpthread_hidden_ver(local, name)
  438. # define libpthread_hidden_data_def(name)
  439. # define libpthread_hidden_data_weak(name)
  440. # define libpthread_hidden_data_ver(local, name)
  441. #endif
  442. #ifdef __UCLIBC_BUILD_RELRO__
  443. # define attribute_relro __attribute__ ((section (".data.rel.ro")))
  444. #else
  445. # define attribute_relro
  446. #endif
  447. #ifdef __GNUC__
  448. # define attribute_noreturn __attribute__ ((__noreturn__))
  449. #else
  450. # define attribute_noreturn
  451. #endif
  452. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  453. # define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
  454. #endif
  455. /* Pull in things like __attribute_used__ */
  456. #include <sys/cdefs.h>
  457. /* --- this is added to integrate linuxthreads */
  458. #define __USE_UNIX98 1
  459. #ifndef __ASSEMBLER__
  460. # ifdef IS_IN_libc
  461. # define __need_size_t
  462. # include <stddef.h>
  463. /* sources are built w/ _GNU_SOURCE, this gets undefined */
  464. extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen);
  465. //extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen);
  466. /* #include <pthread.h> */
  467. # ifndef __UCLIBC_HAS_THREADS__
  468. # define __pthread_mutex_init(mutex, mutexattr) ((void)0)
  469. # define __pthread_mutex_lock(mutex) ((void)0)
  470. # define __pthread_mutex_trylock(mutex) ((void)0)
  471. # define __pthread_mutex_unlock(mutex) ((void)0)
  472. # endif
  473. /* internal access to program name */
  474. extern const char *__uclibc_progname attribute_hidden;
  475. # endif /* IS_IN_libc */
  476. /* #include <alloca.h> */
  477. #include <bits/stackinfo.h>
  478. #if _STACK_GROWS_DOWN
  479. # define extend_alloca(buf, len, newlen) \
  480. (__typeof (buf)) ({ size_t __newlen = (newlen); \
  481. char *__newbuf = alloca (__newlen); \
  482. if (__newbuf + __newlen == (char *) buf) \
  483. len += __newlen; \
  484. else \
  485. len = __newlen; \
  486. __newbuf; })
  487. #elif _STACK_GROWS_UP
  488. # define extend_alloca(buf, len, newlen) \
  489. (__typeof (buf)) ({ size_t __newlen = (newlen); \
  490. char *__newbuf = alloca (__newlen); \
  491. char *__buf = (buf); \
  492. if (__buf + __newlen == __newbuf) \
  493. { \
  494. len += __newlen; \
  495. __newbuf = __buf; \
  496. } \
  497. else \
  498. len = __newlen; \
  499. __newbuf; })
  500. #else
  501. # warning unknown stack
  502. # define extend_alloca(buf, len, newlen) \
  503. alloca (((len) = (newlen)))
  504. #endif
  505. #endif /* __ASSEMBLER__ */
  506. #endif /* _LIBC_INTERNAL_H */