Build with -Wfloat-conversion + fix all warnings

This commit is contained in:
Anonymous Maarten 2024-06-03 23:33:29 +02:00 committed by GitHub
parent 17c459e384
commit a919774fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 199 additions and 203 deletions

View file

@ -59,6 +59,11 @@ function(SDL_AddCommonCompilerFlags TARGET)
sdl_target_compile_option_all_languages(${TARGET} "-Wundef") sdl_target_compile_option_all_languages(${TARGET} "-Wundef")
endif() endif()
check_c_compiler_flag(-Wfloat-conversion HAVE_GCC_WFLOAT_CONVERSION)
if(HAVE_GCC_WFLOAT_CONVERSION)
sdl_target_compile_option_all_languages(${TARGET} "-Wfloat-conversion")
endif()
check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING) check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING)
if(HAVE_GCC_NO_STRICT_ALIASING) if(HAVE_GCC_NO_STRICT_ALIASING)
sdl_target_compile_option_all_languages(${TARGET} "-fno-strict-aliasing") sdl_target_compile_option_all_languages(${TARGET} "-fno-strict-aliasing")

View file

@ -966,8 +966,8 @@ static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec
const int thisw = thisspec->width; const int thisw = thisspec->width;
const int thish = thisspec->height; const int thish = thisspec->height;
const float thisaspect = ((float)thisw) / ((float)thish); const float thisaspect = ((float)thisw) / ((float)thish);
const float aspectdiff = SDL_fabs(wantaspect - thisaspect); const float aspectdiff = SDL_fabsf(wantaspect - thisaspect);
const float diff = SDL_fabs(closestaspect - thisaspect); const float diff = SDL_fabsf(closestaspect - thisaspect);
const int diffw = SDL_abs(thisw - wantw); const int diffw = SDL_abs(thisw - wantw);
if (diff < epsilon) { // matches current closestaspect? See if resolution is closer in size. if (diff < epsilon) { // matches current closestaspect? See if resolution is closer in size.
if (diffw < closestdiffw) { if (diffw < closestdiffw) {
@ -1022,7 +1022,7 @@ static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec
} }
const float thisfps = thisspec->interval_denominator ? (thisspec->interval_numerator / thisspec->interval_denominator) : 0.0f; const float thisfps = thisspec->interval_denominator ? (thisspec->interval_numerator / thisspec->interval_denominator) : 0.0f;
const float fpsdiff = SDL_fabs(wantfps - thisfps); const float fpsdiff = SDL_fabsf(wantfps - thisfps);
if (fpsdiff < closestfps) { // this is a closest FPS? Take it until something closer arrives. if (fpsdiff < closestfps) { // this is a closest FPS? Take it until something closer arrives.
closestfps = fpsdiff; closestfps = fpsdiff;
closest->interval_numerator = thisspec->interval_numerator; closest->interval_numerator = thisspec->interval_numerator;

View file

@ -688,7 +688,7 @@ static int SDL_SYS_ToDirection(Uint16 *dest, const SDL_HapticDirection *src)
} else if (!src->dir[0]) { } else if (!src->dir[0]) {
*dest = (src->dir[1] >= 0 ? 0x8000 : 0); *dest = (src->dir[1] >= 0 ? 0x8000 : 0);
} else { } else {
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */ float f = SDL_atan2f(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
/* /*
SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
- Y-axis-value is the second coordinate (from center to SOUTH) - Y-axis-value is the second coordinate (from center to SOUTH)

View file

@ -1252,14 +1252,14 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
GCControllerDirectionPad *dpad; GCControllerDirectionPad *dpad;
dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadOne]; dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadOne];
if (dpad.xAxis.value || dpad.yAxis.value) { if (dpad.xAxis.value != 0.f || dpad.yAxis.value != 0.f) {
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f); SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
} else { } else {
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_RELEASED, 0.0f, 0.0f, 1.0f); SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_RELEASED, 0.0f, 0.0f, 1.0f);
} }
dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadTwo]; dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadTwo];
if (dpad.xAxis.value || dpad.yAxis.value) { if (dpad.xAxis.value != 0.f || dpad.yAxis.value != 0.f) {
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f); SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
} else { } else {
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_RELEASED, 0.0f, 0.0f, 1.0f); SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_RELEASED, 0.0f, 0.0f, 1.0f);

View file

@ -206,7 +206,7 @@ static SDL_bool GetHIDScaledCalibratedState(recDevice *pDevice, recElement *pEle
if (readScale == 0) { if (readScale == 0) {
returnValue = SDL_TRUE; /* no scaling at all */ returnValue = SDL_TRUE; /* no scaling at all */
} else { } else {
*pValue = ((*pValue - pElement->minReport) * deviceScale / readScale) + min; *pValue = (Sint32)(((*pValue - pElement->minReport) * deviceScale / readScale) + min);
returnValue = SDL_TRUE; returnValue = SDL_TRUE;
} }
} }

View file

@ -41,29 +41,23 @@ static const enum PspCtrlButtons button_map[] = {
}; };
static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */
typedef struct
{
int x;
int y;
} point;
/* 4 points define the bezier-curve. */ /* 4 points define the bezier-curve. */
static point a = { 0, 0 }; static SDL_Point a = { 0, 0 };
static point b = { 50, 0 }; static SDL_Point b = { 50, 0 };
static point c = { 78, 32767 }; static SDL_Point c = { 78, 32767 };
static point d = { 128, 32767 }; static SDL_Point d = { 128, 32767 };
/* simple linear interpolation between two points */ /* simple linear interpolation between two points */
static SDL_INLINE void lerp(point *dest, point *pt_a, point *pt_b, float t) static SDL_INLINE void lerp(SDL_Point *dest, const SDL_Point *pt_a, const SDL_Point *pt_b, float t)
{ {
dest->x = pt_a->x + (pt_b->x - pt_a->x) * t; dest->x = pt_a->x + (int)((pt_b->x - pt_a->x) * t);
dest->y = pt_a->y + (pt_b->y - pt_a->y) * t; dest->y = pt_a->y + (int)((pt_b->y - pt_a->y) * t);
} }
/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ /* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */
static int calc_bezier_y(float t) static int calc_bezier_y(float t)
{ {
point ab, bc, cd, abbc, bccd, dest; SDL_Point ab, bc, cd, abbc, bccd, dest;
lerp(&ab, &a, &b, t); /* point between a and b */ lerp(&ab, &a, &b, t); /* point between a and b */
lerp(&bc, &b, &c, t); /* point between b and c */ lerp(&bc, &b, &c, t); /* point between b and c */
lerp(&cd, &c, &d, t); /* point between c and d */ lerp(&cd, &c, &d, t); /* point between c and d */

View file

@ -64,30 +64,24 @@ static const unsigned int ext_button_map[] = {
static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */
typedef struct
{
int x;
int y;
} point;
/* 4 points define the bezier-curve. */ /* 4 points define the bezier-curve. */
/* The Vita has a good amount of analog travel, so use a linear curve */ /* The Vita has a good amount of analog travel, so use a linear curve */
static point a = { 0, 0 }; static SDL_Point a = { 0, 0 };
static point b = { 0, 0 }; static SDL_Point b = { 0, 0 };
static point c = { 128, 32767 }; static SDL_Point c = { 128, 32767 };
static point d = { 128, 32767 }; static SDL_Point d = { 128, 32767 };
/* simple linear interpolation between two points */ /* simple linear interpolation between two points */
static SDL_INLINE void lerp(point *dest, point *first, point *second, float t) static SDL_INLINE void lerp(SDL_Point *dest, const SDL_Point *first, const SDL_Point *second, float t)
{ {
dest->x = first->x + (second->x - first->x) * t; dest->x = first->x + (int)((second->x - first->x) * t);
dest->y = first->y + (second->y - first->y) * t; dest->y = first->y + (int)((second->y - first->y) * t);
} }
/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ /* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */
static int calc_bezier_y(float t) static int calc_bezier_y(float t)
{ {
point ab, bc, cd, abbc, bccd, dest; SDL_Point ab, bc, cd, abbc, bccd, dest;
lerp(&ab, &a, &b, t); /* point between a and b */ lerp(&ab, &a, &b, t); /* point between a and b */
lerp(&bc, &b, &c, t); /* point between b and c */ lerp(&bc, &b, &c, t); /* point between b and c */
lerp(&cd, &c, &d, t); /* point between c and d */ lerp(&cd, &c, &d, t); /* point between c and d */

View file

@ -43,13 +43,14 @@ SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *p
return SDL_TRUE; return SDL_TRUE;
} }
if (batteryState.charging) if (batteryState.charging) {
*state = batteryState.chargingTime == 0.0 ? SDL_POWERSTATE_CHARGED : SDL_POWERSTATE_CHARGING; *state = batteryState.chargingTime == 0.0 ? SDL_POWERSTATE_CHARGED : SDL_POWERSTATE_CHARGING;
else } else {
*state = SDL_POWERSTATE_ON_BATTERY; *state = SDL_POWERSTATE_ON_BATTERY;
}
*seconds = batteryState.dischargingTime; *seconds = (int)batteryState.dischargingTime;
*percent = batteryState.level * 100; *percent = (int)batteryState.level * 100;
return SDL_TRUE; return SDL_TRUE;
} }

View file

@ -1047,8 +1047,8 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const
viewport->w, viewport->h); viewport->w, viewport->h);
if (viewport->w && viewport->h) { if (viewport->w && viewport->h) {
data->glOrtho((GLdouble)0, (GLdouble)viewport->w, data->glOrtho((GLdouble)0, (GLdouble)viewport->w,
(GLdouble)istarget ? 0 : viewport->h, (GLdouble)(istarget ? 0 : viewport->h),
(GLdouble)istarget ? viewport->h : 0, (GLdouble)(istarget ? viewport->h : 0),
0.0, 1.0); 0.0, 1.0);
} }
data->glMatrixMode(GL_MODELVIEW); data->glMatrixMode(GL_MODELVIEW);

