Start removing conditional pthreads use.

We can treat HAVE_PTHREAD and HAVE_PTHREAD_H as equivalent. But using
_PTHREAD_H is a real kludge.
pull/1876/head
George Baltz N3GB 2025-08-20 18:11:15 -04:00
rodzic 9f4755cf70
commit df65ceee67
9 zmienionych plików z 3 dodań i 50 usunięć

Wyświetl plik

@ -178,11 +178,7 @@ typedef struct
int head; int head;
int tail; int tail;
int flush; // flush flag for stop_morse int flush; // flush flag for stop_morse
#ifdef _PTHREAD_H
pthread_mutex_t mutex; pthread_mutex_t mutex;
#else
int mutex;
#endif
} FIFO_RIG; } FIFO_RIG;

Wyświetl plik

@ -24,8 +24,10 @@
#ifndef _RIG_STATE_H #ifndef _RIG_STATE_H
#define _RIG_STATE_H 1 #define _RIG_STATE_H 1
__BEGIN_DECLS //#include <hamlib/rig.h>
//#include <pthread.h>
__BEGIN_DECLS
/** /**
* \addtogroup rig * \addtogroup rig

Wyświetl plik

@ -223,9 +223,7 @@ int anytone_init(RIG *rig)
{ {
STATE(rig)->priv = p; STATE(rig)->priv = p;
p->vfo_curr = RIG_VFO_NONE; p->vfo_curr = RIG_VFO_NONE;
#ifdef HAVE_PTHREAD
pthread_mutex_init(&p->mutex, NULL); pthread_mutex_init(&p->mutex, NULL);
#endif
} }
} }

Wyświetl plik

@ -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 (n > 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: buf=%s\n", __func__, buf); }
} }
#if defined(HAVE_PTHREAD)
#if 0 #if 0
typedef struct pstrotator_handler_args_sw typedef struct pstrotator_handler_args_sw
{ {
@ -245,8 +244,6 @@ static void *pstrotator_handler_start(void *arg)
return NULL; return NULL;
} }
#endif
static int pstrotator_rot_init(ROT *rot) static int pstrotator_rot_init(ROT *rot)
{ {
struct pstrotator_rot_priv_data *priv; struct pstrotator_rot_priv_data *priv;

Wyświetl plik

@ -40,7 +40,6 @@
extern struct rot_caps pstrotator_caps; extern struct rot_caps pstrotator_caps;
extern struct rot_caps netrotctl_caps; extern struct rot_caps netrotctl_caps;
#if defined(HAVE_PTHREAD)
typedef struct pstrotator_handler_args_sw typedef struct pstrotator_handler_args_sw
{ {
ROT *rot; ROT *rot;
@ -55,8 +54,6 @@ typedef struct pstrotator_handler_priv_data_s
int sockfd2; int sockfd2;
} pstrotator_handler_priv_data; } pstrotator_handler_priv_data;
#endif
#endif /* _ROT_PSTROTATOR_H */ #endif /* _ROT_PSTROTATOR_H */

Wyświetl plik

