these days I try to use another way to test the time used by the operation:
I use l4_rdtsc() function,but after I using it as following:

#include <l4/util/rdtsc.h>
...
...
l4_cpu_time_t tsc1,tsc2;
l4_uint32_t args;
...
...
tsc1 = l4_rdtsc();
...
/*operations*/
...
tsc2 = l4_rdtsc();
args = l4_tsc_to_us(tsc2 - tsc1);
printf("start_tsc = %ld\n end_tsc = %ld\n us_time = %u",tsc1,tsc2,args);

why can't I test the time?
for example,one result is:
tsc1 = -2036300143
tsc2 = 1
us_time = 3129796927

thank you!





2009/4/6 fang zhengshu <fangzhsh07@gmail.com>
hi all,
I write a simple test example about time function.but when I use the "time()" function,the code can not be compiled correctly.
I just have include the <time.h>,any question?
the error I put following:
l4@192:~/tudos/l4/pkg/test_fifo/examples/client$ make
PWD=/home/l4/tudos/build/pkg/test_fifo/examples/client/OBJ-x86_586-l4v2 make  -C /home/l4/tudos/build/pkg/test_fifo/examples/client/OBJ-x86_586-l4v2 -f Makefile
make[1]: Entering directory `/home/l4/tudos/build/pkg/test_fifo/examples/client/OBJ-x86_586-l4v2'
  ... Compiling main.o
  LD_PRELOAD=/home/l4/tudos/build/tool/gendep/libgendep.so GENDEP_TARGET=main.o GENDEP_BINARY=cc1   gcc -m32 -c     -DUSE_UCLIBC=y -DRAM_BASE=0x0    -DSYSTEM_x86_586_l4v2 -DARCH_x86 -DCPUTYPE_586 -DL4API_l4v2 -DCONFIG_L4_CALL_SYSCALLS -DCONFIG_L4_ABS_SYSCALLS  -I/home/l4/tudos/build/pkg/test_fifo/idl/OBJ-x86-l4v2 -I/home/l4/tudos/build/include/x86/l4v2 -I/home/l4/tudos/build/include/l4v2 -I/home/l4/tudos/build/include/x86 -I/home/l4/tudos/build/include -I/home/l4/tudos/l4/../dice/include -I/home/drops/include/x86/l4v2 -I/home/drops/include/l4v2 -I/home/drops/include/x86 -I/home/drops/include -nostdinc -I/home/l4/tudos/build/include/x86/uclibc -I/home/l4/tudos/build/include/uclibc -I/home/l4/tudos/build/include/uclibc++ -I/home/drops/include/x86/uclibc -I/home/drops/include/uclibc -I/home/drops/include/uclibc++ -I/usr/lib/gcc/i486-linux-gnu/4.2.4/include -I/usr/lib/gcc/i486-linux-gnu/4.2.4/include-fixed -gstabs+      -g -O2 -fno-strict-aliasing  -march=i586 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -fno-common -fno-stack-protector /home/l4/tudos/l4/pkg/test_fifo/examples/client/main.c -o main.o
    ==> Linking test_fifo-client
    LD_PRELOAD=/home/l4/tudos/build/tool/gendep/libgendep.so GENDEP_TARGET=test_fifo-client GENDEP_BINARY=ld  GENDEP_BINARY_ALT1=ld ld -m elf_i386 -o test_fifo-client /home/l4/tudos/build/lib/x86_586/crt0.o main.o test-client.o -Ttext=0x1100000 --hash-style=sysv  -L/home/l4/tudos/build/lib/x86_586/l4v2 -L/home/l4/tudos/build/lib/x86_586 -L/home/l4/tudos/build/lib -L/home/drops/lib/x86_586/l4v2 -L/home/drops/lib/x86_586 -L/home/drops/lib  -T/home/l4/tudos/build/lib/x86_586/main_stat.ld   -static -lgeneric_ts -ll4env -ll4rm -ldm_generic -ldm_mem -lthread -lsemaphore -llogserver_capsule -lnames -ll4util_root -ll4util -lsigma0 -lroot -ll4env -ll4env_err -ll4rm -ldm_generic -ldm_mem -lthread -lslab -ll4sys -nostdlib  -luc_c -luclibc_support -u mmap_anon -lc_be_simple_mem -lc_be_mmap -lc_be_mmap_util -lc_be_l4env_start_stop -lc_be_minimal_log_io -luc_be_simple_sleep -ll4env -llogserver_capsule -ll4rm -ldm_generic -ldm_mem -lthread -lgeneric_ts -luc_c /usr/lib/gcc/i486-linux-gnu/4.2.4/libgcc.a -luc_c -ll4sys -Ttext=0x1100000 --warn-common -gc-sections
    main.o: In function `main':
    /home/l4/tudos/l4/pkg/test_fifo/examples/client/main.c:36: undefined reference to `time'
    /home/l4/tudos/l4/pkg/test_fifo/examples/client/main.c:40: undefined reference to `time'
    /home/l4/tudos/l4/pkg/test_fifo/examples/client/main.c:36: undefined reference to `time'
    make[1]: *** [test_fifo-client] Error 1
    make[1]: Leaving directory `/home/l4/tudos/build/pkg/test_fifo/examples/client/OBJ-x86_586-l4v2'
    make: *** [/home/l4/tudos/build/pkg/test_fifo/examples/client/OBJ-x86_586-l4v2] Error 2


I have search the same error in l4-hackers ,someone suggest use rtc server,I think it's a good idea.but I have found that the time() function  in time.h,why the error will happen?
The reason I just include time.h?

Thank you!

--
fang,




--
fang,