From b704f034f4dd30a23310618efbc547abdfeabd9e Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Mon, 25 Aug 2008 18:54:38 +0000 Subject: [PATCH] spu_mfcio.h (mfc_begin_critical_section): New function. * config/spu/spu_mfcio.h (mfc_begin_critical_section): New function. (mfc_end_critical_section): Likewise. From-SVN: r139570 --- gcc/ChangeLog | 5 +++++ gcc/config/spu/spu_mfcio.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bd4b67bfa23..f38c298043d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-08-25 Ulrich Weigand + + * config/spu/spu_mfcio.h (mfc_begin_critical_section): New function. + (mfc_end_critical_section): Likewise. + 2008-08-25 Ulrich Weigand * config/rs6000/rs6000.c (rs6000_handle_altivec_attribute): Propagate diff --git a/gcc/config/spu/spu_mfcio.h b/gcc/config/spu/spu_mfcio.h index 8423b9e8d5d..b0d3cd540f9 100644 --- a/gcc/config/spu/spu_mfcio.h +++ b/gcc/config/spu/spu_mfcio.h @@ -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 */