[glib: 4/26] gtypes: Deprecate GTimeVal in favour of guint64 or GDateTime



commit e3f88f311fe260bc1b57a8f1b84a4b7189956383
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Jun 14 12:30:11 2019 +0100

    gtypes: Deprecate GTimeVal in favour of guint64 or GDateTime
    
    GTimeVal is subject to the year 2038 problem, since its `tv_sec` field
    is a `glong`, which is 32 bits on 32-bit platforms.
    
    Use `guint64` to represent microsecond-precision time since the Unix
    epoch; or use `GDateTime` for full date/time representation.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Fixes: #1438

 glib/gasyncqueue.h | 2 ++
 glib/gdate.c       | 2 ++
 glib/gmain.h       | 2 ++
 glib/gtypes.h      | 4 ++--
 4 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/glib/gasyncqueue.h b/glib/gasyncqueue.h
index 05980a777..73e537b07 100644
--- a/glib/gasyncqueue.h
+++ b/glib/gasyncqueue.h
@@ -110,12 +110,14 @@ GLIB_AVAILABLE_IN_2_46
 void         g_async_queue_push_front_unlocked  (GAsyncQueue      *queue,
                                                  gpointer          item);
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop)
 gpointer     g_async_queue_timed_pop            (GAsyncQueue      *queue,
                                                  GTimeVal         *end_time);
 GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop_unlocked)
 gpointer     g_async_queue_timed_pop_unlocked   (GAsyncQueue      *queue,
                                                  GTimeVal         *end_time);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 G_END_DECLS
 
diff --git a/glib/gdate.c b/glib/gdate.c
index 9272ede7e..eb5144631 100644
--- a/glib/gdate.c
+++ b/glib/gdate.c
@@ -123,6 +123,8 @@
  * removed from a future version of GLib. A consequence of using `glong` for
  * `tv_sec` is that on 32-bit systems `GTimeVal` is subject to the year 2038
  * problem.
+ *
+ * Deprecated: 2.62: Use #GDateTime or #guint64 instead.
  */
 
 /**
diff --git a/glib/gmain.h b/glib/gmain.h
index eca14d7d5..e9cb7d2d4 100644
--- a/glib/gmain.h
+++ b/glib/gmain.h
@@ -544,9 +544,11 @@ GLIB_AVAILABLE_IN_ALL
 void     g_source_remove_child_source (GSource        *source,
                                       GSource        *child_source);
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 GLIB_DEPRECATED_IN_2_28_FOR(g_source_get_time)
 void     g_source_get_current_time (GSource        *source,
                                     GTimeVal       *timeval);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 GLIB_AVAILABLE_IN_ALL
 gint64   g_source_get_time         (GSource        *source);
diff --git a/glib/gtypes.h b/glib/gtypes.h
index ca80c81fc..d646f15e8 100644
--- a/glib/gtypes.h
+++ b/glib/gtypes.h
@@ -546,13 +546,13 @@ union _GDoubleIEEE754
 #error unknown ENDIAN type
 #endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
 
-typedef struct _GTimeVal                GTimeVal;
+typedef struct _GTimeVal GTimeVal GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
 
 struct _GTimeVal
 {
   glong tv_sec;
   glong tv_usec;
-};
+} GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
 
 typedef gint            grefcount;
 typedef volatile gint   gatomicrefcount;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]