#!/bin/sh
usage() {
- echo "usage: sztest [-h] [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]"
+ echo "usage: sztest [-hab] [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]"
}
+mode=size
sheaders=
lheaders=
while [ "${1:0:1}" = "-" ]; do
usage
exit 0
;;
+ "-a")
+ mode=align
+ ;;
+ "-b")
+ mode=both
+ ;;
"-H")
sheaders="$sheaders $1"
shift
cat >>"$file.c" <<EOF
int main(int argc, char **argv)
{
- printf("%zi\n", sizeof($type));
+EOF
+case "$mode" in
+ size)
+ echo " printf(\"%zi\\n\", sizeof($type));" >>"$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" <<EOF
return(0);
}
EOF