40 #include <pcl/pcl_config.h>
41 #include <boost/cstdint.hpp>
49 using boost::uint16_t;
51 using boost::uint32_t;
53 using boost::uint64_t;
54 using boost::int_fast16_t;
57 #if defined __INTEL_COMPILER
58 #pragma warning disable 2196 2536 279
66 #pragma warning (disable: 4018 4244 4267 4521 4251 4661 4305 4503 4146)
72 #ifndef _USE_MATH_DEFINES
73 #define _USE_MATH_DEFINES
78 #if defined _WIN32 && defined _MSC_VER
83 # define M_PI 3.14159265358979323846 // pi
84 # define M_PI_2 1.57079632679489661923 // pi/2
85 # define M_PI_4 0.78539816339744830962 // pi/4
86 # define M_PIl 3.1415926535897932384626433832795029L // pi
87 # define M_PI_2l 1.5707963267948966192313216916397514L // pi/2
88 # define M_PI_4l 0.7853981633974483096156608458198757L // pi/4
96 # define pcl_isnan(x) _isnan(x)
97 # define pcl_isfinite(x) (_finite(x) != 0)
98 # define pcl_isinf(x) (_finite(x) == 0)
100 # define __PRETTY_FUNCTION__ __FUNCTION__
101 # define __func__ __FUNCTION__
106 # define pcl_isnan(x) std::isnan(x)
107 # define pcl_isfinite(x) std::isfinite(x)
108 # define pcl_isinf(x) std::isinf(x)
110 #elif _GLIBCXX_USE_C99_MATH
113 # define pcl_isnan(x) std::isnan(x)
114 # define pcl_isfinite(x) std::isfinite(x)
115 # define pcl_isinf(x) std::isinf(x)
120 template <
typename T>
int
126 # define pcl_isfinite(x) std::isfinite(x)
127 # define pcl_isinf(x) std::isinf(x)
132 # define pcl_isnan(x) isnan(x)
133 # define pcl_isfinite(x) isfinite(x)
134 # define pcl_isinf(x) isinf(x)
139 #define DEG2RAD(x) ((x)*0.017453293)
143 #define RAD2DEG(x) ((x)*57.29578)
148 #define PCL_LINEAR_VERSION(major,minor,patch) ((major)<<16|(minor)<<8|(patch))
155 pcl_round (
double number)
157 return (number < 0.0 ? ceil (number - 0.5) : floor (number + 0.5));
160 pcl_round (
float number)
162 return (number < 0.0f ? ceilf (number - 0.5f) : floorf (number + 0.5f));
166 #define pcl_lrint(x) (lrint(static_cast<double> (x)))
167 #define pcl_lrintf(x) (lrintf(static_cast<float> (x)))
169 #define pcl_lrint(x) (static_cast<long int>(pcl_round(x)))
170 #define pcl_lrintf(x) (static_cast<long int>(pcl_round(x)))
178 return (static_cast<float> (logf (x) * M_LOG2E));
183 #define pcl_sleep(x) Sleep(1000*(x))
185 #define pcl_sleep(x) sleep(x)
190 #s << " = " << (s) << std::flush
194 #s << " = " << (s) << "\n"
198 #s << " = " << (s) << ", " << std::flush
202 #s << " = " << (s) << " " << std::flush
206 #s << " = " << RAD2DEG(s) << "deg" << std::flush
210 #s << " = " << RAD2DEG(s) << "deg\n"
214 #s << " = " << RAD2DEG(s) << "deg, " << std::flush
218 #s << " = " << RAD2DEG(s) << "deg " << std::flush
222 std::fixed << s << std::resetiosflags(std::ios_base::fixed)
225 #define ERASE_STRUCT(var) memset(&var, 0, sizeof(var))
229 #define ERASE_ARRAY(var, size) memset(var, 0, size*sizeof(*var))
233 #define SET_ARRAY(var, value, size) { for (int i = 0; i < static_cast<int> (size); ++i) var[i]=value; }
264 #define PCL_EXTERN_C extern "C"
270 #if defined WIN32 || defined _WIN32 || defined WINCE || defined __MINGW32__
271 #ifdef PCLAPI_EXPORTS
272 #define PCL_EXPORTS __declspec(dllexport)
280 #if defined WIN32 || defined _WIN32
281 #define PCL_CDECL __cdecl
282 #define PCL_STDCALL __stdcall
289 #define PCLAPI(rettype) PCL_EXTERN_C PCL_EXPORTS rettype PCL_CDECL
293 #if (defined (__GNUC__) || defined(__clang__))
294 #define PCL_PRAGMA(x) _Pragma (#x)
296 #define PCL_PRAGMA(x) __pragma (#x)
302 #if (defined (__GNUC__) || defined(__clang__))
303 #define PCL_PRAGMA_WARNING(x) PCL_PRAGMA (GCC warning x)
305 #define PCL_PRAGMA_WARNING(x) PCL_PRAGMA (warning (x))
307 #define PCL_PRAGMA_WARNING
320 #ifndef __has_extension
321 #define __has_extension(x) 0 // Compatibility with pre-3.0 compilers.
325 #if defined(__INTEL_COMPILER)
326 #define PCL_DEPRECATED(message) __attribute((deprecated))
327 #elif (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) < PCL_LINEAR_VERSION(4,5,0) && ! defined(__clang__)) || defined(__INTEL_COMPILER)
328 #define PCL_DEPRECATED(message) __attribute__ ((deprecated))
330 #elif (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) >= PCL_LINEAR_VERSION(4,5,0)) || (defined(__clang__) && __has_extension(attribute_deprecated_with_message))
331 #define PCL_DEPRECATED(message) __attribute__ ((deprecated(message)))
332 #elif defined(_MSC_VER)
333 #define PCL_DEPRECATED(message) __declspec(deprecated(message))
335 #pragma message("WARNING: You need to implement PCL_DEPRECATED for this compiler")
336 #define PCL_DEPRECATED(message)
357 #if defined(__INTEL_COMPILER)
358 #define PCL_DEPRECATED_CLASS(func, message) __attribute((deprecated)) func
359 #elif (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) < PCL_LINEAR_VERSION(4,5,0) && ! defined(__clang__)) || defined(__INTEL_COMPILER)
360 #define PCL_DEPRECATED_CLASS(func, message) __attribute__ ((deprecated)) func
362 #elif (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) >= PCL_LINEAR_VERSION(4,5,0)) || (defined(__clang__) && __has_extension(attribute_deprecated_with_message))
363 #define PCL_DEPRECATED_CLASS(func, message) __attribute__ ((deprecated(message))) func
364 #elif defined(_MSC_VER)
365 #define PCL_DEPRECATED_CLASS(func, message) __declspec(deprecated(message)) func
367 #pragma message("WARNING: You need to implement PCL_DEPRECATED_CLASS for this compiler")
368 #define PCL_DEPRECATED_CLASS(func) func
371 #if defined (__GNUC__) || defined (__PGI) || defined (__IBMCPP__) || defined (__SUNPRO_CC)
372 #define PCL_ALIGN(alignment) __attribute__((aligned(alignment)))
373 #elif defined (_MSC_VER)
374 #define PCL_ALIGN(alignment) __declspec(align(alignment))
376 #error Alignment not supported on your platform
379 #if defined(__GLIBC__) && PCL_LINEAR_VERSION(__GLIBC__,__GLIBC_MINOR__,0)>PCL_LINEAR_VERSION(2,8,0)
380 #define GLIBC_MALLOC_ALIGNED 1
382 #define GLIBC_MALLOC_ALIGNED 0
385 #if defined(__FreeBSD__) && !defined(__arm__) && !defined(__mips__)
386 #define FREEBSD_MALLOC_ALIGNED 1
388 #define FREEBSD_MALLOC_ALIGNED 0
391 #if defined(__APPLE__) || defined(_WIN64) || GLIBC_MALLOC_ALIGNED || FREEBSD_MALLOC_ALIGNED
392 #define MALLOC_ALIGNED 1
395 #if defined (HAVE_MM_MALLOC)
397 #if defined(__INTEL_COMPILER)
400 #include <mm_malloc.h>
405 aligned_malloc (
size_t size)
408 #if defined (MALLOC_ALIGNED)
409 ptr = std::malloc (size);
410 #elif defined (HAVE_POSIX_MEMALIGN)
411 if (posix_memalign (&ptr, 16, size))
413 #elif defined (HAVE_MM_MALLOC)
414 ptr = _mm_malloc (size, 16);
415 #elif defined (_MSC_VER)
416 ptr = _aligned_malloc (size, 16);
417 #elif defined (ANDROID)
418 ptr = memalign (16, size);
420 #error aligned_malloc not supported on your platform
427 aligned_free (
void* ptr)
429 #if defined (MALLOC_ALIGNED) || defined (HAVE_POSIX_MEMALIGN)
431 #elif defined (HAVE_MM_MALLOC)
433 #elif defined (_MSC_VER)
435 #elif defined (ANDROID)
438 #error aligned_free not supported on your platform
442 #endif //#ifndef PCL_MACROS_H_
This file defines compatibility wrappers for low level I/O functions.