sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: sleepy.penguin@librelist.org
Subject: Re: [sleepy.penguin] [PATCH] Add support for Mac OS X
Date: Mon, 26 Aug 2013 09:12:05 +0000	[thread overview]
Message-ID: <20130826091205.GA8878@dcvr.yhbt.net> (raw)
In-Reply-To: 1377506784-48542-1-git-send-email-godfat@godfat.org

Lin Jen-Shin <godfat@godfat.org> wrote:
> Since Mac OS X does not support clock_gettime, we need to wrap
> around clock_gettime to make kqueue work on Mac OS X.
> 
> epoll.c does not need this wrapper as it's only on Linux,
> but I guess it's fine to use the wrapper as well. Maybe
> someday *BSD could also support epoll in someway?

I can accept something along these lines if it only uses
generic/portable calls instead of system-specific code/ifdefs.

This way it can be easier to test/review and reusable to other platforms
which may not have proper clock_gettime

> @@ -0,0 +1,17 @@
> +#ifdef __MACH__

Use have_func() checks instead.

Actually, clogger already has a fallback for clock_gettime which works
for all platforms (but is less "correct")

	git clone git://bogomips.org/clogger.git

You can probably just copy code from that.

I can't accept using interfaces which only work on rare/non-Free systems.

> +void clock_gettime_mach(struct timespec *now){
> +	clock_serv_t cclock;
> +	mach_timespec_t mts;
> +	host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
> +	clock_get_time(cclock, &mts);
> +	mach_port_deallocate(mach_task_self(), cclock);
> +	now->tv_sec = mts.tv_sec;
> +	now->tv_nsec = mts.tv_nsec;

clogger just uses gettimeofday(), but that's usually good enough.

Also, Ruby trunk recently got Process.clock_gettime; so someday we can
just fall back to rb_funcall.

Anyways thanks for bringing this to my attention.  If you want, please
send me a patch based on what's in clogger (and that fallback in clogger
is probably buggy, too, so an extra set of eyes would be appreciated :)


  parent reply	other threads:[~2013-08-26  9:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <godfat@godfat.org>
2013-08-26  8:46 ` [sleepy.penguin] [PATCH] Add support for Mac OS X Lin Jen-Shin
2013-08-26  8:52   ` [sleepy.penguin] " Lin Jen-Shin (godfat)
2013-08-26  9:12   ` Eric Wong [this message]
2013-08-28 18:10     ` [sleepy.penguin] " Lin Jen-Shin (godfat)

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

  List information: https://yhbt.net/sleepy_penguin/

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

  git send-email \
    --in-reply-to=20130826091205.GA8878@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=sleepy.penguin@librelist.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/sleepy_penguin.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).