Print this page
3900 illumos will not build against gcc compiled perl
4723 Remove unused perl extensions
Reviewed by: Keith Wesolowski <keith.wesolowski@joyent.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/perl/contrib/Sun/Solaris/Lgrp/Lgrp.pm
+++ new/usr/src/cmd/perl/contrib/Sun/Solaris/Lgrp/Lgrp.pm
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # The contents of this file are subject to the terms of the
5 5 # Common Development and Distribution License (the "License").
6 6 # You may not use this file except in compliance with the License.
7 7 #
8 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 # or http://www.opensolaris.org/os/licensing.
10 10 # See the License for the specific language governing permissions
11 11 # and limitations under the License.
12 12 #
13 13 # When distributing Covered Code, include this CDDL HEADER in each
14 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 # If applicable, add the following below this CDDL HEADER, with the
16 16 # fields enclosed by brackets "[]" replaced with your own identifying
17 17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 18 #
19 19 # CDDL HEADER END
20 20 #
21 21
22 22 #
23 23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 +# Copyright (c) 2014 Racktop Systems.
25 26 #
26 27
27 28 #
28 29 # Lgrp.pm provides procedural and object-oriented interface to the Solaris
29 30 # liblgrp(3LIB) library.
30 31 #
31 32
32 33
33 -require 5.8.4;
34 +require 5.0010;
34 35 use strict;
35 36 use warnings;
36 37 use Carp;
37 38
38 39 package Sun::Solaris::Lgrp;
39 40
40 41 our $VERSION = '1.1';
41 42 use XSLoader;
42 43 XSLoader::load(__PACKAGE__, $VERSION);
43 44
44 45 require Exporter;
45 46
46 47 our @ISA = qw(Exporter);
47 48
48 49 our (@EXPORT_OK, %EXPORT_TAGS);
49 50
50 51 # Things to export
51 52 my @lgrp_constants = qw(LGRP_AFF_NONE LGRP_AFF_STRONG LGRP_AFF_WEAK
52 53 LGRP_CONTENT_DIRECT LGRP_CONTENT_HIERARCHY
53 54 LGRP_MEM_SZ_FREE LGRP_MEM_SZ_INSTALLED LGRP_VER_CURRENT
54 55 LGRP_VER_NONE LGRP_VIEW_CALLER
55 56 LGRP_VIEW_OS LGRP_NONE
56 57 LGRP_RSRC_CPU LGRP_RSRC_MEM
57 58 LGRP_CONTENT_ALL LGRP_LAT_CPU_TO_MEM
58 59 );
59 60
60 61 my @proc_constants = qw(P_PID P_LWPID P_MYID);
61 62
62 63 my @constants = (@lgrp_constants, @proc_constants);
63 64
64 65 my @functions = qw(lgrp_affinity_get lgrp_affinity_set
65 66 lgrp_children lgrp_cookie_stale lgrp_cpus lgrp_fini
66 67 lgrp_home lgrp_init lgrp_latency lgrp_latency_cookie
67 68 lgrp_mem_size lgrp_nlgrps lgrp_parents
68 69 lgrp_root lgrp_version lgrp_view lgrp_resources
69 70 lgrp_isleaf lgrp_lgrps lgrp_leaves);
70 71
71 72 my @all = (@constants, @functions);
72 73
73 74 # Define symbolic names for various subsets of export lists
74 75 %EXPORT_TAGS = ('CONSTANTS' => \@constants,
75 76 'LGRP_CONSTANTS' => \@lgrp_constants,
76 77 'PROC_CONSTANTS' => \@proc_constants,
77 78 'FUNCTIONS' => \@functions,
78 79 'ALL' => \@all);
79 80
80 81 # Define things that are ok ot export.
81 82 @EXPORT_OK = ( @{ $EXPORT_TAGS{'ALL'} } );
82 83
83 84 #
84 85 # _usage(): print error message and terminate the program.
85 86 #
86 87 sub _usage
87 88 {
88 89 my $msg = shift;
89 90 Carp::croak "Usage: Sun::Solaris::Lgrp::$msg";
90 91 }
91 92
92 93 #
93 94 # lgrp_isleaf($cookie, $lgrp)
94 95 # Returns T if lgrp is leaf, F otherwise.
95 96 #
96 97 sub lgrp_isleaf
97 98 {
98 99 scalar @_ == 2 or _usage "lgrp_isleaf(cookie, lgrp)";
99 100 return (!lgrp_children(shift, shift));
100 101 }
101 102
102 103 #
103 104 # lgrp_lgrps($cookie, [$lgrp])
104 105 # Returns: list of lgrps in a subtree starting from $lgrp.
105 106 # If $root is not specified, use lgrp_root.
106 107 # undef on failure.
107 108 sub lgrp_lgrps
108 109 {
109 110 scalar @_ > 0 or _usage("lgrp_lgrps(cookie, [lgrp])");
110 111 my $cookie = shift;
111 112 my $root = shift;
112 113 $root = lgrp_root($cookie) unless defined $root;
113 114 return unless defined $root;
114 115 my @children = lgrp_children($cookie, $root);
115 116 my @result;
116 117
117 118 #
118 119 # Concatenate root with subtrees for every children. Every subtree is
119 120 # obtained by calling lgrp_lgrps recursively with each of the children
120 121 # as the argument.
121 122 #
122 123 @result = @children ?
123 124 ($root, map {lgrp_lgrps($cookie, $_)} @children) :
124 125 ($root);
125 126 return (wantarray ? @result : scalar @result);
126 127 }
127 128
128 129 #
129 130 # lgrp_leaves($cookie, [$lgrp])
130 131 # Returns: list of leaves in the hierarchy starting from $lgrp.
131 132 # If $lgrp is not specified, use lgrp_root.
132 133 # undef on failure.
133 134 #
134 135 sub lgrp_leaves
135 136 {
136 137 scalar @_ > 0 or _usage("lgrp_leaves(cookie, [lgrp])");
137 138 my $cookie = shift;
138 139 my $root = shift;
139 140 $root = lgrp_root($cookie) unless defined $root;
140 141 return unless defined $root;
141 142 my @result = grep {
142 143 lgrp_isleaf($cookie, $_)
143 144 } lgrp_lgrps($cookie, $root);
144 145 return (wantarray ? @result : scalar @result);
145 146 }
146 147
147 148 ######################################################################
148 149 # Object-Oriented interface.
149 150 ######################################################################
150 151
151 152 #
152 153 # cookie: extract cookie from the argument.
153 154 # If the argument is scalar, it is the cookie itself, otherwise it is the
154 155 # reference to the object and the cookie value is in $self->{COOKIE}.
155 156 #
156 157 sub cookie
157 158 {
158 159 my $self = shift;
159 160 return ((ref $self) ? $self->{COOKIE} : $self);
160 161 }
161 162
162 163 #
163 164 # new: The object constructor
164 165 #
165 166 sub new
166 167 {
167 168 my $class = shift;
168 169 my ($self, $view);
169 170 $view = shift;
170 171 $self->{COOKIE} = ($view ? lgrp_init($view) : lgrp_init()) or
171 172 croak("lgrp_init: $!\n"), return;
172 173 bless($self, $class) if defined($class);
173 174 bless($self) unless defined($class);
174 175 return ($self);
175 176 }
176 177
177 178 #
178 179 # DESTROY: the object destructor.
179 180 #
180 181 sub DESTROY
181 182 {
182 183 lgrp_fini(cookie(shift));
183 184 }
184 185
185 186 ############################################################
186 187 # Wrapper methods.
187 188 #
188 189 sub stale
189 190 {
190 191 scalar @_ == 1 or _usage("stale(class)");
191 192 return (lgrp_cookie_stale(cookie(shift)));
192 193 }
193 194
194 195 sub view
195 196 {
196 197 scalar @_ == 1 or _usage("view(class)");
197 198 return (lgrp_view(cookie(shift)));
198 199 }
199 200
200 201 sub root
201 202 {
202 203 scalar @_ == 1 or _usage("root(class)");
203 204 return (lgrp_root(cookie(shift)));
204 205 }
205 206
206 207 sub nlgrps
207 208 {
208 209 scalar @_ == 1 or _usage("nlgrps(class)");
209 210 return (lgrp_nlgrps(cookie(shift)));
210 211 }
211 212
212 213 sub lgrps
213 214 {
214 215 scalar @_ > 0 or _usage("lgrps(class, [lgrp])");
215 216 return (lgrp_lgrps(cookie(shift), shift));
216 217 }
217 218
218 219 sub leaves
219 220 {
220 221 scalar @_ > 0 or _usage("leaves(class, [lgrp])");
221 222 return (lgrp_leaves(cookie(shift), shift));
222 223 }
223 224
224 225 sub version
225 226 {
226 227 scalar @_ > 0 or _usage("leaves(class, [version])");
227 228 shift;
228 229 return (lgrp_version(shift || 0));
229 230 }
230 231
231 232 sub children
232 233 {
233 234 scalar @_ == 2 or _usage("children(class, lgrp)");
234 235 return (lgrp_children(cookie(shift), shift));
235 236 }
236 237
237 238 sub parents
238 239 {
239 240 scalar @_ == 2 or _usage("parents(class, lgrp)");
240 241 return (lgrp_parents(cookie(shift), shift));
241 242 }
242 243
243 244 sub mem_size
244 245 {
245 246 scalar @_ == 4 or _usage("mem_size(class, lgrp, type, content)");
246 247 return (lgrp_mem_size(cookie(shift), shift, shift, shift));
247 248 }
248 249
249 250 sub cpus
250 251 {
251 252 scalar @_ == 3 or _usage("cpus(class, lgrp, content)");
252 253 return (lgrp_cpus(cookie(shift), shift, shift));
253 254 }
254 255
255 256 sub isleaf
256 257 {
257 258 scalar @_ == 2 or _usage("isleaf(class, lgrp)");
258 259 lgrp_isleaf(cookie(shift), shift);
259 260 }
260 261
261 262 sub resources
262 263 {
263 264 scalar @_ == 3 or _usage("resources(class, lgrp, resource)");
264 265 return (lgrp_resources(cookie(shift), shift, shift));
265 266 }
266 267
267 268 sub latency
268 269 {
269 270 scalar @_ == 3 or _usage("latency(class, from, to)");
270 271 return (lgrp_latency_cookie(cookie(shift), shift, shift));
271 272 }
272 273
273 274 # Methods that do not require cookie
274 275 sub home
275 276 {
276 277 scalar @_ == 3 or _usage("home(class, idtype, id)");
277 278 shift;
278 279 return (lgrp_home(shift, shift));
279 280 }
280 281
281 282 sub affinity_get
282 283 {
283 284 scalar @_ == 4 or _usage("affinity_get(class, idtype, id, lgrp)");
284 285 shift;
285 286 return (lgrp_affinity_get(shift, shift, shift));
286 287 }
287 288
288 289 sub affinity_set
289 290 {
290 291 scalar @_ == 5 or
291 292 _usage("affinity_set(class, idtype, id, lgrp, affinity)");
292 293 shift;
293 294 return (lgrp_affinity_set(shift, shift, shift, shift));
294 295 }
295 296
296 297 1;
297 298
298 299 __END__
↓ open down ↓ |
255 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX