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..5c4d3a834 --- /dev/null +++ b/libgloss/libnosys/getentropy.c @@ -0,0 +1,21 @@ +/* + * Stub version of getentropy. + */ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#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)_$( +#include +#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 + int _getentropy_r(struct _reent *<[ptr]>, + void *<[buf]>, size_t <[buflen]>); + +DESCRIPTION + This is a reentrant version of <>. It + takes a pointer to the global data block, which holds + <>. +*/ + +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 +#include +#include + +int +getentropy (void *buf, + size_t buflen) +{ + return _getentropy_r (_REENT, buf, buflen); +}