In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/45bbc013ffb5816b9483592845928fa0efc8f0ff?hp=a65dc09f8c2a74df9479cbf2883f5f3778987217>

- Log -----------------------------------------------------------------
commit 45bbc013ffb5816b9483592845928fa0efc8f0ff
Author: Tony Cook <[email protected]>
Date:   Tue Nov 15 10:15:42 2016 +1100

    avoid a declaration conflict on El Capitan with recent XCode
    
    OS X El Capitan doesn't implement the clock_gettime() or clock_getrez()
    APIs, but recent versions of XCode, which are released to El Capitan
    do include updated headers that declare those functions.
    
    This causes errors like:
    
    HiRes.xs:810:12: error: static declaration of 'clock_gettime' follows 
non-static
          declaration
    static int clock_gettime(clockid_t clock_id, struct timespec *ts) {
               ^
    
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/time.h:177:5:
 note:
          previous declaration is here
    int clock_gettime(clockid_t __clock_id, struct timespec *__tp);
        ^
    HiRes.xs:844:12: error: static declaration of 'clock_getres' follows 
non-static
          declaration
    static int clock_getres(clockid_t clock_id, struct timespec *ts) {
               ^
    
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/time.h:174:5:
 note:
          previous declaration is here
    int clock_getres(clockid_t __clock_id, struct timespec *__res);
        ^
    2 errors generated.
    
    To avoid that, define the emulation functions with our own name
    and use a macro to map the standard names to our implemnentations.
-----------------------------------------------------------------------

Summary of changes:
 dist/Time-HiRes/HiRes.xs | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/dist/Time-HiRes/HiRes.xs b/dist/Time-HiRes/HiRes.xs
index d0cbff5..a8d26c7 100644
--- a/dist/Time-HiRes/HiRes.xs
+++ b/dist/Time-HiRes/HiRes.xs
@@ -807,7 +807,7 @@ static int darwin_time_init() {
 }
 
 #ifdef TIME_HIRES_CLOCK_GETTIME_EMULATION
-static int clock_gettime(clockid_t clock_id, struct timespec *ts) {
+static int th_clock_gettime(clockid_t clock_id, struct timespec *ts) {
   if (darwin_time_init() && timebase_info.denom) {
     switch (clock_id) {
       case CLOCK_REALTIME:
@@ -838,10 +838,13 @@ static int clock_gettime(clockid_t clock_id, struct 
timespec *ts) {
   SETERRNO(EINVAL, LIB_INVARG);
   return -1;
 }
+
+#define clock_gettime(clock_id, ts) th_clock_gettime((clock_id), (ts))
+
 #endif /* TIME_HIRES_CLOCK_GETTIME_EMULATION */
 
 #ifdef TIME_HIRES_CLOCK_GETRES_EMULATION
-static int clock_getres(clockid_t clock_id, struct timespec *ts) {
+static int th_clock_getres(clockid_t clock_id, struct timespec *ts) {
   if (darwin_time_init() && timebase_info.denom) {
     switch (clock_id) {
       case CLOCK_REALTIME:
@@ -860,10 +863,12 @@ static int clock_getres(clockid_t clock_id, struct 
timespec *ts) {
   SETERRNO(EINVAL, LIB_INVARG);
   return -1;
 }
+
+#define clock_getres(clock_id, ts) th_clock_getres((clock_id), (ts))
 #endif /* TIME_HIRES_CLOCK_GETRES_EMULATION */
 
 #ifdef TIME_HIRES_CLOCK_NANOSLEEP_EMULATION
-static int clock_nanosleep(clockid_t clock_id, int flags,
+static int th_clock_nanosleep(clockid_t clock_id, int flags,
                           const struct timespec *rqtp,
                           struct timespec *rmtp) {
   if (darwin_time_init()) {
@@ -900,6 +905,10 @@ static int clock_nanosleep(clockid_t clock_id, int flags,
   SETERRNO(EINVAL, LIB_INVARG);
   return -1;
 }
+
+#define clock_nanosleep(clock_id, flags, rqtp, rmtp) \
+  th_clock_nanosleep((clock_id), (flags), (rqtp), (rmtp))
+
 #endif /* TIME_HIRES_CLOCK_NANOSLEEP_EMULATION */
 
 #endif /* PERL_DARWIN */

--
Perl5 Master Repository

Reply via email to