Upgraded MPIR.Net solution to VS2013. Cleaned up all compiler warnings.

This commit is contained in:
Alex Dyachenko 2015-12-23 09:10:58 -05:00
parent 914844ebb3
commit b006a3b4d9
8 changed files with 64 additions and 42 deletions

View File

@ -94,15 +94,9 @@
</Otherwise>
</Choose>
<ItemGroup>
<None Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\Arithmetic.cs">
<Link>HugeFloatTests\Arithmetic.cs</Link>
</None>
<Compile Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\Assignment.cs">
<Link>HugeFloatTests\Assignment.cs</Link>
</Compile>
<None Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\Comparisons.cs">
<Link>HugeFloatTests\Comparisons.cs</Link>
</None>
<Compile Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\Arithmetic.cs">
<Link>HugeFloatTests\Arithmetic.cs</Link>
</Compile>
@ -115,12 +109,6 @@
<Compile Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\Conversions.cs">
<Link>HugeFloatTests\Conversions.cs</Link>
</Compile>
<None Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\ExpressionTests.cs">
<Link>HugeFloatTests\ExpressionTests.cs</Link>
</None>
<None Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\IO.cs">
<Link>HugeFloatTests\IO.cs</Link>
</None>
<Compile Include="..\..\..\mpir.net\mpir.net-tests\HugeFloatTests\ExpressionTests.cs">
<Link>HugeFloatTests\ExpressionTests.cs</Link>
</Compile>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -28,28 +28,28 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@ -96,6 +96,7 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -109,6 +110,7 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -121,6 +123,7 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -133,6 +136,7 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -53,5 +53,5 @@ using namespace System::Security::Permissions;
[assembly:AssemblyVersionAttribute("1.0.0.0")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
//obsolete in .Net 4.0 [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
[assembly:InternalsVisibleTo("mpir.net-tests")];

View File

@ -147,7 +147,7 @@ struct EvaluationContext
Zero = 0;
}
#define CTXT_ADD_RATIONAL(numerator, denominator) \
#define CTXT_ADD_RATIONAL_SI(numerator, denominator) \
auto ptr = &context.Temp[context.Index].Rational; \
context.RationalArgs[context.Index++] = ptr; \
\
@ -161,6 +161,20 @@ struct EvaluationContext
ptr->_mp_den._mp_size = (int)SGN(denominator); \
ptr->_mp_den._mp_d = &_d;
#define CTXT_ADD_RATIONAL_UI(numerator, denominator) \
auto ptr = &context.Temp[context.Index].Rational; \
context.RationalArgs[context.Index++] = ptr; \
\
auto _n = (mpir_ui)numerator; \
ptr->_mp_num._mp_alloc = 1; \
ptr->_mp_num._mp_size = (int)SGN(numerator); \
ptr->_mp_num._mp_d = &_n; \
\
auto _d = (mpir_ui)denominator; \
ptr->_mp_den._mp_alloc = 1; \
ptr->_mp_den._mp_size = (int)SGN(denominator); \
ptr->_mp_den._mp_d = &_d;
#define CTXT_ADD_RATIONAL_DOUBLE(value) \
context.Initialized(RationalInitialized); \
auto ptr = &context.Temp[context.Index].Rational; \

View File

@ -233,11 +233,19 @@ private ref class MPEXPR(name) : base
operation(destination, destination, Right); \
}
#define DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(name, leftTypeAbbr, rightTypeAbbr, operation) \
#define DEFINE_BINARY_ASSIGNMENT_REF_RATUI(name, leftTypeAbbr, rightTypeAbbr, operation) \
DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \
{ \
IN_CONTEXT(Left); \
CTXT_ADD_RATIONAL(Right, 1); \
CTXT_ADD_RATIONAL_UI(Right, 1); \
operation(destination, CTXT(0), CTXT(1)); \
}
#define DEFINE_BINARY_ASSIGNMENT_REF_RATSI(name, leftTypeAbbr, rightTypeAbbr, operation) \
DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \
{ \
IN_CONTEXT(Left); \
CTXT_ADD_RATIONAL_SI(Right, 1); \
operation(destination, CTXT(0), CTXT(1)); \
}
@ -248,11 +256,19 @@ private ref class MPEXPR(name) : base
operation(destination, Left, destination); \
}
#define DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(name, leftTypeAbbr, rightTypeAbbr, operation) \
#define DEFINE_BINARY_ASSIGNMENT_RATUI_REF(name, leftTypeAbbr, rightTypeAbbr, operation) \
DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \
{ \
IN_CONTEXT(Right); \
CTXT_ADD_RATIONAL(Left, 1); \
CTXT_ADD_RATIONAL_UI(Left, 1); \
operation(destination, CTXT(1), CTXT(0)); \
}
#define DEFINE_BINARY_ASSIGNMENT_RATSI_REF(name, leftTypeAbbr, rightTypeAbbr, operation) \
DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \
{ \
IN_CONTEXT(Right); \
CTXT_ADD_RATIONAL_SI(Left, 1); \
operation(destination, CTXT(1), CTXT(0)); \
}

View File

