Signed-off-by: Daniel Lehman dlehman25@gmail.com --- .../api-ms-win-crt-runtime-l1-1-0.spec | 2 +- dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr120/tests/msvcr120.c | 21 ++++++++++++++++--- dlls/msvcr120_app/msvcr120_app.spec | 2 +- dlls/msvcrt/math.c | 12 +++++++++++ dlls/ucrtbase/ucrtbase.spec | 2 +- include/msvcrt/fenv.h | 1 + 7 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec b/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec index 610af8e436b..3733a524382 100644 --- a/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec +++ b/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec @@ -87,7 +87,7 @@ @ cdecl _wsystem(wstr) ucrtbase._wsystem @ cdecl abort() ucrtbase.abort @ cdecl exit(long) ucrtbase.exit -@ stub feclearexcept +@ cdecl feclearexcept(long) ucrtbase.feclearexcept @ cdecl fegetenv(ptr) ucrtbase.fegetenv @ cdecl fegetexceptflag(ptr long) ucrtbase.fegetexceptflag @ cdecl fegetround() ucrtbase.fegetround diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 430124740bb..306bee5f50c 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -2143,7 +2143,7 @@ @ cdecl fdim(double double) @ cdecl fdimf(float float) @ cdecl fdiml(double double) fdim -@ stub feclearexcept +@ cdecl feclearexcept(long) @ cdecl fegetenv(ptr) @ cdecl fegetexceptflag(ptr long) @ cdecl fegetround() diff --git a/dlls/msvcr120/tests/msvcr120.c b/dlls/msvcr120/tests/msvcr120.c index 5266e73a3a0..ceb06930b58 100644 --- a/dlls/msvcr120/tests/msvcr120.c +++ b/dlls/msvcr120/tests/msvcr120.c @@ -185,6 +185,7 @@ static int (CDECL *p_fesetround)(int); static int (CDECL *p_fegetexceptflag)(fexcept_t*,int); static int (CDECL *p_fesetexceptflag)(const fexcept_t*,int); static int (CDECL *p_fetestexcept)(int); +static int (CDECL *p_feclearexcept)(int); static int (CDECL *p__clearfp)(void); static _locale_t (__cdecl *p_wcreate_locale)(int, const wchar_t *); static void (__cdecl *p_free_locale)(_locale_t); @@ -263,6 +264,7 @@ static BOOL init(void) SET(p_fegetexceptflag, "fegetexceptflag"); SET(p_fesetexceptflag, "fesetexceptflag"); SET(p_fetestexcept, "fetestexcept"); + SET(p_feclearexcept, "feclearexcept");
SET(p__clearfp, "_clearfp"); SET(p_vsscanf, "vsscanf"); @@ -861,10 +863,10 @@ static void test_feenv(void)
ret = p_fesetexceptflag(NULL, 0); ok(!ret, "fesetexceptflag returned %x\n", ret); + ret = p_feclearexcept(~FE_ALL_EXCEPT); + ok(!ret, "feclearexceptflag returned %x\n", ret);
for(i=0; i<ARRAY_SIZE(tests2); i++) { - p__clearfp(); - except = FE_ALL_EXCEPT; ret = p_fesetexceptflag(&except, tests2[i]); ok(!ret, "fesetexceptflag returned %x\n", ret); @@ -872,7 +874,10 @@ static void test_feenv(void) except = p_fetestexcept(tests2[i]); ok(except == tests2[i], "expected %lx, got %lx\n", tests2[i], except);
- p__clearfp(); + ret = p_feclearexcept(tests2[i]); + ok(!ret, "feclearexceptflag returned %x\n", ret); + except = p_fetestexcept(tests2[i]); + ok(!except, "expected 0, got %lx\n", except);
except = tests2[i]; ret = p_fesetexceptflag(&except, FE_ALL_EXCEPT); @@ -880,9 +885,19 @@ static void test_feenv(void)
except = p_fetestexcept(tests2[i]); ok(except == tests2[i], "expected %lx, got %lx\n", tests2[i], except); + + ret = p_feclearexcept(tests2[i]); + ok(!ret, "feclearexceptflag returned %x\n", ret); + except = p_fetestexcept(tests2[i]); + ok(!except, "expected 0, got %lx\n", except); }
except = FE_ALL_EXCEPT; + ret = p_fesetexceptflag(&except, FE_ALL_EXCEPT); + ok(!ret, "fesetexceptflag returned %x\n", ret); + except = p_fetestexcept(FE_ALL_EXCEPT); + ok(except == FE_ALL_EXCEPT, "expected %x, got %lx\n", FE_ALL_EXCEPT, except); + ret = p_fesetexceptflag(&except, 0); ok(!ret, "fesetexceptflag returned %x\n", ret); except = p_fetestexcept(FE_ALL_EXCEPT); diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec index 2905f4d7b08..b16d1a5b3f0 100644 --- a/dlls/msvcr120_app/msvcr120_app.spec +++ b/dlls/msvcr120_app/msvcr120_app.spec @@ -1809,7 +1809,7 @@ @ cdecl fdim(double double) msvcr120.fdim @ cdecl fdimf(float float) msvcr120.fdimf @ cdecl fdiml(double double) msvcr120.fdiml -@ stub feclearexcept +@ cdecl feclearexcept(long) msvcr120.feclearexcept @ cdecl fegetenv(ptr) msvcr120.fegetenv @ cdecl fegetexceptflag(ptr long) msvcr120.fegetexceptflag @ cdecl fegetround() msvcr120.fegetround diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 8157e02f94a..1d1f5a2d182 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -2257,6 +2257,18 @@ int CDECL fesetexceptflag(const fexcept_t *status, int excepts) env._Fe_stat |= (*status & excepts & FE_ALL_EXCEPT); return fesetenv(&env); } + +/********************************************************************* + * feclearexcept (MSVCR120.@) + */ +int CDECL feclearexcept(int flags) +{ + fenv_t env; + + fegetenv(&env); + env._Fe_stat &= (~flags & FE_ALL_EXCEPT); + return fesetenv(&env); +} #endif
#if _MSVCR_VER>=140 diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index e5fbc6b14b9..8f331825fc4 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -2286,7 +2286,7 @@ @ cdecl fdim(double double) @ cdecl fdimf(float float) @ cdecl fdiml(double double) fdim -@ stub feclearexcept +@ cdecl feclearexcept(long) @ cdecl fegetenv(ptr) @ cdecl fegetexceptflag(ptr long) @ cdecl fegetround() diff --git a/include/msvcrt/fenv.h b/include/msvcrt/fenv.h index 45cd0b9e534..88f9ebd1b4f 100644 --- a/include/msvcrt/fenv.h +++ b/include/msvcrt/fenv.h @@ -39,6 +39,7 @@ _ACRTIMP int __cdecl fesetexceptflag(const fexcept_t*, int); _ACRTIMP int __cdecl fegetround(void); _ACRTIMP int __cdecl fesetround(int); _ACRTIMP int __cdecl fetestexcept(int); +_ACRTIMP int __cdecl feclearexcept(int);
#ifdef __cplusplus }