Ignore:
Timestamp:
Dec 23, 2016, 1:14:39 PM (2 years ago)
Author:
nmedfort
Message:

Reverted last change to support gcc 4.9 prior to changing UCD property table structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/util/aligned_allocator.h

    r5235 r5236  
    33
    44#include <boost/version.hpp>
    5 #if BOOST_VERSION >= 105600
     5#if (BOOST_VERSION >= 105600)
    66#include <boost/align/aligned_allocator.hpp>
    7 template<typename T, unsigned Align>
    8 using AlignedAllocator = boost::alignment::aligned_allocator<T, Align>;
     7template<typename T, unsigned alignment>
     8using AlignedAllocator = boost::alignment::aligned_allocator<T, alignment>;
    99#else
    10 
    11 template <typename T, unsigned Align>
    12 class AlignedAllocator
    13 {
     10#include <stdlib.h>
     11template <typename T, unsigned alignment>
     12class AlignedAllocator {
     13    static_assert ((alignment & (alignment - 1)) == 0, "alignment must be power of two");
    1414public:
    1515    typedef T         value_type;
     
    2222
    2323    template <class U>
    24     struct rebind { typedef AlignedAllocator<U, Align> other; };
     24    struct rebind { typedef AlignedAllocator<U, alignment> other; };
    2525
    2626public:
    2727    AlignedAllocator() noexcept {}
    2828
    29     pointer allocate(size_type n, const_pointer = 0) {
     29    pointer allocate(const size_type n, const_pointer = 0) {
    3030        const auto size = n * sizeof(T);
    3131        if (size == 0) {
     
    3333        }
    3434        void * ptr = nullptr;
    35         int rc = posix_memalign(&ptr, Align, size);
    36         if (rc != 0) {
     35        if (LLVM_UNLIKELY(::posix_memalign(&ptr, alignment, size) != 0)) {
    3736            throw std::bad_alloc();
    3837        }
     38        assert (ptr && (reinterpret_cast<size_t>(ptr) & (alignment - 1)) == 0);
    3939        return reinterpret_cast<pointer>(ptr);
    4040    }
    4141
    42     template<typename Type, unsigned align>
    43     inline bool operator==(AlignedAllocator<Type, align> const &) {
     42    template<typename U, unsigned align>
     43    inline bool operator==(const AlignedAllocator<U, align> &) const {
    4444        return false;
    4545    }
    4646
    47     template<typename Type, unsigned align>
    48     inline bool operator!=(AlignedAllocator<Type, align> const &) {
     47    template<typename U, unsigned align>
     48    inline bool operator!=(const AlignedAllocator<U, align> &) const {
    4949        return true;
    5050    }
    5151
    52 
    5352    void deallocate(pointer p, size_type) noexcept {
    54         return free(p);
     53        return ::free(p);
    5554    }
    5655};
    57 
    5856#endif
    59 
    60 
    61 
    6257#endif // ALIGNED_ALLOCATOR_H
Note: See TracChangeset for help on using the changeset viewer.