diff TaskManager/Fifo/gettime.h @ 1400:3152bb4429da draft

add gettime
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Tue, 14 Feb 2012 16:22:16 +0900
parents
children 2187bd10f16d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Fifo/gettime.h	Tue Feb 14 16:22:16 2012 +0900
@@ -0,0 +1,30 @@
+#ifndef GETTIME_H_
+#define GETTIME_H_
+
+#include <time.h>
+
+/**
+ *  Mac OS X側には、clock_gettimeがないので、gettimeofdayを使う
+ */
+inline unsigned long long gettime() {
+
+	unsigned long long time;
+#ifdef __CERIUM_FIFO__
+	struct timespec ts;
+
+#ifndef __APPLE__
+	clock_gettime(CLOCK_REALTIME, &ts);
+#else
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	ts.tv_sec = tv.tv_sec;
+	ts.tv_nsec = tv.tv_usec * 1000;
+#endif
+
+	time = ((ts.tv_sec << 32) | ts.tv_nsec );
+#endif // __CERIUM_FIFO__
+	return time;
+
+}
+
+#endif