aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-03-27 18:46:21 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-03-27 18:46:21 +0400
commitd450657c9040e77057fdcaf2151537f7ad46580f (patch)
tree015a75b1387a05950bab52fc2a6d18872764d547
parentbbc501fbfd1f8ffe67b97cc684ca5c1152ccbfd1 (diff)
downloadrspamd-d450657c9040e77057fdcaf2151537f7ad46580f.tar.gz
rspamd-d450657c9040e77057fdcaf2151537f7ad46580f.zip
Use 64 bit offset while compiled in 32 bit mode.
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/aio_event.c12
-rw-r--r--src/aio_event.h4
3 files changed, 15 insertions, 5 deletions
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);
/**