View file

@ -128,10 +128,8 @@ typedef struct
float x, y, z; float x, y, z;
} VertTCV; } VertTCV;
#define PI 3.14159265358979f #define radToDeg(x) ((x)*180.f / SDL_PI_F)
#define degToRad(x) ((x)*SDL_PI_F / 180.f)
#define radToDeg(x) ((x)*180.f / PI)
#define degToRad(x) ((x)*PI / 180.f)
static float MathAbs(float x) static float MathAbs(float x)
{ {
@ -809,7 +807,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
float curX = x; float curX = x;
const float endX = x + width; const float endX = x + width;
const float slice = 64.0f; const float slice = 64.0f;
const size_t count = SDL_ceilf(width / slice); const size_t count = (size_t)SDL_ceilf(width / slice);
size_t i; size_t i;
float ustep = (u1 - u0) / width * slice; float ustep = (u1 - u0) / width * slice;
@ -877,7 +875,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T
cmd->data.draw.count = 1; cmd->data.draw.count = 1;
MathSincos(degToRad(360 - angle), &s, &c); MathSincos(degToRad((float)(360 - angle)), &s, &c);
cw1 = c * -centerx; cw1 = c * -centerx;
sw1 = s * -centerx; sw1 = s * -centerx;

View file

@ -838,8 +838,8 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
if (data->drawstate.viewport_dirty) { if (data->drawstate.viewport_dirty) {
const SDL_Rect *viewport = &data->drawstate.viewport; const SDL_Rect *viewport = &data->drawstate.viewport;
float sw = viewport->w / 2.; float sw = viewport->w / 2.f;
float sh = viewport->h / 2.; float sh = viewport->h / 2.f;
float x_scale = sw; float x_scale = sw;
float x_off = viewport->x + sw; float x_off = viewport->x + sw;

View file

@ -1367,7 +1367,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (state->window_maxW || state->window_maxH) { if (state->window_maxW || state->window_maxH) {
SDL_SetWindowMaximumSize(state->windows[i], state->window_maxW, state->window_maxH); SDL_SetWindowMaximumSize(state->windows[i], state->window_maxW, state->window_maxH);
} }
if (state->window_min_aspect || state->window_max_aspect) { if (state->window_min_aspect != 0.f || state->window_max_aspect != 0.f) {
SDL_SetWindowAspectRatio(state->windows[i], state->window_min_aspect, state->window_max_aspect); SDL_SetWindowAspectRatio(state->windows[i], state->window_min_aspect, state->window_max_aspect);
} }
SDL_GetWindowSize(state->windows[i], &w, &h); SDL_GetWindowSize(state->windows[i], &w, &h);

View file

@ -796,7 +796,7 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
if (tonemap_operator) { if (tonemap_operator) {
if (SDL_strncmp(tonemap_operator, "*=", 2) == 0) { if (SDL_strncmp(tonemap_operator, "*=", 2) == 0) {
tonemap.op = SDL_TONEMAP_LINEAR; tonemap.op = SDL_TONEMAP_LINEAR;
tonemap.data.linear.scale = SDL_atof(tonemap_operator + 2); tonemap.data.linear.scale = (float)SDL_atof(tonemap_operator + 2);
} else if (SDL_strcasecmp(tonemap_operator, "chrome") == 0) { } else if (SDL_strcasecmp(tonemap_operator, "chrome") == 0) {
tonemap.op = SDL_TONEMAP_CHROME; tonemap.op = SDL_TONEMAP_CHROME;
} else if (SDL_strcasecmp(tonemap_operator, "none") == 0) { } else if (SDL_strcasecmp(tonemap_operator, "none") == 0) {

View file

@ -1497,8 +1497,8 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
if (focus && ([theEvent window] == ((__bridge SDL_CocoaWindowData *)focus->driverdata).nswindow)) { if (focus && ([theEvent window] == ((__bridge SDL_CocoaWindowData *)focus->driverdata).nswindow)) {
rc = SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, state, button, clicks); rc = SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, state, button, clicks);
} else { } else {
const int orig_x = mouse->x; const float orig_x = mouse->x;
const int orig_y = mouse->y; const float orig_y = mouse->y;
const NSPoint point = [theEvent locationInWindow]; const NSPoint point = [theEvent locationInWindow];
mouse->x = (int)point.x; mouse->x = (int)point.x;
mouse->y = (int)(window->h - point.y); mouse->y = (int)(window->h - point.y);
@ -2376,8 +2376,8 @@ void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int
viewport = [contentView convertRectToBacking:viewport]; viewport = [contentView convertRectToBacking:viewport];
} }
*w = viewport.size.width; *w = (int)viewport.size.width;
*h = viewport.size.height; *h = (int)viewport.size.height;
} }
} }

View file

@ -886,7 +886,7 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u
emscripten_get_element_css_size(window_data->canvas_id, &w, &h); emscripten_get_element_css_size(window_data->canvas_id, &w, &h);
} }
emscripten_set_canvas_element_size(window_data->canvas_id, w * window_data->pixel_ratio, h * window_data->pixel_ratio); emscripten_set_canvas_element_size(window_data->canvas_id, SDL_lroundf(w * window_data->pixel_ratio), SDL_lroundf(h * window_data->pixel_ratio));
/* set_canvas_size unsets this */ /* set_canvas_size unsets this */
if (!window_data->external_size && window_data->pixel_ratio != 1.0f) { if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
@ -899,7 +899,7 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u
window_data->window->h = 0; window_data->window->h = 0;
} }
SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, w, h); SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(w), SDL_lroundf(h));
} }
} }
@ -915,7 +915,7 @@ Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userDat
if (window_data->fullscreen_resize) { if (window_data->fullscreen_resize) {
double css_w, css_h; double css_w, css_h;
emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h); emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h);
SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, css_w, css_h); SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(css_w), SDL_lroundf(css_h));
} }
return 0; return 0;

