public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Tulak <jtulak@redhat.com>
To: xfs@oss.sgi.com
Cc: Jan Tulak <jtulak@redhat.com>
Subject: [PATCH 10/14 v2] xfsprogs: Add a timer implementation for OS X
Date: Wed, 30 Sep 2015 10:23:05 +0200	[thread overview]
Message-ID: <1443601385-831-1-git-send-email-jtulak@redhat.com> (raw)
In-Reply-To: <1442311164-12921-11-git-send-email-jtulak@redhat.com>

UPDATE:
- Instead of ifndef just call memset to zero the structure universally.

OS X does not have the timer used in xfs_repair.
Add a simple implementation providing the required
capabilities.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/darwin.h  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 repair/progress.c |  3 +--
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/include/darwin.h b/include/darwin.h
index 1409c91..0d2f175 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -28,6 +28,7 @@
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/types.h>
+#include <sys/time.h>
 #include <ftw.h>
 #include <mach/mach_time.h>
 #include <inttypes.h>
@@ -168,4 +169,51 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len)
 	return 0;
 }
 
+/*
+ * POSIX timer replacement.
+ * It really just do the minimum we need for xfs_repair.
+ * Also, as setitimer can't create multiple timers,
+ * the timerid things are useless - we have only one ITIMER_REAL
+ * timer.
+ */
+#define CLOCK_REALTIME ITIMER_REAL
+#define itimerspec itimerval
+typedef uint64_t timer_t;
+typedef double   timer_c;
+typedef clock_id_t clockid_t;
+
+
+static inline int timer_create (clockid_t __clock_id,
+                         struct sigevent *__restrict __evp,
+                         timer_t *__restrict timer)
+{
+	// set something, to initialize the variable, just in case
+	*timer = 0;
+	return 0;
+}
+
+static inline int timer_settime (timer_t timerid, int flags,
+                          const struct itimerspec *__restrict timerspec,
+                          struct itimerspec *__restrict ovalue)
+{
+	return setitimer(ITIMER_REAL, timerspec, ovalue);
+}
+
+static inline int timer_delete (timer_t timerid)
+{
+	struct itimerspec timespec;
+
+	timespec.it_interval.tv_sec=0;
+	timespec.it_interval.tv_usec=0;
+	timespec.it_value.tv_sec=0;
+	timespec.it_value.tv_usec=0;
+
+	return setitimer(ITIMER_REAL, &timespec, NULL);
+}
+
+static inline int timer_gettime (timer_t timerid, struct itimerspec *value)
+{
+	return getitimer(ITIMER_REAL, value);
+}
+
 #endif	/* __XFS_DARWIN_H__ */
diff --git a/repair/progress.c b/repair/progress.c
index 27cbaef..418b803 100644
--- a/repair/progress.c
+++ b/repair/progress.c
@@ -183,10 +183,9 @@ progress_rpt_thread (void *p)
 	 * Specify a repeating timer that fires each MSG_INTERVAL seconds.
 	 */
 
+	memset(&timespec, 0, sizeof(timespec));
 	timespec.it_value.tv_sec = msgp->interval;
-	timespec.it_value.tv_nsec = 0;
 	timespec.it_interval.tv_sec = msgp->interval;
-	timespec.it_interval.tv_nsec = 0;
 
 	if (timer_create (CLOCK_REALTIME, NULL, &timerid))
 		do_error(_("progress_rpt: cannot create timer\n"));
-- 
2.5.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2015-09-30  8:23 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-15  9:59 [PATCH 00/14 v5] xfsprogs: Partial OSX support Jan Tulak
2015-09-15  9:59 ` [PATCH 01/14] xfsprogs: Add a way to compile without blkid Jan Tulak
2015-09-15  9:59 ` [PATCH 02/14] xfsprogs: Add XATTR_LIST_MAX to OS X headers Jan Tulak
2015-09-15  9:59 ` [PATCH 03/14] xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX Jan Tulak
2015-09-23  3:09   ` Dave Chinner
2015-09-15  9:59 ` [PATCH 04/14] xfsprogs: prefix XATTR_LIST_MAX with XFS_ Jan Tulak
2015-09-23  3:15   ` Dave Chinner
2015-09-24  8:28     ` Jan Tulak
2015-09-24 22:41       ` Dave Chinner
2015-10-07 11:17   ` [PATCH 04/14 v2] " Jan Tulak
2015-09-15  9:59 ` [PATCH 05/14] xfsprogs: Add includes required for OS X builds (delta) Jan Tulak
2015-09-15  9:59 ` [PATCH 06/14] xfsprogs: Add autoconf check for fsetxattr call Jan Tulak
2015-09-15  9:59 ` [PATCH 07/14] xfsprogs: uuid changes for OS X Jan Tulak
2015-09-15  9:59 ` [PATCH 08/14] xfsprogs: Remove conflicting define " Jan Tulak
2015-09-15  9:59 ` [PATCH 09/14] xfsprogs: change nftw64 to nftw Jan Tulak
2015-09-15  9:59 ` [PATCH 10/14] xfsprogs: Add a timer implementation for OS X Jan Tulak
2015-09-23  3:25   ` Dave Chinner
2015-09-24  9:26     ` Jan Tulak
2015-09-30  8:23   ` Jan Tulak [this message]
2015-09-15  9:59 ` [PATCH 11/14] xfsprogs: Add statvfs64 for osx Jan Tulak
2015-09-23  3:32   ` Dave Chinner
2015-09-24  9:33     ` Jan Tulak
2015-09-30  8:21   ` [PATCH 11/14 v2] " Jan Tulak
2015-09-15  9:59 ` [PATCH 12/14] xfsprogs: make fsr use mntinfo when there is no mntent Jan Tulak
2015-09-23  3:36   ` Dave Chinner
2015-09-24 14:38     ` Jan Tulak
2015-09-24 22:53       ` Dave Chinner
2015-09-29 16:07         ` Jan Tulak
2015-09-29 16:04   ` [PATCH 12/14 v2] " Jan Tulak
2015-10-13  4:54     ` Dave Chinner
2015-10-13  8:45       ` Jan Tulak
2015-10-13  9:56     ` [PATCH 12/14 v3] " Jan Tulak
2015-09-15  9:59 ` [PATCH 13/14] xfsprogs: Make mremap conditional Jan Tulak
2015-10-13  4:42   ` Dave Chinner
2015-09-15  9:59 ` [PATCH 14/14] xfsprogs: rename lstat64 to lstat for OS X Jan Tulak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443601385-831-1-git-send-email-jtulak@redhat.com \
    --to=jtulak@redhat.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox