LibC: Add shm_open/shm_unlink

These can just open files in /tmp/shm. no need for anything fancier
This commit is contained in:
2026-05-25 01:25:43 +03:00
parent 2a6792b44a
commit 43d03eb4a9

View File

@@ -1,5 +1,7 @@
#include <fcntl.h>
#include <pthread.h> #include <pthread.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <unistd.h> #include <unistd.h>
@@ -43,10 +45,6 @@ int posix_madvise(void* addr, size_t len, int advice)
return 0; return 0;
} }
#include <BAN/Assert.h>
#include <BAN/Debug.h>
#include <errno.h>
int mlock(const void* addr, size_t len) int mlock(const void* addr, size_t len)
{ {
(void)addr; (void)addr;
@@ -63,18 +61,16 @@ int munlock(const void* addr, size_t len)
int shm_open(const char* name, int oflag, mode_t mode) int shm_open(const char* name, int oflag, mode_t mode)
{ {
(void)name; if (mkdir("/tmp/shm", 0777) == -1 && errno != EEXIST)
(void)oflag; return -1;
(void)mode; char path[PATH_MAX];
dwarnln("TODO: shm_open"); sprintf(path, "/tmp/shm%s", name);
errno = ENOTSUP; return open(path, oflag | O_CLOEXEC, mode);
return -1;
} }
int shm_unlink(const char* name) int shm_unlink(const char* name)
{ {
(void)name; char path[PATH_MAX];
dwarnln("TODO: shm_unlink"); sprintf(path, "/tmp/shm%s", name);
errno = ENOTSUP; return unlink(path);
return -1;
} }