[Python-Dev] TELL64

Guido van Rossum guido@python.org
Mon, 15 Jan 2001 11:02:39 -0500


Greg Stein noticed me checking in *yet* another system that needs
the fallback TELL64() definition in fileobjects.c, and wrote:

> All of those #ifdefs could be tossed and it would be more robust (long term)
> if an autoconf macro were used to specify when TELL64 should be defined.
> 
> [ I've looked thru fileobject.c and am a bit confused: the conditions for
>   defining TELL64 do not match the conditions for *using* it. that would
>   seem to imply a semantic error somewhere and/or a potential gotcha when
>   they get skewed (like I assume what happened to FreeBSD). simplifying with
>   an autoconf macro may help to rationalize it. ]

I have a better idea.  Since "lseek((fd),0,SEEK_CUR)" seems to be the
universal fallback, why not just define TELL64 to be that if it's not
previously defined (currently only MS_WIN64 has a different
definition)?  It isn't always *used* (the conditions under which
_portable_fseek() uses it are quite complex), but *when* it is used,
this seems to be the most common definition...

Patch:

*** fileobject.c	2001/01/15 10:36:56	2.106
--- fileobject.c	2001/01/15 16:02:06
***************
*** 58,66 ****
  /* define the appropriate 64-bit capable tell() function */
  #if defined(MS_WIN64)
  #define TELL64 _telli64
! #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(_HAVE_BSDI) || defined(__APPLE__)
! /* NOTE: this is only used on older
!    NetBSD prior to f*o() funcions */
  #define TELL64(fd) lseek((fd),0,SEEK_CUR)
  #endif
  
--- 58,65 ----
  /* define the appropriate 64-bit capable tell() function */
  #if defined(MS_WIN64)
  #define TELL64 _telli64
! #else
! /* Fallback for older systems that don't have the f*o() funcions */
  #define TELL64(fd) lseek((fd),0,SEEK_CUR)
  #endif


I'll check this in after 24 hours unless a better idea comes up.

--Guido van Rossum (home page: http://www.python.org/~guido/)