From 73f01f98cd08ebb9ae8fd4a8b1c8413e74eb9dc8 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 4 Apr 2019 12:59:43 -0500 Subject: Update java m4 to latest --- m4/ax_check_class.m4 | 75 ++++------------------------------------------- m4/ax_check_classpath.m4 | 6 ++-- m4/ax_check_java_home.m4 | 6 ++-- m4/ax_check_junit.m4 | 4 +-- m4/ax_check_rqrd_class.m4 | 6 ++-- m4/ax_java_check_class.m4 | 8 ++--- m4/ax_java_options.m4 | 4 +-- m4/ax_jni_include_dir.m4 | 61 +++++++++++++++++++++++++------------- m4/ax_prog_jar.m4 | 4 +-- m4/ax_prog_java.m4 | 6 ++-- m4/ax_prog_java_cc.m4 | 6 ++-- m4/ax_prog_java_works.m4 | 51 +++----------------------------- m4/ax_prog_javac.m4 | 6 ++-- m4/ax_prog_javac_works.m4 | 6 ++-- m4/ax_prog_javadoc.m4 | 4 +-- m4/ax_prog_javah.m4 | 16 +++++----- m4/ax_try_compile_java.m4 | 8 ++--- m4/ax_try_run_java.m4 | 4 +-- 18 files changed, 96 insertions(+), 185 deletions(-) diff --git a/m4/ax_check_class.m4 b/m4/ax_check_class.m4 index 098aa77..e673c2d 100644 --- a/m4/ax_check_class.m4 +++ b/m4/ax_check_class.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_class.html +# https://www.gnu.org/software/autoconf-archive/ax_check_class.html # =========================================================================== # # SYNOPSIS @@ -36,7 +36,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -51,83 +51,18 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 7 +#serial 12 AU_ALIAS([AC_CHECK_CLASS], [AX_CHECK_CLASS]) AC_DEFUN([AX_CHECK_CLASS],[ AC_REQUIRE([AX_PROG_JAVA]) ac_var_name=`echo $1 | sed 's/\./_/g'` -dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is +dnl Normally I'd use a AC_CACHE_CHECK here but since the variable name is dnl dynamic I need an extra level of extraction AC_MSG_CHECKING([for $1 class]) AC_CACHE_VAL(ax_cv_class_$ac_var_name, [ -if test x$ac_cv_prog_uudecode_base64 = xyes; then -dnl /** -dnl * Test.java: used to test dynamicaly if a class exists. -dnl */ -dnl public class Test -dnl { -dnl -dnl public static void -dnl main( String[] argv ) -dnl { -dnl Class lib; -dnl if (argv.length < 1) -dnl { -dnl System.err.println ("Missing argument"); -dnl System.exit (77); -dnl } -dnl try -dnl { -dnl lib = Class.forName (argv[0]); -dnl } -dnl catch (ClassNotFoundException e) -dnl { -dnl System.exit (1); -dnl } -dnl lib = null; -dnl System.exit (0); -dnl } -dnl -dnl } -cat << \EOF > Test.uue -begin-base64 644 Test.class -yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE -bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 -bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ -AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt -ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV -ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp -VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM -amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi -AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B -AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA -AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN -uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK -AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA -JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA -JwAAAAIAKA== -==== -EOF - if $UUDECODE Test.uue; then - : - else - echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD - echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD - cat Test.uue >&AS_MESSAGE_LOG_FD - ac_cv_prog_uudecode_base64=no - fi - rm -f Test.uue - if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then - eval "ac_cv_class_$ac_var_name=yes" - else - eval "ac_cv_class_$ac_var_name=no" - fi - rm -f Test.class -else AX_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"], [eval "ac_cv_class_$ac_var_name=no"]) -fi eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`" HAVE_LAST_CLASS=$ac_var_val @@ -137,7 +72,7 @@ else ifelse([$3], , :, [$3]) fi ]) -dnl for some reason the above statment didn't fall though here? +dnl for some reason the above statement didn't fall though here? dnl do scripts have variable scoping? eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" AC_MSG_RESULT($ac_var_val) diff --git a/m4/ax_check_classpath.m4 b/m4/ax_check_classpath.m4 index 3c9081a..e08a253 100644 --- a/m4/ax_check_classpath.m4 +++ b/m4/ax_check_classpath.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_classpath.html +# https://www.gnu.org/software/autoconf-archive/ax_check_classpath.html # =========================================================================== # # SYNOPSIS @@ -33,7 +33,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -48,7 +48,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 5 +#serial 6 AU_ALIAS([AC_CHECK_CLASSPATH], [AX_CHECK_CLASSPATH]) AC_DEFUN([AX_CHECK_CLASSPATH],[ diff --git a/m4/ax_check_java_home.m4 b/m4/ax_check_java_home.m4 index cfe8f58..1d60387 100644 --- a/m4/ax_check_java_home.m4 +++ b/m4/ax_check_java_home.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_java_home.html +# https://www.gnu.org/software/autoconf-archive/ax_check_java_home.html # =========================================================================== # # SYNOPSIS @@ -28,7 +28,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -43,7 +43,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 6 +#serial 7 AU_ALIAS([AC_CHECK_JAVA_HOME], [AX_CHECK_JAVA_HOME]) diff --git a/m4/ax_check_junit.m4 b/m4/ax_check_junit.m4 index 39b52d1..44dd70d 100644 --- a/m4/ax_check_junit.m4 +++ b/m4/ax_check_junit.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_junit.html +# https://www.gnu.org/software/autoconf-archive/ax_check_junit.html # =========================================================================== # # SYNOPSIS @@ -45,7 +45,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 5 +#serial 6 AU_ALIAS([AC_CHECK_JUNIT], [AX_CHECK_JUNIT]) AC_DEFUN([AX_CHECK_JUNIT],[ diff --git a/m4/ax_check_rqrd_class.m4 b/m4/ax_check_rqrd_class.m4 index 8f14241..baa041a 100644 --- a/m4/ax_check_rqrd_class.m4 +++ b/m4/ax_check_rqrd_class.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_rqrd_class.html +# https://www.gnu.org/software/autoconf-archive/ax_check_rqrd_class.html # =========================================================================== # # SYNOPSIS @@ -35,7 +35,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -50,7 +50,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 5 +#serial 6 AU_ALIAS([AC_CHECK_RQRD_CLASS], [AX_CHECK_RQRD_CLASS]) AC_DEFUN([AX_CHECK_RQRD_CLASS],[ diff --git a/m4/ax_java_check_class.m4 b/m4/ax_java_check_class.m4 index 917638a..c9d60f7 100644 --- a/m4/ax_java_check_class.m4 +++ b/m4/ax_java_check_class.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html +# https://www.gnu.org/software/autoconf-archive/ax_java_check_class.html # =========================================================================== # # SYNOPSIS @@ -15,7 +15,7 @@ # # The macro tries to compile a minimal program importing . Some # newer compilers moan about the failure to use this but fail or produce a -# class file anyway. All moaing is sunk to /dev/null since I only wanted +# class file anyway. All moaning is sunk to /dev/null since I only wanted # to know if the class could be imported. This is a recommended followup # to AX_CHECK_JAVA_PLUGIN with classpath appropriately adjusted. # @@ -34,7 +34,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -49,7 +49,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 9 +#serial 12 AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS]) AC_DEFUN([AX_JAVA_CHECK_CLASS],[ diff --git a/m4/ax_java_options.m4 b/m4/ax_java_options.m4 index 36c10d9..722d788 100644 --- a/m4/ax_java_options.m4 +++ b/m4/ax_java_options.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_java_options.html +# https://www.gnu.org/software/autoconf-archive/ax_java_options.html # =========================================================================== # # SYNOPSIS @@ -27,7 +27,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 6 +#serial 7 AU_ALIAS([AC_JAVA_OPTIONS], [AX_JAVA_OPTIONS]) AC_DEFUN([AX_JAVA_OPTIONS],[ diff --git a/m4/ax_jni_include_dir.m4 b/m4/ax_jni_include_dir.m4 index becb33a..ae7a5f0 100644 --- a/m4/ax_jni_include_dir.m4 +++ b/m4/ax_jni_include_dir.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html +# https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html # =========================================================================== # # SYNOPSIS @@ -32,6 +32,10 @@ # # - at the configure level, setenv JAVAC # +# This macro depends on AC_CANONICAL_HOST which requires that config.guess +# and config.sub be distributed along with the source code. See autoconf +# manual for details. +# # Note: This macro can work with the autoconf M4 macros for Java programs. # This particular macro is not part of the original set of macros. # @@ -44,11 +48,13 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 11 +#serial 15 AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR]) AC_DEFUN([AX_JNI_INCLUDE_DIR],[ +AC_REQUIRE([AC_CANONICAL_HOST]) + JNI_INCLUDE_DIRS="" if test "x$JAVA_HOME" != x; then @@ -66,14 +72,17 @@ else fi case "$host_os" in - darwin*) # Apple JDK is at /System location and has headers symlinked elsewhere - case "$_JTOPDIR" in - /System/Library/Frameworks/JavaVM.framework/*) - _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` - _JINC="$_JTOPDIR/Headers";; - *) _JINC="$_JTOPDIR/include";; - esac;; - *) _JINC="$_JTOPDIR/include";; + darwin*) # Apple Java headers are inside the Xcode bundle. + macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p') + if @<:@ "$macos_version" -gt "7" @:>@; then + _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework" + _JINC="$_JTOPDIR/Headers" + else + _JTOPDIR="/System/Library/Frameworks/JavaVM.framework" + _JINC="$_JTOPDIR/Headers" + fi + ;; + *) _JINC="$_JTOPDIR/include";; esac _AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR]) _AS_ECHO_LOG([_JINC=$_JINC]) @@ -81,13 +90,21 @@ _AS_ECHO_LOG([_JINC=$_JINC]) # On Mac OS X 10.6.4, jni.h is a symlink: # /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h # -> ../../CurrentJDK/Headers/jni.h. -AC_CHECK_FILE([$_JINC/jni.h], - [JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC"], - [_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` - AC_CHECK_FILE([$_JTOPDIR/include/jni.h], - [JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"], - AC_MSG_ERROR([cannot find JDK header files])) - ]) +AC_CACHE_CHECK(jni headers, ac_cv_jni_header_path, +[ + if test -f "$_JINC/jni.h"; then + ac_cv_jni_header_path="$_JINC" + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path" + else + _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` + if test -f "$_JTOPDIR/include/jni.h"; then + ac_cv_jni_header_path="$_JTOPDIR/include" + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path" + else + ac_cv_jni_header_path=none + fi + fi +]) # get the likely subdirectories for system specific java includes case "$host_os" in @@ -102,13 +119,15 @@ cygwin*) _JNI_INC_SUBDIRS="win32";; *) _JNI_INC_SUBDIRS="genunix";; esac -# add any subdirectories that are present -for JINCSUBDIR in $_JNI_INC_SUBDIRS -do +if test "x$ac_cv_jni_header_path" != "xnone"; then + # add any subdirectories that are present + for JINCSUBDIR in $_JNI_INC_SUBDIRS + do if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR" fi -done + done +fi ]) # _ACJNI_FOLLOW_SYMLINKS diff --git a/m4/ax_prog_jar.m4 b/m4/ax_prog_jar.m4 index 3c60fca..d474912 100644 --- a/m4/ax_prog_jar.m4 +++ b/m4/ax_prog_jar.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_jar.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_jar.html # =========================================================================== # # SYNOPSIS @@ -37,7 +37,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 7 +#serial 8 AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) AC_DEFUN([AX_PROG_JAR],[ diff --git a/m4/ax_prog_java.m4 b/m4/ax_prog_java.m4 index 03961db..c2e6964 100644 --- a/m4/ax_prog_java.m4 +++ b/m4/ax_prog_java.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_java.html # =========================================================================== # # SYNOPSIS @@ -85,7 +85,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -100,7 +100,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 9 +#serial 10 AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) AC_DEFUN([AX_PROG_JAVA],[ diff --git a/m4/ax_prog_java_cc.m4 b/m4/ax_prog_java_cc.m4 index 3df064f..ce9612d 100644 --- a/m4/ax_prog_java_cc.m4 +++ b/m4/ax_prog_java_cc.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html # =========================================================================== # # SYNOPSIS @@ -56,7 +56,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -71,7 +71,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 4 +#serial 5 # AX_PROG_JAVA_CC([COMPILER ...]) # -------------------------- diff --git a/m4/ax_prog_java_works.m4 b/m4/ax_prog_java_works.m4 index 54e132a..bc70526 100644 --- a/m4/ax_prog_java_works.m4 +++ b/m4/ax_prog_java_works.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html # =========================================================================== # # SYNOPSIS @@ -32,7 +32,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -47,57 +47,16 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 9 +#serial 11 AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) AC_DEFUN([AX_PROG_JAVA_WORKS], [ -AC_PATH_PROG(UUDECODE, uudecode, [no]) -if test x$UUDECODE != xno; then -AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ -dnl /** -dnl * Test.java: used to test if java compiler works. -dnl */ -dnl public class Test -dnl { -dnl -dnl public static void -dnl main( String[] argv ) -dnl { -dnl System.exit (0); -dnl } -dnl -dnl } -cat << \EOF > Test.uue -begin-base64 644 Test.class -yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE -bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 -bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s -YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG -aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB -AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB -AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= -==== -EOF -if $UUDECODE Test.uue; then - ac_cv_prog_uudecode_base64=yes -else - echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD - echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD - cat Test.uue >&AS_MESSAGE_LOG_FD - ac_cv_prog_uudecode_base64=no -fi -rm -f Test.uue]) -fi -if test x$ac_cv_prog_uudecode_base64 != xyes; then - rm -f Test.class - AC_MSG_WARN([I have to compile Test.class from scratch]) if test x$ac_cv_prog_javac_works = xno; then AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) fi if test x$ac_cv_prog_javac_works = x; then AX_PROG_JAVAC fi -fi AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ JAVA_TEST=Test.java CLASS_TEST=Test.class @@ -111,7 +70,6 @@ public static void main (String args[]) { } } EOF changequote([, ])dnl -if test x$ac_cv_prog_uudecode_base64 != xyes; then if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then : else @@ -119,7 +77,6 @@ if test x$ac_cv_prog_uudecode_base64 != xyes; then cat $JAVA_TEST >&AS_MESSAGE_LOG_FD AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) fi -fi if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then ac_cv_prog_java_works=yes else @@ -127,7 +84,7 @@ else cat $JAVA_TEST >&AS_MESSAGE_LOG_FD AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) fi -rm -fr $JAVA_TEST $CLASS_TEST Test.uue +rm -f $JAVA_TEST $CLASS_TEST ]) AC_PROVIDE([$0])dnl ] diff --git a/m4/ax_prog_javac.m4 b/m4/ax_prog_javac.m4 index d061243..8abb733 100644 --- a/m4/ax_prog_javac.m4 +++ b/m4/ax_prog_javac.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javac.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_javac.html # =========================================================================== # # SYNOPSIS @@ -49,7 +49,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -64,7 +64,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 7 +#serial 8 AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) AC_DEFUN([AX_PROG_JAVAC],[ diff --git a/m4/ax_prog_javac_works.m4 b/m4/ax_prog_javac_works.m4 index 7dfa1e3..9b48149 100644 --- a/m4/ax_prog_javac_works.m4 +++ b/m4/ax_prog_javac_works.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html # =========================================================================== # # SYNOPSIS @@ -32,7 +32,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -47,7 +47,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 6 +#serial 7 AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) AC_DEFUN([AX_PROG_JAVAC_WORKS],[ diff --git a/m4/ax_prog_javadoc.m4 b/m4/ax_prog_javadoc.m4 index bcb6045..b9fcea4 100644 --- a/m4/ax_prog_javadoc.m4 +++ b/m4/ax_prog_javadoc.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javadoc.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_javadoc.html # =========================================================================== # # SYNOPSIS @@ -38,7 +38,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 8 +#serial 9 AU_ALIAS([AC_PROG_JAVADOC], [AX_PROG_JAVADOC]) AC_DEFUN([AX_PROG_JAVADOC],[ diff --git a/m4/ax_prog_javah.m4 b/m4/ax_prog_javah.m4 index cefc616..935ec89 100644 --- a/m4/ax_prog_javah.m4 +++ b/m4/ax_prog_javah.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javah.html +# https://www.gnu.org/software/autoconf-archive/ax_prog_javah.html # =========================================================================== # # SYNOPSIS @@ -21,7 +21,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 8 +#serial 11 AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH]) AC_DEFUN([AX_PROG_JAVAH],[ @@ -30,19 +30,19 @@ AC_REQUIRE([AC_PROG_CPP])dnl AC_PATH_PROG(JAVAH,javah) AS_IF([test -n "$ac_cv_path_JAVAH"], [ - AC_TRY_CPP([#include ],,[ + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])],[],[ ac_save_CPPFLAGS="$CPPFLAGS" - _ACJAVAH_FOLLOW_SYMLINKS("$ac_cv_path_JAVAH") + _ACJAVAH_FOLLOW_SYMLINKS("$ac_cv_path_JAVAH") ax_prog_javah_bin_dir=`AS_DIRNAME([$_ACJAVAH_FOLLOWED])` ac_dir="`AS_DIRNAME([$ax_prog_javah_bin_dir])`/include" AS_CASE([$build_os], - [cygwin*], + [cygwin*|mingw*], [ac_machdep=win32], [ac_machdep=`AS_ECHO($build_os) | sed 's,[[-0-9]].*,,'`]) CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep" - AC_TRY_CPP([#include ], - ac_save_CPPFLAGS="$CPPFLAGS", - AC_MSG_WARN([unable to include ])) + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], + [ac_save_CPPFLAGS="$CPPFLAGS"], + [AC_MSG_WARN([unable to include ])]) CPPFLAGS="$ac_save_CPPFLAGS"]) ]) ]) diff --git a/m4/ax_try_compile_java.m4 b/m4/ax_try_compile_java.m4 index a8ed6b2..245c36c 100644 --- a/m4/ax_try_compile_java.m4 +++ b/m4/ax_try_compile_java.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html +# https://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html # =========================================================================== # # SYNOPSIS @@ -29,7 +29,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 8 +#serial 10 AU_ALIAS([AC_TRY_COMPILE_JAVA], [AX_TRY_COMPILE_JAVA]) AC_DEFUN([AX_TRY_COMPILE_JAVA],[ @@ -48,8 +48,8 @@ dnl Don't remove the temporary files here, so they can be examined. else echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD cat Test.java >&AS_MESSAGE_LOG_FD -ifelse([$4], , , [ rm -fr Test.java Test.class +ifelse([$4], , , [ rm -f Test.java Test.class $4 ])dnl fi -rm -fr Test.java Test.class]) +rm -f Test.java Test.class]) diff --git a/m4/ax_try_run_java.m4 b/m4/ax_try_run_java.m4 index c680f03..2ebb86d 100644 --- a/m4/ax_try_run_java.m4 +++ b/m4/ax_try_run_java.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_try_run_java.html +# https://www.gnu.org/software/autoconf-archive/ax_try_run_java.html # =========================================================================== # # SYNOPSIS @@ -29,7 +29,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 2 +#serial 3 AU_ALIAS([AC_TRY_RUN_JAVA], [AX_TRY_RUN_JAVA]) AC_DEFUN([AX_TRY_RUN_JAVA],[ -- cgit v0.12 From 4142d8b7d4ac48cffcc2b92af4a54352b329865b Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Thu, 4 Apr 2019 23:31:01 -0500 Subject: Move dataspace selection-specific coding to the callbacks as preparation for the H5Sencode changes. --- src/H5Sall.c | 44 +++++++++++++++++++++++------- src/H5Shyper.c | 84 +++++++++++++++++++++++++++++++++++++++++++-------------- src/H5Snone.c | 45 ++++++++++++++++++++++++------- src/H5Spkg.h | 3 +-- src/H5Spoint.c | 66 ++++++++++++++++++++++++++++++++++++--------- src/H5Sselect.c | 69 +++++------------------------------------------ 6 files changed, 194 insertions(+), 117 deletions(-) diff --git a/src/H5Sall.c b/src/H5Sall.c index 0aa2f05..9823d36 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -58,8 +58,7 @@ static herr_t H5S__all_release(H5S_t *space); static htri_t H5S__all_is_valid(const H5S_t *space); static hssize_t H5S__all_serial_size(const H5S_t *space); static herr_t H5S__all_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__all_deserialize(H5S_t *space, uint32_t version, uint8_t flags, - const uint8_t **p); +static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__all_offset(const H5S_t *space, hsize_t *off); static int H5S__all_unlim_dim(const H5S_t *space); @@ -648,10 +647,8 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S_all_deserialize(space, p) - H5S_t *space; IN/OUT: Dataspace pointer to place + H5S_t **space; IN/OUT: Dataspace pointer to place selection into - uint32_t version IN: Selection version - uint8_t flags IN: Selection flags uint8 **p; OUT: Pointer to buffer holding serialized selection. Will be advanced to end of serialized selection. @@ -666,22 +663,51 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__all_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags, - const uint8_t H5_ATTR_UNUSED **p) +H5S__all_deserialize(H5S_t **space, const uint8_t **p) { + uint32_t version; /* Version number */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC - HDassert(space); HDassert(p); HDassert(*p); + /* As part of the efforts to push all selection-type specific coding + to the callbacks, the coding for the allocation of a null dataspace + is moved from H5S_select_deserialize() in H5Sselect.c. + This is needed for decoding virtual layout in H5O__layout_decode() */ + + /* Allocate space if not provided */ + if(!*space) { + if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") + } /* end if */ + else + tmp_space = *space; + + /* Decode version */ + UINT32DECODE(*p, version); + + /* Skip over the remainder of the header */ + *p += 8; + /* Change to "all" selection */ - if(H5S_select_all(space, TRUE) < 0) + if(H5S_select_all(tmp_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + /* Return space to the caller if allocated */ + if(!*space) + *space = tmp_space; + done: + /* Free temporary space if not passed to caller (only happens on error) */ + if(!*space && tmp_space) + if(H5S_close(tmp_space) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_deserialize() */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 4cb5e28..0146bfd 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -95,8 +95,7 @@ static herr_t H5S__hyper_release(H5S_t *space); static htri_t H5S__hyper_is_valid(const H5S_t *space); static hssize_t H5S__hyper_serial_size(const H5S_t *space); static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__hyper_deserialize(H5S_t *space, uint32_t version, uint8_t flags, - const uint8_t **p); +static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset); static int H5S__hyper_unlim_dim(const H5S_t *space); @@ -3456,7 +3455,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p) { - uint8_t *pp; /* Local pointer for decoding */ + uint8_t *pp; /* Local pointer for encoding */ uint8_t *lenp; /* Pointer to length location for later storage */ uint32_t len = 0; /* Number of bytes used */ uint32_t version; /* Version number */ @@ -3636,10 +3635,8 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S__hyper_deserialize(space, p) - H5S_t *space; IN/OUT: Dataspace pointer to place + H5S_t **space; IN/OUT: Dataspace pointer to place selection into - uint32_t version IN: Selection version - uint8_t flags IN: Selection flags uint8 **p; OUT: Pointer to buffer holding serialized selection. Will be advanced to end of serialized selection. @@ -3654,27 +3651,65 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t flags, - const uint8_t **p) +H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) { - unsigned rank; /* Rank of points */ - const uint8_t *pp; /* Local pointer for decoding */ - hsize_t start[H5S_MAX_RANK]; /* Hyperslab start information */ - hsize_t block[H5S_MAX_RANK]; /* Hyperslab block information */ - unsigned u; /* Local counting variable */ - herr_t ret_value = FAIL; /* Return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + hsize_t dims[H5S_MAX_RANK]; /* Dimenion sizes */ + hsize_t start[H5S_MAX_RANK]; /* Hyperslab start information */ + hsize_t block[H5S_MAX_RANK]; /* Hyperslab block information */ + uint32_t version; /* Version number */ + uint8_t flags = 0; /* Flags */ + unsigned rank; /* Rank of points */ + const uint8_t *pp; /* Local pointer for decoding */ + unsigned u; /* Local counting variable */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC /* Check args */ - HDassert(space); HDassert(p); pp = (*p); HDassert(pp); - /* Deserialize slabs to select */ - /* (The header and rank have already beed decoded) */ - rank = space->extent.rank; /* Retrieve rank from space */ + /* As part of the efforts to push all selection-type specific coding + to the callbacks, the coding for the allocation of a null dataspace + is moved from H5S_select_deserialize() in H5Sselect.c to here. + This is needed for decoding virtual layout in H5O__layout_decode() */ + /* Allocate space if not provided */ + if(!*space) { + if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") + } /* end if */ + else + tmp_space = *space; + + /* Decode version */ + UINT32DECODE(pp, version); + + if(version >= (uint32_t)2) { + /* Decode flags */ + flags = *(pp)++; + + /* Skip over the remainder of the header */ + pp += 4; + } else + /* Skip over the remainder of the header */ + pp += 8; + + /* Decode the rank of the point selection */ + UINT32DECODE(pp,rank); + + if(!*space) { + /* Patch the rank of the allocated dataspace */ + (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); + if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") + } /* end if */ + else + /* Verify the rank of the provided dataspace */ + if(rank != tmp_space->extent.rank) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace") /* If there is an unlimited dimension, only encode opt_unlim_diminfo */ if(flags & H5S_SELECT_FLAG_UNLIM) { @@ -3695,7 +3730,7 @@ H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fl } /* end for */ /* Select the hyperslab to the current selection */ - if((ret_value = H5S_select_hyperslab(space, H5S_SELECT_SET, start, stride, count, block)) < 0) + if((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection") } /* end if */ else { @@ -3729,7 +3764,7 @@ H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fl *tblock = (*tend - *tstart) + 1; /* Select or add the hyperslab to the current selection */ - if((ret_value = H5S_select_hyperslab(space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, stride, count, block)) < 0) + if((ret_value = H5S_select_hyperslab(tmp_space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, stride, count, block)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection") } /* end for */ } /* end else */ @@ -3737,7 +3772,16 @@ H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fl /* Update decoding pointer */ *p = pp; + /* Return space to the caller if allocated */ + if(!*space) + *space = tmp_space; + done: + /* Free temporary space if not passed to caller (only happens on error) */ + if(!*space && tmp_space) + if(H5S_close(tmp_space) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_deserialize() */ diff --git a/src/H5Snone.c b/src/H5Snone.c index 86994dd..cae9a67 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -58,8 +58,7 @@ static herr_t H5S__none_release(H5S_t *space); static htri_t H5S__none_is_valid(const H5S_t *space); static hssize_t H5S__none_serial_size(const H5S_t *space); static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__none_deserialize(H5S_t *space, uint32_t version, uint8_t flags, - const uint8_t **p); +static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); static int H5S__none_unlim_dim(const H5S_t *space); @@ -602,10 +601,8 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S__none_deserialize(space, version, flags, p) - H5S_t *space; IN/OUT: Dataspace pointer to place + H5S_t **space; IN/OUT: Dataspace pointer to place selection into - uint32_t version IN: Selection version - uint8_t flags IN: Selection flags uint8 **p; OUT: Pointer to buffer holding serialized selection. Will be advanced to end of serialized selection. @@ -620,22 +617,50 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, - uint8_t H5_ATTR_UNUSED flags, const uint8_t H5_ATTR_UNUSED **p) +H5S__none_deserialize(H5S_t **space, const uint8_t **p) { - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + uint32_t version; /* Version number */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC - HDassert(space); HDassert(p); HDassert(*p); + /* As part of the efforts to push all selection-type specific coding + to the callbacks, the coding for the allocation of a null dataspace + is moved from H5S_select_deserialize() in H5Sselect.c to here. + This is needed for decoding virtual layout in H5O__layout_decode() */ + /* Allocate space if not provided */ + if(!*space) { + if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") + } /* end if */ + else + tmp_space = *space; + + /* Decode version */ + UINT32DECODE(*p, version); + + /* Skip over the remainder of the header */ + *p += 8; + /* Change to "none" selection */ - if(H5S_select_none(space) < 0) + if(H5S_select_none(tmp_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + /* Return space to the caller if allocated */ + if(!*space) + *space = tmp_space; + done: + /* Free temporary space if not passed to caller (only happens on error) */ + if(!*space && tmp_space) + if(H5S_close(tmp_space) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_deserialize() */ diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 0575f03..2918648 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -148,8 +148,7 @@ typedef hssize_t (*H5S_sel_serial_size_func_t)(const H5S_t *space); /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ typedef herr_t (*H5S_sel_serialize_func_t)(const H5S_t *space, uint8_t **p); /* Method to create selection from "serialized" form (a byte sequence suitable for storing on disk) */ -typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t *space, uint32_t version, uint8_t flags, - const uint8_t **p); +typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t **space, const uint8_t **p); /* Method to determine smallest n-D bounding box containing the current selection */ typedef herr_t (*H5S_sel_bounds_func_t)(const H5S_t *space, hsize_t *start, hsize_t *end); /* Method to determine linear offset of initial element in selection within dataspace */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index e62b48d..ac9c983 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -60,8 +60,7 @@ static herr_t H5S__point_release(H5S_t *space); static htri_t H5S__point_is_valid(const H5S_t *space); static hssize_t H5S__point_serial_size(const H5S_t *space); static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__point_deserialize(H5S_t *space, uint32_t version, uint8_t flags, - const uint8_t **p); +static herr_t H5S__point_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__point_offset(const H5S_t *space, hsize_t *off); static int H5S__point_unlim_dim(const H5S_t *space); @@ -988,7 +987,7 @@ static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p) { H5S_pnt_node_t *curr; /* Point information nodes */ - uint8_t *pp = (*p); /* Local pointer for decoding */ + uint8_t *pp; /* Local pointer for encoding */ uint8_t *lenp; /* Pointer to length location for later storage */ uint32_t len = 0; /* Number of bytes used */ unsigned u; /* Local counting variable */ @@ -998,6 +997,7 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) /* Check args */ HDassert(space); HDassert(p); + pp = (*p); HDassert(pp); /* Store the preamble information */ @@ -1045,10 +1045,8 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S__point_deserialize(space, p) - H5S_t *space; IN/OUT: Dataspace pointer to place + H5S_t **space; IN/OUT: Dataspace pointer to place selection into - uint32_t version IN: Selection version - uint8_t flags IN: Selection flags uint8 **p; OUT: Pointer to buffer holding serialized selection. Will be advanced to end of serialized selection. @@ -1063,11 +1061,14 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags, - const uint8_t **p) +H5S__point_deserialize(H5S_t **space, const uint8_t **p) { + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */ + uint32_t version; /* Version number */ hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ - const uint8_t *pp = (*p); /* Local pointer for decoding */ + const uint8_t *pp; /* Local pointer for decoding */ size_t num_elem = 0; /* Number of elements in selection */ unsigned rank; /* Rank of points */ unsigned i, j; /* local counting variables */ @@ -1076,13 +1077,43 @@ H5S__point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5 FUNC_ENTER_STATIC /* Check args */ - HDassert(space); HDassert(p); + pp = (*p); HDassert(pp); + /* As part of the efforts to push all selection-type specific coding + to the callbacks, the coding for the allocation of a null dataspace + is moved from H5S_select_deserialize() in H5Sselect.c to here. + This is needed for decoding virtual layout in H5O__layout_decode() */ + /* Allocate space if not provided */ + if(!*space) { + if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") + } /* end if */ + else + tmp_space = *space; + + /* Decode version */ + UINT32DECODE(pp, version); + + /* Skip over the remainder of the header */ + pp += 8; + + /* Decode the rank of the point selection */ + UINT32DECODE(pp,rank); + + if(!*space) { + /* Patch the rank of the allocated dataspace */ + (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); + if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") + } /* end if */ + else + /* Verify the rank of the provided dataspace */ + if(rank != tmp_space->extent.rank) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace") + /* Deserialize points to select */ - /* (The header and rank have already beed decoded) */ - rank = space->extent.rank; /* Retrieve rank from space */ UINT32DECODE(pp, num_elem); /* decode the number of points */ /* Allocate space for the coordinates */ @@ -1095,13 +1126,22 @@ H5S__point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5 UINT32DECODE(pp, *tcoord); /* Select points */ - if(H5S_select_elements(space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0) + if(H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Update decoding pointer */ *p = pp; + /* Return space to the caller if allocated */ + if(!*space) + *space = tmp_space; + done: + /* Free temporary space if not passed to caller (only happens on error) */ + if(!*space && tmp_space) + if(H5S_close(tmp_space) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + /* Free the coordinate array if necessary */ if(coord != NULL) H5MM_xfree(coord); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index ef38746..aaea203 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -544,101 +544,44 @@ H5S_select_valid(const H5S_t *space) herr_t H5S_select_deserialize(H5S_t **space, const uint8_t **p) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, either - *space or a newly allocated one */ uint32_t sel_type; /* Pointer to the selection type */ - uint32_t version; /* Version number */ - uint8_t flags = 0; /* Flags */ herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(space); - /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") - } /* end if */ - else - tmp_space = *space; + /* Selection-type specific coding is moved to the callbacks. */ /* Decode selection type */ UINT32DECODE(*p, sel_type); - /* Decode version */ - UINT32DECODE(*p, version); - - if(version >= (uint32_t)2) { - /* Decode flags */ - flags = *(*p)++; - - /* Check for unknown flags */ - if(flags & ~H5S_SELECT_FLAG_BITS) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection") - - /* Skip over the remainder of the header */ - *p += 4; - } /* end if */ - else - /* Skip over the remainder of the header */ - *p += 8; - - /* Decode and check or patch rank for point and hyperslab selections */ - if((sel_type == H5S_SEL_POINTS) || (sel_type == H5S_SEL_HYPERSLABS)) { - uint32_t rank; /* Rank of dataspace */ - - /* Decode the rank of the point selection */ - UINT32DECODE(*p,rank); - - if(!*space) { - hsize_t dims[H5S_MAX_RANK]; - - /* Patch the rank of the allocated dataspace */ - (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); - if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") - } /* end if */ - else - /* Verify the rank of the provided dataspace */ - if(rank != tmp_space->extent.rank) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace") - } /* end if */ - /* Make routine for selection type */ switch(sel_type) { case H5S_SEL_POINTS: /* Sequence of points selected */ - ret_value = (*H5S_sel_point->deserialize)(tmp_space, version, flags, p); + ret_value = (*H5S_sel_point->deserialize)(space, p); break; case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ - ret_value = (*H5S_sel_hyper->deserialize)(tmp_space, version, flags, p); + ret_value = (*H5S_sel_hyper->deserialize)(space, p); break; case H5S_SEL_ALL: /* Entire extent selected */ - ret_value = (*H5S_sel_all->deserialize)(tmp_space, version, flags, p); + ret_value = (*H5S_sel_all->deserialize)(space, p); break; case H5S_SEL_NONE: /* Nothing selected */ - ret_value = (*H5S_sel_none->deserialize)(tmp_space, version, flags, p); + ret_value = (*H5S_sel_none->deserialize)(space, p); break; default: break; } /* end switch */ + if(ret_value < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection") - /* Return space to the caller if allocated */ - if(!*space) - *space = tmp_space; - done: - /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_deserialize() */ -- cgit v0.12 From 7fe665ebff3e86aaf1eef92199f757a5c0d1fe80 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Fri, 5 Apr 2019 11:34:58 -0500 Subject: Fix for HDFFV-10271 hyperslab encoding incorrect length. --- src/H5Shyper.c | 1 + test/th5s.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 4cb5e28..2a5da1e 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -3507,6 +3507,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].count); UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].block); } /* end for */ + len += (4 * space->extent.rank * 8); } /* end if */ /* Check for a "regular" hyperslab selection */ else if(space->select.sel_info.hslab->diminfo_valid) { diff --git a/test/th5s.c b/test/th5s.c index 14f5de9..07d31ed 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -1325,6 +1325,84 @@ test_h5s_encode(void) /**************************************************************** ** +** test_h5s_encode_length(): +** Test to verify HDFFV-10271 is fixed. +** Verify that version 2 hyperslab encoding length is correct. +** +** See "RFC: H5Sencode/H5Sdecode Format Change" for the +** description of the encoding format. +** +****************************************************************/ +static void +test_h5s_encode_length(void) +{ + hid_t sid; /* Dataspace ID */ + hid_t decoded_sid; /* Dataspace ID from H5Sdecode2 */ + size_t sbuf_size=0; /* Buffer size for H5Sencode2/1 */ + unsigned char *sbuf=NULL; /* Buffer for H5Sencode2/1 */ + hsize_t dims[1] = {500}; /* Dimension size */ + hsize_t start, count, block, stride; /* Hyperslab selection specifications */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Version 2 Hyperslab Encoding Length is correct\n")); + + /* Create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Setting H5S_UNLIMITED in count will use version 2 for hyperslab encoding */ + start = 0; + stride = 10; + block = 4; + count = H5S_UNLIMITED; + + /* Set hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Encode simple data space in a buffer */ + ret = H5Sencode(sid, NULL, &sbuf_size); + CHECK(ret, FAIL, "H5Sencode"); + + /* Allocate the buffer */ + if(sbuf_size > 0) { + sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + CHECK(sbuf, NULL, "H5Sencode2"); + } + + /* Encode the dataspace */ + ret = H5Sencode(sid, sbuf, &sbuf_size); + CHECK(ret, FAIL, "H5Sencode"); + + /* Verify that length stored at this location in the buffer is correct */ + VERIFY((uint32_t)sbuf[40], 36, "Length for encoding version 2"); + VERIFY((uint32_t)sbuf[35], 2, "Hyperslab encoding version is 2"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid = H5Sdecode(sbuf); + CHECK(decoded_sid, FAIL, "H5Sdecode"); + + /* Verify that the original and the decoded dataspace are equal */ + VERIFY(H5Sget_select_npoints(sid), H5Sget_select_npoints(decoded_sid), "Compare npoints"); + + /* Close the decoded dataspace */ + ret = H5Sclose(decoded_sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Free the buffer */ + if(sbuf) + HDfree(sbuf); + + /* Close the original dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_encode_length() */ + + +/**************************************************************** +** ** test_h5s_scalar_write(): Test scalar H5S (dataspace) writing code. ** ****************************************************************/ @@ -2516,6 +2594,7 @@ test_h5s(void) test_h5s_null(); /* Test Null dataspace H5S code */ test_h5s_zero_dim(); /* Test dataspace with zero dimension size */ test_h5s_encode(); /* Test encoding and decoding */ + test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ test_h5s_scalar_write(); /* Test scalar H5S writing code */ test_h5s_scalar_read(); /* Test scalar H5S reading code */ -- cgit v0.12