From: n0nb <n0...@us...> - 2025-09-01 14:36:38
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 4c520571dfb13cc04c42120e751d09af6f2ef0e6 (commit) via e09007a543f707cd833bbd1b199a804cb84c3b32 (commit) via 1c0de2107c4061f2cd79958dc4e362a34f03a6c3 (commit) via 002677e48c2d5218254421472cefa6a354f54e84 (commit) via 9a90745ba693767a4c29caaabb406a3feb943982 (commit) via df65ceee67bc11d6f6daba9bce3142ef55a082c5 (commit) via 9f4755cf70e0a556bff61f433dbaab5e6e20f269 (commit) from 9123d08a6c95a59214a01da6551fd9c887939ce8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4c520571dfb13cc04c42120e751d09af6f2ef0e6 Merge: 9123d08a6 e09007a54 Author: Nate Bargmann <n0...@n0...> Date: Sun Aug 31 20:11:12 2025 -0500 Merge GitHub PR #1876 commit e09007a543f707cd833bbd1b199a804cb84c3b32 Author: George Baltz N3GB <Geo...@gm...> Date: Sun Aug 31 14:36:55 2025 -0400 Update NEWS diff --git a/NEWS b/NEWS index 7cf1895e1..7eba7f0cd 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ Version 5.x -- future Version 4.7.0 * 2025-12-01 (target) + * POSIX threads are required to build and run Hamlib. Note that it was + actually the case for 4.6.x, but now the configuration step will + fail instead of the compilation. * Functions rig_get_conf, rot_get_conf, amp_get_conf deprecated; use *_get_conf2() instead. * Fix handling of unprintable characters in kenwood.c that broke radios commit 1c0de2107c4061f2cd79958dc4e362a34f03a6c3 Author: George Baltz N3GB <Geo...@gm...> Date: Sat Aug 30 11:29:45 2025 -0400 Remove conditionals based on HAVE_PTHREAD diff --git a/tests/ampctld.c b/tests/ampctld.c index 89baf9c62..3f0bc8284 100644 --- a/tests/ampctld.c +++ b/tests/ampctld.c @@ -54,9 +54,7 @@ # include <netdb.h> #endif -#ifdef HAVE_PTHREAD -# include <pthread.h> -#endif +#include <pthread.h> #include "hamlib/amplifier.h" @@ -168,10 +166,8 @@ int main(int argc, char *argv[]) char host[NI_MAXHOST]; char serv[NI_MAXSERV]; -#ifdef HAVE_PTHREAD pthread_t thread; pthread_attr_t attr; -#endif struct handle_data *arg; #ifdef SIGPIPE #if HAVE_SIGACTION @@ -557,7 +553,6 @@ int main(int argc, char *argv[]) host, serv); -#ifdef HAVE_PTHREAD pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); @@ -569,9 +564,6 @@ int main(int argc, char *argv[]) break; } -#else - handle_socket(arg); -#endif } while (retcode == 0); @@ -676,9 +668,7 @@ handle_exit: #endif free(arg); -#ifdef HAVE_PTHREAD pthread_exit(NULL); -#endif return NULL; } diff --git a/tests/rigctld.c b/tests/rigctld.c index 1f291de61..9935f5520 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -64,9 +64,7 @@ # include <netdb.h> #endif -#ifdef HAVE_PTHREAD -# include <pthread.h> -#endif +#include <pthread.h> #include "hamlib/rig.h" #include "misc.h" @@ -129,9 +127,7 @@ void *handle_socket(void *arg); void usage(void); -#ifdef HAVE_PTHREAD static unsigned client_count; -#endif static RIG *my_rig; /* handle to rig (instance) */ static volatile int rig_opened = 0; @@ -159,7 +155,6 @@ static int bind_all = 0; void mutex_rigctld(int lock) { -#ifdef HAVE_PTHREAD static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER; if (lock) @@ -173,7 +168,6 @@ void mutex_rigctld(int lock) pthread_mutex_unlock(&client_lock); } -#endif } #ifdef WIN32 @@ -273,10 +267,8 @@ int main(int argc, char *argv[]) struct sigaction act; #endif -#ifdef HAVE_PTHREAD pthread_t thread; pthread_attr_t attr; -#endif struct handle_data *arg; int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */ int i; @@ -1070,7 +1062,6 @@ int main(int argc, char *argv[]) host, serv); -#ifdef HAVE_PTHREAD pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); @@ -1082,16 +1073,12 @@ int main(int argc, char *argv[]) break; } -#else - handle_socket(arg); -#endif } } while (!ctrl_c); rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__); -#ifdef HAVE_PTHREAD /* allow threads to finish current action */ mutex_rigctld(1); @@ -1107,9 +1094,6 @@ int main(int argc, char *argv[]) #endif rig_close(my_rig); mutex_rigctld(0); -#else - rig_close(my_rig); /* close port */ -#endif rig_cleanup(my_rig); /* if you care about memory */ @@ -1185,7 +1169,6 @@ void *handle_socket(void *arg) goto handle_exit; } -#ifdef HAVE_PTHREAD mutex_rigctld(1); ++client_count; @@ -1206,19 +1189,6 @@ void *handle_socket(void *arg) #endif mutex_rigctld(0); -#else - mutex_rigctld(1); - retcode = rig_open(my_rig); - mutex_rigctld(0); - - if (RIG_OK == retcode && verbose > RIG_DEBUG_ERR) - { - printf("Opened rig model %d, '%s'\n", - my_rig->caps->rig_model, - my_rig->caps->model_name); - } - -#endif if (my_rig->caps->get_powerstat) { @@ -1314,21 +1284,16 @@ void *handle_socket(void *arg) } while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(retcode))); -#if defined(HAVE_PTHREAD) - + mutex_rigctld(1); if (rigctld_idle && client_count == 1) -#else - if (rigctld_idle) -#endif { rig_close(my_rig); if (verbose > RIG_DEBUG_ERR) { printf("Closed rig model %s. Will reopen for new clients\n", my_rig->caps->model_name); } } - -#ifdef HAVE_PTHREAD --client_count; + mutex_rigctld(0); if (rigctld_idle && client_count > 0) { printf("%u client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); } @@ -1349,17 +1314,6 @@ void *handle_socket(void *arg) } mutex_rigctld(0); -#endif -#else - rig_close(my_rig); - - if (verbose > RIG_DEBUG_ERR) - { - printf("Closed rig model %d, '%s - will reopen for new clients'\n", - my_rig->caps->rig_model, - my_rig->caps->model_name); - } - #endif if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr, @@ -1404,9 +1358,7 @@ handle_exit: free(arg); -#ifdef HAVE_PTHREAD pthread_exit(NULL); -#endif return NULL; } commit 002677e48c2d5218254421472cefa6a354f54e84 Author: George Baltz N3GB <Geo...@gm...> Date: Wed Aug 27 15:12:57 2025 -0400 Still more pthread conditional code cleanup diff --git a/src/microham.c b/src/microham.c index 77ed1ca64..b18c25765 100644 --- a/src/microham.c +++ b/src/microham.c @@ -88,18 +88,12 @@ static int uh_wkey_in_use; static int statusbyte = 0; -#ifdef HAVE_PTHREAD - #include <pthread.h> static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t readthread; #define getlock() if (pthread_mutex_lock(&mutex)) perror("GETLOCK:") #define freelock() if (pthread_mutex_unlock(&mutex)) perror("FREELOCK:") -#else -#define getlock() -#define freelock() -#endif #if defined(HAVE_SELECT) // @@ -108,7 +102,7 @@ static pthread_t readthread; static time_t lastbeat = 0; #endif -#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) +#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) static time_t starttime; #define TIME ((int) (time(NULL) - starttime)) @@ -176,10 +170,8 @@ static void close_microham() TRACE("%10d:Closing MicroHam device\n", TIME); uh_is_initialized = 0; -#ifdef HAVE_PTHREAD // wait for read_device thread to finish pthread_join(readthread, NULL); -#endif close_all_files(); } @@ -717,7 +709,7 @@ static void writeControl(const unsigned char *data, int len) } -#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) +#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) // // send a heartbeat and record time // The "last heartbeat" time is recorded in a global variable @@ -733,7 +725,7 @@ static void heartbeat() writeControl(seq, 2); lastbeat = time(NULL); } -#endif /* defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) */ +#endif /* defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) */ #if defined(HAVE_SELECT) @@ -770,7 +762,7 @@ static void *read_device(void *p) } -#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) +#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) // // This is the right place to ensure that a heartbeat is sent @@ -906,7 +898,7 @@ static void *read_device(void *p) */ static void start_thread() { -#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) +#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) /* * Find a microHam device and open serial port to it. * If successful, create sockets for doing I/O from within hamlib diff --git a/src/misc.h b/src/misc.h index 2e4331e78..25ad442f9 100644 --- a/src/misc.h +++ b/src/misc.h @@ -23,20 +23,15 @@ #ifndef _MISC_H #define _MISC_H 1 -#include "hamlib/rig.h" #include "hamlib/config.h" +#include "hamlib/rig.h" /* */ -#ifdef HAVE_PTHREAD #include <pthread.h> #define set_transaction_active(rig) {pthread_mutex_lock(&STATE(rig)->mutex_set_transaction);STATE(rig)->transaction_active = 1;} #define set_transaction_inactive(rig) {STATE(rig)->transaction_active = 0;pthread_mutex_unlock(&STATE(rig)->mutex_set_transaction);} -#else -#define set_transaction_active(rig) {STATE(rig)->transaction_active = 1;} -#define set_transaction_inactive(rig) {STATE(rig)->transaction_active = 0;} -#endif __BEGIN_DECLS diff --git a/src/settings.c b/src/settings.c index 500708c83..14ca46e7f 100644 --- a/src/settings.c +++ b/src/settings.c @@ -96,7 +96,6 @@ int HAMLIB_API rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) || vfo == RIG_VFO_CURR || vfo == STATE(rig)->current_vfo) { -#if defined(HAVE_PTHREAD) if (level == RIG_LEVEL_KEYSPD) { @@ -104,7 +103,6 @@ int HAMLIB_API rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) morse_data_handler_set_keyspd(rig, val.i); } -#endif retcode = caps->set_level(rig, vfo, level, val); rig_lock(rig, 0); return retcode; diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index 375cee160..005f50db1 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -72,11 +72,9 @@ extern int read_history(); /* Hash table implementation See: http://uthash.sourceforge.net/ */ #include "uthash.h" -#ifdef HAVE_PTHREAD -# include <pthread.h> +#include <pthread.h> static pthread_mutex_t amp_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif #define STR1(S) #S #define STR(S) STR1(S) @@ -1339,9 +1337,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) * mutex locking needed because ampctld is multithreaded * and hamlib is not MT-safe */ -#ifdef HAVE_PTHREAD pthread_mutex_lock(&_mutex); -#endif if (!prompt) { @@ -1389,9 +1385,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) ""); #endif -#ifdef HAVE_PTHREAD pthread_mutex_unlock(&_mutex); -#endif if (retcode == -RIG_EIO) { return retcode; } diff --git a/tests/rigctltcp.c b/tests/rigctltcp.c index 0aef3a708..5e92f8cf9 100644 --- a/tests/rigctltcp.c +++ b/tests/rigctltcp.c @@ -68,9 +68,7 @@ # include <netdb.h> #endif -#ifdef HAVE_PTHREAD -# include <pthread.h> -#endif +#include <pthread.h> #include "hamlib/rig.h" #include "misc.h" @@ -132,10 +130,7 @@ struct handle_data void *handle_socket(void *arg); void usage(void); - -#ifdef HAVE_PTHREAD static unsigned client_count; -#endif static RIG *my_rig; /* handle to rig (instance) */ static volatile int rig_opened = 0; @@ -163,7 +158,6 @@ static int rigctld_idle = void mutex_rigctld(int lock) { -#ifdef HAVE_PTHREAD static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER; if (lock) @@ -177,7 +171,6 @@ void mutex_rigctld(int lock) pthread_mutex_unlock(&client_lock); } -#endif } #ifdef WIN32 @@ -273,10 +266,8 @@ int main(int argc, char *argv[]) struct sigaction act; #endif -#ifdef HAVE_PTHREAD pthread_t thread; pthread_attr_t attr; -#endif struct handle_data *arg; int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */ int i; @@ -980,7 +971,6 @@ int main(int argc, char *argv[]) host, serv); -#ifdef HAVE_PTHREAD pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); @@ -992,16 +982,12 @@ int main(int argc, char *argv[]) break; } -#else - handle_socket(arg); -#endif } } while (!ctrl_c); rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__); -#ifdef HAVE_PTHREAD /* allow threads to finish current action */ mutex_rigctld(1); @@ -1012,9 +998,6 @@ int main(int argc, char *argv[]) rig_close(my_rig); mutex_rigctld(0); -#else - rig_close(my_rig); /* close port */ -#endif network_multicast_publisher_stop(my_rig); @@ -1088,7 +1071,6 @@ void *handle_socket(void *arg) goto handle_exit; } -#ifdef HAVE_PTHREAD mutex_rigctld(1); ++client_count; @@ -1109,19 +1091,6 @@ void *handle_socket(void *arg) #endif mutex_rigctld(0); -#else - mutex_rigctld(1); - retcode = rig_open(my_rig); - mutex_rigctld(1); - - if (RIG_OK == retcode && verbose > RIG_DEBUG_ERR) - { - printf("Opened rig model %d, '%s'\n", - my_rig->caps->rig_model, - my_rig->caps->model_name); - } - -#endif if (my_rig->caps->get_powerstat) { @@ -1316,23 +1285,18 @@ void *handle_socket(void *arg) client_done: -#if defined(HAVE_PTHREAD) - if (rigctld_idle && client_count == 1) -#else - if (rigctld_idle) -#endif { rig_close(my_rig); if (verbose > RIG_DEBUG_ERR) { printf("Closed rig model %s. Will reopen for new clients\n", my_rig->caps->model_name); } } - -#ifdef HAVE_PTHREAD + mutex_rigctld(1); --client_count; if (rigctld_idle && client_count > 0) { printf("%u client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); } + mutex_rigctld(0); #if 0 mutex_rigctld(1); @@ -1351,17 +1315,6 @@ client_done: } mutex_rigctld(0); -#endif -#else - rig_close(my_rig); - - if (verbose > RIG_DEBUG_ERR) - { - printf("Closed rig model %d, '%s - will reopen for new clients'\n", - my_rig->caps->rig_model, - my_rig->caps->model_name); - } - #endif if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr, @@ -1406,9 +1359,7 @@ handle_exit: free(arg); -#ifdef HAVE_PTHREAD pthread_exit(NULL); -#endif return NULL; } diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index bfc3488b7..2b4255890 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -88,11 +88,9 @@ extern int read_history(); /* Hash table implementation See: http://uthash.sourceforge.net/ */ #include "uthash.h" -#ifdef HAVE_PTHREAD -# include <pthread.h> +#include <pthread.h> static pthread_mutex_t rot_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif #define STR1(S) #S #define STR(S) STR1(S) @@ -1413,9 +1411,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char *argv[], * mutex locking needed because rotctld is multithreaded * and hamlib is not MT-safe */ -#ifdef HAVE_PTHREAD pthread_mutex_lock(&rot_mutex); -#endif if (!prompt) { @@ -1467,9 +1463,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char *argv[], ""); #endif -#ifdef HAVE_PTHREAD pthread_mutex_unlock(&rot_mutex); -#endif if (retcode == -RIG_EIO) { return retcode; } diff --git a/tests/rotctld.c b/tests/rotctld.c index 405591bb6..9410620ea 100644 --- a/tests/rotctld.c +++ b/tests/rotctld.c @@ -51,9 +51,7 @@ # include <netdb.h> #endif -#ifdef HAVE_PTHREAD -# include <pthread.h> -#endif +#include <pthread.h> #include "hamlib/rotator.h" @@ -166,10 +164,8 @@ int main(int argc, char *argv[]) char host[NI_MAXHOST]; char serv[NI_MAXSERV]; -#ifdef HAVE_PTHREAD pthread_t thread; pthread_attr_t attr; -#endif struct handle_data *arg; rig_set_debug(verbose); @@ -575,7 +571,6 @@ int main(int argc, char *argv[]) host, serv); -#ifdef HAVE_PTHREAD pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); @@ -587,12 +582,7 @@ int main(int argc, char *argv[]) break; } -#else - handle_socket(arg); - retcode = 1; -#endif } - while (retcode == 0); rot_close(my_rot); /* close port */ @@ -702,9 +692,7 @@ handle_exit: #endif free(arg); -#ifdef HAVE_PTHREAD pthread_exit(NULL); -#endif return NULL; } commit 9a90745ba693767a4c29caaabb406a3feb943982 Author: George Baltz N3GB <Geo...@gm...> Date: Thu Aug 21 04:23:26 2025 -0400 More conditional pthread usage unleashed Anybody know what sync_callback() is supposed to do? Currently unused, very broken, and not even a header comment. diff --git a/rotators/ars/ars.c b/rotators/ars/ars.c index 795aa0f53..2b51609a4 100644 --- a/rotators/ars/ars.c +++ b/rotators/ars/ars.c @@ -27,9 +27,7 @@ #include <sys/ioctl.h> #endif -#ifdef HAVE_PTHREAD #include <pthread.h> -#endif #include "hamlib/rotator.h" #include "hamlib/rot_state.h" @@ -84,9 +82,7 @@ static int ars_set_position_sync(ROT *rot, azimuth_t az, elevation_t el); static int ars_set_position(ROT *rot, azimuth_t az, elevation_t el); static int ars_get_position(ROT *rot, azimuth_t *az, elevation_t *el); -#ifdef HAVE_PTHREAD static void *handle_set_position(void *); -#endif /* ************************************************************************* */ @@ -193,7 +189,6 @@ ars_open(ROT *rot) /* make it idle, and known state */ ars_stop(rot); -#ifdef HAVE_PTHREAD { struct ars_priv_data *priv = (struct ars_priv_data *)ROTSTATE(rot)->priv; pthread_attr_t attr; @@ -212,7 +207,6 @@ ars_open(ROT *rot) return -RIG_ENOMEM; } } -#endif return RIG_OK; } @@ -220,11 +214,9 @@ ars_open(ROT *rot) int ars_close(ROT *rot) { -#ifdef HAVE_PTHREAD struct ars_priv_data *priv = (struct ars_priv_data *)ROTSTATE(rot)->priv; pthread_cancel(priv->thread); -#endif /* leave it in safe state */ ars_stop(rot); @@ -241,9 +233,7 @@ ars_stop(ROT *rot) rig_debug(RIG_DEBUG_TRACE, "%s called, brake was %s\n", __func__, priv->brake_off ? "OFF" : "ON"); -#ifdef HAVE_PTHREAD priv->set_pos_active = 0; -#endif par_lock(pport); @@ -422,7 +412,6 @@ static int angle_in_range(float angle, float angle_base, float range) /* * Thread handler */ -#ifdef HAVE_PTHREAD static void *handle_set_position(void *arg) { ROT *rot = (ROT *) arg; @@ -453,7 +442,6 @@ static void *handle_set_position(void *arg) return NULL; } -#endif /* * ars_set_position_sync() is synchronous. @@ -583,7 +571,6 @@ ars_set_position_sync(ROT *rot, azimuth_t az, elevation_t el) int ars_set_position(ROT *rot, azimuth_t az, elevation_t el) { -#ifdef HAVE_PTHREAD struct ars_priv_data *priv = (struct ars_priv_data *)ROTSTATE(rot)->priv; /* will be picked by handle_set_position() next polling tick */ @@ -592,9 +579,6 @@ ars_set_position(ROT *rot, azimuth_t az, elevation_t el) priv->set_pos_active = 1; return RIG_OK; -#else - return ars_set_position_sync(rot, az, el); -#endif } static int comparunsigned(const void *a, const void *b) diff --git a/rotators/ars/ars.h b/rotators/ars/ars.h index c85c3796e..b463f84b1 100644 --- a/rotators/ars/ars.h +++ b/rotators/ars/ars.h @@ -30,12 +30,10 @@ struct ars_priv_data { int curr_move; unsigned char pp_control; unsigned char pp_data; -#ifdef HAVE_PTHREAD pthread_t thread; int set_pos_active; azimuth_t target_az; elevation_t target_el; -#endif }; extern const struct rot_caps rci_az_rot_caps; diff --git a/src/event.c b/src/event.c index ad3ed7789..78c5b9624 100644 --- a/src/event.c +++ b/src/event.c @@ -39,9 +39,7 @@ #include <stdio.h> #include <errno.h> -#ifdef HAVE_PTHREAD -# include <pthread.h> -#endif +#include <pthread.h> #include "hamlib/rig.h" #include "hamlib/rig_state.h" @@ -52,7 +50,6 @@ #define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !STATE(r)->comm_state) -#ifdef HAVE_PTHREAD typedef struct rig_poll_routine_args_s { RIG *rig; @@ -362,8 +359,6 @@ int rig_poll_routine_stop(RIG *rig) RETURNFUNC(RIG_OK); } -#endif - /** * \brief set the callback for freq events * \param rig The rig handle @@ -609,7 +604,6 @@ int HAMLIB_API rig_get_trn(RIG *rig, int *trn) RETURNFUNC(-RIG_EDEPRECATED); } -#if defined(HAVE_PTHREAD) int rig_fire_freq_event(RIG *rig, vfo_t vfo, freq_t freq) { ENTERFUNC; @@ -648,9 +642,7 @@ int rig_fire_freq_event(RIG *rig, vfo_t vfo, freq_t freq) RETURNFUNC(0); } -#endif -#if defined(HAVE_PTHREAD) int rig_fire_mode_event(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { ENTERFUNC; @@ -676,10 +668,8 @@ int rig_fire_mode_event(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) RETURNFUNC(0); } -#endif -#if defined(HAVE_PTHREAD) int rig_fire_vfo_event(RIG *rig, vfo_t vfo) { struct rig_cache *cachep = CACHE(rig); @@ -699,10 +689,8 @@ int rig_fire_vfo_event(RIG *rig, vfo_t vfo) RETURNFUNC(0); } -#endif -#if defined(HAVE_PTHREAD) int rig_fire_ptt_event(RIG *rig, vfo_t vfo, ptt_t ptt) { struct rig_cache *cachep = CACHE(rig); @@ -723,10 +711,8 @@ int rig_fire_ptt_event(RIG *rig, vfo_t vfo, ptt_t ptt) RETURNFUNC(0); } -#endif -#if defined(HAVE_PTHREAD) int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd) { ENTERFUNC; @@ -743,10 +729,8 @@ int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd) RETURNFUNC(0); } -#endif -#if defined(HAVE_PTHREAD) int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width) { @@ -764,10 +748,8 @@ int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, RETURNFUNC(RIG_OK); } -#endif -#if defined(HAVE_PTHREAD) static int print_spectrum_line(char *str, size_t length, struct rig_spectrum_line *line) { @@ -825,10 +807,8 @@ static int print_spectrum_line(char *str, size_t length, return c; } -#endif -#if defined(HAVE_PTHREAD) int rig_fire_spectrum_event(RIG *rig, struct rig_spectrum_line *line) { ENTERFUNC; @@ -850,6 +830,5 @@ int rig_fire_spectrum_event(RIG *rig, struct rig_spectrum_line *line) RETURNFUNC(RIG_OK); } -#endif /** @} */ diff --git a/src/mutex.h b/src/mutex.h index a872231b4..f11d79913 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -1,18 +1,9 @@ #include "hamlib/config.h" -#if defined(HAVE_PTHREAD) #include <pthread.h> -#endif -#ifdef HAVE_PTHREAD #define MUTEX(var) static pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER #define MUTEX_LOCK(var) pthread_mutex_lock(&var) #define MUTEX_UNLOCK(var) pthread_mutex_unlock(&var) -#else -#warning NOT PTHREAD -#define MUTEX(var) -#define MUTEX_LOCK(var) -#define MUTEX_UNLOCK(var) -#endif extern int MUTEX_CHECK(pthread_mutex_t *m); diff --git a/src/network.c b/src/network.c index 848a45eae..958075b3d 100644 --- a/src/network.c +++ b/src/network.c @@ -125,9 +125,7 @@ typedef struct multicast_publisher_args_s int data_read_fd; #endif -#ifdef HAVE_PTHREAD pthread_mutex_t write_lock; -#endif } multicast_publisher_args; typedef struct multicast_publisher_priv_data_s @@ -511,9 +509,9 @@ int network_close(hamlib_port_t *rp) } //! @endcond -extern void sync_callback(int lock); +//TODO See defn in rig.c +//extern void sync_callback(int lock); -#ifdef HAVE_PTHREAD //! @cond Doxygen_Suppress #define MULTICAST_DATA_PIPE_TIMEOUT_MILLIS 1000 @@ -1953,5 +1951,4 @@ int network_multicast_receiver_stop(RIG *rig) RETURNFUNC(RIG_OK); } -#endif /** @} */ diff --git a/src/rig.c b/src/rig.c index 4807011db..f40846fe4 100644 --- a/src/rig.c +++ b/src/rig.c @@ -192,7 +192,6 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */ MUTEX(morse_mutex); -#ifdef HAVE_PTHREAD // returns true if mutex is busy int MUTEX_CHECK(pthread_mutex_t *m) { @@ -205,9 +204,6 @@ int MUTEX_CHECK(pthread_mutex_t *m) return trylock == EBUSY; } -#else -#define MUTEX_CHECK(var) 0 -#endif /* @@ -255,7 +251,6 @@ static const char *const rigerror_table[] = #define ERROR_TBL_SZ (sizeof(rigerror_table)/sizeof(char *)) -#if defined(HAVE_PTHREAD) typedef struct async_data_handler_args_s { RIG *rig; @@ -270,9 +265,7 @@ typedef struct async_data_handler_priv_data_s static int async_data_handler_start(RIG *rig); static int async_data_handler_stop(RIG *rig); static void *async_data_handler(void *arg); -#endif -#if defined(HAVE_PTHREAD) typedef struct morse_data_handler_args_s { RIG *rig; @@ -290,7 +283,6 @@ static int morse_data_handler_start(RIG *rig); static int morse_data_handler_stop(RIG *rig); int morse_data_handler_set_keyspd(RIG *rig, int keyspd); static void *morse_data_handler(void *arg); -#endif /* * track which rig is opened (with rig_open) @@ -642,9 +634,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) * TODO: read the Preferences here! */ rs = STATE(rig); -#if defined(HAVE_PTHREAD) pthread_mutex_init(&rs->mutex_set_transaction, NULL); -#endif //TODO Allocate and link ports // For now, use the embedded ones @@ -681,9 +671,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) rs->comm_state); #endif rp->type.rig = caps->port_type; /* default from caps */ -#if defined(HAVE_PTHREAD) rp->asyncio = 0; -#endif switch (caps->port_type) { @@ -1548,8 +1536,6 @@ int HAMLIB_API rig_open(RIG *rig) if (skip_init) { RETURNFUNC2(RIG_OK); } -#if defined(HAVE_PTHREAD) - status = async_data_handler_start(rig); if (status < 0) @@ -1573,8 +1559,6 @@ int HAMLIB_API rig_open(RIG *rig) } } -#endif - if (rs->auto_disable_screensaver) { // try to turn off the screensaver if possible @@ -1646,7 +1630,6 @@ int HAMLIB_API rig_open(RIG *rig) rig_flush_force(rp, 1); rs->timeout = timesave; -#if defined(HAVE_PTHREAD) enum multicast_item_e items = RIG_MULTICAST_POLL | RIG_MULTICAST_TRANSCEIVE | RIG_MULTICAST_SPECTRUM; retval = network_multicast_publisher_start(rig, rs->multicast_data_addr, @@ -1680,8 +1663,6 @@ int HAMLIB_API rig_open(RIG *rig) // we will consider this non-fatal for now } -#endif - rs->comm_status = RIG_COMM_STATUS_OK; add_opened_rig(rig); @@ -1733,8 +1714,6 @@ int HAMLIB_API rig_close(RIG *rig) rs->comm_status = RIG_COMM_STATUS_DISCONNECTED; -#if defined(HAVE_PTHREAD) - if (!skip_init) { morse_data_handler_stop(rig); @@ -1744,8 +1723,6 @@ int HAMLIB_API rig_close(RIG *rig) network_multicast_publisher_stop(rig); } -#endif - // Let the backend say 73 to the rig. // and ignore the return code. if (caps->rig_close) @@ -8395,13 +8372,12 @@ int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie, return ret; } -#if defined(HAVE_PTHREAD) +//TODO FIX THIS!!!! (presently unused) +#if 0 static pthread_mutex_t initializer = PTHREAD_MUTEX_INITIALIZER; -#endif HAMLIB_EXPORT(void) sync_callback(int lock) { -#if defined(HAVE_PTHREAD) pthread_mutex_t client_lock = initializer; if (lock) @@ -8415,12 +8391,11 @@ HAMLIB_EXPORT(void) sync_callback(int lock) pthread_mutex_unlock(&client_lock); } -#endif } +#endif void rig_lock(RIG *rig, int lock) { -#if defined(HAVE_PTHREAD) struct rig_state *rs = STATE(rig); @@ -8435,8 +8410,6 @@ void rig_lock(RIG *rig, int lock) pthread_mutex_unlock(&rs->api_mutex); } -#endif - } @@ -8445,7 +8418,6 @@ void rig_lock(RIG *rig, int lock) #define MAX_FRAME_LENGTH 1024 -#if defined(HAVE_PTHREAD) static int async_data_handler_start(RIG *rig) { struct rig_state *rs = STATE(rig); @@ -8487,9 +8459,7 @@ static int async_data_handler_start(RIG *rig) RETURNFUNC(RIG_OK); } -#endif -#if defined(HAVE_PTHREAD) static int morse_data_handler_start(RIG *rig) { struct rig_state *rs = STATE(rig); @@ -8527,10 +8497,8 @@ static int morse_data_handler_start(RIG *rig) RETURNFUNC(RIG_OK); } -#endif -#if defined(HAVE_PTHREAD) static int async_data_handler_stop(RIG *rig) { struct rig_state *rs = STATE(rig); @@ -8569,9 +8537,7 @@ static int async_data_handler_stop(RIG *rig) RETURNFUNC(RIG_OK); } -#endif -#if defined(HAVE_PTHREAD) static int morse_data_handler_stop(RIG *rig) { struct rig_state *rs = STATE(rig); @@ -8625,9 +8591,7 @@ static int morse_data_handler_stop(RIG *rig) RETURNFUNC(RIG_OK); } -#endif -#if defined(HAVE_PTHREAD) static void *async_data_handler(void *arg) { struct async_data_handler_args_s *args = (struct async_data_handler_args_s *) @@ -8721,9 +8685,7 @@ again: pthread_exit(NULL); return NULL; } -#endif -#if defined(HAVE_PTHREAD) static void *morse_data_handler(void *arg) { struct morse_data_handler_args_s *args = @@ -8866,7 +8828,6 @@ static void *morse_data_handler(void *arg) pthread_exit(NULL); return NULL; } -#endif HAMLIB_EXPORT(int) rig_password(RIG *rig, const char *key1) @@ -9065,7 +9026,6 @@ HAMLIB_EXPORT(int) rig_is_model(RIG *rig, rig_model_t model) } -#if defined(HAVE_PTHREAD) int morse_data_handler_set_keyspd(RIG *rig, int keyspd) { struct rig_state *rs = STATE(rig); @@ -9075,7 +9035,6 @@ int morse_data_handler_set_keyspd(RIG *rig, int keyspd) rig_debug(RIG_DEBUG_VERBOSE, "%s: keyspd=%d\n", __func__, keyspd); return RIG_OK; } -#endif /** * \brief Get the address of a Hamlib data structure commit df65ceee67bc11d6f6daba9bce3142ef55a082c5 Author: George Baltz N3GB <Geo...@gm...> Date: Wed Aug 20 18:11:15 2025 -0400 Start removing conditional pthreads use. We can treat HAVE_PTHREAD and HAVE_PTHREAD_H as equivalent. But using _PTHREAD_H is a real kludge. diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 902bb683c..0502e97ca 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -178,11 +178,7 @@ typedef struct int head; int tail; int flush; // flush flag for stop_morse -#ifdef _PTHREAD_H pthread_mutex_t mutex; -#else - int mutex; -#endif } FIFO_RIG; diff --git a/include/hamlib/rig_state.h b/include/hamlib/rig_state.h index bd1c727c1..5d32089d7 100644 --- a/include/hamlib/rig_state.h +++ b/include/hamlib/rig_state.h @@ -24,8 +24,10 @@ #ifndef _RIG_STATE_H #define _RIG_STATE_H 1 -__BEGIN_DECLS +//#include <hamlib/rig.h> +//#include <pthread.h> +__BEGIN_DECLS /** * \addtogroup rig diff --git a/rigs/anytone/anytone.c b/rigs/anytone/anytone.c index 3945d08f6..426332deb 100644 --- a/rigs/anytone/anytone.c +++ b/rigs/anytone/anytone.c @@ -223,9 +223,7 @@ int anytone_init(RIG *rig) { STATE(rig)->priv = p; p->vfo_curr = RIG_VFO_NONE; -#ifdef HAVE_PTHREAD pthread_mutex_init(&p->mutex, NULL); -#endif } } diff --git a/rigs/dummy/rot_pstrotator.c b/rigs/dummy/rot_pstrotator.c index 69d7c4da1..a4b31d675 100644 --- a/rigs/dummy/rot_pstrotator.c +++ b/rigs/dummy/rot_pstrotator.c @@ -178,7 +178,6 @@ static void readPacket(int sockfd, char *buf, int buf_len, int expected) //if (n > 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: buf=%s\n", __func__, buf); } } -#if defined(HAVE_PTHREAD) #if 0 typedef struct pstrotator_handler_args_sw { @@ -245,8 +244,6 @@ static void *pstrotator_handler_start(void *arg) return NULL; } -#endif - static int pstrotator_rot_init(ROT *rot) { struct pstrotator_rot_priv_data *priv; diff --git a/rigs/dummy/rot_pstrotator.h b/rigs/dummy/rot_pstrotator.h index 5f85c46b7..509f31382 100644 --- a/rigs/dummy/rot_pstrotator.h +++ b/rigs/dummy/rot_pstrotator.h @@ -40,7 +40,6 @@ extern struct rot_caps pstrotator_caps; extern struct rot_caps netrotctl_caps; -#if defined(HAVE_PTHREAD) typedef struct pstrotator_handler_args_sw { ROT *rot; @@ -55,8 +54,6 @@ typedef struct pstrotator_handler_priv_data_s int sockfd2; } pstrotator_handler_priv_data; -#endif - #endif /* _ROT_PSTROTATOR_H */ diff --git a/rigs/flexradio/smartsdr.c b/rigs/flexradio/smartsdr.c index c24718905..1bbc1da8d 100644 --- a/rigs/flexradio/smartsdr.c +++ b/rigs/flexradio/smartsdr.c @@ -301,7 +301,6 @@ int smartsdr_cleanup(RIG *rig) } #if 0 -#if defined(HAVE_PTHREAD) typedef struct smartsdr_data_handler_args_s { RIG *rig; @@ -370,7 +369,6 @@ static int smartsdr_data_handler_start(RIG *rig) } #endif -#endif /* Example response to "sub slice 0" 511+511+35 diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 77d3ac80e..85686a68b 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -9049,7 +9049,6 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq, RETURNFUNC(RIG_OK); } -#if defined(HAVE_PTHREAD) static int icom_parse_spectrum_frame(RIG *rig, size_t length, const unsigned char *frame_data) { @@ -9209,7 +9208,6 @@ static int icom_parse_spectrum_frame(RIG *rig, size_t length, RETURNFUNC(RIG_OK); } -#endif int icom_is_async_frame(RIG *rig, size_t frame_length, const unsigned char *frame) @@ -9262,9 +9260,7 @@ int icom_process_async_frame(RIG *rig, size_t frame_length, // TODO: Disable cache timeout for frequency after first transceive packet once we figure out how to get active VFO reliably with transceive updates // TODO: rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_FREQ, HAMLIB_CACHE_ALWAYS); freq_t freq = (freq_t) from_bcd(frame + 5, (priv->civ_731_mode ? 4 : 5) * 2); -#if defined(HAVE_PTHREAD) rig_fire_freq_event(rig, RIG_VFO_CURR, freq); -#endif #if 0 @@ -9284,9 +9280,7 @@ int icom_process_async_frame(RIG *rig, size_t frame_length, // TODO: Disable cache timeout for frequency after first transceive packet once we figure out how to get active VFO reliably with transceive updates // TODO: rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_MODE, HAMLIB_CACHE_ALWAYS); icom2rig_mode(rig, frame[5], frame[6], &mode, &width); -#if defined(HAVE_PTHREAD) rig_fire_mode_event(rig, RIG_VFO_CURR, mode, width); -#endif if (rs->use_cached_mode != 1) { @@ -9297,8 +9291,6 @@ int icom_process_async_frame(RIG *rig, size_t frame_length, break; -#if defined(HAVE_PTHREAD) - case C_CTL_SCP: if (frame[5] == S_SCP_DAT) { @@ -9306,7 +9298,6 @@ int icom_process_async_frame(RIG *rig, size_t frame_length, } break; -#endif default: rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n", diff --git a/rigs/tentec/orion.h b/rigs/tentec/orion.h index 76772a4c2..cf6c89040 100644 --- a/rigs/tentec/orion.h +++ b/rigs/tentec/orion.h @@ -354,25 +354,13 @@ RIG_MODEL(RIG_MODEL_TT565), .rig_close = tt565_close, .set_freq = tt565_set_freq, -#if defined(HAVE_PTHREAD) .get_freq = tt565_get_freq_cache, -#else -.get_freq = tt565_get_freq, -#endif .set_vfo = tt565_set_vfo, .get_vfo = tt565_get_vfo, .set_mode = tt565_set_mode, -#if defined(HAVE_PTHREAD) .get_mode = tt565_get_mode_cache, -#else -.get_mode = tt565_get_mode, -#endif .set_split_vfo = tt565_set_split_vfo, -#if defined(HAVE_PTHREAD) .get_split_vfo = tt565_get_split_vfo_cache, -#else -.get_split_vfo = tt565_get_split_vfo, -#endif .set_level = tt565_set_level, .get_level = tt565_get_level, .set_mem = tt565_set_mem, diff --git a/src/fifo.c b/src/fifo.c index cd112a9d7..b145bcbd0 100644 --- a/src/fifo.c +++ b/src/fifo.c @@ -8,10 +8,8 @@ void initFIFO(FIFO_RIG *fifo) { fifo->head = 0; fifo->tail = 0; -#ifdef _PTHREAD_H static pthread_mutex_t t = PTHREAD_MUTEX_INITIALIZER; fifo->mutex = t; -#endif } void resetFIFO(FIFO_RIG *fifo) @@ -25,9 +23,7 @@ void resetFIFO(FIFO_RIG *fifo) // return -RIG error if overflow int push(FIFO_RIG *fifo, const char *msg) { -#ifdef _PTHREAD_H pthread_mutex_lock(&fifo->mutex); -#endif int len = strlen(msg); for (int i = 0; i < len; ++i) @@ -57,9 +53,7 @@ int push(FIFO_RIG *fifo, const char *msg) fifo->tail = (fifo->tail + 1) % HAMLIB_FIFO_SIZE; } -#ifdef _PTHREAD_H pthread_mutex_unlock(&fifo->mutex); -#endif return RIG_OK; } @@ -73,9 +67,7 @@ int peek(FIFO_RIG *fifo) if (fifo->tail == fifo->head) { return -1; } -#ifdef _PTHREAD_H pthread_mutex_lock(&fifo->mutex); -#endif char c = fifo->data[fifo->head]; #if 0 @@ -89,9 +81,7 @@ int peek(FIFO_RIG *fifo) fifo->tail); #endif -#ifdef _PTHREAD_H pthread_mutex_unlock(&fifo->mutex); -#endif return c; } @@ -99,9 +89,7 @@ int pop(FIFO_RIG *fifo) { if (fifo->tail == fifo->head) { return -1; } -#ifdef _PTHREAD_H pthread_mutex_lock(&fifo->mutex); -#endif char c = fifo->data[fifo->head]; #if 0 @@ -115,9 +103,7 @@ int pop(FIFO_RIG *fifo) #endif fifo->head = (fifo->head + 1) % HAMLIB_FIFO_SIZE; -#ifdef _PTHREAD_H pthread_mutex_unlock(&fifo->mutex); -#endif return c; } commit 9f4755cf70e0a556bff61f433dbaab5e6e20f269 Author: George Baltz N3GB <Geo...@gm...> Date: Tue Aug 19 21:12:56 2025 -0400 Add requirement for POSIX threads (pthreads) I wrote this one-liner, and then realized I couldn't test it - I have no systems that do not have pthreads as an integral part - does anybody? Since <pthread.h> has been a de facto requirement since 4.5, the point may be moot. (Update: quick '# mv pthread.h pthread2.h' and it fails) And are the URLs in README.developer correct? Should they point to github? diff --git a/README.developer b/README.developer index 177717f09..41576a385 100644 --- a/README.developer +++ b/README.developer @@ -159,7 +159,7 @@ file. This document introduces hacking the code of Hamlib. git clone git://git.code.sf.net/p/hamlib/code hamlib -The clone has to only be done the first time. +The clone only has to be done the first time. After the initial clone, whenever you want to update your local repository, issue the following command in the root directory of Hamlib: @@ -277,6 +277,9 @@ distributions may differ). * libtool 2.2.6b+ # libtool --version * Git for connection to git.code.sf.net/p/hamlib/code +As of Hamlib 4.7, POSIX thread support (pthreads) is required to compile or +run Hamlib. + N.B. Hamlib requires libtool >= 2.2.6b in compliance with CVE-2009-3736. Optional, but highly recommended: @@ -518,6 +521,7 @@ So far, Hamlib has been tested successfully under the following systems: * Debian sid mipsel * Raspbian armhf (Raspberry Pi Debian derivative) * RedHat i386 + * openSUSE (Leap & Tumbleweed) * Linux ppc * Slackware i386 * FreeBSD & NetBSD diff --git a/configure.ac b/configure.ac index 81e045539..150954246 100644 --- a/configure.ac +++ b/configure.ac @@ -172,7 +172,7 @@ dnl If pthread support is found, this macro defines HAVE_PTHREAD and dnl AC_SUBST's PTHREAD_LIBS, PTHREAD_CFLAGS, and PTHREAD_CC making those dnl variables available in Makefiles. # macros/ax_pthread.m4 -AX_PTHREAD +AX_PTHREAD([], [AC_MSG_ERROR([POSIX threads not found])]) AC_SYS_POSIX_TERMIOS() ----------------------------------------------------------------------- Summary of changes: NEWS | 3 +++ README.developer | 6 ++++- configure.ac | 2 +- include/hamlib/rig.h | 4 ---- include/hamlib/rig_state.h | 4 +++- rigs/anytone/anytone.c | 2 -- rigs/dummy/rot_pstrotator.c | 3 --- rigs/dummy/rot_pstrotator.h | 3 --- rigs/flexradio/smartsdr.c | 2 -- rigs/icom/icom.c | 9 -------- rigs/tentec/orion.h | 12 ---------- rotators/ars/ars.c | 16 ------------- rotators/ars/ars.h | 2 -- src/event.c | 23 +------------------ src/fifo.c | 14 ------------ src/microham.c | 18 +++++---------- src/misc.h | 7 +----- src/mutex.h | 9 -------- src/network.c | 7 ++---- src/rig.c | 47 +++----------------------------------- src/settings.c | 2 -- tests/ampctl_parse.c | 8 +------ tests/ampctld.c | 12 +--------- tests/rigctld.c | 54 +++----------------------------------------- tests/rigctltcp.c | 55 +++------------------------------------------ tests/rotctl_parse.c | 8 +------ tests/rotctld.c | 14 +----------- 27 files changed, 34 insertions(+), 312 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |