On Sun, 2010-10-24 at 09:45 -0700, Eddie Kohler wrote: 
> Hi Harald,
> 
> Great to hear about other people using patchless!
> 
> Re: hweight32: That is definitely a missing CLICK_CXX_PROTECT.  The way 
> to find it is to use nm on the individual object files to find where 
> it's used.  Something like
> 
> for i in *.o; do if nm $i | grep -l hweight32 >/dev/null 2>&1; then echo 
> $i; fi; done

Hi Eddie, 
this was my first idea, too, but it yielded every single .o file....

I traced down the bug by prepanding that to every linux header 
(thanks for fixincludes.pl ;-) 

#ifdef __cplusplus
# ifndef CLICK_CXX_PROTECTED
#  error "This file can only be included in CLICK_CXX_PROTECT stancas"
# endif
#endif

compiles and loads for me now, patches attached

(0002 is ommited for mailinglist friendliness, its just the huge diff
autoconf will generate on the configure...) 

> More soon.
> 
> Eddie
> 
> 
> On 10/24/10 8:21 AM, Harald Schioeberg wrote:
> > Hi,
> >
> > i'm currently trying to catch up with the patchless stuff, see below for
> > my current status.
> >
> > I tried against the weird ubuntu-maverick kernel, but then
> > I stepped back a bit to vanilla 2.6.27.54 on i386 for the moment.
> > This gives me a click build, but with:
> >
> > WARNING:
> > "_Z9hweight32j" [/data/harald/patchless/click/linuxmodule/click.ko]
> > undefined!
> > and of course a failure to load the "click" module, the proclikefs
> > loads.
> >
> > Apparently hweigth32 is not CXX_PROTECTed, any ideas why this might
> > happen?
> > Its in click-linuxmodule/include0/asm-generic/bitops/hweight.h
> > which should only be included via<linux/bitops.h>, but I have not found
> > any unprotected "#include<linux/bitops.h>" or related stuff anywhere.
> >
> > Here I am starting from eddie/96471bf1 + from Joonwoo.
> >
> > [joonwoo 01/12]
> > This fixes a configury issue, but the real compile will use [joonwoo
> > 9/12], which is in mainline by now as 340c5ebe
> > IMHO this needs some means to emulate
> > LINUX_VERSION_CODE<  KERNEL_VERSION(2, 6, 33)
> > in the configure to make it "nice"
> >
> > [joonwoo 02/12]
> > I didn't need that one until now...
> >
> > [joonwoo 03/12]
> > Same here
> >
> > [joonwoo 04/12]
> > Used joonwoo's patch, discussion is ongoing between eddie and joonwoo
> >
> > [joonwoo 05/12] [joonwoo 06/12] are in mainline
> >
> > [joonwoo 07/12]
> > used the patch from joowoon,
> > eddie already confirmed the patch, but it's not in mainline yet
> >
> > [joonwoo 08/12]
> > eddie checked in A Different Version
> >
> > [joonwoo 09/12]
> > it's upstream, related to 01/12
> >
> > [joonwoo 10/12 and 11/12]
> > they are upstream
> >
> > [joonwoo 12/12]
> > A Different Version is upstream as a5f200d
> >
> > _______________________________________________
> > click mailing list
> > [email protected]
> > https://amsterdam.lcs.mit.edu/mailman/listinfo/click

>From e589050e62e937723699f00bc4bce3c2fa424808 Mon Sep 17 00:00:00 2001
From: Harald Schioeberg <[email protected]>
Date: Mon, 25 Oct 2010 13:12:42 +0200
Subject: [PATCH 1/3] fixincludes: Check for proper use of cxxprotect

Add preprocessor directives to all linux kernel includes to allow for compile
time checking of the proper use of the CLICK_CXX_PROTECT provisions.

1) Have fixincludes.pl add
.#ifdef __cplusplus
.# ifndef CLICK_CXX_PROTECTED
.#  error "This file can only be included in CLICK_CXX_PROTECT stancas"
.# endif
.#endif
to all includefiles

