Skip to content

Commit

Permalink
Common: remove warning for Linux build
Browse files Browse the repository at this point in the history
ODE: replace fpclassify on std:fpclassify
xrCore: add define XRCORE_EXPORTS, copy _fpclass replacement from ODE
  • Loading branch information
eagleivg committed Jun 5, 2018
1 parent d453845 commit fbf7987
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Externals/ode/ode/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "objects.h"
#include "float.h"
#if defined(LINUX)
#include <math.h>
#include <cmath>
#endif

void dInternalHandleAutoDisabling (dxWorld *world, dReal stepsize);
Expand All @@ -48,7 +48,7 @@ inline bool dValid(const float x)
if (cls&(_FPCLASS_SNAN+_FPCLASS_QNAN+_FPCLASS_NINF+_FPCLASS_PINF+_FPCLASS_ND+_FPCLASS_PD))
return false;
#elif defined(LINUX)
int cls = fpclassify((double )x);
int cls = std::fpclassify((double )x);
switch (cls)
{
case FP_NAN:
Expand Down
4 changes: 2 additions & 2 deletions src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ typedef dirent DirEntryType;
#define strcmpi stricmp
#define lstrcpy strcpy
#define stricmp strcasecmp
#define strncpy_s(dest, size, source, num) strncpy(dest, source, num)
#define strcpy_s(dest, num, source) strcpy(dest, source)
#define strncpy_s(dest, size, source, num) (NULL == strncpy(dest, source, num))
#define strcpy_s(dest, num, source) (NULL == strcpy(dest, source))
#define _vsnprintf vsnprintf
#define _alloca alloca
#define _snprintf snprintf
Expand Down
1 change: 1 addition & 0 deletions src/xrCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_dir("${DIRS}")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/pugixml/src ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include)

add_definitions(-DXRCORE_EXPORTS)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
Expand Down
27 changes: 22 additions & 5 deletions src/xrCore/_std_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,25 @@ IC bool _valid(const float x) noexcept
if (cls & (_FPCLASS_SNAN + _FPCLASS_QNAN + _FPCLASS_NINF + _FPCLASS_PINF + _FPCLASS_ND + _FPCLASS_PD))
return false;
#else
#pragma todo("Find Linux alternative for _fpclass. Check https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/crt/math.h");
int cls = std::fpclassify((double )x);
switch (cls)
{
case FP_NAN:
case FP_INFINITE:
case FP_SUBNORMAL:
return false;
default:
break;
}

/* *****other cases are*****
_FPCLASS_NN Negative normalized non-zero
_FPCLASS_NZ Negative zero ( ??? 0)
_FPCLASS_PZ Positive 0 (+0)
_FPCLASS_PN Positive normalized non-zero
*/
return true;
#endif
return true;
}

// double
Expand All @@ -114,16 +123,24 @@ IC bool _valid(const double x)
if (cls & (_FPCLASS_SNAN + _FPCLASS_QNAN + _FPCLASS_NINF + _FPCLASS_PINF + _FPCLASS_ND + _FPCLASS_PD))
return false;
#else
#pragma todo("Find Linux alternative for _fpclass. Check https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/crt/math.h");

int cls = std::fpclassify((double )x);
switch (cls)
{
case FP_NAN:
case FP_INFINITE:
case FP_SUBNORMAL:
return false;
default:
break;
}
/* *****other cases are*****
_FPCLASS_NN Negative normalized non-zero
_FPCLASS_NZ Negative zero ( ??? 0)
_FPCLASS_PZ Positive 0 (+0)
_FPCLASS_PN Positive normalized non-zero
*/
return true;
#endif
return true;
}

// XXX: "magic" specializations, that really require profiling to see if they are worth this effort.
Expand Down

0 comments on commit fbf7987

Please sign in to comment.