From: Casey Barker Date: Thu, 4 Aug 2011 23:18:59 +0000 (-0700) Subject: lib: Adapt headers for use in C++. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43d1478b1690ecd0ef6b63890bc13438c1914e47;p=openvswitch 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. --- diff --git a/AUTHORS b/AUTHORS index aeb32629..cf75c790 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 b1162aeb..2e6d8b9b 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 109612fb..026eedaf 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -22,6 +22,10 @@ #include #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 a987fa48..ed2d78d3 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 7ee3e69f..dfd47be6 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 88100673..a739fce0 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 3f8bc47b..3c1ffe9c 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 */