bf77fda8d66846743054779aecf74b199325b138
[platform/upstream/glibc.git] / include / libc-symbols.h
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-1998,2000,2001,2002 Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5
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.
10
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.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #ifndef _LIBC_SYMBOLS_H
22 #define _LIBC_SYMBOLS_H 1
23
24 /* This file's macros are included implicitly in the compilation of every
25    file in the C library by -imacros.
26
27    We include config.h which is generated by configure.
28    It should define for us the following symbols:
29
30    * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
31    * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
32    * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
33      or leave it undefined if there is no .type directive.
34    * HAVE_GNU_LD if using GNU ld, with support for weak symbols in a.out,
35    and for symbol set and warning messages extensions in a.out and ELF.
36    * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
37    * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
38    * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
39
40    */
41
42 /* This is defined for the compilation of all C library code.  features.h
43    tests this to avoid inclusion of stubs.h while compiling the library,
44    before stubs.h has been generated.  Some library code that is shared
45    with other packages also tests this symbol to see if it is being
46    compiled as part of the C library.  We must define this before including
47    config.h, because it makes some definitions conditional on whether libc
48    itself is being compiled, or just some generator program.  */
49 #define _LIBC   1
50
51 /* Enable declarations of GNU extensions, since we are compiling them.  */
52 #define _GNU_SOURCE     1
53 /* And we also need the data for the reentrant functions.  */
54 #define _REENTRANT      1
55
56 #include <config.h>
57
58 /* The symbols in all the user (non-_) macros are C symbols.
59    HAVE_GNU_LD without HAVE_ELF implies a.out.  */
60
61 #if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
62 # define HAVE_WEAK_SYMBOLS
63 #endif
64
65 #ifndef __SYMBOL_PREFIX
66 # ifdef NO_UNDERSCORES
67 #  define __SYMBOL_PREFIX
68 # else
69 #  define __SYMBOL_PREFIX "_"
70 # endif
71 #endif
72
73 #ifndef C_SYMBOL_NAME
74 # ifdef NO_UNDERSCORES
75 #  define C_SYMBOL_NAME(name) name
76 # else
77 #  define C_SYMBOL_NAME(name) _##name
78 # endif
79 #endif
80
81 #ifndef ASM_LINE_SEP
82 # define ASM_LINE_SEP ;
83 #endif
84
85 #ifndef C_SYMBOL_DOT_NAME
86 # define C_SYMBOL_DOT_NAME(name) .##name
87 #endif
88
89 #ifndef __ASSEMBLER__
90 /* GCC understands weak symbols and aliases; use its interface where
91    possible, instead of embedded assembly language.  */
92
93 /* Define ALIASNAME as a strong alias for NAME.  */
94 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
95 # define _strong_alias(name, aliasname) \
96   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
97
98 /* This comes between the return type and function name in
99    a function definition to make that definition weak.  */
100 # define weak_function __attribute__ ((weak))
101 # define weak_const_function __attribute__ ((weak, __const__))
102
103 # ifdef HAVE_WEAK_SYMBOLS
104
105 /* Define ALIASNAME as a weak alias for NAME.
106    If weak aliases are not available, this defines a strong alias.  */
107 #  define weak_alias(name, aliasname) _weak_alias (name, aliasname)
108 #  define _weak_alias(name, aliasname) \
109   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
110
111 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
112 #  define weak_extern(symbol) _weak_extern (symbol)
113 #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
114 #   define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
115 #  else
116 #   define _weak_extern(symbol)    asm (".weak " __SYMBOL_PREFIX #symbol);
117 #  endif
118
119 # else
120
121 #  define weak_alias(name, aliasname) strong_alias(name, aliasname)
122 #  define weak_extern(symbol) /* Nothing. */
123
124 # endif
125
126 #else /* __ASSEMBLER__ */
127
128 # ifdef HAVE_ASM_SET_DIRECTIVE
129 #  define strong_alias(original, alias)         \
130   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP       \
131   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
132 # else
133 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
134 #   define strong_alias(original, alias)        \
135   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP       \
136   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
137   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP   \
138   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
139 #  else
140 #   define strong_alias(original, alias)        \
141   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP       \
142   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
143 #  endif
144 # endif
145
146 # ifdef HAVE_WEAK_SYMBOLS
147 #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
148 #   define weak_alias(original, alias)  \
149   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
150 #   define weak_extern(symbol)  \
151   .weakext C_SYMBOL_NAME (symbol)
152
153 #  else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
154
155 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
156 #    define weak_alias(original, alias) \
157   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP                      \
158   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
159   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP   \
160   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
161 #   else
162 #    define weak_alias(original, alias) \
163   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP      \
164   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
165 #   endif
166
167 #   define weak_extern(symbol)  \
168   .weak C_SYMBOL_NAME (symbol)
169
170 #  endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
171
172 # else /* ! HAVE_WEAK_SYMBOLS */
173
174 #  define weak_alias(original, alias) strong_alias(original, alias)
175 #  define weak_extern(symbol) /* Nothing */
176 # endif /* ! HAVE_WEAK_SYMBOLS */
177
178 #endif /* __ASSEMBLER__ */
179
180 /* On some platforms we can make internal function calls (i.e., calls of
181    functions not exported) a bit faster by using a different calling
182    convention.  */
183 #ifndef internal_function
184 # define internal_function      /* empty */
185 #endif
186
187 /* Prepare for the case that `__builtin_expect' is not available.  */
188 #ifndef HAVE_BUILTIN_EXPECT
189 # define __builtin_expect(expr, val) (expr)
190 #endif
191
192 /* Determine the return address.  */
193 #define RETURN_ADDRESS(nr) \
194   __builtin_extract_return_addr (__builtin_return_address (nr))
195
196 /* When a reference to SYMBOL is encountered, the linker will emit a
197    warning message MSG.  */
198 #ifdef HAVE_GNU_LD
199 # ifdef HAVE_ELF
200
201 /* We want the .gnu.warning.SYMBOL section to be unallocated.  */
202 #  ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
203 #   define __make_section_unallocated(section_string)   \
204   asm (".section " section_string "\n\t.previous");
205 #  elif defined HAVE_ASM_POPSECTION_DIRECTIVE
206 #   define __make_section_unallocated(section_string)   \
207   asm (".pushsection " section_string "\n\t.popsection");
208 #  else
209 #   define __make_section_unallocated(section_string)
210 #  endif
211
212 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
213    section attributes on what looks like a comment to the assembler.  */
214 #  ifdef HAVE_SECTION_QUOTES
215 #   define link_warning(symbol, msg) \
216   __make_section_unallocated (".gnu.warning." #symbol) \
217   static const char __evoke_link_warning_##symbol[]     \
218     __attribute__ ((unused, section (".gnu.warning." #symbol "\"\n\t#\""))) \
219     = msg;
220 #  else
221 #   define link_warning(symbol, msg) \
222   __make_section_unallocated (".gnu.warning." #symbol) \
223   static const char __evoke_link_warning_##symbol[]     \
224     __attribute__ ((unused, section (".gnu.warning." #symbol "\n\t#"))) = msg;
225 #  endif
226 # else /* Not ELF: a.out */
227 #  ifdef HAVE_XCOFF
228 /* XCOFF does not support .stabs.
229    The native aix linker will remove the .stab and .stabstr sections
230    The gnu linker will have a fatal error if there is a relocation for
231    symbol in the .stab section.  Silently disable this macro.  */
232 #   define link_warning(symbol, msg)
233 #  else
234 #   define link_warning(symbol, msg)            \
235      asm (".stabs \"" msg "\",30,0,0,0\n\t"     \
236           ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
237 #  endif /* XCOFF */
238 # endif
239 #else
240 /* We will never be heard; they will all die horribly.  */
241 # define link_warning(symbol, msg)
242 #endif
243
244 /* A canned warning for sysdeps/stub functions.  */
245 #define stub_warning(name) \
246   link_warning (name, \
247                 "warning: " #name " is not implemented and will always fail")
248
249
250 /* Declare SYMBOL to be TYPE (`function' or `object') and of SIZE bytes,
251    when the assembler supports such declarations (such as in ELF).
252    This is only necessary when defining something in assembly, or playing
253    funny alias games where the size should be other than what the compiler
254    thinks it is.  */
255 #define declare_symbol(symbol, type, size) \
256   declare_symbol_1 (symbol, type, size)
257 #ifdef ASM_TYPE_DIRECTIVE_PREFIX
258 # ifdef __ASSEMBLER__
259 #  define declare_symbol_1(symbol, type, size) \
260     .type C_SYMBOL_NAME (symbol), \
261           declare_symbol_1_paste (ASM_TYPE_DIRECTIVE_PREFIX, type), size
262 #  define declare_symbol_1_paste(a, b)  declare_symbol_1_paste_1 (a,b)
263 #  define declare_symbol_1_paste_1(a,b) a##b
264 # else /* Not __ASSEMBLER__.  */
265 #  define declare_symbol_1(symbol, type, size) \
266     asm (".type " __SYMBOL_PREFIX #symbol \
267          declare_symbol_1_stringify (ASM_TYPE_DIRECTIVE_PREFIX) #type \
268          "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
269 #  define declare_symbol_1_stringify(x) declare_symbol_1_stringify_1 (x)
270 #  define declare_symbol_1_stringify_1(x) #x
271 # endif /* __ASSEMBLER__ */
272 #else
273 # define declare_symbol_1(symbol, type, size) /* Nothing.  */
274 #endif
275
276
277 /*
278 \f
279 */
280
281 #ifdef HAVE_GNU_LD
282
283 /* Symbol set support macros.  */
284
285 # ifdef HAVE_ELF
286
287 /* Make SYMBOL, which is in the text segment, an element of SET.  */
288 #  define text_set_element(set, symbol) _elf_set_element(set, symbol)
289 /* Make SYMBOL, which is in the data segment, an element of SET.  */
290 #  define data_set_element(set, symbol) _elf_set_element(set, symbol)
291 /* Make SYMBOL, which is in the bss segment, an element of SET.  */
292 #  define bss_set_element(set, symbol)  _elf_set_element(set, symbol)
293
294 /* These are all done the same way in ELF.
295    There is a new section created for each set.  */
296 #  ifdef SHARED
297 /* When building a shared library, make the set section writable,
298    because it will need to be relocated at run time anyway.  */
299 #   define _elf_set_element(set, symbol) \
300   static const void *__elf_set_##set##_element_##symbol##__ \
301     __attribute__ ((unused, section (#set))) = &(symbol)
302 #  else
303 #   define _elf_set_element(set, symbol) \
304   static const void *const __elf_set_##set##_element_##symbol##__ \
305     __attribute__ ((unused, section (#set))) = &(symbol)
306 #  endif
307
308 /* Define SET as a symbol set.  This may be required (it is in a.out) to
309    be able to use the set's contents.  */
310 #  define symbol_set_define(set)        symbol_set_declare(set)
311
312 /* Declare SET for use in this module, if defined in another module.  */
313 #  define symbol_set_declare(set) \
314   extern void *const __start_##set __attribute__ ((__weak__));          \
315   extern void *const __stop_##set __attribute__ ((__weak__));           \
316   weak_extern (__start_##set) weak_extern (__stop_##set)
317
318 /* Return a pointer (void *const *) to the first element of SET.  */
319 #  define symbol_set_first_element(set) (&__start_##set)
320
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) >= &__stop_##set)
324
325 # else  /* Not ELF: a.out.  */
326
327 #  ifdef HAVE_XCOFF
328 /* XCOFF does not support .stabs.
329    The native aix linker will remove the .stab and .stabstr sections
330    The gnu linker will have a fatal error if there is a relocation for
331    symbol in the .stab section.  Silently disable these macros.  */
332 #   define text_set_element(set, symbol)
333 #   define data_set_element(set, symbol)
334 #   define bss_set_element(set, symbol)
335 #  else
336 #   define text_set_element(set, symbol)        \
337     asm (".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
338 #   define data_set_element(set, symbol)        \
339     asm (".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
340 #   define bss_set_element(set, symbol) ?error Must use initialized data.
341 #  endif /* XCOFF */
342 #  define symbol_set_define(set)        void *const (set)[1];
343 #  define symbol_set_declare(set)       extern void *const (set)[1];
344
345 #  define symbol_set_first_element(set) &(set)[1]
346 #  define symbol_set_end_p(set, ptr)    (*(ptr) == 0)
347
348 # endif /* ELF.  */
349 #else
350 /* We cannot do anything in generial.  */
351 # define text_set_element(set, symbol) asm ("")
352 # define data_set_element(set, symbol) asm ("")
353 # define bss_set_element(set, symbol) asm ("")
354 # define symbol_set_define(set)         void *const (set)[1];
355 # define symbol_set_declare(set)        extern void *const (set)[1];
356
357 # define symbol_set_first_element(set)  &(set)[1]
358 # define symbol_set_end_p(set, ptr)     (*(ptr) == 0)
359 #endif  /* Have GNU ld.  */
360
361 #if DO_VERSIONING
362 # define symbol_version(real, name, version) \
363      _symbol_version(real, name, version)
364 # define default_symbol_version(real, name, version) \
365      _default_symbol_version(real, name, version)
366 # ifdef __ASSEMBLER__
367 #  define _symbol_version(real, name, version) \
368      .symver real, name##@##version
369 #  define _default_symbol_version(real, name, version) \
370      .symver real, name##@##@##version
371 # else
372 #  define _symbol_version(real, name, version) \
373      __asm__ (".symver " #real "," #name "@" #version)
374 #  define _default_symbol_version(real, name, version) \
375      __asm__ (".symver " #real "," #name "@@" #version)
376 # endif
377 #else
378 # define symbol_version(real, name, version)
379 # define default_symbol_version(real, name, version) \
380   strong_alias(real, name)
381 #endif
382
383 #if defined HAVE_VISIBILITY_ATTRIBUTE && defined SHARED
384 # define attribute_hidden __attribute__ ((visibility ("hidden")))
385 #else
386 # define attribute_hidden
387 #endif
388
389 /* Handling on non-exported internal names.  We have to do this only
390    for shared code.  */
391 #ifdef SHARED
392 # define INTUSE(name) name##_internal
393 # define INTDEF(name) strong_alias (name, name##_internal)
394 # define INTVARDEF(name) \
395   _INTVARDEF (name, name##_internal)
396 # if defined HAVE_VISIBILITY_ATTRIBUTE
397 #  define _INTVARDEF(name, aliasname) \
398   extern __typeof (name) aliasname __attribute__ ((alias (#name), \
399                                                    visibility ("hidden")));
400 # else
401 #  define _INTVARDEF(name, aliasname) \
402   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
403 # endif
404 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
405 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
406 #else
407 # define INTUSE(name) name
408 # define INTDEF(name)
409 # define INTVARDEF(name)
410 # define INTDEF2(name, newname)
411 # define INTVARDEF2(name, newname)
412 #endif
413
414 /* The following macros are used for PLT bypassing within libc.so
415    (and if needed other libraries similarly).
416    First of all, you need to have the function prototyped somewhere,
417    say in foo/foo.h:
418
419    int foo (int __bar);
420
421    If calls to foo within libc.so should always go to foo defined in libc.so,
422    then in include/foo.h you add:
423
424    libc_hidden_proto (foo)
425
426    line and after the foo function definition:
427
428    int foo (int __bar)
429    {
430      return __bar;
431    }
432    libc_hidden_def (foo)
433
434    or
435
436    int foo (int __bar)
437    {
438      return __bar;
439    }
440    libc_hidden_weak (foo)
441
442    If foo is normally just an alias (strong or weak) of some other function,
443    you should use the normal strong_alias first, then add libc_hidden_def
444    or libc_hidden_weak:
445
446    int baz (int __bar)
447    {
448      return __bar;
449    }
450    strong_alias (baz, foo)
451    libc_hidden_weak (foo)
452
453    If the function should be internal to multiple objects, say ld.so and
454    libc.so, the best way is to use:
455
456    #if !defined NOT_IN_libc || defined IS_IN_rtld
457    hidden_proto (foo)
458    #endif
459
460    in include/foo.h and the normal macros at all function definitions
461    depending on what DSO they belong to.
462
463    If versioned_symbol macro is used to define foo,
464    libc_hidden_ver macro should be used, as in:
465
466    int __real_foo (int __bar)
467    {
468      return __bar;
469    }
470    versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
471    libc_hidden_ver (__real_foo, foo)  */
472
473 #if defined SHARED && defined DO_VERSIONING \
474     && !defined HAVE_BROKEN_ALIAS_ATTRIBUTE
475 # ifndef __ASSEMBLER__
476 #  ifdef HAVE_BROKEN_VISIBILITY_ATTRIBUTE
477 #   define __hidden_proto_hiddenattr
478 #  else
479 #   define __hidden_proto_hiddenattr attribute_hidden
480 #  endif
481 #  define hidden_proto(name) __hidden_proto (name, __GI_##name)
482 #  define __hidden_proto(name, internal) \
483   extern __typeof (name) internal; \
484   extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
485   __hidden_proto_hiddenattr;
486 #  define __hidden_asmname(name) \
487   __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
488 #  define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
489 #  define __hidden_asmname2(prefix, name) #prefix name
490 #  ifdef HAVE_ASM_SET_DIRECTIVE
491 #   define __hidden_def1(original, alias)                       \
492   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP       \
493   .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
494 #  else
495 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
496 #    define __hidden_def1(original, alias)                      \
497   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP       \
498   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
499   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP   \
500   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
501 #   else
502 #    define __hidden_def1(original, alias)                      \
503   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP       \
504   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
505 #   endif
506 #  endif
507 #  define __hidden_def2(...) #__VA_ARGS__
508 #  define __hidden_def3(...) __hidden_def2 (__VA_ARGS__)
509 #  define hidden_def(name)                                      \
510   __asm__ (__hidden_def3 (__hidden_def1 (__GI_##name, name)));
511 #  define hidden_ver(local, name)                               \
512   __asm__ (__hidden_def3 (__hidden_def1 (local, __GI_##name)));
513 #  ifdef HAVE_WEAK_SYMBOLS
514 #   ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
515 #    define __hidden_weak1(original, alias)                     \
516   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
517 #   else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
518 #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
519 #     define __hidden_weak1(original, alias)                    \
520   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP                      \
521   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
522   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP   \
523   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
524 #    else
525 #     define __hidden_weak1(original, alias)                    \
526   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP                      \
527   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
528 #    endif
529 #   endif
530 #   define hidden_weak(name)                                    \
531   __asm__ (__hidden_def3 (__hidden_weak1 (__GI_##name, name)));
532 #  else
533 #   define hidden_weak(name) hidden_def (name)
534 #  endif
535 # else
536 /* For assembly, we need to do the opposite of what we do in C:
537    in assembly gcc __REDIRECT stuff is not in place, so functions
538    are defined by its normal name and we need to create the
539    __GI_* alias to it, in C __REDIRECT causes the function definition
540    to use __GI_* name and we need to add alias to the real name.
541    There is no reason to use hidden_weak over hidden_def in assembly,
542    but we provide it for consistency with the C usage.
543    hidden_proto doesn't make sense for assembly but the equivalent
544    is to call via the HIDDEN_JUMPTARGET macro einstead of JUMPTARGET.  */
545 #  define hidden_def(name)      strong_alias (name, __GI_##name)
546 #  define hidden_weak(name)     hidden_def (name)
547 #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
548 #  define HIDDEN_JUMPTARGET(name) __GI_##name
549 # endif
550 #else
551 # ifndef __ASSEMBLER__
552 #  define hidden_proto(name)
553 # else
554 #  define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
555 # endif /* Not  __ASSEMBLER__ */
556 # define hidden_weak(name)
557 # define hidden_def(name)
558 # define hidden_ver(local, name)
559 #endif
560
561 #if !defined NOT_IN_libc
562 # define libc_hidden_proto(name) hidden_proto (name)
563 # define libc_hidden_def(name) hidden_def (name)
564 # define libc_hidden_weak(name) hidden_weak (name)
565 # define libc_hidden_ver(local, name) hidden_ver (local, name)
566 #else
567 # define libc_hidden_proto(name)
568 # define libc_hidden_def(name)
569 # define libc_hidden_weak(name)
570 # define libc_hidden_ver(local, name)
571 #endif
572
573 #if defined NOT_IN_libc && defined IS_IN_rtld
574 # define rtld_hidden_proto(name) hidden_proto (name)
575 # define rtld_hidden_def(name) hidden_def (name)
576 # define rtld_hidden_weak(name) hidden_weak (name)
577 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
578 #else
579 # define rtld_hidden_proto(name)
580 # define rtld_hidden_def(name)
581 # define rtld_hidden_weak(name)
582 # define rtld_hidden_ver(local, name)
583 #endif
584
585 #if defined NOT_IN_libc && defined IS_IN_libm
586 # define libm_hidden_proto(name) hidden_proto (name)
587 # define libm_hidden_def(name) hidden_def (name)
588 # define libm_hidden_weak(name) hidden_weak (name)
589 # define libm_hidden_ver(local, name) hidden_ver (local, name)
590 #else
591 # define libm_hidden_proto(name)
592 # define libm_hidden_def(name)
593 # define libm_hidden_weak(name)
594 # define libm_hidden_ver(local, name)
595 #endif
596
597 #endif /* libc-symbols.h */