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: Does __sync_bool_compare_and_swap on ia64 have wrong return type?


On Wed, Apr 23, 2003 at 04:50:02PM -0700, Richard Henderson wrote:
> On Wed, Apr 23, 2003 at 04:11:18PM -0700, H. J. Lu wrote:
> > +  : (int) __sync_bool_compare_and_swap_di(...)
> 
> It'd be nicer to get the return type fixed internally...
> 
> 

This seems to work for me.


H.J.
---
2003-04-24  H.J. Lu <hjl at gnu dot org>

	* config/ia64/ia64.c (ia64_init_builtins): Add si_ftype_pdi_di_di
	for __sync_bool_compare_and_swap_di for int return type.

	* config/ia64/ia64intrin.h (__sync_bool_compare_and_swap_di):
	Change return type to int.
	(__sync_bool_compare_and_swap): Likewise.

--- gcc/config/ia64/ia64.c.type	2003-04-18 07:44:35.000000000 -0700
+++ gcc/config/ia64/ia64.c	2003-04-24 09:12:02.000000000 -0700
@@ -7730,11 +7730,16 @@ ia64_init_builtins ()
 				psi_type_node, integer_type_node,
 				integer_type_node, NULL_TREE);
 
-  /* __sync_val_compare_and_swap_di, __sync_bool_compare_and_swap_di */
+  /* __sync_val_compare_and_swap_di */
   tree di_ftype_pdi_di_di
     = build_function_type_list (long_integer_type_node,
 				pdi_type_node, long_integer_type_node,
 				long_integer_type_node, NULL_TREE);
+  /* __sync_bool_compare_and_swap_di */
+  tree si_ftype_pdi_di_di
+    = build_function_type_list (integer_type_node,
+				pdi_type_node, long_integer_type_node,
+				long_integer_type_node, NULL_TREE);
   /* __sync_synchronize */
   tree void_ftype_void
     = build_function_type (void_type_node, void_list_node);
@@ -7767,7 +7772,7 @@ ia64_init_builtins ()
 	       IA64_BUILTIN_VAL_COMPARE_AND_SWAP_DI);
   def_builtin ("__sync_bool_compare_and_swap_si", si_ftype_psi_si_si,
 	       IA64_BUILTIN_BOOL_COMPARE_AND_SWAP_SI);
-  def_builtin ("__sync_bool_compare_and_swap_di", di_ftype_pdi_di_di,
+  def_builtin ("__sync_bool_compare_and_swap_di", si_ftype_pdi_di_di,
 	       IA64_BUILTIN_BOOL_COMPARE_AND_SWAP_DI);
 
   def_builtin ("__sync_synchronize", void_ftype_void,
--- gcc/config/ia64/ia64intrin.h.type	2002-01-20 18:24:02.000000000 -0800
+++ gcc/config/ia64/ia64intrin.h	2003-04-24 08:58:39.000000000 -0700
@@ -19,13 +19,11 @@ extern long __sync_val_compare_and_swap_
     __sync_val_compare_and_swap_di((long *)(PTR),(long)(OLD),(long)(NEW)))
 
 extern int __sync_bool_compare_and_swap_si (int *, int, int);
-extern long __sync_bool_compare_and_swap_di (long *, long, long);
+extern int __sync_bool_compare_and_swap_di (long *, long, long);
 #define __sync_bool_compare_and_swap(PTR, OLD, NEW)			\
  ((sizeof (*(PTR)) == sizeof(int))					\
-  ? (__typeof__(*(PTR)))						\
-    __sync_bool_compare_and_swap_si((int *)(PTR),(int)(OLD),(int)(NEW))	\
-  : (__typeof__(*(PTR)))						\
-    __sync_bool_compare_and_swap_di((long *)(PTR),(long)(OLD),(long)(NEW)))
+  ? __sync_bool_compare_and_swap_si((int *)(PTR),(int)(OLD),(int)(NEW))	\
+  : __sync_bool_compare_and_swap_di((long *)(PTR),(long)(OLD),(long)(NEW)))
 
 extern void __sync_lock_release_si (int *);
 extern void __sync_lock_release_di (long *);


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