Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/scripts/cygmagic')
-rwxr-xr-xwinsup/cygwin/scripts/cygmagic43
1 files changed, 43 insertions, 0 deletions
diff --git a/winsup/cygwin/scripts/cygmagic b/winsup/cygwin/scripts/cygmagic
new file mode 100755
index 000000000..eee4a3b73
--- /dev/null
+++ b/winsup/cygwin/scripts/cygmagic
@@ -0,0 +1,43 @@
+#!/bin/bash
+# cygmagic - Generate "magic numbers" from a structure.
+#
+# This file is part of Cygwin.
+#
+# This software is a copyrighted work licensed under the terms of the
+# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+# details.
+
+set -e
+shopt -s -o pipefail
+shopt -s inherit_errexit
+
+file_magic=$1; shift
+gcc=$1; shift
+file=$1; shift
+
+tmpfile=/tmp/$$.magic
+trap "rm -f /tmp/$$.magic" 0 1 2 15
+
+cat <<EOF > $tmpfile
+/* autogenerated - do not edit */
+#include "$file"
+EOF
+
+sumit() {
+ cksum $*
+}
+
+while [ -n "$1" ]; do
+ define=$1; shift
+ struct=$1; shift
+ sum=`$gcc -D__CYGMAGIC__ -E -P $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'`
+ 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 for $define changed old $curr != new $sum
+*** WARNING WARNING WARNING WARNING WARNING ***" 1>&2
+done >> $tmpfile
+
+mv $tmpfile $file_magic
+
+exit 0