openlibm icon indicating copy to clipboard operation
openlibm copied to clipboard

long double functions stubs

Open alexkalmuk opened this issue 4 years ago • 1 comments

Are there stubs of functions that operate with long double types like roundl(), sinl() and so on? I can not find it. I found such stubs in glibc and newlib, hence I wonder shouldn't OpenLibm provide these stubs for the platforms which have long double equal to double type if the check below failed?

https://github.com/JuliaMath/openlibm/blob/f052f42bb393918acd6fd51ec1f018c5679dfe30/src/Make.files#L46-L47

alexkalmuk avatar Apr 13 '21 15:04 alexkalmuk

I was looking for this – a bit late but I hope it helps. When long double is double (aka. 64-bit floating-point), the files in src define aliases. For instance, src/s_nan.c has:

#if (LDBL_MANT_DIG == 53)
openlibm_weak_reference(nan, nanl);
#endif

The mechanism used for weak references is defined in src/cdefs-compat.h, as you'd expect it varies heavily depending on the OS and compiler.

You can check that the weak symbol is indeed there by running objdump -t (or readelf, or any other tool) on a relevant object file.

% objdump -t src/s_nan.c.o

src/s_nan.c.o:     file format elf32-big

SYMBOL TABLE:
...
000000fc  w    F .text	0000003c _nanl
000000fc g     F .text	0000003c _nan
...
00000138 g     F .text	00000034 _nanf

It can be missing if the weak reference mechanism doesn't work (this was the case for me, since on my architecture there are underscores before symbol names and src/cdefs-compat.h didn't account for it).

lephe avatar May 20 '21 16:05 lephe