[pisa-src] Re: r2137 - in trunk: Makefile.am libpisa/scheduler.c libpisa/scheduler.h libpisa/sysdep.c libpisa/sysdep.h libpisa/util.c libpisa/util.h

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Mon, 15 Mar 2010 00:36:01 +0100

On Sat, Mar 13, 2010 at 07:35:43PM +0100, Mircea Gherzan wrote:
> 
> Log:
> libpisa: add sysdep files
> 
> For now, only surrogates for timespec/clock_gettime. This is one more
> step towards portability across various *NIX platforms.

Before switching to clock_gettime we were using gettimeofday() IIRC.
This worked fine and was available on OS X as well, probably on more
platforms that may lack clock_gettime.

Now we're adding local clutter to work around platform shortcomings.
I have the nagging feeling that gettimeofday() would avoid all these
problems.  So why not switch back?

> --- trunk/Makefile.am Sat Mar 13 01:06:37 2010        (r2136)
> +++ trunk/Makefile.am Sat Mar 13 19:35:42 2010        (r2137)
> @@ -79,7 +79,8 @@
>                                libpisa/pisaconf.c    \
>                                libpisa/scheduler.c   \
>                                libpisa/tunnel.c      \
> -                              libpisa/util.c
> +                              libpisa/util.c        \
> +                           libpisa/sysdep.c

stray tabs

> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ trunk/libpisa/sysdep.c    Sat Mar 13 19:35:42 2010        (r2137)
> @@ -0,0 +1,51 @@
> +
> +/**
> + * @file dict-maa.h

No.

> +/**
> + * Retrieve the time from a specific system clock
> + * @param clock_id  id of the system clock, only CLOCK_REALTIME is supported
> + * @param ts        time structure to store the result
> + * @return          0 on success, -1 on failure
> + */
> +int clock_gettime(int clock_id, struct timespec *ts)

my man page disagrees:

  int clock_gettime(clockid_t clk_id, struct timespec *tp);

> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ trunk/libpisa/sysdep.h    Sat Mar 13 19:35:42 2010        (r2137)
> @@ -0,0 +1,40 @@
> +/* vim: set expandtab tabstop=4 shiftwidth=4: */
> +/*
> + * Copyright (c) 2010, Distributed Systems Group, RWTH Aachen
> + * All rights reserved.
> + */
> +
> +/**
> + * @file dict-maa.h

Nope.

> +#ifdef __linux__
> +
> +#define HAVE_CLOCK_GETTIME
> +
> +#endif /* __linux__ */

This is ugly and nonportable.  I don't even think it's correct since
there is no direct relationship between the kernel and clock_gettime()
availability.  I bet it's missing not only in OS X but also on older
Linux distros, maybe OpenWrt, scratchbox, maemo...

This should be a proper check in configure.

Diego

Other related posts: