Skip to content
  • Philippe Gerum's avatar
    lib/cobalt: allow for overriding Cobalt service implementation · 1a190ca3
    Philippe Gerum authored
    We provide a mean for overriding Cobalt wrapper routines with
    user-provided routines.
    
    Each "foo" Cobalt routine shadowing a POSIX service may then appear
    as:
    
    __real_foo() => Original POSIX implementation.
    __cobalt_foo() => Cobalt implementation.
    __wrap_foo() => Weak alias to __cobalt_foo(). May be overriden
    by some extension library.
    
    Extension libraries overriding some of the shadowed POSIX routines
    shall provide:
    
    * Their own implementation of the POSIX service as __wrap_foo()
    * An entry for the "foo" symbol in some override definition file, to
    be installed in $(prefix)/lib, and named after the interface. This
    file must have the same format than lib/cobalt/cobalt.wrappers.
    
    E.g. a new interface "foo" overriding POSIX symbols should install a
    file named $(prefix)/lib/foo.wrappers. This file will be picked
    automatically by the xeno-config script when built for the Cobalt
    core.
    
    The Cobalt implementation of any overriden "foo" routine is still
    callable as __COBALT(foo(args...)). Any call reference to foo() will
    branch to the user-defined implementation overriding Cobalt's.
    
    e.g. Library "foo" wants to provide its own implementation of service
    sched_yield().
    
    lib/foo
    	/foo.wrappers
    		...
    		--wrap sched_yield
    		...
    
    	/pthread.c
    		int __wrap_sched_yield(void)
    		{
    			/* Eventually branch to Cobalt's version. */
    			return __COBALT(sched_yield());
    		}
    
    A Makefile rule should install lib/foo/foo.wrappers into $(prefix)/lib.
    
    $ cd buildir
    $ .../xenomai/configure --with-cobalt-override=.../lib/overlib/overlib.wrappers
    
    NOTE: for pratical reasons, xeno-config and wrap-link.sh scripts
    expect all POSIX wrapper files to match the "*.wrappers" glob pattern.
    1a190ca3