Reactos

[CRT] Add round and roundf and add it to msvcrtex to make clang v14 happy

+37
+3
sdk/include/crt/math.h
··· 275 275 _Check_return_ long lrintl(_In_ long double x); 276 276 #pragma function(lrint, lrintf, lrintl) 277 277 #endif 278 + 279 + #ifndef _CRTBLD 278 280 _Check_return_ __CRT_INLINE double round(_In_ double x) { return (x < 0) ? ceil(x - 0.5f) : floor(x + 0.5); } 279 281 _Check_return_ __CRT_INLINE float roundf(_In_ float x) { return (x < 0) ? ceilf(x - 0.5f) : floorf(x + 0.5); } 280 282 _Check_return_ __CRT_INLINE long double roundl(_In_ long double x) { return (x < 0) ? ceill(x - 0.5f) : floorl(x + 0.5); } ··· 294 296 _Check_return_ __CRT_INLINE long long llrintf(_In_ float x) { return (long long)((x < 0) ? (x - 0.5f) : (x + 0.5)); } 295 297 _Check_return_ __CRT_INLINE long long llrintl(_In_ long double x) { return (long long)((x < 0) ? (x - 0.5f) : (x + 0.5)); } 296 298 _Check_return_ __CRT_INLINE double log2(_In_ double x) { return log(x) / log(2); } 299 + #endif /* !_CRTBLD */ 297 300 298 301 #ifndef NO_OLDNAMES /* !__STDC__ */ 299 302
+16
sdk/lib/crt/math/round.c
··· 1 + /* 2 + * COPYRIGHT: BSD - See COPYING.ARM in the top level directory 3 + * PROJECT: ReactOS CRT library 4 + * PURPOSE: Portable implementation of round 5 + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) 6 + */ 7 + 8 + #include <math.h> 9 + 10 + double round(double arg) 11 + { 12 + if (arg < 0.0) 13 + return ceil(arg - 0.5); 14 + else 15 + return floor(arg + 0.5); 16 + }
+16
sdk/lib/crt/math/roundf.c
··· 1 + /* 2 + * COPYRIGHT: BSD - See COPYING.ARM in the top level directory 3 + * PROJECT: ReactOS CRT library 4 + * PURPOSE: Portable implementation of roundf 5 + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) 6 + */ 7 + 8 + #include <math.h> 9 + 10 + float roundf(float arg) 11 + { 12 + if (arg < 0.0) 13 + return ceilf(arg - 0.5); 14 + else 15 + return floorf(arg + 0.5); 16 + }
+2
sdk/lib/crt/msvcrtex.cmake
··· 13 13 if(CMAKE_C_COMPILER_ID STREQUAL "Clang") 14 14 # Clang performs some optimizations requiring those funtions 15 15 list(APPEND MSVCRTEX_SOURCE 16 + math/round.c 17 + math/roundf.c 16 18 math/exp2.c 17 19 math/exp2f.c 18 20 )