Kernel/Userspace: Replace my custom SHM system with SysV shm
This allows xbanan to use shm!
This commit is contained in:
@@ -16,21 +16,3 @@ int load_keymap(const char* path)
|
||||
{
|
||||
return syscall(SYS_LOAD_KEYMAP, path);
|
||||
}
|
||||
|
||||
long smo_create(size_t size, int prot)
|
||||
{
|
||||
return syscall(SYS_SMO_CREATE, size, prot);
|
||||
}
|
||||
|
||||
int smo_delete(long key)
|
||||
{
|
||||
return syscall(SYS_SMO_DELETE, key);
|
||||
}
|
||||
|
||||
void* smo_map(long key)
|
||||
{
|
||||
long ret = syscall(SYS_SMO_MAP, key);
|
||||
if (ret < 0)
|
||||
return nullptr;
|
||||
return reinterpret_cast<void*>(ret);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
#include <BAN/Debug.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define TODO_FUNC(type, name, ...) type name(__VA_ARGS__) { dwarnln("TODO: " #name); errno = ENOTSUP; return (type)-1; }
|
||||
void* shmat(int shmid, const void* shmaddr, int shmflg)
|
||||
{
|
||||
const auto result = syscall(SYS_SHMAT, shmid, shmaddr, shmflg);
|
||||
if (result == -1)
|
||||
return SHM_FAILED;
|
||||
return reinterpret_cast<void*>(result);
|
||||
}
|
||||
|
||||
TODO_FUNC(void*, shmat, int, const void*, int)
|
||||
TODO_FUNC(int, shmctl, int, int, struct shmid_ds*)
|
||||
TODO_FUNC(int, shmdt, const void*)
|
||||
TODO_FUNC(int, shmget, key_t, size_t, int)
|
||||
int shmctl(int shmid, int cmd, struct shmid_ds* buf)
|
||||
{
|
||||
return syscall(SYS_SHMCTL, shmid, cmd, buf);
|
||||
}
|
||||
|
||||
int shmdt(const void* shmaddr)
|
||||
{
|
||||
return syscall(SYS_SHMDT, shmaddr);
|
||||
}
|
||||
|
||||
int shmget(key_t key, size_t size, int shmflg)
|
||||
{
|
||||
return syscall(SYS_SHMGET, key, size, shmflg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user