Skip to content

Commit

Permalink
Issue #2378 & #2051 - Part 4 - Remove unused moz_xposix_memalign().
Browse files Browse the repository at this point in the history
Also switch to using HAVE_POSIX_MEMALIGN for Mac PowerPC tests.
When there is no posix_memalign() on Mac, just call malloc().
  • Loading branch information
dbsoft committed Nov 23, 2023
1 parent af52fd4 commit 9dfc190
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
11 changes: 0 additions & 11 deletions memory/mozalloc/mozalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,6 @@ moz_xstrndup(const char* str, size_t strsize)

#if defined(HAVE_POSIX_MEMALIGN)
int
moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
{
int err = posix_memalign_impl(ptr, alignment, size);
if (MOZ_UNLIKELY(err && ENOMEM == err)) {
mozalloc_handle_oom(size);
return moz_xposix_memalign(ptr, alignment, size);
}
// else: (0 == err) or (EINVAL == err)
return err;
}
int
moz_posix_memalign(void **ptr, size_t alignment, size_t size)
{
int code = posix_memalign_impl(ptr, alignment, size);
Expand Down
3 changes: 0 additions & 3 deletions memory/mozalloc/mozalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ MFBT_API char* moz_xstrndup(const char* str, size_t strsize)


#if defined(HAVE_POSIX_MEMALIGN)
MFBT_API __attribute__ ((warn_unused_result))
int moz_xposix_memalign(void **ptr, size_t alignment, size_t size);

MFBT_API __attribute__ ((warn_unused_result))
int moz_posix_memalign(void **ptr, size_t alignment, size_t size);
#endif /* if defined(HAVE_POSIX_MEMALIGN) */
Expand Down
6 changes: 5 additions & 1 deletion memory/mozjemalloc/jemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5869,7 +5869,11 @@ MOZ_MEMORY_API
void *
MEMALIGN(size_t alignment, size_t size)
{
#if defined(MOZ_MEMORY_DARWIN) && !defined(__ppc__)
#if defined(MOZ_MEMORY_DARWIN) && !defined(HAVE_POSIX_MEMALIGN)
// If we don't have memalign, like on 10.5 just use malloc
// it should be 16 byte aligned and jemalloc is not enabled.
return malloc(size);
#else
DARWIN_ONLY(return (szone->memalign)(szone, alignment, size));
#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:
#if !defined(__ppc__)
#ifdef HAVE_POSIX_MEMALIGN
(void)moz_posix_memalign(&mBuf, aAlignment, aSize);
#else
// 10.4 doesn't have memalign, but our malloc()s are always aligned to
Expand Down

0 comments on commit 9dfc190

Please sign in to comment.