From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 4F84A6EC58; Mon, 2 Aug 2021 03:46:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4F84A6EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627865172; bh=lJ6V1OcgZ2v9jncFZ2nIo1nrj9tv15tkU5SKzeb2ybs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Bg3i2qgMnfTA4V7ExWRveWUEFaNsNpKK0dS63wdxvlTKKA4gq3c6rfVRpw+/8x1oj w8l7Qnx9C5gDA4AtPod09XVZny+r27FtY7MWg0Qjl5mItOih4CCEjK2Wv49UFUmjqP iVl/hJiuLAUrPWvj/O4EmidwBB7hNqkeOJjo/3LA= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 579B36E473 for ; Mon, 2 Aug 2021 03:41:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 579B36E473 Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1mAM1S-0000PY-Qf; Mon, 02 Aug 2021 03:41:39 +0300 To: v.shpilevoy@tarantool.org, olegrok@tarantool.org Date: Mon, 2 Aug 2021 03:41:05 +0300 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD941C43E597735A9C3FDAB68B812060C77E97CF8617D978122182A05F538085040FE57E8EA635968046B47915FD8A954737C4C97A4CFEB87D9E62BA122491DB35D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F9D3BE5B596754B8C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE737AE489DBC023F2AEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F235656659E5DA2C93291A66869C4450EECC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C0C6F18EE27F98D4EAD7EC71F1DB884274AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C34B26726BD97DF1CFBA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE72F88032165008D51731C566533BA786AA5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458F0AFF96BAACF4158235E5A14AD4A4A4625E192CAD1D9E79DB53CE84373687089D276D1A37C966CAE X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C85811CA530B504918747506F5545CBDC647441D2AFDE34189C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF03D88DA7F5FEDC25699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D041FB2E16F174C4FB0261C35BB30BE0B760D63CA6F647B1FD5C2FBBCE31AEC35800B3A2BF4F8D741D7E09C32AA3244CE0A375EB6F360D47075B06AACAD762721DD47778AE04E04D8D5DD81C2BAB7D1D X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMCfuYI4Pred7Q64aRK5d9g== X-Mailru-Sender: B5B6A6EBBD94DAD8315E1362B7B20B88DEAF1C7620D8E5B080DADE4B61A702D05EDFEAEC550964125C2808D6142752370A8ED71B308007E3DC85537438B7E1A423D748DE48713E689437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v3 9/9] lua, box, datetime: rename struct datetime_t X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Timur Safin via Tarantool-patches Reply-To: Timur Safin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Renamed all references: - `struct datetime_t` -> `struct datetime`; - `struct datetime_interval_t` -> `struct datetime_interval`. Part of #5941 --- src/box/tuple_compare.cc | 10 +++++----- src/lib/core/datetime.c | 25 ++++++++++++------------- src/lib/core/datetime.h | 29 ++++++++++++++--------------- src/lib/mpstream/mpstream.c | 3 +-- src/lib/mpstream/mpstream.h | 5 ++--- src/lua/datetime.lua | 6 +++--- src/lua/msgpack.c | 2 +- src/lua/msgpackffi.lua | 8 ++++---- src/lua/serializer.c | 2 +- src/lua/serializer.h | 2 +- src/lua/utils.c | 10 +++++----- src/lua/utils.h | 4 ++-- test/unit/datetime.c | 17 +++++++++-------- 13 files changed, 60 insertions(+), 63 deletions(-) diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc index f733b9f01..530417fcc 100644 --- a/src/box/tuple_compare.cc +++ b/src/box/tuple_compare.cc @@ -397,8 +397,8 @@ mp_compare_uuid(const char *field_a, const char *field_b) static int mp_compare_datetime(const char *lhs, const char *rhs) { - datetime_t lhs_dt, rhs_dt; - datetime_t *ret; + datetime lhs_dt, rhs_dt; + datetime *ret; ret = mp_decode_datetime(&lhs, &lhs_dt); assert(ret != NULL); ret = mp_decode_datetime(&rhs, &rhs_dt); @@ -1648,7 +1648,7 @@ hint_uuid_raw(const char *data) } static inline hint_t -hint_datetime(struct datetime_t *date) +hint_datetime(struct datetime *date) { /* * Use at most HINT_VALUE_SECS_BITS from datetime @@ -1803,7 +1803,7 @@ field_hint_datetime(const char *field) int8_t ext_type; uint32_t len = mp_decode_extl(&field, &ext_type); assert(ext_type == MP_DATETIME); - struct datetime_t date; + struct datetime date; return hint_datetime(datetime_unpack(&field, len, &date)); } @@ -1860,7 +1860,7 @@ field_hint_scalar(const char *field, struct coll *coll) return hint_uuid_raw(field); case MP_DATETIME: { - struct datetime_t date; + struct datetime date; return hint_datetime(datetime_unpack(&field, len, &date)); } default: diff --git a/src/lib/core/datetime.c b/src/lib/core/datetime.c index 96e554bd2..03facb123 100755 --- a/src/lib/core/datetime.c +++ b/src/lib/core/datetime.c @@ -84,7 +84,7 @@ mp_decode_Xint(const char **data) } static inline uint32_t -mp_sizeof_datetime_raw(const struct datetime_t *date) +mp_sizeof_datetime_raw(const struct datetime *date) { uint32_t sz = mp_sizeof_Xint(date->secs); @@ -98,13 +98,13 @@ mp_sizeof_datetime_raw(const struct datetime_t *date) } uint32_t -mp_sizeof_datetime(const struct datetime_t *date) +mp_sizeof_datetime(const struct datetime *date) { return mp_sizeof_ext(mp_sizeof_datetime_raw(date)); } -struct datetime_t * -datetime_unpack(const char **data, uint32_t len, struct datetime_t *date) +struct datetime * +datetime_unpack(const char **data, uint32_t len, struct datetime *date) { const char * svp = *data; @@ -128,8 +128,8 @@ datetime_unpack(const char **data, uint32_t len, struct datetime_t *date) return date; } -struct datetime_t * -mp_decode_datetime(const char **data, struct datetime_t *date) +struct datetime * +mp_decode_datetime(const char **data, struct datetime *date) { if (mp_typeof(**data) != MP_EXT) return NULL; @@ -144,7 +144,7 @@ mp_decode_datetime(const char **data, struct datetime_t *date) } char * -datetime_pack(char *data, const struct datetime_t *date) +datetime_pack(char *data, const struct datetime *date) { data = mp_encode_Xint(data, date->secs); if (date->nsec != 0 || date->offset != 0) @@ -156,7 +156,7 @@ datetime_pack(char *data, const struct datetime_t *date) } char * -mp_encode_datetime(char *data, const struct datetime_t *date) +mp_encode_datetime(char *data, const struct datetime *date) { uint32_t len = mp_sizeof_datetime_raw(date); @@ -165,8 +165,7 @@ mp_encode_datetime(char *data, const struct datetime_t *date) return datetime_pack(data, date); } -int -datetime_to_string(const struct datetime_t * date, char *buf, uint32_t len) +int datetime_to_string(const struct datetime *date, char *buf, uint32_t len) { char * src = buf; int offset = date->offset; @@ -218,7 +217,7 @@ datetime_to_string(const struct datetime_t * date, char *buf, uint32_t len) int mp_snprint_datetime(char *buf, int size, const char **data, uint32_t len) { - struct datetime_t date = {0}; + struct datetime date = {0}; if (datetime_unpack(data, len, &date) == NULL) return -1; @@ -229,7 +228,7 @@ mp_snprint_datetime(char *buf, int size, const char **data, uint32_t len) int mp_fprint_datetime(FILE *file, const char **data, uint32_t len) { - struct datetime_t date; + struct datetime date; if (datetime_unpack(data, len, &date) == NULL) return -1; @@ -240,7 +239,7 @@ mp_fprint_datetime(FILE *file, const char **data, uint32_t len) return fprintf(file, "%s", buf); } -int datetime_compare(const struct datetime_t *lhs, const struct datetime_t *rhs) +int datetime_compare(const struct datetime *lhs, const struct datetime *rhs) { int result = COMPARE_RESULT(lhs->secs, rhs->secs); if (result != 0) diff --git a/src/lib/core/datetime.h b/src/lib/core/datetime.h index 2c9530ad7..540bd68d9 100644 --- a/src/lib/core/datetime.h +++ b/src/lib/core/datetime.h @@ -50,7 +50,8 @@ extern "C" * Time is kept normalized to UTC, time-zone offset * is informative only. */ -struct datetime_t { +struct datetime +{ int64_t secs; /**< seconds since epoch */ int32_t nsec; /**< nanoseconds if any */ int32_t offset; /**< offset in minutes from UTC */ @@ -59,42 +60,41 @@ struct datetime_t { /** * Date/time interval structure */ -struct datetime_interval_t { +struct datetime_interval +{ int64_t secs; /**< relative seconds delta */ int32_t nsec; /**< nanoseconds delta */ }; -int -datetime_compare(const struct datetime_t * lhs, - const struct datetime_t * rhs); +int datetime_compare(const struct datetime *lhs, + const struct datetime *rhs); - -struct datetime_t * -datetime_unpack(const char **data, uint32_t len, struct datetime_t *date); +struct datetime * +datetime_unpack(const char **data, uint32_t len, struct datetime *date); /** * Pack datetime_t data to the MessagePack buffer. */ char * -datetime_pack(char *data, const struct datetime_t *date); +datetime_pack(char *data, const struct datetime *date); /** * Calculate size of MessagePack buffer for datetime_t data. */ uint32_t -mp_sizeof_datetime(const struct datetime_t *date); +mp_sizeof_datetime(const struct datetime *date); /** * Decode data from MessagePack buffer to datetime_t structure. */ -struct datetime_t * -mp_decode_datetime(const char **data, struct datetime_t *date); +struct datetime * +mp_decode_datetime(const char **data, struct datetime *date); /** * Encode datetime_t structure to the MessagePack buffer. */ char * -mp_encode_datetime(char *data, const struct datetime_t *date); +mp_encode_datetime(char *data, const struct datetime *date); /** * Convert datetime to string using default format @@ -102,8 +102,7 @@ mp_encode_datetime(char *data, const struct datetime_t *date); * @param buf output character buffer * @param len size ofoutput buffer */ -int -datetime_to_string(const struct datetime_t * date, char *buf, uint32_t len); +int datetime_to_string(const struct datetime *date, char *buf, uint32_t len); int mp_snprint_datetime(char *buf, int size, const char **data, uint32_t len); diff --git a/src/lib/mpstream/mpstream.c b/src/lib/mpstream/mpstream.c index 1077e3b19..2af77c205 100644 --- a/src/lib/mpstream/mpstream.c +++ b/src/lib/mpstream/mpstream.c @@ -209,8 +209,7 @@ mpstream_encode_uuid(struct mpstream *stream, const struct tt_uuid *uuid) mpstream_advance(stream, pos - data); } -void -mpstream_encode_datetime(struct mpstream *stream, const struct datetime_t *val) +void mpstream_encode_datetime(struct mpstream *stream, const struct datetime *val) { char *data = mpstream_reserve(stream, mp_sizeof_datetime(val)); if (data == NULL) diff --git a/src/lib/mpstream/mpstream.h b/src/lib/mpstream/mpstream.h index 540e9a666..9e0ed6e72 100644 --- a/src/lib/mpstream/mpstream.h +++ b/src/lib/mpstream/mpstream.h @@ -39,7 +39,7 @@ extern "C" { #endif /* defined(__cplusplus) */ struct tt_uuid; -struct datetime_t; +struct datetime; /** * Ask the allocator to reserve at least size bytes. It can reserve @@ -146,8 +146,7 @@ mpstream_encode_decimal(struct mpstream *stream, const decimal_t *val); void mpstream_encode_uuid(struct mpstream *stream, const struct tt_uuid *uuid); -void -mpstream_encode_datetime(struct mpstream *stream, const struct datetime_t *dt); +void mpstream_encode_datetime(struct mpstream *stream, const struct datetime *dt); /** Copies n bytes from memory area src to stream. */ void diff --git a/src/lua/datetime.lua b/src/lua/datetime.lua index dc88a9d9d..5cad4e02f 100644 --- a/src/lua/datetime.lua +++ b/src/lua/datetime.lua @@ -80,7 +80,7 @@ ffi.cdef [[ // datetime.c int - datetime_to_string(const struct datetime_t * date, char *buf, uint32_t len); + datetime_to_string(const struct datetime * date, char *buf, uint32_t len); // @@ -180,8 +180,8 @@ local NANOS_PER_SEC = 1000000000LL local DT_EPOCH_1970_OFFSET = 719163LL -local datetime_t = ffi.typeof('struct datetime_t') -local interval_t = ffi.typeof('struct datetime_interval_t') +local datetime_t = ffi.typeof('struct datetime') +local interval_t = ffi.typeof('struct datetime_interval') ffi.cdef [[ struct t_interval_months { int m; diff --git a/src/lua/msgpack.c b/src/lua/msgpack.c index 0a4ba8129..9c1acc4dc 100644 --- a/src/lua/msgpack.c +++ b/src/lua/msgpack.c @@ -339,7 +339,7 @@ luamp_decode(struct lua_State *L, struct luaL_serializer *cfg, } case MP_DATETIME: { - struct datetime_t * date = luaL_pushdatetime(L); + struct datetime *date = luaL_pushdatetime(L); date = datetime_unpack(data, len, date); if (date == NULL) goto ext_decode_err; diff --git a/src/lua/msgpackffi.lua b/src/lua/msgpackffi.lua index c47d77acb..fb5e7d644 100644 --- a/src/lua/msgpackffi.lua +++ b/src/lua/msgpackffi.lua @@ -40,8 +40,8 @@ decimal_t * decimal_unpack(const char **data, uint32_t len, decimal_t *dec); struct tt_uuid * uuid_unpack(const char **data, uint32_t len, struct tt_uuid *uuid); -struct datetime_t * -datetime_unpack(const char **data, uint32_t len, struct datetime_t *date); +struct datetime * +datetime_unpack(const char **data, uint32_t len, struct datetime *date); ]]) local strict_alignment = (jit.arch == 'arm') @@ -331,7 +331,7 @@ on_encode(ffi.typeof('float'), encode_float) on_encode(ffi.typeof('double'), encode_double) on_encode(ffi.typeof('decimal_t'), encode_decimal) on_encode(ffi.typeof('struct tt_uuid'), encode_uuid) -on_encode(ffi.typeof('struct datetime_t'), encode_datetime) +on_encode(ffi.typeof('struct datetime'), encode_datetime) -------------------------------------------------------------------------------- -- Decoder @@ -527,7 +527,7 @@ local ext_decoder = { end, -- MP_DATETIME [4] = function(data, len) - local dt = ffi.new("struct datetime_t") + local dt = ffi.new("struct datetime") builtin.datetime_unpack(data, len, dt) return dt end, diff --git a/src/lua/serializer.c b/src/lua/serializer.c index c27e62c62..24f4a5ff9 100644 --- a/src/lua/serializer.c +++ b/src/lua/serializer.c @@ -547,7 +547,7 @@ luaL_tofield(struct lua_State *L, struct luaL_serializer *cfg, field->ext_type = MP_ERROR; } else if (cd->ctypeid == CTID_DATETIME) { field->ext_type = MP_DATETIME; - field->dateval = (struct datetime_t*) cdata; + field->dateval = (struct datetime *)cdata; } else { field->ext_type = MP_UNKNOWN_EXTENSION; } diff --git a/src/lua/serializer.h b/src/lua/serializer.h index 52e51d279..e7a240e0a 100644 --- a/src/lua/serializer.h +++ b/src/lua/serializer.h @@ -224,7 +224,7 @@ struct luaL_field { uint32_t size; decimal_t *decval; struct tt_uuid *uuidval; - struct datetime_t *dateval; + struct datetime *dateval; }; enum mp_type type; /* subtypes of MP_EXT */ diff --git a/src/lua/utils.c b/src/lua/utils.c index 685cab47b..9753016c9 100644 --- a/src/lua/utils.c +++ b/src/lua/utils.c @@ -110,7 +110,7 @@ luaL_pushuuid(struct lua_State *L) return luaL_pushcdata(L, CTID_UUID); } -struct datetime_t * +struct datetime * luaL_pushdatetime(struct lua_State *L) { return luaL_pushcdata(L, CTID_DATETIME); @@ -720,22 +720,22 @@ tarantool_lua_utils_init(struct lua_State *L) CTID_UUID = luaL_ctypeid(L, "struct tt_uuid"); assert(CTID_UUID != 0); - rc = luaL_cdef(L, "struct datetime_t {" + rc = luaL_cdef(L, "struct datetime {" "int64_t secs;" "int32_t nsec;" "int32_t offset;" "};"); assert(rc == 0); (void) rc; - CTID_DATETIME = luaL_ctypeid(L, "struct datetime_t"); + CTID_DATETIME = luaL_ctypeid(L, "struct datetime"); assert(CTID_DATETIME != 0); - rc = luaL_cdef(L, "struct datetime_interval_t {" + rc = luaL_cdef(L, "struct datetime_interval {" "int64_t secs;" "int32_t nsec;" "};"); assert(rc == 0); (void) rc; - CTID_INTERVAL = luaL_ctypeid(L, "struct datetime_interval_t"); + CTID_INTERVAL = luaL_ctypeid(L, "struct datetime_interval"); assert(CTID_INTERVAL != 0); lua_pushcfunction(L, luaT_newthread_wrapper); diff --git a/src/lua/utils.h b/src/lua/utils.h index bf56b1bb5..c27065a1c 100644 --- a/src/lua/utils.h +++ b/src/lua/utils.h @@ -59,7 +59,7 @@ struct lua_State; struct ibuf; typedef struct ibuf box_ibuf_t; struct tt_uuid; -struct datetime_t; +struct datetime; /** * Single global lua_State shared by core and modules. @@ -84,7 +84,7 @@ luaL_pushuuid(struct lua_State *L); * @sa luaL_pushcdata * @return memory associated with this datetime_t data */ -struct datetime_t * +struct datetime * luaL_pushdatetime(struct lua_State *L); /** \cond public */ diff --git a/test/unit/datetime.c b/test/unit/datetime.c index 226b6fadb..e8a022542 100644 --- a/test/unit/datetime.c +++ b/test/unit/datetime.c @@ -141,26 +141,27 @@ exit: #define SECS_PER_DAY 86400 #define DT_EPOCH_1970_OFFSET 719163 - -struct datetime_t { +struct datetime +{ int64_t secs; int32_t nsec; int32_t offset; }; static int -local_rd(const struct datetime_t * dt) { +local_rd(const struct datetime *dt) +{ return (int)(dt->secs / SECS_PER_DAY) + DT_EPOCH_1970_OFFSET; } static int -local_dt(const struct datetime_t * dt) { +local_dt(const struct datetime *dt) +{ return dt_from_rdn(local_rd(dt)); } - -struct tm* -datetime_to_tm(struct datetime_t * dt) +struct tm * +datetime_to_tm(struct datetime *dt) { static struct tm tm; @@ -198,7 +199,7 @@ static void datetime_test(void) // check that stringized literal produces the same date // time fields static char buff[40]; - struct datetime_t dt = {secs, nanosecs, ofs}; + struct datetime dt = {secs, nanosecs, ofs}; // datetime_to_tm returns time in GMT zone struct tm * p_tm = datetime_to_tm(&dt); size_t len = strftime(buff, sizeof buff, "%F %T%z", p_tm); -- 2.29.2