summaryrefslogtreecommitdiff
path: root/pjlib/src/pj
diff options
context:
space:
mode:
authorRiza Sulistyo <riza@teluu.com>2013-06-19 06:47:43 +0000
committerRiza Sulistyo <riza@teluu.com>2013-06-19 06:47:43 +0000
commitd7aa4332dae06ae890053dd13239ddabee46b86c (patch)
tree34c599b317369bcc33827d5ee1200604a6599164 /pjlib/src/pj
parent7949b9e53b97281cfa4526ffe5cf7c7d887b7025 (diff)
Re #1680: Add initial support for Win64
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4537 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj')
-rw-r--r--pjlib/src/pj/activesock.c6
-rw-r--r--pjlib/src/pj/errno.c2
-rw-r--r--pjlib/src/pj/fifobuf.c10
-rw-r--r--pjlib/src/pj/file_io_win32.c4
-rw-r--r--pjlib/src/pj/hash.c4
-rw-r--r--pjlib/src/pj/ioqueue_common_abs.c8
-rw-r--r--pjlib/src/pj/ioqueue_select.c5
-rw-r--r--pjlib/src/pj/log.c16
-rw-r--r--pjlib/src/pj/os_core_win32.c9
-rw-r--r--pjlib/src/pj/os_error_win32.c6
-rw-r--r--pjlib/src/pj/os_info.c4
-rw-r--r--pjlib/src/pj/pool.c6
-rw-r--r--pjlib/src/pj/pool_buf.c4
-rw-r--r--pjlib/src/pj/pool_caching.c8
-rw-r--r--pjlib/src/pj/pool_dbg.c5
-rw-r--r--pjlib/src/pj/sock_bsd.c25
-rw-r--r--pjlib/src/pj/ssl_sock_ossl.c22
-rw-r--r--pjlib/src/pj/string.c2
-rw-r--r--pjlib/src/pj/timer.c7
-rw-r--r--pjlib/src/pj/unicode_win32.c11
20 files changed, 88 insertions, 76 deletions
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 s1<s2 ? s2 : s1;
@@ -72,7 +72,7 @@ PJ_DEF(void*) pj_fifobuf_alloc (pj_fifobuf_t *fifobuf, unsigned size)
/* try to allocate from the end part of the fifo */
if (fifobuf->uend >= 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 <pj/pool_i.h>
#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);
if (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 <windows.h>
# 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 <timer_ids_> 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 <windows.h>
-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';