]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blob - libc/include/sys/cdefs_elf.h
Merge "libc: Define new symbol visibility macros"
[android-sdk/platform-bionic.git] / libc / include / sys / cdefs_elf.h
1 /*      $NetBSD: cdefs_elf.h,v 1.22 2005/02/26 22:25:34 perry Exp $     */
3 /*
4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
30 #ifndef _SYS_CDEFS_ELF_H_
31 #define _SYS_CDEFS_ELF_H_
33 #ifdef __LEADING_UNDERSCORE
34 #define _C_LABEL(x)     __CONCAT(_,x)
35 #define _C_LABEL_STRING(x)      "_"x
36 #else
37 #define _C_LABEL(x)     x
38 #define _C_LABEL_STRING(x)      x
39 #endif
41 #if __STDC__
42 #define ___RENAME(x)    __asm__(___STRING(_C_LABEL(x)))
43 #else
44 #ifdef __LEADING_UNDERSCORE
45 #define ___RENAME(x)    ____RENAME(_/**/x)
46 #define ____RENAME(x)   __asm__(___STRING(x))
47 #else
48 #define ___RENAME(x)    __asm__(___STRING(x))
49 #endif
50 #endif
52 #define __indr_reference(sym,alias)     /* nada, since we do weak refs */
54 #if __STDC__
55 #define __strong_alias(alias,sym)                                       \
56     __asm__(".global " _C_LABEL_STRING(#alias) "\n"                     \
57             _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
59 #define __weak_alias(alias,sym)                                         \
60     __asm__(".weak " _C_LABEL_STRING(#alias) "\n"                       \
61             _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
62 #define __weak_extern(sym)                                              \
63     __asm__(".weak " _C_LABEL_STRING(#sym));
64 #define __warn_references(sym,msg)                                      \
65     __asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");
67 #else /* !__STDC__ */
69 #ifdef __LEADING_UNDERSCORE
70 #define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym)
71 #define ___weak_alias(alias,sym)                                        \
72     __asm__(".weak alias\nalias = sym");
73 #else
74 #define __weak_alias(alias,sym)                                         \
75     __asm__(".weak alias\nalias = sym");
76 #endif
77 #ifdef __LEADING_UNDERSCORE
78 #define __weak_extern(sym) ___weak_extern(_/**/sym)
79 #define ___weak_extern(sym)                                             \
80     __asm__(".weak sym");
81 #else
82 #define __weak_extern(sym)                                              \
83     __asm__(".weak sym");
84 #endif
85 #define __warn_references(sym,msg)                                      \
86     __asm__(".section .gnu.warning.sym\n\t.ascii msg ; .text");
88 #endif /* !__STDC__ */
90 #if __STDC__
91 #define __SECTIONSTRING(_sec, _str)                                     \
92         __asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous")
93 #else
94 #define __SECTIONSTRING(_sec, _str)                                     \
95         __asm__(".section _sec\n\t.asciz _str\n\t.previous")
96 #endif
98 /* GCC visibility helper macro */
99 /* This must be used to tag non-static functions that are private, i.e.
100  * never exposed by the shared library. */
101 #define __LIBC_HIDDEN__                                                 \
102         __attribute__ ((visibility ("hidden")))
104 /* This must be used to tag non-static functions that are public, i.e.
105  * exposed by the shared library, and part of the stable NDK ABI */
106 #define __LIBC_ABI_PUBLIC__ \
107         __attribute__ ((visibility ("default")))
109 /* This must be used to tag non-static functions that must be exported
110  * by the shared library, but whose implementation is private to the
111  * platform. For now this is equivalent to __LIBC_ABI_PUBLIC__, but we
112  * may want to change this later.
113  */
114 #define __LIBC_ABI_PRIVATE__ \
115         __attribute__ ((visibility ("default")))
117 #define __IDSTRING(_n,_s)               __SECTIONSTRING(.ident,_s)
119 #define __RCSID(_s)                     __IDSTRING(rcsid,_s)
120 #define __SCCSID(_s)
121 #define __SCCSID2(_s)
122 #if 0   /* XXX userland __COPYRIGHTs have \ns in them */
123 #define __COPYRIGHT(_s)                 __SECTIONSTRING(.copyright,_s)
124 #else
125 #define __COPYRIGHT(_s)                                                 \
126         static const char copyright[]                                   \
127             __attribute__((__unused__,__section__(".copyright"))) = _s
128 #endif
130 #define __KERNEL_RCSID(_n, _s)          __RCSID(_s)
131 #define __KERNEL_SCCSID(_n, _s)
132 #if 0   /* XXX see above */
133 #define __KERNEL_COPYRIGHT(_n, _s)      __COPYRIGHT(_s)
134 #else
135 #define __KERNEL_COPYRIGHT(_n, _s)      __SECTIONSTRING(.copyright, _s)
136 #endif
138 #ifndef __lint__
139 #define __link_set_make_entry(set, sym)                                 \
140         static void const * const __link_set_##set##_sym_##sym          \
141             __section("link_set_" #set) __used = &sym
142 #define __link_set_make_entry2(set, sym, n)                             \
143         static void const * const __link_set_##set##_sym_##sym##_##n    \
144             __section("link_set_" #set) __used = &sym[n]
145 #else
146 #define __link_set_make_entry(set, sym)                                 \
147         extern void const * const __link_set_##set##_sym_##sym
148 #define __link_set_make_entry2(set, sym, n)                             \
149         extern void const * const __link_set_##set##_sym_##sym##_##n
150 #endif /* __lint__ */
152 #define __link_set_add_text(set, sym)   __link_set_make_entry(set, sym)
153 #define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym)
154 #define __link_set_add_data(set, sym)   __link_set_make_entry(set, sym)
155 #define __link_set_add_bss(set, sym)    __link_set_make_entry(set, sym)
156 #define __link_set_add_text2(set, sym, n)   __link_set_make_entry2(set, sym, n)
157 #define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n)
158 #define __link_set_add_data2(set, sym, n)   __link_set_make_entry2(set, sym, n)
159 #define __link_set_add_bss2(set, sym, n)    __link_set_make_entry2(set, sym, n)
161 #define __link_set_decl(set, ptype)                                     \
162         extern ptype * const __start_link_set_##set[];                  \
163         extern ptype * const __stop_link_set_##set[]                    \
165 #define __link_set_start(set)   (__start_link_set_##set)
166 #define __link_set_end(set)     (__stop_link_set_##set)
168 #define __link_set_count(set)                                           \
169         (__link_set_end(set) - __link_set_start(set))
171 #endif /* !_SYS_CDEFS_ELF_H_ */