source/Platform/Unix: stub implementation
This commit is contained in:
parent
4d69ff3a18
commit
6464838159
20 changed files with 498 additions and 2 deletions
31
source/Platform/Unix/UnixSystem.cpp
Normal file
31
source/Platform/Unix/UnixSystem.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <Spectre/System/System.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
unsigned long system::getMilliseconds()
|
||||
{
|
||||
struct timespec tv;
|
||||
clock_gettime(CLOCK_REALTIME, &tv);
|
||||
return (tv.tv_sec * 1000ul) + (tv.tv_nsec / 1000000ul);
|
||||
|
||||
}
|
||||
|
||||
void system::sleep(int milliseconds)
|
||||
{
|
||||
struct timespec req, rem;
|
||||
req.tv_sec = milliseconds / 1000ul;
|
||||
req.tv_nsec = (milliseconds - (req.tv_sec * 1000ul)) * 1000000ul;
|
||||
|
||||
_start:
|
||||
// Try again if we get interrupted.
|
||||
if (clock_nanosleep(CLOCK_REALTIME, 0, &req, &rem) == EINTR) {
|
||||
// Update req with remaining time.
|
||||
req = rem;
|
||||
goto _start;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
Loading…
Add table
Add a link
Reference in a new issue