summaryrefslogtreecommitdiff
path: root/Ports/llvm/patches/insert-ifdef-serenity.patch
blob: e1b16686d7c2a9451ec117fd70ab4dd3cff4a051 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index c37b3a546..e51badb34 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -109,7 +109,7 @@ typedef uint_t uint;
 #endif
 
 #if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
-    defined(__MVS__)
+    defined(__MVS__) || defined(__serenity__)
 #define STATVFS_F_FLAG(vfs) (vfs).f_flag
 #else
 #define STATVFS_F_FLAG(vfs) (vfs).f_flags
@@ -531,7 +531,7 @@ static bool is_local_impl(struct STATVFS &Vfs) {
 
   // vmount entry not found; "remote" is the conservative answer.
   return false;
-#elif defined(__MVS__)
+#elif defined(__MVS__) || defined(__serenity__)
   // The file system can have an arbitrary structure on z/OS; must go with the
   // conservative answer.
   return false;
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index be59bb023..ff8931308 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -335,7 +335,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
 namespace llvm {
 namespace sys {
 
-#ifndef _AIX
+#if !defined(_AIX) && !defined(__serenity__)
 using ::wait4;
 #else
 static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage);
@@ -344,7 +344,7 @@ static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage);
 } // namespace sys
 } // namespace llvm
 
-#ifdef _AIX
+#if defined(_AIX) || defined(__serenity__)
 #ifndef _ALL_SOURCE
 extern "C" pid_t (wait4)(pid_t pid, int *status, int options,
                          struct rusage *usage);
@@ -357,7 +357,7 @@ pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options,
 
   // AIX wait4 does not work well with WNOHANG.
   if (!(options & WNOHANG))
-    return ::wait4(pid, status, options, usage);
+    return ::waitpid(pid, status, options);
 
   // For WNOHANG, we use waitid (which supports WNOWAIT) until the child process
   // has terminated.
@@ -374,7 +374,7 @@ pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options,
   // The child has already terminated, so a blocking wait on it is okay in the
   // absence of indiscriminate `wait` calls from the current process (which
   // would cause the call here to fail with ECHILD).
-  return ::wait4(pid, status, options & ~WNOHANG, usage);
+  return ::waitpid(pid, status, options & ~WNOHANG);
 }
 #endif
 
@@ -534,10 +534,10 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
 
 bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
                                                   ArrayRef<StringRef> Args) {
-  static long ArgMax = sysconf(_SC_ARG_MAX);
+  static long ArgMax = 4096;
   // POSIX requires that _POSIX_ARG_MAX is 4096, which is the lowest possible
   // value for ARG_MAX on a POSIX compliant system.
-  static long ArgMin = _POSIX_ARG_MAX;
+  static long ArgMin = 4096;
 
   // This the same baseline used by xargs.
   long EffectiveArgMax = 128 * 1024;
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
index 7f197a50c..03bf029db 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
@@ -50,7 +50,7 @@ void printErrorAndExit(Twine ErrMsg) {
 }
 
 int openListener(std::string Host, std::string PortStr) {
-#ifndef LLVM_ON_UNIX
+#if !defined(LLVM_ON_UNIX) || defined(__serenity__)
   // FIXME: Add TCP support for Windows.
   printErrorAndExit("listen option not supported");
   return 0;
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 8bd384ec7..a28e938ec 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -770,7 +770,7 @@ static Expected<int> connectTCPSocket(std::string Host, std::string PortStr) {
 
 Expected<std::unique_ptr<ExecutorProcessControl>>
 LLVMJITLinkRemoteExecutorProcessControl::ConnectToExecutor() {
-#ifndef LLVM_ON_UNIX
+#if !defined(LLVM_ON_UNIX) || defined(__serenity__)
   // FIXME: Add TCP support for Windows.
   return make_error<StringError>("-" + OutOfProcessExecutorConnect.ArgStr +
                                      " not supported on non-unix platforms",
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h    2021-04-06 19:38:18.000000000 +0300
+++ llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h      2021-06-09 16:00:20.111549941 +0300
@@ -22,7 +22,7 @@
 #endif
 
 #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||            \
-    defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
+    defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__serenity__)
 #include <endian.h>
 #elif defined(_AIX)
 #include <sys/machine.h>