2) Define new stance CLICK_CXX_PROTECTED in cxxprotect.h and undef it in cxxunprotect.h
3) Have configure.in add CLICK_CXX_PROTECTED to the include test.

Note: the autoconf'ed configure is not included in this patch
Note: Instead of generating the error, we could as well silently fix by
adding the missing "extern C"

Signed-off-by: Harald Schioeberg <[email protected]>
---
 configure.in                 |    1 +
 include/click/cxxprotect.h   |    4 ++++
 include/click/cxxunprotect.h |    1 +
 linuxmodule/fixincludes.pl   |    3 ++-
 4 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/configure.in b/configure.in
index 78af645..c2471f3 100644
--- a/configure.in
+++ b/configure.in
@@ -1163,6 +1163,7 @@ fixincludes.pl execution failed.
 #define namespace linux_namespace
 #define false linux_false
 #define true linux_true
+#define CLICK_CXX_PROTECTED
 #include <asm/types.h>]])
 
 
diff --git a/include/click/cxxprotect.h b/include/click/cxxprotect.h
index 37fc9a6..1c3bccc 100644
--- a/include/click/cxxprotect.h
+++ b/include/click/cxxprotect.h
@@ -22,3 +22,7 @@
 #  define CLICK_CXX_UNPROTECT	/* nothing */
 # endif
 #endif
+
+#ifndef CLICK_CXX_PROTECTED
+# define CLICK_CXX_PROTECTED
+#endif
diff --git a/include/click/cxxunprotect.h b/include/click/cxxunprotect.h
index 76b2756..3d83a57 100644
--- a/include/click/cxxunprotect.h
+++ b/include/click/cxxunprotect.h
@@ -12,3 +12,4 @@
 # undef false
 # undef true
 #endif
