I need to track down how exactly is double sin(double x) implemented in eglibc-2.13. I downloaded the source code and the only part that made sense was __sin function, that was platform-specific. Is it the heart of what I have in /usr/lib/i386-linux-gnu/libm.a?
How to track down the macrodefinitions that lead from sin() to __sin()? What I really need is the exact code (filename and the line is enough) and a way in which the build process deduces which implementation to use. The architecture’s i386.
The (e)glibc build process is black, black magic. You do not want to try to comprehend it. However, glibc adheres to a one-file-per-public-function coding style, so in general, if you have the source tree and you want to find the implementation(s) of some function, the easiest thing to do is
from the top level, replacing
functionwith the name of the function, of course.Talking specifically about
sin: the generic implementations of the math functions are in themathdirectory: however, it appears that there is no generic definition ofsin. So the next place to look issysdeps. Everything that isn’t generic is insysdeps, and in particular,sysdeps/ieee754is where all the math functions that have some dependence on the IEEE 754 floating point specification, but no other system dependencies, live. This directory is organized by type:sysdeps/ieee754/dbl-64contains all the math functions for IEEEdouble. And here you will findsysdeps/ieee754/dbl-64/s_sin.c, which is the code you are looking for. (Thee_,s_,k_, etc prefixes on all these files used to mean something but AFAIK no longer do.)If there were an implementation of
sinin assembly language for a particular processor, it would be in a file namedsin.S(or possiblys_sin.S) somewhere else insysdeps. It does not appear that there is one, though.