From: Vsevolod Stakhov Date: Tue, 27 Mar 2012 14:46:21 +0000 (+0400) Subject: Use 64 bit offset while compiled in 32 bit mode. X-Git-Tag: 0.5.0~50 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d450657c9040e77057fdcaf2151537f7ad46580f;p=rspamd.git Use 64 bit offset while compiled in 32 bit mode. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ac5fded7..80045a4bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,7 +208,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") SET(LOCALSTATES_PREFIX "/var/run/rspamd") ENDIF(NOT LOCALSTATES_PREFIX) ENDIF(CMAKE_INSTALL_PREFIX) - + IF(BUILD_CPU_MODE STREQUAL "32") + SET(CMAKE_C_FLAGS "-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE ${CMAKE_C_FLAGS}") + ENDIF(BUILD_CPU_MODE STREQUAL "32") # Workaround with architecture specific includes IF(IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/") INCLUDE_DIRECTORIES("/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/") diff --git a/src/aio_event.c b/src/aio_event.c index e11b7ec83..8608e9d4c 100644 --- a/src/aio_event.c +++ b/src/aio_event.c @@ -307,7 +307,7 @@ rspamd_aio_open (struct aio_context *ctx, const gchar *path, int flags) * Asynchronous read of file */ gint -rspamd_aio_read (gint fd, gpointer buf, gsize len, off_t offset, struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud) +rspamd_aio_read (gint fd, gpointer buf, gsize len, guint64 offset, struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud) { struct io_cbdata *cbdata; gint r = -1; @@ -354,7 +354,11 @@ rspamd_aio_read (gint fd, gpointer buf, gsize len, off_t offset, struct aio_cont else { /* Blocking variant */ blocking: +#ifdef _LARGEFILE64_SOURCE + r = lseek64 (fd, offset, SEEK_SET); +#else r = lseek (fd, offset, SEEK_SET); +#endif if (r > 0) { r = read (fd, buf, len); if (r >= 0) { @@ -373,7 +377,7 @@ blocking: * Asynchronous write of file */ gint -rspamd_aio_write (gint fd, gpointer buf, gsize len, off_t offset, struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud) +rspamd_aio_write (gint fd, gpointer buf, gsize len, guint64 offset, struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud) { struct io_cbdata *cbdata; gint r = -1; @@ -424,7 +428,11 @@ rspamd_aio_write (gint fd, gpointer buf, gsize len, off_t offset, struct aio_con else { /* Blocking variant */ blocking: +#ifdef _LARGEFILE64_SOURCE + r = lseek64 (fd, offset, SEEK_SET); +#else r = lseek (fd, offset, SEEK_SET); +#endif if (r > 0) { r = write (fd, buf, len); if (r >= 0) { diff --git a/src/aio_event.h b/src/aio_event.h index 7fcb69469..d51d02b3b 100644 --- a/src/aio_event.h +++ b/src/aio_event.h @@ -50,13 +50,13 @@ gint rspamd_aio_open (struct aio_context *ctx, const gchar *path, int flags); /** * Asynchronous read of file */ -gint rspamd_aio_read (gint fd, gpointer buf, gsize len, off_t offset, +gint rspamd_aio_read (gint fd, gpointer buf, gsize len, guint64 offset, struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud); /** * Asynchronous write of file */ -gint rspamd_aio_write (gint fd, gpointer buf, gsize len, off_t offset, +gint rspamd_aio_write (gint fd, gpointer buf, gsize len, guint64 offset, struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud); /**