X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=misc%2Fbuilddeps%2Fwin32%2Fsdl%2Finclude%2FSDL2%2FSDL_bits.h;h=b116cc8d01e99ee3bfbd6446896531b6d17239e8;hp=528da2eac69715d49b3c500c2c9b1bf44d590214;hb=1e434bee7af23e6dfd2130a8eadd131e5da3d643;hpb=c40448285437999d5a83a3c9adb62c58ba8640bc diff --git a/misc/builddeps/win32/sdl/include/SDL2/SDL_bits.h b/misc/builddeps/win32/sdl/include/SDL2/SDL_bits.h index 528da2ea..b116cc8d 100644 --- a/misc/builddeps/win32/sdl/include/SDL2/SDL_bits.h +++ b/misc/builddeps/win32/sdl/include/SDL2/SDL_bits.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -25,8 +25,8 @@ * Functions for fiddling with bits and bitmasks. */ -#ifndef _SDL_bits_h -#define _SDL_bits_h +#ifndef SDL_bits_h_ +#define SDL_bits_h_ #include "SDL_stdinc.h" @@ -47,10 +47,20 @@ extern "C" { * * \return Index of the most significant bit, or -1 if the value is 0. */ +#if defined(__WATCOMC__) && defined(__386__) +extern _inline int _SDL_clz_watcom (Uint32); +#pragma aux _SDL_clz_watcom = \ + "bsr eax, eax" \ + "xor eax, 31" \ + parm [eax] nomemory \ + value [eax] \ + modify exact [eax] nomemory; +#endif + SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x) { -#if defined(__GNUC__) && __GNUC__ >= 4 +#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) /* Count Leading Zeroes builtin in GCC. * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html */ @@ -58,6 +68,11 @@ SDL_MostSignificantBitIndex32(Uint32 x) return -1; } return 31 - __builtin_clz(x); +#elif defined(__WATCOMC__) && defined(__386__) + if (x == 0) { + return -1; + } + return 31 - _SDL_clz_watcom(x); #else /* Based off of Bit Twiddling Hacks by Sean Eron Anderson * , released in the public domain. @@ -86,12 +101,21 @@ SDL_MostSignificantBitIndex32(Uint32 x) #endif } +SDL_FORCE_INLINE SDL_bool +SDL_HasExactlyOneBitSet32(Uint32 x) +{ + if (x && !(x & (x - 1))) { + return SDL_TRUE; + } + return SDL_FALSE; +} + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include "close_code.h" -#endif /* _SDL_bits_h */ +#endif /* SDL_bits_h_ */ /* vi: set ts=4 sw=4 expandtab: */