This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[RT #129789] Time::HiRes: fix compilation on darwin
authorSergey Aleynikov <sergey.aleynikov@gmail.com>
Wed, 5 Oct 2016 15:29:34 +0000 (18:29 +0300)
committerAaron Crane <arc@cpan.org>
Sun, 16 Oct 2016 11:04:26 +0000 (12:04 +0100)
Commit 1c5665476f0d7250c7d93f82eab2b7cda1e6937f added explicit cast
for one of the clock_gettime() arguments, but darwin lacks clockid_t,
so update emulation layer to match function prototype too.

dist/Time-HiRes/HiRes.xs

index 1b9ee23..de63b93 100644 (file)
@@ -802,8 +802,10 @@ static int darwin_time_init() {
   return success;
 }
 
+typedef int clockid_t; /* to conform with POSIX prototypes */
+
 #ifdef TIME_HIRES_CLOCK_GETTIME_EMULATION
-static int clock_gettime(int clock_id, struct timespec *ts) {
+static int clock_gettime(clockid_t clock_id, struct timespec *ts) {
   if (darwin_time_init() && timebase_info.denom) {
     switch (clock_id) {
       case CLOCK_REALTIME:
@@ -837,7 +839,7 @@ static int clock_gettime(int clock_id, struct timespec *ts) {
 #endif /* TIME_HIRES_CLOCK_GETTIME_EMULATION */
 
 #ifdef TIME_HIRES_CLOCK_GETRES_EMULATION
-static int clock_getres(int clock_id, struct timespec *ts) {
+static int clock_getres(clockid_t clock_id, struct timespec *ts) {
   if (darwin_time_init() && timebase_info.denom) {
     switch (clock_id) {
       case CLOCK_REALTIME:
@@ -859,7 +861,7 @@ static int clock_getres(int clock_id, struct timespec *ts) {
 #endif /* TIME_HIRES_CLOCK_GETRES_EMULATION */
 
 #ifdef TIME_HIRES_CLOCK_NANOSLEEP_EMULATION
-static int clock_nanosleep(int clock_id, int flags,
+static int clock_nanosleep(clockid_t clock_id, int flags,
                           const struct timespec *rqtp,
                           struct timespec *rmtp) {
   if (darwin_time_init()) {