/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Lgrp.xs contains XS wrappers for the system locality group library
* liblgrp(3LIB).
*/
#include <sys/lgrp_user.h>
/*
* On i386 Solaris defines SP, which conflicts with the perl definition of SP
* We don't need the Solaris one, so get rid of it to avoid warnings.
*/
/* Perl XS includes. */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
/* Return undef in scalar context and empty list in list context */
#define LGRP_BADVAL() { \
else \
}
/*
* Push all values from input array onto the perl return stack.
*/
{ \
int x; \
\
if (nitems < 0) { \
LGRP_BADVAL() \
} else if (nitems > 0) { \
for (x = 0; x < nitems; x++) { \
} \
} \
}
/*
* Several constants are not present in the first version of the Lgrp API,
* we define them here.
*
* lgrp_resources() and lgrp_latency_cookie() only appear in API v2. If the
* module is linked with old version of liblgrp(3LIB) there is no lgrp_resources
* symbol in the library and perl wrapper returns empty list and sets errno to
* EINVAL.
*
* The lgrp_latency_cookie() is emulated using lgrp_latency().
*/
#if LGRP_VER_CURRENT == 1
#define LGRP_LAT_CPU_TO_MEM 0
#define LGRP_RSRC_CPU 0 /* CPU resources */
/*
* Simulate lgrp_latency_cookie() which just fails. This macro is never called
* and we just define it so that the C compiler will not complain about the
* missing symbol.
*/
#else
int nr; \
\
errno = 0; \
if (nr < 0) \
LGRP_BADVAL(); \
XSRETURN_IV(nr); \
if (nr == 0) { \
LGRP_BADVAL(); \
} else { \
} \
}
#endif
/*
* Special version of lgrp_latency_cookie(). Use lgrp_latency() for liblgrp V1
* and lgrp_latency_cookie for V2.
*/
static int
int between)
{
return (LGRP_VER_CURRENT < 2 ?
}
/*
* Most functions in liblgrp return -1 on failure. The perl equivalent returns
* 'undef' instead. The macro should be call after the RETVAL is set to the
* return value of the function.
*/
/*
* End of C part, start of XS part.
*
* The XS code exported to perl is below here. Note that the XS preprocessor
* has its own commenting syntax, so all comments from this point on are in
* that form.
*/
#
#
BOOT:
{
}
#
#
#
#
int
int
int
int
int type
int
int
#
#
int
CODE:
#
#
#
#
#
#
void
int count;
errno = 0;
LGRP_BADVAL();
if (count > 0) {
LGRP_BADVAL();
} else {
}
}
#
#
void
int count;
errno = 0;
LGRP_BADVAL();
if (count > 0) {
LGRP_BADVAL();
} else {
}
}
#
void
int ncpus;
errno = 0;
LGRP_BADVAL();
if (ncpus > 0) {
LGRP_BADVAL();
} else {
}
}
void
int type;