1[This file of Tom Christiansen's has been edited to change makelib to h2ph
   2and .h to .ph where appropriate--law.]
   4This directory contains files to help you convert the *.ph files generated my
   5h2ph out of the perl source directory into *.pl files with all the
   6indirection of the subroutine calls removed.  The .ph version will be more
   7safely portable, because if something isn't defined on the new system, like
   8&TIOCGETP, then you'll get a fatal run-time error on the system lacking that
   9function.  Using the .pl version means that the subsequent scripts will give
  10you a 0 $TIOCGETP and God only knows what may then happen.   Still, I like the stuff because they're faster to load.
  13FIrst, you need to run h2ph on things like sys/ioctl.h to get stuff
  14into the perl library directory, often /usr/local/lib/perl.  For example,
  15    # h2ph sys/ioctl.h
  16takes /usr/include/sys/ioctl.h as input and writes (without i/o redirection)
  17the file /usr/local/lib/perl/sys/, which looks like this
  19    eval 'sub TIOCM_RTS {0004;}';
  20    eval 'sub TIOCM_ST {0010;}';
  21    eval 'sub TIOCM_SR {0020;}';
  22    eval 'sub TIOCM_CTS {0040;}';
  23    eval 'sub TIOCM_CAR {0100;}';
  25and much worse, rather than what Larry's from the perl source dir has, 
  26which is:
  28    $TIOCM_RTS = 0004;
  29    $TIOCM_ST = 0010;
  30    $TIOCM_SR = 0020;
  31    $TIOCM_CTS = 0040;
  32    $TIOCM_CAR = 0100;
  34[Workaround for fixed bug in makedir/h2ph deleted--law.]
  36The more complicated ioctl subs look like this:
  38    eval 'sub TIOCGSIZE {&TIOCGWINSZ;}';
  39    eval 'sub TIOCGWINSZ {&_IOR("t", 104, \'struct winsize\');}';
  40    eval 'sub TIOCSETD {&_IOW("t", 1, \'int\');}';
  41    eval 'sub TIOCGETP {&_IOR("t", 8,\'struct sgttyb\');}';
  43The _IO[RW] routines use a %sizeof array, which (presumably) 
  44is keyed on the type name with the value being the size in bytes.  
  46To build %sizeof, try running this in this directory:
  48    % ./getioctlsizes 
  50Which will tell you which things the %sizeof array needs
  51to hold.  You can try to build a file with:
  53    % ./getioctlsizes | ./mksizes >
  55Note that mksizes hardcodes the #include files for all the types, so it will
  56probably require customization.  Once you have, install it in the
  57perl library directory.  Run my tcbreak script to see whether you can do
  58ioctls in perl now.  You'll get some kind of fatal run-time error if you
  59can't.  That script should be included in this directory.
  61If this works well, now you can try to convert the *.ph files into
  62*.pl files.  Try this:
  64    foreach file ( sys/{,} )
  65        ./mkvars $file > t/$
  66    end
  68The last one will be the hardest.  If it works, should be able to 
  69run tcbreak2 and have it work the same as tcbreak.
  71Good luck.
  72 kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.