From c4c0f38aab52e00e5d2201a294df1cac0eb3c27e Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 19 Mar 2014 14:34:02 -0500 Subject: [PATCH] FS-6294 FS-6308 NetBSD support should work test and report back please. --- libs/apr/configure.ac | 3 +++ libs/esl/src/esl_json.c | 2 +- libs/sofia-sip/.update | 2 +- .../libsofia-sip-ua/sip/sip_tag_class.c | 4 +-- libs/sofia-sip/libsofia-sip-ua/su/su_bm.c | 2 +- .../libsofia-sip-ua/su/su_kqueue_port.c | 25 +++++++++++++------ src/include/switch_utils.h | 2 +- src/switch_json.c | 2 +- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/libs/apr/configure.ac b/libs/apr/configure.ac index 354fa772ba..fa5796ecca 100644 --- a/libs/apr/configure.ac +++ b/libs/apr/configure.ac @@ -1375,6 +1375,9 @@ case $host in *-solaris*) pid_t_fmt='#define APR_PID_T_FMT "ld"' ;; + *-netbsd*) + pid_t_fmt='#define APR_PID_T_FMT "ld"' + ;; *aix4*|*aix5*) ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"' size_t_fmt='#define APR_SIZE_T_FMT "ld"' diff --git a/libs/esl/src/esl_json.c b/libs/esl/src/esl_json.c index 41f9936ff7..176c4603a5 100644 --- a/libs/esl/src/esl_json.c +++ b/libs/esl/src/esl_json.c @@ -40,7 +40,7 @@ ESL_DECLARE(const char *)cJSON_GetErrorPtr(void) {return ep;} static int cJSON_strcasecmp(const char *s1,const char *s2) { if (!s1) return (s1==s2)?0:1;if (!s2) return 1; - for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0; + for(; tolower(*(const unsigned char *)s1) == tolower(*(const unsigned char *)s2); ++s1, ++s2) if(*s1 == 0) return 0; return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2); } diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index bd721b372a..a225165170 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Tue Mar 18 17:42:45 CDT 2014 +Wed Mar 19 14:23:50 CDT 2014 diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sip_tag_class.c b/libs/sofia-sip/libsofia-sip-ua/sip/sip_tag_class.c index 4277ccad70..3fc69e36db 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sip_tag_class.c +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sip_tag_class.c @@ -381,8 +381,8 @@ char const *append_escaped(su_strlst_t *l, return NULL; for (;*n; n++) - if (isupper(*n)) - *n = tolower(*n); + if (isupper(*(const unsigned char *)n)) + *n = tolower(*(const unsigned char *)n); slen = strlen(s); elen = url_esclen(s, HNV_RESERVED); diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c b/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c index eb3e995218..7442a346e0 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c @@ -183,7 +183,7 @@ bm_memcasemem_study0(char const *needle, size_t nlen, bm_fwd_table_t *fwd) fwd->table[i] = (unsigned char)nlen; for (i = 0; i < nlen; i++) { - unsigned char n = tolower(needle[i]); + unsigned char n = tolower((const unsigned char)needle[i]); fwd->table[n] = (unsigned char)(nlen - i - 1); } diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c index f9381288a4..c394895de4 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c @@ -46,6 +46,17 @@ #include +/* INT_TO_UDATA() macros from https://github.com/libevent/libevent */ + +/* Some platforms apparently define the udata field of struct kevent as + * intptr_t, whereas others define it as void*. There doesn't seem to be an + * easy way to tell them apart via autoconf, so we need to use OS macros. */ +#if defined(HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__) +#define INT_TO_UDATA(x) ((intptr_t)(x)) +#else +#define INT_TO_UDATA(x) ((void*)(intptr_t)(x)) +#endif + #define SU_ENABLE_MULTISHOT_KQUEUE 1 #include @@ -246,7 +257,7 @@ int su_kqueue_port_register(su_port_t *self, i = ser->ser_id; flags = (wait->events & SU_WAIT_IN) ? EV_ADD : EV_ADD | EV_DISABLE; - EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)(intptr_t)i); + EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, INT_TO_UDATA(i)); if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) { SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n", wait->fd, "EVFILT_READ", flags, (void *)(intptr_t)i, strerror(errno))); @@ -254,13 +265,13 @@ int su_kqueue_port_register(su_port_t *self, } flags = (wait->events & SU_WAIT_OUT) ? EV_ADD : EV_ADD | EV_DISABLE; - EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)(intptr_t)i); + EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, INT_TO_UDATA(i)); if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) { int error = errno; SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n", wait->fd, "EVFILT_WRITE", flags, (void *)(intptr_t)i, strerror(error))); - EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)(intptr_t)i); + EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, INT_TO_UDATA(i)); kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL); errno = error; @@ -298,14 +309,14 @@ static int su_kqueue_port_deregister0(su_port_t *self, int i, int destroy_wait) wait = ser->ser_wait; - EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)(intptr_t)i); + EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, INT_TO_UDATA(i)); if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) { SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n", wait->fd, "EVFILT_READ", "EV_DELETE", (void *)(intptr_t)i, strerror(errno))); } - EV_SET(ev, wait->fd, EVFILT_WRITE, EV_DELETE, 0, 0, (void *)(intptr_t)i); + EV_SET(ev, wait->fd, EVFILT_WRITE, EV_DELETE, 0, 0, INT_TO_UDATA(i)); if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) { SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n", wait->fd, "EVFILT_WRITE", "EV_DELETE", (void *)(intptr_t)i, @@ -465,7 +476,7 @@ int su_kqueue_port_eventmask(su_port_t *self, int index, int socket, int events) wait->events = events; flags = (wait->events & SU_WAIT_IN) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE; - EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)(intptr_t)index); + EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, INT_TO_UDATA(index)); if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) { SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n", wait->fd, "EVFILT_READ", @@ -474,7 +485,7 @@ int su_kqueue_port_eventmask(su_port_t *self, int index, int socket, int events) } flags = (wait->events & SU_WAIT_OUT) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE; - EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)(intptr_t)index); + EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, INT_TO_UDATA(index)); if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) { SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n", wait->fd, "EVFILT_WRITE", diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 8e768b9af4..751b94632c 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -384,7 +384,7 @@ static inline int switch_dtmftoi(char *s) switch_assert(s); if (!(r = atoi(s))) { - int l = tolower(*s); + int l = tolower((unsigned char)*s); if (l > 96 && l < 101) { r = l - 87; } diff --git a/src/switch_json.c b/src/switch_json.c index ccdaedb83e..7235e88f6f 100644 --- a/src/switch_json.c +++ b/src/switch_json.c @@ -40,7 +40,7 @@ SWITCH_DECLARE(const char *)cJSON_GetErrorPtr() {return ep;} static int cJSON_strcasecmp(const char *s1,const char *s2) { if (!s1) return (s1==s2)?0:1;if (!s2) return 1; - for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0; + for(; tolower(*(const unsigned char *)s1) == tolower(*(const unsigned char *)s2); ++s1, ++s2) if(*s1 == 0) return 0; return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2); }