Discover decls in header files using autoconf

This commit is contained in:
Harendra Kumar 2020-08-20 06:27:40 +05:30
parent 5912650423
commit 6d6c37ed3c
6 changed files with 93 additions and 16 deletions

50
configure vendored
View File

@ -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 <CoreServices/CoreServices.h>
"
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 <CoreServices/CoreServices.h>
"
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 <CoreServices/CoreServices.h>
"
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 <CoreServices/CoreServices.h>
"
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'

View File

@ -12,6 +12,12 @@ AC_ARG_WITH([compiler], [GHC])
AC_CHECK_DECLS([IN_MASK_CREATE],[],[],[#include <sys/inotify.h>])
AC_CHECK_DECLS([IN_EXCL_UNLINK],[],[],[#include <sys/inotify.h>])
# XXX Do this only for macOS
AC_CHECK_DECLS([kFSEventStreamCreateFlagFileEvents],[],[],[#include <CoreServices/CoreServices.h>])
AC_CHECK_DECLS([kFSEventStreamCreateFlagFullHistory],[],[],[#include <CoreServices/CoreServices.h>])
AC_CHECK_DECLS([kFSEventStreamEventFlagItemCloned],[],[],[#include <CoreServices/CoreServices.h>])
AC_CHECK_DECLS([kFSEventStreamEventFlagItemIsHardlink],[],[],[#include <CoreServices/CoreServices.h>])
# Check headers and functions required
AC_CHECK_HEADERS([time.h])
AC_CHECK_FUNCS([clock_gettime])

View File

@ -1,4 +1,4 @@
#include <Availability.h>
#include <config.h>
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 ();

View File

@ -62,10 +62,10 @@
-- Need a real cpp to process Availability.h
{-# OPTIONS_GHC -pgmP gcc -optP -E #-}
#include <Availability.h>
#include <config.h>
#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

View File

@ -5,6 +5,10 @@
*
*/
#include <config.h>
#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS
#include <CoreServices/CoreServices.h>
#include <pthread.h>
#include <unistd.h>
@ -287,3 +291,4 @@ void destroyWatch(struct watch* w) {
pthread_mutex_destroy(&w->mut);
free(w);
}
#endif

View File

@ -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 <inttypes.h> header file. */
#undef HAVE_INTTYPES_H