~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to include/ruby/signal.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
 
 
3
  rubysig.h -
 
4
 
 
5
  $Author: matz $
 
6
  $Date: 2007-08-25 12:29:39 +0900 (土, 25  8月 2007) $
 
7
  created at: Wed Aug 16 01:15:38 JST 1995
 
8
 
 
9
  Copyright (C) 1993-2007 Yukihiro Matsumoto
 
10
 
 
11
**********************************************************************/
 
12
 
 
13
#ifndef RUBYSIG_H
 
14
#define RUBYSIG_H 1
 
15
 
 
16
#if defined(__cplusplus)
 
17
extern "C" {
 
18
#if 0
 
19
} /* satisfy cc-mode */
 
20
#endif
 
21
#endif
 
22
 
 
23
#include <errno.h>
 
24
 
 
25
#ifdef _WIN32
 
26
typedef LONG rb_atomic_t;
 
27
 
 
28
# define ATOMIC_TEST(var) InterlockedExchange(&(var), 0)
 
29
# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
 
30
# define ATOMIC_INC(var) InterlockedIncrement(&(var))
 
31
# define ATOMIC_DEC(var) InterlockedDecrement(&(var))
 
32
 
 
33
/* Windows doesn't allow interrupt while system calls */
 
34
# define TRAP_BEG do {\
 
35
    rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1)
 
36
 
 
37
# define TRAP_END\
 
38
    ATOMIC_SET(rb_trap_immediate, trap_immediate);\
 
39
} while (0)
 
40
 
 
41
# define RUBY_CRITICAL(statements) do {\
 
42
    rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 0);\
 
43
    statements;\
 
44
    ATOMIC_SET(rb_trap_immediate, trap_immediate);\
 
45
} while (0)
 
46
#else
 
47
typedef int rb_atomic_t;
 
48
 
 
49
# define ATOMIC_TEST(var) ((var) ? ((var) = 0, 1) : 0)
 
50
# define ATOMIC_SET(var, val) ((var) = (val))
 
51
# define ATOMIC_INC(var) (++(var))
 
52
# define ATOMIC_DEC(var) (--(var))
 
53
 
 
54
# define TRAP_BEG do {\
 
55
    int trap_immediate = rb_trap_immediate;\
 
56
    rb_trap_immediate = 1
 
57
 
 
58
# define TRAP_END \
 
59
    rb_trap_immediate = trap_immediate;\
 
60
} while (0)
 
61
 
 
62
# define RUBY_CRITICAL(statements) do {\
 
63
    int trap_immediate = rb_trap_immediate;\
 
64
    rb_trap_immediate = 0;\
 
65
    statements;\
 
66
    rb_trap_immediate = trap_immediate;\
 
67
} while (0)
 
68
#endif
 
69
RUBY_EXTERN rb_atomic_t rb_trap_immediate;
 
70
 
 
71
RUBY_EXTERN int rb_prohibit_interrupt;
 
72
#define DEFER_INTS (rb_prohibit_interrupt++)
 
73
#define ALLOW_INTS do {\
 
74
    rb_prohibit_interrupt--;\
 
75
} while (0)
 
76
#define ENABLE_INTS (rb_prohibit_interrupt--)
 
77
 
 
78
VALUE rb_with_disable_interrupt(VALUE(*)(ANYARGS),VALUE);
 
79
 
 
80
RUBY_EXTERN rb_atomic_t rb_trap_pending;
 
81
void rb_trap_restore_mask(void);
 
82
 
 
83
RUBY_EXTERN int rb_thread_critical;
 
84
void rb_thread_schedule(void);
 
85
 
 
86
#if defined(__cplusplus)
 
87
#if 0
 
88
{ /* satisfy cc-mode */
 
89
#endif
 
90
}  /* extern "C" { */
 
91
#endif
 
92
 
 
93
#endif /* RUBYSIG_H */