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 79109741EE; Fri, 6 Aug 2021 03:27:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 79109741EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628209660; bh=KzQ1qWG+DKHUFArM2Gn//XyBaDA1f5r+h504/V2XECI=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LSsWsaAKNN5EmWsh6W80m5o40i+7jXJXQRPsAAv2y/RSVzBIckUmr+TutzXSO7jc4 dqCG1YWyEBQusPkkj0GDowRoYDX3A4o4SvZdd5ab3uTWKz+Y0fhzq8qmbPYbiGfTYT WZjCOy/BbJbXBCCGGfJj7W3Mev5FY+4EaM/Q7weo= Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (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 10B34741EA for ; Fri, 6 Aug 2021 03:27:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 10B34741EA Received: by smtp3.mail.ru with esmtpa (envelope-from ) id 1mBni4-0004FV-Jj; Fri, 06 Aug 2021 03:27:37 +0300 To: v.shpilevoy@tarantool.org, olegrok@tarantool.org References: Message-ID: <78245e5f-2a1e-ee6c-7c65-e9999441f8ba@tarantool.org> Date: Fri, 6 Aug 2021 03:27:36 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9BCE6B93DE0C6C3914462CDB1732D383C182A05F5380850407181A94F0C286C7694D1B38627D45BB3C3D4FBF2BC67A32518B635FF683862EE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F9D3BE5B596754B8C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7AB524098FB2F2222EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F20E75CCEDEFBF9078677271C193B0BEB8CC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CC15841AC4D79B974C0837EA9F3D197644AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C34046BBBC458D877CBA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7D151390FFDBF6399731C566533BA786AA5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458F0AFF96BAACF4158235E5A14AD4A4A4625E192CAD1D9E79D94463893BF8742D04B4C1984257714FD X-C1DE0DAB: 0D63561A33F958A57898EFE2DF5AFE6A6FDB109C41DA224914BD6FCC7D58586BD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7501A9DF589746230F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34047E322BFAFD69BDDAB81A73D4E7E3C3571F177CF13702391C01EF9DE9096A3753E3861D29A61F571D7E09C32AA3244CD7871662F891E7677B90538F860073231E098CBE561D634383B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojFhlvmGwdUwSP4UDGdHDrAQ== X-Mailru-Sender: B5B6A6EBBD94DAD81091F6801AA03C01355C29F9B61C34EABDCBF14E36448EDF49E4D5238DB0B3495C2808D6142752370A8ED71B308007E3DC85537438B7E1A423D748DE48713E689437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [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: Safin Timur via Tarantool-patches Reply-To: Safin Timur Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This change dissolved in many patches. On 02.08.2021 3:41, Timur Safin wrote: > 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); >