Skip to content

Commit

Permalink
Adjust mmap to new interface
Browse files Browse the repository at this point in the history
JIRA: RTOS-665
  • Loading branch information
badochov committed Nov 2, 2023
1 parent 894855f commit 060a4c8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions include/sys/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include <phoenix/mman.h>


#define MAP_ANON MAP_ANONYMOUS
#define MAP_FAILED (void *)-1
#define MAP_ANON MAP_ANONYMOUS


#ifdef __cplusplus
Expand All @@ -39,7 +38,7 @@ extern void meminfo(meminfo_t *info);
extern int syspageprog(syspageprog_t *prog, int index);


extern void *mmap(void *vaddr, size_t size, int prot, int flags, oid_t *oid, offs_t offs);
extern void *mmap(void *vaddr, size_t size, int prot, int flags, int fildes, off_t offs);


extern int munmap(void *vaddr, size_t size);
Expand Down
2 changes: 1 addition & 1 deletion pthread/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
attrs = attr;

void *stack = mmap(attrs->stackaddr, attrs->stacksize,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, NULL, 0);
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

if (stack == MAP_FAILED || stack == NULL)

Check failure on line 242 in pthread/pthread.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'MAP_FAILED' undeclared (first use in this function); did you mean 'MAP_FIXED'?

Check failure on line 242 in pthread/pthread.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'MAP_FAILED' undeclared (first use in this function); did you mean 'MAP_FIXED'?

Check failure on line 242 in pthread/pthread.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m4-stm32l4x6-nucleo)

'MAP_FAILED' undeclared (first use in this function); did you mean 'MAP_FIXED'?

Check failure on line 242 in pthread/pthread.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt117x-evk)

'MAP_FAILED' undeclared (first use in this function); did you mean 'MAP_FIXED'?

Check failure on line 242 in pthread/pthread.c

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-qemu)

'MAP_FAILED' undeclared (first use in this function); did you mean 'MAP_FIXED'?
return EAGAIN;
Expand Down
4 changes: 2 additions & 2 deletions stdio/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void *buffAlloc(size_t size)
void *ret;

#ifndef NOMMU
if ((ret = mmap(NULL, (size + (_PAGE_SIZE - 1)) & ~(_PAGE_SIZE - 1), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, NULL, 0)) == MAP_FAILED) {
if ((ret = mmap(NULL, (size + (_PAGE_SIZE - 1)) & ~(_PAGE_SIZE - 1), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0)) == MAP_FAILED) {
return NULL;
}
#else
Expand Down Expand Up @@ -1150,7 +1150,7 @@ FILE *popen(const char *command, const char *mode)
goto failed;
}

if ((pf->file.buffer = mmap(NULL, BUFSIZ, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, NULL, 0)) == MAP_FAILED) {
if ((pf->file.buffer = mmap(NULL, BUFSIZ, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0)) == MAP_FAILED) {
goto failed;
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/malloc_dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ static heap_t *_malloc_heapAlloc(size_t size)
if (heapSize < size)
return NULL;

heap = mmap(NULL, heapSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, NULL, 0);
heap = mmap(NULL, heapSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (heap == MAP_FAILED)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion stdlib/malloc_trivial3.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static heap_t *_malloc_heapCreate(size_t size)
heap_t *heap;
chunk_t *chunk;

if ((heap = mmap((void *)0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, NULL, 0)) == NULL)
if ((heap = mmap((void *)0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)) == NULL)
return NULL;

heap->size = size;
Expand Down

0 comments on commit 060a4c8

Please sign in to comment.