From b3a36de6af4b6bf5155953044510671a84debe81 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Wed, 9 Mar 2022 17:24:16 +0100 Subject: [PATCH 1/4] Generate types for darwin/arm64 --- host/host_darwin_arm64.go | 22 ++++ mktypes.sh | 3 + process/process_darwin_arm64.go | 205 ++++++++++++++++++++++++++++++++ process/types_darwin.go | 1 + 4 files changed, 231 insertions(+) create mode 100644 host/host_darwin_arm64.go create mode 100644 process/process_darwin_arm64.go diff --git a/host/host_darwin_arm64.go b/host/host_darwin_arm64.go new file mode 100644 index 000000000..89e6fdb92 --- /dev/null +++ b/host/host_darwin_arm64.go @@ -0,0 +1,22 @@ +// +build darwin +// +build arm64 +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs /Users/paul.cacheux/dd/gopsutil/host/types_darwin.go + +package host + +type Utmpx struct { + User [256]int8 + Id [4]int8 + Line [32]int8 + Pid int32 + Type int16 + Tv Timeval + Host [256]int8 + Pad [16]uint32 +} +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} diff --git a/mktypes.sh b/mktypes.sh index 7bf2e2412..c0d141c64 100644 --- a/mktypes.sh +++ b/mktypes.sh @@ -20,6 +20,9 @@ case $ARCH in arm) GOARCH="arm" ;; + arm64) + GOARCH="arm64" + ;; *) echo "unknown arch: $ARCH" exit 1 diff --git a/process/process_darwin_arm64.go b/process/process_darwin_arm64.go new file mode 100644 index 000000000..59a857baa --- /dev/null +++ b/process/process_darwin_arm64.go @@ -0,0 +1,205 @@ +// +build darwin +// +build arm64 +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs /Users/paul.cacheux/dd/gopsutil/process/types_darwin.go + +package process + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +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 int32 + Pad_cgo_0 [4]byte +} + +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 uint64 + Max uint64 +} + +type UGid_t uint32 + +type KinfoProc struct { + Proc ExternProc + Eproc Eproc +} + +type Eproc struct { + Paddr *Proc + Sess *Session + Pcred Upcred + Ucred Uucred + Vm Vmspace + Ppid int32 + Pgid int32 + Jobc int16 + Tdev int32 + Tpgid int32 + Tsess *Session + Wmesg [8]int8 + Xsize int32 + Xrssize int16 + Xccount int16 + Xswrss int16 + Flag int32 + Login [12]int8 + Spare [4]int32 + Pad_cgo_0 [4]byte +} + +type Proc struct{} + +type Session struct{} + +type ucred struct{} + +type Uucred struct { + Ref int32 + Uid uint32 + Ngroups int16 + Groups [16]uint32 +} + +type Upcred struct { + Pc_lock [72]int8 + Pc_ucred *ucred + P_ruid uint32 + P_svuid uint32 + P_rgid uint32 + P_svgid uint32 + P_refcnt int32 + Pad_cgo_0 [4]byte +} + +type Vmspace struct { + Dummy int32 + Dummy2 *int8 + Dummy3 [5]int32 + Dummy4 [3]*int8 +} + +type Sigacts struct{} + +type ExternProc struct { + P_un [16]byte + P_vmspace *Vmspace + P_sigacts *Sigacts + P_flag int32 + P_stat int8 + P_pid int32 + P_oppid int32 + P_dupfd int32 + User_stack *int8 + Exit_thread *byte + P_debugger int32 + Sigwait int32 + P_estcpu uint32 + P_cpticks int32 + P_pctcpu uint32 + P_wchan *byte + P_wmesg *int8 + P_swtime uint32 + P_slptime uint32 + P_realtimer Itimerval + P_rtime Timeval + P_uticks uint64 + P_sticks uint64 + P_iticks uint64 + P_traceflag int32 + P_tracep *Vnode + P_siglist int32 + P_textvp *Vnode + P_holdcnt int32 + P_sigmask uint32 + P_sigignore uint32 + P_sigcatch uint32 + P_priority uint8 + P_usrpri uint8 + P_nice int8 + P_comm [17]int8 + P_pgrp *Pgrp + P_addr *UserStruct + P_xstat uint16 + P_acflag uint16 + P_ru *Rusage +} + +type Itimerval struct { + Interval Timeval + Value Timeval +} + +type Vnode struct{} + +type Pgrp struct{} + +type UserStruct struct{} + +type Au_session struct { + Aia_p *AuditinfoAddr + Mask AuMask +} + +type Posix_cred struct{} + +type Label struct{} + +type AuditinfoAddr struct { + Auid uint32 + Mask AuMask + Termid AuTidAddr + Asid int32 + Flags uint64 +} +type AuMask struct { + Success uint32 + Failure uint32 +} +type AuTidAddr struct { + Port int32 + Type uint32 + Addr [4]uint32 +} + +type UcredQueue struct { + Next *ucred + Prev **ucred +} diff --git a/process/types_darwin.go b/process/types_darwin.go index 21216cd09..8be5f582c 100644 --- a/process/types_darwin.go +++ b/process/types_darwin.go @@ -21,6 +21,7 @@ package process #define __DARWIN_UNIX03 0 #define KERNEL #define _DARWIN_USE_64_BIT_INODE +#include #include #include #include From 251bc102b1319b8dc145d0791a10d4c1c66e87b0 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Tue, 28 Jun 2022 14:19:06 +0200 Subject: [PATCH 2/4] Generate types for darwin/arm64 --- host/host_darwin_arm64.go | 2 +- mktypes.sh | 0 process/process_darwin_arm64.go | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 mktypes.sh diff --git a/host/host_darwin_arm64.go b/host/host_darwin_arm64.go index 89e6fdb92..5e3e97977 100644 --- a/host/host_darwin_arm64.go +++ b/host/host_darwin_arm64.go @@ -1,7 +1,7 @@ // +build darwin // +build arm64 // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs /Users/paul.cacheux/dd/gopsutil/host/types_darwin.go +// cgo -godefs /Users/paul.cacheux/go/src/github.com/DataDog/gopsutil/host/types_darwin.go package host diff --git a/mktypes.sh b/mktypes.sh old mode 100644 new mode 100755 diff --git a/process/process_darwin_arm64.go b/process/process_darwin_arm64.go index 59a857baa..24deb8aa6 100644 --- a/process/process_darwin_arm64.go +++ b/process/process_darwin_arm64.go @@ -1,7 +1,7 @@ // +build darwin // +build arm64 // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs /Users/paul.cacheux/dd/gopsutil/process/types_darwin.go +// cgo -godefs /Users/paul.cacheux/go/src/github.com/DataDog/gopsutil/process/types_darwin.go package process From 4ad6fe19154e784efdc60f1def4381e92d39b897 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Tue, 28 Jun 2022 14:20:07 +0200 Subject: [PATCH 3/4] Cleanup paths --- host/host_darwin_arm64.go | 2 +- process/process_darwin_arm64.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/host/host_darwin_arm64.go b/host/host_darwin_arm64.go index 5e3e97977..5f9ddad5b 100644 --- a/host/host_darwin_arm64.go +++ b/host/host_darwin_arm64.go @@ -1,7 +1,7 @@ // +build darwin // +build arm64 // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs /Users/paul.cacheux/go/src/github.com/DataDog/gopsutil/host/types_darwin.go +// cgo -godefs host/types_darwin.go package host diff --git a/process/process_darwin_arm64.go b/process/process_darwin_arm64.go index 24deb8aa6..6f6ce32eb 100644 --- a/process/process_darwin_arm64.go +++ b/process/process_darwin_arm64.go @@ -1,7 +1,7 @@ // +build darwin // +build arm64 // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs /Users/paul.cacheux/go/src/github.com/DataDog/gopsutil/process/types_darwin.go +// cgo -godefs process/types_darwin.go package process From 9ef6a0c4dc9f787239bedad82fae48b8afa47470 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Tue, 28 Jun 2022 15:14:56 +0200 Subject: [PATCH 4/4] Fix `UID`, `Uid` mix up --- mktypes.sh | 3 +++ process/process_darwin_arm64.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mktypes.sh b/mktypes.sh index c0d141c64..b48576506 100755 --- a/mktypes.sh +++ b/mktypes.sh @@ -28,6 +28,9 @@ case $ARCH in exit 1 esac +# Note that `process.Uucred#Uid` must be chanded manually to `UID` to match upstream behavior. +# Please see https://github.com/shirou/gopsutil/pull/917 for more information. + for DIR in $DIRS do if [ -e ${DIR}/types_${GOOS}.go ]; then diff --git a/process/process_darwin_arm64.go b/process/process_darwin_arm64.go index 6f6ce32eb..f61e392f9 100644 --- a/process/process_darwin_arm64.go +++ b/process/process_darwin_arm64.go @@ -93,7 +93,7 @@ type ucred struct{} type Uucred struct { Ref int32 - Uid uint32 + UID uint32 Ngroups int16 Groups [16]uint32 }