source: rtems/cpukit/score/src/timespectoticks.c @ a936aa49

4.115
Last change on this file since a936aa49 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 *  @file  score/src/timespectoticks.c
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-2007.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <sys/types.h>
19
20#include <rtems/system.h>
21#include <rtems/config.h>
22#include <rtems/score/timespec.h>
23#include <rtems/score/tod.h>
24#include <rtems/score/watchdog.h>
25
26/**
27 *
28 *  This routines converts a timespec to the corresponding number of ticks.
29 */
30
31uint32_t _Timespec_To_ticks(
32  const struct timespec *time
33)
34{
35  uint32_t  ticks;
36  uint32_t  nanoseconds_per_tick;
37
38  if ( (time->tv_sec == 0) && (time->tv_nsec == 0) )
39    return 0;
40
41  /**
42   *  We should ensure the ticks not be truncated by integer division.  We
43   *  need to have it be greater than or equal to the requested time.  It
44   *  should not be shorter.
45   */
46  ticks                 = time->tv_sec * TOD_TICKS_PER_SECOND;
47  nanoseconds_per_tick  = rtems_configuration_get_nanoseconds_per_tick();
48  ticks                += time->tv_nsec / nanoseconds_per_tick;
49
50  if ( (time->tv_nsec % nanoseconds_per_tick) != 0 )
51    ticks += 1;
52
53  return ticks;
54}
Note: See TracBrowser for help on using the repository browser.