[prev in list] [next in list] [prev in thread] [next in thread] 

List:       strongswan-announce
Subject:    [strongSwan-dev] [PATCH 2/2] If HAVE_CLOCK_GETTIME is not defined,
From:       J. Tang <tang () jtang ! org>
Date:       2011-11-07 3:43:55
Message-ID: 556DFB73-643D-4EAF-BD84-6BD3CAEAF5F3 () jtang ! org
[Download RAW message or body]

If HAVE_CLOCK_GETTIME is not defined, call gettimeofday() instead.

Signed-off-by: J. Tang <tang@jtang.org>
---
  src/libstrongswan/utils.c |   11 +++++++++++
  src/libstrongswan/utils.h |    6 ++++++
  2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/libstrongswan/utils.c b/src/libstrongswan/utils.c
index 2fe7f65..9be530f 100644
--- a/src/libstrongswan/utils.c
+++ b/src/libstrongswan/utils.c
@@ -468,3 +468,14 @@ int mem_printf_hook(char *dst, size_t dstlen,
  	}
  	return written;
  }
+
+#ifndef HAVE_CLOCK_GETTIME
+
+void clock_gettime(int clk_id __attribute__((unused)), struct  
timespec *tp) {
+	struct timeval tv = {0, 0};
+	gettimeofday(&tv, NULL);
+	tp->tv_sec = tv.tv_sec;
+	tp->tv_nsec = tv.tv_usec * 1000;
+}
+
+#endif /* HAVE_CLOCK_GETTIME */
diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h
index 0f06fec..54ee2c3 100644
--- a/src/libstrongswan/utils.h
+++ b/src/libstrongswan/utils.h
@@ -574,4 +574,10 @@ int time_delta_printf_hook(char *dst, size_t  
len, printf_hook_spec_t *spec,
  int mem_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
  					const void *const *args);

+#ifndef HAVE_CLOCK_GETTIME
+#define CLOCK_THREAD_CPUTIME_ID 0
+void clock_gettime(int clk_id, struct timespec *tp);
+
+#endif /* HAVE_CLOCK_GETTIME */
+
  #endif /** UTILS_H_ @}*/
-- 
1.7.3.2


_______________________________________________
Dev mailing list
Dev@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic