Improve seed() function

This commit is contained in:
Landon Curt Noll
2021-12-07 00:44:57 -08:00
parent f9464652fe
commit 7ffbaf922e
7 changed files with 190 additions and 24 deletions

View File

@@ -379,19 +379,32 @@ HAVE_CONST=
HAVE_UID_T=
#HAVE_UID_T= -DHAVE_NO_UID_T
# Determine if we have user environment external:
# Determine if we have a non-NULL user environment external:
#
# extern char **environ;
# extern char **environ; /* user environment */
#
# If HAVE_ENVIRON is empty, this Makefile will run the have_environ program
# to determine if environ exsuts. If HAVE_ENVIRON is set to -DHAVE_NO_ENVIRON,
# then calc will assume there is no external environ symbol.
# to determine if environ exists and is non-NULL. If HAVE_ENVIRON is set
# to -DHAVE_NO_ENVIRON, then calc will assume there is no external environ
# symbol.
#
# If in doubt, leave HAVE_ENVIRON empty and this Makefile will figure it out.
#
HAVE_ENVIRON=
#HAVE_ENVIRON= -DHAVE_NO_ENVIRON
# Determine if we have the arc4random_buf() function
#
# If HAVE_ARC4RANDOM is empty, this Makefile will run the have_arc4random
# program to determine if arc4random_buf() function exists. If
# HAVE_ARC4RANDOM is set to -DHAVE_NO_ARC4RANDOM, then calc will assume
# there is no arc4random_buf() function.
#
# If in doubt, leave HAVE_ARC4RANDOM empty and this Makefile will figure it out.
#
HAVE_ARC4RANDOM=
#HAVE_ARC4RANDOM= -DHAVE_NO_ARC4RANDOM
# Determine if we have memcpy(), memset() and strchr()
#
# If HAVE_NEWSTR is empty, this Makefile will run the have_newstr program
@@ -1927,7 +1940,7 @@ BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \
have_posscl.h have_rusage.h have_stdlib.h have_strdup.h \
have_string.h have_strlcat.h have_strlcpy.h have_times.h \
have_uid_t.h have_unistd.h have_unused.h have_urandom.h \
have_ustat.h longbits.h terminal.h have_environ.h
have_ustat.h longbits.h terminal.h have_environ.h have_arc4random.h
# we build these .c files during the make
#
@@ -1942,7 +1955,8 @@ UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \
have_fpos_pos.c have_offscl.c have_posscl.c have_memmv.c \
have_ustat.c have_getsid.c have_getpgid.c have_environ.c \
have_gettime.c have_getprid.c have_rusage.c have_strdup.c \
have_unused.c have_ban_pragma.c have_strlcpy.c have_strlcat.c
have_unused.c have_ban_pragma.c have_strlcpy.c have_strlcat.c \
have_arc4random.c
# these awk and sed tools are used in the process of building BUILD_H_SRC
# and BUILD_C_SRC
@@ -1959,7 +1973,8 @@ UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \
try_strarg.o have_stdvs.o have_varvs.o have_posscl.o have_memmv.o \
have_ustat.o have_getsid.o have_getpgid.o have_environ.o \
have_gettime.o have_getprid.o ver_calc.o have_rusage.o have_strdup.o \
have_unused.o have_ban_pragma.o have_strlcpy.o have_strlcat.o
have_unused.o have_ban_pragma.o have_strlcpy.o have_strlcat.o \
have_arc4random.o
# these temp files may be created (and removed) during the build of BUILD_C_SRC
#
@@ -1977,7 +1992,7 @@ UTIL_PROGS= align32${EXT} fposval${EXT} have_uid_t${EXT} have_const${EXT} \
ver_calc${EXT} have_strdup${EXT} have_environ{EXT} \
have_unused${EXT} have_fpos${EXT} have_fpos_pos${EXT} \
have_offscl${EXT} have_rusage${EXT} have_ban_pragma${EXT} \
have_strlcpy${EXT} have_strlcat${EXT}
have_strlcpy${EXT} have_strlcat${EXT} have_arc4random${EXT}
# these utility files and scripts may be created in the process of building
# the BUILD_H_SRC file set
@@ -3302,6 +3317,48 @@ have_environ.h: have_environ.c \
${TRUE}; \
fi
have_arc4random.h: have_arc4random.c have_stdlib.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f have_arc4random arc4random_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(HAVE_ARC4RANDOM)' >> $@
${Q} echo '#define HAVE_ARC4RANDOM' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have or want arc4random? */' >> $@
${Q} ${RM} -f have_arc4random.o have_arc4random${EXT}
-${Q} ${LCC} ${ICFLAGS} ${HAVE_arc4random} have_arc4random.c -c ${S} \
|| ${TRUE}
-${Q} ${LCC} ${ILDFLAGS} have_arc4random.o \
-o have_arc4random${EXT} ${S} \
|| ${TRUE}
-${Q} ./have_arc4random${EXT} > arc4random_tmp ${E} \
|| ${TRUE}
-${Q} if [ -s arc4random_tmp ]; then \
${CAT} arc4random_tmp >> $@; \
else \
echo '#undef HAVE_arc4random /* no */' >> $@; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif /* !HAVE_ARC4RANDOM */' >> $@
${Q} ${RM} -f have_arc4random${EXT} have_arc4random.o arc4random_tmp
${H} echo '$@ formed'
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
${CAT} $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
have_newstr.h: have_newstr.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f newstr_tmp $@
${H} echo 'forming $@'
@@ -4478,6 +4535,7 @@ env:
@echo 'FPOS_POS_BITS=${FPOS_POS_BITS}'; echo ''
@echo 'GREP=${GREP}'; echo ''
@echo 'H=${H}'; echo ''
@echo 'HAVE_ARC4RANDOM=${HAVE_ARC4RANDOM}'; echo ''
@echo 'HAVE_CONST=${HAVE_CONST}'; echo ''
@echo 'HAVE_ENVIRON=${HAVE_ENVIRON}'; echo ''
@echo 'HAVE_FPOS=${HAVE_FPOS}'; echo ''
@@ -5866,6 +5924,10 @@ hash.o: value.h
hash.o: zmath.h
hash.o: zrand.h
hash.o: zrandom.h
have_arc4random.o: banned.h
have_arc4random.o: have_arc4random.c
have_arc4random.o: have_ban_pragma.h
have_arc4random.o: have_stdlib.h
have_ban_pragma.o: banned.h
have_ban_pragma.o: have_ban_pragma.c
have_ban_pragma.o: have_ban_pragma.h
@@ -6512,6 +6574,7 @@ seed.o: banned.h
seed.o: byteswap.h
seed.o: decl.h
seed.o: endian_calc.h
seed.o: have_arc4random.h
seed.o: have_ban_pragma.h
seed.o: have_const.h
seed.o: have_environ.h