Conversation
|
cc @tekknolagi |
|
Nice catch. Some duplicated code - I'll check on Monday |
|
Might be able to define _GNU_SOURCE to fix instead |
|
Thanks. I'm waiting for the fix by @tekknolagi, and will release a new |
|
@Morriar I recommend looking into a fix with _GNU_SOURCE--it's likely the platform has MAP_ANONYMOUS but is pretending not to If not, then we should at least drop the _WIN32 branch of the ifdef (it's otherwise handled by map_memory) and inline this whole thing into map_memory |
src/util/rbs_allocator.c
Outdated
| #ifdef _WIN32 | ||
| ptr = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | ||
| if (ptr == NULL) return NULL; |
There was a problem hiding this comment.
| #ifdef _WIN32 | |
| ptr = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | |
| if (ptr == NULL) return NULL; |
src/util/rbs_allocator.c
Outdated
| ptr = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | ||
| if (ptr == NULL) return NULL; | ||
| #elif defined(MAP_ANONYMOUS) | ||
| ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); |
There was a problem hiding this comment.
| ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); | |
| return mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); |
src/util/rbs_allocator.c
Outdated
| #elif defined(MAP_ANONYMOUS) | ||
| ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); | ||
| #elif defined(MAP_ANON) | ||
| ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0); |
There was a problem hiding this comment.
| ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0); | |
| return mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0); |
src/util/rbs_allocator.c
Outdated
| #else | ||
| /* Fallback to /dev/zero for systems without anonymous mapping */ | ||
| int fd = open("/dev/zero", O_RDWR); | ||
| if (fd == -1) return MAP_FAILED; |
There was a problem hiding this comment.
Masking as MAP_FAILED is a little gross imo; have it have its own assert
a23c761 to
aa34584
Compare
|
Nice! |
|
@soutaro This PR should pass all compilation builds now 😄 |
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
|
@soutaro I've rebased this branch. It should be good to go now |
Trying fix for ruby/ruby#13237 (comment)