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
This commit is contained in:
alkondratenko@gmail.com 2013-07-20 21:35:14 +00:00
parent ac354636de
commit d8e12e94ea
2 changed files with 23 additions and 0 deletions

View File

@ -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,,

View File

@ -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) {