Daily bump.
[gcc.git] / libitm / dispatch.h
index dbf05e4da37271674602e5a993b58b91cc949048..4b5acd71f4f3ad88c61906d5cf7639b6a1f72742 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
    Contributed by Torvald Riegel <triegel@redhat.com>.
 
    This file is part of the GNU Transactional Memory Library (libitm).
 virtual void memtransfer(void *dst, const void* src, size_t size,    \
     bool may_overlap, ls_modifier dst_mod, ls_modifier src_mod)       \
 {                                                                     \
-  memtransfer_static(dst, src, size, may_overlap, dst_mod, src_mod); \
+  if (size > 0)                                                       \
+    memtransfer_static(dst, src, size, may_overlap, dst_mod, src_mod); \
 }                                                                     \
 virtual void memset(void *dst, int c, size_t size, ls_modifier mod)  \
 {                                                                     \
-  memset_static(dst, c, size, mod);                                  \
+  if (size > 0)                                                       \
+    memset_static(dst, c, size, mod);                                 \
 }
 
 #define CREATE_DISPATCH_METHODS_MEM_PV()  \
@@ -245,6 +247,12 @@ struct method_group
   // Stop using any method from this group for now. This can be used to
   // destruct meta data as soon as this method group is not used anymore.
   virtual void fini() = 0;
+  // This can be overriden to implement more light-weight re-initialization.
+  virtual void reinit()
+  {
+    fini();
+    init();
+  }
 };
 
 
@@ -283,6 +291,10 @@ public:
   // Rolls back a transaction. Called on abort or after trycommit() returned
   // false.
   virtual void rollback(gtm_transaction_cp *cp = 0) = 0;
+  // Returns true iff the snapshot is most recent, which will be the case if
+  // this transaction cannot be the reason why other transactions cannot
+  // ensure privatization safety.
+  virtual bool snapshot_most_recent() = 0;
 
   // Return an alternative method that is compatible with the current
   // method but supports closed nesting. Return zero if there is none.
@@ -290,6 +302,10 @@ public:
   // method on begin of a nested transaction without committing or restarting
   // the parent method.
   virtual abi_dispatch* closed_nesting_alternative() { return 0; }
+  // Returns true iff this method group supports the current situation.
+  // NUMBER_OF_THREADS is the current number of threads that might execute
+  // transactions.
+  virtual bool supports(unsigned number_of_threads) { return true; }
 
   bool read_only () const { return m_read_only; }
   bool write_through() const { return m_write_through; }
@@ -299,6 +315,9 @@ public:
   }
   // Returns true iff this TM method supports closed nesting.
   bool closed_nesting() const { return m_closed_nesting; }
+  // Returns STATE_SERIAL or STATE_SERIAL | STATE_IRREVOCABLE iff the TM
+  // method only works for serial-mode transactions.
+  uint32_t requires_serial() const { return m_requires_serial; }
   method_group* get_method_group() const { return m_method_group; }
 
   static void *operator new(size_t s) { return xmalloc (s); }
@@ -320,12 +339,14 @@ protected:
   const bool m_write_through;
   const bool m_can_run_uninstrumented_code;
   const bool m_closed_nesting;
+  const uint32_t m_requires_serial;
   method_group* const m_method_group;
   abi_dispatch(bool ro, bool wt, bool uninstrumented, bool closed_nesting,
-      method_group* mg) :
+      uint32_t requires_serial, method_group* mg) :
     m_read_only(ro), m_write_through(wt),
     m_can_run_uninstrumented_code(uninstrumented),
-    m_closed_nesting(closed_nesting), m_method_group(mg)
+    m_closed_nesting(closed_nesting), m_requires_serial(requires_serial),
+    m_method_group(mg)
   { }
 };