$OpenBSD: patch-provider_libserver_ZarafaCmd_cpp,v 1.18 2011/06/02 12:46:37 ajacoutot Exp $

OpenBSD does not have CLOCK_THREAD_CPUTIME_ID.

--- provider/libserver/ZarafaCmd.cpp.orig	Wed Apr 20 19:51:49 2011
+++ provider/libserver/ZarafaCmd.cpp	Mon May  2 12:47:53 2011
@@ -731,11 +731,11 @@ double GetTimeOfDay();
 
 #define SOAP_ENTRY_FUNCTION_HEADER(resultvar, fname) \
     ECRESULT		er = erSuccess; \
-    struct timespec	startTimes = {0}, endTimes = {0};	\
+    struct tms		startTimes, endTimes; \
     double			dblStart = GetTimeOfDay(); \
     ECSession		*lpecSession = NULL; \
     unsigned int 	*lpResultVar = &resultvar; \
-    clock_gettime(CLOCK_THREAD_CPUTIME_ID, &startTimes); \
+    times(&startTimes); \
 	SOAP_CALLBACK(soap, pthread_self(), (std::string) "[" + PrettyIP(soap->ip) + "] " + #fname); \
 	er = g_lpSessionManager->ValidateSession(soap, ulSessionId, &lpecSession, true);\
 	const bool UNUSED_VAR bSupportUnicode = (er == erSuccess ? (lpecSession->GetCapabilities() & ZARAFA_CAP_UNICODE) != 0 : false); \
@@ -746,11 +746,11 @@ double GetTimeOfDay();
 #define SOAP_ENTRY_FUNCTION_FOOTER \
 __soapentry_exit: \
     *lpResultVar = er; \
-    clock_gettime(CLOCK_THREAD_CPUTIME_ID, &endTimes); \
+    times(&endTimes); \
     if(lpecSession) { \
-    	lpecSession->AddClocks( timespec2dbl(endTimes) - timespec2dbl(startTimes), \
-    	                        0, \
-							    GetTimeOfDay() - dblStart); \
+    	lpecSession->AddClocks( (double)(endTimes.tms_utime - startTimes.tms_utime) / CLOCKS_PER_SEC, \
+							    (double)(endTimes.tms_stime - startTimes.tms_stime) / CLOCKS_PER_SEC, \
+ 							    GetTimeOfDay() - dblStart); \
 	lpecSession->RemoveBusyState(pthread_self()); \
         lpecSession->Unlock(); \
     } \
