[PATCH] Add stub for getentropy

Torbjörn SVENSSON <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Example test case that fails with undefined reference to getentropy:

Testing g++.robertl/eb77.C,  -std=c++20
doing compile
Executing on host: /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++  /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C  -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output   -fmessage-length=0  -std=c++20 -pedantic-errors -Wno-long-long        -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat   -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe    (timeout = 800)
spawn -ignore SIGHUP /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe
pid is 28414 -28414
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
pid is -1
close result is 28414 exp6 0 1
output is /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
 status 1
compiler exited with status 1
FAIL: g++.old-deja/g++.robertl/eb77.C  -std=c++20 (test for excess errors)
Excess errors:
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
(.text._rs_stir+0x8): undefined reference to `getentropy'
UNRESOLVED: g++.old-deja/g++.robertl/eb77.C  -std=c++20 compilation failed to produce executable

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
 libgloss/Makefile.in                 |   5 +
 libgloss/libnosys/Makefile.inc       |   1 +
 libgloss/libnosys/getentropy.c       |  22 ++++
 newlib/Makefile.in                   | 147 +++++++++++++++++----------
 newlib/libc/include/_syslist.h       |   1 +
 newlib/libc/include/reent.h          |   2 +
 newlib/libc/reent/Makefile.inc       |   2 +
 newlib/libc/reent/getentropyr.c      |  53 ++++++++++
 newlib/libc/syscalls/Makefile.inc    |   1 +
 newlib/libc/syscalls/sysgetentropy.c |  12 +++
 10 files changed, 192 insertions(+), 54 deletions(-)
 create mode 100644 libgloss/libnosys/getentropy.c
 create mode 100644 newlib/libc/reent/getentropyr.c
 create mode 100644 newlib/libc/syscalls/sysgetentropy.c

diff --git a/libgloss/Makefile.in b/libgloss/Makefile.in
index 187d0edb0..7f46375c0 100644
--- a/libgloss/Makefile.in
+++ b/libgloss/Makefile.in
@@ -409,6 +409,7 @@ libnosys_libnosys_a_LIBADD =
 @CONFIG_LIBNOSYS_TRUE@	libnosys/unlink.$(OBJEXT) \
 @CONFIG_LIBNOSYS_TRUE@	libnosys/wait.$(OBJEXT) \
 @CONFIG_LIBNOSYS_TRUE@	libnosys/write.$(OBJEXT) \
+@CONFIG_LIBNOSYS_TRUE@	libnosys/getentropy.$(OBJEXT) \
 @CONFIG_LIBNOSYS_TRUE@	libnosys/_exit.$(OBJEXT)
 libnosys_libnosys_a_OBJECTS = $(am_libnosys_libnosys_a_OBJECTS)
 libobjs_a_AR = $(AR) $(ARFLAGS)
@@ -991,6 +992,7 @@ TEXINFO_TEX = ../texinfo/texinfo.tex
 @CONFIG_LIBNOSYS_TRUE@	libnosys/unlink.c \
 @CONFIG_LIBNOSYS_TRUE@	libnosys/wait.c \
 @CONFIG_LIBNOSYS_TRUE@	libnosys/write.c \
+@CONFIG_LIBNOSYS_TRUE@	libnosys/getentropy.c \
 @CONFIG_LIBNOSYS_TRUE@	libnosys/_exit.c
 
 @CONFIG_LM32_TRUE@lm32_libgloss_a_SOURCES = \
@@ -1558,6 +1560,8 @@ libnosys/wait.$(OBJEXT): libnosys/$(am__dirstamp) \
 	libnosys/$(DEPDIR)/$(am__dirstamp)
 libnosys/write.$(OBJEXT): libnosys/$(am__dirstamp) \
 	libnosys/$(DEPDIR)/$(am__dirstamp)
+libnosys/getentropy.$(OBJEXT): libnosys/$(am__dirstamp) \
+	libnosys/$(DEPDIR)/$(am__dirstamp)
 libnosys/_exit.$(OBJEXT): libnosys/$(am__dirstamp) \
 	libnosys/$(DEPDIR)/$(am__dirstamp)
 
@@ -1958,6 +1962,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/execve.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/fork.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/fstat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/getentropy.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/getpid.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/gettod.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/isatty.Po@am__quote@
diff --git a/libgloss/libnosys/Makefile.inc b/libgloss/libnosys/Makefile.inc
index 5e69072e7..334f694af 100644
--- a/libgloss/libnosys/Makefile.inc
+++ b/libgloss/libnosys/Makefile.inc
@@ -24,4 +24,5 @@ multilibtool_LIBRARIES += %D%/libnosys.a
 	%D%/unlink.c \
 	%D%/wait.c \
 	%D%/write.c \
+	%D%/getentropy.c \
 	%D%/_exit.c
diff --git a/libgloss/libnosys/getentropy.c b/libgloss/libnosys/getentropy.c
new file mode 100644
index 000000000..f8a071248
--- /dev/null
+++ b/libgloss/libnosys/getentropy.c
@@ -0,0 +1,22 @@
+/*
+ * Stub version of getentropy.
+ */
+
+#include "config.h"
+#include <_ansi.h>
+#include <_syslist.h>
+#include <errno.h>
+#undef errno
+extern int errno;
+#include "warning.h"
+
+int
+_getentropy (void *buf,
+        size_t buflen)
+{
+  errno = ENOSYS;
+  return -1;
+}
+
+stub_warning(_getentropy)
+
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index 4d2b5e782..6e5b0fbd6 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -391,6 +391,7 @@ check_PROGRAMS =
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/sysclose.c \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/sysfcntl.c \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/sysfstat.c \
+@HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/sysgetentropy.c \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/sysgetpid.c \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/sysgettod.c \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/sysisatty.c \
@@ -1438,6 +1439,7 @@ am__objects_28 = libc/reent/libc_a-execr.$(OBJEXT)
 @HAVE_SYSCALL_DIR_TRUE@am__objects_44 = libc/syscalls/libc_a-sysclose.$(OBJEXT) \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/libc_a-sysfcntl.$(OBJEXT) \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/libc_a-sysfstat.$(OBJEXT) \
+@HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/libc_a-sysgetentropy.$(OBJEXT) \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/libc_a-sysgetpid.$(OBJEXT) \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/libc_a-sysgettod.$(OBJEXT) \
 @HAVE_SYSCALL_DIR_TRUE@	libc/syscalls/libc_a-sysisatty.$(OBJEXT) \
@@ -2521,6 +2523,7 @@ am_libc_a_OBJECTS = $(am__objects_1) \
 	libc/reent/libc_a-impure.$(OBJEXT) \
 	libc/reent/libc_a-fcntlr.$(OBJEXT) \
 	libc/reent/libc_a-fstatr.$(OBJEXT) \
+	libc/reent/libc_a-getentropyr.$(OBJEXT) \
 	libc/reent/libc_a-getreent.$(OBJEXT) \
 	libc/reent/libc_a-gettimeofdayr.$(OBJEXT) \
 	libc/reent/libc_a-isattyr.$(OBJEXT) \
@@ -4092,50 +4095,50 @@ libc_a_SOURCES = $(am__append_5) libc/stdlib/__adjust.c \
 	libc/locale/setlocale.h libc/locale/locale.c \
 	libc/locale/localeconv.c $(am__append_19) libc/reent/closer.c \
 	libc/reent/reent.c libc/reent/impure.c libc/reent/fcntlr.c \
-	libc/reent/fstatr.c libc/reent/getreent.c \
-	libc/reent/gettimeofdayr.c libc/reent/isattyr.c \
-	libc/reent/linkr.c libc/reent/lseekr.c libc/reent/mkdirr.c \
-	libc/reent/openr.c libc/reent/readr.c libc/reent/renamer.c \
-	libc/reent/signalr.c libc/reent/sbrkr.c libc/reent/statr.c \
-	libc/reent/timesr.c libc/reent/unlinkr.c libc/reent/writer.c \
-	$(am__append_21) $(am__append_22) $(am__append_23) \
-	libc/errno/errno.c libc/misc/__dprintf.c libc/misc/unctrl.c \
-	libc/misc/ffs.c libc/misc/init.c libc/misc/fini.c \
-	$(am__append_24) $(am__append_25) $(am__append_26) \
-	$(am__append_27) $(am__append_28) $(am__append_29) \
-	$(am__append_30) $(am__append_31) $(am__append_32) \
-	$(am__append_33) $(am__append_34) $(am__append_35) \
-	$(am__append_36) $(am__append_38) $(am__append_41) \
-	$(am__append_42) $(am__append_43) $(am__append_44) \
-	$(am__append_45) $(am__append_46) $(am__append_47) \
-	$(am__append_48) $(am__append_49) $(am__append_50) \
-	$(am__append_51) $(am__append_52) $(am__append_53) \
-	$(am__append_54) $(am__append_55) $(am__append_56) \
-	$(am__append_57) $(am__append_58) $(am__append_59) \
-	$(am__append_60) $(am__append_61) $(am__append_62) \
-	$(am__append_63) $(am__append_64) $(am__append_65) \
-	$(am__append_66) $(am__append_67) $(am__append_68) \
-	$(am__append_69) $(am__append_70) $(am__append_71) \
-	$(am__append_73) $(am__append_74) $(am__append_75) \
-	$(am__append_76) $(am__append_77) $(am__append_78) \
-	$(am__append_79) $(am__append_80) $(am__append_81) \
-	$(am__append_82) $(am__append_83) $(am__append_84) \
-	$(am__append_85) $(am__append_86) $(am__append_87) \
-	$(am__append_88) $(am__append_89) $(am__append_90) \
-	$(am__append_91) $(am__append_92) $(am__append_93) \
-	$(am__append_94) $(am__append_95) $(am__append_96) \
-	$(am__append_97) $(am__append_98) $(am__append_99) \
-	$(am__append_100) $(am__append_101) $(am__append_102) \
-	$(am__append_103) $(am__append_104) $(am__append_105) \
-	$(am__append_106) $(am__append_107) $(am__append_108) \
-	$(am__append_109) $(am__append_110) $(am__append_111) \
-	$(am__append_112) $(am__append_113) $(am__append_114) \
-	$(am__append_115) $(am__append_116) $(am__append_117) \
-	$(am__append_118) $(am__append_119) $(am__append_120) \
-	$(am__append_121) $(am__append_122) $(am__append_123) \
-	$(am__append_124) $(am__append_125) $(am__append_126) \
-	$(am__append_127) $(am__append_128) $(am__append_129) \
-	$(am__append_130)
+	libc/reent/fstatr.c libc/reent/getentropyr.c \
+	libc/reent/getreent.c libc/reent/gettimeofdayr.c \
+	libc/reent/isattyr.c libc/reent/linkr.c libc/reent/lseekr.c \
+	libc/reent/mkdirr.c libc/reent/openr.c libc/reent/readr.c \
+	libc/reent/renamer.c libc/reent/signalr.c libc/reent/sbrkr.c \
+	libc/reent/statr.c libc/reent/timesr.c libc/reent/unlinkr.c \
+	libc/reent/writer.c $(am__append_21) $(am__append_22) \
+	$(am__append_23) libc/errno/errno.c libc/misc/__dprintf.c \
+	libc/misc/unctrl.c libc/misc/ffs.c libc/misc/init.c \
+	libc/misc/fini.c $(am__append_24) $(am__append_25) \
+	$(am__append_26) $(am__append_27) $(am__append_28) \
+	$(am__append_29) $(am__append_30) $(am__append_31) \
+	$(am__append_32) $(am__append_33) $(am__append_34) \
+	$(am__append_35) $(am__append_36) $(am__append_38) \
+	$(am__append_41) $(am__append_42) $(am__append_43) \
+	$(am__append_44) $(am__append_45) $(am__append_46) \
+	$(am__append_47) $(am__append_48) $(am__append_49) \
+	$(am__append_50) $(am__append_51) $(am__append_52) \
+	$(am__append_53) $(am__append_54) $(am__append_55) \
+	$(am__append_56) $(am__append_57) $(am__append_58) \
+	$(am__append_59) $(am__append_60) $(am__append_61) \
+	$(am__append_62) $(am__append_63) $(am__append_64) \
+	$(am__append_65) $(am__append_66) $(am__append_67) \
+	$(am__append_68) $(am__append_69) $(am__append_70) \
+	$(am__append_71) $(am__append_73) $(am__append_74) \
+	$(am__append_75) $(am__append_76) $(am__append_77) \
+	$(am__append_78) $(am__append_79) $(am__append_80) \
+	$(am__append_81) $(am__append_82) $(am__append_83) \
+	$(am__append_84) $(am__append_85) $(am__append_86) \
+	$(am__append_87) $(am__append_88) $(am__append_89) \
+	$(am__append_90) $(am__append_91) $(am__append_92) \
+	$(am__append_93) $(am__append_94) $(am__append_95) \
+	$(am__append_96) $(am__append_97) $(am__append_98) \
+	$(am__append_99) $(am__append_100) $(am__append_101) \
+	$(am__append_102) $(am__append_103) $(am__append_104) \
+	$(am__append_105) $(am__append_106) $(am__append_107) \
+	$(am__append_108) $(am__append_109) $(am__append_110) \
+	$(am__append_111) $(am__append_112) $(am__append_113) \
+	$(am__append_114) $(am__append_115) $(am__append_116) \
+	$(am__append_117) $(am__append_118) $(am__append_119) \
+	$(am__append_120) $(am__append_121) $(am__append_122) \
+	$(am__append_123) $(am__append_124) $(am__append_125) \
+	$(am__append_126) $(am__append_127) $(am__append_128) \
+	$(am__append_129) $(am__append_130)
 libc_a_CFLAGS = $(AM_CFLAGS) $(libc_a_CFLAGS_$(subst /,_,$(@D))) $(libc_a_CFLAGS_$(subst /,_,$(@D)_$(<F)))
 libc_a_CCASFLAGS = $(AM_CCASFLAGS) $(libc_a_CCASFLAGS_$(subst /,_,$(@D))) $(libc_a_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
 libc_a_CPPFLAGS = $(AM_CPPFLAGS) $(libc_a_CPPFLAGS_$(subst /,_,$(@D))) $(libc_a_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
@@ -4325,16 +4328,17 @@ LIBC_CHEWOUT_FILES = libc/stdlib/_Exit.def libc/stdlib/a64l.def \
 	libc/locale/newlocale.def libc/locale/uselocale.def \
 	libc/reent/closer.def libc/reent/reent.def \
 	libc/reent/execr.def libc/reent/fcntlr.def \
-	libc/reent/fstatr.def libc/reent/gettimeofdayr.def \
-	libc/reent/linkr.def libc/reent/lseekr.def \
-	libc/reent/mkdirr.def libc/reent/openr.def \
-	libc/reent/readr.def libc/reent/renamer.def \
-	libc/reent/signalr.def libc/reent/sbrkr.def \
-	libc/reent/statr.def libc/reent/timesr.def \
-	libc/reent/unlinkr.def libc/reent/fstat64r.def \
-	libc/reent/lseek64r.def libc/reent/stat64r.def \
-	libc/reent/open64r.def libc/reent/writer.def libc/misc/ffs.def \
-	libc/misc/lock.def libc/misc/unctrl.def libc/posix/popen.def \
+	libc/reent/fstatr.def libc/reent/getentropyr.def \
+	libc/reent/gettimeofdayr.def libc/reent/linkr.def \
+	libc/reent/lseekr.def libc/reent/mkdirr.def \
+	libc/reent/openr.def libc/reent/readr.def \
+	libc/reent/renamer.def libc/reent/signalr.def \
+	libc/reent/sbrkr.def libc/reent/statr.def \
+	libc/reent/timesr.def libc/reent/unlinkr.def \
+	libc/reent/fstat64r.def libc/reent/lseek64r.def \
+	libc/reent/stat64r.def libc/reent/open64r.def \
+	libc/reent/writer.def libc/misc/ffs.def libc/misc/lock.def \
+	libc/misc/unctrl.def libc/posix/popen.def \
 	libc/posix/posix_spawn.def libc/iconv/lib/iconv.def
 LIBC_CHAPTERS = libc/sys.tex libc/stdlib/stdlib.tex \
 	libc/ctype/ctype.tex libc/stdio/stdio.tex \
@@ -6519,6 +6523,8 @@ libc/reent/libc_a-fcntlr.$(OBJEXT): libc/reent/$(am__dirstamp) \
 	libc/reent/$(DEPDIR)/$(am__dirstamp)
 libc/reent/libc_a-fstatr.$(OBJEXT): libc/reent/$(am__dirstamp) \
 	libc/reent/$(DEPDIR)/$(am__dirstamp)
+libc/reent/libc_a-getentropyr.$(OBJEXT): libc/reent/$(am__dirstamp) \
+	libc/reent/$(DEPDIR)/$(am__dirstamp)
 libc/reent/libc_a-getreent.$(OBJEXT): libc/reent/$(am__dirstamp) \
 	libc/reent/$(DEPDIR)/$(am__dirstamp)
 libc/reent/libc_a-gettimeofdayr.$(OBJEXT): libc/reent/$(am__dirstamp) \
@@ -6704,6 +6710,9 @@ libc/syscalls/libc_a-sysfcntl.$(OBJEXT):  \
 libc/syscalls/libc_a-sysfstat.$(OBJEXT):  \
 	libc/syscalls/$(am__dirstamp) \
 	libc/syscalls/$(DEPDIR)/$(am__dirstamp)
+libc/syscalls/libc_a-sysgetentropy.$(OBJEXT):  \
+	libc/syscalls/$(am__dirstamp) \
+	libc/syscalls/$(DEPDIR)/$(am__dirstamp)
 libc/syscalls/libc_a-sysgetpid.$(OBJEXT):  \
 	libc/syscalls/$(am__dirstamp) \
 	libc/syscalls/$(DEPDIR)/$(am__dirstamp)
@@ -13085,6 +13094,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libc/reent/$(DEPDIR)/libc_a-fcntlr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/reent/$(DEPDIR)/libc_a-fstat64r.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/reent/$(DEPDIR)/libc_a-fstatr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libc/reent/$(DEPDIR)/libc_a-getentropyr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/reent/$(DEPDIR)/libc_a-getreent.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/reent/$(DEPDIR)/libc_a-gettimeofdayr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/reent/$(DEPDIR)/libc_a-impure.Po@am__quote@
@@ -13845,6 +13855,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libc/syscalls/$(DEPDIR)/libc_a-sysfcntl.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/syscalls/$(DEPDIR)/libc_a-sysfork.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/syscalls/$(DEPDIR)/libc_a-sysfstat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libc/syscalls/$(DEPDIR)/libc_a-sysgetentropy.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/syscalls/$(DEPDIR)/libc_a-sysgetpid.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/syscalls/$(DEPDIR)/libc_a-sysgettod.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/syscalls/$(DEPDIR)/libc_a-sysisatty.Po@am__quote@
@@ -27763,6 +27774,20 @@ libc/reent/libc_a-fstatr.obj: libc/reent/fstatr.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/reent/libc_a-fstatr.obj `if test -f 'libc/reent/fstatr.c'; then $(CYGPATH_W) 'libc/reent/fstatr.c'; else $(CYGPATH_W) '$(srcdir)/libc/reent/fstatr.c'; fi`
 
+libc/reent/libc_a-getentropyr.o: libc/reent/getentropyr.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/reent/libc_a-getentropyr.o -MD -MP -MF libc/reent/$(DEPDIR)/libc_a-getentropyr.Tpo -c -o libc/reent/libc_a-getentropyr.o `test -f 'libc/reent/getentropyr.c' || echo '$(srcdir)/'`libc/reent/getentropyr.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/reent/$(DEPDIR)/libc_a-getentropyr.Tpo libc/reent/$(DEPDIR)/libc_a-getentropyr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/reent/getentropyr.c' object='libc/reent/libc_a-getentropyr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/reent/libc_a-getentropyr.o `test -f 'libc/reent/getentropyr.c' || echo '$(srcdir)/'`libc/reent/getentropyr.c
+
+libc/reent/libc_a-getentropyr.obj: libc/reent/getentropyr.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/reent/libc_a-getentropyr.obj -MD -MP -MF libc/reent/$(DEPDIR)/libc_a-getentropyr.Tpo -c -o libc/reent/libc_a-getentropyr.obj `if test -f 'libc/reent/getentropyr.c'; then $(CYGPATH_W) 'libc/reent/getentropyr.c'; else $(CYGPATH_W) '$(srcdir)/libc/reent/getentropyr.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/reent/$(DEPDIR)/libc_a-getentropyr.Tpo libc/reent/$(DEPDIR)/libc_a-getentropyr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/reent/getentropyr.c' object='libc/reent/libc_a-getentropyr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/reent/libc_a-getentropyr.obj `if test -f 'libc/reent/getentropyr.c'; then $(CYGPATH_W) 'libc/reent/getentropyr.c'; else $(CYGPATH_W) '$(srcdir)/libc/reent/getentropyr.c'; fi`
+
 libc/reent/libc_a-getreent.o: libc/reent/getreent.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/reent/libc_a-getreent.o -MD -MP -MF libc/reent/$(DEPDIR)/libc_a-getreent.Tpo -c -o libc/reent/libc_a-getreent.o `test -f 'libc/reent/getreent.c' || echo '$(srcdir)/'`libc/reent/getreent.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/reent/$(DEPDIR)/libc_a-getreent.Tpo libc/reent/$(DEPDIR)/libc_a-getreent.Po
