[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    [committed] Remove long long support from linux-atomic.c
From:       John David Anglin <dave.anglin () bell ! net>
Date:       2015-01-31 20:13:24
Message-ID: BLU436-SMTP554D8B458E3F2F21560663973E0 () phx ! gbl
[Download RAW message or body]

The attached patch removes long long support from config/pa/linux-atomic.c =
and corrects some issues
found in trying to get the long long support working.

There are a number of issues.  On the 4.9 branch, webkitgtk fails to build =
with the current long long
support because the __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* and __GCC_ATOMIC_*_L=
OCK_FREE
defines are missing because of the libcall implementation.  These could be =
provided by defining
HAVE_sync_compare_and_swapqi, etc, but then we std:future builds and we pro=
bable need an
ABI bump for libstdc++.  It also turns out we don't initialize the sync bui=
ltins for double word size.
The webkitgtk build only conflicts with the long long support.

Secondly, when the HAVE defines and initialization are added, a middle-end =
wrong code bug is exposed for
the long long case.  I'm still researching this issue.

Finally, atomic long long loads and stores have to be done using the floati=
ng-point co-processor in the
32-bit parisc runtime, so maybe we are better off without long long support.

Tested on hppa-unknown-linux-gnu.  Committed to trunk and 4.9.

Dave
--
John David Anglin	dave.anglin@bell.net



["linux-atomic.c.d.txt" (linux-atomic.c.d.txt)]

2015-01-31  John David Anglin  <danglin@gcc.gnu.org>

	* config/pa/linux-atomic.c (__kernel_cmpxchg2): Change declaration of
	oldval and newval to const void *.  Fix typo.
	(FETCH_AND_OP_2): Use __atomic_load_n to load value.
	(FETCH_AND_OP_WORD): Likewise.
	(OP_AND_FETCH_WORD): Likewise.
	(COMPARE_AND_SWAP_2): Likewise.
	(__sync_val_compare_and_swap_4): Likewise.
	(__sync_lock_test_and_set_4): Likewise.
	(SYNC_LOCK_RELEASE_2): Likewise.
	Remove support for long long atomic operations.

Index: config/pa/linux-atomic.c
===================================================================
--- config/pa/linux-atomic.c	(revision 220301)
+++ config/pa/linux-atomic.c	(working copy)
@@ -73,7 +73,8 @@
 }
 
 static inline long
-__kernel_cmpxchg2 (void * oldval, void * newval, void *mem, int val_size)
+__kernel_cmpxchg2 (const void *oldval, const void *newval, void *mem,
+		   int val_size)
 {
   register unsigned long lws_mem asm("r26") = (unsigned long) (mem);
   register long lws_ret   asm("r28");
@@ -90,7 +91,7 @@
   if (__builtin_expect (lws_errno == -EFAULT || lws_errno == -ENOSYS, 0))
     __builtin_trap ();
 
-  /* If the kernel LWS call fails, retrun EBUSY */
+  /* If the kernel LWS call fails, return EBUSY */
   if (!lws_errno && lws_ret)
     lws_errno = -EBUSY;
 
@@ -113,7 +114,7 @@
     int failure;							\
 									\
     do {								\
-      tmp = *ptr;							\
+      tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);			\
       newval = PFX_OP (tmp INF_OP val);					\
       failure = __kernel_cmpxchg2 (&tmp, &newval, ptr, INDEX);		\
     } while (failure != 0);						\
@@ -121,13 +122,6 @@
     return tmp;								\
   }
 
-FETCH_AND_OP_2 (add,   , +, long long, 8, 3)
-FETCH_AND_OP_2 (sub,   , -, long long, 8, 3)
-FETCH_AND_OP_2 (or,    , |, long long, 8, 3)
-FETCH_AND_OP_2 (and,   , &, long long, 8, 3)
-FETCH_AND_OP_2 (xor,   , ^, long long, 8, 3)
-FETCH_AND_OP_2 (nand, ~, &, long long, 8, 3)
-
 FETCH_AND_OP_2 (add,   , +, short, 2, 1)
 FETCH_AND_OP_2 (sub,   , -, short, 2, 1)
 FETCH_AND_OP_2 (or,    , |, short, 2, 1)
