From: Kevin Day Date: Sat, 20 Apr 2024 04:29:22 +0000 (-0500) Subject: Update: Add additional time types, refactor f_time_spec and similar, and rebuild... X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=9d8835b60db27f2803bf61b8682c8ed7a5fd046d;p=fll Update: Add additional time types, refactor f_time_spec and similar, and rebuild stand alone build configs. The f_time_spec_t is not the same as "struct timespec". Avoid confusion by renaming it to f_time_simple_t. rename f_date_spec_t to f_date_simple_t for the same reason. Add additional types and now that f_time_spec_t is available, create f_time_spec_t as a typedef of "struct timespec". Update the stand alone build scripts with all of these changes and some changes from previous commits. --- diff --git a/build/stand_alone/byte_dump.config.h b/build/stand_alone/byte_dump.config.h index ac58f5c..a5e3d41 100644 --- a/build/stand_alone/byte_dump.config.h +++ b/build/stand_alone/byte_dump.config.h @@ -215,7 +215,7 @@ //#define _di_f_conversion_number_signed_to_string_ //#define _di_f_conversion_number_unsigned_print_ //#define _di_f_conversion_number_unsigned_to_string_ -#define _di_f_date_spec_t_ +#define _di_f_date_simple_t_ #define _di_f_date_t_ #define _di_f_file_access_ #define _di_f_file_access_at_ @@ -549,6 +549,8 @@ #define _di_fll_print_trim_raw_ #define _di_fll_print_trim_raw_safely_ #define _di_fll_print_trim_safely_ +//#define _di_fll_program_copyright_s_ +//#define _di_fll_program_copyright_year_author_s_ //#define _di_fll_program_data_delete_ #define _di_fll_program_data_destroy_ //#define _di_fll_program_data_pipe_e_ @@ -1386,6 +1388,8 @@ #define _di_f_thread_spin_t_ #define _di_f_thread_spin_unlock_ #define _di_f_thread_unlock_ +#define _di_f_time_part_t_ +#define _di_f_time_simple_t_ #define _di_f_time_spec_t_ #define _di_f_time_t_ //#define _di_f_type_d_ diff --git a/build/stand_alone/example.config.h b/build/stand_alone/example.config.h index c4ff055..a8cef24 100644 --- a/build/stand_alone/example.config.h +++ b/build/stand_alone/example.config.h @@ -8,7 +8,7 @@ // // Example: // echo > /tmp/all.txt -// for i in f_type f_status f_memory f_type_array f_string f_utf f_color f_console f_conversion f_file f_pipe f_print f_rip f_signal f_thread ; do grep -horP '\b_di_f_\w*\b' level_0/$i/c >> /tmp/all.txt ; grep -horP '\b_di_macro_\w*\b' level_0/$i/c >> /tmp/all.txt ; done +// for i in f_type f_status f_memory f_type_array f_string f_utf f_color f_console f_conversion f_file f_pipe f_print f_rip f_signal f_time f_thread ; do grep -horP '\b_di_f_\w*\b' level_0/$i/c >> /tmp/all.txt ; grep -horP '\b_di_macro_\w*\b' level_0/$i/c >> /tmp/all.txt ; done // for i in fl_print ; do grep -horP '\b_di_fl_\w*\b' level_1/$i/c >> /tmp/all.txt ; grep -horP '\b_di_macro_\w*\b' level_1/$i/c >> /tmp/all.txt ; done // for i in fll_error fll_print fll_program ; do grep -horP '\b_di_fll_\w*\b' level_2/$i/c >> /tmp/all.txt ; grep -horP '\b_di_macro_\w*\b' level_2/$i/c >> /tmp/all.txt ; done // sort /tmp/all.txt | uniq | sed -e 's|^_|#define &|g' > /tmp/sorted.txt @@ -166,7 +166,7 @@ //#define _di_f_conversion_number_signed_to_string_ //#define _di_f_conversion_number_unsigned_print_ //#define _di_f_conversion_number_unsigned_to_string_ -#define _di_f_date_spec_t_ +#define _di_f_date_simple_t_ #define _di_f_date_t_ #define _di_f_file_access_ #define _di_f_file_access_at_ @@ -474,6 +474,8 @@ #define _di_fll_print_trim_raw_ #define _di_fll_print_trim_raw_safely_ #define _di_fll_print_trim_safely_ +//#define _di_fll_program_copyright_s_ +//#define _di_fll_program_copyright_year_author_s_ //#define _di_fll_program_data_delete_ #define _di_fll_program_data_destroy_ //#define _di_fll_program_data_pipe_e_ @@ -1311,6 +1313,8 @@ #define _di_f_thread_spin_t_ #define _di_f_thread_spin_unlock_ #define _di_f_thread_unlock_ +#define _di_f_time_part_t_ +#define _di_f_time_simple_t_ #define _di_f_time_spec_t_ #define _di_f_time_t_ //#define _di_f_type_d_ diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index 5bbaa61..8fc0578 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -302,7 +302,7 @@ //#define _di_f_conversion_number_signed_to_string_ //#define _di_f_conversion_number_unsigned_print_ //#define _di_f_conversion_number_unsigned_to_string_ -#define _di_f_date_spec_t_ +#define _di_f_date_simple_t_ #define _di_f_date_t_ //#define _di_f_directory_at_d_ #define _di_f_directory_back_s_ @@ -584,9 +584,11 @@ #define _di_f_fss_payload_object_name_s_ #define _di_f_fss_payload_object_part_s_ #define _di_f_fss_payload_object_payload_s_ +#define _di_f_fss_payload_object_salt_s_ #define _di_f_fss_payload_object_signature_s_ #define _di_f_fss_payload_object_size_s_ #define _di_f_fss_payload_object_status_s_ +#define _di_f_fss_payload_object_time_s_ #define _di_f_fss_payload_object_total_s_ #define _di_f_fss_payload_object_type_s_ #define _di_f_fss_payload_s_ @@ -786,8 +788,10 @@ //#define _di_fl_fss_extended_object_read_ #define _di_fl_fss_extended_object_write_ #define _di_fl_fss_payload_d_ +#define _di_fl_fss_payload_header_internal_t_ #define _di_fl_fss_payload_header_map_ #define _di_fl_fss_payload_header_maps_ +#define _di_fl_fss_payload_header_state_t_ //#define _di_fl_iki_read_ //#define _di_f_limit_process_ #define _di_f_limit_setss_delete_callback_ @@ -923,6 +927,8 @@ #define _di_fll_print_trim_raw_ #define _di_fll_print_trim_raw_safely_ #define _di_fll_print_trim_safely_ +//#define _di_fll_program_copyright_s_ +//#define _di_fll_program_copyright_year_author_s_ //#define _di_fll_program_data_delete_ #define _di_fll_program_data_destroy_ //#define _di_fll_program_data_pipe_e_ @@ -1869,6 +1875,8 @@ #define _di_f_thread_spin_t_ #define _di_f_thread_spin_unlock_ #define _di_f_thread_unlock_ +#define _di_f_time_part_t_ +#define _di_f_time_simple_t_ #define _di_f_time_spec_t_ #define _di_f_time_t_ //#define _di_f_type_d_ diff --git a/build/stand_alone/firewall.config.h b/build/stand_alone/firewall.config.h index a1b4666..a63e24c 100644 --- a/build/stand_alone/firewall.config.h +++ b/build/stand_alone/firewall.config.h @@ -302,7 +302,7 @@ //#define _di_f_conversion_number_signed_to_string_ //#define _di_f_conversion_number_unsigned_print_ //#define _di_f_conversion_number_unsigned_to_string_ -#define _di_f_date_spec_t_ +#define _di_f_date_simple_t_ #define _di_f_date_t_ #define _di_f_directory_at_d_ //#define _di_f_directory_back_s_ @@ -584,9 +584,11 @@ #define _di_f_fss_payload_object_name_s_ #define _di_f_fss_payload_object_part_s_ #define _di_f_fss_payload_object_payload_s_ +#define _di_f_fss_payload_object_salt_s_ #define _di_f_fss_payload_object_signature_s_ #define _di_f_fss_payload_object_size_s_ #define _di_f_fss_payload_object_status_s_ +#define _di_f_fss_payload_object_time_s_ #define _di_f_fss_payload_object_total_s_ #define _di_f_fss_payload_object_type_s_ #define _di_f_fss_payload_s_ @@ -786,8 +788,10 @@ //#define _di_fl_fss_extended_object_read_ #define _di_fl_fss_extended_object_write_ #define _di_fl_fss_payload_d_ +#define _di_fl_fss_payload_header_internal_t_ #define _di_fl_fss_payload_header_map_ #define _di_fl_fss_payload_header_maps_ +#define _di_fl_fss_payload_header_state_t_ #define _di_fl_iki_read_ //#define _di_f_limit_process_ #define _di_f_limit_setss_delete_callback_ @@ -935,6 +939,8 @@ #define _di_fll_print_trim_raw_ #define _di_fll_print_trim_raw_safely_ #define _di_fll_print_trim_safely_ +//#define _di_fll_program_copyright_s_ +//#define _di_fll_program_copyright_year_author_s_ //#define _di_fll_program_data_delete_ #define _di_fll_program_data_destroy_ //#define _di_fll_program_data_pipe_e_ @@ -1937,9 +1943,18 @@ #define _di_f_thread_spin_t_ #define _di_f_thread_spin_unlock_ #define _di_f_thread_unlock_ +#define _di_f_time_calendar_string_ +#define _di_f_time_calendar_string_part_ +#define _di_f_time_epoch_get_ +#define _di_f_time_local_get_ +#define _di_f_time_of_day_get_ +#define _di_f_time_of_day_set_ +#define _di_f_time_part_t_ +#define _di_f_time_simple_t_ #define _di_f_time_spec_millisecond_ #define _di_f_time_spec_nanosecond_ #define _di_f_time_spec_t_ +#define _di_f_time_utc_get_ #define _di_f_time_t_ //#define _di_f_type_d_ //#define _di_f_type_file_defaults_d_ diff --git a/build/stand_alone/utf8.config.h b/build/stand_alone/utf8.config.h index 5b05691..5727ebc 100644 --- a/build/stand_alone/utf8.config.h +++ b/build/stand_alone/utf8.config.h @@ -215,7 +215,7 @@ //#define _di_f_conversion_number_signed_to_string_ //#define _di_f_conversion_number_unsigned_print_ //#define _di_f_conversion_number_unsigned_to_string_ -#define _di_f_date_spec_t_ +#define _di_f_date_simple_t_ #define _di_f_date_t_ #define _di_f_file_access_ #define _di_f_file_access_at_ @@ -549,6 +549,8 @@ #define _di_fll_print_trim_raw_ #define _di_fll_print_trim_raw_safely_ #define _di_fll_print_trim_safely_ +//#define _di_fll_program_copyright_s_ +//#define _di_fll_program_copyright_year_author_s_ //#define _di_fll_program_data_delete_ #define _di_fll_program_data_destroy_ //#define _di_fll_program_data_pipe_e_ @@ -1404,6 +1406,10 @@ #define _di_f_thread_spin_t_ #define _di_f_thread_spin_unlock_ #define _di_f_thread_unlock_ +#define _di_f_time_part_t_ +#define _di_f_time_simple_t_ +#define _di_f_time_spec_millisecond_ +#define _di_f_time_spec_nanosecond_ #define _di_f_time_spec_t_ #define _di_f_time_t_ //#define _di_f_type_d_ diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index 7d6a6ce..e56c936 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -1864,7 +1864,7 @@ extern "C" { #endif // _di_f_file_select_ #ifndef _di_f_file_select_signal_ - f_status_t f_file_select_signal(const int highest_plus_one, fd_set * const read, fd_set * const write, fd_set * const except, const struct timespec * const timeout, const sigset_t * const signal) { + f_status_t f_file_select_signal(const int highest_plus_one, fd_set * const read, fd_set * const write, fd_set * const except, const f_time_spec_t * const timeout, const sigset_t * const signal) { if (!highest_plus_one) return F_data_not; if (!read && !write && !except && !timeout) return F_data_not; diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index d770a77..d3fbc55 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -32,6 +32,7 @@ // FLL-0 includes. #include #include +#include #include #include #include @@ -2066,7 +2067,7 @@ extern "C" { * @see pselect() */ #ifndef _di_f_file_select_signal_ - extern f_status_t f_file_select_signal(const int highest_plus_one, fd_set * const read, fd_set * const write, fd_set * const except, const struct timespec * const timeout, const sigset_t * const signal); + extern f_status_t f_file_select_signal(const int highest_plus_one, fd_set * const read, fd_set * const write, fd_set * const except, const f_time_spec_t * const timeout, const sigset_t * const signal); #endif // _di_f_file_select_signal_ /** diff --git a/level_0/f_signal/c/signal.c b/level_0/f_signal/c/signal.c index 6ef5146..dbd5adc 100644 --- a/level_0/f_signal/c/signal.c +++ b/level_0/f_signal/c/signal.c @@ -292,7 +292,7 @@ extern "C" { #endif // _di_f_signal_wait_ #ifndef _di_f_signal_wait_until_ - f_status_t f_signal_wait_until(const sigset_t * const set, const struct timespec * timeout, siginfo_t * const information) { + f_status_t f_signal_wait_until(const sigset_t * const set, const f_time_spec_t *timeout, siginfo_t * const information) { if (sigtimedwait(set, information, timeout) == -1) { if (errno == EAGAIN) return F_time_out; diff --git a/level_0/f_signal/c/signal.h b/level_0/f_signal/c/signal.h index fc29a46..abac46a 100644 --- a/level_0/f_signal/c/signal.h +++ b/level_0/f_signal/c/signal.h @@ -407,7 +407,7 @@ extern "C" { * @see sigtimedwait() */ #ifndef _di_f_signal_wait_until_ - extern f_status_t f_signal_wait_until(const sigset_t * const set, const struct timespec *timeout, siginfo_t * const information); + extern f_status_t f_signal_wait_until(const sigset_t * const set, const f_time_spec_t *timeout, siginfo_t * const information); #endif // _di_f_signal_wait_until_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index d042a33..c9dcfb2 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -901,7 +901,7 @@ extern "C" { #endif // _di_f_thread_condition_wait_ #ifndef _di_f_thread_condition_wait_timed_ - f_status_t f_thread_condition_wait_timed(const struct timespec *wait, f_thread_condition_t * const condition, f_thread_mutex_t * const mutex) { + f_status_t f_thread_condition_wait_timed(const f_time_spec_t *wait, f_thread_condition_t * const condition, f_thread_mutex_t * const mutex) { #ifndef _di_level_0_parameter_checking_ if (!condition) return F_status_set_error(F_parameter); if (!mutex) return F_status_set_error(F_parameter); @@ -1010,7 +1010,7 @@ extern "C" { #endif // _di_f_thread_join_try_ #ifndef _di_f_thread_join_timed_ - f_status_t f_thread_join_timed(const f_thread_id_t id, const struct timespec wait, void **result) { + f_status_t f_thread_join_timed(const f_thread_id_t id, const f_time_spec_t wait, void **result) { const int error = pthread_timedjoin_np(id, result, &wait); @@ -1228,7 +1228,7 @@ extern "C" { #endif // _di_f_thread_lock_read_ #ifndef _di_f_thread_lock_read_timed_ - f_status_t f_thread_lock_read_timed(const struct timespec * const timeout, f_thread_lock_t * const lock) { + f_status_t f_thread_lock_read_timed(const f_time_spec_t * const timeout, f_thread_lock_t * const lock) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!lock) return F_status_set_error(F_parameter); @@ -1290,7 +1290,7 @@ extern "C" { #endif // _di_f_thread_lock_write_ #ifndef _di_f_thread_lock_write_timed_ - f_status_t f_thread_lock_write_timed(const struct timespec * const timeout, f_thread_lock_t * const lock) { + f_status_t f_thread_lock_write_timed(const f_time_spec_t * const timeout, f_thread_lock_t * const lock) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!lock) return F_status_set_error(F_parameter); @@ -1599,7 +1599,7 @@ extern "C" { #endif // _di_f_thread_mutex_lock_ #ifndef _di_f_thread_mutex_lock_timed_ - f_status_t f_thread_mutex_lock_timed(const struct timespec * const timeout, f_thread_mutex_t * const mutex) { + f_status_t f_thread_mutex_lock_timed(const f_time_spec_t * const timeout, f_thread_mutex_t * const mutex) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!mutex) return F_status_set_error(F_parameter); @@ -1907,7 +1907,7 @@ extern "C" { #endif // _di_f_thread_semaphore_lock_ #ifndef _di_f_thread_semaphore_lock_timed_ - f_status_t f_thread_semaphore_lock_timed(const struct timespec * const timeout, f_thread_semaphore_t * const semaphore) { + f_status_t f_thread_semaphore_lock_timed(const f_time_spec_t * const timeout, f_thread_semaphore_t * const semaphore) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!semaphore) return F_status_set_error(F_parameter); diff --git a/level_0/f_thread/c/thread.h b/level_0/f_thread/c/thread.h index e033f03..b21aa81 100644 --- a/level_0/f_thread/c/thread.h +++ b/level_0/f_thread/c/thread.h @@ -1146,7 +1146,7 @@ extern "C" { * @see pthread_cond_timedwait() */ #ifndef _di_f_thread_condition_wait_timed_ - extern f_status_t f_thread_condition_wait_timed(const struct timespec *wait, f_thread_condition_t * const condition, f_thread_mutex_t * const mutex); + extern f_status_t f_thread_condition_wait_timed(const f_time_spec_t *wait, f_thread_condition_t * const condition, f_thread_mutex_t * const mutex); #endif // _di_f_thread_condition_wait_timed_ /** @@ -1310,7 +1310,7 @@ extern "C" { * @see pthread_timedjoin_np() */ #ifndef _di_f_thread_join_timed_ - extern f_status_t f_thread_join_timed(const f_thread_id_t id, const struct timespec wait, void **result); + extern f_status_t f_thread_join_timed(const f_thread_id_t id, const f_time_spec_t wait, void **result); #endif // _di_f_thread_join_timed_ /** @@ -1580,7 +1580,7 @@ extern "C" { * @see pthread_rwlock_timedrdlock() */ #ifndef _di_f_thread_lock_read_timed_ - extern f_status_t f_thread_lock_read_timed(const struct timespec * const timeout, f_thread_lock_t * const lock); + extern f_status_t f_thread_lock_read_timed(const f_time_spec_t * const timeout, f_thread_lock_t * const lock); #endif // _di_f_thread_lock_read_timed_ /** @@ -1655,7 +1655,7 @@ extern "C" { * @see pthread_rwlock_timedwrlock() */ #ifndef _di_f_thread_lock_write_timed_ - extern f_status_t f_thread_lock_write_timed(const struct timespec * const timeout, f_thread_lock_t * const lock); + extern f_status_t f_thread_lock_write_timed(const f_time_spec_t * const timeout, f_thread_lock_t * const lock); #endif // _di_f_thread_lock_write_timed_ /** @@ -2068,7 +2068,7 @@ extern "C" { * @see pthread_mutex_timedlock() */ #ifndef _di_f_thread_mutex_lock_timed_ - extern f_status_t f_thread_mutex_lock_timed(const struct timespec * const timeout, f_thread_mutex_t * const mutex); + extern f_status_t f_thread_mutex_lock_timed(const f_time_spec_t * const timeout, f_thread_mutex_t * const mutex); #endif // _di_f_thread_mutex_lock_timed_ /** @@ -2376,7 +2376,7 @@ extern "C" { * @see sem_timedwait() */ #ifndef _di_f_thread_semaphore_lock_timed_ - extern f_status_t f_thread_semaphore_lock_timed(const struct timespec * const timeout, f_thread_semaphore_t * const semaphore); + extern f_status_t f_thread_semaphore_lock_timed(const f_time_spec_t * const timeout, f_thread_semaphore_t * const semaphore); #endif // _di_f_thread_semaphore_lock_timed_ /** diff --git a/level_0/f_time/c/time.c b/level_0/f_time/c/time.c index 578cd5c..41b7549 100644 --- a/level_0/f_time/c/time.c +++ b/level_0/f_time/c/time.c @@ -116,7 +116,7 @@ extern "C" { #endif // _di_f_time_of_day_set_ #ifndef _di_f_time_spec_millisecond_ - extern f_status_t f_time_spec_millisecond(const f_number_unsigned_t second, const f_number_unsigned_t millisecond, struct timespec * const time) { + extern f_status_t f_time_spec_millisecond(const f_number_unsigned_t second, const f_number_unsigned_t millisecond, f_time_spec_t * const time) { #ifndef _di_level_0_parameter_checking_ if (!time) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -157,7 +157,7 @@ extern "C" { #endif // _di_f_time_spec_millisecond_ #ifndef _di_f_time_spec_nanosecond_ - extern f_status_t f_time_spec_nanosecond(const f_number_unsigned_t second, const f_number_unsigned_t nanosecond, struct timespec * const time) { + extern f_status_t f_time_spec_nanosecond(const f_number_unsigned_t second, const f_number_unsigned_t nanosecond, f_time_spec_t * const time) { #ifndef _di_level_0_parameter_checking_ if (!time) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_time/c/time.h b/level_0/f_time/c/time.h index 4a3fa34..84fc487 100644 --- a/level_0/f_time/c/time.h +++ b/level_0/f_time/c/time.h @@ -16,6 +16,7 @@ // FLL-0 includes. #include +#include #include #include @@ -174,9 +175,8 @@ extern "C" { /** * Create a timespec representing the given seconds and milliseconds. * - * This is intended to work with "struct timespec" and is not intended to work with "f_time_spec_t". - * The "struct timespec" may have different lengths and so this function provides overflow and underflow protection. - * The "f_time_spec_t" should not need this as "f_time_spec_t" is intended to always be uint64_t. + * The "f_time_spec_t" may have different lengths and so this function provides overflow and underflow protection. + * The "f_time_simple_t" should not need this as "f_time_simple_t" is intended to always be uint64_t. * * @param second * The number of seconds. @@ -196,15 +196,14 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_time_spec_millisecond_ - extern f_status_t f_time_spec_millisecond(const f_number_unsigned_t second, const f_number_unsigned_t millisecond, struct timespec * const time); + extern f_status_t f_time_spec_millisecond(const f_number_unsigned_t second, const f_number_unsigned_t millisecond, f_time_spec_t * const time); #endif // _di_f_time_spec_millisecond_ /** * Create a timespec representing the given seconds and nanoseconds. * - * This is intended to work with "struct timespec" and is not intended to work with "f_time_spec_t". - * The "struct timespec" may have different lengths and so this function provides overflow and underflow protection. - * The "f_time_spec_t" should not need this as "f_time_spec_t" is intended to always be uint64_t. + * The "f_time_spec_t" may have different lengths and so this function provides overflow and underflow protection. + * The "f_time_simple_t" should not need this as "f_time_simple_t" is intended to always be uint64_t. * * @param second * The number of seconds. @@ -224,7 +223,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_time_spec_nanosecond_ - extern f_status_t f_time_spec_nanosecond(const f_number_unsigned_t second, const f_number_unsigned_t nanosecond, struct timespec * const time); + extern f_status_t f_time_spec_nanosecond(const f_number_unsigned_t second, const f_number_unsigned_t nanosecond, f_time_spec_t * const time); #endif // _di_f_time_spec_nanosecond_ /** diff --git a/level_0/f_time/c/time/common.h b/level_0/f_time/c/time/common.h index ce1b80c..58a810b 100644 --- a/level_0/f_time/c/time/common.h +++ b/level_0/f_time/c/time/common.h @@ -26,24 +26,6 @@ extern "C" { #define F_time_calendar_string_length_d 27 #endif // _di_f_time_d_ -/** - * A typedef representing struct timeval. - */ -#ifndef _di_f_time_value_t_ - typedef struct timeval f_time_value_t; - - #define f_time_value_t_initialize { 0 } -#endif // _di_f_time_value_t_ - -/** - * A typedef representing struct tm. - */ -#ifndef _di_f_time_part_t_ - typedef struct tm f_time_part_t; - - #define f_time_part_t_initialize { 0 } -#endif // _di_f_time_part_t_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_time/tests/unit/c/test-time-spec_millisecond.c b/level_0/f_time/tests/unit/c/test-time-spec_millisecond.c index 587c4e8..9f2407c 100644 --- a/level_0/f_time/tests/unit/c/test-time-spec_millisecond.c +++ b/level_0/f_time/tests/unit/c/test-time-spec_millisecond.c @@ -17,7 +17,7 @@ void test__f_time_spec_millisecond__number_overflow(void **state) { second = (f_number_unsigned_t) ((time_t) (-1)); } - struct timespec time = { 0 }; + f_time_spec_t time = { 0 }; { const f_status_t status = f_time_spec_millisecond(second, 1000, &time); @@ -34,7 +34,7 @@ void test__f_time_spec_millisecond__number_overflow(void **state) { void test__f_time_spec_millisecond__number_underflow(void **state) { - struct timespec time = { .tv_sec = -1, .tv_nsec = -1 }; + f_time_spec_t time = { .tv_sec = -1, .tv_nsec = -1 }; // If this system has uses unsigned, then this test is not needed. if (time.tv_sec >= 0 && time.tv_nsec >= 0) return; @@ -77,7 +77,7 @@ void test__f_time_spec_millisecond__parameter_checking(void **state) { void test__f_time_spec_millisecond__works(void **state) { - struct timespec time = { 0 }; + f_time_spec_t time = { 0 }; { const f_number_unsigned_t seconds[] = { diff --git a/level_0/f_time/tests/unit/c/test-time-spec_nanosecond.c b/level_0/f_time/tests/unit/c/test-time-spec_nanosecond.c index 25dc01f..62b2333 100644 --- a/level_0/f_time/tests/unit/c/test-time-spec_nanosecond.c +++ b/level_0/f_time/tests/unit/c/test-time-spec_nanosecond.c @@ -17,7 +17,7 @@ void test__f_time_spec_nanosecond__number_overflow(void **state) { second = (f_number_unsigned_t) ((time_t) (-1)); } - struct timespec time = { 0 }; + f_time_spec_t time = { 0 }; { const f_status_t status = f_time_spec_nanosecond(second, 1000000000, &time); @@ -34,7 +34,7 @@ void test__f_time_spec_nanosecond__number_overflow(void **state) { void test__f_time_spec_nanosecond__number_underflow(void **state) { - struct timespec time = { .tv_sec = -1, .tv_nsec = -1 }; + f_time_spec_t time = { .tv_sec = -1, .tv_nsec = -1 }; // If this system has uses unsigned, then this test is not needed. if (time.tv_sec >= 0 && time.tv_nsec >= 0) return; @@ -77,7 +77,7 @@ void test__f_time_spec_nanosecond__parameter_checking(void **state) { void test__f_time_spec_nanosecond__works(void **state) { - struct timespec time = { 0 }; + f_time_spec_t time = { 0 }; { const f_number_unsigned_t seconds[] = { diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index bdd7464..ba4ee3a 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include // FLL-0 type includes. diff --git a/level_0/f_type/c/type/time.h b/level_0/f_type/c/type/time.h index 0d91f1e..a0938d5 100644 --- a/level_0/f_type/c/type/time.h +++ b/level_0/f_type/c/type/time.h @@ -44,9 +44,39 @@ extern "C" { typedef uint64_t f_time_t; #define f_time_t_initialize 0 + + #define macro_f_time_t_clear(time) \ + time = 0; #endif // _di_f_time_t_ /** + * A typedef representing struct tm. + */ +#ifndef _di_f_time_part_t_ + typedef struct tm f_time_part_t; + + #define f_time_part_t_initialize { 0 } +#endif // _di_f_time_part_t_ + +/** + * A typedef representing struct timespec. + */ +#ifndef _di_f_time_spec_t_ + typedef struct timespec f_time_spec_t; + + #define f_time_spec_t_initialize { 0 } +#endif // _di_f_time_spec_t_ + +/** + * A typedef representing struct timeval. + */ +#ifndef _di_f_time_value_t_ + typedef struct timeval f_time_value_t; + + #define f_time_value_t_initialize { 0 } +#endif // _di_f_time_value_t_ + +/** * A non-kernel dependent alternative version of "struct timespec". * * This is may not compatible with struct timespec because seconds is time_t and that may not be a uint64_t. @@ -56,18 +86,18 @@ extern "C" { * - seconds: The total number of seconds. * - seconds_nano: The total number of nanoseconds. */ -#ifndef _di_f_time_spec_t_ +#ifndef _di_f_time_simple_t_ typedef struct { f_time_t seconds; f_time_t seconds_nano; - } f_time_spec_t; + } f_time_simple_t; - #define f_time_spec_t_initialize { f_time_t_initialize, f_time_t_initialize } + #define f_time_simple_t_initialize { f_time_t_initialize, f_time_t_initialize } - #define macro_f_time_spec_t_clear(spec) \ - spec.seconds = 0; \ - spec.seconds_nano = 0; -#endif // _di_f_time_spec_t_ + #define macro_f_time_simple_t_clear(simple) \ + macro_f_time_t_clear(simple.seconds); \ + macro_f_time_t_clear(simple.seconds_nano); +#endif // _di_f_time_simple_t_ /** * Hold a unit of Time along with a year to represent a date. @@ -92,36 +122,36 @@ extern "C" { f_time_t time; } f_date_t; - #define f_date_t_initialize { 0, 0 } + #define f_date_t_initialize { f_time_t_initialize, f_time_t_initialize } #define macro_f_date_t_clear(date) \ date.year = 0; \ - date.time = 0; + macro_f_time_t_clear(date.time); #endif // _di_f_date_t_ /** - * A variation of f_date_t that using f_time_spec_t rather than f_time_t. + * A variation of f_date_t that using f_time_simple_t rather than f_time_t. * * This can is a more precise alternative to f_date_t because it stores nanoseconds. * - * The f_time_spec_t.time.seconds can be directly cast to the f_date_t.time. + * The f_time_simple_t.time.seconds can be directly cast to the f_date_t.time. * * Properties: * - year: A number representing the year. * - time: A number representing the time with seconds and nanoseconds. */ -#ifndef _di_f_date_spec_t_ +#ifndef _di_f_date_simple_t_ typedef struct { f_time_t year; - f_time_spec_t time; - } f_date_spec_t; + f_time_simple_t time; + } f_date_simple_t; - #define f_date_spec_t_initialize { f_time_t_initialize, macro_f_time_spec_t_clear } + #define f_date_simple_t_initialize { f_time_t_initialize, macro_f_time_simple_t_clear } - #define macro_f_date_spec_t_clear(date) \ - date.year = 0; \ - macro_f_time_spec_t_clear(date.time); -#endif // _di_f_date_spec_t_ + #define macro_f_date_simple_t_clear(date) \ + macro_f_time_t_clear(date.year); \ + macro_f_time_simple_t_clear(date.time); +#endif // _di_f_date_simple_t_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/controller/c/common.h b/level_3/controller/c/common.h index 85c04c5..429380f 100644 --- a/level_3/controller/c/common.h +++ b/level_3/controller/c/common.h @@ -1190,7 +1190,7 @@ extern "C" { uid_t user; gid_t group; - f_time_spec_t timestamp; + f_time_simple_t timestamp; f_string_dynamic_t alias; f_string_dynamic_t engine; @@ -1239,7 +1239,7 @@ extern "C" { 0, \ 0, \ 0, \ - f_time_spec_t_initialize, \ + f_time_simple_t_initialize, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ diff --git a/level_3/controller/c/common/private-cache.h b/level_3/controller/c/common/private-cache.h index c84da0c..7ad3118 100644 --- a/level_3/controller/c/common/private-cache.h +++ b/level_3/controller/c/common/private-cache.h @@ -74,7 +74,7 @@ extern "C" { */ #ifndef _di_controller_cache_t_ typedef struct { - f_time_spec_t timestamp; + f_time_simple_t timestamp; f_range_t range_action; @@ -100,7 +100,7 @@ extern "C" { } controller_cache_t; #define controller_cache_t_initialize { \ - f_time_spec_t_initialize, \ + f_time_simple_t_initialize, \ f_range_t_initialize, \ f_number_unsigneds_t_initialize, \ f_number_unsigneds_t_initialize, \ diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index d678939..8caa676 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -39,7 +39,7 @@ extern "C" { cache->action.name_file.used = 0; cache->buffer_file.used = 0; - macro_f_time_spec_t_clear(cache->timestamp); + macro_f_time_simple_t_clear(cache->timestamp); status = f_string_dynamic_append(path_prefix, &cache->action.name_file); @@ -712,7 +712,7 @@ extern "C" { #endif // _di_controller_status_simplify_error_ #ifndef _di_controller_time_ - void controller_time(const time_t seconds, const long nanoseconds, struct timespec *time) { + void controller_time(const time_t seconds, const long nanoseconds, f_time_spec_t *time) { struct timeval now; @@ -731,10 +731,10 @@ extern "C" { #endif // _di_controller_time_ #ifndef _di_controller_time_milliseconds_ - struct timespec controller_time_milliseconds(const f_number_unsigned_t milliseconds) { + f_time_spec_t controller_time_milliseconds(const f_number_unsigned_t milliseconds) { // @todo update all of these type of functions to use the newer f_time_spec_milliseconds() and f_time_spec_nanoseconds() as appropriate. - struct timespec time; + f_time_spec_t time; time.tv_sec = milliseconds > 1000 ? milliseconds / 1000 : 0; time.tv_nsec = (time.tv_sec ? milliseconds - time.tv_sec : milliseconds) * 1000; @@ -743,9 +743,9 @@ extern "C" { #endif // _di_controller_time_milliseconds_ #ifndef _di_controller_time_seconds_ - struct timespec controller_time_seconds(const f_number_unsigned_t seconds) { + f_time_spec_t controller_time_seconds(const f_number_unsigned_t seconds) { - struct timespec time; + f_time_spec_t time; time.tv_sec = seconds; time.tv_nsec = 0; @@ -754,7 +754,7 @@ extern "C" { #endif // _di_controller_time_seconds_ #ifndef _di_controller_time_sleep_nanoseconds_ - int controller_time_sleep_nanoseconds(controller_main_t * const main, controller_process_t * const setting, struct timespec time) { + int controller_time_sleep_nanoseconds(controller_main_t * const main, controller_process_t * const setting, f_time_spec_t time) { // When sleep is a second or more, instead wait for terminating signals if interruptible. if ((setting->flag & controller_setting_flag_interruptible_e) && time.tv_sec) { diff --git a/level_3/controller/c/controller/private-controller.h b/level_3/controller/c/controller/private-controller.h index 7b05b6d..39b7f92 100644 --- a/level_3/controller/c/controller/private-controller.h +++ b/level_3/controller/c/controller/private-controller.h @@ -307,7 +307,7 @@ extern "C" { * Get the current time, plus the given offset. * * @todo this is basic enough that there needs to be an f_time class with this function f_time_now(), f_time_future(), f_time_past(). - * "struct timespec" -> f_time_nano_t, "struct timeval" -> f_time_micro_t. + * "f_time_spec_t" -> f_time_nano_t, "struct timeval" -> f_time_micro_t. * * @param seconds * The seconds to add to current time. @@ -317,7 +317,7 @@ extern "C" { * The resulting current time. */ #ifndef _di_controller_time_ - void controller_time(const time_t seconds, const long nanoseconds, struct timespec *time) F_attribute_visibility_internal_d; + void controller_time(const time_t seconds, const long nanoseconds, f_time_spec_t *time) F_attribute_visibility_internal_d; #endif // _di_controller_time_ /** @@ -332,7 +332,7 @@ extern "C" { * @see nanosleep() */ #ifndef _di_controller_time_milliseconds_ - extern struct timespec controller_time_milliseconds(const f_number_unsigned_t milliseconds) F_attribute_visibility_internal_d; + extern f_time_spec_t controller_time_milliseconds(const f_number_unsigned_t milliseconds) F_attribute_visibility_internal_d; #endif // _di_controller_time_milliseconds_ /** @@ -347,7 +347,7 @@ extern "C" { * @see nanosleep() */ #ifndef _di_controller_time_seconds_ - extern struct timespec controller_time_seconds(const f_number_unsigned_t seconds) F_attribute_visibility_internal_d; + extern f_time_spec_t controller_time_seconds(const f_number_unsigned_t seconds) F_attribute_visibility_internal_d; #endif // _di_controller_time_seconds_ /** @@ -366,7 +366,7 @@ extern "C" { * @see nanosleep() */ #ifndef _di_controller_time_sleep_nanoseconds_ - extern int controller_time_sleep_nanoseconds(controller_main_t * const main, controller_process_t * const setting, struct timespec time) F_attribute_visibility_internal_d; + extern int controller_time_sleep_nanoseconds(controller_main_t * const main, controller_process_t * const setting, f_time_spec_t time) F_attribute_visibility_internal_d; #endif // _di_controller_time_sleep_nanoseconds_ /** diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index 7774e08..7ba6837 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -1529,7 +1529,7 @@ extern "C" { cache->action.line_action = 0; cache->action.line_item = 0; - macro_f_time_spec_t_clear(cache->timestamp); + macro_f_time_simple_t_clear(cache->timestamp); cache->comments.used = 0; cache->delimits.used = 0; diff --git a/level_3/controller/c/lock/private-lock.c b/level_3/controller/c/lock/private-lock.c index 2b99768..6483462 100644 --- a/level_3/controller/c/lock/private-lock.c +++ b/level_3/controller/c/lock/private-lock.c @@ -39,7 +39,7 @@ extern "C" { #ifndef _di_controller_lock_read_ f_status_t controller_lock_read(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t *lock) { - struct timespec time; + f_time_spec_t time; f_status_t status = F_okay; @@ -80,7 +80,7 @@ extern "C" { #ifndef _di_controller_lock_write_ f_status_t controller_lock_write(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t *lock) { - struct timespec time; + f_time_spec_t time; f_status_t status = F_okay; diff --git a/level_3/controller/c/process/private-process.c b/level_3/controller/c/process/private-process.c index 9c8cc28..fefbbc3 100644 --- a/level_3/controller/c/process/private-process.c +++ b/level_3/controller/c/process/private-process.c @@ -107,7 +107,7 @@ extern "C" { return F_status_set_error(F_interrupt); } - struct timespec time; + f_time_spec_t time; f_status_t status = F_okay; f_status_t status_lock = F_okay; diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 84c4315..ca5b169 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -1459,7 +1459,7 @@ extern "C" { // Sleep for less than a second to better show simulation of synchronous vs asynchronous. { - const struct timespec delay = controller_time_milliseconds(controller_thread_simulation_timeout_d); + const f_time_spec_t delay = controller_time_milliseconds(controller_thread_simulation_timeout_d); if (controller_time_sleep_nanoseconds(main, (controller_process_t *) process->main_setting, delay) == -1) { status = F_status_set_error(F_interrupt); @@ -1715,7 +1715,7 @@ extern "C" { // Sleep for less than a second to better show simulation of synchronous vs asynchronous. { - const struct timespec delay = controller_time_milliseconds(controller_thread_simulation_timeout_d); + const f_time_spec_t delay = controller_time_milliseconds(controller_thread_simulation_timeout_d); if (controller_time_sleep_nanoseconds(main, (controller_process_t *) process->main_setting, delay) == -1) { status = F_status_set_error(F_interrupt); @@ -1898,7 +1898,7 @@ extern "C" { } if (rerun_item->delay) { - const struct timespec delay = controller_time_milliseconds(rerun_item->delay); + const f_time_spec_t delay = controller_time_milliseconds(rerun_item->delay); if (controller_time_sleep_nanoseconds(main, (controller_process_t *) process->main_setting, delay) == -1) { return -1; @@ -3207,7 +3207,7 @@ extern "C" { process->options = options; process->type = type; - macro_f_time_spec_t_clear(process->cache.timestamp) + macro_f_time_simple_t_clear(process->cache.timestamp) macro_f_range_t_clear(process->cache.range_action) process->cache.ats.used = 0; @@ -3628,7 +3628,7 @@ extern "C" { rule->user = 0; rule->nice = 0; - macro_f_time_spec_t_clear(rule->timestamp); + macro_f_time_simple_t_clear(rule->timestamp); rule->alias.used = 0; rule->engine.used = 0; diff --git a/level_3/controller/c/thread/private-thread.c b/level_3/controller/c/thread/private-thread.c index ed0a500..93e6426 100644 --- a/level_3/controller/c/thread/private-thread.c +++ b/level_3/controller/c/thread/private-thread.c @@ -25,7 +25,7 @@ extern "C" { if (global->thread->enabled != controller_thread_enabled_e) return 0; - const struct timespec delay = controller_time_seconds((global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) ? controller_thread_cleanup_interval_short_d : controller_thread_cleanup_interval_long_d); + const f_time_spec_t delay = controller_time_seconds((global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) ? controller_thread_cleanup_interval_short_d : controller_thread_cleanup_interval_long_d); f_status_t status = F_okay; diff --git a/level_3/controller/c/thread/private-thread_entry.c b/level_3/controller/c/thread/private-thread_entry.c index e36d93d..7e686a8 100644 --- a/level_3/controller/c/thread/private-thread_entry.c +++ b/level_3/controller/c/thread/private-thread_entry.c @@ -119,7 +119,7 @@ extern "C" { } if (F_status_is_error_not(*status) && *status != F_child && entry->global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e && entry->global->setting->mode == controller_setting_mode_helper_e) { - struct timespec time; + f_time_spec_t time; time.tv_sec = controller_thread_exit_helper_timeout_seconds_d; time.tv_nsec = controller_thread_exit_helper_timeout_nanoseconds_d; diff --git a/level_3/controller/c/thread/private-thread_process.c b/level_3/controller/c/thread/private-thread_process.c index e93d767..d25da66 100644 --- a/level_3/controller/c/thread/private-thread_process.c +++ b/level_3/controller/c/thread/private-thread_process.c @@ -54,7 +54,7 @@ extern "C" { return; } - struct timespec time; + f_time_spec_t time; controller_entry_t *entry = 0; controller_data_t *process = 0; @@ -376,7 +376,7 @@ extern "C" { } } else { - struct timespec time; + f_time_spec_t time; do { status = f_thread_mutex_lock(&global->thread->lock.alert); diff --git a/level_3/controller/c/thread/private-thread_signal.c b/level_3/controller/c/thread/private-thread_signal.c index c65b1f1..5aaab62 100644 --- a/level_3/controller/c/thread/private-thread_signal.c +++ b/level_3/controller/c/thread/private-thread_signal.c @@ -16,7 +16,7 @@ extern "C" { if (!controller_thread_is_enabled(is_normal, global->thread)) return; siginfo_t information; - struct timespec time; + f_time_spec_t time; int error = 0; while (controller_thread_is_enabled(is_normal, global->thread)) {