summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>1999-11-22 16:12:19 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>1999-11-22 16:12:19 +0000
commit2545646bebdd415e62e430da129498dad0a8edba (patch)
tree09cf8e649994ec083e34a7293eb364b4cee06e40
parent+ Corrected bug in error check. (diff)
downloadrtems-2545646bebdd415e62e430da129498dad0a8edba.tar.bz2
+ Updated comments.
+ Corrected enable/disable of dispatch.
-rw-r--r--c/src/exec/posix/src/semopen.c29
-rw-r--r--cpukit/posix/src/semopen.c29
2 files changed, 40 insertions, 18 deletions
diff --git a/c/src/exec/posix/src/semopen.c b/c/src/exec/posix/src/semopen.c
index b52c436e74..8bcf4fccf1 100644
--- a/c/src/exec/posix/src/semopen.c
+++ b/c/src/exec/posix/src/semopen.c
@@ -18,6 +18,11 @@
/*PAGE
*
+ * sem_open
+ *
+ * Opens a named semaphore. Used in conjunction with the sem_close
+ * and sem_unlink commands.
+ *
* 11.2.3 Initialize/Open a Named Semaphore, P1003.1b-1993, p.221
*
* NOTE: When oflag is O_CREAT, then optional third and fourth
@@ -39,7 +44,8 @@ sem_t *sem_open(
Objects_Id the_semaphore_id;
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
-
+
+ _Thread_Disable_dispatch();
if ( oflag & O_CREAT ) {
va_start(arg, oflag);
@@ -60,16 +66,14 @@ sem_t *sem_open(
if ( status ) {
/*
- * Unless we are willing to create name -> ID translation failure is
- * an error.
+ * Unless provided a valid name that did not already exist
+ * and we are willing to create then it is an error.
*/
- if ( status == EINVAL ) {
- if ( !(oflag & O_CREAT) ) {
- set_errno_and_return_minus_one_cast( ENOENT, sem_t * );
- }
+ if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
+ _Thread_Enable_dispatch();
+ set_errno_and_return_minus_one_cast( status, sem_t * );
}
-
} else {
/*
@@ -77,11 +81,14 @@ sem_t *sem_open(
*/
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
+ _Thread_Enable_dispatch();
set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
}
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
the_semaphore->open_count += 1;
+ _Thread_Enable_dispatch();
+ _Thread_Enable_dispatch();
return (sem_t *)&the_semaphore->Object.id;
}
@@ -91,7 +98,7 @@ sem_t *sem_open(
* checked. We should go ahead and create a semaphore.
*/
- status = _POSIX_Semaphore_Create_support(
+ status =_POSIX_Semaphore_Create_support(
name,
FALSE, /* not shared across processes */
value,
@@ -102,8 +109,12 @@ sem_t *sem_open(
* errno was set by Create_support, so don't set it again.
*/
+ _Thread_Enable_dispatch();
+
if ( status == -1 )
return SEM_FAILED;
return (sem_t *) &the_semaphore->Object.id;
}
+
+
diff --git a/cpukit/posix/src/semopen.c b/cpukit/posix/src/semopen.c
index b52c436e74..8bcf4fccf1 100644
--- a/cpukit/posix/src/semopen.c
+++ b/cpukit/posix/src/semopen.c
@@ -18,6 +18,11 @@
/*PAGE
*
+ * sem_open
+ *
+ * Opens a named semaphore. Used in conjunction with the sem_close
+ * and sem_unlink commands.
+ *
* 11.2.3 Initialize/Open a Named Semaphore, P1003.1b-1993, p.221
*
* NOTE: When oflag is O_CREAT, then optional third and fourth
@@ -39,7 +44,8 @@ sem_t *sem_open(
Objects_Id the_semaphore_id;
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
-
+
+ _Thread_Disable_dispatch();
if ( oflag & O_CREAT ) {
va_start(arg, oflag);
@@ -60,16 +66,14 @@ sem_t *sem_open(
if ( status ) {
/*
- * Unless we are willing to create name -> ID translation failure is
- * an error.
+ * Unless provided a valid name that did not already exist
+ * and we are willing to create then it is an error.
*/
- if ( status == EINVAL ) {
- if ( !(oflag & O_CREAT) ) {
- set_errno_and_return_minus_one_cast( ENOENT, sem_t * );
- }
+ if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
+ _Thread_Enable_dispatch();
+ set_errno_and_return_minus_one_cast( status, sem_t * );
}
-
} else {
/*
@@ -77,11 +81,14 @@ sem_t *sem_open(
*/
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
+ _Thread_Enable_dispatch();
set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
}
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
the_semaphore->open_count += 1;
+ _Thread_Enable_dispatch();
+ _Thread_Enable_dispatch();
return (sem_t *)&the_semaphore->Object.id;
}
@@ -91,7 +98,7 @@ sem_t *sem_open(
* checked. We should go ahead and create a semaphore.
*/
- status = _POSIX_Semaphore_Create_support(
+ status =_POSIX_Semaphore_Create_support(
name,
FALSE, /* not shared across processes */
value,
@@ -102,8 +109,12 @@ sem_t *sem_open(
* errno was set by Create_support, so don't set it again.
*/
+ _Thread_Enable_dispatch();
+
if ( status == -1 )
return SEM_FAILED;
return (sem_t *) &the_semaphore->Object.id;
}
+
+