Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
macos_build_command: 'xcrun swift-format lint -s -r --configuration ./.swift-format . && xcrun swift test && xcrun swift test -c release && xcrun swift test --disable-default-traits'
enable_linux_static_sdk_build: true
enable_android_sdk_build: true
android_ndk_version: '["r27d", "r29"]'
linux_static_sdk_versions: '["6.1", "nightly-6.2"]'
linux_static_sdk_build_command: |
for triple in aarch64-swift-linux-musl x86_64-swift-linux-musl ; do
Expand Down
15 changes: 1 addition & 14 deletions Sources/Subprocess/Thread.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,29 +307,16 @@ internal func pthread_create(
self.body = body
}
}
#if canImport(Darwin)
func proc(_ context: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? {
(Unmanaged<AnyObject>.fromOpaque(context).takeRetainedValue() as! Context).body()
return context
}
#elseif canImport(Glibc) || canImport(Musl)
func proc(_ context: UnsafeMutableRawPointer?) -> UnsafeMutableRawPointer? {
(Unmanaged<AnyObject>.fromOpaque(context!).takeRetainedValue() as! Context).body()
return context
}
#elseif canImport(Bionic)
func proc(_ context: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer {
(Unmanaged<AnyObject>.fromOpaque(context).takeRetainedValue() as! Context).body()
return context
}
#endif

#if canImport(Glibc) || canImport(Bionic)
var thread = pthread_t()
#else
var thread: pthread_t?
#endif
let rc = pthread_create(
let rc = _subprocess_pthread_create(
&thread,
nil,
proc,
Expand Down
8 changes: 8 additions & 0 deletions Sources/_SubprocessCShims/include/process_shims.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "target_conditionals.h"

#if !TARGET_OS_WINDOWS
#include <pthread.h>
#include <unistd.h>

#if _POSIX_SPAWN
Expand All @@ -39,6 +40,13 @@
extern "C" {
#endif

int _subprocess_pthread_create(
pthread_t * _Nonnull ptr,
pthread_attr_t const * _Nullable attr,
void * _Nullable (* _Nonnull start)(void * _Nullable),
void * _Nullable context
);

#if __has_include(<mach/vm_page_size.h>)
vm_size_t _subprocess_vm_size(void);
#endif
Expand Down
9 changes: 9 additions & 0 deletions Sources/_SubprocessCShims/process_shims.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ int _was_process_suspended(int status) {
return WIFSTOPPED(status);
}

int _subprocess_pthread_create(
pthread_t * _Nonnull ptr,
pthread_attr_t const * _Nullable attr,
void * _Nullable (* _Nonnull start)(void * _Nullable),
void * _Nullable context
) {
return pthread_create(ptr, attr, start, context);
}

#endif

#if __has_include(<mach/vm_page_size.h>)
Expand Down