From 04adec22bcb0da73bb88b074c1d8976184d5a226 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 12 Feb 2016 07:52:35 -0700 Subject: [PATCH] Add extern "C" wrapper to all public headers Also consistently place the extern "C" before any includes or other declarations in files that already had it. Change-Id: Ia316d5be3e509ec76c4a98cfa90ed516073351e0 Signed-off-by: Daniel Verkamp --- include/spdk/assert.h | 8 ++++++++ include/spdk/barrier.h | 8 ++++++++ include/spdk/file.h | 8 ++++++++ include/spdk/ioat.h | 8 ++++++++ include/spdk/ioat_spec.h | 8 ++++++++ include/spdk/mmio.h | 8 ++++++++ include/spdk/nvme.h | 8 +++++--- include/spdk/nvme_intel.h | 8 ++++++++ include/spdk/nvme_spec.h | 8 ++++++++ include/spdk/pci.h | 8 ++++++++ include/spdk/pci_ids.h | 8 ++++++++ include/spdk/queue.h | 8 ++++++++ include/spdk/string.h | 8 ++++++++ include/spdk/vtophys.h | 4 ++-- 14 files changed, 103 insertions(+), 5 deletions(-) diff --git a/include/spdk/assert.h b/include/spdk/assert.h index 6a7102262..80b65b0d0 100644 --- a/include/spdk/assert.h +++ b/include/spdk/assert.h @@ -34,6 +34,10 @@ #ifndef SPDK_ASSERT_H #define SPDK_ASSERT_H +#ifdef __cplusplus +extern "C" { +#endif + #include #define SPDK_CONCAT_(x, y) x##y @@ -52,4 +56,8 @@ typedef char SPDK_CONCAT(SPDK_STATIC_ASSERT_, __LINE__)[!!(cond) - 1] #endif +#ifdef __cplusplus +} +#endif + #endif /* SPDK_ASSERT_H */ diff --git a/include/spdk/barrier.h b/include/spdk/barrier.h index 6a183481e..637c64d56 100644 --- a/include/spdk/barrier.h +++ b/include/spdk/barrier.h @@ -34,7 +34,15 @@ #ifndef SPDK_BARRIER_H #define SPDK_BARRIER_H +#ifdef __cplusplus +extern "C" { +#endif + #define spdk_wmb() __asm volatile("sfence" ::: "memory") #define spdk_mb() __asm volatile("mfence" ::: "memory") +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/file.h b/include/spdk/file.h index 1c6b1b45e..5cb17691d 100644 --- a/include/spdk/file.h +++ b/include/spdk/file.h @@ -34,9 +34,17 @@ #ifndef SPDK_FILE_H #define SPDK_FILE_H +#ifdef __cplusplus +extern "C" { +#endif + #include uint64_t spdk_file_get_size(int fd); uint32_t spdk_dev_get_blocklen(int fd); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/ioat.h b/include/spdk/ioat.h index e64caa571..d44bd25cf 100644 --- a/include/spdk/ioat.h +++ b/include/spdk/ioat.h @@ -38,6 +38,10 @@ #ifndef SPDK_IOAT_H #define SPDK_IOAT_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include "spdk/pci.h" @@ -149,4 +153,8 @@ enum spdk_ioat_dma_capability_flags { */ uint32_t spdk_ioat_get_dma_capabilities(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/ioat_spec.h b/include/spdk/ioat_spec.h index 7315a2906..f8ed7a98e 100644 --- a/include/spdk/ioat_spec.h +++ b/include/spdk/ioat_spec.h @@ -34,6 +34,10 @@ #ifndef SPDK_IOAT_SPEC_H #define SPDK_IOAT_SPEC_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include "spdk/assert.h" @@ -312,4 +316,8 @@ union spdk_ioat_hw_desc { }; SPDK_STATIC_ASSERT(sizeof(union spdk_ioat_hw_desc) == 64, "incorrect spdk_ioat_hw_desc layout"); +#ifdef __cplusplus +} +#endif + #endif /* SPDK_IOAT_SPEC_H */ diff --git a/include/spdk/mmio.h b/include/spdk/mmio.h index a9f390281..3674fdecc 100644 --- a/include/spdk/mmio.h +++ b/include/spdk/mmio.h @@ -34,6 +34,10 @@ #ifndef SPDK_MMIO_H #define SPDK_MMIO_H +#ifdef __cplusplus +extern "C" { +#endif + #include #ifdef __x86_64__ @@ -88,4 +92,8 @@ spdk_mmio_write_8(volatile uint64_t *addr, uint64_t val) } } +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 73b0bf767..d76220369 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -34,6 +34,10 @@ #ifndef SPDK_NVME_H #define SPDK_NVME_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include "spdk/pci.h" #include "nvme_spec.h" @@ -45,9 +49,7 @@ #define SPDK_NVME_DEFAULT_RETRY_COUNT (4) extern int32_t spdk_nvme_retry_count; -#ifdef __cplusplus -extern "C" { -#endif + /** \brief Opaque handle to a controller. Returned by \ref spdk_nvme_probe()'s attach_cb. */ struct spdk_nvme_ctrlr; diff --git a/include/spdk/nvme_intel.h b/include/spdk/nvme_intel.h index be1055d3c..bac0be2c9 100644 --- a/include/spdk/nvme_intel.h +++ b/include/spdk/nvme_intel.h @@ -34,6 +34,10 @@ #ifndef SPDK_NVME_INTEL_H #define SPDK_NVME_INTEL_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -193,4 +197,8 @@ union spdk_nvme_intel_feat_latency_tracking { }; SPDK_STATIC_ASSERT(sizeof(union spdk_nvme_intel_feat_latency_tracking) == 4, "Incorrect size"); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/nvme_spec.h b/include/spdk/nvme_spec.h index ab8a90c3d..1cac84b74 100644 --- a/include/spdk/nvme_spec.h +++ b/include/spdk/nvme_spec.h @@ -34,6 +34,10 @@ #ifndef SPDK_NVME_SPEC_H #define SPDK_NVME_SPEC_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -1149,4 +1153,8 @@ enum spdk_nvme_ns_management_type { #define SPDK_NVME_IO_FLAGS_FORCE_UNIT_ACCESS (1U << 30) #define SPDK_NVME_IO_FLAGS_LIMITED_RETRY (1U << 31) +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/pci.h b/include/spdk/pci.h index bde5af5a6..a2f8e5884 100644 --- a/include/spdk/pci.h +++ b/include/spdk/pci.h @@ -34,6 +34,10 @@ #ifndef SPDK_PCI_H #define SPDK_PCI_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -63,4 +67,8 @@ int spdk_pci_device_bind_uio_driver(struct spdk_pci_device *dev); int spdk_pci_device_switch_to_uio_driver(struct spdk_pci_device *pci_dev); int spdk_pci_device_claim(struct spdk_pci_device *dev); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/pci_ids.h b/include/spdk/pci_ids.h index 67d7f8866..84edc5e5a 100644 --- a/include/spdk/pci_ids.h +++ b/include/spdk/pci_ids.h @@ -34,6 +34,10 @@ #ifndef SPDK_PCI_IDS #define SPDK_PCI_IDS +#ifdef __cplusplus +extern "C" { +#endif + #include #define SPDK_PCI_VID_INTEL 0x8086 @@ -47,4 +51,8 @@ */ #define SPDK_PCI_CLASS_NVME 0x010802 +#ifdef __cplusplus +} +#endif + #endif /* SPDK_PCI_IDS */ diff --git a/include/spdk/queue.h b/include/spdk/queue.h index 2b27f5567..d3d8615d4 100644 --- a/include/spdk/queue.h +++ b/include/spdk/queue.h @@ -34,6 +34,10 @@ #ifndef SPDK_QUEUE_H #define SPDK_QUEUE_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -46,4 +50,8 @@ #include #endif +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/string.h b/include/spdk/string.h index ae8337c8c..f6261dc47 100644 --- a/include/spdk/string.h +++ b/include/spdk/string.h @@ -34,6 +34,10 @@ #ifndef SPDK_STRING_H #define SPDK_STRING_H +#ifdef __cplusplus +extern "C" { +#endif + /** * sprintf with automatic buffer allocation. * @@ -43,4 +47,8 @@ */ char *spdk_sprintf_alloc(const char *format, ...) __attribute__((format(printf, 1, 2))); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/spdk/vtophys.h b/include/spdk/vtophys.h index ebd8acf57..146d8008f 100644 --- a/include/spdk/vtophys.h +++ b/include/spdk/vtophys.h @@ -34,12 +34,12 @@ #ifndef SPDK_VTOPHYS_H #define SPDK_VTOPHYS_H -#include - #ifdef __cplusplus extern "C" { #endif +#include + #define SPDK_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL) uint64_t spdk_vtophys(void *buf);