Make libnewblue headers C++ friendly.
This CL adds extern "C" wrapping for exported headers so that the C++
consumers can include them without specifying extern "C" themselves.
BUG=chromium:840517
TEST=Build C++ client (newblued) without extern "C".
Change-Id: Ifa164bf274e39bb7fbf3380e76be8a069912f0aa
Reviewed-on: https://chromium-review.googlesource.com/1089920
Commit-Ready: Sonny Sasaka <sonnysasaka@chromium.org>
Tested-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/att.h b/att.h
index 987b3c7..3d88ac0 100644
--- a/att.h
+++ b/att.h
@@ -13,6 +13,8 @@
#include "uuid.h"
#include "uniq.h"
+NEWBLUE_BEGIN_DECLS
+
typedef uniq_t att_range_t;
typedef uniq_t att_cid_t;
typedef uniq_t att_trans_t;
@@ -177,4 +179,6 @@
/* completely stateless helpers */
bool attReadUuid(struct uuid *dst, sg s); //read uuid-16 or uuid-128 from an sg assuming it is the only thing in there
+NEWBLUE_END_DECLS
+
#endif
diff --git a/gatt-builtin.h b/gatt-builtin.h
index 5cade4f..f9d9513 100644
--- a/gatt-builtin.h
+++ b/gatt-builtin.h
@@ -9,6 +9,7 @@
#include "newblue-macros.h"
#include "types.h"
+NEWBLUE_BEGIN_DECLS
/*
* This file provides GATT profiles for GATT & GAP as required by the spec. It should be inited after
@@ -75,6 +76,7 @@
uint16_t to) NEWBLUE_EXPORT;
void gattBuiltinSetAppearance(uint16_t appearance) NEWBLUE_EXPORT; /* GAP_APPEAR_* */
+NEWBLUE_END_DECLS
diff --git a/gatt.h b/gatt.h
index 44316f0..2815f71 100644
--- a/gatt.h
+++ b/gatt.h
@@ -14,6 +14,7 @@
#include "uniq.h"
+NEWBLUE_BEGIN_DECLS
typedef uniq_t gatt_service_t;
typedef uniq_t gatt_client_conn_t;
@@ -174,6 +175,7 @@
uint8_t gattClientNotifsSubscribe(gatt_client_conn_t conn, const struct uuid *inThisService, const struct uuid *thisChar, bool reliable, gattCliNotifSubscribeStateCbk stateCbk, gattCliNotifArrivedCbk arrivedCbk) NEWBLUE_EXPORT;
uint8_t gattClientNotifsUnsubscribe(gatt_client_conn_t conn, const struct uuid *inThisService, const struct uuid *thisChar) NEWBLUE_EXPORT;
+NEWBLUE_END_DECLS
diff --git a/hci.h b/hci.h
index 8768665..376565b 100644
--- a/hci.h
+++ b/hci.h
@@ -12,6 +12,8 @@
#include "types.h"
#include "uniq.h"
+NEWBLUE_BEGIN_DECLS
+
#define HCI_CONN_ID_MASK 0x0FFF
#define HCI_PKT_TYP_CMD 0x01
@@ -229,6 +231,7 @@
bool hciAdvSetGetCurTxPowerLevel(hci_adv_set_t set, int8_t *advTxPowerLevelP) NEWBLUE_EXPORT;
bool hciAdvSetGetCurAdvAddr(hci_adv_set_t set, struct bt_addr *ownAddr) NEWBLUE_EXPORT;
+NEWBLUE_END_DECLS
#endif
diff --git a/l2cap.h b/l2cap.h
index f73f0f5..b776c25 100644
--- a/l2cap.h
+++ b/l2cap.h
@@ -6,6 +6,7 @@
#ifndef _L2CAP_H_
#define _L2CAP_H_
+#include "newblue-macros.h"
#include "multiNotif.h"
#include "types.h"
#include "uniq.h"
@@ -13,6 +14,7 @@
#include "bt.h"
#include "sg.h"
+NEWBLUE_BEGIN_DECLS
#define OUR_MTU 0xEFFF /* no reason to limit it pointlessly */
@@ -194,5 +196,7 @@
/* lower layer calls this when connection encryption key refreshed. called with FALSE if encr failed to resume with a new key since BT cannot really go from encrypted to not */
void l2cAclLinkEncrKeyRefresh(hci_conn_t aclConn, bool isEncrypted, bool isMitmSafe);
+NEWBLUE_END_DECLS
+
#endif
diff --git a/newblue-macros.h b/newblue-macros.h
index 0f6286a..f5c4714 100644
--- a/newblue-macros.h
+++ b/newblue-macros.h
@@ -12,4 +12,12 @@
# define __packed __attribute__ ((__packed__))
#endif
+#ifdef __cplusplus
+# define NEWBLUE_BEGIN_DECLS extern "C" {
+# define NEWBLUE_END_DECLS }
+#else
+# define NEWBLUE_BEGIN_DECLS
+# define NEWBLUE_END_DECLS
+#endif
+
#endif
diff --git a/sm.h b/sm.h
index e63c840..b59cfd3 100644
--- a/sm.h
+++ b/sm.h
@@ -11,6 +11,8 @@
#include "sg.h"
#include "types.h"
+NEWBLUE_BEGIN_DECLS
+
#define L2C_FIXED_CH_NUM_SM 6
#define SM_BLOCK_LEN 16
@@ -260,4 +262,6 @@
void smCalcKeyForTest(uint8_t *out, const uint8_t *k, const uint8_t *r1, const uint8_t *r2);
uint32_t smAddressHashForTest(uint32_t r, const uint8_t *key);
+NEWBLUE_END_DECLS
+
#endif /* _SM_H_ */