From ffce35b803dd80ac3cfd4d4cc5d943cd2072379a Mon Sep 17 00:00:00 2001 From: Wlad Meixner Date: Mon, 30 Mar 2020 12:47:54 +0200 Subject: [PATCH] add: darwin gittid. - Add a darwin compatible gettid syscall - split linux/darwin build target files --- internal/utils/utils_darwin.go | 40 +++++++++++++++++++ .../utils/{utils_unix.go => utils_linux.go} | 3 +- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 internal/utils/utils_darwin.go rename internal/utils/{utils_unix.go => utils_linux.go} (97%) diff --git a/internal/utils/utils_darwin.go b/internal/utils/utils_darwin.go new file mode 100644 index 0000000..7534107 --- /dev/null +++ b/internal/utils/utils_darwin.go @@ -0,0 +1,40 @@ +// +build darwin +/* + * GML - Go QML + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Roland Singer + * Copyright (c) 2019 Sebastian Borchers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package utils + +import ( + "syscall" + + "golang.org/x/sys/unix" +) + +func GetThreadID() int { + tid, _, _ := syscall.Syscall(unix.SYS_THREAD_SELFID, 0, 0, 0) + return int(tid) +} diff --git a/internal/utils/utils_unix.go b/internal/utils/utils_linux.go similarity index 97% rename from internal/utils/utils_unix.go rename to internal/utils/utils_linux.go index 46d4262..ee1e87d 100644 --- a/internal/utils/utils_unix.go +++ b/internal/utils/utils_linux.go @@ -1,5 +1,4 @@ -// +build !windows - +// +build !darwin, !windows /* * GML - Go QML *