Mac and Linux SDL2 binary snapshots
Edward Rudd
2018-08-19 b362dde5a356d24199d91b600e2ac8be6b59b5c4
include/SDL2/SDL_bits.h
@@ -1,6 +1,6 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
  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 @@
 *
 *  \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 @@
        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
     * <seander@cs.stanford.edu>, released in the public domain.
@@ -92,6 +107,6 @@
#endif
#include "close_code.h"
#endif /* _SDL_bits_h */
#endif /* SDL_bits_h_ */
/* vi: set ts=4 sw=4 expandtab: */