view TaskManager/Fifo/gettime.h @ 1479:163220e54cc0 draft

remove hard code for TaskLog
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Tue, 24 Jul 2012 17:15:15 +0900
parents 2187bd10f16d
children 411401d1cb71
line wrap: on
line source

#ifndef GETTIME_H_
#define GETTIME_H_

#include <time.h>
#ifdef __APPLE__
#include <sys/time.h>
#endif
/**
 *  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