Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Merging few files from i386/amd64 into x86



David Young <dyoung%pobox.com@localhost> wrote:
> Can you avoid using new #ifdefs, or else confine them to the top of the
> file?  They make even straightforward code hard to read. :-/
> 

More about this:

http://www.netbsd.org/~rmind/x86_cpu.diff

        if (stack != NULL) {
#ifdef __x86_64__
                tf->tf_rsp = (uint64_t)stack + stacksize;
#else
                tf->tf_esp = (u_int)stack + stacksize;
#endif
        }

With these macros, such code would become:

        if (stack != NULL)
                X86_TF_RSP(tf) = (uintptr_t)stack + stacksize;

This would make merge of trap.c and syscall.c into x86 quite nice.

Concerns:

- Any reason why we would want to keep the type size in MD (instead of
  abstracting it out, eg. with uintptr_t)?  By the way:
  http://nxr.netbsd.org/source/xref/sys/arch/i386/include/frame.h#trapframe
  Why these and others are not unsigned, eg. uint32_t?

- Naming of macros could be better. Suggestions?

Thanks.

-- 
Best regards,
Mindaugas


Home | Main Index | Thread Index | Old Index