diff --git a/meson.build b/meson.build index 99bdb1a6e7f9ad42fa790fe10a01f4fc753df97a..952933d039ea2683d61167da9cb50453b8987a34 100644 --- a/meson.build +++ b/meson.build @@ -839,17 +839,10 @@ foreach src_subdir : src_subdirs _headers, ], include_directories: include_directories(incdirs), - dependencies : [ - dependencies - ], c_args : [ cflags, quoted_cflags_list, ], - objects : data_objects, - link_args : [ - libs, - ], link_language: 'c', ) endif diff --git a/src/binary_c_function_macros.h b/src/binary_c_function_macros.h index 7be569003d68e2c34c5a03b9f0279834edc38e6e..7f4fee6bcbcd742eeb852db17e7d6eb956c0f05d 100644 --- a/src/binary_c_function_macros.h +++ b/src/binary_c_function_macros.h @@ -1537,7 +1537,39 @@ fflush(NULL); \ _exit(0); \ } - + +/* + * long int converters + */ +#define Long_int_to_int(N) \ + ((int)( \ + (N) > INT_MAX ? INT_MAX : \ + (N) < INT_MIN ? INT_MIN : \ + (N) \ + )) +#define Long_int_to_short_int(N) \ + ((short int)( \ + (N) > SHRT_MAX ? SHRT_MAX : \ + (N) < SHRT_MIN ? SHRT_MIN : \ + (N) \ + )) +#define Long_int_to_unsigned_int(N) \ + ((unsigned int)( \ + (N) > UINT_MAX ? UINT_MAX : \ + (N) < 0 ? 0 : \ + (N) \ + )) +#define Long_int_to_unsigned_short_int(N) \ + ((unsigned short int)( \ + (N) > USHRT_MAX ? USHRT_MAX : \ + (N) < 0 ? 0 : \ + (N) \ + )) +#define Long_int_to_boolean(N) \ + ((Boolean)( \ + (N) == 0 ? FALSE : TRUE \ + )) + #endif // BINARY_C_FUNCTION_MACROS_H diff --git a/src/setup/argument_setting_functions.c b/src/setup/argument_setting_functions.c index 300c62a838ad4dcaf9de56029e8eb1d8e12ec157..42d8155185a88910f916dbf9a926e2c7b01ae238 100644 --- a/src/setup/argument_setting_functions.c +++ b/src/setup/argument_setting_functions.c @@ -10,7 +10,7 @@ static char * arg_variable_default_string( void binary_c_warmup_cpu(ARG_SUBROUTINE_DECLARATION) { (*c)++; - const int secs = (int) strtol(argv[*c],NULL,10); + const int secs = Long_int_to_int(strtol(argv[*c],NULL,10)); if(secs!=0)warmup_cpu(stardata,secs); } @@ -388,7 +388,7 @@ void No_return dumpversion(ARG_SUBROUTINE_DECLARATION) void set_init_abund_mult(ARG_SUBROUTINE_DECLARATION) { (*c)++; - Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10); + Isotope n MAYBE_UNUSED = (Isotope)Long_int_to_unsigned_short_int(strtol(argv[*c],NULL,10)); (*c)++; #ifdef NUCSYN double f = strtod(argv[*c],NULL); @@ -399,7 +399,7 @@ void set_init_abund_mult(ARG_SUBROUTINE_DECLARATION) void set_init_abund_dex(ARG_SUBROUTINE_DECLARATION) { (*c)++; - Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10); + Isotope n MAYBE_UNUSED = (Isotope)Long_int_to_unsigned_short_int(strtol(argv[*c],NULL,10)); (*c)++; #ifdef NUCSYN double f = strtod(argv[*c],NULL); @@ -412,7 +412,7 @@ void set_init_abund_dex(ARG_SUBROUTINE_DECLARATION) void set_init_abund(ARG_SUBROUTINE_DECLARATION) { (*c)++; - Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10); + Isotope n MAYBE_UNUSED = (Isotope)Long_int_to_unsigned_short_int(strtol(argv[*c],NULL,10)); (*c)++; #ifdef NUCSYN double X = strtod(argv[*c],NULL); @@ -423,7 +423,7 @@ void set_init_abund(ARG_SUBROUTINE_DECLARATION) void set_third_dup_multiplier(ARG_SUBROUTINE_DECLARATION) { (*c)++; - Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10); + Isotope n MAYBE_UNUSED = (Isotope)Long_int_to_unsigned_short_int(strtol(argv[*c],NULL,10)); (*c)++; #if defined (NUCSYN) && defined(THIRD_DREDGE_UP) && defined(NUCSYN_THIRD_DREDGE_UP_MULTIPLIERS) double X = strtod(argv[*c],NULL); diff --git a/src/setup/cmd_line_function_macros.h b/src/setup/cmd_line_function_macros.h index 0c0ec2730b13fd50d3b4ac1038c1db00c0901f61..d363be96eb24f3905115b3a2550e8a55a53ed039 100644 --- a/src/setup/cmd_line_function_macros.h +++ b/src/setup/cmd_line_function_macros.h @@ -235,7 +235,9 @@ test = \ Arg_is_true(argv[c]) ? TRUE : \ Arg_is_false(argv[c]) ? FALSE : \ - (Boolean)strtol(argv[++c],NULL,10); \ + (Boolean)Long_int_to_boolean(strtol(argv[++c], \ + NULL, \ + 10)); \ Cprint("test %d (c=%d vs argc=%d arg is %s)\n", \ test,c,argc,argv[c]); \ } \