about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch
blob: d908cb6ba80b213d008a7904fc5fa1d7a7f3e474 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
diff --git a/caffe2/perfkernels/cvtsh_ss_bugfix.h b/caffe2/perfkernels/cvtsh_ss_bugfix.h
index bd06681..00172b7 100644
--- a/caffe2/perfkernels/cvtsh_ss_bugfix.h
+++ b/caffe2/perfkernels/cvtsh_ss_bugfix.h
@@ -1,10 +1,36 @@
+/**
+ * Copyright (c) 2016-present, Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #pragma once
 
-#if defined(__APPLE__) && (__clang_major__ < 8)
+// Apple clang was fixed in 8.1
+#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1)))
+#define __APPLE_NEED_FIX 1
+#endif
+
+// Regular clang was fixed in 3.9
+#if defined(__clang__) && (__clang_major__ < 4) && (__clang_minor__ < 9)
+#define __CLANG_NEED_FIX 1
+#endif
+
+#if __APPLE_NEED_FIX || __CLANG_NEED_FIX
 
 #include <emmintrin.h>
 
-// This version of apple clang has a bug that _cvtsh_ss is not defined, see
+// This version of clang has a bug that _cvtsh_ss is not defined, see
 // https://reviews.llvm.org/D16177
 static __inline float
     __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
@@ -15,7 +41,10 @@ _cvtsh_ss(unsigned short a)
   return r[0];
 }
 
-#endif // defined(__APPLE__) && (__clang_major__ < 8)
+#endif // __APPLE_NEED_FIX || __CLANG_NEED_FIX
+
+#undef __APPLE_NEED_FIX
+#undef __CLANG_NEED_FIX
 
 #ifdef _MSC_VER