#endif
//Freebsd doesn't provide this clock_gettime flag yet, because it was added too recently (after 1993)
-#ifdef __FreeBSD__
+#if defined (CLOCK_PROF) && ! defined (CLOCK_PROCESS_CPUTIME_ID)
#define CLOCK_PROCESS_CPUTIME_ID CLOCK_PROF
#endif
-#ifdef MACOS
+#if defined(__APPLE__) && defined(__MACH__)
#include <sys/types.h>
#include <sys/sysctl.h>
#include <mach/mach_init.h>
timer->elapse.tv_sec = 0;
timer->elapse.tv_nsec = 0;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->start));
-#elif defined(HAVE_GETTIMEOFDAY) && defined(MACOS) //attempt for timing of the thread on OSX
+#elif defined(HAVE_GETTIMEOFDAY) && defined(__MACH__) && defined(__APPLE__)//attempt for timing of the thread on OSX
timer->elapse.tv_sec = 0;
timer->elapse.tv_usec = 0;
int count = THREAD_BASIC_INFO_COUNT;
timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->start));
-#elif defined(HAVE_GETTIMEOFDAY) && defined(MACOS)
+#elif defined(HAVE_GETTIMEOFDAY) && defined(__MACH__) && defined(__APPLE__)
timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
timer->elapse.tv_usec += timer->stop.tv_usec - timer->start.tv_usec;
int count = THREAD_BASIC_INFO_COUNT;
{
#ifdef HAVE_POSIX_GETTIME
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->stop));
-#elif defined(HAVE_GETTIMEOFDAY) && defined(MACOS)
+#elif defined(HAVE_GETTIMEOFDAY) && defined(__MACH__) && defined(__APPLE__)
int count = THREAD_BASIC_INFO_COUNT;
thread_basic_info_data_t thi_data;
thread_basic_info_t thi = &thi_data;