Fixed bug 3768 - provide a quick copysign() solution for watcom
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Aug 2017 16:30:24 -0700
changeset 113418b3231952c22
parent 11340 97cd834a843e
child 11342 0b924e560249
Fixed bug 3768 - provide a quick copysign() solution for watcom

Ozkan Sezer

The following patch provides a quick copysign solution for Watcom/x86
src/stdlib/SDL_stdlib.c
     1.1 --- a/src/stdlib/SDL_stdlib.c	Mon Aug 21 13:01:22 2017 -0700
     1.2 +++ b/src/stdlib/SDL_stdlib.c	Mon Aug 21 16:30:24 2017 -0700
     1.3 @@ -109,6 +109,12 @@
     1.4      return copysign(x, y);
     1.5  #elif defined(HAVE__COPYSIGN)
     1.6      return _copysign(x, y);
     1.7 +#elif defined(__WATCOMC__) && defined(__386__)
     1.8 +    /* this is nasty as hell, but it works.. */
     1.9 +    unsigned int *xi = (unsigned int *) &x,
    1.10 +                 *yi = (unsigned int *) &y;
    1.11 +    xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
    1.12 +    return x;
    1.13  #else
    1.14      return SDL_uclibc_copysign(x, y);
    1.15  #endif /* HAVE_COPYSIGN */