This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Rely on C89 <math.h> in Perl-specific units
[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 #include <sys/dir.h>
50 #endif
51 #endif
52 #endif
53 int main() {
54         DIR *dirp = opendir(".");
55         if (dirfd(dirp) >= 0)
56                 exit(0);
57         else
58                 exit(1);
59 }
60 EOM
61 val=$undef
62 set dirfd
63 if eval $compile; then
64         val="$define"
65 fi
66 case "$val" in
67 $define)        echo "dirfd() found." >&4       ;;
68 *)              echo "dirfd() NOT found." >&4   ;;
69 esac
70 set d_dirfd
71 eval $setvar
72 $rm -f dirfd*
73