From 3c417bbde3864cb57ddc5407472083fa741084ae Mon Sep 17 00:00:00 2001
From: yangfl <yangfl@users.noreply.github.com>
Date: Sat, 27 Jul 2024 12:26:22 +0800
Subject: [PATCH 11/11] stb_image_resize2.h: fix gcc unroll errors

---
 stb_image_resize2.h | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/stb_image_resize2.h b/stb_image_resize2.h
index 2a59c95..751bd25 100644
--- a/stb_image_resize2.h
+++ b/stb_image_resize2.h
@@ -1059,7 +1059,7 @@ struct stbir__info
 #define stbir__small_float ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20))
 
 // min/max friendly
-#define STBIR_CLAMP(x, xmin, xmax) for(;;) { \
+#define STBIR_CLAMP(x, xmin, xmax) while(1) { \
   if ( (x) < (xmin) ) (x) = (xmin);     \
   if ( (x) > (xmax) ) (x) = (xmax);     \
   break;                                \
@@ -2613,7 +2613,7 @@ static void stbir_simd_memcpy( void * dest, void const * src, size_t bytes )
       d = (char*)( ( ( (size_t)d ) + 16 ) & ~15 );
 
       STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-      for(;;)
+      while(1)
       {
         STBIR_SIMD_NO_UNROLL(d);
 
@@ -2646,7 +2646,7 @@ static void stbir_simd_memcpy( void * dest, void const * src, size_t bytes )
     d = (char*)( ( ( (size_t)d ) + (16*stbir__simdfX_float_count) ) & ~((16*stbir__simdfX_float_count)-1) );
 
     STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       STBIR_SIMD_NO_UNROLL(d);
 
@@ -7050,7 +7050,7 @@ static stbir__info * stbir__alloc_internal_mem_and_build_samplers( stbir__sample
   vertical_buffer_size = (size_t)horizontal->scale_info.output_sub_size * (size_t)effective_channels * sizeof(float) + sizeof(float);  // extra float for padding
 
   // we make two passes through this loop, 1st to add everything up, 2nd to allocate and init
-  for(;;)
+  while(1)
   {
     int i;
     void * advance_mem = alloced;
@@ -7500,7 +7500,7 @@ static int stbir__double_to_rational(double f, stbir_uint32 limit, stbir_uint32
   bot = 1 << 25;
 
   // keep refining, but usually stops in a few loops - usually 5 for bad cases
-  for(;;)
+  while(1)
   {
     stbir_uint64 est, temp;
 
@@ -8253,7 +8253,7 @@ static float * STBIR__CODER_NAME( stbir__decode_uint8_linear_scaled )( float * d
   {
     decode_end -= 16;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o0,o1;
@@ -8354,7 +8354,7 @@ static void STBIR__CODER_NAME( stbir__encode_uint8_linear_scaled )( void * outpu
     float const * end_encode_m8 = encode + width_times_channels - stbir__simdfX_float_count*2;
     end_output -= stbir__simdfX_float_count*2;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       stbir__simdfX e0, e1;
       stbir__simdi i;
@@ -8472,7 +8472,7 @@ static float * STBIR__CODER_NAME(stbir__decode_uint8_linear)( float * decodep, i
   {
     decode_end -= 16;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o0,o1;
@@ -8566,7 +8566,7 @@ static void STBIR__CODER_NAME( stbir__encode_uint8_linear )( void * outputp, int
     float const * end_encode_m8 = encode + width_times_channels - stbir__simdfX_float_count*2;
     end_output -= stbir__simdfX_float_count*2;
     STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       stbir__simdfX e0, e1;
       stbir__simdi i;
@@ -8770,7 +8770,7 @@ static void STBIR__CODER_NAME( stbir__encode_uint8_srgb )( void * outputp, int w
     float const * end_encode_m16 = encode + width_times_channels - 16;
     end_output -= 16;
     STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       stbir__simdf f0, f1, f2, f3;
       stbir__simdi i0, i1, i2, i3;
@@ -8875,7 +8875,7 @@ static void STBIR__CODER_NAME( stbir__encode_uint8_srgb4_linearalpha )( void * o
     float const * end_encode_m16 = encode + width_times_channels - 16;
     end_output -= 16;
     STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       stbir__simdf f0, f1, f2, f3;
       stbir__simdi i0, i1, i2, i3;
@@ -8969,7 +8969,7 @@ static void STBIR__CODER_NAME( stbir__encode_uint8_srgb2_linearalpha )( void * o
     float const * end_encode_m16 = encode + width_times_channels - 16;
     end_output -= 16;
     STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       stbir__simdf f0, f1, f2, f3;
       stbir__simdi i0, i1, i2, i3;
@@ -9032,7 +9032,7 @@ static float * STBIR__CODER_NAME(stbir__decode_uint16_linear_scaled)( float * de
   {
     decode_end -= 8;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o;
@@ -9122,7 +9122,7 @@ static void STBIR__CODER_NAME(stbir__encode_uint16_linear_scaled)( void * output
       float const * end_encode_m8 = encode + width_times_channels - stbir__simdfX_float_count*2;
       end_output -= stbir__simdfX_float_count*2;
       STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-      for(;;)
+      while(1)
       {
         stbir__simdfX e0, e1;
         stbir__simdiX i;
@@ -9238,7 +9238,7 @@ static float * STBIR__CODER_NAME(stbir__decode_uint16_linear)( float * decodep,
   {
     decode_end -= 8;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o;
@@ -9324,7 +9324,7 @@ static void STBIR__CODER_NAME(stbir__encode_uint16_linear)( void * outputp, int
       float const * end_encode_m8 = encode + width_times_channels - stbir__simdfX_float_count*2;
       end_output -= stbir__simdfX_float_count*2;
       STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-      for(;;)
+      while(1)
       {
         stbir__simdfX e0, e1;
         stbir__simdiX i;
@@ -9422,7 +9422,7 @@ static float * STBIR__CODER_NAME(stbir__decode_half_float_linear)( float * decod
     stbir__FP16 const * end_input_m8 = input + width_times_channels - 8;
     decode_end -= 8;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       STBIR_NO_UNROLL(decode);
 
@@ -9508,7 +9508,7 @@ static void STBIR__CODER_NAME( stbir__encode_half_float_linear )( void * outputp
     float const * end_encode_m8 = encode + width_times_channels - 8;
     end_output -= 8;
     STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       STBIR_SIMD_NO_UNROLL(encode);
       #ifdef stbir__decode_swizzle
@@ -9594,7 +9594,7 @@ static float * STBIR__CODER_NAME(stbir__decode_float_linear)( float * decodep, i
     float const * end_input_m16 = input + width_times_channels - 16;
     decode_end -= 16;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       STBIR_NO_UNROLL(decode);
       #ifdef stbir__decode_swizzle
@@ -9722,7 +9722,7 @@ static void STBIR__CODER_NAME( stbir__encode_float_linear )( void * outputp, int
     float const * end_encode_m8 = encode + width_times_channels - ( stbir__simdfX_float_count * 2 );
     end_output -= ( stbir__simdfX_float_count * 2 );
     STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       stbir__simdfX e0, e1;
       STBIR_SIMD_NO_UNROLL(encode);
-- 
2.50.1

