diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys index aa20c8af8450..f2b07d9127fa 100644 --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -51,10 +51,6 @@ STATICOBJS+= auxv.o STATICOBJS+= interposing_table.o .endif -NOASM= \ - flag_captured.o \ - yield.o - PSEUDO= \ clock_gettime \ exit \ diff --git a/sys/amd64/linux/linux_systrace_args.c b/sys/amd64/linux/linux_systrace_args.c index d0738267b35a..20322f7a8660 100644 --- a/sys/amd64/linux/linux_systrace_args.c +++ b/sys/amd64/linux/linux_systrace_args.c @@ -1,5 +1,5 @@ /* - * System call argument to DTrace register array converstion. + * System call argument to DTrace register array conversion. * * This file is part of the DTrace syscall provider. * diff --git a/sys/amd64/linux32/linux32_systrace_args.c b/sys/amd64/linux32/linux32_systrace_args.c index cf9d5b64a87f..7793124e6935 100644 --- a/sys/amd64/linux32/linux32_systrace_args.c +++ b/sys/amd64/linux32/linux32_systrace_args.c @@ -1,5 +1,5 @@ /* - * System call argument to DTrace register array converstion. + * System call argument to DTrace register array conversion. * * This file is part of the DTrace syscall provider. * diff --git a/sys/arm64/linux/linux_systrace_args.c b/sys/arm64/linux/linux_systrace_args.c index 9e7b0935e560..54e4dd82355d 100644 --- a/sys/arm64/linux/linux_systrace_args.c +++ b/sys/arm64/linux/linux_systrace_args.c @@ -1,5 +1,5 @@ /* - * System call argument to DTrace register array converstion. + * System call argument to DTrace register array conversion. * * This file is part of the DTrace syscall provider. * diff --git a/sys/cddl/dev/systrace/systrace.c b/sys/cddl/dev/systrace/systrace.c index 4969343ed06e..c14a663d1995 100644 --- a/sys/cddl/dev/systrace/systrace.c +++ b/sys/cddl/dev/systrace/systrace.c @@ -92,7 +92,7 @@ extern struct sysent linux32_sysent[]; #elif defined(FREEBSD32_SYSTRACE) /* * The syscall arguments are processed into a DTrace argument array - * using a generated function. See sys/tools/makesyscalls.lua. + * using a generated function. See sys/tools/syscalls/README.md. */ #include #include @@ -106,7 +106,7 @@ extern const char *freebsd32_syscallnames[]; #else /* * The syscall arguments are processed into a DTrace argument array - * using a generated function. See sys/tools/makesyscalls.lua. + * using a generated function. See sys/tools/syscalls/README.md. */ #include #include diff --git a/sys/compat/freebsd32/freebsd32_syscall.h b/sys/compat/freebsd32/freebsd32_syscall.h index aa9f1da5892f..3ed8374c57f4 100644 --- a/sys/compat/freebsd32/freebsd32_syscall.h +++ b/sys/compat/freebsd32/freebsd32_syscall.h @@ -67,7 +67,7 @@ #define FREEBSD32_SYS_umask 60 #define FREEBSD32_SYS_chroot 61 /* 62 is old freebsd32_fstat */ - /* 63 is obsolete ogetkerninfo */ + /* 63 is obsolete getkerninfo */ /* 64 is old getpagesize */ #define FREEBSD32_SYS_msync 65 #define FREEBSD32_SYS_vfork 66 @@ -140,7 +140,7 @@ #define FREEBSD32_SYS_mkdir 136 #define FREEBSD32_SYS_rmdir 137 #define FREEBSD32_SYS_freebsd32_utimes 138 - /* 139 is obsolete sigreturn */ + /* 139 is obsolete freebsd32_sigreturn */ #define FREEBSD32_SYS_freebsd32_adjtime 140 /* 141 is old getpeername */ /* 142 is old gethostid */ diff --git a/sys/compat/freebsd32/freebsd32_syscalls.c b/sys/compat/freebsd32/freebsd32_syscalls.c index 00838cae320f..947e1e8a0073 100644 --- a/sys/compat/freebsd32/freebsd32_syscalls.c +++ b/sys/compat/freebsd32/freebsd32_syscalls.c @@ -68,7 +68,7 @@ const char *freebsd32_syscallnames[] = { "umask", /* 60 = umask */ "chroot", /* 61 = chroot */ "compat.freebsd32_fstat", /* 62 = old freebsd32_fstat */ - "obs_getkerninfo", /* 63 = obsolete ogetkerninfo */ + "obs_getkerninfo", /* 63 = obsolete getkerninfo */ "compat.getpagesize", /* 64 = old getpagesize */ "msync", /* 65 = msync */ "vfork", /* 66 = vfork */ @@ -144,7 +144,7 @@ const char *freebsd32_syscallnames[] = { "mkdir", /* 136 = mkdir */ "rmdir", /* 137 = rmdir */ "freebsd32_utimes", /* 138 = freebsd32_utimes */ - "obs_freebsd32_sigreturn", /* 139 = obsolete sigreturn */ + "obs_freebsd32_sigreturn", /* 139 = obsolete freebsd32_sigreturn */ "freebsd32_adjtime", /* 140 = freebsd32_adjtime */ "compat.getpeername", /* 141 = old getpeername */ "compat.gethostid", /* 142 = old gethostid */ diff --git a/sys/compat/freebsd32/freebsd32_sysent.c b/sys/compat/freebsd32/freebsd32_sysent.c index 3057800daf5b..41b2a21f592b 100644 --- a/sys/compat/freebsd32/freebsd32_sysent.c +++ b/sys/compat/freebsd32/freebsd32_sysent.c @@ -59,6 +59,12 @@ #define compat13(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys #endif +#ifdef COMPAT_FREEBSD14 +#define compat14(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(freebsd14_, name) +#else +#define compat14(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys +#endif + /* The casts are bogus but will do for now. */ struct sysent freebsd32_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 0 = syscall */ @@ -124,7 +130,7 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = AS(umask_args), .sy_call = (sy_call_t *)sys_umask, .sy_auevent = AUE_UMASK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 60 = umask */ { .sy_narg = AS(chroot_args), .sy_call = (sy_call_t *)sys_chroot, .sy_auevent = AUE_CHROOT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 61 = chroot */ { compat(AS(ofreebsd32_fstat_args),freebsd32_fstat), .sy_auevent = AUE_FSTAT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 62 = old freebsd32_fstat */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 63 = obsolete ogetkerninfo */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 63 = obsolete getkerninfo */ { compat(0,getpagesize), .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 64 = old getpagesize */ { .sy_narg = AS(msync_args), .sy_call = (sy_call_t *)sys_msync, .sy_auevent = AUE_MSYNC, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 65 = msync */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 66 = vfork */ @@ -200,7 +206,7 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = AS(mkdir_args), .sy_call = (sy_call_t *)sys_mkdir, .sy_auevent = AUE_MKDIR, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 136 = mkdir */ { .sy_narg = AS(rmdir_args), .sy_call = (sy_call_t *)sys_rmdir, .sy_auevent = AUE_RMDIR, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 137 = rmdir */ { .sy_narg = AS(freebsd32_utimes_args), .sy_call = (sy_call_t *)freebsd32_utimes, .sy_auevent = AUE_UTIMES, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 138 = freebsd32_utimes */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 139 = obsolete sigreturn */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 139 = obsolete freebsd32_sigreturn */ { .sy_narg = AS(freebsd32_adjtime_args), .sy_call = (sy_call_t *)freebsd32_adjtime, .sy_auevent = AUE_ADJTIME, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 140 = freebsd32_adjtime */ { compat(AS(ogetpeername_args),getpeername), .sy_auevent = AUE_GETPEERNAME, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 141 = old getpeername */ { compat(0,gethostid), .sy_auevent = AUE_SYSCTL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 142 = old gethostid */ @@ -215,7 +221,7 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 151 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 152 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 153 = reserved for local use */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 154 = nlm_syscall */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 154 = freebsd32_nlm_syscall */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 155 = nfssvc */ { compat(AS(ofreebsd32_getdirentries_args),freebsd32_getdirentries), .sy_auevent = AUE_GETDIRENTRIES, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 156 = old freebsd32_getdirentries */ { compat4(AS(freebsd4_freebsd32_statfs_args),freebsd32_statfs), .sy_auevent = AUE_STATFS, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 157 = freebsd4 freebsd32_statfs */ @@ -309,7 +315,7 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 245 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 246 = reserved for local use */ { .sy_narg = AS(freebsd32_clock_getcpuclockid2_args), .sy_call = (sy_call_t *)freebsd32_clock_getcpuclockid2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 247 = freebsd32_clock_getcpuclockid2 */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 248 = ntp_gettime */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 248 = freebsd32_ntp_gettime */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 249 = reserved for local use */ { .sy_narg = AS(minherit_args), .sy_call = (sy_call_t *)sys_minherit, .sy_auevent = AUE_MINHERIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 250 = minherit */ { .sy_narg = AS(rfork_args), .sy_call = (sy_call_t *)sys_rfork, .sy_auevent = AUE_RFORK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 251 = rfork */ @@ -398,7 +404,7 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = AS(freebsd32_sched_rr_get_interval_args), .sy_call = (sy_call_t *)freebsd32_sched_rr_get_interval, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 334 = freebsd32_sched_rr_get_interval */ { .sy_narg = AS(utrace_args), .sy_call = (sy_call_t *)sys_utrace, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 335 = utrace */ { compat4(AS(freebsd4_freebsd32_sendfile_args),freebsd32_sendfile), .sy_auevent = AUE_SENDFILE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 336 = freebsd4 freebsd32_sendfile */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 337 = kldsym */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 337 = freebsd32_kldsym */ { .sy_narg = AS(freebsd32_jail_args), .sy_call = (sy_call_t *)freebsd32_jail, .sy_auevent = AUE_JAIL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 338 = freebsd32_jail */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 339 = nnpfs_syscall */ { .sy_narg = AS(sigprocmask_args), .sy_call = (sy_call_t *)sys_sigprocmask, .sy_auevent = AUE_SIGPROCMASK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 340 = sigprocmask */ @@ -438,19 +444,19 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = AS(__setugid_args), .sy_call = (sy_call_t *)sys___setugid, .sy_auevent = AUE_SETUGID, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 374 = __setugid */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 375 = obsolete nfsclnt */ { .sy_narg = AS(eaccess_args), .sy_call = (sy_call_t *)sys_eaccess, .sy_auevent = AUE_EACCESS, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 376 = eaccess */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 377 = afs3_syscall */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 377 = freebsd32_afs3_syscall */ { .sy_narg = AS(freebsd32_nmount_args), .sy_call = (sy_call_t *)freebsd32_nmount, .sy_auevent = AUE_NMOUNT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 378 = freebsd32_nmount */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 379 = obsolete kse_exit */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 380 = obsolete kse_wakeup */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 381 = obsolete kse_create */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 382 = obsolete kse_thr_interrupt */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 383 = obsolete kse_release */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 384 = __mac_get_proc */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 385 = __mac_set_proc */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 386 = __mac_get_fd */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 387 = __mac_get_file */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 388 = __mac_set_fd */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 389 = __mac_set_file */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 384 = freebsd32___mac_get_proc */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 385 = freebsd32___mac_set_proc */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 386 = freebsd32___mac_get_fd */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 387 = freebsd32___mac_get_file */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 388 = freebsd32___mac_set_fd */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 389 = freebsd32___mac_set_file */ { .sy_narg = AS(kenv_args), .sy_call = (sy_call_t *)sys_kenv, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 390 = kenv */ { .sy_narg = AS(lchflags_args), .sy_call = (sy_call_t *)sys_lchflags, .sy_auevent = AUE_LCHFLAGS, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 391 = lchflags */ { .sy_narg = AS(uuidgen_args), .sy_call = (sy_call_t *)sys_uuidgen, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 392 = uuidgen */ @@ -470,13 +476,13 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = AS(ksem_unlink_args), .sy_call = (sy_call_t *)lkmressys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 406 = ksem_unlink */ { .sy_narg = AS(ksem_getvalue_args), .sy_call = (sy_call_t *)lkmressys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 407 = ksem_getvalue */ { .sy_narg = AS(ksem_destroy_args), .sy_call = (sy_call_t *)lkmressys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 408 = ksem_destroy */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 409 = __mac_get_pid */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 410 = __mac_get_link */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 411 = __mac_set_link */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 409 = freebsd32___mac_get_pid */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 410 = freebsd32___mac_get_link */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 411 = freebsd32___mac_set_link */ { .sy_narg = AS(extattr_set_link_args), .sy_call = (sy_call_t *)sys_extattr_set_link, .sy_auevent = AUE_EXTATTR_SET_LINK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 412 = extattr_set_link */ { .sy_narg = AS(extattr_get_link_args), .sy_call = (sy_call_t *)sys_extattr_get_link, .sy_auevent = AUE_EXTATTR_GET_LINK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 413 = extattr_get_link */ { .sy_narg = AS(extattr_delete_link_args), .sy_call = (sy_call_t *)sys_extattr_delete_link, .sy_auevent = AUE_EXTATTR_DELETE_LINK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 414 = extattr_delete_link */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 415 = __mac_execve */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 415 = freebsd32___mac_execve */ { .sy_narg = AS(freebsd32_sigaction_args), .sy_call = (sy_call_t *)freebsd32_sigaction, .sy_auevent = AUE_SIGACTION, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 416 = freebsd32_sigaction */ { .sy_narg = AS(freebsd32_sigreturn_args), .sy_call = (sy_call_t *)freebsd32_sigreturn, .sy_auevent = AUE_SIGRETURN, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 417 = freebsd32_sigreturn */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 418 = reserved for local use */ @@ -491,7 +497,7 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = AS(__acl_delete_link_args), .sy_call = (sy_call_t *)sys___acl_delete_link, .sy_auevent = AUE_ACL_DELETE_LINK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 427 = __acl_delete_link */ { .sy_narg = AS(__acl_aclcheck_link_args), .sy_call = (sy_call_t *)sys___acl_aclcheck_link, .sy_auevent = AUE_ACL_CHECK_LINK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 428 = __acl_aclcheck_link */ { .sy_narg = AS(sigwait_args), .sy_call = (sy_call_t *)sys_sigwait, .sy_auevent = AUE_SIGWAIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 429 = sigwait */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 430 = thr_create */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 430 = freebsd32_thr_create */ { .sy_narg = AS(thr_exit_args), .sy_call = (sy_call_t *)sys_thr_exit, .sy_auevent = AUE_THR_EXIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 431 = thr_exit */ { .sy_narg = AS(thr_self_args), .sy_call = (sy_call_t *)sys_thr_self, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 432 = thr_self */ { .sy_narg = AS(thr_kill_args), .sy_call = (sy_call_t *)sys_thr_kill, .sy_auevent = AUE_THR_KILL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 433 = thr_kill */ diff --git a/sys/compat/freebsd32/freebsd32_systrace_args.c b/sys/compat/freebsd32/freebsd32_systrace_args.c index 13f399264b29..ca300fda8c91 100644 --- a/sys/compat/freebsd32/freebsd32_systrace_args.c +++ b/sys/compat/freebsd32/freebsd32_systrace_args.c @@ -2,7 +2,7 @@ #define PAD64_REQUIRED #endif /* - * System call argument to DTrace register array converstion. + * System call argument to DTrace register array conversion. * * This file is part of the DTrace syscall provider. * diff --git a/sys/compat/freebsd32/syscalls.conf b/sys/compat/freebsd32/syscalls.conf index 81dba8e981f6..1f4b62cfa1c3 100644 --- a/sys/compat/freebsd32/syscalls.conf +++ b/sys/compat/freebsd32/syscalls.conf @@ -19,10 +19,10 @@ abi_ptr_array_t="uint32_t" abi_headers="#include " # -# Variables below this line are exceptions to the ABI changes programatically -# detected by makesyscalls.lua. New system calls should not require an entry -# here in nearly virtually all cases. New entries are almost certainly -# representative of badly designed interfaces. +# Variables below this line are exceptions to the ABI changes +# programmatically detected by sys/tools/syscalls. New system calls +# should not require an entry here in virtually all cases. New entries +# are almost certainly representative of badly designed interfaces. # # System calls that require freebsd32-specific handling: diff --git a/sys/compat/freebsd64/freebsd64_syscall.h b/sys/compat/freebsd64/freebsd64_syscall.h index ba6bf95ec6e2..49a4db2386b5 100644 --- a/sys/compat/freebsd64/freebsd64_syscall.h +++ b/sys/compat/freebsd64/freebsd64_syscall.h @@ -12,7 +12,7 @@ #define FREEBSD64_SYS_freebsd64_open 5 #define FREEBSD64_SYS_close 6 #define FREEBSD64_SYS_freebsd64_wait4 7 - /* 8 is obsolete ocreat */ + /* 8 is obsolete creat */ #define FREEBSD64_SYS_freebsd64_link 9 #define FREEBSD64_SYS_freebsd64_unlink 10 /* 11 is obsolete execv */ @@ -22,8 +22,8 @@ #define FREEBSD64_SYS_freebsd64_chmod 15 #define FREEBSD64_SYS_freebsd64_chown 16 #define FREEBSD64_SYS_freebsd64_break 17 - /* 18 is obsolete freebsd4_getfsstat */ - /* 19 is obsolete olseek */ + /* 18 is obsolete getfsstat */ + /* 19 is obsolete lseek */ #define FREEBSD64_SYS_getpid 20 #define FREEBSD64_SYS_freebsd64_mount 21 #define FREEBSD64_SYS_freebsd64_unmount 22 @@ -42,21 +42,21 @@ #define FREEBSD64_SYS_fchflags 35 #define FREEBSD64_SYS_sync 36 #define FREEBSD64_SYS_kill 37 - /* 38 is obsolete ostat */ + /* 38 is obsolete stat */ #define FREEBSD64_SYS_getppid 39 - /* 40 is obsolete olstat */ + /* 40 is obsolete lstat */ #define FREEBSD64_SYS_dup 41 #define FREEBSD64_SYS_freebsd10_pipe 42 #define FREEBSD64_SYS_getegid 43 #define FREEBSD64_SYS_freebsd64_profil 44 #define FREEBSD64_SYS_freebsd64_ktrace 45 - /* 46 is obsolete osigaction */ + /* 46 is obsolete sigaction */ #define FREEBSD64_SYS_getgid 47 - /* 48 is obsolete osigprocmask */ + /* 48 is obsolete sigprocmask */ #define FREEBSD64_SYS_freebsd64_getlogin 49 #define FREEBSD64_SYS_freebsd64_setlogin 50 #define FREEBSD64_SYS_freebsd64_acct 51 - /* 52 is obsolete osigpending */ + /* 52 is obsolete sigpending */ #define FREEBSD64_SYS_freebsd64_sigaltstack 53 #define FREEBSD64_SYS_freebsd64_ioctl 54 #define FREEBSD64_SYS_reboot 55 @@ -66,16 +66,16 @@ #define FREEBSD64_SYS_freebsd64_execve 59 #define FREEBSD64_SYS_umask 60 #define FREEBSD64_SYS_freebsd64_chroot 61 - /* 62 is obsolete ofstat */ - /* 63 is obsolete ogetkerninfo */ - /* 64 is obsolete ogetpagesize */ + /* 62 is obsolete fstat */ + /* 63 is obsolete getkerninfo */ + /* 64 is obsolete getpagesize */ #define FREEBSD64_SYS_freebsd64_msync 65 #define FREEBSD64_SYS_vfork 66 /* 67 is obsolete vread */ /* 68 is obsolete vwrite */ /* 69 is obsolete sbrk */ /* 70 is obsolete sstk */ - /* 71 is obsolete ommap */ + /* 71 is obsolete mmap */ #define FREEBSD64_SYS_freebsd11_vadvise 72 #define FREEBSD64_SYS_freebsd64_munmap 73 #define FREEBSD64_SYS_freebsd64_mprotect 74 @@ -88,11 +88,11 @@ #define FREEBSD64_SYS_getpgrp 81 #define FREEBSD64_SYS_setpgid 82 #define FREEBSD64_SYS_freebsd64_setitimer 83 - /* 84 is obsolete owait */ + /* 84 is obsolete wait */ #define FREEBSD64_SYS_freebsd64_swapon 85 #define FREEBSD64_SYS_freebsd64_getitimer 86 - /* 87 is obsolete ogethostname */ - /* 88 is obsolete osethostname */ + /* 87 is obsolete gethostname */ + /* 88 is obsolete sethostname */ #define FREEBSD64_SYS_getdtablesize 89 #define FREEBSD64_SYS_dup2 90 #define FREEBSD64_SYS_freebsd64_cheri_cidcap_alloc 91 @@ -102,22 +102,22 @@ #define FREEBSD64_SYS_setpriority 96 #define FREEBSD64_SYS_socket 97 #define FREEBSD64_SYS_freebsd64_connect 98 - /* 99 is obsolete oaccept */ + /* 99 is obsolete accept */ #define FREEBSD64_SYS_getpriority 100 - /* 101 is obsolete osend */ - /* 102 is obsolete orecv */ - /* 103 is obsolete osigreturn */ + /* 101 is obsolete send */ + /* 102 is obsolete recv */ + /* 103 is obsolete sigreturn */ #define FREEBSD64_SYS_freebsd64_bind 104 #define FREEBSD64_SYS_freebsd64_setsockopt 105 #define FREEBSD64_SYS_listen 106 /* 107 is obsolete vtimes */ - /* 108 is obsolete osigvec */ - /* 109 is obsolete osigblock */ - /* 110 is obsolete osigsetmask */ - /* 111 is obsolete osigsuspend */ - /* 112 is obsolete osigstack */ - /* 113 is obsolete orecvmsg */ - /* 114 is obsolete osendmsg */ + /* 108 is obsolete sigvec */ + /* 109 is obsolete sigblock */ + /* 110 is obsolete sigsetmask */ + /* 111 is obsolete sigsuspend */ + /* 112 is obsolete sigstack */ + /* 113 is obsolete recvmsg */ + /* 114 is obsolete sendmsg */ /* 115 is obsolete vtrace */ #define FREEBSD64_SYS_freebsd64_gettimeofday 116 #define FREEBSD64_SYS_freebsd64_getrusage 117 @@ -127,12 +127,12 @@ #define FREEBSD64_SYS_freebsd64_settimeofday 122 #define FREEBSD64_SYS_fchown 123 #define FREEBSD64_SYS_fchmod 124 - /* 125 is obsolete orecvfrom */ + /* 125 is obsolete recvfrom */ #define FREEBSD64_SYS_setreuid 126 #define FREEBSD64_SYS_setregid 127 #define FREEBSD64_SYS_freebsd64_rename 128 - /* 129 is obsolete otruncate */ - /* 130 is obsolete oftruncate */ + /* 129 is obsolete truncate */ + /* 130 is obsolete ftruncate */ #define FREEBSD64_SYS_flock 131 #define FREEBSD64_SYS_freebsd64_mkfifo 132 #define FREEBSD64_SYS_freebsd64_sendto 133 @@ -143,26 +143,26 @@ #define FREEBSD64_SYS_freebsd64_utimes 138 /* 139 is obsolete sigreturn */ #define FREEBSD64_SYS_freebsd64_adjtime 140 - /* 141 is obsolete ogetpeername */ - /* 142 is obsolete ogethostid */ - /* 143 is obsolete osethostid */ - /* 144 is obsolete ogetrlimit */ - /* 145 is obsolete osetrlimit */ - /* 146 is obsolete okillpg */ + /* 141 is obsolete getpeername */ + /* 142 is obsolete gethostid */ + /* 143 is obsolete sethostid */ + /* 144 is obsolete getrlimit */ + /* 145 is obsolete setrlimit */ + /* 146 is obsolete killpg */ #define FREEBSD64_SYS_setsid 147 #define FREEBSD64_SYS_freebsd64_quotactl 148 - /* 149 is obsolete oquota */ - /* 150 is obsolete ogetsockname */ + /* 149 is obsolete quota */ + /* 150 is obsolete getsockname */ #define FREEBSD64_SYS_freebsd64_nlm_syscall 154 #define FREEBSD64_SYS_freebsd64_nfssvc 155 - /* 156 is obsolete ogetdirentries */ - /* 157 is obsolete freebsd4_statfs */ - /* 158 is obsolete freebsd4_fstatfs */ + /* 156 is obsolete getdirentries */ + /* 157 is obsolete statfs */ + /* 158 is obsolete fstatfs */ #define FREEBSD64_SYS_freebsd64_lgetfh 160 #define FREEBSD64_SYS_freebsd64_getfh 161 - /* 162 is obsolete freebsd4_getdomainname */ - /* 163 is obsolete freebsd4_setdomainname */ - /* 164 is obsolete freebsd4_uname */ + /* 162 is obsolete getdomainname */ + /* 163 is obsolete setdomainname */ + /* 164 is obsolete uname */ #define FREEBSD64_SYS_freebsd64_sysarch 165 #define FREEBSD64_SYS_freebsd64_rtprio 166 #define FREEBSD64_SYS_semsys 169 @@ -246,7 +246,7 @@ #define FREEBSD64_SYS_freebsd11_freebsd64_nlstat 280 #define FREEBSD64_SYS_freebsd64_preadv 289 #define FREEBSD64_SYS_freebsd64_pwritev 290 - /* 297 is obsolete freebsd4_fhstatfs */ + /* 297 is obsolete fhstatfs */ #define FREEBSD64_SYS_freebsd64_fhopen 298 #define FREEBSD64_SYS_freebsd11_freebsd64_fhstat 299 #define FREEBSD64_SYS_modnext 300 @@ -285,15 +285,15 @@ #define FREEBSD64_SYS_sched_get_priority_min 333 #define FREEBSD64_SYS_freebsd64_sched_rr_get_interval 334 #define FREEBSD64_SYS_freebsd64_utrace 335 - /* 336 is obsolete freebsd4_sendfile */ + /* 336 is obsolete sendfile */ #define FREEBSD64_SYS_freebsd64_kldsym 337 #define FREEBSD64_SYS_freebsd64_jail 338 #define FREEBSD64_SYS_freebsd64_nnpfs_syscall 339 #define FREEBSD64_SYS_freebsd64_sigprocmask 340 #define FREEBSD64_SYS_freebsd64_sigsuspend 341 - /* 342 is obsolete freebsd4_sigaction */ + /* 342 is obsolete sigaction */ #define FREEBSD64_SYS_freebsd64_sigpending 343 - /* 344 is obsolete freebsd4_sigreturn */ + /* 344 is obsolete sigreturn */ #define FREEBSD64_SYS_freebsd64_sigtimedwait 345 #define FREEBSD64_SYS_freebsd64_sigwaitinfo 346 #define FREEBSD64_SYS_freebsd64___acl_get_file 347 diff --git a/sys/compat/freebsd64/freebsd64_syscalls.c b/sys/compat/freebsd64/freebsd64_syscalls.c index 456d3a395d80..b390df1c56ff 100644 --- a/sys/compat/freebsd64/freebsd64_syscalls.c +++ b/sys/compat/freebsd64/freebsd64_syscalls.c @@ -13,7 +13,7 @@ const char *freebsd64_syscallnames[] = { "freebsd64_open", /* 5 = freebsd64_open */ "close", /* 6 = close */ "freebsd64_wait4", /* 7 = freebsd64_wait4 */ - "obs_ocreat", /* 8 = obsolete ocreat */ + "obs_creat", /* 8 = obsolete creat */ "freebsd64_link", /* 9 = freebsd64_link */ "freebsd64_unlink", /* 10 = freebsd64_unlink */ "obs_execv", /* 11 = obsolete execv */ @@ -23,8 +23,8 @@ const char *freebsd64_syscallnames[] = { "freebsd64_chmod", /* 15 = freebsd64_chmod */ "freebsd64_chown", /* 16 = freebsd64_chown */ "freebsd64_break", /* 17 = freebsd64_break */ - "obs_freebsd4_getfsstat", /* 18 = obsolete freebsd4_getfsstat */ - "obs_olseek", /* 19 = obsolete olseek */ + "obs_getfsstat", /* 18 = obsolete getfsstat */ + "obs_lseek", /* 19 = obsolete lseek */ "getpid", /* 20 = getpid */ "freebsd64_mount", /* 21 = freebsd64_mount */ "freebsd64_unmount", /* 22 = freebsd64_unmount */ @@ -43,21 +43,21 @@ const char *freebsd64_syscallnames[] = { "fchflags", /* 35 = fchflags */ "sync", /* 36 = sync */ "kill", /* 37 = kill */ - "obs_ostat", /* 38 = obsolete ostat */ + "obs_stat", /* 38 = obsolete stat */ "getppid", /* 39 = getppid */ - "obs_olstat", /* 40 = obsolete olstat */ + "obs_lstat", /* 40 = obsolete lstat */ "dup", /* 41 = dup */ "compat10.pipe", /* 42 = freebsd10 pipe */ "getegid", /* 43 = getegid */ "freebsd64_profil", /* 44 = freebsd64_profil */ "freebsd64_ktrace", /* 45 = freebsd64_ktrace */ - "obs_osigaction", /* 46 = obsolete osigaction */ + "obs_sigaction", /* 46 = obsolete sigaction */ "getgid", /* 47 = getgid */ - "obs_osigprocmask", /* 48 = obsolete osigprocmask */ + "obs_sigprocmask", /* 48 = obsolete sigprocmask */ "freebsd64_getlogin", /* 49 = freebsd64_getlogin */ "freebsd64_setlogin", /* 50 = freebsd64_setlogin */ "freebsd64_acct", /* 51 = freebsd64_acct */ - "obs_osigpending", /* 52 = obsolete osigpending */ + "obs_sigpending", /* 52 = obsolete sigpending */ "freebsd64_sigaltstack", /* 53 = freebsd64_sigaltstack */ "freebsd64_ioctl", /* 54 = freebsd64_ioctl */ "reboot", /* 55 = reboot */ @@ -67,16 +67,16 @@ const char *freebsd64_syscallnames[] = { "freebsd64_execve", /* 59 = freebsd64_execve */ "umask", /* 60 = umask */ "freebsd64_chroot", /* 61 = freebsd64_chroot */ - "obs_ofstat", /* 62 = obsolete ofstat */ - "obs_ogetkerninfo", /* 63 = obsolete ogetkerninfo */ - "obs_ogetpagesize", /* 64 = obsolete ogetpagesize */ + "obs_fstat", /* 62 = obsolete fstat */ + "obs_getkerninfo", /* 63 = obsolete getkerninfo */ + "obs_getpagesize", /* 64 = obsolete getpagesize */ "freebsd64_msync", /* 65 = freebsd64_msync */ "vfork", /* 66 = vfork */ "obs_vread", /* 67 = obsolete vread */ "obs_vwrite", /* 68 = obsolete vwrite */ "obs_sbrk", /* 69 = obsolete sbrk */ "obs_sstk", /* 70 = obsolete sstk */ - "obs_ommap", /* 71 = obsolete ommap */ + "obs_mmap", /* 71 = obsolete mmap */ "compat11.vadvise", /* 72 = freebsd11 vadvise */ "freebsd64_munmap", /* 73 = freebsd64_munmap */ "freebsd64_mprotect", /* 74 = freebsd64_mprotect */ @@ -89,11 +89,11 @@ const char *freebsd64_syscallnames[] = { "getpgrp", /* 81 = getpgrp */ "setpgid", /* 82 = setpgid */ "freebsd64_setitimer", /* 83 = freebsd64_setitimer */ - "obs_owait", /* 84 = obsolete owait */ + "obs_wait", /* 84 = obsolete wait */ "freebsd64_swapon", /* 85 = freebsd64_swapon */ "freebsd64_getitimer", /* 86 = freebsd64_getitimer */ - "obs_ogethostname", /* 87 = obsolete ogethostname */ - "obs_osethostname", /* 88 = obsolete osethostname */ + "obs_gethostname", /* 87 = obsolete gethostname */ + "obs_sethostname", /* 88 = obsolete sethostname */ "getdtablesize", /* 89 = getdtablesize */ "dup2", /* 90 = dup2 */ "freebsd64_cheri_cidcap_alloc", /* 91 = freebsd64_cheri_cidcap_alloc */ @@ -104,22 +104,22 @@ const char *freebsd64_syscallnames[] = { "setpriority", /* 96 = setpriority */ "socket", /* 97 = socket */ "freebsd64_connect", /* 98 = freebsd64_connect */ - "obs_oaccept", /* 99 = obsolete oaccept */ + "obs_accept", /* 99 = obsolete accept */ "getpriority", /* 100 = getpriority */ - "obs_osend", /* 101 = obsolete osend */ - "obs_orecv", /* 102 = obsolete orecv */ - "obs_osigreturn", /* 103 = obsolete osigreturn */ + "obs_send", /* 101 = obsolete send */ + "obs_recv", /* 102 = obsolete recv */ + "obs_sigreturn", /* 103 = obsolete sigreturn */ "freebsd64_bind", /* 104 = freebsd64_bind */ "freebsd64_setsockopt", /* 105 = freebsd64_setsockopt */ "listen", /* 106 = listen */ "obs_vtimes", /* 107 = obsolete vtimes */ - "obs_osigvec", /* 108 = obsolete osigvec */ - "obs_osigblock", /* 109 = obsolete osigblock */ - "obs_osigsetmask", /* 110 = obsolete osigsetmask */ - "obs_osigsuspend", /* 111 = obsolete osigsuspend */ - "obs_osigstack", /* 112 = obsolete osigstack */ - "obs_orecvmsg", /* 113 = obsolete orecvmsg */ - "obs_osendmsg", /* 114 = obsolete osendmsg */ + "obs_sigvec", /* 108 = obsolete sigvec */ + "obs_sigblock", /* 109 = obsolete sigblock */ + "obs_sigsetmask", /* 110 = obsolete sigsetmask */ + "obs_sigsuspend", /* 111 = obsolete sigsuspend */ + "obs_sigstack", /* 112 = obsolete sigstack */ + "obs_recvmsg", /* 113 = obsolete recvmsg */ + "obs_sendmsg", /* 114 = obsolete sendmsg */ "obs_vtrace", /* 115 = obsolete vtrace */ "freebsd64_gettimeofday", /* 116 = freebsd64_gettimeofday */ "freebsd64_getrusage", /* 117 = freebsd64_getrusage */ @@ -130,12 +130,12 @@ const char *freebsd64_syscallnames[] = { "freebsd64_settimeofday", /* 122 = freebsd64_settimeofday */ "fchown", /* 123 = fchown */ "fchmod", /* 124 = fchmod */ - "obs_orecvfrom", /* 125 = obsolete orecvfrom */ + "obs_recvfrom", /* 125 = obsolete recvfrom */ "setreuid", /* 126 = setreuid */ "setregid", /* 127 = setregid */ "freebsd64_rename", /* 128 = freebsd64_rename */ - "obs_otruncate", /* 129 = obsolete otruncate */ - "obs_oftruncate", /* 130 = obsolete oftruncate */ + "obs_truncate", /* 129 = obsolete truncate */ + "obs_ftruncate", /* 130 = obsolete ftruncate */ "flock", /* 131 = flock */ "freebsd64_mkfifo", /* 132 = freebsd64_mkfifo */ "freebsd64_sendto", /* 133 = freebsd64_sendto */ @@ -146,30 +146,30 @@ const char *freebsd64_syscallnames[] = { "freebsd64_utimes", /* 138 = freebsd64_utimes */ "obs_sigreturn", /* 139 = obsolete sigreturn */ "freebsd64_adjtime", /* 140 = freebsd64_adjtime */ - "obs_ogetpeername", /* 141 = obsolete ogetpeername */ - "obs_ogethostid", /* 142 = obsolete ogethostid */ - "obs_osethostid", /* 143 = obsolete osethostid */ - "obs_ogetrlimit", /* 144 = obsolete ogetrlimit */ - "obs_osetrlimit", /* 145 = obsolete osetrlimit */ - "obs_okillpg", /* 146 = obsolete okillpg */ + "obs_getpeername", /* 141 = obsolete getpeername */ + "obs_gethostid", /* 142 = obsolete gethostid */ + "obs_sethostid", /* 143 = obsolete sethostid */ + "obs_getrlimit", /* 144 = obsolete getrlimit */ + "obs_setrlimit", /* 145 = obsolete setrlimit */ + "obs_killpg", /* 146 = obsolete killpg */ "setsid", /* 147 = setsid */ "freebsd64_quotactl", /* 148 = freebsd64_quotactl */ - "obs_oquota", /* 149 = obsolete oquota */ - "obs_ogetsockname", /* 150 = obsolete ogetsockname */ + "obs_quota", /* 149 = obsolete quota */ + "obs_getsockname", /* 150 = obsolete getsockname */ "#151", /* 151 = reserved for local use */ "#152", /* 152 = reserved for local use */ "#153", /* 153 = reserved for local use */ "freebsd64_nlm_syscall", /* 154 = freebsd64_nlm_syscall */ "freebsd64_nfssvc", /* 155 = freebsd64_nfssvc */ - "obs_ogetdirentries", /* 156 = obsolete ogetdirentries */ - "obs_freebsd4_statfs", /* 157 = obsolete freebsd4_statfs */ - "obs_freebsd4_fstatfs", /* 158 = obsolete freebsd4_fstatfs */ + "obs_getdirentries", /* 156 = obsolete getdirentries */ + "obs_statfs", /* 157 = obsolete statfs */ + "obs_fstatfs", /* 158 = obsolete fstatfs */ "#159", /* 159 = reserved for local use */ "freebsd64_lgetfh", /* 160 = freebsd64_lgetfh */ "freebsd64_getfh", /* 161 = freebsd64_getfh */ - "obs_freebsd4_getdomainname", /* 162 = obsolete freebsd4_getdomainname */ - "obs_freebsd4_setdomainname", /* 163 = obsolete freebsd4_setdomainname */ - "obs_freebsd4_uname", /* 164 = obsolete freebsd4_uname */ + "obs_getdomainname", /* 162 = obsolete getdomainname */ + "obs_setdomainname", /* 163 = obsolete setdomainname */ + "obs_uname", /* 164 = obsolete uname */ "freebsd64_sysarch", /* 165 = freebsd64_sysarch */ "freebsd64_rtprio", /* 166 = freebsd64_rtprio */ "#167", /* 167 = reserved for local use */ @@ -302,7 +302,7 @@ const char *freebsd64_syscallnames[] = { "#294", /* 294 = reserved for local use */ "#295", /* 295 = reserved for local use */ "#296", /* 296 = reserved for local use */ - "obs_freebsd4_fhstatfs", /* 297 = obsolete freebsd4_fhstatfs */ + "obs_fhstatfs", /* 297 = obsolete fhstatfs */ "freebsd64_fhopen", /* 298 = freebsd64_fhopen */ "compat11.freebsd64_fhstat", /* 299 = freebsd11 freebsd64_fhstat */ "modnext", /* 300 = modnext */ @@ -341,15 +341,15 @@ const char *freebsd64_syscallnames[] = { "sched_get_priority_min", /* 333 = sched_get_priority_min */ "freebsd64_sched_rr_get_interval", /* 334 = freebsd64_sched_rr_get_interval */ "freebsd64_utrace", /* 335 = freebsd64_utrace */ - "obs_freebsd4_sendfile", /* 336 = obsolete freebsd4_sendfile */ + "obs_sendfile", /* 336 = obsolete sendfile */ "freebsd64_kldsym", /* 337 = freebsd64_kldsym */ "freebsd64_jail", /* 338 = freebsd64_jail */ "freebsd64_nnpfs_syscall", /* 339 = freebsd64_nnpfs_syscall */ "freebsd64_sigprocmask", /* 340 = freebsd64_sigprocmask */ "freebsd64_sigsuspend", /* 341 = freebsd64_sigsuspend */ - "obs_freebsd4_sigaction", /* 342 = obsolete freebsd4_sigaction */ + "obs_sigaction", /* 342 = obsolete sigaction */ "freebsd64_sigpending", /* 343 = freebsd64_sigpending */ - "obs_freebsd4_sigreturn", /* 344 = obsolete freebsd4_sigreturn */ + "obs_sigreturn", /* 344 = obsolete sigreturn */ "freebsd64_sigtimedwait", /* 345 = freebsd64_sigtimedwait */ "freebsd64_sigwaitinfo", /* 346 = freebsd64_sigwaitinfo */ "freebsd64___acl_get_file", /* 347 = freebsd64___acl_get_file */ diff --git a/sys/compat/freebsd64/freebsd64_sysent.c b/sys/compat/freebsd64/freebsd64_sysent.c index 68854b0dfd26..120834fba110 100644 --- a/sys/compat/freebsd64/freebsd64_sysent.c +++ b/sys/compat/freebsd64/freebsd64_sysent.c @@ -11,6 +11,18 @@ #define AS(name) (sizeof(struct name) / sizeof(syscallarg_t)) +#ifdef COMPAT_43 +#define compat(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(o, name) +#else +#define compat(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys +#endif + +#ifdef COMPAT_FREEBSD4 +#define compat4(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(freebsd4_, name) +#else +#define compat4(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys +#endif + #ifdef COMPAT_FREEBSD6 #define compat6(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(freebsd6_, name) #else @@ -47,6 +59,12 @@ #define compat13(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys #endif +#ifdef COMPAT_FREEBSD14 +#define compat14(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(freebsd14_, name) +#else +#define compat14(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys +#endif + /* The casts are bogus but will do for now. */ struct sysent freebsd64_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 0 = syscall */ @@ -57,7 +75,7 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(freebsd64_open_args), .sy_call = (sy_call_t *)freebsd64_open, .sy_auevent = AUE_OPEN_RWTC, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 5 = freebsd64_open */ { .sy_narg = AS(close_args), .sy_call = (sy_call_t *)sys_close, .sy_auevent = AUE_CLOSE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 6 = close */ { .sy_narg = AS(freebsd64_wait4_args), .sy_call = (sy_call_t *)freebsd64_wait4, .sy_auevent = AUE_WAIT4, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 7 = freebsd64_wait4 */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 8 = obsolete ocreat */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 8 = obsolete creat */ { .sy_narg = AS(freebsd64_link_args), .sy_call = (sy_call_t *)freebsd64_link, .sy_auevent = AUE_LINK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 9 = freebsd64_link */ { .sy_narg = AS(freebsd64_unlink_args), .sy_call = (sy_call_t *)freebsd64_unlink, .sy_auevent = AUE_UNLINK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 10 = freebsd64_unlink */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 11 = obsolete execv */ @@ -67,8 +85,8 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(freebsd64_chmod_args), .sy_call = (sy_call_t *)freebsd64_chmod, .sy_auevent = AUE_CHMOD, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 15 = freebsd64_chmod */ { .sy_narg = AS(freebsd64_chown_args), .sy_call = (sy_call_t *)freebsd64_chown, .sy_auevent = AUE_CHOWN, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 16 = freebsd64_chown */ { .sy_narg = AS(freebsd64_break_args), .sy_call = (sy_call_t *)freebsd64_break, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 17 = freebsd64_break */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 18 = obsolete freebsd4_getfsstat */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 19 = obsolete olseek */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 18 = obsolete getfsstat */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 19 = obsolete lseek */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_getpid, .sy_auevent = AUE_GETPID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 20 = getpid */ { .sy_narg = AS(freebsd64_mount_args), .sy_call = (sy_call_t *)freebsd64_mount, .sy_auevent = AUE_MOUNT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 21 = freebsd64_mount */ { .sy_narg = AS(freebsd64_unmount_args), .sy_call = (sy_call_t *)freebsd64_unmount, .sy_auevent = AUE_UMOUNT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 22 = freebsd64_unmount */ @@ -87,21 +105,21 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(fchflags_args), .sy_call = (sy_call_t *)sys_fchflags, .sy_auevent = AUE_FCHFLAGS, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 35 = fchflags */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_sync, .sy_auevent = AUE_SYNC, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 36 = sync */ { .sy_narg = AS(kill_args), .sy_call = (sy_call_t *)sys_kill, .sy_auevent = AUE_KILL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 37 = kill */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 38 = obsolete ostat */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 38 = obsolete stat */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_getppid, .sy_auevent = AUE_GETPPID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 39 = getppid */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 40 = obsolete olstat */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 40 = obsolete lstat */ { .sy_narg = AS(dup_args), .sy_call = (sy_call_t *)sys_dup, .sy_auevent = AUE_DUP, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 41 = dup */ { compat10(0,pipe), .sy_auevent = AUE_PIPE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 42 = freebsd10 pipe */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_getegid, .sy_auevent = AUE_GETEGID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 43 = getegid */ { .sy_narg = AS(freebsd64_profil_args), .sy_call = (sy_call_t *)freebsd64_profil, .sy_auevent = AUE_PROFILE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 44 = freebsd64_profil */ { .sy_narg = AS(freebsd64_ktrace_args), .sy_call = (sy_call_t *)freebsd64_ktrace, .sy_auevent = AUE_KTRACE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 45 = freebsd64_ktrace */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 46 = obsolete osigaction */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 46 = obsolete sigaction */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_getgid, .sy_auevent = AUE_GETGID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 47 = getgid */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 48 = obsolete osigprocmask */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 48 = obsolete sigprocmask */ { .sy_narg = AS(freebsd64_getlogin_args), .sy_call = (sy_call_t *)freebsd64_getlogin, .sy_auevent = AUE_GETLOGIN, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 49 = freebsd64_getlogin */ { .sy_narg = AS(freebsd64_setlogin_args), .sy_call = (sy_call_t *)freebsd64_setlogin, .sy_auevent = AUE_SETLOGIN, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 50 = freebsd64_setlogin */ { .sy_narg = AS(freebsd64_acct_args), .sy_call = (sy_call_t *)freebsd64_acct, .sy_auevent = AUE_ACCT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 51 = freebsd64_acct */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 52 = obsolete osigpending */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 52 = obsolete sigpending */ { .sy_narg = AS(freebsd64_sigaltstack_args), .sy_call = (sy_call_t *)freebsd64_sigaltstack, .sy_auevent = AUE_SIGALTSTACK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 53 = freebsd64_sigaltstack */ { .sy_narg = AS(freebsd64_ioctl_args), .sy_call = (sy_call_t *)freebsd64_ioctl, .sy_auevent = AUE_IOCTL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 54 = freebsd64_ioctl */ { .sy_narg = AS(reboot_args), .sy_call = (sy_call_t *)sys_reboot, .sy_auevent = AUE_REBOOT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 55 = reboot */ @@ -111,16 +129,16 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(freebsd64_execve_args), .sy_call = (sy_call_t *)freebsd64_execve, .sy_auevent = AUE_EXECVE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 59 = freebsd64_execve */ { .sy_narg = AS(umask_args), .sy_call = (sy_call_t *)sys_umask, .sy_auevent = AUE_UMASK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 60 = umask */ { .sy_narg = AS(freebsd64_chroot_args), .sy_call = (sy_call_t *)freebsd64_chroot, .sy_auevent = AUE_CHROOT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 61 = freebsd64_chroot */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 62 = obsolete ofstat */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 63 = obsolete ogetkerninfo */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 64 = obsolete ogetpagesize */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 62 = obsolete fstat */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 63 = obsolete getkerninfo */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 64 = obsolete getpagesize */ { .sy_narg = AS(freebsd64_msync_args), .sy_call = (sy_call_t *)freebsd64_msync, .sy_auevent = AUE_MSYNC, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 65 = freebsd64_msync */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 66 = vfork */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 67 = obsolete vread */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 68 = obsolete vwrite */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 69 = obsolete sbrk */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 70 = obsolete sstk */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 71 = obsolete ommap */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 71 = obsolete mmap */ { compat11(AS(freebsd11_vadvise_args),vadvise), .sy_auevent = AUE_O_VADVISE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 72 = freebsd11 vadvise */ { .sy_narg = AS(freebsd64_munmap_args), .sy_call = (sy_call_t *)freebsd64_munmap, .sy_auevent = AUE_MUNMAP, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 73 = freebsd64_munmap */ { .sy_narg = AS(freebsd64_mprotect_args), .sy_call = (sy_call_t *)freebsd64_mprotect, .sy_auevent = AUE_MPROTECT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 74 = freebsd64_mprotect */ @@ -133,11 +151,11 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)sys_getpgrp, .sy_auevent = AUE_GETPGRP, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 81 = getpgrp */ { .sy_narg = AS(setpgid_args), .sy_call = (sy_call_t *)sys_setpgid, .sy_auevent = AUE_SETPGRP, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 82 = setpgid */ { .sy_narg = AS(freebsd64_setitimer_args), .sy_call = (sy_call_t *)freebsd64_setitimer, .sy_auevent = AUE_SETITIMER, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 83 = freebsd64_setitimer */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 84 = obsolete owait */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 84 = obsolete wait */ { .sy_narg = AS(freebsd64_swapon_args), .sy_call = (sy_call_t *)freebsd64_swapon, .sy_auevent = AUE_SWAPON, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 85 = freebsd64_swapon */ { .sy_narg = AS(freebsd64_getitimer_args), .sy_call = (sy_call_t *)freebsd64_getitimer, .sy_auevent = AUE_GETITIMER, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 86 = freebsd64_getitimer */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 87 = obsolete ogethostname */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 88 = obsolete osethostname */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 87 = obsolete gethostname */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 88 = obsolete sethostname */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_getdtablesize, .sy_auevent = AUE_GETDTABLESIZE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 89 = getdtablesize */ { .sy_narg = AS(dup2_args), .sy_call = (sy_call_t *)sys_dup2, .sy_auevent = AUE_DUP2, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 90 = dup2 */ { .sy_narg = AS(freebsd64_cheri_cidcap_alloc_args), .sy_call = (sy_call_t *)freebsd64_cheri_cidcap_alloc, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 91 = freebsd64_cheri_cidcap_alloc */ @@ -148,22 +166,22 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(setpriority_args), .sy_call = (sy_call_t *)sys_setpriority, .sy_auevent = AUE_SETPRIORITY, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 96 = setpriority */ { .sy_narg = AS(socket_args), .sy_call = (sy_call_t *)sys_socket, .sy_auevent = AUE_SOCKET, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 97 = socket */ { .sy_narg = AS(freebsd64_connect_args), .sy_call = (sy_call_t *)freebsd64_connect, .sy_auevent = AUE_CONNECT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 98 = freebsd64_connect */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 99 = obsolete oaccept */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 99 = obsolete accept */ { .sy_narg = AS(getpriority_args), .sy_call = (sy_call_t *)sys_getpriority, .sy_auevent = AUE_GETPRIORITY, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 100 = getpriority */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 101 = obsolete osend */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 102 = obsolete orecv */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 103 = obsolete osigreturn */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 101 = obsolete send */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 102 = obsolete recv */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 103 = obsolete sigreturn */ { .sy_narg = AS(freebsd64_bind_args), .sy_call = (sy_call_t *)freebsd64_bind, .sy_auevent = AUE_BIND, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 104 = freebsd64_bind */ { .sy_narg = AS(freebsd64_setsockopt_args), .sy_call = (sy_call_t *)freebsd64_setsockopt, .sy_auevent = AUE_SETSOCKOPT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 105 = freebsd64_setsockopt */ { .sy_narg = AS(listen_args), .sy_call = (sy_call_t *)sys_listen, .sy_auevent = AUE_LISTEN, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 106 = listen */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 107 = obsolete vtimes */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 108 = obsolete osigvec */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 109 = obsolete osigblock */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 110 = obsolete osigsetmask */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 111 = obsolete osigsuspend */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 112 = obsolete osigstack */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 113 = obsolete orecvmsg */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 114 = obsolete osendmsg */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 108 = obsolete sigvec */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 109 = obsolete sigblock */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 110 = obsolete sigsetmask */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 111 = obsolete sigsuspend */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 112 = obsolete sigstack */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 113 = obsolete recvmsg */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 114 = obsolete sendmsg */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 115 = obsolete vtrace */ { .sy_narg = AS(freebsd64_gettimeofday_args), .sy_call = (sy_call_t *)freebsd64_gettimeofday, .sy_auevent = AUE_GETTIMEOFDAY, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 116 = freebsd64_gettimeofday */ { .sy_narg = AS(freebsd64_getrusage_args), .sy_call = (sy_call_t *)freebsd64_getrusage, .sy_auevent = AUE_GETRUSAGE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 117 = freebsd64_getrusage */ @@ -174,12 +192,12 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(freebsd64_settimeofday_args), .sy_call = (sy_call_t *)freebsd64_settimeofday, .sy_auevent = AUE_SETTIMEOFDAY, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 122 = freebsd64_settimeofday */ { .sy_narg = AS(fchown_args), .sy_call = (sy_call_t *)sys_fchown, .sy_auevent = AUE_FCHOWN, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 123 = fchown */ { .sy_narg = AS(fchmod_args), .sy_call = (sy_call_t *)sys_fchmod, .sy_auevent = AUE_FCHMOD, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 124 = fchmod */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 125 = obsolete orecvfrom */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 125 = obsolete recvfrom */ { .sy_narg = AS(setreuid_args), .sy_call = (sy_call_t *)sys_setreuid, .sy_auevent = AUE_SETREUID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 126 = setreuid */ { .sy_narg = AS(setregid_args), .sy_call = (sy_call_t *)sys_setregid, .sy_auevent = AUE_SETREGID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 127 = setregid */ { .sy_narg = AS(freebsd64_rename_args), .sy_call = (sy_call_t *)freebsd64_rename, .sy_auevent = AUE_RENAME, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 128 = freebsd64_rename */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 129 = obsolete otruncate */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 130 = obsolete oftruncate */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 129 = obsolete truncate */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 130 = obsolete ftruncate */ { .sy_narg = AS(flock_args), .sy_call = (sy_call_t *)sys_flock, .sy_auevent = AUE_FLOCK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 131 = flock */ { .sy_narg = AS(freebsd64_mkfifo_args), .sy_call = (sy_call_t *)freebsd64_mkfifo, .sy_auevent = AUE_MKFIFO, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 132 = freebsd64_mkfifo */ { .sy_narg = AS(freebsd64_sendto_args), .sy_call = (sy_call_t *)freebsd64_sendto, .sy_auevent = AUE_SENDTO, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 133 = freebsd64_sendto */ @@ -190,30 +208,30 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(freebsd64_utimes_args), .sy_call = (sy_call_t *)freebsd64_utimes, .sy_auevent = AUE_UTIMES, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 138 = freebsd64_utimes */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 139 = obsolete sigreturn */ { .sy_narg = AS(freebsd64_adjtime_args), .sy_call = (sy_call_t *)freebsd64_adjtime, .sy_auevent = AUE_ADJTIME, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 140 = freebsd64_adjtime */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 141 = obsolete ogetpeername */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 142 = obsolete ogethostid */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 143 = obsolete osethostid */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 144 = obsolete ogetrlimit */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 145 = obsolete osetrlimit */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 146 = obsolete okillpg */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 141 = obsolete getpeername */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 142 = obsolete gethostid */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 143 = obsolete sethostid */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 144 = obsolete getrlimit */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 145 = obsolete setrlimit */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 146 = obsolete killpg */ { .sy_narg = 0, .sy_call = (sy_call_t *)sys_setsid, .sy_auevent = AUE_SETSID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 147 = setsid */ { .sy_narg = AS(freebsd64_quotactl_args), .sy_call = (sy_call_t *)freebsd64_quotactl, .sy_auevent = AUE_QUOTACTL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 148 = freebsd64_quotactl */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 149 = obsolete oquota */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 150 = obsolete ogetsockname */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 149 = obsolete quota */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 150 = obsolete getsockname */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 151 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 152 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 153 = reserved for local use */ { .sy_narg = AS(freebsd64_nlm_syscall_args), .sy_call = (sy_call_t *)lkmressys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 154 = freebsd64_nlm_syscall */ { .sy_narg = AS(freebsd64_nfssvc_args), .sy_call = (sy_call_t *)lkmressys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 155 = freebsd64_nfssvc */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 156 = obsolete ogetdirentries */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 157 = obsolete freebsd4_statfs */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 158 = obsolete freebsd4_fstatfs */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 156 = obsolete getdirentries */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 157 = obsolete statfs */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 158 = obsolete fstatfs */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 159 = reserved for local use */ { .sy_narg = AS(freebsd64_lgetfh_args), .sy_call = (sy_call_t *)freebsd64_lgetfh, .sy_auevent = AUE_LGETFH, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 160 = freebsd64_lgetfh */ { .sy_narg = AS(freebsd64_getfh_args), .sy_call = (sy_call_t *)freebsd64_getfh, .sy_auevent = AUE_NFS_GETFH, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 161 = freebsd64_getfh */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 162 = obsolete freebsd4_getdomainname */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 163 = obsolete freebsd4_setdomainname */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 164 = obsolete freebsd4_uname */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 162 = obsolete getdomainname */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 163 = obsolete setdomainname */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 164 = obsolete uname */ { .sy_narg = AS(freebsd64_sysarch_args), .sy_call = (sy_call_t *)freebsd64_sysarch, .sy_auevent = AUE_SYSARCH, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 165 = freebsd64_sysarch */ { .sy_narg = AS(freebsd64_rtprio_args), .sy_call = (sy_call_t *)freebsd64_rtprio, .sy_auevent = AUE_RTPRIO, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 166 = freebsd64_rtprio */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 167 = reserved for local use */ @@ -309,8 +327,8 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(freebsd64_lio_listio_args), .sy_call = (sy_call_t *)freebsd64_lio_listio, .sy_auevent = AUE_LIO_LISTIO, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 257 = freebsd64_lio_listio */ { .sy_narg = AS(freebsd64_kbounce_args), .sy_call = (sy_call_t *)freebsd64_kbounce, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 258 = freebsd64_kbounce */ { .sy_narg = AS(freebsd64_flag_captured_args), .sy_call = (sy_call_t *)freebsd64_flag_captured, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 259 = freebsd64_flag_captured */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 260 = cheri_revoke_get_shadow */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 261 = cheri_revoke */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 260 = freebsd64_cheri_revoke_get_shadow */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 261 = freebsd64_cheri_revoke */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 262 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 263 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 264 = reserved for local use */ @@ -346,7 +364,7 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 294 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 295 = reserved for local use */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 296 = reserved for local use */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 297 = obsolete freebsd4_fhstatfs */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 297 = obsolete fhstatfs */ { .sy_narg = AS(freebsd64_fhopen_args), .sy_call = (sy_call_t *)freebsd64_fhopen, .sy_auevent = AUE_FHOPEN, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 298 = freebsd64_fhopen */ { compat11(AS(freebsd11_freebsd64_fhstat_args),freebsd64_fhstat), .sy_auevent = AUE_FHSTAT, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 299 = freebsd11 freebsd64_fhstat */ { .sy_narg = AS(modnext_args), .sy_call = (sy_call_t *)sys_modnext, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 300 = modnext */ @@ -385,15 +403,15 @@ struct sysent freebsd64_sysent[] = { { .sy_narg = AS(sched_get_priority_min_args), .sy_call = (sy_call_t *)sys_sched_get_priority_min, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 333 = sched_get_priority_min */ { .sy_narg = AS(freebsd64_sched_rr_get_interval_args), .sy_call = (sy_call_t *)freebsd64_sched_rr_get_interval, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 334 = freebsd64_sched_rr_get_interval */ { .sy_narg = AS(freebsd64_utrace_args), .sy_call = (sy_call_t *)freebsd64_utrace, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 335 = freebsd64_utrace */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 336 = obsolete freebsd4_sendfile */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 336 = obsolete sendfile */ { .sy_narg = AS(freebsd64_kldsym_args), .sy_call = (sy_call_t *)freebsd64_kldsym, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 337 = freebsd64_kldsym */ { .sy_narg = AS(freebsd64_jail_args), .sy_call = (sy_call_t *)freebsd64_jail, .sy_auevent = AUE_JAIL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 338 = freebsd64_jail */ { .sy_narg = AS(freebsd64_nnpfs_syscall_args), .sy_call = (sy_call_t *)lkmressys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 339 = freebsd64_nnpfs_syscall */ { .sy_narg = AS(freebsd64_sigprocmask_args), .sy_call = (sy_call_t *)freebsd64_sigprocmask, .sy_auevent = AUE_SIGPROCMASK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 340 = freebsd64_sigprocmask */ { .sy_narg = AS(freebsd64_sigsuspend_args), .sy_call = (sy_call_t *)freebsd64_sigsuspend, .sy_auevent = AUE_SIGSUSPEND, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 341 = freebsd64_sigsuspend */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 342 = obsolete freebsd4_sigaction */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 342 = obsolete sigaction */ { .sy_narg = AS(freebsd64_sigpending_args), .sy_call = (sy_call_t *)freebsd64_sigpending, .sy_auevent = AUE_SIGPENDING, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 343 = freebsd64_sigpending */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 344 = obsolete freebsd4_sigreturn */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 344 = obsolete sigreturn */ { .sy_narg = AS(freebsd64_sigtimedwait_args), .sy_call = (sy_call_t *)freebsd64_sigtimedwait, .sy_auevent = AUE_SIGWAIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 345 = freebsd64_sigtimedwait */ { .sy_narg = AS(freebsd64_sigwaitinfo_args), .sy_call = (sy_call_t *)freebsd64_sigwaitinfo, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 346 = freebsd64_sigwaitinfo */ { .sy_narg = AS(freebsd64___acl_get_file_args), .sy_call = (sy_call_t *)freebsd64___acl_get_file, .sy_auevent = AUE_ACL_GET_FILE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 347 = freebsd64___acl_get_file */ diff --git a/sys/compat/freebsd64/freebsd64_systrace_args.c b/sys/compat/freebsd64/freebsd64_systrace_args.c index 214d396900ee..61d63b58e312 100644 --- a/sys/compat/freebsd64/freebsd64_systrace_args.c +++ b/sys/compat/freebsd64/freebsd64_systrace_args.c @@ -1,5 +1,5 @@ /* - * System call argument to DTrace register array converstion. + * System call argument to DTrace register array conversion. * * This file is part of the DTrace syscall provider. * diff --git a/sys/conf/sysent.mk b/sys/conf/sysent.mk index 1be84181e152..b146cd4f83e4 100644 --- a/sys/conf/sysent.mk +++ b/sys/conf/sysent.mk @@ -24,14 +24,8 @@ SYSENT_CONF?= syscalls.conf SRCS+= ${SYSENT_FILE} SRCS+= ${SYSENT_CONF} -# Ensure that the target gets updated if the capabilities file is modified, -# even though it is not an explicit input to makesyscalls.lua. For some -# targets, like Linux system calls, this is unnecessary, but a spurious rebuild -# is both rare and harmless. -SRCS+= ${CAPABILITIES_CONF} - MAKESYSCALLS_INTERP?= ${LUA} -MAKESYSCALLS_SCRIPT?= ${SYSDIR}/tools/makesyscalls.lua +MAKESYSCALLS_SCRIPT?= ${SYSDIR}/tools/syscalls/main.lua MAKESYSCALLS= ${MAKESYSCALLS_INTERP} ${MAKESYSCALLS_SCRIPT} all: @@ -42,9 +36,8 @@ all: .ORDER: ${GENERATED} sysent: ${GENERATED} -# We slap a .PHONY on makesyscalls.lua so that we regenerate every single time, -# for now, which can be less painful across rebases or other things that may -# have odd effects on mtimes. +# We slap a .PHONY on MAKESYSCALLS_SCRIPT so that we regenerate every +# single time rather than tracking all internal dependencies for now. ${MAKESYSCALLS_SCRIPT}: .PHONY ${GENERATED}: ${MAKESYSCALLS_SCRIPT} ${SRCS} diff --git a/sys/i386/linux/linux_systrace_args.c b/sys/i386/linux/linux_systrace_args.c index 041ee80fd4ff..f3e3c32a2bbf 100644 --- a/sys/i386/linux/linux_systrace_args.c +++ b/sys/i386/linux/linux_systrace_args.c @@ -1,5 +1,5 @@ /* - * System call argument to DTrace register array converstion. + * System call argument to DTrace register array conversion. * * This file is part of the DTrace syscall provider. * diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index e14576df34fc..9ecadb29e49a 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -58,6 +58,12 @@ #define compat13(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys #endif +#ifdef COMPAT_FREEBSD14 +#define compat14(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(freebsd14_, name) +#else +#define compat14(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys +#endif + /* The casts are bogus but will do for now. */ struct sysent sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 0 = syscall */ diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 626d7a074e3a..feb749d7358d 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -46,6 +46,7 @@ ; NOPROTO same as STD except do not create structure or ; function prototype in sys/sysproto.h. Does add a ; definition to syscall.h besides adding a sysent. +; NOLIB don't create stubs in libc or libsys ; NOTSTATIC syscall is loadable ; SYSMUX syscall multiplexer. No prototype, argument struct, or ; handler is declared or used. Handled in MD syscall code. @@ -58,10 +59,10 @@ ; - Use u_int and u_long rather than "unsigned (int|long)". ; - size_t is allowed. ; - typedefs are allowed, but new signed types that vary between 32- and -; 64-bit ABIs must be added to makesyscalls.lua so it knows they require -; handling. +; 64-bit ABIs must be added to config.known_abi_flags in +; sys/tools/syscalls/config.lua so it knows they require handling. ; - Always-64-bit types other than dev_t, id_t, and off_t must be added to -; makesyscalls.lua. +; util.is64bitType in sys/tools/syscalls/tools/util.lua. ; For pointers: ; - Prefer structs to typedefs so an ABI-specific suffix (e.g., "32") can ; be prepended (e.g., ucontext_t -> struct ucontext -> struct ucontext32). @@ -1494,7 +1495,7 @@ int flags ); } -259 AUE_NULL STD { +259 AUE_NULL STD|NOLIB { int flag_captured( _In_z_ const char *message, uint32_t key @@ -1704,7 +1705,7 @@ _In_opt_ _Contains_ptr_ struct osigevent *sig ); } -321 AUE_NULL STD|CAPENABLED { +321 AUE_NULL STD|CAPENABLED|NOLIB { int yield(void); } 322 AUE_NULL OBSOL thr_sleep diff --git a/sys/kern/systrace_args.c b/sys/kern/systrace_args.c index 9d4eb4b922aa..95dd4ce6b518 100644 --- a/sys/kern/systrace_args.c +++ b/sys/kern/systrace_args.c @@ -1,5 +1,5 @@ /* - * System call argument to DTrace register array converstion. + * System call argument to DTrace register array conversion. * * This file is part of the DTrace syscall provider. * diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk index eb38726ad59b..1b7d8272d22b 100644 --- a/sys/sys/syscall.mk +++ b/sys/sys/syscall.mk @@ -171,7 +171,6 @@ MIASM = \ aio_write.o \ lio_listio.o \ kbounce.o \ - flag_captured.o \ cheri_revoke_get_shadow.o \ cheri_revoke.o \ freebsd11_getdents.o \ @@ -201,7 +200,6 @@ MIASM = \ aio_suspend.o \ aio_cancel.o \ aio_error.o \ - yield.o \ mlockall.o \ munlockall.o \ __getcwd.o \ diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua deleted file mode 100644 index e33048f6c047..000000000000 --- a/sys/tools/makesyscalls.lua +++ /dev/null @@ -1,1757 +0,0 @@ --- --- SPDX-License-Identifier: BSD-2-Clause --- --- Copyright (c) 2019 Kyle Evans --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions --- are met: --- 1. Redistributions of source code must retain the above copyright --- notice, this list of conditions and the following disclaimer. --- 2. Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND --- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE --- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE --- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE --- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT --- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY --- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF --- SUCH DAMAGE. --- - - --- We generally assume that this script will be run by flua, however we've --- carefully crafted modules for it that mimic interfaces provided by modules --- available in ports. Currently, this script is compatible with lua from ports --- along with the compatible luafilesystem and lua-posix modules. -local lfs = require("lfs") -local unistd = require("posix.unistd") - -local savesyscall = -1 -local maxsyscall = -1 -local structs = {} -local generated_tag = "@" .. "generated" - --- Default configuration; any of these may get replaced by a configuration file --- optionally specified. -local config = { - abi_func_prefix = "", - libsysmap = "/dev/null", - libsys_h = "/dev/null", - sysargmap = "/dev/null", - sysargmap_h = "_SYS_SYSARGMAP_H_", - sysnames = "syscalls.c", - sysproto = "../sys/sysproto.h", - sysproto_h = "_SYS_SYSPROTO_H_", - syshdr = "../sys/syscall.h", - sysmk = "/dev/null", - syssw = "init_sysent.c", - syscallprefix = "SYS_", - switchname = "sysent", - namesname = "syscallnames", - systrace = "systrace_args.c", - capabilities_conf = "capabilities.conf", - capenabled = {}, - compat_set = "native", - mincompat = 0, - abi_type_suffix = "", - abi_flags = "", - abi_flags_mask = 0, - abi_headers = "", - abi_intptr_t = "intptr_t", - abi_size_t = "size_t", - abi_u_long = "u_long", - abi_long = "long", - abi_semid_t = "semid_t", - abi_ptr_array_t = "", - ptr_intptr_t_cast = "intptr_t", - ptr_qualified="*", - sysargmaskname = "sysargmask", - syscall_abi_change = "", - sys_abi_change = {}, - syscall_no_abi_change = "", - sys_no_abi_change = {}, - obsol = "", - obsol_dict = {}, - unimpl = "", - unimpl_dict = {}, -} - -local config_modified = {} -local cleantmp = true -local tmpspace = "/tmp/sysent." .. unistd.getpid() .. "/" - -local output_files = { - "sysargmap", - "sysnames", - "syshdr", - "sysmk", - "libsysmap", - "libsys_h", - "syssw", - "systrace", - "sysproto", -} - --- These ones we'll create temporary files for; generation purposes. -local temp_files = { - "libsys_h_type", - "libsys_h_func", - "sysaue", - "sysdcl", - "syscompat", - "syscompatdcl", - "sysent", - "sysinc", - "sysarg", - "sysprotoend", - "systracetmp", - "systraceret", -} - --- Opened files -local files = {} - -local function cleanup() - for _, v in pairs(files) do - assert(v:close()) - end - if cleantmp then - if lfs.dir(tmpspace) then - for fname in lfs.dir(tmpspace) do - if fname ~= "." and fname ~= ".." then - assert(os.remove(tmpspace .. "/" .. - fname)) - end - end - end - - if lfs.attributes(tmpspace) and not lfs.rmdir(tmpspace) then - assert(io.stderr:write("Failed to clean up tmpdir: " .. - tmpspace .. "\n")) - end - else - assert(io.stderr:write("Temp files left in " .. tmpspace .. - "\n")) - end -end - -local function abort(status, msg) - assert(io.stderr:write(msg .. "\n")) - cleanup() - os.exit(status) -end - --- Each entry should have a value so we can represent abi flags as a bitmask --- for convenience. One may also optionally provide an expr; this gets applied --- to each argument type to indicate whether this argument is subject to ABI --- change given the configured flags. -local known_abi_flags = { - long_size = { - value = 0x00000001, - exprs = { - "_Contains[a-z_]*_long_", - "^long [a-z0-9_]+$", - "long [*]", - "size_t [*]", - -- semid_t is not included because it is only used - -- as an argument or written out individually and - -- said writes are handled by the ksem framework. - -- Technically a sign-extension issue exists for - -- arguments, but because semid_t is actually a file - -- descriptor negative 32-bit values are invalid - -- regardless of sign-extension. - }, - }, - time_t_size = { - value = 0x00000002, - exprs = { - "_Contains[a-z_]*_timet_", - }, - }, - pointer_args = { - value = 0x00000004, - }, - pointer_size = { - value = 0x00000008, - exprs = { - "_Contains[a-z_]*_ptr_", - "[*][*]", - }, - }, - pair_64bit = { - value = 0x00000010, - exprs = { - "^dev_t[ ]*$", - "^id_t[ ]*$", - "^off_t[ ]*$", - }, - }, -} - -local known_flags = { - STD = 0x00000001, - OBSOL = 0x00000002, - RESERVED = 0x00000004, - UNIMPL = 0x00000008, - NODEF = 0x00000010, - NOARGS = 0x00000020, - NOPROTO = 0x00000040, - NOSTD = 0x00000080, - NOTSTATIC = 0x00000100, - CAPENABLED = 0x00000200, - SYSMUX = 0x00000400, - - -- Compat flags start from here. We have plenty of space. -} - --- All compat option entries should have five entries: --- definition: The preprocessor macro that will be set for this --- compatlevel: The level this compatibility should be included at. This --- generally represents the version of FreeBSD that it is compatible --- with, but ultimately it's just the level of mincompat in which it's --- included. --- flag: The name of the flag in syscalls.master. --- prefix: The prefix to use for _args and syscall prototype. This will be --- used as-is, without "_" or any other character appended. --- descr: The description of this compat option in init_sysent.c comments. --- The special "stdcompat" entry will cause the other five to be autogenerated. -local compat_option_sets = { - native = { - { - definition = "COMPAT_43", - compatlevel = 3, - flag = "COMPAT", - prefix = "o", - descr = "old", - }, - { stdcompat = "FREEBSD4" }, - { stdcompat = "FREEBSD6" }, - { stdcompat = "FREEBSD7" }, - { stdcompat = "FREEBSD10" }, - { stdcompat = "FREEBSD11" }, - { stdcompat = "FREEBSD12" }, - { stdcompat = "FREEBSD13" }, - { stdcompat = "FREEBSD14" }, - }, -} - --- compat_options will be resolved to a set from the configuration. -local compat_options - -local function trim(s, char) - if s == nil then - return nil - end - if char == nil then - char = "%s" - end - return s:gsub("^" .. char .. "+", ""):gsub(char .. "+$", "") -end - --- config looks like a shell script; in fact, the previous makesyscalls.sh --- script actually sourced it in. It had a pretty common format, so we should --- be fine to make various assumptions -local function process_config(file) - local cfg = {} - local comment_line_expr = "^%s*#.*" - -- We capture any whitespace padding here so we can easily advance to - -- the end of the line as needed to check for any trailing bogus bits. - -- Alternatively, we could drop the whitespace and instead try to - -- use a pattern to strip out the meaty part of the line, but then we - -- would need to sanitize the line for potentially special characters. - local line_expr = "^([%w%p]+%s*)=(%s*[`\"]?[^\"`]*[`\"]?)" - - if not file then - return nil, "No file given" - end - - local fh = assert(io.open(file)) - - for nextline in fh:lines() do - -- Strip any whole-line comments - nextline = nextline:gsub(comment_line_expr, "") - -- Parse it into key, value pairs - local key, value = nextline:match(line_expr) - if key ~= nil and value ~= nil then - local kvp = key .. "=" .. value - key = trim(key) - value = trim(value) - local delim = value:sub(1,1) - if delim == '"' then - local trailing_context - - -- Strip off the key/value part - trailing_context = nextline:sub(kvp:len() + 1) - -- Strip off any trailing comment - trailing_context = trailing_context:gsub("#.*$", - "") - -- Strip off leading/trailing whitespace - trailing_context = trim(trailing_context) - if trailing_context ~= "" then - print(trailing_context) - abort(1, "Malformed line: " .. nextline) - end - - value = trim(value, delim) - else - -- Strip off potential comments - value = value:gsub("#.*$", "") - -- Strip off any padding whitespace - value = trim(value) - if value:match("%s") then - abort(1, "Malformed config line: " .. - nextline) - end - end - -- Heuristically convert anything fully numeric - -- to a number to allow us to compare compat levels. - if tonumber(value) ~= nil then - value = tonumber(value) - end - cfg[key] = value - elseif not nextline:match("^%s*$") then - -- Make sure format violations don't get overlooked - -- here, but ignore blank lines. Comments are already - -- stripped above. - abort(1, "Malformed config line: " .. nextline) - end - end - - assert(io.close(fh)) - return cfg -end - -local function grab_capenabled(file, open_fail_ok) - local capentries = {} - local commentExpr = "#.*" - - if file == nil then - print "No file" - return {} - end - - local fh = io.open(file) - if fh == nil then - if not open_fail_ok then - abort(1, "Failed to open " .. file) - end - return {} - end - - for nextline in fh:lines() do - -- Strip any comments - nextline = nextline:gsub(commentExpr, "") - if nextline ~= "" then - capentries[nextline] = true - end - end - - assert(io.close(fh)) - return capentries -end - -local function process_compat() - local nval = 0 - for _, v in pairs(known_flags) do - if v > nval then - nval = v - end - end - - nval = nval << 1 - for _, v in pairs(compat_options) do - if v.stdcompat ~= nil then - local stdcompat = v.stdcompat - v.definition = "COMPAT_" .. stdcompat:upper() - v.compatlevel = tonumber(stdcompat:match("([0-9]+)$")) - v.flag = stdcompat:gsub("FREEBSD", "COMPAT") - v.prefix = stdcompat:lower() .. "_" - v.descr = stdcompat:lower() - end - - local tmpname = "sys" .. v.flag:lower() - local dcltmpname = tmpname .. "dcl" - files[tmpname] = io.tmpfile() - files[dcltmpname] = io.tmpfile() - v.tmp = tmpname - v.dcltmp = dcltmpname - - known_flags[v.flag] = nval - v.mask = nval - nval = nval << 1 - - v.count = 0 - end -end - -local function process_abi_flags() - local flags, mask = config.abi_flags, 0 - for txtflag in flags:gmatch("([^|]+)") do - if known_abi_flags[txtflag] == nil then - abort(1, "Unknown abi_flag: " .. txtflag) - end - - mask = mask | known_abi_flags[txtflag].value - end - - config.abi_flags_mask = mask -end - -local function process_obsol() - local obsol = config.obsol - for syscall in obsol:gmatch("([^ ]+)") do - config.obsol_dict[syscall] = true - end -end - -local function process_unimpl() - local unimpl = config.unimpl - for syscall in unimpl:gmatch("([^ ]+)") do - config.unimpl_dict[syscall] = true - end -end - -local function process_syscall_abi_change() - local changes_abi = config.syscall_abi_change - for syscall in changes_abi:gmatch("([^ ]+)") do - config.sys_abi_change[syscall] = true - end - - local no_changes = config.syscall_no_abi_change - for syscall in no_changes:gmatch("([^ ]+)") do - config.sys_no_abi_change[syscall] = true - end -end - -local function abi_changes(name) - if known_abi_flags[name] == nil then - abort(1, "abi_changes: unknown flag: " .. name) - end - - return config.abi_flags_mask & known_abi_flags[name].value ~= 0 -end - -local function strip_abi_prefix(funcname) - local abiprefix = config.abi_func_prefix - local stripped_name - if funcname == nil then - return nil - end - if abiprefix ~= "" and funcname:find("^" .. abiprefix) then - stripped_name = funcname:gsub("^" .. abiprefix, "") - else - stripped_name = funcname - end - - return stripped_name -end - -local function read_file(tmpfile) - if files[tmpfile] == nil then - print("Not found: " .. tmpfile) - return - end - - local fh = files[tmpfile] - assert(fh:seek("set")) - return assert(fh:read("a")) -end - -local function write_line(tmpfile, line) - if files[tmpfile] == nil then - print("Not found: " .. tmpfile) - return - end - assert(files[tmpfile]:write(line)) -end - -local function write_line_pfile(tmppat, line) - for k in pairs(files) do - if k:match(tmppat) ~= nil then - assert(files[k]:write(line)) - end - end -end - --- Check both literal intptr_t and the abi version because this needs --- to work both before and after the substitution -local function isptrtype(type) - return type:find("*") or type:find("caddr_t") or - type:find("intptr_t") or type:find(config.abi_intptr_t) -end - -local function isptrarraytype(type) - return type:find("[*][*]") or type:find("[*][ ]*const[ ]*[*]") -end - --- Find types that are always 64-bits wide -local function is64bittype(type) - return type:find("^dev_t[ ]*$") or type:find("^id_t[ ]*$") or type:find("^off_t[ ]*$") -end - -local process_syscall_def - --- These patterns are processed in order on any line that isn't empty. -local pattern_table = { - { - dump_prevline = true, - pattern = "^#%s*include", - process = function(line) - line = line .. "\n" - write_line("sysinc", line) - end, - }, - { - dump_prevline = true, - pattern = "^#", - process = function(line) - if line:find("^#%s*if") then - savesyscall = maxsyscall - elseif line:find("^#%s*else") then - maxsyscall = savesyscall - end - line = line .. "\n" - write_line("sysent", line) - write_line("sysdcl", line) - write_line("sysarg", line) - write_line_pfile("syscompat[0-9]*$", line) - write_line("sysnames", line) - write_line_pfile("systrace.*", line) - end, - }, - { - dump_prevline = true, - pattern = "%%ABI_HEADERS%%", - process = function() - if config.abi_headers ~= "" then - local line = config.abi_headers .. "\n" - write_line("sysinc", line) - end - end, - }, - { - -- Buffer anything else - pattern = ".+", - process = function(line, prevline) - local incomplete = line:find("\\$") ~= nil - -- Lines that end in \ get the \ stripped - -- Lines that start with a syscall number, prepend \n - line = trim(line):gsub("\\$", "") - if line:find("^[0-9]") and prevline then - process_syscall_def(prevline) - prevline = nil - end - - prevline = (prevline or '') .. line - incomplete = incomplete or prevline:find(",$") ~= nil - incomplete = incomplete or prevline:find("{") ~= nil and - prevline:find("}") == nil - if prevline:find("^[0-9]") and not incomplete then - process_syscall_def(prevline) - prevline = nil - end - - return prevline - end, - }, -} - -local function process_sysfile(file) - local capentries = {} - local commentExpr = "^%s*;.*" - - if file == nil then - print "No file" - return {} - end - - local fh = io.open(file) - if fh == nil then - print("Failed to open " .. file) - return {} - end - - local function do_match(nextline, prevline) - local pattern, handler, dump - for _, v in pairs(pattern_table) do - pattern = v.pattern - handler = v.process - dump = v.dump_prevline - if nextline:match(pattern) then - if dump and prevline then - process_syscall_def(prevline) - prevline = nil - end - - return handler(nextline, prevline) - end - end - - abort(1, "Failed to handle: " .. nextline) - end - - local prevline - for nextline in fh:lines() do - -- Strip any comments - nextline = nextline:gsub(commentExpr, "") - if nextline ~= "" then - prevline = do_match(nextline, prevline) - end - end - - -- Dump any remainder - if prevline ~= nil and prevline:find("^[0-9]") then - process_syscall_def(prevline) - end - - assert(io.close(fh)) - return capentries -end - -local function get_mask(flags) - local mask = 0 - for _, v in ipairs(flags) do - if known_flags[v] == nil then - abort(1, "Checking for unknown flag " .. v) - end - - mask = mask | known_flags[v] - end - - return mask -end - -local function get_mask_pat(pflags) - local mask = 0 - for k, v in pairs(known_flags) do - if k:find(pflags) then - mask = mask | v - end - end - - return mask -end - -local function strip_arg_annotations(arg) - arg = arg:gsub("_Contains_[^ ]*[_)] ?", "") - arg = arg:gsub("_In[^ ]*[_)] ?", "") - arg = arg:gsub("_Out[^ ]*[_)] ?", "") - return trim(arg) -end - -local function check_abi_changes(arg) - for k, v in pairs(known_abi_flags) do - local exprs = v.exprs - if abi_changes(k) and exprs ~= nil then - for _, e in pairs(exprs) do - if arg:find(e) then - return true - end - end - end - end - - return false -end - -local function process_args(args) - local funcargs = {} - local changes_abi = false - - for arg in args:gmatch("([^,]+)") do - local arg_abi_change = check_abi_changes(arg) - changes_abi = changes_abi or arg_abi_change - - arg = strip_arg_annotations(arg) - - local argname = arg:match("([^* ]+)$") - - -- argtype is... everything else. - local argtype = trim(arg:gsub(argname .. "$", ""), nil) - - if argtype == "" and argname == "void" then - goto out - end - - -- is64bittype() needs a bare type so check it after argname - -- is removed - changes_abi = changes_abi or (abi_changes("pair_64bit") and is64bittype(argtype)) - - argtype = argtype:gsub("intptr_t", config.abi_intptr_t) - argtype = argtype:gsub("semid_t", config.abi_semid_t) - if isptrtype(argtype) then - argtype = argtype:gsub("size_t", config.abi_size_t) - argtype = argtype:gsub("^long", config.abi_long); - argtype = argtype:gsub("^u_long", config.abi_u_long); - argtype = argtype:gsub("^const u_long", "const " .. config.abi_u_long); - elseif argtype:find("^long$") then - argtype = config.abi_long - end - if isptrarraytype(argtype) and config.abi_ptr_array_t ~= "" then - -- `* const *` -> `**` - argtype = argtype:gsub("[*][ ]*const[ ]*[*]", "**") - -- e.g., `struct aiocb **` -> `uint32_t *` - argtype = argtype:gsub("[^*]*[*]", config.abi_ptr_array_t .. " ", 1) - end - - -- XX TODO: Forward declarations? See: sysstubfwd in CheriBSD - if arg_abi_change then - local abi_type_suffix = config.abi_type_suffix - argtype = argtype:gsub("(struct [^ ]*)", "%1" .. - abi_type_suffix) - argtype = argtype:gsub("(union [^ ]*)", "%1" .. - abi_type_suffix) - end - - -- Allow pointers to be qualified - argtype = argtype:gsub("[*]", config['ptr_qualified']) - argtype = argtype:gsub(" *$", "") - - -- Strip extra whitespace around pointers - argtype = argtype:gsub(" *", " ") - - if abi_changes("pair_64bit") and is64bittype(argtype) then - if #funcargs % 2 == 1 then - funcargs[#funcargs + 1] = { - type = "int", - name = "_pad", - } - end - funcargs[#funcargs + 1] = { - type = "uint32_t", - name = argname .. "1", - } - funcargs[#funcargs + 1] = { - type = "uint32_t", - name = argname .. "2", - } - else - funcargs[#funcargs + 1] = { - type = argtype, - name = argname, - } - end - end - - ::out:: - return funcargs, changes_abi -end - -local function handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype, - auditev, syscallret, funcname, funcalias, funcargs, argalias) - local argssize - - if flags & known_flags.SYSMUX ~= 0 then - argssize = "0" - elseif #funcargs > 0 or flags & known_flags.NODEF ~= 0 then - argssize = "AS(" .. argalias .. ")" - else - argssize = "0" - end - - write_line("systrace", string.format([[ - /* %s */ - case %d: { -]], funcname, sysnum)) - write_line("systracetmp", string.format([[ - /* %s */ - case %d: -]], funcname, sysnum)) - write_line("systraceret", string.format([[ - /* %s */ - case %d: -]], funcname, sysnum)) - - if #funcargs > 0 and flags & known_flags.SYSMUX == 0 then - write_line("systracetmp", "\t\tswitch (ndx) {\n") - write_line("systrace", string.format( - "\t\tstruct %s *p = params;\n", argalias)) - - - local argtype, argname, desc, padding - padding = "" - for idx, arg in ipairs(funcargs) do - argtype = arg.type - argname = arg.name - - argtype = trim(argtype:gsub("__restrict$", ""), nil) - if argtype == "int" and argname == "_pad" and abi_changes("pair_64bit") then - write_line("systracetmp", "#ifdef PAD64_REQUIRED\n") - end - -- Pointer arg? - if argtype:find("*") then - desc = "userland " .. argtype - else - desc = argtype; - end - write_line("systracetmp", string.format( - "\t\tcase %d%s:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", - idx - 1, padding, desc)) - if argtype == "int" and argname == "_pad" and abi_changes("pair_64bit") then - padding = " - _P_" - write_line("systracetmp", "#define _P_ 0\n#else\n#define _P_ 1\n#endif\n") - end - - if isptrtype(argtype) then - write_line("systrace", string.format( - "\t\tuarg[a++] = (%s)p->%s; /* %s */\n", - config.ptr_intptr_t_cast, - argname, argtype)) - elseif argtype == "union l_semun" then - write_line("systrace", string.format( - "\t\tuarg[a++] = p->%s.buf; /* %s */\n", - argname, argtype)) - elseif argtype:sub(1,1) == "u" or argtype == "size_t" then - write_line("systrace", string.format( - "\t\tuarg[a++] = p->%s; /* %s */\n", - argname, argtype)) - else - if argtype == "int" and argname == "_pad" and abi_changes("pair_64bit") then - write_line("systrace", "#ifdef PAD64_REQUIRED\n") - end - write_line("systrace", string.format( - "\t\tiarg[a++] = p->%s; /* %s */\n", - argname, argtype)) - if argtype == "int" and argname == "_pad" and abi_changes("pair_64bit") then - write_line("systrace", "#endif\n") - end - end - end - - write_line("systracetmp", - "\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") - if padding ~= "" then - write_line("systracetmp", "#undef _P_\n\n") - end - - write_line("systraceret", string.format([[ - if (ndx == 0 || ndx == 1) - p = "%s"; - break; -]], syscallret)) - end - local n_args = #funcargs - if flags & known_flags.SYSMUX ~= 0 then - n_args = 0 - end - write_line("systrace", string.format( - "\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", n_args)) - write_line("systracetmp", "\t\tbreak;\n") - - local nargflags = get_mask({"NOARGS", "NOPROTO", "NODEF"}) - if flags & nargflags == 0 then - if #funcargs > 0 then - write_line("sysarg", string.format("struct %s {\n", - argalias)) - for _, v in ipairs(funcargs) do - local argname, argtype = v.name, v.type - if argtype == "int" and argname == "_pad" and abi_changes("pair_64bit") then - write_line("sysarg", "#ifdef PAD64_REQUIRED\n") - end - write_line("sysarg", string.format( - "\tchar %s_l_[PADL_(%s)]; %s %s; char %s_r_[PADR_(%s)];\n", - argname, argtype, - argtype, argname, - argname, argtype)) - if argtype == "int" and argname == "_pad" and abi_changes("pair_64bit") then - write_line("sysarg", "#endif\n") - end - end - write_line("sysarg", "};\n") - else - write_line("sysarg", string.format( - "struct %s {\n\tsyscallarg_t dummy;\n};\n", argalias)) - end - end - - local daflags = get_mask({"NOPROTO", "NODEF"}) - if flags & daflags == 0 then - write_line("sysargmap", string.format("\t[%s%s] = (0x0", - config["syscallprefix"], funcalias)) - local i = 0 - for _, v in ipairs(funcargs) do - if isptrtype(v["type"]) then - write_line("sysargmap", string.format(" | 0x%x", - 1 << i)) - end - i = i + 1 - end - write_line("sysargmap", "),\n") - end - - local protoflags = get_mask({"NOPROTO", "NODEF"}) - if flags & protoflags == 0 then - local sys_prefix = "sys_" - if funcname == "nosys" or funcname == "lkmnosys" or - funcname == "sysarch" or funcname:find("^freebsd") or - funcname:find("^linux") then - sys_prefix = "" - end - write_line("sysdcl", string.format( - "%s\t%s%s(struct thread *, struct %s *);\n", - rettype, sys_prefix, funcname, argalias)) - write_line("sysaue", string.format("#define\t%sAUE_%s\t%s\n", - config.syscallprefix, funcalias, auditev)) - end - - write_line("sysent", - string.format("\t{ .sy_narg = %s, .sy_call = (sy_call_t *)", argssize)) - - if flags & known_flags.SYSMUX ~= 0 then - write_line("sysent", string.format( - "nosys, .sy_auevent = AUE_NULL, " .. - ".sy_flags = %s, .sy_thrcnt = SY_THR_STATIC },", - sysflags)) - elseif flags & known_flags.NOSTD ~= 0 then - write_line("sysent", string.format( - "lkmressys, .sy_auevent = AUE_NULL, " .. - ".sy_flags = %s, .sy_thrcnt = SY_THR_ABSENT },", - sysflags)) - else - if funcname == "nosys" or funcname == "lkmnosys" or - funcname == "sysarch" or funcname:find("^freebsd") or - funcname:find("^linux") then - write_line("sysent", string.format( - "%s, .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = %s },", - funcname, auditev, sysflags, thr_flag)) - else - write_line("sysent", string.format( - "sys_%s, .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = %s },", - funcname, auditev, sysflags, thr_flag)) - end - end - - write_line("sysent", string.format("\t/* %d = %s */\n", - sysnum, funcalias)) - write_line("sysnames", string.format("\t\"%s\",\t\t\t/* %d = %s */\n", - funcalias, sysnum, funcalias)) - - if flags & known_flags.NODEF == 0 then - write_line("syshdr", string.format("#define\t%s%s\t%d\n", - config.syscallprefix, funcalias, sysnum)) - write_line("sysmk", string.format(" \\\n\t%s.o", - funcalias)) - -- yield has never been exposed as a syscall - if funcalias == "yield" then - return - end - -- flag_captured has never been exposed as a syscall - if funcalias == "flag_captured" then - return - end - if funcalias ~= "exit" and funcalias ~= "vfork" then - write_line("libsysmap", string.format("\t_%s;\n", - funcalias)) - end - write_line("libsysmap", string.format("\t__sys_%s;\n", - funcalias)) - - if flags & known_flags.SYSMUX == 0 then - local argstr_type = "" - local argstr_var = "" - local comma = "" - if #funcargs == 0 then - argstr_type = "void" - argstr_var = "void" - end - for _, v in ipairs(funcargs) do - local argname, argtype = v.name, v.type - argstr_type = argstr_type .. comma .. argtype - argstr_var = argstr_var .. comma .. argtype .. " " .. argname - comma = ", " - - -- Accumulate a list of struct types for - -- forward decls. We can't do this in - -- process_args because we don't want compat - -- types in userspace even as no-op. - if isptrtype(argtype) then - local is_struct = false - for word in argtype:gmatch("[^ *]+") do - if is_struct then - structs[word] = word - break - end - if word == "struct" then - is_struct = true - -- next word is the name - end - end - end - end - write_line("libsys_h_type", - string.format("typedef %s (__sys_%s_t)(%s);\n", - syscallret, funcalias, argstr_type)) - write_line("libsys_h_func", - string.format("%s __sys_%s(%s);\n", - syscallret, funcalias, argstr_var)) - - end - end -end - -local function handle_obsol(sysnum, funcname, comment) - write_line("sysent", - "\t{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, " .. - ".sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },") - - write_line("sysent", string.format("\t/* %d = obsolete %s */\n", - sysnum, comment)) - write_line("sysnames", string.format( - "\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", - funcname, sysnum, comment)) - write_line("syshdr", string.format("\t\t\t\t/* %d is obsolete %s */\n", - sysnum, comment)) -end - -local function handle_compat(sysnum, thr_flag, flags, sysflags, rettype, - auditev, funcname, funcalias, funcargs, argalias) - local argssize, out, outdcl, wrap, prefix, descr - - if #funcargs > 0 or flags & known_flags.NODEF ~= 0 then - argssize = "AS(" .. argalias .. ")" - else - argssize = "0" - end - - for _, v in pairs(compat_options) do - if flags & v.mask ~= 0 then - if config.mincompat > v.compatlevel then - funcname = strip_abi_prefix(funcname) - funcname = v.prefix .. funcname - return handle_obsol(sysnum, funcname, funcname) - end - v.count = v.count + 1 - out = v.tmp - outdcl = v.dcltmp - wrap = v.flag:lower() - prefix = v.prefix - descr = v.descr - goto compatdone - end - end - - ::compatdone:: - local dprotoflags = get_mask({"NOPROTO", "NODEF"}) - local nargflags = dprotoflags | known_flags.NOARGS - if #funcargs > 0 and flags & nargflags == 0 then - write_line(out, string.format("struct %s {\n", argalias)) - for _, v in ipairs(funcargs) do - local argname, argtype = v.name, v.type - write_line(out, string.format( - "\tchar %s_l_[PADL_(%s)]; %s %s; char %s_r_[PADR_(%s)];\n", - argname, argtype, - argtype, argname, - argname, argtype)) - end - write_line(out, "};\n") - elseif flags & nargflags == 0 then - write_line("sysarg", string.format( - "struct %s {\n\tsyscallarg_t dummy;\n};\n", argalias)) - end - if flags & dprotoflags == 0 then - write_line(outdcl, string.format( - "%s\t%s%s(struct thread *, struct %s *);\n", - rettype, prefix, funcname, argalias)) - write_line("sysaue", string.format( - "#define\t%sAUE_%s%s\t%s\n", config.syscallprefix, - prefix, funcname, auditev)) - end - - if flags & known_flags.NOSTD ~= 0 then - write_line("sysent", string.format( - "\t{ .sy_narg = %s, .sy_call = (sy_call_t *)%s, " .. - ".sy_auevent = %s, .sy_flags = 0, " .. - ".sy_thrcnt = SY_THR_ABSENT },", - "0", "lkmressys", "AUE_NULL")) - else - write_line("sysent", string.format( - "\t{ %s(%s,%s), .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = %s },", - wrap, argssize, funcname, auditev, sysflags, thr_flag)) - end - - write_line("sysent", string.format("\t/* %d = %s %s */\n", - sysnum, descr, funcalias)) - write_line("sysnames", string.format( - "\t\"%s.%s\",\t\t/* %d = %s %s */\n", - wrap, funcalias, sysnum, descr, funcalias)) - -- Do not provide freebsdN_* symbols in libc for < FreeBSD 7 - local nosymflags = get_mask({"COMPAT", "COMPAT4", "COMPAT6"}) - if flags & nosymflags ~= 0 then - write_line("syshdr", string.format( - "\t\t\t\t/* %d is %s %s */\n", - sysnum, descr, funcalias)) - elseif flags & known_flags.NODEF == 0 then - write_line("syshdr", string.format("#define\t%s%s%s\t%d\n", - config.syscallprefix, prefix, funcalias, sysnum)) - write_line("sysmk", string.format(" \\\n\t%s%s.o", - prefix, funcalias)) - end -end - -local function handle_unimpl(sysnum, sysstart, sysend, comment) - if sysstart == nil and sysend == nil then - sysstart = tonumber(sysnum) - sysend = tonumber(sysnum) - end - - sysnum = sysstart - while sysnum <= sysend do - write_line("sysent", string.format( - "\t{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, " .. - ".sy_auevent = AUE_NULL, .sy_flags = 0, " .. - ".sy_thrcnt = SY_THR_ABSENT },\t/* %d = %s */\n", - sysnum, comment)) - write_line("sysnames", string.format( - "\t\"#%d\",\t\t\t/* %d = %s */\n", - sysnum, sysnum, comment)) - sysnum = sysnum + 1 - end -end - -local function handle_reserved(sysnum, sysstart, sysend) - handle_unimpl(sysnum, sysstart, sysend, "reserved for local use") -end - -process_syscall_def = function(line) - local sysstart, sysend, flags, funcname, sysflags - local thr_flag, syscallret - local orig = line - flags = 0 - thr_flag = "SY_THR_STATIC" - - -- Parse out the interesting information first - local initialExpr = "^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s*" - local sysnum, auditev, allflags = line:match(initialExpr) - - if sysnum == nil or auditev == nil or allflags == nil then - -- XXX TODO: Better? - abort(1, "Completely malformed: " .. line) - end - - if sysnum:find("-") then - sysstart, sysend = sysnum:match("^([%d]+)-([%d]+)$") - if sysstart == nil or sysend == nil then - abort(1, "Malformed range: " .. sysnum) - end - sysnum = nil - sysstart = tonumber(sysstart) - sysend = tonumber(sysend) - if sysstart ~= maxsyscall + 1 then - abort(1, "syscall number out of sync, missing " .. - maxsyscall + 1) - end - else - sysnum = tonumber(sysnum) - if sysnum ~= maxsyscall + 1 then - abort(1, "syscall number out of sync, missing " .. - maxsyscall + 1) - end - end - - -- Split flags - for flag in allflags:gmatch("([^|]+)") do - if known_flags[flag] == nil then - abort(1, "Unknown flag " .. flag .. " for " .. sysnum) - end - flags = flags | known_flags[flag] - end - - if (flags & get_mask({"RESERVED", "UNIMPL"})) == 0 and sysnum == nil then - abort(1, "Range only allowed with RESERVED and UNIMPL: " .. line) - end - - if (flags & known_flags.NOTSTATIC) ~= 0 then - thr_flag = "SY_THR_ABSENT" - end - - -- Strip earlier bits out, leave declaration + alt - line = line:gsub("^.+" .. allflags .. "%s*", "") - - local decl_fnd = line:find("^{") ~= nil - if decl_fnd and line:find("}") == nil then - abort(1, "Malformed, no closing brace: " .. line) - end - - local decl, alt - if decl_fnd then - line = line:gsub("^{", "") - decl, alt = line:match("([^}]*)}[%s]*(.*)$") - else - alt = line - end - - if decl == nil and alt == nil then - abort(1, "Malformed bits: " .. line) - end - - local funcalias, funcomment, argalias, rettype, args - if not decl_fnd and alt ~= nil and alt ~= "" then - -- Peel off one entry for name - funcname = trim(alt:match("^([^%s]+)"), nil) - alt = alt:gsub("^([^%s]+)[%s]*", "") - end - -- Do we even need it? - if flags & get_mask({"OBSOL", "UNIMPL"}) ~= 0 then - local NF = 0 - for _ in orig:gmatch("[^%s]+") do - NF = NF + 1 - end - - funcomment = funcname or '' - if NF < 6 then - funcomment = funcomment .. " " .. alt - end - - funcomment = trim(funcomment) - --- if funcname ~= nil then --- else --- funcomment = trim(alt) --- end - goto skipalt - end - - if alt ~= nil and alt ~= "" then - local altExpr = "^([^%s]+)%s+([^%s]+)%s+([^%s]+)" - funcalias, argalias, rettype = alt:match(altExpr) - funcalias = trim(funcalias) - if funcalias == nil or argalias == nil or rettype == nil then - abort(1, "Malformed alt: " .. line) - end - end - if decl_fnd then - -- Don't clobber rettype set in the alt information - if rettype == nil then - rettype = "int" - end - -- Peel off the return type - syscallret = line:match("([^%s]+)%s") - line = line:match("[^%s]+%s(.+)") - -- Pointer incoming - if line:sub(1,1) == "*" then - syscallret = syscallret .. " " - end - while line:sub(1,1) == "*" do - line = line:sub(2) - syscallret = syscallret .. "*" - end - funcname = line:match("^([^(]+)%(") - if funcname == nil then - abort(1, "Not a signature? " .. line) - end - args = line:match("^[^(]+%((.+)%)[^)]*$") - args = trim(args, '[,%s]') - end - - ::skipalt:: - - if funcname == nil then - funcname = funcalias - end - - funcname = trim(funcname) - - if config.obsol_dict[funcname] then - local compat_prefix = "" - for _, v in pairs(compat_options) do - if flags & v.mask ~= 0 then - compat_prefix = v.prefix - goto obsol_compat_done - end - end - ::obsol_compat_done:: - args = nil - flags = known_flags.OBSOL - funcomment = compat_prefix .. funcname - end - if config.unimpl_dict[funcname] then - flags = known_flags.UNIMPL - funcomment = funcname - end - - sysflags = "0" - - -- NODEF events do not get audited - if flags & known_flags.NODEF ~= 0 then - auditev = 'AUE_NULL' - end - - -- If applicable; strip the ABI prefix from the name - local stripped_name = strip_abi_prefix(funcname) - - if flags & known_flags.CAPENABLED ~= 0 or - config.capenabled[funcname] ~= nil or - config.capenabled[stripped_name] ~= nil then - sysflags = "SYF_CAPENABLED" - end - - local funcargs = {} - local changes_abi = false - if args ~= nil then - funcargs, changes_abi = process_args(args) - end - if config.sys_no_abi_change[funcname] then - changes_abi = false - end - local noproto = config.abi_flags ~= "" and not changes_abi - - local argprefix = '' - local funcprefix = '' - if abi_changes("pointer_args") then - for _, v in ipairs(funcargs) do - if isptrtype(v.type) then - if config.sys_no_abi_change[funcname] then - print("WARNING: " .. funcname .. - " in syscall_no_abi_change, but pointers args are present") - end - changes_abi = true - goto ptrfound - end - end - ::ptrfound:: - end - if config.sys_abi_change[funcname] then - changes_abi = true - end - if changes_abi then - -- argalias should be: - -- COMPAT_PREFIX + ABI Prefix + funcname - argprefix = config.abi_func_prefix - funcprefix = config.abi_func_prefix - funcalias = funcprefix .. funcname - noproto = false - end - if funcname ~= nil then - funcname = funcprefix .. funcname - end - if funcalias == nil or funcalias == "" then - funcalias = funcname - end - - if argalias == nil and funcname ~= nil then - argalias = funcname .. "_args" - for _, v in pairs(compat_options) do - local mask = v.mask - if (flags & mask) ~= 0 then - -- Multiple aliases doesn't seem to make - -- sense. - argalias = v.prefix .. argalias - goto out - end - end - ::out:: - elseif argalias ~= nil then - argalias = argprefix .. argalias - end - - local ncompatflags = get_mask({"STD", "NODEF", "NOARGS", "NOPROTO", - "NOSTD"}) - local compatflags = get_mask_pat("COMPAT.*") - if noproto or flags & known_flags.SYSMUX ~= 0 then - flags = flags | known_flags.NOPROTO; - end - if flags & known_flags.OBSOL ~= 0 then - handle_obsol(sysnum, funcname, funcomment) - elseif flags & known_flags.RESERVED ~= 0 then - handle_reserved(sysnum, sysstart, sysend) - elseif flags & known_flags.UNIMPL ~= 0 then - handle_unimpl(sysnum, sysstart, sysend, funcomment) - elseif flags & compatflags ~= 0 then - if flags & known_flags.STD ~= 0 then - abort(1, "Incompatible COMPAT/STD: " .. line) - end - handle_compat(sysnum, thr_flag, flags, sysflags, rettype, - auditev, funcname, funcalias, funcargs, argalias) - elseif flags & ncompatflags ~= 0 then - handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype, - auditev, syscallret, funcname, funcalias, funcargs, - argalias) - else - abort(1, "Bad flags? " .. line) - end - - if sysend ~= nil then - maxsyscall = sysend - elseif sysnum ~= nil then - maxsyscall = sysnum - end -end - -local function pairsByKeys (t, f) - local a = {} - for n in pairs(t) do table.insert(a, n) end - table.sort(a, f) - local i = 0 -- iterator variable - local iter = function () -- iterator function - i = i + 1 - if a[i] == nil then return nil - else return a[i], t[a[i]] - end - end - return iter -end - --- Entry point - -if #arg < 1 or #arg > 2 then - error("usage: " .. arg[0] .. " input-file ") -end - -local sysfile, configfile = arg[1], arg[2] - --- process_config either returns nil and a message, or a --- table that we should merge into the global config -if configfile ~= nil then - local res = assert(process_config(configfile)) - - for k, v in pairs(res) do - if v ~= config[k] then - config[k] = v - config_modified[k] = true - end - end -end - -local compat_set = config.compat_set -if compat_set ~= "" then - if not compat_option_sets[compat_set] then - abort(1, "Undefined compat set: " .. compat_set) - end - - compat_options = compat_option_sets[compat_set] -else - compat_options = {} -end - --- We ignore errors here if we're relying on the default configuration. -if not config_modified.capenabled then - config.capenabled = grab_capenabled(config.capabilities_conf, - config_modified.capabilities_conf == nil) -elseif config.capenabled ~= "" then - -- Due to limitations in the config format mostly, we'll have a comma - -- separated list. Parse it into lines - local capenabled = {} - -- print("here: " .. config.capenabled) - for sysc in config.capenabled:gmatch("([^,]+)") do - capenabled[sysc] = true - end - config.capenabled = capenabled -end -process_compat() -process_abi_flags() -process_syscall_abi_change() -process_obsol() -process_unimpl() - -if not lfs.mkdir(tmpspace) then - error("Failed to create tempdir " .. tmpspace) -end - --- XXX Revisit the error handling here, we should probably move the rest of this --- into a function that we pcall() so we can catch the errors and clean up --- gracefully. -for _, v in ipairs(temp_files) do - local tmpname = tmpspace .. v - files[v] = io.open(tmpname, "w+") - -- XXX Revisit these with a pcall() + error handler - if not files[v] then - abort(1, "Failed to open temp file: " .. tmpname) - end -end - -for _, v in ipairs(output_files) do - local tmpname = tmpspace .. v - files[v] = io.open(tmpname, "w+") - -- XXX Revisit these with a pcall() + error handler - if not files[v] then - abort(1, "Failed to open temp output file: " .. tmpname) - end -end - --- Write out all of the preamble bits -write_line("sysent", string.format([[ - -/* The casts are bogus but will do for now. */ -struct sysent %s[] = { -]], config.switchname)) - -write_line("syssw", string.format([[/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -]], generated_tag)) - -write_line("sysarg", string.format([[/* - * System call prototypes. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -#ifndef %s -#define %s - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct proc; - -struct thread; - -#define PAD_(t) (sizeof(syscallarg_t) <= sizeof(t) ? \ - 0 : sizeof(syscallarg_t) - sizeof(t)) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define PADL_(t) 0 -#define PADR_(t) PAD_(t) -#else -#define PADL_(t) PAD_(t) -#define PADR_(t) 0 -#endif - -]], generated_tag, config.sysproto_h, config.sysproto_h)) -if abi_changes("pair_64bit") then - write_line("sysarg", string.format([[ -#if !defined(PAD64_REQUIRED) && !defined(__amd64__) -#define PAD64_REQUIRED -#endif -]])) -end -if abi_changes("pair_64bit") then - write_line("systrace", string.format([[ -#if !defined(PAD64_REQUIRED) && !defined(__amd64__) -#define PAD64_REQUIRED -#endif -]])) -end -for _, v in pairs(compat_options) do - write_line(v.tmp, string.format("\n#ifdef %s\n\n", v.definition)) -end - -write_line("sysargmap", string.format([[/* - * System call argument map. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -#ifndef %s -#define %s - -static int %s[] = { -]], generated_tag, config['sysargmap_h'], - config['sysargmap_h'], config['sysargmaskname'])) - -write_line("sysnames", string.format([[/* - * System call names. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -const char *%s[] = { -]], generated_tag, config.namesname)) - -write_line("syshdr", string.format([[/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -]], generated_tag)) - -write_line("sysmk", string.format([[ -# -# FreeBSD system call object files. -# -# DO NOT EDIT-- this file is automatically %s. -# - -MIASM = ]], generated_tag)) - -write_line("libsysmap", string.format([[/* - * FreeBSD system call symbols. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -FBSDprivate_1.0 { -]], generated_tag)) - -write_line("libsys_h", string.format([[/* - * Public system call stubs provided by libsys. - * - * Do not use directly, include instead. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -#ifndef __LIBSYS_H_ -#define __LIBSYS_H_ - -#include -#include -#include -#include -#include -#include /* for mcontext_t */ -#include -#include - -]], generated_tag)) - -write_line("systrace", string.format([[/* - * System call argument to DTrace register array converstion. - * - * This file is part of the DTrace syscall provider. - * - * DO NOT EDIT-- this file is automatically %s. - */ - -static void -systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) -{ - int64_t *iarg = (int64_t *)uarg; - int a = 0; - switch (sysnum) { -]], generated_tag)) - -write_line("systracetmp", [[static void -systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) -{ - const char *p = NULL; - switch (sysnum) { -]]) - -write_line("systraceret", [[static void -systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) -{ - const char *p = NULL; - switch (sysnum) { -]]) - --- Processing the sysfile will parse out the preprocessor bits and put them into --- the appropriate place. Any syscall-looking lines get thrown into the sysfile --- buffer, one per line, for later processing once they're all glued together. -process_sysfile(sysfile) - -write_line("sysinc", - "\n#define AS(name) (sizeof(struct name) / sizeof(syscallarg_t))\n") - -for _, v in pairs(compat_options) do - if v.count > 0 then - write_line("sysinc", string.format([[ - -#ifdef %s -#define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s, name) -#else -#define %s(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys -#endif -]], v.definition, v.flag:lower(), v.prefix, v.flag:lower())) - end - - write_line(v.dcltmp, string.format("\n#endif /* %s */\n\n", - v.definition)) -end - -write_line("sysprotoend", string.format([[ - -#undef PAD_ -#undef PADL_ -#undef PADR_ - -#endif /* !%s */ -]], config.sysproto_h)) - -write_line("sysmk", "\n") -write_line("libsysmap", "};\n") -write_line("sysent", "};\n") -write_line("sysnames", "};\n") --- maxsyscall is the highest seen; MAXSYSCALL should be one higher -write_line("syshdr", string.format("#define\t%sMAXSYSCALL\t%d\n", - config.syscallprefix, maxsyscall + 1)) -write_line("systrace", [[ - default: - *n_args = 0; - break; - }; -} -]]) - -write_line("systracetmp", [[ - default: - break; - }; - if (p != NULL) - strlcpy(desc, p, descsz); -} -]]) - -write_line("systraceret", [[ - default: - break; - }; - if (p != NULL) - strlcpy(desc, p, descsz); -} -]]) - --- Finish up; output -table.sort(structs) -for name,_ in pairsByKeys(structs) do - write_line("libsys_h", string.format("struct %s;\n", name)) -end -write_line("libsys_h", "union semun;\n\n__BEGIN_DECLS\n") -write_line("libsys_h", read_file("libsys_h_type")) -write_line("libsys_h", "\n") -write_line("libsys_h", read_file("libsys_h_func")) -write_line("libsys_h", "__END_DECLS\n\n#endif /* __LIBSYS_H_ */\n") - -write_line("sysargmap", string.format([[ -}; - -#endif /* !%s */ -]], config["sysargmap_h"])) - -write_line("syssw", read_file("sysinc")) -write_line("syssw", read_file("sysent")) - -write_line("sysproto", read_file("sysarg")) -write_line("sysproto", read_file("sysdcl")) -for _, v in pairs(compat_options) do - write_line("sysproto", read_file(v.tmp)) - write_line("sysproto", read_file(v.dcltmp)) -end -write_line("sysproto", read_file("sysaue")) -write_line("sysproto", read_file("sysprotoend")) - -write_line("systrace", read_file("systracetmp")) -write_line("systrace", read_file("systraceret")) - -for _, v in ipairs(output_files) do - local target = config[v] - if target ~= "/dev/null" then - local fh = assert(io.open(target, "w+")) - if fh == nil then - abort(1, "Failed to open '" .. target .. "'") - end - assert(fh:write(read_file(v))) - assert(fh:close()) - end -end - -cleanup() diff --git a/sys/tools/syscalls/README.md b/sys/tools/syscalls/README.md new file mode 100644 index 000000000000..1797411f1aa0 --- /dev/null +++ b/sys/tools/syscalls/README.md @@ -0,0 +1,49 @@ +# System call creation library +Parses `syscalls.master` and packages information into objects with methods. +Modules reproduce the previously monolithic file auto-generation. + +We generally assume that this script will be run by flua, however we've +carefully crafted modules for it that mimic interfaces provided by modules +available in ports. Currently, this script is compatible with lua from +ports along with the compatible luafilesystem and lua-posix modules. + +## Usage +`main.lua` generates all files. +Files are associated with their respective modules, and modules can be run as +standalone scripts to generate specific files. + +### Examples +**All files:** +`# /usr/libexec/flua /usr/src/sys/tools/syscalls/main.lua /usr/src/sys/kern/syscalls.master` +
+**syscalls.h:** +`# /usr/libexec/flua /usr/src/sys/tools/syscalls/scripts/syscalls.h /usr/src/sys/kern/syscalls.master` + +## Organization +* `root` + * `main.lua` - Main entry point that calls all scripts. + * `config.lua` - Contains the global configuration table and associated + configuration functions. + + * `core` (Core Classes) + * `syscall.lua` - Packages each system call entry from `syscalls.master` + into a system call object. + * `scarg.lua` - Packages each argument for the system call into an argument + object. + * `scret.lua` - An object for the return value of the system call. + * `freebsd-syscall.lua` - Contains the master system call table after + processing. + + * `scripts` + * `init_sysent.lua` - Generates `init_sysent.c`. + * `libsys_h.lua` - Generates `lib/libsys/_libsys.h`. + * `syscall_h.lua` - Generates `syscall.h`. + * `syscall_mk.lua` - Generates `syscall.mk`. + * `syscalls.lua` - Generates `syscalls.c`. + * `syscalls_map.lua` - Generates `lib/libsys/syscalls.map`. + * `sysproto_h.lua` - Generates `sysproto.h`. + * `systrace_args.lua` - Generates `systrace_args.c`. + + * `tools` + * `util.lua` - Contains utility functions. + * `generator.lua` - Handles file generation for the library. diff --git a/sys/tools/syscalls/config.lua b/sys/tools/syscalls/config.lua new file mode 100644 index 000000000000..29723ab60535 --- /dev/null +++ b/sys/tools/syscalls/config.lua @@ -0,0 +1,267 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2021-2024 SRI International +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- +-- Code to read in the config file that drives this. Since we inherit from the +-- FreeBSD makesyscall.sh legacy, all config is done through a config file that +-- sets a number of variables (as noted below); it used to be a .sh file that +-- was sourced in. This dodges the need to write a command line parser. +-- + +local util = require("tools.util") + +-- +-- Global config map. +-- Default configuration is native. Any of these may get replaced by an +-- optionally specified configuration file. +-- +local config = { + sysnames = "syscalls.c", + syshdr = "../sys/syscall.h", + sysmk = "/dev/null", + syssw = "init_sysent.c", + systrace = "systrace_args.c", + sysproto = "../sys/sysproto.h", + libsysmap = "/dev/null", + libsys_h = "/dev/null", + sysargmap = "/dev/null", + sysargmap_h = "_SYS_SYSARGMAP_H_", + sysargmaskname = "sysargmask", + sysproto_h = "_SYS_SYSPROTO_H_", + syscallprefix = "SYS_", + switchname = "sysent", + namesname = "syscallnames", + abi_flags = {}, + abi_func_prefix = "", + abi_type_suffix = "", + abi_long = "long", + abi_u_long = "u_long", + abi_semid_t = "semid_t", + abi_size_t = "size_t", + abi_ptr_array_t = "", + abi_headers = "", + abi_intptr_t = "intptr_t", + ptr_intptr_t_cast = "intptr_t", + ptr_qualified = "*", + obsol = {}, + unimpl = {}, + compat_set = "native", + mincompat = 0, + -- System calls that require ABI-specific handling. + syscall_abi_change = {}, + -- System calls that appear to require handling, but don't. + syscall_no_abi_change = {}, + -- Keep track of modifications if there are. + modifications = {}, + -- Stores compat_sets from syscalls.conf; config.mergeCompat() + -- instantiates. + compat_options = {}, +} + +-- +-- For each entry, the ABI flag is the key. One may also optionally provide an +-- expr, which are contained in an array associated with each key; expr gets +-- applied to each argument type to indicate whether this argument is subject to +-- ABI change given the configured flags. +-- +config.known_abi_flags = { + long_size = { + "_Contains[a-z_]*_long_", + "^long [a-z0-9_]+$", + "long [*]", + "size_t [*]", + -- semid_t is not included because it is only used + -- as an argument or written out individually and + -- said writes are handled by the ksem framework. + -- Technically a sign-extension issue exists for + -- arguments, but because semid_t is actually a file + -- descriptor negative 32-bit values are invalid + -- regardless of sign-extension. + }, + time_t_size = { + "_Contains[a-z_]*_timet_", + }, + pointer_args = { + -- no expr + }, + pointer_size = { + "_Contains[a-z_]*_ptr_", + "[*][*]", + }, + pair_64bit = { + "^dev_t[ ]*$", + "^id_t[ ]*$", + "^off_t[ ]*$", + }, +} + +-- All compat option entries should have five entries: +-- definition: The preprocessor macro that will be set for this. +-- compatlevel: The level this compatibility should be included at. This +-- generally represents the version of FreeBSD that it is compatible +-- with, but ultimately it's just the level of mincompat in which it's +-- included. +-- flag: The name of the flag in syscalls.master. +-- prefix: The prefix to use for _args and syscall prototype. This will be +-- used as-is, without "_" or any other character appended. +-- descr: The description of this compat option in init_sysent.c comments. +-- The special "stdcompat" entry will cause the other five to be autogenerated. +local compat_option_sets = { + native = { + { + definition = "COMPAT_43", + compatlevel = 3, + flag = "COMPAT", + prefix = "o", + descr = "old", + }, + { stdcompat = "FREEBSD4" }, + { stdcompat = "FREEBSD6" }, + { stdcompat = "FREEBSD7" }, + { stdcompat = "FREEBSD10" }, + { stdcompat = "FREEBSD11" }, + { stdcompat = "FREEBSD12" }, + { stdcompat = "FREEBSD13" }, + { stdcompat = "FREEBSD14" }, + }, +} + +-- +-- config looks like a shell script; in fact, the previous makesyscalls.sh +-- script actually sourced it in. It had a pretty common format, so we should +-- be fine to make various assumptions. +-- +-- This function processes config to be merged into our global config map with +-- config.merge(). It aborts if there's malformed lines and returns NIL and a +-- message if no file was provided. +-- +function config.process(file) + local cfg = {} + local comment_line_expr = "^%s*#.*" + -- We capture any whitespace padding here so we can easily advance to + -- the end of the line as needed to check for any trailing bogus bits. + -- Alternatively, we could drop the whitespace and instead try to + -- use a pattern to strip out the meaty part of the line, but then we + -- would need to sanitize the line for potentially special characters. + local line_expr = "^([%w%p]+%s*)=(%s*[`\"]?[^\"`]*[`\"]?)" + + if not file then + return nil, "No file given" + end + + local fh = assert(io.open(file)) + + for nextline in fh:lines() do + -- Strip any whole-line comments. + nextline = nextline:gsub(comment_line_expr, "") + -- Parse it into key, value pairs. + local key, value = nextline:match(line_expr) + if key ~= nil and value ~= nil then + local kvp = key .. "=" .. value + key = util.trim(key) + value = util.trim(value) + local delim = value:sub(1,1) + if delim == '"' then + local trailing_context + + -- Strip off the key/value part. + trailing_context = nextline:sub(kvp:len() + 1) + -- Strip off any trailing comment. + trailing_context = trailing_context:gsub("#.*$", + "") + -- Strip off leading/trailing whitespace. + trailing_context = util.trim(trailing_context) + if trailing_context ~= "" then + print(trailing_context) + util.abort(1, + "Malformed line: " .. nextline) + end + + value = util.trim(value, delim) + else + -- Strip off potential comments. + value = value:gsub("#.*$", "") + -- Strip off any padding whitespace. + value = util.trim(value) + if value:match("%s") then + util.abort(1, + "Malformed config line: " .. + nextline) + end + end + cfg[key] = value + elseif not nextline:match("^%s*$") then + -- Make sure format violations don't get overlooked + -- here, but ignore blank lines. Comments are already + -- stripped above. + util.abort(1, "Malformed config line: " .. nextline) + end + end + + assert(fh:close()) + return cfg +end + +-- Merges processed configuration file into the global config map (see above), +-- or returns NIL and a message if no file was provided. +function config.merge(fh) + if not fh then + return nil, "No file given" + end + + local res = assert(config.process(fh)) + + for k, v in pairs(res) do + if v ~= config[k] then + -- Handling of string lists: + if k:find("abi_flags") then + -- Match for pipe, that's how abi_flags + -- is formatted. + config[k] = util.setFromString(v, "[^|]+") + elseif k:find("syscall_abi_change") or + k:find("syscall_no_abi_change") or + k:find("obsol") or + k:find("unimpl") then + -- Match for space, that's how these + -- are formatted. + config[k] = util.setFromString(v, "[^ ]+") + else + config[k] = v + end + -- Construct config modified table as config + -- is processed. + config.modifications[k] = true + else + -- config wasn't modified. + config.modifications[k] = false + end + end +end + +-- Returns TRUE if there are ABI changes from native for the provided ABI flag. +function config.abiChanges(name) + if config.known_abi_flags[name] == nil then + util.abort(1, "abi_changes: unknown flag: " .. name) + end + return config.abi_flags[name] ~= nil +end + +-- Instantiates config.compat_options. +function config.mergeCompat() + if config.compat_set ~= "" then + if not compat_option_sets[config.compat_set] then + util.abort(1, "Undefined compat set: " .. + config.compat_set) + end + + config.compat_options = compat_option_sets[config.compat_set] + end +end + +return config diff --git a/sys/tools/syscalls/core/freebsd-syscall.lua b/sys/tools/syscalls/core/freebsd-syscall.lua new file mode 100644 index 000000000000..193b1e43563c --- /dev/null +++ b/sys/tools/syscalls/core/freebsd-syscall.lua @@ -0,0 +1,147 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +local syscall = require("core.syscall") +local util = require("tools.util") + +local FreeBSDSyscall = {} + +FreeBSDSyscall.__index = FreeBSDSyscall + +-- For each compat option in the provided config table, process them and insert +-- them into known_flags for class syscall. +function FreeBSDSyscall:processCompat() + for _, v in pairs(self.config.compat_options) do + if v.stdcompat ~= nil then + local stdcompat = v.stdcompat + v.definition = "COMPAT_" .. stdcompat:upper() + v.compatlevel = tonumber(stdcompat:match("([0-9]+)$")) + v.flag = stdcompat:gsub("FREEBSD", "COMPAT") + v.prefix = stdcompat:lower() .. "_" + v.descr = stdcompat:lower() + end + + -- Add compat option to syscall.known_flags. + table.insert(syscall.known_flags, v.flag) + end +end + +function FreeBSDSyscall:parseSysfile() + local file = self.sysfile + local config = self.config + local commentExpr = "^%s*;.*" + + if file == nil then + return nil, "No file given" + end + + self.syscalls = {} + + local fh, msg = io.open(file) + if fh == nil then + return nil, msg + end + + local incs = "" + local defs = "" + local s + for line in fh:lines() do + line = line:gsub(commentExpr, "") -- Strip any comments. + -- NOTE: Can't use pure pattern matching here because of + -- the 's' test and this is shorter than a generic pattern + -- matching pattern. + if line == nil or line == "" then + goto skip -- Blank line, skip this line. + elseif s ~= nil then + -- If we have a partial system call object s, + -- then feed it one more line. + if s:add(line) then + -- Append to system call list. + for t in s:iter() do + if t:validate(t.num - 1) then + table.insert(self.syscalls, t) + else + util.abort(1, + "Skipped system call " .. + "at number " .. t.num) + end + end + s = nil + end + elseif line:match("^#%s*include") then + incs = incs .. line .. "\n" + elseif line:match("%%ABI_HEADERS%%") then + local h = self.config.abi_headers + if h ~= nil and h ~= "" then + incs = incs .. h .. "\n" + end + elseif line:match("^#%s*define") then + defs = defs .. line.. "\n" + elseif line:match("^#") then + util.abort(1, "Unsupported cpp op " .. line) + else + s = syscall:new() + if s:add(line) then + -- Append to system call list. + for t in s:iter() do + if t:validate(t.num - 1) then + table.insert(self.syscalls, t) + else + util.abort(1, + "Skipped system call " .. + "at number " .. t.num) + end + end + s = nil + end + end + ::skip:: + end + + -- Special handling for linux nosys. + if config.syscallprefix:find("LINUX") ~= nil then + s = nil + end + + if s ~= nil then + util.abort(1, "Dangling system call at the end") + end + + assert(fh:close()) + self.includes = incs + self.defines = defs +end + +function FreeBSDSyscall:findStructs() + self.structs = {} + + for _, s in pairs(self.syscalls) do + if s:native() and not s.type.NODEF then + for _, v in ipairs(s.args) do + local name = util.structName(v.type) + if name ~= nil then + self.structs[name] = name + end + end + end + end +end + +function FreeBSDSyscall:new(obj) + obj = obj or {} + setmetatable(obj, self) + self.__index = self + + obj:processCompat() + obj:parseSysfile() + obj:findStructs() + + return obj +end + +return FreeBSDSyscall diff --git a/sys/tools/syscalls/core/scarg.lua b/sys/tools/syscalls/core/scarg.lua new file mode 100644 index 000000000000..4828444b7ee1 --- /dev/null +++ b/sys/tools/syscalls/core/scarg.lua @@ -0,0 +1,170 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2021-2024 SRI International +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +local config = require("config") +local util = require("tools.util") + +local scarg = {} + +scarg.__index = scarg + +-- Check this argument against config for ABI changes from native. Return TRUE +-- if there are. +local function checkAbiChanges(arg) + for k, v in pairs(config.known_abi_flags) do + if config.abiChanges(k) and v ~= nil then + for _, e in pairs(v) do + if arg:find(e) then + return true + end + end + end + end + return false +end + +-- Strips the Microsoft(R) SAL annotations from this argument. +local function stripArgAnnotations(arg) + arg = arg:gsub("_Contains_[^ ]*[_)] ?", "") + arg = arg:gsub("_In[^ ]*[_)] ?", "") + arg = arg:gsub("_Out[^ ]*[_)] ?", "") + return util.trim(arg) +end + +-- Preprocessing of this argument. +function scarg:init(line) + -- Trim whitespace and trailing comma. We don't want them here; + -- these can mess with our processing of this argument. + line = util.trim(line) -- This provides a clearer abort error. + self.scarg = util.trim(line, ',') + + self.arg_abi_change = checkAbiChanges(self.scarg) + self.changes_abi = self.arg_abi_change + self.scarg = stripArgAnnotations(self.scarg) + + self.name = self.scarg:match("([^* ]+)$") + -- Our pattern might produce a Lua pattern sequence; that's a malformed + -- declaration. + local status, type = pcall(function() + return util.trim(self.scarg:gsub(self.name .. "$", ""), nil) + end) + if not status then + util.abort(1, "Malformed argument line: " .. line) + end + self.type = type +end + +-- Processes this argument. +-- Flags if there's ABI changes from native, converts this argument to the +-- target ABI, and handles 64-bit argument pairing. +-- Returns TRUE if this argument is processed and ready to add. +-- Returns FALSE if it shouldn't be added (the argument type is void). +function scarg:process() + if self.type ~= "" and self.name ~= "void" then + -- util.is64bitType() needs a bare type so check it after + -- argname is removed. + self.changes_abi = self.changes_abi or + (config.abiChanges("pair_64bit") and + util.is64bitType(self.type)) + + self.type = self.type:gsub("intptr_t", config.abi_intptr_t) + self.type = self.type:gsub("semid_t", config.abi_semid_t) + + if util.isPtrType(self.type) then + self.type = self.type:gsub("size_t", config.abi_size_t) + self.type = self.type:gsub("^long", config.abi_long) + self.type = self.type:gsub("^u_long", config.abi_u_long) + self.type = self.type:gsub("^const u_long", "const " .. + config.abi_u_long) + elseif self.type:find("^long$") then + self.type = config.abi_long + end + + if util.isPtrArrayType(self.type) and + config.abi_ptr_array_t ~= "" then + -- `* const *` -> `**` + self.type = self.type:gsub("[*][ ]*const[ ]*[*]", "**") + -- e.g., `struct aiocb **` -> `uint32_t *` + self.type = self.type:gsub("[^*]*[*]", + config.abi_ptr_array_t .. " ", 1) + end + + if self.arg_abi_change then + self.type = self.type:gsub("(struct [^ ]*)", "%1" .. + config.abi_type_suffix) + self.type = self.type:gsub("(union [^ ]*)", "%1" .. + config.abi_type_suffix) + end + + -- Allow pointers to be qualified + self.type = util.trim(self.type:gsub("[*]", + config.ptr_qualified)) + self.type = self.type:gsub(" *$", "") -- trailing space + self.type = self.type:gsub(" *", " ") -- extra spaces + + return true + end + return false +end + +-- For pairing 64-bit arguments, pad if necessary. +-- Returns TRUE if this argument was padded. +local function pad(tbl) + if #tbl % 2 == 1 then + table.insert(tbl, { + type = "int", + name = "_pad", + }) + return true + end + return false +end + +-- To append to a system call's argument table. Appends to the end. +function scarg:append(tbl) + if config.abiChanges("pair_64bit") and util.is64bitType(self.type) then + pad(tbl) -- Needs argument padding. + table.insert(tbl, { + type = "uint32_t", + name = self.name .. "1", + }) + table.insert(tbl, { + type = "uint32_t", + name = self.name .. "2", + }) + else + table.insert(tbl, { + type = self.type, + name = self.name, + }) + end +end + +-- Returns TRUE if this argument has ABI changes from native. +-- EXAMPLE: 32-bit argument for freebsd32. +function scarg:changesAbi() + return self.changes_abi +end + +function scarg:new(obj, line) + obj = obj or { } + setmetatable(obj, self) + self.__index = self + + -- ABI changes that we only want in this scope. + self.arg_abi_change = false + -- ABI changes that we want the system call object to see. + self.changes_abi = false + + obj:init(line) + + return obj +end + +return scarg diff --git a/sys/tools/syscalls/core/scret.lua b/sys/tools/syscalls/core/scret.lua new file mode 100644 index 000000000000..25522b4c830e --- /dev/null +++ b/sys/tools/syscalls/core/scret.lua @@ -0,0 +1,45 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +local util = require("tools.util") + +local scret = {} + +scret.__index = scret + +-- Processes this return type. +function scret:process() + local words = util.split(self.scret, "%S+") + self.scret = words[1] + -- Pointer incoming. + if words[2]:sub(1,1) == "*" then + self.scret = self.scret .. " " + end + while words[2]:sub(1,1) == "*" do + words[2] = words[2]:sub(2) + self.scret = self.scret .. "*" + end +end + +-- To add this return type to the system call. +function scret:add() + self:process() + return self.scret +end + +function scret:new(obj, line) + obj = obj or { } + setmetatable(obj, self) + self.__index = self + + self.scret = line + + return obj +end + +return scret diff --git a/sys/tools/syscalls/core/syscall.lua b/sys/tools/syscalls/core/syscall.lua new file mode 100644 index 000000000000..e7e3dc3aac33 --- /dev/null +++ b/sys/tools/syscalls/core/syscall.lua @@ -0,0 +1,495 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +local config = require("config") +local scarg = require("core.scarg") +local scret = require("core.scret") +local util = require("tools.util") + +local syscall = {} + +syscall.__index = syscall + +syscall.known_flags = util.set { + "STD", + "OBSOL", + "RESERVED", + "UNIMPL", + "NODEF", + "NOARGS", + "NOPROTO", + "NOSTD", + + -- flags beyond this point are modifiers + "CAPENABLED", + "NOLIB", + "NOTSTATIC", + "SYSMUX", +} + +-- Native is an arbitrarily large number to have a constant and not +-- interfere with compat numbers. +local native = 1000000 + +-- Processes and assigns the appropriate thread flag for this system call. +function syscall:processThr() + self.thr = "SY_THR_STATIC" + for k, _ in pairs(self.type) do + if k == "NOTSTATIC" then + self.thr = "SY_THR_ABSENT" + end + end +end + +-- Processes and assigns the appropriate capability flag for this system call. +-- "SYF_CAPENABLED" for capability enabled; "0" for NOT capability enabled. +function syscall:processCap() + self.cap = "0" + local stripped = util.stripAbiPrefix(self.name, self.prefix) + for k, _ in pairs(self.type) do + if k == "CAPENABLED" then + self.cap = "SYF_CAPENABLED" + end + end +end + +-- Check that this system call has a known type. +local function checkType(type) + for k, _ in pairs(type) do + if not syscall.known_flags[k] and not + k:match("^COMPAT") then + util.abort(1, "Bad type: " .. k) + end + end +end + +-- If there are ABI changes from native, process this system call to match the +-- target ABI. +function syscall:processChangesAbi() + -- First, confirm we want to uphold our changes_abi flag. + if config.syscall_no_abi_change[self.name] then + self.changes_abi = false + end + self.noproto = not util.isEmpty(config.abi_flags) and + not self.changes_abi + if config.abiChanges("pointer_args") then + for _, v in ipairs(self.args) do + if util.isPtrType(v.type, config.abi_intptr_t) then + if config.syscall_no_abi_change[self.name] then + print("WARNING: " .. self.name .. + " in syscall_no_abi_change, " .. + "but pointers args are present") + end + self.changes_abi = true + goto ptrfound + end + end + ::ptrfound:: + end + if config.syscall_abi_change[self.name] then + self.changes_abi = true + end + if self.changes_abi then + self.noproto = false + end +end + +-- Final processing of flags. Process any flags that haven't already been +-- processed (e.g., dictionaries from syscalls.conf). +function syscall:processFlags() + if config.obsol[self.name] or (self:compatLevel() > 0 and + self:compatLevel() < tonumber(config.mincompat)) then + self.args = nil + self.type.OBSOL = true + -- Don't apply any ABI handling, declared as obsolete. + self.changes_abi = false + end + if config.unimpl[self.name] then + self.type.UNIMPL = true + end + if self.noproto or self.type.SYSMUX then + self.type.NOPROTO = true + end + if self.type.NODEF then + self.audit = "AUE_NULL" + end +end + +-- Returns TRUE if prefix and arg_prefix are assigned; FALSE if they're left +-- unassigned. Relies on a valid changes_abi flag, so should be called AFTER +-- processChangesAbi(). +function syscall:processPrefix() + -- If there are ABI changes from native, assign the correct prefixes. + if self.changes_abi then + self.arg_prefix = config.abi_func_prefix + self.prefix = config.abi_func_prefix + return true + end + return false +end + +-- Validate that we're not skipping system calls by comparing this system call +-- number to the previous system call number. Called higher up the call stack +-- by class FreeBSDSyscall. +function syscall:validate(prev) + return prev + 1 == self.num +end + +-- Return the compat prefix for this system call. +function syscall:compatPrefix() + local c = self:compatLevel() + if self.type.OBSOL then + return "obs_" + end + if self.type.RESERVED then + return "reserved #" + end + if self.type.UNIMPL then + return "unimp_" + end + if c == 3 then + return "o" + end + if c < native then + return "freebsd" .. tostring(c) .. "_" + end + return "" +end + +-- Return the symbol name for this system call. +function syscall:symbol() + return self:compatPrefix() .. self.name +end + +-- +-- Return the compatibility level for this system call. +-- 0 is obsolete. +-- < 0 is this isn't really a system call we care about. +-- 3 is 4.3BSD in theory, but anything before FreeBSD 4. +-- >= 4 is FreeBSD version, this system call was replaced with a new +-- version. +-- +function syscall:compatLevel() + if self.type.UNIMPL or self.type.RESERVED then + return -1 + elseif self.type.OBSOL then + return 0 + elseif self.type.COMPAT then + return 3 + end + for k, _ in pairs(self.type) do + local l = k:match("^COMPAT(%d+)") + if l ~= nil then + return tonumber(l) + end + end + return native +end + +-- Adds the definition for this system call. Guarded by whether we already have +-- a system call number or not. +function syscall:addDef(line) + if self.num == nil then + local words = util.split(line, "%S+") + self.num = words[1] + self.audit = words[2] + self.type = util.setFromString(words[3], "[^|]+") + checkType(self.type) + self.name = words[4] + -- These next three are optional, and either all present + -- or all absent. + self.altname = words[5] + self.alttag = words[6] + self.rettype = words[7] + return true + end + return false +end + +-- Adds the function declaration for this system call. If addDef() found an +-- opening curly brace, then we're looking for a function declaration. +function syscall:addFunc(line) + if self.name == "{" then + local words = util.split(line, "%S+") + -- Expect line is `type syscall(` or `type syscall(void);`. + if #words ~= 2 then + util.abort(1, "Malformed line " .. line) + end + + local ret = scret:new({}, line) + self.ret = ret:add() + -- Don't clobber rettype set in the alt information. + if self.rettype == nil then + self.rettype = "int" + end + + self.name = words[2]:match("([%w_]+)%(") + if words[2]:match("%);$") then + -- Now we're looking for ending curly brace. + self.expect_rbrace = true + end + return true + end + return false +end + +-- Adds the argument(s) for this system call. Once addFunc() assigns a name +-- for this system call, arguments are next in syscalls.master. +function syscall:addArgs(line) + if not self.expect_rbrace then + if line:match("%);$") then + self.expect_rbrace = true + return true + end + local arg = scarg:new({}, line) + -- We don't want to add this argument if it doesn't process. + -- scarg:process() handles those conditions. + if arg:process() then + arg:append(self.args) + end + -- If this argument has ABI changes, set globally for this + -- system call. + self.changes_abi = self.changes_abi or arg:changesAbi() + return true + end + return false +end + +-- Once we have a good syscall, add some final information to it. +function syscall:finalize() + if self.name == nil then + self.name = "" + end + + -- Preserve the original name as the alias. + self.alias = self.name + + self:processChangesAbi() -- process changes to the ABI + self:processFlags() -- process any unprocessed flags + + -- If there's changes to the ABI, these prefixes will be changed by + -- processPrefix(); otherwise, they'll remain empty. + self.prefix = "" + self.arg_prefix = "" + self:processPrefix() + + self:processCap() -- capability flag + self:processThr() -- thread flag + + -- Assign argument alias. + if self.alttag ~= nil then + self.arg_alias = self.alttag + elseif self.arg_alias == nil and self.name ~= nil then + -- argalias should be: + -- COMPAT_PREFIX + ABI Prefix + funcname + self.arg_alias = self:compatPrefix() .. self.arg_prefix .. + self.name .. "_args" + elseif self.arg_alias ~= nil then + self.arg_alias = self.arg_prefix .. self.arg_alias + end + + -- An empty string would not want a prefix; the entry doesn't have + -- a name so we want to keep the empty string. + if self.name ~= nil and self.name ~= "" then + self.name = self.prefix .. self.name + end + + self:processArgstrings() + self:processArgsize() +end + +-- Assigns the correct args_size. Defaults to "0", except if there's arguments +-- or NODEF flag. +function syscall:processArgsize() + if self.type.SYSMUX then -- catch this first + self.args_size = "0" + elseif self.arg_alias ~= nil and + (#self.args ~= 0 or self.type.NODEF) then + self.args_size = "AS(" .. self.arg_alias .. ")" + else + self.args_size = "0" + end +end + +-- Constructs argstr_* strings for generated declerations/wrappers. +function syscall:processArgstrings() + local type = "" + local type_var = "" + local var = "" + local comma = "" + + for _, v in ipairs(self.args) do + local argname, argtype = v.name, v.type + type = type .. comma .. argtype + type_var = type_var .. comma .. argtype .. " " .. argname + var = var .. comma .. argname + comma = ", " + end + if type == "" then + type = "void" + type_var = "void" + end + + self.argstr_type = type + self.argstr_type_var = type_var + self.argstr_var = var +end + +-- Interface to add this system call to the master system call table. +-- The system call is built up one line at a time. The states describe the +-- current parsing state. +-- Returns TRUE when ready to add and FALSE while still parsing. +function syscall:add(line) + if self:addDef(line) then + return self:isAdded(line) + end + if self:addFunc(line) then + return false -- Function added; keep going. + end + if self:addArgs(line) then + return false -- Arguments added; keep going. + end + return self:isAdded(line) -- Final validation, before adding. +end + +-- Returns TRUE if this system call was succesfully added. There's two entry +-- points to this function: (1) the entry in syscalls.master is one-line, or +-- (2) the entry is a full system call. This function handles those cases and +-- decides whether to exit early for (1) or validate a full system call for +-- (2). This function also handles cases where we don't want to add, and +-- instead want to abort. +function syscall:isAdded(line) + -- This system call is a range - exit early. + if tonumber(self.num) == nil then + -- The only allowed types are RESERVED and UNIMPL. + if not (self.type.RESERVED or self.type.UNIMPL) then + util.abort(1, "Range only allowed with RESERVED " .. + "and UNIMPL: " .. line) + end + self:finalize() + return true + -- This system call is a loadable system call - exit early. + elseif self.altname ~= nil and self.alttag ~= nil and + self.rettype ~= nil then + self:finalize() + return true + -- This system call is only one line, and should only be one line + -- (we didn't make it to addFunc()) - exit early. + elseif self.name ~= "{" and self.ret == nil then + self:finalize() + return true + -- This is a full system call and we've passed multiple states to + -- get here - final exit. + elseif self.expect_rbrace then + if not line:match("}$") then + util.abort(1, "Expected '}' found '" .. line .. + "' instead.") + end + self:finalize() + return true + end + return false +end + +-- Return TRUE if this system call is native. +function syscall:native() + return self:compatLevel() == native +end + +-- Make a shallow copy of `self` and replace the system call number with num +-- (which should be a number). +-- For system call ranges. +function syscall:shallowCopy(num) + local obj = syscall:new() + + -- shallow copy + for k, v in pairs(self) do + obj[k] = v + end + obj.num = num -- except override range + return obj +end + +-- Make a deep copy of the parameter object. Save copied tables in `copies`, +-- indexed by original table. +-- CREDIT: http://lua-users.org/wiki/CopyTable +-- For a full system call (the nested arguments table should be a deep copy). +local function deepCopy(orig, copies) + copies = copies or {} + local orig_type = type(orig) + local copy + if orig_type == 'table' then + if copies[orig] then + copy = copies[orig] + else + copy = {} + copies[orig] = copy + for orig_key, orig_value in next, orig, nil do + copy[deepCopy(orig_key, copies)] = + deepCopy(orig_value, copies) + end + setmetatable(copy, deepCopy(getmetatable(orig), copies)) + end + else -- number, string, boolean, etc + copy = orig + end + return copy +end + +-- +-- In syscalls.master, system calls come in two types: (1) a fully defined +-- system call with function declaration, with a distinct number for each system +-- call; or (2) a one-line entry, sometimes with a distinct number and sometimes +-- with a range of numbers. One-line entries can be obsolete, reserved, no +-- definition, etc. Ranges are only allowed for reserved and unimplemented. +-- +-- This function provides the iterator to traverse system calls by number. If +-- the entry is a fully defined system call with a distinct number, the iterator +-- creates a deep copy and captures any nested objects; if the entry is a range +-- of numbers, the iterator creates shallow copies from the start of the range +-- to the end of the range. +-- +function syscall:iter() + local s = tonumber(self.num) + local e + if s == nil then + s, e = string.match(self.num, "(%d+)%-(%d+)") + s, e = tonumber(s), tonumber(e) + return function () + if s <= e then + s = s + 1 + return self:shallowCopy(s - 1) + end + end + else + e = s + self.num = s -- Replace string with number, like the clones. + return function () + if s == e then + local deep_copy = deepCopy(self) + s = e + 1 + return deep_copy + end + end + end +end + +function syscall:new(obj) + obj = obj or { } + setmetatable(obj, self) + self.__index = self + + self.expect_rbrace = false + self.changes_abi = false + self.args = {} + self.noproto = false + + return obj +end + +return syscall diff --git a/sys/tools/syscalls/main.lua b/sys/tools/syscalls/main.lua new file mode 100755 index 000000000000..96b300b78039 --- /dev/null +++ b/sys/tools/syscalls/main.lua @@ -0,0 +1,66 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- +-- Thanks to Kyle Evans for his makesyscall.lua in FreeBSD which served as +-- inspiration for this, and as a source of code at times. +-- + +-- When we have a path, add it to the package.path (. is already in the list). +if arg[0]:match("/") then + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/?.lua" +end + +-- Common config file management. +local config = require("config") +-- FreeBSDSyscall generates a table of system calls from syscalls.master. +local FreeBSDSyscall = require("core.freebsd-syscall") + +-- Modules for each file: +local init_sysent = require("scripts.init_sysent") +local libsys_h = require("scripts.libsys_h") +local sysargmap = require("scripts.sysargmap") +local syscall_h = require("scripts.syscall_h") +local syscall_mk = require("scripts.syscall_mk") +local syscalls = require("scripts.syscalls") +local syscalls_map = require("scripts.syscalls_map") +local sysproto_h = require("scripts.sysproto_h") +local systrace_args = require("scripts.systrace_args") + +-- Entry: +if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") +end + +local sysfile, configfile = arg[1], arg[2] + +config.merge(configfile) +config.mergeCompat() + +local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + +-- Output files: +init_sysent.file = config.syssw +libsys_h.file = config.libsys_h +sysargmap.file = config.sysargmap +syscall_h.file = config.syshdr +syscall_mk.file = config.sysmk +syscalls.file = config.sysnames +syscalls_map.file = config.libsysmap +sysproto_h.file = config.sysproto +systrace_args.file = config.systrace + +init_sysent.generate(tbl, config, init_sysent.file) +libsys_h.generate(tbl, config, libsys_h.file) +sysargmap.generate(tbl, config, sysargmap.file) +syscall_h.generate(tbl, config, syscall_h.file) +syscall_mk.generate(tbl, config, syscall_mk.file) +syscalls.generate(tbl, config, syscalls.file) +syscalls_map.generate(tbl, config, syscalls_map.file) +sysproto_h.generate(tbl, config, sysproto_h.file) +systrace_args.generate(tbl, config, systrace_args.file) diff --git a/sys/tools/syscalls/scripts/init_sysent.lua b/sys/tools/syscalls/scripts/init_sysent.lua new file mode 100755 index 000000000000..66683250b482 --- /dev/null +++ b/sys/tools/syscalls/scripts/init_sysent.lua @@ -0,0 +1,192 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local init_sysent = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +init_sysent.file = "/dev/null" + +function init_sysent.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + + -- Write the generated preamble. + gen:preamble("System call switch table.") + + gen:write(tbl.includes) + + -- Newline before and after this line. + gen:write( + "\n#define AS(name) (sizeof(struct name) / sizeof(syscallarg_t))\n") + + -- Write out all the compat directives from compat_options. + for _, v in pairs(config.compat_options) do + gen:write(string.format([[ + +#ifdef %s +#define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s, name) +#else +#define %s(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys +#endif +]], v.definition, v.flag:lower(), v.prefix, v.flag:lower())) + end + -- Add a newline only if there were compat_options. + if config.compat_options ~= nil then + gen:write("\n") + end + + gen:write(string.format([[ +/* The casts are bogus but will do for now. */ +struct sysent %s[] = { +]], config.switchname)) + + for _, v in pairs(s) do + local c = v:compatLevel() + -- Comment is the function name by default, but may change + -- based on the type of system call. + local comment = v.name + + -- Handle non-compat: + if v:native() then + gen:write(string.format( + "\t{ .sy_narg = %s, .sy_call = (sy_call_t *)", + v.args_size)) + -- Handle SYSMUX flag: + if v.type.SYSMUX then + gen:write(string.format("nosys, " .. + ".sy_auevent = AUE_NULL, " .. + ".sy_flags = %s, " .. + ".sy_thrcnt = SY_THR_STATIC },", + v.cap)) + -- Handle NOSTD flag: + elseif v.type.NOSTD then + gen:write(string.format("lkmressys, " .. + ".sy_auevent = AUE_NULL, " .. + ".sy_flags = %s, " .. + ".sy_thrcnt = SY_THR_ABSENT },", + v.cap)) + -- Handle rest of non-compat: + else + if v.name == "nosys" or + v.name == "lkmnosys" or + v.name == "sysarch" or + v.name:find("^freebsd") or + v.name:find("^linux") then + gen:write(string.format("%s, " .. + ".sy_auevent = %s, " .. + ".sy_flags = %s, " .. + ".sy_thrcnt = %s },", + v:symbol(), v.audit, v.cap, v.thr)) + else + gen:write(string.format("sys_%s, " .. + ".sy_auevent = %s, " .. + ".sy_flags = %s, " .. + ".sy_thrcnt = %s },", + v:symbol(), v.audit, v.cap, v.thr)) + end + end + + -- Handle compat (everything >= FREEBSD3): + elseif c >= 3 then + -- Lookup the info for this specific compat option. + local flag, descr + for _, opt in pairs(config.compat_options) do + if opt.compatlevel == c then + flag = opt.flag + flag = flag:lower() + descr = opt.descr + break + end + end + + if v.type.NOSTD then + gen:write(string.format("\t{ " .. + ".sy_narg = %s, " .. + ".sy_call = (sy_call_t *)%s, " .. + ".sy_auevent = %s, " .. + ".sy_flags = 0, " .. + ".sy_thrcnt = SY_THR_ABSENT },", + "0", "lkmressys", "AUE_NULL")) + else + gen:write(string.format("\t{ %s(%s,%s), " .. + ".sy_auevent = %s, " .. + ".sy_flags = %s, " .. + ".sy_thrcnt = %s },", + flag, v.args_size, v.name, v.audit, v.cap, v.thr)) + end + comment = descr .. " " .. v.name + + -- Handle obsolete: + elseif v.type.OBSOL then + gen:write("\t{ " .. + ".sy_narg = 0, .sy_call = (sy_call_t *)nosys, " .. + ".sy_auevent = AUE_NULL, .sy_flags = 0, " .. + ".sy_thrcnt = SY_THR_ABSENT },") + comment = "obsolete " .. v.name + + -- Handle unimplemented: + elseif v.type.UNIMPL then + gen:write("\t{ " .. + ".sy_narg = 0, .sy_call = (sy_call_t *)nosys, " .. + ".sy_auevent = AUE_NULL, .sy_flags = 0, " .. + ".sy_thrcnt = SY_THR_ABSENT },") + -- UNIMPL comment is not different in sysent. + + -- Handle reserved: + elseif v.type.RESERVED then + gen:write("\t{ " .. + ".sy_narg = 0, .sy_call = (sy_call_t *)nosys, " .. + ".sy_auevent = AUE_NULL, .sy_flags = 0, " .. + ".sy_thrcnt = SY_THR_ABSENT },") + comment = "reserved for local use" + end + + gen:write(string.format("\t/* %d = %s */\n", v.num, comment)) + end + + -- End + gen:write("};\n") +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed syscall table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + init_sysent.file = config.syssw -- change file here + init_sysent.generate(tbl, config, init_sysent.file) +end + +-- Return the module. +return init_sysent diff --git a/sys/tools/syscalls/scripts/libsys_h.lua b/sys/tools/syscalls/scripts/libsys_h.lua new file mode 100755 index 000000000000..91349d5dc870 --- /dev/null +++ b/sys/tools/syscalls/scripts/libsys_h.lua @@ -0,0 +1,110 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 SRI International +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local libsys_h = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") +local util = require("tools.util") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +libsys_h.file = "/dev/null" + +function libsys_h.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + + local print_decl = function (sc) + return sc:native() and not sc.type.NODEF and + not sc.type.NOLIB and not sc.type.SYSMUX + end + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + + -- Write the generated preamble. + gen:preamble("Public system call stubs provided by libsys.\n" .. + "\n" .. + "Do not use directly, include instead.") + + gen:write(string.format([[ +#ifndef __LIBSYS_H_ +#define __LIBSYS_H_ + +#include +#include +#include +#include +#include +#include /* for mcontext_t */ +#include +#include + +]])) + + for name, _ in util.pairsByKeys(tbl.structs) do + gen:write(string.format("struct %s;\n", name)) + end + gen:write("union semun;\n") + + gen:write("\n__BEGIN_DECLS\n") + + for _, v in pairs(s) do + if print_decl(v) then + gen:write(string.format( + "typedef %s (__sys_%s_t)(%s);\n", + v.ret, v.name, v.argstr_type)) + end + end + + gen:write("\n") + + for _, v in pairs(s) do + if print_decl(v) then + gen:write(string.format("%s __sys_%s(%s);\n", + v.ret, v.name, v.argstr_type_var)) + end + end + + gen:write("__END_DECLS\n") + -- End + gen:write("\n#endif /* __LIBSYS_H_ */\n") +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed syscall table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + libsys_h.file = config.libsys_h -- change file here + libsys_h.generate(tbl, config, libsys_h.file) +end + +-- Return the module. +return libsys_h diff --git a/sys/tools/syscalls/scripts/sysargmap.lua b/sys/tools/syscalls/scripts/sysargmap.lua new file mode 100755 index 000000000000..6b09d51511ec --- /dev/null +++ b/sys/tools/syscalls/scripts/sysargmap.lua @@ -0,0 +1,101 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 SRI International +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local sysargmap = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") +local util = require("tools.util") + +-- File has not been decided yet; config will decide file. Default defined as +-- null +sysargmap.file = "/dev/null" + +function sysargmap.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + + local print_decl = function (s) + return s:native() and not s.type.NODEF and not s.type.NOPROTO + end + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + + -- Write the generated preamble. + gen:preamble("System call argument map.") + + gen:write(string.format([[ +#ifndef %s +#define %s + +]], config.sysargmap_h, config.sysargmap_h)) + + gen:write(string.format([[ +static int %s[] = { +]], config.sysargmaskname)) + + for _, v in pairs(s) do + if print_decl(v) then + gen:write(string.format("\t[%s%s] = (0x0", + config.syscallprefix, v.name, v.argstr_type)) + + local i = 0 + for _, arg in ipairs(v.args) do + if util.isPtrType(arg.type, + config.abi_intptr_t) then + gen:write(string.format(" | 0x%x", + 1 << i)) + end + i = i + 1 + end + + gen:write("),\n") + end + end + + gen:write("};\n") + -- End + gen:write(string.format([[ + +#endif /* !%s */ +]], config.sysargmap_h)) +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + config.mergeCapability() + + -- The parsed syscall table + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + sysargmap.file = config.sysargmap -- change file here + sysargmap.generate(tbl, config, sysargmap.file) +end + +-- Return the module. +return sysargmap diff --git a/sys/tools/syscalls/scripts/syscall_h.lua b/sys/tools/syscalls/scripts/syscall_h.lua new file mode 100755 index 000000000000..5f8d8fb66889 --- /dev/null +++ b/sys/tools/syscalls/scripts/syscall_h.lua @@ -0,0 +1,96 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local syscall_h = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +syscall_h.file = "/dev/null" + +-- Libc has all the STD, NOSTD and SYSMUX system calls in it, as well as +-- replaced system calls dating back to FreeBSD 7. We are lucky that the +-- system call filename is just the base symbol name for it. +function syscall_h.generate(tbl, config, fh) + -- Grab the master system calls table, and prepare bookkeeping for + -- the max system call number. + local s = tbl.syscalls + local max = 0 + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + + -- Write the generated preamble. + gen:preamble("System call numbers.") + + for _, v in pairs(s) do + local c = v:compatLevel() + if v.num > max then + max = v.num + end + if v.type.UNIMPL then + goto skip + elseif v.type.RESERVED then + goto skip + elseif v.type.NODEF then + goto skip + elseif v.type.STD or v.type.NOSTD or v.type.SYSMUX or + c >= 7 then + gen:write(string.format("#define\t%s%s%s\t%d\n", + config.syscallprefix, v:compatPrefix(), v.name, + v.num)) + elseif c >= 0 then + local comment + if c == 0 then + comment = "obsolete" + elseif c == 3 then + comment = "old" + else + comment = "freebsd" .. c + end + gen:write(string.format("\t\t\t\t/* %d is %s %s */\n", + v.num, comment, v.name)) + end + ::skip:: + end + gen:write(string.format("#define\t%sMAXSYSCALL\t%d\n", + config.syscallprefix, max + 1)) +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed system call table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + syscall_h.file = config.syshdr -- change file here + syscall_h.generate(tbl, config, syscall_h.file) +end + +-- Return the module. +return syscall_h diff --git a/sys/tools/syscalls/scripts/syscall_mk.lua b/sys/tools/syscalls/scripts/syscall_mk.lua new file mode 100755 index 000000000000..49d3f6f86c20 --- /dev/null +++ b/sys/tools/syscalls/scripts/syscall_mk.lua @@ -0,0 +1,89 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local syscall_mk = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +syscall_mk.file = "/dev/null" + +-- Libc has all the STD, NOSTD and SYSMUX system calls in it, as well as +-- replaced system calls dating back to FreeBSD 7. We are lucky that the +-- system call filename is just the base symbol name for it. +function syscall_mk.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + -- Bookkeeping for keeping track of when we're at the last system + -- call (no backslash). + local size = #s + local idx = 0 + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + + -- Write the generated preamble. + gen:preamble("FreeBSD system call object files.", "#") + + gen:write("MIASM = \\\n") -- preamble + for _, v in pairs(s) do + local c = v:compatLevel() + idx = idx + 1 + if v:native() and not v.type.NODEF and not v.type.NOLIB then + if idx >= size then + -- At last system call, no backslash. + gen:write(string.format("\t%s.o\n", v:symbol())) + else + -- Normal behavior. + gen:write(string.format("\t%s.o \\\n", v:symbol())) + end + -- Handle compat (everything >= FREEBSD3): + elseif c >= 7 and not v.type.NODEF and not v.type.NOLIB then + if idx >= size then + -- At last system call, no backslash. + gen:write(string.format("\t%s.o\n", v:symbol())) + else + -- Normal behavior. + gen:write(string.format("\t%s.o \\\n", v:symbol())) + end + end + end +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed syscall table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + syscall_mk.file = config.sysmk -- change file here + syscall_mk.generate(tbl, config, syscall_mk.file) +end + +-- Return the module. +return syscall_mk diff --git a/sys/tools/syscalls/scripts/syscalls.lua b/sys/tools/syscalls/scripts/syscalls.lua new file mode 100755 index 000000000000..38ed396a73ae --- /dev/null +++ b/sys/tools/syscalls/scripts/syscalls.lua @@ -0,0 +1,108 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local syscalls = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +syscalls.file = "/dev/null" + +function syscalls.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + + -- Write the generated preamble. + gen:preamble("System call names.") + + gen:write(string.format("const char *%s[] = {\n", config.namesname)) + + for _, v in pairs(s) do + --print("num " .. v.num .. " name " .. v.name) + local c = v:compatLevel() + if v:native() then + gen:write(string.format([[ + "%s", /* %d = %s */ +]], + v.name, v.num, v.name)) + elseif c >= 3 then + -- Lookup the info for this specific compat option. + local flag, descr + for _, opt in pairs(config.compat_options) do + if opt.compatlevel == c then + flag = opt.flag + flag = flag:lower() + descr = opt.descr + break + end + end + + gen:write(string.format([[ + "%s.%s", /* %d = %s %s */ +]], + flag, v.name, v.num, descr, v.name)) + + elseif v.type.RESERVED then + gen:write(string.format([[ + "#%d", /* %d = reserved for local use */ +]], + v.num, v.num)) + + elseif v.type.UNIMPL then + gen:write(string.format([[ + "#%d", /* %d = %s */ +]], + v.num, v.num, v.alias)) + + elseif v.type.OBSOL then + gen:write(string.format([[ + "obs_%s", /* %d = obsolete %s */ +]], + v.name, v.num, v.name)) + + end + end + -- End + gen:write("};\n") +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed syscall table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + syscalls.file = config.sysnames -- change file here + syscalls.generate(tbl, config, syscalls.file) +end + +-- Return the module. +return syscalls diff --git a/sys/tools/syscalls/scripts/syscalls_map.lua b/sys/tools/syscalls/scripts/syscalls_map.lua new file mode 100755 index 000000000000..023b43052921 --- /dev/null +++ b/sys/tools/syscalls/scripts/syscalls_map.lua @@ -0,0 +1,73 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 SRI International +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local syscalls_map = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +syscalls_map.file = "/dev/null" + +function syscalls_map.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + + -- Write the generated preamble. + gen:preamble("FreeBSD system call symbols.") + + gen:write(string.format("FBSDprivate_1.0 {\n")) + + for _, v in pairs(s) do + --print("num " .. v.num .. " name " .. v.name) + if v:native() and not v.type.NODEF and not v.type.NOLIB then + if v.name ~= "exit" and v.name ~= "vfork" then + gen:write(string.format("\t_%s;\n", v.name)) + end + gen:write(string.format("\t__sys_%s;\n", v.name)) + end + end + -- End + gen:write("};\n") +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed syscall table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + syscalls_map.file = config.libsysmap -- change file here + syscalls_map.generate(tbl, config, syscalls_map.file) +end + +-- Return the module. +return syscalls_map diff --git a/sys/tools/syscalls/scripts/sysproto_h.lua b/sys/tools/syscalls/scripts/sysproto_h.lua new file mode 100755 index 000000000000..6770e0548899 --- /dev/null +++ b/sys/tools/syscalls/scripts/sysproto_h.lua @@ -0,0 +1,241 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local sysproto_h = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local generator = require("tools.generator") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +sysproto_h.file = "/dev/null" + +function sysproto_h.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + gen.storage_levels = {} -- make sure storage is clear + + -- Write the generated preamble. + gen:preamble("System call prototypes.") + + -- Write out all the preprocessor directives. + gen:write(string.format([[ +#ifndef %s +#define %s + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct proc; + +struct thread; + +#define PAD_(t) (sizeof(syscallarg_t) <= sizeof(t) ? \ + 0 : sizeof(syscallarg_t) - sizeof(t)) + +#if BYTE_ORDER == LITTLE_ENDIAN +#define PADL_(t) 0 +#define PADR_(t) PAD_(t) +#else +#define PADL_(t) PAD_(t) +#define PADR_(t) 0 +#endif + +]], config.sysproto_h, config.sysproto_h)) + + -- 64-bit padding preprocessor directive. + gen:pad64(config.abiChanges("pair_64bit")) + + -- + -- Storing each compat entry requires storing multiple levels of file + -- generation; compat entries are given ranges of 10 instead to cope + -- with this. For example, 13 is indexed as 130; 131 is the second + -- storage level of 13. + -- + + -- Store all the compat #ifdef from compat_options at their zero index. + for _, v in pairs(config.compat_options) do + -- Tag an extra newline to the end, so it doesn't have to be + -- worried about later. + gen:store(string.format("\n#ifdef %s\n\n", v.definition), + v.compatlevel * 10) + end + + for _, v in pairs(s) do + local c = v:compatLevel() + + -- Audit defines are stored at an arbitrarily large number so + -- that they're always at the last storage level, and compat + -- entries can be indexed by their compat level (more + -- intuitive). + local audit_idx = 10000 -- this should do + + -- Handle non-compat: + if v:native() then + -- All these negation conditions are because (in + -- general) these are cases where code for sysproto.h + -- is not generated. + if not v.type.NOARGS and not v.type.NOPROTO and + not v.type.NODEF then + if #v.args > 0 then + gen:write(string.format( + "struct %s {\n", v.arg_alias)) + for _, arg in ipairs(v.args) do + if arg.type == "int" and + arg.name == "_pad" and + config.abiChanges( + "pair_64bit") then + gen:write("#ifdef PAD64_REQUIRED\n") + end + + gen:write(string.format([[ + char %s_l_[PADL_(%s)]; %s %s; char %s_r_[PADR_(%s)]; +]], + arg.name, arg.type, + arg.type, arg.name, + arg.name, arg.type)) + + if arg.type == "int" and + arg.name == "_pad" and + config.abiChanges( + "pair_64bit") then + gen:write("#endif\n") + end + end + gen:write("};\n") + else + gen:write(string.format( + "struct %s {\n\tsyscallarg_t dummy;\n};\n", + v.arg_alias)) + end + end + if not v.type.NOPROTO and not v.type.NODEF then + local sys_prefix = "sys_" + if v.name == "nosys" or v.name == "lkmnosys" or + v.name == "sysarch" or + v.name:find("^freebsd") or + v.name:find("^linux") then + sys_prefix = "" + end + gen:store(string.format( + "%s\t%s%s(struct thread *, struct %s *);\n", + v.rettype, sys_prefix, v.name, v.arg_alias), + 1) + gen:store(string.format( + "#define\t%sAUE_%s\t%s\n", + config.syscallprefix, v:symbol(), v.audit), + audit_idx) + end + + -- Handle compat (everything >= FREEBSD3): + elseif c >= 3 then + local idx = c * 10 + if not v.type.NOARGS and not v.type.NOPROTO and + not v.type.NODEF then + if #v.args > 0 then + gen:store(string.format( + "struct %s {\n", v.arg_alias), idx) + for _, arg in ipairs(v.args) do + gen:store(string.format([[ + char %s_l_[PADL_(%s)]; %s %s; char %s_r_[PADR_(%s)]; +]], + arg.name, arg.type, + arg.type, arg.name, + arg.name, arg.type), idx) + end + gen:store("};\n", idx) + else + -- Not stored, written on the first run. + gen:write(string.format([[ +struct %s { + syscallarg_t dummy; +}; +]], + v.arg_alias)) + end + end + if not v.type.NOPROTO and not v.type.NODEF then + gen:store(string.format([[ +%s %s%s(struct thread *, struct %s *); +]], + v.rettype, v:compatPrefix(), v.name, + v.arg_alias), idx + 1) + gen:store(string.format([[ +#define %sAUE_%s%s %s +]], + config.syscallprefix, v:compatPrefix(), + v.name, v.audit), audit_idx) + end + end + -- Do nothing for obsolete, unimplemented, and reserved. + end + + -- Append #endif to the end of each compat option. + for _, v in pairs(config.compat_options) do + -- Based on how they're indexed, 9 is the last index. + local end_idx = (v.compatlevel * 10) + 9 + -- Need an extra newline after #endif. + gen:store(string.format("\n#endif /* %s */\n\n", v.definition), + end_idx) + end + + if gen.storage_levels ~= nil then + gen:writeStorage() + end + + -- After storage has been unrolled, tag on the ending bits. + gen:write(string.format([[ + +#undef PAD_ +#undef PADL_ +#undef PADR_ + +#endif /* !%s */ +]], config.sysproto_h)) +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed system call table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + sysproto_h.file = config.sysproto -- change file here + sysproto_h.generate(tbl, config, sysproto_h.file) +end + +-- Return the module. +return sysproto_h diff --git a/sys/tools/syscalls/scripts/systrace_args.lua b/sys/tools/syscalls/scripts/systrace_args.lua new file mode 100755 index 000000000000..88170b85e737 --- /dev/null +++ b/sys/tools/syscalls/scripts/systrace_args.lua @@ -0,0 +1,267 @@ +#!/usr/libexec/flua +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +-- Setup to be a module, or ran as its own script. +local systrace_args = {} +local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script. +if script then + -- Add library root to the package path. + local path = arg[0]:gsub("/[^/]+.lua$", "") + package.path = package.path .. ";" .. path .. "/../?.lua" +end + +local FreeBSDSyscall = require("core.freebsd-syscall") +local util = require("tools.util") +local generator = require("tools.generator") + +-- File has not been decided yet; config will decide file. Default defined as +-- /dev/null. +systrace_args.file = "/dev/null" + +function systrace_args.generate(tbl, config, fh) + -- Grab the master system calls table. + local s = tbl.syscalls + + -- Bind the generator to the parameter file. + local gen = generator:new({}, fh) + gen.storage_levels = {} -- make sure storage is clear + + -- 64-bit padding preprocessor directive. + gen:pad64(config.abiChanges("pair_64bit")) + + -- Write the generated preamble. + gen:preamble( + "System call argument to DTrace register array conversion.\n" .. + "\n" .. + "This file is part of the DTrace syscall provider.") + + gen:write(string.format([[ +static void +systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) +{ + int64_t *iarg = (int64_t *)uarg; + int a = 0; + switch (sysnum) { +]])) + + gen:store(string.format([[ +static void +systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) +{ + const char *p = NULL; + switch (sysnum) { +]]), 1) + + gen:store(string.format([[ +static void +systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) +{ + const char *p = NULL; + switch (sysnum) { +]]), 2) + + for _, v in pairs(s) do + + -- Handle non compat: + if v:native() then + gen:write(string.format([[ + /* %s */ + case %d: { +]], v.name, v.num)) + + gen:store(string.format([[ + /* %s */ + case %d: +]], v.name, v.num), 1) + + gen:store(string.format([[ + /* %s */ + case %d: +]], v.name, v.num), 2) + + local n_args = #v.args + if v.type.SYSMUX then + n_args = 0 + end + + if #v.args > 0 and not v.type.SYSMUX then + local padding = "" + + gen:write(string.format([[ + struct %s *p = params; +]], + v.arg_alias)) + + gen:store([[ + switch (ndx) { +]], + 1) + + for idx, arg in ipairs(v.args) do + local argtype = util.trim( + arg.type:gsub( + "__restrict$", ""), nil) + if argtype == "int" and + arg.name == "_pad" and + config.abiChanges("pair_64bit") then + gen:store( + "#ifdef PAD64_REQUIRED\n", + 1) + end + + -- Pointer arg? + local desc + if argtype:find("*") then + desc = "userland " .. argtype + else + desc = argtype; + end + + gen:store(string.format([[ + case %d%s: + p = "%s"; + break; +]], + idx - 1, padding, desc), 1) + + if argtype == "int" and + arg.name == "_pad" and + config.abiChanges("pair_64bit") then + padding = " - _P_" + gen:store([[ +#define _P_ 0 +#else +#define _P_ 1 +#endif +]], + 1) + end + + if util.isPtrType(argtype, + config.abi_intptr_t) then + gen:write(string.format([[ + uarg[a++] = (%s)p->%s; /* %s */ +]], + config.ptr_intptr_t_cast, + arg.name, argtype)) + elseif argtype == "union l_semun" then + gen:write(string.format([[ + uarg[a++] = p->%s.buf; /* %s */ +]], + arg.name, argtype)) + elseif argtype:sub(1,1) == "u" or + argtype == "size_t" then + gen:write(string.format([[ + uarg[a++] = p->%s; /* %s */ +]], + arg.name, argtype)) + else + if argtype == "int" and + arg.name == "_pad" and + config.abiChanges( + "pair_64bit") then + gen:write([[ +#ifdef PAD64_REQUIRED +]]) + end + + gen:write(string.format([[ + iarg[a++] = p->%s; /* %s */ +]], + arg.name, argtype)) + + if argtype == "int" and + arg.name == "_pad" and + config.abiChanges( + "pair_64bit") then + gen:write("#endif\n") + end + end + end + + gen:store([[ + default: + break; + }; +]], + 1) + + if padding ~= "" then + gen:store("#undef _P_\n\n", 1) + end + + gen:store(string.format([[ + if (ndx == 0 || ndx == 1) + p = "%s"; + break; +]], v.ret), 2) + end + + gen:write(string.format("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", + n_args)) + gen:store("\t\tbreak;\n", 1) + + -- Handle compat (everything >= FREEBSD3): + -- Do nothing, only for native. + end + end + + gen:write([[ + default: + *n_args = 0; + break; + }; +} +]]) + gen:store([[ + default: + break; + }; + if (p != NULL) + strlcpy(desc, p, descsz); +} +]], 1) + gen:store([[ + default: + break; + }; + if (p != NULL) + strlcpy(desc, p, descsz); +} +]], 2) + + -- Write all stored lines. + if gen.storage_levels ~= nil then + gen:writeStorage() + end + +end + +-- Entry of script: +if script then + local config = require("config") + + if #arg < 1 or #arg > 2 then + error("usage: " .. arg[0] .. " syscall.master") + end + + local sysfile, configfile = arg[1], arg[2] + + config.merge(configfile) + config.mergeCompat() + + -- The parsed system call table. + local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} + + systrace_args.file = config.systrace -- change file here + systrace_args.generate(tbl, config, systrace_args.file) +end + +-- Return the module. +return systrace_args diff --git a/sys/tools/syscalls/tools/generator.lua b/sys/tools/syscalls/tools/generator.lua new file mode 100644 index 000000000000..bb6378a27ed6 --- /dev/null +++ b/sys/tools/syscalls/tools/generator.lua @@ -0,0 +1,113 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2019 Kyle Evans +-- + +local util = require("tools.util") + +local generator = {} + +generator.__index = generator + +-- Wrapper for Lua write() best practice, for a simpler write call. +function generator:write(line) + assert(self.gen:write(line)) +end + +-- +-- A write macro for the PAD64 preprocessor directive. +-- Used for 32-bit configurations by passing config.abiChanges("pair_64bit") and +-- padding will be done if necessary. +-- +-- PARAM: bool, TRUE to pad. +-- +function generator:pad64(bool) + if bool then + self:write([[ +#if !defined(PAD64_REQUIRED) && !defined(__amd64__) +#define PAD64_REQUIRED +#endif +]]) + end +end + +-- Returns the generated tag. +function generator:tag() + return self.tag +end + +generator.storage_levels = {} + +-- Optional level to specify which order to store in, which defaults to one if +-- not provided. +function generator:store(str, level) + level = level or 1 + self.storage_levels[level] = self.storage_levels[level] or {} + table.insert(self.storage_levels[level], str) +end + +-- Write all storage in the order it was stored. +function generator:writeStorage() + if self.storage_levels ~= nil then + for _, v in util.ipairsSparse(self.storage_levels) do + for _, line in ipairs(v) do + generator:write(line) + end + end + end +end + +-- +-- Writes the generated preamble. Default comment is C comments. +-- +-- PARAM: String str, the title for the file. +-- +-- PARAM: String comment, nil or optional to change comment (e.g., "#" for sh +-- comments). +-- +-- SEE: style(9) +-- +function generator:preamble(str, comment) + if str ~= nil then + local comment_start = comment or "/*" + local comment_middle = comment or " *" + local comment_end = comment or " */" + self:write(string.format("%s\n", comment_start)) + -- Splits our string into lines split by newline, or is just the + -- original string if there's no newlines. + for line in str:gmatch("[^\n]*") do + -- Only add a space after the comment if there's + -- text on this line. + local space + if line ~= "" then + space = " " + else + space = "" + end + -- Make sure to append the newline back. + self:write(string.format("%s%s%s\n", comment_middle, + space, line)) + end + self:write(string.format([[%s +%s DO NOT EDIT-- this file is automatically %s. +%s + +]], comment_middle, comment_middle, self.tag, comment_end)) + end +end + +-- generator binds to the parameter file. +function generator:new(obj, fh) + obj = obj or { } + setmetatable(obj, self) + self.__index = self + + self.gen = assert(io.open(fh, "w+")) + self.tag = "@" .. "generated" + + return obj +end + +return generator diff --git a/sys/tools/syscalls/tools/util.lua b/sys/tools/syscalls/tools/util.lua new file mode 100644 index 000000000000..c9ff98dda786 --- /dev/null +++ b/sys/tools/syscalls/tools/util.lua @@ -0,0 +1,194 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2024 Tyler Baxter +-- Copyright (c) 2023 Warner Losh +-- Copyright (c) 2019 Kyle Evans +-- + +local util = {} + +-- +-- Returns a trimmed string. Default is to trim whitespace. +-- +-- PARAM: String s, the string to trim. +-- +-- PARAM: char, nil or optional character to trim. +-- +function util.trim(s, char) + if s == nil then + return nil + end + if char == nil then + char = "%s" + end + return s:gsub("^" .. char .. "+", ""):gsub(char .. "+$", "") +end + +-- Returns a table (list) of strings. +function util.split(s, re) + local t = { } + + for v in s:gmatch(re) do + table.insert(t, v) + end + return t +end + +-- Aborts with a message and does a clean exit procedure. +function util.abort(status, msg) + assert(io.stderr:write(msg .. "\n")) + -- cleanup + os.exit(status) +end + +-- +-- Returns a set. +-- +-- PARAM: t, a list. +-- +-- EXAMPLE: param: {"foo", "bar"}, return: {foo = true, bar = true} +-- +function util.set(t) + local s = { } + + for _,v in pairs(t) do + s[v] = true + end + return s +end + +-- +-- Returns a set. +-- +-- PARAM: str, a string. +-- PARAM: re, the pattern to construct keys from. +-- +function util.setFromString(str, re) + local s = { } + + for v in str:gmatch(re) do + s[v] = true + end + return s +end + +function util.isEmpty(tbl) + if tbl ~= nil then + if next(tbl) == nil then + return true + end + return false + end + return true +end + +-- +-- Iterator that traverses a table following the order of its keys. +-- An optional parameter f allows the specification of an alternative order. +-- +-- CREDIT: https://www.lua.org/pil/19.3.html +-- LICENSE: MIT +-- +function util.pairsByKeys(t, f) + local a = {} + for n in pairs(t) do table.insert(a, n) end + table.sort(a, f) + local i = 0 -- iterator variable + local iter = function () -- iterator function + i = i + 1 + if a[i] == nil then + return nil + else + return a[i], t[a[i]] + end + end + return iter +end + +-- +-- Checks for pointer types: '*', caddr_t, or intptr_t. +-- +-- PARAM: type, the type to check. +-- +-- PARAM: abi, nil or optional ABI-specified intptr_t. +-- +function util.isPtrType(type, abi) + local default = abi or "intptr_t" + return type:find("*") or type:find("caddr_t") or type:find(default) +end + +function util.isPtrArrayType(type) + return type:find("[*][*]") or type:find("[*][ ]*const[ ]*[*]") +end + +-- Find types that are always 64-bits wide. +function util.is64bitType(type) + return type:find("^dev_t[ ]*$") or type:find("^id_t[ ]*$") or + type:find("^off_t[ ]*$") +end + +-- +-- Returns the name of the struct pointed to by the argument or nil. +-- +-- PARAM: type, the type to check. +-- +function util.structName(type) + if util.isPtrType(type) then + local is_struct = false + for word in type:gmatch("[^ *]+") do + if is_struct then + return word + end + if word == "struct" then + -- next word is the struct name + is_struct = true + end + end + end + return nil +end + +-- Strip the ABI function prefix if it exists (e.g., "freebsd32_"). Returns the +-- function name with the ABI prefix stripped, or the original function name if +-- there was no ABI function prefix. +function util.stripAbiPrefix(funcname, abiprefix) + local stripped_name + if funcname == nil then + return nil + end + if abiprefix ~= "" and funcname:find("^" .. abiprefix) then + stripped_name = funcname:gsub("^" .. abiprefix, "") + else + stripped_name = funcname + end + + return stripped_name +end + +-- ipairs for a sparse array. +-- CREDIT: Lua Game Development Cookbook, Mario Kasuba +function util.ipairsSparse(t) + -- tmp_index will hold sorted indices, otherwise + -- this iterator would be no different from pairs iterator + local tmp_index = {} + local index, _ = next(t) + while index do + tmp_index[#tmp_index + 1] = index + index, _ = next(t, index) + end + -- sort table indices + table.sort(tmp_index) + local j = 1 + + return function() + -- get index value + local i = tmp_index[j] + j = j + 1 + if i then + return i, t[i] + end + end +end + +return util