Skip to content

Commit 90a731d

Browse files
committed
rtos_idle_loop is MBED_NORETURN
Don't need loops at two layers. Also tighten up slightly-invalid extern "C" markings.
1 parent ea16a6b commit 90a731d

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

rtos/TARGET_CORTEX/mbed_rtx_handlers.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "mbed_interface.h"
2323
#include "RTX_Config.h"
2424
#include "rtos/rtos_handlers.h"
25+
#include "rtos/rtos_idle.h"
2526

2627
#ifdef RTE_Compiler_EventRecorder
2728
#include "EventRecorder.h" // Keil::Compiler:Event Recorder
@@ -30,8 +31,6 @@
3031
#define EvtRtxThreadTerminate EventID(EventLevelAPI, 0xF2U, 0x1AU)
3132
#endif
3233

33-
extern void rtos_idle_loop(void);
34-
3534
static void (*terminate_hook)(osThreadId_t id);
3635

3736
static void thread_terminate_hook(osThreadId_t id)
@@ -48,9 +47,7 @@ void rtos_attach_thread_terminate_hook(void (*fptr)(osThreadId_t id))
4847

4948
__NO_RETURN void osRtxIdleThread(void *argument)
5049
{
51-
for (;;) {
52-
rtos_idle_loop();
53-
}
50+
rtos_idle_loop();
5451
}
5552

5653
__NO_RETURN uint32_t osRtxErrorNotify(uint32_t code, void *object_id)

rtos/TARGET_CORTEX/mbed_rtx_idle.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
#include "mbed_assert.h"
2929
#include <new>
3030
#include "rtx_os.h"
31+
32+
/* Everything in rtx_lib.h, and provided by this file, has C linkage */
3133
extern "C" {
3234
#include "rtx_lib.h"
33-
}
3435

3536
using namespace mbed;
3637

@@ -136,10 +137,12 @@ void rtos_attach_idle_hook(void (*fptr)(void))
136137
}
137138
}
138139

139-
extern "C" void rtos_idle_loop(void)
140+
MBED_NORETURN void rtos_idle_loop(void)
140141
{
141142
//Continuously call the idle hook function pointer
142143
while (1) {
143144
idle_hook_fptr();
144145
}
145146
}
147+
148+
} // extern "C"

rtos/rtos_idle.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifndef RTOS_IDLE_H
2626
#define RTOS_IDLE_H
2727

28+
#include "mbed_toolchain.h"
2829
#include <stddef.h>
2930

3031
#ifdef __cplusplus
@@ -41,6 +42,10 @@ extern "C" {
4142
@param fptr Hook function pointer.
4243
*/
4344
void rtos_attach_idle_hook(void (*fptr)(void));
45+
46+
/** @private */
47+
MBED_NORETURN void rtos_idle_loop(void);
48+
4449
/** @}*/
4550

4651
#ifdef __cplusplus

0 commit comments

Comments
 (0)