Mercurial > projects > dstress
changeset 512:9f7e0ec4c6d7
alignment of struct members
Robert Atkinson <Robert.Atkinson@gmail.com>
2005-05-04
news:d5afkg$1svk$1@digitaldaemon.com
author | thomask |
---|---|
date | Tue, 10 May 2005 23:50:13 +0000 |
parents | 50a9bd194e33 |
children | c785d528fa37 |
files | run/align_11.d run/align_12.d run/align_13.d run/align_14.d run/align_15.d run/align_16.d run/align_17.d |
diffstat | 7 files changed, 210 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/align_11.d Tue May 10 23:50:13 2005 +0000 @@ -0,0 +1,30 @@ +// $HeadURL: http://dstress.kuehne.cn/run/align_11.d $ +// $Date: 2005-05-06 14:14:51 +0200 (Fr, 06 Mai 2005) $ +// $Author: thomask $ + +// @author@ Robert Atkinson <Robert.Atkinson@gmail.com> +// @date@ 2005-05-04 +// @uri@ news:d5afkg$1svk$1@digitaldaemon.com + +module dstress.run.align_11; + +version(X86){ + version(linux) version=testA; // c compiler: gcc +} + +align(1) struct S{ + byte a; + byte b; +} + +int main(){ + S s; + version(testA){ + assert(&s.a-&s.b==-1); + }else{ + pragma(msg, "no C alignment data present"); + static assert(0); + } + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/align_12.d Tue May 10 23:50:13 2005 +0000 @@ -0,0 +1,30 @@ +// $HeadURL: http://dstress.kuehne.cn/run/align_12.d $ +// $Date: 2005-05-06 14:14:51 +0200 (Fr, 06 Mai 2005) $ +// $Author: thomask $ + +// @author@ Robert Atkinson <Robert.Atkinson@gmail.com> +// @date@ 2005-05-04 +// @uri@ news:d5afkg$1svk$1@digitaldaemon.com + +module dstress.run.align_12; + +version(X86){ + version(linux) version=testA; // c compiler: gcc +} + +align(2) struct S{ + byte a; + byte b; +} + +int main(){ + S s; + version(testA){ + assert(&s.a-&s.b==-2); + }else{ + pragma(msg, "no C alignment data present"); + static assert(0); + } + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/align_13.d Tue May 10 23:50:13 2005 +0000 @@ -0,0 +1,30 @@ +// $HeadURL: http://dstress.kuehne.cn/run/align_13.d $ +// $Date: 2005-05-06 14:14:51 +0200 (Fr, 06 Mai 2005) $ +// $Author: thomask $ + +// @author@ Robert Atkinson <Robert.Atkinson@gmail.com> +// @date@ 2005-05-04 +// @uri@ news:d5afkg$1svk$1@digitaldaemon.com + +module dstress.run.align_13; + +version(X86){ + version(linux) version=testA; // c compiler: gcc +} + +align(4) struct S{ + byte a; + byte b; +} + +int main(){ + S s; + version(testA){ + assert(&s.a-&s.b==-4); + }else{ + pragma(msg, "no C alignment data present"); + static assert(0); + } + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/align_14.d Tue May 10 23:50:13 2005 +0000 @@ -0,0 +1,30 @@ +// $HeadURL: http://dstress.kuehne.cn/run/align_14.d $ +// $Date: 2005-05-06 14:14:51 +0200 (Fr, 06 Mai 2005) $ +// $Author: thomask $ + +// @author@ Robert Atkinson <Robert.Atkinson@gmail.com> +// @date@ 2005-05-04 +// @uri@ news:d5afkg$1svk$1@digitaldaemon.com + +module dstress.run.align_14; + +version(X86){ + version(linux) version=testA; // c compiler: gcc +} + +align(16) struct S{ + byte a; + byte b; +} + +int main(){ + S s; + version(testA){ + assert(&s.a-&s.b==-16); + }else{ + pragma(msg, "no C alignment data present"); + static assert(0); + } + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/align_15.d Tue May 10 23:50:13 2005 +0000 @@ -0,0 +1,30 @@ +// $HeadURL: http://dstress.kuehne.cn/run/align_15.d $ +// $Date: 2005-05-06 14:14:51 +0200 (Fr, 06 Mai 2005) $ +// $Author: thomask $ + +// @author@ Robert Atkinson <Robert.Atkinson@gmail.com> +// @date@ 2005-05-04 +// @uri@ news:d5afkg$1svk$1@digitaldaemon.com + +module dstress.run.align_15; + +version(X86){ + version(linux) version=testA; // c compiler: gcc +} + +align(32) struct S{ + byte a; + byte b; +} + +int main(){ + S s; + version(testA){ + assert(&s.a-&s.b==-32); + }else{ + pragma(msg, "no C alignment data present"); + static assert(0); + } + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/align_16.d Tue May 10 23:50:13 2005 +0000 @@ -0,0 +1,30 @@ +// $HeadURL: http://dstress.kuehne.cn/run/align_16.d $ +// $Date: 2005-05-06 14:14:51 +0200 (Fr, 06 Mai 2005) $ +// $Author: thomask $ + +// @author@ Robert Atkinson <Robert.Atkinson@gmail.com> +// @date@ 2005-05-04 +// @uri@ news:d5afkg$1svk$1@digitaldaemon.com + +module dstress.run.align_16; + +version(X86){ + version(linux) version=testA; // c compiler: gcc +} + +align(64) struct S{ + byte a; + byte b; +} + +int main(){ + S s; + version(testA){ + assert(&s.a-&s.b==-64); + }else{ + pragma(msg, "no C alignment data present"); + static assert(0); + } + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/align_17.d Tue May 10 23:50:13 2005 +0000 @@ -0,0 +1,30 @@ +// $HeadURL: http://dstress.kuehne.cn/run/align_17.d $ +// $Date: 2005-05-06 14:14:51 +0200 (Fr, 06 Mai 2005) $ +// $Author: thomask $ + +// @author@ Robert Atkinson <Robert.Atkinson@gmail.com> +// @date@ 2005-05-04 +// @uri@ news:d5afkg$1svk$1@digitaldaemon.com + +module dstress.run.align_17; + +version(X86){ + version(linux) version=testA; // c compiler: gcc +} + +align(128) struct S{ + byte a; + byte b; +} + +int main(){ + S s; + version(testA){ + assert(&s.a-&s.b==-128); + }else{ + pragma(msg, "no C alignment data present"); + static assert(0); + } + return 0; +} +