From 4b21a26173c93c84387055583a92ace6fda960c7 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 23 Jun 2024 12:49:45 +0800 Subject: [PATCH] Fix compilation on prerelease versions of Haiku * src/kqueue.c (Fkqueue_add_watch): Don't specify EV_ENABLE unless it is defined. (cherry picked from commit cb7be6035eeb7165d6789bb62708a14607e84e5d) --- src/kqueue.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/kqueue.c b/src/kqueue.c index 4693e130208..aabaab6c8c3 100644 --- a/src/kqueue.c +++ b/src/kqueue.c @@ -444,23 +444,29 @@ only when the upper directory of the renamed file is watched. */) if (! NILP (Fmember (Qrevoke, flags))) fflags |= NOTE_REVOKE; /* Register event. */ - EV_SET (&kev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, + EV_SET (&kev, fd, EVFILT_VNODE, (EV_ADD +#ifdef EV_ENABLE + | EV_ENABLE +#endif /* EV_ENABLE */ + | EV_CLEAR), fflags, 0, NULL); - if (kevent (kqueuefd, &kev, 1, NULL, 0, NULL) < 0) { - emacs_close (fd); - report_file_error ("Cannot watch file", file); - } + if (kevent (kqueuefd, &kev, 1, NULL, 0, NULL) < 0) + { + emacs_close (fd); + report_file_error ("Cannot watch file", file); + } /* Store watch object in watch list. */ Lisp_Object watch_descriptor = make_fixnum (fd); if (NILP (Ffile_directory_p (file))) watch_object = list4 (watch_descriptor, file, flags, callback); - else { - dir_list = directory_files_internal (file, Qnil, Qnil, Qnil, true, Qnil, - Qnil); - watch_object = list5 (watch_descriptor, file, flags, callback, dir_list); - } + else + { + dir_list = directory_files_internal (file, Qnil, Qnil, Qnil, true, Qnil, + Qnil); + watch_object = list5 (watch_descriptor, file, flags, callback, dir_list); + } watch_list = Fcons (watch_object, watch_list); return watch_descriptor; @@ -486,11 +492,12 @@ WATCH-DESCRIPTOR should be an object returned by `kqueue-add-watch'. */) /* Remove watch descriptor from watch list. */ watch_list = Fdelq (watch_object, watch_list); - if (NILP (watch_list) && (kqueuefd >= 0)) { - delete_read_fd (kqueuefd); - emacs_close (kqueuefd); - kqueuefd = -1; - } + if (NILP (watch_list) && (kqueuefd >= 0)) + { + delete_read_fd (kqueuefd); + emacs_close (kqueuefd); + kqueuefd = -1; + } return Qt; } -- 2.39.2