From 45cab335bcf7531a9a128c99415df4c72e64976c Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 1 May 2017 13:22:48 -0700 Subject: [PATCH] include: move standard includes into spdk/stdinc.h This is the first step toward isolating standard C and POSIX headers into a single replaceable header file. Change-Id: I527297f5e7260b01103018ad3429922962ee9add Signed-off-by: Daniel Verkamp --- include/spdk/assert.h | 4 +-- include/spdk/barrier.h | 2 ++ include/spdk/bdev.h | 6 +--- include/spdk/bit_array.h | 6 ++-- include/spdk/blob.h | 3 +- include/spdk/blob_bdev.h | 2 ++ include/spdk/blobfs.h | 4 +-- include/spdk/conf.h | 2 +- include/spdk/copy_engine.h | 3 +- include/spdk/endian.h | 4 +-- include/spdk/env.h | 7 ++-- include/spdk/event.h | 5 +-- include/spdk/fd.h | 4 +-- include/spdk/gpt_spec.h | 2 +- include/spdk/io_channel.h | 3 +- include/spdk/ioat.h | 5 ++- include/spdk/ioat_spec.h | 4 +-- include/spdk/iscsi_spec.h | 2 +- include/spdk/json.h | 6 +--- include/spdk/jsonrpc.h | 11 ++---- include/spdk/likely.h | 2 ++ include/spdk/log.h | 5 +-- include/spdk/mmio.h | 4 +-- include/spdk/net.h | 6 +--- include/spdk/nvme.h | 6 ++-- include/spdk/nvme_intel.h | 5 ++- include/spdk/nvme_spec.h | 5 ++- include/spdk/nvmf.h | 2 +- include/spdk/nvmf_spec.h | 2 +- include/spdk/pci_ids.h | 4 +-- include/spdk/rpc.h | 2 +- include/spdk/scsi.h | 5 +-- include/spdk/scsi_spec.h | 2 +- include/spdk/stdinc.h | 73 ++++++++++++++++++++++++++++++++++++++ include/spdk/string.h | 5 ++- include/spdk/trace.h | 3 +- include/spdk/util.h | 5 ++- include/spdk/vhost.h | 2 ++ 38 files changed, 129 insertions(+), 94 deletions(-) create mode 100644 include/spdk/stdinc.h diff --git a/include/spdk/assert.h b/include/spdk/assert.h index 1bdc1cb73..67e674aac 100644 --- a/include/spdk/assert.h +++ b/include/spdk/assert.h @@ -38,12 +38,12 @@ #ifndef SPDK_ASSERT_H #define SPDK_ASSERT_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include - #ifdef static_assert #define SPDK_STATIC_ASSERT(cond, msg) static_assert(cond, msg) #else diff --git a/include/spdk/barrier.h b/include/spdk/barrier.h index 1b83f354b..1b2a5591d 100644 --- a/include/spdk/barrier.h +++ b/include/spdk/barrier.h @@ -38,6 +38,8 @@ #ifndef SPDK_BARRIER_H #define SPDK_BARRIER_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/spdk/bdev.h b/include/spdk/bdev.h index b02876c07..c97126d60 100644 --- a/include/spdk/bdev.h +++ b/include/spdk/bdev.h @@ -39,11 +39,7 @@ #ifndef SPDK_BDEV_H_ #define SPDK_BDEV_H_ -#include -#include /* for offsetof */ -#include /* for struct iovec */ -#include -#include +#include "spdk/stdinc.h" #include "spdk/event.h" #include "spdk/queue.h" diff --git a/include/spdk/bit_array.h b/include/spdk/bit_array.h index 7d013d075..3ccdabcb6 100644 --- a/include/spdk/bit_array.h +++ b/include/spdk/bit_array.h @@ -38,14 +38,12 @@ #ifndef SPDK_BIT_ARRAY_H #define SPDK_BIT_ARRAY_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include -#include - /** * Variable-length bit array. */ diff --git a/include/spdk/blob.h b/include/spdk/blob.h index 3a6f41f9a..5d4ef3d5d 100644 --- a/include/spdk/blob.h +++ b/include/spdk/blob.h @@ -66,8 +66,7 @@ #ifndef SPDK_BLOB_H #define SPDK_BLOB_H -#include -#include +#include "spdk/stdinc.h" typedef uint64_t spdk_blob_id; #define SPDK_BLOBID_INVALID (uint64_t)-1 diff --git a/include/spdk/blob_bdev.h b/include/spdk/blob_bdev.h index 86fe54bed..674427b20 100644 --- a/include/spdk/blob_bdev.h +++ b/include/spdk/blob_bdev.h @@ -38,6 +38,8 @@ #ifndef SPDK_BLOB_BDEV_H #define SPDK_BLOB_BDEV_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/spdk/blobfs.h b/include/spdk/blobfs.h index 863e829d6..8a2490897 100644 --- a/include/spdk/blobfs.h +++ b/include/spdk/blobfs.h @@ -38,9 +38,7 @@ #ifndef SPDK_FS_H #define SPDK_FS_H -#include -#include -#include +#include "spdk/stdinc.h" #include "spdk/blob.h" diff --git a/include/spdk/conf.h b/include/spdk/conf.h index e79e831e3..586b4660d 100644 --- a/include/spdk/conf.h +++ b/include/spdk/conf.h @@ -39,7 +39,7 @@ #ifndef SPDK_CONF_H #define SPDK_CONF_H -#include +#include "spdk/stdinc.h" struct spdk_conf_value; struct spdk_conf_item; diff --git a/include/spdk/copy_engine.h b/include/spdk/copy_engine.h index 54465d4eb..e450387e3 100644 --- a/include/spdk/copy_engine.h +++ b/include/spdk/copy_engine.h @@ -38,8 +38,7 @@ #ifndef SPDK_COPY_ENGINE_H #define SPDK_COPY_ENGINE_H -#include -#include +#include "spdk/stdinc.h" typedef void (*spdk_copy_completion_cb)(void *ref, int status); diff --git a/include/spdk/endian.h b/include/spdk/endian.h index a6fae07bf..116b7fb9c 100644 --- a/include/spdk/endian.h +++ b/include/spdk/endian.h @@ -39,12 +39,12 @@ #ifndef SPDK_ENDIAN_H #define SPDK_ENDIAN_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include - static inline uint16_t from_be16(const void *ptr) { diff --git a/include/spdk/env.h b/include/spdk/env.h index 8c0fa8b79..a25098517 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -38,15 +38,12 @@ #ifndef SPDK_ENV_H #define SPDK_ENV_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include -#include -#include - #define SPDK_ENV_SOCKET_ID_ANY (-1) struct spdk_pci_device; diff --git a/include/spdk/event.h b/include/spdk/event.h index 59366a412..7073fe311 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -41,10 +41,7 @@ #ifndef SPDK_EVENT_H #define SPDK_EVENT_H -#include -#include -#include -#include +#include "spdk/stdinc.h" #include "spdk/queue.h" diff --git a/include/spdk/fd.h b/include/spdk/fd.h index 41bdf1b34..8fec287e2 100644 --- a/include/spdk/fd.h +++ b/include/spdk/fd.h @@ -38,12 +38,12 @@ #ifndef SPDK_FD_H #define SPDK_FD_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include - uint64_t spdk_fd_get_size(int fd); uint32_t spdk_fd_get_blocklen(int fd); diff --git a/include/spdk/gpt_spec.h b/include/spdk/gpt_spec.h index 19880bb2b..90f6aaded 100644 --- a/include/spdk/gpt_spec.h +++ b/include/spdk/gpt_spec.h @@ -39,7 +39,7 @@ #ifndef SPDK_GPT_SPEC_H #define SPDK_GPT_SPEC_H -#include +#include "spdk/stdinc.h" #include "spdk/assert.h" diff --git a/include/spdk/io_channel.h b/include/spdk/io_channel.h index 19f435fe2..8f5f77c52 100644 --- a/include/spdk/io_channel.h +++ b/include/spdk/io_channel.h @@ -38,8 +38,7 @@ #ifndef SPDK_IO_CHANNEL_H_ #define SPDK_IO_CHANNEL_H_ -#include -#include +#include "spdk/stdinc.h" #include "spdk/queue.h" diff --git a/include/spdk/ioat.h b/include/spdk/ioat.h index 7b5c2b2d7..d366c9efe 100644 --- a/include/spdk/ioat.h +++ b/include/spdk/ioat.h @@ -38,13 +38,12 @@ #ifndef SPDK_IOAT_H #define SPDK_IOAT_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include - #include "spdk/env.h" /** diff --git a/include/spdk/ioat_spec.h b/include/spdk/ioat_spec.h index 117a1edf4..7a9baf79d 100644 --- a/include/spdk/ioat_spec.h +++ b/include/spdk/ioat_spec.h @@ -39,12 +39,12 @@ #ifndef SPDK_IOAT_SPEC_H #define SPDK_IOAT_SPEC_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include - #include "spdk/assert.h" #define SPDK_IOAT_INTRCTRL_MASTER_INT_EN 0x01 diff --git a/include/spdk/iscsi_spec.h b/include/spdk/iscsi_spec.h index 63ae43875..8714d33ea 100644 --- a/include/spdk/iscsi_spec.h +++ b/include/spdk/iscsi_spec.h @@ -40,7 +40,7 @@ #ifndef SPDK_ISCSI_SPEC_H #define SPDK_ISCSI_SPEC_H -#include +#include "spdk/stdinc.h" #include "spdk/assert.h" diff --git a/include/spdk/json.h b/include/spdk/json.h index 61a423d66..915939d70 100644 --- a/include/spdk/json.h +++ b/include/spdk/json.h @@ -39,11 +39,7 @@ #ifndef SPDK_JSON_H_ #define SPDK_JSON_H_ -#include -#include -#include -#include -#include +#include "spdk/stdinc.h" enum spdk_json_val_type { SPDK_JSON_VAL_INVALID, diff --git a/include/spdk/jsonrpc.h b/include/spdk/jsonrpc.h index 62f6c7427..248638233 100644 --- a/include/spdk/jsonrpc.h +++ b/include/spdk/jsonrpc.h @@ -39,17 +39,10 @@ #ifndef SPDK_JSONRPC_H_ #define SPDK_JSONRPC_H_ +#include "spdk/stdinc.h" + #include "spdk/json.h" -#include -#include -#include -#include - -#include -#include -#include - #define SPDK_JSONRPC_ERROR_PARSE_ERROR -32700 #define SPDK_JSONRPC_ERROR_INVALID_REQUEST -32600 #define SPDK_JSONRPC_ERROR_METHOD_NOT_FOUND -32601 diff --git a/include/spdk/likely.h b/include/spdk/likely.h index 4006b6c88..034a9b98b 100644 --- a/include/spdk/likely.h +++ b/include/spdk/likely.h @@ -38,6 +38,8 @@ #ifndef SPDK_LIKELY_H #define SPDK_LIKELY_H +#include "spdk/stdinc.h" + #define spdk_unlikely(cond) __builtin_expect((cond), 0) #define spdk_likely(cond) __builtin_expect(!!(cond), 1) diff --git a/include/spdk/log.h b/include/spdk/log.h index 0fe18b69e..1348415e2 100644 --- a/include/spdk/log.h +++ b/include/spdk/log.h @@ -39,10 +39,7 @@ #ifndef SPDK_LOG_H #define SPDK_LOG_H -#include -#include -#include -#include +#include "spdk/stdinc.h" /* * Default: 1 - noticelog messages will print to stderr and syslog. diff --git a/include/spdk/mmio.h b/include/spdk/mmio.h index 0f062e74b..1dbfa5823 100644 --- a/include/spdk/mmio.h +++ b/include/spdk/mmio.h @@ -38,12 +38,12 @@ #ifndef SPDK_MMIO_H #define SPDK_MMIO_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include - #include "spdk/barrier.h" #ifdef __x86_64__ diff --git a/include/spdk/net.h b/include/spdk/net.h index 42bf82f9e..327a0cc4d 100644 --- a/include/spdk/net.h +++ b/include/spdk/net.h @@ -38,11 +38,7 @@ #ifndef SPDK_NET_H #define SPDK_NET_H -#include -#include -#include -#include -#include +#include "spdk/stdinc.h" #include "spdk/queue.h" diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 73ab523ec..9e755d461 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -38,14 +38,12 @@ #ifndef SPDK_NVME_H #define SPDK_NVME_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include -#include - #include "spdk/env.h" #include "spdk/nvme_spec.h" #include "spdk/nvmf_spec.h" diff --git a/include/spdk/nvme_intel.h b/include/spdk/nvme_intel.h index af7d03122..fc4cd0cd0 100644 --- a/include/spdk/nvme_intel.h +++ b/include/spdk/nvme_intel.h @@ -42,13 +42,12 @@ #ifndef SPDK_NVME_INTEL_H #define SPDK_NVME_INTEL_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include - #include "spdk/assert.h" enum spdk_nvme_intel_feat { diff --git a/include/spdk/nvme_spec.h b/include/spdk/nvme_spec.h index b80353ad1..aa3388620 100644 --- a/include/spdk/nvme_spec.h +++ b/include/spdk/nvme_spec.h @@ -39,13 +39,12 @@ #ifndef SPDK_NVME_SPEC_H #define SPDK_NVME_SPEC_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include - #include "spdk/assert.h" /** diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index 59df2071e..45915c302 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -38,7 +38,7 @@ #ifndef SPDK_NVMF_H #define SPDK_NVMF_H -#include +#include "spdk/stdinc.h" #include "spdk/env.h" #include "spdk/nvmf_spec.h" diff --git a/include/spdk/nvmf_spec.h b/include/spdk/nvmf_spec.h index b4f9e8fd0..53f4ae719 100644 --- a/include/spdk/nvmf_spec.h +++ b/include/spdk/nvmf_spec.h @@ -34,7 +34,7 @@ #ifndef SPDK_NVMF_SPEC_H #define SPDK_NVMF_SPEC_H -#include +#include "spdk/stdinc.h" #include "spdk/assert.h" #include "spdk/nvme_spec.h" diff --git a/include/spdk/pci_ids.h b/include/spdk/pci_ids.h index 5f7aa2949..2ac94cf82 100644 --- a/include/spdk/pci_ids.h +++ b/include/spdk/pci_ids.h @@ -38,12 +38,12 @@ #ifndef SPDK_PCI_IDS #define SPDK_PCI_IDS +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include - #define SPDK_PCI_ANY_ID 0xffff #define SPDK_PCI_VID_INTEL 0x8086 #define SPDK_PCI_VID_MEMBLAZE 0x1c5f diff --git a/include/spdk/rpc.h b/include/spdk/rpc.h index 27922083f..4b3d5c539 100644 --- a/include/spdk/rpc.h +++ b/include/spdk/rpc.h @@ -34,7 +34,7 @@ #ifndef SPDK_RPC_CONFIG_H_ #define SPDK_RPC_CONFIG_H_ -#include +#include "spdk/stdinc.h" #include "spdk/jsonrpc.h" diff --git a/include/spdk/scsi.h b/include/spdk/scsi.h index 54a4cd30a..d2e9d2d6a 100644 --- a/include/spdk/scsi.h +++ b/include/spdk/scsi.h @@ -39,10 +39,7 @@ #ifndef SPDK_SCSI_H #define SPDK_SCSI_H -#include -#include -#include -#include +#include "spdk/stdinc.h" #include "spdk/queue.h" #include "spdk/event.h" diff --git a/include/spdk/scsi_spec.h b/include/spdk/scsi_spec.h index d6b02df2a..6163eb25c 100644 --- a/include/spdk/scsi_spec.h +++ b/include/spdk/scsi_spec.h @@ -39,7 +39,7 @@ #ifndef SPDK_SCSI_SPEC_H #define SPDK_SCSI_SPEC_H -#include +#include "spdk/stdinc.h" #include "spdk/assert.h" diff --git a/include/spdk/stdinc.h b/include/spdk/stdinc.h new file mode 100644 index 000000000..e3026b36f --- /dev/null +++ b/include/spdk/stdinc.h @@ -0,0 +1,73 @@ +/*- + * BSD LICENSE + * + * Copyright (c) Intel Corporation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** \file + * Standard C headers + * + * This file is intended to be included first by all other SPDK files. + */ + +#ifndef SPDK_STDINC_H +#define SPDK_STDINC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Standard C */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* POSIX */ +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +} +#endif + +#endif /* SPDK_STDINC_H */ diff --git a/include/spdk/string.h b/include/spdk/string.h index 914dc0206..b0ee0ad0c 100644 --- a/include/spdk/string.h +++ b/include/spdk/string.h @@ -38,13 +38,12 @@ #ifndef SPDK_STRING_H #define SPDK_STRING_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include - /** * sprintf with automatic buffer allocation. * diff --git a/include/spdk/trace.h b/include/spdk/trace.h index f7a8181dd..a017498d6 100644 --- a/include/spdk/trace.h +++ b/include/spdk/trace.h @@ -39,8 +39,7 @@ #ifndef _SPDK_TRACE_H_ #define _SPDK_TRACE_H_ -#include -#include +#include "spdk/stdinc.h" #ifdef __cplusplus extern "C" { diff --git a/include/spdk/util.h b/include/spdk/util.h index ec5ff793f..447ac1fed 100644 --- a/include/spdk/util.h +++ b/include/spdk/util.h @@ -38,13 +38,12 @@ #ifndef SPDK_UTIL_H #define SPDK_UTIL_H +#include "spdk/stdinc.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include - #define spdk_min(a,b) (((a)<(b))?(a):(b)) #define spdk_max(a,b) (((a)>(b))?(a):(b)) diff --git a/include/spdk/vhost.h b/include/spdk/vhost.h index 75e362f57..995caf8df 100644 --- a/include/spdk/vhost.h +++ b/include/spdk/vhost.h @@ -39,6 +39,8 @@ #ifndef SPDK_VHOST_H #define SPDK_VHOST_H +#include "spdk/stdinc.h" + #include "spdk/event.h" #define SPDK_VHOST_SCSI_CTRLR_MAX_DEVS 8