R: size of long on all supported arches

From: Nuno Teixeira <eduardo_at_freebsd.org>
Date: Fri, 19 Apr 2024 07:29:52 UTC
Hello all,

I'm testing a fix for tests on a R port (math/R-cran-RcppArmadillo):
https://github.com/RcppCore/RcppArmadillo/issues/408

Resuming: test is failing because "tolerance" needs to get adjusted to work:

---- FAILED[data]: test_cube.R<44--45>
   call| expect_equivalent(cx_fcube_test(cplx_cube), (cplx_cube^2),
tolerance = critTol)
   diff| Mean relative Mod difference: 1.512537e-07
  ----- FAILED[data]: test_cube.R<81--82>
   call| expect_equivalent(as_cx_fcube(cplx_cube), (cplx_cube^2),
tolerance = critTol)
   diff| Mean relative Mod difference: 1.512537e-07
  Error: 2 out of 314 tests failed

is fixed by patching:

 .onWindows <- .Platform$OS.type == "windows"
-critTol <- if (.onWindows) 1.0e-6 else 1.5e-7
+critTol <- if (.onWindows || .Machine$sizeof.long == 4 ||
.Machine$sizeof.long == 8) 1.0e-6 else 1.5e-7

i.e., setting "tolerance" to 1.0e-6 value, test is ok (on systems bellow)

With my hardware i7 and rpi4 I noted that long are:

amd64   .Machine$sizeof.long == 8
i386    .Machine$sizeof.long == 4
aarch64 .Machine$sizeof.long == 8
armv7   .Machine$sizeof.long == 4

and suppose that is the same to all 32/64 bit supported systems?

Upstream are sugesting using OS agnostic check to fix test, so, any better
approach or sugestion is welcome.

Thanks :)

-- 
Nuno Teixeira
FreeBSD Committer (ports)