This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit a1ea31e0701ffe864934448132ee470f26a4d0de
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Thu Jul 6 19:49:56 2023 +0200
image: Use sub-second time info when available
---
configure.ac | 3 +++
src/lib/file.c | 29 +++++++++++++++++++++++++----
src/lib/file.h | 13 +++++--------
src/lib/image.c | 2 +-
src/lib/image.h | 2 +-
5 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/configure.ac b/configure.ac
index 245dd06..ab16732 100644
--- a/configure.ac
+++ b/configure.ac
@@ -269,6 +269,9 @@ EC_C_VISIBILITY(yes)
EC_C_PACKING()
EC_C_ASAN()
+AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
+AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
+
VERSION_MAJOR=`echo $VERSION | awk -F. '{print $1}'`
VERSION_MINOR=`echo $VERSION | awk -F. '{print $2}'`
VERSION_MICRO=`echo $VERSION | awk -F. '{print $3}'`
diff --git a/src/lib/file.c b/src/lib/file.c
index 6ff9c42..5ee3e96 100644
--- a/src/lib/file.c
+++ b/src/lib/file.c
@@ -124,7 +124,28 @@ __imlib_FileIsFile(const char *s)
return (S_ISREG(st.st_mode)) ? 1 : 0;
}
-time_t
+#define STONS 1000000000ULL
+
+uint64_t
+__imlib_StatModDate(const struct stat *st)
+{
+ uint64_t mtime_ns, ctime_ns;
+
+#if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+ mtime_ns = st->st_mtim.tv_sec * STONS + st->st_mtim.tv_nsec;
+ ctime_ns = st->st_ctim.tv_sec * STONS + st->st_ctim.tv_nsec;
+#elif HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
+ mtime_ns = st->st_mtimespec.tv_sec * STONS + st->st_mtimespec.tv_nsec;
+ ctime_ns = st->st_ctimespec.tv_sec * STONS + st->st_ctimespec.tv_nsec;
+#else
+ mtime_ns = st->st_mtime;
+ ctime_ns = st->st_ctime;
+#endif
+
+ return (mtime_ns > ctime_ns) ? mtime_ns : ctime_ns;
+}
+
+uint64_t
__imlib_FileModDate(const char *s)
{
struct stat st;
@@ -134,10 +155,10 @@ __imlib_FileModDate(const char *s)
if (__imlib_FileStat(s, &st))
return 0;
- return (st.st_mtime > st.st_ctime) ? st.st_mtime : st.st_ctime;
+ return __imlib_StatModDate(&st);
}
-time_t
+uint64_t
__imlib_FileModDateFd(int fd)
{
struct stat st;
@@ -145,7 +166,7 @@ __imlib_FileModDateFd(int fd)
if (fstat(fd, &st) < 0)
return 0;
- return (st.st_mtime > st.st_ctime) ? st.st_mtime : st.st_ctime;
+ return __imlib_StatModDate(&st);
}
char **
diff --git a/src/lib/file.h b/src/lib/file.h
index 961dc8e..0a18aca 100644
--- a/src/lib/file.h
+++ b/src/lib/file.h
@@ -1,7 +1,7 @@
#ifndef __FILE_H
#define __FILE_H 1
-#include <time.h>
+#include <stdint.h>
#include <sys/stat.h>
char *__imlib_FileKey(const char *file);
@@ -9,11 +9,7 @@ char *__imlib_FileRealFile(const char *file);
const char *__imlib_FileExtension(const char *file);
-static inline time_t
-__imlib_StatModDate(const struct stat *st)
-{
- return (st->st_mtime > st->st_ctime) ? st->st_mtime : st->st_ctime;
-}
+uint64_t __imlib_StatModDate(const struct stat *st);
static inline int
__imlib_StatIsFile(const struct stat *st)
@@ -28,8 +24,9 @@ __imlib_StatIsDir(const struct stat *st)
}
int __imlib_FileIsFile(const char *s);
-time_t __imlib_FileModDate(const char *s);
-time_t __imlib_FileModDateFd(int fd);
+
+uint64_t __imlib_FileModDate(const char *s);
+uint64_t __imlib_FileModDateFd(int fd);
char **__imlib_FileDir(const char *dir, int *num);
void __imlib_FileFreeDirList(char **l, int num);
diff --git a/src/lib/image.c b/src/lib/image.c
index bc60c31..c183859 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -498,7 +498,7 @@ __imlib_LoadImage(const char *file, ImlibLoadArgs * ila)
{
if (IM_FLAG_ISSET(im, F_ALWAYS_CHECK_DISK))
{
- time_t current_modified_time;
+ uint64_t current_modified_time;
current_modified_time = ila->fp ?
__imlib_FileModDateFd(fileno(ila->fp)) :
diff --git a/src/lib/image.h b/src/lib/image.h
index be52169..d527293 100644
--- a/src/lib/image.h
+++ b/src/lib/image.h
@@ -70,7 +70,7 @@ struct _ImlibImage {
char *file;
char *key;
- time_t moddate;
+ uint64_t moddate;
unsigned int flags;
int references;
char *format;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.