File Coverage

blib/lib/POSIX/2008.pm
Criterion Covered Total %
statement 22 30 73.3
branch 1 4 25.0
condition 2 3 66.6
subroutine 5 7 71.4
pod n/a
total 30 44 68.1


line stmt bran cond sub pod time code
1             package POSIX::2008;
2              
3 5     5   432879 use strict;
  5         47  
  5         145  
4 5     5   25 use warnings;
  5         14  
  5         138  
5 5     5   29 use Carp;
  5         9  
  5         4769  
6              
7             require Exporter;
8              
9             our $VERSION = '0.20_03';
10             our $XS_VERSION = $VERSION;
11             $VERSION = eval $VERSION; # so "use Module 0.002" won't warn on underscore
12              
13             our @_functions = qw(
14             a64l abort abs access acos acosh alarm asin asinh atan atan2 atanh atof atoi
15             basename cabs cacos cacosh carg casin casinh catan catanh catclose catgets
16             catopen cbrt ccos ccosh ceil cexp chdir chmod chown cimag clock
17             clock_getcpuclockid clock_getres clock_gettime clock_nanosleep clock_settime
18             clog close confstr conj copysign cos cosh cpow cproj creal csin csinh csqrt
19             ctan ctanh dirname div dlclose dlerror dlopen dlsym drand48 endutxent erand48
20             erf erfc exp exp2 expm1 faccessat fchmodat fchownat fdatasync fdim fdopen
21             fdopendir fegetround fesetround ffs floor fma fmax fmin fmod fnmatch
22             fpclassify fstatat fsync futimens getdate getdate_err getegid geteuid getgid
23             gethostid gethostname getitimer getpriority getsid getuid getutxent getutxid
24             getutxline hypot ilogb isalnum isalpha isascii isatty isblank iscntrl isdigit
25             isfinite isgraph isgreaterequal isinf isless islessequal islessgreater islower
26             isnan isnormal isprint ispunct isspace isunordered isupper isxdigit j0 j1 jn
27             jrand48 killpg l64a ldexp lgamma link linkat log log1p log2 logb lrand48
28             lround lstat mkdir mkdirat mkdtemp mkfifo mkfifoat mknod mknodat mkstemp
29             mrand48 nanosleep nearbyint nextafter nice nrand48 open openat openat2 pread
30             preadv ptsname pwrite pwritev random read readlink readlinkat readv realpath
31             remainder remove remquo rename renameat rmdir round scalbn seed48 setegid
32             seteuid setgid setitimer setpriority setregid setreuid setsid setuid setutxent
33             sighold sigignore signbit sigpause sigrelse sin sinh srand48 srandom stat
34             strptime symlink symlinkat sync tan tanh tgamma timer_create timer_delete
35             timer_getoverrun timer_gettime timer_settime trunc truncate ttyname unlink
36             unlinkat utimensat write writev y0 y1 yn
37             );
38              
39             our @_constants = qw(
40             AT_EACCESS AT_EMPTY_PATH AT_FDCWD AT_NO_AUTOMOUNT AT_REMOVEDIR
41             AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW BOOT_TIME CLOCK_BOOTTIME CLOCK_HIGHRES
42             CLOCK_MONOTONIC CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
43             CLOCK_MONOTONIC_PRECISE CLOCK_MONOTONIC_RAW CLOCK_PROCESS_CPUTIME_ID
44             CLOCK_REALTIME CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST
45             CLOCK_REALTIME_PRECISE CLOCK_SOFTTIME CLOCK_THREAD_CPUTIME_ID CLOCK_UPTIME
46             CLOCK_UPTIME_FAST CLOCK_UPTIME_PRECISE _CS_GNU_LIBC_VERSION
47             _CS_GNU_LIBPTHREAD_VERSION _CS_PATH DEAD_PROCESS F_DUPFD F_DUPFD_CLOEXEC
48             F_GETFD F_SETFD F_GETFL F_SETFL F_GETLK F_SETLK F_SETLKW F_GETOWN F_SETOWN
49             F_RDLCK F_UNLCK F_WRLCK FD_CLOEXEC FE_TONEAREST FE_TOWARDZERO FE_UPWARD
50             FE_DOWNWARD FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW
51             FE_ALL_EXCEPT FNM_CASEFOLD FNM_FILE_NAME FNM_LEADING_DIR FNM_NOESCAPE
52             FNM_NOMATCH FNM_PATHNAME FNM_PERIOD FP_INFINITE FP_NAN FP_NORMAL FP_SUBNORMAL
53             FP_ZERO INIT_PROCESS ITIMER_PROF ITIMER_REAL ITIMER_VIRTUAL LOGIN_PROCESS
54             NEW_TIME O_ACCMODE O_APPEND O_CLOEXEC O_CREAT O_DIRECTORY O_DSYNC O_EXEC
55             O_NOCTTY O_NOFOLLOW O_NONBLOCK O_RDONLY O_RDWR O_RSYNC O_SEARCH O_SYNC
56             O_TMPFILE O_TRUNC O_TTY_INIT O_WRONLY OLD_TIME POSIX_FADV_NORMAL
57             POSIX_FADV_SEQUENTIAL POSIX_FADV_RANDOM POSIX_FADV_NOREUSE POSIX_FADV_WILLNEED
58             POSIX_FADV_DONTNEED PRIO_PROCESS PRIO_PGRP PRIO_USER RESOLVE_BENEATH
59             RESOLVE_IN_ROOT RESOLVE_NO_MAGICLINKS RESOLVE_NO_SYMLINKS RESOLVE_NO_XDEV
60             RESOLVE_CACHED RTLD_GLOBAL RTLD_LAZY RTLD_LOCAL RTLD_NOW RUN_LVL S_IFMT
61             S_IFBLK S_IFCHR S_IFIFO S_IFREG S_IFDIR S_IFLNK S_IFSOCK S_ISUID S_ISGID
62             S_IRWXU S_IRUSR S_IWUSR S_IXUSR S_IRWXG S_IRGRP S_IWGRP S_IXGRP S_IRWXO
63             S_IROTH S_IWOTH S_IXOTH S_ISVTX SEEK_SET SEEK_CUR SEEK_END TIMER_ABSTIME
64             USER_PROCESS UTIME_NOW UTIME_OMIT F_OK R_OK W_OK X_OK
65             );
66              
67             our @ISA = qw(Exporter);
68              
69             our @EXPORT = ();
70             our @EXPORT_OK = (@_functions, @_constants);
71              
72             our %EXPORT_TAGS = (
73             # at: Older Perls don't have variable length lookbehind, hence two regexen
74             # for functions.
75             'at' => [grep(/^(?:AT|RESOLVE)_/, @_constants),
76             grep(/at$/ && !/^l?stat$/, @_functions), 'openat2'],
77             'id' => [grep /^[gs]et.+id$/, @_functions],
78             'is' => [grep /^is/, @_functions],
79             'rw' => [qw(read write readv writev)],
80             'prw' => [qw(pread preadv pwrite pwritev)],
81             'clock' => [grep(/^CLOCK_/, @_constants), grep(/^clock/, @_functions)],
82             'fcntl' => [grep /^(?:[FORWX]|FD|POSIX_FADV|SEEK)_/, @_constants],
83             'fnm' => [grep(/^FNM_/, @_constants), 'fnmatch'],
84             'stat_h' => [grep /^(?:S_I|UTIME_)/, @_constants],
85             'time_h' => [grep /^(?:CLOCK|TIMER)_/, @_constants],
86             'timer' => [grep(/^TIMER_/, @_constants), grep(/^timer_/, @_functions)],
87             );
88              
89             my %depre = (
90             atol => 'atoi',
91             atoll => 'atoi',
92             ldiv => 'div',
93             fchdir => 'chdir',
94             fchmod => 'chmod',
95             fchown => 'chown',
96             ftruncate => 'truncate',
97             );
98              
99             push @EXPORT_OK, keys %depre;
100              
101             our $AUTOLOAD;
102             sub AUTOLOAD {
103 0     0   0 my ($func) = ($AUTOLOAD =~ /.*::(.*)/);
104 0 0       0 die "POSIX::2008.xs has failed to load\n" if $func eq 'constant';
105 0         0 constant($func);
106             }
107              
108             sub import {
109 5     5   55 my $this = shift;
110              
111             # This is a hack that allows us to import only the non-XS portion of the
112             # module in Makefile.PL to get the constants for WriteConstants(). It's not
113             # intended for use in actual code!
114 5 50 66     80 if (@_ && $_[0] eq '-noxs') {
115 0         0 shift;
116             }
117             else {
118 5         44 require XSLoader;
119 5         7264 XSLoader::load('POSIX::2008', $XS_VERSION);
120              
121 5         119 while (my ($func, $repl) = each %depre) {
122 35         84 my $package_func = __PACKAGE__."::${func}";
123 35         65 my $package_repl = __PACKAGE__."::${repl}";
124 5     5   39 no strict 'refs';
  5         16  
  5         886  
125 35         230 *{$package_func} = sub {
126 0     0   0 carp("${package_func}() is deprecated, use ${package_repl}() instead");
127 0         0 &{*{$package_repl}};
  0         0  
  0         0  
128             }
129 35         118 }
130             }
131              
132 5         6407 __PACKAGE__->export_to_level(1, $this, @_);
133             }
134              
135             1;