Changeset 5466 for icGREP/icgrep-devel


Ignore:
Timestamp:
May 22, 2017, 1:18:11 PM (2 years ago)
Author:
nmedfort
Message:

AlignedMalloc? now uses posix_memalign if aligned_alloc does not exist in stdlib.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.cpp

    r5465 r5466  
    238238}
    239239
     240#ifndef STDLIB_HAS_ALIGNED_ALLOC
     241void * aligned_alloc(const size_t alignment, const size_t size) {
     242    void * ptr;
     243    if (LLVM_UNLIKELY(::posix_memalign(&ptr, alignment, size) != 0)) {
     244        throw std::bad_alloc();
     245    }
     246    return ptr;
     247}
     248#endif
     249
    240250Value * CBuilder::CreateAlignedMalloc(Value * size, const unsigned alignment) {
    241251    if (LLVM_UNLIKELY((alignment & (alignment - 1)) != 0)) {
     
    246256    IntegerType * const sizeTy = getSizeTy();
    247257    if (LLVM_UNLIKELY(f == nullptr)) {
    248 //        PointerType * const voidPtrTy = getVoidPtrTy();
    249 //        FunctionType * const fty = FunctionType::get(voidPtrTy, {sizeTy, sizeTy}, false);
    250 //        f = Function::Create(fty, Function::ExternalLinkage, "aligned_alloc", m);
    251 //        f->setCallingConv(CallingConv::C);
    252 //        f->setDoesNotAlias(0);
    253258        f = LinkFunction("aligned_alloc", &aligned_alloc);
    254259    }
Note: See TracChangeset for help on using the changeset viewer.