Forum: Ruby #defines in Ruby's .c files

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eb9493c94d8db9887e5f15284d2c767f?d=identicon&s=25 unknown (Guest)
on 2006-02-01 23:37
(Received via mailing list)
I was talking to someone on irc who was trying to speed up sockets - he
came up
with a way to do it by modifying sysread() so that a new buffer doesn't
always
have to be allocated on each call. (sped up sockets by 314x by his
account, BTW
:)  However, he had to patch the Ruby source code to do this because he
was not
able to access a macro (READ_DATA_BUFFERED) from his extenstion code.
Turns
out that the macro READ_DATA_BUFFERED is defined in io.c, so you can't
use it
from an extenstion.

So, I got to thinking that maybe #defines like that should go into .h
files,
not .c files (maybe it should be #define'd in rubyio.h) so that they are
accessable in extenstions.

Would it be possible to move some of them to .h files for 1.8.5 (or at
least
before 2.0)?

Phil
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2006-02-02 07:30
(Received via mailing list)
Hi,

In message "Re: #defines in Ruby's .c files"
    on Thu, 2 Feb 2006 06:45:53 +0900, ptkwt@aracnet.com (Phil Tomson)
writes:
|
|I was talking to someone on irc who was trying to speed up sockets - he came up
|with a way to do it by modifying sysread() so that a new buffer doesn't always
|have to be allocated on each call. (sped up sockets by 314x by his account, BTW
|:)  However, he had to patch the Ruby source code to do this because he was not
|able to access a macro (READ_DATA_BUFFERED) from his extenstion code.  Turns
|out that the macro READ_DATA_BUFFERED is defined in io.c, so you can't use it
|from an extenstion.
|
|So, I got to thinking that maybe #defines like that should go into .h files,
|not .c files (maybe it should be #define'd in rubyio.h) so that they are
|accessable in extenstions.
|
|Would it be possible to move some of them to .h files for 1.8.5 (or at least
|before 2.0)?

How about merging his patch to io.c?  I would be very glad to apply if
it increases io performance 314 times.

							matz.
Eb9493c94d8db9887e5f15284d2c767f?d=identicon&s=25 unknown (Guest)
on 2006-02-02 09:04
(Received via mailing list)
In article <1138861656.852332.2507.nullmailer@x31.priv.netlab.jp>,
Yukihiro Matsumoto  <matz@ruby-lang.org> wrote:
>|out that the macro READ_DATA_BUFFERED is defined in io.c, so you can't use it
>it increases io performance 314 times.
>
>							matz.
>
>

It looks like he found some other problems with that patch (core dumps).
So
the idea is being rethought.

Phil
This topic is locked and can not be replied to.