diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-20 07:28:09 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-20 07:28:09 -0700 |
commit | 0cff857c70c0f770259066d29a720f4404770558 (patch) | |
tree | 24de009609878bf6eebe62d90856687e7876082a /tests/017 | |
parent | c6619399afc67006f7fa63d895d38a6c7008a6af (diff) | |
download | txr-0cff857c70c0f770259066d29a720f4404770558.tar.gz txr-0cff857c70c0f770259066d29a720f4404770558.tar.bz2 txr-0cff857c70c0f770259066d29a720f4404770558.zip |
ffi: pack bugfix and tests.
* ffi.c (ffi_transform_pack): Fix: return the original syntax in
the situation when no cases are recognized, rather than
the cdr of the syntax. When the struct/union syntax has no
members, return the original syntax to indicate no transformation
took place.
* txr.1: Document the feature that pack on a typedef name or struct
name with no members will do the alignment adjustment only, without
the syntactic transformation.
* tests/017/pack-align.tl: New file.
Diffstat (limited to 'tests/017')
-rw-r--r-- | tests/017/pack-align.tl | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/tests/017/pack-align.tl b/tests/017/pack-align.tl new file mode 100644 index 00000000..a1048788 --- /dev/null +++ b/tests/017/pack-align.tl @@ -0,0 +1,112 @@ +(load "../common") + +(mtest + (alignof int) 4 + (alignof (align int)) 16 + (alignof (align 1 int)) 4 + (alignof (align 6 int)) :error + (alignof (align 8 int)) 8) + +(mtest + (alignof (pack int)) 1 + (alignof (pack 1 int)) 1 + (alignof (pack 6 int)) :error + (alignof (pack 8 int)) 8) + +(mtest + (alignof (pack 1 (align 8 int))) 8 + (alignof (align 8 (pack 1 int))) 8) + +(typedef s0 (pack (struct s0 + (a char) + (b short) + (c int) + (d longlong)))) + +(mtest + (alignof s0.a) 1 + (alignof s0.b) 1 + (alignof s0.c) 1 + (alignof s0.d) 1) + +(mtest + (offsetof s0 a) 0 + (offsetof s0 b) 1 + (offsetof s0 c) 3 + (offsetof s0 d) 7 + (sizeof s0) 15) + +(typedef s1 (pack 2 (struct s1 + (a char) + (b short) + (c int) + (d longlong)))) + +(mtest + (alignof s1.a) 2 + (alignof s1.b) 2 + (alignof s1.c) 2 + (alignof s1.d) 2) + +(mtest + (offsetof s1 a) 0 + (offsetof s1 b) 2 + (offsetof s1 c) 4 + (offsetof s1 d) 8 + (sizeof s1) 16) + +(typedef s2 (pack 32 (struct s2 + (a char) + (b short) + (c int) + (d longlong)))) + +(mtest + (alignof s2.a) 32 + (alignof s2.b) 32 + (alignof s2.c) 32 + (alignof s2.d) 32) + +(mtest + (offsetof s2 a) 0 + (offsetof s2 b) 32 + (offsetof s2 c) 64 + (offsetof s2 d) 96 + (sizeof s2) 128) + +(typedef s3 (pack 1 (struct s3 + (a char) + (b (align 2 char)) + (c (align int)) + (d longlong)))) + +(mtest + (alignof s3.a) 1 + (alignof s3.b) 2 + (alignof s3.c) 16 + (alignof s3.d) 1) + +(mtest + (offsetof s3 a) 0 + (offsetof s3 b) 2 + (offsetof s3 c) 16 + (offsetof s3 d) 20 + (sizeof s3) 32) + +(typedef s4 (align 256 s3)) + +(mtest + (sizeof s4) 32 + (alignof s4) 256) + +(typedef s5 (pack s3)) + +(mtest + (sizeof s5) 32 + (alignof s5) 1) + +(typedef s6 (pack (struct s3))) + +(mtest + (sizeof s6) 32 + (alignof s6) 1) |