[#28337] constant look up order in CVS HEAD — Yukihiro Matsumoto <matz@...>

まつもと ゆきひろです

15 messages 2006/02/18
[#28338] Re: constant look up order in CVS HEAD — Tanaka Akira <akr@...17n.org> 2006/02/19

In article <1140229116.805371.31930.nullmailer@x31.priv.netlab.jp>,

[#28341] Re: constant look up order in CVS HEAD — GOTOU Yuuzou <gotoyuzo@...> 2006/02/19

In message <87lkw8xfay.fsf@m17n.org>,

[#28342] Re: constant look up order in CVS HEAD — Yukihiro Matsumoto <matz@...> 2006/02/19

まつもと ゆきひろです

[ruby-dev:28383] Re: bcc32 memory manager

From: "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
Date: 2006-02-23 13:39:14 UTC
List: ruby-dev #28383
山本です。

>|>ちょっと試してみたのですが、単に下のようにしただけだと bcc32 では
>|>落ちますね・・・・ win32 だと動くんですけど。
>|
>|ああ、すみません。原因はこれですね。
>
>コミットするかどうかはおまかせします。よろしく。

#define で置き換えるのをやめてリンカまかせ(?)にしたら
free を -1 にする必要がなさそうなのですが、testrb drb が memory allocation failed
とか言って落ちます。うーん。(#define で置き換えても同じ)

dynamic RTL の使ってるメモリ関数までは置き換えできないので、その辺に原因があるの
かもしれません。

とりあえず borlndmm.dll を使うパッチを入れておきます。

E:\ruby-cvs\temp>testrb drb
E:/ruby-cvs/ruby_1_8/lib/drb/extservm.rb:67:in `initialize': failed to allocate
memory (NoMemoryError)
        from E:/ruby-cvs/ruby_1_8/lib/drb/extservm.rb:67:in `invoke_thread'
        from E:/ruby-cvs/ruby_1_8/lib/drb/extservm.rb:27:in `initialize'
        from E:/ruby-cvs/ruby_1_8/test/drb/drbtest.rb:14
        from ..\ruby_1_8\\test\drb/test_drb.rb:1
        from E:/ruby-cvs/ruby_1_8/lib/test/unit/collector/dir.rb:83:in `collect_
file'
        from E:/ruby-cvs/ruby_1_8/lib/test/unit/collector/dir.rb:66:in `recursiv
e_collect'
        from E:/ruby-cvs/ruby_1_8/lib/test/unit/collector/dir.rb:51:in `recursiv
e_collect'
        from E:/ruby-cvs/ruby_1_8/lib/test/unit/collector/dir.rb:26:in `collect'

        from E:/ruby-cvs/ruby_1_8/lib/test/unit/autorunner.rb:67
        from E:/ruby-cvs/ruby_1_8/lib/test/unit/autorunner.rb:198:in `run'
        from ../ruby_1_8//bin/testrb:5


Index: win32.c
===================================================================
RCS file: /src/ruby/win32/win32.c,v
retrieving revision 1.103.2.43
diff -u -w -b -p -r1.103.2.43 win32.c
--- win32.c	14 Feb 2006 05:03:16 -0000	1.103.2.43
+++ win32.c	23 Feb 2006 12:45:29 -0000
@@ -3621,11 +3621,12 @@ rb_w32_isatty(int fd)
 }
 #endif
 
+#ifdef __BORLANDC__
+
 //
 // Fix bcc32's stdio bug
 //
 
-#ifdef __BORLANDC__
 static int
 too_many_files()
 {
@@ -3671,4 +3672,41 @@ rb_w32_fsopen(const char *path, const ch
     }
     return f;
 }
+
+//
+// Workaround for bcc32 internal memory manager's bug
+//
+
+static inline void *
+check(void *p)
+{
+    if (!p) errno = ENOMEM;
+
+    return p;
+}
+
+void *
+malloc(size_t n)
+{
+    return check(HeapAlloc(GetProcessHeap(), 0, n));
+}
+
+void *
+calloc(size_t i, size_t n)
+{
+    return check(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, i * n));
+}
+
+void *
+realloc(void *p, size_t n)
+{
+    return check(HeapReAlloc(GetProcessHeap(), 0, p, n));
+}
+
+void
+free(void *p)
+{
+    HeapFree(GetProcessHeap(), 0, p);
+}
+
 #endif


In This Thread