lkml.org 
[lkml]   [2009]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access APIs
From
Date
Masami Hiramatsu <mhiramat@redhat.com> writes:

> Add following APIs for accessing registers and stack entries from pt_regs.

You forgot to state who calls these functions/why are they added?
Who only has strings for registers?

I can see the point of having a function for nth argument though,
that's useful.

> +static inline unsigned long regs_get_argument_nth(struct pt_regs *regs,
> + unsigned n)
> +{
> + if (n < NR_REGPARMS) {
> + switch (n) {
> + case 0:
> + return regs->ax;
> + case 1:
> + return regs->dx;
> + case 2:
> + return regs->cx;


[....]

That could be done shorter with a offsetof table.

> + if (n < NR_REGPARMS) {
> + switch (n) {
> + case 0:
> + return regs->di;
> + case 1:
> + return regs->si;
> + case 2:
> + return regs->dx;
> + case 3:
> + return regs->cx;
> + case 4:
> + return regs->r8;
> + case 5:
> + return regs->r9;

and that too.


-Andi
--
ak@linux.intel.com -- Speaking for myself only.


\
 
 \ /
  Last update: 2009-07-06 16:37    [W:1.114 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site