# Useless external functions

**URL:** <https://www.ruby-forum.com/t/useless-external-functions/147702>\
**Category:** Development\
**Created:** [September 4, 2008, 12:17pm UTC](https://www.ruby-forum.com/t/useless-external-functions/147702 "2008-09-04T12:17:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SASADA\_Koichi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@SASADA\_Koichi](https://www.ruby-forum.com/u/SASADA_Koichi)\
**Post date:** [September 4, 2008, 12:17pm UTC](https://www.ruby-forum.com/t/useless-external-functions/147702/1 "2008-09-04T12:17:52Z")

</div>

Hi,

I counted references of external functions in MRI/trunk.

e$B!!e(Bhttp://www.atdot.net/sp/readonly/yr0o6k

[Function name, Reference count, Object file name]

(sorted by refcount, funcname).

It will be help for refactoring (some functions which have few  
reference count should be review).

How to make it:

$ ./ruby -v  
ruby 1.9.0 (2008-09-04 revision 19114) [i686-linux]

$ objdump -t libruby-static.a .ext/i686-linux/_.so  
.ext/i686-linux/\*\*/_.so \> syms

$ cat t.rb

global\_syms = {}  
local\_syms = {}  
und\_syms = Hash.new(0)  
file = nil

File.read(‘syms’).each{|line|  
info = line.split(/\s+/)  
if info[3] == ‘.text’  
if info[1] == ‘g’  
global\_syms[info[5]] = file  
elsif info[1] == ‘l’  
local\_syms[info[5]] = file  
else  
#  
end  
elsif info[1] == ‘_UND_’  
und\_syms[info[3]] += 1  
elsif /^(.+.(so|o))😕 =~ info[0]  
file = $1  
else  
# p line  
end  
}

st = Hash.new(0)  
global\_syms.each{|m, f|  
st[m] = und\_syms[m]  
}

st.to\_a.sort\_by{|(m, c)| [c, m]}.each{|(m, c)|  
p [m, c, global\_syms[m]]  
}

Regards,

---

<div class="post-metadata">

**Author:** ![SASADA\_Koichi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@SASADA\_Koichi](https://www.ruby-forum.com/u/SASADA_Koichi)\
**Post date:** [September 4, 2008, 2:12pm UTC](https://www.ruby-forum.com/t/useless-external-functions/147702/2 "2008-09-04T14:12:47Z")

</div>

Hello

While you are looking at this - are the visible symbols in libruby  
prefixed with something like ruby\_ or rb\_?

There seem to be a few random functions here and there, the st\_, vm\_  
iseq\_ and insn\_ stuff.  
Also oniguruma has many symbols in that list. As I understand it Ruby  
uses a modified Oniguruma so people who would like to use Ruby and  
Oniguruma might have a hard time putting it together.

With 1.8 I had some trouble linking a program using a standalone regex  
library with libruby as there was something like regex\_start in both.

Thanks

Michal

---

<div class="post-metadata">

**Author:** ![SASADA\_Koichi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@SASADA\_Koichi](https://www.ruby-forum.com/u/SASADA_Koichi)\
**Post date:** [September 7, 2008, 11:02am UTC](https://www.ruby-forum.com/t/useless-external-functions/147702/3 "2008-09-07T11:02:45Z")

</div>

On 06/09/2008, Charles Oliver N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > uses a modified Oniguruma so people who would like to use Ruby and  
> > Oniguruma might have a hard time putting it together.
> > 
> > With 1.8 I had some trouble linking a program using a standalone regex  
> > library with libruby as there was something like regex\_start in both.
> 
> The oniguruma thing should definitely be addressed. The version  
> incorporated into 1.9 would conflict if an application wanted to link both  
> 1.9 and Oniguruma.

I do not see how onigiruma is different from the other symbols that  
are not prefixed. Any other language interpreter (and even other  
programs) can have insn\_ vm\_ iseq\_ or any of the other symbols.

Thanks

Michal

---

<div class="post-metadata">

**Author:** ![SASADA\_Koichi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@SASADA\_Koichi](https://www.ruby-forum.com/u/SASADA_Koichi)\
**Post date:** [September 4, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/useless-external-functions/147702/4 "2008-09-04T14:46:50Z")

</div>

SASADA Koichi wrote:

> I counted references of external functions in MRI/trunk.
> 
> e$B!!e(Bhttp://www.atdot.net/sp/readonly/yr0o6k

Here is a variable version:  
[http://www.atdot.net/sp/readonly/4p8o6k](http://www.atdot.net/sp/readonly/4p8o6k)

---

<div class="post-metadata">

**Author:** ![SASADA\_Koichi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@SASADA\_Koichi](https://www.ruby-forum.com/u/SASADA_Koichi)\
**Post date:** [September 6, 2008, 8:45pm UTC](https://www.ruby-forum.com/t/useless-external-functions/147702/5 "2008-09-06T20:45:43Z")

</div>

Michal S. wrote:

> With 1.8 I had some trouble linking a program using a standalone regex  
> library with libruby as there was something like regex\_start in both.

The oniguruma thing should definitely be addressed. The version  
incorporated into 1.9 would conflict if an application wanted to link  
both 1.9 and Oniguruma.

I suppose it’s also worth asking why Oniguruma was imported and directly  
modified too. Why?

- Charlie
