From: Eric Wong <normalperson@yhbt.net>
To: sleepy.penguin@librelist.org
Subject: Re: [sleepy.penguin] [PATCH] Support for broken system without clock_gettime.
Date: Wed, 25 Sep 2013 17:37:28 +0000 [thread overview]
Message-ID: <20130925173728.GB9181@dcvr.yhbt.net> (raw)
In-Reply-To: <CAA2_N1sWjJg83snXVjVqvZh+a_Z4-_=Y5Q80go8=w6RroH-1yA@mail.gmail.com>
"Lin Jen-Shin (godfat)" <godfat@godfat.org> wrote:
> On Wed, Sep 25, 2013 at 5:05 AM, Eric Wong <normalperson@yhbt.net> 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)
prev parent reply other threads:[~2013-09-25 17:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-24 8:55 [sleepy.penguin] [PATCH] Support for broken system without clock_gettime Lin Jen-Shin
2013-09-24 18:09 ` Eric Wong
2013-09-24 18:15 ` Lin Jen-Shin (godfat)
2013-09-24 21:05 ` Eric Wong
2013-09-25 11:43 ` Lin Jen-Shin (godfat)
2013-09-25 17:37 ` Eric Wong [this message]
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=20130925173728.GB9181@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).