aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/include/_types.h11
-rw-r--r--sys/alpha/include/atomic.h28
-rw-r--r--sys/alpha/include/cpufunc.h6
-rw-r--r--sys/alpha/include/critical.h6
-rw-r--r--sys/alpha/include/endian.h6
-rw-r--r--sys/alpha/include/in_cksum.h2
-rw-r--r--sys/alpha/include/ioctl_bt848.h4
-rw-r--r--sys/alpha/include/ioctl_meteor.h4
-rw-r--r--sys/alpha/include/limits.h4
-rw-r--r--sys/alpha/include/stdarg.h6
-rw-r--r--sys/alpha/include/varargs.h16
-rw-r--r--sys/amd64/amd64/fpu.c6
-rw-r--r--sys/amd64/amd64/prof_machdep.c24
-rw-r--r--sys/amd64/include/_types.h9
-rw-r--r--sys/amd64/include/atomic.h26
-rw-r--r--sys/amd64/include/bus_amd64.h42
-rw-r--r--sys/amd64/include/cpufunc.h16
-rw-r--r--sys/amd64/include/critical.h6
-rw-r--r--sys/amd64/include/endian.h6
-rw-r--r--sys/amd64/include/ieeefp.h18
-rw-r--r--sys/amd64/include/in_cksum.h2
-rw-r--r--sys/amd64/include/limits.h4
-rw-r--r--sys/amd64/include/pcpu.h9
-rw-r--r--sys/amd64/include/profile.h18
-rw-r--r--sys/amd64/include/stdarg.h4
-rw-r--r--sys/amd64/include/varargs.h16
-rw-r--r--sys/arm/arm/busdma_machdep.c6
-rw-r--r--sys/arm/include/_types.h13
-rw-r--r--sys/arm/include/limits.h4
-rw-r--r--sys/arm/include/stdarg.h12
-rw-r--r--sys/boot/arc/include/arcfuncs.h12
-rw-r--r--sys/boot/efi/include/ia64/efibind.h4
-rw-r--r--sys/dev/cx/machdep.h6
-rw-r--r--sys/dev/ichsmb/ichsmb.c2
-rw-r--r--sys/dev/iir/iir.h6
-rw-r--r--sys/dev/isp/ispvar.h5
-rw-r--r--sys/dev/mcd/mcdreg.h27
-rw-r--r--sys/dev/mpt/mpilib/mpi_type.h6
-rw-r--r--sys/dev/random/nehemiah.c4
-rw-r--r--sys/dev/scd/scdreg.h14
-rw-r--r--sys/i386/acpica/acpi_wakeup.c8
-rw-r--r--sys/i386/i386/identcpu.c4
-rw-r--r--sys/i386/i386/in_cksum.c8
-rw-r--r--sys/i386/include/_types.h13
-rw-r--r--sys/i386/include/atomic.h26
-rw-r--r--sys/i386/include/bus_at386.h42
-rw-r--r--sys/i386/include/cpufunc.h16
-rw-r--r--sys/i386/include/critical.h6
-rw-r--r--sys/i386/include/endian.h16
-rw-r--r--sys/i386/include/ieeefp.h8
-rw-r--r--sys/i386/include/in_cksum.h8
-rw-r--r--sys/i386/include/ioctl_bt848.h4
-rw-r--r--sys/i386/include/ioctl_meteor.h4
-rw-r--r--sys/i386/include/limits.h4
-rw-r--r--sys/i386/include/pcpu.h9
-rw-r--r--sys/i386/include/profile.h16
-rw-r--r--sys/i386/include/stdarg.h12
-rw-r--r--sys/i386/include/varargs.h14
-rw-r--r--sys/i386/isa/npx.c6
-rw-r--r--sys/i386/isa/prof_machdep.c20
-rw-r--r--sys/ia64/include/_types.h11
-rw-r--r--sys/ia64/include/cpufunc.h10
-rw-r--r--sys/ia64/include/critical.h6
-rw-r--r--sys/ia64/include/endian.h6
-rw-r--r--sys/ia64/include/in_cksum.h2
-rw-r--r--sys/ia64/include/limits.h4
-rw-r--r--sys/ia64/include/stdarg.h2
-rw-r--r--sys/kern/subr_prof.c4
-rw-r--r--sys/powerpc/include/_types.h11
-rw-r--r--sys/powerpc/include/atomic.h16
-rw-r--r--sys/powerpc/include/critical.h6
-rw-r--r--sys/powerpc/include/endian.h6
-rw-r--r--sys/powerpc/include/in_cksum.h2
-rw-r--r--sys/powerpc/include/limits.h4
-rw-r--r--sys/powerpc/include/stdarg.h8
-rw-r--r--sys/powerpc/include/varargs.h14
-rw-r--r--sys/powerpc/powerpc/busdma_machdep.c6
-rw-r--r--sys/sparc64/include/_types.h11
-rw-r--r--sys/sparc64/include/critical.h6
-rw-r--r--sys/sparc64/include/endian.h2
-rw-r--r--sys/sparc64/include/stdarg.h10
-rw-r--r--sys/sparc64/include/varargs.h14
-rw-r--r--sys/sys/cdefs.h78
-rw-r--r--sys/sys/dir.h4
-rw-r--r--sys/sys/ioctl.h7
-rw-r--r--sys/sys/linker_set.h12
-rw-r--r--sys/sys/queue.h6
-rw-r--r--sys/sys/syslimits.h5
88 files changed, 584 insertions, 353 deletions
diff --git a/sys/alpha/include/_types.h b/sys/alpha/include/_types.h
index 885b2415935c..a8acbbbce351 100644
--- a/sys/alpha/include/_types.h
+++ b/sys/alpha/include/_types.h
@@ -39,6 +39,10 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Basic types upon which most other types are built.
*/
@@ -97,7 +101,7 @@ typedef __uint64_t __vm_size_t;
/*
* Unusual type definitions.
*/
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifdef __GNUCLIKE_BUILTIN_VAALIST
typedef __builtin_va_list __va_list; /* internally known to gcc */
#else
typedef struct {
@@ -105,8 +109,9 @@ typedef struct {
int __offset;
int __pad;
} __va_list;
-#endif /* post GCC 2.95 */
-#if defined __GNUC__ && !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST)
+#endif /* __GNUCLIKE_BUILTIN_VAALIST */
+#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
+ && !defined(__NO_GNUC_VA_LIST)
#define __GNUC_VA_LIST
typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
#endif
diff --git a/sys/alpha/include/atomic.h b/sys/alpha/include/atomic.h
index 599700b5fc2c..cc2dbb44f7a5 100644
--- a/sys/alpha/include/atomic.h
+++ b/sys/alpha/include/atomic.h
@@ -29,6 +29,10 @@
#ifndef _MACHINE_ATOMIC_H_
#define _MACHINE_ATOMIC_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
#include <machine/alpha_cpu.h>
/*
@@ -50,7 +54,7 @@ static __inline void atomic_set_32(volatile u_int32_t *p, u_int32_t v)
{
u_int32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldl_l %0, %2\n\t" /* load old value */
"bis %0, %3, %0\n\t" /* calculate new value */
@@ -66,7 +70,7 @@ static __inline void atomic_clear_32(volatile u_int32_t *p, u_int32_t v)
{
u_int32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldl_l %0, %1\n\t" /* load old value */
"bic %0, %2, %0\n\t" /* calculate new value */
@@ -82,7 +86,7 @@ static __inline void atomic_add_32(volatile u_int32_t *p, u_int32_t v)
{
u_int32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldl_l %0, %1\n\t" /* load old value */
"addl %0, %2, %0\n\t" /* calculate new value */
@@ -98,7 +102,7 @@ static __inline void atomic_subtract_32(volatile u_int32_t *p, u_int32_t v)
{
u_int32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldl_l %0, %1\n\t" /* load old value */
"subl %0, %2, %0\n\t" /* calculate new value */
@@ -114,7 +118,7 @@ static __inline u_int32_t atomic_readandclear_32(volatile u_int32_t *addr)
{
u_int32_t result,temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"wmb\n" /* ensure pending writes have drained */
"1:\tldl_l %0,%2\n\t" /* load current value, asserting lock */
@@ -133,7 +137,7 @@ static __inline void atomic_set_64(volatile u_int64_t *p, u_int64_t v)
{
u_int64_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldq_l %0, %1\n\t" /* load old value */
"bis %0, %2, %0\n\t" /* calculate new value */
@@ -149,7 +153,7 @@ static __inline void atomic_clear_64(volatile u_int64_t *p, u_int64_t v)
{
u_int64_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldq_l %0, %1\n\t" /* load old value */
"bic %0, %2, %0\n\t" /* calculate new value */
@@ -165,7 +169,7 @@ static __inline void atomic_add_64(volatile u_int64_t *p, u_int64_t v)
{
u_int64_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldq_l %0, %1\n\t" /* load old value */
"addq %0, %2, %0\n\t" /* calculate new value */
@@ -181,7 +185,7 @@ static __inline void atomic_subtract_64(volatile u_int64_t *p, u_int64_t v)
{
u_int64_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldq_l %0, %1\n\t" /* load old value */
"subq %0, %2, %0\n\t" /* calculate new value */
@@ -197,7 +201,7 @@ static __inline u_int64_t atomic_readandclear_64(volatile u_int64_t *addr)
{
u_int64_t result,temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"wmb\n" /* ensure pending writes have drained */
"1:\tldq_l %0,%2\n\t" /* load current value, asserting lock */
@@ -336,7 +340,7 @@ atomic_cmpset_32(volatile u_int32_t* p, u_int32_t cmpval, u_int32_t newval)
{
u_int32_t ret;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldl_l %0, %1\n\t" /* load old value */
"cmpeq %0, %2, %0\n\t" /* compare */
@@ -363,7 +367,7 @@ atomic_cmpset_64(volatile u_int64_t* p, u_int64_t cmpval, u_int64_t newval)
{
u_int64_t ret;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tldq_l %0, %1\n\t" /* load old value */
"cmpeq %0, %2, %0\n\t" /* compare */
diff --git a/sys/alpha/include/cpufunc.h b/sys/alpha/include/cpufunc.h
index 05bdbd4a345a..5979987c6687 100644
--- a/sys/alpha/include/cpufunc.h
+++ b/sys/alpha/include/cpufunc.h
@@ -35,9 +35,13 @@
#include <machine/chipset.h>
#include <machine/alpha_cpu.h>
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
struct thread;
-#ifdef __GNUC__
+#if defined(__GNUCLIKE_ASM)
static __inline void
breakpoint(void)
diff --git a/sys/alpha/include/critical.h b/sys/alpha/include/critical.h
index 22ff08cecb22..4c9f729dfc23 100644
--- a/sys/alpha/include/critical.h
+++ b/sys/alpha/include/critical.h
@@ -46,7 +46,7 @@ __BEGIN_DECLS
*/
void cpu_critical_fork_exit(void);
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
/*
* cpu_critical_enter:
@@ -75,12 +75,12 @@ cpu_critical_exit(struct thread *td)
intr_restore(td->td_md.md_savecrit);
}
-#else /* !__GNUC__ */
+#else /* !__CC_SUPPORTS___INLINE */
void cpu_critical_enter(struct thread *td);
void cpu_critical_exit(struct thread *td);
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE */
__END_DECLS
diff --git a/sys/alpha/include/endian.h b/sys/alpha/include/endian.h
index 1b11ffb5798b..974ce1626938 100644
--- a/sys/alpha/include/endian.h
+++ b/sys/alpha/include/endian.h
@@ -64,7 +64,7 @@
#define BYTE_ORDER _BYTE_ORDER
#endif
-#ifdef __GNUC__
+#if defined(__CC_SUPPORTS___INLINE) && defined(__GNUCLIKE_ASM)
static __inline __uint64_t
__bswap64(__uint64_t _x)
@@ -113,7 +113,7 @@ __bswap16(__uint16_t _x)
#define __ntohl(x) __bswap32(x)
#define __ntohs(x) __bswap16(x)
-#else /* !__GNUC__ */
+#else /* !(__CC_SUPPORTS___INLINE && __GNUCLIKE_ASM) */
/*
* No optimizations are available for this compiler. Fall back to
@@ -122,6 +122,6 @@ __bswap16(__uint16_t _x)
*/
#define _BYTEORDER_FUNC_DEFINED
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE && __GNUCLIKE_ASM */
#endif /* !_MACHINE_ENDIAN_H_ */
diff --git a/sys/alpha/include/in_cksum.h b/sys/alpha/include/in_cksum.h
index a899ef0d8488..09920062a0ae 100644
--- a/sys/alpha/include/in_cksum.h
+++ b/sys/alpha/include/in_cksum.h
@@ -45,7 +45,7 @@
* in the normal case (where there are no options and the header length is
* therefore always exactly five 32-bit words.
*/
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
static __inline void
in_cksum_update(struct ip *ip)
diff --git a/sys/alpha/include/ioctl_bt848.h b/sys/alpha/include/ioctl_bt848.h
index 7ef237b00e2f..ca83a36cdb5a 100644
--- a/sys/alpha/include/ioctl_bt848.h
+++ b/sys/alpha/include/ioctl_bt848.h
@@ -29,7 +29,9 @@
#ifndef _MACHINE_IOCTL_BT848_H_
#define _MACHINE_IOCTL_BT848_H_
-#ifdef __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning Include dev/bktr/ioctl_bt848.h instead of this header.
#endif
diff --git a/sys/alpha/include/ioctl_meteor.h b/sys/alpha/include/ioctl_meteor.h
index 69d033e6573e..0322f1ede2c1 100644
--- a/sys/alpha/include/ioctl_meteor.h
+++ b/sys/alpha/include/ioctl_meteor.h
@@ -29,7 +29,9 @@
#ifndef _MACHINE_IOCTL_METEOR_H_
#define _MACHINE_IOCTL_METEOR_H_
-#ifdef __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning Include dev/bktr/ioctl_meteor.h instead of this header.
#endif
diff --git a/sys/alpha/include/limits.h b/sys/alpha/include/limits.h
index a02c8e18e4c4..94447607a886 100644
--- a/sys/alpha/include/limits.h
+++ b/sys/alpha/include/limits.h
@@ -34,7 +34,9 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#if __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
diff --git a/sys/alpha/include/stdarg.h b/sys/alpha/include/stdarg.h
index bd67f1f2cf76..13449627c907 100644
--- a/sys/alpha/include/stdarg.h
+++ b/sys/alpha/include/stdarg.h
@@ -47,7 +47,7 @@
typedef __va_list va_list;
#endif
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifdef __GNUCLIKE_BUILTIN_STDARG
#define va_start(ap, last) \
__builtin_stdarg_start((ap), (last))
@@ -63,7 +63,7 @@ typedef __va_list va_list;
#define va_end(ap) \
__builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* !__GNUCLIKE_BUILTIN_STDARG */
#ifdef __lint__
#define __builtin_saveregs() (0)
@@ -87,6 +87,6 @@ typedef __va_list va_list;
#define va_end(ap) ((void)0)
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_STDARG */
#endif /* !_MACHINE_STDARG_H_ */
diff --git a/sys/alpha/include/varargs.h b/sys/alpha/include/varargs.h
index 8565a3c63f24..b05a9a5b1113 100644
--- a/sys/alpha/include/varargs.h
+++ b/sys/alpha/include/varargs.h
@@ -44,7 +44,11 @@
#ifndef _MACHINE_VARARGS_H_
#define _MACHINE_VARARGS_H_
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
+#if defined(__GNUCLIKE_BUILTIN_VARARGS)
#include <sys/_types.h>
@@ -61,23 +65,21 @@ typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
#define va_arg(ap, type) __builtin_va_arg((ap), type)
#define va_end(ap) __builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* ! __GNUCLIKE_BUILTIN_VARARGS */
#include <machine/stdarg.h>
-#if __GNUC__ == 1
-#define __va_ellipsis
-#else
#define __va_ellipsis ...
-#endif
+#ifdef __GNUCLIKE_BUILTIN_VAALIST
#define va_alist __builtin_va_alist
#define va_dcl long __builtin_va_alist; __va_ellipsis
+#endif
#undef va_start
#define va_start(ap) \
((ap) = *(va_list *)__builtin_saveregs(), (ap).__pad = 0)
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
#endif /* !_MACHINE_VARARGS_H_ */
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index 0b2071e11d9d..d727a4191d0e 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$");
* Floating point support.
*/
-#if defined(__GNUC__) && !defined(lint)
+#if defined(__GNUCLIKE_ASM) && !defined(lint)
#define fldcw(addr) __asm("fldcw %0" : : "m" (*(addr)))
#define fnclex() __asm("fnclex")
@@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$");
: : "n" (CR0_TS) : "ax")
#define stop_emulating() __asm("clts")
-#else /* not __GNUC__ */
+#else /* !__GNUCLIKE_ASM */
void fldcw(caddr_t addr);
void fnclex(void);
@@ -89,7 +89,7 @@ void fxrstor(caddr_t addr);
void start_emulating(void);
void stop_emulating(void);
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_ASM */
#define GET_FPU_CW(thread) ((thread)->td_pcb->pcb_save.sv_env.en_cw)
#define GET_FPU_SW(thread) ((thread)->td_pcb->pcb_save.sv_env.en_sw)
diff --git a/sys/amd64/amd64/prof_machdep.c b/sys/amd64/amd64/prof_machdep.c
index e797cc080834..1449f3fffa91 100644
--- a/sys/amd64/amd64/prof_machdep.c
+++ b/sys/amd64/amd64/prof_machdep.c
@@ -69,7 +69,7 @@ static struct gmonparam saved_gmp;
#endif
#endif /* GUPROF */
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm(" \n\
GM_STATE = 0 \n\
GMON_PROF_OFF = 3 \n\
@@ -140,9 +140,9 @@ __cyg_profile_func_enter: \n\
.mcount_exit: \n\
ret \n\
");
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
-#error
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#else /* !__GNUCLIKE_ASM */
+#error this file needs to be ported to your compiler
+#endif /* __GNUCLIKE_ASM */
#ifdef GUPROF
/*
@@ -151,7 +151,7 @@ __cyg_profile_func_enter: \n\
* dependent file together with cputime(), __mcount and [.]mcount. cputime()
* can't just be put in machdep.c because it has to be compiled without -pg.
*/
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm(" \n\
.text \n\
# \n\
@@ -194,9 +194,9 @@ __cyg_profile_func_exit: \n\
.mexitcount_exit: \n\
ret \n\
");
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
-#error
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#else /* !__GNUCLIKE_ASM */
+#error this file needs to be ported to your compiler
+#endif /* __GNUCLIKE_ASM */
/*
* Return the time elapsed since the last call. The units are machine-
@@ -379,7 +379,7 @@ stopguprof(gp)
}
#else /* !GUPROF */
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm(" \n\
.text \n\
.p2align 4,0x90 \n\
@@ -387,7 +387,7 @@ __asm(" \n\
" __XSTRING(HIDENAME(mexitcount)) ": \n\
ret \n\
");
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
-#error
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#else /* !__GNUCLIKE_ASM */
+#error this file needs to be ported to your compiler
+#endif /* __GNUCLIKE_ASM */
#endif /* GUPROF */
diff --git a/sys/amd64/include/_types.h b/sys/amd64/include/_types.h
index 4a7b6e7edcde..709cc161665f 100644
--- a/sys/amd64/include/_types.h
+++ b/sys/amd64/include/_types.h
@@ -39,6 +39,10 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Basic types upon which most other types are built.
*/
@@ -97,12 +101,13 @@ typedef __uint64_t __vm_size_t;
/*
* Unusual type definitions.
*/
-#if defined(__GNUC__)
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
typedef __builtin_va_list __va_list; /* internally known to gcc */
#elif defined(lint)
typedef char * __va_list; /* pretend */
#endif
-#if defined __GNUC__ && !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST)
+#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
+ && !defined(__NO_GNUC_VA_LIST)
#define __GNUC_VA_LIST
typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
#endif
diff --git a/sys/amd64/include/atomic.h b/sys/amd64/include/atomic.h
index cbee2715929d..eaf8068c7f84 100644
--- a/sys/amd64/include/atomic.h
+++ b/sys/amd64/include/atomic.h
@@ -28,6 +28,10 @@
#ifndef _MACHINE_ATOMIC_H_
#define _MACHINE_ATOMIC_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Various simple arithmetic on memory which is atomic in the presence
* of interrupts and multiple processors.
@@ -76,7 +80,7 @@ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
#else /* !KLD_MODULE */
-#ifdef __GNUC__
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
/*
* For userland, assume the SMP case and use lock prefixes so that
@@ -102,12 +106,12 @@ atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
} \
struct __hack
-#else /* !__GNUC__ */
+#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
extern void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
/*
* Atomic compare and set, used by the mutex functions
@@ -117,7 +121,7 @@ extern void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
* Returns 0 on failure, non-zero on success
*/
-#if defined(__GNUC__)
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
static __inline int
atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
@@ -158,9 +162,9 @@ atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
return (res);
}
-#endif /* defined(__GNUC__) */
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
-#if defined(__GNUC__)
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \
static __inline u_##TYPE \
@@ -189,7 +193,7 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
} \
struct __hack
-#else /* !defined(__GNUC__) */
+#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
extern int atomic_cmpset_int(volatile u_int *, u_int, u_int);
extern int atomic_cmpset_long(volatile u_long *, u_long, u_long);
@@ -198,7 +202,7 @@ extern int atomic_cmpset_long(volatile u_long *, u_long, u_long);
extern u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p); \
extern void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
-#endif /* defined(__GNUC__) */
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
#endif /* KLD_MODULE */
@@ -371,7 +375,7 @@ ATOMIC_PTR(subtract)
#undef ATOMIC_PTR
-#if defined(__GNUC__)
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
static __inline u_int
atomic_readandclear_int(volatile u_int *addr)
@@ -403,12 +407,12 @@ atomic_readandclear_long(volatile u_long *addr)
return (result);
}
-#else /* !defined(__GNUC__) */
+#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
extern u_long atomic_readandclear_long(volatile u_long *);
extern u_int atomic_readandclear_int(volatile u_int *);
-#endif /* defined(__GNUC__) */
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
#endif /* !defined(WANT_FUNCTIONS) */
#endif /* ! _MACHINE_ATOMIC_H_ */
diff --git a/sys/amd64/include/bus_amd64.h b/sys/amd64/include/bus_amd64.h
index 189816bd0481..9e0bc45085af 100644
--- a/sys/amd64/include/bus_amd64.h
+++ b/sys/amd64/include/bus_amd64.h
@@ -74,6 +74,10 @@
#include <machine/cpufunc.h>
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* To remain compatible with NetBSD's interface, default to both memio and
* pio when neither of them is defined.
@@ -284,7 +288,7 @@ bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: movb (%2),%%al \n\
@@ -313,7 +317,7 @@ bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: movw (%2),%%ax \n\
@@ -342,7 +346,7 @@ bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: movl (%2),%%eax \n\
@@ -391,7 +395,7 @@ bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: inb %w2,%%al \n\
@@ -410,7 +414,7 @@ bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
bus_space_handle_t _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -433,7 +437,7 @@ bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: inw %w2,%%ax \n\
@@ -452,7 +456,7 @@ bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
bus_space_handle_t _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -475,7 +479,7 @@ bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: inl %w2,%%eax \n\
@@ -494,7 +498,7 @@ bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
bus_space_handle_t _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -623,7 +627,7 @@ bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsb \n\
@@ -652,7 +656,7 @@ bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsw \n\
@@ -681,7 +685,7 @@ bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsl \n\
@@ -731,7 +735,7 @@ bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsb \n\
@@ -750,7 +754,7 @@ bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
bus_space_handle_t _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -773,7 +777,7 @@ bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsw \n\
@@ -792,7 +796,7 @@ bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
bus_space_handle_t _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -815,7 +819,7 @@ bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsl \n\
@@ -834,7 +838,7 @@ bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
bus_space_handle_t _port_ = bsh + offset;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -1213,7 +1217,7 @@ static __inline void
bus_space_barrier(bus_space_tag_t tag __unused, bus_space_handle_t bsh __unused,
bus_size_t offset __unused, bus_size_t len __unused, int flags)
{
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
if (flags & BUS_SPACE_BARRIER_READ)
__asm __volatile("lock; addl $0,0(%%rsp)" : : : "memory");
else
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index e55885876204..4c596a02ebe1 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -39,6 +39,10 @@
#ifndef _MACHINE_CPUFUNC_H_
#define _MACHINE_CPUFUNC_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
struct region_descriptor;
#define readb(va) (*(volatile u_int8_t *) (va))
@@ -51,7 +55,7 @@ struct region_descriptor;
#define writel(va, d) (*(volatile u_int32_t *) (va) = (d))
#define writeq(va, d) (*(volatile u_int64_t *) (va) = (d))
-#ifdef __GNUC__
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
static __inline void
breakpoint(void)
@@ -152,12 +156,12 @@ halt(void)
__asm __volatile("hlt");
}
-#if __GNUC__ < 2
+#if !defined(__GNUCLIKE_BUILTIN_CONSTANT_P) || __GNUCLIKE_ASM < 3
#define inb(port) inbv(port)
#define outb(port, data) outbv(port, data)
-#else /* __GNUC >= 2 */
+#else /* __GNUCLIKE_BUILTIN_CONSTANT_P && __GNUCLIKE_ASM >= 3 */
/*
* The following complications are to get around gcc not having a
@@ -204,7 +208,7 @@ outbc(u_int port, u_char data)
__asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port)));
}
-#endif /* __GNUC <= 2 */
+#endif /* __GNUCLIKE_BUILTIN_CONSTANT_P */
static __inline u_char
inbv(u_int port)
@@ -696,7 +700,7 @@ intr_restore(register_t rflags)
write_rflags(rflags);
}
-#else /* !__GNUC__ */
+#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
int breakpoint(void);
u_int bsfl(u_int mask);
@@ -761,7 +765,7 @@ void wbinvd(void);
void write_rflags(u_int rf);
void wrmsr(u_int msr, u_int64_t newval);
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
void reset_dbregs(void);
diff --git a/sys/amd64/include/critical.h b/sys/amd64/include/critical.h
index 0e02e1fab640..37ba264b38d8 100644
--- a/sys/amd64/include/critical.h
+++ b/sys/amd64/include/critical.h
@@ -46,7 +46,7 @@ __BEGIN_DECLS
*/
void cpu_critical_fork_exit(void);
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
/*
* cpu_critical_enter:
@@ -74,12 +74,12 @@ cpu_critical_exit(struct thread *td)
intr_restore(td->td_md.md_savecrit);
}
-#else /* !__GNUC__ */
+#else /* !__CC_SUPPORTS___INLINE */
void cpu_critical_enter(struct thread *td);
void cpu_critical_exit(struct thread *td);
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE */
__END_DECLS
diff --git a/sys/amd64/include/endian.h b/sys/amd64/include/endian.h
index 459126bdac07..6ed21185fd7d 100644
--- a/sys/amd64/include/endian.h
+++ b/sys/amd64/include/endian.h
@@ -63,7 +63,7 @@
#define BYTE_ORDER _BYTE_ORDER
#endif
-#ifdef __GNUC__
+#if defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE_BUILTIN_CONSTANT_P)
#define __word_swap_int_var(x) \
__extension__ ({ register __uint32_t __X = (x); \
@@ -177,7 +177,7 @@ __bswap16(__uint16_t _x)
#define __ntohl(x) __bswap32(x)
#define __ntohs(x) __bswap16(x)
-#else /* !__GNUC__ */
+#else /* !(__GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P) */
/*
* No optimizations are available for this compiler. Fall back to
@@ -186,6 +186,6 @@ __bswap16(__uint16_t _x)
*/
#define _BYTEORDER_FUNC_DEFINED
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P */
#endif /* !_MACHINE_ENDIAN_H_ */
diff --git a/sys/amd64/include/ieeefp.h b/sys/amd64/include/ieeefp.h
index 214f3b561671..bfa80aacff31 100644
--- a/sys/amd64/include/ieeefp.h
+++ b/sys/amd64/include/ieeefp.h
@@ -42,6 +42,10 @@
#ifndef _MACHINE_IEEEFP_H_
#define _MACHINE_IEEEFP_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* FP rounding modes
*/
@@ -117,7 +121,8 @@ typedef enum {
#define SSE_RND_OFF 13 /* rounding control offset */
#define SSE_FZ_OFF 15 /* flush to zero offset */
-#if defined(__GNUC__) && !defined(__cplusplus)
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE__) \
+ && !defined(__cplusplus)
#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
@@ -263,9 +268,10 @@ __fpsetsticky(fp_except_t _m)
return (_p);
}
-#endif /* __GNUC__ && !__cplusplus */
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE__ && !__cplusplus */
-#if !defined(__IEEEFP_NOINLINES__) && !defined(__cplusplus) && defined(__GNUC__)
+#if !defined(__IEEEFP_NOINLINES__) && !defined(__cplusplus) \
+ && defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE__)
#define fpgetround() __fpgetround()
#define fpsetround(_m) __fpsetround(_m)
@@ -279,7 +285,8 @@ __fpsetsticky(fp_except_t _m)
/* Suppress prototypes in the MI header. */
#define _IEEEFP_INLINED_ 1
-#else /* !__IEEEFP_NOINLINES__ && !__cplusplus && __GNUC__ */
+#else /* !__IEEEFP_NOINLINES__ && !__cplusplus && __GNUCLIKE_ASM
+ && __CC_SUPPORTS___INLINE__ */
/* Augment the userland declarations */
__BEGIN_DECLS
@@ -287,6 +294,7 @@ extern fp_prec_t fpgetprec(void);
extern fp_prec_t fpsetprec(fp_prec_t);
__END_DECLS
-#endif /* !__IEEEFP_NOINLINES__ && !__cplusplus && __GNUC__ */
+#endif /* !__IEEEFP_NOINLINES__ && !__cplusplus && __GNUCLIKE_ASM
+ && __CC_SUPPORTS___INLINE__ */
#endif /* !_MACHINE_IEEEFP_H_ */
diff --git a/sys/amd64/include/in_cksum.h b/sys/amd64/include/in_cksum.h
index a899ef0d8488..09920062a0ae 100644
--- a/sys/amd64/include/in_cksum.h
+++ b/sys/amd64/include/in_cksum.h
@@ -45,7 +45,7 @@
* in the normal case (where there are no options and the header length is
* therefore always exactly five 32-bit words.
*/
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
static __inline void
in_cksum_update(struct ip *ip)
diff --git a/sys/amd64/include/limits.h b/sys/amd64/include/limits.h
index 8e3bb11edfc3..35eea1f619de 100644
--- a/sys/amd64/include/limits.h
+++ b/sys/amd64/include/limits.h
@@ -33,7 +33,9 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#if __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
index 0694c766fc83..b9d4a6171911 100644
--- a/sys/amd64/include/pcpu.h
+++ b/sys/amd64/include/pcpu.h
@@ -29,6 +29,10 @@
#ifndef _MACHINE_PCPU_H_
#define _MACHINE_PCPU_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
#ifdef _KERNEL
/*
@@ -55,7 +59,8 @@ extern struct pcpu *pcpup;
#define PCPU_PTR(member) (&pcpup->pc_ ## member)
#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
-#elif defined(__GNUC__)
+#elif defined(__GNUCLIKE___TYPEOF) && defined(__GNUCLIKE___OFFSETOF) \
+ && defined(__GNUCLIKE_ASM)
/*
* Evaluates to the byte offset of the per-cpu variable name.
@@ -170,7 +175,7 @@ __curthread(void)
#define curthread (__curthread())
#else
-#error gcc or lint is required to use this file
+#error this file needs to be ported to your compiler
#endif
#endif /* _KERNEL */
diff --git a/sys/amd64/include/profile.h b/sys/amd64/include/profile.h
index ecd34264dcd3..93e8614523f3 100644
--- a/sys/amd64/include/profile.h
+++ b/sys/amd64/include/profile.h
@@ -33,6 +33,10 @@
#ifndef _MACHINE_PROFILE_H_
#define _MACHINE_PROFILE_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
#ifdef _KERNEL
/*
@@ -53,7 +57,7 @@
#define MCOUNT_DECL(s)
#define MCOUNT_ENTER(s)
#define MCOUNT_EXIT(s)
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
#define MCOUNT_OVERHEAD(label) \
__asm __volatile("pushq %0; call __mcount; popq %%rcx" \
: \
@@ -70,8 +74,8 @@
#define MEXITCOUNT_OVERHEAD()
#define MEXITCOUNT_OVERHEAD_GETLABEL()
#else
-#error
-#endif /* __GNUC */
+#error this file needs to be ported to your compiler
+#endif /* __GNUCLIKE_ASM */
#else /* !GUPROF */
#define MCOUNT_DECL(s) u_long s;
#ifdef SMP
@@ -108,7 +112,7 @@ void user(void);
static void _mcount(uintfptr_t frompc, uintfptr_t selfpc) __used; \
static void _mcount
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
#define MCOUNT __asm(" \n\
.globl .mcount \n\
.type .mcount @function \n\
@@ -166,13 +170,13 @@ mcount() \
_mcount(frompc, selfpc); \
}
#endif
-#else /* !__GNUC__ */
+#else /* !__GNUCLIKE_ASM */
#define MCOUNT \
void \
mcount() \
{ \
}
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_ASM */
typedef u_long uintfptr_t;
@@ -193,7 +197,7 @@ void mcount(uintfptr_t frompc, uintfptr_t selfpc);
#include <sys/cdefs.h>
__BEGIN_DECLS
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
void mcount(void) __asm(".mcount");
#endif
__END_DECLS
diff --git a/sys/amd64/include/stdarg.h b/sys/amd64/include/stdarg.h
index 60a204ad177f..d3612d21e830 100644
--- a/sys/amd64/include/stdarg.h
+++ b/sys/amd64/include/stdarg.h
@@ -39,7 +39,7 @@
typedef __va_list va_list;
#endif
-#if defined(__GNUC__)
+#if defined(__GNUCLIKE_BUILTIN_STDARG)
#define va_start(ap, last) \
__builtin_stdarg_start((ap), (last))
@@ -67,6 +67,8 @@ typedef __va_list va_list;
(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
#define va_end(ap)
+#else
+#error this file needs to be ported to your compiler
#endif
#endif /* !_MACHINE_STDARG_H_ */
diff --git a/sys/amd64/include/varargs.h b/sys/amd64/include/varargs.h
index 1a58a47a8daa..3b9f542f28fd 100644
--- a/sys/amd64/include/varargs.h
+++ b/sys/amd64/include/varargs.h
@@ -43,7 +43,11 @@
#ifndef _MACHINE_VARARGS_H_
#define _MACHINE_VARARGS_H_
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
#include <sys/_types.h>
@@ -60,21 +64,17 @@ typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
#define va_arg(ap, type) __builtin_va_arg((ap), type)
#define va_end(ap) __builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* !__GNUCLIKE_BUILTIN_VARARGS */
typedef char *va_list;
#define __va_size(type) \
(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_BUILTIN_VAALIST
#define va_alist __builtin_va_alist
#endif
-#if __GNUC__ > 1
#define va_dcl int va_alist; ...
-#else
-#define va_dcl int va_alist;
-#endif
#define va_start(ap) \
((ap) = (va_list)&va_alist)
@@ -84,6 +84,6 @@ typedef char *va_list;
#define va_end(ap)
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
#endif /* !_MACHINE_VARARGS_H_ */
diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c
index 6e296e993e56..a95163e4f214 100644
--- a/sys/arm/arm/busdma_machdep.c
+++ b/sys/arm/arm/busdma_machdep.c
@@ -532,7 +532,7 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
{
vm_offset_t lastaddr = 0;
int error, nsegs = -1;
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS_DYNAMIC_ARRAY_INIT
bus_dma_segment_t dm_segments[dmat->nsegments];
#else
bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
@@ -564,7 +564,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0,
bus_dmamap_callback2_t *callback, void *callback_arg,
int flags)
{
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS_DYNAMIC_ARRAY_INIT
bus_dma_segment_t dm_segments[dmat->nsegments];
#else
bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
@@ -650,7 +650,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, struct uio *uio,
int flags)
{
vm_offset_t lastaddr;
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS_DYNAMIC_ARRAY_INIT
bus_dma_segment_t dm_segments[dmat->nsegments];
#else
bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
diff --git a/sys/arm/include/_types.h b/sys/arm/include/_types.h
index 57b1c7c1db8b..c700f523caf1 100644
--- a/sys/arm/include/_types.h
+++ b/sys/arm/include/_types.h
@@ -39,6 +39,10 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Basic types upon which most other types are built.
*/
@@ -49,7 +53,7 @@ typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
-#if defined(__GNUC__)
+#ifdef __GNUCLIKE_ATTRIBUTE_MODE_DI
typedef int __attribute__((__mode__(__DI__))) __int64_t;
typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
#else
@@ -105,12 +109,13 @@ typedef __uint32_t __vm_size_t;
/*
* Unusual type definitions.
*/
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
typedef __builtin_va_list __va_list; /* internally known to gcc */
#else
typedef char * __va_list;
-#endif /* post GCC 2.95 */
-#if defined __GNUC__ && !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST)
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
+#if defined(__GNUCLIKE_BUILTIN_VAALIST) && !defined(__GNUC_VA_LIST) \
+ && !defined(__NO_GNUC_VA_LIST)
#define __GNUC_VA_LIST
typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
#endif
diff --git a/sys/arm/include/limits.h b/sys/arm/include/limits.h
index 8e3bb11edfc3..35eea1f619de 100644
--- a/sys/arm/include/limits.h
+++ b/sys/arm/include/limits.h
@@ -33,7 +33,9 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#if __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
diff --git a/sys/arm/include/stdarg.h b/sys/arm/include/stdarg.h
index cf8aef59f239..a8b0ff0eae81 100644
--- a/sys/arm/include/stdarg.h
+++ b/sys/arm/include/stdarg.h
@@ -42,7 +42,7 @@
typedef __va_list va_list;
#endif
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifdef __GNUCLIKE_BUILTIN_STDARG
#define va_start(ap, last) \
__builtin_stdarg_start((ap), (last))
@@ -58,24 +58,24 @@ typedef __va_list va_list;
#define va_end(ap) \
__builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* !__GNUCLIKE_BUILTIN_STDARG */
#define __va_size(type) \
(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_BUILTIN_NEXT_ARG
#define va_start(ap, last) \
((ap) = (va_list)__builtin_next_arg(last))
-#else /* non-GNU compiler */
+#else /* !__GNUCLIKE_BUILTIN_NEXT_ARG */
#define va_start(ap, last) \
((ap) = (va_list)&(last) + __va_size(last))
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_BUILTIN_NEXT_ARG */
#define va_arg(ap, type) \
(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
#define va_end(ap)
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_STDARG */
#endif /* !_MACHINE_STDARG_H_ */
diff --git a/sys/boot/arc/include/arcfuncs.h b/sys/boot/arc/include/arcfuncs.h
index e88ff03a1c10..13e4792961f0 100644
--- a/sys/boot/arc/include/arcfuncs.h
+++ b/sys/boot/arc/include/arcfuncs.h
@@ -27,7 +27,14 @@
*
*/
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifndef _ARCFUNCS_H
+#define _ARCFUNCS_H
+
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
+#ifdef __CC_SUPPORTS_INLINE
#define INLINE inline
#else
#define INLINE /**/
@@ -197,3 +204,6 @@ VND_FN(3, u_int32_t, Print,
VND_FN(4, void, ReturnExtendedSystemInformation,
(EXTENDED_SYSTEM_INFORMATION *SystemInfo),
(SystemInfo))
+
+#endif /* _ARGFUNCS_H */
+
diff --git a/sys/boot/efi/include/ia64/efibind.h b/sys/boot/efi/include/ia64/efibind.h
index 73f346981ec4..07883b8ff011 100644
--- a/sys/boot/efi/include/ia64/efibind.h
+++ b/sys/boot/efi/include/ia64/efibind.h
@@ -18,8 +18,6 @@ Revision History
--*/
-#pragma pack()
-
#include <sys/stdint.h>
/* Basic EFI types of various widths. */
@@ -142,7 +140,7 @@ void __mf (void);
#ifdef NO_INTERFACE_DECL
#define INTERFACE_DECL(x)
#else
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS_FORWARD_REFERENCE_CONSTRUCT
#define INTERFACE_DECL(x) struct x
#else
#define INTERFACE_DECL(x) typedef struct x
diff --git a/sys/dev/cx/machdep.h b/sys/dev/cx/machdep.h
index c4affc46923a..a425af5b717d 100644
--- a/sys/dev/cx/machdep.h
+++ b/sys/dev/cx/machdep.h
@@ -75,6 +75,10 @@
# include <sys/systm.h>
# define memset(a,b,c) bzero (a,c)
# define port_t int
+
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
#endif
#endif
@@ -82,7 +86,7 @@
#endif
#ifndef inline
-# if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
+# ifdef __CC_SUPPORTS___INLINE__
# define inline __inline__
# else
# define inline /**/
diff --git a/sys/dev/ichsmb/ichsmb.c b/sys/dev/ichsmb/ichsmb.c
index 2d92a65f9fe5..8896745b3bee 100644
--- a/sys/dev/ichsmb/ichsmb.c
+++ b/sys/dev/ichsmb/ichsmb.c
@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
* Enable debugging by defining ICHSMB_DEBUG to a non-zero value.
*/
#define ICHSMB_DEBUG 0
-#if ICHSMB_DEBUG != 0 && (defined(__GNUC__) || defined(__INTEL_COMPILER))
+#if ICHSMB_DEBUG != 0 && defined(__CC_SUPPORTS___FUNC__)
#define DBG(fmt, args...) \
do { log(LOG_DEBUG, "%s: " fmt, __func__ , ## args); } while (0)
#else
diff --git a/sys/dev/iir/iir.h b/sys/dev/iir/iir.h
index 667a8d299ec2..ad5528d8bc7c 100644
--- a/sys/dev/iir/iir.h
+++ b/sys/dev/iir/iir.h
@@ -47,6 +47,10 @@
#ifndef _IIR_H
#define _IIR_H
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
#define IIR_DRIVER_VERSION 1
#define IIR_DRIVER_SUBVERSION 5
@@ -699,7 +703,7 @@ void iir_free(struct gdt_softc *);
void iir_attach(struct gdt_softc *);
void iir_intr(void *arg);
-#if defined( __GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __CC_SUPPORTS___INLINE__
/* These all require correctly aligned buffers */
static __inline__ void gdt_enc16(u_int8_t *, u_int16_t);
static __inline__ void gdt_enc32(u_int8_t *, u_int32_t);
diff --git a/sys/dev/isp/ispvar.h b/sys/dev/isp/ispvar.h
index b5aa8deed4c1..b3e7911dbea2 100644
--- a/sys/dev/isp/ispvar.h
+++ b/sys/dev/isp/ispvar.h
@@ -44,6 +44,9 @@
#include <dev/isp/isp_target.h>
#include <dev/isp/isp_tpublic.h>
#endif
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
#endif
#ifdef __linux__
#include "ispmbox.h"
@@ -760,7 +763,7 @@ int isp_async(struct ispsoftc *, ispasync_t, void *);
/*
* Platform Dependent Error and Debug Printout
*/
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ATTRIBUTE_PRINTF
void isp_prt(struct ispsoftc *, int level, const char *, ...)
__attribute__((__format__(__printf__,3,4)));
#else
diff --git a/sys/dev/mcd/mcdreg.h b/sys/dev/mcd/mcdreg.h
index 7a255afa04df..451fc5de76c3 100644
--- a/sys/dev/mcd/mcdreg.h
+++ b/sys/dev/mcd/mcdreg.h
@@ -47,12 +47,6 @@
#ifndef MCD_H
#define MCD_H
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
-#pragma pack(1)
-#endif
-#endif
-
/* toc */
#define MCD_MAXTOCS 104 /* from the Linux driver */
#define MCD_LASTPLUS1 170 /* special toc entry */
@@ -172,14 +166,14 @@ struct mcd_dma_mode {
u_char dma_mode;
u_char data0; /* If dma_mode & 0x10: Use IRQ settings */
u_char data1; /* Used if dma_mode & 0x01 */
-};
+} __packed;
struct mcd_volinfo {
bcd_t trk_low;
bcd_t trk_high;
bcd_t vol_msf[3];
bcd_t trk1_msf[3];
-};
+} __packed;
struct mcd_qchninfo {
u_char addr_type:4;
@@ -189,29 +183,29 @@ struct mcd_qchninfo {
bcd_t trk_size_msf[3];
u_char :8;
bcd_t hd_pos_msf[3];
-};
+} __packed;
struct mcd_volume {
u_char v0l;
u_char v0rs;
u_char v0r;
u_char v0ls;
-};
+} __packed;
struct mcd_holdtime {
u_char units_of_ten_seconds;
/* If this is 0, the default (12) is used */
-};
+} __packed;
struct mcd_read1 {
bcd_t start_msf[3];
u_char nsec[3];
-};
+} __packed;
struct mcd_read2 {
bcd_t start_msf[3];
bcd_t end_msf[3];
-};
+} __packed;
struct mcd_rawsector {
u_char sync1[12];
@@ -220,11 +214,6 @@ struct mcd_rawsector {
u_char subheader2[4];
u_char data[MCDBLK];
u_char ecc_bits[280];
-};
+} __packed;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
-#pragma pack(4)
-#endif
-#endif
#endif /* MCD_H */
diff --git a/sys/dev/mpt/mpilib/mpi_type.h b/sys/dev/mpt/mpilib/mpi_type.h
index c10cb92bbc8d..2fc483204def 100644
--- a/sys/dev/mpt/mpilib/mpi_type.h
+++ b/sys/dev/mpt/mpilib/mpi_type.h
@@ -46,6 +46,9 @@
#ifndef MPI_TYPE_H
#define MPI_TYPE_H
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
/*******************************************************************************
* Define MPI_POINTER if it hasn't already been defined. By default MPI_POINTER
@@ -68,7 +71,8 @@ typedef unsigned char U8;
typedef signed short S16;
typedef unsigned short U16;
-#if defined(unix) || defined(__arm) || defined(ALPHA) || defined(__GNUC__) || defined(__INTEL_COMPILER)
+#if defined(unix) || defined(__arm) || defined(ALPHA) \
+ || defined(__CC_INT_IS_32BIT)
typedef signed int S32;
typedef unsigned int U32;
diff --git a/sys/dev/random/nehemiah.c b/sys/dev/random/nehemiah.c
index c0dba9e5da83..9780dbd2755a 100644
--- a/sys/dev/random/nehemiah.c
+++ b/sys/dev/random/nehemiah.c
@@ -85,7 +85,7 @@ static union VIA_ACE_CW acw __aligned(16);
static __inline size_t
VIA_RNG_store(void *buf)
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
uint32_t retval = 0;
uint32_t rate = 0;
@@ -107,7 +107,7 @@ VIA_RNG_store(void *buf)
static __inline void
VIA_ACE_cbc(void *in, void *out, size_t count, void *key, union VIA_ACE_CW *cw, void *iv)
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
/* The .byte line is really VIA C3 "xcrypt-cbc" instruction */
__asm __volatile(
"pushf \n\t"
diff --git a/sys/dev/scd/scdreg.h b/sys/dev/scd/scdreg.h
index 38e2293bc7d8..c98c6ca630a6 100644
--- a/sys/dev/scd/scdreg.h
+++ b/sys/dev/scd/scdreg.h
@@ -32,12 +32,6 @@
#ifndef SCD_H
#define SCD_H
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
-#pragma pack(1)
-#endif
-#endif
-
typedef unsigned char bcd_t;
#define M_msf(msf) msf[0]
#define S_msf(msf) msf[1]
@@ -94,7 +88,7 @@ struct sony_drive_configuration {
char product[16];
char revision[8];
u_short config;
-};
+} __packed;
/* Almost same as cd_sub_channel_position_data */
struct sony_subchannel_position_data {
@@ -105,14 +99,14 @@ struct sony_subchannel_position_data {
u_char rel_msf[3];
u_char dummy;
u_char abs_msf[3];
-};
+} __packed;
struct sony_tracklist {
u_char adr :4; /* xcdplayer needs these two values */
u_char ctl :4;
u_char track;
u_char start_msf[3];
-};
+} __packed;
#define MAX_TRACKS 100
@@ -140,6 +134,6 @@ struct sony_toc {
/* The rest is just to take space in case all data is returned */
u_char dummy[6*9];
-};
+} __packed;
#endif /* SCD_H */
diff --git a/sys/i386/acpica/acpi_wakeup.c b/sys/i386/acpica/acpi_wakeup.c
index 400d9f15388a..fa5e784eba3d 100644
--- a/sys/i386/acpica/acpi_wakeup.c
+++ b/sys/i386/acpica/acpi_wakeup.c
@@ -52,6 +52,10 @@ __FBSDID("$FreeBSD$");
#include "acpi_wakecode.h"
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
extern uint32_t acpi_reset_video;
extern void initializecpu(void);
@@ -73,7 +77,7 @@ static void acpi_alloc_wakeup_handler(void);
extern int acpi_savecpu(void);
extern int acpi_restorecpu(void);
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm__(" \n\
.text \n\
.p2align 2, 0x90 \n\
@@ -140,7 +144,7 @@ acpi_savecpu: \n\
movl $1,%eax \n\
ret \n\
");
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM */
static void
acpi_printcpu(void)
diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c
index 8b9d9895abd9..8c8e1218ed41 100644
--- a/sys/i386/i386/identcpu.c
+++ b/sys/i386/i386/identcpu.c
@@ -776,7 +776,7 @@ static volatile u_int trap_by_rdmsr;
* be advanced.
*/
inthand_t bluetrap6;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm
(" \n\
.text \n\
@@ -795,7 +795,7 @@ __asm
* Accessing non-existent MSR generates general protection fault.
*/
inthand_t bluetrap13;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm
(" \n\
.text \n\
diff --git a/sys/i386/i386/in_cksum.c b/sys/i386/i386/in_cksum.c
index a236245a42db..412a93b69e95 100644
--- a/sys/i386/i386/in_cksum.c
+++ b/sys/i386/i386/in_cksum.c
@@ -57,7 +57,11 @@ __FBSDID("$FreeBSD$");
#undef ADDCARRY
#define ADDCARRY(x) if ((x) > 0xffff) (x) -= 0xffff
-#if !defined(__GNUC__) || defined(__INTEL_COMPILER)
+/*
+ * icc needs to be special cased here, as the asm code below results
+ * in broken code if compiled with icc.
+ */
+#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER)
/* non gcc parts stolen from sys/alpha/alpha/in_cksum.c */
#define REDUCE32 \
{ \
@@ -74,7 +78,7 @@ __FBSDID("$FreeBSD$");
#endif
#define REDUCE {sum = (sum & 0xffff) + (sum >> 16); ADDCARRY(sum);}
-#if !defined(__GNUC__) || defined(__INTEL_COMPILER)
+#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER)
static const u_int32_t in_masks[] = {
/*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/
0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */
diff --git a/sys/i386/include/_types.h b/sys/i386/include/_types.h
index 9884c83247c6..7df734df7735 100644
--- a/sys/i386/include/_types.h
+++ b/sys/i386/include/_types.h
@@ -39,6 +39,10 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Basic types upon which most other types are built.
*/
@@ -54,7 +58,7 @@ typedef unsigned int __uint32_t;
typedef long long __int64_t;
/* LONGLONG */
typedef unsigned long long __uint64_t;
-#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
+#elif defined(__GNUCLIKE_ATTRIBUTE_MODE_DI)
typedef int __attribute__((__mode__(__DI__))) __int64_t;
typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
#else
@@ -114,12 +118,13 @@ typedef __uint32_t __vm_size_t;
/*
* Unusual type definitions.
*/
-#if (defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER))
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
typedef __builtin_va_list __va_list; /* internally known to gcc */
#else
typedef char * __va_list;
-#endif /* ! (__GNUC__ post 2.95 || __INTEL_COMPILER) */
-#if defined(__GNUC__) && !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST)
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
+#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
+ && !defined(__NO_GNUC_VA_LIST)
#define __GNUC_VA_LIST
typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
#endif
diff --git a/sys/i386/include/atomic.h b/sys/i386/include/atomic.h
index 5b9ef4270635..219a33bbd184 100644
--- a/sys/i386/include/atomic.h
+++ b/sys/i386/include/atomic.h
@@ -28,6 +28,10 @@
#ifndef _MACHINE_ATOMIC_H_
#define _MACHINE_ATOMIC_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Various simple arithmetic on memory which is atomic in the presence
* of interrupts and multiple processors.
@@ -75,7 +79,7 @@ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
#else /* !KLD_MODULE */
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
/*
* For userland, assume the SMP case and use lock prefixes so that
@@ -101,12 +105,12 @@ atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
} \
struct __hack
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
+#else /* !__GNUCLIKE_ASM */
#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
extern void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM */
/*
* Atomic compare and set, used by the mutex functions
@@ -116,7 +120,7 @@ extern void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
* Returns 0 on failure, non-zero on success
*/
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
#if defined(CPU_DISABLE_CMPXCHG)
@@ -168,9 +172,9 @@ atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
#endif /* defined(CPU_DISABLE_CMPXCHG) */
-#endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */
+#endif /* __GNUCLIKE_ASM */
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
#if defined(_KERNEL) && !defined(SMP)
@@ -226,7 +230,7 @@ struct __hack
#endif /* !defined(SMP) */
-#else /* !(defined(__GNUC__) || defined(__INTEL_COMPILER)) */
+#else /* !__GNUCLIKE_ASM */
extern int atomic_cmpset_int(volatile u_int *, u_int, u_int);
@@ -234,7 +238,7 @@ extern int atomic_cmpset_int(volatile u_int *, u_int, u_int);
extern u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p); \
extern void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
-#endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */
+#endif /* __GNUCLIKE_ASM */
#endif /* KLD_MODULE */
@@ -410,7 +414,7 @@ ATOMIC_PTR(subtract)
#undef ATOMIC_PTR
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
static __inline u_int
atomic_readandclear_int(volatile u_int *addr)
@@ -442,12 +446,12 @@ atomic_readandclear_long(volatile u_long *addr)
return (result);
}
-#else /* !(defined(__GNUC__) || defined(__INTEL_COMPILER)) */
+#else /* !__GNUCLIKE_ASM */
extern u_long atomic_readandclear_long(volatile u_long *);
extern u_int atomic_readandclear_int(volatile u_int *);
-#endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */
+#endif /* __GNUCLIKE_ASM */
#endif /* !defined(WANT_FUNCTIONS) */
#endif /* ! _MACHINE_ATOMIC_H_ */
diff --git a/sys/i386/include/bus_at386.h b/sys/i386/include/bus_at386.h
index 4600e3568b10..83302b93de22 100644
--- a/sys/i386/include/bus_at386.h
+++ b/sys/i386/include/bus_at386.h
@@ -72,6 +72,10 @@
#ifndef _I386_BUS_AT386_H_
#define _I386_BUS_AT386_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
#include <machine/cpufunc.h>
/*
@@ -292,7 +296,7 @@ bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: movb (%2),%%al \n\
@@ -325,7 +329,7 @@ bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: movw (%2),%%ax \n\
@@ -358,7 +362,7 @@ bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: movl (%2),%%eax \n\
@@ -411,7 +415,7 @@ bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: inb %w2,%%al \n\
@@ -434,7 +438,7 @@ bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -461,7 +465,7 @@ bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: inw %w2,%%ax \n\
@@ -484,7 +488,7 @@ bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -511,7 +515,7 @@ bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: inl %w2,%%eax \n\
@@ -534,7 +538,7 @@ bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -667,7 +671,7 @@ bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsb \n\
@@ -700,7 +704,7 @@ bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsw \n\
@@ -733,7 +737,7 @@ bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
else
#endif
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsl \n\
@@ -787,7 +791,7 @@ bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsb \n\
@@ -810,7 +814,7 @@ bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -837,7 +841,7 @@ bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsw \n\
@@ -860,7 +864,7 @@ bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -887,7 +891,7 @@ bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
1: lodsl \n\
@@ -910,7 +914,7 @@ bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
#endif
{
int _port_ = bsh + offset;
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm __volatile(" \n\
cld \n\
repne \n\
@@ -1293,7 +1297,7 @@ static __inline void
bus_space_barrier(bus_space_tag_t tag __unused, bus_space_handle_t bsh __unused,
bus_size_t offset __unused, bus_size_t len __unused, int flags)
{
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
if (flags & BUS_SPACE_BARRIER_READ)
__asm __volatile("lock; addl $0,0(%%esp)" : : : "memory");
else
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h
index 01f5c56c7fa0..ecb84cdcd665 100644
--- a/sys/i386/include/cpufunc.h
+++ b/sys/i386/include/cpufunc.h
@@ -38,6 +38,10 @@
#ifndef _MACHINE_CPUFUNC_H_
#define _MACHINE_CPUFUNC_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
struct region_descriptor;
#define readb(va) (*(volatile u_int8_t *) (va))
@@ -48,7 +52,7 @@ struct region_descriptor;
#define writew(va, d) (*(volatile u_int16_t *) (va) = (d))
#define writel(va, d) (*(volatile u_int32_t *) (va) = (d))
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
static __inline void
breakpoint(void)
@@ -126,12 +130,12 @@ halt(void)
__asm __volatile("hlt");
}
-#if __GNUC__ < 2
+#if !defined(__GNUCLIKE_BUILTIN_CONSTANT_P) || __GNUCLIKE_ASM < 3
#define inb(port) inbv(port)
#define outb(port, data) outbv(port, data)
-#else /* __GNUC >= 2 */
+#else /* __GNUCLIKE_BUILTIN_CONSTANT_P && __GNUCLIKE_ASM >= 3 */
/*
* The following complications are to get around gcc not having a
@@ -178,7 +182,7 @@ outbc(u_int port, u_char data)
__asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port)));
}
-#endif /* __GNUC <= 2 */
+#endif /* __GNUCLIKE_BUILTIN_CONSTANT_P && __GNUCLIKE_ASM >= 3*/
static __inline u_char
inbv(u_int port)
@@ -618,7 +622,7 @@ intr_restore(register_t eflags)
write_eflags(eflags);
}
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
+#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
int breakpoint(void);
u_int bsfl(u_int mask);
@@ -683,7 +687,7 @@ void wbinvd(void);
void write_eflags(u_int ef);
void wrmsr(u_int msr, u_int64_t newval);
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
void reset_dbregs(void);
diff --git a/sys/i386/include/critical.h b/sys/i386/include/critical.h
index 9826988322d3..58af490639f6 100644
--- a/sys/i386/include/critical.h
+++ b/sys/i386/include/critical.h
@@ -46,7 +46,7 @@ __BEGIN_DECLS
*/
void cpu_critical_fork_exit(void);
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __CC_SUPPORTS___INLINE
/*
* cpu_critical_enter:
@@ -81,12 +81,12 @@ cpu_critical_exit(struct thread *td)
intr_restore(td->td_md.md_savecrit);
}
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
+#else /* !__CC_SUPPORTS___INLINE */
void cpu_critical_enter(struct thread *td);
void cpu_critical_exit(struct thread *td);
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __CC_SUPPORTS___INLINE */
__END_DECLS
diff --git a/sys/i386/include/endian.h b/sys/i386/include/endian.h
index 13d596a9ce70..59fa4a5e9cc5 100644
--- a/sys/i386/include/endian.h
+++ b/sys/i386/include/endian.h
@@ -67,17 +67,7 @@ extern "C" {
#define BYTE_ORDER _BYTE_ORDER
#endif
-#if defined(__INTEL_COMPILER)
-#if defined(__cplusplus)
-#if __INTEL_COMPILER >= 800
-#define __INTEL_COMPILER_with_FreeBSD_endian 1
-#endif
-#else
-#define __INTEL_COMPILER_with_FreeBSD_endian 1
-#endif
-#endif
-
-#if defined(__GNUC__) || defined(__INTEL_COMPILER_with_FreeBSD_endian)
+#if defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE_BUILTIN_CONSTANT_P)
#define __word_swap_int_var(x) \
__extension__ ({ register __uint32_t __X = (x); \
@@ -168,7 +158,7 @@ __bswap16(__uint16_t _x)
#define __ntohl(x) __bswap32(x)
#define __ntohs(x) __bswap16(x)
-#else /* !(__GNUC__ || __INTEL_COMPILER_with_FreeBSD_endian) */
+#else /* !(__GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P) */
/*
* No optimizations are available for this compiler. Fall back to
@@ -177,7 +167,7 @@ __bswap16(__uint16_t _x)
*/
#define _BYTEORDER_FUNC_DEFINED
-#endif /* __GNUC__ || __INTEL_COMPILER_with_FreeBSD_endian */
+#endif /* __GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P */
#ifdef __cplusplus
}
diff --git a/sys/i386/include/ieeefp.h b/sys/i386/include/ieeefp.h
index 48011f71aea1..17dbc8811b5e 100644
--- a/sys/i386/include/ieeefp.h
+++ b/sys/i386/include/ieeefp.h
@@ -41,6 +41,10 @@
#ifndef _MACHINE_IEEEFP_H_
#define _MACHINE_IEEEFP_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* FP rounding modes
*/
@@ -98,7 +102,7 @@ typedef enum {
#define FP_RND_OFF 10 /* round control offset */
#define FP_STKY_OFF 0 /* sticky flags offset */
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
@@ -151,7 +155,7 @@ __fpsetreg(int _m, int _reg, int _fld, int _off)
return _p;
}
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM */
/*
* SysV/386 FP control interface
diff --git a/sys/i386/include/in_cksum.h b/sys/i386/include/in_cksum.h
index 27d1195a7723..062c675c8e77 100644
--- a/sys/i386/include/in_cksum.h
+++ b/sys/i386/include/in_cksum.h
@@ -35,6 +35,10 @@
#ifndef _MACHINE_IN_CKSUM_H_
#define _MACHINE_IN_CKSUM_H_ 1
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* MP safe (alfred)
*/
@@ -49,7 +53,7 @@
* in the normal case (where there are no options and the header length is
* therefore always exactly five 32-bit words.
*/
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#if defined(__GNUCLIKE_ASM) && !defined(__INTEL_COMPILER)
static __inline u_int
in_cksum_hdr(const struct ip *ip)
{
@@ -119,7 +123,7 @@ in_pseudo(u_int sum, u_int b, u_int c)
#endif
#ifdef _KERNEL
-#if !defined(__GNUC__) || defined(__INTEL_COMPILER)
+#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER)
u_int in_cksum_hdr(const struct ip *ip);
u_short in_addword(u_short sum, u_short b);
u_short in_pseudo(u_int sum, u_int b, u_int c);
diff --git a/sys/i386/include/ioctl_bt848.h b/sys/i386/include/ioctl_bt848.h
index c87c4b9320a4..ca83a36cdb5a 100644
--- a/sys/i386/include/ioctl_bt848.h
+++ b/sys/i386/include/ioctl_bt848.h
@@ -29,7 +29,9 @@
#ifndef _MACHINE_IOCTL_BT848_H_
#define _MACHINE_IOCTL_BT848_H_
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning Include dev/bktr/ioctl_bt848.h instead of this header.
#endif
diff --git a/sys/i386/include/ioctl_meteor.h b/sys/i386/include/ioctl_meteor.h
index c9595ded5bb1..0322f1ede2c1 100644
--- a/sys/i386/include/ioctl_meteor.h
+++ b/sys/i386/include/ioctl_meteor.h
@@ -29,7 +29,9 @@
#ifndef _MACHINE_IOCTL_METEOR_H_
#define _MACHINE_IOCTL_METEOR_H_
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning Include dev/bktr/ioctl_meteor.h instead of this header.
#endif
diff --git a/sys/i386/include/limits.h b/sys/i386/include/limits.h
index 8e3bb11edfc3..35eea1f619de 100644
--- a/sys/i386/include/limits.h
+++ b/sys/i386/include/limits.h
@@ -33,7 +33,9 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#if __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h
index 6552ea9fa449..f371e39a5c21 100644
--- a/sys/i386/include/pcpu.h
+++ b/sys/i386/include/pcpu.h
@@ -29,6 +29,10 @@
#ifndef _MACHINE_PCPU_H_
#define _MACHINE_PCPU_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
#ifdef _KERNEL
#include <machine/segments.h>
@@ -59,7 +63,8 @@ extern struct pcpu *pcpup;
#define PCPU_PTR(member) (&pcpup->pc_ ## member)
#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
-#elif defined(__GNUC__) || defined (__INTEL_COMPILER)
+#elif defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) \
+ && defined(__GNUCLIKE___OFFSETOF)
/*
* Evaluates to the byte offset of the per-cpu variable name.
@@ -162,7 +167,7 @@ __curthread(void)
#define curthread (__curthread())
#else
-#error gcc or lint is required to use this file
+#error this file needs to be ported to your compiler
#endif
#endif /* _KERNEL */
diff --git a/sys/i386/include/profile.h b/sys/i386/include/profile.h
index 79dd308598ce..06418ebad19d 100644
--- a/sys/i386/include/profile.h
+++ b/sys/i386/include/profile.h
@@ -33,6 +33,10 @@
#ifndef _MACHINE_PROFILE_H_
#define _MACHINE_PROFILE_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
#ifdef _KERNEL
/*
@@ -53,7 +57,7 @@
#define MCOUNT_DECL(s)
#define MCOUNT_ENTER(s)
#define MCOUNT_EXIT(s)
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
#define MCOUNT_OVERHEAD(label) \
__asm __volatile("pushl %0; call __mcount; popl %%ecx" \
: \
@@ -71,7 +75,7 @@
#define MEXITCOUNT_OVERHEAD_GETLABEL()
#else
#error
-#endif /* !(__GNUC__ || __INTEL_COMPILER) */
+#endif /* !__GNUCLIKE_ASM */
#else /* !GUPROF */
#define MCOUNT_DECL(s) u_long s;
#ifdef SMP
@@ -106,7 +110,7 @@ void user(void);
#define _MCOUNT_DECL static __inline void _mcount
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
#define MCOUNT \
void \
mcount() \
@@ -129,13 +133,13 @@ mcount() \
frompc = ((uintfptr_t *)frompc)[1]; \
_mcount(frompc, selfpc); \
}
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
+#else /* !__GNUCLIKE_ASM */
void \
#define MCOUNT \
mcount() \
{ \
}
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM */
typedef u_int uintfptr_t;
@@ -156,7 +160,7 @@ void mcount(uintfptr_t frompc, uintfptr_t selfpc);
#include <sys/cdefs.h>
__BEGIN_DECLS
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
void mcount(void) __asm(".mcount");
#endif
__END_DECLS
diff --git a/sys/i386/include/stdarg.h b/sys/i386/include/stdarg.h
index ce59c7f4813a..a8ef25e62239 100644
--- a/sys/i386/include/stdarg.h
+++ b/sys/i386/include/stdarg.h
@@ -46,7 +46,7 @@
typedef __va_list va_list;
#endif
-#if (defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER))
+#ifdef __GNUCLIKE_BUILTIN_STDARG
#define va_start(ap, last) \
__builtin_stdarg_start((ap), (last))
@@ -62,18 +62,18 @@ typedef __va_list va_list;
#define va_end(ap) \
__builtin_va_end(ap)
-#else /* ! (__GNUC__ post GCC 2.95 || __INTEL_COMPILER) */
+#else /* !__GNUCLIKE_BUILTIN_STDARG */
#define __va_size(type) \
(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_BUILTIN_NEXT_ARG
#define va_start(ap, last) \
((ap) = (va_list)__builtin_next_arg(last))
-#else /* non-GNU compiler */
+#else /* !__GNUCLIKE_BUILTIN_NEXT_ARG */
#define va_start(ap, last) \
((ap) = (va_list)&(last) + __va_size(last))
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_BUILTIN_NEXT_ARG */
#define va_arg(ap, type) \
(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
@@ -85,6 +85,6 @@ typedef __va_list va_list;
#define va_end(ap)
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_STDARG */
#endif /* !_MACHINE_STDARG_H_ */
diff --git a/sys/i386/include/varargs.h b/sys/i386/include/varargs.h
index 4d05f875b8fa..a71b2ffc8a04 100644
--- a/sys/i386/include/varargs.h
+++ b/sys/i386/include/varargs.h
@@ -39,7 +39,11 @@
#ifndef _MACHINE_VARARGS_H_
#define _MACHINE_VARARGS_H_
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
#include <sys/_types.h>
@@ -56,17 +60,17 @@ typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
#define va_arg(ap, type) __builtin_va_arg((ap), type)
#define va_end(ap) __builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* !__GNUCLIKE_BUILTIN_VARARGS */
typedef char *va_list;
#define __va_size(type) \
(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-#ifdef __GNUC__
+#if defined(__GNUCLIKE_BUILTIN_VAALIST)
#define va_alist __builtin_va_alist
#endif
-#if __GNUC__ > 1
+#ifdef __CC_SUPPORTS_VARADIC_XXX
#define va_dcl int va_alist; ...
#else
#define va_dcl int va_alist;
@@ -80,6 +84,6 @@ typedef char *va_list;
#define va_end(ap)
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
#endif /* !_MACHINE_VARARGS_H_ */
diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c
index 4a80533d5917..6db89704b7c8 100644
--- a/sys/i386/isa/npx.c
+++ b/sys/i386/isa/npx.c
@@ -95,7 +95,7 @@ __FBSDID("$FreeBSD$");
#define NPX_DISABLE_I586_OPTIMIZED_BZERO (1 << 1)
#define NPX_DISABLE_I586_OPTIMIZED_COPYIO (1 << 2)
-#if (defined(__GNUC__) && !defined(lint)) || defined(__INTEL_COMPILER)
+#if defined(__GNUCLIKE_ASM) && !defined(lint)
#define fldcw(addr) __asm("fldcw %0" : : "m" (*(addr)))
#define fnclex() __asm("fnclex")
@@ -113,7 +113,7 @@ __FBSDID("$FreeBSD$");
: : "n" (CR0_TS) : "ax")
#define stop_emulating() __asm("clts")
-#else /* !((__GNUC__ && !lint ) || __INTEL_COMPILER) */
+#else /* !(__GNUCLIKE_ASM && !lint) */
void fldcw(caddr_t addr);
void fnclex(void);
@@ -130,7 +130,7 @@ void fxrstor(caddr_t addr);
void start_emulating(void);
void stop_emulating(void);
-#endif /* (__GNUC__ && !lint ) || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM && !lint */
#ifdef CPU_ENABLE_SSE
#define GET_FPU_CW(thread) \
diff --git a/sys/i386/isa/prof_machdep.c b/sys/i386/isa/prof_machdep.c
index 57d234262b78..616be3e2c4ea 100644
--- a/sys/i386/isa/prof_machdep.c
+++ b/sys/i386/isa/prof_machdep.c
@@ -69,7 +69,7 @@ static struct gmonparam saved_gmp;
#endif
#endif /* GUPROF */
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm(" \n\
GM_STATE = 0 \n\
GMON_PROF_OFF = 3 \n\
@@ -122,9 +122,9 @@ __cyg_profile_func_enter: \n\
.mcount_exit: \n\
ret \n\
");
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
-#error
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#else /* !__GNUCLIKE_ASM */
+#error this file needs to be ported to your compiler
+#endif /* __GNUCLIKE_ASM */
#ifdef GUPROF
/*
@@ -133,7 +133,7 @@ __cyg_profile_func_enter: \n\
* dependent file together with cputime(), __mcount and [.]mcount. cputime()
* can't just be put in machdep.c because it has to be compiled without -pg.
*/
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm(" \n\
.text \n\
# \n\
@@ -168,9 +168,7 @@ __cyg_profile_func_exit: \n\
.mexitcount_exit: \n\
ret \n\
");
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
-#error
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM */
/*
* Return the time elapsed since the last call. The units are machine-
@@ -353,7 +351,7 @@ stopguprof(gp)
}
#else /* !GUPROF */
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE_ASM
__asm(" \n\
.text \n\
.p2align 4,0x90 \n\
@@ -361,7 +359,5 @@ __asm(" \n\
" __XSTRING(HIDENAME(mexitcount)) ": \n\
ret \n\
");
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
-#error
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE_ASM */
#endif /* GUPROF */
diff --git a/sys/ia64/include/_types.h b/sys/ia64/include/_types.h
index 5809f630d889..8fc1be2f3873 100644
--- a/sys/ia64/include/_types.h
+++ b/sys/ia64/include/_types.h
@@ -39,6 +39,10 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Basic types upon which most other types are built.
*/
@@ -97,9 +101,10 @@ typedef __uint64_t __vm_size_t;
/*
* Unusual type definitions.
*/
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
typedef __builtin_va_list __va_list; /* internally known to gcc */
-#if !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST)
+#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
+ && !defined(__NO_GNUC_VA_LIST)
#define __GNUC_VA_LIST
typedef __va_list __gnuc_va_list; /* compat. with GNU headers */
#endif
@@ -109,6 +114,6 @@ typedef char * __va_list; /* non-functional */
#else
#error Must add va_list support for this non-GCC compiler.
#endif /* lint */
-#endif /* __GNUC__ */
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
#endif /* !_MACHINE__TYPES_H_ */
diff --git a/sys/ia64/include/cpufunc.h b/sys/ia64/include/cpufunc.h
index 29563fe8b83e..27d66ef63947 100644
--- a/sys/ia64/include/cpufunc.h
+++ b/sys/ia64/include/cpufunc.h
@@ -35,11 +35,15 @@
#include <machine/ia64_cpu.h>
#include <machine/vmparam.h>
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
struct thread;
#define IA64_FIXED_BREAK 0x84B5D
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
static __inline void
breakpoint(void)
@@ -50,8 +54,6 @@ breakpoint(void)
#define HAVE_INLINE_FFS
#define ffs(x) __builtin_ffs(x)
-#endif
-
extern uint64_t ia64_port_base;
#define __MEMIO_ADDR(x) (__volatile void*)(IA64_PHYS_TO_RR6(x))
#define __PIO_ADDR(x) (__volatile void*)(ia64_port_base | \
@@ -208,6 +210,8 @@ intr_restore(register_t ie)
enable_intr();
}
+#endif /* __GNUCLIKE_ASM */
+
#endif /* _KERNEL */
#endif /* !_MACHINE_CPUFUNC_H_ */
diff --git a/sys/ia64/include/critical.h b/sys/ia64/include/critical.h
index 08c7d61f9f1f..26f2edd4e796 100644
--- a/sys/ia64/include/critical.h
+++ b/sys/ia64/include/critical.h
@@ -46,7 +46,7 @@ __BEGIN_DECLS
*/
void cpu_critical_fork_exit(void);
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
/*
* cpu_critical_enter:
@@ -76,12 +76,12 @@ cpu_critical_exit(struct thread *td)
}
-#else /* !__GNUC__ */
+#else /* !__CC_SUPPORTS___INLINE */
void cpu_critical_enter(struct thread *td)
void cpu_critical_exit(struct thread *td)
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE */
__END_DECLS
diff --git a/sys/ia64/include/endian.h b/sys/ia64/include/endian.h
index 2293dde7cd07..5b3d9788fe69 100644
--- a/sys/ia64/include/endian.h
+++ b/sys/ia64/include/endian.h
@@ -64,7 +64,7 @@
#define BYTE_ORDER _BYTE_ORDER
#endif
-#ifdef __GNUC__
+#if defined(__CC_SUPPORTS___INLINE) && defined(__GNUCLIKE_ASM)
static __inline __uint64_t
__bswap64(__uint64_t _x)
@@ -95,7 +95,7 @@ __bswap16(__uint16_t _x)
#define __ntohl(x) __bswap32(x)
#define __ntohs(x) __bswap16(x)
-#else /* !__GNUC__ */
+#else /* !(__CC_SUPPORTS___INLINE && __GNUCLIKE_ASM) */
/*
* No optimizations are available for this compiler. Fall back to
@@ -104,6 +104,6 @@ __bswap16(__uint16_t _x)
*/
#define _BYTEORDER_FUNC_DEFINED
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE && __GNUCLIKE_ASM */
#endif /* !_MACHINE_ENDIAN_H_ */
diff --git a/sys/ia64/include/in_cksum.h b/sys/ia64/include/in_cksum.h
index a899ef0d8488..09920062a0ae 100644
--- a/sys/ia64/include/in_cksum.h
+++ b/sys/ia64/include/in_cksum.h
@@ -45,7 +45,7 @@
* in the normal case (where there are no options and the header length is
* therefore always exactly five 32-bit words.
*/
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
static __inline void
in_cksum_update(struct ip *ip)
diff --git a/sys/ia64/include/limits.h b/sys/ia64/include/limits.h
index c26df92cb7d6..62772bcc48b1 100644
--- a/sys/ia64/include/limits.h
+++ b/sys/ia64/include/limits.h
@@ -35,7 +35,9 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#if __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
diff --git a/sys/ia64/include/stdarg.h b/sys/ia64/include/stdarg.h
index 51dde800de58..9ab18b8c0e8f 100644
--- a/sys/ia64/include/stdarg.h
+++ b/sys/ia64/include/stdarg.h
@@ -46,7 +46,7 @@
typedef __va_list va_list;
#endif
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#if defined(__GNUCLIKE_BUILTIN_STDARG)
#define va_start(ap, last) \
__builtin_stdarg_start((ap), (last))
diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c
index ba36093aca2d..0e2379d52cb3 100644
--- a/sys/kern/subr_prof.c
+++ b/sys/kern/subr_prof.c
@@ -543,8 +543,8 @@ out:
PROC_UNLOCK(p);
}
-#if (defined(__amd64__) || defined(__i386__)) && __GNUC__ >= 2 && \
- !defined(__INTEL_COMPILER)
+#if (defined(__amd64__) || defined(__i386__)) && \
+ defined(__GNUCLIKE_CTOR_SECTION_HANDLING)
/*
* Support for "--test-coverage --profile-arcs" in GCC.
*
diff --git a/sys/powerpc/include/_types.h b/sys/powerpc/include/_types.h
index 32fe2e3f1e66..c6babcf4a108 100644
--- a/sys/powerpc/include/_types.h
+++ b/sys/powerpc/include/_types.h
@@ -39,6 +39,10 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Basic types upon which most other types are built.
*/
@@ -54,7 +58,7 @@ typedef unsigned int __uint32_t;
typedef long long __int64_t;
/* LONGLONG */
typedef unsigned long long __uint64_t;
-#elif defined(__GNUC__)
+#elif defined(__GNUCLIKE_ATTRIBUTE_MODE_DI)
typedef int __attribute__((__mode__(__DI__))) __int64_t;
typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
#else
@@ -110,7 +114,7 @@ typedef __uint32_t __vm_size_t;
/*
* Unusual type definitions.
*/
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#if defined(__GNUCLIKE_BUILTIN_VARARGS)
typedef __builtin_va_list __va_list; /* internally known to gcc */
#else
typedef struct {
@@ -121,7 +125,8 @@ typedef struct {
char *__base;
} __va_list;
#endif /* post GCC 2.95 */
-#if defined __GNUC__ && !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST)
+#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
+ && !defined(__NO_GNUC_VA_LIST)
#define __GNUC_VA_LIST
typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
#endif
diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h
index dee4c84fe68c..ad23a3fb1254 100644
--- a/sys/powerpc/include/atomic.h
+++ b/sys/powerpc/include/atomic.h
@@ -33,6 +33,10 @@
#include <machine/cpufunc.h>
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Various simple arithmetic on memory which is atomic in the presence
* of interrupts and SMP safe.
@@ -53,7 +57,7 @@ atomic_set_32(volatile uint32_t *p, uint32_t v)
{
uint32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tlwarx %0, 0, %2\n\t" /* load old value */
"or %0, %3, %0\n\t" /* calculate new value */
@@ -70,7 +74,7 @@ atomic_clear_32(volatile uint32_t *p, uint32_t v)
{
uint32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tlwarx %0, 0, %2\n\t" /* load old value */
"andc %0, %0, %3\n\t" /* calculate new value */
@@ -87,7 +91,7 @@ atomic_add_32(volatile uint32_t *p, uint32_t v)
{
uint32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tlwarx %0, 0, %2\n\t" /* load old value */
"add %0, %3, %0\n\t" /* calculate new value */
@@ -104,7 +108,7 @@ atomic_subtract_32(volatile uint32_t *p, uint32_t v)
{
uint32_t temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tlwarx %0, 0, %2\n\t" /* load old value */
"subf %0, %3, %0\n\t" /* calculate new value */
@@ -121,7 +125,7 @@ atomic_readandclear_32(volatile uint32_t *addr)
{
uint32_t result,temp;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"\tsync\n" /* drain writes */
"1:\tlwarx %0, 0, %3\n\t" /* load old value */
@@ -348,7 +352,7 @@ atomic_cmpset_32(volatile uint32_t* p, uint32_t cmpval, uint32_t newval)
{
uint32_t ret;
-#ifdef __GNUC__
+#ifdef __GNUCLIKE_ASM
__asm __volatile (
"1:\tlwarx %0, 0, %2\n\t" /* load old value */
"cmplw %3, %0\n\t" /* compare */
diff --git a/sys/powerpc/include/critical.h b/sys/powerpc/include/critical.h
index cc0768af4d3b..405bc57f0422 100644
--- a/sys/powerpc/include/critical.h
+++ b/sys/powerpc/include/critical.h
@@ -46,7 +46,7 @@ __BEGIN_DECLS
*/
void cpu_critical_fork_exit(void);
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
/*
* cpu_critical_enter:
@@ -77,12 +77,12 @@ cpu_critical_exit(struct thread *td)
}
-#else /* !__GNUC__ */
+#else /* !__CC_SUPPORTS___INLINE */
void cpu_critical_enter(struct thread *td);
void cpu_critical_exit(struct thread *td);
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE */
__END_DECLS
diff --git a/sys/powerpc/include/endian.h b/sys/powerpc/include/endian.h
index af8f030abad6..bc96b9e4fc81 100644
--- a/sys/powerpc/include/endian.h
+++ b/sys/powerpc/include/endian.h
@@ -65,7 +65,7 @@
#define BYTE_ORDER _BYTE_ORDER
#endif
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
static __inline __uint16_t
__bswap16(__uint16_t _x)
@@ -97,7 +97,7 @@ __bswap64(__uint64_t _x)
#define __ntohl(x) ((__uint32_t)(x))
#define __ntohs(x) ((__uint16_t)(x))
-#else /* !__GNUC__ */
+#else /* !__CC_SUPPORTS___INLINE */
/*
* No optimizations are available for this compiler. Fall back to
@@ -106,6 +106,6 @@ __bswap64(__uint64_t _x)
*/
#define _BYTEORDER_FUNC_DEFINED
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE */
#endif /* !_MACHINE_ENDIAN_H_ */
diff --git a/sys/powerpc/include/in_cksum.h b/sys/powerpc/include/in_cksum.h
index a899ef0d8488..09920062a0ae 100644
--- a/sys/powerpc/include/in_cksum.h
+++ b/sys/powerpc/include/in_cksum.h
@@ -45,7 +45,7 @@
* in the normal case (where there are no options and the header length is
* therefore always exactly five 32-bit words.
*/
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
static __inline void
in_cksum_update(struct ip *ip)
diff --git a/sys/powerpc/include/limits.h b/sys/powerpc/include/limits.h
index 8e3bb11edfc3..35eea1f619de 100644
--- a/sys/powerpc/include/limits.h
+++ b/sys/powerpc/include/limits.h
@@ -33,7 +33,9 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#if __GNUC__
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
diff --git a/sys/powerpc/include/stdarg.h b/sys/powerpc/include/stdarg.h
index 973da783c126..d0af5bb3324f 100644
--- a/sys/powerpc/include/stdarg.h
+++ b/sys/powerpc/include/stdarg.h
@@ -39,7 +39,7 @@
typedef __va_list va_list;
#endif
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#if defined(__GNUCLIKE_BUILTIN_STDARG)
#define va_start(ap, last) \
__builtin_stdarg_start((ap), (last))
@@ -58,7 +58,7 @@ typedef __va_list va_list;
#define va_end(ap) \
__builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* !__GNUCLIKE_BUILTIN_STDARG */
#ifdef __lint__
@@ -67,7 +67,7 @@ typedef __va_list va_list;
#else
-#if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+#if defined(__GNUC_VA_LIST_COMPATIBILITY)
#define va_start(ap, last) \
(__builtin_next_arg(last), \
__builtin_memcpy((void *)&(ap), __builtin_saveregs (), \
@@ -145,6 +145,6 @@ typedef __va_list va_list;
#endif
#endif
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_STDARG */
#endif /* _MACHINE_STDARG_H_ */
diff --git a/sys/powerpc/include/varargs.h b/sys/powerpc/include/varargs.h
index 8bbf2ca22126..fed04c9463ed 100644
--- a/sys/powerpc/include/varargs.h
+++ b/sys/powerpc/include/varargs.h
@@ -31,7 +31,11 @@
#ifndef _MACHINE_VARARGS_H_
#define _MACHINE_VARARGS_H_
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
+#if defined(__GNUCLIKE_BUILTIN_VARARGS)
#include <sys/_types.h>
@@ -48,12 +52,16 @@ typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
#define va_arg(ap, type) __builtin_va_arg((ap), type)
#define va_end(ap) __builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* ! __GNUCLIKE_BUILTIN_VARARGS */
#include <machine/stdarg.h>
+#ifdef __GNUCLIKE_BUILTIN_VAALIST
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist; ...
+#else
+#error this file needs to be ported to your compiler
+#endif
#undef va_start
@@ -67,6 +75,6 @@ typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
(ap).__fpr = __va_first_fpr)
#endif
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
#endif /* _MACHINE_VARARGS_H_ */
diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c
index 7493980aa169..f2efafe4ad61 100644
--- a/sys/powerpc/powerpc/busdma_machdep.c
+++ b/sys/powerpc/powerpc/busdma_machdep.c
@@ -309,7 +309,7 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
{
vm_offset_t vaddr;
vm_offset_t paddr;
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS_DYNAMIC_ARRAY_INIT
bus_dma_segment_t dm_segments[dmat->nsegments];
#else
bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
@@ -462,7 +462,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0,
bus_dmamap_callback2_t *callback, void *callback_arg,
int flags)
{
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS_DYNAMIC_ARRAY_INIT
bus_dma_segment_t dm_segments[dmat->nsegments];
#else
bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
@@ -538,7 +538,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, struct uio *uio,
int flags)
{
vm_offset_t lastaddr;
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS_DYNAMIC_ARRAY_INIT
bus_dma_segment_t dm_segments[dmat->nsegments];
#else
bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
diff --git a/sys/sparc64/include/_types.h b/sys/sparc64/include/_types.h
index f014b54eb1f7..f810c159a6ef 100644
--- a/sys/sparc64/include/_types.h
+++ b/sys/sparc64/include/_types.h
@@ -35,6 +35,10 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* Basic types upon which most other types are built.
*/
@@ -93,12 +97,13 @@ typedef __uint64_t __vm_size_t;
/*
* Unusual type definitions.
*/
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
typedef __builtin_va_list __va_list; /* internally known to gcc */
#else
typedef char * __va_list;
-#endif /* post GCC 2.95 */
-#if defined __GNUC__ && !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST)
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
+#if defined(__GNUCLIKE_BUILTIN_VAALIST) && !defined(__GNUC_VA_LIST) \
+ && !defined(__NO_GNUC_VA_LIST)
#define __GNUC_VA_LIST
typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
#endif
diff --git a/sys/sparc64/include/critical.h b/sys/sparc64/include/critical.h
index 381ec453602a..999a5fddc208 100644
--- a/sys/sparc64/include/critical.h
+++ b/sys/sparc64/include/critical.h
@@ -46,7 +46,7 @@ __BEGIN_DECLS
*/
void cpu_critical_fork_exit(void);
-#ifdef __GNUC__
+#ifdef __CC_SUPPORTS___INLINE
/*
* cpu_critical_enter:
@@ -79,12 +79,12 @@ cpu_critical_exit(struct thread *td)
wrpr(pil, td->td_md.md_savecrit, 0);
}
-#else /* !__GNUC__ */
+#else /* !__CC_SUPPORTS___INLINE */
void cpu_critical_enter(struct thread *td);
void cpu_critical_exit(struct thread *td);
-#endif /* __GNUC__ */
+#endif /* __CC_SUPPORTS___INLINE */
__END_DECLS
diff --git a/sys/sparc64/include/endian.h b/sys/sparc64/include/endian.h
index a3b9c2db476e..a643dd3537c8 100644
--- a/sys/sparc64/include/endian.h
+++ b/sys/sparc64/include/endian.h
@@ -63,7 +63,7 @@
#define BYTE_ORDER _BYTE_ORDER
#endif
-#if defined(__GNUC__) && defined(__OPTIMIZE__)
+#if defined(__GNUCLIKE_BUILTIN_CONSTANT_P) && defined(__OPTIMIZE__)
#define __is_constant(x) __builtin_constant_p(x)
#else
#define __is_constant(x) 0
diff --git a/sys/sparc64/include/stdarg.h b/sys/sparc64/include/stdarg.h
index bd4e9ddeb905..a7ff28484389 100644
--- a/sys/sparc64/include/stdarg.h
+++ b/sys/sparc64/include/stdarg.h
@@ -49,7 +49,7 @@
typedef __va_list va_list;
#endif
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifdef __GNUCLIKE_BUILTIN_STDARG
#define va_start(ap, last) \
__builtin_stdarg_start((ap), (last))
@@ -65,7 +65,11 @@ typedef __va_list va_list;
#define va_end(ap) \
__builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* ! __GNUCLIKE_BUILTIN_STDARG */
+
+#if !defined(__GNUCLIKE_BUILTIN_NEXT_ARG) && !defined(lint)
+#error no support for your compiler
+#endif
#define va_start(ap, last) \
(__builtin_next_arg(last), (ap) = (va_list)__builtin_saveregs())
@@ -92,6 +96,6 @@ typedef __va_list va_list;
(sizeof(type) <= 16 ? __va_arg16(ap, type) : \
*__va_arg8(ap, type *)))))
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_STDARG */
#endif /* !_MACHINE_STDARG_H_ */
diff --git a/sys/sparc64/include/varargs.h b/sys/sparc64/include/varargs.h
index 165e8078a7a0..a168c6e33c32 100644
--- a/sys/sparc64/include/varargs.h
+++ b/sys/sparc64/include/varargs.h
@@ -52,7 +52,11 @@
#ifndef _MACHINE_VARARGS_H_
#define _MACHINE_VARARGS_H_
-#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
#include <sys/_types.h>
@@ -69,15 +73,11 @@ typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
#define va_arg(ap, type) __builtin_va_arg((ap), type)
#define va_end(ap) __builtin_va_end(ap)
-#else /* ! __GNUC__ post GCC 2.95 */
+#else /* !__GNUCLIKE_BUILTIN_VARARGS */
#include <machine/stdarg.h>
-#if __GNUC__ == 1
-#define __va_ellipsis
-#else
#define __va_ellipsis ...
-#endif
#define va_alist __builtin_va_alist
#define va_dcl long __builtin_va_alist; __va_ellipsis
@@ -86,6 +86,6 @@ typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
#define va_start(ap) \
((ap) = (va_list)__builtin_saveregs())
-#endif /* __GNUC__ post GCC 2.95 */
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
#endif /* !_MACHINE_VARARGS_H_ */
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index a3f0025bef70..a4b11c421504 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -45,6 +45,76 @@
#endif
/*
+ * This code has been put in place to help reduce the addition of
+ * compiler specific defines in FreeBSD code. It helps to aid in
+ * having a compiler-agnostic source tree.
+ */
+
+#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+
+#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
+#define __GNUCLIKE_ASM 3
+#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
+#else
+#define __GNUCLIKE_ASM 2
+#endif
+#define __GNUCLIKE___TYPEOF 1
+#define __GNUCLIKE___OFFSETOF 1
+#define __GNUCLIKE___SECTION 1
+
+#define __GNUCLIKE_ATTRIBUTE_PRINTF 1
+#define __GNUCLIKE_ATTRIBUTE_MODE_DI 1
+
+#ifndef __INTEL_COMPILER
+# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
+#endif
+
+#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
+# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
+ && __INTEL_COMPILER < 800
+# undef __GNUCLIKE_BUILTIN_CONSTANT_P
+# endif
+
+#if __GNUC_MINOR__ > 95 || __GNUC__ >= 3 || defined(__INTEL_COMPILER)
+# define __GNUCLIKE_BUILTIN_VARARGS 1
+#endif
+#define __GNUCLIKE_BUILTIN_VAALIST 1
+
+#if defined(__GNUC__)
+# define __GNUC_VA_LIST_COMPATIBILITY 1
+#endif
+
+#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
+# define __GNUCLIKE_BUILTIN_STDARG 1
+#endif
+
+#ifndef __INTEL_COMPILER
+# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
+# define __GNUCLIKE_MATH_BUILTIN_RELOPS
+#endif
+
+#define __GNUCLIKE_BUILTIN_MEMCPY 1
+
+/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
+#define __CC_SUPPORTS_INLINE 1
+#define __CC_SUPPORTS___INLINE 1
+#define __CC_SUPPORTS___INLINE__ 1
+
+#define __CC_SUPPORTS___FUNC__ 1
+#define __CC_SUPPORTS_WARNING 1
+
+#define __CC_SUPPORTS_FORWARD_REFERENCE_CONSTRUCT 1
+
+#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
+
+#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
+
+/* XXX: sys/dev/mpt/mpilib/mpi_type.h uses it, someone should review it */
+#define __CC_INT_IS_32BIT 1
+
+#endif /* __GNUC__ || __INTEL_COMPILER */
+
+/*
* Macro to test if we're using a specific version of gcc or later.
*/
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
@@ -79,9 +149,9 @@
#if defined(__cplusplus)
#define __inline inline /* convert to C++ keyword */
#else
-#if !(defined(__GNUC__) || defined(__INTEL_COMPILER))
+#if !(defined(__CC_SUPPORTS___INLINE))
#define __inline /* delete GCC keyword */
-#endif /* !(__GNUC__ || __INTEL_COMPILER) */
+#endif /* ! __CC_SUPPORTS___INLINE */
#endif /* !__cplusplus */
#else /* !(__STDC__ || __cplusplus) */
@@ -89,7 +159,7 @@
#define __CONCAT(x,y) x/**/y
#define __STRING(x) "x"
-#if !(defined(__GNUC__) || defined(__INTEL_COMPILER))
+#if !defined(__CC_SUPPORTS___INLINE)
#define __const /* delete pseudo-ANSI C keywords */
#define __inline
#define __signed
@@ -108,7 +178,7 @@
#define signed
#define volatile
#endif /* !NO_ANSI_KEYWORDS */
-#endif /* !(__GNUC__ || __INTEL_COMPILER) */
+#endif /* !__CC_SUPPORTS___INLINE */
#endif /* !(__STDC__ || __cplusplus) */
/*
diff --git a/sys/sys/dir.h b/sys/sys/dir.h
index 48c98d208c9d..799ad9ed353c 100644
--- a/sys/sys/dir.h
+++ b/sys/sys/dir.h
@@ -33,7 +33,9 @@
#ifndef _SYS_DIR_H_
#define _SYS_DIR_H_
-#if defined(__GNUC__) || defined (__INTEL_COMPILER)
+#include <sys/cdefs.h>
+
+#ifdef __CC_SUPPORTS_WARNING
#warning "The information in this file should be obtained from <dirent.h>"
#warning "and is provided solely (and temporarily) for backward compatibility."
#endif
diff --git a/sys/sys/ioctl.h b/sys/sys/ioctl.h
index 530e2d4a9e0f..fd54f6d42ed1 100644
--- a/sys/sys/ioctl.h
+++ b/sys/sys/ioctl.h
@@ -39,10 +39,13 @@
#define _SYS_IOCTL_H_
#ifdef _KERNEL
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-#warning "Don't #include ioctl.h in the kernel. Include xxxio.h instead."
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
#endif
+#ifdef __CC_SUPPORTS_WARNING
+#warning "Don't #include ioctl.h in the kernel. Include xxxio.h instead."
#endif
+#endif /* _KERNEL */
#include <sys/ttycom.h>
diff --git a/sys/sys/linker_set.h b/sys/sys/linker_set.h
index 0c4a246ae064..5f55beb5a3b7 100644
--- a/sys/sys/linker_set.h
+++ b/sys/sys/linker_set.h
@@ -30,6 +30,10 @@
#ifndef _SYS_LINKER_SET_H_
#define _SYS_LINKER_SET_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+
/*
* The following macros are used to declare global sets of objects, which
* are collected by the linker into a `linker_set' as defined below.
@@ -39,16 +43,16 @@
/*
* Private macros, not to be used outside this header file.
*/
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __GNUCLIKE___SECTION
#define __MAKE_SET(set, sym) \
static void const * const __set_##set##_sym_##sym \
__section("set_" #set) __used = &sym
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
+#else /* !__GNUCLIKE___SECTION */
#ifndef lint
-#error "This file needs to be compiled by GCC, an Intel compiler or lint"
+#error this file needs to be ported to your compiler
#endif /* lint */
#define __MAKE_SET(set, sym) extern void const * const (__set_##set##_sym_##sym)
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __GNUCLIKE___SECTION */
/*
* Public macros.
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index 23c03c822157..c9a32307c109 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -517,7 +517,7 @@ struct quehead {
struct quehead *qh_rlink;
};
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifdef __CC_SUPPORTS___INLINE
static __inline void
insque(void *a, void *b)
@@ -541,12 +541,12 @@ remque(void *a)
element->qh_rlink = 0;
}
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
+#else /* !__CC_SUPPORTS___INLINE */
void insque(void *a, void *b);
void remque(void *a);
-#endif /* __GNUC__ || __INTEL_COMPILER */
+#endif /* __CC_SUPPORTS___INLINE */
#endif /* _KERNEL */
diff --git a/sys/sys/syslimits.h b/sys/sys/syslimits.h
index 974e17393a74..0d477be87bcb 100644
--- a/sys/sys/syslimits.h
+++ b/sys/sys/syslimits.h
@@ -34,7 +34,10 @@
#define _SYS_SYSLIMITS_H_
#if !defined(_KERNEL) && !defined(_LIMITS_H_) && !defined(_SYS_PARAM_H_)
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
+#ifdef __CC_SUPPORTS_WARNING
#warning "No user-serviceable parts inside."
#endif
#endif