@@ -65,7 +65,9 @@ enum fARCH {
6565 fARCH_i386 ,
6666 fARCH_x86_64 ,
6767 fARCH_arm ,
68- fARCH_aarch64
68+ fARCH_aarch64 ,
69+ fARCH_loongarch64 ,
70+ fARCH_SIZE // To get the number of architectures.
6971};
7072
7173static gchar const APPIMAGEIGNORE [] = ".appimageignore" ;
@@ -288,7 +290,7 @@ static void replacestr(char *line, const char *search, const char *replace)
288290int count_archs (bool * archs ) {
289291 int countArchs = 0 ;
290292 int i ;
291- for (i = 0 ; i < 4 ; i ++ ) {
293+ for (i = 0 ; i < fARCH_SIZE ; i ++ ) {
292294 countArchs += archs [i ];
293295 }
294296 return countArchs ;
@@ -303,11 +305,18 @@ gchar* getArchName(bool* archs) {
303305 return "armhf" ;
304306 else if (archs [fARCH_aarch64 ])
305307 return "aarch64" ;
308+ else if (archs [fARCH_loongarch64 ])
309+ return "loongarch64" ;
306310 else
307311 return "all" ;
308312}
309313
310314void extract_arch_from_e_machine_field (int16_t e_machine , const gchar * sourcename , bool * archs ) {
315+ if (e_machine == 2 ) {
316+ archs [fARCH_loongarch64 ] = 1 ;
317+ if (verbose )
318+ fprintf (stderr , "%s used for determining architecture loongarch64\n" , sourcename );
319+ }
311320 if (e_machine == 3 ) {
312321 archs [fARCH_i386 ] = 1 ;
313322 if (verbose )
@@ -363,6 +372,10 @@ void extract_arch_from_text(gchar *archname, const gchar* sourcename, bool* arch
363372 archs [fARCH_aarch64 ] = 1 ;
364373 if (verbose )
365374 fprintf (stderr , "%s used for determining architecture ARM aarch64\n" , sourcename );
375+ } else if (g_ascii_strncasecmp ("loongarch64" , archname , 20 ) == 0 ) {
376+ archs [fARCH_loongarch64 ] = 1 ;
377+ if (verbose )
378+ fprintf (stderr , "%s used for determining architecture loongarch64\n" , sourcename );
366379 }
367380 }
368381 }
@@ -720,7 +733,8 @@ main (int argc, char *argv[])
720733 }
721734
722735 /* Determine the architecture */
723- bool archs [4 ] = {0 , 0 , 0 , 0 };
736+ bool archs [fARCH_SIZE ];
737+ memset (archs ,0 ,sizeof (bool )* fARCH_SIZE );
724738 extract_arch_from_text (getenv ("ARCH" ), "Environmental variable ARCH" , archs );
725739 if (count_archs (archs ) != 1 ) {
726740 /* If no $ARCH variable is set check a file */
0 commit comments