diff options
author | Peter Maydell | 2022-02-26 19:07:21 +0100 |
---|---|---|
committer | Peter Maydell | 2022-03-07 14:16:05 +0100 |
commit | 88454f844efe26ea8ac7f394a72b1e6620dccf7e (patch) | |
tree | a4cb9fee7fe522abba9ffd71a427f14dbcecb7e6 /util | |
parent | util: Share qemu_try_memalign() implementation between POSIX and Windows (diff) | |
download | qemu-88454f844efe26ea8ac7f394a72b1e6620dccf7e.tar.gz qemu-88454f844efe26ea8ac7f394a72b1e6620dccf7e.tar.xz qemu-88454f844efe26ea8ac7f394a72b1e6620dccf7e.zip |
util: Use meson checks for valloc() and memalign() presence
Instead of assuming that all CONFIG_BSD have valloc() and anything
else is memalign(), explicitly check for those functions in
meson.build and use the "is the function present" define. Tests for
specific functionality are better than which-OS checks; this also
lets us give a helpful error message if somehow there's no usable
function present.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20220226180723.1706285-8-peter.maydell@linaro.org
Diffstat (limited to 'util')
-rw-r--r-- | util/memalign.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/util/memalign.c b/util/memalign.c index 22b405700e..083aaae619 100644 --- a/util/memalign.c +++ b/util/memalign.c @@ -56,10 +56,12 @@ void *qemu_try_memalign(size_t alignment, size_t size) } #elif defined(CONFIG_ALIGNED_MALLOC) ptr = _aligned_malloc(size, alignment); -#elif defined(CONFIG_BSD) +#elif defined(CONFIG_VALLOC) ptr = valloc(size); -#else +#elif defined(CONFIG_MEMALIGN) ptr = memalign(alignment, size); +#else + #error No function to allocate aligned memory available #endif trace_qemu_memalign(alignment, size, ptr); return ptr; |