Skip to content

Commit 6477b76

Browse files
committed
Style clean-up of Thread-related files
1 parent 96af5a4 commit 6477b76

File tree

4 files changed

+170
-137
lines changed

4 files changed

+170
-137
lines changed

rtos/Kernel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
namespace rtos {
2828

29-
uint64_t Kernel::get_ms_count() {
29+
uint64_t Kernel::get_ms_count()
30+
{
3031
// CMSIS-RTOS 2.1.0 and 2.1.1 differ in the time type. We assume
3132
// our header at least matches the implementation, so we don't try looking
3233
// at the run-time version report. (There's no compile-time version report)
@@ -36,7 +37,7 @@ uint64_t Kernel::get_ms_count() {
3637
// 2.1.x who knows? We assume could go back to uint64_t
3738
if (sizeof osKernelGetTickCount() == sizeof(uint64_t)) {
3839
return osKernelGetTickCount();
39-
} else /* assume 32-bit */ {
40+
} else { /* assume 32-bit */
4041
// Based on suggestion in CMSIS-RTOS 2.1.1 docs, but with reentrancy
4142
// protection for the tick memory. We use critical section rather than a
4243
// mutex, as hopefully this method can be callable from interrupt later -

rtos/TARGET_CORTEX/mbed_rtx_handlers.c

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,43 @@
3232
extern void rtos_idle_loop(void);
3333
extern void thread_terminate_hook(osThreadId_t id);
3434

35-
__NO_RETURN void osRtxIdleThread (void *argument)
35+
__NO_RETURN void osRtxIdleThread(void *argument)
3636
{
3737
for (;;) {
38-
rtos_idle_loop();
38+
rtos_idle_loop();
3939
}
4040
}
4141

42-
__NO_RETURN uint32_t osRtxErrorNotify (uint32_t code, void *object_id)
42+
__NO_RETURN uint32_t osRtxErrorNotify(uint32_t code, void *object_id)
4343
{
4444
osThreadId_t tid = osThreadGetId();
4545

4646
switch (code) {
47-
case osRtxErrorStackUnderflow:
48-
// Stack underflow detected for thread (thread_id=object_id)
49-
// Note: "overflow" is printed instead of "underflow" due to end user familiarity with overflow errors
50-
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_STACK_OVERFLOW), "CMSIS-RTOS error: Stack overflow", code);
51-
break;
52-
case osRtxErrorISRQueueOverflow:
53-
// ISR Queue overflow detected when inserting object (object_id)
54-
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_ISR_QUEUE_OVERFLOW), "CMSIS-RTOS error: ISR Queue overflow", code);
55-
break;
56-
case osRtxErrorTimerQueueOverflow:
57-
// User Timer Callback Queue overflow detected for timer (timer_id=object_id)
58-
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_TIMER_QUEUE_OVERFLOW), "CMSIS-RTOS error: User Timer Callback Queue overflow", code);
59-
break;
60-
case osRtxErrorClibSpace:
61-
// Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
62-
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_SPACE_UNAVAILABLE), "CMSIS-RTOS error: STD C/C++ library libspace not available", code);
63-
break;
64-
case osRtxErrorClibMutex:
65-
// Standard C/C++ library mutex initialization failed
66-
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_MUTEX_INIT_FAILURE), "CMSIS-RTOS error: STD C/C++ library mutex initialization failed", code);
67-
break;
68-
default:
69-
//Unknown error flagged from kernel
70-
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_UNKNOWN), "CMSIS-RTOS error: Unknown", code);
71-
break;
47+
case osRtxErrorStackUnderflow:
48+
// Stack underflow detected for thread (thread_id=object_id)
49+
// Note: "overflow" is printed instead of "underflow" due to end user familiarity with overflow errors
50+
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_STACK_OVERFLOW), "CMSIS-RTOS error: Stack overflow", code);
51+
break;
52+
case osRtxErrorISRQueueOverflow:
53+
// ISR Queue overflow detected when inserting object (object_id)
54+
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_ISR_QUEUE_OVERFLOW), "CMSIS-RTOS error: ISR Queue overflow", code);
55+
break;
56+
case osRtxErrorTimerQueueOverflow:
57+
// User Timer Callback Queue overflow detected for timer (timer_id=object_id)
58+
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_TIMER_QUEUE_OVERFLOW), "CMSIS-RTOS error: User Timer Callback Queue overflow", code);
59+
break;
60+
case osRtxErrorClibSpace:
61+
// Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
62+
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_SPACE_UNAVAILABLE), "CMSIS-RTOS error: STD C/C++ library libspace not available", code);
63+
break;
64+
case osRtxErrorClibMutex:
65+
// Standard C/C++ library mutex initialization failed
66+
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_MUTEX_INIT_FAILURE), "CMSIS-RTOS error: STD C/C++ library mutex initialization failed", code);
67+
break;
68+
default:
69+
//Unknown error flagged from kernel
70+
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_UNKNOWN), "CMSIS-RTOS error: Unknown", code);
71+
break;
7272
}
7373

