Backed out commit 898992405fa7 because memset() does a byte fill and SDL_memset4() does a uint32 fill and this change breaks SDL_FillRect()
authorSam Lantinga <slouken@libsdl.org>
Tue, 09 Jul 2013 07:13:58 -0700
changeset 73856e90315f859a
parent 7384 07c5fcdd3cad
child 7386 ff3af8304053
Backed out commit 898992405fa7 because memset() does a byte fill and SDL_memset4() does a uint32 fill and this change breaks SDL_FillRect()
include/SDL_stdinc.h
     1.1 --- a/include/SDL_stdinc.h	Tue Jul 09 10:25:16 2013 -0300
     1.2 +++ b/include/SDL_stdinc.h	Tue Jul 09 07:13:58 2013 -0700
     1.3 @@ -257,9 +257,33 @@
     1.4  /* Note that the semantics are different from memset() in that this is a 32-bit assignment */
     1.5  SDL_FORCE_INLINE void SDL_memset4(void *dst, int val, size_t dwords)
     1.6  {
     1.7 -    SDL_memset(dst, val, dwords * 4);
     1.8 +#if defined(__GNUC__) && defined(i386)
     1.9 +    int u0, u1, u2;
    1.10 +    __asm__ __volatile__ (
    1.11 +        "cld \n\t"
    1.12 +        "rep ; stosl \n\t"
    1.13 +        : "=&D" (u0), "=&a" (u1), "=&c" (u2)
    1.14 +        : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords))
    1.15 +        : "memory"
    1.16 +    );
    1.17 +#else
    1.18 +    size_t _n = (dwords + 3) / 4;
    1.19 +    Uint32 *_p = SDL_static_cast(Uint32 *, dst);
    1.20 +    Uint32 _val = (val);
    1.21 +    if (dwords == 0)
    1.22 +        return;
    1.23 +    switch (dwords % 4)
    1.24 +    {
    1.25 +        case 0: do {    *_p++ = _val;
    1.26 +        case 3:         *_p++ = _val;
    1.27 +        case 2:         *_p++ = _val;
    1.28 +        case 1:         *_p++ = _val;
    1.29 +        } while ( --_n );
    1.30 +    }
    1.31 +#endif
    1.32  }
    1.33  
    1.34 +
    1.35  extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
    1.36  
    1.37  SDL_FORCE_INLINE void *SDL_memcpy4(void *dst, const void *src, size_t dwords)