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

4.8
Last change on this file since b72e847b was 412dbff6, checked in by Joel Sherrill <joel.sherrill@…>, on 04/05/07 at 21:17:27

2007-04-05 Joel Sherrill <joel@…>

  • posix/Makefile.am, posix/include/rtems/posix/time.h, posix/src/adjtime.c, posix/src/alarm.c, posix/src/clockgetres.c, posix/src/condtimedwait.c, posix/src/mqueuetimedreceive.c, posix/src/mqueuetimedsend.c, posix/src/mutextimedlock.c, posix/src/nanosleep.c, posix/src/posixtimespecabsolutetimeout.c, posix/src/pthread.c, posix/src/pthreadcreate.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/sched.c, posix/src/semtimedwait.c, posix/src/sigtimedwait.c, posix/src/ualarm.c, rtems/src/clocktodtoseconds.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/tod.h, score/inline/rtems/score/tod.inl, score/src/coretod.c, score/src/coretodget.c, score/src/coretodgetuptime.c, score/src/coretodset.c, score/src/coretodtickle.c: Provide timespec manipulation routines in the SuperCore?. Use them everywhere possible. This lead to significant cleanup in the API routines and eliminated some of the same code from the POSIX API. At this point, the SuperCore? keeps time in POSIX timespec format properly from 1970. You just cannot set it before 1988 in keeping with RTEMS traditional behavior.
  • score/include/rtems/score/timespec.h, score/src/timespecaddto.c, score/src/timespecfromticks.c, score/src/timespecisvalid.c, score/src/timespeclessthan.c, score/src/timespecsubtract.c, score/src/timespectoticks.c: New files.
  • posix/src/posixintervaltotimespec.c, posix/src/posixtimespecsubtract.c, posix/src/posixtimespectointerval.c: Removed.
  • Property mode set to 100644
File size: 946 bytes
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 *  $Id$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <rtems/system.h>
21#include <rtems/score/timespec.h>
22#include <sys/types.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
37  if ( (time->tv_sec == 0) && (time->tv_nsec == 0) )
38    return 0;
39
40  ticks  = time->tv_sec * TOD_TICKS_PER_SECOND;
41
42  ticks += (time->tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND) /
43             _TOD_Microseconds_per_tick;
44
45  if (ticks)
46    return ticks;
47
48  return 1;
49}
Note: See TracBrowser for help on using the repository browser.