Skip to content

Commit

Permalink
Fixes build for OSX 10.4.
Browse files Browse the repository at this point in the history
This is a modified version of [email protected]'s patch,
originally applied to 3.14 and brought forward to 3.15/3.16.  The
original patch attempted to handle earlier OSX versions as well, but
that was obviously untested, since the 10.3 version of the define is
actually _TIMESPEC_DECLARED, not _TIMESPEC_DEFINED (though MacPorts
doesn't support anything older than 10.4, anyway).  It turns out that
building for 10.3 is broken for other reasons, but this patch should
at least fix this particular problem for 10.3 (and earlier?) as well
as 10.4.

Aside from expanding the #ifndef, this adds a #define _STRUCT_TIMESPEC
inside the conditional, for consistency with other such usage, even
though it's unlikely that these particular headers will be included
multiple times.

TESTED:
Verified that building for OSX 10.4 fails without this patch, and
succeeds with it.  Also tested builds for 10.5 and 10.9 (both x86 and
PPC in the former case), as well as Linux and xxxBSD builds.  Ran
regression tests in all cases except the failing 10.4 case.
  • Loading branch information
fhgwright authored and eric-s-raymond committed Feb 10, 2016
1 parent 389ad57 commit 9b1053c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,20 @@ extern "C" {
typedef int clockid_t;
#define CLOCKID_T_DEFINED
# endif
/* OS X uses _STRUCT_TIMESPEC, but no clock_gettime */
#ifndef _STRUCT_TIMESPEC
/*
* OS X 10.5 and later use _STRUCT_TIMESPEC (like other OSes)
* 10.4 uses _TIMESPEC
* 10.3 and earlier use _TIMESPEC_DECLARED
*/
#if !defined(_STRUCT_TIMESPEC) \
&& !defined(_TIMESPEC) && !defined(_TIMESPEC_DECLARED)
#define _STRUCT_TIMESPEC
struct timespec {
time_t tv_sec;
long tv_nsec;
};
#endif
/* OS X does not have clock_gettime */
#define CLOCK_REALTIME 0
int clock_gettime(clockid_t, struct timespec *);
# ifdef __cplusplus
Expand Down

0 comments on commit 9b1053c

Please sign in to comment.