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