1 #ifndef CYGONCE_POSIX_TIME_H
2 #define CYGONCE_POSIX_TIME_H
3 /*=============================================================================
9 //=============================================================================
10 // ####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later
20 // eCos is distributed in the hope that it will be useful, but WITHOUT
21 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 // You should have received a copy of the GNU General Public License
26 // along with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 // As a special exception, if other files instantiate templates or use
30 // macros or inline functions from this file, or you compile this file
31 // and link it with other works to produce a work based on this file,
32 // this file does not by itself cause the resulting work to be covered by
33 // the GNU General Public License. However the source code for this file
34 // must still be made available in accordance with section (3) of the GNU
35 // General Public License v2.
37 // This exception does not invalidate any other reasons why a work based
38 // on this file might be covered by the GNU General Public License.
39 // -------------------------------------------
40 // ####ECOSGPLCOPYRIGHTEND####
41 //=============================================================================
42 //#####DESCRIPTIONBEGIN####
45 // Contributors: nickg, jlarmour
47 // Purpose: POSIX time header
48 // Description: This header contains all the definitions needed to support
49 // the POSIX timer and timer API under eCos.
51 // Usage: Do not include this file directly - instead include <time.h>
54 //####DESCRIPTIONEND####
56 //===========================================================================*/
58 #include <pkgconf/posix.h>
59 #include <cyg/infra/cyg_type.h>
61 /*---------------------------------------------------------------------------*/
62 /* Types for timers and clocks */
64 typedef int clockid_t
;
66 #ifdef CYGPKG_POSIX_TIMERS
69 /* forward declaration - if the app uses it it will have to include
75 /*---------------------------------------------------------------------------*/
84 #ifdef CYGPKG_POSIX_TIMERS
87 struct timespec it_interval
;
88 struct timespec it_value
;
92 /*---------------------------------------------------------------------------*/
93 /* Manifest constants */
95 #define CLOCK_REALTIME 0
97 #ifdef CYGPKG_POSIX_TIMERS
98 #define TIMER_ABSTIME 1
101 /*---------------------------------------------------------------------------*/
102 /* Clock functions */
104 /* Set the clocks current time */
105 __externC
int clock_settime( clockid_t clock_id
, const struct timespec
*tp
);
107 /* Get the clocks current time */
108 __externC
int clock_gettime( clockid_t clock_id
, struct timespec
*tp
);
110 /* Get the clocks resolution */
111 __externC
int clock_getres( clockid_t clock_id
, struct timespec
*tp
);
114 /*---------------------------------------------------------------------------*/
115 /* Timer functions */
117 #ifdef CYGPKG_POSIX_TIMERS
119 /* Create a timer based on the given clock. */
120 __externC
int timer_create( clockid_t clock_id
,
121 struct sigevent
*evp
,
124 /* Delete the timer */
125 __externC
int timer_delete( timer_t timer_id
);
127 /* Set the expiration time of the timer. */
128 __externC
int timer_settime( timer_t timerid
, int flags
,
129 const struct itimerspec
*value
,
130 struct itimerspec
*ovalue
);
132 /* Get current timer values */
133 __externC
int timer_gettime( timer_t timerid
, struct itimerspec
*value
);
135 /* Get number of missed triggers */
136 __externC
int timer_getoverrun( timer_t timerid
);
140 /*---------------------------------------------------------------------------*/
143 /* Sleep for the given time. */
144 __externC
int nanosleep( const struct timespec
*rqtp
,
145 struct timespec
*rmtp
);
148 /*---------------------------------------------------------------------------*/
149 #endif /* ifndef CYGONCE_POSIX_TIME_H */