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 # Grrr, this should use stdin and stdout, but is encrufted for compatibility.
    5 
    6 usage() {
    7         echo "usage: genassym [-o outfile] objfile"
    8         exit 1
    9 }
   10 
   11 outfile=/dev/stdout
   12 while getopts "o:" option
   13 do
   14         case "$option" in
   15         o)      outfile="$OPTARG";;
   16         *)      usage;;
   17         esac
   18 done
   19 shift $(($OPTIND - 1))
   20 case $# in
   21 1)      ;;
   22 *)      usage;;
   23 esac
   24 
   25 nm "$1" | awk '
   26 / C .*sign$/ {
   27         sign = substr($1, length($1) - 3, 4)
   28         sub("^0*", "", sign)
   29         if (sign != "")
   30                 sign = "-"
   31 }
   32 / C .*w0$/ {
   33         w0 = substr($1, length($1) - 3, 4)
   34 }
   35 / C .*w1$/ {
   36         w1 = substr($1, length($1) - 3, 4)
   37 }
   38 / C .*w2$/ {
   39         w2 = substr($1, length($1) - 3, 4)
   40 }
   41 / C .*w3$/ {
   42         w3 = substr($1, length($1) - 3, 4)
   43         w = w3 w2 w1 w0
   44         sub("^0*", "", w)
   45         if (w == "")
   46                 w = "0"
   47         sub("w3$", "", $3)
   48         # This still has minor problems representing INT_MIN, etc.  E.g.,
   49         # with 32-bit 2''s complement ints, this prints -0x80000000, which 
   50         # has the wrong type (unsigned int).
   51         printf("#define\t%s\t%s0x%s\n", $3, sign, w)
   52 }
   53 ' 3>"$outfile" >&3 3>&-

Cache object: 9188921b4e812f69098bbe1aaf0f5074


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