# HG changeset patch # User Daichi TOMA # Date 1329204136 -32400 # Node ID 3152bb4429da044c7f39130e6db3b0ab2181ef09 # Parent d6170e1200a0bea6cf212bd67e10742bdeceb84d add gettime diff -r d6170e1200a0 -r 3152bb4429da TaskManager/Fifo/FifoDmaManager.cc --- a/TaskManager/Fifo/FifoDmaManager.cc Mon Feb 06 16:29:26 2012 +0900 +++ b/TaskManager/Fifo/FifoDmaManager.cc Tue Feb 14 16:22:16 2012 +0900 @@ -4,7 +4,7 @@ #include "FifoDmaManager.h" #include "Scheduler.h" #include "TaskManagerImpl.h" -#include "rdtsc.h" +#include "gettime.h" void * FifoDmaManager::dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask) @@ -237,13 +237,13 @@ start_dmawait_profile = &FifoDmaManager::do_start_dmawait_profile; end_dmawait_profile = &FifoDmaManager::do_end_dmawait_profile; - stop_time = rdtsc(); + stop_time = gettime(); } void FifoDmaManager::stop_profile() { - start_time = rdtsc(); + start_time = gettime(); global_busy_time += start_time - stop_time; start_dmawait_profile = &FifoDmaManager::null_start_dmawait_profile; @@ -253,14 +253,14 @@ void FifoDmaManager::do_start_dmawait_profile() { - start_time = rdtsc(); + start_time = gettime(); global_busy_time += start_time - stop_time; } void FifoDmaManager::do_end_dmawait_profile(unsigned long long *counter) { - stop_time = rdtsc(); + stop_time = gettime(); *counter += stop_time - start_time; } diff -r d6170e1200a0 -r 3152bb4429da TaskManager/Fifo/gettime.h --- /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 + +/** + * 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 diff -r d6170e1200a0 -r 3152bb4429da TaskManager/Makefile.fifo --- a/TaskManager/Makefile.fifo Mon Feb 06 16:29:26 2012 +0900 +++ b/TaskManager/Makefile.fifo Tue Feb 14 16:22:16 2012 +0900 @@ -5,6 +5,10 @@ EXTRA_CFLAGS = -D__CERIUM_FIFO__ +#ifndef __APPLE__ +CFLAGS += -lrt +#endif + .cc.o: $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ diff -r d6170e1200a0 -r 3152bb4429da TaskManager/Makefile.parallel --- a/TaskManager/Makefile.parallel Mon Feb 06 16:29:26 2012 +0900 +++ b/TaskManager/Makefile.parallel Tue Feb 14 16:22:16 2012 +0900 @@ -1,6 +1,10 @@ include ./Makefile.def TARGET = libFifoManager.a CFLAGS += -DHAS_POSIX_MEMALIGN +#ifndef __APPLE__ +CFLAGS += -lrt +#endif + .SUFFIXES: .cc .o