Commit 06e67a82da7b0d2bb2bdada0ec7122032a330312
1 parent
a876e289
Allocate code gen buffer properly on FreeBSD
Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5331 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
22 additions
and
0 deletions
exec.c
... | ... | @@ -443,6 +443,28 @@ static void code_gen_alloc(unsigned long tb_size) |
443 | 443 | exit(1); |
444 | 444 | } |
445 | 445 | } |
446 | +#elif defined(__FreeBSD__) | |
447 | + { | |
448 | + int flags; | |
449 | + void *addr = NULL; | |
450 | + flags = MAP_PRIVATE | MAP_ANONYMOUS; | |
451 | +#if defined(__x86_64__) | |
452 | + /* FreeBSD doesn't have MAP_32BIT, use MAP_FIXED and assume | |
453 | + * 0x40000000 is free */ | |
454 | + flags |= MAP_FIXED; | |
455 | + addr = (void *)0x40000000; | |
456 | + /* Cannot map more than that */ | |
457 | + if (code_gen_buffer_size > (800 * 1024 * 1024)) | |
458 | + code_gen_buffer_size = (800 * 1024 * 1024); | |
459 | +#endif | |
460 | + code_gen_buffer = mmap(addr, code_gen_buffer_size, | |
461 | + PROT_WRITE | PROT_READ | PROT_EXEC, | |
462 | + flags, -1, 0); | |
463 | + if (code_gen_buffer == MAP_FAILED) { | |
464 | + fprintf(stderr, "Could not allocate dynamic translator buffer\n"); | |
465 | + exit(1); | |
466 | + } | |
467 | + } | |
446 | 468 | #else |
447 | 469 | code_gen_buffer = qemu_malloc(code_gen_buffer_size); |
448 | 470 | if (!code_gen_buffer) { | ... | ... |