Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memcpy test fix build warning on openbsd. #714

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/test/func/memory/memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@
#include <test/xoroshiro.h>
#include <unordered_set>
#include <vector>
#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.
* QEMU `setrlimit64` does not behave as the same as native linux,
* so we need to exclude it from such tests.
*/
# include <sys/resource.h>
# include <sys/sysinfo.h>
# ifndef __OpenBSD__
# include <sys/sysinfo.h>
# endif
# include <sys/wait.h>
# include <unistd.h>
# 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
Expand All @@ -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))
Expand All @@ -59,6 +66,7 @@ void test_limited(rlim64_t as_limit, size_t& count)
upper_bound = std::min(
upper_bound, static_cast<unsigned long long>(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);
Expand Down
7 changes: 7 additions & 0 deletions src/test/perf/memcpy/memcpy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Shape> allocs;
Expand Down
Loading