kopia lustrzana https://github.com/Hamlib/Hamlib
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
rodzic
9f4755cf70
commit
df65ceee67
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
|
|
14
src/fifo.c
14
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;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue