Changeset cb3c1718 in rtems


Ignore:
Timestamp:
Nov 22, 1999, 4:13:22 PM (21 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
101e9b0
Parents:
2545646
Message:

+ Corrected enable/disable of dispatch.
+ Cleaned up code.

Files:
2 edited

Legend:

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

    r2545646 rcb3c1718  
    1919/*PAGE
    2020 *
     21 *  sem_unlink
     22 * 
     23 *  Unlinks a named semaphore, sem_close must also be called to remove
     24 *  the semaphore.
     25 *
    2126 *  11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225
    2227 */
     
    3136  Objects_Locations                 location;
    3237 
     38  _Thread_Disable_dispatch();
     39
    3340  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
    34   if ( status != 0 )
     41  if ( status != 0 ) {
     42    _Thread_Enable_dispatch();
    3543    set_errno_and_return_minus_one( status );
     44  }
    3645
    37   the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
    38   switch ( location ) {
    39     case OBJECTS_ERROR:
    40       set_errno_and_return_minus_one( EINVAL );
    41     case OBJECTS_REMOTE:
    42       _Thread_Dispatch();
    43       return POSIX_MP_NOT_IMPLEMENTED();
    44       set_errno_and_return_minus_one( EINVAL );
    45     case OBJECTS_LOCAL:
     46  /*
     47   *  Don't support unlinking a remote semaphore.
     48   */
    4649
     50  if ( !_Objects_Is_local_id(the_semaphore_id) ) {
     51    _Thread_Enable_dispatch();
     52    set_errno_and_return_minus_one( ENOSYS );
     53  }
     54
     55  the_semaphore = _Objects_Get_local_object(
     56    &_POSIX_Semaphore_Information,
     57    _Objects_Get_index( the_semaphore_id )
     58  );
     59 
    4760#if defined(RTEMS_MULTIPROCESSING)
    48       if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
    49         _Objects_MP_Close(
    50           &_POSIX_Semaphore_Information,
    51           the_semaphore->Object.id
    52         );
    53       }
     61  if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
     62    _Objects_MP_Close( &_POSIX_Semaphore_Information, the_semaphore_id );
     63  }
    5464#endif
    5565
    56       the_semaphore->linked = FALSE;
    57       _POSIX_Semaphore_Namespace_remove( the_semaphore );
    58       _POSIX_Semaphore_Delete( the_semaphore );
     66  the_semaphore->linked = FALSE;
     67  _POSIX_Semaphore_Namespace_remove( the_semaphore );
     68  _POSIX_Semaphore_Delete( the_semaphore );
    5969
    60       _Thread_Enable_dispatch();
    61       return 0;
    62   }
    63   return POSIX_BOTTOM_REACHED();
     70  _Thread_Enable_dispatch();
     71  return 0;
    6472}
  • cpukit/posix/src/semunlink.c

    r2545646 rcb3c1718  
    1919/*PAGE
    2020 *
     21 *  sem_unlink
     22 * 
     23 *  Unlinks a named semaphore, sem_close must also be called to remove
     24 *  the semaphore.
     25 *
    2126 *  11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225
    2227 */
     
    3136  Objects_Locations                 location;
    3237 
     38  _Thread_Disable_dispatch();
     39
    3340  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
    34   if ( status != 0 )
     41  if ( status != 0 ) {
     42    _Thread_Enable_dispatch();
    3543    set_errno_and_return_minus_one( status );
     44  }
    3645
    37   the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
    38   switch ( location ) {
    39     case OBJECTS_ERROR:
    40       set_errno_and_return_minus_one( EINVAL );
    41     case OBJECTS_REMOTE:
    42       _Thread_Dispatch();
    43       return POSIX_MP_NOT_IMPLEMENTED();
    44       set_errno_and_return_minus_one( EINVAL );
    45     case OBJECTS_LOCAL:
     46  /*
     47   *  Don't support unlinking a remote semaphore.
     48   */
    4649
     50  if ( !_Objects_Is_local_id(the_semaphore_id) ) {
     51    _Thread_Enable_dispatch();
     52    set_errno_and_return_minus_one( ENOSYS );
     53  }
     54
     55  the_semaphore = _Objects_Get_local_object(
     56    &_POSIX_Semaphore_Information,
     57    _Objects_Get_index( the_semaphore_id )
     58  );
     59 
    4760#if defined(RTEMS_MULTIPROCESSING)
    48       if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
    49         _Objects_MP_Close(
    50           &_POSIX_Semaphore_Information,
    51           the_semaphore->Object.id
    52         );
    53       }
     61  if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
     62    _Objects_MP_Close( &_POSIX_Semaphore_Information, the_semaphore_id );
     63  }
    5464#endif
    5565
    56       the_semaphore->linked = FALSE;
    57       _POSIX_Semaphore_Namespace_remove( the_semaphore );
    58       _POSIX_Semaphore_Delete( the_semaphore );
     66  the_semaphore->linked = FALSE;
     67  _POSIX_Semaphore_Namespace_remove( the_semaphore );
     68  _POSIX_Semaphore_Delete( the_semaphore );
    5969
    60       _Thread_Enable_dispatch();
    61       return 0;
    62   }
    63   return POSIX_BOTTOM_REACHED();
     70  _Thread_Enable_dispatch();
     71  return 0;
    6472}
Note: See TracChangeset for help on using the changeset viewer.