Skip to content

Commit

Permalink
libc: Define Z_LIBC_DATA macro globally
Browse files Browse the repository at this point in the history
This commit globally defines the `Z_LIBC_DATA` macro, which is used to
place variables into the libc memory partition, so that it can be
re-used.

Signed-off-by: Stephanos Ioannidis <[email protected]>
  • Loading branch information
stephanosio authored and carlescufi committed Jun 1, 2022
1 parent 4735e10 commit 2bcb713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/zephyr/sys/libc-hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define ZEPHYR_INCLUDE_SYS_LIBC_HOOKS_H_

#include <zephyr/toolchain.h>
#include <zephyr/app_memory/app_memdomain.h>
#include <stdio.h>
#include <stddef.h>

Expand Down Expand Up @@ -85,4 +86,7 @@ extern struct k_mem_partition z_libc_partition;

#include <syscalls/libc-hooks.h>

/* C library memory partitions */
#define Z_LIBC_DATA K_APP_DMEM(z_libc_partition)

#endif /* ZEPHYR_INCLUDE_SYS_LIBC_HOOKS_H_ */
5 changes: 1 addition & 4 deletions lib/libc/minimal/source/stdlib/rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

#include <stdlib.h>
#include <zephyr/sys/libc-hooks.h>
#include <zephyr/app_memory/app_memdomain.h>

#define LIBC_DATA K_APP_DMEM(z_libc_partition)

#define OUTPUT_BITS (0x7fffffffU)
#define MULTIPLIER (1103515245U)
Expand All @@ -22,7 +19,7 @@ int rand_r(unsigned int *seed)
}

#ifdef CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS
static LIBC_DATA unsigned int srand_seed = 1;
static Z_LIBC_DATA unsigned int srand_seed = 1;

void srand(unsigned int s)
{
Expand Down

0 comments on commit 2bcb713

Please sign in to comment.