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=AWL,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 8E8591F70D for ; Mon, 26 Aug 2013 09:12:11 +0000 (UTC) Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id 1401B74C4D for ; Mon, 26 Aug 2013 09:20:29 +0000 (UTC) MIME-Version: 1.0 Date: Mon, 26 Aug 2013 09:12:05 +0000 From: Eric Wong List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Message-Id: <20130826091205.GA8878@dcvr.yhbt.net> Precedence: list References: <1377506784-48542-1-git-send-email-godfat@godfat.org> 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 Lin Jen-Shin 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 :)