4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
39 struct pool_callback
{
46 static void throwException(JNIEnv
*, const char *, const char *);
47 static void throw_pe(JNIEnv
*);
48 static jobject
makeUnsignedInt64(JNIEnv
*, uint64_t);
49 static int pool_property_walker(pool_conf_t
*, pool_elem_t
*p
, const char *,
50 pool_value_t
*, void *);
51 static jobject
copyArray(JNIEnv
*, void **);
54 * Cached class, method, and field IDs.
56 static jclass ui64class
;
57 static jmethodID ui64cons_mid
;
60 * Throw an exception of the specified class with the specified message.
63 throwException(JNIEnv
*env
, const char *class, const char *msg
)
67 clazz
= (*env
)->FindClass(env
, class);
69 (*env
)->ThrowNew(env
, clazz
, msg
);
73 * Throw a PoolsException.
76 throw_pe(JNIEnv
*jenv
)
82 clazz
= (*jenv
)->FindClass(jenv
,
83 "com/sun/solaris/service/pools/PoolsException");
84 mid
= (*jenv
)->GetMethodID(jenv
, clazz
, "<init>", "()V");
85 throwObj
= (*jenv
)->NewObject(jenv
, clazz
, mid
);
86 (*jenv
)->Throw(jenv
, throwObj
);
90 * Return an instance of an UnsignedInt64 class which encapsulates the
94 makeUnsignedInt64(JNIEnv
*env
, uint64_t value
)
101 if (!(byteArray
= (*env
)->NewByteArray(env
, 9)))
102 return (NULL
); /* OutOfMemoryError thrown */
103 if (!(bytes
= (*env
)->GetByteArrayElements(env
, byteArray
, NULL
)))
104 return (NULL
); /* OutOfMemoryError thrown */
107 * Interpret the uint64_t as a 9-byte big-endian signed quantity
108 * suitable for constructing an UnsignedInt64 or BigInteger.
110 for (i
= 8; i
>= 1; i
--) {
111 bytes
[i
] = value
& 0xff;
115 (*env
)->ReleaseByteArrayElements(env
, byteArray
, bytes
, 0);
117 if (!(valueObj
= (*env
)->NewObject(env
, ui64class
, ui64cons_mid
,
119 return (NULL
); /* exception thrown */
125 * Create an array list and then copy the native array into it
128 copyArray(JNIEnv
*jenv
, void **nativeArray
)
131 jobject jresult
= NULL
;
133 if (nativeArray
!= NULL
) {
135 jmethodID ALinit
, ALadd
;
139 ALclazz
= (*jenv
)->FindClass(jenv
,
140 "java/util/ArrayList");
141 ALinit
= (*jenv
)->GetMethodID(jenv
,
142 ALclazz
, "<init>", "()V");
143 ALadd
= (*jenv
)->GetMethodID(jenv
,
144 ALclazz
, "add", "(Ljava/lang/Object;)Z");
145 jresult
= (*jenv
)->NewObject(jenv
, ALclazz
, ALinit
);
146 Lclazz
= (*jenv
)->FindClass(jenv
, "java/lang/Long");
147 Linit
= (*jenv
)->GetMethodID(jenv
,
148 Lclazz
, "<init>", "(J)V");
149 for (i
= 0; nativeArray
[i
] != NULL
; i
++) {
151 /* Build longs and add them */
152 L
= (*jenv
)->NewObject(jenv
,
153 Lclazz
, Linit
, (jlong
)(uintptr_t)nativeArray
[i
]);
154 (*jenv
)->CallBooleanMethod(jenv
,
163 * pool_version(3pool) wrapper
166 JNIEXPORT jlong JNICALL
167 Java_com_sun_solaris_service_pools_PoolInternal_pool_1version(JNIEnv
*jenv
,
168 jclass jcls
, jlong jver
) {
169 return ((jlong
)pool_version((uint_t
)jver
));
173 * native constant accessor
176 JNIEXPORT jint JNICALL
177 Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1NATIVE(JNIEnv
*jenv
,
179 return ((jint
)POX_NATIVE
);
183 * native constant accessor
186 JNIEXPORT jint JNICALL
187 Java_com_sun_solaris_service_pools_PoolInternal_get_1POX_1TEXT(JNIEnv
*jenv
,
189 return ((jint
)POX_TEXT
);
193 * native constant accessor
196 JNIEXPORT jint JNICALL
197 Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INVAL(JNIEnv
*jenv
,
199 return ((jint
)POC_INVAL
);
203 * native constant accessor
206 JNIEXPORT jint JNICALL
207 Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1UINT(JNIEnv
*jenv
,
209 return ((jint
)POC_UINT
);
213 * native constant accessor
216 JNIEXPORT jint JNICALL
217 Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1INT(JNIEnv
*jenv
,
219 return ((jint
)POC_INT
);
223 * native constant accessor
226 JNIEXPORT jint JNICALL
227 Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1DOUBLE(JNIEnv
*jenv
,
229 return ((jint
)POC_DOUBLE
);
233 * native constant accessor
236 JNIEXPORT jint JNICALL
237 Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1BOOL(JNIEnv
*jenv
,
239 return ((jint
)POC_BOOL
);
243 * native constant accessor
246 JNIEXPORT jint JNICALL
247 Java_com_sun_solaris_service_pools_PoolInternal_get_1POC_1STRING(JNIEnv
*jenv
,
249 return ((jint
)POC_STRING
);
253 * native constant accessor
256 JNIEXPORT jint JNICALL
257 Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1NONE(JNIEnv
*jenv
,
259 return ((jint
)POV_NONE
);
263 * native constant accessor
266 JNIEXPORT jint JNICALL
267 Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1LOOSE(JNIEnv
*jenv
,
269 return ((jint
)POV_LOOSE
);
273 * native constant accessor
276 JNIEXPORT jint JNICALL
277 Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1STRICT(JNIEnv
*jenv
,
279 return ((jint
)POV_STRICT
);
283 * native constant accessor
286 JNIEXPORT jint JNICALL
287 Java_com_sun_solaris_service_pools_PoolInternal_get_1POV_1RUNTIME(JNIEnv
*jenv
,
289 return ((jint
)POV_RUNTIME
);
293 * native constant accessor
296 JNIEXPORT jint JNICALL
297 Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1INVALID(JNIEnv
*jenv
,
299 return ((jint
)POF_INVALID
);
303 * native constant accessor
306 JNIEXPORT jint JNICALL
307 Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1VALID(JNIEnv
*jenv
,
309 return ((jint
)POF_VALID
);
313 * native constant accessor
316 JNIEXPORT jint JNICALL
317 Java_com_sun_solaris_service_pools_PoolInternal_get_1POF_1DESTROY(JNIEnv
*jenv
,
319 return ((jint
)POF_DESTROY
);
323 * pool_error(3pool) wrapper
326 JNIEXPORT jint JNICALL
327 Java_com_sun_solaris_service_pools_PoolInternal_pool_1error(JNIEnv
*jenv
,
329 return ((jint
)pool_error());
333 * pool_strerror(3pool) wrapper
336 JNIEXPORT jstring JNICALL
337 Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror(JNIEnv
*jenv
,
338 jclass jcls
, jint jperr
) {
339 jstring jresult
= NULL
;
342 result
= (char *)pool_strerror((int)jperr
);
345 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
350 * strerror(3c) wrapper
353 JNIEXPORT jstring JNICALL
354 Java_com_sun_solaris_service_pools_PoolInternal_pool_1strerror_1sys(JNIEnv
*
356 jstring jresult
= NULL
;
359 result
= (char *)strerror(errno
);
362 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
370 JNIEXPORT jint JNICALL
371 Java_com_sun_solaris_service_pools_PoolsException_getErrno(JNIEnv
*jenv
,
373 return ((jint
)errno
);
377 * pool_resource_type_list(3pool) wrapper
380 JNIEXPORT jint JNICALL
381 Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1type_1list(
382 JNIEnv
*jenv
, jclass jcls
, jlong jreslist
, jlong jnumres
) {
383 char **reslist
= (char **)(uintptr_t)jreslist
;
384 uint_t
*numres
= (uint_t
*)(uintptr_t)jnumres
;
386 return ((jint
)pool_resource_type_list((char const **)reslist
, numres
));
390 * pool_get_status(3pool) wrapper
393 JNIEXPORT jint JNICALL
394 Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1status(JNIEnv
*jenv
,
399 err
= pool_get_status(&status
);
401 return ((jint
)PO_FAIL
);
403 return ((jint
)status
);
407 * pool_set_status(3pool) wrapper
410 JNIEXPORT jint JNICALL
411 Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1status(JNIEnv
*jenv
,
412 jclass jcls
, jint jstate
) {
413 return ((jint
)pool_set_status((int)jstate
));
417 * pool_conf_alloc(3pool) wrapper
420 JNIEXPORT jlong JNICALL
421 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1alloc(JNIEnv
*jenv
,
423 return ((jlong
)(uintptr_t)pool_conf_alloc());
427 * pool_conf_free(3pool) wrapper
430 JNIEXPORT
void JNICALL
431 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1free(JNIEnv
*jenv
,
432 jclass jcls
, jlong jconf
) {
433 pool_conf_free((pool_conf_t
*)(uintptr_t)jconf
);
437 * pool_conf_status(3pool) wrapper
440 JNIEXPORT jint JNICALL
441 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1status(JNIEnv
*jenv
,
442 jclass jcls
, jlong jconf
) {
443 return ((jint
)pool_conf_status((pool_conf_t
*)(uintptr_t)jconf
));
447 * pool_conf_close(3pool) wrapper
450 JNIEXPORT jint JNICALL
451 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1close(JNIEnv
*jenv
,
452 jclass jcls
, jlong jconf
) {
453 return ((jint
)pool_conf_close((pool_conf_t
*)(uintptr_t)jconf
));
457 * pool_conf_remove(3pool) wrapper
460 JNIEXPORT jint JNICALL
461 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1remove(JNIEnv
*jenv
,
462 jclass jcls
, jlong jconf
) {
463 return ((jint
)pool_conf_remove((pool_conf_t
*)(uintptr_t)jconf
));
467 * pool_conf_open(3pool) wrapper
470 JNIEXPORT jint JNICALL
471 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1open(JNIEnv
*jenv
,
472 jclass jcls
, jlong jconf
, jstring jlocation
, jint jflags
) {
473 const char *location
;
476 location
= (jlocation
) ? (*jenv
)->GetStringUTFChars(jenv
,
477 jlocation
, 0) : NULL
;
478 result
= (int)pool_conf_open((pool_conf_t
*)(uintptr_t)jconf
, location
,
482 (*jenv
)->ReleaseStringUTFChars(jenv
, jlocation
, location
);
483 return ((jint
)result
);
487 * pool_conf_rollback(3pool) wrapper
490 JNIEXPORT jint JNICALL
491 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1rollback(
492 JNIEnv
*jenv
, jclass jcls
, jlong jconf
) {
493 return ((jint
)pool_conf_rollback((pool_conf_t
*)(uintptr_t)jconf
));
497 * pool_conf_commit(3pool) wrapper
500 JNIEXPORT jint JNICALL
501 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1commit(JNIEnv
*jenv
,
502 jclass jcls
, jlong jconf
, jint jactive
) {
503 return ((jint
)pool_conf_commit(
504 (pool_conf_t
*)(uintptr_t)jconf
, (int)jactive
));
508 * pool_conf_export(3pool) wrapper
511 JNIEXPORT jint JNICALL
512 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1export(JNIEnv
*jenv
,
513 jclass jcls
, jlong jconf
, jstring jlocation
, jint jformat
) {
514 const char *location
;
517 location
= (jlocation
) ? (*jenv
)->GetStringUTFChars(jenv
,
518 jlocation
, 0) : NULL
;
519 result
= (int)pool_conf_export((pool_conf_t
*)(uintptr_t)jconf
,
520 location
, (pool_export_format_t
)jformat
);
523 (*jenv
)->ReleaseStringUTFChars(jenv
, jlocation
, location
);
524 return ((jint
)result
);
528 * pool_conf_validate(3pool) wrapper
531 JNIEXPORT jint JNICALL
532 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1validate(
533 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jint jlevel
) {
534 return ((jint
)pool_conf_validate((pool_conf_t
*)(uintptr_t)jconf
,
535 (pool_valid_level_t
)jlevel
));
539 * pool_conf_update(3pool) wrapper
542 JNIEXPORT jint JNICALL
543 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1update(JNIEnv
*jenv
,
544 jclass jcls
, jlong jconf
) {
548 result
= pool_conf_update((pool_conf_t
*)(uintptr_t)jconf
, &changed
);
550 if (result
!= PO_SUCCESS
) {
554 return ((jint
)changed
);
558 * pool_get_pool(3pool) wrapper
561 JNIEXPORT jlong JNICALL
562 Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1pool(JNIEnv
*jenv
,
563 jclass jcls
, jlong jconf
, jstring jname
) {
567 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) :
569 result
= (pool_t
*)pool_get_pool((pool_conf_t
*)(uintptr_t)jconf
, name
);
572 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
573 return ((jlong
)(uintptr_t)result
);
577 * pool_query_pools(3pool) wrapper
580 JNIEXPORT jobject JNICALL
581 Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pools(JNIEnv
*jenv
,
582 jclass jcls
, jlong jconf
, jobject jprops
) {
583 pool_value_t
**props
;
593 * Initialize the target parameter for case when input is null
596 if (jprops
!= NULL
) {
597 Lclazz
= (*jenv
)->GetObjectClass(jenv
, jprops
);
598 Lsize
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "size", "()I");
599 size
= (*jenv
)->CallIntMethod(jenv
, jprops
, Lsize
);
604 Lget
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "get",
605 "(I)Ljava/lang/Object;");
607 * Allocate space for the props array
610 if ((props
= calloc(size
+ 1, sizeof (pool_value_t
*)))
612 throwException(jenv
, "java/lang/Exception",
613 "Could not allocate props array");
619 for (i
= 0; i
< size
; i
++) {
625 aVal
= (*jenv
)->CallObjectMethod(jenv
, jprops
,
627 Vclazz
= (*jenv
)->GetObjectClass(jenv
, aVal
);
628 Vthis
= (*jenv
)->GetFieldID(jenv
, Vclazz
,
630 this = (*jenv
)->GetLongField(jenv
, aVal
, Vthis
);
631 props
[i
] = (pool_value_t
*)(uintptr_t)this;
635 result
= pool_query_pools((pool_conf_t
*)(uintptr_t)jconf
, &nelem
,
638 return (copyArray(jenv
, (void **)result
));
642 * pool_get_resource(3pool) wrapper
645 JNIEXPORT jlong JNICALL
646 Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource(
647 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jstring jtype
, jstring jname
) {
650 pool_resource_t
*result
;
652 type
= (jtype
) ? (*jenv
)->GetStringUTFChars(jenv
, jtype
, 0) :
654 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) :
656 result
= pool_get_resource((pool_conf_t
*)(uintptr_t)jconf
, type
, name
);
659 (*jenv
)->ReleaseStringUTFChars(jenv
, jtype
, type
);
661 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
662 return ((jlong
)(uintptr_t)result
);
666 * pool_query_resources(3pool) wrapper
669 JNIEXPORT jobject JNICALL
670 Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resources(
671 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jobject jprops
) {
672 pool_value_t
**props
;
673 pool_resource_t
**result
;
681 * Initialize the target parameter for case when input is null
684 if (jprops
!= NULL
) {
685 Lclazz
= (*jenv
)->GetObjectClass(jenv
, jprops
);
686 Lsize
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "size", "()I");
687 size
= (*jenv
)->CallIntMethod(jenv
, jprops
, Lsize
);
692 Lget
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "get",
693 "(I)Ljava/lang/Object;");
695 * Allocate space for the props array
697 if ((props
= calloc(size
+ 1, sizeof (pool_value_t
*)))
699 throwException(jenv
, "java/lang/Exception",
700 "Could not allocate props array");
706 for (i
= 0; i
< size
; i
++) {
713 aVal
= (*jenv
)->CallObjectMethod(jenv
, jprops
,
715 Vclazz
= (*jenv
)->GetObjectClass(jenv
, aVal
);
716 Vthis
= (*jenv
)->GetFieldID(jenv
, Vclazz
,
718 this = (*jenv
)->GetLongField(jenv
, aVal
, Vthis
);
719 props
[i
] = (pool_value_t
*)(uintptr_t)this;
723 result
= pool_query_resources((pool_conf_t
*)(uintptr_t)jconf
, &nelem
,
726 return (copyArray(jenv
, (void *)result
));
730 * pool_query_components(3pool) wrapper
733 JNIEXPORT jobject JNICALL
734 Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1components(
735 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jobject jprops
) {
736 pool_value_t
**props
;
737 pool_component_t
**result
;
745 * Initialize the target parameter for case when input is null
748 if (jprops
!= NULL
) {
749 Lclazz
= (*jenv
)->GetObjectClass(jenv
, jprops
);
750 Lsize
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "size", "()I");
751 size
= (*jenv
)->CallIntMethod(jenv
, jprops
, Lsize
);
756 Lget
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "get",
757 "(I)Ljava/lang/Object;");
759 * Allocate space for the props array
762 if ((props
= calloc(size
+ 1, sizeof (pool_value_t
*)))
764 throwException(jenv
, "java/lang/Exception",
765 "Could not allocate props array");
771 for (i
= 0; i
< size
; i
++) {
777 aVal
= (*jenv
)->CallObjectMethod(jenv
, jprops
,
779 Vclazz
= (*jenv
)->GetObjectClass(jenv
, aVal
);
780 Vthis
= (*jenv
)->GetFieldID(jenv
, Vclazz
,
782 this = (*jenv
)->GetLongField(jenv
, aVal
, Vthis
);
783 props
[i
] = (pool_value_t
*)(uintptr_t)this;
787 result
= pool_query_components((pool_conf_t
*)(uintptr_t)jconf
, &nelem
,
790 return (copyArray(jenv
, (void **)result
));
794 * pool_conf_location(3pool) wrapper
797 JNIEXPORT jstring JNICALL
798 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1location(
799 JNIEnv
*jenv
, jclass jcls
, jlong jconf
) {
800 jstring jresult
= NULL
;
803 result
= pool_conf_location((pool_conf_t
*)(uintptr_t)jconf
);
806 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
811 * pool_conf_info(3pool) wrapper
814 JNIEXPORT jstring JNICALL
815 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1info(JNIEnv
*jenv
,
816 jclass jcls
, jlong jconf
, jint jflags
) {
817 jstring jresult
= NULL
;
820 result
= pool_conf_info((pool_conf_t
*)(uintptr_t)jconf
, (int)jflags
);
823 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
824 free((void *)result
);
829 * pool_resource_create(3pool) wrapper
832 JNIEXPORT jlong JNICALL
833 Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1create(
834 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jstring jtype
, jstring jname
) {
837 pool_resource_t
*result
;
839 type
= (jtype
) ? (*jenv
)->GetStringUTFChars(jenv
, jtype
, 0) :
841 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) :
844 pool_resource_create((pool_conf_t
*)(uintptr_t)jconf
, type
, name
);
847 (*jenv
)->ReleaseStringUTFChars(jenv
, jtype
, type
);
849 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
850 return ((jlong
)(uintptr_t)result
);
854 * pool_resource_destroy(3pool) wrapper
857 JNIEXPORT jint JNICALL
858 Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1destroy(
859 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jresource
) {
860 return ((jint
)pool_resource_destroy((pool_conf_t
*)(uintptr_t)jconf
,
861 (pool_resource_t
*)(uintptr_t)jresource
));
865 * pool_resource_transfer(3pool) wrapper
868 JNIEXPORT jint JNICALL
869 Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1transfer(
870 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jsource
, jlong jtarget
,
872 return (pool_resource_transfer((pool_conf_t
*)(uintptr_t)jconf
,
873 (pool_resource_t
*)(uintptr_t)jsource
,
874 (pool_resource_t
*)(uintptr_t)jtarget
,
879 * pool_resource_xtransfer(3pool) wrapper
882 JNIEXPORT jint JNICALL
883 Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1xtransfer(
884 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jsource
, jlong jtarget
,
885 jobject jcomponents
) {
886 pool_component_t
**components
;
893 * Initialize the target parameter for case when input is null
896 if (jcomponents
!= NULL
) {
897 Lclazz
= (*jenv
)->GetObjectClass(jenv
, jcomponents
);
898 Lsize
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "size", "()I");
899 size
= (*jenv
)->CallIntMethod(jenv
, jcomponents
, Lsize
);
905 Lget
= (*jenv
)->GetMethodID(jenv
,
906 Lclazz
, "get", "(I)Ljava/lang/Object;");
907 /* Allocate space for the components array */
909 if ((components
= calloc(size
+ 1,
910 sizeof (pool_component_t
*))) == NULL
) {
911 throwException(jenv
, "java/lang/Exception",
912 "Could not allocate component array");
918 for (i
= 0; i
< size
; i
++) {
924 aVal
= (*jenv
)->CallObjectMethod(jenv
,
925 jcomponents
, Lget
, (jint
) i
);
926 Vclazz
= (*jenv
)->GetObjectClass(jenv
,
928 Vthis
= (*jenv
)->GetMethodID(jenv
,
929 Vclazz
, "getComponent", "()J");
930 this = (*jenv
)->CallLongMethod(jenv
,
933 (pool_component_t
*)(uintptr_t)this;
937 result
= (int)pool_resource_xtransfer((pool_conf_t
*)(uintptr_t)jconf
,
938 (pool_resource_t
*)(uintptr_t)jsource
,
939 (pool_resource_t
*)(uintptr_t)jtarget
,
943 return ((jint
)result
);
947 * pool_query_resource_components(3pool) wrapper
950 JNIEXPORT jobject JNICALL
951 Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1resource_\
952 1components(JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jresource
,
954 pool_value_t
**props
;
955 pool_component_t
**result
;
962 * Initialize the target parameter for case when input is null
965 if (jprops
!= NULL
) {
966 Lclazz
= (*jenv
)->GetObjectClass(jenv
, jprops
);
967 Lsize
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "size", "()I");
968 size
= (*jenv
)->CallIntMethod(jenv
, jprops
, Lsize
);
974 Lget
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "get",
975 "(I)Ljava/lang/Object;");
977 * Allocate space for the props array
979 if ((props
= calloc(size
+ 1, sizeof (pool_value_t
*)))
981 throwException(jenv
, "java/lang/Exception",
982 "Could not allocate props array");
988 for (i
= 0; i
< size
; i
++) {
994 aVal
= (*jenv
)->CallObjectMethod(jenv
, jprops
,
996 Vclazz
= (*jenv
)->GetObjectClass(jenv
, aVal
);
997 Vthis
= (*jenv
)->GetFieldID(jenv
, Vclazz
,
999 this = (*jenv
)->GetLongField(jenv
, aVal
, Vthis
);
1000 props
[i
] = (pool_value_t
*)(uintptr_t)this;
1004 result
= pool_query_resource_components(
1005 (pool_conf_t
*)(uintptr_t)jconf
,
1006 (pool_resource_t
*)(uintptr_t)jresource
, &nelem
, props
);
1008 return (copyArray(jenv
, (void **)result
));
1012 * pool_resource_info(3pool) wrapper
1015 JNIEXPORT jstring JNICALL
1016 Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1info(
1017 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jresource
, jint jflags
) {
1018 jstring jresult
= NULL
;
1021 result
= pool_resource_info((pool_conf_t
*)(uintptr_t)jconf
,
1022 (pool_resource_t
*)(uintptr_t)jresource
, (int)jflags
);
1025 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1026 free((void *)result
);
1031 * pool_create(3pool) wrapper
1034 JNIEXPORT jlong JNICALL
1035 Java_com_sun_solaris_service_pools_PoolInternal_pool_1create(JNIEnv
*jenv
,
1036 jclass jcls
, jlong jconf
, jstring jname
) {
1040 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) :
1042 result
= pool_create((pool_conf_t
*)(uintptr_t)jconf
, name
);
1045 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
1046 return ((jlong
)(uintptr_t)result
);
1050 * pool_destroy(3pool) wrapper
1053 JNIEXPORT jint JNICALL
1054 Java_com_sun_solaris_service_pools_PoolInternal_pool_1destroy(JNIEnv
*jenv
,
1055 jclass jcls
, jlong jconf
, jlong jpool
) {
1056 return ((jint
)pool_destroy((pool_conf_t
*)(uintptr_t)jconf
,
1057 (pool_t
*)(uintptr_t)jpool
));
1061 * pool_associate(3pool) wrapper
1064 JNIEXPORT jint JNICALL
1065 Java_com_sun_solaris_service_pools_PoolInternal_pool_1associate(JNIEnv
*jenv
,
1066 jclass jcls
, jlong jconf
, jlong jpool
, jlong jresource
) {
1067 return ((jint
)pool_associate((pool_conf_t
*)(uintptr_t)jconf
,
1068 (pool_t
*)(uintptr_t)jpool
,
1069 (pool_resource_t
*)(uintptr_t)jresource
));
1073 * pool_dissociate(3pool) wrapper
1076 JNIEXPORT jint JNICALL
1077 Java_com_sun_solaris_service_pools_PoolInternal_pool_1dissociate(JNIEnv
*jenv
,
1078 jclass jcls
, jlong jconf
, jlong jpool
, jlong jresource
) {
1079 return ((jint
)pool_dissociate((pool_conf_t
*)(uintptr_t)jconf
,
1080 (pool_t
*)(uintptr_t)jpool
,
1081 (pool_resource_t
*)(uintptr_t)jresource
));
1085 * pool_info(3pool) wrapper
1088 JNIEXPORT jstring JNICALL
1089 Java_com_sun_solaris_service_pools_PoolInternal_pool_1info(JNIEnv
*jenv
,
1090 jclass jcls
, jlong jconf
, jlong jpool
, jint jflags
) {
1091 jstring jresult
= NULL
;
1094 result
= pool_info((pool_conf_t
*)(uintptr_t)jconf
,
1095 (pool_t
*)(uintptr_t)jpool
, (int)jflags
);
1098 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1099 free((void *)result
);
1104 * pool_query_pool_resources(3pool) wrapper
1107 JNIEXPORT jobject JNICALL
1108 Java_com_sun_solaris_service_pools_PoolInternal_pool_1query_1pool_1resources(
1109 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jpool
, jobject jprops
) {
1110 pool_value_t
**props
;
1111 pool_resource_t
**result
;
1118 * Initialize the target parameter for case when input is null
1121 if (jprops
!= NULL
) {
1122 Lclazz
= (*jenv
)->GetObjectClass(jenv
, jprops
);
1123 Lsize
= (*jenv
)->GetMethodID(jenv
, Lclazz
, "size", "()I");
1124 size
= (*jenv
)->CallIntMethod(jenv
, jprops
, Lsize
);
1130 Lget
= (*jenv
)->GetMethodID(jenv
,
1131 Lclazz
, "get", "(I)Ljava/lang/Object;");
1133 * Allocate space for the props array
1136 if ((props
= calloc(size
+ 1, sizeof (pool_value_t
*)))
1138 throwException(jenv
, "java/lang/Exception",
1139 "Could not allocate props array");
1145 for (i
= 0; i
< size
; i
++) {
1151 aVal
= (*jenv
)->CallObjectMethod(jenv
, jprops
,
1153 Vclazz
= (*jenv
)->GetObjectClass(jenv
, aVal
);
1154 Vthis
= (*jenv
)->GetFieldID(jenv
, Vclazz
,
1156 this = (*jenv
)->GetLongField(jenv
, aVal
, Vthis
);
1157 props
[i
] = (pool_value_t
*)(uintptr_t)this;
1161 result
= pool_query_pool_resources((pool_conf_t
*)(uintptr_t)jconf
,
1162 (pool_t
*)(uintptr_t)jpool
, &nelem
, props
);
1164 return (copyArray(jenv
, (void **)result
));
1168 * pool_get_owning_resource(3pool) wrapper
1171 JNIEXPORT jlong JNICALL
1172 Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1owning_1resource(
1173 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jcomponent
) {
1174 return ((jlong
)(uintptr_t)pool_get_owning_resource(
1175 (pool_conf_t
*)(uintptr_t)jconf
,
1176 (pool_component_t
*)(uintptr_t)jcomponent
));
1180 * pool_component_info(3pool) wrapper
1183 JNIEXPORT jstring JNICALL
1184 Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1info(
1185 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jcomponent
, jint jflags
) {
1186 jstring jresult
= NULL
;
1189 result
= pool_component_info((pool_conf_t
*)(uintptr_t)jconf
,
1190 (pool_component_t
*)(uintptr_t)jcomponent
, (int)jflags
);
1193 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1194 free((void *)result
);
1199 * pool_get_property(3pool) wrapper
1202 JNIEXPORT jint JNICALL
1203 Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1property(
1204 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jelem
, jstring jname
,
1209 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) :
1211 result
= pool_get_property((pool_conf_t
*)(uintptr_t)jconf
,
1212 (pool_elem_t
*)(uintptr_t)jelem
, name
,
1213 (pool_value_t
*)(uintptr_t)jproperty
);
1216 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
1217 return ((jint
)result
);
1221 * pool_put_property(3pool) wrapper
1224 JNIEXPORT jint JNICALL
1225 Java_com_sun_solaris_service_pools_PoolInternal_pool_1put_1property(
1226 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jelem
, jstring jname
,
1231 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) : NULL
;
1232 result
= (int)pool_put_property((pool_conf_t
*)(uintptr_t)jconf
,
1233 (pool_elem_t
*)(uintptr_t)jelem
, name
,
1234 (pool_value_t
*)(uintptr_t)jvalue
);
1237 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
1238 return ((jint
)result
);
1242 * pool_rm_property(3pool) wrapper
1245 JNIEXPORT jint JNICALL
1246 Java_com_sun_solaris_service_pools_PoolInternal_pool_1rm_1property(JNIEnv
*jenv
,
1247 jclass jcls
, jlong jconf
, jlong jelem
, jstring jname
) {
1251 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) : NULL
;
1252 result
= pool_rm_property((pool_conf_t
*)(uintptr_t)jconf
,
1253 (pool_elem_t
*)(uintptr_t)jelem
, name
);
1256 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
1257 return ((jint
)result
);
1261 * pool_walk_properties(3pool) wrapper
1264 JNIEXPORT jint JNICALL
1265 Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1properties(
1266 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jelem
, jlong jarg
,
1270 result
= (int)pool_walk_properties((pool_conf_t
*)(uintptr_t)jconf
,
1271 (pool_elem_t
*)(uintptr_t)jelem
, (void *)(uintptr_t)jarg
,
1272 (int (*)(pool_conf_t
*, pool_elem_t
*, char const *,
1273 pool_value_t
*, void *))(uintptr_t)jcallback
);
1275 return ((jint
)result
);
1279 * pool_conf_to_elem(3pool) wrapper
1282 JNIEXPORT jlong JNICALL
1283 Java_com_sun_solaris_service_pools_PoolInternal_pool_1conf_1to_1elem(
1284 JNIEnv
*jenv
, jclass jcls
, jlong jconf
) {
1285 return ((jlong
)(uintptr_t)pool_conf_to_elem(
1286 (pool_conf_t
*)(uintptr_t)jconf
));
1290 * pool_to_elem(3pool) wrapper
1293 JNIEXPORT jlong JNICALL
1294 Java_com_sun_solaris_service_pools_PoolInternal_pool_1to_1elem(JNIEnv
*jenv
,
1295 jclass jcls
, jlong jconf
, jlong jpool
) {
1296 return ((jlong
)(uintptr_t)pool_to_elem((pool_conf_t
*)(uintptr_t)jconf
,
1297 (pool_t
*)(uintptr_t)jpool
));
1301 * pool_resource_to_elem(3pool) wrapper
1304 JNIEXPORT jlong JNICALL
1305 Java_com_sun_solaris_service_pools_PoolInternal_pool_1resource_1to_1elem(
1306 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jresource
) {
1307 return ((jlong
)(uintptr_t)pool_resource_to_elem(
1308 (pool_conf_t
*)(uintptr_t)jconf
,
1309 (pool_resource_t
*)(uintptr_t)jresource
));
1313 * pool_component_to_elem(3pool) wrapper
1316 JNIEXPORT jlong JNICALL
1317 Java_com_sun_solaris_service_pools_PoolInternal_pool_1component_1to_1elem(
1318 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jcomponent
) {
1319 return ((jlong
)(uintptr_t)pool_component_to_elem(
1320 (pool_conf_t
*)(uintptr_t)jconf
,
1321 (pool_component_t
*)(uintptr_t)jcomponent
));
1325 * pool_value_get_type(3pool) wrapper
1328 JNIEXPORT jint JNICALL
1329 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1type(
1330 JNIEnv
*jenv
, jclass jcls
, jlong jvalue
) {
1331 return ((jint
)pool_value_get_type((pool_value_t
*)(uintptr_t)jvalue
));
1335 * pool_value_set_uint64(3pool) wrapper
1338 JNIEXPORT
void JNICALL
1339 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1uint64(
1340 JNIEnv
*jenv
, jclass jcls
, jlong jvalue
, jlong jui64
) {
1341 pool_value_set_uint64(
1342 (pool_value_t
*)(uintptr_t)jvalue
, (uint64_t)jui64
);
1346 * pool_value_set_int64(3pool) wrapper
1349 JNIEXPORT
void JNICALL
1350 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1int64(
1351 JNIEnv
*jenv
, jclass jcls
, jlong jvalue
, jlong ji64
) {
1352 pool_value_set_int64((pool_value_t
*)(uintptr_t)jvalue
, (int64_t)ji64
);
1356 * pool_value_set_double(3pool) wrapper
1359 JNIEXPORT
void JNICALL
1360 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1double(
1361 JNIEnv
*jenv
, jclass jcls
, jlong jvalue
, jdouble jd
) {
1362 pool_value_set_double((pool_value_t
*)(uintptr_t)jvalue
, (double)jd
);
1366 * pool_value_set_bool(3pool) wrapper
1369 JNIEXPORT
void JNICALL
1370 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1bool(
1371 JNIEnv
*jenv
, jclass jcls
, jlong jvalue
, jshort jb
) {
1372 pool_value_set_bool((pool_value_t
*)(uintptr_t)jvalue
, (uchar_t
)jb
);
1376 * pool_value_set_string(3pool) wrapper
1379 JNIEXPORT jint JNICALL
1380 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1string(
1381 JNIEnv
* jenv
, jclass jcls
, jlong jvalue
, jstring jstr
) {
1385 str
= (jstr
) ? (*jenv
)->GetStringUTFChars(jenv
, jstr
, 0) : NULL
;
1386 result
= pool_value_set_string((pool_value_t
*)(uintptr_t)jvalue
, str
);
1389 (*jenv
)->ReleaseStringUTFChars(jenv
, jstr
, str
);
1390 return ((jint
)result
);
1394 * pool_value_get_name(3pool) wrapper
1397 JNIEXPORT jstring JNICALL
1398 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1get_1name(
1399 JNIEnv
*jenv
, jclass jcls
, jlong jvalue
) {
1400 jstring jresult
= NULL
;
1403 result
= pool_value_get_name((pool_value_t
*)(uintptr_t)jvalue
);
1406 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1411 * pool_value_set_name(3pool) wrapper
1414 JNIEXPORT jint JNICALL
1415 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1set_1name(
1416 JNIEnv
*jenv
, jclass jcls
, jlong jvalue
, jstring jname
) {
1420 name
= (jname
) ? (*jenv
)->GetStringUTFChars(jenv
, jname
, 0) : NULL
;
1421 result
= pool_value_set_name((pool_value_t
*)(uintptr_t)jvalue
, name
);
1424 (*jenv
)->ReleaseStringUTFChars(jenv
, jname
, name
);
1425 return ((jint
)result
);
1429 * pool_value_alloc(3pool) wrapper
1432 JNIEXPORT jlong JNICALL
1433 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1alloc(JNIEnv
*jenv
,
1435 return ((jlong
)(uintptr_t)pool_value_alloc());
1439 * pool_value_free(3pool) wrapper
1442 JNIEXPORT
void JNICALL
1443 Java_com_sun_solaris_service_pools_PoolInternal_pool_1value_1free(JNIEnv
*jenv
,
1444 jclass jcls
, jlong jvalue
) {
1445 pool_value_free((pool_value_t
*)(uintptr_t)jvalue
);
1449 * pool_static_location(3pool) wrapper
1452 JNIEXPORT jstring JNICALL
1453 Java_com_sun_solaris_service_pools_PoolInternal_pool_1static_1location(
1454 JNIEnv
*jenv
, jclass jcls
) {
1455 jstring jresult
= NULL
;
1458 result
= pool_static_location();
1461 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1466 * pool_dynamic_location(3pool) wrapper
1469 JNIEXPORT jstring JNICALL
1470 Java_com_sun_solaris_service_pools_PoolInternal_pool_1dynamic_1location(JNIEnv
*
1471 jenv
, jclass jcls
) {
1472 jstring jresult
= NULL
;
1475 result
= pool_dynamic_location();
1478 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1483 * pool_set_binding(3pool) wrapper
1486 JNIEXPORT jint JNICALL
1487 Java_com_sun_solaris_service_pools_PoolInternal_pool_1set_1binding(JNIEnv
*jenv
,
1488 jclass jcls
, jstring jpool
, jint jidtype
, jint jpid
) {
1492 pool
= (jpool
) ? (*jenv
)->GetStringUTFChars(jenv
, jpool
, 0) : NULL
;
1493 result
= (int)pool_set_binding(pool
, (idtype_t
)jidtype
, (id_t
)jpid
);
1496 (*jenv
)->ReleaseStringUTFChars(jenv
, jpool
, pool
);
1497 return ((jint
)result
);
1501 * pool_get_binding(3pool) wrapper
1504 JNIEXPORT jstring JNICALL
1505 Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1binding(JNIEnv
*jenv
,
1506 jclass jcls
, jint jpid
) {
1507 jstring jresult
= NULL
;
1510 result
= pool_get_binding((pid_t
)jpid
);
1513 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1514 free((void *)result
);
1519 * pool_get_resource_binding(3pool) wrapper
1522 JNIEXPORT jstring JNICALL
1523 Java_com_sun_solaris_service_pools_PoolInternal_pool_1get_1resource_1binding(
1524 JNIEnv
*jenv
, jclass jcls
, jstring jtype
, jint jpid
) {
1525 jstring jresult
= NULL
;
1529 type
= (jtype
) ? (*jenv
)->GetStringUTFChars(jenv
, jtype
, 0) : NULL
;
1530 result
= pool_get_resource_binding(type
, (pid_t
)jpid
);
1533 jresult
= (*jenv
)->NewStringUTF(jenv
, result
);
1534 free((void *)result
);
1536 (*jenv
)->ReleaseStringUTFChars(jenv
, jtype
, type
);
1541 * pool_walk_pools(3pool) wrapper
1544 JNIEXPORT jint JNICALL
1545 Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1pools(JNIEnv
*jenv
,
1546 jclass jcls
, jlong jconf
, jlong jarg
, jlong jcallback
) {
1549 result
= pool_walk_pools((pool_conf_t
*)(uintptr_t)jconf
,
1550 (void *)(uintptr_t)jarg
,
1551 (int (*)(pool_conf_t
*, pool_t
*, void *))(uintptr_t)jcallback
);
1552 return ((jint
)result
);
1556 * pool_walk_resources(3pool) wrapper
1559 JNIEXPORT jint JNICALL
1560 Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1resources(
1561 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jpool
, jlong jarg
,
1565 result
= pool_walk_resources((pool_conf_t
*)(uintptr_t)jconf
,
1566 (pool_t
*)(uintptr_t)jpool
, (void *)(uintptr_t)jarg
,
1567 (int (*)(pool_conf_t
*, pool_resource_t
*, void *))
1568 (uintptr_t)jcallback
);
1569 return ((jint
)result
);
1573 * pool_walk_components(3pool) wrapper
1576 JNIEXPORT jint JNICALL
1577 Java_com_sun_solaris_service_pools_PoolInternal_pool_1walk_1components(
1578 JNIEnv
*jenv
, jclass jcls
, jlong jconf
, jlong jresource
, jlong jarg
,
1582 result
= pool_walk_components((pool_conf_t
*)(uintptr_t)jconf
,
1583 (pool_resource_t
*)(uintptr_t)jresource
, (void *)(uintptr_t)jarg
,
1584 (int (*)(pool_conf_t
*, pool_component_t
*, void *))
1585 (uintptr_t)jcallback
);
1586 return ((jint
)result
);
1590 JNIEXPORT jint JNICALL
1591 Java_com_sun_solaris_service_pools_Element_walkProps(JNIEnv
*env
,
1592 jobject obj
, jlong conf
, jlong elem
, jobject handler
, jobject userobj
)
1594 struct pool_callback pc
;
1596 pc
.pc_user
= userobj
;
1597 pc
.pc_handler
= handler
;
1600 return (pool_walk_properties((pool_conf_t
*)*(void**)&conf
,
1601 (pool_elem_t
*)*(void**)&elem
, (void *)&pc
, pool_property_walker
));
1606 pool_property_walker(pool_conf_t
*conf
, pool_elem_t
*pe
, const char *name
,
1607 pool_value_t
*pv
, void *user
)
1609 jclass clazz
, vclazz
;
1610 jmethodID mgetwalk
, mvcon
;
1611 struct pool_callback
*pc
= (struct pool_callback
*)user
;
1613 pool_value_t
*pv_new
;
1621 * Since we intend to embed our value into a Java Value object
1622 * and then reclaim the value when the object is garbage
1623 * collected we must create a new pool value and then pass this
1624 * to the constructor. We must not use the pool value which is
1628 if ((pv_new
= pool_value_alloc()) == NULL
)
1630 switch (pool_value_get_type(pv
)) {
1632 (void) pool_value_get_uint64(pv
, &uval
);
1633 (void) pool_value_set_uint64(pv_new
, uval
);
1636 (void) pool_value_get_int64(pv
, &ival
);
1637 (void) pool_value_set_int64(pv_new
, ival
);
1640 (void) pool_value_get_double(pv
, &dval
);
1641 (void) pool_value_set_double(pv_new
, dval
);
1644 (void) pool_value_get_bool(pv
, &bval
);
1645 (void) pool_value_set_bool(pv_new
, bval
);
1648 (void) pool_value_get_string(pv
, &sval
);
1649 (void) pool_value_set_string(pv_new
, sval
);
1652 pool_value_free(pv_new
);
1655 if (pool_value_set_name(pv_new
, name
) != PO_SUCCESS
||
1656 (vclazz
= (*pc
->pc_env
)->FindClass(pc
->pc_env
,
1657 "com/sun/solaris/service/pools/Value")) == NULL
||
1658 (mvcon
= (*pc
->pc_env
)->GetMethodID(pc
->pc_env
, vclazz
,
1659 "<init>", "(J)V")) == NULL
||
1660 (valueObj
= (*pc
->pc_env
)->NewObject(pc
->pc_env
, vclazz
, mvcon
,
1662 (clazz
= (*pc
->pc_env
)->GetObjectClass(pc
->pc_env
, pc
->pc_handler
))
1664 (mgetwalk
= (*pc
->pc_env
)->GetMethodID(pc
->pc_env
,
1666 "(Lcom/sun/solaris/service/pools/Element;Lcom/sun/solaris/"
1667 "service/pools/Value;Ljava/lang/Object;)I")) == NULL
)
1669 return ((*pc
->pc_env
)->CallIntMethod(pc
->pc_env
,
1670 pc
->pc_handler
, mgetwalk
, pc
->pc_elem
, valueObj
, pc
->pc_user
));
1674 JNIEXPORT jlong JNICALL
1675 Java_com_sun_solaris_service_pools_Value_getLongValue(JNIEnv
*jenv
,
1676 jclass
class, jlong pointer
)
1682 pool_value_get_int64((pool_value_t
*)(uintptr_t)pointer
, &arg2
);
1684 if (result
!= PO_SUCCESS
) { /* it could be a uint64 */
1686 pool_value_get_uint64((pool_value_t
*)(uintptr_t)pointer
,
1688 if (result
!= PO_SUCCESS
) {
1692 * Unfortunately, Java has no unsigned types, so we lose some
1693 * precision by forcing the top bit clear
1695 arg2
&= 0x7fffffffffffffffULL
;
1697 return ((jlong
)arg2
);
1701 JNIEXPORT jstring JNICALL
1702 Java_com_sun_solaris_service_pools_Value_getStringValue(JNIEnv
*jenv
,
1703 jclass
class, jlong pointer
)
1709 pool_value_get_string((pool_value_t
*)(uintptr_t)pointer
, &arg2
);
1710 if (result
!= PO_SUCCESS
)
1712 return ((*jenv
)->NewStringUTF(jenv
, arg2
));
1716 JNIEXPORT jboolean JNICALL
1717 Java_com_sun_solaris_service_pools_Value_getBoolValue(JNIEnv
*jenv
,
1718 jclass
class, jlong pointer
)
1723 result
= pool_value_get_bool((pool_value_t
*)(uintptr_t)pointer
, &arg2
);
1725 if (result
!= PO_SUCCESS
) {
1728 if (arg2
== PO_TRUE
)
1735 JNIEXPORT jdouble JNICALL
1736 Java_com_sun_solaris_service_pools_Value_getDoubleValue(JNIEnv
*jenv
,
1737 jclass
class, jlong pointer
)
1743 pool_value_get_double((pool_value_t
*)(uintptr_t)pointer
, &arg2
);
1745 if (result
!= PO_SUCCESS
) {
1748 return ((jdouble
)arg2
);
1752 JNIEXPORT jobject JNICALL
1753 Java_com_sun_solaris_service_pools_Value_getUnsignedInt64Value(JNIEnv
*jenv
,
1754 jclass
class, jlong pointer
)
1760 pool_value_get_uint64((pool_value_t
*)(uintptr_t)pointer
, &arg2
);
1762 if (result
!= PO_SUCCESS
) {
1765 return (makeUnsignedInt64(jenv
, arg2
));
1769 JNIEXPORT jobject JNICALL
1770 Java_com_sun_solaris_service_pools_HRTime_timestamp(JNIEnv
*env
, jobject obj
)
1772 return (makeUnsignedInt64(env
, gethrtime()));
1776 * Cache class, method, and field IDs.
1779 JNIEXPORT
void JNICALL
1780 Java_com_sun_solaris_service_pools_PoolInternal_init(JNIEnv
*env
, jclass clazz
)
1782 jclass ui64class_lref
;
1784 if (!(ui64class_lref
= (*env
)->FindClass(env
,
1785 "com/sun/solaris/service/pools/UnsignedInt64")))
1786 return; /* exception thrown */
1787 if (!(ui64class
= (*env
)->NewGlobalRef(env
, ui64class_lref
)))
1788 return; /* exception thrown */
1789 ui64cons_mid
= (*env
)->GetMethodID(env
, ui64class
, "<init>", "([B)V");