Skip to content

Commit fbf7987

Browse files
committed
Common: remove warning for Linux build
ODE: replace fpclassify on std:fpclassify xrCore: add define XRCORE_EXPORTS, copy _fpclass replacement from ODE
1 parent d453845 commit fbf7987

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

Externals/ode/ode/src/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "objects.h"
2727
#include "float.h"
2828
#if defined(LINUX)
29-
#include <math.h>
29+
#include <cmath>
3030
#endif
3131

3232
void dInternalHandleAutoDisabling (dxWorld *world, dReal stepsize);
@@ -48,7 +48,7 @@ inline bool dValid(const float x)
4848
if (cls&(_FPCLASS_SNAN+_FPCLASS_QNAN+_FPCLASS_NINF+_FPCLASS_PINF+_FPCLASS_ND+_FPCLASS_PD))
4949
return false;
5050
#elif defined(LINUX)
51-
int cls = fpclassify((double )x);
51+
int cls = std::fpclassify((double )x);
5252
switch (cls)
5353
{
5454
case FP_NAN:

src/Common/PlatformLinux.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ typedef dirent DirEntryType;
196196
#define strcmpi stricmp
197197
#define lstrcpy strcpy
198198
#define stricmp strcasecmp
199-
#define strncpy_s(dest, size, source, num) strncpy(dest, source, num)
200-
#define strcpy_s(dest, num, source) strcpy(dest, source)
199+
#define strncpy_s(dest, size, source, num) (NULL == strncpy(dest, source, num))
200+
#define strcpy_s(dest, num, source) (NULL == strcpy(dest, source))
201201
#define _vsnprintf vsnprintf
202202
#define _alloca alloca
203203
#define _snprintf snprintf

src/xrCore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ add_dir("${DIRS}")
1818

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

21+
add_definitions(-DXRCORE_EXPORTS)
2122
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
2223

2324
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")

src/xrCore/_std_extensions.h

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,25 @@ IC bool _valid(const float x) noexcept
9292
if (cls & (_FPCLASS_SNAN + _FPCLASS_QNAN + _FPCLASS_NINF + _FPCLASS_PINF + _FPCLASS_ND + _FPCLASS_PD))
9393
return false;
9494
#else
95-
#pragma todo("Find Linux alternative for _fpclass. Check https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/crt/math.h");
95+
int cls = std::fpclassify((double )x);
96+
switch (cls)
97+
{
98+
case FP_NAN:
99+
case FP_INFINITE:
100+
case FP_SUBNORMAL:
101+
return false;
102+
default:
103+
break;
104+
}
96105

97106
/* *****other cases are*****
98107
_FPCLASS_NN Negative normalized non-zero
99108
_FPCLASS_NZ Negative zero ( ??? 0)
100109
_FPCLASS_PZ Positive 0 (+0)
101110
_FPCLASS_PN Positive normalized non-zero
102111
*/
103-
return true;
104112
#endif
113+
return true;
105114
}
106115

107116
// double
@@ -114,16 +123,24 @@ IC bool _valid(const double x)
114123
if (cls & (_FPCLASS_SNAN + _FPCLASS_QNAN + _FPCLASS_NINF + _FPCLASS_PINF + _FPCLASS_ND + _FPCLASS_PD))
115124
return false;
116125
#else
117-
#pragma todo("Find Linux alternative for _fpclass. Check https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/crt/math.h");
118-
126+
int cls = std::fpclassify((double )x);
127+
switch (cls)
128+
{
129+
case FP_NAN:
130+
case FP_INFINITE:
131+
case FP_SUBNORMAL:
132+
return false;
133+
default:
134+
break;
135+
}
119136
/* *****other cases are*****
120137
_FPCLASS_NN Negative normalized non-zero
121138
_FPCLASS_NZ Negative zero ( ??? 0)
122139
_FPCLASS_PZ Positive 0 (+0)
123140
_FPCLASS_PN Positive normalized non-zero
124141
*/
125-
return true;
126142
#endif
143+
return true;
127144
}
128145

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

0 commit comments

Comments
 (0)