2018-11-08 08:37:01 -02:00
|
|
|
#include <mman.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
2018-10-24 04:48:24 -03:00
|
|
|
#include <Kernel/Syscall.h>
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
2018-11-08 08:37:01 -02:00
|
|
|
void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset)
|
2018-10-24 04:48:24 -03:00
|
|
|
{
|
2018-11-08 08:37:01 -02:00
|
|
|
Syscall::SC_mmap_params params { (dword)addr, size, prot, flags, fd, offset };
|
2018-12-21 00:02:06 -02:00
|
|
|
int rc = syscall(SC_mmap, ¶ms);
|
2019-02-16 12:34:31 -02:00
|
|
|
if (rc < 0 && -rc < EMAXERRNO) {
|
|
|
|
|
errno = -rc;
|
|
|
|
|
return (void*)-1;
|
|
|
|
|
}
|
|
|
|
|
return (void*)rc;
|
2018-10-24 04:48:24 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int munmap(void* addr, size_t size)
|
|
|
|
|
{
|
2018-12-21 00:02:06 -02:00
|
|
|
int rc = syscall(SC_munmap, addr, size);
|
2018-10-25 07:06:00 -03:00
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
2018-10-24 04:48:24 -03:00
|
|
|
}
|
|
|
|
|
|
2018-10-28 05:57:22 -03:00
|
|
|
int set_mmap_name(void* addr, size_t size, const char* name)
|
|
|
|
|
{
|
2018-12-21 00:02:06 -02:00
|
|
|
int rc = syscall(SC_set_mmap_name, addr, size, name);
|
2018-10-28 05:57:22 -03:00
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-08 18:44:12 -03:00
|
|
|
int shm_open(const char* name, int flags, mode_t mode)
|
|
|
|
|
{
|
|
|
|
|
int rc = syscall(SC_shm_open, name, flags, mode);
|
|
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int shm_unlink(const char* name)
|
|
|
|
|
{
|
|
|
|
|
int rc = syscall(SC_unlink, name);
|
|
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-24 04:48:24 -03:00
|
|
|
}
|