Skip to content

Commit

Permalink
Move System.Math to it's own class lib
Browse files Browse the repository at this point in the history
- Rework System.Math to System.MathInternal to keep abs, max and min (int args only)
- Update mscorlib assembly declarations
- Add System.Math assembly declarations
- Update CMakes accordingly
- Update cmake.varianats with new build option
- Update STM32 build definitions enabling system.math for all targets, except STM32F091
- Update ESP32 build definitions enabling system.math

Signed-off-by: José Simões <jose.simoes@eclo.solutions>
  • Loading branch information
josesimoes committed Oct 26, 2018
1 parent b8b4da9 commit fa7ebdf
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 300 deletions.
2 changes: 1 addition & 1 deletion CMake/Modules/FindNF_CoreCLR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ set(NF_CoreCLR_SRCS
corlib_native_System_Globalization_DateTimeFormat.cpp
corlib_native_System_Guid.cpp
corlib_native_System_MarshalByRefObject.cpp
corlib_native_System_Math.cpp
corlib_native_System_MathInternal.cpp
corlib_native_System_MulticastDelegate.cpp
corlib_native_System_Number.cpp
corlib_native_System_Object.cpp
Expand Down
38 changes: 38 additions & 0 deletions CMake/Modules/FindSystem.Math.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright (c) 2018 The nanoFramework project contributors
# See LICENSE file in the project root for full license information.
#


# native code directory
set(BASE_PATH_FOR_THIS_MODULE "${PROJECT_SOURCE_DIR}/src/CLR/System.Math")


# set include directories
list(APPEND System.Math_INCLUDE_DIRS "${BASE_PATH_FOR_THIS_MODULE}")


# source files
set(System.Math_SRCS

nf_native_system_math.cpp
nf_native_system_math_System_Math.cpp

)

foreach(SRC_FILE ${System.Math_SRCS})
set(System.Math_SRC_FILE SRC_FILE-NOTFOUND)
find_file(System.Math_SRC_FILE ${SRC_FILE}
PATHS
"${BASE_PATH_FOR_THIS_MODULE}"

CMAKE_FIND_ROOT_PATH_BOTH
)
# message("${SRC_FILE} >> ${System.Math_SRC_FILE}") # debug helper
list(APPEND System.Math_SOURCES ${System.Math_SRC_FILE})
endforeach()


include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(System.Math DEFAULT_MSG System.Math_INCLUDE_DIRS System.Math_SOURCES)
7 changes: 7 additions & 0 deletions CMake/Modules/NF_NativeAssemblies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

option(API_nanoFramework.Networking.Sntp "option for nanoFramework.Networking.Sntp")
option(API_nanoFramework.Runtime.Events "option for nanoFramework.Runtime.Events API")
option(API_System.Math "option for System.Math")
option(API_System.Net "option for System.Net")
option(API_Windows.Devices.Adc "option for Windows.Devices.Adc API")
option(API_Windows.Devices.Gpio "option for Windows.Devices.Gpio API")
Expand Down Expand Up @@ -101,6 +102,12 @@ macro(ParseNativeAssemblies)

endif()

# System.Math
if(API_System.Math)
##### API name here (doted name)
PerformSettingsForApiEntry("System.Math")
endif()

# System.Net
if(API_System.Net)
##### API name here (doted name)
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ environment:
matrix:
- BOARD_NAME: 'STM32'
- BOARD_NAME: 'ESP32_DEVKITC'
BUILD_OPTIONS: '-DTARGET_SERIES=ESP32 -DRTOS=FREERTOS -DNF_WP_IMPLEMENTS_CRC32=OFF -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Net=ON -DAPI_Windows.Devices.Wifi=ON -DNF_SECURITY_OPENSSL=ON -DAPI_Hardware.Esp32=ON -DSUPPORT_ANY_BASE_CONVERSION=ON'
BUILD_OPTIONS: '-DTARGET_SERIES=ESP32 -DRTOS=FREERTOS -DNF_WP_IMPLEMENTS_CRC32=OFF -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DAPI_System.Math=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Net=ON -DAPI_Windows.Devices.Wifi=ON -DNF_SECURITY_OPENSSL=ON -DAPI_Hardware.Esp32=ON -DSUPPORT_ANY_BASE_CONVERSION=ON'
- BOARD_NAME: 'NANOCLR_WINDOWS'
- BOARD_NAME: 'NOT_A_BOARD_CHANGELOG'

Expand Down
1 change: 1 addition & 0 deletions cmake-variants.TEMPLATE.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"NF_SECURITY_OPENSSL" : "OFF-default-ON-to-add-network-security-from-OpenSSL",
"NF_SECURITY_MBEDTLS" : "OFF-default-ON-to-add-network-security-from-mbedTLS",
"MBEDTLS_SOURCE" : "<path-to-mbedtls-source-mind-the-forward-slashes>",
"API_System.Math" : "OFF-default-ON-to-add-this-API",
"API_System.Net" : "OFF-default-ON-to-add-this-API",
"API_Windows.Devices.Adc" : "OFF-default-ON-to-add-this-API",
"API_Windows.Devices.Gpio" : "OFF-default-ON-to-add-this-API",
Expand Down
12 changes: 6 additions & 6 deletions get-stm32-targets-to-build.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#build matrx with target names and build options
$BuildMatrix = ("MBN_QUAIL", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON", 'True'),
("ST_STM32F4_DISCOVERY", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DNF_FEATURE_DEBUGGER=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'False'),
("ST_STM32F429I_DISCOVERY", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DUSE_RNG=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'False'),
$BuildMatrix = ("MBN_QUAIL", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DUSE_RNG=ON -DAPI_System.Math=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON", 'True'),
("ST_STM32F4_DISCOVERY", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DNF_FEATURE_DEBUGGER=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DUSE_RNG=ON -DAPI_System.Math=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'False'),
("ST_STM32F429I_DISCOVERY", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DUSE_RNG=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DAPI_System.Math=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'False'),
("ST_NUCLEO64_F091RC", "-DTARGET_SERIES=STM32F0xx -DRTOS=CHIBIOS -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=OFF -DNF_PLATFORM_NO_CLR_TRACE=ON -DNF_CLR_NO_IL_INLINE=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON", 'False'),
("ST_NUCLEO144_F746ZG", "-DTARGET_SERIES=STM32F7xx -DRTOS=CHIBIOS -DNF_FEATURE_DEBUGGER=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DNF_FEATURE_HAS_CONFIG_BLOCK=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Net=ON -DNF_SECURITY_MBEDTLS=ON", 'False'),
("ST_STM32F769I_DISCOVERY", "-DTARGET_SERIES=STM32F7xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DAPI_Hardware.Stm32=ON -DNF_FEATURE_HAS_CONFIG_BLOCK=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Net=ON -DNF_SECURITY_MBEDTLS=ON", 'False'),
("NETDUINO3_WIFI", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'True')
("ST_NUCLEO144_F746ZG", "-DTARGET_SERIES=STM32F7xx -DRTOS=CHIBIOS -DNF_FEATURE_DEBUGGER=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DNF_FEATURE_HAS_CONFIG_BLOCK=ON -DUSE_RNG=ON -DAPI_System.Math=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Net=ON -DNF_SECURITY_MBEDTLS=ON", 'False'),
("ST_STM32F769I_DISCOVERY", "-DTARGET_SERIES=STM32F7xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DUSE_RNG=ON -DAPI_System.Math=ON -DAPI_Hardware.Stm32=ON -DNF_FEATURE_HAS_CONFIG_BLOCK=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Net=ON -DNF_SECURITY_MBEDTLS=ON", 'False'),
("NETDUINO3_WIFI", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=ON -DAPI_System.Math=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'True')


# get commit message
Expand Down
58 changes: 5 additions & 53 deletions src/CLR/CorLib/corlib_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,57 +464,9 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
Library_corlib_native_System_Math::Abs___STATIC__I4__I4,
Library_corlib_native_System_Math::Max___STATIC__I4__I4__I4,
Library_corlib_native_System_Math::Min___STATIC__I4__I4__I4,
Library_corlib_native_System_Math::Abs___STATIC__R8__R8,
Library_corlib_native_System_Math::Abs___STATIC__R4__R4,
Library_corlib_native_System_Math::Acos___STATIC__R8__R8,
Library_corlib_native_System_Math::Acos___STATIC__R4__R4,
Library_corlib_native_System_Math::Asin___STATIC__R8__R8,
Library_corlib_native_System_Math::Asin___STATIC__R4__R4,
Library_corlib_native_System_Math::Atan___STATIC__R8__R8,
Library_corlib_native_System_Math::Atan___STATIC__R4__R4,
Library_corlib_native_System_Math::Atan2___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Atan2___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Ceiling___STATIC__R8__R8,
Library_corlib_native_System_Math::Ceiling___STATIC__R4__R4,
Library_corlib_native_System_Math::Cos___STATIC__R8__R8,
Library_corlib_native_System_Math::Cos___STATIC__R4__R4,
Library_corlib_native_System_Math::Cosh___STATIC__R8__R8,
Library_corlib_native_System_Math::Cosh___STATIC__R4__R4,
Library_corlib_native_System_Math::IEEERemainder___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::IEEERemainder___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Exp___STATIC__R8__R8,
Library_corlib_native_System_Math::Exp___STATIC__R4__R4,
Library_corlib_native_System_Math::Floor___STATIC__R8__R8,
Library_corlib_native_System_Math::Floor___STATIC__R4__R4,
Library_corlib_native_System_Math::Log___STATIC__R8__R8,
Library_corlib_native_System_Math::Log___STATIC__R4__R4,
Library_corlib_native_System_Math::Log10___STATIC__R8__R8,
Library_corlib_native_System_Math::Log10___STATIC__R4__R4,
Library_corlib_native_System_Math::Max___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Max___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Min___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Min___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Pow___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Pow___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Round___STATIC__R8__R8,
Library_corlib_native_System_Math::Round___STATIC__R4__R4,
Library_corlib_native_System_Math::Sign___STATIC__I4__R8,
Library_corlib_native_System_Math::Sign___STATIC__I4__R4,
Library_corlib_native_System_Math::Sin___STATIC__R8__R8,
Library_corlib_native_System_Math::Sin___STATIC__R4__R4,
Library_corlib_native_System_Math::Sinh___STATIC__R8__R8,
Library_corlib_native_System_Math::Sinh___STATIC__R4__R4,
Library_corlib_native_System_Math::Sqrt___STATIC__R8__R8,
Library_corlib_native_System_Math::Sqrt___STATIC__R4__R4,
Library_corlib_native_System_Math::Tan___STATIC__R8__R8,
Library_corlib_native_System_Math::Tan___STATIC__R4__R4,
Library_corlib_native_System_Math::Tanh___STATIC__R8__R8,
Library_corlib_native_System_Math::Tanh___STATIC__R4__R4,
Library_corlib_native_System_Math::Truncate___STATIC__R8__R8,
Library_corlib_native_System_Math::Truncate___STATIC__R4__R4,
Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4,
Library_corlib_native_System_MathInternal::Min___STATIC__I4__I4__I4,
Library_corlib_native_System_MathInternal::Max___STATIC__I4__I4__I4,
NULL,
NULL,
NULL,
Expand Down Expand Up @@ -945,7 +897,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_mscorlib =
{
"mscorlib",
0x8899664E,
0xEF6F3396,
method_lookup,
{ 1, 0, 4, 0 }
{ 1, 0, 5, 0 }
};
52 changes: 2 additions & 50 deletions src/CLR/CorLib/corlib_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,59 +500,11 @@ struct Library_corlib_native_System_Int64

};

struct Library_corlib_native_System_Math
struct Library_corlib_native_System_MathInternal
{
NANOCLR_NATIVE_DECLARE(Abs___STATIC__I4__I4);
NANOCLR_NATIVE_DECLARE(Max___STATIC__I4__I4__I4);
NANOCLR_NATIVE_DECLARE(Min___STATIC__I4__I4__I4);
NANOCLR_NATIVE_DECLARE(Abs___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Abs___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Acos___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Acos___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Asin___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Asin___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Atan___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Atan___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Atan2___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Atan2___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Ceiling___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Ceiling___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Cos___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Cos___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Cosh___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Cosh___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(IEEERemainder___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(IEEERemainder___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Exp___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Exp___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Floor___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Floor___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Log___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Log___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Log10___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Log10___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Max___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Max___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Min___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Min___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Pow___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Pow___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Round___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Round___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Sign___STATIC__I4__R8);
NANOCLR_NATIVE_DECLARE(Sign___STATIC__I4__R4);
NANOCLR_NATIVE_DECLARE(Sin___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Sin___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Sinh___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Sinh___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Sqrt___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Sqrt___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Tan___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Tan___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Tanh___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Tanh___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Truncate___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Truncate___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Max___STATIC__I4__I4__I4);

//--//

Expand Down
103 changes: 103 additions & 0 deletions src/CLR/CorLib/corlib_native_System_MathInternal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// Copyright (c) 2017 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
//
#include "CorLib.h"

#if !defined(NANOCLR_EMULATED_FLOATINGPOINT)
#include "nanoPAL_NativeDouble.h"

HRESULT Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4( CLR_RT_StackFrame& stack )
{
#if (DP_FLOATINGPOINT == TRUE)
stack.NotImplementedStub();
#else

NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

float d = stack.Arg0().NumericByRefConst().s4;
float res = fabs( d );

stack.SetResult_I4( res );

NANOCLR_NOCLEANUP_NOLABEL();

#endif
}

HRESULT Library_corlib_native_System_MathInternal::Max___STATIC__I4__I4__I4( CLR_RT_StackFrame& stack )
{
#if (DP_FLOATINGPOINT == TRUE)
return stack.NotImplementedStub();
#else

NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

float x = stack.Arg0().NumericByRefConst().s4;
float y = stack.Arg1().NumericByRefConst().s4;
float res = x >= y ? x : y;

stack.SetResult_I4( res );

NANOCLR_NOCLEANUP_NOLABEL();

#endif
}

HRESULT Library_corlib_native_System_MathInternal::Min___STATIC__I4__I4__I4( CLR_RT_StackFrame& stack )
{
#if (DP_FLOATINGPOINT == TRUE)
return stack.NotImplementedStub();
#else

NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

float x = stack.Arg0().NumericByRefConst().s4;
float y = stack.Arg1().NumericByRefConst().s4;
float res = x <= y ? x : y;

stack.SetResult_I4( res );

NANOCLR_NOCLEANUP_NOLABEL();

#endif
}

#else

/// No floating point
HRESULT Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4( CLR_RT_StackFrame& stack )
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub());

NANOCLR_NOCLEANUP();
}

HRESULT Library_corlib_native_System_MathInternal::Max___STATIC__I4__I4__I4( CLR_RT_StackFrame& stack )
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub());

NANOCLR_NOCLEANUP();
}

HRESULT Library_corlib_native_System_MathInternal::Min___STATIC__I4__I4__I4( CLR_RT_StackFrame& stack )
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub());

NANOCLR_NOCLEANUP();
}

#endif // NANOCLR_EMULATED_FLOATINGPOINT
Loading

0 comments on commit fa7ebdf

Please sign in to comment.