source: rtems/cpukit/score/src/timespecsubtract.c @ 5472ad41

4.115
Last change on this file since 5472ad41 was 28352fae, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/29/09 at 13:51:53

Whitespace removal.

  • Property mode set to 100644
File size: 935 bytes
Line 
1/**
2 *  @file  score/src/timespecsubtract.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
26void _Timespec_Subtract(
27  const struct timespec *start,
28  const struct timespec *end,
29  struct timespec       *result
30)
31{
32
33  if (end->tv_nsec < start->tv_nsec) {
34    result->tv_sec  = end->tv_sec - start->tv_sec - 1;
35    result->tv_nsec =
36      (TOD_NANOSECONDS_PER_SECOND - start->tv_nsec) + end->tv_nsec;
37  } else {
38    result->tv_sec  = end->tv_sec - start->tv_sec;
39    result->tv_nsec = end->tv_nsec - start->tv_nsec;
40  }
41}
Note: See TracBrowser for help on using the repository browser.