File: fix-ftbfs-on-32bit.patch

package info (click to toggle)
r-cran-s2 1.1.7-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 9,316 kB
  • sloc: cpp: 96,702; pascal: 1,362; ansic: 37; sh: 15; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,339 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
Description: Fix BN_ext_get_uint64 for OpenSSL >= 1.1 32bit
 Suggested changes fix compilation error with OpenSSL >= 1.0 for 32bit target.
 The algorithm is similar to what is currently being done in BN_ext_set_uint64,
 but in the opposite direction.
Author: Konstantin Podsirov
Origin: upstream
Bug: https://github.com/google/s2geometry/pull/183
Forwarded: no
Reviewed-by: Étienne Mollier <emollier@debian.org>
Last-Update: 2021-10-04
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/s2/util/math/exactfloat/exactfloat.cc
+++ b/src/s2/util/math/exactfloat/exactfloat.cc
@@ -75,6 +75,22 @@ inline static uint64 BN_ext_get_uint64(c
   return u64;
 }
 
+// Return the absolute value of a BIGNUM as a 64-bit unsigned integer.
+// Requires that BIGNUM fits into 64 bits.
+inline static uint64 BN_ext_get_uint64(const BIGNUM* bn) {
+  uint64 r;
+#ifdef IS_LITTLE_ENDIAN
+  S2_CHECK_EQ(BN_bn2lebinpad(bn, reinterpret_cast<unsigned char*>(&r),
+              sizeof(r)), sizeof(r));
+#elif IS_BIG_ENDIAN
+  S2_CHECK_EQ(BN_bn2binpad(bn, reinterpret_cast<unsigned char*>(&r),
+              sizeof(r)), sizeof(r));
+#else
+#error one of IS_LITTLE_ENDIAN or IS_BIG_ENDIAN should be defined!
+#endif
+  return r;
+}
+
 static int BN_ext_count_low_zero_bits(const BIGNUM* bn) {
   return BN_count_low_zero_bits(bn);
 }