The OpenD Programming Language

1 /++
2 $(H2 Auxiliary data types and functions.)
3 
4 $(GREEN This module is is compatible with betterC compilation mode.)
5 
6 License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
7 
8 Authors:   Ilia Ki
9 +/
10 module cpuid.common;
11 
12 /// Cache Information
13 struct  Cache
14 {
15     /// Cache size in KBs
16     uint size;
17     /// Ways of associativity. Equals `associative.max` if cache is fully associative.
18     ushort associative;
19     /// Cache line in bytes
20     ushort line;
21     /// CPU cores per cache
22     ubyte cores;
23     /// `true` if cache is inclusive of lower cache levels.
24     bool inclusive;
25 
26     const @property @safe pure nothrow @nogc:
27 
28     /// Code: `associative == associative.max`
29     bool isFullyAssociative()()
30     {
31         static if (__VERSION__ >= 2068)
32             pragma(inline, true);
33         return associative == associative.max;
34     }
35 }
36 
37 /// Translation Lookaside Buffer Information
38 struct Tlb
39 {
40     /// Page size in KBs
41     uint page;
42     /// Amount of pages TLB
43     uint entries;
44     /// Ways of associativity. Equals `associative.max` if TLB is fully associative.
45     ushort associative;
46 
47     const @property @safe pure nothrow @nogc:
48 
49     /** Computes size in KBs.
50     Code: `entries * page`
51     */
52     uint size()()
53     {
54         static if (__VERSION__ >= 2068)
55             pragma(inline, true);
56         return entries * page;
57     }
58     /// Code: `associative == associative.max`
59     bool isFullyAssociative()()
60     {
61         static if (__VERSION__ >= 2068)
62             pragma(inline, true);
63         return associative == associative.max;
64     }
65 }