AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
July 2004

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2004.07.11 15:16 "CVS libtiff & thandle_t", by Bob Friesenhahn
2004.07.11 15:42 "Re: CVS libtiff & thandle_t", by Bob Friesenhahn
2004.07.11 20:16 "Re: CVS libtiff & thandle_t", by Andrey Kiselev
2004.07.11 21:35 "Re: CVS libtiff & thandle_t", by Bob Friesenhahn

2004.07.11 15:16 "CVS libtiff & thandle_t", by Bob Friesenhahn

CVS libtiff has a severe problem with the definition of thandle_t on 
64-bit machines, and there is still a problem on 32-bit machines. 
For some reason this change was made though the ChangeLog notes that 
the change can't work for 64-bit environments.  Here is the new 
definition:

#if defined(USE_WIN32_FILEIO)
#include <windows.h>
#ifdef __WIN32__
DECLARE_HANDLE(thandle_t);      /* Win32 file handle */
#else
typedef HFILE thandle_t;        /* client data handle */
#endif
#else
typedef int thandle_t;          /* client data handle */
#endif

Note that outside of Windows, thandle_t is is typedef 'int'. 
ImageMagick, GraphicsMagick, and likely other software, have been 
passing pointers via the thandle_t argument of TIFFClientOpen() since 
thandle_t used to be defined as void*.

The 'int' type is not sufficient to store a pointer on 64 bit 
machines.  Even on 32-bit machines the 'int' type only covers 1/2 of 
the available address space so using 'int' (rather than 'unsigned 
int') is wrong.

This is the definition from tiff-v3.6.1:

#if defined(USE_WIN32_FILEIO)
#include <windows.h>
#ifdef __WIN32__
DECLARE_HANDLE(thandle_t);      /* Win32 file handle */
#else
typedef HFILE thandle_t;        /* client data handle */
#endif
#else
typedef void* thandle_t;        /* client data handle */
#endif

If thandle_t has to be an integer value now (the reason for the API 
change was not noted), then it should at least be an 'unsigned long' 
so that it can be assured to support a pointer.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us
http://www.simplesystems.org/users/bfriesen