[PATCH] Support for sysconf(_SC_MONOTONIC_CLOCK)
Bernhard Fischer
rep.nop at aon.at
Mon Sep 18 16:58:25 UTC 2006
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'?
Didn't look if you need a libc_hidden_proto(clock_getres)..
+
+ if (r >= 0)
+ return _POSIX_VERSION;
+ }
+
+ RETURN_NEG_1;
}
}
libc_hidden_def(sysconf)
More information about the uClibc
mailing list