Search code examples
cvisual-studiovisual-c++msvcrt

MSVCRT: Where is the implement (source code) of sin, cos et al?


I wonder where the implemention of basic trigonometric functions can be found in the Visual C++ CRT.

Find in files for "sin" in C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\crt shows the definition in math.h but nothing more (except a mention in the EXPORTS section of some def file).

To the best of my knowledge, sin is not a keyword that the compiler translates itself to machine code. So there must be an implementation somewhere, even if that implementation boils down to some straight assembly code.

What am I missing here? Where'z teh codez?

EDIT: Obviously, I was not clear enough: I'm looking for the source code, not compiled lib or dll


Solution

  • It's in MSVCR90.DLL:

    C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_...>dumpbin /exports msvcr90.dll | findstr sin
             74   48 0007ABA0 _CIasin = __CIasin
             84   52 0007B5C0 _CIsin = __CIsin
             85   53 0007AF38 _CIsinh = __CIsinh
            159   9D 000236AB __get_flsindex = ___get_flsindex
            160   9E 000236AB __get_tlsindex = ___get_flsindex
            177   AF 0007CE73 __libm_sse2_asin = ___libm_sse2_asin
            178   B0 0007D2C1 __libm_sse2_asinf = ___libm_sse2_asinf
            192   BE 0007FE7C __libm_sse2_sin = ___libm_sse2_sin
            193   BF 00080039 __libm_sse2_sinf = ___libm_sse2_sinf
            696  2B7 0002E27A _mbsinc = __mbsinc
            697  2B8 0002E24E _mbsinc_l = __mbsinc_l
           1211  4BA 0007AB60 asin = _asin
           1349  544 0007B580 sin = _sin
           1350  545 0007AF20 sinh = _sinh
    

    Update:

    The source isn't provided. The library supplying the functions in the CRT source provided seems to be in crt\src\intel\mt_lib\tran.lib:

    C:\...\crt\src\intel\mt_lib> lib /list tran.lib
        :   :   :
    f:\dd\vctools\crt_bld\SELF_X86\crt\prebuild\build\INTEL\mt_obj\_sincosf_sse2_.obj
    f:\dd\vctools\crt_bld\SELF_X86\crt\prebuild\build\INTEL\mt_obj\_sincos_sse2_.obj
    f:\dd\vctools\crt_bld\SELF_X86\crt\prebuild\build\INTEL\mt_obj\_sinf_sse2_.obj
    f:\dd\vctools\crt_bld\SELF_X86\crt\prebuild\build\INTEL\mt_obj\_sin_sse2_.obj
    f:\dd\vctools\crt_bld\SELF_X86\crt\prebuild\build\INTEL\mt_obj\_tanf_sse2_.obj
    f:\dd\vctools\crt_bld\SELF_X86\crt\prebuild\build\INTEL\mt_obj\_tan_sse2_.obj
        :   :   :