In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/56ed632cd2df6011bd67673f4f87d04f29bfaeb1?hp=d18ec13df17c5e14d3ecc903ff761bc2254269bb>
- Log ----------------------------------------------------------------- commit 56ed632cd2df6011bd67673f4f87d04f29bfaeb1 Author: Dagfinn Ilmari Mannsåker <[email protected]> Date: Thu Oct 20 15:23:07 2016 +0100 Use CLOCK_REALTIME in clock_nanosleep check For consistency with the other checks that use CLOCK_* constants. M dist/Time-HiRes/Makefile.PL commit 605b4dbe4a3c395a201b795317b61e743c2fb146 Author: Dagfinn Ilmari Mannsåker <[email protected]> Date: Thu Oct 20 15:17:46 2016 +0100 Fix up includes in Time-HiRes Makefile.PL checks This aligns the includes with what the POSIX, Linux and FreeBSD manpages say they should be. M dist/Time-HiRes/Makefile.PL commit 2979fdf32233b7325cc8175898388636697a355f Author: Dagfinn Ilmari Mannsåker <[email protected]> Date: Mon Oct 17 11:39:56 2016 +0100 Use clockid_t throughout in Time::HiRes Commit 69d1f2c2 makes clockid_t available on all platforms, so use that for function arguments throughout instead of casting in the clock_gettime() calls. This particularly needs smoking with C++ on platforms that provide clock_gettime but not clockid_t. M dist/Time-HiRes/HiRes.xs M dist/Time-HiRes/typemap ----------------------------------------------------------------------- Summary of changes: dist/Time-HiRes/HiRes.xs | 16 ++++++++-------- dist/Time-HiRes/Makefile.PL | 13 ++++++++----- dist/Time-HiRes/typemap | 2 ++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/dist/Time-HiRes/HiRes.xs b/dist/Time-HiRes/HiRes.xs index eb48aee..d0cbff5 100644 --- a/dist/Time-HiRes/HiRes.xs +++ b/dist/Time-HiRes/HiRes.xs @@ -1435,7 +1435,7 @@ utime(accessed, modified, ...) NV clock_gettime(clock_id = CLOCK_REALTIME) - int clock_id + clockid_t clock_id PREINIT: struct timespec ts; int status = -1; @@ -1443,7 +1443,7 @@ clock_gettime(clock_id = CLOCK_REALTIME) #ifdef TIME_HIRES_CLOCK_GETTIME_SYSCALL status = syscall(SYS_clock_gettime, clock_id, &ts); #else - status = clock_gettime((clockid_t)clock_id, &ts); + status = clock_gettime(clock_id, &ts); #endif RETVAL = status == 0 ? ts.tv_sec + (NV) ts.tv_nsec / NV_1E9 : -1; @@ -1454,7 +1454,7 @@ clock_gettime(clock_id = CLOCK_REALTIME) NV clock_gettime(clock_id = 0) - int clock_id + clockid_t clock_id CODE: PERL_UNUSED_ARG(clock_id); croak("Time::HiRes::clock_gettime(): unimplemented in this platform"); @@ -1468,7 +1468,7 @@ clock_gettime(clock_id = 0) NV clock_getres(clock_id = CLOCK_REALTIME) - int clock_id + clockid_t clock_id PREINIT: int status = -1; struct timespec ts; @@ -1476,7 +1476,7 @@ clock_getres(clock_id = CLOCK_REALTIME) #ifdef TIME_HIRES_CLOCK_GETRES_SYSCALL status = syscall(SYS_clock_getres, clock_id, &ts); #else - status = clock_getres((clockid_t)clock_id, &ts); + status = clock_getres(clock_id, &ts); #endif RETVAL = status == 0 ? ts.tv_sec + (NV) ts.tv_nsec / NV_1E9 : -1; @@ -1487,7 +1487,7 @@ clock_getres(clock_id = CLOCK_REALTIME) NV clock_getres(clock_id = 0) - int clock_id + clockid_t clock_id CODE: PERL_UNUSED_ARG(clock_id); croak("Time::HiRes::clock_getres(): unimplemented in this platform"); @@ -1501,7 +1501,7 @@ clock_getres(clock_id = 0) NV clock_nanosleep(clock_id, nsec, flags = 0) - int clock_id + clockid_t clock_id NV nsec int flags PREINIT: @@ -1522,7 +1522,7 @@ clock_nanosleep(clock_id, nsec, flags = 0) NV clock_nanosleep(clock_id, nsec, flags = 0) - int clock_id + clockid_t clock_id NV nsec int flags CODE: diff --git a/dist/Time-HiRes/Makefile.PL b/dist/Time-HiRes/Makefile.PL index 340ee99..9060fa2 100644 --- a/dist/Time-HiRes/Makefile.PL +++ b/dist/Time-HiRes/Makefile.PL @@ -290,6 +290,7 @@ sub has_clock_xxx_syscall { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#include <time.h> #include <$SYSCALL_H> int main(int argc, char** argv) { @@ -309,6 +310,7 @@ sub has_clock_xxx { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#include <time.h> int main(int argc, char** argv) { struct timespec ts; @@ -325,6 +327,7 @@ sub has_clock { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#include <time.h> int main(int argc, char** argv) { clock_t tictoc; @@ -348,7 +351,8 @@ int main(int argc, char** argv) struct timespec ts2; ts1.tv_sec = 0; ts1.tv_nsec = 750000000;; - ret = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts1, &ts2); + /* All implementations are supposed to support CLOCK_REALTIME. */ + ret = clock_nanosleep(CLOCK_REALTIME, 0, &ts1, &ts2); ret == 0 ? exit(0) : exit(errno ? errno : -1); } EOM @@ -360,7 +364,7 @@ sub has_futimens { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" -#include <sys/time.h> +#include <sys/stat.h> int main(int argc, char** argv) { int ret; @@ -377,7 +381,7 @@ sub has_utimensat{ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" -#include <sys/time.h> +#include <sys/stat.h> #include <fcntl.h> int main(int argc, char** argv) { @@ -395,8 +399,7 @@ sub has_clockid_t{ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" -#include <sys/time.h> -#include <fcntl.h> +#include <time.h> int main(int argc, char** argv) { clockid_t id = CLOCK_REALTIME; diff --git a/dist/Time-HiRes/typemap b/dist/Time-HiRes/typemap index 1124eb6..3fa91f3 100644 --- a/dist/Time-HiRes/typemap +++ b/dist/Time-HiRes/typemap @@ -28,6 +28,8 @@ AV * T_AVREF HV * T_HVREF CV * T_CVREF +clockid_t T_IV + IV T_IV UV T_UV NV T_NV -- Perl5 Master Repository
