Skip to content

Commit

Permalink
Update GCC implementation of assume_aligned
Browse files Browse the repository at this point in the history
Allow use with pointer types other than void pointers.
  • Loading branch information
glenfe committed Feb 7, 2016
1 parent 1f82968 commit df0e5ea
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/boost/align/detail/assume_aligned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ License, Version 1.0.
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_HPP

#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment)
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n)

#endif
6 changes: 3 additions & 3 deletions include/boost/align/detail/assume_aligned_clang.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ License, Version 1.0.
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_CLANG_HPP

#if __has_builtin(__builtin_assume_aligned)
#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) \
(ptr) = __builtin_assume_aligned((ptr), (alignment))
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
(ptr) = __builtin_assume_aligned((p), (n))
#else
#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment)
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n)
#endif

#endif
4 changes: 2 additions & 2 deletions include/boost/align/detail/assume_aligned_gcc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ License, Version 1.0.
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_GCC_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_GCC_HPP

#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) \
(ptr) = __builtin_assume_aligned((ptr), (alignment))
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
(p) = static_cast<typeof(p)>(__builtin_assume_aligned((p), (n)))

#endif
4 changes: 2 additions & 2 deletions include/boost/align/detail/assume_aligned_intel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ License, Version 1.0.
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_INTEL_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_INTEL_HPP

#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) \
__assume_aligned((ptr), (alignment))
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
__assume_aligned((p), (n))

#endif
4 changes: 2 additions & 2 deletions include/boost/align/detail/assume_aligned_msvc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ License, Version 1.0.

#include <cstddef>

#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) \
__assume((reinterpret_cast<std::size_t>(ptr) & ((alignment) - 1)) == 0)
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
__assume((reinterpret_cast<std::size_t>(p) & ((n) - 1)) == 0)

#endif

0 comments on commit df0e5ea

Please sign in to comment.