1 /*-------------------------------------------------------------------------
4 * 64-bit versions of fseeko/ftello()
6 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * $PostgreSQL: pgsql/src/port/fseeko.c,v 1.14 2004/03/23 05:26:53 momjian Exp $
13 *-------------------------------------------------------------------------
17 * We have to use the native defines here because configure hasn't
20 #if defined(__bsdi__) || defined(__NetBSD__)
28 #include <sys/types.h>
33 * On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards
34 * say off_t is an arithmetic type, but not necessarily integral,
35 * while fpos_t might be neither.
37 * This is thread-safe on BSD/OS using flockfile/funlockfile.
41 fseeko(FILE *stream, off_t offset, int whence)
52 if (fgetpos(stream, &floc) != 0)
55 if (fsetpos(stream, &floc) != 0)
63 if (fsetpos(stream, &offset) != 0)
71 fflush(stream); /* force writes to fd for stat() */
72 if (fstat(fileno(stream), &filestat) != 0)
74 floc = filestat.st_size;
75 if (fsetpos(stream, &floc) != 0)
100 if (fgetpos(stream, &floc) != 0)