If sizeof(int) == sizeof(long) run compilation tests to determine which
authorOwen Taylor <otaylor@redhat.com>
Mon, 13 May 2002 15:57:25 +0000 (15:57 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 13 May 2002 15:57:25 +0000 (15:57 +0000)
Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>

        * 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
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
acglib.m4
configure.in

index a7dc0d9a2a807454b19157ad65ec2d9f141f3fa2..78035418d0118f68fec50593b6688b38947acd70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <otaylor@redhat.com>
  
         * glib/libcharset/*: Update from libcharset CVS.
index a7dc0d9a2a807454b19157ad65ec2d9f141f3fa2..78035418d0118f68fec50593b6688b38947acd70 100644 (file)
@@ -1,3 +1,9 @@
+Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <otaylor@redhat.com>
  
         * glib/libcharset/*: Update from libcharset CVS.
index a7dc0d9a2a807454b19157ad65ec2d9f141f3fa2..78035418d0118f68fec50593b6688b38947acd70 100644 (file)
@@ -1,3 +1,9 @@
+Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <otaylor@redhat.com>
  
         * glib/libcharset/*: Update from libcharset CVS.
index a7dc0d9a2a807454b19157ad65ec2d9f141f3fa2..78035418d0118f68fec50593b6688b38947acd70 100644 (file)
@@ -1,3 +1,9 @@
+Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <otaylor@redhat.com>
  
         * glib/libcharset/*: Update from libcharset CVS.
index a7dc0d9a2a807454b19157ad65ec2d9f141f3fa2..78035418d0118f68fec50593b6688b38947acd70 100644 (file)
@@ -1,3 +1,9 @@
+Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <otaylor@redhat.com>
  
         * glib/libcharset/*: Update from libcharset CVS.
index a7dc0d9a2a807454b19157ad65ec2d9f141f3fa2..78035418d0118f68fec50593b6688b38947acd70 100644 (file)
@@ -1,3 +1,9 @@
+Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <otaylor@redhat.com>
  
         * glib/libcharset/*: Update from libcharset CVS.
index a7dc0d9a2a807454b19157ad65ec2d9f141f3fa2..78035418d0118f68fec50593b6688b38947acd70 100644 (file)
@@ -1,3 +1,9 @@
+Mon May 13 11:55:33 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <otaylor@redhat.com>
  
         * glib/libcharset/*: Update from libcharset CVS.
index 01972685d0ee62def57934feebd1e1fc5c605f3f..ead0fd3ed1e9fe63cecbcd18529f497e0ace6385 100644 (file)
--- 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
index 43daa6e79985ef7da47706608f3324295e25edfe..32678463842e536e2c5c6b5627cbcea56676f7ab 100644 (file)
@@ -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 <stddef.h> 
+int main ()
+{
+  size_t s = 1;
+  unsigned int *size_int = &s;
+  return (int)*size_int;
+}
+    ],glib_size_type=int,
+      [GLIB_CHECK_COMPILE_WARNINGS([
+#include <stddef.h> 
+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