Fix warnings when compiling codegen_*.c

Patch from davefiddes. Original commit message :

This fixes the following warnings:

codegen_allocator.c:
 - implict function declaration of rand() due to missing stdlib.h

codegen_backend_x86-64.c:
 - implict function declaration of malloc() due to missing stdlib.h
 - unused variables in codegen_backend_init()
 - invalid typecast in use of host_x86_CALL()

codegen_backend_x86-64-uop.c:
 - Remove unused variable declarations in codegen_CALL_FUNC_RESULT(),
   codegen_LOAD_SEG(), codegen_OR_IMM(), codegen_XOR() and codegen_XOR_IMM()
 - Move debug only variable declarations under the debug conditional define in
   codegen_CALL_FUNC_RESULT(), codegen_LOAD_SEG(), codegen_MEM_LOAD_SINGLE(),
   codegen_MEM_LOAD_DOUBLE(), codegen_MEM_STORE_SINGLE(),
   codegen_MEM_STORE_DOUBLE()

codegen_reg.c:
 - Change (int) typecasts to the correct (intptr_t) for small values stored
   in a pointer. This fixes a series of 64-bit compilation warnings.

Tests:
 - Build with no warnings on Fedora 32 with gcc 10.1
 - Boot a Win98 machine with dynamic compilation enabled
This commit is contained in:
SarahW 2020-07-14 19:54:15 +01:00
commit 9b737f65b1
4 changed files with 20 additions and 24 deletions

View file

@ -13,6 +13,7 @@
#if defined(__linux__) || defined(__APPLE__)
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#endif
#if defined WIN32 || defined _WIN32 || defined _WIN32
#include <windows.h>
@ -288,12 +289,6 @@ void codegen_backend_init()
{
codeblock_t *block;
int c;
#if defined(__linux__) || defined(__APPLE__)
void *start;
size_t len;
long pagesize = sysconf(_SC_PAGESIZE);
long pagemask = ~(pagesize - 1);
#endif
codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t));
codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *));
@ -322,7 +317,7 @@ void codegen_backend_init()
host_x86_XOR32_REG_REG(block, REG_EDI, REG_EDI);
host_x86_XOR32_REG_REG(block, REG_ESI, REG_ESI);
#endif
host_x86_CALL(block, (uintptr_t)x86gpf);
host_x86_CALL(block, (void *)x86gpf);
codegen_exit_rout = &codeblock[block_current].data[block_pos];
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x38);
host_x86_POP(block, REG_R15);