std C/C++ patch #5

David Scott Page page at cs.utexas.edu
Thu Apr 25 18:01:03 EDT 2002


Hi,

This patch:

1. Provides an alternative to a couple of gcc language extensions (C
array assignment and C++ array element construction).

2. removes a conflict with Solaris netinet/in.h macro definitions for
ip6 address shorthand (I hope the undefs do not confuse gcc on other
OS's).

3. Defines storage for the static ProcessingT::processing_letters and
moves the initialization (non integral initializer) to the definition.

--
Scott Page

------------------------------- 8< -----------------------------------
diff -Naur click-stdC++.4/elements/ethernet/ethermirror.cc click-stdC++.5/elements/ethernet/ethermirror.cc
--- click-stdC++.4/elements/ethernet/ethermirror.cc	Fri Mar 29 04:57:43 2002
+++ click-stdC++.5/elements/ethernet/ethermirror.cc	Thu Apr 25 21:46:17 2002
@@ -36,10 +36,16 @@
 {
   if (WritablePacket *q = p->uniqueify()) {
     click_ether *ethh = reinterpret_cast<click_ether *>(q->data());
-    unsigned char tmpa[6];
+    uint8_t tmpa[6];
+#if defined __GNUC__
     tmpa = ethh->ether_dhost;
     ethh->ether_dhost = ethh->ether_shost;
     ethh->ether_shost = tmpa;
+#else
+    std::memcpy(tmpa, ethh->ether_dhost, sizeof(click_ether));
+    std::memcpy(ethh->ether_dhost, ethh->ether_shost, sizeof(click_ether));
+    std::memcpy(ethh->ether_shost, tmpa, sizeof(click_ether));
+#endif
     return q;
   } else
     return 0;
diff -Naur click-stdC++.4/include/click/click_ip6.h click-stdC++.5/include/click/click_ip6.h
--- click-stdC++.4/include/click/click_ip6.h	Fri Apr  5 00:17:19 2002
+++ click-stdC++.5/include/click/click_ip6.h	Thu Apr 25 21:46:17 2002
@@ -18,9 +18,13 @@
 	uint64_t	u6_addr64[2];
 #endif
     } in6_u;
+#undef s6_addr
 #define s6_addr in6_u.u6_addr8
+#undef s6_addr16
 #define s6_addr16 in6_u.u6_addr16
+#undef s6_addr32
 #define s6_addr32 in6_u.u6_addr32
+#undef s6_addr64
 #define s6_addr64 in6_u.u6_addr64
 };
 
diff -Naur click-stdC++.4/tools/lib/processingt.cc click-stdC++.5/tools/lib/processingt.cc
--- click-stdC++.4/tools/lib/processingt.cc	Sat Jan  5 09:33:22 2002
+++ click-stdC++.5/tools/lib/processingt.cc	Thu Apr 25 21:46:17 2002
@@ -27,6 +27,8 @@
 #include <ctype.h>
 #include <string.h>
 
+const char * const ProcessingT::processing_letters = "ahl";
+
 ProcessingT::ProcessingT()
     : _router(0)
 {
@@ -651,7 +653,13 @@
 	return "x/y";
 
     // read flow codes, create `codes' array
+#if defined( __GNUG__ )
     Bitvector *codes = new Bitvector[noutputs](ninputs, false);
+#else  // standard C++
+    Bitvector *codes = new Bitvector[noutputs] ;
+    codes->resize(ninputs);
+    codes->clear();
+#endif
     Bitvector input_vec(ninput_pidx(), false);
     int opidx = input_pidx(PortT(output, 0));
     for (int i = 0; i < ninputs; i++) {
diff -Naur click-stdC++.4/tools/lib/processingt.hh click-stdC++.5/tools/lib/processingt.hh
--- click-stdC++.4/tools/lib/processingt.hh	Sat Jan  5 09:33:22 2002
+++ click-stdC++.5/tools/lib/processingt.hh	Thu Apr 25 21:46:17 2002
@@ -8,7 +8,7 @@
 class ProcessingT { public:
 
     enum ProcessingCode { VAGNOSTIC = 0, VPUSH = 1, VPULL = 2 };
-    static const char * const processing_letters = "ahl";
+    static const char * const processing_letters ;
 
     ProcessingT();
     ProcessingT(const RouterT *, ErrorHandler *);



More information about the click mailing list