This is the mail archive of the libc-alpha@sourceware.org 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: RISCV NFPREG?


On Tue, Oct 8, 2019 at 10:42 PM Maciej W. Rozycki <macro@wdc.com> wrote:
>  We have this:
> #define ELF_NFPREG      NFPREG
> in sysdeps/unix/sysv/linux/riscv/bits/procfs.h, however NFPREG is nowhere
> defined.  This has come from your initial commit 7f33b09c65e3 ("RISC-V:
> Linux ABI").  Do you happen to remember what the intent was here if any?

I don't know the history here, but looking at an old pre-upstream copy
of the glibc port, I see in ucontext.h

/* Number of general registers.  */
#define NGREG   32
#define NFPREG  32

and

/* Container for all general registers.  */
typedef greg_t gregset_t[NGREG];

/* Container for all FPU registers.  */
typedef fpreg_t fpregset_t[NFPREG];

So it was probably dropped when fpregset was expanded to include fcsr.
That poses a problem, because we have 32 FP regs which may be 32-bit,
64-bit, or 128-bit, and 1 fcsr reg which is always 32-bit, so how
exactly do we count the number of FP regs when we have two different
types of FP registers that may be of two different sizes?  It is
simpler to say that we don't have a fixed number of FP registers and
not define NFPREG.  That forces people to parse the fpregset
structure, instead of trying to index into it as an array of registers
which doesn't work.  When NFPREG was dropped, they probably missed the
use in procfs.h.  I had to deal with some of these problems when I
added the FP reg ptrace support to the linux kernel and gdb.  Anyways,
I'd suggest just removing the useless NFPREG stuff in profcs.h.

I'm puzzled by your gdb comment though, because as far as I know the
riscv gdb port isn't using NFPREG, and shouldn't need it.  Though
maybe you are working on the missing gdbserver support for RISC-V?  If
you do readd NFPREG or __NFPREG it is probably worth adding a comment
explaining that you can't just iterate through the fpregset as an
array because of the different sized fcsr register.

Jim


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