]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
build: port to AIX
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jun 2015 00:33:54 +0000 (17:33 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jun 2015 07:46:13 +0000 (00:46 -0700)
Problems reported by Michael Felt, and and part of this fix taken
from code suggested by Pádraig Brady in:
http://bugs.gnu.org/20733#112
* configure.ac (stdbuf_supported): Check for warnings, and
for -fPIC and -shared, for AIX.
* src/stat.c (STRUCT_STATVFS): Define to struct statvfs64 if
STATFS is statvfs64.
* src/sync.c (sync_arg) [_AIX]: Open in write mode,
since AIX fsync doesn't work on read-only file descriptors.
* tests/misc/wc-parallel.sh: Skip test if xargs -P does not work.

configure.ac
src/stat.c
src/sync.c
tests/misc/wc-parallel.sh

index c1599831c6b9f389cad7cab7a1f5692a85b4c6f6..a50992d042dacc4407499549aa5269c4b31973d6 100644 (file)
@@ -454,8 +454,17 @@ if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
   gl_ADD_PROG([optional_bin_progs], [df])
 fi
 
-AC_MSG_CHECKING([whether this is system supports stdbuf])
-AC_COMPILE_IFELSE(
+ac_save_CFLAGS=$CFLAGS
+ac_save_LDFLAGS=$LDFLAGS
+# Detect warnings about ignored "constructor" attributes.
+gl_WARN_ADD([-Werror], [CFLAGS])
+gl_WARN_ADD([-errwarn], [CFLAGS])
+# Put this message here, after gl_WARN_ADD's chatter.
+AC_MSG_CHECKING([whether this system supports stdbuf])
+CFLAGS="-fPIC $CFLAGS"
+LDFLAGS="-shared $LDFLAGS"
+stdbuf_supported=no
+AC_LINK_IFELSE(
   [AC_LANG_PROGRAM([[
     static int stdbuf = 0;
 
@@ -470,12 +479,13 @@ AC_COMPILE_IFELSE(
     }]],[[
     return !(stdbuf == 1);]])
   ],
-  [stdbuf_supported=yes],
-  [stdbuf_supported=no])
+  [stdbuf_supported=yes])
 AC_MSG_RESULT([$stdbuf_supported])
 if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
   gl_ADD_PROG([optional_bin_progs], [stdbuf])
 fi
+CFLAGS=$ac_save_CFLAGS
+LDFLAGS=$ac_save_LDFLAGS
 
 ############################################################################
 
index 4b5aff71fd110c227173b22bca489b770bc1a658..6d2366539bb2b26b6d0a07a875c9e6ce6f4d56e5 100644 (file)
 #include "xvasprintf.h"
 
 #if USE_STATVFS
-# define STRUCT_STATVFS struct statvfs
 # define STRUCT_STATXFS_F_FSID_IS_INTEGER STRUCT_STATVFS_F_FSID_IS_INTEGER
 # define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATVFS_F_TYPE
 # if HAVE_STRUCT_STATVFS_F_NAMEMAX
 #  define SB_F_NAMEMAX(S) ((S)->f_namemax)
 # endif
 # if ! STAT_STATVFS && STAT_STATVFS64
+#  define STRUCT_STATVFS struct statvfs64
 #  define STATFS statvfs64
 # else
+#  define STRUCT_STATVFS struct statvfs
 #  define STATFS statvfs
 # endif
 # define STATFS_FRSIZE(S) ((S)->f_frsize)
index 85d77c092ae9fe9bb1ba7a1f759fdab14a4d00f1..5e1dbb8c61eb64658da60603f04a899f4f3adda1 100644 (file)
@@ -91,24 +91,34 @@ static bool
 sync_arg (enum sync_mode mode, char const *file)
 {
   bool ret = true;
+  int open_flags = O_RDONLY | O_NONBLOCK;
   int fd;
 
+#ifdef _AIX
+  /* AIX 7.1 fsync requires write access to file.  */
+  if (mode == MODE_FILE)
+    open_flags = O_WRONLY | O_NONBLOCK;
+#endif
+
   /* Note O_PATH might be supported with syncfs(),
      though as of Linux 3.18 is not.  */
-  if ((fd = open (file, O_RDONLY | O_NONBLOCK)) < 0)
+  fd = open (file, open_flags);
+  if (fd < 0)
     {
       /* Use the O_RDONLY errno, which is significant
          with directories for example.  */
       int rd_errno = errno;
-      if ((fd = open (file, O_WRONLY | O_NONBLOCK)) < 0)
+      if (open_flags != (O_WRONLY | O_NONBLOCK))
+        fd = open (file, O_WRONLY | O_NONBLOCK);
+      if (fd < 0)
         error (0, rd_errno, _("error opening %s"), quote (file));
       return false;
     }
 
   /* We used O_NONBLOCK above to not hang with fifos,
      so reset that here.  */
-  int fdflags;
-  if ((fdflags = fcntl (fd, F_GETFL)) == -1
+  int fdflags = fcntl (fd, F_GETFL);
+  if (fdflags == -1
       || fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
     {
       error (0, errno, _("couldn't reset non-blocking mode %s"), quote (file));
index 2d1e9f4053ff20c1e1365967bf9c14ed50fc5622..98c36b9faa354fd20349b195e91765c400f5960a 100755 (executable)
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ wc
 
+if xargs -P2 </dev/null >/dev/null 2>&1
+  skip_ 'xargs -P is required'
+fi
+
 (mkdir tmp && cd tmp && seq 2000 | xargs touch)
 
 # This will output at least 16KiB per process