ICU-5279 The current wchar_t macro is a little old and unreliable. Make it easier for cross-compiling. Also make it not fail on the Intel compiler with the additional -fvisibility=hidden compiler option.

X-SVN-Rev: 21620
This commit is contained in:
George Rhoten 2007-06-03 01:24:37 +00:00
parent 61cc1e07c8
commit b4d2e556bd
3 changed files with 439 additions and 52 deletions

View File

@ -339,30 +339,4 @@ AC_DEFUN(AC_CHECK_STRICT_COMPILE,
fi
])
dnl Define a sizeof checking macro that is a bit better than autoconf's
dnl builtin (and heavily based on it, of course). The new macro is
dnl AC_DO_CHECK_SIZEOF(TYPE [, CROSS_SIZE [, INCLUDES])
AC_DEFUN(AC_DO_CHECK_SIZEOF,
[changequote(<<, >>)dnl
dnl The name to #define.
define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
dnl The cache variable name.
define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
changequote([, ])dnl
AC_MSG_CHECKING(size of $1)
AC_CACHE_VAL(AC_CV_NAME,
[AC_TRY_RUN($3
[#include <stdio.h>
main()
{
FILE *f=fopen("conftestval", "w");
if (!f) exit(1);
fprintf(f, "%d\n", (int)sizeof($1));
exit(0);
}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
AC_MSG_RESULT($AC_CV_NAME)
AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
undefine([AC_TYPE_NAME])dnl
undefine([AC_CV_NAME])dnl
])

452
icu4c/source/configure vendored
View File

@ -7543,14 +7543,10 @@ fi
ac_default_sizeof_wchar_t=4
echo "$as_me:$LINENO: checking size of wchar_t" >&5
echo $ECHO_N "checking size of wchar_t... $ECHO_C" >&6
if test "${ac_cv_sizeof_wchar_t+set}" = set; then
echo "$as_me:$LINENO: checking for wchar_t" >&5
echo $ECHO_N "checking for wchar_t... $ECHO_C" >&6
if test "${ac_cv_type_wchar_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
ac_cv_sizeof_wchar_t=$ac_default_sizeof_wchar_t
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@ -7558,6 +7554,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if STDC_HEADERS
#include <stddef.h>
#endif
@ -7566,13 +7563,422 @@ cat >>conftest.$ac_ext <<_ACEOF
#include <string.h>
#include <wchar.h>
#endif
#include <stdio.h>
main()
int
main ()
{
FILE *f=fopen("conftestval", "w");
if (!f) exit(1);
fprintf(f, "%d\n", (int)sizeof(wchar_t));
exit(0);
if ((wchar_t *) 0)
return 0;
if (sizeof (wchar_t))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_wchar_t=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_wchar_t=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_wchar_t" >&5
echo "${ECHO_T}$ac_cv_type_wchar_t" >&6
echo "$as_me:$LINENO: checking size of wchar_t" >&5
echo $ECHO_N "checking size of wchar_t... $ECHO_C" >&6
if test "${ac_cv_sizeof_wchar_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$ac_cv_type_wchar_t" = yes; then
# The cast to unsigned long 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.
if test "$cross_compiling" = yes; then
# Depending upon the size, compute the lo and hi bounds.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if STDC_HEADERS
#include <stddef.h>
#endif
#include <stdlib.h>
#if HAVE_WCHAR_H
#include <string.h>
#include <wchar.h>
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) >= 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_lo=0 ac_mid=0
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if STDC_HEADERS
#include <stddef.h>
#endif
#include <stdlib.h>
#if HAVE_WCHAR_H
#include <string.h>
#include <wchar.h>
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_hi=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr $ac_mid + 1`
if test $ac_lo -le $ac_mid; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid + 1`
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if STDC_HEADERS
#include <stddef.h>
#endif
#include <stdlib.h>
#if HAVE_WCHAR_H
#include <string.h>
#include <wchar.h>
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) < 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_hi=-1 ac_mid=-1
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if STDC_HEADERS
#include <stddef.h>
#endif
#include <stdlib.h>
#if HAVE_WCHAR_H
#include <string.h>
#include <wchar.h>
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) >= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_lo=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_hi=`expr '(' $ac_mid ')' - 1`
if test $ac_mid -le $ac_hi; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid`
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo= ac_hi=
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if STDC_HEADERS
#include <stddef.h>
#endif
#include <stdlib.h>
#if HAVE_WCHAR_H
#include <string.h>
#include <wchar.h>
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_hi=$ac_mid
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr '(' $ac_mid ')' + 1`
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in
?*) ac_cv_sizeof_wchar_t=$ac_lo;;
'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t), 77
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (wchar_t), 77
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; } ;;
esac
else
if test "$cross_compiling" = yes; then
{ { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
See \`config.log' for more details." >&5
echo "$as_me: error: cannot run test program while cross compiling
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if STDC_HEADERS
#include <stddef.h>
#endif
#include <stdlib.h>
#if HAVE_WCHAR_H
#include <string.h>
#include <wchar.h>
#endif
long longval () { return (long) (sizeof (wchar_t)); }
unsigned long ulongval () { return (long) (sizeof (wchar_t)); }
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
FILE *f = fopen ("conftest.val", "w");
if (! f)
exit (1);
if (((long) (sizeof (wchar_t))) < 0)
{
long i = longval ();
if (i != ((long) (sizeof (wchar_t))))
exit (1);
fprintf (f, "%ld\n", i);
}
else
{
unsigned long i = ulongval ();
if (i != ((long) (sizeof (wchar_t))))
exit (1);
fprintf (f, "%lu\n", i);
}
exit (ferror (f) || fclose (f) != 0);
;
return 0;
}
_ACEOF
rm -f conftest$ac_exeext
@ -7586,18 +7992,27 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sizeof_wchar_t=`cat conftestval`
ac_cv_sizeof_wchar_t=`cat conftest.val`
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
ac_cv_sizeof_wchar_t=0
{ { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t), 77
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (wchar_t), 77
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
rm -f conftest.val
else
ac_cv_sizeof_wchar_t=0
fi
fi
echo "$as_me:$LINENO: result: $ac_cv_sizeof_wchar_t" >&5
echo "${ECHO_T}$ac_cv_sizeof_wchar_t" >&6
cat >>confdefs.h <<_ACEOF
@ -7606,12 +8021,13 @@ _ACEOF
U_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t
# We do this check to verify that everything is okay.
if test $U_SIZEOF_WCHAR_T = 0; then
if test $U_HAVE_WCHAR_H=1; then
{ { echo "$as_me:$LINENO: error: There is wchar.h but the size of wchar_t is 0" >&5
if test $U_HAVE_WCHAR_H=1; then
{ { echo "$as_me:$LINENO: error: There is wchar.h but the size of wchar_t is 0" >&5
echo "$as_me: error: There is wchar.h but the size of wchar_t is 0" >&2;}
{ (exit 1); exit 1; }; }
fi
fi
fi

View File

@ -791,8 +791,7 @@ fi
AC_SUBST(U_HAVE_WCHAR_H)
AC_SUBST(U_HAVE_WCSCPY)
ac_default_sizeof_wchar_t=4
AC_DO_CHECK_SIZEOF(wchar_t,$ac_default_sizeof_wchar_t,[
AC_CHECK_SIZEOF([wchar_t], 0, [
#if STDC_HEADERS
#include <stddef.h>
#endif
@ -801,14 +800,12 @@ AC_DO_CHECK_SIZEOF(wchar_t,$ac_default_sizeof_wchar_t,[
#include <string.h>
#include <wchar.h>
#endif])
dnl We could set ac_cv_sizeof_wchar_t to the default if the check returned
dnl 0 (unknown) but we'd rather do it in the headers, so we know we had no
dnl clue at configure time.
U_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t
# We do this check to verify that everything is okay.
if test $U_SIZEOF_WCHAR_T = 0; then
if test $U_HAVE_WCHAR_H=1; then
AC_MSG_ERROR(There is wchar.h but the size of wchar_t is 0)
fi
if test $U_HAVE_WCHAR_H=1; then
AC_MSG_ERROR(There is wchar.h but the size of wchar_t is 0)
fi
fi
AC_SUBST(U_SIZEOF_WCHAR_T)