summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-07 15:21:27 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-07 15:21:27 +0000
commit05ce4e097aeab6292b59a0d3b792cb403eeb6e03 (patch)
tree2f37ce9a4edec10f176cdee1f42c5edc5e8257ec
parentnew file (diff)
downloadrtems-05ce4e097aeab6292b59a0d3b792cb403eeb6e03.tar.bz2
changed code which set errno and then returned -1 to use the macro
set_errno_and_return_minus_one.
-rw-r--r--c/src/exec/posix/src/mqueue.c16
-rw-r--r--c/src/exec/posix/src/sched.c19
-rw-r--r--c/src/exec/posix/src/semaphore.c12
-rw-r--r--c/src/exec/posix/src/time.c34
-rw-r--r--c/src/exec/posix/src/types.c7
-rw-r--r--cpukit/posix/src/mqueue.c16
-rw-r--r--cpukit/posix/src/sched.c19
-rw-r--r--cpukit/posix/src/semaphore.c12
-rw-r--r--cpukit/posix/src/time.c34
-rw-r--r--cpukit/posix/src/types.c7
10 files changed, 64 insertions, 112 deletions
diff --git a/c/src/exec/posix/src/mqueue.c b/c/src/exec/posix/src/mqueue.c
index b489643401..82da4ee706 100644
--- a/c/src/exec/posix/src/mqueue.c
+++ b/c/src/exec/posix/src/mqueue.c
@@ -24,6 +24,7 @@
#include <rtems/system.h>
#include <rtems/score/watchdog.h>
+#include <rtems/posix/seterr.h>
#include <rtems/posix/mqueue.h>
#include <rtems/posix/time.h>
@@ -76,8 +77,7 @@ int _POSIX_Message_queue_Create_support(
if ( !the_mq ) {
_Thread_Enable_dispatch();
- seterrno( ENFILE );
- return -1;
+ set_errno_and_return_minus_one( ENFILE );
}
if ( pshared == PTHREAD_PROCESS_SHARED &&
@@ -85,8 +85,7 @@ int _POSIX_Message_queue_Create_support(
the_mq->Object.id, FALSE ) ) ) {
_POSIX_Message_queue_Free( the_mq );
_Thread_Enable_dispatch();
- seterrno( ENFILE );
- return -1;
+ set_errno_and_return_minus_one( ENFILE );
}
the_mq->process_shared = pshared;
@@ -134,8 +133,7 @@ int _POSIX_Message_queue_Create_support(
_POSIX_Message_queue_Free( the_mq );
_Thread_Enable_dispatch();
- seterrno( ENOSPC );
- return -1;
+ set_errno_and_return_minus_one( ENOSPC );
}
@@ -323,10 +321,8 @@ int mq_unlink(
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
- if ( !status ) {
- seterrno( status );
- return -1;
- }
+ if ( !status )
+ set_errno_and_return_minus_one( status );
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
switch ( location ) {
diff --git a/c/src/exec/posix/src/sched.c b/c/src/exec/posix/src/sched.c
index b66c6fb195..f16bb12757 100644
--- a/c/src/exec/posix/src/sched.c
+++ b/c/src/exec/posix/src/sched.c
@@ -9,6 +9,7 @@
#include <rtems/system.h>
#include <rtems/score/tod.h>
#include <rtems/score/thread.h>
+#include <rtems/posix/seterr.h>
#include <rtems/posix/priority.h>
#include <rtems/posix/time.h>
@@ -23,8 +24,7 @@ int sched_setparam(
const struct sched_param *param
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -37,8 +37,7 @@ int sched_getparam(
const struct sched_param *param
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -53,8 +52,7 @@ int sched_setscheduler(
const struct sched_param *param
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -66,8 +64,7 @@ int sched_getscheduler(
pid_t pid
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -87,8 +84,7 @@ int sched_get_priority_max(
break;
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return POSIX_SCHEDULER_MAXIMUM_PRIORITY;
@@ -111,8 +107,7 @@ int sched_get_priority_min(
break;
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return POSIX_SCHEDULER_MINIMUM_PRIORITY;
diff --git a/c/src/exec/posix/src/semaphore.c b/c/src/exec/posix/src/semaphore.c
index 628e094716..a968abe43b 100644
--- a/c/src/exec/posix/src/semaphore.c
+++ b/c/src/exec/posix/src/semaphore.c
@@ -64,8 +64,7 @@ int _POSIX_Semaphore_Create_support(
if ( !the_semaphore ) {
_Thread_Enable_dispatch();
- seterrno( ENOMEM );
- return -1;
+ set_errno_and_return_minus_one( ENOMEM );
}
if ( pshared == PTHREAD_PROCESS_SHARED &&
@@ -73,8 +72,7 @@ int _POSIX_Semaphore_Create_support(
the_semaphore->Object.id, FALSE ) ) ) {
_POSIX_Semaphore_Free( the_semaphore );
_Thread_Enable_dispatch();
- seterrno( EAGAIN );
- return -1;
+ set_errno_and_return_minus_one( EAGAIN );
}
the_semaphore->process_shared = pshared;
@@ -382,10 +380,8 @@ int sem_unlink(
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
- if ( !status ) {
- seterrno( status );
- return -1;
- }
+ if ( !status )
+ set_errno_and_return_minus_one( status );
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
switch ( location ) {
diff --git a/c/src/exec/posix/src/time.c b/c/src/exec/posix/src/time.c
index 95fdbcc8d5..3860ae993d 100644
--- a/c/src/exec/posix/src/time.c
+++ b/c/src/exec/posix/src/time.c
@@ -11,6 +11,7 @@
#include <rtems/score/thread.h>
#include <rtems/score/tod.h>
+#include <rtems/posix/seterr.h>
#include <rtems/posix/time.h>
/*PAGE
@@ -63,10 +64,8 @@ time_t time(
{
time_t seconds_since_epoch;
- if ( !_TOD_Is_set() ) {
- errno = EINVAL;
- return -1;
- }
+ if ( !_TOD_Is_set() )
+ set_errno_and_return_minus_one( EINVAL );
/*
* Internally the RTEMS epoch is 1988. This must be taken into account.
@@ -118,10 +117,8 @@ int clock_settime(
tod.ticks = (tp->tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND) /
_TOD_Microseconds_per_tick;
- if ( !_TOD_Validate( &tod ) ) {
- errno = EINVAL;
- return -1;
- }
+ if ( !_TOD_Validate( &tod ) )
+ set_errno_and_return_minus_one( EINVAL );
/*
* We can't use the tp->tv_sec field because it is based on
@@ -146,8 +143,7 @@ int clock_settime(
break;
#endif
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return 0;
@@ -171,10 +167,8 @@ int clock_gettime(
switch ( clock_id ) {
case CLOCK_REALTIME:
- if ( !_TOD_Is_set() ) { /* XXX does posix allow it to not be set? */
- errno = EINVAL;
- return -1;
- }
+ if ( !_TOD_Is_set() ) /* XXX does posix allow it to not be set? */
+ set_errno_and_return_minus_one( EINVAL );
_ISR_Disable( level );
seconds = _TOD_Seconds_since_epoch;
@@ -199,8 +193,7 @@ int clock_gettime(
break;
#endif
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return 0;
@@ -229,8 +222,7 @@ int clock_getres(
break;
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return 0;
@@ -247,10 +239,8 @@ int nanosleep(
{
Watchdog_Interval ticks;
- if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
- errno = EINVAL;
- return -1;
- }
+ if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
+ set_errno_and_return_minus_one( EINVAL );
/* XXX this is interruptible by a posix signal */
diff --git a/c/src/exec/posix/src/types.c b/c/src/exec/posix/src/types.c
index 17c83c4641..6bea1127b6 100644
--- a/c/src/exec/posix/src/types.c
+++ b/c/src/exec/posix/src/types.c
@@ -9,6 +9,7 @@
#include <rtems/system.h>
#include <rtems/score/object.h>
+#include <rtems/posix/seterr.h>
pid_t _POSIX_types_Ppid = 0;
uid_t _POSIX_types_Uid = 0;
@@ -175,8 +176,7 @@ pid_t getpgrp( void )
pid_t setsid( void )
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -189,8 +189,7 @@ int setpgid(
pid_t pgid
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*
diff --git a/cpukit/posix/src/mqueue.c b/cpukit/posix/src/mqueue.c
index b489643401..82da4ee706 100644
--- a/cpukit/posix/src/mqueue.c
+++ b/cpukit/posix/src/mqueue.c
@@ -24,6 +24,7 @@
#include <rtems/system.h>
#include <rtems/score/watchdog.h>
+#include <rtems/posix/seterr.h>
#include <rtems/posix/mqueue.h>
#include <rtems/posix/time.h>
@@ -76,8 +77,7 @@ int _POSIX_Message_queue_Create_support(
if ( !the_mq ) {
_Thread_Enable_dispatch();
- seterrno( ENFILE );
- return -1;
+ set_errno_and_return_minus_one( ENFILE );
}
if ( pshared == PTHREAD_PROCESS_SHARED &&
@@ -85,8 +85,7 @@ int _POSIX_Message_queue_Create_support(
the_mq->Object.id, FALSE ) ) ) {
_POSIX_Message_queue_Free( the_mq );
_Thread_Enable_dispatch();
- seterrno( ENFILE );
- return -1;
+ set_errno_and_return_minus_one( ENFILE );
}
the_mq->process_shared = pshared;
@@ -134,8 +133,7 @@ int _POSIX_Message_queue_Create_support(
_POSIX_Message_queue_Free( the_mq );
_Thread_Enable_dispatch();
- seterrno( ENOSPC );
- return -1;
+ set_errno_and_return_minus_one( ENOSPC );
}
@@ -323,10 +321,8 @@ int mq_unlink(
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
- if ( !status ) {
- seterrno( status );
- return -1;
- }
+ if ( !status )
+ set_errno_and_return_minus_one( status );
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
switch ( location ) {
diff --git a/cpukit/posix/src/sched.c b/cpukit/posix/src/sched.c
index b66c6fb195..f16bb12757 100644
--- a/cpukit/posix/src/sched.c
+++ b/cpukit/posix/src/sched.c
@@ -9,6 +9,7 @@
#include <rtems/system.h>
#include <rtems/score/tod.h>
#include <rtems/score/thread.h>
+#include <rtems/posix/seterr.h>
#include <rtems/posix/priority.h>
#include <rtems/posix/time.h>
@@ -23,8 +24,7 @@ int sched_setparam(
const struct sched_param *param
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -37,8 +37,7 @@ int sched_getparam(
const struct sched_param *param
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -53,8 +52,7 @@ int sched_setscheduler(
const struct sched_param *param
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -66,8 +64,7 @@ int sched_getscheduler(
pid_t pid
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -87,8 +84,7 @@ int sched_get_priority_max(
break;
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return POSIX_SCHEDULER_MAXIMUM_PRIORITY;
@@ -111,8 +107,7 @@ int sched_get_priority_min(
break;
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return POSIX_SCHEDULER_MINIMUM_PRIORITY;
diff --git a/cpukit/posix/src/semaphore.c b/cpukit/posix/src/semaphore.c
index 628e094716..a968abe43b 100644
--- a/cpukit/posix/src/semaphore.c
+++ b/cpukit/posix/src/semaphore.c
@@ -64,8 +64,7 @@ int _POSIX_Semaphore_Create_support(
if ( !the_semaphore ) {
_Thread_Enable_dispatch();
- seterrno( ENOMEM );
- return -1;
+ set_errno_and_return_minus_one( ENOMEM );
}
if ( pshared == PTHREAD_PROCESS_SHARED &&
@@ -73,8 +72,7 @@ int _POSIX_Semaphore_Create_support(
the_semaphore->Object.id, FALSE ) ) ) {
_POSIX_Semaphore_Free( the_semaphore );
_Thread_Enable_dispatch();
- seterrno( EAGAIN );
- return -1;
+ set_errno_and_return_minus_one( EAGAIN );
}
the_semaphore->process_shared = pshared;
@@ -382,10 +380,8 @@ int sem_unlink(
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
- if ( !status ) {
- seterrno( status );
- return -1;
- }
+ if ( !status )
+ set_errno_and_return_minus_one( status );
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
switch ( location ) {
diff --git a/cpukit/posix/src/time.c b/cpukit/posix/src/time.c
index 95fdbcc8d5..3860ae993d 100644
--- a/cpukit/posix/src/time.c
+++ b/cpukit/posix/src/time.c
@@ -11,6 +11,7 @@
#include <rtems/score/thread.h>
#include <rtems/score/tod.h>
+#include <rtems/posix/seterr.h>
#include <rtems/posix/time.h>
/*PAGE
@@ -63,10 +64,8 @@ time_t time(
{
time_t seconds_since_epoch;
- if ( !_TOD_Is_set() ) {
- errno = EINVAL;
- return -1;
- }
+ if ( !_TOD_Is_set() )
+ set_errno_and_return_minus_one( EINVAL );
/*
* Internally the RTEMS epoch is 1988. This must be taken into account.
@@ -118,10 +117,8 @@ int clock_settime(
tod.ticks = (tp->tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND) /
_TOD_Microseconds_per_tick;
- if ( !_TOD_Validate( &tod ) ) {
- errno = EINVAL;
- return -1;
- }
+ if ( !_TOD_Validate( &tod ) )
+ set_errno_and_return_minus_one( EINVAL );
/*
* We can't use the tp->tv_sec field because it is based on
@@ -146,8 +143,7 @@ int clock_settime(
break;
#endif
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return 0;
@@ -171,10 +167,8 @@ int clock_gettime(
switch ( clock_id ) {
case CLOCK_REALTIME:
- if ( !_TOD_Is_set() ) { /* XXX does posix allow it to not be set? */
- errno = EINVAL;
- return -1;
- }
+ if ( !_TOD_Is_set() ) /* XXX does posix allow it to not be set? */
+ set_errno_and_return_minus_one( EINVAL );
_ISR_Disable( level );
seconds = _TOD_Seconds_since_epoch;
@@ -199,8 +193,7 @@ int clock_gettime(
break;
#endif
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return 0;
@@ -229,8 +222,7 @@ int clock_getres(
break;
default:
- errno = EINVAL;
- return -1;
+ set_errno_and_return_minus_one( EINVAL );
}
return 0;
@@ -247,10 +239,8 @@ int nanosleep(
{
Watchdog_Interval ticks;
- if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
- errno = EINVAL;
- return -1;
- }
+ if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
+ set_errno_and_return_minus_one( EINVAL );
/* XXX this is interruptible by a posix signal */
diff --git a/cpukit/posix/src/types.c b/cpukit/posix/src/types.c
index 17c83c4641..6bea1127b6 100644
--- a/cpukit/posix/src/types.c
+++ b/cpukit/posix/src/types.c
@@ -9,6 +9,7 @@
#include <rtems/system.h>
#include <rtems/score/object.h>
+#include <rtems/posix/seterr.h>
pid_t _POSIX_types_Ppid = 0;
uid_t _POSIX_types_Uid = 0;
@@ -175,8 +176,7 @@ pid_t getpgrp( void )
pid_t setsid( void )
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*PAGE
@@ -189,8 +189,7 @@ int setpgid(
pid_t pgid
)
{
- errno = ENOSYS;
- return -1;
+ set_errno_and_return_minus_one( ENOSYS );
}
/*