abi.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #include <stdlib.h>
  14. #include <assert.h>
  15. #include <cxxabi.h>
  16. #include <stdint.h>
  17. // using __cxxabiv1::__guard;
  18. void *operator new(size_t size)
  19. {
  20. return malloc(size);
  21. }
  22. void *operator new[](size_t size)
  23. {
  24. return malloc(size);
  25. }
  26. void operator delete(void * ptr)
  27. {
  28. free(ptr);
  29. }
  30. void operator delete[](void * ptr)
  31. {
  32. free(ptr);
  33. }
  34. extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
  35. extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
  36. void __cxa_pure_virtual(void)
  37. {
  38. abort();
  39. }
  40. void __cxa_deleted_virtual(void)
  41. {
  42. abort();
  43. }
  44. #if 0
  45. typedef struct {
  46. uint8_t guard;
  47. uint8_t ps;
  48. } guard_t;
  49. extern "C" int __cxa_guard_acquire(__guard* pg)
  50. {
  51. uint8_t ps = xt_rsil(15);
  52. if (reinterpret_cast<guard_t*>(pg)->guard) {
  53. xt_wsr_ps(ps);
  54. return 0;
  55. }
  56. reinterpret_cast<guard_t*>(pg)->ps = ps;
  57. return 1;
  58. }
  59. extern "C" void __cxa_guard_release(__guard* pg)
  60. {
  61. reinterpret_cast<guard_t*>(pg)->guard = 1;
  62. xt_wsr_ps(reinterpret_cast<guard_t*>(pg)->ps);
  63. }
  64. extern "C" void __cxa_guard_abort(__guard* pg)
  65. {
  66. xt_wsr_ps(reinterpret_cast<guard_t*>(pg)->ps);
  67. }
  68. #endif
  69. extern "C" void __cxa_throw_bad_array_new_length()
  70. {
  71. abort();
  72. }
  73. namespace std
  74. {
  75. void __throw_bad_function_call()
  76. {
  77. abort();
  78. }
  79. void __throw_length_error(char const*)
  80. {
  81. abort();
  82. }
  83. void __throw_bad_alloc()
  84. {
  85. abort();
  86. }
  87. void __throw_logic_error(const char* str)
  88. {
  89. abort();
  90. }
  91. void __throw_out_of_range(const char* str)
  92. {
  93. abort();
  94. }
  95. }