This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: glibc


Hi,

  I'm getting glibc going on Linux/VAX. Lars has pointed out
that we are encountering similar problems.

> One problem I've encountered is that a few files outside of sysdeps
> include <ieee754.h>: math/test-misc.c, stdio-common/printf_size.c,
> stdlib/erand48_r.c, strtod.c.  Would it be acceptable to abstract this

 Plus a few more scattered here and there. (I'm currently looking at the
2.2.3 codebase, so apologies if these are already altered).

  wcsmbs/wcstof.c:       u.ieee.mantissa = (mant) &
0x7fffff;                                 \
  wcsmbs/wcstold.c:       u.ieee.mantissa0 = (((mant) >> 32) &
0x7fffffff) | 0x80000000;              wcsmbs/wcstold.c:      
u.ieee.mantissa1 = (mant) &
0xffffffff;                                    

 The VAX support was obviously working at some point in the (probably
distant) past. Presumably that included floating point support.
There is already a foundation to build this on, in the shape of the 
macros in math/math_private.h for endianess of the IEEE structures.
    
  The problems as I see them mainly stem from general library routines
'assuming' IEEE format. This can range from explicit bit twiddling such 
as goes on in the SET_MANTISSA macro of stdlib/strtod.c, through
to 'knowing' that single precision implies there is one mantissa 
element to the bit pattern, which can be accessed via (x).ieee.mantissa.
(As a reminder, on the vax, F float format format is 
    struct
      {
        unsigned int mantissa1:7;
        unsigned int exponent:8;
        unsigned int negative:1;   /* sign bit */
        unsigned int mantissa:16;
      } ieee;
 -- The ieee at the end of the structure is of course for compatibility
 reasons )

 To make this work, a small amount of abstraction needs to be put in 
place. Rather than including <ieee754.h> a new header <float-format.h>
could be used. This also allows us to rewrite so that rather than
accessing (x).ieee.mantissa, or exponent or quiet_nan in a 
function, in float-format.h could define 

static inline (or whatever) get_float_mantissa(float x);

returns the value of ieee.mantissa for ieee machines, and 
vax.mantissa+vax.mantissa1 for vaxes. (True, for the vax there
is no concept of inf, or NaN as such. But NaN can be emulated
by using the reserved operand bit pattern.)

  This would also have to include changing the names of 
the unions as lars mentioned, from ieee754_float etc, to 
float_format.

  In terms of some of the bit twiddling that goes on in the 
math library, thats another matter. It may be possible to 
abstract some of these operations, or it may be more 
effective to leave them alone and re-write vax/pdp specific 
versions of the affected routines.

  There are only a handful of files affected by this 
change. I dont see why this would offer any overhead to the
default IEEE 754 using case, which should fall through
the typedefs of the float_format to ieee_float, and the 
static inlines to generate essentially the same code as
before.

    Cheers,
         Andy

-- 
Dr. Andy Phillips			atp@pergamentum.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]