Changeset fd882ee in rtems


Ignore:
Timestamp:
Nov 2, 1999, 3:29:47 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
d80188eb
Parents:
26c828f
Message:

Now much closer to working.

Files:
2 edited

Legend:

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

    r26c828f rfd882ee  
    6262  _Thread_Disable_dispatch();
    6363 
     64  /* Sharing semaphores among processes is not currently supported */
     65  if (pshared != 0) {
     66    _Thread_Enable_dispatch();
     67    set_errno_and_return_minus_one( ENOSYS );
     68  }
     69
    6470  the_semaphore = _POSIX_Semaphore_Allocate();
    6571 
    6672  if ( !the_semaphore ) {
    6773    _Thread_Enable_dispatch();
    68     set_errno_and_return_minus_one( ENOMEM );
     74    set_errno_and_return_minus_one( ENOSPC );
    6975  }
    7076 
     
    97103
    98104  the_sem_attr->discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
    99  
     105
     106  /*
     107   *  This effectively disables limit checking.
     108   */
     109
     110  the_sem_attr->maximum_count = 0xFFFFFFFF;
     111
    100112  _CORE_semaphore_Initialize(
    101113    &the_semaphore->Semaphore,
     
    244256  Objects_Id                 the_semaphore_id;
    245257  POSIX_Semaphore_Control   *the_semaphore;
     258  Objects_Locations          location;
    246259 
    247260
    248261  if ( oflag & O_CREAT ) {
    249262    va_start(arg, oflag);
    250     mode = (mode_t) va_arg( arg, mode_t * );
    251     value = (unsigned int) va_arg( arg, unsigned int * );
     263    /*mode = (mode_t) va_arg( arg, mode_t * );*/
     264    mode = va_arg( arg, mode_t );
     265    /*value = (unsigned int) va_arg( arg, unsigned int * );*/
     266    value = va_arg( arg, unsigned int );
    252267    va_end(arg);
    253268  }
     
    271286    }
    272287    /* some type of error */
    273     set_errno_and_return_minus_one_cast( status, sem_t * );
     288    /*set_errno_and_return_minus_one_cast( status, sem_t * );*/
    274289
    275290  } else {                /* name -> ID translation succeeded */
     
    284299     */
    285300
     301    the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
    286302    the_semaphore->open_count += 1;
    287303
     
    298314  status = _POSIX_Semaphore_Create_support(
    299315    name,
    300     TRUE,         /* shared across processes */
     316    FALSE,         /* not shared across processes */
    301317    value,
    302318    &the_semaphore
     
    432448  register POSIX_Semaphore_Control *the_semaphore;
    433449  Objects_Locations                 location;
     450  int                               code;
    434451 
    435452  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
     
    449466      );
    450467      _Thread_Enable_dispatch();
    451       return _Thread_Executing->Wait.return_code;
     468      code = _Thread_Executing->Wait.return_code;
     469      switch (_Thread_Executing->Wait.return_code) {
     470        case 1:
     471          errno = EAGAIN;
     472          code = -1;
     473          break;
     474        case 3:
     475          errno = ETIMEDOUT;
     476          code = -1;
     477          break;
     478      }
     479
     480      /*return _Thread_Executing->Wait.return_code;*/
     481      return code;
    452482  }
    453483  return POSIX_BOTTOM_REACHED();
     
    574604  return POSIX_BOTTOM_REACHED();
    575605}
     606
     607/*PAGE
     608 *
     609 *  _POSIX_Semaphore_Name_to_id
     610 *
     611 *  XXX
     612 */
     613
     614int _POSIX_Semaphore_Name_to_id(
     615  const char          *name,
     616  Objects_Id          *id
     617)
     618{
     619  Objects_Name_to_id_errors  status;
     620
     621  status = _Objects_Name_to_id( &_POSIX_Semaphore_Information, name, 0, id );
     622
     623  if ( status == OBJECTS_SUCCESSFUL ) {
     624          return 0;
     625  } else {
     626          return EINVAL;
     627  }
     628}
     629
  • cpukit/posix/src/semaphore.c

    r26c828f rfd882ee  
    6262  _Thread_Disable_dispatch();
    6363 
     64  /* Sharing semaphores among processes is not currently supported */
     65  if (pshared != 0) {
     66    _Thread_Enable_dispatch();
     67    set_errno_and_return_minus_one( ENOSYS );
     68  }
     69
    6470  the_semaphore = _POSIX_Semaphore_Allocate();
    6571 
    6672  if ( !the_semaphore ) {
    6773    _Thread_Enable_dispatch();
    68     set_errno_and_return_minus_one( ENOMEM );
     74    set_errno_and_return_minus_one( ENOSPC );
    6975  }
    7076 
     
    97103
    98104  the_sem_attr->discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
    99  
     105
     106  /*
     107   *  This effectively disables limit checking.
     108   */
     109
     110  the_sem_attr->maximum_count = 0xFFFFFFFF;
     111
    100112  _CORE_semaphore_Initialize(
    101113    &the_semaphore->Semaphore,
     
    244256  Objects_Id                 the_semaphore_id;
    245257  POSIX_Semaphore_Control   *the_semaphore;
     258  Objects_Locations          location;
    246259 
    247260
    248261  if ( oflag & O_CREAT ) {
    249262    va_start(arg, oflag);
    250     mode = (mode_t) va_arg( arg, mode_t * );
    251     value = (unsigned int) va_arg( arg, unsigned int * );
     263    /*mode = (mode_t) va_arg( arg, mode_t * );*/
     264    mode = va_arg( arg, mode_t );
     265    /*value = (unsigned int) va_arg( arg, unsigned int * );*/
     266    value = va_arg( arg, unsigned int );
    252267    va_end(arg);
    253268  }
     
    271286    }
    272287    /* some type of error */
    273     set_errno_and_return_minus_one_cast( status, sem_t * );
     288    /*set_errno_and_return_minus_one_cast( status, sem_t * );*/
    274289
    275290  } else {                /* name -> ID translation succeeded */
     
    284299     */
    285300
     301    the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
    286302    the_semaphore->open_count += 1;
    287303
     
    298314  status = _POSIX_Semaphore_Create_support(
    299315    name,
    300     TRUE,         /* shared across processes */
     316    FALSE,         /* not shared across processes */
    301317    value,
    302318    &the_semaphore
     
    432448  register POSIX_Semaphore_Control *the_semaphore;
    433449  Objects_Locations                 location;
     450  int                               code;
    434451 
    435452  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
     
    449466      );
    450467      _Thread_Enable_dispatch();
    451       return _Thread_Executing->Wait.return_code;
     468      code = _Thread_Executing->Wait.return_code;
     469      switch (_Thread_Executing->Wait.return_code) {
     470        case 1:
     471          errno = EAGAIN;
     472          code = -1;
     473          break;
     474        case 3:
     475          errno = ETIMEDOUT;
     476          code = -1;
     477          break;
     478      }
     479
     480      /*return _Thread_Executing->Wait.return_code;*/
     481      return code;
    452482  }
    453483  return POSIX_BOTTOM_REACHED();
     
    574604  return POSIX_BOTTOM_REACHED();
    575605}
     606
     607/*PAGE
     608 *
     609 *  _POSIX_Semaphore_Name_to_id
     610 *
     611 *  XXX
     612 */
     613
     614int _POSIX_Semaphore_Name_to_id(
     615  const char          *name,
     616  Objects_Id          *id
     617)
     618{
     619  Objects_Name_to_id_errors  status;
     620
     621  status = _Objects_Name_to_id( &_POSIX_Semaphore_Information, name, 0, id );
     622
     623  if ( status == OBJECTS_SUCCESSFUL ) {
     624          return 0;
     625  } else {
     626          return EINVAL;
     627  }
     628}
     629
Note: See TracChangeset for help on using the changeset viewer.