On Thu, Aug 18, 2022 at 10:32:36PM -0500, Scott Cheloha wrote:
> Hi,
> 
> clockframe is sometimes defined in cpu.h, sometimes in frame.h, and
> sometimes defined once each in both header files.
> 
> Can we put the clockframe definitions in frame.h?  Always?  It is, at
> least ostensibly, a "frame".
> 
> I do not want to consolidate the clockframe definitions in cpu.h
> because this is creating a circular dependency problem for my clock
> interrupt patch.
> 
> In particular, cpu.h needs a data structure defined in a new header
> file to add it to struct cpu_info on all architectures, like this:
> 
> /* cpu.h */
> 
> #include <sys/clockintr.h>
> 
> struct cpu_info {
>       /* ... */
>       struct clockintr_state;
> };
> 
> ... but the header clockintr.h needs the clockframe definition so it
> can prototype functions accepting a clockframe pointer, like this:
> 
> /* clockintr.h */
> 
> #include <machine/frame.h>    /* this works fine */
> 
> #ifdef this_does_not_work
> #include <machine/cpu.h>
> #endif
> 
> int clockintr_foo(struct clockframe *, int, short);
> int clockintr_bar(struct clockframe *, char *, long);

You can also just do:

struct clockframe;
int clockintr_foo(struct clockframe *, int, short);
int clockintr_bar(struct clockframe *, char *, long);

There is no need to have the full struct definition for a pointer.
With that there is no need to include machine/frame.h or machine/cpu.h
In my opinion this may be the preferred way of handling this but unifying
the definitions into one place still makes sense to me.

-- 
:wq Claudio

Reply via email to