1 /*
2  * This file was generated automatically by ExtUtils::ParseXS version 3.45 from the
3  * contents of Lgrp.xs. Do not edit this file, edit Lgrp.xs instead.
4  *
5  *    ANY CHANGES MADE HERE WILL BE LOST!
6  *
7  */
8 
9 #line 1 "Lgrp.xs"
10 /*
11  * CDDL HEADER START
12  *
13  * The contents of this file are subject to the terms of the
14  * Common Development and Distribution License (the "License").
15  * You may not use this file except in compliance with the License.
16  *
17  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
18  * or http://www.opensolaris.org/os/licensing.
19  * See the License for the specific language governing permissions
20  * and limitations under the License.
21  *
22  * When distributing Covered Code, include this CDDL HEADER in each
23  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
24  * If applicable, add the following below this CDDL HEADER, with the
25  * fields enclosed by brackets "[]" replaced with your own identifying
26  * information: Portions Copyright [yyyy] [name of copyright owner]
27  *
28  * CDDL HEADER END
29  */
30 
31 /*
32  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
33  * Use is subject to license terms.
34  */
35 
36 #pragma ident	"%Z%%M%	%I%	%E% SMI"
37 
38 /*
39  * Lgrp.xs contains XS wrappers for the system locality group library
40  * liblgrp(3LIB).
41  */
42 
43 #include <sys/errno.h>
44 #include <sys/lgrp_user.h>
45 
46 /*
47  * On i386 Solaris defines SP, which conflicts with the perl definition of SP
48  * We don't need the Solaris one, so get rid of it to avoid warnings.
49  */
50 #undef SP
51 
52 /* Perl XS includes. */
53 #include "EXTERN.h"
54 #if __GNUC__ >= 5
55 #include "perl.h"
56 #else
57 #define _Thread_local
58 #include "perl.h"
59 #undef _Thread_local
60 #undef PERL_GET_CONTEXT
61 #undef PERL_SET_CONTEXT
62 #define PERL_GET_CONTEXT	PTHREAD_GETSPECIFIC(PL_thr_key)
63 #define PERL_SET_CONTEXT(t)	Perl_set_context((void*)t)
64 #endif
65 #include "XSUB.h"
66 
67 /* Return undef in scalar context and empty list in list context */
68 #define LGRP_BADVAL() {			\
69 	if (GIMME_V == G_ARRAY)		\
70 			XSRETURN_EMPTY;	\
71 		else			\
72 			XSRETURN_UNDEF;	\
73 }
74 
75 /*
76  * Push all values from input array onto the perl return stack.
77  */
78 #define	PUSHARRAY(array, nitems)	\
79 {					\
80 	int x;				\
81 					\
82 	if (nitems < 0) {		\
83 		LGRP_BADVAL()		\
84 	} else if (nitems > 0) {	\
85 		EXTEND(SP, nitems);	\
86 		for (x = 0; x < nitems; x++) {	\
87 			PUSHs(sv_2mortal(newSVnv(array[x])));	\
88 		}			\
89 	}				\
90 }
91 
92 /*
93  * Several constants are not present in the first version of the Lgrp API,
94  * we define them here.
95  *
96  * lgrp_resources() and lgrp_latency_cookie() only appear in API v2. If the
97  * module is linked with old version of liblgrp(3LIB) there is no lgrp_resources
98  * symbol in the library and perl wrapper returns empty list and sets errno to
99  * EINVAL.
100  *
101  * The lgrp_latency_cookie() is emulated using lgrp_latency().
102  */
103 #if LGRP_VER_CURRENT == 1
104 #define	LGRP_CONTENT_ALL LGRP_CONTENT_HIERARCHY
105 #define	LGRP_LAT_CPU_TO_MEM 	0
106 #define LGRP_RSRC_CPU           0       /* CPU resources */
107 #define LGRP_RSRC_MEM           1       /* memory resources */
108 
109 #define LGRP_RESOURCES(c, lgrp, type) \
110 	{ errno = EINVAL; LGRP_BADVAL(); }
111 
112 /*
113  * Simulate lgrp_latency_cookie() which just fails. This macro is never called
114  * and we just define it so that the C compiler will not complain about the
115  * missing symbol.
116  */
117 #define	lgrp_latency_cookie(c, f, t, b) (errno = EINVAL, -1)
118 
119 #else
120 #define	LGRP_RESOURCES(c, lgrp, type) { \
121 	int nr;				\
122 	lgrp_id_t *lgrps;		\
123 					\
124 	errno = 0;			\
125 	nr = lgrp_resources(c, lgrp, NULL, 0, type);	\
126 	if (nr < 0)			\
127 		LGRP_BADVAL();		\
128 	if (GIMME_V == G_SCALAR)	\
129 		XSRETURN_IV(nr);	\
130 	if (nr == 0) {			\
131 		XSRETURN_EMPTY;		\
132 	} else if (New(0, lgrps, nr, lgrp_id_t) == NULL) {	\
133 		errno = ENOMEM;		\
134 		LGRP_BADVAL();		\
135 	} else {			\
136 		nr = lgrp_resources(c, lgrp, lgrps, nr, type);	\
137 		PUSHARRAY(lgrps, nr);	\
138 		Safefree(lgrps);	\
139 	}				\
140 }
141 #endif
142 
143 /*
144  * Special version of lgrp_latency_cookie(). Use lgrp_latency() for liblgrp V1
145  * and lgrp_latency_cookie for V2.
146  */
147 static int
148 _lgrp_latency_cookie(lgrp_cookie_t cookie, lgrp_id_t from, lgrp_id_t to,
149 				   int between)
150 {
151 	return (LGRP_VER_CURRENT < 2 ?
152 	    lgrp_latency(from, to) :
153 	    lgrp_latency_cookie(cookie, from, to, between));
154 }
155 
156 /*
157  * Most functions in liblgrp return -1 on failure. The perl equivalent returns
158  * 'undef' instead. The macro should be call after the RETVAL is set to the
159  * return value of the function.
160  */
161 #define	RETURN_UNDEF_IF_FAIL { if (RETVAL < 0) XSRETURN_UNDEF; }
162 
163 /*
164  * End of C part, start of XS part.
165  *
166  * The XS code exported to perl is below here.  Note that the XS preprocessor
167  * has its own commenting syntax, so all comments from this point on are in
168  * that form.
169  */
170 
171 #line 172 "Lgrp.c"
172 #ifndef PERL_UNUSED_VAR
173 #  define PERL_UNUSED_VAR(var) if (0) var = var
174 #endif
175 
176 #ifndef dVAR
177 #  define dVAR		dNOOP
178 #endif
179 
180 
181 /* This stuff is not part of the API! You have been warned. */
182 #ifndef PERL_VERSION_DECIMAL
183 #  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
184 #endif
185 #ifndef PERL_DECIMAL_VERSION
186 #  define PERL_DECIMAL_VERSION \
187 	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
188 #endif
189 #ifndef PERL_VERSION_GE
190 #  define PERL_VERSION_GE(r,v,s) \
191 	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
192 #endif
193 #ifndef PERL_VERSION_LE
194 #  define PERL_VERSION_LE(r,v,s) \
195 	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
196 #endif
197 
198 /* XS_INTERNAL is the explicit static-linkage variant of the default
199  * XS macro.
200  *
201  * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
202  * "STATIC", ie. it exports XSUB symbols. You probably don't want that
203  * for anything but the BOOT XSUB.
204  *
205  * See XSUB.h in core!
206  */
207 
208 
209 /* TODO: This might be compatible further back than 5.10.0. */
210 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
211 #  undef XS_EXTERNAL
212 #  undef XS_INTERNAL
213 #  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
214 #    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
215 #    define XS_INTERNAL(name) STATIC XSPROTO(name)
216 #  endif
217 #  if defined(__SYMBIAN32__)
218 #    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
219 #    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
220 #  endif
221 #  ifndef XS_EXTERNAL
222 #    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
223 #      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
224 #      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
225 #    else
226 #      ifdef __cplusplus
227 #        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
228 #        define XS_INTERNAL(name) static XSPROTO(name)
229 #      else
230 #        define XS_EXTERNAL(name) XSPROTO(name)
231 #        define XS_INTERNAL(name) STATIC XSPROTO(name)
232 #      endif
233 #    endif
234 #  endif
235 #endif
236 
237 /* perl >= 5.10.0 && perl <= 5.15.1 */
238 
239 
240 /* The XS_EXTERNAL macro is used for functions that must not be static
241  * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
242  * macro defined, the best we can do is assume XS is the same.
243  * Dito for XS_INTERNAL.
244  */
245 #ifndef XS_EXTERNAL
246 #  define XS_EXTERNAL(name) XS(name)
247 #endif
248 #ifndef XS_INTERNAL
249 #  define XS_INTERNAL(name) XS(name)
250 #endif
251 
252 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
253  * internal macro that we're free to redefine for varying linkage due
254  * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
255  * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
256  */
257 
258 #undef XS_EUPXS
259 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
260 #  define XS_EUPXS(name) XS_EXTERNAL(name)
261 #else
262    /* default to internal */
263 #  define XS_EUPXS(name) XS_INTERNAL(name)
264 #endif
265 
266 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
267 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
268 
269 /* prototype to pass -Wmissing-prototypes */
270 STATIC void
271 S_croak_xs_usage(const CV *const cv, const char *const params);
272 
273 STATIC void
274 S_croak_xs_usage(const CV *const cv, const char *const params)
275 {
276     const GV *const gv = CvGV(cv);
277 
278     PERL_ARGS_ASSERT_CROAK_XS_USAGE;
279 
280     if (gv) {
281         const char *const gvname = GvNAME(gv);
282         const HV *const stash = GvSTASH(gv);
283         const char *const hvname = stash ? HvNAME(stash) : NULL;
284 
285         if (hvname)
286 	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
287         else
288 	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
289     } else {
290         /* Pants. I don't think that it should be possible to get here. */
291 	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
292     }
293 }
294 #undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE
295 
296 #define croak_xs_usage        S_croak_xs_usage
297 
298 #endif
299 
300 /* NOTE: the prototype of newXSproto() is different in versions of perls,
301  * so we define a portable version of newXSproto()
302  */
303 #ifdef newXS_flags
304 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
305 #else
306 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
307 #endif /* !defined(newXS_flags) */
308 
309 #if PERL_VERSION_LE(5, 21, 5)
310 #  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
311 #else
312 #  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
313 #endif
314 
315 #line 316 "Lgrp.c"
316 
317 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_init); /* prototype to pass -Wmissing-prototypes */
318 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_init)
319 {
320     dVAR; dXSARGS;
321     if (items < 0 || items > 1)
322        croak_xs_usage(cv,  "view= LGRP_VIEW_OS");
323     {
324 	lgrp_cookie_t	RETVAL;
325 	dXSTARG;
326 	lgrp_view_t	view;
327 
328 	if (items < 1)
329 	    view = LGRP_VIEW_OS;
330 	else {
331 	    view = (lgrp_view_t)SvUV(ST(0))
332 ;
333 	}
334 
335 	RETVAL = lgrp_init(view);
336 #line 212 "Lgrp.xs"
337 	RETURN_UNDEF_IF_FAIL;
338 #line 339 "Lgrp.c"
339 	XSprePUSH;
340 	PUSHu((UV)RETVAL);
341     }
342     XSRETURN(1);
343 }
344 
345 
346 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_view); /* prototype to pass -Wmissing-prototypes */
347 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_view)
348 {
349     dVAR; dXSARGS;
350     if (items != 1)
351        croak_xs_usage(cv,  "cookie");
352     {
353 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
354 ;
355 	lgrp_view_t	RETVAL;
356 	dXSTARG;
357 
358 	RETVAL = lgrp_view(cookie);
359 #line 218 "Lgrp.xs"
360 	RETURN_UNDEF_IF_FAIL;
361 #line 362 "Lgrp.c"
362 	XSprePUSH;
363 	PUSHu((UV)RETVAL);
364     }
365     XSRETURN(1);
366 }
367 
368 
369 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_affinity_get); /* prototype to pass -Wmissing-prototypes */
370 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_affinity_get)
371 {
372     dVAR; dXSARGS;
373     if (items != 3)
374        croak_xs_usage(cv,  "idtype, id, lgrp");
375     {
376 	idtype_t	idtype = (idtype_t)SvIV(ST(0))
377 ;
378 	id_t	id = (id_t)SvIV(ST(1))
379 ;
380 	lgrp_id_t	lgrp = (lgrp_id_t)SvIV(ST(2))
381 ;
382 	lgrp_affinity_t	RETVAL;
383 	dXSTARG;
384 
385 	RETVAL = lgrp_affinity_get(idtype, id, lgrp);
386 #line 226 "Lgrp.xs"
387 	RETURN_UNDEF_IF_FAIL;
388 #line 389 "Lgrp.c"
389 	XSprePUSH;
390 	PUSHi((IV)RETVAL);
391     }
392     XSRETURN(1);
393 }
394 
395 
396 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_affinity_set); /* prototype to pass -Wmissing-prototypes */
397 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_affinity_set)
398 {
399     dVAR; dXSARGS;
400     if (items != 4)
401        croak_xs_usage(cv,  "idtype, id, lgrp, affinity");
402     {
403 	idtype_t	idtype = (idtype_t)SvIV(ST(0))
404 ;
405 	id_t	id = (id_t)SvIV(ST(1))
406 ;
407 	lgrp_id_t	lgrp = (lgrp_id_t)SvIV(ST(2))
408 ;
409 	lgrp_affinity_t	affinity = (lgrp_affinity_t)SvIV(ST(3))
410 ;
411 	int	RETVAL;
412 	dXSTARG;
413 
414 	RETVAL = lgrp_affinity_set(idtype, id, lgrp, affinity);
415 #line 235 "Lgrp.xs"
416 	RETURN_UNDEF_IF_FAIL;
417 	XSRETURN_YES;
418 #line 419 "Lgrp.c"
419 	XSprePUSH;
420 	PUSHi((IV)RETVAL);
421     }
422     XSRETURN(1);
423 }
424 
425 
426 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_cookie_stale); /* prototype to pass -Wmissing-prototypes */
427 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_cookie_stale)
428 {
429     dVAR; dXSARGS;
430     if (items != 1)
431        croak_xs_usage(cv,  "cookie");
432     {
433 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
434 ;
435 	int	RETVAL;
436 	dXSTARG;
437 
438 	RETVAL = lgrp_cookie_stale(cookie);
439 #line 242 "Lgrp.xs"
440 	RETURN_UNDEF_IF_FAIL;
441 #line 442 "Lgrp.c"
442 	XSprePUSH;
443 	PUSHi((IV)RETVAL);
444     }
445     XSRETURN(1);
446 }
447 
448 
449 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_fini); /* prototype to pass -Wmissing-prototypes */
450 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_fini)
451 {
452     dVAR; dXSARGS;
453     if (items != 1)
454        croak_xs_usage(cv,  "cookie");
455     {
456 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
457 ;
458 	int	RETVAL;
459 	dXSTARG;
460 
461 	RETVAL = lgrp_fini(cookie);
462 #line 248 "Lgrp.xs"
463 	RETURN_UNDEF_IF_FAIL;
464 	XSRETURN_YES;
465 #line 466 "Lgrp.c"
466 	XSprePUSH;
467 	PUSHi((IV)RETVAL);
468     }
469     XSRETURN(1);
470 }
471 
472 
473 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_home); /* prototype to pass -Wmissing-prototypes */
474 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_home)
475 {
476     dVAR; dXSARGS;
477     if (items != 2)
478        croak_xs_usage(cv,  "idtype, id");
479     {
480 	idtype_t	idtype = (idtype_t)SvIV(ST(0))
481 ;
482 	id_t	id = (id_t)SvIV(ST(1))
483 ;
484 	lgrp_id_t	RETVAL;
485 	dXSTARG;
486 
487 	RETVAL = lgrp_home(idtype, id);
488 #line 256 "Lgrp.xs"
489 	RETURN_UNDEF_IF_FAIL;
490 #line 491 "Lgrp.c"
491 	XSprePUSH;
492 	PUSHi((IV)RETVAL);
493     }
494     XSRETURN(1);
495 }
496 
497 
498 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_latency); /* prototype to pass -Wmissing-prototypes */
499 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_latency)
500 {
501     dVAR; dXSARGS;
502     if (items != 2)
503        croak_xs_usage(cv,  "from, to");
504     {
505 	int	RETVAL;
506 	dXSTARG;
507 	lgrp_id_t	from = (lgrp_id_t)SvIV(ST(0))
508 ;
509 	lgrp_id_t	to = (lgrp_id_t)SvIV(ST(1))
510 ;
511 
512 	RETVAL = lgrp_latency(from, to);
513 #line 261 "Lgrp.xs"
514 	RETURN_UNDEF_IF_FAIL;
515 #line 516 "Lgrp.c"
516 	XSprePUSH;
517 	PUSHi((IV)RETVAL);
518     }
519     XSRETURN(1);
520 }
521 
522 
523 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_mem_size); /* prototype to pass -Wmissing-prototypes */
524 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_mem_size)
525 {
526     dVAR; dXSARGS;
527     if (items != 4)
528        croak_xs_usage(cv,  "cookie, lgrp, type, content");
529     {
530 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
531 ;
532 	lgrp_id_t	lgrp = (lgrp_id_t)SvIV(ST(1))
533 ;
534 	int	type = (int)SvIV(ST(2))
535 ;
536 	lgrp_content_t	content = (lgrp_content_t)SvIV(ST(3))
537 ;
538 	lgrp_mem_size_t	RETVAL;
539 	dXSTARG;
540 
541 	RETVAL = lgrp_mem_size(cookie, lgrp, type, content);
542 #line 270 "Lgrp.xs"
543 	RETURN_UNDEF_IF_FAIL;
544 #line 545 "Lgrp.c"
545 	XSprePUSH;
546 	PUSHi((IV)RETVAL);
547     }
548     XSRETURN(1);
549 }
550 
551 
552 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_nlgrps); /* prototype to pass -Wmissing-prototypes */
553 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_nlgrps)
554 {
555     dVAR; dXSARGS;
556     if (items != 1)
557        croak_xs_usage(cv,  "cookie");
558     {
559 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
560 ;
561 	int	RETVAL;
562 	dXSTARG;
563 
564 	RETVAL = lgrp_nlgrps(cookie);
565 #line 276 "Lgrp.xs"
566 	RETURN_UNDEF_IF_FAIL;
567 #line 568 "Lgrp.c"
568 	XSprePUSH;
569 	PUSHi((IV)RETVAL);
570     }
571     XSRETURN(1);
572 }
573 
574 
575 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_root); /* prototype to pass -Wmissing-prototypes */
576 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_root)
577 {
578     dVAR; dXSARGS;
579     if (items != 1)
580        croak_xs_usage(cv,  "cookie");
581     {
582 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
583 ;
584 	lgrp_id_t	RETVAL;
585 	dXSTARG;
586 
587 	RETVAL = lgrp_root(cookie);
588 #line 282 "Lgrp.xs"
589 	RETURN_UNDEF_IF_FAIL;
590 #line 591 "Lgrp.c"
591 	XSprePUSH;
592 	PUSHi((IV)RETVAL);
593     }
594     XSRETURN(1);
595 }
596 
597 
598 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_version); /* prototype to pass -Wmissing-prototypes */
599 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_version)
600 {
601     dVAR; dXSARGS;
602     if (items < 0 || items > 1)
603        croak_xs_usage(cv,  "version= LGRP_VER_NONE");
604     {
605 	int	RETVAL;
606 	dXSTARG;
607 	int	version;
608 
609 	if (items < 1)
610 	    version = LGRP_VER_NONE;
611 	else {
612 	    version = (int)SvIV(ST(0))
613 ;
614 	}
615 
616 	RETVAL = lgrp_version(version);
617 	XSprePUSH;
618 	PUSHi((IV)RETVAL);
619     }
620     XSRETURN(1);
621 }
622 
623 
624 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_latency_cookie); /* prototype to pass -Wmissing-prototypes */
625 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_latency_cookie)
626 {
627     dVAR; dXSARGS;
628     if (items < 3 || items > 4)
629        croak_xs_usage(cv,  "cookie, from, to, between= 0");
630     {
631 	int	RETVAL;
632 	dXSTARG;
633 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
634 ;
635 	lgrp_id_t	from = (lgrp_id_t)SvIV(ST(1))
636 ;
637 	lgrp_id_t	to = (lgrp_id_t)SvIV(ST(2))
638 ;
639 	int	between;
640 
641 	if (items < 4)
642 	    between = 0;
643 	else {
644 	    between = (int)SvIV(ST(3))
645 ;
646 	}
647 #line 294 "Lgrp.xs"
648 	RETVAL = _lgrp_latency_cookie(cookie, from, to, between);
649 #line 650 "Lgrp.c"
650 #line 296 "Lgrp.xs"
651 	RETURN_UNDEF_IF_FAIL;
652 #line 653 "Lgrp.c"
653 	XSprePUSH;
654 	PUSHi((IV)RETVAL);
655     }
656     XSRETURN(1);
657 }
658 
659 
660 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_children); /* prototype to pass -Wmissing-prototypes */
661 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_children)
662 {
663     dVAR; dXSARGS;
664     if (items != 2)
665        croak_xs_usage(cv,  "cookie, lgrp");
666     PERL_UNUSED_VAR(ax); /* -Wall */
667     SP -= items;
668     {
669 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
670 ;
671 	lgrp_id_t	lgrp = (lgrp_id_t)SvIV(ST(1))
672 ;
673 #line 320 "Lgrp.xs"
674 	lgrp_id_t *lgrps;
675 	int	count;
676 #line 677 "Lgrp.c"
677 #line 323 "Lgrp.xs"
678 	errno = 0;
679 	if ((count = lgrp_children(cookie, lgrp, NULL, 0)) < 0)
680 		LGRP_BADVAL();
681 
682 	if (GIMME_V == G_SCALAR)
683 		XSRETURN_IV(count);
684 
685 	if (count > 0) {
686 		if (New(0, lgrps, count, lgrp_id_t) == NULL) {
687 			errno = ENOMEM;
688 			LGRP_BADVAL();
689 		} else {
690 			count = lgrp_children(cookie, lgrp, lgrps, count);
691 			PUSHARRAY(lgrps, count);
692 			Safefree(lgrps);
693 		}
694 	}
695 #line 696 "Lgrp.c"
696 	PUTBACK;
697 	return;
698     }
699 }
700 
701 
702 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_parents); /* prototype to pass -Wmissing-prototypes */
703 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_parents)
704 {
705     dVAR; dXSARGS;
706     if (items != 2)
707        croak_xs_usage(cv,  "cookie, lgrp");
708     PERL_UNUSED_VAR(ax); /* -Wall */
709     SP -= items;
710     {
711 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
712 ;
713 	lgrp_id_t	lgrp = (lgrp_id_t)SvIV(ST(1))
714 ;
715 #line 349 "Lgrp.xs"
716 	lgrp_id_t *lgrps;
717 	int count;
718 #line 719 "Lgrp.c"
719 #line 352 "Lgrp.xs"
720 	errno = 0;
721 	if ((count = lgrp_parents(cookie, lgrp, NULL, 0)) < 0)
722 		LGRP_BADVAL();
723 
724 	if (GIMME_V == G_SCALAR)
725 		XSRETURN_IV(count);
726 
727 	if (count > 0) {
728 		if (New(0, lgrps, count, lgrp_id_t) == NULL) {
729 			errno = ENOMEM;
730 			LGRP_BADVAL();
731 		} else {
732 			count = lgrp_parents(cookie, lgrp, lgrps, count);
733 			PUSHARRAY(lgrps, count);
734 			Safefree(lgrps);
735 		}
736 	}
737 #line 738 "Lgrp.c"
738 	PUTBACK;
739 	return;
740     }
741 }
742 
743 
744 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_cpus); /* prototype to pass -Wmissing-prototypes */
745 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_cpus)
746 {
747     dVAR; dXSARGS;
748     if (items != 3)
749        croak_xs_usage(cv,  "cookie, lgrp, content");
750     PERL_UNUSED_VAR(ax); /* -Wall */
751     SP -= items;
752     {
753 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
754 ;
755 	lgrp_id_t	lgrp = (lgrp_id_t)SvIV(ST(1))
756 ;
757 	lgrp_content_t	content = (lgrp_content_t)SvIV(ST(2))
758 ;
759 #line 380 "Lgrp.xs"
760 	int ncpus;
761 	processorid_t *cpus;
762 #line 763 "Lgrp.c"
763 #line 383 "Lgrp.xs"
764 	errno = 0;
765 	if ((ncpus = lgrp_cpus(cookie, lgrp, NULL, 0, content)) < 0)
766 		LGRP_BADVAL();
767 
768 	if (GIMME_V == G_SCALAR)
769 		XSRETURN_IV(ncpus);
770 
771 	if (ncpus > 0) {
772 		if (New(0, cpus, ncpus, processorid_t) == NULL) {
773 			errno = ENOMEM;
774 			LGRP_BADVAL();
775 		} else {
776 			ncpus = lgrp_cpus(cookie, lgrp, cpus, ncpus, content);
777 			PUSHARRAY(cpus, ncpus);
778 			Safefree(cpus);
779 		}
780 	}
781 #line 782 "Lgrp.c"
782 	PUTBACK;
783 	return;
784     }
785 }
786 
787 
788 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_resources); /* prototype to pass -Wmissing-prototypes */
789 XS_EUPXS(XS_Sun__Solaris__Lgrp_lgrp_resources)
790 {
791     dVAR; dXSARGS;
792     if (items != 3)
793        croak_xs_usage(cv,  "cookie, lgrp, type");
794     PERL_UNUSED_VAR(ax); /* -Wall */
795     SP -= items;
796     {
797 	lgrp_cookie_t	cookie = (lgrp_cookie_t)SvUV(ST(0))
798 ;
799 	lgrp_id_t	lgrp = (lgrp_id_t)SvIV(ST(1))
800 ;
801 	int	type = (int)SvIV(ST(2))
802 ;
803 #line 407 "Lgrp.xs"
804 	LGRP_RESOURCES(cookie, lgrp, type);
805 #line 806 "Lgrp.c"
806 	PUTBACK;
807 	return;
808     }
809 }
810 
811 #ifdef __cplusplus
812 extern "C"
813 #endif
814 XS_EXTERNAL(boot_Sun__Solaris__Lgrp); /* prototype to pass -Wmissing-prototypes */
815 XS_EXTERNAL(boot_Sun__Solaris__Lgrp)
816 {
817 #if PERL_VERSION_LE(5, 21, 5)
818     dVAR; dXSARGS;
819 #else
820     dVAR; dXSBOOTARGSXSAPIVERCHK;
821 #endif
822 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
823     char* file = __FILE__;
824 #else
825     const char* file = __FILE__;
826 #endif
827 
828     PERL_UNUSED_VAR(file);
829 
830     PERL_UNUSED_VAR(cv); /* -W */
831     PERL_UNUSED_VAR(items); /* -W */
832 #if PERL_VERSION_LE(5, 21, 5)
833     XS_VERSION_BOOTCHECK;
834 #  ifdef XS_APIVERSION_BOOTCHECK
835     XS_APIVERSION_BOOTCHECK;
836 #  endif
837 #endif
838 
839         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_init", XS_Sun__Solaris__Lgrp_lgrp_init, file, ";$");
840         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_view", XS_Sun__Solaris__Lgrp_lgrp_view, file, "$");
841         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_affinity_get", XS_Sun__Solaris__Lgrp_lgrp_affinity_get, file, "$$$");
842         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_affinity_set", XS_Sun__Solaris__Lgrp_lgrp_affinity_set, file, "$$$$");
843         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_cookie_stale", XS_Sun__Solaris__Lgrp_lgrp_cookie_stale, file, "$");
844         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_fini", XS_Sun__Solaris__Lgrp_lgrp_fini, file, "$");
845         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_home", XS_Sun__Solaris__Lgrp_lgrp_home, file, "$$");
846         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_latency", XS_Sun__Solaris__Lgrp_lgrp_latency, file, "$$");
847         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_mem_size", XS_Sun__Solaris__Lgrp_lgrp_mem_size, file, "$$$$");
848         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_nlgrps", XS_Sun__Solaris__Lgrp_lgrp_nlgrps, file, "$");
849         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_root", XS_Sun__Solaris__Lgrp_lgrp_root, file, "$");
850         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_version", XS_Sun__Solaris__Lgrp_lgrp_version, file, ";$");
851         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_latency_cookie", XS_Sun__Solaris__Lgrp_lgrp_latency_cookie, file, "$$$;$");
852         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_children", XS_Sun__Solaris__Lgrp_lgrp_children, file, "$$");
853         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_parents", XS_Sun__Solaris__Lgrp_lgrp_parents, file, "$$");
854         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_cpus", XS_Sun__Solaris__Lgrp_lgrp_cpus, file, "$$$");
855         (void)newXSproto_portable("Sun::Solaris::Lgrp::lgrp_resources", XS_Sun__Solaris__Lgrp_lgrp_resources, file, "$$$");
856 
857     /* Initialisation Section */
858 
859 #line 172 "Lgrp.xs"
860 	{
861 	HV *stash;
862 
863 	stash = gv_stashpv("Sun::Solaris::Lgrp", TRUE);
864 	newCONSTSUB(stash, "LGRP_AFF_NONE", newSViv(LGRP_AFF_NONE));
865 	newCONSTSUB(stash, "LGRP_AFF_STRONG", newSViv(LGRP_AFF_STRONG));
866 	newCONSTSUB(stash, "LGRP_AFF_WEAK", newSViv(LGRP_AFF_WEAK));
867 	newCONSTSUB(stash, "LGRP_VER_CURRENT", newSViv(LGRP_VER_CURRENT));
868 	newCONSTSUB(stash, "LGRP_VER_NONE", newSViv(LGRP_VER_NONE));
869 	newCONSTSUB(stash, "LGRP_NONE", newSViv(LGRP_NONE));
870 	newCONSTSUB(stash, "LGRP_RSRC_CPU", newSViv(LGRP_RSRC_CPU));
871 	newCONSTSUB(stash, "LGRP_RSRC_MEM", newSViv(LGRP_RSRC_MEM));
872 	newCONSTSUB(stash, "LGRP_CONTENT_HIERARCHY",
873 			newSViv(LGRP_CONTENT_HIERARCHY));
874 	newCONSTSUB(stash, "LGRP_CONTENT_DIRECT", newSViv(LGRP_CONTENT_DIRECT));
875 	newCONSTSUB(stash, "LGRP_VIEW_CALLER", newSViv(LGRP_VIEW_CALLER));
876 	newCONSTSUB(stash, "LGRP_VIEW_OS", newSViv(LGRP_VIEW_OS));
877 	newCONSTSUB(stash, "LGRP_MEM_SZ_FREE", newSViv(LGRP_MEM_SZ_FREE));
878 	newCONSTSUB(stash, "LGRP_MEM_SZ_INSTALLED",
879 			newSViv(LGRP_MEM_SZ_INSTALLED));
880 	newCONSTSUB(stash, "LGRP_CONTENT_ALL", newSViv(LGRP_CONTENT_ALL));
881 	newCONSTSUB(stash, "LGRP_LAT_CPU_TO_MEM", newSViv(LGRP_LAT_CPU_TO_MEM));
882 	newCONSTSUB(stash, "P_PID", newSViv(P_PID));
883 	newCONSTSUB(stash, "P_LWPID", newSViv(P_LWPID));
884 	newCONSTSUB(stash, "P_MYID", newSViv(P_MYID));
885 	}
886 
887 #line 888 "Lgrp.c"
888 
889     /* End of Initialisation Section */
890 
891 #if PERL_VERSION_LE(5, 21, 5)
892 #  if PERL_VERSION_GE(5, 9, 0)
893     if (PL_unitcheckav)
894         call_list(PL_scopestack_ix, PL_unitcheckav);
895 #  endif
896     XSRETURN_YES;
897 #else
898     Perl_xs_boot_epilog(aTHX_ ax);
899 #endif
900 }
901 
902