tech-kern archive

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

Re: UVM typedef struct




On Jun 16, 2009, at 4:21 PM, Antti Kantee wrote:

On Tue Jun 16 2009 at 21:00:35 +0100, Mindaugas Rasiukevicius wrote:
The underlying problem is that I do not see any benefit from arbitrary
typedefs such as struct x -> x_t.  Will we get u32_t next?

I understand that it is a personal preference, but at least to me, it would increase readability. It would be good to hear opinions of more people who
are working in sys/uvm.

Also, as already mentioned, this would be consistent with other core parts,
eg. various code in sys/kern.

No, your argument is personal preference, mine is technical.  This was
already hinted a few times, but here we go again:

If you have typedef struct foo foo_t; and use foo_t * in an interface,
you must always expose the implementation struct foo since you cannot
typedef twice. With struct foo * you have no such problems since you can use forward declarations. Now, either you will implicitly create rules
about type exposure, need to have two sets of prototypes, some #ifdef
magic, or you will have inconsitency in code (interface has struct foo*,
code uses foo_t and foo_t *).

This is untrue. There is no requirement to expose the contents of a FILE * for instance in order for API's to use it as an opaque data structure. On the pieces that actually need internals need the implementation exposed.

James



Home | Main Index | Thread Index | Old Index