Skip to content

Commit

Permalink
sys/mman: Set errno on mmap and munmap
Browse files Browse the repository at this point in the history
JIRA: RTOS-808
  • Loading branch information
agkaminski committed Apr 5, 2024
1 parent 5687309 commit 72389ef
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# Copyright 2018, 2020 Phoenix Systems
#

OBJS += $(addprefix $(PREFIX_O)sys/, events.o ioctl.o list.o mount.o rb.o resource.o select.o semaphore.o socket.o stat.o statvfs.o threads.o time.o times.o wait.o uio.o proto.o)
OBJS += $(addprefix $(PREFIX_O)sys/, events.o ioctl.o list.o mount.o rb.o resource.o select.o \
semaphore.o socket.o stat.o statvfs.o threads.o time.o times.o wait.o uio.o proto.o mman.o)
37 changes: 37 additions & 0 deletions sys/mman.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* mmap/munmap
*
* Copyright 2024 Phoenix Systems
* Author: Aleksander Kaminski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include <stddef.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <errno.h>


WRAP_ERRNO_DEF(int, munmap, (void *vadddr, size_t size), (vadddr, size))


extern int sys_mmap(void **vaddr, size_t size, int prot, int flags, int fildes, off_t offs);


void *mmap(void *vaddr, size_t size, int prot, int flags, int fildes, off_t offs)
{
int err = sys_mmap(&vaddr, size, prot, flags, fildes, offs);
if (err < 0) {
vaddr = MAP_FAILED;
SET_ERRNO(err);
}

return vaddr;
}

0 comments on commit 72389ef

Please sign in to comment.