Skip to content

Commit 182bbd5

Browse files
authored
Merge pull request #5547 from ARMmbed/revert_PR5428
Revert "Shrink RTOS classes"
2 parents 34b61d1 + d1236f6 commit 182bbd5

File tree

10 files changed

+37
-31
lines changed

10 files changed

+37
-31
lines changed

rtos/EventFlags.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ EventFlags::EventFlags(const char *name)
3939
void EventFlags::constructor(const char *name)
4040
{
4141
memset(&_obj_mem, 0, sizeof(_obj_mem));
42-
osEventFlagsAttr_t attr;
43-
attr.name = name ? name : "application_unnamed_event_flags";
44-
attr.cb_mem = &_obj_mem;
45-
attr.cb_size = sizeof(_obj_mem);
46-
_id = osEventFlagsNew(&attr);
42+
memset(&_attr, 0, sizeof(_attr));
43+
_attr.name = name ? name : "application_unnamed_event_flags";
44+
_attr.cb_mem = &_obj_mem;
45+
_attr.cb_size = sizeof(_obj_mem);
46+
_id = osEventFlagsNew(&_attr);
4747
MBED_ASSERT(_id);
4848
}
4949

rtos/EventFlags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class EventFlags : private mbed::NonCopyable<EventFlags> {
9494
void constructor(const char *name = NULL);
9595
uint32_t wait(uint32_t flags, uint32_t opt, uint32_t timeout, bool clear);
9696
osEventFlagsId_t _id;
97+
osEventFlagsAttr_t _attr;
9798
mbed_rtos_storage_event_flags_t _obj_mem;
9899
};
99100

rtos/MemoryPool.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
5454
MemoryPool() {
5555
memset(_pool_mem, 0, sizeof(_pool_mem));
5656
memset(&_obj_mem, 0, sizeof(_obj_mem));
57-
osMemoryPoolAttr_t attr = { 0 };
58-
attr.mp_mem = _pool_mem;
59-
attr.mp_size = sizeof(_pool_mem);
60-
attr.cb_mem = &_obj_mem;
61-
attr.cb_size = sizeof(_obj_mem);
62-
_id = osMemoryPoolNew(pool_sz, sizeof(T), &attr);
57+
memset(&_attr, 0, sizeof(_attr));
58+
_attr.mp_mem = _pool_mem;
59+
_attr.mp_size = sizeof(_pool_mem);
60+
_attr.cb_mem = &_obj_mem;
61+
_attr.cb_size = sizeof(_obj_mem);
62+
_id = osMemoryPoolNew(pool_sz, sizeof(T), &_attr);
6363
MBED_ASSERT(_id);
6464
}
6565

@@ -99,6 +99,7 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
9999

100100
private:
101101
osMemoryPoolId_t _id;
102+
osMemoryPoolAttr_t _attr;
102103
/* osMemoryPoolNew requires that pool block size is a multiple of 4 bytes. */
103104
char _pool_mem[((sizeof(T) + 3) & ~3) * pool_sz];
104105
mbed_rtos_storage_mem_pool_t _obj_mem;

rtos/Mutex.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ Mutex::Mutex(const char *name)
4040
void Mutex::constructor(const char *name)
4141
{
4242
memset(&_obj_mem, 0, sizeof(_obj_mem));
43-
osMutexAttr_t attr = { 0 };
44-
attr.name = name ? name : "aplication_unnamed_mutex";
45-
attr.cb_mem = &_obj_mem;
46-
attr.cb_size = sizeof(_obj_mem);
47-
attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
48-
_id = osMutexNew(&attr);
43+
memset(&_attr, 0, sizeof(_attr));
44+
_attr.name = name ? name : "aplication_unnamed_mutex";
45+
_attr.cb_mem = &_obj_mem;
46+
_attr.cb_size = sizeof(_obj_mem);
47+
_attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
48+
_id = osMutexNew(&_attr);
4949
MBED_ASSERT(_id);
5050
}
5151

