# HG changeset patch # User Paul Boddie # Date 1664468139 -7200 # Node ID 672a5524af3a11bfd7e859ca40412999a98fb8b4 # Parent 440178360e6c7f839efc40a478e09f6ec90098ae Added structure alignment test. diff -r 440178360e6c -r 672a5524af3a conf/dstest_align.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/dstest_align.cfg Thu Sep 29 18:15:39 2022 +0200 @@ -0,0 +1,10 @@ +-- vim:set ft=lua: + +local L4 = require("L4"); + +local l = L4.default_loader; + +l:startv({ + log = { "align", "g" }, + }, + "rom/dstest_align"); diff -r 440178360e6c -r 672a5524af3a conf/dstest_align.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/dstest_align.list Thu Sep 29 18:15:39 2022 +0200 @@ -0,0 +1,25 @@ +entry dstest_align +roottask moe rom/dstest_align.cfg +module dstest_align.cfg +module e2test.fs +module l4re +module ned +module dstest_align +module lib4re-c.so +module lib4re-c-util.so +module lib4re.so +module lib4re-util.so +module libc_be_l4refile.so +module libc_be_l4re.so +module libc_be_socket_noop.so +module libc_support_misc.so +module libdl.so +module libipc.so +module libl4sys-direct.so +module libl4sys.so +module libl4util.so +module libld-l4.so +module libpthread.so +module libstdc++.so +module libsupc++.so +module libuc_c.so diff -r 440178360e6c -r 672a5524af3a tests/Makefile --- a/tests/Makefile Tue Sep 20 01:04:19 2022 +0200 +++ b/tests/Makefile Thu Sep 29 18:15:39 2022 +0200 @@ -2,6 +2,7 @@ L4DIR ?= $(PKGDIR)/../../.. TARGET = \ + dstest_align \ dstest_block_client dstest_block_client_simple \ dstest_ext2fs_client \ dstest_file_access \ @@ -82,6 +83,8 @@ PLAIN_SRC_CC_dstest_file_mapping = dstest_file_mapping.cc SRC_CC_dstest_file_mapping = $(PLAIN_SRC_CC_dstest_file_mapping) $(CLIENT_INTERFACES_SRC_CC) +SRC_CC_dstest_align = dstest_align.cc + REQUIRES_LIBS = l4re_c-util libexec libfsclient libmem libipc libstdc++ libsystypes libe2access_blockserver PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) diff -r 440178360e6c -r 672a5524af3a tests/dstest_align.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/dstest_align.cc Thu Sep 29 18:15:39 2022 +0200 @@ -0,0 +1,51 @@ +#include +#include + +struct A +{ + uint32_t a; + uint64_t b; + uint64_t c; +} __attribute__ ((packed)); + +struct B +{ + uint32_t a; + uint64_t b; + uint64_t c; +}; + +struct C +{ + uint32_t a; + uint32_t b; + uint64_t c; +}; + +int main(int argc, char *argv[]) +{ + struct A a = {1, 2, 3}; + struct B b = {1, 2, 3}; + struct C c = {1, 2, 3}; + uint32_t m[6] = {1, 2, 3, 4, 5, 6}; + struct A *ma = (struct A *) m; + struct A *ma1 = (struct A *) (m + 1); + + printf("a.a @ %p = %x\n", &a.a, a.a); + printf("a.b @ %p = %llx\n", &a.b, a.b); + printf("a.c @ %p = %llx\n\n", &a.c, a.c); + printf("b.a @ %p = %x\n", &b.a, b.a); + printf("b.b @ %p = %llx\n", &b.b, b.b); + printf("b.c @ %p = %llx\n\n", &b.c, b.c); + printf("c.a @ %p = %x\n", &c.a, c.a); + printf("c.b @ %p = %x\n", &c.b, c.b); + printf("c.c @ %p = %llx\n\n", &c.c, c.c); + printf("ma.a @ %p = %x\n", &ma->a, ma->a); + printf("ma.b @ %p = %llx\n", &ma->b, ma->b); + printf("ma.c @ %p = %llx\n\n", &ma->c, ma->c); + printf("ma1.a @ %p = %x\n", &ma1->a, ma1->a); + printf("ma1.b @ %p = %llx\n", &ma1->b, ma1->b); + printf("ma1.c @ %p = %llx\n\n", &ma1->c, ma1->c); + + return 0; +}