Index: share/mk/src.sys.mk =================================================================== --- share/mk/src.sys.mk +++ share/mk/src.sys.mk @@ -34,6 +34,8 @@ .endif # SRCCONF .endif +LUA?= /usr/local/bin/lua53 + # tempting, but bsd.compiler.mk causes problems this early # probably need to remove dependence on bsd.own.mk #.include "src.opts.mk" Index: sys/amd64/linux/Makefile =================================================================== --- sys/amd64/linux/Makefile +++ sys/amd64/linux/Makefile @@ -11,5 +11,5 @@ sysent: linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c: \ - ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf + ${LUA} ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf Index: sys/amd64/linux/linux_systrace_args.c =================================================================== --- sys/amd64/linux/linux_systrace_args.c +++ sys/amd64/linux/linux_systrace_args.c @@ -156,7 +156,7 @@ struct linux_ioctl_args *p = params; iarg[0] = p->fd; /* l_uint */ iarg[1] = p->cmd; /* l_uint */ - uarg[2] = p->arg; /* uintptr_t */ + uarg[2] = (intptr_t) p->arg; /* uintptr_t */ *n_args = 3; break; } @@ -374,7 +374,7 @@ case 42: { struct linux_connect_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -383,8 +383,8 @@ case 43: { struct linux_accept_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -392,10 +392,10 @@ case 44: { struct linux_sendto_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->len; /* l_int */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->to; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->to; /* l_uintptr_t */ iarg[5] = p->tolen; /* l_int */ *n_args = 6; break; @@ -404,11 +404,11 @@ case 45: { struct linux_recvfrom_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->buf; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->buf; /* l_uintptr_t */ iarg[2] = p->len; /* l_size_t */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->from; /* l_uintptr_t */ - iarg[5] = p->fromlen; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->from; /* l_uintptr_t */ + uarg[5] = (intptr_t) p->fromlen; /* l_uintptr_t */ *n_args = 6; break; } @@ -416,7 +416,7 @@ case 46: { struct linux_sendmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; @@ -425,7 +425,7 @@ case 47: { struct linux_recvmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; @@ -442,7 +442,7 @@ case 49: { struct linux_bind_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -459,8 +459,8 @@ case 51: { struct linux_getsockname_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -468,8 +468,8 @@ case 52: { struct linux_getpeername_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -479,7 +479,7 @@ iarg[0] = p->domain; /* l_int */ iarg[1] = p->type; /* l_int */ iarg[2] = p->protocol; /* l_int */ - iarg[3] = p->rsv; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->rsv; /* l_uintptr_t */ *n_args = 4; break; } @@ -489,7 +489,7 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ iarg[4] = p->optlen; /* l_int */ *n_args = 5; break; @@ -500,8 +500,8 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ - iarg[4] = p->optlen; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->optlen; /* l_uintptr_t */ *n_args = 5; break; } @@ -1277,10 +1277,10 @@ case 157: { struct linux_prctl_args *p = params; iarg[0] = p->option; /* l_int */ - iarg[1] = p->arg2; /* l_uintptr_t */ - iarg[2] = p->arg3; /* l_uintptr_t */ - iarg[3] = p->arg4; /* l_uintptr_t */ - iarg[4] = p->arg5; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->arg2; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->arg3; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->arg4; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->arg5; /* l_uintptr_t */ *n_args = 5; break; } @@ -2064,8 +2064,8 @@ case 288: { struct linux_accept4_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ iarg[3] = p->flags; /* int */ *n_args = 4; break; Index: sys/amd64/linux32/Makefile =================================================================== --- sys/amd64/linux32/Makefile +++ sys/amd64/linux32/Makefile @@ -10,6 +10,6 @@ sysent: linux32_sysent.c linux32_syscall.h linux32_proto.h linux32_syscalls.c linux32_systrace_args.c -linux32_sysent.c linux32_syscall.h linux32_proto.h linux32_syscalls.c linux32_systrace_args.c: ../../kern/makesyscalls.sh \ +linux32_sysent.c linux32_syscall.h linux32_proto.h linux32_syscalls.c linux32_systrace_args.c: ../../tools/makesyscalls.lua \ syscalls.master ${.CURDIR}/syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + ${LUA} ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf Index: sys/amd64/linux32/linux32_systrace_args.c =================================================================== --- sys/amd64/linux32/linux32_systrace_args.c +++ sys/amd64/linux32/linux32_systrace_args.c @@ -355,7 +355,7 @@ struct linux_ioctl_args *p = params; iarg[0] = p->fd; /* l_uint */ iarg[1] = p->cmd; /* l_uint */ - uarg[2] = p->arg; /* uintptr_t */ + uarg[2] = (intptr_t) p->arg; /* uintptr_t */ *n_args = 3; break; } @@ -364,7 +364,7 @@ struct linux_fcntl_args *p = params; iarg[0] = p->fd; /* l_uint */ iarg[1] = p->cmd; /* l_uint */ - uarg[2] = p->arg; /* uintptr_t */ + uarg[2] = (intptr_t) p->arg; /* uintptr_t */ *n_args = 3; break; } @@ -786,7 +786,7 @@ iarg[1] = p->arg1; /* l_int */ iarg[2] = p->arg2; /* l_int */ iarg[3] = p->arg3; /* l_uint */ - iarg[4] = p->ptr; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->ptr; /* l_uintptr_t */ iarg[5] = p->arg5; /* l_uint */ *n_args = 6; break; @@ -1539,7 +1539,7 @@ struct linux_fcntl64_args *p = params; iarg[0] = p->fd; /* l_uint */ iarg[1] = p->cmd; /* l_uint */ - uarg[2] = p->arg; /* uintptr_t */ + uarg[2] = (intptr_t) p->arg; /* uintptr_t */ *n_args = 3; break; } @@ -2493,7 +2493,7 @@ iarg[0] = p->domain; /* l_int */ iarg[1] = p->type; /* l_int */ iarg[2] = p->protocol; /* l_int */ - iarg[3] = p->rsv; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->rsv; /* l_uintptr_t */ *n_args = 4; break; } @@ -2501,7 +2501,7 @@ case 361: { struct linux_bind_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -2510,7 +2510,7 @@ case 362: { struct linux_connect_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -2527,8 +2527,8 @@ case 364: { struct linux_accept4_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ iarg[3] = p->flags; /* l_int */ *n_args = 4; break; @@ -2539,8 +2539,8 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ - iarg[4] = p->optlen; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->optlen; /* l_uintptr_t */ *n_args = 5; break; } @@ -2550,7 +2550,7 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ iarg[4] = p->optlen; /* l_int */ *n_args = 5; break; @@ -2559,8 +2559,8 @@ case 367: { struct linux_getsockname_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -2568,8 +2568,8 @@ case 368: { struct linux_getpeername_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -2577,10 +2577,10 @@ case 369: { struct linux_sendto_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->len; /* l_int */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->to; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->to; /* l_uintptr_t */ iarg[5] = p->tolen; /* l_int */ *n_args = 6; break; @@ -2589,7 +2589,7 @@ case 370: { struct linux_sendmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; @@ -2598,11 +2598,11 @@ case 371: { struct linux_recvfrom_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->buf; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->buf; /* l_uintptr_t */ iarg[2] = p->len; /* l_size_t */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->from; /* l_uintptr_t */ - iarg[5] = p->fromlen; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->from; /* l_uintptr_t */ + uarg[5] = (intptr_t) p->fromlen; /* l_uintptr_t */ *n_args = 6; break; } @@ -2610,7 +2610,7 @@ case 372: { struct linux_recvmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; Index: sys/arm64/linux/Makefile =================================================================== --- sys/arm64/linux/Makefile +++ sys/arm64/linux/Makefile @@ -11,5 +11,5 @@ sysent: linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c: \ - ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf + ${LUA} ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf Index: sys/arm64/linux/linux_systrace_args.c =================================================================== --- sys/arm64/linux/linux_systrace_args.c +++ sys/arm64/linux/linux_systrace_args.c @@ -169,7 +169,7 @@ struct linux_ioctl_args *p = params; iarg[0] = p->fd; /* l_uint */ iarg[1] = p->cmd; /* l_uint */ - uarg[2] = p->arg; /* uintptr_t */ + uarg[2] = (intptr_t) p->arg; /* uintptr_t */ *n_args = 3; break; } @@ -1253,10 +1253,10 @@ case 167: { struct linux_prctl_args *p = params; iarg[0] = p->option; /* l_int */ - iarg[1] = p->arg2; /* l_uintptr_t */ - iarg[2] = p->arg3; /* l_uintptr_t */ - iarg[3] = p->arg4; /* l_uintptr_t */ - iarg[4] = p->arg5; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->arg2; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->arg3; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->arg4; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->arg5; /* l_uintptr_t */ *n_args = 5; break; } @@ -1482,7 +1482,7 @@ iarg[0] = p->domain; /* l_int */ iarg[1] = p->type; /* l_int */ iarg[2] = p->protocol; /* l_int */ - iarg[3] = p->rsv; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->rsv; /* l_uintptr_t */ *n_args = 4; break; } @@ -1490,7 +1490,7 @@ case 200: { struct linux_bind_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -1507,8 +1507,8 @@ case 202: { struct linux_accept_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -1516,7 +1516,7 @@ case 203: { struct linux_connect_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -1525,8 +1525,8 @@ case 204: { struct linux_getsockname_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -1534,8 +1534,8 @@ case 205: { struct linux_getpeername_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -1543,10 +1543,10 @@ case 206: { struct linux_sendto_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->len; /* l_int */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->to; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->to; /* l_uintptr_t */ iarg[5] = p->tolen; /* l_int */ *n_args = 6; break; @@ -1555,11 +1555,11 @@ case 207: { struct linux_recvfrom_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->buf; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->buf; /* l_uintptr_t */ iarg[2] = p->len; /* l_size_t */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->from; /* l_uintptr_t */ - iarg[5] = p->fromlen; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->from; /* l_uintptr_t */ + uarg[5] = (intptr_t) p->fromlen; /* l_uintptr_t */ *n_args = 6; break; } @@ -1569,7 +1569,7 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ iarg[4] = p->optlen; /* l_int */ *n_args = 5; break; @@ -1580,8 +1580,8 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ - iarg[4] = p->optlen; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->optlen; /* l_uintptr_t */ *n_args = 5; break; } @@ -1597,7 +1597,7 @@ case 211: { struct linux_sendmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; @@ -1606,7 +1606,7 @@ case 212: { struct linux_recvmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; @@ -1819,8 +1819,8 @@ case 242: { struct linux_accept4_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ iarg[3] = p->flags; /* int */ *n_args = 4; break; Index: sys/compat/freebsd32/Makefile =================================================================== --- sys/compat/freebsd32/Makefile +++ sys/compat/freebsd32/Makefile @@ -11,8 +11,8 @@ sysent: freebsd32_sysent.c freebsd32_syscall.h freebsd32_proto.h freebsd32_systrace_args.c freebsd32_sysent.c freebsd32_syscalls.c freebsd32_syscall.h freebsd32_proto.h freebsd32_systrace_args.c : \ - ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf ../../kern/capabilities.conf - sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf ../../kern/capabilities.conf + ${LUA} ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf clean: rm -f freebsd32_sysent.c freebsd32_syscalls.c freebsd32_syscall.h freebsd32_proto.h Index: sys/compat/freebsd32/freebsd32_proto.h =================================================================== --- sys/compat/freebsd32/freebsd32_proto.h +++ sys/compat/freebsd32/freebsd32_proto.h @@ -238,7 +238,7 @@ }; struct freebsd32_lio_listio_args { char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)]; - char acb_list_l_[PADL_(struct aiocb32 *const *)]; struct aiocb32 *const * acb_list; char acb_list_r_[PADR_(struct aiocb32 *const *)]; + char acb_list_l_[PADL_(struct aiocb32 * const *)]; struct aiocb32 * const * acb_list; char acb_list_r_[PADR_(struct aiocb32 * const *)]; char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)]; char sig_l_[PADL_(struct sigevent32 *)]; struct sigevent32 * sig; char sig_r_[PADR_(struct sigevent32 *)]; }; @@ -262,17 +262,17 @@ }; struct freebsd32_modstat_args { char modid_l_[PADL_(int)]; int modid; char modid_r_[PADR_(int)]; - char stat_l_[PADL_(struct module_stat32 *)]; struct module_stat32 * stat; char stat_r_[PADR_(struct module_stat32 *)]; + char stat_l_[PADL_(struct module_stat32*)]; struct module_stat32* stat; char stat_r_[PADR_(struct module_stat32*)]; }; struct freebsd32_kldstat_args { char fileid_l_[PADL_(int)]; int fileid; char fileid_r_[PADR_(int)]; - char stat_l_[PADL_(struct kld32_file_stat *)]; struct kld32_file_stat * stat; char stat_r_[PADR_(struct kld32_file_stat *)]; + char stat_l_[PADL_(struct kld32_file_stat*)]; struct kld32_file_stat* stat; char stat_r_[PADR_(struct kld32_file_stat*)]; }; struct freebsd32_aio_return_args { char aiocbp_l_[PADL_(struct aiocb32 *)]; struct aiocb32 * aiocbp; char aiocbp_r_[PADR_(struct aiocb32 *)]; }; struct freebsd32_aio_suspend_args { - char aiocbp_l_[PADL_(struct aiocb32 *const *)]; struct aiocb32 *const * aiocbp; char aiocbp_r_[PADR_(struct aiocb32 *const *)]; + char aiocbp_l_[PADL_(struct aiocb32 * const *)]; struct aiocb32 * const * aiocbp; char aiocbp_r_[PADR_(struct aiocb32 * const *)]; char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)]; char timeout_l_[PADL_(const struct timespec32 *)]; const struct timespec32 * timeout; char timeout_r_[PADR_(const struct timespec32 *)]; }; @@ -1094,7 +1094,7 @@ }; struct freebsd6_freebsd32_lio_listio_args { char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)]; - char acb_list_l_[PADL_(struct oaiocb32 *const *)]; struct oaiocb32 *const * acb_list; char acb_list_r_[PADR_(struct oaiocb32 *const *)]; + char acb_list_l_[PADL_(struct oaiocb32 * const *)]; struct oaiocb32 * const * acb_list; char acb_list_r_[PADR_(struct oaiocb32 * const *)]; char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)]; char sig_l_[PADL_(struct osigevent32 *)]; struct osigevent32 * sig; char sig_r_[PADR_(struct osigevent32 *)]; }; Index: sys/compat/freebsd32/freebsd32_syscalls.c =================================================================== --- sys/compat/freebsd32/freebsd32_syscalls.c +++ sys/compat/freebsd32/freebsd32_syscalls.c @@ -128,7 +128,7 @@ "freebsd32_gettimeofday", /* 116 = freebsd32_gettimeofday */ "freebsd32_getrusage", /* 117 = freebsd32_getrusage */ "getsockopt", /* 118 = getsockopt */ - "#119", /* 119 = resuba */ + "#119", /* 119 = resuba (BSD/OS 2.x) */ "freebsd32_readv", /* 120 = freebsd32_readv */ "freebsd32_writev", /* 121 = freebsd32_writev */ "freebsd32_settimeofday", /* 122 = freebsd32_settimeofday */ @@ -160,9 +160,9 @@ "quotactl", /* 148 = quotactl */ "obs_oquota", /* 149 = obsolete oquota */ "obs_ogetsockname", /* 150 = obsolete ogetsockname */ - "#151", /* 151 = sem_lock */ - "#152", /* 152 = sem_wakeup */ - "#153", /* 153 = asyncdaemon */ + "#151", /* 151 = sem_lock (BSD/OS 2.x) */ + "#152", /* 152 = sem_wakeup (BSD/OS 2.x) */ + "#153", /* 153 = asyncdaemon (BSD/OS 2.x) */ "#154", /* 154 = nlm_syscall */ "#155", /* 155 = nfssvc */ "compat.freebsd32_getdirentries", /* 156 = old freebsd32_getdirentries */ @@ -186,9 +186,9 @@ "compat6.freebsd32_pwrite", /* 174 = freebsd6 freebsd32_pwrite */ "#175", /* 175 = nosys */ "ntp_adjtime", /* 176 = ntp_adjtime */ - "#177", /* 177 = sfork */ - "#178", /* 178 = getdescriptor */ - "#179", /* 179 = setdescriptor */ + "#177", /* 177 = sfork (BSD/OS 2.x) */ + "#178", /* 178 = getdescriptor (BSD/OS 2.x) */ + "#179", /* 179 = setdescriptor (BSD/OS 2.x) */ "#180", /* 180 = nosys */ "setgid", /* 181 = setgid */ "setegid", /* 182 = setegid */ Index: sys/compat/freebsd32/freebsd32_sysent.c =================================================================== --- sys/compat/freebsd32/freebsd32_sysent.c +++ sys/compat/freebsd32/freebsd32_sysent.c @@ -175,7 +175,7 @@ { AS(freebsd32_gettimeofday_args), (sy_call_t *)freebsd32_gettimeofday, AUE_GETTIMEOFDAY, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 116 = freebsd32_gettimeofday */ { AS(freebsd32_getrusage_args), (sy_call_t *)freebsd32_getrusage, AUE_GETRUSAGE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 117 = freebsd32_getrusage */ { AS(getsockopt_args), (sy_call_t *)sys_getsockopt, AUE_GETSOCKOPT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 118 = getsockopt */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 119 = resuba */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 119 = resuba (BSD/OS 2.x) */ { AS(freebsd32_readv_args), (sy_call_t *)freebsd32_readv, AUE_READV, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 120 = freebsd32_readv */ { AS(freebsd32_writev_args), (sy_call_t *)freebsd32_writev, AUE_WRITEV, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 121 = freebsd32_writev */ { AS(freebsd32_settimeofday_args), (sy_call_t *)freebsd32_settimeofday, AUE_SETTIMEOFDAY, NULL, 0, 0, 0, SY_THR_STATIC }, /* 122 = freebsd32_settimeofday */ @@ -207,9 +207,9 @@ { AS(quotactl_args), (sy_call_t *)sys_quotactl, AUE_QUOTACTL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 148 = quotactl */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 149 = obsolete oquota */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 150 = obsolete ogetsockname */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 151 = sem_lock */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 152 = sem_wakeup */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 153 = asyncdaemon */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 151 = sem_lock (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 152 = sem_wakeup (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 153 = asyncdaemon (BSD/OS 2.x) */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 154 = nlm_syscall */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 155 = nfssvc */ { compat(AS(ofreebsd32_getdirentries_args),freebsd32_getdirentries), AUE_GETDIRENTRIES, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 156 = old freebsd32_getdirentries */ @@ -233,9 +233,9 @@ { compat6(AS(freebsd6_freebsd32_pwrite_args),freebsd32_pwrite), AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 174 = freebsd6 freebsd32_pwrite */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 175 = nosys */ { AS(ntp_adjtime_args), (sy_call_t *)sys_ntp_adjtime, AUE_NTP_ADJTIME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 176 = ntp_adjtime */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 177 = sfork */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 178 = getdescriptor */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 179 = setdescriptor */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 177 = sfork (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 178 = getdescriptor (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 179 = setdescriptor (BSD/OS 2.x) */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 180 = nosys */ { AS(setgid_args), (sy_call_t *)sys_setgid, AUE_SETGID, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 181 = setgid */ { AS(setegid_args), (sy_call_t *)sys_setegid, AUE_SETEGID, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 182 = setegid */ Index: sys/compat/freebsd32/freebsd32_systrace_args.c =================================================================== --- sys/compat/freebsd32/freebsd32_systrace_args.c +++ sys/compat/freebsd32/freebsd32_systrace_args.c @@ -1278,7 +1278,7 @@ case 257: { struct freebsd32_lio_listio_args *p = params; iarg[0] = p->mode; /* int */ - uarg[1] = (intptr_t) p->acb_list; /* struct aiocb32 *const * */ + uarg[1] = (intptr_t) p->acb_list; /* struct aiocb32 * const * */ iarg[2] = p->nent; /* int */ uarg[3] = (intptr_t) p->sig; /* struct sigevent32 * */ *n_args = 4; @@ -1341,7 +1341,7 @@ case 301: { struct freebsd32_modstat_args *p = params; iarg[0] = p->modid; /* int */ - uarg[1] = (intptr_t) p->stat; /* struct module_stat32 * */ + uarg[1] = (intptr_t) p->stat; /* struct module_stat32* */ *n_args = 2; break; } @@ -1391,7 +1391,7 @@ case 308: { struct freebsd32_kldstat_args *p = params; iarg[0] = p->fileid; /* int */ - uarg[1] = (intptr_t) p->stat; /* struct kld32_file_stat * */ + uarg[1] = (intptr_t) p->stat; /* struct kld32_file_stat* */ *n_args = 2; break; } @@ -1437,7 +1437,7 @@ /* freebsd32_aio_suspend */ case 315: { struct freebsd32_aio_suspend_args *p = params; - uarg[0] = (intptr_t) p->aiocbp; /* struct aiocb32 *const * */ + uarg[0] = (intptr_t) p->aiocbp; /* struct aiocb32 * const * */ iarg[1] = p->nent; /* int */ uarg[2] = (intptr_t) p->timeout; /* const struct timespec32 * */ *n_args = 3; @@ -5359,7 +5359,7 @@ p = "int"; break; case 1: - p = "userland struct aiocb32 *const *"; + p = "userland struct aiocb32 * const *"; break; case 2: p = "int"; @@ -5471,7 +5471,7 @@ p = "int"; break; case 1: - p = "userland struct module_stat32 *"; + p = "userland struct module_stat32*"; break; default: break; @@ -5544,7 +5544,7 @@ p = "int"; break; case 1: - p = "userland struct kld32_file_stat *"; + p = "userland struct kld32_file_stat*"; break; default: break; @@ -5616,7 +5616,7 @@ case 315: switch(ndx) { case 0: - p = "userland struct aiocb32 *const *"; + p = "userland struct aiocb32 * const *"; break; case 1: p = "int"; Index: sys/i386/linux/Makefile =================================================================== --- sys/i386/linux/Makefile +++ sys/i386/linux/Makefile @@ -11,5 +11,5 @@ sysent: linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c: \ - ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf + ${LUA} ../../tools/makesyscalls.lua syscalls.master ${.CURDIR}/syscalls.conf Index: sys/i386/linux/linux_systrace_args.c =================================================================== --- sys/i386/linux/linux_systrace_args.c +++ sys/i386/linux/linux_systrace_args.c @@ -815,7 +815,7 @@ iarg[1] = p->arg1; /* l_int */ iarg[2] = p->arg2; /* l_int */ iarg[3] = p->arg3; /* l_uint */ - iarg[4] = p->ptr; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->ptr; /* l_uintptr_t */ iarg[5] = p->arg5; /* l_uint */ *n_args = 6; break; @@ -1175,7 +1175,7 @@ /* poll */ case 168: { struct poll_args *p = params; - uarg[0] = (intptr_t) p->fds; /* struct pollfd * */ + uarg[0] = (intptr_t) p->fds; /* struct pollfd* */ uarg[1] = p->nfds; /* unsigned int */ iarg[2] = p->timeout; /* long */ *n_args = 3; @@ -2569,7 +2569,7 @@ iarg[0] = p->domain; /* l_int */ iarg[1] = p->type; /* l_int */ iarg[2] = p->protocol; /* l_int */ - iarg[3] = p->rsv; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->rsv; /* l_uintptr_t */ *n_args = 4; break; } @@ -2577,7 +2577,7 @@ case 361: { struct linux_bind_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -2586,7 +2586,7 @@ case 362: { struct linux_connect_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->name; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->name; /* l_uintptr_t */ iarg[2] = p->namelen; /* l_int */ *n_args = 3; break; @@ -2603,8 +2603,8 @@ case 364: { struct linux_accept4_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ iarg[3] = p->flags; /* l_int */ *n_args = 4; break; @@ -2615,8 +2615,8 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ - iarg[4] = p->optlen; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->optlen; /* l_uintptr_t */ *n_args = 5; break; } @@ -2626,7 +2626,7 @@ iarg[0] = p->s; /* l_int */ iarg[1] = p->level; /* l_int */ iarg[2] = p->optname; /* l_int */ - iarg[3] = p->optval; /* l_uintptr_t */ + uarg[3] = (intptr_t) p->optval; /* l_uintptr_t */ iarg[4] = p->optlen; /* l_int */ *n_args = 5; break; @@ -2635,8 +2635,8 @@ case 367: { struct linux_getsockname_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -2644,8 +2644,8 @@ case 368: { struct linux_getpeername_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->addr; /* l_uintptr_t */ - iarg[2] = p->namelen; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->addr; /* l_uintptr_t */ + uarg[2] = (intptr_t) p->namelen; /* l_uintptr_t */ *n_args = 3; break; } @@ -2653,10 +2653,10 @@ case 369: { struct linux_sendto_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->len; /* l_int */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->to; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->to; /* l_uintptr_t */ iarg[5] = p->tolen; /* l_int */ *n_args = 6; break; @@ -2665,7 +2665,7 @@ case 370: { struct linux_sendmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; @@ -2674,11 +2674,11 @@ case 371: { struct linux_recvfrom_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->buf; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->buf; /* l_uintptr_t */ iarg[2] = p->len; /* l_size_t */ iarg[3] = p->flags; /* l_int */ - iarg[4] = p->from; /* l_uintptr_t */ - iarg[5] = p->fromlen; /* l_uintptr_t */ + uarg[4] = (intptr_t) p->from; /* l_uintptr_t */ + uarg[5] = (intptr_t) p->fromlen; /* l_uintptr_t */ *n_args = 6; break; } @@ -2686,7 +2686,7 @@ case 372: { struct linux_recvmsg_args *p = params; iarg[0] = p->s; /* l_int */ - iarg[1] = p->msg; /* l_uintptr_t */ + uarg[1] = (intptr_t) p->msg; /* l_uintptr_t */ iarg[2] = p->flags; /* l_int */ *n_args = 3; break; @@ -4815,7 +4815,7 @@ case 168: switch(ndx) { case 0: - p = "userland struct pollfd *"; + p = "userland struct pollfd*"; break; case 1: p = "unsigned int"; Index: sys/kern/Makefile =================================================================== --- sys/kern/Makefile +++ sys/kern/Makefile @@ -13,6 +13,6 @@ ../sys/sysproto.h init_sysent.c syscalls.c systrace_args.c ../sys/syscall.h \ -../sys/syscall.mk ../sys/sysproto.h: makesyscalls.sh syscalls.master \ +../sys/syscall.mk ../sys/sysproto.h: ../tools/makesyscalls.lua syscalls.master \ capabilities.conf - sh makesyscalls.sh syscalls.master + ${LUA} ../tools/makesyscalls.lua syscalls.master Index: sys/kern/init_sysent.c =================================================================== --- sys/kern/init_sysent.c +++ sys/kern/init_sysent.c @@ -168,7 +168,7 @@ { AS(gettimeofday_args), (sy_call_t *)sys_gettimeofday, AUE_GETTIMEOFDAY, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 116 = gettimeofday */ { AS(getrusage_args), (sy_call_t *)sys_getrusage, AUE_GETRUSAGE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 117 = getrusage */ { AS(getsockopt_args), (sy_call_t *)sys_getsockopt, AUE_GETSOCKOPT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 118 = getsockopt */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 119 = resuba */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 119 = resuba (BSD/OS 2.x) */ { AS(readv_args), (sy_call_t *)sys_readv, AUE_READV, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 120 = readv */ { AS(writev_args), (sy_call_t *)sys_writev, AUE_WRITEV, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 121 = writev */ { AS(settimeofday_args), (sy_call_t *)sys_settimeofday, AUE_SETTIMEOFDAY, NULL, 0, 0, 0, SY_THR_STATIC }, /* 122 = settimeofday */ @@ -200,9 +200,9 @@ { AS(quotactl_args), (sy_call_t *)sys_quotactl, AUE_QUOTACTL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 148 = quotactl */ { compat(0,quota), AUE_O_QUOTA, NULL, 0, 0, 0, SY_THR_STATIC }, /* 149 = old quota */ { compat(AS(getsockname_args),getsockname), AUE_GETSOCKNAME, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 150 = old getsockname */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 151 = sem_lock */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 152 = sem_wakeup */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 153 = asyncdaemon */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 151 = sem_lock (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 152 = sem_wakeup (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 153 = asyncdaemon (BSD/OS 2.x) */ { AS(nlm_syscall_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 154 = nlm_syscall */ { AS(nfssvc_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 155 = nfssvc */ { compat(AS(ogetdirentries_args),getdirentries), AUE_GETDIRENTRIES, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 156 = old getdirentries */ @@ -226,9 +226,9 @@ { compat6(AS(freebsd6_pwrite_args),pwrite), AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 174 = freebsd6 pwrite */ { AS(setfib_args), (sy_call_t *)sys_setfib, AUE_SETFIB, NULL, 0, 0, 0, SY_THR_STATIC }, /* 175 = setfib */ { AS(ntp_adjtime_args), (sy_call_t *)sys_ntp_adjtime, AUE_NTP_ADJTIME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 176 = ntp_adjtime */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 177 = sfork */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 178 = getdescriptor */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 179 = setdescriptor */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 177 = sfork (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 178 = getdescriptor (BSD/OS 2.x) */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 179 = setdescriptor (BSD/OS 2.x) */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 180 = nosys */ { AS(setgid_args), (sy_call_t *)sys_setgid, AUE_SETGID, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 181 = setgid */ { AS(setegid_args), (sy_call_t *)sys_setegid, AUE_SETEGID, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 182 = setegid */ Index: sys/kern/syscalls.c =================================================================== --- sys/kern/syscalls.c +++ sys/kern/syscalls.c @@ -125,7 +125,7 @@ "gettimeofday", /* 116 = gettimeofday */ "getrusage", /* 117 = getrusage */ "getsockopt", /* 118 = getsockopt */ - "#119", /* 119 = resuba */ + "#119", /* 119 = resuba (BSD/OS 2.x) */ "readv", /* 120 = readv */ "writev", /* 121 = writev */ "settimeofday", /* 122 = settimeofday */ @@ -157,9 +157,9 @@ "quotactl", /* 148 = quotactl */ "compat.quota", /* 149 = old quota */ "compat.getsockname", /* 150 = old getsockname */ - "#151", /* 151 = sem_lock */ - "#152", /* 152 = sem_wakeup */ - "#153", /* 153 = asyncdaemon */ + "#151", /* 151 = sem_lock (BSD/OS 2.x) */ + "#152", /* 152 = sem_wakeup (BSD/OS 2.x) */ + "#153", /* 153 = asyncdaemon (BSD/OS 2.x) */ "nlm_syscall", /* 154 = nlm_syscall */ "nfssvc", /* 155 = nfssvc */ "compat.getdirentries", /* 156 = old getdirentries */ @@ -183,9 +183,9 @@ "compat6.pwrite", /* 174 = freebsd6 pwrite */ "setfib", /* 175 = setfib */ "ntp_adjtime", /* 176 = ntp_adjtime */ - "#177", /* 177 = sfork */ - "#178", /* 178 = getdescriptor */ - "#179", /* 179 = setdescriptor */ + "#177", /* 177 = sfork (BSD/OS 2.x) */ + "#178", /* 178 = getdescriptor (BSD/OS 2.x) */ + "#179", /* 179 = setdescriptor (BSD/OS 2.x) */ "#180", /* 180 = nosys */ "setgid", /* 181 = setgid */ "setegid", /* 182 = setegid */ Index: sys/kern/systrace_args.c =================================================================== --- sys/kern/systrace_args.c +++ sys/kern/systrace_args.c @@ -1314,7 +1314,7 @@ case 257: { struct lio_listio_args *p = params; iarg[0] = p->mode; /* int */ - uarg[1] = (intptr_t) p->acb_list; /* struct aiocb *const * */ + uarg[1] = (intptr_t) p->acb_list; /* struct aiocb* const * */ iarg[2] = p->nent; /* int */ uarg[3] = (intptr_t) p->sig; /* struct sigevent * */ *n_args = 4; @@ -1375,7 +1375,7 @@ case 301: { struct modstat_args *p = params; iarg[0] = p->modid; /* int */ - uarg[1] = (intptr_t) p->stat; /* struct module_stat * */ + uarg[1] = (intptr_t) p->stat; /* struct module_stat* */ *n_args = 2; break; } @@ -1471,7 +1471,7 @@ /* aio_suspend */ case 315: { struct aio_suspend_args *p = params; - uarg[0] = (intptr_t) p->aiocbp; /* struct aiocb *const * */ + uarg[0] = (intptr_t) p->aiocbp; /* struct aiocb * const * */ iarg[1] = p->nent; /* int */ uarg[2] = (intptr_t) p->timeout; /* const struct timespec * */ *n_args = 3; @@ -5410,7 +5410,7 @@ p = "int"; break; case 1: - p = "userland struct aiocb *const *"; + p = "userland struct aiocb* const *"; break; case 2: p = "int"; @@ -5516,7 +5516,7 @@ p = "int"; break; case 1: - p = "userland struct module_stat *"; + p = "userland struct module_stat*"; break; default: break; @@ -5661,7 +5661,7 @@ case 315: switch(ndx) { case 0: - p = "userland struct aiocb *const *"; + p = "userland struct aiocb * const *"; break; case 1: p = "int"; Index: sys/sys/sysproto.h =================================================================== --- sys/sys/sysproto.h +++ sys/sys/sysproto.h @@ -710,7 +710,7 @@ }; struct lio_listio_args { char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)]; - char acb_list_l_[PADL_(struct aiocb *const *)]; struct aiocb *const * acb_list; char acb_list_r_[PADR_(struct aiocb *const *)]; + char acb_list_l_[PADL_(struct aiocb* const *)]; struct aiocb* const * acb_list; char acb_list_r_[PADR_(struct aiocb* const *)]; char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)]; char sig_l_[PADL_(struct sigevent *)]; struct sigevent * sig; char sig_r_[PADR_(struct sigevent *)]; }; @@ -743,7 +743,7 @@ }; struct modstat_args { char modid_l_[PADL_(int)]; int modid; char modid_r_[PADR_(int)]; - char stat_l_[PADL_(struct module_stat *)]; struct module_stat * stat; char stat_r_[PADR_(struct module_stat *)]; + char stat_l_[PADL_(struct module_stat*)]; struct module_stat* stat; char stat_r_[PADR_(struct module_stat*)]; }; struct modfnext_args { char modid_l_[PADL_(int)]; int modid; char modid_r_[PADR_(int)]; @@ -787,7 +787,7 @@ char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)]; }; struct aio_suspend_args { - char aiocbp_l_[PADL_(struct aiocb *const *)]; struct aiocb *const * aiocbp; char aiocbp_r_[PADR_(struct aiocb *const *)]; + char aiocbp_l_[PADL_(struct aiocb * const *)]; struct aiocb * const * aiocbp; char aiocbp_r_[PADR_(struct aiocb * const *)]; char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)]; char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)]; }; @@ -2487,7 +2487,7 @@ }; struct freebsd6_lio_listio_args { char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)]; - char acb_list_l_[PADL_(struct oaiocb *const *)]; struct oaiocb *const * acb_list; char acb_list_r_[PADR_(struct oaiocb *const *)]; + char acb_list_l_[PADL_(struct oaiocb * const *)]; struct oaiocb * const * acb_list; char acb_list_r_[PADR_(struct oaiocb * const *)]; char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)]; char sig_l_[PADL_(struct osigevent *)]; struct osigevent * sig; char sig_r_[PADR_(struct osigevent *)]; }; Index: sys/tools/makesyscalls.lua =================================================================== --- /dev/null +++ sys/tools/makesyscalls.lua @@ -0,0 +1,1060 @@ +local maxsyscall = 0 +local generated_tag = "@" .. "generated" + +-- Default configuration; any of these may get replaced by a configuration file +-- optionally specified. +local config = { + os_id_keyword = "FreeBSD", + abi_func_prefix = "", + sysnames = "syscalls.c", + sysproto = "../sys/sysproto.h", + sysproto_h = "_SYS_SYSPROTO_H_", + syshdr = "../sys/syscall.h", + sysmk = "../sys/syscall.mk", + syssw = "init_sysent.c", + syscallprefix = "SYS_", + switchname = "sysent", + namesname = "syscallnames", + systrace = "systrace_args.c", + capabilities_conf = "capabilities.conf", + capenabled = {}, + mincompat = 0, + abi_flags = "", + abi_flags_mask = 0, + ptr_intptr_t_cast = "intptr_t", +} + +local config_files_needed = { + "sysnames", + "syshdr", + "sysmk", + "syssw", + "systrace", +} + +local config_modified = {} + +-- This perhaps sucks for debugging since we can't get them to stick around +-- after script execution is complete. +local files = { + sysaue = io.tmpfile(), + sysdcl = io.tmpfile(), + syscompat = io.tmpfile(), + syscompatdcl = io.tmpfile(), + sysent = io.tmpfile(), + sysinc = io.tmpfile(), + sysarg = io.tmpfile(), + sysprotoend = io.tmpfile(), + systrace = io.tmpfile(), + systracetmp = io.tmpfile(), + systraceret = io.tmpfile(), +} + +local known_abi_flags = { + long_size = 0x00000001, + time_t_size = 0x00000002, + pointer_args = 0x00000004, + pointer_size = 0x00000008, +} + +local known_flags = { + STD = 0x00000001, + OBSOL = 0x00000002, + UNIMPL = 0x00000004, + NODEF = 0x00000008, + NOARGS = 0x00000010, + NOPROTO = 0x00000020, + NOSTD = 0x00000040, + NOTSTATIC = 0x00000080, + + -- Compat flags start from here. We have plenty of space. +} + +-- All compat_options 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_options = { + { + definition = "COMPAT_43", + compatlevel = 3, + flag = "COMPAT", + prefix = "o", + descr = "old", + }, + { stdcompat = "FREEBSD4" }, + { stdcompat = "FREEBSD6" }, + { stdcompat = "FREEBSD7" }, + { stdcompat = "FREEBSD10" }, + { stdcompat = "FREEBSD11" }, +} + +-- 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 commentExpr = "#.*" + local lineExpr = "([%w%p]+)%s*=%s*\"?([^\"]+)\"?" + + if file == nil then + return nil, "No file given" + end + + local fh = io.open(file) + if fh == nil then + return nil, "Could not open file" + end + + for nextline in fh:lines() do + -- Strip any comments + nextline = nextline:gsub(commentExpr, "") + -- Parse it into key, value pairs + key, value = nextline:match(lineExpr) + if key ~= nil and value ~= nil then + cfg[key] = value + end + end + + 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 + io.stderr:write("Failed to open " .. file) + os.exit(1) + end + return {} + end + + for nextline in fh:lines() do + -- Strip any comments + nextline = nextline:gsub(commentExpr, "") + if nextline ~= "" then + capentries[nextline] = true + end + end + + io.close(fh) + return capentries +end + +local function process_compat() + local nval = 0 + for k, v in pairs(known_flags) do + if v > nval then + nval = v + end + end + + nval = nval << 1 + for k, 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 + + tmpname = "sys" .. v["flag"]:lower() + 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 + io.stderr:write("Unknown abi_flag: " .. txtflag) + os.exit(1) + end + + mask = mask | known_abi_flags[txtflag] + end + + config["abi_flags_mask"] = mask +end + +local function abi_changes(name) + if known_abi_flags[name] == nil then + io.stderr:write("abi_changes: unknown flag: " .. name) + os.exit(1) + end + + return config["abi_flags_mask"] & known_abi_flags[name] ~= 0 +end + +local function strip_abi_prefix(funcname) + local abiprefix = config["abi_func_prefix"] + local stripped_name + 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] + fh:seek("set") + return fh:read("a") +end + +local function write_line(tmpfile, line) + if files[tmpfile] == nil then + print("Not found: " .. tmpfile) + return + end + files[tmpfile]:write(line) +end + +local function write_line_pfile(tmppat, line) + for k, v in pairs(files) do + if k:match(tmppat) ~= nil then + files[k]:write(line) + end + end +end + +local function trim(s) + if s == nil then + return nil + end + return s:gsub("^%s*([^%s])", "%1"):gsub("([^%s])%s+$", "%1") +end + +local function isptrtype(type) + return type:find("*") or type:find("caddr_t") or type:find("intptr_t") +end + +local process_syscall_def + +-- These patterns are processed in order on any line that isn't empty. +local pattern_table = { + { + pattern = "%s*$" .. config['os_id_keyword'], + process = function(_, _) + -- Ignore... ID tag + end, + }, + { + dump_prevline = true, + pattern = "^#%s*include", + process = function(prevline, line) + line = line .. "\n" + write_line('sysinc', line) + end, + }, + { + dump_prevline = true, + pattern = "^#", + process = function(prevline, line) + 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, + }, + { + -- Buffer anything else + pattern = ".+", + process = function(prevline, line) + 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(prevline, nextline) + 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(prevline, nextline) + end + end + + io.stderr:write("Failed to handle: " .. nextline) + os.exit(1) + end + + local pattern, handler, prevline, dump + for nextline in fh:lines() do + -- Strip any comments + nextline = nextline:gsub(commentExpr, "") + if nextline ~= "" then + prevline = do_match(prevline, nextline) + end + end + + -- Dump any remainder + if prevline ~= nil and prevline:find("^[0-9]") then + process_syscall_def(prevline) + end + + 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 + io.stderr:write("Checking for unknown flag " .. v) + os.exit(1) + 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 align_sysent_comment(col) + write_line("sysent", "\t") + col = col + 8 - col % 8 + while col < 56 do + write_line("sysent", "\t") + col = col + 8 + end +end + +local function strip_arg_annotations(arg) + arg = arg:gsub("_In[^ ]*[_)] ?", "") + arg = arg:gsub("_Out[^ ]*[_)] ?", "") + return trim(arg) +end + +local function check_abi_changes(arg) + return (abi_changes("long_size") and arg:find("_Contains[a-z_]*_long_")) or + (abi_changes("pointer_size") and arg:find("_Contains[a-z_]*_ptr_")) or + (abi_changes("time_t_size") and arg:find("_Contains[a-z_]*_timet_/")) +end + +local function process_args(sysnum, args) + local funcargs = {} + + for arg in args:gmatch("([^,]+)") do + local abi_change = (not isptrtype(arg)) or check_abi_changes(arg) + + arg = strip_arg_annotations(arg) + + local argname = arg:match("([^* ]+)$") + + -- argtype is... everything else. + argtype = trim(arg:gsub(argname .. "$", "")) + + if argtype == "" and argname == "void" then + goto out + end + + funcargs[#funcargs + 1] = { + type = argtype, + name = argname, + } + end + + ::out:: + return funcargs +end + +local function handle_noncompat(sysnum, thr_flag, allflags, flags, sysflags, rettype, auditev, syscallret, funcname, funcalias, funcargs, argalias) + local argssize + + if #funcargs > 0 or flags & known_flags["NODEF"] ~= 0 then + argssize = "AS(" .. argalias .. ")" + else + argssize = "0" + end + write_line("systrace", string.format("\t/* %s */\n\tcase %d: {\n", funcname, sysnum)) + write_line("systracetmp", string.format("\t/* %s */\n\tcase %d:\n", funcname, sysnum)) + write_line("systraceret", string.format("\t/* %s */\n\tcase %d:\n", funcname, sysnum)) + + if #funcargs > 0 then + write_line("systracetmp", "\t\tswitch(ndx) {\n") + write_line("systrace", string.format("\t\tstruct %s *p = params;\n", argalias)) + + local argtype, argname + for idx, arg in ipairs(funcargs) do + argtype = arg["type"] + argname = arg["name"] + + argtype = argtype:gsub("__restrict$", "") + -- Pointer arg? + if argtype:find("*") then + write_line("systracetmp", + string.format("\t\tcase %d:\n\t\t\tp = \"userland %s\";\n\t\t\tbreak;\n", idx - 1, argtype)) + else + write_line("systracetmp", + string.format("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", idx - 1, argtype)) + end + + if isptrtype(argtype) then + write_line("systrace", + string.format("\t\tuarg[%d] = (%s) p->%s; /* %s */\n", + idx - 1, config["ptr_intptr_t_cast"], argname, + argtype)) + elseif argtype == "union l_semun" then + write_line("systrace", + string.format("\t\tuarg[%d] = p->%s.buf; /* %s */\n", + idx - 1, argname, argtype)) + elseif argtype:sub(1,1) == "u" or argtype == "size_t" then + write_line("systrace", + string.format("\t\tuarg[%d] = p->%s; /* %s */\n", + idx - 1, argname, argtype)) + else + write_line("systrace", + string.format("\t\tiarg[%d] = p->%s; /* %s */\n", + idx - 1, argname, argtype)) + end + end + + write_line("systracetmp", "\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") + + write_line("systraceret", "\t\tif (ndx == 0 || ndx == 1)\n") + write_line("systraceret", string.format("\t\t\tp = \"%s\";\n", syscallret)) + write_line("systraceret", "\t\tbreak;\n") + end + write_line("systrace", string.format("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", #funcargs)) + 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 k, v in ipairs(funcargs) do + local argname, argtype = v["name"], v["type"] + write_line("sysarg", string.format("\tchar %s_l_[PADL_(%s)]; %s %s; char %s_r_[PADR_(%s)];\n", + argname, argtype, + argtype, argname, + argname, argtype)) + end + write_line("sysarg", "};\n") + else + write_line("sysarg", string.format("struct %s {\n\tregister_t dummy;\n};\n", + argalias)) + end + end + + local protoflags = get_mask({"NOPROTO", "NODEF"}) + if flags & protoflags == 0 then + if funcname == "nosys" or funcname == "lkmnosys" or + funcname == "sysarch" or funcname:find("^freebsd") or + funcname:find("^linux") or + funcname:find("^cloudabi") then + write_line("sysdcl", string.format("%s\t%s(struct thread *, struct %s *)", + rettype, funcname, argalias)) + else + write_line("sysdcl", string.format("%s\tsys_%s(struct thread *, struct %s *)", + rettype, funcname, argalias)) + end + write_line("sysdcl", ";\n") + write_line("sysaue", string.format("#define\t%sAUE_%s\t%s\n", + config['syscallprefix'], funcalias, auditev)) + end + + write_line("sysent", string.format("\t{ %s, (sy_call_t *)", argssize)) + local column = 8 + 2 + #argssize + 15 + + if flags & known_flags["NOSTD"] ~= 0 then + write_line("sysent", string.format("lkmressys, AUE_NULL, NULL, 0, 0, %s, SY_THR_ABSENT },", + sysflags)) + column = column + #"lkmressys" + #"AUE_NULL" + 3 + else + if funcname == "nosys" or funcname == "lkmnosys" or + funcname == "sysarch" or funcname:find("^freebsd") or + funcname:find("^linux") or + funcname:find("^cloudabi") then + write_line("sysent", string.format("%s, %s, NULL, 0, 0, %s, %s },", + funcname, auditev, sysflags, thr_flag)) + column = column + #funcname + #auditev + #sysflags + 3 + else + write_line("sysent", string.format("sys_%s, %s, NULL, 0, 0, %s, %s },", + funcname, auditev, sysflags, thr_flag)) + column = column + #funcname + #auditev + #sysflags + 3 + 4 + end + end + + align_sysent_comment(column) + write_line("sysent", string.format("/* %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)) + end +end + +local function handle_obsol(sysnum, funcname, comment) + write_line("sysent", "\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },") + align_sysent_comment(34) + + write_line("sysent", string.format("/* %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, allflags, flags, sysflags, rettype, auditev, syscallret, 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 = v["prefix"] .. strip_abi_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\tregister_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{ %s, (sy_call_t *)%s, %s, NULL, 0, 0, 0, SY_THR_ABSENT },", + "0", "lkmressys", "AUE_NULL")) + align_sysent_comment(8 + 2 + #"0" + 15 + #"lkmressys" + + #"AUE_NULL" + 3) + else + write_line("sysent", string.format("\t{ %s(%s,%s), %s, NULL, 0, 0, %s, %s },", + wrap, argssize, funcname, auditev, sysflags, thr_flag)) + align_sysent_comment(8 + 9 + #argssize + 1 + #funcname + + #auditev + #sysflags + 4) + end + + write_line("sysent", string.format("/* %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, funcname, comment) + if sysstart == nil and sysend == nil then + sysstart = tonumber(sysnum) + sysend = tonumber(sysnum) + end + + comment = trim(comment) + sysnum = sysstart + while sysnum <= sysend do + write_line("sysent", string.format( + "\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },\t\t\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 + +process_syscall_def = function(line) + local sysnum, sysstart, sysend, aue, flags, funcname, allflags, sysflags + local funcprefix, thr_flag + flags = 0 + thr_flag = "SY_THR_STATIC" + funcprefix = "" + + -- Parse out the interesting information first + sysnum, auditev, allflags = line:match("^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s*") + + if sysnum == nil or auditev == nil or allflags == nil then + -- XXX TODO: Better? + io.stderr:write("Completely malformed: " .. line) + os.exit(1) + end + + if sysnum:find("-") then + sysstart, sysend = sysnum:match("^([%d]+)-([%d]+)$") + if sysstart == nil or sysend == nil then + io.stderr:write("Malformed range: " .. sysnum) + os.exit(1) + end + sysnum = nil + sysstart = tonumber(sysstart) + sysend = tonumber(sysend) + end + + -- Split flags + for flag in allflags:gmatch("([^|]+)") do + flags = flags | known_flags[flag] + end + + if (flags & known_flags["UNIMPL"]) == 0 and sysnum == nil then + io.stderr:write("Range only allowed with UNIMPL: " .. line) + os.exit(1) + 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 + io.stderr:write("Malformed, no closing brace: " .. line) + os.exit(1) + 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 + io.stderr:write("Malformed bits: " .. line) + os.exit(1) + 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]+)")) + alt = alt:gsub("^([^%s]+)[%s]*", "") + end + -- Do we even need it? + if flags & get_mask({"OBSOL", "UNIMPL"}) ~= 0 then + if funcname ~= nil then + funcomment = trim(funcname .. " " .. alt) + else + funcomment = trim(alt) + end + alt = nil + goto skipalt + end + + if alt ~= nil and alt ~= "" then + funcalias, argalias, rettype = alt:match("^([^%s]+)%s+([^%s]+)%s+([^%s]+)") + funcalias = trim(funcalias) + if funcalias == nil or argalias == nil or rettype == nil then + io.stderr:write("Malformed alt: " .. line) + os.exit(1) + 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 + io.stderr:write("Not a signature? " .. line) + os.exit(1) + end + args = line:match("^[^(]+%((.+)%)[^)]*$") + end + + ::skipalt:: + + if funcname == nil then + funcname = funcalias + end + + funcname = trim(funcname) + + 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 config["capenabled"][funcname] ~= nil or + config["capenabled"][stripped_name] ~= nil then + sysflags = "SYF_CAPENABLED" + end + + local funcargs = {} + if args ~= nil then + funcargs = process_args(sysnum, args) + end + + if abi_changes("pointer_args") then + for _, v in ipairs(funcargs) do + if isptrtype(v["type"]) then + -- argalias should be: + -- COMPAT_PREFIX + ABI Prefix + funcname + argalias = config['abi_func_prefix'] .. + argalias + funcalias = config['abi_func_prefix'] .. + funcname + goto ptrfound + end + end + ::ptrfound:: + 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:: + end + + local ncompatflags = get_mask({"STD", "NODEF", "NOARGS", "NOPROTO", "NOSTD"}) + local compatflags = get_mask_pat("COMPAT.*") + -- Now try compat... + if flags & compatflags ~= 0 then + if flags & known_flags['STD'] ~= 0 then + io.stderr:write("Incompatible COMPAT/STD: " .. line) + os.exit(1) + end + handle_compat(sysnum, thr_flag, allflags, flags, sysflags, rettype, auditev, syscallret, funcname, funcalias, funcargs, argalias) + elseif flags & ncompatflags ~= 0 then + handle_noncompat(sysnum, thr_flag, allflags, flags, sysflags, rettype, auditev, syscallret, funcname, funcalias, funcargs, argalias) + elseif flags & known_flags["OBSOL"] ~= 0 then + handle_obsol(sysnum, funcname, funcomment) + elseif flags & known_flags["UNIMPL"] ~= 0 then + handle_unimpl(sysnum, sysstart, sysend, funcname, funcomment) + if sysend ~= nil and sysend > maxsyscall then + maxsyscall = sysend + end + else + io.stderr:write("Bad flags? " .. line) + os.exit(1) + end + + if sysnum ~= nil and tonumber(sysnum) > maxsyscall then + maxsyscall = tonumber(sysnum) + end +end + +-- Entry point + +if #arg < 1 or #arg > 2 then + io.stderr:write("usage: " .. arg[0] .. " input-file \n") + os.exit(1) +end + +sysfile=arg[1] +configfile=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 + res, msg = process_config(configfile) + + if res == nil then + -- Error... handle? + print(msg) + os.exit(1) + end + + for k, v in pairs(res) do + if v ~= config[k] then + config[k] = v + config_modified[k] = true + end + end +end + +-- We ignore errors here if we're relying on the default configuration. +config["capenabled"] = grab_capenabled(config['capabilities_conf'], + config_modified[k] == nil) +process_compat() +process_abi_flags() + +for _, v in ipairs(config_files_needed) do + files[v] = io.open(config[v], "w+") +end + +-- Write out all of the preamble bits +write_line("sysent", "\n/* The casts are bogus but will do for now. */\n") +write_line("sysent", string.format("struct sysent %s[] = {\n", config['switchname'])) + +write_line("syssw", "/*\n * System call switch table.\n *\n") +write_line("syssw", " * DO NOT EDIT-- this file is automatically " .. generated_tag .. ".\n") +write_line("syssw", string.format(" * $%s$\n", config['os_id_keyword'])) +write_line("syssw", " */\n\n") + +write_line("sysarg", "/*\n * System call prototypes.\n *\n") +write_line("sysarg", " * DO NOT EDIT-- this file is automatically " .. generated_tag .. ".\n") +write_line("sysarg", string.format(" * $%s$\n", config['os_id_keyword'])) +write_line("sysarg", " */\n\n") +write_line("sysarg", string.format("#ifndef %s\n", config['sysproto_h'])) +write_line("sysarg", string.format("#define\t%s\n\n", config['sysproto_h'])) +write_line("sysarg", "#include \n") +write_line("sysarg", "#include \n") +write_line("sysarg", "#include \n") +write_line("sysarg", "#include \n") +write_line("sysarg", "#include \n") +write_line("sysarg", "#include \n") +write_line("sysarg", "#include \n") +write_line("sysarg", "#include \n\n") +write_line("sysarg", "#include \n\n") +write_line("sysarg", "struct proc;\n\n") +write_line("sysarg", "struct thread;\n\n") +write_line("sysarg", "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n") +write_line("sysarg", "\t\t0 : sizeof(register_t) - sizeof(t))\n\n") +write_line("sysarg", "#if BYTE_ORDER == LITTLE_ENDIAN\n") +write_line("sysarg", "#define\tPADL_(t)\t0\n") +write_line("sysarg", "#define\tPADR_(t)\tPAD_(t)\n") +write_line("sysarg", "#else\n") +write_line("sysarg", "#define\tPADL_(t)\tPAD_(t)\n") +write_line("sysarg", "#define\tPADR_(t)\t0\n") +write_line("sysarg", "#endif\n\n") + +for _, v in pairs(compat_options) do + write_line(v["tmp"], string.format("\n#ifdef %s\n\n", v["definition"])) +end + +write_line("sysnames", "/*\n * System call names.\n *\n") +write_line("sysnames", " * DO NOT EDIT-- this file is automatically " .. generated_tag .. ".\n") +write_line("sysnames", string.format(" * $%s$\n", config['os_id_keyword'])) +write_line("sysnames", " */\n\n") +write_line("sysnames", string.format ("const char *%s[] = {\n", config['namesname'])) + +write_line("syshdr", "/*\n * System call numbers.\n *\n") +write_line("syshdr", " * DO NOT EDIT-- this file is automatically " .. generated_tag .. ".\n") +write_line("syshdr", string.format(" * $%s$\n", config['os_id_keyword'])) +write_line("syshdr", " */\n\n") + +write_line("sysmk", "# FreeBSD system call object files.\n") +write_line("sysmk", "# DO NOT EDIT-- this file is automatically " .. generated_tag .. ".\n") +write_line("sysmk", string.format("# $%s$\n", config['os_id_keyword'])) +write_line("sysmk", "MIASM = ") + +write_line("systrace", "/*\n * System call argument to DTrace register array converstion.\n *\n") +write_line("systrace", " * DO NOT EDIT-- this file is automatically " .. generated_tag .. ".\n") +write_line("systrace", string.format(" * $%s$\n", config['os_id_keyword'])) +write_line("systrace", " * This file is part of the DTrace syscall provider.\n */\n\n") +write_line("systrace", "static void\nsystrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)\n{\n") +write_line("systrace", "\tint64_t *iarg = (int64_t *) uarg;\n") +write_line("systrace", "\tswitch (sysnum) {\n") + +write_line("systracetmp", "static void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n") +write_line("systracetmp", "\tswitch (sysnum) {\n") + +write_line("systraceret", "static void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n") +write_line("systraceret", "\tswitch (sysnum) {\n") + +-- 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(register_t))\n") + +for _, v in pairs(compat_options) do + if v["count"] > 0 then + write_line("sysinc", string.format("\n#ifdef %s\n", v["definition"])) + write_line("sysinc", string.format("#define %s(n, name) n, (sy_call_t *)__CONCAT(%s,name)\n", + v["flag"]:lower(), v["prefix"])) + write_line("sysinc", "#else\n") + write_line("sysinc", string.format("#define %s(n, name) 0, (sy_call_t *)nosys\n", + v["flag"]:lower())) + write_line("sysinc", "#endif\n") + end + + write_line(v["dcltmp"], string.format("\n#endif /* %s */\n\n", + v["definition"])) +end + +write_line("sysprotoend", "\n#undef PAD_\n") +write_line("sysprotoend", "#undef PADL_\n") +write_line("sysprotoend", "#undef PADR_\n") +write_line("sysprotoend", string.format("\n#endif /* !%s */\n", + config["sysproto_h"])) + +write_line("sysmk", "\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","\tdefault:\n\t\t*n_args = 0;\n\t\tbreak;\n\t};\n}\n") +write_line("systracetmp", "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n") +write_line("systraceret", "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n") + +-- Finish up; output +write_line("syssw", read_file("sysinc")) +write_line("syssw", read_file("sysent")) + +fh = io.open(config["sysproto"], "w+") +fh:write(read_file("sysarg")) +fh:write(read_file("sysdcl")) +for _, v in pairs(compat_options) do + fh:write(read_file(v["tmp"])) + fh:write(read_file(v["dcltmp"])) +end +fh:write(read_file("sysaue")) +fh:write(read_file("sysprotoend")) +fh:close() + +write_line("systrace", read_file("systracetmp")) +write_line("systrace", read_file("systraceret")) + +for _, v in ipairs(config_files_needed) do + files[v]:close() +end