logo       

Re: Re: question about harddrv.{h,cc}: msg#00130

emulators.bochs.devel

Subject: Re: Re: question about harddrv.{h,cc}

There has always been a discrepancy between the naming of that macro in
the CPU and in the io devices. Even now in current CVS we have in the CPU

#if BX_USE_CPU_SMF == 0
# define BX_CPU_THIS_PTR this->
# define BX_CPU_THIS this
#else
# define BX_CPU_THIS_PTR BX_CPU(0)->
# define BX_CPU_THIS BX_CPU(0)
#endif

but then in the io devices, the _PTR suffix is not used.

#if BX_USE_PIC_SMF
# define BX_PIC_SMF static
# define BX_PIC_THIS thePic->
#else
# define BX_PIC_SMF
# define BX_PIC_THIS this->
#endif


I think the naming convention in the CPU makes a lot of sense (to the
extent that any macro that ends with an arrow can make sense). So if all
the iodevs eventually got the macro names changed to BX_???_THIS_PTR, I
consider that to be more clear.

Brian: I noticed that the macros named with _PTR at the end that appear
in the iodev directory were added by you, in the BRANCH_SAVE_RESTORE
branch only, back in April. :) From the output of "cvs annotate
-rBRANCH_SAVE_RESTORE keyboard.h" we have

1.1 (cvs 10-Apr-01): #if BX_USE_KEY_SMF
1.1 (cvs 10-Apr-01): # define BX_KEY_SMF static
1.21.2.2 (slechta 04-Apr-03): # define BX_KEY_THIS_PTR theKeyboard->
1.21.2.2 (slechta 04-Apr-03): # define BX_KEY_THIS theKeyboard
1.1 (cvs 10-Apr-01): #else
1.1 (cvs 10-Apr-01): # define BX_KEY_SMF
1.21.2.2 (slechta 04-Apr-03): # define BX_KEY_THIS_PTR this->
1.21.2.2 (slechta 04-Apr-03): # define BX_KEY_THIS this
1.1 (cvs 10-Apr-01): #endif

>From "cvs annotate -rHEAD keyboard" we have

1.1 (cvs 10-Apr-01): #if BX_USE_KEY_SMF
1.1 (cvs 10-Apr-01): # define BX_KEY_SMF static
1.18 (bdenney 24-Oct-02): # define BX_KEY_THIS theKeyboard->
1.1 (cvs 10-Apr-01): #else
1.1 (cvs 10-Apr-01): # define BX_KEY_SMF
1.18 (bdenney 24-Oct-02): # define BX_KEY_THIS
1.1 (cvs 10-Apr-01): #endif


So if in the process of working on save/restore you need access to both
the "this" and the "this->", then I suggest switching those devices to the
BX_?_THIS and BX_?_THIS_PTR notation, as you have been doing.

-Bryce




On Sat, 22 Nov 2003, Brian Slechta wrote:
> In fact, I see this in other files in iodev/ such as keyboard.{h,cc}.
> Is there a reason for the differences or are these bugs? In the case of
> keyboad.cc, we see the following:
>
> BX_KEY_THIS timer_handle = bx_pc_system.register_timer(this, ... );
>
> I would think that this should be:
>
> BX_KEY_THIS_PTR timer_handle =
> bx_pc_system.register_timer(BX_KEY_THIS, ... );
>
> Perhaps I am not reading this correctly.
>
> --Brian
>
> Brian Slechta wrote:
>
> > In the CVS of harddrv.{h,cc}, there are macros for making the class
> > completely static. I realize that this has speed implications when
> > there is only one hard drive class that needs to be instantiated. In
> > any case, the following marcos are in mainline CVS:
> >
> > # define BX_HD_SMF static
> > # define BX_HD_THIS_PTR theHardDrive->
> > # define BX_HD_THIS (theHardDrive)
> > #else
> > # define BX_HD_SMF
> > # define BX_HD_THIS_PTR this->
> > # define BX_HD_THIS this->
> > #endif
> >
> > This does not appear consistent with other classes in Bochs that use
> > this construct. Shouldn't BX_HD_THIS be defined as "this" rather than
> > "this->"? Also, functions in harddrv.cc reference "this" directly.
> > Shouldn't these functions use BX_HD_THIS instead?
> >
> > Thanks,
> > Brian
> >
> >
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive? Does it
> help you create better code? SHARE THE LOVE, and help us help
> YOU! Click Here: http://sourceforge.net/donate/
> _______________________________________________
> bochs-developers mailing list
> bochs-developers@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/bochs-developers
>
>




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise