From 2e45f5d8086a3a0700e7926ea3f802ce8e13616d Mon Sep 17 00:00:00 2001 From: Matt Ullman Date: Wed, 23 Mar 2016 22:33:54 -0400 Subject: [PATCH 1/2] Cleanup more BSD-isms --- authd/reslib.h | 16 ++++++++-------- configure.ac | 30 ++---------------------------- include/hash.h | 8 ++++---- ircd/hash.c | 16 ++++++++-------- 4 files changed, 22 insertions(+), 48 deletions(-) diff --git a/authd/reslib.h b/authd/reslib.h index 38f7b8f39..e8917130c 100644 --- a/authd/reslib.h +++ b/authd/reslib.h @@ -78,24 +78,24 @@ typedef struct */ #define IRC_NS_GET16(s, cp) { \ const unsigned char *t_cp = (const unsigned char *)(cp); \ - (s) = ((u_int16_t)t_cp[0] << 8) \ - | ((u_int16_t)t_cp[1]) \ + (s) = ((uint16_t)t_cp[0] << 8) \ + | ((uint16_t)t_cp[1]) \ ; \ (cp) += NS_INT16SZ; \ } #define IRC_NS_GET32(l, cp) { \ const unsigned char *t_cp = (const unsigned char *)(cp); \ - (l) = ((u_int32_t)t_cp[0] << 24) \ - | ((u_int32_t)t_cp[1] << 16) \ - | ((u_int32_t)t_cp[2] << 8) \ - | ((u_int32_t)t_cp[3]) \ + (l) = ((uint32_t)t_cp[0] << 24) \ + | ((uint32_t)t_cp[1] << 16) \ + | ((uint32_t)t_cp[2] << 8) \ + | ((uint32_t)t_cp[3]) \ ; \ (cp) += NS_INT32SZ; \ } #define IRC_NS_PUT16(s, cp) { \ - u_int16_t t_s = (u_int16_t)(s); \ + uint16_t t_s = (uint16_t)(s); \ unsigned char *t_cp = (unsigned char *)(cp); \ *t_cp++ = t_s >> 8; \ *t_cp = t_s; \ @@ -103,7 +103,7 @@ typedef struct } #define IRC_NS_PUT32(l, cp) { \ - u_int32_t t_l = (u_int32_t)(l); \ + uint32_t t_l = (uint32_t)(l); \ unsigned char *t_cp = (unsigned char *)(cp); \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ diff --git a/configure.ac b/configure.ac index 333a793d8..2911f973b 100644 --- a/configure.ac +++ b/configure.ac @@ -188,34 +188,8 @@ dnl Check for stdarg.h - if we can't find it, halt configure AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - charybdis will not compile without it **])]) AC_CHECK_FUNCS([strlcat strlcpy]) -AC_CHECK_TYPE([u_int32_t], [], -[ - AC_CHECK_TYPE([uint32_t], - [ - AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.]) - ], - [ - AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int]) - AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.]) - ]) -]) - -AC_CHECK_TYPE([u_int16_t], [], -[ - AC_CHECK_TYPE([uint16_t], - [ - AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute]) - ], - [ - AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int]) - AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.]) - ]) -]) - -AC_CHECK_TYPE([in_port_t], [], -[AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])], -[[#include -#include ]]) +AC_TYPE_INT16_T +AC_TYPE_INT32_T AC_CHECK_TYPE([sa_family_t], [], [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])], diff --git a/include/hash.h b/include/hash.h index 4aba22ccf..c2d220dbb 100644 --- a/include/hash.h +++ b/include/hash.h @@ -65,10 +65,10 @@ struct ConfItem; struct cachefile; struct nd_entry; -extern u_int32_t fnv_hash_upper(const unsigned char *s, int bits); -extern u_int32_t fnv_hash(const unsigned char *s, int bits); -extern u_int32_t fnv_hash_len(const unsigned char *s, int bits, int len); -extern u_int32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len); +extern uint32_t fnv_hash_upper(const unsigned char *s, int bits); +extern uint32_t fnv_hash(const unsigned char *s, int bits); +extern uint32_t fnv_hash_len(const unsigned char *s, int bits, int len); +extern uint32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len); extern void init_hash(void); diff --git a/ircd/hash.c b/ircd/hash.c index c1ef81cbc..172734d3a 100644 --- a/ircd/hash.c +++ b/ircd/hash.c @@ -70,10 +70,10 @@ init_hash(void) hostname_tree = rb_radixtree_create("hostname", irccasecanon); } -u_int32_t +uint32_t fnv_hash_upper(const unsigned char *s, int bits) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; while (*s) { @@ -85,10 +85,10 @@ fnv_hash_upper(const unsigned char *s, int bits) return h; } -u_int32_t +uint32_t fnv_hash(const unsigned char *s, int bits) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; while (*s) { @@ -100,10 +100,10 @@ fnv_hash(const unsigned char *s, int bits) return h; } -u_int32_t +uint32_t fnv_hash_len(const unsigned char *s, int bits, int len) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; const unsigned char *x = s + len; while (*s && s < x) { @@ -115,10 +115,10 @@ fnv_hash_len(const unsigned char *s, int bits, int len) return h; } -u_int32_t +uint32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; const unsigned char *x = s + len; while (*s && s < x) { From cf623e08025ebed7542cfc829e70fa1b9ded4b08 Mon Sep 17 00:00:00 2001 From: Matt Ullman Date: Wed, 23 Mar 2016 22:51:03 -0400 Subject: [PATCH 2/2] authd: Fix windows build Replace stray NO with false --- authd/getaddrinfo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/authd/getaddrinfo.c b/authd/getaddrinfo.c index e0524b35e..43384c426 100644 --- a/authd/getaddrinfo.c +++ b/authd/getaddrinfo.c @@ -30,6 +30,7 @@ #ifdef _WIN32 #include #include "getaddrinfo.h" +#include "stdinc.h" static const char in_addrany[] = { 0, 0, 0, 0 }; static const char in_loopback[] = { 127, 0, 0, 1 }; @@ -187,7 +188,8 @@ str_isnumber(const char *p) char *ep; if (*p == '\0') - return NO; + return false; + ep = NULL; errno = 0; (void)strtoul(p, &ep, 10);