summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/cygmagic
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/cygmagic')
-rwxr-xr-xwinsup/cygwin/cygmagic20
1 files changed, 20 insertions, 0 deletions
diff --git a/winsup/cygwin/cygmagic b/winsup/cygwin/cygmagic
new file mode 100755
index 000000000..17c74b496
--- /dev/null
+++ b/winsup/cygwin/cygmagic
@@ -0,0 +1,20 @@
+#!/bin/sh
+file_magic=$1; shift
+gcc=$1; shift
+file=$1; shift
+trap "rm -f /tmp/$$.magic" 0 1 2 15
+cat <<EOF > $file_magic
+/* autogenerated - do not edit */
+#include "$file"
+EOF
+while [ -n "$1" ]; do
+ define=$1; shift
+ struct=$1; shift
+ sum=`$gcc -E $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | sum | awk '{print "obase=16;\"0x\";", $1}' | bc | tr '[A-Z]' '[a-z]'`
+ echo "#define $define $sum"
+ curr=`sed -n "s/^#[ ]*define CURR_$define[ ][ ]*\([^ ][^ ]*\)/\1/p" $file`
+ [ "$curr" == "$sum" ] || echo "*** WARNING WARNING WARNING WARNING WARNING ***
+*** $file: magic number changed old $curr != new $sum
+*** WARNING WARNING WARNING WARNING WARNING ***" 1>&2
+done >> $file_magic
+exit 0