summaryrefslogtreecommitdiffstats
path: root/external/nss/clang-cl.patch.0
blob: 1d615c2397d8703cfa04811a2d9a7ed355891e1a (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# "#pragma deprecated" and "#pragma intrinsic" not (yet?) handled in the "if
# (LangOpts.MicrosoftExt)" block in Preprocessor::RegisterBuiltinPragmas in
# Clang's lib/Lex/Pragma.cpp:
--- nspr/pr/include/pratom.h
+++ nspr/pr/include/pratom.h
@@ -83,7 +83,7 @@
 
 #include <intrin.h>
 
-#ifdef _MSC_VER
+#if defined _WIN32 && !defined __clang__
 #pragma intrinsic(_InterlockedIncrement)
 #pragma intrinsic(_InterlockedDecrement)
 #pragma intrinsic(_InterlockedExchange)
--- nspr/pr/include/prbit.h
+++ nspr/pr/include/prbit.h
@@ -14,7 +14,7 @@
 */
 #if defined(_WIN32) && (_MSC_VER >= 1300) && \
     (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || \
-     defined(_M_ARM64))
+     defined(_M_ARM64)) && !defined __clang__
 # include <intrin.h>
 # pragma  intrinsic(_BitScanForward,_BitScanReverse)
 __forceinline static int __prBitScanForward32(unsigned int val)
@@ -32,7 +32,7 @@
 # define pr_bitscan_ctz32(val)  __prBitScanForward32(val)
 # define pr_bitscan_clz32(val)  __prBitScanReverse32(val)
 # define  PR_HAVE_BUILTIN_BITSCAN32
-#elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
+#elif defined __GNUC__ && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
        (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
         defined(__aarch64__))
 # define pr_bitscan_ctz32(val)  __builtin_ctz(val)
@@ -136,7 +136,7 @@
 */
 
 #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \
-    defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64))
+    defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64)) && !defined __clang__
 #include <stdlib.h>
 #pragma intrinsic(_rotl, _rotr)
 #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)
--- nss/lib/certdb/certdb.h
+++ nss/lib/certdb/certdb.h
@@ -21,7 +21,7 @@
 /* On Windows, Mac, and Linux (and other gcc platforms), we can give compile
  * time deprecation warnings when applications use the old CERTDB_VALID_PEER
  * define */
-#if __GNUC__ > 3
+#if defined __GNUC__ && __GNUC__ > 3
 #if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5)
 typedef unsigned int __CERTDB_VALID_PEER __attribute__((deprecated));
 #else
@@ -30,7 +30,7 @@
 #endif
 #define CERTDB_VALID_PEER ((__CERTDB_VALID_PEER)CERTDB_TERMINAL_RECORD)
 #else
-#ifdef _WIN32
+#if defined _WIN32 && !defined __clang__
 #pragma deprecated(CERTDB_VALID_PEER)
 #endif
 #define CERTDB_VALID_PEER CERTDB_TERMINAL_RECORD
--- nss/lib/util/pkcs11n.h
+++ nss/lib/util/pkcs11n.h
@@ -426,7 +426,7 @@
 /* keep the old value for compatibility reasons*/
 #define CKT_NSS_MUST_VERIFY ((__CKT_NSS_MUST_VERIFY)(CKT_NSS + 4))
 #else
-#ifdef _WIN32
+#if defined _WIN32 && !defined __clang__
 /* This magic gets the windows compiler to give us a deprecation
  * warning */
 #pragma deprecated(CKT_NSS_UNTRUSTED, CKT_NSS_MUST_VERIFY, CKT_NSS_VALID)

# While MSVC uses
#  #pragma warning(disable : 4103)
# in the inner pkcs11p.h, clang-cl wants
#  #pragma clang diagnostic ignored "-Wpragma-pack"
# in the outer pkcs11t.h:
--- nss/lib/util/pkcs11t.h
+++ nss/lib/util/pkcs11t.h
@@ -72,7 +72,14 @@
 #define CK_INVALID_HANDLE 0
 
 /* pack */
+#if defined __clang__ && defined _MSC_VER
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpragma-pack"
+#endif
 #include "pkcs11p.h"
+#if defined __clang__ && defined _MSC_VER
+#pragma clang diagnostic pop
+#endif
 
 typedef struct CK_VERSION {
     CK_BYTE major; /* integer portion of version number */
@@ -1795,6 +1802,13 @@
 #include "pkcs11n.h"
 
 /* undo packing */
+#if defined __clang__ && defined _MSC_VER
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpragma-pack"
+#endif
 #include "pkcs11u.h"
+#if defined __clang__ && defined _MSC_VER
+#pragma clang diagnostic pop
+#endif
 
 #endif