typeinfo.cc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright 2010-2012 PathScale, Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * 1. Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. *
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
  15. * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  16. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  23. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  24. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include "typeinfo.h"
  27. #include <string.h>
  28. #include <stdlib.h>
  29. #include <stdio.h>
  30. #include "se_cdefs.h"
  31. SGX_ACCESS_VERSION(tstdcxx, 4)
  32. using std::type_info;
  33. type_info::~type_info() {}
  34. bool type_info::operator==(const type_info &other) const
  35. {
  36. return __type_name == other.__type_name;
  37. }
  38. bool type_info::operator!=(const type_info &other) const
  39. {
  40. return __type_name != other.__type_name;
  41. }
  42. bool type_info::before(const type_info &other) const
  43. {
  44. return __type_name < other.__type_name;
  45. }
  46. const char* type_info::name() const
  47. {
  48. return __type_name;
  49. }
  50. type_info::type_info (const type_info& rhs)
  51. {
  52. __type_name = rhs.__type_name;
  53. }
  54. type_info& type_info::operator= (const type_info& rhs)
  55. {
  56. return *new type_info(rhs);
  57. }
  58. __cxxabiv1::__fundamental_type_info::~__fundamental_type_info() {}
  59. __cxxabiv1::__array_type_info::~__array_type_info() {}
  60. __cxxabiv1::__function_type_info::~__function_type_info() {}
  61. __cxxabiv1::__enum_type_info::~__enum_type_info() {}
  62. __cxxabiv1::__class_type_info::~__class_type_info() {}
  63. __cxxabiv1::__si_class_type_info::~__si_class_type_info() {}
  64. __cxxabiv1::__vmi_class_type_info::~__vmi_class_type_info() {}
  65. __cxxabiv1::__pbase_type_info::~__pbase_type_info() {}
  66. __cxxabiv1::__pointer_type_info::~__pointer_type_info() {}
  67. __cxxabiv1::__pointer_to_member_type_info::~__pointer_to_member_type_info() {}
  68. #if 0
  69. // From libelftc
  70. extern "C" char *__cxa_demangle_gnu3(const char *);
  71. extern "C" char* __cxa_demangle(const char* mangled_name,
  72. char* buf,
  73. size_t* n,
  74. int* status)
  75. {
  76. // TODO: We should probably just be linking against libelf-tc, rather than
  77. // copying their code. This requires them to do an actual release,
  78. // however, and for our changes to be pushed upstream. We also need to
  79. // call a different demangling function here depending on the ABI (e.g.
  80. // ARM).
  81. char *demangled = __cxa_demangle_gnu3(mangled_name);
  82. if (NULL != demangled)
  83. {
  84. size_t len = strlen(demangled);
  85. buf = (char*)realloc(buf, len+1);
  86. if (0 != buf)
  87. {
  88. memcpy(buf, demangled, len);
  89. buf[len] = 0;
  90. if (n)
  91. {
  92. *n = len;
  93. }
  94. if (status)
  95. {
  96. *status = 0;
  97. }
  98. }
  99. else
  100. {
  101. if (status)
  102. {
  103. *status = -1;
  104. }
  105. }
  106. free(demangled);
  107. }
  108. else
  109. {
  110. if (status)
  111. {
  112. *status = -2;
  113. }
  114. return NULL;
  115. }
  116. return buf;
  117. }
  118. #endif