summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Barker <crbarker@google.com>2011-08-04 16:18:59 -0700
committerBen Pfaff <blp@nicira.com>2011-08-04 16:20:04 -0700
commit43d1478b1690ecd0ef6b63890bc13438c1914e47 (patch)
tree122b7ece40701cc950390e1a6dc3f56f83cb46f0
parentc71c6043a7617e6e6c2b8748550014f54476faa7 (diff)
downloadopenvswitch-43d1478b1690ecd0ef6b63890bc13438c1914e47.tar.gz
lib: Adapt headers for use in C++.
This commit makes several library headers suitable for inclusion in C++. It adds [extern "C"] guards and makes minor changes to fix casting and keyword issues.
-rw-r--r--AUTHORS1
-rw-r--r--lib/classifier.h8
-rw-r--r--lib/hash.h12
-rw-r--r--lib/hmap.h2
-rw-r--r--lib/ofp-util.h3
-rw-r--r--lib/sset.h8
-rw-r--r--lib/vconn.h8
7 files changed, 38 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index aeb326297..cf75c790e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -6,6 +6,7 @@ Andrew Lambeth wal@nicira.com
Andy Southgate andy.southgate@citrix.com
Ben Pfaff blp@nicira.com
Bryan Phillippe bp@toroki.com
+Casey Barker crbarker@google.com
Dan Wendlandt dan@nicira.com
David Erickson derickso@stanford.edu
Ethan Jackson ethan@nicira.com
diff --git a/lib/classifier.h b/lib/classifier.h
index b1162aeb8..2e6d8b9b9 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -32,6 +32,10 @@
#include "openflow/nicira-ext.h"
#include "openflow/openflow.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* A flow classifier. */
struct classifier {
int n_rules; /* Total number of rules. */
@@ -164,4 +168,8 @@ struct cls_rule *cls_cursor_next(struct cls_cursor *, struct cls_rule *);
: 0); \
(RULE) = (NEXT))
+#ifdef __cplusplus
+}
+#endif
+
#endif /* classifier.h */
diff --git a/lib/hash.h b/lib/hash.h
index 109612fb7..026eedaf4 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -22,6 +22,10 @@
#include <string.h>
#include "util.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* This is the public domain lookup3 hash by Bob Jenkins from
* http://burtleburtle.net/bob/c/lookup3.c, modified for style. */
@@ -81,8 +85,8 @@ static inline uint32_t hash_int(uint32_t x, uint32_t basis)
* quality. */
static inline uint32_t hash_boolean(bool x, uint32_t basis)
{
- enum { P0 = 0xc2b73583 }; /* This is hash_int(1, 0). */
- enum { P1 = 0xe90f1258 }; /* This is hash_int(2, 0). */
+ const uint32_t P0 = 0xc2b73583; /* This is hash_int(1, 0). */
+ const uint32_t P1 = 0xe90f1258; /* This is hash_int(2, 0). */
return (x ? P0 : P1) ^ HASH_ROT(basis, 1);
}
@@ -108,4 +112,8 @@ static inline uint32_t hash_pointer(const void *p, uint32_t basis)
return hash_int((uint32_t) (uintptr_t) p, basis);
}
+#ifdef __cplusplus
+}
+#endif
+
#endif /* hash.h */
diff --git a/lib/hmap.h b/lib/hmap.h
index a987fa488..ed2d78d34 100644
--- a/lib/hmap.h
+++ b/lib/hmap.h
@@ -89,7 +89,7 @@ static inline void hmap_remove(struct hmap *, struct hmap_node *);
void hmap_node_moved(struct hmap *, struct hmap_node *, struct hmap_node *);
static inline void hmap_replace(struct hmap *, const struct hmap_node *old,
- struct hmap_node *new);
+ struct hmap_node *new_node);
struct hmap_node *hmap_random_node(const struct hmap *);
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 7ee3e69f7..dfd47be6d 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -315,7 +315,8 @@ enum ofputil_action_code ofputil_decode_action_unsafe(
static inline union ofp_action *
ofputil_action_next(const union ofp_action *a)
{
- return (void *) ((uint8_t *) a + ntohs(a->header.len));
+ return ((union ofp_action *) (void *)
+ ((uint8_t *) a + ntohs(a->header.len)));
}
static inline bool
diff --git a/lib/sset.h b/lib/sset.h
index 88100673f..a739fce00 100644
--- a/lib/sset.h
+++ b/lib/sset.h
@@ -19,6 +19,10 @@
#include "hmap.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct sset_node {
struct hmap_node hmap_node;
char name[1];
@@ -85,4 +89,8 @@ bool sset_equals(const struct sset *, const struct sset *);
SSET_NAME_FROM_HMAP_NODE( \
hmap_next(&(SSET)->map, &SSET_NODE_FROM_NAME(NAME)->hmap_node))
+#ifdef __cplusplus
+}
+#endif
+
#endif /* sset.h */
diff --git a/lib/vconn.h b/lib/vconn.h
index 3f8bc47b8..3c1ffe9c2 100644
--- a/lib/vconn.h
+++ b/lib/vconn.h
@@ -24,6 +24,10 @@
#include "flow.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct list;
struct ofpbuf;
struct ofp_action_header;
@@ -78,4 +82,8 @@ void pvconn_close(struct pvconn *);
int pvconn_accept(struct pvconn *, int min_version, struct vconn **);
void pvconn_wait(struct pvconn *);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* vconn.h */