summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2014-12-29 17:43:26 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2014-12-29 17:43:26 -0400
commitb5fbe94491a2cced7765e0ec64a2662941f2ab15 (patch)
treeeedd6c5d8113d5f235aa119cc416e0bfe99e6587
parent2faa44e9bcd774ea29757979e19d5b81b7d6c676 (diff)
fix more warnings on BSD/OSX
-rw-r--r--Utility/Touch.hsc24
1 files changed, 14 insertions, 10 deletions
diff --git a/Utility/Touch.hsc b/Utility/Touch.hsc
index 61276c523..ca4eb8475 100644
--- a/Utility/Touch.hsc
+++ b/Utility/Touch.hsc
@@ -13,11 +13,24 @@ module Utility.Touch (
touch
) where
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+
+#if (defined UTIME_OMIT && defined UTIME_NOW && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW)
+#define use_utimensat 1
+
import Utility.FileSystemEncoding
import Foreign
import Foreign.C
import Control.Monad (when)
+#endif
newtype TimeSpec = TimeSpec CTime
@@ -28,16 +41,7 @@ touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO ()
touch :: FilePath -> TimeSpec -> Bool -> IO ()
touch file mtime = touchBoth file mtime mtime
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/time.h>
-
-#ifndef _BSD_SOURCE
-#define _BSD_SOURCE
-#endif
-
-#if (defined UTIME_OMIT && defined UTIME_NOW && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW)
+#ifdef use_utimensat
at_fdcwd :: CInt
at_fdcwd = #const AT_FDCWD