2007.08.24 21:08 "[Tiff] A few libtiff4 changes", by Frank Warmerdam

2007.09.12 15:01 "Re: [Tiff] SIZEOF_UNSIGNED_LONG", by Frank Warmerdam

Edward Lam wrote:
> Frank Warmerdam wrote:
>> Well, this doesn't address the case of it being defined to
>> something odd, like 5.
>
> And why is that a problem? What if my platform does indeed have
> sizeof(long) == 5? or sizeof(long)==16?
>

> If you're concerned about this, then I think runtime checking is the > only real way to do. It should hardly be an efficiency issue if someone

> like TIFFClientOpen() checked SIZEOF_UNSIGNED_LONG with sizeof(unsigned > long) and error out if they don't match.

Edward,

The whole code segment looks like this. The #else really only makes sense if the unsigned long is 4 bytes long. I presume for the FAX3 code to work on a system with an unsigned long size other than 4 or 8 some sort of work will be needed in tif_fax3.c. But the testing can be done at compile time which is much better than checking at runtime since fax compression support might not be widely tested as part of test suites.

#if SIZEOF_UNSIGNED_LONG == 8
# define FILL(n, cp) \
     switch (n) { \

     case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\
     case 12:(cp)[11] = 0xff; case 11:(cp)[10] = 0xff; case 10: (cp)[9] = 0xff;\
     case  9: (cp)[8] = 0xff; case  8: (cp)[7] = 0xff; case  7: (cp)[6] = 0xff;\
     case  6: (cp)[5] = 0xff; case  5: (cp)[4] = 0xff; case  4: (cp)[3] = 0xff;\
     case  3: (cp)[2] = 0xff; case  2: (cp)[1] = 0xff;                        \
     case  1: (cp)[0] = 0xff; (cp) += (n); case 0:  ;                         \
     }
# define ZERO(n, cp)                                                    \
     switch (n) {                                                       \
     case 15:(cp)[14] = 0; case 14:(cp)[13] = 0; case 13: (cp)[12] = 0; \
     case 12:(cp)[11] = 0; case 11:(cp)[10] = 0; case 10: (cp)[9] = 0;  \
     case  9: (cp)[8] = 0; case  8: (cp)[7] = 0; case  7: (cp)[6] = 0;  \
     case  6: (cp)[5] = 0; case  5: (cp)[4] = 0; case  4: (cp)[3] = 0;  \
     case  3: (cp)[2] = 0; case  2: (cp)[1] = 0;                                \
     case  1: (cp)[0] = 0; (cp) += (n); case 0:  ;                      \
     }
#else
# define FILL(n, cp)                                                        \
     switch (n) {                                                           \
     case 7: (cp)[6] = 0xff; case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; \
     case 4: (cp)[3] = 0xff; case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \
     case 1: (cp)[0] = 0xff; (cp) += (n); case 0:  ;                        \
     }
# define ZERO(n, cp)                                                    \
     switch (n) {                                                       \
     case 7: (cp)[6] = 0; case 6: (cp)[5] = 0; case 5: (cp)[4] = 0;     \
     case 4: (cp)[3] = 0; case 3: (cp)[2] = 0; case 2: (cp)[1] = 0;     \
     case 1: (cp)[0] = 0; (cp) += (n); case 0:  ;                       \

     }
#endif

Best regards,
--
---------------------------------------+--------------------------------------

I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam

and watch the world go round - Rush    | President OSGeo, http://osgeo.org