#include "internal.h" #include #include Impl impl; void *getSharedMemory(){ impl.sharedMemorySize = 8000; auto id = shmget(impl.sharedMemoryKey, impl.sharedMemorySize, 0644u | IPC_CREAT); if(id == -1){ //error impl.sharedMemorySize = 0; return nullptr; } void *data = shmat(id, nullptr, 0); if(data == (char*)(-1)){ //error impl.sharedMemorySize = 0; return nullptr; } return data; } int getSharedMemorySize(){ return impl.sharedMemorySize; } void sendSignal(pid_t pid, int signalNumber) { kill(pid, signalNumber); } void onSignal(int signalNumber, void(*callback)(int)) { signal(signalNumber, callback); } InterruptEntry *getInterrupTable(){ return (InterruptEntry*)((char*)getSharedMemory() + sizeof(Registers) + 1024/*reserved*/); } bool callEvent(EventType type) { auto ivt = getInterrupTable(); if(ivt[type].pid != 0){ sendSignal(ivt[type].pid, ivt[type].signum); } return true; }