summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fseek.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2000-02-21 22:11:20 +0000
committermillert <millert@openbsd.org>2000-02-21 22:11:20 +0000
commit8b74247033dee8049b4768e6075fe0d3342fcf4e (patch)
tree2eeb686ff96c918e906923e39ba604eee570287c /lib/libc/stdio/fseek.c
parentPKCS#1 padding (diff)
downloadwireguard-openbsd-8b74247033dee8049b4768e6075fe0d3342fcf4e.tar.xz
wireguard-openbsd-8b74247033dee8049b4768e6075fe0d3342fcf4e.zip
Add fseeko() and ftello() -- versions of fseek() and ftell() that use off_t.
Also make fsetpos() and fgetpos() use fseeko() and ftello() respectively since fpos_t is actually a 64bit type.
Diffstat (limited to 'lib/libc/stdio/fseek.c')
-rw-r--r--lib/libc/stdio/fseek.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index 035ac7918c3..8063c6a0d9b 100644
--- a/lib/libc/stdio/fseek.c
+++ b/lib/libc/stdio/fseek.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: fseek.c,v 1.2 1996/08/19 08:32:46 tholo Exp $";
+static char rcsid[] = "$OpenBSD: fseek.c,v 1.3 2000/02/21 22:11:22 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -53,9 +53,9 @@ static char rcsid[] = "$OpenBSD: fseek.c,v 1.2 1996/08/19 08:32:46 tholo Exp $";
* `Whence' must be one of the three SEEK_* macros.
*/
int
-fseek(fp, offset, whence)
+fseeko(fp, offset, whence)
register FILE *fp;
- long offset;
+ off_t offset;
int whence;
{
register fpos_t (*seekfn) __P((void *, fpos_t, int));
@@ -93,7 +93,7 @@ fseek(fp, offset, whence)
curoff = fp->_offset;
else {
curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR);
- if (curoff == -1L)
+ if (curoff == (fpos_t)-1)
return (EOF);
}
if (fp->_flags & __SRD) {
@@ -245,3 +245,21 @@ dumb:
fp->_flags &= ~__SEOF;
return (0);
}
+
+/*
+ * fseek()'s offset is a long and sizeof(off_t) != sizeof(long) on all arches
+ */
+#if defined(__alpha__) && defined(__indr_reference)
+__indr_reference(fseeko, fseek);
+#else
+int
+fseek(fp, offset, whence)
+ register FILE *fp;
+ long offset;
+ int whence;
+{
+ off_t off = offset;
+
+ return(fseeko(fp, off, whence));
+}
+#endif