View file

@ -215,9 +215,9 @@ static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, S
scaled_w = css_w * wdata->pixel_ratio; scaled_w = css_w * wdata->pixel_ratio;
scaled_h = css_h * wdata->pixel_ratio; scaled_h = css_h * wdata->pixel_ratio;
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, css_w, css_h); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(css_w), SDL_lroundf(css_h));
} }
emscripten_set_canvas_element_size(wdata->canvas_id, scaled_w, scaled_h); emscripten_set_canvas_element_size(wdata->canvas_id, SDL_lroundf(scaled_w), SDL_lroundf(scaled_h));
/* if the size is not being controlled by css, we need to scale down for hidpi */ /* if the size is not being controlled by css, we need to scale down for hidpi */
if (!wdata->external_size) { if (!wdata->external_size) {
@ -252,7 +252,7 @@ static void Emscripten_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
data->pixel_ratio = emscripten_get_device_pixel_ratio(); data->pixel_ratio = emscripten_get_device_pixel_ratio();
} }
emscripten_set_canvas_element_size(data->canvas_id, window->floating.w * data->pixel_ratio, window->floating.h * data->pixel_ratio); emscripten_set_canvas_element_size(data->canvas_id, SDL_lroundf(window->floating.w * data->pixel_ratio), SDL_lroundf(window->floating.h * data->pixel_ratio));
/*scale canvas down*/ /*scale canvas down*/
if (!data->external_size && data->pixel_ratio != 1.0f) { if (!data->external_size && data->pixel_ratio != 1.0f) {
@ -268,8 +268,8 @@ static void Emscripten_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window
SDL_WindowData *data; SDL_WindowData *data;
if (window->driverdata) { if (window->driverdata) {
data = window->driverdata; data = window->driverdata;
*w = window->w * data->pixel_ratio; *w = SDL_lroundf(window->w * data->pixel_ratio);
*h = window->h * data->pixel_ratio; *h = SDL_lroundf(window->h * data->pixel_ratio);
} }
} }

View file

@ -422,7 +422,7 @@ static int KMSDRM_MoveCursor(SDL_Cursor *cursor)
return SDL_SetError("Cursor not initialized properly."); return SDL_SetError("Cursor not initialized properly.");
} }
ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y); ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, (int)mouse->x, (int)mouse->y);
if (ret) { if (ret) {
return SDL_SetError("drmModeMoveCursor() failed."); return SDL_SetError("drmModeMoveCursor() failed.");

View file

@ -366,7 +366,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
new_mode_parameters.visibleRegion.height = window->h; new_mode_parameters.visibleRegion.height = window->h;
/* SDL (and DRM, if we look at drmModeModeInfo vrefresh) uses plain integer Hz for /* SDL (and DRM, if we look at drmModeModeInfo vrefresh) uses plain integer Hz for
display mode refresh rate, but Vulkan expects higher precision. */ display mode refresh rate, but Vulkan expects higher precision. */
new_mode_parameters.refreshRate = window->current_fullscreen_mode.refresh_rate * 1000; new_mode_parameters.refreshRate = (uint32_t)(window->current_fullscreen_mode.refresh_rate * 1000);
SDL_zero(display_mode_create_info); SDL_zero(display_mode_create_info);
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR; display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;

View file

@ -386,8 +386,8 @@ int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
for (UIScreenMode *uimode in availableModes) { for (UIScreenMode *uimode in availableModes) {
CGSize size = GetUIScreenModeSize(data.uiscreen, uimode); CGSize size = GetUIScreenModeSize(data.uiscreen, uimode);
int w = size.width; int w = (int)size.width;
int h = size.height; int h = (int)size.height;
/* Make sure the width/height are oriented correctly */ /* Make sure the width/height are oriented correctly */
if (isLandscape != (w > h)) { if (isLandscape != (w > h)) {
@ -449,10 +449,10 @@ int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ
return -1; return -1;
} }
rect->x += frame.origin.x; rect->x += (int)frame.origin.x;
rect->y += frame.origin.y; rect->y += (int)frame.origin.y;
rect->w = frame.size.width; rect->w = (int)frame.size.width;
rect->h = frame.size.height; rect->h = (int)frame.size.height;
} }
return 0; return 0;

View file

@ -522,8 +522,8 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
#endif #endif
if (self.keyboardHeight) { if (self.keyboardHeight) {
int rectbottom = self.textInputRect.y + self.textInputRect.h; int rectbottom = (int)(self.textInputRect.y + self.textInputRect.h);
int keybottom = self.view.bounds.size.height - self.keyboardHeight; int keybottom = (int)(self.view.bounds.size.height - self.keyboardHeight);
if (keybottom < rectbottom) { if (keybottom < rectbottom) {
offset.y = keybottom - rectbottom; offset.y = keybottom - rectbottom;
} }

View file

@ -376,8 +376,8 @@ void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int
/* Integer truncation of fractional values matches SDL_uikitmetalview and /* Integer truncation of fractional values matches SDL_uikitmetalview and
* SDL_uikitopenglview. */ * SDL_uikitopenglview. */
*w = size.width * scale; *w = (int)(size.width * scale);
*h = size.height * scale; *h = (int)(size.height * scale);
} }
} }

View file

@ -173,11 +173,11 @@ void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita
y = (vita_y - area_info[port].y) / (area_info[port].h - 1); y = (vita_y - area_info[port].y) / (area_info[port].h - 1);
} }
x = SDL_max(x, 0.0); x = SDL_max(x, 0.0f);
x = SDL_min(x, 1.0); x = SDL_min(x, 1.0f);
y = SDL_max(y, 0.0); y = SDL_max(y, 0.0f);
y = SDL_min(y, 1.0); y = SDL_min(y, 1.0f);
*sdl_x = x; *sdl_x = x;
*sdl_y = y; *sdl_y = y;

View file

@ -998,12 +998,12 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri
if (window_data->current.logical_width <= 1) { if (window_data->current.logical_width <= 1) {
x = 0.5f; x = 0.5f;
} else { } else {
x = wl_fixed_to_double(fx) / (window_data->current.logical_width - 1); x = (float)wl_fixed_to_double(fx) / (window_data->current.logical_width - 1);
} }
if (window_data->current.logical_height <= 1) { if (window_data->current.logical_height <= 1) {
y = 0.5f; y = 0.5f;
} else { } else {
y = wl_fixed_to_double(fy) / (window_data->current.logical_height - 1); y = (float)wl_fixed_to_double(fy) / (window_data->current.logical_height - 1);
} }
SDL_SetMouseFocus(window_data->sdlwindow); SDL_SetMouseFocus(window_data->sdlwindow);
@ -1026,8 +1026,8 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial
SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface); SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
if (window_data) { if (window_data) {
const float x = wl_fixed_to_double(fx) / window_data->current.logical_width; const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width;
const float y = wl_fixed_to_double(fy) / window_data->current.logical_height; const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height;
SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch, SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
(SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_FALSE, x, y, 0.0f); (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_FALSE, x, y, 0.0f);
@ -1055,8 +1055,8 @@ static void touch_handler_motion(void *data, struct wl_touch *touch, uint32_t ti
SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface); SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
if (window_data) { if (window_data) {
const float x = wl_fixed_to_double(fx) / window_data->current.logical_width; const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width;
const float y = wl_fixed_to_double(fy) / window_data->current.logical_height; const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height;
SDL_SendTouchMotion(Wayland_GetPointerTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch, SDL_SendTouchMotion(Wayland_GetPointerTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
(SDL_FingerID)(id + 1), window_data->sdlwindow, x, y, 1.0f); (SDL_FingerID)(id + 1), window_data->sdlwindow, x, y, 1.0f);
@ -2783,7 +2783,7 @@ static void tablet_tool_handle_slider(void *data, struct zwp_tablet_tool_v2 *too
{ {
struct SDL_WaylandTool *sdltool = data; struct SDL_WaylandTool *sdltool = data;
struct SDL_WaylandTabletInput *input = sdltool->tablet; struct SDL_WaylandTabletInput *input = sdltool->tablet;
input->current_pen.update_status.axes[SDL_PEN_AXIS_SLIDER] = position / 65535.0; input->current_pen.update_status.axes[SDL_PEN_AXIS_SLIDER] = position / 65535.f;
} }
static void tablet_tool_handle_wheel(void *data, struct zwp_tablet_tool_v2 *tool, int32_t degrees, int32_t clicks) static void tablet_tool_handle_wheel(void *data, struct zwp_tablet_tool_v2 *tool, int32_t degrees, int32_t clicks)

View file

@ -350,7 +350,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, struct Wayland_C
/* Cursors use integer scaling. */ /* Cursors use integer scaling. */
*scale = SDL_ceilf(focusdata->windowed_scale_factor); *scale = SDL_ceilf(focusdata->windowed_scale_factor);
size *= *scale; size *= (int)*scale;
for (int i = 0; i < vdata->num_cursor_themes; i += 1) { for (int i = 0; i < vdata->num_cursor_themes; i += 1) {
if (vdata->cursor_themes[i].size == size) { if (vdata->cursor_themes[i].size == size) {
theme = vdata->cursor_themes[i].theme; theme = vdata->cursor_themes[i].theme;
@ -638,12 +638,12 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor)
} }
} }
wl_surface_set_buffer_scale(data->surface, scale); wl_surface_set_buffer_scale(data->surface, (int32_t)scale);
wl_pointer_set_cursor(pointer, wl_pointer_set_cursor(pointer,
input->pointer_enter_serial, input->pointer_enter_serial,
data->surface, data->surface,
data->hot_x / scale, (int32_t)(data->hot_x / scale),
data->hot_y / scale); (int32_t)(data->hot_y / scale));
if (data->is_system_cursor) { if (data->is_system_cursor) {
wl_surface_attach(data->surface, data->cursor_data.system.frames[0].wl_buffer, 0, 0); wl_surface_attach(data->surface, data->cursor_data.system.frames[0].wl_buffer, 0, 0);

View file

@ -846,10 +846,10 @@ static void handle_configure_xdg_toplevel(void *data,
/* Aspect correction. */ /* Aspect correction. */
const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height; const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height;
if (window->min_aspect && aspect < window->min_aspect) { if (window->min_aspect != 0.f && aspect < window->min_aspect) {
wind->requested.logical_height = SDL_roundf((float)wind->requested.logical_width / window->min_aspect); wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect);
} else if (window->max_aspect && aspect > window->max_aspect) { } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
wind->requested.logical_width = SDL_roundf((float)wind->requested.logical_height * window->max_aspect); wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect);
} }
} else { } else {
if (window->max_w > 0) { if (window->max_w > 0) {
@ -865,10 +865,10 @@ static void handle_configure_xdg_toplevel(void *data,
/* Aspect correction. */ /* Aspect correction. */
const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height; const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height;
if (window->min_aspect && aspect < window->min_aspect) { if (window->min_aspect != 0.f && aspect < window->min_aspect) {
wind->requested.pixel_height = SDL_roundf((float)wind->requested.pixel_width / window->min_aspect); wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect);
} else if (window->max_aspect && aspect > window->max_aspect) { } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
wind->requested.pixel_width = SDL_roundf((float)wind->requested.pixel_height * window->max_aspect); wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect);
} }
wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width); wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width);
@ -1228,10 +1228,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
/* Aspect correction. */ /* Aspect correction. */
const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height; const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height;
if (window->min_aspect && aspect < window->min_aspect) { if (window->min_aspect != 0.f && aspect < window->min_aspect) {
wind->requested.logical_height = SDL_roundf((float)wind->requested.logical_width / window->min_aspect); wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect);
} else if (window->max_aspect && aspect > window->max_aspect) { } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
wind->requested.logical_width = SDL_roundf((float)wind->requested.logical_height * window->max_aspect); wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect);
} }
} else { } else {
if (window->max_w > 0) { if (window->max_w > 0) {
@ -1247,10 +1247,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
/* Aspect correction. */ /* Aspect correction. */
const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height; const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height;
if (window->min_aspect && aspect < window->min_aspect) { if (window->min_aspect != 0.f && aspect < window->min_aspect) {
wind->requested.pixel_height = SDL_roundf((float)wind->requested.pixel_width / window->min_aspect); wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect);
} else if (window->max_aspect && aspect > window->max_aspect) { } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
wind->requested.pixel_width = SDL_roundf((float)wind->requested.pixel_height * window->max_aspect); wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect);
} }
wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width); wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width);
@ -1471,7 +1471,7 @@ static const struct wl_surface_listener surface_listener = {
static void handle_preferred_fractional_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale) static void handle_preferred_fractional_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale)
{ {
const float factor = scale / 120.; /* 120 is a magic number defined in the spec as a common denominator */ const float factor = scale / 120.f; /* 120 is a magic number defined in the spec as a common denominator */
Wayland_HandlePreferredScaleChanged(data, factor); Wayland_HandlePreferredScaleChanged(data, factor);
} }

View file

@ -570,7 +570,7 @@ SDL_bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const
{ {
SDL_Window *window = data->window; SDL_Window *window = data->window;
if (!window->hit_test) return SDL_FALSE; if (!window->hit_test) return SDL_FALSE;
const SDL_Point point = { x, y }; const SDL_Point point = { (int)x, (int)y };
SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
if (!force_new_result && rc == data->hit_test_result) { if (!force_new_result && rc == data->hit_test_result) {
return SDL_TRUE; return SDL_TRUE;
@ -585,7 +585,7 @@ SDL_bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data,
SDL_Window *window = data->window; SDL_Window *window = data->window;
if (window->hit_test) { if (window->hit_test) {
const SDL_Point point = { x, y }; const SDL_Point point = { (int)x, (int)y };
static const int directions[] = { static const int directions[] = {
_NET_WM_MOVERESIZE_SIZE_TOPLEFT, _NET_WM_MOVERESIZE_SIZE_TOP, _NET_WM_MOVERESIZE_SIZE_TOPLEFT, _NET_WM_MOVERESIZE_SIZE_TOP,
_NET_WM_MOVERESIZE_SIZE_TOPRIGHT, _NET_WM_MOVERESIZE_SIZE_RIGHT, _NET_WM_MOVERESIZE_SIZE_TOPRIGHT, _NET_WM_MOVERESIZE_SIZE_RIGHT,

View file

@ -152,7 +152,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
if (new_scale > 0.0) { if (new_scale > 0.0) {
*scale_factor = new_scale; *scale_factor = new_scale;
UpdateDisplayContentScale(new_scale); UpdateDisplayContentScale((float)new_scale);
} }
return DBUS_HANDLER_RESULT_HANDLED; return DBUS_HANDLER_RESULT_HANDLED;
@ -245,7 +245,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this)
} }
} }
return scale_factor; return (float)scale_factor;
} }
static int get_visualinfo(Display *display, int screen, XVisualInfo *vinfo) static int get_visualinfo(Display *display, int screen, XVisualInfo *vinfo)
@ -402,7 +402,7 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor)
static float CalculateXRandRRefreshRate(const XRRModeInfo *info) static float CalculateXRandRRefreshRate(const XRRModeInfo *info)
{ {
double vTotal = info->vTotal; float vTotal = info->vTotal;
if (info->modeFlags & RR_DoubleScan) { if (info->modeFlags & RR_DoubleScan) {
/* doublescan doubles the number of lines */ /* doublescan doubles the number of lines */
@ -415,7 +415,7 @@ static float CalculateXRandRRefreshRate(const XRRModeInfo *info)
vTotal /= 2; vTotal /= 2;
} }
if (info->hTotal && vTotal) { if (info->hTotal && vTotal != 0.f) {
return ((100 * (Sint64)info->dotClock) / (info->hTotal * vTotal)) / 100.0f; return ((100 * (Sint64)info->dotClock) / (info->hTotal * vTotal)) / 100.0f;
} }
return 0.0f; return 0.0f;

View file

@ -481,8 +481,8 @@ void X11_InitPen(SDL_VideoDevice *_this)
Atom vname = val_classinfo->label; Atom vname = val_classinfo->label;
int axis = -1; int axis = -1;
float min = val_classinfo->min; float min = (float)val_classinfo->min;
float max = val_classinfo->max; float max = (float)val_classinfo->max;
if (vname == pen_atoms.abs_pressure) { if (vname == pen_atoms.abs_pressure) {
axis = SDL_PEN_AXIS_PRESSURE; axis = SDL_PEN_AXIS_PRESSURE;
@ -653,7 +653,7 @@ static void xinput2_normalize_pen_axes(const SDL_Pen *peninfo,
case SDL_PEN_AXIS_ROTATION: case SDL_PEN_AXIS_ROTATION:
/* normalised to -1..1, so let's convert to degrees */ /* normalised to -1..1, so let's convert to degrees */
value *= 180.0; value *= 180.0f;
value += xpen->rotation_bias; value += xpen->rotation_bias;
/* handle simple over/underflow */ /* handle simple over/underflow */
@ -685,7 +685,7 @@ void X11_PenAxesFromValuators(const SDL_Pen *peninfo,
if (valuator == SDL_PEN_AXIS_VALUATOR_MISSING || valuator >= mask_len * 8 || !(XIMaskIsSet(mask, valuator))) { if (valuator == SDL_PEN_AXIS_VALUATOR_MISSING || valuator >= mask_len * 8 || !(XIMaskIsSet(mask, valuator))) {
axis_values[i] = 0.0f; axis_values[i] = 0.0f;
} else { } else {
axis_values[i] = input_values[valuator]; axis_values[i] = (float)input_values[valuator];
} }
} }
xinput2_normalize_pen_axes(peninfo, pen, axis_values); xinput2_normalize_pen_axes(peninfo, pen, axis_values);

View file

@ -102,17 +102,17 @@ static void xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x,
if (window->w == 1) { if (window->w == 1) {
*out_x = 0.5f; *out_x = 0.5f;
} else { } else {
*out_x = in_x / (window->w - 1); *out_x = (float)in_x / (window->w - 1);
} }
if (window->h == 1) { if (window->h == 1) {
*out_y = 0.5f; *out_y = 0.5f;
} else { } else {
*out_y = in_y / (window->h - 1); *out_y = (float)in_y / (window->h - 1);
} }
} else { } else {
// couldn't find the window... // couldn't find the window...
*out_x = in_x; *out_x = (float)in_x;
*out_y = in_y; *out_y = (float)in_y;
} }
} }
#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */ #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
@ -400,10 +400,10 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
xevent.xkey.root = xev->root; xevent.xkey.root = xev->root;
xevent.xkey.subwindow = xev->child; xevent.xkey.subwindow = xev->child;
xevent.xkey.time = xev->time; xevent.xkey.time = xev->time;
xevent.xkey.x = xev->event_x; xevent.xkey.x = (int)xev->event_x;
xevent.xkey.y = xev->event_y; xevent.xkey.y = (int)xev->event_y;
xevent.xkey.x_root = xev->root_x; xevent.xkey.x_root = (int)xev->root_x;
xevent.xkey.y_root = xev->root_y; xevent.xkey.y_root = (int)xev->root_y;
xevent.xkey.state = xev->mods.effective; xevent.xkey.state = xev->mods.effective;
xevent.xkey.keycode = xev->detail; xevent.xkey.keycode = xev->detail;
xevent.xkey.same_screen = 1; xevent.xkey.same_screen = 1;
@ -463,7 +463,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
if (pressed) { if (pressed) {
X11_HandleButtonPress(_this, windowdata, (SDL_MouseID)xev->sourceid, button, X11_HandleButtonPress(_this, windowdata, (SDL_MouseID)xev->sourceid, button,
xev->event_x, xev->event_y, xev->time); (float)xev->event_x, (float)xev->event_y, xev->time);
} else { } else {
X11_HandleButtonRelease(_this, windowdata, (SDL_MouseID)xev->sourceid, button); X11_HandleButtonRelease(_this, windowdata, (SDL_MouseID)xev->sourceid, button);
} }
@ -492,8 +492,8 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
if (pen) { if (pen) {
SDL_PenStatusInfo pen_status; SDL_PenStatusInfo pen_status;
pen_status.x = xev->event_x; pen_status.x = (float)xev->event_x;
pen_status.y = xev->event_y; pen_status.y = (float)xev->event_y;
X11_PenAxesFromValuators(pen, X11_PenAxesFromValuators(pen,
xev->valuators.values, xev->valuators.mask, xev->valuators.mask_len, xev->valuators.values, xev->valuators.mask, xev->valuators.mask_len,

View file

@ -919,7 +919,7 @@ static int convert_audio_chunks(SDL_AudioStream* stream, const void* src, int sr
} }
} }
} }
if (to_get) if (to_get)
{ {
ret = get_audio_data_split(stream, (Uint8*)(dst) + total_out, to_get); ret = get_audio_data_split(stream, (Uint8*)(dst) + total_out, to_get);
@ -1026,7 +1026,7 @@ static int audio_resampleLoss(void *arg)
} }
tick_beg = SDL_GetPerformanceCounter(); tick_beg = SDL_GetPerformanceCounter();
buf_out = (float *)SDL_malloc(len_target); buf_out = (float *)SDL_malloc(len_target);
SDLTest_AssertCheck(buf_out != NULL, "Expected output buffer to be created."); SDLTest_AssertCheck(buf_out != NULL, "Expected output buffer to be created.");
if (buf_out == NULL) { if (buf_out == NULL) {
@ -1059,11 +1059,11 @@ static int audio_resampleLoss(void *arg)
} }
SDL_free(buf_out); SDL_free(buf_out);
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */ signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
SDLTest_AssertCheck(isfinite(sum_squared_value), "Sum of squared target should be finite."); SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
SDLTest_AssertCheck(isfinite(sum_squared_error), "Sum of squared error should be finite."); SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite.");
/* Infinity is theoretically possible when there is very little to no noise */ /* Infinity is theoretically possible when there is very little to no noise */
SDLTest_AssertCheck(!isnan(signal_to_noise), "Signal-to-noise ratio should not be NaN."); SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
SDLTest_AssertCheck(isfinite(max_error), "Maximum conversion error should be finite."); SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite.");
SDLTest_AssertCheck(signal_to_noise >= spec->signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.", SDLTest_AssertCheck(signal_to_noise >= spec->signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.",
signal_to_noise, spec->signal_to_noise); signal_to_noise, spec->signal_to_noise);
SDLTest_AssertCheck(max_error <= spec->max_error, "Maximum conversion error %f should be no more than %f.", SDLTest_AssertCheck(max_error <= spec->max_error, "Maximum conversion error %f should be no more than %f.",
@ -1345,11 +1345,11 @@ static int audio_formatChange(void *arg)
} }
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */ signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
SDLTest_AssertCheck(isfinite(sum_squared_value), "Sum of squared target should be finite."); SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
SDLTest_AssertCheck(isfinite(sum_squared_error), "Sum of squared error should be finite."); SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite.");
/* Infinity is theoretically possible when there is very little to no noise */ /* Infinity is theoretically possible when there is very little to no noise */
SDLTest_AssertCheck(!isnan(signal_to_noise), "Signal-to-noise ratio should not be NaN."); SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
SDLTest_AssertCheck(isfinite(max_error), "Maximum conversion error should be finite."); SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite.");
SDLTest_AssertCheck(signal_to_noise >= target_signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.", SDLTest_AssertCheck(signal_to_noise >= target_signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.",
signal_to_noise, target_signal_to_noise); signal_to_noise, target_signal_to_noise);
SDLTest_AssertCheck(max_error <= target_max_error, "Maximum conversion error %f should be no more than %f.", SDLTest_AssertCheck(max_error <= target_max_error, "Maximum conversion error %f should be no more than %f.",

View file

@ -25,7 +25,7 @@
#define EULER M_E #define EULER M_E
#endif #endif
#define IS_INFINITY(V) isinf(V) #define IS_INFINITY(V) ISINF(V)
/* Square root of 3 (used in atan2) */ /* Square root of 3 (used in atan2) */
#define SQRT3 1.7320508075688771931766041234368458390235900878906250 #define SQRT3 1.7320508075688771931766041234368458390235900878906250
@ -207,7 +207,7 @@ helper_range(const char *func_name, d_to_d_func func)
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
double result; double result;
/* These are tested elsewhere */ /* These are tested elsewhere */
if (isnan(test_value) || isinf(test_value)) { if (ISNAN(test_value) || ISINF(test_value)) {
continue; continue;
} }
@ -272,7 +272,7 @@ static int
floor_nanCase(void *args) floor_nanCase(void *args)
{ {
const double result = SDL_floor(NAN); const double result = SDL_floor(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Floor(nan), expected nan, got %f", "Floor(nan), expected nan, got %f",
result); result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -376,7 +376,7 @@ static int
ceil_nanCase(void *args) ceil_nanCase(void *args)
{ {
const double result = SDL_ceil(NAN); const double result = SDL_ceil(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Ceil(nan), expected nan, got %f", "Ceil(nan), expected nan, got %f",
result); result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -480,7 +480,7 @@ static int
trunc_nanCase(void *args) trunc_nanCase(void *args)
{ {
const double result = SDL_trunc(NAN); const double result = SDL_trunc(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Trunc(nan), expected nan, got %f", "Trunc(nan), expected nan, got %f",
result); result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -584,7 +584,7 @@ static int
round_nanCase(void *args) round_nanCase(void *args)
{ {
const double result = SDL_round(NAN); const double result = SDL_round(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Round(nan), expected nan, got %f", "Round(nan), expected nan, got %f",
result); result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -688,7 +688,7 @@ static int
fabs_nanCase(void *args) fabs_nanCase(void *args)
{ {
const double result = SDL_fabs(NAN); const double result = SDL_fabs(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fabs(nan), expected nan, got %f", "Fabs(nan), expected nan, got %f",
result); result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -765,12 +765,12 @@ copysign_nanCases(void *args)
double result; double result;
result = SDL_copysign(NAN, 1.0); result = SDL_copysign(NAN, 1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Copysign(nan,1.0), expected nan, got %f", "Copysign(nan,1.0), expected nan, got %f",
result); result);
result = SDL_copysign(NAN, -1.0); result = SDL_copysign(NAN, -1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Copysign(nan,-1.0), expected nan, got %f", "Copysign(nan,-1.0), expected nan, got %f",
result); result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -793,7 +793,7 @@ copysign_rangeTest(void *args)
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
double result; double result;
/* These are tested elsewhere */ /* These are tested elsewhere */
if (isnan(test_value) || isinf(test_value)) { if (ISNAN(test_value) || ISINF(test_value)) {
continue; continue;
} }
@ -829,22 +829,22 @@ fmod_divOfInfCases(void *args)
double result; double result;
result = SDL_fmod(INFINITY, -1.0); result = SDL_fmod(INFINITY, -1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(%f,%.1f), expected %f, got %f", "Fmod(%f,%.1f), expected %f, got %f",
INFINITY, -1.0, NAN, result); INFINITY, -1.0, NAN, result);
result = SDL_fmod(INFINITY, 1.0); result = SDL_fmod(INFINITY, 1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(%f,%.1f), expected %f, got %f", "Fmod(%f,%.1f), expected %f, got %f",
INFINITY, 1.0, NAN, result); INFINITY, 1.0, NAN, result);
result = SDL_fmod(-INFINITY, -1.0); result = SDL_fmod(-INFINITY, -1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(%f,%.1f), expected %f, got %f", "Fmod(%f,%.1f), expected %f, got %f",
-INFINITY, -1.0, NAN, result); -INFINITY, -1.0, NAN, result);
result = SDL_fmod(-INFINITY, 1.0); result = SDL_fmod(-INFINITY, 1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(%f,%.1f), expected %f, got %f", "Fmod(%f,%.1f), expected %f, got %f",
-INFINITY, 1.0, NAN, result); -INFINITY, 1.0, NAN, result);
@ -909,22 +909,22 @@ fmod_divByZeroCases(void *args)
double result; double result;
result = SDL_fmod(1.0, 0.0); result = SDL_fmod(1.0, 0.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(1.0,0.0), expected nan, got %f", "Fmod(1.0,0.0), expected nan, got %f",
result); result);
result = SDL_fmod(-1.0, 0.0); result = SDL_fmod(-1.0, 0.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(-1.0,0.0), expected nan, got %f", "Fmod(-1.0,0.0), expected nan, got %f",
result); result);
result = SDL_fmod(1.0, -0.0); result = SDL_fmod(1.0, -0.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(1.0,-0.0), expected nan, got %f", "Fmod(1.0,-0.0), expected nan, got %f",
result); result);
result = SDL_fmod(-1.0, -0.0); result = SDL_fmod(-1.0, -0.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(-1.0,-0.0), expected nan, got %f", "Fmod(-1.0,-0.0), expected nan, got %f",
result); result);
@ -941,22 +941,22 @@ fmod_nanCases(void *args)
double result; double result;
result = SDL_fmod(NAN, 1.0); result = SDL_fmod(NAN, 1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(nan,1.0), expected nan, got %f", "Fmod(nan,1.0), expected nan, got %f",
result); result);
result = SDL_fmod(NAN, -1.0); result = SDL_fmod(NAN, -1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(nan,-1.0), expected nan, got %f", "Fmod(nan,-1.0), expected nan, got %f",
result); result);
result = SDL_fmod(1.0, NAN); result = SDL_fmod(1.0, NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(1.0,nan), expected nan, got %f", "Fmod(1.0,nan), expected nan, got %f",
result); result);
result = SDL_fmod(-1.0, NAN); result = SDL_fmod(-1.0, NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Fmod(-1.0,nan), expected nan, got %f", "Fmod(-1.0,nan), expected nan, got %f",
result); result);
@ -996,7 +996,7 @@ fmod_rangeTest(void *args)
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
double result; double result;
/* These are tested elsewhere */ /* These are tested elsewhere */
if (isnan(test_value) || isinf(test_value)) { if (ISNAN(test_value) || ISINF(test_value)) {
continue; continue;
} }
@ -1065,7 +1065,7 @@ exp_overflowCase(void *args)
} }
result = SDL_exp(710.0); result = SDL_exp(710.0);
SDLTest_AssertCheck(isinf(result), SDLTest_AssertCheck(ISINF(result),
"Exp(%f), expected %f, got %f", "Exp(%f), expected %f, got %f",
710.0, INFINITY, result); 710.0, INFINITY, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -1169,12 +1169,12 @@ log_nanCases(void *args)
double result; double result;
result = SDL_log(NAN); result = SDL_log(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Log(%f), expected %f, got %f", "Log(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
result = SDL_log(-1234.5678); result = SDL_log(-1234.5678);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Log(%f), expected %f, got %f", "Log(%f), expected %f, got %f",
-1234.5678, NAN, result); -1234.5678, NAN, result);
@ -1259,12 +1259,12 @@ log10_nanCases(void *args)
double result; double result;
result = SDL_log10(NAN); result = SDL_log10(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Log10(%f), expected %f, got %f", "Log10(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
result = SDL_log10(-1234.5678); result = SDL_log10(-1234.5678);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Log10(%f), expected %f, got %f", "Log10(%f), expected %f, got %f",
-1234.5678, NAN, result); -1234.5678, NAN, result);
@ -1477,7 +1477,7 @@ static int
pow_badOperationCase(void *args) pow_badOperationCase(void *args)
{ {
const double result = SDL_pow(-2.0, 4.2); const double result = SDL_pow(-2.0, 4.2);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Pow(%f,%f), expected %f, got %f", "Pow(%f,%f), expected %f, got %f",
-2.0, 4.2, NAN, result); -2.0, 4.2, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -1529,17 +1529,17 @@ pow_nanArgsCases(void *args)
double result; double result;
result = SDL_pow(7.8, NAN); result = SDL_pow(7.8, NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Pow(%f,%f), expected %f, got %f", "Pow(%f,%f), expected %f, got %f",
7.8, NAN, NAN, result); 7.8, NAN, NAN, result);
result = SDL_pow(NAN, 10.0); result = SDL_pow(NAN, 10.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Pow(%f,%f), expected %f, got %f", "Pow(%f,%f), expected %f, got %f",
NAN, 10.0, NAN, result); NAN, 10.0, NAN, result);
result = SDL_pow(NAN, NAN); result = SDL_pow(NAN, NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Pow(%f,%f), expected %f, got %f", "Pow(%f,%f), expected %f, got %f",
NAN, NAN, NAN, result); NAN, NAN, NAN, result);
@ -1727,7 +1727,7 @@ pow_rangeTest(void *args)
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
double result; double result;
/* These are tested elsewhere */ /* These are tested elsewhere */
if (isnan(test_value) || isinf(test_value)) { if (ISNAN(test_value) || ISINF(test_value)) {
continue; continue;
} }
@ -1775,7 +1775,7 @@ static int
sqrt_nanCase(void *args) sqrt_nanCase(void *args)
{ {
const double result = SDL_sqrt(NAN); const double result = SDL_sqrt(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Sqrt(%f), expected %f, got %f", "Sqrt(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -1791,17 +1791,17 @@ sqrt_outOfDomainCases(void *args)
double result; double result;
result = SDL_sqrt(-1.0); result = SDL_sqrt(-1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Sqrt(%f), expected %f, got %f", "Sqrt(%f), expected %f, got %f",
-1.0, NAN, result); -1.0, NAN, result);
result = SDL_sqrt(-12345.6789); result = SDL_sqrt(-12345.6789);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Sqrt(%f), expected %f, got %f", "Sqrt(%f), expected %f, got %f",
-12345.6789, NAN, result); -12345.6789, NAN, result);
result = SDL_sqrt(-INFINITY); result = SDL_sqrt(-INFINITY);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Sqrt(%f), expected %f, got %f", "Sqrt(%f), expected %f, got %f",
-INFINITY, NAN, result); -INFINITY, NAN, result);
@ -1910,7 +1910,7 @@ static int
scalbn_nanCase(void *args) scalbn_nanCase(void *args)
{ {
const double result = SDL_scalbn(NAN, 2); const double result = SDL_scalbn(NAN, 2);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Scalbn(%f,%d), expected %f, got %f", "Scalbn(%f,%d), expected %f, got %f",
NAN, 2, NAN, result); NAN, 2, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -1965,12 +1965,12 @@ cos_infCases(void *args)
double result; double result;
result = SDL_cos(INFINITY); result = SDL_cos(INFINITY);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Cos(%f), expected %f, got %f", "Cos(%f), expected %f, got %f",
INFINITY, NAN, result); INFINITY, NAN, result);
result = SDL_cos(-INFINITY); result = SDL_cos(-INFINITY);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Cos(%f), expected %f, got %f", "Cos(%f), expected %f, got %f",
-INFINITY, NAN, result); -INFINITY, NAN, result);
@ -1985,7 +1985,7 @@ static int
cos_nanCase(void *args) cos_nanCase(void *args)
{ {
const double result = SDL_cos(NAN); const double result = SDL_cos(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Cos(%f), expected %f, got %f", "Cos(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -2054,7 +2054,7 @@ cos_rangeTest(void *args)
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
double result; double result;
/* These are tested elsewhere */ /* These are tested elsewhere */
if (isnan(test_value) || isinf(test_value)) { if (ISNAN(test_value) || ISINF(test_value)) {
continue; continue;
} }
@ -2082,12 +2082,12 @@ sin_infCases(void *args)
double result; double result;
result = SDL_sin(INFINITY); result = SDL_sin(INFINITY);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Sin(%f), expected %f, got %f", "Sin(%f), expected %f, got %f",
INFINITY, NAN, result); INFINITY, NAN, result);
result = SDL_sin(-INFINITY); result = SDL_sin(-INFINITY);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Sin(%f), expected %f, got %f", "Sin(%f), expected %f, got %f",
-INFINITY, NAN, result); -INFINITY, NAN, result);
@ -2102,7 +2102,7 @@ static int
sin_nanCase(void *args) sin_nanCase(void *args)
{ {
const double result = SDL_sin(NAN); const double result = SDL_sin(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Sin(%f), expected %f, got %f", "Sin(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -2172,7 +2172,7 @@ sin_rangeTest(void *args)
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
double result; double result;
/* These are tested elsewhere */ /* These are tested elsewhere */
if (isnan(test_value) || isinf(test_value)) { if (ISNAN(test_value) || ISINF(test_value)) {
continue; continue;
} }
@ -2200,12 +2200,12 @@ tan_infCases(void *args)
double result; double result;
result = SDL_tan(INFINITY); result = SDL_tan(INFINITY);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Tan(%f), expected %f, got %f", "Tan(%f), expected %f, got %f",
INFINITY, NAN, result); INFINITY, NAN, result);
result = SDL_tan(-INFINITY); result = SDL_tan(-INFINITY);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Tan(%f), expected %f, got %f", "Tan(%f), expected %f, got %f",
-INFINITY, NAN, result); -INFINITY, NAN, result);
@ -2220,7 +2220,7 @@ static int
tan_nanCase(void *args) tan_nanCase(void *args)
{ {
const double result = SDL_tan(NAN); const double result = SDL_tan(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Tan(%f), expected %f, got %f", "Tan(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -2307,12 +2307,12 @@ acos_outOfDomainCases(void *args)
double result; double result;
result = SDL_acos(1.1); result = SDL_acos(1.1);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Acos(%f), expected %f, got %f", "Acos(%f), expected %f, got %f",
1.1, NAN, result); 1.1, NAN, result);
result = SDL_acos(-1.1); result = SDL_acos(-1.1);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Acos(%f), expected %f, got %f", "Acos(%f), expected %f, got %f",
-1.1, NAN, result); -1.1, NAN, result);
@ -2327,7 +2327,7 @@ static int
acos_nanCase(void *args) acos_nanCase(void *args)
{ {
const double result = SDL_acos(NAN); const double result = SDL_acos(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Acos(%f), expected %f, got %f", "Acos(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -2399,12 +2399,12 @@ asin_outOfDomainCases(void *args)
double result; double result;
result = SDL_asin(1.1); result = SDL_asin(1.1);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Asin(%f), expected %f, got %f", "Asin(%f), expected %f, got %f",
1.1, NAN, result); 1.1, NAN, result);
result = SDL_asin(-1.1); result = SDL_asin(-1.1);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Asin(%f), expected %f, got %f", "Asin(%f), expected %f, got %f",
-1.1, NAN, result); -1.1, NAN, result);
@ -2419,7 +2419,7 @@ static int
asin_nanCase(void *args) asin_nanCase(void *args)
{ {
const double result = SDL_asin(NAN); const double result = SDL_asin(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Asin(%f), expected %f, got %f", "Asin(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -2513,7 +2513,7 @@ static int
atan_nanCase(void *args) atan_nanCase(void *args)
{ {
const double result = SDL_atan(NAN); const double result = SDL_atan(NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Atan(%f), expected %f, got %f", "Atan(%f), expected %f, got %f",
NAN, NAN, result); NAN, NAN, result);
return TEST_COMPLETED; return TEST_COMPLETED;
@ -2723,17 +2723,17 @@ atan2_nanCases(void *args)
double result; double result;
result = SDL_atan2(NAN, NAN); result = SDL_atan2(NAN, NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Atan2(%f,%f), expected %f, got %f", "Atan2(%f,%f), expected %f, got %f",
NAN, NAN, NAN, result); NAN, NAN, NAN, result);
result = SDL_atan2(NAN, 1.0); result = SDL_atan2(NAN, 1.0);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Atan2(%f,%f), expected %f, got %f", "Atan2(%f,%f), expected %f, got %f",
NAN, 1.0, NAN, result); NAN, 1.0, NAN, result);
result = SDL_atan2(1.0, NAN); result = SDL_atan2(1.0, NAN);
SDLTest_AssertCheck(isnan(result), SDLTest_AssertCheck(ISNAN(result),
"Atan2(%f,%f), expected %f, got %f", "Atan2(%f,%f), expected %f, got %f",
1.0, NAN, NAN, result); 1.0, NAN, NAN, result);

View file

@ -8,6 +8,10 @@
#include <SDL3/SDL_test.h> #include <SDL3/SDL_test.h>
#define ISFINITE(X) isfinite((float)(X))
#define ISINF(X) isinf((float)(X))
#define ISNAN(X) isnan((float)(X))
/* Test collections */ /* Test collections */
extern SDLTest_TestSuiteReference audioTestSuite; extern SDLTest_TestSuiteReference audioTestSuite;
extern SDLTest_TestSuiteReference clipboardTestSuite; extern SDLTest_TestSuiteReference clipboardTestSuite;

View file

@ -1492,7 +1492,7 @@ int main(int argc, char *argv[])
positions[i].h = (float)sprite_h; positions[i].h = (float)sprite_h;
velocities[i].x = 0.0f; velocities[i].x = 0.0f;
velocities[i].y = 0.0f; velocities[i].y = 0.0f;
while (!velocities[i].x || !velocities[i].y) { while (velocities[i].x == 0.f || velocities[i].y == 0.f) {
velocities[i].x = (float)((rand() % (2 + 1)) - 1); velocities[i].x = (float)((rand() % (2 + 1)) - 1);
velocities[i].y = (float)((rand() % (2 + 1)) - 1); velocities[i].y = (float)((rand() % (2 + 1)) - 1);
} }

View file

@ -498,7 +498,7 @@ Render(unsigned int width, unsigned int height, shader_data *data)
multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview); multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
/* Pull the camera back from the cube */ /* Pull the camera back from the cube */
matrix_modelview[14] -= 2.5; matrix_modelview[14] -= 2.5f;
perspective_matrix(45.0f, (float)width / height, 0.01f, 100.0f, matrix_perspective); perspective_matrix(45.0f, (float)width / height, 0.01f, 100.0f, matrix_perspective);
multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp); multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp);

View file

@ -196,7 +196,7 @@ int main(int argc, char *argv[])
positions[i].h = (float)sprite_h; positions[i].h = (float)sprite_h;
velocities[i].x = 0.0f; velocities[i].x = 0.0f;
velocities[i].y = 0.0f; velocities[i].y = 0.0f;
while (!velocities[i].x && !velocities[i].y) { while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED); velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED); velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
} }

View file

@ -568,7 +568,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
positions[i].h = sprite_h; positions[i].h = sprite_h;
velocities[i].x = 0; velocities[i].x = 0;
velocities[i].y = 0; velocities[i].y = 0;
while (!velocities[i].x && !velocities[i].y) { while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
velocities[i].x = (float)SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED); velocities[i].x = (float)SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED);
velocities[i].y = (float)SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED); velocities[i].y = (float)SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED);
} }

View file

@ -144,7 +144,7 @@ int main(int argc, char *argv[])
positions[i].h = (float)sprite_h; positions[i].h = (float)sprite_h;
velocities[i].x = 0.0f; velocities[i].x = 0.0f;
velocities[i].y = 0.0f; velocities[i].y = 0.0f;
while (!velocities[i].x && !velocities[i].y) { while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED); velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED); velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
} }

View file

@ -107,7 +107,7 @@ static int InitSprites(void)
positions[i].h = (float)sprite_h; positions[i].h = (float)sprite_h;
velocities[i].x = 0.0f; velocities[i].x = 0.0f;
velocities[i].y = 0.0f; velocities[i].y = 0.0f;
while (!velocities[i].x && !velocities[i].y) { while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED); velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED); velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
} }