From: Dave Love Date: Tue, 12 Oct 1999 08:39:35 +0000 (+0000) Subject: aclocal.m4: Re-write, defining LIBU77_GETTIMEOFDAY, not LIBU77_HAVE_STRUCT_TIMEZONE. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e15ef052036441d9cd932891c2176d2a12f3d7a;p=platform%2Fupstream%2Fgcc.git aclocal.m4: Re-write, defining LIBU77_GETTIMEOFDAY, not LIBU77_HAVE_STRUCT_TIMEZONE. * libU77/aclocal.m4: Re-write, defining LIBU77_GETTIMEOFDAY, not LIBU77_HAVE_STRUCT_TIMEZONE. * libU77/configure.in: Use LIBU77_GETTIMEOFDAY, not LIBU77_HAVE_STRUCT_TIMEZONE. Don't check for gettimeofday separately. * libU77/datetime_.c (G77_date_and_time_0): Use GETTIMEOFDAY_ONE_ARGUMENT. From-SVN: r29917 --- diff --git a/libf2c/ChangeLog b/libf2c/ChangeLog index 2b75c1b..94668e0 100644 --- a/libf2c/ChangeLog +++ b/libf2c/ChangeLog @@ -1,3 +1,15 @@ +1999-10-22 Dave Love + + * libU77/aclocal.m4: Re-write, defining LIBU77_GETTIMEOFDAY, not + LIBU77_HAVE_STRUCT_TIMEZONE. + + * libU77/configure.in: Use LIBU77_GETTIMEOFDAY, not + LIBU77_HAVE_STRUCT_TIMEZONE. Don't check for gettimeofday + separately. + + * libU77/datetime_.c (G77_date_and_time_0): Use + GETTIMEOFDAY_ONE_ARGUMENT. + Tue Sep 14 01:44:01 1999 Marc Espie * Makefile.in: Prepend $(SHELL) to move-if-change calls. diff --git a/libf2c/libU77/aclocal.m4 b/libf2c/libU77/aclocal.m4 index d230dad..b9a74fd 100644 --- a/libf2c/libU77/aclocal.m4 +++ b/libf2c/libU77/aclocal.m4 @@ -1,16 +1,64 @@ -dnl See whether we have struct timezone -dnl LIBU77_HAVE_STRUCT_TIMEZONE -AC_DEFUN(LIBU77_HAVE_STRUCT_TIMEZONE, -[AC_MSG_CHECKING([whether struct timezone exists]) -AC_CACHE_VAL(libu77_cv_have_struct_timezone, -[AC_TRY_COMPILE([#include ], -[struct timezone tz;], -libu77_ac_have_struct_timezone=yes, libu77_ac_have_struct_timezone=no)]) -if test $libu77_ac_have_struct_timezone = yes; then - AC_MSG_RESULT(yes) - AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEZONE) -else - AC_MSG_RESULT(no) -fi -])dnl - +dnl Check: +dnl * If we have gettimeofday; +dnl * If we have struct timezone for use in calling it; +dnl * If calling it with a timezone pointer actually works -- this is deemed +dnl obsolete or undefined on some systems which say you should use a null +dnl pointer -- and undefine HAVE_TIMEZONE if so; +dnl * Whether it only takes one arg. +AC_DEFUN(LIBU77_GETTIMEOFDAY, [ + AC_CHECK_FUNCS(gettimeofday) + if test "$ac_cv_func_gettimeofday" = yes; then + AC_CACHE_CHECK([for struct timezone], g77_cv_struct_timezone, + [AC_TRY_COMPILE([#include ], + [struct timezone tz;], + g77_cv_struct_timezone=yes, g77_cv_struct_timezone=no)]) + if test $g77_cv_struct_timezone = yes; then + dnl It may be that we can't call gettimeofday with a non-null pointer. + dnl In that case we'll lie about struct timezone. + AC_TRY_RUN([ +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif +#endif +main () +{ + struct timeval time; + struct timezone dummy; + if (gettimeofday (&time, &dummy)) + exit (1); + else + exit (0); +}], + [AC_DEFINE(HAVE_TIMEZONE)], ,[AC_DEFINE(HAVE_TIMEZONE)]) + fi + AC_REQUIRE([AC_HEADER_TIME]) + AC_CACHE_CHECK(whether gettimeofday can accept two arguments, + emacs_cv_gettimeofday_two_arguments, + AC_TRY_LINK([ +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif +#endif + ], + [ + struct timeval time; + struct timezone dummy; + gettimeofday (&time, &dummy);], + emacs_cv_gettimeofday_two_arguments=yes, + emacs_cv_gettimeofday_two_arguments=no)) + if test $emacs_cv_gettimeofday_two_arguments = no; then + AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT) + fi + fi]) diff --git a/libf2c/libU77/configure b/libf2c/libU77/configure index fc8a490..b9a3b22 100755 --- a/libf2c/libU77/configure +++ b/libf2c/libU77/configure @@ -1448,16 +1448,15 @@ fi for ac_func in symlink getcwd getwd lstat gethostname strerror clock \ - getrusage times alarm getlogin getgid getuid kill link ttyname \ - gettimeofday + getrusage times alarm getlogin getgid getuid kill link ttyname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1456: checking for $ac_func" >&5 +echo "configure:1455: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1504,46 +1503,188 @@ else fi done -test $ac_cv_func_symlink = yes && MAYBES="$MAYBES symlnk_.o" -test $ac_cv_func_lstat = yes && MAYBES="$MAYBES lstat_.o" -test $ac_cv_func_gethostname = yes && MAYBES="$MAYBES hostnm_.o" -test $ac_cv_func_clock = yes && MAYBES="$MAYBES mclock_.o" -echo $ac_n "checking whether struct timezone exists""... $ac_c" 1>&6 -echo "configure:1515: checking whether struct timezone exists" >&5 -if eval "test \"`echo '$''{'libu77_cv_have_struct_timezone'+set}'`\" = set"; then + for ac_func in gettimeofday +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1512: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + int main() { -struct timezone tz; + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + ; return 0; } EOF -if { (eval echo configure:1527: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* - libu77_ac_have_struct_timezone=yes + eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* - libu77_ac_have_struct_timezone=no + eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi -if test $libu77_ac_have_struct_timezone = yes; then +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi +done + + if test "$ac_cv_func_gettimeofday" = yes; then + echo $ac_n "checking for struct timezone""... $ac_c" 1>&6 +echo "configure:1566: checking for struct timezone" >&5 +if eval "test \"`echo '$''{'g77_cv_struct_timezone'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { +struct timezone tz; +; return 0; } +EOF +if { (eval echo configure:1578: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + g77_cv_struct_timezone=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + g77_cv_struct_timezone=no +fi +rm -f conftest* +fi + +echo "$ac_t""$g77_cv_struct_timezone" 1>&6 + if test $g77_cv_struct_timezone = yes; then + if test "$cross_compiling" = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_TIMEZONE 1 +EOF + +else + cat > conftest.$ac_ext < +#include +#else +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif +#endif +main () +{ + struct timeval time; + struct timezone dummy; + if (gettimeofday (&time, &dummy)) + exit (1); + else + exit (0); +} +EOF +if { (eval echo configure:1622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + cat >> confdefs.h <<\EOF +#define HAVE_TIMEZONE 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -fr conftest* +fi + + fi + + echo $ac_n "checking whether gettimeofday can accept two arguments""... $ac_c" 1>&6 +echo "configure:1638: checking whether gettimeofday can accept two arguments" >&5 +if eval "test \"`echo '$''{'emacs_cv_gettimeofday_two_arguments'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#else +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif +#endif + +int main() { + + struct timeval time; + struct timezone dummy; + gettimeofday (&time, &dummy); +; return 0; } +EOF +if { (eval echo configure:1664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + emacs_cv_gettimeofday_two_arguments=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + emacs_cv_gettimeofday_two_arguments=no +fi +rm -f conftest* +fi + +echo "$ac_t""$emacs_cv_gettimeofday_two_arguments" 1>&6 + if test $emacs_cv_gettimeofday_two_arguments = no; then + cat >> confdefs.h <<\EOF +#define GETTIMEOFDAY_ONE_ARGUMENT 1 +EOF + + fi + fi + +test $ac_cv_func_symlink = yes && MAYBES="$MAYBES symlnk_.o" +test $ac_cv_func_lstat = yes && MAYBES="$MAYBES lstat_.o" +test $ac_cv_func_gethostname = yes && MAYBES="$MAYBES hostnm_.o" +test $ac_cv_func_clock = yes && MAYBES="$MAYBES mclock_.o" diff --git a/libf2c/libU77/configure.in b/libf2c/libU77/configure.in index 1262645..460e3dc 100644 --- a/libf2c/libU77/configure.in +++ b/libf2c/libU77/configure.in @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -# Copyright (C) 1995, 1998 Free Software Foundation, Inc. +# Copyright (C) 1995, 1998, 1999 Free Software Foundation, Inc. # Contributed by Dave Love (d.love@dl.ac.uk). # #This file is part of the GNU Fortran libU77 library. @@ -86,16 +86,19 @@ AC_CHECK_LIB(socket, gethostname, [LIBS="$LIBS -lsocket"]) dnl Checks for library functions. AC_CHECK_FUNCS(symlink getcwd getwd lstat gethostname strerror clock \ - getrusage times alarm getlogin getgid getuid kill link ttyname \ - gettimeofday) + getrusage times alarm getlogin getgid getuid kill link ttyname) + +dnl The standard autoconf HAVE_STRUCT_TIMEZONE doesn't actually check +dnl for struct timezone, as you might think. We also need to check how +dnl to call gettimeofday if we have it. +LIBU77_GETTIMEOFDAY + test $ac_cv_func_symlink = yes && MAYBES="$MAYBES symlnk_.o" test $ac_cv_func_lstat = yes && MAYBES="$MAYBES lstat_.o" test $ac_cv_func_gethostname = yes && MAYBES="$MAYBES hostnm_.o" test $ac_cv_func_clock = yes && MAYBES="$MAYBES mclock_.o" AC_SUBST(MAYBES) -LIBU77_HAVE_STRUCT_TIMEZONE - AC_SUBST(CROSS) AC_SUBST(RANLIB) AC_SUBST(RANLIB_TEST) diff --git a/libf2c/libU77/datetime_.c b/libf2c/libU77/datetime_.c index faf773a..1ea7731 100644 --- a/libf2c/libU77/datetime_.c +++ b/libf2c/libU77/datetime_.c @@ -57,24 +57,30 @@ int G77_date_and_time_0 (char *date, char *fftime, char *zone, vals[4] = ltime.tm_hour; vals[5] = ltime.tm_min; vals[6] = ltime.tm_sec; - vals[7] = 0; /* no STDC way to get this */ + vals[7] = 0; /* no STDC/POSIX way to get this */ /* GNUish way; maybe use `ftime' on other systems. */ #if HAVE_GETTIMEOFDAY { struct timeval tp; -#if HAVE_STRUCT_TIMEZONE +# if GETTIMEOFDAY_ONE_ARGUMENT + if (! gettimeofday (&tp)) +# else +# if HAVE_STRUCT_TIMEZONE struct timezone tzp; - /* This is still not strictly correct on some systems such as HPUX, - which does have struct timezone, but gettimeofday takes void* as - the 2nd arg. However, the effect of passing anything other than a null - pointer is unspecified on HPUX. */ + /* Some systems such as HPUX, do have struct timezone, but + gettimeofday takes void* as the 2nd arg. However, the effect + of passing anything other than a null pointer is unspecified on + HPUX. Configure checks if gettimeofday actually fails with a + non-NULL arg and pretends that struct timezone is missing if it + does fail. */ if (! gettimeofday (&tp, &tzp)) -#else +# else if (! gettimeofday (&tp, (void *) 0)) -#endif +# endif /* HAVE_STRUCT_TIMEZONE */ +# endif /* GETTIMEOFDAY_ONE_ARGUMENT */ vals[7] = tp.tv_usec/1000; } -#endif +#endif /* HAVE_GETTIMEOFDAY */ if (values) /* null pointer for missing optional */ for (i=0; i<=7; i++) values[i] = vals[i];