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