VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/posix/timer-posix.cpp@ 10854

Last change on this file since 10854 was 10854, checked in by vboxsync, 16 years ago

Disable use of posix timers on Solaris, working around the missing SIGEV_THREAD in Solaris 10.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 20.3 KB
Line 
1/* $Id: timer-posix.cpp 10854 2008-07-24 13:38:48Z vboxsync $ */
2/** @file
3 * IPRT - Timer, POSIX.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31/*******************************************************************************
32* Defined Constants And Macros *
33*******************************************************************************/
34/** Enables the use of POSIX RT timers. */
35#ifndef RT_OS_SOLARIS /* Solaris 10 doesn't have SIGEV_THREAD */
36#define IPRT_WITH_POSIX_TIMERS
37#endif /* !RT_OS_SOLARIS */
38
39
40/*******************************************************************************
41* Header Files *
42*******************************************************************************/
43#include <iprt/timer.h>
44#include <iprt/alloc.h>
45#include <iprt/assert.h>
46#include <iprt/thread.h>
47#include <iprt/log.h>
48#include <iprt/asm.h>
49#include <iprt/semaphore.h>
50#include <iprt/string.h>
51#include <iprt/err.h>
52#include "internal/magics.h"
53
54#include <unistd.h>
55#include <sys/fcntl.h>
56#include <sys/ioctl.h>
57#ifdef RT_OS_LINUX
58# include <linux/rtc.h>
59#endif
60#include <sys/time.h>
61#include <signal.h>
62#include <errno.h>
63#ifndef RT_OS_OS2
64# include <pthread.h>
65#endif
66
67
68/*******************************************************************************
69* Structures and Typedefs *
70*******************************************************************************/
71/**
72 * The internal representation of a timer handle.
73 */
74typedef struct RTTIMER
75{
76 /** Magic.
77 * This is RTTIMER_MAGIC, but changes to something else before the timer
78 * is destroyed to indicate clearly that thread should exit. */
79 uint32_t volatile u32Magic;
80 /** Flag indicating the the timer is suspended. */
81 uint8_t volatile fSuspended;
82 /** Flag indicating that the timer has been destroyed. */
83 uint8_t volatile fDestroyed;
84#ifndef IPRT_WITH_POSIX_TIMERS /** @todo We have to take the signals on a dedicated timer thread as
85 * we (might) have code assuming that signals doesn't screw around
86 * on existing threads. (It would be sufficient to have one thread
87 * per signal of course since the signal will be masked while it's
88 * running, however, it may just cause more compilcations than its
89 * worth - sigwait/sigwaitinfo work atomically anyway...)
90 * Also, must block the signal in the thread main procedure too. */
91 /** The timer thread. */
92 RTTHREAD Thread;
93 /** Event semaphore on which the thread is blocked. */
94 RTSEMEVENT Event;
95#endif
96 /** User argument. */
97 void *pvUser;
98 /** Callback. */
99 PFNRTTIMER pfnTimer;
100 /** The timer interval. 0 if one-shot. */
101 uint64_t u64NanoInterval;
102#ifndef IPRT_WITH_POSIX_TIMERS
103 /** The first shot interval. 0 if ASAP. */
104 uint64_t volatile u64NanoFirst;
105#endif /* !IPRT_WITH_POSIX_TIMERS */
106 /** The current timer tick. */
107 uint64_t volatile iTick;
108#ifndef IPRT_WITH_POSIX_TIMERS
109 /** The error/status of the timer.
110 * Initially -1, set to 0 when the timer have been successfully started, and
111 * to errno on failure in starting the timer. */
112 int volatile iError;
113#else /* !IPRT_WITH_POSIX_TIMERS */
114 timer_t timer;
115#endif /* !IPRT_WITH_POSIX_TIMERS */
116
117} RTTIMER;
118
119#ifndef IPRT_WITH_POSIX_TIMERS
120
121/**
122 * Signal handler which ignore everything it gets.
123 *
124 * @param iSignal The signal number.
125 */
126static void rttimerSignalIgnore(int iSignal)
127{
128 //AssertBreakpoint();
129}
130
131
132/**
133 * SIGALRM wait thread.
134 */
135static DECLCALLBACK(int) rttimerThread(RTTHREAD Thread, void *pvArg)
136{
137 PRTTIMER pTimer = (PRTTIMER)(void *)pvArg;
138 RTTIMER Timer = *pTimer;
139 Assert(pTimer->u32Magic == RTTIMER_MAGIC);
140
141 /*
142 * Install signal handler.
143 */
144 struct sigaction SigAct;
145 memset(&SigAct, 0, sizeof(SigAct));
146 SigAct.sa_flags = SA_RESTART;
147 sigemptyset(&SigAct.sa_mask);
148 SigAct.sa_handler = rttimerSignalIgnore;
149 if (sigaction(SIGALRM, &SigAct, NULL))
150 {
151 SigAct.sa_flags &= ~SA_RESTART;
152 if (sigaction(SIGALRM, &SigAct, NULL))
153 AssertMsgFailed(("sigaction failed, errno=%d\n", errno));
154 }
155
156 /*
157 * Mask most signals except those which might be used by the pthread implementation (linux).
158 */
159 sigset_t SigSet;
160 sigfillset(&SigSet);
161 sigdelset(&SigSet, SIGTERM);
162 sigdelset(&SigSet, SIGHUP);
163 sigdelset(&SigSet, SIGINT);
164 sigdelset(&SigSet, SIGABRT);
165 sigdelset(&SigSet, SIGKILL);
166#ifdef SIGRTMIN
167 for (int iSig = SIGRTMIN; iSig < SIGRTMAX; iSig++)
168 sigdelset(&SigSet, iSig);
169#endif
170 if (sigprocmask(SIG_SETMASK, &SigSet, NULL))
171 {
172 int rc = pTimer->iError = RTErrConvertFromErrno(errno);
173 AssertMsgFailed(("sigprocmask -> errno=%d\n", errno));
174 return rc;
175 }
176
177 /*
178 * The work loop.
179 */
180 RTThreadUserSignal(Thread);
181 while ( !pTimer->fDestroyed
182 && pTimer->u32Magic == RTTIMER_MAGIC)
183 {
184 /*
185 * Wait for a start or destroy event.
186 */
187 if (pTimer->fSuspended)
188 {
189 int rc = RTSemEventWait(pTimer->Event, RT_INDEFINITE_WAIT);
190 if (RT_FAILURE(rc) && rc != VERR_INTERRUPTED)
191 {
192 AssertRC(rc);
193 RTThreadSleep(1000); /* Don't cause trouble! */
194 }
195 if ( pTimer->fSuspended
196 || pTimer->fDestroyed)
197 continue;
198 }
199
200 /*
201 * Start the timer.
202 *
203 * For some SunOS (/SysV?) threading compatibility Linux will only
204 * deliver the SIGALRM to the thread calling setitimer(). Therefore
205 * we have to call it here.
206 *
207 * It turns out this might not always be the case, see SIGALRM killing
208 * processes on RH 2.4.21.
209 */
210 struct itimerval TimerVal;
211 if (pTimer->u64NanoFirst)
212 {
213 uint64_t u64 = RT_MAX(1000, pTimer->u64NanoFirst);
214 TimerVal.it_value.tv_sec = u64 / 1000000000;
215 TimerVal.it_value.tv_usec = (u64 % 1000000000) / 1000;
216 }
217 else
218 {
219 TimerVal.it_value.tv_sec = 0;
220 TimerVal.it_value.tv_usec = 10;
221 }
222 if (pTimer->u64NanoInterval)
223 {
224 uint64_t u64 = RT_MAX(1000, pTimer->u64NanoInterval);
225 TimerVal.it_interval.tv_sec = u64 / 1000000000;
226 TimerVal.it_interval.tv_usec = (u64 % 1000000000) / 1000;
227 }
228 else
229 {
230 TimerVal.it_interval.tv_sec = 0;
231 TimerVal.it_interval.tv_usec = 0;
232 }
233
234 if (setitimer(ITIMER_REAL, &TimerVal, NULL))
235 {
236 ASMAtomicXchgU8(&pTimer->fSuspended, true);
237 pTimer->iError = RTErrConvertFromErrno(errno);
238 RTThreadUserSignal(Thread);
239 continue; /* back to suspended mode. */
240 }
241 pTimer->iError = 0;
242 RTThreadUserSignal(Thread);
243
244 /*
245 * Timer Service Loop.
246 */
247 sigemptyset(&SigSet);
248 sigaddset(&SigSet, SIGALRM);
249 do
250 {
251 siginfo_t SigInfo = {0};
252#ifdef RT_OS_DARWIN
253 if (RT_LIKELY(sigwait(&SigSet, &SigInfo.si_signo) >= 0))
254 {
255#else
256 if (RT_LIKELY(sigwaitinfo(&SigSet, &SigInfo) >= 0))
257 {
258 if (RT_LIKELY(SigInfo.si_signo == SIGALRM))
259#endif
260 {
261 if (RT_UNLIKELY( pTimer->fSuspended
262 || pTimer->fDestroyed
263 || pTimer->u32Magic != RTTIMER_MAGIC))
264 break;
265
266 pTimer->pfnTimer(pTimer, pTimer->pvUser, ++pTimer->iTick);
267
268 /* auto suspend one-shot timers. */
269 if (RT_UNLIKELY(!pTimer->u64NanoInterval))
270 {
271 ASMAtomicXchgU8(&pTimer->fSuspended, true);
272 break;
273 }
274 }
275 }
276 else if (errno != EINTR)
277 AssertMsgFailed(("sigwaitinfo -> errno=%d\n", errno));
278 } while (RT_LIKELY( !pTimer->fSuspended
279 && !pTimer->fDestroyed
280 && pTimer->u32Magic == RTTIMER_MAGIC));
281
282 /*
283 * Disable the timer.
284 */
285 struct itimerval TimerVal2 = {{0,0}, {0,0}};
286 if (setitimer(ITIMER_REAL, &TimerVal2, NULL))
287 AssertMsgFailed(("setitimer(ITIMER_REAL,&{0}, NULL) failed, errno=%d\n", errno));
288
289 /*
290 * ACK any pending suspend request.
291 */
292 if (!pTimer->fDestroyed)
293 {
294 pTimer->iError = 0;
295 RTThreadUserSignal(Thread);
296 }
297 }
298
299 /*
300 * Exit.
301 */
302 pTimer->iError = 0;
303 RTThreadUserSignal(Thread);
304
305 return VINF_SUCCESS;
306}
307#else /* !IPRT_WITH_POSIX_TIMERS */
308void rttimerCallback(union sigval SigVal)
309{
310 PRTTIMER pTimer = (PRTTIMER)SigVal.sival_ptr;
311 /* Is the timer being destoyed/suspended at this very moment? */
312 if (RT_LIKELY(pTimer->u32Magic == RTTIMER_MAGIC
313 && !pTimer->fSuspended
314 && !pTimer->fDestroyed))
315 {
316 pTimer->pfnTimer(pTimer, pTimer->pvUser, ++pTimer->iTick);
317 }
318}
319#endif /* !IPRT_WITH_POSIX_TIMERS */
320
321
322RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, unsigned fFlags, PFNRTTIMER pfnTimer, void *pvUser)
323{
324 /*
325 * We don't support the fancy MP features.
326 */
327 if (fFlags & RTTIMER_FLAGS_CPU_SPECIFIC)
328 return VERR_NOT_SUPPORTED;
329
330#ifndef IPRT_WITH_POSIX_TIMERS /** @todo the signal blocking applies to the new code too, see comment in the struct. */
331 /*
332 * Check if timer is busy.
333 */
334 struct itimerval TimerVal;
335 if (getitimer(ITIMER_REAL, &TimerVal))
336 {
337 AssertMsgFailed(("getitimer() -> errno=%d\n", errno));
338 return VERR_NOT_IMPLEMENTED;
339 }
340 if ( TimerVal.it_value.tv_usec || TimerVal.it_value.tv_sec
341 || TimerVal.it_interval.tv_usec || TimerVal.it_interval.tv_sec
342 )
343 {
344 AssertMsgFailed(("A timer is running. System limit is one timer per process!\n"));
345 return VERR_TIMER_BUSY;
346 }
347
348 /*
349 * Block SIGALRM from calling thread.
350 */
351 sigset_t SigSet;
352 sigemptyset(&SigSet);
353 sigaddset(&SigSet, SIGALRM);
354 sigprocmask(SIG_BLOCK, &SigSet, NULL);
355
356 /** @todo Move this RTC hack else where... */
357 static bool fDoneRTC;
358 if (!fDoneRTC)
359 {
360 fDoneRTC = true;
361 /* check resolution. */
362 TimerVal.it_interval.tv_sec = 0;
363 TimerVal.it_interval.tv_usec = 1000;
364 TimerVal.it_value = TimerVal.it_interval;
365 if ( setitimer(ITIMER_REAL, &TimerVal, NULL)
366 || getitimer(ITIMER_REAL, &TimerVal)
367 || TimerVal.it_interval.tv_usec > 1000)
368 {
369 /*
370 * Try open /dev/rtc to set the irq rate to 1024 and
371 * turn periodic
372 */
373 Log(("RTTimerCreate: interval={%ld,%ld} trying to adjust /dev/rtc!\n", TimerVal.it_interval.tv_sec, TimerVal.it_interval.tv_usec));
374#ifdef RT_OS_LINUX
375 int fh = open("/dev/rtc", O_RDONLY);
376 if (fh >= 0)
377 {
378 if ( ioctl(fh, RTC_IRQP_SET, 1024) < 0
379 || ioctl(fh, RTC_PIE_ON, 0) < 0)
380 Log(("RTTimerCreate: couldn't configure rtc! errno=%d\n", errno));
381 ioctl(fh, F_SETFL, O_ASYNC);
382 ioctl(fh, F_SETOWN, getpid());
383 /* not so sure if closing it is a good idea... */
384 //close(fh);
385 }
386 else
387 Log(("RTTimerCreate: couldn't configure rtc! open failed with errno=%d\n", errno));
388#endif
389 }
390 /* disable it */
391 TimerVal.it_interval.tv_sec = 0;
392 TimerVal.it_interval.tv_usec = 0;
393 TimerVal.it_value = TimerVal.it_interval;
394 setitimer(ITIMER_REAL, &TimerVal, NULL);
395 }
396
397 /*
398 * Create a new timer.
399 */
400 int rc;
401 PRTTIMER pTimer = (PRTTIMER)RTMemAlloc(sizeof(*pTimer));
402 if (pTimer)
403 {
404 pTimer->u32Magic = RTTIMER_MAGIC;
405 pTimer->fSuspended = true;
406 pTimer->fDestroyed = false;
407 pTimer->Thread = NIL_RTTHREAD;
408 pTimer->Event = NIL_RTSEMEVENT;
409 pTimer->pfnTimer = pfnTimer;
410 pTimer->pvUser = pvUser;
411 pTimer->u64NanoInterval = u64NanoInterval;
412 pTimer->u64NanoFirst = 0;
413 pTimer->iTick = 0;
414 pTimer->iError = 0;
415 rc = RTSemEventCreate(&pTimer->Event);
416 AssertRC(rc);
417 if (RT_SUCCESS(rc))
418 {
419 rc = RTThreadCreate(&pTimer->Thread, rttimerThread, pTimer, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "Timer");
420 AssertRC(rc);
421 if (RT_SUCCESS(rc))
422 {
423 /*
424 * Wait for the timer thread to initialize it self.
425 * This might take a little while...
426 */
427 rc = RTThreadUserWait(pTimer->Thread, 45*1000);
428 AssertRC(rc);
429 if (RT_SUCCESS(rc))
430 {
431 rc = RTThreadUserReset(pTimer->Thread); AssertRC(rc);
432 rc = pTimer->iError;
433 AssertRC(rc);
434 if (RT_SUCCESS(rc))
435 {
436 RTThreadYield(); /* <-- Horrible hack to make tstTimer work. (linux 2.6.12) */
437 *ppTimer = pTimer;
438 return VINF_SUCCESS;
439 }
440 }
441
442 /* bail out */
443 ASMAtomicXchgU8(&pTimer->fDestroyed, true);
444 ASMAtomicXchgU32(&pTimer->u32Magic, RTTIMER_MAGIC + 1);
445 RTThreadWait(pTimer->Thread, 45*1000, NULL);
446 }
447 RTSemEventDestroy(pTimer->Event);
448 pTimer->Event = NIL_RTSEMEVENT;
449 }
450 RTMemFree(pTimer);
451 }
452 else
453 rc = VERR_NO_MEMORY;
454#else /* !IPRT_WITH_POSIX_TIMERS */
455 /*
456 * Create a new timer.
457 */
458 int rc;
459 PRTTIMER pTimer = (PRTTIMER)RTMemAlloc(sizeof(*pTimer));
460 if (pTimer)
461 {
462 struct sigevent evt;
463
464 /* Initialize timer structure. */
465 pTimer->u32Magic = RTTIMER_MAGIC;
466 pTimer->fSuspended = true;
467 pTimer->fDestroyed = false;
468 pTimer->pfnTimer = pfnTimer;
469 pTimer->pvUser = pvUser;
470 pTimer->u64NanoInterval = u64NanoInterval;
471 pTimer->iTick = 0;
472
473 /* Ask to call rttimerCallback in a separate thread context upon timer expiration. */
474 memset(&evt, 0, sizeof(evt));
475 evt.sigev_notify = SIGEV_THREAD;
476 evt.sigev_value.sival_ptr = pTimer;
477 evt.sigev_notify_function = rttimerCallback;
478
479 rc = RTErrConvertFromErrno(timer_create(CLOCK_REALTIME, &evt, &pTimer->timer));
480 if (RT_SUCCESS(rc))
481 {
482 *ppTimer = pTimer;
483 return VINF_SUCCESS;
484 }
485 RTMemFree(pTimer);
486 }
487 else
488 rc = VERR_NO_MEMORY;
489
490#endif /* !IPRT_WITH_POSIX_TIMERS */
491 return rc;
492}
493
494
495RTR3DECL(int) RTTimerDestroy(PRTTIMER pTimer)
496{
497 LogFlow(("RTTimerDestroy: pTimer=%p\n", pTimer));
498
499 /*
500 * Validate input.
501 */
502 /* NULL is ok. */
503 if (!pTimer)
504 return VINF_SUCCESS;
505 int rc = VINF_SUCCESS;
506 AssertPtrReturn(pTimer, VERR_INVALID_POINTER);
507 AssertReturn(pTimer->u32Magic == RTTIMER_MAGIC, VERR_INVALID_MAGIC);
508#ifndef IPRT_WITH_POSIX_TIMERS
509 AssertReturn(pTimer->Thread != RTThreadSelf(), VERR_INTERNAL_ERROR);
510
511 /*
512 * Tell the thread to terminate and wait for it do complete.
513 */
514 ASMAtomicXchgU8(&pTimer->fDestroyed, true);
515 ASMAtomicXchgU32(&pTimer->u32Magic, RTTIMER_MAGIC + 1);
516 rc = RTSemEventSignal(pTimer->Event);
517 AssertRC(rc);
518 if (!pTimer->fSuspended)
519 {
520#ifndef RT_OS_OS2
521 pthread_kill((pthread_t)RTThreadGetNative(pTimer->Thread), SIGALRM);
522#endif
523 }
524 rc = RTThreadWait(pTimer->Thread, 30 * 1000, NULL);
525 AssertRC(rc);
526
527 RTSemEventDestroy(pTimer->Event);
528 pTimer->Event = NIL_RTSEMEVENT;
529#else /* !IPRT_WITH_POSIX_TIMERS */
530 if (ASMAtomicXchgU8(&pTimer->fDestroyed, true))
531 {
532 /* It is already being destroyed by another thread. */
533 return VINF_SUCCESS;
534 }
535 rc = RTErrConvertFromErrno(timer_delete(pTimer->timer));
536#endif /* !IPRT_WITH_POSIX_TIMERS */
537 if (RT_SUCCESS(rc))
538 RTMemFree(pTimer);
539 return rc;
540}
541
542
543RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First)
544{
545 /*
546 * Validate input.
547 */
548 AssertPtrReturn(pTimer, VERR_INVALID_POINTER);
549 AssertReturn(pTimer->u32Magic == RTTIMER_MAGIC, VERR_INVALID_MAGIC);
550#ifndef IPRT_WITH_POSIX_TIMERS
551 AssertReturn(pTimer->Thread != RTThreadSelf(), VERR_INTERNAL_ERROR);
552
553 /*
554 * Already running?
555 */
556 if (!pTimer->fSuspended)
557 return VERR_TIMER_ACTIVE;
558
559 /*
560 * Tell the thread to start servicing the timer.
561 */
562 RTThreadUserReset(pTimer->Thread);
563 ASMAtomicUoWriteU64(&pTimer->u64NanoFirst, u64First);
564 ASMAtomicUoWriteU64(&pTimer->iTick, 0);
565 ASMAtomicWriteU8(&pTimer->fSuspended, false);
566 int rc = RTSemEventSignal(pTimer->Event);
567 if (RT_SUCCESS(rc))
568 {
569 rc = RTThreadUserWait(pTimer->Thread, 45*1000);
570 AssertRC(rc);
571 RTThreadUserReset(pTimer->Thread);
572 }
573 else
574 AssertRC(rc);
575 if (RT_FAILURE(rc))
576 ASMAtomicXchgU8(&pTimer->fSuspended, false);
577#else /* !IPRT_WITH_POSIX_TIMERS */
578 struct itimerspec ts;
579
580 if (!ASMAtomicXchgU8(&pTimer->fSuspended, false))
581 return VERR_TIMER_ACTIVE;
582
583 ts.it_value.tv_sec = u64First / 1000000000; /* nanosec => sec */
584 ts.it_value.tv_nsec = u64First ? u64First % 1000000000 : 1; /* 0 means disable, replace it with 1. */
585 ts.it_interval.tv_sec = pTimer->u64NanoInterval / 1000000000;
586 ts.it_interval.tv_nsec = pTimer->u64NanoInterval % 1000000000;
587 int rc = RTErrConvertFromErrno(timer_settime(pTimer->timer, 0, &ts, NULL));
588#endif /* !IPRT_WITH_POSIX_TIMERS */
589
590 return rc;
591}
592
593
594RTDECL(int) RTTimerStop(PRTTIMER pTimer)
595{
596 /*
597 * Validate input.
598 */
599 AssertPtrReturn(pTimer, VERR_INVALID_POINTER);
600 AssertReturn(pTimer->u32Magic == RTTIMER_MAGIC, VERR_INVALID_MAGIC);
601
602#ifndef IPRT_WITH_POSIX_TIMERS
603 /*
604 * Already running?
605 */
606 if (pTimer->fSuspended)
607 return VERR_TIMER_SUSPENDED;
608
609 /*
610 * Tell the thread to stop servicing the timer.
611 */
612 RTThreadUserReset(pTimer->Thread);
613 ASMAtomicXchgU8(&pTimer->fSuspended, true);
614 int rc = VINF_SUCCESS;
615 if (RTThreadSelf() != pTimer->Thread)
616 {
617#ifndef RT_OS_OS2
618 pthread_kill((pthread_t)RTThreadGetNative(pTimer->Thread), SIGALRM);
619#endif
620 rc = RTThreadUserWait(pTimer->Thread, 45*1000);
621 AssertRC(rc);
622 RTThreadUserReset(pTimer->Thread);
623 }
624#else /* !IPRT_WITH_POSIX_TIMERS */
625 struct itimerspec ts;
626
627 if (ASMAtomicXchgU8(&pTimer->fSuspended, true))
628 return VERR_TIMER_SUSPENDED;
629
630 ts.it_value.tv_sec = 0;
631 ts.it_value.tv_nsec = 0;
632 int rc = RTErrConvertFromErrno(timer_settime(pTimer->timer, 0, &ts, NULL));
633#endif /* !IPRT_WITH_POSIX_TIMERS */
634
635 return rc;
636}
637
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette