diff options
author | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2019-06-25 17:39:35 (GMT) |
---|---|---|
committer | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2019-06-25 17:39:35 (GMT) |
commit | 35c9af8371c4da7f5327c76ddab097b442128f59 (patch) | |
tree | d51be51c385a9b463388ba154efc3fa37cad49e8 /java/src/jni/h5Imp.c | |
parent | c752332bfd0e9c3090f3a0c02d0253cd45c2e2ce (diff) | |
parent | 1d8f7bf297100ec11204442708a7f670a89f3f02 (diff) | |
download | hdf5-35c9af8371c4da7f5327c76ddab097b442128f59.zip hdf5-35c9af8371c4da7f5327c76ddab097b442128f59.tar.gz hdf5-35c9af8371c4da7f5327c76ddab097b442128f59.tar.bz2 |
Merge branch 'develop' into parallel_vds_developinactive/parallel_vds_develop
Diffstat (limited to 'java/src/jni/h5Imp.c')
-rw-r--r-- | java/src/jni/h5Imp.c | 108 |
1 files changed, 68 insertions, 40 deletions
diff --git a/java/src/jni/h5Imp.c b/java/src/jni/h5Imp.c index 1ad6b17..f0dd691 100644 --- a/java/src/jni/h5Imp.c +++ b/java/src/jni/h5Imp.c @@ -35,7 +35,10 @@ extern "C" { #include "h5jni.h" #include "h5Imp.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -46,10 +49,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5open (JNIEnv *env, jclass clss) { - herr_t retVal = H5open(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + + UNUSED(clss); + if ((retVal = H5open()) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5open */ @@ -62,10 +69,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5close (JNIEnv *env, jclass clss) { - herr_t retVal = H5close(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5close()) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5close */ @@ -78,10 +89,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5dont_1atexit (JNIEnv *env, jclass clss) { - herr_t retVal = H5dont_atexit(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + UNUSED(clss); + + if ((retVal = H5dont_atexit()) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5dont_1atexit */ @@ -94,28 +109,24 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5get_1libversion (JNIEnv *env, jclass clss, jintArray libversion) { - unsigned *theArray = NULL; - herr_t status = -1; - jboolean isCopy; - - if (libversion == NULL) { - h5nullArgument(env, "H5get_version: libversion is NULL"); - } /* end if */ - else { - theArray = (unsigned*)ENVPTR->GetIntArrayElements(ENVPAR libversion, &isCopy); - if (theArray == NULL) { - h5JNIFatalError( env, "H5get_libversion: input not pinned"); - } /* end if */ - else { - status = H5get_libversion(&(theArray[0]), &(theArray[1]), &(theArray[2])); - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR libversion, (jint*)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - ENVPTR->ReleaseIntArrayElements(ENVPAR libversion, (jint*)theArray,0); - } /* end else */ - } /* end else */ + jboolean libversionArrayIsCopy; + int *libversionArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (libversion == NULL) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5get_libversion: libversion is NULL"); + + PIN_INT_ARRAY(ENVONLY, libversion, libversionArray, &libversionArrayIsCopy, "H5get_libversion: libversion input not pinned"); + + if ((status = H5get_libversion((unsigned *) &(libversionArray[0]), (unsigned *) &(libversionArray[1]), (unsigned *) &(libversionArray[2]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (libversionArray) + UNPIN_INT_ARRAY(ENVONLY, libversion, libversionArray, (status < 0) ? JNI_ABORT : 0); + return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5get_1libversion */ @@ -128,6 +139,9 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5check_1version (JNIEnv *env, jclass clss, jint majnum, jint minnum, jint relnum) { + UNUSED(env); + UNUSED(clss); + return (jint)H5check_version((unsigned)majnum, (unsigned)minnum, (unsigned)relnum); } /* end Java_hdf_hdf5lib_H5_H5check_1version */ @@ -141,10 +155,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5garbage_1collect (JNIEnv *env, jclass clss) { - herr_t retVal = H5garbage_collect(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5garbage_collect()) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5garbage_1collect */ @@ -158,11 +176,15 @@ Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits (JNIEnv *env, jclass clss, jint reg_global_lim, jint reg_list_lim, jint arr_global_lim, jint arr_list_lim, jint blk_global_lim, jint blk_list_lim ) { - herr_t retVal = H5set_free_list_limits((int)reg_global_lim, (int)reg_list_lim, - (int)arr_global_lim, (int)arr_list_lim, (int)blk_global_lim, (int)blk_list_lim); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + UNUSED(clss); + + if ((retVal = H5set_free_list_limits((int)reg_global_lim, (int)reg_list_lim, + (int)arr_global_lim, (int)arr_list_lim, (int)blk_global_lim, (int)blk_list_lim)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits */ @@ -176,7 +198,13 @@ Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe (JNIEnv *env, jclass clss) { hbool_t is_ts = false; - H5is_library_threadsafe(&is_ts); + + UNUSED(clss); + + if (H5is_library_threadsafe(&is_ts) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jboolean)is_ts; } /* end Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe */ |