| 1 | # File: Itimer.pm | ||||||||||
| 2 | # Author: Daniel Hagerty, hag@linnaean.org | ||||||||||
| 3 | # Date: Sun Jul 4 17:05:49 1999 | ||||||||||
| 4 | # Description: Perl interface to BSD derived {g,s}etitimer functions | ||||||||||
| 5 | # | ||||||||||
| 6 | # Copyright (c) 1999 Daniel Hagerty. All rights reserved. This program | ||||||||||
| 7 | # is free software; you can redistribute it and/or modify it under the | ||||||||||
| 8 | # same terms as Perl itself. | ||||||||||
| 9 | # | ||||||||||
| 10 | # $Id: Itimer.pm,v 1.1 1999/07/06 02:56:10 hag Exp $ | ||||||||||
| 11 | |||||||||||
| 12 | package BSD::Itimer; | ||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | ▶ | use DynaLoader; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use AutoLoader; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | ### | ||||||||||
| 24 | |||||||||||
| 25 | # This version number is incremented explicitly by the human. | ||||||||||
| 26 | 1 | $VERSION = '0.8'; | |||||||||
| 27 | |||||||||||
| 28 | 1 | @ISA = qw(Exporter DynaLoader); | |||||||||
| 29 | # Items to export into callers namespace by default. Note: do not export | ||||||||||
| 30 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||
| 31 | # Do not simply export all your public functions/methods/constants. | ||||||||||
| 32 | 1 | @EXPORT = qw( | |||||||||
| 33 | ITIMER_PROF | ||||||||||
| 34 | ITIMER_REAL | ||||||||||
| 35 | ITIMER_REALPROF | ||||||||||
| 36 | ITIMER_VIRTUAL | ||||||||||
| 37 | getitimer | ||||||||||
| 38 | setitimer | ||||||||||
| 39 | ); | ||||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: called CC=5 SCAR=18.4
| |||||||||||
| 42 | # This AUTOLOAD is used to 'autoload' constants from the constant() | ||||||||||
| 43 | # XS function. If a constant is not found then control is passed | ||||||||||
| 44 | # to the AUTOLOAD in AutoLoader. | ||||||||||
| 45 | |||||||||||
| 46 | 1 | my $constname; | |||||||||
| 47 | 1 | ($constname = $AUTOLOAD) =~ s/.*:://; | |||||||||
| 48 | 1 | ▶ | croak "& not defined" if $constname eq 'constant'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | ▶ | my $val = constant($constname, @_ ? $_[0] : 0); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 1 | ▶ | if ($! != 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | ▶ | if ($! =~ /Invalid/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | $AutoLoader::AUTOLOAD = $AUTOLOAD; | |||||||||
| 53 | 0 | goto &AutoLoader::AUTOLOAD; | |||||||||
| 54 | } | ||||||||||
| 55 | else { | ||||||||||
| 56 | 0 | croak "Your vendor has not defined BSD::Itimer macro $constname"; | |||||||||
| 57 | } | ||||||||||
| 58 | } | ||||||||||
| 59 | { | ||||||||||
| 60 | 1 | ▶ | no strict "refs"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 61 | 1 | ▶ | *$AUTOLOAD = sub { $val }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 62 | } | ||||||||||
| 63 | 1 | goto &$AUTOLOAD; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 1 | bootstrap BSD::Itimer $VERSION; | |||||||||
| 67 | |||||||||||
| 68 | # Preloaded methods go here. | ||||||||||
| 69 | |||||||||||
| 70 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||
| 71 | |||||||||||
| 72 | 1 | 1; | |||||||||
| 73 | __END__ | ||||||||||