Welcome to mirror list, hosted at ThFree Co, Russian Federation.

UnixNativeTimeval.cs « MonoLibUsb « LibWinUsb - github.com/ClusterM/clovershell-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 948609068ddcdee4c3ae947f12dd14ac13243ce3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Runtime.InteropServices;
using LibUsbDotNet.Main;

namespace MonoLibUsb
{
    /// <summary>
    /// Unix mono.net timeval structure.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct UnixNativeTimeval
    {
        private IntPtr mTvSecInternal;
        private IntPtr mTvUSecInternal;

        /// <summary>
        /// Default <see cref="UnixNativeTimeval"/> used by the <see cref="MonoUsbEventHandler"/> on windows platforms.
        /// </summary>
        public static UnixNativeTimeval WindowsDefault
        {
            get { return new UnixNativeTimeval(2, 0); }
        }

        /// <summary>
        /// Default <see cref="UnixNativeTimeval"/> used by the <see cref="MonoUsbEventHandler"/> on unix-like platforms.
        /// </summary>
        public static UnixNativeTimeval LinuxDefault
        {
            get { return new UnixNativeTimeval(2, 0); }
        }

        /// <summary>
        /// Default <see cref="UnixNativeTimeval"/>.
        /// </summary>
        public static UnixNativeTimeval Default
        {
            get { return Helper.IsLinux ? LinuxDefault : WindowsDefault; }
        }

        /// <summary>
        /// Timeval seconds property.
        /// </summary>
        public long tv_sec
        {
            get { return mTvSecInternal.ToInt64(); }
            set { mTvSecInternal = new IntPtr(value); }
        }

        /// <summary>
        /// Timeval milliseconds property.
        /// </summary>
        public long tv_usec
        {
            get { return mTvUSecInternal.ToInt64(); }
            set { mTvUSecInternal = new IntPtr(value); }
        }

        /// <summary>
        /// Timeval constructor.
        /// </summary>
        /// <param name="tvSec">seconds</param>
        /// <param name="tvUsec">milliseconds</param>
        public UnixNativeTimeval(long tvSec, long tvUsec)
        {
            mTvSecInternal = new IntPtr(tvSec);
            mTvUSecInternal = new IntPtr(tvUsec);
        }
    }
}