forked from Imagelibrary/rtems
score: Add rtems_set_errno_and_return_value()
Remove rtems_set_errno_and_return_minus_one_cast().
This commit is contained in:
@@ -44,6 +44,8 @@
|
|||||||
#include <rtems/posix/time.h>
|
#include <rtems/posix/time.h>
|
||||||
#include <rtems/seterr.h>
|
#include <rtems/seterr.h>
|
||||||
|
|
||||||
|
#define MQ_OPEN_FAILED ((mqd_t) -1)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272
|
* 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +84,7 @@ mqd_t mq_open(
|
|||||||
the_mq_fd = _POSIX_Message_queue_Allocate_fd();
|
the_mq_fd = _POSIX_Message_queue_Allocate_fd();
|
||||||
if ( !the_mq_fd ) {
|
if ( !the_mq_fd ) {
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
rtems_set_errno_and_return_minus_one( ENFILE );
|
rtems_set_errno_and_return_value( ENFILE, MQ_OPEN_FAILED );
|
||||||
}
|
}
|
||||||
the_mq_fd->oflag = oflag;
|
the_mq_fd->oflag = oflag;
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ mqd_t mq_open(
|
|||||||
if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
|
if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
|
||||||
_POSIX_Message_queue_Free_fd( the_mq_fd );
|
_POSIX_Message_queue_Free_fd( the_mq_fd );
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
rtems_set_errno_and_return_minus_one_cast( status, mqd_t );
|
rtems_set_errno_and_return_value( status, MQ_OPEN_FAILED );
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { /* name -> ID translation succeeded */
|
} else { /* name -> ID translation succeeded */
|
||||||
@@ -112,7 +114,7 @@ mqd_t mq_open(
|
|||||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||||
_POSIX_Message_queue_Free_fd( the_mq_fd );
|
_POSIX_Message_queue_Free_fd( the_mq_fd );
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
rtems_set_errno_and_return_minus_one_cast( EEXIST, mqd_t );
|
rtems_set_errno_and_return_value( EEXIST, MQ_OPEN_FAILED );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -129,7 +131,7 @@ mqd_t mq_open(
|
|||||||
);
|
);
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
return (mqd_t)the_mq_fd->Object.id;
|
return the_mq_fd->Object.id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +153,7 @@ mqd_t mq_open(
|
|||||||
if ( status == -1 ) {
|
if ( status == -1 ) {
|
||||||
_POSIX_Message_queue_Free_fd( the_mq_fd );
|
_POSIX_Message_queue_Free_fd( the_mq_fd );
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
return (mqd_t) -1;
|
return MQ_OPEN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
the_mq_fd->Queue = the_mq;
|
the_mq_fd->Queue = the_mq;
|
||||||
@@ -163,5 +165,5 @@ mqd_t mq_open(
|
|||||||
|
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
|
|
||||||
return (mqd_t) the_mq_fd->Object.id;
|
return the_mq_fd->Object.id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ sem_t *sem_open(
|
|||||||
|
|
||||||
if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
|
if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
rtems_set_errno_and_return_minus_one_cast( status, sem_t * );
|
rtems_set_errno_and_return_value( status, SEM_FAILED );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ sem_t *sem_open(
|
|||||||
|
|
||||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
rtems_set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
|
rtems_set_errno_and_return_value( EEXIST, SEM_FAILED );
|
||||||
}
|
}
|
||||||
|
|
||||||
the_semaphore = _POSIX_Semaphore_Get( (sem_t *) &the_semaphore_id, &location );
|
the_semaphore = _POSIX_Semaphore_Get( (sem_t *) &the_semaphore_id, &location );
|
||||||
|
|||||||
@@ -31,25 +31,22 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a helper macro which will set the variable errno and return
|
* This is a helper macro which will set the variable errno and return
|
||||||
* -1 to the caller. This pattern is common to many POSIX methods.
|
* the specified value to the caller.
|
||||||
*
|
*
|
||||||
* @param[in] _error is the error code
|
* @param[in] _error is the error code
|
||||||
|
* @param[in] _value is the value to return
|
||||||
*/
|
*/
|
||||||
#define rtems_set_errno_and_return_minus_one( _error ) \
|
#define rtems_set_errno_and_return_value( _error, _value ) \
|
||||||
do { errno = (_error); return -1; } while(0)
|
do { errno = ( _error ); return ( _value ); } while ( 0 )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a helper macro which will set the variable errno and return
|
* This is a helper macro which will set the variable errno and return
|
||||||
* -1 to the caller. This pattern is common to many POSIX methods.
|
* -1 to the caller. This pattern is common to many POSIX methods.
|
||||||
*
|
*
|
||||||
* @param[in] _error is the error code
|
* @param[in] _error is the error code
|
||||||
* @param[in] _cast is the type to which -1 must be cast
|
|
||||||
*
|
|
||||||
* @note It is similar to @ref rtems_set_errno_and_return_minus_one but
|
|
||||||
* this -1 value is cast to something other than an int.
|
|
||||||
*/
|
*/
|
||||||
#define rtems_set_errno_and_return_minus_one_cast( _error, _cast ) \
|
#define rtems_set_errno_and_return_minus_one( _error ) \
|
||||||
do { errno = (_error); return (_cast) -1; } while(0)
|
rtems_set_errno_and_return_value( _error, -1 )
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user