From 3611d91e8361fe8454289050ce9c30f537449367 Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Tue, 26 Nov 2019 16:55:16 +0800 Subject: [PATCH] reduced required subdir-link-time dependencies to speed things up and greatly reduce the size of build files --- meson.build | 7 ------ src/binary_c_function_macros.h | 34 +++++++++++++++++++++++++- src/setup/argument_setting_functions.c | 10 ++++---- src/setup/cmd_line_function_macros.h | 4 ++- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 99bdb1a6e..952933d03 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 7be569003..7f4fee6bc 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 300c62a83..42d815518 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 0c0ec2730..d363be96e 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]); \ } \ -- GitLab