kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=5a2490eb7f987fc9c1fce47f58f006ff098f8459

commit 5a2490eb7f987fc9c1fce47f58f006ff098f8459
Author: Kim Woelders <[email protected]>
Date:   Fri Oct 22 15:35:28 2021 +0200

    imlib2_load: Use clock_gettime() when available
---
 configure.ac          | 10 ++++++++++
 src/bin/Makefile.am   |  2 +-
 src/bin/imlib2_load.c |  4 ++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 0996595..9d8888a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,16 @@ AM_CONDITIONAL(BUILD_X11, test "x$have_x" = "xyes")
 AC_CHECK_LIB(dl, dlopen, DLOPEN_LIBS=-ldl)
 AC_SUBST(DLOPEN_LIBS)
 
+AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
+  [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
+     [have_clock_gettime=no])])
+if test "x$have_clock_gettime" != xno; then
+  AC_DEFINE(USE_MONOTONIC_CLOCK, 1, [Use monotonic clock from clock_gettime()])
+  if test "x$have_clock_gettime" != xyes; then
+    AC_SUBST(CLOCK_LIBS, [$have_clock_gettime])
+  fi
+fi
+
 
 AC_MSG_CHECKING(whether to enable jpeg support)
 AC_ARG_WITH([jpeg],
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 9bd81a8..2bca045 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -19,7 +19,7 @@ imlib2_conv_SOURCES = imlib2_conv.c
 imlib2_conv_LDADD   = $(top_builddir)/src/lib/libImlib2.la
 
 imlib2_load_SOURCES = imlib2_load.c
-imlib2_load_LDADD   = $(top_builddir)/src/lib/libImlib2.la
+imlib2_load_LDADD   = $(top_builddir)/src/lib/libImlib2.la $(CLOCK_LIBS)
 
 imlib2_show_SOURCES = imlib2_show.c
 imlib2_show_LDADD   = $(top_builddir)/src/lib/libImlib2.la -lX11 -lm
diff --git a/src/bin/imlib2_load.c b/src/bin/imlib2_load.c
index 1ccafab..2d7009a 100644
--- a/src/bin/imlib2_load.c
+++ b/src/bin/imlib2_load.c
@@ -4,7 +4,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#if USE_MONOTONIC_CLOCK
+#include <time.h>
+#else
 #include <sys/time.h>
+#endif
 
 #ifndef X_DISPLAY_MISSING
 #define X_DISPLAY_MISSING

-- 


Reply via email to