From owner-freebsd-arm@FreeBSD.ORG Fri Dec 19 18:45:52 2008 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6233F1065676 for ; Fri, 19 Dec 2008 18:45:52 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout011.mac.com (asmtpout011.mac.com [17.148.16.86]) by mx1.freebsd.org (Postfix) with ESMTP id 4DEF38FC12 for ; Fri, 19 Dec 2008 18:45:52 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_6aRa5zsxN2/Qv99f8U55DA)" Received: from mohan-pc.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp011.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0KC5008CM03OS630@asmtp011.mac.com> for arm@freebsd.org; Fri, 19 Dec 2008 10:45:25 -0800 (PST) Message-id: <4CEE2ADA-1827-463B-8174-C2204C05442D@mac.com> From: Marcel Moolenaar To: arm@freebsd.org Date: Fri, 19 Dec 2008 10:45:23 -0800 X-Mailer: Apple Mail (2.930.3) Cc: Subject: Support for FPA float on LE ARM X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Dec 2008 18:45:52 -0000 --Boundary_(ID_6aRa5zsxN2/Qv99f8U55DA) Content-type: text/plain; charset=US-ASCII; format=flowed Content-transfer-encoding: 7BIT All, As mentioned before, we (read: Juniper) need support for FPA floating-point. FPA is like VFP, except that it's always stored in big-endian. For ARMEB this obviously is exactly the same as VFP, but for ARMEL this needs a tweak. See attached patch. Does this make sense? -- Marcel Moolenaar xcllnt@mac.com --Boundary_(ID_6aRa5zsxN2/Qv99f8U55DA) Content-type: application/octet-stream; x-unix-mode=0644; name=fpa-fbsd.diff Content-transfer-encoding: 7bit Content-disposition: attachment; filename=fpa-fbsd.diff Index: lib/msun/src/math_private.h =================================================================== --- lib/msun/src/math_private.h (revision 186331) +++ lib/msun/src/math_private.h (working copy) @@ -38,8 +38,18 @@ * ints. */ -#if BYTE_ORDER == BIG_ENDIAN +#ifdef __arm__ +#if defined(__VFP_FP__) || defined(__ARMEB__) +#define IEEE_WORD_ORDER BYTE_ORDER +#else +#define IEEE_WORD_ORDER BIG_ENDIAN +#endif +#else /* __arm__ */ +#define IEEE_WORD_ORDER BYTE_ORDER +#endif +#if IEEE_WORD_ORDER == BIG_ENDIAN + typedef union { double value; @@ -52,7 +62,7 @@ #endif -#if BYTE_ORDER == LITTLE_ENDIAN +#if IEEE_WORD_ORDER == LITTLE_ENDIAN typedef union { Index: lib/libc/arm/_fpmath.h =================================================================== --- lib/libc/arm/_fpmath.h (revision 186331) +++ lib/libc/arm/_fpmath.h (working copy) @@ -26,15 +26,26 @@ * $FreeBSD$ */ +#if defined(__VFP_FP__) || defined(__ARMEB__) +#define _IEEE_WORD_ORDER _BYTE_ORDER +#else +#define _IEEE_WORD_ORDER _BIG_ENDIAN +#endif + union IEEEl2bits { long double e; struct { -#ifndef __ARMEB__ +#if _BYTE_ORDER == _LITTLE_ENDIAN +#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN unsigned int manl :32; +#endif unsigned int manh :20; unsigned int exp :11; unsigned int sign :1; -#else +#if _IEEE_WORD_ORDER == _BIG_ENDIAN + unsigned int manl :32; +#endif +#else /* _BYTE_ORDER == _LITTLE_ENDIAN */ unsigned int sign :1; unsigned int exp :11; unsigned int manh :20; Index: lib/libc/arm/arith.h =================================================================== --- lib/libc/arm/arith.h (revision 186331) +++ lib/libc/arm/arith.h (working copy) @@ -11,7 +11,7 @@ * architecture. See contrib/gdtoa/gdtoaimp.h for details. */ -#ifndef __ARMEB__ +#if !defined(__ARMEB__) && defined(__VFP_FP__) #define IEEE_8087 #define Arith_Kind_ASL 1 #define Sudden_Underflow Index: lib/libc/include/fpmath.h =================================================================== --- lib/libc/include/fpmath.h (revision 186331) +++ lib/libc/include/fpmath.h (working copy) @@ -30,6 +30,10 @@ #include #include "_fpmath.h" +#ifndef _IEEE_WORD_ORDER +#define _IEEE_WORD_ORDER _BYTE_ORDER +#endif + union IEEEf2bits { float f; struct { @@ -52,10 +56,15 @@ double d; struct { #if _BYTE_ORDER == _LITTLE_ENDIAN +#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN unsigned int manl :32; +#endif unsigned int manh :20; unsigned int exp :11; unsigned int sign :1; +#if _IEEE_WORD_ORDER == _BIG_ENDIAN + unsigned int manl :32; +#endif #else /* _BIG_ENDIAN */ unsigned int sign :1; unsigned int exp :11; Index: sys/arm/include/ieee.h =================================================================== --- sys/arm/include/ieee.h (revision 186331) +++ sys/arm/include/ieee.h (working copy) @@ -91,6 +91,12 @@ #define DBL_EXPBITS 11 #define DBL_FRACBITS 52 +#if defined(__VFP_FP__) || defined(__ARMEB__) +#define _IEEE_WORD_ORDER _BYTE_ORDER +#else +#define _IEEE_WORD_ORDER _BIG_ENDIAN +#endif + struct ieee_single { #if _BYTE_ORDER == _BIG_ENDIAN u_int sng_sign:1; @@ -110,10 +116,15 @@ u_int dbl_frach:20; u_int dbl_fracl; #else +#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN u_int dbl_fracl; +#endif u_int dbl_frach:20; u_int dbl_exp:11; u_int dbl_sign:1; +#if _IEEE_WORD_ORDER == _BIG_ENDIAN + u_int dbl_fracl; +#endif #endif }; --Boundary_(ID_6aRa5zsxN2/Qv99f8U55DA) Content-type: text/plain; charset=US-ASCII; format=flowed Content-transfer-encoding: 7BIT --Boundary_(ID_6aRa5zsxN2/Qv99f8U55DA)--