From RTSC-Pedia

Jump to: navigation, search
revision tip
—— LANDSCAPE orientation
[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC

C Language Binding

Compile-time & run-time elements introduced by RTSC

Contents

Common public functions

The following functions are part of the public interface provided by all modules.

C - Module_getMask Get a module's diagnostics mask
C - Module_hasMask Check for a module diagnostics mask
C - Module_heap Get a module's heap
C - Module_id Get a module's unique ID
C - Module_setMask Set a module's diagnostics mask
C - Module_startupDone Query if a module's startup is complete

In addition, modules that support instance objects also provide the following functions.

C - construct Initialize a new instance object inside the provided structure
C - create Allocate and initialize a new instance object and return its handle
C - destruct Finalize the instance object inside the provided structure
C - delete Finalize and free this previously allocated instance object
C - Handle_label Get an instance's label
C - Handle_name Get an instance's name
C - Object_count Get the number of statically created instances
C - Object_first Get the handle of the first dynamically created instance
C - Object_get Get the instance handle of a statically created instance
C - Object_heap Get a module's instance heap
C - Object_next Get the handle of the next dynamically created instance
C - Params_init Initialize new instance creation parameters

Modules that inherit from interfaces provide the following type-safe conversion operations.

C - Handle_downCast conditionally move one level down the inheritance hierarchy
C - Handle_upCast unconditionally move one level up the inheritance hierarchy

Internal functions

The following functions are "internal functions" implemented by modules in order to support module instance object creation and deletion (if necessary) as well as the common public functions listed above.

C - Instance_finalize Module's instance finalization function
C - Instance_init Module's instance initialization function
C - Module_startup Module's startup initialization function

Module-specific functions

Module-wide functions

Module-wide functions.  The RTSC IDL allows you to specify "module-wide" functions; functions that are not associated with any particular instance that may be managed by the module. For example, the LoggerBuf_flushAll() function is declared in LoggerBuf.xdc and implemented in LoggerBuf.c as follows:

LoggerBuf.xdc
 
 
 
 
 module LoggerBuf {
     Void flushAll();
         :
}
LoggerBuf.c
 
 
 
 
 
 
#include "package/internal/LoggerBuf.xdc.h"
 
Void LoggerBuf_flushAll(Void)
{
    :
}

Clients of LoggerBuf_flushAll simply include the LoggerBuf module's public header and call LoggerBuf_flushAll() using the arguments specified in LoggerBuf.xdc.

client.c
 
 
 
#include <xdc/runtime/LoggerBuf.h>
    :
LoggerBuf_flushAll();
Instance functions

Instance functions.  The RTSC IDL allows you to specify module functions which operate on an instance type managed by the module. For example, the HeapMin_alloc() function is declared in HeapMin.xdc and implemented in HeapMin.c as follows:

HeapMin.xdc
 
 
 
 
 
 module HeapMin {
     instance:
     Void free(Ptr block, SizeT size);
         :
}
HeapMin.c
 
 
 
 
 
 
#include "package/internal/HeapMin.xdc.h"
 
Void HeapMin_free(HeapMin_Object *obj, Ptr block, SizeT size)
{
    :
}

Clients of HeapMin_free simply include the HeapMin module's public header and call HeapMin_free() using the arguments specified in HeapMin.xdc after passing an instance handle as the first argument.

client.c
 
 
 
 
#include <xdc/runtime/HeapMin.h>
    :
HeapMin_Handle heap;
HeapMin_free(heap, buf, size);
Variable arguments support

Variable arguments support.  The RTSC IDL allows you to specify functions which, like printf(), accept a variable number of arguments. The syntax used in the IDL is essentially the same as that specified by ANSI C. For example, the System_printf() function is declared in System.xdc and implemented in System.c as follows:

System.xdc
 
 
 
 
 module System {
     Int printf(String fmt, ...);
         :
}
System.c
 
 
 
 
 
 
#include "package/internal/System.xdc.h"
 
Int System_printf_va(String fmt, VaList va)
{
    :
}

Clients of System_printf simply include the System module's public header and call System_printf() using the arguments specified in System.xdc.

client.c
 
 
 
#include <xdc/runtime/System.h>
    :
System_printf("x = %d, y = %d\n", 1, 2);

Module Binary Contract

The following topics describe the binary data structures and symbols created to support the bindings described above. To maintain compatibility with packages created using different versions of XDCtools, these data structures and their names must not change. It's important to note, however, that while the data structures defined in a module's headers can not change, the data structures defined in the generated configuration files can (and often do) change from release to release of XDCtools.

Integrating RTSC Modules#Linking Integrating RTSC modules into existing C/C++ environments
Integrating RTSC Modules#Debugging Integrating RTSC modules into existing C/C++ environments

[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC
Copyright © 2008 The Eclipse Foundation. All Rights Reserved


Views
Personal tools
package reference