3131#include " llerror.h"
3232#include " llexception.h"
3333
34+ #if !LL_ARM64
3435jmp_buf LLImageJPEG::sSetjmpBuffer ;
36+ #endif
3537LLImageJPEG::LLImageJPEG (S32 quality)
3638: LLImageFormatted(IMG_CODEC_JPEG),
3739 mOutputBuffer( NULL ),
@@ -78,12 +80,15 @@ bool LLImageJPEG::updateData()
7880 //
7981 // try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
8082 // so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
83+ // except in the case of AARCH64/ARM64 where setjmp will crash
8184 //
85+ #if !LL_ARM64
8286 if (setjmp (sSetjmpBuffer ))
8387 {
8488 jpeg_destroy_decompress (&cinfo);
8589 return false ;
8690 }
91+ #endif
8792 try
8893 {
8994 // Now we can initialize the JPEG decompression object.
@@ -223,11 +228,13 @@ bool LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time)
223228 // try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
224229 // so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
225230 //
231+ #if !LL_ARM64
226232 if (setjmp (sSetjmpBuffer ))
227233 {
228234 jpeg_destroy_decompress (&cinfo);
229235 return true ; // done
230236 }
237+ #endif
231238 try
232239 {
233240 // Now we can initialize the JPEG decompression object.
@@ -431,9 +438,10 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo )
431438
432439 // Let the memory manager delete any temp files
433440 jpeg_destroy (cinfo);
434-
441+ # if !LL_ARM64
435442 // Return control to the setjmp point
436443 longjmp (sSetjmpBuffer , 1 ) ;
444+ #endif
437445}
438446
439447// Decide whether to emit a trace or warning message.
@@ -545,6 +553,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
545553 // try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
546554 // so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
547555 //
556+ #if !LL_ARM64
548557 if ( setjmp (sSetjmpBuffer ) )
549558 {
550559 // If we get here, the JPEG code has signaled an error.
@@ -555,7 +564,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
555564 mOutputBufferSize = 0 ;
556565 return false ;
557566 }
558-
567+ # endif
559568 try
560569 {
561570
0 commit comments