This is the mail archive of the mailing list for the libc-ports 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]

fixing ARM aeabi fesetround and friends


glibc-ports/sysdeps/arm/eabi/ contains functions for manipulating
rounding modes and other parameters specified in IEEE 754.

Unfortunately, they do not work correctly when a program is compiled
with software floating point, yet the runtime hardware contains a VFP.


fesetround (int round)
  if (GLRO (dl_hwcap) & HWCAP_ARM_VFP)
      fpu_control_t temp;

      switch (round)
        case FE_TONEAREST:
        case FE_UPWARD:
        case FE_DOWNWARD:
        case FE_TOWARDZERO:
          _FPU_GETCW (temp);
          temp = (temp & ~FE_TOWARDZERO) | round;
          _FPU_SETCW (temp);
          return 0;
          return 1;
  else if (round == FE_TONEAREST)
    /* This is the only supported rounding mode for soft-fp.  */
    return 0;

  /* Unsupported, so fail.  */
  return 1;

When I compile a program with software floating point, I expect
fesetround to fail when I set a non-default rounding mode. Instead, the
failure is dependent on the presence of a VFP at runtime. In this case,
fesetround sets the control word of the VFP, and returns success. But
because I am not using the VFP, it should fail.

With the addition of ARM attribute tags, it should be possible to
condition on the user's intent. Specifically, Tag_VFP_arch tells us if
the user wants to use software or hardware FP. This tag is set by the

Can we change the dl_hwcap conditional there to read the VFP attribute
tag instead? Is this information still around at the point fesetround is
called? I am trying to figure out how to load this information, it looks
like something in dl-sysdep, but I'm not sure. Any hints are welcome.



Attachment: signature.asc
Description: OpenPGP digital signature

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