Dolda2000 GitWeb
/
utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8f1c8d4
)
Added alignment checking to sztest.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Thu, 24 Feb 2011 09:41:43 +0000
(10:41 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Thu, 24 Feb 2011 09:41:43 +0000
(10:41 +0100)
sztest
patch
|
blob
|
blame
|
history
diff --git
a/sztest
b/sztest
index
ca7182c
..
dcb2982
100755
(executable)
--- a/
sztest
+++ b/
sztest
@@
-1,9
+1,10
@@
#!/bin/sh
usage() {
#!/bin/sh
usage() {
- echo "usage: sztest [-h] [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]"
+ echo "usage: sztest [-h
ab
] [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]"
}
}
+mode=size
sheaders=
lheaders=
while [ "${1:0:1}" = "-" ]; do
sheaders=
lheaders=
while [ "${1:0:1}" = "-" ]; do
@@
-14,6
+15,12
@@
while [ "${1:0:1}" = "-" ]; do
usage
exit 0
;;
usage
exit 0
;;
+ "-a")
+ mode=align
+ ;;
+ "-b")
+ mode=both
+ ;;
"-H")
sheaders="$sheaders $1"
shift
"-H")
sheaders="$sheaders $1"
shift
@@
-47,7
+54,19
@@
done
cat >>"$file.c" <<EOF
int main(int argc, char **argv)
{
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
return(0);
}
EOF