kopia lustrzana https://github.com/Hamlib/Hamlib
More conditional pthread usage unleashed
Anybody know what sync_callback() is supposed to do? Currently unused, very broken, and not even a header comment.pull/1876/head
rodzic
df65ceee67
commit
9a90745ba6
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
23
src/event.c
23
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
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
/** @} */
|
||||
|
|
47
src/rig.c
47
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
|
||||
|
|
Ładowanie…
Reference in New Issue