on master help sign in
Discover decls in header files using autoconf
commit6d6c37ed3cc22daaad51916b04bc0a3575b92f7f authorHarendra Kumar <harendra@composewell.com> dateThu 20 Aug 2020, 06:27 (6 years ago) parent5912650
6 files changed+93−16
configure+50 configure.ac+6 src/Streamly/Internal/FileSystem/Event/Darwin.h+4−4 src/Streamly/Internal/FileSystem/Event/Darwin.hs+12−12 src/Streamly/Internal/FileSystem/Event/Darwin.m+5 src/config.h.in+16
configure+50
@@ -2971,6 +2971,56 @@ cat >>confdefs.h <<_ACEOF
29712971_ACEOF
29722972
29732973
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+
29743024# Check headers and functions required
29753025ac_ext=c
29763026ac_cpp='$CPP $CPPFLAGS'
configure.ac+6
@@ -12,6 +12,12 @@ AC_ARG_WITH([compiler], [GHC])
1212AC_CHECK_DECLS([IN_MASK_CREATE],[],[],[#include <sys/inotify.h>])
1313AC_CHECK_DECLS([IN_EXCL_UNLINK],[],[],[#include <sys/inotify.h>])
1414
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+
1521# Check headers and functions required
1622AC_CHECK_HEADERS([time.h])
1723AC_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>
22
33struct watch;
44
@@ -27,7 +27,7 @@ UInt32 FSEventStreamCreateFlagNoDefer ();
2727UInt32 FSEventStreamCreateFlagWatchRoot ();
2828UInt32 FSEventStreamCreateFlagFileEvents ();
2929UInt32 FSEventStreamCreateFlagIgnoreSelf ();
30−#if 0
30+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
3131UInt32 FSEventStreamCreateFlagFullHistory;
3232#endif
3333
@@ -51,13 +51,13 @@ UInt32 FSEventStreamEventFlagItemCreated ();
5151UInt32 FSEventStreamEventFlagItemRemoved ();
5252UInt32 FSEventStreamEventFlagItemRenamed ();
5353UInt32 FSEventStreamEventFlagItemModified ();
54−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
54+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
5555UInt32 FSEventStreamEventFlagItemCloned ();
5656#endif
5757UInt32 FSEventStreamEventFlagItemIsDir ();
5858UInt32 FSEventStreamEventFlagItemIsFile ();
5959UInt32 FSEventStreamEventFlagItemIsSymlink ();
60−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
60+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
6161UInt32 FSEventStreamEventFlagItemIsHardlink ();
6262#endif
6363UInt32 FSEventStreamEventFlagItemIsLastHardlink ();
src/Streamly/Internal/FileSystem/Event/Darwin.hs+12−12
@@ -62,10 +62,10 @@
6262-- Need a real cpp to process Availability.h
6363{-# OPTIONS_GHC -pgmP gcc -optP -E #-}
6464
65−#include <Availability.h>
65+#include <config.h>
6666
67−#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \
68− && __MAC_OS_X_VERSION_MIN_REQUIRED >= 10700
67+-- macOS 10.7+
68+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS
6969
7070module Streamly.Internal.FileSystem.Event.Darwin
7171 (
@@ -84,7 +84,7 @@ module Streamly.Internal.FileSystem.Event.Darwin
8484 , setRootChanged
8585 , setFileEvents
8686 , setIgnoreSelf
87−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
87+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
8888 , setFullHistory
8989#endif
9090
@@ -122,7 +122,7 @@ module Streamly.Internal.FileSystem.Event.Darwin
122122 , isDeleted
123123 , isMoved
124124 , isModified
125−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
125+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
126126 , isCloned
127127#endif
128128
@@ -130,7 +130,7 @@ module Streamly.Internal.FileSystem.Event.Darwin
130130 , isDir
131131 , isFile
132132 , isSymLink
133−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
133+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
134134 , isHardLink
135135 , isLastHardLink
136136#endif
@@ -287,7 +287,7 @@ foreign import ccall safe
287287setIgnoreSelf :: Toggle -> Config -> Config
288288setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf
289289
290−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
290+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
291291foreign import ccall safe
292292 "FSEventStreamCreateFlagFullHistory"
293293 kFSEventStreamCreateFlagFullHistory :: Word32
@@ -314,7 +314,7 @@ setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory
314314-- * 'setFileEvents' 'On'
315315-- * 'setRootChanged' 'Off'
316316-- * 'setIgnoreSelf' 'Off'
317−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
317+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
318318-- * 'setFullHistory' 'Off'
319319#endif
320320--
@@ -857,7 +857,7 @@ foreign import ccall safe
857857isModified :: Event -> Bool
858858isModified = getFlag kFSEventStreamEventFlagItemModified
859859
860−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
860+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
861861foreign import ccall safe
862862 "FSEventStreamEventFlagItemCloned"
863863 kFSEventStreamEventFlagItemCloned :: Word32
@@ -924,7 +924,7 @@ foreign import ccall safe
924924isSymLink :: Event -> Bool
925925isSymLink = getFlag kFSEventStreamEventFlagItemIsSymlink
926926
927−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
927+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
928928foreign import ccall safe
929929 "FSEventStreamEventFlagItemIsHardlink"
930930 kFSEventStreamEventFlagItemIsHardlink :: Word32
@@ -994,14 +994,14 @@ showEvent ev@Event{..} =
994994 ++ showev isDeleted "Deleted"
995995 ++ showev isModified "Modified"
996996 ++ showev isMoved "Moved"
997−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
997+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED
998998 ++ showev isCloned "Cloned"
999999#endif
10001000
10011001 ++ showev isDir "Dir"
10021002 ++ showev isFile "File"
10031003 ++ showev isSymLink "SymLink"
1004−#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
1004+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK
10051005 ++ showev isHardLink "HardLink"
10061006 ++ showev isLastHardLink "LastHardLink"
10071007#endif
src/Streamly/Internal/FileSystem/Event/Darwin.m+5
@@ -5,6 +5,10 @@
55 *
66 */
77
8+#include <config.h>
9+
10+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS
11+
812#include <CoreServices/CoreServices.h>
913#include <pthread.h>
1014#include <unistd.h>
@@ -287,3 +291,4 @@ void destroyWatch(struct watch* w) {
287291 pthread_mutex_destroy(&w->mut);
288292 free(w);
289293}
294+#endif
src/config.h.in+16
@@ -11,6 +11,22 @@
1111 you don't. */
1212#undef HAVE_DECL_IN_MASK_CREATE
1313
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+
1430/* Define to 1 if you have the <inttypes.h> header file. */
1531#undef HAVE_INTTYPES_H
1632