µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
exit.c File Reference
#include <cmsis-plus/rtos/os-hooks.h>
#include <cmsis-plus/diag/trace.h>
#include <cmsis_device.h>
#include <stdlib.h>
#include <stdbool.h>
#include "atexit.h"

Go to the source code of this file.

Functions

void _Exit (int code)
 
void _exit (int status)
 
void abort (void)
 
void exit (int code)
 
void os_exit (int code)
 
void os_goodbye (void)
 

Function Documentation

◆ _Exit()

void _Exit ( int  code)

Definition at line 112 of file exit.c.

113{
114 trace_printf ("%s()\n", __func__);
115
116 // Print some statistics about memory use.
118
119 // Gracefully terminate the trace session.
120 trace_flush ();
121
122// By default disable it, since it prevents standalone tests
123// to terminate properly.
124#if defined(DEBUG) && defined(OS_ENABLE_BKPT_ON_EXIT)
125
126#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
127 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
128 {
129 // Break only if the debugger is connected.
130 __BKPT (0);
131 }
132#endif /* defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) */
133
134#endif /* defined(DEBUG) */
135
136 // Reset hardware or terminate the semihosting session.
137 os_terminate (code);
138
139 while (true)
140 {
141 __NOP ();
142 }
143 /* NOTREACHED */
144}
void os_terminate(int code)
Terminate the application. There is no more life after this.
void os_terminate_goodbye(void)
Display statistics and say goodbye before terminating.
Definition os-main.cpp:194
void trace_flush(void)
Definition trace.cpp:177
int trace_printf(const char *format,...)

References os_terminate(), os_terminate_goodbye(), trace_flush(), and trace_printf().

Referenced by abort(), and exit().

◆ _exit()

void _exit ( int  status)

◆ abort()

void abort ( void  )

Definition at line 43 of file exit.c.

44{
45 trace_puts ("abort(), exiting...");
46
47 _Exit (1);
48 /* NOTREACHED */
49}
void _Exit(int code)
Definition exit.c:112
int trace_puts(const char *s)

References _Exit(), and trace_puts().

Referenced by __assert_func(), __cxa_pure_virtual(), and __gnu_cxx::__verbose_terminate_handler().

◆ exit()

void exit ( int  code)
Parameters
codeExit code.

exit() does several cleanups before ending the application:

  • calls all application-defined cleanup functions enrolled with atexit();
  • files and streams are cleaned up: any pending output is delivered to the host system, each open file or stream is closed, and files created by tmpfile() are deleted (wishful thinking, not implemented);
  • call the static destructors (in reverse order of constructors)

When all cleanups are done, _Exit() is called to perform the actual termination.

Definition at line 70 of file exit.c.

71{
72 trace_printf ("%s(%d)\n", __func__, code);
73
74 // Call the cleanup functions enrolled with atexit().
75 __call_exitprocs (code, NULL);
76
77 // Run the C++ static destructors.
79
80 // This should normally be the end of it.
81 _Exit (code);
82
83 // Reset again, in case _Exit() did not kill it.
84 // This normally should not happen, but since it can be
85 // overloaded by the application, better safe than sorry.
86 os_terminate (code);
87
88 // If it does not want o die, loop.
89 while (true)
90 {
91 __NOP ();
92 }
93 /* NOTREACHED */
94}
void __call_exitprocs(int, void *)
void os_run_fini_array(void)
Definition startup.cpp:187

References __call_exitprocs(), _Exit(), os_run_fini_array(), os_terminate(), and trace_printf().

Referenced by _start().

◆ os_exit()

void os_exit ( int  code)

◆ os_goodbye()

void os_goodbye ( void  )