]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - libio/iofgetpos.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / libio / iofgetpos.c
index 4338b5097a5ba3ea804e130d6e6bfe7da70a409d..06ac51bb3464d779190587508156570bacb493e2 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -14,7 +13,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.
+   <https://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
+/* We need to avoid the header declarations of these, because
+   the types don't match _IO_fgetpos and then the compiler will
+   complain about the mismatch when we do the alias below.  */
+#define _IO_new_fgetpos64 __renamed__IO_new_fgetpos64
+#define _IO_fgetpos64 __renamed__IO_fgetpos64
+#define fgetpos64 __renamed_fgetpos64
+
 #include "libioP.h"
+
+#undef _IO_new_fgetpos64
+#undef _IO_fgetpos64
+#undef fgetpos64
+
 #include <errno.h>
 #include <stdlib.h>
 #include <shlib-compat.h>
 
 int
-_IO_new_fgetpos (fp, posp)
-     _IO_FILE *fp;
-     _IO_fpos_t *posp;
+_IO_new_fgetpos (FILE *fp, __fpos_t *posp)
 {
-  _IO_off64_t pos;
+  off64_t pos;
   int result = 0;
   CHECK_FILE (fp, EOF);
   _IO_acquire_lock (fp);
@@ -49,24 +58,19 @@ _IO_new_fgetpos (fp, posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
         failure.  */
-#ifdef EIO
       if (errno == 0)
        __set_errno (EIO);
-#endif
       result = EOF;
     }
-  else if ((_IO_off64_t) (__typeof (posp->__pos)) pos != pos)
+  else if ((off64_t) (__typeof (posp->__pos)) pos != pos)
     {
-#ifdef EOVERFLOW
       __set_errno (EOVERFLOW);
-#endif
       result = EOF;
     }
   else
     {
       posp->__pos = pos;
-      if (fp->_mode > 0
-         && (*fp->_codecvt->__codecvt_do_encoding) (fp->_codecvt) < 0)
+      if (fp->_mode > 0 && __libio_codecvt_encoding (fp->_codecvt) < 0)
        /* This is a stateful encoding, safe the state.  */
        posp->__state = fp->_wide_data->_IO_state;
     }
@@ -78,3 +82,10 @@ _IO_new_fgetpos (fp, posp)
 strong_alias (_IO_new_fgetpos, __new_fgetpos)
 versioned_symbol (libc, _IO_new_fgetpos, _IO_fgetpos, GLIBC_2_2);
 versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (_IO_new_fgetpos, _IO_new_fgetpos64)
+strong_alias (_IO_new_fgetpos64, __new_fgetpos64)
+versioned_symbol (libc, _IO_new_fgetpos64, _IO_fgetpos64, GLIBC_2_2);
+versioned_symbol (libc, __new_fgetpos64, fgetpos64, GLIBC_2_2);
+#endif