[KinoSearch] Towards a stable C API... via indirect dispatch

Nathan Kurz nate at verse.com
Sun Oct 28 12:52:39 PDT 2007



On 10/27/07, Marvin Humphrey <marvin at rectangular.com> wrote:
> In order to present a useful public C API for KS, we need to make
> method calls available -- not just functions.  But in KS, inheritance
> is implemented using vtables -- structs with function pointer members
> -- and once those vtables are part of the public API, you can't
> change the vtable struct layout without wrecking binary
> compatibility.

Good summary, but I'm not sure that there are that many cases where we
would be breaking the binary API.  The link you provide suggests that
things will break if we add a new method to the end of the vtable, but
I don't think this applies to the way Boilerplater works.   Am I
wrong?

My instinct is that this is a fine solution to the problem, but that
it's not really a problem that we need to solve right now.   I'm not
seeing how KinoSearch is different than any other shared library ---
couldn't we just bump up the major version number every time the
binary API changes?

I may just be being misled by the trivial examples you are using.
Could you offer a better example of a case where this technique would
be necessary?

Aaron Crane writes:
> More specifically, the failure would be at link-time, right?  Unless
> I'm misunderstanding, code using the new macro will contain a reference
> to the kino_Term_destroy_OFFSET symbol, so the linker should fail when
> trying to resolve uses of that symbol in callers.

I'm pretty sure that in Marvin's solution the offset value is a
variable stored in the Kinosearch shared library.   This is probably
what you mean in the next sentence, but to confirm, this means the
failure will be detected at dynamic link time by ld-linux.so (or
equivalent), which from a user's point of view is the  same as failure
at run-time

Nathan Kurz
nate at verse.com

_______________________________________________
KinoSearch mailing list
KinoSearch at rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch




More information about the kinosearch mailing list