Remove configure probe for link.
authorThomas Munro <tmunro@postgresql.org>
Thu, 4 Aug 2022 21:36:50 +0000 (09:36 +1200)
committerThomas Munro <tmunro@postgresql.org>
Thu, 4 Aug 2022 21:36:50 +0000 (09:36 +1200)
link() is in SUSv2 and all targeted Unix systems have it.  We have
replacement code for Windows that doesn't require a configure probe.
Since only Windows needs it, rename src/port/link.c to win32link.c like
other similar things.

There is no need for a vestigial HAVE_LINK macro, because we expect all
Unix and, with our replacement function, Windows systems to have it, so
we didn't have any tests around link() usage.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com

configure
configure.ac
src/include/pg_config.h.in
src/include/port.h
src/port/win32link.c [moved from src/port/link.c with 92% similarity]
src/tools/msvc/Mkvcbuild.pm
src/tools/msvc/Solution.pm

index 1f852078e7531fed45f7283e6e8ac389c57de99a..6358bdcabcd7ff00ceace7c9a44860177aa81b60 100755 (executable)
--- a/configure
+++ b/configure
@@ -16715,19 +16715,6 @@ esac
 
 fi
 
-ac_fn_c_check_func "$LINENO" "link" "ac_cv_func_link"
-if test "x$ac_cv_func_link" = xyes; then :
-  $as_echo "#define HAVE_LINK 1" >>confdefs.h
-
-else
-  case " $LIBOBJS " in
-  *" link.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS link.$ac_objext"
- ;;
-esac
-
-fi
-
 ac_fn_c_check_func "$LINENO" "mkdtemp" "ac_cv_func_mkdtemp"
 if test "x$ac_cv_func_mkdtemp" = xyes; then :
   $as_echo "#define HAVE_MKDTEMP 1" >>confdefs.h
@@ -17059,6 +17046,12 @@ esac
  ;;
 esac
 
+  case " $LIBOBJS " in
+  *" win32link.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS win32link.$ac_objext"
+ ;;
+esac
+
   case " $LIBOBJS " in
   *" win32ntdll.$ac_objext "* ) ;;
   *) LIBOBJS="$LIBOBJS win32ntdll.$ac_objext"
index ca0c65fbd9acbf0231ab87c46833cdcb30971a1d..3cf42d1ce49d556b81334a37076d97debd569d4b 100644 (file)
@@ -1877,7 +1877,6 @@ AC_REPLACE_FUNCS(m4_normalize([
    getopt
    getpeereid
    inet_aton
-   link
    mkdtemp
    pread
    pwrite
@@ -1957,6 +1956,7 @@ if test "$PORTNAME" = "win32"; then
   AC_LIBOBJ(win32dlopen)
   AC_LIBOBJ(win32env)
   AC_LIBOBJ(win32error)
+  AC_LIBOBJ(win32link)
   AC_LIBOBJ(win32ntdll)
   AC_LIBOBJ(win32security)
   AC_LIBOBJ(win32setlocale)
index 15e01efa068728614f8bdbeb8fd8e0644fb83daa..beb42549c1610df01cae8e30032654a2ac7be516 100644 (file)
 /* Define to 1 if you have the `zstd' library (-lzstd). */
 #undef HAVE_LIBZSTD
 
-/* Define to 1 if you have the `link' function. */
-#undef HAVE_LINK
-
 /* Define to 1 if the system has the type `locale_t'. */
 #undef HAVE_LOCALE_T
 
index 7dad6caa639923c2959ca538f990b9d2133bc31c..a219a8b8689d1a9b3caa7e0cedec72201e95d3c1 100644 (file)
@@ -402,7 +402,8 @@ extern float pg_strtof(const char *nptr, char **endptr);
 #define strtof(a,b) (pg_strtof((a),(b)))
 #endif
 
-#ifndef HAVE_LINK
+#ifdef WIN32
+/* src/port/win32link.c */
 extern int link(const char *src, const char *dst);
 #endif
 
similarity index 92%
rename from src/port/link.c
rename to src/port/win32link.c
index 1e0ccd4648a582ad0951f0a52860b7a998626642..06584790465aa32977d85c29b4d96b83e54f73c1 100644 (file)
@@ -1,21 +1,19 @@
 /*-------------------------------------------------------------------------
  *
- * link.c
+ * win32link.c
  *
  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
  * IDENTIFICATION
- *   src/port/link.c
+ *   src/port/win32link.c
  *
  *-------------------------------------------------------------------------
  */
 
 #include "c.h"
 
-#ifdef WIN32
-
 int
 link(const char *src, const char *dst)
 {
@@ -31,5 +29,3 @@ link(const char *src, const char *dst)
    else
        return 0;
 }
-
-#endif
index 266f98e2ed4d1460fc04e77b099ad22fb30d5922..1ffe6e66d5aa911f51517ab6a02ce3832708996b 100644 (file)
@@ -103,13 +103,15 @@ sub mkvcbuild
      getpeereid.c getrusage.c inet_aton.c
      getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c
      snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
-     dirent.c getopt.c getopt_long.c link.c
+     dirent.c getopt.c getopt_long.c
      pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c
      pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c
      pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c
      strerror.c tar.c
      win32dlopen.c
-     win32env.c win32error.c win32ntdll.c
+     win32env.c win32error.c
+     win32link.c
+     win32ntdll.c
      win32security.c win32setlocale.c win32stat.c);
 
    push(@pgportfiles, 'strtof.c') if ($vsVersion < '14.00');
index 71db5f60f8ac5f945612359fa72086caf8ebfe57..7806ad67d0844413938e760a257f7a37bb9c8d6a 100644 (file)
@@ -306,7 +306,6 @@ sub GenerateFiles
        HAVE_LIBXSLT                                => undef,
        HAVE_LIBZ                   => $self->{options}->{zlib} ? 1 : undef,
        HAVE_LIBZSTD                => undef,
-       HAVE_LINK                   => undef,
        HAVE_LOCALE_T               => 1,
        HAVE_LONG_INT_64            => undef,
        HAVE_LONG_LONG_INT_64       => 1,