forked from Imagelibrary/rtems
2011-12-13 Sebastian Huber <sebastian.huber@embedded-brains.de>
* posix/src/mqueuenametoid.c, posix/src/semaphorenametoid.c: Removed files. * posix/src/psxnametoid.c: New file. * posix/Makefile.am: Reflect changes above. * posix/include/rtems/posix/config.h: Fixed integer types. * posix/include/rtems/posix/posixapi.h: Declare _POSIX_Name_to_id(). * posix/include/rtems/posix/mqueue.h, posix/inline/rtems/posix/mqueue.inl: Changed parameter of _POSIX_Message_queue_Create_support(). _POSIX_Message_queue_Name_to_id() is now inline. * posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/semaphore.inl: Changed parameter of _POSIX_Semaphore_Create_support(). _POSIX_Semaphore_Name_to_id() is now inline. * posix/src/mqueuecreatesupp.c, posix/src/semaphorecreatesupp.c: Use _Workspace_String_duplicate(). * posix/src/mqueuesendsupp.c, posix/src/mqueueopen.c, posix/src/mqueueunlink.c, posix/src/seminit.c, posix/src/semopen.c, posix/src/semunlink.c: Update due to API changes.
This commit is contained in:
@@ -1,3 +1,25 @@
|
|||||||
|
2011-12-13 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
|
* posix/src/mqueuenametoid.c,
|
||||||
|
posix/src/semaphorenametoid.c: Removed files.
|
||||||
|
* posix/src/psxnametoid.c: New file.
|
||||||
|
* posix/Makefile.am: Reflect changes above.
|
||||||
|
* posix/include/rtems/posix/config.h: Fixed integer types.
|
||||||
|
* posix/include/rtems/posix/posixapi.h: Declare _POSIX_Name_to_id().
|
||||||
|
* posix/include/rtems/posix/mqueue.h,
|
||||||
|
posix/inline/rtems/posix/mqueue.inl: Changed parameter of
|
||||||
|
_POSIX_Message_queue_Create_support().
|
||||||
|
_POSIX_Message_queue_Name_to_id() is now inline.
|
||||||
|
* posix/include/rtems/posix/semaphore.h,
|
||||||
|
posix/inline/rtems/posix/semaphore.inl: Changed parameter of
|
||||||
|
_POSIX_Semaphore_Create_support(). _POSIX_Semaphore_Name_to_id() is
|
||||||
|
now inline.
|
||||||
|
* posix/src/mqueuecreatesupp.c, posix/src/semaphorecreatesupp.c: Use
|
||||||
|
_Workspace_String_duplicate().
|
||||||
|
* posix/src/mqueuesendsupp.c, posix/src/mqueueopen.c,
|
||||||
|
posix/src/mqueueunlink.c, posix/src/seminit.c, posix/src/semopen.c,
|
||||||
|
posix/src/semunlink.c: Update due to API changes.
|
||||||
|
|
||||||
2011-12-13 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
2011-12-13 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* sapi/include/confdefs.h: Fixed workspace size estimate of POSIX keys
|
* sapi/include/confdefs.h: Fixed workspace size estimate of POSIX keys
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ libposix_a_SOURCES += src/mprotect.c
|
|||||||
## MESSAGE_QUEUE_C_FILES
|
## MESSAGE_QUEUE_C_FILES
|
||||||
libposix_a_SOURCES += src/mqueue.c src/mqueueclose.c \
|
libposix_a_SOURCES += src/mqueue.c src/mqueueclose.c \
|
||||||
src/mqueuecreatesupp.c src/mqueuedeletesupp.c src/mqueuegetattr.c \
|
src/mqueuecreatesupp.c src/mqueuedeletesupp.c src/mqueuegetattr.c \
|
||||||
src/mqueuenametoid.c src/mqueuenotify.c src/mqueueopen.c \
|
src/mqueuenotify.c src/mqueueopen.c \
|
||||||
src/mqueuereceive.c src/mqueuerecvsupp.c src/mqueuesend.c \
|
src/mqueuereceive.c src/mqueuerecvsupp.c src/mqueuesend.c \
|
||||||
src/mqueuesendsupp.c src/mqueuesetattr.c src/mqueuetimedreceive.c \
|
src/mqueuesendsupp.c src/mqueuesetattr.c src/mqueuetimedreceive.c \
|
||||||
src/mqueuetimedsend.c src/mqueuetranslatereturncode.c \
|
src/mqueuetimedsend.c src/mqueuetranslatereturncode.c \
|
||||||
@@ -170,7 +170,7 @@ libposix_a_SOURCES += src/prwlock.c src/prwlockdestroy.c src/prwlockinit.c \
|
|||||||
|
|
||||||
## SEMAPHORE_C_FILES
|
## SEMAPHORE_C_FILES
|
||||||
libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \
|
libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \
|
||||||
src/semaphoredeletesupp.c src/semaphorenametoid.c \
|
src/semaphoredeletesupp.c \
|
||||||
src/semaphoretranslatereturncode.c src/semaphorewaitsupp.c \
|
src/semaphoretranslatereturncode.c src/semaphorewaitsupp.c \
|
||||||
src/semclose.c src/semdestroy.c src/semgetvalue.c src/seminit.c \
|
src/semclose.c src/semdestroy.c src/semgetvalue.c src/seminit.c \
|
||||||
src/semopen.c src/sempost.c src/semtimedwait.c src/semtrywait.c \
|
src/semopen.c src/sempost.c src/semtimedwait.c src/semtrywait.c \
|
||||||
@@ -195,6 +195,7 @@ libposix_a_SOURCES += src/getitimer.c src/setitimer.c
|
|||||||
|
|
||||||
## SUPPORT_C_FILES
|
## SUPPORT_C_FILES
|
||||||
libposix_a_SOURCES += src/psxpriorityisvalid.c
|
libposix_a_SOURCES += src/psxpriorityisvalid.c
|
||||||
|
libposix_a_SOURCES += src/psxnametoid.c
|
||||||
|
|
||||||
EXTRA_DIST += src/README.mqueue
|
EXTRA_DIST += src/README.mqueue
|
||||||
|
|
||||||
|
|||||||
@@ -45,19 +45,19 @@ typedef struct {
|
|||||||
} posix_initialization_threads_table;
|
} posix_initialization_threads_table;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int maximum_threads;
|
uint32_t maximum_threads;
|
||||||
int maximum_mutexes;
|
uint32_t maximum_mutexes;
|
||||||
int maximum_condition_variables;
|
uint32_t maximum_condition_variables;
|
||||||
int maximum_keys;
|
uint32_t maximum_keys;
|
||||||
int maximum_timers;
|
uint32_t maximum_timers;
|
||||||
int maximum_queued_signals;
|
uint32_t maximum_queued_signals;
|
||||||
int maximum_message_queues;
|
uint32_t maximum_message_queues;
|
||||||
int maximum_message_queue_descriptors;
|
uint32_t maximum_message_queue_descriptors;
|
||||||
int maximum_semaphores;
|
uint32_t maximum_semaphores;
|
||||||
int maximum_barriers;
|
uint32_t maximum_barriers;
|
||||||
int maximum_rwlocks;
|
uint32_t maximum_rwlocks;
|
||||||
int maximum_spinlocks;
|
uint32_t maximum_spinlocks;
|
||||||
int number_of_initialization_threads;
|
uint32_t number_of_initialization_threads;
|
||||||
posix_initialization_threads_table *User_initialization_threads_table;
|
posix_initialization_threads_table *User_initialization_threads_table;
|
||||||
} posix_api_configuration_table;
|
} posix_api_configuration_table;
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <mqueue.h> /* struct mq_attr */
|
#include <mqueue.h> /* struct mq_attr */
|
||||||
#include <rtems/score/coremsg.h>
|
#include <rtems/score/coremsg.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
|
#include <rtems/posix/posixapi.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -79,6 +80,7 @@ void _POSIX_Message_queue_Manager_initialization(void);
|
|||||||
|
|
||||||
int _POSIX_Message_queue_Create_support(
|
int _POSIX_Message_queue_Create_support(
|
||||||
const char *name,
|
const char *name,
|
||||||
|
size_t name_len,
|
||||||
int pshared,
|
int pshared,
|
||||||
struct mq_attr *attr,
|
struct mq_attr *attr,
|
||||||
POSIX_Message_queue_Control **message_queue
|
POSIX_Message_queue_Control **message_queue
|
||||||
@@ -126,7 +128,7 @@ int _POSIX_Message_queue_Send_support(
|
|||||||
mqd_t mqdes,
|
mqd_t mqdes,
|
||||||
const char *msg_ptr,
|
const char *msg_ptr,
|
||||||
size_t msg_len,
|
size_t msg_len,
|
||||||
uint32_t msg_prio,
|
unsigned int msg_prio,
|
||||||
bool wait,
|
bool wait,
|
||||||
Watchdog_Interval timeout
|
Watchdog_Interval timeout
|
||||||
);
|
);
|
||||||
@@ -186,20 +188,6 @@ RTEMS_INLINE_ROUTINE bool _POSIX_Message_queue_Is_null (
|
|||||||
POSIX_Message_queue_Control *the_mq
|
POSIX_Message_queue_Control *the_mq
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Message_queue_Name_to_id
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This routine looks up the specified name for a message queue and returns the
|
|
||||||
* id of the message queue associated with it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int _POSIX_Message_queue_Name_to_id(
|
|
||||||
const char *name,
|
|
||||||
Objects_Id *id
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _POSIX_Message_queue_Priority_to_core
|
* _POSIX_Message_queue_Priority_to_core
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#define _RTEMS_POSIX_POSIXAPI_H
|
#define _RTEMS_POSIX_POSIXAPI_H
|
||||||
|
|
||||||
#include <rtems/config.h>
|
#include <rtems/config.h>
|
||||||
|
#include <rtems/score/object.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize POSIX API
|
* @brief Initialize POSIX API
|
||||||
@@ -29,5 +30,27 @@
|
|||||||
*/
|
*/
|
||||||
void _POSIX_API_Initialize(void);
|
void _POSIX_API_Initialize(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Queries the object identifier @a id for a @a name.
|
||||||
|
*
|
||||||
|
* @param[in] information Object information.
|
||||||
|
* @param[in] name Zero terminated name string to look up.
|
||||||
|
* @param[out] id Pointer for identifier. The pointer must be valid.
|
||||||
|
* @param[out] len Pointer for string length. The pointer must be valid.
|
||||||
|
*
|
||||||
|
* @retval 0 Successful operation.
|
||||||
|
* @retval EINVAL The @a name pointer is @c NULL or the @a name string has
|
||||||
|
* zero length.
|
||||||
|
* @retval ENAMETOOLONG The @a name string length is greater than or equal to
|
||||||
|
* @c NAME_MAX.
|
||||||
|
* @retval ENOENT Found no corresponding identifier.
|
||||||
|
*/
|
||||||
|
int _POSIX_Name_to_id(
|
||||||
|
Objects_Information *information,
|
||||||
|
const char *name,
|
||||||
|
Objects_Id *id,
|
||||||
|
size_t *len
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <rtems/score/coresem.h>
|
#include <rtems/score/coresem.h>
|
||||||
|
#include <rtems/posix/posixapi.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data Structure used to manage a POSIX semaphore
|
* Data Structure used to manage a POSIX semaphore
|
||||||
@@ -129,6 +130,7 @@ RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_null (
|
|||||||
|
|
||||||
int _POSIX_Semaphore_Create_support(
|
int _POSIX_Semaphore_Create_support(
|
||||||
const char *name,
|
const char *name,
|
||||||
|
size_t name_len,
|
||||||
int pshared,
|
int pshared,
|
||||||
unsigned int value,
|
unsigned int value,
|
||||||
POSIX_Semaphore_Control **the_sem
|
POSIX_Semaphore_Control **the_sem
|
||||||
@@ -161,19 +163,6 @@ int _POSIX_Semaphore_Wait_support(
|
|||||||
Watchdog_Interval timeout
|
Watchdog_Interval timeout
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Semaphore_Name_to_id
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This routine performs name to id translation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int _POSIX_Semaphore_Name_to_id(
|
|
||||||
const char *name,
|
|
||||||
sem_t *id
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _POSIX_Semaphore_Translate_core_semaphore_return_code
|
* _POSIX_Semaphore_Translate_core_semaphore_return_code
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types _POSIX_Message_queue_Priori
|
|||||||
unsigned int priority
|
unsigned int priority
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return priority * -1;
|
return (CORE_message_queue_Submit_types) priority * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -143,7 +143,19 @@ RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* absolute value without a library dependency */
|
/* absolute value without a library dependency */
|
||||||
return ((priority >= 0) ? priority : -priority);
|
return (unsigned int) ((priority >= 0) ? priority : -priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see _POSIX_Name_to_id().
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE int _POSIX_Message_queue_Name_to_id(
|
||||||
|
const char *name,
|
||||||
|
Objects_Id *id,
|
||||||
|
size_t *len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return _POSIX_Name_to_id( &_POSIX_Message_queue_Information, name, id, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -81,6 +81,18 @@ RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_null (
|
|||||||
return !the_semaphore;
|
return !the_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see _POSIX_Name_to_id().
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Name_to_id(
|
||||||
|
const char *name,
|
||||||
|
Objects_Id *id,
|
||||||
|
size_t *len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return _POSIX_Name_to_id( &_POSIX_Semaphore_Information, name, id, len );
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,6 @@
|
|||||||
#include <rtems/posix/mqueue.h>
|
#include <rtems/posix/mqueue.h>
|
||||||
#include <rtems/posix/time.h>
|
#include <rtems/posix/time.h>
|
||||||
|
|
||||||
/* pure ANSI mode does not have this prototype */
|
|
||||||
size_t strnlen(const char *, size_t);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _POSIX_Message_queue_Create_support
|
* _POSIX_Message_queue_Create_support
|
||||||
*
|
*
|
||||||
@@ -54,6 +51,7 @@ size_t strnlen(const char *, size_t);
|
|||||||
|
|
||||||
int _POSIX_Message_queue_Create_support(
|
int _POSIX_Message_queue_Create_support(
|
||||||
const char *name_arg,
|
const char *name_arg,
|
||||||
|
size_t name_len,
|
||||||
int pshared,
|
int pshared,
|
||||||
struct mq_attr *attr_ptr,
|
struct mq_attr *attr_ptr,
|
||||||
POSIX_Message_queue_Control **message_queue
|
POSIX_Message_queue_Control **message_queue
|
||||||
@@ -63,9 +61,7 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
CORE_message_queue_Attributes *the_mq_attr;
|
CORE_message_queue_Attributes *the_mq_attr;
|
||||||
struct mq_attr attr;
|
struct mq_attr attr;
|
||||||
char *name;
|
char *name;
|
||||||
size_t n;
|
|
||||||
|
|
||||||
n = strnlen( name_arg, NAME_MAX );
|
|
||||||
/* length of name has already been validated */
|
/* length of name has already been validated */
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
@@ -99,22 +95,21 @@ int _POSIX_Message_queue_Create_support(
|
|||||||
rtems_set_errno_and_return_minus_one( ENFILE );
|
rtems_set_errno_and_return_minus_one( ENFILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
the_mq->process_shared = pshared;
|
|
||||||
the_mq->named = true;
|
|
||||||
the_mq->open_count = 1;
|
|
||||||
the_mq->linked = true;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make a copy of the user's string for name just in case it was
|
* Make a copy of the user's string for name just in case it was
|
||||||
* dynamically constructed.
|
* dynamically constructed.
|
||||||
*/
|
*/
|
||||||
name = _Workspace_Allocate(n+1);
|
name = _Workspace_String_duplicate( name_arg, name_len );
|
||||||
if (!name) {
|
if ( !name ) {
|
||||||
_POSIX_Message_queue_Free( the_mq );
|
_POSIX_Message_queue_Free( the_mq );
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
rtems_set_errno_and_return_minus_one( ENOMEM );
|
rtems_set_errno_and_return_minus_one( ENOMEM );
|
||||||
}
|
}
|
||||||
strncpy( name, name_arg, n+1 );
|
|
||||||
|
the_mq->process_shared = pshared;
|
||||||
|
the_mq->named = true;
|
||||||
|
the_mq->open_count = 1;
|
||||||
|
the_mq->linked = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: That thread blocking discipline should be based on the
|
* NOTE: That thread blocking discipline should be based on the
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* COPYRIGHT (c) 1989-2009.
|
|
||||||
* On-Line Applications Research Corporation (OAR).
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
|
||||||
* found in the file LICENSE in this distribution or at
|
|
||||||
* http://www.rtems.com/license/LICENSE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <mqueue.h>
|
|
||||||
|
|
||||||
#include <rtems/system.h>
|
|
||||||
#include <rtems/score/watchdog.h>
|
|
||||||
#include <rtems/seterr.h>
|
|
||||||
#include <rtems/posix/mqueue.h>
|
|
||||||
#include <rtems/posix/time.h>
|
|
||||||
|
|
||||||
/* pure ANSI mode does not have this prototype */
|
|
||||||
size_t strnlen(const char *, size_t);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Message_queue_Name_to_id
|
|
||||||
*
|
|
||||||
* Look up the specified name and attempt to locate the id
|
|
||||||
* for the associated message queue.
|
|
||||||
*/
|
|
||||||
int _POSIX_Message_queue_Name_to_id(
|
|
||||||
const char *name,
|
|
||||||
Objects_Id *id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Objects_Name_or_id_lookup_errors status;
|
|
||||||
Objects_Id the_id;
|
|
||||||
|
|
||||||
if ( !name )
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
if ( !name[0] )
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
if ( strnlen( name, NAME_MAX ) >= NAME_MAX )
|
|
||||||
return ENAMETOOLONG;
|
|
||||||
|
|
||||||
status = _Objects_Name_to_id_string(
|
|
||||||
&_POSIX_Message_queue_Information,
|
|
||||||
name,
|
|
||||||
&the_id
|
|
||||||
);
|
|
||||||
*id = the_id;
|
|
||||||
|
|
||||||
if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ENOENT;
|
|
||||||
}
|
|
||||||
@@ -58,6 +58,7 @@ mqd_t mq_open(
|
|||||||
POSIX_Message_queue_Control *the_mq;
|
POSIX_Message_queue_Control *the_mq;
|
||||||
POSIX_Message_queue_Control_fd *the_mq_fd;
|
POSIX_Message_queue_Control_fd *the_mq_fd;
|
||||||
Objects_Locations location;
|
Objects_Locations location;
|
||||||
|
size_t name_len;
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ mqd_t mq_open(
|
|||||||
}
|
}
|
||||||
the_mq_fd->oflag = oflag;
|
the_mq_fd->oflag = oflag;
|
||||||
|
|
||||||
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
|
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the name to id translation worked, then the message queue exists
|
* If the name to id translation worked, then the message queue exists
|
||||||
@@ -128,6 +129,7 @@ mqd_t mq_open(
|
|||||||
*/
|
*/
|
||||||
status = _POSIX_Message_queue_Create_support(
|
status = _POSIX_Message_queue_Create_support(
|
||||||
name,
|
name,
|
||||||
|
name_len,
|
||||||
true, /* shared across processes */
|
true, /* shared across processes */
|
||||||
attr,
|
attr,
|
||||||
&the_mq
|
&the_mq
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ int _POSIX_Message_queue_Send_support(
|
|||||||
mqd_t mqdes,
|
mqd_t mqdes,
|
||||||
const char *msg_ptr,
|
const char *msg_ptr,
|
||||||
size_t msg_len,
|
size_t msg_len,
|
||||||
uint32_t msg_prio,
|
unsigned int msg_prio,
|
||||||
bool wait,
|
bool wait,
|
||||||
Watchdog_Interval timeout
|
Watchdog_Interval timeout
|
||||||
)
|
)
|
||||||
@@ -91,7 +91,7 @@ int _POSIX_Message_queue_Send_support(
|
|||||||
*/
|
*/
|
||||||
msg_status = _CORE_message_queue_Submit(
|
msg_status = _CORE_message_queue_Submit(
|
||||||
&the_mq->Message_queue,
|
&the_mq->Message_queue,
|
||||||
(void *)msg_ptr,
|
msg_ptr,
|
||||||
msg_len,
|
msg_len,
|
||||||
mqdes, /* mqd_t is an object id */
|
mqdes, /* mqd_t is an object id */
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -51,10 +51,11 @@ int mq_unlink(
|
|||||||
int status;
|
int status;
|
||||||
register POSIX_Message_queue_Control *the_mq;
|
register POSIX_Message_queue_Control *the_mq;
|
||||||
Objects_Id the_mq_id;
|
Objects_Id the_mq_id;
|
||||||
|
size_t name_len;
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
|
|
||||||
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
|
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
|
||||||
if ( status != 0 ) {
|
if ( status != 0 ) {
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
rtems_set_errno_and_return_minus_one( status );
|
rtems_set_errno_and_return_minus_one( status );
|
||||||
|
|||||||
58
cpukit/posix/src/psxnametoid.c
Normal file
58
cpukit/posix/src/psxnametoid.c
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* COPYRIGHT (c) 1989-2009.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rtems/posix/posixapi.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* pure ANSI mode does not have this prototype */
|
||||||
|
size_t strnlen(const char *, size_t);
|
||||||
|
|
||||||
|
int _POSIX_Name_to_id(
|
||||||
|
Objects_Information *information,
|
||||||
|
const char *name,
|
||||||
|
Objects_Id *id,
|
||||||
|
size_t *len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int eno = EINVAL;
|
||||||
|
size_t n = 0;
|
||||||
|
|
||||||
|
if ( name != NULL && name [0] != '\0' ) {
|
||||||
|
n = strnlen( name, NAME_MAX );
|
||||||
|
|
||||||
|
if ( n < NAME_MAX ) {
|
||||||
|
Objects_Name_or_id_lookup_errors status = _Objects_Name_to_id_string(
|
||||||
|
information,
|
||||||
|
name,
|
||||||
|
id
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) {
|
||||||
|
eno = 0;
|
||||||
|
} else {
|
||||||
|
eno = ENOENT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
eno = ENAMETOOLONG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*len = n;
|
||||||
|
|
||||||
|
return eno;
|
||||||
|
}
|
||||||
@@ -24,13 +24,11 @@
|
|||||||
|
|
||||||
#include <rtems/system.h>
|
#include <rtems/system.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
|
#include <rtems/score/wkspace.h>
|
||||||
#include <rtems/posix/semaphore.h>
|
#include <rtems/posix/semaphore.h>
|
||||||
#include <rtems/posix/time.h>
|
#include <rtems/posix/time.h>
|
||||||
#include <rtems/seterr.h>
|
#include <rtems/seterr.h>
|
||||||
|
|
||||||
/* pure ANSI mode does not have this prototype */
|
|
||||||
size_t strnlen(const char *, size_t);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _POSIX_Semaphore_Create_support
|
* _POSIX_Semaphore_Create_support
|
||||||
*
|
*
|
||||||
@@ -39,7 +37,8 @@ size_t strnlen(const char *, size_t);
|
|||||||
* sem_open.
|
* sem_open.
|
||||||
*/
|
*/
|
||||||
int _POSIX_Semaphore_Create_support(
|
int _POSIX_Semaphore_Create_support(
|
||||||
const char *name,
|
const char *name_arg,
|
||||||
|
size_t name_len,
|
||||||
int pshared,
|
int pshared,
|
||||||
unsigned int value,
|
unsigned int value,
|
||||||
POSIX_Semaphore_Control **the_sem
|
POSIX_Semaphore_Control **the_sem
|
||||||
@@ -47,26 +46,35 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
{
|
{
|
||||||
POSIX_Semaphore_Control *the_semaphore;
|
POSIX_Semaphore_Control *the_semaphore;
|
||||||
CORE_semaphore_Attributes *the_sem_attr;
|
CORE_semaphore_Attributes *the_sem_attr;
|
||||||
char *name_p = (char *)name;
|
char *name;
|
||||||
|
|
||||||
/* Sharing semaphores among processes is not currently supported */
|
/* Sharing semaphores among processes is not currently supported */
|
||||||
if (pshared != 0)
|
if (pshared != 0)
|
||||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||||
|
|
||||||
if ( name ) {
|
|
||||||
if ( strnlen( name, NAME_MAX ) >= NAME_MAX )
|
|
||||||
rtems_set_errno_and_return_minus_one( ENAMETOOLONG );
|
|
||||||
}
|
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
|
|
||||||
the_semaphore = _POSIX_Semaphore_Allocate();
|
the_semaphore = _POSIX_Semaphore_Allocate();
|
||||||
|
|
||||||
if ( !the_semaphore ) {
|
if ( !the_semaphore ) {
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
rtems_set_errno_and_return_minus_one( ENOSPC );
|
rtems_set_errno_and_return_minus_one( ENOSPC );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a copy of the user's string for name just in case it was
|
||||||
|
* dynamically constructed.
|
||||||
|
*/
|
||||||
|
if ( name_arg != NULL ) {
|
||||||
|
name = _Workspace_String_duplicate( name_arg, name_len );
|
||||||
|
if ( !name ) {
|
||||||
|
_POSIX_Semaphore_Free( the_semaphore );
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
|
rtems_set_errno_and_return_minus_one( ENOMEM );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
name = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
the_semaphore->process_shared = pshared;
|
the_semaphore->process_shared = pshared;
|
||||||
|
|
||||||
if ( name ) {
|
if ( name ) {
|
||||||
@@ -103,7 +111,7 @@ int _POSIX_Semaphore_Create_support(
|
|||||||
_Objects_Open_string(
|
_Objects_Open_string(
|
||||||
&_POSIX_Semaphore_Information,
|
&_POSIX_Semaphore_Information,
|
||||||
&the_semaphore->Object,
|
&the_semaphore->Object,
|
||||||
name_p
|
name
|
||||||
);
|
);
|
||||||
|
|
||||||
*the_sem = the_semaphore;
|
*the_sem = the_semaphore;
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* COPYRIGHT (c) 1989-2007.
|
|
||||||
* On-Line Applications Research Corporation (OAR).
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
|
||||||
* found in the file LICENSE in this distribution or at
|
|
||||||
* http://www.rtems.com/license/LICENSE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <semaphore.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include <rtems/system.h>
|
|
||||||
#include <rtems/score/object.h>
|
|
||||||
#include <rtems/posix/semaphore.h>
|
|
||||||
#include <rtems/posix/time.h>
|
|
||||||
#include <rtems/seterr.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Semaphore_Name_to_id
|
|
||||||
*
|
|
||||||
* Look up the specified name and attempt to locate the id
|
|
||||||
* for the associated semaphore.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int _POSIX_Semaphore_Name_to_id(
|
|
||||||
const char *name,
|
|
||||||
sem_t *id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Objects_Name_or_id_lookup_errors status;
|
|
||||||
Objects_Id the_id;
|
|
||||||
|
|
||||||
if ( !name )
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
if ( !name[0] )
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
status = _Objects_Name_to_id_string(
|
|
||||||
&_POSIX_Semaphore_Information,
|
|
||||||
name,
|
|
||||||
&the_id
|
|
||||||
);
|
|
||||||
*id = the_id;
|
|
||||||
|
|
||||||
if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ENOENT;
|
|
||||||
}
|
|
||||||
@@ -45,6 +45,7 @@ int sem_init(
|
|||||||
|
|
||||||
status = _POSIX_Semaphore_Create_support(
|
status = _POSIX_Semaphore_Create_support(
|
||||||
NULL,
|
NULL,
|
||||||
|
0,
|
||||||
pshared,
|
pshared,
|
||||||
value,
|
value,
|
||||||
&the_semaphore
|
&the_semaphore
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ sem_t *sem_open(
|
|||||||
mode_t mode;
|
mode_t mode;
|
||||||
unsigned int value = 0;
|
unsigned int value = 0;
|
||||||
int status;
|
int status;
|
||||||
sem_t the_semaphore_id;
|
Objects_Id the_semaphore_id;
|
||||||
sem_t *id;
|
|
||||||
POSIX_Semaphore_Control *the_semaphore;
|
POSIX_Semaphore_Control *the_semaphore;
|
||||||
Objects_Locations location;
|
Objects_Locations location;
|
||||||
|
size_t name_len;
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ sem_t *sem_open(
|
|||||||
va_end(arg);
|
va_end(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
|
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the name to id translation worked, then the semaphore exists
|
* If the name to id translation worked, then the semaphore exists
|
||||||
@@ -96,7 +96,7 @@ sem_t *sem_open(
|
|||||||
rtems_set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
|
rtems_set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
|
||||||
}
|
}
|
||||||
|
|
||||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
the_semaphore = _POSIX_Semaphore_Get( (sem_t *) &the_semaphore_id, &location );
|
||||||
the_semaphore->open_count += 1;
|
the_semaphore->open_count += 1;
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
@@ -110,6 +110,7 @@ sem_t *sem_open(
|
|||||||
|
|
||||||
status =_POSIX_Semaphore_Create_support(
|
status =_POSIX_Semaphore_Create_support(
|
||||||
name,
|
name,
|
||||||
|
name_len,
|
||||||
false, /* not shared across processes */
|
false, /* not shared across processes */
|
||||||
value,
|
value,
|
||||||
&the_semaphore
|
&the_semaphore
|
||||||
@@ -127,9 +128,8 @@ sem_t *sem_open(
|
|||||||
return_id:
|
return_id:
|
||||||
#if defined(RTEMS_USE_16_BIT_OBJECT)
|
#if defined(RTEMS_USE_16_BIT_OBJECT)
|
||||||
the_semaphore->Semaphore_id = the_semaphore->Object.id;
|
the_semaphore->Semaphore_id = the_semaphore->Object.id;
|
||||||
id = &the_semaphore->Semaphore_id;
|
return &the_semaphore->Semaphore_id;
|
||||||
#else
|
#else
|
||||||
id = (sem_t *)&the_semaphore->Object.id;
|
return (sem_t *)&the_semaphore->Object.id;
|
||||||
#endif
|
#endif
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,11 +42,12 @@ int sem_unlink(
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
register POSIX_Semaphore_Control *the_semaphore;
|
register POSIX_Semaphore_Control *the_semaphore;
|
||||||
sem_t the_semaphore_id;
|
Objects_Id the_semaphore_id;
|
||||||
|
size_t name_len;
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
|
|
||||||
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
|
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
|
||||||
if ( status != 0 ) {
|
if ( status != 0 ) {
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
rtems_set_errno_and_return_minus_one( status );
|
rtems_set_errno_and_return_minus_one( status );
|
||||||
|
|||||||
Reference in New Issue
Block a user