From 441f6f21603ba14785ebd49bb51b446363592fd3 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 1 Aug 2016 23:49:39 +0000
Subject: Haiku patch


diff --git a/Makefile.in b/Makefile.in
index 3a70a71..722e7bf 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,7 +4,7 @@ CXX		:= @CXX@
 CC		:= @CC@
 CXXFLAGS	:= -DHAVE_LIBSAMPLERATE -DHAVE_FFTW3 -DFFTW_DOUBLE_ONLY -DNO_THREAD_CHECKS -DUSE_PTHREADS -DNO_TIMING -DNDEBUG -I. -Isrc -Irubberband @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ $(OPTFLAGS)
 CFLAGS		:= @CFLAGS@ $(OPTFLAGS)
-LDFLAGS		:= @LDFLAGS@ -lpthread $(LDFLAGS)
+LDFLAGS		:= @LDFLAGS@ @LIBPTHREAD@ $(LDFLAGS)
 
 JNI_CXXFLAGS	:= -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
 JAVAC		:= $(JAVA_HOME)/bin/javac
diff --git a/configure.ac b/configure.ac
index eef571b..e275071 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,6 +7,10 @@ AC_PROG_CC
 AC_HEADER_STDC
 AC_C_BIGENDIAN
 
+AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD="-lpthread"],
+	[LIBPTHREAD=""])
+AC_SUBST(LIBPTHREAD)
+
 PKG_CHECK_MODULES([SRC],[samplerate])
 AC_SUBST(SRC_CFLAGS)
 AC_SUBST(SRC_LIBS)
diff --git a/src/system/sysutils.h b/src/system/sysutils.h
index b63c640..c80d47d 100644
--- a/src/system/sysutils.h
+++ b/src/system/sysutils.h
@@ -130,9 +130,15 @@ extern void system_memorybarrier();
 #include <dlfcn.h>
 #include <stdio.h>
 
+#ifdef __HAIKU__
+#define MLOCK(a,b)   (0)
+#define MUNLOCK(a,b) (0)
+#define MUNLOCK_SAMPLEBLOCK(a) do { ; } while(0);
+#else
 #define MLOCK(a,b)   ::mlock((char *)(a),(b))
 #define MUNLOCK(a,b) (::munlock((char *)(a),(b)) ? (::perror("munlock failed"), 0) : 0)
 #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
+#endif
 
 #ifdef __APPLE__
 #include <libkern/OSAtomic.h>
-- 
2.7.0

