TBrokenGreenlet.cpp 1021 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* -*- indent-tabs-mode: nil; tab-width: 4; -*- */
  2. /**
  3. * Implementation of greenlet::UserGreenlet.
  4. *
  5. * Format with:
  6. * clang-format -i --style=file src/greenlet/greenlet.c
  7. *
  8. *
  9. * Fix missing braces with:
  10. * clang-tidy src/greenlet/greenlet.c -fix -checks="readability-braces-around-statements"
  11. */
  12. #include "TGreenlet.hpp"
  13. namespace greenlet {
  14. void* BrokenGreenlet::operator new(size_t UNUSED(count))
  15. {
  16. return allocator.allocate(1);
  17. }
  18. void BrokenGreenlet::operator delete(void* ptr)
  19. {
  20. return allocator.deallocate(static_cast<BrokenGreenlet*>(ptr),
  21. 1);
  22. }
  23. greenlet::PythonAllocator<greenlet::BrokenGreenlet> greenlet::BrokenGreenlet::allocator;
  24. bool
  25. BrokenGreenlet::force_slp_switch_error() const noexcept
  26. {
  27. return this->_force_slp_switch_error;
  28. }
  29. UserGreenlet::switchstack_result_t BrokenGreenlet::g_switchstack(void)
  30. {
  31. if (this->_force_switch_error) {
  32. return switchstack_result_t(-1);
  33. }
  34. return UserGreenlet::g_switchstack();
  35. }
  36. }; //namespace greenlet