aboutsummaryrefslogtreecommitdiff
path: root/lib/System
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-11-29 18:16:10 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-11-29 18:16:10 +0000
commit1f6efa3996dd1929fbc129203ce5009b620e6969 (patch)
tree6b782914982f90d3a983bcefef98b8ef68ab2961 /lib/System
parent9363f739cdc3bd02e8516a25de0090f52ae12fbb (diff)
Merge System into Support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120298 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/Alarm.cpp33
-rw-r--r--lib/System/Atomic.cpp112
-rw-r--r--lib/System/CMakeLists.txt52
-rw-r--r--lib/System/Disassembler.cpp75
-rw-r--r--lib/System/DynamicLibrary.cpp177
-rw-r--r--lib/System/Errno.cpp74
-rw-r--r--lib/System/Host.cpp307
-rw-r--r--lib/System/IncludeFile.cpp20
-rw-r--r--lib/System/Makefile20
-rw-r--r--lib/System/Memory.cpp74
-rw-r--r--lib/System/Mutex.cpp157
-rw-r--r--lib/System/Path.cpp297
-rw-r--r--lib/System/Process.cpp33
-rw-r--r--lib/System/Program.cpp56
-rw-r--r--lib/System/README.txt43
-rw-r--r--lib/System/RWMutex.cpp157
-rw-r--r--lib/System/SearchForAddressOfSpecialSymbol.cpp68
-rw-r--r--lib/System/Signals.cpp34
-rw-r--r--lib/System/ThreadLocal.cpp85
-rw-r--r--lib/System/Threading.cpp116
-rw-r--r--lib/System/TimeValue.cpp58
-rw-r--r--lib/System/Unix/Alarm.inc72
-rw-r--r--lib/System/Unix/Host.inc96
-rw-r--r--lib/System/Unix/Memory.inc151
-rw-r--r--lib/System/Unix/Mutex.inc43
-rw-r--r--lib/System/Unix/Path.inc896
-rw-r--r--lib/System/Unix/Process.inc295
-rw-r--r--lib/System/Unix/Program.inc422
-rw-r--r--lib/System/Unix/README.txt16
-rw-r--r--lib/System/Unix/RWMutex.inc43
-rw-r--r--lib/System/Unix/Signals.inc303
-rw-r--r--lib/System/Unix/ThreadLocal.inc26
-rw-r--r--lib/System/Unix/TimeValue.inc56
-rw-r--r--lib/System/Unix/Unix.h87
-rw-r--r--lib/System/Unix/system_error.inc34
-rw-r--r--lib/System/Valgrind.cpp54
-rw-r--r--lib/System/Win32/Alarm.inc43
-rw-r--r--lib/System/Win32/DynamicLibrary.inc200
-rw-r--r--lib/System/Win32/Host.inc23
-rw-r--r--lib/System/Win32/Memory.inc73
-rw-r--r--lib/System/Win32/Mutex.inc58
-rw-r--r--lib/System/Win32/Path.inc918
-rw-r--r--lib/System/Win32/Process.inc222
-rw-r--r--lib/System/Win32/Program.inc412
-rw-r--r--lib/System/Win32/RWMutex.inc58
-rw-r--r--lib/System/Win32/Signals.inc326
-rw-r--r--lib/System/Win32/ThreadLocal.inc54
-rw-r--r--lib/System/Win32/TimeValue.inc51
-rw-r--r--lib/System/Win32/Win32.h60
-rw-r--r--lib/System/Win32/system_error.inc140
-rw-r--r--lib/System/system_error.cpp121
51 files changed, 0 insertions, 7401 deletions
diff --git a/lib/System/Alarm.cpp b/lib/System/Alarm.cpp
deleted file mode 100644
index 0014ca716b..0000000000
--- a/lib/System/Alarm.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-//===- Alarm.cpp - Alarm Generation Support ---------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the Alarm functionality
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/System/Alarm.h"
-#include "llvm/Config/config.h"
-
-namespace llvm {
-using namespace sys;
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only TRULY operating system
-//=== independent code.
-//===----------------------------------------------------------------------===//
-
-}
-
-// Include the platform-specific parts of this class.
-#ifdef LLVM_ON_UNIX
-#include "Unix/Alarm.inc"
-#endif
-#ifdef LLVM_ON_WIN32
-#include "Win32/Alarm.inc"
-#endif
diff --git a/lib/System/Atomic.cpp b/lib/System/Atomic.cpp
deleted file mode 100644
index 7ba8b774d5..0000000000
--- a/lib/System/Atomic.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-//===-- Atomic.cpp - Atomic Operations --------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This header file implements atomic operations.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/System/Atomic.h"
-#include "llvm/Config/config.h"
-
-using namespace llvm;
-
-#if defined(_MSC_VER)
-#include <windows.h>
-#undef MemoryFence
-#endif
-
-void sys::MemoryFence() {
-#if LLVM_MULTITHREADED==0
- return;
-#else
-# if defined(__GNUC__)
- __sync_synchronize();
-# elif defined(_MSC_VER)
- MemoryBarrier();
-# else
-# error No memory fence implementation for your platform!
-# endif
-#endif
-}
-
-sys::cas_flag sys::CompareAndSwap(volatile sys::cas_flag* ptr,
- sys::cas_flag new_value,
- sys::cas_flag old_value) {
-#if LLVM_MULTITHREADED==0
- sys::cas_flag result = *ptr;
- if (result == old_value)
- *ptr = new_value;
- return result;
-#elif defined(__GNUC__)
- return __sync_val_compare_and_swap(ptr, old_value, new_value);
-#elif defined(_MSC_VER)
- return InterlockedCompareExchange(ptr, new_value, old_value);
-#else
-# error No compare-and-swap implementation for your platform!
-#endif
-}
-
-sys::cas_flag sys::AtomicIncrement(volatile sys::cas_flag* ptr) {
-#if LLVM_MULTITHREADED==0
- ++(*ptr);
- return *ptr;
-#elif defined(__GNUC__)
- return __sync_add_and_fetch(ptr, 1);
-#elif defined(_MSC_VER)
- return InterlockedIncrement(ptr);
-#else
-# error No atomic increment implementation for your platform!
-#endif
-}
-
-sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) {
-#if LLVM_MULTITHREADED==0
- --(*ptr);
- return *ptr;
-#elif defined(__GNUC__)
- return __sync_sub_and_fetch(ptr, 1);
-#elif defined(_MSC_VER)
- return InterlockedDecrement(ptr);
-#else
-# error No atomic decrement implementation for your platform!
-#endif
-}
-
-sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
-#if LLVM_MULTITHREADED==0
- *ptr += val;
- return *ptr;
-#elif defined(__GNUC__)
- return __sync_add_and_fetch(ptr, val);
-#elif defined(_MSC_VER)
- return InterlockedExchangeAdd(ptr, val) + val;
-#else
-# error No atomic add implementation for your platform!
-#endif
-}
-
-sys::cas_flag sys::AtomicMul(volatile sys::cas_flag* ptr, sys::cas_flag val) {
- sys::cas_flag original, result;
- do {
- original = *ptr;
- result = original * val;
- } while (sys::CompareAndSwap(ptr, result, original) != original);
-
- return result;
-}
-
-sys::cas_flag sys::AtomicDiv(volatile sys::cas_flag* ptr, sys::cas_flag val) {
- sys::cas_flag original, result;
- do {
- original = *ptr;
- result = original / val;
- } while (sys::CompareAndSwap(ptr, result, original) != original);
-
- return result;
-}
diff --git a/lib/System/CMakeLists.txt b/lib/System/CMakeLists.txt
deleted file mode 100644
index 16612ad88f..0000000000
--- a/lib/System/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-set(LLVM_REQUIRES_RTTI 1)
-if( MINGW )
- set(LLVM_REQUIRES_EH 1)
-endif()
-
-add_llvm_library(LLVMSystem
- Alarm.cpp
- Atomic.cpp
- Disassembler.cpp
- DynamicLibrary.cpp
- Errno.cpp
- Host.cpp
- IncludeFile.cpp
- Memory.cpp
- Mutex.cpp
- Path.cpp
- Process.cpp
- Program.cpp
- RWMutex.cpp
- SearchForAddressOfSpecialSymbol.cpp
- Signals.cpp
- system_error.cpp
- ThreadLocal.cpp
- Threading.cpp
- TimeValue.cpp
- Valgrind.cpp
- Unix/Alarm.inc
- Unix/Host.inc
- Unix/Memory.inc
- Unix/Mutex.inc
- Unix/Path.inc
- Unix/Process.inc
- Unix/Program.inc
- Unix/RWMutex.inc
- Unix/Signals.inc
- Unix/system_error.inc
- Unix/ThreadLocal.inc
- Unix/TimeValue.inc
- Win32/Alarm.inc
- Win32/DynamicLibrary.inc
- Win32/Host.inc
- Win32/Memory.inc
- Win32/Mutex.inc
- Win32/Path.inc
- Win32/Process.inc
- Win32/Program.inc
- Win32/RWMutex.inc
- Win32/Signals.inc
- Win32/system_error.inc
- Win32/ThreadLocal.inc
- Win32/TimeValue.inc
- )
diff --git a/lib/System/Disassembler.cpp b/lib/System/Disassembler.cpp
deleted file mode 100644
index 139e3be1aa..0000000000
--- a/lib/System/Disassembler.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//===- lib/System/Disassembler.cpp ------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the necessary glue to call external disassembler
-// libraries.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Config/config.h"
-#include "llvm/System/Disassembler.h"
-
-#include <cassert>
-#include <iomanip>
-#include <string>
-#include <sstream>
-
-#if USE_UDIS86
-#include <udis86.h>
-#endif
-
-using namespace llvm;
-
-bool llvm::sys::hasDisassembler()
-{
-#if defined (__i386__) || defined (__amd64__) || defined (__x86_64__)
- // We have option to enable udis86 library.
-# if USE_UDIS86
- return true;
-#else
- return false;
-#endif
-#else
- return false;
-#endif
-}
-
-std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
- uint64_t pc) {
- std::stringstream res;
-
-#if (defined (__i386__) || defined (__amd64__) || defined (__x86_64__)) \
- && USE_UDIS86
- unsigned bits;
-# if defined(__i386__)
- bits = 32;
-# else
- bits = 64;
-# endif
-
- ud_t ud_obj;
-
- ud_init(&ud_obj);
- ud_set_input_buffer(&ud_obj, start, length);
- ud_set_mode(&ud_obj, bits);
- ud_set_pc(&ud_obj, pc);
- ud_set_syntax(&ud_obj, UD_SYN_ATT);
-
- res << std::setbase(16)
- << std::setw(bits/4);
-
- while (ud_disassemble(&ud_obj)) {
- res << ud_insn_off(&ud_obj) << ":\t" << ud_insn_asm(&ud_obj) << "\n";
- }
-#else
- res << "No disassembler available. See configure help for options.\n";
-#endif
-
- return res.str();
-}
diff --git a/lib/System/DynamicLibrary.cpp b/lib/System/DynamicLibrary.cpp
deleted file mode 100644
index 33f86334e3..0000000000
--- a/lib/System/DynamicLibrary.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-//===-- DynamicLibrary.cpp - Runtime link/load libraries --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This header file implements the operating system DynamicLibrary concept.
-//
-// FIXME: This file leaks the ExplicitSymbols and OpenedHandles vector, and is
-// not thread safe!
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/System/DynamicLibrary.h"
-#include "llvm/System/Mutex.h"
-#include "llvm/Config/config.h"
-#include <cstdio>
-#include <cstring>
-#include <map>
-#include <vector>
-
-// Collection of symbol name/value pairs to be searched prior to any libraries.
-static std::map<std::string, void*> *ExplicitSymbols = 0;
-
-namespace {
-
-struct ExplicitSymbolsDeleter {
- ~ExplicitSymbolsDeleter() {
- if (ExplicitSymbols)
- delete ExplicitSymbols;
- }
-};
-
-}
-
-static ExplicitSymbolsDeleter Dummy;
-
-void llvm::sys::DynamicLibrary::AddSymbol(const char* symbolName,
- void *symbolValue) {
- if (ExplicitSymbols == 0)
- ExplicitSymbols = new std::map<std::string, void*>();
- (*ExplicitSymbols)[symbolName] = symbolValue;
-}
-
-#ifdef LLVM_ON_WIN32
-
-#include "Win32/DynamicLibrary.inc"
-
-#else
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-using namespace llvm;
-using namespace llvm::sys;
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only TRULY operating system
-//=== independent code.
-//===----------------------------------------------------------------------===//
-
-static SmartMutex<true>* HandlesMutex;
-static std::vector<void *> *OpenedHandles = 0;
-
-static bool InitializeMutex() {
- HandlesMutex = new SmartMutex<true>;
- return HandlesMutex != 0;
-}
-
-static bool EnsureMutexInitialized() {
- static bool result = InitializeMutex();
- return result;
-}
-
-
-bool DynamicLibrary::LoadLibraryPermanently(const char *Filename,
- std::string *ErrMsg) {
- void *H = dlopen(Filename, RTLD_LAZY|RTLD_GLOBAL);
- if (H == 0) {
- if (ErrMsg) *ErrMsg = dlerror();
- return true;
- }
-#ifdef __CYGWIN__
- // Cygwin searches symbols only in the main
- // with the handle of dlopen(NULL, RTLD_GLOBAL).
- if (Filename == NULL)
- H = RTLD_DEFAULT;
-#endif
- EnsureMutexInitialized();
- SmartScopedLock<true> Lock(*HandlesMutex);
- if (OpenedHandles == 0)
- OpenedHandles = new std::vector<void *>();
- OpenedHandles->push_back(H);
- return false;
-}
-#else
-
-using namespace llvm;
-using namespace llvm::sys;
-
-bool DynamicLibrary::LoadLibraryPermanently(const char *Filename,
- std::string *ErrMsg) {
- if (ErrMsg) *ErrMsg = "dlopen() not supported on this platform";
- return true;
-}
-#endif
-
-namespace llvm {
-void *SearchForAddressOfSpecialSymbol(const char* symbolName);
-}
-
-void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
- // First check symbols added via AddSymbol().
- if (ExplicitSymbols) {
- std::map<std::string, void *>::iterator I =
- ExplicitSymbols->find(symbolName);
- std::map<std::string, void *>::iterator E = ExplicitSymbols->end();
-
- if (I != E)
- return I->second;
- }
-
-#if HAVE_DLFCN_H
- // Now search the libraries.
- EnsureMutexInitialized();
- SmartScopedLock<true> Lock(*HandlesMutex);
- if (OpenedHandles) {
- for (std::vector<void *>::iterator I = OpenedHandles->begin(),
- E = OpenedHandles->end(); I != E; ++I) {
- //lt_ptr ptr = lt_dlsym(*I, symbolName);
- void *ptr = dlsym(*I, symbolName);
- if (ptr) {
- return ptr;
- }
- }
- }
-#endif
-
- if (void *Result = llvm::SearchForAddressOfSpecialSymbol(symbolName))
- return Result;
-
-// This macro returns the address of a well-known, explicit symbol
-#define EXPLICIT_SYMBOL(SYM) \
- if (!strcmp(symbolName, #SYM)) return &SYM
-
-// On linux we have a weird situation. The stderr/out/in symbols are both
-// macros and global variables because of standards requirements. So, we
-// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
-#if defined(__linux__)
- {
- EXPLICIT_SYMBOL(stderr);
- EXPLICIT_SYMBOL(stdout);
- EXPLICIT_SYMBOL(stdin);
- }
-#else
- // For everything else, we want to check to make sure the symbol isn't defined
- // as a macro before using EXPLICIT_SYMBOL.
- {
-#ifndef stdin
- EXPLICIT_SYMBOL(stdin);
-#endif
-#ifndef stdout
- EXPLICIT_SYMBOL(stdout);
-#endif
-#ifndef stderr
- EXPLICIT_SYMBOL(stderr);
-#endif
- }
-#endif
-#undef EXPLICIT_SYMBOL
-
- return 0;
-}
-
-#endif // LLVM_ON_WIN32
diff --git a/lib/System/Errno.cpp b/lib/System/Errno.cpp
deleted file mode 100644
index 68f66f6e43..0000000000
--- a/lib/System/Errno.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-//===- Errno.cpp - errno support --------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the errno wrappers.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/System/Errno.h"
-#include "llvm/Config/config.h" // Get autoconf configuration settings
-
-#if HAVE_STRING_H
-#include <string.h>
-
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only TRULY operating system
-//=== independent code.
-//===----------------------------------------------------------------------===//
-
-namespace llvm {
-namespace sys {
-
-#if HAVE_ERRNO_H
-std::string StrError() {
- return StrError(errno);
-}
-#endif // HAVE_ERRNO_H
-
-std::string StrError(int errnum) {
- const int MaxErrStrLen = 2000;
- char buffer[MaxErrStrLen];
- buffer[0] = '\0';
- char* str = buffer;
-#ifdef HAVE_STRERROR_R
- // strerror_r is thread-safe.
- if (errnum)
-# if defined(__GLIBC__) && defined(_GNU_SOURCE)
- // glibc defines its own incompatible version of strerror_r
- // which may not use the buffer supplied.
- str = strerror_r(errnum,buffer,MaxErrStrLen-1);
-# else
- strerror_r(errnum,buffer,MaxErrStrLen-1);
-# endif
-#elif defined(HAVE_STRERROR_S) // Windows.
- if (errnum)
- strerror_s(buffer, errnum);
-#elif defined(HAVE_STRERROR)
- // Copy the thread un-safe result of strerror into
- // the buffer as fast as possible to minimize impact
- // of collision of strerror in multiple threads.
- if (errnum)
- strncpy(buffer,strerror(errnum),MaxErrStrLen-1);
- buffer[MaxErrStrLen-1] = '\0';
-#else
- // Strange that this system doesn't even have strerror
- // but, oh well, just use a generic message
- sprintf(buffer, "Error #%d", errnum);
-#endif
- return str;
-}
-
-} // namespace sys
-} // namespace llvm
-
-#endif // HAVE_STRING_H
diff --git a/lib/System/Host.cpp b/lib/System/Host.cpp
deleted file mode 100644
index 17384a18f9..0000000000
--- a/lib/System/Host.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-//===-- Host.cpp - Implement OS Host Concept --------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This header file implements the operating system Host concept.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/System/Host.h"
-#include "llvm/Config/config.h"
-#include <string.h>
-
-// Include the platform-specific parts of this class.
-#ifdef LLVM_ON_UNIX
-#include "Unix/Host.inc"
-#endif
-#ifdef LLVM_ON_WIN32
-#include "Win32/Host.inc"
-#endif
-#ifdef _MSC_VER
-#include <intrin.h>
-#endif
-
-//===----------------------------------------------------------------------===//
-//
-// Implementations of the CPU detection routines
-//
-//===----------------------------------------------------------------------===//
-
-using namespace llvm;
-
-#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)\
- || defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
-
-/// GetX86CpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
-/// specified arguments. If we can't run cpuid on the host, return true.
-static bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX,
- unsigned *rEBX, unsigned *rECX, unsigned *rEDX) {
-#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
- #if defined(__GNUC__)
- // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
- asm ("movq\t%%rbx, %%rsi\n\t"
- "cpuid\n\t"
- "xchgq\t%%rbx, %%rsi\n\t"
- : "=a" (*rEAX),
- "=S" (*rEBX),
- "=c" (*rECX),
- "=d" (*rEDX)
- : "a" (value));
- return false;
- #elif defined(_MSC_VER)
- int registers[4];
- __cpuid(registers, value);
- *rEAX = registers[0];
- *rEBX = registers[1];
- *rECX = registers[2];
- *rEDX = registers[3];
- return false;
- #endif
-#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
- #if defined(__GNUC__)
- asm ("movl\t%%ebx, %%esi\n\t"
- "cpuid\n\t"
- "xchgl\t%%ebx, %%esi\n\t"
- : "=a" (*rEAX),
- "=S" (*rEBX),
- "=c" (*rECX),
- "=d" (*rEDX)
- : "a" (value));
- return false;
- #elif defined(_MSC_VER)
- __asm {
- mov eax,value
- cpuid
- mov esi,rEAX
- mov dword ptr [esi],eax
- mov esi,rEBX
- mov dword ptr [esi],ebx
- mov esi,rECX
- mov dword ptr [esi],ecx
- mov esi,rEDX
- mov dword ptr [esi],edx
- }
- return false;
- #endif
-#endif
- return true;
-}
-
-static void DetectX86FamilyModel(unsigned EAX, unsigned &Family,
- unsigned &Model) {
- Family = (EAX >> 8) & 0xf; // Bits 8 - 11
- Model = (EAX >> 4) & 0xf; // Bits 4 - 7
- if (Family == 6 || Family == 0xf) {
- if (Family == 0xf)
- // Examine extended family ID if family ID is F.
- Family += (EAX >> 20) & 0xff; // Bits 20 - 27
- // Examine extended model ID if family ID is 6 or F.
- Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
- }
-}
-
-std::string sys::getHostCPUName() {
- unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
- if (GetX86CpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX))
- return "generic";
- unsigned Family = 0;
- unsigned Model = 0;
- DetectX86FamilyModel(EAX, Family, Model);
-
- bool HasSSE3 = (ECX & 0x1);
- GetX86CpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
- bool Em64T = (EDX >> 29) & 0x1;
-
- union {
- unsigned u[3];
- char c[12];
- } text;
-
- GetX86CpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1);
- if (memcmp(text.c, "GenuineIntel", 12) == 0) {
- switch (Family) {
- case 3:
- return "i386";
- case 4:
- switch (Model) {
- case 0: // Intel486 DX processors
- case 1: // Intel486 DX processors
- case 2: // Intel486 SX processors
- case 3: // Intel487 processors, IntelDX2 OverDrive processors,
- // IntelDX2 processors
- case 4: // Intel486 SL processor
- case 5: // IntelSX2 processors
- case 7: // Write-Back Enhanced IntelDX2 processors
- case 8: // IntelDX4 OverDrive processors, IntelDX4 processors
- default: return "i486";
- }
- case 5:
- switch (Model) {
- case 1: // Pentium OverDrive processor for Pentium processor (60, 66),
- // Pentium processors (60, 66)
- case 2: // Pentium OverDrive processor for Pentium processor (75, 90,
- // 100, 120, 133), Pentium processors (75, 90, 100, 120, 133,
- // 150, 166, 200)
- case 3: // Pentium OverDrive processors for Intel486 processor-based
- // systems
- return "pentium";
-
- case 4: // Pentium OverDrive processor with MMX technology for Pentium
- // processor (75, 90, 100, 120, 133), Pentium processor with
- // MMX technology (166, 200)
- return "pentium-mmx";
-
- default: return "pentium";
- }
- case 6:
- switch (Model) {
- case 1: // Pentium Pro processor
- return "pentiumpro";
-
- case 3: // Intel Pentium II OverDriv