17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23414388d7Ssl  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <errno.h>
287c478bd9Sstevel@tonic-gate #include <jni.h>
297c478bd9Sstevel@tonic-gate #include <pool.h>
307c478bd9Sstevel@tonic-gate #include <stdlib.h>
317c478bd9Sstevel@tonic-gate #include <string.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/time.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include "jpool.h"
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate struct pool_callback {
387c478bd9Sstevel@tonic-gate 	jobject	pc_user;
397c478bd9Sstevel@tonic-gate 	jobject	pc_handler;
407c478bd9Sstevel@tonic-gate 	jobject	pc_elem;
417c478bd9Sstevel@tonic-gate 	JNIEnv	*pc_env;
427c478bd9Sstevel@tonic-gate };
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate static void throwException(JNIEnv *, const char *, const char *);
457c478bd9Sstevel@tonic-gate static void throw_pe(JNIEnv *);
467c478bd9Sstevel@tonic-gate static jobject makeUnsignedInt64(JNIEnv *, uint64_t);
477c478bd9Sstevel@tonic-gate static int pool_property_walker(pool_conf_t *, pool_elem_t *p, const char *,
487c478bd9Sstevel@tonic-gate     pool_value_t *, void *);
497c478bd9Sstevel@tonic-gate static jobject copyArray(JNIEnv *, void **);
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * Cached class, method, and field IDs.
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate static jclass ui64class;
557c478bd9Sstevel@tonic-gate static jmethodID ui64cons_mid;
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * Throw an exception of the specified class with the specified message.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate void
throwException(JNIEnv * env,const char * class,const char * msg)617c478bd9Sstevel@tonic-gate throwException(JNIEnv *env, const char *class, const char *msg)
627c478bd9Sstevel@tonic-gate {
637c478bd9Sstevel@tonic-gate 	jclass clazz;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 	clazz = (*env)->FindClass(env, class);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 	(*env)->ThrowNew(env, clazz, msg);
687c478bd9Sstevel@tonic-gate }
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Throw a PoolsException.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate void
throw_pe(JNIEnv * jenv)747c478bd9Sstevel@tonic-gate throw_pe(JNIEnv *jenv)
757c478bd9Sstevel@tonic-gate {
767c478bd9Sstevel@tonic-gate 	jclass clazz;
777c478bd9Sstevel@tonic-gate 	jmethodID mid;
787c478bd9Sstevel@tonic-gate 	jthrowable throwObj;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 	clazz = (*jenv)->FindClass(jenv,
817c478bd9Sstevel@tonic-gate 	    "com/sun/solaris/service/pools/PoolsException");
827c478bd9Sstevel@tonic-gate 	mid = (*jenv)->GetMethodID(jenv, clazz, "<init>", "()V");
837c478bd9Sstevel@tonic-gate 	throwObj = (*jenv)->NewObject(jenv, clazz, mid);
847c478bd9Sstevel@tonic-gate 	(*jenv)->Throw(jenv, throwObj);
857c478bd9Sstevel@tonic-gate }
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * Return an instance of an UnsignedInt64 class which encapsulates the
897c478bd9Sstevel@tonic-gate  * supplied value.
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate jobject
makeUnsignedInt64(JNIEnv * env,uint64_t value)927c478bd9Sstevel@tonic-gate makeUnsignedInt64(JNIEnv *env, uint64_t value)
937c478bd9Sstevel@tonic-gate {
947c478bd9Sstevel@tonic-gate 	jobject valueObj;
957c478bd9Sstevel@tonic-gate 	jobject byteArray;
967c478bd9Sstevel@tonic-gate 	jbyte *bytes;
977c478bd9Sstevel@tonic-gate 	int i;
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 	if (!(byteArray = (*env)->NewByteArray(env, 9)))
1007c478bd9Sstevel@tonic-gate 		return (NULL); /* OutOfMemoryError thrown */
1017c478bd9Sstevel@tonic-gate 	if (!(bytes = (*env)->GetByteArrayElements(env, byteArray, NULL)))
1027c478bd9Sstevel@tonic-gate 		return (NULL); /* OutOfMemoryError thrown */
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	/*
1057c478bd9Sstevel@tonic-gate 	 * Interpret the uint64_t as a 9-byte big-endian signed quantity
1067c478bd9Sstevel@tonic-gate 	 * suitable for constructing an UnsignedInt64 or BigInteger.
1077c478bd9Sstevel@tonic-gate 	 */
1087c478bd9Sstevel@tonic-gate 	for (i = 8; i >= 1; i--) {
1097c478bd9Sstevel@tonic-gate 		bytes[i] = value & 0xff;
1107c478bd9Sstevel@tonic-gate 		value >>= 8;
1117c478bd9Sstevel@tonic-gate 	}
1127c478bd9Sstevel@tonic-gate 	bytes[0] = 0;
1137c478bd9Sstevel@tonic-gate 	(*env)->ReleaseByteArrayElements(env, byteArray, bytes, 0);
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	if (!(valueObj = (*env)->NewObject(env, ui64class, ui64cons_mid,
1167c478bd9Sstevel@tonic-gate 	    byteArray)))
1177c478bd9Sstevel@tonic-gate 		return (NULL); /* exception thrown */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 	return (valueObj);
1207c478bd9Sstevel@tonic-gate }
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * Create an array list and then copy the native array into it
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate jobject
copyArray(JNIEnv * jenv,void ** nativeArray)1267c478bd9Sstevel@tonic-gate copyArray(JNIEnv *jenv, void **nativeArray)
1277c478bd9Sstevel@tonic-gate {
1287c478bd9Sstevel@tonic-gate 	int i;
1297c478bd9Sstevel@tonic-gate 	jobject jresult = NULL;
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	if (nativeArray != NULL) {
1327c478bd9Sstevel@tonic-gate 		jclass ALclazz;
1337c478bd9Sstevel@tonic-gate 		jmethodID ALinit, ALadd;
1347c478bd9Sstevel@tonic-gate 		jclass Lclazz;
1357c478bd9Sstevel@tonic-gate 		jmethodID Linit;
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 		ALclazz = (*jenv)->FindClass(jenv,
1387c478bd9Sstevel@tonic-gate 		    "java/util/ArrayList");
1397c478bd9Sstevel@tonic-gate 		ALinit = (*jenv)->GetMethodID(jenv,
1407c478bd9Sstevel@tonic-gate 		    ALclazz, "<init>", "()V");
1417c478bd9Sstevel@tonic-gate 		ALadd = (*jenv)->GetMethodID(jenv,
1427c478bd9Sstevel@tonic-gate 		    ALclazz, "add", "(Ljava/lang/Object;)Z");
1437c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewObject(jenv, ALclazz, ALinit);
1447c478bd9Sstevel@tonic-gate 		Lclazz = (*jenv)->FindClass(jenv, "java/lang/Long");
1457c478bd9Sstevel@tonic-gate 		Linit = (*jenv)->GetMethodID(jenv,
1467c478bd9Sstevel@tonic-gate 		    Lclazz, "<init>", "(J)V");
1477c478bd9Sstevel@tonic-gate 		for (i = 0; nativeArray[i] != NULL; i++) {
1487c478bd9Sstevel@tonic-gate 			jobject L;
1497c478bd9Sstevel@tonic-gate 			/* Build longs and add them */
1507c478bd9Sstevel@tonic-gate 			L = (*jenv)->NewObject(jenv,
1517c478bd9Sstevel@tonic-gate 			    Lclazz, Linit, (jlong)(uintptr_t)nativeArray[i]);
1527c478bd9Sstevel@tonic-gate 			(*jenv)->CallBooleanMethod(jenv,
1537c478bd9Sstevel@tonic-gate 			    jresult, ALadd, L);
1547c478bd9Sstevel@tonic-gate 		}
1557c478bd9Sstevel@tonic-gate 		free(nativeArray);
1567c478bd9Sstevel@tonic-gate 	}
1577c478bd9Sstevel@tonic-gate 	return (jresult);
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate /*
1617c478bd9Sstevel@tonic-gate  * pool_version(3pool) wrapper
1627c478bd9Sstevel@tonic-gate  */
1637c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1647c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1version(JNIEnv * jenv,jclass jcls,jlong jver)1657c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1version(JNIEnv *jenv,
166*03dfa5baSToomas Soome     jclass jcls, jlong jver)
167*03dfa5baSToomas Soome {
1687c478bd9Sstevel@tonic-gate 	return ((jlong)pool_version((uint_t)jver));
1697c478bd9Sstevel@tonic-gate }
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * native constant accessor
1737c478bd9Sstevel@tonic-gate  */
1747c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1757c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1NATIVE(JNIEnv * jenv,jclass jcls)1767c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1NATIVE(JNIEnv *jenv,
177*03dfa5baSToomas Soome     jclass jcls)
178*03dfa5baSToomas Soome {
1797c478bd9Sstevel@tonic-gate 	return ((jint)POX_NATIVE);
1807c478bd9Sstevel@tonic-gate }
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate /*
1837c478bd9Sstevel@tonic-gate  * native constant accessor
1847c478bd9Sstevel@tonic-gate  */
1857c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1867c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1TEXT(JNIEnv * jenv,jclass jcls)1877c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1TEXT(JNIEnv *jenv,
188*03dfa5baSToomas Soome     jclass jcls)
189*03dfa5baSToomas Soome {
1907c478bd9Sstevel@tonic-gate 	return ((jint)POX_TEXT);
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * native constant accessor
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1977c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INVAL(JNIEnv * jenv,jclass jcls)1987c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INVAL(JNIEnv *jenv,
199*03dfa5baSToomas Soome     jclass jcls)
200*03dfa5baSToomas Soome {
2017c478bd9Sstevel@tonic-gate 	return ((jint)POC_INVAL);
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate /*
2057c478bd9Sstevel@tonic-gate  * native constant accessor
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2087c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1UINT(JNIEnv * jenv,jclass jcls)2097c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1UINT(JNIEnv *jenv,
210*03dfa5baSToomas Soome     jclass jcls)
211*03dfa5baSToomas Soome {
2127c478bd9Sstevel@tonic-gate 	return ((jint)POC_UINT);
2137c478bd9Sstevel@tonic-gate }
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate  * native constant accessor
2177c478bd9Sstevel@tonic-gate  */
2187c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2197c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INT(JNIEnv * jenv,jclass jcls)2207c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INT(JNIEnv *jenv,
221*03dfa5baSToomas Soome     jclass jcls)
222*03dfa5baSToomas Soome {
2237c478bd9Sstevel@tonic-gate 	return ((jint)POC_INT);
2247c478bd9Sstevel@tonic-gate }
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /*
2277c478bd9Sstevel@tonic-gate  * native constant accessor
2287c478bd9Sstevel@tonic-gate  */
2297c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2307c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1DOUBLE(JNIEnv * jenv,jclass jcls)2317c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1DOUBLE(JNIEnv *jenv,
232*03dfa5baSToomas Soome     jclass jcls)
233*03dfa5baSToomas Soome {
2347c478bd9Sstevel@tonic-gate 	return ((jint)POC_DOUBLE);
2357c478bd9Sstevel@tonic-gate }
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate /*
2387c478bd9Sstevel@tonic-gate  * native constant accessor
2397c478bd9Sstevel@tonic-gate  */
2407c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2417c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1BOOL(JNIEnv * jenv,jclass jcls)2427c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1BOOL(JNIEnv *jenv,
243*03dfa5baSToomas Soome     jclass jcls)
244*03dfa5baSToomas Soome {
2457c478bd9Sstevel@tonic-gate 	return ((jint)POC_BOOL);
2467c478bd9Sstevel@tonic-gate }
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate /*
2497c478bd9Sstevel@tonic-gate  * native constant accessor
2507c478bd9Sstevel@tonic-gate  */
2517c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2527c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1STRING(JNIEnv * jenv,jclass jcls)2537c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1STRING(JNIEnv *jenv,
254*03dfa5baSToomas Soome     jclass jcls)
255*03dfa5baSToomas Soome {
2567c478bd9Sstevel@tonic-gate 	return ((jint)POC_STRING);
2577c478bd9Sstevel@tonic-gate }
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate /*
2607c478bd9Sstevel@tonic-gate  * native constant accessor
2617c478bd9Sstevel@tonic-gate  */
2627c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2637c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1NONE(JNIEnv * jenv,jclass jcls)2647c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1NONE(JNIEnv *jenv,
265*03dfa5baSToomas Soome     jclass jcls)
266*03dfa5baSToomas Soome {
2677c478bd9Sstevel@tonic-gate 	return ((jint)POV_NONE);
2687c478bd9Sstevel@tonic-gate }
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate /*
2717c478bd9Sstevel@tonic-gate  * native constant accessor
2727c478bd9Sstevel@tonic-gate  */
2737c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2747c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1LOOSE(JNIEnv * jenv,jclass jcls)2757c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1LOOSE(JNIEnv *jenv,
276*03dfa5baSToomas Soome     jclass jcls)
277*03dfa5baSToomas Soome {
2787c478bd9Sstevel@tonic-gate 	return ((jint)POV_LOOSE);
2797c478bd9Sstevel@tonic-gate }
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate /*
2827c478bd9Sstevel@tonic-gate  * native constant accessor
2837c478bd9Sstevel@tonic-gate  */
2847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2857c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1STRICT(JNIEnv * jenv,jclass jcls)2867c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1STRICT(JNIEnv *jenv,
287*03dfa5baSToomas Soome     jclass jcls)
288*03dfa5baSToomas Soome {
2897c478bd9Sstevel@tonic-gate 	return ((jint)POV_STRICT);
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate /*
2937c478bd9Sstevel@tonic-gate  * native constant accessor
2947c478bd9Sstevel@tonic-gate  */
2957c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2967c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1RUNTIME(JNIEnv * jenv,jclass jcls)2977c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1RUNTIME(JNIEnv *jenv,
298*03dfa5baSToomas Soome     jclass jcls)
299*03dfa5baSToomas Soome {
3007c478bd9Sstevel@tonic-gate 	return ((jint)POV_RUNTIME);
3017c478bd9Sstevel@tonic-gate }
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate  * native constant accessor
3057c478bd9Sstevel@tonic-gate  */
3067c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3077c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1INVALID(JNIEnv * jenv,jclass jcls)3087c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1INVALID(JNIEnv *jenv,
309*03dfa5baSToomas Soome     jclass jcls)
310*03dfa5baSToomas Soome {
3117c478bd9Sstevel@tonic-gate 	return ((jint)POF_INVALID);
3127c478bd9Sstevel@tonic-gate }
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate /*
3157c478bd9Sstevel@tonic-gate  * native constant accessor
3167c478bd9Sstevel@tonic-gate  */
3177c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3187c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1VALID(JNIEnv * jenv,jclass jcls)3197c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1VALID(JNIEnv *jenv,
320*03dfa5baSToomas Soome     jclass jcls)
321*03dfa5baSToomas Soome {
3227c478bd9Sstevel@tonic-gate 	return ((jint)POF_VALID);
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate /*
3267c478bd9Sstevel@tonic-gate  * native constant accessor
3277c478bd9Sstevel@tonic-gate  */
3287c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3297c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1DESTROY(JNIEnv * jenv,jclass jcls)3307c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1DESTROY(JNIEnv *jenv,
331*03dfa5baSToomas Soome     jclass jcls)
332*03dfa5baSToomas Soome {
3337c478bd9Sstevel@tonic-gate 	return ((jint)POF_DESTROY);
3347c478bd9Sstevel@tonic-gate }
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate /*
3377c478bd9Sstevel@tonic-gate  * pool_error(3pool) wrapper
3387c478bd9Sstevel@tonic-gate  */
3397c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3407c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1error(JNIEnv * jenv,jclass jcls)3417c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1error(JNIEnv *jenv,
342*03dfa5baSToomas Soome     jclass jcls)
343*03dfa5baSToomas Soome {
3447c478bd9Sstevel@tonic-gate 	return ((jint)pool_error());
3457c478bd9Sstevel@tonic-gate }
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate /*
3487c478bd9Sstevel@tonic-gate  * pool_strerror(3pool) wrapper
3497c478bd9Sstevel@tonic-gate  */
3507c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3517c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror(JNIEnv * jenv,jclass jcls,jint jperr)3527c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror(JNIEnv *jenv,
353*03dfa5baSToomas Soome     jclass jcls, jint jperr)
354*03dfa5baSToomas Soome {
3557c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
3567c478bd9Sstevel@tonic-gate 	char *result;
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate 	result = (char *)pool_strerror((int)jperr);
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate 	if (result)
3617c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
3627c478bd9Sstevel@tonic-gate 	return (jresult);
3637c478bd9Sstevel@tonic-gate }
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate /*
3667c478bd9Sstevel@tonic-gate  * strerror(3c) wrapper
3677c478bd9Sstevel@tonic-gate  */
3687c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3697c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror_1sys(JNIEnv * jenv,jclass jcls)3707c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror_1sys(JNIEnv *
371*03dfa5baSToomas Soome     jenv, jclass jcls)
372*03dfa5baSToomas Soome {
3737c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
3747c478bd9Sstevel@tonic-gate 	char *result;
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate 	result = (char *)strerror(errno);
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate 	if (result)
3797c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
3807c478bd9Sstevel@tonic-gate 	return (jresult);
3817c478bd9Sstevel@tonic-gate }
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate /*
3847c478bd9Sstevel@tonic-gate  * errno(3c) accessor
3857c478bd9Sstevel@tonic-gate  */
3867c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3877c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolsException_getErrno(JNIEnv * jenv,jclass jcls)3887c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolsException_getErrno(JNIEnv *jenv,
389*03dfa5baSToomas Soome     jclass jcls)
390*03dfa5baSToomas Soome {
3917c478bd9Sstevel@tonic-gate 	return ((jint)errno);
3927c478bd9Sstevel@tonic-gate }
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate /*
3957c478bd9Sstevel@tonic-gate  * pool_resource_type_list(3pool) wrapper
3967c478bd9Sstevel@tonic-gate  */
3977c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3987c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1type_1list(JNIEnv * jenv,jclass jcls,jlong jreslist,jlong jnumres)3997c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1type_1list(
400*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jreslist, jlong jnumres)
401*03dfa5baSToomas Soome {
402414388d7Ssl 	char **reslist = (char **)(uintptr_t)jreslist;
403414388d7Ssl 	uint_t *numres = (uint_t *)(uintptr_t)jnumres;
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate 	return ((jint)pool_resource_type_list((char const **)reslist, numres));
4067c478bd9Sstevel@tonic-gate }
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /*
4097c478bd9Sstevel@tonic-gate  * pool_get_status(3pool) wrapper
4107c478bd9Sstevel@tonic-gate  */
4117c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4127c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1status(JNIEnv * jenv,jclass jcls)4137c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1status(JNIEnv *jenv,
414*03dfa5baSToomas Soome     jclass jcls)
415*03dfa5baSToomas Soome {
416414388d7Ssl 	int status;
417414388d7Ssl 	int err;
418414388d7Ssl 
419414388d7Ssl 	err = pool_get_status(&status);
420414388d7Ssl 	if (err == -1)
421414388d7Ssl 		return ((jint)PO_FAIL);
422414388d7Ssl 	else
423414388d7Ssl 		return ((jint)status);
4247c478bd9Sstevel@tonic-gate }
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate /*
4277c478bd9Sstevel@tonic-gate  * pool_set_status(3pool) wrapper
4287c478bd9Sstevel@tonic-gate  */
4297c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4307c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1status(JNIEnv * jenv,jclass jcls,jint jstate)4317c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1status(JNIEnv *jenv,
432*03dfa5baSToomas Soome     jclass jcls, jint jstate)
433*03dfa5baSToomas Soome {
4347c478bd9Sstevel@tonic-gate 	return ((jint)pool_set_status((int)jstate));
4357c478bd9Sstevel@tonic-gate }
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate /*
4387c478bd9Sstevel@tonic-gate  * pool_conf_alloc(3pool) wrapper
4397c478bd9Sstevel@tonic-gate  */
4407c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4417c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1alloc(JNIEnv * jenv,jclass jcls)4427c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1alloc(JNIEnv *jenv,
443*03dfa5baSToomas Soome     jclass jcls)
444*03dfa5baSToomas Soome {
4457c478bd9Sstevel@tonic-gate 	return ((jlong)(uintptr_t)pool_conf_alloc());
4467c478bd9Sstevel@tonic-gate }
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate /*
4497c478bd9Sstevel@tonic-gate  * pool_conf_free(3pool) wrapper
4507c478bd9Sstevel@tonic-gate  */
4517c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4527c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1free(JNIEnv * jenv,jclass jcls,jlong jconf)4537c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1free(JNIEnv *jenv,
454*03dfa5baSToomas Soome     jclass jcls, jlong jconf)
455*03dfa5baSToomas Soome {
456414388d7Ssl 	pool_conf_free((pool_conf_t *)(uintptr_t)jconf);
4577c478bd9Sstevel@tonic-gate }
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate /*
4607c478bd9Sstevel@tonic-gate  * pool_conf_status(3pool) wrapper
4617c478bd9Sstevel@tonic-gate  */
4627c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4637c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1status(JNIEnv * jenv,jclass jcls,jlong jconf)4647c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1status(JNIEnv *jenv,
465*03dfa5baSToomas Soome     jclass jcls, jlong jconf)
466*03dfa5baSToomas Soome {
467414388d7Ssl 	return ((jint)pool_conf_status((pool_conf_t *)(uintptr_t)jconf));
4687c478bd9Sstevel@tonic-gate }
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate /*
4717c478bd9Sstevel@tonic-gate  * pool_conf_close(3pool) wrapper
4727c478bd9Sstevel@tonic-gate  */
4737c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4747c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1close(JNIEnv * jenv,jclass jcls,jlong jconf)4757c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1close(JNIEnv *jenv,
476*03dfa5baSToomas Soome     jclass jcls, jlong jconf)
477*03dfa5baSToomas Soome {
478414388d7Ssl 	return ((jint)pool_conf_close((pool_conf_t *)(uintptr_t)jconf));
4797c478bd9Sstevel@tonic-gate }
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate /*
4827c478bd9Sstevel@tonic-gate  * pool_conf_remove(3pool) wrapper
4837c478bd9Sstevel@tonic-gate  */
4847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4857c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1remove(JNIEnv * jenv,jclass jcls,jlong jconf)4867c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1remove(JNIEnv *jenv,
487*03dfa5baSToomas Soome     jclass jcls, jlong jconf)
488*03dfa5baSToomas Soome {
489414388d7Ssl 	return ((jint)pool_conf_remove((pool_conf_t *)(uintptr_t)jconf));
4907c478bd9Sstevel@tonic-gate }
4917c478bd9Sstevel@tonic-gate 
4927c478bd9Sstevel@tonic-gate /*
4937c478bd9Sstevel@tonic-gate  * pool_conf_open(3pool) wrapper
4947c478bd9Sstevel@tonic-gate  */
4957c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4967c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1open(JNIEnv * jenv,jclass jcls,jlong jconf,jstring jlocation,jint jflags)4977c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1open(JNIEnv *jenv,
498*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jstring jlocation, jint jflags)
499*03dfa5baSToomas Soome {
5007c478bd9Sstevel@tonic-gate 	const char *location;
5017c478bd9Sstevel@tonic-gate 	int result;
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate 	location = (jlocation) ? (*jenv)->GetStringUTFChars(jenv,
5047c478bd9Sstevel@tonic-gate 	    jlocation, 0) : NULL;
505414388d7Ssl 	result = (int)pool_conf_open((pool_conf_t *)(uintptr_t)jconf, location,
5067c478bd9Sstevel@tonic-gate 	    (int)jflags);
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate 	if (location)
5097c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jlocation, location);
5107c478bd9Sstevel@tonic-gate 	return ((jint)result);
5117c478bd9Sstevel@tonic-gate }
5127c478bd9Sstevel@tonic-gate 
5137c478bd9Sstevel@tonic-gate /*
5147c478bd9Sstevel@tonic-gate  * pool_conf_rollback(3pool) wrapper
5157c478bd9Sstevel@tonic-gate  */
5167c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5177c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1rollback(JNIEnv * jenv,jclass jcls,jlong jconf)5187c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1rollback(
519*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf)
520*03dfa5baSToomas Soome {
521414388d7Ssl 	return ((jint)pool_conf_rollback((pool_conf_t *)(uintptr_t)jconf));
5227c478bd9Sstevel@tonic-gate }
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate /*
5257c478bd9Sstevel@tonic-gate  * pool_conf_commit(3pool) wrapper
5267c478bd9Sstevel@tonic-gate  */
5277c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5287c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1commit(JNIEnv * jenv,jclass jcls,jlong jconf,jint jactive)5297c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1commit(JNIEnv *jenv,
530*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jint jactive)
531*03dfa5baSToomas Soome {
532414388d7Ssl 	return ((jint)pool_conf_commit(
533414388d7Ssl 	    (pool_conf_t *)(uintptr_t)jconf, (int)jactive));
5347c478bd9Sstevel@tonic-gate }
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate /*
5377c478bd9Sstevel@tonic-gate  * pool_conf_export(3pool) wrapper
5387c478bd9Sstevel@tonic-gate  */
5397c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5407c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1export(JNIEnv * jenv,jclass jcls,jlong jconf,jstring jlocation,jint jformat)5417c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1export(JNIEnv *jenv,
542*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jstring jlocation, jint jformat)
543*03dfa5baSToomas Soome {
5447c478bd9Sstevel@tonic-gate 	const char *location;
5457c478bd9Sstevel@tonic-gate 	int result;
5467c478bd9Sstevel@tonic-gate 
5477c478bd9Sstevel@tonic-gate 	location = (jlocation) ? (*jenv)->GetStringUTFChars(jenv,
5487c478bd9Sstevel@tonic-gate 	    jlocation, 0) : NULL;
549414388d7Ssl 	result = (int)pool_conf_export((pool_conf_t *)(uintptr_t)jconf,
5507c478bd9Sstevel@tonic-gate 	    location, (pool_export_format_t)jformat);
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate 	if (location)
5537c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jlocation, location);
5547c478bd9Sstevel@tonic-gate 	return ((jint)result);
5557c478bd9Sstevel@tonic-gate }
5567c478bd9Sstevel@tonic-gate 
5577c478bd9Sstevel@tonic-gate /*
5587c478bd9Sstevel@tonic-gate  * pool_conf_validate(3pool) wrapper
5597c478bd9Sstevel@tonic-gate  */
5607c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5617c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1validate(JNIEnv * jenv,jclass jcls,jlong jconf,jint jlevel)5627c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1validate(
563*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jint jlevel)
564*03dfa5baSToomas Soome {
565414388d7Ssl 	return ((jint)pool_conf_validate((pool_conf_t *)(uintptr_t)jconf,
566*03dfa5baSToomas Soome 	    (pool_valid_level_t)jlevel));
5677c478bd9Sstevel@tonic-gate }
5687c478bd9Sstevel@tonic-gate 
5697c478bd9Sstevel@tonic-gate /*
5707c478bd9Sstevel@tonic-gate  * pool_conf_update(3pool) wrapper
5717c478bd9Sstevel@tonic-gate  */
5727c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5737c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1update(JNIEnv * jenv,jclass jcls,jlong jconf)5747c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1update(JNIEnv *jenv,
575*03dfa5baSToomas Soome     jclass jcls, jlong jconf)
576*03dfa5baSToomas Soome {
5777c478bd9Sstevel@tonic-gate 	int changed;
5787c478bd9Sstevel@tonic-gate 	int result;
5797c478bd9Sstevel@tonic-gate 
580414388d7Ssl 	result = pool_conf_update((pool_conf_t *)(uintptr_t)jconf, &changed);
5817c478bd9Sstevel@tonic-gate 
5827c478bd9Sstevel@tonic-gate 	if (result != PO_SUCCESS) {
5837c478bd9Sstevel@tonic-gate 		throw_pe(jenv);
5847c478bd9Sstevel@tonic-gate 	}
5857c478bd9Sstevel@tonic-gate 
5867c478bd9Sstevel@tonic-gate 	return ((jint)changed);
5877c478bd9Sstevel@tonic-gate }
5887c478bd9Sstevel@tonic-gate 
5897c478bd9Sstevel@tonic-gate /*
5907c478bd9Sstevel@tonic-gate  * pool_get_pool(3pool) wrapper
5917c478bd9Sstevel@tonic-gate  */
5927c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5937c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1pool(JNIEnv * jenv,jclass jcls,jlong jconf,jstring jname)5947c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1pool(JNIEnv *jenv,
595*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jstring jname)
596*03dfa5baSToomas Soome {
5977c478bd9Sstevel@tonic-gate 	const char *name;
5987c478bd9Sstevel@tonic-gate 	pool_t *result;
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) :
6017c478bd9Sstevel@tonic-gate 	    NULL;
602414388d7Ssl 	result = (pool_t *)pool_get_pool((pool_conf_t *)(uintptr_t)jconf, name);
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate 	if (name)
6057c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
6067c478bd9Sstevel@tonic-gate 	return ((jlong)(uintptr_t)result);
6077c478bd9Sstevel@tonic-gate }
6087c478bd9Sstevel@tonic-gate 
6097c478bd9Sstevel@tonic-gate /*
6107c478bd9Sstevel@tonic-gate  * pool_query_pools(3pool) wrapper
6117c478bd9Sstevel@tonic-gate  */
6127c478bd9Sstevel@tonic-gate /*ARGSUSED*/
6137c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pools(JNIEnv * jenv,jclass jcls,jlong jconf,jobject jprops)6147c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pools(JNIEnv *jenv,
615*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jobject jprops)
616*03dfa5baSToomas Soome {
6177c478bd9Sstevel@tonic-gate 	pool_value_t **props;
6187c478bd9Sstevel@tonic-gate 	pool_t **result;
6197c478bd9Sstevel@tonic-gate 	jclass Lclazz;
6207c478bd9Sstevel@tonic-gate 	jmethodID Lsize;
6217c478bd9Sstevel@tonic-gate 	jint size;
6227c478bd9Sstevel@tonic-gate 	uint_t nelem;
6237c478bd9Sstevel@tonic-gate 	int i;
6247c478bd9Sstevel@tonic-gate 
6257c478bd9Sstevel@tonic-gate 
6267c478bd9Sstevel@tonic-gate 	/*
6277c478bd9Sstevel@tonic-gate 	 * Initialize the target parameter for case when input is null
6287c478bd9Sstevel@tonic-gate 	 */
6297c478bd9Sstevel@tonic-gate 	props = NULL;
6307c478bd9Sstevel@tonic-gate 	if (jprops != NULL) {
6317c478bd9Sstevel@tonic-gate 		Lclazz = (*jenv)->GetObjectClass(jenv, jprops);
6327c478bd9Sstevel@tonic-gate 		Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I");
6337c478bd9Sstevel@tonic-gate 		size = (*jenv)->CallIntMethod(jenv, jprops, Lsize);
6347c478bd9Sstevel@tonic-gate 
6357c478bd9Sstevel@tonic-gate 		if (size != 0) {
6367c478bd9Sstevel@tonic-gate 			jmethodID Lget;
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate 			Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get",
6397c478bd9Sstevel@tonic-gate 			    "(I)Ljava/lang/Object;");
6407c478bd9Sstevel@tonic-gate 			/*
6417c478bd9Sstevel@tonic-gate 			 * Allocate space for the props array
6427c478bd9Sstevel@tonic-gate 			 */
6437c478bd9Sstevel@tonic-gate 
6447c478bd9Sstevel@tonic-gate 			if ((props = calloc(size + 1, sizeof (pool_value_t *)))
6457c478bd9Sstevel@tonic-gate 			    == NULL) {
6467c478bd9Sstevel@tonic-gate 				throwException(jenv, "java/lang/Exception",
6477c478bd9Sstevel@tonic-gate 				    "Could not allocate props array");
6487c478bd9Sstevel@tonic-gate 				return (NULL);
6497c478bd9Sstevel@tonic-gate 			}
6507c478bd9Sstevel@tonic-gate 			/*
6517c478bd9Sstevel@tonic-gate 			 * Copy in the array
6527c478bd9Sstevel@tonic-gate 			 */
6537c478bd9Sstevel@tonic-gate 			for (i = 0; i < size; i++) {
6547c478bd9Sstevel@tonic-gate 				jobject aVal;
6557c478bd9Sstevel@tonic-gate 				jclass Vclazz;
6567c478bd9Sstevel@tonic-gate 				jfieldID Vthis;
6577c478bd9Sstevel@tonic-gate 				jlong this;
6587c478bd9Sstevel@tonic-gate 
6597c478bd9Sstevel@tonic-gate 				aVal = (*jenv)->CallObjectMethod(jenv, jprops,
6607c478bd9Sstevel@tonic-gate 				    Lget, (jint) i);
6617c478bd9Sstevel@tonic-gate 				Vclazz = (*jenv)->GetObjectClass(jenv, aVal);
6627c478bd9Sstevel@tonic-gate 				Vthis = (*jenv)->GetFieldID(jenv, Vclazz,
6637c478bd9Sstevel@tonic-gate 				    "_this", "J");
6647c478bd9Sstevel@tonic-gate 				this = (*jenv)->GetLongField(jenv, aVal, Vthis);
665414388d7Ssl 				props[i] = (pool_value_t *)(uintptr_t)this;
6667c478bd9Sstevel@tonic-gate 			}
6677c478bd9Sstevel@tonic-gate 		}
6687c478bd9Sstevel@tonic-gate 	}
669414388d7Ssl 	result = pool_query_pools((pool_conf_t *)(uintptr_t)jconf, &nelem,
6707c478bd9Sstevel@tonic-gate 	    props);
6717c478bd9Sstevel@tonic-gate 	free(props);
6727c478bd9Sstevel@tonic-gate 	return (copyArray(jenv, (void **)result));
6737c478bd9Sstevel@tonic-gate }
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate /*
6767c478bd9Sstevel@tonic-gate  * pool_get_resource(3pool) wrapper
6777c478bd9Sstevel@tonic-gate  */
6787c478bd9Sstevel@tonic-gate /*ARGSUSED*/
6797c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource(JNIEnv * jenv,jclass jcls,jlong jconf,jstring jtype,jstring jname)6807c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource(
681*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jstring jtype, jstring jname)
682*03dfa5baSToomas Soome {
6837c478bd9Sstevel@tonic-gate 	const char *type;
6847c478bd9Sstevel@tonic-gate 	const char *name;
6857c478bd9Sstevel@tonic-gate 	pool_resource_t *result;
6867c478bd9Sstevel@tonic-gate 
6877c478bd9Sstevel@tonic-gate 	type = (jtype) ? (*jenv)->GetStringUTFChars(jenv, jtype, 0) :
6887c478bd9Sstevel@tonic-gate 	    NULL;
6897c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) :
6907c478bd9Sstevel@tonic-gate 	    NULL;
691414388d7Ssl 	result = pool_get_resource((pool_conf_t *)(uintptr_t)jconf, type, name);
6927c478bd9Sstevel@tonic-gate 
6937c478bd9Sstevel@tonic-gate 	if (type)
6947c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jtype, type);
6957c478bd9Sstevel@tonic-gate 	if (name)
6967c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
6977c478bd9Sstevel@tonic-gate 	return ((jlong)(uintptr_t)result);
6987c478bd9Sstevel@tonic-gate }
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate /*
7017c478bd9Sstevel@tonic-gate  * pool_query_resources(3pool) wrapper
7027c478bd9Sstevel@tonic-gate  */
7037c478bd9Sstevel@tonic-gate /*ARGSUSED*/
7047c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resources(JNIEnv * jenv,jclass jcls,jlong jconf,jobject jprops)7057c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resources(
706*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jobject jprops)
707*03dfa5baSToomas Soome {
7087c478bd9Sstevel@tonic-gate 	pool_value_t **props;
7097c478bd9Sstevel@tonic-gate 	pool_resource_t **result;
7107c478bd9Sstevel@tonic-gate 	jclass Lclazz;
7117c478bd9Sstevel@tonic-gate 	jmethodID Lsize;
7127c478bd9Sstevel@tonic-gate 	jint size;
7137c478bd9Sstevel@tonic-gate 	uint_t nelem;
7147c478bd9Sstevel@tonic-gate 	int i;
7157c478bd9Sstevel@tonic-gate 
7167c478bd9Sstevel@tonic-gate 	/*
7177c478bd9Sstevel@tonic-gate 	 * Initialize the target parameter for case when input is null
7187c478bd9Sstevel@tonic-gate 	 */
7197c478bd9Sstevel@tonic-gate 	props = NULL;
7207c478bd9Sstevel@tonic-gate 	if (jprops != NULL) {
7217c478bd9Sstevel@tonic-gate 		Lclazz = (*jenv)->GetObjectClass(jenv, jprops);
7227c478bd9Sstevel@tonic-gate 		Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I");
7237c478bd9Sstevel@tonic-gate 		size = (*jenv)->CallIntMethod(jenv, jprops, Lsize);
7247c478bd9Sstevel@tonic-gate 
7257c478bd9Sstevel@tonic-gate 		if (size != 0) {
7267c478bd9Sstevel@tonic-gate 			jmethodID Lget;
7277c478bd9Sstevel@tonic-gate 
7287c478bd9Sstevel@tonic-gate 			Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get",
7297c478bd9Sstevel@tonic-gate 			    "(I)Ljava/lang/Object;");
7307c478bd9Sstevel@tonic-gate 			/*
7317c478bd9Sstevel@tonic-gate 			 * Allocate space for the props array
7327c478bd9Sstevel@tonic-gate 			 */
7337c478bd9Sstevel@tonic-gate 			if ((props = calloc(size + 1, sizeof (pool_value_t *)))
7347c478bd9Sstevel@tonic-gate 			    == NULL) {
7357c478bd9Sstevel@tonic-gate 				throwException(jenv, "java/lang/Exception",
7367c478bd9Sstevel@tonic-gate 				    "Could not allocate props array");
7377c478bd9Sstevel@tonic-gate 				return (NULL);
7387c478bd9Sstevel@tonic-gate 			}
7397c478bd9Sstevel@tonic-gate 			/*
7407c478bd9Sstevel@tonic-gate 			 * Copy in the array
7417c478bd9Sstevel@tonic-gate 			 */
7427c478bd9Sstevel@tonic-gate 			for (i = 0; i < size; i++) {
7437c478bd9Sstevel@tonic-gate 				jobject aVal;
7447c478bd9Sstevel@tonic-gate 				jclass Vclazz;
7457c478bd9Sstevel@tonic-gate 				jfieldID Vthis;
7467c478bd9Sstevel@tonic-gate 				jlong this;
7477c478bd9Sstevel@tonic-gate 
7487c478bd9Sstevel@tonic-gate 
7497c478bd9Sstevel@tonic-gate 				aVal = (*jenv)->CallObjectMethod(jenv, jprops,
7507c478bd9Sstevel@tonic-gate 				    Lget, (jint) i);
7517c478bd9Sstevel@tonic-gate 				Vclazz = (*jenv)->GetObjectClass(jenv, aVal);
7527c478bd9Sstevel@tonic-gate 				Vthis = (*jenv)->GetFieldID(jenv, Vclazz,
7537c478bd9Sstevel@tonic-gate 				    "_this", "J");
7547c478bd9Sstevel@tonic-gate 				this = (*jenv)->GetLongField(jenv, aVal, Vthis);
755414388d7Ssl 				props[i] = (pool_value_t *)(uintptr_t)this;
7567c478bd9Sstevel@tonic-gate 			}
7577c478bd9Sstevel@tonic-gate 		}
7587c478bd9Sstevel@tonic-gate 	}
759414388d7Ssl 	result = pool_query_resources((pool_conf_t *)(uintptr_t)jconf, &nelem,
7607c478bd9Sstevel@tonic-gate 	    props);
7617c478bd9Sstevel@tonic-gate 	free(props);
7627c478bd9Sstevel@tonic-gate 	return (copyArray(jenv, (void *)result));
7637c478bd9Sstevel@tonic-gate }
7647c478bd9Sstevel@tonic-gate 
7657c478bd9Sstevel@tonic-gate /*
7667c478bd9Sstevel@tonic-gate  * pool_query_components(3pool) wrapper
7677c478bd9Sstevel@tonic-gate  */
7687c478bd9Sstevel@tonic-gate /*ARGSUSED*/
7697c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1components(JNIEnv * jenv,jclass jcls,jlong jconf,jobject jprops)7707c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1components(
771*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jobject jprops)
772*03dfa5baSToomas Soome {
7737c478bd9Sstevel@tonic-gate 	pool_value_t **props;
7747c478bd9Sstevel@tonic-gate 	pool_component_t **result;
7757c478bd9Sstevel@tonic-gate 	jclass Lclazz;
7767c478bd9Sstevel@tonic-gate 	jmethodID Lsize;
7777c478bd9Sstevel@tonic-gate 	jint size;
7787c478bd9Sstevel@tonic-gate 	uint_t nelem;
7797c478bd9Sstevel@tonic-gate 	int i;
7807c478bd9Sstevel@tonic-gate 
7817c478bd9Sstevel@tonic-gate 	/*
7827c478bd9Sstevel@tonic-gate 	 * Initialize the target parameter for case when input is null
7837c478bd9Sstevel@tonic-gate 	 */
7847c478bd9Sstevel@tonic-gate 	props = NULL;
7857c478bd9Sstevel@tonic-gate 	if (jprops != NULL) {
7867c478bd9Sstevel@tonic-gate 		Lclazz = (*jenv)->GetObjectClass(jenv, jprops);
7877c478bd9Sstevel@tonic-gate 		Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I");
7887c478bd9Sstevel@tonic-gate 		size = (*jenv)->CallIntMethod(jenv, jprops, Lsize);
7897c478bd9Sstevel@tonic-gate 
7907c478bd9Sstevel@tonic-gate 		if (size != 0) {
7917c478bd9Sstevel@tonic-gate 			jmethodID Lget;
7927c478bd9Sstevel@tonic-gate 
7937c478bd9Sstevel@tonic-gate 			Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get",
7947c478bd9Sstevel@tonic-gate 			    "(I)Ljava/lang/Object;");
7957c478bd9Sstevel@tonic-gate 			/*
7967c478bd9Sstevel@tonic-gate 			 * Allocate space for the props array
7977c478bd9Sstevel@tonic-gate 			 */
7987c478bd9Sstevel@tonic-gate 
7997c478bd9Sstevel@tonic-gate 			if ((props = calloc(size + 1, sizeof (pool_value_t *)))
8007c478bd9Sstevel@tonic-gate 			    == NULL) {
8017c478bd9Sstevel@tonic-gate 				throwException(jenv, "java/lang/Exception",
8027c478bd9Sstevel@tonic-gate 				    "Could not allocate props array");
8037c478bd9Sstevel@tonic-gate 				return (NULL);
8047c478bd9Sstevel@tonic-gate 			}
8057c478bd9Sstevel@tonic-gate 			/*
8067c478bd9Sstevel@tonic-gate 			 * Copy in the array
8077c478bd9Sstevel@tonic-gate 			 */
8087c478bd9Sstevel@tonic-gate 			for (i = 0; i < size; i++) {
8097c478bd9Sstevel@tonic-gate 				jobject aVal;
8107c478bd9Sstevel@tonic-gate 				jclass Vclazz;
8117c478bd9Sstevel@tonic-gate 				jfieldID Vthis;
8127c478bd9Sstevel@tonic-gate 				jlong this;
8137c478bd9Sstevel@tonic-gate 
8147c478bd9Sstevel@tonic-gate 				aVal = (*jenv)->CallObjectMethod(jenv, jprops,
8157c478bd9Sstevel@tonic-gate 				    Lget, (jint) i);
8167c478bd9Sstevel@tonic-gate 				Vclazz = (*jenv)->GetObjectClass(jenv, aVal);
8177c478bd9Sstevel@tonic-gate 				Vthis = (*jenv)->GetFieldID(jenv, Vclazz,
8187c478bd9Sstevel@tonic-gate 				    "_this", "J");
8197c478bd9Sstevel@tonic-gate 				this = (*jenv)->GetLongField(jenv, aVal, Vthis);
820414388d7Ssl 				props[i] = (pool_value_t *)(uintptr_t)this;
8217c478bd9Sstevel@tonic-gate 			}
8227c478bd9Sstevel@tonic-gate 		}
8237c478bd9Sstevel@tonic-gate 	}
824414388d7Ssl 	result = pool_query_components((pool_conf_t *)(uintptr_t)jconf, &nelem,
8257c478bd9Sstevel@tonic-gate 	    props);
8267c478bd9Sstevel@tonic-gate 	free(props);
8277c478bd9Sstevel@tonic-gate 	return (copyArray(jenv, (void **)result));
8287c478bd9Sstevel@tonic-gate }
8297c478bd9Sstevel@tonic-gate 
8307c478bd9Sstevel@tonic-gate /*
8317c478bd9Sstevel@tonic-gate  * pool_conf_location(3pool) wrapper
8327c478bd9Sstevel@tonic-gate  */
8337c478bd9Sstevel@tonic-gate /*ARGSUSED*/
8347c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1location(JNIEnv * jenv,jclass jcls,jlong jconf)8357c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1location(
836*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf)
837*03dfa5baSToomas Soome {
8387c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
8397c478bd9Sstevel@tonic-gate 	const char *result;
8407c478bd9Sstevel@tonic-gate 
841414388d7Ssl 	result = pool_conf_location((pool_conf_t *)(uintptr_t)jconf);
8427c478bd9Sstevel@tonic-gate 
8437c478bd9Sstevel@tonic-gate 	if (result)
8447c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
8457c478bd9Sstevel@tonic-gate 	return (jresult);
8467c478bd9Sstevel@tonic-gate }
8477c478bd9Sstevel@tonic-gate 
8487c478bd9Sstevel@tonic-gate /*
8497c478bd9Sstevel@tonic-gate  * pool_conf_info(3pool) wrapper
8507c478bd9Sstevel@tonic-gate  */
8517c478bd9Sstevel@tonic-gate /*ARGSUSED*/
8527c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1info(JNIEnv * jenv,jclass jcls,jlong jconf,jint jflags)8537c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1info(JNIEnv *jenv,
854*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jint jflags)
855*03dfa5baSToomas Soome {
8567c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
8577c478bd9Sstevel@tonic-gate 	const char *result;
8587c478bd9Sstevel@tonic-gate 
859414388d7Ssl 	result = pool_conf_info((pool_conf_t *)(uintptr_t)jconf, (int)jflags);
8607c478bd9Sstevel@tonic-gate 
8617c478bd9Sstevel@tonic-gate 	if (result)
8627c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
8637c478bd9Sstevel@tonic-gate 	free((void *)result);
8647c478bd9Sstevel@tonic-gate 	return (jresult);
8657c478bd9Sstevel@tonic-gate }
8667c478bd9Sstevel@tonic-gate 
8677c478bd9Sstevel@tonic-gate /*
8687c478bd9Sstevel@tonic-gate  * pool_resource_create(3pool) wrapper
8697c478bd9Sstevel@tonic-gate  */
8707c478bd9Sstevel@tonic-gate /*ARGSUSED*/
8717c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1create(JNIEnv * jenv,jclass jcls,jlong jconf,jstring jtype,jstring jname)8727c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1create(
873*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jstring jtype, jstring jname)
874*03dfa5baSToomas Soome {
8757c478bd9Sstevel@tonic-gate 	const char *type;
8767c478bd9Sstevel@tonic-gate 	const char *name;
8777c478bd9Sstevel@tonic-gate 	pool_resource_t *result;
8787c478bd9Sstevel@tonic-gate 
8797c478bd9Sstevel@tonic-gate 	type = (jtype) ? (*jenv)->GetStringUTFChars(jenv, jtype, 0) :
8807c478bd9Sstevel@tonic-gate 	    NULL;
8817c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) :
8827c478bd9Sstevel@tonic-gate 	    NULL;
883414388d7Ssl 	result =
884414388d7Ssl 	    pool_resource_create((pool_conf_t *)(uintptr_t)jconf, type, name);
8857c478bd9Sstevel@tonic-gate 
8867c478bd9Sstevel@tonic-gate 	if (type)
8877c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jtype, type);
8887c478bd9Sstevel@tonic-gate 	if (name)
8897c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
8907c478bd9Sstevel@tonic-gate 	return ((jlong)(uintptr_t)result);
8917c478bd9Sstevel@tonic-gate }
8927c478bd9Sstevel@tonic-gate 
8937c478bd9Sstevel@tonic-gate /*
8947c478bd9Sstevel@tonic-gate  * pool_resource_destroy(3pool) wrapper
8957c478bd9Sstevel@tonic-gate  */
8967c478bd9Sstevel@tonic-gate /*ARGSUSED*/
8977c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1destroy(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jresource)8987c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1destroy(
899*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource)
900*03dfa5baSToomas Soome {
901414388d7Ssl 	return ((jint)pool_resource_destroy((pool_conf_t *)(uintptr_t)jconf,
902*03dfa5baSToomas Soome 	    (pool_resource_t *)(uintptr_t)jresource));
9037c478bd9Sstevel@tonic-gate }
9047c478bd9Sstevel@tonic-gate 
9057c478bd9Sstevel@tonic-gate /*
9067c478bd9Sstevel@tonic-gate  * pool_resource_transfer(3pool) wrapper
9077c478bd9Sstevel@tonic-gate  */
9087c478bd9Sstevel@tonic-gate /*ARGSUSED*/
9097c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1transfer(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jsource,jlong jtarget,jlong jsize)9107c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1transfer(
9117c478bd9Sstevel@tonic-gate     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jsource, jlong jtarget,
912*03dfa5baSToomas Soome     jlong jsize)
913*03dfa5baSToomas Soome {
914414388d7Ssl 	return (pool_resource_transfer((pool_conf_t *)(uintptr_t)jconf,
915414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jsource,
916414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jtarget,
917414388d7Ssl 	    (uint64_t)jsize));
9187c478bd9Sstevel@tonic-gate }
9197c478bd9Sstevel@tonic-gate 
9207c478bd9Sstevel@tonic-gate /*
9217c478bd9Sstevel@tonic-gate  * pool_resource_xtransfer(3pool) wrapper
9227c478bd9Sstevel@tonic-gate  */
9237c478bd9Sstevel@tonic-gate /*ARGSUSED*/
9247c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1xtransfer(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jsource,jlong jtarget,jobject jcomponents)9257c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1xtransfer(
9267c478bd9Sstevel@tonic-gate     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jsource, jlong jtarget,
927*03dfa5baSToomas Soome     jobject jcomponents)
928*03dfa5baSToomas Soome {
9297c478bd9Sstevel@tonic-gate 	pool_component_t **components;
9307c478bd9Sstevel@tonic-gate 	int result;
9317c478bd9Sstevel@tonic-gate 	jclass Lclazz;
9327c478bd9Sstevel@tonic-gate 	jmethodID Lsize;
9337c478bd9Sstevel@tonic-gate 	jint size;
9347c478bd9Sstevel@tonic-gate 
9357c478bd9Sstevel@tonic-gate 	/*
9367c478bd9Sstevel@tonic-gate 	 * Initialize the target parameter for case when input is null
9377c478bd9Sstevel@tonic-gate 	 */
9387c478bd9Sstevel@tonic-gate 	components = NULL;
9397c478bd9Sstevel@tonic-gate 	if (jcomponents != NULL) {
9407c478bd9Sstevel@tonic-gate 		Lclazz = (*jenv)->GetObjectClass(jenv, jcomponents);
9417c478bd9Sstevel@tonic-gate 		Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I");
9427c478bd9Sstevel@tonic-gate 		size = (*jenv)->CallIntMethod(jenv, jcomponents, Lsize);
9437c478bd9Sstevel@tonic-gate 
9447c478bd9Sstevel@tonic-gate 		if (size != 0) {
9457c478bd9Sstevel@tonic-gate 			jmethodID Lget;
9467c478bd9Sstevel@tonic-gate 			int i;
9477c478bd9Sstevel@tonic-gate 
9487c478bd9Sstevel@tonic-gate 			Lget = (*jenv)->GetMethodID(jenv,
9497c478bd9Sstevel@tonic-gate 			    Lclazz, "get", "(I)Ljava/lang/Object;");
9507c478bd9Sstevel@tonic-gate 			/* Allocate space for the components array */
9517c478bd9Sstevel@tonic-gate 
9527c478bd9Sstevel@tonic-gate 			if ((components = calloc(size + 1,
9537c478bd9Sstevel@tonic-gate 			    sizeof (pool_component_t *))) == NULL) {
9547c478bd9Sstevel@tonic-gate 				throwException(jenv, "java/lang/Exception",
9557c478bd9Sstevel@tonic-gate 				    "Could not allocate component array");
956*03dfa5baSToomas Soome 				return (0);
9577c478bd9Sstevel@tonic-gate 			}
9587c478bd9Sstevel@tonic-gate 			/*
9597c478bd9Sstevel@tonic-gate 			 * Copy in the array
9607c478bd9Sstevel@tonic-gate 			 */
9617c478bd9Sstevel@tonic-gate 			for (i = 0; i < size; i++) {
9627c478bd9Sstevel@tonic-gate 				jobject aVal;
9637c478bd9Sstevel@tonic-gate 				jclass Vclazz;
9647c478bd9Sstevel@tonic-gate 				jlong this;
9657c478bd9Sstevel@tonic-gate 				jmethodID Vthis;
9667c478bd9Sstevel@tonic-gate 
9677c478bd9Sstevel@tonic-gate 				aVal = (*jenv)->CallObjectMethod(jenv,
9687c478bd9Sstevel@tonic-gate 				    jcomponents, Lget, (jint) i);
9697c478bd9Sstevel@tonic-gate 				Vclazz = (*jenv)->GetObjectClass(jenv,
9707c478bd9Sstevel@tonic-gate 				    aVal);
9717c478bd9Sstevel@tonic-gate 				Vthis = (*jenv)->GetMethodID(jenv,
9727c478bd9Sstevel@tonic-gate 				    Vclazz, "getComponent", "()J");
9737c478bd9Sstevel@tonic-gate 				this = (*jenv)->CallLongMethod(jenv,
9747c478bd9Sstevel@tonic-gate 				    aVal, Vthis);
975414388d7Ssl 				components[i] =
976414388d7Ssl 				    (pool_component_t *)(uintptr_t)this;
9777c478bd9Sstevel@tonic-gate 			}
9787c478bd9Sstevel@tonic-gate 		}
9797c478bd9Sstevel@tonic-gate 	}
980414388d7Ssl 	result = (int)pool_resource_xtransfer((pool_conf_t *)(uintptr_t)jconf,
981414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jsource,
982414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jtarget,
9837c478bd9Sstevel@tonic-gate 	    components);
9847c478bd9Sstevel@tonic-gate 	free(components);
9857c478bd9Sstevel@tonic-gate 
9867c478bd9Sstevel@tonic-gate 	return ((jint)result);
9877c478bd9Sstevel@tonic-gate }
9887c478bd9Sstevel@tonic-gate 
9897c478bd9Sstevel@tonic-gate /*
9907c478bd9Sstevel@tonic-gate  * pool_query_resource_components(3pool) wrapper
9917c478bd9Sstevel@tonic-gate  */
9927c478bd9Sstevel@tonic-gate /*ARGSUSED*/
9937c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resource_1components(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jresource,jobject jprops)9947c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resource_\
9957c478bd9Sstevel@tonic-gate 1components(JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource,
996*03dfa5baSToomas Soome     jobject jprops)
997*03dfa5baSToomas Soome {
9987c478bd9Sstevel@tonic-gate 	pool_value_t **props;
9997c478bd9Sstevel@tonic-gate 	pool_component_t **result;
10007c478bd9Sstevel@tonic-gate 	jclass Lclazz;
10017c478bd9Sstevel@tonic-gate 	jmethodID Lsize;
10027c478bd9Sstevel@tonic-gate 	uint_t nelem;
10037c478bd9Sstevel@tonic-gate 	jint size;
10047c478bd9Sstevel@tonic-gate 
10057c478bd9Sstevel@tonic-gate 	/*
10067c478bd9Sstevel@tonic-gate 	 * Initialize the target parameter for case when input is null
10077c478bd9Sstevel@tonic-gate 	 */
10087c478bd9Sstevel@tonic-gate 	props = NULL;
10097c478bd9Sstevel@tonic-gate 	if (jprops != NULL) {
10107c478bd9Sstevel@tonic-gate 		Lclazz = (*jenv)->GetObjectClass(jenv, jprops);
10117c478bd9Sstevel@tonic-gate 		Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I");
10127c478bd9Sstevel@tonic-gate 		size = (*jenv)->CallIntMethod(jenv, jprops, Lsize);
10137c478bd9Sstevel@tonic-gate 
10147c478bd9Sstevel@tonic-gate 		if (size != 0) {
10157c478bd9Sstevel@tonic-gate 			jmethodID Lget;
10167c478bd9Sstevel@tonic-gate 			int i;
10177c478bd9Sstevel@tonic-gate 
10187c478bd9Sstevel@tonic-gate 			Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get",
10197c478bd9Sstevel@tonic-gate 			    "(I)Ljava/lang/Object;");
10207c478bd9Sstevel@tonic-gate 			/*
10217c478bd9Sstevel@tonic-gate 			 * Allocate space for the props array
10227c478bd9Sstevel@tonic-gate 			 */
10237c478bd9Sstevel@tonic-gate 			if ((props = calloc(size + 1, sizeof (pool_value_t *)))
10247c478bd9Sstevel@tonic-gate 			    == NULL) {
10257c478bd9Sstevel@tonic-gate 				throwException(jenv, "java/lang/Exception",
10267c478bd9Sstevel@tonic-gate 				    "Could not allocate props array");
10277c478bd9Sstevel@tonic-gate 				return (NULL);
10287c478bd9Sstevel@tonic-gate 			}
10297c478bd9Sstevel@tonic-gate 			/*
10307c478bd9Sstevel@tonic-gate 			 * Copy in the array
10317c478bd9Sstevel@tonic-gate 			 */
10327c478bd9Sstevel@tonic-gate 			for (i = 0; i < size; i++) {
10337c478bd9Sstevel@tonic-gate 				jobject aVal;
10347c478bd9Sstevel@tonic-gate 				jclass Vclazz;
10357c478bd9Sstevel@tonic-gate 				jfieldID Vthis;
10367c478bd9Sstevel@tonic-gate 				jlong this;
10377c478bd9Sstevel@tonic-gate 
10387c478bd9Sstevel@tonic-gate 				aVal = (*jenv)->CallObjectMethod(jenv, jprops,
10397c478bd9Sstevel@tonic-gate 				    Lget, (jint) i);
10407c478bd9Sstevel@tonic-gate 				Vclazz = (*jenv)->GetObjectClass(jenv, aVal);
10417c478bd9Sstevel@tonic-gate 				Vthis = (*jenv)->GetFieldID(jenv, Vclazz,
10427c478bd9Sstevel@tonic-gate 				    "_this", "J");
10437c478bd9Sstevel@tonic-gate 				this = (*jenv)->GetLongField(jenv, aVal, Vthis);
1044414388d7Ssl 				props[i] = (pool_value_t *)(uintptr_t)this;
10457c478bd9Sstevel@tonic-gate 			}
10467c478bd9Sstevel@tonic-gate 		}
10477c478bd9Sstevel@tonic-gate 	}
1048414388d7Ssl 	result = pool_query_resource_components(
1049414388d7Ssl 	    (pool_conf_t *)(uintptr_t)jconf,
1050414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jresource, &nelem, props);
10517c478bd9Sstevel@tonic-gate 	free(props);
10527c478bd9Sstevel@tonic-gate 	return (copyArray(jenv, (void **)result));
10537c478bd9Sstevel@tonic-gate }
10547c478bd9Sstevel@tonic-gate 
10557c478bd9Sstevel@tonic-gate /*
10567c478bd9Sstevel@tonic-gate  * pool_resource_info(3pool) wrapper
10577c478bd9Sstevel@tonic-gate  */
10587c478bd9Sstevel@tonic-gate /*ARGSUSED*/
10597c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1info(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jresource,jint jflags)10607c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1info(
1061*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource, jint jflags)
1062*03dfa5baSToomas Soome {
10637c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
10647c478bd9Sstevel@tonic-gate 	const char *result;
10657c478bd9Sstevel@tonic-gate 
1066414388d7Ssl 	result = pool_resource_info((pool_conf_t *)(uintptr_t)jconf,
1067414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jresource, (int)jflags);
10687c478bd9Sstevel@tonic-gate 
10697c478bd9Sstevel@tonic-gate 	if (result)
10707c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
10717c478bd9Sstevel@tonic-gate 	free((void *)result);
10727c478bd9Sstevel@tonic-gate 	return (jresult);
10737c478bd9Sstevel@tonic-gate }
10747c478bd9Sstevel@tonic-gate 
10757c478bd9Sstevel@tonic-gate /*
10767c478bd9Sstevel@tonic-gate  * pool_create(3pool) wrapper
10777c478bd9Sstevel@tonic-gate  */
10787c478bd9Sstevel@tonic-gate /*ARGSUSED*/
10797c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1create(JNIEnv * jenv,jclass jcls,jlong jconf,jstring jname)10807c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1create(JNIEnv *jenv,
1081*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jstring jname)
1082*03dfa5baSToomas Soome {
10837c478bd9Sstevel@tonic-gate 	const char *name;
10847c478bd9Sstevel@tonic-gate 	pool_t *result;
10857c478bd9Sstevel@tonic-gate 
10867c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) :
10877c478bd9Sstevel@tonic-gate 	    NULL;
1088414388d7Ssl 	result = pool_create((pool_conf_t *)(uintptr_t)jconf, name);
10897c478bd9Sstevel@tonic-gate 
10907c478bd9Sstevel@tonic-gate 	if (name)
10917c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
10927c478bd9Sstevel@tonic-gate 	return ((jlong)(uintptr_t)result);
10937c478bd9Sstevel@tonic-gate }
10947c478bd9Sstevel@tonic-gate 
10957c478bd9Sstevel@tonic-gate /*
10967c478bd9Sstevel@tonic-gate  * pool_destroy(3pool) wrapper
10977c478bd9Sstevel@tonic-gate  */
10987c478bd9Sstevel@tonic-gate /*ARGSUSED*/
10997c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1destroy(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jpool)11007c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1destroy(JNIEnv *jenv,
1101*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jlong jpool)
1102*03dfa5baSToomas Soome {
1103414388d7Ssl 	return ((jint)pool_destroy((pool_conf_t *)(uintptr_t)jconf,
1104414388d7Ssl 	    (pool_t *)(uintptr_t)jpool));
11057c478bd9Sstevel@tonic-gate }
11067c478bd9Sstevel@tonic-gate 
11077c478bd9Sstevel@tonic-gate /*
11087c478bd9Sstevel@tonic-gate  * pool_associate(3pool) wrapper
11097c478bd9Sstevel@tonic-gate  */
11107c478bd9Sstevel@tonic-gate /*ARGSUSED*/
11117c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1associate(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jpool,jlong jresource)11127c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1associate(JNIEnv *jenv,
1113*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jlong jpool, jlong jresource)
1114*03dfa5baSToomas Soome {
1115414388d7Ssl 	return ((jint)pool_associate((pool_conf_t *)(uintptr_t)jconf,
1116414388d7Ssl 	    (pool_t *)(uintptr_t)jpool,
1117414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jresource));
11187c478bd9Sstevel@tonic-gate }
11197c478bd9Sstevel@tonic-gate 
11207c478bd9Sstevel@tonic-gate /*
11217c478bd9Sstevel@tonic-gate  * pool_dissociate(3pool) wrapper
11227c478bd9Sstevel@tonic-gate  */
11237c478bd9Sstevel@tonic-gate /*ARGSUSED*/
11247c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1dissociate(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jpool,jlong jresource)11257c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1dissociate(JNIEnv *jenv,
1126*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jlong jpool, jlong jresource)
1127*03dfa5baSToomas Soome {
1128414388d7Ssl 	return ((jint)pool_dissociate((pool_conf_t *)(uintptr_t)jconf,
1129414388d7Ssl 	    (pool_t *)(uintptr_t)jpool,
1130414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jresource));
11317c478bd9Sstevel@tonic-gate }
11327c478bd9Sstevel@tonic-gate 
11337c478bd9Sstevel@tonic-gate /*
11347c478bd9Sstevel@tonic-gate  * pool_info(3pool) wrapper
11357c478bd9Sstevel@tonic-gate  */
11367c478bd9Sstevel@tonic-gate /*ARGSUSED*/
11377c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1info(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jpool,jint jflags)11387c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1info(JNIEnv *jenv,
1139*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jlong jpool, jint jflags)
1140*03dfa5baSToomas Soome {
11417c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
11427c478bd9Sstevel@tonic-gate 	const char *result;
11437c478bd9Sstevel@tonic-gate 
1144414388d7Ssl 	result = pool_info((pool_conf_t *)(uintptr_t)jconf,
1145414388d7Ssl 	    (pool_t *)(uintptr_t)jpool, (int)jflags);
11467c478bd9Sstevel@tonic-gate 
11477c478bd9Sstevel@tonic-gate 	if (result)
11487c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
11497c478bd9Sstevel@tonic-gate 	free((void *)result);
11507c478bd9Sstevel@tonic-gate 	return (jresult);
11517c478bd9Sstevel@tonic-gate }
11527c478bd9Sstevel@tonic-gate 
11537c478bd9Sstevel@tonic-gate /*
11547c478bd9Sstevel@tonic-gate  * pool_query_pool_resources(3pool) wrapper
11557c478bd9Sstevel@tonic-gate  */
11567c478bd9Sstevel@tonic-gate /*ARGSUSED*/
11577c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pool_1resources(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jpool,jobject jprops)11587c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pool_1resources(
1159*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jpool, jobject jprops)
1160*03dfa5baSToomas Soome {
11617c478bd9Sstevel@tonic-gate 	pool_value_t **props;
11627c478bd9Sstevel@tonic-gate 	pool_resource_t **result;
11637c478bd9Sstevel@tonic-gate 	jclass Lclazz;
11647c478bd9Sstevel@tonic-gate 	jmethodID Lsize;
11657c478bd9Sstevel@tonic-gate 	uint_t nelem;
11667c478bd9Sstevel@tonic-gate 	jint size;
11677c478bd9Sstevel@tonic-gate 
11687c478bd9Sstevel@tonic-gate 	/*
11697c478bd9Sstevel@tonic-gate 	 * Initialize the target parameter for case when input is null
11707c478bd9Sstevel@tonic-gate 	 */
11717c478bd9Sstevel@tonic-gate 	props = NULL;
11727c478bd9Sstevel@tonic-gate 	if (jprops != NULL) {
11737c478bd9Sstevel@tonic-gate 		Lclazz = (*jenv)->GetObjectClass(jenv, jprops);
11747c478bd9Sstevel@tonic-gate 		Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I");
11757c478bd9Sstevel@tonic-gate 		size = (*jenv)->CallIntMethod(jenv, jprops, Lsize);
11767c478bd9Sstevel@tonic-gate 
11777c478bd9Sstevel@tonic-gate 		if (size != 0) {
11787c478bd9Sstevel@tonic-gate 			jmethodID Lget;
11797c478bd9Sstevel@tonic-gate 			int i;
11807c478bd9Sstevel@tonic-gate 
11817c478bd9Sstevel@tonic-gate 			Lget = (*jenv)->GetMethodID(jenv,
11827c478bd9Sstevel@tonic-gate 			    Lclazz, "get", "(I)Ljava/lang/Object;");
11837c478bd9Sstevel@tonic-gate 			/*
11847c478bd9Sstevel@tonic-gate 			 * Allocate space for the props array
11857c478bd9Sstevel@tonic-gate 			 */
11867c478bd9Sstevel@tonic-gate 
11877c478bd9Sstevel@tonic-gate 			if ((props = calloc(size + 1, sizeof (pool_value_t *)))
11887c478bd9Sstevel@tonic-gate 			    == NULL) {
11897c478bd9Sstevel@tonic-gate 				throwException(jenv, "java/lang/Exception",
11907c478bd9Sstevel@tonic-gate 				    "Could not allocate props array");
11917c478bd9Sstevel@tonic-gate 				return (NULL);
11927c478bd9Sstevel@tonic-gate 			}
11937c478bd9Sstevel@tonic-gate 			/*
11947c478bd9Sstevel@tonic-gate 			 * Copy in the array
11957c478bd9Sstevel@tonic-gate 			 */
11967c478bd9Sstevel@tonic-gate 			for (i = 0; i < size; i++) {
11977c478bd9Sstevel@tonic-gate 				jobject aVal;
11987c478bd9Sstevel@tonic-gate 				jclass Vclazz;
11997c478bd9Sstevel@tonic-gate 				jfieldID Vthis;
12007c478bd9Sstevel@tonic-gate 				jlong this;
12017c478bd9Sstevel@tonic-gate 
12027c478bd9Sstevel@tonic-gate 				aVal = (*jenv)->CallObjectMethod(jenv, jprops,
12037c478bd9Sstevel@tonic-gate 				    Lget, (jint) i);
12047c478bd9Sstevel@tonic-gate 				Vclazz = (*jenv)->GetObjectClass(jenv, aVal);
12057c478bd9Sstevel@tonic-gate 				Vthis = (*jenv)->GetFieldID(jenv, Vclazz,
12067c478bd9Sstevel@tonic-gate 				    "_this", "J");
12077c478bd9Sstevel@tonic-gate 				this = (*jenv)->GetLongField(jenv, aVal, Vthis);
1208414388d7Ssl 				props[i] = (pool_value_t *)(uintptr_t)this;
12097c478bd9Sstevel@tonic-gate 			}
12107c478bd9Sstevel@tonic-gate 		}
12117c478bd9Sstevel@tonic-gate 	}
1212414388d7Ssl 	result = pool_query_pool_resources((pool_conf_t *)(uintptr_t)jconf,
1213414388d7Ssl 	    (pool_t *)(uintptr_t)jpool, &nelem, props);
12147c478bd9Sstevel@tonic-gate 	free(props);
12157c478bd9Sstevel@tonic-gate 	return (copyArray(jenv, (void **)result));
12167c478bd9Sstevel@tonic-gate }
12177c478bd9Sstevel@tonic-gate 
12187c478bd9Sstevel@tonic-gate /*
12197c478bd9Sstevel@tonic-gate  * pool_get_owning_resource(3pool) wrapper
12207c478bd9Sstevel@tonic-gate  */
12217c478bd9Sstevel@tonic-gate /*ARGSUSED*/
12227c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1owning_1resource(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jcomponent)12237c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1owning_1resource(
1224*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jcomponent)
1225*03dfa5baSToomas Soome {
1226414388d7Ssl 	return ((jlong)(uintptr_t)pool_get_owning_resource(
1227414388d7Ssl 	    (pool_conf_t *)(uintptr_t)jconf,
1228414388d7Ssl 	    (pool_component_t *)(uintptr_t)jcomponent));
12297c478bd9Sstevel@tonic-gate }
12307c478bd9Sstevel@tonic-gate 
12317c478bd9Sstevel@tonic-gate /*
12327c478bd9Sstevel@tonic-gate  * pool_component_info(3pool) wrapper
12337c478bd9Sstevel@tonic-gate  */
12347c478bd9Sstevel@tonic-gate /*ARGSUSED*/
12357c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1info(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jcomponent,jint jflags)12367c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1info(
1237*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jcomponent, jint jflags)
1238*03dfa5baSToomas Soome {
12397c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
12407c478bd9Sstevel@tonic-gate 	const char *result;
12417c478bd9Sstevel@tonic-gate 
1242414388d7Ssl 	result = pool_component_info((pool_conf_t *)(uintptr_t)jconf,
1243414388d7Ssl 	    (pool_component_t *)(uintptr_t)jcomponent, (int)jflags);
12447c478bd9Sstevel@tonic-gate 
12457c478bd9Sstevel@tonic-gate 	if (result)
12467c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
12477c478bd9Sstevel@tonic-gate 	free((void *)result);
12487c478bd9Sstevel@tonic-gate 	return (jresult);
12497c478bd9Sstevel@tonic-gate }
12507c478bd9Sstevel@tonic-gate 
12517c478bd9Sstevel@tonic-gate /*
12527c478bd9Sstevel@tonic-gate  * pool_get_property(3pool) wrapper
12537c478bd9Sstevel@tonic-gate  */
12547c478bd9Sstevel@tonic-gate /*ARGSUSED*/
12557c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1property(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jelem,jstring jname,jlong jproperty)12567c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1property(
12577c478bd9Sstevel@tonic-gate     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jelem, jstring jname,
1258*03dfa5baSToomas Soome     jlong jproperty)
1259*03dfa5baSToomas Soome {
12607c478bd9Sstevel@tonic-gate 	const char *name;
12617c478bd9Sstevel@tonic-gate 	int result;
12627c478bd9Sstevel@tonic-gate 
12637c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) :
12647c478bd9Sstevel@tonic-gate 	    NULL;
1265414388d7Ssl 	result = pool_get_property((pool_conf_t *)(uintptr_t)jconf,
1266414388d7Ssl 	    (pool_elem_t *)(uintptr_t)jelem, name,
1267414388d7Ssl 	    (pool_value_t *)(uintptr_t)jproperty);
12687c478bd9Sstevel@tonic-gate 
12697c478bd9Sstevel@tonic-gate 	if (name)
12707c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
12717c478bd9Sstevel@tonic-gate 	return ((jint)result);
12727c478bd9Sstevel@tonic-gate }
12737c478bd9Sstevel@tonic-gate 
12747c478bd9Sstevel@tonic-gate /*
12757c478bd9Sstevel@tonic-gate  * pool_put_property(3pool) wrapper
12767c478bd9Sstevel@tonic-gate  */
12777c478bd9Sstevel@tonic-gate /*ARGSUSED*/
12787c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1put_1property(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jelem,jstring jname,jlong jvalue)12797c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1put_1property(
12807c478bd9Sstevel@tonic-gate     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jelem, jstring jname,
1281*03dfa5baSToomas Soome     jlong jvalue)
1282*03dfa5baSToomas Soome {
12837c478bd9Sstevel@tonic-gate 	const char *name;
12847c478bd9Sstevel@tonic-gate 	int result;
12857c478bd9Sstevel@tonic-gate 
12867c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : NULL;
1287414388d7Ssl 	result = (int)pool_put_property((pool_conf_t *)(uintptr_t)jconf,
1288414388d7Ssl 	    (pool_elem_t *)(uintptr_t)jelem, name,
1289414388d7Ssl 	    (pool_value_t *)(uintptr_t)jvalue);
12907c478bd9Sstevel@tonic-gate 
12917c478bd9Sstevel@tonic-gate 	if (name)
12927c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
12937c478bd9Sstevel@tonic-gate 	return ((jint)result);
12947c478bd9Sstevel@tonic-gate }
12957c478bd9Sstevel@tonic-gate 
12967c478bd9Sstevel@tonic-gate /*
12977c478bd9Sstevel@tonic-gate  * pool_rm_property(3pool) wrapper
12987c478bd9Sstevel@tonic-gate  */
12997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
13007c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1rm_1property(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jelem,jstring jname)13017c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1rm_1property(JNIEnv *jenv,
1302*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jlong jelem, jstring jname)
1303*03dfa5baSToomas Soome {
13047c478bd9Sstevel@tonic-gate 	const char *name;
13057c478bd9Sstevel@tonic-gate 	int result;
13067c478bd9Sstevel@tonic-gate 
13077c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : NULL;
1308414388d7Ssl 	result = pool_rm_property((pool_conf_t *)(uintptr_t)jconf,
1309414388d7Ssl 	    (pool_elem_t *)(uintptr_t)jelem, name);
13107c478bd9Sstevel@tonic-gate 
13117c478bd9Sstevel@tonic-gate 	if (name)
13127c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
13137c478bd9Sstevel@tonic-gate 	return ((jint)result);
13147c478bd9Sstevel@tonic-gate }
13157c478bd9Sstevel@tonic-gate 
13167c478bd9Sstevel@tonic-gate /*
13177c478bd9Sstevel@tonic-gate  * pool_walk_properties(3pool) wrapper
13187c478bd9Sstevel@tonic-gate  */
13197c478bd9Sstevel@tonic-gate /*ARGSUSED*/
13207c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1properties(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jelem,jlong jarg,jlong jcallback)13217c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1properties(
13227c478bd9Sstevel@tonic-gate     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jelem, jlong jarg,
1323*03dfa5baSToomas Soome     jlong jcallback)
1324*03dfa5baSToomas Soome {
13257c478bd9Sstevel@tonic-gate 	int result;
13267c478bd9Sstevel@tonic-gate 
1327414388d7Ssl 	result = (int)pool_walk_properties((pool_conf_t *)(uintptr_t)jconf,
1328414388d7Ssl 	    (pool_elem_t *)(uintptr_t)jelem, (void *)(uintptr_t)jarg,
13297c478bd9Sstevel@tonic-gate 	    (int (*)(pool_conf_t *, pool_elem_t *, char const *,
1330*03dfa5baSToomas Soome 	    pool_value_t *, void *))(uintptr_t)jcallback);
13317c478bd9Sstevel@tonic-gate 
13327c478bd9Sstevel@tonic-gate 	return ((jint)result);
13337c478bd9Sstevel@tonic-gate }
13347c478bd9Sstevel@tonic-gate 
13357c478bd9Sstevel@tonic-gate /*
13367c478bd9Sstevel@tonic-gate  * pool_conf_to_elem(3pool) wrapper
13377c478bd9Sstevel@tonic-gate  */
13387c478bd9Sstevel@tonic-gate /*ARGSUSED*/
13397c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1to_1elem(JNIEnv * jenv,jclass jcls,jlong jconf)13407c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1to_1elem(
1341*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf)
1342*03dfa5baSToomas Soome {
1343414388d7Ssl 	return ((jlong)(uintptr_t)pool_conf_to_elem(
1344414388d7Ssl 	    (pool_conf_t *)(uintptr_t)jconf));
13457c478bd9Sstevel@tonic-gate }
13467c478bd9Sstevel@tonic-gate 
13477c478bd9Sstevel@tonic-gate /*
13487c478bd9Sstevel@tonic-gate  * pool_to_elem(3pool) wrapper
13497c478bd9Sstevel@tonic-gate  */
13507c478bd9Sstevel@tonic-gate /*ARGSUSED*/
13517c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1to_1elem(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jpool)13527c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1to_1elem(JNIEnv *jenv,
1353*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jlong jpool)
1354*03dfa5baSToomas Soome {
1355414388d7Ssl 	return ((jlong)(uintptr_t)pool_to_elem((pool_conf_t *)(uintptr_t)jconf,
1356414388d7Ssl 	    (pool_t *)(uintptr_t)jpool));
13577c478bd9Sstevel@tonic-gate }
13587c478bd9Sstevel@tonic-gate 
13597c478bd9Sstevel@tonic-gate /*
13607c478bd9Sstevel@tonic-gate  * pool_resource_to_elem(3pool) wrapper
13617c478bd9Sstevel@tonic-gate  */
13627c478bd9Sstevel@tonic-gate /*ARGSUSED*/
13637c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1to_1elem(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jresource)13647c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1to_1elem(
1365*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource)
1366*03dfa5baSToomas Soome {
1367414388d7Ssl 	return ((jlong)(uintptr_t)pool_resource_to_elem(
1368414388d7Ssl 	    (pool_conf_t *)(uintptr_t)jconf,
1369414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jresource));
13707c478bd9Sstevel@tonic-gate }
13717c478bd9Sstevel@tonic-gate 
13727c478bd9Sstevel@tonic-gate /*
13737c478bd9Sstevel@tonic-gate  * pool_component_to_elem(3pool) wrapper
13747c478bd9Sstevel@tonic-gate  */
13757c478bd9Sstevel@tonic-gate /*ARGSUSED*/
13767c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1to_1elem(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jcomponent)13777c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1to_1elem(
1378*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jcomponent)
1379*03dfa5baSToomas Soome {
1380414388d7Ssl 	return ((jlong)(uintptr_t)pool_component_to_elem(
1381414388d7Ssl 	    (pool_conf_t *)(uintptr_t)jconf,
1382414388d7Ssl 	    (pool_component_t *)(uintptr_t)jcomponent));
13837c478bd9Sstevel@tonic-gate }
13847c478bd9Sstevel@tonic-gate 
13857c478bd9Sstevel@tonic-gate /*
13867c478bd9Sstevel@tonic-gate  * pool_value_get_type(3pool) wrapper
13877c478bd9Sstevel@tonic-gate  */
13887c478bd9Sstevel@tonic-gate /*ARGSUSED*/
13897c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1type(JNIEnv * jenv,jclass jcls,jlong jvalue)13907c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1type(
1391*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jvalue)
1392*03dfa5baSToomas Soome {
1393414388d7Ssl 	return ((jint)pool_value_get_type((pool_value_t *)(uintptr_t)jvalue));
13947c478bd9Sstevel@tonic-gate }
13957c478bd9Sstevel@tonic-gate 
13967c478bd9Sstevel@tonic-gate /*
13977c478bd9Sstevel@tonic-gate  * pool_value_set_uint64(3pool) wrapper
13987c478bd9Sstevel@tonic-gate  */
13997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14007c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1uint64(JNIEnv * jenv,jclass jcls,jlong jvalue,jlong jui64)14017c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1uint64(
1402*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jvalue, jlong jui64)
1403*03dfa5baSToomas Soome {
1404414388d7Ssl 	pool_value_set_uint64(
1405414388d7Ssl 	    (pool_value_t *)(uintptr_t)jvalue, (uint64_t)jui64);
14067c478bd9Sstevel@tonic-gate }
14077c478bd9Sstevel@tonic-gate 
14087c478bd9Sstevel@tonic-gate /*
14097c478bd9Sstevel@tonic-gate  * pool_value_set_int64(3pool) wrapper
14107c478bd9Sstevel@tonic-gate  */
14117c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14127c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1int64(JNIEnv * jenv,jclass jcls,jlong jvalue,jlong ji64)14137c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1int64(
1414*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jvalue, jlong ji64)
1415*03dfa5baSToomas Soome {
1416414388d7Ssl 	pool_value_set_int64((pool_value_t *)(uintptr_t)jvalue, (int64_t)ji64);
14177c478bd9Sstevel@tonic-gate }
14187c478bd9Sstevel@tonic-gate 
14197c478bd9Sstevel@tonic-gate /*
14207c478bd9Sstevel@tonic-gate  * pool_value_set_double(3pool) wrapper
14217c478bd9Sstevel@tonic-gate  */
14227c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14237c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1double(JNIEnv * jenv,jclass jcls,jlong jvalue,jdouble jd)14247c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1double(
1425*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jvalue, jdouble jd)
1426*03dfa5baSToomas Soome {
1427414388d7Ssl 	pool_value_set_double((pool_value_t *)(uintptr_t)jvalue, (double)jd);
14287c478bd9Sstevel@tonic-gate }
14297c478bd9Sstevel@tonic-gate 
14307c478bd9Sstevel@tonic-gate /*
14317c478bd9Sstevel@tonic-gate  * pool_value_set_bool(3pool) wrapper
14327c478bd9Sstevel@tonic-gate  */
14337c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14347c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1bool(JNIEnv * jenv,jclass jcls,jlong jvalue,jshort jb)14357c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1bool(
1436*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jvalue, jshort jb)
1437*03dfa5baSToomas Soome {
1438414388d7Ssl 	pool_value_set_bool((pool_value_t *)(uintptr_t)jvalue, (uchar_t)jb);
14397c478bd9Sstevel@tonic-gate }
14407c478bd9Sstevel@tonic-gate 
14417c478bd9Sstevel@tonic-gate /*
14427c478bd9Sstevel@tonic-gate  * pool_value_set_string(3pool) wrapper
14437c478bd9Sstevel@tonic-gate  */
14447c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14457c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1string(JNIEnv * jenv,jclass jcls,jlong jvalue,jstring jstr)14467c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1string(
1447*03dfa5baSToomas Soome     JNIEnv * jenv, jclass jcls, jlong jvalue, jstring jstr)
1448*03dfa5baSToomas Soome {
14497c478bd9Sstevel@tonic-gate 	const char *str;
14507c478bd9Sstevel@tonic-gate 	int result;
14517c478bd9Sstevel@tonic-gate 
14527c478bd9Sstevel@tonic-gate 	str = (jstr) ? (*jenv)->GetStringUTFChars(jenv, jstr, 0) : NULL;
1453414388d7Ssl 	result = pool_value_set_string((pool_value_t *)(uintptr_t)jvalue, str);
14547c478bd9Sstevel@tonic-gate 
14557c478bd9Sstevel@tonic-gate 	if (str)
14567c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jstr, str);
14577c478bd9Sstevel@tonic-gate 	return ((jint)result);
14587c478bd9Sstevel@tonic-gate }
14597c478bd9Sstevel@tonic-gate 
14607c478bd9Sstevel@tonic-gate /*
14617c478bd9Sstevel@tonic-gate  * pool_value_get_name(3pool) wrapper
14627c478bd9Sstevel@tonic-gate  */
14637c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14647c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1name(JNIEnv * jenv,jclass jcls,jlong jvalue)14657c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1name(
1466*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jvalue)
1467*03dfa5baSToomas Soome {
14687c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
14697c478bd9Sstevel@tonic-gate 	const char *result;
14707c478bd9Sstevel@tonic-gate 
1471414388d7Ssl 	result = pool_value_get_name((pool_value_t *)(uintptr_t)jvalue);
14727c478bd9Sstevel@tonic-gate 
14737c478bd9Sstevel@tonic-gate 	if (result)
14747c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
14757c478bd9Sstevel@tonic-gate 	return (jresult);
14767c478bd9Sstevel@tonic-gate }
14777c478bd9Sstevel@tonic-gate 
14787c478bd9Sstevel@tonic-gate /*
14797c478bd9Sstevel@tonic-gate  * pool_value_set_name(3pool) wrapper
14807c478bd9Sstevel@tonic-gate  */
14817c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14827c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1name(JNIEnv * jenv,jclass jcls,jlong jvalue,jstring jname)14837c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1name(
1484*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jlong jvalue, jstring jname)
1485*03dfa5baSToomas Soome {
14867c478bd9Sstevel@tonic-gate 	const char *name;
14877c478bd9Sstevel@tonic-gate 	int result;
14887c478bd9Sstevel@tonic-gate 
14897c478bd9Sstevel@tonic-gate 	name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : NULL;
1490414388d7Ssl 	result = pool_value_set_name((pool_value_t *)(uintptr_t)jvalue, name);
14917c478bd9Sstevel@tonic-gate 
14927c478bd9Sstevel@tonic-gate 	if (name)
14937c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jname, name);
14947c478bd9Sstevel@tonic-gate 	return ((jint)result);
14957c478bd9Sstevel@tonic-gate }
14967c478bd9Sstevel@tonic-gate 
14977c478bd9Sstevel@tonic-gate /*
14987c478bd9Sstevel@tonic-gate  * pool_value_alloc(3pool) wrapper
14997c478bd9Sstevel@tonic-gate  */
15007c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15017c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1alloc(JNIEnv * jenv,jclass jcls)15027c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1alloc(JNIEnv *jenv,
1503*03dfa5baSToomas Soome     jclass jcls)
1504*03dfa5baSToomas Soome {
15057c478bd9Sstevel@tonic-gate 	return ((jlong)(uintptr_t)pool_value_alloc());
15067c478bd9Sstevel@tonic-gate }
15077c478bd9Sstevel@tonic-gate 
15087c478bd9Sstevel@tonic-gate /*
15097c478bd9Sstevel@tonic-gate  * pool_value_free(3pool) wrapper
15107c478bd9Sstevel@tonic-gate  */
15117c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15127c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1free(JNIEnv * jenv,jclass jcls,jlong jvalue)15137c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1free(JNIEnv *jenv,
1514*03dfa5baSToomas Soome     jclass jcls, jlong jvalue)
1515*03dfa5baSToomas Soome {
1516414388d7Ssl 	pool_value_free((pool_value_t *)(uintptr_t)jvalue);
15177c478bd9Sstevel@tonic-gate }
15187c478bd9Sstevel@tonic-gate 
15197c478bd9Sstevel@tonic-gate /*
15207c478bd9Sstevel@tonic-gate  * pool_static_location(3pool) wrapper
15217c478bd9Sstevel@tonic-gate  */
15227c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15237c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1static_1location(JNIEnv * jenv,jclass jcls)15247c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1static_1location(
1525*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls)
1526*03dfa5baSToomas Soome {
15277c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
15287c478bd9Sstevel@tonic-gate 	const char *result;
15297c478bd9Sstevel@tonic-gate 
15307c478bd9Sstevel@tonic-gate 	result = pool_static_location();
15317c478bd9Sstevel@tonic-gate 
15327c478bd9Sstevel@tonic-gate 	if (result)
15337c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
15347c478bd9Sstevel@tonic-gate 	return (jresult);
15357c478bd9Sstevel@tonic-gate }
15367c478bd9Sstevel@tonic-gate 
15377c478bd9Sstevel@tonic-gate /*
15387c478bd9Sstevel@tonic-gate  * pool_dynamic_location(3pool) wrapper
15397c478bd9Sstevel@tonic-gate  */
15407c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15417c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1dynamic_1location(JNIEnv * jenv,jclass jcls)15427c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1dynamic_1location(JNIEnv *
1543*03dfa5baSToomas Soome     jenv, jclass jcls)
1544*03dfa5baSToomas Soome {
15457c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
15467c478bd9Sstevel@tonic-gate 	const char *result;
15477c478bd9Sstevel@tonic-gate 
15487c478bd9Sstevel@tonic-gate 	result = pool_dynamic_location();
15497c478bd9Sstevel@tonic-gate 
15507c478bd9Sstevel@tonic-gate 	if (result)
15517c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
15527c478bd9Sstevel@tonic-gate 	return (jresult);
15537c478bd9Sstevel@tonic-gate }
15547c478bd9Sstevel@tonic-gate 
15557c478bd9Sstevel@tonic-gate /*
15567c478bd9Sstevel@tonic-gate  * pool_set_binding(3pool) wrapper
15577c478bd9Sstevel@tonic-gate  */
15587c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15597c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1binding(JNIEnv * jenv,jclass jcls,jstring jpool,jint jidtype,jint jpid)15607c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1binding(JNIEnv *jenv,
1561*03dfa5baSToomas Soome     jclass jcls, jstring jpool, jint jidtype, jint jpid)
1562*03dfa5baSToomas Soome {
15637c478bd9Sstevel@tonic-gate 	const char *pool;
15647c478bd9Sstevel@tonic-gate 	int result;
15657c478bd9Sstevel@tonic-gate 
15667c478bd9Sstevel@tonic-gate 	pool = (jpool) ? (*jenv)->GetStringUTFChars(jenv, jpool, 0) : NULL;
15677c478bd9Sstevel@tonic-gate 	result = (int)pool_set_binding(pool, (idtype_t)jidtype, (id_t)jpid);
15687c478bd9Sstevel@tonic-gate 
15697c478bd9Sstevel@tonic-gate 	if (pool)
15707c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jpool, pool);
15717c478bd9Sstevel@tonic-gate 	return ((jint)result);
15727c478bd9Sstevel@tonic-gate }
15737c478bd9Sstevel@tonic-gate 
15747c478bd9Sstevel@tonic-gate /*
15757c478bd9Sstevel@tonic-gate  * pool_get_binding(3pool) wrapper
15767c478bd9Sstevel@tonic-gate  */
15777c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15787c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1binding(JNIEnv * jenv,jclass jcls,jint jpid)15797c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1binding(JNIEnv *jenv,
1580*03dfa5baSToomas Soome     jclass jcls, jint jpid)
1581*03dfa5baSToomas Soome {
15827c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
15837c478bd9Sstevel@tonic-gate 	const char *result;
15847c478bd9Sstevel@tonic-gate 
15857c478bd9Sstevel@tonic-gate 	result = pool_get_binding((pid_t)jpid);
15867c478bd9Sstevel@tonic-gate 
15877c478bd9Sstevel@tonic-gate 	if (result)
15887c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
15897c478bd9Sstevel@tonic-gate 	free((void *)result);
15907c478bd9Sstevel@tonic-gate 	return (jresult);
15917c478bd9Sstevel@tonic-gate }
15927c478bd9Sstevel@tonic-gate 
15937c478bd9Sstevel@tonic-gate /*
15947c478bd9Sstevel@tonic-gate  * pool_get_resource_binding(3pool) wrapper
15957c478bd9Sstevel@tonic-gate  */
15967c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15977c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource_1binding(JNIEnv * jenv,jclass jcls,jstring jtype,jint jpid)15987c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource_1binding(
1599*03dfa5baSToomas Soome     JNIEnv *jenv, jclass jcls, jstring jtype, jint jpid)
1600*03dfa5baSToomas Soome {
16017c478bd9Sstevel@tonic-gate 	jstring jresult = NULL;
16027c478bd9Sstevel@tonic-gate 	const char *type;
16037c478bd9Sstevel@tonic-gate 	const char *result;
16047c478bd9Sstevel@tonic-gate 
16057c478bd9Sstevel@tonic-gate 	type = (jtype) ? (*jenv)->GetStringUTFChars(jenv, jtype, 0) : NULL;
16067c478bd9Sstevel@tonic-gate 	result = pool_get_resource_binding(type, (pid_t)jpid);
16077c478bd9Sstevel@tonic-gate 
16087c478bd9Sstevel@tonic-gate 	if (result)
16097c478bd9Sstevel@tonic-gate 		jresult = (*jenv)->NewStringUTF(jenv, result);
16107c478bd9Sstevel@tonic-gate 	free((void *)result);
16117c478bd9Sstevel@tonic-gate 	if (type)
16127c478bd9Sstevel@tonic-gate 		(*jenv)->ReleaseStringUTFChars(jenv, jtype, type);
16137c478bd9Sstevel@tonic-gate 	return (jresult);
16147c478bd9Sstevel@tonic-gate }
16157c478bd9Sstevel@tonic-gate 
16167c478bd9Sstevel@tonic-gate /*
16177c478bd9Sstevel@tonic-gate  * pool_walk_pools(3pool) wrapper
16187c478bd9Sstevel@tonic-gate  */
16197c478bd9Sstevel@tonic-gate /*ARGSUSED*/
16207c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1pools(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jarg,jlong jcallback)16217c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1pools(JNIEnv *jenv,
1622*03dfa5baSToomas Soome     jclass jcls, jlong jconf, jlong jarg, jlong jcallback)
1623*03dfa5baSToomas Soome {
16247c478bd9Sstevel@tonic-gate 	int result;
16257c478bd9Sstevel@tonic-gate 
1626414388d7Ssl 	result = pool_walk_pools((pool_conf_t *)(uintptr_t)jconf,
1627414388d7Ssl 	    (void *)(uintptr_t)jarg,
1628414388d7Ssl 	    (int (*)(pool_conf_t *, pool_t *, void *))(uintptr_t)jcallback);
16297c478bd9Sstevel@tonic-gate 	return ((jint)result);
16307c478bd9Sstevel@tonic-gate }
16317c478bd9Sstevel@tonic-gate 
16327c478bd9Sstevel@tonic-gate /*
16337c478bd9Sstevel@tonic-gate  * pool_walk_resources(3pool) wrapper
16347c478bd9Sstevel@tonic-gate  */
16357c478bd9Sstevel@tonic-gate /*ARGSUSED*/
16367c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1resources(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jpool,jlong jarg,jlong jcallback)16377c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1resources(
16387c478bd9Sstevel@tonic-gate     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jpool, jlong jarg,
1639*03dfa5baSToomas Soome     jlong jcallback)
1640*03dfa5baSToomas Soome {
16417c478bd9Sstevel@tonic-gate 	int result;
16427c478bd9Sstevel@tonic-gate 
1643414388d7Ssl 	result = pool_walk_resources((pool_conf_t *)(uintptr_t)jconf,
1644414388d7Ssl 	    (pool_t *)(uintptr_t)jpool, (void *)(uintptr_t)jarg,
1645414388d7Ssl 	    (int (*)(pool_conf_t *, pool_resource_t *, void *))
1646414388d7Ssl 	    (uintptr_t)jcallback);
16477c478bd9Sstevel@tonic-gate 	return ((jint)result);
16487c478bd9Sstevel@tonic-gate }
16497c478bd9Sstevel@tonic-gate 
16507c478bd9Sstevel@tonic-gate /*
16517c478bd9Sstevel@tonic-gate  * pool_walk_components(3pool) wrapper
16527c478bd9Sstevel@tonic-gate  */
16537c478bd9Sstevel@tonic-gate /*ARGSUSED*/
16547c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1components(JNIEnv * jenv,jclass jcls,jlong jconf,jlong jresource,jlong jarg,jlong jcallback)16557c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1components(
16567c478bd9Sstevel@tonic-gate     JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource, jlong jarg,
1657*03dfa5baSToomas Soome     jlong jcallback)
1658*03dfa5baSToomas Soome {
16597c478bd9Sstevel@tonic-gate 	int result;
16607c478bd9Sstevel@tonic-gate 
1661414388d7Ssl 	result = pool_walk_components((pool_conf_t *)(uintptr_t)jconf,
1662414388d7Ssl 	    (pool_resource_t *)(uintptr_t)jresource, (void *)(uintptr_t)jarg,
1663414388d7Ssl 	    (int (*)(pool_conf_t *, pool_component_t *, void *))
1664414388d7Ssl 	    (uintptr_t)jcallback);
16657c478bd9Sstevel@tonic-gate 	return ((jint)result);
16667c478bd9Sstevel@tonic-gate }
16677c478bd9Sstevel@tonic-gate 
16687c478bd9Sstevel@tonic-gate /*ARGSUSED*/
16697c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL
Java_com_sun_solaris_service_pools_Element_walkProps(JNIEnv * env,jobject obj,jlong conf,jlong elem,jobject handler,jobject userobj)16707c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Element_walkProps(JNIEnv *env,
1671*03dfa5baSToomas Soome     jobject obj, jlong conf, jlong elem, jobject handler, jobject userobj)
16727c478bd9Sstevel@tonic-gate {
16737c478bd9Sstevel@tonic-gate 	struct pool_callback pc;
16747c478bd9Sstevel@tonic-gate 
16757c478bd9Sstevel@tonic-gate 	pc.pc_user = userobj;
16767c478bd9Sstevel@tonic-gate 	pc.pc_handler = handler;
16777c478bd9Sstevel@tonic-gate 	pc.pc_elem = obj;
16787c478bd9Sstevel@tonic-gate 	pc.pc_env = env;
16797c478bd9Sstevel@tonic-gate 	return (pool_walk_properties((pool_conf_t *)*(void**)&conf,
16807c478bd9Sstevel@tonic-gate 	    (pool_elem_t *)*(void**)&elem, (void *)&pc, pool_property_walker));
16817c478bd9Sstevel@tonic-gate }
16827c478bd9Sstevel@tonic-gate 
16837c478bd9Sstevel@tonic-gate /*ARGSUSED*/
16847c478bd9Sstevel@tonic-gate static int
pool_property_walker(pool_conf_t * conf,pool_elem_t * pe,const char * name,pool_value_t * pv,void * user)16857c478bd9Sstevel@tonic-gate pool_property_walker(pool_conf_t *conf, pool_elem_t *pe, const char *name,
1686*03dfa5baSToomas Soome     pool_value_t *pv, void *user)
16877c478bd9Sstevel@tonic-gate {
16887c478bd9Sstevel@tonic-gate 	jclass clazz, vclazz;
16897c478bd9Sstevel@tonic-gate 	jmethodID mgetwalk, mvcon;
16907c478bd9Sstevel@tonic-gate 	struct pool_callback *pc = (struct pool_callback *)user;
16917c478bd9Sstevel@tonic-gate 	jobject valueObj;
16927c478bd9Sstevel@tonic-gate 	pool_value_t *pv_new;
16937c478bd9Sstevel@tonic-gate 	uint64_t uval;
16947c478bd9Sstevel@tonic-gate 	int64_t ival;
16957c478bd9Sstevel@tonic-gate 	double dval;
16967c478bd9Sstevel@tonic-gate 	uchar_t bval;
16977c478bd9Sstevel@tonic-gate 	const char *sval;
16987c478bd9Sstevel@tonic-gate 
16997c478bd9Sstevel@tonic-gate 	/*
17007c478bd9Sstevel@tonic-gate 	 * Since we intend to embed our value into a Java Value object
17017c478bd9Sstevel@tonic-gate 	 * and then reclaim the value when the object is garbage
17027c478bd9Sstevel@tonic-gate 	 * collected we must create a new pool value and then pass this
17037c478bd9Sstevel@tonic-gate 	 * to the constructor.  We must not use the pool value which is
17047c478bd9Sstevel@tonic-gate 	 * passed to us.
17057c478bd9Sstevel@tonic-gate 	 */
17067c478bd9Sstevel@tonic-gate 
17077c478bd9Sstevel@tonic-gate 	if ((pv_new = pool_value_alloc()) == NULL)
17087c478bd9Sstevel@tonic-gate 		return (PO_FAIL);
17097c478bd9Sstevel@tonic-gate 	switch (pool_value_get_type(pv)) {
17107c478bd9Sstevel@tonic-gate 	case POC_UINT:
17117c478bd9Sstevel@tonic-gate 		(void) pool_value_get_uint64(pv, &uval);
17127c478bd9Sstevel@tonic-gate 		(void) pool_value_set_uint64(pv_new, uval);
17137c478bd9Sstevel@tonic-gate 		break;
17147c478bd9Sstevel@tonic-gate 	case POC_INT:
17157c478bd9Sstevel@tonic-gate 		(void) pool_value_get_int64(pv, &ival);
17167c478bd9Sstevel@tonic-gate 		(void) pool_value_set_int64(pv_new, ival);
17177c478bd9Sstevel@tonic-gate 		break;
17187c478bd9Sstevel@tonic-gate 	case POC_DOUBLE:
17197c478bd9Sstevel@tonic-gate 		(void) pool_value_get_double(pv, &dval);
17207c478bd9Sstevel@tonic-gate 		(void) pool_value_set_double(pv_new, dval);
17217c478bd9Sstevel@tonic-gate 		break;
17227c478bd9Sstevel@tonic-gate 	case POC_BOOL:
17237c478bd9Sstevel@tonic-gate 		(void) pool_value_get_bool(pv, &bval);
17247c478bd9Sstevel@tonic-gate 		(void) pool_value_set_bool(pv_new, bval);
17257c478bd9Sstevel@tonic-gate 		break;
17267c478bd9Sstevel@tonic-gate 	case POC_STRING:
17277c478bd9Sstevel@tonic-gate 		(void) pool_value_get_string(pv, &sval);
17287c478bd9Sstevel@tonic-gate 		(void) pool_value_set_string(pv_new, sval);
17297c478bd9Sstevel@tonic-gate 		break;
17307c478bd9Sstevel@tonic-gate 	default:
17317c478bd9Sstevel@tonic-gate 		pool_value_free(pv_new);
17327c478bd9Sstevel@tonic-gate 		return (PO_FAIL);
17337c478bd9Sstevel@tonic-gate 	}
17347c478bd9Sstevel@tonic-gate 	if (pool_value_set_name(pv_new, name) != PO_SUCCESS ||
17357c478bd9Sstevel@tonic-gate 	    (vclazz = (*pc->pc_env)->FindClass(pc->pc_env,
17367c478bd9Sstevel@tonic-gate 	    "com/sun/solaris/service/pools/Value")) == NULL ||
17377c478bd9Sstevel@tonic-gate 	    (mvcon = (*pc->pc_env)->GetMethodID(pc->pc_env, vclazz,
17387c478bd9Sstevel@tonic-gate 	    "<init>", "(J)V")) == NULL ||
17397c478bd9Sstevel@tonic-gate 	    (valueObj = (*pc->pc_env)->NewObject(pc->pc_env, vclazz, mvcon,
17407c478bd9Sstevel@tonic-gate 	    pv_new)) == NULL ||
17417c478bd9Sstevel@tonic-gate 	    (clazz = (*pc->pc_env)->GetObjectClass(pc->pc_env, pc->pc_handler))
17427c478bd9Sstevel@tonic-gate 	    == NULL ||
17437c478bd9Sstevel@tonic-gate 	    (mgetwalk = (*pc->pc_env)->GetMethodID(pc->pc_env,
17447c478bd9Sstevel@tonic-gate 	    clazz, "walk",
17457c478bd9Sstevel@tonic-gate 	    "(Lcom/sun/solaris/service/pools/Element;Lcom/sun/solaris/"
17467c478bd9Sstevel@tonic-gate 	    "service/pools/Value;Ljava/lang/Object;)I")) == NULL)
17477c478bd9Sstevel@tonic-gate 		return (PO_FAIL);
17487c478bd9Sstevel@tonic-gate 	return ((*pc->pc_env)->CallIntMethod(pc->pc_env,
1749*03dfa5baSToomas Soome 	    pc->pc_handler, mgetwalk, pc->pc_elem, valueObj, pc->pc_user));
17507c478bd9Sstevel@tonic-gate }
17517c478bd9Sstevel@tonic-gate 
17527c478bd9Sstevel@tonic-gate /*ARGSUSED*/
17537c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL
Java_com_sun_solaris_service_pools_Value_getLongValue(JNIEnv * jenv,jclass class,jlong pointer)17547c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getLongValue(JNIEnv *jenv,
1755*03dfa5baSToomas Soome     jclass class, jlong pointer)
17567c478bd9Sstevel@tonic-gate {
17577c478bd9Sstevel@tonic-gate 	int64_t arg2;
17587c478bd9Sstevel@tonic-gate 	int result;
17597c478bd9Sstevel@tonic-gate 
1760414388d7Ssl 	result =
1761414388d7Ssl 	    pool_value_get_int64((pool_value_t *)(uintptr_t)pointer, &arg2);
17627c478bd9Sstevel@tonic-gate 
17637c478bd9Sstevel@tonic-gate 	if (result != PO_SUCCESS) { /* it could be a uint64 */
1764414388d7Ssl 		result =
1765414388d7Ssl 		    pool_value_get_uint64((pool_value_t *)(uintptr_t)pointer,
17667c478bd9Sstevel@tonic-gate 		    (uint64_t *)&arg2);
17677c478bd9Sstevel@tonic-gate 		if (result != PO_SUCCESS) {
17687c478bd9Sstevel@tonic-gate 			throw_pe(jenv);
17697c478bd9Sstevel@tonic-gate 		}
17707c478bd9Sstevel@tonic-gate 		/*
17717c478bd9Sstevel@tonic-gate 		 * Unfortunately, Java has no unsigned types, so we lose some
17727c478bd9Sstevel@tonic-gate 		 * precision by forcing the top bit clear
17737c478bd9Sstevel@tonic-gate 		 */
1774414388d7Ssl 		arg2 &= 0x7fffffffffffffffULL;
17757c478bd9Sstevel@tonic-gate 	}
17767c478bd9Sstevel@tonic-gate 	return ((jlong)arg2);
17777c478bd9Sstevel@tonic-gate }
17787c478bd9Sstevel@tonic-gate 
17797c478bd9Sstevel@tonic-gate /*ARGSUSED*/
17807c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL
Java_com_sun_solaris_service_pools_Value_getStringValue(JNIEnv * jenv,jclass class,jlong pointer)17817c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getStringValue(JNIEnv *jenv,
1782*03dfa5baSToomas Soome     jclass class, jlong pointer)
17837c478bd9Sstevel@tonic-gate {
17847c478bd9Sstevel@tonic-gate 	const char *arg2;
17857c478bd9Sstevel@tonic-gate 	int result;
17867c478bd9Sstevel@tonic-gate 
1787414388d7Ssl 	result =
1788414388d7Ssl 	    pool_value_get_string((pool_value_t *)(uintptr_t)pointer, &arg2);
17897c478bd9Sstevel@tonic-gate 	if (result != PO_SUCCESS)
17907c478bd9Sstevel@tonic-gate 		throw_pe(jenv);
17917c478bd9Sstevel@tonic-gate 	return ((*jenv)->NewStringUTF(jenv, arg2));
17927c478bd9Sstevel@tonic-gate }
17937c478bd9Sstevel@tonic-gate 
17947c478bd9Sstevel@tonic-gate /*ARGSUSED*/
17957c478bd9Sstevel@tonic-gate JNIEXPORT jboolean JNICALL
Java_com_sun_solaris_service_pools_Value_getBoolValue(JNIEnv * jenv,jclass class,jlong pointer)17967c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getBoolValue(JNIEnv *jenv,
1797*03dfa5baSToomas Soome     jclass class, jlong pointer)
17987c478bd9Sstevel@tonic-gate {
17997c478bd9Sstevel@tonic-gate 	uchar_t arg2;
18007c478bd9Sstevel@tonic-gate 	int result;
18017c478bd9Sstevel@tonic-gate 
1802414388d7Ssl 	result = pool_value_get_bool((pool_value_t *)(uintptr_t)pointer, &arg2);
18037c478bd9Sstevel@tonic-gate 
18047c478bd9Sstevel@tonic-gate 	if (result != PO_SUCCESS) {
18057c478bd9Sstevel@tonic-gate 		throw_pe(jenv);
18067c478bd9Sstevel@tonic-gate 	}
18077c478bd9Sstevel@tonic-gate 	if (arg2 == PO_TRUE)
18087c478bd9Sstevel@tonic-gate 		return (JNI_TRUE);
18097c478bd9Sstevel@tonic-gate 	else
18107c478bd9Sstevel@tonic-gate 		return (JNI_FALSE);
18117c478bd9Sstevel@tonic-gate }
18127c478bd9Sstevel@tonic-gate 
18137c478bd9Sstevel@tonic-gate /*ARGSUSED*/
18147c478bd9Sstevel@tonic-gate JNIEXPORT jdouble JNICALL
Java_com_sun_solaris_service_pools_Value_getDoubleValue(JNIEnv * jenv,jclass class,jlong pointer)18157c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getDoubleValue(JNIEnv *jenv,
1816*03dfa5baSToomas Soome     jclass class, jlong pointer)
18177c478bd9Sstevel@tonic-gate {
18187c478bd9Sstevel@tonic-gate 	double arg2;
18197c478bd9Sstevel@tonic-gate 	int result;
18207c478bd9Sstevel@tonic-gate 
1821414388d7Ssl 	result =
1822414388d7Ssl 	    pool_value_get_double((pool_value_t *)(uintptr_t)pointer, &arg2);
18237c478bd9Sstevel@tonic-gate 
18247c478bd9Sstevel@tonic-gate 	if (result != PO_SUCCESS) {
18257c478bd9Sstevel@tonic-gate 		throw_pe(jenv);
18267c478bd9Sstevel@tonic-gate 	}
18277c478bd9Sstevel@tonic-gate 	return ((jdouble)arg2);
18287c478bd9Sstevel@tonic-gate }
18297c478bd9Sstevel@tonic-gate 
18307c478bd9Sstevel@tonic-gate /*ARGSUSED*/
18317c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL
Java_com_sun_solaris_service_pools_Value_getUnsignedInt64Value(JNIEnv * jenv,jclass class,jlong pointer)18327c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getUnsignedInt64Value(JNIEnv *jenv,
18337c478bd9Sstevel@tonic-gate     jclass class, jlong pointer)
18347c478bd9Sstevel@tonic-gate {
18357c478bd9Sstevel@tonic-gate 	uint64_t arg2;
18367c478bd9Sstevel@tonic-gate 	int result;
18377c478bd9Sstevel@tonic-gate 
1838414388d7Ssl 	result =
1839414388d7Ssl 	    pool_value_get_uint64((pool_value_t *)(uintptr_t)pointer, &arg2);
18407c478bd9Sstevel@tonic-gate 
18417c478bd9Sstevel@tonic-gate 	if (result != PO_SUCCESS) {
18427c478bd9Sstevel@tonic-gate 		throw_pe(jenv);
18437c478bd9Sstevel@tonic-gate 	}
18447c478bd9Sstevel@tonic-gate 	return (makeUnsignedInt64(jenv, arg2));
18457c478bd9Sstevel@tonic-gate }
18467c478bd9Sstevel@tonic-gate 
18477c478bd9Sstevel@tonic-gate /*ARGSUSED*/
18487c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL
Java_com_sun_solaris_service_pools_HRTime_timestamp(JNIEnv * env,jobject obj)18497c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_HRTime_timestamp(JNIEnv *env, jobject obj)
18507c478bd9Sstevel@tonic-gate {
18517c478bd9Sstevel@tonic-gate 	return (makeUnsignedInt64(env, gethrtime()));
18527c478bd9Sstevel@tonic-gate }
18537c478bd9Sstevel@tonic-gate 
18547c478bd9Sstevel@tonic-gate /*
18557c478bd9Sstevel@tonic-gate  * Cache class, method, and field IDs.
18567c478bd9Sstevel@tonic-gate  */
18577c478bd9Sstevel@tonic-gate /*ARGSUSED*/
18587c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL
Java_com_sun_solaris_service_pools_PoolInternal_init(JNIEnv * env,jclass clazz)18597c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_init(JNIEnv *env, jclass clazz)
18607c478bd9Sstevel@tonic-gate {
18617c478bd9Sstevel@tonic-gate 	jclass ui64class_lref;
18627c478bd9Sstevel@tonic-gate 
18637c478bd9Sstevel@tonic-gate 	if (!(ui64class_lref = (*env)->FindClass(env,
18647c478bd9Sstevel@tonic-gate 	    "com/sun/solaris/service/pools/UnsignedInt64")))
18657c478bd9Sstevel@tonic-gate 		return; /* exception thrown */
18667c478bd9Sstevel@tonic-gate 	if (!(ui64class = (*env)->NewGlobalRef(env, ui64class_lref)))
18677c478bd9Sstevel@tonic-gate 		return; /* exception thrown */
18687c478bd9Sstevel@tonic-gate 	ui64cons_mid = (*env)->GetMethodID(env, ui64class, "<init>", "([B)V");
18697c478bd9Sstevel@tonic-gate }
1870