Changeset e72d995a in rtems


Ignore:
Timestamp:
May 31, 1996, 7:01:26 PM (24 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
1e665a5
Parents:
b927fba
Message:

moved sleep() from psignal.c to unistd.c

implemented sigemptyset() sigfillset(), sigaddset(), sigdelset(), and
sigismember().

added checks for valid attribute values to some of the pthread_attr_t sets.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/src/psignal.c

    rb927fba re72d995a  
    33 */
    44
     5#include <assert.h>
     6#include <errno.h>
    57#include <signal.h>
    68
    79#include <rtems/system.h>
    810#include <rtems/score/thread.h>
     11
     12/*
     13 *  Currently only 20 signals numbered 1-20 are defined
     14 */
     15
     16#define SIGNAL_ALL_MASK  0x000fffff
     17
     18#define signo_to_mask( _sig ) (1 << ((_sig) - 1))
     19
     20#define is_valid_signo( _sig ) \
     21  ((signo_to_mask(_sig) & SIGNAL_ALL_MASK) != 0 )
    922
    1023/*
     
    3447)
    3548{
    36   return POSIX_NOT_IMPLEMENTED();
     49  assert( set );  /* no word from posix, solaris returns EFAULT */
     50
     51  *set = 0;
     52  return 0;
    3753}
    3854
     
    4561)
    4662{
    47   return POSIX_NOT_IMPLEMENTED();
     63  assert( set );
     64
     65  *set = SIGNAL_ALL_MASK;
     66  return 0;
    4867}
    4968
     
    5776)
    5877{
    59   return POSIX_NOT_IMPLEMENTED();
     78  assert( set );
     79
     80  if ( !is_valid_signo(signo) ) {
     81    errno = EINVAL;
     82    return -1;
     83  }
     84
     85  *set |= signo_to_mask(signo);
     86  return 0;
    6087}
    6188
     
    6996)
    7097{
    71   return POSIX_NOT_IMPLEMENTED();
     98  assert( set );
     99 
     100  if ( !is_valid_signo(signo) ) {
     101    errno = EINVAL;
     102    return -1;
     103  }
     104 
     105  *set &= ~signo_to_mask(signo);
     106  return 0;
    72107}
    73108
     
    81116)
    82117{
    83   return POSIX_NOT_IMPLEMENTED();
     118  assert( set );
     119 
     120  if ( !is_valid_signo(signo) ) {
     121    errno = EINVAL;
     122    return -1;
     123  }
     124 
     125  if ( *set & signo_to_mask(signo) )
     126    return 1;
     127
     128  return 0;
    84129}
    85130
     
    229274
    230275/*
    231  *  3.4.2 Suspend Process Execution, P1003.1b-1993, p. 80
     276 *  3.4.2 Suspend Process Execution, P1003.1b-1993, p. 81
    232277 */
    233278
     
    236281  return POSIX_NOT_IMPLEMENTED();
    237282}
    238 
    239 /*
    240  *  3.4.3 Delay Process Execution, P1003.1b-1993, p. 73
    241  */
    242 
    243 unsigned int sleep(
    244   unsigned int seconds
    245 )
    246 {
    247   /* XXX can we get away with this implementation? */
    248   struct timespec tp;
    249 
    250   tp.tv_sec = seconds;
    251   tp.tv_nsec = 0;
    252 
    253   return nanosleep( &tp, NULL );
    254 }
  • c/src/exec/posix/src/pthread.c

    rb927fba re72d995a  
    223223    return EINVAL;
    224224
     225  switch ( contentionscope ) {
     226    case PTHREAD_SCOPE_PROCESS:
     227    case PTHREAD_SCOPE_SYSTEM:
     228      break;
     229    default:
     230      return EINVAL;
     231  }
     232
    225233  attr->contentionscope = contentionscope;
    226234  return 0;
     
    256264  if ( !attr || !attr->is_initialized )
    257265    return EINVAL;
     266
     267  switch ( inheritsched ) {
     268    case PTHREAD_INHERIT_SCHED:
     269    case PTHREAD_EXPLICIT_SCHED:
     270      break;
     271    default:
     272      return EINVAL;
     273  }
    258274
    259275  attr->inheritsched = inheritsched;
     
    568584  int  detachstate;
    569585#endif
     586
     587  /*
     588   *  P1003.1c/D10, p. 121.
     589   *
     590   *  If inheritsched is set to PTHREAD_INHERIT_SCHED, then this thread
     591   *  inherits scheduling attributes from the creating thread.   If it is
     592   *  PTHREAD_EXPLICIT_SCHED, then scheduling parameters come from the
     593   *  attributes structure.
     594   */
     595
     596  switch ( attrp->inheritsched ) {
     597    case PTHREAD_INHERIT_SCHED:
     598      break;
     599    case PTHREAD_EXPLICIT_SCHED:
     600      break;
     601  }
    570602
    571603  /*
  • c/src/exec/posix/src/time.c

    rb927fba re72d995a  
    299299  Watchdog_Interval ticks;
    300300
     301  if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
     302    errno = EINVAL;
     303    return -1;
     304  }
     305 
    301306/* XXX this is interruptible by a posix signal */
    302307
    303308/* XXX rmtp is the time remaining on the timer -- we do not support this */
    304 
    305 /* XXX rmtp may be NULL */
    306309
    307310  ticks = _POSIX_Time_Spec_to_interval( rqtp );
     
    317320    _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks );
    318321  _Thread_Enable_dispatch();
    319   return 0;                    /* XXX should account for signal/remaining */
     322
     323  if ( rmtp ) {
     324    /* XXX calculate time remaining */
     325  }
     326
     327  return 0;                    /* XXX should account for signal */
    320328
    321329}
  • c/src/exec/posix/src/unistd.c

    rb927fba re72d995a  
    33 */
    44
     5#include <time.h>
    56#include <unistd.h>
    67
    78#include <rtems/system.h>
    89
     10
     11/*
     12 *  3.4.3 Delay Process Execution, P1003.1b-1993, p. 73
     13 */
     14
     15unsigned int sleep(
     16  unsigned int seconds
     17)
     18{
     19  /* XXX can we get away with this implementation? */
     20  struct timespec tp;
     21  struct timespec tm;
     22
     23  tp.tv_sec = seconds;
     24  tp.tv_nsec = 0;
     25
     26  nanosleep( &tp, &tm );
     27
     28  return tm->tv_sec;       /* seconds remaining */
     29}
    930/*
    1031 *  4.8.1 Get Configurable System Variables, P1003.1b-1993, p. 95
  • cpukit/posix/src/psignal.c

    rb927fba re72d995a  
    33 */
    44
     5#include <assert.h>
     6#include <errno.h>
    57#include <signal.h>
    68
    79#include <rtems/system.h>
    810#include <rtems/score/thread.h>
     11
     12/*
     13 *  Currently only 20 signals numbered 1-20 are defined
     14 */
     15
     16#define SIGNAL_ALL_MASK  0x000fffff
     17
     18#define signo_to_mask( _sig ) (1 << ((_sig) - 1))
     19
     20#define is_valid_signo( _sig ) \
     21  ((signo_to_mask(_sig) & SIGNAL_ALL_MASK) != 0 )
    922
    1023/*
     
    3447)
    3548{
    36   return POSIX_NOT_IMPLEMENTED();
     49  assert( set );  /* no word from posix, solaris returns EFAULT */
     50
     51  *set = 0;
     52  return 0;
    3753}
    3854
     
    4561)
    4662{
    47   return POSIX_NOT_IMPLEMENTED();
     63  assert( set );
     64
     65  *set = SIGNAL_ALL_MASK;
     66  return 0;
    4867}
    4968
     
    5776)
    5877{
    59   return POSIX_NOT_IMPLEMENTED();
     78  assert( set );
     79
     80  if ( !is_valid_signo(signo) ) {
     81    errno = EINVAL;
     82    return -1;
     83  }
     84
     85  *set |= signo_to_mask(signo);
     86  return 0;
    6087}
    6188
     
    6996)
    7097{
    71   return POSIX_NOT_IMPLEMENTED();
     98  assert( set );
     99 
     100  if ( !is_valid_signo(signo) ) {
     101    errno = EINVAL;
     102    return -1;
     103  }
     104 
     105  *set &= ~signo_to_mask(signo);
     106  return 0;
    72107}
    73108
     
    81116)
    82117{
    83   return POSIX_NOT_IMPLEMENTED();
     118  assert( set );
     119 
     120  if ( !is_valid_signo(signo) ) {
     121    errno = EINVAL;
     122    return -1;
     123  }
     124 
     125  if ( *set & signo_to_mask(signo) )
     126    return 1;
     127
     128  return 0;
    84129}
    85130
     
    229274
    230275/*
    231  *  3.4.2 Suspend Process Execution, P1003.1b-1993, p. 80
     276 *  3.4.2 Suspend Process Execution, P1003.1b-1993, p. 81
    232277 */
    233278
     
    236281  return POSIX_NOT_IMPLEMENTED();
    237282}
    238 
    239 /*
    240  *  3.4.3 Delay Process Execution, P1003.1b-1993, p. 73
    241  */
    242 
    243 unsigned int sleep(
    244   unsigned int seconds
    245 )
    246 {
    247   /* XXX can we get away with this implementation? */
    248   struct timespec tp;
    249 
    250   tp.tv_sec = seconds;
    251   tp.tv_nsec = 0;
    252 
    253   return nanosleep( &tp, NULL );
    254 }
  • cpukit/posix/src/pthread.c

    rb927fba re72d995a  
    223223    return EINVAL;
    224224
     225  switch ( contentionscope ) {
     226    case PTHREAD_SCOPE_PROCESS:
     227    case PTHREAD_SCOPE_SYSTEM:
     228      break;
     229    default:
     230      return EINVAL;
     231  }
     232
    225233  attr->contentionscope = contentionscope;
    226234  return 0;
     
    256264  if ( !attr || !attr->is_initialized )
    257265    return EINVAL;
     266
     267  switch ( inheritsched ) {
     268    case PTHREAD_INHERIT_SCHED:
     269    case PTHREAD_EXPLICIT_SCHED:
     270      break;
     271    default:
     272      return EINVAL;
     273  }
    258274
    259275  attr->inheritsched = inheritsched;
     
    568584  int  detachstate;
    569585#endif
     586
     587  /*
     588   *  P1003.1c/D10, p. 121.
     589   *
     590   *  If inheritsched is set to PTHREAD_INHERIT_SCHED, then this thread
     591   *  inherits scheduling attributes from the creating thread.   If it is
     592   *  PTHREAD_EXPLICIT_SCHED, then scheduling parameters come from the
     593   *  attributes structure.
     594   */
     595
     596  switch ( attrp->inheritsched ) {
     597    case PTHREAD_INHERIT_SCHED:
     598      break;
     599    case PTHREAD_EXPLICIT_SCHED:
     600      break;
     601  }
    570602
    571603  /*
  • cpukit/posix/src/time.c

    rb927fba re72d995a  
    299299  Watchdog_Interval ticks;
    300300
     301  if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
     302    errno = EINVAL;
     303    return -1;
     304  }
     305 
    301306/* XXX this is interruptible by a posix signal */
    302307
    303308/* XXX rmtp is the time remaining on the timer -- we do not support this */
    304 
    305 /* XXX rmtp may be NULL */
    306309
    307310  ticks = _POSIX_Time_Spec_to_interval( rqtp );
     
    317320    _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks );
    318321  _Thread_Enable_dispatch();
    319   return 0;                    /* XXX should account for signal/remaining */
     322
     323  if ( rmtp ) {
     324    /* XXX calculate time remaining */
     325  }
     326
     327  return 0;                    /* XXX should account for signal */
    320328
    321329}
Note: See TracChangeset for help on using the changeset viewer.