Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>,
	Maxim Kokryashkin <m.kokryashkin@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit 3/4] FFI: Allow ffi.metatype() for typedefs with attributes.
Date: Tue, 11 Jun 2024 18:48:01 +0300	[thread overview]
Message-ID: <c37f18a9-230a-49d5-9db5-1f3ad5ebea0b@tarantool.org> (raw)
In-Reply-To: <034b0afe429e672809ec8192ff1fb41a7bfd2937.1717424008.git.skaplun@tarantool.org>

[-- Attachment #1: Type: text/plain, Size: 2409 bytes --]

Hi, Sergey

thanks for the patch! LGTM with a nit below.

On 03.06.2024 17:34, Sergey Kaplun wrote:
> From: Mike Pall <mike>
>
> Reported by Eric Gouyer.
>
> (cherry picked from commit 27a6fee82e91319bbed8c3aa443aa2b0f1b0a470)
>
> Before the patch, `ffi.metatype()` raises an error when calling it on
> ctype with attributes.  This patch fixes the behaviour by using
extra whitespace above
> `ctype_raw()` instead of `ctype_get()` to follow child ctypes unless
> there are no attributes on the ctype.
>
> Sergey Kaplun:
> * added the description and the test for the problem
>
> Part of tarantool/tarantool#9924
> ---
>   src/lib_ffi.c                                         |  2 +-
>   test/tarantool-tests/lj-861-ctype-attributes.test.lua | 10 +++++++---
>   2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib_ffi.c b/src/lib_ffi.c
> index 2bfca25a..dfb01658 100644
> --- a/src/lib_ffi.c
> +++ b/src/lib_ffi.c
> @@ -770,7 +770,7 @@ LJLIB_CF(ffi_metatype)
>     CTypeID id = ffi_checkctype(L, cts, NULL);
>     GCtab *mt = lj_lib_checktab(L, 2);
>     GCtab *t = cts->miscmap;
> -  CType *ct = ctype_get(cts, id);  /* Only allow raw types. */
> +  CType *ct = ctype_raw(cts, id);
>     TValue *tv;
>     GCcdata *cd;
>     if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) ||
> diff --git a/test/tarantool-tests/lj-861-ctype-attributes.test.lua b/test/tarantool-tests/lj-861-ctype-attributes.test.lua
> index e8b29d67..a407fae0 100644
> --- a/test/tarantool-tests/lj-861-ctype-attributes.test.lua
> +++ b/test/tarantool-tests/lj-861-ctype-attributes.test.lua
> @@ -7,14 +7,14 @@ local tap = require('tap')
>   local test = tap.test('lj-861-ctype-attributes')
>   local ffi = require('ffi')
>   
> -test:plan(4)
> +test:plan(5)
>   
>   local EXPECTED_ALIGN = 4
>   
>   ffi.cdef([[
> -struct __attribute__((aligned($))) s_aligned {
> +typedef struct __attribute__((aligned($))) s_aligned {
>     uint8_t a;
> -};
> +} s_aligned;
>   
>   struct test_parsing_sizeof {
>     char a[sizeof(struct s_aligned &)];
> @@ -37,4 +37,8 @@ test:is(ffi.sizeof('struct test_parsing_sizeof'), EXPECTED_ALIGN,
>   test:is(ffi.sizeof('struct test_parsing_alignof'), EXPECTED_ALIGN,
>           'correct alignof during C parsing')
>   
> +local ok, _ = pcall(ffi.metatype, 's_aligned', {})
> +
> +test:ok(ok, 'ffi.metatype is called at the structure with attributes')
> +
>   test:done(true)

[-- Attachment #2: Type: text/html, Size: 2969 bytes --]

  reply	other threads:[~2024-06-11 15:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03 14:33 [Tarantool-patches] [PATCH luajit 0/4] Fixes for ctypes " Sergey Kaplun via Tarantool-patches
2024-06-03 14:33 ` [Tarantool-patches] [PATCH luajit 1/4] FFI: Fix ffi.alignof() for reference types Sergey Kaplun via Tarantool-patches
2024-06-11 15:40   ` Sergey Bronnikov via Tarantool-patches
2024-06-14 12:19   ` Maxim Kokryashkin via Tarantool-patches
2024-06-03 14:34 ` [Tarantool-patches] [PATCH luajit 2/4] FFI: Fix sizeof expression in C parser " Sergey Kaplun via Tarantool-patches
2024-06-11 15:42   ` Sergey Bronnikov via Tarantool-patches
2024-06-14 12:21   ` Maxim Kokryashkin via Tarantool-patches
2024-06-03 14:34 ` [Tarantool-patches] [PATCH luajit 3/4] FFI: Allow ffi.metatype() for typedefs with attributes Sergey Kaplun via Tarantool-patches
2024-06-11 15:48   ` Sergey Bronnikov via Tarantool-patches [this message]
2024-06-13  7:34     ` Sergey Kaplun via Tarantool-patches
2024-06-13 15:14       ` Sergey Bronnikov via Tarantool-patches
2024-06-14 12:39   ` Maxim Kokryashkin via Tarantool-patches
2024-06-03 14:34 ` [Tarantool-patches] [PATCH luajit 4/4] FFI: Fix ffi.metatype() for non-raw types Sergey Kaplun via Tarantool-patches
2024-06-11 15:50   ` Sergey Bronnikov via Tarantool-patches
2024-06-14 12:40   ` Maxim Kokryashkin via Tarantool-patches
2024-07-09  8:03 ` [Tarantool-patches] [PATCH luajit 0/4] Fixes for ctypes with attributes Sergey Kaplun 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=c37f18a9-230a-49d5-9db5-1f3ad5ebea0b@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.kokryashkin@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 3/4] FFI: Allow ffi.metatype() for typedefs with attributes.' \
    /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