Data sharing between CC and Ada 10262021 Matt
Data sharing between C/C++ and Ada 10/26/2021 Matt Mark - matt. mark@lmco. com 1
Introduction u u Development of real time Air Traffic Control system (ERAM - En. Route Automation Modernization) with strict response time requirements. Legacy components include Ada and C code. These legacy components are being integrated together. Components typically are implemented in Ada or C/C++ and provide APIs in both languages. Due to the to frequency of calls between languages, we wanted better performance than a language independent format such as XML. 10/26/2021 Matt Mark - matt. mark@lmco. com 2
Dictionaries u u u From previous programs, we have tools that use ASIS to gather information about data structures and build dictionary files. Similar tools available for C structures. Dictionary files include information such as: type names / field names / kind of field (float , integer, enumeration) / ranges / offsets Ada 95 unique features such as tagged types not supported Dictionaries used by support tools. For example, to format binary recorded data into text. 10/26/2021 Matt Mark - matt. mark@lmco. com 3
Solution / type generator u Wrote a type generator tool that uses information in dictionary entry and creates Ada and C types. u Entire type is defined in a single Ada package / C header file which can be compiled. u Types supported limited to those naturally defined in Ada and C/C++ (no variant records, unions). 10/26/2021 Matt Mark - matt. mark@lmco. com 4
Usage Define type to be shared in Ada, C, C++ u Create dictionary entry u Run type generator to create opposite language type. u Use “opposite language” type (modification allowed). u Create dictionary entry for “opposite language” type. u At system build time, two types checked to be binary compatible. u 10/26/2021 Matt Mark - matt. mark@lmco. com 5
Example – original type package Rel is subtype Name_T is String (1. . 8); type Kind_T is (None, Os, Firm, Appl); end Rel; with Rel; package Rel_Msg is type Delete_Rel_T is record Kind : Rel. Kind_T; Name : Rel. Name_T; end record; end Rel_Msg; 10/26/2021 Matt Mark - matt. mark@lmco. com 6
Generated Ada code package Test 2 is type Rel_Kind_T is subtype Rel_Name_T (None, Os, Firm, Appl); is String (1. . 8); type Rel_Msg_Delete_Rel_T is record Kind : Rel_Kind_T; Name : Rel_Name_T; end record; for Rel_Msg_Delete_Rel_T use record Kind at 0 range 0. . 7; Name at 0 range 8. . 71; end record; for Rel_Msg_Delete_Rel_T'Size use 72; end Test 2; 10/26/2021 Matt Mark - matt. mark@lmco. com 7
Generated C code typedef enum e_REL_KIND_T {NONE, OS, FIRM, APPL } REL_KIND_T; typedef struct {unsigned char KIND; char NAME[8]; } REL_MSG_DELETE_REL_T; 10/26/2021 Matt Mark - matt. mark@lmco. com 8
Notes about generated types Generated code contained in single package for simplicity of the type generator tool – although, this results in awkward naming of types. u Generated types contain rep spec regardless of whether original type did. u Pad fields added to C types where necessary u 10/26/2021 Matt Mark - matt. mark@lmco. com 9
Modification of generated types u u u Modification of generated types allows for more natural type definitions in each language. For example, character arrays in C are defined in arrays of characters in generated Ada types. At build time, generated types are compared to original types. Dictionary entries of original type and generated type are compared. Some comparison rules are: – Array types and fields, the bit locations, number of elements, and element sizes must match – For integer fields, the bit locations must match and have overlapping ranges u A switch on the type matching tool control if field names must match. 10/26/2021 Matt Mark - matt. mark@lmco. com 10
Other applications Systems that transitions to new compilers or platforms and go through periods where old and updates systems co-exist. u Sharing data between support and operational systems. u 10/26/2021 Matt Mark - matt. mark@lmco. com 11
Conclusion We’ve started using these tools with success. u Currently completing SW development and the type generator tool has been used more than the type matching tool. u Expect more use from type matching tool as we transition from primarily developing code to integration. u 10/26/2021 Matt Mark - matt. mark@lmco. com 12
- Slides: 12