Changeset 6e98ea91 in rtems


Ignore:
Timestamp:
Jun 9, 2016, 3:40:35 PM (3 years ago)
Author:
Gedare Bloom <gedare@…>
Branches:
master
Children:
10e4000
Parents:
f23d470
git-author:
Gedare Bloom <gedare@…> (06/09/16 15:40:35)
git-committer:
Gedare Bloom <gedare@…> (07/25/16 16:44:47)
Message:

posix: add clock_nanosleep and tests

updates #2732

Files:
10 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/nanosleep.c

    rf23d470 r6e98ea91  
    99 *  COPYRIGHT (c) 1989-2015.
    1010 *  On-Line Applications Research Corporation (OAR).
     11 *
     12 *  Copyright (c) 2016. Gedare Bloom.
    1113 *
    1214 *  The license and distribution terms for this file may be
     
    3133  THREAD_QUEUE_INITIALIZER( "Nanosleep" );
    3234
    33 /*
    34  *  14.2.5 High Resolution Sleep, P1003.1b-1993, p. 269
    35  */
    36 int nanosleep(
     35static inline int nanosleep_helper(
    3736  const struct timespec  *rqtp,
    38   struct timespec        *rmtp
     37  struct timespec        *rmtp,
     38  Watchdog_Discipline     discipline
    3939)
    4040{
     
    5858   */
    5959  if ( !_Timespec_Is_valid( rqtp ) )
    60     rtems_set_errno_and_return_minus_one( EINVAL );
     60    return EINVAL;
    6161
    6262  /*
     
    9494    STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL,
    9595    ticks,
    96     WATCHDOG_RELATIVE,
     96    discipline,
    9797    1
    9898  );
     
    111111   * If the user wants the time remaining, do the conversion.
    112112   */
    113   if ( rmtp ) {
     113  if ( rmtp && discipline == WATCHDOG_RELATIVE ) {
    114114    _Timespec_From_ticks( ticks, rmtp );
    115115  }
     
    123123     */
    124124    if ( ticks )
    125       rtems_set_errno_and_return_minus_one( EINTR );
     125      return EINTR;
    126126  #endif
    127127
    128128  return 0;
    129129}
     130/*
     131 *  14.2.5 High Resolution Sleep, P1003.1b-1993, p. 269
     132 */
     133int nanosleep(
     134  const struct timespec  *rqtp,
     135  struct timespec        *rmtp
     136)
     137{
     138  int err = nanosleep_helper(rqtp, rmtp, WATCHDOG_RELATIVE);
     139  if (err) {
     140    rtems_set_errno_and_return_minus_one( err );
     141  }
     142  return 0;
     143}
     144
     145/*
     146 * High Resolution Sleep with Specifiable Clock, IEEE Std 1003.1, 2001
     147 */
     148int clock_nanosleep(
     149  clockid_t               clock_id,
     150  int                     flags,
     151  const struct timespec  *rqtp,
     152  struct timespec        *rmtp
     153)
     154{
     155  int err = 0;
     156  if ( clock_id == CLOCK_REALTIME || clock_id == CLOCK_MONOTONIC ) {
     157    if ( flags & TIMER_ABSTIME ) {
     158      err = nanosleep_helper(rqtp, rmtp, WATCHDOG_ABSOLUTE);
     159    } else {
     160      err = nanosleep_helper(rqtp, rmtp, WATCHDOG_RELATIVE);
     161    }
     162  } else {
     163    err = ENOTSUP;
     164  }
     165  return err;
     166}
  • testsuites/psxtests/psxhdrs/Makefile.am

    rf23d470 r6e98ea91  
    9696lib_a_SOURCES += time/clock_getres.c
    9797lib_a_SOURCES += time/clock_gettime.c
     98lib_a_SOURCES += time/clock_nanosleep.c
    9899lib_a_SOURCES += time/clock_settime.c
    99100lib_a_SOURCES += time/ctime.c
  • testsuites/psxtmtests/Makefile.am

    rf23d470 r6e98ea91  
    88SUBDIRS += psxtmbarrier03
    99SUBDIRS += psxtmbarrier04
     10SUBDIRS += psxtmclocknanosleep01
     11SUBDIRS += psxtmclocknanosleep02
     12SUBDIRS += psxtmclocknanosleep03
    1013SUBDIRS += psxtmcond01
    1114SUBDIRS += psxtmcond02
  • testsuites/psxtmtests/configure.ac

    rf23d470 r6e98ea91  
    8282psxtmbarrier03/Makefile
    8383psxtmbarrier04/Makefile
     84psxtmclocknanosleep01/Makefile
     85psxtmclocknanosleep02/Makefile
     86psxtmclocknanosleep03/Makefile
    8487psxtmcond01/Makefile
    8588psxtmcond02/Makefile
Note: See TracChangeset for help on using the changeset viewer.