Skip to content
Permalink
Browse files

libc: minimal: Implement exit()/_exit() functions.

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 af529d1158c9c85f41a5c15fabf1b3a83bfd9ac2
Showing with 24 additions and 0 deletions.
  1. +1 −0 lib/libc/minimal/CMakeLists.txt
  2. +8 −0 lib/libc/minimal/include/stdlib.h
  3. +15 −0 lib/libc/minimal/source/stdlib/exit.c
@@ -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
@@ -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))
@@ -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.
You can’t perform that action at this time.