+#undef CLICK_CXX_PROTECTED
diff --git a/linuxmodule/fixincludes.pl b/linuxmodule/fixincludes.pl
index 0c81a4c..7592348 100755
--- a/linuxmodule/fixincludes.pl
+++ b/linuxmodule/fixincludes.pl
@@ -214,10 +214,11 @@ sub one_includeroot ($$) {
 	    if ($d eq "netdevice.h") {
 		s{(.*)(\(.*\b)(NETREG_.+)(\b\))}{#ifdef __cplusplus\n$1$2net_device::$3$4\n#else\n$1$2$3$4\n#endif}g;
 	    }
-
+        
 	    # unquote.
 	    $_ = sunprotect($_);
 
+        $_ = "#ifdef __cplusplus\n# ifndef CLICK_CXX_PROTECTED\n#  error \"This file can only be included in CLICK_CXX_PROTECT stancas\"\n# endif\n#endif\n" . $_; 
 	    # perhaps nothing has changed; avoid changing the timestamp
 	    if (-f "$outputroot$dd/$d") {
 		open(F, "$outputroot$dd/$d");
-- 
1.7.0.4

>From 14f7b458a5e07021da74e10b3ba8fe600e16b523 Mon Sep 17 00:00:00 2001
From: Harald Schioeberg <[email protected]>
Date: Tue, 26 Oct 2010 10:18:54 +0200
Subject: [PATCH 3/3] Fix all missing CLICK_CXX_PROTECTS revealed by earlier patch

Mechanically fix all complaints triggered by introducing the preprocessor
error in the fixinclude script

Signed-off-by: Harald Schioeberg <[email protected]>
---
 config-linuxmodule.h.in                |    8 ++++----
 elements/icmp/checkicmpheader.cc       |    4 ++++
 elements/ip/checkipheader.cc           |    4 ++++
 elements/linuxmodule/fasttcpflows.cc   |    4 ++++
 elements/linuxmodule/fastudpflows.cc   |    4 ++++
 elements/linuxmodule/fastudpsrc.cc     |    4 ++++
 elements/linuxmodule/perfcountaccum.cc |    4 ++++
 elements/linuxmodule/perfcountuser.cc  |    4 ++++
 elements/linuxmodule/setperfcount.cc   |    5 +++++
 elements/tcpudp/checktcpheader.cc      |    4 ++++
 elements/tcpudp/checkudpheader.cc      |    4 ++++
 elements/tcpudp/dynudpipencap.cc       |    4 ++++
 elements/tcpudp/tcpfragmenter.cc       |    4 ++++
 elements/tcpudp/tcpipsend.cc           |    4 ++++
 elements/tcpudp/udpipencap.cc          |    4 ++++
 include/click/atomic.hh                |    4 ++++
 include/click/fixconfig.h              |    4 ++++
 include/click/llrpc.h                  |   10 ++++++++--
 include/click/perfctr-i586.hh          |    4 ++++
 include/click/straccum.hh              |    4 ++++
 linuxmodule/proclikefs.h               |   10 ++++------
 21 files changed, 89 insertions(+), 12 deletions(-)

diff --git a/config-linuxmodule.h.in b/config-linuxmodule.h.in
index 511d9c0..31250ad 100644
--- a/config-linuxmodule.h.in
+++ b/config-linuxmodule.h.in
@@ -155,12 +155,12 @@
 #define MODULE 1
 
 /* Include Linux configuration and type definitions. */
-#ifndef AUTOCONF_INCLUDED
-# include <linux/autoconf.h>
-#endif
-#include <linux/version.h>
 #ifdef __cplusplus
 # include <click/cxxprotect.h>
+# ifndef AUTOCONF_INCLUDED
+#  include <linux/autoconf.h>
+# endif
+# include <linux/version.h>
 # include <asm/types.h>
 # include <linux/types.h>
 # include <click/cxxunprotect.h>
diff --git a/elements/icmp/checkicmpheader.cc b/elements/icmp/checkicmpheader.cc
index ea9bab3..6c22a61 100644
--- a/elements/icmp/checkicmpheader.cc
+++ b/elements/icmp/checkicmpheader.cc
@@ -26,7 +26,11 @@
 #include <click/bitvector.hh>
 #include <click/straccum.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/elements/ip/checkipheader.cc b/elements/ip/checkipheader.cc
index f425d9e..44972bd 100644
--- a/elements/ip/checkipheader.cc
+++ b/elements/ip/checkipheader.cc
@@ -26,7 +26,11 @@
 #include <click/error.hh>
 #include <click/standard/alignmentinfo.hh>
 #ifdef CLICK_LINUXMODULE
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/elements/linuxmodule/fasttcpflows.cc b/elements/linuxmodule/fasttcpflows.cc
index a6b50d5..4259689 100644
--- a/elements/linuxmodule/fasttcpflows.cc
+++ b/elements/linuxmodule/fasttcpflows.cc
@@ -23,7 +23,11 @@
 #include <click/glue.hh>
 #include <click/standard/alignmentinfo.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 
 const unsigned FastTCPFlows::NO_LIMIT;
diff --git a/elements/linuxmodule/fastudpflows.cc b/elements/linuxmodule/fastudpflows.cc
index b9c017d..53390a5 100644
--- a/elements/linuxmodule/fastudpflows.cc
+++ b/elements/linuxmodule/fastudpflows.cc
@@ -23,7 +23,11 @@
 #include <click/glue.hh>
 #include <click/standard/alignmentinfo.hh>
 #ifdef CLICK_LINUXMODULE
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 
 const unsigned FastUDPFlows::NO_LIMIT;
diff --git a/elements/linuxmodule/fastudpsrc.cc b/elements/linuxmodule/fastudpsrc.cc
index 0fbcbe3..38763ca 100644
--- a/elements/linuxmodule/fastudpsrc.cc
+++ b/elements/linuxmodule/fastudpsrc.cc
@@ -22,7 +22,11 @@
 #include <click/glue.hh>
 #include <click/standard/alignmentinfo.hh>
 #ifdef CLICK_LINUXMODULE
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 
 const unsigned FastUDPSource::NO_LIMIT;
diff --git a/elements/linuxmodule/perfcountaccum.cc b/elements/linuxmodule/perfcountaccum.cc
index 51fb1c5..fb693da 100644
--- a/elements/linuxmodule/perfcountaccum.cc
+++ b/elements/linuxmodule/perfcountaccum.cc
@@ -21,7 +21,11 @@
 #include <click/error.hh>
 #include <click/glue.hh>
 #include <click/packet_anno.hh>
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 #include <asm/msr.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 
 PerfCountAccum::PerfCountAccum()
 {
diff --git a/elements/linuxmodule/perfcountuser.cc b/elements/linuxmodule/perfcountuser.cc
index ae4d13b..75aad25 100644
--- a/elements/linuxmodule/perfcountuser.cc
+++ b/elements/linuxmodule/perfcountuser.cc
@@ -21,7 +21,11 @@
 #include <click/error.hh>
 #include <click/router.hh>
 #include <click/glue.hh>
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 #include <asm/msr.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #include <click/perfctr-i586.hh>
 
 PerfCountUser::PerfCountUser()
diff --git a/elements/linuxmodule/setperfcount.cc b/elements/linuxmodule/setperfcount.cc
index a2850fb..c3d7381 100644
--- a/elements/linuxmodule/setperfcount.cc
+++ b/elements/linuxmodule/setperfcount.cc
@@ -21,7 +21,12 @@
 #include <click/error.hh>
 #include <click/glue.hh>
 #include <click/packet_anno.hh>
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 #include <asm/msr.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
+
 
 SetPerfCount::SetPerfCount()
 {
diff --git a/elements/tcpudp/checktcpheader.cc b/elements/tcpudp/checktcpheader.cc
index 10dc047..354f52e 100644
--- a/elements/tcpudp/checktcpheader.cc
+++ b/elements/tcpudp/checktcpheader.cc
@@ -26,7 +26,11 @@
 #include <click/bitvector.hh>
 #include <click/straccum.hh>
 #ifdef CLICK_LINUXMODULE
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/elements/tcpudp/checkudpheader.cc b/elements/tcpudp/checkudpheader.cc
index b43300e..1d72b83 100644
--- a/elements/tcpudp/checkudpheader.cc
+++ b/elements/tcpudp/checkudpheader.cc
@@ -25,7 +25,11 @@
 #include <click/error.hh>
 #include <click/straccum.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/elements/tcpudp/dynudpipencap.cc b/elements/tcpudp/dynudpipencap.cc
index c75c9e9..b37828f 100644
--- a/elements/tcpudp/dynudpipencap.cc
+++ b/elements/tcpudp/dynudpipencap.cc
@@ -23,7 +23,11 @@
 #include <click/glue.hh>
 #include <click/standard/alignmentinfo.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/elements/tcpudp/tcpfragmenter.cc b/elements/tcpudp/tcpfragmenter.cc
index 7105561..82597a3 100644
--- a/elements/tcpudp/tcpfragmenter.cc
+++ b/elements/tcpudp/tcpfragmenter.cc
@@ -24,7 +24,11 @@
 #include <click/glue.hh>
 #include <click/standard/alignmentinfo.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/elements/tcpudp/tcpipsend.cc b/elements/tcpudp/tcpipsend.cc
index d15649e..49f48ba 100644
--- a/elements/tcpudp/tcpipsend.cc
+++ b/elements/tcpudp/tcpipsend.cc
@@ -24,7 +24,11 @@
 #include <click/glue.hh>
 #include <click/router.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/elements/tcpudp/udpipencap.cc b/elements/tcpudp/udpipencap.cc
index 8117216..fcc799d 100644
--- a/elements/tcpudp/udpipencap.cc
+++ b/elements/tcpudp/udpipencap.cc
@@ -24,7 +24,11 @@
 #include <click/glue.hh>
 #include <click/standard/alignmentinfo.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <net/checksum.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 CLICK_DECLS
 
diff --git a/include/click/atomic.hh b/include/click/atomic.hh
index 8302e41..abed14f 100644
--- a/include/click/atomic.hh
+++ b/include/click/atomic.hh
@@ -7,7 +7,11 @@
 CLICK_DECLS
 #if CLICK_LINUXMODULE
 # if HAVE_LINUX_ASM_SYSTEM_H
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 #  include <asm/system.h>
+# include <click/cxxunprotect.h> 
+CLICK_CXX_UNPROTECT
 # endif
 # define CLICK_ATOMIC_VAL	_val.counter
 #else
diff --git a/include/click/fixconfig.h b/include/click/fixconfig.h
index 976f1f9..c8872fb 100644
--- a/include/click/fixconfig.h
+++ b/include/click/fixconfig.h
@@ -4,9 +4,13 @@
 #if CLICK_LINUXMODULE && HAVE_LINUX_ASM_ALTERNATIVE_H
 // The .smp_locks section and C++-style weak linkage interact badly.
 # if CONFIG_SMP && (defined(__i386__) || defined(__x86_64__))
+# include <click/cxxprotect.h> 
+CLICK_CXX_PROTECT
 #  include <asm/alternative.h>
 #  undef LOCK_PREFIX
 #  define LOCK_PREFIX "lock ; "
+# include <click/cxxunprotect.h> 
+CLICK_CXX_UNPROTECT
 # endif
 #endif
 
diff --git a/include/click/llrpc.h b/include/click/llrpc.h
index 19e9787..3dbcb45 100644
--- a/include/click/llrpc.h
+++ b/include/click/llrpc.h
@@ -1,8 +1,12 @@
 #ifndef CLICK_LLRPC_H
 #define CLICK_LLRPC_H
 #if CLICK_LINUXMODULE
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 # include <linux/errno.h>
 # include <linux/ioctl.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #elif CLICK_BSDMODULE
 # include <sys/errno.h>
 # include <sys/ioccom.h>
@@ -114,9 +118,11 @@ struct click_llrpc_call_handler_st {
 
 # ifdef __cplusplus
 #  define __CLICK_LLRPC_CAST(x) reinterpret_cast< x >
-extern "C" {
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 #  include <asm/uaccess.h>
-}
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 # else
 #  define __CLICK_LLRPC_CAST(x) (x)
 #  include <asm/uaccess.h>
diff --git a/include/click/perfctr-i586.hh b/include/click/perfctr-i586.hh
index e1a42cb..75d39ed 100644
--- a/include/click/perfctr-i586.hh
+++ b/include/click/perfctr-i586.hh
@@ -2,7 +2,11 @@
 #define CLICK_PERFCTR_HH
 #ifdef __KERNEL__
 #include <click/glue.hh>
+#include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 #include <asm/msr.h>
+#include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
 
 #define DCU_MISS_OUTSTANDING	0x48
diff --git a/include/click/straccum.hh b/include/click/straccum.hh
index 65dac00..cfb0b5f 100644
--- a/include/click/straccum.hh
+++ b/include/click/straccum.hh
@@ -4,7 +4,11 @@
 #include <click/glue.hh>
 #include <click/string.hh>
 #ifdef CLICK_LINUXMODULE
+# include <click/cxxprotect.h> 
+CLICK_CXX_PROTECT
 # include <asm/string.h>
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #elif defined(CLICK_BSDMODULE)
 # include <sys/systm.h>
 #else	/* User-space */
diff --git a/linuxmodule/proclikefs.h b/linuxmodule/proclikefs.h
index 0402e52..bd64efc 100644
--- a/linuxmodule/proclikefs.h
+++ b/linuxmodule/proclikefs.h
@@ -1,9 +1,8 @@
 /* -*- c-basic-offset: 4 -*- */
 #ifndef PROCLIKEFS_H
 #define PROCLIKEFS_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+# include <click/cxxprotect.h>
+CLICK_CXX_PROTECT
 #include <linux/fs.h>
 #include <linux/list.h>
 #include <linux/version.h>
@@ -30,7 +29,6 @@ void proclikefs_put_super(struct super_block *);
 struct file_operations *proclikefs_new_file_operations(struct proclikefs_file_system *);
 struct inode_operations *proclikefs_new_inode_operations(struct proclikefs_file_system *);
 
-#ifdef __cplusplus
-}
-#endif
+# include <click/cxxunprotect.h>
+CLICK_CXX_UNPROTECT
 #endif
-- 
1.7.0.4

_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click

Reply via email to