This is the mail archive of the ecos-discuss@sourceware.cygnus.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

improving type safety in kapi c-language interfaces?


The company I work for has pretty much decided to go with ecos for our
embedded o/s, using the c-language interfaces provided by kapi.cxx and
kapi.h.  On the whole, ecos appears to provide the features we want in
a relatively simple and compact package.

However, one thing we've noticed about these function that we don't
particularly care for is their use of cyg_handle_t as a generic type
for all sorts of objects.  It seems unfortunate to have weakened the
type safety of the underlying c++ interfaces.

Having looked at kapi.[ch], it seems to me it would be relatively easy
to replace the common cyg_handle_t with separate cyg_thread_handle_t,
cyg_counter_handle_t, and cyg_clock_t and so on.  Declaring these as
pointer types to incomplete structs, ie,

        typedef struct cyg_thread_handle *cyg_thread_handle_t;
        ...

would preserve their opaque nature, yet buy back some compile-time
type checking in the c-language interface.  Is my assumption that this
change would be straightforward correct, or is there something I'm
missing?

Would a patch on the lines suggested above being accepted into ecos?
I suspect the answer would be no, simply because it represents an
incompatible change in the interface.  Since we'd prefer not to
maintain separate patches to ecos, our alternative is to provide
wrappers for the parts of the ecos interface we intend to use, which
can provide a better level of type checking.

Dale.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]