[ntpsec commit] Use entirely POSIX integer types even in the ISC code.
Eric S. Raymond
esr at ntpsec.org
Wed Oct 21 04:28:28 UTC 2015
Module: ntpsec
Branch: master
Commit: 2f848e7441b46a04c04ca6a6df4d3e4181dcb5de
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=2f848e7441b46a04c04ca6a6df4d3e4181dcb5de
Author: Eric S. Raymond <esr at thyrsus.com>
Date: Wed Oct 21 00:27:36 2015 -0400
Use entirely POSIX integer types even in the ISC code.
---
include/interfaceiter.h | 2 +-
libisc/include/isc/interfaceiter.h | 2 +-
libisc/include/isc/md5.h | 6 +++---
libisc/include/isc/netaddr.h | 6 +++---
libisc/include/isc/random.h | 8 +++----
libisc/include/isc/sha1.h | 4 ++--
libisc/include/isc/types.h | 9 +++-----
libisc/inet_aton.c | 6 +++---
libisc/md5.c | 10 ++++-----
libisc/netaddr.c | 4 ++--
libisc/random.c | 12 +++++------
libisc/sha1.c | 4 ++--
libisc/unix/ifiter_ioctl.c | 2 +-
libisc/unix/include/isc/int.h | 43 --------------------------------------
libisc/unix/include/isc/time.h | 6 +++---
libisc/unix/interfaceiter.c | 8 +++----
libisc/unix/time.c | 20 +++++++++---------
libisc/win32/interfaceiter.c | 10 ++++-----
libisc/win32/time.c | 10 ++++-----
19 files changed, 63 insertions(+), 109 deletions(-)
diff --git a/include/interfaceiter.h b/include/interfaceiter.h
index d97797d..3581cd2 100644
--- a/include/interfaceiter.h
+++ b/include/interfaceiter.h
@@ -44,7 +44,7 @@ struct isc_interface {
isc_netaddr_t netmask; /* Network mask. */
isc_netaddr_t dstaddress; /* Destination address
(point-to-point only). */
- isc_uint32_t flags; /* Flags; see below. */
+ uint32_t flags; /* Flags; see below. */
};
/* Interface flags. */
diff --git a/libisc/include/isc/interfaceiter.h b/libisc/include/isc/interfaceiter.h
index a675664..f995c34 100644
--- a/libisc/include/isc/interfaceiter.h
+++ b/libisc/include/isc/interfaceiter.h
@@ -43,7 +43,7 @@ struct isc_interface {
isc_netaddr_t netmask; /*%< Network mask. */
isc_netaddr_t broadcast; /*&< Broadcast address. */
isc_netaddr_t dstaddress; /*%< Destination address (point-to-point only). */
- isc_uint32_t flags; /*%< Flags; see INTERFACE flags. */
+ uint32_t flags; /*%< Flags; see INTERFACE flags. */
unsigned int ifindex; /*%< Interface index for IP(V6)_MULTICAST_IF. */
};
diff --git a/libisc/include/isc/md5.h b/libisc/include/isc/md5.h
index b11cd28..aac45c4 100644
--- a/libisc/include/isc/md5.h
+++ b/libisc/include/isc/md5.h
@@ -44,9 +44,9 @@ typedef EVP_MD_CTX isc_md5_t;
#else
typedef struct {
- isc_uint32_t buf[4];
- isc_uint32_t bytes[2];
- isc_uint32_t in[16];
+ uint32_t buf[4];
+ uint32_t bytes[2];
+ uint32_t in[16];
} isc_md5_t;
#endif
diff --git a/libisc/include/isc/netaddr.h b/libisc/include/isc/netaddr.h
index b56bb35..167ba8e 100644
--- a/libisc/include/isc/netaddr.h
+++ b/libisc/include/isc/netaddr.h
@@ -23,7 +23,7 @@ struct isc_netaddr {
struct in_addr in;
struct in6_addr in6;
} type;
- isc_uint32_t zone;
+ uint32_t zone;
};
bool
@@ -95,9 +95,9 @@ isc_result_t
isc_netaddr_frompath(isc_netaddr_t *netaddr, const char *path);
void
-isc_netaddr_setzone(isc_netaddr_t *netaddr, isc_uint32_t zone);
+isc_netaddr_setzone(isc_netaddr_t *netaddr, uint32_t zone);
-isc_uint32_t
+uint32_t
isc_netaddr_getzone(const isc_netaddr_t *netaddr);
void
diff --git a/libisc/include/isc/random.h b/libisc/include/isc/random.h
index 1f41419..435aa88 100644
--- a/libisc/include/isc/random.h
+++ b/libisc/include/isc/random.h
@@ -24,13 +24,13 @@
ISC_LANG_BEGINDECLS
void
-isc_random_seed(isc_uint32_t seed);
+isc_random_seed(uint32_t seed);
/*%<
* Set the initial seed of the random state.
*/
void
-isc_random_get(isc_uint32_t *val);
+isc_random_get(uint32_t *val);
/*%<
* Get a random value.
*
@@ -38,8 +38,8 @@ isc_random_get(isc_uint32_t *val);
* val != NULL.
*/
-isc_uint32_t
-isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter);
+uint32_t
+isc_random_jitter(uint32_t max, uint32_t jitter);
/*%<
* Get a random value between (max - jitter) and (max).
* This is useful for jittering timer values.
diff --git a/libisc/include/isc/sha1.h b/libisc/include/isc/sha1.h
index 139b0aa..54ce063 100644
--- a/libisc/include/isc/sha1.h
+++ b/libisc/include/isc/sha1.h
@@ -29,8 +29,8 @@ typedef EVP_MD_CTX isc_sha1_t;
#else
typedef struct {
- isc_uint32_t state[5];
- isc_uint32_t count[2];
+ uint32_t state[5];
+ uint32_t count[2];
unsigned char buffer[ISC_SHA1_BLOCK_LENGTH];
} isc_sha1_t;
#endif
diff --git a/libisc/include/isc/types.h b/libisc/include/isc/types.h
index 2a4d2d8..dc8a26f 100644
--- a/libisc/include/isc/types.h
+++ b/libisc/include/isc/types.h
@@ -9,11 +9,8 @@
#define GUARD_ISC_TYPES_H 1
/*! \file isc/types.h
- * \brief
- * OS-specific types, from the OS-specific include directories.
*/
-#include <isc/int.h>
-
+#include <stdint.h>
#include <stdbool.h>
/*
* XXXDCL This is just for ISC_LIST and ISC_LINK, but gets all of the other
@@ -35,7 +32,7 @@ typedef struct isc_entropysource isc_entropysource_t; /*%< Entropy Source */
typedef struct isc_event isc_event_t; /*%< Event */
typedef ISC_LIST(isc_event_t) isc_eventlist_t; /*%< Event List */
typedef unsigned int isc_eventtype_t; /*%< Event Type */
-typedef isc_uint32_t isc_fsaccess_t; /*%< FS Access */
+typedef uint32_t isc_fsaccess_t; /*%< FS Access */
typedef struct isc_hash isc_hash_t; /*%< Hash */
typedef struct isc_httpd isc_httpd_t; /*%< HTTP client */
typedef void (isc_httpdfree_t)(isc_buffer_t *, void *); /*%< HTTP free function */
@@ -60,7 +57,7 @@ typedef struct isc_quota isc_quota_t; /*%< Quota */
typedef struct isc_random isc_random_t; /*%< Random */
typedef struct isc_ratelimiter isc_ratelimiter_t; /*%< Rate Limiter */
typedef struct isc_region isc_region_t; /*%< Region */
-typedef isc_uint64_t isc_resourcevalue_t; /*%< Resource Value */
+typedef uint64_t isc_resourcevalue_t; /*%< Resource Value */
typedef unsigned int isc_result_t; /*%< Result */
typedef struct isc_rwlock isc_rwlock_t; /*%< Read Write Lock */
typedef struct isc_sockaddr isc_sockaddr_t; /*%< Socket Address */
diff --git a/libisc/inet_aton.c b/libisc/inet_aton.c
index 84f303a..2d27b68 100644
--- a/libisc/inet_aton.c
+++ b/libisc/inet_aton.c
@@ -79,8 +79,8 @@ isc_net_aton(const char *cp, struct in_addr *addr) {
unsigned long val;
int base, n;
unsigned char c;
- isc_uint8_t parts[4];
- isc_uint8_t *pp = parts;
+ uint8_t parts[4];
+ uint8_t *pp = parts;
int digit;
c = *cp;
@@ -132,7 +132,7 @@ isc_net_aton(const char *cp, struct in_addr *addr) {
*/
if (pp >= parts + 3 || val > 0xffU)
return (0);
- *pp++ = (isc_uint8_t)val;
+ *pp++ = (uint8_t)val;
c = *++cp;
} else
break;
diff --git a/libisc/md5.c b/libisc/md5.c
index 48ecadf..6e97af3 100644
--- a/libisc/md5.c
+++ b/libisc/md5.c
@@ -55,12 +55,12 @@ isc_md5_final(isc_md5_t *ctx, unsigned char *digest) {
#else
static void
-byteSwap(isc_uint32_t *buf, unsigned words)
+byteSwap(uint32_t *buf, unsigned words)
{
unsigned char *p = (unsigned char *)buf;
do {
- *buf++ = (isc_uint32_t)((unsigned)p[3] << 8 | p[2]) << 16 |
+ *buf++ = (uint32_t)((unsigned)p[3] << 8 | p[2]) << 16 |
((unsigned)p[1] << 8 | p[0]);
p += 4;
} while (--words);
@@ -106,8 +106,8 @@ isc_md5_invalidate(isc_md5_t *ctx) {
* the data and converts bytes into longwords for this routine.
*/
static void
-transform(isc_uint32_t buf[4], isc_uint32_t const in[16]) {
- register isc_uint32_t a, b, c, d;
+transform(uint32_t buf[4], uint32_t const in[16]) {
+ register uint32_t a, b, c, d;
a = buf[0];
b = buf[1];
@@ -194,7 +194,7 @@ transform(isc_uint32_t buf[4], isc_uint32_t const in[16]) {
*/
void
isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) {
- isc_uint32_t t;
+ uint32_t t;
/* Update byte count */
diff --git a/libisc/netaddr.c b/libisc/netaddr.c
index ba6a066..b514d5b 100644
--- a/libisc/netaddr.c
+++ b/libisc/netaddr.c
@@ -201,14 +201,14 @@ isc_netaddr_fromin6(isc_netaddr_t *netaddr, const struct in6_addr *ina6) {
}
void
-isc_netaddr_setzone(isc_netaddr_t *netaddr, isc_uint32_t zone) {
+isc_netaddr_setzone(isc_netaddr_t *netaddr, uint32_t zone) {
/* we currently only support AF_INET6. */
REQUIRE(netaddr->family == AF_INET6);
netaddr->zone = zone;
}
-isc_uint32_t
+uint32_t
isc_netaddr_getzone(const isc_netaddr_t *netaddr) {
return (netaddr->zone);
}
diff --git a/libisc/random.c b/libisc/random.c
index 3aa566f..81afdd3 100644
--- a/libisc/random.c
+++ b/libisc/random.c
@@ -43,19 +43,19 @@ initialize(void)
}
void
-isc_random_seed(isc_uint32_t seed)
+isc_random_seed(uint32_t seed)
{
initialize();
#ifndef HAVE_ARC4RANDOM
srand(seed);
#else
- arc4random_addrandom((u_char *) &seed, sizeof(isc_uint32_t));
+ arc4random_addrandom((u_char *) &seed, sizeof(uint32_t));
#endif
}
void
-isc_random_get(isc_uint32_t *val)
+isc_random_get(uint32_t *val)
{
REQUIRE(val != NULL);
@@ -81,9 +81,9 @@ isc_random_get(isc_uint32_t *val)
#endif
}
-isc_uint32_t
-isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter) {
- isc_uint32_t rnd;
+uint32_t
+isc_random_jitter(uint32_t max, uint32_t jitter) {
+ uint32_t rnd;
REQUIRE(jitter < max || (jitter == 0 && max == 0));
diff --git a/libisc/sha1.c b/libisc/sha1.c
index c6f9ef1..1017148 100644
--- a/libisc/sha1.c
+++ b/libisc/sha1.c
@@ -117,8 +117,8 @@ typedef union {
* Hash a single 512-bit block. This is the core of the algorithm.
*/
static void
-transform(isc_uint32_t state[5], const unsigned char buffer[64]) {
- isc_uint32_t a, b, c, d, e;
+transform(uint32_t state[5], const unsigned char buffer[64]) {
+ uint32_t a, b, c, d, e;
CHAR64LONG16 *block;
CHAR64LONG16 workspace;
diff --git a/libisc/unix/ifiter_ioctl.c b/libisc/unix/ifiter_ioctl.c
index feb4533..972e9cf 100644
--- a/libisc/unix/ifiter_ioctl.c
+++ b/libisc/unix/ifiter_ioctl.c
@@ -624,7 +624,7 @@ internal_current6(isc_interfaceiter_t *iter) {
if (isc_netaddr_islinklocal(&iter->current.address))
isc_netaddr_setzone(&iter->current.address,
- (isc_uint32_t)lifreq.lifr_index);
+ (uint32_t)lifreq.lifr_index);
/*
* If the interface does not have a address ignore it.
diff --git a/libisc/unix/include/isc/int.h b/libisc/unix/include/isc/int.h
deleted file mode 100644
index 6a6deb1..0000000
--- a/libisc/unix/include/isc/int.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1999-2001 Internet Software Consortium.
- * Copyright 2015 by the NTPsec project contributors
- * SPDX-License-Identifier: ISC
- */
-
-#ifndef GUARD_ISC_INT_H
-#define GUARD_ISC_INT_H 1
-
-/*! \file */
-
-typedef char isc_int8_t;
-typedef unsigned char isc_uint8_t;
-typedef short isc_int16_t;
-typedef unsigned short isc_uint16_t;
-typedef int isc_int32_t;
-typedef unsigned int isc_uint32_t;
-typedef long long isc_int64_t;
-typedef unsigned long long isc_uint64_t;
-
-#define ISC_INT8_MIN -128
-#define ISC_INT8_MAX 127
-#define ISC_UINT8_MAX 255
-
-#define ISC_INT16_MIN -32768
-#define ISC_INT16_MAX 32767
-#define ISC_UINT16_MAX 65535
-
-/*%
- * Note that "int" is 32 bits on all currently supported Unix-like operating
- * systems, but "long" can be either 32 bits or 64 bits, thus the 32 bit
- * constants are not qualified with "L".
- */
-#define ISC_INT32_MIN -2147483648
-#define ISC_INT32_MAX 2147483647
-#define ISC_UINT32_MAX 4294967295U
-
-#define ISC_INT64_MIN -9223372036854775808LL
-#define ISC_INT64_MAX 9223372036854775807LL
-#define ISC_UINT64_MAX 18446744073709551615ULL
-
-#endif /* GUARD_ISC_INT_H */
diff --git a/libisc/unix/include/isc/time.h b/libisc/unix/include/isc/time.h
index 8c540aa..ae3ab56 100644
--- a/libisc/unix/include/isc/time.h
+++ b/libisc/unix/include/isc/time.h
@@ -213,7 +213,7 @@ isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
* The interval is larger than the time since the epoch.
*/
-isc_uint64_t
+uint64_t
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2);
/*%<
* Find the difference in microseconds between time t1 and time t2.
@@ -227,7 +227,7 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2);
*\li The difference of t1 - t2, or 0 if t1 <= t2.
*/
-isc_uint32_t
+uint32_t
isc_time_seconds(const isc_time_t *t);
/*%<
* Return the number of seconds since the epoch stored in a time structure.
@@ -260,7 +260,7 @@ isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp);
*\li Out of range
*/
-isc_uint32_t
+uint32_t
isc_time_nanoseconds(const isc_time_t *t);
/*%<
* Return the number of nanoseconds stored in a time structure.
diff --git a/libisc/unix/interfaceiter.c b/libisc/unix/interfaceiter.c
index 90ec3bf..58dd926 100644
--- a/libisc/unix/interfaceiter.c
+++ b/libisc/unix/interfaceiter.c
@@ -91,7 +91,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
* we only consider unicast link-local addresses.
*/
if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) {
- isc_uint16_t zone16;
+ uint16_t zone16;
memcpy(&zone16, &sa6->sin6_addr.s6_addr[2],
sizeof(zone16));
@@ -99,7 +99,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
if (zone16 != 0) {
/* the zone ID is embedded */
isc_netaddr_setzone(dst,
- (isc_uint32_t)zone16);
+ (uint32_t)zone16);
dst->type.in6.s6_addr[2] = 0;
dst->type.in6.s6_addr[3] = 0;
#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
@@ -115,7 +115,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
zone = if_nametoindex(ifname);
if (zone != 0) {
isc_netaddr_setzone(dst,
- (isc_uint32_t)zone);
+ (uint32_t)zone);
}
#endif
}
@@ -225,7 +225,7 @@ linux_if_inet6_current(isc_interfaceiter_t *iter) {
iter->current.ifindex = ifindex;
if (isc_netaddr_islinklocal(&iter->current.address)) {
isc_netaddr_setzone(&iter->current.address,
- (isc_uint32_t)ifindex);
+ (uint32_t)ifindex);
}
for (i = 0; i < 16; i++) {
if (prefix > 8) {
diff --git a/libisc/unix/time.c b/libisc/unix/time.c
index 5d45342..c1484dd 100644
--- a/libisc/unix/time.c
+++ b/libisc/unix/time.c
@@ -290,15 +290,15 @@ isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
return (ISC_R_SUCCESS);
}
-isc_uint64_t
+uint64_t
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
- isc_uint64_t i1, i2, i3;
+ uint64_t i1, i2, i3;
REQUIRE(t1 != NULL && t2 != NULL);
INSIST(t1->nanoseconds < NS_PER_S && t2->nanoseconds < NS_PER_S);
- i1 = (isc_uint64_t)t1->seconds * NS_PER_S + t1->nanoseconds;
- i2 = (isc_uint64_t)t2->seconds * NS_PER_S + t2->nanoseconds;
+ i1 = (uint64_t)t1->seconds * NS_PER_S + t1->nanoseconds;
+ i2 = (uint64_t)t2->seconds * NS_PER_S + t2->nanoseconds;
if (i1 <= i2)
return (0);
@@ -313,12 +313,12 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
return (i3);
}
-isc_uint32_t
+uint32_t
isc_time_seconds(const isc_time_t *t) {
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
- return ((isc_uint32_t)t->seconds);
+ return ((uint32_t)t->seconds);
}
isc_result_t
@@ -347,8 +347,8 @@ isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp) {
*/
seconds = (time_t)t->seconds;
- INSIST(sizeof(unsigned int) == sizeof(isc_uint32_t));
- INSIST(sizeof(time_t) >= sizeof(isc_uint32_t));
+ INSIST(sizeof(unsigned int) == sizeof(uint32_t));
+ INSIST(sizeof(time_t) >= sizeof(uint32_t));
if (t->seconds > (~0U>>1) && seconds <= (time_t)(~0U>>1))
return (ISC_R_RANGE);
@@ -358,13 +358,13 @@ isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp) {
return (ISC_R_SUCCESS);
}
-isc_uint32_t
+uint32_t
isc_time_nanoseconds(const isc_time_t *t) {
REQUIRE(t != NULL);
ENSURE(t->nanoseconds < NS_PER_S);
- return ((isc_uint32_t)t->nanoseconds);
+ return ((uint32_t)t->nanoseconds);
}
void
diff --git a/libisc/win32/interfaceiter.c b/libisc/win32/interfaceiter.c
index 4f35200..499f848 100644
--- a/libisc/win32/interfaceiter.c
+++ b/libisc/win32/interfaceiter.c
@@ -89,12 +89,12 @@ static PGETADAPTERSADDRESSES pGAA;
static void
get_broadcastaddr(isc_netaddr_t *bcastaddr, isc_netaddr_t *addr, isc_netaddr_t *netmask) {
- isc_uint32_t * b;
- isc_uint32_t a, n;
+ uint32_t * b;
+ uint32_t a, n;
- b = (isc_uint32_t *)&bcastaddr->type.in;
- a = *(isc_uint32_t *)&addr->type.in;
- n = *(isc_uint32_t *)&netmask->type.in;
+ b = (uint32_t *)&bcastaddr->type.in;
+ a = *(uint32_t *)&addr->type.in;
+ n = *(uint32_t *)&netmask->type.in;
*b = a | ~n;
}
diff --git a/libisc/win32/time.c b/libisc/win32/time.c
index f929a9b..f692e97 100644
--- a/libisc/win32/time.c
+++ b/libisc/win32/time.c
@@ -189,7 +189,7 @@ isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
return (ISC_R_SUCCESS);
}
-isc_uint64_t
+uint64_t
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
ULARGE_INTEGER i1, i2;
LONGLONG i3;
@@ -212,7 +212,7 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
return (i3);
}
-isc_uint32_t
+uint32_t
isc_time_seconds(const isc_time_t *t) {
SYSTEMTIME epoch = { 1970, 1, 4, 1, 0, 0, 0, 0 };
FILETIME temp;
@@ -228,16 +228,16 @@ isc_time_seconds(const isc_time_t *t) {
i3 = (i1.QuadPart - i2.QuadPart) / 10000000;
- return ((isc_uint32_t)i3);
+ return ((uint32_t)i3);
}
-isc_uint32_t
+uint32_t
isc_time_nanoseconds(const isc_time_t *t) {
ULARGE_INTEGER i;
i.LowPart = t->absolute.dwLowDateTime;
i.HighPart = t->absolute.dwHighDateTime;
- return ((isc_uint32_t)(i.QuadPart % 10000000) * 100);
+ return ((uint32_t)(i.QuadPart % 10000000) * 100);
}
void
More information about the vc
mailing list