* rtems/include/rtems/rtems/sem.h, rtems/src/semobtain.c:
	Changed option set type to rtems_option.

	* score/src/objectgetinfo.c: Check return value of
	_Objects_API_maximum_class().

	* libmisc/monitor/mon-mpci.c, libmisc/monitor/monitor.h,
	rtems/include/rtems/rtems/message.h, rtems/src/msgmp.c,
	rtems/src/msgqallocate.c, rtems/src/msgqbroadcast.c,
	rtems/src/msgqcreate.c, rtems/src/msgqreceive.c, rtems/src/msgqsend.c,
	rtems/src/msgqurgent.c, score/include/rtems/score/coremsg.h,
	score/include/rtems/score/mpci.h, score/include/rtems/score/thread.h,
	score/inline/rtems/score/coremsg.inl, score/src/coremsg.c,
	score/src/coremsgbroadcast.c, score/src/coremsgseize.c,
	score/src/coremsgsubmit.c:
	Removed parameters of _Message_queue_Allocate().  Changed option set
	type to rtems_option.  Changed type of maximum message and packet size
	to size_t.  Changed the input buffer type for message send functions to
	"const void *".  Changed the pointer to the second return argument in
	the thread wait information to a union.  This union can contain a
	pointer to an immutable or a mutable object.  This is somewhat fragile.
	An alternative would be to add a third pointer for immutable objects,
	but this would increase the structure size.
