Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shrink RTOS classes #5428

Merged
merged 1 commit into from Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions rtos/EventFlags.cpp
Expand Up @@ -39,11 +39,11 @@ EventFlags::EventFlags(const char *name)
void EventFlags::constructor(const char *name)
{
memset(&_obj_mem, 0, sizeof(_obj_mem));
memset(&_attr, 0, sizeof(_attr));
_attr.name = name ? name : "application_unnamed_event_flags";
_attr.cb_mem = &_obj_mem;
_attr.cb_size = sizeof(_obj_mem);
_id = osEventFlagsNew(&_attr);
osEventFlagsAttr_t attr;
attr.name = name ? name : "application_unnamed_event_flags";
attr.cb_mem = &_obj_mem;
attr.cb_size = sizeof(_obj_mem);
_id = osEventFlagsNew(&attr);
MBED_ASSERT(_id);
}

Expand Down
1 change: 0 additions & 1 deletion rtos/EventFlags.h
Expand Up @@ -90,7 +90,6 @@ class EventFlags : private mbed::NonCopyable<EventFlags> {
void constructor(const char *name = NULL);
uint32_t wait(uint32_t flags, uint32_t opt, uint32_t timeout, bool clear);
osEventFlagsId_t _id;
osEventFlagsAttr_t _attr;
mbed_rtos_storage_event_flags_t _obj_mem;
};

Expand Down
13 changes: 6 additions & 7 deletions rtos/MemoryPool.h
Expand Up @@ -50,12 +50,12 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
MemoryPool() {
memset(_pool_mem, 0, sizeof(_pool_mem));
memset(&_obj_mem, 0, sizeof(_obj_mem));
memset(&_attr, 0, sizeof(_attr));
_attr.mp_mem = _pool_mem;
_attr.mp_size = sizeof(_pool_mem);
_attr.cb_mem = &_obj_mem;
_attr.cb_size = sizeof(_obj_mem);
_id = osMemoryPoolNew(pool_sz, sizeof(T), &_attr);
osMemoryPoolAttr_t attr = { 0 };
attr.mp_mem = _pool_mem;
attr.mp_size = sizeof(_pool_mem);
attr.cb_mem = &_obj_mem;
attr.cb_size = sizeof(_obj_mem);
_id = osMemoryPoolNew(pool_sz, sizeof(T), &attr);
MBED_ASSERT(_id);
}

