diff --git a/include/misc/libc-hooks.h b/include/misc/libc-hooks.h index 03df2798e06ffa..5009f0882a46b1 100644 --- a/include/misc/libc-hooks.h +++ b/include/misc/libc-hooks.h @@ -1,60 +1,15 @@ /* - * Copyright (c) 2018, Intel Corporation. + * Copyright (c) 2019 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ - #ifndef ZEPHYR_INCLUDE_MISC_LIBC_HOOKS_H_ #define ZEPHYR_INCLUDE_MISC_LIBC_HOOKS_H_ -#include -#include -#include - -/* - * Private header for specifying accessory functions to the C library internals - * that need to call into the kernel as system calls - */ - -#ifdef CONFIG_NEWLIB_LIBC - -/* syscall generation ignores preprocessor, ensure this is defined to ensure - * we don't have compile errors - */ -#define _MLIBC_RESTRICT - -__syscall int z_zephyr_read_stdin(char *buf, int nbytes); - -__syscall int z_zephyr_write_stdout(const void *buf, int nbytes); - -#else -/* Minimal libc */ - -__syscall int zephyr_fputc(int c, FILE * stream); - -__syscall size_t zephyr_fwrite(const void *_MLIBC_RESTRICT ptr, size_t size, - size_t nitems, FILE *_MLIBC_RESTRICT stream); -#endif /* CONFIG_NEWLIB_LIBC */ - -#ifdef CONFIG_USERSPACE -#if defined(CONFIG_NEWLIB_LIBC) || (CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE > 0) -#define Z_MALLOC_PARTITION_EXISTS 1 - -/* Memory partition containing the libc malloc arena */ -extern struct k_mem_partition z_malloc_partition; -#endif - -#if defined(CONFIG_NEWLIB_LIBC) || defined(CONFIG_STACK_CANARIES) -/* Minimal libc has no globals. We do put the stack canary global in the - * libc partition since it is not worth placing in a partition of its own. - */ -#define Z_LIBC_PARTITION_EXISTS 1 - -/* C library globals, except the malloc arena */ -extern struct k_mem_partition z_libc_partition; +#ifndef CONFIG_COMPAT_INCLUDES +#warning "This header file has moved, include instead." #endif -#endif /* CONFIG_USERSPACE */ -#include +#include #endif /* ZEPHYR_INCLUDE_MISC_LIBC_HOOKS_H_ */ diff --git a/include/sys/libc-hooks.h b/include/sys/libc-hooks.h new file mode 100644 index 00000000000000..b5b895fda7aea6 --- /dev/null +++ b/include/sys/libc-hooks.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018, Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_SYS_LIBC_HOOKS_H_ +#define ZEPHYR_INCLUDE_SYS_LIBC_HOOKS_H_ + +#include +#include +#include + +/* + * Private header for specifying accessory functions to the C library internals + * that need to call into the kernel as system calls + */ + +#ifdef CONFIG_NEWLIB_LIBC + +/* syscall generation ignores preprocessor, ensure this is defined to ensure + * we don't have compile errors + */ +#define _MLIBC_RESTRICT + +__syscall int z_zephyr_read_stdin(char *buf, int nbytes); + +__syscall int z_zephyr_write_stdout(const void *buf, int nbytes); + +#else +/* Minimal libc */ + +__syscall int zephyr_fputc(int c, FILE * stream); + +__syscall size_t zephyr_fwrite(const void *_MLIBC_RESTRICT ptr, size_t size, + size_t nitems, FILE *_MLIBC_RESTRICT stream); +#endif /* CONFIG_NEWLIB_LIBC */ + +#ifdef CONFIG_USERSPACE +#if defined(CONFIG_NEWLIB_LIBC) || (CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE > 0) +#define Z_MALLOC_PARTITION_EXISTS 1 + +/* Memory partition containing the libc malloc arena */ +extern struct k_mem_partition z_malloc_partition; +#endif + +#if defined(CONFIG_NEWLIB_LIBC) || defined(CONFIG_STACK_CANARIES) +/* Minimal libc has no globals. We do put the stack canary global in the + * libc partition since it is not worth placing in a partition of its own. + */ +#define Z_LIBC_PARTITION_EXISTS 1 + +/* C library globals, except the malloc arena */ +extern struct k_mem_partition z_libc_partition; +#endif +#endif /* CONFIG_USERSPACE */ + +#include + +#endif /* ZEPHYR_INCLUDE_SYS_LIBC_HOOKS_H_ */ diff --git a/kernel/userspace.c b/kernel/userspace.c index 0eb7400e91bb09..819db64ee0a7a3 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #ifdef Z_LIBC_PARTITION_EXISTS diff --git a/lib/libc/minimal/source/stdout/stdout_console.c b/lib/libc/minimal/source/stdout/stdout_console.c index fab6cdc3ba9711..4ca2d659f7144d 100644 --- a/lib/libc/minimal/source/stdout/stdout_console.c +++ b/lib/libc/minimal/source/stdout/stdout_console.c @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include diff --git a/lib/libc/newlib/libc-hooks.c b/lib/libc/newlib/libc-hooks.c index ef7245eea239cd..4b40c1bff1f1b8 100644 --- a/lib/libc/newlib/libc-hooks.c +++ b/lib/libc/newlib/libc-hooks.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/subsys/testsuite/ztest/src/ztest.c b/subsys/testsuite/ztest/src/ztest.c index dfa74b543dafa8..4825d9141f3bd2 100644 --- a/subsys/testsuite/ztest/src/ztest.c +++ b/subsys/testsuite/ztest/src/ztest.c @@ -8,7 +8,7 @@ #include #include #ifdef CONFIG_USERSPACE -#include +#include #endif #ifdef KERNEL