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/makesyscalls.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 #       $NetBSD: makesyscalls.sh,v 1.73 2008/10/13 18:16:33 pooka Exp $
    3 #
    4 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
    5 # All rights reserved.
    6 #
    7 # Redistribution and use in source and binary forms, with or without
    8 # modification, are permitted provided that the following conditions
    9 # are met:
   10 # 1. Redistributions of source code must retain the above copyright
   11 #    notice, this list of conditions and the following disclaimer.
   12 # 2. Redistributions in binary form must reproduce the above copyright
   13 #    notice, this list of conditions and the following disclaimer in the
   14 #    documentation and/or other materials provided with the distribution.
   15 # 3. All advertising materials mentioning features or use of this software
   16 #    must display the following acknowledgement:
   17 #      This product includes software developed for the NetBSD Project
   18 #      by Christopher G. Demetriou.
   19 # 4. The name of the author may not be used to endorse or promote products
   20 #    derived from this software without specific prior written permission
   21 #
   22 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   23 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   24 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   25 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   27 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   31 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   32 
   33 #       @(#)makesyscalls.sh     8.1 (Berkeley) 6/10/93
   34 
   35 set -e
   36 
   37 case $# in
   38     2)  ;;
   39     *)  echo "Usage: $0 config-file input-file" 1>&2
   40         exit 1
   41         ;;
   42 esac
   43 
   44 # the config file sets the following variables:
   45 #       sysalign        check for alignment of off_t
   46 #       sysnames        the syscall names file
   47 #       sysnumhdr       the syscall numbers file
   48 #       syssw           the syscall switch file
   49 #       sysarghdr       the syscall argument struct definitions
   50 #       compatopts      those syscall types that are for 'compat' syscalls
   51 #       switchname      the name for the 'struct sysent' we define
   52 #       namesname       the name for the 'const char *[]' we define
   53 #       constprefix     the prefix for the system call constants
   54 #       registertype    the type for register_t
   55 #       nsysent         the size of the sysent table
   56 #       sys_nosys       [optional] name of function called for unsupported
   57 #                       syscalls, if not sys_nosys()
   58 #       maxsysargs      [optiona] the maximum number or arguments
   59 #
   60 # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'SYSLIBCOMPAT'.
   61 
   62 # source the config file.
   63 sys_nosys="sys_nosys"   # default is sys_nosys(), if not specified otherwise
   64 maxsysargs=8            # default limit is 8 (32bit) arguments
   65 rumpcalls="/dev/null"
   66 rumpcallshdr="/dev/null"
   67 . ./$1
   68 
   69 # tmp files:
   70 sysdcl="sysent.dcl"
   71 sysprotos="sys.protos"
   72 syscompat_pref="sysent."
   73 sysent="sysent.switch"
   74 sysnamesbottom="sysnames.bottom"
   75 
   76 trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom" 0
   77 
   78 # Awk program (must support nawk extensions)
   79 # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
   80 awk=${AWK:-awk}
   81 
   82 # Does this awk have a "toupper" function?
   83 have_toupper=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null`
   84 
   85 # If this awk does not define "toupper" then define our own.
   86 if [ "$have_toupper" = TRUE ] ; then
   87         # Used awk (GNU awk or nawk) provides it
   88         toupper=
   89 else
   90         # Provide our own toupper()
   91         toupper='
   92 function toupper(str) {
   93         _toupper_cmd = "echo "str" |tr a-z A-Z"
   94         _toupper_cmd | getline _toupper_str;
   95         close(_toupper_cmd);
   96         return _toupper_str;
   97 }'
   98 fi
   99 
  100 # before handing it off to awk, make a few adjustments:
  101 #       (1) insert spaces around {, }, (, ), *, and commas.
  102 #       (2) get rid of any and all dollar signs (so that rcs id use safe)
  103 #
  104 # The awk script will deal with blank lines and lines that
  105 # start with the comment character (';').
  106 
  107 sed -e '
  108 s/\$//g
  109 :join
  110         /\\$/{a\
  111 
  112         N
  113         s/\\\n//
  114         b join
  115         }
  116 2,${
  117         /^#/!s/\([{}()*,]\)/ \1 /g
  118 }
  119 ' < $2 | $awk "
  120 $toupper
  121 BEGIN {
  122         # Create a NetBSD tag that does not get expanded when checking
  123         # this script out of CVS.  (This part of the awk script is in a
  124         # shell double-quoted string, so the backslashes are eaten by
  125         # the shell.)
  126         tag = \"\$\" \"NetBSD\" \"\$\"
  127 
  128         # to allow nested #if/#else/#endif sets
  129         savedepth = 0
  130         # to track already processed syscalls
  131 
  132         sysnames = \"$sysnames\"
  133         sysprotos = \"$sysprotos\"
  134         sysnumhdr = \"$sysnumhdr\"
  135         sysarghdr = \"$sysarghdr\"
  136         rumpcalls = \"$rumpcalls\"
  137         rumpcallshdr = \"$rumpcallshdr\"
  138         switchname = \"$switchname\"
  139         namesname = \"$namesname\"
  140         constprefix = \"$constprefix\"
  141         registertype = \"$registertype\"
  142         sysalign=\"$sysalign\"
  143         if (!registertype) {
  144             registertype = \"register_t\"
  145         }
  146         nsysent = \"$nsysent\"
  147 
  148         sysdcl = \"$sysdcl\"
  149         syscompat_pref = \"$syscompat_pref\"
  150         sysent = \"$sysent\"
  151         sysnamesbottom = \"$sysnamesbottom\"
  152         sys_nosys = \"$sys_nosys\"
  153         maxsysargs = \"$maxsysargs\"
  154         infile = \"$2\"
  155 
  156         compatopts = \"$compatopts\"
  157         "'
  158 
  159         printf "/* %s */\n\n", tag > sysdcl
  160         printf "/*\n * System call switch table.\n *\n" > sysdcl
  161         printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
  162 
  163         ncompat = split(compatopts,compat)
  164         for (i = 1; i <= ncompat; i++) {
  165                 compat_upper[i] = toupper(compat[i])
  166 
  167                 printf "\n#ifdef %s\n", compat_upper[i] > sysent
  168                 printf "#define %s(func) __CONCAT(%s_,func)\n", compat[i], \
  169                     compat[i] > sysent
  170                 printf "#else\n" > sysent
  171                 printf "#define %s(func) %s\n", compat[i], sys_nosys > sysent
  172                 printf "#endif\n" > sysent
  173         }
  174 
  175         printf "\n#define\ts(type)\tsizeof(type)\n" > sysent
  176         printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > sysent
  177         printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > sysent
  178         printf "struct sysent %s[] = {\n",switchname > sysent
  179 
  180         printf "/* %s */\n\n", tag > sysnames
  181         printf "/*\n * System call names.\n *\n" > sysnames
  182         printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
  183 
  184         printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos
  185 
  186         printf "/* %s */\n\n", tag > sysnumhdr
  187         printf "/*\n * System call numbers.\n *\n" > sysnumhdr
  188         printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr
  189 
  190         printf "/* %s */\n\n", tag > sysarghdr
  191         printf "/*\n * System call argument lists.\n *\n" > sysarghdr
  192         printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr
  193 
  194         printf "/* %s */\n\n", tag > rumpcalls
  195         printf "/*\n * System call marshalling for rump.\n *\n" > rumpcalls
  196         printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls
  197 
  198         printf "/* %s */\n\n", tag > rumpcallshdr
  199         printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
  200         printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
  201 }
  202 NR == 1 {
  203         sub(/ $/, "")
  204         printf " * created from%s\n */\n\n", $0 > sysdcl
  205         printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysdcl
  206 
  207         printf " * created from%s\n */\n\n", $0 > sysnames
  208         printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysnames
  209 
  210         printf " * created from%s\n */\n\n", $0 > rumpcalls
  211         printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > rumpcalls
  212         printf "#include <sys/types.h>\n" > rumpcalls
  213         printf "#include <sys/param.h>\n" > rumpcalls
  214         printf "#include <sys/proc.h>\n" > rumpcalls
  215         printf "#include <sys/syscallargs.h>\n" > rumpcalls
  216         printf "#include \"rump_syscalls.h\"\n" > rumpcalls
  217         printf "#include \"rump_private.h\"\n\n" > rumpcalls
  218         printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls
  219         printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls
  220         printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls
  221         printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls
  222         printf "#endif\n\n" > rumpcalls
  223         printf "int rump_enosys(void);\n" > rumpcalls
  224         printf "int\nrump_enosys()\n{\n\n\treturn ENOSYS;\n}\n" > rumpcalls
  225 
  226         # System call names are included by userland (kdump(1)), so
  227         # hide the include files from it.
  228         printf "#if defined(_KERNEL_OPT)\n" > sysnames
  229 
  230         printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom
  231         printf "const char *const %s[] = {\n",namesname > sysnamesbottom
  232 
  233         printf " * created from%s\n */\n\n", $0 > sysnumhdr
  234 
  235         printf " * created from%s\n */\n\n", $0 > sysarghdr
  236 
  237         printf " * created from%s\n */\n\n", $0 > rumpcallshdr
  238 
  239         printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr
  240         printf "#define _" constprefix "SYSCALL_H_\n\n" > sysnumhdr
  241         printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr
  242         printf "#define _" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr
  243         # Write max number of system call arguments to both headers
  244         printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
  245                 > sysnumhdr
  246         printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
  247                 > sysarghdr
  248         printf "#undef\tsyscallarg\n" > sysarghdr
  249         printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr
  250         printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr
  251         printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr
  252         printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr
  253         printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \
  254                 > sysarghdr
  255         printf "\t\t\tint8_t pad[  /* CONSTCOND */\t\t\t\\\n" > sysarghdr
  256         printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \
  257                 registertype > sysarghdr
  258         printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr
  259         printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \
  260                 registertype > sysarghdr
  261         printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr
  262         printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr
  263         printf "\t}\n" > sysarghdr
  264         printf("\n#undef check_syscall_args\n") >sysarghdr
  265         printf("#define check_syscall_args(call) \\\n" \
  266                 "\ttypedef char call##_check_args" \
  267                     "[sizeof (struct call##_args) \\\n" \
  268                 "\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \
  269                 constprefix, registertype) >sysarghdr
  270         next
  271 }
  272 NF == 0 || $1 ~ /^;/ {
  273         next
  274 }
  275 $0 ~ /^%%$/ {
  276         intable = 1
  277         next
  278 }
  279 $1 ~ /^#[       ]*include/ {
  280         print > sysdcl
  281         print > sysnames
  282         next
  283 }
  284 $1 ~ /^#/ && !intable {
  285         print > sysdcl
  286         print > sysnames
  287         next
  288 }
  289 $1 ~ /^#/ && intable {
  290         if ($1 ~ /^#[   ]*if/) {
  291                 savedepth++
  292                 savesyscall[savedepth] = syscall
  293         }
  294         if ($1 ~ /^#[   ]*else/) {
  295                 if (savedepth <= 0) {
  296                         printf("%s: line %d: unbalanced #else\n", \
  297                             infile, NR)
  298                         exit 1
  299                 }
  300                 syscall = savesyscall[savedepth]
  301         }
  302         if ($1 ~ /^#[       ]*endif/) {
  303                 if (savedepth <= 0) {
  304                         printf("%s: line %d: unbalanced #endif\n", \
  305                             infile, NR)
  306                         exit 1
  307                 }
  308                 savedepth--
  309         }
  310         print > sysent
  311         print > sysarghdr
  312         print > sysnumhdr
  313         print > sysprotos
  314         print > sysnamesbottom
  315         next
  316 }
  317 syscall != $1 {
  318         printf "%s: line %d: syscall number out of sync at %d\n", \
  319            infile, NR, syscall
  320         printf "line is:\n"
  321         print
  322         exit 1
  323 }
  324 function parserr(was, wanted) {
  325         printf "%s: line %d: unexpected %s (expected %s)\n", \
  326             infile, NR, was, wanted
  327         printf "line is:\n"
  328         print
  329         exit 1
  330 }
  331 function parseline() {
  332         f=3                     # toss number and type
  333         if ($2 == "INDIR")
  334                 sycall_flags="SYCALL_INDIRECT"
  335         else
  336                 sycall_flags="0"
  337         if ($NF != "}") {
  338                 funcalias=$NF
  339                 end=NF-1
  340         } else {
  341                 funcalias=""
  342                 end=NF
  343         }
  344         if ($f == "INDIR") {            # allow for "NOARG INDIR"
  345                 sycall_flags = "SYCALL_INDIRECT | " sycall_flags
  346                 f++
  347         }
  348         if ($f == "RUMP") {
  349                 rumpable = 1
  350                 f++
  351         } else {
  352                 rumpable = 0
  353         }
  354         if ($f ~ /^[a-z0-9_]*$/) {      # allow syscall alias
  355                 funcalias=$f
  356                 f++
  357         }
  358         if ($f != "{")
  359                 parserr($f, "{")
  360         f++
  361         if ($end != "}")
  362                 parserr($end, "}")
  363         end--
  364         if ($end != ";")
  365                 parserr($end, ";")
  366         end--
  367         if ($end != ")")
  368                 parserr($end, ")")
  369         end--
  370 
  371         returntype = oldf = "";
  372         do {
  373                 if (returntype != "" && oldf != "*")
  374                         returntype = returntype" ";
  375                 returntype = returntype$f;
  376                 oldf = $f;
  377                 f++
  378         } while (f < (end - 1) && $(f+1) != "(");
  379         if (f == (end - 1)) {
  380                 parserr($f, "function argument definition (maybe \"(\"?)");
  381         }
  382 
  383         funcname=$f
  384         if (funcalias == "") {
  385                 funcalias=funcname
  386                 sub(/^([^_]+_)*sys_/, "", funcalias)
  387         }
  388         f++
  389 
  390         if ($f != "(")
  391                 parserr($f, ")")
  392         f++
  393 
  394         argc=0;
  395         argalign=0;
  396         if (f == end) {
  397                 if ($f != "void")
  398                         parserr($f, "argument definition")
  399                 isvarargs = 0;
  400                 varargc = 0;
  401                 return
  402         }
  403 
  404         # some system calls (open() and fcntl()) can accept a variable
  405         # number of arguments.  If syscalls accept a variable number of
  406         # arguments, they must still have arguments specified for
  407         # the remaining argument "positions," because of the way the
  408         # kernel system call argument handling works.
  409         #
  410         # Indirect system calls, e.g. syscall(), are exceptions to this
  411         # rule, since they are handled entirely by machine-dependent code
  412         # and do not need argument structures built.
  413 
  414         isvarargs = 0;
  415         while (f <= end) {
  416                 if ($f == "...") {
  417                         f++;
  418                         isvarargs = 1;
  419                         varargc = argc;
  420                         continue;
  421                 }
  422                 argc++
  423                 argtype[argc]=""
  424                 oldf=""
  425                 while (f < end && $(f+1) != ",") {
  426                         if (argtype[argc] != "" && oldf != "*")
  427                                 argtype[argc] = argtype[argc]" ";
  428                         argtype[argc] = argtype[argc]$f;
  429                         oldf = $f;
  430                         f++
  431                 }
  432                 if (argtype[argc] == "")
  433                         parserr($f, "argument definition")
  434                 if (argtype[argc] == "off_t") {
  435                         if ((argalign % 2) != 0 && sysalign &&
  436                             funcname != "sys_posix_fadvise") # XXX for now
  437                                 parserr($f, "a padding argument")
  438                 } else {
  439                         argalign++;
  440                 }
  441                 argname[argc]=$f;
  442                 f += 2;                 # skip name, and any comma
  443         }
  444         # must see another argument after varargs notice.
  445         if (isvarargs) {
  446                 if (argc == varargc)
  447                         parserr($f, "argument definition")
  448         } else
  449                 varargc = argc;
  450 }
  451 
  452 function printproto(wrap) {
  453         printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias,
  454             returntype) > sysnumhdr
  455         for (i = 1; i <= varargc; i++)
  456                 printf(" \"%s\"", argtype[i]) > sysnumhdr
  457         if (isvarargs)
  458                 printf(" \"...\"") > sysnumhdr
  459         printf(" */\n") > sysnumhdr
  460         printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
  461             syscall) > sysnumhdr
  462 
  463         # rumpalooza
  464         if (!rumpable)
  465                 return
  466 
  467         if (wrap == "")
  468                 wrap = "sys"
  469         printf("%s rump_%s_%s(", returntype, wrap, funcalias) > rumpcallshdr
  470         for (i = 1; i <= argc; i++)
  471                 printf("%s, ", argtype[i]) > rumpcallshdr
  472         printf("int *);\n") > rumpcallshdr
  473 }
  474 
  475 function putent(type, compatwrap) {
  476         # output syscall declaration for switch table.
  477         if (compatwrap == "")
  478                 compatwrap_ = ""
  479         else
  480                 compatwrap_ = compatwrap "_"
  481         if (argc == 0)
  482                 arg_type = "void";
  483         else {
  484                 arg_type = "struct " compatwrap_ funcname "_args";
  485         }
  486         proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \
  487             arg_type " *, register_t *);\n"
  488         if (sysmap[proto] != 1) {
  489                 sysmap[proto] = 1;
  490                 print proto > sysprotos;
  491         }
  492 
  493         # output syscall switch entry
  494         printf("\t{ ") > sysent
  495         if (argc == 0) {
  496                 printf("0, 0, ") > sysent
  497         } else {
  498                 printf("ns(struct %s%s_args), ", compatwrap_, funcname) > sysent
  499         }
  500         if (compatwrap == "")
  501                 wfn = "(sy_call_t *)" funcname;
  502         else
  503                 wfn = "(sy_call_t *)" compatwrap "(" funcname ")";
  504         printf("%s,\n\t    %s },", sycall_flags, wfn) > sysent
  505         for (i = 0; i < (33 - length(wfn)) / 8; i++)
  506                 printf("\t") > sysent
  507         printf("/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent
  508 
  509         # output syscall name for names table
  510         printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \
  511             > sysnamesbottom
  512 
  513         # output syscall number of header, if appropriate
  514         if (type == "STD" || type == "NOARGS" || type == "INDIR") {
  515                 # output a prototype, to be used to generate lint stubs in
  516                 # libc.
  517                 printproto("")
  518         } else if (type == "COMPAT") {
  519                 # Just define the syscall number with a comment.  These
  520                 # may be used by compatibility stubs in libc.
  521                 printproto(compatwrap_)
  522         }
  523 
  524         # output syscall argument structure, if it has arguments
  525         if (argc != 0) {
  526                 printf("\nstruct %s%s_args", compatwrap_, funcname) > sysarghdr
  527                 if (type != "NOARGS") {
  528                         print " {" >sysarghdr;
  529                         for (i = 1; i <= argc; i++)
  530                                 printf("\tsyscallarg(%s) %s;\n", argtype[i],
  531                                     argname[i]) > sysarghdr
  532                         printf "}" >sysarghdr;
  533                 }
  534                 printf(";\n") > sysarghdr
  535                 if (type != "NOARGS" && type != "INDIR") {
  536                         printf("check_syscall_args(%s%s)\n", compatwrap_,
  537                             funcname) >sysarghdr
  538                 }
  539         }
  540 
  541         # output rump marshalling code if necessary
  542         if (!rumpable)
  543                 return
  544 
  545         printf("\n%s\nrump_%s(", returntype, funcname) > rumpcalls
  546         for (i = 1; i <= argc; i++) {
  547                 printf("%s %s, ", argtype[i], argname[i]) > rumpcalls
  548         }
  549         printf("int *error)\n") > rumpcalls
  550         printf("{\n\tregister_t retval = 0;\n") > rumpcalls
  551         argarg = "NULL"
  552         if (argc) {
  553                 argarg = "&arg"
  554                 printf("\tstruct %s%s_args arg;\n\n", funcname, compatwrap_) \
  555                     > rumpcalls
  556                 for (i = 1; i <= argc; i++) {
  557                         printf("\tSPARG(&arg, %s) = %s;\n", \
  558                             argname[i], argname[i]) > rumpcalls
  559                 }
  560                 printf("\n") > rumpcalls
  561         } else {
  562                 printf("\n") > rumpcalls
  563         }
  564         printf("\t*error = %s(curlwp, %s, &retval);\n", funcname, argarg) \
  565             > rumpcalls
  566         printf("\tif (*error)\n\t\tretval = -1;\n") > rumpcalls
  567         if (returntype != "void")
  568                 printf("\treturn retval;\n") > rumpcalls
  569         printf("}\n") > rumpcalls
  570         printf("__weak_alias(%s,rump_enosys);\n", funcname) > rumpcalls
  571 }
  572 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" {
  573         parseline()
  574         putent($2, "")
  575         syscall++
  576         next
  577 }
  578 $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" {
  579         if ($2 == "OBSOL")
  580                 comment="obsolete"
  581         else if ($2 == "EXCL")
  582                 comment="excluded"
  583         else if ($2 == "IGNORED")
  584                 comment="ignored"
  585         else
  586                 comment="unimplemented"
  587         for (i = 3; i <= NF; i++)
  588                 comment=comment " " $i
  589 
  590         if ($2 == "IGNORED")
  591                 sys_stub = "(sy_call_t *)nullop";
  592         else
  593                 sys_stub = sys_nosys;
  594 
  595         printf("\t{ 0, 0, 0,\n\t    %s },\t\t\t/* %d = %s */\n", \
  596             sys_stub, syscall, comment) > sysent
  597         printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \
  598             > sysnamesbottom
  599         if ($2 != "UNIMPL")
  600                 printf("\t\t\t\t/* %d is %s */\n", syscall, comment) > sysnumhdr
  601         syscall++
  602         next
  603 }
  604 {
  605         for (i = 1; i <= ncompat; i++) {
  606                 if ($2 == compat_upper[i]) {
  607                         parseline();
  608                         putent("COMPAT", compat[i])
  609                         syscall++
  610                         next
  611                 }
  612         }
  613         printf("%s: line %d: unrecognized keyword %s\n", infile, NR, $2)
  614         exit 1
  615 }
  616 END {
  617         maxsyscall = syscall
  618         if (nsysent) {
  619                 if (syscall > nsysent) {
  620                         printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)
  621                         exit 1
  622                 }
  623                 while (syscall < nsysent) {
  624                         printf("\t{ 0, 0, 0,\n\t    %s },\t\t\t/* %d = filler */\n", \
  625                             sys_nosys, syscall) > sysent
  626                         syscall++
  627                 }
  628         }
  629         printf("};\n\n") > sysent
  630         printf("};\n") > sysnamesbottom
  631         printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr
  632         if (nsysent)
  633                 printf("#define\t%sNSYSENT\t%d\n", constprefix, nsysent) > sysnumhdr
  634 } '
  635 
  636 cat $sysprotos >> $sysarghdr
  637 echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
  638 echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
  639 cat $sysdcl $sysent > $syssw
  640 cat $sysnamesbottom >> $sysnames
  641 
  642 #chmod 444 $sysnames $sysnumhdr $syssw

Cache object: 74ea7e29320c2f77cc2a696572ed8645


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