Expand Down Expand Up @@ -95,7 +95,6 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {

private:
osMemoryPoolId_t _id;
osMemoryPoolAttr_t _attr;
/* osMemoryPoolNew requires that pool block size is a multiple of 4 bytes. */
char _pool_mem[((sizeof(T) + 3) & ~3) * pool_sz];
mbed_rtos_storage_mem_pool_t _obj_mem;
Expand Down
12 changes: 6 additions & 6 deletions rtos/Mutex.cpp
Expand Up @@ -40,12 +40,12 @@ Mutex::Mutex(const char *name)
void Mutex::constructor(const char *name)
{
memset(&_obj_mem, 0, sizeof(_obj_mem));
memset(&_attr, 0, sizeof(_attr));
_attr.name = name ? name : "aplication_unnamed_mutex";
_attr.cb_mem = &_obj_mem;
_attr.cb_size = sizeof(_obj_mem);
_attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
_id = osMutexNew(&_attr);
osMutexAttr_t attr = { 0 };
attr.name = name ? name : "aplication_unnamed_mutex";
attr.cb_mem = &_obj_mem;
attr.cb_size = sizeof(_obj_mem);
attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
_id = osMutexNew(&attr);
MBED_ASSERT(_id);
}

Expand Down
1 change: 0 additions & 1 deletion rtos/Mutex.h
Expand Up @@ -82,7 +82,6 @@ class Mutex : private mbed::NonCopyable<Mutex> {
void constructor(const char *name = NULL);

osMutexId_t _id;
osMutexAttr_t _attr;
mbed_rtos_storage_mutex_t _obj_mem;
};

Expand Down
13 changes: 6 additions & 7 deletions rtos/Queue.h
Expand Up @@ -51,12 +51,12 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
/** Create and initialize a message Queue. */
Queue() {
memset(&_obj_mem, 0, sizeof(_obj_mem));
memset(&_attr, 0, sizeof(_attr));
_attr.mq_mem = _queue_mem;
_attr.mq_size = sizeof(_queue_mem);
_attr.cb_mem = &_obj_mem;
_attr.cb_size = sizeof(_obj_mem);
_id = osMessageQueueNew(queue_sz, sizeof(T*), &_attr);
osMessageQueueAttr_t attr = { 0 };
attr.mq_mem = _queue_mem;
attr.mq_size = sizeof(_queue_mem);
attr.cb_mem = &_obj_mem;
attr.cb_size = sizeof(_obj_mem);
_id = osMessageQueueNew(queue_sz, sizeof(T*), &attr);
MBED_ASSERT(_id);
}

Expand Down Expand Up @@ -115,7 +115,6 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {

private:
osMessageQueueId_t _id;
osMessageQueueAttr_t _attr;
char _queue_mem[queue_sz * (sizeof(T*) + sizeof(mbed_rtos_storage_message_t))];
mbed_rtos_storage_msg_queue_t _obj_mem;
};
Expand Down
8 changes: 4 additions & 4 deletions rtos/RtosTimer.cpp
Expand Up @@ -31,10 +31,10 @@ namespace rtos {
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
_function = func;
memset(&_obj_mem, 0, sizeof(_obj_mem));
memset(&_attr, 0, sizeof(_attr));
_attr.cb_mem = &_obj_mem;
_attr.cb_size = sizeof(_obj_mem);
_id = osTimerNew((void (*)(void *))Callback<void()>::thunk, type, &_function, &_attr);
osTimerAttr_t attr = { 0 };
attr.cb_mem = &_obj_mem;
attr.cb_size = sizeof(_obj_mem);
_id = osTimerNew((void (*)(void *))Callback<void()>::thunk, type, &_function, &attr);
MBED_ASSERT(_id);
}

Expand Down
1 change: 0 additions & 1 deletion rtos/RtosTimer.h
Expand Up @@ -157,7 +157,6 @@ class RtosTimer : private mbed::NonCopyable<RtosTimer> {
void constructor(mbed::Callback<void()> func, os_timer_type type);

osTimerId_t _id;
osTimerAttr_t _attr;
mbed_rtos_storage_timer_t _obj_mem;
mbed::Callback<void()> _function;
};
Expand Down
8 changes: 4 additions & 4 deletions rtos/Semaphore.cpp
Expand Up @@ -36,10 +36,10 @@ Semaphore::Semaphore(int32_t count, uint16_t max_count) {

void Semaphore::constructor(int32_t count, uint16_t max_count) {
memset(&_obj_mem, 0, sizeof(_obj_mem));
memset(&_attr, 0, sizeof(_attr));
_attr.cb_mem = &_obj_mem;
_attr.cb_size = sizeof(_obj_mem);
_id = osSemaphoreNew(max_count, count, &_attr);
osSemaphoreAttr_t attr = { 0 };
attr.cb_mem = &_obj_mem;
attr.cb_size = sizeof(_obj_mem);
_id = osSemaphoreNew(max_count, count, &attr);
MBED_ASSERT(_id != NULL);
}

Expand Down
1 change: 0 additions & 1 deletion rtos/Semaphore.h
Expand Up @@ -71,7 +71,6 @@ class Semaphore : private mbed::NonCopyable<Semaphore> {
void constructor(int32_t count, uint16_t max_count);

osSemaphoreId_t _id;
osSemaphoreAttr_t _attr;
mbed_rtos_storage_semaphore_t _obj_mem;
};

Expand Down