00-future-2024-05-22-wasm-eptr.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. diff --git a/include/__exception/exception_ptr.h b/include/__exception/exception_ptr.h
  2. index 53e2f71..73834b6 100644
  3. --- a/include/__exception/exception_ptr.h
  4. +++ b/include/__exception/exception_ptr.h
  5. @@ -36,11 +36,14 @@ struct __cxa_exception;
  6. _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
  7. void*,
  8. std::type_info*,
  9. - void(
  10. # if defined(_WIN32)
  11. - __thiscall
  12. + void(__thiscall*)(void*)) throw();
  13. +# elif defined(__wasm__)
  14. + // In Wasm, a destructor returns its argument
  15. + void* (*)(void*)) throw();
  16. +# else
  17. + void (*)(void*)) throw();
  18. # endif
  19. - *)(void*)) throw();
  20. }
  21. } // namespace __cxxabiv1
  22. @@ -88,8 +91,16 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
  23. using _Ep2 = __decay_t<_Ep>;
  24. void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
  25. +# ifdef __wasm__
  26. + // In Wasm, a destructor returns its argument
  27. + (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) -> void* {
  28. +# else
  29. (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) {
  30. +# endif
  31. std::__destroy_at(static_cast<_Ep2*>(__p));
  32. +# ifdef __wasm__
  33. + return __p;
  34. +# endif
  35. });
  36. try {
  37. diff --git a/include/__locale b/include/__locale
  38. index 2186db8..fa987cb 100644
  39. --- a/include/__locale
  40. +++ b/include/__locale
  41. @@ -344,12 +344,12 @@ public:
  42. static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
  43. # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
  44. # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
  45. -#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
  46. +#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
  47. # ifdef __APPLE__
  48. typedef __uint32_t mask;
  49. # elif defined(__FreeBSD__)
  50. typedef unsigned long mask;
  51. -# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
  52. +# elif defined(__NetBSD__)
  53. typedef unsigned short mask;
  54. # endif
  55. static const mask space = _CTYPE_S;