From fb2e5a27d9b1e2a95f68f20976d8c9ca7c41de47 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Mon, 13 May 2002 15:57:25 +0000 Subject: [PATCH] If sizeof(int) == sizeof(long) run compilation tests to determine which Mon May 13 11:55:33 2002 Owen Taylor * configure.in acglib.m4: If sizeof(int) == sizeof(long) run compilation tests to determine which way gsize should be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) --- ChangeLog | 6 +++++ ChangeLog.pre-2-10 | 6 +++++ ChangeLog.pre-2-12 | 6 +++++ ChangeLog.pre-2-2 | 6 +++++ ChangeLog.pre-2-4 | 6 +++++ ChangeLog.pre-2-6 | 6 +++++ ChangeLog.pre-2-8 | 6 +++++ acglib.m4 | 18 ++++++++++++++ configure.in | 61 ++++++++++++++++++++++++++++++++++++---------- 9 files changed, 108 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7dc0d9a2..78035418d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon May 13 11:55:33 2002 Owen Taylor + + * configure.in acglib.m4: If sizeof(int) == sizeof(long) + run compilation tests to determine which way gsize should + be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) + Mon May 13 11:42:23 2002 Owen Taylor * glib/libcharset/*: Update from libcharset CVS. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a7dc0d9a2..78035418d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Mon May 13 11:55:33 2002 Owen Taylor + + * configure.in acglib.m4: If sizeof(int) == sizeof(long) + run compilation tests to determine which way gsize should + be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) + Mon May 13 11:42:23 2002 Owen Taylor * glib/libcharset/*: Update from libcharset CVS. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index a7dc0d9a2..78035418d 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +Mon May 13 11:55:33 2002 Owen Taylor + + * configure.in acglib.m4: If sizeof(int) == sizeof(long) + run compilation tests to determine which way gsize should + be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) + Mon May 13 11:42:23 2002 Owen Taylor * glib/libcharset/*: Update from libcharset CVS. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index a7dc0d9a2..78035418d 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Mon May 13 11:55:33 2002 Owen Taylor + + * configure.in acglib.m4: If sizeof(int) == sizeof(long) + run compilation tests to determine which way gsize should + be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) + Mon May 13 11:42:23 2002 Owen Taylor * glib/libcharset/*: Update from libcharset CVS. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index a7dc0d9a2..78035418d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Mon May 13 11:55:33 2002 Owen Taylor + + * configure.in acglib.m4: If sizeof(int) == sizeof(long) + run compilation tests to determine which way gsize should + be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) + Mon May 13 11:42:23 2002 Owen Taylor * glib/libcharset/*: Update from libcharset CVS. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index a7dc0d9a2..78035418d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Mon May 13 11:55:33 2002 Owen Taylor + + * configure.in acglib.m4: If sizeof(int) == sizeof(long) + run compilation tests to determine which way gsize should + be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) + Mon May 13 11:42:23 2002 Owen Taylor * glib/libcharset/*: Update from libcharset CVS. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index a7dc0d9a2..78035418d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Mon May 13 11:55:33 2002 Owen Taylor + + * configure.in acglib.m4: If sizeof(int) == sizeof(long) + run compilation tests to determine which way gsize should + be defined. (#74413, reported by Miroslaw Dobrzanski-Neumann) + Mon May 13 11:42:23 2002 Owen Taylor * glib/libcharset/*: Update from libcharset CVS. diff --git a/acglib.m4 b/acglib.m4 index 01972685d..ead0fd3ed 100644 --- a/acglib.m4 +++ b/acglib.m4 @@ -147,3 +147,21 @@ AC_TRY_RUN(`cat confrun.c`, AC_MSG_RESULT(done), AC_MSG_RESULT(failed)]) rm -f confrun.c ]) + +# GLIB_CHECK_COMPILE_WARNINGS(PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# --------------------------------------------------------------------- +# Try to compile PROGRAM, check for warnings +m4_define([GLIB_CHECK_COMPILE_WARNINGS], +[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +rm -f conftest.$ac_objext +glib_ac_compile_save="$ac_compile" +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext' +AS_IF([_AC_EVAL_STDERR($ac_compile) && + AC_TRY_COMMAND([(if test -s conftest.err; then false ; else true; fi)])], + [$2], + [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD +cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD +m4_ifvaln([$3],[$3])dnl])dnl +ac_compile="$glib_ac_compile_save" +rm -f conftest.$ac_objext conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl +])# GLIB_CHECK_COMPILE_WARNINGS diff --git a/configure.in b/configure.in index 43daa6e79..326784638 100644 --- a/configure.in +++ b/configure.in @@ -578,6 +578,51 @@ GLIB_SIZEOF([$size_includes], size_t, size_t) GLIB_SIZEOF([$size_includes], ptrdiff_t, ptrdiff_t) GLIB_SIZEOF([$size_includes], intmax_t, intmax_t) +dnl Try to figure out whether gsize, gssize should be long or int +AC_MSG_CHECKING([for the appropriate definition for size_t]) + +case $glib_cv_sizeof_size_t in + $ac_cv_sizeof_short) + glib_size_type=short + ;; + $ac_cv_sizeof_int) + glib_size_type=int + ;; + $ac_cv_sizeof_long) + glib_size_type=long + ;; + *) AC_MSG_ERROR([No type matching size_t in size]) + ;; +esac + +dnl If int/long are the same size, we see which one produces +dnl warnings when used in the location as size_t. (This matters +dnl on AIX with xlc) +dnl +if test $glib_cv_sizeof_size_t = $ac_cv_sizeof_int && + test $glib_cv_sizeof_size_t = $ac_cv_sizeof_long ; then + GLIB_CHECK_COMPILE_WARNINGS([ +#include +int main () +{ + size_t s = 1; + unsigned int *size_int = &s; + return (int)*size_int; +} + ],glib_size_type=int, + [GLIB_CHECK_COMPILE_WARNINGS([ +#include +int main () +{ + size_t s = 1; + unsigned long *size_long = &s; + return (int)*size_long; +} + ],glib_size_type=long)]) +fi + +AC_MSG_RESULT(unsigned $glib_size_type) + # Check for some functions AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf unsetenv getc_unlocked) @@ -1780,19 +1825,8 @@ _______EOF _______EOF - case x$glib_size_t in - x2) echo "typedef gint16 gssize;" >> $outfile - echo "typedef guint16 gsize;" >> $outfile - ;; - x4) echo "typedef gint32 gssize;" >> $outfile - echo "typedef guint32 gsize;" >> $outfile - ;; - x8) echo "typedef gint64 gssize;" >> $outfile - echo "typedef guint64 gsize;" >> $outfile - ;; - *) echo "#error size of size_t is unknown" >> $outfile - ;; - esac +echo "typedef signed $glib_size_type_define gssize;" >> $outfile +echo "typedef unsigned $glib_size_type_define gsize;" >> $outfile if test -z "$glib_unknown_void_p"; then cat >>$outfile <<_______EOF @@ -2074,6 +2108,7 @@ $ac_cv_sizeof___int64) ;; esac glib_size_t=$glib_cv_sizeof_size_t +glib_size_type_define=$glib_size_type glib_void_p=$ac_cv_sizeof_long glib_long=$ac_cv_sizeof_void_p