xref: /relibc/openlibm/src/cdefs-compat.h (revision 232ba9db6e4b36dd94ff2ca1022f9ba09970a2ec)
1 #ifndef _CDEFS_COMPAT_H_
2 #define	_CDEFS_COMPAT_H_
3 
4 #if defined(__cplusplus)
5 #define	__BEGIN_DECLS	extern "C" {
6 #define	__END_DECLS	}
7 #else
8 #define	__BEGIN_DECLS
9 #define	__END_DECLS
10 #endif
11 
12 #ifdef __GNUC__
13 #ifndef __strong_reference
14 #ifdef __APPLE__
15 #define __strong_reference(sym,aliassym) __weak_reference(sym,aliassym)
16 #else
17 #define __strong_reference(sym,aliassym)	\
18 	OLM_DLLEXPORT extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
19 #endif /* __APPLE__ */
20 #endif /* __strong_reference */
21 
22 #ifndef __weak_reference
23 #ifdef __ELF__
24 #ifdef __STDC__
25 #define	__weak_reference(sym,alias)	\
26 	__asm__(".weak " #alias);	\
27 	__asm__(".equ "  #alias ", " #sym)
28 #define	__warn_references(sym,msg)	\
29 	__asm__(".section .gnu.warning." #sym);	\
30 	__asm__(".asciz \"" msg "\"");	\
31 	__asm__(".previous")
32 #else
33 #define	__weak_reference(sym,alias)	\
34 	__asm__(".weak alias");		\
35 	__asm__(".equ alias, sym")
36 #define	__warn_references(sym,msg)	\
37 	__asm__(".section .gnu.warning.sym"); \
38 	__asm__(".asciz \"msg\"");	\
39 	__asm__(".previous")
40 #endif	/* __STDC__ */
41 #elif defined(__clang__) /* CLANG */
42 #ifdef __STDC__
43 #define __weak_reference(sym,alias)     \
44     __asm__(".weak_reference " #alias); \
45     __asm__(".set " #alias ", " #sym)
46 #else
47 #define __weak_reference(sym,alias)     \
48     __asm__(".weak_reference alias");\
49     __asm__(".set alias, sym")
50 #endif
51 #else	/* !__ELF__ */
52 #ifdef __STDC__
53 #define __weak_reference(sym,alias)	\
54 	__asm__(".stabs \"_" #alias "\",11,0,0,0");	\
55 	__asm__(".stabs \"_" #sym "\",1,0,0,0")
56 #define __warn_references(sym,msg)	\
57 	__asm__(".stabs \"" msg "\",30,0,0,0");		\
58 	__asm__(".stabs \"_" #sym "\",1,0,0,0")
59 #else
60 #define __weak_reference(sym,alias)	\
61 	__asm__(".stabs \"_/**/alias\",11,0,0,0");	\
62 	__asm__(".stabs \"_/**/sym\",1,0,0,0")
63 #define __warn_references(sym,msg)	\
64 	__asm__(".stabs msg,30,0,0,0");			\
65 	__asm__(".stabs \"_/**/sym\",1,0,0,0")
66 #endif	/* __STDC__ */
67 #endif	/* __ELF__ */
68 #endif  /* __weak_reference */
69 #endif	/* __GNUC__ */
70 
71 
72 #endif /* _CDEFS_COMPAT_H_ */
73