From 08b7160aa773ecc3307eefc98e829cd10daa4b69 Mon Sep 17 00:00:00 2001 From: P1umer <1226063714@qq.com> Date: Wed, 20 Jul 2022 18:38:41 +0800 Subject: all: add freebsd/riscv64 support --- Makefile | 1 + pkg/compiler/const_file.go | 2 ++ sys/freebsd/aio.txt.const | 2 +- sys/freebsd/amd64.txt.const | 2 +- sys/freebsd/capsicum.txt.const | 2 +- sys/freebsd/cpuset.txt.const | 2 +- sys/freebsd/dev_bpf.txt.const | 2 +- sys/freebsd/dev_crypto.txt.const | 2 +- sys/freebsd/dev_kbd.txt.const | 2 +- sys/freebsd/dev_md.txt.const | 2 +- sys/freebsd/dev_smbus.txt.const | 2 +- sys/freebsd/efidev.txt.const | 2 +- sys/freebsd/evdev.txt.const | 2 +- sys/freebsd/extattr.txt.const | 2 +- sys/freebsd/fh.txt.const | 2 +- sys/freebsd/filemon.txt.const | 2 +- sys/freebsd/ipc.txt.const | 2 +- sys/freebsd/kmq.txt.const | 2 +- sys/freebsd/kqueue.txt.const | 2 +- sys/freebsd/ksem.txt.const | 2 +- sys/freebsd/ktimer.txt.const | 4 ++-- sys/freebsd/ktrace.txt.const | 2 +- sys/freebsd/pf.txt.const | 2 +- sys/freebsd/posix_fs.txt.const | 2 +- sys/freebsd/posix_mm.txt.const | 2 +- sys/freebsd/procctl.txt.const | 2 +- sys/freebsd/socket.txt.const | 2 +- sys/freebsd/socket_inet.txt.const | 2 +- sys/freebsd/socket_inet6.txt.const | 2 +- sys/freebsd/socket_inet_icmp.txt.const | 2 +- sys/freebsd/socket_inet_sctp.txt.const | 2 +- sys/freebsd/socket_inet_tcp.txt.const | 2 +- sys/freebsd/socket_inet_udp.txt.const | 2 +- sys/freebsd/socket_inet_udplite.txt.const | 2 +- sys/freebsd/socket_unix.txt.const | 2 +- sys/freebsd/sys.txt.const | 2 +- sys/freebsd/vnet.txt.const | 2 +- sys/targets/targets.go | 11 +++++++++++ vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go | 1 - 39 files changed, 50 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index b5d88fdee..a6c67660d 100644 --- a/Makefile +++ b/Makefile @@ -333,6 +333,7 @@ presubmit_arch_freebsd: descriptions env HOSTOS=freebsd HOSTARCH=amd64 $(MAKE) host env TARGETOS=freebsd TARGETARCH=amd64 $(MAKE) target env TARGETOS=freebsd TARGETARCH=386 $(MAKE) target + env TARGETOS=freebsd TARGETARCH=riscv64 $(MAKE) target presubmit_arch_netbsd: descriptions env HOSTOS=netbsd HOSTARCH=amd64 $(MAKE) host diff --git a/pkg/compiler/const_file.go b/pkg/compiler/const_file.go index 8f4bfe390..6755fffc8 100644 --- a/pkg/compiler/const_file.go +++ b/pkg/compiler/const_file.go @@ -90,6 +90,8 @@ func (cf *ConstFile) Serialize() []byte { for arch := range cf.arches { arches = append(arches, arch) } + arches = append(arches, "riscv64") + sort.Strings(arches) var consts []constVal for _, cv := range cf.m { diff --git a/sys/freebsd/aio.txt.const b/sys/freebsd/aio.txt.const index e7309af56..48605d05b 100644 --- a/sys/freebsd/aio.txt.const +++ b/sys/freebsd/aio.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 LIO_DSYNC = 24 LIO_MLOCK = 32 LIO_NOP = 0 diff --git a/sys/freebsd/amd64.txt.const b/sys/freebsd/amd64.txt.const index 7fe7305ce..ee5b89485 100644 --- a/sys/freebsd/amd64.txt.const +++ b/sys/freebsd/amd64.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AMD64_CLEAR_PKRU = 134 AMD64_GET_FSBASE = 128 AMD64_GET_GSBASE = 130 diff --git a/sys/freebsd/capsicum.txt.const b/sys/freebsd/capsicum.txt.const index 001ed4394..69e6d1fcf 100644 --- a/sys/freebsd/capsicum.txt.const +++ b/sys/freebsd/capsicum.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 SYS___cap_rights_get = 515 SYS_cap_enter = 516 SYS_cap_fcntls_get = 537 diff --git a/sys/freebsd/cpuset.txt.const b/sys/freebsd/cpuset.txt.const index 8e3f38fb6..0363d7f33 100644 --- a/sys/freebsd/cpuset.txt.const +++ b/sys/freebsd/cpuset.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 CPU_LEVEL_CPUSET = 2 CPU_LEVEL_ROOT = 1 CPU_LEVEL_WHICH = 3 diff --git a/sys/freebsd/dev_bpf.txt.const b/sys/freebsd/dev_bpf.txt.const index 1e25b058e..5325acfdd 100644 --- a/sys/freebsd/dev_bpf.txt.const +++ b/sys/freebsd/dev_bpf.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_APPLETALK = 16 AF_ARP = 35 AF_ATM = 30 diff --git a/sys/freebsd/dev_crypto.txt.const b/sys/freebsd/dev_crypto.txt.const index fd321a97f..270143344 100644 --- a/sys/freebsd/dev_crypto.txt.const +++ b/sys/freebsd/dev_crypto.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_FDCWD = 18446744073709551516 CIOCCRYPT = 386:3223085927, amd64:3224396647 CIOCCRYPTAEAD = 386:3223872365, amd64:3225445229 diff --git a/sys/freebsd/dev_kbd.txt.const b/sys/freebsd/dev_kbd.txt.const index 5c599ed99..bd7c73732 100644 --- a/sys/freebsd/dev_kbd.txt.const +++ b/sys/freebsd/dev_kbd.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 ALK = 130 ASH = 131 AT_FDCWD = 18446744073709551516 diff --git a/sys/freebsd/dev_md.txt.const b/sys/freebsd/dev_md.txt.const index 721906fa5..db87f40da 100644 --- a/sys/freebsd/dev_md.txt.const +++ b/sys/freebsd/dev_md.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_FDCWD = 18446744073709551516 MDIOCATTACH = 386:3249827072, amd64:3250613504 MDIOCDETACH = 386:3249827073, amd64:3250613505 diff --git a/sys/freebsd/dev_smbus.txt.const b/sys/freebsd/dev_smbus.txt.const index 21195acae..ad654791b 100644 --- a/sys/freebsd/dev_smbus.txt.const +++ b/sys/freebsd/dev_smbus.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_FDCWD = 18446744073709551516 SMB_BREAD = 386:3223087371, amd64:3224398091 SMB_BWRITE = 386:2149345546, amd64:2150656266 diff --git a/sys/freebsd/efidev.txt.const b/sys/freebsd/efidev.txt.const index 4678a168d..3527dc8c8 100644 --- a/sys/freebsd/efidev.txt.const +++ b/sys/freebsd/efidev.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_FDCWD = 18446744073709551516 EFIIOC_GET_TIME = 1074808066 EFIIOC_SET_TIME = 2148549891 diff --git a/sys/freebsd/evdev.txt.const b/sys/freebsd/evdev.txt.const index 0cbb165ab..93fd9bbff 100644 --- a/sys/freebsd/evdev.txt.const +++ b/sys/freebsd/evdev.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_FDCWD = 18446744073709551516 EVIOCGABS_MAX = 1075332479 EVIOCGABS_MIN = 1075332416 diff --git a/sys/freebsd/extattr.txt.const b/sys/freebsd/extattr.txt.const index bf977ae5c..c798ff165 100644 --- a/sys/freebsd/extattr.txt.const +++ b/sys/freebsd/extattr.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 EXTATTR_NAMESPACE_SYSTEM = 2 EXTATTR_NAMESPACE_USER = 1 SYS_extattr_delete_fd = 373 diff --git a/sys/freebsd/fh.txt.const b/sys/freebsd/fh.txt.const index 16dd3e4a0..461b52a71 100644 --- a/sys/freebsd/fh.txt.const +++ b/sys/freebsd/fh.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_SYMLINK_NOFOLLOW = 512 MAXFIDSZ = 16 SYS_fhlink = 565 diff --git a/sys/freebsd/filemon.txt.const b/sys/freebsd/filemon.txt.const index f531a8f6d..3c12ef4f3 100644 --- a/sys/freebsd/filemon.txt.const +++ b/sys/freebsd/filemon.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_FDCWD = 18446744073709551516 FILEMON_SET_FD = 3221508865 FILEMON_SET_PID = 3221508866 diff --git a/sys/freebsd/ipc.txt.const b/sys/freebsd/ipc.txt.const index 14bc65137..03285a34b 100644 --- a/sys/freebsd/ipc.txt.const +++ b/sys/freebsd/ipc.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 FIOGSHMLPGCNF = 1076913765 FIOSSHMLPGCNF = 2150655588 GETALL = 6 diff --git a/sys/freebsd/kmq.txt.const b/sys/freebsd/kmq.txt.const index 7d8979703..aaf92761c 100644 --- a/sys/freebsd/kmq.txt.const +++ b/sys/freebsd/kmq.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 O_CREAT = 512 O_EXCL = 2048 O_NONBLOCK = 4 diff --git a/sys/freebsd/kqueue.txt.const b/sys/freebsd/kqueue.txt.const index c048e4434..622b24bf0 100644 --- a/sys/freebsd/kqueue.txt.const +++ b/sys/freebsd/kqueue.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 EVFILT_AIO = 18446744073709551613 EVFILT_EMPTY = 18446744073709551603 EVFILT_PROC = 18446744073709551611 diff --git a/sys/freebsd/ksem.txt.const b/sys/freebsd/ksem.txt.const index 898bbc416..fea4b1dfd 100644 --- a/sys/freebsd/ksem.txt.const +++ b/sys/freebsd/ksem.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 O_CREAT = 512 O_EXCL = 2048 SYS_ksem_close = 400 diff --git a/sys/freebsd/ktimer.txt.const b/sys/freebsd/ktimer.txt.const index 6615a6c8f..ec1d93a13 100644 --- a/sys/freebsd/ktimer.txt.const +++ b/sys/freebsd/ktimer.txt.const @@ -1,6 +1,6 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 -SIGEVENT_SIZE = 386:44, amd64:80 +arches = 386, amd64, riscv64 +SIGEVENT_SIZE = 386:44, amd64:80, riscv64:80 SIGEV_KEVENT = 3 SIGEV_NONE = 0 SIGEV_SIGNAL = 1 diff --git a/sys/freebsd/ktrace.txt.const b/sys/freebsd/ktrace.txt.const index a9b64de3e..7872b706e 100644 --- a/sys/freebsd/ktrace.txt.const +++ b/sys/freebsd/ktrace.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 KTRFAC_CAPFAIL = 4096 KTRFAC_CSW = 64 KTRFAC_FAULT = 8192 diff --git a/sys/freebsd/pf.txt.const b/sys/freebsd/pf.txt.const index 7d8184e1c..ca921b923 100644 --- a/sys/freebsd/pf.txt.const +++ b/sys/freebsd/pf.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_FDCWD = ??? DIOCADDADDR = 386:3294118964, amd64:3295691828 DIOCADDALTQV0 = 386:3236709421, amd64:3238020141 diff --git a/sys/freebsd/posix_fs.txt.const b/sys/freebsd/posix_fs.txt.const index 2b710cdc6..fd13b567a 100644 --- a/sys/freebsd/posix_fs.txt.const +++ b/sys/freebsd/posix_fs.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_EMPTY_PATH = 16384 AT_FDCWD = 18446744073709551516 AT_SYMLINK_NOFOLLOW = 512 diff --git a/sys/freebsd/posix_mm.txt.const b/sys/freebsd/posix_mm.txt.const index d75e892b0..22e6e8275 100644 --- a/sys/freebsd/posix_mm.txt.const +++ b/sys/freebsd/posix_mm.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 MADV_AUTOSYNC = 7 MADV_CORE = 9 MADV_DONTNEED = 4 diff --git a/sys/freebsd/procctl.txt.const b/sys/freebsd/procctl.txt.const index 9d2bf6883..1deba967f 100644 --- a/sys/freebsd/procctl.txt.const +++ b/sys/freebsd/procctl.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 PROC_ASLR_CTL = 13 PROC_ASLR_STATUS = 14 PROC_NO_NEW_PRIVS_CTL = 19 diff --git a/sys/freebsd/socket.txt.const b/sys/freebsd/socket.txt.const index ae198f82b..e78d55f03 100644 --- a/sys/freebsd/socket.txt.const +++ b/sys/freebsd/socket.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_APPLETALK = 16 AF_INET = 2 AF_INET6 = 28 diff --git a/sys/freebsd/socket_inet.txt.const b/sys/freebsd/socket_inet.txt.const index 35c98a0c7..1f756eebf 100644 --- a/sys/freebsd/socket_inet.txt.const +++ b/sys/freebsd/socket_inet.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_INET = 2 IPPROTO_IP = 0 IP_ADD_MEMBERSHIP = 12 diff --git a/sys/freebsd/socket_inet6.txt.const b/sys/freebsd/socket_inet6.txt.const index 57ba5ea08..1761d4491 100644 --- a/sys/freebsd/socket_inet6.txt.const +++ b/sys/freebsd/socket_inet6.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_INET6 = 28 IPPROTO_IPV6 = 41 IPV6_2292DSTOPTS = 23 diff --git a/sys/freebsd/socket_inet_icmp.txt.const b/sys/freebsd/socket_inet_icmp.txt.const index ec3cfbafa..a84d92b67 100644 --- a/sys/freebsd/socket_inet_icmp.txt.const +++ b/sys/freebsd/socket_inet_icmp.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_INET = 2 AF_INET6 = 28 IPPROTO_ICMP = 1 diff --git a/sys/freebsd/socket_inet_sctp.txt.const b/sys/freebsd/socket_inet_sctp.txt.const index df3dde31c..344796e80 100644 --- a/sys/freebsd/socket_inet_sctp.txt.const +++ b/sys/freebsd/socket_inet_sctp.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_INET = 2 AF_INET6 = 28 IPPROTO_SCTP = 132 diff --git a/sys/freebsd/socket_inet_tcp.txt.const b/sys/freebsd/socket_inet_tcp.txt.const index 0baadc4c9..65b609c75 100644 --- a/sys/freebsd/socket_inet_tcp.txt.const +++ b/sys/freebsd/socket_inet_tcp.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_INET = 2 AF_INET6 = 28 CC_NEWRENO_BETA = 1 diff --git a/sys/freebsd/socket_inet_udp.txt.const b/sys/freebsd/socket_inet_udp.txt.const index a179670b3..af0d93473 100644 --- a/sys/freebsd/socket_inet_udp.txt.const +++ b/sys/freebsd/socket_inet_udp.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_INET = 2 AF_INET6 = 28 IPPROTO_UDP = 17 diff --git a/sys/freebsd/socket_inet_udplite.txt.const b/sys/freebsd/socket_inet_udplite.txt.const index 8cefcca75..c71aa08a6 100644 --- a/sys/freebsd/socket_inet_udplite.txt.const +++ b/sys/freebsd/socket_inet_udplite.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_INET = 2 AF_INET6 = 28 IPPROTO_UDPLITE = 136 diff --git a/sys/freebsd/socket_unix.txt.const b/sys/freebsd/socket_unix.txt.const index 04e7d1890..040cc9d99 100644 --- a/sys/freebsd/socket_unix.txt.const +++ b/sys/freebsd/socket_unix.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AF_UNIX = 1 AF_UNSPEC = 0 CMGROUP_MAX = 16 diff --git a/sys/freebsd/sys.txt.const b/sys/freebsd/sys.txt.const index 210c81a9a..ecefff584 100644 --- a/sys/freebsd/sys.txt.const +++ b/sys/freebsd/sys.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 AT_EACCESS = 256 AT_EMPTY_PATH = 16384 AT_REMOVEDIR = 2048 diff --git a/sys/freebsd/vnet.txt.const b/sys/freebsd/vnet.txt.const index b2212b2ae..be8e131b7 100644 --- a/sys/freebsd/vnet.txt.const +++ b/sys/freebsd/vnet.txt.const @@ -1,5 +1,5 @@ # Code generated by syz-sysgen. DO NOT EDIT. -arches = 386, amd64 +arches = 386, amd64, riscv64 ARPHRD_ETHER = 1 ARPHRD_FRELAY = 15 ARPHRD_IEEE1394 = 24 diff --git a/sys/targets/targets.go b/sys/targets/targets.go index 45db59d11..24187d7d5 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -335,6 +335,17 @@ var List = map[string]map[string]*Target{ return nr == 482 || nr >= 569 }, }, + RiscV64: { + PtrSize: 8, + PageSize: 4 << 10, + LittleEndian: true, + CCompiler: "clang", + CFlags: []string{"-m64"}, + NeedSyscallDefine: func(nr uint64) bool { + // freebsd_12_shm_open, shm_open2, shm_rename, __realpathat, close_range, copy_file_range + return nr == 482 || nr >= 569 + }, + }, }, Darwin: { AMD64: { diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go index d6fd9e883..a64016f9b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go @@ -32,7 +32,6 @@ type Timeval struct { } type Time_t int64 - type Rusage struct { Utime Timeval Stime Timeval -- cgit mrf-deployment