Skip to content

Commit 24d05b9

Browse files
committed
Tweak memory allocation size for portability
Close #161
1 parent d8d4bd1 commit 24d05b9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/io.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,19 @@
1616

1717
#include "io.h"
1818

19+
1920
static uint8_t *data_memory_base;
20-
/* set memory size to 2^32 bytes */
21-
#define MEM_SIZE 0x100000000ULL
21+
/*
22+
* set memory size to 2^32 - 1 bytes
23+
*
24+
* The memory size is set to 2^32 - 1 bytes in order
25+
* to make rv32emu portable for both 32-bit and 64-bit platforms.
26+
* As a result, rv32emu can access any segment of the memory in
27+
* either platform. Furthermore, it is safe because most of the 
28+
* test cases' data memory usage will not exceed this memory size.
29+
*
30+
*/
31+
#define MEM_SIZE 0xFFFFFFFFULL
2232

2333
memory_t *memory_new()
2434
{

0 commit comments

Comments
 (0)