_evbuffer_chain_pin(chain, EVBUFFER_MEM_PINNED_W);
if ((size_t)at_most > chain->off) {
- b->len = chain->off;
+ /* XXXX Cast is safe for now, since win32 has no
+ mmaped chains. But later, we need to have this
+ add more WSAbufs if chain->off is greater than
+ ULONG_MAX */
+ b->len = (unsigned long)chain->off;
at_most -= chain->off;
} else {
- b->len = at_most;
+ b->len = (unsigned long)at_most;
++i;
break;
}
at_most = evbuffer_get_length(bev->output);
/* XXXX This over-commits. */
- limit = _bufferevent_get_write_max(&beva->bev);
+ /* This is safe so long as bufferevent_get_write_max never returns
+ * more than INT_MAX. That's true for now. XXXX */
+ limit = (int)_bufferevent_get_write_max(&beva->bev);
if (at_most >= (size_t)limit && limit >= 0)
at_most = limit;
}
/* XXXX This over-commits. */
- limit = _bufferevent_get_read_max(&beva->bev);
+ /* XXXX see also not above on cast on _bufferevent_get_write_max() */
+ limit = (int)_bufferevent_get_read_max(&beva->bev);
if (at_most >= (size_t)limit && limit >= 0)
at_most = limit;
}
readmax = _bufferevent_get_read_max(bufev_p);
if (howmuch < 0 || howmuch > readmax) /* The use of -1 for "unlimited"
- * uglifies this code. */
+ * uglifies this code. XXXX */
howmuch = readmax;
if (bufev_p->read_suspended)
goto done;
evbuffer_unfreeze(input, 0);
- res = evbuffer_read(input, fd, howmuch);
+ res = evbuffer_read(input, fd, (int)howmuch); /* XXXX evbuffer_read would do better to take and return ev_ssize_t */
evbuffer_freeze(input, 0);
if (res == -1) {
int res = 0;
short what = BEV_EVENT_WRITING;
int connected = 0;
- int atmost = -1;
+ ev_ssize_t atmost = -1;
_bufferevent_incref_and_lock(bufev);
/** unused space at the beginning of buffer or an offset into a
* file for sendfile buffers. */
- off_t misalign;
+ ev_off_t misalign;
/** Offset into buffer + misalign at which to start writing.
* In other words, the total number of bytes actually stored
/* Helper macro: copies an evbuffer_iovec in ei to a win32 WSABUF in i. */
#define WSABUF_FROM_EVBUFFER_IOV(i,ei) do { \
(i)->buf = (ei)->iov_base; \
- (i)->len = (ei)->iov_len; \
+ (i)->len = (unsigned long)(ei)->iov_len; \
} while (0)
+/* XXXX the cast above is safe for now, but not if we allow mmaps on win64.
+ * See note in buffer_iocp's launch_write function */
/** Set the parent bufferevent object for buf to bev */
void evbuffer_set_parent(struct evbuffer *buf, struct bufferevent *bev);
#define open _open
#define read _read
#define close _close
-#define fstat _fstat
-#define stat _stat
+#define fstat _fstati64
+#define stat _stati64
#endif
/**
return -2;
}
read_so_far = 0;
- while ((r = read(fd, mem+read_so_far, st.st_size - read_so_far)) > 0) {
+#ifdef WIN32
+#define N_TO_READ(x) ((x) > INT_MAX) ? INT_MAX : ((int)(x))
+#else
+#defien N_TO_READ(x) (x)
+#endif
+ while ((r = read(fd, mem+read_so_far, N_TO_READ(st.st_size - read_so_far))) > 0) {
read_so_far += r;
if (read_so_far >= (size_t)st.st_size)
break;
if (!(cp = strchr(ip_as_string, ']'))) {
return -1;
}
- len = cp-(ip_as_string + 1);
+ len = (int) ( cp-(ip_as_string + 1) );
if (len > (int)sizeof(buf)-1) {
return -1;
}
evutil_secure_rng_add_bytes(const char *buf, size_t n)
{
arc4random_addrandom((unsigned char*)buf,
- n>(size_t)INT_MAX ? INT_MAX : n);
+ n>(size_t)INT_MAX ? INT_MAX : (int)n);
}
a += chain->buffer_len;
u += chain->off;
if (chain->next && chain->next->off)
- w += chain->buffer_len - (chain->misalign + chain->off);
+ w += (size_t)(chain->buffer_len - (chain->misalign + chain->off));
chain = chain->next;
}
/* subsequent nonempty chains */
while (chain && chain->off) {
++n;
a += chain->buffer_len;
- w += chain->misalign;
+ w += (size_t)chain->misalign;
u += chain->off;
if (chain->next && chain->next->off)
- w += chain->buffer_len - (chain->misalign + chain->off);
+ w += (size_t) (chain->buffer_len - (chain->misalign + chain->off));
chain = chain->next;
}
/* subsequent empty chains */