require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_SAFE_SAFEVAR_H_)) {
    eval 'sub _SAFE_SAFEVAR_H_ () {1;}' unless defined(&_SAFE_SAFEVAR_H_);
    eval 'sub SAFE_CRK_PARAM_BASE () {0;}' unless defined(&SAFE_CRK_PARAM_BASE);
    eval 'sub SAFE_CRK_PARAM_EXP () {1;}' unless defined(&SAFE_CRK_PARAM_EXP);
    eval 'sub SAFE_CRK_PARAM_MOD () {2;}' unless defined(&SAFE_CRK_PARAM_MOD);
    unless(defined(&SAFE_MAX_NQUEUE)) {
	eval 'sub SAFE_MAX_NQUEUE () {60;}' unless defined(&SAFE_MAX_NQUEUE);
    }
    eval 'sub SAFE_MAX_PART () {64;}' unless defined(&SAFE_MAX_PART);
    eval 'sub SAFE_DMA_BOUNDARY () {0;}' unless defined(&SAFE_DMA_BOUNDARY);
    eval 'sub SAFE_MAX_DSIZE () { &MCLBYTES;}' unless defined(&SAFE_MAX_DSIZE);
    eval 'sub SAFE_MAX_SSIZE () {0xffff;}' unless defined(&SAFE_MAX_SSIZE);
    eval 'sub SAFE_MAX_DMA () {0xfffff;}' unless defined(&SAFE_MAX_DMA);
    eval 'sub SAFE_TOTAL_DPART () {( &SAFE_MAX_NQUEUE *  &SAFE_MAX_PART);}' unless defined(&SAFE_TOTAL_DPART);
    eval 'sub SAFE_TOTAL_SPART () {( &SAFE_MAX_NQUEUE *  &SAFE_MAX_PART);}' unless defined(&SAFE_TOTAL_SPART);
    eval 'sub SAFE_RNG_MAXBUFSIZ () {128;}' unless defined(&SAFE_RNG_MAXBUFSIZ);
    eval 'sub SAFE_CARD {
        my($sid) = @_;
	    eval q(((($sid) & 0xf0000000) >> 28));
    }' unless defined(&SAFE_CARD);
    eval 'sub SAFE_SESSION {
        my($sid) = @_;
	    eval q(( ($sid) & 0xfffffff));
    }' unless defined(&SAFE_SESSION);
    eval 'sub SAFE_SID {
        my($crd, $sesn) = @_;
	    eval q(((($crd) << 28) | (($sesn) & 0xfffffff)));
    }' unless defined(&SAFE_SID);
    if(defined(&_KERNEL)) {
	eval 'sub SAFE_QFLAGS_COPYOUTIV () {0x1;}' unless defined(&SAFE_QFLAGS_COPYOUTIV);
	eval 'sub SAFE_QFLAGS_COPYOUTICV () {0x2;}' unless defined(&SAFE_QFLAGS_COPYOUTICV);
	eval 'sub re_src_m () { ($re_src->{u}->{m});}' unless defined(&re_src_m);
	eval 'sub re_src_io () { ($re_src->{u}->{io});}' unless defined(&re_src_io);
	eval 'sub re_src_map () { ($re_src->{map});}' unless defined(&re_src_map);
	eval 'sub re_src_nsegs () { ($re_src->{map}->{dm_nsegs});}' unless defined(&re_src_nsegs);
	eval 'sub re_src_segs () { ($re_src->{map}->{dm_segs});}' unless defined(&re_src_segs);
	eval 'sub re_src_mapsize () { ($re_src->{map}->{dm_mapsize});}' unless defined(&re_src_mapsize);
	eval 'sub re_dst_m () { ($re_dst->{u}->{m});}' unless defined(&re_dst_m);
	eval 'sub re_dst_io () { ($re_dst->{u}->{io});}' unless defined(&re_dst_io);
	eval 'sub re_dst_map () { ($re_dst->{map});}' unless defined(&re_dst_map);
	eval 'sub re_dst_nsegs () { ($re_dst->{map}->{dm_nsegs});}' unless defined(&re_dst_nsegs);
	eval 'sub re_dst_segs () { ($re_dst->{map}->{dm_segs});}' unless defined(&re_dst_segs);
	eval 'sub re_dst_mapsize () { ($re_dst->{map}->{dm_mapsize});}' unless defined(&re_dst_mapsize);
    }
}
1;
