From patchwork Sat Oct 31 18:32:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 538676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id 5E97914138C for ; Sun, 1 Nov 2015 05:33:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=HvbwG1o6; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 63AC588773; Sat, 31 Oct 2015 18:33:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WqDWJwgwwVfU; Sat, 31 Oct 2015 18:33:12 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id A2AD6884A6; Sat, 31 Oct 2015 18:33:12 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 85B9B1C11FD for ; Sat, 31 Oct 2015 18:33:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7F91B88524 for ; Sat, 31 Oct 2015 18:33:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OMKgI-ctQwsS for ; Sat, 31 Oct 2015 18:33:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qk0-f180.google.com (mail-qk0-f180.google.com [209.85.220.180]) by whitealder.osuosl.org (Postfix) with ESMTPS id 8502187AF9 for ; Sat, 31 Oct 2015 18:33:09 +0000 (UTC) Received: by qkcl124 with SMTP id l124so40100559qkc.3 for ; Sat, 31 Oct 2015 11:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u6EU5wIqcbOa/z40LrT7HPfI5lRixnHPuqen7Mkg3KQ=; b=HvbwG1o6Y83e9nc8l8FYzlXulHd9P5BzEIiKbVIj3NLpmru8pQGNkR088vpmn4nk9S izj/v2i6KEk6g5xlb06Bgm6damss2PikS7RV/mWajYBWT6/YoDiNAXDXeZ3UPu55iWXp KuwKtM0SOKOtAyE43AVUczM/8g07Xi7XF/SF1hZOShlokarZUCb0bb7XWjokONJY2Kx9 8v0T6phIoeIt4yfPZK9wRJtwQVBYTXNeivqUrKXc/jFrhsQzy4kXZYdcY9nijtfjVnCU SUf6ABW1zRU41cppOjWSUN6w97YShd0vrbRG4iSK9/rbtUQZ5o68DmPtfaAB5mi7/rV/ Ph3Q== X-Received: by 10.55.79.145 with SMTP id d139mr18546405qkb.101.1446316388804; Sat, 31 Oct 2015 11:33:08 -0700 (PDT) Received: from khem-dvm-001.sys.comcast.net (a-96-119-177-31.sys.comcast.net. [96.119.177.31]) by smtp.gmail.com with ESMTPSA id n48sm4817436qgd.35.2015.10.31.11.33.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Oct 2015 11:33:08 -0700 (PDT) From: Khem Raj To: uclibc@uclibc.org Subject: [PATCH 2/9] Add implementation for copysignl for ppc Date: Sat, 31 Oct 2015 18:32:54 +0000 Message-Id: <1446316381-5070-2-git-send-email-raj.khem@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1446316381-5070-1-git-send-email-raj.khem@gmail.com> References: <1446316381-5070-1-git-send-email-raj.khem@gmail.com> X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" Signed-off-by: Khem Raj --- libc/sysdeps/linux/powerpc/Makefile.arch | 2 +- libc/sysdeps/linux/powerpc/copysignl.c | 89 ++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 libc/sysdeps/linux/powerpc/copysignl.c diff --git a/libc/sysdeps/linux/powerpc/Makefile.arch b/libc/sysdeps/linux/powerpc/Makefile.arch index 4fbcb11..7c09c87 100644 --- a/libc/sysdeps/linux/powerpc/Makefile.arch +++ b/libc/sysdeps/linux/powerpc/Makefile.arch @@ -5,7 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -CSRC-y := __syscall_error.c ioctl.c +CSRC-y := __syscall_error.c ioctl.c copysignl.c SSRC-y := \ __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \ diff --git a/libc/sysdeps/linux/powerpc/copysignl.c b/libc/sysdeps/linux/powerpc/copysignl.c new file mode 100644 index 0000000..000f653 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/copysignl.c @@ -0,0 +1,89 @@ +/* s_copysignl.c -- long double version of s_copysign.c. + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * copysignl(long double x, long double y) + * copysignl(x,y) returns a value with the magnitude of x and + * with the sign bit of y. + */ + +#include +#include + +#if __FLOAT_WORD_ORDER == BIG_ENDIAN + +typedef union +{ + long double value; + struct + { + int sign_exponent:16; + unsigned int empty:16; + uint32_t msw; + uint32_t lsw; + } parts; +} ieee_long_double_shape_type; + +#endif + +#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN + +typedef union +{ + long double value; + struct + { + uint32_t lsw; + uint32_t msw; + int sign_exponent:16; + unsigned int empty:16; + } parts; +} ieee_long_double_shape_type; + +#endif + +/* Get int from the exponent of a long double. */ + +#define GET_LDOUBLE_EXP(exp,d) \ +do { \ + ieee_long_double_shape_type ge_u; \ + ge_u.value = (d); \ + (exp) = ge_u.parts.sign_exponent; \ +} while (0) + +/* Set exponent of a long double from an int. */ + +#define SET_LDOUBLE_EXP(d,exp) \ +do { \ + ieee_long_double_shape_type se_u; \ + se_u.value = (d); \ + se_u.parts.sign_exponent = (exp); \ + (d) = se_u.value; \ +} while (0) + +long double copysignl(long double x, long double y); +libc_hidden_proto(copysignl); + +long double copysignl(long double x, long double y) +{ + uint32_t es1,es2; + GET_LDOUBLE_EXP(es1,x); + GET_LDOUBLE_EXP(es2,y); + SET_LDOUBLE_EXP(x,(es1&0x7fff)|(es2&0x8000)); + return x; +} + +libc_hidden_def(copysignl);