[#12164] patch for ext/gdbm — Koji Arai <JCA02266@...>

新井です。

24 messages 2001/02/04
[#12168] Re: patch for ext/gdbm — matz@... (Yukihiro Matsumoto) 2001/02/05

まつもと ゆきひろです

[#12176] Re: patch for ext/gdbm — Koji Arai <JCA02266@...> 2001/02/05

新井です。

[#12179] Re: patch for ext/gdbm — matz@... (Yukihiro Matsumoto) 2001/02/06

まつもと ゆきひろです

[#12219] Re: patch for ext/gdbm — Koji Arai <JCA02266@...> 2001/02/12

新井です。

[#12220] Re: patch for ext/gdbm — Koji Arai <JCA02266@...> 2001/02/12

新井です。

[#12256] set_trace_func — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

15 messages 2001/02/17

[#12293] crash on proc without a block — Kenichi Komiya <kom@...1.accsnet.ne.jp>

15 messages 2001/02/25

[#12323] Re: [ruby-list:28364] class definition extension — "K.Kosako" <kosako@...>

ruby-listから移動しました。

13 messages 2001/02/28
[#12324] Re: [ruby-list:28364] class definition extension — matz@... (Yukihiro Matsumoto) 2001/02/28

まつもと ゆきひろです

[ruby-dev:12224] lazy mswin32/mingw32(Re: データベース )

From: "Nobuyoshi.Nakada" <nobu.nakada@...>
Date: 2001-02-13 10:19:23 UTC
List: ruby-dev #12224
なかだです。

  dev へ持ってきます。

At Sun, 11 Feb 2001 01:27:15 +0900
WATANABE Hirofumi <eban@os.rim.or.jp> wrote:
> 原因はwin32のsignal対応か。
> これだけ遅いとなると何か考える必要がありそうです。
> 
> ruby -ne '' ruby-talk.0101 でも92秒かかる(MMX 266MHz)。

  考えてみました。というかかなりヤケクソ気味。ソケット周りとか
割り込み不可の部分をガードしてない暫定版ですが、これで mingw32 
が cygwin の3割り増しくらい、mswin32 が5割り増しちょいくらいに
なりました。

  それと my_open_osfhandle() と一緒じゃないとまずいので 
_alloc_osfhnd() は展開してみました。

# なんだか __BORLANDC__ とか入ってるし。


Index: rubysig.h
===================================================================
RCS file: /home/cvs/ruby/src/ruby/rubysig.h,v
retrieving revision 1.6
diff -u -2 -p -r1.6 rubysig.h
--- rubysig.h	2000/11/16 07:24:11	1.6
+++ rubysig.h	2001/02/13 09:02:48
@@ -23,10 +23,12 @@ typedef LONG rb_atomic_t;
 
 /* Windows doesn't allow interrupt while system calls */
-# define TRAP_BEG win32_enter_syscall()
-# define TRAP_END win32_leave_syscall()
+# define TRAP_BEG do {\
+    rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1);
+# define TRAP_END ATOMIC_SET(rb_trap_immediate, trap_immediate);\
+} while (0)
 # define RUBY_CRITICAL(statements) do {\
-    win32_disable_interrupt();\
+    win32_enter_critical();\
     statements;\
-    win32_enable_interrupt();\
+    win32_leave_critical();\
 } while (0)
 #else
Index: win32/win32.c
===================================================================
RCS file: /home/cvs/ruby/src/ruby/win32/win32.c,v
retrieving revision 1.34
diff -u -2 -p -r1.34 win32.c
--- win32/win32.c	2001/02/09 15:02:14	1.34
+++ win32/win32.c	2001/02/13 09:17:34
@@ -1706,21 +1706,8 @@ EXTERN_C _CRTIMP ioinfo * __pioinfo[];
 
 static int
-_alloc_osfhnd(void)
-{
-    HANDLE hF = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL);
-    int fh = _open_osfhandle((long)hF, 0);
-    CloseHandle(hF);
-    if (fh == -1)
-        return fh;
-#ifdef MSVCRT_THREADS
-    EnterCriticalSection(&(_pioinfo(fh)->lock));
-#endif
-    return fh;
-}
-
-static int
 my_open_osfhandle(long osfhandle, int flags)
 {
     int fh;
+    HANDLE hF;
     char fileflags;		/* _osfile flags */
 
@@ -1738,5 +1725,8 @@ my_open_osfhandle(long osfhandle, int fl
 
     /* attempt to allocate a C Runtime file handle */
-    if ((fh = _alloc_osfhnd()) == -1) {
+    hF = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL);
+    fh = _open_osfhandle((long)hF, 0);
+    CloseHandle(hF);
+    if (fh == -1) {
 	errno = EMFILE;		/* too many open files */
 	_doserrno = 0L;		/* not an OS error */
@@ -1744,4 +1734,7 @@ my_open_osfhandle(long osfhandle, int fl
     }
 
+#ifdef MSVCRT_THREADS
+    EnterCriticalSection(&(_pioinfo(fh)->lock));
+#endif
     /* the file is open. now, set the info in _osfhnd array */
     _set_osfhnd(fh, osfhandle);
@@ -2443,7 +2436,5 @@ waitpid (pid_t pid, int *stat_loc, int o
     if (wait_events((HANDLE)pid, timeout) == WAIT_OBJECT_0) {
 	pid = _cwait(stat_loc, pid, 0);
-#if !defined __BORLANDC__
 	*stat_loc <<= 8;
-#endif
 	return pid;
     }
@@ -2705,5 +2696,5 @@ static LONG flag_interrupt = -1;
 static volatile DWORD tlsi_interrupt = TLS_OUT_OF_INDEXES;
 
-void win32_disable_interrupt(void)
+void win32_enter_critical(void)
 {
     if (IsWinNT()) {
@@ -2726,5 +2717,5 @@ void win32_disable_interrupt(void)
 }
 
-void win32_enable_interrupt(void)
+void win32_leave_critical(void)
 {
     if (IsWinNT()) {
@@ -2847,5 +2838,9 @@ int win32_main_context(int arg, void (*h
 int win32_sleep(unsigned long msec)
 {
-    return wait_events(NULL, msec) != WAIT_TIMEOUT;
+    DWORD ret;
+    RUBY_CRITICAL(ret = wait_events(NULL, msec));
+    yield_once();
+    CHECK_INTS;
+    return ret != WAIT_TIMEOUT;
 }
 
@@ -2853,20 +2848,31 @@ static void catch_interrupt(void)
 {
     yield_once();
-    win32_sleep(0);
+    RUBY_CRITICAL(wait_events(NULL, 0));
     CHECK_INTS;
 }
 
-void win32_enter_syscall(void)
+int win32_getc(FILE* stream)
 {
-    InterlockedExchange(&rb_trap_immediate, 1);
-    catch_interrupt();
-    win32_disable_interrupt();
+    int c;
+    if (--stream->_cnt >= 0) {
+	c = (unsigned char)*stream->_ptr++;
+    }
+    else {
+	RUBY_CRITICAL(c = _filbuf(stream));
+	catch_interrupt();
+    }
+    return c;
 }
 
-void win32_leave_syscall(void)
+int win32_putc(int c, FILE* stream)
 {
-    win32_enable_interrupt();
-    catch_interrupt();
-    InterlockedExchange(&rb_trap_immediate, 0);
+    if (--stream->_cnt >= 0) {
+	c = (unsigned char)(*stream->_ptr++ = (char)c);
+    }
+    else {
+	RUBY_CRITICAL(c = _flsbuf(c, stream));
+	catch_interrupt();
+    }
+    return c;
 }
 
Index: win32/win32.h
===================================================================
RCS file: /home/cvs/ruby/src/ruby/win32/win32.h,v
retrieving revision 1.15
diff -u -2 -p -r1.15 win32.h
--- win32/win32.h	2001/02/09 15:02:14	1.15
+++ win32/win32.h	2001/02/13 09:30:57
@@ -113,4 +113,21 @@ extern "C++" {
 #define WNOHANG -1
 
+#undef getc
+#undef putc
+#undef fgetc
+#undef fputc
+#undef getchar
+#undef putchar
+#undef fgetchar
+#undef fputchar
+#define getc(_stream)		win32_getc(_stream)
+#define putc(_c, _stream)	win32_putc(_c, _stream)
+#define fgetc(_stream)		getc(_stream)
+#define fputc(_c, _stream)	putc(_c, _stream)
+#define getchar()		win32_getc(stdin)
+#define putchar(_c)		win32_putc(_c, stdout)
+#define fgetchar(_stream)	getchar()
+#define fputchar(_c, _stream)	putchar(_c)
+
 #define access	   _access
 #define chmod	   _chmod
@@ -428,8 +445,8 @@ HANDLE GetCurrentThreadHandle(void);
 int win32_main_context(int arg, void (*handler)(int));
 int win32_sleep(unsigned long msec);
-void win32_enter_syscall(void);
-void win32_leave_syscall(void);
-void win32_disable_interrupt(void);
-void win32_enable_interrupt(void);
+void win32_enter_critical(void);
+void win32_leave_critical(void);
+int win32_putc(int, FILE*);
+int win32_getc(FILE*);
 #define Sleep(msec) (void)win32_sleep(msec)
 


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread

Prev Next