Skip to content

Commit

Permalink
lib, ovsdb: Adapt headers for C++ usage
Browse files Browse the repository at this point in the history
This patch adds 'extern "C"' in a couple of header files so that
they can be compiled with C++ compilers.

Signed-off-by: Yi-Hung Wei <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
YiHungWei authored and blp committed Dec 1, 2017
1 parent 936cca1 commit 9131abe
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/dirs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@
#ifndef DIRS_H
#define DIRS_H 1

#ifdef __cplusplus
extern "C" {
#endif

const char *ovs_sysconfdir(void); /* /usr/local/etc */
const char *ovs_pkgdatadir(void); /* /usr/local/share/openvswitch */
const char *ovs_rundir(void); /* /usr/local/var/run/openvswitch */
const char *ovs_logdir(void); /* /usr/local/var/log/openvswitch */
const char *ovs_dbdir(void); /* /usr/local/etc/openvswitch */
const char *ovs_bindir(void); /* /usr/local/bin */

#ifdef __cplusplus
}
#endif

#endif /* dirs.h */
8 changes: 8 additions & 0 deletions lib/ovsdb-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "ovsdb-types.h"
#include "openvswitch/shash.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_OVSDB_ATOM_RANGE_SIZE 4096

struct ds;
Expand Down Expand Up @@ -282,4 +286,8 @@ bool ovsdb_token_is_delim(unsigned char);
struct ovsdb_error *ovsdb_atom_range_check_size(int64_t range_start,
int64_t range_end);

#ifdef __cplusplus
}
#endif

#endif /* ovsdb-data.h */
8 changes: 8 additions & 0 deletions lib/ovsdb-idl-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include "openvswitch/shash.h"
#include "uuid.h"

#ifdef __cplusplus
extern "C" {
#endif

/* A local copy of a row in an OVSDB table, replicated from an OVSDB server.
* This structure is used as a header for a larger structure that translates
* the "struct ovsdb_datum"s into easier-to-use forms, via the ->parse() and
Expand Down Expand Up @@ -161,4 +165,8 @@ void ovsdb_idl_txn_verify(const struct ovsdb_idl_row *,

struct ovsdb_idl_txn *ovsdb_idl_txn_get(const struct ovsdb_idl_row *);

#ifdef __cplusplus
}
#endif

#endif /* ovsdb-idl-provider.h */
9 changes: 9 additions & 0 deletions lib/ovsdb-idl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#include "ovsdb-condition.h"
#include "skiplist.h"

#ifdef __cplusplus
extern "C" {
#endif

struct json;
struct ovsdb_datum;
struct ovsdb_idl_class;
Expand Down Expand Up @@ -409,4 +413,9 @@ struct ovsdb_idl_row *ovsdb_idl_index_forward_to(
int ovsdb_idl_index_compare(struct ovsdb_idl_index_cursor *,
struct ovsdb_idl_row *a,
struct ovsdb_idl_row *b);

#ifdef __cplusplus
}
#endif

#endif /* ovsdb-idl.h */
8 changes: 8 additions & 0 deletions lib/ovsdb-map-op.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#include "ovsdb-data.h"

#ifdef __cplusplus
extern "C" {
#endif

enum map_op_type {
MAP_OP_UPDATE,
MAP_OP_INSERT,
Expand All @@ -42,4 +46,8 @@ void map_op_list_add(struct map_op_list *, struct map_op *,
struct map_op *map_op_list_first(struct map_op_list *);
struct map_op *map_op_list_next(struct map_op_list *, struct map_op *);

#ifdef __cplusplus
}
#endif

#endif /* ovsdb-map-op.h */
8 changes: 8 additions & 0 deletions lib/ovsdb-set-op.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "ovsdb-data.h"

#ifdef __cplusplus
extern "C" {
#endif

enum set_op_type {
SET_OP_INSERT,
SET_OP_DELETE
Expand All @@ -42,4 +46,8 @@ void set_op_list_add(struct set_op_list *, struct set_op *,
struct set_op *set_op_list_first(struct set_op_list *);
struct set_op *set_op_list_next(struct set_op_list *, struct set_op *);

#ifdef __cplusplus
}
#endif

#endif /* ovsdb-set-op.h */
8 changes: 8 additions & 0 deletions lib/ovsdb-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "compiler.h"
#include "uuid.h"

#ifdef __cplusplus
extern "C" {
#endif

struct json;

/* An atomic type: one that OVSDB regards as a single unit of data. */
Expand Down Expand Up @@ -227,4 +231,8 @@ static inline bool ovsdb_type_is_map(const struct ovsdb_type *type)
return type->value.type != OVSDB_TYPE_VOID;
}

#ifdef __cplusplus
}
#endif

#endif /* ovsdb-types.h */
8 changes: 8 additions & 0 deletions lib/smap.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include "hash.h"
#include "openvswitch/hmap.h"

#ifdef __cplusplus
extern "C" {
#endif

struct json;
struct uuid;

Expand Down Expand Up @@ -113,4 +117,8 @@ struct json *smap_to_json(const struct smap *);

bool smap_equal(const struct smap *, const struct smap *);

#ifdef __cplusplus
}
#endif

#endif /* smap.h */
8 changes: 8 additions & 0 deletions lib/uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

#include "openvswitch/uuid.h"

#ifdef __cplusplus
extern "C" {
#endif

/* An initializer or expression for an all-zero UUID. */
#define UUID_ZERO ((struct uuid) { .parts = { 0, 0, 0, 0 } })

Expand Down Expand Up @@ -69,4 +73,8 @@ int uuid_is_partial_string(const char *);
int uuid_is_partial_match(const struct uuid *, const char *match);
void uuid_set_bits_v4(struct uuid *);

#ifdef __cplusplus
}
#endif

#endif /* uuid.h */
11 changes: 10 additions & 1 deletion ovsdb/ovsdb-idlc.in
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ def printCIDLHeader(schemaFile):
#include "ovsdb-data.h"
#include "ovsdb-idl-provider.h"
#include "smap.h"
#include "uuid.h"''' % {'prefix': prefix.upper()})
#include "uuid.h"

#ifdef __cplusplus
extern "C" {
#endif
''' % {'prefix': prefix.upper()})

for tableName, table in sorted(schema.tables.items()):
structName = "%s%s" % (prefix, tableName.lower())
Expand Down Expand Up @@ -305,6 +310,10 @@ bool %(s)s_is_updated(const struct %(s)s *, enum %(s)s_column_id);
print("\nextern struct ovsdb_idl_class %sidl_class;" % prefix)

print("\nconst char * %sget_db_version(void);" % prefix)
print('''
#ifdef __cplusplus
}
#endif''')
print("\n#endif /* %(prefix)sIDL_HEADER */" % {'prefix': prefix.upper()})

def printEnum(type, members):
Expand Down

0 comments on commit 9131abe

Please sign in to comment.