RCS file: /usr1/CVS/rtems/cpukit/score/src/coremsg.c,v
retrieving revision 1.14.2.1
diff -u -r1.14.2.1 coremsg.c
|
|
|
64 | 64 | _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL ); |
65 | 65 | |
66 | 66 | /* |
67 | | * round size up to multiple of a ptr for chain init |
| 67 | * Round size up to multiple of a pointer for chain init and |
| 68 | * check for overflow on adding overhead to each message. |
68 | 69 | */ |
69 | 70 | |
70 | 71 | allocated_message_size = maximum_message_size; |
… |
… |
|
73 | 74 | allocated_message_size &= ~(sizeof(unsigned32) - 1); |
74 | 75 | } |
75 | 76 | |
| 77 | if (allocated_message_size < maximum_message_size) |
| 78 | return FALSE; |
| 79 | |
| 80 | /* |
| 81 | * Calculate how much total memory is required for message buffering and |
| 82 | * check for overflow on the multiplication. |
| 83 | */ |
76 | 84 | message_buffering_required = maximum_pending_messages * |
77 | 85 | (allocated_message_size + sizeof(CORE_message_queue_Buffer_control)); |
78 | 86 | |
| 87 | if (message_buffering_required < allocated_message_size) |
| 88 | return FALSE; |
| 89 | |
| 90 | /* |
| 91 | * Attempt to allocate the message memory |
| 92 | */ |
79 | 93 | the_message_queue->message_buffers = (CORE_message_queue_Buffer *) |
80 | 94 | _Workspace_Allocate( message_buffering_required ); |
81 | 95 | |
82 | 96 | if (the_message_queue->message_buffers == 0) |
83 | 97 | return FALSE; |
84 | 98 | |
| 99 | /* |
| 100 | * Initialize the pool of inactive messages, pending messages, |
| 101 | * and set of waiting threads. |
| 102 | */ |
85 | 103 | _Chain_Initialize ( |
86 | 104 | &the_message_queue->Inactive_messages, |
87 | 105 | the_message_queue->message_buffers, |