[#11890] Ruby and Solaris door library — "Hiro Asari" <asari.ruby@...>

Hi, there. This is my first patch against ruby. I think I followed

19 messages 2007/08/13
[#11892] Re: Ruby and Solaris door library — Daniel Berger <djberg96@...> 2007/08/14

Hiro Asari wrote:

[#11899] pack/unpack 64bit Integers — Hadmut Danisch <hadmut@...>

Hi,

13 messages 2007/08/14
[#11903] Re: pack/unpack 64bit Integers — Brian Candler <B.Candler@...> 2007/08/15

On Wed, Aug 15, 2007 at 06:50:01AM +0900, Hadmut Danisch wrote:

[#11948] Fibers in Ruby 1.9? — David Flanagan <david@...>

I just noticed that my ruby1.9 build of August 17th includes a Fiber

22 messages 2007/08/22
[#11949] Re: Fibers in Ruby 1.9? — Daniel Berger <djberg96@...> 2007/08/22

David Flanagan wrote:

[#11950] Re: Fibers in Ruby 1.9? — "Francis Cianfrocca" <garbagecat10@...> 2007/08/22

On 8/22/07, Daniel Berger <djberg96@gmail.com> wrote:

[#11952] Re: Fibers in Ruby 1.9? — MenTaLguY <mental@...> 2007/08/22

On Wed, 22 Aug 2007 20:50:12 +0900, "Francis Cianfrocca" <garbagecat10@gmail.com> wrote:

[#11988] String#length not working properly in Ruby 1.9 — "Vincent Isambart" <vincent.isambart@...>

I saw that Matz just merged his M17N implementation in the trunk.

17 messages 2007/08/25
[#11991] Re: String#length not working properly in Ruby 1.9 — "Michael Neumann" <mneumann@...> 2007/08/25

On Sat, 25 Aug 2007 10:54:20 +0200, Yukihiro Matsumoto

[#11992] Re: String#length not working properly in Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/08/25

Hi,

[#12042] Encodings of string literals; explicit codepoint escapes? — David Flanagan <david@...>

This message contains queries that probably only Matz can answer:

16 messages 2007/08/31
[#12043] Re: Encodings of string literals; explicit codepoint escapes? — Yukihiro Matsumoto <matz@...> 2007/08/31

Hi,

Re: Whatever happened to have_const?

From: Nobuyoshi Nakada <nobu@...>
Date: 2007-08-30 02:04:32 UTC
List: ruby-core #12029
Hi,

At Thu, 30 Aug 2007 05:29:57 +0900,
Daniel Berger wrote in [ruby-core:12027]:
> What ever happened to the have_const patch that was supposed to get 
> added to mkmf.rb?

Sorry, but nothing yet.

> I ask because I've hit yet another scenario where I need to check for an 
> enum value.
> 
> BTW, there's a bug in that diff - the word "type" should be replaced 
> with "const".

For the case of non-integral value as asked by Matz in
[ruby-core:04428], I'd change the check code like this.

If no objection, I want to commit it to 1.8 and trunk.
Any thoughts?


def try_const(const, header = nil, opt = "", &b)
  const, type = *const
  if try_compile(<<"SRC", opt, &b)
#{COMMON_HEADERS}
#{cpp_include(header)}
/*top*/
typedef #{type || 'int'} conftest_type;
conftest_type conftestval = #{type ? '' : '(int)'}#{const};
SRC
    $defs.push(format("-DHAVE_CONST_%s", const.strip.upcase.tr_s("^A-Z0-9_", "_")))
    true
  else
    false
  end
end

# Returns whether or not the constant +const+ is defined.  You may
# optionally pass the +type+ of +const+ as <code>[const, type]</code>,
# like as:
#
#   have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h")
#
# You may also pass additional +headers+ to check against in addition
# to the common header files, and additional flags to +opt+ which are
# then passed along to the compiler.
#
# If found, a macro is passed as a preprocessor constant to the compiler using
# the type name, in uppercase, prepended with 'HAVE_CONST_'.
#
# For example, if have_const('foo') returned true, then the HAVE_CONST_FOO
# preprocessor macro would be passed to the compiler.
#
def have_const(const, header = nil, opt = "", &b)
  checking_for checking_message([*const].compact.join(' '), header, opt) do
    try_const(const, header, opt, &b)
  end
end


-- 
Nobu Nakada

In This Thread