This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / d_dirfd.U
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: Copyright (c) 2001, Jarkko Hietaniemi
4 ?RCS:
5 ?RCS: You may redistribute only under the terms of the Artistic License,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?RCS:
12 ?MAKE:d_dirfd: Compile cat rm Setvar i_dirent i_sysdir i_sysndir i_systypes i_stdlib
13 ?MAKE:  -pick add $@ %<
14 ?S:d_dirfd:
15 ?S:     This variable conditionally defines the HAS_DIRFD constant,
16 ?S:     which indicates to the C program that dirfd() is available
17 ?S:     to return the file descriptor of a directory stream.
18 ?S:.
19 ?C:HAS_DIRFD:
20 ?C:     This manifest constant lets the C program know that dirfd
21 ?C:     is available.
22 ?C:.
23 ?H:#$d_dirfd HAS_DIRFD          /**/
24 ?H:.
25 ?LINT:set d_dirfd
26 ?X: Can't use Inlibc because dirfd() might be a macro.
27 : Look for dirfd
28 echo " "
29 $cat >dirfd.c <<EOM
30 #include <stdio.h>
31 #$i_stdlib I_STDLIB
32 #ifdef I_STDLIB
33 #include <stdlib.h>
34 #endif
35 #$i_dirent I_DIRENT             /**/
36 #$i_sysdir I_SYS_DIR            /**/
37 #$i_sysndir I_SYS_NDIR          /**/
38 #$i_systypes I_SYS_TYPES        /**/
39 #if defined(I_SYS_TYPES)
40 #include <sys/types.h>
41 #endif
42 #if defined(I_DIRENT)
43 #include <dirent.h>
44 #else
45 #ifdef I_SYS_NDIR
46 #include <sys/ndir.h>
47 #else
48 #ifdef I_SYS_DIR
49 #ifdef hp9000s500
50 #include <ndir.h>       /* may be wrong in the future */
51 #else
52 #include <sys/dir.h>
53 #endif
54 #endif
55 #endif
56 #endif
57 int main() {
58         DIR *dirp = opendir(".");
59         if (dirfd(dirp) >= 0)
60                 exit(0);
61         else
62                 exit(1);
63 }
64 EOM
65 val=$undef
66 set dirfd
67 if eval $compile; then
68         val="$define"
69 fi
70 case "$val" in
71 $define)        echo "dirfd() found." >&4       ;;
72 *)              echo "dirfd() NOT found." >&4   ;;
73 esac
74 set d_dirfd
75 eval $setvar
76 $rm -f dirfd*
77