bug-gnulib
[Top][All Lists]
Advanced

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

new module 'fseeko'


From: Bruno Haible
Subject: new module 'fseeko'
Date: Wed, 25 Apr 2007 09:39:13 +0200
User-agent: KMail/1.5.4

Eric Blake wrote on 2007-04-17:
> A module for fseek/fseeko still needs to be written.  And in the process,
> I discovered that mingw lacks ftello, so we also need a module for
> ftell/ftello (until that is written, fflush fails to compile on mingw).
> Unfortunately, on mingw, Microsoft has chosen for off_t to be 4 bytes
> (plain 'long'), which means fseeko is no more accurate than fseek; then
> changed their mind to provide 64-bit file offsets, but via the
> non-standard _ftelli64 and _fseeki64 on the type __int64 (basically 'long
> long'), along with non-standard _stat64 to make stat() use 64-bit
> timestamps and file lengths rather than 32-bit.  I guess we implement
> fseeko using mingw's choice of off_t, even though it is an artificial
> limit compared to what the platform is capable of via non-standard functions.

I agree this is the right choice. If the mingw headers were prepared for
_FILE_OFFSET_BITS=64, and autoconf's AC_SYS_LARGEFILE macro handled it,
we could use it also in gnulib. But putting the LFS support in gnulib seems
wrong, since the risk would be too high that parts of an application be
compiled with a 64-bit off_t and other parts with a 32-bit off_t.

Btw, what is AC_FUNC_FSEEKO good for?


2007-04-25  Bruno Haible  <address@hidden>

        * modules/fseeko: New file.
        * m4/fseeko.m4: New file.
        * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Set also GNULIB_FSEEKO,
        HAVE_FSEEKO.
        * lib/stdio_.h (fseeko): New declaration.
        * modules/stdio (Makefile.am): Substitute also GNULIB_FSEEKO,
        HAVE_FSEEKO.

========================== modules/fseeko ==================================
Description:
fseeko() function: Reposition a FILE stream.

Files:
m4/fseeko.m4

Depends-on:
stdio

configure.ac:
gl_FUNC_FSEEKO
gl_STDIO_MODULE_INDICATOR([fseeko])

Makefile.am:

Include:
<stdio.h>

License:
LGPL

Maintainer:
Bruno Haible

========================== m4/fseeko.m4 ====================================
# fseeko.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

AC_DEFUN([gl_FUNC_FSEEKO],
[
  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
  AC_REQUIRE([AC_PROG_CC])
  AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
    [
      AC_TRY_LINK([#include <stdio.h>], [fseeko (stdin, 0, 0);],
        [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
    ])
  if test $gl_cv_func_fseeko = no; then
    HAVE_FSEEKO=0
  fi
])
============================================================================
*** lib/stdio_.h        25 Apr 2007 07:09:29 -0000      1.17
--- lib/stdio_.h        25 Apr 2007 07:29:34 -0000
***************
*** 207,212 ****
--- 207,225 ----
  # endif
  #endif
  
+ #if @GNULIB_FSEEKO@
+ # if address@hidden@
+ /* Assume 'off_t' is the same type as 'long'.  */
+ #  define fseeko fseek
+ # endif
+ #else
+ # undef fseeko
+ # define fseeko(f,o,w) \
+    (GL_LINK_WARNING ("fseeko is unportable - " \
+                      "use gnulib module fseeko for portability"), \
+     fseeko (f, o, w))
+ #endif
+ 
  #if @GNULIB_FFLUSH@
  # if @REPLACE_FFLUSH@
  #  define fflush rpl_fflush
*** modules/stdio       10 Apr 2007 03:09:07 -0000      1.11
--- modules/stdio       25 Apr 2007 07:29:34 -0000
***************
*** 30,35 ****
--- 30,36 ----
              -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
              -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
              -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
+             -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
              -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
              -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
              -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
***************
*** 43,48 ****
--- 44,50 ----
              -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
              -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
              -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
+             -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
              -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/stdio_.h; \
*** m4/stdio_h.m4       10 Apr 2007 03:09:07 -0000      1.11
--- m4/stdio_h.m4       25 Apr 2007 07:29:34 -0000
***************
*** 1,4 ****
! # stdio_h.m4 serial 3
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # stdio_h.m4 serial 4
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
***************
*** 30,35 ****
--- 30,36 ----
    GNULIB_VSNPRINTF=0;      AC_SUBST([GNULIB_VSNPRINTF])
    GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
    GNULIB_VASPRINTF=0;      AC_SUBST([GNULIB_VASPRINTF])
+   GNULIB_FSEEKO=0;         AC_SUBST([GNULIB_FSEEKO])
    GNULIB_FFLUSH=0;         AC_SUBST([GNULIB_FFLUSH])
    dnl Assume proper GNU behavior unless another module says otherwise.
    REPLACE_FPRINTF=0;       AC_SUBST([REPLACE_FPRINTF])
***************
*** 44,48 ****
--- 45,50 ----
    REPLACE_VSPRINTF=0;      AC_SUBST([REPLACE_VSPRINTF])
    HAVE_VASPRINTF=1;        AC_SUBST([HAVE_VASPRINTF])
    REPLACE_VASPRINTF=0;     AC_SUBST([REPLACE_VASPRINTF])
+   HAVE_FSEEKO=1;           AC_SUBST([HAVE_FSEEKO])
    REPLACE_FFLUSH=0;        AC_SUBST([REPLACE_FFLUSH])
  ])





reply via email to

[Prev in Thread] Current Thread [Next in Thread]