Skip to content

Add compatibility for glib>=2.62 (replace GTimeVal by GDateTime) - #123

Closed
amotl wants to merge 1 commit into
sigrokproject:masterfrom
daq-tools:glib-2.62
Closed

Add compatibility for glib>=2.62 (replace GTimeVal by GDateTime)#123
amotl wants to merge 1 commit into
sigrokproject:masterfrom
daq-tools:glib-2.62

Conversation

@amotl

@amotl amotl commented Feb 21, 2021

Copy link
Copy Markdown

Hi again,

while working on sigrokproject/sigrok-meter#1, when building on macOS Catalina with glib installed through Homebrew, there is already glib 2.66.7.

However, GTimeVal has been deprecated since glib 2.62 and should be replaced by GDateTime [1], see also [2].

GTimeVal has been deprecated since version 2.62 and should not be used in newly-written code. Use GDateTime or guint64 instead.

So, this is just a humble attempt to make things work again on this end. As I told you in #122, I am not deeply involved into C/C++, but this update makes things work for us so you might want to build upon it in one of the future iterations.

With kind regards,
Andreas.

[1] https://developer.gnome.org/glib/stable/glib-Date-and-Time-Functions.html#GTimeVal
[2] https://tecnocode.co.uk/2019/08/24/gtimeval-deprecation-in-glib-2-61-2/

When building on macOS Catalina with glib installed through Homebrew,
there is already glib 2.66.7.

However, GTimeVal has been deprecated since glib 2.62 and should be
replaced by GDateTime [1].

[1] https://developer.gnome.org/glib/stable/glib-Date-and-Time-Functions.html#GTimeVal
Comment thread configure.ac
Comment on lines -374 to +377
SR_PKG_CHECK([glibmm], [SR_PKGLIBS_CXX], [glibmm-2.4 >= 2.32.0])
AM_COND_IF([MACOS],
[SR_PKG_CHECK([glibmm], [SR_PKGLIBS_CXX], [glibmm-2.68 >= 2.32.0])],
[SR_PKG_CHECK([glibmm], [SR_PKGLIBS_CXX], [glibmm-2.4 >= 2.32.0])])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS/Homebrew, glibmm is named differently.

$ pkg-config --list-all | grep glib
gio-unix-2.0                        GIO unix specific APIs - unix specific headers for glib I/O library
gio-2.0                             GIO - glib I/O library
glib-2.0                            GLib - C Utility Library
glibmm-2.68                         glibmm - C++ wrapper for GLib

@amotl

amotl commented Feb 21, 2021

Copy link
Copy Markdown
Author

... build upon it in one of the future iterations.

While the current implementation within this patch works for me, I am not sure if it will produce a memleak.

GDateTime is reference counted: the reference count is increased by calling g_date_time_ref() and decreased by calling g_date_time_unref(). When the reference count drops to 0, the resources allocated by the GDateTime structure are released [1].

You should release the return value by calling GLib.DateTime.unref() when you are done with it [2].


On the other hand, when already refactoring something related to timekeeping, using the monotonic clock might also be an option [3,4]?

[1] https://developer.gnome.org/glib/stable/glib-GDateTime.html
[2] https://lazka.github.io/pgi-docs/GLib-2.0/classes/DateTime.html#GLib.DateTime.new
[3] https://stackoverflow.com/questions/41894213/what-is-the-use-of-clock-realtime
[4] https://stackoverflow.com/questions/3523442/difference-between-clock-realtime-and-clock-monotonic

@depili

depili commented Nov 27, 2022

Copy link
Copy Markdown

Implemented in e446b3c and ee9e086

@amotl

amotl commented Nov 27, 2022

Copy link
Copy Markdown
Author

Dear @depili and @gsigh,

thank you very much.

With kind regards,
Andreas.

@amotl amotl closed this Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants