Skip to content

Commit 6e6c01b

Browse files
prusnakdpgeorge
authored andcommitted
unix: Convert mp_uint_t to size_t in alloc.c.
1 parent 2460888 commit 6e6c01b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

unix/alloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typedef struct _mmap_region_t {
4949
struct _mmap_region_t *next;
5050
} mmap_region_t;
5151

52-
void mp_unix_alloc_exec(mp_uint_t min_size, void **ptr, mp_uint_t *size) {
52+
void mp_unix_alloc_exec(size_t min_size, void **ptr, size_t *size) {
5353
// size needs to be a multiple of the page size
5454
*size = (min_size + 0xfff) & (~0xfff);
5555
*ptr = mmap(NULL, *size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
@@ -65,7 +65,7 @@ void mp_unix_alloc_exec(mp_uint_t min_size, void **ptr, mp_uint_t *size) {
6565
MP_STATE_VM(mmap_region_head) = rg;
6666
}
6767

68-
void mp_unix_free_exec(void *ptr, mp_uint_t size) {
68+
void mp_unix_free_exec(void *ptr, size_t size) {
6969
munmap(ptr, size);
7070

7171
// unlink the mmap'd region from the list
@@ -93,7 +93,7 @@ void *ffi_closure_alloc(size_t size, void **code);
9393
void ffi_closure_free(void *ptr);
9494

9595
void *ffi_closure_alloc(size_t size, void **code) {
96-
mp_uint_t dummy;
96+
size_t dummy;
9797
mp_unix_alloc_exec(size, code, &dummy);
9898
return *code;
9999
}

unix/mpconfigport.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ extern const struct _mp_obj_module_t mp_module_jni;
217217

218218
// type definitions for the specific machine
219219

220+
// For size_t and ssize_t
221+
#include <unistd.h>
222+
220223
// assume that if we already defined the obj repr then we also defined types
221224
#ifndef MICROPY_OBJ_REPR
222225
#ifdef __LP64__
@@ -239,8 +242,8 @@ typedef long long mp_off_t;
239242
typedef long mp_off_t;
240243
#endif
241244

242-
void mp_unix_alloc_exec(mp_uint_t min_size, void** ptr, mp_uint_t *size);
243-
void mp_unix_free_exec(void *ptr, mp_uint_t size);
245+
void mp_unix_alloc_exec(size_t min_size, void** ptr, size_t *size);
246+
void mp_unix_free_exec(void *ptr, size_t size);
244247
void mp_unix_mark_exec(void);
245248
#define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) mp_unix_alloc_exec(min_size, ptr, size)
246249
#define MP_PLAT_FREE_EXEC(ptr, size) mp_unix_free_exec(ptr, size)
@@ -253,7 +256,6 @@ void mp_unix_mark_exec(void);
253256
#if MICROPY_PY_OS_DUPTERM
254257
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
255258
#else
256-
#include <unistd.h>
257259
#define MP_PLAT_PRINT_STRN(str, len) do { ssize_t ret = write(1, str, len); (void)ret; } while (0)
258260
#endif
259261

0 commit comments

Comments
 (0)