diff --git a/configure b/configure index 4f03818c..77b359e1 100755 --- a/configure +++ b/configure @@ -2971,6 +2971,56 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# XXX Do this only for macOS +ac_fn_c_check_decl "$LINENO" "kFSEventStreamCreateFlagFileEvents" "ac_cv_have_decl_kFSEventStreamCreateFlagFileEvents" "#include +" +if test "x$ac_cv_have_decl_kFSEventStreamCreateFlagFileEvents" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "kFSEventStreamCreateFlagFullHistory" "ac_cv_have_decl_kFSEventStreamCreateFlagFullHistory" "#include +" +if test "x$ac_cv_have_decl_kFSEventStreamCreateFlagFullHistory" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "kFSEventStreamEventFlagItemCloned" "ac_cv_have_decl_kFSEventStreamEventFlagItemCloned" "#include +" +if test "x$ac_cv_have_decl_kFSEventStreamEventFlagItemCloned" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "kFSEventStreamEventFlagItemIsHardlink" "ac_cv_have_decl_kFSEventStreamEventFlagItemIsHardlink" "#include +" +if test "x$ac_cv_have_decl_kFSEventStreamEventFlagItemIsHardlink" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK $ac_have_decl +_ACEOF + + # Check headers and functions required ac_ext=c ac_cpp='$CPP $CPPFLAGS' diff --git a/configure.ac b/configure.ac index 4f3d5a95..f79eeaed 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,12 @@ AC_ARG_WITH([compiler], [GHC]) AC_CHECK_DECLS([IN_MASK_CREATE],[],[],[#include ]) AC_CHECK_DECLS([IN_EXCL_UNLINK],[],[],[#include ]) +# XXX Do this only for macOS +AC_CHECK_DECLS([kFSEventStreamCreateFlagFileEvents],[],[],[#include ]) +AC_CHECK_DECLS([kFSEventStreamCreateFlagFullHistory],[],[],[#include ]) +AC_CHECK_DECLS([kFSEventStreamEventFlagItemCloned],[],[],[#include ]) +AC_CHECK_DECLS([kFSEventStreamEventFlagItemIsHardlink],[],[],[#include ]) + # Check headers and functions required AC_CHECK_HEADERS([time.h]) AC_CHECK_FUNCS([clock_gettime]) diff --git a/src/Streamly/Internal/FileSystem/Event/Darwin.h b/src/Streamly/Internal/FileSystem/Event/Darwin.h index 08cdff1a..93af9405 100644 --- a/src/Streamly/Internal/FileSystem/Event/Darwin.h +++ b/src/Streamly/Internal/FileSystem/Event/Darwin.h @@ -1,4 +1,4 @@ -#include +#include struct watch; @@ -27,7 +27,7 @@ UInt32 FSEventStreamCreateFlagNoDefer (); UInt32 FSEventStreamCreateFlagWatchRoot (); UInt32 FSEventStreamCreateFlagFileEvents (); UInt32 FSEventStreamCreateFlagIgnoreSelf (); -#if 0 +#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY UInt32 FSEventStreamCreateFlagFullHistory; #endif @@ -51,13 +51,13 @@ UInt32 FSEventStreamEventFlagItemCreated (); UInt32 FSEventStreamEventFlagItemRemoved (); UInt32 FSEventStreamEventFlagItemRenamed (); UInt32 FSEventStreamEventFlagItemModified (); -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED UInt32 FSEventStreamEventFlagItemCloned (); #endif UInt32 FSEventStreamEventFlagItemIsDir (); UInt32 FSEventStreamEventFlagItemIsFile (); UInt32 FSEventStreamEventFlagItemIsSymlink (); -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK UInt32 FSEventStreamEventFlagItemIsHardlink (); #endif UInt32 FSEventStreamEventFlagItemIsLastHardlink (); diff --git a/src/Streamly/Internal/FileSystem/Event/Darwin.hs b/src/Streamly/Internal/FileSystem/Event/Darwin.hs index 08eb45cd..d3bea9d5 100644 --- a/src/Streamly/Internal/FileSystem/Event/Darwin.hs +++ b/src/Streamly/Internal/FileSystem/Event/Darwin.hs @@ -62,10 +62,10 @@ -- Need a real cpp to process Availability.h {-# OPTIONS_GHC -pgmP gcc -optP -E #-} -#include +#include -#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \ - && __MAC_OS_X_VERSION_MIN_REQUIRED >= 10700 +-- macOS 10.7+ +#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS module Streamly.Internal.FileSystem.Event.Darwin ( @@ -84,7 +84,7 @@ module Streamly.Internal.FileSystem.Event.Darwin , setRootChanged , setFileEvents , setIgnoreSelf -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 +#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY , setFullHistory #endif @@ -122,7 +122,7 @@ module Streamly.Internal.FileSystem.Event.Darwin , isDeleted , isMoved , isModified -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED , isCloned #endif @@ -130,7 +130,7 @@ module Streamly.Internal.FileSystem.Event.Darwin , isDir , isFile , isSymLink -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK , isHardLink , isLastHardLink #endif @@ -287,7 +287,7 @@ foreign import ccall safe setIgnoreSelf :: Toggle -> Config -> Config setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 +#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY foreign import ccall safe "FSEventStreamCreateFlagFullHistory" kFSEventStreamCreateFlagFullHistory :: Word32 @@ -314,7 +314,7 @@ setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory -- * 'setFileEvents' 'On' -- * 'setRootChanged' 'Off' -- * 'setIgnoreSelf' 'Off' -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 +#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY -- * 'setFullHistory' 'Off' #endif -- @@ -857,7 +857,7 @@ foreign import ccall safe isModified :: Event -> Bool isModified = getFlag kFSEventStreamEventFlagItemModified -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED foreign import ccall safe "FSEventStreamEventFlagItemCloned" kFSEventStreamEventFlagItemCloned :: Word32 @@ -924,7 +924,7 @@ foreign import ccall safe isSymLink :: Event -> Bool isSymLink = getFlag kFSEventStreamEventFlagItemIsSymlink -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK foreign import ccall safe "FSEventStreamEventFlagItemIsHardlink" kFSEventStreamEventFlagItemIsHardlink :: Word32 @@ -994,14 +994,14 @@ showEvent ev@Event{..} = ++ showev isDeleted "Deleted" ++ showev isModified "Modified" ++ showev isMoved "Moved" -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED ++ showev isCloned "Cloned" #endif ++ showev isDir "Dir" ++ showev isFile "File" ++ showev isSymLink "SymLink" -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK ++ showev isHardLink "HardLink" ++ showev isLastHardLink "LastHardLink" #endif diff --git a/src/Streamly/Internal/FileSystem/Event/Darwin.m b/src/Streamly/Internal/FileSystem/Event/Darwin.m index f99154bc..089d64fd 100644 --- a/src/Streamly/Internal/FileSystem/Event/Darwin.m +++ b/src/Streamly/Internal/FileSystem/Event/Darwin.m @@ -5,6 +5,10 @@ * */ +#include + +#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS + #include #include #include @@ -287,3 +291,4 @@ void destroyWatch(struct watch* w) { pthread_mutex_destroy(&w->mut); free(w); } +#endif diff --git a/src/config.h.in b/src/config.h.in index 1faed0d1..1e6dbc4d 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,6 +11,22 @@ you don't. */ #undef HAVE_DECL_IN_MASK_CREATE +/* Define to 1 if you have the declaration of + `kFSEventStreamCreateFlagFileEvents', and to 0 if you don't. */ +#undef HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS + +/* Define to 1 if you have the declaration of + `kFSEventStreamCreateFlagFullHistory', and to 0 if you don't. */ +#undef HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY + +/* Define to 1 if you have the declaration of + `kFSEventStreamEventFlagItemCloned', and to 0 if you don't. */ +#undef HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED + +/* Define to 1 if you have the declaration of + `kFSEventStreamEventFlagItemIsHardlink', and to 0 if you don't. */ +#undef HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H