[PATCH] Support for sysconf(_SC_MONOTONIC_CLOCK)
Peter Kjellerstedt
peter.kjellerstedt at axis.com
Tue Sep 19 07:59:52 UTC 2006
> -----Original Message-----
> From: uclibc-bounces at uclibc.org
> [mailto:uclibc-bounces at uclibc.org] On Behalf Of Bernhard Fischer
> Sent: Monday, September 18, 2006 18:58
> To: Peter Kjellerstedt
> Cc: uclibc at uclibc.org; Rich Felker
> Subject: Re: [PATCH] Support for sysconf(_SC_MONOTONIC_CLOCK)
>
> On Mon, Sep 18, 2006 at 06:18:29PM +0200, Peter Kjellerstedt wrote:
> >> -----Original Message-----
> >> From: uclibc-bounces at uclibc.org
> >> [mailto:uclibc-bounces at uclibc.org] On Behalf Of Rich Felker
> >> Sent: Monday, September 18, 2006 17:54
> >> To: uclibc at uclibc.org
> >> Subject: Re: [PATCH] Support for sysconf(_SC_MONOTONIC_CLOCK)
> >>
> >> On Mon, Sep 18, 2006 at 05:21:57PM +0200, Peter Kjellerstedt wrote:
> >> > + case _SC_MONOTONIC_CLOCK:
> >> > +#ifdef __NR_clock_getres
> >> > + /* Check using the clock_getres system call. */
> >> > + {
> >> > + static inline _syscall2(int, clock_getres,
> >> clockid_t, clock_id, struct timespec*, res);
> >>
> >> This is a nested function -- are they allowed in uclibc??
> >> If inlining is disabled it might even result in an executable
> >> stack requirement.
> >> IMO put the syscall macro where it belongs, outside of functions.
> >>
> >> Other than that, no comments, you'll have to wait to hear what the
> >> actual developers say.
> >>
> >> Rich
> >
> >That sounds fair. But then I realized that I could just call the
> >clock_getres() that is already build into the library, and thus
> >avoid the "trouble" of using a syscall directly. Anyway, here is
> >an updated patch that I believe and hope should be ok to commit.
>
> Index: libc/unistd/sysconf.c
> ===================================================================
> --- libc/unistd/sysconf.c (revision 16020)
> +++ libc/unistd/sysconf.c (working copy)
> @@ -883,6 +883,18 @@
> #else
> RETURN_NEG_1;
> #endif
> +
> + case _SC_MONOTONIC_CLOCK:
> + /* Check using the clock_getres system call. */
> + {
> + struct timespec ts;
> + int r = clock_getres(CLOCK_MONOTONIC, &ts);
>
> Doesn't look like you'd actually do anything with ts, if i read this
> correctly then passing NULL in instead should be fine for a
> non realtime clock, no?
> Same code-size if you let the compiler allocate an eventual temporary
> for 'r'?
The use of a dummy ts argument was taken from the glibc code I
looked at. However, I checked the POSIX documentation, and also
checked the implementation in the kernel, and NULL should be valid.
I also corrected the clock_getres() implementation in uClibc when
no clock_getres syscall is available.
Anyway, I have attached a new, even simpler version of the patch.
> Didn't look if you need a libc_hidden_proto(clock_getres)..
No, there is no libc_hidden_def(clock_getres).
Maybe there should be? What is the benefit?
> +
> + if (r >= 0)
> + return _POSIX_VERSION;
> + }
> +
> + RETURN_NEG_1;
> }
> }
> libc_hidden_def(sysconf)
//Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sysconf.patch
Type: application/octet-stream
Size: 471 bytes
Desc: sysconf.patch
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20060919/4a607b81/attachment-0002.obj
More information about the uClibc
mailing list