From 1a0b51b6974c18392418537b9e9095bf80a62a60 Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 24 Apr 2007 10:42:02 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20arc4random,=20arc4random=5Fpush:=20?= =?UTF-8?q?use=20our=20own=20protos=20to=20check=20=20=20XXX=20u=5Fint32?= =?UTF-8?q?=5Ft=20is=20not=20ISO=20C99,=20but=20seems=20to=20work=20well?= =?UTF-8?q?=20enough=20=20=20XXX=20if=20it=20fails=20anywhere,=20we'll=20s?= =?UTF-8?q?ee=20in=20the=20build=20logs=20=20=20XXX=20apple=20doesn't=20ha?= =?UTF-8?q?ve=20the=20standard=20uint32=5Ft=20and=20API=20doesn't=20specif?= =?UTF-8?q?y=20it=20=E2=80=A2=20sys=5Fsiglist=5Fdefn:=20rename=20to=20sys?= =?UTF-8?q?=5Fsiglist=5Fdecl=20as=20we're=20really=20checking=20=20=20for?= =?UTF-8?q?=20the=20declaration=20in=20the=20headers;=20change=20wording?= =?UTF-8?q?=20to=20=E2=80=9Ccheck=20if=20=E2=80=A6=20does=20=20=20not=20ne?= =?UTF-8?q?ed=20to=20be=20declared=E2=80=9D=20since=20we=20don't=20need=20?= =?UTF-8?q?to=20declare=20if=20we=20don't=20use=20=E2=80=A2=20scan=20for?= =?UTF-8?q?=20arc4random,=20arc4random=5Fpush,=20confstr=20declarations=20?= =?UTF-8?q?too=20=E2=80=A2=20sh.h:=20confstr=20declaration=20is=20no=20lon?= =?UTF-8?q?ger=20#ifdef=20=5F=5Fsun=5F=5F;=20sort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Build.sh | 37 +++++++++++++++++++++++++++++++++---- Makefile | 14 ++++++++------ sh.h | 26 ++++++++++++++++++-------- 3 files changed, 59 insertions(+), 18 deletions(-) diff --git a/Build.sh b/Build.sh index 21adc9a..31b8525 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirOS: src/bin/mksh/Build.sh,v 1.178 2007/04/23 22:33:20 tg Exp $ +# $MirOS: src/bin/mksh/Build.sh,v 1.179 2007/04/24 10:42:02 tg Exp $ #- # Environment used: CC CFLAGS CPP CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS # CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM @@ -548,12 +548,16 @@ EOF # Environment: library functions # ac_test arc4random <<-'EOF' - #include + #include + #if HAVE_STDINT_H + #include + #endif + extern u_int32_t arc4random(void); int main(void) { return (arc4random()); } EOF ac_test arc4random_push arc4random 0 <<-'EOF' - #include + extern void arc4random_push(int); int main(void) { arc4random_push(1); return (0); } EOF @@ -620,7 +624,32 @@ EOF # # checks for function definitions in headers # -ac_test sys_siglist_defn sys_siglist 1 'if sys_siglist[] is defined' <<-'EOF' +ac_test arc4random_decl arc4random 1 'if arc4random() does not need to be declared' <<-'EOF' + #if 0 + #include + #else + #define MKSH_INCLUDES_ONLY + #include "sh.h" + #endif + int main(void) { return (arc4random()); } +EOF +ac_test arc4random_push_decl arc4random_push 1 'if arc4random_push() does not need to be declared' <<-'EOF' + #define MKSH_INCLUDES_ONLY + #include "sh.h" + int main(void) { arc4random_push(1); return (0); } +EOF +ac_test confstr_decl '' 'if confstr() does not need to be declared' <<-'EOF' + #define MKSH_INCLUDES_ONLY + #include "sh.h" + int main(int ac, char *av[]) { + #if !defined(_PATH_DEFPATH) && defined(_CS_PATH) + return (confstr(ac, *av, 0)); + #else + return (ac + **av); + #endif + } +EOF +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" int main(void) { return (sys_siglist[0][0]); } diff --git a/Makefile b/Makefile index 1c65208..7ad3fd5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/Makefile,v 1.37 2007/04/23 20:37:16 tg Exp $ +# $MirOS: src/bin/mksh/Makefile,v 1.38 2007/04/24 10:42:02 tg Exp $ #- # use CPPFLAGS=-DDEBUG __CRAZY=Yes to check for certain more stuff @@ -17,11 +17,13 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 \ -DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 -DHAVE_RLIM_T=1 \ -DHAVE_SIG_T=1 -DHAVE_MKSH_SIGNAME=0 -DHAVE_SYS_SIGNAME=1 \ -DHAVE__SYS_SIGNAME=0 -DHAVE_SYS_SIGLIST=1 -DHAVE_STRSIGNAL=0 \ - -DHAVE_ARC4RANDOM=1 -DHAVE_ARC4RANDOM_PUSH=1 -DHAVE_FLOCK_EX=1 \ - -DHAVE_SETLOCALE_CTYPE=0 -DHAVE_LANGINFO_CODESET=0 \ - -DHAVE_REVOKE=1 -DHAVE_SETMODE=1 -DHAVE_SETRESUGID=1 \ - -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 -DHAVE_STRLCPY=1 \ - -DHAVE_SYS_SIGLIST_DEFN=1 -DHAVE_PERSISTENT_HISTORY=1 \ + -DHAVE_ARC4RANDOM=1 -DHAVE_ARC4RANDOM_PUSH=1 \ + -DHAVE_FLOCK_EX=1 -DHAVE_SETLOCALE_CTYPE=0 \ + -DHAVE_LANGINFO_CODESET=0 -DHAVE_REVOKE=1 -DHAVE_SETMODE=1 \ + -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 \ + -DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 \ + -DHAVE_ARC4RANDOM_PUSH_DECL=1 -DHAVE_CONFSTR_DECL=1 \ + -DHAVE_SYS_SIGLIST_DECL=1 -DHAVE_PERSISTENT_HISTORY=1 \ -DHAVE_MULTI_IDSTRING=1 COPTS+= -std=gnu99 -Wall .endif diff --git a/sh.h b/sh.h index 8854835..21d85d4 100644 --- a/sh.h +++ b/sh.h @@ -8,7 +8,7 @@ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ -#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.126 2007/04/23 20:37:16 tg Exp $" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.127 2007/04/24 10:42:02 tg Exp $" #define MKSH_VERSION "R29 2007/04/17" #if HAVE_SYS_PARAM_H @@ -182,21 +182,35 @@ typedef int bool; #undef BAD /* AIX defines that somewhere */ -/* OS-dependent additions */ +/* OS-dependent additions (functions, variables, by OS) */ + +#if !HAVE_ARC4RANDOM_DECL +extern u_int32_t arc4random(void); +#endif + +#if !HAVE_ARC4RANDOM_PUSH_DECL +extern void arc4random_push(int); +#endif + +#if !HAVE_CONFSTR_DECL +size_t confstr(int, char *, size_t); +#endif #if !HAVE_SETMODE mode_t getmode(const void *, mode_t); void *setmode(const char *); #endif + #if !HAVE_STRCASESTR const char *stristr(const char *, const char *); #endif + #if !HAVE_STRLCPY size_t strlcpy(char *, const char *, size_t); #endif -#if defined(__sun__) && !defined(_PATH_DEFPATH) && defined(_CS_PATH) -size_t confstr(int, char *, size_t); +#if !HAVE_SYS_SIGLIST_DECL +extern const char *const sys_siglist[]; #endif #ifdef __INTERIX @@ -205,10 +219,6 @@ extern int __cdecl seteuid(uid_t); extern int __cdecl setegid(gid_t); #endif -#if !HAVE_SYS_SIGLIST_DEFN -extern const char *const sys_siglist[]; -#endif - /* some useful #defines */ #ifdef EXTERN # define I__(i) = i