diff options
author | alkondratenko@gmail.com <alkondratenko@gmail.com@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2013-07-20 21:35:14 +0000 |
---|---|---|
committer | alkondratenko@gmail.com <alkondratenko@gmail.com@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2013-07-20 21:35:14 +0000 |
commit | d8e12e94ea09eaf8b040c6887f75cdf832b5619b (patch) | |
tree | eefa5b74ee0bc4abae3612f9dc90dff262fcc153 | |
parent | ac354636de8a4f11e4fde679b52e9f58fda0e079 (diff) | |
download | gperftools-d8e12e94ea09eaf8b040c6887f75cdf832b5619b.tar.gz |
issue-549: handle most recent mingw that has sleep and nanosleep
I.e. we have to check their presence in configure and in case of their
presence we have to avoid re-defining then in window's port.h
git-svn-id: http://gperftools.googlecode.com/svn/trunk@223 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | src/windows/port.h | 14 |
2 files changed, 23 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 033f224..06da531 100644 --- a/configure.ac +++ b/configure.ac @@ -354,6 +354,15 @@ AC_PROGRAM_INVOCATION_NAME # Make the install prefix available, to figure out where to look for pprof AC_INSTALL_PREFIX +dnl only very recent mingw has sleep and nanosleep +case "$host" in + *-mingw*) + AC_CHECK_DECLS([sleep], [], [], [#include <unistd.h>]) + AC_CHECK_DECLS([nanosleep], [], [], [#include <time.h>]) + ;; +esac + + # For windows, this has a non-trivial value (__declspec(export)), but any # system that uses configure wants this to be the empty string. AC_DEFINE(PERFTOOLS_DLL_DECL,, diff --git a/src/windows/port.h b/src/windows/port.h index 0da2eee..6c90a8d 100644 --- a/src/windows/port.h +++ b/src/windows/port.h @@ -413,10 +413,17 @@ EXTERN_C int getpagesize(); /* in port.cc */ inline void srandom(unsigned int seed) { srand(seed); } inline long random(void) { return rand(); } + +#ifndef HAVE_DECL_SLEEP +#define HAVE_DECL_SLEEP 0 +#endif + +#if !HAVE_DECL_SLEEP inline unsigned int sleep(unsigned int seconds) { Sleep(seconds * 1000); return 0; } +#endif // mingw64 seems to define timespec (though mingw.org mingw doesn't), // protected by the _TIMESPEC_DEFINED macro. @@ -427,10 +434,17 @@ struct timespec { }; #endif +#ifndef HAVE_DECL_NANOSLEEP +#define HAVE_DECL_NANOSLEEP 0 +#endif + +// latest mingw64 has nanosleep. Earlier mingw and MSVC do not +#if !HAVE_DECL_NANOSLEEP inline int nanosleep(const struct timespec *req, struct timespec *rem) { Sleep(req->tv_sec * 1000 + req->tv_nsec / 1000000); return 0; } +#endif #ifndef __MINGW32__ inline long long int strtoll(const char *nptr, char **endptr, int base) { |