libc-internal.h 22 KB

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