summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2005-03-02 21:33:29 +0000
committerjoerg <joerg@FreeBSD.org>2005-03-02 21:33:29 +0000
commitc85a3e95f78bb183ec62ae6ef948265e7ade6b7a (patch)
tree69c98a86a28838e983d8eca9ba158f46450df8c1 /sys/powerpc
parent2307c11d0fa1ac2133cff99d6c1a90c711b15f61 (diff)
downloadFreeBSD-src-c85a3e95f78bb183ec62ae6ef948265e7ade6b7a.zip
FreeBSD-src-c85a3e95f78bb183ec62ae6ef948265e7ade6b7a.tar.gz
netchild's mega-patch to isolate compiler dependencies into a central
place. This moves the dependency on GCC's and other compiler's features into the central sys/cdefs.h file, while the individual source files can then refer to #ifdef __COMPILER_FEATURE_FOO where they by now used to refer to #if __GNUC__ > 3.1415 && __BARC__ <= 42. By now, GCC and ICC (the Intel compiler) have been actively tested on IA32 platforms by netchild. Extension to other compilers is supposed to be possible, of course. Submitted by: netchild Reviewed by: various developers on arch@, some time ago
Diffstat (limited to 'sys/powerpc')
-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
9 files changed, 46 insertions, 27 deletions
diff --git a/sys/powerpc/include/_types.h b/sys/powerpc/include/_types.h
index 32fe2e3..c6babcf 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 dee4c84..ad23a3f 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 cc0768a..405bc57 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 af8f030..bc96b9e 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 a899ef0..0992006 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 8e3bb11..35eea1f 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 973da78..d0af5bb 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 8bbf2ca..fed04c9 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 7493980..f2efafe 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];
OpenPOWER on IntegriCloud