Skip to content

Generate headers from ILE C headers #6

@NattyNarwhal

Description

@NattyNarwhal

While this makes calling programs/procedures pretty easy, you might still need to copy and paste (and adapt) structure definitions and still write the PGMFunction/ILEFunction definitions. What'd be nice is being able to point to a header and extract definitions.

Likely challenges:

  • Turn function definitions into the previously mentioned wrappers, preserve structures. Preserve macros perhaps too, since they may be used for i.e. enum fields. Unsure of function pointer types, or data symbols (we need a wrapper type for this).
  • Deal with ILE C extensions, i.e. _Packed that are present in system headers. Either handle them in parsing or preprocess to convert them to the GCC extensions (which are still incompatible with strict standard C parsers...).
  • Preserve ABI layout in the AIX version of the structure. long is 32-bit in ILE C, and pointers are 128-bit (well, unless Teraspace is used, but there are pragmas to control this).
  • It might be wise to run the preprocessor (or at least unifdef) ahead of time, since there are some funny constructs that trip up i.e. tree-sitter and libclang unless we do that (i.e. use #ifdef for using #pragma for linkage control rather than extern "OS for OPM).
    • This means figuring out what stock definitions we need to set, what pragmas we need to keep and understand.
    • For #include, make sure we're importing the ILE C and not OS one (for i.e. sys/types.h. This likely means making a copy of the system headers and dumping them into a sysroot for GCC CPP (and hoping GCC CPP can understand), or a C preprocessor that we have finer grained control of.

What would be nice is an IDL for system APIs that we can generate from rather than parsing C, but that precludes user things (unless they conform to said IDL).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions