Update contrib.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Name : timer_funcs.cpp
15 // Part of : librt-timer specific cpp file
16 // This is a project specific source file for building the
17 // timer related functions as part of librt library.
26 #include "timerhandler.h"
28 const TInt KErrWouldBlock=-1000;
32 /* Create new per-process timer using CLOCK_ID. */
33 EXPORT_C int timer_create (clockid_t __clock_id,
34 struct sigevent *__restrict __evp,
35 timer_t *__restrict __timerid)
43 if(__clock_id != CLOCK_REALTIME)
49 int err = getTimerHandler()->CreateTimer(*__timerid, __evp);
51 if (err == KErrWouldBlock)
53 return MapError(EAGAIN, errno);
56 return MapError(err, errno);
60 /* Delete timer TIMERID. */
61 EXPORT_C int timer_delete (timer_t __timerid)
63 return MapError(getTimerHandler()->RemoveTimer(__timerid),errno);
68 /* Set timer TIMERID to VALUE, returning old value in OVLAUE. */
69 EXPORT_C int timer_settime (timer_t __timerid, int __flags,
70 const struct itimerspec *__restrict __value,
71 struct itimerspec *__restrict __ovalue)
73 return MapError(getTimerHandler()->SetTime(__timerid, __flags, __value, __ovalue),errno);
76 /* Get current value of timer TIMERID and store it in VLAUE. */
77 EXPORT_C int timer_gettime (timer_t __timerid, struct itimerspec *__value)
85 return MapError(getTimerHandler()->Time(__timerid, __value),errno);
88 /* Get expiration overrun for timer TIMERID. */
89 EXPORT_C int timer_getoverrun (timer_t __timerid)
92 #if (!defined SYMBIAN_OE_POSIX_SIGNALS || !defined SYMBIAN_OE_LIBRT)
93 __timerid = __timerid;//warning fix
98 int lerr = MapError(getTimerHandler()->OverrunCount(__timerid, overrun),errno);
99 if(lerr == -1 && errno == EINVAL)
105 overrun = (overrun <= 1) ? 0 : (overrun-1);