On Sat, 2023-01-28 at 14:43 -0800, Richard Cochran wrote:
> Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
> ---
>  clock.c | 19 ++++++++++++++++---
>  tz.h    | 26 ++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 3 deletions(-)
>  create mode 100644 tz.h
> 
> diff --git a/clock.c b/clock.c
> index 134c7c3..767599b 100644
> --- a/clock.c
> +++ b/clock.c
> @@ -42,6 +42,7 @@
>  #include "rtnl.h"
>  #include "tlv.h"
>  #include "tsproc.h"
> +#include "tz.h"
>  #include "uds.h"
>  #include "util.h"
>  
> @@ -79,6 +80,15 @@ struct clock_subscriber {
>         time_t expiration;
>  };
>  
> +struct time_zone {
> +       bool enabled;
> +       int32_t current_offset;
> +       int32_t jump_seconds;
> +       uint16_t next_jump_msb;
> +       uint32_t next_jump_lsb;
> +       struct static_ptp_text display_name;
> +};
> +
>  struct clock {
>         enum clock_type type;
>         struct config *config;
> @@ -137,6 +147,7 @@ struct clock {
>         struct monitor *slave_event_monitor;
>         int step_window_counter;
>         int step_window;
> +       struct time_zone tz[MAX_TIME_ZONES];
>  };
>  
>  struct clock the_clock;
> @@ -894,19 +905,17 @@ int clock_required_modes(struct clock *c)
>  struct clock *clock_create(enum clock_type type, struct config
> *config,
>                            const char *phc_device)
>  {
> +       int conf_phc_index, i, max_adj = 0, phc_index, required_modes
> = 0, sfl, sw_ts;
>         enum servo_type servo = config_get_int(config, NULL,
> "clock_servo");
>         char ts_label[IF_NAMESIZE], phc[32], *tmp;
>         enum timestamp_type timestamping;
> -       int phc_index, conf_phc_index, required_modes = 0;
>         struct clock *c = &the_clock;
> -       int max_adj = 0, sw_ts;
>         const char *uds_ifname;
>         double fadj = 0.0;
>         struct port *p;
>         unsigned char oui[OUI_LEN];
>         struct interface *iface;
>         struct timespec ts;
> -       int sfl;
>  
>         clock_gettime(CLOCK_REALTIME, &ts);
>         srandom(ts.tv_sec ^ ts.tv_nsec);
> @@ -1201,6 +1210,10 @@ struct clock *clock_create(enum clock_type
> type, struct config *config,
>         c->dad.pds.observedParentClockPhaseChangeRate    =
> 0x7fffffff;
>         c->dad.ptl = c->ptl;
>  
> +       for (i = 0; i < MAX_TIME_ZONES; i++) {
> +               c->tz[i].display_name.max_symbols =
> MAX_TZ_DISPLAY_NAME;
> +       }
> +
>         clock_sync_interval(c, 0);
>  
>         LIST_INIT(&c->subscribers);
> diff --git a/tz.h b/tz.h
> new file mode 100644
> index 0000000..986f976
> --- /dev/null
> +++ b/tz.h
> @@ -0,0 +1,26 @@
> +/**
> + * @file tz.h
> + * @brief Implements time zone constants.
> + * @note Copyright (C) 2021 Richard Cochran <
> richardcoch...@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> modify
> + * it under the terms of the GNU General Public License as published
> by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> along
> + * with this program; if not, write to the Free Software Foundation,
> Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */

Perhaps we can use SPDX, like the Linux kernel do?
https://www.kernel.org/doc/html/latest/process/license-rules.html
https://spdx.dev/


> +#ifndef HAVE_TZ_H
> +#define HAVE_TZ_H
> +
> +#define MAX_TZ_DISPLAY_NAME    10
> +#define MAX_TIME_ZONES         4
> +
> +#endif

Erez


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to