Commit 6c2928b4befa2228ef53c223aec01aac65cb58d8

Eddy Jansson 2022-04-29T19:30:47

Switch uses of MIN() to SDL_min() We're excluding files in src/hidapi to minimize the diff against the upstream project.

diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c
index 6a9efac..d5ffc14 100644
--- a/src/render/software/SDL_rotate.c
+++ b/src/render/software/SDL_rotate.c
@@ -62,11 +62,6 @@ typedef struct tColorY {
 } tColorY;
 
 /* !
-\brief Returns maximum of two numbers a and b.
-*/
-#define MAX(a,b)    (((a) > (b)) ? (a) : (b))
-
-/* !
 \brief Number of guard rows added to destination surfaces.
 
 This is a simple but effective workaround for observed issues.
diff --git a/src/render/software/SDL_rotate.h b/src/render/software/SDL_rotate.h
index 171baa5..8d7ec9d 100644
--- a/src/render/software/SDL_rotate.h
+++ b/src/render/software/SDL_rotate.h
@@ -22,10 +22,6 @@
 #ifndef SDL_rotate_h_
 #define SDL_rotate_h_
 
-#ifndef MIN
-#define MIN(a,b)    (((a) < (b)) ? (a) : (b))
-#endif
-
 extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy,
         const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center);
 extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c
index 983c9d9..e8b05ec 100644
--- a/src/video/SDL_RLEaccel.c
+++ b/src/video/SDL_RLEaccel.c
@@ -92,10 +92,6 @@
 #include "SDL_blit.h"
 #include "SDL_RLEaccel_c.h"
 
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
 #define PIXEL_COPY(to, from, len, bpp)          \
     SDL_memcpy(to, from, (size_t)(len) * (bpp))
 
@@ -1161,13 +1157,13 @@ RLEAlphaSurface(SDL_Surface * surface)
                     ADD_OPAQUE_COUNTS(max_opaque_run, 0);
                     skip -= max_opaque_run;
                 }
-                len = MIN(run, max_opaque_run);
+                len = SDL_min(run, max_opaque_run);
                 ADD_OPAQUE_COUNTS(skip, len);
                 dst += copy_opaque(dst, src + runstart, len, sf, df);
                 runstart += len;
                 run -= len;
                 while (run) {
-                    len = MIN(run, max_opaque_run);
+                    len = SDL_min(run, max_opaque_run);
                     ADD_OPAQUE_COUNTS(0, len);
                     dst += copy_opaque(dst, src + runstart, len, sf, df);
                     runstart += len;
@@ -1195,13 +1191,13 @@ RLEAlphaSurface(SDL_Surface * surface)
                     ADD_TRANSL_COUNTS(max_transl_run, 0);
                     skip -= max_transl_run;
                 }
-                len = MIN(run, max_transl_run);
+                len = SDL_min(run, max_transl_run);
                 ADD_TRANSL_COUNTS(skip, len);
                 dst += copy_transl(dst, src + runstart, len, sf, df);
                 runstart += len;
                 run -= len;
                 while (run) {
-                    len = MIN(run, max_transl_run);
+                    len = SDL_min(run, max_transl_run);
                     ADD_TRANSL_COUNTS(0, len);
                     dst += copy_transl(dst, src + runstart, len, sf, df);
                     runstart += len;
@@ -1359,14 +1355,14 @@ RLEColorkeySurface(SDL_Surface * surface)
                 ADD_COUNTS(maxn, 0);
                 skip -= maxn;
             }
-            len = MIN(run, maxn);
+            len = SDL_min(run, maxn);
             ADD_COUNTS(skip, len);
             SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
             dst += len * bpp;
             run -= len;
             runstart += len;
             while (run) {
-                len = MIN(run, maxn);
+                len = SDL_min(run, maxn);
                 ADD_COUNTS(0, len);
                 SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
                 dst += len * bpp;
diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m
index 52158f8..ef5ca74 100644
--- a/src/video/uikit/SDL_uikitopenglview.m
+++ b/src/video/uikit/SDL_uikitopenglview.m
@@ -89,7 +89,7 @@
             glGetIntegerv(GL_MAX_SAMPLES, &maxsamples);
 
             /* Clamp the samples to the max supported count. */
-            samples = MIN(samples, maxsamples);
+            samples = SDL_min(samples, maxsamples);
         }
 
         if (sRGB) {