[runtime] Remove handler block trampoline code
[mono.git] / mcs / class / corlib / System.Threading / Volatile.cs
1 //
2 // Volatile.cs
3 //
4 // Authors:
5 //       Marek Safar (marek.safar@gmail.com)
6 //
7 // Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26
27 using System.Runtime.ConstrainedExecution;
28 using System.Runtime.CompilerServices;
29
30 namespace System.Threading
31 {
32         public
33         static class Volatile
34         {
35                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
36                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
37                 public extern static bool Read (ref bool location);
38
39                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
40                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
41                 public extern static byte Read (ref byte location);
42
43                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
44                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
45                 [CLSCompliant (false)]
46                 public extern static sbyte Read (ref sbyte location);
47
48                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
49                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
50                 public extern static short Read (ref short location);
51
52                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
53                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
54                 [CLSCompliant (false)]
55                 public extern static ushort Read (ref ushort location);
56
57                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
58                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
59                 public extern static int Read (ref int location);
60
61                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
62                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
63                 [CLSCompliant (false)]
64                 public extern static uint Read (ref uint location);
65
66                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
67                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
68                 public extern static long Read (ref long location);
69
70                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
71                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
72                 [CLSCompliant (false)]
73                 public extern static ulong Read (ref ulong location);
74
75                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
76                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
77                 public extern static IntPtr Read (ref IntPtr location);
78
79                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
80                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
81                 [CLSCompliant (false)]
82                 public extern static UIntPtr Read (ref UIntPtr location);
83
84                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
85                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
86                 public extern static double Read (ref double location);
87
88                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
89                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
90                 public extern static float Read (ref float location);
91
92                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
93                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
94                 public extern static T Read<T> (ref T location) where T : class;
95
96                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
97                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
98                 public extern static void Write (ref bool location, bool value);
99
100                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
101                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
102                 public extern static void Write (ref byte location, byte value);
103
104                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
105                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
106                 [CLSCompliant (false)]
107                 public extern static void Write (ref sbyte location, sbyte value);
108
109                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
110                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
111                 public extern static void Write (ref short location, short value);
112
113                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
114                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
115                 [CLSCompliant (false)]
116                 public extern static void Write (ref ushort location, ushort value);
117
118                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
119                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
120                 public extern static void Write (ref int location, int value);
121
122                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
123                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
124                 [CLSCompliant (false)]
125                 public extern static void Write (ref uint location, uint value);
126
127                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
128                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
129                 public extern static void Write (ref long location, long value);
130
131                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
132                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
133                 [CLSCompliant (false)]
134                 public extern static void Write (ref ulong location, ulong value);
135
136                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
137                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
138                 public extern static void Write (ref IntPtr location, IntPtr value);
139
140                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
141                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
142                 [CLSCompliant (false)]
143                 public extern static void Write (ref UIntPtr location, UIntPtr value);
144
145                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
146                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
147                 public extern static void Write (ref double location, double value);
148
149                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
150                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
151                 public extern static void Write (ref float location, float value);
152
153                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
154                 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
155                 public extern static void Write<T>(ref T location, T value) where T : class;
156         }
157 }