1 /** 2 * Alternate implementations of single-precision math functions missing in at 3 * least some 32-bit x86 MS VC runtime versions. 4 * These alternate symbols are referenced in the rt.msvc module. 5 * 6 * Copyright: Copyright Digital Mars 2015. 7 * License: Distributed under the 8 * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 9 * (See accompanying file LICENSE) 10 * Authors: Martin Kinkelin 11 * Source: $(DRUNTIMESRC rt/_msvc_math.d) 12 */ 13 module rt.msvc_math; 14 15 version (CRuntime_Microsoft): 16 version (X86): 17 18 import core.stdc.math; 19 20 extern(C): 21 @trusted: 22 nothrow: 23 @nogc: 24 25 mixin template AltImpl(string baseName) 26 { 27 mixin("float _msvc_"~baseName~"f(float x) { return cast(float) "~baseName~"(x); }"); 28 } 29 mixin template AltImpl2(string baseName) 30 { 31 mixin("float _msvc_"~baseName~"f(float x, float y) { return cast(float) "~baseName~"(x, y); }"); 32 } 33 34 mixin AltImpl!"acos"; 35 mixin AltImpl!"asin"; 36 mixin AltImpl!"atan"; 37 mixin AltImpl2!"atan2"; 38 mixin AltImpl!"cos"; 39 mixin AltImpl!"sin"; 40 mixin AltImpl!"tan"; 41 mixin AltImpl!"cosh"; 42 mixin AltImpl!"sinh"; 43 mixin AltImpl!"tanh"; 44 mixin AltImpl!"exp"; 45 mixin AltImpl!"log"; 46 mixin AltImpl!"log10"; 47 mixin AltImpl2!"pow"; 48 mixin AltImpl!"sqrt"; 49 mixin AltImpl!"ceil"; 50 mixin AltImpl!"floor"; 51 mixin AltImpl2!"fmod"; 52 53 float _msvc_modff(float value, float* iptr) 54 { 55 double di; 56 const result = cast(float) modf(value, &di); 57 *iptr = cast(float) di; 58 return result; 59 }