Runtime "target test" hook in firmware?

I took a quick look for any reference to related subjects on the web reference and forum topics, so if I overlooked any cite to this my apologies in advance.

Is there a runtime hook in the firmware that I can leverage for target device conditionals?

Example:
if (Photon) perform_Photon_operation;
else if (P1) perform_P1_operation;
else none_of_the_above;

So you have a Product that has two hardware implementations?

Yes sir.
And I’d like a single code base.

Try a search on a compiler directive “PLATFORM_ID”.

Thanks Bear!
Directives work too!

Bookmarked for future reference: