[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18863 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18863 - in gnunet/src: include util |
Date: |
Sat, 31 Dec 2011 11:23:30 +0100 |
Author: grothoff
Date: 2011-12-31 11:23:30 +0100 (Sat, 31 Dec 2011)
New Revision: 18863
Modified:
gnunet/src/include/gnunet_disk_lib.h
gnunet/src/util/container_bloomfilter.c
gnunet/src/util/disk.c
Log:
-LRN: OFF_T/off_t patch for 64-bit files on W32
Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h 2011-12-30 23:52:54 UTC (rev
18862)
+++ gnunet/src/include/gnunet_disk_lib.h 2011-12-31 10:23:30 UTC (rev
18863)
@@ -25,6 +25,12 @@
#ifndef GNUNET_DISK_LIB_H
#define GNUNET_DISK_LIB_H
+#if WINDOWS
+#define OFF_T uint64_t
+#else
+#define OFF_T off_t
+#endif
+
/**
* Opaque handle used to access files.
*/
@@ -295,8 +301,8 @@
* @param whence specification to which position the offset parameter relates
to
* @return the new position on success, GNUNET_SYSERR otherwise
*/
-off_t
-GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset,
+uint64_t
+GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, uint64_t offset,
enum GNUNET_DISK_Seek whence);
@@ -378,7 +384,7 @@
*/
int
GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
- off_t *size);
+ OFF_T *size);
/**
@@ -624,8 +630,8 @@
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
-GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
- off_t lockEnd, int excl);
+GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart,
+ OFF_T lockEnd, int excl);
/**
@@ -636,8 +642,8 @@
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
-GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart,
- off_t unlockEnd);
+GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart,
+ OFF_T unlockEnd);
/**
Modified: gnunet/src/util/container_bloomfilter.c
===================================================================
--- gnunet/src/util/container_bloomfilter.c 2011-12-30 23:52:54 UTC (rev
18862)
+++ gnunet/src/util/container_bloomfilter.c 2011-12-31 10:23:30 UTC (rev
18863)
@@ -183,7 +183,7 @@
incrementBit (char *bitArray, unsigned int bitIdx,
const struct GNUNET_DISK_FileHandle *fh)
{
- off_t fileSlot;
+ uint64_t fileSlot;
unsigned char value;
unsigned int high;
unsigned int low;
@@ -231,7 +231,7 @@
decrementBit (char *bitArray, unsigned int bitIdx,
const struct GNUNET_DISK_FileHandle *fh)
{
- off_t fileSlot;
+ uint64_t fileSlot;
unsigned char value;
unsigned int high;
unsigned int low;
@@ -453,10 +453,10 @@
{
struct GNUNET_CONTAINER_BloomFilter *bf;
char *rbuff;
- off_t pos;
+ OFF_T pos;
int i;
size_t ui;
- off_t fsize;
+ OFF_T fsize;
int must_read;
GNUNET_assert (NULL != filename);
Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c 2011-12-30 23:52:54 UTC (rev 18862)
+++ gnunet/src/util/disk.c 2011-12-31 10:23:30 UTC (rev 18863)
@@ -204,7 +204,6 @@
#endif
}
-
/**
* Get the size of an open file.
*
@@ -214,7 +213,7 @@
*/
int
GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
- off_t *size)
+ OFF_T *size)
{
#if WINDOWS
BOOL b;
@@ -225,7 +224,7 @@
SetErrnoFromWinError (GetLastError ());
return GNUNET_SYSERR;
}
- *size = (off_t) li.QuadPart;
+ *size = (OFF_T) li.QuadPart;
#else
struct stat sbuf;
@@ -245,8 +244,8 @@
* @param whence specification to which position the offset parameter relates
to
* @return the new position on success, GNUNET_SYSERR otherwise
*/
-off_t
-GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset,
+uint64_t
+GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, uint64_t
offset,
enum GNUNET_DISK_Seek whence)
{
if (h == NULL)
@@ -256,25 +255,27 @@
}
#ifdef MINGW
- DWORD ret;
+ LARGE_INTEGER li, new_pos;
+ BOOL b;
static DWORD t[] = {[GNUNET_DISK_SEEK_SET] = FILE_BEGIN,
[GNUNET_DISK_SEEK_CUR] = FILE_CURRENT,[GNUNET_DISK_SEEK_END] = FILE_END
};
+ li.QuadPart = offset;
- ret = SetFilePointer (h->h, offset, NULL, t[whence]);
- if (ret == INVALID_SET_FILE_POINTER)
+ b = SetFilePointerEx (h->h, li, &new_pos, t[whence]);
+ if (b == 0)
{
SetErrnoFromWinError (GetLastError ());
return GNUNET_SYSERR;
}
- return ret;
+ return new_pos.QuadPart;
#else
static int t[] = {[GNUNET_DISK_SEEK_SET] = SEEK_SET,
[GNUNET_DISK_SEEK_CUR] = SEEK_CUR,[GNUNET_DISK_SEEK_END] = SEEK_END
};
- return lseek (h->fd, offset, t[whence]);
+ return lseek64 (h->fd, offset, t[whence]);
#endif
}
@@ -1251,8 +1252,8 @@
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
-GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
- off_t lockEnd, int excl)
+GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart,
+ OFF_T lockEnd, int excl)
{
if (fh == NULL)
{
@@ -1297,8 +1298,8 @@
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
-GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart,
- off_t unlockEnd)
+GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart,
+ OFF_T unlockEnd)
{
if (fh == NULL)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18863 - in gnunet/src: include util,
gnunet <=