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

Cache object: 5a3ed6df8ad5460ebe67dc88ef8ba72f


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