blosc-common.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*********************************************************************
  2. Blosc - Blocked Shuffling and Compression Library
  3. Author: Francesc Alted <francesc@blosc.org>
  4. See LICENSES/BLOSC.txt for details about copyright and rights to use.
  5. **********************************************************************/
  6. #ifndef SHUFFLE_COMMON_H
  7. #define SHUFFLE_COMMON_H
  8. #include "blosc-export.h"
  9. #include <string.h>
  10. /* Import standard integer type definitions */
  11. #if defined(_WIN32) && !defined(__MINGW32__)
  12. /* stdint.h only available in VS2010 (VC++ 16.0) and newer */
  13. #if defined(_MSC_VER) && _MSC_VER < 1600
  14. #include "win32/stdint-windows.h"
  15. #else
  16. #include <stdint.h>
  17. #endif
  18. /* Use inlined functions for supported systems */
  19. #if defined(_MSC_VER) && !defined(__cplusplus) /* Visual Studio */
  20. #define inline __inline /* Visual C is not C99, but supports some kind of inline */
  21. #endif
  22. #else
  23. #include <stdint.h>
  24. #endif /* _WIN32 */
  25. /* Define the __SSE2__ symbol if compiling with Visual C++ and
  26. targeting the minimum architecture level supporting SSE2.
  27. Other compilers define this as expected and emit warnings
  28. when it is re-defined. */
  29. #if !defined(__SSE2__) && defined(_MSC_VER) && \
  30. (defined(_M_X64) || (defined(_M_IX86) && _M_IX86_FP >= 2))
  31. #define __SSE2__
  32. #endif
  33. /*
  34. * Detect if the architecture is fine with unaligned access.
  35. */
  36. #if !defined(BLOSC_STRICT_ALIGN)
  37. #define BLOSC_STRICT_ALIGN
  38. #if defined(__i386__) || defined(__386) || defined (__amd64) /* GNU C, Sun Studio */
  39. #undef BLOSC_STRICT_ALIGN
  40. #elif defined(__i486__) || defined(__i586__) || defined(__i686__) /* GNU C */
  41. #undef BLOSC_STRICT_ALIGN
  42. #elif defined(_M_IX86) || defined(_M_X64) /* Intel, MSVC */
  43. #undef BLOSC_STRICT_ALIGN
  44. #elif defined(__386)
  45. #undef BLOSC_STRICT_ALIGN
  46. #elif defined(_X86_) /* MinGW */
  47. #undef BLOSC_STRICT_ALIGN
  48. #elif defined(__I86__) /* Digital Mars */
  49. #undef BLOSC_STRICT_ALIGN
  50. /* Seems like unaligned access in ARM (at least ARMv6) is pretty
  51. expensive, so we are going to always enforce strict aligment in ARM.
  52. If anybody suggest that newer ARMs are better, we can revisit this. */
  53. /* #elif defined(__ARM_FEATURE_UNALIGNED) */ /* ARM, GNU C */
  54. /* #undef BLOSC_STRICT_ALIGN */
  55. #elif defined(_ARCH_PPC) || defined(__PPC__)
  56. /* Modern PowerPC systems (like POWER8) should support unaligned access
  57. quite efficiently. */
  58. #undef BLOSC_STRICT_ALIGN
  59. #endif
  60. #endif
  61. #if defined(__SSE2__)
  62. #include <emmintrin.h>
  63. #endif
  64. #if defined(__AVX2__)
  65. #include <immintrin.h>
  66. #endif
  67. #endif /* SHUFFLE_COMMON_H */