From 9127e2f63e04e71567abb2351731b2e5300b2c0c Mon Sep 17 00:00:00 2001 From: Haakan T Johansson Date: Tue, 2 Sep 2025 14:48:10 +0200 Subject: [PATCH 1/2] Build on FreeBSD. --- Makefile | 6 ++++++ src/filewatcher.cpp | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 76bd725..bf4ebc6 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,12 @@ ifeq (Darwin,$(shell uname -s)) LDFLAGS:=-framework CoreServices endif +# FreeBSD inotify for file watching. + +ifeq (FreeBSD,$(shell uname -s)) +LIBS+=-linotify +endif + # Bison flags. # --version prints info to stdout if the -W flags are accepted, else stderr. diff --git a/src/filewatcher.cpp b/src/filewatcher.cpp index 140bc8f..7012dc9 100644 --- a/src/filewatcher.cpp +++ b/src/filewatcher.cpp @@ -25,9 +25,12 @@ #include #include -#ifdef __linux__ +#if defined( __linux__) || defined(__FreeBSD__) +#ifdef __linux__ # include +#endif +# include # include # include # include From 92eba3ca4e1d7a1a7126dfaa09fd19629038dad1 Mon Sep 17 00:00:00 2001 From: Haakan T Johansson Date: Tue, 2 Sep 2025 14:48:10 +0200 Subject: [PATCH 2/2] 3rd arg of poll() is int. --- src/filewatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filewatcher.cpp b/src/filewatcher.cpp index 7012dc9..7442ee4 100644 --- a/src/filewatcher.cpp +++ b/src/filewatcher.cpp @@ -90,7 +90,7 @@ std::string FileWatcherImpl::WaitFile(unsigned a_timeout_ms) fds[0].fd = m_fd; fds[0].events = POLLIN; - nfds = poll(fds, LENGTH(fds), a_timeout_ms); + nfds = poll(fds, LENGTH(fds), (int) a_timeout_ms); if (nfds < 0) { std::cerr << "poll: " << strerror(errno) << ".\n"; throw std::runtime_error(__func__);