public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] libitm: Fix recent changes to allocations log.
@ 2015-11-22 21:33 Torvald Riegel
  0 siblings, 0 replies; only message in thread
From: Torvald Riegel @ 2015-11-22 21:33 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 271 bytes --]

This fixes an oversight in the recent changes to the allocations log for
supporting sized delete.

Tested libitm on x86_64-linux.  COmmitted as obvious.

        libitm/
        * libitm_i.h (gtm_alloc_action): Remove union.
        * testsuite/libitm.c/alloc-1.c: New.


[-- Attachment #2: fixsizeddelete.patch --]
[-- Type: text/x-patch, Size: 1557 bytes --]

commit 74c5fd924fe3e8d6bececce209d00bf0523bb4dc
Author: Torvald Riegel <triegel@redhat.com>
Date:   Sun Nov 22 21:54:24 2015 +0100

    libitm: Fix recent changes to allocations log.
    
    	libitm/
    	* libitm_i.h (gtm_alloc_action): Remove union.
    	* testsuite/libitm.c/alloc-1.c: New.

diff --git a/libitm/libitm_i.h b/libitm/libitm_i.h
index f01a1ab..4b72348 100644
--- a/libitm/libitm_i.h
+++ b/libitm/libitm_i.h
@@ -106,12 +106,10 @@ namespace GTM HIDDEN {
 // the template used inside gtm_thread can instantiate.
 struct gtm_alloc_action
 {
-  // Iff free_fn_sz is nonzero, it must be used instead of free_fn.
-  union
-  {
-    void (*free_fn)(void *);
-    void (*free_fn_sz)(void *, size_t);
-  };
+  // Iff free_fn_sz is nonzero, it must be used instead of free_fn, and vice
+  // versa.
+  void (*free_fn)(void *);
+  void (*free_fn_sz)(void *, size_t);
   size_t sz;
   // If true, this is an allocation; we discard the log entry on outermost
   // commit, and deallocate on abort.  If false, this is a deallocation and
diff --git a/libitm/testsuite/libitm.c/alloc-1.c b/libitm/testsuite/libitm.c/alloc-1.c
new file mode 100644
index 0000000..49faab5
--- /dev/null
+++ b/libitm/testsuite/libitm.c/alloc-1.c
@@ -0,0 +1,17 @@
+// Test that rolling back allocations works.
+#include <stdlib.h>
+
+void __attribute((transaction_pure,noinline)) dont_optimize(void* p)
+{
+  *(volatile char *) p;
+}
+
+int main()
+{
+  __transaction_atomic {
+    void *p = malloc (23);
+    dont_optimize (p);
+    __transaction_cancel;
+  }
+  return 0;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-22 20:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-22 21:33 [COMMITTED] libitm: Fix recent changes to allocations log Torvald Riegel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).