On Mon 25 Feb 2019 at 18:10:20 +0000, Eduardo Horvath wrote: > I'd do something like: > > uint64_t ufetch_64(const uint64_t *uaddr, int *errp); > > where *errp needs to be initialized to zero and is set on fault so you can > do: > > int err = 0; > long hisflags = ufetch_64(flag1p, &err) | ufetch_64(flag2p, &err); > > if (err) return EFAULT; > > do_something(hisflags); I like this, because it swaps the cost of the value that is always needed (which was expensive) versus the one that isn't expected often (the error case, was cheap). With this change, the return value can be stored in a register. If you take the address of the variable where you want the value to be, it can't be a register. But the error case hopefully doesn't occur often, so the error code likely doesn't even have to be stored into. > Eduardo -Olaf. -- ___ Olaf 'Rhialto' Seibert -- "What good is a Ring of Power \X/ rhialto/at/falu.nl -- if you're unable...to Speak." - Agent Elrond
Attachment:
signature.asc
Description: PGP signature