From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tml <tarantool-patches@dev.tarantool.org>
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [Tarantool-patches] [PATCH v12 3/8] module_cache: improve naming
Date: Mon, 18 Jan 2021 23:35:51 +0300 [thread overview]
Message-ID: <20210118203556.281700-4-gorcunov@gmail.com> (raw)
In-Reply-To: <20210118203556.281700-1-gorcunov@gmail.com>
- rename func_name to func_name_desc because
it is not just a name but rather a name descriptor
which includes symbol address
- rename func_split_name to parse_func_name because
the action of splitting name to parts is not what
the function about, the function parses specification
to fetch a descriptor
Part-of #4642
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
src/box/module_cache.c | 52 +++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/src/box/module_cache.c b/src/box/module_cache.c
index 9fe316807..8ae61a883 100644
--- a/src/box/module_cache.c
+++ b/src/box/module_cache.c
@@ -26,9 +26,9 @@
static struct mh_strnptr_t *mod_hash = NULL;
/**
- * Parsed symbol and package names.
+ * Function name descriptor: a symbol and a package.
*/
-struct func_name {
+struct func_name_desc {
/**
* Null-terminated symbol name, e.g.
* "func" for "mod.submod.func".
@@ -46,25 +46,25 @@ struct func_name {
};
/***
- * Split function name to symbol and package names.
+ * Parse function name into a name descriptor.
*
* For example, str = foo.bar.baz => sym = baz, package = foo.bar
*
* @param str function name, e.g. "module.submodule.function".
- * @param[out] name parsed symbol and a package name.
+ * @param[out] d parsed symbol and a package name.
*/
static void
-func_split_name(const char *str, struct func_name *name)
+parse_func_name(const char *str, struct func_name_desc *d)
{
- name->package = str;
- name->package_end = strrchr(str, '.');
- if (name->package_end != NULL) {
+ d->package = str;
+ d->package_end = strrchr(str, '.');
+ if (d->package_end != NULL) {
/* module.submodule.function => module.submodule, function */
- name->sym = name->package_end + 1; /* skip '.' */
+ d->sym = d->package_end + 1; /* skip '.' */
} else {
/* package == function => function, function */
- name->sym = name->package;
- name->package_end = str + strlen(str);
+ d->sym = d->package;
+ d->package_end = str + strlen(str);
}
}
@@ -335,12 +335,12 @@ module_sym_load(struct module_sym *mod_sym)
{
assert(mod_sym->addr == NULL);
- struct func_name name;
- func_split_name(mod_sym->name, &name);
+ struct func_name_desc d;
+ parse_func_name(mod_sym->name, &d);
- struct module *module = module_cache_find(name.package, name.package_end);
+ struct module *module = module_cache_find(d.package, d.package_end);
if (module == NULL) {
- module = module_load(name.package, name.package_end);
+ module = module_load(d.package, d.package_end);
if (module == NULL)
return -1;
if (module_cache_add(module) != 0) {
@@ -349,7 +349,7 @@ module_sym_load(struct module_sym *mod_sym)
}
}
- mod_sym->addr = module_sym(module, name.sym);
+ mod_sym->addr = module_sym(module, d.sym);
if (mod_sym->addr == NULL)
return -1;
@@ -366,9 +366,9 @@ module_sym_unload(struct module_sym *mod_sym)
rlist_del(&mod_sym->item);
if (rlist_empty(&mod_sym->module->funcs_list)) {
- struct func_name name;
- func_split_name(mod_sym->name, &name);
- module_cache_del(name.package, name.package_end);
+ struct func_name_desc d;
+ parse_func_name(mod_sym->name, &d);
+ module_cache_del(d.package, d.package_end);
}
module_gc(mod_sym->module);
@@ -439,13 +439,13 @@ module_reload(const char *package, const char *package_end,
struct module_sym *mod_sym, *tmp;
rlist_foreach_entry_safe(mod_sym, &old->funcs_list, item, tmp) {
- struct func_name name;
- func_split_name(mod_sym->name, &name);
+ struct func_name_desc d;
+ parse_func_name(mod_sym->name, &d);
- mod_sym->addr = module_sym(new, name.sym);
+ mod_sym->addr = module_sym(new, d.sym);
if (mod_sym->addr == NULL) {
say_error("module: reload %s, symbol %s not found",
- package, name.sym);
+ package, d.sym);
goto restore;
}
@@ -467,9 +467,9 @@ module_reload(const char *package, const char *package_end,
* restore old functions.
*/
do {
- struct func_name name;
- func_split_name(mod_sym->name, &name);
- mod_sym->addr = module_sym(old, name.sym);
+ struct func_name_desc d;
+ parse_func_name(mod_sym->name, &d);
+ mod_sym->addr = module_sym(old, d.sym);
if (mod_sym->addr == NULL) {
/*
* Something strange was happen, an early loaden
--
2.29.2
next prev parent reply other threads:[~2021-01-18 20:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 20:35 [Tarantool-patches] [PATCH v12 0/8] box: implement cmod Lua module Cyrill Gorcunov via Tarantool-patches
2021-01-18 20:35 ` [Tarantool-patches] [PATCH v12 1/8] box/func: factor out c function entry structure Cyrill Gorcunov via Tarantool-patches
2021-01-18 20:35 ` [Tarantool-patches] [PATCH v12 2/8] module_cache: move module handling into own subsystem Cyrill Gorcunov via Tarantool-patches
2021-01-24 16:26 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-25 8:52 ` Cyrill Gorcunov via Tarantool-patches
2021-01-18 20:35 ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-01-24 16:27 ` [Tarantool-patches] [PATCH v12 3/8] module_cache: improve naming Vladislav Shpilevoy via Tarantool-patches
2021-01-24 22:32 ` Cyrill Gorcunov via Tarantool-patches
2021-01-30 18:53 ` Vladislav Shpilevoy via Tarantool-patches
2021-02-01 11:41 ` Cyrill Gorcunov via Tarantool-patches
2021-01-18 20:35 ` [Tarantool-patches] [PATCH v12 4/8] module_cache: direct update a cache value on reload Cyrill Gorcunov via Tarantool-patches
2021-01-19 12:46 ` Cyrill Gorcunov via Tarantool-patches
2021-01-24 16:27 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-24 22:26 ` Cyrill Gorcunov via Tarantool-patches
2021-01-18 20:35 ` [Tarantool-patches] [PATCH v12 5/8] module_cache: rename calls to ref in module structure Cyrill Gorcunov via Tarantool-patches
2021-01-24 16:27 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-25 10:29 ` Cyrill Gorcunov via Tarantool-patches
2021-01-18 20:35 ` [Tarantool-patches] [PATCH v12 6/8] module_cache: provide helpers to load and unload modules Cyrill Gorcunov via Tarantool-patches
2021-01-24 16:28 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-18 20:35 ` [Tarantool-patches] [PATCH v12 7/8] box/cmod: implement cmod Lua module Cyrill Gorcunov via Tarantool-patches
2021-01-24 16:28 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-25 16:50 ` Cyrill Gorcunov via Tarantool-patches
2021-01-30 18:53 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-18 20:35 ` [Tarantool-patches] [PATCH v12 8/8] test: box/cfunc -- add cmod test Cyrill Gorcunov via Tarantool-patches
2021-01-24 16:28 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-24 16:26 ` [Tarantool-patches] [PATCH v12 0/8] box: implement cmod Lua module Vladislav Shpilevoy via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210118203556.281700-4-gorcunov@gmail.com \
--to=tarantool-patches@dev.tarantool.org \
--cc=gorcunov@gmail.com \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v12 3/8] module_cache: improve naming' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox