summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ftell.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/ftell.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/ftell.c')
-rw-r--r--lib/libc/stdio/ftell.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c
index 64d69266047..c4431fa527e 100644
--- a/lib/libc/stdio/ftell.c
+++ b/lib/libc/stdio/ftell.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: ftell.c,v 1.2 1996/08/19 08:32:47 tholo Exp $";
+static char rcsid[] = "$OpenBSD: ftell.c,v 1.3 2000/02/21 22:11:22 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -43,17 +43,17 @@ static char rcsid[] = "$OpenBSD: ftell.c,v 1.2 1996/08/19 08:32:47 tholo Exp $";
#include "local.h"
/*
- * ftell: return current offset.
+ * ftello: return current offset.
*/
-long
-ftell(fp)
+off_t
+ftello(fp)
register FILE *fp;
{
register fpos_t pos;
if (fp->_seek == NULL) {
errno = ESPIPE; /* historic practice */
- return (-1L);
+ return ((off_t)-1);
}
/*
@@ -87,3 +87,20 @@ ftell(fp)
}
return (pos);
}
+
+/*
+ * ftell() returns a long and sizeof(off_t) != sizeof(long) on all arches
+ */
+#if defined(__alpha__) && defined(__indr_reference)
+__indr_reference(ftello, ftell);
+#else
+long
+ftell(fp)
+ register FILE *fp;
+{
+ long pos;
+
+ pos = (long)ftello(fp);
+ return(pos);
+}
+#endif