mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* win32/win32.[ch] (rb_w32_enter_critical, rb_w32_leave_critical): no
need to reject reentrance. removed. * rubysig.h (RUBY_CRITICAL): follow above changes. * rubysig.h (TRAP_BEG, TRAP_END): no need to save errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									20e961458e
								
							
						
					
					
						commit
						314734add8
					
				
					 5 changed files with 14 additions and 63 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,12 @@
 | 
			
		|||
Wed Apr 11 16:35:16 2007  NAKAMURA Usaku  <usa@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* win32/win32.[ch] (rb_w32_enter_critical, rb_w32_leave_critical): no
 | 
			
		||||
	  need to reject reentrance. removed.
 | 
			
		||||
 | 
			
		||||
	* rubysig.h (RUBY_CRITICAL): follow above changes.
 | 
			
		||||
 | 
			
		||||
	* rubysig.h (TRAP_BEG, TRAP_END): no need to save errno.
 | 
			
		||||
 | 
			
		||||
Tue Apr 10 17:02:17 2007  NAKAMURA Usaku  <usa@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* win32/win32.c (rb_w32_fclose, rb_w32_close): need to save errno
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								rubysig.h
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								rubysig.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -24,19 +24,16 @@ typedef LONG rb_atomic_t;
 | 
			
		|||
 | 
			
		||||
/* Windows doesn't allow interrupt while system calls */
 | 
			
		||||
# define TRAP_BEG do {\
 | 
			
		||||
    int saved_errno = 0;\
 | 
			
		||||
    rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1)
 | 
			
		||||
 | 
			
		||||
# define TRAP_END\
 | 
			
		||||
    ATOMIC_SET(rb_trap_immediate, trap_immediate);\
 | 
			
		||||
    saved_errno = errno;\
 | 
			
		||||
    errno = saved_errno;\
 | 
			
		||||
} while (0)
 | 
			
		||||
 | 
			
		||||
# define RUBY_CRITICAL(statements) do {\
 | 
			
		||||
    rb_w32_enter_critical();\
 | 
			
		||||
    rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 0);\
 | 
			
		||||
    statements;\
 | 
			
		||||
    rb_w32_leave_critical();\
 | 
			
		||||
    ATOMIC_SET(rb_trap_immediate, trap_immediate);\
 | 
			
		||||
} while (0)
 | 
			
		||||
#else
 | 
			
		||||
typedef int rb_atomic_t;
 | 
			
		||||
| 
						 | 
				
			
			@ -47,14 +44,11 @@ typedef int rb_atomic_t;
 | 
			
		|||
# define ATOMIC_DEC(var) (--(var))
 | 
			
		||||
 | 
			
		||||
# define TRAP_BEG do {\
 | 
			
		||||
    int saved_errno = 0;\
 | 
			
		||||
    int trap_immediate = rb_trap_immediate;\
 | 
			
		||||
    rb_trap_immediate = 1
 | 
			
		||||
 | 
			
		||||
# define TRAP_END \
 | 
			
		||||
    rb_trap_immediate = trap_immediate;\
 | 
			
		||||
    saved_errno = errno;\
 | 
			
		||||
    errno = saved_errno;\
 | 
			
		||||
} while (0)
 | 
			
		||||
 | 
			
		||||
# define RUBY_CRITICAL(statements) do {\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
#define RUBY_VERSION "1.9.0"
 | 
			
		||||
#define RUBY_RELEASE_DATE "2007-04-10"
 | 
			
		||||
#define RUBY_RELEASE_DATE "2007-04-11"
 | 
			
		||||
#define RUBY_VERSION_CODE 190
 | 
			
		||||
#define RUBY_RELEASE_CODE 20070410
 | 
			
		||||
#define RUBY_RELEASE_CODE 20070411
 | 
			
		||||
#define RUBY_PATCHLEVEL 0
 | 
			
		||||
 | 
			
		||||
#define RUBY_VERSION_MAJOR 1
 | 
			
		||||
| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
#define RUBY_VERSION_TEENY 0
 | 
			
		||||
#define RUBY_RELEASE_YEAR 2007
 | 
			
		||||
#define RUBY_RELEASE_MONTH 4
 | 
			
		||||
#define RUBY_RELEASE_DAY 10
 | 
			
		||||
#define RUBY_RELEASE_DAY 11
 | 
			
		||||
 | 
			
		||||
RUBY_EXTERN const char ruby_version[];
 | 
			
		||||
RUBY_EXTERN const char ruby_release_date[];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3627,56 +3627,6 @@ rb_w32_times(struct tms *tmbuf)
 | 
			
		|||
#define yield_once() Sleep(0)
 | 
			
		||||
#define yield_until(condition) do yield_once(); while (!(condition))
 | 
			
		||||
 | 
			
		||||
static CRITICAL_SECTION *
 | 
			
		||||
system_state(void)
 | 
			
		||||
{
 | 
			
		||||
    static int initialized = 0;
 | 
			
		||||
    static CRITICAL_SECTION syssect;
 | 
			
		||||
 | 
			
		||||
    if (!initialized) {
 | 
			
		||||
	InitializeCriticalSection(&syssect);
 | 
			
		||||
	initialized = 1;
 | 
			
		||||
    }
 | 
			
		||||
    return &syssect;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static LONG flag_interrupt = -1;
 | 
			
		||||
static volatile DWORD tlsi_interrupt = TLS_OUT_OF_INDEXES;
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
rb_w32_enter_critical(void)
 | 
			
		||||
{
 | 
			
		||||
    if (IsWinNT()) {
 | 
			
		||||
	EnterCriticalSection(system_state());
 | 
			
		||||
	return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (tlsi_interrupt == TLS_OUT_OF_INDEXES) {
 | 
			
		||||
	tlsi_interrupt = TlsAlloc();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
	DWORD ti = (DWORD)TlsGetValue(tlsi_interrupt);
 | 
			
		||||
	while (InterlockedIncrement(&flag_interrupt) > 0 && !ti) {
 | 
			
		||||
	    InterlockedDecrement(&flag_interrupt);
 | 
			
		||||
	    Sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
	TlsSetValue(tlsi_interrupt, (PVOID)++ti);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
rb_w32_leave_critical(void)
 | 
			
		||||
{
 | 
			
		||||
    if (IsWinNT()) {
 | 
			
		||||
	LeaveCriticalSection(system_state());
 | 
			
		||||
	return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    InterlockedDecrement(&flag_interrupt);
 | 
			
		||||
    TlsSetValue(tlsi_interrupt, (PVOID)((DWORD)TlsGetValue(tlsi_interrupt) - 1));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct handler_arg_t {
 | 
			
		||||
    void (*handler)(int);
 | 
			
		||||
    int arg;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -508,8 +508,6 @@ int rb_w32_times(struct tms *);
 | 
			
		|||
/* thread stuff */
 | 
			
		||||
HANDLE GetCurrentThreadHandle(void);
 | 
			
		||||
int  rb_w32_sleep(unsigned long msec);
 | 
			
		||||
void rb_w32_enter_critical(void);
 | 
			
		||||
void rb_w32_leave_critical(void);
 | 
			
		||||
int  rb_w32_putc(int, FILE*);
 | 
			
		||||
int  rb_w32_getc(FILE*);
 | 
			
		||||
int  rb_w32_close(int);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue