aef7ad3d00562d077ac179075e6cf1e81c7cec82
[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 $VERSION = $VERSION = "1.00";
31 # Items to export into callers namespace by default
32 # (move infrequently used names to @EXPORT_OK below)
33 @EXPORT =
34   qw(
35      F_DUPFD F_GETFD F_GETLK F_SETFD F_GETFL F_SETFL F_SETLK F_SETLKW
36      FD_CLOEXEC F_RDLCK F_UNLCK F_WRLCK
37      O_CREAT O_EXCL O_NOCTTY O_TRUNC
38      O_APPEND O_NONBLOCK
39      O_NDELAY
40      O_RDONLY O_RDWR O_WRONLY
41      );
42 # Other items we are prepared to export if requested
43 @EXPORT_OK = qw(
44 );
45
46 sub AUTOLOAD {
47     local($constname);
48     ($constname = $AUTOLOAD) =~ s/.*:://;
49     $val = constant($constname, @_ ? $_[0] : 0);
50     if ($! != 0) {
51         if ($! =~ /Invalid/) {
52             $AutoLoader::AUTOLOAD = $AUTOLOAD;
53             goto &AutoLoader::AUTOLOAD;
54         }
55         else {
56             ($pack,$file,$line) = caller;
57             die "Your vendor has not defined Fcntl macro $constname, used at $file line $line.
58 ";
59         }
60     }
61     eval "sub $AUTOLOAD { $val }";
62     goto &$AUTOLOAD;
63 }
64
65 bootstrap Fcntl;
66
67 # Preloaded methods go here.  Autoload methods go after __END__, and are
68 # processed by the autosplit program.
69 package Fcntl; # return to package Fcntl so AutoSplit is happy
70 1;
71 __END__