diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-31 10:23:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-31 10:23:30 +0000 |
commit | 4ebecadf090c6602f8f571d24556e9b902ec5b20 (patch) | |
tree | a41755a6c7b57d4e24e71d7cc20f56c9c079320b /src | |
parent | dc20c525694ee21014e88abd2fa51cf78d6c22f9 (diff) | |
download | gnunet-4ebecadf090c6602f8f571d24556e9b902ec5b20.tar.gz gnunet-4ebecadf090c6602f8f571d24556e9b902ec5b20.zip |
-LRN: OFF_T/off_t patch for 64-bit files on W32
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_disk_lib.h | 20 | ||||
-rw-r--r-- | src/util/container_bloomfilter.c | 8 | ||||
-rw-r--r-- | src/util/disk.c | 29 |
3 files changed, 32 insertions, 25 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index d0a9dfdb7..eab3c7bfa 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -25,6 +25,12 @@ | |||
25 | #ifndef GNUNET_DISK_LIB_H | 25 | #ifndef GNUNET_DISK_LIB_H |
26 | #define GNUNET_DISK_LIB_H | 26 | #define GNUNET_DISK_LIB_H |
27 | 27 | ||
28 | #if WINDOWS | ||
29 | #define OFF_T uint64_t | ||
30 | #else | ||
31 | #define OFF_T off_t | ||
32 | #endif | ||
33 | |||
28 | /** | 34 | /** |
29 | * Opaque handle used to access files. | 35 | * Opaque handle used to access files. |
30 | */ | 36 | */ |
@@ -295,8 +301,8 @@ GNUNET_DISK_file_test (const char *fil); | |||
295 | * @param whence specification to which position the offset parameter relates to | 301 | * @param whence specification to which position the offset parameter relates to |
296 | * @return the new position on success, GNUNET_SYSERR otherwise | 302 | * @return the new position on success, GNUNET_SYSERR otherwise |
297 | */ | 303 | */ |
298 | off_t | 304 | uint64_t |
299 | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset, | 305 | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, uint64_t offset, |
300 | enum GNUNET_DISK_Seek whence); | 306 | enum GNUNET_DISK_Seek whence); |
301 | 307 | ||
302 | 308 | ||
@@ -378,7 +384,7 @@ GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, | |||
378 | */ | 384 | */ |
379 | int | 385 | int |
380 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | 386 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, |
381 | off_t *size); | 387 | OFF_T *size); |
382 | 388 | ||
383 | 389 | ||
384 | /** | 390 | /** |
@@ -624,8 +630,8 @@ GNUNET_DISK_directory_create (const char *dir); | |||
624 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 630 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
625 | */ | 631 | */ |
626 | int | 632 | int |
627 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | 633 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, |
628 | off_t lockEnd, int excl); | 634 | OFF_T lockEnd, int excl); |
629 | 635 | ||
630 | 636 | ||
631 | /** | 637 | /** |
@@ -636,8 +642,8 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | |||
636 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 642 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
637 | */ | 643 | */ |
638 | int | 644 | int |
639 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, | 645 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart, |
640 | off_t unlockEnd); | 646 | OFF_T unlockEnd); |
641 | 647 | ||
642 | 648 | ||
643 | /** | 649 | /** |
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index 9ae8206fe..5016b70ef 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c | |||
@@ -183,7 +183,7 @@ static void | |||
183 | incrementBit (char *bitArray, unsigned int bitIdx, | 183 | incrementBit (char *bitArray, unsigned int bitIdx, |
184 | const struct GNUNET_DISK_FileHandle *fh) | 184 | const struct GNUNET_DISK_FileHandle *fh) |
185 | { | 185 | { |
186 | off_t fileSlot; | 186 | uint64_t fileSlot; |
187 | unsigned char value; | 187 | unsigned char value; |
188 | unsigned int high; | 188 | unsigned int high; |
189 | unsigned int low; | 189 | unsigned int low; |
@@ -231,7 +231,7 @@ static void | |||
231 | decrementBit (char *bitArray, unsigned int bitIdx, | 231 | decrementBit (char *bitArray, unsigned int bitIdx, |
232 | const struct GNUNET_DISK_FileHandle *fh) | 232 | const struct GNUNET_DISK_FileHandle *fh) |
233 | { | 233 | { |
234 | off_t fileSlot; | 234 | uint64_t fileSlot; |
235 | unsigned char value; | 235 | unsigned char value; |
236 | unsigned int high; | 236 | unsigned int high; |
237 | unsigned int low; | 237 | unsigned int low; |
@@ -453,10 +453,10 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size, | |||
453 | { | 453 | { |
454 | struct GNUNET_CONTAINER_BloomFilter *bf; | 454 | struct GNUNET_CONTAINER_BloomFilter *bf; |
455 | char *rbuff; | 455 | char *rbuff; |
456 | off_t pos; | 456 | OFF_T pos; |
457 | int i; | 457 | int i; |
458 | size_t ui; | 458 | size_t ui; |
459 | off_t fsize; | 459 | OFF_T fsize; |
460 | int must_read; | 460 | int must_read; |
461 | 461 | ||
462 | GNUNET_assert (NULL != filename); | 462 | GNUNET_assert (NULL != filename); |
diff --git a/src/util/disk.c b/src/util/disk.c index 9e64a3a60..1131ade2d 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -204,7 +204,6 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h) | |||
204 | #endif | 204 | #endif |
205 | } | 205 | } |
206 | 206 | ||
207 | |||
208 | /** | 207 | /** |
209 | * Get the size of an open file. | 208 | * Get the size of an open file. |
210 | * | 209 | * |
@@ -214,7 +213,7 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h) | |||
214 | */ | 213 | */ |
215 | int | 214 | int |
216 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | 215 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, |
217 | off_t *size) | 216 | OFF_T *size) |
218 | { | 217 | { |
219 | #if WINDOWS | 218 | #if WINDOWS |
220 | BOOL b; | 219 | BOOL b; |
@@ -225,7 +224,7 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | |||
225 | SetErrnoFromWinError (GetLastError ()); | 224 | SetErrnoFromWinError (GetLastError ()); |
226 | return GNUNET_SYSERR; | 225 | return GNUNET_SYSERR; |
227 | } | 226 | } |
228 | *size = (off_t) li.QuadPart; | 227 | *size = (OFF_T) li.QuadPart; |
229 | #else | 228 | #else |
230 | struct stat sbuf; | 229 | struct stat sbuf; |
231 | 230 | ||
@@ -245,8 +244,8 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | |||
245 | * @param whence specification to which position the offset parameter relates to | 244 | * @param whence specification to which position the offset parameter relates to |
246 | * @return the new position on success, GNUNET_SYSERR otherwise | 245 | * @return the new position on success, GNUNET_SYSERR otherwise |
247 | */ | 246 | */ |
248 | off_t | 247 | uint64_t |
249 | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset, | 248 | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, uint64_t offset, |
250 | enum GNUNET_DISK_Seek whence) | 249 | enum GNUNET_DISK_Seek whence) |
251 | { | 250 | { |
252 | if (h == NULL) | 251 | if (h == NULL) |
@@ -256,25 +255,27 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset, | |||
256 | } | 255 | } |
257 | 256 | ||
258 | #ifdef MINGW | 257 | #ifdef MINGW |
259 | DWORD ret; | 258 | LARGE_INTEGER li, new_pos; |
259 | BOOL b; | ||
260 | 260 | ||
261 | static DWORD t[] = {[GNUNET_DISK_SEEK_SET] = FILE_BEGIN, | 261 | static DWORD t[] = {[GNUNET_DISK_SEEK_SET] = FILE_BEGIN, |
262 | [GNUNET_DISK_SEEK_CUR] = FILE_CURRENT,[GNUNET_DISK_SEEK_END] = FILE_END | 262 | [GNUNET_DISK_SEEK_CUR] = FILE_CURRENT,[GNUNET_DISK_SEEK_END] = FILE_END |
263 | }; | 263 | }; |
264 | li.QuadPart = offset; | ||
264 | 265 | ||
265 | ret = SetFilePointer (h->h, offset, NULL, t[whence]); | 266 | b = SetFilePointerEx (h->h, li, &new_pos, t[whence]); |
266 | if (ret == INVALID_SET_FILE_POINTER) | 267 | if (b == 0) |
267 | { | 268 | { |
268 | SetErrnoFromWinError (GetLastError ()); | 269 | SetErrnoFromWinError (GetLastError ()); |
269 | return GNUNET_SYSERR; | 270 | return GNUNET_SYSERR; |
270 | } | 271 | } |
271 | return ret; | 272 | return new_pos.QuadPart; |
272 | #else | 273 | #else |
273 | static int t[] = {[GNUNET_DISK_SEEK_SET] = SEEK_SET, | 274 | static int t[] = {[GNUNET_DISK_SEEK_SET] = SEEK_SET, |
274 | [GNUNET_DISK_SEEK_CUR] = SEEK_CUR,[GNUNET_DISK_SEEK_END] = SEEK_END | 275 | [GNUNET_DISK_SEEK_CUR] = SEEK_CUR,[GNUNET_DISK_SEEK_END] = SEEK_END |
275 | }; | 276 | }; |
276 | 277 | ||
277 | return lseek (h->fd, offset, t[whence]); | 278 | return lseek64 (h->fd, offset, t[whence]); |
278 | #endif | 279 | #endif |
279 | } | 280 | } |
280 | 281 | ||
@@ -1251,8 +1252,8 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user) | |||
1251 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1252 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
1252 | */ | 1253 | */ |
1253 | int | 1254 | int |
1254 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | 1255 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, |
1255 | off_t lockEnd, int excl) | 1256 | OFF_T lockEnd, int excl) |
1256 | { | 1257 | { |
1257 | if (fh == NULL) | 1258 | if (fh == NULL) |
1258 | { | 1259 | { |
@@ -1297,8 +1298,8 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | |||
1297 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1298 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
1298 | */ | 1299 | */ |
1299 | int | 1300 | int |
1300 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, | 1301 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart, |
1301 | off_t unlockEnd) | 1302 | OFF_T unlockEnd) |
1302 | { | 1303 | { |
1303 | if (fh == NULL) | 1304 | if (fh == NULL) |
1304 | { | 1305 | { |