From 12e371f1af1cee0c235c89f17fa558c4dd287d2d Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 11 Sep 2007 18:12:16 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20scanning=20for=20integer=20types:?= =?UTF-8?q?=20only=20scan=20for=20these=20we=20need,=20=20=20i.e.=20uint32?= =?UTF-8?q?=5Ft=20and=20uint64=5Ft=20=E2=80=A2=20faking=20:=20u?= =?UTF-8?q?=5Fint32=5Ft=20is=20not=20part=20of=20ISO=20C99,=20so=20=20=20d?= =?UTF-8?q?o=20not=20add=20it=20there=20=E2=80=A2=20add=20a=20test=20if=20?= =?UTF-8?q?u=5Fint32=5Ft=20is=20declared,=20for=20the=20sake=20of=20the=20?= =?UTF-8?q?=20=20fucked=20up=20OpenBSD=20standard=20arc4random(3)=20declar?= =?UTF-8?q?ation,=20and=20=20=20define=20it=20to=20uint32=5Ft=20if=20the?= =?UTF-8?q?=20former=20type=20is=20not=20available,=20=20=20e.g.=20on=20So?= =?UTF-8?q?laris=20or=20if=20we=20fake=20=20=E2=80=A2=20fix=20de?= =?UTF-8?q?tection=20of=20arc4random=5Fpushb(3)=20and=20the=20prototypes?= =?UTF-8?q?=20=20=20if=20one=20of=20the=20things=20above=20applied=20to=20?= =?UTF-8?q?our=20system=20=E2=80=A2=20fix=20detection=20of=20arc4random=20?= =?UTF-8?q?function=20suite=20prototypes=20if=20=20=20they=20are=20added?= =?UTF-8?q?=20via=20an=20arc4random.c=20file=20in=20the=20srcdir,=20and=20?= =?UTF-8?q?=20=20copy=20that=20file=20into=20builddir=20(if=20it=20does=20?= =?UTF-8?q?not=20already=20exist)=20=20=20to=20keep=20these=20isolated=20f?= =?UTF-8?q?rom=20each=20other?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit based on a real-life bug report by cnuke@ at the Croatian restaurant ☺☻ unbreaks “set ±o arc4random” on Solaris, both SUNpro and GCC --- Build.sh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Build.sh b/Build.sh index 1dc0d68..f6267bc 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirOS: src/bin/mksh/Build.sh,v 1.263 2007/09/11 17:49:57 tg Exp $ +# $MirOS: src/bin/mksh/Build.sh,v 1.264 2007/09/11 18:12:16 tg Exp $ #- # Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS # CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM @@ -38,6 +38,7 @@ ao= fx= me=`basename "$0"` orig_CFLAGS=$CFLAGS +NEED_ARC4RANDOM=0 if test -t 1; then bi='' @@ -650,11 +651,11 @@ ac_header values.h ac_testn can_inttypes '!' stdint_h 1 "if we have standard integer types" <<-'EOF' #include int main(int ac, char **av) { uint32_t x = (uint32_t)**av; - return (x == (u_int32_t)ac); + return (x == (uint64_t)ac); } EOF if test 0 = $HAVE_CAN_INTTYPES; then - ac_testn can_inttypes2 '' "if we have u_char, u_int, u_long" <<-'EOF' + ac_testn can_uinttypes '' "if we have u_char, u_int, u_long" <<-'EOF' #include int main(int ac, char **av) { u_int x = (u_int)**av; return (x == (u_int)(u_long)(u_char)ac); @@ -669,7 +670,6 @@ if test 0 = $HAVE_CAN_INTTYPES; then typedef unsigned short uint16_t; typedef unsigned int uint32_t; typedef unsigned long long uint64_t; - typedef unsigned int u_int32_t; EOF test 1 = $HAVE_CAN_UINTTYPES || cat >>stdint.h <<-'EOF' typedef unsigned char u_char; @@ -742,6 +742,15 @@ fi ac_cppflags SIG_T +ac_testn u_int32_t <<-'EOF' + #include + #if HAVE_STDINT_H + #include + #endif + int main(void) { return ((int)(u_int32_t)0); } +EOF +test 1 = $HAVE_U_INT32_T || CPPFLAGS="$CPPFLAGS -Du_int32_t=uint32_t" + # # Environment: signals # @@ -782,12 +791,15 @@ ac_testn arc4random <<-'EOF' int main(void) { return (arc4random()); } EOF +save_LIBS=$LIBS if test 0 = $HAVE_ARC4RANDOM && test -f "$srcdir/arc4random.c"; then ac_header sys/sysctl.h addsrcs HAVE_ARC4RANDOM arc4random.c HAVE_ARC4RANDOM=1 - HAVE_ARC4RANDOM_DECL=0 - HAVE_ARC4RANDOM_PUSH=0 + # ensure isolation of source directory from build directory + test -f arc4random.c || cp "$srcdir/arc4random.c" . + NEED_ARC4RANDOM=1 + LIBS="$LIBS arc4random.c" fi ac_cppflags ARC4RANDOM @@ -799,6 +811,7 @@ ac_test arc4random_pushb arc4random 0 <<-'EOF' extern uint32_t arc4random_pushb(void *, size_t); int main(int ac, char *av[]) { return (arc4random_pushb(*av, ac)); } EOF +LIBS=$save_LIBS ac_test flock_ex '' 'flock and mmap' <<-'EOF' #include @@ -882,6 +895,8 @@ EOF # # check headers for declarations # +save_LIBS=$LIBS +test 1 = $NEED_ARC4RANDOM && LIBS="$LIBS arc4random.c" ac_test '!' arc4random_decl arc4random 1 'if arc4random() does not need to be declared' <<-'EOF' #define MKSH_INCLUDES_ONLY #include "sh.h" @@ -894,6 +909,7 @@ ac_test '!' arc4random_pushb_decl arc4random_pushb 1 'if arc4random_pushb() does int arc4random_pushb(char, int); /* this clashes if defined before */ int main(int ac, char *av[]) { return (arc4random_pushb(**av, ac)); } EOF +LIBS=$save_LIBS ac_test sys_siglist_decl sys_siglist 1 'if sys_siglist[] does not need to be declared' <<-'EOF' #define MKSH_INCLUDES_ONLY #include "sh.h"