Commit 1a8467b0 authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

init: Make some functions entirely private



There were some functions in the internal header that can be entirely
private to the init library. Move them over.

Also, remove the support for including the header from a C++ file
because these headers are internal to SPDK which is pure C.

Change-Id: Ic4323b2b8664e70106a57b3ca8acbc7c2efe621d
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6642


Reviewed-by: default avatarTom Nabarro <tom.nabarro@outlook.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 00b0dc66
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -373,28 +373,6 @@ void _spdk_lw_thread_set_core(struct spdk_lw_thread *thread, uint32_t lcore);
void _spdk_lw_thread_get_current_stats(struct spdk_lw_thread *thread,
				       struct spdk_thread_stats *stats);

/**
 * \brief Register a new subsystem
 */
#define SPDK_SUBSYSTEM_REGISTER(_name) \
	__attribute__((constructor)) static void _name ## _register(void)	\
	{									\
		spdk_add_subsystem(&_name);					\
	}

/**
 * \brief Declare that a subsystem depends on another subsystem.
 */
#define SPDK_SUBSYSTEM_DEPEND(_name, _depends_on)						\
	static struct spdk_subsystem_depend __subsystem_ ## _name ## _depend_on ## _depends_on = { \
	.name = #_name,										\
	.depends_on = #_depends_on,								\
	};											\
	__attribute__((constructor)) static void _name ## _depend_on ## _depends_on(void)	\
	{											\
		spdk_add_subsystem_depend(&__subsystem_ ## _name ## _depend_on ## _depends_on); \
	}

#ifdef __cplusplus
}
#endif
+0 −25
Original line number Diff line number Diff line
@@ -41,10 +41,6 @@
#include "spdk/stdinc.h"
#include "spdk/queue.h"

#ifdef __cplusplus
extern "C" {
#endif

struct spdk_json_write_ctx;

struct spdk_subsystem {
@@ -62,20 +58,12 @@ struct spdk_subsystem {
	TAILQ_ENTRY(spdk_subsystem) tailq;
};

struct spdk_subsystem *spdk_subsystem_find(const char *name);
struct spdk_subsystem *spdk_subsystem_get_first(void);
struct spdk_subsystem *spdk_subsystem_get_next(struct spdk_subsystem *cur_subsystem);

struct spdk_subsystem_depend {
	const char *name;
	const char *depends_on;
	TAILQ_ENTRY(spdk_subsystem_depend) tailq;
};

struct spdk_subsystem_depend *spdk_subsystem_get_first_depend(void);
struct spdk_subsystem_depend *spdk_subsystem_get_next_depend(struct spdk_subsystem_depend
		*cur_depend);

void spdk_add_subsystem(struct spdk_subsystem *subsystem);
void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend);

@@ -87,15 +75,6 @@ void spdk_subsystem_fini(spdk_subsystem_fini_fn cb_fn, void *cb_arg);
void spdk_subsystem_init_next(int rc);
void spdk_subsystem_fini_next(void);

/**
 * Save pointed \c subsystem configuration to the JSON write context \c w. In case of
 * error \c null is written to the JSON context.
 *
 * \param w JSON write context
 * \param subsystem the subsystem to query
 */
void spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem);

/**
 * \brief Register a new subsystem
 */
@@ -118,8 +97,4 @@ void spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsy
		spdk_add_subsystem_depend(&__subsystem_ ## _name ## _depend_on ## _depends_on); \
	}

#ifdef __cplusplus
}
#endif

#endif
+0 −6
Original line number Diff line number Diff line
@@ -2,18 +2,12 @@
	global:

	# Public functions
	spdk_subsystem_find;
	spdk_subsystem_get_first;
	spdk_subsystem_get_next;
	spdk_subsystem_get_first_depend;
	spdk_subsystem_get_next_depend;
	spdk_add_subsystem;
	spdk_add_subsystem_depend;
	spdk_subsystem_init;
	spdk_subsystem_fini;
	spdk_subsystem_init_next;
	spdk_subsystem_fini_next;
	spdk_subsystem_config_json;

	local: *;
};
+10 −8
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@

#include "spdk/json.h"

#include "subsystem.h"

TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem);
struct spdk_subsystem_list g_subsystems = TAILQ_HEAD_INITIALIZER(g_subsystems);

@@ -82,32 +84,32 @@ _subsystem_find(struct spdk_subsystem_list *list, const char *name)
}

struct spdk_subsystem *
spdk_subsystem_find(const char *name)
subsystem_find(const char *name)
{
	return _subsystem_find(&g_subsystems, name);
}

struct spdk_subsystem *
spdk_subsystem_get_first(void)
subsystem_get_first(void)
{
	return TAILQ_FIRST(&g_subsystems);
}

struct spdk_subsystem *
spdk_subsystem_get_next(struct spdk_subsystem *cur_subsystem)
subsystem_get_next(struct spdk_subsystem *cur_subsystem)
{
	return TAILQ_NEXT(cur_subsystem, tailq);
}


struct spdk_subsystem_depend *
spdk_subsystem_get_first_depend(void)
subsystem_get_first_depend(void)
{
	return TAILQ_FIRST(&g_subsystems_deps);
}

struct spdk_subsystem_depend *
spdk_subsystem_get_next_depend(struct spdk_subsystem_depend *cur_depend)
subsystem_get_next_depend(struct spdk_subsystem_depend *cur_depend)
{
	return TAILQ_NEXT(cur_depend, tailq);
}
@@ -196,12 +198,12 @@ spdk_subsystem_init(spdk_subsystem_init_fn cb_fn, void *cb_arg)

	/* Verify that all dependency name and depends_on subsystems are registered */
	TAILQ_FOREACH(dep, &g_subsystems_deps, tailq) {
		if (!spdk_subsystem_find(dep->name)) {
		if (!subsystem_find(dep->name)) {
			SPDK_ERRLOG("subsystem %s is missing\n", dep->name);
			g_subsystem_start_fn(-1, g_subsystem_start_arg);
			return;
		}
		if (!spdk_subsystem_find(dep->depends_on)) {
		if (!subsystem_find(dep->depends_on)) {
			SPDK_ERRLOG("subsystem %s dependency %s is missing\n",
				    dep->name, dep->depends_on);
			g_subsystem_start_fn(-1, g_subsystem_start_arg);
@@ -268,7 +270,7 @@ spdk_subsystem_fini(spdk_msg_fn cb_fn, void *cb_arg)
}

void
spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem)
subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem)
{
	if (subsystem && subsystem->write_config_json) {
		subsystem->write_config_json(w);

lib/init/subsystem.h

0 → 100644
+53 −0
Original line number Diff line number Diff line
/*-
 *   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.
 */

#ifndef SPDK_SUBSYSTEM_H
#define SPDK_SUBSYSTEM_H

struct spdk_subsystem *subsystem_find(const char *name);
struct spdk_subsystem *subsystem_get_first(void);
struct spdk_subsystem *subsystem_get_next(struct spdk_subsystem *cur_subsystem);

struct spdk_subsystem_depend *subsystem_get_first_depend(void);
struct spdk_subsystem_depend *subsystem_get_next_depend(struct spdk_subsystem_depend
		*cur_depend);

/**
 * Save pointed \c subsystem configuration to the JSON write context \c w. In case of
 * error \c null is written to the JSON context.
 *
 * \param w JSON write context
 * \param subsystem the subsystem to query
 */
void subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem);

#endif
Loading