From nobody@FreeBSD.org  Sun Jul  9 21:39:58 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6DC5B16A5C6
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  9 Jul 2006 21:39:58 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4B09443F6D
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  9 Jul 2006 21:36:23 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k69LaNaQ055392
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 9 Jul 2006 21:36:23 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k69LaNDX055391;
	Sun, 9 Jul 2006 21:36:23 GMT
	(envelope-from nobody)
Message-Id: <200607092136.k69LaNDX055391@www.freebsd.org>
Date: Sun, 9 Jul 2006 21:36:23 GMT
From: Intron <intron@intron.ac>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Get Ready for Kernel Module in C++
X-Send-Pr-Version: www-2.3

>Number:         99979
>Category:       kern
>Synopsis:       [patch] 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:  Wed Jul 26 07:56:04 GMT 2006
>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:
Responsible-Changed-From-To: freebsd-bugs->delphij 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Mon Jul 10 01:18:56 UTC 2006 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99979 

From: "Joseph Koshy" <joseph.koshy@gmail.com>
To: Intron <intron@intron.ac>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/99979: Get Ready for Kernel Module in C++
Date: Mon, 10 Jul 2006 08:45:15 +0530

 > 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.
 
 Your patch is missing the following:
 
  - runtime support for static constructors and destructors
  - runtime support for C++ exceptions
  - support for RTTI
 
 Don't forget that these need to work in kernel modules
 too.
 
 -- 
 FreeBSD Volunteer,     http://people.freebsd.org/~jkoshy
Responsible-Changed-From-To: delphij->freebsd-bugs 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Wed Jul 26 07:54:58 UTC 2006 
Responsible-Changed-Why:  
Return to poll, this needs more work and I do not have energy 
nor time to do that right now. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99979 
>Unformatted:
