libc-internal.h 26 KB

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