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 701589DB7B8; Mon, 29 Jan 2024 13:59:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 701589DB7B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706525996; bh=icnAeq5XYf6DfDaGB4gLnI2DBWptHZYl1wBUvSbggOQ=; 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=C0biq3iZNiTRErX7VTWIaahwxC1ok7o5TAHTmJimIrSF6i9OVNpGN4eyWObXt9Ff8 IIfgBsP2wjjNv7dLpd30CB+LBD2J2/LCl6Vx/tm+g1ItBWYgg3GGuz3mdbLkBFgLUR YV+XCnWjAItSWvGZ1Gx24bnHhHauBl5pnFBaFsTo= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [95.163.41.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 903069DC606 for ; Mon, 29 Jan 2024 13:49:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 903069DC606 Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1rUPDB-0000000BQ6r-30nd; Mon, 29 Jan 2024 13:49:58 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 29 Jan 2024 13:45:21 +0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96A58C36AA2E996491AB5482BACCB3FBCCBBF638FE815CE47182A05F5380850408780817C280EE8E933594132A326AF8B82EF9AA8A6C2176FDCA41764705814781A3BE929C6DF5677 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72F22E6DC541F75D9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F39D5C6FCD02A9C38638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8B69A4EC2D897F8BABE1BF1E404F07B8E51E09A513119E03ECC7F00164DA146DAFE8445B8C89999728AA50765F79006374F09588CB15B21E6389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC878444BBB7636F62AF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C4B1E592663965C8BC0837EA9F3D197644AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3C9EFC713E70D1A96BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CFED8438A78DFE0A9E1DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3CD42BCEBB57B85E635872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A53AEB2B2763C66BC45002B1117B3ED6967F7899587D9AB2A20E58516B1639A14B823CB91A9FED034534781492E4B8EEAD5DF1C2DF01CE7211C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF6A086230AEDAE8263BE546E09A2D26464F512592F4C1C9BB1FB585A52B33DB58657CCA151A12AF58FB01E7B8BF01A69EDDF3291903B2DA3B718120DE96C5CC579A5F3F7F4BC26B0C226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmd9AG1X07oT0Kv/2sx/Puw== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A7698B8240C88AF2027333594132A326AF8B82EF9AA8A6C2176FB7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable LuaJIT test 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: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch changes `dofile()` (which uses an unreliable relative file path and mutates `_G` with global functions to be defined) to the corresponding `require()` of the helper functions. It adds groups with the names of subtests and enables the test in . Part of tarantool/tarantool#9398 --- .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++--------- test/LuaJIT-tests/lib/ffi/index | 1 + 2 files changed, 176 insertions(+), 160 deletions(-) diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua index 16a3d053..cb231c33 100644 --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua @@ -1,113 +1,123 @@ local ffi = require("ffi") -dofile("../common/ffi_util.inc") +local checkfail = require("common.ffi.checkfail") +local checktypes = require("common.ffi.checktypes") +local fails = require("common.fails") -checkfail{ - "struct", - "struct {", - "struct xx xx {}", - "struct { int x }", - "struct { int x, }", - "struct { int x,y }", - "struct { void x; }", - "struct { int x(void); }", - "struct recursive1 { struct recursive1 { } x; }", - "union", - "union {", - "union xx xx {}", - "union { int x }", - "union { int x, }", - "union { int x,y }", - "union { void x; }", - "union { int x(void); }", - "union recursive1 { union recursive1 { } x; }", -} +local P = ffi.sizeof("void *") +local A = (ffi.arch == "x86" and not ffi.abi("win")) and 4 or 8 + +do --- checkfail + checkfail{ + "struct", + "struct {", + "struct xx xx {}", + "struct { int x }", + "struct { int x, }", + "struct { int x,y }", + "struct { void x; }", + "struct { int x(void); }", + "struct recursive1 { struct recursive1 { } x; }", + "union", + "union {", + "union xx xx {}", + "union { int x }", + "union { int x, }", + "union { int x,y }", + "union { void x; }", + "union { int x(void); }", + "union recursive1 { union recursive1 { } x; }", + } +end -- NYI: rollback doesn't recover struct state -- ffi.cdef("struct zzz") -- fails(ffi.cdef, "struct zzz { int") -- ffi.cdef("struct zzz { int x; }") -ffi.cdef("struct foo; typedef struct foo foo_t;") -assert(ffi.sizeof("struct foo") == nil) -assert(ffi.sizeof("foo_t") == nil) -ffi.cdef("struct foo { int x,y; };") -assert(ffi.sizeof("struct foo") == 8) -assert(ffi.sizeof("foo_t") == 8) -assert(ffi.sizeof(ffi.typeof("struct foo")) == 8) -assert(ffi.sizeof(ffi.typeof("foo_t")) == 8) -ffi.cdef("struct foo;") -fails(ffi.cdef, "struct foo {};") -fails(ffi.cdef, "union foo;") -fails(ffi.cdef, "union foo {};") -fails(ffi.cdef, "enum foo;") -fails(ffi.cdef, "enum foo { ZZZ1 };") - -local P = ffi.sizeof("void *") -local A = (ffi.arch == "x86" and not ffi.abi("win")) and 4 or 8 +do --- siezeofs and invalid decalarations + ffi.cdef("struct foo; typedef struct foo struct_foo_t;") + assert(ffi.sizeof("struct foo") == nil) + assert(ffi.sizeof("struct_foo_t") == nil) + ffi.cdef("struct foo { int x,y; };") + assert(ffi.sizeof("struct foo") == 8) + assert(ffi.sizeof("struct_foo_t") == 8) + assert(ffi.sizeof(ffi.typeof("struct foo")) == 8) + assert(ffi.sizeof(ffi.typeof("struct_foo_t")) == 8) + ffi.cdef("struct foo;") + fails(ffi.cdef, "struct foo {};") + fails(ffi.cdef, "union foo;") + fails(ffi.cdef, "union foo {};") + fails(ffi.cdef, "enum foo;") + fails(ffi.cdef, "enum foo { ZZZ1 };") +end -checktypes{ - 0, 1, "struct {}", - 1, 1, "struct { char x; }", - 2, 1, "struct { char x,y; }", - 4, 1, "struct { char x,y; char a,b; }", - 4, 2, "struct { char x; short y; }", - 4, 2, "struct { short x; char y; }", - 8, 4, "struct { char x; int y; }", - 8, 4, "struct { int x; char y; }", - 12, 4, "struct { char x; int y; char z; }", - P*4, P, "struct { char x,*y,**z,a,b,c,d; }", - 64, 4, "struct { struct { struct { struct { int x,y; } a,b; } a,b; } a,b; }", - 4, 4, "struct { struct { struct { struct { int x; }; }; }; }", - 8, 4, "struct { struct foo; }", - 8, 4, "struct { foo_t; }", - 8, 8, "struct __attribute__((aligned(sizeof(foo_t)))) { int a; }", - 6, 2, "struct { char a; char x; short y; char z; char c; }", - 10, 2, "struct { char a; struct { char x; short y; char z; } b; char c; }", - 8, A, "struct { double a; }", - A+8, A, "struct { int a; double b; }", - 8, A, "struct { long long a; }", - A+8, A, "struct { int a; long long b; }", - 16, A, "struct { _Complex a; }", - A+16, A, "struct { int a; _Complex b; }", - 8, 8, "struct { float __attribute__((mode(__V2SF__))) a; }", - 16, 8, "struct { int a; float __attribute__((mode(__V2SF__))) b; }", - 16, 8, "struct { float __attribute__((mode(__V2SF__))) a[2]; }", - 24, 8, "struct { int a; float __attribute__((mode(__V2SF__))) b[2]; }", - 16, 16, "struct { float __attribute__((vector_size(16))) a; }", - 32, 16, "struct { int a; float __attribute__((vector_size(16))) b; }", -} +do --- struct base + checktypes{ + 0, 1, "struct {}", + 1, 1, "struct { char x; }", + 2, 1, "struct { char x,y; }", + 4, 1, "struct { char x,y; char a,b; }", + 4, 2, "struct { char x; short y; }", + 4, 2, "struct { short x; char y; }", + 8, 4, "struct { char x; int y; }", + 8, 4, "struct { int x; char y; }", + 12, 4, "struct { char x; int y; char z; }", + P*4, P, "struct { char x,*y,**z,a,b,c,d; }", + 64, 4, "struct { struct { struct { struct { int x,y; } a,b; } a,b; } a,b; }", + 4, 4, "struct { struct { struct { struct { int x; }; }; }; }", + 8, 4, "struct { struct foo; }", + 8, 4, "struct { struct_foo_t; }", + 8, 8, "struct __attribute__((aligned(sizeof(struct_foo_t)))) { int a; }", + 6, 2, "struct { char a; char x; short y; char z; char c; }", + 10, 2, "struct { char a; struct { char x; short y; char z; } b; char c; }", + 8, A, "struct { double a; }", + A+8, A, "struct { int a; double b; }", + 8, A, "struct { long long a; }", + A+8, A, "struct { int a; long long b; }", + 16, A, "struct { _Complex a; }", + A+16, A, "struct { int a; _Complex b; }", + 8, 8, "struct { float __attribute__((mode(__V2SF__))) a; }", + 16, 8, "struct { int a; float __attribute__((mode(__V2SF__))) b; }", + 16, 8, "struct { float __attribute__((mode(__V2SF__))) a[2]; }", + 24, 8, "struct { int a; float __attribute__((mode(__V2SF__))) b[2]; }", + 16, 16, "struct { float __attribute__((vector_size(16))) a; }", + 32, 16, "struct { int a; float __attribute__((vector_size(16))) b; }", + } +end -checktypes{ - 0, 1, "union {}", - 1, 1, "union { char x; }", - 1, 1, "union { char x,y; }", - 2, 2, "union { char x; short y; }", - 2, 2, "union { short x; char y; }", - 4, 4, "union { char x; int y; }", - 4, 4, "union { int x; char y; }", - 4, 4, "union { char x; int y; short z; }", - P, P, "union { char x,*y,**z,a,b,c,d; }", - 4, 4, "union { union { union { union { int x,y; } a,b; } a,b; } a,b; }", - 4, 4, "union { union { union { union { int x; }; }; }; }", - 2, 2, "union { union { short x; }; char y; }", - 2, 2, "union { struct { short x; }; char y; }", - 4, 2, "struct { union { short x; }; char y; }", - 2, 1, "union { struct { char a,b; }; char y; }", - 2, 1, "struct { union { char a,b; }; char y; }", - 8, A, "union { double a; }", - 8, A, "union { int a; double b; }", - 8, A, "union { long long a; }", - 8, A, "union { int a; long long b; }", - 16, A, "union { _Complex a; }", - 16, A, "union { int a; _Complex b; }", - 8, 8, "union { float __attribute__((mode(__V2SF__))) a; }", - 8, 8, "union { int a; float __attribute__((mode(__V2SF__))) b; }", - 16, 16, "union { float __attribute__((vector_size(16))) a; }", - 16, 16, "union { int a; float __attribute__((vector_size(16))) b; }", -} +do --- unions + checktypes{ + 0, 1, "union {}", + 1, 1, "union { char x; }", + 1, 1, "union { char x,y; }", + 2, 2, "union { char x; short y; }", + 2, 2, "union { short x; char y; }", + 4, 4, "union { char x; int y; }", + 4, 4, "union { int x; char y; }", + 4, 4, "union { char x; int y; short z; }", + P, P, "union { char x,*y,**z,a,b,c,d; }", + 4, 4, "union { union { union { union { int x,y; } a,b; } a,b; } a,b; }", + 4, 4, "union { union { union { union { int x; }; }; }; }", + 2, 2, "union { union { short x; }; char y; }", + 2, 2, "union { struct { short x; }; char y; }", + 4, 2, "struct { union { short x; }; char y; }", + 2, 1, "union { struct { char a,b; }; char y; }", + 2, 1, "struct { union { char a,b; }; char y; }", + 8, A, "union { double a; }", + 8, A, "union { int a; double b; }", + 8, A, "union { long long a; }", + 8, A, "union { int a; long long b; }", + 16, A, "union { _Complex a; }", + 16, A, "union { int a; _Complex b; }", + 8, 8, "union { float __attribute__((mode(__V2SF__))) a; }", + 8, 8, "union { int a; float __attribute__((mode(__V2SF__))) b; }", + 16, 16, "union { float __attribute__((vector_size(16))) a; }", + 16, 16, "union { int a; float __attribute__((vector_size(16))) b; }", + } +end -do +do --- struct offsetof local ct ct = ffi.typeof("struct { int a; char b; short c; int d; }") assert(ffi.offsetof(ct, "a") == 0) @@ -129,40 +139,44 @@ do assert(ffi.offsetof(ct, "b") == A) end -checkfail{ - "struct { int :; }", - "struct { int a:; }", - "struct { int a:bad; }", - "struct { int a:0; }", - "struct { int a:33; }", - "struct { int a:-1; }", - "struct { _Bool a:2; }", - "struct { double a:2; }", - "struct { complex a:2; }", - "struct { int __attribute__((mode(__TI__))) a:2; }", - "struct { int __attribute__((vector_size(16))) a:2; }", - "struct { int a[2]:2; }", - "struct { void a:2; }", -} +do --- checkfail bitfields + checkfail{ + "struct { int :; }", + "struct { int a:; }", + "struct { int a:bad; }", + "struct { int a:0; }", + "struct { int a:33; }", + "struct { int a:-1; }", + "struct { _Bool a:2; }", + "struct { double a:2; }", + "struct { complex a:2; }", + "struct { int __attribute__((mode(__TI__))) a:2; }", + "struct { int __attribute__((vector_size(16))) a:2; }", + "struct { int a[2]:2; }", + "struct { void a:2; }", + } +end -checktypes{ - 4, 4, "struct { unsigned a:1; }", - 4, 4, "struct { unsigned a:1, b:1, c:1; }", - 1, 1, "struct { _Bool a:1, b:1, c:1; }", - 8, 4, "struct { unsigned a:16, b:16, c:16; }", - 8, 4, "struct { unsigned a:17, b:16, c:16; }", - 12, 4, "struct { unsigned a:17, b:16, c:17; }", - 12, 4, "struct { unsigned a:16, b:17, c:16; }", - 8, 4, "struct { unsigned a:16, :16, c:16; }", - 8, 4, "struct { unsigned a:17, :16, c:16; }", - 12, 4, "struct { unsigned a:17, :16, c:17; }", - 12, 4, "struct { unsigned a:16, :17, c:16; }", - 8, 4, "struct { unsigned a:16, :0, c:16; }", - 4, 4, "struct { unsigned a:16, b:16, :0, :0; }", - 8, 4, "struct { unsigned a:16, :0, :0, :0, c:16; }", - 1, 1, "struct { char a:1; _Bool b:1; }", - 1, 1, "struct { char a:1; signed char b:1; unsigned char c:1; }", -} +do --- bitfields + checktypes{ + 4, 4, "struct { unsigned a:1; }", + 4, 4, "struct { unsigned a:1, b:1, c:1; }", + 1, 1, "struct { _Bool a:1, b:1, c:1; }", + 8, 4, "struct { unsigned a:16, b:16, c:16; }", + 8, 4, "struct { unsigned a:17, b:16, c:16; }", + 12, 4, "struct { unsigned a:17, b:16, c:17; }", + 12, 4, "struct { unsigned a:16, b:17, c:16; }", + 8, 4, "struct { unsigned a:16, :16, c:16; }", + 8, 4, "struct { unsigned a:17, :16, c:16; }", + 12, 4, "struct { unsigned a:17, :16, c:17; }", + 12, 4, "struct { unsigned a:16, :17, c:16; }", + 8, 4, "struct { unsigned a:16, :0, c:16; }", + 4, 4, "struct { unsigned a:16, b:16, :0, :0; }", + 8, 4, "struct { unsigned a:16, :0, :0, :0, c:16; }", + 1, 1, "struct { char a:1; _Bool b:1; }", + 1, 1, "struct { char a:1; signed char b:1; unsigned char c:1; }", + } +end -- NYI: bit fields > 32 bit -- local L = ffi.alignof("struct { long long a; }") @@ -170,35 +184,36 @@ checktypes{ -- L, L, "struct { long long a:1; }", -- } --- Bit field packing. -checktypes{ - 1, 1, "struct { _Bool a:1, b:1, c:1; }", - 4, 4, "struct { short a:9; int b:9; char c; }", - 4, 4, "struct { char a; int b:7; }", - 4, 4, "struct { short a; char b; int c:7; }", - 4, 4, "struct { char a:7; int b:7; int c:7; int d:10; }", - 4, 1, "struct { char a:7; char b:7; char c:7; char d:7; }", - 4, 4, "struct { char a:7; int b:7, c:7, d:7; int e:4; }", - 4, 4, "struct { char a:7; int b:7, c:7, d:7; char e:4; }", - 5, 1, "struct { char a:7; char b:7, c:7, d:7; char e:4; }", - 4, 1, "struct __attribute__((packed)) { char a:7; char b:7, c:7, d:7; char e:4; }", - 4, 4, "struct { char a:7; int b:7; int c:7; int d:10; }", - 8, 4, "struct { char a:7; int b:7; char c:7; int d:10; }", - 4, 1, "struct __attribute__((packed)) { char a:7; int b:7; char c:7; int d:10; }", - 4, 1, "struct { char a:7; int b:7; char c:7; int d:10; } __attribute__((packed))", - 2, 1, "struct __attribute__((packed)) { char a:4; char b:8; }", - 2, 1, "struct __attribute__((packed)) { char a:4; char :0; char b:4; }", - 1, 1, "struct __attribute__((packed)) { _Bool a:1; _Bool b:1; }", - 2, 1, "struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(1))); }", - 4, 2, "struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(2))); }", - 8, 4, "struct { _Bool a:1; int b __attribute((aligned(2))); }", - 16, 8, "struct { _Bool a:1; int b __attribute((aligned(8))); }", - 6, 2, "struct { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }", - 6, 2, "struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))); }", - 6, 2, "struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }", -} +do --- Bit field packing. + checktypes{ + 1, 1, "struct { _Bool a:1, b:1, c:1; }", + 4, 4, "struct { short a:9; int b:9; char c; }", + 4, 4, "struct { char a; int b:7; }", + 4, 4, "struct { short a; char b; int c:7; }", + 4, 4, "struct { char a:7; int b:7; int c:7; int d:10; }", + 4, 1, "struct { char a:7; char b:7; char c:7; char d:7; }", + 4, 4, "struct { char a:7; int b:7, c:7, d:7; int e:4; }", + 4, 4, "struct { char a:7; int b:7, c:7, d:7; char e:4; }", + 5, 1, "struct { char a:7; char b:7, c:7, d:7; char e:4; }", + 4, 1, "struct __attribute__((packed)) { char a:7; char b:7, c:7, d:7; char e:4; }", + 4, 4, "struct { char a:7; int b:7; int c:7; int d:10; }", + 8, 4, "struct { char a:7; int b:7; char c:7; int d:10; }", + 4, 1, "struct __attribute__((packed)) { char a:7; int b:7; char c:7; int d:10; }", + 4, 1, "struct { char a:7; int b:7; char c:7; int d:10; } __attribute__((packed))", + 2, 1, "struct __attribute__((packed)) { char a:4; char b:8; }", + 2, 1, "struct __attribute__((packed)) { char a:4; char :0; char b:4; }", + 1, 1, "struct __attribute__((packed)) { _Bool a:1; _Bool b:1; }", + 2, 1, "struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(1))); }", + 4, 2, "struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(2))); }", + 8, 4, "struct { _Bool a:1; int b __attribute((aligned(2))); }", + 16, 8, "struct { _Bool a:1; int b __attribute((aligned(8))); }", + 6, 2, "struct { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }", + 6, 2, "struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))); }", + 6, 2, "struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }", + } +end -do +do --- pragma pack pop ffi.cdef[[ struct foo_packorig { char a; int b; short c; }; #pragma pack(1) @@ -236,7 +251,7 @@ do assert(ffi.sizeof("struct foo_packpop2") == 12) end -do +do --- pragma pack aligment ffi.cdef[[ #pragma pack(2) struct foo_packalign8 { diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index index 12b6387f..e3a34e30 100644 --- a/test/LuaJIT-tests/lib/ffi/index +++ b/test/LuaJIT-tests/lib/ffi/index @@ -19,6 +19,7 @@ ffi_new.lua ffi_parse_array.lua ffi_parse_basic.lua ffi_parse_cdef.lua +ffi_parse_struct.lua istype.lua jit_array.lua jit_complex.lua -- 2.43.0