git: 7c2beee51d07 - main - benchmarks/netperfmeter: Fix build with -DNDEBUG defined

From: Daniel Engberg <diizzy_at_FreeBSD.org>
Date: Thu, 20 Oct 2022 09:24:16 UTC
The branch main has been updated by diizzy:

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

commit 7c2beee51d072ab185dd5186b2fd9d6eda4b7dfc
Author:     Daniel Engberg <diizzy@FreeBSD.org>
AuthorDate: 2022-10-20 09:21:33 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2022-10-20 09:24:09 +0000

    benchmarks/netperfmeter: Fix build with -DNDEBUG defined
    
    Disable usage of OMNeT++ random generator when -DNDEBUG is defined
    
    PR:             266721
    Reported by:    antoine (via exp-run)
    Approved by:    portmgr (build fix)
---
 benchmarks/netperfmeter/files/patch-src_tools.cc | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/benchmarks/netperfmeter/files/patch-src_tools.cc b/benchmarks/netperfmeter/files/patch-src_tools.cc
new file mode 100644
index 000000000000..8007c7c87668
--- /dev/null
+++ b/benchmarks/netperfmeter/files/patch-src_tools.cc
@@ -0,0 +1,25 @@
+--- src/tools.cc.orig	2022-10-20 09:17:55 UTC
++++ src/tools.cc
+@@ -1135,11 +1135,13 @@ uint64_t random64()
+ /* ###### Get 32-bit random value ######################################## */
+ uint32_t random32()
+ {
++/*
+ #ifdef NDEBUG
+ #warning Using OMNeT++ random generator instead of time-seeded one!
+    const double value = uniform(0.0, (double)0xffffffff);
+    return((uint32_t)rint(value));
+ #else
++*/
+    uint32_t number;
+ 
+    switch(RandomSource) {
+@@ -1165,7 +1167,7 @@ uint32_t random32()
+    const uint16_t a = random() & 0xffff;
+    const uint16_t b = random() & 0xffff;
+    return( (((uint32_t)a) << 16) | (uint32_t)b );
+-#endif
++
+ }
+ 
+