From 7d64ae7a417dd968cd355f4738764f9206f62eea Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Sat, 26 Feb 2022 10:49:52 +0100 Subject: [PATCH] runtime: Add a syscall wrapper package It allows to support syscall variations between host OSes. Signed-off-by: Samuel Ortiz --- src/runtime/pkg/syscall/syscall_darwin.go | 16 ++++++++++++++++ src/runtime/pkg/syscall/syscall_linux.go | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/runtime/pkg/syscall/syscall_darwin.go create mode 100644 src/runtime/pkg/syscall/syscall_linux.go diff --git a/src/runtime/pkg/syscall/syscall_darwin.go b/src/runtime/pkg/syscall/syscall_darwin.go new file mode 100644 index 0000000000..a5cc79d18b --- /dev/null +++ b/src/runtime/pkg/syscall/syscall_darwin.go @@ -0,0 +1,16 @@ +// Copyright (c) 2022 Apple Inc. +// +// SPDX-License-Identifier: Apache-2.0 +// + +package syscall + +import ( + "syscall" +) + +func Gettid() int { + // There is no equivalent to a thread ID on Darwin. + // We use the PID instead. + return syscall.Getpid() +} diff --git a/src/runtime/pkg/syscall/syscall_linux.go b/src/runtime/pkg/syscall/syscall_linux.go new file mode 100644 index 0000000000..b05fc156d1 --- /dev/null +++ b/src/runtime/pkg/syscall/syscall_linux.go @@ -0,0 +1,14 @@ +// Copyright (c) 2022 Apple Inc. +// +// SPDX-License-Identifier: Apache-2.0 +// + +package syscall + +import ( + "syscall" +) + +func Gettid() int { + return syscall.Gettid() +}