Skip to content

Commit

Permalink
libc: minimal: Implement exit()/_exit() functions.
Browse files Browse the repository at this point in the history
Behavior is similar to newlib version: print "exit" message and go
into infinite loop.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
  • Loading branch information
pfalcon authored and nashif committed May 23, 2019
1 parent f0ea13d commit af529d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/libc/minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ zephyr_library_sources(
source/stdlib/strtoul.c
source/stdlib/malloc.c
source/stdlib/bsearch.c
source/stdlib/exit.c
source/string/strncasecmp.c
source/string/strstr.c
source/string/string.c
Expand Down
8 changes: 8 additions & 0 deletions lib/libc/minimal/include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ void *bsearch(const void *key, const void *array,
size_t count, size_t size,
int (*cmp)(const void *key, const void *element));

#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
void _exit(int status);
static inline void exit(int status)
{
_exit(status);
}

int rand(void);

#define abs(x) ((x) < 0 ? -(x) : (x))
Expand Down
15 changes: 15 additions & 0 deletions lib/libc/minimal/source/stdlib/exit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdlib.h>
#include <zephyr.h>

void _exit(int status)
{
printk("exit\n");
while (1) {
}
}

0 comments on commit af529d1

Please sign in to comment.