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 /* 23*414388d7Ssl108498 * 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 #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <errno.h> 307c478bd9Sstevel@tonic-gate #include <jni.h> 317c478bd9Sstevel@tonic-gate #include <pool.h> 327c478bd9Sstevel@tonic-gate #include <stdlib.h> 337c478bd9Sstevel@tonic-gate #include <string.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/time.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include "jpool.h" 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate struct pool_callback { 407c478bd9Sstevel@tonic-gate jobject pc_user; 417c478bd9Sstevel@tonic-gate jobject pc_handler; 427c478bd9Sstevel@tonic-gate jobject pc_elem; 437c478bd9Sstevel@tonic-gate JNIEnv *pc_env; 447c478bd9Sstevel@tonic-gate }; 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate static void throwException(JNIEnv *, const char *, const char *); 477c478bd9Sstevel@tonic-gate static void throw_pe(JNIEnv *); 487c478bd9Sstevel@tonic-gate static jobject makeUnsignedInt64(JNIEnv *, uint64_t); 497c478bd9Sstevel@tonic-gate static int pool_property_walker(pool_conf_t *, pool_elem_t *p, const char *, 507c478bd9Sstevel@tonic-gate pool_value_t *, void *); 517c478bd9Sstevel@tonic-gate static jobject copyArray(JNIEnv *, void **); 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Cached class, method, and field IDs. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate static jclass ui64class; 577c478bd9Sstevel@tonic-gate static jmethodID ui64cons_mid; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * Throw an exception of the specified class with the specified message. 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate void 637c478bd9Sstevel@tonic-gate throwException(JNIEnv *env, const char *class, const char *msg) 647c478bd9Sstevel@tonic-gate { 657c478bd9Sstevel@tonic-gate jclass clazz; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate clazz = (*env)->FindClass(env, class); 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate (*env)->ThrowNew(env, clazz, msg); 707c478bd9Sstevel@tonic-gate } 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Throw a PoolsException. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate void 767c478bd9Sstevel@tonic-gate throw_pe(JNIEnv *jenv) 777c478bd9Sstevel@tonic-gate { 787c478bd9Sstevel@tonic-gate jclass clazz; 797c478bd9Sstevel@tonic-gate jmethodID mid; 807c478bd9Sstevel@tonic-gate jthrowable throwObj; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate clazz = (*jenv)->FindClass(jenv, 837c478bd9Sstevel@tonic-gate "com/sun/solaris/service/pools/PoolsException"); 847c478bd9Sstevel@tonic-gate mid = (*jenv)->GetMethodID(jenv, clazz, "<init>", "()V"); 857c478bd9Sstevel@tonic-gate throwObj = (*jenv)->NewObject(jenv, clazz, mid); 867c478bd9Sstevel@tonic-gate (*jenv)->Throw(jenv, throwObj); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Return an instance of an UnsignedInt64 class which encapsulates the 917c478bd9Sstevel@tonic-gate * supplied value. 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate jobject 947c478bd9Sstevel@tonic-gate makeUnsignedInt64(JNIEnv *env, uint64_t value) 957c478bd9Sstevel@tonic-gate { 967c478bd9Sstevel@tonic-gate jobject valueObj; 977c478bd9Sstevel@tonic-gate jobject byteArray; 987c478bd9Sstevel@tonic-gate jbyte *bytes; 997c478bd9Sstevel@tonic-gate int i; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate if (!(byteArray = (*env)->NewByteArray(env, 9))) 1027c478bd9Sstevel@tonic-gate return (NULL); /* OutOfMemoryError thrown */ 1037c478bd9Sstevel@tonic-gate if (!(bytes = (*env)->GetByteArrayElements(env, byteArray, NULL))) 1047c478bd9Sstevel@tonic-gate return (NULL); /* OutOfMemoryError thrown */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Interpret the uint64_t as a 9-byte big-endian signed quantity 1087c478bd9Sstevel@tonic-gate * suitable for constructing an UnsignedInt64 or BigInteger. 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate for (i = 8; i >= 1; i--) { 1117c478bd9Sstevel@tonic-gate bytes[i] = value & 0xff; 1127c478bd9Sstevel@tonic-gate value >>= 8; 1137c478bd9Sstevel@tonic-gate } 1147c478bd9Sstevel@tonic-gate bytes[0] = 0; 1157c478bd9Sstevel@tonic-gate (*env)->ReleaseByteArrayElements(env, byteArray, bytes, 0); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate if (!(valueObj = (*env)->NewObject(env, ui64class, ui64cons_mid, 1187c478bd9Sstevel@tonic-gate byteArray))) 1197c478bd9Sstevel@tonic-gate return (NULL); /* exception thrown */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate return (valueObj); 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Create an array list and then copy the native array into it 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate jobject 1287c478bd9Sstevel@tonic-gate copyArray(JNIEnv *jenv, void **nativeArray) 1297c478bd9Sstevel@tonic-gate { 1307c478bd9Sstevel@tonic-gate int i; 1317c478bd9Sstevel@tonic-gate jobject jresult = NULL; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate if (nativeArray != NULL) { 1347c478bd9Sstevel@tonic-gate jclass ALclazz; 1357c478bd9Sstevel@tonic-gate jmethodID ALinit, ALadd; 1367c478bd9Sstevel@tonic-gate jclass Lclazz; 1377c478bd9Sstevel@tonic-gate jmethodID Linit; 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate ALclazz = (*jenv)->FindClass(jenv, 1407c478bd9Sstevel@tonic-gate "java/util/ArrayList"); 1417c478bd9Sstevel@tonic-gate ALinit = (*jenv)->GetMethodID(jenv, 1427c478bd9Sstevel@tonic-gate ALclazz, "<init>", "()V"); 1437c478bd9Sstevel@tonic-gate ALadd = (*jenv)->GetMethodID(jenv, 1447c478bd9Sstevel@tonic-gate ALclazz, "add", "(Ljava/lang/Object;)Z"); 1457c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewObject(jenv, ALclazz, ALinit); 1467c478bd9Sstevel@tonic-gate Lclazz = (*jenv)->FindClass(jenv, "java/lang/Long"); 1477c478bd9Sstevel@tonic-gate Linit = (*jenv)->GetMethodID(jenv, 1487c478bd9Sstevel@tonic-gate Lclazz, "<init>", "(J)V"); 1497c478bd9Sstevel@tonic-gate for (i = 0; nativeArray[i] != NULL; i++) { 1507c478bd9Sstevel@tonic-gate jobject L; 1517c478bd9Sstevel@tonic-gate /* Build longs and add them */ 1527c478bd9Sstevel@tonic-gate L = (*jenv)->NewObject(jenv, 1537c478bd9Sstevel@tonic-gate Lclazz, Linit, (jlong)(uintptr_t)nativeArray[i]); 1547c478bd9Sstevel@tonic-gate (*jenv)->CallBooleanMethod(jenv, 1557c478bd9Sstevel@tonic-gate jresult, ALadd, L); 1567c478bd9Sstevel@tonic-gate } 1577c478bd9Sstevel@tonic-gate free(nativeArray); 1587c478bd9Sstevel@tonic-gate } 1597c478bd9Sstevel@tonic-gate return (jresult); 1607c478bd9Sstevel@tonic-gate } 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* 1637c478bd9Sstevel@tonic-gate * pool_version(3pool) wrapper 1647c478bd9Sstevel@tonic-gate */ 1657c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1667c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 1677c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1version(JNIEnv *jenv, 1687c478bd9Sstevel@tonic-gate jclass jcls, jlong jver) { 1697c478bd9Sstevel@tonic-gate return ((jlong)pool_version((uint_t)jver)); 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate /* 1737c478bd9Sstevel@tonic-gate * native constant accessor 1747c478bd9Sstevel@tonic-gate */ 1757c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1767c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 1777c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1NATIVE(JNIEnv *jenv, 1787c478bd9Sstevel@tonic-gate jclass jcls) { 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 1877c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1TEXT(JNIEnv *jenv, 1887c478bd9Sstevel@tonic-gate jclass jcls) { 1897c478bd9Sstevel@tonic-gate return ((jint)POX_TEXT); 1907c478bd9Sstevel@tonic-gate } 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate /* 1937c478bd9Sstevel@tonic-gate * native constant accessor 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1967c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 1977c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INVAL(JNIEnv *jenv, 1987c478bd9Sstevel@tonic-gate jclass jcls) { 1997c478bd9Sstevel@tonic-gate return ((jint)POC_INVAL); 2007c478bd9Sstevel@tonic-gate } 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * native constant accessor 2047c478bd9Sstevel@tonic-gate */ 2057c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2067c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2077c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1UINT(JNIEnv *jenv, 2087c478bd9Sstevel@tonic-gate jclass jcls) { 2097c478bd9Sstevel@tonic-gate return ((jint)POC_UINT); 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /* 2137c478bd9Sstevel@tonic-gate * native constant accessor 2147c478bd9Sstevel@tonic-gate */ 2157c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2167c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2177c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INT(JNIEnv *jenv, 2187c478bd9Sstevel@tonic-gate jclass jcls) { 2197c478bd9Sstevel@tonic-gate return ((jint)POC_INT); 2207c478bd9Sstevel@tonic-gate } 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate /* 2237c478bd9Sstevel@tonic-gate * native constant accessor 2247c478bd9Sstevel@tonic-gate */ 2257c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2267c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2277c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1DOUBLE(JNIEnv *jenv, 2287c478bd9Sstevel@tonic-gate jclass jcls) { 2297c478bd9Sstevel@tonic-gate return ((jint)POC_DOUBLE); 2307c478bd9Sstevel@tonic-gate } 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate /* 2337c478bd9Sstevel@tonic-gate * native constant accessor 2347c478bd9Sstevel@tonic-gate */ 2357c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2367c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2377c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1BOOL(JNIEnv *jenv, 2387c478bd9Sstevel@tonic-gate jclass jcls) { 2397c478bd9Sstevel@tonic-gate return ((jint)POC_BOOL); 2407c478bd9Sstevel@tonic-gate } 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate /* 2437c478bd9Sstevel@tonic-gate * native constant accessor 2447c478bd9Sstevel@tonic-gate */ 2457c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2467c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2477c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1STRING(JNIEnv *jenv, 2487c478bd9Sstevel@tonic-gate jclass jcls) { 2497c478bd9Sstevel@tonic-gate return ((jint)POC_STRING); 2507c478bd9Sstevel@tonic-gate } 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * native constant accessor 2547c478bd9Sstevel@tonic-gate */ 2557c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2567c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2577c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1NONE(JNIEnv *jenv, 2587c478bd9Sstevel@tonic-gate jclass jcls) { 2597c478bd9Sstevel@tonic-gate return ((jint)POV_NONE); 2607c478bd9Sstevel@tonic-gate } 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate /* 2637c478bd9Sstevel@tonic-gate * native constant accessor 2647c478bd9Sstevel@tonic-gate */ 2657c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2667c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2677c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1LOOSE(JNIEnv *jenv, 2687c478bd9Sstevel@tonic-gate jclass jcls) { 2697c478bd9Sstevel@tonic-gate return ((jint)POV_LOOSE); 2707c478bd9Sstevel@tonic-gate } 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * native constant accessor 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2767c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2777c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1STRICT(JNIEnv *jenv, 2787c478bd9Sstevel@tonic-gate jclass jcls) { 2797c478bd9Sstevel@tonic-gate return ((jint)POV_STRICT); 2807c478bd9Sstevel@tonic-gate } 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate /* 2837c478bd9Sstevel@tonic-gate * native constant accessor 2847c478bd9Sstevel@tonic-gate */ 2857c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2867c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 2877c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1RUNTIME(JNIEnv *jenv, 2887c478bd9Sstevel@tonic-gate jclass jcls) { 2897c478bd9Sstevel@tonic-gate return ((jint)POV_RUNTIME); 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 2977c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1INVALID(JNIEnv *jenv, 2987c478bd9Sstevel@tonic-gate jclass jcls) { 2997c478bd9Sstevel@tonic-gate return ((jint)POF_INVALID); 3007c478bd9Sstevel@tonic-gate } 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate /* 3037c478bd9Sstevel@tonic-gate * native constant accessor 3047c478bd9Sstevel@tonic-gate */ 3057c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3067c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 3077c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1VALID(JNIEnv *jenv, 3087c478bd9Sstevel@tonic-gate jclass jcls) { 3097c478bd9Sstevel@tonic-gate return ((jint)POF_VALID); 3107c478bd9Sstevel@tonic-gate } 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate /* 3137c478bd9Sstevel@tonic-gate * native constant accessor 3147c478bd9Sstevel@tonic-gate */ 3157c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3167c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 3177c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1DESTROY(JNIEnv *jenv, 3187c478bd9Sstevel@tonic-gate jclass jcls) { 3197c478bd9Sstevel@tonic-gate return ((jint)POF_DESTROY); 3207c478bd9Sstevel@tonic-gate } 3217c478bd9Sstevel@tonic-gate 3227c478bd9Sstevel@tonic-gate /* 3237c478bd9Sstevel@tonic-gate * pool_error(3pool) wrapper 3247c478bd9Sstevel@tonic-gate */ 3257c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3267c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 3277c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1error(JNIEnv *jenv, 3287c478bd9Sstevel@tonic-gate jclass jcls) { 3297c478bd9Sstevel@tonic-gate return ((jint)pool_error()); 3307c478bd9Sstevel@tonic-gate } 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * pool_strerror(3pool) wrapper 3347c478bd9Sstevel@tonic-gate */ 3357c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3367c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 3377c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror(JNIEnv *jenv, 3387c478bd9Sstevel@tonic-gate jclass jcls, jint jperr) { 3397c478bd9Sstevel@tonic-gate jstring jresult = NULL; 3407c478bd9Sstevel@tonic-gate char *result; 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate result = (char *)pool_strerror((int)jperr); 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate if (result) 3457c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 3467c478bd9Sstevel@tonic-gate return (jresult); 3477c478bd9Sstevel@tonic-gate } 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate /* 3507c478bd9Sstevel@tonic-gate * strerror(3c) wrapper 3517c478bd9Sstevel@tonic-gate */ 3527c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3537c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 3547c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror_1sys(JNIEnv * 3557c478bd9Sstevel@tonic-gate jenv, jclass jcls) { 3567c478bd9Sstevel@tonic-gate jstring jresult = NULL; 3577c478bd9Sstevel@tonic-gate char *result; 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate result = (char *)strerror(errno); 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate if (result) 3627c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 3637c478bd9Sstevel@tonic-gate return (jresult); 3647c478bd9Sstevel@tonic-gate } 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate /* 3677c478bd9Sstevel@tonic-gate * errno(3c) accessor 3687c478bd9Sstevel@tonic-gate */ 3697c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3707c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 3717c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolsException_getErrno(JNIEnv *jenv, 3727c478bd9Sstevel@tonic-gate jclass jcls) { 3737c478bd9Sstevel@tonic-gate return ((jint)errno); 3747c478bd9Sstevel@tonic-gate } 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate /* 3777c478bd9Sstevel@tonic-gate * pool_resource_type_list(3pool) wrapper 3787c478bd9Sstevel@tonic-gate */ 3797c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3807c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 3817c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1type_1list( 3827c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jreslist, jlong jnumres) { 383*414388d7Ssl108498 char **reslist = (char **)(uintptr_t)jreslist; 384*414388d7Ssl108498 uint_t *numres = (uint_t *)(uintptr_t)jnumres; 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate return ((jint)pool_resource_type_list((char const **)reslist, numres)); 3877c478bd9Sstevel@tonic-gate } 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate /* 3907c478bd9Sstevel@tonic-gate * pool_get_status(3pool) wrapper 3917c478bd9Sstevel@tonic-gate */ 3927c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3937c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 3947c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1status(JNIEnv *jenv, 395*414388d7Ssl108498 jclass jcls) { 396*414388d7Ssl108498 int status; 397*414388d7Ssl108498 int err; 398*414388d7Ssl108498 399*414388d7Ssl108498 err = pool_get_status(&status); 400*414388d7Ssl108498 if (err == -1) 401*414388d7Ssl108498 return ((jint)PO_FAIL); 402*414388d7Ssl108498 else 403*414388d7Ssl108498 return ((jint)status); 4047c478bd9Sstevel@tonic-gate } 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate /* 4077c478bd9Sstevel@tonic-gate * pool_set_status(3pool) wrapper 4087c478bd9Sstevel@tonic-gate */ 4097c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4107c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 4117c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1status(JNIEnv *jenv, 4127c478bd9Sstevel@tonic-gate jclass jcls, jint jstate) { 4137c478bd9Sstevel@tonic-gate return ((jint)pool_set_status((int)jstate)); 4147c478bd9Sstevel@tonic-gate } 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* 4177c478bd9Sstevel@tonic-gate * pool_conf_alloc(3pool) wrapper 4187c478bd9Sstevel@tonic-gate */ 4197c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4207c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 4217c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1alloc(JNIEnv *jenv, 4227c478bd9Sstevel@tonic-gate jclass jcls) { 4237c478bd9Sstevel@tonic-gate return ((jlong)(uintptr_t)pool_conf_alloc()); 4247c478bd9Sstevel@tonic-gate } 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate /* 4277c478bd9Sstevel@tonic-gate * pool_conf_free(3pool) wrapper 4287c478bd9Sstevel@tonic-gate */ 4297c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4307c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL 4317c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1free(JNIEnv *jenv, 4327c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf) { 433*414388d7Ssl108498 pool_conf_free((pool_conf_t *)(uintptr_t)jconf); 4347c478bd9Sstevel@tonic-gate } 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate /* 4377c478bd9Sstevel@tonic-gate * pool_conf_status(3pool) wrapper 4387c478bd9Sstevel@tonic-gate */ 4397c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4407c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 4417c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1status(JNIEnv *jenv, 4427c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf) { 443*414388d7Ssl108498 return ((jint)pool_conf_status((pool_conf_t *)(uintptr_t)jconf)); 4447c478bd9Sstevel@tonic-gate } 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate /* 4477c478bd9Sstevel@tonic-gate * pool_conf_close(3pool) wrapper 4487c478bd9Sstevel@tonic-gate */ 4497c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4507c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 4517c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1close(JNIEnv *jenv, 4527c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf) { 453*414388d7Ssl108498 return ((jint)pool_conf_close((pool_conf_t *)(uintptr_t)jconf)); 4547c478bd9Sstevel@tonic-gate } 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate /* 4577c478bd9Sstevel@tonic-gate * pool_conf_remove(3pool) wrapper 4587c478bd9Sstevel@tonic-gate */ 4597c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4607c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 4617c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1remove(JNIEnv *jenv, 4627c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf) { 463*414388d7Ssl108498 return ((jint)pool_conf_remove((pool_conf_t *)(uintptr_t)jconf)); 4647c478bd9Sstevel@tonic-gate } 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate /* 4677c478bd9Sstevel@tonic-gate * pool_conf_open(3pool) wrapper 4687c478bd9Sstevel@tonic-gate */ 4697c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4707c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 4717c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1open(JNIEnv *jenv, 4727c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jstring jlocation, jint jflags) { 4737c478bd9Sstevel@tonic-gate const char *location; 4747c478bd9Sstevel@tonic-gate int result; 4757c478bd9Sstevel@tonic-gate 4767c478bd9Sstevel@tonic-gate location = (jlocation) ? (*jenv)->GetStringUTFChars(jenv, 4777c478bd9Sstevel@tonic-gate jlocation, 0) : NULL; 478*414388d7Ssl108498 result = (int)pool_conf_open((pool_conf_t *)(uintptr_t)jconf, location, 4797c478bd9Sstevel@tonic-gate (int)jflags); 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate if (location) 4827c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jlocation, location); 4837c478bd9Sstevel@tonic-gate return ((jint)result); 4847c478bd9Sstevel@tonic-gate } 4857c478bd9Sstevel@tonic-gate 4867c478bd9Sstevel@tonic-gate /* 4877c478bd9Sstevel@tonic-gate * pool_conf_rollback(3pool) wrapper 4887c478bd9Sstevel@tonic-gate */ 4897c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4907c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 4917c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1rollback( 4927c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf) { 493*414388d7Ssl108498 return ((jint)pool_conf_rollback((pool_conf_t *)(uintptr_t)jconf)); 4947c478bd9Sstevel@tonic-gate } 4957c478bd9Sstevel@tonic-gate 4967c478bd9Sstevel@tonic-gate /* 4977c478bd9Sstevel@tonic-gate * pool_conf_commit(3pool) wrapper 4987c478bd9Sstevel@tonic-gate */ 4997c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5007c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 5017c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1commit(JNIEnv *jenv, 5027c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jint jactive) { 503*414388d7Ssl108498 return ((jint)pool_conf_commit( 504*414388d7Ssl108498 (pool_conf_t *)(uintptr_t)jconf, (int)jactive)); 5057c478bd9Sstevel@tonic-gate } 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate /* 5087c478bd9Sstevel@tonic-gate * pool_conf_export(3pool) wrapper 5097c478bd9Sstevel@tonic-gate */ 5107c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5117c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 5127c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1export(JNIEnv *jenv, 5137c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jstring jlocation, jint jformat) { 5147c478bd9Sstevel@tonic-gate const char *location; 5157c478bd9Sstevel@tonic-gate int result; 5167c478bd9Sstevel@tonic-gate 5177c478bd9Sstevel@tonic-gate location = (jlocation) ? (*jenv)->GetStringUTFChars(jenv, 5187c478bd9Sstevel@tonic-gate jlocation, 0) : NULL; 519*414388d7Ssl108498 result = (int)pool_conf_export((pool_conf_t *)(uintptr_t)jconf, 5207c478bd9Sstevel@tonic-gate location, (pool_export_format_t)jformat); 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate if (location) 5237c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jlocation, location); 5247c478bd9Sstevel@tonic-gate return ((jint)result); 5257c478bd9Sstevel@tonic-gate } 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate /* 5287c478bd9Sstevel@tonic-gate * pool_conf_validate(3pool) wrapper 5297c478bd9Sstevel@tonic-gate */ 5307c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5317c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 5327c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1validate( 5337c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jint jlevel) { 534*414388d7Ssl108498 return ((jint)pool_conf_validate((pool_conf_t *)(uintptr_t)jconf, 5357c478bd9Sstevel@tonic-gate (pool_valid_level_t)jlevel)); 5367c478bd9Sstevel@tonic-gate } 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate /* 5397c478bd9Sstevel@tonic-gate * pool_conf_update(3pool) wrapper 5407c478bd9Sstevel@tonic-gate */ 5417c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5427c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 5437c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1update(JNIEnv *jenv, 5447c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf) { 5457c478bd9Sstevel@tonic-gate int changed; 5467c478bd9Sstevel@tonic-gate int result; 5477c478bd9Sstevel@tonic-gate 548*414388d7Ssl108498 result = pool_conf_update((pool_conf_t *)(uintptr_t)jconf, &changed); 5497c478bd9Sstevel@tonic-gate 5507c478bd9Sstevel@tonic-gate if (result != PO_SUCCESS) { 5517c478bd9Sstevel@tonic-gate throw_pe(jenv); 5527c478bd9Sstevel@tonic-gate } 5537c478bd9Sstevel@tonic-gate 5547c478bd9Sstevel@tonic-gate return ((jint)changed); 5557c478bd9Sstevel@tonic-gate } 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate /* 5587c478bd9Sstevel@tonic-gate * pool_get_pool(3pool) wrapper 5597c478bd9Sstevel@tonic-gate */ 5607c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5617c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 5627c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1pool(JNIEnv *jenv, 5637c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jstring jname) { 5647c478bd9Sstevel@tonic-gate const char *name; 5657c478bd9Sstevel@tonic-gate pool_t *result; 5667c478bd9Sstevel@tonic-gate 5677c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : 5687c478bd9Sstevel@tonic-gate NULL; 569*414388d7Ssl108498 result = (pool_t *)pool_get_pool((pool_conf_t *)(uintptr_t)jconf, name); 5707c478bd9Sstevel@tonic-gate 5717c478bd9Sstevel@tonic-gate if (name) 5727c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 5737c478bd9Sstevel@tonic-gate return ((jlong)(uintptr_t)result); 5747c478bd9Sstevel@tonic-gate } 5757c478bd9Sstevel@tonic-gate 5767c478bd9Sstevel@tonic-gate /* 5777c478bd9Sstevel@tonic-gate * pool_query_pools(3pool) wrapper 5787c478bd9Sstevel@tonic-gate */ 5797c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5807c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL 5817c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pools(JNIEnv *jenv, 5827c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jobject jprops) { 5837c478bd9Sstevel@tonic-gate pool_value_t **props; 5847c478bd9Sstevel@tonic-gate pool_t **result; 5857c478bd9Sstevel@tonic-gate jclass Lclazz; 5867c478bd9Sstevel@tonic-gate jmethodID Lsize; 5877c478bd9Sstevel@tonic-gate jint size; 5887c478bd9Sstevel@tonic-gate uint_t nelem; 5897c478bd9Sstevel@tonic-gate int i; 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate 5927c478bd9Sstevel@tonic-gate /* 5937c478bd9Sstevel@tonic-gate * Initialize the target parameter for case when input is null 5947c478bd9Sstevel@tonic-gate */ 5957c478bd9Sstevel@tonic-gate props = NULL; 5967c478bd9Sstevel@tonic-gate if (jprops != NULL) { 5977c478bd9Sstevel@tonic-gate Lclazz = (*jenv)->GetObjectClass(jenv, jprops); 5987c478bd9Sstevel@tonic-gate Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I"); 5997c478bd9Sstevel@tonic-gate size = (*jenv)->CallIntMethod(jenv, jprops, Lsize); 6007c478bd9Sstevel@tonic-gate 6017c478bd9Sstevel@tonic-gate if (size != 0) { 6027c478bd9Sstevel@tonic-gate jmethodID Lget; 6037c478bd9Sstevel@tonic-gate 6047c478bd9Sstevel@tonic-gate Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get", 6057c478bd9Sstevel@tonic-gate "(I)Ljava/lang/Object;"); 6067c478bd9Sstevel@tonic-gate /* 6077c478bd9Sstevel@tonic-gate * Allocate space for the props array 6087c478bd9Sstevel@tonic-gate */ 6097c478bd9Sstevel@tonic-gate 6107c478bd9Sstevel@tonic-gate if ((props = calloc(size + 1, sizeof (pool_value_t *))) 6117c478bd9Sstevel@tonic-gate == NULL) { 6127c478bd9Sstevel@tonic-gate throwException(jenv, "java/lang/Exception", 6137c478bd9Sstevel@tonic-gate "Could not allocate props array"); 6147c478bd9Sstevel@tonic-gate return (NULL); 6157c478bd9Sstevel@tonic-gate } 6167c478bd9Sstevel@tonic-gate /* 6177c478bd9Sstevel@tonic-gate * Copy in the array 6187c478bd9Sstevel@tonic-gate */ 6197c478bd9Sstevel@tonic-gate for (i = 0; i < size; i++) { 6207c478bd9Sstevel@tonic-gate jobject aVal; 6217c478bd9Sstevel@tonic-gate jclass Vclazz; 6227c478bd9Sstevel@tonic-gate jfieldID Vthis; 6237c478bd9Sstevel@tonic-gate jlong this; 6247c478bd9Sstevel@tonic-gate 6257c478bd9Sstevel@tonic-gate aVal = (*jenv)->CallObjectMethod(jenv, jprops, 6267c478bd9Sstevel@tonic-gate Lget, (jint) i); 6277c478bd9Sstevel@tonic-gate Vclazz = (*jenv)->GetObjectClass(jenv, aVal); 6287c478bd9Sstevel@tonic-gate Vthis = (*jenv)->GetFieldID(jenv, Vclazz, 6297c478bd9Sstevel@tonic-gate "_this", "J"); 6307c478bd9Sstevel@tonic-gate this = (*jenv)->GetLongField(jenv, aVal, Vthis); 631*414388d7Ssl108498 props[i] = (pool_value_t *)(uintptr_t)this; 6327c478bd9Sstevel@tonic-gate } 6337c478bd9Sstevel@tonic-gate } 6347c478bd9Sstevel@tonic-gate } 635*414388d7Ssl108498 result = pool_query_pools((pool_conf_t *)(uintptr_t)jconf, &nelem, 6367c478bd9Sstevel@tonic-gate props); 6377c478bd9Sstevel@tonic-gate free(props); 6387c478bd9Sstevel@tonic-gate return (copyArray(jenv, (void **)result)); 6397c478bd9Sstevel@tonic-gate } 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gate /* 6427c478bd9Sstevel@tonic-gate * pool_get_resource(3pool) wrapper 6437c478bd9Sstevel@tonic-gate */ 6447c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 6457c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 6467c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource( 6477c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jstring jtype, jstring jname) { 6487c478bd9Sstevel@tonic-gate const char *type; 6497c478bd9Sstevel@tonic-gate const char *name; 6507c478bd9Sstevel@tonic-gate pool_resource_t *result; 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate type = (jtype) ? (*jenv)->GetStringUTFChars(jenv, jtype, 0) : 6537c478bd9Sstevel@tonic-gate NULL; 6547c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : 6557c478bd9Sstevel@tonic-gate NULL; 656*414388d7Ssl108498 result = pool_get_resource((pool_conf_t *)(uintptr_t)jconf, type, name); 6577c478bd9Sstevel@tonic-gate 6587c478bd9Sstevel@tonic-gate if (type) 6597c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jtype, type); 6607c478bd9Sstevel@tonic-gate if (name) 6617c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 6627c478bd9Sstevel@tonic-gate return ((jlong)(uintptr_t)result); 6637c478bd9Sstevel@tonic-gate } 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate /* 6667c478bd9Sstevel@tonic-gate * pool_query_resources(3pool) wrapper 6677c478bd9Sstevel@tonic-gate */ 6687c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 6697c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL 6707c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resources( 6717c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jobject jprops) { 6727c478bd9Sstevel@tonic-gate pool_value_t **props; 6737c478bd9Sstevel@tonic-gate pool_resource_t **result; 6747c478bd9Sstevel@tonic-gate jclass Lclazz; 6757c478bd9Sstevel@tonic-gate jmethodID Lsize; 6767c478bd9Sstevel@tonic-gate jint size; 6777c478bd9Sstevel@tonic-gate uint_t nelem; 6787c478bd9Sstevel@tonic-gate int i; 6797c478bd9Sstevel@tonic-gate 6807c478bd9Sstevel@tonic-gate /* 6817c478bd9Sstevel@tonic-gate * Initialize the target parameter for case when input is null 6827c478bd9Sstevel@tonic-gate */ 6837c478bd9Sstevel@tonic-gate props = NULL; 6847c478bd9Sstevel@tonic-gate if (jprops != NULL) { 6857c478bd9Sstevel@tonic-gate Lclazz = (*jenv)->GetObjectClass(jenv, jprops); 6867c478bd9Sstevel@tonic-gate Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I"); 6877c478bd9Sstevel@tonic-gate size = (*jenv)->CallIntMethod(jenv, jprops, Lsize); 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate if (size != 0) { 6907c478bd9Sstevel@tonic-gate jmethodID Lget; 6917c478bd9Sstevel@tonic-gate 6927c478bd9Sstevel@tonic-gate Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get", 6937c478bd9Sstevel@tonic-gate "(I)Ljava/lang/Object;"); 6947c478bd9Sstevel@tonic-gate /* 6957c478bd9Sstevel@tonic-gate * Allocate space for the props array 6967c478bd9Sstevel@tonic-gate */ 6977c478bd9Sstevel@tonic-gate if ((props = calloc(size + 1, sizeof (pool_value_t *))) 6987c478bd9Sstevel@tonic-gate == NULL) { 6997c478bd9Sstevel@tonic-gate throwException(jenv, "java/lang/Exception", 7007c478bd9Sstevel@tonic-gate "Could not allocate props array"); 7017c478bd9Sstevel@tonic-gate return (NULL); 7027c478bd9Sstevel@tonic-gate } 7037c478bd9Sstevel@tonic-gate /* 7047c478bd9Sstevel@tonic-gate * Copy in the array 7057c478bd9Sstevel@tonic-gate */ 7067c478bd9Sstevel@tonic-gate for (i = 0; i < size; i++) { 7077c478bd9Sstevel@tonic-gate jobject aVal; 7087c478bd9Sstevel@tonic-gate jclass Vclazz; 7097c478bd9Sstevel@tonic-gate jfieldID Vthis; 7107c478bd9Sstevel@tonic-gate jlong this; 7117c478bd9Sstevel@tonic-gate 7127c478bd9Sstevel@tonic-gate 7137c478bd9Sstevel@tonic-gate aVal = (*jenv)->CallObjectMethod(jenv, jprops, 7147c478bd9Sstevel@tonic-gate Lget, (jint) i); 7157c478bd9Sstevel@tonic-gate Vclazz = (*jenv)->GetObjectClass(jenv, aVal); 7167c478bd9Sstevel@tonic-gate Vthis = (*jenv)->GetFieldID(jenv, Vclazz, 7177c478bd9Sstevel@tonic-gate "_this", "J"); 7187c478bd9Sstevel@tonic-gate this = (*jenv)->GetLongField(jenv, aVal, Vthis); 719*414388d7Ssl108498 props[i] = (pool_value_t *)(uintptr_t)this; 7207c478bd9Sstevel@tonic-gate } 7217c478bd9Sstevel@tonic-gate } 7227c478bd9Sstevel@tonic-gate } 723*414388d7Ssl108498 result = pool_query_resources((pool_conf_t *)(uintptr_t)jconf, &nelem, 7247c478bd9Sstevel@tonic-gate props); 7257c478bd9Sstevel@tonic-gate free(props); 7267c478bd9Sstevel@tonic-gate return (copyArray(jenv, (void *)result)); 7277c478bd9Sstevel@tonic-gate } 7287c478bd9Sstevel@tonic-gate 7297c478bd9Sstevel@tonic-gate /* 7307c478bd9Sstevel@tonic-gate * pool_query_components(3pool) wrapper 7317c478bd9Sstevel@tonic-gate */ 7327c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 7337c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL 7347c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1components( 7357c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jobject jprops) { 7367c478bd9Sstevel@tonic-gate pool_value_t **props; 7377c478bd9Sstevel@tonic-gate pool_component_t **result; 7387c478bd9Sstevel@tonic-gate jclass Lclazz; 7397c478bd9Sstevel@tonic-gate jmethodID Lsize; 7407c478bd9Sstevel@tonic-gate jint size; 7417c478bd9Sstevel@tonic-gate uint_t nelem; 7427c478bd9Sstevel@tonic-gate int i; 7437c478bd9Sstevel@tonic-gate 7447c478bd9Sstevel@tonic-gate /* 7457c478bd9Sstevel@tonic-gate * Initialize the target parameter for case when input is null 7467c478bd9Sstevel@tonic-gate */ 7477c478bd9Sstevel@tonic-gate props = NULL; 7487c478bd9Sstevel@tonic-gate if (jprops != NULL) { 7497c478bd9Sstevel@tonic-gate Lclazz = (*jenv)->GetObjectClass(jenv, jprops); 7507c478bd9Sstevel@tonic-gate Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I"); 7517c478bd9Sstevel@tonic-gate size = (*jenv)->CallIntMethod(jenv, jprops, Lsize); 7527c478bd9Sstevel@tonic-gate 7537c478bd9Sstevel@tonic-gate if (size != 0) { 7547c478bd9Sstevel@tonic-gate jmethodID Lget; 7557c478bd9Sstevel@tonic-gate 7567c478bd9Sstevel@tonic-gate Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get", 7577c478bd9Sstevel@tonic-gate "(I)Ljava/lang/Object;"); 7587c478bd9Sstevel@tonic-gate /* 7597c478bd9Sstevel@tonic-gate * Allocate space for the props array 7607c478bd9Sstevel@tonic-gate */ 7617c478bd9Sstevel@tonic-gate 7627c478bd9Sstevel@tonic-gate if ((props = calloc(size + 1, sizeof (pool_value_t *))) 7637c478bd9Sstevel@tonic-gate == NULL) { 7647c478bd9Sstevel@tonic-gate throwException(jenv, "java/lang/Exception", 7657c478bd9Sstevel@tonic-gate "Could not allocate props array"); 7667c478bd9Sstevel@tonic-gate return (NULL); 7677c478bd9Sstevel@tonic-gate } 7687c478bd9Sstevel@tonic-gate /* 7697c478bd9Sstevel@tonic-gate * Copy in the array 7707c478bd9Sstevel@tonic-gate */ 7717c478bd9Sstevel@tonic-gate for (i = 0; i < size; i++) { 7727c478bd9Sstevel@tonic-gate jobject aVal; 7737c478bd9Sstevel@tonic-gate jclass Vclazz; 7747c478bd9Sstevel@tonic-gate jfieldID Vthis; 7757c478bd9Sstevel@tonic-gate jlong this; 7767c478bd9Sstevel@tonic-gate 7777c478bd9Sstevel@tonic-gate aVal = (*jenv)->CallObjectMethod(jenv, jprops, 7787c478bd9Sstevel@tonic-gate Lget, (jint) i); 7797c478bd9Sstevel@tonic-gate Vclazz = (*jenv)->GetObjectClass(jenv, aVal); 7807c478bd9Sstevel@tonic-gate Vthis = (*jenv)->GetFieldID(jenv, Vclazz, 7817c478bd9Sstevel@tonic-gate "_this", "J"); 7827c478bd9Sstevel@tonic-gate this = (*jenv)->GetLongField(jenv, aVal, Vthis); 783*414388d7Ssl108498 props[i] = (pool_value_t *)(uintptr_t)this; 7847c478bd9Sstevel@tonic-gate } 7857c478bd9Sstevel@tonic-gate } 7867c478bd9Sstevel@tonic-gate } 787*414388d7Ssl108498 result = pool_query_components((pool_conf_t *)(uintptr_t)jconf, &nelem, 7887c478bd9Sstevel@tonic-gate props); 7897c478bd9Sstevel@tonic-gate free(props); 7907c478bd9Sstevel@tonic-gate return (copyArray(jenv, (void **)result)); 7917c478bd9Sstevel@tonic-gate } 7927c478bd9Sstevel@tonic-gate 7937c478bd9Sstevel@tonic-gate /* 7947c478bd9Sstevel@tonic-gate * pool_conf_location(3pool) wrapper 7957c478bd9Sstevel@tonic-gate */ 7967c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 7977c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 7987c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1location( 7997c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf) { 8007c478bd9Sstevel@tonic-gate jstring jresult = NULL; 8017c478bd9Sstevel@tonic-gate const char *result; 8027c478bd9Sstevel@tonic-gate 803*414388d7Ssl108498 result = pool_conf_location((pool_conf_t *)(uintptr_t)jconf); 8047c478bd9Sstevel@tonic-gate 8057c478bd9Sstevel@tonic-gate if (result) 8067c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 8077c478bd9Sstevel@tonic-gate return (jresult); 8087c478bd9Sstevel@tonic-gate } 8097c478bd9Sstevel@tonic-gate 8107c478bd9Sstevel@tonic-gate /* 8117c478bd9Sstevel@tonic-gate * pool_conf_info(3pool) wrapper 8127c478bd9Sstevel@tonic-gate */ 8137c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 8147c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 8157c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1info(JNIEnv *jenv, 8167c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jint jflags) { 8177c478bd9Sstevel@tonic-gate jstring jresult = NULL; 8187c478bd9Sstevel@tonic-gate const char *result; 8197c478bd9Sstevel@tonic-gate 820*414388d7Ssl108498 result = pool_conf_info((pool_conf_t *)(uintptr_t)jconf, (int)jflags); 8217c478bd9Sstevel@tonic-gate 8227c478bd9Sstevel@tonic-gate if (result) 8237c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 8247c478bd9Sstevel@tonic-gate free((void *)result); 8257c478bd9Sstevel@tonic-gate return (jresult); 8267c478bd9Sstevel@tonic-gate } 8277c478bd9Sstevel@tonic-gate 8287c478bd9Sstevel@tonic-gate /* 8297c478bd9Sstevel@tonic-gate * pool_resource_create(3pool) wrapper 8307c478bd9Sstevel@tonic-gate */ 8317c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 8327c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 8337c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1create( 8347c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jstring jtype, jstring jname) { 8357c478bd9Sstevel@tonic-gate const char *type; 8367c478bd9Sstevel@tonic-gate const char *name; 8377c478bd9Sstevel@tonic-gate pool_resource_t *result; 8387c478bd9Sstevel@tonic-gate 8397c478bd9Sstevel@tonic-gate type = (jtype) ? (*jenv)->GetStringUTFChars(jenv, jtype, 0) : 8407c478bd9Sstevel@tonic-gate NULL; 8417c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : 8427c478bd9Sstevel@tonic-gate NULL; 843*414388d7Ssl108498 result = 844*414388d7Ssl108498 pool_resource_create((pool_conf_t *)(uintptr_t)jconf, type, name); 8457c478bd9Sstevel@tonic-gate 8467c478bd9Sstevel@tonic-gate if (type) 8477c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jtype, type); 8487c478bd9Sstevel@tonic-gate if (name) 8497c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 8507c478bd9Sstevel@tonic-gate return ((jlong)(uintptr_t)result); 8517c478bd9Sstevel@tonic-gate } 8527c478bd9Sstevel@tonic-gate 8537c478bd9Sstevel@tonic-gate /* 8547c478bd9Sstevel@tonic-gate * pool_resource_destroy(3pool) wrapper 8557c478bd9Sstevel@tonic-gate */ 8567c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 8577c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 8587c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1destroy( 8597c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource) { 860*414388d7Ssl108498 return ((jint)pool_resource_destroy((pool_conf_t *)(uintptr_t)jconf, 861*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jresource)); 8627c478bd9Sstevel@tonic-gate } 8637c478bd9Sstevel@tonic-gate 8647c478bd9Sstevel@tonic-gate /* 8657c478bd9Sstevel@tonic-gate * pool_resource_transfer(3pool) wrapper 8667c478bd9Sstevel@tonic-gate */ 8677c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 8687c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 8697c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1transfer( 8707c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jsource, jlong jtarget, 8717c478bd9Sstevel@tonic-gate jlong jsize) { 872*414388d7Ssl108498 return (pool_resource_transfer((pool_conf_t *)(uintptr_t)jconf, 873*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jsource, 874*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jtarget, 8757c478bd9Sstevel@tonic-gate (uint64_t)jsize)); 8767c478bd9Sstevel@tonic-gate } 8777c478bd9Sstevel@tonic-gate 8787c478bd9Sstevel@tonic-gate /* 8797c478bd9Sstevel@tonic-gate * pool_resource_xtransfer(3pool) wrapper 8807c478bd9Sstevel@tonic-gate */ 8817c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 8827c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 8837c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1xtransfer( 8847c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jsource, jlong jtarget, 8857c478bd9Sstevel@tonic-gate jobject jcomponents) { 8867c478bd9Sstevel@tonic-gate pool_component_t **components; 8877c478bd9Sstevel@tonic-gate int result; 8887c478bd9Sstevel@tonic-gate jclass Lclazz; 8897c478bd9Sstevel@tonic-gate jmethodID Lsize; 8907c478bd9Sstevel@tonic-gate jint size; 8917c478bd9Sstevel@tonic-gate 8927c478bd9Sstevel@tonic-gate /* 8937c478bd9Sstevel@tonic-gate * Initialize the target parameter for case when input is null 8947c478bd9Sstevel@tonic-gate */ 8957c478bd9Sstevel@tonic-gate components = NULL; 8967c478bd9Sstevel@tonic-gate if (jcomponents != NULL) { 8977c478bd9Sstevel@tonic-gate Lclazz = (*jenv)->GetObjectClass(jenv, jcomponents); 8987c478bd9Sstevel@tonic-gate Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I"); 8997c478bd9Sstevel@tonic-gate size = (*jenv)->CallIntMethod(jenv, jcomponents, Lsize); 9007c478bd9Sstevel@tonic-gate 9017c478bd9Sstevel@tonic-gate if (size != 0) { 9027c478bd9Sstevel@tonic-gate jmethodID Lget; 9037c478bd9Sstevel@tonic-gate int i; 9047c478bd9Sstevel@tonic-gate 9057c478bd9Sstevel@tonic-gate Lget = (*jenv)->GetMethodID(jenv, 9067c478bd9Sstevel@tonic-gate Lclazz, "get", "(I)Ljava/lang/Object;"); 9077c478bd9Sstevel@tonic-gate /* Allocate space for the components array */ 9087c478bd9Sstevel@tonic-gate 9097c478bd9Sstevel@tonic-gate if ((components = calloc(size + 1, 9107c478bd9Sstevel@tonic-gate sizeof (pool_component_t *))) == NULL) { 9117c478bd9Sstevel@tonic-gate throwException(jenv, "java/lang/Exception", 9127c478bd9Sstevel@tonic-gate "Could not allocate component array"); 9137c478bd9Sstevel@tonic-gate return (NULL); 9147c478bd9Sstevel@tonic-gate } 9157c478bd9Sstevel@tonic-gate /* 9167c478bd9Sstevel@tonic-gate * Copy in the array 9177c478bd9Sstevel@tonic-gate */ 9187c478bd9Sstevel@tonic-gate for (i = 0; i < size; i++) { 9197c478bd9Sstevel@tonic-gate jobject aVal; 9207c478bd9Sstevel@tonic-gate jclass Vclazz; 9217c478bd9Sstevel@tonic-gate jlong this; 9227c478bd9Sstevel@tonic-gate jmethodID Vthis; 9237c478bd9Sstevel@tonic-gate 9247c478bd9Sstevel@tonic-gate aVal = (*jenv)->CallObjectMethod(jenv, 9257c478bd9Sstevel@tonic-gate jcomponents, Lget, (jint) i); 9267c478bd9Sstevel@tonic-gate Vclazz = (*jenv)->GetObjectClass(jenv, 9277c478bd9Sstevel@tonic-gate aVal); 9287c478bd9Sstevel@tonic-gate Vthis = (*jenv)->GetMethodID(jenv, 9297c478bd9Sstevel@tonic-gate Vclazz, "getComponent", "()J"); 9307c478bd9Sstevel@tonic-gate this = (*jenv)->CallLongMethod(jenv, 9317c478bd9Sstevel@tonic-gate aVal, Vthis); 932*414388d7Ssl108498 components[i] = 933*414388d7Ssl108498 (pool_component_t *)(uintptr_t)this; 9347c478bd9Sstevel@tonic-gate } 9357c478bd9Sstevel@tonic-gate } 9367c478bd9Sstevel@tonic-gate } 937*414388d7Ssl108498 result = (int)pool_resource_xtransfer((pool_conf_t *)(uintptr_t)jconf, 938*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jsource, 939*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jtarget, 9407c478bd9Sstevel@tonic-gate components); 9417c478bd9Sstevel@tonic-gate free(components); 9427c478bd9Sstevel@tonic-gate 9437c478bd9Sstevel@tonic-gate return ((jint)result); 9447c478bd9Sstevel@tonic-gate } 9457c478bd9Sstevel@tonic-gate 9467c478bd9Sstevel@tonic-gate /* 9477c478bd9Sstevel@tonic-gate * pool_query_resource_components(3pool) wrapper 9487c478bd9Sstevel@tonic-gate */ 9497c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 9507c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL 9517c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resource_\ 9527c478bd9Sstevel@tonic-gate 1components(JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource, 9537c478bd9Sstevel@tonic-gate jobject jprops) { 9547c478bd9Sstevel@tonic-gate pool_value_t **props; 9557c478bd9Sstevel@tonic-gate pool_component_t **result; 9567c478bd9Sstevel@tonic-gate jclass Lclazz; 9577c478bd9Sstevel@tonic-gate jmethodID Lsize; 9587c478bd9Sstevel@tonic-gate uint_t nelem; 9597c478bd9Sstevel@tonic-gate jint size; 9607c478bd9Sstevel@tonic-gate 9617c478bd9Sstevel@tonic-gate /* 9627c478bd9Sstevel@tonic-gate * Initialize the target parameter for case when input is null 9637c478bd9Sstevel@tonic-gate */ 9647c478bd9Sstevel@tonic-gate props = NULL; 9657c478bd9Sstevel@tonic-gate if (jprops != NULL) { 9667c478bd9Sstevel@tonic-gate Lclazz = (*jenv)->GetObjectClass(jenv, jprops); 9677c478bd9Sstevel@tonic-gate Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I"); 9687c478bd9Sstevel@tonic-gate size = (*jenv)->CallIntMethod(jenv, jprops, Lsize); 9697c478bd9Sstevel@tonic-gate 9707c478bd9Sstevel@tonic-gate if (size != 0) { 9717c478bd9Sstevel@tonic-gate jmethodID Lget; 9727c478bd9Sstevel@tonic-gate int i; 9737c478bd9Sstevel@tonic-gate 9747c478bd9Sstevel@tonic-gate Lget = (*jenv)->GetMethodID(jenv, Lclazz, "get", 9757c478bd9Sstevel@tonic-gate "(I)Ljava/lang/Object;"); 9767c478bd9Sstevel@tonic-gate /* 9777c478bd9Sstevel@tonic-gate * Allocate space for the props array 9787c478bd9Sstevel@tonic-gate */ 9797c478bd9Sstevel@tonic-gate if ((props = calloc(size + 1, sizeof (pool_value_t *))) 9807c478bd9Sstevel@tonic-gate == NULL) { 9817c478bd9Sstevel@tonic-gate throwException(jenv, "java/lang/Exception", 9827c478bd9Sstevel@tonic-gate "Could not allocate props array"); 9837c478bd9Sstevel@tonic-gate return (NULL); 9847c478bd9Sstevel@tonic-gate } 9857c478bd9Sstevel@tonic-gate /* 9867c478bd9Sstevel@tonic-gate * Copy in the array 9877c478bd9Sstevel@tonic-gate */ 9887c478bd9Sstevel@tonic-gate for (i = 0; i < size; i++) { 9897c478bd9Sstevel@tonic-gate jobject aVal; 9907c478bd9Sstevel@tonic-gate jclass Vclazz; 9917c478bd9Sstevel@tonic-gate jfieldID Vthis; 9927c478bd9Sstevel@tonic-gate jlong this; 9937c478bd9Sstevel@tonic-gate 9947c478bd9Sstevel@tonic-gate aVal = (*jenv)->CallObjectMethod(jenv, jprops, 9957c478bd9Sstevel@tonic-gate Lget, (jint) i); 9967c478bd9Sstevel@tonic-gate Vclazz = (*jenv)->GetObjectClass(jenv, aVal); 9977c478bd9Sstevel@tonic-gate Vthis = (*jenv)->GetFieldID(jenv, Vclazz, 9987c478bd9Sstevel@tonic-gate "_this", "J"); 9997c478bd9Sstevel@tonic-gate this = (*jenv)->GetLongField(jenv, aVal, Vthis); 1000*414388d7Ssl108498 props[i] = (pool_value_t *)(uintptr_t)this; 10017c478bd9Sstevel@tonic-gate } 10027c478bd9Sstevel@tonic-gate } 10037c478bd9Sstevel@tonic-gate } 1004*414388d7Ssl108498 result = pool_query_resource_components( 1005*414388d7Ssl108498 (pool_conf_t *)(uintptr_t)jconf, 1006*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jresource, &nelem, props); 10077c478bd9Sstevel@tonic-gate free(props); 10087c478bd9Sstevel@tonic-gate return (copyArray(jenv, (void **)result)); 10097c478bd9Sstevel@tonic-gate } 10107c478bd9Sstevel@tonic-gate 10117c478bd9Sstevel@tonic-gate /* 10127c478bd9Sstevel@tonic-gate * pool_resource_info(3pool) wrapper 10137c478bd9Sstevel@tonic-gate */ 10147c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 10157c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 10167c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1info( 10177c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource, jint jflags) { 10187c478bd9Sstevel@tonic-gate jstring jresult = NULL; 10197c478bd9Sstevel@tonic-gate const char *result; 10207c478bd9Sstevel@tonic-gate 1021*414388d7Ssl108498 result = pool_resource_info((pool_conf_t *)(uintptr_t)jconf, 1022*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jresource, (int)jflags); 10237c478bd9Sstevel@tonic-gate 10247c478bd9Sstevel@tonic-gate if (result) 10257c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 10267c478bd9Sstevel@tonic-gate free((void *)result); 10277c478bd9Sstevel@tonic-gate return (jresult); 10287c478bd9Sstevel@tonic-gate } 10297c478bd9Sstevel@tonic-gate 10307c478bd9Sstevel@tonic-gate /* 10317c478bd9Sstevel@tonic-gate * pool_create(3pool) wrapper 10327c478bd9Sstevel@tonic-gate */ 10337c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 10347c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 10357c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1create(JNIEnv *jenv, 10367c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jstring jname) { 10377c478bd9Sstevel@tonic-gate const char *name; 10387c478bd9Sstevel@tonic-gate pool_t *result; 10397c478bd9Sstevel@tonic-gate 10407c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : 10417c478bd9Sstevel@tonic-gate NULL; 1042*414388d7Ssl108498 result = pool_create((pool_conf_t *)(uintptr_t)jconf, name); 10437c478bd9Sstevel@tonic-gate 10447c478bd9Sstevel@tonic-gate if (name) 10457c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 10467c478bd9Sstevel@tonic-gate return ((jlong)(uintptr_t)result); 10477c478bd9Sstevel@tonic-gate } 10487c478bd9Sstevel@tonic-gate 10497c478bd9Sstevel@tonic-gate /* 10507c478bd9Sstevel@tonic-gate * pool_destroy(3pool) wrapper 10517c478bd9Sstevel@tonic-gate */ 10527c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 10537c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 10547c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1destroy(JNIEnv *jenv, 10557c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jlong jpool) { 1056*414388d7Ssl108498 return ((jint)pool_destroy((pool_conf_t *)(uintptr_t)jconf, 1057*414388d7Ssl108498 (pool_t *)(uintptr_t)jpool)); 10587c478bd9Sstevel@tonic-gate } 10597c478bd9Sstevel@tonic-gate 10607c478bd9Sstevel@tonic-gate /* 10617c478bd9Sstevel@tonic-gate * pool_associate(3pool) wrapper 10627c478bd9Sstevel@tonic-gate */ 10637c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 10647c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 10657c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1associate(JNIEnv *jenv, 10667c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jlong jpool, jlong jresource) { 1067*414388d7Ssl108498 return ((jint)pool_associate((pool_conf_t *)(uintptr_t)jconf, 1068*414388d7Ssl108498 (pool_t *)(uintptr_t)jpool, 1069*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jresource)); 10707c478bd9Sstevel@tonic-gate } 10717c478bd9Sstevel@tonic-gate 10727c478bd9Sstevel@tonic-gate /* 10737c478bd9Sstevel@tonic-gate * pool_dissociate(3pool) wrapper 10747c478bd9Sstevel@tonic-gate */ 10757c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 10767c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 10777c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1dissociate(JNIEnv *jenv, 10787c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jlong jpool, jlong jresource) { 1079*414388d7Ssl108498 return ((jint)pool_dissociate((pool_conf_t *)(uintptr_t)jconf, 1080*414388d7Ssl108498 (pool_t *)(uintptr_t)jpool, 1081*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jresource)); 10827c478bd9Sstevel@tonic-gate } 10837c478bd9Sstevel@tonic-gate 10847c478bd9Sstevel@tonic-gate /* 10857c478bd9Sstevel@tonic-gate * pool_info(3pool) wrapper 10867c478bd9Sstevel@tonic-gate */ 10877c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 10887c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 10897c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1info(JNIEnv *jenv, 10907c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jlong jpool, jint jflags) { 10917c478bd9Sstevel@tonic-gate jstring jresult = NULL; 10927c478bd9Sstevel@tonic-gate const char *result; 10937c478bd9Sstevel@tonic-gate 1094*414388d7Ssl108498 result = pool_info((pool_conf_t *)(uintptr_t)jconf, 1095*414388d7Ssl108498 (pool_t *)(uintptr_t)jpool, (int)jflags); 10967c478bd9Sstevel@tonic-gate 10977c478bd9Sstevel@tonic-gate if (result) 10987c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 10997c478bd9Sstevel@tonic-gate free((void *)result); 11007c478bd9Sstevel@tonic-gate return (jresult); 11017c478bd9Sstevel@tonic-gate } 11027c478bd9Sstevel@tonic-gate 11037c478bd9Sstevel@tonic-gate /* 11047c478bd9Sstevel@tonic-gate * pool_query_pool_resources(3pool) wrapper 11057c478bd9Sstevel@tonic-gate */ 11067c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 11077c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL 11087c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pool_1resources( 11097c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jpool, jobject jprops) { 11107c478bd9Sstevel@tonic-gate pool_value_t **props; 11117c478bd9Sstevel@tonic-gate pool_resource_t **result; 11127c478bd9Sstevel@tonic-gate jclass Lclazz; 11137c478bd9Sstevel@tonic-gate jmethodID Lsize; 11147c478bd9Sstevel@tonic-gate uint_t nelem; 11157c478bd9Sstevel@tonic-gate jint size; 11167c478bd9Sstevel@tonic-gate 11177c478bd9Sstevel@tonic-gate /* 11187c478bd9Sstevel@tonic-gate * Initialize the target parameter for case when input is null 11197c478bd9Sstevel@tonic-gate */ 11207c478bd9Sstevel@tonic-gate props = NULL; 11217c478bd9Sstevel@tonic-gate if (jprops != NULL) { 11227c478bd9Sstevel@tonic-gate Lclazz = (*jenv)->GetObjectClass(jenv, jprops); 11237c478bd9Sstevel@tonic-gate Lsize = (*jenv)->GetMethodID(jenv, Lclazz, "size", "()I"); 11247c478bd9Sstevel@tonic-gate size = (*jenv)->CallIntMethod(jenv, jprops, Lsize); 11257c478bd9Sstevel@tonic-gate 11267c478bd9Sstevel@tonic-gate if (size != 0) { 11277c478bd9Sstevel@tonic-gate jmethodID Lget; 11287c478bd9Sstevel@tonic-gate int i; 11297c478bd9Sstevel@tonic-gate 11307c478bd9Sstevel@tonic-gate Lget = (*jenv)->GetMethodID(jenv, 11317c478bd9Sstevel@tonic-gate Lclazz, "get", "(I)Ljava/lang/Object;"); 11327c478bd9Sstevel@tonic-gate /* 11337c478bd9Sstevel@tonic-gate * Allocate space for the props array 11347c478bd9Sstevel@tonic-gate */ 11357c478bd9Sstevel@tonic-gate 11367c478bd9Sstevel@tonic-gate if ((props = calloc(size + 1, sizeof (pool_value_t *))) 11377c478bd9Sstevel@tonic-gate == NULL) { 11387c478bd9Sstevel@tonic-gate throwException(jenv, "java/lang/Exception", 11397c478bd9Sstevel@tonic-gate "Could not allocate props array"); 11407c478bd9Sstevel@tonic-gate return (NULL); 11417c478bd9Sstevel@tonic-gate } 11427c478bd9Sstevel@tonic-gate /* 11437c478bd9Sstevel@tonic-gate * Copy in the array 11447c478bd9Sstevel@tonic-gate */ 11457c478bd9Sstevel@tonic-gate for (i = 0; i < size; i++) { 11467c478bd9Sstevel@tonic-gate jobject aVal; 11477c478bd9Sstevel@tonic-gate jclass Vclazz; 11487c478bd9Sstevel@tonic-gate jfieldID Vthis; 11497c478bd9Sstevel@tonic-gate jlong this; 11507c478bd9Sstevel@tonic-gate 11517c478bd9Sstevel@tonic-gate aVal = (*jenv)->CallObjectMethod(jenv, jprops, 11527c478bd9Sstevel@tonic-gate Lget, (jint) i); 11537c478bd9Sstevel@tonic-gate Vclazz = (*jenv)->GetObjectClass(jenv, aVal); 11547c478bd9Sstevel@tonic-gate Vthis = (*jenv)->GetFieldID(jenv, Vclazz, 11557c478bd9Sstevel@tonic-gate "_this", "J"); 11567c478bd9Sstevel@tonic-gate this = (*jenv)->GetLongField(jenv, aVal, Vthis); 1157*414388d7Ssl108498 props[i] = (pool_value_t *)(uintptr_t)this; 11587c478bd9Sstevel@tonic-gate } 11597c478bd9Sstevel@tonic-gate } 11607c478bd9Sstevel@tonic-gate } 1161*414388d7Ssl108498 result = pool_query_pool_resources((pool_conf_t *)(uintptr_t)jconf, 1162*414388d7Ssl108498 (pool_t *)(uintptr_t)jpool, &nelem, props); 11637c478bd9Sstevel@tonic-gate free(props); 11647c478bd9Sstevel@tonic-gate return (copyArray(jenv, (void **)result)); 11657c478bd9Sstevel@tonic-gate } 11667c478bd9Sstevel@tonic-gate 11677c478bd9Sstevel@tonic-gate /* 11687c478bd9Sstevel@tonic-gate * pool_get_owning_resource(3pool) wrapper 11697c478bd9Sstevel@tonic-gate */ 11707c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 11717c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 11727c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1owning_1resource( 11737c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jcomponent) { 1174*414388d7Ssl108498 return ((jlong)(uintptr_t)pool_get_owning_resource( 1175*414388d7Ssl108498 (pool_conf_t *)(uintptr_t)jconf, 1176*414388d7Ssl108498 (pool_component_t *)(uintptr_t)jcomponent)); 11777c478bd9Sstevel@tonic-gate } 11787c478bd9Sstevel@tonic-gate 11797c478bd9Sstevel@tonic-gate /* 11807c478bd9Sstevel@tonic-gate * pool_component_info(3pool) wrapper 11817c478bd9Sstevel@tonic-gate */ 11827c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 11837c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 11847c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1info( 11857c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jcomponent, jint jflags) { 11867c478bd9Sstevel@tonic-gate jstring jresult = NULL; 11877c478bd9Sstevel@tonic-gate const char *result; 11887c478bd9Sstevel@tonic-gate 1189*414388d7Ssl108498 result = pool_component_info((pool_conf_t *)(uintptr_t)jconf, 1190*414388d7Ssl108498 (pool_component_t *)(uintptr_t)jcomponent, (int)jflags); 11917c478bd9Sstevel@tonic-gate 11927c478bd9Sstevel@tonic-gate if (result) 11937c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 11947c478bd9Sstevel@tonic-gate free((void *)result); 11957c478bd9Sstevel@tonic-gate return (jresult); 11967c478bd9Sstevel@tonic-gate } 11977c478bd9Sstevel@tonic-gate 11987c478bd9Sstevel@tonic-gate /* 11997c478bd9Sstevel@tonic-gate * pool_get_property(3pool) wrapper 12007c478bd9Sstevel@tonic-gate */ 12017c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 12027c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 12037c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1property( 12047c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jelem, jstring jname, 12057c478bd9Sstevel@tonic-gate jlong jproperty) { 12067c478bd9Sstevel@tonic-gate const char *name; 12077c478bd9Sstevel@tonic-gate int result; 12087c478bd9Sstevel@tonic-gate 12097c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : 12107c478bd9Sstevel@tonic-gate NULL; 1211*414388d7Ssl108498 result = pool_get_property((pool_conf_t *)(uintptr_t)jconf, 1212*414388d7Ssl108498 (pool_elem_t *)(uintptr_t)jelem, name, 1213*414388d7Ssl108498 (pool_value_t *)(uintptr_t)jproperty); 12147c478bd9Sstevel@tonic-gate 12157c478bd9Sstevel@tonic-gate if (name) 12167c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 12177c478bd9Sstevel@tonic-gate return ((jint)result); 12187c478bd9Sstevel@tonic-gate } 12197c478bd9Sstevel@tonic-gate 12207c478bd9Sstevel@tonic-gate /* 12217c478bd9Sstevel@tonic-gate * pool_put_property(3pool) wrapper 12227c478bd9Sstevel@tonic-gate */ 12237c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 12247c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 12257c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1put_1property( 12267c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jelem, jstring jname, 12277c478bd9Sstevel@tonic-gate jlong jvalue) { 12287c478bd9Sstevel@tonic-gate const char *name; 12297c478bd9Sstevel@tonic-gate int result; 12307c478bd9Sstevel@tonic-gate 12317c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : NULL; 1232*414388d7Ssl108498 result = (int)pool_put_property((pool_conf_t *)(uintptr_t)jconf, 1233*414388d7Ssl108498 (pool_elem_t *)(uintptr_t)jelem, name, 1234*414388d7Ssl108498 (pool_value_t *)(uintptr_t)jvalue); 12357c478bd9Sstevel@tonic-gate 12367c478bd9Sstevel@tonic-gate if (name) 12377c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 12387c478bd9Sstevel@tonic-gate return ((jint)result); 12397c478bd9Sstevel@tonic-gate } 12407c478bd9Sstevel@tonic-gate 12417c478bd9Sstevel@tonic-gate /* 12427c478bd9Sstevel@tonic-gate * pool_rm_property(3pool) wrapper 12437c478bd9Sstevel@tonic-gate */ 12447c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 12457c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 12467c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1rm_1property(JNIEnv *jenv, 12477c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jlong jelem, jstring jname) { 12487c478bd9Sstevel@tonic-gate const char *name; 12497c478bd9Sstevel@tonic-gate int result; 12507c478bd9Sstevel@tonic-gate 12517c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : NULL; 1252*414388d7Ssl108498 result = pool_rm_property((pool_conf_t *)(uintptr_t)jconf, 1253*414388d7Ssl108498 (pool_elem_t *)(uintptr_t)jelem, name); 12547c478bd9Sstevel@tonic-gate 12557c478bd9Sstevel@tonic-gate if (name) 12567c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 12577c478bd9Sstevel@tonic-gate return ((jint)result); 12587c478bd9Sstevel@tonic-gate } 12597c478bd9Sstevel@tonic-gate 12607c478bd9Sstevel@tonic-gate /* 12617c478bd9Sstevel@tonic-gate * pool_walk_properties(3pool) wrapper 12627c478bd9Sstevel@tonic-gate */ 12637c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 12647c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 12657c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1properties( 12667c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jelem, jlong jarg, 12677c478bd9Sstevel@tonic-gate jlong jcallback) { 12687c478bd9Sstevel@tonic-gate int result; 12697c478bd9Sstevel@tonic-gate 1270*414388d7Ssl108498 result = (int)pool_walk_properties((pool_conf_t *)(uintptr_t)jconf, 1271*414388d7Ssl108498 (pool_elem_t *)(uintptr_t)jelem, (void *)(uintptr_t)jarg, 12727c478bd9Sstevel@tonic-gate (int (*)(pool_conf_t *, pool_elem_t *, char const *, 1273*414388d7Ssl108498 pool_value_t *, void *))(uintptr_t)jcallback); 12747c478bd9Sstevel@tonic-gate 12757c478bd9Sstevel@tonic-gate return ((jint)result); 12767c478bd9Sstevel@tonic-gate } 12777c478bd9Sstevel@tonic-gate 12787c478bd9Sstevel@tonic-gate /* 12797c478bd9Sstevel@tonic-gate * pool_conf_to_elem(3pool) wrapper 12807c478bd9Sstevel@tonic-gate */ 12817c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 12827c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 12837c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1to_1elem( 12847c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf) { 1285*414388d7Ssl108498 return ((jlong)(uintptr_t)pool_conf_to_elem( 1286*414388d7Ssl108498 (pool_conf_t *)(uintptr_t)jconf)); 12877c478bd9Sstevel@tonic-gate } 12887c478bd9Sstevel@tonic-gate 12897c478bd9Sstevel@tonic-gate /* 12907c478bd9Sstevel@tonic-gate * pool_to_elem(3pool) wrapper 12917c478bd9Sstevel@tonic-gate */ 12927c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 12937c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 12947c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1to_1elem(JNIEnv *jenv, 12957c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jlong jpool) { 1296*414388d7Ssl108498 return ((jlong)(uintptr_t)pool_to_elem((pool_conf_t *)(uintptr_t)jconf, 1297*414388d7Ssl108498 (pool_t *)(uintptr_t)jpool)); 12987c478bd9Sstevel@tonic-gate } 12997c478bd9Sstevel@tonic-gate 13007c478bd9Sstevel@tonic-gate /* 13017c478bd9Sstevel@tonic-gate * pool_resource_to_elem(3pool) wrapper 13027c478bd9Sstevel@tonic-gate */ 13037c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13047c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 13057c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1to_1elem( 13067c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource) { 1307*414388d7Ssl108498 return ((jlong)(uintptr_t)pool_resource_to_elem( 1308*414388d7Ssl108498 (pool_conf_t *)(uintptr_t)jconf, 1309*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jresource)); 13107c478bd9Sstevel@tonic-gate } 13117c478bd9Sstevel@tonic-gate 13127c478bd9Sstevel@tonic-gate /* 13137c478bd9Sstevel@tonic-gate * pool_component_to_elem(3pool) wrapper 13147c478bd9Sstevel@tonic-gate */ 13157c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13167c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 13177c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1to_1elem( 13187c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jcomponent) { 1319*414388d7Ssl108498 return ((jlong)(uintptr_t)pool_component_to_elem( 1320*414388d7Ssl108498 (pool_conf_t *)(uintptr_t)jconf, 1321*414388d7Ssl108498 (pool_component_t *)(uintptr_t)jcomponent)); 13227c478bd9Sstevel@tonic-gate } 13237c478bd9Sstevel@tonic-gate 13247c478bd9Sstevel@tonic-gate /* 13257c478bd9Sstevel@tonic-gate * pool_value_get_type(3pool) wrapper 13267c478bd9Sstevel@tonic-gate */ 13277c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13287c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 13297c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1type( 13307c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jvalue) { 1331*414388d7Ssl108498 return ((jint)pool_value_get_type((pool_value_t *)(uintptr_t)jvalue)); 13327c478bd9Sstevel@tonic-gate } 13337c478bd9Sstevel@tonic-gate 13347c478bd9Sstevel@tonic-gate /* 13357c478bd9Sstevel@tonic-gate * pool_value_set_uint64(3pool) wrapper 13367c478bd9Sstevel@tonic-gate */ 13377c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13387c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL 13397c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1uint64( 13407c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jvalue, jlong jui64) { 1341*414388d7Ssl108498 pool_value_set_uint64( 1342*414388d7Ssl108498 (pool_value_t *)(uintptr_t)jvalue, (uint64_t)jui64); 13437c478bd9Sstevel@tonic-gate } 13447c478bd9Sstevel@tonic-gate 13457c478bd9Sstevel@tonic-gate /* 13467c478bd9Sstevel@tonic-gate * pool_value_set_int64(3pool) wrapper 13477c478bd9Sstevel@tonic-gate */ 13487c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13497c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL 13507c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1int64( 13517c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jvalue, jlong ji64) { 1352*414388d7Ssl108498 pool_value_set_int64((pool_value_t *)(uintptr_t)jvalue, (int64_t)ji64); 13537c478bd9Sstevel@tonic-gate } 13547c478bd9Sstevel@tonic-gate 13557c478bd9Sstevel@tonic-gate /* 13567c478bd9Sstevel@tonic-gate * pool_value_set_double(3pool) wrapper 13577c478bd9Sstevel@tonic-gate */ 13587c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13597c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL 13607c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1double( 13617c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jvalue, jdouble jd) { 1362*414388d7Ssl108498 pool_value_set_double((pool_value_t *)(uintptr_t)jvalue, (double)jd); 13637c478bd9Sstevel@tonic-gate } 13647c478bd9Sstevel@tonic-gate 13657c478bd9Sstevel@tonic-gate /* 13667c478bd9Sstevel@tonic-gate * pool_value_set_bool(3pool) wrapper 13677c478bd9Sstevel@tonic-gate */ 13687c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13697c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL 13707c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1bool( 13717c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jvalue, jshort jb) { 1372*414388d7Ssl108498 pool_value_set_bool((pool_value_t *)(uintptr_t)jvalue, (uchar_t)jb); 13737c478bd9Sstevel@tonic-gate } 13747c478bd9Sstevel@tonic-gate 13757c478bd9Sstevel@tonic-gate /* 13767c478bd9Sstevel@tonic-gate * pool_value_set_string(3pool) wrapper 13777c478bd9Sstevel@tonic-gate */ 13787c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13797c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 13807c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1string( 13817c478bd9Sstevel@tonic-gate JNIEnv * jenv, jclass jcls, jlong jvalue, jstring jstr) { 13827c478bd9Sstevel@tonic-gate const char *str; 13837c478bd9Sstevel@tonic-gate int result; 13847c478bd9Sstevel@tonic-gate 13857c478bd9Sstevel@tonic-gate str = (jstr) ? (*jenv)->GetStringUTFChars(jenv, jstr, 0) : NULL; 1386*414388d7Ssl108498 result = pool_value_set_string((pool_value_t *)(uintptr_t)jvalue, str); 13877c478bd9Sstevel@tonic-gate 13887c478bd9Sstevel@tonic-gate if (str) 13897c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jstr, str); 13907c478bd9Sstevel@tonic-gate return ((jint)result); 13917c478bd9Sstevel@tonic-gate } 13927c478bd9Sstevel@tonic-gate 13937c478bd9Sstevel@tonic-gate /* 13947c478bd9Sstevel@tonic-gate * pool_value_get_name(3pool) wrapper 13957c478bd9Sstevel@tonic-gate */ 13967c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 13977c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 13987c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1name( 13997c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jvalue) { 14007c478bd9Sstevel@tonic-gate jstring jresult = NULL; 14017c478bd9Sstevel@tonic-gate const char *result; 14027c478bd9Sstevel@tonic-gate 1403*414388d7Ssl108498 result = pool_value_get_name((pool_value_t *)(uintptr_t)jvalue); 14047c478bd9Sstevel@tonic-gate 14057c478bd9Sstevel@tonic-gate if (result) 14067c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 14077c478bd9Sstevel@tonic-gate return (jresult); 14087c478bd9Sstevel@tonic-gate } 14097c478bd9Sstevel@tonic-gate 14107c478bd9Sstevel@tonic-gate /* 14117c478bd9Sstevel@tonic-gate * pool_value_set_name(3pool) wrapper 14127c478bd9Sstevel@tonic-gate */ 14137c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 14147c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 14157c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1name( 14167c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jvalue, jstring jname) { 14177c478bd9Sstevel@tonic-gate const char *name; 14187c478bd9Sstevel@tonic-gate int result; 14197c478bd9Sstevel@tonic-gate 14207c478bd9Sstevel@tonic-gate name = (jname) ? (*jenv)->GetStringUTFChars(jenv, jname, 0) : NULL; 1421*414388d7Ssl108498 result = pool_value_set_name((pool_value_t *)(uintptr_t)jvalue, name); 14227c478bd9Sstevel@tonic-gate 14237c478bd9Sstevel@tonic-gate if (name) 14247c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jname, name); 14257c478bd9Sstevel@tonic-gate return ((jint)result); 14267c478bd9Sstevel@tonic-gate } 14277c478bd9Sstevel@tonic-gate 14287c478bd9Sstevel@tonic-gate /* 14297c478bd9Sstevel@tonic-gate * pool_value_alloc(3pool) wrapper 14307c478bd9Sstevel@tonic-gate */ 14317c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 14327c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 14337c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1alloc(JNIEnv *jenv, 14347c478bd9Sstevel@tonic-gate jclass jcls) { 14357c478bd9Sstevel@tonic-gate return ((jlong)(uintptr_t)pool_value_alloc()); 14367c478bd9Sstevel@tonic-gate } 14377c478bd9Sstevel@tonic-gate 14387c478bd9Sstevel@tonic-gate /* 14397c478bd9Sstevel@tonic-gate * pool_value_free(3pool) wrapper 14407c478bd9Sstevel@tonic-gate */ 14417c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 14427c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL 14437c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1free(JNIEnv *jenv, 14447c478bd9Sstevel@tonic-gate jclass jcls, jlong jvalue) { 1445*414388d7Ssl108498 pool_value_free((pool_value_t *)(uintptr_t)jvalue); 14467c478bd9Sstevel@tonic-gate } 14477c478bd9Sstevel@tonic-gate 14487c478bd9Sstevel@tonic-gate /* 14497c478bd9Sstevel@tonic-gate * pool_static_location(3pool) wrapper 14507c478bd9Sstevel@tonic-gate */ 14517c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 14527c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 14537c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1static_1location( 14547c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls) { 14557c478bd9Sstevel@tonic-gate jstring jresult = NULL; 14567c478bd9Sstevel@tonic-gate const char *result; 14577c478bd9Sstevel@tonic-gate 14587c478bd9Sstevel@tonic-gate result = pool_static_location(); 14597c478bd9Sstevel@tonic-gate 14607c478bd9Sstevel@tonic-gate if (result) 14617c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 14627c478bd9Sstevel@tonic-gate return (jresult); 14637c478bd9Sstevel@tonic-gate } 14647c478bd9Sstevel@tonic-gate 14657c478bd9Sstevel@tonic-gate /* 14667c478bd9Sstevel@tonic-gate * pool_dynamic_location(3pool) wrapper 14677c478bd9Sstevel@tonic-gate */ 14687c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 14697c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 14707c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1dynamic_1location(JNIEnv * 14717c478bd9Sstevel@tonic-gate jenv, jclass jcls) { 14727c478bd9Sstevel@tonic-gate jstring jresult = NULL; 14737c478bd9Sstevel@tonic-gate const char *result; 14747c478bd9Sstevel@tonic-gate 14757c478bd9Sstevel@tonic-gate result = pool_dynamic_location(); 14767c478bd9Sstevel@tonic-gate 14777c478bd9Sstevel@tonic-gate if (result) 14787c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 14797c478bd9Sstevel@tonic-gate return (jresult); 14807c478bd9Sstevel@tonic-gate } 14817c478bd9Sstevel@tonic-gate 14827c478bd9Sstevel@tonic-gate /* 14837c478bd9Sstevel@tonic-gate * pool_set_binding(3pool) wrapper 14847c478bd9Sstevel@tonic-gate */ 14857c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 14867c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 14877c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1binding(JNIEnv *jenv, 14887c478bd9Sstevel@tonic-gate jclass jcls, jstring jpool, jint jidtype, jint jpid) { 14897c478bd9Sstevel@tonic-gate const char *pool; 14907c478bd9Sstevel@tonic-gate int result; 14917c478bd9Sstevel@tonic-gate 14927c478bd9Sstevel@tonic-gate pool = (jpool) ? (*jenv)->GetStringUTFChars(jenv, jpool, 0) : NULL; 14937c478bd9Sstevel@tonic-gate result = (int)pool_set_binding(pool, (idtype_t)jidtype, (id_t)jpid); 14947c478bd9Sstevel@tonic-gate 14957c478bd9Sstevel@tonic-gate if (pool) 14967c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jpool, pool); 14977c478bd9Sstevel@tonic-gate return ((jint)result); 14987c478bd9Sstevel@tonic-gate } 14997c478bd9Sstevel@tonic-gate 15007c478bd9Sstevel@tonic-gate /* 15017c478bd9Sstevel@tonic-gate * pool_get_binding(3pool) wrapper 15027c478bd9Sstevel@tonic-gate */ 15037c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 15047c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 15057c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1binding(JNIEnv *jenv, 15067c478bd9Sstevel@tonic-gate jclass jcls, jint jpid) { 15077c478bd9Sstevel@tonic-gate jstring jresult = NULL; 15087c478bd9Sstevel@tonic-gate const char *result; 15097c478bd9Sstevel@tonic-gate 15107c478bd9Sstevel@tonic-gate result = pool_get_binding((pid_t)jpid); 15117c478bd9Sstevel@tonic-gate 15127c478bd9Sstevel@tonic-gate if (result) 15137c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 15147c478bd9Sstevel@tonic-gate free((void *)result); 15157c478bd9Sstevel@tonic-gate return (jresult); 15167c478bd9Sstevel@tonic-gate } 15177c478bd9Sstevel@tonic-gate 15187c478bd9Sstevel@tonic-gate /* 15197c478bd9Sstevel@tonic-gate * pool_get_resource_binding(3pool) wrapper 15207c478bd9Sstevel@tonic-gate */ 15217c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 15227c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 15237c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource_1binding( 15247c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jstring jtype, jint jpid) { 15257c478bd9Sstevel@tonic-gate jstring jresult = NULL; 15267c478bd9Sstevel@tonic-gate const char *type; 15277c478bd9Sstevel@tonic-gate const char *result; 15287c478bd9Sstevel@tonic-gate 15297c478bd9Sstevel@tonic-gate type = (jtype) ? (*jenv)->GetStringUTFChars(jenv, jtype, 0) : NULL; 15307c478bd9Sstevel@tonic-gate result = pool_get_resource_binding(type, (pid_t)jpid); 15317c478bd9Sstevel@tonic-gate 15327c478bd9Sstevel@tonic-gate if (result) 15337c478bd9Sstevel@tonic-gate jresult = (*jenv)->NewStringUTF(jenv, result); 15347c478bd9Sstevel@tonic-gate free((void *)result); 15357c478bd9Sstevel@tonic-gate if (type) 15367c478bd9Sstevel@tonic-gate (*jenv)->ReleaseStringUTFChars(jenv, jtype, type); 15377c478bd9Sstevel@tonic-gate return (jresult); 15387c478bd9Sstevel@tonic-gate } 15397c478bd9Sstevel@tonic-gate 15407c478bd9Sstevel@tonic-gate /* 15417c478bd9Sstevel@tonic-gate * pool_walk_pools(3pool) wrapper 15427c478bd9Sstevel@tonic-gate */ 15437c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 15447c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 15457c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1pools(JNIEnv *jenv, 15467c478bd9Sstevel@tonic-gate jclass jcls, jlong jconf, jlong jarg, jlong jcallback) { 15477c478bd9Sstevel@tonic-gate int result; 15487c478bd9Sstevel@tonic-gate 1549*414388d7Ssl108498 result = pool_walk_pools((pool_conf_t *)(uintptr_t)jconf, 1550*414388d7Ssl108498 (void *)(uintptr_t)jarg, 1551*414388d7Ssl108498 (int (*)(pool_conf_t *, pool_t *, void *))(uintptr_t)jcallback); 15527c478bd9Sstevel@tonic-gate return ((jint)result); 15537c478bd9Sstevel@tonic-gate } 15547c478bd9Sstevel@tonic-gate 15557c478bd9Sstevel@tonic-gate /* 15567c478bd9Sstevel@tonic-gate * pool_walk_resources(3pool) wrapper 15577c478bd9Sstevel@tonic-gate */ 15587c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 15597c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 15607c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1resources( 15617c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jpool, jlong jarg, 15627c478bd9Sstevel@tonic-gate jlong jcallback) { 15637c478bd9Sstevel@tonic-gate int result; 15647c478bd9Sstevel@tonic-gate 1565*414388d7Ssl108498 result = pool_walk_resources((pool_conf_t *)(uintptr_t)jconf, 1566*414388d7Ssl108498 (pool_t *)(uintptr_t)jpool, (void *)(uintptr_t)jarg, 1567*414388d7Ssl108498 (int (*)(pool_conf_t *, pool_resource_t *, void *)) 1568*414388d7Ssl108498 (uintptr_t)jcallback); 15697c478bd9Sstevel@tonic-gate return ((jint)result); 15707c478bd9Sstevel@tonic-gate } 15717c478bd9Sstevel@tonic-gate 15727c478bd9Sstevel@tonic-gate /* 15737c478bd9Sstevel@tonic-gate * pool_walk_components(3pool) wrapper 15747c478bd9Sstevel@tonic-gate */ 15757c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 15767c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 15777c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1components( 15787c478bd9Sstevel@tonic-gate JNIEnv *jenv, jclass jcls, jlong jconf, jlong jresource, jlong jarg, 15797c478bd9Sstevel@tonic-gate jlong jcallback) { 15807c478bd9Sstevel@tonic-gate int result; 15817c478bd9Sstevel@tonic-gate 1582*414388d7Ssl108498 result = pool_walk_components((pool_conf_t *)(uintptr_t)jconf, 1583*414388d7Ssl108498 (pool_resource_t *)(uintptr_t)jresource, (void *)(uintptr_t)jarg, 1584*414388d7Ssl108498 (int (*)(pool_conf_t *, pool_component_t *, void *)) 1585*414388d7Ssl108498 (uintptr_t)jcallback); 15867c478bd9Sstevel@tonic-gate return ((jint)result); 15877c478bd9Sstevel@tonic-gate } 15887c478bd9Sstevel@tonic-gate 15897c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 15907c478bd9Sstevel@tonic-gate JNIEXPORT jint JNICALL 15917c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Element_walkProps(JNIEnv *env, 15927c478bd9Sstevel@tonic-gate jobject obj, jlong conf, jlong elem, jobject handler, jobject userobj) 15937c478bd9Sstevel@tonic-gate { 15947c478bd9Sstevel@tonic-gate struct pool_callback pc; 15957c478bd9Sstevel@tonic-gate 15967c478bd9Sstevel@tonic-gate pc.pc_user = userobj; 15977c478bd9Sstevel@tonic-gate pc.pc_handler = handler; 15987c478bd9Sstevel@tonic-gate pc.pc_elem = obj; 15997c478bd9Sstevel@tonic-gate pc.pc_env = env; 16007c478bd9Sstevel@tonic-gate return (pool_walk_properties((pool_conf_t *)*(void**)&conf, 16017c478bd9Sstevel@tonic-gate (pool_elem_t *)*(void**)&elem, (void *)&pc, pool_property_walker)); 16027c478bd9Sstevel@tonic-gate } 16037c478bd9Sstevel@tonic-gate 16047c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 16057c478bd9Sstevel@tonic-gate static int 16067c478bd9Sstevel@tonic-gate pool_property_walker(pool_conf_t *conf, pool_elem_t *pe, const char *name, 16077c478bd9Sstevel@tonic-gate pool_value_t *pv, void *user) 16087c478bd9Sstevel@tonic-gate { 16097c478bd9Sstevel@tonic-gate jclass clazz, vclazz; 16107c478bd9Sstevel@tonic-gate jmethodID mgetwalk, mvcon; 16117c478bd9Sstevel@tonic-gate struct pool_callback *pc = (struct pool_callback *)user; 16127c478bd9Sstevel@tonic-gate jobject valueObj; 16137c478bd9Sstevel@tonic-gate pool_value_t *pv_new; 16147c478bd9Sstevel@tonic-gate uint64_t uval; 16157c478bd9Sstevel@tonic-gate int64_t ival; 16167c478bd9Sstevel@tonic-gate double dval; 16177c478bd9Sstevel@tonic-gate uchar_t bval; 16187c478bd9Sstevel@tonic-gate const char *sval; 16197c478bd9Sstevel@tonic-gate 16207c478bd9Sstevel@tonic-gate /* 16217c478bd9Sstevel@tonic-gate * Since we intend to embed our value into a Java Value object 16227c478bd9Sstevel@tonic-gate * and then reclaim the value when the object is garbage 16237c478bd9Sstevel@tonic-gate * collected we must create a new pool value and then pass this 16247c478bd9Sstevel@tonic-gate * to the constructor. We must not use the pool value which is 16257c478bd9Sstevel@tonic-gate * passed to us. 16267c478bd9Sstevel@tonic-gate */ 16277c478bd9Sstevel@tonic-gate 16287c478bd9Sstevel@tonic-gate if ((pv_new = pool_value_alloc()) == NULL) 16297c478bd9Sstevel@tonic-gate return (PO_FAIL); 16307c478bd9Sstevel@tonic-gate switch (pool_value_get_type(pv)) { 16317c478bd9Sstevel@tonic-gate case POC_UINT: 16327c478bd9Sstevel@tonic-gate (void) pool_value_get_uint64(pv, &uval); 16337c478bd9Sstevel@tonic-gate (void) pool_value_set_uint64(pv_new, uval); 16347c478bd9Sstevel@tonic-gate break; 16357c478bd9Sstevel@tonic-gate case POC_INT: 16367c478bd9Sstevel@tonic-gate (void) pool_value_get_int64(pv, &ival); 16377c478bd9Sstevel@tonic-gate (void) pool_value_set_int64(pv_new, ival); 16387c478bd9Sstevel@tonic-gate break; 16397c478bd9Sstevel@tonic-gate case POC_DOUBLE: 16407c478bd9Sstevel@tonic-gate (void) pool_value_get_double(pv, &dval); 16417c478bd9Sstevel@tonic-gate (void) pool_value_set_double(pv_new, dval); 16427c478bd9Sstevel@tonic-gate break; 16437c478bd9Sstevel@tonic-gate case POC_BOOL: 16447c478bd9Sstevel@tonic-gate (void) pool_value_get_bool(pv, &bval); 16457c478bd9Sstevel@tonic-gate (void) pool_value_set_bool(pv_new, bval); 16467c478bd9Sstevel@tonic-gate break; 16477c478bd9Sstevel@tonic-gate case POC_STRING: 16487c478bd9Sstevel@tonic-gate (void) pool_value_get_string(pv, &sval); 16497c478bd9Sstevel@tonic-gate (void) pool_value_set_string(pv_new, sval); 16507c478bd9Sstevel@tonic-gate break; 16517c478bd9Sstevel@tonic-gate default: 16527c478bd9Sstevel@tonic-gate pool_value_free(pv_new); 16537c478bd9Sstevel@tonic-gate return (PO_FAIL); 16547c478bd9Sstevel@tonic-gate } 16557c478bd9Sstevel@tonic-gate if (pool_value_set_name(pv_new, name) != PO_SUCCESS || 16567c478bd9Sstevel@tonic-gate (vclazz = (*pc->pc_env)->FindClass(pc->pc_env, 16577c478bd9Sstevel@tonic-gate "com/sun/solaris/service/pools/Value")) == NULL || 16587c478bd9Sstevel@tonic-gate (mvcon = (*pc->pc_env)->GetMethodID(pc->pc_env, vclazz, 16597c478bd9Sstevel@tonic-gate "<init>", "(J)V")) == NULL || 16607c478bd9Sstevel@tonic-gate (valueObj = (*pc->pc_env)->NewObject(pc->pc_env, vclazz, mvcon, 16617c478bd9Sstevel@tonic-gate pv_new)) == NULL || 16627c478bd9Sstevel@tonic-gate (clazz = (*pc->pc_env)->GetObjectClass(pc->pc_env, pc->pc_handler)) 16637c478bd9Sstevel@tonic-gate == NULL || 16647c478bd9Sstevel@tonic-gate (mgetwalk = (*pc->pc_env)->GetMethodID(pc->pc_env, 16657c478bd9Sstevel@tonic-gate clazz, "walk", 16667c478bd9Sstevel@tonic-gate "(Lcom/sun/solaris/service/pools/Element;Lcom/sun/solaris/" 16677c478bd9Sstevel@tonic-gate "service/pools/Value;Ljava/lang/Object;)I")) == NULL) 16687c478bd9Sstevel@tonic-gate return (PO_FAIL); 16697c478bd9Sstevel@tonic-gate return ((*pc->pc_env)->CallIntMethod(pc->pc_env, 16707c478bd9Sstevel@tonic-gate pc->pc_handler, mgetwalk, pc->pc_elem, valueObj, pc->pc_user)); 16717c478bd9Sstevel@tonic-gate } 16727c478bd9Sstevel@tonic-gate 16737c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 16747c478bd9Sstevel@tonic-gate JNIEXPORT jlong JNICALL 16757c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getLongValue(JNIEnv *jenv, 16767c478bd9Sstevel@tonic-gate jclass class, jlong pointer) 16777c478bd9Sstevel@tonic-gate { 16787c478bd9Sstevel@tonic-gate int64_t arg2; 16797c478bd9Sstevel@tonic-gate int result; 16807c478bd9Sstevel@tonic-gate 1681*414388d7Ssl108498 result = 1682*414388d7Ssl108498 pool_value_get_int64((pool_value_t *)(uintptr_t)pointer, &arg2); 16837c478bd9Sstevel@tonic-gate 16847c478bd9Sstevel@tonic-gate if (result != PO_SUCCESS) { /* it could be a uint64 */ 1685*414388d7Ssl108498 result = 1686*414388d7Ssl108498 pool_value_get_uint64((pool_value_t *)(uintptr_t)pointer, 16877c478bd9Sstevel@tonic-gate (uint64_t *)&arg2); 16887c478bd9Sstevel@tonic-gate if (result != PO_SUCCESS) { 16897c478bd9Sstevel@tonic-gate throw_pe(jenv); 16907c478bd9Sstevel@tonic-gate } 16917c478bd9Sstevel@tonic-gate /* 16927c478bd9Sstevel@tonic-gate * Unfortunately, Java has no unsigned types, so we lose some 16937c478bd9Sstevel@tonic-gate * precision by forcing the top bit clear 16947c478bd9Sstevel@tonic-gate */ 1695*414388d7Ssl108498 arg2 &= 0x7fffffffffffffffULL; 16967c478bd9Sstevel@tonic-gate } 16977c478bd9Sstevel@tonic-gate return ((jlong)arg2); 16987c478bd9Sstevel@tonic-gate } 16997c478bd9Sstevel@tonic-gate 17007c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 17017c478bd9Sstevel@tonic-gate JNIEXPORT jstring JNICALL 17027c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getStringValue(JNIEnv *jenv, 17037c478bd9Sstevel@tonic-gate jclass class, jlong pointer) 17047c478bd9Sstevel@tonic-gate { 17057c478bd9Sstevel@tonic-gate const char *arg2; 17067c478bd9Sstevel@tonic-gate int result; 17077c478bd9Sstevel@tonic-gate 1708*414388d7Ssl108498 result = 1709*414388d7Ssl108498 pool_value_get_string((pool_value_t *)(uintptr_t)pointer, &arg2); 17107c478bd9Sstevel@tonic-gate if (result != PO_SUCCESS) 17117c478bd9Sstevel@tonic-gate throw_pe(jenv); 17127c478bd9Sstevel@tonic-gate return ((*jenv)->NewStringUTF(jenv, arg2)); 17137c478bd9Sstevel@tonic-gate } 17147c478bd9Sstevel@tonic-gate 17157c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 17167c478bd9Sstevel@tonic-gate JNIEXPORT jboolean JNICALL 17177c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getBoolValue(JNIEnv *jenv, 17187c478bd9Sstevel@tonic-gate jclass class, jlong pointer) 17197c478bd9Sstevel@tonic-gate { 17207c478bd9Sstevel@tonic-gate uchar_t arg2; 17217c478bd9Sstevel@tonic-gate int result; 17227c478bd9Sstevel@tonic-gate 1723*414388d7Ssl108498 result = pool_value_get_bool((pool_value_t *)(uintptr_t)pointer, &arg2); 17247c478bd9Sstevel@tonic-gate 17257c478bd9Sstevel@tonic-gate if (result != PO_SUCCESS) { 17267c478bd9Sstevel@tonic-gate throw_pe(jenv); 17277c478bd9Sstevel@tonic-gate } 17287c478bd9Sstevel@tonic-gate if (arg2 == PO_TRUE) 17297c478bd9Sstevel@tonic-gate return (JNI_TRUE); 17307c478bd9Sstevel@tonic-gate else 17317c478bd9Sstevel@tonic-gate return (JNI_FALSE); 17327c478bd9Sstevel@tonic-gate } 17337c478bd9Sstevel@tonic-gate 17347c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 17357c478bd9Sstevel@tonic-gate JNIEXPORT jdouble JNICALL 17367c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getDoubleValue(JNIEnv *jenv, 17377c478bd9Sstevel@tonic-gate jclass class, jlong pointer) 17387c478bd9Sstevel@tonic-gate { 17397c478bd9Sstevel@tonic-gate double arg2; 17407c478bd9Sstevel@tonic-gate int result; 17417c478bd9Sstevel@tonic-gate 1742*414388d7Ssl108498 result = 1743*414388d7Ssl108498 pool_value_get_double((pool_value_t *)(uintptr_t)pointer, &arg2); 17447c478bd9Sstevel@tonic-gate 17457c478bd9Sstevel@tonic-gate if (result != PO_SUCCESS) { 17467c478bd9Sstevel@tonic-gate throw_pe(jenv); 17477c478bd9Sstevel@tonic-gate } 17487c478bd9Sstevel@tonic-gate return ((jdouble)arg2); 17497c478bd9Sstevel@tonic-gate } 17507c478bd9Sstevel@tonic-gate 17517c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 17527c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL 17537c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_Value_getUnsignedInt64Value(JNIEnv *jenv, 17547c478bd9Sstevel@tonic-gate jclass class, jlong pointer) 17557c478bd9Sstevel@tonic-gate { 17567c478bd9Sstevel@tonic-gate uint64_t arg2; 17577c478bd9Sstevel@tonic-gate int result; 17587c478bd9Sstevel@tonic-gate 1759*414388d7Ssl108498 result = 1760*414388d7Ssl108498 pool_value_get_uint64((pool_value_t *)(uintptr_t)pointer, &arg2); 17617c478bd9Sstevel@tonic-gate 17627c478bd9Sstevel@tonic-gate if (result != PO_SUCCESS) { 17637c478bd9Sstevel@tonic-gate throw_pe(jenv); 17647c478bd9Sstevel@tonic-gate } 17657c478bd9Sstevel@tonic-gate return (makeUnsignedInt64(jenv, arg2)); 17667c478bd9Sstevel@tonic-gate } 17677c478bd9Sstevel@tonic-gate 17687c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 17697c478bd9Sstevel@tonic-gate JNIEXPORT jobject JNICALL 17707c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_HRTime_timestamp(JNIEnv *env, jobject obj) 17717c478bd9Sstevel@tonic-gate { 17727c478bd9Sstevel@tonic-gate return (makeUnsignedInt64(env, gethrtime())); 17737c478bd9Sstevel@tonic-gate } 17747c478bd9Sstevel@tonic-gate 17757c478bd9Sstevel@tonic-gate /* 17767c478bd9Sstevel@tonic-gate * Cache class, method, and field IDs. 17777c478bd9Sstevel@tonic-gate */ 17787c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 17797c478bd9Sstevel@tonic-gate JNIEXPORT void JNICALL 17807c478bd9Sstevel@tonic-gate Java_com_sun_solaris_service_pools_PoolInternal_init(JNIEnv *env, jclass clazz) 17817c478bd9Sstevel@tonic-gate { 17827c478bd9Sstevel@tonic-gate jclass ui64class_lref; 17837c478bd9Sstevel@tonic-gate 17847c478bd9Sstevel@tonic-gate if (!(ui64class_lref = (*env)->FindClass(env, 17857c478bd9Sstevel@tonic-gate "com/sun/solaris/service/pools/UnsignedInt64"))) 17867c478bd9Sstevel@tonic-gate return; /* exception thrown */ 17877c478bd9Sstevel@tonic-gate if (!(ui64class = (*env)->NewGlobalRef(env, ui64class_lref))) 17887c478bd9Sstevel@tonic-gate return; /* exception thrown */ 17897c478bd9Sstevel@tonic-gate ui64cons_mid = (*env)->GetMethodID(env, ui64class, "<init>", "([B)V"); 17907c478bd9Sstevel@tonic-gate } 1791