mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 03:44:22 -04:00
Make evbuffer_add_file take ev_off_t, not off_t
This change has no effect on non-windows platforms, since those either define off_t to 64-bits, or allow you to decide whether it should be 64-bits yourself via some LARGEFILE-like macro. On Windows, however, off_t is always 32-bit, so it's a bad choice for "file size" or "file offset" values. Instead, I'm adding an ev_off_t type, and using it in the one place where we used off_t to mean "the size of a file" or "an offset into a file" in the API. This breaks ABI compatibility on Windows.
This commit is contained in:
parent
2c66983a6d
commit
ac7e52d84d
4
buffer.c
4
buffer.c
@ -2642,7 +2642,7 @@ done:
|
||||
*/
|
||||
int
|
||||
evbuffer_add_file(struct evbuffer *outbuf, int fd,
|
||||
off_t offset, off_t length)
|
||||
ev_off_t offset, ev_off_t length)
|
||||
{
|
||||
#if defined(USE_SENDFILE) || defined(_EVENT_HAVE_MMAP)
|
||||
struct evbuffer_chain *chain;
|
||||
@ -2738,7 +2738,7 @@ evbuffer_add_file(struct evbuffer *outbuf, int fd,
|
||||
return (-1);
|
||||
|
||||
#ifdef WIN32
|
||||
#define lseek _lseek
|
||||
#define lseek _lseeki64
|
||||
#endif
|
||||
if (lseek(fd, offset, SEEK_SET) == -1) {
|
||||
evbuffer_free(tmp);
|
||||
|
@ -375,8 +375,8 @@ int evbuffer_add_reference(struct evbuffer *outbuf,
|
||||
@return 0 if successful, or -1 if an error occurred
|
||||
*/
|
||||
|
||||
int evbuffer_add_file(struct evbuffer *output, int fd, off_t offset,
|
||||
off_t length);
|
||||
int evbuffer_add_file(struct evbuffer *output, int fd, ev_off_t offset,
|
||||
ev_off_t length);
|
||||
|
||||
/**
|
||||
Append a formatted string to the end of an evbuffer.
|
||||
|
@ -161,6 +161,12 @@ extern "C" {
|
||||
#define ev_ssize_t ssize_t
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define ev_off_t ev_int64_t
|
||||
#else
|
||||
#define ev_off_t off_t
|
||||
#endif
|
||||
|
||||
/* Limits for integer types.
|
||||
|
||||
We're making two assumptions here:
|
||||
|
Loading…
x
Reference in New Issue
Block a user