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   421337 use strict;
  5         52  
  5         151  
4 5     5   29 use warnings;
  5         10  
  5         140  
5 5     5   27 use Carp;
  5         9  
  5         5370  
6              
7             require Exporter;
8              
9             our $VERSION = '0.20_04';
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 preadv2 ptsname pwrite pwritev pwritev2 random read readlink readlinkat
31             readv realpath remainder remove remquo rename renameat rmdir round scalbn
32             seed48 setegid seteuid setgid setitimer setpriority setregid setreuid setsid
33             setuid setutxent sighold sigignore signbit sigpause sigrelse sin sinh srand48
34             srandom stat strptime symlink symlinkat sync tan tanh tgamma timer_create
35             timer_delete timer_getoverrun timer_gettime timer_settime trunc truncate
36             ttyname unlink 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 RWF_DSYNC
61             RWF_HIPRI RWF_SYNC RWF_NOWAIT RWF_APPEND S_IFMT S_IFBLK S_IFCHR S_IFIFO
62             S_IFREG S_IFDIR S_IFLNK S_IFSOCK S_ISUID S_ISGID S_IRWXU S_IRUSR S_IWUSR
63             S_IXUSR S_IRWXG S_IRGRP S_IWGRP S_IXGRP S_IRWXO S_IROTH S_IWOTH S_IXOTH
64             S_ISVTX SEEK_SET SEEK_CUR SEEK_END SEEK_DATA SEEK_HOLE TIMER_ABSTIME
65             USER_PROCESS UTIME_NOW UTIME_OMIT F_OK R_OK W_OK X_OK
66             );
67              
68             our @ISA = qw(Exporter);
69              
70             our @EXPORT = ();
71             our @EXPORT_OK = (@_functions, @_constants);
72              
73             our %EXPORT_TAGS = (
74             # at: Older Perls don't have variable length lookbehind, hence two regexen
75             # for functions.
76             'at' => [grep(/^(?:AT|RESOLVE)_/, @_constants),
77             grep(/at$/ && !/^l?stat$/, @_functions), 'openat2'],
78             'id' => [grep /^[gs]et.+id$/, @_functions],
79             'is' => [grep /^is/, @_functions],
80             'rw' => [qw(read write readv writev)],
81             'prw' => [qw(pread preadv preadv2 pwrite pwritev pwritev2)],
82             'clock' => [grep(/^CLOCK_/, @_constants), grep(/^clock/, @_functions)],
83             'fcntl' => [grep /^(?:[FORWX]|FD|POSIX_FADV|SEEK)_/, @_constants],
84             'fnm' => [grep(/^FNM_/, @_constants), 'fnmatch'],
85             'stat_h' => [grep /^(?:S_I|UTIME_)/, @_constants],
86             'time_h' => [grep /^(?:CLOCK|TIMER)_/, @_constants],
87             'timer' => [grep(/^TIMER_/, @_constants), grep(/^timer_/, @_functions)],
88             );
89              
90             my %depre = (
91             atol => 'atoi',
92             atoll => 'atoi',
93             ldiv => 'div',
94             fchdir => 'chdir',
95             fchmod => 'chmod',
96             fchown => 'chown',
97             ftruncate => 'truncate',
98             );
99              
100             push @EXPORT_OK, keys %depre;
101              
102             our $AUTOLOAD;
103             sub AUTOLOAD {
104 0     0   0 my ($func) = ($AUTOLOAD =~ /.*::(.*)/);
105 0 0       0 die "POSIX::2008.xs has failed to load\n" if $func eq 'constant';
106 0         0 constant($func);
107             }
108              
109             sub import {
110 5     5   69 my $this = shift;
111              
112             # This is a hack that allows us to import only the non-XS portion of the
113             # module in Makefile.PL to get the constants for WriteConstants(). It's not
114             # intended for use in actual code!
115 5 50 66     35 if (@_ && $_[0] eq '-noxs') {
116 0         0 shift;
117             }
118             else {
119 5         39 require XSLoader;
120 5         7283 XSLoader::load('POSIX::2008', $XS_VERSION);
121              
122 5         63 while (my ($func, $repl) = each %depre) {
123 35         89 my $package_func = __PACKAGE__."::${func}";
124 35         66 my $package_repl = __PACKAGE__."::${repl}";
125 5     5   43 no strict 'refs';
  5         11  
  5         916  
126 35         222 *{$package_func} = sub {
127 0     0   0 carp("${package_func}() is deprecated, use ${package_repl}() instead");
128 0         0 &{*{$package_repl}};
  0         0  
  0         0  
129             }
130 35         117 }
131             }
132              
133 5         6305 __PACKAGE__->export_to_level(1, $this, @_);
134             }
135              
136             1;