Project

General

Profile

Actions

Bug #1130

closed

[PATCH] extern rb_thread_blocking_region_begin/end

Added by tmm1 (Aman Gupta) about 12 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.1p0 (2009-01-30 revision 21907) [x86_64-linux]
Backport:
[ruby-core:21929]

Description

=begin
rubysig.h uses:

RUBY_EXTERN struct rb_blocking_region_buffer *rb_thread_blocking_region_begin(void);
RUBY_EXTERN void rb_thread_blocking_region_end(struct rb_blocking_region_buffer *);

which compiles and links, but does not run:

/tmp/ruby19/bin/ruby: symbol lookup error: ext.so: undefined symbol: _Z31rb_thread_blocking_region_beginv

this patch fixes the issue:

--- ruby-1.9.1-p0/include/ruby/intern.h 2009-01-16 22:38:58.000000000 -0800
+++ ruby-1.9.1-p0/include/ruby/intern.h.new 2009-02-07 23:18:10.000000000 -0800
@@ -701,6 +701,8 @@
int rb_thread_interrupted(VALUE thval);
VALUE rb_thread_blocking_region(rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2);
+RUBY_EXTERN struct rb_blocking_region_buffer *rb_thread_blocking_region_begin(void);
+RUBY_EXTERN void rb_thread_blocking_region_end(struct rb_blocking_region_buffer *);
#define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
#define RUBY_UBF_PROCESS ((rb_unblock_function_t *)-1)
VALUE rb_mutex_new(void);
=end

Actions #1

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r22123.
=end

Actions #2

Updated by tmm1 (Aman Gupta) about 12 years ago

=begin
Still having issues with g++:

/tmp/ruby19/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
g++ -I. -I/tmp/ruby19/include/ruby-1.9.1/x86_64-linux -I/tmp/ruby19/include/ruby-1.9.1/ruby/backward -I/tmp/ruby19/include/ruby-1.9.1 -I. -DBUILD_FOR_RUBY -DHAVE_RB_THREAD_BLOCKING_REGION_BEGIN -DHAVE_TBR_BEGIN -DHAVE_RB_THREAD_BLOCKING_REGION -DOS_UNIX -DHAVE_SYS_EPOLL_H -DHAVE_EPOLL -DWITH_SSL -fPIC -O2 -g -Wall -Wno-parentheses -o em.o -c em.cpp
In file included from em.h:38,
from project.h:106,
from em.cpp:24:
/tmp/ruby19/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
em.cpp: In member function 'bool EventMachine_t::_RunEpollOnce()':
em.cpp:432: error: expected primary-expression before 'void'
em.cpp:436: error: invalid conversion from 'void*' to 'rb_blocking_region_buffer*'
em.cpp:436: error: initializing argument 1 of 'void rb_thread_blocking_region_end(rb_blocking_region_buffer*)'
em.cpp:515: warning: comparison between signed and unsigned integer expressions

make: *** [em.o] Error 1
make: Leaving directory `/home/aman/code/em/ext'

I used the following patch:

diff --git a/include/ruby/backward/rubysig.h b/include/ruby/backward/rubysig.h
index 9f40f19..a645ea5 100644
--- a/include/ruby/backward/rubysig.h
+++ b/include/ruby/backward/rubysig.h
@@ -23,7 +23,7 @@
struct rb_blocking_region_buffer;
RUBY_EXTERN struct rb_blocking_region_buffer *rb_thread_blocking_region_begin(void);
RUBY_EXTERN void rb_thread_blocking_region_end(struct rb_blocking_region_buffer *);
-#define TRAP_BEG do {void *region = rb_thread_blocking_region_begin(void);
+#define TRAP_BEG do {struct rb_blocking_region_buffer *
region = rb_thread_blocking_region_begin();
#define TRAP_END rb_thread_blocking_region_end(__region);} while (0)
#define RUBY_CRITICAL(statements) do {statements;} while (0)
#define DEFER_INTS (0)

=end

Actions #3

Updated by tmm1 (Aman Gupta) about 12 years ago

=begin
Also, I think these functions should be added to intern.h so they can be used without rubysig.h

diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index db3bd2e..8c0511b 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -701,6 +701,8 @@ void rb_thread_check_ints(void);
int rb_thread_interrupted(VALUE thval);
VALUE rb_thread_blocking_region(rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2);
+RUBY_EXTERN struct rb_blocking_region_buffer *rb_thread_blocking_region_begin(void);
+RUBY_EXTERN void rb_thread_blocking_region_end(struct rb_blocking_region_buffer *);
#define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
#define RUBY_UBF_PROCESS ((rb_unblock_function_t *)-1)
VALUE rb_mutex_new(void);

=end

Actions #4

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Status changed from Closed to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

=begin

=end

Actions #5

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Status changed from Assigned to Closed

=begin
All under include/ruby/backward are deprecated.
=end

Actions #6

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Status changed from Closed to Assigned
  • Assignee changed from nobu (Nobuyoshi Nakada) to yugui (Yuki Sonoda)

=begin

=end

Actions #7

Updated by yugui (Yuki Sonoda) almost 12 years ago

  • Status changed from Assigned to Closed

=begin

=end

Actions

Also available in: Atom PDF