Commit a15fcb1e authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Just use a volatile static in Malloc.h

Summary: As suggested late in the initial diff (D5840883), just mark it volatile, as it works under all supported platforms.

Reviewed By: davidtgoldblatt, yfeldblum

Differential Revision: D6155241

fbshipit-source-id: 00c07a11dc7fc2e33c2d1f9a45fd28006eeff6f9
parent 760b0714
......@@ -183,15 +183,12 @@ FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept {
uint64_t origAllocated = *counter;
const void* ptr = malloc(1);
static const void* volatile ptr = malloc(1);
if (!ptr) {
// wtf, failing to allocate 1 byte
return false;
}
/* Avoid optimizing away the malloc. */
asm volatile("" ::"m"(ptr) : "memory");
return (origAllocated != *counter);
}();
......
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