annotate m4/isapipe.m4 @ 17480:f40b3156a43e

selinux-at: omit unnecessary include * lib/selinux-at.c: Don't include dosname.h; not needed, since this source file doesn't use its macros, and subsidiary files that use the macros already include it.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 23 Aug 2013 13:53:46 -0700
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7233
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 # Test whether a file descriptor is a pipe.
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
3 dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
7233
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 dnl This file is free software; the Free Software Foundation
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 dnl gives unlimited permission to copy and/or distribute it,
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7 dnl with or without modifications, as long as this notice is preserved.
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
8
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9 dnl Written by Paul Eggert.
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 AC_DEFUN([gl_ISAPIPE],
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 [
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13 # OpenVMS has isapipe already, so check for it.
14988
cc7009b139e3 isapipe: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
14 AC_CHECK_FUNCS([isapipe])
cc7009b139e3 isapipe: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
15 if test $ac_cv_func_isapipe = yes; then
cc7009b139e3 isapipe: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
16 HAVE_ISAPIPE=1
cc7009b139e3 isapipe: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
17 else
cc7009b139e3 isapipe: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
18 HAVE_ISAPIPE=0
7233
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19 fi
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 ])
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22 # Prerequisites of lib/isapipe.c.
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23 AC_DEFUN([gl_PREREQ_ISAPIPE],
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
24 [
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25 AC_CACHE_CHECK([whether pipes are FIFOs (and for their link count)],
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26 [gl_cv_pipes_are_fifos],
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27 [AC_RUN_IFELSE(
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28 [AC_LANG_SOURCE(
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
29 [[#include <stdio.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
30 #include <sys/types.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
31 #include <sys/stat.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
32 #include <unistd.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
33 #ifndef S_ISFIFO
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
34 #define S_ISFIFO(m) 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
35 #endif
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
36 #ifndef S_ISSOCK
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
37 #define S_ISSOCK(m) 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
38 #endif
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
39 int
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
40 main (int argc, char **argv)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
41 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
42 int fd[2];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
43 struct stat st;
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
44 if (pipe (fd) != 0)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
45 return 1;
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
46 if (fstat (fd[0], &st) != 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
47 return 2;
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
48 if (2 <= argc && argv[1][0] == '-')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
49 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
50 char const *yesno = (S_ISFIFO (st.st_mode) ? "yes" : "no");
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
51 if (st.st_nlink <= 1)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
52 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
53 long int i = st.st_nlink;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
54 if (i != st.st_nlink)
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
55 return 3;
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
56 printf ("%s (%ld)\n", yesno, i);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
57 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
58 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
59 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
60 unsigned long int i = st.st_nlink;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
61 if (i != st.st_nlink)
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
62 return 4;
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
63 printf ("%s (%lu)\n", yesno, i);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
64 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
65 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
66 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
67 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
68 if (! S_ISFIFO (st.st_mode) && ! S_ISSOCK (st.st_mode))
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
69 return 5;
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
70 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
71 return 0;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
72 }]])],
7233
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
73 [gl_cv_pipes_are_fifos=`./conftest$ac_exeext -`
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
74 test -z "$gl_cv_pipes_are_fifos" && gl_cv_pipes_are_fifos=no],
7233
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
75 [gl_cv_pipes_are_fifos=unknown],
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
76 [gl_cv_pipes_are_fifos=cross-compiling])])
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
77
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
78 case $gl_cv_pipes_are_fifos in #(
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
79 'yes ('*')')
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 7233
diff changeset
80 AC_DEFINE([HAVE_FIFO_PIPES], [1],
7233
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
81 [Define to 1 if pipes are FIFOs, 0 if sockets. Leave undefined
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
82 if not known.]);; #(
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
83 'no ('*')')
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 7233
diff changeset
84 AC_DEFINE([HAVE_FIFO_PIPES], [0]);;
7233
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
85 esac
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
86
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
87 case $gl_cv_pipes_are_fifos in #(
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
88 *'('*')')
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
89 AC_DEFINE_UNQUOTED([PIPE_LINK_COUNT_MAX],
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
90 [`expr "$gl_cv_pipes_are_fifos" : '.*\((.*)\)'`],
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
91 [Define to the maximum link count that a true pipe can have.]);;
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
92 esac
ec85aace506a * modules/isapipe: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
93 ])