From 1330dd5a16ec1054053c7c391edc54c5ea81721f Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 18 Dec 2024 04:41:10 +0000 Subject: [PATCH 1/2] memcpy test fix build warning on openbsd. --- src/test/perf/memcpy/memcpy.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/perf/memcpy/memcpy.cc b/src/test/perf/memcpy/memcpy.cc index 763dcd72e..d726ea429 100644 --- a/src/test/perf/memcpy/memcpy.cc +++ b/src/test/perf/memcpy/memcpy.cc @@ -13,7 +13,14 @@ struct Shape size_t my_random() { +#ifndef __OpenBSD__ return (size_t)rand(); +#else + // OpenBSD complains on rand() usage + // we let it know we purposely want + // deterministic randomness here + return (size_t)lrand48(); +#endif } std::vector allocs; From 757846dea49e0328ad1558df00b4d2573d2f832c Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 18 Dec 2024 04:54:00 +0000 Subject: [PATCH 2/2] enabling TEST_LIMITED for openbsd too. --- src/test/func/memory/memory.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/test/func/memory/memory.cc b/src/test/func/memory/memory.cc index 7d176f43d..c85659eab 100644 --- a/src/test/func/memory/memory.cc +++ b/src/test/func/memory/memory.cc @@ -5,8 +5,8 @@ #include #include #include -#if ((defined(__linux__) && !defined(__ANDROID__)) || defined(__sun)) && \ - !defined(SNMALLOC_QEMU_WORKAROUND) +#if ((defined(__linux__) && !defined(__ANDROID__)) || defined(__sun)) || \ + defined(__OpenBSD__) && !defined(SNMALLOC_QEMU_WORKAROUND) /* * We only test allocations with limited AS on linux and Solaris for now. * It should be a good representative for POSIX systems. @@ -14,13 +14,19 @@ * so we need to exclude it from such tests. */ # include -# include +# ifndef __OpenBSD__ +# include +# endif # include # include # define TEST_LIMITED # define KiB (1024ull) # define MiB (KiB * KiB) # define GiB (KiB * MiB) + +# ifdef __OpenBSD__ +using rlim64_t = rlim_t; +# endif #else using rlim64_t = size_t; #endif @@ -45,6 +51,7 @@ void test_limited(rlim64_t as_limit, size_t& count) } std::cout << "limiting memory to " << limit.rlim_cur / KiB << " KiB" << std::endl; +# ifndef __OpenBSD__ struct sysinfo info {}; if (sysinfo(&info)) @@ -59,6 +66,7 @@ void test_limited(rlim64_t as_limit, size_t& count) upper_bound = std::min( upper_bound, static_cast(info.freeram >> 3u)); std::cout << "trying to alloc " << upper_bound / KiB << " KiB" << std::endl; +# endif auto& alloc = ThreadAlloc::get(); std::cout << "allocator initialised" << std::endl; auto chunk = alloc.alloc(upper_bound);