gettimeofday(2) and time(2)
Adam Lackorzynski
adam at os.inf.tu-dresden.de
Thu Jun 9 01:32:12 CEST 2005
On Wed Jun 08, 2005 at 17:34:38 +0200, Derick Swanepoel wrote:
> On 6/8/05, Adam Lackorzynski <adam at os.inf.tu-dresden.de> wrote:
> > On Wed Jun 08, 2005 at 10:54:23 +0100, Tiago João Portela Jorge wrote:
> > > in my case, all i had to do was to load the server. try that. no linking with
> > > its libs are needed. the RTC only reads the clock and makes its value avaliable
> > > to who wants to use it.
> >
> > Just to clarify, using the time backend makes gettimeofday and co work
> > (when using dietlibc).
> > If you're just using the rtc interface, you of course do not need that
> > backend.
>
> When I load the RTC server it prints out the time correctly as it
> starts, but using time() in my program still returns -1...
Here's a small example that works for me:
Makefile:
PKGDIR ?= ../..
L4DIR ?= $(PKGDIR)/../..
TARGET = time_test
SYSTEMS = x86-l4v2
MODE = sigma0_diet
DEFAULT_RELOC = 0x01000000
LIBS += -ldiet_be_time -lrtc
SRC_C = main.c
include $(L4DIR)/mk/prog.mk
main.c:
#include <time.h>
#include <stdio.h>
int main(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
printf("%ld, %ld.%ld\n", time(NULL), tv.tv_sec, tv.tv_usec);
return 0;
}
This is with dietlibc, though.
Adam
--
Adam adam at os.inf.tu-dresden.de
Lackorzynski http://os.inf.tu-dresden.de/~adam/
More information about the l4-hackers
mailing list