From d7aa4332dae06ae890053dd13239ddabee46b86c Mon Sep 17 00:00:00 2001 From: Riza Sulistyo Date: Wed, 19 Jun 2013 06:47:43 +0000 Subject: Re #1680: Add initial support for Win64 git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4537 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/build/pjlib.vcproj | 6460 ++++++++++++++++++++------- pjlib/build/pjlib_test.vcproj | 3428 +++++++++++--- pjlib/include/pj/compat/errno.h | 3 +- pjlib/include/pj/compat/socket.h | 3 +- pjlib/include/pj/config.h | 13 +- pjlib/include/pj/config_site_sample.h | 2 +- pjlib/include/pj/except.h | 4 +- pjlib/include/pj/pool.h | 2 +- pjlib/include/pj/string_i.h | 6 +- pjlib/include/pj/types.h | 12 +- pjlib/include/pj/unicode.h | 8 +- pjlib/src/pj/activesock.c | 6 +- pjlib/src/pj/errno.c | 2 +- pjlib/src/pj/fifobuf.c | 10 +- pjlib/src/pj/file_io_win32.c | 4 +- pjlib/src/pj/hash.c | 4 +- pjlib/src/pj/ioqueue_common_abs.c | 8 +- pjlib/src/pj/ioqueue_select.c | 5 +- pjlib/src/pj/log.c | 16 +- pjlib/src/pj/os_core_win32.c | 9 +- pjlib/src/pj/os_error_win32.c | 6 +- pjlib/src/pj/os_info.c | 4 +- pjlib/src/pj/pool.c | 6 +- pjlib/src/pj/pool_buf.c | 4 +- pjlib/src/pj/pool_caching.c | 8 +- pjlib/src/pj/pool_dbg.c | 5 +- pjlib/src/pj/sock_bsd.c | 25 +- pjlib/src/pj/ssl_sock_ossl.c | 22 +- pjlib/src/pj/string.c | 2 +- pjlib/src/pj/timer.c | 7 +- pjlib/src/pj/unicode_win32.c | 11 +- pjlib/src/pjlib-test/errno.c | 5 +- pjlib/src/pjlib-test/ioq_perf.c | 4 +- pjlib/src/pjlib-test/ioq_tcp.c | 10 +- pjlib/src/pjlib-test/ioq_udp.c | 7 +- pjlib/src/pjlib-test/ioq_unreg.c | 4 +- pjlib/src/pjlib-test/list.c | 5 +- pjlib/src/pjlib-test/pool.c | 5 +- pjlib/src/pjlib-test/sock_perf.c | 4 +- pjlib/src/pjlib-test/ssl_sock.c | 11 +- pjlib/src/pjlib-test/timer.c | 3 +- pjlib/src/pjlib-test/udp_echo_srv_ioqueue.c | 8 +- pjlib/src/pjlib-test/udp_echo_srv_sync.c | 2 +- 43 files changed, 7872 insertions(+), 2301 deletions(-) (limited to 'pjlib') diff --git a/pjlib/build/pjlib.vcproj b/pjlib/build/pjlib.vcproj index d50db471..6a217a0b 100644 --- a/pjlib/build/pjlib.vcproj +++ b/pjlib/build/pjlib.vcproj @@ -11,16 +11,19 @@ Name="Win32" /> + @@ -129,7 +132,7 @@ /> @@ -195,7 +198,7 @@ /> - - - - + + @@ -450,7 +446,7 @@ /> - - - - @@ -648,7 +627,7 @@ /> + + - - - - @@ -930,9 +902,9 @@ /> @@ -996,9 +968,9 @@ /> - - @@ -1158,7 +1122,7 @@ /> @@ -1224,7 +1188,7 @@ /> - - @@ -1413,7 +1370,7 @@ /> @@ -1479,7 +1436,7 @@ /> + + + + + + + + + + + + + + + + + @@ -1545,7 +1560,7 @@ /> @@ -1611,7 +1626,7 @@ /> + + + + + + + + + + + + + + + + + + + + + @@ -1761,9 +1851,9 @@ /> @@ -1827,9 +1917,9 @@ /> @@ -1866,7 +1956,7 @@ /> @@ -1932,7 +2022,7 @@ /> @@ -1998,7 +2088,7 @@ /> @@ -2064,7 +2154,7 @@ /> @@ -2130,7 +2220,7 @@ /> @@ -2196,7 +2286,7 @@ /> @@ -2553,9 +2643,9 @@ /> @@ -2619,9 +2709,9 @@ /> @@ -2685,9 +2775,9 @@ /> @@ -2750,41 +2840,2142 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + - - - - - - + + + + + + + + - - - - + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - @@ -6997,17 +9995,7 @@ /> - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -140,7 +143,7 @@ @@ -206,7 +209,7 @@ + @@ -284,26 +294,25 @@ Name="VCBscMakeTool" /> - - + @@ -350,24 +362,22 @@ Name="VCBscMakeTool" /> - - @@ -404,7 +414,7 @@ @@ -470,7 +480,7 @@ + @@ -616,24 +632,22 @@ Name="VCBscMakeTool" /> - - @@ -670,7 +684,7 @@ @@ -736,7 +750,7 @@ + @@ -814,24 +835,90 @@ Name="VCBscMakeTool" /> + + - + + - + + + + + + + + + + + + + + + + @@ -868,7 +955,7 @@ @@ -934,7 +1021,7 @@ + AdditionalDependencies="netapi32.lib mswsock.lib ws2_32.lib odbc32.lib odbccp32.lib oleaut32.lib ole32.lib" + OutputFile="..\bin\pjlib-test-$(TargetCPU)-$(PlatformName)-vc$(VSVer)-$(ConfigurationName).exe" + /> + @@ -1080,24 +1173,22 @@ Name="VCBscMakeTool" /> - - @@ -1134,7 +1225,7 @@ @@ -1200,7 +1291,7 @@ + @@ -1278,24 +1376,90 @@ Name="VCBscMakeTool" /> + + - + + - + + + + + + + + + + + + + + + + @@ -1332,7 +1496,7 @@ @@ -1398,7 +1562,7 @@ @@ -1559,9 +1725,9 @@ /> @@ -1625,9 +1791,9 @@ /> @@ -1664,7 +1830,7 @@ @@ -1730,7 +1896,7 @@ @@ -1796,7 +1962,7 @@ @@ -1862,7 +2028,7 @@ - @@ -1944,22 +2106,24 @@ Name="VCBscMakeTool" /> - - @@ -1996,7 +2160,7 @@ @@ -2062,7 +2226,7 @@ @@ -2128,7 +2292,7 @@ @@ -2194,7 +2358,7 @@ @@ -2260,7 +2424,7 @@ @@ -2326,7 +2490,7 @@ - @@ -2408,22 +2568,156 @@ Name="VCBscMakeTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2487,9 +2781,9 @@ /> @@ -2553,9 +2847,9 @@ /> @@ -2592,7 +2886,7 @@ @@ -2658,7 +2952,7 @@ @@ -2724,7 +3018,7 @@ + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - - - - - - - - - - - - - - - - diff --git a/pjlib/include/pj/config_site_sample.h b/pjlib/include/pj/config_site_sample.h index 559f74ad..c48ea8ea 100644 --- a/pjlib/include/pj/config_site_sample.h +++ b/pjlib/include/pj/config_site_sample.h @@ -475,7 +475,7 @@ # define PJ_HASH_USE_OWN_TOLOWER 1 # define PJSIP_UNESCAPE_IN_PLACE 1 -# ifdef PJ_WIN32 +# if defined(PJ_WIN32) || defined(PJ_WIN64) # define PJSIP_MAX_NET_EVENTS 10 # endif diff --git a/pjlib/include/pj/except.h b/pjlib/include/pj/except.h index efe42e7b..9369825c 100644 --- a/pjlib/include/pj/except.h +++ b/pjlib/include/pj/except.h @@ -339,9 +339,9 @@ public: * stack. */ struct pj_exception_state_t -{ - struct pj_exception_state_t *prev; /**< Previous state in the list. */ +{ pj_jmp_buf state; /**< jmp_buf. */ + struct pj_exception_state_t *prev; /**< Previous state in the list. */ }; /** diff --git a/pjlib/include/pj/pool.h b/pjlib/include/pj/pool.h index 3e9c76d5..9adaeca9 100644 --- a/pjlib/include/pj/pool.h +++ b/pjlib/include/pj/pool.h @@ -856,7 +856,7 @@ struct pj_caching_pool /** * Internal pool. */ - char pool_buf[256 * (sizeof(long) / 4)]; + char pool_buf[256 * (sizeof(size_t) / 4)]; /** * Mutex. diff --git a/pjlib/include/pj/string_i.h b/pjlib/include/pj/string_i.h index 98b97dc6..53794864 100644 --- a/pjlib/include/pj/string_i.h +++ b/pjlib/include/pj/string_i.h @@ -145,7 +145,7 @@ PJ_IDEF(int) pj_strcmp( const pj_str_t *str1, const pj_str_t *str2) } else if (str2->slen == 0) { return 1; } else { - int min = (str1->slen < str2->slen)? str1->slen : str2->slen; + pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen; int res = pj_memcmp(str1->ptr, str2->ptr, min); if (res == 0) { return (str1->slen < str2->slen) ? -1 : @@ -213,7 +213,7 @@ PJ_IDEF(int) pj_stricmp( const pj_str_t *str1, const pj_str_t *str2) } else if (str2->slen == 0) { return 1; } else { - int min = (str1->slen < str2->slen)? str1->slen : str2->slen; + pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen; int res = pj_ansi_strnicmp(str1->ptr, str2->ptr, min); if (res == 0) { return (str1->slen < str2->slen) ? -1 : @@ -355,7 +355,7 @@ PJ_IDEF(void) pj_strcat(pj_str_t *dst, const pj_str_t *src) PJ_IDEF(void) pj_strcat2(pj_str_t *dst, const char *str) { - unsigned len = str? pj_ansi_strlen(str) : 0; + pj_size_t len = str? pj_ansi_strlen(str) : 0; if (len) { pj_memcpy(dst->ptr + dst->slen, str, len); dst->slen += len; diff --git a/pjlib/include/pj/types.h b/pjlib/include/pj/types.h index 04e426b5..420ddd9b 100644 --- a/pjlib/include/pj/types.h +++ b/pjlib/include/pj/types.h @@ -58,7 +58,11 @@ typedef unsigned char pj_uint8_t; typedef size_t pj_size_t; /** Large signed integer. */ -typedef long pj_ssize_t; +#if defined(PJ_WIN64) && PJ_WIN64!=0 + typedef pj_int64_t pj_ssize_t; +#else + typedef long pj_ssize_t; +#endif /** Status code. */ typedef int pj_status_t; @@ -250,7 +254,11 @@ typedef struct pj_pipe_t pj_pipe_t; typedef void *pj_oshandle_t; /** Socket handle. */ -typedef long pj_sock_t; +#if defined(PJ_WIN64) && PJ_WIN64!=0 + typedef pj_int64_t pj_sock_t; +#else + typedef long pj_sock_t; +#endif /** Generic socket address. */ typedef void pj_sockaddr_t; diff --git a/pjlib/include/pj/unicode.h b/pjlib/include/pj/unicode.h index 47e5fe2b..503bc240 100644 --- a/pjlib/include/pj/unicode.h +++ b/pjlib/include/pj/unicode.h @@ -47,8 +47,8 @@ PJ_BEGIN_DECL * * @return The Unicode string, NULL terminated. */ -PJ_DECL(wchar_t*) pj_ansi_to_unicode(const char *str, pj_size_t len, - wchar_t *wbuf, pj_size_t wbuf_count); +PJ_DECL(wchar_t*) pj_ansi_to_unicode(const char *str, int len, + wchar_t *wbuf, int wbuf_count); /** @@ -61,8 +61,8 @@ PJ_DECL(wchar_t*) pj_ansi_to_unicode(const char *str, pj_size_t len, * * @return The ANSI string, NULL terminated. */ -PJ_DECL(char*) pj_unicode_to_ansi(const wchar_t *wstr, pj_size_t len, - char *buf, pj_size_t buf_size); +PJ_DECL(char*) pj_unicode_to_ansi(const wchar_t *wstr, pj_ssize_t len, + char *buf, int buf_size); #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 diff --git a/pjlib/src/pj/activesock.c b/pjlib/src/pj/activesock.c index bbe10676..0f322834 100644 --- a/pjlib/src/pj/activesock.c +++ b/pjlib/src/pj/activesock.c @@ -370,7 +370,7 @@ PJ_DEF(pj_status_t) pj_activesock_start_read2( pj_activesock_t *asock, pj_ssize_t size_to_read; r->pkt = (pj_uint8_t*)readbuf[i]; - r->max_size = size_to_read = buff_size; + size_to_read = r->max_size = buff_size; status = pj_ioqueue_recv(asock->key, &r->op_key, r->pkt, &size_to_read, PJ_IOQUEUE_ALWAYS_ASYNC | flags); @@ -429,7 +429,7 @@ PJ_DEF(pj_status_t) pj_activesock_start_recvfrom2( pj_activesock_t *asock, pj_ssize_t size_to_read; r->pkt = (pj_uint8_t*) readbuf[i]; - r->max_size = size_to_read = buff_size; + size_to_read = r->max_size = buff_size; r->src_addr_len = sizeof(r->src_addr); status = pj_ioqueue_recvfrom(asock->key, &r->op_key, r->pkt, @@ -532,7 +532,7 @@ static void ioqueue_on_read_complete(pj_ioqueue_key_t *key, * oriented, it means connection has been closed. For datagram * sockets, it means we've got some error (e.g. EWOULDBLOCK). */ - status = -bytes_read; + status = (pj_status_t)-bytes_read; } /* Set default remainder to zero */ diff --git a/pjlib/src/pj/errno.c b/pjlib/src/pj/errno.c index ae59f450..ebfeb9ed 100644 --- a/pjlib/src/pj/errno.c +++ b/pjlib/src/pj/errno.c @@ -100,7 +100,7 @@ static int pjlib_error(pj_status_t code, char *buf, pj_size_t size) if (len >= size) len = size-1; pj_memcpy(buf, err_str[i].msg, len); buf[len] = '\0'; - return len; + return (int)len; } } #endif diff --git a/pjlib/src/pj/fifobuf.c b/pjlib/src/pj/fifobuf.c index fe023d8f..565a9935 100644 --- a/pjlib/src/pj/fifobuf.c +++ b/pjlib/src/pj/fifobuf.c @@ -47,10 +47,10 @@ PJ_DEF(unsigned) pj_fifobuf_max_size (pj_fifobuf_t *fifobuf) PJ_CHECK_STACK(); if (fifobuf->uend >= fifobuf->ubegin) { - s1 = fifobuf->last - fifobuf->uend; - s2 = fifobuf->ubegin - fifobuf->first; + s1 = (unsigned)(fifobuf->last - fifobuf->uend); + s2 = (unsigned)(fifobuf->ubegin - fifobuf->first); } else { - s1 = s2 = fifobuf->ubegin - fifobuf->uend; + s1 = s2 = (unsigned)(fifobuf->ubegin - fifobuf->uend); } return s1uend >= fifobuf->ubegin) { - available = fifobuf->last - fifobuf->uend; + available = (unsigned)(fifobuf->last - fifobuf->uend); if (available >= size+SZ) { char *ptr = fifobuf->uend; fifobuf->uend += (size+SZ); @@ -92,7 +92,7 @@ PJ_DEF(void*) pj_fifobuf_alloc (pj_fifobuf_t *fifobuf, unsigned size) /* try to allocate from the start part of the fifo */ start = (fifobuf->uend <= fifobuf->ubegin) ? fifobuf->uend : fifobuf->first; - available = fifobuf->ubegin - start; + available = (unsigned)(fifobuf->ubegin - start); if (available >= size+SZ) { char *ptr = start; fifobuf->uend = start + size + SZ; diff --git a/pjlib/src/pj/file_io_win32.c b/pjlib/src/pj/file_io_win32.c index e7c16356..b43c3abe 100644 --- a/pjlib/src/pj/file_io_win32.c +++ b/pjlib/src/pj/file_io_win32.c @@ -124,7 +124,7 @@ PJ_DEF(pj_status_t) pj_file_write( pj_oshandle_t fd, BOOL rc; DWORD bytesWritten; - rc = WriteFile(fd, data, *size, &bytesWritten, NULL); + rc = WriteFile(fd, data, (DWORD)*size, &bytesWritten, NULL); if (!rc) { *size = -1; return PJ_RETURN_OS_ERROR(GetLastError()); @@ -141,7 +141,7 @@ PJ_DEF(pj_status_t) pj_file_read( pj_oshandle_t fd, BOOL rc; DWORD bytesRead; - rc = ReadFile(fd, data, *size, &bytesRead, NULL); + rc = ReadFile(fd, data, (DWORD)*size, &bytesRead, NULL); if (!rc) { *size = -1; return PJ_RETURN_OS_ERROR(GetLastError()); diff --git a/pjlib/src/pj/hash.c b/pjlib/src/pj/hash.c index 7bce8b6e..226d680f 100644 --- a/pjlib/src/pj/hash.c +++ b/pjlib/src/pj/hash.c @@ -141,7 +141,7 @@ static pj_hash_entry **find_entry( pj_pool_t *pool, pj_hash_table_t *ht, if (hval && *hval != 0) { hash = *hval; if (keylen==PJ_HASH_KEY_STRING) { - keylen = pj_ansi_strlen((const char*)key); + keylen = (unsigned)pj_ansi_strlen((const char*)key); } } else { /* This slightly differs with pj_hash_calc() because we need @@ -156,7 +156,7 @@ static pj_hash_entry **find_entry( pj_pool_t *pool, pj_hash_table_t *ht, else hash = hash * PJ_HASH_MULTIPLIER + *p; } - keylen = p - (const unsigned char*)key; + keylen = (unsigned)(p - (const unsigned char*)key); } else { const pj_uint8_t *p = (const pj_uint8_t*)key, *end = p + keylen; diff --git a/pjlib/src/pj/ioqueue_common_abs.c b/pjlib/src/pj/ioqueue_common_abs.c index a5dc3f95..5ccdd3f1 100644 --- a/pjlib/src/pj/ioqueue_common_abs.c +++ b/pjlib/src/pj/ioqueue_common_abs.c @@ -240,7 +240,7 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h) status = PJ_STATUS_FROM_OS(value); } } -#elif defined(PJ_WIN32) && PJ_WIN32!=0 +#elif (defined(PJ_WIN32) && PJ_WIN32!=0) || (defined(PJ_WIN64) && PJ_WIN64!=0) status = PJ_SUCCESS; /* success */ #else /* Excellent information in D.J. Bernstein page: @@ -523,6 +523,7 @@ void ioqueue_dispatch_read_event( pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h ) * that error is easier to catch. */ # if defined(PJ_WIN32) && PJ_WIN32 != 0 || \ + defined(PJ_WIN64) && PJ_WIN64 != 0 || \ defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE != 0 rc = pj_sock_recv(h->fd, read_op->buf, &bytes_read, read_op->flags); @@ -540,7 +541,8 @@ void ioqueue_dispatch_read_event( pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h ) } if (rc != PJ_SUCCESS) { -# if defined(PJ_WIN32) && PJ_WIN32 != 0 +# if (defined(PJ_WIN32) && PJ_WIN32 != 0) || \ + (defined(PJ_WIN64) && PJ_WIN64 != 0) /* On Win32, for UDP, WSAECONNRESET on the receive side * indicates that previous sending has triggered ICMP Port * Unreachable message. @@ -1281,7 +1283,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_post_completion( pj_ioqueue_key_t *key, (*key->cb.on_accept_complete)(key, op_key, PJ_INVALID_SOCKET, - bytes_status); + (pj_status_t)bytes_status); return PJ_SUCCESS; } op_rec = op_rec->next; diff --git a/pjlib/src/pj/ioqueue_select.c b/pjlib/src/pj/ioqueue_select.c index 28a08da0..6be66ae5 100644 --- a/pjlib/src/pj/ioqueue_select.c +++ b/pjlib/src/pj/ioqueue_select.c @@ -202,7 +202,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_create( pj_pool_t *pool, ioqueue = PJ_POOL_ALLOC_T(pool, pj_ioqueue_t); ioqueue_init(ioqueue); - ioqueue->max = max_fd; + ioqueue->max = (unsigned)max_fd; ioqueue->count = 0; PJ_FD_ZERO(&ioqueue->rfdset); PJ_FD_ZERO(&ioqueue->wfdset); @@ -323,6 +323,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_register_sock2(pj_pool_t *pool, { pj_ioqueue_key_t *key = NULL; #if defined(PJ_WIN32) && PJ_WIN32!=0 || \ + defined(PJ_WIN64) && PJ_WIN64 != 0 || \ defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 u_long value; #else @@ -369,6 +370,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_register_sock2(pj_pool_t *pool, /* Set socket to nonblocking. */ value = 1; #if defined(PJ_WIN32) && PJ_WIN32!=0 || \ + defined(PJ_WIN64) && PJ_WIN64 != 0 || \ defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 if (ioctlsocket(sock, FIONBIO, &value)) { #else @@ -762,6 +764,7 @@ static pj_status_t replace_udp_sock(pj_ioqueue_key_t *h) /* Set socket to nonblocking. */ val = 1; #if defined(PJ_WIN32) && PJ_WIN32!=0 || \ + defined(PJ_WIN64) && PJ_WIN64 != 0 || \ defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 if (ioctlsocket(new_sock, FIONBIO, &val)) { #else diff --git a/pjlib/src/pj/log.c b/pjlib/src/pj/log.c index 86bfefdd..47b6b0fc 100644 --- a/pjlib/src/pj/log.c +++ b/pjlib/src/pj/log.c @@ -49,7 +49,8 @@ static unsigned log_decor = PJ_LOG_HAS_TIME | PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_SENDER | PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_SPACE | PJ_LOG_HAS_THREAD_SWC | PJ_LOG_HAS_INDENT -#if defined(PJ_WIN32) && PJ_WIN32!=0 +#if (defined(PJ_WIN32) && PJ_WIN32!=0) || \ + (defined(PJ_WIN64) && PJ_WIN64!=0) | PJ_LOG_HAS_COLOR #endif ; @@ -103,12 +104,12 @@ static void logging_shutdown(void) static void log_set_indent(int indent) { if (indent < 0) indent = 0; - pj_thread_local_set(thread_indent_tls_id, (void*)(long)indent); + pj_thread_local_set(thread_indent_tls_id, (void*)(pj_ssize_t)indent); } static int log_get_raw_indent() { - return (long)pj_thread_local_get(thread_indent_tls_id); + return (long)(pj_ssize_t)pj_thread_local_get(thread_indent_tls_id); } #else @@ -267,7 +268,8 @@ static void suspend_logging(int *saved_level) #if PJ_HAS_THREADS if (thread_suspended_tls_id != -1) { - pj_thread_local_set(thread_suspended_tls_id, (void*)PJ_TRUE); + pj_thread_local_set(thread_suspended_tls_id, + (void*)(pj_ssize_t)PJ_TRUE); } else #endif @@ -378,7 +380,7 @@ PJ_DEF(void) pj_log( const char *sender, int level, } if (log_decor & PJ_LOG_HAS_SENDER) { enum { SENDER_WIDTH = 14 }; - int sender_len = strlen(sender); + pj_size_t sender_len = strlen(sender); if (pre!=log_buffer) *pre++ = ' '; if (sender_len <= SENDER_WIDTH) { while (sender_len < SENDER_WIDTH) @@ -394,7 +396,7 @@ PJ_DEF(void) pj_log( const char *sender, int level, if (log_decor & PJ_LOG_HAS_THREAD_ID) { enum { THREAD_WIDTH = 12 }; const char *thread_name = pj_thread_get_name(pj_thread_this()); - int thread_len = strlen(thread_name); + pj_size_t thread_len = strlen(thread_name); *pre++ = ' '; if (thread_len <= THREAD_WIDTH) { while (thread_len < THREAD_WIDTH) @@ -433,7 +435,7 @@ PJ_DEF(void) pj_log( const char *sender, int level, } #endif - len = pre - log_buffer; + len = (int)(pre - log_buffer); /* Print the whole message to the string log_buffer. */ print_len = pj_ansi_vsnprintf(pre, sizeof(log_buffer)-len, format, diff --git a/pjlib/src/pj/os_core_win32.c b/pjlib/src/pj/os_core_win32.c index 5168d7db..531be6bf 100644 --- a/pjlib/src/pj/os_core_win32.c +++ b/pjlib/src/pj/os_core_win32.c @@ -408,7 +408,7 @@ PJ_DEF(pj_status_t) pj_thread_register ( const char *cstr_thread_name, cstr_thread_name, thread->idthread); else pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), - "thr%p", (void*)thread->idthread); + "thr%p", (void*)(pj_ssize_t)thread->idthread); rc = pj_thread_local_set(thread_tls_id, thread); if (rc != PJ_SUCCESS) @@ -499,7 +499,7 @@ PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool, PJ_LOG(6, (rec->obj_name, "Thread created")); #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 - rec->stk_size = stack_size ? stack_size : 0xFFFFFFFFUL; + rec->stk_size = stack_size ? (pj_uint32_t)stack_size : 0xFFFFFFFFUL; rec->stk_max_usage = 0; #endif @@ -634,8 +634,9 @@ PJ_DEF(void) pj_thread_check_stack(const char *file, int line) pj_assert(thread); /* Calculate current usage. */ - usage = (&stk_ptr > thread->stk_start) ? &stk_ptr - thread->stk_start : - thread->stk_start - &stk_ptr; + usage = (&stk_ptr > thread->stk_start) ? + (pj_uint32_t)(&stk_ptr - thread->stk_start) : + (pj_uint32_t)(thread->stk_start - &stk_ptr); /* Assert if stack usage is dangerously high. */ pj_assert("STACK OVERFLOW!! " && (usage <= thread->stk_size - 128)); diff --git a/pjlib/src/pj/os_error_win32.c b/pjlib/src/pj/os_error_win32.c index c0e0aa59..369f5f2f 100644 --- a/pjlib/src/pj/os_error_win32.c +++ b/pjlib/src/pj/os_error_win32.c @@ -142,7 +142,7 @@ PJ_DEF(void) pj_set_netos_error(pj_status_t code) int platform_strerror( pj_os_err_type os_errcode, char *buf, pj_size_t bufsize) { - int len = 0; + pj_size_t len = 0; PJ_DECL_UNICODE_TEMP_BUF(wbuf,128); pj_assert(buf != NULL); @@ -193,7 +193,7 @@ int platform_strerror( pj_os_err_type os_errcode, os_errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, - bufsize, + (int)bufsize, NULL); buf[bufsize-1] = '\0'; #endif @@ -215,6 +215,6 @@ int platform_strerror( pj_os_err_type os_errcode, buf[len] = '\0'; } - return len; + return (int)len; } diff --git a/pjlib/src/pj/os_info.c b/pjlib/src/pj/os_info.c index f7136c11..dfa486c5 100644 --- a/pjlib/src/pj/os_info.c +++ b/pjlib/src/pj/os_info.c @@ -71,7 +71,7 @@ static char *ver_info(pj_uint32_t ver, char *buf) { - int len; + pj_size_t len; if (ver == 0) { *buf = '\0'; @@ -125,7 +125,7 @@ PJ_DEF(const pj_sys_info*) pj_get_sys_info(void) static char si_buffer[PJ_SYS_INFO_BUFFER_SIZE]; static pj_sys_info si; static pj_bool_t si_initialized; - unsigned left = PJ_SYS_INFO_BUFFER_SIZE, len; + pj_size_t left = PJ_SYS_INFO_BUFFER_SIZE, len; if (si_initialized) return &si; diff --git a/pjlib/src/pj/pool.c b/pjlib/src/pj/pool.c index 623acd9c..3e2e2686 100644 --- a/pjlib/src/pj/pool.c +++ b/pjlib/src/pj/pool.c @@ -31,8 +31,8 @@ # include #endif -#define LOG(expr) PJ_LOG(6,expr) -#define ALIGN_PTR(PTR,ALIGNMENT) (PTR + (-(long)(PTR) & (ALIGNMENT-1))) +#define LOG(expr) PJ_LOG(6,expr) +#define ALIGN_PTR(PTR,ALIGNMENT) (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1))) PJ_DEF_DATA(int) PJ_NO_MEMORY_EXCEPTION; @@ -92,7 +92,7 @@ PJ_DEF(void*) pj_pool_allocate_find(pj_pool_t *pool, pj_size_t size) { pj_pool_block *block = pool->block_list.next; void *p; - unsigned block_size; + pj_size_t block_size; PJ_CHECK_STACK(); diff --git a/pjlib/src/pj/pool_buf.c b/pjlib/src/pj/pool_buf.c index 83561681..13940d47 100644 --- a/pjlib/src/pj/pool_buf.c +++ b/pjlib/src/pj/pool_buf.c @@ -83,7 +83,7 @@ PJ_DEF(pj_pool_t*) pj_pool_create_on_buf(const char *name, { #if PJ_HAS_POOL_ALT_API == 0 struct creation_param param; - long align_diff; + pj_size_t align_diff; PJ_ASSERT_RETURN(buf && size, NULL); @@ -94,7 +94,7 @@ PJ_DEF(pj_pool_t*) pj_pool_create_on_buf(const char *name, } /* Check and align buffer */ - align_diff = (long)buf; + align_diff = (pj_size_t)buf; if (align_diff & (PJ_POOL_ALIGNMENT-1)) { align_diff &= (PJ_POOL_ALIGNMENT-1); buf = (void*) (((char*)buf) + align_diff); diff --git a/pjlib/src/pj/pool_caching.c b/pjlib/src/pj/pool_caching.c index 763e9b04..3a969233 100644 --- a/pjlib/src/pj/pool_caching.c +++ b/pjlib/src/pj/pool_caching.c @@ -191,7 +191,7 @@ static pj_pool_t* cpool_create_pool(pj_pool_factory *pf, pj_list_insert_before( &cp->used_list, pool ); /* Mark factory data */ - pool->factory_data = (void*) (long) idx; + pool->factory_data = (void*) (pj_ssize_t) idx; /* Increment used count. */ ++cp->used_count; @@ -251,7 +251,7 @@ static void cpool_release_pool( pj_pool_factory *pf, pj_pool_t *pool) /* * Otherwise put the pool in our recycle list. */ - i = (unsigned) (unsigned long) pool->factory_data; + i = (unsigned) (unsigned long) (pj_ssize_t) pool->factory_data; pj_assert(i= PJ_CACHING_POOL_ARRAY_SIZE ) { @@ -279,10 +279,10 @@ static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail ) cp->capacity, cp->max_capacity, cp->used_count)); if (detail) { pj_pool_t *pool = (pj_pool_t*) cp->used_list.next; - pj_uint32_t total_used = 0, total_capacity = 0; + pj_size_t total_used = 0, total_capacity = 0; PJ_LOG(3,("cachpool", " Dumping all active pools:")); while (pool != (void*)&cp->used_list) { - unsigned pool_capacity = pj_pool_get_capacity(pool); + pj_size_t pool_capacity = pj_pool_get_capacity(pool); PJ_LOG(3,("cachpool", " %16s: %8d of %8d (%d%%) used", pj_pool_getobjname(pool), pj_pool_get_used_size(pool), diff --git a/pjlib/src/pj/pool_dbg.c b/pjlib/src/pj/pool_dbg.c index c9f714ed..9ea40c9f 100644 --- a/pjlib/src/pj/pool_dbg.c +++ b/pjlib/src/pj/pool_dbg.c @@ -32,8 +32,9 @@ #endif -#if defined(PJ_WIN32) && PJ_WIN32!=0 && defined(PJ_DEBUG) && PJ_DEBUG!=0 \ - && !PJ_NATIVE_STRING_IS_UNICODE +#if ((defined(PJ_WIN32) && PJ_WIN32!=0) || \ + (defined(PJ_WIN64) && PJ_WIN64 != 0)) && \ + defined(PJ_DEBUG) && PJ_DEBUG!=0 && !PJ_NATIVE_STRING_IS_UNICODE # include # define TRACE_(msg) OutputDebugString(msg) #endif diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c index 2862721e..107f5247 100644 --- a/pjlib/src/pj/sock_bsd.c +++ b/pjlib/src/pj/sock_bsd.c @@ -60,7 +60,7 @@ const pj_uint16_t PJ_SOCK_RDM = SOCK_RDM; const pj_uint16_t PJ_SOL_SOCKET = SOL_SOCKET; #ifdef SOL_IP const pj_uint16_t PJ_SOL_IP = SOL_IP; -#elif defined(PJ_WIN32) && PJ_WIN32 +#elif (defined(PJ_WIN32) && PJ_WIN32) || (defined(PJ_WIN64) && PJ_WIN64) const pj_uint16_t PJ_SOL_IP = IPPROTO_IP; #else const pj_uint16_t PJ_SOL_IP = 0; @@ -70,7 +70,7 @@ const pj_uint16_t PJ_SOL_IP = 0; const pj_uint16_t PJ_SOL_TCP = SOL_TCP; #elif defined(IPPROTO_TCP) const pj_uint16_t PJ_SOL_TCP = IPPROTO_TCP; -#elif defined(PJ_WIN32) && PJ_WIN32 +#elif (defined(PJ_WIN32) && PJ_WIN32) || (defined(PJ_WIN64) && PJ_WIN64) const pj_uint16_t PJ_SOL_TCP = IPPROTO_TCP; #else const pj_uint16_t PJ_SOL_TCP = 6; @@ -80,7 +80,7 @@ const pj_uint16_t PJ_SOL_TCP = 6; const pj_uint16_t PJ_SOL_UDP = SOL_UDP; #elif defined(IPPROTO_UDP) const pj_uint16_t PJ_SOL_UDP = IPPROTO_UDP; -#elif defined(PJ_WIN32) && PJ_WIN32 +#elif (defined(PJ_WIN32) && PJ_WIN32) || (defined(PJ_WIN64) && PJ_WIN64) const pj_uint16_t PJ_SOL_UDP = IPPROTO_UDP; #else const pj_uint16_t PJ_SOL_UDP = 17; @@ -88,7 +88,7 @@ const pj_uint16_t PJ_SOL_UDP = 17; #ifdef SOL_IPV6 const pj_uint16_t PJ_SOL_IPV6 = SOL_IPV6; -#elif defined(PJ_WIN32) && PJ_WIN32 +#elif (defined(PJ_WIN32) && PJ_WIN32) || (defined(PJ_WIN64) && PJ_WIN64) # if defined(IPPROTO_IPV6) || (_WIN32_WINNT >= 0x0501) const pj_uint16_t PJ_SOL_IPV6 = IPPROTO_IPV6; # else @@ -304,7 +304,7 @@ PJ_DEF(pj_status_t) pj_inet_pton(int af, const pj_str_t *src, void *dst) return PJ_SUCCESS; -#elif defined(PJ_WIN32) || defined(PJ_WIN32_WINCE) +#elif defined(PJ_WIN32) || defined(PJ_WIN64) || defined(PJ_WIN32_WINCE) /* * Implementation on Windows, using WSAStringToAddress(). * Should also work on Unicode systems. @@ -378,7 +378,7 @@ PJ_DEF(pj_status_t) pj_inet_ntop(int af, const void *src, return PJ_SUCCESS; -#elif defined(PJ_WIN32) || defined(PJ_WIN32_WINCE) +#elif defined(PJ_WIN32) || defined(PJ_WIN64) || defined(PJ_WIN32_WINCE) /* * Implementation on Windows, using WSAAddressToString(). * Should also work on Unicode systems. @@ -461,7 +461,7 @@ PJ_DEF(const pj_str_t*) pj_gethostname(void) return &hostname; } -#if defined(PJ_WIN32) +#if defined(PJ_WIN32) || defined(PJ_WIN64) /* * Create new socket/endpoint for communication and returns a descriptor. */ @@ -474,7 +474,7 @@ PJ_DEF(pj_status_t) pj_sock_socket(int af, /* Sanity checks. */ PJ_ASSERT_RETURN(sock!=NULL, PJ_EINVAL); - PJ_ASSERT_RETURN((unsigned)PJ_INVALID_SOCKET==INVALID_SOCKET, + PJ_ASSERT_RETURN((SOCKET)PJ_INVALID_SOCKET==INVALID_SOCKET, (*sock=PJ_INVALID_SOCKET, PJ_EINVAL)); *sock = WSASocket(af, type, proto, NULL, 0, WSA_FLAG_OVERLAPPED); @@ -599,6 +599,7 @@ PJ_DEF(pj_status_t) pj_sock_close(pj_sock_t sock) PJ_CHECK_STACK(); #if defined(PJ_WIN32) && PJ_WIN32!=0 || \ + defined(PJ_WIN64) && PJ_WIN64 != 0 || \ defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 rc = closesocket(sock); #else @@ -659,7 +660,7 @@ PJ_DEF(pj_status_t) pj_sock_send(pj_sock_t sock, flags |= MSG_NOSIGNAL; #endif - *len = send(sock, (const char*)buf, *len, flags); + *len = send(sock, (const char*)buf, (int)(*len), flags); if (*len < 0) return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); @@ -683,7 +684,7 @@ PJ_DEF(pj_status_t) pj_sock_sendto(pj_sock_t sock, CHECK_ADDR_LEN(to, tolen); - *len = sendto(sock, (const char*)buf, *len, flags, + *len = sendto(sock, (const char*)buf, (int)(*len), flags, (const struct sockaddr*)to, tolen); if (*len < 0) @@ -703,7 +704,7 @@ PJ_DEF(pj_status_t) pj_sock_recv(pj_sock_t sock, PJ_CHECK_STACK(); PJ_ASSERT_RETURN(buf && len, PJ_EINVAL); - *len = recv(sock, (char*)buf, *len, flags); + *len = recv(sock, (char*)buf, (int)(*len), flags); if (*len < 0) return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); @@ -724,7 +725,7 @@ PJ_DEF(pj_status_t) pj_sock_recvfrom(pj_sock_t sock, PJ_CHECK_STACK(); PJ_ASSERT_RETURN(buf && len, PJ_EINVAL); - *len = recvfrom(sock, (char*)buf, *len, flags, + *len = recvfrom(sock, (char*)buf, (int)(*len), flags, (struct sockaddr*)from, (socklen_t*)fromlen); if (*len < 0) diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c index b5098d22..281e6f8a 100644 --- a/pjlib/src/pj/ssl_sock_ossl.c +++ b/pjlib/src/pj/ssl_sock_ossl.c @@ -380,7 +380,7 @@ static int password_cb(char *buf, int num, int rwflag, void *user_data) return 0; pj_memcpy(buf, cert->privkey_pass.ptr, cert->privkey_pass.slen); - return cert->privkey_pass.slen; + return (int)cert->privkey_pass.slen; } @@ -987,7 +987,7 @@ static pj_bool_t on_handshake_complete(pj_ssl_sock_t *ssock, errmsg)); /* Workaround for ticket #985 */ -#if defined(PJ_WIN32) && PJ_WIN32!=0 +#if (defined(PJ_WIN32) && PJ_WIN32!=0) || (defined(PJ_WIN64) && PJ_WIN64!=0) if (ssock->param.timer_heap) { pj_time_val interval = {0, DELAYED_CLOSE_TIMEOUT}; @@ -1130,7 +1130,7 @@ static void free_send_data(pj_ssl_sock_t *ssock, write_data_t *wdata) buf->len -= ((char*)wdata->next - buf->start); } else { /* Overlapped */ - unsigned right_len, left_len; + pj_size_t right_len, left_len; right_len = buf->buf + buf->max_len - (char*)wdata; left_len = (char*)wdata->next - buf->buf; buf->len -= (right_len + left_len); @@ -1138,13 +1138,13 @@ static void free_send_data(pj_ssl_sock_t *ssock, write_data_t *wdata) } else if (spl->prev == wdata) { /* This is the last data, just adjust the buffer length */ if (wdata->prev < wdata) { - unsigned jump_len; + pj_size_t jump_len; jump_len = (char*)wdata - ((char*)wdata->prev + wdata->prev->record_len); buf->len -= (wdata->record_len + jump_len); } else { /* Overlapped */ - unsigned right_len, left_len; + pj_size_t right_len, left_len; right_len = buf->buf + buf->max_len - ((char*)wdata->prev + wdata->prev->record_len); left_len = (char*)wdata + wdata->record_len - buf->buf; @@ -1387,7 +1387,7 @@ static pj_bool_t asock_on_data_read (pj_activesock_t *asock, /* Socket error or closed */ if (data && size > 0) { /* Consume the whole data */ - nwritten = BIO_write(ssock->ossl_rbio, data, size); + nwritten = BIO_write(ssock->ossl_rbio, data, (int)size); if (nwritten < size) { status = GET_SSL_STATUS(ssock); goto on_error; @@ -1413,7 +1413,7 @@ static pj_bool_t asock_on_data_read (pj_activesock_t *asock, do { read_data_t *buf = *(OFFSET_OF_READ_DATA_PTR(ssock, data)); void *data_ = (pj_int8_t*)buf->data + buf->len; - int size_ = ssock->read_size - buf->len; + int size_ = (int)(ssock->read_size - buf->len); /* SSL_read() may write some data to BIO write when re-negotiation * is on progress, so let's protect it with write mutex. @@ -1455,7 +1455,7 @@ static pj_bool_t asock_on_data_read (pj_activesock_t *asock, } else { - int err = SSL_get_error(ssock->ossl_ssl, size); + int err = SSL_get_error(ssock->ossl_ssl, (int)size); /* SSL might just return SSL_ERROR_WANT_READ in * re-negotiation. @@ -1663,7 +1663,7 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock, /* Start read */ status = pj_activesock_start_read2(ssock->asock, ssock->pool, - ssock->param.read_buffer_size, + (unsigned)ssock->param.read_buffer_size, ssock->asock_rbuf, PJ_IOQUEUE_ALWAYS_ASYNC); if (status != PJ_SUCCESS) @@ -1742,7 +1742,7 @@ static pj_bool_t asock_on_connect_complete (pj_activesock_t *asock, /* Start read */ status = pj_activesock_start_read2(ssock->asock, ssock->pool, - ssock->param.read_buffer_size, + (unsigned)ssock->param.read_buffer_size, ssock->asock_rbuf, PJ_IOQUEUE_ALWAYS_ASYNC); if (status != PJ_SUCCESS) @@ -2180,7 +2180,7 @@ static pj_status_t ssl_write(pj_ssl_sock_t *ssock, * until re-negotiation is completed. */ pj_lock_acquire(ssock->write_mutex); - nwritten = SSL_write(ssock->ossl_ssl, data, size); + nwritten = SSL_write(ssock->ossl_ssl, data, (int)size); pj_lock_release(ssock->write_mutex); if (nwritten == size) { diff --git a/pjlib/src/pj/string.c b/pjlib/src/pj/string.c index ca3a4605..5610c907 100644 --- a/pjlib/src/pj/string.c +++ b/pjlib/src/pj/string.c @@ -194,7 +194,7 @@ PJ_DEF(int) pj_utoa_pad( unsigned long val, char *buf, int min_dig, int pad) *p++ = (char) (digval + '0'); } while (val > 0); - len = p-buf; + len = (int)(p-buf); while (len < min_dig) { *p++ = (char)pad; ++len; diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c index 07752f82..b9205c81 100644 --- a/pjlib/src/pj/timer.c +++ b/pjlib/src/pj/timer.c @@ -124,7 +124,8 @@ PJ_INLINE(void) unlock_timer_heap( pj_timer_heap_t *ht ) } -static void copy_node( pj_timer_heap_t *ht, int slot, pj_timer_entry *moved_node ) +static void copy_node( pj_timer_heap_t *ht, pj_size_t slot, + pj_timer_entry *moved_node ) { PJ_CHECK_STACK(); @@ -132,7 +133,7 @@ static void copy_node( pj_timer_heap_t *ht, int slot, pj_timer_entry *moved_node ht->heap[slot] = moved_node; // Update the corresponding slot in the parallel array. - ht->timer_ids[moved_node->_timer_id] = slot; + ht->timer_ids[moved_node->_timer_id] = (int)slot; } static pj_timer_id_t pop_freelist( pj_timer_heap_t *ht ) @@ -235,7 +236,7 @@ static pj_timer_entry * remove_node( pj_timer_heap_t *ht, size_t slot) if (slot < ht->cur_size) { - int parent; + pj_size_t parent; pj_timer_entry *moved_node = ht->heap[ht->cur_size]; // Move the end node to the location being removed and update diff --git a/pjlib/src/pj/unicode_win32.c b/pjlib/src/pj/unicode_win32.c index 999a0404..7718f65b 100644 --- a/pjlib/src/pj/unicode_win32.c +++ b/pjlib/src/pj/unicode_win32.c @@ -23,8 +23,8 @@ #include -PJ_DEF(wchar_t*) pj_ansi_to_unicode(const char *s, pj_size_t len, - wchar_t *buf, pj_size_t buf_count) +PJ_DEF(wchar_t*) pj_ansi_to_unicode(const char *s, int len, + wchar_t *buf, int buf_count) { PJ_ASSERT_RETURN(s && buf, NULL); @@ -41,12 +41,13 @@ PJ_DEF(wchar_t*) pj_ansi_to_unicode(const char *s, pj_size_t len, } -PJ_DEF(char*) pj_unicode_to_ansi( const wchar_t *wstr, pj_size_t len, - char *buf, pj_size_t buf_size) +PJ_DEF(char*) pj_unicode_to_ansi( const wchar_t *wstr, pj_ssize_t len, + char *buf, int buf_size) { PJ_ASSERT_RETURN(wstr && buf, NULL); - len = WideCharToMultiByte(CP_ACP, 0, wstr, len, buf, buf_size, NULL, NULL); + len = WideCharToMultiByte(CP_ACP, 0, wstr, (int)len, buf, buf_size, + NULL, NULL); if (buf_size) { if (len < buf_size) buf[len] = '\0'; diff --git a/pjlib/src/pjlib-test/errno.c b/pjlib/src/pjlib-test/errno.c index a82cfc89..e6d901fe 100644 --- a/pjlib/src/pjlib-test/errno.c +++ b/pjlib/src/pjlib-test/errno.c @@ -28,7 +28,8 @@ #define THIS_FILE "errno" -#if defined(PJ_WIN32) && PJ_WIN32 != 0 +#if (defined(PJ_WIN32) && PJ_WIN32 != 0) || \ + (defined(PJ_WIN64) && PJ_WIN64 != 0) # include #endif @@ -59,7 +60,7 @@ int my_strncasecmp(const char *s1, const char *s2, int max_len) const char *my_stristr(const char *whole, const char *part) { - int part_len = strlen(part); + int part_len = (int)strlen(part); while (*whole) { if (my_strncasecmp(whole, part, part_len) == 0) return whole; diff --git a/pjlib/src/pjlib-test/ioq_perf.c b/pjlib/src/pjlib-test/ioq_perf.c index 54d4d4bd..2dd94442 100644 --- a/pjlib/src/pjlib-test/ioq_perf.c +++ b/pjlib/src/pjlib-test/ioq_perf.c @@ -84,7 +84,7 @@ static void on_read_complete(pj_ioqueue_key_t *key, return; if (bytes_read < 0) { - pj_status_t rc = -bytes_read; + pj_status_t rc = (pj_status_t)-bytes_read; char errmsg[PJ_ERR_MSG_SIZE]; if (rc != last_error) { @@ -424,7 +424,7 @@ static int perform_test(pj_bool_t allow_concur, /* Calculate total bytes received. */ total_received = 0; for (i=0; ivalue) ? 0 : -1; + return ((long)(pj_ssize_t)value == node->value) ? 0 : -1; } #define PJ_SIGNED_ARRAY_SIZE(a) ((int)PJ_ARRAY_SIZE(a)) @@ -207,7 +207,8 @@ int list_test() if (p != &nodes[i]) { return -1; } - p = (list_node*) pj_list_search(&list, (void*)(long)i, &compare_node); + p = (list_node*) pj_list_search(&list, (void*)(pj_ssize_t)i, + &compare_node); pj_assert( p == &nodes[i] ); if (p != &nodes[i]) { return -1; diff --git a/pjlib/src/pjlib-test/pool.c b/pjlib/src/pjlib-test/pool.c index d7af16e4..e3fbb555 100644 --- a/pjlib/src/pjlib-test/pool.c +++ b/pjlib/src/pjlib-test/pool.c @@ -93,7 +93,8 @@ static int pool_alignment_test(void) if (!pool) return -300; -#define IS_ALIGNED(p) ((((unsigned long)p) & (PJ_POOL_ALIGNMENT-1)) == 0) +#define IS_ALIGNED(p) ((((unsigned long)(pj_ssize_t)p) & \ + (PJ_POOL_ALIGNMENT-1)) == 0) for (i=0; ierr = -sent; + st->err = (pj_status_t)-sent; } else { st->sent += sent; @@ -1113,7 +1113,8 @@ static int perf_test(unsigned clients, unsigned ms_handshake_timeout) pj_sockaddr addr, listen_addr; pj_ssl_cert_t *cert = NULL; pj_status_t status; - unsigned i, cli_err = 0, tot_sent = 0, tot_recv = 0; + unsigned i, cli_err = 0; + pj_size_t tot_sent = 0, tot_recv = 0; pj_time_val start; pool = pj_pool_create(mem, "ssl_perf", 256, 256, NULL); diff --git a/pjlib/src/pjlib-test/timer.c b/pjlib/src/pjlib-test/timer.c index 9bc2a82f..9521aa9e 100644 --- a/pjlib/src/pjlib-test/timer.c +++ b/pjlib/src/pjlib-test/timer.c @@ -59,7 +59,8 @@ static int test_timer_heap(void) pj_timer_heap_t *timer; pj_time_val delay; pj_status_t rc; int err=0; - unsigned size, count; + pj_size_t size; + unsigned count; size = pj_timer_heap_mem_size(MAX_COUNT)+MAX_COUNT*sizeof(pj_timer_entry); pool = pj_pool_create( mem, NULL, size, 4000, NULL); diff --git a/pjlib/src/pjlib-test/udp_echo_srv_ioqueue.c b/pjlib/src/pjlib-test/udp_echo_srv_ioqueue.c index 217a8d87..bd701655 100644 --- a/pjlib/src/pjlib-test/udp_echo_srv_ioqueue.c +++ b/pjlib/src/pjlib-test/udp_echo_srv_ioqueue.c @@ -49,13 +49,13 @@ static void on_read_complete(pj_ioqueue_key_t *key, if (bytes_received < 0) { if (-bytes_received != recv_rec->last_err) { - recv_rec->last_err = -bytes_received; - app_perror("...error receiving data", -bytes_received); + recv_rec->last_err = (pj_status_t)-bytes_received; + app_perror("...error receiving data", recv_rec->last_err); } } else if (bytes_received == 0) { /* note: previous error, or write callback */ } else { - pj_atomic_add(total_bytes, bytes_received); + pj_atomic_add(total_bytes, (pj_atomic_value_t)bytes_received); if (!send_rec->is_pending) { pj_ssize_t sent = bytes_received; @@ -106,7 +106,7 @@ static void on_write_complete(pj_ioqueue_key_t *key, struct op_key *send_rec = (struct op_key*)op_key; if (bytes_sent <= 0) { - pj_status_t rc = -bytes_sent; + pj_status_t rc = (pj_status_t)-bytes_sent; if (rc != send_rec->last_err) { send_rec->last_err = rc; app_perror("...send error(2)", rc); diff --git a/pjlib/src/pjlib-test/udp_echo_srv_sync.c b/pjlib/src/pjlib-test/udp_echo_srv_sync.c index a5624208..5e9fdf6b 100644 --- a/pjlib/src/pjlib-test/udp_echo_srv_sync.c +++ b/pjlib/src/pjlib-test/udp_echo_srv_sync.c @@ -46,7 +46,7 @@ static int worker_thread(void *arg) continue; } - pj_atomic_add(total_bytes, len); + pj_atomic_add(total_bytes, (pj_atomic_value_t)len); rc = pj_sock_sendto(sock, buf, &len, 0, &addr, addrlen); if (rc != PJ_SUCCESS) { -- cgit v1.2.3