forked from Imagelibrary/rtems
+ Debuged to the point that you could open, unlink and close a semaphore.
but all paths have not been checked, yet.
This commit is contained in:
@@ -43,8 +43,7 @@ int mq_unlink(
|
||||
Objects_Locations location;
|
||||
|
||||
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
|
||||
|
||||
if ( !status )
|
||||
if ( status != 0 )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
*
|
||||
* _POSIX_Semaphore_Name_to_id
|
||||
*
|
||||
* XXX
|
||||
* Look up the specified name and attempt to locate the id
|
||||
* for the associated semaphore.
|
||||
*/
|
||||
|
||||
int _POSIX_Semaphore_Name_to_id(
|
||||
@@ -30,12 +31,12 @@ int _POSIX_Semaphore_Name_to_id(
|
||||
{
|
||||
Objects_Name_to_id_errors status;
|
||||
|
||||
status = _Objects_Name_to_id( &_POSIX_Semaphore_Information, (char *)name, 0, id );
|
||||
status = _Objects_Name_to_id(
|
||||
&_POSIX_Semaphore_Information, (char *)name, 0, id );
|
||||
|
||||
if ( status == OBJECTS_SUCCESSFUL ) {
|
||||
return 0;
|
||||
} else {
|
||||
return EINVAL;
|
||||
}
|
||||
if ( status == OBJECTS_SUCCESSFUL )
|
||||
return 0;
|
||||
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,7 @@ sem_t *sem_open(
|
||||
|
||||
if ( oflag & O_CREAT ) {
|
||||
va_start(arg, oflag);
|
||||
/*mode = (mode_t) va_arg( arg, mode_t * );*/
|
||||
mode = va_arg( arg, mode_t );
|
||||
/*value = (unsigned int) va_arg( arg, unsigned int * );*/
|
||||
value = va_arg( arg, unsigned int );
|
||||
va_end(arg);
|
||||
}
|
||||
@@ -61,35 +59,34 @@ sem_t *sem_open(
|
||||
|
||||
if ( status ) {
|
||||
|
||||
if ( status == EINVAL ) { /* name -> ID translation failed */
|
||||
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
||||
/*
|
||||
* Unless we are willing to create name -> ID translation failure is
|
||||
* an error.
|
||||
*/
|
||||
|
||||
if ( status == EINVAL ) {
|
||||
if ( !(oflag & O_CREAT) ) {
|
||||
set_errno_and_return_minus_one_cast( ENOENT, sem_t * );
|
||||
}
|
||||
/* we are willing to create it */
|
||||
}
|
||||
/* some type of error */
|
||||
/*set_errno_and_return_minus_one_cast( status, sem_t * );*/
|
||||
|
||||
} else { /* name -> ID translation succeeded */
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Check for existence with creation.
|
||||
*/
|
||||
|
||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||
set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX In this case we need to do an ID->pointer conversion to
|
||||
* check the mode. This is probably a good place for a subroutine.
|
||||
*/
|
||||
|
||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||
the_semaphore->open_count += 1;
|
||||
|
||||
return (sem_t *)&the_semaphore->Object.id;
|
||||
|
||||
}
|
||||
|
||||
/* XXX verify this comment...
|
||||
*
|
||||
/*
|
||||
* At this point, the semaphore does not exist and everything has been
|
||||
* checked. We should go ahead and create a semaphore.
|
||||
*/
|
||||
@@ -101,9 +98,12 @@ sem_t *sem_open(
|
||||
&the_semaphore
|
||||
);
|
||||
|
||||
/*
|
||||
* errno was set by Create_support, so don't set it again.
|
||||
*/
|
||||
|
||||
if ( status == -1 )
|
||||
return (sem_t *) -1;
|
||||
return SEM_FAILED;
|
||||
|
||||
return (sem_t *) &the_semaphore->Object.id;
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ int sem_unlink(
|
||||
Objects_Locations location;
|
||||
|
||||
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
|
||||
|
||||
if ( !status )
|
||||
if ( status != 0 )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||
@@ -55,7 +54,7 @@ int sem_unlink(
|
||||
#endif
|
||||
|
||||
the_semaphore->linked = FALSE;
|
||||
|
||||
_POSIX_Semaphore_Namespace_remove( the_semaphore );
|
||||
_POSIX_Semaphore_Delete( the_semaphore );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
@@ -43,8 +43,7 @@ int mq_unlink(
|
||||
Objects_Locations location;
|
||||
|
||||
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
|
||||
|
||||
if ( !status )
|
||||
if ( status != 0 )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
*
|
||||
* _POSIX_Semaphore_Name_to_id
|
||||
*
|
||||
* XXX
|
||||
* Look up the specified name and attempt to locate the id
|
||||
* for the associated semaphore.
|
||||
*/
|
||||
|
||||
int _POSIX_Semaphore_Name_to_id(
|
||||
@@ -30,12 +31,12 @@ int _POSIX_Semaphore_Name_to_id(
|
||||
{
|
||||
Objects_Name_to_id_errors status;
|
||||
|
||||
status = _Objects_Name_to_id( &_POSIX_Semaphore_Information, (char *)name, 0, id );
|
||||
status = _Objects_Name_to_id(
|
||||
&_POSIX_Semaphore_Information, (char *)name, 0, id );
|
||||
|
||||
if ( status == OBJECTS_SUCCESSFUL ) {
|
||||
return 0;
|
||||
} else {
|
||||
return EINVAL;
|
||||
}
|
||||
if ( status == OBJECTS_SUCCESSFUL )
|
||||
return 0;
|
||||
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,7 @@ sem_t *sem_open(
|
||||
|
||||
if ( oflag & O_CREAT ) {
|
||||
va_start(arg, oflag);
|
||||
/*mode = (mode_t) va_arg( arg, mode_t * );*/
|
||||
mode = va_arg( arg, mode_t );
|
||||
/*value = (unsigned int) va_arg( arg, unsigned int * );*/
|
||||
value = va_arg( arg, unsigned int );
|
||||
va_end(arg);
|
||||
}
|
||||
@@ -61,35 +59,34 @@ sem_t *sem_open(
|
||||
|
||||
if ( status ) {
|
||||
|
||||
if ( status == EINVAL ) { /* name -> ID translation failed */
|
||||
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
||||
/*
|
||||
* Unless we are willing to create name -> ID translation failure is
|
||||
* an error.
|
||||
*/
|
||||
|
||||
if ( status == EINVAL ) {
|
||||
if ( !(oflag & O_CREAT) ) {
|
||||
set_errno_and_return_minus_one_cast( ENOENT, sem_t * );
|
||||
}
|
||||
/* we are willing to create it */
|
||||
}
|
||||
/* some type of error */
|
||||
/*set_errno_and_return_minus_one_cast( status, sem_t * );*/
|
||||
|
||||
} else { /* name -> ID translation succeeded */
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Check for existence with creation.
|
||||
*/
|
||||
|
||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||
set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX In this case we need to do an ID->pointer conversion to
|
||||
* check the mode. This is probably a good place for a subroutine.
|
||||
*/
|
||||
|
||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||
the_semaphore->open_count += 1;
|
||||
|
||||
return (sem_t *)&the_semaphore->Object.id;
|
||||
|
||||
}
|
||||
|
||||
/* XXX verify this comment...
|
||||
*
|
||||
/*
|
||||
* At this point, the semaphore does not exist and everything has been
|
||||
* checked. We should go ahead and create a semaphore.
|
||||
*/
|
||||
@@ -101,9 +98,12 @@ sem_t *sem_open(
|
||||
&the_semaphore
|
||||
);
|
||||
|
||||
/*
|
||||
* errno was set by Create_support, so don't set it again.
|
||||
*/
|
||||
|
||||
if ( status == -1 )
|
||||
return (sem_t *) -1;
|
||||
return SEM_FAILED;
|
||||
|
||||
return (sem_t *) &the_semaphore->Object.id;
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ int sem_unlink(
|
||||
Objects_Locations location;
|
||||
|
||||
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
|
||||
|
||||
if ( !status )
|
||||
if ( status != 0 )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||
@@ -55,7 +54,7 @@ int sem_unlink(
|
||||
#endif
|
||||
|
||||
the_semaphore->linked = FALSE;
|
||||
|
||||
_POSIX_Semaphore_Namespace_remove( the_semaphore );
|
||||
_POSIX_Semaphore_Delete( the_semaphore );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
Reference in New Issue
Block a user