LSB 4.0 Beta 1: possible <time.h> header file error

Printer-friendly versionPosted to the lsb-discuss mailing list by: Nelson H. F. Beebe

I've just installed the LSB 4.0 Beta 1 release on all of our IA-32, IA-64, and AMD64 systems running Red Hat GNU/Linux versions 4 and 5. For each platform with the new LSB installation, I then ran test builds of a large mathematical library that I'm developing, and got a compilation error that can be distilled to this simple example: % cat lsb-bug.c #include #include double clock_ticks_per_second; void lsb_bug(void) { clock_ticks_per_second = (double)CLK_TCK; } % lsbcc -c -Werror-implicit-function-declaration -Wall -Wmissing-prototypes lsb-bug.c lsb-bug.c:8: warning: no previous prototype for 'lsb_bug' lsb-bug.c: In function 'lsb_bug': lsb-bug.c:9: error: implicit declaration of function '__sysconf' % lsbcc -E lsb-bug.c | grep sysconf extern long int sysconf(int); clock_ticks_per_second = (double)((clock_t)__sysconf(2)); % find /opt/lsb/include/ -type f | xargs grep sysconf /opt/lsb/include/unistd.h:/* `sysconf' NAME values.*/ /opt/lsb/include/unistd.h: extern long int sysconf(int); /opt/lsb/include/time.h:#define CLK_TCK ((clock_t)__sysconf(2)) It looks like the LSB file should be calling sysconf(), not __sysconf(), since there is no prototype visible for the latter anywhere in the LSB header file directory tree. Its intended type is "long int", which is incompatible with C's default integer type, so one cannot just accept the default return type. Comments and/or advice? ------------------------------------------------------------------------------- - Nelson H. F. Beebe Tel: +1 801 581 5254 - - University of Utah FAX: +1 801 581 4148 - - Department of Mathematics, 110 LCB Internet e-mail: beebe@math.utah.edu - - 155 S 1400 E RM 233 beebe@acm.org beebe@computer.org - - Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe/ - -------------------------------------------------------------------------------
LSB 4.0 Beta 1: possible <time.h> header file error
Submitted by Wichmann Mats D on Fri, 10/17/2008 - 02:15.

Nelson H. F. Beebe wrote:
> I've just installed the LSB 4.0 Beta 1 release on all of our IA-32,
> IA-64, and AMD64 systems running Red Hat GNU/Linux versions 4 and 5.
>
> For each platform with the new LSB installation, I then ran test
> builds of a large mathematical library that I'm developing, and got a
> compilation error that can be distilled to this simple example:
>
> % cat lsb-bug.c
> #include
> #include
>
> double clock_ticks_per_second;
>
> void
> lsb_bug(void)
> {
> clock_ticks_per_second = (double)CLK_TCK;
> }
>
> % lsbcc -c -Werror-implicit-function-declaration -Wall
> -Wmissing-prototypes lsb-bug.c lsb-bug.c:8: warning: no
> previous prototype for 'lsb_bug' lsb-bug.c: In function
> 'lsb_bug': lsb-bug.c:9: error: implicit declaration of
> function '__sysconf'
>
> % lsbcc -E lsb-bug.c | grep sysconf
> extern long int sysconf(int);
> clock_ticks_per_second = (double)((clock_t)__sysconf(2));
>
> % find /opt/lsb/include/ -type f | xargs grep sysconf
> /opt/lsb/include/unistd.h:/* `sysconf' NAME values.*/
> /opt/lsb/include/unistd.h: extern long int sysconf(int);
> /opt/lsb/include/time.h:#define CLK_TCK
> ((clock_t)__sysconf(2))
>
> It looks like the LSB file should be calling sysconf(), not
> __sysconf(), since there is no prototype visible for the latter
> anywhere in the LSB header file directory tree. Its intended type is
> "long int", which is incompatible with C's default integer type, so
> one cannot just accept the default return type.
>
> Comments and/or advice?

Thanks for the report.

I think you're right, but there's also some evidence that this
may have been intentional, so let's wait a bit before fixing.
As a temporary workaround there would be no harm in replacing
__sysconf with sysconf (as in, manually hack the header).
__sysconf is in the LSB, tagged as:

__sysconf() is not in the source standard; it is only in
the binary standard.

LSB 4.0 Beta 1: possible <time.h> header file error
Submitted by Denis Silakov on Fri, 10/17/2008 - 08:15.

Wichmann, Mats D wrote:
> I think you're right, but there's also some evidence that this
> may have been intentional, so let's wait a bit before fixing.
> As a temporary workaround there would be no harm in replacing
> __sysconf with sysconf (as in, manually hack the header).
> __sysconf is in the LSB, tagged as:
>
> __sysconf() is not in the source standard; it is only in
> the binary standard.

Indeed, __sysconf is not supposed to be used in applications directly.
However, CLK_TCK definition that causes the problem comes from
bits/time.h header, and that header does provide __sysconf declaration.
Since LSB time.h incorporate time.h and bits/time.h, maybe it makes
sense to include __sysconf() declaration it this header, too?

--
Regards,
Denis.

Copyright © 2008 Linux Foundation. All rights reserved.
LSB is a trademark of the Linux Foundation. Linux is a registered trademark of Linus Torvalds