query.cc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright (C) 2008-2022 Free Software Foundation, Inc.
  2. Contributed by Richard Henderson <rth@redhat.com>.
  3. This file is part of the GNU Transactional Memory Library (libitm).
  4. Libitm is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. #include "libitm_i.h"
  20. using namespace GTM;
  21. int ITM_REGPARM
  22. _ITM_versionCompatible (int version)
  23. {
  24. return version == _ITM_VERSION_NO;
  25. }
  26. const char * ITM_REGPARM
  27. _ITM_libraryVersion (void)
  28. {
  29. return "GNU libitm " _ITM_VERSION;
  30. }
  31. _ITM_howExecuting ITM_REGPARM
  32. _ITM_inTransaction (void)
  33. {
  34. #if defined(USE_HTM_FASTPATH)
  35. // If we use the HTM fastpath, we cannot reliably detect whether we are
  36. // in a transaction because this function can be called outside of
  37. // a transaction and thus we can't deduce this by looking at just the serial
  38. // lock. This function isn't used in practice currently, so the easiest
  39. // way to handle it is to just abort.
  40. if (gtm_thread::serial_lock.get_htm_fastpath() && htm_transaction_active())
  41. htm_abort();
  42. #endif
  43. struct gtm_thread *tx = gtm_thr();
  44. if (tx && (tx->nesting > 0))
  45. {
  46. if (tx->state & gtm_thread::STATE_IRREVOCABLE)
  47. return inIrrevocableTransaction;
  48. else
  49. return inRetryableTransaction;
  50. }
  51. return outsideTransaction;
  52. }
  53. _ITM_transactionId_t ITM_REGPARM
  54. _ITM_getTransactionId (void)
  55. {
  56. #if defined(USE_HTM_FASTPATH)
  57. // See ITM_inTransaction.
  58. if (gtm_thread::serial_lock.get_htm_fastpath() && htm_transaction_active())
  59. htm_abort();
  60. #endif
  61. struct gtm_thread *tx = gtm_thr();
  62. return (tx && (tx->nesting > 0)) ? tx->id : _ITM_noTransactionId;
  63. }
  64. void ITM_REGPARM ITM_NORETURN
  65. _ITM_error (const _ITM_srcLocation * loc UNUSED, int errorCode UNUSED)
  66. {
  67. abort ();
  68. }