fcontext.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright Oliver Kowalke 2009.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_CONTEXT_FCONTEXT_H
  6. #define BOOST_CONTEXT_FCONTEXT_H
  7. #if defined(__PGI)
  8. #include <stdint.h>
  9. #endif
  10. #if defined(_WIN32_WCE)
  11. typedef int intptr_t;
  12. #endif
  13. #include <boost/config.hpp>
  14. #include <boost/cstdint.hpp>
  15. #include <boost/context/detail/config.hpp>
  16. #ifdef BOOST_HAS_ABI_HEADERS
  17. # include BOOST_ABI_PREFIX
  18. #endif
  19. // x86_64
  20. // test x86_64 before i386 because icc might
  21. // define __i686__ for x86_64 too
  22. #if defined(__x86_64__) || defined(__x86_64) \
  23. || defined(__amd64__) || defined(__amd64) \
  24. || defined(_M_X64) || defined(_M_AMD64)
  25. # if defined(BOOST_WINDOWS)
  26. # include <boost/context/detail/fcontext_x86_64_win.hpp>
  27. # else
  28. # include <boost/context/detail/fcontext_x86_64.hpp>
  29. # endif
  30. // i386
  31. #elif defined(i386) || defined(__i386__) || defined(__i386) \
  32. || defined(__i486__) || defined(__i586__) || defined(__i686__) \
  33. || defined(__X86__) || defined(_X86_) || defined(__THW_INTEL__) \
  34. || defined(__I86__) || defined(__INTEL__) || defined(__IA32__) \
  35. || defined(_M_IX86) || defined(_I86_)
  36. # if defined(BOOST_WINDOWS)
  37. # include <boost/context/detail/fcontext_i386_win.hpp>
  38. # else
  39. # include <boost/context/detail/fcontext_i386.hpp>
  40. # endif
  41. // arm
  42. #elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) \
  43. || defined(__TARGET_ARCH_THUMB) || defined(_ARM) || defined(_M_ARM)
  44. # include <boost/context/detail/fcontext_arm.hpp>
  45. // mips
  46. #elif (defined(__mips) && __mips == 1) || defined(_MIPS_ISA_MIPS1) \
  47. || defined(_R3000)
  48. # include <boost/context/detail/fcontext_mips.hpp>
  49. // powerpc
  50. #elif defined(__powerpc) || defined(__powerpc__) || defined(__ppc) \
  51. || defined(__ppc__) || defined(_ARCH_PPC) || defined(__POWERPC__) \
  52. || defined(__PPCGECKO__) || defined(__PPCBROADWAY) || defined(_XENON)
  53. # include <boost/context/detail/fcontext_ppc.hpp>
  54. #elif defined(__sparc__) || defined(__sparc)
  55. // sparc or sparc64
  56. # include <boost/context/detail/fcontext_sparc.hpp>
  57. #else
  58. # error "platform not supported"
  59. #endif
  60. namespace boost {
  61. namespace context {
  62. extern "C" BOOST_CONTEXT_DECL
  63. intptr_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp, bool preserve_fpu = true);
  64. extern "C" BOOST_CONTEXT_DECL
  65. fcontext_t * BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( intptr_t) );
  66. }}
  67. #ifdef BOOST_HAS_ABI_HEADERS
  68. # include BOOST_ABI_SUFFIX
  69. #endif
  70. #endif // BOOST_CONTEXT_FCONTEXT_H