aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2020-08-30 14:12:48 +0200
committerCorinna Vinschen <corinna@vinschen.de>2020-08-30 14:27:43 +0200
commit023ddc41283b3508d32eb00bb45a7408cc196ffa (patch)
tree7300185b9e93460684d359c44468aba92cdc4254 /winsup
parent0e6690a92ccda8b2d6a759bc1649c6160137d170 (diff)
downloadnewlib-023ddc41283b3508d32eb00bb45a7408cc196ffa.zip
newlib-023ddc41283b3508d32eb00bb45a7408cc196ffa.tar.gz
newlib-023ddc41283b3508d32eb00bb45a7408cc196ffa.tar.bz2
Cygwin: crt: Add "volatile" to all inline assembly snippets under math
On 32 bit x86, clang seems to miss loading input parameters based on asm constraints for inline assembly that uses the x87 floating registers, unless the snippet has got the volatile keyword. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/math/acosl.c3
-rw-r--r--winsup/cygwin/math/asinl.c3
-rw-r--r--winsup/cygwin/math/atan2l.c2
-rw-r--r--winsup/cygwin/math/atanl.c3
-rw-r--r--winsup/cygwin/math/exp.def.h3
-rw-r--r--winsup/cygwin/math/fabsl.c2
-rw-r--r--winsup/cygwin/math/fmodl.c3
-rw-r--r--winsup/cygwin/math/logbl.c3
-rw-r--r--winsup/cygwin/math/modfl.c4
-rw-r--r--winsup/cygwin/math/pow.def.h6
-rw-r--r--winsup/cygwin/math/sqrt.def.h4
11 files changed, 21 insertions, 15 deletions
diff --git a/winsup/cygwin/math/acosl.c b/winsup/cygwin/math/acosl.c
index 511b5de..553d06f 100644
--- a/winsup/cygwin/math/acosl.c
+++ b/winsup/cygwin/math/acosl.c
@@ -10,7 +10,8 @@ long double acosl (long double x)
long double res = 0.0L;
/* acosl = atanl (sqrtl(1 - x^2) / x) */
- asm ( "fld %%st\n\t"
+ asm volatile (
+ "fld %%st\n\t"
"fmul %%st(0)\n\t" /* x^2 */
"fld1\n\t"
"fsubp\n\t" /* 1 - x^2 */
diff --git a/winsup/cygwin/math/asinl.c b/winsup/cygwin/math/asinl.c
index a4d8746..35df3b5 100644
--- a/winsup/cygwin/math/asinl.c
+++ b/winsup/cygwin/math/asinl.c
@@ -16,7 +16,8 @@ long double asinl (long double x)
{
long double res = 0.0L;
- asm ( "fld %%st\n\t"
+ asm volatile (
+ "fld %%st\n\t"
"fmul %%st(0)\n\t" /* x^2 */
"fld1\n\t"
"fsubp\n\t" /* 1 - x^2 */
diff --git a/winsup/cygwin/math/atan2l.c b/winsup/cygwin/math/atan2l.c
index a32b097..a4300cb 100644
--- a/winsup/cygwin/math/atan2l.c
+++ b/winsup/cygwin/math/atan2l.c
@@ -9,6 +9,6 @@ long double
atan2l (long double y, long double x)
{
long double res = 0.0L;
- asm ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
+ asm volatile ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
return res;
}
diff --git a/winsup/cygwin/math/atanl.c b/winsup/cygwin/math/atanl.c
index b85d053..d289ef0 100644
--- a/winsup/cygwin/math/atanl.c
+++ b/winsup/cygwin/math/atanl.c
@@ -10,7 +10,8 @@ atanl (long double x)
{
long double res = 0.0L;
- asm ("fld1\n\t"
+ asm volatile (
+ "fld1\n\t"
"fpatan"
: "=t" (res) : "0" (x));
return res;
diff --git a/winsup/cygwin/math/exp.def.h b/winsup/cygwin/math/exp.def.h
index d4d4c04..3066b74 100644
--- a/winsup/cygwin/math/exp.def.h
+++ b/winsup/cygwin/math/exp.def.h
@@ -52,7 +52,8 @@ static long double
__expl_internal (long double x)
{
long double res = 0.0L;
- asm ("fldl2e\n\t" /* 1 log2(e) */
+ asm volatile (
+ "fldl2e\n\t" /* 1 log2(e) */
"fmul %%st(1),%%st\n\t" /* 1 x log2(e) */
#ifdef __x86_64__
diff --git a/winsup/cygwin/math/fabsl.c b/winsup/cygwin/math/fabsl.c
index 2dfdfaa..f3864ea 100644
--- a/winsup/cygwin/math/fabsl.c
+++ b/winsup/cygwin/math/fabsl.c
@@ -10,7 +10,7 @@ fabsl (long double x)
{
#if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_)
long double res = 0.0L;
- asm ("fabs;" : "=t" (res) : "0" (x));
+ asm volatile ("fabs;" : "=t" (res) : "0" (x));
return res;
#elif defined(__arm__) || defined(_ARM_)
return __builtin_fabsl (x);
diff --git a/winsup/cygwin/math/fmodl.c b/winsup/cygwin/math/fmodl.c
index 6224db1..462b6fa 100644
--- a/winsup/cygwin/math/fmodl.c
+++ b/winsup/cygwin/math/fmodl.c
@@ -10,7 +10,8 @@ fmodl (long double x, long double y)
{
long double res = 0.0L;
- asm ("1:\tfprem\n\t"
+ asm volatile (
+ "1:\tfprem\n\t"
"fstsw %%ax\n\t"
"sahf\n\t"
"jp 1b\n\t"
diff --git a/winsup/cygwin/math/logbl.c b/winsup/cygwin/math/logbl.c
index 310c445..5e533c0 100644
--- a/winsup/cygwin/math/logbl.c
+++ b/winsup/cygwin/math/logbl.c
@@ -16,7 +16,8 @@ logbl (long double x)
{
long double res = 0.0L;
- asm ("fxtract\n\t"
+ asm volatile (
+ "fxtract\n\t"
"fstp %%st" : "=t" (res) : "0" (x));
return res;
}
diff --git a/winsup/cygwin/math/modfl.c b/winsup/cygwin/math/modfl.c
index ef1ab16..33593e6 100644
--- a/winsup/cygwin/math/modfl.c
+++ b/winsup/cygwin/math/modfl.c
@@ -13,7 +13,7 @@ modfl (long double value, long double* iptr)
long double int_part = 0.0L;
/* truncate */
#if defined(_AMD64_) || defined(__x86_64__)
- asm ("subq $8, %%rsp\n"
+ asm volatile ("subq $8, %%rsp\n"
"fnstcw 4(%%rsp)\n"
"movzwl 4(%%rsp), %%eax\n"
"orb $12, %%ah\n"
@@ -23,7 +23,7 @@ modfl (long double value, long double* iptr)
"fldcw 4(%%rsp)\n"
"addq $8, %%rsp\n" : "=t" (int_part) : "0" (value) : "eax"); /* round */
#elif defined(_X86_) || defined(__i386__)
- asm ("push %%eax\n\tsubl $8, %%esp\n"
+ asm volatile ("push %%eax\n\tsubl $8, %%esp\n"
"fnstcw 4(%%esp)\n"
"movzwl 4(%%esp), %%eax\n"
"orb $12, %%ah\n"
diff --git a/winsup/cygwin/math/pow.def.h b/winsup/cygwin/math/pow.def.h
index c22064b..2ea8257 100644
--- a/winsup/cygwin/math/pow.def.h
+++ b/winsup/cygwin/math/pow.def.h
@@ -82,7 +82,7 @@ internal_modf (__FLT_TYPE value, __FLT_TYPE *iptr)
/* truncate */
/* truncate */
#ifdef __x86_64__
- asm ("pushq %%rax\n\tsubq $8, %%rsp\n"
+ asm volatile ("pushq %%rax\n\tsubq $8, %%rsp\n"
"fnstcw 4(%%rsp)\n"
"movzwl 4(%%rsp), %%eax\n"
"orb $12, %%ah\n"
@@ -92,7 +92,7 @@ internal_modf (__FLT_TYPE value, __FLT_TYPE *iptr)
"fldcw 4(%%rsp)\n"
"addq $8, %%rsp\npopq %%rax" : "=t" (int_part) : "0" (value)); /* round */
#else
- asm ("push %%eax\n\tsubl $8, %%esp\n"
+ asm volatile ("push %%eax\n\tsubl $8, %%esp\n"
"fnstcw 4(%%esp)\n"
"movzwl 4(%%esp), %%eax\n"
"orb $12, %%ah\n"
@@ -204,7 +204,7 @@ __FLT_ABI(pow) (__FLT_TYPE x, __FLT_TYPE y)
}
if (y == __FLT_CST(0.5))
{
- asm ("fsqrt" : "=t" (rslt) : "0" (x));
+ asm volatile ("fsqrt" : "=t" (rslt) : "0" (x));
return rslt;
}
}
diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
index 863c028..cf8b5cb 100644
--- a/winsup/cygwin/math/sqrt.def.h
+++ b/winsup/cygwin/math/sqrt.def.h
@@ -50,7 +50,7 @@
* asm ("fsqrts %[dst], %[src];\n" : [dst] "=w" (res) : [src] "w" (x));
*/
__FLT_TYPE __fsqrt_internal( __FLT_TYPE x );
-asm(".def __fsqrt_internal; .scl 2; .type 32; .endef\n"
+asm volatile(".def __fsqrt_internal; .scl 2; .type 32; .endef\n"
"\t.text\n"
"\t.align 4\n"
"\t.globl __fsqrt_internal\n"
@@ -85,7 +85,7 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
#if defined(__arm__) || defined(_ARM_)
__fsqrt_internal(x);
#elif defined(_X86_) || defined(__i386__) || defined(_AMD64_) || defined(__x86_64__)
- asm ("fsqrt" : "=t" (res) : "0" (x));
+ asm volatile ("fsqrt" : "=t" (res) : "0" (x));
#else
#error Not supported on your platform yet
#endif