1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /* ONC_PLUS EXTRACT START */
  23 
  24 /*
  25  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  26  * Copyright 2012 Milan Jurik. All rights reserved.
  27  * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
  28  */
  29 
  30 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  31 /*        All Rights Reserved   */
  32 
  33 /* ONC_PLUS EXTRACT END */
  34 
  35 #include <sys/param.h>
  36 #include <sys/types.h>
  37 #include <sys/systm.h>
  38 #include <sys/systrace.h>
  39 #include <sys/procfs.h>
  40 #include <sys/mman.h>
  41 #include <sys/int_types.h>
  42 #include <c2/audit.h>
  43 #include <sys/stat.h>
  44 #include <sys/times.h>
  45 #include <sys/statfs.h>
  46 #include <sys/stropts.h>
  47 #include <sys/statvfs.h>
  48 #include <sys/utsname.h>
  49 #include <sys/timex.h>
  50 #include <sys/socket.h>
  51 #include <sys/sendfile.h>
  52 
  53 struct hrtsysa;
  54 struct mmaplf32a;
  55 
  56 /* ONC_PLUS EXTRACT START */
  57 /*
  58  * This table is the switch used to transfer to the appropriate
  59  * routine for processing a system call.  Each row contains the
  60  * number of arguments expected, a switch that tells systrap()
  61  * in trap.c whether a setjmp() is not necessary, and a pointer
  62  * to the routine.
  63  */
  64 /* ONC_PLUS EXTRACT END */
  65 
  66 int     access(char *, int);
  67 int     alarm(int);
  68 int     auditsys(struct auditcalls *, rval_t *);
  69 int64_t brandsys(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
  70     uintptr_t);
  71 int     brk(caddr_t);
  72 int     chdir(char *);
  73 int     chmod(char *, int);
  74 int     chown(char *, uid_t, gid_t);
  75 int     chroot(char *);
  76 int     cladm(int, int, void *);
  77 int     close(int);
  78 int     exece(const char *, const char **, const char **);
  79 int     faccessat(int, char *, int, int);
  80 int     fchmodat(int, char *, int, int);
  81 int     fchownat(int, char *, uid_t, gid_t, int);
  82 int     fcntl(int, int, intptr_t);
  83 int64_t vfork();
  84 int64_t forksys(int, int);
  85 int     fstat(int, struct stat *);
  86 int     fdsync(int, int);
  87 int64_t getgid();
  88 int     ucredsys(int, int, void *);
  89 int64_t getpid();
  90 int64_t getuid();
  91 time_t  gtime();
  92 int     getloadavg(int *, int);
  93 int     rusagesys(int, void *, void *, void *, void *);
  94 int     getpagesizes(int, size_t *, int);
  95 int     gtty(int, intptr_t);
  96 #if defined(__i386) || defined(__amd64)
  97 int     hrtsys(struct hrtsysa *, rval_t *);
  98 #endif /* __i386 || __amd64 */
  99 int     ioctl(int, int, intptr_t);
 100 int     kill();
 101 int     labelsys(int, void *, void *, void *, void *, void *);
 102 int     link(char *, char *);
 103 int     linkat(int, char *, int, char *, int);
 104 off32_t lseek32(int32_t, off32_t, int32_t);
 105 off_t   lseek64(int, off_t, int);
 106 int     lgrpsys(int, long, void *);
 107 int     mmapobjsys(int, uint_t, mmapobj_result_t *, uint_t *, void *);
 108 int     mknod(char *, mode_t, dev_t);
 109 int     mknodat(int, char *, mode_t, dev_t);
 110 int     mount(long *, rval_t *);
 111 int     nice(int);
 112 int     nullsys();
 113 int     open(char *, int, int);
 114 int     openat(int, char *, int, int);
 115 int     pause();
 116 long    pcsample(void *, long);
 117 int     privsys(int, priv_op_t, priv_ptype_t, void *, size_t, int);
 118 int     profil(unsigned short *, size_t, ulong_t, uint_t);
 119 ssize_t pread(int, void *, size_t, off_t);
 120 ssize_t pwrite(int, void *, size_t, off_t);
 121 ssize_t read(int, void *, size_t);
 122 int     rename(char *, char *);
 123 int     renameat(int, char *, int, char *);
 124 void    rexit(int);
 125 int     semsys();
 126 int     setgid(gid_t);
 127 int     setpgrp(int, int, int);
 128 int     setuid(uid_t);
 129 uintptr_t       shmsys();
 130 uint64_t        sidsys(int, int, int, int);
 131 int     sigprocmask(int, sigset_t *, sigset_t *);
 132 int     sigsuspend(sigset_t);
 133 int     sigaltstack(struct sigaltstack *, struct sigaltstack *);
 134 int     sigaction(int, struct sigaction *, struct sigaction *);
 135 int     sigpending(int, sigset_t *);
 136 int     sigresend(int, siginfo_t *, sigset_t *);
 137 int     sigtimedwait(sigset_t *, siginfo_t *, timespec_t *);
 138 int     getsetcontext(int, void *);
 139 int     stat(char *, struct stat *);
 140 int     fstatat(int, char *, struct stat *, int);
 141 int     stime(time_t);
 142 int     stty(int, intptr_t);
 143 int     syssync();
 144 int     sysacct(char *);
 145 clock_t times(struct tms *);
 146 long    ulimit(int, long);
 147 int     getrlimit32(int, struct rlimit32 *);
 148 int     setrlimit32(int, struct rlimit32 *);
 149 int     umask(int);
 150 int     umount2(char *, int);
 151 int     unlink(char *);
 152 int     unlinkat(int, char *, int);
 153 int     utimesys(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
 154 int64_t utssys32(void *, int, int, void *);
 155 int64_t utssys64(void *, long, int, void *);
 156 int     uucopy(const void *, void *, size_t);
 157 ssize_t uucopystr(const char *, char *, size_t);
 158 ssize_t write(int, void *, size_t);
 159 ssize_t readv(int, struct iovec *, int);
 160 ssize_t writev(int, struct iovec *, int);
 161 int     syslwp_park(int, uintptr_t, uintptr_t);
 162 int     rmdir(char *);
 163 int     mkdir(char *, int);
 164 int     mkdirat(int, char *, int);
 165 int     getdents32(int, void *, size_t);
 166 int     statfs32(char *, struct statfs32 *, int32_t, int32_t);
 167 int     fstatfs32(int32_t, struct statfs32 *, int32_t, int32_t);
 168 int     sysfs(int, long, long);
 169 int     getmsg(int, struct strbuf *, struct strbuf *, int *);
 170 int     pollsys(pollfd_t *, nfds_t, timespec_t *, sigset_t *);
 171 int     putmsg(int, struct strbuf *, struct strbuf *, int);
 172 int     uadmin();
 173 int     lstat(char *, struct stat *);
 174 int     symlink(char *, char *);
 175 int     symlinkat(char *, int, char *);
 176 ssize_t readlink(char *, char *, size_t);
 177 ssize_t readlinkat(int, char *, char *, size_t);
 178 int     resolvepath(char *, char *, size_t);
 179 int     setgroups(int, gid_t *);
 180 int     getgroups(int, gid_t *);
 181 int     fchdir(int);
 182 int     fchown(int, uid_t, uid_t);
 183 int     fchmod(int, int);
 184 int     getcwd(char *, size_t);
 185 int     statvfs(char *, struct statvfs *);
 186 int     fstatvfs(int, struct statvfs *);
 187 offset_t llseek32(int32_t, uint32_t, uint32_t, int);
 188 
 189 #if (defined(__i386) && !defined(__amd64)) || defined(__i386_COMPAT)
 190 int     sysi86(short, uintptr_t, uintptr_t, uintptr_t);
 191 #endif
 192 
 193 int     acl(const char *, int, int, void *);
 194 int     facl(int, int, int, void *);
 195 long    priocntlsys(int, procset_t *, int, caddr_t, caddr_t);
 196 int     waitsys(idtype_t, id_t, siginfo_t *, int);
 197 int     sigsendsys(procset_t *, int);
 198 int     mincore(caddr_t, size_t, char *);
 199 caddr_t smmap64(caddr_t, size_t, int, int, int, off_t);
 200 caddr_t smmap32(caddr32_t, size32_t, int, int, int, off32_t);
 201 int     smmaplf32(struct mmaplf32a *, rval_t *);
 202 int     mprotect(caddr_t, size_t, int);
 203 int     munmap(caddr_t, size_t);
 204 int     uname(struct utsname *);
 205 int     lchown(char *, uid_t, gid_t);
 206 int     getpmsg(int, struct strbuf *, struct strbuf *, int *, int *);
 207 int     putpmsg(int, struct strbuf *, struct strbuf *, int, int);
 208 int     memcntl(caddr_t, size_t, int, caddr_t, int, int);
 209 long    sysconfig(int);
 210 int     adjtime(struct timeval *, struct timeval *);
 211 long    systeminfo(int, char *, long);
 212 int     setegid(gid_t);
 213 int     seteuid(uid_t);
 214 
 215 int     setreuid(uid_t, uid_t);
 216 int     setregid(gid_t, gid_t);
 217 int     install_utrap(utrap_entry_t type, utrap_handler_t, utrap_handler_t *);
 218 #ifdef __sparc
 219 int     sparc_utrap_install(utrap_entry_t type, utrap_handler_t,
 220     utrap_handler_t, utrap_handler_t *, utrap_handler_t *);
 221 #endif
 222 
 223 int     syslwp_create(ucontext_t *, int, id_t *);
 224 void    syslwp_exit();
 225 int     syslwp_suspend(id_t);
 226 int     syslwp_continue(id_t);
 227 int     syslwp_private(int, int, uintptr_t);
 228 int     lwp_detach(id_t);
 229 int     lwp_info(timestruc_t *);
 230 int     lwp_kill(id_t, int);
 231 int     lwp_self();
 232 int64_t lwp_sigmask(int, uint_t, uint_t, uint_t, uint_t);
 233 int     yield();
 234 int     lwp_wait(id_t, id_t *);
 235 int     lwp_mutex_timedlock(lwp_mutex_t *, timespec_t *, uintptr_t);
 236 int     lwp_mutex_wakeup(lwp_mutex_t *, int);
 237 int     lwp_mutex_unlock(lwp_mutex_t *);
 238 int     lwp_mutex_trylock(lwp_mutex_t *, uintptr_t);
 239 int     lwp_mutex_register(lwp_mutex_t *, caddr_t);
 240 int     lwp_rwlock_sys(int, lwp_rwlock_t *, timespec_t *);
 241 int     lwp_sema_post(lwp_sema_t *);
 242 int     lwp_sema_timedwait(lwp_sema_t *, timespec_t *, int);
 243 int     lwp_sema_trywait(lwp_sema_t *);
 244 int     lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *, timespec_t *, int);
 245 int     lwp_cond_signal(lwp_cond_t *);
 246 int     lwp_cond_broadcast(lwp_cond_t *);
 247 caddr_t schedctl();
 248 
 249 long    pathconf(char *, int);
 250 long    fpathconf(int, int);
 251 int     processor_bind(idtype_t, id_t, processorid_t, processorid_t *);
 252 int     processor_info(processorid_t, processor_info_t *);
 253 int     p_online(processorid_t, int);
 254 
 255 /*
 256  *      POSIX .4 system calls *
 257  */
 258 int     clock_gettime(clockid_t, timespec_t *);
 259 int     clock_settime(clockid_t, timespec_t *);
 260 int     clock_getres(clockid_t, timespec_t *);
 261 int     timer_create(clockid_t, struct sigevent *, timer_t *);
 262 int     timer_delete(timer_t);
 263 int     timer_settime(timer_t, int, itimerspec_t *, itimerspec_t *);
 264 int     timer_gettime(timer_t, itimerspec_t *);
 265 int     timer_getoverrun(timer_t);
 266 int     nanosleep(timespec_t *, timespec_t *);
 267 int     sigqueue(pid_t, int, void *, int, int);
 268 int     signotify(int, siginfo_t *, signotify_id_t *);
 269 
 270 int     getdents64(int, void *, size_t);
 271 int     stat64(char *, struct stat64 *);
 272 int     lstat64(char *, struct stat64 *);
 273 int     fstatat64(int, char *, struct stat64 *, int);
 274 int     fstat64(int, struct stat64 *);
 275 int     statvfs64(char *, struct statvfs64 *);
 276 int     fstatvfs64(int, struct statvfs64 *);
 277 int     setrlimit64(int, struct rlimit64 *);
 278 int     getrlimit64(int, struct rlimit64 *);
 279 int     pread64(int, void *, size32_t, uint32_t, uint32_t);
 280 int     pwrite64(int, void *, size32_t, uint32_t, uint32_t);
 281 int     open64(char *, int, int);
 282 int     openat64(int, char *, int, int);
 283 
 284 /*
 285  * NTP syscalls
 286  */
 287 
 288 int ntp_gettime(struct ntptimeval *);
 289 int ntp_adjtime(struct timex *);
 290 
 291 /*
 292  *      ++++++++++++++++++++++++
 293  *      ++  SunOS4.1 Buyback  ++
 294  *      ++++++++++++++++++++++++
 295  *
 296  *      fchroot, vhangup, gettimeofday
 297  */
 298 
 299 int     fchroot(int);
 300 int     vhangup();
 301 int     gettimeofday(struct timeval *);
 302 int     getitimer(uint_t, struct itimerval *);
 303 int     setitimer(uint_t, struct itimerval *, struct itimerval *);
 304 
 305 int     corectl(int, uintptr_t, uintptr_t, uintptr_t);
 306 int     modctl(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
 307 int64_t loadable_syscall();
 308 int64_t indir();
 309 
 310 long    tasksys(int, projid_t, uint_t, void *, size_t);
 311 long    rctlsys(int, char *, void *, void *, size_t, int);
 312 
 313 long    zone();
 314 
 315 int     so_socket(int, int, int, char *, int);
 316 int     so_socketpair(int[2]);
 317 int     bind(int, struct sockaddr *, socklen_t, int);
 318 int     listen(int, int, int);
 319 int     accept(int, struct sockaddr *, socklen_t *, int, int);
 320 int     connect(int, struct sockaddr *, socklen_t, int);
 321 int     shutdown(int, int, int);
 322 ssize_t recv(int, void *, size_t, int);
 323 ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
 324 ssize_t recvmsg(int, struct nmsghdr *, int);
 325 ssize_t send(int, void *, size_t, int);
 326 ssize_t sendmsg(int, struct nmsghdr *, int);
 327 ssize_t sendto(int, void *, size_t, int, struct sockaddr *, socklen_t);
 328 int     getpeername(int, struct sockaddr *, socklen_t *, int);
 329 int     getsockname(int, struct sockaddr *, socklen_t *, int);
 330 int     getsockopt(int, int, int, void *, socklen_t *, int);
 331 int     setsockopt(int, int, int, void *, socklen_t *, int);
 332 int     sockconfig(int, void *, void *, void *, void *);
 333 ssize_t sendfilev(int, int, const struct sendfilevec *, int, size_t *);
 334 
 335 typedef int64_t (*llfcn_t)();   /* for casting one-word returns */
 336 
 337 /*
 338  * Sysent initialization macros.
 339  *      These take the name string of the system call even though that isn't
 340  *      currently used in the sysent entry.  This might be useful someday.
 341  *
 342  * Initialization macro for system calls which take their args in the C style.
 343  * These system calls return the longlong_t return value and must call
 344  * set_errno() to return an error.  For SPARC, narg must be at most six.
 345  * For more args, use the SYSENT_AP() routine.
 346  *
 347  * We are able to return two distinct values to userland via the rval_t.
 348  * At this time, that corresponds to one 64-bit quantity, or two 32-bit
 349  * quantities.  The kernel does not currently need to return two 64-bit
 350  * values, or one 128 bit value(!), but we may do one day, so the calling
 351  * sequence between userland and the kernel should permit it.
 352  *
 353  * The interpretation of rval_t is provided by the sy_flags field
 354  * which is used to determine how to arrange the results in registers
 355  * (or on the stack) for return userland.
 356  */
 357         /* returns a 64-bit quantity for both ABIs */
 358 #define SYSENT_C(name, call, narg)      \
 359         { (narg), SE_64RVAL, NULL, NULL, (llfcn_t)(call) }
 360 
 361         /* returns one 32-bit value for both ABIs: r_val1 */
 362 #define SYSENT_CI(name, call, narg)     \
 363         { (narg), SE_32RVAL1, NULL, NULL, (llfcn_t)(call) }
 364 
 365         /* returns 2 32-bit values: r_val1 & r_val2 */
 366 #define SYSENT_2CI(name, call, narg)    \
 367         { (narg), SE_32RVAL1|SE_32RVAL2, NULL, NULL, (llfcn_t)(call) }
 368 
 369 /*
 370  * Initialization macro for system calls which take their args in the standard
 371  * Unix style of a pointer to the arg structure and a pointer to the rval_t.
 372  *
 373  * Deprecated wherever possible (slower on some architectures, and trickier
 374  * to maintain two flavours).
 375  */
 376 #define SYSENT_AP(name, call, narg)     \
 377         { (narg), SE_64RVAL, (call), NULL, syscall_ap }
 378 
 379 /*
 380  * Conditional constructors to build the tables without #ifdef clutter
 381  */
 382 #if defined(_LP64)
 383 #define IF_LP64(true, false)    true
 384 #else
 385 #define IF_LP64(true, false)    false
 386 #endif
 387 
 388 #if defined(__sparc)
 389 #define IF_sparc(true, false)   true
 390 #else
 391 #define IF_sparc(true, false)   false
 392 #endif
 393 
 394 #if defined(__i386) && !defined(__amd64)
 395 #define IF_i386(true, false)    true
 396 #else
 397 #define IF_i386(true, false)    false
 398 #endif
 399 
 400 #if defined(__i386) || defined(__amd64)
 401 #define IF_x86(true, false)     true
 402 #else
 403 #define IF_x86(true, false)     false
 404 #endif
 405 
 406 #if (defined(__i386) && !defined(__amd64)) || defined(__i386_COMPAT)
 407 #define IF_386_ABI(true, false) true
 408 #else
 409 #define IF_386_ABI(true, false) false
 410 #endif
 411 
 412 /*
 413  * Define system calls that return a native 'long' quantity i.e. a 32-bit
 414  * or 64-bit integer - depending on how the kernel is itself compiled
 415  * e.g. read(2) returns 'ssize_t' in the kernel and in userland.
 416  */
 417 #define SYSENT_CL(name, call, narg)     \
 418         IF_LP64(SYSENT_C(name, call, narg), SYSENT_CI(name, call, narg))
 419 
 420 /*
 421  * Initialization macro for loadable native system calls.
 422  */
 423 #define SYSENT_LOADABLE()       \
 424         { 0, SE_LOADABLE, (int (*)())nosys, NULL, loadable_syscall }
 425 /* ONC_PLUS EXTRACT END */
 426 
 427 /*
 428  * Initialization macro for loadable 32-bit compatibility system calls.
 429  */
 430 #define SYSENT_LOADABLE32()     SYSENT_LOADABLE()
 431 
 432 #define SYSENT_NOSYS()          SYSENT_C("nosys", nosys, 0)
 433 
 434 struct sysent nosys_ent = SYSENT_NOSYS();
 435 
 436 /* ONC_PLUS EXTRACT START */
 437 /*
 438  * Native sysent table.
 439  */
 440 struct sysent sysent[NSYSCALL] =
 441 {
 442 /* ONC_PLUS EXTRACT END */
 443         /*  0 */ IF_LP64(
 444                         SYSENT_NOSYS(),
 445                         SYSENT_C("indir",       indir,          1)),
 446         /*  1 */ SYSENT_CI("exit",              rexit,          1),
 447         /*  2 */ SYSENT_LOADABLE(),                     /* (was forkall) */
 448         /*  3 */ SYSENT_CL("read",              read,           3),
 449         /*  4 */ SYSENT_CL("write",             write,          3),
 450         /*  5 */ SYSENT_CI("open",              open,           3),
 451         /*  6 */ SYSENT_CI("close",             close,          1),
 452         /*  7 */ SYSENT_CI("linkat",            linkat,         5),
 453         /*  8 */ SYSENT_LOADABLE(),                     /* (was creat) */
 454         /*  9 */ SYSENT_CI("link",              link,           2),
 455         /* 10 */ SYSENT_CI("unlink",            unlink,         1),
 456         /* 11 */ SYSENT_CI("symlinkat",         symlinkat,      3),
 457         /* 12 */ SYSENT_CI("chdir",             chdir,          1),
 458         /* 13 */ SYSENT_CL("time",              gtime,          0),
 459         /* 14 */ SYSENT_CI("mknod",             mknod,          3),
 460         /* 15 */ SYSENT_CI("chmod",             chmod,          2),
 461         /* 16 */ SYSENT_CI("chown",             chown,          3),
 462         /* 17 */ SYSENT_CI("brk",               brk,            1),
 463         /* 18 */ SYSENT_CI("stat",              stat,           2),
 464         /* 19 */ IF_LP64(
 465                         SYSENT_CL("lseek",      lseek64,        3),
 466                         SYSENT_CL("lseek",      lseek32,        3)),
 467         /* 20 */ SYSENT_2CI("getpid",           getpid,         0),
 468         /* 21 */ SYSENT_AP("mount",             mount,          8),
 469         /* 22 */ SYSENT_CL("readlinkat",        readlinkat,     4),
 470         /* 23 */ SYSENT_CI("setuid",            setuid,         1),
 471         /* 24 */ SYSENT_2CI("getuid",           getuid,         0),
 472         /* 25 */ SYSENT_CI("stime",             stime,          1),
 473         /* 26 */ SYSENT_CL("pcsample",          pcsample,       2),
 474         /* 27 */ SYSENT_CI("alarm",             alarm,          1),
 475         /* 28 */ SYSENT_CI("fstat",             fstat,          2),
 476         /* 29 */ SYSENT_CI("pause",             pause,          0),
 477         /* 30 */ SYSENT_LOADABLE(),                     /* (was utime) */
 478         /* 31 */ SYSENT_CI("stty",              stty,           2),
 479         /* 32 */ SYSENT_CI("gtty",              gtty,           2),
 480         /* 33 */ SYSENT_CI("access",            access,         2),
 481         /* 34 */ SYSENT_CI("nice",              nice,           1),
 482         /* 35 */ IF_LP64(
 483                         SYSENT_NOSYS(),
 484                         SYSENT_CI("statfs",     statfs32,       4)),
 485         /* 36 */ SYSENT_CI("sync",              syssync,        0),
 486         /* 37 */ SYSENT_CI("kill",              kill,           2),
 487         /* 38 */ IF_LP64(
 488                         SYSENT_NOSYS(),
 489                         SYSENT_CI("fstatfs",    fstatfs32,      4)),
 490         /* 39 */ SYSENT_CI("setpgrp",           setpgrp,        3),
 491         /* 40 */ SYSENT_CI("uucopystr",         uucopystr,      3),
 492         /* 41 */ SYSENT_LOADABLE(),                     /* (was dup) */
 493         /* 42 */ SYSENT_LOADABLE(),                     /* pipe */
 494         /* 43 */ SYSENT_CL("times",             times,          1),
 495         /* 44 */ SYSENT_CI("prof",              profil,         4),
 496         /* 45 */ SYSENT_CI("faccessat",         faccessat,      4),
 497         /* 46 */ SYSENT_CI("setgid",            setgid,         1),
 498         /* 47 */ SYSENT_2CI("getgid",           getgid,         0),
 499         /* 48 */ SYSENT_CI("mknodat",           mknodat,        4),
 500         /* 49 */ SYSENT_LOADABLE(),                     /* msgsys */
 501         /* 50 */ IF_x86(
 502                         SYSENT_CI("sysi86",     sysi86,         4),
 503                         SYSENT_LOADABLE()),             /* (was sys3b) */
 504         /* 51 */ SYSENT_LOADABLE(),                     /* sysacct */
 505         /* 52 */ SYSENT_LOADABLE(),                     /* shmsys */
 506         /* 53 */ SYSENT_LOADABLE(),                     /* semsys */
 507         /* 54 */ SYSENT_CI("ioctl",             ioctl,          3),
 508         /* 55 */ SYSENT_CI("uadmin",            uadmin,         3),
 509         /* 56 */ SYSENT_CI("fchownat",          fchownat,       5),
 510         /* 57 */ IF_LP64(
 511                         SYSENT_2CI("utssys",    utssys64,       4),
 512                         SYSENT_2CI("utssys",    utssys32,       4)),
 513         /* 58 */ SYSENT_CI("fdsync",            fdsync,         2),
 514         /* 59 */ SYSENT_CI("exece",             exece,          3),
 515         /* 60 */ SYSENT_CI("umask",             umask,          1),
 516         /* 61 */ SYSENT_CI("chroot",            chroot,         1),
 517         /* 62 */ SYSENT_CI("fcntl",             fcntl,          3),
 518         /* 63 */ SYSENT_CI("ulimit",            ulimit,         2),
 519         /* 64 */ SYSENT_CI("renameat",          renameat,       4),
 520         /* 65 */ SYSENT_CI("unlinkat",          unlinkat,       3),
 521         /* 66 */ SYSENT_CI("fstatat",           fstatat,        4),
 522         /* 67 */ IF_LP64(
 523                         SYSENT_NOSYS(),
 524                         SYSENT_CI("fstatat64",  fstatat64,      4)),
 525         /* 68 */ SYSENT_CI("openat",            openat,         4),
 526         /* 69 */ IF_LP64(
 527                         SYSENT_NOSYS(),
 528                         SYSENT_CI("openat64",   openat64,       4)),
 529         /* 70 */ SYSENT_CI("tasksys",           tasksys,        5),
 530         /* 71 */ SYSENT_LOADABLE(),             /* acctctl */
 531         /* 72 */ SYSENT_LOADABLE(),             /* exacct */
 532         /* 73 */ SYSENT_CI("getpagesizes",      getpagesizes,   3),
 533         /* 74 */ SYSENT_CI("rctlsys",           rctlsys,        6),
 534         /* 75 */ SYSENT_2CI("sidsys",           sidsys,         4),
 535         /* 76 */ SYSENT_LOADABLE(),                     /* (was fsat) */
 536         /* 77 */ SYSENT_CI("lwp_park",          syslwp_park,    3),
 537         /* 78 */ SYSENT_CL("sendfilev",         sendfilev,      5),
 538         /* 79 */ SYSENT_CI("rmdir",             rmdir,          1),
 539         /* 80 */ SYSENT_CI("mkdir",             mkdir,          2),
 540         /* 81 */ IF_LP64(
 541                         SYSENT_CI("getdents",   getdents64,     3),
 542                         SYSENT_CI("getdents",   getdents32,     3)),
 543         /* 82 */ SYSENT_CI("privsys",           privsys,        6),
 544         /* 83 */ SYSENT_CI("ucredsys",          ucredsys,       3),
 545         /* 84 */ SYSENT_CI("sysfs",             sysfs,          3),
 546         /* 85 */ SYSENT_CI("getmsg",            getmsg,         4),
 547         /* 86 */ SYSENT_CI("putmsg",            putmsg,         4),
 548         /* 87 */ SYSENT_LOADABLE(),                     /* (was poll) */
 549         /* 88 */ SYSENT_CI("lstat",             lstat,          2),
 550         /* 89 */ SYSENT_CI("symlink",           symlink,        2),
 551         /* 90 */ SYSENT_CL("readlink",          readlink,       3),
 552         /* 91 */ SYSENT_CI("setgroups",         setgroups,      2),
 553         /* 92 */ SYSENT_CI("getgroups",         getgroups,      2),
 554         /* 93 */ SYSENT_CI("fchmod",            fchmod,         2),
 555         /* 94 */ SYSENT_CI("fchown",            fchown,         3),
 556         /* 95 */ SYSENT_CI("sigprocmask",       sigprocmask,    3),
 557         /* 96 */ SYSENT_CI("sigsuspend",        sigsuspend,     1),
 558         /* 97 */ SYSENT_CI("sigaltstack",       sigaltstack,    2),
 559         /* 98 */ SYSENT_CI("sigaction",         sigaction,      3),
 560         /* 99 */ SYSENT_CI("sigpending",        sigpending,     2),
 561         /* 100 */ SYSENT_CI("getsetcontext",    getsetcontext,  2),
 562         /* 101 */ SYSENT_CI("fchmodat",         fchmodat,       4),
 563         /* 102 */ SYSENT_CI("mkdirat",          mkdirat,        3),
 564         /* 103 */ SYSENT_CI("statvfs",          statvfs,        2),
 565         /* 104 */ SYSENT_CI("fstatvfs",         fstatvfs,       2),
 566         /* 105 */ SYSENT_CI("getloadavg",       getloadavg,     2),
 567 /* ONC_PLUS EXTRACT START */
 568         /* 106 */ SYSENT_LOADABLE(),            /* nfssys */
 569 /* ONC_PLUS EXTRACT END */
 570         /* 107 */ SYSENT_CI("waitsys",          waitsys,        4),
 571         /* 108 */ SYSENT_CI("sigsendset",       sigsendsys,     2),
 572         /* 109 */ IF_x86(
 573                         SYSENT_AP("hrtsys",     hrtsys,         5),
 574                         SYSENT_LOADABLE()),
 575         /* 110 */ SYSENT_CI("utimesys",         utimesys,       5),
 576         /* 111 */ SYSENT_CI("sigresend",        sigresend,      3),
 577         /* 112 */ SYSENT_CL("priocntlsys",      priocntlsys,    5),
 578         /* 113 */ SYSENT_CL("pathconf",         pathconf,       2),
 579         /* 114 */ SYSENT_CI("mincore",          mincore,        3),
 580         /* 115 */ IF_LP64(
 581                         SYSENT_CL("mmap",       smmap64,        6),
 582                         SYSENT_CL("mmap",       smmap32,        6)),
 583         /* 116 */ SYSENT_CI("mprotect",         mprotect,       3),
 584         /* 117 */ SYSENT_CI("munmap",           munmap,         2),
 585         /* 118 */ SYSENT_CL("fpathconf",        fpathconf,      2),
 586         /* 119 */ SYSENT_2CI("vfork",           vfork,          0),
 587         /* 120 */ SYSENT_CI("fchdir",           fchdir,         1),
 588         /* 121 */ SYSENT_CL("readv",            readv,          3),
 589         /* 122 */ SYSENT_CL("writev",           writev,         3),
 590         /* 123 */ SYSENT_LOADABLE(),                    /* (was xstat) */
 591         /* 124 */ SYSENT_LOADABLE(),                    /* (was lxstat) */
 592         /* 125 */ SYSENT_LOADABLE(),                    /* (was fxstat) */
 593         /* 126 */ SYSENT_LOADABLE(),                    /* (was xmknod) */
 594         /* 127 */ SYSENT_CI("mmapobj",          mmapobjsys,     5),
 595         /* 128 */ IF_LP64(
 596                         SYSENT_CI("setrlimit",  setrlimit64,    2),
 597                         SYSENT_CI("setrlimit",  setrlimit32,    2)),
 598         /* 129 */ IF_LP64(
 599                         SYSENT_CI("getrlimit",  getrlimit64,    2),
 600                         SYSENT_CI("getrlimit",  getrlimit32,    2)),
 601         /* 130 */ SYSENT_CI("lchown",           lchown,         3),
 602         /* 131 */ SYSENT_CI("memcntl",          memcntl,        6),
 603         /* 132 */ SYSENT_CI("getpmsg",          getpmsg,        5),
 604         /* 133 */ SYSENT_CI("putpmsg",          putpmsg,        5),
 605         /* 134 */ SYSENT_CI("rename",           rename,         2),
 606         /* 135 */ SYSENT_CI("uname",            uname,          1),
 607         /* 136 */ SYSENT_CI("setegid",          setegid,        1),
 608         /* 137 */ SYSENT_CL("sysconfig",        sysconfig,      1),
 609         /* 138 */ SYSENT_CI("adjtime",          adjtime,        2),
 610         /* 139 */ SYSENT_CL("systeminfo",       systeminfo,     3),
 611         /* 140 */ SYSENT_LOADABLE(),            /* sharefs */
 612         /* 141 */ SYSENT_CI("seteuid",          seteuid,        1),
 613         /* 142 */ SYSENT_2CI("forksys",         forksys,        2),
 614         /* 143 */ SYSENT_LOADABLE(),                    /* (was fork1) */
 615         /* 144 */ SYSENT_CI("sigtimedwait",     sigtimedwait,   3),
 616         /* 145 */ SYSENT_CI("lwp_info",         lwp_info,       1),
 617         /* 146 */ SYSENT_CI("yield",            yield,          0),
 618         /* 147 */ SYSENT_LOADABLE(),                /* (was lwp_sema_wait) */
 619         /* 148 */ SYSENT_CI("lwp_sema_post",    lwp_sema_post,  1),
 620         /* 149 */ SYSENT_CI("lwp_sema_trywait", lwp_sema_trywait, 1),
 621         /* 150 */ SYSENT_CI("lwp_detach",       lwp_detach,     1),
 622         /* 151 */ SYSENT_CI("corectl",          corectl,        4),
 623         /* 152 */ SYSENT_CI("modctl",           modctl,         6),
 624         /* 153 */ SYSENT_CI("fchroot",          fchroot,        1),
 625         /* 154 */ SYSENT_LOADABLE(),                    /* (was utimes) */
 626         /* 155 */ SYSENT_CI("vhangup",          vhangup,        0),
 627         /* 156 */ SYSENT_CI("gettimeofday",     gettimeofday,   1),
 628         /* 157 */ SYSENT_CI("getitimer",        getitimer,      2),
 629         /* 158 */ SYSENT_CI("setitimer",        setitimer,      3),
 630         /* 159 */ SYSENT_CI("lwp_create",       syslwp_create,  3),
 631         /* 160 */ SYSENT_CI("lwp_exit", (int (*)())syslwp_exit, 0),
 632         /* 161 */ SYSENT_CI("lwp_suspend",      syslwp_suspend, 1),
 633         /* 162 */ SYSENT_CI("lwp_continue",     syslwp_continue, 1),
 634         /* 163 */ SYSENT_CI("lwp_kill",         lwp_kill,       2),
 635         /* 164 */ SYSENT_CI("lwp_self",         lwp_self,       0),
 636         /* 165 */ SYSENT_2CI("lwp_sigmask",     lwp_sigmask,    5),
 637         /* 166 */ IF_x86(
 638                         SYSENT_CI("lwp_private", syslwp_private, 3),
 639                         SYSENT_NOSYS()),
 640         /* 167 */ SYSENT_CI("lwp_wait",         lwp_wait,       2),
 641         /* 168 */ SYSENT_CI("lwp_mutex_wakeup", lwp_mutex_wakeup,       2),
 642         /* 169 */ SYSENT_LOADABLE(),                /* (was lwp_mutex_lock) */
 643         /* 170 */ SYSENT_CI("lwp_cond_wait",    lwp_cond_wait,          4),
 644         /* 171 */ SYSENT_CI("lwp_cond_signal",  lwp_cond_signal,        1),
 645         /* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast,   1),
 646         /* 173 */ SYSENT_CL("pread",            pread,          4),
 647         /* 174 */ SYSENT_CL("pwrite ",          pwrite,         4),
 648         /*
 649          * The 64-bit C library maps llseek() to lseek(), so this
 650          * is needed as a native syscall only on the 32-bit kernel.
 651          */
 652         /* 175 */ IF_LP64(
 653                         SYSENT_NOSYS(),
 654                         SYSENT_C("llseek",      llseek32,       4)),
 655         /* 176 */ SYSENT_LOADABLE(),            /* inst_sync */
 656         /* 177 */ SYSENT_CI("brandsys",         brandsys,       6),
 657         /* 178 */ SYSENT_LOADABLE(),            /* kaio */
 658         /* 179 */ SYSENT_LOADABLE(),            /* cpc */
 659         /* 180 */ SYSENT_CI("lgrpsys",          lgrpsys,        3),
 660         /* 181 */ SYSENT_CI("rusagesys",        rusagesys,      5),
 661         /* 182 */ SYSENT_LOADABLE(),            /* portfs */
 662         /* 183 */ SYSENT_CI("pollsys",          pollsys,        4),
 663         /* 184 */ SYSENT_CI("labelsys",         labelsys,       5),
 664         /* 185 */ SYSENT_CI("acl",              acl,            4),
 665         /* 186 */ SYSENT_AP("auditsys",         auditsys,       6),
 666         /* 187 */ SYSENT_CI("processor_bind",   processor_bind, 4),
 667         /* 188 */ SYSENT_CI("processor_info",   processor_info, 2),
 668         /* 189 */ SYSENT_CI("p_online",         p_online,       2),
 669         /* 190 */ SYSENT_CI("sigqueue",         sigqueue,       5),
 670         /* 191 */ SYSENT_CI("clock_gettime",    clock_gettime,  2),
 671         /* 192 */ SYSENT_CI("clock_settime",    clock_settime,  2),
 672         /* 193 */ SYSENT_CI("clock_getres",     clock_getres,   2),
 673         /* 194 */ SYSENT_CI("timer_create",     timer_create,   3),
 674         /* 195 */ SYSENT_CI("timer_delete",     timer_delete,   1),
 675         /* 196 */ SYSENT_CI("timer_settime",    timer_settime,  4),
 676         /* 197 */ SYSENT_CI("timer_gettime",    timer_gettime,  2),
 677         /* 198 */ SYSENT_CI("timer_getoverrun", timer_getoverrun, 1),
 678         /* 199 */ SYSENT_CI("nanosleep",        nanosleep,      2),
 679         /* 200 */ SYSENT_CI("facl",             facl,           4),
 680         /* 201 */ SYSENT_LOADABLE(),            /* door */
 681         /* 202 */ SYSENT_CI("setreuid",         setreuid,       2),
 682         /* 203 */ SYSENT_CI("setregid",         setregid,       2),
 683         /* 204 */ SYSENT_CI("install_utrap",    install_utrap,  3),
 684         /* 205 */ SYSENT_CI("signotify",        signotify,      3),
 685         /* 206 */ SYSENT_CL("schedctl",         schedctl,       0),
 686         /* 207 */ SYSENT_LOADABLE(),            /* pset */
 687         /* 208 */ IF_sparc(
 688                 SYSENT_CI("sparc_utrap_install", sparc_utrap_install, 5),
 689                 SYSENT_NOSYS()),
 690         /* 209 */ SYSENT_CI("resolvepath",      resolvepath,    3),
 691         /* 210 */ SYSENT_CI("lwp_mutex_timedlock", lwp_mutex_timedlock, 3),
 692         /* 211 */ SYSENT_CI("lwp_sema_timedwait", lwp_sema_timedwait,   3),
 693         /* 212 */ SYSENT_CI("lwp_rwlock_sys",   lwp_rwlock_sys, 3),
 694         /*
 695          * Syscalls 213-225: 32-bit system call support for large files.
 696          *
 697          * (The 64-bit C library transparently maps these system calls
 698          * back to their native versions, so almost all of them are only
 699          * needed as native syscalls on the 32-bit kernel).
 700          */
 701         /* 213 */ IF_LP64(
 702                         SYSENT_NOSYS(),
 703                         SYSENT_CI("getdents64", getdents64,     3)),
 704         /* 214 */ IF_LP64(
 705                         SYSENT_NOSYS(),
 706                         SYSENT_AP("smmaplf32",  smmaplf32,      7)),
 707         /* 215 */ IF_LP64(
 708                         SYSENT_NOSYS(),
 709                         SYSENT_CI("stat64",     stat64,         2)),
 710         /* 216 */ IF_LP64(
 711                         SYSENT_NOSYS(),
 712                         SYSENT_CI("lstat64",    lstat64,        2)),
 713         /* 217 */ IF_LP64(
 714                         SYSENT_NOSYS(),
 715                         SYSENT_CI("fstat64",    fstat64,        2)),
 716         /* 218 */ IF_LP64(
 717                         SYSENT_NOSYS(),
 718                         SYSENT_CI("statvfs64",  statvfs64,      2)),
 719         /* 219 */ IF_LP64(
 720                         SYSENT_NOSYS(),
 721                         SYSENT_CI("fstatvfs64", fstatvfs64,     2)),
 722         /* 220 */ IF_LP64(
 723                         SYSENT_NOSYS(),
 724                         SYSENT_CI("setrlimit64", setrlimit64,   2)),
 725         /* 221 */ IF_LP64(
 726                         SYSENT_NOSYS(),
 727                         SYSENT_CI("getrlimit64", getrlimit64,   2)),
 728         /* 222 */ IF_LP64(
 729                         SYSENT_NOSYS(),
 730                         SYSENT_CI("pread64",    pread64,        5)),
 731         /* 223 */ IF_LP64(
 732                         SYSENT_NOSYS(),
 733                         SYSENT_CI("pwrite64",   pwrite64,       5)),
 734         /* 224 */ SYSENT_LOADABLE(),                    /* (was creat64) */
 735         /* 225 */ IF_LP64(
 736                         SYSENT_NOSYS(),
 737                         SYSENT_CI("open64",     open64,         3)),
 738         /* 226 */ SYSENT_LOADABLE(),            /* rpcsys */
 739         /* 227 */ SYSENT_CL("zone",             zone,           5),
 740         /* 228 */ SYSENT_LOADABLE(),            /* autofssys */
 741         /* 229 */ SYSENT_CI("getcwd",           getcwd,         2),
 742         /* 230 */ SYSENT_CI("so_socket",        so_socket,      5),
 743         /* 231 */ SYSENT_CI("so_socketpair",    so_socketpair,  1),
 744         /* 232 */ SYSENT_CI("bind",             bind,           4),
 745         /* 233 */ SYSENT_CI("listen",           listen,         3),
 746         /* 234 */ SYSENT_CI("accept",           accept,         5),
 747         /* 235 */ SYSENT_CI("connect",          connect,        4),
 748         /* 236 */ SYSENT_CI("shutdown",         shutdown,       3),
 749         /* 237 */ SYSENT_CL("recv",             recv,           4),
 750         /* 238 */ SYSENT_CL("recvfrom",         recvfrom,       6),
 751         /* 239 */ SYSENT_CL("recvmsg",          recvmsg,        3),
 752         /* 240 */ SYSENT_CL("send",             send,           4),
 753         /* 241 */ SYSENT_CL("sendmsg",          sendmsg,        3),
 754         /* 242 */ SYSENT_CL("sendto",           sendto,         6),
 755         /* 243 */ SYSENT_CI("getpeername",      getpeername,    4),
 756         /* 244 */ SYSENT_CI("getsockname",      getsockname,    4),
 757         /* 245 */ SYSENT_CI("getsockopt",       getsockopt,     6),
 758         /* 246 */ SYSENT_CI("setsockopt",       setsockopt,     6),
 759         /* 247 */ SYSENT_CI("sockconfig",       sockconfig,     5),
 760         /* 248 */ SYSENT_CI("ntp_gettime",      ntp_gettime,    1),
 761         /* 249 */ SYSENT_CI("ntp_adjtime",      ntp_adjtime,    1),
 762         /* 250 */ SYSENT_CI("lwp_mutex_unlock", lwp_mutex_unlock,       1),
 763         /* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock,     2),
 764         /* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register,   2),
 765         /* 253 */ SYSENT_CI("cladm",            cladm,          3),
 766         /* 254 */ SYSENT_CI("uucopy",           uucopy,         3),
 767         /* 255 */ SYSENT_CI("umount2",          umount2,        2)
 768 /* ONC_PLUS EXTRACT START */
 769 };
 770 /* ONC_PLUS EXTRACT END */
 771 
 772 
 773 #ifdef _SYSCALL32_IMPL
 774 
 775 extern int ulimit32(int, int);
 776 extern ssize_t read32(int32_t, caddr32_t, size32_t);
 777 extern ssize_t write32(int32_t, caddr32_t, size32_t);
 778 extern ssize_t pread32(int32_t, caddr32_t, size32_t, off32_t);
 779 extern ssize_t pwrite32(int32_t, caddr32_t, size32_t, off32_t);
 780 extern ssize_t readv32(int32_t, caddr32_t, int32_t);
 781 extern ssize_t writev32(int32_t, caddr32_t, int32_t);
 782 extern ssize_t readlink32(caddr32_t, caddr32_t, size32_t);
 783 extern ssize_t readlinkat32(int, caddr32_t, caddr32_t, size32_t);
 784 extern int open32(char *, int, int);
 785 extern int openat32(int, char *, int, int);
 786 extern int stat32(char *, struct stat32 *);
 787 extern int fstatat32(int, char *, struct stat32 *, int);
 788 extern int lstat32(char *, struct stat32 *);
 789 extern int fstat32(int, struct stat32 *);
 790 extern int fstatat64_32(int, char *, struct stat64_32 *, int);
 791 extern int stat64_32(char *, struct stat64_32 *);
 792 extern int lstat64_32(char *, struct stat64_32 *);
 793 extern int fstat64_32(int, struct stat64_32 *);
 794 extern int getmsg32(int, struct strbuf32 *, struct strbuf32 *, int32_t *);
 795 extern int putmsg32(int, struct strbuf32 *, struct strbuf32 *, int32_t *);
 796 extern int getpmsg32(int, struct strbuf32 *, struct strbuf32 *, int32_t *,
 797     int32_t *);
 798 extern int putpmsg32(int, struct strbuf32 *, struct strbuf32 *, int32_t,
 799     int32_t);
 800 extern int getsetcontext32(int, void *);
 801 extern int statvfs32(char *, struct statvfs32 *);
 802 extern int fstatvfs32(int, struct statvfs32 *);
 803 extern int statvfs64_32(char *, struct statvfs64_32 *);
 804 extern int fstatvfs64_32(int, struct statvfs64_32 *);
 805 extern int sigaction32(int, struct sigaction32 *, struct sigaction32 *);
 806 extern clock32_t times32(struct tms32 *);
 807 extern int stime32(time32_t);
 808 extern int getpagesizes32(int, size32_t *, int);
 809 extern int sigaltstack32(struct sigaltstack32 *, struct sigaltstack32 *);
 810 extern int sigqueue32(pid_t, int, caddr32_t, int, int);
 811 extern offset_t llseek32(int32_t, uint32_t, uint32_t, int);
 812 extern int waitsys32(idtype_t, id_t, siginfo_t *, int);
 813 
 814 extern ssize_t recv32(int32_t, caddr32_t, size32_t, int32_t);
 815 extern ssize_t recvfrom32(int32_t, caddr32_t, size32_t, int32_t, caddr32_t,
 816     caddr32_t);
 817 extern ssize_t send32(int32_t, caddr32_t, size32_t, int32_t);
 818 extern ssize_t sendto32(int32_t, caddr32_t, size32_t, int32_t, caddr32_t,
 819     socklen_t);
 820 
 821 extern int privsys32(int, priv_op_t, priv_ptype_t, caddr32_t, size32_t, int);
 822 extern int ucredsys32(int, int, caddr32_t);
 823 
 824 /* ONC_PLUS EXTRACT START */
 825 /*
 826  * sysent table for ILP32 processes running on
 827  * a LP64 kernel.
 828  */
 829 struct sysent sysent32[NSYSCALL] =
 830 {
 831 /* ONC_PLUS EXTRACT END */
 832         /*  0 */ SYSENT_C("indir",              indir,          1),
 833         /*  1 */ SYSENT_CI("exit",      (int (*)())rexit,       1),
 834         /*  2 */ SYSENT_LOADABLE32(),                   /* (was forkall) */
 835         /*  3 */ SYSENT_CI("read",              read32,         3),
 836         /*  4 */ SYSENT_CI("write",             write32,        3),
 837         /*  5 */ SYSENT_CI("open",              open32,         3),
 838         /*  6 */ SYSENT_CI("close",             close,          1),
 839         /*  7 */ SYSENT_CI("linkat",            linkat,         5),
 840         /*  8 */ SYSENT_LOADABLE32(),                   /* (was creat32) */
 841         /*  9 */ SYSENT_CI("link",              link,           2),
 842         /* 10 */ SYSENT_CI("unlink",            unlink,         1),
 843         /* 11 */ SYSENT_CI("symlinkat",         symlinkat,      3),
 844         /* 12 */ SYSENT_CI("chdir",             chdir,          1),
 845         /* 13 */ SYSENT_CI("time",              gtime,          0),
 846         /* 14 */ SYSENT_CI("mknod",             mknod,          3),
 847         /* 15 */ SYSENT_CI("chmod",             chmod,          2),
 848         /* 16 */ SYSENT_CI("chown",             chown,          3),
 849         /* 17 */ SYSENT_CI("brk",               brk,            1),
 850         /* 18 */ SYSENT_CI("stat",              stat32,         2),
 851         /* 19 */ SYSENT_CI("lseek",             lseek32,        3),
 852         /* 20 */ SYSENT_2CI("getpid",           getpid,         0),
 853         /* 21 */ SYSENT_AP("mount",             mount,          8),
 854         /* 22 */ SYSENT_CI("readlinkat",        readlinkat32,   4),
 855         /* 23 */ SYSENT_CI("setuid",            setuid,         1),
 856         /* 24 */ SYSENT_2CI("getuid",           getuid,         0),
 857         /* 25 */ SYSENT_CI("stime",             stime32,        1),
 858         /* 26 */ SYSENT_CI("pcsample",          pcsample,       2),
 859         /* 27 */ SYSENT_CI("alarm",             alarm,          1),
 860         /* 28 */ SYSENT_CI("fstat",             fstat32,        2),
 861         /* 29 */ SYSENT_CI("pause",             pause,          0),
 862         /* 30 */ SYSENT_LOADABLE32(),                   /* (was utime) */
 863         /* 31 */ SYSENT_CI("stty",              stty,           2),
 864         /* 32 */ SYSENT_CI("gtty",              gtty,           2),
 865         /* 33 */ SYSENT_CI("access",            access,         2),
 866         /* 34 */ SYSENT_CI("nice",              nice,           1),
 867         /* 35 */ SYSENT_CI("statfs",            statfs32,       4),
 868         /* 36 */ SYSENT_CI("sync",              syssync,        0),
 869         /* 37 */ SYSENT_CI("kill",              kill,           2),
 870         /* 38 */ SYSENT_CI("fstatfs",           fstatfs32,      4),
 871         /* 39 */ SYSENT_CI("setpgrp",           setpgrp,        3),
 872         /* 40 */ SYSENT_CI("uucopystr",         uucopystr,      3),
 873         /* 41 */ SYSENT_LOADABLE32(),                   /* (was dup) */
 874         /* 42 */ SYSENT_LOADABLE32(),                   /* pipe */
 875         /* 43 */ SYSENT_CI("times",             times32,        1),
 876         /* 44 */ SYSENT_CI("prof",              profil,         4),
 877         /* 45 */ SYSENT_CI("faccessat",         faccessat,      4),
 878         /* 46 */ SYSENT_CI("setgid",            setgid,         1),
 879         /* 47 */ SYSENT_2CI("getgid",           getgid,         0),
 880         /* 48 */ SYSENT_CI("mknodat",           mknodat,        4),
 881         /* 49 */ SYSENT_LOADABLE32(),                   /* msgsys */
 882         /* 50 */ IF_386_ABI(
 883                         SYSENT_CI("sysi86",     sysi86,         4),
 884                         SYSENT_LOADABLE32()),           /* (was sys3b) */
 885         /* 51 */ SYSENT_LOADABLE32(),                   /* sysacct */
 886         /* 52 */ SYSENT_LOADABLE32(),                   /* shmsys */
 887         /* 53 */ SYSENT_LOADABLE32(),                   /* semsys */
 888         /* 54 */ SYSENT_CI("ioctl",             ioctl,          3),
 889         /* 55 */ SYSENT_CI("uadmin",            uadmin,         3),
 890         /* 56 */ SYSENT_CI("fchownat",          fchownat,       5),
 891         /* 57 */ SYSENT_2CI("utssys",           utssys32,       4),
 892         /* 58 */ SYSENT_CI("fdsync",            fdsync,         2),
 893         /* 59 */ SYSENT_CI("exece",             exece,          3),
 894         /* 60 */ SYSENT_CI("umask",             umask,          1),
 895         /* 61 */ SYSENT_CI("chroot",            chroot,         1),
 896         /* 62 */ SYSENT_CI("fcntl",             fcntl,          3),
 897         /* 63 */ SYSENT_CI("ulimit",            ulimit32,       2),
 898         /* 64 */ SYSENT_CI("renameat",          renameat,       4),
 899         /* 65 */ SYSENT_CI("unlinkat",          unlinkat,       3),
 900         /* 66 */ SYSENT_CI("fstatat",           fstatat32,      4),
 901         /* 67 */ SYSENT_CI("fstatat64",         fstatat64_32,   4),
 902         /* 68 */ SYSENT_CI("openat",            openat32,       4),
 903         /* 69 */ SYSENT_CI("openat64",          openat64,       4),
 904         /* 70 */ SYSENT_CI("tasksys",           tasksys,        5),
 905         /* 71 */ SYSENT_LOADABLE32(),           /* acctctl */
 906         /* 72 */ SYSENT_LOADABLE32(),           /* exacct */
 907         /* 73 */ SYSENT_CI("getpagesizes",      getpagesizes32, 3),
 908         /* 74 */ SYSENT_CI("rctlsys",           rctlsys,        6),
 909         /* 75 */ SYSENT_2CI("sidsys",           sidsys,         4),
 910         /* 76 */ SYSENT_LOADABLE32(),                   /* (was fsat) */
 911         /* 77 */ SYSENT_CI("lwp_park",          syslwp_park,    3),
 912         /* 78 */ SYSENT_CI("sendfilev",         sendfilev,      5),
 913         /* 79 */ SYSENT_CI("rmdir",             rmdir,          1),
 914         /* 80 */ SYSENT_CI("mkdir",             mkdir,          2),
 915         /* 81 */ SYSENT_CI("getdents",          getdents32,     3),
 916         /* 82 */ SYSENT_CI("privsys",           privsys32,      6),
 917         /* 83 */ SYSENT_CI("ucredsys",          ucredsys32,     3),
 918         /* 84 */ SYSENT_CI("sysfs",             sysfs,          3),
 919         /* 85 */ SYSENT_CI("getmsg",            getmsg32,       4),
 920         /* 86 */ SYSENT_CI("putmsg",            putmsg32,       4),
 921         /* 87 */ SYSENT_LOADABLE32(),                   /* (was poll) */
 922         /* 88 */ SYSENT_CI("lstat",             lstat32,        2),
 923         /* 89 */ SYSENT_CI("symlink",           symlink,        2),
 924         /* 90 */ SYSENT_CI("readlink",          readlink32,     3),
 925         /* 91 */ SYSENT_CI("setgroups",         setgroups,      2),
 926         /* 92 */ SYSENT_CI("getgroups",         getgroups,      2),
 927         /* 93 */ SYSENT_CI("fchmod",            fchmod,         2),
 928         /* 94 */ SYSENT_CI("fchown",            fchown,         3),
 929         /* 95 */ SYSENT_CI("sigprocmask",       sigprocmask,    3),
 930         /* 96 */ SYSENT_CI("sigsuspend",        sigsuspend,     1),
 931         /* 97 */ SYSENT_CI("sigaltstack",       sigaltstack32,  2),
 932         /* 98 */ SYSENT_CI("sigaction",         sigaction32,    3),
 933         /* 99 */ SYSENT_CI("sigpending",        sigpending,     2),
 934         /* 100 */ SYSENT_CI("getsetcontext",    getsetcontext32, 2),
 935         /* 101 */ SYSENT_CI("fchmodat",         fchmodat,       4),
 936         /* 102 */ SYSENT_CI("mkdirat",          mkdirat,        3),
 937         /* 103 */ SYSENT_CI("statvfs",          statvfs32,      2),
 938         /* 104 */ SYSENT_CI("fstatvfs",         fstatvfs32,     2),
 939         /* 105 */ SYSENT_CI("getloadavg",       getloadavg,     2),
 940 /* ONC_PLUS EXTRACT START */
 941         /* 106 */ SYSENT_LOADABLE32(),          /* nfssys */
 942 /* ONC_PLUS EXTRACT END */
 943         /* 107 */ SYSENT_CI("waitsys",          waitsys32,      4),
 944         /* 108 */ SYSENT_CI("sigsendset",       sigsendsys,     2),
 945         /* 109 */ IF_x86(
 946                         SYSENT_AP("hrtsys",     hrtsys,         5),
 947                         SYSENT_LOADABLE32()),
 948         /* 110 */ SYSENT_CI("utimesys",         utimesys,       5),
 949         /* 111 */ SYSENT_CI("sigresend",        sigresend,      3),
 950         /* 112 */ SYSENT_CI("priocntlsys",      priocntlsys,    5),
 951         /* 113 */ SYSENT_CI("pathconf",         pathconf,       2),
 952         /* 114 */ SYSENT_CI("mincore",          mincore,        3),
 953         /* 115 */ SYSENT_CI("mmap",             smmap32,        6),
 954         /* 116 */ SYSENT_CI("mprotect",         mprotect,       3),
 955         /* 117 */ SYSENT_CI("munmap",           munmap,         2),
 956         /* 118 */ SYSENT_CI("fpathconf",        fpathconf,      2),
 957         /* 119 */ SYSENT_2CI("vfork",           vfork,          0),
 958         /* 120 */ SYSENT_CI("fchdir",           fchdir,         1),
 959         /* 121 */ SYSENT_CI("readv",            readv32,        3),
 960         /* 122 */ SYSENT_CI("writev",           writev32,       3),
 961         /* 123 */ SYSENT_LOADABLE32(),          /*      was xstat32     */
 962         /* 124 */ SYSENT_LOADABLE32(),          /*      was lxstat32    */
 963         /* 125 */ SYSENT_LOADABLE32(),          /*      was fxstat32    */
 964         /* 126 */ SYSENT_LOADABLE32(),          /*      was xmknod      */
 965         /* 127 */ SYSENT_CI("mmapobj",          mmapobjsys,     5),
 966         /* 128 */ SYSENT_CI("setrlimit",        setrlimit32,    2),
 967         /* 129 */ SYSENT_CI("getrlimit",        getrlimit32,    2),
 968         /* 130 */ SYSENT_CI("lchown",           lchown,         3),
 969         /* 131 */ SYSENT_CI("memcntl",          memcntl,        6),
 970         /* 132 */ SYSENT_CI("getpmsg",          getpmsg32,      5),
 971         /* 133 */ SYSENT_CI("putpmsg",          putpmsg32,      5),
 972         /* 134 */ SYSENT_CI("rename",           rename,         2),
 973         /* 135 */ SYSENT_CI("uname",            uname,          1),
 974         /* 136 */ SYSENT_CI("setegid",          setegid,        1),
 975         /* 137 */ SYSENT_CI("sysconfig",        sysconfig,      1),
 976         /* 138 */ SYSENT_CI("adjtime",          adjtime,        2),
 977         /* 139 */ SYSENT_CI("systeminfo",       systeminfo,     3),
 978         /* 140 */ SYSENT_LOADABLE32(),          /* sharefs */
 979         /* 141 */ SYSENT_CI("seteuid",          seteuid,        1),
 980         /* 142 */ SYSENT_2CI("forksys",         forksys,        2),
 981         /* 143 */ SYSENT_LOADABLE32(),                  /* (was fork1) */
 982         /* 144 */ SYSENT_CI("sigtimedwait",     sigtimedwait,   3),
 983         /* 145 */ SYSENT_CI("lwp_info",         lwp_info,       1),
 984         /* 146 */ SYSENT_CI("yield",            yield,          0),
 985         /* 147 */ SYSENT_LOADABLE32(),              /* (was lwp_sema_wait) */
 986         /* 148 */ SYSENT_CI("lwp_sema_post",    lwp_sema_post,  1),
 987         /* 149 */ SYSENT_CI("lwp_sema_trywait", lwp_sema_trywait, 1),
 988         /* 150 */ SYSENT_CI("lwp_detach",       lwp_detach,     1),
 989         /* 151 */ SYSENT_CI("corectl",          corectl,        4),
 990         /* 152 */ SYSENT_CI("modctl",           modctl,         6),
 991         /* 153 */ SYSENT_CI("fchroot",          fchroot,        1),
 992         /* 154 */ SYSENT_LOADABLE32(),                  /* (was utimes) */
 993         /* 155 */ SYSENT_CI("vhangup",          vhangup,        0),
 994         /* 156 */ SYSENT_CI("gettimeofday",     gettimeofday,   1),
 995         /* 157 */ SYSENT_CI("getitimer",        getitimer,      2),
 996         /* 158 */ SYSENT_CI("setitimer",        setitimer,      3),
 997         /* 159 */ SYSENT_CI("lwp_create",       syslwp_create,  3),
 998         /* 160 */ SYSENT_CI("lwp_exit", (int (*)())syslwp_exit, 0),
 999         /* 161 */ SYSENT_CI("lwp_suspend",      syslwp_suspend, 1),
1000         /* 162 */ SYSENT_CI("lwp_continue",     syslwp_continue, 1),
1001         /* 163 */ SYSENT_CI("lwp_kill",         lwp_kill,       2),
1002         /* 164 */ SYSENT_CI("lwp_self",         lwp_self,       0),
1003         /* 165 */ SYSENT_2CI("lwp_sigmask",     lwp_sigmask,    5),
1004         /* 166 */ IF_x86(
1005                         SYSENT_CI("lwp_private", syslwp_private, 3),
1006                         SYSENT_NOSYS()),
1007         /* 167 */ SYSENT_CI("lwp_wait",         lwp_wait,       2),
1008         /* 168 */ SYSENT_CI("lwp_mutex_wakeup", lwp_mutex_wakeup,       2),
1009         /* 169 */ SYSENT_LOADABLE32(),              /* (was lwp_mutex_lock) */
1010         /* 170 */ SYSENT_CI("lwp_cond_wait",    lwp_cond_wait,          4),
1011         /* 171 */ SYSENT_CI("lwp_cond_signal",  lwp_cond_signal,        1),
1012         /* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast,   1),
1013         /* 173 */ SYSENT_CI("pread",            pread32,                4),
1014         /* 174 */ SYSENT_CI("pwrite",           pwrite32,               4),
1015         /* 175 */ SYSENT_C("llseek",            llseek32,       4),
1016         /* 176 */ SYSENT_LOADABLE32(),          /* inst_sync */
1017         /* 177 */ SYSENT_CI("brandsys",         brandsys,       6),
1018         /* 178 */ SYSENT_LOADABLE32(),          /* kaio */
1019         /* 179 */ SYSENT_LOADABLE32(),          /* cpc */
1020         /* 180 */ SYSENT_CI("lgrpsys",          lgrpsys,        3),
1021         /* 181 */ SYSENT_CI("rusagesys",        rusagesys,      5),
1022         /* 182 */ SYSENT_LOADABLE32(),          /* portfs */
1023         /* 183 */ SYSENT_CI("pollsys",          pollsys,        4),
1024         /* 184 */ SYSENT_CI("labelsys",         labelsys,       5),
1025         /* 185 */ SYSENT_CI("acl",              acl,            4),
1026         /* 186 */ SYSENT_AP("auditsys",         auditsys,       6),
1027         /* 187 */ SYSENT_CI("processor_bind",   processor_bind, 4),
1028         /* 188 */ SYSENT_CI("processor_info",   processor_info, 2),
1029         /* 189 */ SYSENT_CI("p_online",         p_online,       2),
1030         /* 190 */ SYSENT_CI("sigqueue",         sigqueue32,     5),
1031         /* 191 */ SYSENT_CI("clock_gettime",    clock_gettime,  2),
1032         /* 192 */ SYSENT_CI("clock_settime",    clock_settime,  2),
1033         /* 193 */ SYSENT_CI("clock_getres",     clock_getres,   2),
1034         /* 194 */ SYSENT_CI("timer_create",     timer_create,   3),
1035         /* 195 */ SYSENT_CI("timer_delete",     timer_delete,   1),
1036         /* 196 */ SYSENT_CI("timer_settime",    timer_settime,  4),
1037         /* 197 */ SYSENT_CI("timer_gettime",    timer_gettime,  2),
1038         /* 198 */ SYSENT_CI("timer_getoverrun", timer_getoverrun, 1),
1039         /* 199 */ SYSENT_CI("nanosleep",        nanosleep,      2),
1040         /* 200 */ SYSENT_CI("facl",             facl,           4),
1041         /* 201 */ SYSENT_LOADABLE32(),          /* door */
1042         /* 202 */ SYSENT_CI("setreuid",         setreuid,       2),
1043         /* 203 */ SYSENT_CI("setregid",         setregid,       2),
1044         /* 204 */ SYSENT_CI("install_utrap",    install_utrap,  3),
1045         /* 205 */ SYSENT_CI("signotify",        signotify,      3),
1046         /* 206 */ SYSENT_CI("schedctl",         schedctl,       0),
1047         /* 207 */ SYSENT_LOADABLE32(),          /* pset */
1048         /* 208 */ SYSENT_LOADABLE32(),
1049         /* 209 */ SYSENT_CI("resolvepath",      resolvepath,    3),
1050         /* 210 */ SYSENT_CI("lwp_mutex_timedlock", lwp_mutex_timedlock, 3),
1051         /* 211 */ SYSENT_CI("lwp_sema_timedwait", lwp_sema_timedwait,   3),
1052         /* 212 */ SYSENT_CI("lwp_rwlock_sys",   lwp_rwlock_sys, 3),
1053         /*
1054          * Syscalls 213-225: 32-bit system call support for large files.
1055          */
1056         /* 213 */ SYSENT_CI("getdents64",       getdents64,     3),
1057         /* 214 */ SYSENT_AP("smmaplf32",        smmaplf32,      7),
1058         /* 215 */ SYSENT_CI("stat64",           stat64_32,      2),
1059         /* 216 */ SYSENT_CI("lstat64",          lstat64_32,     2),
1060         /* 217 */ SYSENT_CI("fstat64",          fstat64_32,     2),
1061         /* 218 */ SYSENT_CI("statvfs64",        statvfs64_32,   2),
1062         /* 219 */ SYSENT_CI("fstatvfs64",       fstatvfs64_32,  2),
1063         /* 220 */ SYSENT_CI("setrlimit64",      setrlimit64,    2),
1064         /* 221 */ SYSENT_CI("getrlimit64",      getrlimit64,    2),
1065         /* 222 */ SYSENT_CI("pread64",          pread64,        5),
1066         /* 223 */ SYSENT_CI("pwrite64",         pwrite64,       5),
1067         /* 224 */ SYSENT_LOADABLE32(),                  /* (was creat64) */
1068         /* 225 */ SYSENT_CI("open64",           open64,         3),
1069         /* 226 */ SYSENT_LOADABLE32(),          /* rpcsys */
1070         /* 227 */ SYSENT_CI("zone",             zone,           6),
1071         /* 228 */ SYSENT_LOADABLE32(),          /* autofssys */
1072         /* 229 */ SYSENT_CI("getcwd",           getcwd,         2),
1073         /* 230 */ SYSENT_CI("so_socket",        so_socket,      5),
1074         /* 231 */ SYSENT_CI("so_socketpair",    so_socketpair,  1),
1075         /* 232 */ SYSENT_CI("bind",             bind,           4),
1076         /* 233 */ SYSENT_CI("listen",           listen,         3),
1077         /* 234 */ SYSENT_CI("accept",           accept,         5),
1078         /* 235 */ SYSENT_CI("connect",          connect,        4),
1079         /* 236 */ SYSENT_CI("shutdown",         shutdown,       3),
1080         /* 237 */ SYSENT_CI("recv",             recv32,         4),
1081         /* 238 */ SYSENT_CI("recvfrom",         recvfrom32,     6),
1082         /* 239 */ SYSENT_CI("recvmsg",          recvmsg,        3),
1083         /* 240 */ SYSENT_CI("send",             send32,         4),
1084         /* 241 */ SYSENT_CI("sendmsg",          sendmsg,        3),
1085         /* 242 */ SYSENT_CI("sendto",           sendto32,       6),
1086         /* 243 */ SYSENT_CI("getpeername",      getpeername,    4),
1087         /* 244 */ SYSENT_CI("getsockname",      getsockname,    4),
1088         /* 245 */ SYSENT_CI("getsockopt",       getsockopt,     6),
1089         /* 246 */ SYSENT_CI("setsockopt",       setsockopt,     6),
1090         /* 247 */ SYSENT_CI("sockconfig",       sockconfig,     5),
1091         /* 248 */ SYSENT_CI("ntp_gettime",      ntp_gettime,    1),
1092         /* 249 */ SYSENT_CI("ntp_adjtime",      ntp_adjtime,    1),
1093         /* 250 */ SYSENT_CI("lwp_mutex_unlock", lwp_mutex_unlock,       1),
1094         /* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock,     2),
1095         /* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register,   2),
1096         /* 253 */ SYSENT_CI("cladm",            cladm,          3),
1097         /* 254 */ SYSENT_CI("uucopy",           uucopy,         3),
1098         /* 255 */ SYSENT_CI("umount2",          umount2,        2)
1099 /* ONC_PLUS EXTRACT START */
1100 };
1101 /* ONC_PLUS EXTRACT END */
1102 #endif /* _SYSCALL32_IMPL */
1103 
1104 /*
1105  * Space allocated and initialized in init_syscallnames().
1106  */
1107 char **syscallnames;
1108 
1109 systrace_sysent_t *systrace_sysent;
1110 void (*systrace_probe)(dtrace_id_t, uintptr_t, uintptr_t,
1111     uintptr_t, uintptr_t, uintptr_t, uintptr_t);
1112 
1113 /*ARGSUSED*/
1114 void
1115 systrace_stub(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
1116     uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1117 {}
1118 
1119 /*ARGSUSED*/
1120 int64_t
1121 dtrace_systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1122     uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1123 {
1124         systrace_sysent_t *sy = &systrace_sysent[curthread->t_sysnum];
1125         dtrace_id_t id;
1126         int64_t rval;
1127         proc_t *p;
1128 
1129         if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1130                 (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
1131 
1132         /*
1133          * We want to explicitly allow DTrace consumers to stop a process
1134          * before it actually executes the meat of the syscall.
1135          */
1136         p = ttoproc(curthread);
1137         mutex_enter(&p->p_lock);
1138         if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1139                 curthread->t_dtrace_stop = 0;
1140                 stop(PR_REQUESTED, 0);
1141         }
1142         mutex_exit(&p->p_lock);
1143 
1144         rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5);
1145 
1146         if (ttolwp(curthread)->lwp_errno != 0)
1147                 rval = -1;
1148 
1149         if ((id = sy->stsy_return) != DTRACE_IDNONE)
1150                 (*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1151                     (uintptr_t)((int64_t)rval >> 32), 0, 0, 0);
1152 
1153         return (rval);
1154 }
1155 
1156 #ifdef _SYSCALL32_IMPL
1157 
1158 systrace_sysent_t *systrace_sysent32;
1159 
1160 /*ARGSUSED*/
1161 int64_t
1162 dtrace_systrace_syscall32(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1163     uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1164 {
1165         systrace_sysent_t *sy = &systrace_sysent32[curthread->t_sysnum];
1166         dtrace_id_t id;
1167         int64_t rval;
1168         proc_t *p;
1169 
1170         if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1171                 (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
1172 
1173         /*
1174          * We want to explicitly allow DTrace consumers to stop a process
1175          * before it actually executes the meat of the syscall.
1176          */
1177         p = ttoproc(curthread);
1178         mutex_enter(&p->p_lock);
1179         if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1180                 curthread->t_dtrace_stop = 0;
1181                 stop(PR_REQUESTED, 0);
1182         }
1183         mutex_exit(&p->p_lock);
1184 
1185         rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5);
1186 
1187         if (ttolwp(curthread)->lwp_errno != 0)
1188                 rval = -1;
1189 
1190         if ((id = sy->stsy_return) != DTRACE_IDNONE)
1191                 (*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1192                     (uintptr_t)((uint64_t)rval >> 32), 0, 0, 0);
1193 
1194         return (rval);
1195 }
1196 
1197 #endif
1198 
1199 void
1200 dtrace_systrace_rtt(void)
1201 {
1202         systrace_sysent_t *sy;
1203         dtrace_id_t id;
1204 
1205         if (get_udatamodel() == DATAMODEL_NATIVE) {
1206                 if (systrace_sysent == NULL)
1207                         return;
1208 
1209                 sy = &systrace_sysent[curthread->t_sysnum];
1210 #ifdef _SYSCALL32_IMPL
1211         } else {
1212                 if (systrace_sysent32 == NULL)
1213                         return;
1214 
1215                 sy = &systrace_sysent32[curthread->t_sysnum];
1216 #endif
1217         }
1218 
1219         if ((id = sy->stsy_return) != DTRACE_IDNONE)
1220                 (*systrace_probe)(id, 0, 0, 0, 0, 0, 0);
1221 }