Changeset 154721c4 in rtems


Ignore:
Timestamp:
Nov 16, 2012, 12:39:55 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
62181b21
Parents:
7ca64d6
git-author:
Sebastian Huber <sebastian.huber@…> (11/16/12 12:39:55)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/21/12 15:24:22)
Message:

score: Add _Timestamp_To_timeval()

Location:
cpukit/score
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    r7ca64d6 r154721c4  
    304304    src/ts64lessthan.c \
    305305    src/ts64set.c src/ts64settozero.c src/ts64subtract.c \
    306     src/ts64toticks.c src/ts64totimespec.c
     306    src/ts64toticks.c src/ts64totimespec.c src/ts64totimeval.c
    307307
    308308## TOD_C_FILES
  • cpukit/score/include/rtems/score/timestamp.h

    r7ca64d6 r154721c4  
    3838 */
    3939/**@{*/
     40
     41#include <sys/time.h>
    4042
    4143#include <rtems/score/cpu.h>
     
    343345#endif
    344346
     347/**
     348 *  @brief Convert Timestamp to struct timeval
     349 *
     350 *  @param[in] _timestamp points to the timestamp
     351 *  @param[in] _timeval points to the timeval
     352 */
     353#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE
     354  #define _Timestamp_To_timeval( _timestamp, _timeval  ) \
     355    do { \
     356      (_timeval)->tv_sec = (_timestamp)->tv_sec; \
     357      (_timeval)->tv_usec = (_timestamp)->tv_nsec / 1000; \
     358    } while (0)
     359#else
     360  #define _Timestamp_To_timeval( _timestamp, _timeval  ) \
     361          _Timestamp64_To_timeval( _timestamp, _timeval  )
     362#endif
     363
    345364#ifdef __cplusplus
    346365}
  • cpukit/score/include/rtems/score/timestamp64.h

    r7ca64d6 r154721c4  
    394394#endif
    395395
     396static inline void _Timestamp64_implementation_To_timeval(
     397  const Timestamp64_Control *_timestamp,
     398  struct timeval            *_timeval
     399)
     400{
     401  _timeval->tv_sec = (time_t) (*_timestamp / 1000000000U);
     402  _timeval->tv_usec = (suseconds_t) ((*_timestamp % 1000000000U) / 1000U);
     403}
     404
     405/**
     406 *  @brief Convert Timestamp to struct timeval
     407 *
     408 *  This method returns the seconds portion of the specified timestamp
     409 *
     410 *  @param[in] _timestamp points to the timestamp
     411 *  @param[out] _timeval points to the timeval
     412 */
     413#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE
     414  #define _Timestamp64_To_timeval( _timestamp, _timeval  ) \
     415    _Timestamp64_implementation_To_timeval( _timestamp, _timeval )
     416#else
     417  void _Timestamp64_To_timeval(
     418    const Timestamp64_Control *_timestamp,
     419    struct timeval            *_timeval
     420  );
     421#endif
     422
    396423#ifdef __cplusplus
    397424}
Note: See TracChangeset for help on using the changeset viewer.