8 Star 0 Fork 33

src-anolis-os/util-linux

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0093-include-c-add-cmp_timespec-and-cmp_stat_mtime.patch 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
小龙 提交于 2023-05-24 11:31 +08:00 . update to util-linux-2.32.1-42.el8_8
From 428791718a166ee5ce275b0bcf4a904a97e6af9d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Dec 2021 13:19:18 +0100
Subject: include/c: add cmp_timespec() and cmp_stat_mtime()
It's like timercmp() in libc, but for timespec and for stat.st_mtim
(or stat.st_mtime for old struct stat versions).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180413
Upstream: http://github.com/util-linux/util-linux/commit/0cfb8c5c3205a92ae81def278cdded63ea47094f
Signed-off-by: Karel Zak <kzak@redhat.com>
---
include/c.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/c.h b/include/c.h
index c8bcb375b..e48ac6d7d 100644
--- a/include/c.h
+++ b/include/c.h
@@ -125,6 +125,24 @@
_a == _b ? 0 : _a > _b ? 1 : -1; })
#endif
+
+#ifndef cmp_timespec
+# define cmp_timespec(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) \
+ ? ((a)->tv_nsec CMP (b)->tv_nsec) \
+ : ((a)->tv_sec CMP (b)->tv_sec))
+#endif
+
+
+#ifndef cmp_stat_mtime
+# ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+# define cmp_stat_mtime(_a, _b, CMP) cmp_timespec(&(_a)->st_mtim, &(_b)->st_mtim, CMP)
+# else
+# define cmp_stat_mtime(_a, _b, CMP) ((_a)->st_mtime CMP (_b)->st_mtime)
+# endif
+#endif
+
+
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
--
2.39.2
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/util-linux.git
git@gitee.com:src-anolis-os/util-linux.git
src-anolis-os
util-linux
util-linux
a8

搜索帮助