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-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  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 
SearchContext: -  none  -  3  -  10 

    1 #! /bin/sh -
    2 #       @(#)makesyscalls.sh     8.1 (Berkeley) 6/10/93
    3 # $FreeBSD: releng/11.0/sys/kern/makesyscalls.sh 303857 2016-08-08 21:18:28Z bdrewery $
    4 
    5 set -e
    6 
    7 # name of compat options:
    8 compat=COMPAT_43
    9 compat4=COMPAT_FREEBSD4
   10 compat6=COMPAT_FREEBSD6
   11 compat7=COMPAT_FREEBSD7
   12 compat10=COMPAT_FREEBSD10
   13 
   14 # output files:
   15 sysnames="syscalls.c"
   16 sysproto="../sys/sysproto.h"
   17 sysproto_h=_SYS_SYSPROTO_H_
   18 syshdr="../sys/syscall.h"
   19 sysmk="../sys/syscall.mk"
   20 syssw="init_sysent.c"
   21 syscallprefix="SYS_"
   22 switchname="sysent"
   23 namesname="syscallnames"
   24 systrace="systrace_args.c"
   25 
   26 # tmp files:
   27 sysaue="sysent.aue.$$"
   28 sysdcl="sysent.dcl.$$"
   29 syscompat="sysent.compat.$$"
   30 syscompatdcl="sysent.compatdcl.$$"
   31 syscompat4="sysent.compat4.$$"
   32 syscompat4dcl="sysent.compat4dcl.$$"
   33 syscompat6="sysent.compat6.$$"
   34 syscompat6dcl="sysent.compat6dcl.$$"
   35 syscompat7="sysent.compat7.$$"
   36 syscompat7dcl="sysent.compat7dcl.$$"
   37 syscompat10="sysent.compat10.$$"
   38 syscompat10dcl="sysent.compat10dcl.$$"
   39 sysent="sysent.switch.$$"
   40 sysinc="sysinc.switch.$$"
   41 sysarg="sysarg.switch.$$"
   42 sysprotoend="sysprotoend.$$"
   43 systracetmp="systrace.$$"
   44 systraceret="systraceret.$$"
   45 
   46 if [ -r capabilities.conf ]; then
   47         capenabled=`cat capabilities.conf | grep -v "^#" | grep -v "^$"`
   48         capenabled=`echo $capenabled | sed 's/ /,/g'`
   49 else
   50         capenabled=""
   51 fi
   52 
   53 trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0
   54 
   55 touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret
   56 
   57 case $# in
   58     0)  echo "usage: $0 input-file <config-file>" 1>&2
   59         exit 1
   60         ;;
   61 esac
   62 
   63 if [ -n "$2" ]; then
   64         . $2
   65 fi
   66 
   67 sed -e '
   68 s/\$//g
   69 :join
   70         /\\$/{a\
   71 
   72         N
   73         s/\\\n//
   74         b join
   75         }
   76 2,${
   77         /^#/!s/\([{}()*,]\)/ \1 /g
   78 }
   79 ' < $1 | awk "
   80         BEGIN {
   81                 sysaue = \"$sysaue\"
   82                 sysdcl = \"$sysdcl\"
   83                 sysproto = \"$sysproto\"
   84                 sysprotoend = \"$sysprotoend\"
   85                 sysproto_h = \"$sysproto_h\"
   86                 syscompat = \"$syscompat\"
   87                 syscompatdcl = \"$syscompatdcl\"
   88                 syscompat4 = \"$syscompat4\"
   89                 syscompat4dcl = \"$syscompat4dcl\"
   90                 syscompat6 = \"$syscompat6\"
   91                 syscompat6dcl = \"$syscompat6dcl\"
   92                 syscompat7 = \"$syscompat7\"
   93                 syscompat7dcl = \"$syscompat7dcl\"
   94                 syscompat10 = \"$syscompat10\"
   95                 syscompat10dcl = \"$syscompat10dcl\"
   96                 sysent = \"$sysent\"
   97                 syssw = \"$syssw\"
   98                 sysinc = \"$sysinc\"
   99                 sysarg = \"$sysarg\"
  100                 sysnames = \"$sysnames\"
  101                 syshdr = \"$syshdr\"
  102                 sysmk = \"$sysmk\"
  103                 systrace = \"$systrace\"
  104                 systracetmp = \"$systracetmp\"
  105                 systraceret = \"$systraceret\"
  106                 compat = \"$compat\"
  107                 compat4 = \"$compat4\"
  108                 compat6 = \"$compat6\"
  109                 compat7 = \"$compat7\"
  110                 compat10 = \"$compat10\"
  111                 syscallprefix = \"$syscallprefix\"
  112                 switchname = \"$switchname\"
  113                 namesname = \"$namesname\"
  114                 infile = \"$1\"
  115                 capenabled_string = \"$capenabled\"
  116                 "'
  117 
  118                 split(capenabled_string, capenabled, ",");
  119 
  120                 printf "/*\n * System call switch table.\n *\n" > syssw
  121                 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syssw
  122                 printf " * $%s$\n", "FreeBSD" > syssw
  123 
  124                 printf "/*\n * System call prototypes.\n *\n" > sysarg
  125                 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarg
  126                 printf " * $%s$\n", "FreeBSD" > sysarg
  127 
  128                 printf "\n#ifdef %s\n\n", compat > syscompat
  129                 printf "\n#ifdef %s\n\n", compat4 > syscompat4
  130                 printf "\n#ifdef %s\n\n", compat6 > syscompat6
  131                 printf "\n#ifdef %s\n\n", compat7 > syscompat7
  132                 printf "\n#ifdef %s\n\n", compat10 > syscompat10
  133 
  134                 printf "/*\n * System call names.\n *\n" > sysnames
  135                 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
  136                 printf " * $%s$\n", "FreeBSD" > sysnames
  137 
  138                 printf "/*\n * System call numbers.\n *\n" > syshdr
  139                 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr
  140                 printf " * $%s$\n", "FreeBSD" > syshdr
  141                 printf "# FreeBSD system call object files.\n" > sysmk
  142                 printf "# DO NOT EDIT-- this file is automatically generated.\n" > sysmk
  143                 printf "# $%s$\n", "FreeBSD" > sysmk
  144 
  145                 printf "/*\n * System call argument to DTrace register array converstion.\n *\n" > systrace
  146                 printf " * DO NOT EDIT-- this file is automatically generated.\n" > systrace
  147                 printf " * $%s$\n", "FreeBSD" > systrace
  148         }
  149         NR == 1 {
  150                 gsub("[$]FreeBSD: ", "", $0)
  151                 gsub(" [$]", "", $0)
  152 
  153                 printf " * created from%s\n */\n\n", $0 > syssw
  154 
  155                 printf "\n/* The casts are bogus but will do for now. */\n" > sysent
  156                 printf "struct sysent %s[] = {\n",switchname > sysent
  157 
  158                 printf " * created from%s\n */\n\n", $0 > sysarg
  159                 printf "#ifndef %s\n", sysproto_h > sysarg
  160                 printf "#define\t%s\n\n", sysproto_h > sysarg
  161                 printf "#include <sys/signal.h>\n" > sysarg
  162                 printf "#include <sys/acl.h>\n" > sysarg
  163                 printf "#include <sys/cpuset.h>\n" > sysarg
  164                 printf "#include <sys/_ffcounter.h>\n" > sysarg
  165                 printf "#include <sys/_semaphore.h>\n" > sysarg
  166                 printf "#include <sys/ucontext.h>\n" > sysarg
  167                 printf "#include <sys/wait.h>\n\n" > sysarg
  168                 printf "#include <bsm/audit_kevents.h>\n\n" > sysarg
  169                 printf "struct proc;\n\n" > sysarg
  170                 printf "struct thread;\n\n" > sysarg
  171                 printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg
  172                 printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg
  173                 printf "#if BYTE_ORDER == LITTLE_ENDIAN\n"> sysarg
  174                 printf "#define\tPADL_(t)\t0\n" > sysarg
  175                 printf "#define\tPADR_(t)\tPAD_(t)\n" > sysarg
  176                 printf "#else\n" > sysarg
  177                 printf "#define\tPADL_(t)\tPAD_(t)\n" > sysarg
  178                 printf "#define\tPADR_(t)\t0\n" > sysarg
  179                 printf "#endif\n\n" > sysarg
  180 
  181                 printf " * created from%s\n */\n\n", $0 > sysnames
  182                 printf "const char *%s[] = {\n", namesname > sysnames
  183 
  184                 printf " * created from%s\n */\n\n", $0 > syshdr
  185 
  186                 printf "# created from%s\nMIASM = ", $0 > sysmk
  187 
  188                 printf " * This file is part of the DTrace syscall provider.\n */\n\n" > systrace
  189                 printf "static void\nsystrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)\n{\n" > systrace
  190                 printf "\tint64_t *iarg  = (int64_t *) uarg;\n" > systrace
  191                 printf "\tswitch (sysnum) {\n" > systrace
  192 
  193                 printf "static void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracetmp
  194                 printf "\tswitch (sysnum) {\n" > systracetmp
  195 
  196                 printf "static void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceret
  197                 printf "\tswitch (sysnum) {\n" > systraceret
  198 
  199                 next
  200         }
  201         NF == 0 || $1 ~ /^;/ {
  202                 next
  203         }
  204         $1 ~ /^#[       ]*include/ {
  205                 print > sysinc
  206                 next
  207         }
  208         $1 ~ /^#[       ]*if/ {
  209                 print > sysent
  210                 print > sysdcl
  211                 print > sysarg
  212                 print > syscompat
  213                 print > syscompat4
  214                 print > syscompat6
  215                 print > syscompat7
  216                 print > syscompat10
  217                 print > sysnames
  218                 print > systrace
  219                 print > systracetmp
  220                 print > systraceret
  221                 savesyscall = syscall
  222                 next
  223         }
  224         $1 ~ /^#[       ]*else/ {
  225                 print > sysent
  226                 print > sysdcl
  227                 print > sysarg
  228                 print > syscompat
  229                 print > syscompat4
  230                 print > syscompat6
  231                 print > syscompat7
  232                 print > syscompat10
  233                 print > sysnames
  234                 print > systrace
  235                 print > systracetmp
  236                 print > systraceret
  237                 syscall = savesyscall
  238                 next
  239         }
  240         $1 ~ /^#/ {
  241                 print > sysent
  242                 print > sysdcl
  243                 print > sysarg
  244                 print > syscompat
  245                 print > syscompat4
  246                 print > syscompat6
  247                 print > syscompat7
  248                 print > syscompat10
  249                 print > sysnames
  250                 print > systrace
  251                 print > systracetmp
  252                 print > systraceret
  253                 next
  254         }
  255         syscall != $1 {
  256                 printf "%s: line %d: syscall number out of sync at %d\n",
  257                     infile, NR, syscall
  258                 printf "line is:\n"
  259                 print
  260                 exit 1
  261         }
  262         # Returns true if the type "name" is the first flag in the type field
  263         function type(name, flags, n) {
  264                 n = split($3, flags, /\|/)
  265                 return (n > 0 && flags[1] == name)
  266         }
  267         # Returns true if the flag "name" is set in the type field
  268         function flag(name, flags, i, n) {
  269                 n = split($3, flags, /\|/)
  270                 for (i = 1; i <= n; i++)
  271                         if (flags[i] == name)
  272                                 return 1
  273                 return 0
  274         }
  275         function align_sysent_comment(column) {
  276                 printf("\t") > sysent
  277                 column = column + 8 - column % 8
  278                 while (column < 56) {
  279                         printf("\t") > sysent
  280                         column = column + 8
  281                 }
  282         }
  283         function parserr(was, wanted) {
  284                 printf "%s: line %d: unexpected %s (expected %s)\n",
  285                     infile, NR, was, wanted
  286                 exit 1
  287         }
  288         function parseline() {
  289                 f=4                     # toss number, type, audit event
  290                 argc= 0;
  291                 argssize = "0"
  292                 thr_flag = "SY_THR_STATIC"
  293                 if (flag("NOTSTATIC")) {
  294                         thr_flag = "SY_THR_ABSENT"
  295                 }
  296                 if ($NF != "}") {
  297                         funcalias=$(NF-2)
  298                         argalias=$(NF-1)
  299                         rettype=$NF
  300                         end=NF-3
  301                 } else {
  302                         funcalias=""
  303                         argalias=""
  304                         rettype="int"
  305                         end=NF
  306                 }
  307                 if (flag("NODEF")) {
  308                         auditev="AUE_NULL"
  309                         funcname=$4
  310                         argssize = "AS(" $6 ")"
  311                         return
  312                 }
  313                 if ($f != "{")
  314                         parserr($f, "{")
  315                 f++
  316                 if ($end != "}")
  317                         parserr($end, "}")
  318                 end--
  319                 if ($end != ";")
  320                         parserr($end, ";")
  321                 end--
  322                 if ($end != ")")
  323                         parserr($end, ")")
  324                 end--
  325 
  326                 syscallret=$f
  327                 f++
  328 
  329                 funcname=$f
  330 
  331                 #
  332                 # We now know the func name, so define a flags field for it.
  333                 # Do this before any other processing as we may return early
  334                 # from it.
  335                 #
  336                 for (cap in capenabled) {
  337                         if (funcname == capenabled[cap]) {
  338                                 flags = "SYF_CAPENABLED";
  339                                 break;
  340                         }
  341                 }
  342 
  343                 if (funcalias == "")
  344                         funcalias = funcname
  345                 if (argalias == "") {
  346                         argalias = funcname "_args"
  347                         if (flag("COMPAT"))
  348                                 argalias = "o" argalias
  349                         if (flag("COMPAT4"))
  350                                 argalias = "freebsd4_" argalias
  351                         if (flag("COMPAT6"))
  352                                 argalias = "freebsd6_" argalias
  353                         if (flag("COMPAT7"))
  354                                 argalias = "freebsd7_" argalias
  355                         if (flag("COMPAT10"))
  356                                 argalias = "freebsd10_" argalias
  357                 }
  358                 f++
  359 
  360                 if ($f != "(")
  361                         parserr($f, ")")
  362                 f++
  363 
  364                 if (f == end) {
  365                         if ($f != "void")
  366                                 parserr($f, "argument definition")
  367                         return
  368                 }
  369 
  370                 while (f <= end) {
  371                         argc++
  372                         argtype[argc]=""
  373                         oldf=""
  374                         while (f < end && $(f+1) != ",") {
  375                                 if (argtype[argc] != "" && oldf != "*")
  376                                         argtype[argc] = argtype[argc]" ";
  377                                 argtype[argc] = argtype[argc]$f;
  378                                 oldf = $f;
  379                                 f++
  380                         }
  381                         if (argtype[argc] == "")
  382                                 parserr($f, "argument definition")
  383                         argname[argc]=$f;
  384                         f += 2;                 # skip name, and any comma
  385                 }
  386                 if (argc != 0)
  387                         argssize = "AS(" argalias ")"
  388         }
  389         {       comment = $4
  390                 if (NF < 7)
  391                         for (i = 5; i <= NF; i++)
  392                                 comment = comment " " $i
  393         }
  394 
  395         #
  396         # The AUE_ audit event identifier.
  397         #
  398         {
  399                 auditev = $2;
  400         }
  401 
  402         #
  403         # The flags, if any.
  404         #
  405         {
  406                 flags = "0";
  407         }
  408 
  409         type("STD") || type("NODEF") || type("NOARGS") || type("NOPROTO") \
  410             || type("NOSTD") {
  411                 parseline()
  412                 printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall) > systrace
  413                 printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systracetmp
  414                 printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systraceret
  415                 if (argc > 0) {
  416                         printf("\t\tswitch(ndx) {\n") > systracetmp
  417                         printf("\t\tstruct %s *p = params;\n", argalias) > systrace
  418                         for (i = 1; i <= argc; i++) {
  419                                 arg = argtype[i]
  420                                 sub("__restrict$", "", arg)
  421                                 printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systracetmp
  422                                 if (index(arg, "*") > 0 || arg == "caddr_t")
  423                                         printf("\t\tuarg[%d] = (intptr_t) p->%s; /* %s */\n", \
  424                                              i - 1, \
  425                                              argname[i], arg) > systrace
  426                                 else if (arg == "union l_semun")
  427                                         printf("\t\tuarg[%d] = p->%s.buf; /* %s */\n", \
  428                                              i - 1, \
  429                                              argname[i], arg) > systrace
  430                                 else if (substr(arg, 1, 1) == "u" || arg == "size_t")
  431                                         printf("\t\tuarg[%d] = p->%s; /* %s */\n", \
  432                                              i - 1, \
  433                                              argname[i], arg) > systrace
  434                                 else
  435                                         printf("\t\tiarg[%d] = p->%s; /* %s */\n", \
  436                                              i - 1, \
  437                                              argname[i], arg) > systrace
  438                         }
  439                         printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systracetmp
  440 
  441                         printf("\t\tif (ndx == 0 || ndx == 1)\n") > systraceret
  442                         printf("\t\t\tp = \"%s\";\n", syscallret) > systraceret
  443                         printf("\t\tbreak;\n") > systraceret
  444                 }
  445                 printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace
  446                 printf("\t\tbreak;\n") > systracetmp
  447                 if (argc != 0 && !flag("NOARGS") && !flag("NOPROTO") && \
  448                     !flag("NODEF")) {
  449                         printf("struct %s {\n", argalias) > sysarg
  450                         for (i = 1; i <= argc; i++)
  451                                 printf("\tchar %s_l_[PADL_(%s)]; " \
  452                                     "%s %s; char %s_r_[PADR_(%s)];\n",
  453                                     argname[i], argtype[i],
  454                                     argtype[i], argname[i],
  455                                     argname[i], argtype[i]) > sysarg
  456                         printf("};\n") > sysarg
  457                 }
  458                 else if (!flag("NOARGS") && !flag("NOPROTO") && !flag("NODEF"))
  459                         printf("struct %s {\n\tregister_t dummy;\n};\n",
  460                             argalias) > sysarg
  461                 if (!flag("NOPROTO") && !flag("NODEF")) {
  462                         if (funcname == "nosys" || funcname == "lkmnosys" ||
  463                             funcname == "sysarch" || funcname ~ /^freebsd/ || 
  464                             funcname ~ /^linux/ || funcname ~ /^svr4/ || 
  465                             funcname ~ /^ibcs2/ || funcname ~ /^xenix/ ||
  466                             funcname ~ /^cloudabi/) {
  467                                 printf("%s\t%s(struct thread *, struct %s *)",
  468                                     rettype, funcname, argalias) > sysdcl
  469                         } else {
  470                                 printf("%s\tsys_%s(struct thread *, struct %s *)",
  471                                     rettype, funcname, argalias) > sysdcl
  472                         } 
  473                         printf(";\n") > sysdcl
  474                         printf("#define\t%sAUE_%s\t%s\n", syscallprefix,
  475                             funcalias, auditev) > sysaue
  476                 }
  477                 printf("\t{ %s, (sy_call_t *)", argssize) > sysent
  478                 column = 8 + 2 + length(argssize) + 15
  479                 if (flag("NOSTD")) {
  480                         printf("lkmressys, AUE_NULL, NULL, 0, 0, %s, SY_THR_ABSENT },", flags) > sysent
  481                         column = column + length("lkmressys") + length("AUE_NULL") + 3
  482                 } else {
  483                         if (funcname == "nosys" || funcname == "sysarch" || 
  484                             funcname == "lkmnosys" || funcname ~ /^freebsd/ ||
  485                             funcname ~ /^linux/ || funcname ~ /^svr4/ ||
  486                             funcname ~ /^ibcs2/ || funcname ~ /^xenix/ ||
  487                             funcname ~ /^cloudabi/) {
  488                                 printf("%s, %s, NULL, 0, 0, %s, %s },", funcname, auditev, flags, thr_flag) > sysent
  489                                 column = column + length(funcname) + length(auditev) + length(flags) + 3 
  490                         } else {
  491                                 printf("sys_%s, %s, NULL, 0, 0, %s, %s },", funcname, auditev, flags, thr_flag) > sysent
  492                                 column = column + length(funcname) + length(auditev) + length(flags) + 3 + 4
  493                         } 
  494                 } 
  495                 align_sysent_comment(column)
  496                 printf("/* %d = %s */\n", syscall, funcalias) > sysent
  497                 printf("\t\"%s\",\t\t\t/* %d = %s */\n",
  498                     funcalias, syscall, funcalias) > sysnames
  499                 if (!flag("NODEF")) {
  500                         printf("#define\t%s%s\t%d\n", syscallprefix,
  501                             funcalias, syscall) > syshdr
  502                         printf(" \\\n\t%s.o", funcalias) > sysmk
  503                 }
  504                 syscall++
  505                 next
  506         }
  507         type("COMPAT") || type("COMPAT4") || type("COMPAT6") || \
  508             type("COMPAT7") || type("COMPAT10") {
  509                 if (flag("COMPAT")) {
  510                         ncompat++
  511                         out = syscompat
  512                         outdcl = syscompatdcl
  513                         wrap = "compat"
  514                         prefix = "o"
  515                         descr = "old"
  516                 } else if (flag("COMPAT4")) {
  517                         ncompat4++
  518                         out = syscompat4
  519                         outdcl = syscompat4dcl
  520                         wrap = "compat4"
  521                         prefix = "freebsd4_"
  522                         descr = "freebsd4"
  523                 } else if (flag("COMPAT6")) {
  524                         ncompat6++
  525                         out = syscompat6
  526                         outdcl = syscompat6dcl
  527                         wrap = "compat6"
  528                         prefix = "freebsd6_"
  529                         descr = "freebsd6"
  530                 } else if (flag("COMPAT7")) {
  531                         ncompat7++
  532                         out = syscompat7
  533                         outdcl = syscompat7dcl
  534                         wrap = "compat7"
  535                         prefix = "freebsd7_"
  536                         descr = "freebsd7"
  537                 } else if (flag("COMPAT10")) {
  538                         ncompat10++
  539                         out = syscompat10
  540                         outdcl = syscompat10dcl
  541                         wrap = "compat10"
  542                         prefix = "freebsd10_"
  543                         descr = "freebsd10"
  544                 }
  545                 parseline()
  546                 if (argc != 0 && !flag("NOARGS") && !flag("NOPROTO") && \
  547                     !flag("NODEF")) {
  548                         printf("struct %s {\n", argalias) > out
  549                         for (i = 1; i <= argc; i++)
  550                                 printf("\tchar %s_l_[PADL_(%s)]; %s %s; " \
  551                                     "char %s_r_[PADR_(%s)];\n",
  552                                     argname[i], argtype[i],
  553                                     argtype[i], argname[i],
  554                                     argname[i], argtype[i]) > out
  555                         printf("};\n") > out
  556                 }
  557                 else if (!flag("NOARGS") && !flag("NOPROTO") && !flag("NODEF"))
  558                         printf("struct %s {\n\tregister_t dummy;\n};\n",
  559                             argalias) > sysarg
  560                 if (!flag("NOPROTO") && !flag("NODEF")) {
  561                         printf("%s\t%s%s(struct thread *, struct %s *);\n",
  562                             rettype, prefix, funcname, argalias) > outdcl
  563                         printf("#define\t%sAUE_%s%s\t%s\n", syscallprefix,
  564                             prefix, funcname, auditev) > sysaue
  565                 }
  566                 if (flag("NOSTD")) {
  567                         printf("\t{ %s, (sy_call_t *)%s, %s, NULL, 0, 0, 0, SY_THR_ABSENT },",
  568                             "0", "lkmressys", "AUE_NULL") > sysent
  569                         align_sysent_comment(8 + 2 + length("0") + 15 + \
  570                             length("lkmressys") + length("AUE_NULL") + 3)
  571                 } else {
  572                         printf("\t{ %s(%s,%s), %s, NULL, 0, 0, %s, %s },",
  573                             wrap, argssize, funcname, auditev, flags, thr_flag) > sysent
  574                         align_sysent_comment(8 + 9 + length(argssize) + 1 + \
  575                             length(funcname) + length(auditev) + \
  576                             length(flags) + 4)
  577                 }
  578                 printf("/* %d = %s %s */\n", syscall, descr, funcalias) > sysent
  579                 printf("\t\"%s.%s\",\t\t/* %d = %s %s */\n",
  580                     wrap, funcalias, syscall, descr, funcalias) > sysnames
  581                 # Do not provide freebsdN_* symbols in libc for < FreeBSD 7
  582                 if (flag("COMPAT") || flag("COMPAT4") || flag("COMPAT6")) {
  583                         printf("\t\t\t\t/* %d is %s %s */\n",
  584                             syscall, descr, funcalias) > syshdr
  585                 } else if (!flag("NODEF")) {
  586                         printf("#define\t%s%s%s\t%d\n", syscallprefix,
  587                             prefix, funcalias, syscall) > syshdr
  588                         printf(" \\\n\t%s%s.o", prefix, funcalias) > sysmk
  589                 }
  590                 syscall++
  591                 next
  592         }
  593         type("OBSOL") {
  594                 printf("\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },") > sysent
  595                 align_sysent_comment(34)
  596                 printf("/* %d = obsolete %s */\n", syscall, comment) > sysent
  597                 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n",
  598                     $4, syscall, comment) > sysnames
  599                 printf("\t\t\t\t/* %d is obsolete %s */\n",
  600                     syscall, comment) > syshdr
  601                 syscall++
  602                 next
  603         }
  604         type("UNIMPL") {
  605                 printf("\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },\t\t\t/* %d = %s */\n",
  606                     syscall, comment) > sysent
  607                 printf("\t\"#%d\",\t\t\t/* %d = %s */\n",
  608                     syscall, syscall, comment) > sysnames
  609                 syscall++
  610                 next
  611         }
  612         {
  613                 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $3
  614                 exit 1
  615         }
  616         END {
  617                 printf "\n#define AS(name) (sizeof(struct name) / sizeof(register_t))\n" > sysinc
  618 
  619                 if (ncompat != 0 || ncompat4 != 0 || ncompat6 != 0 || ncompat7 != 0 || ncompat10 != 0)
  620                         printf "#include \"opt_compat.h\"\n\n" > syssw
  621 
  622                 if (ncompat != 0) {
  623                         printf "\n#ifdef %s\n", compat > sysinc
  624                         printf "#define compat(n, name) n, (sy_call_t *)__CONCAT(o,name)\n" > sysinc
  625                         printf "#else\n" > sysinc
  626                         printf "#define compat(n, name) 0, (sy_call_t *)nosys\n" > sysinc
  627                         printf "#endif\n" > sysinc
  628                 }
  629 
  630                 if (ncompat4 != 0) {
  631                         printf "\n#ifdef %s\n", compat4 > sysinc
  632                         printf "#define compat4(n, name) n, (sy_call_t *)__CONCAT(freebsd4_,name)\n" > sysinc
  633                         printf "#else\n" > sysinc
  634                         printf "#define compat4(n, name) 0, (sy_call_t *)nosys\n" > sysinc
  635                         printf "#endif\n" > sysinc
  636                 }
  637 
  638                 if (ncompat6 != 0) {
  639                         printf "\n#ifdef %s\n", compat6 > sysinc
  640                         printf "#define compat6(n, name) n, (sy_call_t *)__CONCAT(freebsd6_,name)\n" > sysinc
  641                         printf "#else\n" > sysinc
  642                         printf "#define compat6(n, name) 0, (sy_call_t *)nosys\n" > sysinc
  643                         printf "#endif\n" > sysinc
  644                 }
  645 
  646                 if (ncompat7 != 0) {
  647                         printf "\n#ifdef %s\n", compat7 > sysinc
  648                         printf "#define compat7(n, name) n, (sy_call_t *)__CONCAT(freebsd7_,name)\n" > sysinc
  649                         printf "#else\n" > sysinc
  650                         printf "#define compat7(n, name) 0, (sy_call_t *)nosys\n" > sysinc
  651                         printf "#endif\n" > sysinc
  652                 }
  653                 if (ncompat10 != 0) {
  654                         printf "\n#ifdef %s\n", compat10 > sysinc
  655                         printf "#define compat10(n, name) n, (sy_call_t *)__CONCAT(freebsd10_,name)\n" > sysinc
  656                         printf "#else\n" > sysinc
  657                         printf "#define compat10(n, name) 0, (sy_call_t *)nosys\n" > sysinc
  658                         printf "#endif\n" > sysinc
  659                 }
  660                 printf("\n#endif /* %s */\n\n", compat) > syscompatdcl
  661                 printf("\n#endif /* %s */\n\n", compat4) > syscompat4dcl
  662                 printf("\n#endif /* %s */\n\n", compat6) > syscompat6dcl
  663                 printf("\n#endif /* %s */\n\n", compat7) > syscompat7dcl
  664                 printf("\n#endif /* %s */\n\n", compat10) > syscompat10dcl
  665 
  666                 printf("\n#undef PAD_\n") > sysprotoend
  667                 printf("#undef PADL_\n") > sysprotoend
  668                 printf("#undef PADR_\n") > sysprotoend
  669                 printf("\n#endif /* !%s */\n", sysproto_h) > sysprotoend
  670 
  671                 printf("\n") > sysmk
  672                 printf("};\n") > sysent
  673                 printf("};\n") > sysnames
  674                 printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \
  675                     > syshdr
  676                 printf "\tdefault:\n\t\t*n_args = 0;\n\t\tbreak;\n\t};\n}\n" > systrace
  677                 printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systracetmp
  678                 printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systraceret
  679         } '
  680 
  681 cat $sysinc $sysent >> $syssw
  682 cat $sysarg $sysdcl \
  683         $syscompat $syscompatdcl \
  684         $syscompat4 $syscompat4dcl \
  685         $syscompat6 $syscompat6dcl \
  686         $syscompat7 $syscompat7dcl \
  687         $syscompat10 $syscompat10dcl \
  688         $sysaue $sysprotoend > $sysproto
  689 cat $systracetmp >> $systrace
  690 cat $systraceret >> $systrace
  691 

Cache object: 4bc45b74320ab53acb791938fffd0586


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