kern/117510: [Patch] sys/cdefs.h lacks support for PCC

Ed Schouten ed at
Thu Oct 25 12:10:01 PDT 2007

>Number:         117510
>Category:       kern
>Synopsis:       [Patch] sys/cdefs.h lacks support for PCC
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 25 19:10:01 UTC 2007
>Originator:     Ed Schouten
>Release:        FreeBSD 6.2-STABLE i386
System: FreeBSD 6.2-STABLE FreeBSD 6.2-STABLE #0: Mon Sep 10 21:37:34 CEST 2007 root at i386
I'm filing this under kern, as it affects the src/sys/ directory.

The current sys/cdefs.h file lacks support for PCC, which means that
when users install PCC from ports, they have a compiler that isn't
really useful.
The following patch is incomplete, but already fixes the __packed
attribute. I'm currently discussing on the mailing list how to implement
__aligned() and __section(), but those can wait for now. It would be
wonderful if this would already make it into RELENG_7, because then
FreeBSD users can already start tinkering around with PCC on an
unpatched install.

A cool thing is: when you apply this patch, all apps in src/bin/ compile
without a flaw! :-)

--- src/sys/sys/cdefs.h	2006-09-21 03:38:58.000000000 +0200
+++ src/sys/sys/cdefs.h	2007-10-17 19:56:42.000000000 +0200
@@ -111,7 +111,7 @@
  * Macro to test if we're using a specific version of gcc or later.
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__PCC__)
 #define	__GNUC_PREREQ__(ma, mi)	\
 	(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
@@ -140,7 +140,7 @@
 #define	__const		const		/* define reserved names to standard */
 #define	__signed	signed
 #define	__volatile	volatile
-#if defined(__cplusplus)
+#if defined(__cplusplus) || defined(__PCC__)
 #define	__inline	inline		/* convert to C++ keyword */
 #if !(defined(__CC_SUPPORTS___INLINE))
@@ -221,6 +221,15 @@
 #define __aligned(x)	__attribute__((__aligned__(x)))
 #define __section(x)	__attribute__((__section__(x)))
+#if defined(__PCC__)
+#define __dead2
+#define __pure2
+#define __unused
+#define __used
+#define __packed	_Pragma("packed")
+#define __aligned(x)
+#define __section(x)
 #if __GNUC_PREREQ__(2, 96)

More information about the freebsd-bugs mailing list