Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jul 2006 21:36:23 GMT
From:      Intron <intron@intron.ac>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/99979: Get Ready for Kernel Module in C++
Message-ID:  <200607092136.k69LaNDX055391@www.freebsd.org>
Resent-Message-ID: <200607092140.k69LeHen000985@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         99979
>Category:       kern
>Synopsis:       Get Ready for Kernel Module in C++
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 09 21:40:17 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Intron
>Release:        7.0-CURRENT
>Organization:
China
>Environment:
7.0-CURRENT, Intel Celeron 1.7GHz
>Description:
     I would write my kernel module in C++, just like IOKit of OpenDarwin. Thus, all conflicts against C++ in current FreeBSD kernel source must be swept out firstly.
     Here, I submit patches for _null.h, libkern.h and systm.h in /sys/sys/.
1. _null.h.diff:
     Now C++ code may also appear inside kernel source.
2. libkern.h.diff:
     C++ prohibits undeclared incompatible cast.
3. systm.h.diff:
     The word "new" is a perserved word of C++.

>How-To-Repeat:

>Fix:
--- _null.h.orig	Mon Jul 10 05:13:36 2006
+++ _null.h	Mon Jul 10 04:58:08 2006
@@ -23,12 +23,12 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: /repoman/r/ncvs/src/sys/sys/_null.h,v 1.7 2005/01/07 02:29:23 imp Exp $
+ * $FreeBSD: src/sys/sys/_null.h,v 1.7 2005/01/07 02:29:23 imp Exp $
  */
 
 #ifndef NULL
 
-#if defined(_KERNEL) || !defined(__cplusplus)
+#if defined(_KERNEL) && !defined(__cplusplus)
 #define	NULL	((void *)0)
 #else
 #if defined(__LP64__)
@@ -36,6 +36,6 @@
 #else
 #define	NULL	0
 #endif	/* __LP64__ */
-#endif	/* _KERNEL || !__cplusplus */
+#endif	/* _KERNEL && !__cplusplus */
 
 #endif



-----------------------------------------------------------------------------



--- libkern.h.orig	Mon Jul 10 05:15:46 2006
+++ libkern.h	Mon Jul 10 04:09:36 2006
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)libkern.h	8.1 (Berkeley) 6/10/93
- * $FreeBSD: /repoman/r/ncvs/src/sys/sys/libkern.h,v 1.52 2005/10/06 19:06:07 pjd Exp $
+ * $FreeBSD: src/sys/sys/libkern.h,v 1.52 2005/10/06 19:06:07 pjd Exp $
  */
 
 #ifndef _SYS_LIBKERN_H_
@@ -115,7 +115,7 @@
 static __inline uint32_t
 crc32_raw(const void *buf, size_t size, uint32_t crc)
 {
-	const uint8_t *p = buf;
+	const uint8_t *p = (const uint8_t *) buf;
 
 	while (size--)
 		crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);



-----------------------------------------------------------------------------



--- systm.h.orig	Mon Jul 10 05:17:29 2006
+++ systm.h	Mon Jul 10 04:07:15 2006
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)systm.h	8.7 (Berkeley) 3/29/95
- * $FreeBSD: /repoman/r/ncvs/src/sys/sys/systm.h,v 1.240 2006/02/11 09:33:07 phk Exp $
+ * $FreeBSD: src/sys/sys/systm.h,v 1.240 2006/02/11 09:33:07 phk Exp $
  */
 
 #ifndef _SYS_SYSTM_H_
@@ -203,7 +203,7 @@
 int	suword16(void *base, int word);
 int	suword32(void *base, int32_t word);
 int	suword64(void *base, int64_t word);
-intptr_t casuptr(intptr_t *p, intptr_t old, intptr_t new);
+intptr_t casuptr(intptr_t *p, intptr_t old, intptr_t _new);
 
 void	realitexpire(void *);
 

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607092136.k69LaNDX055391>