diff --git a/.gitattributes b/.gitattributes index e70c097453..9398462c94 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11442,6 +11442,7 @@ tests/test/units/math/tmask.pp svneol=native#text/plain tests/test/units/math/tmask2.pp svneol=native#text/plain tests/test/units/math/tnaninf.pp svneol=native#text/plain tests/test/units/math/tpower.pp svneol=native#text/pascal +tests/test/units/math/tsincos.pp svneol=native#text/pascal tests/test/units/math/ttrig1.pp svneol=native#text/plain tests/test/units/matrix/tinv1.pp svneol=native#text/pascal tests/test/units/objects/testobj.pp svneol=native#text/plain diff --git a/rtl/i386/mathu.inc b/rtl/i386/mathu.inc index 879fbedcae..01e54b26a0 100644 --- a/rtl/i386/mathu.inc +++ b/rtl/i386/mathu.inc @@ -24,7 +24,7 @@ function arctan2(y,x : float) : float;assembler; {$define FPC_MATH_HAS_SINCOS} -procedure sincos(theta : float;out sinus,cosinus : float);assembler; +procedure sincos(theta : extended;out sinus,cosinus : extended);assembler; asm fldt theta fsincos @@ -34,6 +34,26 @@ procedure sincos(theta : float;out sinus,cosinus : float);assembler; end; +procedure sincos(theta : double;out sinus,cosinus : double);assembler; + asm + fldl theta + fsincos + fstpl (%edx) + fstpl (%eax) + fwait + end; + + +procedure sincos(theta : single;out sinus,cosinus : single);assembler; + asm + flds theta + fsincos + fstps (%edx) + fstps (%eax) + fwait + end; + + {$define FPC_MATH_HAS_TAN} function tan(x : float) : float;assembler; asm diff --git a/rtl/objpas/math.pp b/rtl/objpas/math.pp index e1bb32f26d..394089d454 100644 --- a/rtl/objpas/math.pp +++ b/rtl/objpas/math.pp @@ -256,7 +256,16 @@ function radtocycle(rad : float) : float;inline; function tan(x : float) : float; function cotan(x : float) : float; function cot(x : float) : float; inline; -procedure sincos(theta : float;out sinus,cosinus : float); +{$ifdef FPC_HAS_TYPE_SINGLE} +procedure sincos(theta : single;out sinus,cosinus : single); +{$endif} +{$ifdef FPC_HAS_TYPE_DOUBLE} +procedure sincos(theta : double;out sinus,cosinus : double); +{$endif} +{$ifdef FPC_HAS_TYPE_EXTENDED} +procedure sincos(theta : extended;out sinus,cosinus : extended); +{$endif} + function secant(x : float) : float; inline; function cosecant(x : float) : float; inline; @@ -682,11 +691,31 @@ end; {$ifndef FPC_MATH_HAS_SINCOS} -procedure sincos(theta : float;out sinus,cosinus : float); +{$ifdef FPC_HAS_TYPE_SINGLE} +procedure sincos(theta : single;out sinus,cosinus : single); begin sinus:=sin(theta); cosinus:=cos(theta); end; +{$endif} + + +{$ifdef FPC_HAS_TYPE_DOUBLE} +procedure sincos(theta : double;out sinus,cosinus : double); + begin + sinus:=sin(theta); + cosinus:=cos(theta); + end; +{$endif} + + +{$ifdef FPC_HAS_TYPE_EXTENDED} +procedure sincos(theta : extended;out sinus,cosinus : extended); + begin + sinus:=sin(theta); + cosinus:=cos(theta); + end; +{$endif} {$endif FPC_MATH_HAS_SINCOS} diff --git a/tests/test/units/math/tsincos.pp b/tests/test/units/math/tsincos.pp new file mode 100644 index 0000000000..3e080f530b --- /dev/null +++ b/tests/test/units/math/tsincos.pp @@ -0,0 +1,17 @@ +uses + math; +var + s1,s2 : single; + d1,d2 : double; + e1,e2 : extended; + +begin + sincos(0,s1,s2); + sincos(0,d1,d2); + sincos(0,e1,e2); + if not(SameValue(s1,0)) or not(SameValue(s2,1)) or not(SameValue(d1,0)) or + not(SameValue(d2,1)) or not(SameValue(e1,0)) or not(SameValue(e2,1)) then + halt(1); + writeln('ok'); +end. +