gst/gstclock.h: GST_SECOND shouldn't cause a conversion to unsigned.

Original commit message from CVS:
* gst/gstclock.h:
GST_SECOND shouldn't cause a conversion to unsigned.
* testsuite/clock/.cvsignore:
* testsuite/clock/Makefile.am:
* testsuite/clock/signedness.c: (main):
make sure it never will again
This commit is contained in:
Benjamin Otte 2004-07-11 18:19:54 +00:00
parent db1987c472
commit 9b9a151d43
8 changed files with 97 additions and 6 deletions

View file

@ -1,3 +1,12 @@
2004-07-11 Benjamin Otte <otte@gnome.org>
* gst/gstclock.h:
GST_SECOND shouldn't cause a conversion to unsigned.
* testsuite/clock/.cvsignore:
* testsuite/clock/Makefile.am:
* testsuite/clock/signedness.c: (main):
make sure it never will again
2004-07-11 Andy Wingo <wingo@pobox.com>
* gst/gstbin.c (gst_bin_add_func): If we're adding an element

View file

@ -42,10 +42,10 @@ typedef gpointer GstClockID;
#define GST_CLOCK_TIME_NONE ((GstClockTime)-1)
#define GST_CLOCK_TIME_IS_VALID(time) ((time) != GST_CLOCK_TIME_NONE)
#define GST_SECOND ((guint64) G_USEC_PER_SEC * G_GINT64_CONSTANT (1000))
#define GST_MSECOND ((guint64) GST_SECOND / G_GINT64_CONSTANT (1000))
#define GST_USECOND ((guint64) GST_SECOND / G_GINT64_CONSTANT (1000000))
#define GST_NSECOND ((guint64) GST_SECOND / G_GINT64_CONSTANT (1000000000))
#define GST_SECOND (G_USEC_PER_SEC * G_GINT64_CONSTANT (1000))
#define GST_MSECOND (GST_SECOND / G_GINT64_CONSTANT (1000))
#define GST_USECOND (GST_SECOND / G_GINT64_CONSTANT (1000000))
#define GST_NSECOND (GST_SECOND / G_GINT64_CONSTANT (1000000000))
#define GST_CLOCK_DIFF(s, e) (GstClockTimeDiff)((s) - (e))
#define GST_TIMEVAL_TO_TIME(tv) ((tv).tv_sec * GST_SECOND + (tv).tv_usec * GST_USECOND)

View file

@ -1,2 +1,3 @@
clock1
clock2
signedness

View file

@ -1,6 +1,6 @@
include ../Rules
tests_pass = clock1 clock2
tests_pass = signedness clock1 clock2
tests_fail =
tests_ignore =

View file

@ -0,0 +1,40 @@
/*
* testsuite program to make sure GST_SECOND doesn't cause signedness
* conversions
*/
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstClockTime time[] = { 0, 1, G_MAXUINT64 / GST_SECOND };
GstClockTimeDiff diff[] =
{ 0, 1, -1, G_MAXINT64 / GST_SECOND, G_MININT64 / GST_SECOND };
guint i;
gst_init (&argc, &argv);
for (i = 0; i < G_N_ELEMENTS (time); i++) {
g_print ("%" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT
" * GST_SECOND / GST_SECOND ? ... ", time[i], time[i]);
if (time[i] != (time[i] * GST_SECOND / GST_SECOND)) {
g_print ("NO\n");
g_assert_not_reached ();
return 1;
}
g_print ("yes\n");
}
for (i = 0; i < G_N_ELEMENTS (diff); i++) {
g_print ("%" G_GINT64_FORMAT " != %" G_GINT64_FORMAT
" * GST_SECOND / GST_SECOND ? ... ", diff[i], diff[i]);
if (diff[i] != (diff[i] * GST_SECOND / GST_SECOND)) {
g_print ("NO\n");
g_assert_not_reached ();
return 1;
}
g_print ("yes\n");
}
return 0;
}

View file

@ -1,2 +1,3 @@
clock1
clock2
signedness

View file

@ -1,6 +1,6 @@
include ../Rules
tests_pass = clock1 clock2
tests_pass = signedness clock1 clock2
tests_fail =
tests_ignore =

View file

@ -0,0 +1,40 @@
/*
* testsuite program to make sure GST_SECOND doesn't cause signedness
* conversions
*/
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstClockTime time[] = { 0, 1, G_MAXUINT64 / GST_SECOND };
GstClockTimeDiff diff[] =
{ 0, 1, -1, G_MAXINT64 / GST_SECOND, G_MININT64 / GST_SECOND };
guint i;
gst_init (&argc, &argv);
for (i = 0; i < G_N_ELEMENTS (time); i++) {
g_print ("%" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT
" * GST_SECOND / GST_SECOND ? ... ", time[i], time[i]);
if (time[i] != (time[i] * GST_SECOND / GST_SECOND)) {
g_print ("NO\n");
g_assert_not_reached ();
return 1;
}
g_print ("yes\n");
}
for (i = 0; i < G_N_ELEMENTS (diff); i++) {
g_print ("%" G_GINT64_FORMAT " != %" G_GINT64_FORMAT
" * GST_SECOND / GST_SECOND ? ... ", diff[i], diff[i]);
if (diff[i] != (diff[i] * GST_SECOND / GST_SECOND)) {
g_print ("NO\n");
g_assert_not_reached ();
return 1;
}
g_print ("yes\n");
}
return 0;
}