diff options
author | Roman Leshchinskiy <rl@cse.unsw.edu.au> | 2007-09-06 00:16:13 +0000 |
---|---|---|
committer | Roman Leshchinskiy <rl@cse.unsw.edu.au> | 2007-09-06 00:16:13 +0000 |
commit | 224a7fa07de24c67f52bc613f31ae1bf453cd7b8 (patch) | |
tree | ad942e2940d717ba576632a7124bb5dbd473c5c6 | |
parent | eeb635d0ed2346568e312ac06ce7f2f1ecb434be (diff) | |
download | haskell-224a7fa07de24c67f52bc613f31ae1bf453cd7b8.tar.gz |
Declare ctime_r on Mac OS
On Mac OS, ctime_r is not declared in time.h if _POSIX_C_SOURCE is defined. We
work around this by providing a declaration ourselves.
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | rts/RtsUtils.c | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 8dec569392..cac3d38e4b 100644 --- a/configure.ac +++ b/configure.ac @@ -1066,6 +1066,13 @@ fi dnl ** check for more functions dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too. AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r]) +dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if +dnl ** _POSIX_C_SOURCE is defined +AC_CHECK_DECLS([ctime_r], , , +[#define _POSIX_SOURCE 1 +#define _POSIX_C_SOURCE 199506L +#include <time.h>]) + dnl ** For ghc/rts/gmp: AC_CHECK_FUNCS([getpagesize]) diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c index c730d7aec4..0123531e27 100644 --- a/rts/RtsUtils.c +++ b/rts/RtsUtils.c @@ -18,6 +18,13 @@ #include <time.h> #endif +/* HACK: On Mac OS X 10.4 (at least), time.h doesn't declare ctime_r with + * _POSIX_C_SOURCE. If this is the case, we declare it ourselves. + */ +#if HAVE_CTIME_R && !HAVE_DECL_CTIME_R +extern char *ctime_r(const time_t *, char *); +#endif + #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif |