Ticket #1291: pr1291-cvs.diff

File pr1291-cvs.diff, 52.9 KB (added by Joel Sherrill, on Jul 18, 2008 at 5:43:16 PM)

Fix against CVS.

  • cpukit/itron/inline/rtems/itron/semaphore.inl

    ? .j.swp
    ? j
    ? log
    ? c/src/lib/libbsp/powerpc/psim/depcomp
    ? cpukit/Doxyfile
    ? cpukit/j.diff
    ? cpukit/mainpage.h
    ? cpukit/libcsupport/src/wrap__free.c
    ? cpukit/libcsupport/src/wrap__malloc.c
    ? cpukit/libmisc/monitor/.mon-monitor.c.swp
    ? cpukit/posix/src/condtimedwait-debug
    ? cpukit/rtems/Makefile.am-hold
    ? cpukit/rtems/src/wrap__Workspace_Allocate.c
    ? cpukit/rtems/src/wrap__Workspace_Allocate_or_fatal_error.c
    ? cpukit/rtems/src/wrap_rtems_task_create.c
    ? cpukit/score/src/.timespeclessthan.c.swp
    ? doc/shell/C
    ? doc/shell/cmd_template.t
    ? doc/shell/commands.t-sav
    ? doc/shell/examples
    ? doc/shell/file_cmds
    ? doc/shell/general_cmds
    ? doc/shell/j
    ? doc/shell/j1
    ? doc/shell/memory_cmds
    ? doc/shell/n
    ? doc/shell/network_cmds
    ? doc/shell/rtems_cmds
    ? doc/user/directive.t
    ? doc/user/j
    RCS file: /usr1/CVS/rtems/cpukit/itron/inline/rtems/itron/semaphore.inl,v
    retrieving revision 1.7
    diff -u -r1.7 semaphore.inl
     
    172172      return E_TMOUT;
    173173    case CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED:
    174174      return E_QOVR;
    175     case CORE_SEMAPHORE_BAD_TIMEOUT_VALUE:
    176       return E_PAR;
    177175    case THREAD_STATUS_PROXY_BLOCKING:
    178176      return THREAD_STATUS_PROXY_BLOCKING;
    179177  }
  • cpukit/itron/src/twai_sem.c

    RCS file: /usr1/CVS/rtems/cpukit/itron/src/twai_sem.c,v
    retrieving revision 1.8
    diff -u -r1.8 twai_sem.c
     
    11/*
    2  *  COPYRIGHT (c) 1989-2007.
     2 *  COPYRIGHT (c) 1989-2008.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
    55 *  The license and distribution terms for this file may be
     
    3030  TMO tmout
    3131)
    3232{
    33   ITRON_Semaphore_Control        *the_semaphore;
    34   Objects_Locations               location;
    35   Watchdog_Interval               interval;
    36   Core_semaphore_Blocking_option  blocking;
     33  ITRON_Semaphore_Control  *the_semaphore;
     34  Objects_Locations         location;
     35  Watchdog_Interval         interval;
     36  boolean                   blocking;
    3737
    3838  interval = 0;
    3939  if ( tmout == TMO_POL ) {
    40     blocking = CORE_SEMAPHORE_NO_WAIT;
     40    blocking = FALSE;
    4141  } else {
    42     blocking = CORE_SEMAPHORE_BLOCK_FOREVER;
     42    blocking = TRUE;
    4343
    4444    if ( tmout != TMO_FEVR )
    4545      interval = TOD_MILLISECONDS_TO_TICKS(tmout);
  • cpukit/posix/include/mqueue.h

    RCS file: /usr1/CVS/rtems/cpukit/posix/include/mqueue.h,v
    retrieving revision 1.10
    diff -u -r1.10 mqueue.h
     
    33 */
    44
    55/*
    6  *  COPYRIGHT (c) 1989-2007.
     6 *  COPYRIGHT (c) 1989-2008.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
    99 *  The license and distribution terms for this file may be
     
    3333 *  15.1.1 Data Structures, P1003.1b-1993, p. 271
    3434 */
    3535
     36/**
     37 *  Message queue id type
     38 */
    3639typedef Objects_Id  mqd_t;
    3740
     41/**
     42 *  This is the message queue attributes structure.
     43 */
    3844struct mq_attr {
    39   long  mq_flags;     /* Message queue flags */
    40   long  mq_maxmsg;    /* Maximum number of messages */
    41   long  mq_msgsize;   /* Maximum message size */
    42   long  mq_curmsgs;   /* Number of messages currently queued */
     45  /** This is the message queue flags */
     46  long  mq_flags;
     47  /** This is the maximum number of messages */
     48  long  mq_maxmsg;
     49  /** This is the maximum message size */
     50  long  mq_msgsize;
     51  /** This is the mumber of messages currently queued */
     52  long  mq_curmsgs;
    4353};
    4454
    45 /*
     55/**
    4656 *  15.2.2 Open a Message Queue, P1003.1b-1993, p. 272
    4757 */
    48 
    4958mqd_t mq_open(
    5059  const char *name,
    5160  int         oflag,
    5261  ...
    5362);
    5463
    55 /*
     64/**
    5665 *  15.2.2 Close a Message Queue, P1003.1b-1993, p. 275
    5766 */
    58 
    5967int mq_close(
    6068  mqd_t  mqdes
    6169);
    6270
    63 /*
     71/**
    6472 *  15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276
    6573 */
    66 
    6774int mq_unlink(
    6875  const char *name
    6976);
    7077
    71 /*
     78/**
    7279 *  15.2.4 Send a Message to a Message Queue, P1003.1b-1993, p. 277
    7380 *
    74  *  NOTE: P1003.4b/D8, p. 45 adds mq_timedsend().
     81 *  @note P1003.4b/D8, p. 45 adds mq_timedsend().
    7582 */
    76 
    7783int mq_send(
    7884  mqd_t         mqdes,
    7985  const char   *msg_ptr,
     
    9096  const char            *msg_ptr,
    9197  size_t                 msg_len,
    9298  unsigned int           msg_prio,
    93   const struct timespec *timeout
     99  const struct timespec *abstime
    94100);
    95101
    96102#endif /* _POSIX_TIMEOUTS */
     
    115121  char                  *msg_ptr,
    116122  size_t                 msg_len,
    117123  unsigned int          *msg_prio,
    118   const struct timespec *timeout
     124  const struct timespec *abstime
    119125);
    120126
    121127#endif /* _POSIX_TIMEOUTS */
  • cpukit/posix/include/rtems/posix/mqueue.h

    RCS file: /usr1/CVS/rtems/cpukit/posix/include/rtems/posix/mqueue.h,v
    retrieving revision 1.23
    diff -u -r1.23 mqueue.h
     
    66 */
    77 
    88/*
    9  *  COPYRIGHT (c) 1989-1999.
     9 *  COPYRIGHT (c) 1989-2008.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
    1212 *  The license and distribution terms for this file may be
     
    112112  char               *msg_ptr,
    113113  size_t              msg_len,
    114114  unsigned int       *msg_prio,
     115  boolean             wait,
    115116  Watchdog_Interval   timeout
    116117);
    117118
     
    128129  const char         *msg_ptr,
    129130  size_t              msg_len,
    130131  uint32_t            msg_prio,
     132  boolean             wait,
    131133  Watchdog_Interval   timeout
    132134);
    133135
  • cpukit/posix/include/rtems/posix/semaphore.h

    RCS file: /usr1/CVS/rtems/cpukit/posix/include/rtems/posix/semaphore.h,v
    retrieving revision 1.22
    diff -u -r1.22 semaphore.h
     
    77 *  This include file contains all the private support information for
    88 *  POSIX Semaphores.
    99 *
    10  *  COPYRIGHT (c) 1989-2007.
     10 *  COPYRIGHT (c) 1989-2008.
    1111 *  On-Line Applications Research Corporation (OAR).
    1212 *
    1313 *  The license and distribution terms for this file may be
     
    153153 */
    154154
    155155int _POSIX_Semaphore_Wait_support(
    156   sem_t                          *sem,
    157   Core_semaphore_Blocking_option  blocking,
    158   Watchdog_Interval               timeout
     156  sem_t               *sem,
     157  boolean              blocking,
     158  Watchdog_Interval    timeout
    159159);
    160160
    161161/*
  • cpukit/posix/include/rtems/posix/time.h

    RCS file: /usr1/CVS/rtems/cpukit/posix/include/rtems/posix/time.h,v
    retrieving revision 1.11
    diff -u -r1.11 time.h
     
    33 */
    44
    55/*
    6  *  COPYRIGHT (c) 1989-2007.
     6 *  COPYRIGHT (c) 1989-2008.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
    99 *  The license and distribution terms for this file may be
     
    1818
    1919#include <rtems/score/timespec.h>
    2020
    21 /*
    22  *  _POSIX_Absolute_timeout_to_ticks
     21/** @brief Absolute Timeout Conversion Results
     22 *
     23 *  This enumeration defines the possible results of converting
     24 *  an absolute time used for timeouts to POSIX blocking calls to
     25 *  a number of ticks.
     26 */
     27typedef enum {
     28  /** The timeout is invalid. */
     29  POSIX_ABSOLUTE_TIMEOUT_INVALID,
     30  /** The timeout represents a time that is in the past. */
     31  POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST,
     32  /** The timeout represents a time that is equal to the current time. */
     33  POSIX_ABSOLUTE_TIMEOUT_IS_NOW,
     34  /** The timeout represents a time that is in the future. */
     35  POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE,
     36} POSIX_Absolute_timeout_conversion_results_t;
     37
     38/**
     39 *  @brief Convert Absolute Timeout to Ticks
     40 *
     41 *  This method takes an absolute time being used as a timeout
     42 *  to a blocking directive, validates it and returns the number
     43 *  of corresponding clock ticks for use by the SuperCore.
     44 *
     45 *  @param[in] abstime is the timeout
     46 *  @param[in] ticks_out will contain the number of ticks
     47 *
     48 *  @return This method returns the number of ticks in @a ticks_out
     49 *          and a status value indicating whether the absolute time
     50 *          is valid, in the past, equal to the current time or in
     51 *          the future as it should be.
    2352 */
    24 int _POSIX_Absolute_timeout_to_ticks(
     53POSIX_Absolute_timeout_conversion_results_t _POSIX_Absolute_timeout_to_ticks(
    2554  const struct timespec *abstime,
    2655  Watchdog_Interval     *ticks_out
    2756);
  • cpukit/posix/src/condtimedwait.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/condtimedwait.c,v
    retrieving revision 1.4
    diff -u -r1.4 condtimedwait.c
     
    33 */
    44
    55/*
    6  *  COPYRIGHT (c) 1989-2007.
     6 *  COPYRIGHT (c) 1989-2008.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
    99 *  The license and distribution terms for this file may be
     
    3939  const struct timespec *abstime
    4040)
    4141{
    42   Watchdog_Interval timeout;
    43   struct timespec   current_time;
    44   struct timespec   difference;
    45   boolean           already_timedout = FALSE;
    46 
    47   if ( !_Timespec_Is_valid(abstime) )
    48     return EINVAL;
    49 
    50   /*
    51    *  The abstime is a walltime.  We turn it into an interval.
    52    */
    53 
    54   _TOD_Get( &current_time );
     42  Watchdog_Interval ticks;
     43  boolean           already_timedout;
    5544
    5645  /*
    57    * Make sure the timeout is in the future
     46   *  POSIX requires that blocking calls with timeouts that take
     47   *  an absolute timeout must ignore issues with the absolute
     48   *  time provided if the operation would otherwise succeed.
     49   *  So we check the abstime provided, and hold on to whether it
     50   *  is valid or not.  If it isn't correct and in the future,
     51   *  then we do a polling operation and convert the UNSATISFIED
     52   *  status into the appropriate error.
    5853   */
    59   if ( _Timespec_Less_than( abstime, &current_time ) ) {
    60     already_timedout = TRUE;
    61     difference.tv_sec  = 0;
    62     difference.tv_nsec = 0;
    63     timeout = 0;
    64   } else {
    65     _Timespec_Subtract( &current_time, abstime, &difference );
    66     timeout = _Timespec_To_ticks( &difference );
     54  switch ( _POSIX_Absolute_timeout_to_ticks(abstime, &ticks) ) {
     55    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     56      return EINVAL;
     57    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     58    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     59      already_timedout = TRUE;
     60      break;
     61    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     62      already_timedout = FALSE;
     63      break;
    6764  }
    6865
    6966  return _POSIX_Condition_variables_Wait_support(
    7067    cond,
    7168    mutex,
    72     timeout,
     69    ticks,
    7370    already_timedout
    7471  );
    7572}
  • cpukit/posix/src/mqueuereceive.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuereceive.c,v
    retrieving revision 1.6
    diff -u -r1.6 mqueuereceive.c
     
    1111 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
    1212 *         time.
    1313 *
    14  *  COPYRIGHT (c) 1989-2007.
     14 *  COPYRIGHT (c) 1989-2008.
    1515 *  On-Line Applications Research Corporation (OAR).
    1616 *
    1717 *  The license and distribution terms for this file may be
     
    5858    msg_ptr,
    5959    msg_len,
    6060    msg_prio,
     61    TRUE,
    6162    THREAD_QUEUE_WAIT_FOREVER
    6263  );
    6364}
  • cpukit/posix/src/mqueuerecvsupp.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuerecvsupp.c,v
    retrieving revision 1.15
    diff -u -r1.15 mqueuerecvsupp.c
     
    1111 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
    1212 *         time.
    1313 *
    14  *  COPYRIGHT (c) 1989-2007.
     14 *  COPYRIGHT (c) 1989-2008.
    1515 *  On-Line Applications Research Corporation (OAR).
    1616 *
    1717 *  The license and distribution terms for this file may be
     
    3939#include <rtems/posix/mqueue.h>
    4040#include <rtems/posix/time.h>
    4141
    42 /*PAGE
    43  *
     42/*
    4443 *  _POSIX_Message_queue_Receive_support
    4544 *
    4645 *  NOTE: XXX Document how size, priority, length, and the buffer go
     
    5251  char               *msg_ptr,
    5352  size_t              msg_len,
    5453  unsigned int       *msg_prio,
     54  boolean             wait,
    5555  Watchdog_Interval   timeout
    5656)
    5757{
     
    5959  POSIX_Message_queue_Control_fd  *the_mq_fd;
    6060  Objects_Locations                location;
    6161  size_t                           length_out;
     62  boolean                          do_wait;
    6263
    6364  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    6465  switch ( location ) {
     
    8384
    8485      length_out = -1;
    8586
     87      /*
     88       *  A timed receive with a bad time will do a poll regardless.
     89       */
     90      if ( wait )
     91        do_wait = (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE;
     92      else
     93        do_wait = wait;
     94
     95      /*
     96       *  Now perform the actual message receive
     97       */
    8698      _CORE_message_queue_Seize(
    8799        &the_mq->Message_queue,
    88100        mqdes,
    89101        msg_ptr,
    90102        &length_out,
    91         (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE,
     103        do_wait,
    92104        timeout
    93105      );
    94106
  • cpukit/posix/src/mqueuesend.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuesend.c,v
    retrieving revision 1.6
    diff -u -r1.6 mqueuesend.c
     
    1111 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
    1212 *         time.
    1313 *
    14  *  COPYRIGHT (c) 1989-2007.
     14 *  COPYRIGHT (c) 1989-2008.
    1515 *  On-Line Applications Research Corporation (OAR).
    1616 *
    1717 *  The license and distribution terms for this file may be
     
    5858    msg_ptr,
    5959    msg_len,
    6060    msg_prio,
     61    TRUE,
    6162    THREAD_QUEUE_WAIT_FOREVER
    6263  );
    6364}
  • cpukit/posix/src/mqueuesendsupp.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuesendsupp.c,v
    retrieving revision 1.19
    diff -u -r1.19 mqueuesendsupp.c
     
    1111 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
    1212 *         time.
    1313 *
    14  *  COPYRIGHT (c) 1989-2007.
     14 *  COPYRIGHT (c) 1989-2008.
    1515 *  On-Line Applications Research Corporation (OAR).
    1616 *
    1717 *  The license and distribution terms for this file may be
     
    5050  const char         *msg_ptr,
    5151  size_t              msg_len,
    5252  uint32_t            msg_prio,
     53  boolean             wait,
    5354  Watchdog_Interval   timeout
    5455)
    5556{
     
    5758  POSIX_Message_queue_Control_fd *the_mq_fd;
    5859  Objects_Locations               location;
    5960  CORE_message_queue_Status       msg_status;
     61  boolean                         do_wait;
    6062
    6163  /*
    6264   * Validate the priority.
     
    7779
    7880      the_mq = the_mq_fd->Queue;
    7981
     82      /*
     83       *  A timed receive with a bad time will do a poll regardless.
     84       */
     85      if ( wait )
     86        do_wait = (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE;
     87      else
     88        do_wait = wait;
     89
     90      /*
     91       *  Now perform the actual message receive
     92       */
    8093      msg_status = _CORE_message_queue_Submit(
    8194        &the_mq->Message_queue,
    8295        (void *)msg_ptr,
     
    8497        mqdes,      /* mqd_t is an object id */
    8598        NULL,
    8699        _POSIX_Message_queue_Priority_to_core( msg_prio ),
    87          (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE,
     100        do_wait,
    88101        timeout    /* no timeout */
    89102      );
    90103
  • cpukit/posix/src/mqueuetimedreceive.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuetimedreceive.c,v
    retrieving revision 1.7
    diff -u -r1.7 mqueuetimedreceive.c
     
    1313 */
    1414
    1515/*
    16  *  COPYRIGHT (c) 1989-2007.
     16 *  COPYRIGHT (c) 1989-2008.
    1717 *  On-Line Applications Research Corporation (OAR).
    1818 *
    1919 *  The license and distribution terms for this file may be
     
    5353  char                  *msg_ptr,
    5454  size_t                 msg_len,
    5555  unsigned int          *msg_prio,
    56   const struct timespec *timeout
     56  const struct timespec *abstime
    5757)
    5858{
     59  Watchdog_Interval ticks;
     60  boolean           do_wait;
     61
     62  /*
     63   *  POSIX requires that blocking calls with timeouts that take
     64   *  an absolute timeout must ignore issues with the absolute
     65   *  time provided if the operation would otherwise succeed.
     66   *  So we check the abstime provided, and hold on to whether it
     67   *  is valid or not.  If it isn't correct and in the future,
     68   *  then we do a polling operation and convert the UNSATISFIED
     69   *  status into the appropriate error.
     70   */
     71  switch ( _POSIX_Absolute_timeout_to_ticks( abstime, &ticks ) ) {
     72    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     73    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     74    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     75      do_wait = FALSE;
     76      break;
     77    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     78      do_wait = TRUE;
     79      break;
     80  }
     81
    5982  return _POSIX_Message_queue_Receive_support(
    6083    mqdes,
    6184    msg_ptr,
    6285    msg_len,
    6386    msg_prio,
    64     _Timespec_To_ticks( timeout )
     87    do_wait,
     88    ticks
    6589  );
    6690}
  • cpukit/posix/src/mqueuetimedsend.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuetimedsend.c,v
    retrieving revision 1.6
    diff -u -r1.6 mqueuetimedsend.c
     
    1313 */
    1414
    1515/*
    16  *  COPYRIGHT (c) 1989-2007.
     16 *  COPYRIGHT (c) 1989-2008.
    1717 *  On-Line Applications Research Corporation (OAR).
    1818 *
    1919 *  The license and distribution terms for this file may be
     
    5353  const char            *msg_ptr,
    5454  size_t                 msg_len,
    5555  unsigned int           msg_prio,
    56   const struct timespec *timeout
     56  const struct timespec *abstime
    5757)
    5858{
     59  Watchdog_Interval ticks;
     60  boolean           do_wait;
     61
     62  /*
     63   *  POSIX requires that blocking calls with timeouts that take
     64   *  an absolute timeout must ignore issues with the absolute
     65   *  time provided if the operation would otherwise succeed.
     66   *  So we check the abstime provided, and hold on to whether it
     67   *  is valid or not.  If it isn't correct and in the future,
     68   *  then we do a polling operation and convert the UNSATISFIED
     69   *  status into the appropriate error.
     70   */
     71  switch ( _POSIX_Absolute_timeout_to_ticks( abstime, &ticks ) ) {
     72    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     73    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     74    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     75      do_wait = FALSE;
     76      break;
     77    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     78      do_wait = TRUE;
     79      break;
     80  }
     81
    5982  return _POSIX_Message_queue_Send_support(
    6083    mqdes,
    6184    msg_ptr,
    6285    msg_len,
    6386    msg_prio,
    64     _Timespec_To_ticks( timeout )
     87    do_wait,
     88    ticks
    6589  );
    6690}
  • cpukit/posix/src/mutextimedlock.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mutextimedlock.c,v
    retrieving revision 1.5
    diff -u -r1.5 mutextimedlock.c
     
    33 */
    44
    55/*
    6  *  COPYRIGHT (c) 1989-2007.
     6 *  COPYRIGHT (c) 1989-2008.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
    99 *  The license and distribution terms for this file may be
     
    3939
    4040int pthread_mutex_timedlock(
    4141  pthread_mutex_t       *mutex,
    42   const struct timespec *timeout
     42  const struct timespec *abstime
    4343)
    4444{
    45   /* XXX does timeout need to be based on CLOCK_REALTIME and be TOD? */
    46   return _POSIX_Mutex_Lock_support(
     45  Watchdog_Interval                            ticks;
     46  boolean                                      do_wait;
     47  POSIX_Absolute_timeout_conversion_results_t  status;
     48  int                                          lock_status;
     49
     50  /*
     51   *  POSIX requires that blocking calls with timeouts that take
     52   *  an absolute timeout must ignore issues with the absolute
     53   *  time provided if the operation would otherwise succeed.
     54   *  So we check the abstime provided, and hold on to whether it
     55   *  is valid or not.  If it isn't correct and in the future,
     56   *  then we do a polling operation and convert the UNSATISFIED
     57   *  status into the appropriate error.
     58   */
     59  status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
     60  switch ( status ) {
     61    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     62    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     63    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     64      do_wait = FALSE;
     65      break;
     66    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     67      do_wait = TRUE;
     68      break;
     69  }
     70
     71  lock_status = _POSIX_Mutex_Lock_support(
    4772    mutex,
    48     TRUE,
    49     _Timespec_To_ticks( timeout )
     73    do_wait,
     74    ticks
    5075  );
     76
     77  /*
     78   *  This service only gives us the option to block.  We used a polling
     79   *  attempt to lock if the abstime was not in the future.  If we did
     80   *  not obtain the mutex, then not look at the status immediately,
     81   *  make sure the right reason is returned.
     82   */
     83  if ( !do_wait && (lock_status == EBUSY) ) {
     84    switch (lock_status) {
     85      case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     86        return EINVAL;
     87      case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     88      case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     89        return ETIMEDOUT;
     90      case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     91        break;
     92    }
     93  }
     94
     95  return lock_status;
    5196}
  • cpukit/posix/src/mutextranslatereturncode.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mutextranslatereturncode.c,v
    retrieving revision 1.1
    diff -u -r1.1 mutextranslatereturncode.c
     
    11/*
    22 *  POSIX Mutex Error Translation
    33 *
    4  *  COPYRIGHT (c) 1989-2007.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
    77 *  The license and distribution terms for this file may be
     
    3838  EDEADLK,                /* CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED */
    3939  EPERM,                  /* CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE */
    4040  EINVAL,                 /* CORE_MUTEX_WAS_DELETED */
    41   EAGAIN,                 /* CORE_MUTEX_TIMEOUT */
     41  ETIMEDOUT,              /* CORE_MUTEX_TIMEOUT */
    4242  EINVAL                  /* CORE_MUTEX_STATUS_CEILING_VIOLATED */
    4343};
    4444
  • cpukit/posix/src/posixtimespecabsolutetimeout.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/posixtimespecabsolutetimeout.c,v
    retrieving revision 1.2
    diff -u -r1.2 posixtimespecabsolutetimeout.c
     
    33 */
    44
    55/*
    6  *  COPYRIGHT (c) 1989-2007.
     6 *  COPYRIGHT (c) 1989-2008.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
    99 *  The license and distribution terms for this file may be
     
    3434/*
    3535 *  The abstime is a walltime.  We turn it into an interval.
    3636 */
    37 int _POSIX_Absolute_timeout_to_ticks(
     37POSIX_Absolute_timeout_conversion_results_t _POSIX_Absolute_timeout_to_ticks(
    3838  const struct timespec *abstime,
    3939  Watchdog_Interval     *ticks_out
    4040)
     
    4242  struct timespec current_time;
    4343  struct timespec difference;
    4444
    45   if ( !_Timespec_Is_valid(abstime) )
    46     return EINVAL;
     45 
     46  /*
     47   *  Make sure there is always a value returned.
     48   */
     49  *ticks_out = 0;
    4750
    48   _TOD_Get( &current_time );
     51  /*
     52   *  Is the absolute time even valid?
     53   */
     54  if ( !_Timespec_Is_valid(abstime) )
     55    return POSIX_ABSOLUTE_TIMEOUT_INVALID;
    4956
    5057  /*
    51    *  Make sure the abstime is in the future
     58   *  Is the absolute time in the past?
    5259   */
     60  _TOD_Get( &current_time );
     61
    5362  if ( _Timespec_Less_than( abstime, &current_time ) )
    54     return EINVAL;
     63    return POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST;
    5564
     65  /*
     66   *  How long until the requested absolute time?
     67   */
    5668  _Timespec_Subtract( &current_time, abstime, &difference );
    5769
     70  /*
     71   *  Internally the SuperCore uses ticks, so convert to them.
     72   */
    5873  *ticks_out = _Timespec_To_ticks( &difference );
    5974
    60   return 0;
     75  /*
     76   *  If the difference was 0, then the future is now.  It is so bright
     77   *  we better wear shades.
     78   */
     79  if ( !*ticks_out )
     80    return POSIX_ABSOLUTE_TIMEOUT_IS_NOW;
     81
     82  /*
     83   *  This is the case we were expecting and it took this long to
     84   *  get here.
     85   */
     86  return POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE;
    6187}
    6288
  • cpukit/posix/src/prwlocktimedrdlock.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/prwlocktimedrdlock.c,v
    retrieving revision 1.4
    diff -u -r1.4 prwlocktimedrdlock.c
     
    11/*
    22 *  POSIX RWLock Manager -- Attempt to Obtain a Read Lock on a RWLock Instance
    33 *
    4  *  COPYRIGHT (c) 1989-2007.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
    77 *  The license and distribution terms for this file may be
     
    4040  const struct timespec *abstime
    4141)
    4242{
    43   POSIX_RWLock_Control  *the_rwlock;
    44   Objects_Locations      location;
    45   Watchdog_Interval      ticks;
    46   int                    status;
     43  POSIX_RWLock_Control                        *the_rwlock;
     44  Objects_Locations                            location;
     45  Watchdog_Interval                            ticks;
     46  boolean                                      do_wait;
     47  POSIX_Absolute_timeout_conversion_results_t  status;
    4748 
    4849  if ( !rwlock )
    4950    return EINVAL;
    5051
     52  /*
     53   *  POSIX requires that blocking calls with timeouts that take
     54   *  an absolute timeout must ignore issues with the absolute
     55   *  time provided if the operation would otherwise succeed.
     56   *  So we check the abstime provided, and hold on to whether it
     57   *  is valid or not.  If it isn't correct and in the future,
     58   *  then we do a polling operation and convert the UNSATISFIED
     59   *  status into the appropriate error.
     60   */
    5161  status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
    52   if ( status )
    53     return status;
     62  switch (status) {
     63    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     64    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     65    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     66      do_wait = FALSE;
     67      break;
     68    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     69      do_wait = TRUE;
     70      break;
     71  }
    5472
    5573  the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
    5674  switch ( location ) {
     
    6078      _CORE_RWLock_Obtain_for_reading(
    6179        &the_rwlock->RWLock,
    6280        *rwlock,
    63         TRUE,                   // we are willing to wait up to ticks
     81        do_wait,
    6482        ticks,
    6583        NULL
    6684      );
    6785
    6886      _Thread_Enable_dispatch();
     87      if ( !do_wait &&
     88           (_Thread_Executing->Wait.return_code == CORE_RWLOCK_UNAVAILABLE) ) {
     89        switch (status) {
     90          case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     91            return EINVAL;
     92          case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     93          case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     94            return ETIMEDOUT;
     95          case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     96            break;
     97        }
     98      }
     99
    69100      return _POSIX_RWLock_Translate_core_RWLock_return_code(
    70101        (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
    71102      );
  • cpukit/posix/src/prwlocktimedwrlock.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/prwlocktimedwrlock.c,v
    retrieving revision 1.4
    diff -u -r1.4 prwlocktimedwrlock.c
     
    11/*
    22 *  POSIX RWLock Manager -- Attempt to Obtain a Write Lock on a RWLock Instance
    33 *
    4  *  COPYRIGHT (c) 1989-2007.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
    77 *  The license and distribution terms for this file may be
     
    4040  const struct timespec *abstime
    4141)
    4242{
    43   POSIX_RWLock_Control  *the_rwlock;
    44   Objects_Locations      location;
    45   int                    status;
    46   Watchdog_Interval      ticks;
    47 
     43  POSIX_RWLock_Control                        *the_rwlock;
     44  Objects_Locations                            location;
     45  Watchdog_Interval                            ticks;
     46  boolean                                      do_wait;
     47  POSIX_Absolute_timeout_conversion_results_t  status;
     48 
    4849  if ( !rwlock )
    4950    return EINVAL;
    5051
     52  /*
     53   *  POSIX requires that blocking calls with timeouts that take
     54   *  an absolute timeout must ignore issues with the absolute
     55   *  time provided if the operation would otherwise succeed.
     56   *  So we check the abstime provided, and hold on to whether it
     57   *  is valid or not.  If it isn't correct and in the future,
     58   *  then we do a polling operation and convert the UNSATISFIED
     59   *  status into the appropriate error.
     60   */
    5161  status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
    52   if ( status )
    53     return status;
     62  switch (status) {
     63    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     64    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     65    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     66      do_wait = FALSE;
     67      break;
     68    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     69      do_wait = TRUE;
     70      break;
     71  }
    5472
    5573  the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
    5674  switch ( location ) {
     
    6078      _CORE_RWLock_Obtain_for_writing(
    6179        &the_rwlock->RWLock,
    6280        *rwlock,
    63         TRUE,                 // we are willing to wait up to ticks
     81        do_wait,
    6482        ticks,
    6583        NULL
    6684      );
    6785
    6886      _Thread_Enable_dispatch();
     87      if ( !do_wait &&
     88           (_Thread_Executing->Wait.return_code == CORE_RWLOCK_UNAVAILABLE) ) {
     89        switch (status) {
     90          case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     91            return EINVAL;
     92          case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     93          case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     94            return ETIMEDOUT;
     95          case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     96            break;
     97        }
     98      }
     99
    69100      return _POSIX_RWLock_Translate_core_RWLock_return_code(
    70101        (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
    71102      );
  • cpukit/posix/src/semaphoretranslatereturncode.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/semaphoretranslatereturncode.c,v
    retrieving revision 1.1
    diff -u -r1.1 semaphoretranslatereturncode.c
     
    4141   * count to the largest value the count can hold.
    4242   */
    4343  ENOSYS,              /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
    44   EINVAL               /* CORE_SEMAPHORE_BAD_TIMEOUT_VALUE */
    4544};
    4645
    4746
  • cpukit/posix/src/semaphorewaitsupp.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/semaphorewaitsupp.c,v
    retrieving revision 1.11
    diff -u -r1.11 semaphorewaitsupp.c
     
    11/*
    2  *  COPYRIGHT (c) 1989-2007.
     2 *  COPYRIGHT (c) 1989-2008.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
    55 *  The license and distribution terms for this file may be
     
    3333 */
    3434
    3535int _POSIX_Semaphore_Wait_support(
    36   sem_t                          *sem,
    37   Core_semaphore_Blocking_option  blocking,
    38   Watchdog_Interval               timeout
     36  sem_t             *sem,
     37  boolean            blocking,
     38  Watchdog_Interval  timeout
    3939)
    4040{
    4141  POSIX_Semaphore_Control *the_semaphore;
  • cpukit/posix/src/semtimedwait.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/semtimedwait.c,v
    retrieving revision 1.9
    diff -u -r1.9 semtimedwait.c
     
    11/*
    2  *  COPYRIGHT (c) 1989-2007.
     2 *  COPYRIGHT (c) 1989-2008.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
    55 *  The license and distribution terms for this file may be
     
    3939  const struct timespec *abstime
    4040)
    4141{
     42  Watchdog_Interval                            ticks;
     43  boolean                                      do_wait = TRUE;
     44  POSIX_Absolute_timeout_conversion_results_t  status;
     45  int                                          lock_status;
     46
    4247  /*
    43    *  The abstime is a walltime.  We turn it into an interval.
     48   *  POSIX requires that blocking calls with timeouts that take
     49   *  an absolute timeout must ignore issues with the absolute
     50   *  time provided if the operation would otherwise succeed.
     51   *  So we check the abstime provided, and hold on to whether it
     52   *  is valid or not.  If it isn't correct and in the future,
     53   *  then we do a polling operation and convert the UNSATISFIED
     54   *  status into the appropriate error.
    4455   */
    45   Watchdog_Interval              ticks = 0;
    46   struct timespec                current_time;
    47   struct timespec                difference;
    48   Core_semaphore_Blocking_option blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT;
     56  status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
     57  switch ( status ) {
     58    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     59    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     60    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     61      do_wait = FALSE;
     62      break;
     63    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     64      do_wait = TRUE;
     65      break;
     66  }
     67
     68  lock_status = _POSIX_Semaphore_Wait_support( sem, do_wait, ticks );
    4969
    5070  /*
    51    *  Error check the absolute time to timeout
     71   *  This service only gives us the option to block.  We used a polling
     72   *  attempt to obtain if the abstime was not in the future.  If we did
     73   *  not obtain the semaphore, then not look at the status immediately,
     74   *  make sure the right reason is returned.
    5275   */
    53   if ( !_Timespec_Is_valid( abstime ) ) {
    54     blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
    55   } else {
    56     _TOD_Get( &current_time );
    57     /*
    58      *  Make sure the abstime is in the future
    59      */
    60     if ( _Timespec_Less_than( abstime, &current_time ) ) {
    61       blocking = CORE_SEMAPHORE_BAD_TIMEOUT;
    62     } else {
    63       _Timespec_Subtract( &current_time, abstime, &difference );
    64       ticks = _Timespec_To_ticks( &difference );
    65       blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT;
     76  if ( !do_wait && (lock_status == EBUSY) ) {
     77    switch (lock_status) {
     78      case POSIX_ABSOLUTE_TIMEOUT_INVALID:
     79        return EINVAL;
     80      case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     81      case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
     82        return ETIMEDOUT;
     83      case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
     84        break;
    6685    }
    67    }
     86  }
    6887
    69    return _POSIX_Semaphore_Wait_support( sem, blocking, ticks );
     88  return lock_status;
    7089}
  • cpukit/posix/src/semtrywait.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/semtrywait.c,v
    retrieving revision 1.4
    diff -u -r1.4 semtrywait.c
     
    11/*
    2  *  COPYRIGHT (c) 1989-2007.
     2 *  COPYRIGHT (c) 1989-2008.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
    55 *  The license and distribution terms for this file may be
     
    3838  sem_t *sem
    3939)
    4040{
    41   return _POSIX_Semaphore_Wait_support( sem, FALSE, THREAD_QUEUE_WAIT_FOREVER );
     41  return _POSIX_Semaphore_Wait_support(sem, FALSE, THREAD_QUEUE_WAIT_FOREVER);
    4242}
  • cpukit/posix/src/semwait.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/semwait.c,v
    retrieving revision 1.5
    diff -u -r1.5 semwait.c
     
    11/*
    2  *  COPYRIGHT (c) 1989-2007.
     2 *  COPYRIGHT (c) 1989-2008.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
    55 *  The license and distribution terms for this file may be
     
    3838  sem_t *sem
    3939)
    4040{
    41   return _POSIX_Semaphore_Wait_support(
    42            sem,
    43            CORE_SEMAPHORE_BLOCK_FOREVER,
    44            THREAD_QUEUE_WAIT_FOREVER
    45          );
     41  return _POSIX_Semaphore_Wait_support( sem, TRUE, THREAD_QUEUE_WAIT_FOREVER );
    4642}
  • cpukit/posix/src/sigtimedwait.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/sigtimedwait.c,v
    retrieving revision 1.13
    diff -u -r1.13 sigtimedwait.c
     
    11/*
    22 *  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
    33 *
    4  *  COPYRIGHT (c) 1989-2007.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
    77 *  The license and distribution terms for this file may be
     
    6363
    6464  /*
    6565   *  Error check parameters before disabling interrupts.
     66   *
     67   *  NOTE: This is very specifically a RELATIVE not ABSOLUTE time
     68   *        in the Open Group specification.
    6669   */
    6770
    6871  interval = 0;
    6972  if ( timeout ) {
    7073
    71     if ( !_Timespec_Is_valid( timeout ) ) {
     74    if ( !_Timespec_Is_valid( timeout ) )
    7275      rtems_set_errno_and_return_minus_one( EINVAL );
    73     }
    7476
    7577    interval = _Timespec_To_ticks( timeout );
     78
     79    if ( !interval )
     80      rtems_set_errno_and_return_minus_one( EINVAL );
    7681  }
    7782
    7883  /*
  • cpukit/posix/src/timersettime.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/timersettime.c,v
    retrieving revision 1.3
    diff -u -r1.3 timersettime.c
     
    5959    /* Check for seconds in the past */
    6060    if ( _Timespec_Greater_than( &normalize.it_value, &_TOD_Now ) )
    6161      rtems_set_errno_and_return_minus_one( EINVAL );
    62     _Timespec_Subtract( &_TOD_Now, &normalize.it_value, &normalize.it_value);
     62    _Timespec_Subtract( &_TOD_Now, &normalize.it_value, &normalize.it_value );
    6363  }
     64
    6465  /* If the function reaches this point, then it will be necessary to do
    6566   * something with the structure of times of the timer: to stop, start
    6667   * or start it again
  • cpukit/posix/src/ualarm.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/ualarm.c,v
    retrieving revision 1.7
    diff -u -r1.7 ualarm.c
     
    11/*
    22 *  3.4.1 Schedule Alarm, P1003.1b-1993, p. 79
    33 *
    4  *  COPYRIGHT (c) 1989-2007.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
    77 *  The license and distribution terms for this file may be
     
    101101    tp.tv_sec = useconds / TOD_MICROSECONDS_PER_SECOND;
    102102    tp.tv_nsec = (useconds % TOD_MICROSECONDS_PER_SECOND) * 1000;
    103103    ticks = _Timespec_To_ticks( &tp );
    104 
    105104    if ( ticks == 0 )
    106105      ticks = 1;
     106
    107107    _Watchdog_Insert_ticks( the_timer, _Timespec_To_ticks( &tp ) );
    108108  }
    109109
  • cpukit/rtems/src/semobtain.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/semobtain.c,v
    retrieving revision 1.13
    diff -u -r1.13 semobtain.c
     
    1515 *     + acquire a semaphore
    1616 *     + release a semaphore
    1717 *
    18  *  COPYRIGHT (c) 1989-2007.
     18 *  COPYRIGHT (c) 1989-2008.
    1919 *  On-Line Applications Research Corporation (OAR).
    2020 *
    2121 *  The license and distribution terms for this file may be
     
    9595      _CORE_semaphore_Seize_isr_disable(
    9696        &the_semaphore->Core_control.semaphore,
    9797        id,
    98         ((_Options_Is_no_wait( option_set )) ?
    99           CORE_SEMAPHORE_NO_WAIT : CORE_SEMAPHORE_BLOCK_FOREVER),
     98        ((_Options_Is_no_wait( option_set )) ? FALSE : TRUE),
    10099        timeout,
    101100        &level
    102101      );
  • cpukit/rtems/src/semtranslatereturncode.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/semtranslatereturncode.c,v
    retrieving revision 1.17
    diff -u -r1.17 semtranslatereturncode.c
     
    115115  RTEMS_OBJECT_WAS_DELETED, /* CORE_SEMAPHORE_WAS_DELETED */
    116116  RTEMS_TIMEOUT,            /* CORE_SEMAPHORE_TIMEOUT  */
    117117  RTEMS_INTERNAL_ERROR,     /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
    118   RTEMS_INTERNAL_ERROR      /* CORE_SEMAPHORE_BAD_TIMEOUT_VALUE */
    119118};
    120119
    121120rtems_status_code _Semaphore_Translate_core_semaphore_return_code (
  • cpukit/score/include/rtems/score/coremutex.h

    RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/score/coremutex.h,v
    retrieving revision 1.33
    diff -u -r1.33 coremutex.h
     
    4141#include <rtems/score/interr.h>
    4242#include <rtems/score/sysstate.h>
    4343
    44 
    4544/**
    4645 *  @brief MP Support Callback Prototype
    4746 *
     
    411410  #define _CORE_mutex_Seize( _the_mutex, _id, _wait, _timeout, _level ) \
    412411     _CORE_mutex_Seize_body( _the_mutex, _id, _wait, _timeout, _level )
    413412#endif
     413
    414414/**
    415415 *  @brief Surrender the Mutex
    416416 *
  • cpukit/score/include/rtems/score/coresem.h

    RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/score/coresem.h,v
    retrieving revision 1.23
    diff -u -r1.23 coresem.h
     
    88 */
    99
    1010/*
    11  *  COPYRIGHT (c) 1989-2007.
     11 *  COPYRIGHT (c) 1989-2008.
    1212 *  On-Line Applications Research Corporation (OAR).
    1313 *
    1414 *  The license and distribution terms for this file may be
     
    8282  /** This status indicates that an attempt was made to unlock the semaphore
    8383   *  and this would have made its count greater than that allowed.
    8484   */
    85   CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED,
    86   /** This status indicates that the semaphore was not immediately
    87    *  available and the caller passed a bad timeout value to the API
    88    *  routine.  In this case, the API required that the validity check
    89    *  for the timeout occur after the check that the semaphore was immediately
    90    *  available.
    91    */
    92   CORE_SEMAPHORE_BAD_TIMEOUT_VALUE
     85  CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
    9386}   CORE_semaphore_Status;
    9487
    9588/**
     
    9790 *
    9891 *  This is the last status value.
    9992 */
    100 #define CORE_SEMAPHORE_STATUS_LAST CORE_SEMAPHORE_BAD_TIMEOUT_VALUE
     93#define CORE_SEMAPHORE_STATUS_LAST CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
    10194
    10295/**
    10396 *  The following defines the control block used to manage the
     
    130123}   CORE_semaphore_Control;
    131124
    132125/**
    133  *  The following enumerated type is the set of blocking options
    134  *  available to seize operation.
    135  */
    136 typedef enum {
    137   /** This value indicates that the caller does not wish to block. */
    138   CORE_SEMAPHORE_NO_WAIT,
    139   /** This value indicates that the caller is willing to block forever. */
    140   CORE_SEMAPHORE_BLOCK_FOREVER,
    141   /** This value indicates that the caller is blocking with a timeout. */
    142   CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT,
    143   /** This value indicates that the caller wanted to block but passed in
    144    *  a bad timeout value to the API. Unfortunately, this is a weird case
    145    *  where the timeout bad error is required to be generated only if
    146    *  the semaphore is not available.
    147    */
    148   CORE_SEMAPHORE_BAD_TIMEOUT
    149 } Core_semaphore_Blocking_option;
    150 
    151 /**
    152126 *  This routine initializes the semaphore based on the parameters passed.
    153127 *
    154128 *  @param[in] the_semaphore is the semaphore to initialize
     
    170144 *  @param[in] the_semaphore is the semaphore to seize
    171145 *  @param[in] id is the Id of the API level Semaphore object associated
    172146 *         with this instance of a SuperCore Semaphore
    173  *  @param[in] wait is the blocking mode
     147 *  @param[in] wait indicates if the caller is willing to block
    174148 *  @param[in] timeout is the number of ticks the calling thread is willing
    175149 *         to wait if @a wait is TRUE.
    176150 */
    177151void _CORE_semaphore_Seize(
    178   CORE_semaphore_Control         *the_semaphore,
    179   Objects_Id                      id,
    180   Core_semaphore_Blocking_option  wait,
    181   Watchdog_Interval               timeout
     152  CORE_semaphore_Control  *the_semaphore,
     153  Objects_Id               id,
     154  boolean                  wait,
     155  Watchdog_Interval        timeout
    182156);
    183157
    184158/**
  • cpukit/score/src/coresemseize.c

    RCS file: /usr1/CVS/rtems/cpukit/score/src/coresemseize.c,v
    retrieving revision 1.8
    diff -u -r1.8 coresemseize.c
     
    5151 */
    5252
    5353void _CORE_semaphore_Seize(
    54   CORE_semaphore_Control         *the_semaphore,
    55   Objects_Id                      id,
    56   Core_semaphore_Blocking_option  wait,
    57   Watchdog_Interval               timeout
     54  CORE_semaphore_Control *the_semaphore,
     55  Objects_Id              id,
     56  boolean                 wait,
     57  Watchdog_Interval       timeout
    5858)
    5959{
    6060  Thread_Control *executing;
     
    7474   *  to block, then return immediately with a status indicating that
    7575   *  the semaphore was not available and the caller never blocked.
    7676   */
    77   if ( wait == CORE_SEMAPHORE_NO_WAIT ) {
    78       _ISR_Enable( level );
    79       executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
    80       return;
    81   }
    82 
    83   /*
    84    *  This is strange case because normally RTEMS validates parameters
    85    *  before performing any real work.  But in this case, the POSIX
    86    *  API requires that a semaphore be checked for immediate availability
    87    *  BEFORE the timeout value is validated.  This is implemented in
    88    *  RTEMS by indicating a special status that the timeout value
    89    *  was invalid which is returned in this case.
    90    */
    91   if ( wait == CORE_SEMAPHORE_BAD_TIMEOUT ) {
    92       _ISR_Enable( level );
    93       executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
    94       return;
     77  if ( !wait ) {
     78    _ISR_Enable( level );
     79    executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
     80    return;
    9581  }
    9682
    9783  /*
    9884   *  If the semaphore is not available and the caller is willing to
    9985   *  block, then we now block the caller with optional timeout.
    10086   */
    101   if (( wait == CORE_SEMAPHORE_BLOCK_FOREVER) ||
    102       ( wait == CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT ) ) {
    103       _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
    104       executing->Wait.queue          = &the_semaphore->Wait_queue;
    105       executing->Wait.id             = id;
    106       _ISR_Enable( level );
    107       _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
    108   }
     87  _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
     88  executing->Wait.queue = &the_semaphore->Wait_queue;
     89  executing->Wait.id    = id;
     90  _ISR_Enable( level );
     91  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
    10992}
  • doc/posix_users/mutex.t

    RCS file: /usr1/CVS/rtems/doc/posix_users/mutex.t,v
    retrieving revision 1.6
    diff -u -r1.6 mutex.t
     
    11@c
    2 @c COPYRIGHT (c) 1988-2002.
     2@c COPYRIGHT (c) 1989-2008.
    33@c On-Line Applications Research Corporation (OAR).
    44@c All rights reserved.
    55@c
     
    630630@item EDEADLK
    631631The current thread already owns the mutex.
    632632
     633@item ETIMEDOUT
     634The calling thread was unable to obtain the mutex within the specified
     635timeout period.
     636
    633637@end table
    634638
    635639@subheading DESCRIPTION:
  • testsuites/psxtests/psx05/init.c

    RCS file: /usr1/CVS/rtems/testsuites/psxtests/psx05/init.c,v
    retrieving revision 1.21
    diff -u -r1.21 init.c
     
    11/*
    2  *  COPYRIGHT (c) 1989-1999.
     2 *  COPYRIGHT (c) 1989-2008.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
    55 *  The license and distribution terms for this file may be
     
    7272  }
    7373}
    7474
     75void calculate_abstimeout(
     76  struct timespec *times,
     77  uint32_t         seconds,
     78  uint32_t         nanoseconds
     79)
     80{
     81  struct timeval       tv1;
     82  struct timezone      tz1;
     83
     84  gettimeofday( &tv1, &tz1 );
     85
     86  times->tv_sec  = seconds     + tv1.tv_sec;
     87  times->tv_nsec = nanoseconds + (tv1.tv_usec * 1000);
     88
     89  while ( times->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
     90    times->tv_sec++;
     91    times->tv_nsec - TOD_NANOSECONDS_PER_SECOND;
     92  }
     93
     94}
     95
    7596void *POSIX_Init(
    7697  void *argument
    7798)
     
    343364    printf( "status = %d\n", status );
    344365  assert( status == EPERM );
    345366
    346   times.tv_sec = 0;
    347   times.tv_nsec = 500000000;
    348367  puts( "Init: pthread_mutex_timedlock - time out in 1/2 second" );
     368  calculate_abstimeout( &times, 0, (TOD_NANOSECONDS_PER_SECOND / 2) );
     369
    349370  status = pthread_mutex_timedlock( &Mutex_id, &times );
    350   if ( status != EAGAIN )
     371  if ( status != ETIMEDOUT )
    351372    printf( "status = %d\n", status );
    352   assert( status == EAGAIN );
     373  assert( status == ETIMEDOUT );
    353374
    354375     /* switch to idle */
    355376
  • testsuites/psxtests/psxmsgq01/init.c

    RCS file: /usr1/CVS/rtems/testsuites/psxtests/psxmsgq01/init.c,v
    retrieving revision 1.17
    diff -u -r1.17 init.c
     
    744744  int              status;
    745745  char            *msg;
    746746
    747   timeout.tv_sec  = 1;
    748   timeout.tv_nsec = 0;
    749 
    750747  printf( "Init: mq_timedsend - on queue %s ", Test_q[que].name);
    751748  len = Predefined_Msgs[MAXMSG].size;
    752749  msg = Predefined_Msgs[MAXMSG].msg;
     750
    753751  gettimeofday( &tv1, &tz1 );
     752  timeout.tv_sec  = tv1.tv_sec + 1;
     753  timeout.tv_nsec = tv1.tv_usec * 1000;
     754
    754755  status = mq_timedsend( Test_q[que].mq, msg, len , 0, &timeout );
     756
    755757  gettimeofday( &tv2, &tz2 );
    756758  tv3.tv_sec  = tv2.tv_sec - tv1.tv_sec;
    757759  tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
    758760
    759761  if ( is_blocking ) { /* Don't verify the non-blocking queue */
    760     fatal_int_service_status( status, -1, "mq_timedsend status");
    761     fatal_posix_service_status( errno, ETIMEDOUT,  "errno ETIMEDOUT");
     762    fatal_int_service_status( status, -1, "mq_timedsend status" );
     763    fatal_posix_service_status( errno, ETIMEDOUT,  "errno ETIMEDOUT" );
    762764  }
    763765
    764   printf("Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
    765 
    766   if ( is_blocking ) /* non-blocking queue */
    767     assert( tv3.tv_sec == 1 );
    768   else
    769     assert( tv3.tv_sec == 0 );
     766  printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
    770767
    771768  if ( que == DEFAULT_RW )
    772769    Test_q[que].count++;
     
    799796  struct timezone tz1, tz2;
    800797  int              status;
    801798
    802   tm.tv_sec  = 1;
    803   tm.tv_nsec = 0;
    804 
    805   printf( "Init: %s mq_timedreceive - on queue %s ", task_name, Test_q[que].name);
     799  printf(
     800    "Init: %s mq_timedreceive - on queue %s ",
     801    task_name,
     802    Test_q[que].name
     803  );
    806804
    807805  gettimeofday( &tv1, &tz1 );
     806  tm.tv_sec  = tv1.tv_sec + 1;
     807  tm.tv_nsec = tv1.tv_usec * 1000;
     808
    808809  status = mq_timedreceive( Test_q[ que ].mq, message, 100, &priority, &tm );
     810
    809811  gettimeofday( &tv2, &tz2 );
    810812  tv3.tv_sec  = tv2.tv_sec - tv1.tv_sec;
    811813  tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
     
    815817    fatal_posix_service_status( errno, ETIMEDOUT,  "errno ETIMEDOUT");
    816818  printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
    817819
    818   if ( is_blocking )
    819     assert( tv3.tv_sec == 1 );
    820   else
    821     assert( tv3.tv_sec == 0 );
    822820}
    823821
    824 
    825 
    826822void verify_timed_receive()
    827823{
    828824  int  que;