@@ -150,7 +144,7 @@
     int failure;							\
 									\
     do {								\
-      tmp = *ptr;							\
+      tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);			\
       newval = PFX_OP (tmp INF_OP val);					\
       failure = __kernel_cmpxchg2 (&tmp, &newval, ptr, INDEX);		\
     } while (failure != 0);						\
@@ -158,13 +152,6 @@
     return PFX_OP (tmp INF_OP val);					\
   }
 
-OP_AND_FETCH_2 (add,   , +, long long, 8, 3)
-OP_AND_FETCH_2 (sub,   , -, long long, 8, 3)
-OP_AND_FETCH_2 (or,    , |, long long, 8, 3)
-OP_AND_FETCH_2 (and,   , &, long long, 8, 3)
-OP_AND_FETCH_2 (xor,   , ^, long long, 8, 3)
-OP_AND_FETCH_2 (nand, ~, &, long long, 8, 3)
-
 OP_AND_FETCH_2 (add,   , +, short, 2, 1)
 OP_AND_FETCH_2 (sub,   , -, short, 2, 1)
 OP_AND_FETCH_2 (or,    , |, short, 2, 1)
@@ -186,7 +173,7 @@
     int failure, tmp;							\
 									\
     do {								\
-      tmp = *ptr;							\
+      tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);			\
       failure = __kernel_cmpxchg (tmp, PFX_OP (tmp INF_OP val), ptr);	\
     } while (failure != 0);						\
 									\
@@ -207,7 +194,7 @@
     int tmp, failure;							\
 									\
     do {								\
-      tmp = *ptr;							\
+      tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);			\
       failure = __kernel_cmpxchg (tmp, PFX_OP (tmp INF_OP val), ptr);	\
     } while (failure != 0);						\
 									\
@@ -233,7 +220,7 @@
 									\
     while (1)								\
       {									\
-	actual_oldval = *ptr;						\
+	actual_oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);	\
 									\
 	if (__builtin_expect (oldval != actual_oldval, 0))		\
 	  return actual_oldval;						\
@@ -242,7 +229,7 @@
 									\
 	if (__builtin_expect (!fail, 1))				\
 	  return actual_oldval;						\
-    }									\
+      }									\
   }									\
 									\
   bool HIDDEN								\
@@ -253,7 +240,6 @@
     return (failure != 0);						\
   }
 
-COMPARE_AND_SWAP_2 (long long, 8, 3)
 COMPARE_AND_SWAP_2 (short, 2, 1)
 COMPARE_AND_SWAP_2 (char, 1, 0)
 
@@ -264,7 +250,7 @@
     
   while (1)
     {
-      actual_oldval = *ptr;
+      actual_oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);
 
       if (__builtin_expect (oldval != actual_oldval, 0))
 	return actual_oldval;
@@ -291,7 +277,7 @@
     int failure;							\
 									\
     do {								\
-      oldval = *ptr;							\
+      oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);			\
       failure = __kernel_cmpxchg2 (&oldval, &val, ptr, INDEX);		\
     } while (failure != 0);						\
 									\
@@ -298,7 +284,6 @@
     return oldval;							\
   }
 
-SYNC_LOCK_TEST_AND_SET_2 (long long, 8, 3)
 SYNC_LOCK_TEST_AND_SET_2 (short, 2, 1)
 SYNC_LOCK_TEST_AND_SET_2 (signed char, 1, 0)
 
@@ -308,7 +293,7 @@
   int failure, oldval;
 
   do {
-    oldval = *ptr;
+    oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);
     failure = __kernel_cmpxchg (oldval, val, ptr);
   } while (failure != 0);
 
@@ -322,12 +307,11 @@
     TYPE failure, oldval, zero = 0;				\
 								\
     do {							\
-      oldval = *ptr;						\
+      oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);		\
       failure = __kernel_cmpxchg2 (&oldval, &zero, ptr, INDEX);	\
     } while (failure != 0);					\
   }
 
-SYNC_LOCK_RELEASE_2 (long long, 8, 3)
 SYNC_LOCK_RELEASE_2 (short, 2, 1)
 SYNC_LOCK_RELEASE_2 (signed char, 1, 0)
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic