Arduino.h and wiring_digital.c problem.

What's the intended behaviour of sbi? you defined it as:

#define sbi(reg, bitmask) reg = 0xffffffff & bitmask

Actually (0xffffffff & bitmask) equals to "bitmask", i don't see why you do this bitwise-AND.

probably you want to do something like that:

#define sbi(reg, mask) (reg |= mask)
#define cbi(reg, mask) (reg &= ~mask)