File: nan-hppa-mips.patch

package info (click to toggle)
libcbor 0.10.2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,440 kB
  • sloc: ansic: 8,540; makefile: 157; cpp: 101; python: 90; sh: 81; ruby: 6
file content (57 lines) | stat: -rw-r--r-- 2,094 bytes parent folder | download | duplicates (2)
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
--- a/test/float_ctrl_encoders_test.c.org	2024-04-27 14:49:38.175261711 +0000
+++ b/test/float_ctrl_encoders_test.c	2024-04-27 14:59:12.825184338 +0000
@@ -9,6 +9,16 @@
 #include "assertions.h"
 #include "cbor.h"
 
+/* In NaNs generated by the PA-RISC and old MIPS processors, the
+ * signaling/quiet bit is zero if the NaN is quiet, and non-zero if the NaN is
+ * signaling. Thus the binary representation is different to other
+ * architectures. See encoding section at https://en.wikipedia.org/wiki/NaN */
+#if defined(__hppa__) || defined(__mips__)
+#define ARCH_WITH_STD_IEEE_754_NAN	0
+#else
+#define ARCH_WITH_STD_IEEE_754_NAN	1
+#endif
+
 unsigned char buffer[512];
 
 static void test_bools(void **_CBOR_UNUSED(_state)) {
@@ -147,13 +157,15 @@
                       5);
 
   assert_size_equal(5, cbor_encode_single(NAN, buffer, 512));
-  assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x00}),
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+	  assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x00}),
                       5);
 
 #ifndef _WIN32
   // TODO: https://github.com/PJK/libcbor/issues/271
   assert_size_equal(5, cbor_encode_single(nanf("3"), buffer, 512));
-  assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x03}),
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+  	assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x03}),
                       5);
 #endif
 
@@ -174,7 +186,8 @@
       9);
 
   assert_size_equal(9, cbor_encode_double(nan(""), buffer, 512));
-  assert_memory_equal(
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+    assert_memory_equal(
       buffer,
       ((unsigned char[]){0xFB, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}),
       9);
@@ -182,7 +195,8 @@
 #ifndef _WIN32
   // TODO: https://github.com/PJK/libcbor/issues/271
   assert_size_equal(9, cbor_encode_double(nan("3"), buffer, 512));
-  assert_memory_equal(
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+    assert_memory_equal(
       buffer,
       ((unsigned char[]){0xFB, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}),
       9);