From d5ce784d118acd2cf0d434268ebeb75a03b04e6f Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Sun, 28 Dec 2014 07:11:55 +0000
Subject: Check if threading library needs to be linked separately


diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 9cc5913..eced637 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -60,7 +60,8 @@ else()
 endif()
 
 if(UNIX)
-    list(APPEND PLATFORM_LIBS pthread)
+	find_package(Threads)
+    list(APPEND PLATFORM_LIBS ${CMAKE_THREAD_LIBS_INIT})
     find_library(LIBRT rt)
     if(LIBRT)
         list(APPEND PLATFORM_LIBS rt)
-- 
1.8.3.4


From c9f6f61516949019b8d9dde31fbdc05d8e67dbb4 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Sun, 28 Dec 2014 07:13:56 +0000
Subject: Add an option to adjust headers installation path


diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index eced637..8ff52f9 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -271,6 +271,7 @@ endif()
 # Build options
 set(LIB_INSTALL_DIR lib CACHE STRING "Install location of libraries")
 set(BIN_INSTALL_DIR bin CACHE STRING "Install location of executables")
+set(INCLUDE_INSTALL_DIR include CACHE STRING "Install location of headers")
 
 if(X64)
     # NOTE: We only officially support 16bit-per-pixel compiles of x265
@@ -379,7 +380,8 @@ endif()
 install(TARGETS x265-static
     LIBRARY DESTINATION ${LIB_INSTALL_DIR}
     ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
-install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h" DESTINATION include)
+install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h"
+        DESTINATION "${INCLUDE_INSTALL_DIR}")
 
 if(CMAKE_RC_COMPILER)
     # The resource compiler does not need CFLAGS or macro defines. It
-- 
1.8.3.4


From dd3065dea7a357f642c0bbb961ecfc9eec2ad184 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Sun, 28 Dec 2014 07:14:34 +0000
Subject: Add Haiku version of adjusting thread priority


diff --git a/source/common/threadpool.cpp b/source/common/threadpool.cpp
index 9c28470..7663d4a 100644
--- a/source/common/threadpool.cpp
+++ b/source/common/threadpool.cpp
@@ -52,6 +52,9 @@
 
 #endif
 
+#if defined(__HAIKU__)
+#include <OS.h>
+#endif
 #if MACOS
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -91,7 +94,10 @@ void WorkerThread::threadMain()
 
 #if _WIN32
     SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
-#else
+#elif defined(__HAIKU__)
+	__attribute__((unused)) status_t
+	val = set_thread_priority(find_thread(NULL), B_LOW_PRIORITY);
+ #else
     __attribute__((unused)) int val = nice(10);
 #endif
 
-- 
1.8.3.4


From 07c68c91ceaa9ef67ed1c83498e2dae54a0e8c15 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Mon, 29 Dec 2014 04:43:42 +0000
Subject: checkasm-a: Explicitly use PLT relocation for libc symbols

Fixes linking with PIC (default for all compilation) on Haiku.

diff --git a/source/test/checkasm-a.asm b/source/test/checkasm-a.asm
index f7b9837..d0d622a 100644
--- a/source/test/checkasm-a.asm
+++ b/source/test/checkasm-a.asm
@@ -153,7 +153,7 @@ cglobal checkasm_call, 2,15,16,max_args*8+8
     jz .ok
     mov  r9, rax
     lea  r0, [error_message]
-    call puts
+    call puts wrt ..plt
     mov  r1, [rsp+max_args*8]
     mov  dword [r1], 0
     mov  rax, r9
-- 
1.8.3.4

