aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/system__info_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/system__info_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/system__info_8cpp-source.html548
1 files changed, 548 insertions, 0 deletions
diff --git a/docs/doxygen/nel/system__info_8cpp-source.html b/docs/doxygen/nel/system__info_8cpp-source.html
new file mode 100644
index 00000000..96c570de
--- /dev/null
+++ b/docs/doxygen/nel/system__info_8cpp-source.html
@@ -0,0 +1,548 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>system_info.cpp</h1><a href="system__info_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026 <font class="preprocessor">#include "<a class="code" href="stdmisc_8h.html">stdmisc.h</a>"</font>
+00027
+00028 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00029 <font class="preprocessor"></font><font class="preprocessor">#include &lt;windows.h&gt;</font>
+00030 <font class="preprocessor">#include &lt;tchar.h&gt;</font>
+00031 <font class="preprocessor">#else</font>
+00032 <font class="preprocessor"></font><font class="preprocessor">#include &lt;sys/types.h&gt;</font>
+00033 <font class="preprocessor">#include &lt;sys/stat.h&gt;</font>
+00034 <font class="preprocessor">#include &lt;fcntl.h&gt;</font>
+00035 <font class="preprocessor">#include &lt;<a class="code" href="unistd_8h.html">unistd.h</a>&gt;</font>
+00036 <font class="preprocessor">#endif</font>
+00037 <font class="preprocessor"></font>
+00038 <font class="preprocessor">#include "<a class="code" href="system__info_8h.html">nel/misc/system_info.h</a>"</font>
+00039 <font class="preprocessor">#include "<a class="code" href="command_8h.html">nel/misc/command.h</a>"</font>
+00040 <font class="preprocessor">#include "<a class="code" href="include_2nel_2misc_2heap__allocator_8h.html">nel/misc/heap_allocator.h</a>"</font>
+00041
+00042 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00043
+00044 <font class="keyword">namespace </font>NLMISC {
+00045
+<a name="l00046"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d0">00046</a> string CSystemInfo::getOS ()
+00047 {
+00048 string OSString = <font class="stringliteral">"Unknown"</font>;
+00049 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00050 <font class="preprocessor"></font> <font class="keywordtype">char</font> ver[1024];
+00051
+00052 OSVERSIONINFOEX osvi;
+00053 BOOL bOsVersionInfoEx;
+00054
+00055 <font class="comment">// Try calling GetVersionEx using the OSVERSIONINFOEX structure,</font>
+00056 <font class="comment">// which is supported on Windows 2000.</font>
+00057 <font class="comment">//</font>
+00058 <font class="comment">// If that fails, try using the OSVERSIONINFO structure.</font>
+00059
+00060 ZeroMemory(&amp;osvi, <font class="keyword">sizeof</font>(OSVERSIONINFOEX));
+00061 osvi.dwOSVersionInfoSize = <font class="keyword">sizeof</font>(OSVERSIONINFOEX);
+00062
+00063 <font class="keywordflow">if</font>( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &amp;osvi)) )
+00064 {
+00065 <font class="comment">// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.</font>
+00066 osvi.dwOSVersionInfoSize = <font class="keyword">sizeof</font> (OSVERSIONINFO);
+00067 <font class="keywordflow">if</font> (! GetVersionEx ( (OSVERSIONINFO *) &amp;osvi) )
+00068 <font class="keywordflow">return</font> <font class="stringliteral">"Windows Unknown"</font>;
+00069 }
+00070
+00071 <font class="keywordflow">switch</font> (osvi.dwPlatformId)
+00072 {
+00073 <font class="keywordflow">case</font> VER_PLATFORM_WIN32_NT:
+00074 <font class="comment">// Test for the product.</font>
+00075
+00076 <font class="keywordflow">if</font> ( osvi.dwMajorVersion &lt;= 4 )
+00077 OSString = <font class="stringliteral">"Microsoft Windows NT "</font>;
+00078
+00079 <font class="keywordflow">if</font> ( osvi.dwMajorVersion == 5 )
+00080 OSString = <font class="stringliteral">"Microsoft Windows 2000 "</font>;
+00081
+00082 <font class="comment">// Test for workstation versus server.</font>
+00083 <font class="comment">/* can't access to product type</font>
+00084 <font class="comment"> if( bOsVersionInfoEx )</font>
+00085 <font class="comment"> {</font>
+00086 <font class="comment"> if ( osvi.wProductType == VER_NT_WORKSTATION )</font>
+00087 <font class="comment"> OSString += "Professional ";</font>
+00088 <font class="comment"></font>
+00089 <font class="comment"> if ( osvi.wProductType == VER_NT_SERVER )</font>
+00090 <font class="comment"> OSString += "Server ";</font>
+00091 <font class="comment"> }</font>
+00092 <font class="comment"> else</font>
+00093 <font class="comment">*/</font> {
+00094 HKEY hKey;
+00095 <font class="keywordtype">char</font> szProductType[80];
+00096 DWORD dwBufLen;
+00097
+00098 RegOpenKeyEx( HKEY_LOCAL_MACHINE, <font class="stringliteral">"SYSTEM\\CurrentControlSet\\Control\\ProductOptions"</font>, 0, KEY_QUERY_VALUE, &amp;hKey );
+00099 RegQueryValueEx( hKey, <font class="stringliteral">"ProductType"</font>, NULL, NULL, (LPBYTE) szProductType, &amp;dwBufLen);
+00100 RegCloseKey( hKey );
+00101 <font class="keywordflow">if</font> ( lstrcmpi( <font class="stringliteral">"WINNT"</font>, szProductType) == 0 )
+00102 OSString += <font class="stringliteral">"Workstation "</font>;
+00103 <font class="keywordflow">if</font> ( lstrcmpi( <font class="stringliteral">"SERVERNT"</font>, szProductType) == 0 )
+00104 OSString += <font class="stringliteral">"Server "</font>;
+00105 }
+00106
+00107 <font class="comment">// Display version, service pack (if any), and build number.</font>
+00108 <a class="code" href="namespaceNLMISC.html#a211">smprintf</a>(ver, 1024, <font class="stringliteral">"version %d.%d '%s' (Build %d)"</font>, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.szCSDVersion, osvi.dwBuildNumber &amp; 0xFFFF);
+00109 OSString += ver;
+00110 <font class="keywordflow">break</font>;
+00111
+00112 <font class="keywordflow">case</font> VER_PLATFORM_WIN32_WINDOWS:
+00113
+00114 <font class="keywordflow">if</font>(osvi.dwMinorVersion == 0)
+00115 OSString = <font class="stringliteral">"Microsoft Windows 95 "</font>;
+00116 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (osvi.dwMinorVersion == 10)
+00117 OSString = <font class="stringliteral">"Microsoft Windows 98 "</font>;
+00118 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (osvi.dwMinorVersion == 90)
+00119 OSString = <font class="stringliteral">"Microsoft Windows Millenium "</font>;
+00120 <font class="comment">/* microsoft way</font>
+00121 <font class="comment"> if ((osvi.dwMajorVersion &gt; 4) || (osvi.dwMajorVersion == 4) &amp;&amp; (osvi.dwMinorVersion &gt; 0)))</font>
+00122 <font class="comment"> OSString += "Microsoft Windows 98 ";</font>
+00123 <font class="comment"> else</font>
+00124 <font class="comment"> OSString += "Microsoft Windows 95 ";</font>
+00125 <font class="comment">*/</font>
+00126 <font class="comment">// Display version, service pack (if any), and build number.</font>
+00127 <a class="code" href="namespaceNLMISC.html#a211">smprintf</a>(ver, 1024, <font class="stringliteral">"version %d.%d %s (Build %d)"</font>, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.szCSDVersion, osvi.dwBuildNumber &amp; 0xFFFF);
+00128 OSString += ver;
+00129 <font class="keywordflow">break</font>;
+00130
+00131 <font class="keywordflow">case</font> VER_PLATFORM_WIN32s:
+00132 OSString = <font class="stringliteral">"Microsoft Win32s"</font>;
+00133 <font class="keywordflow">break</font>;
+00134 }
+00135
+00136 <font class="preprocessor">#elif defined NL_OS_UNIX</font>
+00137 <font class="preprocessor"></font>
+00138 OSString = <font class="stringliteral">"Unix"</font>;
+00139
+00140 <font class="preprocessor">#endif // NL_OS_UNIX</font>
+00141 <font class="preprocessor"></font>
+00142 <font class="keywordflow">return</font> OSString;
+00143 }
+00144
+<a name="l00145"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d1">00145</a> string CSystemInfo::getProc ()
+00146 {
+00147 string ProcString = <font class="stringliteral">"Unknown"</font>;
+00148
+00149 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00150 <font class="preprocessor"></font>
+00151 LONG result;
+00152 <font class="keywordtype">char</font> <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>[1024];
+00153 DWORD valueSize;
+00154 HKEY hKey;
+00155
+00156 result = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, <font class="stringliteral">"Hardware\\Description\\System\\CentralProcessor\\0"</font>, 0, KEY_QUERY_VALUE, &amp;hKey);
+00157 <font class="keywordflow">if</font> (result == ERROR_SUCCESS)
+00158 {
+00159 <font class="comment">// get processor name</font>
+00160 valueSize = 1024;
+00161 result = ::RegQueryValueEx (hKey, _T(<font class="stringliteral">"ProcessorNameString"</font>), NULL, NULL, (LPBYTE)&amp;<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, &amp;valueSize);
+00162 <font class="keywordflow">if</font> (result == ERROR_SUCCESS)
+00163 ProcString = <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
+00164 <font class="keywordflow">else</font>
+00165 ProcString = <font class="stringliteral">"UnknownProc"</font>;
+00166
+00167 ProcString += <font class="stringliteral">" / "</font>;
+00168
+00169 <font class="comment">// get processor identifier</font>
+00170 valueSize = 1024;
+00171 result = ::RegQueryValueEx (hKey, _T(<font class="stringliteral">"Identifier"</font>), NULL, NULL, (LPBYTE)&amp;<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, &amp;valueSize);
+00172 <font class="keywordflow">if</font> (result == ERROR_SUCCESS)
+00173 ProcString += <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
+00174 <font class="keywordflow">else</font>
+00175 ProcString += <font class="stringliteral">"UnknownIdentifier"</font>;
+00176
+00177 ProcString += <font class="stringliteral">" / "</font>;
+00178
+00179 <font class="comment">// get processor vendor</font>
+00180 valueSize = 1024;
+00181 result = ::RegQueryValueEx (hKey, _T(<font class="stringliteral">"VendorIdentifier"</font>), NULL, NULL, (LPBYTE)&amp;<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, &amp;valueSize);
+00182 <font class="keywordflow">if</font> (result == ERROR_SUCCESS)
+00183 ProcString += <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
+00184 <font class="keywordflow">else</font>
+00185 ProcString += <font class="stringliteral">"UnknownVendor"</font>;
+00186
+00187 ProcString += <font class="stringliteral">" / "</font>;
+00188
+00189 <font class="comment">// get processor frequence</font>
+00190 result = ::RegQueryValueEx (hKey, _T(<font class="stringliteral">"~MHz"</font>), NULL, NULL, (LPBYTE)&amp;<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, &amp;valueSize);
+00191 <font class="keywordflow">if</font> (result == ERROR_SUCCESS)
+00192 {
+00193 ProcString += itoa (*(<font class="keywordtype">int</font> *)<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, 10);
+00194 ProcString += <font class="stringliteral">"MHz"</font>;
+00195 }
+00196 <font class="keywordflow">else</font>
+00197 ProcString += <font class="stringliteral">"UnknownFreq"</font>;
+00198 }
+00199
+00200 <font class="comment">// Make sure to close the reg key</font>
+00201
+00202 RegCloseKey (hKey);
+00203
+00204 <font class="preprocessor">#elif defined NL_OS_UNIX</font>
+00205 <font class="preprocessor"></font>
+00206
+00207 <font class="preprocessor">#endif</font>
+00208 <font class="preprocessor"></font>
+00209 <font class="keywordflow">return</font> ProcString;
+00210 }
+00211
+<a name="l00212"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d2">00212</a> string CSystemInfo::getMem ()
+00213 {
+00214 string MemString = <font class="stringliteral">"Unknown"</font>;
+00215
+00216 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00217 <font class="preprocessor"></font>
+00218 MEMORYSTATUS ms;
+00219
+00220 GlobalMemoryStatus (&amp;ms);
+00221
+00222 sint extt = 0, extf = 0;
+00223 <font class="keywordtype">char</font> *ext2str[] = { <font class="stringliteral">"b"</font>, <font class="stringliteral">"Kb"</font>, <font class="stringliteral">"Mb"</font>, <font class="stringliteral">"Gb"</font>, <font class="stringliteral">"Tb"</font> };
+00224
+00225 <font class="keywordflow">while</font> (ms.dwTotalPhys &gt; 1024)
+00226 {
+00227 ms.dwTotalPhys /= 1024;
+00228 extt++;
+00229 }
+00230
+00231 <font class="keywordflow">while</font> (ms.dwAvailPhys &gt; 1024)
+00232 {
+00233 ms.dwAvailPhys /= 1024;
+00234 extf++;
+00235 }
+00236
+00237 <font class="keywordtype">char</font> mem[1024];
+00238 <a class="code" href="namespaceNLMISC.html#a211">smprintf</a> (mem, 1024, <font class="stringliteral">"physical memory: total: %d %s free: %d %s"</font>, ms.dwTotalPhys+1, ext2str[extt], ms.dwAvailPhys+1, ext2str[extf]);
+00239 MemString = mem;
+00240
+00241 <font class="preprocessor">#elif defined NL_OS_UNIX</font>
+00242 <font class="preprocessor"></font>
+00243
+00244 <font class="preprocessor">#endif</font>
+00245 <font class="preprocessor"></font>
+00246 <font class="keywordflow">return</font> MemString;
+00247 }
+00248
+00249
+00250 <font class="keyword">static</font> <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a291">DetectMMX</a>()
+00251 {
+00252 <font class="preprocessor"> #ifdef NL_OS_WINDOWS </font>
+00253 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!CSystemInfo::hasCPUID()) <font class="keywordflow">return</font> <font class="keyword">false</font>; <font class="comment">// cpuid not supported ...</font>
+00254
+00255 uint32 result = 0;
+00256 __asm
+00257 {
+00258 mov eax,1
+00259 cpuid
+00260 test edx,0x800000 <font class="comment">// bit 23 = MMX instruction set</font>
+00261 je noMMX
+00262 mov result, 1
+00263 noMMX:
+00264 }
+00265
+00266 <font class="keywordflow">return</font> result == 1;
+00267
+00268 <font class="comment">// printf("mmx detected\n");</font>
+00269
+00270 <font class="preprocessor"> #else</font>
+00271 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00272 <font class="preprocessor"> #endif</font>
+00273 <font class="preprocessor"></font>}
+00274
+00275
+00276 <font class="keyword">static</font> <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a292">DetectSSE</a>()
+00277 {
+00278 <font class="preprocessor"> #ifdef NL_OS_WINDOWS</font>
+00279 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!CSystemInfo::hasCPUID()) <font class="keywordflow">return</font> <font class="keyword">false</font>; <font class="comment">// cpuid not supported ...</font>
+00280
+00281 uint32 result = 0;
+00282 __asm
+00283 {
+00284 mov eax, 1 <font class="comment">// request for feature flags</font>
+00285 cpuid
+00286 test EDX, 002000000h <font class="comment">// bit 25 in feature flags equal to 1</font>
+00287 je noSSE
+00288 mov result, 1 <font class="comment">// sse detected</font>
+00289 noSSE:
+00290 }
+00291
+00292
+00293 <font class="keywordflow">if</font> (result)
+00294 {
+00295 <font class="comment">// check OS support for SSE</font>
+00296 <font class="keywordflow">try</font>
+00297 {
+00298 __asm
+00299 {
+00300 xorps xmm0, xmm0 <font class="comment">// Streaming SIMD Extension</font>
+00301 }
+00302 }
+00303 <font class="keywordflow">catch</font>(...)
+00304 {
+00305 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00306 }
+00307
+00308 <font class="comment">// printf("sse detected\n");</font>
+00309
+00310 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00311 }
+00312 <font class="keywordflow">else</font>
+00313 {
+00314 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00315 }
+00316 <font class="preprocessor"> #else</font>
+00317 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00318 <font class="preprocessor"> #endif</font>
+00319 <font class="preprocessor"></font>}
+00320
+00321 <font class="keyword">static</font> <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a203">HaveMMX</a> = <a class="code" href="namespaceNLMISC.html#a291">DetectMMX</a> ();
+00322 <font class="keyword">static</font> <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a204">HaveSSE</a> = <a class="code" href="namespaceNLMISC.html#a292">DetectSSE</a> ();
+00323
+<a name="l00324"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d3">00324</a> <font class="keywordtype">bool</font> CSystemInfo::hasCPUID ()
+00325 {
+00326 <font class="preprocessor"> #ifdef NL_OS_WINDOWS</font>
+00327 <font class="preprocessor"></font> uint32 result;
+00328 __asm
+00329 {
+00330 pushad
+00331 pushfd
+00332 <font class="comment">// If ID bit of EFLAGS can change, then cpuid is available</font>
+00333 pushfd
+00334 pop eax <font class="comment">// Get EFLAG</font>
+00335 mov ecx,eax
+00336 xor eax,0x200000 <font class="comment">// Flip ID bit</font>
+00337 push eax
+00338 popfd <font class="comment">// Write EFLAGS</font>
+00339 pushfd
+00340 pop eax <font class="comment">// read back EFLAG</font>
+00341 xor eax,ecx
+00342 je noCpuid <font class="comment">// no flip -&gt; no CPUID instr.</font>
+00343
+00344 popfd <font class="comment">// restore state</font>
+00345 popad
+00346 mov result, 1
+00347 jmp CPUIDPresent
+00348
+00349 noCpuid:
+00350 popfd <font class="comment">// restore state</font>
+00351 popad
+00352 mov result, 0
+00353 CPUIDPresent:
+00354 }
+00355 <font class="keywordflow">return</font> result == 1;
+00356 <font class="preprocessor"> #else</font>
+00357 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00358 <font class="preprocessor"> #endif</font>
+00359 <font class="preprocessor"></font>}
+<a name="l00360"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d4">00360</a> <font class="keywordtype">bool</font> CSystemInfo::hasMMX () { <font class="keywordflow">return</font> <a class="code" href="namespaceNLMISC.html#a203">HaveMMX</a>; }
+<a name="l00361"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d5">00361</a> <font class="keywordtype">bool</font> CSystemInfo::hasSSE () { <font class="keywordflow">return</font> <a class="code" href="namespaceNLMISC.html#a204">HaveSSE</a>; }
+00362
+00363
+<a name="l00364"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d6">00364</a> <font class="keywordtype">bool</font> CSystemInfo::isNT()
+00365 {
+00366 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00367 <font class="preprocessor"></font> OSVERSIONINFO ver;
+00368 ver.dwOSVersionInfoSize = <font class="keyword">sizeof</font>(OSVERSIONINFO);
+00369 GetVersionEx(&amp;ver);
+00370 <font class="keywordflow">return</font> ver.dwPlatformId == VER_PLATFORM_WIN32_NT;
+00371 <font class="preprocessor">#else</font>
+00372 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00373 <font class="preprocessor">#endif</font>
+00374 <font class="preprocessor"></font>}
+00375
+00376
+00377 <font class="preprocessor">#ifdef NL_OS_UNIX</font>
+00378 <font class="preprocessor"></font>
+00379 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNLMISC.html#a298">skipWS</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *p)
+00380 {
+00381 <font class="keywordflow">while</font> (isspace(*p)) p++;
+00382 <font class="keywordflow">return</font> (<font class="keywordtype">char</font> *)p;
+00383 }
+00384
+00385 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNLMISC.html#a299">skipToken</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *p)
+00386 {
+00387 <font class="keywordflow">while</font> (isspace(*p)) p++;
+00388 <font class="keywordflow">while</font> (*p &amp;&amp; !isspace(*p)) p++;
+00389 <font class="keywordflow">return</font> (<font class="keywordtype">char</font> *)p;
+00390 }
+00391
+00392 <font class="comment">// col: 0=total used free shared buffers cached</font>
+00393 uint32 getSystemMemory (uint col)
+00394 {
+00395 <font class="keywordflow">if</font> (col &gt; 5)
+00396 <font class="keywordflow">return</font> 0;
+00397
+00398 <font class="keywordtype">char</font> buffer[4096+1];
+00399 <font class="keywordtype">int</font> fd, len;
+00400 <font class="keywordtype">char</font> *p;
+00401
+00402 <font class="comment">/* get system wide memory usage */</font>
+00403 {
+00404 <font class="keywordtype">char</font> *p;
+00405
+00406 fd = open(<font class="stringliteral">"/proc/meminfo"</font>, O_RDONLY);
+00407 len = read(fd, buffer, <font class="keyword">sizeof</font>(buffer)-1);
+00408 close(fd);
+00409 buffer[len] = <font class="charliteral">'\0'</font>;
+00410
+00411 <font class="comment">/* be prepared for extra columns to appear be seeking</font>
+00412 <font class="comment"> to ends of lines */</font>
+00413 p = strchr(buffer, <font class="charliteral">'\n'</font>);
+00414 p = <a class="code" href="namespaceNLMISC.html#a299">skipToken</a>(p); <font class="comment">/* "Mem:" */</font>
+00415 <font class="keywordflow">for</font> (uint i = 0; i &lt; col; i++)
+00416 {
+00417 p = <a class="code" href="namespaceNLMISC.html#a299">skipToken</a>(p);
+00418 }
+00419 <font class="keywordflow">return</font> strtoul(p, &amp;p, 10);
+00420 }
+00421 }
+00422
+00423 <font class="preprocessor">#endif // NL_OS_UNIX</font>
+00424 <font class="preprocessor"></font>
+00425
+00426
+00427
+<a name="l00428"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d7">00428</a> uint32 CSystemInfo::availablePhysicalMemory ()
+00429 {
+00430 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00431 <font class="preprocessor"></font>
+00432 MEMORYSTATUS ms;
+00433 GlobalMemoryStatus (&amp;ms);
+00434 <font class="keywordflow">return</font> ms.dwAvailPhys;
+00435
+00436 <font class="preprocessor">#elif defined NL_OS_UNIX</font>
+00437 <font class="preprocessor"></font>
+00438 <font class="keywordflow">return</font> getSystemMemory (2);
+00439
+00440 <font class="preprocessor">#endif</font>
+00441 <font class="preprocessor"></font>
+00442 <font class="keywordflow">return</font> 0;
+00443 }
+00444
+<a name="l00445"></a><a class="code" href="classNLMISC_1_1CSystemInfo.html#d8">00445</a> uint32 CSystemInfo::totalPhysicalMemory ()
+00446 {
+00447 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00448 <font class="preprocessor"></font>
+00449 MEMORYSTATUS ms;
+00450 GlobalMemoryStatus (&amp;ms);
+00451 <font class="keywordflow">return</font> ms.dwTotalPhys;
+00452
+00453 <font class="preprocessor">#elif defined NL_OS_UNIX</font>
+00454 <font class="preprocessor"></font>
+00455 <font class="keywordflow">return</font> getSystemMemory (0);
+00456
+00457 <font class="preprocessor">#endif</font>
+00458 <font class="preprocessor"></font>
+00459 <font class="keywordflow">return</font> 0;
+00460 }
+00461
+00462
+00463 <a class="code" href="namespaceNLMISC.html#a314">NLMISC_DYNVARIABLE</a>(uint32, AvailablePhysicalMemory, <font class="stringliteral">"Physical memory available on this computer in bytes"</font>)
+00464 {
+00465 <font class="keywordflow">if</font> (get) *<a class="code" href="driver__opengl__extension__def_8h.html#a362">pointer</a> = CSystemInfo::availablePhysicalMemory ();
+00466 }
+00467
+00468 <a class="code" href="namespaceNLMISC.html#a314">NLMISC_DYNVARIABLE</a>(uint32, TotalPhysicalMemory, <font class="stringliteral">"Total physical memory on this computer in bytes"</font>)
+00469 {
+00470 <font class="keywordflow">if</font> (get) *<a class="code" href="driver__opengl__extension__def_8h.html#a362">pointer</a> = CSystemInfo::totalPhysicalMemory ();
+00471 }
+00472
+00473 <a class="code" href="namespaceNLMISC.html#a314">NLMISC_DYNVARIABLE</a>(uint32, ProcessUsedMemory, <font class="stringliteral">"Memory used by this process in bytes"</font>)
+00474 {
+00475 <font class="keywordflow">if</font> (get) *<a class="code" href="driver__opengl__extension__def_8h.html#a362">pointer</a> = CHeapAllocator::getAllocatedSystemMemory ();
+00476 }
+00477
+00478
+00479 } <font class="comment">// NLMISC</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>