X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=sztest;h=dcb29821cc92ee476a387f2891476039778598b4;hb=e5f1f6aa4366b045a555bb4b50f83f4cd9fd7ae5;hp=239397121cc23eff36a5764ab02a2825303f901a;hpb=c5f010d44d71cb874e5aaf80c51c6cadaf9cfe98;p=utils.git diff --git a/sztest b/sztest index 2393971..dcb2982 100755 --- a/sztest +++ b/sztest @@ -1,16 +1,26 @@ #!/bin/sh -if [ $# -lt 1 ]; then - echo "usage: sztest [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]" >&2 - exit 1 -fi +usage() { + echo "usage: sztest [-hab] [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]" +} +mode=size sheaders= lheaders= while [ "${1:0:1}" = "-" ]; do opt="$1" shift case "$opt" in + "-h") + usage + exit 0 + ;; + "-a") + mode=align + ;; + "-b") + mode=both + ;; "-H") sheaders="$sheaders $1" shift @@ -21,6 +31,10 @@ while [ "${1:0:1}" = "-" ]; do ;; esac done +if [ $# -lt 1 ]; then + usage >&2 + exit 1 +fi type="$1" shift file="$(mktemp /tmp/sztestXXXXXX)" @@ -40,7 +54,19 @@ done cat >>"$file.c" <>"$file.c" + ;; + align) + echo " printf(\"%zi\\n\", __alignof__($type));" >>"$file.c" + ;; + both) + echo " printf(\"%zi %zi\\n\", sizeof($type), __alignof__($type));" >>"$file.c" + ;; +esac +cat >>"$file.c" <