forked from MarshallOfSound/electron
/
fix_disable_usage_of_pthread_fchdir_np_and_pthread_chdir_np_in_mas.patch
54 lines (47 loc) · 1.64 KB
/
fix_disable_usage_of_pthread_fchdir_np_and_pthread_chdir_np_in_mas.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 4 Mar 2019 14:46:48 -0800
Subject: fix: disable usage of pthread_fchdir_np and pthread_chdir_np in MAS
builds
diff --git a/base/process/launch_mac.cc b/base/process/launch_mac.cc
index 6c0e14fc3332c27309c83137cff9f060ed306aea..2f77af0cafbc0122603bc2735f6327e2e42a07b6 100644
--- a/base/process/launch_mac.cc
+++ b/base/process/launch_mac.cc
@@ -24,10 +24,12 @@
// descriptor. libpthread only exposes a syscall wrapper starting in
// macOS 10.12, but the system call dates back to macOS 10.5. On older OSes,
// the syscall is issued directly.
+#if !defined(MAS_BUILD)
extern "C" {
int pthread_chdir_np(const char*) API_AVAILABLE(macosx(10.12));
int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12));
}
+#endif
namespace base {
@@ -94,21 +96,29 @@ class PosixSpawnFileActions {
};
int ChangeCurrentThreadDirectory(const char* path) {
+ #if defined(MAS_BUILD)
+ return syscall(SYS___pthread_chdir, path);
+ #else
if (__builtin_available(macOS 10.12, *)) {
return pthread_chdir_np(path);
} else {
return syscall(SYS___pthread_chdir, path);
}
+ #endif
}
// The recommended way to unset a per-thread cwd is to set a new value to an
// invalid file descriptor, per libpthread-218.1.3/private/private.h.
int ResetCurrentThreadDirectory() {
+ #if defined(MAS_BUILD)
+ return syscall(SYS___pthread_fchdir, -1);
+ #else
if (__builtin_available(macOS 10.12, *)) {
return pthread_fchdir_np(-1);
} else {
return syscall(SYS___pthread_fchdir, -1);
}
+ #endif
}
struct GetAppOutputOptions {