lkml.org 
[lkml]   [2000]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From

On 2000/12/15 Werner Almesberger wrote:
> LA Walsh wrote:
>
> Exception: opaque types; there one would have to go via a __ identifier,
> i.e.
>
> <public>/foo.h defines struct __foo ...;
> <public>/bar.h includes <public>/foo.h
> and uses #define FOOSIZE sizeof(struct __foo)
> <private>/foo.h either typedef struct __foo foo_t;
> or #define foo __foo /* ugly */
>

Easier: public kernel interfaces only work through pointers.
<public>/foo.h typedef struct foo foo_t;
foo_t* foo_new();
<private>/foo.h includes <public>/foo.h
struct foo { ............... };
and uses #define FOOSIZE sizeof(foo_t)
Drawback: public access is slow (always through foo_set_xxxx_field(foo_t*))
private access from kernel or modules is fast (foo_t->x = ...)
Advantage: kernel can change, foo_t internals can change and it is binary
compatible. Even public headers can be kernel version
independent.
Too kind-of-classroom-not-real-world-useless-thing ?
All depends on public access needing full fast paths...

--
Juan Antonio Magallon Lacarta #> cd /pub
mailto:jamagallon@able.es #> more beer

Linux werewolf 2.2.19-pre1 #1 SMP Fri Dec 15 22:25:20 CET 2000 i686

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:52    [from the cache]
©2003-2011 Jasper Spaans