/usr/include/d2/4.6/std/cpuid.d is in libphobos2-4.6-dev 0.29.1-4.6.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | // Written in the D programming language.
/**
* $(RED Scheduled for deprecation. Please use core.cpuid instead.)
*
* Identify the characteristics of the host CPU.
*
* Implemented according to:
- AP-485 Intel(C) Processor Identification and the CPUID Instruction
$(LINK http://www.intel.com/design/xeon/applnots/241618.htm)
- Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 2A: Instruction Set Reference, A-M
$(LINK http://developer.intel.com/design/pentium4/manuals/index_new.htm)
- AMD CPUID Specification Publication # 25481
$(LINK http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25481.pdf)
Example:
---
import std.cpuid;
import std.stdio;
void main()
{
writefln(std.cpuid.toString());
}
---
BUGS: Only works on x86 CPUs
Macros:
WIKI = Phobos/StdCpuid
Copyright: Copyright Tomas Lindquist Olsen 2007 - 2009.
License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
Authors: Tomas Lindquist Olsen <tomas@famolsen.dk>
Source: $(PHOBOSSRC std/_cpuid.d)
*/
/*
* Copyright Tomas Lindquist Olsen 2007 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module std.cpuid;
import std.string;
import std.conv;
private import core.cpuid;
version(D_InlineAsm_X86)
{
/// Returns everything as a printable string
string toString()
{
string feats;
if (mmx) feats ~= "MMX ";
if (fxsr) feats ~= "FXSR ";
if (sse) feats ~= "SSE ";
if (sse2) feats ~= "SSE2 ";
if (sse3) feats ~= "SSE3 ";
if (ssse3) feats ~= "SSSE3 ";
if (amd3dnow) feats ~= "3DNow! ";
if (amd3dnowExt) feats ~= "3DNow!+ ";
if (amdMmx) feats ~= "MMX+ ";
if (ia64) feats ~= "IA-64 ";
if (amd64) feats ~= "AMD64 ";
if (hyperThreading) feats ~= "HTT";
return format(
"Vendor string: %s\n", vendor,
"Processor string: %s\n", processor,
"Signature: Family=%d Model=%d Stepping=%d\n", family, model, stepping,
"Features: %s\n", feats,
"Multithreading: %d threads / %d cores\n", threadsPerCPU, coresPerCPU);
}
/// Returns vendor string
alias core.cpuid.vendor vendor;
/// Returns processor string
alias core.cpuid.processor processor;
/// Is MMX supported?
alias core.cpuid.mmx mmx;
/// Is FXSR supported?
alias core.cpuid.hasFxsr fxsr;
/// Is SSE supported?
alias core.cpuid.sse sse;
/// Is SSE2 supported?
alias core.cpuid.sse2 sse2;
/// Is SSE3 supported?
alias core.cpuid.sse3 sse3;
/// Is SSSE3 supported?
alias core.cpuid.ssse3 ssse3;
/// Is AMD 3DNOW supported?
alias core.cpuid.amd3dnow amd3dnow;
/// Is AMD 3DNOW Ext supported?
alias core.cpuid.amd3dnowExt amd3dnowExt;
/// Is AMD MMX supported?
alias core.cpuid.amdMmx amdMmx;
/// Is this an Intel Architecture IA64?
alias core.cpuid.isItanium ia64;
/// Is this an AMD 64?
alias core.cpuid.isX86_64 amd64;
/// Is hyperthreading supported?
alias core.cpuid.hyperThreading hyperThreading;
/// Returns number of threads per CPU
alias core.cpuid.threadsPerCPU threadsPerCPU;
/// Returns number of cores in CPU
alias core.cpuid.coresPerCPU coresPerCPU;
/// Is this an Intel processor?
bool intel() {return manufac==INTEL;}
/// Is this an AMD processor?
bool amd() {return manufac==AMD;}
/// Returns stepping
uint stepping() {return core.cpuid.stepping;}
/// Returns model
uint model() {return core.cpuid.model;}
/// Returns family
uint family() {return core.cpuid.family;}
shared static this()
{
switch (vendor())
{
case "GenuineIntel":
manufac = INTEL;
break;
case "AuthenticAMD":
manufac = AMD;
break;
default:
manufac = OTHER;
}
}
private:
// manufacturer
enum
{
OTHER,
INTEL,
AMD
}
__gshared
{
uint manufac=OTHER;
}
}
else
{
auto toString() { return "unknown CPU\n"; }
auto vendor() {return "unknown vendor"; }
auto processor() {return "unknown processor"; }
bool mmx() {return false; }
bool fxsr() {return false; }
bool sse() {return false; }
bool sse2() {return false; }
bool sse3() {return false; }
bool ssse3() {return false; }
bool amd3dnow() {return false; }
bool amd3dnowExt() {return false; }
bool amdMmx() {return false; }
bool ia64() {return false; }
bool amd64() {return false; }
bool hyperThreading() {return false; }
uint threadsPerCPU() {return 0; }
uint coresPerCPU() {return 0; }
bool intel() {return false; }
bool amd() {return false; }
uint stepping() {return 0; }
uint model() {return 0; }
uint family() {return 0; }
}
|