Changeset bdc468a in rtems


Ignore:
Timestamp:
Sep 22, 2017, 6:22:11 AM (20 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
560acb62
Parents:
714cb06
git-author:
Sebastian Huber <sebastian.huber@…> (09/22/17 06:22:11)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/22/17 06:24:57)
Message:

posix: Allow PTHREAD_PROCESS_SHARED for rwlocks

Close #3153.

Files:
2 edited

Legend:

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

    r714cb06 rbdc468a  
    5959)
    6060{
    61   POSIX_RWLock_Control        *the_rwlock;
    62   pthread_rwlockattr_t         default_attr;
    63   const pthread_rwlockattr_t  *the_attr;
     61  POSIX_RWLock_Control *the_rwlock;
    6462
    6563  /*
     
    6967    return EINVAL;
    7068
    71   /*
    72    * If the user passed in NULL, use the default attributes
    73    */
    74   if ( attr ) {
    75     the_attr = attr;
    76   } else {
    77     (void) pthread_rwlockattr_init( &default_attr );
    78     the_attr = &default_attr;
    79   }
     69  if ( attr != NULL ) {
     70    if ( !attr->is_initialized ) {
     71      return EINVAL;
     72    }
    8073
    81   /*
    82    * Now start error checking the attributes that we are going to use
    83    */
    84   if ( !the_attr->is_initialized )
    85     return EINVAL;
    86 
    87   switch ( the_attr->process_shared ) {
    88     case PTHREAD_PROCESS_PRIVATE:    /* only supported values */
    89       break;
    90     case PTHREAD_PROCESS_SHARED:
    91     default:
     74    if ( !_POSIX_Is_valid_pshared( attr->process_shared ) ) {
    9275      return EINVAL;
     76    }
    9377  }
    9478
  • testsuites/psxtests/psxrwlock01/test.c

    r714cb06 rbdc468a  
    8989  rtems_test_assert( !status );
    9090  return NULL;
     91}
     92
     93static void test_pshared_init(void)
     94{
     95  pthread_rwlock_t rwlock;
     96  pthread_rwlockattr_t attr;
     97  int eno;
     98
     99  eno = pthread_rwlockattr_init(&attr);
     100  rtems_test_assert(eno == 0);
     101
     102  eno = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE);
     103  rtems_test_assert(eno == 0);
     104
     105  eno = pthread_rwlock_init(&rwlock, &attr);
     106  rtems_test_assert(eno == 0);
     107
     108  eno = pthread_rwlock_destroy(&rwlock);
     109  rtems_test_assert(eno == 0);
     110
     111  eno = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
     112  rtems_test_assert(eno == 0);
     113
     114  eno = pthread_rwlock_init(&rwlock, &attr);
     115  rtems_test_assert(eno == 0);
     116
     117  eno = pthread_rwlock_destroy(&rwlock);
     118  rtems_test_assert(eno == 0);
     119
     120  attr.process_shared = -1;
     121
     122  eno = pthread_rwlock_init(&rwlock, &attr);
     123  rtems_test_assert(eno == EINVAL);
     124
     125  eno = pthread_rwlockattr_destroy(&attr);
     126  rtems_test_assert(eno == 0);
    91127}
    92128
     
    114150  TEST_BEGIN();
    115151
     152  test_pshared_init();
     153
    116154  /*************** NULL POINTER CHECKS *****************/
    117155  puts( "pthread_rwlockattr_init( NULL ) -- EINVAL" );
Note: See TracChangeset for help on using the changeset viewer.