diff --git a/changelogs/unreleased/gh-7124-remove-cord-slab-cache-symbol-from-public-api-export.md b/changelogs/unreleased/gh-7124-remove-cord-slab-cache-symbol-from-public-api-export.md new file mode 100644 index 0000000000000000000000000000000000000000..0c421f6e0567e2dfdefa6e0e826a50275417e3c2 --- /dev/null +++ b/changelogs/unreleased/gh-7124-remove-cord-slab-cache-symbol-from-public-api-export.md @@ -0,0 +1,4 @@ +## bugfix/box + +* **[Breaking change]** The `cord_slab_cache` symbol was removed from the public + API export (gh-7124). diff --git a/extra/exports b/extra/exports index 5bd2e111c4187e76b69f322bd5885e7bda82cab6..194ab954f5f1303f7fbc4fe5b0b5ddae509a2c78 100644 --- a/extra/exports +++ b/extra/exports @@ -169,7 +169,6 @@ console_set_output_format cord_ibuf_drop cord_ibuf_put cord_ibuf_take -cord_slab_cache crc32_calc crypto_ERR_error_string crypto_ERR_get_error diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c index 6ed65bba53712e7fe8add56b2db46f9632907564..4ba0fc5c91d4121d3d0f913fa2be1c7fcbb96399 100644 --- a/src/lib/core/fiber.c +++ b/src/lib/core/fiber.c @@ -1983,12 +1983,6 @@ cord_is_main(void) return cord() == &main_cord; } -struct slab_cache * -cord_slab_cache(void) -{ - return &cord()->slabc; -} - void cord_cancel_and_join(struct cord *cord) { diff --git a/src/lib/core/fiber.h b/src/lib/core/fiber.h index 3fd2d81c1d6cde78f3350d426c1a2c73eb98adbf..13b2aefbecdd77d478f9822a9d9077b219872f91 100644 --- a/src/lib/core/fiber.h +++ b/src/lib/core/fiber.h @@ -425,14 +425,6 @@ fiber_clock64(void); API_EXPORT void fiber_reschedule(void); -struct slab_cache; - -/** - * Return slab_cache suitable to use with tarantool/small library - */ -API_EXPORT struct slab_cache * -cord_slab_cache(void); - /** * box region allocator * @@ -910,6 +902,15 @@ cord_collect_garbage(struct cord *cord); void cord_cancel_and_join(struct cord *cord); +/** + * Return slab_cache suitable to use with tarantool/small library + */ +static inline struct slab_cache * +cord_slab_cache(void) +{ + return &cord()->slabc; +} + /** * @brief Create a new system fiber. * diff --git a/test/app-tap/module_api.c b/test/app-tap/module_api.c index 8190f8508a3b000e359e1009cda6452cbdec6e3c..aa54dd5504f1c4ff622ea59919d92c23034226d4 100644 --- a/test/app-tap/module_api.c +++ b/test/app-tap/module_api.c @@ -181,49 +181,51 @@ test_checkint64(lua_State *L) return 1; } +/* {{{ Helpers for `box_ibuf` C API test cases */ + static int test_box_ibuf(lua_State *L) { - struct slab_cache *slabc = cord_slab_cache(); - fail_unless(slabc != NULL); - box_ibuf_t ibuf; + box_ibuf_t *ibuf; + ibuf = luaT_toibuf(L, -1); - ibuf_create(&ibuf, slabc, 16320); - fail_unless(ibuf_used(&ibuf) == 0); - void *ptr = box_ibuf_reserve(&ibuf, 65536); + fail_unless(ibuf_used(ibuf) == 0); + void *ptr = box_ibuf_reserve(ibuf, 65536); fail_unless(ptr != NULL); char **rpos; char **wpos; - box_ibuf_read_range(&ibuf, &rpos, &wpos); + box_ibuf_read_range(ibuf, &rpos, &wpos); - ptr = ibuf_alloc(&ibuf, 10); + ptr = ibuf_alloc(ibuf, 10); fail_unless(ptr != NULL); - fail_unless(ibuf_used(&ibuf) == 10); + fail_unless(ibuf_used(ibuf) == 10); fail_unless((*wpos - *rpos) == 10); /* let be a little bit paranoid and double check */ - box_ibuf_read_range(&ibuf, &rpos, &wpos); + box_ibuf_read_range(ibuf, &rpos, &wpos); fail_unless((*wpos - *rpos) == 10); - ptr = ibuf_alloc(&ibuf, 10000); + ptr = ibuf_alloc(ibuf, 10000); fail_unless(ptr != NULL); - fail_unless(ibuf_used(&ibuf) == 10010); + fail_unless(ibuf_used(ibuf) == 10010); fail_unless((*wpos - *rpos) == 10010); - size_t unused = ibuf_unused(&ibuf); + size_t unused = ibuf_unused(ibuf); char **end; - box_ibuf_write_range(&ibuf, &wpos, &end); + box_ibuf_write_range(ibuf, &wpos, &end); fail_unless((*end - *wpos) == (ptrdiff_t)unused); - ibuf_reset(&ibuf); - fail_unless(ibuf_used(&ibuf) == 0); + ibuf_reset(ibuf); + fail_unless(ibuf_used(ibuf) == 0); fail_unless(*rpos == *wpos); lua_pushboolean(L, 1); return 1; } +/* }}} Helpers for `box_ibuf` C API test cases */ + static int test_toibuf(lua_State *L) { @@ -334,19 +336,6 @@ test_fiber_set_ctx(lua_State *L) return 1; } -static int -test_cord(lua_State *L) -{ - struct slab_cache *slabc = cord_slab_cache(); - fail_unless(slabc != NULL); - struct ibuf ibuf; - ibuf_create(&ibuf, slabc, 16320); - ibuf_destroy(&ibuf); - - lua_pushboolean(L, 1); - return 1; -} - static int test_pushcdata(lua_State *L) { @@ -3172,7 +3161,6 @@ luaopen_module_api(lua_State *L) {"test_toint64", test_toint64 }, {"test_fiber", test_fiber }, {"test_fiber_set_ctx", test_fiber_set_ctx }, - {"test_cord", test_cord }, {"pushcdata", test_pushcdata }, {"checkcdata", test_checkcdata }, {"test_clock", test_clock }, @@ -3195,7 +3183,7 @@ luaopen_module_api(lua_State *L) {"test_key_def_merge", test_key_def_merge}, {"test_key_def_extract_key", test_key_def_extract_key}, {"test_key_def_validate_key", test_key_def_validate_key}, - {"test_box_ibuf", test_box_ibuf}, + {"box_ibuf", test_box_ibuf}, {"tuple_validate_def", test_tuple_validate_default}, {"tuple_validate_fmt", test_tuple_validate_formatted}, {"test_key_def_dup", test_key_def_dup}, diff --git a/test/app-tap/module_api.test.lua b/test/app-tap/module_api.test.lua index 76303a24ecbc03ad3db8d4d8adf25fcdf9d18dbb..3e72004d7ce985cabc022ed6374d60a0dbd07bbf 100755 --- a/test/app-tap/module_api.test.lua +++ b/test/app-tap/module_api.test.lua @@ -663,8 +663,15 @@ local function test_box_iproto_override(test, module) module.box_iproto_override_reset(box.iproto.type.PING) end +-- Wrapper for passing an `ibuf` to the `box_ibuf` C API test. +local function test_box_ibuf(test, module) + test:plan(1) + + test:ok(module.box_ibuf(require('buffer').ibuf()), "box_ibuf API") +end + require('tap').test("module_api", function(test) - test:plan(49) + test:plan(48) local status, module = pcall(require, 'module_api') test:is(status, true, "module") test:ok(status, "module is loaded") @@ -701,6 +708,7 @@ require('tap').test("module_api", function(test) test:test("box_session_id_matches", test_box_session_id_matches, module) test:test("box_iproto_send", test_box_iproto_send, module) test:test("box_iproto_override", test_box_iproto_override, module) + test:test("box_ibuf", test_box_ibuf, module) space:drop() end)