aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Kernel/Process/CapabilityExtensions.cs
blob: dd133ee15da6d1bfac58d6c104976b987431c2bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Numerics;

namespace Ryujinx.HLE.HOS.Kernel.Process
{
    static class CapabilityExtensions
    {
        public static CapabilityType GetCapabilityType(this uint cap)
        {
            return (CapabilityType)(((cap + 1) & ~cap) - 1);
        }

        public static uint GetFlag(this CapabilityType type)
        {
            return (uint)type + 1;
        }

        public static uint GetId(this CapabilityType type)
        {
            return (uint)BitOperations.TrailingZeroCount(type.GetFlag());
        }
    }
}