on master help sign in
Discover decls in header files using autoconf
6d6c37eHarendra Kumar
configure+50
@@ -2971,6 +2971,56 @@ cat >>confdefs.h <<_ACEOF
2971_ACEOF
2971_ACEOF
2972
2972
2973
2973
2974+# XXX Do this only for macOS
2975+ac_fn_c_check_decl "$LINENO" "kFSEventStreamCreateFlagFileEvents" "ac_cv_have_decl_kFSEventStreamCreateFlagFileEvents" "#include <CoreServices/CoreServices.h>
2976+"
2977+if test "x$ac_cv_have_decl_kFSEventStreamCreateFlagFileEvents" = xyes; then :
2978+ ac_have_decl=1
2979+else
2980+ ac_have_decl=0
2981+fi
2982+
2983+cat >>confdefs.h <<_ACEOF
2984+#define HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS $ac_have_decl
2985+_ACEOF
2986+
2987+ac_fn_c_check_decl "$LINENO" "kFSEventStreamCreateFlagFullHistory" "ac_cv_have_decl_kFSEventStreamCreateFlagFullHistory" "#include <CoreServices/CoreServices.h>
2988+"
2989+if test "x$ac_cv_have_decl_kFSEventStreamCreateFlagFullHistory" = xyes; then :
2990+ ac_have_decl=1
2991+else
2992+ ac_have_decl=0
2993+fi
2994+
2995+cat >>confdefs.h <<_ACEOF
2996+#define HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY $ac_have_decl
2997+_ACEOF
2998+
2999+ac_fn_c_check_decl "$LINENO" "kFSEventStreamEventFlagItemCloned" "ac_cv_have_decl_kFSEventStreamEventFlagItemCloned" "#include <CoreServices/CoreServices.h>
3000+"
3001+if test "x$ac_cv_have_decl_kFSEventStreamEventFlagItemCloned" = xyes; then :
3002+ ac_have_decl=1
3003+else
3004+ ac_have_decl=0
3005+fi
3006+
3007+cat >>confdefs.h <<_ACEOF
3008+#define HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED $ac_have_decl
3009+_ACEOF
3010+
3011+ac_fn_c_check_decl "$LINENO" "kFSEventStreamEventFlagItemIsHardlink" "ac_cv_have_decl_kFSEventStreamEventFlagItemIsHardlink" "#include <CoreServices/CoreServices.h>
3012+"
3013+if test "x$ac_cv_have_decl_kFSEventStreamEventFlagItemIsHardlink" = xyes; then :
3014+ ac_have_decl=1
3015+else
3016+ ac_have_decl=0
3017+fi
3018+
3019+cat >>confdefs.h <<_ACEOF
3020+#define HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK $ac_have_decl
3021+_ACEOF
3022+
3023+
2974# Check headers and functions required
3024# Check headers and functions required
2975ac_ext=c
3025ac_ext=c
2976ac_cpp='$CPP $CPPFLAGS'
3026ac_cpp='$CPP $CPPFLAGS'
configure.ac+6
@@ -12,6 +12,12 @@ AC_ARG_WITH([compiler], [GHC])
12AC_CHECK_DECLS([IN_MASK_CREATE],[],[],[#include <sys/inotify.h>])
12AC_CHECK_DECLS([IN_MASK_CREATE],[],[],[#include <sys/inotify.h>])
13AC_CHECK_DECLS([IN_EXCL_UNLINK],[],[],[#include <sys/inotify.h>])
13AC_CHECK_DECLS([IN_EXCL_UNLINK],[],[],[#include <sys/inotify.h>])
14
14
15+# XXX Do this only for macOS
16+AC_CHECK_DECLS([kFSEventStreamCreateFlagFileEvents],[],[],[#include <CoreServices/CoreServices.h>])
17+AC_CHECK_DECLS([kFSEventStreamCreateFlagFullHistory],[],[],[#include <CoreServices/CoreServices.h>])
18+AC_CHECK_DECLS([kFSEventStreamEventFlagItemCloned],[],[],[#include <CoreServices/CoreServices.h>])
19+AC_CHECK_DECLS([kFSEventStreamEventFlagItemIsHardlink],[],[],[#include <CoreServices/CoreServices.h>])
20+
15# Check headers and functions required
21# Check headers and functions required
16AC_CHECK_HEADERS([time.h])
22AC_CHECK_HEADERS([time.h])
17AC_CHECK_FUNCS([clock_gettime])
23AC_CHECK_FUNCS([clock_gettime])
src/Streamly/Internal/FileSystem/Event/Darwin.h+4−4
@@ -1,4 +1,4 @@
1−#include <Availability.h>
1+#include <config.h>
2
2
3struct watch;
3struct watch;
4
4
@@ -27,7 +27,7 @@ UInt32 FSEventStreamCreateFlagNoDefer ();
27UInt32 FSEventStreamCreateFlagWatchRoot ();
27UInt32 FSEventStreamCreateFlagWatchRoot ();
28UInt32 FSEventStreamCreateFlagFileEvents ();
28UInt32 FSEventStreamCreateFlagFileEvents ();
29UInt32 FSEventStreamCreateFlagIgnoreSelf ();
29UInt32 FSEventStreamCreateFlagIgnoreSelf ();
30−#if 0
30+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
31UInt32 FSEventStreamCreateFlagFullHistory;
31UInt32 FSEventStreamCreateFlagFullHistory;
32#endif
32#endif
33
33
@@ -51,13 +51,13 @@ UInt32 FSEventStreamEventFlagItemCreated ();
51UInt32 FSEventStreamEventFlagItemRemoved ();
51UInt32 FSEventStreamEventFlagItemRemoved ();
52UInt32 FSEventStreamEventFlagItemRenamed ();
52UInt32 FSEventStreamEventFlagItemRenamed ();
53UInt32 FSEventStreamEventFlagItemModified ();
53UInt32 FSEventStreamEventFlagItemModified ();
54−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
54+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
55UInt32 FSEventStreamEventFlagItemCloned ();
55UInt32 FSEventStreamEventFlagItemCloned ();
56#endif
56#endif
57UInt32 FSEventStreamEventFlagItemIsDir ();
57UInt32 FSEventStreamEventFlagItemIsDir ();
58UInt32 FSEventStreamEventFlagItemIsFile ();
58UInt32 FSEventStreamEventFlagItemIsFile ();
59UInt32 FSEventStreamEventFlagItemIsSymlink ();
59UInt32 FSEventStreamEventFlagItemIsSymlink ();
60−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
60+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
61UInt32 FSEventStreamEventFlagItemIsHardlink ();
61UInt32 FSEventStreamEventFlagItemIsHardlink ();
62#endif
62#endif
63UInt32 FSEventStreamEventFlagItemIsLastHardlink ();
63UInt32 FSEventStreamEventFlagItemIsLastHardlink ();
src/Streamly/Internal/FileSystem/Event/Darwin.hs+12−12
@@ -62,10 +62,10 @@
62-- Need a real cpp to process Availability.h
62-- Need a real cpp to process Availability.h
63{-# OPTIONS_GHC -pgmP gcc -optP -E #-}
63{-# OPTIONS_GHC -pgmP gcc -optP -E #-}
64
64
65−#include <Availability.h>
65+#include <config.h>
66
66
67−#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \
67+-- macOS 10.7+
68− && __MAC_OS_X_VERSION_MIN_REQUIRED >= 10700
68+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS
69
69
70module Streamly.Internal.FileSystem.Event.Darwin
70module Streamly.Internal.FileSystem.Event.Darwin
71 (
71 (
@@ -84,7 +84,7 @@ module Streamly.Internal.FileSystem.Event.Darwin
84 , setRootChanged
84 , setRootChanged
85 , setFileEvents
85 , setFileEvents
86 , setIgnoreSelf
86 , setIgnoreSelf
87−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
87+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
88 , setFullHistory
88 , setFullHistory
89#endif
89#endif
90
90
@@ -122,7 +122,7 @@ module Streamly.Internal.FileSystem.Event.Darwin
122 , isDeleted
122 , isDeleted
123 , isMoved
123 , isMoved
124 , isModified
124 , isModified
125−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
125+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
126 , isCloned
126 , isCloned
127#endif
127#endif
128
128
@@ -130,7 +130,7 @@ module Streamly.Internal.FileSystem.Event.Darwin
130 , isDir
130 , isDir
131 , isFile
131 , isFile
132 , isSymLink
132 , isSymLink
133−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
133+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
134 , isHardLink
134 , isHardLink
135 , isLastHardLink
135 , isLastHardLink
136#endif
136#endif
@@ -287,7 +287,7 @@ foreign import ccall safe
287setIgnoreSelf :: Toggle -> Config -> Config
287setIgnoreSelf :: Toggle -> Config -> Config
288setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf
288setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf
289
289
290−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
290+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
291foreign import ccall safe
291foreign import ccall safe
292 "FSEventStreamCreateFlagFullHistory"
292 "FSEventStreamCreateFlagFullHistory"
293 kFSEventStreamCreateFlagFullHistory :: Word32
293 kFSEventStreamCreateFlagFullHistory :: Word32
@@ -314,7 +314,7 @@ setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory
314-- * 'setFileEvents' 'On'
314-- * 'setFileEvents' 'On'
315-- * 'setRootChanged' 'Off'
315-- * 'setRootChanged' 'Off'
316-- * 'setIgnoreSelf' 'Off'
316-- * 'setIgnoreSelf' 'Off'
317−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
317+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
318-- * 'setFullHistory' 'Off'
318-- * 'setFullHistory' 'Off'
319#endif
319#endif
320--
320--
@@ -857,7 +857,7 @@ foreign import ccall safe
857isModified :: Event -> Bool
857isModified :: Event -> Bool
858isModified = getFlag kFSEventStreamEventFlagItemModified
858isModified = getFlag kFSEventStreamEventFlagItemModified
859
859
860−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
860+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
861foreign import ccall safe
861foreign import ccall safe
862 "FSEventStreamEventFlagItemCloned"
862 "FSEventStreamEventFlagItemCloned"
863 kFSEventStreamEventFlagItemCloned :: Word32
863 kFSEventStreamEventFlagItemCloned :: Word32
@@ -924,7 +924,7 @@ foreign import ccall safe
924isSymLink :: Event -> Bool
924isSymLink :: Event -> Bool
925isSymLink = getFlag kFSEventStreamEventFlagItemIsSymlink
925isSymLink = getFlag kFSEventStreamEventFlagItemIsSymlink
926
926
927−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
927+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
928foreign import ccall safe
928foreign import ccall safe
929 "FSEventStreamEventFlagItemIsHardlink"
929 "FSEventStreamEventFlagItemIsHardlink"
930 kFSEventStreamEventFlagItemIsHardlink :: Word32
930 kFSEventStreamEventFlagItemIsHardlink :: Word32
@@ -994,14 +994,14 @@ showEvent ev@Event{..} =
994 ++ showev isDeleted "Deleted"
994 ++ showev isDeleted "Deleted"
995 ++ showev isModified "Modified"
995 ++ showev isModified "Modified"
996 ++ showev isMoved "Moved"
996 ++ showev isMoved "Moved"
997−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
997+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
998 ++ showev isCloned "Cloned"
998 ++ showev isCloned "Cloned"
999#endif
999#endif
1000
1000
1001 ++ showev isDir "Dir"
1001 ++ showev isDir "Dir"
1002 ++ showev isFile "File"
1002 ++ showev isFile "File"
1003 ++ showev isSymLink "SymLink"
1003 ++ showev isSymLink "SymLink"
1004−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
1004+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
1005 ++ showev isHardLink "HardLink"
1005 ++ showev isHardLink "HardLink"
1006 ++ showev isLastHardLink "LastHardLink"
1006 ++ showev isLastHardLink "LastHardLink"
1007#endif
1007#endif
src/Streamly/Internal/FileSystem/Event/Darwin.m+5
@@ -5,6 +5,10 @@
5 *
5 *
6 */
6 */
7
7
8+#include <config.h>
9+
10+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS
11+
8#include <CoreServices/CoreServices.h>
12#include <CoreServices/CoreServices.h>
9#include <pthread.h>
13#include <pthread.h>
10#include <unistd.h>
14#include <unistd.h>
@@ -287,3 +291,4 @@ void destroyWatch(struct watch* w) {
287 pthread_mutex_destroy(&w->mut);
291 pthread_mutex_destroy(&w->mut);
288 free(w);
292 free(w);
289}
293}
294+#endif
src/config.h.in+16
@@ -11,6 +11,22 @@
11 you don't. */
11 you don't. */
12#undef HAVE_DECL_IN_MASK_CREATE
12#undef HAVE_DECL_IN_MASK_CREATE
13
13
14+/* Define to 1 if you have the declaration of
15+ `kFSEventStreamCreateFlagFileEvents', and to 0 if you don't. */
16+#undef HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS
17+
18+/* Define to 1 if you have the declaration of
19+ `kFSEventStreamCreateFlagFullHistory', and to 0 if you don't. */
20+#undef HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
21+
22+/* Define to 1 if you have the declaration of
23+ `kFSEventStreamEventFlagItemCloned', and to 0 if you don't. */
24+#undef HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
25+
26+/* Define to 1 if you have the declaration of
27+ `kFSEventStreamEventFlagItemIsHardlink', and to 0 if you don't. */
28+#undef HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
29+
14/* Define to 1 if you have the <inttypes.h> header file. */
30/* Define to 1 if you have the <inttypes.h> header file. */
15#undef HAVE_INTTYPES_H
31#undef HAVE_INTTYPES_H
16
32