From 7b903e4aa947f5dede53a8cd4eac82debbf20898 Mon Sep 17 00:00:00 2001 From: tg Date: Thu, 18 Jan 2007 15:50:32 +0000 Subject: [PATCH] header overhaul: replace all #ifdef __OS__ with mirtoconf checks (except the persistent history one) --- Build.sh | 60 ++++++++++++++++++++++++++++++++------------------------ Makefile | 13 ++++++------ check.t | 4 ++-- misc.c | 4 ++-- sh.h | 34 +++++++++++++++----------------- 5 files changed, 61 insertions(+), 54 deletions(-) diff --git a/Build.sh b/Build.sh index 5a2287d..c39105a 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirOS: src/bin/mksh/Build.sh,v 1.142 2007/01/18 03:31:50 tg Exp $ +# $MirOS: src/bin/mksh/Build.sh,v 1.143 2007/01/18 15:50:31 tg Exp $ #- # Env: CC, CFLAGS, CPP, CPPFLAGS, LDFLAGS, LIBS, NOWARN, NROFF, TARGET_OS # CPPFLAGS recognised: MKSH_SMALL MKSH_NOPWNAM @@ -25,10 +25,13 @@ else ao= fi +allu=QWERTYUIOPASDFGHJKLZXCVBNM +alll=qwertyuiopasdfghjklzxcvbnm +alln=0123456789 + upper() { - echo :"$@" | sed 's/^://' | \ - tr qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM + echo :"$@" | sed 's/^://' | tr $alll $allu } # pipe .c | ac_test[n] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput @@ -103,6 +106,21 @@ ac_flags() test 11 = $fa$fv || CFLAGS=$save_CFLAGS } +# ac_header header [prereq ...] +ac_header() +{ + hf=$1; shift + hv=`echo "$hf" | tr -d '\r\n' | tr -c $alll$allu$alln- _` + for i + do + echo "#include <$i>" >>x + done + echo "#include <$hf>" >>x + echo 'int main(void) { return (0); }' >>x + ac_test "$hv" "" "<$hf>" ' <<-'EOF' - #include - int main(void) { return (0); } -EOF - -ac_test sys_sysmacros_h '' '' <<-'EOF' - #include - int main(void) { return (0); } -EOF - -ac_test libgen_h '' '' <<-'EOF' - #include - int main(void) { return (0); } -EOF - -ac_test stdbool_h '' '' <<-'EOF' - #include - int main(void) { return (0); } -EOF +ac_header sys/param.h +ac_header sys/mkdev.h +ac_header sys/sysmacros.h +ac_header libgen.h +ac_header paths.h +ac_header stdbool.h +ac_header grp.h sys/types.h +ac_header ulimit.h +ac_header values.h # # Environment: types @@ -443,7 +451,9 @@ EOF ac_test setgroups setresugid 0 <<-'EOF' #include + #if HAVE_GRP_H #include + #endif #include int main(void) { gid_t gid = 0; return (setgroups(0, &gid)); } EOF @@ -476,7 +486,6 @@ EOF # if test 1 = $NEED_MKSH_SIGNAME; then $e ... checking how to run the C Preprocessor - rm -f x save_CPP=$CPP for i in "$save_CPP" "$CC -E -" "cpp" "/usr/libexec/cpp" "/lib/cpp"; do CPP=$i @@ -500,7 +509,6 @@ $e ... done. # Some operating systems have ancient versions of ed(1) writing # the character count to standard output; cope for that -rm -f x echo wq >x ed x /dev/null | grep 3 >/dev/null 2>&1 && \ check_categories=$check_categories,oldish-ed diff --git a/Makefile b/Makefile index d723c6b..c7fda99 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/Makefile,v 1.27 2007/01/18 01:24:46 tg Exp $ +# $MirOS: src/bin/mksh/Makefile,v 1.28 2007/01/18 15:50:32 tg Exp $ PROG= mksh SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \ @@ -6,11 +6,12 @@ SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \ .if !make(test-build) CPPFLAGS+= -DHAVE_ATTRIBUTE=1 -DHAVE_ATTRIBUTE_BOUNDED=1 \ -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_PARAM_H=1 \ - -DHAVE_SYS_SYSMACROS_H=0 -DHAVE_LIBGEN_H=1 \ - -DHAVE_STDBOOL_H=1 -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_SYS_MKDEV_H=0 -DHAVE_SYS_SYSMACROS_H=0 \ + -DHAVE_LIBGEN_H=1 -DHAVE_PATHS_H=1 -DHAVE_STDBOOL_H=1 \ + -DHAVE_GRP_H=1 -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_SETLOCALE_CTYPE=1 \ -DHAVE_LANGINFO_CODESET=1 -DHAVE_REVOKE=1 -DHAVE_SETMODE=1 \ -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 \ diff --git a/check.t b/check.t index cc13856..e5d648d 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.85 2007/01/18 01:10:55 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.86 2007/01/18 15:50:32 tg Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ @@ -7,7 +7,7 @@ # http://www.research.att.com/~gsf/public/ifs.sh expected-stdout: - @(#)MIRBSD KSH R29 2007/01/17 + @(#)MIRBSD KSH R29 2007/01/18 description: Check version of shell. category: pdksh diff --git a/misc.c b/misc.c index 2c41f8a..25f2c23 100644 --- a/misc.c +++ b/misc.c @@ -2,11 +2,11 @@ /* $OpenBSD: path.c,v 1.12 2005/03/30 17:16:37 deraadt Exp $ */ #include "sh.h" -#if HAVE_SETGROUPS +#if HAVE_GRP_H #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.46 2007/01/18 01:01:25 tg Exp $\t" +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.47 2007/01/18 15:50:32 tg Exp $\t" MKSH_SH_H_ID); #undef USE_CHVT diff --git a/sh.h b/sh.h index c143001..2a8ec9c 100644 --- a/sh.h +++ b/sh.h @@ -8,8 +8,8 @@ /* $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.107 2007/01/18 01:03:10 tg Exp $" -#define MKSH_VERSION "R29 2007/01/17" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.108 2007/01/18 15:50:32 tg Exp $" +#define MKSH_VERSION "R29 2007/01/18" #if HAVE_SYS_PARAM_H #include @@ -41,6 +41,9 @@ #include #include #include +#if HAVE_SYS_MKDEV_H +#include +#endif #include #include #include @@ -55,7 +58,7 @@ #include #endif #include -#if !defined(__sun__) +#if HAVE_PATHS_H #include #endif #include @@ -71,17 +74,11 @@ #include #include #include -#include - -/* extra headers */ - -#if defined(__sun__) || defined(__INTERIX) -#include -#endif -#if !defined(__OpenBSD__) && !defined(__CYGWIN__) +#if HAVE_ULIMIT_H #include #endif -#if defined(__sun__) || defined(__gnu_linux__) +#include +#if HAVE_VALUES_H #include #endif @@ -91,6 +88,10 @@ typedef long rlim_t; #endif +#if !HAVE_SIG_T +typedef void (*sig_t)(int); +#endif + #if !HAVE_STDBOOL_H /* kludge, but enough for mksh */ typedef int bool; @@ -166,7 +167,7 @@ typedef int bool; /* OS-dependent additions */ -#if !HAVE_SETMODE && !defined(MKSH_SMALL) +#if !HAVE_SETMODE mode_t getmode(const void *, mode_t); void *setmode(const char *); #endif @@ -182,7 +183,7 @@ size_t confstr(int, char *, size_t); #endif #ifdef __INTERIX -#define makedev(x,y) mkdev((x),(y)) +#define makedev mkdev extern int __cdecl seteuid(uid_t); extern int __cdecl setegid(gid_t); #endif @@ -373,10 +374,6 @@ struct temp { #define shl_out (&shf_iob[2]) EXTERN int shl_stdout_ok; -#if !HAVE_SIG_T -typedef void (*sig_t)(int); -#endif - /* * trap handlers */ @@ -742,6 +739,7 @@ extern const struct builtin shbuiltins [], kshbuiltins []; #define V_OPTIND 4 #define V_RANDOM 8 #define V_HISTSIZE 9 +/* this is defined when we support persistent history, undefined otherwise */ #if !defined(__sun__) && !defined(MKSH_SMALL) #define V_HISTFILE 10 #endif