source: rtems/cpukit/score/include/rtems/score/timespec.h @ 6a614160

4.104.115
Last change on this file since 6a614160 was 6a614160, checked in by Joel Sherrill <joel.sherrill@…>, on 12/05/08 at 22:27:47

2008-12-05 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/timespec.h: Remove unnecessary includes. Fix typo.
  • posix/include/rtems/posix/time.h, score/src/coretodget.c, score/src/coretodgetuptime.c: Add required include files which were formerly included from timespec.h
  • Property mode set to 100644
File size: 4.9 KB
Line 
1/**
2 *  @file  rtems/score/timespec.h
3 *
4 *  This include file contains helpers for manipulating timespecs.
5 */
6
7/*
8 *  COPYRIGHT (c) 1989-2008.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#ifndef _RTEMS_SCORE_TIMESPEC_H
19#define _RTEMS_SCORE_TIMESPEC_H
20
21/**
22 *  @defgroup Timespec Helpers
23 *
24 *  This handler encapsulates functionality related to manipulating
25 *  POSIX struct timespecs.
26 */
27/**@{*/
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <sys/types.h>
34
35/** @brief Is Timespec Valid
36 *
37 *  This method determines the validity of a timespec.
38 *
39 *  @param[in] time is the timespec instance to validate.
40 *
41 *  @return This method returns true if @a time is valid and
42 *          false otherwise.
43 */
44bool _Timespec_Is_valid(
45  const struct timespec *time
46);
47
48/** @brief Timespec Less Than Operator
49 *
50 *  This method is the less than operator for timespecs.
51 *
52 *  @param[in] lhs is the left hand side timespec
53 *  @param[in] rhs is the right hand side timespec
54 *
55 *  @return This method returns true if @a lhs is less than the @a rhs and
56 *          false otherwise.
57 */
58bool _Timespec_Less_than(
59  const struct timespec *lhs,
60  const struct timespec *rhs
61);
62
63/** @brief Timespec Greater Than Operator
64 *
65 *  This method is the greater than operator for timespecs.
66 *
67 *  @param[in] lhs is the left hand side timespec
68 *  @param[in] rhs is the right hand side timespec
69 *
70 *  @return This method returns true if @a lhs is greater than the @a rhs and
71 *          false otherwise.
72 */
73bool _Timespec_Greater_than(
74  const struct timespec *lhs,
75  const struct timespec *rhs
76);
77
78/** @brief Timespec equal to Operator
79 *
80 *  This method is the is equal to than operator for timespecs.
81 *
82 *  @param[in] lhs is the left hand side timespec
83 *  @param[in] rhs is the right hand side timespec
84 *
85 *  @return This method returns true if @a lhs is equal to  @a rhs and
86 *          false otherwise.
87 */
88#define _Timespec_Equal_to( lhs, rhs ) \
89  ( ((lhs)->tv_sec  == (rhs)->tv_sec) &&   \
90    ((lhs)->tv_nsec == (rhs)->tv_nsec)     \
91  )
92
93/** @brief Add to a Timespec
94 *
95 *  This routine adds two timespecs.  The second argument is added
96 *  to the first.
97 *
98 *  @param[in] time is the base time to be added to
99 *  @param[in] add is the timespec to add to the first argument
100 *
101 *  @return This method returns the number of seconds @a time increased by.
102 */
103uint32_t _Timespec_Add_to(
104  struct timespec       *time,
105  const struct timespec *add
106);
107
108/** @brief Convert Timespec to Number of Ticks
109 *
110 *  This routine convert the @a time timespec to the corresponding number
111 *  of clock ticks.
112 *
113 *  @param[in] time is the time to be converted
114 *
115 *  @return This method returns the number of ticks computed.
116 */
117uint32_t _Timespec_To_ticks(
118  const struct timespec *time
119);
120
121/** @brief Convert Ticks to Timespec
122 *
123 *  This routine converts the @a ticks value to the corresponding
124 *  timespec format @a time.
125 *
126 *  @param[in] time is the timespec format time result
127 *  @param[in] ticks is the number of ticks to convert
128 */
129void _Timespec_From_ticks(
130  uint32_t         ticks,
131  struct timespec *time
132);
133
134/** @brief Subtract Two Timespec
135 *
136 *  This routine subtracts two timespecs.  @a result is set to
137 *  @a end - @a start.
138 *
139 *  @param[in] start is the starting time
140 *  @param[in] end is the ending time
141 *  @param[in] result is the difference between starting and ending time.
142 *
143 *  @return This method fills in @a result.
144 */
145void _Timespec_Subtract(
146  const struct timespec *start,
147  const struct timespec *end,
148  struct timespec       *result
149);
150
151/** @brief Divide Timespec By Integer
152 *
153 *  This routine divides a timespec by an integer value.  The expected
154 *  use is to assist in benchmark calculations where you typically
155 *  divide a duration by a number of iterations.
156 *
157 *  @param[in] time is the total
158 *  @param[in] iterations is the number of iterations
159 *  @param[in] result is the average time.
160 *
161 *  @return This method fills in @a result.
162 */
163void _Timespec_Divide_by_integer(
164  const struct timespec *time,
165  uint32_t               iterations,
166  struct timespec       *result
167);
168
169/** @brief Divide Timespec
170 *
171 *  This routine divides a timespec by another timespec.  The
172 *  intended use is for calculating percentages to three decimal points.
173 *
174 *  @param[in] lhs is the left hand number
175 *  @param[in] rhs is the right hand number
176 *  @param[in] ival_percentage is the integer portion of the average
177 *  @param[in] fval_percentage is the thousandths of percentage
178 *
179 *  @return This method fills in @a result.
180 */
181void _Timespec_Divide(
182  const struct timespec *lhs,
183  const struct timespec *rhs,
184  uint32_t              *ival_percentage,
185  uint32_t              *fval_percentage
186);
187
188#ifdef __cplusplus
189}
190#endif
191
192/**@}*/
193
194#endif
195/* end of include file */
Note: See TracBrowser for help on using the repository browser.