@ -366,7 +366,7 @@ namespace MPIR
/// <param name="a">Value to compare the source with</param>
/// <param name="precision">The number of most significant bits that must match for the two numbers to be considered equal</param>
/// <returns>true if the values of the source and <paramref name="a"/> are equal to <paramref name="precision"/>, false otherwise.</returns>
bool Equals(MPEXPR_NAME^ a, mp_bitcnt_t precision) { IN_CONTEXT(this, a); return MP(eq)(CTXT(0), CTXT(1), precision); }
bool Equals(MPEXPR_NAME^ a, mp_bitcnt_t precision) { IN_CONTEXT(this, a); return MP(eq)(CTXT(0), CTXT(1), precision) != 0; }
/// <summary>Computes the hash code of the source value.
/// <para>If called on an expression, it is evaluated into a temporary variable before the comparison is performed.
@ -1314,7 +1314,7 @@ namespace MPIR
/// <param name="reader">Text reader to input the number from</param>
/// <param name="base">The base to use for the mantissa.
/// <para>The base can be from 2 to 62; uppercase letters represent digits 10-35 while lowercase letters represent digits 36-61.
/// </para>For bases larger than 36, the <paramref name="lowercase"/> argument is ignored and uppercase letters represent digits 10-35 while lowercase letters represent digits 36-61.</param>
/// </para>For bases 36 and less, uppercase and lowercase letters are equivalent.</param>
/// <returns>the number of characters read</returns>
size_t Read(TextReader^ reader, int base) { return Read(reader, base, true); }

View File

@ -1918,7 +1918,7 @@ namespace MPIR
auto bitsPerLimb = 8 * bytesPerLimb - nails;
auto limbCount = (MP(sizeinbase)(_value, 2) - 1) / bitsPerLimb + 1;
auto arrayCount = (limbCount * bytesPerLimb - 1) / sizeof(T) + 1;
auto data = gcnew array<T>(arrayCount);
auto data = gcnew array<T>((int)arrayCount);
PIN(data);
MP(export)(pinned_data, &limbCount, (int)limbOrder, bytesPerLimb, (int)endianness, nails, _value);

View File

@ -234,14 +234,14 @@ namespace MPIR
if(a->GetType() == mpir_ui::typeid)
{
ASSIGN_TO(context);
CTXT_ADD_RATIONAL((mpir_ui)a, 1);
CTXT_ADD_RATIONAL_UI((mpir_ui)a, 1);
return MP(equal)(CTXT(0), CTXT(1)) != 0;
}
if(a->GetType() == mpir_si::typeid)
{
ASSIGN_TO(context);
CTXT_ADD_RATIONAL((mpir_si)a, 1);
CTXT_ADD_RATIONAL_SI((mpir_si)a, 1);
return MP(equal)(CTXT(0), CTXT(1)) != 0;
}
@ -267,14 +267,14 @@ namespace MPIR
bool MPEXPR_NAME::Equals(mpir_si numerator, mpir_ui denominator)
{
IN_CONTEXT(this);
CTXT_ADD_RATIONAL(numerator, denominator);
CTXT_ADD_RATIONAL_SI(numerator, denominator);
return MP(equal)(CTXT(0), CTXT(1)) != 0;
}
bool MPEXPR_NAME::Equals(mpir_ui numerator, mpir_ui denominator)
{
IN_CONTEXT(this);
CTXT_ADD_RATIONAL(numerator, denominator);
CTXT_ADD_RATIONAL_UI(numerator, denominator);
return MP(equal)(CTXT(0), CTXT(1)) != 0;
}
@ -328,28 +328,28 @@ namespace MPIR
DEFINE_UNARY_ASSIGNMENT_REF(Abs, Rat, MP(abs))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Add, Rat, MP(add))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Add, Rat, Ui, MP(add))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Add, Rat, Si, MP(add))
DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Add, Rat, Ui, MP(add))
DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Add, Rat, Si, MP(add))
DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Add, Rat, IExpr, MP(add))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Subtract, Rat, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Subtract, Rat, Ui, MP(sub))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Subtract, Ui, Rat, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Subtract, Rat, Si, MP(sub))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Subtract, Si, Rat, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Subtract, Rat, Ui, MP(sub))
DEFINE_BINARY_ASSIGNMENT_RATUI_REF(Subtract, Ui, Rat, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Subtract, Rat, Si, MP(sub))
DEFINE_BINARY_ASSIGNMENT_RATSI_REF(Subtract, Si, Rat, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Subtract, Rat, IExpr, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Subtract, IExpr, Rat, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Multiply, Rat, MP(mul))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Multiply, Rat, Ui, MP(mul))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Multiply, Rat, Si, MP(mul))
DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Multiply, Rat, Ui, MP(mul))
DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Multiply, Rat, Si, MP(mul))
DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Multiply, Rat, IExpr, MP(mul))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Divide, Rat, MP(div))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Divide, Rat, Ui, MP(div))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Divide, Ui, Rat, MP(div))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Divide, Rat, Si, MP(div))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Divide, Si, Rat, MP(div))
DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Divide, Rat, Ui, MP(div))
DEFINE_BINARY_ASSIGNMENT_RATUI_REF(Divide, Ui, Rat, MP(div))
DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Divide, Rat, Si, MP(div))
DEFINE_BINARY_ASSIGNMENT_RATSI_REF(Divide, Si, Rat, MP(div))
DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Divide, Rat, IExpr, MP(div))
DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Divide, IExpr, Rat, MP(div))