From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31139 invoked by alias); 15 Sep 2003 20:54:18 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31005 invoked from network); 15 Sep 2003 20:54:17 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 15 Sep 2003 20:54:17 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 7012B2B89; Mon, 15 Sep 2003 16:54:17 -0400 (EDT) Message-ID: <3F6626F9.90003@redhat.com> Date: Mon, 15 Sep 2003 20:54:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com, binutils@sources.redhat.com, gcc-patches@gcc.gnu.org Subject: Re: [libiberty and gdb] floatformat_is_valid References: <20030915143933.GA22129@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-09/txt/msg00341.txt.bz2 > +/* Return non-zero iff the data at FROM is a valid number in format FMT. */ > + > +int > +floatformat_is_valid (fmt, from) > + const struct floatformat *fmt; > + char *from; > +{ Shouldn't this be a new virtual method in floatformat? > + if (fmt == &floatformat_i387_ext) > + { > + /* In the i387 double-extended format, if the exponent is all > + ones, then the integer bit must be set. If the exponent > + is neither 0 nor ~0, the intbit must also be set. Only > + if the exponent is zero can it be zero, and then it must > + be zero. */ > + unsigned int exponent, int_bit; > + unsigned char *ufrom = (unsigned char *) from; > + > + exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, > + fmt->exp_start, fmt->exp_len); > + int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize, > + fmt->man_start, 1); > + > + if ((exponent == 0) != (int_bit == 0)) > + return 0; > + else > + return 1; > + } > + > + /* Other formats with invalid representations should be added > + here. */ > + return 1; > } Andrew