[PATCH v2] msvcrt: Implement nearbyint and nearbyintf

Piotr Caban piotr.caban at gmail.com
Fri Nov 18 10:11:24 CST 2016


Hi,

it looks like your patch got corrupted by your mail client. Here are 
some hints about sending patches:
https://wiki.winehq.org/Submitting_Patches#Sending_the_patch

if you have any questions please let me know.

Thanks,
Piotr

On 18/11/16 00:45, Stefan Silviu wrote:
> It now has a fallback if the functions are missing.
>
> Fixes https://bugs.winehq.org/show_bug.cgi?id=41695
>
> Signed-off-by: Stefan Silviu <sylviu44 at gmail.com>
> ---
>   configure                                          |  2 ++
>   configure.ac                                       |  2 ++
>   .../api-ms-win-crt-math-l1-1-0.spec                |  4 ++--
>   dlls/msvcrt/math.c                                 | 24 ++++++++++++++++++++++
>   dlls/msvcrt/msvcrt.spec                            |  2 ++
>   dlls/ucrtbase/ucrtbase.spec                        |  4 ++--
>   include/msvcrt/math.h                              |  3 +++
>   7 files changed, 37 insertions(+), 4 deletions(-)
>
> diff --git a/configure b/configure
> index f91d64d..d347956 100755
> --- a/configure
> +++ b/configure
> @@ -17121,6 +17121,8 @@ for ac_func in \
>    lrintf \
>    lround \
>    lroundf \
> +  nearbyint \
> +  nearbyintf \
>    powl \
>    remainder \
>    remainderf \
> diff --git a/configure.ac b/configure.ac
> index 2489ac0..9c03fc8 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2554,6 +2554,8 @@ AC_CHECK_FUNCS(\
>    lrintf \
>    lround \
>    lroundf \
> +  nearbyint \
> +  nearbyintf \
>    powl \
>    remainder \
>    remainderf \
> diff --git a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
> b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
> index f886b97..b781276 100644
> --- a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
> +++ b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
> @@ -291,8 +291,8 @@
>   @ stub nan
>   @ stub nanf
>   @ stub nanl
> -@ stub nearbyint
> -@ stub nearbyintf
> +@ cdecl nearbyint(double) ucrtbase.nearbyint
> +@ cdecl nearbyintf(float) ucrtbase.nearbyintf
>   @ stub nearbyintl
>   @ cdecl nextafter(double double) ucrtbase.nextafter
>   @ cdecl nextafterf(float float) ucrtbase.nextafterf
> diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
> index e87151a..32c32b0 100644
> --- a/dlls/msvcrt/math.c
> +++ b/dlls/msvcrt/math.c
> @@ -1354,6 +1354,30 @@ double CDECL MSVCRT__yn(int order, double num)
>   }
>
>   /*********************************************************************
> + * _nearbyint (MSVCRT.@)
> + */
> +double CDECL MSVCRT_nearbyint(double num)
> +{
> +  #ifdef HAVE_NEARBYINT
> +    return nearbyint(num);
> +  #else
> +    return num >= 0 ? floor(num + 0.5) : ceil(num - 0.5);
> +  #endif
> +}
> +
> +/*********************************************************************
> + * _nearbyintf (MSVCRT.@)
> + */
> +float CDECL MSVCRT_nearbyintf(float num)
> +{
> +  #ifdef HAVE_NEARBYINTF
> +    return nearbyintf(num);
> +  #else
> +    return MSVCRT_nearbyint(num);
> +  #endif
> +}
> +
> +/*********************************************************************
>    * _nextafter (MSVCRT.@)
>    */
>   double CDECL MSVCRT__nextafter(double num, double next)
> diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
> index 0c1d4ad..d44e880 100644
> --- a/dlls/msvcrt/msvcrt.spec
> +++ b/dlls/msvcrt/msvcrt.spec
> @@ -837,6 +837,8 @@
>   @ cdecl _msize(ptr)
>   # stub -arch=win32 _msize_debug(ptr long)
>   # stub -arch=win64 _msize_dbg(ptr long)
> +@ cdecl nearbyint(double) MSVCRT_nearbyint
> +@ cdecl nearbyintf(float) MSVCRT_nearbyintf
>   @ cdecl _nextafter(double double) MSVCRT__nextafter
>   @ cdecl -arch=arm,x86_64 _nextafterf(float float) MSVCRT__nextafterf
>   @ cdecl _onexit(ptr) MSVCRT__onexit
> diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec
> index 2aa0563..111de2e 100644
> --- a/dlls/ucrtbase/ucrtbase.spec
> +++ b/dlls/ucrtbase/ucrtbase.spec
> @@ -2432,8 +2432,8 @@
>   @ stub nan
>   @ stub nanf
>   @ stub nanl
> -@ stub nearbyint
> -@ stub nearbyintf
> +@ cdecl nearbyint(double) MSVCRT_nearbyint
> +@ cdecl nearbyintf(float) MSVCRT_nearbyintf
>   @ stub nearbyintl
>   @ cdecl nextafter(double double) MSVCRT__nextafter
>   @ cdecl nextafterf(float float) MSVCRT__nextafterf
> diff --git a/include/msvcrt/math.h b/include/msvcrt/math.h
> index c76fe0d..5b42b4d 100644
> --- a/include/msvcrt/math.h
> +++ b/include/msvcrt/math.h
> @@ -148,6 +148,9 @@ float __cdecl fmodf(float, float);
>
>   #define ldexpf(x,y) ((float)ldexp((double)(x),(y)))
>
> +double __cdecl nearbyint(double);
> +float __cdecl nearbyintf(float);
> +
>   float __cdecl _hypotf(float, float);
>
>   int __cdecl _matherr(struct _exception*);




More information about the wine-devel mailing list