This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] s390: support for __sync_lock_test_and_set


On Fri, Sep 30, 2005 at 03:05:11PM +0200, Adrian Straetling wrote:
> Hi,
> 
> this patch enables support for __sync_lock_test_and_set for all integer
> modes.
> 
> Bootstrapped and regtested on s390 and s390x. The patch introduces two testcase failures:
> gcc.dg/ia64-sync-1.c
> gcc.dg/ia64-sync-2.c
> 
> These testcases check the memory location for the value 1 after invoking __sync_lock_test_and_set.
> However, the test_and_set instruction on s390(x) stores 0xff into the
> memory location, which should be ok since the documentation states that
> 'the true contents of the memory are implementation defined'.
> 
> As discussed with rth, the best solution should be to just check that the
> memory is non-null. I'll post that patch as well.

This patch makes the above testcases not to FAIL on s390(x).
Additionally it calls __sync_lock_test_and_set twice, too, checking the
return value of the second call to be 1, indicating that the lock was
actually set.

Testing on s390(x) and i686 shows no problems.

Ok for 4.1?

bye,
Adrian

2005-09-30  Adrian Straetling  <straetling@de.ibm.com>

	* testsuite/gcc.dg/ia64-sync-1.c: (main): Add code to hide the
	true memory contents of __sync_lock_test_and_set.
	* testsuite/gcc.dg/ia64-sync-1.c: (main): Likewise.
	(do_si,do_di): Call __sync_lock_test_and_set twice.

	
Index: gcc/testsuite/gcc.dg/ia64-sync-1.c
===================================================================
*** gcc/testsuite/gcc.dg/ia64-sync-1.c.orig	2005-09-13 19:21:25.000000000 +0200
--- gcc/testsuite/gcc.dg/ia64-sync-1.c	2005-09-16 10:15:10.194003958 +0200
*************** int main()
*** 62,67 ****
--- 62,74 ----
    do_noret_si ();
    do_noret_di ();
  
+  /* The memory location has to be non-zero after __sync_lock_test_and_set. The
+     exact content is implementation defined.  */
+   if (AI[2] != 0)
+     AI[2] = 1;
+   if (AL[2] != 0)
+     AL[2] = 1;
+   
    if (memcmp (AI, test_noret_si, sizeof(test_noret_si)))
      abort ();
    if (memcmp (AL, test_noret_di, sizeof(test_noret_di)))
Index: gcc/testsuite/gcc.dg/ia64-sync-2.c
===================================================================
*** gcc/testsuite/gcc.dg/ia64-sync-2.c.orig	2005-09-13 19:21:25.000000000 +0200
--- gcc/testsuite/gcc.dg/ia64-sync-2.c	2005-09-16 10:15:03.354003958 +0200
*************** do_si (void)
*** 27,32 ****
--- 27,34 ----
  
    if (__sync_lock_test_and_set(AI+2, 1) != 0)
      abort ();
+   if (__sync_lock_test_and_set(AI+2, 1) != 1)
+     abort ();
  
    if (__sync_fetch_and_add(AI+4, 1) != 0)
      abort ();
*************** do_di (void)
*** 77,82 ****
--- 79,86 ----
  
    if (__sync_lock_test_and_set(AL+2, 1) != 0)
      abort ();
+   if (__sync_lock_test_and_set(AL+2, 1) != 1)
+     abort ();
  
    if (__sync_fetch_and_add(AL+4, 1) != 0)
      abort ();
*************** int main()
*** 117,122 ****
--- 121,133 ----
    do_si ();
    do_di ();
  
+   /* The memory location has to be non-zero after __sync_lock_test_and_set. The
+      exact content is implementation defined.  */
+   if (AI[2] != 0)
+     AI[2] = 1; 
+   if (AL[2] != 0)
+     AL[2] = 1; 
+ 
    if (memcmp (AI, test_si, sizeof(test_si)))
      abort ();
    if (memcmp (AL, test_di, sizeof(test_di)))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]