[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] mintlib patch



Attached is a patch to mintlib which adds new functions ftello/fseeko
which essentially call their ftell/fseek counterparts as they're defined
as using off_t instead of long int.

If we ever get 64bit support then this would need fixing, but for now
they work just the same.

Alan.
Index: include/stdio.h
===================================================================
RCS file: /mint/mintlib/include/stdio.h,v
retrieving revision 1.5
diff -u -r1.5 stdio.h
--- include/stdio.h	27 Feb 2008 09:45:39 -0000	1.5
+++ include/stdio.h	23 May 2008 14:38:36 -0000
@@ -708,7 +708,6 @@
 				    FILE *__restrict __stream));
 #endif
 
-
 /* Seek to a certain position on STREAM.  */
 extern int fseek __P ((FILE *__stream, long int __off, int __whence));
 /* Return the current position of STREAM.  */
@@ -716,6 +715,26 @@
 /* Rewind to the beginning of STREAM.  */
 extern void rewind __P ((FILE *__stream));
 
+/* The Single Unix Specification, Version 2, specifies an alternative,
+   more adequate interface for the two functions above which deal with
+   file offset.  `long int' is not the right type.  These definitions
+   are originally defined in the Large File Support API.  */
+
+#if defined __USE_LARGEFILE || defined __USE_XOPEN2K
+# ifndef __USE_FILE_OFFSET64
+/* Seek to a certain position on STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fseeko __P ((FILE *__stream, __off_t __off, int __whence));
+/* Return the current position of STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern __off_t ftello __P ((FILE *__stream));
+# endif
+#endif
+
 /* Get STREAM's position.  */
 extern int fgetpos __P ((FILE *__restrict __stream, fpos_t *__restrict __pos));
 /* Set STREAM's position.  */
Index: stdio/fseek.c
===================================================================
RCS file: /mint/mintlib/stdio/fseek.c,v
retrieving revision 1.2
diff -u -r1.2 fseek.c
--- stdio/fseek.c	2 Apr 2008 06:44:42 -0000	1.2
+++ stdio/fseek.c	23 May 2008 14:38:36 -0000
@@ -138,3 +138,13 @@
      which will move to the target file position before reading or writing.  */
   return 0;
 }
+
+/* Just use fseek for now */
+int
+fseeko (stream, offset, whence)
+     register FILE *stream;
+     off_t offset;
+     int whence;
+{
+  return fseek(stream, (long int)offset, whence);
+}
Index: stdio/ftell.c
===================================================================
RCS file: /mint/mintlib/stdio/ftell.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ftell.c
--- stdio/ftell.c	12 Oct 2000 10:56:54 -0000	1.1.1.1
+++ stdio/ftell.c	23 May 2008 14:38:36 -0000
@@ -52,3 +52,11 @@
 
   return pos;
 }
+
+/* Just use ftell for now */
+off_t
+ftello (stream)
+     FILE *stream;
+{
+  return (off_t)ftell(stream);
+}