1 // 2 // Authors: 3 // Tim Jenks (tim.jenks@realtimeworlds.com) 4 // 5 // (C) 2008 Realtime Worlds Ltd 6 // 7 // Permission is hereby granted, free of charge, to any person obtaining 8 // a copy of this software and associated documentation files (the 9 // "Software"), to deal in the Software without restriction, including 10 // without limitation the rights to use, copy, modify, merge, publish, 11 // distribute, sublicense, and/or sell copies of the Software, and to 12 // permit persons to whom the Software is furnished to do so, subject to 13 // the following conditions: 14 // 15 // The above copyright notice and this permission notice shall be 16 // included in all copies or substantial portions of the Software. 17 // 18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 // 26 27 using System; 28 using System.Runtime.InteropServices; 29 using System.Threading; 30 31 namespace Mono.Unix.Native { 32 33 public struct RealTimeSignum 34 : IEquatable <RealTimeSignum> 35 { 36 private int rt_offset; 37 private static readonly int MaxOffset = UnixSignal.GetSIGRTMAX () - UnixSignal.GetSIGRTMIN () - 1; 38 public static readonly RealTimeSignum MinValue = new RealTimeSignum (0); 39 public static readonly RealTimeSignum MaxValue = new RealTimeSignum (MaxOffset); 40 RealTimeSignumMono.Unix.Native.RealTimeSignum41 public RealTimeSignum (int offset) 42 { 43 if (offset < 0) 44 throw new ArgumentOutOfRangeException ("Offset cannot be negative"); 45 if (offset > MaxOffset) 46 throw new ArgumentOutOfRangeException ("Offset greater than maximum supported SIGRT"); 47 rt_offset = offset; 48 } 49 50 public int Offset { 51 get { return rt_offset; } 52 } 53 GetHashCodeMono.Unix.Native.RealTimeSignum54 public override int GetHashCode () 55 { 56 return rt_offset.GetHashCode (); 57 } 58 EqualsMono.Unix.Native.RealTimeSignum59 public override bool Equals (object obj) 60 { 61 if ((obj == null) || (obj.GetType () != GetType ())) 62 return false; 63 return Equals ((RealTimeSignum)obj); 64 } 65 EqualsMono.Unix.Native.RealTimeSignum66 public bool Equals (RealTimeSignum value) 67 { 68 return Offset == value.Offset; 69 } 70 operator ==Mono.Unix.Native.RealTimeSignum71 public static bool operator== (RealTimeSignum lhs, RealTimeSignum rhs) 72 { 73 return lhs.Equals (rhs); 74 } 75 operator !=Mono.Unix.Native.RealTimeSignum76 public static bool operator!= (RealTimeSignum lhs, RealTimeSignum rhs) 77 { 78 return !lhs.Equals (rhs); 79 } 80 } 81 } 82