Skip to content

Commit

Permalink
config: convert 'ntpshm_segment' to the new scheme.
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Aug 23, 2015
1 parent 177a710 commit 4c9c447
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 23 deletions.
7 changes: 1 addition & 6 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_DBL("first_step_threshold", 0.00002, 0.0, DBL_MAX),
GLOB_ITEM_INT("logging_level", LOG_INFO, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX),
GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX),
GLOB_ITEM_INT("ntpshm_segment", 0, INT_MIN, INT_MAX),
GLOB_ITEM_DBL("pi_integral_const", 0.0, 0.0, DBL_MAX),
GLOB_ITEM_DBL("pi_integral_exponent", 0.4, -DBL_MAX, DBL_MAX),
GLOB_ITEM_DBL("pi_integral_norm_max", 0.3, DBL_MIN, 2.0),
Expand Down Expand Up @@ -554,12 +555,6 @@ static enum parser_result parse_global_setting(const char *option,
return r;
cfg->dds.sanity_freq_limit = val;

} else if (!strcmp(option, "ntpshm_segment")) {
r = get_ranged_int(value, &val, INT_MIN, INT_MAX);
if (r != PARSED_OK)
return r;
*cfg->ntpshm_segment = val;

} else if (!strcmp(option, "ptp_dst_mac")) {
if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]))
Expand Down
2 changes: 0 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ struct config {
struct port_defaults pod;
enum servo_type clock_servo;

int *ntpshm_segment;

unsigned char *ptp_dst_mac;
unsigned char *p2p_dst_mac;
unsigned char *udp6_scope;
Expand Down
9 changes: 3 additions & 6 deletions ntpshm.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
#include <sys/types.h>
#include <sys/shm.h>

#include "config.h"
#include "print.h"
#include "ntpshm.h"
#include "servo_private.h"

#define NS_PER_SEC 1000000000

/* NTP leap values */
#define LEAP_NORMAL 0x0
#define LEAP_INSERT 0x1
Expand All @@ -36,9 +35,6 @@
/* Key of the first SHM segment */
#define SHMKEY 0x4e545030

/* Number of the SHM segment to be used */
int ntpshm_segment = 0;

/* Declaration of the SHM segment from ntp (ntpd/refclock_shm.c) */
struct shmTime {
int mode; /* 0 - if valid set
Expand Down Expand Up @@ -134,9 +130,10 @@ static void ntpshm_leap(struct servo *servo, int leap)
s->leap = leap;
}

struct servo *ntpshm_servo_create(void)
struct servo *ntpshm_servo_create(struct config *cfg)
{
struct ntpshm_servo *s;
int ntpshm_segment = config_get_int(cfg, NULL, "ntpshm_segment");
int shmid;

s = calloc(1, sizeof(*s));
Expand Down
7 changes: 1 addition & 6 deletions ntpshm.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

#include "servo.h"

/**
* The number of the SHM segment that will be used by newly created servo
*/
extern int ntpshm_segment;

struct servo *ntpshm_servo_create(void);
struct servo *ntpshm_servo_create(struct config *cfg);

#endif
3 changes: 3 additions & 0 deletions phc2sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@ int main(int argc, char *argv[])
int c, domain_number = 0, pps_fd = -1;
int r, wait_sync = 0;
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
int ntpshm_segment;
double phc_rate, tmp;
struct node node = {
.sanity_freq_limit = 200000000,
Expand Down Expand Up @@ -1334,6 +1335,8 @@ int main(int argc, char *argv[])
case 'M':
if (get_arg_val_i(c, optarg, &ntpshm_segment, INT_MIN, INT_MAX))
return -1;
if (config_set_int(cfg, "ntpshm_segment", ntpshm_segment))
return -1;
break;
case 'u':
if (get_arg_val_ui(c, optarg, &node.stats_max_count,
Expand Down
2 changes: 0 additions & 2 deletions ptp4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ static struct config cfg_settings = {
.transport = TRANS_UDP_IPV4,
.clock_servo = CLOCK_SERVO_PI,

.ntpshm_segment = &ntpshm_segment,

.ptp_dst_mac = ptp_dst_mac,
.p2p_dst_mac = p2p_dst_mac,
.udp6_scope = &udp6_scope,
Expand Down
2 changes: 1 addition & 1 deletion servo.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct servo *servo_create(struct config *cfg, enum servo_type type,
servo = linreg_servo_create(fadj);
break;
case CLOCK_SERVO_NTPSHM:
servo = ntpshm_servo_create();
servo = ntpshm_servo_create(cfg);
break;
case CLOCK_SERVO_NULLF:
servo = nullf_servo_create();
Expand Down

0 comments on commit 4c9c447

Please sign in to comment.