libc: set up memory partitions

* Newlib now defines a special z_newlib_partition containing
  all globals relevant to newlib. Most of these are in libc.a
  with a heap tracking variable in newlib's hooks.

* Both C libraries now expose a k_mem_partition containing the
  bounds of the malloc heap arena. Threads that want to use
  libc malloc() will need to add this to their memory domain.

* z_newlib_get_heap_bounds has been removed, in favor of the
  memory partition for the heap arena

* ztest now includes the C library partitions in its memory
  domain.

* The mem_alloc test now runs in user mode to prove that this
  all works for both C libraries.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2019-02-01 12:18:31 -08:00 committed by Anas Nashif
commit 4b4f773484
9 changed files with 90 additions and 50 deletions

View file

@ -27,6 +27,13 @@ __syscall int _zephyr_read(char *buf, int nbytes);
__syscall int _zephyr_write(const void *buf, int nbytes);
#ifdef CONFIG_APP_SHARED_MEM
/* Memory partition containing newlib's globals. This includes all the globals
* within libc.a and the supporting zephyr hooks, but not the malloc arena.
*/
extern struct k_mem_partition z_newlib_partition;
#endif /* CONFIG_APP_SHARED_MEM */
#else
/* Minimal libc */
@ -34,9 +41,13 @@ __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_APP_SHARED_MEM
/* Memory partition containing the libc malloc arena */
extern struct k_mem_partition z_malloc_partition;
#endif
#include <syscalls/libc-hooks.h>
#endif /* ZEPHYR_INCLUDE_MISC_LIBC_HOOKS_H_ */