Commit df6b55fd authored by gila's avatar gila Committed by Jim Harris
Browse files

bdev: make spdk_bdev_register_module_xxx function names predictable



Currently, the SPDK_BDEV_REGISTER_MODULE() macro uses __LINE__
to generate functions like spdk_bdev_module_register_187().

Typically, this is not a problem as these functions are not called directly
rather, they are only used as constructor functions to load the bdevs during
system startup.

There are languages however, (e.g rust) that require these functions to be
referenced explicitly to prevent them from being removed during the linking phase.

In order to reference them, having the names predictable (and potentially
changed per commit) makes things easier.

Change-Id: I15947ed9136912cfe2368db7e5bba833f1d94b15
Signed-off-by: default avatargila <jeffry.molanus@gmail.com>
Reviewed-on: https://review.gerrithub.io/c/443536


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent e8ccc71e
Loading
Loading
Loading
Loading
+6 −18
Original line number Diff line number Diff line
@@ -1006,22 +1006,10 @@ uint64_t spdk_bdev_part_get_offset_blocks(struct spdk_bdev_part *part);
/*
 *  Macro used to register module for later initialization.
 */
#define SPDK_BDEV_MODULE_REGISTER(_module)							\
	__attribute__((constructor)) static void						\
	SPDK_BDEV_MODULE_REGISTER_FN_NAME(__LINE__)  (void)					\
#define SPDK_BDEV_MODULE_REGISTER(name, module) \
static void __attribute__((constructor)) spdk_bdev_module_register_##name(void) \
{ \
	    spdk_bdev_module_list_add(_module);							\
	}

/*
 * This is helper macro for automatic function generation.
 *
 */
#define SPDK_BDEV_MODULE_REGISTER_FN_NAME(line) SPDK_BDEV_MODULE_REGISTER_FN_NAME_(line)

/*
 *  Second helper macro for "stringize" trick to work.
 */
#define SPDK_BDEV_MODULE_REGISTER_FN_NAME_(line) spdk_bdev_module_register_ ## line
	spdk_bdev_module_list_add(module); \
} \

#endif /* SPDK_BDEV_MODULE_H */
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ static struct spdk_bdev_module aio_if = {
	.get_ctx_size	= bdev_aio_get_ctx_size,
};

SPDK_BDEV_MODULE_REGISTER(&aio_if)
SPDK_BDEV_MODULE_REGISTER(aio, &aio_if)

static int
bdev_aio_open(struct file_disk *disk)
+1 −1
Original line number Diff line number Diff line
@@ -1394,7 +1394,7 @@ static struct spdk_bdev_module crypto_if = {
	.config_json = vbdev_crypto_config_json
};

SPDK_BDEV_MODULE_REGISTER(&crypto_if)
SPDK_BDEV_MODULE_REGISTER(crypto, &crypto_if)

static int
vbdev_crypto_claim(struct spdk_bdev *bdev)
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ static struct spdk_bdev_module error_if = {

};

SPDK_BDEV_MODULE_REGISTER(&error_if)
SPDK_BDEV_MODULE_REGISTER(error, &error_if)

int
spdk_vbdev_inject_error(char *name, uint32_t io_type, uint32_t error_type, uint32_t error_num)
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ static struct spdk_bdev_module g_ftl_if = {
	.get_ctx_size	= bdev_ftl_get_ctx_size,
};

SPDK_BDEV_MODULE_REGISTER(&g_ftl_if)
SPDK_BDEV_MODULE_REGISTER(ftl, &g_ftl_if)

static struct ftl_bdev_ctrlr *
bdev_ftl_ctrlr_find(const struct spdk_nvme_transport_id *trid)
Loading