Skip to content

Commit

Permalink
Merge pull request #80 from ZimbiX/fix-gem-require-in-termux-on-android
Browse files Browse the repository at this point in the history
Fix require failing in Termux on Android
  • Loading branch information
SamSaffron committed Jun 29, 2020
2 parents aff85bb + 5b18f29 commit 4b6b80c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
9 changes: 7 additions & 2 deletions ext/rbtrace.c
Expand Up @@ -51,6 +51,11 @@
#endif


// The SUN_LEN macro is not available on Android
#ifndef SUN_LEN
#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen((ptr)->sun_path))
#endif

static uint64_t
ru_utime_usec()
{
Expand Down Expand Up @@ -688,7 +693,7 @@ rbtracer_add(char *query, bool is_slow)
*idx = NULL,
*method = NULL;

if (NULL != (idx = rindex(query, '.'))) {
if (NULL != (idx = strrchr(query, '.'))) {
klass_begin = 0;
klass_end = idx - query;
is_singleton = true;
Expand All @@ -700,7 +705,7 @@ rbtracer_add(char *query, bool is_slow)

method = idx+1;

} else if (NULL != (idx = rindex(query, '#'))) {
} else if (NULL != (idx = strrchr(query, '#'))) {
klass_begin = 0;
klass_end = idx - query;
is_singleton = false;
Expand Down
23 changes: 13 additions & 10 deletions server.rb
@@ -1,4 +1,5 @@
require 'ext/rbtrace'
require 'tmpdir'

class String
def multiply_vowels(num)
Expand Down Expand Up @@ -26,19 +27,21 @@ def self.run

while true
proc {
Dir.chdir("/tmp") do
Dir.pwd
Process.pid
'hello'.multiply_vowels(3){ :ohai }
sleep rand*0.5
Dir.mktmpdir do |tmp|
Dir.chdir(tmp) do
Dir.pwd
Process.pid
'hello'.multiply_vowels(3){ :ohai }
sleep rand*0.5

ENV['blah']
GC.start
ENV['blah']
GC.start

reload_test.call
Test.run
reload_test.call
Test.run

#fib(1024*100)
#fib(1024*100)
end
end
}.call
end

0 comments on commit 4b6b80c

Please sign in to comment.