20#include "modules/subsys/posix/PollEvent.h"
21#include "pedigree/kernel/Log.h"
23#include "modules/system/vfs/File.h"
25static void pollEventHandler(uint8_t* pBuffer);
30 :
Event(reinterpret_cast<uintptr_t>(&pollEventHandler), false),
31 m_pSemaphore(pSemaphore),
38PollEvent::~PollEvent() {}
40void PollEvent::fire() {
41 m_pFd->revents |= m_nREvent;
47 void* alignedBuffer = ASSUME_ALIGNMENT(pBuffer,
sizeof(
size_t));
48 size_t* pBuf =
reinterpret_cast<size_t*
>(alignedBuffer);
49 pBuf[0] = EventNumbers::PollEvent;
50 pBuf[1] =
reinterpret_cast<size_t>(m_pSemaphore);
51 pBuf[2] =
reinterpret_cast<size_t>(m_pFd);
52 pBuf[3] =
static_cast<size_t>(m_nREvent);
53 pBuf[4] =
reinterpret_cast<size_t>(m_pFile);
55 return 5 *
sizeof(size_t);
58bool PollEvent::unserialize(uint8_t* pBuffer,
PollEvent& event) {
59 void* alignedBuffer = ASSUME_ALIGNMENT(pBuffer,
sizeof(
size_t));
60 size_t* pBuf =
reinterpret_cast<size_t*
>(alignedBuffer);
61 if (pBuf[0] != EventNumbers::PollEvent)
64 event.m_pSemaphore =
reinterpret_cast<Semaphore*
>(pBuf[1]);
65 event.m_pFd =
reinterpret_cast<struct pollfd*
>(pBuf[2]);
66 event.m_nREvent =
static_cast<int>(pBuf[3]);
67 event.m_pFile =
reinterpret_cast<File*
>(pBuf[4]);
72void pollEventHandler(uint8_t* pBuffer) {
74 if (!PollEvent::unserialize(pBuffer, e)) {
75 FATAL(
"PollEventHandler: unable to unserialize event!");
virtual size_t serialize(uint8_t *pBuffer)