diff --git a/include/System/Collections/Generic/List.h b/include/System/Collections/Generic/List.h index 07742d5..acc79a6 100644 --- a/include/System/Collections/Generic/List.h +++ b/include/System/Collections/Generic/List.h @@ -232,7 +232,7 @@ namespace System // Removes the element at the specified index of the List<>. void RemoveAt(const int index) { - memcpy(&_items[index], &_items[index + 1], (size - index) * sizeof(T)): + memcpy(&_items[index], &_items[index + 1], (_size - index) * sizeof(T)); _size--; _version++; diff --git a/include/System/Diagnostics/Debug.h b/include/System/Diagnostics/Debug.h index 909b510..8d0836a 100644 --- a/include/System/Diagnostics/Debug.h +++ b/include/System/Diagnostics/Debug.h @@ -7,12 +7,6 @@ #ifndef _SYSTEM_DIAGNOSTICS_DEBUG_ #define _SYSTEM_DIAGNOSTICS_DEBUG_ -#if _MSC_VER -#define FORMAT -#else -#define FORMAT __attribute__(format(printf, 1, 2)); -#endif - namespace System { class String; @@ -54,7 +48,7 @@ namespace System * @param args * An object array containing zero or more objects to format. */ - static void WriteLine(const String& format, ...) FORMAT; + static void WriteLine(const String& format, ...); }; } } diff --git a/include/System/Diagnostics/Stopwatch.h b/include/System/Diagnostics/Stopwatch.h new file mode 100644 index 0000000..e9b2493 --- /dev/null +++ b/include/System/Diagnostics/Stopwatch.h @@ -0,0 +1,42 @@ +#ifndef _SYSTEM_DIAGNOSTICS_STOPWATCH_ +#define _SYSTEM_DIAGNOSTICS_STOPWATCH_ + +#include + +namespace System +{ + namespace Diagnostics + { + /** + * + */ + class Stopwatch + { + private: + bool isRunning; + long long elapsedTicks; + + public: + static const long long Frequency; + + TimeSpan getElapsed() const; + /** + * Gets the total elapsed time measured by the current instance, in milliseconds. + */ + long long getElapsedMilliseconds() const; + long long getElapsedTicks() const; + bool IsRunning() const; + + Stopwatch(); + + static long long GetTimestamp(); + void Reset(); + void Restart(); + void Start(); + static const Stopwatch& StartNew(); + void Stop(); + }; + } +} + +#endif //_SYSTEM_DIAGNOSTICS_STOPWATCH_ diff --git a/include/System/IO/DirectoryInfo.h b/include/System/IO/DirectoryInfo.h index e326af3..0e3c20f 100644 --- a/include/System/IO/DirectoryInfo.h +++ b/include/System/IO/DirectoryInfo.h @@ -1,8 +1,8 @@ /***************************************************************************** - * DirectoryInfo.h * + * DirectoryInfo.h * * * - * XFX System::IO::DirectoryInfo class definition file * - * Copyright (c) XFX Team. All Rights Reserved * + * XFX System::IO::DirectoryInfo class definition file. * + * Copyright (c) XFX Team. All Rights Reserved. * *****************************************************************************/ #ifndef _SYSTEM_IO_DIRECTORYINFO_ #define _SYSTEM_IO_DIRECTORYINFO_ @@ -30,20 +30,28 @@ namespace System public: bool Exists() const; String getName() const; - DirectoryInfo Parent(); - DirectoryInfo Root(); + DirectoryInfo* getParent() const; + DirectoryInfo* getRoot() const; DirectoryInfo(); DirectoryInfo(const String& path); // Initializes a new instance of the System::IO::DirectoryInfo class on the specified path. - // Creates a directory. + /** + * Creates a directory. + */ void Create(); - // Creates a subdirectory or subdirectories on the specified path. - // The specified path can be relative to this instance of the System::IO::DirectoryInfo class. + /** + * Creates a subdirectory or subdirectories on the specified path. + * The specified path can be relative to this instance of the System::IO::DirectoryInfo class. + */ DirectoryInfo CreateSubDirectory(const String& path); - // Deletes this System::IO::DirectoryInfo if it is empty. + /** + * Deletes this System::IO::DirectoryInfo if it is empty. + */ void Delete(); - // Deletes this instance of a System::IO::DirectoryInfo, specifying whether to delete subdirectories and files. + /** + * Deletes this instance of a System::IO::DirectoryInfo, specifying whether to delete subdirectories and files. + */ void Delete(const bool recursive); DirectoryInfo* GetDirectories(); // DirectoryInfo* GetDirectories(const String& searchPattern); diff --git a/include/xmem.h b/include/xmem.h index 601d2cf..0c53544 100644 --- a/include/xmem.h +++ b/include/xmem.h @@ -13,7 +13,7 @@ * Differences from C++ auto_ptr: exception-less and supports array notation. */ template -class auto_ptr +struct auto_ptr { private: T* ptr; diff --git a/src/libSystem/Debug.cpp b/src/libSystem/Debug.cpp index abd8bf2..43493f8 100644 --- a/src/libSystem/Debug.cpp +++ b/src/libSystem/Debug.cpp @@ -28,6 +28,10 @@ #include #include +#include +#include +#include + #if ENABLE_XBOX #include #else @@ -76,7 +80,20 @@ namespace System return; } - // TODO: implement + va_list args; + va_start(args, format); + + int count = vsnprintf(NULL, 0, format, args); + + char* res = (char*)malloc(count + 1); + + vsnprintf(res, count + 1, format, args); + + va_end(args); + + DbgPrint(res); + + free(res); #endif } } diff --git a/src/libSystem/Stopwatch.cpp b/src/libSystem/Stopwatch.cpp new file mode 100644 index 0000000..736bb06 --- /dev/null +++ b/src/libSystem/Stopwatch.cpp @@ -0,0 +1,68 @@ +#include + +#if ENABLE_XBOX +#include +#else +#endif + +namespace System +{ + namespace Diagnostics + { + const long long Stopwatch::Frequency = KeQueryPerformanceFrequency(); + + TimeSpan Stopwatch::getElapsed() const + { + return TimeSpan::FromTicks(elapsedTicks); + } + + long long Stopwatch::getElapsedMilliseconds() const + { + return getElapsed().Milliseconds(); + } + + long long Stopwatch::getElapsedTicks() const + { + return elapsedTicks; + } + + bool Stopwatch::IsRunning() const + { + return isRunning; + } + + Stopwatch::Stopwatch() + { + } + + long long Stopwatch::GetTimestamp() + { + return KeQueryPerformanceCounter(); + } + + void Stopwatch::Restart() + { + Reset(); + Start(); + } + + void Stopwatch::Start() + { + + isRunning = true; + } + + const Stopwatch& Stopwatch::StartNew() + { + Stopwatch sw = Stopwatch(); + sw.Start(); + return sw; + } + + void Stopwatch::Stop() + { + + isRunning = false; + } + } +} diff --git a/src/libSystem/libSystem.vcxproj b/src/libSystem/libSystem.vcxproj index daa25bb..7ce272a 100644 --- a/src/libSystem/libSystem.vcxproj +++ b/src/libSystem/libSystem.vcxproj @@ -77,6 +77,7 @@ + diff --git a/src/libSystem/libSystem.vcxproj.filters b/src/libSystem/libSystem.vcxproj.filters index b9dab7a..962c130 100644 --- a/src/libSystem/libSystem.vcxproj.filters +++ b/src/libSystem/libSystem.vcxproj.filters @@ -54,6 +54,9 @@ Source Files\Diagnostics + + Source Files\Diagnostics + diff --git a/src/libSystem/makefile b/src/libSystem/makefile index 21fcd0f..9de677e 100644 --- a/src/libSystem/makefile +++ b/src/libSystem/makefile @@ -26,7 +26,7 @@ LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP) LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib LD_LIBS = $(LD_DIRS) -lmscorlib -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lgcc -lstdc++ -OBJS = CancelEventArgs.o Debug.o Socket.o SocketAddress.o SocketAsyncEventArgs.o +OBJS = CancelEventArgs.o Debug.o Socket.o SocketAddress.o SocketAsyncEventArgs.o Stopwatch.o all: libSystem.a diff --git a/src/libmscorlib/Calendar.cpp b/src/libmscorlib/Calendar.cpp index 2c74a87..4d46b3b 100644 --- a/src/libmscorlib/Calendar.cpp +++ b/src/libmscorlib/Calendar.cpp @@ -27,11 +27,14 @@ #include #include +#include namespace System { namespace Globalization { + const Type CalendarTypeInfo("Calendar", "System::Globalization::Calendar", TypeCode::Object); + DateTime Calendar::AddDays(DateTime time, int days) { DateTime result(time); @@ -67,9 +70,9 @@ namespace System return result; } - int Calendar::GetType() + const Type& Calendar::GetType() { - //! TODO: implement + return CalendarTypeInfo; } } } diff --git a/src/libmscorlib/Console.cpp b/src/libmscorlib/Console.cpp index 52c9c97..aa0f46f 100644 --- a/src/libmscorlib/Console.cpp +++ b/src/libmscorlib/Console.cpp @@ -19,9 +19,13 @@ namespace System void Console::Write(const bool value) { if (value) + { debugPrint("true"); + } else + { debugPrint("false"); + } } void Console::Write(const char value) @@ -41,7 +45,9 @@ namespace System //sassert(index + count < Array::Length(value), "index + count are out of range of the array."); for (int i = index; i < (index + count); i++) + { debugPrint("%c", value[i]); + } } void Console::Write(const double value) diff --git a/src/libmscorlib/DateTime.cpp b/src/libmscorlib/DateTime.cpp index 9a59c8a..d66b107 100644 --- a/src/libmscorlib/DateTime.cpp +++ b/src/libmscorlib/DateTime.cpp @@ -92,15 +92,15 @@ namespace System DateTime DateTime::Add(double value, int scale) { long long num = (long long)((value * scale) + ((value >= 0.0) ? 0.5 : -0.5)); - if ((num <= -315537897600000LL) || (num >= 0x11efae44cb400LL)) + if ((num <= -315537897600000LL) || (num >= 0x11efae44cb400LL)) { #if DEBUG - //throw ArgumentOutOfRangeException("value", "ArgumentOutOfRange_AddValue"); + //throw ArgumentOutOfRangeException("value", "ArgumentOutOfRange_AddValue"); #endif return *this; } - return AddTicks(num * 0x2710L); + return AddTicks(num * 0x2710L); } DateTime::DateTime(int year, int month, int day) diff --git a/src/libmscorlib/DirectoryInfo.cpp b/src/libmscorlib/DirectoryInfo.cpp index ed7f6ea..e370aa2 100644 --- a/src/libmscorlib/DirectoryInfo.cpp +++ b/src/libmscorlib/DirectoryInfo.cpp @@ -41,6 +41,21 @@ namespace System { namespace IO { + DirectoryInfo* DirectoryInfo::getParent() const + { + return new DirectoryInfo(parent); + } + + DirectoryInfo* DirectoryInfo::getRoot() const + { + // TODO; implement + return NULL; + } + + DirectoryInfo::DirectoryInfo() + { + } + DirectoryInfo::DirectoryInfo(const String& path) { sassert(path != null, FrameworkResources::ArgumentNull_Path); @@ -57,11 +72,12 @@ namespace System void DirectoryInfo::Create() { + // TODO: implement } DirectoryInfo DirectoryInfo::CreateSubDirectory(const String& path) { - + // TODO: implement } void DirectoryInfo::Delete() @@ -92,14 +108,12 @@ namespace System bool DirectoryInfo::operator !=(const DirectoryInfo& right) const { - return ((strncmp(current, right.current, strlen(current)) != 0) || - (strncmp(parent, right.parent, strlen(parent)) != 0)); + return (current != right.current) || (parent != right.parent); } bool DirectoryInfo::operator ==(const DirectoryInfo& right) const { - return ((strncmp(current, right.current, strlen(current)) == 0) && - (strncmp(parent, right.parent, strlen(parent)) == 0)); + return (current == right.current) && (parent == right.parent); } } } diff --git a/src/libmscorlib/Double.cpp b/src/libmscorlib/Double.cpp index c3049ac..3e2166e 100644 --- a/src/libmscorlib/Double.cpp +++ b/src/libmscorlib/Double.cpp @@ -35,6 +35,8 @@ #include +extern "C" int strcasecmp(const char * s1, const char * s2); + namespace System { static unsigned long long rawNaND = 0x7ff8000000000000ULL; @@ -63,9 +65,15 @@ namespace System int Double::CompareTo(const Double other) const { if (value > other.value) + { return 1; + } + if (value < other.value) + { return -1; + } + return 0; } @@ -92,22 +100,32 @@ namespace System *result = 0; char sign = 0; - char *sp = const_cast((const char *)str.ToString()); + char* sp = const_cast((const char *)str.ToString()); if (*sp == '+' || *sp == '-') + { sign = *sp++; + } if (strcasecmp(sp, "inf") == 0) { if (!sign || sign == '+') + { *result = PositiveInfinity; + } else + { *result = NegativeInfinity; + } } else if (strcasecmp(sp, "nan") == 0) + { *result = NaN; + } else /* valid number */ + { *result = atof(sp); + } return true; } diff --git a/src/libmscorlib/FileStream.cpp b/src/libmscorlib/FileStream.cpp index 7fe2a71..fcb094d 100644 --- a/src/libmscorlib/FileStream.cpp +++ b/src/libmscorlib/FileStream.cpp @@ -110,17 +110,17 @@ namespace System } FileStream::FileStream() - : handle(NULL), _file(NULL) + : _file(NULL), handle(NULL) { } FileStream::FileStream(FILE * const file) - : handle(NULL), _file(file) + : _file(file), handle(NULL) { } FileStream::FileStream(const String& path, const FileMode_t mode) - : handle(NULL), _file(NULL) + : _file(NULL), handle(NULL) { sassert(!String::IsNullOrEmpty(path), FrameworkResources::ArgumentNull_Path); diff --git a/src/libmscorlib/Int64.cpp b/src/libmscorlib/Int64.cpp index 52f982b..7fb707e 100644 --- a/src/libmscorlib/Int64.cpp +++ b/src/libmscorlib/Int64.cpp @@ -98,12 +98,16 @@ namespace System char* end = NULL; if (String::IsNullOrEmpty(str)) + { return false; + } long long retval = strtoll(str, &end, 10); if (end) + { return false; + } *result = retval; return true; diff --git a/src/libmscorlib/String.cpp b/src/libmscorlib/String.cpp index d43ba1f..d6d3ff2 100644 --- a/src/libmscorlib/String.cpp +++ b/src/libmscorlib/String.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,8 @@ namespace System { const String String::Empty = ""; + const Type StringTypeInfo("String", "System::String", TypeCode::String); + String::String() : Length(0) { @@ -92,7 +95,9 @@ namespace System String::~String() { if (internalString) + { free(internalString); + } } String String::Clone() const @@ -107,7 +112,7 @@ namespace System int String::CompareTo(const String other) const { - return (Compare(*this, other)); + return strcmp(this->internalString, other.internalString); } String String::Concat(const String values[], const int stringCount) @@ -165,6 +170,8 @@ namespace System vsnprintf(res, count + 1, format, args); + va_end(args); + return res; } @@ -180,9 +187,9 @@ namespace System return h; } - int String::GetType() + const Type& String::GetType() { - return 18; + return StringTypeInfo; } int String::IndexOf(char value) const @@ -190,8 +197,11 @@ namespace System for(int i = 0; i <= Length; i++) { if (internalString[i] == value) + { return i; + } } + return -1; } @@ -210,8 +220,11 @@ namespace System for(int i = startIndex; i < startIndex + count; i++) { if(internalString[i] == value) + { return i; + } } + return -1; } @@ -233,7 +246,9 @@ namespace System { indexOf = IndexOf(anyOf[i], startIndex, count); if (indexOf != -1) + { return indexOf; + } } return indexOf; @@ -279,7 +294,9 @@ namespace System String String::PadRight(int totalWidth, char paddingChar) { if(totalWidth <= Length) - return String(*this); + { + return *this; + } char* newString = (char*)malloc(totalWidth + 1); @@ -369,7 +386,9 @@ namespace System String newString = String(*this); for (int i = 0; i < Length; i++) + { newString.internalString[i] = tolower(internalString[i]); + } return newString; } @@ -379,13 +398,15 @@ namespace System size_t strLen = strlen(str); char* tmp = (char*)malloc(strLen + 1); for (size_t i = 0; i < strLen; i++) + { tmp[i] = tolower(str[i]); + } tmp[strLen] = '\0'; return tmp; } - const String& String::ToString() const + const String String::ToString() const { return *this; } @@ -395,7 +416,9 @@ namespace System String newString = String(*this); for (int i = 0; i < Length; i++) + { newString.internalString[i] = toupper(internalString[i]); + } return newString; } @@ -404,8 +427,11 @@ namespace System { size_t strLen = strlen(str); char* tmp = (char*)malloc(strLen + 1); + for (size_t i = 0; i < strLen; i++) + { tmp[i] = toupper(str[i]); + } tmp[strLen] = '\0'; return tmp; @@ -422,6 +448,7 @@ namespace System { return !Equals(right); } + return true; } @@ -431,6 +458,7 @@ namespace System { return (strncmp(internalString, right, Length) != 0); } + return false; } @@ -449,6 +477,7 @@ namespace System { return (strncmp(internalString, right, Length) == 0); } + return false; } @@ -456,15 +485,11 @@ namespace System { // check for self-assignment if (*this == right) + { return *this; + } - *(const_cast(&Length)) = right.Length; - free(internalString); - internalString = (char*)malloc(Length + 1); - strncpy(internalString, right.internalString, Length); - internalString[Length] = '\0'; - - return *this; + return String(right); } String String::operator +(const char *right) const diff --git a/src/libmscorlib/TimeSpan.cpp b/src/libmscorlib/TimeSpan.cpp index caf1cf3..b5988a4 100644 --- a/src/libmscorlib/TimeSpan.cpp +++ b/src/libmscorlib/TimeSpan.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -41,6 +42,8 @@ namespace System const long long TimeSpan::TicksPerHour = 36000000000LL; const long long TimeSpan::TicksPerDay = 864000000000LL; + const Type TimeSpanTypeInfo("TimeSpan", "System::TimeSpan", TypeCode::Object); + TimeSpan::TimeSpan() { _ticks = 0; @@ -141,9 +144,15 @@ namespace System int TimeSpan::Compare(const TimeSpan t1, const TimeSpan t2) { if (t1._ticks < t2._ticks) + { return -1; + } + if (t1._ticks > t2._ticks) + { return 1; + } + return 0; } @@ -202,9 +211,9 @@ namespace System return (((int)_ticks) ^ ((int)(_ticks >> 0x20))); } - int TimeSpan::GetType() + const Type& TimeSpan::GetType() { - //! TODO: implement + return TimeSpanTypeInfo; } TimeSpan TimeSpan::Negate() @@ -223,7 +232,7 @@ namespace System return TimeSpan(ticks); } - const String& TimeSpan::ToString() const + const String TimeSpan::ToString() const { return String::Format("Ticks: %ll", _ticks); } diff --git a/src/libmscorlib/UInt16.cpp b/src/libmscorlib/UInt16.cpp index 090bb82..2033f8b 100644 --- a/src/libmscorlib/UInt16.cpp +++ b/src/libmscorlib/UInt16.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -34,6 +35,7 @@ namespace System { const ushort UInt16::MaxValue = 0xFFFF; const ushort UInt16::MinValue = 0; + const Type UInt16TypeInfo("UInt16", "System::UInt16", TypeCode::UInt16); UInt16::UInt16() : value(0) @@ -53,9 +55,15 @@ namespace System int UInt16::CompareTo(const UInt16 other) const { if (value < other.value) + { return -1; + } + if (value > other.value) + { return 1; + } + return 0; } @@ -74,17 +82,17 @@ namespace System return value; } - int UInt16::GetType() + const Type& UInt16::GetType() { - return 8; + return UInt16TypeInfo; } - const String& UInt16::ToString() const + const String UInt16::ToString() const { return String::Format("%i", value); } - const String& UInt16::ToString(const ushort value) + const String UInt16::ToString(const ushort value) { return String::Format("%i", value); } @@ -95,12 +103,16 @@ namespace System char* end = NULL; if (String::IsNullOrEmpty(str)) + { return false; + } ushort retval = (ushort)strtoul(str, &end, 10); if (end) + { return false; + } *result = retval; return true; diff --git a/src/libmscorlib/UInt32.cpp b/src/libmscorlib/UInt32.cpp index d028301..0f8272f 100644 --- a/src/libmscorlib/UInt32.cpp +++ b/src/libmscorlib/UInt32.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -34,6 +35,7 @@ namespace System { const uint UInt32::MaxValue = 0xFFFFFFFF; const uint UInt32::MinValue = 0; + const Type UInt32TypeInfo("UInt32", "System::UInt32", TypeCode::UInt32); UInt32::UInt32(const UInt32 &obj) : value(obj.value) @@ -69,17 +71,17 @@ namespace System return (int)value; } - int UInt32::GetType() + const Type& UInt32::GetType() { - return 10; + return UInt32TypeInfo; } - const String& UInt32::ToString() const + const String UInt32::ToString() const { return String::Format("%i", value); } - const String& UInt32::ToString(const uint value) + const String UInt32::ToString(const uint value) { return String::Format("%i", value); } @@ -90,12 +92,16 @@ namespace System char* end = NULL; if (String::IsNullOrEmpty(str)) + { return false; + } uint retval = strtoul(str, &end, 10); if (*end) + { return false; + } *result = retval; return true; diff --git a/src/libmscorlib/UInt64.cpp b/src/libmscorlib/UInt64.cpp index 1a34f7e..f08b671 100644 --- a/src/libmscorlib/UInt64.cpp +++ b/src/libmscorlib/UInt64.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -34,6 +35,7 @@ namespace System { const ulong UInt64::MaxValue = 0xFFFFFFFFFFFFFFFFULL; const ulong UInt64::MinValue = 0; + const Type UInt64TypeInfo("UInt64", "System::UInt64", TypeCode::UInt64); UInt64::UInt64(const UInt64 &obj) : value(obj.value) @@ -48,9 +50,15 @@ namespace System int UInt64::CompareTo(const UInt64 other) const { if (value > other.value) + { return 1; + } + if (value < other.value) + { return -1; + } + return 0; } @@ -69,9 +77,9 @@ namespace System return (int)value; } - int UInt64::GetType() + const Type& UInt64::GetType() { - return 12; + return UInt64TypeInfo; } const String UInt64::ToString() const @@ -90,12 +98,16 @@ namespace System char* end = NULL; if (String::IsNullOrEmpty(str)) + { return false; + } ulong retval = strtoull(str, &end, 10); if (end) + { return false; + } *result = retval; return true; diff --git a/src/libmscorlib/Version.cpp b/src/libmscorlib/Version.cpp index a1752df..23951dd 100644 --- a/src/libmscorlib/Version.cpp +++ b/src/libmscorlib/Version.cpp @@ -26,12 +26,15 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include #include #include namespace System { + const Type VersionTypeInfo("Version", "System::Version", TypeCode::Object); + Version::Version(int major, int minor) : Build(0), Major(major), Minor(minor), Revision(0) { @@ -60,9 +63,15 @@ namespace System int Version::CompareTo(const Version value) const { if (*this < value) + { return -1; + } + if (*this > value) + { return 1; + } + return 0; } @@ -82,22 +91,22 @@ namespace System return (Build ^ Major ^ Minor ^ Revision); } - int Version::GetType() + const Type& Version::GetType() { - // TODO: implement + return VersionTypeInfo; } - const String& Version::ToString() const + const String Version::ToString() const { return String::Format("%i.%i.%i.%i", Major, Minor, Build, Revision); } - const String& Version::ToString(int fieldCount) const + const String Version::ToString(int fieldCount) const { switch(fieldCount) { case 0: - return ""; + return String::Empty; break; case 1: return String::Format("%i", Major); diff --git a/src/libmscorlib/makefile b/src/libmscorlib/makefile index 2e91122..c00ad5b 100644 --- a/src/libmscorlib/makefile +++ b/src/libmscorlib/makefile @@ -4,15 +4,15 @@ ######################################################################### PREFIX = /openxdk -CC = xbox-gcc -CCAS = xbox-gcc -CPP = xbox-g++ -AR = xbox-ar rcu -RANLIB = xbox-ranlib +CC = gcc +CCAS = gcc +CPP = g++ +AR = ar rcu +RANLIB = ranlib CXBE = $(PREFIX)/bin/cxbe SDLFLAGS = -DENABLE_XBOX -DDEBUG -CC_FLAGS = -c -g -O2 -std=gnu99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS) +CC_FLAGS = -c -g -O2 -std=C99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS) CCAS_FLAGS = --32 -march=pentiumiii, mmx, sse -mtune=pentiumiii -msse-check=error CPP_FLAGS = -c -O2 -std=c++03 -Wall -nostdlib -fno-builtin -fno-exceptions -fno-rtti -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS) INCLUDE = -I$(PREFIX)/i386-pc-xbox/include -I$(PREFIX)/include -I$(PREFIX)/include/SDL -I../../include diff --git a/src/libmscorlib/misc.cpp b/src/libmscorlib/misc.cpp index 0625458..5e8671e 100644 --- a/src/libmscorlib/misc.cpp +++ b/src/libmscorlib/misc.cpp @@ -8,6 +8,7 @@ #include #include +#include /******************************************************************************/ @@ -135,3 +136,19 @@ void *memset(void *s, char c, size_t count) :"memory"); return s; } + +int strcasecmp(const char * s1, const char * s2) +{ + const unsigned char *us1 = (const unsigned char *)s1, + *us2 = (const unsigned char *)s2; + + while (tolower(*us1) == tolower(*us2++)) + { + if (*us1++ == '\0') + { + return (0); + } + } + + return (tolower(*us1) - tolower(*--us2)); +}