mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-28 04:23:38 +01:00
stdlib: add exit() based on target-provided _Exit()
This is implemented for gint only currently; on Vhex, _Exit() is likely just going to be a syscall. For CASIOWIN, this is slightly more difficult, as there is no native exit syscall.
This commit is contained in:
parent
73d6b2eb7c
commit
4b90740d3b
9 changed files with 68 additions and 1 deletions
|
@ -125,6 +125,7 @@ set(SOURCES
|
|||
src/libc/stdlib/atoll.c
|
||||
src/libc/stdlib/calloc.c
|
||||
src/libc/stdlib/div.c
|
||||
src/libc/stdlib/exit.c
|
||||
src/libc/stdlib/labs.c
|
||||
src/libc/stdlib/ldiv.c
|
||||
src/libc/stdlib/llabs.c
|
||||
|
|
7
STATUS
7
STATUS
|
@ -102,7 +102,12 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested
|
|||
7.20.1.4 strtol, strtoul, strtoll, strtoull: DONE
|
||||
! 7.20.2 Pseudo-random sequence generation functions: TODO
|
||||
! 7.20.3 Memory management functions: TODO (check existing code first)
|
||||
! 7.20.4 Communication with the environment: TODO
|
||||
! 7.20.4.1 abort: BDEPS(raise)
|
||||
! 7.20.4.2 atexit: TODO
|
||||
7.20.4.3 exit: DONE (missing stream flushing/closing/etc)
|
||||
7.20.4.4 _Exit: DONE (gint only)
|
||||
! 7.20.4.5 getenv: TODO
|
||||
! 7.20.4.6 system: TODO
|
||||
! 7.20.5 Searching and sorting utilities: TODO
|
||||
7.20.6.1 abs, labs, llabs: DONE
|
||||
7.20.6.2 div, ldiv, lldiv: DONE
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <bits/exit.h>
|
||||
|
||||
/* Dynamic memory management. */
|
||||
|
||||
|
@ -27,6 +28,14 @@ extern void *reallocarray(void *__ptr, size_t __nmemb, size_t __size);
|
|||
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
|
||||
extern void free(void *__ptr);
|
||||
|
||||
/* Communication with the environment. */
|
||||
|
||||
/* Exit; calls handlers, flushes and closes streams and temporary files. */
|
||||
void exit(int __status);
|
||||
|
||||
/* Exit immediately, bypassing exit handlers or signal handlers. */
|
||||
void _Exit(int __status);
|
||||
|
||||
/* Integer arithmetic functions. */
|
||||
|
||||
extern int abs(int __j);
|
||||
|
|
8
include/target/casiowin-cg/bits/exit.h
Normal file
8
include/target/casiowin-cg/bits/exit.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef __BITS_EXIT_H__
|
||||
# define __BITS_EXIT_H__
|
||||
|
||||
/* Exit codes for CASIOWIN add-ins. */
|
||||
#define EXIT_SUCCESS 1
|
||||
#define EXIT_FAILURE 0
|
||||
|
||||
#endif /*__BITS_EXIT_H__*/
|
8
include/target/casiowin-fx/bits/exit.h
Normal file
8
include/target/casiowin-fx/bits/exit.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef __BITS_EXIT_H__
|
||||
# define __BITS_EXIT_H__
|
||||
|
||||
/* Exit codes for CASIOWIN add-ins. */
|
||||
#define EXIT_SUCCESS 1
|
||||
#define EXIT_FAILURE 0
|
||||
|
||||
#endif /*__BITS_EXIT_H__*/
|
8
include/target/gint/bits/exit.h
Normal file
8
include/target/gint/bits/exit.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef __BITS_EXIT_H__
|
||||
# define __BITS_EXIT_H__
|
||||
|
||||
/* Exit codes for CASIOWIN add-ins. */
|
||||
#define EXIT_SUCCESS 1
|
||||
#define EXIT_FAILURE 0
|
||||
|
||||
#endif /*__BITS_EXIT_H__*/
|
7
include/target/vhex-generic/bits/exit.h
Normal file
7
include/target/vhex-generic/bits/exit.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef __BITS_EXIT_H__
|
||||
# define __BITS_EXIT_H__
|
||||
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
#endif /*__BITS_EXIT_H__*/
|
10
src/libc/stdlib/abort.c
Normal file
10
src/libc/stdlib/abort.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <bits/stdlib.h>
|
||||
|
||||
void abort(int rc)
|
||||
{
|
||||
/* TODO: Close BFile handles (essential) */
|
||||
|
||||
raise(SIGABRT);
|
||||
_Exit(EXIT_FAILURE);
|
||||
}
|
11
src/libc/stdlib/exit.c
Normal file
11
src/libc/stdlib/exit.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
void exit(int rc)
|
||||
{
|
||||
/* TODO: invoke atexit callbacks */
|
||||
/* TODO: exit: Flush all streams */
|
||||
/* TODO: exit: Close all streams */
|
||||
/* TODO: exit: Remove temporary files */
|
||||
|
||||
_Exit(rc);
|
||||
}
|
Loading…
Reference in a new issue