]> sourceware.org Git - newlib-cygwin.git/blame - winsup/cygwin/cygmagic
Throughout, update copyrights to reflect dates which correspond to main-branch
[newlib-cygwin.git] / winsup / cygwin / cygmagic
CommitLineData
77f4a250 1#!/bin/sh
33ad2bf9
CF
2# cygmagic - Generate "magic numbers" from a structure.
3#
bc837d22 4# Copyright 2001, 2002, 2005 Red Hat, Inc.
33ad2bf9
CF
5#
6# This file is part of Cygwin.
7#
8# This software is a copyrighted work licensed under the terms of the
9# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
10# details.
11
77f4a250
CF
12file_magic=$1; shift
13gcc=$1; shift
14file=$1; shift
15trap "rm -f /tmp/$$.magic" 0 1 2 15
16cat <<EOF > $file_magic
17/* autogenerated - do not edit */
18#include "$file"
19EOF
6d8bd861
CF
20sumit() {
21 cksum $*
22}
f3647dd7 23
77f4a250
CF
24while [ -n "$1" ]; do
25 define=$1; shift
26 struct=$1; shift
44055eca 27 sum=`$gcc -E $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'`
77f4a250
CF
28 echo "#define $define $sum"
29 curr=`sed -n "s/^#[ ]*define CURR_$define[ ][ ]*\([^ ][^ ]*\)/\1/p" $file`
acf05df7 30 [ "$curr" != "$sum" ] && echo "*** WARNING WARNING WARNING WARNING WARNING ***
aaf219f0 31*** $file: magic number for $define changed old $curr != new $sum
77f4a250
CF
32*** WARNING WARNING WARNING WARNING WARNING ***" 1>&2
33done >> $file_magic
34exit 0
This page took 0.305586 seconds and 5 git commands to generate.