G3D::System Class ReferenceOS and processor abstraction.
More...
#include <System.h>
List of all members.
|
Public Types |
| typedef bool(*) | OutOfMemoryCallback (size_t size, bool recoverable) |
Static Public Member Functions |
| static void | alignedFree (void *ptr) |
| static void * | alignedMalloc (size_t bytes, size_t alignment) |
| static void | beginCycleCount (uint64 &cycleCount) |
| static const std::string & | build () |
| static void * | calloc (size_t n, size_t x) |
| static void | consoleClearScreen () |
| static bool | consoleKeyPressed () |
| static int | consoleReadKey () |
| static const std::string & | cpuArchitecture () |
| static int | cpuSpeedMHz () |
| static const std::string & | cpuVendor () |
| static std::string | currentProgramFilename () |
| static void | describeSystem (std::string &s) |
| static void | describeSystem (class TextOutput &t) |
| static void | endCycleCount (uint64 &cycleCount) |
| static std::string | findDataFile (const std::string &full, bool errorIfNotFound=true) |
| static void | free (void *p) |
| static std::string | getClipboardText () |
| static uint64 | getCycleCount () |
| static const char * | getEnv (const std::string &name) |
| static bool | has3DNow () |
| static bool | hasCPUID () |
| static bool | hasMMX () |
| static bool | hasRDTSC () |
| static bool | hasSSE () |
| static bool | hasSSE2 () |
| static bool | hasSSE3 () |
| static void | init () |
| static G3DEndian | machineEndian () |
| static void * | malloc (size_t bytes) |
| static std::string | mallocPerformance () |
| static std::string | mallocStatus () |
| static void | memcpy (void *dst, const void *src, size_t numBytes) |
| static void | memset (void *dst, uint8 value, size_t numBytes) |
| static const std::string & | operatingSystem () |
| static void * | realloc (void *block, size_t bytes) |
| static void | resetMallocPerformanceCounters () |
| static void | setClipboardText (const std::string &s) |
| static void | setEnv (const std::string &name, const std::string &value) |
| static void | sleep (RealTime t) |
| static RealTime | time () |
| static const std::string & | version () |
Static Public Attributes |
| static OutOfMemoryCallback | outOfMemoryCallback |
Detailed Description
OS and processor abstraction.
The first time any method is called the processor will be analyzed. Future calls are then fast.
Timing function overview: System::getCycleCount
System::getTick
- High-resolution time in seconds since program started
System::getLocalTime
- High-resolution time in seconds since Jan 1, 1970 (because it is stored in a double, this may be less accurate than getTick)
Member Typedef Documentation
- Parameters:
-
| size | Size of memory that the system was trying to allocate |
- Parameters:
-
| recoverable | If true, the system will attempt to allocate again if the callback returns true. If false, malloc is going to return NULL and this invocation is just to notify the application. |
- Returns:
- Return true to force malloc to attempt allocation again if the error was recoverable.
Member Function Documentation
| static void G3D::System::alignedFree |
( |
void * |
ptr |
) |
[static] |
Frees memory allocated with alignedMalloc.
| static void* G3D::System::alignedMalloc |
( |
size_t |
bytes, |
|
|
size_t |
alignment | |
|
) |
| | [static] |
Guarantees that the start of the array is aligned to the specified number of bytes.
| void G3D::System::beginCycleCount |
( |
uint64 & |
cycleCount |
) |
[inline, static] |
To count the number of cycles a given operation takes:.
unsigned long count;
System::beginCycleCount(count);
...
System::endCycleCount(count);
count now contains the cycle count for the intervening operation.
| static const std::string& G3D::System::build |
( |
|
) |
[static] |
Either Debug or Release, depending on whether _DEBUG was defined at compile-time for the library.
| static void* G3D::System::calloc |
( |
size_t |
n, |
|
|
size_t |
x | |
|
) |
| | [static] |
| static void G3D::System::consoleClearScreen |
( |
|
) |
[static] |
Clears the console.
Console programs only.
| static bool G3D::System::consoleKeyPressed |
( |
|
) |
[static] |
Returns true if a key is waiting.
Console programs only.
| static int G3D::System::consoleReadKey |
( |
|
) |
[static] |
Blocks until a key is read (use consoleKeyPressed to determine if a key is waiting to be read) then returns the character code for that key.
| static const std::string& G3D::System::cpuArchitecture |
( |
|
) |
[static] |
| static int G3D::System::cpuSpeedMHz |
( |
|
) |
[static] |
Returns the speed of processor 0 in MHz.
Always returns 0 on linux.
| static const std::string& G3D::System::cpuVendor |
( |
|
) |
[static] |
| static std::string G3D::System::currentProgramFilename |
( |
|
) |
[static] |
| static void G3D::System::describeSystem |
( |
std::string & |
s |
) |
[static] |
| static void G3D::System::describeSystem |
( |
class TextOutput & |
t |
) |
[static] |
Prints a human-readable description of this machine to the text output stream.
Either argument may be NULL.
| void G3D::System::endCycleCount |
( |
uint64 & |
cycleCount |
) |
[inline, static] |
| static std::string G3D::System::findDataFile |
( |
const std::string & |
full, |
|
|
bool |
errorIfNotFound = true | |
|
) |
| | [static] |
Tries to locate the resource by looking in related directories.
If found, returns the full path to the resource, otherwise returns the empty string.
| static void G3D::System::free |
( |
void * |
p |
) |
[static] |
| static std::string G3D::System::getClipboardText |
( |
|
) |
[static] |
On Win32, returns the clipboard text contents.
Does nothing on other platforms (yet)
| uint64 G3D::System::getCycleCount |
( |
|
) |
[inline, static] |
| static const char* G3D::System::getEnv |
( |
const std::string & |
name |
) |
[static] |
Get an environment variable for the current process.
Returns NULL if the variable doesn't exist.
| static bool G3D::System::has3DNow |
( |
|
) |
[static] |
| static bool G3D::System::hasCPUID |
( |
|
) |
[static] |
| static bool G3D::System::hasMMX |
( |
|
) |
[static] |
| static bool G3D::System::hasRDTSC |
( |
|
) |
[static] |
| static bool G3D::System::hasSSE |
( |
|
) |
[static] |
| static bool G3D::System::hasSSE2 |
( |
|
) |
[static] |
| static bool G3D::System::hasSSE3 |
( |
|
) |
[static] |
| static void G3D::System::init |
( |
|
) |
[static] |
Called automatically by the other System routines.
| static G3DEndian G3D::System::machineEndian |
( |
|
) |
[static] |
Returns the endianness of this machine.
| static void* G3D::System::malloc |
( |
size_t |
bytes |
) |
[static] |
Uses pooled storage to optimize small allocations (1 byte to 5 kilobytes).
Can be 10x to 100x faster than calling malloc or new.
The result must be freed with free.
Threadsafe on Win32.
- See also:
- calloc realloc OutOfMemoryCallback free
| static std::string G3D::System::mallocPerformance |
( |
|
) |
[static] |
Returns a string describing how well System::malloc is using its internal pooled storage.
"heap" memory was slow to allocate; the other data sizes are comparatively fast.
| static std::string G3D::System::mallocStatus |
( |
|
) |
[static] |
Returns a string describing the current usage of the buffer pools used for optimizing System::malloc.
| static void G3D::System::memcpy |
( |
void * |
dst, |
|
|
const void * |
src, |
|
|
size_t |
numBytes | |
|
) |
| | [static] |
An implementation of memcpy that may be up to 2x as fast as the C library one on some processors.
Guaranteed to have the same behavior as memcpy in all cases.
| static void G3D::System::memset |
( |
void * |
dst, |
|
|
uint8 |
value, |
|
|
size_t |
numBytes | |
|
) |
| | [static] |
An implementation of memset that may be up to 2x as fast as the C library one on some processors.
Guaranteed to have the same behavior as memset in all cases.
| static const std::string& G3D::System::operatingSystem |
( |
|
) |
[static] |
e.g.
"Windows", "GNU/Linux"
| static void* G3D::System::realloc |
( |
void * |
block, |
|
|
size_t |
bytes | |
|
) |
| | [static] |
| static void G3D::System::resetMallocPerformanceCounters |
( |
|
) |
[static] |
| static void G3D::System::setClipboardText |
( |
const std::string & |
s |
) |
[static] |
Copies the text to the clipboard on Win32.
| static void G3D::System::setEnv |
( |
const std::string & |
name, |
|
|
const std::string & |
value | |
|
) |
| | [static] |
Set an environment variable for the current process.
| static void G3D::System::sleep |
( |
RealTime |
t |
) |
[static] |
Causes the current thread to yield for the specified duration and consume almost no CPU.
The sleep will be extremely precise; it uses System::time() to calibrate the exact yeild time.
| static RealTime G3D::System::time |
( |
|
) |
[static] |
The actual time (measured in seconds since Jan 1 1970 midnight).
Adjusted for local timezone and daylight savings time. This is as accurate and fast as getCycleCount().
| static const std::string& G3D::System::version |
( |
|
) |
[static] |
Member Data Documentation
When System::malloc fails to allocate memory because the system is out of memory, it invokes this handler (if it is not NULL).
The argument to the callback is the amount of memory that malloc was trying to allocate when it ran out. If the callback returns true, System::malloc will attempt to allocate the memory again. If the callback returns false, then System::malloc will return NULL.
You can use outOfMemoryCallback to free data structures or to register the failure.
The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:48 2007 for G3D by
1.5.2
Hosted by
|