7474
/* That shouldn't be reached */
@@ -77,52 +77,52 @@ __NO_RETURN uint32_t osRtxErrorNotify (uint32_t code, void *object_id)
7777

7878
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
7979

80-
static const char* error_msg(int32_t status)
80+
static const char *error_msg(int32_t status)
8181
{
8282
switch (status) {
83-
case osError:
84-
return "Unspecified RTOS error";
85-
case osErrorTimeout:
86-
return "Operation not completed within the timeout period";
87-
case osErrorResource:
88-
return "Resource not available";
89-
case osErrorParameter:
90-
return "Parameter error";
91-
case osErrorNoMemory:
92-
return "System is out of memory";
93-
case osErrorISR:
94-
return "Not allowed in ISR context";
95-
default:
96-
return "Unknown";
83+
case osError:
84+
return "Unspecified RTOS error";
85+
case osErrorTimeout:
86+
return "Operation not completed within the timeout period";
87+
case osErrorResource:
88+
return "Resource not available";
89+
case osErrorParameter:
90+
return "Parameter error";
91+
case osErrorNoMemory:
92+
return "System is out of memory";
93+
case osErrorISR:
94+
return "Not allowed in ISR context";
95+
default:
96+
return "Unknown";
9797
}
9898
}
9999

100-
void EvrRtxKernelError (int32_t status)
100+
void EvrRtxKernelError(int32_t status)
101101
{
102102
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_EVENT), error_msg(status), status);
103103
}
104104

105-
void EvrRtxThreadError (osThreadId_t thread_id, int32_t status)
105+
void EvrRtxThreadError(osThreadId_t thread_id, int32_t status)
106106
{
107107
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_THREAD_EVENT), error_msg(status), thread_id);
108108
}
109109

110-
void EvrRtxTimerError (osTimerId_t timer_id, int32_t status)
110+
void EvrRtxTimerError(osTimerId_t timer_id, int32_t status)
111111
{
112112
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_TIMER_EVENT), error_msg(status), timer_id);
113113
}
114114

115-
void EvrRtxEventFlagsError (osEventFlagsId_t ef_id, int32_t status)
115+
void EvrRtxEventFlagsError(osEventFlagsId_t ef_id, int32_t status)
116116
{
117117
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_EVENT_FLAGS_EVENT), error_msg(status), ef_id);
118118
}
119119

120-
void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status)
120+
void EvrRtxMutexError(osMutexId_t mutex_id, int32_t status)
121121
{
122122
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MUTEX_EVENT), error_msg(status), mutex_id);
123123
}
124124

125-
void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
125+
void EvrRtxSemaphoreError(osSemaphoreId_t semaphore_id, int32_t status)
126126
{
127127
// Ignore semaphore overflow, the count will saturate with a returned error
128128
if (status == osRtxErrorSemaphoreCountLimit) {
@@ -132,20 +132,20 @@ void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
132132
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_SEMAPHORE_EVENT), error_msg(status), semaphore_id);
133133
}
134134

135-
void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id, int32_t status)
135+
void EvrRtxMemoryPoolError(osMemoryPoolId_t mp_id, int32_t status)
136136
{
137137
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MEMORY_POOL_EVENT), error_msg(status), mp_id);
138138
}
139139

140-
void EvrRtxMessageQueueError (osMessageQueueId_t mq_id, int32_t status)
140+
void EvrRtxMessageQueueError(osMessageQueueId_t mq_id, int32_t status)
141141
{
142142
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MESSAGE_QUEUE_EVENT), error_msg(status), mq_id);
143143
}
144144

145145
#endif
146146

147147
// RTX hook which gets called when a thread terminates, using the event function to call hook
148-
void EvrRtxThreadExit (void)
148+
void EvrRtxThreadExit(void)
149149
{
150150
osThreadId_t thread_id = osThreadGetId();
151151
thread_terminate_hook(thread_id);
@@ -154,7 +154,7 @@ void EvrRtxThreadExit (void)
154154
#endif
155155
}
156156

157-
void EvrRtxThreadTerminate (osThreadId_t thread_id)
157+
void EvrRtxThreadTerminate(osThreadId_t thread_id)
158158
{
159159
thread_terminate_hook(thread_id);
160160
#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_TERMINATE_DISABLE) && defined(RTE_Compiler_EventRecorder))

0 commit comments

Comments
 (0)