library/src/internal.cpp

28 lines
590 B
C++
Raw Normal View History

#include "internal.h"
2019-11-04 23:17:15 +01:00
#include <sys/shm.h>
2019-11-06 12:47:34 +01:00
#include <csignal>
2019-11-07 12:41:01 +01:00
#include "SharedMemoryAccess.h"
2019-11-04 23:17:15 +01:00
2019-11-07 12:41:01 +01:00
Impl impl;
2019-11-06 12:47:34 +01:00
void sendSignal(pid_t pid, int signalNumber) {
kill(pid, signalNumber);
}
void onSignal(int signalNumber, void(*callback)(int)) {
signal(signalNumber, callback);
}
2019-11-06 13:41:24 +01:00
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;
}