line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Int64; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
93461
|
use strict; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
283
|
|
4
|
9
|
|
|
9
|
|
31
|
use warnings; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
427
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
9
|
|
|
9
|
|
17
|
our $VERSION = '0.52'; |
8
|
9
|
|
|
|
|
30
|
require XSLoader; |
9
|
9
|
|
|
|
|
5565
|
XSLoader::load('Math::Int64', $VERSION); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
|
48
|
use constant MAX_INT64 => string_to_int64 ( '0x7fff_ffff_ffff_ffff'); |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
718
|
|
13
|
9
|
|
|
9
|
|
33
|
use constant MIN_INT64 => string_to_int64 ('-0x8000_0000_0000_0000'); |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
397
|
|
14
|
9
|
|
|
9
|
|
41
|
use constant MAX_UINT64 => string_to_uint64( '0xffff_ffff_ffff_ffff'); |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
3437
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
require Exporter; |
17
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw(int64 |
19
|
|
|
|
|
|
|
int64_to_number |
20
|
|
|
|
|
|
|
net_to_int64 int64_to_net |
21
|
|
|
|
|
|
|
native_to_int64 int64_to_native |
22
|
|
|
|
|
|
|
string_to_int64 hex_to_int64 |
23
|
|
|
|
|
|
|
BER_to_int64 int64_to_BER |
24
|
|
|
|
|
|
|
int64_to_string int64_to_hex |
25
|
|
|
|
|
|
|
int64_rand |
26
|
|
|
|
|
|
|
int64_srand |
27
|
|
|
|
|
|
|
uint64 |
28
|
|
|
|
|
|
|
uint64_to_number |
29
|
|
|
|
|
|
|
net_to_uint64 uint64_to_net |
30
|
|
|
|
|
|
|
native_to_uint64 uint64_to_native |
31
|
|
|
|
|
|
|
string_to_uint64 hex_to_uint64 |
32
|
|
|
|
|
|
|
BER_to_uint64 uint64_to_BER |
33
|
|
|
|
|
|
|
uint64_to_string uint64_to_hex |
34
|
|
|
|
|
|
|
uint64_rand |
35
|
|
|
|
|
|
|
BER_length |
36
|
|
|
|
|
|
|
MAX_INT64 MIN_INT64 MAX_UINT64 |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my %available_pragmas = map { $_ => 1 } qw(native_if_available |
40
|
|
|
|
|
|
|
die_on_overflow); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub import { |
43
|
9
|
|
|
9
|
|
45
|
my $pkg = shift; |
44
|
9
|
|
|
|
|
10
|
my (%pragmas, @subs, %native); |
45
|
9
|
|
|
|
|
19
|
for (@_) { |
46
|
57
|
100
|
66
|
|
|
151
|
if ($_ =~ /^:(.*)/ and $available_pragmas{$1}) { |
47
|
2
|
|
|
|
|
5
|
$pragmas{$1} = 1 |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
55
|
|
|
|
|
65
|
push @subs, $_; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
9
|
50
|
|
|
|
25
|
if ($pragmas{die_on_overflow}) { |
55
|
0
|
|
|
|
|
0
|
require Math::Int64::die_on_overflow; |
56
|
0
|
|
|
|
|
0
|
Math::Int64::die_on_overflow->import; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
9
|
100
|
|
|
|
28
|
if ($pragmas{native_if_available}) { |
60
|
2
|
|
|
|
|
636
|
require Math::Int64::native_if_available; |
61
|
2
|
|
|
|
|
12
|
Math::Int64::native_if_available->import; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
10560
|
Math::Int64->export_to_level(1, $pkg, @subs); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
9
|
|
|
|
|
84
|
use overload ( '+' => \&_add, |
68
|
|
|
|
|
|
|
'+=' => \&_add, |
69
|
|
|
|
|
|
|
'-' => \&_sub, |
70
|
|
|
|
|
|
|
'-=' => \&_sub, |
71
|
|
|
|
|
|
|
'*' => \&_mul, |
72
|
|
|
|
|
|
|
'*=' => \&_mul, |
73
|
|
|
|
|
|
|
'**' => \&_pow, |
74
|
|
|
|
|
|
|
'**=' => \&_pow, |
75
|
|
|
|
|
|
|
'/' => \&_div, |
76
|
|
|
|
|
|
|
'/=' => \&_div, |
77
|
|
|
|
|
|
|
'%' => \&_rest, |
78
|
|
|
|
|
|
|
'%=' => \&_rest, |
79
|
|
|
|
|
|
|
'neg' => \&_neg, |
80
|
|
|
|
|
|
|
'++' => \&_inc, |
81
|
|
|
|
|
|
|
'--' => \&_dec, |
82
|
|
|
|
|
|
|
'!' => \&_not, |
83
|
|
|
|
|
|
|
'~' => \&_bnot, |
84
|
|
|
|
|
|
|
'&' => \&_and, |
85
|
|
|
|
|
|
|
'|' => \&_or, |
86
|
|
|
|
|
|
|
'^' => \&_xor, |
87
|
|
|
|
|
|
|
'<<' => \&_left, |
88
|
|
|
|
|
|
|
'>>' => \&_right, |
89
|
|
|
|
|
|
|
'<=>' => \&_spaceship, |
90
|
|
|
|
|
|
|
'>' => \&_gtn, |
91
|
|
|
|
|
|
|
'<' => \&_ltn, |
92
|
|
|
|
|
|
|
'>=' => \&_gen, |
93
|
|
|
|
|
|
|
'<=' => \&_len, |
94
|
|
|
|
|
|
|
'==' => \&_eqn, |
95
|
|
|
|
|
|
|
'!=' => \&_nen, |
96
|
|
|
|
|
|
|
'bool' => \&_bool, |
97
|
|
|
|
|
|
|
'0+' => \&_number, |
98
|
|
|
|
|
|
|
'""' => \&_string, |
99
|
|
|
|
|
|
|
'=' => \&_clone, |
100
|
9
|
|
|
9
|
|
9759
|
fallback => 1 ); |
|
9
|
|
|
|
|
7525
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
package # hide from PAUSE since it also has its own .pm file |
103
|
|
|
|
|
|
|
Math::UInt64; |
104
|
9
|
|
|
|
|
65
|
use overload ( '+' => \&_add, |
105
|
|
|
|
|
|
|
'+=' => \&_add, |
106
|
|
|
|
|
|
|
'-' => \&_sub, |
107
|
|
|
|
|
|
|
'-=' => \&_sub, |
108
|
|
|
|
|
|
|
'*' => \&_mul, |
109
|
|
|
|
|
|
|
'*=' => \&_mul, |
110
|
|
|
|
|
|
|
'**' => \&_pow, |
111
|
|
|
|
|
|
|
'**=' => \&_pow, |
112
|
|
|
|
|
|
|
'/' => \&_div, |
113
|
|
|
|
|
|
|
'/=' => \&_div, |
114
|
|
|
|
|
|
|
'%' => \&_rest, |
115
|
|
|
|
|
|
|
'%=' => \&_rest, |
116
|
|
|
|
|
|
|
'neg' => \&_neg, |
117
|
|
|
|
|
|
|
'++' => \&_inc, |
118
|
|
|
|
|
|
|
'--' => \&_dec, |
119
|
|
|
|
|
|
|
'!' => \&_not, |
120
|
|
|
|
|
|
|
'~' => \&_bnot, |
121
|
|
|
|
|
|
|
'&' => \&_and, |
122
|
|
|
|
|
|
|
'|' => \&_or, |
123
|
|
|
|
|
|
|
'^' => \&_xor, |
124
|
|
|
|
|
|
|
'<<' => \&_left, |
125
|
|
|
|
|
|
|
'>>' => \&_right, |
126
|
|
|
|
|
|
|
'<=>' => \&_spaceship, |
127
|
|
|
|
|
|
|
'>' => \&_gtn, |
128
|
|
|
|
|
|
|
'<' => \&_ltn, |
129
|
|
|
|
|
|
|
'>=' => \&_gen, |
130
|
|
|
|
|
|
|
'<=' => \&_len, |
131
|
|
|
|
|
|
|
'==' => \&_eqn, |
132
|
|
|
|
|
|
|
'!=' => \&_nen, |
133
|
|
|
|
|
|
|
'bool' => \&_bool, |
134
|
|
|
|
|
|
|
'0+' => \&_number, |
135
|
|
|
|
|
|
|
'""' => \&_string, |
136
|
|
|
|
|
|
|
'=' => \&_clone, |
137
|
9
|
|
|
9
|
|
3569
|
fallback => 1 ); |
|
9
|
|
|
|
|
12
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# ABSTRACT: Manipulate 64 bits integers in Perl |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
__END__ |