b9251509db20308e1a442a1199c931298cbb564a
[p5sagit/p5-mst-13.2.git] / ext / Fcntl / Fcntl.pm
1 package Fcntl;
2
3 =head1 NAME
4
5 Fcntl - load the C Fcntl.h defines
6
7 =head1 SYNOPSIS
8
9     use Fcntl;
10
11 =head1 DESCRIPTION
12
13 This module is just a translation of the C F<fnctl.h> file.
14 Unlike the old mechanism of requiring a translated F<fnctl.ph>
15 file, this uses the B<h2xs> program (see the Perl source distribution)
16 and your native C compiler.  This means that it has a 
17 far more likely chance of getting the numbers right.
18
19 =head1 NOTE
20
21 Only C<#define> symbols get translated; you must still correctly
22 pack up your own arguments to pass as args for locking functions, etc.
23
24 =cut
25
26 require Exporter;
27 use AutoLoader;
28 require DynaLoader;
29 @ISA = qw(Exporter DynaLoader);
30 # Items to export into callers namespace by default
31 # (move infrequently used names to @EXPORT_OK below)
32 @EXPORT =
33   qw(
34      F_DUPFD F_GETFD F_GETLK F_SETFD F_GETFL F_SETFL F_SETLK F_SETLKW
35      FD_CLOEXEC F_RDLCK F_UNLCK F_WRLCK
36      O_CREAT O_EXCL O_NOCTTY O_TRUNC
37      O_APPEND O_NONBLOCK
38      O_NDELAY
39      O_RDONLY O_RDWR O_WRONLY
40      );
41 # Other items we are prepared to export if requested
42 @EXPORT_OK = qw(
43 );
44
45 sub AUTOLOAD {
46     local($constname);
47     ($constname = $AUTOLOAD) =~ s/.*:://;
48     $val = constant($constname, @_ ? $_[0] : 0);
49     if ($! != 0) {
50         if ($! =~ /Invalid/) {
51             $AutoLoader::AUTOLOAD = $AUTOLOAD;
52             goto &AutoLoader::AUTOLOAD;
53         }
54         else {
55             ($pack,$file,$line) = caller;
56             die "Your vendor has not defined Fcntl macro $constname, used at $file line $line.
57 ";
58         }
59     }
60     eval "sub $AUTOLOAD { $val }";
61     goto &$AUTOLOAD;
62 }
63
64 bootstrap Fcntl;
65
66 # Preloaded methods go here.  Autoload methods go after __END__, and are
67 # processed by the autosplit program.
68 package Fcntl; # return to package Fcntl so AutoSplit is happy
69 1;
70 __END__