source: rtems/cpukit/score/src/coretodget.c @ c86da31c

4.115
Last change on this file since c86da31c was c16bcc0, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/08 at 19:41:31

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

  • libcsupport/src/times.c, libmisc/cpuuse/cpuusagereport.c, libmisc/cpuuse/cpuusagereset.c, posix/src/clockgettime.c, posix/src/pthread.c, posix/src/timersettime.c, rtems/include/rtems/rtems/ratemon.h, rtems/src/clockgetsecondssinceepoch.c, rtems/src/clockgetuptime.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonreportstatistics.c, rtems/src/taskwakewhen.c, rtems/src/timerfirewhen.c, rtems/src/timerserver.c, rtems/src/timerserverfirewhen.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/thread.h, score/include/rtems/score/tod.h, score/src/coretod.c, score/src/coretodget.c, score/src/coretodgetuptime.c, score/src/coretodset.c, score/src/coretodtickle.c, score/src/threaddispatch.c, score/src/threadinitialize.c: Add SuperCore? handler Timestamp to provide an opaque class for the representation and manipulation of uptime, time of day, and the difference between two timestamps. By using SuperCore? Timestamp, it is clear which methods and APIs really have to be struct timespec and which can be in an optimized native format.
  • score/include/rtems/score/timestamp.h, score/src/coretodgetuptimetimespec.c: New files.
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  Time of Day (TOD) Handler - get TOD
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/isr.h>
20#include <rtems/score/timespec.h>
21#include <rtems/score/timestamp.h>
22#include <rtems/score/tod.h>
23#include <rtems/score/watchdog.h>
24
25/*
26 *  _TOD_Get
27 *
28 *  This routine is used to obtain the current date and time.
29 *
30 *  Input parameters:
31 *    time  - pointer to the time and date structure
32 *
33 *  Output parameters: NONE
34 */
35
36void _TOD_Get(
37  struct timespec *time
38)
39{
40  ISR_Level         level;
41  Timestamp_Control offset;
42  Timestamp_Control now;
43  long              nanoseconds;
44
45  /* assume time checked for NULL by caller */
46
47  /* _TOD_Now is the native current time */
48  nanoseconds = 0;
49  _ISR_Disable( level );
50    now = _TOD_Now;
51    if ( _Watchdog_Nanoseconds_since_tick_handler )
52      nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
53  _ISR_Enable( level );
54
55  _Timestamp_Set( &offset, 0, nanoseconds );
56  _Timestamp_Add_to( &now, &offset );
57  _Timestamp_To_timespec( &now, time );
58}
Note: See TracBrowser for help on using the repository browser.