+
+ ev_stop (EV_A_ (W)w);
+}
+#endif
+
+#if EV_STAT_ENABLE
+
+# ifdef _WIN32
+# define lstat(a,b) stat(a,b)
+# endif
+
+void
+ev_stat_stat (EV_P_ ev_stat *w)
+{
+ if (lstat (w->path, &w->attr) < 0)
+ w->attr.st_nlink = 0;
+ else if (!w->attr.st_nlink)
+ w->attr.st_nlink = 1;
+}
+
+static void
+stat_timer_cb (EV_P_ ev_timer *w_, int revents)
+{
+ ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer));
+
+ /* we copy this here each the time so that */
+ /* prev has the old value when the callback gets invoked */
+ w->prev = w->attr;
+ ev_stat_stat (EV_A_ w);
+
+ if (memcmp (&w->prev, &w->attr, sizeof (ev_statdata)))
+ ev_feed_event (EV_A_ w, EV_STAT);
+}
+
+void
+ev_stat_start (EV_P_ ev_stat *w)
+{
+ if (expect_false (ev_is_active (w)))
+ return;
+
+ /* since we use memcmp, we need to clear any padding data etc. */
+ memset (&w->prev, 0, sizeof (ev_statdata));
+ memset (&w->attr, 0, sizeof (ev_statdata));
+
+ ev_stat_stat (EV_A_ w);
+
+ ev_timer_init (&w->timer, stat_timer_cb, w->interval, w->interval);
+ ev_set_priority (&w->timer, ev_priority (w));
+ ev_timer_start (EV_A_ &w->timer);
+
+ ev_start (EV_A_ (W)w, 1);
+}
+
+void
+ev_stat_stop (EV_P_ ev_stat *w)
+{
+ ev_clear_pending (EV_A_ (W)w);
+ if (expect_false (!ev_is_active (w)))
+ return;
+
+ ev_timer_stop (EV_A_ &w->timer);
+