Commit d21d2b30 authored by Bob Friesenhahn's avatar Bob Friesenhahn

* libtiff/tif_config.vc.h: Make adjustments to match the new

definitions that configure produces, including for WIN64.  Still
needs to be tested.

'lld' is not assured by the run-time DLLs and so GCC warns.
Add TIFF_SIZE_T and TIFF_SIZE_FORMAT to provide a type definition
and printf format specifier to deal with printing values of
'size_t' type.  In particular, this was necessary for WIN64.
Added a configure test for if the system headers provide 'optarg'
(normal case) and block out the many explicit 'extern' statements
in the utilities.  This was found to be necessary under Windows
when getopt is in a DLL and the symbols are already imported with
dllimport via standard header files.
parent 108fe0c6
2015-06-20 Bob Friesenhahn <[email protected]s>
* libtiff/tif_config.vc.h: Make adjustments to match the new
definitions that configure produces, including for WIN64. Still
needs to be tested.
* configure.ac: For 64-bit MinGW, fix SSIZE_FORMAT formatting
specifier. 64-bit MinGW supports 'long long' but support for
'lld' is not assured by the run-time DLLs.
'lld' is not assured by the run-time DLLs and so GCC warns.
Add TIFF_SIZE_T and TIFF_SIZE_FORMAT to provide a type definition
and printf format specifier to deal with printing values of
'size_t' type. In particular, this was necessary for WIN64.
Added a configure test for if the system headers provide 'optarg'
(normal case) and block out the many explicit 'extern' statements
in the utilities. This was found to be necessary under Windows
when getopt is in a DLL and the symbols are already imported with
dllimport via standard header files.
* test/raw_decode.c (XMD_H): Avoid conflicting typedefs for INT32
and boolean in MinGW build due to including jpeglib.h.
......
......@@ -2198,6 +2198,52 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_type
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly.
ac_fn_c_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
# --------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
......@@ -17192,6 +17238,18 @@ $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
fi
ac_fn_c_check_decl "$LINENO" "optarg" "ac_cv_have_decl_optarg" "$ac_includes_default"
if test "x$ac_cv_have_decl_optarg" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_OPTARG $ac_have_decl
_ACEOF
# Obtain size of an 'signed short' and define as SIZEOF_SIGNED_SHORT
# The cast to long int works around a bug in the HP C Compiler
......@@ -17513,6 +17571,42 @@ _ACEOF
# Obtain the size of 'size_t' and define as SIZEOF_SIZE_T. Result is
# available in ac_cv_sizeof_size_t
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5
$as_echo_n "checking size of size_t... " >&6; }
if ${ac_cv_sizeof_size_t+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then :
else
if test "$ac_cv_type_size_t" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (size_t)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_size_t=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5
$as_echo "$ac_cv_sizeof_size_t" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed 8-bit type" >&5
$as_echo_n "checking for signed 8-bit type... " >&6; }
INT8_T='signed char'
......@@ -17680,12 +17774,58 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
# Determine formatting specifier for 'size_t'. While the size should
# be precise, the type determined may not match the system definition.
# A named type is provided to allow casting to the type we determined
# without changing the actual size.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for 'size_t' format specifier" >&5
$as_echo_n "checking for 'size_t' format specifier... " >&6; }
SIZE_T='unknown'
SIZE_FORMAT='unknown'
if test $ac_cv_sizeof_unsigned_int -eq $ac_cv_sizeof_size_t
then
SIZE_T='unsigned int'
SIZE_FORMAT='"%u"'
elif test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_size_t
then
SIZE_T='unsigned long'
SIZE_FORMAT='"%lu"'
elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_size_t
then
SIZE_T='unsigned long long'
case "${host_os}" in
mingw32*)
# MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT
SIZE_FORMAT='"%I64u"'
;;
*)
SIZE_FORMAT='"%llu"'
;;
esac
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SIZE_FORMAT" >&5
$as_echo "$SIZE_FORMAT" >&6; }
cat >>confdefs.h <<_ACEOF
#define TIFF_SIZE_T $SIZE_T
_ACEOF
cat >>confdefs.h <<_ACEOF
#define TIFF_SIZE_FORMAT $SIZE_FORMAT
_ACEOF
# Determine TIFF equivalent of ssize_t
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed size type" >&5
$as_echo_n "checking for signed size type... " >&6; }
SSIZE_T='unknown'
SSIZE_FORMAT='unknown'
if test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_unsigned_char_p
if test $ac_cv_sizeof_signed_int -eq $ac_cv_sizeof_unsigned_char_p
then
SSIZE_T='signed int'
SSIZE_FORMAT='"%d"'
elif test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_unsigned_char_p
then
SSIZE_T='signed long'
SSIZE_FORMAT='"%ld"'
......
......@@ -182,6 +182,9 @@ AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
dnl Check if optarg (and presumably related externs) already declared in headers
AC_CHECK_DECLS([optarg])
dnl ---------------------------------------------------------------------------
dnl Compute sized types for current CPU and compiler options
dnl ---------------------------------------------------------------------------
......@@ -218,6 +221,10 @@ AC_CHECK_SIZEOF(unsigned long long)
# ac_cv_sizeof_unsigned_char_p.
AC_CHECK_SIZEOF(unsigned char *)
# Obtain the size of 'size_t' and define as SIZEOF_SIZE_T. Result is
# available in ac_cv_sizeof_size_t
AC_CHECK_SIZEOF([size_t])
AC_MSG_CHECKING(for signed 8-bit type)
INT8_T='signed char'
AC_MSG_RESULT($INT8_T)
......@@ -321,11 +328,47 @@ AC_MSG_RESULT($UINT64_T)
AC_DEFINE_UNQUOTED(TIFF_UINT64_T,$UINT64_T,[Unsigned 64-bit type])
AC_DEFINE_UNQUOTED(TIFF_UINT64_FORMAT,$UINT64_FORMAT,[Unsigned 64-bit type formatter])
# Determine formatting specifier for 'size_t'. While the size should
# be precise, the type determined may not match the system definition.
# A named type is provided to allow casting to the type we determined
# without changing the actual size.
AC_MSG_CHECKING([for 'size_t' format specifier])
SIZE_T='unknown'
SIZE_FORMAT='unknown'
if test $ac_cv_sizeof_unsigned_int -eq $ac_cv_sizeof_size_t
then
SIZE_T='unsigned int'
SIZE_FORMAT='"%u"'
elif test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_size_t
then
SIZE_T='unsigned long'
SIZE_FORMAT='"%lu"'
elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_size_t
then
SIZE_T='unsigned long long'
case "${host_os}" in
mingw32*)
# MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT
SIZE_FORMAT='"%I64u"'
;;
*)
SIZE_FORMAT='"%llu"'
;;
esac
fi
AC_MSG_RESULT([$SIZE_FORMAT])
AC_DEFINE_UNQUOTED([TIFF_SIZE_T],[$SIZE_T],[Unsigned size type])
AC_DEFINE_UNQUOTED([TIFF_SIZE_FORMAT],[$SIZE_FORMAT],[Size type formatter])
# Determine TIFF equivalent of ssize_t
AC_MSG_CHECKING(for signed size type)
SSIZE_T='unknown'
SSIZE_FORMAT='unknown'
if test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_unsigned_char_p
if test $ac_cv_sizeof_signed_int -eq $ac_cv_sizeof_unsigned_char_p
then
SSIZE_T='signed int'
SSIZE_FORMAT='"%d"'
elif test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_unsigned_char_p
then
SSIZE_T='signed long'
SSIZE_FORMAT='"%ld"'
......
/* $Id: iptcutil.c,v 1.10 2015-05-29 13:43:47 bfriesen Exp $ */
/* $Id: iptcutil.c,v 1.11 2015-06-21 01:09:09 bfriesen Exp $ */
#include "tif_config.h"
......@@ -801,11 +801,11 @@ void chstore(char *string,int max,char ch)
switch(_p_flag&3)
{
case 1: /* convert to upper */
c=toupper(ch);
c=toupper((int) ch);
break;
case 2: /* convert to lower */
c=tolower(ch);
c=tolower((int) ch);
break;
default: /* use as is */
......
/* "$Id: mkg3states.c,v 1.11 2010-03-10 18:56:48 bfriesen Exp $ */
/* "$Id: mkg3states.c,v 1.12 2015-06-21 01:09:09 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
......@@ -383,8 +383,11 @@ main(int argc, char* argv[])
FILE* fd;
char* outputfile;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:s:bp")) != -1)
switch (c) {
......
......@@ -27,6 +27,10 @@
/* Define to 1 if you have the <assert.h> header file. */
#undef HAVE_ASSERT_H
/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
*/
#undef HAVE_DECL_OPTARG
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
......@@ -252,6 +256,9 @@
/* The size of `signed short', as computed by sizeof. */
#undef SIZEOF_SIGNED_SHORT
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
/* The size of `unsigned char *', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_CHAR_P
......@@ -307,6 +314,12 @@
/* Pointer difference type */
#undef TIFF_PTRDIFF_T
/* Size type formatter */
#undef TIFF_SIZE_FORMAT
/* Unsigned size type */
#undef TIFF_SIZE_T
/* Signed size type formatter */
#undef TIFF_SSIZE_FORMAT
......
......@@ -26,6 +26,9 @@
/* Define to 1 if you have the `setmode' function. */
#define HAVE_SETMODE 1
/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */
#define HAVE_DECL_OPTARG 1
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
......@@ -44,6 +47,57 @@
/* Unsigned 64-bit type */
#define TIFF_UINT64_T unsigned __int64
#if _WIN64
/*
Windows 64-bit build
*/
/* Pointer difference type */
# define TIFF_PTRDIFF_T TIFF_INT64_T
/* The size of `size_t', as computed by sizeof. */
# define SIZEOF_SIZE_T 8
/* Size type formatter */
# define TIFF_SIZE_FORMAT TIFF_INT64_FORMAT
/* Unsigned size type */
# define TIFF_SIZE_T TIFF_UINT64_T
/* Signed size type formatter */
# define TIFF_SSIZE_FORMAT TIFF_INT64_FORMAT
/* Signed size type */
# define TIFF_SSIZE_T TIFF_INT64_T
#else
/*
Windows 32-bit build
*/
/* Pointer difference type */
# define TIFF_PTRDIFF_T signed int
/* The size of `size_t', as computed by sizeof. */
# define SIZEOF_SIZE_T 4
/* Size type formatter */
# define TIFF_SIZE_FORMAT "%u"
/* Size type formatter */
# define TIFF_SIZE_FORMAT "%u"
/* Unsigned size type */
# define TIFF_SIZE_T unsigned int
/* Signed size type formatter */
# define TIFF_SSIZE_FORMAT "%d"
/* Signed size type */
# define TIFF_SSIZE_T signed int
#endif
/* Set the native cpu bit order */
#define HOST_FILLORDER FILLORDER_LSB2MSB
......
/* $Id: tif_luv.c,v 1.39 2015-05-31 21:24:44 bfriesen Exp $ */
/* $Id: tif_luv.c,v 1.40 2015-06-21 01:09:09 bfriesen Exp $ */
/*
* Copyright (c) 1997 Greg Ward Larson
......@@ -695,7 +695,9 @@ LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#undef log2 /* Conflict with C'99 function */
#define log2(x) ((1./M_LN2)*log(x))
#undef exp2 /* Conflict with C'99 function */
#define exp2(x) exp(M_LN2*(x))
#define itrunc(x,m) ((m)==SGILOGENCODE_NODITHER ? \
......
/* $Id: strcasecmp.c,v 1.3 2009-01-22 20:53:07 fwarmerdam Exp $ */
/* $Id: strcasecmp.c,v 1.4 2015-06-21 01:09:09 bfriesen Exp $ */
/*
* Copyright (c) 1987, 1993
......@@ -44,8 +44,8 @@ strcasecmp(const char *s1, const char *s2)
const unsigned char *us1 = (const unsigned char *)s1,
*us2 = (const unsigned char *)s2;
while (tolower(*us1) == tolower(*us2++))
while (tolower((int) *us1) == tolower((int) *us2++))
if (*us1++ == '\0')
return (0);
return (tolower(*us1) - tolower(*--us2));
return (tolower((int) *us1) - tolower((int) *--us2));
}
/* $Id: bmp2tiff.c,v 1.25 2015-05-29 02:37:56 bfriesen Exp $
/* $Id: bmp2tiff.c,v 1.26 2015-06-21 01:09:09 bfriesen Exp $
*
* Project: libtiff tools
* Purpose: Convert Windows BMP files in TIFF.
......@@ -247,8 +247,10 @@ main(int argc, char* argv[])
uint32 row, clr;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:r:o:h")) != -1) {
switch (c) {
......
/* $Id: fax2ps.c,v 1.28 2014-11-20 16:47:21 erouault Exp $" */
/* $Id: fax2ps.c,v 1.29 2015-06-21 01:09:09 bfriesen Exp $" */
/*
* Copyright (c) 1991-1997 Sam Leffler
......@@ -323,8 +323,10 @@ static void usage(int code);
int
main(int argc, char** argv)
{
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
uint16 *pages = NULL, npages = 0, pageNumber;
int c, dowarnings = 0; /* if 1, enable library warnings */
TIFF* tif;
......
/* $Id: fax2tiff.c,v 1.22 2010-03-10 18:56:49 bfriesen Exp $ */
/* $Id: fax2tiff.c,v 1.23 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
......@@ -95,9 +95,11 @@ main(int argc, char* argv[])
int c;
int pn, npages;
float resY = 196.0;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "R:X:o:1234ABLMPUW5678abcflmprsuvwz?")) != -1)
switch (c) {
......
/* $Id: gif2tiff.c,v 1.17 2015-05-30 20:16:00 bfriesen Exp $ */
/* $Id: gif2tiff.c,v 1.18 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
......@@ -137,8 +137,11 @@ void rasterize(int, char*);
int
main(int argc, char* argv[])
{
#if !HAVE_DECL_OPTARG
extern int optind;
extern char *optarg;
#endif
int c, status;
while ((c = getopt(argc, argv, "c:r:")) != -1)
......
/* $Id: pal2rgb.c,v 1.14 2014-12-21 20:04:31 erouault Exp $ */
/* $Id: pal2rgb.c,v 1.15 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
......@@ -81,8 +81,11 @@ main(int argc, char* argv[])
int cmap = -1;
TIFF *in, *out;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "C:c:p:r:")) != -1)
switch (c) {
......
/* $Id: ppm2tiff.c,v 1.18 2012-12-10 18:19:11 tgl Exp $ */
/* $Id: ppm2tiff.c,v 1.19 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
......@@ -98,8 +98,10 @@ main(int argc, char* argv[])
unsigned int w, h, prec, row;
char *infile;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
tmsize_t scanline_size;
if (argc < 2) {
......
/* $Id: ras2tiff.c,v 1.21 2015-05-28 04:07:31 bfriesen Exp $ */
/* $Id: ras2tiff.c,v 1.22 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
......@@ -70,8 +70,10 @@ main(int argc, char* argv[])
uint16 config = PLANARCONFIG_CONTIG;
uint32 rowsperstrip = (uint32) -1;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:r:h")) != -1)
switch (c) {
......
/* $Id: raw2tiff.c,v 1.26 2015-05-30 16:13:29 bfriesen Exp $
/* $Id: raw2tiff.c,v 1.27 2015-06-21 01:09:10 bfriesen Exp $
*
* Project: libtiff tools
* Purpose: Convert raw byte sequences in TIFF images
......@@ -105,8 +105,10 @@ main(int argc, char* argv[])
uint32 row, col, band;
int c;
unsigned char *buf = NULL, *buf1 = NULL;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:r:H:w:l:b:d:LMp:si:o:h")) != -1) {
switch (c) {
......
/* $Id: rgb2ycbcr.c,v 1.15 2013-05-02 14:44:29 tgl Exp $ */
/* $Id: rgb2ycbcr.c,v 1.16 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
......@@ -72,8 +72,10 @@ main(int argc, char* argv[])
{
TIFF *in, *out;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char *optarg;
#endif
while ((c = getopt(argc, argv, "c:h:r:v:z")) != -1)
switch (c) {
......
/* $Id: sgi2tiff.c,v 1.6 2010-03-10 18:56:49 bfriesen Exp $ */
/* $Id: sgi2tiff.c,v 1.7 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
......@@ -60,8 +60,10 @@ main(int argc, char* argv[])
IMAGE *in;
TIFF *out;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
switch (c) {
......
/* $Id: sgisv.c,v 1.6 2010-03-10 18:56:49 bfriesen Exp $ */
/* $Id: sgisv.c,v 1.7 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
......@@ -56,8 +56,10 @@ int
main(int argc, char* argv[])
{
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
switch (c) {
......
/* $Id: thumbnail.c,v 1.20 2014-12-21 20:04:31 erouault Exp $ */
/* $Id: thumbnail.c,v 1.21 2015-06-21 01:09:10 bfriesen Exp $ */
/*
* Copyright (c) 1994-1997 Sam Leffler
......@@ -71,8 +71,10 @@ static int generateThumbnail(TIFF*, TIFF*);
static void initScale();
static void usage(void);
#if !HAVE_DECL_OPTARG