Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Leibner
dune-common
Commits
2c5b0eee
Commit
2c5b0eee
authored
7 years ago
by
Simon Praetorius
Browse files
Options
Downloads
Patches
Plain Diff
Better test whether standard library supports aligned_alloc()
parent
99d1dc26
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmake/modules/CheckCXXFeatures.cmake
+11
-0
11 additions, 0 deletions
cmake/modules/CheckCXXFeatures.cmake
config.h.cmake
+3
-0
3 additions, 0 deletions
config.h.cmake
dune/common/alignedallocator.hh
+6
-2
6 additions, 2 deletions
dune/common/alignedallocator.hh
with
20 additions
and
2 deletions
cmake/modules/CheckCXXFeatures.cmake
+
11
−
0
View file @
2c5b0eee
...
...
@@ -484,6 +484,17 @@ check_cxx_source_compiles("
"
DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR
)
# Check whether the stadard library supports aligned_alloc()
check_cxx_source_compiles
(
"
#include <cstdlib>
int main()
{
int* p = static_cast<int*>(aligned_alloc(64, 64*sizeof *p));
}
"
DUNE_HAVE_C_ALIGNED_ALLOC
)
# ******************************************************************************
#
...
...
This diff is collapsed.
Click to expand it.
config.h.cmake
+
3
−
0
View file @
2c5b0eee
...
...
@@ -35,6 +35,9 @@
/* does the compiler support conditionally throwing exceptions in constexpr context? */
#cmakedefine DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR 1
/* does the standard library provides
aligned_alloc
()
? */
#cmakedefine DUNE_HAVE_C_ALIGNED_ALLOC 1
/* does the standard library provide <experimental/type_traits> ? */
#cmakedefine DUNE_HAVE_HEADER_EXPERIMENTAL_TYPE_TRAITS 1
...
...
This diff is collapsed.
Click to expand it.
dune/common/alignedallocator.hh
+
6
−
2
View file @
2c5b0eee
...
...
@@ -6,6 +6,10 @@
#include
"mallocallocator.hh"
#include
<cstdlib>
#if !(DUNE_HAVE_C_ALIGNED_ALLOC || (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600))
#error Need either aligned_alloc() or posix_memalign() to compile AlignedAllocator
#endif
namespace
Dune
{
...
...
@@ -19,7 +23,7 @@ namespace Dune
template
<
class
T
,
int
Alignment
=
-
1
>
class
AlignedAllocator
:
public
MallocAllocator
<
T
>
{
#if
__APPLE__
#if
!DUNE_HAVE_C_ALIGNED_ALLOC
/*
* posix_memalign() on macOS has pretty draconian restrictions on the
...
...
@@ -67,7 +71,7 @@ namespace Dune
if
(
n
>
this
->
max_size
())
throw
std
::
bad_alloc
();
#if
__APPLE__
#if
!DUNE_HAVE_C_ALIGNED_ALLOC
/*
* Apple's standard library doesn't have aligned_alloc() - C11 is still something
* from the future in Cupertino. Luckily, they got around to finally implementing
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment