require '_h2ph_pre.ph';

unless(defined(&_HFS_SYSDEP_H)) {
    eval 'sub _HFS_SYSDEP_H () {1;}' unless defined(&_HFS_SYSDEP_H);
    require 'linux/slab.ph';
    require 'linux/types.ph';
    require 'linux/locks.ph';
    require 'linux/fs.ph';
    require 'asm/byteorder.ph';
    require 'asm/unaligned.ph';
    undef(&offsetof) if defined(&offsetof);
    eval 'sub offsetof {
        local($TYPE, $MEMB) = @_;
	    eval q(( (0)->$MEMB));
    }' unless defined(&offsetof);
    eval 'sub hfs_warn () {( &format,  &args...)  &printk( &KERN_WARNING  &format ,   &args);}' unless defined(&hfs_warn);
    eval 'sub hfs_error () {( &format,  &args...)  &printk( &KERN_ERR  &format ,   &args);}' unless defined(&hfs_error);
    if(defined( &DEBUG_ALL) || defined( &DEBUG_MEM)) {
    }
    if(defined( &DEBUG_ALL) || defined( &DEBUG_MEM)) {
    }
    if(defined( &DEBUG_ALL) || defined( &DEBUG_MEM)) {
    }
    eval 'sub HFS_BAD_BUFFER () { &NULL;}' unless defined(&HFS_BAD_BUFFER);
    undef(&BITNR) if defined(&BITNR);
    if(defined( &__BIG_ENDIAN)) {
	eval 'sub BITNR {
	    local($X) = @_;
    	    eval q((($X)^31));
	}' unless defined(&BITNR);
	if(!defined( &__constant_htonl)) {
	    eval 'sub __constant_htonl {
	        local($x) = @_;
    		eval q(($x));
	    }' unless defined(&__constant_htonl);
	}
	if(!defined( &__constant_htons)) {
	    eval 'sub __constant_htons {
	        local($x) = @_;
    		eval q(($x));
	    }' unless defined(&__constant_htons);
	}
    }
 elsif(defined( &__LITTLE_ENDIAN)) {
	eval 'sub BITNR {
	    local($X) = @_;
    	    eval q((($X)^7));
	}' unless defined(&BITNR);
	if(!defined( &__constant_htonl)) {
	    eval 'sub __constant_htonl {
	        local($x) = @_;
    		eval q((((( & 0xff) << 24) | (( & 0xff00) << 8) | (( & 0xff0000) >> 8) | ((($x) & 0xff000000) >> 24))));
	    }' unless defined(&__constant_htonl);
	}
	if(!defined( &__constant_htons)) {
	    eval 'sub __constant_htons {
	        local($x) = @_;
    		eval q((((( & 0xff) << 8) | ((($x) & 0xff00) >> 8))));
	    }' unless defined(&__constant_htons);
	}
    } else {
	die("Don't know if bytes are big- or little-endian!");
    }
    undef(&BITNR) if defined(&BITNR);
    eval 'sub hfs_get_hs {
        local($addr) = @_;
	    eval q( &ntohs(*(($addr))));
    }' unless defined(&hfs_get_hs);
    eval 'sub hfs_get_ns {
        local($addr) = @_;
	    eval q((*(($addr))));
    }' unless defined(&hfs_get_ns);
    eval 'sub hfs_get_hl {
        local($addr) = @_;
	    eval q( &ntohl( &get_unaligned(($addr))));
    }' unless defined(&hfs_get_hl);
    eval 'sub hfs_get_nl {
        local($addr) = @_;
	    eval q( &get_unaligned(($addr)));
    }' unless defined(&hfs_get_nl);
    eval 'sub hfs_get_ahl {
        local($addr) = @_;
	    eval q( &ntohl(*(($addr))));
    }' unless defined(&hfs_get_ahl);
    eval 'sub hfs_get_anl {
        local($addr) = @_;
	    eval q((*(($addr))));
    }' unless defined(&hfs_get_anl);
    eval 'sub hfs_put_hs {
        local($val, $addr) = @_;
	    eval q(((*(($addr)) =  &ntohs($val))));
    }' unless defined(&hfs_put_hs);
    eval 'sub hfs_put_ns {
        local($val, $addr) = @_;
	    eval q(((*(($addr)) = ($val))));
    }' unless defined(&hfs_put_ns);
    eval 'sub hfs_put_hl {
        local($val, $addr) = @_;
	    eval q( &put_unaligned( &htonl, ($addr)));
    }' unless defined(&hfs_put_hl);
    eval 'sub hfs_put_nl {
        local($val, $addr) = @_;
	    eval q( &put_unaligned(, ($addr)));
    }' unless defined(&hfs_put_nl);
    eval 'sub hfs_put_ahl {
        local($val, $addr) = @_;
	    eval q(((*(($addr)) =  &ntohl($val))));
    }' unless defined(&hfs_put_ahl);
    eval 'sub hfs_put_anl {
        local($val, $addr) = @_;
	    eval q(((*(($addr)) = ($val))));
    }' unless defined(&hfs_put_anl);
}
1;
