Assume that we have utime() and <utime.h>.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2020 19:04:19 +0000 (14:04 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2020 19:30:47 +0000 (14:30 -0500)
These are required by POSIX since SUSv2, and no live platforms fail
to provide them.  On Windows, utime() exists and we bring our own
<utime.h>, so we're good there too.  So remove the configure probes
and ad-hoc substitute code.  We don't need to check for utimes()
anymore either, since that was only used as a substitute.

In passing, make the Windows build include <sys/utime.h> only where
we need it, not everywhere.

This is part of a series of commits to get rid of no-longer-relevant
configure checks and dead src/port/ code.  I'm committing them separately
to make it easier to back out individual changes if they prove less
portable than I expect.

Discussion: https://postgr.es/m/15379.1582221614@sss.pgh.pa.us

configure
configure.in
src/backend/libpq/pqcomm.c
src/backend/utils/init/miscinit.c
src/include/pg_config.h.in
src/include/port/win32_msvc/utime.h
src/include/port/win32_port.h
src/tools/msvc/Solution.pm

index d746255f25de00f5fe70e3c80c16f7088d985644..e6e8275e807e0b58d6b458aa234f120a0da59e4c 100755 (executable)
--- a/configure
+++ b/configure
@@ -12762,7 +12762,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
 fi
 
 
-for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/event.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h
+for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/event.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h wchar.h wctype.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -14925,7 +14925,7 @@ fi
 LIBS_including_readline="$LIBS"
 LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
 
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred getrlimit kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink sync_file_range uselocale utime utimes wcstombs_l
+for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred getrlimit kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink sync_file_range uselocale wcstombs_l
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
index a9c91dadbc1b384789e45fa78362cc5ab7d885a6..e8e972231c2f16a6a02cf94be070d0c07a20c1e7 100644 (file)
@@ -1300,7 +1300,6 @@ AC_CHECK_HEADERS(m4_normalize([
    sys/un.h
    termios.h
    ucred.h
-   utime.h
    wchar.h
    wctype.h
 ]))
@@ -1642,8 +1641,6 @@ AC_CHECK_FUNCS(m4_normalize([
    symlink
    sync_file_range
    uselocale
-   utime
-   utimes
    wcstombs_l
 ]))
 
index 10bf13f997db3e1a138cc69530585b896a36554a..7717bb27195e15295358e8c62e8b1bf86226ca13 100644 (file)
@@ -81,9 +81,7 @@
 #ifdef HAVE_NETINET_TCP_H
 #include <netinet/tcp.h>
 #endif
-#ifdef HAVE_UTIME_H
 #include <utime.h>
-#endif
 #ifdef _MSC_VER                    /* mstcpip.h is missing on mingw */
 #include <mstcpip.h>
 #endif
@@ -866,20 +864,8 @@ TouchSocketFiles(void)
    {
        char       *sock_path = (char *) lfirst(l);
 
-       /*
-        * utime() is POSIX standard, utimes() is a common alternative. If we
-        * have neither, there's no way to affect the mod or access time of
-        * the socket :-(
-        *
-        * In either path, we ignore errors; there's no point in complaining.
-        */
-#ifdef HAVE_UTIME
-       utime(sock_path, NULL);
-#else                          /* !HAVE_UTIME */
-#ifdef HAVE_UTIMES
-       utimes(sock_path, NULL);
-#endif                         /* HAVE_UTIMES */
-#endif                         /* HAVE_UTIME */
+       /* Ignore errors; there's no point in complaining */
+       (void) utime(sock_path, NULL);
    }
 }
 
index c7c9bef617ede10594d667592546cd5b3d89066b..b02bad442033bd12f3486b588b00e0bc9339371c 100644 (file)
@@ -26,9 +26,7 @@
 #include <pwd.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#ifdef HAVE_UTIME_H
 #include <utime.h>
-#endif
 
 #include "access/htup_details.h"
 #include "catalog/pg_authid.h"
@@ -1213,29 +1211,8 @@ TouchSocketLockFiles(void)
        if (strcmp(socketLockFile, DIRECTORY_LOCK_FILE) == 0)
            continue;
 
-       /*
-        * utime() is POSIX standard, utimes() is a common alternative; if we
-        * have neither, fall back to actually reading the file (which only
-        * sets the access time not mod time, but that should be enough in
-        * most cases).  In all paths, we ignore errors.
-        */
-#ifdef HAVE_UTIME
-       utime(socketLockFile, NULL);
-#else                          /* !HAVE_UTIME */
-#ifdef HAVE_UTIMES
-       utimes(socketLockFile, NULL);
-#else                          /* !HAVE_UTIMES */
-       int         fd;
-       char        buffer[1];
-
-       fd = open(socketLockFile, O_RDONLY | PG_BINARY, 0);
-       if (fd >= 0)
-       {
-           read(fd, buffer, sizeof(buffer));
-           close(fd);
-       }
-#endif                         /* HAVE_UTIMES */
-#endif                         /* HAVE_UTIME */
+       /* we just ignore any error here */
+       (void) utime(socketLockFile, NULL);
    }
 }
 
index e3e74728204d954d181fe7b61a0aa3b31ce67803..20700cb85a97dccce0767eca8db955f8d4d6b008 100644 (file)
 /* Define to 1 if you have the `uselocale' function. */
 #undef HAVE_USELOCALE
 
-/* Define to 1 if you have the `utime' function. */
-#undef HAVE_UTIME
-
-/* Define to 1 if you have the `utimes' function. */
-#undef HAVE_UTIMES
-
-/* Define to 1 if you have the <utime.h> header file. */
-#undef HAVE_UTIME_H
-
 /* Define to 1 if you have BSD UUID support. */
 #undef HAVE_UUID_BSD
 
index dd1b103eaef6fca320564fee5860e3b6e05cda42..c78e79c33d34fa6ea12287ec74e5194bf705491e 100644 (file)
@@ -1 +1,3 @@
 /* src/include/port/win32_msvc/utime.h */
+
+#include <sys/utime.h>         /* for non-unicode version */
index 91ec01468e84884ad54c4c975528b2ef18ceb393..8b6576b23dc869dc3d4c5a9c0bc1fd38aea995b0 100644 (file)
@@ -50,7 +50,6 @@
 #include <process.h>
 #include <signal.h>
 #include <direct.h>
-#include <sys/utime.h>         /* for non-unicode version */
 #undef near
 #include <sys/stat.h>          /* needed before sys/stat hacking below */
 
index cb03d03a971a770fb3b7c8e1d8cefaf7e657d322..151a41ad5b62a4595799323872d5d4b50955da89 100644 (file)
@@ -390,9 +390,6 @@ sub GenerateFiles
        HAVE_UNIX_SOCKETS                        => undef,
        HAVE_UNSETENV                            => undef,
        HAVE_USELOCALE                           => undef,
-       HAVE_UTIME                               => 1,
-       HAVE_UTIMES                              => undef,
-       HAVE_UTIME_H                             => 1,
        HAVE_UUID_BSD                            => undef,
        HAVE_UUID_E2FS                           => undef,
        HAVE_UUID_OSSP                           => undef,