diff src/lib-storage/index/maildir/maildir-sync.c @ 7526:a957567706ec HEAD

Replaced HAVE_ST_NSEC macro checks with more generic ST_?TIME_NSEC() macros for getting the nanosecond and ST_NTIMES_EQUAL() macro for comparing them. Added support for BSD st_?timespec fields.
author Timo Sirainen <tss@iki.fi>
date Sat, 17 May 2008 01:00:22 +0300
parents c14a2b0a3126
children c438437b709a
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-sync.c	Sat May 17 00:40:31 2008 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Sat May 17 01:00:22 2008 +0300
@@ -403,19 +403,11 @@
 	if (new_dir) {
 		ctx->mbox->maildir_hdr.new_check_time = now;
 		ctx->mbox->maildir_hdr.new_mtime = st.st_mtime;
-#ifdef HAVE_STAT_TV_NSEC
-		ctx->mbox->maildir_hdr.new_mtime_nsecs = st.st_mtim.tv_nsec;
-#else
-		ctx->mbox->maildir_hdr.new_mtime_nsecs = 0;
-#endif
+		ctx->mbox->maildir_hdr.new_mtime_nsecs = ST_MTIME_NSEC(st);
 	} else {
 		ctx->mbox->maildir_hdr.cur_check_time = now;
 		ctx->mbox->maildir_hdr.cur_mtime = st.st_mtime;
-#ifdef HAVE_STAT_TV_NSEC
-		ctx->mbox->maildir_hdr.cur_mtime_nsecs = st.st_mtim.tv_nsec;
-#else
-		ctx->mbox->maildir_hdr.cur_mtime_nsecs = 0;
-#endif
+		ctx->mbox->maildir_hdr.cur_mtime_nsecs = ST_MTIME_NSEC(st);
 	}
 
 	src = t_str_new(1024);
@@ -538,13 +530,6 @@
 				    const char *new_dir, const char *cur_dir,
 				    bool *new_changed_r, bool *cur_changed_r)
 {
-#ifdef HAVE_STAT_TV_NSEC
-#  define DIR_NSECS_CHANGED(st, hdr, name) \
-	((unsigned int)(st).st_mtim.tv_nsec != (hdr)->name ## _mtime_nsecs)
-#else
-#  define DIR_NSECS_CHANGED(st, hdr, name) 0
-#endif
-
 #define DIR_DELAYED_REFRESH(hdr, name) \
 	((hdr)->name ## _check_time <= \
 		(hdr)->name ## _mtime + MAILDIR_SYNC_SECS && \
@@ -553,7 +538,7 @@
 
 #define DIR_MTIME_CHANGED(st, hdr, name) \
 	((st).st_mtime != (time_t)(hdr)->name ## _mtime || \
-	 DIR_NSECS_CHANGED(st, hdr, name))
+	 !ST_NTIMES_EQUAL(ST_MTIME_NSEC(st), (hdr)->name ## _mtime_nsecs))
 
 	struct maildir_index_header *hdr = &mbox->maildir_hdr;
 	struct stat new_st, cur_st;