From: Kevin Day Date: Fri, 7 May 2021 05:22:33 +0000 (-0500) Subject: Update: Provide defines for disabling less-portable code exposed as a problem when... X-Git-Tag: 0.5.4~39 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=443cd55101167d8acf857fb161933741cbb414f2;p=fll Update: Provide defines for disabling less-portable code exposed as a problem when using musl-libc. The f_thread project utilizes several pthread functions that are non-portable. Add some initial support for disabling these and do disable these by default. I intend to expand upon this and adding more defines. The current ones might be renamed. --- diff --git a/build/level_0/settings b/build/level_0/settings index f990a2b..dc58b90 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -46,7 +46,8 @@ search_shared yes search_static yes #defines_all -D_di_libcap_ -defines_all -D_libcap_legacy_only_ +defines_all -D_libcap_legacy_only +defines_all-level -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_all-level_threadless -D_di_pthread_support_ defines_static defines_shared diff --git a/build/level_1/settings b/build/level_1/settings index 866da87..844dfc1 100644 --- a/build/level_1/settings +++ b/build/level_1/settings @@ -47,6 +47,7 @@ search_static yes #defines_all -D_di_libcap_ defines_all +defines_all-level -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_all-level_threadless -D_di_pthread_support_ defines_static defines_shared diff --git a/build/level_2/settings b/build/level_2/settings index b1e85df..22e1147 100644 --- a/build/level_2/settings +++ b/build/level_2/settings @@ -47,6 +47,7 @@ search_static yes #defines_all -D_di_libcap_ defines_all -D_libcap_legacy_only_ +defines_all-level -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_all-level_threadless -D_di_pthread_support_ defines_static defines_shared diff --git a/build/monolithic/settings b/build/monolithic/settings index 7ef4732..645ef84 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -47,6 +47,7 @@ search_static yes #defines_all -D_di_libcap_ defines_all -D_libcap_legacy_only_ +defines_all-monolithic -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_all-monolithic_threadless -D_di_pthread_support_ defines_static defines_shared diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index 1393298..c12e634 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -25,7 +25,15 @@ extern "C" { } #endif // _di_f_thread_key_create_ -#ifndef _di_f_thread_attribute_affinity_get_ +#if defined(_pthread_attr_unsupported_) && !defined(_di_f_thread_attribute_affinity_get_) + f_status_t f_thread_attribute_affinity_get(const f_thread_attribute_t attribute, const size_t affinity_size, cpu_set_t *affinity_set) { + #ifndef _di_level_0_parameter_checking_ + if (!affinity_set) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return F_status_set_error(F_implemented_not); + } +#elif !defined(_di_f_thread_attribute_affinity_get_) f_status_t f_thread_attribute_affinity_get(const f_thread_attribute_t attribute, const size_t affinity_size, cpu_set_t *affinity_set) { #ifndef _di_level_0_parameter_checking_ if (!affinity_set) return F_status_set_error(F_parameter); @@ -41,9 +49,17 @@ extern "C" { return F_none; } -#endif // _di_f_thread_attribute_affinity_get_ +#endif // defined(_pthread_attr_unsupported_) && !defined(_di_f_thread_attribute_affinity_get_) -#ifndef _di_f_thread_attribute_affinity_set_ +#if defined(_pthread_attr_unsupported_) && !defined(_di_f_thread_attribute_affinity_set_) + f_status_t f_thread_attribute_affinity_set(const size_t affinity_size, const cpu_set_t *affinity_set, f_thread_attribute_t *attribute) { + #ifndef _di_level_0_parameter_checking_ + if (!attribute) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return F_status_set_error(F_implemented_not); + } +#elif !defined(_di_f_thread_attribute_affinity_set_) f_status_t f_thread_attribute_affinity_set(const size_t affinity_size, const cpu_set_t *affinity_set, f_thread_attribute_t *attribute) { #ifndef _di_level_0_parameter_checking_ if (!attribute) return F_status_set_error(F_parameter); @@ -60,7 +76,7 @@ extern "C" { return F_none; } -#endif // _di_f_thread_attribute_affinity_set_ +#endif // defined(_pthread_attr_unsupported_) && !defined(_di_f_thread_attribute_affinity_set_) #ifndef _di_f_thread_attribute_clock_get_ f_status_t f_thread_attribute_clock_get(const f_thread_condition_attribute_t *attribute, clockid_t *id) { @@ -2978,7 +2994,12 @@ extern "C" { } #endif // _di_f_thread_signal_mask_ -#ifndef _di_f_thread_signal_queue_ +#if defined(_pthread_sigqueue_unsupported_) && !defined(_di_f_thread_signal_queue_) + f_status_t f_thread_signal_queue(const f_thread_id_t id, const int signal, const union sigval value) { + + return F_status_set_error(F_implemented_not); + } +#elif !defined(_di_f_thread_signal_queue_) f_status_t f_thread_signal_queue(const f_thread_id_t id, const int signal, const union sigval value) { const int error = pthread_sigqueue(id, signal, value); @@ -2994,7 +3015,7 @@ extern "C" { return F_none; } -#endif // _di_f_thread_signal_queue_ +#endif // defined(_pthread_sigqueue_unsupported_) && !defined(_di_f_thread_signal_queue_) #ifndef _di_f_thread_spin_create_ f_status_t f_thread_spin_create(const int shared, f_thread_spin_t *spin) { diff --git a/level_0/f_thread/data/build/defines b/level_0/f_thread/data/build/defines index aa6477b..bd9bb11 100644 --- a/level_0/f_thread/data/build/defines +++ b/level_0/f_thread/data/build/defines @@ -1,2 +1,5 @@ # fss-0000 + _di_pthread_support_ disables thread support, which is intended to disable this entire f_thread project. This is not directly used by this library, but is instead used by other libraries to not include f_thread (such as special compilations like monolithic). Future versions may potentially support this, providing stubs. +_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. +_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_0/f_thread/data/build/settings b/level_0/f_thread/data/build/settings index 5d1fcb9..374681d 100644 --- a/level_0/f_thread/data/build/settings +++ b/level_0/f_thread/data/build/settings @@ -44,7 +44,7 @@ search_exclusive yes search_shared yes search_static yes -defines_all +defines_all -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_static defines_shared diff --git a/level_2/fll_execute/data/build/defines b/level_2/fll_execute/data/build/defines index 8a7625a..6a045ca 100644 --- a/level_2/fll_execute/data/build/defines +++ b/level_2/fll_execute/data/build/defines @@ -1,3 +1,6 @@ # fss-0000 + _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). _di_pthread_support_ Disable support for compiling and depending on pthreads (and projects like f_thread). +_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. +_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_2/fll_execute/data/build/settings b/level_2/fll_execute/data/build/settings index 52d5c46..6727fff 100644 --- a/level_2/fll_execute/data/build/settings +++ b/level_2/fll_execute/data/build/settings @@ -46,7 +46,7 @@ search_shared yes search_static yes #defines_all -D_di_libcap_ -defines_all -D_libcap_legacy_only_ +defines_all -D_libcap_legacy_only_ -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_all-individual_threadless -D_di_pthread_support_ defines_static defines_shared diff --git a/level_3/controller/data/build/defines b/level_3/controller/data/build/defines index 0aedddb..427a9c7 100644 --- a/level_3/controller/data/build/defines +++ b/level_3/controller/data/build/defines @@ -2,3 +2,5 @@ _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). +_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. +_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/controller/data/build/settings b/level_3/controller/data/build/settings index c55c3ff..9d3edd8 100644 --- a/level_3/controller/data/build/settings +++ b/level_3/controller/data/build/settings @@ -47,7 +47,7 @@ search_shared yes search_static yes #defines_all -D_di_libcap_ -D_di_thread_support_ -defines_all -D_libcap_legacy_only_ +defines_all -D_libcap_legacy_only_ -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_static defines_shared diff --git a/level_3/fake/data/build/defines b/level_3/fake/data/build/defines index 0aedddb..427a9c7 100644 --- a/level_3/fake/data/build/defines +++ b/level_3/fake/data/build/defines @@ -2,3 +2,5 @@ _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). +_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. +_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/fake/data/build/settings b/level_3/fake/data/build/settings index ad18614..4d9529e 100644 --- a/level_3/fake/data/build/settings +++ b/level_3/fake/data/build/settings @@ -47,7 +47,7 @@ search_shared yes search_static yes #defines_all -D_di_libcap_ -D_di_thread_support_ -defines_all -D_libcap_legacy_only_ +defines_all -D_libcap_legacy_only_ -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_static defines_shared diff --git a/level_3/firewall/data/build/defines b/level_3/firewall/data/build/defines index 0aedddb..427a9c7 100644 --- a/level_3/firewall/data/build/defines +++ b/level_3/firewall/data/build/defines @@ -2,3 +2,5 @@ _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). +_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. +_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/firewall/data/build/settings b/level_3/firewall/data/build/settings index 001a232..63320d7 100644 --- a/level_3/firewall/data/build/settings +++ b/level_3/firewall/data/build/settings @@ -47,7 +47,7 @@ search_shared yes search_static yes #defines_all -D_di_libcap_ -D_di_thread_support_ -defines_all -D_libcap_legacy_only_ +defines_all -D_libcap_legacy_only_ -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ defines_static defines_shared