From patchwork Fri Jan 23 22:04:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 4784 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Received: (qmail 4826 invoked by alias); 23 Jan 2015 22:04:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 4815 invoked by uid 89); 23 Jan 2015 22:04:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e24smtp03.br.ibm.com Message-ID: <54C2C558.2050304@linux.vnet.ibm.com> Date: Fri, 23 Jan 2015 20:04:08 -0200 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "GNU C. Library" Subject: [PATCH] powerpc: Fix inline feraiseexcept, feclearexcept macros X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15012322-0025-0000-0000-000002E3443D This patch fixes the inline feraiseexcept and feclearexcept macros for powerpc by casting the input argument to integer before operation on it. It fixes BZ#17776. Tested on powerpc64 and powerp32, no regression found. --- [BZ #17776] * sysdeps/powerpc/bits/fenvinline.h (feraiseexcept): Convert input to integer before bitwise and assembly operations. (feclearexcept): Likewise. -- diff --git a/NEWS b/NEWS index ed15176..b62088c 100644 --- a/NEWS +++ b/NEWS @@ -17,8 +17,8 @@ Version 2.21 17608, 17616, 17625, 17630, 17633, 17634, 17635, 17647, 17653, 17657, 17658, 17664, 17665, 17668, 17682, 17702, 17717, 17719, 17722, 17723, 17724, 17725, 17732, 17733, 17744, 17745, 17746, 17747, 17748, 17775, - 17777, 17780, 17781, 17782, 17791, 17793, 17796, 17797, 17803, 17806, - 17834, 17844. + 17776, 17777, 17780, 17781, 17782, 17791, 17793, 17796, 17797, 17803, + 17806, 17834, 17844. * A new semaphore algorithm has been implemented in generic C code for all machines. Previous custom assembly implementations of semaphore were diff --git a/sysdeps/powerpc/bits/fenvinline.h b/sysdeps/powerpc/bits/fenvinline.h index 35c2114..999c6b2 100644 --- a/sysdeps/powerpc/bits/fenvinline.h +++ b/sysdeps/powerpc/bits/fenvinline.h @@ -34,29 +34,41 @@ /* Inline definition for feraiseexcept. */ # define feraiseexcept(__excepts) \ - ((__builtin_constant_p (__excepts) \ - && ((__excepts) & ((__excepts)-1)) == 0 \ - && (__excepts) != FE_INVALID) \ - ? ((__excepts) != 0 \ - ? (__extension__ ({ __asm__ __volatile__ \ - ("mtfsb1 %s0" \ - : : "i#*X"(__builtin_ffs (__excepts))); \ - 0; })) \ - : 0) \ - : (feraiseexcept) (__excepts)) + (__extension__ ({ \ + int __e = __excepts; \ + int __ret; \ + if (__builtin_constant_p (__e) \ + && ((__e & (__e-1)) == 0) \ + && (__e != FE_INVALID)) \ + { \ + if (__e != 0) \ + __asm__ __volatile__ ("mtfsb1 %s0" \ + : : "i#*X" (__builtin_ffs (__e))); \ + __ret = 0; \ + } \ + else \ + __ret = feraiseexcept (__e); \ + __ret; \ + })) /* Inline definition for feclearexcept. */ # define feclearexcept(__excepts) \ - ((__builtin_constant_p (__excepts) \ - && ((__excepts) & ((__excepts)-1)) == 0 \ - && (__excepts) != FE_INVALID) \ - ? ((__excepts) != 0 \ - ? (__extension__ ({ __asm__ __volatile__ \ - ("mtfsb0 %s0" \ - : : "i#*X"(__builtin_ffs (__excepts))); \ - 0; })) \ - : 0) \ - : (feclearexcept) (__excepts)) + (__extension__ ({ \ + int __e = __excepts; \ + int __ret; \ + if (__builtin_constant_p (__e) \ + && ((__e & (__e-1)) == 0) \ + && (__e != FE_INVALID)) \ + { \ + if (__e != 0) \ + __asm__ __volatile__ ("mtfsb0 %s0" \ + : : "i#*X" (__builtin_ffs (__e))); \ + __ret = 0; \ + } \ + else \ + __ret = feclearexcept (__e); \ + __ret; \ + })) # endif /* !__NO_MATH_INLINES. */