Skip to content
Snippets Groups Projects

Better test whether standard library supports aligned_alloc()

This fixes #111 (closed)

Summary

Added a cmake compile-test to check whether the used standard library provides the function aligned_alloc(). The Dune::AlignedAllocator implementation is adapted, using the introduced config variable DUNE_HAVE_C_ALIGNED_ALLOC.

Motivation

I have added a cmake test for standard library function aligned_alloc() since it cannot be detected in the code whether this function exists. The old test #if __APPLE__ was not enough. E.g. on our cluster, the standard library does not support aligned_alloc() for some reasons and thus, the compile fails to compile the AlignedAllocator, although there are alternatives already implemented.

TODO

Additionally, I've added an error message if neither aligned_alloc nor posix_memalign is available on a system. But, since I do not have an Apple system I cannot test this completely.

The branch can be merged when someone confirms, that the condition

#if !(DUNE_HAVE_C_ALIGNED_ALLOC || (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600))

works fine on systems with Apple's standard library. This test assumes that a posix library of a minimal version always provides the posix_memalign() function.

Maybe an additional cmake compile-test should be added to test for this function as well.

Edited by Simon Praetorius

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading