The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System, Second Edition

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kern/genassym.sh

Version: -  FREEBSD  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  3  -  10 

    1 #!/bin/sh
    2 # $FreeBSD$
    3 
    4 usage()
    5 {
    6         echo "usage: genassym [-o outfile] objfile"
    7         exit 1
    8 }
    9 
   10 
   11 work()
   12 {
   13         ${NM:='nm'} "$1" | ${AWK:='awk'} '
   14         / C .*sign$/ {
   15                 sign = substr($1, length($1) - 3, 4)
   16                 sub("^0*", "", sign)
   17                 if (sign != "")
   18                         sign = "-"
   19         }
   20         / C .*w0$/ {
   21                 w0 = substr($1, length($1) - 3, 4)
   22         }
   23         / C .*w1$/ {
   24                 w1 = substr($1, length($1) - 3, 4)
   25         }
   26         / C .*w2$/ {
   27                 w2 = substr($1, length($1) - 3, 4)
   28         }
   29         / C .*w3$/ {
   30                 w3 = substr($1, length($1) - 3, 4)
   31                 w = w3 w2 w1 w0
   32                 sub("^0*", "", w)
   33                 if (w == "")
   34                         w = "0"
   35                 sub("w3$", "", $3)
   36                 # This still has minor problems representing INT_MIN, etc. 
   37                 # E.g.,
   38                 # with 32-bit 2''s complement ints, this prints -0x80000000,
   39                 # which has the wrong type (unsigned int).
   40                 printf("#define\t%s\t%s0x%s\n", $3, sign, w)
   41         } '
   42 }
   43 
   44 
   45 #
   46 #MAIN PROGGRAM
   47 #
   48 use_outfile="no"
   49 while getopts "o:" option
   50 do
   51         case "$option" in
   52         o)      outfile="$OPTARG"
   53                 use_outfile="yes";;
   54         *)      usage;;
   55         esac
   56 done
   57 shift $(($OPTIND - 1))
   58 case $# in
   59 1)      ;;
   60 *)      usage;;
   61 esac
   62 
   63 if [ "$use_outfile" = "yes" ]
   64 then
   65         work $1  3>"$outfile" >&3 3>&-
   66 else
   67         work $1
   68 fi
   69 

Cache object: 7d370ebfa12199fd56efb17a44f46a78


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.