Skip to content

Commit 64f1162

Browse files
committed
builtin: support -d no_getpid and -d no_gettid for systems that lack proper process management APIs
1 parent 7002411 commit 64f1162

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

vlib/builtin/builtin.c.v

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,10 @@ pub fn arguments() []string {
965965
// remain the same while the current process is running. It may or may not be
966966
// equal to the value of v_gettid(). Note: it is *NOT equal on Windows*.
967967
pub fn v_getpid() u64 {
968-
$if windows {
968+
$if no_getpid ? {
969+
// support non posix/windows systems that lack process management
970+
return 0
971+
} $else $if windows {
969972
return u64(C.GetCurrentProcessId())
970973
} $else {
971974
return u64(C.getpid())
@@ -981,7 +984,10 @@ pub fn v_getpid() u64 {
981984
// *avoid relying on this equivalence*, and use v_gettid and v_getpid only for
982985
// tracing and debugging multithreaded issues, but *NOT for logic decisions*.
983986
pub fn v_gettid() u64 {
984-
$if windows {
987+
$if no_gettid ? {
988+
// support non posix/windows systems that lack process management
989+
return 0
990+
} $else $if windows {
985991
return u64(C.GetCurrentThreadId())
986992
} $else $if linux && !musl ? {
987993
return u64(C.gettid())

0 commit comments

Comments
 (0)