@@ -623,8 +623,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
623
623
break ;
624
624
case 't' : // threads
625
625
errno = 0 ;
626
- jl_options .nthreadpools = 1 ;
627
- long nthreads = -1 , nthreadsi = 0 ;
626
+ jl_options .nthreadpools = 2 ;
627
+ // By default, main threads = -1 (== "auto"), interactive = 1
628
+ long nthreads = -1 , nthreadsi = 1 ;
629
+
628
630
if (!strncmp (optarg , "auto" , 4 )) {
629
631
jl_options .nthreads = -1 ;
630
632
if (optarg [4 ] == ',' ) {
@@ -633,10 +635,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
633
635
else {
634
636
errno = 0 ;
635
637
nthreadsi = strtol (& optarg [5 ], & endptr , 10 );
636
- if (errno != 0 || endptr == & optarg [5 ] || * endptr != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX )
637
- jl_errorf ("julia: -t,--threads=auto,<m>; m must be an integer >= 1 " );
638
+ if (errno != 0 || endptr == & optarg [5 ] || * endptr != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
639
+ jl_errorf ("julia: -t,--threads=auto,<m>; m must be an integer >= 0 " );
638
640
}
639
- jl_options .nthreadpools ++ ;
640
641
}
641
642
}
642
643
else {
@@ -650,17 +651,16 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
650
651
errno = 0 ;
651
652
char * endptri ;
652
653
nthreadsi = strtol (& endptr [1 ], & endptri , 10 );
653
- if (errno != 0 || endptri == & endptr [1 ] || * endptri != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX )
654
- jl_errorf ("julia: -t,--threads=<n>,<m>; n and m must be integers >= 1" );
654
+ // Allow 0 for interactive
655
+ if (errno != 0 || endptri == & endptr [1 ] || * endptri != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
656
+ jl_errorf ("julia: -t,--threads=<n>,<m>; m must be an integer ≥ 0" );
655
657
}
656
- jl_options .nthreadpools ++ ;
657
658
}
658
659
jl_options .nthreads = nthreads + nthreadsi ;
659
660
}
660
661
int16_t * ntpp = (int16_t * )malloc_s (jl_options .nthreadpools * sizeof (int16_t ));
661
662
ntpp [0 ] = (int16_t )nthreads ;
662
- if (jl_options .nthreadpools == 2 )
663
- ntpp [1 ] = (int16_t )nthreadsi ;
663
+ ntpp [1 ] = (int16_t )nthreadsi ;
664
664
jl_options .nthreads_per_pool = ntpp ;
665
665
break ;
666
666
case 'p' : // procs
0 commit comments