Skip to content

Commit 2a6660b

Browse files
committed
extmod/modmachine: Avoid conflicts with system PAGE_SIZE define, if any.
1 parent 1abb449 commit 2a6660b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

extmod/modmachine.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
#include <errno.h>
3434
#include <fcntl.h>
3535
#include <sys/mman.h>
36+
#define MICROPY_PAGE_SIZE 4096
37+
#define MICROPY_PAGE_MASK (MICROPY_PAGE_SIZE - 1)
3638
#endif
3739

3840
#if MICROPY_PY_MACHINE
3941

40-
#define PAGE_SIZE 4096
41-
#define PAGE_MASK (PAGE_SIZE - 1)
4242

4343
STATIC mp_uint_t get_addr(mp_obj_t addr_o, uint align) {
4444
mp_uint_t addr = mp_obj_int_get_truncated(addr_o);
@@ -58,12 +58,12 @@ STATIC mp_uint_t get_addr(mp_obj_t addr_o, uint align) {
5858
}
5959
}
6060

61-
mp_uint_t cur_base = addr & ~PAGE_MASK;
61+
mp_uint_t cur_base = addr & ~MICROPY_PAGE_MASK;
6262
if (cur_base != last_base) {
63-
map_page = (mp_uint_t)mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, cur_base);
63+
map_page = (mp_uint_t)mmap(NULL, MICROPY_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, cur_base);
6464
last_base = cur_base;
6565
}
66-
addr = map_page + (addr & PAGE_MASK);
66+
addr = map_page + (addr & MICROPY_PAGE_MASK);
6767
}
6868
#endif
6969

0 commit comments

Comments
 (0)