Commit 8ddf4174 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo

Linker: Fix type in m32_free_internal

The code:

    uint64_t c = __sync_sub_and_fetch((uint64_t*)addr, 1);

was causing GCC to emit atomic instructions for 64 bit values which
are not available on PowerPC. However, since PowerPC only has a 32
bit address space, use of a 64 bit value is superflous.

Switching the type from `uint64_t` to `uintptr_t` should simply do
the correct thing on all 32 and 64 bit architectures.

Reviewers: austin, bgamari, simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1399

GHC Trac Issues: #11036
parent e272ab99
......@@ -1217,7 +1217,7 @@ static void m32_allocator_init(m32_allocator m32) {
* You shouldn't have to use this method. Use `m32_free` instead.
*/
static void m32_free_internal(void * addr) {
uint64_t c = __sync_sub_and_fetch((uint64_t*)addr, 1);
uintptr_t c = __sync_sub_and_fetch((uintptr_t*)addr, 1);
if (c == 0) {
munmapForLinker(addr, getPageSize());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment