Subject: Re: libm and libc
To: Aymeric Vincent <>
From: Klaus Klein <>
List: tech-userlevel
Date: 05/26/2001 17:22:24
Aymeric Vincent <> writes:

> I would like libm to be independant of the standard C library.
> It looks like libc defines __infinity, isinf() and the like. Why is
> that?

There are two different reasons for those two symbols:

* While X/Open states that portable application must link against
  libm in order to make visible functions from <math.h>, it does
  not state this for symbolic constants from <math.h>.  Needing
  to link against libm to use HUGE_VAL isn't what I'd expect.

  (Of course there are other ways to implement this, one of them being
  moving this into <machine/math.h>.)

* isinf() and isnan() needed within libc itself, and libc must not
  depend on libm.

> If it's necessary for some standard compliance, would it be possible
> to redefine those symbols as weak symbols in libm?
> [ I'm trying to use a program in C++/Java which uses the math lib, but
>   doesn't import our libc since the jdk runs in linux emulation ]

Given that libm actually depends on some of the more critical
internals of libc (i.e. __errno; __sF could be worked around) which
differ in their glibc implementations, it's not quite clear to me what
you would gain by including only __infinity and isinf()/isnan().

- Klaus