@ -301,7 +301,6 @@ int smartsdr_cleanup(RIG *rig)
} }
#if 0 #if 0
#if defined(HAVE_PTHREAD)
typedef struct smartsdr_data_handler_args_s typedef struct smartsdr_data_handler_args_s
{ {
RIG *rig; RIG *rig;
@ -370,7 +369,6 @@ static int smartsdr_data_handler_start(RIG *rig)
} }
#endif #endif
#endif
/* Example response to "sub slice 0" /* Example response to "sub slice 0"
511+511+35 511+511+35

Wyświetl plik

@ -9049,7 +9049,6 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq,
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
#if defined(HAVE_PTHREAD)
static int icom_parse_spectrum_frame(RIG *rig, size_t length, static int icom_parse_spectrum_frame(RIG *rig, size_t length,
const unsigned char *frame_data) const unsigned char *frame_data)
{ {
@ -9209,7 +9208,6 @@ static int icom_parse_spectrum_frame(RIG *rig, size_t length,
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
#endif
int icom_is_async_frame(RIG *rig, size_t frame_length, int icom_is_async_frame(RIG *rig, size_t frame_length,
const unsigned char *frame) 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: 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); // 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); 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); rig_fire_freq_event(rig, RIG_VFO_CURR, freq);
#endif
#if 0 #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: 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); // TODO: rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_MODE, HAMLIB_CACHE_ALWAYS);
icom2rig_mode(rig, frame[5], frame[6], &mode, &width); icom2rig_mode(rig, frame[5], frame[6], &mode, &width);
#if defined(HAVE_PTHREAD)
rig_fire_mode_event(rig, RIG_VFO_CURR, mode, width); rig_fire_mode_event(rig, RIG_VFO_CURR, mode, width);
#endif
if (rs->use_cached_mode != 1) if (rs->use_cached_mode != 1)
{ {
@ -9297,8 +9291,6 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
break; break;
#if defined(HAVE_PTHREAD)
case C_CTL_SCP: case C_CTL_SCP:
if (frame[5] == S_SCP_DAT) if (frame[5] == S_SCP_DAT)
{ {
@ -9306,7 +9298,6 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
} }
break; break;
#endif
default: default:
rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n", rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n",

Wyświetl plik

@ -354,25 +354,13 @@ RIG_MODEL(RIG_MODEL_TT565),
.rig_close = tt565_close, .rig_close = tt565_close,
.set_freq = tt565_set_freq, .set_freq = tt565_set_freq,
#if defined(HAVE_PTHREAD)
.get_freq = tt565_get_freq_cache, .get_freq = tt565_get_freq_cache,
#else
.get_freq = tt565_get_freq,
#endif
.set_vfo = tt565_set_vfo, .set_vfo = tt565_set_vfo,
.get_vfo = tt565_get_vfo, .get_vfo = tt565_get_vfo,
.set_mode = tt565_set_mode, .set_mode = tt565_set_mode,
#if defined(HAVE_PTHREAD)
.get_mode = tt565_get_mode_cache, .get_mode = tt565_get_mode_cache,
#else
.get_mode = tt565_get_mode,
#endif
.set_split_vfo = tt565_set_split_vfo, .set_split_vfo = tt565_set_split_vfo,
#if defined(HAVE_PTHREAD)
.get_split_vfo = tt565_get_split_vfo_cache, .get_split_vfo = tt565_get_split_vfo_cache,
#else
.get_split_vfo = tt565_get_split_vfo,
#endif
.set_level = tt565_set_level, .set_level = tt565_set_level,
.get_level = tt565_get_level, .get_level = tt565_get_level,
.set_mem = tt565_set_mem, .set_mem = tt565_set_mem,

Wyświetl plik

@ -8,10 +8,8 @@ void initFIFO(FIFO_RIG *fifo)
{ {
fifo->head = 0; fifo->head = 0;
fifo->tail = 0; fifo->tail = 0;
#ifdef _PTHREAD_H
static pthread_mutex_t t = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t t = PTHREAD_MUTEX_INITIALIZER;
fifo->mutex = t; fifo->mutex = t;
#endif
} }
void resetFIFO(FIFO_RIG *fifo) void resetFIFO(FIFO_RIG *fifo)
@ -25,9 +23,7 @@ void resetFIFO(FIFO_RIG *fifo)
// return -RIG error if overflow // return -RIG error if overflow
int push(FIFO_RIG *fifo, const char *msg) int push(FIFO_RIG *fifo, const char *msg)
{ {
#ifdef _PTHREAD_H
pthread_mutex_lock(&fifo->mutex); pthread_mutex_lock(&fifo->mutex);
#endif
int len = strlen(msg); int len = strlen(msg);
for (int i = 0; i < len; ++i) 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; fifo->tail = (fifo->tail + 1) % HAMLIB_FIFO_SIZE;
} }
#ifdef _PTHREAD_H
pthread_mutex_unlock(&fifo->mutex); pthread_mutex_unlock(&fifo->mutex);
#endif
return RIG_OK; return RIG_OK;
} }
@ -73,9 +67,7 @@ int peek(FIFO_RIG *fifo)
if (fifo->tail == fifo->head) { return -1; } if (fifo->tail == fifo->head) { return -1; }
#ifdef _PTHREAD_H
pthread_mutex_lock(&fifo->mutex); pthread_mutex_lock(&fifo->mutex);
#endif
char c = fifo->data[fifo->head]; char c = fifo->data[fifo->head];
#if 0 #if 0
@ -89,9 +81,7 @@ int peek(FIFO_RIG *fifo)
fifo->tail); fifo->tail);
#endif #endif
#ifdef _PTHREAD_H
pthread_mutex_unlock(&fifo->mutex); pthread_mutex_unlock(&fifo->mutex);
#endif
return c; return c;
} }
@ -99,9 +89,7 @@ int pop(FIFO_RIG *fifo)
{ {
if (fifo->tail == fifo->head) { return -1; } if (fifo->tail == fifo->head) { return -1; }
#ifdef _PTHREAD_H
pthread_mutex_lock(&fifo->mutex); pthread_mutex_lock(&fifo->mutex);
#endif
char c = fifo->data[fifo->head]; char c = fifo->data[fifo->head];
#if 0 #if 0
@ -115,9 +103,7 @@ int pop(FIFO_RIG *fifo)
#endif #endif
fifo->head = (fifo->head + 1) % HAMLIB_FIFO_SIZE; fifo->head = (fifo->head + 1) % HAMLIB_FIFO_SIZE;
#ifdef _PTHREAD_H
pthread_mutex_unlock(&fifo->mutex); pthread_mutex_unlock(&fifo->mutex);
#endif
return c; return c;
} }