From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: normalperson@yhbt.net Received: from zedshaw2.xen.prgmr.com (zedshaw2.xen.prgmr.com [71.19.156.177]) by dcvr.yhbt.net (Postfix) with ESMTP id 761AC1F5B6 for ; Wed, 28 Aug 2013 18:11:16 +0000 (UTC) Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id BD97F74E7C for ; Wed, 28 Aug 2013 18:19:44 +0000 (UTC) MIME-Version: 1.0 Date: Thu, 29 Aug 2013 02:10:31 +0800 From: "Lin Jen-Shin (godfat)" List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Message-Id: Precedence: list References: <1377506784-48542-1-git-send-email-godfat@godfat.org> <20130826091205.GA8878@dcvr.yhbt.net> Sender: sleepy.penguin@librelist.org Subject: Re: [sleepy.penguin] [PATCH] Add support for Mac OS X To: sleepy.penguin@librelist.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, Aug 26, 2013 at 5:12 PM, Eric Wong wrote: > Lin Jen-Shin wrote: [...] >> @@ -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. I'll take a look later, thanks! >> +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 :) Thanks for reviewing and suggesting, too. I'll work on the patch, but only after the one for rainbows with eventmachine with threads :) Maybe this weekend, or next week...