gil_config.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Copyright 2005-2007 Adobe Systems Incorporated
  3. Copyright 2018 Mateusz Loskot <mateusz at loskot dot net>
  4. Use, modification and distribution are subject to the Boost Software License,
  5. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt).
  7. See http://opensource.adobe.com/gil for most recent version including documentation.
  8. */
  9. /*************************************************************************************************/
  10. #ifndef GIL_CONFIG_HPP
  11. #define GIL_CONFIG_HPP
  12. ////////////////////////////////////////////////////////////////////////////////////////
  13. /// \file
  14. /// \brief GIL configuration file
  15. /// \author Lubomir Bourdev and Hailin Jin \n
  16. /// Adobe Systems Incorporated
  17. ///
  18. ////////////////////////////////////////////////////////////////////////////////////////
  19. #include <boost/config.hpp>
  20. #include <boost/config/pragma_message.hpp>
  21. #if defined(BOOST_GIL_DOXYGEN_ONLY)
  22. /// \def BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS
  23. /// \brief Define to allow unaligned memory access
  24. /// Theoretically (or historically?) on platforms which support dereferencing on
  25. /// non-word memory boundary, unaligned access may result in performance improvement.
  26. /// \warning Unfortunately, this optimization may be a C/C++ strict aliasing rules
  27. /// violation, if accessed data buffer has effective type that cannot be aliased
  28. /// without leading to undefined behaviour.
  29. #define BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS
  30. #endif
  31. #if defined(BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS)
  32. #if defined(sun) || defined(__sun) || \ // SunOS
  33. defined(__osf__) || defined(__osf) || \ // Tru64
  34. defined(_hpux) || defined(hpux) || \ // HP-UX
  35. defined(__arm__) || defined(__ARM_ARCH) || \ // ARM
  36. defined(_AIX) // AIX
  37. #error Unaligned access strictly disabled for some UNIX platforms or ARM architecture
  38. #elif defined(__i386__) || defined(__x86_64__) || defined(__vax__)
  39. // The check for little-endian architectures that tolerate unaligned memory
  40. // accesses is just an optimization. Nothing will break if it fails to detect
  41. // a suitable architecture.
  42. //
  43. // Unfortunately, this optimization may be a C/C++ strict aliasing rules violation
  44. // if accessed data buffer has effective type that cannot be aliased
  45. // without leading to undefined behaviour.
  46. BOOST_PRAGMA_MESSAGE("CAUTION: Unaligned access tolerated on little-endian may cause undefined behaviour")
  47. #else
  48. #error Unaligned access disabled for unknown platforms and architectures
  49. #endif
  50. #endif // defined(BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS)
  51. #endif