[crisscross commit] r879 - in trunk: . examples/CPUID source source/crisscross targets/vs2008 tools

0 views
Skip to first unread message

codesite...@google.com

unread,
Oct 19, 2008, 8:21:01 PM10/19/08
to crisscr...@googlegroups.com
Author: steven.noonan
Date: Sun Oct 19 17:20:26 2008
New Revision: 879

Modified:
trunk/CHANGES
trunk/CMakeLists.txt
trunk/clean.sh
trunk/examples/CPUID/main.cpp
trunk/source/cpuid.cpp
trunk/source/crisscross/cpuid.h
trunk/targets/vs2008/.gitignore
trunk/tools/GenerateBuildNumber.sh

Log:
Update to Git commit dae2ee93deuu434ff6b3ee1e90ebd55d3f5c384c


Modified: trunk/CHANGES
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Sun Oct 19 17:20:26 2008
@@ -1,5 +1,6 @@
VERSION 0.7.2 (r???)
* Old (and buggy) build system removed in favor of CMake.
+ * Changed source control to Git from Subversion.
* Fixed a few memory leaks in CPUID.
* Added support for DEC Alpha and Sun SPARC.
* Documentation is now more verbose and has been clarified in some areas.

Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Sun Oct 19 17:20:26 2008
@@ -40,7 +40,6 @@
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Yu\"${_headerName}\"")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yu\"${_headerName}\"")
GET_FILENAME_COMPONENT(_sourceFile ${_source} NAME)
- MESSAGE(STATUS "${_sourceFile}")
set_source_files_properties("${_sourceFile}"
COMPILE_FLAGS "/Yc\"${_headerName}\""
)
@@ -119,7 +118,10 @@
ENDMACRO(ADD_FLAG)

