on master help sign in
Use inotify flags only if the kernel supports them
9fd6f72Harendra Kumar
configure+75−3
@@ -1435,6 +1435,52 @@ fi
1435
1435
1436} # ac_fn_c_try_compile
1436} # ac_fn_c_try_compile
1437
1437
1438+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
1439+# ---------------------------------------------
1440+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
1441+# accordingly.
1442+ac_fn_c_check_decl ()
1443+{
1444+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1445+ as_decl_name=`echo $2|sed 's/ *(.*//'`
1446+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
1447+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
1448+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
1449+if eval \${$3+:} false; then :
1450+ $as_echo_n "(cached) " >&6
1451+else
1452+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1453+/* end confdefs.h. */
1454+$4
1455+int
1456+main ()
1457+{
1458+#ifndef $as_decl_name
1459+#ifdef __cplusplus
1460+ (void) $as_decl_use;
1461+#else
1462+ (void) $as_decl_name;
1463+#endif
1464+#endif
1465+
1466+ ;
1467+ return 0;
1468+}
1469+_ACEOF
1470+if ac_fn_c_try_compile "$LINENO"; then :
1471+ eval "$3=yes"
1472+else
1473+ eval "$3=no"
1474+fi
1475+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1476+fi
1477+eval ac_res=\$$3
1478+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1479+$as_echo "$ac_res" >&6; }
1480+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1481+
1482+} # ac_fn_c_check_decl
1483+
1438# ac_fn_c_try_cpp LINENO
1484# ac_fn_c_try_cpp LINENO
1439# ----------------------
1485# ----------------------
1440# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
1486# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -2109,7 +2155,7 @@ if test "${with_compiler+set}" = set; then :
2109fi
2155fi
2110
2156
2111
2157
2112−# Check headers and functions required
2158+# XXX Do this only for linux
2113ac_ext=c
2159ac_ext=c
2114ac_cpp='$CPP $CPPFLAGS'
2160ac_cpp='$CPP $CPPFLAGS'
2115ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2161ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -2900,6 +2946,32 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
2900ac_compiler_gnu=$ac_cv_c_compiler_gnu
2946ac_compiler_gnu=$ac_cv_c_compiler_gnu
2901
2947
2902
2948
2949+ac_fn_c_check_decl "$LINENO" "IN_MASK_CREATE" "ac_cv_have_decl_IN_MASK_CREATE" "#include <sys/inotify.h>
2950+"
2951+if test "x$ac_cv_have_decl_IN_MASK_CREATE" = xyes; then :
2952+ ac_have_decl=1
2953+else
2954+ ac_have_decl=0
2955+fi
2956+
2957+cat >>confdefs.h <<_ACEOF
2958+#define HAVE_DECL_IN_MASK_CREATE $ac_have_decl
2959+_ACEOF
2960+
2961+ac_fn_c_check_decl "$LINENO" "IN_EXCL_UNLINK" "ac_cv_have_decl_IN_EXCL_UNLINK" "#include <sys/inotify.h>
2962+"
2963+if test "x$ac_cv_have_decl_IN_EXCL_UNLINK" = xyes; then :
2964+ ac_have_decl=1
2965+else
2966+ ac_have_decl=0
2967+fi
2968+
2969+cat >>confdefs.h <<_ACEOF
2970+#define HAVE_DECL_IN_EXCL_UNLINK $ac_have_decl
2971+_ACEOF
2972+
2973+
2974+# Check headers and functions required
2903ac_ext=c
2975ac_ext=c
2904ac_cpp='$CPP $CPPFLAGS'
2976ac_cpp='$CPP $CPPFLAGS'
2905ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2977ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3322,7 +3394,7 @@ done
3322
3394
3323
3395
3324# Output
3396# Output
3325−ac_config_headers="$ac_config_headers src/Streamly/Internal/Data/Time/config.h"
3397+ac_config_headers="$ac_config_headers src/config.h"
3326
3398
3327cat >confcache <<\_ACEOF
3399cat >confcache <<\_ACEOF
3328# This file is a shell script that caches the results of configure
3400# This file is a shell script that caches the results of configure
@@ -3996,7 +4068,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
3996for ac_config_target in $ac_config_targets
4068for ac_config_target in $ac_config_targets
3997do
4069do
3998 case $ac_config_target in
4070 case $ac_config_target in
3999− "src/Streamly/Internal/Data/Time/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/Streamly/Internal/Data/Time/config.h" ;;
4071+ "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;;
4000
4072
4001 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
4073 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
4002 esac
4074 esac
configure.ac+5−1
@@ -8,10 +8,14 @@ AC_INIT([streamly], [0.7.2], [streamly@composewell.com], [streamly])
8# To suppress "WARNING: unrecognized options: --with-compiler"
8# To suppress "WARNING: unrecognized options: --with-compiler"
9AC_ARG_WITH([compiler], [GHC])
9AC_ARG_WITH([compiler], [GHC])
10
10
11+# XXX Do this only for linux
12+AC_CHECK_DECLS([IN_MASK_CREATE],[],[],[#include <sys/inotify.h>])
13+AC_CHECK_DECLS([IN_EXCL_UNLINK],[],[],[#include <sys/inotify.h>])
14+
11# Check headers and functions required
15# Check headers and functions required
12AC_CHECK_HEADERS([time.h])
16AC_CHECK_HEADERS([time.h])
13AC_CHECK_FUNCS([clock_gettime])
17AC_CHECK_FUNCS([clock_gettime])
14
18
15# Output
19# Output
16−AC_CONFIG_HEADERS([src/Streamly/Internal/Data/Time/config.h])
20+AC_CONFIG_HEADERS([src/config.h])
17AC_OUTPUT
21AC_OUTPUT
src/Streamly/Internal/Data/Time/Clock.hsc+1−1
@@ -5,7 +5,7 @@
5#include "config.h"
5#include "config.h"
6#endif
6#endif
7
7
8−#include "config-clock.h"
8+#include "Streamly/Internal/Data/Time/config-clock.h"
9
9
10-- |
10-- |
11-- Module : Streamly.Internal.Data.Time.Clock
11-- Module : Streamly.Internal.Data.Time.Clock
src/Streamly/Internal/Data/Time/TimeSpec.hsc+1−1
@@ -7,7 +7,7 @@
7#include "config.h"
7#include "config.h"
8#endif
8#endif
9
9
10−#include "config-clock.h"
10+#include "Streamly/Internal/Data/Time/config-clock.h"
11
11
12-- |
12-- |
13-- Module : Streamly.Internal.Data.Time.TimeSpec
13-- Module : Streamly.Internal.Data.Time.TimeSpec
src/Streamly/Internal/Data/Time/config-clock.h+1−1
@@ -2,7 +2,7 @@
2#define HS_CLOCK_GHCJS 1
2#define HS_CLOCK_GHCJS 1
3#elif defined(_WIN32)
3#elif defined(_WIN32)
4#define HS_CLOCK_WINDOWS 1
4#define HS_CLOCK_WINDOWS 1
5−#elif (defined (HAVE_TIME_H) && defined(HAVE_CLOCK_GETTIME))
5+#elif HAVE_TIME_H && HAVE_CLOCK_GETTIME
6#define HS_CLOCK_POSIX 1
6#define HS_CLOCK_POSIX 1
7#elif __APPLE__
7#elif __APPLE__
8#define HS_CLOCK_OSX 1
8#define HS_CLOCK_OSX 1
src/Streamly/Internal/FileSystem/Event/Linux.hs+19−3
@@ -19,6 +19,8 @@
19-- 'Event' is an opaque type. Accessor functions (e.g. 'showEvent' above)
19-- 'Event' is an opaque type. Accessor functions (e.g. 'showEvent' above)
20-- provided in this module are used to determine the attributes of the event.
20-- provided in this module are used to determine the attributes of the event.
21--
21--
22+-- Identical successive events may be coalesced into a single event.
23+--
22-- =Design notes
24-- =Design notes
23--
25--
24-- For reference documentation see:
26-- For reference documentation see:
@@ -53,6 +55,9 @@
53-- 4. On Linux 'watchPaths' fails if a path does not exist, on macOS it does
55-- 4. On Linux 'watchPaths' fails if a path does not exist, on macOS it does
54-- not fail.
56-- not fail.
55
57
58+#include "config.h"
59+
60+#if HAVE_DECL_IN_EXCL_UNLINK
56module Streamly.Internal.FileSystem.Event.Linux
61module Streamly.Internal.FileSystem.Event.Linux
57 (
62 (
58 -- * Subscribing to events
63 -- * Subscribing to events
@@ -231,8 +236,11 @@ foreign import capi
231setUnwatchMoved :: Toggle -> Config -> Config
236setUnwatchMoved :: Toggle -> Config -> Config
232setUnwatchMoved = setFlag iN_EXCL_UNLINK
237setUnwatchMoved = setFlag iN_EXCL_UNLINK
233
238
239+#if HAVE_DECL_IN_MASK_CREATE
234foreign import capi
240foreign import capi
235 "sys/inotify.h value IN_MASK_CREATE" iN_MASK_CREATE :: Word32
241 "sys/inotify.h value IN_MASK_CREATE" iN_MASK_CREATE :: Word32
242+#endif
243+
236foreign import capi
244foreign import capi
237 "sys/inotify.h value IN_MASK_ADD" iN_MASK_ADD :: Word32
245 "sys/inotify.h value IN_MASK_ADD" iN_MASK_ADD :: Word32
238
246
@@ -242,9 +250,11 @@ foreign import capi
242-- /Internal/
250-- /Internal/
243--
251--
244data WhenExists =
252data WhenExists =
245− FailIfExists -- ^ Fail the API
246− | AddIfExists -- ^ Do not set an existing setting to 'Off' only set to 'On'
253+ AddIfExists -- ^ Do not set an existing setting to 'Off' only set to 'On'
247 | ReplaceIfExists -- ^ Replace the existing settings with new settings
254 | ReplaceIfExists -- ^ Replace the existing settings with new settings
255+#if HAVE_DECL_IN_MASK_CREATE
256+ | FailIfExists -- ^ Fail the API
257+#endif
248
258
249-- | When adding a new path to the watch, specify what to do if a watch already
259-- | When adding a new path to the watch, specify what to do if a watch already
250-- exists on that path.
260-- exists on that path.
@@ -256,9 +266,11 @@ data WhenExists =
256setWhenExists :: WhenExists -> Config -> Config
266setWhenExists :: WhenExists -> Config -> Config
257setWhenExists val cfg =
267setWhenExists val cfg =
258 case val of
268 case val of
259− FailIfExists -> setFlag iN_MASK_CREATE On cfg
260 AddIfExists -> setFlag iN_MASK_ADD On cfg
269 AddIfExists -> setFlag iN_MASK_ADD On cfg
261 ReplaceIfExists -> setFlag iN_MASK_ADD Off cfg
270 ReplaceIfExists -> setFlag iN_MASK_ADD Off cfg
271+#if HAVE_DECL_IN_MASK_CREATE
272+ FailIfExists -> setFlag iN_MASK_CREATE On cfg
273+#endif
262
274
263foreign import capi
275foreign import capi
264 "sys/inotify.h value IN_ONESHOT" iN_ONESHOT :: Word32
276 "sys/inotify.h value IN_ONESHOT" iN_ONESHOT :: Word32
@@ -1010,3 +1022,7 @@ showEvent ev@Event{..} =
1010 ++ "\n"
1022 ++ "\n"
1011
1023
1012 where showev f str = if f ev then "\n" ++ str else ""
1024 where showev f str = if f ev then "\n" ++ str else ""
1025+#else
1026+#warning "Disabling module Streamly.Internal.FileSystem.Event.Linux. Does not support kernels older than 2.6.36."
1027+module Streamly.Internal.FileSystem.Event.Linux () where
1028+#endif
src/Streamly/Internal/Data/Time/config.h.in → src/config.h.inrenamed+9−1
@@ -1,8 +1,16 @@
1−/* src/Streamly/Internal/Data/Time/config.h.in. Generated from configure.ac by autoheader. */
1+/* src/config.h.in. Generated from configure.ac by autoheader. */
2
2
3/* Define to 1 if you have the `clock_gettime' function. */
3/* Define to 1 if you have the `clock_gettime' function. */
4#undef HAVE_CLOCK_GETTIME
4#undef HAVE_CLOCK_GETTIME
5
5
6+/* Define to 1 if you have the declaration of `IN_EXCL_UNLINK', and to 0 if
7+ you don't. */
8+#undef HAVE_DECL_IN_EXCL_UNLINK
9+
10+/* Define to 1 if you have the declaration of `IN_MASK_CREATE', and to 0 if
11+ you don't. */
12+#undef HAVE_DECL_IN_MASK_CREATE
13+
6/* Define to 1 if you have the <inttypes.h> header file. */
14/* Define to 1 if you have the <inttypes.h> header file. */
7#undef HAVE_INTTYPES_H
15#undef HAVE_INTTYPES_H
8
16
streamly.cabal+3−4
@@ -145,7 +145,7 @@ extra-source-files:
145 src/Streamly/Internal/Data/Array/PrimInclude.hs
145 src/Streamly/Internal/Data/Array/PrimInclude.hs
146 src/Streamly/Internal/Data/Array/Prim/TypesInclude.hs
146 src/Streamly/Internal/Data/Array/Prim/TypesInclude.hs
147 src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs
147 src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs
148− src/Streamly/Internal/Data/Time/config.h.in
148+ src/config.h.in
149 src/inline.hs
149 src/inline.hs
150 stack.yaml
150 stack.yaml
151
151
@@ -153,7 +153,7 @@ extra-tmp-files:
153 config.log
153 config.log
154 config.status
154 config.status
155 autom4te.cache
155 autom4te.cache
156− src/Streamly/Internal/Data/Time/config.h
156+ src/config.h
157
157
158source-repository head
158source-repository head
159 type: git
159 type: git
@@ -347,8 +347,7 @@ library
347 default-extensions: QuantifiedConstraints
347 default-extensions: QuantifiedConstraints
348
348
349 js-sources: jsbits/clock.js
349 js-sources: jsbits/clock.js
350− include-dirs: src/Streamly/Internal/Data/Time
350+ include-dirs: src
351− , src
352 if os(windows)
351 if os(windows)
353 c-sources: src/Streamly/Internal/Data/Time/Windows.c
352 c-sources: src/Streamly/Internal/Data/Time/Windows.c
354 if os(darwin)
353 if os(darwin)