20 #include "modules/subsys/posix/PollEvent.h" 21 #include "modules/system/vfs/File.h" 22 #include "pedigree/kernel/Log.h" 24 static void pollEventHandler(uint8_t *pBuffer);
27 :
Event(0, false), m_pSemaphore(0), m_pFd(0), m_nREvent(0), m_pFile(0)
32 Semaphore *pSemaphore,
struct pollfd *fd,
int revent,
File *pFile)
33 :
Event(reinterpret_cast<uintptr_t>(&pollEventHandler),
false),
34 m_pSemaphore(pSemaphore), m_pFd(fd), m_nREvent(revent), m_pFile(pFile)
39 PollEvent::~PollEvent()
43 void PollEvent::fire()
45 m_pFd->revents |= m_nREvent;
52 void *alignedBuffer = ASSUME_ALIGNMENT(pBuffer,
sizeof(
size_t));
53 size_t *pBuf =
reinterpret_cast<size_t *
>(alignedBuffer);
54 pBuf[0] = EventNumbers::PollEvent;
55 pBuf[1] =
reinterpret_cast<size_t>(m_pSemaphore);
56 pBuf[2] =
reinterpret_cast<size_t>(m_pFd);
57 pBuf[3] =
static_cast<size_t>(m_nREvent);
58 pBuf[4] =
reinterpret_cast<size_t>(m_pFile);
60 return 5 *
sizeof(size_t);
63 bool PollEvent::unserialize(uint8_t *pBuffer,
PollEvent &event)
65 void *alignedBuffer = ASSUME_ALIGNMENT(pBuffer,
sizeof(
size_t));
66 size_t *pBuf =
reinterpret_cast<size_t *
>(alignedBuffer);
67 if (pBuf[0] != EventNumbers::PollEvent)
70 event.m_pSemaphore =
reinterpret_cast<Semaphore *
>(pBuf[1]);
71 event.m_pFd =
reinterpret_cast<struct pollfd *
>(pBuf[2]);
72 event.m_nREvent =
static_cast<int>(pBuf[3]);
73 event.m_pFile =
reinterpret_cast<File *
>(pBuf[4]);
78 void pollEventHandler(uint8_t *pBuffer)
81 if (!PollEvent::unserialize(pBuffer, e))
83 FATAL(
"PollEventHandler: unable to unserialize event!");
Event(uintptr_t handlerAddress, bool isDeletable, size_t specificNestingLevel=~0UL)
virtual size_t serialize(uint8_t *pBuffer)