From 091ada0fe6fc38bea10911038dcf5075c9d3cd3d 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 2f26274..570f962 100644
--- a/stb_image_resize2.h
+++ b/stb_image_resize2.h
@@ -1104,7 +1104,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;                                \
@@ -2595,7 +2595,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);
 
@@ -2628,7 +2628,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);
 
@@ -7003,7 +7003,7 @@ static stbir__info * stbir__alloc_internal_mem_and_build_samplers( stbir__sample
   vertical_buffer_size = horizontal->scale_info.output_sub_size * 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;
@@ -7485,7 +7485,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;
 
@@ -8238,7 +8238,7 @@ static void STBIR__CODER_NAME( stbir__decode_uint8_linear_scaled )( float * deco
   {
     decode_end -= 16;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o0,o1;
@@ -8337,7 +8337,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;
@@ -8455,7 +8455,7 @@ static void STBIR__CODER_NAME(stbir__decode_uint8_linear)( float * decodep, int
   {
     decode_end -= 16;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o0,o1;
@@ -8548,7 +8548,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;
@@ -8751,7 +8751,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;
@@ -8854,7 +8854,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;
@@ -8946,7 +8946,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;
@@ -9009,7 +9009,7 @@ static void STBIR__CODER_NAME(stbir__decode_uint16_linear_scaled)( float * decod
   {
     decode_end -= 8;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o;
@@ -9098,7 +9098,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;
@@ -9214,7 +9214,7 @@ static void STBIR__CODER_NAME(stbir__decode_uint16_linear)( float * decodep, int
   {
     decode_end -= 8;
     STBIR_NO_UNROLL_LOOP_START_INF_FOR
-    for(;;)
+    while(1)
     {
       #ifdef STBIR_SIMD8
       stbir__simdi i; stbir__simdi8 o;
@@ -9299,7 +9299,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;
@@ -9397,7 +9397,7 @@ static void STBIR__CODER_NAME(stbir__decode_half_float_linear)( float * decodep,
     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);
 
@@ -9482,7 +9482,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
@@ -9568,7 +9568,7 @@ static void STBIR__CODER_NAME(stbir__decode_float_linear)( float * decodep, int
     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
@@ -9693,7 +9693,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.47.2

