Metal C function descriptor support

When a library or a set of functions are used by multiple applications, these functions have the same code in all the applications while their associated data is application-specific. In this case, you can use Metal C function descriptors to call these library functions instead of using normal function pointers.

A Metal C function descriptor encapsulates all the information that a function call needs to access both the function and the application-specific data. You can use Metal C function descriptors to point to and call functions with their own set of associated data for the particular program or invocation.

A function pointer that is declared with the __fdptr keyword points to a Metal C function descriptor, which is an internal control block that contains two fields:
  • The address of the actual function to be called when the function pointer is dereferenced
  • The address of the data location or function environment
The length of each field is the same as that of a pointer in the current compilation's unit AMODE.

Related information