feat(cgo): add byte-slice support to Call arguments

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-03 19:35:54 +00:00
parent 7588b3d1de
commit 375d522b1a
2 changed files with 14 additions and 0 deletions

View file

@ -177,6 +177,15 @@ func TestCallSupportsCUintptrArgument(t *testing.T) {
}
}
func TestCallSupportsByteSliceArgument(t *testing.T) {
t.Parallel()
payload := []byte("agent")
if err := Call(callSumLengthFunction(), payload, SizeT(len(payload))); err != nil {
t.Fatalf("expected success, got %v", err)
}
}
func TestErrnoMapping(t *testing.T) {
t.Parallel()

View file

@ -819,6 +819,11 @@ func toSyscallArg(value interface{}) (uintptr, bool) {
return 0, true
}
return 0, false
case []byte:
if len(typed) == 0 {
return 0, true
}
return uintptr(unsafe.Pointer(&typed[0])), true
}
}