public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, SPU] Add interrupt-safe critical section functions to spu_mfcio.h
@ 2008-08-22 17:13 Ulrich Weigand
  2008-08-22 20:59 ` trevor_smigiel
  0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Weigand @ 2008-08-22 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: trevor_smigiel, andrew_pinski

Hello,

this patch to spu_mfcio.h provides the functions to support interrupt-safe
critical sections as defined in TWG RFC00130-2 (will be included in the
upcoming version 2.6 of the C/C++ Language Extensions for Cell/B.E. 
specification).

OK for mainline and 4.3?

Bye,
Ulrich


ChangeLog:

	* config/spu/spu_mfcio.h (mfc_begin_critical_section): New function.
	(mfc_end_critical_section): Likewise.


--- gcc-4.3.1/gcc/config/spu/spu_mfcio.h.orig	2008-08-22 16:43:50.000000000 +0200
+++ gcc-4.3.1/gcc/config/spu/spu_mfcio.h	2008-08-22 16:43:56.000000000 +0200
@@ -289,6 +289,34 @@ typedef struct mfc_list_element {
 #define spu_write_srr0(srr0)          spu_writech(SPU_WrSRR0,srr0)
 #define spu_read_srr0()               spu_readch(SPU_RdSRR0)
 
+/* Interrupt-Safe Critical Sections */
+
+static __inline__ unsigned int mfc_begin_critical_section (void)
+  __attribute__ ((__always_inline__));
+
+static __inline__ unsigned int
+mfc_begin_critical_section (void)
+{
+#ifdef SPU_MFCIO_INTERRUPT_SAFE
+  unsigned int __status = spu_read_machine_status ();
+  spu_idisable ();
+  return __status;
+#else
+  return 0;
+#endif
+}
+
+static __inline__ void mfc_end_critical_section (unsigned int)
+  __attribute__ ((__always_inline__));
+
+static __inline__ void
+mfc_end_critical_section (unsigned int __status __attribute__ ((__unused__)))
+{
+#ifdef SPU_MFCIO_INTERRUPT_SAFE
+  if (__status & 1)
+    spu_ienable ();
+#endif
+}
 
 /* MFC Tag Manager */
 
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, SPU] Add interrupt-safe critical section functions to  spu_mfcio.h
  2008-08-22 17:13 [PATCH, SPU] Add interrupt-safe critical section functions to spu_mfcio.h Ulrich Weigand
@ 2008-08-22 20:59 ` trevor_smigiel
  0 siblings, 0 replies; 2+ messages in thread
From: trevor_smigiel @ 2008-08-22 20:59 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gcc-patches, andrew_pinski

Ok for both.

Trevor

* Ulrich Weigand <uweigand@de.ibm.com> [2008-08-22 09:45]:
> Hello,
> 
> this patch to spu_mfcio.h provides the functions to support interrupt-safe
> critical sections as defined in TWG RFC00130-2 (will be included in the
> upcoming version 2.6 of the C/C++ Language Extensions for Cell/B.E. 
> specification).
> 
> OK for mainline and 4.3?
> 
> Bye,
> Ulrich
> 
> 
> ChangeLog:
> 
> 	* config/spu/spu_mfcio.h (mfc_begin_critical_section): New function.
> 	(mfc_end_critical_section): Likewise.
> 
> 
> --- gcc-4.3.1/gcc/config/spu/spu_mfcio.h.orig	2008-08-22 16:43:50.000000000 +0200
> +++ gcc-4.3.1/gcc/config/spu/spu_mfcio.h	2008-08-22 16:43:56.000000000 +0200
> @@ -289,6 +289,34 @@ typedef struct mfc_list_element {
>  #define spu_write_srr0(srr0)          spu_writech(SPU_WrSRR0,srr0)
>  #define spu_read_srr0()               spu_readch(SPU_RdSRR0)
>  
> +/* Interrupt-Safe Critical Sections */
> +
> +static __inline__ unsigned int mfc_begin_critical_section (void)
> +  __attribute__ ((__always_inline__));
> +
> +static __inline__ unsigned int
> +mfc_begin_critical_section (void)
> +{
> +#ifdef SPU_MFCIO_INTERRUPT_SAFE
> +  unsigned int __status = spu_read_machine_status ();
> +  spu_idisable ();
> +  return __status;
> +#else
> +  return 0;
> +#endif
> +}
> +
> +static __inline__ void mfc_end_critical_section (unsigned int)
> +  __attribute__ ((__always_inline__));
> +
> +static __inline__ void
> +mfc_end_critical_section (unsigned int __status __attribute__ ((__unused__)))
> +{
> +#ifdef SPU_MFCIO_INTERRUPT_SAFE
> +  if (__status & 1)
> +    spu_ienable ();
> +#endif
> +}
>  
>  /* MFC Tag Manager */
>  
> -- 
>   Dr. Ulrich Weigand
>   GNU Toolchain for Linux on System z and Cell BE
>   Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-22 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-22 17:13 [PATCH, SPU] Add interrupt-safe critical section functions to spu_mfcio.h Ulrich Weigand
2008-08-22 20:59 ` trevor_smigiel

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).