[PATCH v3 16/26] git-compat-util.h: add inotify stubs on non-Linux platforms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is to avoid spreading #ifdef HAVE_INOTIFY around and keep most
code compiled even if it's never active.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 config.mak.uname  |  1 +
 git-compat-util.h | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/config.mak.uname b/config.mak.uname
index 7d31fad..ee548f5 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -33,6 +33,7 @@ ifeq ($(uname_S),Linux)
 	HAVE_PATHS_H = YesPlease
 	LIBC_CONTAINS_LIBINTL = YesPlease
 	HAVE_DEV_TTY = YesPlease
+	BASIC_CFLAGS += -DHAVE_INOTIFY
 endif
 ifeq ($(uname_S),GNU/kFreeBSD)
 	NO_STRLCPY = YesPlease
diff --git a/git-compat-util.h b/git-compat-util.h
index cbd86c3..8b55dd0 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -128,6 +128,9 @@
 #else
 #include <poll.h>
 #endif
+#ifdef HAVE_INOTIFY
+#include <sys/inotify.h>
+#endif
 
 #if defined(__MINGW32__)
 /* pull in Windows compatibility stuff */
@@ -721,4 +724,44 @@ void warn_on_inaccessible(const char *path);
 /* Get the passwd entry for the UID of the current process. */
 struct passwd *xgetpwuid_self(void);
 
+#ifndef HAVE_INOTIFY
+/* Keep inotify-specific code build, even if it's not used */
+
+#define IN_DELETE_SELF	1
+#define IN_MOVE_SELF	2
+#define IN_ATTRIB	4
+#define IN_DELETE	8
+#define IN_MODIFY	16
+#define IN_MOVED_FROM	32
+#define IN_MOVED_TO	64
+#define IN_Q_OVERFLOW	128
+#define IN_UNMOUNT	256
+#define IN_CREATE	512
+#define IN_ISDIR	1024
+#define IN_IGNORED	2048
+
+struct inotify_event {
+	int event, mask, wd, len;
+	char name[FLEX_ARRAY];
+};
+
+static inline int inotify_init()
+{
+	errno = ENOSYS;
+	return -1;
+}
+
+static inline int inotify_add_watch(int fd, const char *path, int options)
+{
+	errno = ENOSYS;
+	return -1;
+}
+
+static inline int inotify_rm_watch(int fd, int wd)
+{
+	errno = ENOSYS;
+	return -1;
+}
+#endif
+
 #endif
-- 
1.8.5.2.240.g8478abd

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]