@@ -28827,6 +28852,20 @@ libc/syscalls/libc_a-sysfstat.obj: libc/syscalls/sysfstat.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/syscalls/libc_a-sysfstat.obj `if test -f 'libc/syscalls/sysfstat.c'; then $(CYGPATH_W) 'libc/syscalls/sysfstat.c'; else $(CYGPATH_W) '$(srcdir)/libc/syscalls/sysfstat.c'; fi`
 
+libc/syscalls/libc_a-sysgetentropy.o: libc/syscalls/sysgetentropy.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/syscalls/libc_a-sysgetentropy.o -MD -MP -MF libc/syscalls/$(DEPDIR)/libc_a-sysgetentropy.Tpo -c -o libc/syscalls/libc_a-sysgetentropy.o `test -f 'libc/syscalls/sysgetentropy.c' || echo '$(srcdir)/'`libc/syscalls/sysgetentropy.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/syscalls/$(DEPDIR)/libc_a-sysgetentropy.Tpo libc/syscalls/$(DEPDIR)/libc_a-sysgetentropy.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/syscalls/sysgetentropy.c' object='libc/syscalls/libc_a-sysgetentropy.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/syscalls/libc_a-sysgetentropy.o `test -f 'libc/syscalls/sysgetentropy.c' || echo '$(srcdir)/'`libc/syscalls/sysgetentropy.c
+
+libc/syscalls/libc_a-sysgetentropy.obj: libc/syscalls/sysgetentropy.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/syscalls/libc_a-sysgetentropy.obj -MD -MP -MF libc/syscalls/$(DEPDIR)/libc_a-sysgetentropy.Tpo -c -o libc/syscalls/libc_a-sysgetentropy.obj `if test -f 'libc/syscalls/sysgetentropy.c'; then $(CYGPATH_W) 'libc/syscalls/sysgetentropy.c'; else $(CYGPATH_W) '$(srcdir)/libc/syscalls/sysgetentropy.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/syscalls/$(DEPDIR)/libc_a-sysgetentropy.Tpo libc/syscalls/$(DEPDIR)/libc_a-sysgetentropy.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/syscalls/sysgetentropy.c' object='libc/syscalls/libc_a-sysgetentropy.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/syscalls/libc_a-sysgetentropy.obj `if test -f 'libc/syscalls/sysgetentropy.c'; then $(CYGPATH_W) 'libc/syscalls/sysgetentropy.c'; else $(CYGPATH_W) '$(srcdir)/libc/syscalls/sysgetentropy.c'; fi`
+
 libc/syscalls/libc_a-sysgetpid.o: libc/syscalls/sysgetpid.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/syscalls/libc_a-sysgetpid.o -MD -MP -MF libc/syscalls/$(DEPDIR)/libc_a-sysgetpid.Tpo -c -o libc/syscalls/libc_a-sysgetpid.o `test -f 'libc/syscalls/sysgetpid.c' || echo '$(srcdir)/'`libc/syscalls/sysgetpid.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/syscalls/$(DEPDIR)/libc_a-sysgetpid.Tpo libc/syscalls/$(DEPDIR)/libc_a-sysgetpid.Po
diff --git a/newlib/libc/include/_syslist.h b/newlib/libc/include/_syslist.h
index 271644efa..2946af551 100644
--- a/newlib/libc/include/_syslist.h
+++ b/newlib/libc/include/_syslist.h
@@ -24,6 +24,7 @@
 #define _unlink unlink
 #define _wait wait
 #define _write write
+#define _getentropy getentropy
 #endif /* MISSING_SYSCALL_NAMES */
 
 #if defined MISSING_SYSCALL_NAMES || !defined HAVE_OPENDIR
diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h
index 23d572cd3..b1dd2a7c4 100644
--- a/newlib/libc/include/reent.h
+++ b/newlib/libc/include/reent.h
@@ -125,6 +125,7 @@ struct timezone;
 #define _unlink_r(__reent, __path)                unlink(__path)
 #define _wait_r(__reent, __status)                wait(__status)
 #define _write_r(__reent, __fd, __buff, __cnt)    write(__fd, __buff, __cnt)
+#define _getentropy_r(__reent, __buff, __cnt)     getentropy(__buff, __cnt)
 #define _gettimeofday_r(__reent, __tp, __tzp)     gettimeofday(__tp, __tzp)
 
 #ifdef __LARGE64_FILES
@@ -156,6 +157,7 @@ extern _CLOCK_T_ _times_r (struct _reent *, struct tms *);
 extern int _unlink_r (struct _reent *, const char *);
 extern int _wait_r (struct _reent *, int *);
 extern _ssize_t _write_r (struct _reent *, int, const void *, size_t);
+extern int _getentropy_r (struct _reent *, void *, size_t);
 
 /* This one is not guaranteed to be available on all targets.  */
 extern int _gettimeofday_r (struct _reent *, struct timeval *__tp, void *__tzp);
diff --git a/newlib/libc/reent/Makefile.inc b/newlib/libc/reent/Makefile.inc
index 38ddf5766..26f952bfa 100644
--- a/newlib/libc/reent/Makefile.inc
+++ b/newlib/libc/reent/Makefile.inc
@@ -4,6 +4,7 @@ libc_a_SOURCES += \
 	%D%/impure.c \
 	%D%/fcntlr.c \
 	%D%/fstatr.c \
+	%D%/getentropyr.c \
 	%D%/getreent.c \
 	%D%/gettimeofdayr.c \
 	%D%/isattyr.c \
@@ -46,6 +47,7 @@ LIBC_CHEWOUT_FILES += \
 	%D%/execr.def \
 	%D%/fcntlr.def \
 	%D%/fstatr.def \
+	%D%/getentropyr.def \
 	%D%/gettimeofdayr.def \
 	%D%/linkr.def \
 	%D%/lseekr.def \
diff --git a/newlib/libc/reent/getentropyr.c b/newlib/libc/reent/getentropyr.c
new file mode 100644
index 000000000..e3f85e41b
--- /dev/null
+++ b/newlib/libc/reent/getentropyr.c
@@ -0,0 +1,53 @@
+/* Reentrant version of getentropy system call. */
+
+#include <reent.h>
+#include <unistd.h>
+#include <_syslist.h>
+
+/* Some targets provides their own versions of these functions.  Those
+   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
+
+#ifdef _REENT_ONLY
+#ifndef REENTRANT_SYSCALLS_PROVIDED
+#define REENTRANT_SYSCALLS_PROVIDED
+#endif
+#endif
+
+#ifndef REENTRANT_SYSCALLS_PROVIDED
+
+/* We use the errno variable used by the system dependent layer.  */
+#undef errno
+extern int errno;
+
+/*
+FUNCTION
+	<<_getentropy_r>>---Reentrant version of getentropy
+
+INDEX
+	_getentropy_r
+
+SYNOPSIS
+	#include <reent.h>
+	int _getentropy_r(struct _reent *<[ptr]>,
+		          void *<[buf]>, size_t <[buflen]>);
+
+DESCRIPTION
+	This is a reentrant version of <<getentropy>>.  It
+	takes a pointer to the global data block, which holds
+	<<errno>>.
+*/
+
+int
+_getentropy_r (struct _reent *ptr,
+     void *buf,
+     size_t buflen)
+{
+  int ret;
+
+  errno = 0;
+  if ((ret = _getentropy (buf, buflen)) == -1 && errno != 0)
+    _REENT_ERRNO(ptr) = errno;
+  return ret;
+}
+
+#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
diff --git a/newlib/libc/syscalls/Makefile.inc b/newlib/libc/syscalls/Makefile.inc
index 627a4dfd2..7f7bbbddb 100644
--- a/newlib/libc/syscalls/Makefile.inc
+++ b/newlib/libc/syscalls/Makefile.inc
@@ -4,6 +4,7 @@ libc_a_SOURCES += \
 	%D%/sysclose.c \
 	%D%/sysfcntl.c \
 	%D%/sysfstat.c \
+	%D%/sysgetentropy.c \
 	%D%/sysgetpid.c \
 	%D%/sysgettod.c \
 	%D%/sysisatty.c \
diff --git a/newlib/libc/syscalls/sysgetentropy.c b/newlib/libc/syscalls/sysgetentropy.c
new file mode 100644
index 000000000..d68ccbc72
--- /dev/null
+++ b/newlib/libc/syscalls/sysgetentropy.c
@@ -0,0 +1,12 @@
+/* connector for getentropy */
+
+#include <reent.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+int
+getentropy (void *buf,
+     size_t buflen)
+{
+  return _getentropy_r (_REENT, buf, buflen);
+}
-- 
2.25.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.