Commit 1d8d63b6 authored by Eric S. Raymond's avatar Eric S. Raymond

Use ANSI fixed-length 32-bit types from stdint.h rather than home-brew ones.

The result of

replace u_int32 uint32_t */*.[ch]
replace 'int32 ' 'int32_t ' */*.[ch]
replace '(int32)' '(int32_t)' */*.[ch]
replace 'int32,' 'int32_t,' */*.[ch]
replace 'int32	' 'int32_t	' */*.[ch]

followed by one fixup of a variable with the unfortunate name uint32.

This change banishes a lot of ugly cuft from include/ntp_types.h
parent b086b860
......@@ -177,16 +177,16 @@ struct interface {
endpt * mclink; /* per-AF_* multicast list */
SOCKET fd; /* socket descriptor */
SOCKET bfd; /* for receiving broadcasts */
u_int32 ifnum; /* endpt instance count */
uint32_t ifnum; /* endpt instance count */
sockaddr_u sin; /* unicast address */
sockaddr_u mask; /* subnet mask */
sockaddr_u bcast; /* broadcast address */
char name[32]; /* name of interface */
u_short family; /* AF_INET/AF_INET6 */
u_short phase; /* phase in update cycle */
u_int32 flags; /* interface flags */
uint32_t flags; /* interface flags */
int last_ttl; /* last TTL specified */
u_int32 addr_refid; /* IPv4 addr or IPv6 hash */
uint32_t addr_refid; /* IPv4 addr or IPv6 hash */
int num_mcast; /* mcast addrs enabled */
u_long starttime; /* current_time at creation */
volatile long received; /* number of incoming packets */
......@@ -266,7 +266,7 @@ struct peer {
u_char cast_flags; /* additional flags */
u_char last_event; /* last peer error code */
u_char num_events; /* number of error events */
u_int32 ttl; /* ttl/refclock mode */
uint32_t ttl; /* ttl/refclock mode */
char *ident; /* group identifier name */
/*
......@@ -289,7 +289,7 @@ struct peer {
s_char precision; /* remote clock precision */
double rootdelay; /* roundtrip delay to primary source */
double rootdisp; /* dispersion to primary source */
u_int32 refid; /* remote reference ID */
uint32_t refid; /* remote reference ID */
l_fp reftime; /* update epoch */
/*
......@@ -298,9 +298,9 @@ struct peer {
keyid_t keyid; /* current key ID */
#ifdef AUTOKEY
#define clear_to_zero opcode
u_int32 opcode; /* last request opcode */
uint32_t opcode; /* last request opcode */
associd_t assoc; /* peer association ID */
u_int32 crypto; /* peer status word */
uint32_t crypto; /* peer status word */
EVP_PKEY *pkey; /* public key */
const EVP_MD *digest; /* message digest algorithm */
char *subject; /* certificate subject name */
......@@ -540,16 +540,16 @@ struct pkt {
s_char precision; /* peer clock precision */
u_fp rootdelay; /* roundtrip delay to primary source */
u_fp rootdisp; /* dispersion to primary source*/
u_int32 refid; /* reference id */
uint32_t refid; /* reference id */
l_fp reftime; /* last update time */
l_fp org; /* originate time stamp */
l_fp rec; /* receive time stamp */
l_fp xmt; /* transmit time stamp */
#define LEN_PKT_NOMAC (12 * sizeof(u_int32)) /* min header length */
#define MIN_MAC_LEN (1 * sizeof(u_int32)) /* crypto_NAK */
#define MAX_MD5_LEN (5 * sizeof(u_int32)) /* MD5 */
#define MAX_MAC_LEN (6 * sizeof(u_int32)) /* SHA */
#define LEN_PKT_NOMAC (12 * sizeof(uint32_t)) /* min header length */
#define MIN_MAC_LEN (1 * sizeof(uint32_t)) /* crypto_NAK */
#define MAX_MD5_LEN (5 * sizeof(uint32_t)) /* MD5 */
#define MAX_MAC_LEN (6 * sizeof(uint32_t)) /* SHA */
/*
* The length of the packet less MAC must be a multiple of 64
......@@ -569,9 +569,9 @@ struct pkt {
* fields have to be parsed or skipped.
*/
#ifdef AUTOKEY
u_int32 exten[(NTP_MAXEXTEN + MAX_MAC_LEN) / sizeof(u_int32)];
uint32_t exten[(NTP_MAXEXTEN + MAX_MAC_LEN) / sizeof(uint32_t)];
#else /* !AUTOKEY follows */
u_int32 exten[(MAX_MAC_LEN) / sizeof(u_int32)];
uint32_t exten[(MAX_MAC_LEN) / sizeof(uint32_t)];
#endif /* !AUTOKEY */
};
......@@ -798,8 +798,8 @@ struct mon_data {
* Structure used for restrictlist entries
*/
typedef struct res_addr4_tag {
u_int32 addr; /* IPv4 addr (host order) */
u_int32 mask; /* IPv4 mask (host order) */
uint32_t addr; /* IPv4 addr (host order) */
uint32_t mask; /* IPv4 mask (host order) */
} res_addr4;
typedef struct res_addr6_tag {
......@@ -810,7 +810,7 @@ typedef struct res_addr6_tag {
typedef struct restrict_u_tag restrict_u;
struct restrict_u_tag {
restrict_u * link; /* link to next entry */
u_int32 count; /* number of packets matched */
uint32_t count; /* number of packets matched */
u_short flags; /* accesslist flags */
u_short mflags; /* match flags */
u_long expire; /* valid until time */
......
......@@ -114,7 +114,7 @@ struct peer_node_tag {
attr_val_fifo * peerflags;
u_char minpoll;
u_char maxpoll;
u_int32 ttl;
uint32_t ttl;
u_char peerversion;
keyid_t peerkey;
char * group;
......
......@@ -6,7 +6,7 @@
typedef union ctl_pkt_u_tag {
u_char data[480 + MAX_MAC_LEN]; /* data + auth */
u_int32 u32[(480 + MAX_MAC_LEN) / sizeof(u_int32)];
uint32_t u32[(480 + MAX_MAC_LEN) / sizeof(uint32_t)];
} ctl_pkt_u;
struct ntp_control {
......
......@@ -118,7 +118,7 @@ invalidsyntax: AUTOKEY should be defined only if OPENSSL is.
*/
struct autokey { /* network byte order */
keyid_t key; /* key ID */
int32 seq; /* key number */
int32_t seq; /* key number */
};
/*
......@@ -129,9 +129,9 @@ struct autokey { /* network byte order */
struct value { /* network byte order */
tstamp_t tstamp; /* timestamp */
tstamp_t fstamp; /* filestamp */
u_int32 vallen; /* value length */
uint32_t vallen; /* value length */
void *ptr; /* data pointer (various) */
u_int32 siglen; /* signature length */
uint32_t siglen; /* signature length */
u_char *sig; /* signature */
};
......@@ -140,12 +140,12 @@ struct value { /* network byte order */
* and signatures in network byte order.
*/
struct exten {
u_int32 opcode; /* opcode */
u_int32 associd; /* association ID */
u_int32 tstamp; /* timestamp */
u_int32 fstamp; /* filestamp */
u_int32 vallen; /* value length */
u_int32 pkt[1]; /* start of value field */
uint32_t opcode; /* opcode */
uint32_t associd; /* association ID */
uint32_t tstamp; /* timestamp */
uint32_t fstamp; /* filestamp */
uint32_t vallen; /* value length */
uint32_t pkt[1]; /* start of value field */
};
......
......@@ -45,7 +45,7 @@ typedef struct filegen_tag {
u_char flag; /* flags modifying processing of file generation */
} FILEGEN;
extern void filegen_setup (FILEGEN *, u_int32);
extern void filegen_setup (FILEGEN *, uint32_t);
extern void filegen_config (FILEGEN *, const char *, const char *,
u_int, u_int);
extern void filegen_statsdir(void);
......
......@@ -29,10 +29,10 @@
*/
typedef struct {
union {
u_int32 Xl_ui;
int32 Xl_i;
uint32_t Xl_ui;
int32_t Xl_i;
} Ul_i;
u_int32 l_uf;
uint32_t l_uf;
} l_fp;
#define l_ui Ul_i.Xl_ui /* unsigned integral part */
......@@ -61,8 +61,8 @@ typedef struct {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
typedef int32 s_fp;
typedef u_int32 u_fp;
typedef int32_t s_fp;
typedef uint32_t u_fp;
/*
* A unit second in fp format. Actually 2**(half_the_bits_in_a_long)
......@@ -134,66 +134,66 @@ typedef u_int32 u_fp;
#define M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \
do { \
u_int32 add_t = (r_f); \
uint32_t add_t = (r_f); \
(r_f) += (a_f); \
(r_i) += (a_i) + ((u_int32)(r_f) < add_t); \
(r_i) += (a_i) + ((uint32_t)(r_f) < add_t); \
} while (false)
#define M_ADD3(r_o, r_i, r_f, a_o, a_i, a_f) /* r += a, three word */ \
do { \
u_int32 add_t, add_c; \
uint32_t add_t, add_c; \
add_t = (r_f); \
(r_f) += (a_f); \
add_c = ((u_int32)(r_f) < add_t); \
add_c = ((uint32_t)(r_f) < add_t); \
(r_i) += add_c; \
add_c = ((u_int32)(r_i) < add_c); \
add_c = ((uint32_t)(r_i) < add_c); \
add_t = (r_i); \
(r_i) += (a_i); \
add_c |= ((u_int32)(r_i) < add_t); \
add_c |= ((uint32_t)(r_i) < add_t); \
(r_o) += (a_o) + add_c; \
} while (false)
#define M_SUB(r_i, r_f, a_i, a_f) /* r -= a */ \
do { \
u_int32 sub_t = (r_f); \
uint32_t sub_t = (r_f); \
(r_f) -= (a_f); \
(r_i) -= (a_i) + ((u_int32)(r_f) > sub_t); \
(r_i) -= (a_i) + ((uint32_t)(r_f) > sub_t); \
} while (false)
#define M_RSHIFTU(v_i, v_f) /* v >>= 1, v is unsigned */ \
do { \
(v_f) = ((u_int32)(v_f) >> 1) | ((u_int32)(v_i) << 31); \
(v_i) = ((u_int32)(v_i) >> 1); \
(v_f) = ((uint32_t)(v_f) >> 1) | ((uint32_t)(v_i) << 31); \
(v_i) = ((uint32_t)(v_i) >> 1); \
} while (false)
#define M_RSHIFT(v_i, v_f) /* v >>= 1, v is signed */ \
do { \
(v_f) = ((u_int32)(v_f) >> 1) | ((u_int32)(v_i) << 31); \
(v_i) = ((u_int32)(v_i) >> 1) | ((u_int32)(v_i) & 0x80000000); \
(v_f) = ((uint32_t)(v_f) >> 1) | ((uint32_t)(v_i) << 31); \
(v_i) = ((uint32_t)(v_i) >> 1) | ((uint32_t)(v_i) & 0x80000000); \
} while (false)
#define M_LSHIFT(v_i, v_f) /* v <<= 1 */ \
do { \
(v_i) = ((u_int32)(v_i) << 1) | ((u_int32)(v_f) >> 31); \
(v_f) = ((u_int32)(v_f) << 1); \
(v_i) = ((uint32_t)(v_i) << 1) | ((uint32_t)(v_f) >> 31); \
(v_f) = ((uint32_t)(v_f) << 1); \
} while (false)
#define M_LSHIFT3(v_o, v_i, v_f) /* v <<= 1, with overflow */ \
do { \
(v_o) = ((u_int32)(v_o) << 1) | ((u_int32)(v_i) >> 31); \
(v_i) = ((u_int32)(v_i) << 1) | ((u_int32)(v_f) >> 31); \
(v_f) = ((u_int32)(v_f) << 1); \
(v_o) = ((uint32_t)(v_o) << 1) | ((uint32_t)(v_i) >> 31); \
(v_i) = ((uint32_t)(v_i) << 1) | ((uint32_t)(v_f) >> 31); \
(v_f) = ((uint32_t)(v_f) << 1); \
} while (false)
#define M_ADDUF(r_i, r_f, uf) /* r += uf, uf is u_int32 fraction */ \
#define M_ADDUF(r_i, r_f, uf) /* r += uf, uf is uint32_t fraction */ \
M_ADD((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */
#define M_SUBUF(r_i, r_f, uf) /* r -= uf, uf is u_int32 fraction */ \
#define M_SUBUF(r_i, r_f, uf) /* r -= uf, uf is uint32_t fraction */ \
M_SUB((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */
#define M_ADDF(r_i, r_f, f) /* r += f, f is a int32 fraction */ \
#define M_ADDF(r_i, r_f, f) /* r += f, f is a int32_t fraction */ \
do { \
int32 add_f = (int32)(f); \
int32_t add_f = (int32_t)(f); \
if (add_f >= 0) \
M_ADD((r_i), (r_f), 0, (uint32)( add_f)); \
else \
......@@ -204,23 +204,23 @@ typedef u_int32 u_fp;
(((v_i) & 0x80000000) != 0)
#define M_ISGT(a_i, a_f, b_i, b_f) /* a > b signed */ \
(((u_int32)((a_i) ^ 0x80000000) > (u_int32)((b_i) ^ 0x80000000)) || \
((a_i) == (b_i) && ((u_int32)(a_f)) > ((u_int32)(b_f))))
(((uint32_t)((a_i) ^ 0x80000000) > (uint32_t)((b_i) ^ 0x80000000)) || \
((a_i) == (b_i) && ((uint32_t)(a_f)) > ((uint32_t)(b_f))))
#define M_ISGTU(a_i, a_f, b_i, b_f) /* a > b unsigned */ \
(((u_int32)(a_i)) > ((u_int32)(b_i)) || \
((a_i) == (b_i) && ((u_int32)(a_f)) > ((u_int32)(b_f))))
(((uint32_t)(a_i)) > ((uint32_t)(b_i)) || \
((a_i) == (b_i) && ((uint32_t)(a_f)) > ((uint32_t)(b_f))))
#define M_ISHIS(a_i, a_f, b_i, b_f) /* a >= b unsigned */ \
(((u_int32)(a_i)) > ((u_int32)(b_i)) || \
((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
(((uint32_t)(a_i)) > ((uint32_t)(b_i)) || \
((a_i) == (b_i) && ((uint32_t)(a_f)) >= ((uint32_t)(b_f))))
#define M_ISGEQ(a_i, a_f, b_i, b_f) /* a >= b signed */ \
(((u_int32)((a_i) ^ 0x80000000) > (u_int32)((b_i) ^ 0x80000000)) || \
((a_i) == (b_i) && (u_int32)(a_f) >= (u_int32)(b_f)))
(((uint32_t)((a_i) ^ 0x80000000) > (uint32_t)((b_i) ^ 0x80000000)) || \
((a_i) == (b_i) && (uint32_t)(a_f) >= (uint32_t)(b_f)))
#define M_ISEQU(a_i, a_f, b_i, b_f) /* a == b unsigned */ \
((u_int32)(a_i) == (u_int32)(b_i) && (u_int32)(a_f) == (u_int32)(b_f))
((uint32_t)(a_i) == (uint32_t)(b_i) && (uint32_t)(a_f) == (uint32_t)(b_f))
/*
* Operations on the long fp format
......@@ -289,8 +289,8 @@ typedef u_int32 u_fp;
if (M_isneg) { \
q_tmp = ~q_tmp + 1; \
} \
(r_uf) = (u_int32)q_tmp; \
(r_ui) = (u_int32)(q_tmp >> 32); \
(r_uf) = (uint32_t)q_tmp; \
(r_ui) = (uint32_t)(q_tmp >> 32); \
} while (false)
#define M_LFPTOD(r_ui, r_uf, d) /* l_fp to double */ \
......@@ -317,17 +317,17 @@ typedef u_int32 u_fp;
do { \
double d_tmp; \
if ((d_tmp = (d)) < 0) { \
(r_ui) = (u_int32)(-d_tmp); \
(r_uf) = (u_int32)(-(d_tmp + (double)(r_ui)) * FRAC); \
(r_ui) = (uint32_t)(-d_tmp); \
(r_uf) = (uint32_t)(-(d_tmp + (double)(r_ui)) * FRAC); \
M_NEG((r_ui), (r_uf)); \
} else { \
(r_ui) = (u_int32)d_tmp; \
(r_uf) = (u_int32)((d_tmp - (double)(r_ui)) * FRAC); \
(r_ui) = (uint32_t)d_tmp; \
(r_uf) = (uint32_t)((d_tmp - (double)(r_ui)) * FRAC); \
} \
} while (0)
#define M_LFPTOD(r_ui, r_uf, d) /* l_fp to double */ \
do { \
u_int32 l_thi, l_tlo; \
uint32_t l_thi, l_tlo; \
l_thi = (r_ui); l_tlo = (r_uf); \
if (M_ISNEG(l_thi)) { \
M_NEG(l_thi, l_tlo); \
......@@ -345,7 +345,7 @@ typedef u_int32 u_fp;
* Prototypes
*/
extern char * dofptoa (u_fp, int, short, int);
extern char * dolfptoa (u_int32, u_int32, int, short, int);
extern char * dolfptoa (uint32_t, uint32_t, int, short, int);
extern bool atolfp (const char *, l_fp *);
extern int buftvtots (const char *, l_fp *);
......@@ -357,7 +357,7 @@ extern bool mstolfp (const char *, l_fp *);
extern char * prettydate (l_fp *);
extern char * gmprettydate (l_fp *);
extern char * uglydate (l_fp *);
extern void mfp_mul (int32 *, u_int32 *, int32, u_int32, int32, u_int32);
extern void mfp_mul (int32_t *, uint32_t *, int32_t, uint32_t, int32_t, uint32_t);
extern void set_sys_fuzz (double);
extern void init_systime (void);
......@@ -365,7 +365,7 @@ extern void get_systime (l_fp *);
extern int step_systime (double);
extern int adj_systime (double);
extern struct tm * ntp2unix_tm (u_int32 ntp, int local);
extern struct tm * ntp2unix_tm (uint32_t ntp, int local);
#define lfptoa(fpv, ndec) mfptoa((fpv)->l_ui, (fpv)->l_uf, (ndec))
#define lfptoms(fpv, ndec) mfptoms((fpv)->l_ui, (fpv)->l_uf, (ndec))
......
......@@ -71,16 +71,16 @@ struct refclockstat {
u_char haveflags; /* bit array of valid flags */
u_short lencode; /* length of last timecode */
const char *p_lastcode; /* last timecode received */
u_int32 polls; /* transmit polls */
u_int32 noresponse; /* no response to poll */
u_int32 badformat; /* bad format timecode received */
u_int32 baddata; /* invalid data timecode received */
u_int32 timereset; /* driver resets */
uint32_t polls; /* transmit polls */
uint32_t noresponse; /* no response to poll */
uint32_t badformat; /* bad format timecode received */
uint32_t baddata; /* invalid data timecode received */
uint32_t timereset; /* driver resets */
const char *clockdesc; /* ASCII description */
double fudgetime1; /* configure fudge time1 */
double fudgetime2; /* configure fudge time2 */
int32 fudgeval1; /* configure fudge value1 */
u_int32 fudgeval2; /* configure fudge value2 */
int32_t fudgeval1; /* configure fudge value1 */
uint32_t fudgeval2; /* configure fudge value2 */
u_char currentstatus; /* clock status */
u_char lastevent; /* last exception event */
u_char leap; /* leap bits */
......@@ -119,8 +119,8 @@ struct refclockbug {
u_char nvalues; /* values following */
u_char ntimes; /* times following */
u_short svalues; /* values format sign array */
u_int32 stimes; /* times format sign array */
u_int32 values[NCLKBUGVALUES]; /* real values */
uint32_t stimes; /* times format sign array */
uint32_t values[NCLKBUGVALUES]; /* real values */
l_fp times[NCLKBUGTIMES]; /* real times */
};
......@@ -139,11 +139,11 @@ extern HANDLE WaitableIoEventHandle;
#define MAXDIAL 60 /* max length of modem dial strings */
/*
* It's ugly that refid is sometimes treated as a u_int32 and sometimes
* It's ugly that refid is sometimes treated as a uint32_t and sometimes
* as a string; that should be fixed. Using this in memcpy() at least
* contains the problem.
*/
#define REFIDLEN sizeof(u_int32)
#define REFIDLEN sizeof(uint32_t)
struct refclockproc {
void * unitptr; /* pointer to unit structure */
......@@ -182,7 +182,7 @@ struct refclockproc {
double fudgetime1; /* fudge time1 */
double fudgetime2; /* fudge time2 */
u_char stratum; /* server stratum */
u_int32 refid; /* reference identifier */
uint32_t refid; /* reference identifier */
u_char sloppyclockflag; /* fudge flags */
/*
......
This diff is collapsed.
......@@ -29,7 +29,7 @@ extern int mvsnprintf(char *, size_t, const char *, va_list)
extern int msnprintf(char *, size_t, const char *, ...)
NTP_PRINTF(3, 4);
extern void msyslog(int, const char *, ...) NTP_PRINTF(2, 3);
extern void init_logging (const char *, u_int32, int);
extern void init_logging (const char *, uint32_t, int);
extern int change_logfile (const char *, int);
extern void setup_logfile (const char *);
#ifndef errno_to_str
......@@ -62,8 +62,8 @@ typedef void (*ctrl_c_fn)(void);
/* authkeys.c */
extern void auth_delkeys (void);
extern int auth_havekey (keyid_t);
extern int authdecrypt (keyid_t, u_int32 *, int, int);
extern int authencrypt (keyid_t, u_int32 *, int);
extern int authdecrypt (keyid_t, uint32_t *, int, int);
extern int authencrypt (keyid_t, uint32_t *, int);
extern int authhavekey (keyid_t);
extern int authistrusted (keyid_t);
extern bool authreadkeys (const char *);
......@@ -76,13 +76,13 @@ extern bool authusekey (keyid_t, int, const u_char *);
* the NTP timestamp properly, or the current system time if the
* pivot pointer is NULL.
*/
extern u_int32 calyearstart (u_int32 ntptime, const time_t *pivot);
extern u_int32 calmonthstart (u_int32 ntptime, const time_t *pivot);
extern u_int32 calweekstart (u_int32 ntptime, const time_t *pivot);
extern u_int32 caldaystart (u_int32 ntptime, const time_t *pivot);
extern uint32_t calyearstart (uint32_t ntptime, const time_t *pivot);
extern uint32_t calmonthstart (uint32_t ntptime, const time_t *pivot);
extern uint32_t calweekstart (uint32_t ntptime, const time_t *pivot);
extern uint32_t caldaystart (uint32_t ntptime, const time_t *pivot);
extern const char *clockname (int);
extern int clocktime (int, int, int, int, int, u_int32, u_long *, u_int32 *);
extern int clocktime (int, int, int, int, int, uint32_t, u_long *, uint32_t *);
extern int ntp_getopt (int, char **, const char *);
extern void init_auth (void);
extern void init_lib (void);
......@@ -92,10 +92,10 @@ extern void auth_prealloc_symkeys(int);
extern int ymd2yd (int, int, int);
/* a_md5encrypt.c */
extern int MD5authdecrypt (int, u_char *, u_int32 *, int, int);
extern int MD5authencrypt (int, u_char *, u_int32 *, int);
extern int MD5authdecrypt (int, u_char *, uint32_t *, int, int);
extern int MD5authencrypt (int, u_char *, uint32_t *, int);
extern void MD5auth_setkey (keyid_t, int, const u_char *, size_t);
extern u_int32 addr2refid (sockaddr_u *);
extern uint32_t addr2refid (sockaddr_u *);
/* emalloc.c */
#ifndef EREALLOC_CALLSITE /* ntp_malloc.h defines */
......@@ -129,20 +129,20 @@ extern bool atouint (const char *, u_long *);
extern bool hextoint (const char *, u_long *);
extern const char * humanlogtime (void);
extern const char * humantime (time_t);
extern char * mfptoa (u_int32, u_int32, short);
extern char * mfptoms (u_int32, u_int32, short);
extern char * mfptoa (uint32_t, uint32_t, short);
extern char * mfptoms (uint32_t, uint32_t, short);
extern const char * modetoa (size_t);
extern const char * eventstr (int);
extern const char * ceventstr (int);
extern const char * res_match_flags(u_short);
extern const char * res_access_flags(u_short);
#ifdef KERNEL_PLL
extern const char * k_st_flags (u_int32);
extern const char * k_st_flags (uint32_t);
#endif
extern char * statustoa (int, int);
extern sockaddr_u * netof (sockaddr_u *);
extern char * numtoa (u_int32);
extern char * numtohost (u_int32);
extern char * numtoa (uint32_t);
extern char * numtohost (uint32_t);
extern const char * socktoa (const sockaddr_u *);
extern const char * sockporttoa(const sockaddr_u *);
extern u_short sock_hash (const sockaddr_u *);
......@@ -151,7 +151,7 @@ extern const char * socktohost (const sockaddr_u *);
extern bool octtoint (const char *, u_long *);
extern u_long ranp2 (int);
extern const char *refnumtoa (sockaddr_u *);
extern const char *refid_str (u_int32, int);
extern const char *refid_str (uint32_t, int);
extern bool decodenetnum (const char *, sockaddr_u *);
......
......@@ -5,7 +5,7 @@
#ifndef NTP_SYSLOG_H
#define NTP_SYSLOG_H
#include <ntp_types.h> /* u_int32 type */
#include <ntp_types.h> /* uint32_t type */
#ifdef VMS
extern void msyslog();
......@@ -72,7 +72,7 @@ extern char * syslog_abs_fname;
#define NLOG_SYNCSTATUS 0x00004000 /* sync status (sync/unsync) */
#define NLOG_SYNCSTATIST 0x00008000 /* sync statistics output */
extern u_int32 ntp_syslogmask;
extern uint32_t ntp_syslogmask;
#define NLOG(bits) if (ntp_syslogmask & (bits))
......
/*
* ntp_types.h - defines how int32 and u_int32 are treated.
* ntp_types.h - NTP basic types and macros.
*
* New style: Make sure C99 fixed width integer types are available:
* intN_t and uintN_t
* Old style: 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
* Assume C99 fixed width integer types are available: int32_t and uint32_t
*/
#ifndef NTP_TYPES_H
#define NTP_TYPES_H
#include <sys/types.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
......@@ -47,68 +41,6 @@
*/
#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;
#endif /* VMS */
#ifdef HAVE_UINT32_T
# ifndef HAVE_INT32
typedef int32_t int32;
# endif
# ifndef HAVE_U_INT32
typedef uint32_t u_int32;
# if defined(UINT32_MAX) && !defined(U_INT32_MAX)
# define U_INT32_MAX UINT32_MAX
# endif
# endif
#elif (SIZEOF_INT == 4)
# if !defined(HAVE_INT32) && !defined(int32)
typedef int int32;
# ifndef INT32_MIN
# define INT32_MIN INT_MIN
# endif
# ifndef INT32_MAX
# define INT32_MAX INT_MAX
# endif
# endif
# if !defined(HAVE_U_INT32) && !defined(u_int32)
typedef unsigned u_int32;
# if defined(UINT_MAX) && !defined(U_INT32_MAX)
# define U_INT32_MAX UINT_MAX
# endif
# endif
#else /* SIZEOF_INT != 4 */
# if (SIZEOF_LONG == 4)
# if !defined(HAVE_INT32) && !defined(int32)
typedef long int32;
# ifndef INT32_MIN
# define INT32_MIN LONG_MIN
# endif
# ifndef INT32_MAX
# define INT32_MAX LONG_MAX
# endif
# endif
# if !defined(HAVE_U_INT32) && !defined(u_int32)
typedef unsigned long u_int32;
# if defined(ULONG_MAX) && !defined(U_INT32_MAX)
# define U_INT32_MAX ULONG_MAX
# endif
# endif
# else /* SIZEOF_LONG != 4 */
# include "Bletch: what's 32 bits on this machine?"
# endif
#endif /* !HAVE_UINT32_T && SIZEOF_INT != 4 */
#ifndef U_INT32_MAX
# define U_INT32_MAX 0xffffffff
#endif
/*
* Ugly dance to find out if we have 64bit integer type.
*/
......@@ -166,10 +98,10 @@ typedef union {
uint16_t hh; uint16_t hl; uint16_t lh; uint16_t ll;
} W_s;
struct {
int32 hi; u_int32 lo;
int32_t hi; uint32_t lo;
} d_s;
struct {
u_int32 hi; u_int32 lo;
uint32_t hi; uint32_t lo;
} D_s;
# else
struct {
......@@ -179,10 +111,10 @@ typedef union {
uint16_t ll; uint16_t lh; uint16_t hl; uint16_t hh;
} W_s;
struct {
u_int32 lo; int32 hi;
uint32_t lo; int32_t hi;
} d_s;
struct {
u_int32 lo; u_int32 hi;
uint32_t lo; uint32_t hi;
} D_s;
# endif
......@@ -193,17 +125,11 @@ typedef union {
} vint64; /* variant int 64 */
typedef uint8_t ntp_u_int8_t;
typedef uint16_t ntp_u_int16_t;
typedef uint32_t ntp_u_int32_t;
typedef struct ntp_uint64_t { u_int32 val[2]; } ntp_uint64_t;
typedef uint16_t associd_t; /* association ID */
#define ASSOCID_MAX USHRT_MAX
typedef u_int32 keyid_t; /* cryptographic key ID */
typedef uint32_t keyid_t; /* cryptographic key ID */
#define KEYID_T_MAX (0xffffffff)
typedef u_int32 tstamp_t; /* NTP seconds timestamp */
typedef uint32_t tstamp_t; /* NTP seconds timestamp */
/*
* Cloning malloc()'s behavior of always returning pointers suitably
......
......@@ -109,7 +109,7 @@ typedef struct interface_info {
typedef void (*interface_receiver_t) (void *, interface_info_t *);
extern void interface_enumerate (interface_receiver_t, void *);
extern endpt * getinterface (sockaddr_u *, u_int32);
extern endpt * getinterface (sockaddr_u *, uint32_t);
extern endpt * select_peerinterface (struct peer *, sockaddr_u *,
endpt *);
extern endpt * findinterface (sockaddr_u *);
......@@ -174,13 +174,13 @@ extern struct peer *findpeerbyassoc(associd_t);
extern void set_peerdstadr (struct peer *, endpt *);
extern struct peer *newpeer (sockaddr_u *, const char *,
endpt *, u_char, u_char,
u_char, u_char, u_int, u_char, u_int32,
u_char, u_char, u_int, u_char, uint32_t,
keyid_t, const char *);
extern void peer_all_reset (void);
extern void peer_clr_stats (void);
extern struct peer *peer_config(sockaddr_u *, const char *,
endpt *, u_char, u_char,
u_char, u_char, u_int, u_int32,
u_char, u_char, u_int, uint32_t,
keyid_t, const char *);
extern void peer_reset (struct peer *);
extern void refresh_all_peerinterfaces(void);
......@@ -286,8 +286,8 @@ extern void record_loop_stats (double, double, double, double, int);
extern void record_clock_stats (sockaddr_u *, const char *);
extern int mprintf_clock_stats(sockaddr_u *, const char *, ...)
NTP_PRINTF(2, 3);
extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid);
extern void check_leap_file (int is_daily_check, u_int32 ntptime, const time_t * systime);
extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, uint32_t refid);
extern void check_leap_file (int is_daily_check, uint32_t ntptime, const time_t * systime);
extern void record_crypto_stats (sockaddr_u *, const char *);
#ifdef DEBUG
extern void record_timing_stats (const char *);
......@@ -467,7 +467,7 @@ extern u_char sys_stratum; /* system stratum */
extern s_char sys_precision; /* local clock precision */
extern double sys_rootdelay; /* roundtrip delay to primary source */
extern double sys_rootdisp; /* dispersion to primary source */
extern u_int32 sys_refid; /* reference id */
extern uint32_t sys_refid; /* reference id */
extern l_fp sys_reftime; /* last update time */
extern struct peer *sys_peer; /* current peer */
......@@ -515,7 +515,7 @@ extern int ntp_minpkt;