cdefs.h revision 1.9
1/* $NetBSD: cdefs.h,v 1.9 1997/10/22 05:20:40 thorpej Exp $ */
2
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 */
29
30#ifndef _MACHINE_CDEFS_H_
31#define	_MACHINE_CDEFS_H_
32
33#define	_C_LABEL(x)	_STRING(x)
34
35#ifdef __GNUC__
36#define	__RENAME(x)	__asm__(x)
37#endif
38
39#ifdef __ELF__
40
41#define	__DO_NOT_DO_WEAK__		/* NO WEAK SYMS IN LIBC YET */
42
43#ifndef __DO_NOT_DO_WEAK__
44#define	__indr_reference(sym,alias)	/* nada, since we do weak refs */
45#endif /* !__DO_NOT_DO_WEAK__ */
46
47#ifdef __STDC__
48
49#ifndef __DO_NOT_DO_WEAK__
50#define	__weak_alias(alias,sym)						\
51    __asm__(".weak " #alias " ; " #alias " = " #sym)
52#endif /* !__DO_NOT_DO_WEAK__ */
53#define	__warn_references(sym,msg)					\
54    __asm__(".section .gnu.warning." #sym " ; .ascii \"" msg "\" ; .text")
55
56#else /* !__STDC__ */
57
58#ifndef __DO_NOT_DO_WEAK__
59#define	__weak_alias(alias,sym)						\
60    __asm__(".weak alias ; alias = sym")
61#endif /* !__DO_NOT_DO_WEAK__ */
62#define	__warn_references(sym,msg)					\
63    __asm__(".section .gnu.warning.sym ; .ascii msg ; .text")
64
65#endif /* !__STDC__ */
66
67#else /* !__ELF__ */
68
69/*
70 * Very little to do if not ELF: we support neither indirect or
71 * weak references, and don't do anything with warnings.
72 */
73
74#define	__warn_references(sym,msg)	/* nothing */
75
76#endif /* !__ELF__ */
77
78
79#ifdef _KERNEL
80
81#ifdef __ELF__
82
83#ifdef __STDC__
84#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
85	__asm__(".section " #_sec " ; .asciz \"" _str "\" ; .text")
86#else
87#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
88	__asm__(".section _sec ; .asciz _str ; .text")
89#endif
90
91#define	__KERNEL_RCSID(_n, _s)		__KERNEL_SECTIONSTRING(.ident, _s)
92#define	__KERNEL_COPYRIGHT(_n, _s)	__KERNEL_SECTIONSTRING(.copyright, _s)
93
94#else /* __ELF__ */
95
96#define	__KERNEL_RCSID(_n, _s)						\
97	static const char __CONCAT(rcsid,_n)[]				\
98	    __attribute__ ((unused)) = _s
99#define	__KERNEL_COPYRIGHT(_n, _s)					\
100	static const char __CONCAT(copyright,_n)[]			\
101	    __attribute__ ((unused)) = _s
102
103#endif /* __ELF__ */
104
105#ifdef NO_KERNEL_RCSIDS
106#undef __KERNEL_RCSID
107#define	__KERNEL_RCSID(_n, _s)		/* nothing */
108#endif
109
110#endif /* _KERNEL */
111
112#endif /* !_MACHINE_CDEFS_H_ */
113