Mercurial > dovecot > original-hg > dovecot-1.2
changeset 56:62fc6c729962 HEAD
64bit off_t fixes
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 28 Aug 2002 02:39:53 +0300 |
parents | db8ea2c11ab7 |
children | 2d2e2594e60f |
files | configure.in src/lib/compat.h src/lib/iobuffer.c src/lib/lib.h src/lib/strfuncs.h |
diffstat | 5 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.in Wed Aug 28 02:27:56 2002 +0300 +++ b/configure.in Wed Aug 28 02:39:53 2002 +0300 @@ -146,7 +146,7 @@ AC_DEFINE(UOFF_T_INT) elif test x$sizeof_off_t = x$ac_cv_sizeof_long_long; then # and finally long long - AC_DEFINE_UNQUOTED(OFF_T_MAX, LONG_LONG_MAX) + AC_DEFINE_UNQUOTED(OFF_T_MAX, LLONG_MAX) AC_DEFINE_UNQUOTED(UOFF_T_FORMAT, "llu") AC_DEFINE(UOFF_T_LONG_LONG) else
--- a/src/lib/compat.h Wed Aug 28 02:27:56 2002 +0300 +++ b/src/lib/compat.h Wed Aug 28 02:39:53 2002 +0300 @@ -1,6 +1,12 @@ #ifndef __COMPAT_H #define __COMPAT_H +/* well, this is obviously wrong since it assumes it's 64bit, but older + GCCs don't define it and we really want it. */ +#ifndef LLONG_MAX +# define LLONG_MAX 9223372036854775807LL +#endif + /* memmove() */ #ifndef HAVE_MEMMOVE # define memmove my_memmove
--- a/src/lib/iobuffer.c Wed Aug 28 02:27:56 2002 +0300 +++ b/src/lib/iobuffer.c Wed Aug 28 02:39:53 2002 +0300 @@ -457,10 +457,15 @@ #ifdef HAVE_SYS_SENDFILE_H static void block_loop_sendfile(IOBufferBlockContext *ctx) { + off_t offset; int ret; - ret = sendfile(ctx->outbuf->fd, ctx->inbuf->fd, - &ctx->inbuf->offset, ctx->size); + i_assert(ctx->inbuf->offset < OFF_T_MAX); + + offset = (off_t)ctx->inbuf->offset; + ret = sendfile(ctx->outbuf->fd, ctx->inbuf->fd, &offset, ctx->size); + ctx->inbuf->offset = (uoff_t)offset; + if (ret < 0) { if (errno != EINTR && errno != EAGAIN) ctx->outbuf->closed = TRUE; @@ -476,12 +481,18 @@ unsigned int size) { IOBufferBlockContext ctx; + off_t offset; int ret; + i_assert(inbuf->offset < OFF_T_MAX); + io_buffer_send_flush(outbuf); /* first try if we can do it with a single sendfile() call */ - ret = sendfile(outbuf->fd, inbuf->fd, &inbuf->offset, size); + offset = (off_t)inbuf->offset; + ret = sendfile(outbuf->fd, inbuf->fd, &offset, size); + inbuf->offset = (uoff_t)offset; + if (ret < 0) { if (errno != EINTR && errno != EAGAIN) return -1;
--- a/src/lib/lib.h Wed Aug 28 02:27:56 2002 +0300 +++ b/src/lib/lib.h Wed Aug 28 02:39:53 2002 +0300 @@ -4,6 +4,7 @@ /* default system includes - keep these at minimum.. */ #include <string.h> /* strcmp() etc. */ #include <stdarg.h> /* va_list is used everywhere */ +#include <limits.h> /* INT_MAX, etc. */ #include <errno.h> /* error checking is good */ #include <sys/types.h> /* many other includes want this */
--- a/src/lib/strfuncs.h Wed Aug 28 02:27:56 2002 +0300 +++ b/src/lib/strfuncs.h Wed Aug 28 02:39:53 2002 +0300 @@ -1,8 +1,6 @@ #ifndef __STRFUNC_H #define __STRFUNC_H -#include <limits.h> - /* max. size for %d and %ld */ #define MAX_INT_STRLEN ((sizeof(int) * CHAR_BIT + 2) / 3 + 1) #define MAX_LONG_STRLEN ((sizeof(long) * CHAR_BIT + 2) / 3 + 1)