-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move System.Math to it's own class lib
- 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
1 parent
b8b4da9
commit fa7ebdf
Showing
12 changed files
with
405 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.