git: e408af5b1b45 - main - math/clrng: make portable

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sun, 06 Sep 2026 16:17:57 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e408af5b1b452bf7dcbc47d1e1fa8bc268e98488

commit e408af5b1b452bf7dcbc47d1e1fa8bc268e98488
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2026-09-06 13:32:50 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-09-06 16:16:59 +0000

    math/clrng: make portable
    
    No architecture restriction is apparent.
    Lift the artificial road block and fix a minor issue preventing
    compilation on armv7.
    
    Event:          Berlin Hackathon 202609
---
 math/clrng/Makefile                                |  3 ---
 ...nclude_private_Random123_features_gccfeatures.h | 18 ++++++++++---
 math/clrng/files/patch-src_library_mrg32k3a.c      | 30 ++++++++++++++++++++++
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/math/clrng/Makefile b/math/clrng/Makefile
index 100cf831a945..b2b80b038c99 100644
--- a/math/clrng/Makefile
+++ b/math/clrng/Makefile
@@ -14,9 +14,6 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 DEPRECATED=	Abandoned upstream, does not build with CMake 4
 EXPIRATION_DATE=2026-11-30
 
-ONLY_FOR_ARCHS=		amd64 i386 powerpc powerpc64 powerpc64le powerpcspe
-ONLY_FOR_ARCHS_REASON=	this code has only been tested on x86 and powerpc platforms
-
 BUILD_DEPENDS=	opencl>=0:devel/opencl
 LIB_DEPENDS=	libOpenCL.so:devel/ocl-icd
 RUN_DEPENDS=	opencl>=0:devel/opencl
diff --git a/math/clrng/files/patch-src_cl_include_private_Random123_features_gccfeatures.h b/math/clrng/files/patch-src_cl_include_private_Random123_features_gccfeatures.h
index b5e36d2787a1..a65152d63e68 100644
--- a/math/clrng/files/patch-src_cl_include_private_Random123_features_gccfeatures.h
+++ b/math/clrng/files/patch-src_cl_include_private_Random123_features_gccfeatures.h
@@ -1,8 +1,18 @@
---- src/cl/include/private/Random123/features/gccfeatures.h.orig	2020-01-02 12:50:28 UTC
+--- src/cl/include/private/Random123/features/gccfeatures.h.orig	2015-05-01 01:08:38 UTC
 +++ src/cl/include/private/Random123/features/gccfeatures.h
-@@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
-  Please let the authors know of any successes (or failures). */
- #endif
+@@ -34,17 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
+ 
+ #define R123_GNUC_VERSION (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
+ 
+-#if !defined(__x86_64__) && !defined(__i386__) && !defined(__powerpc__)
+-#  error "This code has only been tested on x86 and powerpc platforms."
+-#include <including_a_nonexistent_file_will_stop_some_compilers_from_continuing_with_a_hopeless_task>
+-{ /* maybe an unbalanced brace will terminate the compilation */
+- /* Feel free to try the Random123 library on other architectures by changing
+- the conditions that reach this error, but you should consider it a
+- porting exercise and expect to encounter bugs and deficiencies.
+- Please let the authors know of any successes (or failures). */
+-#endif
  
 -#ifdef __powerpc__
 +#if defined(__powerpc__) && !defined(__clang__)
diff --git a/math/clrng/files/patch-src_library_mrg32k3a.c b/math/clrng/files/patch-src_library_mrg32k3a.c
new file mode 100644
index 000000000000..161f0cd2300d
--- /dev/null
+++ b/math/clrng/files/patch-src_library_mrg32k3a.c
@@ -0,0 +1,30 @@
+--- src/library/mrg32k3a.c.orig	2026-09-06 13:27:06 UTC
++++ src/library/mrg32k3a.c
+@@ -404,21 +404,21 @@ clrngStatus clrngMrg32k3aWriteStreamInfo(const clrngMr
+ 	// The Initial state of the Stream
+ 	fprintf(file, "\n   initial = { ");
+ 	for (size_t i = 0; i < 3; i++)
+-		fprintf(file, "%lu, ", stream->initial.g1[i]);
++		fprintf(file, "%ju, ", (uintmax_t)stream->initial.g1[i]);
+ 
+ 	for (size_t i = 0; i < 2; i++)
+-		fprintf(file, "%lu, ", stream->initial.g2[i]);
++		fprintf(file, "%ju, ", (uintmax_t)stream->initial.g2[i]);
+ 
+-	fprintf(file, "%lu }\n", stream->initial.g2[2]);
++	fprintf(file, "%ju }\n", (uintmax_t)stream->initial.g2[2]);
+ 	//The Current state of the Stream
+ 	fprintf(file, "\n   Current = { ");
+ 	for (size_t i = 0; i < 3; i++)
+-		fprintf(file, "%lu, ", stream->current.g1[i]);
++		fprintf(file, "%ju, ", (uintmax_t)stream->current.g1[i]);
+ 
+ 	for (size_t i = 0; i < 2; i++)
+-		fprintf(file, "%lu, ", stream->current.g2[i]);
++		fprintf(file, "%ju, ", (uintmax_t)stream->current.g2[i]);
+ 
+-	fprintf(file, "%lu }\n", stream->current.g2[2]);
++	fprintf(file, "%ju }\n", (uintmax_t)stream->current.g2[2]);
+ 
+ 	return CLRNG_SUCCESS;
+ }