From 211004898fffc575fc12dbaa6cc51d165669c3bd Mon Sep 17 00:00:00 2001 From: dmh Date: Wed, 9 Apr 2014 15:20:16 -0600 Subject: [PATCH] jna fixes --- CMakeLists.txt | 6 ++++++ configure.ac | 13 +++++++++++++ libsrc4/nc4file.c | 7 +++++++ ljna | 1 + wjna | 1 + 5 files changed, 28 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48b77641e..7b253b447 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -831,6 +831,12 @@ IF(ENABLE_FSYNC) SET(USE_FSYNC ON) ENDIF() +# Temporary +OPTION (ENABLE_JNA "Enable jna bug fix code." OFF) +IF(ENABLE_JNA) + SET(JNA ON) +ENDIF() + # Linux specific large file support flags. # Modelled after check in CMakeLists.txt for hdf5. OPTION(ENABLE_LARGE_FILE_SUPPORT "Enable large file support." ON) diff --git a/configure.ac b/configure.ac index d2265f644..ce317b7b7 100644 --- a/configure.ac +++ b/configure.ac @@ -950,6 +950,19 @@ AC_SUBST(HAS_PNETCDF,[$enable_pnetcdf]) AC_SUBST(HAS_HDF5,[$enable_netcdf_4]) AC_SUBST(HAS_SZLIB,[$nc_has_szlib]) +# temporary to deal with a JNA problem +AC_MSG_CHECKING([If compilation is for use with JNA]) +AC_ARG_ENABLE([jna], + [AS_HELP_STRING([--enable-jna], + [enable jna bug fix])], + [], + [enable_jna=no]) +test "x$enable_jna" = xno || enable_jna=yes +AC_MSG_RESULT($enable_jna) +if test "x$enable_jna" = xyes ; then +AC_DEFINE([JNA], [1], [if true, include JNA bug fix]) +fi + # Include some specifics for netcdf on windows. #AH_VERBATIM([_WIN32_STRICMP], AH_BOTTOM( diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index f57e5487a..1f712436a 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -1187,6 +1187,13 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) member_name = H5Tget_member_name(type->native_hdf_typeid, m); if (!member_name || strlen(member_name) > NC_MAX_NAME) return NC_EBADNAME; +#ifdef JNA +/* There appears to be a bug that is + causing malloc error. */ + member_name = strdup(member_name); + if(member_name == NULL) + return NC_ENOMEM; +#endif /*JNA*/ /* Offset in bytes on *this* platform. */ member_offset = H5Tget_member_offset(type->native_hdf_typeid, m); diff --git a/ljna b/ljna index 3af0f51ce..9b5a16853 100644 --- a/ljna +++ b/ljna @@ -16,6 +16,7 @@ FLAGS="--prefix ${PREFIX}" FLAGS="$FLAGS --disable-examples" FLAGS="$FLAGS --disable-utilities" FLAGS="$FLAGS --enable-shared" +#FLAGS="$FLAGS --enable-jna" export PATH export CC diff --git a/wjna b/wjna index e39a53b28..6e0ef8fb4 100644 --- a/wjna +++ b/wjna @@ -16,6 +16,7 @@ FLAGS="-DHDF5_DIR=${CPP}/cmake/hdf5 ${FLAGS}" FLAGS="-DENABLE_CONVERSION_WARNINGS=OFF ${FLAGS}" FLAGS="-DBUILD_UTILITIES=OFF ${FLAGS}" FLAGS="-DENABLE_EXAMPLES=OFF ${FLAGS}" +FLAGS="-DENABLE_JNA=ON ${FLAGS}" rm -fr ./build mkdir build