13cab2bb3Spatrick#!/usr/bin/awk -f
23cab2bb3Spatrick
33cab2bb3Spatrick#===-- generate_netbsd_syscalls.awk ----------------------------------------===#
43cab2bb3Spatrick#
53cab2bb3Spatrick# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
63cab2bb3Spatrick# See https://llvm.org/LICENSE.txt for license information.
73cab2bb3Spatrick# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
83cab2bb3Spatrick#
93cab2bb3Spatrick#===------------------------------------------------------------------------===#
103cab2bb3Spatrick#
113cab2bb3Spatrick# This file is a generator of:
123cab2bb3Spatrick#  - include/sanitizer/netbsd_syscall_hooks.h
133cab2bb3Spatrick#  - lib/sanitizer_common/sanitizer_syscalls_netbsd.inc
143cab2bb3Spatrick#
153cab2bb3Spatrick# This script accepts on the input syscalls.master by default located in the
163cab2bb3Spatrick# /usr/src/sys/kern/syscalls.master path in the NetBSD distribution.
173cab2bb3Spatrick#
183cab2bb3Spatrick# This script shall be executed only on the newest NetBSD version.
193cab2bb3Spatrick# This script will emit compat code for the older releases.
203cab2bb3Spatrick#
213cab2bb3Spatrick# NetBSD minimal version supported 9.0.
223cab2bb3Spatrick# NetBSD current version supported 9.99.30.
233cab2bb3Spatrick#
243cab2bb3Spatrick#===------------------------------------------------------------------------===#
253cab2bb3Spatrick
263cab2bb3SpatrickBEGIN {
27*810390e3Srobert  # hardcode the script name
283cab2bb3Spatrick  script_name = "generate_netbsd_syscalls.awk"
293cab2bb3Spatrick  outputh = "../include/sanitizer/netbsd_syscall_hooks.h"
303cab2bb3Spatrick  outputinc = "../lib/sanitizer_common/sanitizer_syscalls_netbsd.inc"
313cab2bb3Spatrick
323cab2bb3Spatrick  # assert that we are in the directory with scripts
333cab2bb3Spatrick  in_utils = system("test -f " script_name " && exit 1 || exit 0")
343cab2bb3Spatrick  if (in_utils == 0) {
353cab2bb3Spatrick    usage()
363cab2bb3Spatrick  }
373cab2bb3Spatrick
383cab2bb3Spatrick  # assert 1 argument passed
393cab2bb3Spatrick  if (ARGC != 2) {
403cab2bb3Spatrick    usage()
413cab2bb3Spatrick  }
423cab2bb3Spatrick
433cab2bb3Spatrick  # assert argument is a valid file path to syscall.master
443cab2bb3Spatrick  if (system("test -f " ARGV[1]) != 0) {
453cab2bb3Spatrick    usage()
463cab2bb3Spatrick  }
473cab2bb3Spatrick
483cab2bb3Spatrick  # sanity check that the path ends with "syscall.master"
493cab2bb3Spatrick  if (ARGV[1] !~ /syscalls\.master$/) {
503cab2bb3Spatrick    usage()
513cab2bb3Spatrick  }
523cab2bb3Spatrick
533cab2bb3Spatrick  # accept overloading CLANGFORMAT from environment
543cab2bb3Spatrick  clangformat = "clang-format"
553cab2bb3Spatrick  if ("CLANGFORMAT" in ENVIRON) {
563cab2bb3Spatrick    clangformat = ENVIRON["CLANGFORMAT"]
573cab2bb3Spatrick  }
583cab2bb3Spatrick
593cab2bb3Spatrick  # parsing specific symbols
603cab2bb3Spatrick  parsingheader=1
613cab2bb3Spatrick
623cab2bb3Spatrick  parsedsyscalls=0
633cab2bb3Spatrick
643cab2bb3Spatrick  # Hardcoded in algorithm
653cab2bb3Spatrick  SYS_MAXSYSARGS=8
663cab2bb3Spatrick}
673cab2bb3Spatrick
683cab2bb3Spatrick# Parse the RCS ID from syscall.master
693cab2bb3Spatrickparsingheader == 1 && NR == 1 {
703cab2bb3Spatrick  if (match($0, /\$[^$]+\$/)) {
713cab2bb3Spatrick    # trim initial 'NetBSD: ' and trailing ' $'
723cab2bb3Spatrick    syscallmasterversion = substr($0, RSTART + 9, RLENGTH - 11)
733cab2bb3Spatrick  } else {
743cab2bb3Spatrick    # wrong file?
753cab2bb3Spatrick    usage()
763cab2bb3Spatrick  }
773cab2bb3Spatrick}
783cab2bb3Spatrick
793cab2bb3Spatrick# skip the following lines
803cab2bb3Spatrick#  - empty
813cab2bb3SpatrickNF == 0 {
823cab2bb3Spatrick  next
833cab2bb3Spatrick}
843cab2bb3Spatrick#  - comment
853cab2bb3Spatrick$1 == ";" {
863cab2bb3Spatrick  next
873cab2bb3Spatrick}
883cab2bb3Spatrick
893cab2bb3Spatrick# separator between the header and table with syscalls
903cab2bb3Spatrick$0 == "%%" {
913cab2bb3Spatrick  parsingheader = 0
923cab2bb3Spatrick  next
933cab2bb3Spatrick}
943cab2bb3Spatrick
953cab2bb3Spatrick# preserve 'if/elif/else/endif' C preprocessor as-is
963cab2bb3Spatrickparsingheader == 0 && $0 ~ /^#/ {
973cab2bb3Spatrick  if (parsedsyscalls in ifelifelseendif) {
983cab2bb3Spatrick    ifelifelseendif[parsedsyscalls] = ifelifelseendif[parsedsyscalls] "\n" $0
993cab2bb3Spatrick  } else {
1003cab2bb3Spatrick    ifelifelseendif[parsedsyscalls] = $0
1013cab2bb3Spatrick  }
1023cab2bb3Spatrick  next
1033cab2bb3Spatrick}
1043cab2bb3Spatrick
1053cab2bb3Spatrick# parsing of syscall definitions
1063cab2bb3Spatrickparsingheader == 0 && $1 ~ /^[0-9]+$/ {
1073cab2bb3Spatrick  # first join multiple lines into single one
1083cab2bb3Spatrick  while (sub(/\\$/, "")) {
1093cab2bb3Spatrick    getline line
1103cab2bb3Spatrick    $0 = $0 "" line
1113cab2bb3Spatrick  }
1123cab2bb3Spatrick
1133cab2bb3Spatrick  # Skip unwanted syscalls
1143cab2bb3Spatrick  skip=0
1153cab2bb3Spatrick  if ($0 ~ /OBSOL/ || $0 ~ /EXCL/ || $0 ~ /UNIMPL/) {
1163cab2bb3Spatrick    skip=1
1173cab2bb3Spatrick  }
1183cab2bb3Spatrick
1193cab2bb3Spatrick  # Compose the syscall name
1203cab2bb3Spatrick  #  - compat?
1213cab2bb3Spatrick  compat=""
1223cab2bb3Spatrick  if (match($0, /COMPAT_[0-9]+/)) {
1233cab2bb3Spatrick    compat = tolower(substr($0, RSTART, RLENGTH))
1243cab2bb3Spatrick  }
1253cab2bb3Spatrick  # - alias name?
1263cab2bb3Spatrick  alias=""
1273cab2bb3Spatrick  if ($(NF) != "}" && !skip) {
1283cab2bb3Spatrick    alias = alias "" $(NF)
1293cab2bb3Spatrick  }
1303cab2bb3Spatrick  # - compat version?
1313cab2bb3Spatrick  compatver=""
1323cab2bb3Spatrick  if (match($0, /\|[0-9]+\|/)) {
1333cab2bb3Spatrick    compatver = tolower(substr($0, RSTART + 1, RLENGTH - 2))
1343cab2bb3Spatrick  }
1353cab2bb3Spatrick  # - basename?
1363cab2bb3Spatrick  basename=""
1373cab2bb3Spatrick  if (skip) {
1383cab2bb3Spatrick    basename = $1
1393cab2bb3Spatrick  } else {
1403cab2bb3Spatrick    if (match($0, /\|[_a-z0-9]+\(/)) {
1413cab2bb3Spatrick      basename = tolower(substr($0, RSTART + 1, RLENGTH - 2))
1423cab2bb3Spatrick    }
1433cab2bb3Spatrick  }
1443cab2bb3Spatrick
1453cab2bb3Spatrick  syscallname=""
1463cab2bb3Spatrick
1473cab2bb3Spatrick  if (skip) {
1483cab2bb3Spatrick    syscallname= syscallname "$"
1493cab2bb3Spatrick  }
1503cab2bb3Spatrick
1513cab2bb3Spatrick  if (length(compat) > 0) {
1523cab2bb3Spatrick    syscallname = syscallname "" compat "_"
1533cab2bb3Spatrick  }
1543cab2bb3Spatrick  if (length(alias) > 0) {
1553cab2bb3Spatrick    syscallname = syscallname "" alias
1563cab2bb3Spatrick  } else {
1573cab2bb3Spatrick    if (length(compatver) > 0) {
1583cab2bb3Spatrick      syscallname = syscallname "__" basename "" compatver
1593cab2bb3Spatrick    } else {
1603cab2bb3Spatrick      syscallname = syscallname "" basename
1613cab2bb3Spatrick    }
1623cab2bb3Spatrick  }
1633cab2bb3Spatrick
1643cab2bb3Spatrick  # Store the syscallname
1653cab2bb3Spatrick  syscalls[parsedsyscalls]=syscallname
1663cab2bb3Spatrick
1673cab2bb3Spatrick  # Extract syscall arguments
1683cab2bb3Spatrick  if (match($0, /\([^)]+\)/)) {
1693cab2bb3Spatrick    args = substr($0, RSTART + 1, RLENGTH - 2)
1703cab2bb3Spatrick
1713cab2bb3Spatrick    if (args == "void") {
1723cab2bb3Spatrick      syscallargs[parsedsyscalls] = "void"
1733cab2bb3Spatrick      syscallfullargs[parsedsyscalls] = "void"
1743cab2bb3Spatrick    } else {
1753cab2bb3Spatrick      # Normalize 'type * argument' to 'type *argument'
1763cab2bb3Spatrick      gsub("\\*[ \t]+", "*", args)
1773cab2bb3Spatrick
1783cab2bb3Spatrick      n = split(args, a, ",")
1793cab2bb3Spatrick
1803cab2bb3Spatrick      # Handle the first argument
1813cab2bb3Spatrick      match(a[1], /[*_a-z0-9\[\]]+$/)
1823cab2bb3Spatrick      syscallfullargs[parsedsyscalls] = substr(a[1], RSTART) "_"
1833cab2bb3Spatrick
1843cab2bb3Spatrick      gsub(".+[ *]", "", a[1])
1853cab2bb3Spatrick      syscallargs[parsedsyscalls] = a[1]
1863cab2bb3Spatrick
1873cab2bb3Spatrick      # Handle the rest of arguments
1883cab2bb3Spatrick      for (i = 2; i <= n; i++) {
1893cab2bb3Spatrick        match(a[i], /[*_a-zA-Z0-9\[\]]+$/)
1903cab2bb3Spatrick        fs = substr(a[i], RSTART)
1913cab2bb3Spatrick        if (fs ~ /\[/) {
1923cab2bb3Spatrick          sub(/\[/, "_[", fs)
1933cab2bb3Spatrick        } else {
1943cab2bb3Spatrick          fs = fs "_"
1953cab2bb3Spatrick        }
1963cab2bb3Spatrick        syscallfullargs[parsedsyscalls] = syscallfullargs[parsedsyscalls] "$" fs
1973cab2bb3Spatrick	gsub(".+[ *]", "", a[i])
1983cab2bb3Spatrick        syscallargs[parsedsyscalls] = syscallargs[parsedsyscalls] "$" a[i]
1993cab2bb3Spatrick      }
2003cab2bb3Spatrick
2013cab2bb3Spatrick      # Handle array arguments for syscall(2) and __syscall(2)
2023cab2bb3Spatrick      nargs = "arg0$arg1$arg2$arg3$arg4$arg5$arg6$arg7"
2033cab2bb3Spatrick      gsub(/args\[SYS_MAXSYSARGS\]/, nargs, syscallargs[parsedsyscalls])
2043cab2bb3Spatrick    }
2053cab2bb3Spatrick  }
2063cab2bb3Spatrick
2073cab2bb3Spatrick  parsedsyscalls++
2083cab2bb3Spatrick
2093cab2bb3Spatrick  # Done with this line
2103cab2bb3Spatrick  next
2113cab2bb3Spatrick}
2123cab2bb3Spatrick
2133cab2bb3Spatrick
2143cab2bb3SpatrickEND {
2153cab2bb3Spatrick  # empty file?
2163cab2bb3Spatrick  if (NR < 1 && !abnormal_exit) {
2173cab2bb3Spatrick    usage()
2183cab2bb3Spatrick  }
2193cab2bb3Spatrick
2203cab2bb3Spatrick  # Handle abnormal exit
2213cab2bb3Spatrick  if (abnormal_exit) {
2223cab2bb3Spatrick    exit(abnormal_exit)
2233cab2bb3Spatrick  }
2243cab2bb3Spatrick
2253cab2bb3Spatrick  # Generate sanitizer_syscalls_netbsd.inc
2263cab2bb3Spatrick
2273cab2bb3Spatrick  # open pipe
2283cab2bb3Spatrick  cmd = clangformat " > " outputh
2293cab2bb3Spatrick
2303cab2bb3Spatrick  pcmd("//===-- netbsd_syscall_hooks.h --------------------------------------------===//")
2313cab2bb3Spatrick  pcmd("//")
2323cab2bb3Spatrick  pcmd("// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.")
2333cab2bb3Spatrick  pcmd("// See https://llvm.org/LICENSE.txt for license information.")
2343cab2bb3Spatrick  pcmd("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception")
2353cab2bb3Spatrick  pcmd("//")
2363cab2bb3Spatrick  pcmd("//===----------------------------------------------------------------------===//")
2373cab2bb3Spatrick  pcmd("//")
2383cab2bb3Spatrick  pcmd("// This file is a part of public sanitizer interface.")
2393cab2bb3Spatrick  pcmd("//")
2403cab2bb3Spatrick  pcmd("// System call handlers.")
2413cab2bb3Spatrick  pcmd("//")
2423cab2bb3Spatrick  pcmd("// Interface methods declared in this header implement pre- and post- syscall")
2433cab2bb3Spatrick  pcmd("// actions for the active sanitizer.")
2443cab2bb3Spatrick  pcmd("// Usage:")
2453cab2bb3Spatrick  pcmd("//   __sanitizer_syscall_pre_getfoo(...args...);")
2463cab2bb3Spatrick  pcmd("//   long long res = syscall(SYS_getfoo, ...args...);")
2473cab2bb3Spatrick  pcmd("//   __sanitizer_syscall_post_getfoo(res, ...args...);")
2483cab2bb3Spatrick  pcmd("//")
2493cab2bb3Spatrick  pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
2503cab2bb3Spatrick  pcmd("//")
2513cab2bb3Spatrick  pcmd("// Generated with: " script_name)
2523cab2bb3Spatrick  pcmd("// Generated date: " strftime("%F"))
2533cab2bb3Spatrick  pcmd("// Generated from: " syscallmasterversion)
2543cab2bb3Spatrick  pcmd("//")
2553cab2bb3Spatrick  pcmd("//===----------------------------------------------------------------------===//")
2563cab2bb3Spatrick  pcmd("#ifndef SANITIZER_NETBSD_SYSCALL_HOOKS_H")
2573cab2bb3Spatrick  pcmd("#define SANITIZER_NETBSD_SYSCALL_HOOKS_H")
2583cab2bb3Spatrick  pcmd("")
2593cab2bb3Spatrick
2603cab2bb3Spatrick  for (i = 0; i < parsedsyscalls; i++) {
2613cab2bb3Spatrick
2623cab2bb3Spatrick    if (i in ifelifelseendif) {
2633cab2bb3Spatrick      pcmd(ifelifelseendif[i])
2643cab2bb3Spatrick    }
2653cab2bb3Spatrick
2663cab2bb3Spatrick    sn = syscalls[i]
2673cab2bb3Spatrick
2683cab2bb3Spatrick    if (sn ~ /^\$/) {
2693cab2bb3Spatrick      pcmd("/* syscall " substr(sn,2) " has been skipped */")
2703cab2bb3Spatrick      continue
2713cab2bb3Spatrick    }
2723cab2bb3Spatrick
2733cab2bb3Spatrick    inargs = ""
2743cab2bb3Spatrick
2753cab2bb3Spatrick    if (syscallargs[i] != "void") {
2763cab2bb3Spatrick      inargs = syscallargs[i]
2773cab2bb3Spatrick      gsub(/\$/, ", ", inargs)
2783cab2bb3Spatrick    }
2793cab2bb3Spatrick
2803cab2bb3Spatrick    outargs = ""
2813cab2bb3Spatrick
2823cab2bb3Spatrick    if (syscallargs[i] != "void") {
2833cab2bb3Spatrick      outargs = "(long long)(" syscallargs[i] ")"
2843cab2bb3Spatrick      gsub(/\$/, "), (long long)(", outargs)
2853cab2bb3Spatrick    }
2863cab2bb3Spatrick
2873cab2bb3Spatrick    pcmd("#define __sanitizer_syscall_pre_" sn "(" inargs ") \\")
2883cab2bb3Spatrick    pcmd("  __sanitizer_syscall_pre_impl_" sn "(" outargs ")")
2893cab2bb3Spatrick
2903cab2bb3Spatrick    if (inargs == "") {
2913cab2bb3Spatrick      inargs = "res"
2923cab2bb3Spatrick    } else {
2933cab2bb3Spatrick      inargs = "res, " inargs
2943cab2bb3Spatrick    }
2953cab2bb3Spatrick
2963cab2bb3Spatrick    if (outargs == "") {
2973cab2bb3Spatrick      outargs = "res"
2983cab2bb3Spatrick    } else {
2993cab2bb3Spatrick      outargs = "res, " outargs
3003cab2bb3Spatrick    }
3013cab2bb3Spatrick
3023cab2bb3Spatrick    pcmd("#define __sanitizer_syscall_post_" sn "(" inargs ") \\")
3033cab2bb3Spatrick    pcmd("  __sanitizer_syscall_post_impl_" sn "(" outargs ")")
3043cab2bb3Spatrick  }
3053cab2bb3Spatrick
3063cab2bb3Spatrick  pcmd("")
3073cab2bb3Spatrick  pcmd("/* Compat with older releases */")
3083cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_pre_getvfsstat __sanitizer_syscall_pre_compat_90_getvfsstat")
3093cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_post_getvfsstat __sanitizer_syscall_post_compat_90_getvfsstat")
3103cab2bb3Spatrick  pcmd("")
3113cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_pre_statvfs1 __sanitizer_syscall_pre_compat_90_statvfs1")
3123cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_post_statvfs1 __sanitizer_syscall_post_compat_90_statvfs1")
3133cab2bb3Spatrick  pcmd("")
3143cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_pre_fstatvfs1 __sanitizer_syscall_pre_compat_90_fstatvfs1")
3153cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_post_fstatvfs1 __sanitizer_syscall_post_compat_90_fstatvfs1")
3163cab2bb3Spatrick  pcmd("")
3173cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_pre___fhstatvfs140 __sanitizer_syscall_pre_compat_90_fhstatvfs1")
3183cab2bb3Spatrick  pcmd("#define __sanitizer_syscall_post___fhstatvfs140 __sanitizer_syscall_post_compat_90_fhstatvfs1")
3193cab2bb3Spatrick
3203cab2bb3Spatrick  pcmd("")
3213cab2bb3Spatrick  pcmd("#ifdef __cplusplus")
3223cab2bb3Spatrick  pcmd("extern \"C\" {")
3233cab2bb3Spatrick  pcmd("#endif")
3243cab2bb3Spatrick  pcmd("")
3253cab2bb3Spatrick  pcmd("// Private declarations. Do not call directly from user code. Use macros above.")
3263cab2bb3Spatrick  pcmd("")
3273cab2bb3Spatrick  pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
3283cab2bb3Spatrick  pcmd("")
3293cab2bb3Spatrick
3303cab2bb3Spatrick  for (i = 0; i < parsedsyscalls; i++) {
3313cab2bb3Spatrick
3323cab2bb3Spatrick    if (i in ifelifelseendif) {
3333cab2bb3Spatrick      pcmd(ifelifelseendif[i])
3343cab2bb3Spatrick    }
3353cab2bb3Spatrick
3363cab2bb3Spatrick    sn = syscalls[i]
3373cab2bb3Spatrick
3383cab2bb3Spatrick    if (sn ~ /^\$/) {
3393cab2bb3Spatrick      pcmd("/* syscall " substr(sn,2) " has been skipped */")
3403cab2bb3Spatrick      continue
3413cab2bb3Spatrick    }
3423cab2bb3Spatrick
3433cab2bb3Spatrick    preargs = syscallargs[i]
3443cab2bb3Spatrick
3453cab2bb3Spatrick    if (preargs != "void") {
3463cab2bb3Spatrick      preargs = "long long " preargs
3473cab2bb3Spatrick      gsub(/\$/, ", long long ", preargs)
3483cab2bb3Spatrick    }
3493cab2bb3Spatrick
3503cab2bb3Spatrick    if (preargs == "void") {
3513cab2bb3Spatrick      postargs = "long long res"
3523cab2bb3Spatrick    } else {
3533cab2bb3Spatrick      postargs = "long long res, " preargs
3543cab2bb3Spatrick    }
3553cab2bb3Spatrick
3563cab2bb3Spatrick    pcmd("void __sanitizer_syscall_pre_impl_" sn "(" preargs ");")
3573cab2bb3Spatrick    pcmd("void __sanitizer_syscall_post_impl_" sn "(" postargs ");")
3583cab2bb3Spatrick  }
3593cab2bb3Spatrick
3603cab2bb3Spatrick  pcmd("")
3613cab2bb3Spatrick  pcmd("#ifdef __cplusplus")
3623cab2bb3Spatrick  pcmd("} // extern \"C\"")
3633cab2bb3Spatrick  pcmd("#endif")
3643cab2bb3Spatrick
3653cab2bb3Spatrick  pcmd("")
3663cab2bb3Spatrick  pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
3673cab2bb3Spatrick  pcmd("")
3683cab2bb3Spatrick
3693cab2bb3Spatrick  pcmd("#endif  // SANITIZER_NETBSD_SYSCALL_HOOKS_H")
3703cab2bb3Spatrick
3713cab2bb3Spatrick  close(cmd)
3723cab2bb3Spatrick
3733cab2bb3Spatrick  # Generate sanitizer_syscalls_netbsd.inc
3743cab2bb3Spatrick
3753cab2bb3Spatrick  # open pipe
3763cab2bb3Spatrick  cmd = clangformat " > " outputinc
3773cab2bb3Spatrick
3783cab2bb3Spatrick  pcmd("//===-- sanitizer_syscalls_netbsd.inc ---------------------------*- C++ -*-===//")
3793cab2bb3Spatrick  pcmd("//")
3803cab2bb3Spatrick  pcmd("// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.")
3813cab2bb3Spatrick  pcmd("// See https://llvm.org/LICENSE.txt for license information.")
3823cab2bb3Spatrick  pcmd("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception")
3833cab2bb3Spatrick  pcmd("//")
3843cab2bb3Spatrick  pcmd("//===----------------------------------------------------------------------===//")
3853cab2bb3Spatrick  pcmd("//")
3863cab2bb3Spatrick  pcmd("// Common syscalls handlers for tools like AddressSanitizer,")
3873cab2bb3Spatrick  pcmd("// ThreadSanitizer, MemorySanitizer, etc.")
3883cab2bb3Spatrick  pcmd("//")
3893cab2bb3Spatrick  pcmd("// This file should be included into the tool's interceptor file,")
3903cab2bb3Spatrick  pcmd("// which has to define it's own macros:")
3913cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_PRE_READ_RANGE")
3923cab2bb3Spatrick  pcmd("//          Called in prehook for regions that will be read by the kernel and")
3933cab2bb3Spatrick  pcmd("//          must be initialized.")
3943cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_PRE_WRITE_RANGE")
3953cab2bb3Spatrick  pcmd("//          Called in prehook for regions that will be written to by the kernel")
3963cab2bb3Spatrick  pcmd("//          and must be addressable. The actual write range may be smaller than")
3973cab2bb3Spatrick  pcmd("//          reported in the prehook. See POST_WRITE_RANGE.")
3983cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_POST_READ_RANGE")
3993cab2bb3Spatrick  pcmd("//          Called in posthook for regions that were read by the kernel. Does")
4003cab2bb3Spatrick  pcmd("//          not make much sense.")
4013cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_POST_WRITE_RANGE")
4023cab2bb3Spatrick  pcmd("//          Called in posthook for regions that were written to by the kernel")
4033cab2bb3Spatrick  pcmd("//          and are now initialized.")
4043cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_ACQUIRE(addr)")
4053cab2bb3Spatrick  pcmd("//          Acquire memory visibility from addr.")
4063cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_RELEASE(addr)")
4073cab2bb3Spatrick  pcmd("//          Release memory visibility to addr.")
4083cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_FD_CLOSE(fd)")
4093cab2bb3Spatrick  pcmd("//          Called before closing file descriptor fd.")
4103cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_FD_ACQUIRE(fd)")
4113cab2bb3Spatrick  pcmd("//          Acquire memory visibility from fd.")
4123cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_FD_RELEASE(fd)")
4133cab2bb3Spatrick  pcmd("//          Release memory visibility to fd.")
4143cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_PRE_FORK()")
4153cab2bb3Spatrick  pcmd("//          Called before fork syscall.")
4163cab2bb3Spatrick  pcmd("//   COMMON_SYSCALL_POST_FORK(long long res)")
4173cab2bb3Spatrick  pcmd("//          Called after fork syscall.")
4183cab2bb3Spatrick  pcmd("//")
4193cab2bb3Spatrick  pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
4203cab2bb3Spatrick  pcmd("//")
4213cab2bb3Spatrick  pcmd("// Generated with: " script_name)
4223cab2bb3Spatrick  pcmd("// Generated date: " strftime("%F"))
4233cab2bb3Spatrick  pcmd("// Generated from: " syscallmasterversion)
4243cab2bb3Spatrick  pcmd("//")
4253cab2bb3Spatrick  pcmd("//===----------------------------------------------------------------------===//")
4263cab2bb3Spatrick  pcmd("")
4273cab2bb3Spatrick  pcmd("#include \"sanitizer_platform.h\"")
4283cab2bb3Spatrick  pcmd("#if SANITIZER_NETBSD")
4293cab2bb3Spatrick  pcmd("")
4303cab2bb3Spatrick  pcmd("#include \"sanitizer_libc.h\"")
4313cab2bb3Spatrick  pcmd("")
4323cab2bb3Spatrick  pcmd("#define PRE_SYSCALL(name)                                                      \\")
4333cab2bb3Spatrick  pcmd("  SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_pre_impl_##name")
4343cab2bb3Spatrick  pcmd("#define PRE_READ(p, s) COMMON_SYSCALL_PRE_READ_RANGE(p, s)")
4353cab2bb3Spatrick  pcmd("#define PRE_WRITE(p, s) COMMON_SYSCALL_PRE_WRITE_RANGE(p, s)")
4363cab2bb3Spatrick  pcmd("")
4373cab2bb3Spatrick  pcmd("#define POST_SYSCALL(name)                                                     \\")
4383cab2bb3Spatrick  pcmd("  SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_post_impl_##name")
4393cab2bb3Spatrick  pcmd("#define POST_READ(p, s) COMMON_SYSCALL_POST_READ_RANGE(p, s)")
4403cab2bb3Spatrick  pcmd("#define POST_WRITE(p, s) COMMON_SYSCALL_POST_WRITE_RANGE(p, s)")
4413cab2bb3Spatrick  pcmd("")
4423cab2bb3Spatrick  pcmd("#ifndef COMMON_SYSCALL_ACQUIRE")
4433cab2bb3Spatrick  pcmd("# define COMMON_SYSCALL_ACQUIRE(addr) ((void)(addr))")
4443cab2bb3Spatrick  pcmd("#endif")
4453cab2bb3Spatrick  pcmd("")
4463cab2bb3Spatrick  pcmd("#ifndef COMMON_SYSCALL_RELEASE")
4473cab2bb3Spatrick  pcmd("# define COMMON_SYSCALL_RELEASE(addr) ((void)(addr))")
4483cab2bb3Spatrick  pcmd("#endif")
4493cab2bb3Spatrick  pcmd("")
4503cab2bb3Spatrick  pcmd("#ifndef COMMON_SYSCALL_FD_CLOSE")
4513cab2bb3Spatrick  pcmd("# define COMMON_SYSCALL_FD_CLOSE(fd) ((void)(fd))")
4523cab2bb3Spatrick  pcmd("#endif")
4533cab2bb3Spatrick  pcmd("")
4543cab2bb3Spatrick  pcmd("#ifndef COMMON_SYSCALL_FD_ACQUIRE")
4553cab2bb3Spatrick  pcmd("# define COMMON_SYSCALL_FD_ACQUIRE(fd) ((void)(fd))")
4563cab2bb3Spatrick  pcmd("#endif")
4573cab2bb3Spatrick  pcmd("")
4583cab2bb3Spatrick  pcmd("#ifndef COMMON_SYSCALL_FD_RELEASE")
4593cab2bb3Spatrick  pcmd("# define COMMON_SYSCALL_FD_RELEASE(fd) ((void)(fd))")
4603cab2bb3Spatrick  pcmd("#endif")
4613cab2bb3Spatrick  pcmd("")
4623cab2bb3Spatrick  pcmd("#ifndef COMMON_SYSCALL_PRE_FORK")
4633cab2bb3Spatrick  pcmd("# define COMMON_SYSCALL_PRE_FORK() {}")
4643cab2bb3Spatrick  pcmd("#endif")
4653cab2bb3Spatrick  pcmd("")
4663cab2bb3Spatrick  pcmd("#ifndef COMMON_SYSCALL_POST_FORK")
4673cab2bb3Spatrick  pcmd("# define COMMON_SYSCALL_POST_FORK(res) {}")
4683cab2bb3Spatrick  pcmd("#endif")
4693cab2bb3Spatrick  pcmd("")
4703cab2bb3Spatrick  pcmd("// FIXME: do some kind of PRE_READ for all syscall arguments (int(s) and such).")
4713cab2bb3Spatrick  pcmd("")
4723cab2bb3Spatrick  pcmd("extern \"C\" {")
4733cab2bb3Spatrick  pcmd("#define SYS_MAXSYSARGS " SYS_MAXSYSARGS)
4743cab2bb3Spatrick
4753cab2bb3Spatrick  for (i = 0; i < parsedsyscalls; i++) {
4763cab2bb3Spatrick
4773cab2bb3Spatrick    if (i in ifelifelseendif) {
4783cab2bb3Spatrick      pcmd(ifelifelseendif[i])
4793cab2bb3Spatrick    }
4803cab2bb3Spatrick
4813cab2bb3Spatrick    sn = syscalls[i]
4823cab2bb3Spatrick
4833cab2bb3Spatrick    if (sn ~ /^\$/) {
4843cab2bb3Spatrick      pcmd("/* syscall " substr(sn,2) " has been skipped */")
4853cab2bb3Spatrick      continue
4863cab2bb3Spatrick    }
4873cab2bb3Spatrick
4883cab2bb3Spatrick    preargs = syscallfullargs[i]
4893cab2bb3Spatrick
4903cab2bb3Spatrick    if (preargs != "void") {
4913cab2bb3Spatrick      preargs = "long long " preargs
4923cab2bb3Spatrick      gsub(/\$/, ", long long ", preargs)
4933cab2bb3Spatrick      gsub(/long long \*/, "void *", preargs)
4943cab2bb3Spatrick    }
4953cab2bb3Spatrick
4963cab2bb3Spatrick    if (preargs == "void") {
4973cab2bb3Spatrick      postargs = "long long res"
4983cab2bb3Spatrick    } else {
4993cab2bb3Spatrick      postargs = "long long res, " preargs
5003cab2bb3Spatrick    }
5013cab2bb3Spatrick
5023cab2bb3Spatrick    pcmd("PRE_SYSCALL(" sn ")(" preargs ")")
5033cab2bb3Spatrick    pcmd("{")
5043cab2bb3Spatrick    syscall_body(sn, "pre")
5053cab2bb3Spatrick    pcmd("}")
5063cab2bb3Spatrick
5073cab2bb3Spatrick    pcmd("POST_SYSCALL(" sn ")(" postargs ")")
5083cab2bb3Spatrick    pcmd("{")
5093cab2bb3Spatrick    syscall_body(sn, "post")
5103cab2bb3Spatrick    pcmd("}")
5113cab2bb3Spatrick  }
5123cab2bb3Spatrick
5133cab2bb3Spatrick  pcmd("#undef SYS_MAXSYSARGS")
5143cab2bb3Spatrick  pcmd("}  // extern \"C\"")
5153cab2bb3Spatrick  pcmd("")
5163cab2bb3Spatrick  pcmd("#undef PRE_SYSCALL")
5173cab2bb3Spatrick  pcmd("#undef PRE_READ")
5183cab2bb3Spatrick  pcmd("#undef PRE_WRITE")
5193cab2bb3Spatrick  pcmd("#undef POST_SYSCALL")
5203cab2bb3Spatrick  pcmd("#undef POST_READ")
5213cab2bb3Spatrick  pcmd("#undef POST_WRITE")
5223cab2bb3Spatrick  pcmd("")
5233cab2bb3Spatrick  pcmd("#endif  // SANITIZER_NETBSD")
5243cab2bb3Spatrick
5253cab2bb3Spatrick  close(cmd)
5263cab2bb3Spatrick
5273cab2bb3Spatrick  # Hack for preprocessed code
5283cab2bb3Spatrick  system("sed -i 's,^ \\([^ ]\\),  \\1,' " outputinc)
5293cab2bb3Spatrick}
5303cab2bb3Spatrick
5313cab2bb3Spatrickfunction usage()
5323cab2bb3Spatrick{
5333cab2bb3Spatrick  print "Usage: " script_name " syscalls.master"
5343cab2bb3Spatrick  abnormal_exit = 1
5353cab2bb3Spatrick  exit 1
5363cab2bb3Spatrick}
5373cab2bb3Spatrick
5383cab2bb3Spatrickfunction pcmd(string)
5393cab2bb3Spatrick{
5403cab2bb3Spatrick  print string | cmd
5413cab2bb3Spatrick}
5423cab2bb3Spatrick
5433cab2bb3Spatrickfunction syscall_body(syscall, mode)
5443cab2bb3Spatrick{
5453cab2bb3Spatrick  # Hardcode sanitizing rules here
5463cab2bb3Spatrick  # These syscalls don't change often so they are hand coded
5473cab2bb3Spatrick  if (syscall == "syscall") {
5483cab2bb3Spatrick    pcmd("/* Nothing to do */")
5493cab2bb3Spatrick  } else if (syscall == "exit") {
5503cab2bb3Spatrick    pcmd("/* Nothing to do */")
5513cab2bb3Spatrick  } else if (syscall == "fork") {
5523cab2bb3Spatrick    if (mode == "pre") {
5533cab2bb3Spatrick      pcmd("COMMON_SYSCALL_PRE_FORK();")
5543cab2bb3Spatrick    } else {
5553cab2bb3Spatrick      pcmd("COMMON_SYSCALL_POST_FORK(res);")
5563cab2bb3Spatrick    }
5573cab2bb3Spatrick  } else if (syscall == "read") {
5583cab2bb3Spatrick    if (mode == "pre") {
5593cab2bb3Spatrick      pcmd("if (buf_) {")
5603cab2bb3Spatrick      pcmd("  PRE_WRITE(buf_, nbyte_);")
5613cab2bb3Spatrick      pcmd("}")
5623cab2bb3Spatrick    } else {
5633cab2bb3Spatrick      pcmd("if (res > 0) {")
5643cab2bb3Spatrick      pcmd("  POST_WRITE(buf_, res);")
5653cab2bb3Spatrick      pcmd("}")
5663cab2bb3Spatrick    }
5673cab2bb3Spatrick  } else if (syscall == "write") {
5683cab2bb3Spatrick    if (mode == "pre") {
5693cab2bb3Spatrick      pcmd("if (buf_) {")
5703cab2bb3Spatrick      pcmd("  PRE_READ(buf_, nbyte_);")
5713cab2bb3Spatrick      pcmd("}")
5723cab2bb3Spatrick    } else {
5733cab2bb3Spatrick      pcmd("if (res > 0) {")
5743cab2bb3Spatrick      pcmd("  POST_READ(buf_, res);")
5753cab2bb3Spatrick      pcmd("}")
5763cab2bb3Spatrick    }
5773cab2bb3Spatrick  } else if (syscall == "open") {
5783cab2bb3Spatrick    if (mode == "pre") {
5793cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
5803cab2bb3Spatrick      pcmd("if (path) {")
5813cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
5823cab2bb3Spatrick      pcmd("}")
5833cab2bb3Spatrick    } else {
5843cab2bb3Spatrick      pcmd("if (res > 0) {")
5853cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
5863cab2bb3Spatrick      pcmd("  if (path) {")
5873cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
5883cab2bb3Spatrick      pcmd("  }")
5893cab2bb3Spatrick      pcmd("}")
5903cab2bb3Spatrick    }
5913cab2bb3Spatrick  } else if (syscall == "close") {
5923cab2bb3Spatrick    if (mode == "pre") {
5933cab2bb3Spatrick      pcmd("COMMON_SYSCALL_FD_CLOSE((int)fd_);")
5943cab2bb3Spatrick    } else {
5953cab2bb3Spatrick      pcmd("/* Nothing to do */")
5963cab2bb3Spatrick    }
5973cab2bb3Spatrick  } else if (syscall == "compat_50_wait4") {
5983cab2bb3Spatrick    pcmd("/* TODO */")
5993cab2bb3Spatrick  } else if (syscall == "compat_43_ocreat") {
6003cab2bb3Spatrick    pcmd("/* TODO */")
6013cab2bb3Spatrick  } else if (syscall == "link") {
6023cab2bb3Spatrick    if (mode == "pre") {
6033cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
6043cab2bb3Spatrick      pcmd("const char *link = (const char *)link_;")
6053cab2bb3Spatrick      pcmd("if (path) {")
6063cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
6073cab2bb3Spatrick      pcmd("}")
6083cab2bb3Spatrick      pcmd("if (link) {")
6093cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(link) + 1);")
6103cab2bb3Spatrick      pcmd("}")
6113cab2bb3Spatrick    } else {
6123cab2bb3Spatrick      pcmd("if (res == 0) {")
6133cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
6143cab2bb3Spatrick      pcmd("  const char *link = (const char *)link_;")
6153cab2bb3Spatrick      pcmd("  if (path) {")
6163cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
6173cab2bb3Spatrick      pcmd("  }")
6183cab2bb3Spatrick      pcmd("  if (link) {")
6193cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(link) + 1);")
6203cab2bb3Spatrick      pcmd("  }")
6213cab2bb3Spatrick      pcmd("}")
6223cab2bb3Spatrick    }
6233cab2bb3Spatrick  } else if (syscall == "unlink") {
6243cab2bb3Spatrick    if (mode == "pre") {
6253cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
6263cab2bb3Spatrick      pcmd("if (path) {")
6273cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
6283cab2bb3Spatrick      pcmd("}")
6293cab2bb3Spatrick    } else {
6303cab2bb3Spatrick      pcmd("if (res == 0) {")
6313cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
6323cab2bb3Spatrick      pcmd("  if (path) {")
6333cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
6343cab2bb3Spatrick      pcmd("  }")
6353cab2bb3Spatrick      pcmd("}")
6363cab2bb3Spatrick    }
6373cab2bb3Spatrick  } else if (syscall == "chdir") {
6383cab2bb3Spatrick    if (mode == "pre") {
6393cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
6403cab2bb3Spatrick      pcmd("if (path) {")
6413cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
6423cab2bb3Spatrick      pcmd("}")
6433cab2bb3Spatrick    } else {
6443cab2bb3Spatrick      pcmd("if (res == 0) {")
6453cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
6463cab2bb3Spatrick      pcmd("  if (path) {")
6473cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
6483cab2bb3Spatrick      pcmd("  }")
6493cab2bb3Spatrick      pcmd("}")
6503cab2bb3Spatrick    }
6513cab2bb3Spatrick  } else if (syscall == "fchdir") {
6523cab2bb3Spatrick    pcmd("/* Nothing to do */")
6533cab2bb3Spatrick  } else if (syscall == "compat_50_mknod") {
6543cab2bb3Spatrick    pcmd("/* TODO */")
6553cab2bb3Spatrick  } else if (syscall == "chmod") {
6563cab2bb3Spatrick    if (mode == "pre") {
6573cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
6583cab2bb3Spatrick      pcmd("if (path) {")
6593cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
6603cab2bb3Spatrick      pcmd("}")
6613cab2bb3Spatrick    } else {
6623cab2bb3Spatrick      pcmd("if (res == 0) {")
6633cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
6643cab2bb3Spatrick      pcmd("  if (path) {")
6653cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
6663cab2bb3Spatrick      pcmd("  }")
6673cab2bb3Spatrick      pcmd("}")
6683cab2bb3Spatrick    }
6693cab2bb3Spatrick  } else if (syscall == "chown") {
6703cab2bb3Spatrick    if (mode == "pre") {
6713cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
6723cab2bb3Spatrick      pcmd("if (path) {")
6733cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
6743cab2bb3Spatrick      pcmd("}")
6753cab2bb3Spatrick    } else {
6763cab2bb3Spatrick      pcmd("if (res == 0) {")
6773cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
6783cab2bb3Spatrick      pcmd("  if (path) {")
6793cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
6803cab2bb3Spatrick      pcmd("  }")
6813cab2bb3Spatrick      pcmd("}")
6823cab2bb3Spatrick    }
6833cab2bb3Spatrick  } else if (syscall == "break") {
6843cab2bb3Spatrick    pcmd("/* Nothing to do */")
6853cab2bb3Spatrick  } else if (syscall == "compat_20_getfsstat") {
6863cab2bb3Spatrick    pcmd("/* TODO */")
6873cab2bb3Spatrick  } else if (syscall == "compat_43_olseek") {
6883cab2bb3Spatrick    pcmd("/* TODO */")
6893cab2bb3Spatrick  } else if (syscall == "getpid") {
6903cab2bb3Spatrick    pcmd("/* Nothing to do */")
6913cab2bb3Spatrick  } else if (syscall == "compat_40_mount") {
6923cab2bb3Spatrick    pcmd("/* TODO */")
6933cab2bb3Spatrick  } else if (syscall == "unmount") {
6943cab2bb3Spatrick    if (mode == "pre") {
6953cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
6963cab2bb3Spatrick      pcmd("if (path) {")
6973cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
6983cab2bb3Spatrick      pcmd("}")
6993cab2bb3Spatrick    } else {
7003cab2bb3Spatrick      pcmd("if (res == 0) {")
7013cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
7023cab2bb3Spatrick      pcmd("  if (path) {")
7033cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
7043cab2bb3Spatrick      pcmd("  }")
7053cab2bb3Spatrick      pcmd("}")
7063cab2bb3Spatrick    }
7073cab2bb3Spatrick  } else if (syscall == "setuid") {
7083cab2bb3Spatrick    pcmd("/* Nothing to do */")
7093cab2bb3Spatrick  } else if (syscall == "getuid") {
7103cab2bb3Spatrick    pcmd("/* Nothing to do */")
7113cab2bb3Spatrick  } else if (syscall == "geteuid") {
7123cab2bb3Spatrick    pcmd("/* Nothing to do */")
7133cab2bb3Spatrick  } else if (syscall == "ptrace") {
7143cab2bb3Spatrick    if (mode == "pre") {
7153cab2bb3Spatrick      pcmd("if (req_ == ptrace_pt_io) {")
7163cab2bb3Spatrick      pcmd("  struct __sanitizer_ptrace_io_desc *addr = (struct __sanitizer_ptrace_io_desc *)addr_;")
7173cab2bb3Spatrick      pcmd("  PRE_READ(addr, struct_ptrace_ptrace_io_desc_struct_sz);")
7183cab2bb3Spatrick      pcmd("  if (addr->piod_op == ptrace_piod_write_d || addr->piod_op == ptrace_piod_write_i) {")
7193cab2bb3Spatrick      pcmd("    PRE_READ(addr->piod_addr, addr->piod_len);")
7203cab2bb3Spatrick      pcmd("  }")
7213cab2bb3Spatrick      pcmd("  if (addr->piod_op == ptrace_piod_read_d || addr->piod_op == ptrace_piod_read_i || addr->piod_op == ptrace_piod_read_auxv) {")
7223cab2bb3Spatrick      pcmd("    PRE_WRITE(addr->piod_addr, addr->piod_len);")
7233cab2bb3Spatrick      pcmd("  }")
7243cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_lwpinfo) {")
7253cab2bb3Spatrick      pcmd("  struct __sanitizer_ptrace_lwpinfo *addr = (struct __sanitizer_ptrace_lwpinfo *)addr_;")
7263cab2bb3Spatrick      pcmd("  PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
7273cab2bb3Spatrick      pcmd("  PRE_WRITE(addr, struct_ptrace_ptrace_lwpinfo_struct_sz);")
7283cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_set_event_mask) {")
7293cab2bb3Spatrick      pcmd("  PRE_READ(addr_, struct_ptrace_ptrace_event_struct_sz);")
7303cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_get_event_mask) {")
7313cab2bb3Spatrick      pcmd("  PRE_WRITE(addr_, struct_ptrace_ptrace_event_struct_sz);")
7323cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_set_siginfo) {")
7333cab2bb3Spatrick      pcmd("  PRE_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
7343cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_get_siginfo) {")
7353cab2bb3Spatrick      pcmd("  PRE_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
7363cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_lwpstatus) {")
7373cab2bb3Spatrick      pcmd("  struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
7383cab2bb3Spatrick      pcmd("  PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
7393cab2bb3Spatrick      pcmd("  PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
7403cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_lwpnext) {")
7413cab2bb3Spatrick      pcmd("  struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
7423cab2bb3Spatrick      pcmd("  PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
7433cab2bb3Spatrick      pcmd("  PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
7443cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_setregs) {")
7453cab2bb3Spatrick      pcmd("  PRE_READ(addr_, struct_ptrace_reg_struct_sz);")
7463cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_getregs) {")
7473cab2bb3Spatrick      pcmd("  PRE_WRITE(addr_, struct_ptrace_reg_struct_sz);")
7483cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_setfpregs) {")
7493cab2bb3Spatrick      pcmd("  PRE_READ(addr_, struct_ptrace_fpreg_struct_sz);")
7503cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_getfpregs) {")
7513cab2bb3Spatrick      pcmd("  PRE_WRITE(addr_, struct_ptrace_fpreg_struct_sz);")
7523cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_setdbregs) {")
7533cab2bb3Spatrick      pcmd("  PRE_READ(addr_, struct_ptrace_dbreg_struct_sz);")
7543cab2bb3Spatrick      pcmd("} else if (req_ == ptrace_pt_getdbregs) {")
7553cab2bb3Spatrick      pcmd("  PRE_WRITE(addr_, struct_ptrace_dbreg_struct_sz);")
7563cab2bb3Spatrick      pcmd("}")
7573cab2bb3Spatrick    } else {
7583cab2bb3Spatrick      pcmd("if (res == 0) {")
7593cab2bb3Spatrick      pcmd("  if (req_ == ptrace_pt_io) {")
7603cab2bb3Spatrick      pcmd("    struct __sanitizer_ptrace_io_desc *addr = (struct __sanitizer_ptrace_io_desc *)addr_;")
7613cab2bb3Spatrick      pcmd("    POST_READ(addr, struct_ptrace_ptrace_io_desc_struct_sz);")
7623cab2bb3Spatrick      pcmd("    if (addr->piod_op == ptrace_piod_write_d || addr->piod_op == ptrace_piod_write_i) {")
7633cab2bb3Spatrick      pcmd("      POST_READ(addr->piod_addr, addr->piod_len);")
7643cab2bb3Spatrick      pcmd("    }")
7653cab2bb3Spatrick      pcmd("    if (addr->piod_op == ptrace_piod_read_d || addr->piod_op == ptrace_piod_read_i || addr->piod_op == ptrace_piod_read_auxv) {")
7663cab2bb3Spatrick      pcmd("      POST_WRITE(addr->piod_addr, addr->piod_len);")
7673cab2bb3Spatrick      pcmd("    }")
7683cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_lwpinfo) {")
7693cab2bb3Spatrick      pcmd("    struct __sanitizer_ptrace_lwpinfo *addr = (struct __sanitizer_ptrace_lwpinfo *)addr_;")
7703cab2bb3Spatrick      pcmd("    POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
7713cab2bb3Spatrick      pcmd("    POST_WRITE(addr, struct_ptrace_ptrace_lwpinfo_struct_sz);")
7723cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_set_event_mask) {")
7733cab2bb3Spatrick      pcmd("    POST_READ(addr_, struct_ptrace_ptrace_event_struct_sz);")
7743cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_get_event_mask) {")
7753cab2bb3Spatrick      pcmd("    POST_WRITE(addr_, struct_ptrace_ptrace_event_struct_sz);")
7763cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_set_siginfo) {")
7773cab2bb3Spatrick      pcmd("    POST_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
7783cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_get_siginfo) {")
7793cab2bb3Spatrick      pcmd("    POST_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
7803cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_lwpstatus) {")
7813cab2bb3Spatrick      pcmd("    struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
7823cab2bb3Spatrick      pcmd("    POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
7833cab2bb3Spatrick      pcmd("    POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
7843cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_lwpnext) {")
7853cab2bb3Spatrick      pcmd("    struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
7863cab2bb3Spatrick      pcmd("    POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
7873cab2bb3Spatrick      pcmd("    POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
7883cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_setregs) {")
7893cab2bb3Spatrick      pcmd("    POST_READ(addr_, struct_ptrace_reg_struct_sz);")
7903cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_getregs) {")
7913cab2bb3Spatrick      pcmd("    POST_WRITE(addr_, struct_ptrace_reg_struct_sz);")
7923cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_setfpregs) {")
7933cab2bb3Spatrick      pcmd("    POST_READ(addr_, struct_ptrace_fpreg_struct_sz);")
7943cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_getfpregs) {")
7953cab2bb3Spatrick      pcmd("    POST_WRITE(addr_, struct_ptrace_fpreg_struct_sz);")
7963cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_setdbregs) {")
7973cab2bb3Spatrick      pcmd("    POST_READ(addr_, struct_ptrace_dbreg_struct_sz);")
7983cab2bb3Spatrick      pcmd("  } else if (req_ == ptrace_pt_getdbregs) {")
7993cab2bb3Spatrick      pcmd("    POST_WRITE(addr_, struct_ptrace_dbreg_struct_sz);")
8003cab2bb3Spatrick      pcmd("  }")
8013cab2bb3Spatrick      pcmd("}")
8023cab2bb3Spatrick    }
8033cab2bb3Spatrick  } else if (syscall == "recvmsg") {
8043cab2bb3Spatrick    if (mode == "pre") {
8053cab2bb3Spatrick      pcmd("PRE_WRITE(msg_, sizeof(__sanitizer_msghdr));")
8063cab2bb3Spatrick    } else {
8073cab2bb3Spatrick      pcmd("if (res > 0) {")
8083cab2bb3Spatrick      pcmd("  POST_WRITE(msg_, sizeof(__sanitizer_msghdr));")
8093cab2bb3Spatrick      pcmd("}")
8103cab2bb3Spatrick    }
8113cab2bb3Spatrick  } else if (syscall == "sendmsg") {
8123cab2bb3Spatrick    if (mode == "pre") {
8133cab2bb3Spatrick      pcmd("PRE_READ(msg_, sizeof(__sanitizer_msghdr));")
8143cab2bb3Spatrick    } else {
8153cab2bb3Spatrick      pcmd("if (res > 0) {")
8163cab2bb3Spatrick      pcmd("  POST_READ(msg_, sizeof(__sanitizer_msghdr));")
8173cab2bb3Spatrick      pcmd("}")
8183cab2bb3Spatrick    }
8193cab2bb3Spatrick  } else if (syscall == "recvfrom") {
8203cab2bb3Spatrick    if (mode == "pre") {
8213cab2bb3Spatrick      pcmd("PRE_WRITE(buf_, len_);")
8223cab2bb3Spatrick      pcmd("PRE_WRITE(from_, struct_sockaddr_sz);")
8233cab2bb3Spatrick      pcmd("PRE_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));")
8243cab2bb3Spatrick    } else {
8253cab2bb3Spatrick      pcmd("if (res >= 0) {")
8263cab2bb3Spatrick      pcmd("  POST_WRITE(buf_, res);")
8273cab2bb3Spatrick      pcmd("  POST_WRITE(from_, struct_sockaddr_sz);")
8283cab2bb3Spatrick      pcmd("  POST_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));")
8293cab2bb3Spatrick      pcmd("}")
8303cab2bb3Spatrick    }
8313cab2bb3Spatrick  } else if (syscall == "accept") {
8323cab2bb3Spatrick    if (mode == "pre") {
8333cab2bb3Spatrick      pcmd("PRE_WRITE(name_, struct_sockaddr_sz);")
8343cab2bb3Spatrick      pcmd("PRE_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));")
8353cab2bb3Spatrick    } else {
8363cab2bb3Spatrick      pcmd("if (res == 0) {")
8373cab2bb3Spatrick      pcmd("  POST_WRITE(name_, struct_sockaddr_sz);")
8383cab2bb3Spatrick      pcmd("  POST_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));")
8393cab2bb3Spatrick      pcmd("}")
8403cab2bb3Spatrick    }
8413cab2bb3Spatrick  } else if (syscall == "getpeername") {
8423cab2bb3Spatrick    if (mode == "pre") {
8433cab2bb3Spatrick      pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);")
8443cab2bb3Spatrick      pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
8453cab2bb3Spatrick    } else {
8463cab2bb3Spatrick      pcmd("if (res == 0) {")
8473cab2bb3Spatrick      pcmd("  POST_WRITE(asa_, struct_sockaddr_sz);")
8483cab2bb3Spatrick      pcmd("  POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
8493cab2bb3Spatrick      pcmd("}")
8503cab2bb3Spatrick    }
8513cab2bb3Spatrick  } else if (syscall == "getsockname") {
8523cab2bb3Spatrick    if (mode == "pre") {
8533cab2bb3Spatrick      pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);")
8543cab2bb3Spatrick      pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
8553cab2bb3Spatrick    } else {
8563cab2bb3Spatrick      pcmd("if (res == 0) {")
8573cab2bb3Spatrick      pcmd("  POST_WRITE(asa_, struct_sockaddr_sz);")
8583cab2bb3Spatrick      pcmd("  POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
8593cab2bb3Spatrick      pcmd("}")
8603cab2bb3Spatrick    }
8613cab2bb3Spatrick  } else if (syscall == "access") {
8623cab2bb3Spatrick    if (mode == "pre") {
8633cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
8643cab2bb3Spatrick      pcmd("if (path) {")
8653cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
8663cab2bb3Spatrick      pcmd("}")
8673cab2bb3Spatrick    } else {
8683cab2bb3Spatrick      pcmd("if (res == 0) {")
8693cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
8703cab2bb3Spatrick      pcmd("  if (path) {")
8713cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
8723cab2bb3Spatrick      pcmd("  }")
8733cab2bb3Spatrick      pcmd("}")
8743cab2bb3Spatrick    }
8753cab2bb3Spatrick  } else if (syscall == "chflags") {
8763cab2bb3Spatrick    if (mode == "pre") {
8773cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
8783cab2bb3Spatrick      pcmd("if (path) {")
8793cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
8803cab2bb3Spatrick      pcmd("}")
8813cab2bb3Spatrick    } else {
8823cab2bb3Spatrick      pcmd("if (res == 0) {")
8833cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
8843cab2bb3Spatrick      pcmd("  if (path) {")
8853cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
8863cab2bb3Spatrick      pcmd("  }")
8873cab2bb3Spatrick      pcmd("}")
8883cab2bb3Spatrick    }
8893cab2bb3Spatrick  } else if (syscall == "fchflags") {
8903cab2bb3Spatrick    pcmd("/* Nothing to do */")
8913cab2bb3Spatrick  } else if (syscall == "sync") {
8923cab2bb3Spatrick    pcmd("/* Nothing to do */")
8933cab2bb3Spatrick  } else if (syscall == "kill") {
8943cab2bb3Spatrick    pcmd("/* Nothing to do */")
8953cab2bb3Spatrick  } else if (syscall == "compat_43_stat43") {
8963cab2bb3Spatrick    pcmd("/* TODO */")
8973cab2bb3Spatrick  } else if (syscall == "getppid") {
8983cab2bb3Spatrick    pcmd("/* Nothing to do */")
8993cab2bb3Spatrick  } else if (syscall == "compat_43_lstat43") {
9003cab2bb3Spatrick    pcmd("/* TODO */")
9013cab2bb3Spatrick  } else if (syscall == "dup") {
9023cab2bb3Spatrick    pcmd("/* Nothing to do */")
9033cab2bb3Spatrick  } else if (syscall == "pipe") {
9043cab2bb3Spatrick    pcmd("/* pipe returns two descriptors through two returned values */")
9053cab2bb3Spatrick  } else if (syscall == "getegid") {
9063cab2bb3Spatrick    pcmd("/* Nothing to do */")
9073cab2bb3Spatrick  } else if (syscall == "profil") {
9083cab2bb3Spatrick    if (mode == "pre") {
9093cab2bb3Spatrick      pcmd("if (samples_) {")
9103cab2bb3Spatrick      pcmd("  PRE_WRITE(samples_, size_);")
9113cab2bb3Spatrick      pcmd("}")
9123cab2bb3Spatrick    } else {
9133cab2bb3Spatrick      pcmd("if (res == 0) {")
9143cab2bb3Spatrick      pcmd("  if (samples_) {")
9153cab2bb3Spatrick      pcmd("    POST_WRITE(samples_, size_);")
9163cab2bb3Spatrick      pcmd("  }")
9173cab2bb3Spatrick      pcmd("}")
9183cab2bb3Spatrick    }
9193cab2bb3Spatrick  } else if (syscall == "ktrace") {
9203cab2bb3Spatrick    if (mode == "pre") {
9213cab2bb3Spatrick      pcmd("const char *fname = (const char *)fname_;")
9223cab2bb3Spatrick      pcmd("if (fname) {")
9233cab2bb3Spatrick      pcmd("  PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
9243cab2bb3Spatrick      pcmd("}")
9253cab2bb3Spatrick    } else {
9263cab2bb3Spatrick      pcmd("const char *fname = (const char *)fname_;")
9273cab2bb3Spatrick      pcmd("if (res == 0) {")
9283cab2bb3Spatrick      pcmd("  if (fname) {")
9293cab2bb3Spatrick      pcmd("    POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
9303cab2bb3Spatrick      pcmd("  }")
9313cab2bb3Spatrick      pcmd("}")
9323cab2bb3Spatrick    }
9333cab2bb3Spatrick  } else if (syscall == "compat_13_sigaction13") {
9343cab2bb3Spatrick    pcmd("/* TODO */")
9353cab2bb3Spatrick  } else if (syscall == "getgid") {
9363cab2bb3Spatrick    pcmd("/* Nothing to do */")
9373cab2bb3Spatrick  } else if (syscall == "compat_13_sigprocmask13") {
9383cab2bb3Spatrick    pcmd("/* TODO */")
9393cab2bb3Spatrick  } else if (syscall == "__getlogin") {
9403cab2bb3Spatrick    if (mode == "pre") {
9413cab2bb3Spatrick      pcmd("if (namebuf_) {")
9423cab2bb3Spatrick      pcmd("  PRE_WRITE(namebuf_, namelen_);")
9433cab2bb3Spatrick      pcmd("}")
9443cab2bb3Spatrick    } else {
9453cab2bb3Spatrick      pcmd("if (res == 0) {")
9463cab2bb3Spatrick      pcmd("  if (namebuf_) {")
9473cab2bb3Spatrick      pcmd("    POST_WRITE(namebuf_, namelen_);")
9483cab2bb3Spatrick      pcmd("  }")
9493cab2bb3Spatrick      pcmd("}")
9503cab2bb3Spatrick    }
9513cab2bb3Spatrick  } else if (syscall == "__setlogin") {
9523cab2bb3Spatrick    if (mode == "pre") {
9533cab2bb3Spatrick      pcmd("const char *namebuf = (const char *)namebuf_;")
9543cab2bb3Spatrick      pcmd("if (namebuf) {")
9553cab2bb3Spatrick      pcmd("  PRE_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);")
9563cab2bb3Spatrick      pcmd("}")
9573cab2bb3Spatrick    } else {
9583cab2bb3Spatrick      pcmd("if (res == 0) {")
9593cab2bb3Spatrick      pcmd("  const char *namebuf = (const char *)namebuf_;")
9603cab2bb3Spatrick      pcmd("  if (namebuf) {")
9613cab2bb3Spatrick      pcmd("    POST_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);")
9623cab2bb3Spatrick      pcmd("  }")
9633cab2bb3Spatrick      pcmd("}")
9643cab2bb3Spatrick    }
9653cab2bb3Spatrick  } else if (syscall == "acct") {
9663cab2bb3Spatrick    if (mode == "pre") {
9673cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
9683cab2bb3Spatrick      pcmd("if (path) {")
9693cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
9703cab2bb3Spatrick      pcmd("}")
9713cab2bb3Spatrick    } else {
9723cab2bb3Spatrick      pcmd("if (res == 0) {")
9733cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
9743cab2bb3Spatrick      pcmd("  if (path) {")
9753cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
9763cab2bb3Spatrick      pcmd("  }")
9773cab2bb3Spatrick      pcmd("}")
9783cab2bb3Spatrick    }
9793cab2bb3Spatrick  } else if (syscall == "compat_13_sigpending13") {
9803cab2bb3Spatrick    pcmd("/* TODO */")
9813cab2bb3Spatrick  } else if (syscall == "compat_13_sigaltstack13") {
9823cab2bb3Spatrick    pcmd("/* TODO */")
9833cab2bb3Spatrick  } else if (syscall == "ioctl") {
9843cab2bb3Spatrick    pcmd("/* Nothing to do */")
9853cab2bb3Spatrick  } else if (syscall == "compat_12_oreboot") {
9863cab2bb3Spatrick    pcmd("/* TODO */")
9873cab2bb3Spatrick  } else if (syscall == "revoke") {
9883cab2bb3Spatrick    if (mode == "pre") {
9893cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
9903cab2bb3Spatrick      pcmd("if (path) {")
9913cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
9923cab2bb3Spatrick      pcmd("}")
9933cab2bb3Spatrick    } else {
9943cab2bb3Spatrick      pcmd("if (res == 0) {")
9953cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
9963cab2bb3Spatrick      pcmd("  if (path) {")
9973cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
9983cab2bb3Spatrick      pcmd("  }")
9993cab2bb3Spatrick      pcmd("}")
10003cab2bb3Spatrick    }
10013cab2bb3Spatrick  } else if (syscall == "symlink") {
10023cab2bb3Spatrick    if (mode == "pre") {
10033cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
10043cab2bb3Spatrick      pcmd("const char *link = (const char *)link_;")
10053cab2bb3Spatrick      pcmd("if (path) {")
10063cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
10073cab2bb3Spatrick      pcmd("}")
10083cab2bb3Spatrick      pcmd("if (link) {")
10093cab2bb3Spatrick      pcmd("  PRE_READ(link, __sanitizer::internal_strlen(link) + 1);")
10103cab2bb3Spatrick      pcmd("}")
10113cab2bb3Spatrick    } else {
10123cab2bb3Spatrick      pcmd("if (res == 0) {")
10133cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
10143cab2bb3Spatrick      pcmd("  const char *link = (const char *)link_;")
10153cab2bb3Spatrick      pcmd("  if (path) {")
10163cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
10173cab2bb3Spatrick      pcmd("  }")
10183cab2bb3Spatrick      pcmd("  if (link) {")
10193cab2bb3Spatrick      pcmd("    POST_READ(link, __sanitizer::internal_strlen(link) + 1);")
10203cab2bb3Spatrick      pcmd("  }")
10213cab2bb3Spatrick      pcmd("}")
10223cab2bb3Spatrick    }
10233cab2bb3Spatrick  } else if (syscall == "readlink") {
10243cab2bb3Spatrick    if (mode == "pre") {
10253cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
10263cab2bb3Spatrick      pcmd("if (path) {")
10273cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
10283cab2bb3Spatrick      pcmd("}")
10293cab2bb3Spatrick      pcmd("if (buf_) {")
10303cab2bb3Spatrick      pcmd("  PRE_WRITE(buf_, count_);")
10313cab2bb3Spatrick      pcmd("}")
10323cab2bb3Spatrick    } else {
10333cab2bb3Spatrick      pcmd("if (res > 0) {")
10343cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
10353cab2bb3Spatrick      pcmd("  if (path) {")
10363cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
10373cab2bb3Spatrick      pcmd("  }")
10383cab2bb3Spatrick      pcmd("  if (buf_) {")
10393cab2bb3Spatrick      pcmd("    PRE_WRITE(buf_, res);")
10403cab2bb3Spatrick      pcmd("  }")
10413cab2bb3Spatrick      pcmd("}")
10423cab2bb3Spatrick    }
10433cab2bb3Spatrick  } else if (syscall == "execve") {
10443cab2bb3Spatrick    if (mode == "pre") {
10453cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
10463cab2bb3Spatrick      pcmd("char **argp = (char **)argp_;")
10473cab2bb3Spatrick      pcmd("char **envp = (char **)envp_;")
10483cab2bb3Spatrick      pcmd("if (path) {")
10493cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
10503cab2bb3Spatrick      pcmd("}")
10513cab2bb3Spatrick      pcmd("if (argp && argp[0]) {")
10523cab2bb3Spatrick      pcmd("  char *a = argp[0];")
10533cab2bb3Spatrick      pcmd("  while (a++) {")
10543cab2bb3Spatrick      pcmd("    PRE_READ(a, __sanitizer::internal_strlen(a) + 1);")
10553cab2bb3Spatrick      pcmd("  }")
10563cab2bb3Spatrick      pcmd("}")
10573cab2bb3Spatrick      pcmd("if (envp && envp[0]) {")
10583cab2bb3Spatrick      pcmd("  char *e = envp[0];")
10593cab2bb3Spatrick      pcmd("  while (e++) {")
10603cab2bb3Spatrick      pcmd("    PRE_READ(e, __sanitizer::internal_strlen(e) + 1);")
10613cab2bb3Spatrick      pcmd("  }")
10623cab2bb3Spatrick      pcmd("}")
10633cab2bb3Spatrick    } else {
10643cab2bb3Spatrick      pcmd("/* If we are here, something went wrong */")
10653cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
10663cab2bb3Spatrick      pcmd("char **argp = (char **)argp_;")
10673cab2bb3Spatrick      pcmd("char **envp = (char **)envp_;")
10683cab2bb3Spatrick      pcmd("if (path) {")
10693cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
10703cab2bb3Spatrick      pcmd("}")
10713cab2bb3Spatrick      pcmd("if (argp && argp[0]) {")
10723cab2bb3Spatrick      pcmd("  char *a = argp[0];")
10733cab2bb3Spatrick      pcmd("  while (a++) {")
10743cab2bb3Spatrick      pcmd("    POST_READ(a, __sanitizer::internal_strlen(a) + 1);")
10753cab2bb3Spatrick      pcmd("  }")
10763cab2bb3Spatrick      pcmd("}")
10773cab2bb3Spatrick      pcmd("if (envp && envp[0]) {")
10783cab2bb3Spatrick      pcmd("  char *e = envp[0];")
10793cab2bb3Spatrick      pcmd("  while (e++) {")
10803cab2bb3Spatrick      pcmd("    POST_READ(e, __sanitizer::internal_strlen(e) + 1);")
10813cab2bb3Spatrick      pcmd("  }")
10823cab2bb3Spatrick      pcmd("}")
10833cab2bb3Spatrick    }
10843cab2bb3Spatrick  } else if (syscall == "umask") {
10853cab2bb3Spatrick    pcmd("/* Nothing to do */")
10863cab2bb3Spatrick  } else if (syscall == "chroot") {
10873cab2bb3Spatrick    if (mode == "pre") {
10883cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
10893cab2bb3Spatrick      pcmd("if (path) {")
10903cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
10913cab2bb3Spatrick      pcmd("}")
10923cab2bb3Spatrick    } else {
10933cab2bb3Spatrick      pcmd("if (res == 0) {")
10943cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
10953cab2bb3Spatrick      pcmd("  if (path) {")
10963cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
10973cab2bb3Spatrick      pcmd("  }")
10983cab2bb3Spatrick      pcmd("}")
10993cab2bb3Spatrick    }
11003cab2bb3Spatrick  } else if (syscall == "compat_43_fstat43") {
11013cab2bb3Spatrick    pcmd("/* TODO */")
11023cab2bb3Spatrick  } else if (syscall == "compat_43_ogetkerninfo") {
11033cab2bb3Spatrick    pcmd("/* TODO */")
11043cab2bb3Spatrick  } else if (syscall == "compat_43_ogetpagesize") {
11053cab2bb3Spatrick    pcmd("/* TODO */")
11063cab2bb3Spatrick  } else if (syscall == "compat_12_msync") {
11073cab2bb3Spatrick    pcmd("/* TODO */")
11083cab2bb3Spatrick  } else if (syscall == "vfork") {
11093cab2bb3Spatrick    pcmd("/* Nothing to do */")
11103cab2bb3Spatrick  } else if (syscall == "compat_43_ommap") {
11113cab2bb3Spatrick    pcmd("/* TODO */")
11123cab2bb3Spatrick  } else if (syscall == "vadvise") {
11133cab2bb3Spatrick    pcmd("/* Nothing to do */")
11143cab2bb3Spatrick  } else if (syscall == "munmap") {
11153cab2bb3Spatrick    pcmd("/* Nothing to do */")
11163cab2bb3Spatrick  } else if (syscall == "mprotect") {
11173cab2bb3Spatrick    pcmd("/* Nothing to do */")
11183cab2bb3Spatrick  } else if (syscall == "madvise") {
11193cab2bb3Spatrick    pcmd("/* Nothing to do */")
11203cab2bb3Spatrick  } else if (syscall == "mincore") {
11213cab2bb3Spatrick    pcmd("/* Nothing to do */")
11223cab2bb3Spatrick  } else if (syscall == "getgroups") {
11233cab2bb3Spatrick    if (mode == "pre") {
11243cab2bb3Spatrick      pcmd("unsigned int *gidset = (unsigned int *)gidset_;")
11253cab2bb3Spatrick      pcmd("if (gidset) {")
11263cab2bb3Spatrick      pcmd("  PRE_WRITE(gidset, sizeof(*gidset) * gidsetsize_);")
11273cab2bb3Spatrick      pcmd("}")
11283cab2bb3Spatrick    } else {
11293cab2bb3Spatrick      pcmd("if (res == 0) {")
11303cab2bb3Spatrick      pcmd("  unsigned int *gidset = (unsigned int *)gidset_;")
11313cab2bb3Spatrick      pcmd("  if (gidset) {")
11323cab2bb3Spatrick      pcmd("    POST_WRITE(gidset, sizeof(*gidset) * gidsetsize_);")
11333cab2bb3Spatrick      pcmd("  }")
11343cab2bb3Spatrick      pcmd("}")
11353cab2bb3Spatrick    }
11363cab2bb3Spatrick  } else if (syscall == "setgroups") {
11373cab2bb3Spatrick    if (mode == "pre") {
11383cab2bb3Spatrick      pcmd("unsigned int *gidset = (unsigned int *)gidset_;")
11393cab2bb3Spatrick      pcmd("if (gidset) {")
11403cab2bb3Spatrick      pcmd("  PRE_READ(gidset, sizeof(*gidset) * gidsetsize_);")
11413cab2bb3Spatrick      pcmd("}")
11423cab2bb3Spatrick    } else {
11433cab2bb3Spatrick      pcmd("if (res == 0) {")
11443cab2bb3Spatrick      pcmd("  unsigned int *gidset = (unsigned int *)gidset_;")
11453cab2bb3Spatrick      pcmd("  if (gidset) {")
11463cab2bb3Spatrick      pcmd("    POST_READ(gidset, sizeof(*gidset) * gidsetsize_);")
11473cab2bb3Spatrick      pcmd("  }")
11483cab2bb3Spatrick      pcmd("}")
11493cab2bb3Spatrick    }
11503cab2bb3Spatrick  } else if (syscall == "getpgrp") {
11513cab2bb3Spatrick    pcmd("/* Nothing to do */")
11523cab2bb3Spatrick  } else if (syscall == "setpgid") {
11533cab2bb3Spatrick    pcmd("/* Nothing to do */")
11543cab2bb3Spatrick  } else if (syscall == "compat_50_setitimer") {
11553cab2bb3Spatrick    pcmd("/* TODO */")
11563cab2bb3Spatrick  } else if (syscall == "compat_43_owait") {
11573cab2bb3Spatrick    pcmd("/* TODO */")
11583cab2bb3Spatrick  } else if (syscall == "compat_12_oswapon") {
11593cab2bb3Spatrick    pcmd("/* TODO */")
11603cab2bb3Spatrick  } else if (syscall == "compat_50_getitimer") {
11613cab2bb3Spatrick    pcmd("/* TODO */")
11623cab2bb3Spatrick  } else if (syscall == "compat_43_ogethostname") {
11633cab2bb3Spatrick    pcmd("/* TODO */")
11643cab2bb3Spatrick  } else if (syscall == "compat_43_osethostname") {
11653cab2bb3Spatrick    pcmd("/* TODO */")
11663cab2bb3Spatrick  } else if (syscall == "compat_43_ogetdtablesize") {
11673cab2bb3Spatrick    pcmd("/* TODO */")
11683cab2bb3Spatrick  } else if (syscall == "dup2") {
11693cab2bb3Spatrick    pcmd("/* Nothing to do */")
1170d89ec533Spatrick  } else if (syscall == "getrandom") {
1171d89ec533Spatrick    pcmd("/* TODO */")
11723cab2bb3Spatrick  } else if (syscall == "fcntl") {
11733cab2bb3Spatrick    pcmd("/* Nothing to do */")
11743cab2bb3Spatrick  } else if (syscall == "compat_50_select") {
11753cab2bb3Spatrick    pcmd("/* TODO */")
11763cab2bb3Spatrick  } else if (syscall == "fsync") {
11773cab2bb3Spatrick    pcmd("/* Nothing to do */")
11783cab2bb3Spatrick  } else if (syscall == "setpriority") {
11793cab2bb3Spatrick    pcmd("/* Nothing to do */")
11803cab2bb3Spatrick  } else if (syscall == "compat_30_socket") {
11813cab2bb3Spatrick    pcmd("/* TODO */")
11823cab2bb3Spatrick  } else if (syscall == "connect") {
11833cab2bb3Spatrick    if (mode == "pre") {
11843cab2bb3Spatrick      pcmd("PRE_READ(name_, namelen_);")
11853cab2bb3Spatrick    } else {
11863cab2bb3Spatrick      pcmd("if (res == 0) {")
11873cab2bb3Spatrick      pcmd("  POST_READ(name_, namelen_);")
11883cab2bb3Spatrick      pcmd("}")
11893cab2bb3Spatrick    }
11903cab2bb3Spatrick  } else if (syscall == "compat_43_oaccept") {
11913cab2bb3Spatrick    pcmd("/* TODO */")
11923cab2bb3Spatrick  } else if (syscall == "getpriority") {
11933cab2bb3Spatrick    pcmd("/* Nothing to do */")
11943cab2bb3Spatrick  } else if (syscall == "compat_43_osend") {
11953cab2bb3Spatrick    pcmd("/* TODO */")
11963cab2bb3Spatrick  } else if (syscall == "compat_43_orecv") {
11973cab2bb3Spatrick    pcmd("/* TODO */")
11983cab2bb3Spatrick  } else if (syscall == "compat_13_sigreturn13") {
11993cab2bb3Spatrick    pcmd("/* TODO */")
12003cab2bb3Spatrick  } else if (syscall == "bind") {
12013cab2bb3Spatrick    if (mode == "pre") {
12023cab2bb3Spatrick      pcmd("PRE_READ(name_, namelen_);")
12033cab2bb3Spatrick    } else {
12043cab2bb3Spatrick      pcmd("if (res == 0) {")
12053cab2bb3Spatrick      pcmd("  PRE_READ(name_, namelen_);")
12063cab2bb3Spatrick      pcmd("}")
12073cab2bb3Spatrick    }
12083cab2bb3Spatrick  } else if (syscall == "setsockopt") {
12093cab2bb3Spatrick    if (mode == "pre") {
12103cab2bb3Spatrick      pcmd("if (val_) {")
12113cab2bb3Spatrick      pcmd("  PRE_READ(val_, valsize_);")
12123cab2bb3Spatrick      pcmd("}")
12133cab2bb3Spatrick    } else {
12143cab2bb3Spatrick      pcmd("if (res == 0) {")
12153cab2bb3Spatrick      pcmd("  if (val_) {")
12163cab2bb3Spatrick      pcmd("    POST_READ(val_, valsize_);")
12173cab2bb3Spatrick      pcmd("  }")
12183cab2bb3Spatrick      pcmd("}")
12193cab2bb3Spatrick    }
12203cab2bb3Spatrick  } else if (syscall == "listen") {
12213cab2bb3Spatrick    pcmd("/* Nothing to do */")
12223cab2bb3Spatrick  } else if (syscall == "compat_43_osigvec") {
12233cab2bb3Spatrick    pcmd("/* TODO */")
12243cab2bb3Spatrick  } else if (syscall == "compat_43_osigblock") {
12253cab2bb3Spatrick    pcmd("/* TODO */")
12263cab2bb3Spatrick  } else if (syscall == "compat_43_osigsetmask") {
12273cab2bb3Spatrick    pcmd("/* TODO */")
12283cab2bb3Spatrick  } else if (syscall == "compat_13_sigsuspend13") {
12293cab2bb3Spatrick    pcmd("/* TODO */")
12303cab2bb3Spatrick  } else if (syscall == "compat_43_osigstack") {
12313cab2bb3Spatrick    pcmd("/* TODO */")
12323cab2bb3Spatrick  } else if (syscall == "compat_43_orecvmsg") {
12333cab2bb3Spatrick    pcmd("/* TODO */")
12343cab2bb3Spatrick  } else if (syscall == "compat_43_osendmsg") {
12353cab2bb3Spatrick    pcmd("/* TODO */")
12363cab2bb3Spatrick  } else if (syscall == "compat_50_gettimeofday") {
12373cab2bb3Spatrick    pcmd("/* TODO */")
12383cab2bb3Spatrick  } else if (syscall == "compat_50_getrusage") {
12393cab2bb3Spatrick    pcmd("/* TODO */")
12403cab2bb3Spatrick  } else if (syscall == "getsockopt") {
12413cab2bb3Spatrick    pcmd("/* TODO */")
12423cab2bb3Spatrick  } else if (syscall == "readv") {
12433cab2bb3Spatrick    if (mode == "pre") {
12443cab2bb3Spatrick      pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
12453cab2bb3Spatrick      pcmd("int i;")
12463cab2bb3Spatrick      pcmd("if (iovp) {")
12473cab2bb3Spatrick      pcmd("  PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
12483cab2bb3Spatrick      pcmd("  for (i = 0; i < iovcnt_; i++) {")
12493cab2bb3Spatrick      pcmd("    PRE_WRITE(iovp[i].iov_base, iovp[i].iov_len);")
12503cab2bb3Spatrick      pcmd("  }")
12513cab2bb3Spatrick      pcmd("}")
12523cab2bb3Spatrick    } else {
12533cab2bb3Spatrick      pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
12543cab2bb3Spatrick      pcmd("int i;")
12553cab2bb3Spatrick      pcmd("uptr m, n = res;")
12563cab2bb3Spatrick      pcmd("if (res > 0) {")
12573cab2bb3Spatrick      pcmd("  if (iovp) {")
12583cab2bb3Spatrick      pcmd("    POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
12593cab2bb3Spatrick      pcmd("    for (i = 0; i < iovcnt_ && n > 0; i++) {")
12603cab2bb3Spatrick      pcmd("      m = n > iovp[i].iov_len ? iovp[i].iov_len : n;")
12613cab2bb3Spatrick      pcmd("      POST_WRITE(iovp[i].iov_base, m);")
12623cab2bb3Spatrick      pcmd("      n -= m;")
12633cab2bb3Spatrick      pcmd("    }")
12643cab2bb3Spatrick      pcmd("  }")
12653cab2bb3Spatrick      pcmd("}")
12663cab2bb3Spatrick    }
12673cab2bb3Spatrick  } else if (syscall == "writev") {
12683cab2bb3Spatrick    if (mode == "pre") {
12693cab2bb3Spatrick      pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
12703cab2bb3Spatrick      pcmd("int i;")
12713cab2bb3Spatrick      pcmd("if (iovp) {")
12723cab2bb3Spatrick      pcmd("  PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
12733cab2bb3Spatrick      pcmd("  for (i = 0; i < iovcnt_; i++) {")
12743cab2bb3Spatrick      pcmd("    PRE_READ(iovp[i].iov_base, iovp[i].iov_len);")
12753cab2bb3Spatrick      pcmd("  }")
12763cab2bb3Spatrick      pcmd("}")
12773cab2bb3Spatrick    } else {
12783cab2bb3Spatrick      pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
12793cab2bb3Spatrick      pcmd("int i;")
12803cab2bb3Spatrick      pcmd("uptr m, n = res;")
12813cab2bb3Spatrick      pcmd("if (res > 0) {")
12823cab2bb3Spatrick      pcmd("  if (iovp) {")
12833cab2bb3Spatrick      pcmd("    POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
12843cab2bb3Spatrick      pcmd("    for (i = 0; i < iovcnt_ && n > 0; i++) {")
12853cab2bb3Spatrick      pcmd("      m = n > iovp[i].iov_len ? iovp[i].iov_len : n;")
12863cab2bb3Spatrick      pcmd("      POST_READ(iovp[i].iov_base, m);")
12873cab2bb3Spatrick      pcmd("      n -= m;")
12883cab2bb3Spatrick      pcmd("    }")
12893cab2bb3Spatrick      pcmd("  }")
12903cab2bb3Spatrick      pcmd("}")
12913cab2bb3Spatrick    }
12923cab2bb3Spatrick  } else if (syscall == "compat_50_settimeofday") {
12933cab2bb3Spatrick    pcmd("/* TODO */")
12943cab2bb3Spatrick  } else if (syscall == "fchown") {
12953cab2bb3Spatrick    pcmd("/* Nothing to do */")
12963cab2bb3Spatrick  } else if (syscall == "fchmod") {
12973cab2bb3Spatrick    pcmd("/* Nothing to do */")
12983cab2bb3Spatrick  } else if (syscall == "compat_43_orecvfrom") {
12993cab2bb3Spatrick    pcmd("/* TODO */")
13003cab2bb3Spatrick  } else if (syscall == "setreuid") {
13013cab2bb3Spatrick    pcmd("/* Nothing to do */")
13023cab2bb3Spatrick  } else if (syscall == "setregid") {
13033cab2bb3Spatrick    pcmd("/* Nothing to do */")
13043cab2bb3Spatrick  } else if (syscall == "rename") {
13053cab2bb3Spatrick    if (mode == "pre") {
13063cab2bb3Spatrick      pcmd("const char *from = (const char *)from_;")
13073cab2bb3Spatrick      pcmd("const char *to = (const char *)to_;")
13083cab2bb3Spatrick      pcmd("if (from) {")
13093cab2bb3Spatrick      pcmd("  PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
13103cab2bb3Spatrick      pcmd("}")
13113cab2bb3Spatrick      pcmd("if (to) {")
13123cab2bb3Spatrick      pcmd("  PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
13133cab2bb3Spatrick      pcmd("}")
13143cab2bb3Spatrick    } else {
13153cab2bb3Spatrick      pcmd("if (res == 0) {")
13163cab2bb3Spatrick      pcmd("  const char *from = (const char *)from_;")
13173cab2bb3Spatrick      pcmd("  const char *to = (const char *)to_;")
13183cab2bb3Spatrick      pcmd("  if (from) {")
13193cab2bb3Spatrick      pcmd("    POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
13203cab2bb3Spatrick      pcmd("  }")
13213cab2bb3Spatrick      pcmd("  if (to) {")
13223cab2bb3Spatrick      pcmd("    POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
13233cab2bb3Spatrick      pcmd("  }")
13243cab2bb3Spatrick      pcmd("}")
13253cab2bb3Spatrick    }
13263cab2bb3Spatrick  } else if (syscall == "compat_43_otruncate") {
13273cab2bb3Spatrick    pcmd("/* TODO */")
13283cab2bb3Spatrick  } else if (syscall == "compat_43_oftruncate") {
13293cab2bb3Spatrick    pcmd("/* TODO */")
13303cab2bb3Spatrick  } else if (syscall == "flock") {
13313cab2bb3Spatrick    pcmd("/* Nothing to do */")
13323cab2bb3Spatrick  } else if (syscall == "mkfifo") {
13333cab2bb3Spatrick    if (mode == "pre") {
13343cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
13353cab2bb3Spatrick      pcmd("if (path) {")
13363cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
13373cab2bb3Spatrick      pcmd("}")
13383cab2bb3Spatrick    } else {
13393cab2bb3Spatrick      pcmd("if (res == 0) {")
13403cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
13413cab2bb3Spatrick      pcmd("  if (path) {")
13423cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
13433cab2bb3Spatrick      pcmd("  }")
13443cab2bb3Spatrick      pcmd("}")
13453cab2bb3Spatrick    }
13463cab2bb3Spatrick  } else if (syscall == "sendto") {
13473cab2bb3Spatrick    if (mode == "pre") {
13483cab2bb3Spatrick      pcmd("PRE_READ(buf_, len_);")
13493cab2bb3Spatrick      pcmd("PRE_READ(to_, tolen_);")
13503cab2bb3Spatrick    } else {
13513cab2bb3Spatrick      pcmd("if (res >= 0) {")
13523cab2bb3Spatrick      pcmd("  POST_READ(buf_, len_);")
13533cab2bb3Spatrick      pcmd("  POST_READ(to_, tolen_);")
13543cab2bb3Spatrick      pcmd("}")
13553cab2bb3Spatrick    }
13563cab2bb3Spatrick  } else if (syscall == "shutdown") {
13573cab2bb3Spatrick    pcmd("/* Nothing to do */")
13583cab2bb3Spatrick  } else if (syscall == "socketpair") {
13593cab2bb3Spatrick    if (mode == "pre") {
13603cab2bb3Spatrick      pcmd("PRE_WRITE(rsv_, 2 * sizeof(int));")
13613cab2bb3Spatrick    } else {
13623cab2bb3Spatrick      pcmd("if (res == 0) {")
13633cab2bb3Spatrick      pcmd("  POST_WRITE(rsv_, 2 * sizeof(int));")
13643cab2bb3Spatrick      pcmd("}")
13653cab2bb3Spatrick    }
13663cab2bb3Spatrick  } else if (syscall == "mkdir") {
13673cab2bb3Spatrick    if (mode == "pre") {
13683cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
13693cab2bb3Spatrick      pcmd("if (path) {")
13703cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
13713cab2bb3Spatrick      pcmd("}")
13723cab2bb3Spatrick    } else {
13733cab2bb3Spatrick      pcmd("if (res == 0) {")
13743cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
13753cab2bb3Spatrick      pcmd("  if (path) {")
13763cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
13773cab2bb3Spatrick      pcmd("  }")
13783cab2bb3Spatrick      pcmd("}")
13793cab2bb3Spatrick    }
13803cab2bb3Spatrick  } else if (syscall == "rmdir") {
13813cab2bb3Spatrick    if (mode == "pre") {
13823cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
13833cab2bb3Spatrick      pcmd("if (path) {")
13843cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
13853cab2bb3Spatrick      pcmd("}")
13863cab2bb3Spatrick    } else {
13873cab2bb3Spatrick      pcmd("if (res == 0) {")
13883cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
13893cab2bb3Spatrick      pcmd("  if (path) {")
13903cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
13913cab2bb3Spatrick      pcmd("  }")
13923cab2bb3Spatrick      pcmd("}")
13933cab2bb3Spatrick    }
13943cab2bb3Spatrick  } else if (syscall == "compat_50_utimes") {
13953cab2bb3Spatrick    pcmd("/* TODO */")
13963cab2bb3Spatrick  } else if (syscall == "compat_50_adjtime") {
13973cab2bb3Spatrick    pcmd("/* TODO */")
13983cab2bb3Spatrick  } else if (syscall == "compat_43_ogetpeername") {
13993cab2bb3Spatrick    pcmd("/* TODO */")
14003cab2bb3Spatrick  } else if (syscall == "compat_43_ogethostid") {
14013cab2bb3Spatrick    pcmd("/* TODO */")
14023cab2bb3Spatrick  } else if (syscall == "compat_43_osethostid") {
14033cab2bb3Spatrick    pcmd("/* TODO */")
14043cab2bb3Spatrick  } else if (syscall == "compat_43_ogetrlimit") {
14053cab2bb3Spatrick    pcmd("/* TODO */")
14063cab2bb3Spatrick  } else if (syscall == "compat_43_osetrlimit") {
14073cab2bb3Spatrick    pcmd("/* TODO */")
14083cab2bb3Spatrick  } else if (syscall == "compat_43_okillpg") {
14093cab2bb3Spatrick    pcmd("/* TODO */")
14103cab2bb3Spatrick  } else if (syscall == "setsid") {
14113cab2bb3Spatrick    pcmd("/* Nothing to do */")
14123cab2bb3Spatrick  } else if (syscall == "compat_50_quotactl") {
14133cab2bb3Spatrick    pcmd("/* TODO */")
14143cab2bb3Spatrick  } else if (syscall == "compat_43_oquota") {
14153cab2bb3Spatrick    pcmd("/* TODO */")
14163cab2bb3Spatrick  } else if (syscall == "compat_43_ogetsockname") {
14173cab2bb3Spatrick    pcmd("/* TODO */")
14183cab2bb3Spatrick  } else if (syscall == "nfssvc") {
14193cab2bb3Spatrick    pcmd("/* Nothing to do */")
14203cab2bb3Spatrick  } else if (syscall == "compat_43_ogetdirentries") {
14213cab2bb3Spatrick    pcmd("/* TODO */")
14223cab2bb3Spatrick  } else if (syscall == "compat_20_statfs") {
14233cab2bb3Spatrick    pcmd("/* TODO */")
14243cab2bb3Spatrick  } else if (syscall == "compat_20_fstatfs") {
14253cab2bb3Spatrick    pcmd("/* TODO */")
14263cab2bb3Spatrick  } else if (syscall == "compat_30_getfh") {
14273cab2bb3Spatrick    pcmd("/* TODO */")
14283cab2bb3Spatrick  } else if (syscall == "compat_09_ogetdomainname") {
14293cab2bb3Spatrick    pcmd("/* TODO */")
14303cab2bb3Spatrick  } else if (syscall == "compat_09_osetdomainname") {
14313cab2bb3Spatrick    pcmd("/* TODO */")
14323cab2bb3Spatrick  } else if (syscall == "compat_09_ouname") {
14333cab2bb3Spatrick    pcmd("/* TODO */")
14343cab2bb3Spatrick  } else if (syscall == "sysarch") {
14353cab2bb3Spatrick    pcmd("/* TODO */")
1436d89ec533Spatrick  } else if (syscall == "__futex") {
1437d89ec533Spatrick    pcmd("/* TODO */")
1438d89ec533Spatrick  } else if (syscall == "__futex_set_robust_list") {
1439d89ec533Spatrick    pcmd("/* TODO */")
1440d89ec533Spatrick  } else if (syscall == "__futex_get_robust_list") {
1441d89ec533Spatrick    pcmd("/* TODO */")
14423cab2bb3Spatrick  } else if (syscall == "compat_10_osemsys") {
14433cab2bb3Spatrick    pcmd("/* TODO */")
14443cab2bb3Spatrick  } else if (syscall == "compat_10_omsgsys") {
14453cab2bb3Spatrick    pcmd("/* TODO */")
14463cab2bb3Spatrick  } else if (syscall == "compat_10_oshmsys") {
14473cab2bb3Spatrick    pcmd("/* TODO */")
14483cab2bb3Spatrick  } else if (syscall == "pread") {
14493cab2bb3Spatrick    if (mode == "pre") {
14503cab2bb3Spatrick      pcmd("if (buf_) {")
14513cab2bb3Spatrick      pcmd("  PRE_WRITE(buf_, nbyte_);")
14523cab2bb3Spatrick      pcmd("}")
14533cab2bb3Spatrick    } else {
14543cab2bb3Spatrick      pcmd("if (res > 0) {")
14553cab2bb3Spatrick      pcmd("  POST_WRITE(buf_, res);")
14563cab2bb3Spatrick      pcmd("}")
14573cab2bb3Spatrick    }
14583cab2bb3Spatrick  } else if (syscall == "pwrite") {
14593cab2bb3Spatrick    if (mode == "pre") {
14603cab2bb3Spatrick      pcmd("if (buf_) {")
14613cab2bb3Spatrick      pcmd("  PRE_READ(buf_, nbyte_);")
14623cab2bb3Spatrick      pcmd("}")
14633cab2bb3Spatrick    } else {
14643cab2bb3Spatrick      pcmd("if (res > 0) {")
14653cab2bb3Spatrick      pcmd("  POST_READ(buf_, res);")
14663cab2bb3Spatrick      pcmd("}")
14673cab2bb3Spatrick    }
14683cab2bb3Spatrick  } else if (syscall == "compat_30_ntp_gettime") {
14693cab2bb3Spatrick    pcmd("/* TODO */")
14703cab2bb3Spatrick  } else if (syscall == "ntp_adjtime") {
14713cab2bb3Spatrick    pcmd("/* Nothing to do */")
14723cab2bb3Spatrick  } else if (syscall == "setgid") {
14733cab2bb3Spatrick    pcmd("/* Nothing to do */")
14743cab2bb3Spatrick  } else if (syscall == "setegid") {
14753cab2bb3Spatrick    pcmd("/* Nothing to do */")
14763cab2bb3Spatrick  } else if (syscall == "seteuid") {
14773cab2bb3Spatrick    pcmd("/* Nothing to do */")
14783cab2bb3Spatrick  } else if (syscall == "lfs_bmapv") {
14793cab2bb3Spatrick    pcmd("/* TODO */")
14803cab2bb3Spatrick  } else if (syscall == "lfs_markv") {
14813cab2bb3Spatrick    pcmd("/* TODO */")
14823cab2bb3Spatrick  } else if (syscall == "lfs_segclean") {
14833cab2bb3Spatrick    pcmd("/* TODO */")
14843cab2bb3Spatrick  } else if (syscall == "compat_50_lfs_segwait") {
14853cab2bb3Spatrick    pcmd("/* TODO */")
14863cab2bb3Spatrick  } else if (syscall == "compat_12_stat12") {
14873cab2bb3Spatrick    pcmd("/* TODO */")
14883cab2bb3Spatrick  } else if (syscall == "compat_12_fstat12") {
14893cab2bb3Spatrick    pcmd("/* TODO */")
14903cab2bb3Spatrick  } else if (syscall == "compat_12_lstat12") {
14913cab2bb3Spatrick    pcmd("/* TODO */")
14923cab2bb3Spatrick  } else if (syscall == "pathconf") {
14933cab2bb3Spatrick    if (mode == "pre") {
14943cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
14953cab2bb3Spatrick      pcmd("if (path) {")
14963cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
14973cab2bb3Spatrick      pcmd("}")
14983cab2bb3Spatrick    } else {
14993cab2bb3Spatrick      pcmd("if (res != -1) {")
15003cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
15013cab2bb3Spatrick      pcmd("  if (path) {")
15023cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
15033cab2bb3Spatrick      pcmd("  }")
15043cab2bb3Spatrick      pcmd("}")
15053cab2bb3Spatrick    }
15063cab2bb3Spatrick  } else if (syscall == "getsockopt2") {
15073cab2bb3Spatrick    pcmd("/* TODO */")
15083cab2bb3Spatrick  } else if (syscall == "fpathconf") {
15093cab2bb3Spatrick    pcmd("/* Nothing to do */")
15103cab2bb3Spatrick  } else if (syscall == "getrlimit") {
15113cab2bb3Spatrick    if (mode == "pre") {
15123cab2bb3Spatrick      pcmd("PRE_WRITE(rlp_, struct_rlimit_sz);")
15133cab2bb3Spatrick    } else {
15143cab2bb3Spatrick      pcmd("if (res == 0) {")
15153cab2bb3Spatrick      pcmd("  POST_WRITE(rlp_, struct_rlimit_sz);")
15163cab2bb3Spatrick      pcmd("}")
15173cab2bb3Spatrick    }
15183cab2bb3Spatrick  } else if (syscall == "setrlimit") {
15193cab2bb3Spatrick    if (mode == "pre") {
15203cab2bb3Spatrick      pcmd("PRE_READ(rlp_, struct_rlimit_sz);")
15213cab2bb3Spatrick    } else {
15223cab2bb3Spatrick      pcmd("if (res == 0) {")
15233cab2bb3Spatrick      pcmd("  POST_READ(rlp_, struct_rlimit_sz);")
15243cab2bb3Spatrick      pcmd("}")
15253cab2bb3Spatrick    }
15263cab2bb3Spatrick  } else if (syscall == "compat_12_getdirentries") {
15273cab2bb3Spatrick    pcmd("/* TODO */")
15283cab2bb3Spatrick  } else if (syscall == "mmap") {
15293cab2bb3Spatrick    pcmd("/* Nothing to do */")
15303cab2bb3Spatrick  } else if (syscall == "__syscall") {
15313cab2bb3Spatrick    pcmd("/* Nothing to do */")
15323cab2bb3Spatrick  } else if (syscall == "lseek") {
15333cab2bb3Spatrick    pcmd("/* Nothing to do */")
15343cab2bb3Spatrick  } else if (syscall == "truncate") {
15353cab2bb3Spatrick    if (mode == "pre") {
15363cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
15373cab2bb3Spatrick      pcmd("if (path) {")
15383cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
15393cab2bb3Spatrick      pcmd("}")
15403cab2bb3Spatrick    } else {
15413cab2bb3Spatrick      pcmd("if (res == 0) {")
15423cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
15433cab2bb3Spatrick      pcmd("  if (path) {")
15443cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
15453cab2bb3Spatrick      pcmd("  }")
15463cab2bb3Spatrick      pcmd("}")
15473cab2bb3Spatrick    }
15483cab2bb3Spatrick  } else if (syscall == "ftruncate") {
15493cab2bb3Spatrick    pcmd("/* Nothing to do */")
15503cab2bb3Spatrick  } else if (syscall == "__sysctl") {
15513cab2bb3Spatrick    if (mode == "pre") {
15523cab2bb3Spatrick      pcmd("const int *name = (const int *)name_;")
15533cab2bb3Spatrick      pcmd("if (name) {")
15543cab2bb3Spatrick      pcmd("  PRE_READ(name, namelen_ * sizeof(*name));")
15553cab2bb3Spatrick      pcmd("}")
15563cab2bb3Spatrick      pcmd("if (newv_) {")
15573cab2bb3Spatrick      pcmd("  PRE_READ(name, newlen_);")
15583cab2bb3Spatrick      pcmd("}")
15593cab2bb3Spatrick    } else {
15603cab2bb3Spatrick      pcmd("if (res == 0) {")
15613cab2bb3Spatrick      pcmd("  const int *name = (const int *)name_;")
15623cab2bb3Spatrick      pcmd("  if (name) {")
15633cab2bb3Spatrick      pcmd("    POST_READ(name, namelen_ * sizeof(*name));")
15643cab2bb3Spatrick      pcmd("  }")
15653cab2bb3Spatrick      pcmd("  if (newv_) {")
15663cab2bb3Spatrick      pcmd("    POST_READ(name, newlen_);")
15673cab2bb3Spatrick      pcmd("  }")
15683cab2bb3Spatrick      pcmd("}")
15693cab2bb3Spatrick    }
15703cab2bb3Spatrick  } else if (syscall == "mlock") {
15713cab2bb3Spatrick    pcmd("/* Nothing to do */")
15723cab2bb3Spatrick  } else if (syscall == "munlock") {
15733cab2bb3Spatrick    pcmd("/* Nothing to do */")
15743cab2bb3Spatrick  } else if (syscall == "undelete") {
15753cab2bb3Spatrick    if (mode == "pre") {
15763cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
15773cab2bb3Spatrick      pcmd("if (path) {")
15783cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
15793cab2bb3Spatrick      pcmd("}")
15803cab2bb3Spatrick    } else {
15813cab2bb3Spatrick      pcmd("if (res == 0) {")
15823cab2bb3Spatrick      pcmd("  const char *path = (const char *)path_;")
15833cab2bb3Spatrick      pcmd("  if (path) {")
15843cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
15853cab2bb3Spatrick      pcmd("  }")
15863cab2bb3Spatrick      pcmd("}")
15873cab2bb3Spatrick    }
15883cab2bb3Spatrick  } else if (syscall == "compat_50_futimes") {
15893cab2bb3Spatrick    pcmd("/* TODO */")
15903cab2bb3Spatrick  } else if (syscall == "getpgid") {
15913cab2bb3Spatrick    pcmd("/* Nothing to do */")
15923cab2bb3Spatrick  } else if (syscall == "reboot") {
15933cab2bb3Spatrick    if (mode == "pre") {
15943cab2bb3Spatrick      pcmd("const char *bootstr = (const char *)bootstr_;")
15953cab2bb3Spatrick      pcmd("if (bootstr) {")
15963cab2bb3Spatrick      pcmd("  PRE_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);")
15973cab2bb3Spatrick      pcmd("}")
15983cab2bb3Spatrick    } else {
15993cab2bb3Spatrick      pcmd("/* This call should never return */")
16003cab2bb3Spatrick      pcmd("const char *bootstr = (const char *)bootstr_;")
16013cab2bb3Spatrick      pcmd("if (bootstr) {")
16023cab2bb3Spatrick      pcmd("  POST_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);")
16033cab2bb3Spatrick      pcmd("}")
16043cab2bb3Spatrick    }
16053cab2bb3Spatrick  } else if (syscall == "poll") {
16063cab2bb3Spatrick    pcmd("/* Nothing to do */")
16073cab2bb3Spatrick  } else if (syscall == "afssys") {
16083cab2bb3Spatrick    pcmd("/* TODO */")
16093cab2bb3Spatrick  } else if (syscall == "compat_14___semctl") {
16103cab2bb3Spatrick    pcmd("/* TODO */")
16113cab2bb3Spatrick  } else if (syscall == "semget") {
16123cab2bb3Spatrick    pcmd("/* Nothing to do */")
16133cab2bb3Spatrick  } else if (syscall == "semop") {
16143cab2bb3Spatrick    if (mode == "pre") {
16153cab2bb3Spatrick      pcmd("if (sops_) {")
16163cab2bb3Spatrick      pcmd("  PRE_READ(sops_, nsops_ * struct_sembuf_sz);")
16173cab2bb3Spatrick      pcmd("}")
16183cab2bb3Spatrick    } else {
16193cab2bb3Spatrick      pcmd("if (res == 0) {")
16203cab2bb3Spatrick      pcmd("  if (sops_) {")
16213cab2bb3Spatrick      pcmd("    POST_READ(sops_, nsops_ * struct_sembuf_sz);")
16223cab2bb3Spatrick      pcmd("  }")
16233cab2bb3Spatrick      pcmd("}")
16243cab2bb3Spatrick    }
16253cab2bb3Spatrick  } else if (syscall == "semconfig") {
16263cab2bb3Spatrick    pcmd("/* Nothing to do */")
16273cab2bb3Spatrick  } else if (syscall == "compat_14_msgctl") {
16283cab2bb3Spatrick    pcmd("/* TODO */")
16293cab2bb3Spatrick  } else if (syscall == "msgget") {
16303cab2bb3Spatrick    pcmd("/* Nothing to do */")
16313cab2bb3Spatrick  } else if (syscall == "msgsnd") {
16323cab2bb3Spatrick    if (mode == "pre") {
16333cab2bb3Spatrick      pcmd("if (msgp_) {")
16343cab2bb3Spatrick      pcmd("  PRE_READ(msgp_, msgsz_);")
16353cab2bb3Spatrick      pcmd("}")
16363cab2bb3Spatrick    } else {
16373cab2bb3Spatrick      pcmd("if (res == 0) {")
16383cab2bb3Spatrick      pcmd("  if (msgp_) {")
16393cab2bb3Spatrick      pcmd("    POST_READ(msgp_, msgsz_);")
16403cab2bb3Spatrick      pcmd("  }")
16413cab2bb3Spatrick      pcmd("}")
16423cab2bb3Spatrick    }
16433cab2bb3Spatrick  } else if (syscall == "msgrcv") {
16443cab2bb3Spatrick    pcmd("/* Nothing to do */")
16453cab2bb3Spatrick  } else if (syscall == "shmat") {
16463cab2bb3Spatrick    pcmd("/* Nothing to do */")
16473cab2bb3Spatrick  } else if (syscall == "compat_14_shmctl") {
16483cab2bb3Spatrick    pcmd("/* TODO */")
16493cab2bb3Spatrick  } else if (syscall == "shmdt") {
16503cab2bb3Spatrick    pcmd("/* Nothing to do */")
16513cab2bb3Spatrick  } else if (syscall == "shmget") {
16523cab2bb3Spatrick    pcmd("/* Nothing to do */")
16533cab2bb3Spatrick  } else if (syscall == "compat_50_clock_gettime") {
16543cab2bb3Spatrick    pcmd("/* TODO */")
16553cab2bb3Spatrick  } else if (syscall == "compat_50_clock_settime") {
16563cab2bb3Spatrick    pcmd("/* TODO */")
16573cab2bb3Spatrick  } else if (syscall == "compat_50_clock_getres") {
16583cab2bb3Spatrick    pcmd("/* TODO */")
16593cab2bb3Spatrick  } else if (syscall == "timer_create") {
16603cab2bb3Spatrick    pcmd("/* Nothing to do */")
16613cab2bb3Spatrick  } else if (syscall == "timer_delete") {
16623cab2bb3Spatrick    pcmd("/* Nothing to do */")
16633cab2bb3Spatrick  } else if (syscall == "compat_50_timer_settime") {
16643cab2bb3Spatrick    pcmd("/* TODO */")
16653cab2bb3Spatrick  } else if (syscall == "compat_50_timer_gettime") {
16663cab2bb3Spatrick    pcmd("/* TODO */")
16673cab2bb3Spatrick  } else if (syscall == "timer_getoverrun") {
16683cab2bb3Spatrick    pcmd("/* Nothing to do */")
16693cab2bb3Spatrick  } else if (syscall == "compat_50_nanosleep") {
16703cab2bb3Spatrick    pcmd("/* TODO */")
16713cab2bb3Spatrick  } else if (syscall == "fdatasync") {
16723cab2bb3Spatrick    pcmd("/* Nothing to do */")
16733cab2bb3Spatrick  } else if (syscall == "mlockall") {
16743cab2bb3Spatrick    pcmd("/* Nothing to do */")
16753cab2bb3Spatrick  } else if (syscall == "munlockall") {
16763cab2bb3Spatrick    pcmd("/* Nothing to do */")
16773cab2bb3Spatrick  } else if (syscall == "compat_50___sigtimedwait") {
16783cab2bb3Spatrick    pcmd("/* TODO */")
16793cab2bb3Spatrick  } else if (syscall == "sigqueueinfo") {
16803cab2bb3Spatrick    if (mode == "pre") {
16813cab2bb3Spatrick      pcmd("if (info_) {")
16823cab2bb3Spatrick      pcmd("  PRE_READ(info_, siginfo_t_sz);")
16833cab2bb3Spatrick      pcmd("}")
16843cab2bb3Spatrick    }
16853cab2bb3Spatrick  } else if (syscall == "modctl") {
16863cab2bb3Spatrick    pcmd("/* TODO */")
16873cab2bb3Spatrick  } else if (syscall == "_ksem_init") {
16883cab2bb3Spatrick    pcmd("/* Nothing to do */")
16893cab2bb3Spatrick  } else if (syscall == "_ksem_open") {
16903cab2bb3Spatrick    if (mode == "pre") {
16913cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
16923cab2bb3Spatrick      pcmd("if (name) {")
16933cab2bb3Spatrick      pcmd("  PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
16943cab2bb3Spatrick      pcmd("}")
16953cab2bb3Spatrick    } else {
16963cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
16973cab2bb3Spatrick      pcmd("if (name) {")
16983cab2bb3Spatrick      pcmd("  POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
16993cab2bb3Spatrick      pcmd("}")
17003cab2bb3Spatrick    }
17013cab2bb3Spatrick  } else if (syscall == "_ksem_unlink") {
17023cab2bb3Spatrick    if (mode == "pre") {
17033cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
17043cab2bb3Spatrick      pcmd("if (name) {")
17053cab2bb3Spatrick      pcmd("  PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
17063cab2bb3Spatrick      pcmd("}")
17073cab2bb3Spatrick    } else {
17083cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
17093cab2bb3Spatrick      pcmd("if (name) {")
17103cab2bb3Spatrick      pcmd("  POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
17113cab2bb3Spatrick      pcmd("}")
17123cab2bb3Spatrick    }
17133cab2bb3Spatrick  } else if (syscall == "_ksem_close") {
17143cab2bb3Spatrick    pcmd("/* Nothing to do */")
17153cab2bb3Spatrick  } else if (syscall == "_ksem_post") {
17163cab2bb3Spatrick    pcmd("/* Nothing to do */")
17173cab2bb3Spatrick  } else if (syscall == "_ksem_wait") {
17183cab2bb3Spatrick    pcmd("/* Nothing to do */")
17193cab2bb3Spatrick  } else if (syscall == "_ksem_trywait") {
17203cab2bb3Spatrick    pcmd("/* Nothing to do */")
17213cab2bb3Spatrick  } else if (syscall == "_ksem_getvalue") {
17223cab2bb3Spatrick    pcmd("/* Nothing to do */")
17233cab2bb3Spatrick  } else if (syscall == "_ksem_destroy") {
17243cab2bb3Spatrick    pcmd("/* Nothing to do */")
17253cab2bb3Spatrick  } else if (syscall == "_ksem_timedwait") {
17263cab2bb3Spatrick    if (mode == "pre") {
17273cab2bb3Spatrick      pcmd("if (abstime_) {")
17283cab2bb3Spatrick      pcmd("  PRE_READ(abstime_, struct_timespec_sz);")
17293cab2bb3Spatrick      pcmd("}")
17303cab2bb3Spatrick    }
17313cab2bb3Spatrick  } else if (syscall == "mq_open") {
17323cab2bb3Spatrick    if (mode == "pre") {
17333cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
17343cab2bb3Spatrick      pcmd("if (name) {")
17353cab2bb3Spatrick      pcmd("  PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
17363cab2bb3Spatrick      pcmd("}")
17373cab2bb3Spatrick    } else {
17383cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
17393cab2bb3Spatrick      pcmd("if (name) {")
17403cab2bb3Spatrick      pcmd("  POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
17413cab2bb3Spatrick      pcmd("}")
17423cab2bb3Spatrick    }
17433cab2bb3Spatrick  } else if (syscall == "mq_close") {
17443cab2bb3Spatrick    pcmd("/* Nothing to do */")
17453cab2bb3Spatrick  } else if (syscall == "mq_unlink") {
17463cab2bb3Spatrick    if (mode == "pre") {
17473cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
17483cab2bb3Spatrick      pcmd("if (name) {")
17493cab2bb3Spatrick      pcmd("  PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
17503cab2bb3Spatrick      pcmd("}")
17513cab2bb3Spatrick    } else {
17523cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
17533cab2bb3Spatrick      pcmd("if (name) {")
17543cab2bb3Spatrick      pcmd("  POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
17553cab2bb3Spatrick      pcmd("}")
17563cab2bb3Spatrick    }
17573cab2bb3Spatrick  } else if (syscall == "mq_getattr") {
17583cab2bb3Spatrick    pcmd("/* Nothing to do */")
17593cab2bb3Spatrick  } else if (syscall == "mq_setattr") {
17603cab2bb3Spatrick    if (mode == "pre") {
17613cab2bb3Spatrick      pcmd("if (mqstat_) {")
17623cab2bb3Spatrick      pcmd("  PRE_READ(mqstat_, struct_mq_attr_sz);")
17633cab2bb3Spatrick      pcmd("}")
17643cab2bb3Spatrick    }
17653cab2bb3Spatrick  } else if (syscall == "mq_notify") {
17663cab2bb3Spatrick    if (mode == "pre") {
17673cab2bb3Spatrick      pcmd("if (notification_) {")
17683cab2bb3Spatrick      pcmd("  PRE_READ(notification_, struct_sigevent_sz);")
17693cab2bb3Spatrick      pcmd("}")
17703cab2bb3Spatrick    }
17713cab2bb3Spatrick  } else if (syscall == "mq_send") {
17723cab2bb3Spatrick    if (mode == "pre") {
17733cab2bb3Spatrick      pcmd("if (msg_ptr_) {")
17743cab2bb3Spatrick      pcmd("  PRE_READ(msg_ptr_, msg_len_);")
17753cab2bb3Spatrick      pcmd("}")
17763cab2bb3Spatrick    }
17773cab2bb3Spatrick  } else if (syscall == "mq_receive") {
17783cab2bb3Spatrick    pcmd("/* Nothing to do */")
17793cab2bb3Spatrick  } else if (syscall == "compat_50_mq_timedsend") {
17803cab2bb3Spatrick    pcmd("/* TODO */")
17813cab2bb3Spatrick  } else if (syscall == "compat_50_mq_timedreceive") {
17823cab2bb3Spatrick    pcmd("/* TODO */")
17833cab2bb3Spatrick  } else if (syscall == "__posix_rename") {
17843cab2bb3Spatrick    if (mode == "pre") {
17853cab2bb3Spatrick      pcmd("const char *from = (const char *)from_;")
17863cab2bb3Spatrick      pcmd("const char *to = (const char *)to_;")
17873cab2bb3Spatrick      pcmd("if (from_) {")
17883cab2bb3Spatrick      pcmd("  PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
17893cab2bb3Spatrick      pcmd("}")
17903cab2bb3Spatrick      pcmd("if (to) {")
17913cab2bb3Spatrick      pcmd("  PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
17923cab2bb3Spatrick      pcmd("}")
17933cab2bb3Spatrick    } else {
17943cab2bb3Spatrick      pcmd("const char *from = (const char *)from_;")
17953cab2bb3Spatrick      pcmd("const char *to = (const char *)to_;")
17963cab2bb3Spatrick      pcmd("if (from) {")
17973cab2bb3Spatrick      pcmd("  POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
17983cab2bb3Spatrick      pcmd("}")
17993cab2bb3Spatrick      pcmd("if (to) {")
18003cab2bb3Spatrick      pcmd("  POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
18013cab2bb3Spatrick      pcmd("}")
18023cab2bb3Spatrick    }
18033cab2bb3Spatrick  } else if (syscall == "swapctl") {
18043cab2bb3Spatrick    pcmd("/* TODO */")
18053cab2bb3Spatrick  } else if (syscall == "compat_30_getdents") {
18063cab2bb3Spatrick    pcmd("/* TODO */")
18073cab2bb3Spatrick  } else if (syscall == "minherit") {
18083cab2bb3Spatrick    pcmd("/* Nothing to do */")
18093cab2bb3Spatrick  } else if (syscall == "lchmod") {
18103cab2bb3Spatrick    if (mode == "pre") {
18113cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18123cab2bb3Spatrick      pcmd("if (path) {")
18133cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
18143cab2bb3Spatrick      pcmd("}")
18153cab2bb3Spatrick    } else {
18163cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18173cab2bb3Spatrick      pcmd("if (path) {")
18183cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
18193cab2bb3Spatrick      pcmd("}")
18203cab2bb3Spatrick    }
18213cab2bb3Spatrick  } else if (syscall == "lchown") {
18223cab2bb3Spatrick    if (mode == "pre") {
18233cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18243cab2bb3Spatrick      pcmd("if (path) {")
18253cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
18263cab2bb3Spatrick      pcmd("}")
18273cab2bb3Spatrick    } else {
18283cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18293cab2bb3Spatrick      pcmd("if (path) {")
18303cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
18313cab2bb3Spatrick      pcmd("}")
18323cab2bb3Spatrick    }
18333cab2bb3Spatrick  } else if (syscall == "compat_50_lutimes") {
18343cab2bb3Spatrick    pcmd("/* TODO */")
18353cab2bb3Spatrick  } else if (syscall == "__msync13") {
18363cab2bb3Spatrick    pcmd("/* Nothing to do */")
18373cab2bb3Spatrick  } else if (syscall == "compat_30___stat13") {
18383cab2bb3Spatrick    pcmd("/* TODO */")
18393cab2bb3Spatrick  } else if (syscall == "compat_30___fstat13") {
18403cab2bb3Spatrick    pcmd("/* TODO */")
18413cab2bb3Spatrick  } else if (syscall == "compat_30___lstat13") {
18423cab2bb3Spatrick    pcmd("/* TODO */")
18433cab2bb3Spatrick  } else if (syscall == "__sigaltstack14") {
18443cab2bb3Spatrick    if (mode == "pre") {
18453cab2bb3Spatrick      pcmd("if (nss_) {")
18463cab2bb3Spatrick      pcmd("  PRE_READ(nss_, struct_sigaltstack_sz);")
18473cab2bb3Spatrick      pcmd("}")
18483cab2bb3Spatrick      pcmd("if (oss_) {")
18493cab2bb3Spatrick      pcmd("  PRE_READ(oss_, struct_sigaltstack_sz);")
18503cab2bb3Spatrick      pcmd("}")
18513cab2bb3Spatrick    }
18523cab2bb3Spatrick  } else if (syscall == "__vfork14") {
18533cab2bb3Spatrick    pcmd("/* Nothing to do */")
18543cab2bb3Spatrick  } else if (syscall == "__posix_chown") {
18553cab2bb3Spatrick    if (mode == "pre") {
18563cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18573cab2bb3Spatrick      pcmd("if (path) {")
18583cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
18593cab2bb3Spatrick      pcmd("}")
18603cab2bb3Spatrick    } else {
18613cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18623cab2bb3Spatrick      pcmd("if (path) {")
18633cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
18643cab2bb3Spatrick      pcmd("}")
18653cab2bb3Spatrick    }
18663cab2bb3Spatrick  } else if (syscall == "__posix_fchown") {
18673cab2bb3Spatrick    pcmd("/* Nothing to do */")
18683cab2bb3Spatrick  } else if (syscall == "__posix_lchown") {
18693cab2bb3Spatrick    if (mode == "pre") {
18703cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18713cab2bb3Spatrick      pcmd("if (path) {")
18723cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
18733cab2bb3Spatrick      pcmd("}")
18743cab2bb3Spatrick    } else {
18753cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
18763cab2bb3Spatrick      pcmd("if (path) {")
18773cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
18783cab2bb3Spatrick      pcmd("}")
18793cab2bb3Spatrick    }
18803cab2bb3Spatrick  } else if (syscall == "getsid") {
18813cab2bb3Spatrick    pcmd("/* Nothing to do */")
18823cab2bb3Spatrick  } else if (syscall == "__clone") {
18833cab2bb3Spatrick    pcmd("/* Nothing to do */")
18843cab2bb3Spatrick  } else if (syscall == "fktrace") {
18853cab2bb3Spatrick    pcmd("/* Nothing to do */")
18863cab2bb3Spatrick  } else if (syscall == "preadv") {
18873cab2bb3Spatrick    pcmd("/* Nothing to do */")
18883cab2bb3Spatrick  } else if (syscall == "pwritev") {
18893cab2bb3Spatrick    pcmd("/* Nothing to do */")
18903cab2bb3Spatrick  } else if (syscall == "compat_16___sigaction14") {
18913cab2bb3Spatrick    pcmd("/* TODO */")
18923cab2bb3Spatrick  } else if (syscall == "__sigpending14") {
18933cab2bb3Spatrick    pcmd("/* Nothing to do */")
18943cab2bb3Spatrick  } else if (syscall == "__sigprocmask14") {
18953cab2bb3Spatrick    pcmd("/* Nothing to do */")
18963cab2bb3Spatrick  } else if (syscall == "__sigsuspend14") {
18973cab2bb3Spatrick    pcmd("if (set_) {")
18983cab2bb3Spatrick    pcmd("  PRE_READ(set_, sizeof(__sanitizer_sigset_t));")
18993cab2bb3Spatrick    pcmd("}")
19003cab2bb3Spatrick  } else if (syscall == "compat_16___sigreturn14") {
19013cab2bb3Spatrick    pcmd("/* TODO */")
19023cab2bb3Spatrick  } else if (syscall == "__getcwd") {
19033cab2bb3Spatrick    pcmd("/* Nothing to do */")
19043cab2bb3Spatrick  } else if (syscall == "fchroot") {
19053cab2bb3Spatrick    pcmd("/* Nothing to do */")
19063cab2bb3Spatrick  } else if (syscall == "compat_30_fhopen") {
19073cab2bb3Spatrick    pcmd("/* TODO */")
19083cab2bb3Spatrick  } else if (syscall == "compat_30_fhstat") {
19093cab2bb3Spatrick    pcmd("/* TODO */")
19103cab2bb3Spatrick  } else if (syscall == "compat_20_fhstatfs") {
19113cab2bb3Spatrick    pcmd("/* TODO */")
19123cab2bb3Spatrick  } else if (syscall == "compat_50_____semctl13") {
19133cab2bb3Spatrick    pcmd("/* TODO */")
19143cab2bb3Spatrick  } else if (syscall == "compat_50___msgctl13") {
19153cab2bb3Spatrick    pcmd("/* TODO */")
19163cab2bb3Spatrick  } else if (syscall == "compat_50___shmctl13") {
19173cab2bb3Spatrick    pcmd("/* TODO */")
19183cab2bb3Spatrick  } else if (syscall == "lchflags") {
19193cab2bb3Spatrick    if (mode == "pre") {
19203cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
19213cab2bb3Spatrick      pcmd("if (path) {")
19223cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
19233cab2bb3Spatrick      pcmd("}")
19243cab2bb3Spatrick    } else {
19253cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
19263cab2bb3Spatrick      pcmd("if (path) {")
19273cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
19283cab2bb3Spatrick      pcmd("}")
19293cab2bb3Spatrick    }
19303cab2bb3Spatrick  } else if (syscall == "issetugid") {
19313cab2bb3Spatrick    pcmd("/* Nothing to do */")
19323cab2bb3Spatrick  } else if (syscall == "utrace") {
19333cab2bb3Spatrick    if (mode == "pre") {
19343cab2bb3Spatrick      pcmd("const char *label = (const char *)label_;")
19353cab2bb3Spatrick      pcmd("if (label) {")
19363cab2bb3Spatrick      pcmd("  PRE_READ(label, __sanitizer::internal_strlen(label) + 1);")
19373cab2bb3Spatrick      pcmd("}")
19383cab2bb3Spatrick      pcmd("if (addr_) {")
19393cab2bb3Spatrick      pcmd("  PRE_READ(addr_, len_);")
19403cab2bb3Spatrick      pcmd("}")
19413cab2bb3Spatrick    } else {
19423cab2bb3Spatrick      pcmd("const char *label = (const char *)label_;")
19433cab2bb3Spatrick      pcmd("if (label) {")
19443cab2bb3Spatrick      pcmd("  POST_READ(label, __sanitizer::internal_strlen(label) + 1);")
19453cab2bb3Spatrick      pcmd("}")
19463cab2bb3Spatrick      pcmd("if (addr_) {")
19473cab2bb3Spatrick      pcmd("  POST_READ(addr_, len_);")
19483cab2bb3Spatrick      pcmd("}")
19493cab2bb3Spatrick    }
19503cab2bb3Spatrick  } else if (syscall == "getcontext") {
19513cab2bb3Spatrick    pcmd("/* Nothing to do */")
19523cab2bb3Spatrick  } else if (syscall == "setcontext") {
19533cab2bb3Spatrick    if (mode == "pre") {
19543cab2bb3Spatrick      pcmd("if (ucp_) {")
19553cab2bb3Spatrick      pcmd("  PRE_READ(ucp_, ucontext_t_sz);")
19563cab2bb3Spatrick      pcmd("}")
19573cab2bb3Spatrick    }
19583cab2bb3Spatrick  } else if (syscall == "_lwp_create") {
19593cab2bb3Spatrick    if (mode == "pre") {
19603cab2bb3Spatrick      pcmd("if (ucp_) {")
19613cab2bb3Spatrick      pcmd("  PRE_READ(ucp_, ucontext_t_sz);")
19623cab2bb3Spatrick      pcmd("}")
19633cab2bb3Spatrick    }
19643cab2bb3Spatrick  } else if (syscall == "_lwp_exit") {
19653cab2bb3Spatrick    pcmd("/* Nothing to do */")
19663cab2bb3Spatrick  } else if (syscall == "_lwp_self") {
19673cab2bb3Spatrick    pcmd("/* Nothing to do */")
19683cab2bb3Spatrick  } else if (syscall == "_lwp_wait") {
19693cab2bb3Spatrick    pcmd("/* Nothing to do */")
19703cab2bb3Spatrick  } else if (syscall == "_lwp_suspend") {
19713cab2bb3Spatrick    pcmd("/* Nothing to do */")
19723cab2bb3Spatrick  } else if (syscall == "_lwp_continue") {
19733cab2bb3Spatrick    pcmd("/* Nothing to do */")
19743cab2bb3Spatrick  } else if (syscall == "_lwp_wakeup") {
19753cab2bb3Spatrick    pcmd("/* Nothing to do */")
19763cab2bb3Spatrick  } else if (syscall == "_lwp_getprivate") {
19773cab2bb3Spatrick    pcmd("/* Nothing to do */")
19783cab2bb3Spatrick  } else if (syscall == "_lwp_setprivate") {
19793cab2bb3Spatrick    pcmd("/* Nothing to do */")
19803cab2bb3Spatrick  } else if (syscall == "_lwp_kill") {
19813cab2bb3Spatrick    pcmd("/* Nothing to do */")
19823cab2bb3Spatrick  } else if (syscall == "_lwp_detach") {
19833cab2bb3Spatrick    pcmd("/* Nothing to do */")
19843cab2bb3Spatrick  } else if (syscall == "compat_50__lwp_park") {
19853cab2bb3Spatrick    pcmd("/* TODO */")
19863cab2bb3Spatrick  } else if (syscall == "_lwp_unpark") {
19873cab2bb3Spatrick    pcmd("/* Nothing to do */")
19883cab2bb3Spatrick  } else if (syscall == "_lwp_unpark_all") {
19893cab2bb3Spatrick    if (mode == "pre") {
19903cab2bb3Spatrick      pcmd("if (targets_) {")
19913cab2bb3Spatrick      pcmd("  PRE_READ(targets_, ntargets_ * sizeof(__sanitizer_lwpid_t));")
19923cab2bb3Spatrick      pcmd("}")
19933cab2bb3Spatrick    }
19943cab2bb3Spatrick  } else if (syscall == "_lwp_setname") {
19953cab2bb3Spatrick    if (mode == "pre") {
19963cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
19973cab2bb3Spatrick      pcmd("if (name) {")
19983cab2bb3Spatrick      pcmd("  PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
19993cab2bb3Spatrick      pcmd("}")
20003cab2bb3Spatrick    } else {
20013cab2bb3Spatrick      pcmd("const char *name = (const char *)name_;")
20023cab2bb3Spatrick      pcmd("if (name) {")
20033cab2bb3Spatrick      pcmd("  POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
20043cab2bb3Spatrick      pcmd("}")
20053cab2bb3Spatrick    }
20063cab2bb3Spatrick  } else if (syscall == "_lwp_getname") {
20073cab2bb3Spatrick    pcmd("/* Nothing to do */")
20083cab2bb3Spatrick  } else if (syscall == "_lwp_ctl") {
20093cab2bb3Spatrick    pcmd("/* Nothing to do */")
20103cab2bb3Spatrick  } else if (syscall == "compat_60_sa_register") {
20113cab2bb3Spatrick    pcmd("/* TODO */")
20123cab2bb3Spatrick  } else if (syscall == "compat_60_sa_stacks") {
20133cab2bb3Spatrick    pcmd("/* TODO */")
20143cab2bb3Spatrick  } else if (syscall == "compat_60_sa_enable") {
20153cab2bb3Spatrick    pcmd("/* TODO */")
20163cab2bb3Spatrick  } else if (syscall == "compat_60_sa_setconcurrency") {
20173cab2bb3Spatrick    pcmd("/* TODO */")
20183cab2bb3Spatrick  } else if (syscall == "compat_60_sa_yield") {
20193cab2bb3Spatrick    pcmd("/* TODO */")
20203cab2bb3Spatrick  } else if (syscall == "compat_60_sa_preempt") {
20213cab2bb3Spatrick    pcmd("/* TODO */")
20223cab2bb3Spatrick  } else if (syscall == "__sigaction_sigtramp") {
20233cab2bb3Spatrick    pcmd("if (nsa_) {")
20243cab2bb3Spatrick    pcmd("  PRE_READ(nsa_, sizeof(__sanitizer_sigaction));")
20253cab2bb3Spatrick    pcmd("}")
20263cab2bb3Spatrick  } else if (syscall == "rasctl") {
20273cab2bb3Spatrick    pcmd("/* Nothing to do */")
20283cab2bb3Spatrick  } else if (syscall == "kqueue") {
20293cab2bb3Spatrick    pcmd("/* Nothing to do */")
20303cab2bb3Spatrick  } else if (syscall == "compat_50_kevent") {
20313cab2bb3Spatrick    pcmd("/* TODO */")
20323cab2bb3Spatrick  } else if (syscall == "_sched_setparam") {
20333cab2bb3Spatrick    pcmd("if (params_) {")
20343cab2bb3Spatrick    pcmd("  PRE_READ(params_, struct_sched_param_sz);")
20353cab2bb3Spatrick    pcmd("}")
20363cab2bb3Spatrick  } else if (syscall == "_sched_getparam") {
20373cab2bb3Spatrick    pcmd("/* Nothing to do */")
20383cab2bb3Spatrick  } else if (syscall == "_sched_setaffinity") {
20393cab2bb3Spatrick    pcmd("if (cpuset_) {")
20403cab2bb3Spatrick    pcmd("  PRE_READ(cpuset_, size_);")
20413cab2bb3Spatrick    pcmd("}")
20423cab2bb3Spatrick  } else if (syscall == "_sched_getaffinity") {
20433cab2bb3Spatrick    pcmd("/* Nothing to do */")
20443cab2bb3Spatrick  } else if (syscall == "sched_yield") {
20453cab2bb3Spatrick    pcmd("/* Nothing to do */")
20463cab2bb3Spatrick  } else if (syscall == "_sched_protect") {
20473cab2bb3Spatrick    pcmd("/* Nothing to do */")
20483cab2bb3Spatrick  } else if (syscall == "fsync_range") {
20493cab2bb3Spatrick    pcmd("/* Nothing to do */")
20503cab2bb3Spatrick  } else if (syscall == "uuidgen") {
20513cab2bb3Spatrick    pcmd("/* Nothing to do */")
20523cab2bb3Spatrick  } else if (syscall == "compat_90_getvfsstat") {
20533cab2bb3Spatrick    pcmd("/* Nothing to do */")
20543cab2bb3Spatrick  } else if (syscall == "compat_90_statvfs1") {
20553cab2bb3Spatrick    if (mode == "pre") {
20563cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
20573cab2bb3Spatrick      pcmd("if (path) {")
20583cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
20593cab2bb3Spatrick      pcmd("}")
20603cab2bb3Spatrick    } else {
20613cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
20623cab2bb3Spatrick      pcmd("if (path) {")
20633cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
20643cab2bb3Spatrick      pcmd("}")
20653cab2bb3Spatrick    }
20663cab2bb3Spatrick  } else if (syscall == "compat_90_fstatvfs1") {
20673cab2bb3Spatrick    pcmd("/* Nothing to do */")
20683cab2bb3Spatrick  } else if (syscall == "compat_30_fhstatvfs1") {
20693cab2bb3Spatrick    pcmd("/* TODO */")
20703cab2bb3Spatrick  } else if (syscall == "extattrctl") {
20713cab2bb3Spatrick    if (mode == "pre") {
20723cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
20733cab2bb3Spatrick      pcmd("if (path) {")
20743cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
20753cab2bb3Spatrick      pcmd("}")
20763cab2bb3Spatrick    } else {
20773cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
20783cab2bb3Spatrick      pcmd("if (path) {")
20793cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
20803cab2bb3Spatrick      pcmd("}")
20813cab2bb3Spatrick    }
20823cab2bb3Spatrick  } else if (syscall == "extattr_set_file") {
20833cab2bb3Spatrick    if (mode == "pre") {
20843cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
20853cab2bb3Spatrick      pcmd("if (path) {")
20863cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
20873cab2bb3Spatrick      pcmd("}")
20883cab2bb3Spatrick    } else {
20893cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
20903cab2bb3Spatrick      pcmd("if (path) {")
20913cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
20923cab2bb3Spatrick      pcmd("}")
20933cab2bb3Spatrick    }
20943cab2bb3Spatrick  } else if (syscall == "extattr_get_file") {
20953cab2bb3Spatrick    if (mode == "pre") {
20963cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
20973cab2bb3Spatrick      pcmd("if (path) {")
20983cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
20993cab2bb3Spatrick      pcmd("}")
21003cab2bb3Spatrick    } else {
21013cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21023cab2bb3Spatrick      pcmd("if (path) {")
21033cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
21043cab2bb3Spatrick      pcmd("}")
21053cab2bb3Spatrick    }
21063cab2bb3Spatrick  } else if (syscall == "extattr_delete_file") {
21073cab2bb3Spatrick    if (mode == "pre") {
21083cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21093cab2bb3Spatrick      pcmd("if (path) {")
21103cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
21113cab2bb3Spatrick      pcmd("}")
21123cab2bb3Spatrick    } else {
21133cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21143cab2bb3Spatrick      pcmd("if (path) {")
21153cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
21163cab2bb3Spatrick      pcmd("}")
21173cab2bb3Spatrick    }
21183cab2bb3Spatrick  } else if (syscall == "extattr_set_fd") {
21193cab2bb3Spatrick    pcmd("/* TODO */")
21203cab2bb3Spatrick  } else if (syscall == "extattr_get_fd") {
21213cab2bb3Spatrick    pcmd("/* TODO */")
21223cab2bb3Spatrick  } else if (syscall == "extattr_delete_fd") {
21233cab2bb3Spatrick    pcmd("/* TODO */")
21243cab2bb3Spatrick  } else if (syscall == "extattr_set_link") {
21253cab2bb3Spatrick    if (mode == "pre") {
21263cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21273cab2bb3Spatrick      pcmd("if (path) {")
21283cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
21293cab2bb3Spatrick      pcmd("}")
21303cab2bb3Spatrick    } else {
21313cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21323cab2bb3Spatrick      pcmd("if (path) {")
21333cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
21343cab2bb3Spatrick      pcmd("}")
21353cab2bb3Spatrick    }
21363cab2bb3Spatrick  } else if (syscall == "extattr_get_link") {
21373cab2bb3Spatrick    if (mode == "pre") {
21383cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21393cab2bb3Spatrick      pcmd("if (path) {")
21403cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
21413cab2bb3Spatrick      pcmd("}")
21423cab2bb3Spatrick    } else {
21433cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21443cab2bb3Spatrick      pcmd("if (path) {")
21453cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
21463cab2bb3Spatrick      pcmd("}")
21473cab2bb3Spatrick    }
21483cab2bb3Spatrick  } else if (syscall == "extattr_delete_link") {
21493cab2bb3Spatrick    if (mode == "pre") {
21503cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21513cab2bb3Spatrick      pcmd("if (path) {")
21523cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
21533cab2bb3Spatrick      pcmd("}")
21543cab2bb3Spatrick    } else {
21553cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21563cab2bb3Spatrick      pcmd("if (path) {")
21573cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
21583cab2bb3Spatrick      pcmd("}")
21593cab2bb3Spatrick    }
21603cab2bb3Spatrick  } else if (syscall == "extattr_list_fd") {
21613cab2bb3Spatrick    pcmd("/* TODO */")
21623cab2bb3Spatrick  } else if (syscall == "extattr_list_file") {
21633cab2bb3Spatrick    if (mode == "pre") {
21643cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21653cab2bb3Spatrick      pcmd("if (path) {")
21663cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
21673cab2bb3Spatrick      pcmd("}")
21683cab2bb3Spatrick    } else {
21693cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21703cab2bb3Spatrick      pcmd("if (path) {")
21713cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
21723cab2bb3Spatrick      pcmd("}")
21733cab2bb3Spatrick    }
21743cab2bb3Spatrick  } else if (syscall == "extattr_list_link") {
21753cab2bb3Spatrick    if (mode == "pre") {
21763cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21773cab2bb3Spatrick      pcmd("if (path) {")
21783cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
21793cab2bb3Spatrick      pcmd("}")
21803cab2bb3Spatrick    } else {
21813cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21823cab2bb3Spatrick      pcmd("if (path) {")
21833cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
21843cab2bb3Spatrick      pcmd("}")
21853cab2bb3Spatrick    }
21863cab2bb3Spatrick  } else if (syscall == "compat_50_pselect") {
21873cab2bb3Spatrick    pcmd("/* TODO */")
21883cab2bb3Spatrick  } else if (syscall == "compat_50_pollts") {
21893cab2bb3Spatrick    pcmd("/* TODO */")
21903cab2bb3Spatrick  } else if (syscall == "setxattr") {
21913cab2bb3Spatrick    if (mode == "pre") {
21923cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21933cab2bb3Spatrick      pcmd("if (path) {")
21943cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
21953cab2bb3Spatrick      pcmd("}")
21963cab2bb3Spatrick    } else {
21973cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
21983cab2bb3Spatrick      pcmd("if (path) {")
21993cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22003cab2bb3Spatrick      pcmd("}")
22013cab2bb3Spatrick    }
22023cab2bb3Spatrick  } else if (syscall == "lsetxattr") {
22033cab2bb3Spatrick    if (mode == "pre") {
22043cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22053cab2bb3Spatrick      pcmd("if (path) {")
22063cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
22073cab2bb3Spatrick      pcmd("}")
22083cab2bb3Spatrick    } else {
22093cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22103cab2bb3Spatrick      pcmd("if (path) {")
22113cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22123cab2bb3Spatrick      pcmd("}")
22133cab2bb3Spatrick    }
22143cab2bb3Spatrick  } else if (syscall == "fsetxattr") {
22153cab2bb3Spatrick    pcmd("/* Nothing to do */")
22163cab2bb3Spatrick  } else if (syscall == "getxattr") {
22173cab2bb3Spatrick    if (mode == "pre") {
22183cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22193cab2bb3Spatrick      pcmd("if (path) {")
22203cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
22213cab2bb3Spatrick      pcmd("}")
22223cab2bb3Spatrick    } else {
22233cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22243cab2bb3Spatrick      pcmd("if (path) {")
22253cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22263cab2bb3Spatrick      pcmd("}")
22273cab2bb3Spatrick    }
22283cab2bb3Spatrick  } else if (syscall == "lgetxattr") {
22293cab2bb3Spatrick    if (mode == "pre") {
22303cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22313cab2bb3Spatrick      pcmd("if (path) {")
22323cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
22333cab2bb3Spatrick      pcmd("}")
22343cab2bb3Spatrick    } else {
22353cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22363cab2bb3Spatrick      pcmd("if (path) {")
22373cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22383cab2bb3Spatrick      pcmd("}")
22393cab2bb3Spatrick    }
22403cab2bb3Spatrick  } else if (syscall == "fgetxattr") {
22413cab2bb3Spatrick    pcmd("/* Nothing to do */")
22423cab2bb3Spatrick  } else if (syscall == "listxattr") {
22433cab2bb3Spatrick    if (mode == "pre") {
22443cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22453cab2bb3Spatrick      pcmd("if (path) {")
22463cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
22473cab2bb3Spatrick      pcmd("}")
22483cab2bb3Spatrick    } else {
22493cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22503cab2bb3Spatrick      pcmd("if (path) {")
22513cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22523cab2bb3Spatrick      pcmd("}")
22533cab2bb3Spatrick    }
22543cab2bb3Spatrick  } else if (syscall == "llistxattr") {
22553cab2bb3Spatrick    if (mode == "pre") {
22563cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22573cab2bb3Spatrick      pcmd("if (path) {")
22583cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
22593cab2bb3Spatrick      pcmd("}")
22603cab2bb3Spatrick    } else {
22613cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22623cab2bb3Spatrick      pcmd("if (path) {")
22633cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22643cab2bb3Spatrick      pcmd("}")
22653cab2bb3Spatrick    }
22663cab2bb3Spatrick  } else if (syscall == "flistxattr") {
22673cab2bb3Spatrick    pcmd("/* TODO */")
22683cab2bb3Spatrick  } else if (syscall == "removexattr") {
22693cab2bb3Spatrick    if (mode == "pre") {
22703cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22713cab2bb3Spatrick      pcmd("if (path) {")
22723cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
22733cab2bb3Spatrick      pcmd("}")
22743cab2bb3Spatrick    } else {
22753cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22763cab2bb3Spatrick      pcmd("if (path) {")
22773cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22783cab2bb3Spatrick      pcmd("}")
22793cab2bb3Spatrick    }
22803cab2bb3Spatrick  } else if (syscall == "lremovexattr") {
22813cab2bb3Spatrick    if (mode == "pre") {
22823cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22833cab2bb3Spatrick      pcmd("if (path) {")
22843cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
22853cab2bb3Spatrick      pcmd("}")
22863cab2bb3Spatrick    } else {
22873cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
22883cab2bb3Spatrick      pcmd("if (path) {")
22893cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
22903cab2bb3Spatrick      pcmd("}")
22913cab2bb3Spatrick    }
22923cab2bb3Spatrick  } else if (syscall == "fremovexattr") {
22933cab2bb3Spatrick    pcmd("/* TODO */")
22943cab2bb3Spatrick  } else if (syscall == "compat_50___stat30") {
22953cab2bb3Spatrick    pcmd("/* TODO */")
22963cab2bb3Spatrick  } else if (syscall == "compat_50___fstat30") {
22973cab2bb3Spatrick    pcmd("/* TODO */")
22983cab2bb3Spatrick  } else if (syscall == "compat_50___lstat30") {
22993cab2bb3Spatrick    pcmd("/* TODO */")
23003cab2bb3Spatrick  } else if (syscall == "__getdents30") {
23013cab2bb3Spatrick    pcmd("/* Nothing to do */")
23023cab2bb3Spatrick  } else if (syscall == "posix_fadvise") {
23033cab2bb3Spatrick    pcmd("/* Nothing to do */")
23043cab2bb3Spatrick  } else if (syscall == "compat_30___fhstat30") {
23053cab2bb3Spatrick    pcmd("/* TODO */")
23063cab2bb3Spatrick  } else if (syscall == "compat_50___ntp_gettime30") {
23073cab2bb3Spatrick    pcmd("/* TODO */")
23083cab2bb3Spatrick  } else if (syscall == "__socket30") {
23093cab2bb3Spatrick    pcmd("/* Nothing to do */")
23103cab2bb3Spatrick  } else if (syscall == "__getfh30") {
23113cab2bb3Spatrick    if (mode == "pre") {
23123cab2bb3Spatrick      pcmd("const char *fname = (const char *)fname_;")
23133cab2bb3Spatrick      pcmd("if (fname) {")
23143cab2bb3Spatrick      pcmd("  PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
23153cab2bb3Spatrick      pcmd("}")
23163cab2bb3Spatrick    } else {
23173cab2bb3Spatrick      pcmd("const char *fname = (const char *)fname_;")
23183cab2bb3Spatrick      pcmd("if (res == 0) {")
23193cab2bb3Spatrick      pcmd("  if (fname) {")
23203cab2bb3Spatrick      pcmd("    POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
23213cab2bb3Spatrick      pcmd("  }")
23223cab2bb3Spatrick      pcmd("}")
23233cab2bb3Spatrick    }
23243cab2bb3Spatrick  } else if (syscall == "__fhopen40") {
23253cab2bb3Spatrick    if (mode == "pre") {
23263cab2bb3Spatrick      pcmd("if (fhp_) {")
23273cab2bb3Spatrick      pcmd("  PRE_READ(fhp_, fh_size_);")
23283cab2bb3Spatrick      pcmd("}")
23293cab2bb3Spatrick    }
23303cab2bb3Spatrick  } else if (syscall == "compat_90_fhstatvfs1") {
23313cab2bb3Spatrick    if (mode == "pre") {
23323cab2bb3Spatrick      pcmd("if (fhp_) {")
23333cab2bb3Spatrick      pcmd("  PRE_READ(fhp_, fh_size_);")
23343cab2bb3Spatrick      pcmd("}")
23353cab2bb3Spatrick    }
23363cab2bb3Spatrick  } else if (syscall == "compat_50___fhstat40") {
23373cab2bb3Spatrick    if (mode == "pre") {
23383cab2bb3Spatrick      pcmd("if (fhp_) {")
23393cab2bb3Spatrick      pcmd("  PRE_READ(fhp_, fh_size_);")
23403cab2bb3Spatrick      pcmd("}")
23413cab2bb3Spatrick    }
23423cab2bb3Spatrick  } else if (syscall == "aio_cancel") {
23433cab2bb3Spatrick    if (mode == "pre") {
23443cab2bb3Spatrick      pcmd("if (aiocbp_) {")
23453cab2bb3Spatrick      pcmd("  PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
23463cab2bb3Spatrick      pcmd("}")
23473cab2bb3Spatrick    }
23483cab2bb3Spatrick  } else if (syscall == "aio_error") {
23493cab2bb3Spatrick    if (mode == "pre") {
23503cab2bb3Spatrick      pcmd("if (aiocbp_) {")
23513cab2bb3Spatrick      pcmd("  PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
23523cab2bb3Spatrick      pcmd("}")
23533cab2bb3Spatrick    }
23543cab2bb3Spatrick  } else if (syscall == "aio_fsync") {
23553cab2bb3Spatrick    if (mode == "pre") {
23563cab2bb3Spatrick      pcmd("if (aiocbp_) {")
23573cab2bb3Spatrick      pcmd("  PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
23583cab2bb3Spatrick      pcmd("}")
23593cab2bb3Spatrick    }
23603cab2bb3Spatrick  } else if (syscall == "aio_read") {
23613cab2bb3Spatrick    if (mode == "pre") {
23623cab2bb3Spatrick      pcmd("if (aiocbp_) {")
23633cab2bb3Spatrick      pcmd("  PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
23643cab2bb3Spatrick      pcmd("}")
23653cab2bb3Spatrick    }
23663cab2bb3Spatrick  } else if (syscall == "aio_return") {
23673cab2bb3Spatrick    if (mode == "pre") {
23683cab2bb3Spatrick      pcmd("if (aiocbp_) {")
23693cab2bb3Spatrick      pcmd("  PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
23703cab2bb3Spatrick      pcmd("}")
23713cab2bb3Spatrick    }
23723cab2bb3Spatrick  } else if (syscall == "compat_50_aio_suspend") {
23733cab2bb3Spatrick    pcmd("/* TODO */")
23743cab2bb3Spatrick  } else if (syscall == "aio_write") {
23753cab2bb3Spatrick    if (mode == "pre") {
23763cab2bb3Spatrick      pcmd("if (aiocbp_) {")
23773cab2bb3Spatrick      pcmd("  PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
23783cab2bb3Spatrick      pcmd("}")
23793cab2bb3Spatrick    }
23803cab2bb3Spatrick  } else if (syscall == "lio_listio") {
23813cab2bb3Spatrick    pcmd("/* Nothing to do */")
23823cab2bb3Spatrick  } else if (syscall == "__mount50") {
23833cab2bb3Spatrick    if (mode == "pre") {
23843cab2bb3Spatrick      pcmd("const char *type = (const char *)type_;")
23853cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
23863cab2bb3Spatrick      pcmd("if (type) {")
23873cab2bb3Spatrick      pcmd("  PRE_READ(type, __sanitizer::internal_strlen(type) + 1);")
23883cab2bb3Spatrick      pcmd("}")
23893cab2bb3Spatrick      pcmd("if (path) {")
23903cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
23913cab2bb3Spatrick      pcmd("}")
23923cab2bb3Spatrick      pcmd("if (data_) {")
23933cab2bb3Spatrick      pcmd("  PRE_READ(data_, data_len_);")
23943cab2bb3Spatrick      pcmd("}")
23953cab2bb3Spatrick    } else {
23963cab2bb3Spatrick      pcmd("const char *type = (const char *)type_;")
23973cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
23983cab2bb3Spatrick      pcmd("if (type) {")
23993cab2bb3Spatrick      pcmd("  POST_READ(type, __sanitizer::internal_strlen(type) + 1);")
24003cab2bb3Spatrick      pcmd("}")
24013cab2bb3Spatrick      pcmd("if (path) {")
24023cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
24033cab2bb3Spatrick      pcmd("}")
24043cab2bb3Spatrick      pcmd("if (data_) {")
24053cab2bb3Spatrick      pcmd("  POST_READ(data_, data_len_);")
24063cab2bb3Spatrick      pcmd("}")
24073cab2bb3Spatrick    }
24083cab2bb3Spatrick  } else if (syscall == "mremap") {
24093cab2bb3Spatrick    pcmd("/* Nothing to do */")
24103cab2bb3Spatrick  } else if (syscall == "pset_create") {
24113cab2bb3Spatrick    pcmd("/* Nothing to do */")
24123cab2bb3Spatrick  } else if (syscall == "pset_destroy") {
24133cab2bb3Spatrick    pcmd("/* Nothing to do */")
24143cab2bb3Spatrick  } else if (syscall == "pset_assign") {
24153cab2bb3Spatrick    pcmd("/* Nothing to do */")
24163cab2bb3Spatrick  } else if (syscall == "_pset_bind") {
24173cab2bb3Spatrick    pcmd("/* Nothing to do */")
24183cab2bb3Spatrick  } else if (syscall == "__posix_fadvise50") {
24193cab2bb3Spatrick    pcmd("/* Nothing to do */")
24203cab2bb3Spatrick  } else if (syscall == "__select50") {
24213cab2bb3Spatrick    pcmd("/* Nothing to do */")
24223cab2bb3Spatrick  } else if (syscall == "__gettimeofday50") {
24233cab2bb3Spatrick    pcmd("/* Nothing to do */")
24243cab2bb3Spatrick  } else if (syscall == "__settimeofday50") {
24253cab2bb3Spatrick    if (mode == "pre") {
24263cab2bb3Spatrick      pcmd("if (tv_) {")
24273cab2bb3Spatrick      pcmd("  PRE_READ(tv_, timeval_sz);")
24283cab2bb3Spatrick      pcmd("}")
24293cab2bb3Spatrick      pcmd("if (tzp_) {")
24303cab2bb3Spatrick      pcmd("  PRE_READ(tzp_, struct_timezone_sz);")
24313cab2bb3Spatrick      pcmd("}")
24323cab2bb3Spatrick    }
24333cab2bb3Spatrick  } else if (syscall == "__utimes50") {
24343cab2bb3Spatrick    if (mode == "pre") {
24353cab2bb3Spatrick      pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
24363cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
24373cab2bb3Spatrick      pcmd("if (path) {")
24383cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
24393cab2bb3Spatrick      pcmd("}")
24403cab2bb3Spatrick      pcmd("if (tptr) {")
24413cab2bb3Spatrick      pcmd("  PRE_READ(tptr[0], struct_timespec_sz);")
24423cab2bb3Spatrick      pcmd("  PRE_READ(tptr[1], struct_timespec_sz);")
24433cab2bb3Spatrick      pcmd("}")
24443cab2bb3Spatrick    }
24453cab2bb3Spatrick  } else if (syscall == "__adjtime50") {
24463cab2bb3Spatrick    if (mode == "pre") {
24473cab2bb3Spatrick      pcmd("if (delta_) {")
24483cab2bb3Spatrick      pcmd("  PRE_READ(delta_, timeval_sz);")
24493cab2bb3Spatrick      pcmd("}")
24503cab2bb3Spatrick    }
24513cab2bb3Spatrick  } else if (syscall == "__lfs_segwait50") {
24523cab2bb3Spatrick    pcmd("/* TODO */")
24533cab2bb3Spatrick  } else if (syscall == "__futimes50") {
24543cab2bb3Spatrick    if (mode == "pre") {
24553cab2bb3Spatrick      pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
24563cab2bb3Spatrick      pcmd("if (tptr) {")
24573cab2bb3Spatrick      pcmd("  PRE_READ(tptr[0], struct_timespec_sz);")
24583cab2bb3Spatrick      pcmd("  PRE_READ(tptr[1], struct_timespec_sz);")
24593cab2bb3Spatrick      pcmd("}")
24603cab2bb3Spatrick    }
24613cab2bb3Spatrick  } else if (syscall == "__lutimes50") {
24623cab2bb3Spatrick    if (mode == "pre") {
24633cab2bb3Spatrick      pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
24643cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
24653cab2bb3Spatrick      pcmd("if (path) {")
24663cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
24673cab2bb3Spatrick      pcmd("}")
24683cab2bb3Spatrick      pcmd("if (tptr) {")
24693cab2bb3Spatrick      pcmd("  PRE_READ(tptr[0], struct_timespec_sz);")
24703cab2bb3Spatrick      pcmd("  PRE_READ(tptr[1], struct_timespec_sz);")
24713cab2bb3Spatrick      pcmd("}")
24723cab2bb3Spatrick    } else {
24733cab2bb3Spatrick      pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
24743cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
24753cab2bb3Spatrick      pcmd("if (path) {")
24763cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
24773cab2bb3Spatrick      pcmd("}")
24783cab2bb3Spatrick      pcmd("if (tptr) {")
24793cab2bb3Spatrick      pcmd("  POST_READ(tptr[0], struct_timespec_sz);")
24803cab2bb3Spatrick      pcmd("  POST_READ(tptr[1], struct_timespec_sz);")
24813cab2bb3Spatrick      pcmd("}")
24823cab2bb3Spatrick    }
24833cab2bb3Spatrick  } else if (syscall == "__setitimer50") {
24843cab2bb3Spatrick    if (mode == "pre") {
24853cab2bb3Spatrick      pcmd("struct __sanitizer_itimerval *itv = (struct __sanitizer_itimerval *)itv_;")
24863cab2bb3Spatrick      pcmd("if (itv) {")
24873cab2bb3Spatrick      pcmd("  PRE_READ(&itv->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
24883cab2bb3Spatrick      pcmd("  PRE_READ(&itv->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
24893cab2bb3Spatrick      pcmd("  PRE_READ(&itv->it_value.tv_sec, sizeof(__sanitizer_time_t));")
24903cab2bb3Spatrick      pcmd("  PRE_READ(&itv->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
24913cab2bb3Spatrick      pcmd("}")
24923cab2bb3Spatrick    }
24933cab2bb3Spatrick  } else if (syscall == "__getitimer50") {
24943cab2bb3Spatrick    pcmd("/* Nothing to do */")
24953cab2bb3Spatrick  } else if (syscall == "__clock_gettime50") {
24963cab2bb3Spatrick    pcmd("/* Nothing to do */")
24973cab2bb3Spatrick  } else if (syscall == "__clock_settime50") {
24983cab2bb3Spatrick    if (mode == "pre") {
24993cab2bb3Spatrick      pcmd("if (tp_) {")
25003cab2bb3Spatrick      pcmd("  PRE_READ(tp_, struct_timespec_sz);")
25013cab2bb3Spatrick      pcmd("}")
25023cab2bb3Spatrick    }
25033cab2bb3Spatrick  } else if (syscall == "__clock_getres50") {
25043cab2bb3Spatrick    pcmd("/* Nothing to do */")
25053cab2bb3Spatrick  } else if (syscall == "__nanosleep50") {
25063cab2bb3Spatrick    if (mode == "pre") {
25073cab2bb3Spatrick      pcmd("if (rqtp_) {")
25083cab2bb3Spatrick      pcmd("  PRE_READ(rqtp_, struct_timespec_sz);")
25093cab2bb3Spatrick      pcmd("}")
25103cab2bb3Spatrick    }
25113cab2bb3Spatrick  } else if (syscall == "____sigtimedwait50") {
25123cab2bb3Spatrick    if (mode == "pre") {
25133cab2bb3Spatrick      pcmd("if (set_) {")
25143cab2bb3Spatrick      pcmd("  PRE_READ(set_, sizeof(__sanitizer_sigset_t));")
25153cab2bb3Spatrick      pcmd("}")
25163cab2bb3Spatrick      pcmd("if (timeout_) {")
25173cab2bb3Spatrick      pcmd("  PRE_READ(timeout_, struct_timespec_sz);")
25183cab2bb3Spatrick      pcmd("}")
25193cab2bb3Spatrick    }
25203cab2bb3Spatrick  } else if (syscall == "__mq_timedsend50") {
25213cab2bb3Spatrick    if (mode == "pre") {
25223cab2bb3Spatrick      pcmd("if (msg_ptr_) {")
25233cab2bb3Spatrick      pcmd("  PRE_READ(msg_ptr_, msg_len_);")
25243cab2bb3Spatrick      pcmd("}")
25253cab2bb3Spatrick      pcmd("if (abs_timeout_) {")
25263cab2bb3Spatrick      pcmd("  PRE_READ(abs_timeout_, struct_timespec_sz);")
25273cab2bb3Spatrick      pcmd("}")
25283cab2bb3Spatrick    }
25293cab2bb3Spatrick  } else if (syscall == "__mq_timedreceive50") {
25303cab2bb3Spatrick    if (mode == "pre") {
25313cab2bb3Spatrick      pcmd("if (msg_ptr_) {")
25323cab2bb3Spatrick      pcmd("  PRE_READ(msg_ptr_, msg_len_);")
25333cab2bb3Spatrick      pcmd("}")
25343cab2bb3Spatrick      pcmd("if (abs_timeout_) {")
25353cab2bb3Spatrick      pcmd("  PRE_READ(abs_timeout_, struct_timespec_sz);")
25363cab2bb3Spatrick      pcmd("}")
25373cab2bb3Spatrick    }
25383cab2bb3Spatrick  } else if (syscall == "compat_60__lwp_park") {
25393cab2bb3Spatrick    pcmd("/* TODO */")
25403cab2bb3Spatrick  } else if (syscall == "__kevent50") {
25413cab2bb3Spatrick    if (mode == "pre") {
25423cab2bb3Spatrick      pcmd("if (changelist_) {")
25433cab2bb3Spatrick      pcmd("  PRE_READ(changelist_, nchanges_ * struct_kevent_sz);")
25443cab2bb3Spatrick      pcmd("}")
25453cab2bb3Spatrick      pcmd("if (timeout_) {")
25463cab2bb3Spatrick      pcmd("  PRE_READ(timeout_, struct_timespec_sz);")
25473cab2bb3Spatrick      pcmd("}")
25483cab2bb3Spatrick    }
25493cab2bb3Spatrick  } else if (syscall == "__pselect50") {
25503cab2bb3Spatrick    if (mode == "pre") {
25513cab2bb3Spatrick      pcmd("if (ts_) {")
25523cab2bb3Spatrick      pcmd("  PRE_READ(ts_, struct_timespec_sz);")
25533cab2bb3Spatrick      pcmd("}")
25543cab2bb3Spatrick      pcmd("if (mask_) {")
25553cab2bb3Spatrick      pcmd("  PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));")
25563cab2bb3Spatrick      pcmd("}")
25573cab2bb3Spatrick    }
25583cab2bb3Spatrick  } else if (syscall == "__pollts50") {
25593cab2bb3Spatrick    if (mode == "pre") {
25603cab2bb3Spatrick      pcmd("if (ts_) {")
25613cab2bb3Spatrick      pcmd("  PRE_READ(ts_, struct_timespec_sz);")
25623cab2bb3Spatrick      pcmd("}")
25633cab2bb3Spatrick      pcmd("if (mask_) {")
25643cab2bb3Spatrick      pcmd("  PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));")
25653cab2bb3Spatrick      pcmd("}")
25663cab2bb3Spatrick    }
25673cab2bb3Spatrick  } else if (syscall == "__aio_suspend50") {
25683cab2bb3Spatrick    if (mode == "pre") {
25693cab2bb3Spatrick      pcmd("int i;")
25703cab2bb3Spatrick      pcmd("const struct aiocb * const *list = (const struct aiocb * const *)list_;")
25713cab2bb3Spatrick      pcmd("if (list) {")
25723cab2bb3Spatrick      pcmd("  for (i = 0; i < nent_; i++) {")
25733cab2bb3Spatrick      pcmd("    if (list[i]) {")
25743cab2bb3Spatrick      pcmd("      PRE_READ(list[i], sizeof(struct __sanitizer_aiocb));")
25753cab2bb3Spatrick      pcmd("    }")
25763cab2bb3Spatrick      pcmd("  }")
25773cab2bb3Spatrick      pcmd("}")
25783cab2bb3Spatrick      pcmd("if (timeout_) {")
25793cab2bb3Spatrick      pcmd("  PRE_READ(timeout_, struct_timespec_sz);")
25803cab2bb3Spatrick      pcmd("}")
25813cab2bb3Spatrick    }
25823cab2bb3Spatrick  } else if (syscall == "__stat50") {
25833cab2bb3Spatrick    if (mode == "pre") {
25843cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
25853cab2bb3Spatrick      pcmd("if (path) {")
25863cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
25873cab2bb3Spatrick      pcmd("}")
25883cab2bb3Spatrick    } else {
25893cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
25903cab2bb3Spatrick      pcmd("if (res == 0) {")
25913cab2bb3Spatrick      pcmd("  if (path) {")
25923cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
25933cab2bb3Spatrick      pcmd("  }")
25943cab2bb3Spatrick      pcmd("}")
25953cab2bb3Spatrick    }
25963cab2bb3Spatrick  } else if (syscall == "__fstat50") {
25973cab2bb3Spatrick    pcmd("/* Nothing to do */")
25983cab2bb3Spatrick  } else if (syscall == "__lstat50") {
25993cab2bb3Spatrick    if (mode == "pre") {
26003cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
26013cab2bb3Spatrick      pcmd("if (path) {")
26023cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
26033cab2bb3Spatrick      pcmd("}")
26043cab2bb3Spatrick    } else {
26053cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
26063cab2bb3Spatrick      pcmd("if (res == 0) {")
26073cab2bb3Spatrick      pcmd("  if (path) {")
26083cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
26093cab2bb3Spatrick      pcmd("  }")
26103cab2bb3Spatrick      pcmd("}")
26113cab2bb3Spatrick    }
26123cab2bb3Spatrick  } else if (syscall == "____semctl50") {
26133cab2bb3Spatrick    pcmd("/* Nothing to do */")
26143cab2bb3Spatrick  } else if (syscall == "__shmctl50") {
26153cab2bb3Spatrick    pcmd("/* Nothing to do */")
26163cab2bb3Spatrick  } else if (syscall == "__msgctl50") {
26173cab2bb3Spatrick    pcmd("/* Nothing to do */")
26183cab2bb3Spatrick  } else if (syscall == "__getrusage50") {
26193cab2bb3Spatrick    pcmd("/* Nothing to do */")
26203cab2bb3Spatrick  } else if (syscall == "__timer_settime50") {
26213cab2bb3Spatrick    if (mode == "pre") {
26223cab2bb3Spatrick      pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;")
26233cab2bb3Spatrick      pcmd("if (value) {")
26243cab2bb3Spatrick      pcmd("  PRE_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
26253cab2bb3Spatrick      pcmd("  PRE_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
26263cab2bb3Spatrick      pcmd("  PRE_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));")
26273cab2bb3Spatrick      pcmd("  PRE_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
26283cab2bb3Spatrick      pcmd("}")
26293cab2bb3Spatrick    } else {
26303cab2bb3Spatrick      pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;")
26313cab2bb3Spatrick      pcmd("if (res == 0) {")
26323cab2bb3Spatrick      pcmd("  if (value) {")
26333cab2bb3Spatrick      pcmd("    POST_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
26343cab2bb3Spatrick      pcmd("    POST_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
26353cab2bb3Spatrick      pcmd("    POST_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));")
26363cab2bb3Spatrick      pcmd("    POST_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
26373cab2bb3Spatrick      pcmd("  }")
26383cab2bb3Spatrick      pcmd("}")
26393cab2bb3Spatrick    }
26403cab2bb3Spatrick  } else if (syscall == "__timer_gettime50") {
26413cab2bb3Spatrick    pcmd("/* Nothing to do */")
26423cab2bb3Spatrick  } else if (syscall == "__ntp_gettime50") {
26433cab2bb3Spatrick    pcmd("/* Nothing to do */")
26443cab2bb3Spatrick  } else if (syscall == "__wait450") {
26453cab2bb3Spatrick    pcmd("/* Nothing to do */")
26463cab2bb3Spatrick  } else if (syscall == "__mknod50") {
26473cab2bb3Spatrick    if (mode == "pre") {
26483cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
26493cab2bb3Spatrick      pcmd("if (path) {")
26503cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
26513cab2bb3Spatrick      pcmd("}")
26523cab2bb3Spatrick    } else {
26533cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
26543cab2bb3Spatrick      pcmd("if (res == 0) {")
26553cab2bb3Spatrick      pcmd("  if (path) {")
26563cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
26573cab2bb3Spatrick      pcmd("  }")
26583cab2bb3Spatrick      pcmd("}")
26593cab2bb3Spatrick    }
26603cab2bb3Spatrick  } else if (syscall == "__fhstat50") {
26613cab2bb3Spatrick    if (mode == "pre") {
26623cab2bb3Spatrick      pcmd("if (fhp_) {")
26633cab2bb3Spatrick      pcmd("  PRE_READ(fhp_, fh_size_);")
26643cab2bb3Spatrick      pcmd("}")
26653cab2bb3Spatrick    } else {
26663cab2bb3Spatrick      pcmd("if (res == 0) {")
26673cab2bb3Spatrick      pcmd("  if (fhp_) {")
26683cab2bb3Spatrick      pcmd("    POST_READ(fhp_, fh_size_);")
26693cab2bb3Spatrick      pcmd("  }")
26703cab2bb3Spatrick      pcmd("}")
26713cab2bb3Spatrick    }
26723cab2bb3Spatrick  } else if (syscall == "pipe2") {
26733cab2bb3Spatrick    pcmd("/* Nothing to do */")
26743cab2bb3Spatrick  } else if (syscall == "dup3") {
26753cab2bb3Spatrick    pcmd("/* Nothing to do */")
26763cab2bb3Spatrick  } else if (syscall == "kqueue1") {
26773cab2bb3Spatrick    pcmd("/* Nothing to do */")
26783cab2bb3Spatrick  } else if (syscall == "paccept") {
26793cab2bb3Spatrick    if (mode == "pre") {
26803cab2bb3Spatrick      pcmd("if (mask_) {")
26813cab2bb3Spatrick      pcmd("  PRE_READ(mask_, sizeof(__sanitizer_sigset_t));")
26823cab2bb3Spatrick      pcmd("}")
26833cab2bb3Spatrick    } else {
26843cab2bb3Spatrick      pcmd("if (res >= 0) {")
26853cab2bb3Spatrick      pcmd("  if (mask_) {")
26863cab2bb3Spatrick      pcmd("    PRE_READ(mask_, sizeof(__sanitizer_sigset_t));")
26873cab2bb3Spatrick      pcmd("  }")
26883cab2bb3Spatrick      pcmd("}")
26893cab2bb3Spatrick    }
26903cab2bb3Spatrick  } else if (syscall == "linkat") {
26913cab2bb3Spatrick    if (mode == "pre") {
26923cab2bb3Spatrick      pcmd("const char *name1 = (const char *)name1_;")
26933cab2bb3Spatrick      pcmd("const char *name2 = (const char *)name2_;")
26943cab2bb3Spatrick      pcmd("if (name1) {")
26953cab2bb3Spatrick      pcmd("  PRE_READ(name1, __sanitizer::internal_strlen(name1) + 1);")
26963cab2bb3Spatrick      pcmd("}")
26973cab2bb3Spatrick      pcmd("if (name2) {")
26983cab2bb3Spatrick      pcmd("  PRE_READ(name2, __sanitizer::internal_strlen(name2) + 1);")
26993cab2bb3Spatrick      pcmd("}")
27003cab2bb3Spatrick    } else {
27013cab2bb3Spatrick      pcmd("const char *name1 = (const char *)name1_;")
27023cab2bb3Spatrick      pcmd("const char *name2 = (const char *)name2_;")
27033cab2bb3Spatrick      pcmd("if (res == 0) {")
27043cab2bb3Spatrick      pcmd("  if (name1) {")
27053cab2bb3Spatrick      pcmd("    POST_READ(name1, __sanitizer::internal_strlen(name1) + 1);")
27063cab2bb3Spatrick      pcmd("  }")
27073cab2bb3Spatrick      pcmd("  if (name2) {")
27083cab2bb3Spatrick      pcmd("    POST_READ(name2, __sanitizer::internal_strlen(name2) + 1);")
27093cab2bb3Spatrick      pcmd("  }")
27103cab2bb3Spatrick      pcmd("}")
27113cab2bb3Spatrick    }
27123cab2bb3Spatrick  } else if (syscall == "renameat") {
27133cab2bb3Spatrick    if (mode == "pre") {
27143cab2bb3Spatrick      pcmd("const char *from = (const char *)from_;")
27153cab2bb3Spatrick      pcmd("const char *to = (const char *)to_;")
27163cab2bb3Spatrick      pcmd("if (from) {")
27173cab2bb3Spatrick      pcmd("  PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
27183cab2bb3Spatrick      pcmd("}")
27193cab2bb3Spatrick      pcmd("if (to) {")
27203cab2bb3Spatrick      pcmd("  PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
27213cab2bb3Spatrick      pcmd("}")
27223cab2bb3Spatrick    } else {
27233cab2bb3Spatrick      pcmd("const char *from = (const char *)from_;")
27243cab2bb3Spatrick      pcmd("const char *to = (const char *)to_;")
27253cab2bb3Spatrick      pcmd("if (res == 0) {")
27263cab2bb3Spatrick      pcmd("  if (from) {")
27273cab2bb3Spatrick      pcmd("    POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
27283cab2bb3Spatrick      pcmd("  }")
27293cab2bb3Spatrick      pcmd("  if (to) {")
27303cab2bb3Spatrick      pcmd("    POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
27313cab2bb3Spatrick      pcmd("  }")
27323cab2bb3Spatrick      pcmd("}")
27333cab2bb3Spatrick    }
27343cab2bb3Spatrick  } else if (syscall == "mkfifoat") {
27353cab2bb3Spatrick    if (mode == "pre") {
27363cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27373cab2bb3Spatrick      pcmd("if (path) {")
27383cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
27393cab2bb3Spatrick      pcmd("}")
27403cab2bb3Spatrick    } else {
27413cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27423cab2bb3Spatrick      pcmd("if (res == 0) {")
27433cab2bb3Spatrick      pcmd("  if (path) {")
27443cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
27453cab2bb3Spatrick      pcmd("  }")
27463cab2bb3Spatrick      pcmd("}")
27473cab2bb3Spatrick    }
27483cab2bb3Spatrick  } else if (syscall == "mknodat") {
27493cab2bb3Spatrick    if (mode == "pre") {
27503cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27513cab2bb3Spatrick      pcmd("if (path) {")
27523cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
27533cab2bb3Spatrick      pcmd("}")
27543cab2bb3Spatrick    } else {
27553cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27563cab2bb3Spatrick      pcmd("if (res == 0) {")
27573cab2bb3Spatrick      pcmd("  if (path) {")
27583cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
27593cab2bb3Spatrick      pcmd("  }")
27603cab2bb3Spatrick      pcmd("}")
27613cab2bb3Spatrick    }
27623cab2bb3Spatrick  } else if (syscall == "mkdirat") {
27633cab2bb3Spatrick    if (mode == "pre") {
27643cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27653cab2bb3Spatrick      pcmd("if (path) {")
27663cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
27673cab2bb3Spatrick      pcmd("}")
27683cab2bb3Spatrick    } else {
27693cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27703cab2bb3Spatrick      pcmd("if (res == 0) {")
27713cab2bb3Spatrick      pcmd("  if (path) {")
27723cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
27733cab2bb3Spatrick      pcmd("  }")
27743cab2bb3Spatrick      pcmd("}")
27753cab2bb3Spatrick    }
27763cab2bb3Spatrick  } else if (syscall == "faccessat") {
27773cab2bb3Spatrick    if (mode == "pre") {
27783cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27793cab2bb3Spatrick      pcmd("if (path) {")
27803cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
27813cab2bb3Spatrick      pcmd("}")
27823cab2bb3Spatrick    } else {
27833cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27843cab2bb3Spatrick      pcmd("if (res == 0) {")
27853cab2bb3Spatrick      pcmd("  if (path) {")
27863cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
27873cab2bb3Spatrick      pcmd("  }")
27883cab2bb3Spatrick      pcmd("}")
27893cab2bb3Spatrick    }
27903cab2bb3Spatrick  } else if (syscall == "fchmodat") {
27913cab2bb3Spatrick    if (mode == "pre") {
27923cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27933cab2bb3Spatrick      pcmd("if (path) {")
27943cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
27953cab2bb3Spatrick      pcmd("}")
27963cab2bb3Spatrick    } else {
27973cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
27983cab2bb3Spatrick      pcmd("if (res == 0) {")
27993cab2bb3Spatrick      pcmd("  if (path) {")
28003cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
28013cab2bb3Spatrick      pcmd("  }")
28023cab2bb3Spatrick      pcmd("}")
28033cab2bb3Spatrick    }
28043cab2bb3Spatrick  } else if (syscall == "fchownat") {
28053cab2bb3Spatrick    if (mode == "pre") {
28063cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28073cab2bb3Spatrick      pcmd("if (path) {")
28083cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
28093cab2bb3Spatrick      pcmd("}")
28103cab2bb3Spatrick    } else {
28113cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28123cab2bb3Spatrick      pcmd("if (res == 0) {")
28133cab2bb3Spatrick      pcmd("  if (path) {")
28143cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
28153cab2bb3Spatrick      pcmd("  }")
28163cab2bb3Spatrick      pcmd("}")
28173cab2bb3Spatrick    }
28183cab2bb3Spatrick  } else if (syscall == "fexecve") {
28193cab2bb3Spatrick    pcmd("/* TODO */")
28203cab2bb3Spatrick  } else if (syscall == "fstatat") {
28213cab2bb3Spatrick    if (mode == "pre") {
28223cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28233cab2bb3Spatrick      pcmd("if (path) {")
28243cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
28253cab2bb3Spatrick      pcmd("}")
28263cab2bb3Spatrick    } else {
28273cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28283cab2bb3Spatrick      pcmd("if (path) {")
28293cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
28303cab2bb3Spatrick      pcmd("}")
28313cab2bb3Spatrick    }
28323cab2bb3Spatrick  } else if (syscall == "utimensat") {
28333cab2bb3Spatrick    if (mode == "pre") {
28343cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28353cab2bb3Spatrick      pcmd("if (path) {")
28363cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
28373cab2bb3Spatrick      pcmd("}")
28383cab2bb3Spatrick      pcmd("if (tptr_) {")
28393cab2bb3Spatrick      pcmd("  PRE_READ(tptr_, struct_timespec_sz);")
28403cab2bb3Spatrick      pcmd("}")
28413cab2bb3Spatrick    } else {
28423cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28433cab2bb3Spatrick      pcmd("if (res > 0) {")
28443cab2bb3Spatrick      pcmd("  if (path) {")
28453cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
28463cab2bb3Spatrick      pcmd("  }")
28473cab2bb3Spatrick      pcmd("  if (tptr_) {")
28483cab2bb3Spatrick      pcmd("    POST_READ(tptr_, struct_timespec_sz);")
28493cab2bb3Spatrick      pcmd("  }")
28503cab2bb3Spatrick      pcmd("}")
28513cab2bb3Spatrick    }
28523cab2bb3Spatrick  } else if (syscall == "openat") {
28533cab2bb3Spatrick    if (mode == "pre") {
28543cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28553cab2bb3Spatrick      pcmd("if (path) {")
28563cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
28573cab2bb3Spatrick      pcmd("}")
28583cab2bb3Spatrick    } else {
28593cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28603cab2bb3Spatrick      pcmd("if (res > 0) {")
28613cab2bb3Spatrick      pcmd("  if (path) {")
28623cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
28633cab2bb3Spatrick      pcmd("  }")
28643cab2bb3Spatrick      pcmd("}")
28653cab2bb3Spatrick    }
28663cab2bb3Spatrick  } else if (syscall == "readlinkat") {
28673cab2bb3Spatrick    if (mode == "pre") {
28683cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28693cab2bb3Spatrick      pcmd("if (path) {")
28703cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
28713cab2bb3Spatrick      pcmd("}")
28723cab2bb3Spatrick    } else {
28733cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
28743cab2bb3Spatrick      pcmd("if (res > 0) {")
28753cab2bb3Spatrick      pcmd("  if (path) {")
28763cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
28773cab2bb3Spatrick      pcmd("  }")
28783cab2bb3Spatrick      pcmd("}")
28793cab2bb3Spatrick    }
28803cab2bb3Spatrick  } else if (syscall == "symlinkat") {
28813cab2bb3Spatrick    if (mode == "pre") {
28823cab2bb3Spatrick      pcmd("const char *path1 = (const char *)path1_;")
28833cab2bb3Spatrick      pcmd("const char *path2 = (const char *)path2_;")
28843cab2bb3Spatrick      pcmd("if (path1) {")
28853cab2bb3Spatrick      pcmd("  PRE_READ(path1, __sanitizer::internal_strlen(path1) + 1);")
28863cab2bb3Spatrick      pcmd("}")
28873cab2bb3Spatrick      pcmd("if (path2) {")
28883cab2bb3Spatrick      pcmd("  PRE_READ(path2, __sanitizer::internal_strlen(path2) + 1);")
28893cab2bb3Spatrick      pcmd("}")
28903cab2bb3Spatrick    } else {
28913cab2bb3Spatrick      pcmd("const char *path1 = (const char *)path1_;")
28923cab2bb3Spatrick      pcmd("const char *path2 = (const char *)path2_;")
28933cab2bb3Spatrick      pcmd("if (res == 0) {")
28943cab2bb3Spatrick      pcmd("  if (path1) {")
28953cab2bb3Spatrick      pcmd("    POST_READ(path1, __sanitizer::internal_strlen(path1) + 1);")
28963cab2bb3Spatrick      pcmd("  }")
28973cab2bb3Spatrick      pcmd("  if (path2) {")
28983cab2bb3Spatrick      pcmd("    POST_READ(path2, __sanitizer::internal_strlen(path2) + 1);")
28993cab2bb3Spatrick      pcmd("  }")
29003cab2bb3Spatrick      pcmd("}")
29013cab2bb3Spatrick    }
29023cab2bb3Spatrick  } else if (syscall == "unlinkat") {
29033cab2bb3Spatrick    if (mode == "pre") {
29043cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
29053cab2bb3Spatrick      pcmd("if (path) {")
29063cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
29073cab2bb3Spatrick      pcmd("}")
29083cab2bb3Spatrick    } else {
29093cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
29103cab2bb3Spatrick      pcmd("if (res == 0) {")
29113cab2bb3Spatrick      pcmd("  if (path) {")
29123cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
29133cab2bb3Spatrick      pcmd("  }")
29143cab2bb3Spatrick      pcmd("}")
29153cab2bb3Spatrick    }
29163cab2bb3Spatrick  } else if (syscall == "futimens") {
29173cab2bb3Spatrick    if (mode == "pre") {
29183cab2bb3Spatrick      pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
29193cab2bb3Spatrick      pcmd("if (tptr) {")
29203cab2bb3Spatrick      pcmd("  PRE_READ(tptr[0], struct_timespec_sz);")
29213cab2bb3Spatrick      pcmd("  PRE_READ(tptr[1], struct_timespec_sz);")
29223cab2bb3Spatrick      pcmd("}")
29233cab2bb3Spatrick    } else {
29243cab2bb3Spatrick      pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
29253cab2bb3Spatrick      pcmd("if (res == 0) {")
29263cab2bb3Spatrick      pcmd("  if (tptr) {")
29273cab2bb3Spatrick      pcmd("    POST_READ(tptr[0], struct_timespec_sz);")
29283cab2bb3Spatrick      pcmd("    POST_READ(tptr[1], struct_timespec_sz);")
29293cab2bb3Spatrick      pcmd("  }")
29303cab2bb3Spatrick      pcmd("}")
29313cab2bb3Spatrick    }
29323cab2bb3Spatrick  } else if (syscall == "__quotactl") {
29333cab2bb3Spatrick    if (mode == "pre") {
29343cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
29353cab2bb3Spatrick      pcmd("if (path) {")
29363cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
29373cab2bb3Spatrick      pcmd("}")
29383cab2bb3Spatrick    } else {
29393cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
29403cab2bb3Spatrick      pcmd("if (res == 0) {")
29413cab2bb3Spatrick      pcmd("  if (path) {")
29423cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
29433cab2bb3Spatrick      pcmd("  }")
29443cab2bb3Spatrick      pcmd("}")
29453cab2bb3Spatrick    }
29463cab2bb3Spatrick  } else if (syscall == "posix_spawn") {
29473cab2bb3Spatrick    if (mode == "pre") {
29483cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
29493cab2bb3Spatrick      pcmd("if (path) {")
29503cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
29513cab2bb3Spatrick      pcmd("}")
29523cab2bb3Spatrick    } else {
29533cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
29543cab2bb3Spatrick      pcmd("if (pid_) {")
29553cab2bb3Spatrick      pcmd("  if (path) {")
29563cab2bb3Spatrick      pcmd("    POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
29573cab2bb3Spatrick      pcmd("  }")
29583cab2bb3Spatrick      pcmd("}")
29593cab2bb3Spatrick    }
29603cab2bb3Spatrick  } else if (syscall == "recvmmsg") {
29613cab2bb3Spatrick    if (mode == "pre") {
29623cab2bb3Spatrick      pcmd("if (timeout_) {")
29633cab2bb3Spatrick      pcmd("  PRE_READ(timeout_, struct_timespec_sz);")
29643cab2bb3Spatrick      pcmd("}")
29653cab2bb3Spatrick    } else {
29663cab2bb3Spatrick      pcmd("if (res >= 0) {")
29673cab2bb3Spatrick      pcmd("  if (timeout_) {")
29683cab2bb3Spatrick      pcmd("    POST_READ(timeout_, struct_timespec_sz);")
29693cab2bb3Spatrick      pcmd("  }")
29703cab2bb3Spatrick      pcmd("}")
29713cab2bb3Spatrick    }
29723cab2bb3Spatrick  } else if (syscall == "sendmmsg") {
29733cab2bb3Spatrick    if (mode == "pre") {
29743cab2bb3Spatrick      pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
29753cab2bb3Spatrick      pcmd("if (mmsg) {")
29763cab2bb3Spatrick      pcmd("  PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));")
29773cab2bb3Spatrick      pcmd("}")
29783cab2bb3Spatrick    } else {
29793cab2bb3Spatrick      pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
29803cab2bb3Spatrick      pcmd("if (res >= 0) {")
29813cab2bb3Spatrick      pcmd("  if (mmsg) {")
29823cab2bb3Spatrick      pcmd("    POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));")
29833cab2bb3Spatrick      pcmd("  }")
29843cab2bb3Spatrick      pcmd("}")
29853cab2bb3Spatrick    }
29863cab2bb3Spatrick  } else if (syscall == "clock_nanosleep") {
29873cab2bb3Spatrick    if (mode == "pre") {
29883cab2bb3Spatrick      pcmd("if (rqtp_) {")
29893cab2bb3Spatrick      pcmd("  PRE_READ(rqtp_, struct_timespec_sz);")
29903cab2bb3Spatrick      pcmd("}")
29913cab2bb3Spatrick    } else {
29923cab2bb3Spatrick      pcmd("if (rqtp_) {")
29933cab2bb3Spatrick      pcmd("  POST_READ(rqtp_, struct_timespec_sz);")
29943cab2bb3Spatrick      pcmd("}")
29953cab2bb3Spatrick    }
29963cab2bb3Spatrick  } else if (syscall == "___lwp_park60") {
29973cab2bb3Spatrick    if (mode == "pre") {
29983cab2bb3Spatrick      pcmd("if (ts_) {")
29993cab2bb3Spatrick      pcmd("  PRE_READ(ts_, struct_timespec_sz);")
30003cab2bb3Spatrick      pcmd("}")
30013cab2bb3Spatrick    } else {
30023cab2bb3Spatrick      pcmd("if (res == 0) {")
30033cab2bb3Spatrick      pcmd("  if (ts_) {")
30043cab2bb3Spatrick      pcmd("    POST_READ(ts_, struct_timespec_sz);")
30053cab2bb3Spatrick      pcmd("  }")
30063cab2bb3Spatrick      pcmd("}")
30073cab2bb3Spatrick    }
30083cab2bb3Spatrick  } else if (syscall == "posix_fallocate") {
30093cab2bb3Spatrick    pcmd("/* Nothing to do */")
30103cab2bb3Spatrick  } else if (syscall == "fdiscard") {
30113cab2bb3Spatrick    pcmd("/* Nothing to do */")
30123cab2bb3Spatrick  } else if (syscall == "wait6") {
30133cab2bb3Spatrick    pcmd("/* Nothing to do */")
30143cab2bb3Spatrick  } else if (syscall == "clock_getcpuclockid2") {
30153cab2bb3Spatrick    pcmd("/* Nothing to do */")
30163cab2bb3Spatrick  } else if (syscall == "__getvfsstat90") {
30173cab2bb3Spatrick    pcmd("/* Nothing to do */")
30183cab2bb3Spatrick  } else if (syscall == "__statvfs190") {
30193cab2bb3Spatrick    if (mode == "pre") {
30203cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
30213cab2bb3Spatrick      pcmd("if (path) {")
30223cab2bb3Spatrick      pcmd("  PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
30233cab2bb3Spatrick      pcmd("}")
30243cab2bb3Spatrick    } else {
30253cab2bb3Spatrick      pcmd("const char *path = (const char *)path_;")
30263cab2bb3Spatrick      pcmd("if (path) {")
30273cab2bb3Spatrick      pcmd("  POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
30283cab2bb3Spatrick      pcmd("}")
30293cab2bb3Spatrick    }
30303cab2bb3Spatrick  } else if (syscall == "__fstatvfs190") {
30313cab2bb3Spatrick    pcmd("/* Nothing to do */")
30323cab2bb3Spatrick  } else if (syscall == "__fhstatvfs190") {
30333cab2bb3Spatrick    if (mode == "pre") {
30343cab2bb3Spatrick      pcmd("if (fhp_) {")
30353cab2bb3Spatrick      pcmd("  PRE_READ(fhp_, fh_size_);")
30363cab2bb3Spatrick      pcmd("}")
30373cab2bb3Spatrick    }
3038d89ec533Spatrick  } else if (syscall == "__acl_get_link") {
3039d89ec533Spatrick    pcmd("/* TODO */")
3040d89ec533Spatrick  } else if (syscall == "__acl_set_link") {
3041d89ec533Spatrick    pcmd("/* TODO */")
3042d89ec533Spatrick  } else if (syscall == "__acl_delete_link") {
3043d89ec533Spatrick    pcmd("/* TODO */")
3044d89ec533Spatrick  } else if (syscall == "__acl_aclcheck_link") {
3045d89ec533Spatrick    pcmd("/* TODO */")
3046d89ec533Spatrick  } else if (syscall == "__acl_get_file") {
3047d89ec533Spatrick    pcmd("/* TODO */")
3048d89ec533Spatrick  } else if (syscall == "__acl_set_file") {
3049d89ec533Spatrick    pcmd("/* TODO */")
3050d89ec533Spatrick  } else if (syscall == "__acl_get_fd") {
3051d89ec533Spatrick    pcmd("/* TODO */")
3052d89ec533Spatrick  } else if (syscall == "__acl_set_fd") {
3053d89ec533Spatrick    pcmd("/* TODO */")
3054d89ec533Spatrick  } else if (syscall == "__acl_delete_file") {
3055d89ec533Spatrick    pcmd("/* TODO */")
3056d89ec533Spatrick  } else if (syscall == "__acl_delete_fd") {
3057d89ec533Spatrick    pcmd("/* TODO */")
3058d89ec533Spatrick  } else if (syscall == "__acl_aclcheck_file") {
3059d89ec533Spatrick    pcmd("/* TODO */")
3060d89ec533Spatrick  } else if (syscall == "__acl_aclcheck_fd") {
3061d89ec533Spatrick    pcmd("/* TODO */")
3062d89ec533Spatrick  } else if (syscall == "lpathconf") {
3063d89ec533Spatrick    pcmd("/* TODO */")
30643cab2bb3Spatrick  } else {
30653cab2bb3Spatrick    print "Unrecognized syscall: " syscall
30663cab2bb3Spatrick    abnormal_exit = 1
30673cab2bb3Spatrick    exit 1
30683cab2bb3Spatrick  }
30693cab2bb3Spatrick}
3070