Perl FAQ 5.12: Where do I get the include files to do ioctl() or syscall()? [h2ph]

Perl FAQ 5.12

Where do I get the include files to do ioctl() or syscall()? [h2ph]

[Note: as of perl5, you probably want to just use h2xs instead, at least, if your system supports dynamic loading.]

These are generated from your system's C include files using the h2ph script (once called makelib) from the Perl source directory. This will make files containing subroutine definitions, like &SYS_getitimer, which you can use as arguments to your function.

You might also look at the h2pl subdirectory in the Perl source for how to convert these to forms like $SYS_getitimer; there are both advantages and disadvantages to this. Read the notes in that directory for details. In both cases, you may well have to fiddle with it to make these work; it depends how funny-looking your system's C include files happen to be.

If you're trying to get at C structures, then you should take a look at using c2ph, which uses debugger ``stab'' entries generated by your BSD or GNU C compiler to produce machine-independent perl definitions for the data structures. This allows to you avoid hardcoding structure layouts, types, padding, or sizes, greatly enhancing portability. c2ph comes with the perl distribution. On an SCO system, GCC only has COFF debugging support by default, so you'll have to build GCC 2.1 with DBX_DEBUGGING_INFO defined, and use -gstabs to get c2ph to work there.

See the file /pub/perl/info/ch2ph on convex.com via anon ftp for more traps and tips on this process.


Other resources at this site: