Detecting compile-time versus run-time incompatibilities in powerPC

Peter Dufault dufault at hda.com
Mon Apr 12 14:17:21 UTC 2010


A few registers and programming modes have snuck into the MPC55XXEVB code that aren't supported on the MPC5554.  I'm working this out with Thomas, but I have a general question.

With the number of different variants of the embedded powerPC family and what they support it's difficult to know what can be used across the board.

It is nice to have a single binary that supports multiple platforms, but it's also nice to detect problems clearly at compile time, and the headers are a good place to keep track of these incompatible differences.  I'd like to undefine unsupported registers and modes in the headers so that compile fails.  This will not play well with a generic binary that uses run-time code to handle differences.

What's the general consensus on this?   Are feature test macros worth-while, e.g., such as:

#if (MPC55XX_CHIP_TYPE == 5554) && \
  defined(DONT_DEFINE_UNSUPPORTED_REGISTERS_AND_MODES) && \
  !defined(THIS_IS_GENERIC_CODE_AND_I_READ_THINGS_REAL_CAREFULLY_DEFINE_ALL_REGISTERS)
          /* ALTCADR is reserved on the MPC5554 and writes will cause an exception.
           */
            uint32_t altcadr_reserved;
#else
            uint32_t altcadr;
#endif

Til, I expect you'll have thoughts

Peter
-----------------
Peter Dufault
HD Associates, Inc.      Software and System Engineering




More information about the users mailing list