From 7199b83b9596855a9929d12e5942cc541c194b5f Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 6 May 2021 23:33:08 -0500 Subject: [PATCH] Bugfix: Compilation/Portability problems exposed when building against musl-libc. Some headers are missing. Change the length types: f_console_parameter_size and f_array_length_t. I have seen problems where the max allowed size is reached in f_array_length_t. Compiling against musl-libc further exposes this problem and so I have reduced the practice to using a set length of 2^63 (aka: signed long). --- level_0/f_color/c/color.h | 1 + level_0/f_console/c/console-common.h | 5 ++++- level_0/f_directory/c/directory.h | 1 + level_0/f_type/c/type.h | 10 +++++++--- level_1/fl_print/c/print.h | 3 +++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/level_0/f_color/c/color.h b/level_0/f_color/c/color.h index a9c0286..17105a5 100644 --- a/level_0/f_color/c/color.h +++ b/level_0/f_color/c/color.h @@ -15,6 +15,7 @@ // libc includes #include +#include #include // fll-0 includes diff --git a/level_0/f_console/c/console-common.h b/level_0/f_console/c/console-common.h index 3795c3f..3ae9994 100644 --- a/level_0/f_console/c/console-common.h +++ b/level_0/f_console/c/console-common.h @@ -168,9 +168,12 @@ extern "C" { /** * The maximum size for a single parameter (the length of the string representing the parameter). + * + * The ideal parameter value is f_array_length_t_size, which generally defaults to 2^64 (unsigned). + * However, the libc/POSIX appears to limit this to 2^63 (signed). */ #ifndef _di_f_console_length_size_ - #define f_console_parameter_size f_array_length_t_size + #define f_console_parameter_size f_type_size_max_64_positive #endif // _di_f_console_length_size_ /** diff --git a/level_0/f_directory/c/directory.h b/level_0/f_directory/c/directory.h index ccac433..6aca2d2 100644 --- a/level_0/f_directory/c/directory.h +++ b/level_0/f_directory/c/directory.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 250001a..b714498 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -187,12 +187,16 @@ extern "C" { /** * Defines a variable to be used by arrays. + * + * There are problems in some libc's and systems that do not handle lengths greater than 2^63. + * This is primarily a problem with libc string functions. + * For general compatiblity reasons, this is set to a signed 64-bit integer. */ #ifndef _di_f_array_t_ - typedef f_number_unsigned_t f_array_length_t; + typedef f_number_signed_t f_array_length_t; - #define f_array_length_t_size f_number_t_size_unsigned - #define f_array_length_t_size_max f_number_t_size_max_unsigned + #define f_array_length_t_size f_type_size_64_positive + #define f_array_length_t_size_max f_type_size_max_64_positive #endif // _di_f_array_t_ /** diff --git a/level_1/fl_print/c/print.h b/level_1/fl_print/c/print.h index a9aded1..a69bebe 100644 --- a/level_1/fl_print/c/print.h +++ b/level_1/fl_print/c/print.h @@ -12,6 +12,9 @@ #ifndef _FL_print_h #define _FL_print_h +// libc includes +#include + // fll-0 includes #include #include -- 1.8.3.1