forked from OSchip/llvm-project
[builtins] Avoid enum name conflicts with fenv.h
After a follow-up change (D98332) this header can be included the same time as fenv.h when running the tests. To avoid enum members conflicting with the macros/enums defined in the host fenv.h, prefix them with CRT_. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D98333
This commit is contained in:
parent
107189a26e
commit
ed0bf875a9
|
@ -23,24 +23,25 @@
|
|||
#ifndef __ARM_FP
|
||||
// For soft float targets, allow changing rounding mode by overriding the weak
|
||||
// __aarch64_fe_default_rmode symbol.
|
||||
FE_ROUND_MODE __attribute__((weak)) __aarch64_fe_default_rmode = FE_TONEAREST;
|
||||
CRT_FE_ROUND_MODE __attribute__((weak)) __aarch64_fe_default_rmode =
|
||||
CRT_FE_TONEAREST;
|
||||
#endif
|
||||
|
||||
FE_ROUND_MODE __fe_getround() {
|
||||
CRT_FE_ROUND_MODE __fe_getround() {
|
||||
#ifdef __ARM_FP
|
||||
uint64_t fpcr;
|
||||
__asm__ __volatile__("mrs %0, fpcr" : "=r" (fpcr));
|
||||
fpcr = fpcr >> AARCH64_RMODE_SHIFT & AARCH64_RMODE_MASK;
|
||||
switch (fpcr) {
|
||||
case AARCH64_UPWARD:
|
||||
return FE_UPWARD;
|
||||
return CRT_FE_UPWARD;
|
||||
case AARCH64_DOWNWARD:
|
||||
return FE_DOWNWARD;
|
||||
return CRT_FE_DOWNWARD;
|
||||
case AARCH64_TOWARDZERO:
|
||||
return FE_TOWARDZERO;
|
||||
return CRT_FE_TOWARDZERO;
|
||||
case AARCH64_TONEAREST:
|
||||
default:
|
||||
return FE_TONEAREST;
|
||||
return CRT_FE_TONEAREST;
|
||||
}
|
||||
#else
|
||||
return __aarch64_fe_default_rmode;
|
||||
|
|
|
@ -23,24 +23,25 @@
|
|||
#ifndef __ARM_FP
|
||||
// For soft float targets, allow changing rounding mode by overriding the weak
|
||||
// __arm_fe_default_rmode symbol.
|
||||
FE_ROUND_MODE __attribute__((weak)) __arm_fe_default_rmode = FE_TONEAREST;
|
||||
CRT_FE_ROUND_MODE __attribute__((weak)) __arm_fe_default_rmode =
|
||||
CRT_FE_TONEAREST;
|
||||
#endif
|
||||
|
||||
FE_ROUND_MODE __fe_getround() {
|
||||
CRT_FE_ROUND_MODE __fe_getround() {
|
||||
#ifdef __ARM_FP
|
||||
uint32_t fpscr;
|
||||
__asm__ __volatile__("vmrs %0, fpscr" : "=r" (fpscr));
|
||||
fpscr = fpscr >> ARM_RMODE_SHIFT & ARM_RMODE_MASK;
|
||||
switch (fpscr) {
|
||||
case ARM_UPWARD:
|
||||
return FE_UPWARD;
|
||||
return CRT_FE_UPWARD;
|
||||
case ARM_DOWNWARD:
|
||||
return FE_DOWNWARD;
|
||||
return CRT_FE_DOWNWARD;
|
||||
case ARM_TOWARDZERO:
|
||||
return FE_TOWARDZERO;
|
||||
return CRT_FE_TOWARDZERO;
|
||||
case ARM_TONEAREST:
|
||||
default:
|
||||
return FE_TONEAREST;
|
||||
return CRT_FE_TONEAREST;
|
||||
}
|
||||
#else
|
||||
return __arm_fe_default_rmode;
|
||||
|
|
|
@ -151,19 +151,19 @@ static __inline fp_t __addXf3__(fp_t a, fp_t b) {
|
|||
// Perform the final rounding. The result may overflow to infinity, but
|
||||
// that is the correct result in that case.
|
||||
switch (__fe_getround()) {
|
||||
case FE_TONEAREST:
|
||||
case CRT_FE_TONEAREST:
|
||||
if (roundGuardSticky > 0x4)
|
||||
result++;
|
||||
if (roundGuardSticky == 0x4)
|
||||
result += result & 1;
|
||||
break;
|
||||
case FE_DOWNWARD:
|
||||
case CRT_FE_DOWNWARD:
|
||||
if (resultSign && roundGuardSticky) result++;
|
||||
break;
|
||||
case FE_UPWARD:
|
||||
case CRT_FE_UPWARD:
|
||||
if (!resultSign && roundGuardSticky) result++;
|
||||
break;
|
||||
case FE_TOWARDZERO:
|
||||
case CRT_FE_TOWARDZERO:
|
||||
break;
|
||||
}
|
||||
if (roundGuardSticky)
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
#include "fp_mode.h"
|
||||
|
||||
// IEEE-754 default rounding (to nearest, ties to even).
|
||||
FE_ROUND_MODE __fe_getround() {
|
||||
return FE_TONEAREST;
|
||||
}
|
||||
CRT_FE_ROUND_MODE __fe_getround() { return CRT_FE_TONEAREST; }
|
||||
|
||||
int __fe_raise_inexact() {
|
||||
return 0;
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
#define FP_MODE
|
||||
|
||||
typedef enum {
|
||||
FE_TONEAREST,
|
||||
FE_DOWNWARD,
|
||||
FE_UPWARD,
|
||||
FE_TOWARDZERO
|
||||
} FE_ROUND_MODE;
|
||||
CRT_FE_TONEAREST,
|
||||
CRT_FE_DOWNWARD,
|
||||
CRT_FE_UPWARD,
|
||||
CRT_FE_TOWARDZERO
|
||||
} CRT_FE_ROUND_MODE;
|
||||
|
||||
FE_ROUND_MODE __fe_getround(void);
|
||||
CRT_FE_ROUND_MODE __fe_getround(void);
|
||||
int __fe_raise_inexact(void);
|
||||
|
||||
#endif // FP_MODE_H
|
||||
|
|
|
@ -14,22 +14,22 @@
|
|||
#define X87_TOWARDZERO 0x0c00
|
||||
#define X87_RMODE_MASK (X87_TONEAREST | X87_UPWARD | X87_DOWNWARD | X87_TOWARDZERO)
|
||||
|
||||
FE_ROUND_MODE __fe_getround() {
|
||||
CRT_FE_ROUND_MODE __fe_getround() {
|
||||
// Assume that the rounding mode state for the fpu agrees with the SSE unit.
|
||||
unsigned short cw;
|
||||
__asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
|
||||
|
||||
switch (cw & X87_RMODE_MASK) {
|
||||
case X87_TONEAREST:
|
||||
return FE_TONEAREST;
|
||||
return CRT_FE_TONEAREST;
|
||||
case X87_DOWNWARD:
|
||||
return FE_DOWNWARD;
|
||||
return CRT_FE_DOWNWARD;
|
||||
case X87_UPWARD:
|
||||
return FE_UPWARD;
|
||||
return CRT_FE_UPWARD;
|
||||
case X87_TOWARDZERO:
|
||||
return FE_TOWARDZERO;
|
||||
return CRT_FE_TOWARDZERO;
|
||||
}
|
||||
return FE_TONEAREST;
|
||||
return CRT_FE_TONEAREST;
|
||||
}
|
||||
|
||||
int __fe_raise_inexact() {
|
||||
|
|
Loading…
Reference in New Issue