[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Negative values from output of rtl_printf



Hi,

I have a question about the formatter %Ld of rtl_printf (printk). The man
page gave me the hint, that this formatter is supported under linux and will
fomat long long values (i.e. 64 bit int's) into strings for console output.
In my case this works only with integers equal or smaller than 0xFFFFFFFF
and with the "u" for unsigned. I discover  the problem, if I tryed to
calculate timing differences. Example:

------------------------------
hrtime_t t1, t2;

	t1 = clock_gethrtime(CLOCK_RTL_SCHED);
	.... // do something
	usleep(300); // sleep in example for 300 microsecs
	t2 = clock_gethrtime(CLOCK_RTL_SCHED);
	rtl_printf("Start=[%Ld] End=[%Ld] Diff=[%Ld]\n", t1, t2, t2-t1);
------------------------------	

If t1 and t2 fits into 32 bits (unsigned long) all seems to be ok otherwise
I get negative values at output. Has anybody an explanation for this
behavior??
At the second, I'am not sure now, if the calculated difference is ok. I will
check this tody, because the schowing value is also not plausible (in the
example above: expected a little bit more than the sleeping time of 300
microsecs, may be 3xx xxx and got: 4732???)

My equipment: Pentium III, 256MB Ram, Mandrake 7.2, RTLinux-3.0 and
prepatched kernel 2.2.18 from fsmlab.

Thanks

Thomas
 

**************************************************************
Dipl.-Ing. (FH) 
Thomas Lehwald
RUETZ Technologies		Tel:   089 / 3 56 10 - 268
Abteilung E-Technik			Fax:  089 / 3 56 10 - 111
Ingolstaedter Strasse 18		80807 Muenchen
email: thomas.lehwald@ruetz.de
****************************************************