Re: [PATCH] C++ breaks on linux/ioport.h

From: Manfred Spraul (manfreds@colorfullife.com)
Date: Fri Apr 28 2000 - 05:36:30 EST


Jamie Lokier wrote:
>
> That's because Domonik really meant:
>
> extern "C" {
> #define new c_new
> #define virtual c_virtual
> #include <linux/header1.h>
> #include <linux/header2.h>
> #undef new
> #undef virtual
> }
>
Ok, I tried that, but there is still one remaining problem:
the "page_address()" macro dereferences virtual, thus you cannot use
page_address() from within the cpp module.

I've attached a patch, "drivers/net/dummy.cpp" now compiles.

--
	Manfred

// $Header$ // Kernel Version: // VERSION = 2 // PATCHLEVEL = 3 // SUBLEVEL = 99 // EXTRAVERSION = -pre6 --- 2.3/include/linux/signal.h Tue Jan 26 01:04:20 1999 +++ build-2.3/include/linux/signal.h Fri Apr 28 12:18:50 2000 @@ -189,7 +189,7 @@ memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1)); break; case 2: set->sig[1] = 0; - case 1: + case 1:; } } @@ -201,7 +201,7 @@ memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1)); break; case 2: set->sig[1] = -1; - case 1: + case 1:; } } --- 2.3/include/asm-i386/semaphore.h Tue Feb 1 22:10:55 2000 +++ build-2.3/include/asm-i386/semaphore.h Fri Apr 28 12:18:50 2000 @@ -320,7 +320,7 @@ "2:\tcall __rwsem_wake\n\t" "jmp 1b\n" ".previous" - ::"a" (sem) + : :"a" (sem) :"memory" ); } @@ -339,7 +339,7 @@ "2:\tcall __rwsem_wake\n\t" "jmp 1b\n" ".previous" - ::"a" (sem) + : :"a" (sem) :"memory" ); } --- 2.3/include/linux/mm.h Thu Apr 27 11:27:24 2000 +++ build-2.3/include/linux/mm.h Fri Apr 28 12:20:34 2000 @@ -450,7 +450,10 @@ extern unsigned long do_brk(unsigned long, unsigned long); -struct zone_t; +#ifndef _LINUX_MMZONE_H +struct zone_struct; +typedef struct zone_struct zone_t; +#endif /* filemap.c */ extern void remove_inode_page(struct page *); extern unsigned long page_unuse(struct page *); --- 2.3/include/asm-i386/system.h Thu Apr 27 11:27:16 2000 +++ build-2.3/include/asm-i386/system.h Fri Apr 28 12:16:25 2000 @@ -149,7 +149,7 @@ movl 4(%0), %%edx; cmpxchg8b (%0); jnz 1b" - :: "D"(ptr), + : : "D"(ptr), "b"(low), "c"(high) : --- 2.3/drivers/net/dummy.c Thu Aug 19 21:04:35 1999 +++ build-2.3/drivers/net/dummy.cpp Fri Apr 28 12:23:36 2000 @@ -29,7 +29,10 @@ */ /* To have statistics (just packets sent) define this */ - +extern "C" { +#define new c_new +#define virtual c_virtual +#define typename c_typename #include <linux/config.h> #include <linux/kernel.h> #include <linux/module.h> @@ -52,6 +55,9 @@ #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> +#undef new +#undef virtual +#undef typename static int dummy_xmit(struct sk_buff *skb, struct net_device *dev); static struct net_device_stats *dummy_get_stats(struct net_device *dev); @@ -145,6 +151,8 @@ { /* Find a name for this unit */ int err=dev_alloc_name(&dev_dummy,"dummy%d"); + struct page* ttt = NULL; + unsigned long test = page_address(ttt); if(err<0) return err; if (register_netdev(&dev_dummy) != 0) @@ -159,3 +167,4 @@ dev_dummy.priv = NULL; } #endif /* MODULE */ +}

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:14 EST