if(CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -ggdb -fno-rtti
-fno-exceptions -rdynamic -Wall -Wno-long-long -pedantic")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98 -fno-rtti
-fno-exceptions -Wall -Wno-long-long -pedantic")
+ if(NOT CYGWIN)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -rdynamic")
+ endif(NOT CYGWIN)
endif(CMAKE_COMPILER_IS_GNUCXX)

# settings for Microsoft Visual C

Modified: trunk/clean.sh
==============================================================================
--- trunk/clean.sh (original)
+++ trunk/clean.sh Sun Oct 19 17:20:26 2008
@@ -1,20 +1,30 @@
#!/bin/bash

+# Quick sanity check.
+if [ ! -d .svn ]; then
+ if [ ! -d .git ]; then
+ echo "This project doesn't seem to be under source control."
+ exit 1
+ fi
+fi
+
echo
-echo "The following files will be purged:"
if [ -d .svn ]; then
svn status --no-ignore | grep ^[I?] | sed 's/^[I?]//g' | sed 's/^[ ].//g'
else
- git clean -n -f -x -d
+ if [ -d .git ]; then
+ git clean -nfxd
+ fi
fi
+echo

+read -p "Remove the above listed files (Y/N)? "
echo
-read -p "Continue (Y/N)? "
if [ "$REPLY" == "y" ]; then
if [ -d .svn ]; then
rm -rvf `svn status --no-ignore | grep ^[I?] | sed 's/^[I?]//g' |
sed 's/^[ ].//g'`
else
- git clean -f -x -d
+ git clean -fxd
fi
else
echo

Modified: trunk/examples/CPUID/main.cpp
==============================================================================
--- trunk/examples/CPUID/main.cpp (original)
+++ trunk/examples/CPUID/main.cpp Sun Oct 19 17:20:26 2008
@@ -113,17 +113,12 @@
CrissCross::Data::DArray<const char *> *featureIDs =
cpuid->proc[i]->features.ConvertIndexToDArray();

- CrissCross::Data::DArray<CrissCross::System::Feature *> *features =
- cpuid->proc[i]->features.ConvertToDArray();
-
for (size_t i = 0; i < featureIDs->size(); i++) {
if (featureIDs->valid(i))
- if (features->get(i)->Enabled)
- console->Write("%s ", featureIDs->get(i));
+ console->Write("%s ", featureIDs->get(i));
}

delete featureIDs;
- delete features;

console->WriteLine();
console->WriteLine();

Modified: trunk/source/cpuid.cpp
==============================================================================
--- trunk/source/cpuid.cpp (original)
+++ trunk/source/cpuid.cpp Sun Oct 19 17:20:26 2008
@@ -117,13 +117,12 @@
struct Registers *Ext;
unsigned int ExtMax;

-#if defined (TARGET_COMPILER_GCC)
-
/* If the current processor supports the CPUID instruction, execute
* one, with REQUEST in %eax, and set *EAX, *EBX, *ECX, and *EDX to
* the values the 'cpuid' stored in those registers. Return true if
* the current processor supports CPUID, false otherwise. */
- static bool call_cpuid(unsigned int request, unsigned int *eax, unsigned
int *ebx, unsigned int *ecx, unsigned int *edx)
+ static bool call_cpuid(unsigned int request, unsigned int *_eax,
+ unsigned int *_ebx, unsigned int *_ecx, unsigned int *_edx)
{
#ifndef TARGET_CPU_X64
unsigned int pre_change, post_change;
@@ -135,47 +134,56 @@
* register. If we can change it, then the CPUID instruction is
* implemented. */
#ifndef TARGET_CPU_X64
- asm ("pushfl\n\t" /* Save %eflags to restore later. */
- "pushfl\n\t" /* Push second copy, for manipulation. */
- "popl %1\n\t" /* Pop it into post_change. */
- "movl %1,%0\n\t" /* Save copy in pre_change. */
- "xorl %2,%1\n\t" /* Tweak bit in post_change. */
- "pushl %1\n\t" /* Push tweaked copy... */
- "popfl\n\t" /* ... and pop it into %eflags. */
- "pushfl\n\t" /* Did it change? Push new %eflags... */
- "popl %1\n\t" /* ... and pop it into post_change. */
- "popfl" /* Restore original value. */
+#if defined (TARGET_COMPILER_GCC)
+ asm ("pushfl\n\t" /* Save %eflags to restore later. */
+ "pushfl\n\t" /* Push second copy, for manipulation. */
+ "popl %1\n\t" /* Pop it into post_change. */
+ "movl %1,%0\n\t" /* Save copy in pre_change. */
+ "xorl %2,%1\n\t" /* Tweak bit in post_change. */
+ "pushl %1\n\t" /* Push tweaked copy... */
+ "popfl\n\t" /* ... and pop it into %eflags. */
+ "pushfl\n\t" /* Did it change? Push new %eflags... */
+ "popl %1\n\t" /* ... and pop it into post_change. */
+ "popfl" /* Restore original value. */
: "=&r" (pre_change), "=&r" (post_change)
: "ir" (id_flag));
+#else
+ __asm {
+ mov edx, id_flag;
+ pushfd; /* Save %eflags to restore later. */
+ pushfd; /* Push second copy, for manipulation. */
+ pop ebx; /* Pop it into post_change. */
+ mov eax, ebx; /* Save copy in pre_change. */
+ xor ebx, edx; /* Tweak bit in post_change. */
+ push ebx; /* Push tweaked copy... */
+ popfd; /* ... and pop it into eflags. */
+ pushfd; /* Did it change? Push new %eflags... */
+ pop ebx; /* ... and pop it into post_change. */
+ popfd; /* Restore original value. */
+ mov pre_change, eax;
+ mov post_change, ebx;
+ }
+#endif
#endif

/* If the bit changed, then we support the CPUID instruction. */
#ifndef TARGET_CPU_X64
- if ((pre_change ^ post_change) & id_flag) {
+ if ((pre_change ^ post_change) & id_flag) {
#endif
+#if defined (TARGET_COMPILER_GCC)
asm volatile ("mov %%ebx, %%esi\n\t" /* Save %ebx. */
"xorl %%ecx, %%ecx\n\t"
"cpuid\n\t"
"xchgl %%ebx, %%esi" /* Restore %ebx. */
- : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
+ : "=a" (*_eax), "=S" (*_ebx), "=c" (*_ecx), "=d" (*_edx)
: "0" (request)
: "memory");
-
- return true;
-#ifndef TARGET_CPU_X64
- } else
- return false;
-#endif
- }
-
#else
-
- static void call_cpuid(unsigned int op, unsigned int *_eax, unsigned int
*_ebx, unsigned int *_ecx, unsigned int *_edx)
- {
- __asm
- {
+ __asm {
+ push esi;
+ push edi;
xor ecx, ecx;
- mov eax, op;
+ mov eax, request;
cpuid;
mov edi, [_eax];
mov esi, [_ebx];
@@ -185,10 +193,16 @@
mov esi, [_edx];
mov[edi], ecx;
mov[esi], edx;
+ pop edi;
+ pop esi;
}
- }
-
#endif
+ return true;
+#ifndef TARGET_CPU_X64
+ } else
+ return false;
+#endif
+ }

CPUID::CPUID()
{
@@ -258,14 +272,6 @@
delete [] proc[i]->caches.get(j);
}

- CrissCross::Data::DArray<Feature *> *nodes =
proc[i]->features.ConvertToDArray();
- for (j = 0; j < nodes->size(); j++) {
- if (nodes->valid(j))
- delete nodes->get(j);
- }
-
- delete nodes;
-
delete [] (char *)proc[i]->Manufacturer;
delete [] (char *)proc[i]->ProcessorName;

@@ -750,7 +756,7 @@
#endif
case 0x49: AddCacheDescription(processor, CreateCacheDescription(
/* This is an L3 on the P4 and an
L2 on the Core 2 */
-
proc[processor]->features.find("SSSE3")->Enabled ? CACHE_TYPE_L2 :
CACHE_TYPE_L3, NULL, 4096, 16, 0, 64, false)); break;
+
proc[processor]->features.exists("SSSE3") ? CACHE_TYPE_L2 : CACHE_TYPE_L3,
NULL, 4096, 16, 0, 64, false)); break;
case 0x4A: AddCacheDescription(processor,
CreateCacheDescription(CACHE_TYPE_L3, NULL, 6144, 12, 0, 64, false)); break;
case 0x4B: AddCacheDescription(processor,
CreateCacheDescription(CACHE_TYPE_L3, NULL, 8192, 16, 0, 64, false)); break;
case 0x4C: AddCacheDescription(processor,
CreateCacheDescription(CACHE_TYPE_L3, NULL, 12288, 12, 0, 64, false));
break;
@@ -838,37 +844,34 @@
{
/* Compliant with Intel document #241618. */

- /* AMD and Intel documentations state that if HTT is supported */
- /* then this the EBX:16 will reflect the logical processor count */
- /* otherwise the flag is reserved. */
-
- Feature *feature = new Feature();
- feature->Enabled = false;
- proc[processor]->features.insert("CMP", feature);
- feature = NULL;
+ /* Do we have HTT flag set? */
+ if (proc[processor]->features.exists("HTT")) {
+ /* AMD and Intel documentations state that if HTT is supported */
+ /* then this the EBX:16 will reflect the logical processor count */
+ /* otherwise the flag is reserved. */

- proc[processor]->CoresPerPackage = (char)((Std[4].eax & 0xFC000000) >>
26) + 1;
+ proc[processor]->features.insert("CMP", NULL);

- /* Do we have HTT flag set? */
- if (proc[processor]->features.find("HTT")->Enabled) {
- /* Set logical processors per package accordingly. */
+ proc[processor]->CoresPerPackage = (char)((Std[4].eax & 0xFC000000) >>
26) + 1;
proc[processor]->LogicalPerPackage = (char)((Std[1].ebx & 0x00FF0000)
>> 16);

+ if (proc[processor]->CoresPerPackage < 1)
+ proc[processor]->CoresPerPackage = 1;
+
+ if (proc[processor]->LogicalPerPackage < 1)
+ proc[processor]->LogicalPerPackage = 1;
+
if (proc[processor]->CoresPerPackage > 1 &&
proc[processor]->LogicalPerPackage >
proc[processor]->CoresPerPackage) {
/* Hyperthreaded dual core. */
- proc[processor]->features.find("HTT")->Enabled = true;
- proc[processor]->features.find("CMP")->Enabled = true;
} else if (proc[processor]->CoresPerPackage > 1 &&
proc[processor]->LogicalPerPackage ==
proc[processor]->CoresPerPackage) {
/* Dual core. */
- proc[processor]->features.find("HTT")->Enabled = false;
- proc[processor]->features.find("CMP")->Enabled = true;
+ proc[processor]->features.erase("HTT");
} else if (proc[processor]->CoresPerPackage == 1 &&
proc[processor]->LogicalPerPackage >
proc[processor]->CoresPerPackage) {
/* Hyperthreaded. */
- proc[processor]->features.find("HTT")->Enabled = true;
- proc[processor]->features.find("CMP")->Enabled = false;
+ proc[processor]->features.erase("CMP");
}
} else {
/* HTT not supported. Report logical processor count as 1. */
@@ -886,11 +889,9 @@
{
/* Compliant with Intel document #241618. */

- Feature *feature = new Feature();
-
- feature->Enabled = (*_register & _flag) > 0;
- proc[_processor]->features.insert(_name, feature);
- feature = NULL;
+ bool supported = (*_register & _flag) > 0;
+ if (supported)
+ proc[_processor]->features.insert(_name, NULL);
}

void CPUID::DetectFeatures(int processor)

Modified: trunk/source/crisscross/cpuid.h
==============================================================================
--- trunk/source/crisscross/cpuid.h (original)
+++ trunk/source/crisscross/cpuid.h Sun Oct 19 17:20:26 2008
@@ -29,20 +29,6 @@
{
namespace System
{
- class Feature
- {
- public:
- bool Enabled;
- Feature()
- {
- Enabled = 0;
- }
-
- ~Feature()
- {
- }
- };
-
class Processor
{
public:
@@ -55,7 +41,7 @@
char Stepping;
char BrandID;
char APICID;
- CrissCross::Data::RedBlackTree<const char *, Feature *> features;
+ CrissCross::Data::RedBlackTree<const char *, void *> features;
CrissCross::Data::DArray <char *> caches;
public:
Processor()

Modified: trunk/targets/vs2008/.gitignore
==============================================================================
--- trunk/targets/vs2008/.gitignore (original)
+++ trunk/targets/vs2008/.gitignore Sun Oct 19 17:20:26 2008
@@ -0,0 +1,5 @@
+*.ncb
+*.suo
+*.vcproj.*.user
+Debug
+Release

Modified: trunk/tools/GenerateBuildNumber.sh
==============================================================================
--- trunk/tools/GenerateBuildNumber.sh (original)
+++ trunk/tools/GenerateBuildNumber.sh Sun Oct 19 17:20:26 2008
@@ -14,12 +14,16 @@

cd $1

-BUILD=`svn --xml info | tr -d '\r' | tr -d '\n' | sed
-e 's/.*<entry.*revision="\([0-9]*\)".*<url>.*/\1/'`
+if [ -d .svn ]; then
+ BUILD=`svn --xml info | tr -d '\r' | tr -d '\n' | sed
-e 's/.*<entry.*revision="\([0-9]*\)".*<url>.*/\1/'`
+else
+ BUILD=`git rev-list --all | wc -l | tr -d ' '`
+fi

mkdir -p $2
cd $2

-if [[ "${#BUILD}" -gt "5" || "${#BUILD}" -lt "1" ]]; then
+if [[ "${#BUILD}" -lt "1" ]]; then
echo "Build number couldn't be detected, defaulting to 1!"
BUILD=1
else

Reply all
Reply to author
Forward
0 new messages