1 /*-------------------------------------------------------------------------
4 * 64-bit versions of fseeko/ftello()
6 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
13 *-------------------------------------------------------------------------
17 * We have to use the native defines here because configure hasn't
20 #if defined(__bsdi__) || defined(__NetBSD__)
31 * On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards
32 * say off_t is an arithmetic type, but not necessarily integral,
33 * while fpos_t might be neither.
35 * This is thread-safe on BSD/OS using flockfile/funlockfile.
39 fseeko(FILE *stream
, off_t offset
, int whence
)
50 if (fgetpos(stream
, &floc
) != 0)
53 if (fsetpos(stream
, &floc
) != 0)
61 if (fsetpos(stream
, &offset
) != 0)
69 fflush(stream
); /* force writes to fd for stat() */
70 if (fstat(fileno(stream
), &filestat
) != 0)
72 floc
= filestat
.st_size
;
74 if (fsetpos(stream
, &floc
) != 0)
99 if (fgetpos(stream
, &floc
) != 0)