File: ntp_types.h

package info (click to toggle)
ntp 1%3A4.2.6.p5%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 22,056 kB
  • sloc: ansic: 144,116; sh: 12,381; perl: 1,401; makefile: 1,274; yacc: 1,034; awk: 417; asm: 37; sed: 7
file content (130 lines) | stat: -rw-r--r-- 3,218 bytes parent folder | download | duplicates (3)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 *  ntp_types.h - defines how int32 and u_int32 are treated.
 *  For 64 bit systems like the DEC Alpha, they have to be defined
 *  as int and u_int.
 *  For 32 bit systems, define them as long and u_long
 */
#ifndef NTP_TYPES_H
#define NTP_TYPES_H

#include <sys/types.h>
#include "ntp_machine.h"

#ifndef TRUE
# define	TRUE	1
#endif
#ifndef FALSE
# define	FALSE	0
#endif

/*
 * This is another naming conflict.
 * On NetBSD for MAC the macro "mac" is defined as 1
 * this is fun for us as a packet structure contains an
 * optional "mac" member - severe confusion results 8-)
 * As we hopefully do not have to rely on that macro we
 * just undefine that.
 */
#ifdef mac
#undef mac
#endif

/*
 * used to quiet compiler warnings
 */
#ifndef UNUSED_ARG
#define UNUSED_ARG(arg)	((void)(arg))
#endif

/*
 * COUNTOF(array) - size of array in elements
 */
#define COUNTOF(arr)	(sizeof(arr) / sizeof((arr)[0]))

/*
 * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H,
 *			and u_int isn't defined anywhere
 */
#if defined(VMS)
#include <socket.h>
typedef unsigned int u_int;
/*
 * Note: VMS DECC has  long == int  (even on __alpha),
 *	 so the distinction below doesn't matter
 */
#endif /* VMS */

#if (SIZEOF_INT == 4)
# ifndef int32
#  define int32 int
#  ifndef INT32_MIN
#   define INT32_MIN INT_MIN
#  endif
#  ifndef INT32_MAX
#   define INT32_MAX INT_MAX
#  endif
# endif
# ifndef u_int32
#  define u_int32 unsigned int
#  ifndef U_INT32_MAX
#   define U_INT32_MAX UINT_MAX
#  endif
# endif
#else /* not sizeof(int) == 4 */
# if (SIZEOF_LONG == 4)
#  ifndef int32
#   define int32 long
#   ifndef INT32_MIN
#    define INT32_MIN LONG_MIN
#   endif
#   ifndef INT32_MAX
#    define INT32_MAX LONG_MAX
#   endif
#  endif
#  ifndef u_int32
#   define u_int32 unsigned long
#   ifndef U_INT32_MAX
#    define U_INT32_MAX ULONG_MAX
#   endif
#  endif
# else /* not sizeof(long) == 4 */
#  include "Bletch: what's 32 bits on this machine?"
# endif /* not sizeof(long) == 4 */
#endif /* not sizeof(int) == 4 */

typedef u_char		ntp_u_int8_t;
typedef u_short		ntp_u_int16_t;
typedef u_int32		ntp_u_int32_t;

typedef struct ntp_uint64_t { u_int32 val[2]; } ntp_uint64_t;

typedef unsigned short associd_t; /* association ID */
typedef u_int32 keyid_t;	/* cryptographic key ID */
typedef u_int32 tstamp_t;	/* NTP seconds timestamp */

/*
 * On Unix struct sock_timeval is equivalent to struct timeval.
 * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long
 * as required by Windows' socket() interface timeout argument, while
 * timeval.tv_sec is time_t for the more common use as a UTC time 
 * within NTP.
 */
#ifndef SYS_WINNT
#define	sock_timeval	timeval
#endif

/*
 * On Unix open() works for tty (serial) devices just fine, while on
 * Windows refclock serial devices are opened using CreateFile, a lower
 * level than the CRT-provided descriptors, because the C runtime lacks
 * tty APIs.  For refclocks which wish to use open() as well as or 
 * instead of refclock_open(), tty_open() is equivalent to open() on
 * Unix and  implemented in the Windows port similarly to
 * refclock_open().
 */
#ifndef SYS_WINNT
#define tty_open(f, a, m)	open(f, a, m)
#endif


#endif	/* NTP_TYPES_H */