blob: 07a02a8d6a72fd3183d31f8ee6c069b0de4ec036 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* This file is Copyright (c) 2015 by the GPSD project
* BSD terms apply: see the file COPYING in the distribution root for details.
*/
#ifndef GPSD_NTPSHM_H
#define GPSD_NTPSHM_H
#include <stdbool.h>
#include <time.h>
#include <sys/time.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#define NTPD_BASE 0x4e545030 /* "NTP0" */
/*
* How to read and write fields in an NTP shared segment.
* This definition of shmTime is from ntpd source ntpd/refclock_shm.c
*/
struct shmTime
{
int mode; /* 0 - if valid set
* use values,
* clear valid
* 1 - if valid set
* if count before and after read of values is equal,
* use values
* clear valid
*/
volatile int count;
time_t clockTimeStampSec;
int clockTimeStampUSec;
time_t receiveTimeStampSec;
int receiveTimeStampUSec;
int leap;
int precision;
int nsamples;
volatile int valid;
unsigned clockTimeStampNSec; /* Unsigned ns timestamps */
unsigned receiveTimeStampNSec; /* Unsigned ns timestamps */
int dummy[8];
};
#endif
/*
* These types are internal to GPSD
*/
enum segstat_t {
OK, NO_SEGMENT, NOT_READY, BAD_MODE, CLASH};
struct shm_stat_t {
int mode;
struct timespec tvc, tvr, tvt;
int precision;
int leap;
};
struct shmTime *shm_get(int, bool);
extern char *shm_name(const int);
enum segstat_t shm_query(struct shmTime *, struct shm_stat_t *);
/* end */
|