Eliminate the ad-hoc use of global variables in the ts2phc program by introducing one data structure that incorporates them. This might make the code more understandable to people coming from a kernel background, since it resembles the type of data organization used there. It is also now closer to the data organization of phc2sys, a similar program in both purpose and implementation. The reason why this is needed has to do with the ts2phc polymorphism for a PPS master. In the next patches, PPS masters will expose a struct clock, which will be synchronized from the main ts2phc.c. Not all PPS masters will expose a clock, only the PHC kind will. So the current object encapsulation model needs to be loosened up little bit, because the main ts2phc.c needs to synchronize a list of clocks, list which is populated by the slaves and the masters which are capable of being synchronized. So instead of having the translation modules of ts2phc communicate through global variables, let's make struct ts2phc_private the common working space for the entire program, which is a paradigm that is more natural. Signed-off-by: Vladimir Oltean <olteanv@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
24 lines
507 B
C
24 lines
507 B
C
/**
|
|
* @file ts2phc.h
|
|
* @brief Structure definitions for ts2phc
|
|
* @note Copyright 2020 Vladimir Oltean <olteanv@gmail.com>
|
|
* @note SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
#ifndef HAVE_TS2PHC_H
|
|
#define HAVE_TS2PHC_H
|
|
|
|
struct ts2phc_slave_array;
|
|
|
|
struct ts2phc_private {
|
|
struct ts2phc_master *master;
|
|
STAILQ_HEAD(slave_ifaces_head, ts2phc_slave) slaves;
|
|
unsigned int n_slaves;
|
|
struct ts2phc_slave_array *polling_array;
|
|
struct config *cfg;
|
|
};
|
|
|
|
#include "ts2phc_master.h"
|
|
#include "ts2phc_slave.h"
|
|
|
|
#endif
|