Changeset c238a218 in rtems


Ignore:
Timestamp:
May 31, 1996, 9:40:48 PM (24 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
5e7b6272
Parents:
f31da72
Message:

added checks to validate values passed to set attribute routines

Files:
12 edited

Legend:

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

    rf31da72 rc238a218  
    143143    return EINVAL;
    144144
    145   attr->process_shared = pshared;
    146   return 0;
     145  switch ( pshared ) {
     146    case PTHREAD_PROCESS_SHARED:
     147    case PTHREAD_PROCESS_PRIVATE:
     148      attr->process_shared = pshared;
     149      return 0;
     150
     151    default:
     152      return EINVAL;
     153  }
    147154}
    148155 
  • c/src/exec/posix/src/mutex.c

    rf31da72 rc238a218  
    152152    return EINVAL;
    153153
    154   attr->process_shared = pshared;
    155   return 0;
     154  switch ( pshared ) {
     155    case PTHREAD_PROCESS_SHARED:
     156    case PTHREAD_PROCESS_PRIVATE:
     157      attr->process_shared = pshared;
     158      return 0;
     159
     160    default:
     161      return EINVAL;
     162  }
    156163}
    157164
     
    467474    return EINVAL;
    468475
    469   attr->protocol = protocol;
    470   return 0;
     476  switch ( protocol ) {
     477    case PTHREAD_PRIO_NONE:
     478    case PTHREAD_PRIO_INHERIT:
     479    case PTHREAD_PRIO_PROTECT:
     480      attr->protocol = protocol;
     481      return 0;
     482 
     483    default:
     484      return EINVAL;
     485  }
    471486}
    472487
  • c/src/exec/posix/src/psignal.c

    rf31da72 rc238a218  
    3232)
    3333{
     34  /*
     35   *  Only supported for the "calling process" (i.e. this node).
     36   */
     37 
     38  assert( pid == getpid() );
     39
    3440  /* SIGABRT comes from abort via assert */
    3541  if ( sig == SIGABRT ) {
  • c/src/exec/posix/src/pthread.c

    rf31da72 rc238a218  
    8181 
    8282  deleted->API_Extensions[ THREAD_API_POSIX ] = NULL;
     83
     84  /* XXX run _POSIX_Keys_Run_destructors here? */
    8385}
    8486
     
    226228    case PTHREAD_SCOPE_PROCESS:
    227229    case PTHREAD_SCOPE_SYSTEM:
    228       break;
     230      attr->contentionscope = contentionscope;
     231      return 0;
     232
    229233    default:
    230234      return EINVAL;
    231235  }
    232 
    233   attr->contentionscope = contentionscope;
    234   return 0;
    235236}
    236237
     
    268269    case PTHREAD_INHERIT_SCHED:
    269270    case PTHREAD_EXPLICIT_SCHED:
    270       break;
     271      attr->inheritsched = inheritsched;
     272      return 0;
     273
    271274    default:
    272275      return EINVAL;
    273276  }
    274 
    275   attr->inheritsched = inheritsched;
    276   return 0;
    277277}
    278278
     
    307307    return EINVAL;
    308308
    309   attr->schedpolicy = policy;
    310   return 0;
     309  switch ( policy ) {
     310    case SCHED_OTHER:
     311    case SCHED_FIFO:
     312    case SCHED_RR:
     313    case SCHED_SPORADIC:
     314      attr->schedpolicy = policy;
     315      return 0;
     316 
     317    default:
     318      return EINVAL;
     319  }
    311320}
    312321
     
    402411    return EINVAL;
    403412
    404   attr->schedpolicy = policy;
    405   attr->schedparam  = *param;
    406   return 0;
     413  switch ( policy ) {
     414    case SCHED_OTHER:
     415    case SCHED_FIFO:
     416    case SCHED_RR:
     417    case SCHED_SPORADIC:
     418      attr->schedpolicy = policy;
     419      attr->schedparam  = *param;
     420      return 0;
     421 
     422    default:
     423      return EINVAL;
     424  }
    407425}
    408426
     
    469487    return EINVAL;
    470488
    471   if ( stacksize < STACK_MINIMUM_SIZE )
     489  if (stacksize < STACK_MINIMUM_SIZE)
    472490    attr->stacksize = STACK_MINIMUM_SIZE;
    473491  else
     
    540558    return EINVAL;
    541559
    542   attr->detachstate = detachstate;
    543   return 0;
     560  switch ( detachstate ) {
     561    case PTHREAD_CREATE_DETACHED:
     562    case PTHREAD_CREATE_JOINABLE:
     563      attr->detachstate = detachstate;
     564      return 0;
     565 
     566    default:
     567      return EINVAL;
     568  }
    544569}
    545570
     
    734759   */
    735760
     761  /* XXX run _POSIX_Keys_Run_destructors here? */
     762
    736763  _Thread_Close( &_POSIX_Threads_Information, the_thread );
    737764 
     
    830857    return EINVAL;
    831858
    832   attr->cputime_clock_allowed = clock_allowed;
    833   return 0;
     859  switch ( clock_allowed ) {
     860    case CLOCK_ENABLED:
     861    case CLOCK_DISABLED:
     862      attr->cputime_clock_allowed = clock_allowed;
     863      return 0;
     864 
     865    default:
     866      return EINVAL;
     867  }
    834868}
    835869
  • c/src/exec/posix/src/sched.c

    rf31da72 rc238a218  
    4949)
    5050{
     51  /*
     52   *  Only supported for the "calling process" (i.e. this node).
     53   */
     54
     55  assert( pid == getpid() );
     56
    5157  return POSIX_NOT_IMPLEMENTED();
    5258}
     
    6167)
    6268{
     69  /*
     70   *  Only supported for the "calling process" (i.e. this node).
     71   */
     72
     73  assert( pid == getpid() );
     74
    6375  return POSIX_NOT_IMPLEMENTED();
    6476}
     
    106118  /* XXX should get for errors? (bad pid) */
    107119
     120  /* XXX some of the time routines also convert usecs to a timespec -- */
     121  /* XXX   should this be a common routine? */
     122
    108123  us_per_quantum = _TOD_Microseconds_per_tick * _Thread_Ticks_per_timeslice;
    109124
    110125  interval->tv_sec  = us_per_quantum / TOD_MICROSECONDS_PER_SECOND;
    111   interval->tv_nsec = (us_per_quantum % TOD_MICROSECONDS_PER_SECOND) * 1000;
     126  interval->tv_nsec = (us_per_quantum % TOD_MICROSECONDS_PER_SECOND) *
     127                         TOD_NANOSECONDS_PER_MICROSECOND;
    112128  return 0;
    113129}
  • c/src/exec/posix/src/types.c

    rf31da72 rc238a218  
    66
    77#include <rtems/system.h>
     8#include <rtems/score/object.h>
    89
    910/*PAGE
     
    1415pid_t getpid( void )
    1516{
    16   return POSIX_NOT_IMPLEMENTED();
     17  return _Objects_Local_node;
    1718}
    1819
  • cpukit/posix/src/cond.c

    rf31da72 rc238a218  
    143143    return EINVAL;
    144144
    145   attr->process_shared = pshared;
    146   return 0;
     145  switch ( pshared ) {
     146    case PTHREAD_PROCESS_SHARED:
     147    case PTHREAD_PROCESS_PRIVATE:
     148      attr->process_shared = pshared;
     149      return 0;
     150
     151    default:
     152      return EINVAL;
     153  }
    147154}
    148155 
  • cpukit/posix/src/mutex.c

    rf31da72 rc238a218  
    152152    return EINVAL;
    153153
    154   attr->process_shared = pshared;
    155   return 0;
     154  switch ( pshared ) {
     155    case PTHREAD_PROCESS_SHARED:
     156    case PTHREAD_PROCESS_PRIVATE:
     157      attr->process_shared = pshared;
     158      return 0;
     159
     160    default:
     161      return EINVAL;
     162  }
    156163}
    157164
     
    467474    return EINVAL;
    468475
    469   attr->protocol = protocol;
    470   return 0;
     476  switch ( protocol ) {
     477    case PTHREAD_PRIO_NONE:
     478    case PTHREAD_PRIO_INHERIT:
     479    case PTHREAD_PRIO_PROTECT:
     480      attr->protocol = protocol;
     481      return 0;
     482 
     483    default:
     484      return EINVAL;
     485  }
    471486}
    472487
  • cpukit/posix/src/psignal.c

    rf31da72 rc238a218  
    3232)
    3333{
     34  /*
     35   *  Only supported for the "calling process" (i.e. this node).
     36   */
     37 
     38  assert( pid == getpid() );
     39
    3440  /* SIGABRT comes from abort via assert */
    3541  if ( sig == SIGABRT ) {
  • cpukit/posix/src/pthread.c

    rf31da72 rc238a218  
    8181 
    8282  deleted->API_Extensions[ THREAD_API_POSIX ] = NULL;
     83
     84  /* XXX run _POSIX_Keys_Run_destructors here? */
    8385}
    8486
     
    226228    case PTHREAD_SCOPE_PROCESS:
    227229    case PTHREAD_SCOPE_SYSTEM:
    228       break;
     230      attr->contentionscope = contentionscope;
     231      return 0;
     232
    229233    default:
    230234      return EINVAL;
    231235  }
    232 
    233   attr->contentionscope = contentionscope;
    234   return 0;
    235236}
    236237
     
    268269    case PTHREAD_INHERIT_SCHED:
    269270    case PTHREAD_EXPLICIT_SCHED:
    270       break;
     271      attr->inheritsched = inheritsched;
     272      return 0;
     273
    271274    default:
    272275      return EINVAL;
    273276  }
    274 
    275   attr->inheritsched = inheritsched;
    276   return 0;
    277277}
    278278
     
    307307    return EINVAL;
    308308
    309   attr->schedpolicy = policy;
    310   return 0;
     309  switch ( policy ) {
     310    case SCHED_OTHER:
     311    case SCHED_FIFO:
     312    case SCHED_RR:
     313    case SCHED_SPORADIC:
     314      attr->schedpolicy = policy;
     315      return 0;
     316 
     317    default:
     318      return EINVAL;
     319  }
    311320}
    312321
     
    402411    return EINVAL;
    403412
    404   attr->schedpolicy = policy;
    405   attr->schedparam  = *param;
    406   return 0;
     413  switch ( policy ) {
     414    case SCHED_OTHER:
     415    case SCHED_FIFO:
     416    case SCHED_RR:
     417    case SCHED_SPORADIC:
     418      attr->schedpolicy = policy;
     419      attr->schedparam  = *param;
     420      return 0;
     421 
     422    default:
     423      return EINVAL;
     424  }
    407425}
    408426
     
    469487    return EINVAL;
    470488
    471   if ( stacksize < STACK_MINIMUM_SIZE )
     489  if (stacksize < STACK_MINIMUM_SIZE)
    472490    attr->stacksize = STACK_MINIMUM_SIZE;
    473491  else
     
    540558    return EINVAL;
    541559
    542   attr->detachstate = detachstate;
    543   return 0;
     560  switch ( detachstate ) {
     561    case PTHREAD_CREATE_DETACHED:
     562    case PTHREAD_CREATE_JOINABLE:
     563      attr->detachstate = detachstate;
     564      return 0;
     565 
     566    default:
     567      return EINVAL;
     568  }
    544569}
    545570
     
    734759   */
    735760
     761  /* XXX run _POSIX_Keys_Run_destructors here? */
     762
    736763  _Thread_Close( &_POSIX_Threads_Information, the_thread );
    737764 
     
    830857    return EINVAL;
    831858
    832   attr->cputime_clock_allowed = clock_allowed;
    833   return 0;
     859  switch ( clock_allowed ) {
     860    case CLOCK_ENABLED:
     861    case CLOCK_DISABLED:
     862      attr->cputime_clock_allowed = clock_allowed;
     863      return 0;
     864 
     865    default:
     866      return EINVAL;
     867  }
    834868}
    835869
  • cpukit/posix/src/sched.c

    rf31da72 rc238a218  
    4949)
    5050{
     51  /*
     52   *  Only supported for the "calling process" (i.e. this node).
     53   */
     54
     55  assert( pid == getpid() );
     56
    5157  return POSIX_NOT_IMPLEMENTED();
    5258}
     
    6167)
    6268{
     69  /*
     70   *  Only supported for the "calling process" (i.e. this node).
     71   */
     72
     73  assert( pid == getpid() );
     74
    6375  return POSIX_NOT_IMPLEMENTED();
    6476}
     
    106118  /* XXX should get for errors? (bad pid) */
    107119
     120  /* XXX some of the time routines also convert usecs to a timespec -- */
     121  /* XXX   should this be a common routine? */
     122
    108123  us_per_quantum = _TOD_Microseconds_per_tick * _Thread_Ticks_per_timeslice;
    109124
    110125  interval->tv_sec  = us_per_quantum / TOD_MICROSECONDS_PER_SECOND;
    111   interval->tv_nsec = (us_per_quantum % TOD_MICROSECONDS_PER_SECOND) * 1000;
     126  interval->tv_nsec = (us_per_quantum % TOD_MICROSECONDS_PER_SECOND) *
     127                         TOD_NANOSECONDS_PER_MICROSECOND;
    112128  return 0;
    113129}
  • cpukit/posix/src/types.c

    rf31da72 rc238a218  
    66
    77#include <rtems/system.h>
     8#include <rtems/score/object.h>
    89
    910/*PAGE
     
    1415pid_t getpid( void )
    1516{
    16   return POSIX_NOT_IMPLEMENTED();
     17  return _Objects_Local_node;
    1718}
    1819
Note: See TracChangeset for help on using the changeset viewer.