rtos/Mutex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Mutex : private mbed::NonCopyable<Mutex> {
8686
void constructor(const char *name = NULL);
8787

8888
osMutexId_t _id;
89+
osMutexAttr_t _attr;
8990
mbed_rtos_storage_mutex_t _obj_mem;
9091
};
9192
/** @}*/

rtos/Queue.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
5555
/** Create and initialize a message Queue. */
5656
Queue() {
5757
memset(&_obj_mem, 0, sizeof(_obj_mem));
58-
osMessageQueueAttr_t attr = { 0 };
59-
attr.mq_mem = _queue_mem;
60-
attr.mq_size = sizeof(_queue_mem);
61-
attr.cb_mem = &_obj_mem;
62-
attr.cb_size = sizeof(_obj_mem);
63-
_id = osMessageQueueNew(queue_sz, sizeof(T*), &attr);
58+
memset(&_attr, 0, sizeof(_attr));
59+
_attr.mq_mem = _queue_mem;
60+
_attr.mq_size = sizeof(_queue_mem);
61+
_attr.cb_mem = &_obj_mem;
62+
_attr.cb_size = sizeof(_obj_mem);
63+
_id = osMessageQueueNew(queue_sz, sizeof(T*), &_attr);
6464
MBED_ASSERT(_id);
6565
}
6666

@@ -119,6 +119,7 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
119119

120120
private:
121121
osMessageQueueId_t _id;
122+
osMessageQueueAttr_t _attr;
122123
char _queue_mem[queue_sz * (sizeof(T*) + sizeof(mbed_rtos_storage_message_t))];
123124
mbed_rtos_storage_msg_queue_t _obj_mem;
124125
};

rtos/RtosTimer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ namespace rtos {
3131
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
3232
_function = func;
3333
memset(&_obj_mem, 0, sizeof(_obj_mem));
34-
osTimerAttr_t attr = { 0 };
35-
attr.cb_mem = &_obj_mem;
36-
attr.cb_size = sizeof(_obj_mem);
37-
_id = osTimerNew((void (*)(void *))Callback<void()>::thunk, type, &_function, &attr);
34+
memset(&_attr, 0, sizeof(_attr));
35+
_attr.cb_mem = &_obj_mem;
36+
_attr.cb_size = sizeof(_obj_mem);
37+
_id = osTimerNew((void (*)(void *))Callback<void()>::thunk, type, &_function, &_attr);
3838
MBED_ASSERT(_id);
3939
}
4040

rtos/RtosTimer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class RtosTimer : private mbed::NonCopyable<RtosTimer> {
161161
void constructor(mbed::Callback<void()> func, os_timer_type type);
162162

163163
osTimerId_t _id;
164+
osTimerAttr_t _attr;
164165
mbed_rtos_storage_timer_t _obj_mem;
165166
mbed::Callback<void()> _function;
166167
};

rtos/Semaphore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ Semaphore::Semaphore(int32_t count, uint16_t max_count) {
3636

3737
void Semaphore::constructor(int32_t count, uint16_t max_count) {
3838
memset(&_obj_mem, 0, sizeof(_obj_mem));
39-
osSemaphoreAttr_t attr = { 0 };
40-
attr.cb_mem = &_obj_mem;
41-
attr.cb_size = sizeof(_obj_mem);
42-
_id = osSemaphoreNew(max_count, count, &attr);
39+
memset(&_attr, 0, sizeof(_attr));
40+
_attr.cb_mem = &_obj_mem;
41+
_attr.cb_size = sizeof(_obj_mem);
42+
_id = osSemaphoreNew(max_count, count, &_attr);
4343
MBED_ASSERT(_id != NULL);
4444
}
4545

rtos/Semaphore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Semaphore : private mbed::NonCopyable<Semaphore> {
7575
void constructor(int32_t count, uint16_t max_count);
7676

7777
osSemaphoreId_t _id;
78+
osSemaphoreAttr_t _attr;
7879
mbed_rtos_storage_semaphore_t _obj_mem;
7980
};
8081
/** @}*/

0 commit comments

Comments
 (0)