forked from Imagelibrary/rtems
Now compiles and is included in normal build even though it is untested.
Added multiprocessing conditional.
This commit is contained in:
@@ -80,6 +80,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
set_errno_and_return_minus_one( ENFILE );
|
set_errno_and_return_minus_one( ENFILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||||
!( _Objects_MP_Allocate_and_open( &_POSIX_Message_queue_Information, 0,
|
!( _Objects_MP_Allocate_and_open( &_POSIX_Message_queue_Information, 0,
|
||||||
the_mq->Object.id, FALSE ) ) ) {
|
the_mq->Object.id, FALSE ) ) ) {
|
||||||
@@ -87,6 +88,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
set_errno_and_return_minus_one( ENFILE );
|
set_errno_and_return_minus_one( ENFILE );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
the_mq->process_shared = pshared;
|
the_mq->process_shared = pshared;
|
||||||
|
|
||||||
@@ -126,10 +128,17 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
&the_mq->Message_queue.Attributes,
|
&the_mq->Message_queue.Attributes,
|
||||||
attr->mq_maxmsg,
|
attr->mq_maxmsg,
|
||||||
attr->mq_msgsize,
|
attr->mq_msgsize,
|
||||||
_POSIX_Message_queue_MP_Send_extract_proxy ) ) {
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
|
_POSIX_Message_queue_MP_Send_extract_proxy
|
||||||
|
#else
|
||||||
|
NULL
|
||||||
|
#endif
|
||||||
|
) ) {
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED )
|
if ( pshared == PTHREAD_PROCESS_SHARED )
|
||||||
_Objects_MP_Close( &_POSIX_Message_queue_Information, the_mq->Object.id );
|
_Objects_MP_Close( &_POSIX_Message_queue_Information, the_mq->Object.id );
|
||||||
|
#endif
|
||||||
|
|
||||||
_POSIX_Message_queue_Free( the_mq );
|
_POSIX_Message_queue_Free( the_mq );
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
@@ -146,6 +155,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
|
|
||||||
*message_queue = the_mq;
|
*message_queue = the_mq;
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED )
|
if ( pshared == PTHREAD_PROCESS_SHARED )
|
||||||
_POSIX_Message_queue_MP_Send_process_packet(
|
_POSIX_Message_queue_MP_Send_process_packet(
|
||||||
POSIX_MESSAGE_QUEUE_MP_ANNOUNCE_CREATE,
|
POSIX_MESSAGE_QUEUE_MP_ANNOUNCE_CREATE,
|
||||||
@@ -153,6 +163,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
(char *) name,
|
(char *) name,
|
||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -198,18 +209,18 @@ mqd_t mq_open(
|
|||||||
|
|
||||||
if ( status == EINVAL ) { /* name -> ID translation failed */
|
if ( status == EINVAL ) { /* name -> ID translation failed */
|
||||||
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
||||||
seterrno( ENOENT );
|
set_errno_and_return_minus_one( ENOENT );
|
||||||
return (mqd_t) -1;
|
return (mqd_t) -1;
|
||||||
}
|
}
|
||||||
/* we are willing to create it */
|
/* we are willing to create it */
|
||||||
}
|
}
|
||||||
seterrno( status ); /* some type of error */
|
set_errno_and_return_minus_one( status ); /* some type of error */
|
||||||
return (mqd_t) -1;
|
return (mqd_t) -1;
|
||||||
|
|
||||||
} else { /* name -> ID translation succeeded */
|
} else { /* name -> ID translation succeeded */
|
||||||
|
|
||||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||||
seterrno( EEXIST );
|
set_errno_and_return_minus_one( EEXIST );
|
||||||
return (mqd_t) -1;
|
return (mqd_t) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +267,7 @@ void _POSIX_Message_queue_Delete(
|
|||||||
if ( !the_mq->linked && !the_mq->open_count ) {
|
if ( !the_mq->linked && !the_mq->open_count ) {
|
||||||
_POSIX_Message_queue_Free( the_mq );
|
_POSIX_Message_queue_Free( the_mq );
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_mq->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_mq->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
|
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
@@ -270,6 +282,7 @@ void _POSIX_Message_queue_Delete(
|
|||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,13 +302,11 @@ int mq_close(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
the_mq->open_count -= 1;
|
the_mq->open_count -= 1;
|
||||||
_POSIX_Message_queue_Delete( the_mq );
|
_POSIX_Message_queue_Delete( the_mq );
|
||||||
@@ -327,19 +338,19 @@ int mq_unlink(
|
|||||||
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
&_POSIX_Message_queue_Information,
|
&_POSIX_Message_queue_Information,
|
||||||
the_mq->Object.id
|
the_mq->Object.id
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
the_mq->linked = FALSE;
|
the_mq->linked = FALSE;
|
||||||
|
|
||||||
@@ -370,13 +381,11 @@ int _POSIX_Message_queue_Send_support(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/* XXX must add support for timeout and priority */
|
/* XXX must add support for timeout and priority */
|
||||||
_CORE_message_queue_Send(
|
_CORE_message_queue_Send(
|
||||||
@@ -384,7 +393,11 @@ int _POSIX_Message_queue_Send_support(
|
|||||||
(void *) msg_ptr,
|
(void *) msg_ptr,
|
||||||
msg_len,
|
msg_len,
|
||||||
mqdes,
|
mqdes,
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
NULL /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
|
NULL /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
|
||||||
|
#else
|
||||||
|
NULL
|
||||||
|
#endif
|
||||||
);
|
);
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return _Thread_Executing->Wait.return_code;
|
return _Thread_Executing->Wait.return_code;
|
||||||
@@ -462,13 +475,11 @@ ssize_t _POSIX_Message_queue_Receive_support(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/* XXX need to define the options argument to this */
|
/* XXX need to define the options argument to this */
|
||||||
length_out = msg_len;
|
length_out = msg_len;
|
||||||
@@ -571,19 +582,16 @@ int mq_notify(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EBADF );
|
set_errno_and_return_minus_one( EBADF );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
if ( notification ) {
|
if ( notification ) {
|
||||||
if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
|
if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
seterrno( EBUSY );
|
set_errno_and_return_minus_one( EBUSY );
|
||||||
return( -1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
|
_CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
|
||||||
@@ -625,13 +633,11 @@ int mq_setattr(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/*
|
/*
|
||||||
* Return the old values.
|
* Return the old values.
|
||||||
@@ -681,13 +687,11 @@ int mq_getattr(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/*
|
/*
|
||||||
* Return the old values.
|
* Return the old values.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/posix/semaphore.h>
|
#include <rtems/posix/semaphore.h>
|
||||||
#include <rtems/posix/time.h>
|
#include <rtems/posix/time.h>
|
||||||
|
#include <rtems/posix/seterr.h>
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
*
|
*
|
||||||
@@ -67,6 +68,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
set_errno_and_return_minus_one( ENOMEM );
|
set_errno_and_return_minus_one( ENOMEM );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||||
!( _Objects_MP_Allocate_and_open( &_POSIX_Semaphore_Information, 0,
|
!( _Objects_MP_Allocate_and_open( &_POSIX_Semaphore_Information, 0,
|
||||||
the_semaphore->Object.id, FALSE ) ) ) {
|
the_semaphore->Object.id, FALSE ) ) ) {
|
||||||
@@ -74,6 +76,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
set_errno_and_return_minus_one( EAGAIN );
|
set_errno_and_return_minus_one( EAGAIN );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
the_semaphore->process_shared = pshared;
|
the_semaphore->process_shared = pshared;
|
||||||
|
|
||||||
@@ -111,6 +114,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
|
|
||||||
*the_sem = the_semaphore;
|
*the_sem = the_semaphore;
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED )
|
if ( pshared == PTHREAD_PROCESS_SHARED )
|
||||||
_POSIX_Semaphore_MP_Send_process_packet(
|
_POSIX_Semaphore_MP_Send_process_packet(
|
||||||
POSIX_SEMAPHORE_MP_ANNOUNCE_CREATE,
|
POSIX_SEMAPHORE_MP_ANNOUNCE_CREATE,
|
||||||
@@ -118,6 +122,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
(char *) name,
|
(char *) name,
|
||||||
0 /* proxy id - Not used */
|
0 /* proxy id - Not used */
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -166,33 +171,35 @@ int sem_destroy(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/*
|
/*
|
||||||
* Undefined operation on a named semaphore.
|
* Undefined operation on a named semaphore.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( the_semaphore->named == TRUE ) {
|
if ( the_semaphore->named == TRUE ) {
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
|
_Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
|
||||||
|
|
||||||
_CORE_semaphore_Flush(
|
_CORE_semaphore_Flush(
|
||||||
&the_semaphore->Semaphore,
|
&the_semaphore->Semaphore,
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
_POSIX_Semaphore_MP_Send_object_was_deleted,
|
_POSIX_Semaphore_MP_Send_object_was_deleted,
|
||||||
|
#else
|
||||||
|
NULL,
|
||||||
|
#endif
|
||||||
-1 /* XXX should also seterrno -> EINVAL */
|
-1 /* XXX should also seterrno -> EINVAL */
|
||||||
);
|
);
|
||||||
|
|
||||||
_POSIX_Semaphore_Free( the_semaphore );
|
_POSIX_Semaphore_Free( the_semaphore );
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
|
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
@@ -207,6 +214,7 @@ int sem_destroy(
|
|||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -257,19 +265,17 @@ sem_t *sem_open(
|
|||||||
|
|
||||||
if ( status == EINVAL ) { /* name -> ID translation failed */
|
if ( status == EINVAL ) { /* name -> ID translation failed */
|
||||||
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
||||||
seterrno( ENOENT );
|
set_errno_and_return_minus_one_cast( ENOENT, sem_t * );
|
||||||
return (sem_t *) -1;
|
|
||||||
}
|
}
|
||||||
/* we are willing to create it */
|
/* we are willing to create it */
|
||||||
}
|
}
|
||||||
seterrno( status ); /* some type of error */
|
/* some type of error */
|
||||||
return (sem_t *) -1;
|
set_errno_and_return_minus_one_cast( status, sem_t * );
|
||||||
|
|
||||||
} else { /* name -> ID translation succeeded */
|
} else { /* name -> ID translation succeeded */
|
||||||
|
|
||||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||||
seterrno( EEXIST );
|
set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
|
||||||
return (sem_t *) -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -315,6 +321,7 @@ void _POSIX_Semaphore_Delete(
|
|||||||
if ( !the_semaphore->linked && !the_semaphore->open_count ) {
|
if ( !the_semaphore->linked && !the_semaphore->open_count ) {
|
||||||
_POSIX_Semaphore_Free( the_semaphore );
|
_POSIX_Semaphore_Free( the_semaphore );
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
|
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
@@ -329,6 +336,7 @@ void _POSIX_Semaphore_Delete(
|
|||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,13 +356,11 @@ int sem_close(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
the_semaphore->open_count -= 1;
|
the_semaphore->open_count -= 1;
|
||||||
_POSIX_Semaphore_Delete( the_semaphore );
|
_POSIX_Semaphore_Delete( the_semaphore );
|
||||||
@@ -386,21 +392,21 @@ int sem_unlink(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
&_POSIX_Semaphore_Information,
|
&_POSIX_Semaphore_Information,
|
||||||
the_semaphore->Object.id
|
the_semaphore->Object.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
the_semaphore->linked = FALSE;
|
the_semaphore->linked = FALSE;
|
||||||
|
|
||||||
@@ -429,13 +435,11 @@ int _POSIX_Semaphore_Wait_support(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
_CORE_semaphore_Seize(
|
_CORE_semaphore_Seize(
|
||||||
&the_semaphore->Semaphore,
|
&the_semaphore->Semaphore,
|
||||||
@@ -520,18 +524,20 @@ int sem_post(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
_CORE_semaphore_Surrender(
|
_CORE_semaphore_Surrender(
|
||||||
&the_semaphore->Semaphore,
|
&the_semaphore->Semaphore,
|
||||||
the_semaphore->Object.id,
|
the_semaphore->Object.id,
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
POSIX_Semaphore_MP_support
|
POSIX_Semaphore_MP_support
|
||||||
|
#else
|
||||||
|
NULL
|
||||||
|
#endif
|
||||||
);
|
);
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -555,13 +561,11 @@ int sem_getvalue(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
*sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore );
|
*sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore );
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
set_errno_and_return_minus_one( ENFILE );
|
set_errno_and_return_minus_one( ENFILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||||
!( _Objects_MP_Allocate_and_open( &_POSIX_Message_queue_Information, 0,
|
!( _Objects_MP_Allocate_and_open( &_POSIX_Message_queue_Information, 0,
|
||||||
the_mq->Object.id, FALSE ) ) ) {
|
the_mq->Object.id, FALSE ) ) ) {
|
||||||
@@ -87,6 +88,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
set_errno_and_return_minus_one( ENFILE );
|
set_errno_and_return_minus_one( ENFILE );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
the_mq->process_shared = pshared;
|
the_mq->process_shared = pshared;
|
||||||
|
|
||||||
@@ -126,10 +128,17 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
&the_mq->Message_queue.Attributes,
|
&the_mq->Message_queue.Attributes,
|
||||||
attr->mq_maxmsg,
|
attr->mq_maxmsg,
|
||||||
attr->mq_msgsize,
|
attr->mq_msgsize,
|
||||||
_POSIX_Message_queue_MP_Send_extract_proxy ) ) {
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
|
_POSIX_Message_queue_MP_Send_extract_proxy
|
||||||
|
#else
|
||||||
|
NULL
|
||||||
|
#endif
|
||||||
|
) ) {
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED )
|
if ( pshared == PTHREAD_PROCESS_SHARED )
|
||||||
_Objects_MP_Close( &_POSIX_Message_queue_Information, the_mq->Object.id );
|
_Objects_MP_Close( &_POSIX_Message_queue_Information, the_mq->Object.id );
|
||||||
|
#endif
|
||||||
|
|
||||||
_POSIX_Message_queue_Free( the_mq );
|
_POSIX_Message_queue_Free( the_mq );
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
@@ -146,6 +155,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
|
|
||||||
*message_queue = the_mq;
|
*message_queue = the_mq;
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED )
|
if ( pshared == PTHREAD_PROCESS_SHARED )
|
||||||
_POSIX_Message_queue_MP_Send_process_packet(
|
_POSIX_Message_queue_MP_Send_process_packet(
|
||||||
POSIX_MESSAGE_QUEUE_MP_ANNOUNCE_CREATE,
|
POSIX_MESSAGE_QUEUE_MP_ANNOUNCE_CREATE,
|
||||||
@@ -153,6 +163,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
(char *) name,
|
(char *) name,
|
||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -198,18 +209,18 @@ mqd_t mq_open(
|
|||||||
|
|
||||||
if ( status == EINVAL ) { /* name -> ID translation failed */
|
if ( status == EINVAL ) { /* name -> ID translation failed */
|
||||||
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
||||||
seterrno( ENOENT );
|
set_errno_and_return_minus_one( ENOENT );
|
||||||
return (mqd_t) -1;
|
return (mqd_t) -1;
|
||||||
}
|
}
|
||||||
/* we are willing to create it */
|
/* we are willing to create it */
|
||||||
}
|
}
|
||||||
seterrno( status ); /* some type of error */
|
set_errno_and_return_minus_one( status ); /* some type of error */
|
||||||
return (mqd_t) -1;
|
return (mqd_t) -1;
|
||||||
|
|
||||||
} else { /* name -> ID translation succeeded */
|
} else { /* name -> ID translation succeeded */
|
||||||
|
|
||||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||||
seterrno( EEXIST );
|
set_errno_and_return_minus_one( EEXIST );
|
||||||
return (mqd_t) -1;
|
return (mqd_t) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +267,7 @@ void _POSIX_Message_queue_Delete(
|
|||||||
if ( !the_mq->linked && !the_mq->open_count ) {
|
if ( !the_mq->linked && !the_mq->open_count ) {
|
||||||
_POSIX_Message_queue_Free( the_mq );
|
_POSIX_Message_queue_Free( the_mq );
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_mq->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_mq->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
|
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
@@ -270,6 +282,7 @@ void _POSIX_Message_queue_Delete(
|
|||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,13 +302,11 @@ int mq_close(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
the_mq->open_count -= 1;
|
the_mq->open_count -= 1;
|
||||||
_POSIX_Message_queue_Delete( the_mq );
|
_POSIX_Message_queue_Delete( the_mq );
|
||||||
@@ -327,19 +338,19 @@ int mq_unlink(
|
|||||||
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
&_POSIX_Message_queue_Information,
|
&_POSIX_Message_queue_Information,
|
||||||
the_mq->Object.id
|
the_mq->Object.id
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
the_mq->linked = FALSE;
|
the_mq->linked = FALSE;
|
||||||
|
|
||||||
@@ -370,13 +381,11 @@ int _POSIX_Message_queue_Send_support(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/* XXX must add support for timeout and priority */
|
/* XXX must add support for timeout and priority */
|
||||||
_CORE_message_queue_Send(
|
_CORE_message_queue_Send(
|
||||||
@@ -384,7 +393,11 @@ int _POSIX_Message_queue_Send_support(
|
|||||||
(void *) msg_ptr,
|
(void *) msg_ptr,
|
||||||
msg_len,
|
msg_len,
|
||||||
mqdes,
|
mqdes,
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
NULL /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
|
NULL /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
|
||||||
|
#else
|
||||||
|
NULL
|
||||||
|
#endif
|
||||||
);
|
);
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return _Thread_Executing->Wait.return_code;
|
return _Thread_Executing->Wait.return_code;
|
||||||
@@ -462,13 +475,11 @@ ssize_t _POSIX_Message_queue_Receive_support(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/* XXX need to define the options argument to this */
|
/* XXX need to define the options argument to this */
|
||||||
length_out = msg_len;
|
length_out = msg_len;
|
||||||
@@ -571,19 +582,16 @@ int mq_notify(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EBADF );
|
set_errno_and_return_minus_one( EBADF );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
if ( notification ) {
|
if ( notification ) {
|
||||||
if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
|
if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
seterrno( EBUSY );
|
set_errno_and_return_minus_one( EBUSY );
|
||||||
return( -1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
|
_CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
|
||||||
@@ -625,13 +633,11 @@ int mq_setattr(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/*
|
/*
|
||||||
* Return the old values.
|
* Return the old values.
|
||||||
@@ -681,13 +687,11 @@ int mq_getattr(
|
|||||||
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/*
|
/*
|
||||||
* Return the old values.
|
* Return the old values.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/posix/semaphore.h>
|
#include <rtems/posix/semaphore.h>
|
||||||
#include <rtems/posix/time.h>
|
#include <rtems/posix/time.h>
|
||||||
|
#include <rtems/posix/seterr.h>
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
*
|
*
|
||||||
@@ -67,6 +68,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
set_errno_and_return_minus_one( ENOMEM );
|
set_errno_and_return_minus_one( ENOMEM );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||||
!( _Objects_MP_Allocate_and_open( &_POSIX_Semaphore_Information, 0,
|
!( _Objects_MP_Allocate_and_open( &_POSIX_Semaphore_Information, 0,
|
||||||
the_semaphore->Object.id, FALSE ) ) ) {
|
the_semaphore->Object.id, FALSE ) ) ) {
|
||||||
@@ -74,6 +76,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
set_errno_and_return_minus_one( EAGAIN );
|
set_errno_and_return_minus_one( EAGAIN );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
the_semaphore->process_shared = pshared;
|
the_semaphore->process_shared = pshared;
|
||||||
|
|
||||||
@@ -111,6 +114,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
|
|
||||||
*the_sem = the_semaphore;
|
*the_sem = the_semaphore;
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( pshared == PTHREAD_PROCESS_SHARED )
|
if ( pshared == PTHREAD_PROCESS_SHARED )
|
||||||
_POSIX_Semaphore_MP_Send_process_packet(
|
_POSIX_Semaphore_MP_Send_process_packet(
|
||||||
POSIX_SEMAPHORE_MP_ANNOUNCE_CREATE,
|
POSIX_SEMAPHORE_MP_ANNOUNCE_CREATE,
|
||||||
@@ -118,6 +122,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
(char *) name,
|
(char *) name,
|
||||||
0 /* proxy id - Not used */
|
0 /* proxy id - Not used */
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -166,33 +171,35 @@ int sem_destroy(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
/*
|
/*
|
||||||
* Undefined operation on a named semaphore.
|
* Undefined operation on a named semaphore.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( the_semaphore->named == TRUE ) {
|
if ( the_semaphore->named == TRUE ) {
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
|
_Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
|
||||||
|
|
||||||
_CORE_semaphore_Flush(
|
_CORE_semaphore_Flush(
|
||||||
&the_semaphore->Semaphore,
|
&the_semaphore->Semaphore,
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
_POSIX_Semaphore_MP_Send_object_was_deleted,
|
_POSIX_Semaphore_MP_Send_object_was_deleted,
|
||||||
|
#else
|
||||||
|
NULL,
|
||||||
|
#endif
|
||||||
-1 /* XXX should also seterrno -> EINVAL */
|
-1 /* XXX should also seterrno -> EINVAL */
|
||||||
);
|
);
|
||||||
|
|
||||||
_POSIX_Semaphore_Free( the_semaphore );
|
_POSIX_Semaphore_Free( the_semaphore );
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
|
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
@@ -207,6 +214,7 @@ int sem_destroy(
|
|||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -257,19 +265,17 @@ sem_t *sem_open(
|
|||||||
|
|
||||||
if ( status == EINVAL ) { /* name -> ID translation failed */
|
if ( status == EINVAL ) { /* name -> ID translation failed */
|
||||||
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
|
||||||
seterrno( ENOENT );
|
set_errno_and_return_minus_one_cast( ENOENT, sem_t * );
|
||||||
return (sem_t *) -1;
|
|
||||||
}
|
}
|
||||||
/* we are willing to create it */
|
/* we are willing to create it */
|
||||||
}
|
}
|
||||||
seterrno( status ); /* some type of error */
|
/* some type of error */
|
||||||
return (sem_t *) -1;
|
set_errno_and_return_minus_one_cast( status, sem_t * );
|
||||||
|
|
||||||
} else { /* name -> ID translation succeeded */
|
} else { /* name -> ID translation succeeded */
|
||||||
|
|
||||||
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
|
||||||
seterrno( EEXIST );
|
set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
|
||||||
return (sem_t *) -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -315,6 +321,7 @@ void _POSIX_Semaphore_Delete(
|
|||||||
if ( !the_semaphore->linked && !the_semaphore->open_count ) {
|
if ( !the_semaphore->linked && !the_semaphore->open_count ) {
|
||||||
_POSIX_Semaphore_Free( the_semaphore );
|
_POSIX_Semaphore_Free( the_semaphore );
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
|
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
@@ -329,6 +336,7 @@ void _POSIX_Semaphore_Delete(
|
|||||||
0 /* Not used */
|
0 /* Not used */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,13 +356,11 @@ int sem_close(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
the_semaphore->open_count -= 1;
|
the_semaphore->open_count -= 1;
|
||||||
_POSIX_Semaphore_Delete( the_semaphore );
|
_POSIX_Semaphore_Delete( the_semaphore );
|
||||||
@@ -386,21 +392,21 @@ int sem_unlink(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
|
||||||
_Objects_MP_Close(
|
_Objects_MP_Close(
|
||||||
&_POSIX_Semaphore_Information,
|
&_POSIX_Semaphore_Information,
|
||||||
the_semaphore->Object.id
|
the_semaphore->Object.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
the_semaphore->linked = FALSE;
|
the_semaphore->linked = FALSE;
|
||||||
|
|
||||||
@@ -429,13 +435,11 @@ int _POSIX_Semaphore_Wait_support(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
_CORE_semaphore_Seize(
|
_CORE_semaphore_Seize(
|
||||||
&the_semaphore->Semaphore,
|
&the_semaphore->Semaphore,
|
||||||
@@ -520,18 +524,20 @@ int sem_post(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
_CORE_semaphore_Surrender(
|
_CORE_semaphore_Surrender(
|
||||||
&the_semaphore->Semaphore,
|
&the_semaphore->Semaphore,
|
||||||
the_semaphore->Object.id,
|
the_semaphore->Object.id,
|
||||||
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
POSIX_Semaphore_MP_support
|
POSIX_Semaphore_MP_support
|
||||||
|
#else
|
||||||
|
NULL
|
||||||
|
#endif
|
||||||
);
|
);
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -555,13 +561,11 @@ int sem_getvalue(
|
|||||||
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
_Thread_Dispatch();
|
_Thread_Dispatch();
|
||||||
return POSIX_MP_NOT_IMPLEMENTED();
|
return POSIX_MP_NOT_IMPLEMENTED();
|
||||||
seterrno( EINVAL );
|
set_errno_and_return_minus_one( EINVAL );
|
||||||
return( -1 );
|
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
*sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore );
|
*sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore );
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
|
|||||||
Reference in New Issue
Block a user