delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/08/18/18:13:56

From: <ams AT ludd DOT luth DOT se>
Message-Id: <200308182213.h7IMDUud018570@speedy.ludd.luth.se>
Subject: Re: tests/libc/c99/math/t-fpclas.c
In-Reply-To: <3F41430E.F3FD2BF6@phekda.freeserve.co.uk> "from Richard Dawe at
Aug 18, 2003 10:20:14 pm"
To: djgpp-workers AT delorie DOT com
Date: Tue, 19 Aug 2003 00:13:30 +0200 (CEST)
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
X-MailScanner: Found to be clean
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

According to Richard Dawe:
> Are you going to post a fix for fpclassifyld sometime?

Errr... yes, here it is:

/*
 * File fpclassd.S.
 *
 * Copyright (C) 2003 Martin Str@"omberg <ams AT ludd DOT luth DOT se>.
 *
 * This software may be used freely so long as this copyright notice is
 * left intact. There is no warranty on this software.
 *
 */

#include <sys/math_def.h>

/*
 * Bits:        79 (sign), 78-64 (exponent), 63 (integer), 62-0 (fraction)
 * Zero:        +/-             0               0               0
 * Subnormal    +/-             0               0               !=0
 * Normal       +/-             !=0, <0xff      1               any
 * Infinity:    +/-             0xff            1               0
 * NaN:         any             0xff            1               !=0
 * Unnormal(1)  any             0               1               any
 * Unnormal(2)  any             !=0             0               any
 */

/*
 *      Stack:
 *      12(%esp):       high 16 bits of the long double
 *      8(%esp):        middle 32 bits of the long double
 *      4(%esp):        low 32 bits of the long double
 *      0(%esp):        return address
 */
        .globl  ___fpclassifyld
___fpclassifyld:
        movl    8(%esp), %edx
        movl    12(%esp), %eax
        testl   $0x80000000, %edx
        jz      no_one_bit

        andl    $0x7fffffff, %edx /* Remove integer bit. */
        andl    $0x7fff, %eax
        jz      unnormal

        cmpl    $0x7fff, %eax
        je      all_ones_exponent

        movl    $FP_NORMAL, %eax
        ret

no_one_bit:
        andl    $0x7fff, %eax
        jnz     unnormal

        orl     4(%esp), %edx
        movl    $FP_ZERO, %eax
        jz      zero

        movl    $FP_SUBNORMAL, %eax
zero:
        ret

unnormal:
        movl    $FP_UNNORMAL, %eax
        ret

all_ones_exponent:
        orl     4(%esp), %edx
        movl    $FP_INFINITE, %eax
        jz      infinity

        movl    $FP_NAN, %eax
infinity:
        ret


Are everyone happy with the additional header file? Otherwise we could
add "#if __GNUC__/#endif" to strategic places in <math.h> (and other
header files if necessary) to remove everything but the defines for .S
files. Or another #define if you know of a better one.

Personally I'd rather add the "#if __GNU__"s instead of the new header
file (now that I think it's possible).


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019