* [PATCH] Let RTEMS provide clock()
@ 2017-09-06 8:53 Sebastian Huber
[not found] ` <20170906084123.GD14453@calimero.vinschen.de>
2017-09-06 13:56 ` Corinna Vinschen
0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-09-06 8:53 UTC (permalink / raw)
To: newlib
Newlib uses _times_r() in clock(). The problem is that the _times_r()
clock frequency is defined by sysconf(_SC_CLK_TCK). The clock frequency
of clock() is the constant CLOCKS_PER_SEC.
FreeBSD uses getrusage() for clock(). Since RTEMS has only one process,
the implementation can be simplified.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
newlib/configure.host | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/newlib/configure.host b/newlib/configure.host
index 3d967a11b..ba2d8c6c7 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -605,7 +605,7 @@ case "${host}" in
default_newlib_io_long_long="yes"
default_newlib_io_c99_formats="yes"
newlib_cflags="${newlib_cflags} -D_COMPILING_NEWLIB"
- newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
+ newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
# turn off unsupported items in posix directory
newlib_cflags="${newlib_cflags} -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN -D_NO_POSIX_SPAWN"
# turn off using cli/sti in i386 setjmp/longjmp
--
2.12.3
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20170906084123.GD14453@calimero.vinschen.de>]
* Re: [PATCH] Let RTEMS provide clock()
[not found] ` <20170906084123.GD14453@calimero.vinschen.de>
@ 2017-09-06 13:06 ` Sebastian Huber
2017-09-06 14:30 ` Joel Sherrill
0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Huber @ 2017-09-06 13:06 UTC (permalink / raw)
To: newlib
On 06/09/17 10:41, Corinna Vinschen wrote:
> I just don't quite understand. Is sysconf(_SC_CLK_TCK) different
> from CLOCKS_PER_SEC on RTEMS?
Yes, the CLOCKS_PER_SEC is a POSIX defined constant and the
sysconf(_SC_CLK_TCK) returns the actual system tick frequency. Which is
usually 100 or 1000 ticks per second.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let RTEMS provide clock()
2017-09-06 13:06 ` Sebastian Huber
@ 2017-09-06 14:30 ` Joel Sherrill
2017-09-06 15:25 ` Craig Howland
0 siblings, 1 reply; 6+ messages in thread
From: Joel Sherrill @ 2017-09-06 14:30 UTC (permalink / raw)
To: Sebastian Huber, newlib
On 9/6/2017 3:53 AM, Sebastian Huber wrote:
> On 06/09/17 10:41, Corinna Vinschen wrote:
>
>> I just don't quite understand. Is sysconf(_SC_CLK_TCK) different
>> from CLOCKS_PER_SEC on RTEMS?
>
> Yes, the CLOCKS_PER_SEC is a POSIX defined constant and the
> sysconf(_SC_CLK_TCK) returns the actual system tick frequency. Which is
> usually 100 or 1000 ticks per second.
>
Making it more complicated, the system tick frequency is
something that the end user can set for each application.
We just need to make sure that the constant CLOCKS_PER_SECOND
is appropriate for use with clock() as defined here:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html
Sebastian.. I assume that all that matches up per POSIX, right?
--joel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let RTEMS provide clock()
2017-09-06 14:30 ` Joel Sherrill
@ 2017-09-06 15:25 ` Craig Howland
2017-09-07 5:52 ` Sebastian Huber
0 siblings, 1 reply; 6+ messages in thread
From: Craig Howland @ 2017-09-06 15:25 UTC (permalink / raw)
To: newlib
On 09/06/2017 09:56 AM, Joel Sherrill wrote:
>
>
> On 9/6/2017 3:53 AM, Sebastian Huber wrote:
>> On 06/09/17 10:41, Corinna Vinschen wrote:
>>
>>> I just don't quite understand. Is sysconf(_SC_CLK_TCK) different
>>> from CLOCKS_PER_SEC on RTEMS?
>>
>> Yes, the CLOCKS_PER_SEC is a POSIX defined constant and the
>> sysconf(_SC_CLK_TCK) returns the actual system tick frequency. Which is
>> usually 100 or 1000 ticks per second.
>>
>
> Making it more complicated, the system tick frequency is
> something that the end user can set for each application.
> We just need to make sure that the constant CLOCKS_PER_SECOND
> is appropriate for use with clock() as defined here:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html
>
> Sebastian.. I assume that all that matches up per POSIX, right?
>
> --joel
CLOCKS_PER_SEC is not necessarily constant on all systems. It is only POSIX
which requires it to be fixed (at 1 million). The C standard defines it as "an
expression with type clock_t that is the number per second of the value returned
by the clock function."Â (In addition, POSIX does not require microsecond
accuracy, so the _times_r() return value could simply be scaled to
CLOCKS_PER_SEC if so desired as an alternative way of doing it.)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let RTEMS provide clock()
2017-09-06 15:25 ` Craig Howland
@ 2017-09-07 5:52 ` Sebastian Huber
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-09-07 5:52 UTC (permalink / raw)
To: Craig Howland, newlib
On 06/09/17 16:30, Craig Howland wrote:
> On 09/06/2017 09:56 AM, Joel Sherrill wrote:
>>
>>
>> On 9/6/2017 3:53 AM, Sebastian Huber wrote:
>>> On 06/09/17 10:41, Corinna Vinschen wrote:
>>>
>>>> I just don't quite understand. Is sysconf(_SC_CLK_TCK) different
>>>> from CLOCKS_PER_SEC on RTEMS?
>>>
>>> Yes, the CLOCKS_PER_SEC is a POSIX defined constant and the
>>> sysconf(_SC_CLK_TCK) returns the actual system tick frequency. Which is
>>> usually 100 or 1000 ticks per second.
>>>
>>
>> Making it more complicated, the system tick frequency is
>> something that the end user can set for each application.
>> We just need to make sure that the constant CLOCKS_PER_SECOND
>> is appropriate for use with clock() as defined here:
>>
>> http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html
>>
>> Sebastian.. I assume that all that matches up per POSIX, right?
>>
>> --joel
> CLOCKS_PER_SEC is not necessarily constant on all systems. It is only
> POSIX which requires it to be fixed (at 1 million). The C standard
> defines it as "an expression with type clock_t that is the number per
> second of the value returned by the clock function." (In addition,
> POSIX does not require microsecond accuracy, so the _times_r() return
> value could simply be scaled to CLOCKS_PER_SEC if so desired as an
> alternative way of doing it.)
This CLOCKS_PER_SEC seems to be a real mess. Its 100 or 1000000 on
Newlib, 128 on FreeBSD, 100 on NetBSD and OpenBSD, 1000000 on glibc.
XSI-conformant is 1000000:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html
With respect to times() the document above says:
"To obtain the number of clock ticks per second returned by the
/times/()
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/times.html>
function, applications should call /sysconf/(_SC_CLK_TCK)."
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let RTEMS provide clock()
2017-09-06 8:53 [PATCH] Let RTEMS provide clock() Sebastian Huber
[not found] ` <20170906084123.GD14453@calimero.vinschen.de>
@ 2017-09-06 13:56 ` Corinna Vinschen
1 sibling, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2017-09-06 13:56 UTC (permalink / raw)
To: newlib
[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]
Hi Sebastian,
On Sep 6 08:58, Sebastian Huber wrote:
> Newlib uses _times_r() in clock(). The problem is that the _times_r()
> clock frequency is defined by sysconf(_SC_CLK_TCK). The clock frequency
> of clock() is the constant CLOCKS_PER_SEC.
>
> FreeBSD uses getrusage() for clock(). Since RTEMS has only one process,
> the implementation can be simplified.
>
> Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
> ---
> newlib/configure.host | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/newlib/configure.host b/newlib/configure.host
> index 3d967a11b..ba2d8c6c7 100644
> --- a/newlib/configure.host
> +++ b/newlib/configure.host
> @@ -605,7 +605,7 @@ case "${host}" in
> default_newlib_io_long_long="yes"
> default_newlib_io_c99_formats="yes"
> newlib_cflags="${newlib_cflags} -D_COMPILING_NEWLIB"
> - newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
> + newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
> # turn off unsupported items in posix directory
> newlib_cflags="${newlib_cflags} -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN -D_NO_POSIX_SPAWN"
> # turn off using cli/sti in i386 setjmp/longjmp
> --
> 2.12.3
I see what you're doing and it's ok to push.
I just don't quite understand. Is sysconf(_SC_CLK_TCK) different
from CLOCKS_PER_SEC on RTEMS?
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-07 5:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 8:53 [PATCH] Let RTEMS provide clock() Sebastian Huber
[not found] ` <20170906084123.GD14453@calimero.vinschen.de>
2017-09-06 13:06 ` Sebastian Huber
2017-09-06 14:30 ` Joel Sherrill
2017-09-06 15:25 ` Craig Howland
2017-09-07 5:52 ` Sebastian Huber
2017-09-06 13:56 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).