Consolidate sin/cos table lookup code
[glibc.git] / include / libc-symbols.h
blob5f603a2864c62f30177359439279dcf35e318145
1 /* Support macros for making weak and strong aliases for symbols,
2 and for using symbol sets and linker warnings with GNU ld.
3 Copyright (C) 1995-2013 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _LIBC_SYMBOLS_H
21 #define _LIBC_SYMBOLS_H 1
23 /* This file's macros are included implicitly in the compilation of every
24 file in the C library by -imacros.
26 We include config.h which is generated by configure.
27 It should define for us the following symbols:
29 * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
30 * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
31 * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
35 /* This is defined for the compilation of all C library code. features.h
36 tests this to avoid inclusion of stubs.h while compiling the library,
37 before stubs.h has been generated. Some library code that is shared
38 with other packages also tests this symbol to see if it is being
39 compiled as part of the C library. We must define this before including
40 config.h, because it makes some definitions conditional on whether libc
41 itself is being compiled, or just some generator program. */
42 #define _LIBC 1
44 /* Enable declarations of GNU extensions, since we are compiling them. */
45 #define _GNU_SOURCE 1
46 /* And we also need the data for the reentrant functions. */
47 #define _REENTRANT 1
49 #include <config.h>
51 /* The symbols in all the user (non-_) macros are C symbols. */
53 #if !defined HAVE_ASM_WEAK_DIRECTIVE && !defined HAVE_ASM_WEAKEXT_DIRECTIVE
54 # error "weak symbol support needed"
55 #endif
57 #ifndef __SYMBOL_PREFIX
58 # define __SYMBOL_PREFIX
59 #endif
61 #ifndef C_SYMBOL_NAME
62 # define C_SYMBOL_NAME(name) name
63 #endif
65 #ifndef ASM_LINE_SEP
66 # define ASM_LINE_SEP ;
67 #endif
69 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
70 # ifndef C_SYMBOL_DOT_NAME
71 # if defined __GNUC__ && defined __GNUC_MINOR__ \
72 && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
73 # define C_SYMBOL_DOT_NAME(name) .name
74 # else
75 # define C_SYMBOL_DOT_NAME(name) .##name
76 # endif
77 # endif
78 #endif
80 #ifndef __ASSEMBLER__
81 /* GCC understands weak symbols and aliases; use its interface where
82 possible, instead of embedded assembly language. */
84 /* Define ALIASNAME as a strong alias for NAME. */
85 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
86 # define _strong_alias(name, aliasname) \
87 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
89 /* This comes between the return type and function name in
90 a function definition to make that definition weak. */
91 # define weak_function __attribute__ ((weak))
92 # define weak_const_function __attribute__ ((weak, __const__))
94 /* Define ALIASNAME as a weak alias for NAME.
95 If weak aliases are not available, this defines a strong alias. */
96 # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
97 # define _weak_alias(name, aliasname) \
98 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
100 /* Same as WEAK_ALIAS, but mark symbol as hidden. */
101 # define weak_hidden_alias(name, aliasname) \
102 _weak_hidden_alias (name, aliasname)
103 # define _weak_hidden_alias(name, aliasname) \
104 extern __typeof (name) aliasname \
105 __attribute__ ((weak, alias (#name), __visibility__ ("hidden")));
107 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
108 # define weak_extern(symbol) _weak_extern (weak symbol)
109 # define _weak_extern(expr) _Pragma (#expr)
112 #else /* __ASSEMBLER__ */
114 # ifdef HAVE_ASM_SET_DIRECTIVE
115 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
116 # define strong_alias(original, alias) \
117 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
118 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
119 .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
120 .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
121 # define strong_data_alias(original, alias) \
122 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
123 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
124 # else
125 # define strong_alias(original, alias) \
126 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
127 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
128 # define strong_data_alias(original, alias) strong_alias(original, alias)
129 # endif
130 # else
131 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
132 # define strong_alias(original, alias) \
133 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
134 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
135 .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
136 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
137 # define strong_data_alias(original, alias) \
138 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
139 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
140 # else
141 # define strong_alias(original, alias) \
142 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
143 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
144 # define strong_data_alias(original, alias) strong_alias(original, alias)
145 # endif
146 # endif
148 # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
149 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
150 # define weak_alias(original, alias) \
151 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
152 .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
153 # else
154 # define weak_alias(original, alias) \
155 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
156 # endif
157 # define weak_extern(symbol) \
158 .weakext C_SYMBOL_NAME (symbol)
160 # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
162 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
163 # define weak_alias(original, alias) \
164 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
165 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
166 .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
167 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
168 # else
169 # define weak_alias(original, alias) \
170 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
171 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
172 # endif
174 # define weak_extern(symbol) \
175 .weak C_SYMBOL_NAME (symbol)
177 # endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
179 #endif /* __ASSEMBLER__ */
181 /* On some platforms we can make internal function calls (i.e., calls of
182 functions not exported) a bit faster by using a different calling
183 convention. */
184 #ifndef internal_function
185 # define internal_function /* empty */
186 #endif
188 /* Determine the return address. */
189 #define RETURN_ADDRESS(nr) \
190 __builtin_extract_return_addr (__builtin_return_address (nr))
192 /* When a reference to SYMBOL is encountered, the linker will emit a
193 warning message MSG. */
194 /* We want the .gnu.warning.SYMBOL section to be unallocated. */
195 #ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
196 # define __make_section_unallocated(section_string) \
197 asm (".section " section_string "\n\t.previous");
198 #elif defined HAVE_ASM_POPSECTION_DIRECTIVE
199 # define __make_section_unallocated(section_string) \
200 asm (".pushsection " section_string "\n\t.popsection");
201 #else
202 # define __make_section_unallocated(section_string)
203 #endif
205 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
206 section attributes on what looks like a comment to the assembler. */
207 #ifdef HAVE_SECTION_QUOTES
208 # define __sec_comment "\"\n\t#\""
209 #else
210 # define __sec_comment "\n\t#"
211 #endif
212 #define link_warning(symbol, msg) \
213 __make_section_unallocated (".gnu.warning." #symbol) \
214 static const char __evoke_link_warning_##symbol[] \
215 __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
216 = msg;
217 #define libc_freeres_ptr(decl) \
218 __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
219 decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
220 #define __libc_freeres_fn_section \
221 __attribute__ ((section ("__libc_freeres_fn")))
223 #define libc_freeres_fn(name) \
224 static void name (void) __attribute_used__ __libc_freeres_fn_section; \
225 text_set_element (__libc_subfreeres, name); \
226 static void name (void)
228 /* A canned warning for sysdeps/stub functions. */
229 #define stub_warning(name) \
230 __make_section_unallocated (".gnu.glibc-stub." #name) \
231 link_warning (name, #name " is not implemented and will always fail")
233 /* Warning for linking functions calling dlopen into static binaries. */
234 #ifdef SHARED
235 #define static_link_warning(name)
236 #else
237 #define static_link_warning(name) static_link_warning1(name)
238 #define static_link_warning1(name) \
239 link_warning(name, "Using '" #name "' in statically linked applications \
240 requires at runtime the shared libraries from the glibc version used \
241 for linking")
242 #endif
244 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
245 alias to ORIGINAL, when the assembler supports such declarations
246 (such as in ELF).
247 This is only necessary when defining something in assembly, or playing
248 funny alias games where the size should be other than what the compiler
249 thinks it is. */
250 #define declare_symbol_alias(symbol, original, type, size) \
251 declare_symbol_alias_1 (symbol, original, type, size)
252 #ifdef __ASSEMBLER__
253 # define declare_symbol_alias_1(symbol, original, type, size) \
254 strong_alias (original, symbol); \
255 .type C_SYMBOL_NAME (symbol), %##type; \
256 .size C_SYMBOL_NAME (symbol), size
257 #else /* Not __ASSEMBLER__. */
258 # define declare_symbol_alias_1(symbol, original, type, size) \
259 asm (".globl " __SYMBOL_PREFIX #symbol \
260 "\n\t" declare_symbol_alias_1_alias (symbol, original) \
261 "\n\t.type " __SYMBOL_PREFIX #symbol ", " \
262 "%" #type \
263 "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
264 # ifdef HAVE_ASM_SET_DIRECTIVE
265 # define declare_symbol_alias_1_alias(symbol, original) \
266 ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original
267 # else
268 # define declare_symbol_alias_1_alias(symbol, original) \
269 __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original
270 # endif /* HAVE_ASM_SET_DIRECTIVE */
271 #endif /* __ASSEMBLER__ */
278 /* Symbol set support macros. */
280 /* Make SYMBOL, which is in the text segment, an element of SET. */
281 #define text_set_element(set, symbol) _elf_set_element(set, symbol)
282 /* Make SYMBOL, which is in the data segment, an element of SET. */
283 #define data_set_element(set, symbol) _elf_set_element(set, symbol)
284 /* Make SYMBOL, which is in the bss segment, an element of SET. */
285 #define bss_set_element(set, symbol) _elf_set_element(set, symbol)
287 /* These are all done the same way in ELF.
288 There is a new section created for each set. */
289 #ifdef SHARED
290 /* When building a shared library, make the set section writable,
291 because it will need to be relocated at run time anyway. */
292 # define _elf_set_element(set, symbol) \
293 static const void *__elf_set_##set##_element_##symbol##__ \
294 __attribute__ ((used, section (#set))) = &(symbol)
295 #else
296 # define _elf_set_element(set, symbol) \
297 static const void *const __elf_set_##set##_element_##symbol##__ \
298 __attribute__ ((used, section (#set))) = &(symbol)
299 #endif
301 /* Define SET as a symbol set. This may be required (it is in a.out) to
302 be able to use the set's contents. */
303 #define symbol_set_define(set) symbol_set_declare(set)
305 /* Declare SET for use in this module, if defined in another module.
306 In a shared library, this is always local to that shared object.
307 For static linking, the set might be wholly absent and so we use
308 weak references. */
309 #define symbol_set_declare(set) \
310 extern char const __start_##set[] __symbol_set_attribute; \
311 extern char const __stop_##set[] __symbol_set_attribute;
312 #ifdef SHARED
313 # define __symbol_set_attribute attribute_hidden
314 #else
315 # define __symbol_set_attribute __attribute__ ((weak))
316 #endif
318 /* Return a pointer (void *const *) to the first element of SET. */
319 #define symbol_set_first_element(set) ((void *const *) (&__start_##set))
321 /* Return true iff PTR (a void *const *) has been incremented
322 past the last element in SET. */
323 #define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
325 #ifdef SHARED
326 # define symbol_version(real, name, version) \
327 _symbol_version(real, name, version)
328 # define default_symbol_version(real, name, version) \
329 _default_symbol_version(real, name, version)
330 # ifdef __ASSEMBLER__
331 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
332 # define _symbol_version(real, name, version) \
333 .symver real, name##@##version ASM_LINE_SEP \
334 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version)
335 # define _default_symbol_version(real, name, version) \
336 .symver real, name##@##@##version ASM_LINE_SEP \
337 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version)
338 # else
339 # define _symbol_version(real, name, version) \
340 .symver real, name##@##version
341 # define _default_symbol_version(real, name, version) \
342 .symver real, name##@##@##version
343 # endif
344 # else
345 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
346 # define _symbol_version(real, name, version) \
347 __asm__ (".symver " #real "," #name "@" #version "\n\t" \
348 ".symver ." #real ",." #name "@" #version)
349 # define _default_symbol_version(real, name, version) \
350 __asm__ (".symver " #real "," #name "@@" #version "\n\t" \
351 ".symver ." #real ",." #name "@@" #version)
352 # else
353 # define _symbol_version(real, name, version) \
354 __asm__ (".symver " #real "," #name "@" #version)
355 # define _default_symbol_version(real, name, version) \
356 __asm__ (".symver " #real "," #name "@@" #version)
357 # endif
358 # endif
359 #else
360 # define symbol_version(real, name, version)
361 # define default_symbol_version(real, name, version) \
362 strong_alias(real, name)
363 #endif
365 #if defined SHARED || defined LIBC_NONSHARED
366 # define attribute_hidden __attribute__ ((visibility ("hidden")))
367 #else
368 # define attribute_hidden
369 #endif
371 #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
373 #define attribute_relro __attribute__ ((section (".data.rel.ro")))
375 /* Handling on non-exported internal names. We have to do this only
376 for shared code. */
377 #ifdef SHARED
378 # define INTUSE(name) name##_internal
379 # define INTDEF(name) strong_alias (name, name##_internal)
380 # define INTVARDEF(name) \
381 _INTVARDEF (name, name##_internal)
382 # define _INTVARDEF(name, aliasname) \
383 extern __typeof (name) aliasname __attribute__ ((alias (#name), \
384 visibility ("hidden")));
385 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
386 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
387 #else
388 # define INTUSE(name) name
389 # define INTDEF(name)
390 # define INTVARDEF(name)
391 # define INTDEF2(name, newname)
392 # define INTVARDEF2(name, newname)
393 #endif
395 /* The following macros are used for PLT bypassing within libc.so
396 (and if needed other libraries similarly).
397 First of all, you need to have the function prototyped somewhere,
398 say in foo/foo.h:
400 int foo (int __bar);
402 If calls to foo within libc.so should always go to foo defined in libc.so,
403 then in include/foo.h you add:
405 libc_hidden_proto (foo)
407 line and after the foo function definition:
409 int foo (int __bar)
411 return __bar;
413 libc_hidden_def (foo)
417 int foo (int __bar)
419 return __bar;
421 libc_hidden_weak (foo)
423 Similarly for global data. If references to foo within libc.so should
424 always go to foo defined in libc.so, then in include/foo.h you add:
426 libc_hidden_proto (foo)
428 line and after foo's definition:
430 int foo = INITIAL_FOO_VALUE;
431 libc_hidden_data_def (foo)
435 int foo = INITIAL_FOO_VALUE;
436 libc_hidden_data_weak (foo)
438 If foo is normally just an alias (strong or weak) to some other function,
439 you should use the normal strong_alias first, then add libc_hidden_def
440 or libc_hidden_weak:
442 int baz (int __bar)
444 return __bar;
446 strong_alias (baz, foo)
447 libc_hidden_weak (foo)
449 If the function should be internal to multiple objects, say ld.so and
450 libc.so, the best way is to use:
452 #if !defined NOT_IN_libc || defined IS_IN_rtld
453 hidden_proto (foo)
454 #endif
456 in include/foo.h and the normal macros at all function definitions
457 depending on what DSO they belong to.
459 If versioned_symbol macro is used to define foo,
460 libc_hidden_ver macro should be used, as in:
462 int __real_foo (int __bar)
464 return __bar;
466 versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
467 libc_hidden_ver (__real_foo, foo) */
469 #if defined SHARED && !defined NO_HIDDEN
470 # ifndef __ASSEMBLER__
471 # define __hidden_proto_hiddenattr(attrs...) \
472 __attribute__ ((visibility ("hidden"), ##attrs))
473 # define hidden_proto(name, attrs...) \
474 __hidden_proto (name, __GI_##name, ##attrs)
475 # define __hidden_proto(name, internal, attrs...) \
476 extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
477 __hidden_proto_hiddenattr (attrs);
478 # define __hidden_asmname(name) \
479 __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
480 # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
481 # define __hidden_asmname2(prefix, name) #prefix name
482 # define __hidden_ver1(local, internal, name) \
483 extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
484 extern __typeof (name) __EI_##name \
485 __attribute__((alias (__hidden_asmname (#local))))
486 # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
487 # define hidden_data_ver(local, name) hidden_ver(local, name)
488 # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
489 # define hidden_data_def(name) hidden_def(name)
490 # define hidden_weak(name) \
491 __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
492 # define hidden_data_weak(name) hidden_weak(name)
493 # define hidden_nolink(name, lib, version) \
494 __hidden_nolink1 (__GI_##name, __EI_##name, name, VERSION_##lib##_##version)
495 # define __hidden_nolink1(local, internal, name, version) \
496 __hidden_nolink2 (local, internal, name, version)
497 # define __hidden_nolink2(local, internal, name, version) \
498 extern __typeof (name) internal __attribute__ ((alias (#local))); \
499 __hidden_nolink3 (local, internal, #name "@" #version)
500 # define __hidden_nolink3(local, internal, vername) \
501 __asm__ (".symver " #internal ", " vername);
502 # else
503 /* For assembly, we need to do the opposite of what we do in C:
504 in assembly gcc __REDIRECT stuff is not in place, so functions
505 are defined by its normal name and we need to create the
506 __GI_* alias to it, in C __REDIRECT causes the function definition
507 to use __GI_* name and we need to add alias to the real name.
508 There is no reason to use hidden_weak over hidden_def in assembly,
509 but we provide it for consistency with the C usage.
510 hidden_proto doesn't make sense for assembly but the equivalent
511 is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
512 # define hidden_def(name) strong_alias (name, __GI_##name)
513 # define hidden_weak(name) hidden_def (name)
514 # define hidden_ver(local, name) strong_alias (local, __GI_##name)
515 # define hidden_data_def(name) strong_data_alias (name, __GI_##name)
516 # define hidden_data_weak(name) hidden_data_def (name)
517 # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
518 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
519 # define HIDDEN_JUMPTARGET(name) .__GI_##name
520 # else
521 # define HIDDEN_JUMPTARGET(name) __GI_##name
522 # endif
523 # endif
524 #else
525 # ifndef __ASSEMBLER__
526 # define hidden_proto(name, attrs...)
527 # else
528 # define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
529 # endif /* Not __ASSEMBLER__ */
530 # define hidden_weak(name)
531 # define hidden_def(name)
532 # define hidden_ver(local, name)
533 # define hidden_data_weak(name)
534 # define hidden_data_def(name)
535 # define hidden_data_ver(local, name)
536 # define hidden_nolink(name, lib, version)
537 #endif
539 #if !defined NOT_IN_libc
540 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
541 # define libc_hidden_def(name) hidden_def (name)
542 # define libc_hidden_weak(name) hidden_weak (name)
543 # ifdef LINK_OBSOLETE_RPC
544 /* libc_hidden_nolink_sunrpc should only get used in sunrpc code. */
545 # define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
546 # else
547 # define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
548 # endif
549 # define libc_hidden_ver(local, name) hidden_ver (local, name)
550 # define libc_hidden_data_def(name) hidden_data_def (name)
551 # define libc_hidden_data_weak(name) hidden_data_weak (name)
552 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
553 #else
554 # define libc_hidden_proto(name, attrs...)
555 # define libc_hidden_def(name)
556 # define libc_hidden_weak(name)
557 # define libc_hidden_ver(local, name)
558 # define libc_hidden_data_def(name)
559 # define libc_hidden_data_weak(name)
560 # define libc_hidden_data_ver(local, name)
561 #endif
563 #if defined NOT_IN_libc && defined IS_IN_rtld
564 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
565 # define rtld_hidden_def(name) hidden_def (name)
566 # define rtld_hidden_weak(name) hidden_weak (name)
567 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
568 # define rtld_hidden_data_def(name) hidden_data_def (name)
569 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
570 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
571 #else
572 # define rtld_hidden_proto(name, attrs...)
573 # define rtld_hidden_def(name)
574 # define rtld_hidden_weak(name)
575 # define rtld_hidden_ver(local, name)
576 # define rtld_hidden_data_def(name)
577 # define rtld_hidden_data_weak(name)
578 # define rtld_hidden_data_ver(local, name)
579 #endif
581 #if defined NOT_IN_libc && defined IS_IN_libm
582 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
583 # define libm_hidden_def(name) hidden_def (name)
584 # define libm_hidden_weak(name) hidden_weak (name)
585 # define libm_hidden_ver(local, name) hidden_ver (local, name)
586 # define libm_hidden_data_def(name) hidden_data_def (name)
587 # define libm_hidden_data_weak(name) hidden_data_weak (name)
588 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
589 #else
590 # define libm_hidden_proto(name, attrs...)
591 # define libm_hidden_def(name)
592 # define libm_hidden_weak(name)
593 # define libm_hidden_ver(local, name)
594 # define libm_hidden_data_def(name)
595 # define libm_hidden_data_weak(name)
596 # define libm_hidden_data_ver(local, name)
597 #endif
599 #if defined NOT_IN_libc && defined IS_IN_libresolv
600 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
601 # define libresolv_hidden_def(name) hidden_def (name)
602 # define libresolv_hidden_weak(name) hidden_weak (name)
603 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
604 # define libresolv_hidden_data_def(name) hidden_data_def (name)
605 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
606 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
607 #else
608 # define libresolv_hidden_proto(name, attrs...)
609 # define libresolv_hidden_def(name)
610 # define libresolv_hidden_weak(name)
611 # define libresolv_hidden_ver(local, name)
612 # define libresolv_hidden_data_def(name)
613 # define libresolv_hidden_data_weak(name)
614 # define libresolv_hidden_data_ver(local, name)
615 #endif
617 #if defined NOT_IN_libc && defined IS_IN_librt
618 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
619 # define librt_hidden_def(name) hidden_def (name)
620 # define librt_hidden_weak(name) hidden_weak (name)
621 # define librt_hidden_ver(local, name) hidden_ver (local, name)
622 # define librt_hidden_data_def(name) hidden_data_def (name)
623 # define librt_hidden_data_weak(name) hidden_data_weak (name)
624 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
625 #else
626 # define librt_hidden_proto(name, attrs...)
627 # define librt_hidden_def(name)
628 # define librt_hidden_weak(name)
629 # define librt_hidden_ver(local, name)
630 # define librt_hidden_data_def(name)
631 # define librt_hidden_data_weak(name)
632 # define librt_hidden_data_ver(local, name)
633 #endif
635 #if defined NOT_IN_libc && defined IS_IN_libdl
636 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
637 # define libdl_hidden_def(name) hidden_def (name)
638 # define libdl_hidden_weak(name) hidden_weak (name)
639 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
640 # define libdl_hidden_data_def(name) hidden_data_def (name)
641 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
642 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
643 #else
644 # define libdl_hidden_proto(name, attrs...)
645 # define libdl_hidden_def(name)
646 # define libdl_hidden_weak(name)
647 # define libdl_hidden_ver(local, name)
648 # define libdl_hidden_data_def(name)
649 # define libdl_hidden_data_weak(name)
650 # define libdl_hidden_data_ver(local, name)
651 #endif
653 #if defined NOT_IN_libc && defined IS_IN_libnss_files
654 # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
655 # define libnss_files_hidden_def(name) hidden_def (name)
656 # define libnss_files_hidden_weak(name) hidden_weak (name)
657 # define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
658 # define libnss_files_hidden_data_def(name) hidden_data_def (name)
659 # define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
660 # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
661 #else
662 # define libnss_files_hidden_proto(name, attrs...)
663 # define libnss_files_hidden_def(name)
664 # define libnss_files_hidden_weak(name)
665 # define libnss_files_hidden_ver(local, name)
666 # define libnss_files_hidden_data_def(name)
667 # define libnss_files_hidden_data_weak(name)
668 # define libnss_files_hidden_data_ver(local, name)
669 #endif
671 #if defined NOT_IN_libc && defined IS_IN_libnsl
672 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
673 # define libnsl_hidden_def(name) hidden_def (name)
674 # define libnsl_hidden_weak(name) hidden_weak (name)
675 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
676 # define libnsl_hidden_data_def(name) hidden_data_def (name)
677 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
678 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
679 #else
680 # define libnsl_hidden_proto(name, attrs...)
681 # define libnsl_hidden_def(name)
682 # define libnsl_hidden_weak(name)
683 # define libnsl_hidden_ver(local, name)
684 # define libnsl_hidden_data_def(name)
685 # define libnsl_hidden_data_weak(name)
686 # define libnsl_hidden_data_ver(local, name)
687 #endif
689 #if defined NOT_IN_libc && defined IS_IN_libnss_nisplus
690 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
691 # define libnss_nisplus_hidden_def(name) hidden_def (name)
692 # define libnss_nisplus_hidden_weak(name) hidden_weak (name)
693 # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
694 # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
695 # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
696 # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
697 #else
698 # define libnss_nisplus_hidden_proto(name, attrs...)
699 # define libnss_nisplus_hidden_def(name)
700 # define libnss_nisplus_hidden_weak(name)
701 # define libnss_nisplus_hidden_ver(local, name)
702 # define libnss_nisplus_hidden_data_def(name)
703 # define libnss_nisplus_hidden_data_weak(name)
704 # define libnss_nisplus_hidden_data_ver(local, name)
705 #endif
707 #define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
708 #define libc_hidden_builtin_def(name) libc_hidden_def (name)
709 #define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
710 #define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
711 #ifdef __ASSEMBLER__
712 # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
713 #endif
715 #if defined NOT_IN_libc && defined IS_IN_libutil
716 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
717 # define libutil_hidden_def(name) hidden_def (name)
718 # define libutil_hidden_weak(name) hidden_weak (name)
719 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
720 # define libutil_hidden_data_def(name) hidden_data_def (name)
721 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
722 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
723 #else
724 # define libutil_hidden_proto(name, attrs...)
725 # define libutil_hidden_def(name)
726 # define libutil_hidden_weak(name)
727 # define libutil_hidden_ver(local, name)
728 # define libutil_hidden_data_def(name)
729 # define libutil_hidden_data_weak(name)
730 # define libutil_hidden_data_ver(local, name)
731 #endif
733 /* Get some dirty hacks. */
734 #include <symbol-hacks.h>
736 /* Move compatibility symbols out of the way by placing them all in a
737 special section. */
738 #ifndef __ASSEMBLER__
739 # define attribute_compat_text_section \
740 __attribute__ ((section (".text.compat")))
741 # define attribute_compat_data_section \
742 __attribute__ ((section (".data.compat")))
743 #else
744 # define compat_text_section .section ".text.compat", "ax";
745 # define compat_data_section .section ".data.compat", "aw";
746 #endif
748 /* Marker used for indirection function symbols. */
749 #define libc_ifunc(name, expr) \
750 extern void *name##_ifunc (void) __asm__ (#name); \
751 void *name##_ifunc (void) \
753 INIT_ARCH (); \
754 __typeof (name) *res = expr; \
755 return res; \
757 __asm__ (".type " #name ", %gnu_indirect_function");
759 /* The body of the function is supposed to use __get_cpu_features
760 which will, if necessary, initialize the data first. */
761 #define libm_ifunc(name, expr) \
762 extern void *name##_ifunc (void) __asm__ (#name); \
763 void *name##_ifunc (void) \
765 __typeof (name) *res = expr; \
766 return res; \
768 __asm__ (".type " #name ", %gnu_indirect_function");
770 #ifdef HAVE_ASM_SET_DIRECTIVE
771 # define libc_ifunc_hidden_def1(local, name) \
772 __asm__ (".globl " #local "\n\t" \
773 ".hidden " #local "\n\t" \
774 ".set " #local ", " #name);
775 #else
776 # define libc_ifunc_hidden_def1(local, name) \
777 __asm__ (".globl " #local "\n\t" \
778 ".hidden " #local "\n\t" \
779 #local " = " #name);
780 #endif
782 #define libc_ifunc_hidden_def(name) \
783 libc_ifunc_hidden_def1 (__GI_##name, name)
785 /* Add the compiler optimization to inhibit loop transformation to library
786 calls. This is used to avoid recursive calls in memset and memmove
787 default implementations. */
788 #ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
789 # define inhibit_loop_to_libcall \
790 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
791 #else
792 # define inhibit_loop_to_libcall
793 #endif
795 #endif /* libc-symbols.h */