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  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
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'} ${NMFLAGS} "$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                 hex = ""
   36                 if (w != "0")
   37                         hex = "0x"
   38                 sub("w3$", "", $3)
   39                 # This still has minor problems representing INT_MIN, etc. 
   40                 # E.g.,
   41                 # with 32-bit 2''s complement ints, this prints -0x80000000,
   42                 # which has the wrong type (unsigned int).
   43                 printf("#define\t%s\t%s%s%s\n", $3, sign, hex, w)
   44         } '
   45 }
   46 
   47 
   48 #
   49 #MAIN PROGGRAM
   50 #
   51 use_outfile="no"
   52 while getopts "o:" option
   53 do
   54         case "$option" in
   55         o)      outfile="$OPTARG"
   56                 use_outfile="yes";;
   57         *)      usage;;
   58         esac
   59 done
   60 shift $((OPTIND - 1))
   61 case $# in
   62 1)      ;;
   63 *)      usage;;
   64 esac
   65 
   66 if [ "$use_outfile" = "yes" ]
   67 then
   68         work "$1"  3>"$outfile" >&3 3>&-
   69 else
   70         work "$1"
   71 fi
   72 

Cache object: 9edb78fdeb0c63cfbc1a4908a32f8299


[ 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.