Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
Bug 1423107 - Replace uses of moz_posix_memalign with posix_memalign.…
Browse files Browse the repository at this point in the history
… r=njn

moz_posix_memalign is a wrapper for posix_memalign that only exists if
posix_memalign exists.

On OSX, it has a fallback for an under-specified bug where it
purportedly returns a pointer that doesn't have the requested alignment.
That fallback was added in bug 414946, over 6 years ago, before jemalloc
was even enabled on OSX.

Considering posix_memalign is used directly in many other places in
Gecko, that we almost always use mozjemalloc, which doesn't have these
problems, and that in all likeliness, the bug was in some old version of
OSX that is not supported anymore, the fallback does not seem all that
useful.

So, just use posix_memalign directly.
  • Loading branch information
glandium committed Dec 5, 2017
1 parent 167d085 commit 62456c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions gfx/thebes/gfxImageSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ TryAllocAlignedBytes(size_t aSize)
void* ptr;
// Try to align for fast alpha recovery. This should only help
// cairo too, can't hurt.
return moz_posix_memalign(&ptr,
1 << gfxAlphaRecovery::GoodAlignmentLog2(),
aSize) ?
return posix_memalign(&ptr,
1 << gfxAlphaRecovery::GoodAlignmentLog2(),
aSize) ?
nullptr : ptr;
#else
// Oh well, hope that luck is with us in the allocator
Expand Down
6 changes: 1 addition & 5 deletions memory/volatile/VolatileBufferFallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ bool VolatileBuffer::Init(size_t aSize, size_t aAlignment)
"Alignment must be multiple of pointer size");

mSize = aSize;
#if defined(MOZ_MEMORY)
#if defined(MOZ_MEMORY) || defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign(&mBuf, aAlignment, aSize) != 0) {
return false;
}
#elif defined(HAVE_POSIX_MEMALIGN)
if (moz_posix_memalign(&mBuf, aAlignment, aSize) != 0) {
return false;
}
#else
#error "No memalign implementation found"
#endif
Expand Down
2 changes: 1 addition & 1 deletion memory/volatile/VolatileBufferOSX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ VolatileBuffer::Init(size_t aSize, size_t aAlignment)
}

heap_alloc:
(void)moz_posix_memalign(&mBuf, aAlignment, aSize);
(void)posix_memalign(&mBuf, aAlignment, aSize);
mHeap = true;
return !!mBuf;
}
Expand Down

0 comments on commit 62456c9

Please sign in to comment.