From 7057824fae6a83b7c2a81b17be321c57d9d7d2e2 Mon Sep 17 00:00:00 2001 From: Robert Clausecker Date: Sat, 18 May 2024 17:35:20 +0200 Subject: [PATCH 1/5] host/types_freebsd.go: fix include path This makes mktypes.sh succeed on FreeBSD. For #1425 --- host/types_freebsd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/types_freebsd.go b/host/types_freebsd.go index 79154d7..16dbe31 100644 --- a/host/types_freebsd.go +++ b/host/types_freebsd.go @@ -12,7 +12,7 @@ package host #include #include #include -#include "freebsd_headers/utxdb.h" +#include "host/freebsd_headers/utxdb.h" enum { sizeofPtr = sizeof(void*), From ca182ca7b85af89f1626a57466af9b1130e36fd7 Mon Sep 17 00:00:00 2001 From: Robert Clausecker Date: Sat, 18 May 2024 17:36:08 +0200 Subject: [PATCH 2/5] add freebsd riscv64 types Generated on 15-CURRENT 5d62025d82a0. Fixes #1425. --- disk/disk_freebsd_riscv64.go | 64 ++++++++++++ host/host_freebsd_riscv64.go | 36 +++++++ process/process_freebsd_riscv64.go | 203 +++++++++++++++++++++++++++++++++++++ 3 files changed, 303 insertions(+) create mode 100644 disk/disk_freebsd_riscv64.go create mode 100644 host/host_freebsd_riscv64.go create mode 100644 process/process_freebsd_riscv64.go diff --git a/disk/disk_freebsd_riscv64.go b/disk/disk_freebsd_riscv64.go new file mode 100644 index 0000000..759389f --- /dev/null +++ b/disk/disk_freebsd_riscv64.go @@ -0,0 +1,64 @@ +//go:build freebsd && riscv64 +// +build freebsd,riscv64 + +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs disk/types_freebsd.go + +package disk + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + sizeofLongDouble = 0x8 + + devstat_NO_DATA = 0x00 + devstat_READ = 0x01 + devstat_WRITE = 0x02 + devstat_FREE = 0x03 +) + +const ( + sizeOfdevstat = 0x120 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 + _C_long_double int64 +) + +type ( + devstat struct { + Sequence0 uint32 + Allocated int32 + Start_count uint32 + End_count uint32 + Busy_from bintime + Dev_links _Ctype_struct___0 + Device_number uint32 + Device_name [16]uint8 + Unit_number int32 + Bytes [4]uint64 + Operations [4]uint64 + Duration [4]bintime + Busy_time bintime + Creation_time bintime + Block_size uint32 + Tag_types [3]uint64 + Flags uint32 + Device_type uint32 + Priority uint32 + Id *byte + Sequence1 uint32 + Pad_cgo_0 [4]byte + } + bintime struct { + Sec int64 + Frac uint64 + } +) diff --git a/host/host_freebsd_riscv64.go b/host/host_freebsd_riscv64.go new file mode 100644 index 0000000..6213391 --- /dev/null +++ b/host/host_freebsd_riscv64.go @@ -0,0 +1,36 @@ +//go:build freebsd && riscv64 +// +build freebsd,riscv64 + +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs host/types_freebsd.go + +package host + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + sizeOfUtmpx = 0xc5 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type ( + Utmp _cgopackage.Incomplete + Utmpx struct { + Type uint8 + Pad_cgo_0 [8]byte + Id [8]uint8 + Pad_cgo_1 [4]byte + User [32]uint8 + Line [16]uint8 + Host [128]uint8 + } +) diff --git a/process/process_freebsd_riscv64.go b/process/process_freebsd_riscv64.go new file mode 100644 index 0000000..4e8ff9c --- /dev/null +++ b/process/process_freebsd_riscv64.go @@ -0,0 +1,203 @@ +//go:build freebsd && riscv64 +// +build freebsd,riscv64 + +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs process/types_freebsd.go + +package process + +const ( + CTLKern = 1 + KernProc = 14 + KernProcPID = 1 + KernProcProc = 8 + KernProcPathname = 12 + KernProcArgs = 7 +) + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +const ( + sizeOfKinfoVmentry = 0x488 + sizeOfKinfoProc = 0x440 +) + +const ( + SIDL = 1 + SRUN = 2 + SSLEEP = 3 + SSTOP = 4 + SZOMB = 5 + SWAIT = 6 + SLOCK = 7 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur int64 + Max int64 +} + +type KinfoProc struct { + Structsize int32 + Layout int32 + Args *int64 /* pargs */ + Paddr *int64 /* proc */ + Addr *int64 /* user */ + Tracep *int64 /* vnode */ + Textvp *int64 /* vnode */ + Fd *int64 /* filedesc */ + Vmspace *int64 /* vmspace */ + Wchan *byte + Pid int32 + Ppid int32 + Pgid int32 + Tpgid int32 + Sid int32 + Tsid int32 + Jobc int16 + Spare_short1 int16 + Tdev_freebsd11 uint32 + Siglist [16]byte /* sigset */ + Sigmask [16]byte /* sigset */ + Sigignore [16]byte /* sigset */ + Sigcatch [16]byte /* sigset */ + Uid uint32 + Ruid uint32 + Svuid uint32 + Rgid uint32 + Svgid uint32 + Ngroups int16 + Spare_short2 int16 + Groups [16]uint32 + Size uint64 + Rssize int64 + Swrss int64 + Tsize int64 + Dsize int64 + Ssize int64 + Xstat uint16 + Acflag uint16 + Pctcpu uint32 + Estcpu uint32 + Slptime uint32 + Swtime uint32 + Cow uint32 + Runtime uint64 + Start Timeval + Childtime Timeval + Flag int64 + Kiflag int64 + Traceflag int32 + Stat uint8 + Nice int8 + Lock uint8 + Rqindex uint8 + Oncpu_old uint8 + Lastcpu_old uint8 + Tdname [17]uint8 + Wmesg [9]uint8 + Login [18]uint8 + Lockname [9]uint8 + Comm [20]uint8 + Emul [17]uint8 + Loginclass [18]uint8 + Moretdname [4]uint8 + Sparestrings [46]uint8 + Spareints [2]int32 + Tdev uint64 + Oncpu int32 + Lastcpu int32 + Tracer int32 + Flag2 int32 + Fibnum int32 + Cr_flags uint32 + Jid int32 + Numthreads int32 + Tid int32 + Pri Priority + Rusage Rusage + Rusage_ch Rusage + Pcb *int64 /* pcb */ + Kstack *byte + Udata *byte + Tdaddr *int64 /* thread */ + Pd *int64 /* pwddesc, not accurate */ + Spareptrs [5]*byte + Sparelongs [12]int64 + Sflag int64 + Tdflags int64 +} + +type Priority struct { + Class uint8 + Level uint8 + Native uint8 + User uint8 +} + +type KinfoVmentry struct { + Structsize int32 + Type int32 + Start uint64 + End uint64 + Offset uint64 + Vn_fileid uint64 + Vn_fsid_freebsd11 uint32 + Flags int32 + Resident int32 + Private_resident int32 + Protection int32 + Ref_count int32 + Shadow_count int32 + Vn_type int32 + Vn_size uint64 + Vn_rdev_freebsd11 uint32 + Vn_mode uint16 + Status uint16 + Type_spec [8]byte + Vn_rdev uint64 + X_kve_ispare [8]int32 + Path [1024]uint8 +} From 367435f27e18ef1ddba148c4a41437bf8b08cfe8 Mon Sep 17 00:00:00 2001 From: Robert Clausecker Date: Sat, 18 May 2024 17:51:30 +0200 Subject: [PATCH 3/5] cpu: add cpu_freebsd_riscv64.go Copied from the arm64 definitions. --- cpu/cpu_freebsd_riscv64.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 cpu/cpu_freebsd_riscv64.go diff --git a/cpu/cpu_freebsd_riscv64.go b/cpu/cpu_freebsd_riscv64.go new file mode 100644 index 0000000..57e1452 --- /dev/null +++ b/cpu/cpu_freebsd_riscv64.go @@ -0,0 +1,9 @@ +package cpu + +type cpuTimes struct { + User uint64 + Nice uint64 + Sys uint64 + Intr uint64 + Idle uint64 +} From 32dcb82a13594ccf5620f0ba60350a6f24c864fc Mon Sep 17 00:00:00 2001 From: Robert Clausecker Date: Sat, 18 May 2024 17:54:59 +0200 Subject: [PATCH 4/5] disk: fix build on riscv64 --- disk/disk_freebsd_riscv64.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/disk/disk_freebsd_riscv64.go b/disk/disk_freebsd_riscv64.go index 759389f..f5492d8 100644 --- a/disk/disk_freebsd_riscv64.go +++ b/disk/disk_freebsd_riscv64.go @@ -41,7 +41,7 @@ type ( Busy_from bintime Dev_links _Ctype_struct___0 Device_number uint32 - Device_name [16]uint8 + Device_name [16]int8 Unit_number int32 Bytes [4]uint64 Operations [4]uint64 @@ -62,3 +62,7 @@ type ( Frac uint64 } ) + +type _Ctype_struct___0 struct { + Empty uint64 +} From d368af90d599cb566f259e2d30574d2025c59894 Mon Sep 17 00:00:00 2001 From: Robert Clausecker Date: Sat, 18 May 2024 17:57:15 +0200 Subject: [PATCH 5/5] process: fix build on riscv64 freebsd --- process/process_freebsd_riscv64.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/process_freebsd_riscv64.go b/process/process_freebsd_riscv64.go index 4e8ff9c..af905d7 100644 --- a/process/process_freebsd_riscv64.go +++ b/process/process_freebsd_riscv64.go @@ -140,7 +140,7 @@ type KinfoProc struct { Wmesg [9]uint8 Login [18]uint8 Lockname [9]uint8 - Comm [20]uint8 + Comm [20]int8 Emul [17]uint8 Loginclass [18]uint8 Moretdname [4]uint8