embree-3.6.0.patchset revision 097347cc
1From f84bf30cb06b3fb70e374415377399f966d84d98 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
3Date: Sat, 24 Aug 2019 09:32:55 +0200
4Subject: Applied patches
5
6
7diff --git a/common/math/math.h b/common/math/math.h
8index caef5aa..2007bda 100644
9--- a/common/math/math.h
10+++ b/common/math/math.h
11@@ -176,7 +176,10 @@ namespace embree
12   __forceinline  int64_t min(int64_t  a, int64_t  b) { return a<b ? a:b; }
13   __forceinline    float min(float    a, float    b) { return a<b ? a:b; }
14   __forceinline   double min(double   a, double   b) { return a<b ? a:b; }
15-#if defined(__X86_64__)
16+#if !defined(__X86_64__) && defined (__HAIKU__)
17+  __forceinline  ssize_t min(ssize_t  a, ssize_t  b) { return a<b ? a:b; }
18+#endif
19+#if defined(__X86_64__) || defined (__HAIKU__)
20   __forceinline   size_t min(size_t   a, size_t   b) { return a<b ? a:b; }
21 #endif
22 
23@@ -193,7 +196,10 @@ namespace embree
24   __forceinline  int64_t max(int64_t  a, int64_t  b) { return a<b ? b:a; }
25   __forceinline    float max(float    a, float    b) { return a<b ? b:a; }
26   __forceinline   double max(double   a, double   b) { return a<b ? b:a; }
27-#if defined(__X86_64__)
28+#if !defined(__X86_64__) && defined (__HAIKU__)
29+  __forceinline  ssize_t max(ssize_t  a, ssize_t  b) { return a<b ? b:a; }
30+#endif
31+#if defined(__X86_64__) || defined (__HAIKU__)
32   __forceinline   size_t max(size_t   a, size_t   b) { return a<b ? b:a; }
33 #endif
34 
35diff --git a/common/sys/alloc.cpp b/common/sys/alloc.cpp
36index e24df4e..8f0453a 100644
37--- a/common/sys/alloc.cpp
38+++ b/common/sys/alloc.cpp
39@@ -253,6 +253,7 @@ namespace embree
40       return nullptr;
41     }
42 
43+#ifndef __HAIKU__
44     /* try direct huge page allocation first */
45     if (isHugePageCandidate(bytes)) 
46     {
47@@ -270,6 +271,7 @@ namespace embree
48       }
49 #endif
50     } 
51+#endif
52 
53     /* fallback to 4k pages */
54     void* ptr = (char*) mmap(0, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
55diff --git a/common/sys/array.h b/common/sys/array.h
56index d64ebb1..a0b9a5c 100644
57--- a/common/sys/array.h
58+++ b/common/sys/array.h
59@@ -152,7 +152,7 @@ namespace embree
60     __forceinline       Ty& operator[](const unsigned i)       { assert(i<N); return data[i]; }
61     __forceinline const Ty& operator[](const unsigned i) const { assert(i<N); return data[i]; }
62 
63-#if defined(__X86_64__)
64+#if defined(__X86_64__) || defined(__HAIKU__)
65     __forceinline       Ty& operator[](const size_t i)       { assert(i<N); return data[i]; }
66     __forceinline const Ty& operator[](const size_t i) const { assert(i<N); return data[i]; }
67 #endif
68diff --git a/common/sys/intrinsics.h b/common/sys/intrinsics.h
69index 5ec477c..8355bd8 100644
70--- a/common/sys/intrinsics.h
71+++ b/common/sys/intrinsics.h
72@@ -87,7 +87,7 @@ namespace embree
73 #endif
74   }
75   
76-#if defined(__X86_64__)
77+#if defined(__X86_64__) || defined (__HAIKU__)
78   __forceinline size_t bsf(size_t v) {
79 #if defined(__AVX2__) 
80     return _tzcnt_u64(v);
81@@ -111,7 +111,7 @@ namespace embree
82     return i;
83   }
84   
85-#if defined(__X86_64__)
86+#if defined(__X86_64__) || defined (__HAIKU__)
87   __forceinline size_t bscf(size_t& v) 
88   {
89     size_t i = bsf(v);
90@@ -407,6 +407,12 @@ namespace embree
91     return _mm_popcnt_u32(in);
92   }
93   
94+#if !defined(__X86_64__) && defined(__HAIKU__)
95+  __forceinline size_t __popcnt(size_t in) {
96+    return _mm_popcnt_u32(in);
97+  }
98+#endif
99+  
100 #if defined(__X86_64__)
101   __forceinline size_t popcnt(size_t in) {
102     return _mm_popcnt_u64(in);
103diff --git a/common/sys/platform.h b/common/sys/platform.h
104index 477fa6f..c0778e8 100644
105--- a/common/sys/platform.h
106+++ b/common/sys/platform.h
107@@ -86,7 +86,7 @@
108 #endif
109 
110 /* try to detect other Unix systems */
111-#if defined(__unix__) || defined (unix) || defined(__unix) || defined(_unix)
112+#if defined(__unix__) || defined (unix) || defined(__unix) || defined(_unix) || defined(__HAIKU__)
113 #  if !defined(__UNIX__)
114 #     define __UNIX__
115 #  endif
116diff --git a/common/sys/sysinfo.cpp b/common/sys/sysinfo.cpp
117index e5aa1d9..e070000 100644
118--- a/common/sys/sysinfo.cpp
119+++ b/common/sys/sysinfo.cpp
120@@ -53,6 +53,10 @@ namespace embree
121     return "Unix (32bit)";
122 #elif defined(__UNIX__) && defined(__X86_64__)
123     return "Unix (64bit)";
124+#elif defined(__HAIKU__) && !defined(__X86_64__)
125+    return "Haiku (32bit)";
126+#elif defined(__HAIKU__) && defined(__X86_64__)
127+    return "Haiku (64bit)";
128 #else
129     return "Unknown";
130 #endif
131@@ -435,7 +439,7 @@ namespace embree
132 /// Linux Platform
133 ////////////////////////////////////////////////////////////////////////////////
134 
135-#if defined(__LINUX__)
136+#if defined(__LINUX__) || defined(__HAIKU__)
137 
138 #include <stdio.h>
139 #include <unistd.h>
140diff --git a/kernels/builders/bvh_builder_sah.h b/kernels/builders/bvh_builder_sah.h
141index 6418a9b..5de64ff 100644
142--- a/kernels/builders/bvh_builder_sah.h
143+++ b/kernels/builders/bvh_builder_sah.h
144@@ -55,7 +55,7 @@ namespace embree
145         {
146           if (RTC_BUILD_ARGUMENTS_HAS(settings,maxBranchingFactor)) branchingFactor = settings.maxBranchingFactor;
147           if (RTC_BUILD_ARGUMENTS_HAS(settings,maxDepth          )) maxDepth        = settings.maxDepth;
148-          if (RTC_BUILD_ARGUMENTS_HAS(settings,sahBlockSize      )) logBlockSize    = bsr(settings.sahBlockSize);
149+          if (RTC_BUILD_ARGUMENTS_HAS(settings,sahBlockSize      )) logBlockSize    = bsr((size_t)settings.sahBlockSize);
150           if (RTC_BUILD_ARGUMENTS_HAS(settings,minLeafSize       )) minLeafSize     = settings.minLeafSize;
151           if (RTC_BUILD_ARGUMENTS_HAS(settings,maxLeafSize       )) maxLeafSize     = settings.maxLeafSize;
152           if (RTC_BUILD_ARGUMENTS_HAS(settings,traversalCost     )) travCost        = settings.traversalCost;
153-- 
1542.23.0
155
156