This commit is contained in:
Joel Sherrill
2008-08-05 13:32:39 +00:00
parent 334b3c1e83
commit f773c0122a
22 changed files with 115 additions and 73 deletions
+26
View File
@@ -1,3 +1,29 @@
2008-08-05 Sebastian Huber <sebastian.huber@embedded-brains.de>
* rtems/include/rtems/rtems/sem.h, rtems/src/semobtain.c:
Changed option set type to rtems_option.
* score/src/objectgetinfo.c: Check return value of
_Objects_API_maximum_class().
* libmisc/monitor/mon-mpci.c, libmisc/monitor/monitor.h,
rtems/include/rtems/rtems/message.h, rtems/src/msgmp.c,
rtems/src/msgqallocate.c, rtems/src/msgqbroadcast.c,
rtems/src/msgqcreate.c, rtems/src/msgqreceive.c, rtems/src/msgqsend.c,
rtems/src/msgqurgent.c, score/include/rtems/score/coremsg.h,
score/include/rtems/score/mpci.h, score/include/rtems/score/thread.h,
score/inline/rtems/score/coremsg.inl, score/src/coremsg.c,
score/src/coremsgbroadcast.c, score/src/coremsgseize.c,
score/src/coremsgsubmit.c:
Removed parameters of _Message_queue_Allocate(). Changed option set
type to rtems_option. Changed type of maximum message and packet size
to size_t. Changed the input buffer type for message send functions to
"const void *". Changed the pointer to the second return argument in
the thread wait information to a union. This union can contain a
pointer to an immutable or a mutable object. This is somewhat fragile.
An alternative would be to add a third pointer for immutable objects,
but this would increase the structure size.
2008-08-05 Xudong Guan <xudong.guan@criticalsoftware.com>
PR 1212/cpukit
+1 -1
View File
@@ -131,7 +131,7 @@ rtems_monitor_mpci_dump(
length += rtems_monitor_dump_decimal(monitor_mpci->default_timeout);
length += rtems_monitor_pad(46, length);
length += rtems_monitor_dump_decimal(monitor_mpci->maximum_packet_size);
length += rtems_monitor_dump_decimal((uint32_t) monitor_mpci->maximum_packet_size);
fprintf(stdout,"\n");
length = 0;
+2 -2
View File
@@ -139,7 +139,7 @@ typedef struct {
rtems_attribute attributes;
uint32_t number_of_pending_messages;
uint32_t maximum_pending_messages;
uint32_t maximum_message_size;
size_t maximum_message_size;
} rtems_monitor_queue_t;
/*
@@ -251,7 +251,7 @@ typedef struct {
uint32_t maximum_proxies; /* maximum # proxies */
uint32_t default_timeout; /* in ticks */
uint32_t maximum_packet_size;
size_t maximum_packet_size;
rtems_monitor_symbol_t initialization;
rtems_monitor_symbol_t get_packet;
rtems_monitor_symbol_t return_packet;
+8 -10
View File
@@ -46,6 +46,7 @@ extern "C" {
#include <rtems/rtems/types.h>
#include <rtems/rtems/status.h>
#include <rtems/rtems/options.h>
#include <rtems/score/chain.h>
#include <rtems/score/object.h>
#include <rtems/rtems/attr.h>
@@ -117,7 +118,7 @@ void _Message_queue_Manager_initialization(
rtems_status_code rtems_message_queue_create(
rtems_name name,
uint32_t count,
uint32_t max_message_size,
size_t max_message_size,
rtems_attribute attribute_set,
Objects_Id *id
);
@@ -164,7 +165,7 @@ rtems_status_code rtems_message_queue_delete(
*/
rtems_status_code rtems_message_queue_send(
Objects_Id id,
void *buffer,
const void *buffer,
size_t size
);
@@ -179,7 +180,7 @@ rtems_status_code rtems_message_queue_send(
*/
rtems_status_code rtems_message_queue_urgent(
Objects_Id id,
void *buffer,
const void *buffer,
size_t size
);
@@ -193,7 +194,7 @@ rtems_status_code rtems_message_queue_urgent(
*/
rtems_status_code rtems_message_queue_broadcast(
Objects_Id id,
void *buffer,
const void *buffer,
size_t size,
uint32_t *count
);
@@ -213,7 +214,7 @@ rtems_status_code rtems_message_queue_receive(
Objects_Id id,
void *buffer,
size_t *size,
uint32_t option_set,
rtems_option option_set,
rtems_interval timeout
);
@@ -256,7 +257,7 @@ rtems_status_code rtems_message_queue_get_number_pending(
*/
rtems_status_code _Message_queue_Submit(
Objects_Id id,
void *buffer,
const void *buffer,
size_t size,
Message_queue_Submit_types submit_type
);
@@ -267,10 +268,7 @@ rtems_status_code _Message_queue_Submit(
* This function allocates a message queue control block from
* the inactive chain of free message queue control blocks.
*/
Message_queue_Control *_Message_queue_Allocate (
uint32_t count,
uint32_t max_message_size
);
Message_queue_Control *_Message_queue_Allocate (void);
/**
* @brief Message_queue_Translate_core_message_queue_return_code
+2 -1
View File
@@ -43,6 +43,7 @@ extern "C" {
#endif
#include <rtems/rtems/types.h>
#include <rtems/rtems/options.h>
#include <rtems/rtems/support.h>
#include <rtems/rtems/tasks.h>
#include <rtems/rtems/attr.h>
@@ -168,7 +169,7 @@ rtems_status_code rtems_semaphore_delete(
*/
rtems_status_code rtems_semaphore_obtain(
rtems_id id,
uint32_t option_set,
rtems_option option_set,
rtems_interval timeout
);
+6 -6
View File
@@ -92,7 +92,7 @@ void _Message_queue_MP_Send_process_packet (
rtems_status_code _Message_queue_MP_Send_request_packet (
Message_queue_MP_Remote_operations operation,
Objects_Id message_queue_id,
void *buffer,
const void *buffer,
size_t *size_p,
rtems_option option_set,
rtems_interval timeout
@@ -168,8 +168,8 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
the_packet->option_set = option_set;
the_packet->size = 0; /* just in case of an error */
_Thread_Executing->Wait.return_argument = (uint32_t *)buffer;
_Thread_Executing->Wait.return_argument_1 = size_p;
_Thread_Executing->Wait.return_argument_second.immutable_object = buffer;
_Thread_Executing->Wait.return_argument = size_p;
return (rtems_status_code) _MPCI_Send_request_packet(
_Objects_Get_node(message_queue_id),
@@ -322,12 +322,12 @@ void _Message_queue_MP_Process_packet (
the_thread = _MPCI_Process_response( the_packet_prefix );
if (the_packet->Prefix.return_code == RTEMS_SUCCESSFUL) {
*(uint32_t *)the_thread->Wait.return_argument_1 =
*(size_t *) the_thread->Wait.return_argument =
the_packet->size;
_CORE_message_queue_Copy_buffer(
the_packet->Buffer.buffer,
the_thread->Wait.return_argument,
the_thread->Wait.return_argument_second.mutable_object,
the_packet->size
);
}
@@ -395,7 +395,7 @@ void _Message_queue_MP_Process_packet (
the_thread = _MPCI_Process_response( the_packet_prefix );
*(uint32_t *)the_thread->Wait.return_argument = the_packet->count;
*(uint32_t *) the_thread->Wait.return_argument = the_packet->count;
_MPCI_Return_packet( the_packet_prefix );
break;
+3 -7
View File
@@ -49,12 +49,8 @@
* the_message_queue - set if successful, NULL otherwise
*/
Message_queue_Control *_Message_queue_Allocate (
uint32_t count,
uint32_t max_message_size
)
Message_queue_Control *_Message_queue_Allocate(void)
{
return
(Message_queue_Control *)_Objects_Allocate(&_Message_queue_Information);
return (Message_queue_Control *)
_Objects_Allocate(&_Message_queue_Information);
}
+1 -1
View File
@@ -55,7 +55,7 @@
rtems_status_code rtems_message_queue_broadcast(
Objects_Id id,
void *buffer,
const void *buffer,
size_t size,
uint32_t *count
)
+2 -2
View File
@@ -57,7 +57,7 @@
rtems_status_code rtems_message_queue_create(
rtems_name name,
uint32_t count,
uint32_t max_message_size,
size_t max_message_size,
rtems_attribute attribute_set,
Objects_Id *id
)
@@ -101,7 +101,7 @@ rtems_status_code rtems_message_queue_create(
_Thread_Disable_dispatch(); /* protects object pointer */
the_message_queue = _Message_queue_Allocate( count, max_message_size );
the_message_queue = _Message_queue_Allocate();
if ( !the_message_queue ) {
_Thread_Enable_dispatch();
+1 -1
View File
@@ -57,7 +57,7 @@ rtems_status_code rtems_message_queue_receive(
Objects_Id id,
void *buffer,
size_t *size,
uint32_t option_set,
rtems_option option_set,
rtems_interval timeout
)
{
+1 -1
View File
@@ -58,7 +58,7 @@
rtems_status_code rtems_message_queue_send(
Objects_Id id,
void *buffer,
const void *buffer,
size_t size
)
{
+1 -1
View File
@@ -58,7 +58,7 @@
rtems_status_code rtems_message_queue_urgent(
Objects_Id id,
void *buffer,
const void *buffer,
size_t size
)
{
+1 -1
View File
@@ -67,7 +67,7 @@
rtems_status_code rtems_semaphore_obtain(
rtems_id id,
uint32_t option_set,
rtems_option option_set,
rtems_interval timeout
)
{
+5 -5
View File
@@ -201,7 +201,7 @@ typedef struct {
/** This is the size in bytes of the largest message which may be
* sent via this queue.
*/
uint32_t maximum_message_size;
size_t maximum_message_size;
/** This chain is the set of pending messages. It may be ordered by
* message priority or in FIFO order.
*/
@@ -244,7 +244,7 @@ boolean _CORE_message_queue_Initialize(
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Attributes *the_message_queue_attributes,
uint32_t maximum_pending_messages,
uint32_t maximum_message_size
size_t maximum_message_size
);
/**
@@ -326,7 +326,7 @@ void _CORE_message_queue_Flush_waiting_threads(
*/
CORE_message_queue_Status _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
void *buffer,
const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -360,7 +360,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
*/
CORE_message_queue_Status _CORE_message_queue_Submit(
CORE_message_queue_Control *the_message_queue,
void *buffer,
const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -396,7 +396,7 @@ void _CORE_message_queue_Seize(
CORE_message_queue_Control *the_message_queue,
Objects_Id id,
void *buffer,
size_t *size,
size_t *size_p,
boolean wait,
Watchdog_Interval timeout
);
+1 -1
View File
@@ -122,7 +122,7 @@ typedef struct {
* MPCI layer. This size places a limit on the size of a message
* which can be transmitted over this interface.
**/
uint32_t maximum_packet_size;
size_t maximum_packet_size;
/** This field points to the MPCI initialization entry point. */
MPCI_initialization_entry initialization;
/** This field points to the MPCI get packet entry point. */
+19 -3
View File
@@ -209,6 +209,21 @@ typedef struct {
*/
#define THREAD_STATUS_PROXY_BLOCKING 0x1111111
/**
* @brief Union type to hold a pointer to an immutable or a mutable object.
*
* The main purpose is to enable passing of pointers to read-only send buffers
* in the message passing subsystem. This approach is somewhat fragile since
* it prevents the compiler to check if the operations on objects are valid
* with respect to the constant qualifier. An alternative would be to add a
* third pointer argument for immutable objects, but this would increase the
* structure size.
*/
typedef union {
void *mutable_object;
const void *immutable_object;
} Thread_Wait_information_Object_argument_type;
/** @brief Thread Blocking Management Information
*
* This contains the information required to manage a thread while it is
@@ -219,10 +234,11 @@ typedef struct {
Objects_Id id;
/** This field is used to return an integer while when blocked. */
uint32_t count;
/** This field is the first pointer to a user return argument. */
/** This field is for a pointer to a user return argument. */
void *return_argument;
/** This field is the second pointer to a user return argument. */
void *return_argument_1;
/** This field is for a pointer to a second user return argument. */
Thread_Wait_information_Object_argument_type
return_argument_second;
/** This field contains any options in effect on this blocking operation. */
uint32_t option;
/** This field will contain the return status from a blocking operation.
+2 -2
View File
@@ -32,7 +32,7 @@
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
CORE_message_queue_Control *the_message_queue,
void *buffer,
const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -62,7 +62,7 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
CORE_message_queue_Control *the_message_queue,
void *buffer,
const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
+5 -5
View File
@@ -56,11 +56,11 @@ boolean _CORE_message_queue_Initialize(
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Attributes *the_message_queue_attributes,
uint32_t maximum_pending_messages,
uint32_t maximum_message_size
size_t maximum_message_size
)
{
uint32_t message_buffering_required;
uint32_t allocated_message_size;
size_t message_buffering_required;
size_t allocated_message_size;
the_message_queue->maximum_pending_messages = maximum_pending_messages;
the_message_queue->number_of_pending_messages = 0;
@@ -85,7 +85,7 @@ boolean _CORE_message_queue_Initialize(
* Calculate how much total memory is required for message buffering and
* check for overflow on the multiplication.
*/
message_buffering_required = maximum_pending_messages *
message_buffering_required = (size_t) maximum_pending_messages *
(allocated_message_size + sizeof(CORE_message_queue_Buffer_control));
if (message_buffering_required < allocated_message_size)
@@ -107,7 +107,7 @@ boolean _CORE_message_queue_Initialize(
_Chain_Initialize (
&the_message_queue->Inactive_messages,
the_message_queue->message_buffers,
maximum_pending_messages,
(size_t) maximum_pending_messages,
allocated_message_size + sizeof( CORE_message_queue_Buffer_control )
);
+4 -4
View File
@@ -56,7 +56,7 @@
CORE_message_queue_Status _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
void *buffer,
const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -66,7 +66,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
Thread_Control *the_thread;
uint32_t number_broadcasted;
Thread_Wait_information *waitp;
uint32_t constrained_size;
size_t constrained_size;
/*
* If there are pending messages, then there can't be threads
@@ -98,11 +98,11 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
_CORE_message_queue_Copy_buffer(
buffer,
waitp->return_argument,
waitp->return_argument_second.mutable_object,
constrained_size
);
*(uint32_t *)the_thread->Wait.return_argument_1 = size;
*(size_t *) the_thread->Wait.return_argument = size;
#if defined(RTEMS_MULTIPROCESSING)
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
+10 -10
View File
@@ -46,7 +46,7 @@
* the_message_queue - pointer to message queue
* id - id of object we are waitig on
* buffer - pointer to message buffer to be filled
* size - pointer to the size of buffer to be filled
* size_p - pointer to the size of buffer to be filled
* wait - TRUE if wait is allowed, FALSE otherwise
* timeout - time to wait for a message
*
@@ -63,7 +63,7 @@ void _CORE_message_queue_Seize(
CORE_message_queue_Control *the_message_queue,
Objects_Id id,
void *buffer,
size_t *size,
size_t *size_p,
boolean wait,
Watchdog_Interval timeout
)
@@ -81,9 +81,9 @@ void _CORE_message_queue_Seize(
the_message_queue->number_of_pending_messages -= 1;
_ISR_Enable( level );
*size = the_message->Contents.size;
*size_p = the_message->Contents.size;
_Thread_Executing->Wait.count = the_message->priority;
_CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size);
_CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p);
/*
* There could be a thread waiting to send a message. If there
@@ -106,9 +106,9 @@ void _CORE_message_queue_Seize(
*/
the_message->priority = the_thread->Wait.count;
the_message->Contents.size = (uint32_t)the_thread->Wait.option;
the_message->Contents.size = (size_t) the_thread->Wait.option;
_CORE_message_queue_Copy_buffer(
the_thread->Wait.return_argument,
the_thread->Wait.return_argument_second.immutable_object,
the_message->Contents.buffer,
the_message->Contents.size
);
@@ -128,10 +128,10 @@ void _CORE_message_queue_Seize(
}
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
executing->Wait.queue = &the_message_queue->Wait_queue;
executing->Wait.id = id;
executing->Wait.return_argument = buffer;
executing->Wait.return_argument_1 = (void *)size;
executing->Wait.queue = &the_message_queue->Wait_queue;
executing->Wait.id = id;
executing->Wait.return_argument_second.mutable_object = buffer;
executing->Wait.return_argument = size_p;
/* Wait.count will be filled in with the message priority */
_ISR_Enable( level );
+8 -8
View File
@@ -59,7 +59,7 @@
CORE_message_queue_Status _CORE_message_queue_Submit(
CORE_message_queue_Control *the_message_queue,
void *buffer,
const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -85,10 +85,10 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
if ( the_thread ) {
_CORE_message_queue_Copy_buffer(
buffer,
the_thread->Wait.return_argument,
the_thread->Wait.return_argument_second.mutable_object,
size
);
*(size_t *)the_thread->Wait.return_argument_1 = size;
*(size_t *) the_thread->Wait.return_argument = size;
the_thread->Wait.count = submit_type;
#if defined(RTEMS_MULTIPROCESSING)
@@ -165,11 +165,11 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
_ISR_Disable( level );
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
executing->Wait.queue = &the_message_queue->Wait_queue;
executing->Wait.id = id;
executing->Wait.return_argument = buffer;
executing->Wait.option = size;
executing->Wait.count = submit_type;
executing->Wait.queue = &the_message_queue->Wait_queue;
executing->Wait.id = id;
executing->Wait.return_argument_second.immutable_object = buffer;
executing->Wait.option = (uint32_t) size;
executing->Wait.count = submit_type;
_ISR_Enable( level );
_Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
+6 -1
View File
@@ -24,11 +24,16 @@ Objects_Information *_Objects_Get_information(
)
{
Objects_Information *info;
int the_class_api_maximum;
if ( !_Objects_Is_api_valid( the_api ) )
return NULL;
if ( !the_class || the_class > _Objects_API_maximum_class(the_api) )
if ( !the_class )
return NULL;
the_class_api_maximum = _Objects_API_maximum_class( the_api );
if ( the_class_api_maximum < 0 || the_class > (uint32_t) the_class_api_maximum )
return NULL;
if ( !_Objects_Information_table[ the_api ] )