summaryrefslogtreecommitdiff
path: root/include/SDL_bits.h
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2018-11-19 21:17:00 -0800
committerSam Lantinga <slouken@libsdl.org>2018-11-19 21:17:00 -0800
commit6cdec1257d249ff9f96b2fb3822246426e9b697f (patch)
tree5013e2c00f29b4de6bd02f57786fb2471b992ed5 /include/SDL_bits.h
parentc7183396ed98900f3378642883c8d78e17faac67 (diff)
downloadsdl-6cdec1257d249ff9f96b2fb3822246426e9b697f.tar.gz
Fixed bug 4391 - hid_enumerate() sometimes causes game to freeze for a few seconds
Daniel Gibson Even though my game (dhewm3) doesn't use SDL_INIT_JOYSTICK, SDL_PumpEvent() calls SDL_JoystickUpdate() which ends up calling hid_enumerate() every three seconds, and sometimes on my Win7 box hid_enumerate() takes about 5 seconds, which causes the whole game to freeze for that time.
Diffstat (limited to 'include/SDL_bits.h')
-rw-r--r--include/SDL_bits.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/SDL_bits.h b/include/SDL_bits.h
index eb8322f0d..b6b668378 100644
--- a/include/SDL_bits.h
+++ b/include/SDL_bits.h
@@ -101,6 +101,15 @@ 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
}