mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Added G_GSIZE_FORMAT and friends.
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org> * configure.in: Added G_GSIZE_FORMAT and friends. * tests/printf-test.c * tests/testglib.c * tests/type-test.c: Add tests for the above.
This commit is contained in:
parent
193f158001
commit
b5ae75aa4a
@ -1,3 +1,11 @@
|
||||
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* 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 <yosh@gimp.org>
|
||||
|
||||
* tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
|
||||
|
@ -1,3 +1,11 @@
|
||||
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* 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 <yosh@gimp.org>
|
||||
|
||||
* tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
|
||||
|
@ -1,3 +1,11 @@
|
||||
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* 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 <yosh@gimp.org>
|
||||
|
||||
* tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
|
||||
|
@ -1,3 +1,11 @@
|
||||
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* 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 <yosh@gimp.org>
|
||||
|
||||
* tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
|
||||
|
@ -1,3 +1,11 @@
|
||||
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* 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 <yosh@gimp.org>
|
||||
|
||||
* tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
|
||||
|
@ -1,3 +1,11 @@
|
||||
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* 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 <yosh@gimp.org>
|
||||
|
||||
* tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
|
||||
|
27
configure.in
27
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`
|
||||
|
||||
|
@ -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"));
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user