require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_DISKLABEL_H_)) {
    eval 'sub _SYS_DISKLABEL_H_ () {1;}' unless defined(&_SYS_DISKLABEL_H_);
    unless(defined(&_LOCORE)) {
	require 'sys/types.ph';
    }
    if((defined(&HAVE_NBTOOL_CONFIG_H) ? &HAVE_NBTOOL_CONFIG_H : undef)) {
	undef(&MAXPARTITIONS) if defined(&MAXPARTITIONS);
	eval 'sub MAXPARTITIONS () { &MAXMAXPARTITIONS;}' unless defined(&MAXPARTITIONS);
    } else {
	require 'machine/disklabel.ph';
    }
    eval 'sub MAXMAXPARTITIONS () {22;}' unless defined(&MAXMAXPARTITIONS);
    if((defined(&MAXPARTITIONS) ? &MAXPARTITIONS : undef) > (defined(&MAXMAXPARTITIONS) ? &MAXMAXPARTITIONS : undef)) {
	warn("beware\:\ MAXPARTITIONS\ bigger\ than\ MAXMAXPARTITIONS");
    }
    if(defined(&_KERNEL)  && defined(&__HAVE_OLD_DISKLABEL)  && ((defined(&MAXPARTITIONS) ? &MAXPARTITIONS : undef) < (defined(&OLDMAXPARTITIONS) ? &OLDMAXPARTITIONS : undef))) {
	die("can only grow disklabel size");
    }
    unless(defined(&__HAVE_OLD_DISKLABEL)) {
	if(!(defined(&HAVE_NBTOOL_CONFIG_H) ? &HAVE_NBTOOL_CONFIG_H : undef)) {
	    eval 'sub DISKUNIT {
	        my($dev) = @_;
    		eval q(( &minor($dev) /  &MAXPARTITIONS));
	    }' unless defined(&DISKUNIT);
	    eval 'sub DISKPART {
	        my($dev) = @_;
    		eval q(( &minor($dev) %  &MAXPARTITIONS));
	    }' unless defined(&DISKPART);
	    eval 'sub DISKMINOR {
	        my($unit, $part) = @_;
    		eval q(((($unit) *  &MAXPARTITIONS) + ($part)));
	    }' unless defined(&DISKMINOR);
	}
    }
    eval 'sub MAKEDISKDEV {
        my($maj, $unit, $part) = @_;
	    eval q(( &makedev(($maj),  &DISKMINOR(($unit), ($part)))));
    }' unless defined(&MAKEDISKDEV);
    eval 'sub DISKMAGIC () {(( &uint32_t)0x82564557);}' unless defined(&DISKMAGIC);
    unless(defined(&_LOCORE)) {
	eval 'sub p_fsize () { ($__partition_u2->{fsize});}' unless defined(&p_fsize);
	eval 'sub p_cdsession () { ($__partition_u2->{cdsession});}' unless defined(&p_cdsession);
	eval 'sub p_cpg () { ($__partition_u1->{cpg});}' unless defined(&p_cpg);
	eval 'sub p_sgs () { ($__partition_u1->{sgs});}' unless defined(&p_sgs);
	eval 'sub d_packname () { ($d_un->{un_d_packname});}' unless defined(&d_packname);
	eval 'sub d_boot0 () { ($d_un->{un_b}->{un_d_boot0});}' unless defined(&d_boot0);
	eval 'sub d_boot1 () { ($d_un->{un_b}->{un_d_boot1});}' unless defined(&d_boot1);
	eval 'sub NDDATA () {5;}' unless defined(&NDDATA);
	eval 'sub NSPARE () {5;}' unless defined(&NSPARE);
	if(defined(&__HAVE_OLD_DISKLABEL)  && !(defined(&HAVE_NBTOOL_CONFIG_H) ? &HAVE_NBTOOL_CONFIG_H : undef)) {
	}
    } else {
    }
    unless(defined(&lint)) {
	eval 'sub ARRAY_INIT {
	    my($element,$value) = @_;
    	    eval q([$element]=$value);
	}' unless defined(&ARRAY_INIT);
    } else {
	eval 'sub ARRAY_INIT {
	    my($element,$value) = @_;
    	    eval q($value);
	}' unless defined(&ARRAY_INIT);
    }
    eval 'sub DKTYPE_DEFN {
        my($x) = @_;
	    eval q($x( &UNKNOWN, 0, \\"unknown\\") $x( &SMD, 1, \\"SMD\\") $x( &MSCP, 2, \\"MSCP\\") $x( &DEC, 3, \\"old DEC\\") $x( &SCSI, 4, \\"SCSI\\") $x( &ESDI, 5, \\"ESDI\\") $x( &ST506, 6, \\"ST506\\") $x( &HPIB, 7, \\"HP-IB\\") $x( &HPFL, 8, \\"HP-FL\\") $x( &TYPE_9, 9, \\"type 9\\") $x( &FLOPPY, 10, \\"floppy\\") $x( &CCD, 11, \\"ccd\\") $x( &VND, 12, \\"vnd\\") $x( &ATAPI, 13, \\"ATAPI\\") $x( &RAID, 14, \\"RAID\\") $x( &LD, 15, \\"ld\\") $x( &JFS2, 16, \\"jfs\\") $x( &CGD, 17, \\"cgd\\") $x( &VINUM, 18, \\"vinum\\") $x( &FLASH, 19, \\"flash\\") $x( &DM, 20, \\"dm\\") $x( &RUMPD, 21, \\"rumpd\\") $x( &MD, 22, \\"md\\"));
    }' unless defined(&DKTYPE_DEFN);
    unless(defined(&_LOCORE)) {
	eval 'sub DKTYPE_NUMS {
	    my($tag, $number, $name) = @_;
    	    eval q( &__CONCAT( &DKTYPE_,$tag=$number),);
	}' unless defined(&DKTYPE_NUMS);
	unless(defined(&DKTYPE_ENUMNAME)) {
	    eval 'sub DKTYPE_ENUMNAME () {1;}' unless defined(&DKTYPE_ENUMNAME);
	}
	undef(&DKTYPE_NUMS) if defined(&DKTYPE_NUMS);
    }
    if(defined(&DKTYPENAMES)) {
	eval 'sub DKTYPE_NAMES {
	    my($tag, $number, $name) = @_;
    	    eval q( &ARRAY_INIT($number,$name),);
	}' unless defined(&DKTYPE_NAMES);
	undef(&DKTYPE_NAMES) if defined(&DKTYPE_NAMES);
    }
    eval 'sub FSTYPE_DEFN {
        my($x) = @_;
	    eval q($x( &UNUSED, 0, \\"unused\\",  &NULL,  &NULL) $x( &SWAP, 1, \\"swap\\",  &NULL,  &NULL) $x( &V6, 2, \\"Version 6\\",  &NULL,  &NULL) $x( &V7, 3, \\"Version 7\\", \\"v7fs\\", \\"v7fs\\") $x( &SYSV, 4, \\"System V\\",  &NULL,  &NULL) $x( &V71K, 5, \\"4.1BSD\\",  &NULL,  &NULL) $x( &V8, 6, \\"Eighth Edition\\", &NULL,  &NULL) $x( &BSDFFS, 7, \\"4.2BSD\\", \\"ffs\\", \\"ffs\\") $x( &MSDOS, 8, \\"MSDOS\\", \\"msdos\\", \\"msdos\\") $x( &BSDLFS, 9, \\"4.4LFS\\", \\"lfs\\", \\"lfs\\") $x( &OTHER, 10, \\"unknown\\",  &NULL,  &NULL) $x( &HPFS, 11, \\"HPFS\\",  &NULL,  &NULL) $x( &ISO9660, 12, \\"ISO9660\\",  &NULL, \\"cd9660\\") $x( &BOOT, 13, \\"boot\\",  &NULL,  &NULL) $x( &ADOS, 14, \\"ADOS\\",  &NULL, \\"ados\\") $x( &HFS, 15, \\"HFS\\",  &NULL,  &NULL) $x( &FILECORE,16, \\"FILECORE\\",  &NULL, \\"filecore\\") $x( &EX2FS, 17, \\"Linux Ext2\\",\\"ext2fs\\",\\"ext2fs\\") $x( &NTFS, 18, \\"NTFS\\",  &NULL, \\"ntfs\\") $x( &RAID, 19, \\"RAID\\",  &NULL,  &NULL) $x( &CCD, 20, \\"ccd\\",  &NULL,  &NULL) $x( &JFS2, 21, \\"jfs\\",  &NULL,  &NULL) $x( &APPLEUFS,22, \\"Apple UFS\\", \\"ffs\\", \\"ffs\\") $x( &VINUM, 23, \\"vinum\\",  &NULL,  &NULL) $x( &UDF, 24, \\"UDF\\",  &NULL, \\"udf\\") $x( &SYSVBFS, 25, \\"SysVBFS\\",  &NULL, \\"sysvbfs\\") $x( &EFS, 26, \\"EFS\\",  &NULL, \\"efs\\") $x( &NILFS, 27, \\"NiLFS\\",  &NULL, \\"nilfs\\") $x( &CGD, 28, \\"cgd\\",  &NULL,  &NULL) $x( &MINIXFS3,29, \\"MINIX FSv3\\",  &NULL,  &NULL) $x( &VMKCORE, 30, \\"VMware vmkcore\\",  &NULL,  &NULL) $x( &VMFS, 31, \\"VMware VMFS\\",  &NULL,  &NULL) $x( &VMWRESV, 32, \\"VMware Reserved\\",  &NULL,  &NULL) $x( &ZFS, 33, \\"ZFS\\",  &NULL, \\"zfs\\"));
    }' unless defined(&FSTYPE_DEFN);
    unless(defined(&_LOCORE)) {
	eval 'sub FS_TYPENUMS {
	    my($tag, $number, $name, $fsck, $mount) = @_;
    	    eval q( &__CONCAT( &FS_,$tag=$number),);
	}' unless defined(&FS_TYPENUMS);
	unless(defined(&FSTYPE_ENUMNAME)) {
	    eval 'sub FSTYPE_ENUMNAME () {1;}' unless defined(&FSTYPE_ENUMNAME);
	}
	undef(&FS_TYPENUMS) if defined(&FS_TYPENUMS);
    }
    if(defined(&FSTYPENAMES)) {
	eval 'sub FS_TYPENAMES {
	    my($tag, $number, $name, $fsck, $mount) = @_;
    	    eval q( &ARRAY_INIT($number,$name),);
	}' unless defined(&FS_TYPENAMES);
	undef(&FS_TYPENAMES) if defined(&FS_TYPENAMES);
    }
    if(defined(&FSCKNAMES)) {
	eval 'sub FS_FSCKNAMES {
	    my($tag, $number, $name, $fsck, $mount) = @_;
    	    eval q( &ARRAY_INIT($number,$fsck),);
	}' unless defined(&FS_FSCKNAMES);
	undef(&FS_FSCKNAMES) if defined(&FS_FSCKNAMES);
	eval 'sub FSMAXNAMES () { &FSMAXTYPES;}' unless defined(&FSMAXNAMES);
    }
    if(defined(&MOUNTNAMES)) {
	eval 'sub FS_MOUNTNAMES {
	    my($tag, $number, $name, $fsck, $mount) = @_;
    	    eval q( &ARRAY_INIT($number,$mount),);
	}' unless defined(&FS_MOUNTNAMES);
	undef(&FS_MOUNTNAMES) if defined(&FS_MOUNTNAMES);
	eval 'sub FSMAXMOUNTNAMES () { &FSMAXTYPES;}' unless defined(&FSMAXMOUNTNAMES);
    }
    eval 'sub D_REMOVABLE () {0x1;}' unless defined(&D_REMOVABLE);
    eval 'sub D_ECC () {0x2;}' unless defined(&D_ECC);
    eval 'sub D_BADSECT () {0x4;}' unless defined(&D_BADSECT);
    eval 'sub D_RAMDISK () {0x8;}' unless defined(&D_RAMDISK);
    eval 'sub D_CHAIN () {0x10;}' unless defined(&D_CHAIN);
    eval 'sub D_SCSI_MMC () {0x20;}' unless defined(&D_SCSI_MMC);
    eval 'sub d_smdflags () { $d_drivedata[0];}' unless defined(&d_smdflags);
    eval 'sub D_SSE () {0x1;}' unless defined(&D_SSE);
    eval 'sub d_mindist () { $d_drivedata[1];}' unless defined(&d_mindist);
    eval 'sub d_maxdist () { $d_drivedata[2];}' unless defined(&d_maxdist);
    eval 'sub d_sdist () { $d_drivedata[3];}' unless defined(&d_sdist);
    eval 'sub d_precompcyl () { $d_drivedata[0];}' unless defined(&d_precompcyl);
    eval 'sub d_gap3 () { $d_drivedata[1];}' unless defined(&d_gap3);
    eval 'sub d_blind () { $d_drivedata[0];}' unless defined(&d_blind);
    unless(defined(&_LOCORE)) {
	if(defined(&_KERNEL)) {
	}
    }
    if(!defined(&_KERNEL)  && !defined(&_LOCORE)) {
	require 'sys/cdefs.ph';
    }
}
1;
