From 5661d03be875d28ee72e44a037b653250de24a53 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 23 Mar 2016 10:09:07 +0100 Subject: [PATCH] Replace GLFWuint64 with uint64_t C99 stdint.h is provided by VS 2010 and later. GLFW has not provided testing or binaries for VS 2008 for several releases. For earlier versions of VS there are third-party alternatives: https://msinttypes.googlecode.com/svn/trunk/stdint.h http://www.azillionmonkeys.com/qed/pstdint.h This change does not affect the ABI. --- README.md | 1 - docs/input.dox | 4 ++-- include/GLFW/glfw3.h | 18 +++--------------- src/cocoa_platform.h | 2 +- src/cocoa_time.c | 4 ++-- src/input.c | 6 +++--- src/internal.h | 8 ++++---- src/posix_time.c | 4 ++-- src/posix_time.h | 2 +- src/win32_platform.h | 2 +- src/win32_time.c | 10 +++++----- src/x11_window.c | 2 +- 12 files changed, 25 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 14a9a81f..4b331e24 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,6 @@ does not find Doxygen, the documentation will not be generated. - Added `glfwWaitEventsTimeout` for waiting for events for a set amount of time - Added `glfwSetWindowIcon` for setting the icon of a window - Added `glfwGetTimerValue` and `glfwGetTimerFrequency` for raw timer access - - Added `GLFWuint64` for platform-independent 64-bit unsigned values - Added `GLFW_NO_API` for creating window without contexts - Added `GLFW_CONTEXT_NO_ERROR` context hint for `GL_KHR_no_error` support - Added `GLFW_INCLUDE_VULKAN` for including the Vulkan header diff --git a/docs/input.dox b/docs/input.dox index c426e887..8e4ff7ea 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -571,7 +571,7 @@ You can also access the raw timer value, measured in 1 / frequency seconds, with @ref glfwGetTimerValue. @code -GLFWuint64 value = glfwGetTimerValue(); +uint64_t value = glfwGetTimerValue(); @endcode The frequency of the raw timer varies depending on what time sources are @@ -579,7 +579,7 @@ available on the machine. You can query its frequency, in Hz, with @ref glfwGetTimerFrequency. @code -GLFWuint64 freqency = glfwGetTimerFrequency(); +uint64_t freqency = glfwGetTimerFrequency(); @endcode diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index d88e108a..809e2153 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -120,6 +120,7 @@ extern "C" { * Include it unconditionally to avoid surprising side-effects. */ #include +#include /* Include the chosen client API headers. */ @@ -728,19 +729,6 @@ extern "C" { * GLFW API types *************************************************************************/ -/*! @brief 64-bit unsigned integer. - * - * 64-bit unsigned integer. - * - * @since Added in version 3.2. - */ -#if defined(_MSC_VER) && (_MSC_VER < 1600) -typedef unsigned __int64 GLFWuint64; -#else - #include -typedef uint64_t GLFWuint64; -#endif - /*! @brief Client API function pointer type. * * Generic function pointer used for returning client API function pointers @@ -3735,7 +3723,7 @@ GLFWAPI void glfwSetTime(double time); * * @ingroup input */ -GLFWAPI GLFWuint64 glfwGetTimerValue(void); +GLFWAPI uint64_t glfwGetTimerValue(void); /*! @brief Returns the frequency, in Hz, of the raw timer. * @@ -3755,7 +3743,7 @@ GLFWAPI GLFWuint64 glfwGetTimerValue(void); * * @ingroup input */ -GLFWAPI GLFWuint64 glfwGetTimerFrequency(void); +GLFWAPI uint64_t glfwGetTimerFrequency(void); /*! @brief Makes the context of the specified window current for the calling * thread. diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index bb52252d..eeeb4727 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -118,7 +118,7 @@ typedef struct _GLFWcursorNS // typedef struct _GLFWtimeNS { - GLFWuint64 frequency; + uint64_t frequency; } _GLFWtimeNS; diff --git a/src/cocoa_time.c b/src/cocoa_time.c index 20b938d7..f8db04e9 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -48,12 +48,12 @@ void _glfwInitTimerNS(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWuint64 _glfwPlatformGetTimerValue(void) +uint64_t _glfwPlatformGetTimerValue(void) { return mach_absolute_time(); } -GLFWuint64 _glfwPlatformGetTimerFrequency(void) +uint64_t _glfwPlatformGetTimerFrequency(void) { return _glfw.ns_time.frequency; } diff --git a/src/input.c b/src/input.c index 368a5569..584f858e 100644 --- a/src/input.c +++ b/src/input.c @@ -660,16 +660,16 @@ GLFWAPI void glfwSetTime(double time) } _glfw.timerOffset = _glfwPlatformGetTimerValue() - - (GLFWuint64) (time * _glfwPlatformGetTimerFrequency()); + (uint64_t) (time * _glfwPlatformGetTimerFrequency()); } -GLFWAPI GLFWuint64 glfwGetTimerValue(void) +GLFWAPI uint64_t glfwGetTimerValue(void) { _GLFW_REQUIRE_INIT_OR_RETURN(0); return _glfwPlatformGetTimerValue(); } -GLFWAPI GLFWuint64 glfwGetTimerFrequency(void) +GLFWAPI uint64_t glfwGetTimerFrequency(void) { _GLFW_REQUIRE_INIT_OR_RETURN(0); return _glfwPlatformGetTimerFrequency(); diff --git a/src/internal.h b/src/internal.h index 42835d14..fc33b0de 100644 --- a/src/internal.h +++ b/src/internal.h @@ -91,7 +91,7 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); typedef void* VkInstance; typedef void* VkPhysicalDevice; -typedef GLFWuint64 VkSurfaceKHR; +typedef uint64_t VkSurfaceKHR; typedef unsigned int VkFlags; typedef unsigned int VkBool32; @@ -431,7 +431,7 @@ struct _GLFWlibrary _GLFWmonitor** monitors; int monitorCount; - GLFWuint64 timerOffset; + uint64_t timerOffset; struct { GLFWbool available; @@ -600,12 +600,12 @@ const char* _glfwPlatformGetJoystickName(int joy); /*! @copydoc glfwGetTimerValue * @ingroup platform */ -GLFWuint64 _glfwPlatformGetTimerValue(void); +uint64_t _glfwPlatformGetTimerValue(void); /*! @copydoc glfwGetTimerFrequency * @ingroup platform */ -GLFWuint64 _glfwPlatformGetTimerFrequency(void); +uint64_t _glfwPlatformGetTimerFrequency(void); /*! @ingroup platform */ diff --git a/src/posix_time.c b/src/posix_time.c index 228f2f7e..7b2d1ab2 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -60,7 +60,7 @@ void _glfwInitTimerPOSIX(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWuint64 _glfwPlatformGetTimerValue(void) +uint64_t _glfwPlatformGetTimerValue(void) { #if defined(CLOCK_MONOTONIC) if (_glfw.posix_time.monotonic) @@ -78,7 +78,7 @@ GLFWuint64 _glfwPlatformGetTimerValue(void) } } -GLFWuint64 _glfwPlatformGetTimerFrequency(void) +uint64_t _glfwPlatformGetTimerFrequency(void) { return _glfw.posix_time.frequency; } diff --git a/src/posix_time.h b/src/posix_time.h index 31591737..237db3a9 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -38,7 +38,7 @@ typedef struct _GLFWtimePOSIX { GLFWbool monotonic; - GLFWuint64 frequency; + uint64_t frequency; } _GLFWtimePOSIX; diff --git a/src/win32_platform.h b/src/win32_platform.h index 36e3ead2..b94b0b0d 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -275,7 +275,7 @@ typedef struct _GLFWcursorWin32 typedef struct _GLFWtimeWin32 { GLFWbool hasPC; - GLFWuint64 frequency; + uint64_t frequency; } _GLFWtimeWin32; diff --git a/src/win32_time.c b/src/win32_time.c index ec6294db..43e67351 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -36,7 +36,7 @@ // void _glfwInitTimerWin32(void) { - GLFWuint64 frequency; + uint64_t frequency; if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) { @@ -55,19 +55,19 @@ void _glfwInitTimerWin32(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWuint64 _glfwPlatformGetTimerValue(void) +uint64_t _glfwPlatformGetTimerValue(void) { if (_glfw.win32_time.hasPC) { - GLFWuint64 value; + uint64_t value; QueryPerformanceCounter((LARGE_INTEGER*) &value); return value; } else - return (GLFWuint64) _glfw_timeGetTime(); + return (uint64_t) _glfw_timeGetTime(); } -GLFWuint64 _glfwPlatformGetTimerFrequency(void) +uint64_t _glfwPlatformGetTimerFrequency(void) { return _glfw.win32_time.frequency; } diff --git a/src/x11_window.c b/src/x11_window.c index aaefcd81..9e004010 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1763,7 +1763,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, if (!_glfwPlatformWindowVisible(window) && _glfw.x11.NET_REQUEST_FRAME_EXTENTS) { - GLFWuint64 base; + uint64_t base; XEvent event; // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to