[Git][ghc/ghc][master] 2 commits: build: get rid of `HAVE_TIME_H`

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Oct 21 06:58:57 UTC 2022



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00
build: get rid of `HAVE_TIME_H`

As advertized by `autoreconf`:

> All current systems provide time.h; it need not be checked for.

Hence, remove the check for it in `configure.ac` and remove conditional
inclusion of the header in `HAVE_TIME_H` blocks where applicable.

The `time.h` header was being included in various source files without a
`HAVE_TIME_H` guard already anyway.

- - - - -
25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00
rts: remove use of `TIME_WITH_SYS_TIME`

`autoreconf` will insert an `m4_warning` when the obsolescent
`AC_HEADER_TIME` macro is used:

> Update your code to rely only on HAVE_SYS_TIME_H,
> then remove this warning and the obsolete code below it.
> All current systems provide time.h; it need not be checked for.
> Not all systems provide sys/time.h, but those that do, all allow
> you to include it and time.h simultaneously.

Presence of `sys/time.h` was already checked in an earlier
`AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and
guards relying on `TIME_WITH_SYS_TIME` can be reworked to
(unconditionally) include `time.h` and include `sys/time.h` based on
`HAVE_SYS_TIME_H`.

Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67
says

> This macro is obsolescent, as current systems can include both files
> when they exist. New programs need not use this macro.

- - - - -


11 changed files:

- configure.ac
- libraries/base/System/CPUTime/Posix/ClockGetTime.hsc
- libraries/base/aclocal.m4
- libraries/base/cbits/sysconf.c
- libraries/base/include/HsBase.h
- m4/fp_check_timer_create.m4
- rts/RtsUtils.c
- rts/posix/Clock.h
- rts/posix/ticker/Pthread.c
- rts/posix/ticker/Setitimer.c
- rts/win32/GetTime.c


Changes:

=====================================
configure.ac
=====================================
@@ -845,7 +845,7 @@ dnl    off_t, because it will affect the result of that test.
 AC_SYS_LARGEFILE
 
 dnl ** check for specific header (.h) files that we are interested in
-AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h])
+AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
 
 dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
 AC_CHECK_HEADERS([sys/cpuset.h], [], [],
@@ -857,9 +857,6 @@ AC_CHECK_HEADERS([sys/cpuset.h], [], [],
 dnl ** check whether a declaration for `environ` is provided by libc.
 FP_CHECK_ENVIRON
 
-dnl ** check if it is safe to include both <time.h> and <sys/time.h>
-AC_HEADER_TIME
-
 dnl ** do we have long longs?
 AC_CHECK_TYPES([long long])
 


=====================================
libraries/base/System/CPUTime/Posix/ClockGetTime.hsc
=====================================
@@ -2,10 +2,8 @@
 
 #include "HsFFI.h"
 #include "HsBaseConfig.h"
-#if HAVE_TIME_H
 #include <unistd.h>
 #include <time.h>
-#endif
 
 module System.CPUTime.Posix.ClockGetTime
     ( getCPUTime


=====================================
libraries/base/aclocal.m4
=====================================
@@ -78,9 +78,7 @@ AC_DEFUN([FPTOOLS_HTYPE_INCLUDES],
 # include <signal.h>
 #endif
 
-#if HAVE_TIME_H
-# include <time.h>
-#endif
+#include <time.h>
 
 #if HAVE_TERMIOS_H
 # include <termios.h>


=====================================
libraries/base/cbits/sysconf.c
=====================================
@@ -6,9 +6,7 @@
 #endif
 
 /* for CLK_TCK */
-#if HAVE_TIME_H
 #include <time.h>
-#endif
 
 long clk_tck(void) {
 #if defined(CLK_TCK)


=====================================
libraries/base/include/HsBase.h
=====================================
@@ -74,9 +74,7 @@
 #  include <sys/timers.h>
 # endif
 #endif
-#if HAVE_TIME_H
 #include <time.h>
-#endif
 #if HAVE_SYS_TIMEB_H && !defined(__FreeBSD__)
 #include <sys/timeb.h>
 #endif


=====================================
m4/fp_check_timer_create.m4
=====================================
@@ -20,9 +20,7 @@ then
 #if defined(HAVE_STDLIB_H)
 #include <stdlib.h>
 #endif
-#if defined(HAVE_TIME_H)
 #include <time.h>
-#endif
 #if defined(HAVE_SIGNAL_H)
 #include <signal.h>
 #endif


=====================================
rts/RtsUtils.c
=====================================
@@ -15,9 +15,7 @@
 #include "Schedule.h"
 #include "RtsFlags.h"
 
-#if defined(HAVE_TIME_H)
 #include <time.h>
-#endif
 
 /* HACK: On Mac OS X 10.4 (at least), time.h doesn't declare ctime_r with
  *       _POSIX_C_SOURCE. If this is the case, we declare it ourselves.


=====================================
rts/posix/Clock.h
=====================================
@@ -12,9 +12,7 @@
 # include <unistd.h>
 #endif
 
-#if defined(HAVE_TIME_H)
-# include <time.h>
-#endif
+#include <time.h>
 
 #if defined(HAVE_SYS_TIME_H)
 # include <sys/time.h>


=====================================
rts/posix/ticker/Pthread.c
=====================================
@@ -44,17 +44,10 @@
 #include "Schedule.h"
 #include "posix/Clock.h"
 
-/* As recommended in the autoconf manual */
-# if defined(TIME_WITH_SYS_TIME)
-#  include <sys/time.h>
-#  include <time.h>
-# else
-#  if defined(HAVE_SYS_TIME_H)
-#   include <sys/time.h>
-#  else
-#   include <time.h>
-#  endif
-# endif
+#include <time.h>
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
 
 #if defined(HAVE_SIGNAL_H)
 # include <signal.h>


=====================================
rts/posix/ticker/Setitimer.c
=====================================
@@ -15,17 +15,10 @@
 #include "posix/Clock.h"
 #include "posix/Signals.h"
 
-/* As recommended in the autoconf manual */
-# if defined(TIME_WITH_SYS_TIME)
-#  include <sys/time.h>
-#  include <time.h>
-# else
-#  if defined(HAVE_SYS_TIME_H)
-#   include <sys/time.h>
-#  else
-#   include <time.h>
-#  endif
-# endif
+#include <time.h>
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
 
 #if defined(HAVE_SIGNAL_H)
 # include <signal.h>


=====================================
rts/win32/GetTime.c
=====================================
@@ -11,9 +11,7 @@
 
 #include <windows.h>
 
-#if defined(HAVE_TIME_H)
-# include <time.h>
-#endif
+#include <time.h>
 
 /* Convert FILETIMEs into secs */
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8cd6f435e60f9dd14ad55a0002ff833536e9ccb2...25cdc63044be34e5eb3ef478910bd5eeb2b5093f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8cd6f435e60f9dd14ad55a0002ff833536e9ccb2...25cdc63044be34e5eb3ef478910bd5eeb2b5093f
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221021/1c94bc34/attachment-0001.html>


More information about the ghc-commits mailing list