From 726a054ecac7e3b2d235706118d8a564bebd2200 Mon Sep 17 00:00:00 2001
From: Calvin Hill <calvin@hakobaito.co.uk>
Date: Mon, 6 Nov 2017 15:11:55 +0000
Subject: StdlibUnittest: temp workarounds for Haiku errno constants


diff --git a/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb b/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
index b8c9f03..787cae2 100644
--- a/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
+++ b/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
@@ -740,7 +740,7 @@ struct _ParentProcess {
       var ret: CInt
       repeat {
         ret = _stdlib_select(&readfds, &writefds, &errorfds, nil)
-      } while ret == -1  &&  errno == EINTR
+      } while ret == -1  &&  errno == 10
       if ret <= 0 {
         fatalError("select() returned an error")
       }
diff --git a/stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift b/stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift
index 5d77a73..2b797e4 100644
--- a/stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift
+++ b/stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift
@@ -278,7 +278,7 @@ public func posixWaitpid(_ pid: pid_t) -> ProcessTerminationStatus {
   }
 #else
   while waitpid(pid, &status, 0) < 0 {
-    if errno != EINTR {
+    if errno != 10 {
       preconditionFailure("waitpid() failed")
     }
   }
diff --git a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift
index 35f0ff1..b18fe28 100644
--- a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift
+++ b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift
@@ -69,7 +69,7 @@ public func _stdlib_pthread_barrier_init(
 ) -> CInt {
   barrier.pointee = _stdlib_pthread_barrier_t()
   if count == 0 {
-    errno = EINVAL
+    errno = 11
     return -1
   }
   barrier.pointee.mutex = UnsafeMutablePointer.allocate(capacity: 1)
-- 
2.14.2


From c7dd4397b9a1df9493391bf68e816fa04a89b3da Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 11 Nov 2017 17:25:41 +0100
Subject: stdlib: fixes depend targets.

example error: No rule to make target
'stdlib/public/runtime/CMakeFiles/section_magic_end-haiku-x86-64.dir/swift_sections.S.o'.

diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt
index ebd6568..61ac765 100644
--- a/stdlib/public/runtime/CMakeLists.txt
+++ b/stdlib/public/runtime/CMakeLists.txt
@@ -192,8 +192,8 @@ foreach(sdk ${ELFISH_SDKS})
       OUTPUT
           "${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o"
       DEPENDS
-          "${section_magic_begin_obj}"
-          "${section_magic_loader_obj}")
+          "section_magic_begin-${arch_suffix}"
+          "section_magic_loader-${arch_suffix}")
 
     add_custom_command_target(section_magic_${arch_suffix}_end_object
       COMMAND
@@ -203,7 +203,7 @@ foreach(sdk ${ELFISH_SDKS})
       OUTPUT
           "${SWIFTLIB_DIR}/${arch_subdir}/swift_end.o"
       DEPENDS
-          "${section_magic_end_obj}")
+          "section_magic_end-${arch_suffix}")
 
     list(APPEND object_target_list
         "${section_magic_${arch_suffix}_begin_object}"
@@ -226,7 +226,7 @@ foreach(sdk ${ELFISH_SDKS})
         OUTPUT
             "${SWIFTSTATICLIB_DIR}/${arch_subdir}/swift_begin.o"
         DEPENDS
-            "${section_magic_begin_obj}")
+            "section_magic_begin-${arch_suffix}")
 
       add_custom_command_target(static_section_magic_${arch_suffix}_end_object
         COMMAND
@@ -236,7 +236,7 @@ foreach(sdk ${ELFISH_SDKS})
         OUTPUT
             "${SWIFTSTATICLIB_DIR}/${arch_subdir}/swift_end.o"
         DEPENDS
-            "${section_magic_end_obj}")
+            "section_magic_end-${arch_suffix}")
 
       list(APPEND object_target_list
             "${static_section_magic_${arch_suffix}_begin_object}"
-- 
2.14.2

