If you have defined your own variables to reside at the port locations, make sure you qualify these variables as "volatile". Without this, bits within the port, or the entire port byte value itself, may not be accessed atomically (in one instruction). For example, the most efficient way to write a bit on 8-bit devices is to set the bit, then optionally clear it if required. this takes the least amount of code, but can lead to the bit changing state twice.
There could also be problems with cached copies of the port value being used if you should read from the port. For example:
If you are using the definitions for the ports that become available after including then these are already correctly qualified and you do not need to modify these definitions.