24df65921b
* Reorganized the kernel locking related to threads and teams. * We now discriminate correctly between process and thread signals. Signal handlers have been moved to teams. Fixes #5679. * Implemented real-time signal support, including signal queuing, SA_SIGINFO support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition of the real-time signal range. Closes #1935 and #2695. * Gave SIGBUS a separate signal number. Fixes #6704. * Implemented <time.h> clock and timer support, and fixed/completed alarm() and [set]itimer(). Closes #5682. * Implemented support for thread cancellation. Closes #5686. * Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554. * Lots over smaller more or less related changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96
89 lines
1.5 KiB
C
89 lines
1.5 KiB
C
/*
|
|
* Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _LIBROOT_TIME_PRIVATE_H
|
|
#define _LIBROOT_TIME_PRIVATE_H
|
|
|
|
|
|
#include <errno.h>
|
|
#include <sys/cdefs.h>
|
|
#include <sys/time.h>
|
|
#include <time.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <new>
|
|
|
|
#define CLOCKS_PER_SEC_BEOS 1000
|
|
#define CLK_TCK_BEOS CLOCKS_PER_SEC_BEOS
|
|
|
|
#define MICROSECONDS_PER_CLOCK_TICK (1000000 / CLOCKS_PER_SEC)
|
|
#define MICROSECONDS_PER_CLOCK_TICK_BEOS (1000000 / CLOCKS_PER_SEC_BEOS)
|
|
|
|
|
|
struct __timer_t {
|
|
int32 id;
|
|
thread_id thread;
|
|
|
|
void SetTo(int32 id, thread_id thread)
|
|
{
|
|
this->id = id;
|
|
this->thread = thread;
|
|
}
|
|
};
|
|
|
|
|
|
static inline void
|
|
bigtime_to_timespec(bigtime_t time, timespec& spec)
|
|
{
|
|
spec.tv_sec = time / 1000000;
|
|
spec.tv_nsec = (time % 1000000) * 1000;
|
|
}
|
|
|
|
|
|
static inline bool
|
|
timespec_to_bigtime(const timespec& spec, bigtime_t& _time)
|
|
{
|
|
if (spec.tv_sec < 0 || spec.tv_nsec < 0 || spec.tv_nsec >= 1000000000)
|
|
return false;
|
|
|
|
_time = (bigtime_t)spec.tv_sec * 1000000 + (spec.tv_nsec + 999) / 1000;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
static inline bool
|
|
timeval_to_timespec(const timeval& val, timespec& spec)
|
|
{
|
|
if (val.tv_sec < 0 || val.tv_usec < 0 || val.tv_usec >= 1000000)
|
|
return false;
|
|
|
|
spec.tv_sec = val.tv_sec;
|
|
spec.tv_nsec = val.tv_usec * 1000;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
static inline void
|
|
timespec_to_timeval(const timespec& spec, timeval& val)
|
|
{
|
|
val.tv_sec = spec.tv_sec;
|
|
val.tv_usec = spec.tv_nsec / 1000;
|
|
}
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
clock_t __clock_beos(void);
|
|
clock_t __clock(void);
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
#endif // _LIBROOT_TIME_PRIVATE_H
|