require '_h2ph_pre.ph';

unless(defined(&_LINUX_SCHED_H)) {
    eval 'sub _LINUX_SCHED_H () {1;}' unless defined(&_LINUX_SCHED_H);
    require 'asm/param.ph';
    require 'linux/config.ph';
    require 'linux/binfmts.ph';
    require 'linux/threads.ph';
    require 'linux/kernel.ph';
    require 'linux/types.ph';
    require 'linux/times.ph';
    require 'linux/timex.ph';
    require 'asm/system.ph';
    require 'asm/semaphore.ph';
    require 'asm/page.ph';
    require 'asm/ptrace.ph';
    require 'asm/mmu.ph';
    require 'linux/smp.ph';
    require 'linux/tty.ph';
    require 'linux/sem.ph';
    require 'linux/signal.ph';
    require 'linux/securebits.ph';
    require 'linux/fs_struct.ph';
    eval 'sub CSIGNAL () {0xff;}' unless defined(&CSIGNAL);
    eval 'sub CLONE_VM () {0x100;}' unless defined(&CLONE_VM);
    eval 'sub CLONE_FS () {0x200;}' unless defined(&CLONE_FS);
    eval 'sub CLONE_FILES () {0x400;}' unless defined(&CLONE_FILES);
    eval 'sub CLONE_SIGHAND () {0x800;}' unless defined(&CLONE_SIGHAND);
    eval 'sub CLONE_PID () {0x1000;}' unless defined(&CLONE_PID);
    eval 'sub CLONE_PTRACE () {0x2000;}' unless defined(&CLONE_PTRACE);
    eval 'sub CLONE_VFORK () {0x4000;}' unless defined(&CLONE_VFORK);
    eval 'sub CLONE_PARENT () {0x8000;}' unless defined(&CLONE_PARENT);
    eval 'sub CLONE_THREAD () {0x10000;}' unless defined(&CLONE_THREAD);
    eval 'sub CLONE_SIGNAL () {( &CLONE_SIGHAND |  &CLONE_THREAD);}' unless defined(&CLONE_SIGNAL);
    eval 'sub FSHIFT () {11;}' unless defined(&FSHIFT);
    eval 'sub FIXED_1 () {(1<< &FSHIFT);}' unless defined(&FIXED_1);
    eval 'sub LOAD_FREQ () {(5* &HZ);}' unless defined(&LOAD_FREQ);
    eval 'sub EXP_1 () {1884;}' unless defined(&EXP_1);
    eval 'sub EXP_5 () {2014;}' unless defined(&EXP_5);
    eval 'sub EXP_15 () {2037;}' unless defined(&EXP_15);
    eval 'sub CALC_LOAD {
        local($load,$exp,$n) = @_;
	    eval q($load *= $exp; $load += $n*( &FIXED_1-$exp); $load >>=  &FSHIFT;);
    }' unless defined(&CALC_LOAD);
    eval 'sub CT_TO_SECS {
        local($x) = @_;
	    eval q((($x) /  &HZ));
    }' unless defined(&CT_TO_SECS);
    eval 'sub CT_TO_USECS {
        local($x) = @_;
	    eval q(((($x) %  &HZ) * 1000000/ &HZ));
    }' unless defined(&CT_TO_USECS);
    require 'linux/fs.ph';
    require 'linux/time.ph';
    require 'linux/param.ph';
    require 'linux/resource.ph';
    require 'linux/timer.ph';
    require 'asm/processor.ph';
    eval 'sub TASK_RUNNING () {0;}' unless defined(&TASK_RUNNING);
    eval 'sub TASK_INTERRUPTIBLE () {1;}' unless defined(&TASK_INTERRUPTIBLE);
    eval 'sub TASK_UNINTERRUPTIBLE () {2;}' unless defined(&TASK_UNINTERRUPTIBLE);
    eval 'sub TASK_ZOMBIE () {4;}' unless defined(&TASK_ZOMBIE);
    eval 'sub TASK_STOPPED () {8;}' unless defined(&TASK_STOPPED);
    eval 'sub __set_task_state {
        local($tsk, $state_value) = @_;
	    eval q( &do { ($tsk)-> &state = ($state_value); }  &while (0));
    }' unless defined(&__set_task_state);
    if(defined(&CONFIG_SMP)) {
	eval 'sub set_task_state {
	    local($tsk, $state_value) = @_;
    	    eval q( &set_mb(($tsk)-> &state, ($state_value)));
	}' unless defined(&set_task_state);
    } else {
	eval 'sub set_task_state {
	    local($tsk, $state_value) = @_;
    	    eval q( &__set_task_state(($tsk), ($state_value)));
	}' unless defined(&set_task_state);
    }
    eval 'sub __set_current_state {
        local($state_value) = @_;
	    eval q( &do {  ($current->{state}) = ($state_value); }  &while (0));
    }' unless defined(&__set_current_state);
    if(defined(&CONFIG_SMP)) {
	eval 'sub set_current_state {
	    local($state_value) = @_;
    	    eval q( &set_mb( ($current->{state}), ($state_value)));
	}' unless defined(&set_current_state);
    } else {
	eval 'sub set_current_state {
	    local($state_value) = @_;
    	    eval q( &__set_current_state($state_value));
	}' unless defined(&set_current_state);
    }
    eval 'sub SCHED_OTHER () {0;}' unless defined(&SCHED_OTHER);
    eval 'sub SCHED_FIFO () {1;}' unless defined(&SCHED_FIFO);
    eval 'sub SCHED_RR () {2;}' unless defined(&SCHED_RR);
    eval 'sub SCHED_YIELD () {0x10;}' unless defined(&SCHED_YIELD);
}
1;
