From bb951b4b712b3ebcbb9e07fee48b7ee3247b033a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 12:56:53 +0100 Subject: [PATCH] Use C99 fminf and fmaxf --- src/init.c | 24 ------------------------ src/input.c | 2 +- src/internal.h | 2 -- src/monitor.c | 2 +- src/null_monitor.c | 2 +- 5 files changed, 3 insertions(+), 29 deletions(-) diff --git a/src/init.c b/src/init.c index 2b903146..532264e1 100644 --- a/src/init.c +++ b/src/init.c @@ -246,30 +246,6 @@ int _glfw_max(int a, int b) return a > b ? a : b; } -float _glfw_fminf(float a, float b) -{ - if (a != a) - return b; - else if (b != b) - return a; - else if (a < b) - return a; - else - return b; -} - -float _glfw_fmaxf(float a, float b) -{ - if (a != a) - return b; - else if (b != b) - return a; - else if (a > b) - return a; - else - return b; -} - void* _glfw_calloc(size_t count, size_t size) { if (count && size) diff --git a/src/input.c b/src/input.c index 542fabe3..7b3b3402 100644 --- a/src/input.c +++ b/src/input.c @@ -1438,7 +1438,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) if (e->type == _GLFW_JOYSTICK_AXIS) { const float value = js->axes[e->index] * e->axisScale + e->axisOffset; - state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f); + state->axes[i] = fminf(fmaxf(value, -1.f), 1.f); } else if (e->type == _GLFW_JOYSTICK_HATBIT) { diff --git a/src/internal.h b/src/internal.h index 1ab3dea8..aec9eb77 100644 --- a/src/internal.h +++ b/src/internal.h @@ -997,8 +997,6 @@ char** _glfwParseUriList(char* text, int* count); char* _glfw_strdup(const char* source); int _glfw_min(int a, int b); int _glfw_max(int a, int b); -float _glfw_fminf(float a, float b); -float _glfw_fmaxf(float a, float b); void* _glfw_calloc(size_t count, size_t size); void* _glfw_realloc(void* pointer, size_t size); diff --git a/src/monitor.c b/src/monitor.c index 61cdcb8f..b76ac6db 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -487,7 +487,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) // Apply gamma curve value = powf(value, 1.f / gamma) * 65535.f + 0.5f; // Clamp to value range - value = _glfw_fminf(value, 65535.f); + value = fminf(value, 65535.f); values[i] = (unsigned short) value; } diff --git a/src/null_monitor.c b/src/null_monitor.c index 787fde71..63cd462f 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -128,7 +128,7 @@ GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) float value; value = i / (float) (monitor->null.ramp.size - 1); value = powf(value, 1.f / gamma) * 65535.f + 0.5f; - value = _glfw_fminf(value, 65535.f); + value = fminf(value, 65535.f); monitor->null.ramp.red[i] = (unsigned short) value; monitor->null.ramp.green[i] = (unsigned short) value;