This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049C: Misra-C Scanning for TI Built-In Function

Part Number: TMS320F280049C
Other Parts Discussed in Thread: C2000WARE

Hi experts,

Our customer requested us to scan Misra-C with our source code and TI's library together and listed all defects to them (especially the mandatory items).

Polyspace (we used this tool to scan Misra-C) found a mandatory defect of TI's library (C2000Ware_2_00_00_03), which is a built-in (intrinsics) function. 

My understanding is that __enable_interrupts() is declared but without a definition.

We know that the built-in functions are implemented by the assembly code, but our customer still wanted to confirm TI whether the compiler can work if there is no associated definition.

We have two related questions:

1. Can we find the assembly source code in the library folder?

2. How compiler links the assembly source code?

Many thanks,

Sincerely

C.C. Liu

  • Hi 

     __enable_interrupts() is a compiler intrinisc function, implemented inside the compiler. Some of these functions can be found in the runtime library, some may not actually exist as a function at all and the compiler will insert some (assembly) code in the location where such a function is called.

    Will forward your query to the compiler team to get more details.

    Best Regards

    Siddharth

  • C.C. Liu,

    Our compiler expert is out today but will reply when they return tomorrow.

    Regards,

    John

  • To learn more about compiler intrinsics like __enable_interrupts, please search the C28x compiler manual for the sub-chapter titled Using Intrinsics to Access Assembly Language Statements.  

    One good way to handle ...

    Polyspace (we used this tool to scan Misra-C) found a mandatory defect of TI's library (C2000Ware_2_00_00_03)

    ... is to create a header file which has a prototype for all the intrinsics used (such as __enable_interrupts), and #include it where needed.

    Thanks and regards,

    -George

  • Hello George,

    Thanks for your reply.

    I knew the document of the C28x compiler manual and I already understood section 7.6.

    My purpose is to know the flow between the intrinsic functions and compiler (please see the below figure with red arrows, is my understanding correct?).

    If my understanding is correct, how compiler knows the intrinsic functions?

    If there is a declaration about the intrinsic function, will the compiler know the contents of intrinsic functions (assembly code)?

    For example, if one calls the __enable_interrupts(), how the compiler knows to link the assembly code (like below)?

     

    Kindly help to clarify my concerns.

    Best Regards,

    C.C.Liu

  • please see the below figure with red arrows, is my understanding correct?

    No.

    In terms of C syntax, an intrinsic is just like a function call.  But that is the only way it is like a function call.  Otherwise, it is different.

    The compiler recognizes an intrinsic by name.  When it sees one, a function does not get called.  Instead, a short sequence of assembly instructions (often just one instruction) is generated that implement an operation that is impossible or difficult to express in C.

    Thanks and regards,

    -George