diff --git a/ChangeLog b/ChangeLog index 9b6c1b243..a5bd4219d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Nov 20 15:09:40 2003 Manish Singh + + * configure.in: Added G_GSIZE_FORMAT and friends. + + * tests/printf-test.c + * tests/testglib.c + * tests/type-test.c: Add tests for the above. + Mon Nov 17 17:28:10 2003 Manish Singh * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9b6c1b243..a5bd4219d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Thu Nov 20 15:09:40 2003 Manish Singh + + * configure.in: Added G_GSIZE_FORMAT and friends. + + * tests/printf-test.c + * tests/testglib.c + * tests/type-test.c: Add tests for the above. + Mon Nov 17 17:28:10 2003 Manish Singh * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 9b6c1b243..a5bd4219d 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +Thu Nov 20 15:09:40 2003 Manish Singh + + * configure.in: Added G_GSIZE_FORMAT and friends. + + * tests/printf-test.c + * tests/testglib.c + * tests/type-test.c: Add tests for the above. + Mon Nov 17 17:28:10 2003 Manish Singh * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9b6c1b243..a5bd4219d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Thu Nov 20 15:09:40 2003 Manish Singh + + * configure.in: Added G_GSIZE_FORMAT and friends. + + * tests/printf-test.c + * tests/testglib.c + * tests/type-test.c: Add tests for the above. + Mon Nov 17 17:28:10 2003 Manish Singh * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9b6c1b243..a5bd4219d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Thu Nov 20 15:09:40 2003 Manish Singh + + * configure.in: Added G_GSIZE_FORMAT and friends. + + * tests/printf-test.c + * tests/testglib.c + * tests/type-test.c: Add tests for the above. + Mon Nov 17 17:28:10 2003 Manish Singh * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9b6c1b243..a5bd4219d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Thu Nov 20 15:09:40 2003 Manish Singh + + * configure.in: Added G_GSIZE_FORMAT and friends. + + * tests/printf-test.c + * tests/testglib.c + * tests/type-test.c: Add tests for the above. + Mon Nov 17 17:28:10 2003 Manish Singh * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER diff --git a/configure.in b/configure.in index 768f0d4bf..91d87c5d5 100644 --- a/configure.in +++ b/configure.in @@ -2083,8 +2083,13 @@ _______EOF _______EOF -echo "typedef signed $glib_size_type_define gssize;" >> $outfile -echo "typedef unsigned $glib_size_type_define gsize;" >> $outfile + cat >>$outfile <<_______EOF +typedef signed $glib_size_type_define gssize; +typedef unsigned $glib_size_type_define gsize; +#define G_GSIZE_MODIFIER $gsize_modifier +#define G_GSSIZE_FORMAT $gssize_format +#define G_GSIZE_FORMAT $gsize_format +_______EOF if test -z "$glib_unknown_void_p"; then cat >>$outfile <<_______EOF @@ -2396,6 +2401,24 @@ glib_size_type_define=$glib_size_type glib_void_p=$ac_cv_sizeof_long glib_long=$ac_cv_sizeof_void_p +case $glib_size_type in +short) + gsize_modifier='"h"' + gsize_format='"hu"' + gssize_format='"hi"' + ;; +int) + gsize_modifier='""' + gsize_format='"u"' + gssize_format='"i"' + ;; +long) + gsize_modifier='"l"' + gsize_format='"lu"' + gssize_format='"li"' + ;; +esac + gintbits=`expr $ac_cv_sizeof_int \* 8` glongbits=`expr $ac_cv_sizeof_long \* 8` diff --git a/tests/printf-test.c b/tests/printf-test.c index b9b061c07..5dabe077b 100644 --- a/tests/printf-test.c +++ b/tests/printf-test.c @@ -93,6 +93,8 @@ main (int argc, TEST (NULL, g_snprintf (buf, 128, "%" G_GUINT32_FORMAT, (guint32)5) == 1 && !strcmp (buf, "5")); TEST (NULL, g_snprintf (buf, 128, "%" G_GINT64_FORMAT, (gint64)-5) == 2 && !strcmp (buf, "-5")); TEST (NULL, g_snprintf (buf, 128, "%" G_GUINT64_FORMAT, (guint64)5) == 1 && !strcmp (buf, "5")); + TEST (NULL, g_snprintf (buf, 128, "%" G_GSSIZE_FORMAT, (gssize)-5) == 2 && !strcmp (buf, "-5")); + TEST (NULL, g_snprintf (buf, 128, "%" G_GSIZE_FORMAT, (gsize)5) == 1 && !strcmp (buf, "5")); /* %d, flags */ TEST (NULL, g_snprintf (buf, 128, "%-d", 5) == 1 && !strcmp (buf, "5")); TEST (NULL, g_snprintf (buf, 128, "%-+d", 5) == 2 && !strcmp (buf, "+5")); diff --git a/tests/testglib.c b/tests/testglib.c index 2bc2d8bd9..c4a8c2c45 100644 --- a/tests/testglib.c +++ b/tests/testglib.c @@ -425,14 +425,14 @@ main (int argc, g_print ("tmp-dir: %s\n", g_get_tmp_dir ()); /* type sizes */ - g_print ("checking size of gint8: %d", (int)sizeof (gint8)); + g_print ("checking size of gint8: %" G_GSIZE_FORMAT, sizeof (gint8)); TEST (NULL, sizeof (gint8) == 1); - g_print ("\nchecking size of gint16: %d", (int)sizeof (gint16)); + g_print ("\nchecking size of gint16: %" G_GSIZE_FORMAT, sizeof (gint16)); TEST (NULL, sizeof (gint16) == 2); - g_print ("\nchecking size of gint32: %d", (int)sizeof (gint32)); + g_print ("\nchecking size of gint32: %" G_GSIZE_FORMAT, sizeof (gint32)); TEST (NULL, sizeof (gint32) == 4); - g_print ("\nchecking size of gsize: %d", (int)sizeof (gsize)); - g_print ("\nchecking size of gint64: %d", (int)sizeof (gint64)); + g_print ("\nchecking size of gsize: %" G_GSIZE_FORMAT, sizeof (gsize)); + g_print ("\nchecking size of gint64: %" G_GSIZE_FORMAT, sizeof (gint64)); TEST (NULL, sizeof (gint64) == 8); g_print ("\n"); diff --git a/tests/type-test.c b/tests/type-test.c index e0d17d0a0..5163b1f82 100644 --- a/tests/type-test.c +++ b/tests/type-test.c @@ -54,6 +54,10 @@ main (int argc, gu64t2 = G_GINT64_CONSTANT(0xa77a0a30026b631dU); gint64 gi64t1; gint64 gi64t2; + gssize gsst1; + gssize gsst2; + gsize gst1; + gsize gst2; /* type sizes */ g_assert (sizeof (gint8) == 1); @@ -117,6 +121,16 @@ main (int argc, g_free (string); g_assert (gi64t1 == gi64t2); g_assert (gu64t1 == gu64t2); + + gsst1 = -0x3AFAFAFA; + gst1 = 0xFAFAFAFA; + +#define FORMATSIZE "%" G_GSSIZE_FORMAT " %" G_GSIZE_FORMAT "\n" + string = g_strdup_printf (FORMATSIZE, gsst1, gst1); + sscanf (string, FORMAT64, &gsst2, &gst2); + g_free (string); + g_assert (gsst1 == gsst2); + g_assert (gst1 == gst2); return 0; }