Closed dearblue closed 9 years ago
I was tried building on FreeBSD 10.1 (amd64). But failed to compile.
So I fixed problems.
System and compiler information:
$ uname -mrs FreeBSD 10.1-RELEASE-p16 amd64 $ cc -v FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 Target: x86_64-unknown-freebsd10.1 Thread model: posix
Modified patch is following (based revision is 2e5a0bf4c0f311d9c6f39ca2518c990df3f36f17):
diff --git a/lzhamcomp/lzham_pthreads_threading.cpp b/lzhamcomp/lzham_pthreads_threading.cpp index 4dd6c5c..bb2c565 100644 --- a/lzhamcomp/lzham_pthreads_threading.cpp +++ b/lzhamcomp/lzham_pthreads_threading.cpp @@ -27,7 +27,7 @@ #include <process.h> #endif -#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) +#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__FreeBSD__) #include <sys/sysinfo.h> #endif @@ -211,7 +211,7 @@ namespace lzham uint lzham_get_max_helper_threads() { -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(__FreeBSD__) int num_procs = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); return (num_procs >= 1) ? (num_procs - 1) : 0; #elif (1) diff --git a/lzhamdecomp/lzham_core.h b/lzhamdecomp/lzham_core.h index fc6e16f..f4e2d4f 100644 --- a/lzhamdecomp/lzham_core.h +++ b/lzhamdecomp/lzham_core.h @@ -241,7 +241,7 @@ const bool c_lzham_big_endian_platform = !c_lzham_little_endian_platform; #include <stdlib.h> #include <stdio.h> #include <math.h> -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) #include <malloc.h> #endif #include <stdarg.h> diff --git a/lzhamdecomp/lzham_mem.cpp b/lzhamdecomp/lzham_mem.cpp index 84d8bcd..02f2324 100644 --- a/lzhamdecomp/lzham_mem.cpp +++ b/lzhamdecomp/lzham_mem.cpp @@ -6,6 +6,9 @@ #include <malloc/malloc.h> #elif defined(__FreeBSD__) || defined(__NetBSD__) #include <malloc_np.h> + #if defined(__FreeBSD__) + #define malloc(size) aligned_alloc((LZHAM_MIN_ALLOC_ALIGNMENT), (size)) + #endif #else #include <malloc.h> #endif diff --git a/lzhamdecomp/lzham_traits.h b/lzhamdecomp/lzham_traits.h index cb0076c..950c3fd 100644 --- a/lzhamdecomp/lzham_traits.h +++ b/lzhamdecomp/lzham_traits.h @@ -67,7 +67,7 @@ namespace lzham // Defines type Q as bitwise copyable. #define LZHAM_DEFINE_BITWISE_COPYABLE(Q) template<> struct bitwise_copyable<Q> { enum { cFlag = true }; }; -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__APPLE__) || defined(__NetBSD__) #define LZHAM_IS_POD(T) std::__is_pod<T>::__value #else #define LZHAM_IS_POD(T) __is_pod(T) diff --git a/lzhamtest/lzhamtest.cpp b/lzhamtest/lzhamtest.cpp index 3af955a..14bb3d1 100644 --- a/lzhamtest/lzhamtest.cpp +++ b/lzhamtest/lzhamtest.cpp @@ -14,7 +14,7 @@ #include <assert.h> #include <memory.h> #include <stdarg.h> -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) #include <malloc.h> #endif #include <vector> @@ -46,6 +46,14 @@ #define fopen fopen #define _fseeki64 fseek #define _ftelli64 ftell +#elif defined(__FreeBSD__) + #include <unistd.h> + #define Sleep(ms) usleep(ms*1000) + #define _aligned_malloc(size, alignment) aligned_alloc(alignment, size) + #define _aligned_free free + #define fopen fopen + #define _fseeki64 fseeko + #define _ftelli64 ftello #else #include <unistd.h> #define Sleep(ms) usleep(ms*1000) diff --git a/lzhamtest/timer.cpp b/lzhamtest/timer.cpp index 648d87e..affd260 100644 --- a/lzhamtest/timer.cpp +++ b/lzhamtest/timer.cpp @@ -27,7 +27,7 @@ inline void query_counter_frequency(timer_ticks *pTicks) QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(pTicks)); } #elif defined(__GNUC__) -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) #include <sys/time.h> #else #include <sys/timex.h>
Thank you very much dearblue! I'll merge your fixes in today.
Ok, patch applied. Thanks again!
I was tried building on FreeBSD 10.1 (amd64). But failed to compile.
So I fixed problems.
System and compiler information:
Modified patch is following (based revision is 2e5a0bf4c0f311d9c6f39ca2518c990df3f36f17):