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: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: normalperson@yhbt.net Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 57DCE1F78D; Wed, 25 Sep 2013 17:37:28 +0000 (UTC) Date: Wed, 25 Sep 2013 17:37:28 +0000 From: Eric Wong To: sleepy.penguin@librelist.org Subject: Re: [sleepy.penguin] [PATCH] Support for broken system without clock_gettime. Message-ID: <20130925173728.GB9181@dcvr.yhbt.net> References: <1380012947-91938-1-git-send-email-godfat@godfat.org> <20130924180901.GA8085@dcvr.yhbt.net> <20130924210507.GA10409@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: "Lin Jen-Shin (godfat)" wrote: > On Wed, Sep 25, 2013 at 5:05 AM, Eric Wong wrote: > > No worries. Btw, do you have time to run/write more tests for the > > kqueue code? I think the RARRAY_PTR usage should be replaced with newer > > RARRAY_* macros or even just rb_ary_entry in some places for 2.1.0 and > > rbx. > > > > (ref: comments in https://bugs.ruby-lang.org/issues/8399) > > Would be my pleasure to do so, though maybe not in a day or two. Thanks! Not a problem, I'm juggling a bunch of projects, too. > On the other hand, since I only wrote some naive C extensions > for Ruby from copying and pasting, (i.e. readline_buffer > https://github.com/godfat/readline_buffer ) Hehe, I pretended to know C for years by copying/editing existing code/patches until I realized one day I knew it (or at least I think I do :) > I don't know why sometimes the API is in the form of macro > and sometimes in the form of function. According to my > C experience, I would prefer to use functions. > > Is there any reason why we need macros for some functions? > To inline function calls before C99? Yes. There are also some reasons such as: DATA_PTR(foo) = bar; /* do NOT do this with R{STRING,ARRAY}_PTR */ Sometimes, it's also easier to just do an "#ifdef MACRO" than to write the have_* checks in mkmf (or autoconf checks). Anyways, for arrays, I perhaps using the slightly-slower rb_ary_* functions might be best as ko1 says: http://mid.gmane.org/524259E2.9020503@atdot.net > And do we need Ruby version guards at places if some > Ruby API is missing for older Ruby? Or just like how we > did for clock_gettime? I prefer guarding based on function/macro availability whenever possible. Only in rare cases would I put version checks (e.g. a function/macro exists, but is broken for some versions)