C#
The xNVMe library is modular and namespaced. The recommended way of
consuming the library is by using #include <libxnvme.h>
. The content of
the Header is provided below for reference.
The Header is an umbrella header, meaning it includes all public headers of the xNVMe project and the necessary third-party definitions. If you have a valid reason for not using this header, you can construct your own custom includes due to the modularity and consistent namespacing conventions of the project. For details on creating custom includes, refer to Custom Include.
Header#
/**
* Cross-platform I/O library for emerging storage devices
*
* Designed for the low-level control and performance offered by NVMe device
* while maintaining the support for traditional storage devices and
* interfaces.
*
* SPDX-FileCopyrightText: Samsung Electronics Co., Ltd
*
* SPDX-License-Identifier: BSD-3-Clause
*
* @file libxnvme.h
*/
#ifndef __LIBXNVME_H
#define __LIBXNVME_H
#ifdef __cplusplus
extern "C" {
#endif
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <time.h>
#include "libxnvme_util.h"
#include "libxnvme_opts.h"
#include "libxnvme_pp.h"
#include "libxnvme_dev.h"
#include "libxnvme_be.h"
#include "libxnvme_buf.h"
#include "libxnvme_mem.h"
#include "libxnvme_geo.h"
#include "libxnvme_ident.h"
#include "libxnvme_queue.h"
#include "libxnvme_spec.h"
#include "libxnvme_spec_fs.h"
#include "libxnvme_spec_pp.h"
#include "libxnvme_cmd.h"
#include "libxnvme_lba.h"
#include "libxnvme_ver.h"
#include "libxnvme_file.h"
#include "libxnvme_adm.h"
#include "libxnvme_nvm.h"
#include "libxnvme_kvs.h"
#include "libxnvme_znd.h"
#include "libxnvme_topology.h"
#include "libxnvme_libconf.h"
#include "libxnvme_cli.h"
#include "libxnvme_pi.h"
#ifdef __cplusplus
}
#endif
#endif /* __LIBXNVME_H */
Custom Include#
The xNVMe library header (libxnvme.h
) serves as a single point of
entry, encompassing all necessary inclusions. However, you might be reading
this because you want to use only a subset of xNVMe, extract specific
definitions, or integrate the definitions/library in a particular way. Here are
a few important points to know about the xNVMe headers:
The public headers never include other headers.
The exception to this rule is
libxnvme.h
itself.All other headers (
libxnvme_*.h
) rely on the symbols they depend on to be defined elsewhere, for example, by the header that included them, such aslibxnvme.h
.- Why this rule?
It provides a single place to define scalar types for integers, floats, and booleans, as well as system headers and other third-party definitions. For instance, someone might have a project where they use part of the xNVMe headers for NVMe definitions but have their own variations of scalar types. By adhering to this rule, all of the
libxnvme_*.h
headers can be recomposed and integrated in any desired manner.
There are no include or C++ guards.
- Why this rule?
Including guards in each header file would be redundant since the common practice for xNVMe is to include
libxnvme.h
, which already has an include and C++ guard, eliminating the need for those in every header. However, if you choose to selectively include xNVMe headers, you will need to set up your own guards.