summaryrefslogtreecommitdiff
path: root/rubysig.h
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-14 07:10:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-14 07:10:31 +0000
commit46620a87720943120cabe6ffe2e94a2c3506c4c2 (patch)
tree472565a24cc842b64c3b97f573688154a1ac75bb /rubysig.h
parente9cf3b3bf56646e94df9189bfe8d6449b79ca0fb (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rubysig.h')
-rw-r--r--rubysig.h38
1 files changed, 32 insertions, 6 deletions
diff --git a/rubysig.h b/rubysig.h
index a837c01..88b3083 100644
--- a/rubysig.h
+++ b/rubysig.h
@@ -13,14 +13,40 @@
#ifndef SIG_H
#define SIG_H
-EXTERN int rb_trap_immediate;
#ifdef NT
-#define TRAP_BEG (rb_trap_immediate=1, SetEvent(rb_InterruptEvent))
-#define TRAP_END (rb_trap_immediate=0, ResetEvent(rb_InterruptEvent))
+typedef LONG rb_atomic_t;
+
+# define ATOMIC_TEST(var) InterlockedExchange(&(var), 0)
+# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
+# define ATOMIC_INC(var) InterlockedIncrement(&(var))
+# define ATOMIC_DEC(var) InterlockedDecrement(&(var))
+
+/* Windows doesn't allow interrupt while system calls */
+# define TRAP_BEG win32_enter_syscall()
+# define TRAP_END win32_leave_syscall()
+# define RUBY_CRITICAL(statements) do {\
+ win32_disable_interrupt();\
+ statements;\
+ win32_enable_interrupt();\
+} while (0)
#else
-#define TRAP_BEG (rb_trap_immediate=1)
-#define TRAP_END (rb_trap_immediate=0)
+typedef int rb_atomic_t;
+
+# define ATOMIC_TEST(var) ((var) ? ((var) = 0, 1) : 0)
+# define ATOMIC_SET(var, val) ((var) = (val))
+# define ATOMIC_INC(var) (++(var))
+# define ATOMIC_DEC(var) (--(var))
+
+# define TRAP_BEG (rb_trap_immediate=1)
+# define TRAP_END (rb_trap_immediate=0)
+# define RUBY_CRITICAL(statements) do {\
+ int trap_immediate = rb_trap_immediate;\
+ rb_trap_immediate = 0;\
+ statements;\
+ rb_trap_immediate = trap_immediate;\
+} while (0)
#endif
+EXTERN rb_atomic_t rb_trap_immediate;
EXTERN int rb_prohibit_interrupt;
#define DEFER_INTS {rb_prohibit_interrupt++;}
@@ -29,7 +55,7 @@ EXTERN int rb_prohibit_interrupt;
VALUE rb_with_disable_interrupt _((VALUE(*)(),VALUE));
-EXTERN int rb_trap_pending;
+EXTERN rb_atomic_t rb_trap_pending;
void rb_trap_restore_mask _((void));
EXTERN int rb_thread_critical;