[Coin-discuss] COIN on a Mac

ScottWelz at aol.com ScottWelz at aol.com
Tue Jan 7 01:07:28 EST 2003


Matt,

It looks like Darwin does not use glibc.   Unfortunately, I haven't been able 
to nail down exactly which libraries are used.   In any case, I found at 
least one other instance where someone porting something to Darwin had to 
include <sys/time.h> (before including <sys/resource.h>) in order to use 
getrusage().

Laci,

I was able to get this to run on Darwin, but had to make the changes shown 
below because of the issue described above.

// Copyright (C) 2002, International Business Machines
// Corporation and others.   All Rights Reserved.

#ifndef _CoinTime_hpp
#define _CoinTime_hpp

//############################################################################

#

#include <ctime>
#if defined(_MSC_VER)
// Turn off compiler warning about long names
#   pragma warning(disable:4786)
#elif defined(__MACH__)                     // Added these lines
#   include <sys/time.h>                     // Added these lines
#   include <sys/resource.h>                 // Added these lines
#else
#   include <sys/resource.h>
#endif

//############################################################################

#

static inline double CoinCpuTime()
{
   double cpu_temp;
#if defined(_MSC_VER)
   unsigned int ticksnow;         /* clock_t is same as int */
 
   ticksnow = (unsigned int)clock();
 
   cpu_temp = (double)((double)ticksnow/CLOCKS_PER_SEC);
#else
   struct rusage usage;
   getrusage(RUSAGE_SELF,&usage);
   cpu_temp = usage.ru_utime.tv_sec;
   cpu_temp += 1.0e-6*((double) usage.ru_utime.tv_usec);
#endif
   return cpu_temp;
}

//############################################################################

#

#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20030107/44ef526a/attachment.html>


More information about the Coin-discuss mailing list