source: rtems/cpukit/score/src/timespecaddto.c @ bd029d87

4.8
Last change on this file since bd029d87 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: 1.0 KB
Line 
1/**
2 *  @file  score/src//timespecaddto.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 <sys/types.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 adds two timespecs.  The second argument is added
29 *  to the first.
30 */
31
32uint32_t _Timespec_Add_to(
33  struct timespec       *time,
34  const struct timespec *add
35)
36{
37  uint32_t seconds = add->tv_sec;
38
39  /* Add the basics */
40  time->tv_sec += add->tv_sec;
41  time->tv_nsec += add->tv_nsec;
42
43  /* Now adjust it so nanoseconds is in range */
44  while ( time->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
45    time->tv_nsec -= TOD_NANOSECONDS_PER_SECOND;
46    time->tv_sec++;
47    seconds++;
48  }
49
50  return seconds;
51}
Note: See TracBrowser for help on using the repository browser.