please help in this galileo code

//made by Abhay Gupta

#define resolution 8
#define mains 50

#define refresh 2 * 1000000 / mains

void setup() {
Serial.begin(115200);

// unused pins are fairly insignificant,
// but pulled low to reduce unknown variables
for(int i = 2; i < 14; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}

for(int i = 8; i < 11; i++)
pinMode(i, INPUT);

startTimer();
}

void loop() {
Serial.print(time(8, B00000001), DEC);
Serial.print(" “);
Serial.print(time(9, B00000010), DEC);
Serial.print(” ");
Serial.println(time(10, B00000100), DEC);

}

long time(int pin, byte mask) {
unsigned long count = 0, total = 0;
while(checkTimer() < refresh) {
// pinMode is about 6 times slower than assigning
// DDRB directly, but that pause is important
pinMode(pin, OUTPUT);
PORTB = 0;
pinMode(pin, INPUT);
while((PINB & mask) == 0)
count++;
total++;
}
startTimer();
return (count << resolution) / total;
}

extern volatile unsigned long timer0_overflow_count;

void startTimer() {
timer0_overflow_count = 0;
TCNT0 = 0;
}

unsigned long checkTimer() {
return ((timer0_overflow_count << 8) + TCNT0) << 2;
}

the above is my code when i try to compile in galileo it is showing these errors
Arduino: 1.6.0 (Windows 7), Board: “Intel® Galileo”

Build options changed, rebuilding all

_3d.ino: In function ‘long int time(int, byte)’:

_3d.ino:39:5: error: ‘PORTB’ was not declared in this scope

_3d.ino:41:12: error: ‘PINB’ was not declared in this scope

_3d.ino: In function ‘void startTimer()’:

_3d.ino:53:3: error: ‘TCNT0’ was not declared in this scope

_3d.ino: In function ‘long unsigned int checkTimer()’:

_3d.ino:57:42: error: ‘TCNT0’ was not declared in this scope

Error compiling.

Build options changed, rebuilding all
_3d.ino: In function ‘long int time(int, byte)’:
_3d.ino:39:5: error: ‘PORTB’ was not declared in this scope
_3d.ino:41:12: error: ‘PINB’ was not declared in this scope

_3d.ino: In function ‘void startTimer()’:
_3d.ino:53:3: error: ‘TCNT0’ was not declared in this scope

_3d.ino: In function ‘long unsigned int checkTimer()’:
_3d.ino:57:42: error: ‘TCNT0’ was not declared in this scope

Error compiling.

it works perfectly fine when comiled in arduino so if any one knows how to rectify it then please help

Does the Galileo actually have the ports that the error report shows ? Probably not. As an experiment change the target board to Uno and try a verify.

The Galileo processor is quite different to the arduino processors. Trying to directly access the hardware registers like that, is not going to work.

please edit your first post and put the code inside code tags. See the "how to post to the forum" to learn how to do that.