Improve seed()

Added charbit.h to define CALC_CHARBIT which is either CHAR_BIT
from <limits.h> or 8 or a value set by the Makefile variable
CALC_CHARBIT.  Added have_limits.h to determine if <limits.h>
is a system include file.
This commit is contained in:
Landon Curt Noll
2021-12-07 21:41:28 -08:00
parent a02f8aa9f9
commit 177a5d00d1
8 changed files with 208 additions and 14 deletions

View File

@@ -223,6 +223,19 @@ CALC_BYTE_ORDER=
#CALC_BYTE_ORDER= -DBIG_ENDIAN
#CALC_BYTE_ORDER= -DLITTLE_ENDIAN
# Determine the number of bits in a byte
#
# If in doubt, leave CALC_CHARBIT empty. This Makefile will run
# the charbits program to determine the length.
#
# In order to avoid make brain damage in some systems, we avoid placing
# a space after the ='s below.
#
# Select CALC_CHARBIT= 8 for DJGPP.
#
CALC_CHARBIT=
#CALC_CHARBIT= 8
# Determine the number of bits in a long
#
# If in doubt, leave LONG_BITS empty. This Makefile will run
@@ -659,6 +672,20 @@ HAVE_UNISTD_H=
#HAVE_UNISTD_H= YES
#HAVE_UNISTD_H= NO
# Determine if we have the <limits.h> include file.
#
# HAVE_LIMITS_H= let the Makefile look for the include file
# HAVE_LIMITS_H= YES assume that the include file exists
# HAVE_LIMITS_H= NO assume that the include file does not exist
#
# Select HAVE_LIMITS_H= YES for DJGPP.
#
# When in doubt, leave HAVE_LIMITS_H empty.
#
HAVE_LIMITS_H=
#HAVE_LIMITS_H= YES
#HAVE_LIMITS_H= NO
# Determine if our compiler allows the unused attribute
#
# If HAVE_UNUSED is empty, this Makefile will run the have_unused program
@@ -1945,7 +1972,8 @@ 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_arc4random.h
have_ustat.h longbits.h terminal.h have_environ.h \
have_arc4random.h have_limits.h charbit.h
# we build these .c files during the make
#
@@ -1961,7 +1989,7 @@ UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.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_arc4random.c
have_arc4random.c charbit.c
# these awk and sed tools are used in the process of building BUILD_H_SRC
# and BUILD_C_SRC
@@ -1979,7 +2007,7 @@ UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.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_arc4random.o
have_arc4random.o charbit.o
# these temp files may be created (and removed) during the build of BUILD_C_SRC
#
@@ -1997,7 +2025,8 @@ 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_arc4random${EXT}
have_strlcpy${EXT} have_strlcat${EXT} have_arc4random${EXT} \
charbit${EXT}
# these utility files and scripts may be created in the process of building
# the BUILD_H_SRC file set
@@ -2673,7 +2702,43 @@ endian_calc.h: endian.c have_stdlib.h have_unistd.h \
${TRUE}; \
fi
longbits.h: longbits.c have_unistd.h have_stdlib.h \
charbit.h: charbit.c have_limits.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f charbit.o charbit${EXT} $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(CALC_CHARBIT_H)' >> $@
${Q} echo '#define CALC_CHARBIT_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
-@if [ -z ${CALC_CHARBIT} ]; then \
${LCC} ${ICFLAGS} charbit.c -c ${S}; \
${LCC} ${ILDFLAGS} charbit.o -o charbit${EXT} ${S}; \
./charbit${EXT} >> $@ ${E}; \
else \
echo '#define CALC_CHARBIT ${CALC_CHARBIT} ' \
'/* set by Makefile.ship */' >> $@; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif /* !CALC_CHARBIT_H */' >> $@
${H} echo '$@ formed'
${Q} ${RM} -f charbit.o charbit${EXT}
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
${CAT} $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
longbits.h: longbits.c charbit.h have_unistd.h have_stdlib.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f longbits.o longbits${EXT} $@
${H} echo 'forming $@'
@@ -2842,6 +2907,42 @@ have_unistd.h: ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_limits.h: ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(CALC_HAVE_LIMITS_H)' >> $@
${Q} echo '#define CALC_HAVE_LIMITS_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have <limits.h>? */' >> $@
-${Q} if [ X"${HAVE_LIMITS_H}" = X"YES" ]; then \
echo '#define HAVE_LIMITS_H /* yes */' >> $@; \
elif [ X"${HAVE_LIMITS_H}" = X"NO" ]; then \
echo '#undef HAVE_LIMITS_H /* no */' >> $@; \
elif echo '#include <limits.h>' | ${CC} -E - ${S}; then \
echo '#define HAVE_LIMITS_H /* yes */' >> $@; \
else \
echo '#undef HAVE_LIMITS_H /* no */' >> $@; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif /* !CALC_HAVE_LIMITS_H */' >> $@
${H} echo '$@ formed'
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
${CAT} $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
have_string.h: ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f $@
${H} echo 'forming $@'
@@ -4298,7 +4399,7 @@ version:
ver_calc${EXT}: version.c strl.c have_string.h have_const.h have_newstr.h \
have_strlcpy.h have_memmv.h have_strlcat.h endian_calc.h longbits.h \
have_unused.h
have_unused.h charbit.h
${RM} -f $@
${LCC} ${ICFLAGS} -DCALC_VER ${ILDFLAGS} version.c strl.c -o $@
@@ -4551,6 +4652,7 @@ env:
@echo 'HAVE_GETRUSAGE=${HAVE_GETRUSAGE}'; echo ''
@echo 'HAVE_GETSID=${HAVE_GETSID}'; echo ''
@echo 'HAVE_GETTIME=${HAVE_GETTIME}'; echo ''
@echo 'HAVE_LIMITS_H=${HAVE_LIMITS_H}'; echo ''
@echo 'HAVE_MEMMOVE=${HAVE_MEMMOVE}'; echo ''
@echo 'HAVE_NEWSTR=${HAVE_NEWSTR}'; echo ''
@echo 'HAVE_OFFSCL=${HAVE_OFFSCL}'; echo ''
@@ -5655,6 +5757,10 @@ calcerr.o: calcerr.c
calcerr.o: calcerr.h
calcerr.o: have_ban_pragma.h
calcerr.o: have_const.h
charbit.o: banned.h
charbit.o: charbit.c
charbit.o: have_ban_pragma.h
charbit.o: have_limits.h
codegen.o: alloc.h
codegen.o: banned.h
codegen.o: block.h
@@ -6226,7 +6332,9 @@ listfunc.o: value.h
listfunc.o: zmath.h
listfunc.o: zrand.h
longbits.o: banned.h
longbits.o: charbit.h
longbits.o: have_ban_pragma.h
longbits.o: have_limits.h
longbits.o: have_stdlib.h
longbits.o: have_unistd.h
longbits.o: longbits.c