OSDN Git Service

openat*: use a static function with the different type and strong_alias_untyped
[uclinux-h8/uClibc.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-2003,2004,2005,2006
4         Free Software Foundation, Inc.
5    This file is part of the GNU C Library.
6
7    The GNU C Library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    The GNU C Library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with the GNU C Library; if not, write to the Free
19    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20    02111-1307 USA.  */
21
22 #ifndef _LIBC_SYMBOLS_H
23 #define _LIBC_SYMBOLS_H 1
24
25 /* This is defined for the compilation of all C library code.  features.h
26    tests this to avoid inclusion of stubs.h while compiling the library,
27    before stubs.h has been generated.  Some library code that is shared
28    with other packages also tests this symbol to see if it is being
29    compiled as part of the C library.  We must define this before including
30    config.h, because it makes some definitions conditional on whether libc
31    itself is being compiled, or just some generator program.  */
32 #define _LIBC   1
33
34
35 /* This file's macros are included implicitly in the compilation of every
36    file in the C library by -imacros.
37
38    We include uClibc_arch_features.h which is defined by arch devs.
39    It should define for us the following symbols:
40
41    * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
42    * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
43    * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
44      or leave it undefined if there is no .type directive.
45    * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
46    * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
47    * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
48
49    */
50
51 #include <bits/uClibc_arch_features.h>
52
53 /* Enable declarations of GNU extensions, since we are compiling them.  */
54 #define _GNU_SOURCE     1
55
56 /* Prepare for the case that `__builtin_expect' is not available.  */
57 #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
58 # define __builtin_expect(x, expected_value) (x)
59 #endif
60 #ifndef likely
61 # define likely(x)      __builtin_expect((!!(x)),1)
62 #endif
63 #ifndef unlikely
64 # define unlikely(x)    __builtin_expect((!!(x)),0)
65 #endif
66 #if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
67 # ifndef __cold
68 #  define __cold __attribute__ ((__cold__))
69 # endif
70 # ifndef __hot
71 #  define __hot __attribute__ ((__hot__))
72 # endif
73 #else
74 # ifndef __cold
75 #  define __cold
76 # endif
77 # ifndef __hot
78 #  define __hot
79 # endif
80 #endif
81 #ifndef __LINUX_COMPILER_H
82 # define __LINUX_COMPILER_H
83 #endif
84 #ifndef __cast__
85 # define __cast__(_to)
86 #endif
87
88 #if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
89 # define attribute_optimize(x) __attribute__ ((optimize(x)))
90 #else
91 # define attribute_optimize(x)
92 #endif
93
94 #define attribute_unused __attribute__ ((unused))
95
96 #if defined __GNUC__ || defined __ICC
97 # define attribute_noreturn __attribute__ ((__noreturn__))
98 #else
99 # define attribute_noreturn
100 #endif
101
102 #define libc_freeres_ptr(decl) \
103       __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
104   decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
105 #define __libc_freeres_fn_section \
106       __attribute__ ((section ("__libc_freeres_fn")))
107
108 #ifndef NOT_IN_libc
109 # define IS_IN_libc 1
110 #endif
111
112 /* Indirect stringification.  Doing two levels allows
113  * the parameter to be a macro itself.
114  */
115 #define __stringify_1(x)    #x
116 #define __stringify(x)      __stringify_1(x)
117
118 #ifdef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
119 # define HAVE_ASM_SET_DIRECTIVE
120 #else
121 # undef HAVE_ASM_SET_DIRECTIVE
122 #endif
123
124 #ifdef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
125 # define ASM_GLOBAL_DIRECTIVE __UCLIBC_ASM_GLOBAL_DIRECTIVE__
126 #else
127 # define ASM_GLOBAL_DIRECTIVE .global
128 #endif
129
130 #ifdef __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
131 # define HAVE_ASM_WEAK_DIRECTIVE
132 #else
133 # undef HAVE_ASM_WEAK_DIRECTIVE
134 #endif
135
136 #ifdef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
137 # define HAVE_ASM_WEAKEXT_DIRECTIVE
138 #else
139 # undef HAVE_ASM_WEAKEXT_DIRECTIVE
140 #endif
141
142 #ifdef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
143 # define HAVE_ASM_GLOBAL_DOT_NAME
144 #else
145 # undef HAVE_ASM_GLOBAL_DOT_NAME
146 #endif
147
148 #ifdef __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
149 # define HAVE_ASM_CFI_DIRECTIVES
150 #else
151 # undef HAVE_ASM_CFI_DIRECTIVES
152 #endif
153
154 #if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
155 # define HAVE_WEAK_SYMBOLS
156 #endif
157
158 #undef C_SYMBOL_NAME
159 #ifndef C_SYMBOL_NAME
160 # ifndef __UCLIBC_UNDERSCORES__
161 #  define C_SYMBOL_NAME(name) name
162 # else
163 #  define C_SYMBOL_NAME(name) _##name
164 # endif
165 #endif
166
167 #ifdef __UCLIBC_ASM_LINE_SEP__
168 # define ASM_LINE_SEP __UCLIBC_ASM_LINE_SEP__
169 #else
170 # define ASM_LINE_SEP ;
171 #endif
172
173 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
174 # ifndef C_SYMBOL_DOT_NAME
175 #  if defined __GNUC__ && defined __GNUC_MINOR__ \
176       && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
177 #   define C_SYMBOL_DOT_NAME(name) .name
178 #  else
179 #   define C_SYMBOL_DOT_NAME(name) .##name
180 #  endif
181 # endif
182 #endif
183
184 #ifndef __ASSEMBLER__
185 /* GCC understands weak symbols and aliases; use its interface where
186    possible, instead of embedded assembly language.  */
187
188 /* Define ALIASNAME as a strong alias for NAME.  */
189 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
190 # define _strong_alias(name, aliasname) \
191   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
192 /* Same, but does not check for type match. Use sparingly.
193    Example: strong_alias(stat,stat64) may fail, this one works: */
194 # define strong_alias_untyped(name, aliasname) \
195   _strong_alias_untyped(name, aliasname)
196 # define _strong_alias_untyped(name, aliasname) \
197   extern __typeof (aliasname) aliasname __attribute__ ((alias (#name)));
198
199 # ifdef HAVE_WEAK_SYMBOLS
200
201 /* This comes between the return type and function name in
202    a function definition to make that definition weak.  */
203 #  define weak_function __attribute__ ((weak))
204 #  define weak_const_function __attribute__ ((weak, __const__))
205
206 /* Define ALIASNAME as a weak alias for NAME.
207    If weak aliases are not available, this defines a strong alias.  */
208 #  define weak_alias(name, aliasname) _weak_alias (name, aliasname)
209 #  define _weak_alias(name, aliasname) \
210   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
211
212 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
213 #  define weak_extern(symbol) _weak_extern (weak symbol)
214 #  define _weak_extern(expr) _Pragma (#expr)
215
216 # else
217
218 #  define weak_function /* empty */
219 #  define weak_const_function __attribute__ ((__const__))
220
221 #  define weak_alias(name, aliasname) strong_alias(name, aliasname)
222 #  define weak_extern(symbol) /* Nothing. */
223
224 # endif
225
226 #else /* __ASSEMBLER__ */
227
228 # ifdef HAVE_ASM_SET_DIRECTIVE
229 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
230 #   define strong_alias(original, alias) \
231         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
232         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)    ASM_LINE_SEP \
233         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
234         .set    C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
235 #   define strong_data_alias(original, alias) \
236         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
237         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
238 #  else
239 #   define strong_alias(original, alias) \
240         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
241         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
242 #   define strong_data_alias(original, alias) strong_alias(original, alias)
243 #  endif
244 # else
245 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
246 #   define strong_alias(original, alias) \
247         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
248         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)          ASM_LINE_SEP \
249         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
250         C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
251 #   define strong_data_alias(original, alias) \
252         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
253         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
254 #  else
255 #   define strong_alias(original, alias) \
256         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
257         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
258 #   define strong_data_alias(original, alias) strong_alias(original, alias)
259 #  endif
260 # endif
261
262 # ifdef HAVE_WEAK_SYMBOLS
263 #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
264 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
265 #    define weak_alias(original, alias) \
266         .weakext C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)   ASM_LINE_SEP \
267         .weakext C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
268 #   else
269 #    define weak_alias(original, alias) \
270         .weakext C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
271 #   endif
272 #   define weak_extern(symbol) \
273         .weakext C_SYMBOL_NAME(symbol)
274
275 #  else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
276
277 #   ifdef HAVE_ASM_SET_DIRECTIVE
278 #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
279 #     define weak_alias(original, alias) \
280         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
281         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)    ASM_LINE_SEP \
282         .weak   C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
283         .set    C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
284 #    else
285 #     define weak_alias(original, alias) \
286         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
287         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
288 #    endif
289 #   else /* ! HAVE_ASM_SET_DIRECTIVE */
290 #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
291 #     define weak_alias(original, alias) \
292         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
293         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)          ASM_LINE_SEP \
294         .weak   C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
295         C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
296 #    else
297 #     define weak_alias(original, alias) \
298         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
299         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
300 #    endif
301 #   endif
302 #   define weak_extern(symbol) \
303         .weak   C_SYMBOL_NAME(symbol)
304
305 #  endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
306
307 # else /* ! HAVE_WEAK_SYMBOLS */
308
309 #  define weak_alias(original, alias) strong_alias(original, alias)
310 #  define weak_extern(symbol) /* Nothing */
311 # endif /* ! HAVE_WEAK_SYMBOLS */
312
313 #endif /* __ASSEMBLER__ */
314
315
316 /* On some platforms we can make internal function calls (i.e., calls of
317    functions not exported) a bit faster by using a different calling
318    convention.  */
319 #ifndef internal_function
320 # define internal_function      /* empty */
321 #endif
322
323
324 /* We want the .gnu.warning.SYMBOL section to be unallocated.  */
325 #define __make_section_unallocated(section_string)      \
326   __asm__ (".section " section_string "\n\t.previous");
327
328
329 /* Tacking on "\n#APP\n\t#" to the section name makes gcc put it's bogus
330    section attributes on what looks like a comment to the assembler.  */
331 #ifdef __sparc__ /* HAVE_SECTION_QUOTES */
332 # define __sec_comment "\"\n#APP\n\t#\""
333 #else
334 # define __sec_comment "\n#APP\n\t#"
335 #endif
336
337
338 /* When a reference to SYMBOL is encountered, the linker will emit a
339    warning message MSG.  */
340 #define link_warning(symbol, msg) \
341   __make_section_unallocated (".gnu.warning." #symbol) \
342   static const char __evoke_link_warning_##symbol[]     \
343     __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
344     = msg;
345
346 /* Handling on non-exported internal names.  We have to do this only
347    for shared code.  */
348 #ifdef SHARED
349 # define INTUSE(name) name##_internal
350 # define INTDEF(name) strong_alias (name, name##_internal)
351 # define INTVARDEF(name) _INTVARDEF (name, name##_internal)
352 # if defined HAVE_VISIBILITY_ATTRIBUTE
353 #  define _INTVARDEF(name, aliasname) \
354   extern __typeof (name) aliasname __attribute__ ((alias (#name), \
355                                                    visibility ("hidden")));
356 # else
357 #  define _INTVARDEF(name, aliasname) \
358   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
359 # endif
360 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
361 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
362 #else
363 # define INTUSE(name) name
364 # define INTDEF(name)
365 # define INTVARDEF(name)
366 # define INTDEF2(name, newname)
367 # define INTVARDEF2(name, newname)
368 #endif
369
370
371 /* The following macros are used for PLT bypassing within libc.so
372    (and if needed other libraries similarly).
373
374    If calls to foo within libc.so should always go to foo defined in libc.so,
375    then in include/foo.h you add:
376
377    int foo(int __bar);
378    libc_hidden_proto(foo)
379
380    line and after the foo function definition:
381
382    int foo(int __bar) {
383      return __bar;
384    }
385    libc_hidden_def(foo)
386
387    or
388
389    int foo(int __bar) {
390      return __bar;
391    }
392    libc_hidden_weak(foo)
393
394    Similarly for global data: if references to foo within libc.so
395    should always go to foo defined in libc.so, then in include/foo.h:
396
397    extern int foo;
398    libc_hidden_proto(foo)
399
400    and after foo's definition:
401
402    int foo = INITIAL_FOO_VALUE;
403    libc_hidden_data_def(foo)
404
405    or
406
407    int foo = INITIAL_FOO_VALUE;
408    libc_hidden_data_weak(foo)
409
410    If foo is normally just an alias (strong or weak) to some other function,
411    you should use the normal strong_alias first, then add libc_hidden_def
412    or libc_hidden_weak:
413
414    int baz(int __bar) {
415      return __bar;
416    }
417    strong_alias(baz, foo)
418    libc_hidden_weak(foo)
419
420    If the function should be internal to multiple objects, say ld.so and
421    libc.so, the best way is to use:
422
423    #if !defined NOT_IN_libc || defined IS_IN_rtld
424    hidden_proto(foo)
425    #endif
426
427    in include/foo.h and the normal macros at all function definitions
428    depending on what DSO they belong to.
429
430    If versioned_symbol macro is used to define foo,
431    libc_hidden_ver macro should be used, as in:
432
433    int __real_foo(int __bar) {
434      return __bar;
435    }
436    versioned_symbol(libc, __real_foo, foo, GLIBC_2_1);
437    libc_hidden_ver(__real_foo, foo)
438  */
439
440 /* uClibc specific (the above comment was copied from glibc):
441  *
442  * when ppc64 will be supported, we need changes to support
443  * strong_data_alias (used by asm hidden_data_def)
444  *
445  * no versioning support, hidden[_data]_ver are noop
446  *
447  * hidden_def() in asm is _hidden_strong_alias (not strong_alias)
448  *
449  * libc_hidden_proto(foo) should be added after declaration
450  * in the header, or after extern foo... in all source files
451  * (this is discouraged).
452  * libc_hidden_def does not hide __GI_foo itself, although the name
453  * suggests it (hiding is done exclusively by libc_hidden_proto).
454
455 FIXME! - ?
456  * The reasoning to have it after the header w/ foo's prototype is
457  * to get first the __REDIRECT from original header and then create
458  * the __GI_foo alias
459
460  * Hunt for references which still go through PLT (example for x86):
461  * build shared lib, then disassemble it and search for <xxx@plt>:
462  * $ objdump -drx libuClibc-*.so >disasm.txt
463  * $ grep -F '@plt>:' disasm.txt
464  *
465  * In uclibc, malloc/free and related functions should be called
466  * through PLT (making it possible to use alternative malloc),
467  * and possibly some __pthread_xxx functions can be called through PLT
468  * (why?). The rest should not use PLT.
469  */
470
471 #if (defined __GNUC__ && defined __GNUC_MINOR__ \
472         && (( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4) \
473     ) || defined __ICC
474 # define attribute_hidden __attribute__ ((visibility ("hidden")))
475 # define attribute_protected __attribute__ ((visibility ("protected")))
476 # define __hidden_proto_hiddenattr(attrs...) __attribute__ ((visibility ("hidden"), ##attrs))
477 #else
478 # define attribute_hidden
479 # define attribute_protected
480 # define __hidden_proto_hiddenattr(attrs...)
481 #endif
482
483 #if /*!defined STATIC &&*/ !defined __BCC__
484
485 # ifndef __ASSEMBLER__
486 #  define hidden_proto(name, attrs...) __hidden_proto(name, __GI_##name, ##attrs)
487 #  define __hidden_proto(name, internal, attrs...) \
488         extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
489         __hidden_proto_hiddenattr (attrs);
490 #  define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
491 #  define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
492 #  define __hidden_asmname2(prefix, name) #prefix name
493 #  define __hidden_ver1(local, internal, name) \
494         extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
495         extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
496 #  define hidden_ver(local, name)       __hidden_ver1(local, __GI_##name, name);
497 #  define hidden_data_ver(local, name)  hidden_ver(local, name)
498 #  define hidden_def(name)              __hidden_ver1(__GI_##name, name, name);
499 #  define hidden_data_def(name)         hidden_def(name)
500 #  define hidden_weak(name) \
501         __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
502 #  define hidden_data_weak(name)        hidden_weak(name)
503
504 # else /* __ASSEMBLER__ */
505
506 #  ifdef HAVE_ASM_SET_DIRECTIVE
507 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
508 #    define _hidden_strong_alias(original, alias) \
509         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
510         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
511         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)    ASM_LINE_SEP \
512         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
513         .hidden C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
514         .set    C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
515 #   else
516 #    define _hidden_strong_alias(original, alias) \
517         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
518         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
519         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
520 #   endif
521 #  else /* dont have .set directive */
522 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
523 #    define _hidden_strong_alias(original, alias) \
524         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
525         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
526         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)          ASM_LINE_SEP \
527         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
528         .hidden C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
529         C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
530 #   else
531 #    define _hidden_strong_alias(original, alias) \
532         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
533         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
534         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
535 #   endif
536 #  endif
537
538 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
539 #   define _hidden_weak_alias(original, alias) \
540         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
541         .hidden C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
542         weak_alias(original, alias)
543 #  else
544 #   define _hidden_weak_alias(original, alias) \
545         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
546         weak_alias(original, alias)
547 #  endif
548
549 /* For assembly, we need to do the opposite of what we do in C:
550    in assembly gcc __REDIRECT stuff is not in place, so functions
551    are defined by its normal name and we need to create the
552    __GI_* alias to it, in C __REDIRECT causes the function definition
553    to use __GI_* name and we need to add alias to the real name.
554    There is no reason to use hidden_weak over hidden_def in assembly,
555    but we provide it for consistency with the C usage.
556    hidden_proto doesn't make sense for assembly but the equivalent
557    is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET.  */
558 #  define hidden_def(name)      _hidden_strong_alias (name, __GI_##name)
559 #  define hidden_weak(name)     _hidden_weak_alias (name, __GI_##name)
560 #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
561 #  define hidden_data_def(name) _hidden_strong_alias (name, __GI_##name)
562 #  define hidden_data_weak(name)        _hidden_weak_alias (name, __GI_##name)
563 #  define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
564 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
565 #   define HIDDEN_JUMPTARGET(name) .__GI_##name
566 #  else
567 #   define HIDDEN_JUMPTARGET(name) __GI_##name
568 #  endif
569 # endif /* __ASSEMBLER__ */
570
571 #else /* not SHARED */
572
573 # ifndef __ASSEMBLER__
574 #  define hidden_proto(name, attrs...)
575 # else
576 #  define HIDDEN_JUMPTARGET(name) name
577 # endif /* not __ASSEMBLER__ */
578 # define hidden_weak(name)
579 # define hidden_def(name)
580 # define hidden_ver(local, name)
581 # define hidden_data_weak(name)
582 # define hidden_data_def(name)
583 # define hidden_data_ver(local, name)
584
585 #endif /* SHARED / not SHARED */
586
587
588 /* uClibc does not support versioning yet. */
589 #define versioned_symbol(lib, local, symbol, version) /* weak_alias(local, symbol) */
590 #undef hidden_ver
591 #define hidden_ver(local, name) /* strong_alias(local, __GI_##name) */
592 #undef hidden_data_ver
593 #define hidden_data_ver(local, name) /* strong_alias(local,__GI_##name) */
594
595 #if !defined NOT_IN_libc
596 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
597 # define libc_hidden_def(name) hidden_def (name)
598 # define libc_hidden_weak(name) hidden_weak (name)
599 # define libc_hidden_ver(local, name) hidden_ver (local, name)
600 # define libc_hidden_data_def(name) hidden_data_def (name)
601 # define libc_hidden_data_weak(name) hidden_data_weak (name)
602 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
603 #else
604 # define libc_hidden_proto(name, attrs...)
605 # define libc_hidden_def(name)
606 # define libc_hidden_weak(name)
607 # define libc_hidden_ver(local, name)
608 # define libc_hidden_data_def(name)
609 # define libc_hidden_data_weak(name)
610 # define libc_hidden_data_ver(local, name)
611 #endif
612
613 #if defined NOT_IN_libc && defined IS_IN_rtld
614 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
615 # define rtld_hidden_def(name) hidden_def (name)
616 # define rtld_hidden_weak(name) hidden_weak (name)
617 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
618 # define rtld_hidden_data_def(name) hidden_data_def (name)
619 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
620 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
621 #else
622 # define rtld_hidden_proto(name, attrs...)
623 # define rtld_hidden_def(name)
624 # define rtld_hidden_weak(name)
625 # define rtld_hidden_ver(local, name)
626 # define rtld_hidden_data_def(name)
627 # define rtld_hidden_data_weak(name)
628 # define rtld_hidden_data_ver(local, name)
629 #endif
630
631 #if defined NOT_IN_libc && defined IS_IN_libm
632 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
633 # define libm_hidden_def(name) hidden_def (name)
634 # define libm_hidden_weak(name) hidden_weak (name)
635 # define libm_hidden_ver(local, name) hidden_ver (local, name)
636 # define libm_hidden_data_def(name) hidden_data_def (name)
637 # define libm_hidden_data_weak(name) hidden_data_weak (name)
638 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
639 #else
640 # define libm_hidden_proto(name, attrs...)
641 # define libm_hidden_def(name)
642 # define libm_hidden_weak(name)
643 # define libm_hidden_ver(local, name)
644 # define libm_hidden_data_def(name)
645 # define libm_hidden_data_weak(name)
646 # define libm_hidden_data_ver(local, name)
647 #endif
648
649 #if defined NOT_IN_libc && defined IS_IN_libresolv
650 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
651 # define libresolv_hidden_def(name) hidden_def (name)
652 # define libresolv_hidden_weak(name) hidden_weak (name)
653 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
654 # define libresolv_hidden_data_def(name) hidden_data_def (name)
655 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
656 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
657 #else
658 # define libresolv_hidden_proto(name, attrs...)
659 # define libresolv_hidden_def(name)
660 # define libresolv_hidden_weak(name)
661 # define libresolv_hidden_ver(local, name)
662 # define libresolv_hidden_data_def(name)
663 # define libresolv_hidden_data_weak(name)
664 # define libresolv_hidden_data_ver(local, name)
665 #endif
666
667 #if defined NOT_IN_libc && defined IS_IN_librt
668 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
669 # define librt_hidden_def(name) hidden_def (name)
670 # define librt_hidden_weak(name) hidden_weak (name)
671 # define librt_hidden_ver(local, name) hidden_ver (local, name)
672 # define librt_hidden_data_def(name) hidden_data_def (name)
673 # define librt_hidden_data_weak(name) hidden_data_weak (name)
674 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
675 #else
676 # define librt_hidden_proto(name, attrs...)
677 # define librt_hidden_def(name)
678 # define librt_hidden_weak(name)
679 # define librt_hidden_ver(local, name)
680 # define librt_hidden_data_def(name)
681 # define librt_hidden_data_weak(name)
682 # define librt_hidden_data_ver(local, name)
683 #endif
684
685 #if defined NOT_IN_libc && defined IS_IN_libdl
686 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
687 # define libdl_hidden_def(name) hidden_def (name)
688 # define libdl_hidden_weak(name) hidden_weak (name)
689 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
690 # define libdl_hidden_data_def(name) hidden_data_def (name)
691 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
692 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
693 #else
694 # define libdl_hidden_proto(name, attrs...)
695 # define libdl_hidden_def(name)
696 # define libdl_hidden_weak(name)
697 # define libdl_hidden_ver(local, name)
698 # define libdl_hidden_data_def(name)
699 # define libdl_hidden_data_weak(name)
700 # define libdl_hidden_data_ver(local, name)
701 #endif
702
703 #if defined NOT_IN_libc && defined IS_IN_libintl
704 # define libintl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
705 # define libintl_hidden_def(name) hidden_def (name)
706 # define libintl_hidden_weak(name) hidden_weak (name)
707 # define libintl_hidden_ver(local, name) hidden_ver (local, name)
708 # define libintl_hidden_data_def(name) hidden_data_def (name)
709 # define libintl_hidden_data_weak(name) hidden_data_weak (name)
710 # define libintl_hidden_data_ver(local, name) hidden_data_ver(local, name)
711 #else
712 # define libintl_hidden_proto(name, attrs...)
713 # define libintl_hidden_def(name)
714 # define libintl_hidden_weak(name)
715 # define libintl_hidden_ver(local, name)
716 # define libintl_hidden_data_def(name)
717 # define libintl_hidden_data_weak(name)
718 # define libintl_hidden_data_ver(local, name)
719 #endif
720
721 #if defined NOT_IN_libc && defined IS_IN_libnsl
722 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
723 # define libnsl_hidden_def(name) hidden_def (name)
724 # define libnsl_hidden_weak(name) hidden_weak (name)
725 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
726 # define libnsl_hidden_data_def(name) hidden_data_def (name)
727 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
728 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
729 #else
730 # define libnsl_hidden_proto(name, attrs...)
731 # define libnsl_hidden_def(name)
732 # define libnsl_hidden_weak(name)
733 # define libnsl_hidden_ver(local, name)
734 # define libnsl_hidden_data_def(name)
735 # define libnsl_hidden_data_weak(name)
736 # define libnsl_hidden_data_ver(local, name)
737 #endif
738
739 #if defined NOT_IN_libc && defined IS_IN_libutil
740 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
741 # define libutil_hidden_def(name) hidden_def (name)
742 # define libutil_hidden_weak(name) hidden_weak (name)
743 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
744 # define libutil_hidden_data_def(name) hidden_data_def (name)
745 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
746 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
747 #else
748 # define libutil_hidden_proto(name, attrs...)
749 # define libutil_hidden_def(name)
750 # define libutil_hidden_weak(name)
751 # define libutil_hidden_ver(local, name)
752 # define libutil_hidden_data_def(name)
753 # define libutil_hidden_data_weak(name)
754 # define libutil_hidden_data_ver(local, name)
755 #endif
756
757 #if defined NOT_IN_libc && defined IS_IN_libcrypt
758 # define libcrypt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
759 # define libcrypt_hidden_def(name) hidden_def (name)
760 # define libcrypt_hidden_weak(name) hidden_weak (name)
761 # define libcrypt_hidden_ver(local, name) hidden_ver (local, name)
762 # define libcrypt_hidden_data_def(name) hidden_data_def (name)
763 # define libcrypt_hidden_data_weak(name) hidden_data_weak (name)
764 # define libcrypt_hidden_data_ver(local, name) hidden_data_ver (local, name)
765 #else
766 # define libcrypt_hidden_proto(name, attrs...)
767 # define libcrypt_hidden_def(name)
768 # define libcrypt_hidden_weak(name)
769 # define libcrypt_hidden_ver(local, name)
770 # define libcrypt_hidden_data_def(name)
771 # define libcrypt_hidden_data_weak(name)
772 # define libcrypt_hidden_data_ver(local, name)
773 #endif
774
775 #if defined NOT_IN_libc && defined IS_IN_libpthread
776 # define libpthread_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
777 # define libpthread_hidden_def(name) hidden_def (name)
778 # define libpthread_hidden_weak(name) hidden_weak (name)
779 # define libpthread_hidden_ver(local, name) hidden_ver (local, name)
780 # define libpthread_hidden_data_def(name) hidden_data_def (name)
781 # define libpthread_hidden_data_weak(name) hidden_data_weak (name)
782 # define libpthread_hidden_data_ver(local, name) hidden_data_ver (local, name)
783 #else
784 # define libpthread_hidden_proto(name, attrs...)
785 # define libpthread_hidden_def(name)
786 # define libpthread_hidden_weak(name)
787 # define libpthread_hidden_ver(local, name)
788 # define libpthread_hidden_data_def(name)
789 # define libpthread_hidden_data_weak(name)
790 # define libpthread_hidden_data_ver(local, name)
791 #endif
792
793 #endif /* libc-symbols.h */