Annotation of 43BSDReno/sys/kern/makesyscalls.sh, revision 1.1

1.1     ! root        1: #! /bin/sh -
        !             2: #      @(#)makesyscalls.sh     7.5 (Berkeley) 6/21/90
        !             3: 
        !             4: set -e
        !             5: 
        !             6: # name of compat option:
        !             7: compat=COMPAT_43
        !             8: 
        !             9: # output files:
        !            10: sysnames="syscalls.c"
        !            11: syshdr="../sys/syscall.h"
        !            12: syssw="init_sysent.c"
        !            13: 
        !            14: # tmp files:
        !            15: sysdcl="sysent.dcl"
        !            16: syscompat="sysent.compat"
        !            17: sysent="sysent.switch"
        !            18: 
        !            19: trap "rm $sysdcl $syscompat $sysent" 0
        !            20: 
        !            21: case $# in
        !            22:     0) echo "Usage: $0 input-file" 1>&2
        !            23:        exit 1
        !            24:        ;;
        !            25: esac
        !            26: 
        !            27: awk < $1 "
        !            28:        BEGIN {
        !            29:                sysdcl = \"$sysdcl\"
        !            30:                syscompat = \"$syscompat\"
        !            31:                sysent = \"$sysent\"
        !            32:                sysnames = \"$sysnames\"
        !            33:                syshdr = \"$syshdr\"
        !            34:                compat = \"$compat\"
        !            35:                infile = \"$1\"
        !            36:                "'
        !            37: 
        !            38:                printf "/*\n * System call switch table.\n *\n" > sysdcl
        !            39:                printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
        !            40: 
        !            41:                printf "\n#ifdef %s\n", compat > syscompat
        !            42:                printf "#define compat(n, name) n, o/**/name\n\n" > syscompat
        !            43: 
        !            44:                printf "/*\n * System call names.\n *\n" > sysnames
        !            45:                printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
        !            46: 
        !            47:                printf "/*\n * System call numbers.\n *\n" > syshdr
        !            48:                printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr
        !            49:        }
        !            50:        NR == 1 {
        !            51:                printf " * created from%s\n */\n\n", $0 > sysdcl
        !            52:                printf "#include \"param.h\"\n" > sysdcl
        !            53:                printf "#include \"systm.h\"\n\n" > sysdcl
        !            54:                printf "int\tnosys();\n\n" > sysdcl
        !            55: 
        !            56:                printf "struct sysent sysent[] = {\n" > sysent
        !            57: 
        !            58:                printf " * created from%s\n */\n\n", $0 > sysnames
        !            59:                printf "char *syscallnames[] = {\n" > sysnames
        !            60: 
        !            61:                printf " * created from%s\n */\n\n", $0 > syshdr
        !            62:                next
        !            63:        }
        !            64:        NF == 0 || $1 ~ /^;/ {
        !            65:                next
        !            66:        }
        !            67:        $1 ~ /^#[       ]*if/ {
        !            68:                print > sysent
        !            69:                print > sysdcl
        !            70:                print > syscompat
        !            71:                print > sysnames
        !            72:                savesyscall = syscall
        !            73:                next
        !            74:        }
        !            75:        $1 ~ /^#[       ]*else/ {
        !            76:                print > sysent
        !            77:                print > sysdcl
        !            78:                print > syscompat
        !            79:                print > sysnames
        !            80:                syscall = savesyscall
        !            81:                next
        !            82:        }
        !            83:        $1 ~ /^#/ {
        !            84:                print > sysent
        !            85:                print > sysdcl
        !            86:                print > syscompat
        !            87:                print > sysnames
        !            88:                next
        !            89:        }
        !            90:        syscall != $1 {
        !            91:                printf "%s: line %d: syscall number out of sync at %d\n", \
        !            92:                   infile, NR, syscall
        !            93:                printf "line is:\n"
        !            94:                print
        !            95:                exit 1
        !            96:        }
        !            97:        {       comment = $4
        !            98:                for (i = 5; i <= NF; i++)
        !            99:                        comment = comment " " $i
        !           100:                if (NF < 5)
        !           101:                        $5 = $4
        !           102:        }
        !           103:        $2 == "STD" {
        !           104:                printf("int\t%s();\n", $4) > sysdcl
        !           105:                printf("\t%d, %s,\t\t\t/* %d = %s */\n", \
        !           106:                    $3, $4, syscall, $5) > sysent
        !           107:                printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
        !           108:                    $5, syscall, $5) > sysnames
        !           109:                printf("#define\tSYS_%s\t%d\n", \
        !           110:                    $5, syscall) > syshdr
        !           111:                syscall++
        !           112:                next
        !           113:        }
        !           114:        $2 == "COMPAT" {
        !           115:                printf("int\to%s();\n", $4) > syscompat
        !           116:                printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \
        !           117:                    $3, $4, syscall, $5) > sysent
        !           118:                printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
        !           119:                    $5, syscall, $5) > sysnames
        !           120:                printf("\t\t\t\t/* %d is old %s */\n", \
        !           121:                    syscall, comment) > syshdr
        !           122:                syscall++
        !           123:                next
        !           124:        }
        !           125:        $2 == "LIBCOMPAT" {
        !           126:                printf("int\to%s();\n", $4) > syscompat
        !           127:                printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \
        !           128:                    $3, $4, syscall, $5) > sysent
        !           129:                printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
        !           130:                    $5, syscall, $5) > sysnames
        !           131:                printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \
        !           132:                    $5, syscall) > syshdr
        !           133:                syscall++
        !           134:                next
        !           135:        }
        !           136:        $2 == "OBSOL" {
        !           137:                printf("\t0, nosys,\t\t\t/* %d = obsolete %s */\n", \
        !           138:                    syscall, comment) > sysent
        !           139:                printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \
        !           140:                    $4, syscall, comment) > sysnames
        !           141:                printf("\t\t\t\t/* %d is obsolete %s */\n", \
        !           142:                    syscall, comment) > syshdr
        !           143:                syscall++
        !           144:                next
        !           145:        }
        !           146:        $2 == "UNIMPL" {
        !           147:                printf("\t0, nosys,\t\t\t/* %d = %s */\n", \
        !           148:                    syscall, comment) > sysent
        !           149:                printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \
        !           150:                    syscall, syscall, comment) > sysnames
        !           151:                syscall++
        !           152:                next
        !           153:        }
        !           154:        {
        !           155:                printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
        !           156:                exit 1
        !           157:        }
        !           158:        END {
        !           159:                printf("\n#else /* %s */\n", compat) > syscompat
        !           160:                printf("#define compat(n, name) 0, nosys\n") > syscompat
        !           161:                printf("#endif /* %s */\n\n", compat) > syscompat
        !           162: 
        !           163:                printf("};\n\n") > sysent
        !           164:                printf("int\tnsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent
        !           165: 
        !           166:                printf("};\n") > sysnames
        !           167:        } '
        !           168: 
        !           169: cat $sysdcl $syscompat $sysent >$syssw
        !           170: 
        !           171: chmod 444 $sysnames $syshdr $syssw

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.